summaryrefslogtreecommitdiff
path: root/EDK/Foundation/Library
diff options
context:
space:
mode:
Diffstat (limited to 'EDK/Foundation/Library')
-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
826 files changed, 135912 insertions, 0 deletions
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