summaryrefslogtreecommitdiff
path: root/EdkModulePkg/Library
diff options
context:
space:
mode:
authorbbahnsen <bbahnsen@6f19259b-4bc3-4df7-8a09-765794883524>2006-04-21 22:54:32 +0000
committerbbahnsen <bbahnsen@6f19259b-4bc3-4df7-8a09-765794883524>2006-04-21 22:54:32 +0000
commit878ddf1fc3540a715f63594ed22b6929e881afb4 (patch)
treec56c44dac138137b510e1fba7c3efe5e4d84bea2 /EdkModulePkg/Library
downloadedk2-878ddf1fc3540a715f63594ed22b6929e881afb4.zip
edk2-878ddf1fc3540a715f63594ed22b6929e881afb4.tar.gz
edk2-878ddf1fc3540a715f63594ed22b6929e881afb4.tar.bz2
Initial import.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkModulePkg/Library')
-rw-r--r--EdkModulePkg/Library/BaseCustomDecompressLibNull/BaseCustomDecompressLibNull.c80
-rw-r--r--EdkModulePkg/Library/BaseCustomDecompressLibNull/BaseCustomDecompressLibNull.mbd30
-rw-r--r--EdkModulePkg/Library/BaseCustomDecompressLibNull/BaseCustomDecompressLibNull.msa45
-rw-r--r--EdkModulePkg/Library/BaseCustomDecompressLibNull/build.xml47
-rw-r--r--EdkModulePkg/Library/BaseUefiTianoDecompressLib/BaseUefiTianoDecompressLib.c887
-rw-r--r--EdkModulePkg/Library/BaseUefiTianoDecompressLib/BaseUefiTianoDecompressLib.mbd30
-rw-r--r--EdkModulePkg/Library/BaseUefiTianoDecompressLib/BaseUefiTianoDecompressLib.msa47
-rw-r--r--EdkModulePkg/Library/BaseUefiTianoDecompressLib/build.xml47
-rw-r--r--EdkModulePkg/Library/DxeCoreCustomDecompressLibFromHob/DxeCoreCustomDecompressLibFromHob.c105
-rw-r--r--EdkModulePkg/Library/DxeCoreCustomDecompressLibFromHob/DxeCoreCustomDecompressLibFromHob.mbd30
-rw-r--r--EdkModulePkg/Library/DxeCoreCustomDecompressLibFromHob/DxeCoreCustomDecompressLibFromHob.msa55
-rw-r--r--EdkModulePkg/Library/DxeCoreCustomDecompressLibFromHob/build.xml47
-rw-r--r--EdkModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c623
-rw-r--r--EdkModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.mbd29
-rw-r--r--EdkModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.msa70
-rw-r--r--EdkModulePkg/Library/DxeCorePerformanceLib/build.xml47
-rw-r--r--EdkModulePkg/Library/DxeCoreTianoDecompressLibFromHob/DxeCoreTianoDecompressLibFromHob.c106
-rw-r--r--EdkModulePkg/Library/DxeCoreTianoDecompressLibFromHob/DxeCoreTianoDecompressLibFromHob.mbd30
-rw-r--r--EdkModulePkg/Library/DxeCoreTianoDecompressLibFromHob/DxeCoreTianoDecompressLibFromHob.msa55
-rw-r--r--EdkModulePkg/Library/DxeCoreTianoDecompressLibFromHob/build.xml47
-rw-r--r--EdkModulePkg/Library/DxeCoreUefiDecompressLibFromHob/DxeCoreUefiDecompressLibFromHob.c105
-rw-r--r--EdkModulePkg/Library/DxeCoreUefiDecompressLibFromHob/DxeCoreUefiDecompressLibFromHob.mbd30
-rw-r--r--EdkModulePkg/Library/DxeCoreUefiDecompressLibFromHob/DxeCoreUefiDecompressLibFromHob.msa55
-rw-r--r--EdkModulePkg/Library/DxeCoreUefiDecompressLibFromHob/build.xml47
-rw-r--r--EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/DebugLib.c314
-rw-r--r--EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/EdkDxeDebugLibReportStatusCode.mbd30
-rw-r--r--EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/EdkDxeDebugLibReportStatusCode.msa69
-rw-r--r--EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/build.xml47
-rw-r--r--EdkModulePkg/Library/EdkDxePeCoffLoaderFromHobLib/EdkDxePeCoffLoaderFromHobLib.mbd30
-rw-r--r--EdkModulePkg/Library/EdkDxePeCoffLoaderFromHobLib/EdkDxePeCoffLoaderFromHobLib.msa50
-rw-r--r--EdkModulePkg/Library/EdkDxePeCoffLoaderFromHobLib/PeCoff.c38
-rw-r--r--EdkModulePkg/Library/EdkDxePeCoffLoaderFromHobLib/build.xml47
-rw-r--r--EdkModulePkg/Library/EdkDxePerformanceLib/DxePerformanceLib.c213
-rw-r--r--EdkModulePkg/Library/EdkDxePerformanceLib/EdkDxePerformanceLib.mbd29
-rw-r--r--EdkModulePkg/Library/EdkDxePerformanceLib/EdkDxePerformanceLib.msa62
-rw-r--r--EdkModulePkg/Library/EdkDxePerformanceLib/build.xml47
-rw-r--r--EdkModulePkg/Library/EdkDxePrintLib/EdkDxePrintLib.mbd30
-rw-r--r--EdkModulePkg/Library/EdkDxePrintLib/EdkDxePrintLib.msa49
-rw-r--r--EdkModulePkg/Library/EdkDxePrintLib/PrintLib.c145
-rw-r--r--EdkModulePkg/Library/EdkDxePrintLib/build.xml47
-rw-r--r--EdkModulePkg/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c258
-rw-r--r--EdkModulePkg/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c480
-rw-r--r--EdkModulePkg/Library/EdkDxeRuntimeDriverLib/EdkDxeRuntimeDriverLib.mbd30
-rw-r--r--EdkModulePkg/Library/EdkDxeRuntimeDriverLib/EdkDxeRuntimeDriverLib.msa69
-rw-r--r--EdkModulePkg/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeLib.c284
-rw-r--r--EdkModulePkg/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeService.c516
-rw-r--r--EdkModulePkg/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h30
-rw-r--r--EdkModulePkg/Library/EdkDxeRuntimeDriverLib/build.xml47
-rw-r--r--EdkModulePkg/Library/EdkDxeSalLib/EdkDxeSalLib.mbd30
-rw-r--r--EdkModulePkg/Library/EdkDxeSalLib/EdkDxeSalLib.msa58
-rw-r--r--EdkModulePkg/Library/EdkDxeSalLib/Ipf/AsmEsalServiceLib.s149
-rw-r--r--EdkModulePkg/Library/EdkDxeSalLib/Ipf/AsmIpfCpuCache.s88
-rw-r--r--EdkModulePkg/Library/EdkDxeSalLib/Ipf/EsalServiceLib.c199
-rw-r--r--EdkModulePkg/Library/EdkDxeSalLib/build.xml47
-rw-r--r--EdkModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.mbd30
-rw-r--r--EdkModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.msa74
-rw-r--r--EdkModulePkg/Library/EdkFvbServiceLib/Fvb.h31
-rw-r--r--EdkModulePkg/Library/EdkFvbServiceLib/Ia32/Fvb.c534
-rw-r--r--EdkModulePkg/Library/EdkFvbServiceLib/Ipf/Fvb.c324
-rw-r--r--EdkModulePkg/Library/EdkFvbServiceLib/build.xml47
-rw-r--r--EdkModulePkg/Library/EdkFvbServiceLib/x64/Fvb.c536
-rw-r--r--EdkModulePkg/Library/EdkGraphicsLib/EdkGraphicsLib.mbd30
-rw-r--r--EdkModulePkg/Library/EdkGraphicsLib/EdkGraphicsLib.msa61
-rw-r--r--EdkModulePkg/Library/EdkGraphicsLib/Graphics.c780
-rw-r--r--EdkModulePkg/Library/EdkGraphicsLib/build.xml47
-rw-r--r--EdkModulePkg/Library/EdkIfrSupportLib/EdkIfrSupportLib.mbd30
-rw-r--r--EdkModulePkg/Library/EdkIfrSupportLib/EdkIfrSupportLib.msa75
-rw-r--r--EdkModulePkg/Library/EdkIfrSupportLib/IfrCommon.c995
-rw-r--r--EdkModulePkg/Library/EdkIfrSupportLib/IfrOnTheFly.c972
-rw-r--r--EdkModulePkg/Library/EdkIfrSupportLib/IfrOpCodeCreation.c613
-rw-r--r--EdkModulePkg/Library/EdkIfrSupportLib/IfrVariable.c484
-rw-r--r--EdkModulePkg/Library/EdkIfrSupportLib/build.xml47
-rw-r--r--EdkModulePkg/Library/EdkMemoryStatusCodeLib/EdkMemoryStatusCodeLib.mbd30
-rw-r--r--EdkModulePkg/Library/EdkMemoryStatusCodeLib/EdkMemoryStatusCodeLib.msa63
-rw-r--r--EdkModulePkg/Library/EdkMemoryStatusCodeLib/MemoryStatusCode.c498
-rw-r--r--EdkModulePkg/Library/EdkMemoryStatusCodeLib/MemoryStatusCode.h94
-rw-r--r--EdkModulePkg/Library/EdkMemoryStatusCodeLib/build.xml47
-rw-r--r--EdkModulePkg/Library/EdkNullCustomizedDecompressLib/CustomizedDecompress.c109
-rw-r--r--EdkModulePkg/Library/EdkNullCustomizedDecompressLib/CustomizedDecompress.h95
-rw-r--r--EdkModulePkg/Library/EdkNullCustomizedDecompressLib/EdkNullCustomizedDecompressLib.mbd30
-rw-r--r--EdkModulePkg/Library/EdkNullCustomizedDecompressLib/EdkNullCustomizedDecompressLib.msa44
-rw-r--r--EdkModulePkg/Library/EdkNullCustomizedDecompressLib/build.xml47
-rw-r--r--EdkModulePkg/Library/EdkPeCoffLoaderLib/EdkPeCoffLoader.c112
-rw-r--r--EdkModulePkg/Library/EdkPeCoffLoaderLib/EdkPeCoffLoaderLib.mbd30
-rw-r--r--EdkModulePkg/Library/EdkPeCoffLoaderLib/EdkPeCoffLoaderLib.msa45
-rw-r--r--EdkModulePkg/Library/EdkPeCoffLoaderLib/build.xml47
-rw-r--r--EdkModulePkg/Library/EdkPeCoffLoaderX64Lib/EdkPeCoffLoaderX64.c940
-rw-r--r--EdkModulePkg/Library/EdkPeCoffLoaderX64Lib/EdkPeCoffLoaderX64Lib.mbd30
-rw-r--r--EdkModulePkg/Library/EdkPeCoffLoaderX64Lib/EdkPeCoffLoaderX64Lib.msa46
-rw-r--r--EdkModulePkg/Library/EdkPeCoffLoaderX64Lib/build.xml46
-rw-r--r--EdkModulePkg/Library/EdkPeiPerformanceLib/EdkPeiPerformanceLib.mbd29
-rw-r--r--EdkModulePkg/Library/EdkPeiPerformanceLib/EdkPeiPerformanceLib.msa61
-rw-r--r--EdkModulePkg/Library/EdkPeiPerformanceLib/PeiPerformanceLib.c315
-rw-r--r--EdkModulePkg/Library/EdkPeiPerformanceLib/build.xml47
-rw-r--r--EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.c397
-rw-r--r--EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.h130
-rw-r--r--EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.mbd30
-rw-r--r--EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.msa72
-rw-r--r--EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/build.xml47
-rw-r--r--EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/RtMemoryStatusCode.c188
-rw-r--r--EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/RtMemoryStatusCode.mbd30
-rw-r--r--EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/RtMemoryStatusCode.msa52
-rw-r--r--EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/build.xml47
-rw-r--r--EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/RtPlatformStatusCode.c130
-rw-r--r--EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/RtPlatformStatusCode.mbd30
-rw-r--r--EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/RtPlatformStatusCode.msa54
-rw-r--r--EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/build.xml47
-rw-r--r--EdkModulePkg/Library/EdkScsiLib/EdkScsiLib.mbd30
-rw-r--r--EdkModulePkg/Library/EdkScsiLib/EdkScsiLib.msa45
-rw-r--r--EdkModulePkg/Library/EdkScsiLib/ScsiLib.c651
-rw-r--r--EdkModulePkg/Library/EdkScsiLib/build.xml47
-rw-r--r--EdkModulePkg/Library/EdkUefiDebugLibConOut/DebugLib.c255
-rw-r--r--EdkModulePkg/Library/EdkUefiDebugLibConOut/EdkUefiDebugLibConOut.mbd30
-rw-r--r--EdkModulePkg/Library/EdkUefiDebugLibConOut/EdkUefiDebugLibConOut.msa69
-rw-r--r--EdkModulePkg/Library/EdkUefiDebugLibConOut/build.xml47
-rw-r--r--EdkModulePkg/Library/EdkUefiDebugLibStdErr/DebugLib.c255
-rw-r--r--EdkModulePkg/Library/EdkUefiDebugLibStdErr/EdkUefiDebugLibStdErr.mbd30
-rw-r--r--EdkModulePkg/Library/EdkUefiDebugLibStdErr/EdkUefiDebugLibStdErr.msa69
-rw-r--r--EdkModulePkg/Library/EdkUefiDebugLibStdErr/build.xml47
-rw-r--r--EdkModulePkg/Library/EdkUsbLib/EdkUsbLib.mbd30
-rw-r--r--EdkModulePkg/Library/EdkUsbLib/EdkUsbLib.msa46
-rw-r--r--EdkModulePkg/Library/EdkUsbLib/UsbDxeLib.c699
-rw-r--r--EdkModulePkg/Library/EdkUsbLib/build.xml47
-rw-r--r--EdkModulePkg/Library/EdkUsbLib/hid.c459
124 files changed, 18851 insertions, 0 deletions
diff --git a/EdkModulePkg/Library/BaseCustomDecompressLibNull/BaseCustomDecompressLibNull.c b/EdkModulePkg/Library/BaseCustomDecompressLibNull/BaseCustomDecompressLibNull.c
new file mode 100644
index 0000000..b165f47
--- /dev/null
+++ b/EdkModulePkg/Library/BaseCustomDecompressLibNull/BaseCustomDecompressLibNull.c
@@ -0,0 +1,80 @@
+/*++
+
+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:
+
+ BaseCustomDecompressLibNull.c
+
+Abstract:
+
+ NULL Custom Decompress Library
+
+--*/
+
+RETURN_STATUS
+EFIAPI
+CustomDecompressGetInfo (
+ IN CONST VOID *Source,
+ IN UINT32 SourceSize,
+ OUT UINT32 *DestinationSize,
+ OUT UINT32 *ScratchSize
+ )
+/*++
+
+Routine Description:
+
+ The internal implementation of *_DECOMPRESS_PROTOCOL.GetInfo().
+
+Arguments:
+
+ Source - The source buffer containing the compressed data.
+ SourceSize - The size of source buffer
+ DestinationSize - The size of destination buffer.
+ ScratchSize - The size of scratch buffer.
+
+Returns:
+
+ RETURN_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
+ RETURN_INVALID_PARAMETER - The source data is corrupted
+
+--*/
+{
+ return RETURN_UNSUPPORTED;
+}
+
+RETURN_STATUS
+EFIAPI
+CustomDecompress (
+ IN CONST VOID *Source,
+ IN OUT VOID *Destination,
+ IN OUT VOID *Scratch
+ )
+/*++
+
+Routine Description:
+
+ The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress().
+
+Arguments:
+
+ Source - The source buffer containing the compressed data.
+ Destination - The destination buffer to store the decompressed data
+ Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
+
+Returns:
+
+ RETURN_SUCCESS - Decompression is successfull
+ RETURN_INVALID_PARAMETER - The source data is corrupted
+
+--*/
+{
+ return RETURN_UNSUPPORTED;
+}
diff --git a/EdkModulePkg/Library/BaseCustomDecompressLibNull/BaseCustomDecompressLibNull.mbd b/EdkModulePkg/Library/BaseCustomDecompressLibNull/BaseCustomDecompressLibNull.mbd
new file mode 100644
index 0000000..0cbb341
--- /dev/null
+++ b/EdkModulePkg/Library/BaseCustomDecompressLibNull/BaseCustomDecompressLibNull.mbd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>BaseCustomDecompressLibNull</BaseName>
+ <Guid>e5566134-c75e-4ace-bad1-e23a3b335e30</Guid>
+ <Version>0</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Created>2006-03-12 17:09</Created>
+ <Modified>2006-03-19 15:18</Modified>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/BaseCustomDecompressLibNull/BaseCustomDecompressLibNull.msa b/EdkModulePkg/Library/BaseCustomDecompressLibNull/BaseCustomDecompressLibNull.msa
new file mode 100644
index 0000000..4dbc8a6
--- /dev/null
+++ b/EdkModulePkg/Library/BaseCustomDecompressLibNull/BaseCustomDecompressLibNull.msa
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>BaseCustomDecompressLibNull</BaseName>
+ <ModuleType>BASE</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>e5566134-c75e-4ace-bad1-e23a3b335e30</Guid>
+ <Version>0</Version>
+ <Abstract>Component description file for the entry point to a EFIDXE Drivers</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>0</Specification>
+ <Created>2006-03-12 17:09</Created>
+ <Updated>2006-03-19 15:18</Updated>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">CustomDecompressLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>BaseCustomDecompressLibNull.c</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/BaseCustomDecompressLibNull/build.xml b/EdkModulePkg/Library/BaseCustomDecompressLibNull/build.xml
new file mode 100644
index 0000000..d2f8ab4
--- /dev/null
+++ b/EdkModulePkg/Library/BaseCustomDecompressLibNull/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="BaseCustomDecompressLibNull"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\BaseCustomDecompressLibNull"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="BaseCustomDecompressLibNull">
+ <GenBuild baseName="BaseCustomDecompressLibNull" mbdFilename="${MODULE_DIR}\BaseCustomDecompressLibNull.mbd" msaFilename="${MODULE_DIR}\BaseCustomDecompressLibNull.msa"/>
+ </target>
+ <target depends="BaseCustomDecompressLibNull_clean" name="clean"/>
+ <target depends="BaseCustomDecompressLibNull_cleanall" name="cleanall"/>
+ <target name="BaseCustomDecompressLibNull_clean">
+ <OutputDirSetup baseName="BaseCustomDecompressLibNull" mbdFilename="${MODULE_DIR}\BaseCustomDecompressLibNull.mbd" msaFilename="${MODULE_DIR}\BaseCustomDecompressLibNull.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\BaseCustomDecompressLibNull_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\BaseCustomDecompressLibNull_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="BaseCustomDecompressLibNull_cleanall">
+ <OutputDirSetup baseName="BaseCustomDecompressLibNull" mbdFilename="${MODULE_DIR}\BaseCustomDecompressLibNull.mbd" msaFilename="${MODULE_DIR}\BaseCustomDecompressLibNull.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\BaseCustomDecompressLibNull_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\BaseCustomDecompressLibNull_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**BaseCustomDecompressLibNull*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/BaseUefiTianoDecompressLib/BaseUefiTianoDecompressLib.c b/EdkModulePkg/Library/BaseUefiTianoDecompressLib/BaseUefiTianoDecompressLib.c
new file mode 100644
index 0000000..bbf88f9
--- /dev/null
+++ b/EdkModulePkg/Library/BaseUefiTianoDecompressLib/BaseUefiTianoDecompressLib.c
@@ -0,0 +1,887 @@
+/*++
+
+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:
+
+ BaseUefiTianoDecompressLib.c
+
+Abstract:
+
+ UEFI and Tiano Decompress Library
+
+--*/
+
+//
+// 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;
+
+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;
+}
+
+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;
+}
+
+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;
+ volatile UINT16 Index;
+ UINT16 Len;
+ UINT16 Char;
+ UINT16 JuBits;
+ UINT16 Avail;
+ UINT16 NextCode;
+ UINT16 Mask;
+
+ for (Index = 1; Index <= 16; Index++) {
+ Count[Index] = 0;
+ }
+
+ for (Index = 0; Index < NumOfChar; Index++) {
+ Count[BitLen[Index]]++;
+ }
+
+ Start[1] = 0;
+
+ for (Index = 1; Index <= 16; Index++) {
+ Start[Index + 1] = (UINT16) (Start[Index] + (Count[Index] << (16 - Index)));
+ }
+
+ if (Start[17] != 0) {
+ /*(1U << 16)*/
+ return (UINT16) BAD_TABLE;
+ }
+
+ JuBits = (UINT16) (16 - TableBits);
+
+ for (Index = 1; Index <= TableBits; Index++) {
+ Start[Index] >>= JuBits;
+ Weight[Index] = (UINT16) (1U << (TableBits - Index));
+ }
+
+ while (Index <= 16) {
+ Weight[Index] = (UINT16) (1U << (16 - Index));
+ Index++;
+ }
+
+ Index = (UINT16) (Start[TableBits + 1] >> JuBits);
+
+ if (Index != 0) {
+ Index3 = (UINT16) (1U << TableBits);
+ while (Index != Index3) {
+ Table[Index++] = 0;
+ }
+ }
+
+ Avail = NumOfChar;
+ Mask = (UINT16) (1U << (15 - TableBits));
+
+ for (Char = 0; Char < NumOfChar; Char++) {
+
+ Len = BitLen[Char];
+ if (Len == 0) {
+ continue;
+ }
+
+ NextCode = (UINT16) (Start[Len] + Weight[Len]);
+
+ if (Len <= TableBits) {
+
+ for (Index = Start[Len]; Index < NextCode; Index++) {
+ Table[Index] = Char;
+ }
+
+ } else {
+
+ Index3 = Start[Len];
+ Pointer = &Table[Index3 >> JuBits];
+ Index = (UINT16) (Len - TableBits);
+
+ while (Index != 0) {
+ if (*Pointer == 0) {
+ Sd->mRight[Avail] = Sd->mLeft[Avail] = 0;
+ *Pointer = Avail++;
+ }
+
+ if (Index3 & Mask) {
+ Pointer = &Sd->mRight[*Pointer];
+ } else {
+ Pointer = &Sd->mLeft[*Pointer];
+ }
+
+ Index3 <<= 1;
+ Index--;
+ }
+
+ *Pointer = Char;
+
+ }
+
+ Start[Len] = NextCode;
+ }
+ //
+ // Succeeds
+ //
+ return 0;
+}
+
+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;
+}
+
+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;
+ volatile UINT16 Index;
+ UINT32 Mask;
+
+ Number = (UINT16) GetBits (Sd, nbit);
+
+ if (Number == 0) {
+ CharC = (UINT16) GetBits (Sd, nbit);
+
+ for (Index = 0; Index < 256; Index++) {
+ Sd->mPTTable[Index] = CharC;
+ }
+
+ for (Index = 0; Index < nn; Index++) {
+ Sd->mPTLen[Index] = 0;
+ }
+
+ return 0;
+ }
+
+ Index = 0;
+
+ while (Index < Number) {
+
+ CharC = (UINT16) (Sd->mBitBuf >> (BITBUFSIZ - 3));
+
+ if (CharC == 7) {
+ Mask = 1U << (BITBUFSIZ - 1 - 3);
+ while (Mask & Sd->mBitBuf) {
+ Mask >>= 1;
+ CharC += 1;
+ }
+ }
+
+ FillBuf (Sd, (UINT16) ((CharC < 7) ? 3 : CharC - 3));
+
+ Sd->mPTLen[Index++] = (UINT8) CharC;
+
+ if (Index == Special) {
+ CharC = (UINT16) GetBits (Sd, 2);
+ while ((INT16) (--CharC) >= 0) {
+ Sd->mPTLen[Index++] = 0;
+ }
+ }
+ }
+
+ while (Index < nn) {
+ Sd->mPTLen[Index++] = 0;
+ }
+
+ return MakeTable (Sd, nn, Sd->mPTLen, 8, Sd->mPTTable);
+}
+
+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;
+ volatile 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 ;
+}
+
+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;
+}
+
+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 ;
+}
+
+RETURN_STATUS
+EFIAPI
+UefiDecompressGetInfo (
+ IN CONST VOID *Source,
+ IN UINT32 SourceSize,
+ OUT UINT32 *DestinationSize,
+ OUT UINT32 *ScratchSize
+ )
+/*++
+
+Routine Description:
+
+ The internal implementation of *_DECOMPRESS_PROTOCOL.GetInfo().
+
+Arguments:
+
+ Source - The source buffer containing the compressed data.
+ SourceSize - The size of source buffer
+ DestinationSize - The size of destination buffer.
+ ScratchSize - The size of scratch buffer.
+
+Returns:
+
+ RETURN_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
+ RETURN_INVALID_PARAMETER - The source data is corrupted
+
+--*/
+{
+ 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;
+}
+
+RETURN_STATUS
+EFIAPI
+UefiTianoDecompress (
+ IN CONST VOID *Source,
+ IN OUT VOID *Destination,
+ IN OUT VOID *Scratch,
+ IN UINT32 Version
+ )
+/*++
+
+Routine Description:
+
+ The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress().
+
+Arguments:
+
+ Source - The source buffer containing the compressed data.
+ Destination - The destination buffer to store the decompressed data
+ Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
+ Version - 1 for UEFI Decompress algoruthm, 2 for Tiano Decompess algorithm
+
+Returns:
+
+ RETURN_SUCCESS - Decompression is successfull
+ RETURN_INVALID_PARAMETER - The source data is corrupted
+
+--*/
+{
+ 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
+ //
+ switch (Version) {
+ case 1 :
+ Sd->mPBit = 4;
+ break;
+ case 2 :
+ Sd->mPBit = 5;
+ break;
+ default:
+ ASSERT (FALSE);
+ }
+ Sd->mSrcBase = (UINT8 *)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
+ //
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ return RETURN_SUCCESS;
+}
+
+RETURN_STATUS
+EFIAPI
+UefiDecompress (
+ IN CONST VOID *Source,
+ IN OUT VOID *Destination,
+ IN OUT VOID *Scratch
+ )
+/*++
+
+Routine Description:
+
+ The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress().
+
+Arguments:
+
+ Source - The source buffer containing the compressed data.
+ Destination - The destination buffer to store the decompressed data
+ Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
+
+Returns:
+
+ RETURN_SUCCESS - Decompression is successfull
+ RETURN_INVALID_PARAMETER - The source data is corrupted
+
+--*/
+{
+ return UefiTianoDecompress (Source, Destination, Scratch, 1);
+}
+
+RETURN_STATUS
+EFIAPI
+TianoDecompressGetInfo (
+ IN CONST VOID *Source,
+ IN UINT32 SourceSize,
+ OUT UINT32 *DestinationSize,
+ OUT UINT32 *ScratchSize
+ )
+/*++
+
+Routine Description:
+
+ The internal implementation of *_DECOMPRESS_PROTOCOL.GetInfo().
+
+Arguments:
+
+ Source - The source buffer containing the compressed data.
+ SourceSize - The size of source buffer
+ DestinationSize - The size of destination buffer.
+ ScratchSize - The size of scratch buffer.
+
+Returns:
+
+ RETURN_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
+ RETURN_INVALID_PARAMETER - The source data is corrupted
+
+--*/
+{
+ return UefiDecompressGetInfo (Source, SourceSize, DestinationSize, ScratchSize);
+}
+
+RETURN_STATUS
+EFIAPI
+TianoDecompress (
+ IN CONST VOID *Source,
+ IN OUT VOID *Destination,
+ IN OUT VOID *Scratch
+ )
+/*++
+
+Routine Description:
+
+ The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress().
+
+Arguments:
+
+ Source - The source buffer containing the compressed data.
+ Destination - The destination buffer to store the decompressed data
+ Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
+
+Returns:
+
+ RETURN_SUCCESS - Decompression is successfull
+ RETURN_INVALID_PARAMETER - The source data is corrupted
+
+--*/
+{
+ return UefiTianoDecompress (Source, Destination, Scratch, 2);
+}
diff --git a/EdkModulePkg/Library/BaseUefiTianoDecompressLib/BaseUefiTianoDecompressLib.mbd b/EdkModulePkg/Library/BaseUefiTianoDecompressLib/BaseUefiTianoDecompressLib.mbd
new file mode 100644
index 0000000..684d8e6
--- /dev/null
+++ b/EdkModulePkg/Library/BaseUefiTianoDecompressLib/BaseUefiTianoDecompressLib.mbd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>BaseUefiTianoDecompressLib</BaseName>
+ <Guid>d774c4d9-c121-4da3-a5e2-0f317e3c630c</Guid>
+ <Version>0</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Created>2006-03-12 17:09</Created>
+ <Modified>2006-03-19 15:18</Modified>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/BaseUefiTianoDecompressLib/BaseUefiTianoDecompressLib.msa b/EdkModulePkg/Library/BaseUefiTianoDecompressLib/BaseUefiTianoDecompressLib.msa
new file mode 100644
index 0000000..89d574e
--- /dev/null
+++ b/EdkModulePkg/Library/BaseUefiTianoDecompressLib/BaseUefiTianoDecompressLib.msa
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>BaseUefiTianoDecompressLib</BaseName>
+ <ModuleType>BASE</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>d774c4d9-c121-4da3-a5e2-0f317e3c630c</Guid>
+ <Version>0</Version>
+ <Abstract>Component description file for the entry point to a EFIDXE Drivers</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>0</Specification>
+ <Created>2006-03-12 17:09</Created>
+ <Updated>2006-03-19 15:18</Updated>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">UefiDecompressLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_PRODUCED">TianoDecompressLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseMemoryLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>BaseUefiTianoDecompressLib.c</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/BaseUefiTianoDecompressLib/build.xml b/EdkModulePkg/Library/BaseUefiTianoDecompressLib/build.xml
new file mode 100644
index 0000000..9b8695b
--- /dev/null
+++ b/EdkModulePkg/Library/BaseUefiTianoDecompressLib/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="BaseUefiTianoDecompressLib"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\BaseUefiTianoDecompressLib"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="BaseUefiTianoDecompressLib">
+ <GenBuild baseName="BaseUefiTianoDecompressLib" mbdFilename="${MODULE_DIR}\BaseUefiTianoDecompressLib.mbd" msaFilename="${MODULE_DIR}\BaseUefiTianoDecompressLib.msa"/>
+ </target>
+ <target depends="BaseUefiTianoDecompressLib_clean" name="clean"/>
+ <target depends="BaseUefiTianoDecompressLib_cleanall" name="cleanall"/>
+ <target name="BaseUefiTianoDecompressLib_clean">
+ <OutputDirSetup baseName="BaseUefiTianoDecompressLib" mbdFilename="${MODULE_DIR}\BaseUefiTianoDecompressLib.mbd" msaFilename="${MODULE_DIR}\BaseUefiTianoDecompressLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\BaseUefiTianoDecompressLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\BaseUefiTianoDecompressLib_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="BaseUefiTianoDecompressLib_cleanall">
+ <OutputDirSetup baseName="BaseUefiTianoDecompressLib" mbdFilename="${MODULE_DIR}\BaseUefiTianoDecompressLib.mbd" msaFilename="${MODULE_DIR}\BaseUefiTianoDecompressLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\BaseUefiTianoDecompressLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\BaseUefiTianoDecompressLib_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**BaseUefiTianoDecompressLib*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/DxeCoreCustomDecompressLibFromHob/DxeCoreCustomDecompressLibFromHob.c b/EdkModulePkg/Library/DxeCoreCustomDecompressLibFromHob/DxeCoreCustomDecompressLibFromHob.c
new file mode 100644
index 0000000..300cc91
--- /dev/null
+++ b/EdkModulePkg/Library/DxeCoreCustomDecompressLibFromHob/DxeCoreCustomDecompressLibFromHob.c
@@ -0,0 +1,105 @@
+/*++
+
+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:
+
+ DxeCoreCustomDecompressLibFromHob.c
+
+Abstract:
+
+ Custom Decompress Library from HOBs
+
+--*/
+
+static DECOMPRESS_LIBRARY mCustomDecompress;
+
+EFI_STATUS
+DxeCoreCustomDecompressLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+
+Arguments:
+
+Returns:
+
+--*/
+{
+ EFI_HOB_GUID_TYPE *GuidHob;
+
+ GuidHob = GetFirstGuidHob (&gEfiCustomizedDecompressProtocolGuid);
+ ASSERT (GuidHob != NULL);
+ CopyMem (&mCustomDecompress, GET_GUID_HOB_DATA (GuidHob), sizeof (mCustomDecompress));
+ return EFI_SUCCESS;
+}
+
+RETURN_STATUS
+EFIAPI
+CustomDecompressGetInfo (
+ IN CONST VOID *Source,
+ IN UINT32 SourceSize,
+ OUT UINT32 *DestinationSize,
+ OUT UINT32 *ScratchSize
+ )
+/*++
+
+Routine Description:
+
+ The internal implementation of *_DECOMPRESS_PROTOCOL.GetInfo().
+
+Arguments:
+
+ Source - The source buffer containing the compressed data.
+ SourceSize - The size of source buffer
+ DestinationSize - The size of destination buffer.
+ ScratchSize - The size of scratch buffer.
+
+Returns:
+
+ RETURN_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
+ RETURN_INVALID_PARAMETER - The source data is corrupted
+
+--*/
+{
+ return mCustomDecompress.GetInfo (Source, SourceSize, DestinationSize, ScratchSize);
+}
+
+RETURN_STATUS
+EFIAPI
+CustomDecompress (
+ IN CONST VOID *Source,
+ IN OUT VOID *Destination,
+ IN OUT VOID *Scratch
+ )
+/*++
+
+Routine Description:
+
+ The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress().
+
+Arguments:
+
+ Source - The source buffer containing the compressed data.
+ Destination - The destination buffer to store the decompressed data
+ Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
+
+Returns:
+
+ RETURN_SUCCESS - Decompression is successfull
+ RETURN_INVALID_PARAMETER - The source data is corrupted
+
+--*/
+{
+ return mCustomDecompress.Decompress (Source, Destination, Scratch);
+}
diff --git a/EdkModulePkg/Library/DxeCoreCustomDecompressLibFromHob/DxeCoreCustomDecompressLibFromHob.mbd b/EdkModulePkg/Library/DxeCoreCustomDecompressLibFromHob/DxeCoreCustomDecompressLibFromHob.mbd
new file mode 100644
index 0000000..f183e5a
--- /dev/null
+++ b/EdkModulePkg/Library/DxeCoreCustomDecompressLibFromHob/DxeCoreCustomDecompressLibFromHob.mbd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>DxeCoreCustomDecompressLibFromHob</BaseName>
+ <Guid>942e0182-3e1d-47f9-92dc-4939d1a0ba00</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Created>2006-03-12 17:09</Created>
+ <Modified>2006-03-31 13:07</Modified>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/DxeCoreCustomDecompressLibFromHob/DxeCoreCustomDecompressLibFromHob.msa b/EdkModulePkg/Library/DxeCoreCustomDecompressLibFromHob/DxeCoreCustomDecompressLibFromHob.msa
new file mode 100644
index 0000000..e135047
--- /dev/null
+++ b/EdkModulePkg/Library/DxeCoreCustomDecompressLibFromHob/DxeCoreCustomDecompressLibFromHob.msa
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>DxeCoreCustomDecompressLibFromHob</BaseName>
+ <ModuleType>DXE_CORE</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>942e0182-3e1d-47f9-92dc-4939d1a0ba00</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Abstract>Component description file for the entry point to a EFIDXE Drivers</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>EFI_SPECIFICATION_VERSION 0x00000000</Specification>
+ <Created>2006-03-12 17:09</Created>
+ <Updated>2006-03-31 13:07</Updated>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">CustomDecompressLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">HobLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseMemoryLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>DxeCoreCustomDecompressLibFromHob.c</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+ <Protocols>
+ <Protocol Usage="ALWAYS_CONSUMED">CustomizedDecompress</Protocol>
+ </Protocols>
+ <Externs>
+ <Extern>
+ <Constructor>DxeCoreCustomDecompressLibConstructor</Constructor>
+ </Extern>
+ </Externs>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/DxeCoreCustomDecompressLibFromHob/build.xml b/EdkModulePkg/Library/DxeCoreCustomDecompressLibFromHob/build.xml
new file mode 100644
index 0000000..c8fb0f7
--- /dev/null
+++ b/EdkModulePkg/Library/DxeCoreCustomDecompressLibFromHob/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="DxeCoreCustomDecompressLibFromHob"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\DxeCoreCustomDecompressLibFromHob"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="DxeCoreCustomDecompressLibFromHob">
+ <GenBuild baseName="DxeCoreCustomDecompressLibFromHob" mbdFilename="${MODULE_DIR}\DxeCoreCustomDecompressLibFromHob.mbd" msaFilename="${MODULE_DIR}\DxeCoreCustomDecompressLibFromHob.msa"/>
+ </target>
+ <target depends="DxeCoreCustomDecompressLibFromHob_clean" name="clean"/>
+ <target depends="DxeCoreCustomDecompressLibFromHob_cleanall" name="cleanall"/>
+ <target name="DxeCoreCustomDecompressLibFromHob_clean">
+ <OutputDirSetup baseName="DxeCoreCustomDecompressLibFromHob" mbdFilename="${MODULE_DIR}\DxeCoreCustomDecompressLibFromHob.mbd" msaFilename="${MODULE_DIR}\DxeCoreCustomDecompressLibFromHob.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\DxeCoreCustomDecompressLibFromHob_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\DxeCoreCustomDecompressLibFromHob_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="DxeCoreCustomDecompressLibFromHob_cleanall">
+ <OutputDirSetup baseName="DxeCoreCustomDecompressLibFromHob" mbdFilename="${MODULE_DIR}\DxeCoreCustomDecompressLibFromHob.mbd" msaFilename="${MODULE_DIR}\DxeCoreCustomDecompressLibFromHob.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\DxeCoreCustomDecompressLibFromHob_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\DxeCoreCustomDecompressLibFromHob_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**DxeCoreCustomDecompressLibFromHob*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/EdkModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
new file mode 100644
index 0000000..c75ab85
--- /dev/null
+++ b/EdkModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
@@ -0,0 +1,623 @@
+/*++
+
+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:
+
+ DxeCorePerformance.c
+
+Abstract:
+
+ Support for measurement of DXE performance
+
+--*/
+
+//
+// Interface declarations for Performance Protocol.
+//
+/**
+ Adds a record at the end of the performance measurement log
+ that records the start time of a performance measurement.
+
+ Adds a record to the end of the performance measurement log
+ that contains the Handle, Token, and Module.
+ The end time of the new record must be set to zero.
+ If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
+ If TimeStamp is zero, the start time in the record is filled in with the value
+ read from the current time stamp.
+
+ @param Handle Pointer to environment specific context used
+ to identify the component being measured.
+ @param Token Pointer to a Null-terminated ASCII string
+ that identifies the component being measured.
+ @param Module Pointer to a Null-terminated ASCII string
+ that identifies the module being measured.
+ @param TimeStamp 64-bit time stamp.
+
+ @retval EFI_SUCCESS The data was read correctly from the device.
+ @retval EFI_OUT_OF_RESOURCES There are not enough resources to record the measurement.
+
+**/
+EFI_STATUS
+EFIAPI
+StartGauge (
+ IN CONST VOID *Handle, OPTIONAL
+ IN CONST CHAR8 *Token, OPTIONAL
+ IN CONST CHAR8 *Module, OPTIONAL
+ IN UINT64 TimeStamp
+ );
+
+/**
+ Searches the performance measurement log from the beginning of the log
+ for the first matching record that contains a zero end time and fills in a valid end time.
+
+ Searches the performance measurement log from the beginning of the log
+ for the first record that matches Handle, Token, and Module and has an end time value of zero.
+ If the record can not be found then return EFI_NOT_FOUND.
+ If the record is found and TimeStamp is not zero,
+ then the end time in the record is filled in with the value specified by TimeStamp.
+ If the record is found and TimeStamp is zero, then the end time in the matching record
+ is filled in with the current time stamp value.
+
+ @param Handle Pointer to environment specific context used
+ to identify the component being measured.
+ @param Token Pointer to a Null-terminated ASCII string
+ that identifies the component being measured.
+ @param Module Pointer to a Null-terminated ASCII string
+ that identifies the module being measured.
+ @param TimeStamp 64-bit time stamp.
+
+ @retval EFI_SUCCESS The end of the measurement was recorded.
+ @retval EFI_NOT_FOUND The specified measurement record could not be found.
+
+**/
+EFI_STATUS
+EFIAPI
+EndGauge (
+ IN CONST VOID *Handle, OPTIONAL
+ IN CONST CHAR8 *Token, OPTIONAL
+ IN CONST CHAR8 *Module, OPTIONAL
+ IN UINT64 TimeStamp
+ );
+
+/**
+ Retrieves a previously logged performance measurement.
+
+ Retrieves the performance log entry from the performance log specified by LogEntryKey.
+ If it stands for a valid entry, then EFI_SUCCESS is returned and
+ GaugeDataEntry stores the pointer to that entry.
+
+ @param LogEntryKey The key for the previous performance measurement log entry.
+ If 0, then the first performance measurement log entry is retrieved.
+ @param GaugeDataEntry The indirect pointer to the gauge data entry specified by LogEntryKey
+ if the retrieval is successful.
+
+ @retval EFI_SUCCESS The GuageDataEntry is successfuly found based on LogEntryKey.
+ @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equals to the total entry number).
+ @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (greater than the total entry number).
+ @retval EFI_INVALIDE_PARAMETER GaugeDataEntry is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+GetGauge (
+ IN UINTN LogEntryKey,
+ OUT GAUGE_DATA_ENTRY **GaugeDataEntry
+ );
+
+//
+// Definition for global variables.
+//
+STATIC GAUGE_DATA_HEADER *mGaugeData;
+STATIC UINT32 mMaxGaugeRecords;
+
+PERFORMANCE_PROTOCOL PerformanceInterface = {
+ StartGauge,
+ EndGauge,
+ GetGauge
+ };
+
+
+/**
+ Searches in the gauge array with keyword Handle, Token and Module.
+
+ This internal function searches for the gauge entry in the gauge array.
+ If there is an entry that exactly matches the given key word triple
+ and its end time stamp is zero, then the index of that gauge entry is returned;
+ otherwise, the the number of gauge entries in the array is returned.
+
+ @param Handle Pointer to environment specific context used
+ to identify the component being measured.
+ @param Token Pointer to a Null-terminated ASCII string
+ that identifies the component being measured.
+ @param Module Pointer to a Null-terminated ASCII string
+ that identifies the module being measured.
+
+ @retval The index of gauge entry in the array.
+
+**/
+UINT32
+InternalSearchForGaugeEntry (
+ IN CONST VOID *Handle, OPTIONAL
+ IN CONST CHAR8 *Token, OPTIONAL
+ IN CONST CHAR8 *Module OPTIONAL
+ )
+{
+ UINT32 Index;
+ UINT32 NumberOfEntries;
+ GAUGE_DATA_ENTRY *GaugeEntryArray;
+
+ if (Token == NULL) {
+ Token = "";
+ }
+ if (Module == NULL) {
+ Module = "";
+ }
+
+ NumberOfEntries = mGaugeData->NumberOfEntries;
+ GaugeEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);
+
+ for (Index = 0; Index < NumberOfEntries; Index++) {
+ if ((GaugeEntryArray[Index].Handle == (EFI_PHYSICAL_ADDRESS) (UINTN) Handle) &&
+ AsciiStrnCmp (GaugeEntryArray[Index].Token, Token, PEI_PERFORMANCE_STRING_LENGTH) == 0 &&
+ AsciiStrnCmp (GaugeEntryArray[Index].Module, Module, PEI_PERFORMANCE_STRING_LENGTH) == 0 &&
+ GaugeEntryArray[Index].EndTimeStamp == 0
+ ) {
+ break;
+ }
+ }
+
+ return Index;
+}
+
+/**
+ Adds a record at the end of the performance measurement log
+ that records the start time of a performance measurement.
+
+ Adds a record to the end of the performance measurement log
+ that contains the Handle, Token, and Module.
+ The end time of the new record must be set to zero.
+ If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
+ If TimeStamp is zero, the start time in the record is filled in with the value
+ read from the current time stamp.
+
+ @param Handle Pointer to environment specific context used
+ to identify the component being measured.
+ @param Token Pointer to a Null-terminated ASCII string
+ that identifies the component being measured.
+ @param Module Pointer to a Null-terminated ASCII string
+ that identifies the module being measured.
+ @param TimeStamp 64-bit time stamp.
+
+ @retval EFI_SUCCESS The data was read correctly from the device.
+ @retval EFI_OUT_OF_RESOURCES There are not enough resources to record the measurement.
+
+**/
+EFI_STATUS
+EFIAPI
+StartGauge (
+ IN CONST VOID *Handle, OPTIONAL
+ IN CONST CHAR8 *Token, OPTIONAL
+ IN CONST CHAR8 *Module, OPTIONAL
+ IN UINT64 TimeStamp
+ )
+{
+ GAUGE_DATA_ENTRY *GaugeEntryArray;
+ UINTN GaugeDataSize;
+ UINTN OldGaugeDataSize;
+ GAUGE_DATA_HEADER *OldGaugeData;
+ EFI_STATUS Status;
+ UINT32 Index;
+
+ Index = mGaugeData->NumberOfEntries;
+ if (Index >= mMaxGaugeRecords) {
+ //
+ // Try to enlarge the scale of gauge arrary.
+ //
+ OldGaugeData = mGaugeData;
+ OldGaugeDataSize = sizeof (GAUGE_DATA_HEADER) + sizeof (GAUGE_DATA_ENTRY) * mMaxGaugeRecords;
+ mMaxGaugeRecords *= 2;
+ GaugeDataSize = sizeof (GAUGE_DATA_HEADER) + sizeof (GAUGE_DATA_ENTRY) * mMaxGaugeRecords;
+ Status = gBS->AllocatePool (
+ EfiBootServicesData,
+ GaugeDataSize,
+ (VOID **) &mGaugeData
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ // Initialize new data arry and migrate old data one.
+ //
+ mGaugeData = ZeroMem (mGaugeData, GaugeDataSize);
+ mGaugeData = CopyMem (mGaugeData, OldGaugeData, OldGaugeDataSize);
+
+ gBS->FreePool (OldGaugeData);
+ }
+
+ GaugeEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);
+ GaugeEntryArray[Index].Handle = (EFI_PHYSICAL_ADDRESS) (UINTN) Handle;
+
+ if (Token != NULL) {
+ AsciiStrnCpy (GaugeEntryArray[Index].Token, Token, DXE_PERFORMANCE_STRING_LENGTH);
+ }
+ if (Module != NULL) {
+ AsciiStrnCpy (GaugeEntryArray[Index].Module, Module, DXE_PERFORMANCE_STRING_LENGTH);
+ }
+
+ if (TimeStamp == 0) {
+ TimeStamp = GetPerformanceCounter ();
+ }
+ GaugeEntryArray[Index].StartTimeStamp = TimeStamp;
+
+ mGaugeData->NumberOfEntries++;
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Searches the performance measurement log from the beginning of the log
+ for the first matching record that contains a zero end time and fills in a valid end time.
+
+ Searches the performance measurement log from the beginning of the log
+ for the first record that matches Handle, Token, and Module and has an end time value of zero.
+ If the record can not be found then return EFI_NOT_FOUND.
+ If the record is found and TimeStamp is not zero,
+ then the end time in the record is filled in with the value specified by TimeStamp.
+ If the record is found and TimeStamp is zero, then the end time in the matching record
+ is filled in with the current time stamp value.
+
+ @param Handle Pointer to environment specific context used
+ to identify the component being measured.
+ @param Token Pointer to a Null-terminated ASCII string
+ that identifies the component being measured.
+ @param Module Pointer to a Null-terminated ASCII string
+ that identifies the module being measured.
+ @param TimeStamp 64-bit time stamp.
+
+ @retval EFI_SUCCESS The end of the measurement was recorded.
+ @retval EFI_NOT_FOUND The specified measurement record could not be found.
+
+**/
+EFI_STATUS
+EFIAPI
+EndGauge (
+ IN CONST VOID *Handle, OPTIONAL
+ IN CONST CHAR8 *Token, OPTIONAL
+ IN CONST CHAR8 *Module, OPTIONAL
+ IN UINT64 TimeStamp
+ )
+{
+ GAUGE_DATA_ENTRY *GaugeEntryArray;
+ UINT32 Index;
+
+ if (TimeStamp == 0) {
+ TimeStamp = GetPerformanceCounter ();
+ }
+
+ Index = InternalSearchForGaugeEntry (Handle, Token, Module);
+ if (Index >= mGaugeData->NumberOfEntries) {
+ return EFI_NOT_FOUND;
+ }
+ GaugeEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);
+ GaugeEntryArray[Index].EndTimeStamp = TimeStamp;
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Retrieves a previously logged performance measurement.
+
+ Retrieves the performance log entry from the performance log specified by LogEntryKey.
+ If it stands for a valid entry, then EFI_SUCCESS is returned and
+ GaugeDataEntry stores the pointer to that entry.
+
+ @param LogEntryKey The key for the previous performance measurement log entry.
+ If 0, then the first performance measurement log entry is retrieved.
+ @param GaugeDataEntry The indirect pointer to the gauge data entry specified by LogEntryKey
+ if the retrieval is successful.
+
+ @retval EFI_SUCCESS The GuageDataEntry is successfuly found based on LogEntryKey.
+ @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equals to the total entry number).
+ @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (greater than the total entry number).
+ @retval EFI_INVALIDE_PARAMETER GaugeDataEntry is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+GetGauge (
+ IN UINTN LogEntryKey,
+ OUT GAUGE_DATA_ENTRY **GaugeDataEntry
+ )
+{
+ UINTN NumberOfEntries;
+ GAUGE_DATA_ENTRY *LogEntryArray;
+
+ NumberOfEntries = (UINTN) (mGaugeData->NumberOfEntries);
+ if (LogEntryKey > NumberOfEntries) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (LogEntryKey == NumberOfEntries) {
+ return EFI_NOT_FOUND;
+ }
+
+ LogEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);
+
+ if (GaugeDataEntry == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ *GaugeDataEntry = &LogEntryArray[LogEntryKey];
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Dumps all the PEI performance log to DXE performance gauge array.
+
+ This internal function dumps all the PEI performance log to the DXE performance gauge array.
+ It retrieves the optional GUID HOB for PEI performance and then saves the performance data
+ to DXE performance data structures.
+
+**/
+VOID
+InternalGetPeiPerformance (
+ VOID
+ )
+{
+ EFI_HOB_GUID_TYPE *GuidHob;
+ PEI_PERFORMANCE_LOG_HEADER *LogHob;
+ PEI_PERFORMANCE_LOG_ENTRY *LogEntryArray;
+ GAUGE_DATA_ENTRY *GaugeEntryArray;
+ UINT32 Index;
+ UINT32 NumberOfEntries;
+
+ NumberOfEntries = 0;
+ GaugeEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);
+
+ //
+ // Dump PEI Log Entries to DXE Guage Data structure.
+ //
+ GuidHob = GetFirstGuidHob (&gPeiPerformanceHobGuid);
+ if (GuidHob != NULL) {
+ LogHob = GET_GUID_HOB_DATA (GuidHob);
+ LogEntryArray = (PEI_PERFORMANCE_LOG_ENTRY *) (LogHob + 1);
+ GaugeEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);
+
+ NumberOfEntries = LogHob->NumberOfEntries;
+ for (Index = 0; Index < NumberOfEntries; Index++) {
+ GaugeEntryArray[Index].Handle = LogEntryArray[Index].Handle;
+ AsciiStrnCpy (GaugeEntryArray[Index].Token, LogEntryArray[Index].Token, DXE_PERFORMANCE_STRING_LENGTH);
+ AsciiStrnCpy (GaugeEntryArray[Index].Module, LogEntryArray[Index].Module, DXE_PERFORMANCE_STRING_LENGTH);
+ GaugeEntryArray[Index].StartTimeStamp = LogEntryArray[Index].StartTimeStamp;
+ GaugeEntryArray[Index].EndTimeStamp = LogEntryArray[Index].EndTimeStamp;
+ }
+ }
+ mGaugeData->NumberOfEntries = NumberOfEntries;
+}
+
+/**
+ The constructor function initializes Performance infrastructure for DXE phase.
+
+ The constructor function publishes Performance protocol, allocates memory to log DXE performance
+ and merges PEI performance data to DXE performance log.
+ It will ASSERT() if one of these operations 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
+DxeCorePerformanceLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
+ UINTN GaugeDataSize;
+
+ //
+ // Install the protocol interfaces.
+ //
+ Handle = NULL;
+ Status = gBS->InstallProtocolInterface (
+ &Handle,
+ &gPerformanceProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &PerformanceInterface
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ mMaxGaugeRecords = INIT_DXE_GAUGE_DATA_ENTRIES + MAX_PEI_PERFORMANCE_LOG_ENTRIES;
+ GaugeDataSize = sizeof (GAUGE_DATA_HEADER) + sizeof (GAUGE_DATA_ENTRY) * mMaxGaugeRecords;
+ Status = gBS->AllocatePool (
+ EfiBootServicesData,
+ GaugeDataSize,
+ (VOID **) &mGaugeData
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ ZeroMem (mGaugeData, GaugeDataSize);
+
+ InternalGetPeiPerformance ();
+
+ return Status;
+}
+
+/**
+ Adds a record at the end of the performance measurement log
+ that records the start time of a performance measurement.
+
+ Adds a record to the end of the performance measurement log
+ that contains the Handle, Token, and Module.
+ The end time of the new record must be set to zero.
+ If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
+ If TimeStamp is zero, the start time in the record is filled in with the value
+ read from the current time stamp.
+
+ @param Handle Pointer to environment specific context used
+ to identify the component being measured.
+ @param Token Pointer to a Null-terminated ASCII string
+ that identifies the component being measured.
+ @param Module Pointer to a Null-terminated ASCII string
+ that identifies the module being measured.
+ @param TimeStamp 64-bit time stamp.
+
+ @retval RETURN_SUCCESS The start of the measurement was recorded.
+ @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.
+
+**/
+RETURN_STATUS
+EFIAPI
+StartPerformanceMeasurement (
+ IN CONST VOID *Handle, OPTIONAL
+ IN CONST CHAR8 *Token, OPTIONAL
+ IN CONST CHAR8 *Module, OPTIONAL
+ IN UINT64 TimeStamp
+ )
+{
+ EFI_STATUS Status;
+
+ Status = StartGauge (Handle, Token, Module, TimeStamp);
+ return (RETURN_STATUS) Status;
+}
+
+/**
+ Searches the performance measurement log from the beginning of the log
+ for the first matching record that contains a zero end time and fills in a valid end time.
+
+ Searches the performance measurement log from the beginning of the log
+ for the first record that matches Handle, Token, and Module and has an end time value of zero.
+ If the record can not be found then return RETURN_NOT_FOUND.
+ If the record is found and TimeStamp is not zero,
+ then the end time in the record is filled in with the value specified by TimeStamp.
+ If the record is found and TimeStamp is zero, then the end time in the matching record
+ is filled in with the current time stamp value.
+
+ @param Handle Pointer to environment specific context used
+ to identify the component being measured.
+ @param Token Pointer to a Null-terminated ASCII string
+ that identifies the component being measured.
+ @param Module Pointer to a Null-terminated ASCII string
+ that identifies the module being measured.
+ @param TimeStamp 64-bit time stamp.
+
+ @retval RETURN_SUCCESS The end of the measurement was recorded.
+ @retval RETURN_NOT_FOUND The specified measurement record could not be found.
+
+**/
+RETURN_STATUS
+EFIAPI
+EndPerformanceMeasurement (
+ IN CONST VOID *Handle, OPTIONAL
+ IN CONST CHAR8 *Token, OPTIONAL
+ IN CONST CHAR8 *Module, OPTIONAL
+ IN UINT64 TimeStamp
+ )
+{
+ EFI_STATUS Status;
+
+ Status = EndGauge (Handle, Token, Module, TimeStamp);
+ return (RETURN_STATUS) Status;
+}
+
+/**
+ Retrieves a previously logged performance measurement.
+
+ Retrieves the performance log entry from the performance log
+ that immediately follows the log entry specified by LogEntryKey.
+ If LogEntryKey is zero, then the first entry from the performance log is returned.
+ If the log entry specified by LogEntryKey is the last entry in the performance log,
+ then 0 is returned. Otherwise, the performance log entry is returned in Handle,
+ Token, Module, StartTimeStamp, and EndTimeStamp.
+ The key for the current performance log entry is returned.
+
+ @param LogEntryKey The key for the previous performance measurement log entry.
+ If 0, then the first performance measurement log entry is retrieved.
+ @param Handle Pointer to environment specific context used
+ to identify the component being measured.
+ @param Token Pointer to a Null-terminated ASCII string
+ that identifies the component being measured.
+ @param Module Pointer to a Null-terminated ASCII string
+ that identifies the module being measured.
+ @param StartTimeStamp The 64-bit time stamp that was recorded when the measurement was started.
+ @param EndTimeStamp The 64-bit time stamp that was recorded when the measurement was ended.
+
+ @return The key for the current performance log entry.
+
+**/
+UINTN
+EFIAPI
+GetPerformanceMeasurement (
+ UINTN LogEntryKey,
+ OUT CONST VOID **Handle,
+ OUT CONST CHAR8 **Token,
+ OUT CONST CHAR8 **Module,
+ OUT UINT64 *StartTimeStamp,
+ OUT UINT64 *EndTimeStamp
+ )
+{
+ EFI_STATUS Status;
+ GAUGE_DATA_ENTRY *GaugeData;
+
+ ASSERT (Handle != NULL);
+ ASSERT (Token != NULL);
+ ASSERT (Module != NULL);
+ ASSERT (StartTimeStamp != NULL);
+ ASSERT (EndTimeStamp != NULL);
+
+ Status = GetGauge (LogEntryKey++, &GaugeData);
+
+ //
+ // Make sure that LogEntryKey is a valid log entry key,
+ //
+ ASSERT (Status != EFI_INVALID_PARAMETER);
+
+ if (EFI_ERROR (Status)) {
+ //
+ // The LogEntryKey is the last entry (equals to the total entry number).
+ //
+ return 0;
+ }
+
+ ASSERT (GaugeData != NULL);
+
+ *Handle = (VOID *) (UINTN) GaugeData->Handle;
+ *Token = GaugeData->Token;
+ *Module = GaugeData->Module;
+ *StartTimeStamp = GaugeData->StartTimeStamp;
+ *EndTimeStamp = GaugeData->EndTimeStamp;
+
+ return LogEntryKey;
+}
+
+/**
+ Returns TRUE if the performance measurement macros are enabled.
+
+ This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
+ PcdPerformanceLibraryPropertyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
+ PcdPerformanceLibraryPropertyMask is set.
+ @retval FALSE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
+ PcdPerformanceLibraryPropertyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+PerformanceMeasurementEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);
+}
diff --git a/EdkModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.mbd b/EdkModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.mbd
new file mode 100644
index 0000000..a8f235f
--- /dev/null
+++ b/EdkModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.mbd
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>DxeCorePerformanceLib</BaseName>
+ <Guid>D0F78BBF-0A30-4c63-8A48-0F618A4AFACD</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Created>2006-04-04 11:10</Created>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.msa b/EdkModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.msa
new file mode 100644
index 0000000..40ce308
--- /dev/null
+++ b/EdkModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.msa
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>DxeCorePerformanceLib</BaseName>
+ <ModuleType>DXE_CORE</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>D0F78BBF-0A30-4c63-8A48-0F618A4AFACD</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Abstract>Component description file for the Tiano Decompress Library</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>EFI_SPECIFICATION_VERSION 0x00000000</Specification>
+ <Created>2006-04-04 11:10</Created>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">PerformanceLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">HobLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseMemoryLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">TimerLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PcdLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>DxeCorePerformanceLib.c</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+ <Protocols>
+ <Protocol Usage="ALWAYS_PRODUCED">Performance</Protocol>
+ </Protocols>
+ <Guids>
+ <GuidEntry Usage="ALWAYS_CONSUMED">
+ <C_Name>PeiPerformanceHob</C_Name>
+ </GuidEntry>
+ </Guids>
+ <Externs>
+ <Extern>
+ <Constructor>DxeCorePerformanceLibConstructor</Constructor>
+ </Extern>
+ </Externs>
+ <PCDs>
+ <PcdData ItemType="FIXED_AT_BUILD">
+ <C_Name>PcdPerformanceLibraryPropertyMask</C_Name>
+ <Token>0x00000001</Token>
+ <DatumType>UINT8</DatumType>
+ </PcdData>
+ </PCDs>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/DxeCorePerformanceLib/build.xml b/EdkModulePkg/Library/DxeCorePerformanceLib/build.xml
new file mode 100644
index 0000000..b9d04ee
--- /dev/null
+++ b/EdkModulePkg/Library/DxeCorePerformanceLib/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="DxeCorePerformanceLib"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\DxeCorePerformanceLib"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="DxeCorePerformanceLib">
+ <GenBuild baseName="DxeCorePerformanceLib" mbdFilename="${MODULE_DIR}\DxeCorePerformanceLib.mbd" msaFilename="${MODULE_DIR}\DxeCorePerformanceLib.msa"/>
+ </target>
+ <target depends="DxeCorePerformanceLib_clean" name="clean"/>
+ <target depends="DxeCorePerformanceLib_cleanall" name="cleanall"/>
+ <target name="DxeCorePerformanceLib_clean">
+ <OutputDirSetup baseName="DxeCorePerformanceLib" mbdFilename="${MODULE_DIR}\DxeCorePerformanceLib.mbd" msaFilename="${MODULE_DIR}\DxeCorePerformanceLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\DxeCorePerformanceLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\DxeCorePerformanceLib_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="DxeCorePerformanceLib_cleanall">
+ <OutputDirSetup baseName="DxeCorePerformanceLib" mbdFilename="${MODULE_DIR}\DxeCorePerformanceLib.mbd" msaFilename="${MODULE_DIR}\DxeCorePerformanceLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\DxeCorePerformanceLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\DxeCorePerformanceLib_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**DxeCorePerformanceLib*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/DxeCoreTianoDecompressLibFromHob/DxeCoreTianoDecompressLibFromHob.c b/EdkModulePkg/Library/DxeCoreTianoDecompressLibFromHob/DxeCoreTianoDecompressLibFromHob.c
new file mode 100644
index 0000000..1bb832b
--- /dev/null
+++ b/EdkModulePkg/Library/DxeCoreTianoDecompressLibFromHob/DxeCoreTianoDecompressLibFromHob.c
@@ -0,0 +1,106 @@
+/*++
+
+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:
+
+ DxeCoreTianoDecompressLibFromHob.c
+
+Abstract:
+
+ Tiano Decompress Library from HOBs
+
+--*/
+
+static DECOMPRESS_LIBRARY mTianoDecompress;
+
+EFI_STATUS
+DxeCoreTianoDecompressLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+
+Arguments:
+
+Returns:
+
+--*/
+{
+ EFI_HOB_GUID_TYPE *GuidHob;
+
+ GuidHob = GetFirstGuidHob (&gEfiTianoDecompressProtocolGuid);
+ ASSERT (GuidHob != NULL);
+ CopyMem (&mTianoDecompress, GET_GUID_HOB_DATA (GuidHob), sizeof (mTianoDecompress));
+ return EFI_SUCCESS;
+}
+
+RETURN_STATUS
+EFIAPI
+TianoDecompressGetInfo (
+ IN CONST VOID *Source,
+ IN UINT32 SourceSize,
+ OUT UINT32 *DestinationSize,
+ OUT UINT32 *ScratchSize
+ )
+/*++
+
+Routine Description:
+
+ The internal implementation of *_DECOMPRESS_PROTOCOL.GetInfo().
+
+Arguments:
+
+ Source - The source buffer containing the compressed data.
+ SourceSize - The size of source buffer
+ DestinationSize - The size of destination buffer.
+ ScratchSize - The size of scratch buffer.
+
+Returns:
+
+ RETURN_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
+ RETURN_INVALID_PARAMETER - The source data is corrupted
+
+--*/
+{
+ return mTianoDecompress.GetInfo (Source, SourceSize, DestinationSize, ScratchSize);
+}
+
+RETURN_STATUS
+EFIAPI
+TianoDecompress (
+ IN CONST VOID *Source,
+ IN OUT VOID *Destination,
+ IN OUT VOID *Scratch
+ )
+/*++
+
+Routine Description:
+
+ The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress().
+
+Arguments:
+
+ Source - The source buffer containing the compressed data.
+ Destination - The destination buffer to store the decompressed data
+ Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
+
+Returns:
+
+ RETURN_SUCCESS - Decompression is successfull
+ RETURN_INVALID_PARAMETER - The source data is corrupted
+
+--*/
+{
+ return mTianoDecompress.Decompress (Source, Destination, Scratch);
+}
+
diff --git a/EdkModulePkg/Library/DxeCoreTianoDecompressLibFromHob/DxeCoreTianoDecompressLibFromHob.mbd b/EdkModulePkg/Library/DxeCoreTianoDecompressLibFromHob/DxeCoreTianoDecompressLibFromHob.mbd
new file mode 100644
index 0000000..f3ca9a4
--- /dev/null
+++ b/EdkModulePkg/Library/DxeCoreTianoDecompressLibFromHob/DxeCoreTianoDecompressLibFromHob.mbd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>DxeCoreTianoDecompressLibFromHob</BaseName>
+ <Guid>cef487a1-751d-4fe0-a39b-e6892b4610c8</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Created>2006-03-12 17:09</Created>
+ <Modified>2006-03-31 13:10</Modified>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/DxeCoreTianoDecompressLibFromHob/DxeCoreTianoDecompressLibFromHob.msa b/EdkModulePkg/Library/DxeCoreTianoDecompressLibFromHob/DxeCoreTianoDecompressLibFromHob.msa
new file mode 100644
index 0000000..bf49ef5
--- /dev/null
+++ b/EdkModulePkg/Library/DxeCoreTianoDecompressLibFromHob/DxeCoreTianoDecompressLibFromHob.msa
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>DxeCoreTianoDecompressLibFromHob</BaseName>
+ <ModuleType>DXE_CORE</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>cef487a1-751d-4fe0-a39b-e6892b4610c8</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Abstract>Component description file for the entry point to a EFIDXE Drivers</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>EFI_SPECIFICATION_VERSION 0x00000000</Specification>
+ <Created>2006-03-12 17:09</Created>
+ <Updated>2006-03-31 13:10</Updated>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">TianoDecompressLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">HobLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseMemoryLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>DxeCoreTianoDecompressLibFromHob.c</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+ <Protocols>
+ <Protocol Usage="ALWAYS_CONSUMED">TianoDecompress</Protocol>
+ </Protocols>
+ <Externs>
+ <Extern>
+ <Constructor>DxeCoreTianoDecompressLibConstructor</Constructor>
+ </Extern>
+ </Externs>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/DxeCoreTianoDecompressLibFromHob/build.xml b/EdkModulePkg/Library/DxeCoreTianoDecompressLibFromHob/build.xml
new file mode 100644
index 0000000..095b92e
--- /dev/null
+++ b/EdkModulePkg/Library/DxeCoreTianoDecompressLibFromHob/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="DxeCoreTianoDecompressLibFromHob"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\DxeCoreTianoDecompressLibFromHob"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="DxeCoreTianoDecompressLibFromHob">
+ <GenBuild baseName="DxeCoreTianoDecompressLibFromHob" mbdFilename="${MODULE_DIR}\DxeCoreTianoDecompressLibFromHob.mbd" msaFilename="${MODULE_DIR}\DxeCoreTianoDecompressLibFromHob.msa"/>
+ </target>
+ <target depends="DxeCoreTianoDecompressLibFromHob_clean" name="clean"/>
+ <target depends="DxeCoreTianoDecompressLibFromHob_cleanall" name="cleanall"/>
+ <target name="DxeCoreTianoDecompressLibFromHob_clean">
+ <OutputDirSetup baseName="DxeCoreTianoDecompressLibFromHob" mbdFilename="${MODULE_DIR}\DxeCoreTianoDecompressLibFromHob.mbd" msaFilename="${MODULE_DIR}\DxeCoreTianoDecompressLibFromHob.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\DxeCoreTianoDecompressLibFromHob_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\DxeCoreTianoDecompressLibFromHob_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="DxeCoreTianoDecompressLibFromHob_cleanall">
+ <OutputDirSetup baseName="DxeCoreTianoDecompressLibFromHob" mbdFilename="${MODULE_DIR}\DxeCoreTianoDecompressLibFromHob.mbd" msaFilename="${MODULE_DIR}\DxeCoreTianoDecompressLibFromHob.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\DxeCoreTianoDecompressLibFromHob_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\DxeCoreTianoDecompressLibFromHob_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**DxeCoreTianoDecompressLibFromHob*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/DxeCoreUefiDecompressLibFromHob/DxeCoreUefiDecompressLibFromHob.c b/EdkModulePkg/Library/DxeCoreUefiDecompressLibFromHob/DxeCoreUefiDecompressLibFromHob.c
new file mode 100644
index 0000000..b4bd539
--- /dev/null
+++ b/EdkModulePkg/Library/DxeCoreUefiDecompressLibFromHob/DxeCoreUefiDecompressLibFromHob.c
@@ -0,0 +1,105 @@
+/*++
+
+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:
+
+ DxeCoreUefiDecompressLibFromHob.c
+
+Abstract:
+
+ UEFI Decompress Library from HOBs
+
+--*/
+
+static DECOMPRESS_LIBRARY mEfiDecompress;
+
+EFI_STATUS
+DxeCoreUefiDecompressLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+
+Arguments:
+
+Returns:
+
+--*/
+{
+ EFI_HOB_GUID_TYPE *GuidHob;
+
+ GuidHob = GetFirstGuidHob (&gEfiDecompressProtocolGuid);
+ ASSERT (GuidHob != NULL);
+ CopyMem (&mEfiDecompress, GET_GUID_HOB_DATA (GuidHob), sizeof (mEfiDecompress));
+ return EFI_SUCCESS;
+}
+
+RETURN_STATUS
+EFIAPI
+UefiDecompressGetInfo (
+ IN CONST VOID *Source,
+ IN UINT32 SourceSize,
+ OUT UINT32 *DestinationSize,
+ OUT UINT32 *ScratchSize
+ )
+/*++
+
+Routine Description:
+
+ The internal implementation of *_DECOMPRESS_PROTOCOL.GetInfo().
+
+Arguments:
+
+ Source - The source buffer containing the compressed data.
+ SourceSize - The size of source buffer
+ DestinationSize - The size of destination buffer.
+ ScratchSize - The size of scratch buffer.
+
+Returns:
+
+ RETURN_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
+ RETURN_INVALID_PARAMETER - The source data is corrupted
+
+--*/
+{
+ return mEfiDecompress.GetInfo (Source, SourceSize, DestinationSize, ScratchSize);
+}
+
+RETURN_STATUS
+EFIAPI
+UefiDecompress (
+ IN CONST VOID *Source,
+ IN OUT VOID *Destination,
+ IN OUT VOID *Scratch
+ )
+/*++
+
+Routine Description:
+
+ The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress().
+
+Arguments:
+
+ Source - The source buffer containing the compressed data.
+ Destination - The destination buffer to store the decompressed data
+ Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
+
+Returns:
+
+ RETURN_SUCCESS - Decompression is successfull
+ RETURN_INVALID_PARAMETER - The source data is corrupted
+
+--*/
+{
+ return mEfiDecompress.Decompress (Source, Destination, Scratch);
+}
diff --git a/EdkModulePkg/Library/DxeCoreUefiDecompressLibFromHob/DxeCoreUefiDecompressLibFromHob.mbd b/EdkModulePkg/Library/DxeCoreUefiDecompressLibFromHob/DxeCoreUefiDecompressLibFromHob.mbd
new file mode 100644
index 0000000..5bb0b93
--- /dev/null
+++ b/EdkModulePkg/Library/DxeCoreUefiDecompressLibFromHob/DxeCoreUefiDecompressLibFromHob.mbd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>DxeCoreUefiDecompressLibFromHob</BaseName>
+ <Guid>5c12c06f-5cf8-48a6-9860-6c5b2c036bbf</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Created>2006-03-12 17:09</Created>
+ <Modified>2006-03-31 13:10</Modified>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/DxeCoreUefiDecompressLibFromHob/DxeCoreUefiDecompressLibFromHob.msa b/EdkModulePkg/Library/DxeCoreUefiDecompressLibFromHob/DxeCoreUefiDecompressLibFromHob.msa
new file mode 100644
index 0000000..895b86c
--- /dev/null
+++ b/EdkModulePkg/Library/DxeCoreUefiDecompressLibFromHob/DxeCoreUefiDecompressLibFromHob.msa
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>DxeCoreUefiDecompressLibFromHob</BaseName>
+ <ModuleType>DXE_CORE</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>5c12c06f-5cf8-48a6-9860-6c5b2c036bbf</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Abstract>Component description file for the entry point to a EFIDXE Drivers</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>EFI_SPECIFICATION_VERSION 0x00000000</Specification>
+ <Created>2006-03-12 17:09</Created>
+ <Updated>2006-03-31 13:10</Updated>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">UefiDecompressLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">HobLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseMemoryLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>DxeCoreUefiDecompressLibFromHob.c</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+ <Protocols>
+ <Protocol Usage="ALWAYS_CONSUMED">Decompress</Protocol>
+ </Protocols>
+ <Externs>
+ <Extern>
+ <Constructor>DxeCoreUefiDecompressLibConstructor</Constructor>
+ </Extern>
+ </Externs>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/DxeCoreUefiDecompressLibFromHob/build.xml b/EdkModulePkg/Library/DxeCoreUefiDecompressLibFromHob/build.xml
new file mode 100644
index 0000000..b46ad56
--- /dev/null
+++ b/EdkModulePkg/Library/DxeCoreUefiDecompressLibFromHob/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="DxeCoreUefiDecompressLibFromHob"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\DxeCoreUefiDecompressLibFromHob"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="DxeCoreUefiDecompressLibFromHob">
+ <GenBuild baseName="DxeCoreUefiDecompressLibFromHob" mbdFilename="${MODULE_DIR}\DxeCoreUefiDecompressLibFromHob.mbd" msaFilename="${MODULE_DIR}\DxeCoreUefiDecompressLibFromHob.msa"/>
+ </target>
+ <target depends="DxeCoreUefiDecompressLibFromHob_clean" name="clean"/>
+ <target depends="DxeCoreUefiDecompressLibFromHob_cleanall" name="cleanall"/>
+ <target name="DxeCoreUefiDecompressLibFromHob_clean">
+ <OutputDirSetup baseName="DxeCoreUefiDecompressLibFromHob" mbdFilename="${MODULE_DIR}\DxeCoreUefiDecompressLibFromHob.mbd" msaFilename="${MODULE_DIR}\DxeCoreUefiDecompressLibFromHob.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\DxeCoreUefiDecompressLibFromHob_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\DxeCoreUefiDecompressLibFromHob_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="DxeCoreUefiDecompressLibFromHob_cleanall">
+ <OutputDirSetup baseName="DxeCoreUefiDecompressLibFromHob" mbdFilename="${MODULE_DIR}\DxeCoreUefiDecompressLibFromHob.mbd" msaFilename="${MODULE_DIR}\DxeCoreUefiDecompressLibFromHob.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\DxeCoreUefiDecompressLibFromHob_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\DxeCoreUefiDecompressLibFromHob_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**DxeCoreUefiDecompressLibFromHob*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/DebugLib.c b/EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/DebugLib.c
new file mode 100644
index 0000000..5a7300f
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/DebugLib.c
@@ -0,0 +1,314 @@
+/*++
+
+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:
+
+ DebugLib.c
+
+Abstract:
+
+ EFI Debug Library
+
+--*/
+
+static BOOLEAN mDebugLevelInstalled = FALSE;
+static EFI_DEBUG_LEVEL_PROTOCOL mDebugLevel = { 0 };
+
+EFI_STATUS
+DebugLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+
+Arguments:
+
+Returns:
+
+--*/
+{
+ EFI_STATUS Status;
+
+ //
+ // Initialize Debug Level Protocol
+ //
+ mDebugLevel.DebugLevel = PcdGet32(PcdDebugPrintErrorLevel);
+
+ //
+ // Install Debug Level Protocol
+ //
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &ImageHandle,
+ &gEfiDebugLevelProtocolGuid, &mDebugLevel,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Set flag to show that the Debug Level Protocol has been installed
+ //
+ mDebugLevelInstalled = TRUE;
+
+ return EFI_SUCCESS;
+}
+
+VOID
+EFIAPI
+DebugAssert (
+ 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 CpuBreakpoint ().
+
+ 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 / sizeof(UINT64)];
+ EFI_DEBUG_ASSERT_DATA *AssertData;
+ UINTN TotalSize;
+ CHAR8 *Temp;
+
+ if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) == 0) {
+ return;
+ }
+
+ //
+ // 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
+ );
+ }
+
+ //
+ // Put break point in module that contained the error.
+ //
+ CpuBreakpoint ();
+}
+
+VOID
+DebugVPrint (
+ 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 / sizeof (UINT64)];
+ EFI_DEBUG_INFO *DebugInfo;
+ UINTN TotalSize;
+ UINTN Index;
+ UINT64 *ArgumentPointer;
+
+ //
+ // Check driver Debug Level value and global debug level
+ //
+ if (mDebugLevelInstalled) {
+ if ((ErrorLevel & mDebugLevel.DebugLevel) == 0) {
+ return;
+ }
+ } else {
+ 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.
+ //
+ for (Index = 0, ArgumentPointer = (UINT64 *)(DebugInfo + 1); Index < 12; Index++, ArgumentPointer++) {
+ *ArgumentPointer = VA_ARG (Marker, UINT64);
+ }
+ AsciiStrCpy ((CHAR8 *)ArgumentPointer, Format);
+
+ //
+ //
+ //
+ REPORT_STATUS_CODE_WITH_EXTENDED_DATA (
+ EFI_DEBUG_CODE,
+ (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_DC_UNSPECIFIED),
+ DebugInfo,
+ TotalSize
+ );
+}
+
+VOID
+EFIAPI
+DebugPrint (
+ IN UINTN ErrorLevel,
+ IN CHAR8 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Wrapper for DebugVPrint ()
+
+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);
+ DebugVPrint (ErrorLevel, Format, Marker);
+ VA_END (Marker);
+}
+
+/**
+ 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
+ )
+{
+// SetMem (Buffer, Length, PcdGet8(PcdDebugClearMemoryValue));
+ SetMem (Buffer, Length, 0xAF);
+ return Buffer;
+}
+
+BOOLEAN
+EFIAPI
+DebugAssertEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
+}
+
+BOOLEAN
+EFIAPI
+DebugPrintEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
+}
+
+BOOLEAN
+EFIAPI
+DebugCodeEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
+}
+
+BOOLEAN
+EFIAPI
+DebugClearMemoryEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
+}
+
diff --git a/EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/EdkDxeDebugLibReportStatusCode.mbd b/EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/EdkDxeDebugLibReportStatusCode.mbd
new file mode 100644
index 0000000..9825a20
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/EdkDxeDebugLibReportStatusCode.mbd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>EdkDxeDebugLibReportStatusCode</BaseName>
+ <Guid>76a2a4d8-f605-407a-8057-4a17dcdc4c6d</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Created>2006-03-12 17:09</Created>
+ <Modified>2006-03-31 13:12</Modified>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/EdkDxeDebugLibReportStatusCode.msa b/EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/EdkDxeDebugLibReportStatusCode.msa
new file mode 100644
index 0000000..e80bee2
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/EdkDxeDebugLibReportStatusCode.msa
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>EdkDxeDebugLibReportStatusCode</BaseName>
+ <ModuleType>DXE_DRIVER</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>76a2a4d8-f605-407a-8057-4a17dcdc4c6d</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Abstract>Debug Library for DXE drivers</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>EFI_SPECIFICATION_VERSION 0x00000000</Specification>
+ <Created>2006-03-12 17:09</Created>
+ <Updated>2006-03-31 13:12</Updated>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">ReportStatusCodeLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseMemoryLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PcdLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>DebugLib.c</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+ <Protocols>
+ <Protocol Usage="ALWAYS_CONSUMED">DebugLevel</Protocol>
+ </Protocols>
+ <Externs>
+ <Extern>
+ <Constructor>DebugLibConstructor</Constructor>
+ </Extern>
+ </Externs>
+ <PCDs>
+ <PcdData ItemType="FIXED_AT_BUILD">
+ <C_Name>PcdDebugPropertyMask</C_Name>
+ <Token>0x00000005</Token>
+ <DatumType>UINT8</DatumType>
+ </PcdData>
+ <PcdData ItemType="PATCHABLE_IN_MODULE">
+ <C_Name>PcdDebugPrintErrorLevel</C_Name>
+ <Token>0x00000006</Token>
+ <DatumType>UINT32</DatumType>
+ </PcdData>
+ </PCDs>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/build.xml b/EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/build.xml
new file mode 100644
index 0000000..fb10546
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxeDebugLibReportStatusCode/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="EdkDxeDebugLibReportStatusCode"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\EdkDxeDebugLibReportStatusCode"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="EdkDxeDebugLibReportStatusCode">
+ <GenBuild baseName="EdkDxeDebugLibReportStatusCode" mbdFilename="${MODULE_DIR}\EdkDxeDebugLibReportStatusCode.mbd" msaFilename="${MODULE_DIR}\EdkDxeDebugLibReportStatusCode.msa"/>
+ </target>
+ <target depends="EdkDxeDebugLibReportStatusCode_clean" name="clean"/>
+ <target depends="EdkDxeDebugLibReportStatusCode_cleanall" name="cleanall"/>
+ <target name="EdkDxeDebugLibReportStatusCode_clean">
+ <OutputDirSetup baseName="EdkDxeDebugLibReportStatusCode" mbdFilename="${MODULE_DIR}\EdkDxeDebugLibReportStatusCode.mbd" msaFilename="${MODULE_DIR}\EdkDxeDebugLibReportStatusCode.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkDxeDebugLibReportStatusCode_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkDxeDebugLibReportStatusCode_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="EdkDxeDebugLibReportStatusCode_cleanall">
+ <OutputDirSetup baseName="EdkDxeDebugLibReportStatusCode" mbdFilename="${MODULE_DIR}\EdkDxeDebugLibReportStatusCode.mbd" msaFilename="${MODULE_DIR}\EdkDxeDebugLibReportStatusCode.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkDxeDebugLibReportStatusCode_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkDxeDebugLibReportStatusCode_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**EdkDxeDebugLibReportStatusCode*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/EdkDxePeCoffLoaderFromHobLib/EdkDxePeCoffLoaderFromHobLib.mbd b/EdkModulePkg/Library/EdkDxePeCoffLoaderFromHobLib/EdkDxePeCoffLoaderFromHobLib.mbd
new file mode 100644
index 0000000..bc500a0
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxePeCoffLoaderFromHobLib/EdkDxePeCoffLoaderFromHobLib.mbd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>EdkDxePeCoffLoaderFromHobLib</BaseName>
+ <Guid>ed3de5c8-c389-44f2-a35e-2ebdc9802a49</Guid>
+ <Version>0</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004 - 2005, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Created>2006-03-12 17:09</Created>
+ <Modified>2006-03-22 15:50</Modified>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/EdkDxePeCoffLoaderFromHobLib/EdkDxePeCoffLoaderFromHobLib.msa b/EdkModulePkg/Library/EdkDxePeCoffLoaderFromHobLib/EdkDxePeCoffLoaderFromHobLib.msa
new file mode 100644
index 0000000..892ae8a
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxePeCoffLoaderFromHobLib/EdkDxePeCoffLoaderFromHobLib.msa
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>EdkDxePeCoffLoaderFromHobLib</BaseName>
+ <ModuleType>DXE_DRIVER</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>ed3de5c8-c389-44f2-a35e-2ebdc9802a49</Guid>
+ <Version>0</Version>
+ <Abstract>Component description file for the PEI library.</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004 - 2005, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>0</Specification>
+ <Created>2006-03-12 17:09</Created>
+ <Updated>2006-03-22 15:50</Updated>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">EdkPeCoffLoaderLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">HobLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>PeCoff.c</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+ <Guids>
+ <GuidEntry Usage="ALWAYS_CONSUMED">
+ <C_Name>PeiPeCoffLoader</C_Name>
+ </GuidEntry>
+ </Guids>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/EdkDxePeCoffLoaderFromHobLib/PeCoff.c b/EdkModulePkg/Library/EdkDxePeCoffLoaderFromHobLib/PeCoff.c
new file mode 100644
index 0000000..7afe9c2
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxePeCoffLoaderFromHobLib/PeCoff.c
@@ -0,0 +1,38 @@
+/*++
+
+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:
+
+ Decompress.c
+
+Abstract:
+
+--*/
+
+
+
+
+
+EFI_PEI_PE_COFF_LOADER_PROTOCOL *
+EFIAPI
+GetPeCoffLoaderProtocol (
+ )
+{
+ EFI_HOB_GUID_TYPE *GuidHob;
+
+ GuidHob = GetFirstGuidHob (&gEfiPeiPeCoffLoaderGuid);
+ if (GuidHob == NULL) {
+ return NULL;
+ } else {
+ return (EFI_PEI_PE_COFF_LOADER_PROTOCOL *)(*(UINTN *)(GET_GUID_HOB_DATA (GuidHob)));
+ }
+}
+
diff --git a/EdkModulePkg/Library/EdkDxePeCoffLoaderFromHobLib/build.xml b/EdkModulePkg/Library/EdkDxePeCoffLoaderFromHobLib/build.xml
new file mode 100644
index 0000000..ba50f03
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxePeCoffLoaderFromHobLib/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="EdkDxePeCoffLoaderFromHobLib"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\EdkDxePeCoffLoaderFromHobLib"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="EdkDxePeCoffLoaderFromHobLib">
+ <GenBuild baseName="EdkDxePeCoffLoaderFromHobLib" mbdFilename="${MODULE_DIR}\EdkDxePeCoffLoaderFromHobLib.mbd" msaFilename="${MODULE_DIR}\EdkDxePeCoffLoaderFromHobLib.msa"/>
+ </target>
+ <target depends="EdkDxePeCoffLoaderFromHobLib_clean" name="clean"/>
+ <target depends="EdkDxePeCoffLoaderFromHobLib_cleanall" name="cleanall"/>
+ <target name="EdkDxePeCoffLoaderFromHobLib_clean">
+ <OutputDirSetup baseName="EdkDxePeCoffLoaderFromHobLib" mbdFilename="${MODULE_DIR}\EdkDxePeCoffLoaderFromHobLib.mbd" msaFilename="${MODULE_DIR}\EdkDxePeCoffLoaderFromHobLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkDxePeCoffLoaderFromHobLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkDxePeCoffLoaderFromHobLib_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="EdkDxePeCoffLoaderFromHobLib_cleanall">
+ <OutputDirSetup baseName="EdkDxePeCoffLoaderFromHobLib" mbdFilename="${MODULE_DIR}\EdkDxePeCoffLoaderFromHobLib.mbd" msaFilename="${MODULE_DIR}\EdkDxePeCoffLoaderFromHobLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkDxePeCoffLoaderFromHobLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkDxePeCoffLoaderFromHobLib_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**EdkDxePeCoffLoaderFromHobLib*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/EdkDxePerformanceLib/DxePerformanceLib.c b/EdkModulePkg/Library/EdkDxePerformanceLib/DxePerformanceLib.c
new file mode 100644
index 0000000..5e448c6
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxePerformanceLib/DxePerformanceLib.c
@@ -0,0 +1,213 @@
+/*++
+
+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:
+
+ DxePerformanceLib.c
+
+Abstract:
+
+ Performance Library
+
+--*/
+
+STATIC PERFORMANCE_PROTOCOL *mPerformance = NULL;
+
+/**
+ The constructor function caches the pointer to Performance protocol.
+
+ The constructor function locates Performance 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
+PerformanceLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+
+ Status = gBS->LocateProtocol (&gPerformanceProtocolGuid, NULL, (VOID **) &mPerformance);
+ ASSERT_EFI_ERROR (Status);
+ ASSERT (mPerformance != NULL);
+
+ return Status;
+}
+
+/**
+ Creates a record for the beginning of a performance measurement.
+
+ Creates a record that contains the Handle, Token, and Module.
+ If TimeStamp is not zero, then TimeStamp is added to the record as the start time.
+ If TimeStamp is zero, then this function reads the current time stamp
+ and adds that time stamp value to the record as the start time.
+
+ @param Handle Pointer to environment specific context used
+ to identify the component being measured.
+ @param Token Pointer to a Null-terminated ASCII string
+ that identifies the component being measured.
+ @param Module Pointer to a Null-terminated ASCII string
+ that identifies the module being measured.
+ @param TimeStamp 64-bit time stamp.
+
+ @retval RETURN_SUCCESS The start of the measurement was recorded.
+ @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.
+
+**/
+RETURN_STATUS
+EFIAPI
+StartPerformanceMeasurement (
+ IN CONST VOID *Handle, OPTIONAL
+ IN CONST CHAR8 *Token, OPTIONAL
+ IN CONST CHAR8 *Module, OPTIONAL
+ IN UINT64 TimeStamp
+ )
+{
+ EFI_STATUS Status;
+
+ Status = mPerformance->StartGauge (Handle, Token, Module, TimeStamp);
+
+ return (RETURN_STATUS) Status;
+}
+
+/**
+ Fills in the end time of a performance measurement.
+
+ Looks up the record that matches Handle, Token, and Module.
+ If the record can not be found then return RETURN_NOT_FOUND.
+ If the record is found and TimeStamp is not zero,
+ then TimeStamp is added to the record as the end time.
+ If the record is found and TimeStamp is zero, then this function reads
+ the current time stamp and adds that time stamp value to the record as the end time.
+ If this function is called multiple times for the same record, then the end time is overwritten.
+
+ @param Handle Pointer to environment specific context used
+ to identify the component being measured.
+ @param Token Pointer to a Null-terminated ASCII string
+ that identifies the component being measured.
+ @param Module Pointer to a Null-terminated ASCII string
+ that identifies the module being measured.
+ @param TimeStamp 64-bit time stamp.
+
+ @retval RETURN_SUCCESS The end of the measurement was recorded.
+ @retval RETURN_NOT_FOUND The specified measurement record could not be found.
+
+**/
+RETURN_STATUS
+EFIAPI
+EndPerformanceMeasurement (
+ IN CONST VOID *Handle, OPTIONAL
+ IN CONST CHAR8 *Token, OPTIONAL
+ IN CONST CHAR8 *Module, OPTIONAL
+ IN UINT64 TimeStamp
+ )
+{
+ EFI_STATUS Status;
+
+ Status = mPerformance->EndGauge (Handle, Token, Module, TimeStamp);
+
+ return (RETURN_STATUS) Status;
+}
+
+/**
+ Retrieves a previously logged performance measurement.
+
+ Looks up the record that matches Handle, Token, and Module.
+ If the record can not be found then return RETURN_NOT_FOUND.
+ If the record is found then the start of the measurement is returned in StartTimeStamp,
+ and the end of the measurement is returned in EndTimeStamp.
+
+ @param LogEntryKey The key for the previous performance measurement log entry.
+ If 0, then the first performance measurement log entry is retrieved.
+ @param Handle Pointer to environment specific context used
+ to identify the component being measured.
+ @param Token Pointer to a Null-terminated ASCII string
+ that identifies the component being measured.
+ @param Module Pointer to a Null-terminated ASCII string
+ that identifies the module being measured.
+ @param StartTimeStamp The 64-bit time stamp that was recorded when the measurement was started.
+ @param EndTimeStamp The 64-bit time stamp that was recorded when the measurement was ended.
+
+ @return The key for the current performance log entry.
+
+**/
+UINTN
+EFIAPI
+GetPerformanceMeasurement (
+ UINTN LogEntryKey,
+ OUT CONST VOID **Handle,
+ OUT CONST CHAR8 **Token,
+ OUT CONST CHAR8 **Module,
+ OUT UINT64 *StartTimeStamp,
+ OUT UINT64 *EndTimeStamp
+ )
+{
+ EFI_STATUS Status;
+ GAUGE_DATA_ENTRY *GaugeData;
+
+ ASSERT (Handle != NULL);
+ ASSERT (Token != NULL);
+ ASSERT (Module != NULL);
+ ASSERT (StartTimeStamp != NULL);
+ ASSERT (EndTimeStamp != NULL);
+
+ Status = mPerformance->GetGauge (LogEntryKey++, &GaugeData);
+
+ //
+ // Make sure that LogEntryKey is a valid log entry key,
+ //
+ ASSERT (Status != EFI_INVALID_PARAMETER);
+
+ if (EFI_ERROR (Status)) {
+ //
+ // The LogEntryKey is the last entry (equals to the total entry number).
+ //
+ return 0;
+ }
+
+ ASSERT (GaugeData != NULL);
+
+ *Handle = (VOID *) (UINTN) GaugeData->Handle;
+ *Token = GaugeData->Token;
+ *Module = GaugeData->Module;
+ *StartTimeStamp = GaugeData->StartTimeStamp;
+ *EndTimeStamp = GaugeData->EndTimeStamp;
+
+ return LogEntryKey;
+}
+
+/**
+ Returns TRUE if the performance measurement macros are enabled.
+
+ This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
+ PcdPerformanceLibraryPropertyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
+ PcdPerformanceLibraryPropertyMask is set.
+ @retval FALSE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
+ PcdPerformanceLibraryPropertyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+PerformanceMeasurementEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);
+}
diff --git a/EdkModulePkg/Library/EdkDxePerformanceLib/EdkDxePerformanceLib.mbd b/EdkModulePkg/Library/EdkDxePerformanceLib/EdkDxePerformanceLib.mbd
new file mode 100644
index 0000000..7bd0e10
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxePerformanceLib/EdkDxePerformanceLib.mbd
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>EdkDxePerformanceLib</BaseName>
+ <Guid>8B8B4CCC-65FC-41a5-8067-308B8E42CCF2</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Created>2006-04-04 11:11</Created>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/EdkDxePerformanceLib/EdkDxePerformanceLib.msa b/EdkModulePkg/Library/EdkDxePerformanceLib/EdkDxePerformanceLib.msa
new file mode 100644
index 0000000..8cddf79
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxePerformanceLib/EdkDxePerformanceLib.msa
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>EdkDxePerformanceLib</BaseName>
+ <ModuleType>DXE_DRIVER</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>8B8B4CCC-65FC-41a5-8067-308B8E42CCF2</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Abstract>Memory-only library functions with no library constructor/destructor</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>EFI_SPECIFICATION_VERSION 0x00000000</Specification>
+ <Created>2006-04-04 11:11</Created>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">PerformanceLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">TimerLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PcdLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>DxePerformanceLib.c</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+ <Protocols>
+ <Protocol Usage="ALWAYS_CONSUMED">Performance</Protocol>
+ </Protocols>
+ <Externs>
+ <Extern>
+ <Constructor>PerformanceLibConstructor</Constructor>
+ </Extern>
+ </Externs>
+ <PCDs>
+ <PcdData ItemType="FIXED_AT_BUILD">
+ <C_Name>PcdPerformanceLibraryPropertyMask</C_Name>
+ <Token>0x00000001</Token>
+ <DatumType>UINT8</DatumType>
+ </PcdData>
+ </PCDs>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/EdkDxePerformanceLib/build.xml b/EdkModulePkg/Library/EdkDxePerformanceLib/build.xml
new file mode 100644
index 0000000..5a1dca4
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxePerformanceLib/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="EdkDxePerformanceLib"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\EdkDxePerformanceLib"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="EdkDxePerformanceLib">
+ <GenBuild baseName="EdkDxePerformanceLib" mbdFilename="${MODULE_DIR}\EdkDxePerformanceLib.mbd" msaFilename="${MODULE_DIR}\EdkDxePerformanceLib.msa"/>
+ </target>
+ <target depends="EdkDxePerformanceLib_clean" name="clean"/>
+ <target depends="EdkDxePerformanceLib_cleanall" name="cleanall"/>
+ <target name="EdkDxePerformanceLib_clean">
+ <OutputDirSetup baseName="EdkDxePerformanceLib" mbdFilename="${MODULE_DIR}\EdkDxePerformanceLib.mbd" msaFilename="${MODULE_DIR}\EdkDxePerformanceLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkDxePerformanceLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkDxePerformanceLib_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="EdkDxePerformanceLib_cleanall">
+ <OutputDirSetup baseName="EdkDxePerformanceLib" mbdFilename="${MODULE_DIR}\EdkDxePerformanceLib.mbd" msaFilename="${MODULE_DIR}\EdkDxePerformanceLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkDxePerformanceLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkDxePerformanceLib_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**EdkDxePerformanceLib*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/EdkDxePrintLib/EdkDxePrintLib.mbd b/EdkModulePkg/Library/EdkDxePrintLib/EdkDxePrintLib.mbd
new file mode 100644
index 0000000..ca9912b
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxePrintLib/EdkDxePrintLib.mbd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>EdkDxePrintLib</BaseName>
+ <Guid>50bcb105-6634-441d-b403-659110a03ad2</Guid>
+ <Version>0</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Created>2006-03-12 17:09</Created>
+ <Modified>2006-03-19 15:19</Modified>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/EdkDxePrintLib/EdkDxePrintLib.msa b/EdkModulePkg/Library/EdkDxePrintLib/EdkDxePrintLib.msa
new file mode 100644
index 0000000..bd58f91
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxePrintLib/EdkDxePrintLib.msa
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>EdkDxePrintLib</BaseName>
+ <ModuleType>DXE_DRIVER</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>50bcb105-6634-441d-b403-659110a03ad2</Guid>
+ <Version>0</Version>
+ <Abstract>Component description file for the entry point to a EFIDXE Drivers</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>0</Specification>
+ <Created>2006-03-12 17:09</Created>
+ <Updated>2006-03-19 15:19</Updated>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">PrintLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">MemoryAllocationLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>PrintLib.c</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+ <Protocols>
+ <Protocol Usage="ALWAYS_CONSUMED">Print</Protocol>
+ </Protocols>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/EdkDxePrintLib/PrintLib.c b/EdkModulePkg/Library/EdkDxePrintLib/PrintLib.c
new file mode 100644
index 0000000..30c0354
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxePrintLib/PrintLib.c
@@ -0,0 +1,145 @@
+/*++
+
+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:
+
+ PrintLib.c
+
+Abstract:
+
+ Print Library
+
+--*/
+
+
+
+static EFI_PRINT_PROTOCOL *gPrintProtocol = NULL;
+
+UINTN
+UnicodeVSPrint (
+ OUT CHAR16 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN const CHAR16 *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;
+
+ if (gPrintProtocol == NULL) {
+ Status = gBS->LocateProtocol (
+ &gEfiPrintProtocolGuid,
+ NULL,
+ (VOID **)&gPrintProtocol
+ );
+ if (EFI_ERROR (Status)) {
+ gPrintProtocol = NULL;
+ }
+ if (gPrintProtocol == NULL) {
+ return 0;
+ }
+ }
+ return gPrintProtocol->VSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
+}
+
+UINTN
+UnicodeSPrint (
+ OUT CHAR16 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN const CHAR16 *FormatString,
+ ...
+ )
+
+{
+ UINTN Return;
+ VA_LIST Marker;
+
+ VA_START (Marker, FormatString);
+ Return = UnicodeVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
+ VA_END (Marker);
+ return Return;
+}
+
+UINTN
+AsciiVSPrint (
+ OUT CHAR8 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN const CHAR8 *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.
+
+--*/
+{
+ return 0;
+}
+
+UINTN
+AsciiSPrint (
+ OUT CHAR8 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN const CHAR8 *FormatString,
+ ...
+ )
+
+{
+ UINTN Return;
+ VA_LIST Marker;
+
+ VA_START (Marker, FormatString);
+ Return = AsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
+ VA_END (Marker);
+ return Return;
+}
diff --git a/EdkModulePkg/Library/EdkDxePrintLib/build.xml b/EdkModulePkg/Library/EdkDxePrintLib/build.xml
new file mode 100644
index 0000000..2ad6bed
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxePrintLib/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="EdkDxePrintLib"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\EdkDxePrintLib"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="EdkDxePrintLib">
+ <GenBuild baseName="EdkDxePrintLib" mbdFilename="${MODULE_DIR}\EdkDxePrintLib.mbd" msaFilename="${MODULE_DIR}\EdkDxePrintLib.msa"/>
+ </target>
+ <target depends="EdkDxePrintLib_clean" name="clean"/>
+ <target depends="EdkDxePrintLib_cleanall" name="cleanall"/>
+ <target name="EdkDxePrintLib_clean">
+ <OutputDirSetup baseName="EdkDxePrintLib" mbdFilename="${MODULE_DIR}\EdkDxePrintLib.mbd" msaFilename="${MODULE_DIR}\EdkDxePrintLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkDxePrintLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkDxePrintLib_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="EdkDxePrintLib_cleanall">
+ <OutputDirSetup baseName="EdkDxePrintLib" mbdFilename="${MODULE_DIR}\EdkDxePrintLib.mbd" msaFilename="${MODULE_DIR}\EdkDxePrintLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkDxePrintLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkDxePrintLib_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**EdkDxePrintLib*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c b/EdkModulePkg/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c
new file mode 100644
index 0000000..adddf93
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c
@@ -0,0 +1,258 @@
+/*++
+
+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:
+
+ RuntimeLib.c
+
+Abstract:
+
+ Light weight lib to support Tiano drivers.
+
+--*/
+
+#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
+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
+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/EdkModulePkg/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c b/EdkModulePkg/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c
new file mode 100644
index 0000000..971dcdb
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c
@@ -0,0 +1,480 @@
+/*++
+
+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:
+
+ RuntimeService.c
+
+Abstract:
+
+ Light weight lib to support Tiano drivers.
+
+--*/
+
+#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/EdkModulePkg/Library/EdkDxeRuntimeDriverLib/EdkDxeRuntimeDriverLib.mbd b/EdkModulePkg/Library/EdkDxeRuntimeDriverLib/EdkDxeRuntimeDriverLib.mbd
new file mode 100644
index 0000000..72edffb
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxeRuntimeDriverLib/EdkDxeRuntimeDriverLib.mbd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>EdkDxeRuntimeDriverLib</BaseName>
+ <Guid>b1ee6c28-54aa-4d17-b705-3e28ccb27b2e</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Created>2006-03-12 17:09</Created>
+ <Modified>2006-03-31 13:13</Modified>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/EdkDxeRuntimeDriverLib/EdkDxeRuntimeDriverLib.msa b/EdkModulePkg/Library/EdkDxeRuntimeDriverLib/EdkDxeRuntimeDriverLib.msa
new file mode 100644
index 0000000..4d9183e
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxeRuntimeDriverLib/EdkDxeRuntimeDriverLib.msa
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>EdkDxeRuntimeDriverLib</BaseName>
+ <ModuleType>DXE_DRIVER</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>b1ee6c28-54aa-4d17-b705-3e28ccb27b2e</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Abstract>Component description file for the entry point to a EFIDXE Drivers</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>EFI_SPECIFICATION_VERSION 0x00000000</Specification>
+ <Created>2006-03-12 17:09</Created>
+ <Updated>2006-03-31 13:13</Updated>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">DxeRuntimeDriverLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">EdkDxeSalLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Arch ArchType="IA32">
+ <Filename>Common\RuntimeLib.c</Filename>
+ <Filename>Common\RuntimeService.c</Filename>
+ </Arch>
+ <Arch ArchType="X64">
+ <Filename>Common\RuntimeLib.c</Filename>
+ <Filename>Common\RuntimeService.c</Filename>
+ </Arch>
+ <Arch ArchType="IPF">
+ <Filename>Ipf\RuntimeLib.c</Filename>
+ <Filename>Ipf\RuntimeService.c</Filename>
+ </Arch>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+ <Protocols>
+ <Protocol Usage="ALWAYS_CONSUMED">ExtendedSalBootService</Protocol>
+ </Protocols>
+ <Externs>
+ <Extern>
+ <Constructor>RuntimeDriverLibConstruct</Constructor>
+ <Destructor>RuntimeDriverLibDeconstruct</Destructor>
+ </Extern>
+ </Externs>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeLib.c b/EdkModulePkg/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeLib.c
new file mode 100644
index 0000000..a4eeb33
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeLib.c
@@ -0,0 +1,284 @@
+/*++
+
+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:
+
+ RuntimeLib.c
+
+Abstract:
+
+ Light weight lib to support Tiano drivers.
+
+--*/
+
+#include <SalApi.h>
+#include <RuntimeLibInternal.h>
+
+//
+// Driver Lib Module Globals
+//
+
+STATIC EFI_EVENT mRuntimeNotifyEvent;
+STATIC EFI_EVENT mEfiVirtualNotifyEvent;
+
+STATIC EFI_PLABEL mPlabel;
+STATIC EXTENDED_SAL_BOOT_SERVICE_PROTOCOL *mEsalBootService;
+
+EFI_RUNTIME_SERVICES *mRT = NULL;
+
+STATIC
+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);
+ }
+}
+
+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);
+ }
+
+ mRT->ConvertPointer (0x0, (VOID **) &mPlabel.EntryPoint);
+ mRT->ConvertPointer (EFI_IPF_GP_POINTER, (VOID **) &mPlabel.GP);
+
+ SetEsalVirtualEntryPoint (mPlabel.EntryPoint, mPlabel.GP);
+
+ //
+ // Clear out BootService globals
+ //
+ gBS = NULL;
+ gST = NULL;
+ mRT = NULL;
+}
+
+EFI_STATUS
+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_PLABEL *Plabel;
+ EFI_STATUS Status;
+
+ mRT = SystemTable->RuntimeServices;
+
+ //
+ // 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);
+
+ //
+ // 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
+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 ExitBootService () has been called
+
+Arguments:
+ NONE
+
+Returns:
+ TRUE - If ExitBootService () has been called
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID;
+ SAL_RETURN_REGS ReturnReg;
+
+ ReturnReg = EfiCallEsalService (&Guid, IsEfiRuntime, 0, 0, 0, 0, 0, 0, 0);
+
+ return (BOOLEAN) (ReturnReg.r9 == 1);
+}
+
+BOOLEAN
+EfiGoneVirtual (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Return TRUE if SetVirtualAddressMap () has been called
+
+Arguments:
+ NONE
+
+Returns:
+ TRUE - If SetVirtualAddressMap () has been called
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID;
+ SAL_RETURN_REGS ReturnReg;
+
+ ReturnReg = EfiCallEsalService (&Guid, IsVirtual, 0, 0, 0, 0, 0, 0, 0);
+
+ return (BOOLEAN) (ReturnReg.r9 == 1);
+}
diff --git a/EdkModulePkg/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeService.c b/EdkModulePkg/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeService.c
new file mode 100644
index 0000000..bc7a318
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeService.c
@@ -0,0 +1,516 @@
+/*++
+
+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:
+
+ RuntimeService.c
+
+Abstract:
+
+ Light weight lib to support Tiano drivers.
+
+--*/
+
+#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
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_RESET_SERVICES_PROTOCOL_GUID;
+
+ EfiCallEsalService (
+ &Guid,
+ ResetSystem,
+ (UINT64) ResetType,
+ (UINT64) ResetStatus,
+ (UINT64) DataSize,
+ (UINT64) ResetData,
+ 0,
+ 0,
+ 0
+ );
+}
+
+
+//
+// The following functions hide the mRT local global from the call to
+// runtime service in the EFI system table.
+//
+EFI_STATUS
+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 (
+ IN EFI_TIME *Time
+ )
+/*++
+
+Routine Description:
+
+ Sets the current local time and date information.
+
+Arguments:
+
+ Time - A pointer to the current time.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ SAL_RETURN_REGS ReturnReg;
+
+ EFI_GUID Guid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID;
+
+ ReturnReg = EfiCallEsalService (&Guid, SetTime, (UINT64) Time, 0, 0, 0, 0, 0, 0);
+ return ReturnReg.Status;
+}
+
+EFI_STATUS
+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;
+}
+
+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;
+}
+
+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;
+}
+
+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
+EfiConvertList (
+ IN UINTN DebugDisposition,
+ IN OUT LIST_ENTRY *ListHead
+ )
+/*++
+
+Routine Description:
+
+ Conver the standard Lib double linked list to a virtual mapping.
+
+Arguments:
+
+ DebugDisposition - Argument to EfiConvertPointer (EFI 1.0 API)
+
+ ListHead - Head of linked list to convert
+
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+{
+ LIST_ENTRY *Link;
+ LIST_ENTRY *NextLink;
+
+ //
+ // Convert all the ForwardLink & BackLink pointers in the list
+ //
+ Link = ListHead;
+ do {
+ NextLink = Link->ForwardLink;
+
+ EfiConvertPointer (
+ Link->ForwardLink == ListHead ? DebugDisposition : 0,
+ (VOID **) &Link->ForwardLink
+ );
+
+ EfiConvertPointer (
+ Link->BackLink == ListHead ? DebugDisposition : 0,
+ (VOID **) &Link->BackLink
+ );
+
+ Link = NextLink;
+ } while (Link != ListHead);
+ return EFI_SUCCESS;
+}
+
+
+/**
+ Change the runtime addressing mode of EFI firmware from physical to virtual.
+
+ @param MemoryMapSize The size in bytes of VirtualMap.
+ @param DescriptorSize The size in bytes of an entry in the VirtualMap.
+ @param DescriptorVersion The version of the structure entries in VirtualMap.
+ @param VirtualMap An array of memory descriptors which contain new virtual
+ address mapping information for all runtime ranges. Type
+ EFI_MEMORY_DESCRIPTOR is defined in the
+ GetMemoryMap() function description.
+
+ @retval EFI_SUCCESS The virtual address map has been applied.
+ @retval EFI_UNSUPPORTED EFI firmware is not at runtime, or the EFI firmware is already in
+ virtual address mapped mode.
+ @retval EFI_INVALID_PARAMETER DescriptorSize or DescriptorVersion is
+ invalid.
+ @retval EFI_NO_MAPPING A virtual address was not supplied for a range in the memory
+ map that requires a mapping.
+ @retval EFI_NOT_FOUND A virtual address was supplied for an address that is not found
+ in the memory map.
+**/
+EFI_STATUS
+EFIAPI
+EfiSetVirtualAddressMap (
+ IN UINTN MemoryMapSize,
+ IN UINTN DescriptorSize,
+ IN UINT32 DescriptorVersion,
+ IN CONST EFI_MEMORY_DESCRIPTOR *VirtualMap
+ )
+{
+ SAL_RETURN_REGS ReturnReg;
+ EFI_GUID Guid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID;
+
+ ReturnReg = EfiCallEsalService (
+ &Guid,
+ SetVirtualAddress,
+ (UINT64) MemoryMapSize,
+ (UINT64) DescriptorSize,
+ (UINT64) DescriptorVersion,
+ (UINT64) VirtualMap,
+ 0,
+ 0,
+ 0
+ );
+
+ return ReturnReg.Status;
+}
+
+
+EFI_STATUS
+EfiUpdateCapsule (
+ IN UEFI_CAPSULE_HEADER **CapsuleHeaderArray,
+ IN UINTN CapsuleCount,
+ IN EFI_PHYSICAL_ADDRESS ScatterGatherList OPTIONAL
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+EfiQueryCapsuleCapabilities (
+ IN UEFI_CAPSULE_HEADER **CapsuleHeaderArray,
+ IN UINTN CapsuleCount,
+ OUT UINT64 *MaximumCapsuleSize,
+ OUT EFI_RESET_TYPE *ResetType
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+
+EFI_STATUS
+EfiQueryVariableInfo (
+ IN UINT32 Attributes,
+ OUT UINT64 *MaximumVariableStorageSize,
+ OUT UINT64 *RemainingVariableStorageSize,
+ OUT UINT64 *MaximumVariableSize
+ )
+{
+ return EFI_UNSUPPORTED;
+}
diff --git a/EdkModulePkg/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h b/EdkModulePkg/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h
new file mode 100644
index 0000000..82494fd
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ RuntimeLibInternal.h
+
+Abstract:
+
+--*/
+
+#ifndef __RUNTIMELIBINTERNAL_H__
+#define __RUNTIMELIBINTERNAL_H__
+
+EFI_STATUS
+EfiConvertInternalPointer (
+ IN OUT VOID *Address
+ );
+
+extern EFI_RUNTIME_SERVICES *mRT;
+
+#endif //__RUNTIMELIBINTERNAL_H__
diff --git a/EdkModulePkg/Library/EdkDxeRuntimeDriverLib/build.xml b/EdkModulePkg/Library/EdkDxeRuntimeDriverLib/build.xml
new file mode 100644
index 0000000..e43f708
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxeRuntimeDriverLib/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="EdkDxeRuntimeDriverLib"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\EdkDxeRuntimeDriverLib"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="EdkDxeRuntimeDriverLib">
+ <GenBuild baseName="EdkDxeRuntimeDriverLib" mbdFilename="${MODULE_DIR}\EdkDxeRuntimeDriverLib.mbd" msaFilename="${MODULE_DIR}\EdkDxeRuntimeDriverLib.msa"/>
+ </target>
+ <target depends="EdkDxeRuntimeDriverLib_clean" name="clean"/>
+ <target depends="EdkDxeRuntimeDriverLib_cleanall" name="cleanall"/>
+ <target name="EdkDxeRuntimeDriverLib_clean">
+ <OutputDirSetup baseName="EdkDxeRuntimeDriverLib" mbdFilename="${MODULE_DIR}\EdkDxeRuntimeDriverLib.mbd" msaFilename="${MODULE_DIR}\EdkDxeRuntimeDriverLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkDxeRuntimeDriverLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkDxeRuntimeDriverLib_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="EdkDxeRuntimeDriverLib_cleanall">
+ <OutputDirSetup baseName="EdkDxeRuntimeDriverLib" mbdFilename="${MODULE_DIR}\EdkDxeRuntimeDriverLib.mbd" msaFilename="${MODULE_DIR}\EdkDxeRuntimeDriverLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkDxeRuntimeDriverLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkDxeRuntimeDriverLib_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**EdkDxeRuntimeDriverLib*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/EdkDxeSalLib/EdkDxeSalLib.mbd b/EdkModulePkg/Library/EdkDxeSalLib/EdkDxeSalLib.mbd
new file mode 100644
index 0000000..dababd2
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxeSalLib/EdkDxeSalLib.mbd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>EdkDxeSalLib</BaseName>
+ <Guid>61999c3c-72a5-4506-a4ff-4271d18a1d14</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Created>2006-03-12 17:09</Created>
+ <Modified>2006-03-31 13:13</Modified>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/EdkDxeSalLib/EdkDxeSalLib.msa b/EdkModulePkg/Library/EdkDxeSalLib/EdkDxeSalLib.msa
new file mode 100644
index 0000000..d9fc583
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxeSalLib/EdkDxeSalLib.msa
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>EdkDxeSalLib</BaseName>
+ <ModuleType>DXE_DRIVER</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>61999c3c-72a5-4506-a4ff-4271d18a1d14</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Abstract>Component description file for the entry point to a EFIDXE Drivers</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>EFI_SPECIFICATION_VERSION 0x00000000</Specification>
+ <Created>2006-03-12 17:09</Created>
+ <Updated>2006-03-31 13:13</Updated>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">EdkDxeSalLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Arch ArchType="IPF">
+ <Filename>Ipf/EsalServiceLib.c</Filename>
+ <Filename>Ipf/AsmEsalServiceLib.s</Filename>
+ <Filename>Ipf/AsmIpfCpuCache.s</Filename>
+ </Arch>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+ <Protocols>
+ <Protocol Usage="ALWAYS_CONSUMED">ExtendedSalBootService</Protocol>
+ </Protocols>
+ <Externs>
+ <Extern>
+ <Constructor>DxeSalLibConstruct</Constructor>
+ </Extern>
+ </Externs>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/EdkDxeSalLib/Ipf/AsmEsalServiceLib.s b/EdkModulePkg/Library/EdkDxeSalLib/Ipf/AsmEsalServiceLib.s
new file mode 100644
index 0000000..2b040b7
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxeSalLib/Ipf/AsmEsalServiceLib.s
@@ -0,0 +1,149 @@
+//++
+// Copyright (c) 2006, Intel Corporation
+// All rights reserved. This program and the accompanying materials
+// are licensed and made available under the terms and conditions of the BSD License
+// which accompanies this distribution. The full text of the license may be found at
+// http://opensource.org/licenses/bsd-license.php
+//
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// Module Name:
+//
+// EsalLib.s
+//
+// Abstract:
+//
+//
+// Revision History:
+//
+//--
+
+.file "EsalLib.s"
+
+#include "IpfMacro.i"
+
+//
+// Exports
+//
+.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/EdkModulePkg/Library/EdkDxeSalLib/Ipf/AsmIpfCpuCache.s b/EdkModulePkg/Library/EdkDxeSalLib/Ipf/AsmIpfCpuCache.s
new file mode 100644
index 0000000..c450505
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxeSalLib/Ipf/AsmIpfCpuCache.s
@@ -0,0 +1,88 @@
+//++
+// 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:
+//
+// 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/EdkModulePkg/Library/EdkDxeSalLib/Ipf/EsalServiceLib.c b/EdkModulePkg/Library/EdkDxeSalLib/Ipf/EsalServiceLib.c
new file mode 100644
index 0000000..d258b98
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxeSalLib/Ipf/EsalServiceLib.c
@@ -0,0 +1,199 @@
+/*++
+
+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:
+
+ EsalServiceLib.c
+
+Abstract:
+
+--*/
+
+#include <Ipf/IpfDefines.h>
+
+
+STATIC EXTENDED_SAL_BOOT_SERVICE_PROTOCOL *mEsalBootService;
+
+EFI_STATUS
+EFIAPI
+DxeSalLibConstruct (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+
+ Status = gBS->LocateProtocol (&gEfiExtendedSalBootServiceProtocolGuid, NULL, &mEsalBootService);
+ ASSERT_EFI_ERROR (Status);
+
+ return Status;
+}
+
+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
+ );
+}
diff --git a/EdkModulePkg/Library/EdkDxeSalLib/build.xml b/EdkModulePkg/Library/EdkDxeSalLib/build.xml
new file mode 100644
index 0000000..e4f1e3e
--- /dev/null
+++ b/EdkModulePkg/Library/EdkDxeSalLib/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="EdkDxeSalLib"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\EdkDxeSalLib"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="EdkDxeSalLib">
+ <GenBuild baseName="EdkDxeSalLib" mbdFilename="${MODULE_DIR}\EdkDxeSalLib.mbd" msaFilename="${MODULE_DIR}\EdkDxeSalLib.msa"/>
+ </target>
+ <target depends="EdkDxeSalLib_clean" name="clean"/>
+ <target depends="EdkDxeSalLib_cleanall" name="cleanall"/>
+ <target name="EdkDxeSalLib_clean">
+ <OutputDirSetup baseName="EdkDxeSalLib" mbdFilename="${MODULE_DIR}\EdkDxeSalLib.mbd" msaFilename="${MODULE_DIR}\EdkDxeSalLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkDxeSalLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkDxeSalLib_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="EdkDxeSalLib_cleanall">
+ <OutputDirSetup baseName="EdkDxeSalLib" mbdFilename="${MODULE_DIR}\EdkDxeSalLib.mbd" msaFilename="${MODULE_DIR}\EdkDxeSalLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkDxeSalLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkDxeSalLib_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**EdkDxeSalLib*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.mbd b/EdkModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.mbd
new file mode 100644
index 0000000..a5ee7cb
--- /dev/null
+++ b/EdkModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.mbd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>EdkFvbServiceLib</BaseName>
+ <Guid>bd4d540e-04b0-4b10-8fd5-4a7bb533cf67</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Created>2006-03-12 17:09</Created>
+ <Modified>2006-03-31 13:13</Modified>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.msa b/EdkModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.msa
new file mode 100644
index 0000000..c20d5ee
--- /dev/null
+++ b/EdkModulePkg/Library/EdkFvbServiceLib/EdkFvbServiceLib.msa
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>EdkFvbServiceLib</BaseName>
+ <ModuleType>DXE_DRIVER</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>bd4d540e-04b0-4b10-8fd5-4a7bb533cf67</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Abstract>FvbService Library for UEFI drivers</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>EFI_SPECIFICATION_VERSION 0x00000000</Specification>
+ <Created>2006-03-12 17:09</Created>
+ <Updated>2006-03-31 13:13</Updated>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">EdkFvbServiceLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PrintLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">MemoryAllocationLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseMemoryLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DxeRuntimeDriverLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">EdkDxeSalLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Arch ArchType="IA32">
+ <Filename>Ia32/Fvb.c</Filename>
+ </Arch>
+ <Arch ArchType="X64">
+ <Filename>x64/Fvb.c</Filename>
+ </Arch>
+ <Arch ArchType="IPF">
+ <Filename>Ipf/Fvb.c</Filename>
+ </Arch>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+ <Protocols>
+ <Protocol Usage="ALWAYS_CONSUMED">FirmwareVolumeBlock</Protocol>
+ <Protocol Usage="ALWAYS_CONSUMED">FvbExtension</Protocol>
+ <ProtocolNotify Usage="SOMETIMES_CONSUMED">FirmwareVolumeBlock</ProtocolNotify>
+ </Protocols>
+ <Externs>
+ <Extern>
+ <Constructor>FvbLibInitialize</Constructor>
+ </Extern>
+ <Extern>
+ <SetVirtualAddressMapCallBack>FvbVirtualAddressChangeNotifyEvent</SetVirtualAddressMapCallBack>
+ </Extern>
+ </Externs>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/EdkFvbServiceLib/Fvb.h b/EdkModulePkg/Library/EdkFvbServiceLib/Fvb.h
new file mode 100644
index 0000000..c6d1eb7
--- /dev/null
+++ b/EdkModulePkg/Library/EdkFvbServiceLib/Fvb.h
@@ -0,0 +1,31 @@
+/*++
+
+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:
+
+ Fvb.h
+
+Abstract:
+
+--*/
+
+#ifndef __FVB_H__
+#define __FVB_H__
+
+#define MAX_FVB_COUNT 16
+
+typedef struct {
+ EFI_HANDLE Handle;
+ EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
+ EFI_FVB_EXTENSION_PROTOCOL *FvbExtension;
+} FVB_ENTRY;
+
+#endif
diff --git a/EdkModulePkg/Library/EdkFvbServiceLib/Ia32/Fvb.c b/EdkModulePkg/Library/EdkFvbServiceLib/Ia32/Fvb.c
new file mode 100644
index 0000000..222fb9b
--- /dev/null
+++ b/EdkModulePkg/Library/EdkFvbServiceLib/Ia32/Fvb.c
@@ -0,0 +1,534 @@
+/*++
+
+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:
+
+ 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 "Fvb.h"
+
+//
+// Lib will ASSERT if more FVB devices than this are added to the system.
+//
+STATIC FVB_ENTRY *mFvbEntry;
+STATIC EFI_EVENT mFvbRegistration;
+STATIC BOOLEAN mEfiFvbInitialized = FALSE;
+STATIC UINTN mFvbCount;
+
+STATIC
+VOID
+EFIAPI
+FvbNotificationEvent (
+ 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;
+
+ 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++;;
+ mFvbEntry[UpdateIndex].Handle = Handle;
+ }
+ //
+ // The array does not have enough entries
+ //
+ ASSERT (UpdateIndex < MAX_FVB_COUNT);
+
+ //
+ // Get the interface pointer and if it's ours, skip it
+ //
+ Status = gBS->HandleProtocol (Handle, &gEfiFirmwareVolumeBlockProtocolGuid, (VOID **) &mFvbEntry[UpdateIndex].Fvb);
+ ASSERT_EFI_ERROR (Status);
+
+ Status = gBS->HandleProtocol (Handle, &gEfiFvbExtensionProtocolGuid, (VOID **) &mFvbEntry[UpdateIndex].FvbExtension);
+ if (Status != EFI_SUCCESS) {
+ mFvbEntry[UpdateIndex].FvbExtension = NULL;
+ }
+ }
+}
+
+VOID
+EFIAPI
+FvbVirtualAddressChangeNotifyEvent (
+ 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) {
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->GetBlockSize);
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->GetPhysicalAddress);
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->GetVolumeAttributes);
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->SetVolumeAttributes);
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->Read);
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->Write);
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->EraseBlocks);
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb);
+ }
+
+ if (NULL != mFvbEntry[Index].FvbExtension) {
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].FvbExtension->EraseFvbCustomBlock);
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].FvbExtension);
+ }
+ }
+
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry);
+ }
+}
+
+EFI_STATUS
+EFIAPI
+FvbLibInitialize (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+ Initialize globals and register Fvb Protocol notification function.
+
+Arguments:
+ None
+
+Returns:
+ EFI_SUCCESS
+
+--*/
+{
+ UINTN Status;
+ mFvbCount = 0;
+
+ Status = gBS->AllocatePool (
+ EfiRuntimeServicesData,
+ (UINTN) sizeof (FVB_ENTRY) * MAX_FVB_COUNT,
+ (VOID *) &mFvbEntry
+ );
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ ZeroMem (mFvbEntry, sizeof (FVB_ENTRY) * MAX_FVB_COUNT);
+
+ EfiCreateProtocolNotifyEvent (
+ &gEfiFirmwareVolumeBlockProtocolGuid,
+ EFI_TPL_CALLBACK,
+ FvbNotificationEvent,
+ 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);
+ //
+
+ //
+ // Register SetVirtualAddressMap () notify function
+ //
+
+ ASSERT_EFI_ERROR (Status);
+
+ mEfiFvbInitialized = TRUE;
+
+ 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/EdkModulePkg/Library/EdkFvbServiceLib/Ipf/Fvb.c b/EdkModulePkg/Library/EdkFvbServiceLib/Ipf/Fvb.c
new file mode 100644
index 0000000..58ad6f5
--- /dev/null
+++ b/EdkModulePkg/Library/EdkFvbServiceLib/Ipf/Fvb.c
@@ -0,0 +1,324 @@
+/*++
+
+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:
+
+ 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 ().
+
+--*/
+
+EFI_STATUS
+FvbLibInitialize (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+ Initialize globals and register Fvb Protocol notification function.
+
+Arguments:
+ None
+
+Returns:
+ EFI_SUCCESS
+
+--*/
+{
+ return EFI_SUCCESS;
+}
+//
+// The following functions wrap Fvb protocol in the Runtime Lib functions.
+// The Instance translates into Fvb instance. The Fvb order defined by HOBs and
+// thus the sequence of FVB protocol addition define Instance.
+//
+// EfiFvbInitialize () must be called before any of the following functions
+// must be called.
+//
+EFI_STATUS
+EfiFvbReadBlock (
+ IN UINTN Instance,
+ IN EFI_LBA Lba,
+ IN UINTN Offset,
+ IN OUT UINTN *NumBytes,
+ IN UINT8 *Buffer
+ )
+/*++
+
+Routine Description:
+ Reads specified number of bytes into a buffer from the specified block
+
+Arguments:
+ Instance - The FV instance to be read from
+ Lba - The logical block address to be read from
+ Offset - Offset into the block at which to begin reading
+ NumBytes - Pointer that on input contains the total size of
+ the buffer. On output, it contains the total number
+ of bytes read
+ Buffer - Pointer to a caller allocated buffer that will be
+ used to hold the data read
+
+Returns:
+ Status code
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;
+
+ return EfiCallEsalService (&Guid, Read, Instance, Lba, Offset, (UINT64) NumBytes, (UINT64) Buffer, 0, 0).Status;
+}
+
+EFI_STATUS
+EfiFvbWriteBlock (
+ IN UINTN Instance,
+ IN EFI_LBA Lba,
+ IN UINTN Offset,
+ IN OUT UINTN *NumBytes,
+ IN UINT8 *Buffer
+ )
+/*++
+
+Routine Description:
+ Writes specified number of bytes from the input buffer to the block
+
+Arguments:
+ Instance - The FV instance to be written to
+ Lba - The starting logical block index to write to
+ Offset - Offset into the block at which to begin writing
+ NumBytes - Pointer that on input contains the total size of
+ the buffer. On output, it contains the total number
+ of bytes actually written
+ Buffer - Pointer to a caller allocated buffer that contains
+ the source for the write
+
+Returns:
+ Status code
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;
+
+ return EfiCallEsalService (&Guid, Write, Instance, Lba, Offset, (UINT64) NumBytes, (UINT64) Buffer, 0, 0).Status;
+}
+
+EFI_STATUS
+EfiFvbEraseBlock (
+ IN UINTN Instance,
+ IN UINTN Lba
+ )
+/*++
+
+Routine Description:
+ Erases and initializes a firmware volume block
+
+Arguments:
+ Instance - The FV instance to be erased
+ Lba - The logical block index to be erased
+
+Returns:
+ Status code
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;
+
+ return EfiCallEsalService (&Guid, EraseBlock, Instance, Lba, 0, 0, 0, 0, 0).Status;
+}
+
+EFI_STATUS
+EfiFvbGetVolumeAttributes (
+ IN UINTN Instance,
+ OUT EFI_FVB_ATTRIBUTES *Attributes
+ )
+/*++
+
+Routine Description:
+ Retrieves attributes, insures positive polarity of attribute bits, returns
+ resulting attributes in output parameter
+
+Arguments:
+ Instance - The FV instance whose attributes is going to be
+ returned
+ Attributes - Output buffer which contains attributes
+
+Returns:
+ Status code
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;
+
+ return EfiCallEsalService (&Guid, SetVolumeAttributes, Instance, (UINT64) Attributes, 0, 0, 0, 0, 0).Status;
+}
+
+EFI_STATUS
+EfiFvbSetVolumeAttributes (
+ IN UINTN Instance,
+ IN EFI_FVB_ATTRIBUTES Attributes
+ )
+/*++
+
+Routine Description:
+ Modifies the current settings of the firmware volume according to the
+ input parameter, and returns the new setting of the volume
+
+Arguments:
+ Instance - The FV instance whose attributes is going to be
+ modified
+ Attributes - On input, it is a pointer to EFI_FVB_ATTRIBUTES
+ containing the desired firmware volume settings.
+ On successful return, it contains the new settings
+ of the firmware volume
+
+Returns:
+ Status code
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;
+
+ return EfiCallEsalService (&Guid, SetVolumeAttributes, Instance, (UINT64) Attributes, 0, 0, 0, 0, 0).Status;
+}
+
+EFI_STATUS
+EfiFvbGetPhysicalAddress (
+ IN UINTN Instance,
+ OUT EFI_PHYSICAL_ADDRESS *BaseAddress
+ )
+/*++
+
+Routine Description:
+ Retrieves the physical address of a memory mapped FV
+
+Arguments:
+ Instance - The FV instance whose base address is going to be
+ returned
+ BaseAddress - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS
+ that on successful return, contains the base address
+ of the firmware volume.
+
+Returns:
+ Status code
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;
+
+ return EfiCallEsalService (&Guid, GetPhysicalAddress, Instance, (UINT64) BaseAddress, 0, 0, 0, 0, 0).Status;
+}
+
+EFI_STATUS
+EfiFvbGetBlockSize (
+ IN UINTN Instance,
+ IN EFI_LBA Lba,
+ OUT UINTN *BlockSize,
+ OUT UINTN *NumOfBlocks
+ )
+/*++
+
+Routine Description:
+ Retrieve the size of a logical block
+
+Arguments:
+ Instance - The FV instance whose block size is going to be
+ returned
+ Lba - Indicates which block to return the size for.
+ BlockSize - A pointer to a caller allocated UINTN in which
+ the size of the block is returned
+ NumOfBlocks - a pointer to a caller allocated UINTN in which the
+ number of consecutive blocks starting with Lba is
+ returned. All blocks in this range have a size of
+ BlockSize
+
+Returns:
+ EFI_SUCCESS - The firmware volume was read successfully and
+ contents are in Buffer
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;
+
+ return EfiCallEsalService (
+ &Guid,
+ GetBlockSize,
+ Instance,
+ Lba,
+ (UINT64) BlockSize,
+ (UINT64) NumOfBlocks,
+ 0,
+ 0,
+ 0
+ ).Status;
+}
+
+EFI_STATUS
+EfiFvbEraseCustomBlockRange (
+ IN UINTN Instance,
+ IN EFI_LBA StartLba,
+ IN UINTN OffsetStartLba,
+ IN EFI_LBA LastLba,
+ IN UINTN OffsetLastLba
+ )
+/*++
+
+Routine Description:
+ Erases and initializes a specified range of a firmware volume
+
+Arguments:
+ Instance - The FV instance to be erased
+ StartLba - The starting logical block index to be erased
+ OffsetStartLba - Offset into the starting block at which to
+ begin erasing
+ LastLba - The last logical block index to be erased
+ OffsetLastLba - Offset into the last block at which to end erasing
+
+Returns:
+ Status code
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;
+
+ return EfiCallEsalService (
+ &Guid,
+ EraseCustomBlockRange,
+ Instance,
+ StartLba,
+ OffsetStartLba,
+ LastLba,
+ OffsetLastLba,
+ 0,
+ 0
+ ).Status;
+}
+
+
+/**
+ BugBug: Can't turn this off in the current MSA so we need a stub
+**/
+VOID
+EFIAPI
+FvbVirtualAddressChangeNotifyEvent (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+}
diff --git a/EdkModulePkg/Library/EdkFvbServiceLib/build.xml b/EdkModulePkg/Library/EdkFvbServiceLib/build.xml
new file mode 100644
index 0000000..ebbb303
--- /dev/null
+++ b/EdkModulePkg/Library/EdkFvbServiceLib/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="EdkFvbServiceLib"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\EdkFvbServiceLib"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="EdkFvbServiceLib">
+ <GenBuild baseName="EdkFvbServiceLib" mbdFilename="${MODULE_DIR}\EdkFvbServiceLib.mbd" msaFilename="${MODULE_DIR}\EdkFvbServiceLib.msa"/>
+ </target>
+ <target depends="EdkFvbServiceLib_clean" name="clean"/>
+ <target depends="EdkFvbServiceLib_cleanall" name="cleanall"/>
+ <target name="EdkFvbServiceLib_clean">
+ <OutputDirSetup baseName="EdkFvbServiceLib" mbdFilename="${MODULE_DIR}\EdkFvbServiceLib.mbd" msaFilename="${MODULE_DIR}\EdkFvbServiceLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkFvbServiceLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkFvbServiceLib_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="EdkFvbServiceLib_cleanall">
+ <OutputDirSetup baseName="EdkFvbServiceLib" mbdFilename="${MODULE_DIR}\EdkFvbServiceLib.mbd" msaFilename="${MODULE_DIR}\EdkFvbServiceLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkFvbServiceLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkFvbServiceLib_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**EdkFvbServiceLib*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/EdkFvbServiceLib/x64/Fvb.c b/EdkModulePkg/Library/EdkFvbServiceLib/x64/Fvb.c
new file mode 100644
index 0000000..76ddfa8
--- /dev/null
+++ b/EdkModulePkg/Library/EdkFvbServiceLib/x64/Fvb.c
@@ -0,0 +1,536 @@
+/*++
+
+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:
+
+ 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 "Fvb.h"
+
+//
+// Lib will ASSERT if more FVB devices than this are added to the system.
+//
+STATIC FVB_ENTRY *mFvbEntry;
+STATIC EFI_EVENT mFvbVirtualNotifyEvent;
+STATIC EFI_EVENT mFvbRegistration;
+STATIC EFI_EVENT mEfiFvbVirtualNotifyEvent;
+STATIC BOOLEAN mEfiFvbInitialized = FALSE;
+STATIC UINTN mFvbCount;
+
+STATIC
+VOID
+EFIAPI
+FvbNotificationEvent (
+ 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;
+
+ 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++;;
+ mFvbEntry[UpdateIndex].Handle = Handle;
+ }
+ //
+ // The array does not have enough entries
+ //
+ ASSERT (UpdateIndex < MAX_FVB_COUNT);
+
+ //
+ // Get the interface pointer and if it's ours, skip it
+ //
+ Status = gBS->HandleProtocol (Handle, &gEfiFirmwareVolumeBlockProtocolGuid, &mFvbEntry[UpdateIndex].Fvb);
+ ASSERT_EFI_ERROR (Status);
+
+ Status = gBS->HandleProtocol (Handle, &gEfiFvbExtensionProtocolGuid, &mFvbEntry[UpdateIndex].FvbExtension);
+ if (Status != EFI_SUCCESS) {
+ mFvbEntry[UpdateIndex].FvbExtension = NULL;
+ }
+ }
+}
+
+VOID
+EFIAPI
+FvbVirtualAddressChangeNotifyEvent (
+ 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) {
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->GetBlockSize);
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->GetPhysicalAddress);
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->GetVolumeAttributes);
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->SetVolumeAttributes);
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->Read);
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->Write);
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb->EraseBlocks);
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].Fvb);
+ }
+
+ if (NULL != mFvbEntry[Index].FvbExtension) {
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].FvbExtension->EraseFvbCustomBlock);
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry[Index].FvbExtension);
+ }
+ }
+
+ EfiConvertPointer (0x0, (VOID **) &mFvbEntry);
+ }
+}
+
+EFI_STATUS
+EFIAPI
+FvbLibInitialize (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+ Initialize globals and register Fvb Protocol notification function.
+
+Arguments:
+ None
+
+Returns:
+ EFI_SUCCESS
+
+--*/
+{
+ UINTN Status;
+ mFvbCount = 0;
+
+ Status = gBS->AllocatePool (
+ EfiRuntimeServicesData,
+ (UINTN) sizeof (FVB_ENTRY) * MAX_FVB_COUNT,
+ (VOID *) &mFvbEntry
+ );
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ ZeroMem (mFvbEntry, sizeof (FVB_ENTRY) * MAX_FVB_COUNT);
+
+ EfiCreateProtocolNotifyEvent (
+ &gEfiFirmwareVolumeBlockProtocolGuid,
+ EFI_TPL_CALLBACK,
+ FvbNotificationEvent,
+ 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);
+ //
+
+ //
+ // Register SetVirtualAddressMap () notify function
+ //
+
+ ASSERT_EFI_ERROR (Status);
+
+ mEfiFvbInitialized = TRUE;
+
+ 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/EdkModulePkg/Library/EdkGraphicsLib/EdkGraphicsLib.mbd b/EdkModulePkg/Library/EdkGraphicsLib/EdkGraphicsLib.mbd
new file mode 100644
index 0000000..4758d6b
--- /dev/null
+++ b/EdkModulePkg/Library/EdkGraphicsLib/EdkGraphicsLib.mbd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>EdkGraphicsLib</BaseName>
+ <Guid>08c1a0e4-1208-47f8-a2c5-f42eabee653a</Guid>
+ <Version>0</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Created>2006-03-12 17:09</Created>
+ <Modified>2006-03-19 15:19</Modified>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/EdkGraphicsLib/EdkGraphicsLib.msa b/EdkModulePkg/Library/EdkGraphicsLib/EdkGraphicsLib.msa
new file mode 100644
index 0000000..03b4f51
--- /dev/null
+++ b/EdkModulePkg/Library/EdkGraphicsLib/EdkGraphicsLib.msa
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>EdkGraphicsLib</BaseName>
+ <ModuleType>DXE_DRIVER</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>08c1a0e4-1208-47f8-a2c5-f42eabee653a</Guid>
+ <Version>0</Version>
+ <Abstract>Graphics Library for UEFI drivers</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>0</Specification>
+ <Created>2006-03-12 17:09</Created>
+ <Updated>2006-03-19 15:19</Updated>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">EdkGraphicsLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PrintLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">MemoryAllocationLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>Graphics.c</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+ <Protocols>
+ <Protocol Usage="ALWAYS_CONSUMED">OEMBadging</Protocol>
+ <Protocol Usage="ALWAYS_CONSUMED">FirmwareVolume</Protocol>
+ <Protocol Usage="ALWAYS_CONSUMED">ConsoleControl</Protocol>
+ <Protocol Usage="ALWAYS_CONSUMED">UgaDraw</Protocol>
+ <Protocol Usage="ALWAYS_CONSUMED">SimpleTextOut</Protocol>
+ </Protocols>
+ <Guids>
+ <GuidEntry Usage="ALWAYS_CONSUMED">
+ <C_Name>Bmp</C_Name>
+ </GuidEntry>
+ </Guids>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/EdkGraphicsLib/Graphics.c b/EdkModulePkg/Library/EdkGraphicsLib/Graphics.c
new file mode 100644
index 0000000..01c612a
--- /dev/null
+++ b/EdkModulePkg/Library/EdkGraphicsLib/Graphics.c
@@ -0,0 +1,780 @@
+/*++
+
+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:
+
+ Graphics.c
+
+Abstract:
+
+ Support for Basic Graphics operations.
+
+ BugBug: Currently *.BMP files are supported. This will be replaced
+ when Tiano graphics format is supported.
+
+--*/
+
+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;
+ EFI_FIRMWARE_VOLUME_PROTOCOL *Fv;
+ UINTN Index;
+ UINT32 AuthenticationStatus;
+
+
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiFirmwareVolumeProtocolGuid,
+ NULL,
+ &FvProtocolCount,
+ &FvHandles
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_NOT_FOUND;
+ }
+
+ for (Index = 0; Index < FvProtocolCount; Index++) {
+ Status = gBS->HandleProtocol (
+ FvHandles[Index],
+ &gEfiFirmwareVolumeProtocolGuid,
+ (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)) {
+ return EFI_SUCCESS;
+ } else if (Status == EFI_BUFFER_TOO_SMALL) {
+ //
+ // ImageSize updated to needed size so return
+ //
+ return EFI_BUFFER_TOO_SMALL;
+ }
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+
+EFI_STATUS
+ConvertBmpToUgaBlt (
+ IN VOID *BmpImage,
+ IN UINTN BmpImageSize,
+ IN OUT VOID **UgaBlt,
+ IN OUT UINTN *UgaBltSize,
+ OUT UINTN *PixelHeight,
+ OUT UINTN *PixelWidth
+ )
+/*++
+
+Routine Description:
+
+ Convert a *.BMP graphics image to a UGA blt buffer. If a NULL UgaBlt buffer
+ is passed in a UgaBlt buffer will be allocated by this routine. If a UgaBlt
+ 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
+
+ UgaBlt - Buffer containing UGA version of BmpImage.
+
+ UgaBltSize - Size of UgaBlt in bytes.
+
+ PixelHeight - Height of UgaBlt/BmpImage in pixels
+
+ PixelWidth - Width of UgaBlt/BmpImage in pixels
+
+
+Returns:
+
+ EFI_SUCCESS - UgaBlt and UgaBltSize are returned.
+ EFI_UNSUPPORTED - BmpImage is not a valid *.BMP image
+ EFI_BUFFER_TOO_SMALL - The passed in UgaBlt buffer is not big enough.
+ UgaBltSize 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_UGA_PIXEL *BltBuffer;
+ EFI_UGA_PIXEL *Blt;
+ UINTN BltBufferSize;
+ UINTN Index;
+ UINTN Height;
+ UINTN Width;
+ UINTN ImageIndex;
+
+ BmpHeader = (BMP_IMAGE_HEADER *) BmpImage;
+ if (BmpHeader->CharB != 'B' || BmpHeader->CharM != 'M') {
+ return EFI_UNSUPPORTED;
+ }
+
+ if (BmpHeader->CompressionType != 0) {
+ return EFI_UNSUPPORTED;
+ }
+
+ //
+ // Calculate Color Map offset in the image.
+ //
+ Image = BmpImage;
+ BmpColorMap = (BMP_COLOR_MAP *) (Image + sizeof (BMP_IMAGE_HEADER));
+
+ //
+ // Calculate graphics image data address in the image
+ //
+ Image = ((UINT8 *) BmpImage) + BmpHeader->ImageOffset;
+ ImageHeader = Image;
+
+ BltBufferSize = BmpHeader->PixelWidth * BmpHeader->PixelHeight * sizeof (EFI_UGA_PIXEL);
+ if (*UgaBlt == NULL) {
+ *UgaBltSize = BltBufferSize;
+ *UgaBlt = AllocatePool (*UgaBltSize);
+ if (*UgaBlt == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ } else {
+ if (*UgaBltSize < BltBufferSize) {
+ *UgaBltSize = BltBufferSize;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+ }
+
+ *PixelWidth = BmpHeader->PixelWidth;
+ *PixelHeight = BmpHeader->PixelHeight;
+
+ //
+ // Convert image from BMP to Blt buffer format
+ //
+ BltBuffer = *UgaBlt;
+ 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:
+ return EFI_UNSUPPORTED;
+ break;
+ };
+
+ }
+
+ ImageIndex = (UINTN) (Image - ImageHeader);
+ if ((ImageIndex % 4) != 0) {
+ //
+ // Bmp Image starts each row on a 32-bit boundary!
+ //
+ Image = Image + (4 - (ImageIndex % 4));
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+LockKeyboards (
+ IN CHAR16 *Password
+ )
+/*++
+
+Routine Description:
+ Use Console Control Protocol to lock the Console In Spliter virtual handle.
+ This is the ConInHandle and ConIn handle in the EFI system table. All key
+ presses will be ignored until the Password is typed in. The only way to
+ disable the password is to type it in to a ConIn device.
+
+Arguments:
+ Password - Password used to lock ConIn device
+
+
+Returns:
+
+ EFI_SUCCESS - ConsoleControl has been flipped to graphics and logo
+ displayed.
+ EFI_UNSUPPORTED - Logo not found
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;
+
+ Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, (VOID **) &ConsoleControl);
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ Status = ConsoleControl->LockStdIn (ConsoleControl, Password);
+ return Status;
+}
+
+
+EFI_STATUS
+EnableQuietBoot (
+ IN EFI_GUID *LogoFile
+ )
+/*++
+
+Routine Description:
+
+ Use Console Control to turn off UGA based Simple Text Out consoles from going
+ to the UGA device. Put up LogoFile on every UGA device that is a console
+
+Arguments:
+
+ LogoFile - File name of logo to display on the center of the screen.
+
+
+Returns:
+
+ EFI_SUCCESS - ConsoleControl has been flipped to graphics and logo
+ displayed.
+ EFI_UNSUPPORTED - Logo not found
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;
+ EFI_UGA_DRAW_PROTOCOL *UgaDraw;
+ EFI_OEM_BADGING_PROTOCOL *Badging;
+ UINT32 SizeOfX;
+ UINT32 SizeOfY;
+ UINT32 ColorDepth;
+ UINT32 RefreshRate;
+ INTN DestX;
+ INTN DestY;
+
+ UINT8 *ImageData;
+ UINTN ImageSize;
+ EFI_UGA_PIXEL *UgaBlt;
+ UINTN UgaBltSize;
+
+ UINT32 Instance;
+ EFI_BADGING_FORMAT Format;
+ EFI_BADGING_DISPLAY_ATTRIBUTE Attribute;
+ UINTN CoordinateX;
+ UINTN CoordinateY;
+ UINTN Height;
+ UINTN Width;
+
+ Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, (VOID **) &ConsoleControl);
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ 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);
+
+ Status = UgaDraw->GetMode (UgaDraw, &SizeOfX, &SizeOfY, &ColorDepth, &RefreshRate);
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ Instance = 0;
+ while (1) {
+ ImageData = NULL;
+ ImageSize = 0;
+
+ if (Badging != NULL) {
+ Status = Badging->GetImage (
+ Badging,
+ &Instance,
+ &Format,
+ &ImageData,
+ &ImageSize,
+ &Attribute,
+ &CoordinateX,
+ &CoordinateY
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Currently only support BMP format
+ //
+ if (Format != EfiBadgingFormatBMP) {
+ gBS->FreePool (ImageData);
+ continue;
+ }
+ } else {
+ Status = GetGraphicsBitMapFromFV (LogoFile, (VOID **) &ImageData, &ImageSize);
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ CoordinateX = 0;
+ CoordinateY = 0;
+ Attribute = EfiBadgingDisplayAttributeCenter;
+ }
+
+ UgaBlt = NULL;
+ Status = ConvertBmpToUgaBlt (
+ ImageData,
+ ImageSize,
+ (VOID **) &UgaBlt,
+ &UgaBltSize,
+ &Height,
+ &Width
+ );
+ if (EFI_ERROR (Status)) {
+ gBS->FreePool (ImageData);
+ 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)) {
+ Status = UgaDraw->Blt (
+ UgaDraw,
+ UgaBlt,
+ EfiUgaBltBufferToVideo,
+ 0,
+ 0,
+ (UINTN) DestX,
+ (UINTN) DestY,
+ Width,
+ Height,
+ Width * sizeof (EFI_UGA_PIXEL)
+ );
+ }
+
+ gBS->FreePool (ImageData);
+ gBS->FreePool (UgaBlt);
+
+ if (Badging == NULL) {
+ break;
+ }
+ }
+
+ return Status;
+}
+
+
+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 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);
+}
+
+static EFI_UGA_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 }
+};
+
+STATIC
+UINTN
+_IPrint (
+ IN EFI_UGA_DRAW_PROTOCOL *UgaDraw,
+ IN EFI_SIMPLE_TEXT_OUT_PROTOCOL *Sto,
+ IN UINTN X,
+ IN UINTN Y,
+ IN EFI_UGA_PIXEL *Foreground,
+ IN EFI_UGA_PIXEL *Background,
+ IN CHAR16 *fmt,
+ IN VA_LIST args
+ )
+/*++
+
+Routine Description:
+
+ Display string worker for: Print, PrintAt, IPrint, IPrintAt
+
+Arguments:
+
+ UgaDraw - UGA draw protocol interface
+
+ Sto - Simple text out protocol interface
+
+ X - X coordinate to start printing
+
+ Y - Y coordinate to start printing
+
+ Foreground - Foreground color
+
+ Background - Background color
+
+ fmt - Format string
+
+ args - Print arguments
+
+Returns:
+
+ EFI_SUCCESS - success
+ EFI_OUT_OF_RESOURCES - out of resources
+
+--*/
+{
+ VOID *Buffer;
+ EFI_STATUS Status;
+ UINT16 GlyphWidth;
+ UINT32 GlyphStatus;
+ UINT16 StringIndex;
+ UINTN Index;
+ CHAR16 *UnicodeWeight;
+ EFI_NARROW_GLYPH *Glyph;
+ EFI_HII_PROTOCOL *Hii;
+ EFI_UGA_PIXEL *LineBuffer;
+ UINT32 HorizontalResolution;
+ UINT32 VerticalResolution;
+ UINT32 ColorDepth;
+ UINT32 RefreshRate;
+
+ GlyphStatus = 0;
+
+ //
+ // For now, allocate an arbitrarily long buffer
+ //
+ Buffer = AllocateZeroPool (0x10000);
+ if (Buffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ UgaDraw->GetMode (UgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate);
+
+ LineBuffer = AllocatePool (sizeof (EFI_UGA_PIXEL) * HorizontalResolution * GLYPH_WIDTH * GLYPH_HEIGHT);
+ if (LineBuffer == NULL) {
+ gBS->FreePool (Buffer);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = gBS->LocateProtocol (&gEfiHiiProtocolGuid, NULL, (VOID **) &Hii);
+ if (EFI_ERROR (Status)) {
+ goto Error;
+ }
+
+ UnicodeVSPrint (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;
+ }
+ }
+
+ for (Index = 0; Index < StrLen (Buffer); 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],
+ StrLen (Buffer),
+ GlyphWidth,
+ GLYPH_HEIGHT,
+ &LineBuffer[Index * GLYPH_WIDTH]
+ );
+ } else {
+ Status = Hii->GlyphToBlt (
+ Hii,
+ (UINT8 *) Glyph,
+ *Foreground,
+ *Background,
+ StrLen (Buffer),
+ GlyphWidth,
+ GLYPH_HEIGHT,
+ &LineBuffer[Index * GLYPH_WIDTH]
+ );
+ }
+ }
+
+ //
+ // Blt a character to the screen
+ //
+ Status = UgaDraw->Blt (
+ UgaDraw,
+ LineBuffer,
+ EfiUgaBltBufferToVideo,
+ 0,
+ 0,
+ X,
+ Y,
+ GLYPH_WIDTH * StrLen (Buffer),
+ GLYPH_HEIGHT,
+ GLYPH_WIDTH * StrLen (Buffer) * sizeof (EFI_UGA_PIXEL)
+ );
+
+Error:
+ gBS->FreePool (LineBuffer);
+ gBS->FreePool (Buffer);
+ return Status;
+}
+
+
+UINTN
+PrintXY (
+ IN UINTN X,
+ IN UINTN Y,
+ IN EFI_UGA_PIXEL *ForeGround, OPTIONAL
+ IN EFI_UGA_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
+
+--*/
+{
+ EFI_HANDLE Handle;
+ 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,
+ &gEfiUgaDrawProtocolGuid,
+ (VOID **) &UgaDraw
+ );
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = gBS->HandleProtocol (
+ Handle,
+ &gEfiSimpleTextOutProtocolGuid,
+ (VOID **) &Sto
+ );
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ return _IPrint (UgaDraw, Sto, X, Y, ForeGround, BackGround, Fmt, Args);
+}
diff --git a/EdkModulePkg/Library/EdkGraphicsLib/build.xml b/EdkModulePkg/Library/EdkGraphicsLib/build.xml
new file mode 100644
index 0000000..cccef0e
--- /dev/null
+++ b/EdkModulePkg/Library/EdkGraphicsLib/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="EdkGraphicsLib"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\EdkGraphicsLib"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="EdkGraphicsLib">
+ <GenBuild baseName="EdkGraphicsLib" mbdFilename="${MODULE_DIR}\EdkGraphicsLib.mbd" msaFilename="${MODULE_DIR}\EdkGraphicsLib.msa"/>
+ </target>
+ <target depends="EdkGraphicsLib_clean" name="clean"/>
+ <target depends="EdkGraphicsLib_cleanall" name="cleanall"/>
+ <target name="EdkGraphicsLib_clean">
+ <OutputDirSetup baseName="EdkGraphicsLib" mbdFilename="${MODULE_DIR}\EdkGraphicsLib.mbd" msaFilename="${MODULE_DIR}\EdkGraphicsLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkGraphicsLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkGraphicsLib_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="EdkGraphicsLib_cleanall">
+ <OutputDirSetup baseName="EdkGraphicsLib" mbdFilename="${MODULE_DIR}\EdkGraphicsLib.mbd" msaFilename="${MODULE_DIR}\EdkGraphicsLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkGraphicsLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkGraphicsLib_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**EdkGraphicsLib*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/EdkIfrSupportLib/EdkIfrSupportLib.mbd b/EdkModulePkg/Library/EdkIfrSupportLib/EdkIfrSupportLib.mbd
new file mode 100644
index 0000000..3864ea2
--- /dev/null
+++ b/EdkModulePkg/Library/EdkIfrSupportLib/EdkIfrSupportLib.mbd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>EdkIfrSupportLib</BaseName>
+ <Guid>ea55bada-d488-427b-9d2d-227e0aaa3707</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Created>2006-03-12 17:09</Created>
+ <Modified>2006-03-31 13:14</Modified>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/EdkIfrSupportLib/EdkIfrSupportLib.msa b/EdkModulePkg/Library/EdkIfrSupportLib/EdkIfrSupportLib.msa
new file mode 100644
index 0000000..fcf02af
--- /dev/null
+++ b/EdkModulePkg/Library/EdkIfrSupportLib/EdkIfrSupportLib.msa
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>EdkIfrSupportLib</BaseName>
+ <ModuleType>DXE_DRIVER</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>ea55bada-d488-427b-9d2d-227e0aaa3707</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Abstract>Graphics Library for UEFI drivers</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>EFI_SPECIFICATION_VERSION 0x00000000</Specification>
+ <Created>2006-03-12 17:09</Created>
+ <Updated>2006-03-31 13:14</Updated>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">EdkIfrSupportLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PrintLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseMemoryLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">MemoryAllocationLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiRuntimeServicesTableLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>IfrCommon.c</Filename>
+ <Filename>IfrOnTheFly.c</Filename>
+ <Filename>IfrOpCodeCreation.c</Filename>
+ <Filename>IfrLibrary.h</Filename>
+ <Filename>IfrVariable.c</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+ <Protocols>
+ <Protocol Usage="ALWAYS_CONSUMED">Hii</Protocol>
+ </Protocols>
+ <Variables>
+ <Variable>
+ <String>L"Lang"</String>
+ <Guid>0x8BE4DF61, 0x93CA, 0x11d2, {0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C}</Guid>
+ </Variable>
+ </Variables>
+ <Guids>
+ <GuidEntry Usage="ALWAYS_CONSUMED">
+ <C_Name>GlobalVariable</C_Name>
+ </GuidEntry>
+ </Guids>
+ <Externs>
+ <Extern>
+ <Constructor>IfrLibConstruct</Constructor>
+ </Extern>
+ </Externs>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/EdkIfrSupportLib/IfrCommon.c b/EdkModulePkg/Library/EdkIfrSupportLib/IfrCommon.c
new file mode 100644
index 0000000..6d0a84d
--- /dev/null
+++ b/EdkModulePkg/Library/EdkIfrSupportLib/IfrCommon.c
@@ -0,0 +1,995 @@
+/*++
+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:
+ IfrCommon.c
+
+Abstract:
+
+ Common Library Routines to assist in IFR creation on-the-fly
+
+Revision History:
+
+--*/
+
+EFI_STATUS
+IfrLibConstruct (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EFI_SUCCESS;
+}
+
+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 (
+ (CHAR16 *) L"Lang",
+ &gEfiGlobalVariableGuid,
+ NULL,
+ &Size,
+ Language
+ );
+
+ if (EFI_ERROR (Status)) {
+ AsciiStrCpy (Language, "eng");
+ }
+
+ for (Index = 0; Language[Index] != 0; 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 = AllocateZeroPool (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 (CompareMem ((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
+ //
+ CopyMem (&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] +
+ StrSize((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
+ //
+ StrCpy ((CHAR16 *) Destination, (CHAR16 *) Source);
+
+ //
+ // Adjust the source/destination to the next string location
+ //
+ Destination = Destination + StrSize ((CHAR16 *) Source);
+ Source = Source + StrSize ((CHAR16 *) Source);
+ }
+
+ //
+ // This copies the new string to the destination buffer
+ //
+ StrCpy ((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 + StrSize (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.
+ //
+ CopyMem (&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) +
+ StrSize (Language) +
+ StrSize (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] + StrSize (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 = (UINT8 *) &PackDestination[3];
+
+ //
+ // Copy the language name string to the new buffer
+ //
+ StrCpy ((CHAR16 *) Destination, Language);
+
+ //
+ // Advance the destination to the new empty spot
+ //
+ Destination = Destination + StrSize (Language);
+
+ //
+ // Copy the string to the new buffer
+ //
+ StrCpy ((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
+ //
+ ZeroMem (StringBuffer, DEFAULT_STRING_BUFFER_SIZE);
+ CopyMem (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 = AllocateZeroPool (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
+ //
+ CopyMem (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
+ //
+ CopyMem (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
+ //
+ CopyMem (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
+ //
+ CopyMem (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
+ //
+ CopyMem (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
+ //
+ ZeroMem (FormBuffer, DEFAULT_FORM_BUFFER_SIZE);
+ CopyMem (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 = AllocateZeroPool (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 = AllocateZeroPool (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
+ //
+ CopyMem (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;
+ }
+
+ if (DefaultImage != NULL) {
+ ZeroMem (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) {
+ CopyMem (&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_CHECKBOX *) &RawData[Index])->Flags;
+ break;
+
+ case EFI_IFR_NUMERIC_OP:
+ CopyMem (
+ &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 = AllocatePool (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 = AllocatePool (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 (CompareGuid (&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 = AllocateZeroPool (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 = AllocateZeroPool (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) {
+ CopyMem (&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 = AllocateZeroPool (SizeOfNvStore);
+ if (VariableData == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = gRT->GetVariable (
+ (CHAR16 *) 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 = AllocatePool (SizeOfNvStore);
+ if (VariableData == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = gRT->GetVariable (
+ (CHAR16 *) 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_CHECKBOX *) &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;
+}
+
diff --git a/EdkModulePkg/Library/EdkIfrSupportLib/IfrOnTheFly.c b/EdkModulePkg/Library/EdkIfrSupportLib/IfrOnTheFly.c
new file mode 100644
index 0000000..e3d1040
--- /dev/null
+++ b/EdkModulePkg/Library/EdkIfrSupportLib/IfrOnTheFly.c
@@ -0,0 +1,972 @@
+/*++
+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:
+ IfrOnTheFly.c
+
+Abstract:
+
+ Library Routines to create IFR on-the-fly
+
+Revision History:
+
+--*/
+
+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 = AllocateZeroPool (DEFAULT_FORM_BUFFER_SIZE);
+ if (FormBuffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Pre-allocate a buffer sufficient for us to work from.
+ //
+ StringBuffer = AllocateZeroPool (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;
+ CopyMem (&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 = (UINT8 *) *FormBuffer;
+
+ //
+ // Copy the formset/endformset data to the form buffer
+ //
+ CopyMem (Destination, &IfrPack, sizeof (EFI_HII_PACK_HEADER));
+
+ Destination = Destination + sizeof (EFI_HII_PACK_HEADER);
+
+ CopyMem (Destination, &FormSet, sizeof (EFI_IFR_FORM_SET));
+
+ Destination = Destination + sizeof (EFI_IFR_FORM_SET);
+
+ CopyMem (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_CHECKBOX 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_CHECKBOX);
+ 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/EdkModulePkg/Library/EdkIfrSupportLib/IfrOpCodeCreation.c b/EdkModulePkg/Library/EdkIfrSupportLib/IfrOpCodeCreation.c
new file mode 100644
index 0000000..6fb2be7
--- /dev/null
+++ b/EdkModulePkg/Library/EdkIfrSupportLib/IfrOpCodeCreation.c
@@ -0,0 +1,613 @@
+/*++
+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:
+ 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:
+
+--*/
+
+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;
+
+ CopyMem (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;
+
+ CopyMem (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;
+
+ CopyMem (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 = (UINT8 *) FormBuffer;
+
+ CopyMem (LocalBuffer, &OneOf, sizeof (EFI_IFR_ONE_OF));
+
+ LocalBuffer = (UINT8 *) (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;
+
+ CopyMem (LocalBuffer, &OneOfOption, sizeof (EFI_IFR_ONE_OF_OPTION));
+
+ LocalBuffer = (UINT8 *) (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;
+
+ CopyMem (LocalBuffer, &EndOneOf, sizeof (EFI_IFR_END_ONE_OF));
+
+ LocalBuffer = (UINT8 *) (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 = (UINT8 *) FormBuffer;
+
+ CopyMem (LocalBuffer, &OrderedList, sizeof (EFI_IFR_ORDERED_LIST));
+
+ LocalBuffer = (UINT8 *) (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;
+
+ CopyMem (LocalBuffer, &OrderedListOption, sizeof (EFI_IFR_ONE_OF_OPTION));
+
+ LocalBuffer = (UINT8 *) (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;
+
+ CopyMem (LocalBuffer, &EndOrderedList, sizeof (EFI_IFR_END_ONE_OF));
+
+ LocalBuffer = (UINT8 *) (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_CHECKBOX 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_CHECKBOX);
+ CheckBox.QuestionId = QuestionId;
+ CheckBox.Width = DataWidth;
+ CheckBox.Prompt = PromptToken;
+
+ CheckBox.Help = HelpToken;
+ CheckBox.Flags = Flags;
+ CheckBox.Key = Key;
+
+ CopyMem (FormBuffer, &CheckBox, sizeof (EFI_IFR_CHECKBOX));
+
+ 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;
+
+ CopyMem (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;
+
+ CopyMem (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);
+ CopyMem (&Banner.Title, &Title, sizeof (UINT16));
+ CopyMem (&Banner.LineNumber, &LineNumber, sizeof (UINT16));
+ Banner.Alignment = Alignment;
+
+ CopyMem (FormBuffer, &Banner, sizeof (EFI_IFR_BANNER));
+
+ return EFI_SUCCESS;
+}
diff --git a/EdkModulePkg/Library/EdkIfrSupportLib/IfrVariable.c b/EdkModulePkg/Library/EdkIfrSupportLib/IfrVariable.c
new file mode 100644
index 0000000..3e37553
--- /dev/null
+++ b/EdkModulePkg/Library/EdkIfrSupportLib/IfrVariable.c
@@ -0,0 +1,484 @@
+/*++
+
+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:
+ IfrVariable.c
+
+Abstract:
+ Variable/Map manipulations routines
+
+--*/
+
+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 == StrCmp (Name, MapName)) && CompareGuid (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 = AllocatePool (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 StrLength;
+ UINTN StrLenSuffix;
+
+ StrLength = StrLen (Name);
+ StrLenSuffix = StrLen (Suffix);
+ if ((StrLength <= StrLenSuffix) || (0 != StrCmp (Suffix, &Name[StrLength - 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 = AllocateZeroPool ((StrLen (Name) + StrLen (Suffix) + 1) * sizeof (CHAR16));
+
+ StrCpy (NameSuffixed, Name);
+ StrCat (NameSuffixed, Suffix);
+
+ Status = EfiLibHiiVariableRetrieveFromNv (NameSuffixed, Guid, Size, &Var);
+ gBS->FreePool (NameSuffixed);
+
+ return Status;
+}
+
diff --git a/EdkModulePkg/Library/EdkIfrSupportLib/build.xml b/EdkModulePkg/Library/EdkIfrSupportLib/build.xml
new file mode 100644
index 0000000..54b607a
--- /dev/null
+++ b/EdkModulePkg/Library/EdkIfrSupportLib/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="EdkIfrSupportLib"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\EdkIfrSupportLib"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="EdkIfrSupportLib">
+ <GenBuild baseName="EdkIfrSupportLib" mbdFilename="${MODULE_DIR}\EdkIfrSupportLib.mbd" msaFilename="${MODULE_DIR}\EdkIfrSupportLib.msa"/>
+ </target>
+ <target depends="EdkIfrSupportLib_clean" name="clean"/>
+ <target depends="EdkIfrSupportLib_cleanall" name="cleanall"/>
+ <target name="EdkIfrSupportLib_clean">
+ <OutputDirSetup baseName="EdkIfrSupportLib" mbdFilename="${MODULE_DIR}\EdkIfrSupportLib.mbd" msaFilename="${MODULE_DIR}\EdkIfrSupportLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkIfrSupportLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkIfrSupportLib_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="EdkIfrSupportLib_cleanall">
+ <OutputDirSetup baseName="EdkIfrSupportLib" mbdFilename="${MODULE_DIR}\EdkIfrSupportLib.mbd" msaFilename="${MODULE_DIR}\EdkIfrSupportLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkIfrSupportLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkIfrSupportLib_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**EdkIfrSupportLib*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/EdkMemoryStatusCodeLib/EdkMemoryStatusCodeLib.mbd b/EdkModulePkg/Library/EdkMemoryStatusCodeLib/EdkMemoryStatusCodeLib.mbd
new file mode 100644
index 0000000..01e0cb2
--- /dev/null
+++ b/EdkModulePkg/Library/EdkMemoryStatusCodeLib/EdkMemoryStatusCodeLib.mbd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>EdkMemoryStatusCodeLib</BaseName>
+ <Guid>e2368d1d-4c94-4e62-be2f-7817bbd78293</Guid>
+ <Version>0</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Created>2006-03-12 17:09</Created>
+ <Modified>2006-03-19 15:19</Modified>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/EdkMemoryStatusCodeLib/EdkMemoryStatusCodeLib.msa b/EdkModulePkg/Library/EdkMemoryStatusCodeLib/EdkMemoryStatusCodeLib.msa
new file mode 100644
index 0000000..6ad58a2
--- /dev/null
+++ b/EdkModulePkg/Library/EdkMemoryStatusCodeLib/EdkMemoryStatusCodeLib.msa
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>EdkMemoryStatusCodeLib</BaseName>
+ <ModuleType>PEIM</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>e2368d1d-4c94-4e62-be2f-7817bbd78293</Guid>
+ <Version>0</Version>
+ <Abstract>Memory Status Code Library for UEFI drivers</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>0</Specification>
+ <Created>2006-03-12 17:09</Created>
+ <Updated>2006-03-19 15:19</Updated>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">EdkMemoryStatusCodeLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">HobLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PeiCoreLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PeiServicesTablePointerLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseMemoryLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>MemoryStatusCode.c</Filename>
+ <Filename>MemoryStatusCode.h</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+ <Hobs>
+ <Hob Usage="SOMETIMES_PRODUCED" HobType="GUID_EXTENSION">
+ <Name>StatusCodeMemoryPpi</Name>
+ <C_Name>gPeiStatusCodeMemoryPpiGuid</C_Name>
+ <Guid>0x26f8ab01, 0xd3cd, 0x489c, 0x98, 0x4f, 0xdf, 0xde, 0xf7, 0x68, 0x39, 0x5b</Guid>
+ </Hob>
+ </Hobs>
+ <PPIs>
+ <Ppi Usage="SOMETIMES_PRODUCED">StatusCodeMemory</Ppi>
+ <Ppi Usage="SOMETIMES_CONSUMED">StatusCode</Ppi>
+ <PpiNotify Usage="SOMETIMES_CONSUMED">FvFileLoader</PpiNotify>
+ </PPIs>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/EdkMemoryStatusCodeLib/MemoryStatusCode.c b/EdkModulePkg/Library/EdkMemoryStatusCodeLib/MemoryStatusCode.c
new file mode 100644
index 0000000..1661d77
--- /dev/null
+++ b/EdkModulePkg/Library/EdkMemoryStatusCodeLib/MemoryStatusCode.c
@@ -0,0 +1,498 @@
+/*++
+
+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:
+
+ MemoryStatusCode.c
+
+Abstract:
+
+ Lib to provide memory journal status code reporting Routines.
+
+--*/
+#include "MemoryStatusCode.h"
+
+//
+// Global variable. Not accessible while running from flash.
+// After we relocate ourselves into memory, we update this
+// and use it to determine if we are running from flash or memory.
+//
+
+//
+// Global variable used to replace the PPI once we start running from memory.
+//
+PEI_STATUS_CODE_MEMORY_PPI mStatusCodeMemoryPpi = { 0, 0, 0, 0 };
+
+//
+// PPI descriptor for the MonoStatusCode PEIM, see MonoStatusCode.c
+//
+extern EFI_PEI_PPI_DESCRIPTOR mPpiListStatusCode;
+
+EFI_STATUS
+EFIAPI
+MemoryStatusCodeInitialize (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+/*++
+
+Routine Description:
+
+ Initialization routine.
+ Allocates heap space for storing Status Codes.
+ Installs a PPI to point to that heap space.
+ Installs a callback to switch to memory.
+ Installs a callback to
+
+Arguments:
+
+ FfsHeader - FV this PEIM was loaded from.
+ PeiServices - General purpose services available to every PEIM.
+
+Returns:
+
+ None
+
+--*/
+{
+ EFI_STATUS Status;
+ MEMORY_STATUS_CODE_INSTANCE *PrivateData;
+ PEI_STATUS_CODE_MEMORY_PPI *StatusCodeMemoryPpi;
+ EFI_PEI_PROGRESS_CODE_PPI *ReportStatusCodePpi;
+ EFI_PHYSICAL_ADDRESS Buffer;
+ VOID *StartPointer;
+ UINTN Length;
+ UINTN LastEntry;
+ EFI_PEI_PPI_DESCRIPTOR *ReportStatusCodeDescriptor;
+ EFI_PEI_PPI_DESCRIPTOR *StatusCodeMemoryDescriptor;
+
+ //
+ // Determine if we are being called after relocation into memory.
+ //
+ if (!gRunningFromMemory) {
+ //
+ // If we are not running from memory, we need to allocate some heap and
+ // install the PPI
+ //
+ //
+ // Allocate heap storage for the journal
+ //
+ Status = (*PeiServices)->AllocatePool (
+ PeiServices,
+ PEI_STATUS_CODE_HEAP_LENGTH,
+ &StartPointer
+ );
+
+ //
+ // This is not a required feature to boot.
+ //
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ // Allocate heap storage for private data
+ // The private data contains the FFS header for this PEIM,
+ // a PPI containing information about the status code journal, and
+ // a notification for the LoadFile service, to relocate the PEIM into
+ // memory.
+ //
+ Status = (*PeiServices)->AllocatePool (
+ PeiServices,
+ sizeof (MEMORY_STATUS_CODE_INSTANCE),
+ (VOID **) &PrivateData
+ );
+
+ //
+ // This is not a required feature to boot.
+ //
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ // Update the contents of the private data.
+ //
+ PrivateData->Signature = MEMORY_STATUS_CODE_SIGNATURE;
+ PrivateData->This = PrivateData;
+ PrivateData->FfsHeader = FfsHeader;
+ PrivateData->PpiDescriptor.Flags = (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST);
+ PrivateData->PpiDescriptor.Guid = &gPeiStatusCodeMemoryPpiGuid;
+ PrivateData->PpiDescriptor.Ppi = &PrivateData->StatusCodeMemoryPpi;
+ PrivateData->StatusCodeMemoryPpi.FirstEntry = 0;
+ PrivateData->StatusCodeMemoryPpi.LastEntry = 0;
+ PrivateData->StatusCodeMemoryPpi.Address = (EFI_PHYSICAL_ADDRESS) (UINTN) StartPointer;
+ PrivateData->StatusCodeMemoryPpi.Length = PEI_STATUS_CODE_HEAP_LENGTH;
+ PrivateData->NotifyDescriptor.Flags =
+ (
+ EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK |
+ EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
+ );
+ PrivateData->NotifyDescriptor.Guid = &gEfiPeiFvFileLoaderPpiGuid;
+ PrivateData->NotifyDescriptor.Notify = LoadImageCallback;
+
+ //
+ // Publish the PPI
+ //
+ Status = (*PeiServices)->InstallPpi (PeiServices, &PrivateData->PpiDescriptor);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ // Post a callback to relocate to memory
+ //
+ Status = (**PeiServices).NotifyPpi (PeiServices, &PrivateData->NotifyDescriptor);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ } else {
+ //
+ // If we are running from memory, we need to copy from the heap to a RT
+ // memory buffer.
+ //
+ //
+ // Locate Journal
+ //
+ Status = (*PeiServices)->LocatePpi (
+ PeiServices,
+ &gPeiStatusCodeMemoryPpiGuid,
+ 0,
+ &StatusCodeMemoryDescriptor,
+ (VOID **) &StatusCodeMemoryPpi
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ // Get private data
+ //
+ PrivateData = _CR (StatusCodeMemoryDescriptor, MEMORY_STATUS_CODE_INSTANCE, PpiDescriptor);
+ //
+ // At this point, we need to fix up any addresses that we have as the heap
+ // has moved.
+ //
+ PrivateData->PpiDescriptor.Ppi = &PrivateData->StatusCodeMemoryPpi;
+ PrivateData->PpiDescriptor.Guid = &gPeiStatusCodeMemoryPpiGuid;
+ PrivateData->StatusCodeMemoryPpi.Address = PrivateData->StatusCodeMemoryPpi.Address +
+ (UINTN) PrivateData - (UINTN) PrivateData->This;
+ PrivateData->NotifyDescriptor.Guid = &gEfiPeiFvFileLoaderPpiGuid;
+ PrivateData->NotifyDescriptor.Notify = LoadImageCallback;
+ PrivateData->This = PrivateData;
+
+ //
+ // Allocate RT memory.
+ //
+ Status = (*PeiServices)->AllocatePages (
+ PeiServices,
+ EfiRuntimeServicesData,
+ PEI_STATUS_CODE_RT_PAGES,
+ &Buffer
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ DEBUG_CODE (
+ ZeroMem ((VOID *) (UINTN) Buffer, PEI_STATUS_CODE_RT_LENGTH);
+ );
+
+ //
+ // Copy the heap to the allocated memory.
+ // Unwind the rolling queue to start at 0 in the new space. We need to do
+ // this because the new queue is much bigger than the heap allocation.
+ //
+ if (PEI_STATUS_CODE_RT_LENGTH <= PEI_STATUS_CODE_HEAP_LENGTH) {
+ return Status;
+ }
+
+ if (StatusCodeMemoryPpi->LastEntry >= StatusCodeMemoryPpi->FirstEntry) {
+ LastEntry = StatusCodeMemoryPpi->LastEntry - StatusCodeMemoryPpi->FirstEntry;
+ StartPointer = (VOID *) ((UINTN) StatusCodeMemoryPpi->Address + (StatusCodeMemoryPpi->FirstEntry * sizeof (EFI_STATUS_CODE_ENTRY)));
+ Length = (StatusCodeMemoryPpi->LastEntry - StatusCodeMemoryPpi->FirstEntry) * sizeof (EFI_STATUS_CODE_ENTRY);
+ (*PeiServices)->CopyMem ((VOID *) (UINTN) Buffer, StartPointer, Length);
+ } else {
+ //
+ // The last entry will be the new last entry after moving heap to buffer
+ //
+ LastEntry = (PEI_STATUS_CODE_MAX_HEAP_ENTRY - StatusCodeMemoryPpi->FirstEntry) + StatusCodeMemoryPpi->LastEntry;
+ //
+ // Copy from the first entry to the end of the heap
+ //
+ StartPointer = (VOID *) ((UINTN) StatusCodeMemoryPpi->Address + (StatusCodeMemoryPpi->FirstEntry * sizeof (EFI_STATUS_CODE_ENTRY)));
+ Length = PEI_STATUS_CODE_HEAP_LENGTH - (StatusCodeMemoryPpi->FirstEntry * sizeof (EFI_STATUS_CODE_ENTRY));
+ (*PeiServices)->CopyMem ((VOID *) (UINTN) Buffer, StartPointer, Length);
+ //
+ // Copy from the start to the heap to the last entry
+ //
+ StartPointer = (VOID *) (UINTN) StatusCodeMemoryPpi->Address;
+ (*PeiServices)->CopyMem (
+ (VOID *) (UINTN) (Buffer + Length),
+ StartPointer,
+ (StatusCodeMemoryPpi->LastEntry * sizeof (EFI_STATUS_CODE_ENTRY))
+ );
+ };
+
+ //
+ // Update the PPI to NULL, so it will not be used.
+ //
+ StatusCodeMemoryPpi->FirstEntry = 0;
+ StatusCodeMemoryPpi->LastEntry = 0;
+ StatusCodeMemoryPpi->Address = 0;
+ StatusCodeMemoryPpi->Length = 0;
+
+ //
+ // Update in memory version of PPI that will be used.
+ //
+ mStatusCodeMemoryPpi.FirstEntry = 0;
+ mStatusCodeMemoryPpi.LastEntry = LastEntry;
+ mStatusCodeMemoryPpi.Address = (EFI_PHYSICAL_ADDRESS) (UINTN) Buffer;
+ mStatusCodeMemoryPpi.Length = PEI_STATUS_CODE_RT_LENGTH;
+
+ //
+ // Reinstall the report status code function
+ //
+ //
+ // Locate status code PPI
+ //
+ Status = (*PeiServices)->LocatePpi (
+ PeiServices,
+ &gEfiPeiStatusCodePpiGuid,
+ 0,
+ &ReportStatusCodeDescriptor,
+ (VOID **) &ReportStatusCodePpi
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ // Reinstall the ReportStatusCode interface using the memory-based
+ // descriptor
+ //
+ Status = (*PeiServices)->ReInstallPpi (
+ PeiServices,
+ ReportStatusCodeDescriptor,
+ &mPpiListStatusCode
+ );
+ if (EFI_ERROR (Status)) {
+ CpuBreakpoint ();
+ return Status;
+ }
+ //
+ // Publish a GUIDed HOB that contains a pointer to the status code PPI
+ // structure. This is a bit of a short cut as I just used the PPI GUID to
+ // identify the HOB. This HOB is caught by the DXE status code memory
+ // listener and used to find the journal.
+ //
+ StatusCodeMemoryPpi = &mStatusCodeMemoryPpi;
+
+ BuildGuidDataHob (
+ &gPeiStatusCodeMemoryPpiGuid,
+ &StatusCodeMemoryPpi,
+ sizeof (VOID *)
+ );
+ }
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+MemoryReportStatusCode (
+ 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:
+
+ Provide a memory status code
+
+Arguments:
+
+ Same as ReportStatusCode PPI
+
+Returns:
+
+ EFI_SUCCESS This function always returns success
+
+--*/
+{
+ EFI_STATUS Status;
+ PEI_STATUS_CODE_MEMORY_PPI *StatusCodeMemoryPpi;
+ EFI_STATUS_CODE_ENTRY *CurrentEntry;
+ UINTN LastEntry;
+ MEMORY_STATUS_CODE_INSTANCE *PrivateData;
+ EFI_PEI_PPI_DESCRIPTOR *StatusCodeMemoryDescriptor;
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer ();
+ //
+ // We don't care to log debug codes.
+ //
+ if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) {
+ return EFI_SUCCESS;
+ }
+
+ if (!gRunningFromMemory) {
+ //
+ // If we are called from DXE and have not been reinstalled into memory, we
+ // can no longer locate the journal, so we can no longer log status codes.
+ //
+ if (!PeiServices) {
+ return EFI_SUCCESS;
+ }
+ //
+ // Locate Journal
+ //
+ Status = (*PeiServices)->LocatePpi (
+ PeiServices,
+ &gPeiStatusCodeMemoryPpiGuid,
+ 0,
+ &StatusCodeMemoryDescriptor,
+ (VOID **) &StatusCodeMemoryPpi
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_SUCCESS;
+ }
+ //
+ // Determine the last entry in the journal.
+ // This is needed to properly implement the rolling queue.
+ //
+ LastEntry = PEI_STATUS_CODE_MAX_HEAP_ENTRY;
+
+ //
+ // Get private data
+ //
+ PrivateData = _CR (StatusCodeMemoryDescriptor, MEMORY_STATUS_CODE_INSTANCE, PpiDescriptor);
+
+ //
+ // Once memory gets installed, heap gets moved to real memory.
+ // We need to fix up the pointers to match the move.
+ //
+ PrivateData->PpiDescriptor.Ppi = &PrivateData->StatusCodeMemoryPpi;
+ PrivateData->PpiDescriptor.Guid = &gPeiStatusCodeMemoryPpiGuid;
+ PrivateData->StatusCodeMemoryPpi.Address = PrivateData->StatusCodeMemoryPpi.Address +
+ (UINTN) PrivateData - (UINTN) PrivateData->This;
+ PrivateData->NotifyDescriptor.Guid = &gEfiPeiFvFileLoaderPpiGuid;
+ PrivateData->NotifyDescriptor.Notify = LoadImageCallback;
+ PrivateData->This = PrivateData;
+
+ StatusCodeMemoryPpi = PrivateData->PpiDescriptor.Ppi;
+ } else {
+ //
+ // Use global/memory copy of the PPI
+ //
+ StatusCodeMemoryPpi = &mStatusCodeMemoryPpi;
+
+ //
+ // Determine the last entry in the journal.
+ // This is needed to properly implement the rolling queue.
+ //
+ LastEntry = PEI_STATUS_CODE_MAX_RT_ENTRY;
+ }
+ //
+ // Return if we are using a cleared PPI somehow
+ //
+ if (!StatusCodeMemoryPpi->Address || !StatusCodeMemoryPpi->Length) {
+ return EFI_SUCCESS;
+ }
+ //
+ // Update the latest entry in the journal (may actually be first due to rolling
+ // queue).
+ //
+ CurrentEntry = (EFI_STATUS_CODE_ENTRY *) (UINTN) (StatusCodeMemoryPpi->Address + (StatusCodeMemoryPpi->LastEntry * sizeof (EFI_STATUS_CODE_ENTRY)));
+
+ StatusCodeMemoryPpi->LastEntry = (StatusCodeMemoryPpi->LastEntry + 1) % LastEntry;
+ if (StatusCodeMemoryPpi->LastEntry == StatusCodeMemoryPpi->FirstEntry) {
+ StatusCodeMemoryPpi->FirstEntry = (StatusCodeMemoryPpi->FirstEntry + 1) % LastEntry;
+ }
+
+ CurrentEntry->Type = CodeType;
+ CurrentEntry->Value = Value;
+ CurrentEntry->Instance = Instance;
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+LoadImageCallback (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
+ IN VOID *Ppi
+ )
+/*++
+
+Routine Description:
+
+ Relocate the PEIM into memory.
+
+ Once load protocol becomes available, relocate our PEIM into memory.
+ The primary benefit is to eliminate the blackout window that we would have in
+ the memory log between the end of PEI and the status code DXE driver taking
+ control. If we don't do this, we cannot determine where our memory journal
+ is located and cannot function.
+
+ A second benefit is speed optimization throughout DXE.
+
+Arguments:
+
+ PeiServices - General purpose services available to every PEIM.
+ NotifyDescriptor - Information about the notify event.
+ Ppi - Context
+
+Returns:
+
+ EFI_SUCCESS This function always returns success.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PHYSICAL_ADDRESS ImageAddress;
+ EFI_PHYSICAL_ADDRESS EntryPoint;
+ UINT64 ImageSize;
+ MEMORY_STATUS_CODE_INSTANCE *PrivateData;
+
+ //
+ // Relocate to memory
+ //
+ if (!gRunningFromMemory) {
+ //
+ // Use the callback descriptor to get the FfsHeader
+ //
+ PrivateData = _CR (NotifyDescriptor, MEMORY_STATUS_CODE_INSTANCE, NotifyDescriptor);
+
+ Status = ((EFI_PEI_FV_FILE_LOADER_PPI *) Ppi)->FvLoadFile (
+ Ppi,
+ PrivateData->FfsHeader,
+ &ImageAddress,
+ &ImageSize,
+ &EntryPoint
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_SUCCESS;
+ }
+ //
+ // Set the flag in the loaded image that indicates the PEIM is executing
+ // from memory.
+ //
+#ifdef EFI_NT_EMULATOR
+ gRunningFromMemory = TRUE;
+#else
+ * (BOOLEAN *) ((UINTN) &gRunningFromMemory + (UINTN) EntryPoint - (UINTN) InstallMonoStatusCode) = TRUE;
+#endif
+ Status = ((EFI_PEIM_ENTRY_POINT )(UINTN) EntryPoint) (PrivateData->FfsHeader, PeiServices);
+ if (EFI_ERROR (Status)) {
+ return EFI_SUCCESS;
+ }
+ }
+
+ return EFI_SUCCESS;
+}
diff --git a/EdkModulePkg/Library/EdkMemoryStatusCodeLib/MemoryStatusCode.h b/EdkModulePkg/Library/EdkMemoryStatusCodeLib/MemoryStatusCode.h
new file mode 100644
index 0000000..3580083
--- /dev/null
+++ b/EdkModulePkg/Library/EdkMemoryStatusCodeLib/MemoryStatusCode.h
@@ -0,0 +1,94 @@
+/*++
+
+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:
+
+ MemoryStatusCode.h
+
+Abstract:
+
+ Lib to provide status code reporting via memory.
+
+--*/
+
+#ifndef _PEI_MEMORY_STATUS_CODE_H_
+#define _PEI_MEMORY_STATUS_CODE_H_
+
+//
+// Publicly exported function
+//
+EFI_STATUS
+EFIAPI
+InstallMonoStatusCode (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+;
+//
+// Publicly exported data
+//
+extern BOOLEAN gRunningFromMemory;
+//
+// Private data
+//
+//
+// Define the amount of heap to use before memory is allocated
+//
+#define PEI_STATUS_CODE_HEAP_LENGTH 512
+#define PEI_STATUS_CODE_MAX_HEAP_ENTRY (PEI_STATUS_CODE_HEAP_LENGTH / sizeof (EFI_STATUS_CODE_ENTRY))
+
+//
+// Define the number of 4K pages of BS memory to allocate (1MB)
+//
+#define PEI_STATUS_CODE_RT_PAGES (128)
+#define PEI_STATUS_CODE_RT_LENGTH (PEI_STATUS_CODE_RT_PAGES * 1024 * 4)
+#define PEI_STATUS_CODE_MAX_RT_ENTRY (PEI_STATUS_CODE_RT_LENGTH / sizeof (EFI_STATUS_CODE_ENTRY))
+
+//
+// Define a private data structure
+//
+#define MEMORY_STATUS_CODE_SIGNATURE EFI_SIGNATURE_32 ('M', 'S', 'C', 'S')
+
+typedef struct _MEMORY_STATUS_CODE_INSTANCE {
+ UINT32 Signature;
+ struct _MEMORY_STATUS_CODE_INSTANCE *This;
+ EFI_FFS_FILE_HEADER *FfsHeader;
+ EFI_PEI_PPI_DESCRIPTOR PpiDescriptor;
+ PEI_STATUS_CODE_MEMORY_PPI StatusCodeMemoryPpi;
+ EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor;
+} MEMORY_STATUS_CODE_INSTANCE;
+
+#define MEMORY_STATUS_CODE_FROM_DESCRIPTOR_THIS(a) \
+ PEI_CR (a, \
+ MEMORY_STATUS_CODE_INSTANCE, \
+ PpiDescriptor, \
+ MEMORY_STATUS_CODE_SIGNATURE \
+ )
+#define MEMORY_STATUS_CODE_FROM_NOTIFY_THIS(a) \
+ PEI_CR (a, \
+ MEMORY_STATUS_CODE_INSTANCE, \
+ NotifyDescriptor, \
+ MEMORY_STATUS_CODE_SIGNATURE \
+ )
+
+//
+// Private function declarations
+//
+EFI_STATUS
+EFIAPI
+LoadImageCallback (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
+ IN VOID *Ppi
+ )
+;
+
+#endif
diff --git a/EdkModulePkg/Library/EdkMemoryStatusCodeLib/build.xml b/EdkModulePkg/Library/EdkMemoryStatusCodeLib/build.xml
new file mode 100644
index 0000000..40db09a
--- /dev/null
+++ b/EdkModulePkg/Library/EdkMemoryStatusCodeLib/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="EdkMemoryStatusCodeLib"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\EdkMemoryStatusCodeLib"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="EdkMemoryStatusCodeLib">
+ <GenBuild baseName="EdkMemoryStatusCodeLib" mbdFilename="${MODULE_DIR}\EdkMemoryStatusCodeLib.mbd" msaFilename="${MODULE_DIR}\EdkMemoryStatusCodeLib.msa"/>
+ </target>
+ <target depends="EdkMemoryStatusCodeLib_clean" name="clean"/>
+ <target depends="EdkMemoryStatusCodeLib_cleanall" name="cleanall"/>
+ <target name="EdkMemoryStatusCodeLib_clean">
+ <OutputDirSetup baseName="EdkMemoryStatusCodeLib" mbdFilename="${MODULE_DIR}\EdkMemoryStatusCodeLib.mbd" msaFilename="${MODULE_DIR}\EdkMemoryStatusCodeLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkMemoryStatusCodeLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkMemoryStatusCodeLib_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="EdkMemoryStatusCodeLib_cleanall">
+ <OutputDirSetup baseName="EdkMemoryStatusCodeLib" mbdFilename="${MODULE_DIR}\EdkMemoryStatusCodeLib.mbd" msaFilename="${MODULE_DIR}\EdkMemoryStatusCodeLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkMemoryStatusCodeLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkMemoryStatusCodeLib_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**EdkMemoryStatusCodeLib*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/EdkNullCustomizedDecompressLib/CustomizedDecompress.c b/EdkModulePkg/Library/EdkNullCustomizedDecompressLib/CustomizedDecompress.c
new file mode 100644
index 0000000..55d9bbe
--- /dev/null
+++ b/EdkModulePkg/Library/EdkNullCustomizedDecompressLib/CustomizedDecompress.c
@@ -0,0 +1,109 @@
+/*++
+
+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:
+
+ CustomizedDecompress.c
+
+Abstract:
+
+ Implementation file for Customized decompression routine
+
+--*/
+
+#include <CustomizedDecompress.h>
+
+EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL mCustomizedDecompress = {
+ CustomizedGetInfo,
+ CustomizedDecompress
+};
+
+EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *
+EFIAPI
+GetCustomizedDecompressProtocol (
+ VOID
+ )
+{
+ return &mCustomizedDecompress;
+}
+
+
+
+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/EdkModulePkg/Library/EdkNullCustomizedDecompressLib/CustomizedDecompress.h b/EdkModulePkg/Library/EdkNullCustomizedDecompressLib/CustomizedDecompress.h
new file mode 100644
index 0000000..e94be43
--- /dev/null
+++ b/EdkModulePkg/Library/EdkNullCustomizedDecompressLib/CustomizedDecompress.h
@@ -0,0 +1,95 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ CustomizedDecompress.h
+
+Abstract:
+
+ Header file for Customized decompression routine
+
+--*/
+#ifndef _CUSTOMIZED_DECOMPRESS_LIB_H_
+#define _CUSTOMIZED_DECOMPRESS_LIB_H_
+
+
+
+
+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
+
+--*/
+;
+
+
+#endif
diff --git a/EdkModulePkg/Library/EdkNullCustomizedDecompressLib/EdkNullCustomizedDecompressLib.mbd b/EdkModulePkg/Library/EdkNullCustomizedDecompressLib/EdkNullCustomizedDecompressLib.mbd
new file mode 100644
index 0000000..a6a6d56
--- /dev/null
+++ b/EdkModulePkg/Library/EdkNullCustomizedDecompressLib/EdkNullCustomizedDecompressLib.mbd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>EdkNullCustomizedDecompressLib</BaseName>
+ <Guid>4a024320-0648-49c3-84d4-3d04670a1c77</Guid>
+ <Version>0</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004 - 2005, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Created>2006-03-12 17:09</Created>
+ <Modified>2006-03-19 15:19</Modified>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/EdkNullCustomizedDecompressLib/EdkNullCustomizedDecompressLib.msa b/EdkModulePkg/Library/EdkNullCustomizedDecompressLib/EdkNullCustomizedDecompressLib.msa
new file mode 100644
index 0000000..3ca559f
--- /dev/null
+++ b/EdkModulePkg/Library/EdkNullCustomizedDecompressLib/EdkNullCustomizedDecompressLib.msa
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>EdkNullCustomizedDecompressLib</BaseName>
+ <ModuleType>DXE_DRIVER</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>4a024320-0648-49c3-84d4-3d04670a1c77</Guid>
+ <Version>0</Version>
+ <Abstract>Component description file for the PEI library.</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004 - 2005, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>0</Specification>
+ <Created>2006-03-12 17:09</Created>
+ <Updated>2006-03-19 15:19</Updated>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">CustomDecompressLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>CustomizedDecompress.c</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/EdkNullCustomizedDecompressLib/build.xml b/EdkModulePkg/Library/EdkNullCustomizedDecompressLib/build.xml
new file mode 100644
index 0000000..a8ae7fe
--- /dev/null
+++ b/EdkModulePkg/Library/EdkNullCustomizedDecompressLib/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="EdkNullCustomizedDecompressLib"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\EdkNullCustomizedDecompressLib"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="EdkNullCustomizedDecompressLib">
+ <GenBuild baseName="EdkNullCustomizedDecompressLib" mbdFilename="${MODULE_DIR}\EdkNullCustomizedDecompressLib.mbd" msaFilename="${MODULE_DIR}\EdkNullCustomizedDecompressLib.msa"/>
+ </target>
+ <target depends="EdkNullCustomizedDecompressLib_clean" name="clean"/>
+ <target depends="EdkNullCustomizedDecompressLib_cleanall" name="cleanall"/>
+ <target name="EdkNullCustomizedDecompressLib_clean">
+ <OutputDirSetup baseName="EdkNullCustomizedDecompressLib" mbdFilename="${MODULE_DIR}\EdkNullCustomizedDecompressLib.mbd" msaFilename="${MODULE_DIR}\EdkNullCustomizedDecompressLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkNullCustomizedDecompressLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkNullCustomizedDecompressLib_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="EdkNullCustomizedDecompressLib_cleanall">
+ <OutputDirSetup baseName="EdkNullCustomizedDecompressLib" mbdFilename="${MODULE_DIR}\EdkNullCustomizedDecompressLib.mbd" msaFilename="${MODULE_DIR}\EdkNullCustomizedDecompressLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkNullCustomizedDecompressLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkNullCustomizedDecompressLib_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**EdkNullCustomizedDecompressLib*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/EdkPeCoffLoaderLib/EdkPeCoffLoader.c b/EdkModulePkg/Library/EdkPeCoffLoaderLib/EdkPeCoffLoader.c
new file mode 100644
index 0000000..86421db
--- /dev/null
+++ b/EdkModulePkg/Library/EdkPeCoffLoaderLib/EdkPeCoffLoader.c
@@ -0,0 +1,112 @@
+/*++
+
+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:
+
+ TianoPeCoffLoader.c
+
+Abstract:
+
+ Wrap the Base PE/COFF loader with the PE COFF Protocol
+
+
+--*/
+
+
+
+EFI_STATUS
+EFIAPI
+TianoPeCoffLoaderLibGetImageInfo (
+ IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+{
+ EFI_STATUS Status;
+
+ Status = PeCoffLoaderGetImageInfo (ImageContext);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ 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 = IMAGE_ERROR_INVALID_SUBSYSTEM;
+ return RETURN_UNSUPPORTED;
+ }
+
+ return Status;
+}
+
+EFI_STATUS
+EFIAPI
+TianoPeCoffLoaderLibLoadImage (
+ IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+{
+ return PeCoffLoaderLoadImage (ImageContext);
+}
+
+EFI_STATUS
+EFIAPI
+TianoPeCoffLoaderLibRelocateImage (
+ IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+{
+ return PeCoffLoaderRelocateImage (ImageContext);
+}
+
+
+EFI_STATUS
+EFIAPI
+TianoPeCoffLoaderLibUnloadimage (
+ IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
+ IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+{
+ return EFI_SUCCESS;
+}
+
+
+EFI_PEI_PE_COFF_LOADER_PROTOCOL mPeiEfiPeiPeCoffLoader = {
+ TianoPeCoffLoaderLibGetImageInfo,
+ TianoPeCoffLoaderLibLoadImage,
+ TianoPeCoffLoaderLibRelocateImage,
+ TianoPeCoffLoaderLibUnloadimage
+};
+
+EFI_PEI_PE_COFF_LOADER_PROTOCOL *
+EFIAPI
+GetPeCoffLoaderProtocol (
+ )
+{
+ return &mPeiEfiPeiPeCoffLoader;
+}
+
+
diff --git a/EdkModulePkg/Library/EdkPeCoffLoaderLib/EdkPeCoffLoaderLib.mbd b/EdkModulePkg/Library/EdkPeCoffLoaderLib/EdkPeCoffLoaderLib.mbd
new file mode 100644
index 0000000..4ffdf99
--- /dev/null
+++ b/EdkModulePkg/Library/EdkPeCoffLoaderLib/EdkPeCoffLoaderLib.mbd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>EdkPeCoffLoaderLib</BaseName>
+ <Guid>858bbbc9-474f-4556-a361-0ae52a44ffa5</Guid>
+ <Version>0</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004 - 2005, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Created>2006-03-12 17:09</Created>
+ <Modified>2006-03-19 15:19</Modified>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/EdkPeCoffLoaderLib/EdkPeCoffLoaderLib.msa b/EdkModulePkg/Library/EdkPeCoffLoaderLib/EdkPeCoffLoaderLib.msa
new file mode 100644
index 0000000..0f85530
--- /dev/null
+++ b/EdkModulePkg/Library/EdkPeCoffLoaderLib/EdkPeCoffLoaderLib.msa
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>EdkPeCoffLoaderLib</BaseName>
+ <ModuleType>PEIM</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>858bbbc9-474f-4556-a361-0ae52a44ffa5</Guid>
+ <Version>0</Version>
+ <Abstract>Component description file for the PEI library.</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004 - 2005, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>0</Specification>
+ <Created>2006-03-12 17:09</Created>
+ <Updated>2006-03-19 15:19</Updated>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">EdkPeCoffLoaderLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PeCoffLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>EdkPeCoffLoader.c</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/EdkPeCoffLoaderLib/build.xml b/EdkModulePkg/Library/EdkPeCoffLoaderLib/build.xml
new file mode 100644
index 0000000..6e7a34f
--- /dev/null
+++ b/EdkModulePkg/Library/EdkPeCoffLoaderLib/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="EdkPeCoffLoaderLib"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\EdkPeCoffLoaderLib"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="EdkPeCoffLoaderLib">
+ <GenBuild baseName="EdkPeCoffLoaderLib" mbdFilename="${MODULE_DIR}\EdkPeCoffLoaderLib.mbd" msaFilename="${MODULE_DIR}\EdkPeCoffLoaderLib.msa"/>
+ </target>
+ <target depends="EdkPeCoffLoaderLib_clean" name="clean"/>
+ <target depends="EdkPeCoffLoaderLib_cleanall" name="cleanall"/>
+ <target name="EdkPeCoffLoaderLib_clean">
+ <OutputDirSetup baseName="EdkPeCoffLoaderLib" mbdFilename="${MODULE_DIR}\EdkPeCoffLoaderLib.mbd" msaFilename="${MODULE_DIR}\EdkPeCoffLoaderLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkPeCoffLoaderLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkPeCoffLoaderLib_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="EdkPeCoffLoaderLib_cleanall">
+ <OutputDirSetup baseName="EdkPeCoffLoaderLib" mbdFilename="${MODULE_DIR}\EdkPeCoffLoaderLib.mbd" msaFilename="${MODULE_DIR}\EdkPeCoffLoaderLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkPeCoffLoaderLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkPeCoffLoaderLib_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**EdkPeCoffLoaderLib*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/EdkPeCoffLoaderX64Lib/EdkPeCoffLoaderX64.c b/EdkModulePkg/Library/EdkPeCoffLoaderX64Lib/EdkPeCoffLoaderX64.c
new file mode 100644
index 0000000..a286257
--- /dev/null
+++ b/EdkModulePkg/Library/EdkPeCoffLoaderX64Lib/EdkPeCoffLoaderX64.c
@@ -0,0 +1,940 @@
+/*++
+
+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:
+
+ EdkPeCoffLoaderX64.c
+
+Abstract:
+
+ Wrap the Base PE/COFF loader with the PE COFF Protocol
+
+
+--*/
+
+#define IMAGE_64_MACHINE_TYPE_SUPPORTED(Machine) \
+ ((Machine) == EFI_IMAGE_MACHINE_IA32 || \
+ (Machine) == EFI_IMAGE_MACHINE_X64 || \
+ (Machine) == EFI_IMAGE_MACHINE_EBC)
+
+STATIC
+EFI_STATUS
+PeCoffLoader64GetPeHeader (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
+ OUT EFI_IMAGE_NT_HEADERS64 *PeHdr
+ );
+
+STATIC
+EFI_STATUS
+PeCoffLoader64CheckImageType (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
+ IN EFI_IMAGE_NT_HEADERS64 *PeHdr
+ );
+
+STATIC
+VOID *
+PeCoffLoader64ImageAddress (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
+ IN UINTN Address
+ );
+
+EFI_STATUS
+EFIAPI
+PeCoffLoader64GetImageInfo (
+ IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ );
+
+EFI_STATUS
+EFIAPI
+PeCoffLoader64RelocateImage (
+ IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ );
+
+EFI_STATUS
+EFIAPI
+PeCoffLoader64LoadImage (
+ IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ );
+
+EFI_STATUS
+EFIAPI
+PeCoffLoader64UnloadImage (
+ IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
+ IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ );
+
+EFI_STATUS
+PeCoffLoader64RelocateImageEx (
+ IN UINT16 *Reloc,
+ IN OUT CHAR8 *Fixup,
+ IN OUT CHAR8 **FixupData,
+ IN UINT64 Adjust
+ );
+
+EFI_PEI_PE_COFF_LOADER_PROTOCOL mPeCoffLoaderX64 = {
+ PeCoffLoader64GetImageInfo,
+ PeCoffLoader64LoadImage,
+ PeCoffLoader64RelocateImage,
+ PeCoffLoader64UnloadImage
+};
+
+STATIC
+EFI_STATUS
+PeCoffLoader64GetPeHeader (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
+ OUT EFI_IMAGE_NT_HEADERS64 *PeHdr
+ )
+/*++
+
+Routine Description:
+ Retrieves the PE Header from a PE/COFF image
+
+Arguments:
+ ImageContext - The context of the image being loaded
+ PeHdr - The buffer in which to return the PE header
+
+Returns:
+ EFI_SUCCESS if the PE Header is read,
+ Otherwise, the error status from reading the PE/COFF image using the ImageRead function.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_IMAGE_DOS_HEADER DosHdr;
+ UINTN Size;
+
+ //
+ // Read the DOS image headers
+ //
+ Size = sizeof (EFI_IMAGE_DOS_HEADER);
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ 0,
+ &Size,
+ &DosHdr
+ );
+ if (EFI_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
+ //
+ Size = sizeof (EFI_IMAGE_NT_HEADERS64);
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ ImageContext->PeCoffHeaderOffset,
+ &Size,
+ PeHdr
+ );
+ if (EFI_ERROR (Status)) {
+ ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;
+ return Status;
+ }
+
+ return EFI_SUCCESS;
+}
+
+static
+EFI_STATUS
+PeCoffLoader64CheckImageType (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
+ IN EFI_IMAGE_NT_HEADERS64 *PeHdr
+ )
+/*++
+
+Routine Description:
+ Checks the PE header of a PE/COFF image to determine if it supported
+
+Arguments:
+ ImageContext - The context of the image being loaded
+ PeHdr - The buffer in which to return the PE header
+
+Returns:
+ EFI_SUCCESS if the PE/COFF image is supported
+ EFI_UNSUPPORTED of the PE/COFF image is not supported.
+
+--*/
+{
+ //
+ // Check the PE/COFF Header SIgnature
+ //
+ if (PeHdr->Signature != EFI_IMAGE_NT_SIGNATURE) {
+ ImageContext->ImageError = IMAGE_ERROR_INVALID_PE_HEADER_SIGNATURE;
+ return EFI_UNSUPPORTED;
+ }
+
+ //
+ // See if the machine type is supported. We support a native machine type (IA-32/Itanium-based)
+ // and the machine type for the Virtual Machine.
+ //
+ ImageContext->Machine = PeHdr->FileHeader.Machine;
+ if (!(IMAGE_64_MACHINE_TYPE_SUPPORTED (ImageContext->Machine))) {
+ ImageContext->ImageError = IMAGE_ERROR_INVALID_MACHINE_TYPE;
+ return EFI_UNSUPPORTED;
+ }
+
+ //
+ // See if the image type is supported. We support EFI Applications,
+ // EFI Boot Service Drivers, and EFI Runtime Drivers.
+ //
+ ImageContext->ImageType = PeHdr->OptionalHeader.Subsystem;
+ 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 = IMAGE_ERROR_INVALID_SUBSYSTEM;
+ return EFI_UNSUPPORTED;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+PeCoffLoader64GetImageInfo (
+ IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+/*++
+
+Routine Description:
+ Retrieves information on a PE/COFF image
+
+Arguments:
+ ImageContext - The context of the image being loaded
+ PeHdr - The buffer in which to return the PE header
+
+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_STATUS Status;
+ EFI_IMAGE_NT_HEADERS64 PeHdr;
+ 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;
+
+ if (NULL == ImageContext) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Assume success
+ //
+ ImageContext->ImageError = IMAGE_ERROR_SUCCESS;
+
+ Status = PeCoffLoader64GetPeHeader (ImageContext, &PeHdr);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Verify machine type
+ //
+ Status = PeCoffLoader64CheckImageType (ImageContext, &PeHdr);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ //
+ // Retrieve the base address of the image
+ //
+ ImageContext->ImageAddress = PeHdr.OptionalHeader.ImageBase;
+
+ //
+ // Initialize the alternate destination address to 0 indicating that it
+ // should not be used.
+ //
+ ImageContext->DestinationAddress = 0;
+
+ //
+ // Initialize the codeview pointer.
+ //
+ ImageContext->CodeView = NULL;
+ ImageContext->PdbPointer = NULL;
+
+ //
+ // Three cases with regards to relocations:
+ // - Image has base relocs, RELOCS_STRIPPED==0 => image is relocatable
+ // - Image has no base relocs, RELOCS_STRIPPED==1 => Image is not relocatable
+ // - Image has no base relocs, RELOCS_STRIPPED==0 => Image is relocatable but
+ // has no base relocs to apply
+ // Obviously having base relocations with RELOCS_STRIPPED==1 is invalid.
+ //
+ // Look at the file header to determine if relocations have been stripped, and
+ // save this info in the image context for later use.
+ //
+ if (PeHdr.FileHeader.Characteristics & EFI_IMAGE_FILE_RELOCS_STRIPPED) {
+ ImageContext->RelocationsStripped = TRUE;
+ } else {
+ ImageContext->RelocationsStripped = FALSE;
+ }
+
+ ImageContext->ImageSize = (UINT64)PeHdr.OptionalHeader.SizeOfImage;
+ ImageContext->SectionAlignment = PeHdr.OptionalHeader.SectionAlignment;
+ ImageContext->SizeOfHeaders = PeHdr.OptionalHeader.SizeOfHeaders;
+
+ //
+ // Modify ImageSize to contain .PDB file name if required and initialize
+ // PdbRVA field...
+ //
+
+ if (PeHdr.OptionalHeader.NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {
+ DebugDirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)
+ &(PeHdr.OptionalHeader.DataDirectory[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) +
+ PeHdr.FileHeader.SizeOfOptionalHeader
+ );
+
+ for (Index = 0; Index < PeHdr.FileHeader.NumberOfSections; Index += 1) {
+ //
+ // 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 = 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 = 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;
+ }
+ }
+ }
+ }
+ return EFI_SUCCESS;
+}
+
+static
+VOID *
+PeCoffLoader64ImageAddress (
+ IN OUT 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 = IMAGE_ERROR_INVALID_IMAGE_ADDRESS;
+ return NULL;
+ }
+ return (CHAR8 *)((UINTN)ImageContext->ImageAddress + Address);
+}
+
+EFI_STATUS
+EFIAPI
+PeCoffLoader64RelocateImage (
+ IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+/*++
+
+Routine Description:
+ Relocates a PE/COFF image in memory
+
+Arguments:
+ 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_STATUS Status;
+ EFI_IMAGE_NT_HEADERS64 *PeHdr;
+ EFI_IMAGE_DATA_DIRECTORY *RelocDir;
+ IN UINT64 Adjust;
+ EFI_IMAGE_BASE_RELOCATION *RelocBase;
+ EFI_IMAGE_BASE_RELOCATION *RelocBaseEnd;
+ UINT16 *Reloc;
+ UINT16 *RelocEnd;
+ CHAR8 *Fixup;
+ CHAR8 *FixupBase;
+ UINT16 *F16;
+ UINT32 *F32;
+ CHAR8 *FixupData;
+ EFI_PHYSICAL_ADDRESS BaseAddress;
+
+
+ //
+ // Assume success
+ //
+ ImageContext->ImageError = 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) {
+ BaseAddress = ImageContext->DestinationAddress;
+ } else {
+ BaseAddress = ImageContext->ImageAddress;
+ }
+ PeHdr = (EFI_IMAGE_NT_HEADERS64 *)((UINTN)ImageContext->ImageAddress +
+ ImageContext->PeCoffHeaderOffset);
+ Adjust = (UINT64) BaseAddress - PeHdr->OptionalHeader.ImageBase;
+
+ PeHdr->OptionalHeader.ImageBase = (UINTN) BaseAddress;
+
+ //
+ // 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 (PeHdr->OptionalHeader.NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
+ RelocDir = &PeHdr->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];
+ RelocBase = PeCoffLoader64ImageAddress (ImageContext, RelocDir->VirtualAddress);
+ RelocBaseEnd = PeCoffLoader64ImageAddress (
+ ImageContext,
+ RelocDir->VirtualAddress + 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);
+ FixupBase = PeCoffLoader64ImageAddress (ImageContext, RelocBase->VirtualAddress);
+ if ((CHAR8 *) RelocEnd < (CHAR8 *)((UINTN)ImageContext->ImageAddress) ||
+ (CHAR8 *) RelocEnd > (CHAR8 *)((UINTN)ImageContext->ImageAddress +
+ (UINTN)ImageContext->ImageSize)) {
+ ImageContext->ImageError = 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 << 16) + (UINT16) Adjust);
+ 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_HIGHADJ:
+ // Return the same EFI_UNSUPPORTED return code as
+ // PeCoffLoader64RelocateImageEx() returns if it does not recognize
+ // the relocation type.
+ //
+ ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
+ return EFI_UNSUPPORTED;
+ default:
+ Status = PeCoffLoader64RelocateImageEx (Reloc, Fixup, &FixupData, Adjust);
+ if (EFI_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 EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+PeCoffLoader64RelocateImageEx (
+ 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:
+ None
+
+--*/
+{
+ UINT64 *F64;
+
+ switch ((*Reloc) >> 12) {
+
+ 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:
+ return EFI_UNSUPPORTED;
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+
+EFI_STATUS
+EFIAPI
+PeCoffLoader64LoadImage (
+ IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+/*++
+
+Routine Description:
+ Loads a PE/COFF image into memory
+
+Arguments:
+ 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_NT_HEADERS64 *PeHdr;
+ PE_COFF_LOADER_IMAGE_CONTEXT CheckContext;
+ EFI_IMAGE_SECTION_HEADER *FirstSection;
+ EFI_IMAGE_SECTION_HEADER *Section;
+ UINTN Index;
+ CHAR8 *Base;
+ CHAR8 *End;
+ CHAR8 *MaxEnd;
+ EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry;
+ EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry;
+ UINTN Size;
+ UINT32 TempDebugEntryRva;
+
+ //
+ // 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 = PeCoffLoader64GetImageInfo (
+ 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 = IMAGE_ERROR_INVALID_IMAGE_SIZE;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // 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 == TRUE) {
+ //
+ // 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 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 = IMAGE_ERROR_INVALID_IMAGE_ADDRESS;
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
+ //
+ // Make sure the allocated space has the proper section alignment
+ //
+ if ((ImageContext->ImageAddress & (CheckContext.SectionAlignment - 1)) != 0) {
+ ImageContext->ImageError = IMAGE_ERROR_INVALID_SECTION_ALIGNMENT;
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Read the entire PE/COFF header into memory
+ //
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ 0,
+ &ImageContext->SizeOfHeaders,
+ (VOID *)(UINTN)ImageContext->ImageAddress
+ );
+ if (EFI_ERROR(Status)) {
+ ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;
+ return EFI_LOAD_ERROR;
+ }
+
+ PeHdr = (EFI_IMAGE_NT_HEADERS64 *)
+ ((UINTN)ImageContext->ImageAddress + ImageContext->PeCoffHeaderOffset);
+
+ //
+ // Load each section of the image
+ //
+ FirstSection = (EFI_IMAGE_SECTION_HEADER *) (
+ (UINTN)ImageContext->ImageAddress +
+ ImageContext->PeCoffHeaderOffset +
+ sizeof(UINT32) +
+ sizeof(EFI_IMAGE_FILE_HEADER) +
+ PeHdr->FileHeader.SizeOfOptionalHeader
+ );
+
+ Section = FirstSection;
+ for ( Index=0, MaxEnd = NULL;
+ Index < PeHdr->FileHeader.NumberOfSections;
+ Index += 1) {
+
+ //
+ // Compute sections address
+ //
+ Base = PeCoffLoader64ImageAddress (ImageContext, Section->VirtualAddress);
+ End = PeCoffLoader64ImageAddress (
+ ImageContext,
+ Section->VirtualAddress + Section->Misc.VirtualSize - 1);
+ if (End > MaxEnd) {
+ MaxEnd = End;
+ }
+ //
+ // If the base start or end address resolved to 0, then fail.
+ //
+ if (!Base || !End) {
+ ImageContext->ImageError = IMAGE_ERROR_SECTION_NOT_LOADED;
+ return EFI_LOAD_ERROR;
+ }
+
+ //
+ // Read the section, we can resume the length of PE image can't
+ // exceed the max 32bit integer
+ //
+ Size = (UINTN) Section->Misc.VirtualSize;
+ if ((Size == 0) || (Size > Section->SizeOfRawData)) {
+ Size = (UINTN) Section->SizeOfRawData;
+ }
+ if (Section->SizeOfRawData) {
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ Section->PointerToRawData,
+ &Size,
+ Base);
+ if (EFI_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 - (UINTN)Size);
+ }
+
+ //
+ // Next Section
+ //
+ Section += 1;
+ }
+
+ //
+ // Get image's entry point
+ //
+ ImageContext->EntryPoint =
+ (EFI_PHYSICAL_ADDRESS) (UINTN) PeCoffLoader64ImageAddress (
+ ImageContext,
+ PeHdr->OptionalHeader.AddressOfEntryPoint
+ );
+
+ //
+ // 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 (PeHdr->OptionalHeader.NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)
+ &PeHdr->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];
+ ImageContext->FixupDataSize =
+ DirectoryEntry->Size / sizeof(UINT16) * sizeof(UINTN);
+ } else {
+ ImageContext->FixupDataSize = 0;
+ }
+ //
+ // 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) {
+ DebugEntry = PeCoffLoader64ImageAddress (
+ ImageContext,
+ ImageContext->DebugDirectoryEntryRva
+ );
+ 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) {
+ ImageContext->CodeView = PeCoffLoader64ImageAddress (ImageContext, TempDebugEntryRva);
+ if (ImageContext->CodeView == NULL) {
+ ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;
+ return EFI_LOAD_ERROR;
+ }
+
+ if (DebugEntry->RVA == 0) {
+ Size = (UINTN) DebugEntry->SizeOfData;
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ DebugEntry->FileOffset,
+ &Size,
+ ImageContext->CodeView
+ );
+ if (EFI_ERROR(Status)) {
+ ImageContext->ImageError = 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;
+ }
+ }
+ }
+ }
+
+ return Status;
+}
+
+EFI_STATUS
+EFIAPI
+PeCoffLoader64UnloadImage (
+ IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
+ IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+/*++
+
+Routine Description:
+ Unload of images is not supported
+
+Arguments:
+ ImageContext - The image to unload
+
+Returns:
+ EFI_SUCCESS
+
+--*/
+{
+ return EFI_SUCCESS;
+}
+
+EFI_PEI_PE_COFF_LOADER_PROTOCOL *
+EFIAPI
+GetPeCoffLoaderX64Protocol (
+ )
+{
+ return &mPeCoffLoaderX64;
+}
+
+
diff --git a/EdkModulePkg/Library/EdkPeCoffLoaderX64Lib/EdkPeCoffLoaderX64Lib.mbd b/EdkModulePkg/Library/EdkPeCoffLoaderX64Lib/EdkPeCoffLoaderX64Lib.mbd
new file mode 100644
index 0000000..8b6f365
--- /dev/null
+++ b/EdkModulePkg/Library/EdkPeCoffLoaderX64Lib/EdkPeCoffLoaderX64Lib.mbd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>EdkPeCoffLoaderX64Lib</BaseName>
+ <Guid>6aac37f2-7b46-4ef3-8645-c24800a3d410</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004 - 2005, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Created>2006-04-03 23:59</Created>
+ <Modified>2006-04-05 21:30</Modified>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/EdkPeCoffLoaderX64Lib/EdkPeCoffLoaderX64Lib.msa b/EdkModulePkg/Library/EdkPeCoffLoaderX64Lib/EdkPeCoffLoaderX64Lib.msa
new file mode 100644
index 0000000..964ae55
--- /dev/null
+++ b/EdkModulePkg/Library/EdkPeCoffLoaderX64Lib/EdkPeCoffLoaderX64Lib.msa
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>EdkPeCoffLoaderX64Lib</BaseName>
+ <ModuleType>PEIM</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>6aac37f2-7b46-4ef3-8645-c24800a3d410</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Abstract>Component description file for the PEI library.</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004 - 2005, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>EFI_SPECIFICATION_VERSION 0x00000000</Specification>
+ <Created>2006-04-03 23:59</Created>
+ <Updated>2006-04-05 21:30</Updated>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">EdkPeCoffLoaderX64Lib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseMemoryLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PeCoffLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>EdkPeCoffLoaderX64.c</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/EdkPeCoffLoaderX64Lib/build.xml b/EdkModulePkg/Library/EdkPeCoffLoaderX64Lib/build.xml
new file mode 100644
index 0000000..c72e03e
--- /dev/null
+++ b/EdkModulePkg/Library/EdkPeCoffLoaderX64Lib/build.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="EdkPeCoffLoaderX64Lib"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\EdkPeCoffLoaderX64Lib"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="EdkPeCoffLoaderX64Lib">
+ <GenBuild baseName="EdkPeCoffLoaderX64Lib" mbdFilename="${MODULE_DIR}\EdkPeCoffLoaderX64Lib.mbd" msaFilename="${MODULE_DIR}\EdkPeCoffLoaderX64Lib.msa"/>
+ </target>
+ <target depends="EdkPeCoffLoaderX64Lib_clean" name="clean"/>
+ <target depends="EdkPeCoffLoaderX64Lib_cleanAll" name="cleanAll"/>
+ <target name="EdkPeCoffLoaderX64Lib_clean">
+ <OutputDirSetup baseName="EdkPeCoffLoaderX64Lib" mbdFilename="${MODULE_DIR}\EdkPeCoffLoaderX64Lib.mbd" msaFilename="${MODULE_DIR}\EdkPeCoffLoaderX64Lib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkPeCoffLoaderX64Lib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkPeCoffLoaderX64Lib_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="EdkPeCoffLoaderX64Lib_cleanAll">
+ <OutputDirSetup baseName="EdkPeCoffLoaderX64Lib" mbdFilename="${MODULE_DIR}\EdkPeCoffLoaderX64Lib.mbd" msaFilename="${MODULE_DIR}\EdkPeCoffLoaderX64Lib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkPeCoffLoaderX64Lib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkPeCoffLoaderX64Lib_build.xml" target="cleanAll"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**EdkPeCoffLoaderX64Lib*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/EdkPeiPerformanceLib/EdkPeiPerformanceLib.mbd b/EdkModulePkg/Library/EdkPeiPerformanceLib/EdkPeiPerformanceLib.mbd
new file mode 100644
index 0000000..103f7c4
--- /dev/null
+++ b/EdkModulePkg/Library/EdkPeiPerformanceLib/EdkPeiPerformanceLib.mbd
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>EdkPeiPerformanceLib</BaseName>
+ <Guid>F72DE735-B24F-4ef6-897F-70A85D01A047</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Created>2006-04-04 11:12</Created>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/EdkPeiPerformanceLib/EdkPeiPerformanceLib.msa b/EdkModulePkg/Library/EdkPeiPerformanceLib/EdkPeiPerformanceLib.msa
new file mode 100644
index 0000000..9c2eda7
--- /dev/null
+++ b/EdkModulePkg/Library/EdkPeiPerformanceLib/EdkPeiPerformanceLib.msa
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>EdkPeiPerformanceLib</BaseName>
+ <ModuleType>PEIM</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>F72DE735-B24F-4ef6-897F-70A85D01A047</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Abstract>Memory-only library functions with no library constructor/destructor</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>EFI_SPECIFICATION_VERSION 0x00000000</Specification>
+ <Created>2006-04-04 11:12</Created>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">PerformanceLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">HobLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">TimerLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PcdLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseMemoryLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>PeiPerformanceLib.c</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+ <Guids>
+ <GuidEntry Usage="SOMETIMES_CONSUMED">
+ <C_Name>PeiPerformanceHob</C_Name>
+ </GuidEntry>
+ </Guids>
+ <PCDs>
+ <PcdData ItemType="FIXED_AT_BUILD">
+ <C_Name>PcdPerformanceLibraryPropertyMask</C_Name>
+ <Token>0x00000001</Token>
+ <DatumType>UINT8</DatumType>
+ </PcdData>
+ </PCDs>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/EdkPeiPerformanceLib/PeiPerformanceLib.c b/EdkModulePkg/Library/EdkPeiPerformanceLib/PeiPerformanceLib.c
new file mode 100644
index 0000000..89e2dd3
--- /dev/null
+++ b/EdkModulePkg/Library/EdkPeiPerformanceLib/PeiPerformanceLib.c
@@ -0,0 +1,315 @@
+/*++
+
+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:
+
+ PeiPerformanceLib.c
+
+Abstract:
+
+ Performance Library
+
+--*/
+
+/**
+ Gets PEI the GUID HOB for PEI performance.
+
+ This internal function searches for the GUID HOB for PEI performance.
+ If that GUID HOB is not found, it will build a new one.
+ It returns the data area of that GUID HOB to record performance log.
+
+ @param Handle Pointer to environment specific context used
+ to identify the component being measured.
+ @param Token Pointer to a Null-terminated ASCII string
+ that identifies the component being measured.
+ @param Module Pointer to a Null-terminated ASCII string
+ that identifies the module being measured.
+
+ @retval The index of log entry in the array.
+
+**/
+PEI_PERFORMANCE_LOG_HEADER *
+InternalGetPerformanceHobLog (
+ VOID
+ )
+{
+ EFI_HOB_GUID_TYPE *GuidHob;
+ PEI_PERFORMANCE_LOG_HEADER *PeiPerformanceLog;
+ UINTN PeiPerformanceLogSize;
+
+ GuidHob = GetFirstGuidHob (&gPeiPerformanceHobGuid);
+
+ if (GuidHob != NULL) {
+ //
+ // PEI Performance HOB was found, then return the existing one.
+ //
+ PeiPerformanceLog = GET_GUID_HOB_DATA (GuidHob);
+ } else {
+ //
+ // PEI Performance HOB was not found, then build one.
+ //
+ PeiPerformanceLogSize = sizeof (PEI_PERFORMANCE_LOG_HEADER) +
+ sizeof (PEI_PERFORMANCE_LOG_ENTRY) * MAX_PEI_PERFORMANCE_LOG_ENTRIES;
+ PeiPerformanceLog = BuildGuidHob (&gPeiPerformanceHobGuid, PeiPerformanceLogSize);
+ PeiPerformanceLog = ZeroMem (PeiPerformanceLog, PeiPerformanceLogSize);
+ }
+
+ return PeiPerformanceLog;
+}
+
+/**
+ Searches in the log array with keyword Handle, Token and Module.
+
+ This internal function searches for the log entry in the log array.
+ If there is an entry that exactly matches the given key word triple
+ and its end time stamp is zero, then the index of that log entry is returned;
+ otherwise, the the number of log entries in the array is returned.
+
+ @param Handle Pointer to environment specific context used
+ to identify the component being measured.
+ @param Token Pointer to a Null-terminated ASCII string
+ that identifies the component being measured.
+ @param Module Pointer to a Null-terminated ASCII string
+ that identifies the module being measured.
+
+ @retval The index of log entry in the array.
+
+**/
+UINT32
+InternalSearchForLogEntry (
+ IN PEI_PERFORMANCE_LOG_HEADER *PeiPerformanceLog,
+ IN CONST VOID *Handle, OPTIONAL
+ IN CONST CHAR8 *Token, OPTIONAL
+ IN CONST CHAR8 *Module OPTIONAL
+ )
+{
+ UINT32 Index;
+ UINT32 NumberOfEntries;
+ PEI_PERFORMANCE_LOG_ENTRY *LogEntryArray;
+
+
+ if (Token == NULL) {
+ Token = "";
+ }
+ if (Module == NULL) {
+ Module = "";
+ }
+ NumberOfEntries = PeiPerformanceLog->NumberOfEntries;
+ LogEntryArray = (PEI_PERFORMANCE_LOG_ENTRY *) (PeiPerformanceLog + 1);
+
+ for (Index = 0; Index < NumberOfEntries; Index++) {
+ if ((LogEntryArray[Index].Handle == (EFI_PHYSICAL_ADDRESS) (UINTN) Handle) &&
+ AsciiStrnCmp (LogEntryArray[Index].Token, Token, PEI_PERFORMANCE_STRING_LENGTH) == 0 &&
+ AsciiStrnCmp (LogEntryArray[Index].Module, Module, PEI_PERFORMANCE_STRING_LENGTH) == 0 &&
+ LogEntryArray[Index].EndTimeStamp == 0
+ ) {
+ break;
+ }
+ }
+ return Index;
+}
+
+/**
+ Creates a record for the beginning of a performance measurement.
+
+ Creates a record that contains the Handle, Token, and Module.
+ If TimeStamp is not zero, then TimeStamp is added to the record as the start time.
+ If TimeStamp is zero, then this function reads the current time stamp
+ and adds that time stamp value to the record as the start time.
+
+ @param Handle Pointer to environment specific context used
+ to identify the component being measured.
+ @param Token Pointer to a Null-terminated ASCII string
+ that identifies the component being measured.
+ @param Module Pointer to a Null-terminated ASCII string
+ that identifies the module being measured.
+ @param TimeStamp 64-bit time stamp.
+
+ @retval RETURN_SUCCESS The start of the measurement was recorded.
+ @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.
+
+**/
+RETURN_STATUS
+EFIAPI
+StartPerformanceMeasurement (
+ IN CONST VOID *Handle, OPTIONAL
+ IN CONST CHAR8 *Token, OPTIONAL
+ IN CONST CHAR8 *Module, OPTIONAL
+ IN UINT64 TimeStamp
+ )
+{
+ PEI_PERFORMANCE_LOG_HEADER *PeiPerformanceLog;
+ PEI_PERFORMANCE_LOG_ENTRY *LogEntryArray;
+ UINT32 Index;
+
+ PeiPerformanceLog = InternalGetPerformanceHobLog ();
+
+ if (PeiPerformanceLog->NumberOfEntries >= MAX_PEI_PERFORMANCE_LOG_ENTRIES) {
+ return RETURN_OUT_OF_RESOURCES;
+ }
+ Index = PeiPerformanceLog->NumberOfEntries++;
+ LogEntryArray = (PEI_PERFORMANCE_LOG_ENTRY *) (PeiPerformanceLog + 1);
+ LogEntryArray[Index].Handle = (EFI_PHYSICAL_ADDRESS) (UINTN) Handle;
+
+ if (Token != NULL) {
+ AsciiStrnCpy (LogEntryArray[Index].Token, Token, PEI_PERFORMANCE_STRING_LENGTH);
+ }
+ if (Module != NULL) {
+ AsciiStrnCpy (LogEntryArray[Index].Module, Module, PEI_PERFORMANCE_STRING_LENGTH);
+ }
+
+ if (TimeStamp == 0) {
+ TimeStamp = GetPerformanceCounter ();
+ }
+ LogEntryArray[Index].StartTimeStamp = TimeStamp;
+
+ return RETURN_SUCCESS;
+}
+
+/**
+ Fills in the end time of a performance measurement.
+
+ Looks up the record that matches Handle, Token, and Module.
+ If the record can not be found then return RETURN_NOT_FOUND.
+ If the record is found and TimeStamp is not zero,
+ then TimeStamp is added to the record as the end time.
+ If the record is found and TimeStamp is zero, then this function reads
+ the current time stamp and adds that time stamp value to the record as the end time.
+ If this function is called multiple times for the same record, then the end time is overwritten.
+
+ @param Handle Pointer to environment specific context used
+ to identify the component being measured.
+ @param Token Pointer to a Null-terminated ASCII string
+ that identifies the component being measured.
+ @param Module Pointer to a Null-terminated ASCII string
+ that identifies the module being measured.
+ @param TimeStamp 64-bit time stamp.
+
+ @retval RETURN_SUCCESS The end of the measurement was recorded.
+ @retval RETURN_NOT_FOUND The specified measurement record could not be found.
+
+**/
+RETURN_STATUS
+EFIAPI
+EndPerformanceMeasurement (
+ IN CONST VOID *Handle, OPTIONAL
+ IN CONST CHAR8 *Token, OPTIONAL
+ IN CONST CHAR8 *Module, OPTIONAL
+ IN UINT64 TimeStamp
+ )
+{
+ PEI_PERFORMANCE_LOG_HEADER *PeiPerformanceLog;
+ PEI_PERFORMANCE_LOG_ENTRY *LogEntryArray;
+ UINT32 Index;
+
+ if (TimeStamp == 0) {
+ TimeStamp = GetPerformanceCounter ();
+ }
+
+ PeiPerformanceLog = InternalGetPerformanceHobLog ();
+ Index = InternalSearchForLogEntry (PeiPerformanceLog, Handle, Token, Module);
+ if (Index >= PeiPerformanceLog->NumberOfEntries) {
+ return RETURN_NOT_FOUND;
+ }
+ LogEntryArray = (PEI_PERFORMANCE_LOG_ENTRY *) (PeiPerformanceLog + 1);
+ LogEntryArray[Index].EndTimeStamp = TimeStamp;
+
+ return RETURN_SUCCESS;
+}
+
+/**
+ Retrieves a previously logged performance measurement.
+
+ Looks up the record that matches Handle, Token, and Module.
+ If the record can not be found then return RETURN_NOT_FOUND.
+ If the record is found then the start of the measurement is returned in StartTimeStamp,
+ and the end of the measurement is returned in EndTimeStamp.
+
+ @param LogEntryKey The key for the previous performance measurement log entry.
+ If 0, then the first performance measurement log entry is retrieved.
+ @param Handle Pointer to environment specific context used
+ to identify the component being measured.
+ @param Token Pointer to a Null-terminated ASCII string
+ that identifies the component being measured.
+ @param Module Pointer to a Null-terminated ASCII string
+ that identifies the module being measured.
+ @param StartTimeStamp The 64-bit time stamp that was recorded when the measurement was started.
+ @param EndTimeStamp The 64-bit time stamp that was recorded when the measurement was ended.
+
+ @return The key for the current performance log entry.
+
+**/
+UINTN
+EFIAPI
+GetPerformanceMeasurement (
+ UINTN LogEntryKey,
+ OUT CONST VOID **Handle,
+ OUT CONST CHAR8 **Token,
+ OUT CONST CHAR8 **Module,
+ OUT UINT64 *StartTimeStamp,
+ OUT UINT64 *EndTimeStamp
+ )
+{
+ PEI_PERFORMANCE_LOG_HEADER *PeiPerformanceLog;
+ PEI_PERFORMANCE_LOG_ENTRY *CurrentLogEntry;
+ PEI_PERFORMANCE_LOG_ENTRY *LogEntryArray;
+ UINTN NumberOfEntries;
+
+ ASSERT (Handle != NULL);
+ ASSERT (Token != NULL);
+ ASSERT (Module != NULL);
+ ASSERT (StartTimeStamp != NULL);
+ ASSERT (EndTimeStamp != NULL);
+
+ PeiPerformanceLog = InternalGetPerformanceHobLog ();
+
+ NumberOfEntries = (UINTN) (PeiPerformanceLog->NumberOfEntries);
+ LogEntryArray = (PEI_PERFORMANCE_LOG_ENTRY *) (PeiPerformanceLog + 1);
+ //
+ // Make sure that LogEntryKey is a valid log entry key.
+ //
+ ASSERT (LogEntryKey <= NumberOfEntries);
+
+ if (LogEntryKey == NumberOfEntries) {
+ return 0;
+ }
+
+ CurrentLogEntry = &(LogEntryArray[LogEntryKey++]);
+
+ *Handle = (VOID *) (UINTN) (CurrentLogEntry->Handle);
+ *Token = CurrentLogEntry->Token;
+ *Module = CurrentLogEntry->Module;
+ *StartTimeStamp = CurrentLogEntry->StartTimeStamp;
+ *EndTimeStamp = CurrentLogEntry->EndTimeStamp;
+
+ return LogEntryKey;
+}
+
+/**
+ Returns TRUE if the performance measurement macros are enabled.
+
+ This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
+ PcdPerformanceLibraryPropertyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
+ PcdPerformanceLibraryPropertyMask is set.
+ @retval FALSE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
+ PcdPerformanceLibraryPropertyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+PerformanceMeasurementEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);
+}
diff --git a/EdkModulePkg/Library/EdkPeiPerformanceLib/build.xml b/EdkModulePkg/Library/EdkPeiPerformanceLib/build.xml
new file mode 100644
index 0000000..8b476da
--- /dev/null
+++ b/EdkModulePkg/Library/EdkPeiPerformanceLib/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="EdkPeiPerformanceLib"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\EdkPeiPerformanceLib"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="EdkPeiPerformanceLib">
+ <GenBuild baseName="EdkPeiPerformanceLib" mbdFilename="${MODULE_DIR}\EdkPeiPerformanceLib.mbd" msaFilename="${MODULE_DIR}\EdkPeiPerformanceLib.msa"/>
+ </target>
+ <target depends="EdkPeiPerformanceLib_clean" name="clean"/>
+ <target depends="EdkPeiPerformanceLib_cleanall" name="cleanall"/>
+ <target name="EdkPeiPerformanceLib_clean">
+ <OutputDirSetup baseName="EdkPeiPerformanceLib" mbdFilename="${MODULE_DIR}\EdkPeiPerformanceLib.mbd" msaFilename="${MODULE_DIR}\EdkPeiPerformanceLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkPeiPerformanceLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkPeiPerformanceLib_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="EdkPeiPerformanceLib_cleanall">
+ <OutputDirSetup baseName="EdkPeiPerformanceLib" mbdFilename="${MODULE_DIR}\EdkPeiPerformanceLib.mbd" msaFilename="${MODULE_DIR}\EdkPeiPerformanceLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkPeiPerformanceLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkPeiPerformanceLib_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**EdkPeiPerformanceLib*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.c b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.c
new file mode 100644
index 0000000..d72aae1
--- /dev/null
+++ b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.c
@@ -0,0 +1,397 @@
+/*++
+
+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:
+
+ BsDataHubStatusCode.c
+
+Abstract:
+
+ This implements a status code listener that logs status codes into the data
+ hub. This is only active during non-runtime DXE.
+
+--*/
+#include "BsDataHubStatusCode.h"
+
+//
+// Globals only work at BootService Time. NOT at Runtime!
+//
+static EFI_DATA_HUB_PROTOCOL *mDataHub;
+static LIST_ENTRY mRecordBuffer;
+static INTN mRecordNum;
+static EFI_EVENT mLogDataHubEvent;
+static EFI_LOCK mStatusCodeReportLock;
+static BOOLEAN mEventHandlerActive = FALSE;
+
+STATUS_CODE_RECORD_LIST *
+GetRecordBuffer (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Returned buffer of length BYTES_PER_RECORD
+
+Arguments:
+
+ None
+
+Returns:
+
+ Entry in mRecordBuffer or NULL if non available
+
+--*/
+{
+ STATUS_CODE_RECORD_LIST *Buffer;
+
+ gBS->AllocatePool (EfiBootServicesData, sizeof (STATUS_CODE_RECORD_LIST), (VOID **) &Buffer);
+ if (Buffer == NULL) {
+ return NULL;
+ }
+
+ ZeroMem (Buffer, sizeof (STATUS_CODE_RECORD_LIST));
+ Buffer->Signature = BS_DATA_HUB_STATUS_CODE_SIGNATURE;
+
+ return Buffer;
+}
+
+DATA_HUB_STATUS_CODE_DATA_RECORD *
+AquireEmptyRecordBuffer (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Allocate a mRecordBuffer entry in the form of a pointer.
+
+Arguments:
+
+ None
+
+Returns:
+
+ Pointer to new buffer. NULL if none exist.
+
+--*/
+{
+ STATUS_CODE_RECORD_LIST *DataBuffer;
+
+ if (mRecordNum < MAX_RECORD_NUM) {
+ DataBuffer = GetRecordBuffer ();
+ if (DataBuffer != NULL) {
+ EfiAcquireLock (&mStatusCodeReportLock);
+ InsertTailList (&mRecordBuffer, &DataBuffer->Link);
+ mRecordNum++;
+ EfiReleaseLock (&mStatusCodeReportLock);
+ return (DATA_HUB_STATUS_CODE_DATA_RECORD *) DataBuffer->RecordBuffer;
+ }
+ }
+
+ return NULL;
+}
+
+EFI_STATUS
+ReleaseRecordBuffer (
+ IN STATUS_CODE_RECORD_LIST *RecordBuffer
+ )
+/*++
+
+Routine Description:
+
+ Release a mRecordBuffer entry allocated by AquireEmptyRecordBuffer ().
+
+Arguments:
+
+ RecordBuffer - Data to free
+
+Returns:
+
+ EFI_SUCCESS - If DataRecord is valid
+ EFI_UNSUPPORTED - The record list has empty
+
+--*/
+{
+ ASSERT (RecordBuffer != NULL);
+ if (mRecordNum <= 0) {
+ return EFI_UNSUPPORTED;
+ }
+
+ EfiAcquireLock (&mStatusCodeReportLock);
+ RemoveEntryList (&RecordBuffer->Link);
+ mRecordNum--;
+ EfiReleaseLock (&mStatusCodeReportLock);
+ gBS->FreePool (RecordBuffer);
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+BsDataHubReportStatusCode (
+ 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:
+
+ Boot service report status code listener. This function logs the status code
+ into the data hub.
+
+Arguments:
+
+ Same as ReportStatusCode (See Tiano Runtime Specification)
+
+Returns:
+
+ None
+
+--*/
+{
+ DATA_HUB_STATUS_CODE_DATA_RECORD *DataHub;
+ UINT32 ErrorLevel;
+ VA_LIST Marker;
+ CHAR8 *Format;
+ UINTN Index;
+ CHAR16 FormatBuffer[BYTES_PER_RECORD];
+
+ if (EfiAtRuntime ()) {
+ //
+ // For now all we do is post code at runtime
+ //
+ return EFI_SUCCESS;
+ }
+ //
+ // If we had an error while in our event handler, then do nothing so
+ // that we don't get in an endless loop.
+ //
+ if (mEventHandlerActive) {
+ return EFI_SUCCESS;
+ }
+
+ DataHub = (DATA_HUB_STATUS_CODE_DATA_RECORD *) AquireEmptyRecordBuffer ();
+ if (DataHub == NULL) {
+ //
+ // There are no empty record buffer in private buffers
+ //
+ return EFI_OUT_OF_RESOURCES;
+ }
+ //
+ // Construct Data Hub Extended Data
+ //
+ DataHub->CodeType = CodeType;
+ DataHub->Value = Value;
+ DataHub->Instance = Instance;
+
+ if (CallerId != NULL) {
+ CopyMem (&DataHub->CallerId, CallerId, sizeof (EFI_GUID));
+ } else {
+ ZeroMem (&DataHub->CallerId, sizeof (EFI_GUID));
+ }
+
+ if (Data == NULL) {
+ ZeroMem (&DataHub->Data, sizeof (EFI_STATUS_CODE_DATA));
+ } else {
+ //
+ // Copy generic Header
+ //
+ CopyMem (&DataHub->Data, Data, sizeof (EFI_STATUS_CODE_DATA));
+
+ if (ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {
+ //
+ // Convert Ascii Format string to Unicode.
+ //
+ for (Index = 0; Format[Index] != '\0' && Index < (BYTES_PER_RECORD - 1); Index += 1) {
+ FormatBuffer[Index] = (CHAR16) Format[Index];
+ }
+
+ FormatBuffer[Index] = L'\0';
+
+ //
+ // Put processed string into the buffer
+ //
+ Index = UnicodeVSPrint (
+ (CHAR16 *) (DataHub + 1),
+ BYTES_PER_RECORD - (sizeof (DATA_HUB_STATUS_CODE_DATA_RECORD)),
+ FormatBuffer,
+ Marker
+ );
+
+ //
+ // DATA_HUB_STATUS_CODE_DATA_RECORD followed by VSPrint String Buffer
+ //
+ DataHub->Data.Size = (UINT16) (Index * sizeof (CHAR16));
+
+ } else {
+ //
+ // Default behavior is to copy optional data
+ //
+ if (Data->Size > (BYTES_PER_RECORD - sizeof (DATA_HUB_STATUS_CODE_DATA_RECORD))) {
+ DataHub->Data.Size = (UINT16) (BYTES_PER_RECORD - sizeof (DATA_HUB_STATUS_CODE_DATA_RECORD));
+ }
+
+ CopyMem (DataHub + 1, Data + 1, DataHub->Data.Size);
+ }
+ }
+
+ gBS->SignalEvent (mLogDataHubEvent);
+
+ return EFI_SUCCESS;
+}
+
+VOID
+EFIAPI
+LogDataHubEventHandler (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+/*++
+
+Routine Description:
+
+ The Event handler which will be notified to log data in Data Hub.
+
+Arguments:
+
+ Event - Instance of the EFI_EVENT to signal whenever data is
+ available to be logged in the system.
+ Context - Context of the event.
+
+Returns:
+
+ None.
+
+--*/
+{
+ EFI_STATUS Status;
+ DATA_HUB_STATUS_CODE_DATA_RECORD *DataRecord;
+ UINTN Size;
+ UINT64 DataRecordClass;
+ LIST_ENTRY *Link;
+ STATUS_CODE_RECORD_LIST *BufferEntry;
+
+ //
+ // Set our global flag so we don't recurse if we get an error here.
+ //
+ mEventHandlerActive = TRUE;
+
+ //
+ // Log DataRecord in Data Hub.
+ // If there are multiple DataRecords, Log all of them.
+ //
+ for (Link = mRecordBuffer.ForwardLink; Link != &mRecordBuffer;) {
+ BufferEntry = CR (Link, STATUS_CODE_RECORD_LIST, Link, BS_DATA_HUB_STATUS_CODE_SIGNATURE);
+ DataRecord = (DATA_HUB_STATUS_CODE_DATA_RECORD *) (BufferEntry->RecordBuffer);
+ Link = Link->ForwardLink;
+
+ //
+ // Add in the size of the header we added.
+ //
+ Size = sizeof (DATA_HUB_STATUS_CODE_DATA_RECORD) + DataRecord->Data.Size;
+
+ if ((DataRecord->CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {
+ DataRecordClass = EFI_DATA_RECORD_CLASS_PROGRESS_CODE;
+ } else if ((DataRecord->CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {
+ DataRecordClass = EFI_DATA_RECORD_CLASS_ERROR;
+ } else if ((DataRecord->CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) {
+ DataRecordClass = EFI_DATA_RECORD_CLASS_DEBUG;
+ } else {
+ //
+ // Should never get here.
+ //
+ DataRecordClass = EFI_DATA_RECORD_CLASS_DEBUG |
+ EFI_DATA_RECORD_CLASS_ERROR |
+ EFI_DATA_RECORD_CLASS_DATA |
+ EFI_DATA_RECORD_CLASS_PROGRESS_CODE;
+ }
+
+ if (((DataRecord->Instance & EFI_D_ERROR) != 0) &&
+ (((DataRecord->Instance & EFI_D_POOL) != 0) || ((DataRecord->Instance & EFI_D_PAGE) != 0))
+ ) {
+ //
+ // If memory error, do not call LogData ().
+ //
+ DebugPrint ((UINTN)-1, "Memory Error\n");
+ Status = EFI_OUT_OF_RESOURCES;
+ } else {
+ //
+ // Log DataRecord in Data Hub
+ //
+ Status = mDataHub->LogData (
+ mDataHub,
+ &gEfiStatusCodeGuid,
+ &gEfiStatusCodeRuntimeProtocolGuid,
+ DataRecordClass,
+ DataRecord,
+ (UINT32) Size
+ );
+ }
+
+ ReleaseRecordBuffer (BufferEntry);
+ }
+
+ mEventHandlerActive = FALSE;
+
+ return ;
+}
+
+VOID
+BsDataHubStatusCodeInitialize (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Install a data hub listener.
+
+Arguments:
+
+ (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
+
+Returns:
+
+ EFI_SUCCESS - Logging Hub protocol installed
+ Other - No protocol installed, unload driver.
+
+--*/
+{
+ EFI_STATUS Status;
+
+ Status = gBS->LocateProtocol (&gEfiDataHubProtocolGuid, NULL, (VOID **) &mDataHub);
+ //
+ // Should never fail due to dependency grammer
+ //
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Initialize FIFO
+ //
+ InitializeListHead (&mRecordBuffer);
+ mRecordNum = 0;
+
+ EfiInitializeLock (&mStatusCodeReportLock, EFI_TPL_HIGH_LEVEL);
+
+ //
+ // Create a Notify Event to log data in Data Hub
+ //
+ Status = gBS->CreateEvent (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ EFI_TPL_CALLBACK,
+ LogDataHubEventHandler,
+ NULL,
+ &mLogDataHubEvent
+ );
+
+}
diff --git a/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.h b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.h
new file mode 100644
index 0000000..f15a90e
--- /dev/null
+++ b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.h
@@ -0,0 +1,130 @@
+/*++
+
+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:
+
+ BsDataHubStatusCode.h
+
+Abstract:
+
+ Header for the status code data hub logging component
+
+--*/
+
+#ifndef _EFI_BS_DATA_HUB_STATUS_CODE_H_
+#define _EFI_BS_DATA_HUB_STATUS_CODE_H_
+
+//
+// Private data declarations
+//
+#define MAX_RECORD_NUM 1000
+#define BYTES_PER_RECORD EFI_STATUS_CODE_DATA_MAX_SIZE
+#define EMPTY_RECORD_TAG 0xFF
+
+#define BS_DATA_HUB_STATUS_CODE_SIGNATURE EFI_SIGNATURE_32 ('B', 'D', 'H', 'S')
+
+typedef struct {
+ UINTN Signature;
+ LIST_ENTRY Link;
+ UINT8 RecordBuffer[BYTES_PER_RECORD];
+} STATUS_CODE_RECORD_LIST;
+
+//
+// Function prototypes
+//
+STATUS_CODE_RECORD_LIST *
+GetRecordBuffer (
+ VOID
+ )
+;
+
+/*++
+
+Routine Description:
+
+ Returned buffer of length BYTES_PER_RECORD
+
+Arguments:
+
+ None
+
+Returns:
+
+ Entry in mRecordBuffer or NULL if non available
+
+--*/
+DATA_HUB_STATUS_CODE_DATA_RECORD *
+AquireEmptyRecordBuffer (
+ VOID
+ )
+;
+
+/*++
+
+Routine Description:
+
+ Allocate a mRecordBuffer entry in the form of a pointer.
+
+Arguments:
+
+ None
+
+Returns:
+
+ Pointer to new buffer. NULL if none exist.
+
+--*/
+EFI_STATUS
+ReleaseRecordBuffer (
+ IN STATUS_CODE_RECORD_LIST *RecordBuffer
+ )
+;
+
+/*++
+
+Routine Description:
+
+ Release a mRecordBuffer entry allocated by AquireEmptyRecordBuffer ().
+
+Arguments:
+
+ RecordBuffer - Data to free
+
+Returns:
+
+ EFI_SUCCESS - If RecordBuffer is valid
+ EFI_UNSUPPORTED - The record list has empty
+
+--*/
+VOID
+EFIAPI
+LogDataHubEventHandler (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+;
+
+/*++
+
+Routine Description:
+
+ Event Handler that log in Status code in Data Hub.
+
+Arguments:
+
+ (Standard EFI Event Handler - EFI_EVENT_NOTIFY)
+
+Returns:
+
+ NONE
+
+--*/
+#endif
diff --git a/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.mbd b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.mbd
new file mode 100644
index 0000000..ce1bd63
--- /dev/null
+++ b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.mbd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>EdkBsDataHubStatusCodeLib</BaseName>
+ <Guid>041bf780-dc3e-49ab-8d67-4b86075440ea</Guid>
+ <Version>0</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004 - 2005, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Created>2006-03-12 17:09</Created>
+ <Modified>2006-03-19 15:19</Modified>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.msa b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.msa
new file mode 100644
index 0000000..7eff726
--- /dev/null
+++ b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/BsDataHubStatusCode.msa
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>EdkBsDataHubStatusCodeLib</BaseName>
+ <ModuleType>DXE_DRIVER</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>041bf780-dc3e-49ab-8d67-4b86075440ea</Guid>
+ <Version>0</Version>
+ <Abstract>Component description file for the PEI library.</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004 - 2005, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>0</Specification>
+ <Created>2006-03-12 17:09</Created>
+ <Updated>2006-03-19 15:19</Updated>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">EdkBsDataHubStatusCodeLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseMemoryLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DxeRuntimeDriverLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">ReportStatusCodeLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PrintLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>BsDataHubStatusCode.c</Filename>
+ <Filename>BsDataHubStatusCode.h</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+ <Protocols>
+ <Protocol Usage="ALWAYS_CONSUMED">StatusCode</Protocol>
+ <Protocol Usage="ALWAYS_CONSUMED">DataHub</Protocol>
+ </Protocols>
+ <Events>
+ <CreateEvents>
+ <Event>
+ <C_Name>EFI_EVENT_NOTIFY_SIGNAL</C_Name>
+ </Event>
+ </CreateEvents>
+ </Events>
+ <DataHubs>
+ <DataHubRecord>gEfiStatusCodeGuid</DataHubRecord>
+ </DataHubs>
+ <Guids>
+ <GuidEntry Usage="ALWAYS_CONSUMED">
+ <C_Name>StatusCode</C_Name>
+ </GuidEntry>
+ </Guids>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/build.xml b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/build.xml
new file mode 100644
index 0000000..308ca95
--- /dev/null
+++ b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/BsDataHubStatusCode/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="EdkBsDataHubStatusCodeLib"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\EdkRuntimeStatusCodeLib\BsDataHubStatusCode"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="EdkBsDataHubStatusCodeLib">
+ <GenBuild baseName="EdkBsDataHubStatusCodeLib" mbdFilename="${MODULE_DIR}\BsDataHubStatusCode.mbd" msaFilename="${MODULE_DIR}\BsDataHubStatusCode.msa"/>
+ </target>
+ <target depends="EdkBsDataHubStatusCodeLib_clean" name="clean"/>
+ <target depends="EdkBsDataHubStatusCodeLib_cleanall" name="cleanall"/>
+ <target name="EdkBsDataHubStatusCodeLib_clean">
+ <OutputDirSetup baseName="EdkBsDataHubStatusCodeLib" mbdFilename="${MODULE_DIR}\BsDataHubStatusCode.mbd" msaFilename="${MODULE_DIR}\BsDataHubStatusCode.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkBsDataHubStatusCodeLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkBsDataHubStatusCodeLib_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="EdkBsDataHubStatusCodeLib_cleanall">
+ <OutputDirSetup baseName="EdkBsDataHubStatusCodeLib" mbdFilename="${MODULE_DIR}\BsDataHubStatusCode.mbd" msaFilename="${MODULE_DIR}\BsDataHubStatusCode.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkBsDataHubStatusCodeLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkBsDataHubStatusCodeLib_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**EdkBsDataHubStatusCodeLib*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/RtMemoryStatusCode.c b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/RtMemoryStatusCode.c
new file mode 100644
index 0000000..375a338
--- /dev/null
+++ b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/RtMemoryStatusCode.c
@@ -0,0 +1,188 @@
+/*++
+
+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:
+
+ RtMemoryStatusCode.c
+
+Abstract:
+
+ EFI lib to provide memory journal status code reporting routines.
+
+--*/
+
+#include <Ppi/StatusCodeMemory.h>
+
+//
+// Global variables
+//
+PEI_STATUS_CODE_MEMORY_PPI mStatusCodeMemoryPpi = { 0, 0, 0, 0 };
+
+//
+// Function implementations
+//
+EFI_STATUS
+RtMemoryReportStatusCode (
+ 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:
+
+ Log a status code to a memory journal. If no memory journal exists,
+ we will just return.
+
+Arguments:
+
+ Same as ReportStatusCode AP
+
+Returns:
+
+ EFI_SUCCESS This function always returns success
+
+--*/
+{
+ EFI_STATUS_CODE_ENTRY *CurrentEntry;
+ UINTN MaxEntry;
+
+ //
+ // We don't care to log debug codes.
+ //
+ if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) {
+ return EFI_SUCCESS;
+ }
+ //
+ // Update the latest entry in the journal.
+ //
+ MaxEntry = mStatusCodeMemoryPpi.Length / sizeof (EFI_STATUS_CODE_ENTRY);
+ if (!MaxEntry) {
+ //
+ // If we don't have any entries, then we can return.
+ // This effectively means that no memory buffer was passed forward from PEI.
+ //
+ return EFI_SUCCESS;
+ }
+
+ CurrentEntry = (EFI_STATUS_CODE_ENTRY *) (UINTN) (mStatusCodeMemoryPpi.Address + (mStatusCodeMemoryPpi.LastEntry * sizeof (EFI_STATUS_CODE_ENTRY)));
+
+ mStatusCodeMemoryPpi.LastEntry = (mStatusCodeMemoryPpi.LastEntry + 1) % MaxEntry;
+ if (mStatusCodeMemoryPpi.LastEntry == mStatusCodeMemoryPpi.FirstEntry) {
+ mStatusCodeMemoryPpi.FirstEntry = (mStatusCodeMemoryPpi.FirstEntry + 1) % MaxEntry;
+ }
+
+ CurrentEntry->Type = CodeType;
+ CurrentEntry->Value = Value;
+ CurrentEntry->Instance = Instance;
+
+ return EFI_SUCCESS;
+}
+
+VOID
+RtMemoryStatusCodeInitialize (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Initialization routine.
+ Allocates heap space for storing Status Codes.
+ Installs a PPI to point to that heap space.
+ Installs a callback to switch to memory.
+ Installs a callback to
+
+Arguments:
+
+ (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
+
+Returns:
+
+ None
+
+--*/
+{
+ EFI_HOB_GUID_TYPE *GuidHob;
+ PEI_STATUS_CODE_MEMORY_PPI **StatusCodeMemoryPpi;
+
+ GuidHob = GetFirstGuidHob (&gPeiStatusCodeMemoryPpiGuid);
+ if (GuidHob == NULL) {
+ return;
+ }
+
+ StatusCodeMemoryPpi = GET_GUID_HOB_DATA (GuidHob);
+
+ //
+ // Copy data to our structure since the HOB will go away at runtime
+ //
+ // BUGBUG: Virtualize for RT
+ //
+ mStatusCodeMemoryPpi.FirstEntry = (*StatusCodeMemoryPpi)->FirstEntry;
+ mStatusCodeMemoryPpi.LastEntry = (*StatusCodeMemoryPpi)->LastEntry;
+ mStatusCodeMemoryPpi.Address = (*StatusCodeMemoryPpi)->Address;
+ mStatusCodeMemoryPpi.Length = (*StatusCodeMemoryPpi)->Length;
+}
+
+VOID
+PlaybackStatusCodes (
+ IN EFI_REPORT_STATUS_CODE ReportStatusCodeFunc
+ )
+/*++
+
+Routine Description:
+
+ Call the input ReportStatusCode function with every status code recorded in
+ the journal.
+
+Arguments:
+
+ ReportStatusCode ReportStatusCode function to call.
+
+Returns:
+
+ None
+
+--*/
+{
+ UINTN MaxEntry;
+ EFI_STATUS_CODE_ENTRY *CurrentEntry;
+ UINTN Counter;
+
+ if (ReportStatusCodeFunc == RtMemoryReportStatusCode) {
+ return ;
+ }
+ //
+ // Playback prior status codes to current listeners
+ //
+ MaxEntry = mStatusCodeMemoryPpi.Length / sizeof (EFI_STATUS_CODE_ENTRY);
+ for (Counter = mStatusCodeMemoryPpi.FirstEntry; Counter != mStatusCodeMemoryPpi.LastEntry; Counter++) {
+ //
+ // Check if we have to roll back to beginning of queue buffer
+ //
+ if (Counter == MaxEntry) {
+ Counter = 0;
+ }
+ //
+ // Play current entry
+ //
+ CurrentEntry = (EFI_STATUS_CODE_ENTRY *) (UINTN) (mStatusCodeMemoryPpi.Address + (Counter * sizeof (EFI_STATUS_CODE_ENTRY)));
+ ReportStatusCodeFunc (
+ CurrentEntry->Type,
+ CurrentEntry->Value,
+ CurrentEntry->Instance,
+ NULL,
+ NULL
+ );
+ }
+}
diff --git a/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/RtMemoryStatusCode.mbd b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/RtMemoryStatusCode.mbd
new file mode 100644
index 0000000..1795204
--- /dev/null
+++ b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/RtMemoryStatusCode.mbd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>EdkRtMemoryStatusCodeLib</BaseName>
+ <Guid>1517564b-ab66-42b7-8903-731a95f314f9</Guid>
+ <Version>0</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004 - 2005, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Created>2006-03-12 17:09</Created>
+ <Modified>2006-03-19 15:19</Modified>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/RtMemoryStatusCode.msa b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/RtMemoryStatusCode.msa
new file mode 100644
index 0000000..84d38e3
--- /dev/null
+++ b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/RtMemoryStatusCode.msa
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>EdkRtMemoryStatusCodeLib</BaseName>
+ <ModuleType>DXE_DRIVER</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>1517564b-ab66-42b7-8903-731a95f314f9</Guid>
+ <Version>0</Version>
+ <Abstract>Component description file for the PEI library.</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004 - 2005, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>0</Specification>
+ <Created>2006-03-12 17:09</Created>
+ <Updated>2006-03-19 15:19</Updated>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">EdkRtMemoryStatusCodeLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DxeRuntimeDriverLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">ReportStatusCodeLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PrintLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">HobLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>RtMemoryStatusCode.c</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/build.xml b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/build.xml
new file mode 100644
index 0000000..0f02e4e
--- /dev/null
+++ b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtMemoryStatusCode/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="EdkRtMemoryStatusCodeLib"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\EdkRuntimeStatusCodeLib\RtMemoryStatusCode"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="EdkRtMemoryStatusCodeLib">
+ <GenBuild baseName="EdkRtMemoryStatusCodeLib" mbdFilename="${MODULE_DIR}\RtMemoryStatusCode.mbd" msaFilename="${MODULE_DIR}\RtMemoryStatusCode.msa"/>
+ </target>
+ <target depends="EdkRtMemoryStatusCodeLib_clean" name="clean"/>
+ <target depends="EdkRtMemoryStatusCodeLib_cleanall" name="cleanall"/>
+ <target name="EdkRtMemoryStatusCodeLib_clean">
+ <OutputDirSetup baseName="EdkRtMemoryStatusCodeLib" mbdFilename="${MODULE_DIR}\RtMemoryStatusCode.mbd" msaFilename="${MODULE_DIR}\RtMemoryStatusCode.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkRtMemoryStatusCodeLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkRtMemoryStatusCodeLib_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="EdkRtMemoryStatusCodeLib_cleanall">
+ <OutputDirSetup baseName="EdkRtMemoryStatusCodeLib" mbdFilename="${MODULE_DIR}\RtMemoryStatusCode.mbd" msaFilename="${MODULE_DIR}\RtMemoryStatusCode.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkRtMemoryStatusCodeLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkRtMemoryStatusCodeLib_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**EdkRtMemoryStatusCodeLib*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/RtPlatformStatusCode.c b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/RtPlatformStatusCode.c
new file mode 100644
index 0000000..47f7f96
--- /dev/null
+++ b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/RtPlatformStatusCode.c
@@ -0,0 +1,130 @@
+/*++
+
+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:
+
+ RtPlatformStatusCode.c
+
+Abstract:
+
+ Contains NT32 specific implementations required to use status codes.
+
+--*/
+
+//
+// Globals only work at BootService Time. NOT at Runtime!
+//
+//
+
+typedef
+EFI_STATUS
+(EFIAPI *REPORT_STATUS_CODE_FUNCTION) (
+ 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
+ );
+
+REPORT_STATUS_CODE_FUNCTION mPeiReportStatusCode;
+
+//
+// Function implementations
+//
+EFI_STATUS
+RtPlatformReportStatusCode (
+ 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:
+
+ Call all status code listeners in the MonoStatusCode.
+
+Arguments:
+
+ Same as ReportStatusCode service
+
+Returns:
+
+ EFI_SUCCESS Always returns success.
+
+--*/
+{
+ RtMemoryReportStatusCode (CodeType, Value, Instance, CallerId, Data);
+ if (EfiAtRuntime ()) {
+ //
+ // For now all we do is post code at runtime
+ //
+ return EFI_SUCCESS;
+ }
+
+ BsDataHubReportStatusCode (CodeType, Value, Instance, CallerId, Data);
+
+ //
+ // Call back into PEI to get status codes. This is because SecMain contains
+ // status code that reports to Win32.
+ //
+ if (mPeiReportStatusCode != NULL) {
+ return mPeiReportStatusCode (CodeType, Value, Instance, CallerId, Data);
+ }
+
+ return EFI_SUCCESS;
+}
+
+VOID
+RtPlatformStatusCodeInitialize (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Initialize the status code listeners.
+
+Arguments:
+
+ (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
+
+Returns:
+
+ None
+
+--*/
+{
+ EFI_HOB_GUID_TYPE *GuidHob;
+ void *Pointer;
+
+ RtMemoryStatusCodeInitialize ();
+ BsDataHubStatusCodeInitialize ();
+
+ //
+ // Play any prior status codes to the data hub.
+ //
+ PlaybackStatusCodes (BsDataHubReportStatusCode);
+
+ //
+ // If PEI has a ReportStatusCode callback find it and use it before StdErr
+ // is connected.
+ //
+ mPeiReportStatusCode = NULL;
+
+ GuidHob = GetFirstGuidHob (&gEfiStatusCodeRuntimeProtocolGuid);
+ if (NULL == GuidHob) {
+ return;
+ }
+ Pointer = GET_GUID_HOB_DATA (GuidHob);
+ mPeiReportStatusCode = (REPORT_STATUS_CODE_FUNCTION) (*(UINTN *) Pointer);
+}
diff --git a/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/RtPlatformStatusCode.mbd b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/RtPlatformStatusCode.mbd
new file mode 100644
index 0000000..6459131
--- /dev/null
+++ b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/RtPlatformStatusCode.mbd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>EdkRtPlatformStatusCodeLib</BaseName>
+ <Guid>68b157b5-9534-43ff-9cd3-6705e4e1d56c</Guid>
+ <Version>0</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004 - 2005, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Created>2006-03-12 17:09</Created>
+ <Modified>2006-03-19 15:19</Modified>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/RtPlatformStatusCode.msa b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/RtPlatformStatusCode.msa
new file mode 100644
index 0000000..2225ca5
--- /dev/null
+++ b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/RtPlatformStatusCode.msa
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>EdkRtPlatformStatusCodeLib</BaseName>
+ <ModuleType>DXE_DRIVER</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>68b157b5-9534-43ff-9cd3-6705e4e1d56c</Guid>
+ <Version>0</Version>
+ <Abstract>Component description file for the PEI library.</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004 - 2005, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>0</Specification>
+ <Created>2006-03-12 17:09</Created>
+ <Updated>2006-03-19 15:19</Updated>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">EdkRtPlatformStatusCodeLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">DxeRuntimeDriverLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">ReportStatusCodeLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PrintLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">HobLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">EdkBsDataHubStatusCodeLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">EdkRtMemoryStatusCodeLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>RtPlatformStatusCode.c</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/build.xml b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/build.xml
new file mode 100644
index 0000000..34d4d75
--- /dev/null
+++ b/EdkModulePkg/Library/EdkRuntimeStatusCodeLib/RtPlatformStatusCode/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="EdkRtPlatformStatusCodeLib"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\EdkRuntimeStatusCodeLib\RtPlatformStatusCode"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="EdkRtPlatformStatusCodeLib">
+ <GenBuild baseName="EdkRtPlatformStatusCodeLib" mbdFilename="${MODULE_DIR}\RtPlatformStatusCode.mbd" msaFilename="${MODULE_DIR}\RtPlatformStatusCode.msa"/>
+ </target>
+ <target depends="EdkRtPlatformStatusCodeLib_clean" name="clean"/>
+ <target depends="EdkRtPlatformStatusCodeLib_cleanall" name="cleanall"/>
+ <target name="EdkRtPlatformStatusCodeLib_clean">
+ <OutputDirSetup baseName="EdkRtPlatformStatusCodeLib" mbdFilename="${MODULE_DIR}\RtPlatformStatusCode.mbd" msaFilename="${MODULE_DIR}\RtPlatformStatusCode.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkRtPlatformStatusCodeLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkRtPlatformStatusCodeLib_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="EdkRtPlatformStatusCodeLib_cleanall">
+ <OutputDirSetup baseName="EdkRtPlatformStatusCodeLib" mbdFilename="${MODULE_DIR}\RtPlatformStatusCode.mbd" msaFilename="${MODULE_DIR}\RtPlatformStatusCode.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkRtPlatformStatusCodeLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkRtPlatformStatusCodeLib_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**EdkRtPlatformStatusCodeLib*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/EdkScsiLib/EdkScsiLib.mbd b/EdkModulePkg/Library/EdkScsiLib/EdkScsiLib.mbd
new file mode 100644
index 0000000..18d03c2
--- /dev/null
+++ b/EdkModulePkg/Library/EdkScsiLib/EdkScsiLib.mbd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>EdkScsiLib</BaseName>
+ <Guid>46c9adef-aee6-410c-99e4-240e3af18d8b</Guid>
+ <Version>0</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Created>2006-03-12 17:09</Created>
+ <Modified>2006-03-19 15:19</Modified>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/EdkScsiLib/EdkScsiLib.msa b/EdkModulePkg/Library/EdkScsiLib/EdkScsiLib.msa
new file mode 100644
index 0000000..033d548
--- /dev/null
+++ b/EdkModulePkg/Library/EdkScsiLib/EdkScsiLib.msa
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>EdkScsiLib</BaseName>
+ <ModuleType>DXE_DRIVER</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>46c9adef-aee6-410c-99e4-240e3af18d8b</Guid>
+ <Version>0</Version>
+ <Abstract>Component description file for Scsi Dxe Library.</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>0</Specification>
+ <Created>2006-03-12 17:09</Created>
+ <Updated>2006-03-19 15:19</Updated>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">EdkScsiLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseMemoryLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>ScsiLib.c</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/EdkScsiLib/ScsiLib.c b/EdkModulePkg/Library/EdkScsiLib/ScsiLib.c
new file mode 100644
index 0000000..9a6eb67
--- /dev/null
+++ b/EdkModulePkg/Library/EdkScsiLib/ScsiLib.c
@@ -0,0 +1,651 @@
+/*++
+
+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:
+
+ ScsiLib.c
+
+Abstract:
+
+
+Revision History
+--*/
+
+
+#include <IndustryStandard/scsi.h>
+
+EFI_STATUS
+SubmitTestUnitReadyCommand (
+ IN EFI_SCSI_IO_PROTOCOL *ScsiIo,
+ IN UINT64 Timeout,
+ OUT VOID *SenseData,
+ OUT UINT8 *SenseDataLength,
+ OUT UINT8 *HostAdapterStatus,
+ OUT UINT8 *TargetStatus
+ )
+/*++
+
+Routine Description:
+ Function tests the ready status of SCSI unit.
+
+Arguments:
+ ScsiIo - A pointer to SCSI IO protocol.
+ Timeout - The length of timeout period.
+ SenseData - A pointer to output sense data.
+ SenseDataLength - The length of output sense data.
+ HostAdapterStatus - The status of Host Adapter.
+ TargetStatus - The status of the target.
+
+Returns:
+
+ Returns:
+ EFI_SUCCESS - The status of the unit is tested successfully.
+ EFI_WARN_BUFFER_TOO_SMALL - The SCSI Request Packet was executed,
+ but the entire DataBuffer could not be transferred.
+ The actual number of bytes transferred is returned
+ in InTransferLength.
+ EFI_NOT_READY - The SCSI Request Packet could not be sent because
+ there are too many SCSI Command Packets already
+ queued.
+ EFI_DEVICE_ERROR - A device error occurred while attempting to send
+ the SCSI Request Packet.
+ EFI_INVALID_PARAMETER - The contents of CommandPacket are invalid.
+ EFI_UNSUPPORTED - The command described by the SCSI Request Packet
+ is not supported by the SCSI initiator(i.e., SCSI
+ Host Controller).
+ EFI_TIMEOUT - A timeout occurred while waiting for the SCSI
+ Request Packet to execute.
+
+--*/
+{
+ EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;
+ UINT64 Lun;
+ UINT8 *Target;
+ EFI_STATUS Status;
+ UINT8 Cdb[6];
+
+ ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET));
+ ZeroMem (Cdb, 6);
+
+ CommandPacket.Timeout = Timeout;
+ CommandPacket.InDataBuffer = NULL;
+ CommandPacket.SenseData = SenseData;
+ CommandPacket.InTransferLength= 0;
+ CommandPacket.Cdb = Cdb;
+ //
+ // Fill Cdb for Test Unit Ready Command
+ //
+ ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);
+
+ Cdb[0] = EFI_SCSI_OP_TEST_UNIT_READY;
+ Cdb[1] = (UINT8) (Lun & 0xe0);
+ CommandPacket.CdbLength = (UINT8) 6;
+ CommandPacket.SenseDataLength = *SenseDataLength;
+
+ Status = ScsiIo->ExecuteSCSICommand (ScsiIo, &CommandPacket, NULL);
+
+ *HostAdapterStatus = CommandPacket.HostAdapterStatus;
+ *TargetStatus = CommandPacket.TargetStatus;
+ *SenseDataLength = CommandPacket.SenseDataLength;
+
+ return Status;
+}
+
+EFI_STATUS
+SubmitInquiryCommand (
+ IN EFI_SCSI_IO_PROTOCOL *ScsiIo,
+ IN UINT64 Timeout,
+ IN VOID *SenseData,
+ IN OUT UINT8 *SenseDataLength,
+ OUT UINT8 *HostAdapterStatus,
+ OUT UINT8 *TargetStatus,
+ IN OUT VOID *InquiryDataBuffer,
+ IN OUT UINT32 *InquiryDataLength,
+ IN BOOLEAN EnableVitalProductData
+ )
+/*++
+
+Routine Description:
+ Function to submit SCSI inquiry command.
+
+Arguments:
+ ScsiIo - A pointer to SCSI IO protocol.
+ Timeout - The length of timeout period.
+ SenseData - A pointer to output sense data.
+ SenseDataLength - The length of output sense data.
+ HostAdapterStatus - The status of Host Adapter.
+ TargetStatus - The status of the target.
+ InquiryDataBuffer - A pointer to inquiry data buffer.
+ InquiryDataLength - The length of inquiry data buffer.
+ EnableVitalProductData - Boolean to enable Vital Product Data.
+
+Returns:
+
+ Returns:
+ EFI_SUCCESS - The status of the unit is tested successfully.
+ EFI_WARN_BUFFER_TOO_SMALL - The SCSI Request Packet was executed,
+ but the entire DataBuffer could not be transferred.
+ The actual number of bytes transferred is returned
+ in TransferLength.
+ EFI_NOT_READY - The SCSI Request Packet could not be sent because
+ there are too many SCSI Command Packets already
+ queued.
+ EFI_DEVICE_ERROR - A device error occurred while attempting to send
+ the SCSI Request Packet.
+ EFI_INVALID_PARAMETER - The contents of CommandPacket are invalid.
+ EFI_UNSUPPORTED - The command described by the SCSI Request Packet
+ is not supported by the SCSI initiator(i.e., SCSI
+ Host Controller).
+ EFI_TIMEOUT - A timeout occurred while waiting for the SCSI
+ Request Packet to execute.
+
+--*/
+{
+ EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;
+ UINT64 Lun;
+ UINT8 *Target;
+ EFI_STATUS Status;
+ UINT8 Cdb[6];
+
+ ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET));
+ ZeroMem (Cdb, 6);
+
+ CommandPacket.Timeout = Timeout;
+ CommandPacket.InDataBuffer = InquiryDataBuffer;
+ CommandPacket.InTransferLength= *InquiryDataLength;
+ CommandPacket.SenseData = SenseData;
+ CommandPacket.SenseDataLength = *SenseDataLength;
+ CommandPacket.Cdb = Cdb;
+
+ ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);
+
+ Cdb[0] = EFI_SCSI_OP_INQUIRY;
+ Cdb[1] = (UINT8) (Lun & 0xe0);
+ if (EnableVitalProductData) {
+ Cdb[1] |= 0x01;
+ }
+
+ if (*InquiryDataLength > 0xff) {
+ *InquiryDataLength = 0xff;
+ }
+
+ Cdb[4] = (UINT8) (*InquiryDataLength);
+ CommandPacket.CdbLength = (UINT8) 6;
+ CommandPacket.DataDirection = EFI_SCSI_DATA_IN;
+
+ Status = ScsiIo->ExecuteSCSICommand (ScsiIo, &CommandPacket, NULL);
+
+ *HostAdapterStatus = CommandPacket.HostAdapterStatus;
+ *TargetStatus = CommandPacket.TargetStatus;
+ *SenseDataLength = CommandPacket.SenseDataLength;
+ *InquiryDataLength = CommandPacket.InTransferLength;
+
+ return Status;
+}
+
+EFI_STATUS
+SubmitModeSense10Command (
+ IN EFI_SCSI_IO_PROTOCOL *ScsiIo,
+ IN UINT64 Timeout,
+ IN VOID *SenseData,
+ IN OUT UINT8 *SenseDataLength,
+ OUT UINT8 *HostAdapterStatus,
+ OUT UINT8 *TargetStatus,
+ IN VOID *DataBuffer,
+ IN OUT UINT32 *DataLength,
+ IN UINT8 DBDField, OPTIONAL
+ IN UINT8 PageControl,
+ IN UINT8 PageCode
+ )
+/*++
+
+Routine Description:
+ Function to submit SCSI mode sense 10 command.
+
+Arguments:
+ ScsiIo - A pointer to SCSI IO protocol.
+ Timeout - The length of timeout period.
+ SenseData - A pointer to output sense data.
+ SenseDataLength - The length of output sense data.
+ HostAdapterStatus - The status of Host Adapter.
+ TargetStatus - The status of the target.
+ DataBuffer - A pointer to input data buffer.
+ DataLength - The length of input data buffer.
+ DBDField - The DBD Field (Optional).
+ PageControl - Page Control.
+ PageCode - Page code.
+
+Returns:
+
+ Returns:
+ EFI_SUCCESS - The status of the unit is tested successfully.
+ EFI_WARN_BUFFER_TOO_SMALL - The SCSI Request Packet was executed,
+ but the entire DataBuffer could not be transferred.
+ The actual number of bytes transferred is returned
+ in TransferLength.
+ EFI_NOT_READY - The SCSI Request Packet could not be sent because
+ there are too many SCSI Command Packets already
+ queued.
+ EFI_DEVICE_ERROR - A device error occurred while attempting to send
+ the SCSI Request Packet.
+ EFI_INVALID_PARAMETER - The contents of CommandPacket are invalid.
+ EFI_UNSUPPORTED - The command described by the SCSI Request Packet
+ is not supported by the SCSI initiator(i.e., SCSI
+ Host Controller).
+ EFI_TIMEOUT - A timeout occurred while waiting for the SCSI
+ Request Packet to execute.
+
+--*/
+{
+ EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;
+ UINT64 Lun;
+ UINT8 *Target;
+ EFI_STATUS Status;
+ UINT8 Cdb[10];
+
+ ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET));
+ ZeroMem (Cdb, 10);
+
+ CommandPacket.Timeout = Timeout;
+ CommandPacket.InDataBuffer = DataBuffer;
+ CommandPacket.SenseData = SenseData;
+ CommandPacket.InTransferLength= *DataLength;
+ CommandPacket.Cdb = Cdb;
+ //
+ // Fill Cdb for Mode Sense (10) Command
+ //
+ ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);
+
+ Cdb[0] = EFI_SCSI_OP_MODE_SEN10;
+ Cdb[1] = (UINT8) ((Lun & 0xe0) + ((DBDField << 3) & 0x08));
+ Cdb[2] = (UINT8) ((PageControl & 0xc0) | (PageCode & 0x3f));
+ Cdb[7] = (UINT8) (*DataLength >> 8);
+ Cdb[8] = (UINT8) (*DataLength);
+
+ CommandPacket.CdbLength = 10;
+ CommandPacket.DataDirection = EFI_SCSI_DATA_IN;
+ CommandPacket.SenseDataLength = *SenseDataLength;
+
+ Status = ScsiIo->ExecuteSCSICommand (ScsiIo, &CommandPacket, NULL);
+
+ *HostAdapterStatus = CommandPacket.HostAdapterStatus;
+ *TargetStatus = CommandPacket.TargetStatus;
+ *SenseDataLength = CommandPacket.SenseDataLength;
+ *DataLength = CommandPacket.InTransferLength;
+
+ return Status;
+}
+
+EFI_STATUS
+SubmitRequestSenseCommand (
+ IN EFI_SCSI_IO_PROTOCOL *ScsiIo,
+ IN UINT64 Timeout,
+ IN VOID *SenseData,
+ IN OUT UINT8 *SenseDataLength,
+ OUT UINT8 *HostAdapterStatus,
+ OUT UINT8 *TargetStatus
+ )
+/*++
+
+Routine Description:
+ Function to submit SCSI request sense command.
+
+Arguments:
+ ScsiIo - A pointer to SCSI IO protocol.
+ Timeout - The length of timeout period.
+ SenseData - A pointer to output sense data.
+ SenseDataLength - The length of output sense data.
+ HostAdapterStatus - The status of Host Adapter.
+ TargetStatus - The status of the target.
+
+Returns:
+
+ Returns:
+ EFI_SUCCESS - The status of the unit is tested successfully.
+ EFI_WARN_BUFFER_TOO_SMALL - The SCSI Request Packet was executed,
+ but the entire DataBuffer could not be transferred.
+ The actual number of bytes transferred is returned
+ in TransferLength.
+ EFI_NOT_READY - The SCSI Request Packet could not be sent because
+ there are too many SCSI Command Packets already
+ queued.
+ EFI_DEVICE_ERROR - A device error occurred while attempting to send
+ the SCSI Request Packet.
+ EFI_INVALID_PARAMETER - The contents of CommandPacket are invalid.
+ EFI_UNSUPPORTED - The command described by the SCSI Request Packet
+ is not supported by the SCSI initiator(i.e., SCSI
+ Host Controller).
+ EFI_TIMEOUT - A timeout occurred while waiting for the SCSI
+ Request Packet to execute.
+
+--*/
+{
+ EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;
+ UINT64 Lun;
+ UINT8 *Target;
+ EFI_STATUS Status;
+ UINT8 Cdb[6];
+
+ ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET));
+ ZeroMem (Cdb, 6);
+/*
+ if (*SenseDataLength > 0xff) {
+ *SenseDataLength = 0xff;
+ }
+*/
+ CommandPacket.Timeout = Timeout;
+ CommandPacket.InDataBuffer = SenseData;
+ CommandPacket.SenseData = NULL;
+ CommandPacket.InTransferLength= *SenseDataLength;
+ CommandPacket.Cdb = Cdb;
+ //
+ // Fill Cdb for Request Sense Command
+ //
+ ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);
+
+ Cdb[0] = EFI_SCSI_OP_REQUEST_SENSE;
+ Cdb[1] = (UINT8) (Lun & 0xe0);
+ Cdb[4] = (UINT8) (*SenseDataLength);
+
+ CommandPacket.CdbLength = (UINT8) 6;
+ CommandPacket.DataDirection = EFI_SCSI_DATA_IN;
+ CommandPacket.SenseDataLength = 0;
+
+ Status = ScsiIo->ExecuteSCSICommand (ScsiIo, &CommandPacket, NULL);
+
+ *HostAdapterStatus = CommandPacket.HostAdapterStatus;
+ *TargetStatus = CommandPacket.TargetStatus;
+ *SenseDataLength = (UINT8) CommandPacket.InTransferLength;
+
+ return Status;
+}
+
+EFI_STATUS
+SubmitReadCapacityCommand (
+ IN EFI_SCSI_IO_PROTOCOL *ScsiIo,
+ IN UINT64 Timeout,
+ IN VOID *SenseData,
+ IN OUT UINT8 *SenseDataLength,
+ OUT UINT8 *HostAdapterStatus,
+ OUT UINT8 *TargetStatus,
+ OUT VOID *DataBuffer,
+ IN OUT UINT32 *DataLength,
+ IN BOOLEAN PMI
+ )
+/*++
+
+Routine Description:
+ Function to submit read capacity command.
+
+Arguments:
+ ScsiIo - A pointer to SCSI IO protocol.
+ Timeout - The length of timeout period.
+ SenseData - A pointer to output sense data.
+ SenseDataLength - The length of output sense data.
+ HostAdapterStatus - The status of Host Adapter.
+ TargetStatus - The status of the target.
+ DataBuffer - A pointer to a data buffer.
+ DataLength - The length of data buffer.
+ PMI - Partial medium indicator.
+
+Returns:
+
+ Returns:
+ EFI_SUCCESS - The status of the unit is tested successfully.
+ EFI_WARN_BUFFER_TOO_SMALL - The SCSI Request Packet was executed,
+ but the entire DataBuffer could not be transferred.
+ The actual number of bytes transferred is returned
+ in TransferLength.
+ EFI_NOT_READY - The SCSI Request Packet could not be sent because
+ there are too many SCSI Command Packets already
+ queued.
+ EFI_DEVICE_ERROR - A device error occurred while attempting to send
+ the SCSI Request Packet.
+ EFI_INVALID_PARAMETER - The contents of CommandPacket are invalid.
+ EFI_UNSUPPORTED - The command described by the SCSI Request Packet
+ is not supported by the SCSI initiator(i.e., SCSI
+ Host Controller).
+ EFI_TIMEOUT - A timeout occurred while waiting for the SCSI
+ Request Packet to execute.
+
+--*/
+{
+ EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;
+ UINT64 Lun;
+ UINT8 *Target;
+ EFI_STATUS Status;
+ UINT8 Cdb[10];
+
+ ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET));
+ ZeroMem (Cdb, 10);
+
+ CommandPacket.Timeout = Timeout;
+ CommandPacket.InDataBuffer = DataBuffer;
+ CommandPacket.SenseData = SenseData;
+ CommandPacket.InTransferLength= *DataLength;
+ CommandPacket.Cdb = Cdb;
+ //
+ // Fill Cdb for Read Capacity Command
+ //
+ ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);
+
+ Cdb[0] = EFI_SCSI_OP_READ_CAPACITY;
+ Cdb[1] = (UINT8) (Lun & 0xe0);
+ if (!PMI) {
+ //
+ // Partial medium indicator,if PMI is FALSE, the Cdb.2 ~ Cdb.5 MUST BE ZERO.
+ //
+ ZeroMem ((Cdb + 2), 4);
+ } else {
+ Cdb[8] |= 0x01;
+ }
+
+ CommandPacket.CdbLength = 10;
+ CommandPacket.DataDirection = EFI_SCSI_DATA_IN;
+ CommandPacket.SenseDataLength = *SenseDataLength;
+
+ Status = ScsiIo->ExecuteSCSICommand (ScsiIo, &CommandPacket, NULL);
+
+ *HostAdapterStatus = CommandPacket.HostAdapterStatus;
+ *TargetStatus = CommandPacket.TargetStatus;
+ *SenseDataLength = CommandPacket.SenseDataLength;
+ *DataLength = CommandPacket.InTransferLength;
+
+ return Status;
+}
+
+EFI_STATUS
+SubmitRead10Command (
+ IN EFI_SCSI_IO_PROTOCOL *ScsiIo,
+ IN UINT64 Timeout,
+ IN VOID *SenseData,
+ IN OUT UINT8 *SenseDataLength,
+ OUT UINT8 *HostAdapterStatus,
+ OUT UINT8 *TargetStatus,
+ OUT VOID *DataBuffer,
+ IN OUT UINT32 *DataLength,
+ IN UINT32 StartLba,
+ IN UINT32 SectorSize
+ )
+/*++
+
+Routine Description:
+ Function to submit read 10 command.
+
+Arguments:
+ ScsiIo - A pointer to SCSI IO protocol.
+ Timeout - The length of timeout period.
+ SenseData - A pointer to output sense data.
+ SenseDataLength - The length of output sense data.
+ HostAdapterStatus - The status of Host Adapter.
+ TargetStatus - The status of the target.
+ DataBuffer - A pointer to a data buffer.
+ DataLength - The length of data buffer.
+ StartLba - The start address of LBA.
+ SectorSize - The sector size.
+
+Returns:
+
+ Returns:
+ EFI_SUCCESS - The status of the unit is tested successfully.
+ EFI_WARN_BUFFER_TOO_SMALL - The SCSI Request Packet was executed,
+ but the entire DataBuffer could not be transferred.
+ The actual number of bytes transferred is returned
+ in TransferLength.
+ EFI_NOT_READY - The SCSI Request Packet could not be sent because
+ there are too many SCSI Command Packets already
+ queued.
+ EFI_DEVICE_ERROR - A device error occurred while attempting to send
+ the SCSI Request Packet.
+ EFI_INVALID_PARAMETER - The contents of CommandPacket are invalid.
+ EFI_UNSUPPORTED - The command described by the SCSI Request Packet
+ is not supported by the SCSI initiator(i.e., SCSI
+ Host Controller).
+ EFI_TIMEOUT - A timeout occurred while waiting for the SCSI
+ Request Packet to execute.
+
+--*/
+{
+ EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;
+ UINT64 Lun;
+ UINT8 *Target;
+ EFI_STATUS Status;
+ UINT8 Cdb[10];
+
+ ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET));
+ ZeroMem (Cdb, 10);
+
+ CommandPacket.Timeout = Timeout;
+ CommandPacket.InDataBuffer = DataBuffer;
+ CommandPacket.SenseData = SenseData;
+ CommandPacket.InTransferLength= *DataLength;
+ CommandPacket.Cdb = Cdb;
+ //
+ // Fill Cdb for Read (10) Command
+ //
+ ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);
+
+ Cdb[0] = EFI_SCSI_OP_READ10;
+ Cdb[1] = (UINT8) (Lun & 0xe0);
+ Cdb[2] = (UINT8) (StartLba >> 24);
+ Cdb[3] = (UINT8) (StartLba >> 16);
+ Cdb[4] = (UINT8) (StartLba >> 8);
+ Cdb[5] = (UINT8) StartLba;
+ Cdb[7] = (UINT8) (SectorSize >> 8);
+ Cdb[8] = (UINT8) SectorSize;
+
+ CommandPacket.CdbLength = 10;
+ CommandPacket.DataDirection = EFI_SCSI_DATA_IN;
+ CommandPacket.SenseDataLength = *SenseDataLength;
+
+ Status = ScsiIo->ExecuteSCSICommand (ScsiIo, &CommandPacket, NULL);
+
+ *HostAdapterStatus = CommandPacket.HostAdapterStatus;
+ *TargetStatus = CommandPacket.TargetStatus;
+ *SenseDataLength = CommandPacket.SenseDataLength;
+ *DataLength = CommandPacket.InTransferLength;
+
+ return Status;
+}
+
+EFI_STATUS
+SubmitWrite10Command (
+ IN EFI_SCSI_IO_PROTOCOL *ScsiIo,
+ IN UINT64 Timeout,
+ IN VOID *SenseData,
+ IN OUT UINT8 *SenseDataLength,
+ OUT UINT8 *HostAdapterStatus,
+ OUT UINT8 *TargetStatus,
+ OUT VOID *DataBuffer,
+ IN OUT UINT32 *DataLength,
+ IN UINT32 StartLba,
+ IN UINT32 SectorSize
+ )
+/*++
+
+Routine Description:
+ Function to submit SCSI write 10 command.
+
+Arguments:
+ ScsiIo - A pointer to SCSI IO protocol.
+ Timeout - The length of timeout period.
+ SenseData - A pointer to output sense data.
+ SenseDataLength - The length of output sense data.
+ HostAdapterStatus - The status of Host Adapter.
+ TargetStatus - The status of the target.
+ DataBuffer - A pointer to a data buffer.
+ DataLength - The length of data buffer.
+ StartLba - The start address of LBA.
+ SectorSize - The sector size.
+
+Returns:
+
+ Returns:
+ EFI_SUCCESS - The status of the unit is tested successfully.
+ EFI_WARN_BUFFER_TOO_SMALL - The SCSI Request Packet was executed,
+ but the entire DataBuffer could not be transferred.
+ The actual number of bytes transferred is returned
+ in InTransferLength.
+ EFI_NOT_READY - The SCSI Request Packet could not be sent because
+ there are too many SCSI Command Packets already
+ queued.
+ EFI_DEVICE_ERROR - A device error occurred while attempting to send
+ the SCSI Request Packet.
+ EFI_INVALID_PARAMETER - The contents of CommandPacket are invalid.
+ EFI_UNSUPPORTED - The command described by the SCSI Request Packet
+ is not supported by the SCSI initiator(i.e., SCSI
+ Host Controller).
+ EFI_TIMEOUT - A timeout occurred while waiting for the SCSI
+ Request Packet to execute.
+
+--*/
+{
+ EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;
+ UINT64 Lun;
+ UINT8 *Target;
+ EFI_STATUS Status;
+ UINT8 Cdb[10];
+
+ ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET));
+ ZeroMem (Cdb, 10);
+
+ CommandPacket.Timeout = Timeout;
+ CommandPacket.InDataBuffer = DataBuffer;
+ CommandPacket.SenseData = SenseData;
+ CommandPacket.InTransferLength= *DataLength;
+ CommandPacket.Cdb = Cdb;
+ //
+ // Fill Cdb for Write (10) Command
+ //
+ ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);
+
+ Cdb[0] = EFI_SCSI_OP_WRITE10;
+ Cdb[1] = (UINT8) (Lun & 0xe0);
+ Cdb[2] = (UINT8) (StartLba >> 24);
+ Cdb[3] = (UINT8) (StartLba >> 16);
+ Cdb[4] = (UINT8) (StartLba >> 8);
+ Cdb[5] = (UINT8) StartLba;
+ Cdb[7] = (UINT8) (SectorSize >> 8);
+ Cdb[8] = (UINT8) SectorSize;
+
+ CommandPacket.CdbLength = 10;
+ CommandPacket.DataDirection = EFI_SCSI_DATA_OUT;
+ CommandPacket.SenseDataLength = *SenseDataLength;
+
+ Status = ScsiIo->ExecuteSCSICommand (ScsiIo, &CommandPacket, NULL);
+
+ *HostAdapterStatus = CommandPacket.HostAdapterStatus;
+ *TargetStatus = CommandPacket.TargetStatus;
+ *SenseDataLength = CommandPacket.SenseDataLength;
+ *DataLength = CommandPacket.InTransferLength;
+
+ return Status;
+}
diff --git a/EdkModulePkg/Library/EdkScsiLib/build.xml b/EdkModulePkg/Library/EdkScsiLib/build.xml
new file mode 100644
index 0000000..511cf6f
--- /dev/null
+++ b/EdkModulePkg/Library/EdkScsiLib/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="EdkScsiLib"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\EdkScsiLib"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="EdkScsiLib">
+ <GenBuild baseName="EdkScsiLib" mbdFilename="${MODULE_DIR}\EdkScsiLib.mbd" msaFilename="${MODULE_DIR}\EdkScsiLib.msa"/>
+ </target>
+ <target depends="EdkScsiLib_clean" name="clean"/>
+ <target depends="EdkScsiLib_cleanall" name="cleanall"/>
+ <target name="EdkScsiLib_clean">
+ <OutputDirSetup baseName="EdkScsiLib" mbdFilename="${MODULE_DIR}\EdkScsiLib.mbd" msaFilename="${MODULE_DIR}\EdkScsiLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkScsiLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkScsiLib_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="EdkScsiLib_cleanall">
+ <OutputDirSetup baseName="EdkScsiLib" mbdFilename="${MODULE_DIR}\EdkScsiLib.mbd" msaFilename="${MODULE_DIR}\EdkScsiLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkScsiLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkScsiLib_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**EdkScsiLib*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/EdkUefiDebugLibConOut/DebugLib.c b/EdkModulePkg/Library/EdkUefiDebugLibConOut/DebugLib.c
new file mode 100644
index 0000000..911002e
--- /dev/null
+++ b/EdkModulePkg/Library/EdkUefiDebugLibConOut/DebugLib.c
@@ -0,0 +1,255 @@
+/*++
+
+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:
+
+ DebugLib.c
+
+Abstract:
+
+ UEFI Debug Library that uses PrintLib to send messages to CONOUT
+
+--*/
+
+static BOOLEAN mDebugLevelInstalled = FALSE;
+static EFI_DEBUG_LEVEL_PROTOCOL mDebugLevel = { 0 };
+
+EFI_STATUS
+DebugLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+
+Arguments:
+
+Returns:
+
+--*/
+{
+ EFI_STATUS Status;
+
+ //
+ // Initialize Debug Level Protocol
+ //
+ mDebugLevel.DebugLevel = PcdGet32(PcdDebugPrintErrorLevel);
+
+ //
+ // Install Debug Level Protocol
+ //
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &ImageHandle,
+ &gEfiDebugLevelProtocolGuid, &mDebugLevel,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Set flag to show that the Debug Level Protocol has been installed
+ //
+ mDebugLevelInstalled = TRUE;
+
+ return EFI_SUCCESS;
+}
+
+VOID
+EFIAPI
+DebugPrint (
+ IN UINTN ErrorLevel,
+ IN CHAR8 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Wrapper for DebugVPrint ()
+
+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
+
+--*/
+{
+ CHAR16 Buffer[0x100];
+ CHAR16 UnicodeBuffer[0x100];
+ UINT32 Index;
+ VA_LIST Marker;
+
+ //
+ // Check to see if CONOUT is avilable
+ //
+ if (gST->ConOut == NULL) {
+ return;
+ }
+
+ //
+ // Check driver Debug Level value and global debug level
+ //
+ if (mDebugLevelInstalled) {
+ if ((ErrorLevel & mDebugLevel.DebugLevel) == 0) {
+ return;
+ }
+ } else {
+ if ((ErrorLevel & PcdGet32(PcdDebugPrintErrorLevel)) == 0) {
+ return;
+ }
+ }
+
+ //
+ // BUGBUG: Need print that take CHAR8 Format and returns CHAR16 Buffer
+ //
+ for (Index = 0; Format[Index] != 0; Index++) {
+ UnicodeBuffer[Index] = Format[Index];
+ }
+ UnicodeBuffer[Index] = Format[Index];
+
+ //
+ // Convert the DEBUG() message to a Unicode String
+ //
+ VA_START (Marker, Format);
+ UnicodeVSPrint (Buffer, sizeof (Buffer), UnicodeBuffer, Marker);
+ VA_END (Marker);
+
+ //
+ // Send the print string to the Standard Error device
+ //
+ gST->ConOut->OutputString (gST->ConOut, Buffer);
+}
+
+VOID
+EFIAPI
+DebugAssert (
+ 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 CpuBreakpoint ().
+
+ 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
+
+--*/
+{
+ CHAR16 Buffer[0x100];
+
+ //
+ // Check to see if CONOUT is avilable
+ //
+ if (gST->ConOut == NULL) {
+ return;
+ }
+
+ //
+ // Generate the ASSERT() message in Unicode format
+ //
+ UnicodeSPrint (Buffer, sizeof (Buffer), (CHAR16 *)L"ASSERT %s(%d): %s\n", FileName, LineNumber, Description);
+
+ //
+ // Send the print string to the Standard Error device
+ //
+ gST->ConOut->OutputString (gST->ConOut, Buffer);
+
+ //
+ // Put break point in module that contained the error.
+ //
+ CpuBreakpoint ();
+}
+
+/**
+ 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
+ )
+{
+// SetMem (Buffer, Length, PcdGet8(PcdDebugClearMemoryValue));
+ SetMem (Buffer, Length, 0xAF);
+ return Buffer;
+}
+
+BOOLEAN
+EFIAPI
+DebugAssertEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
+}
+
+BOOLEAN
+EFIAPI
+DebugPrintEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
+}
+
+BOOLEAN
+EFIAPI
+DebugCodeEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
+}
+
+BOOLEAN
+EFIAPI
+DebugClearMemoryEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
+}
diff --git a/EdkModulePkg/Library/EdkUefiDebugLibConOut/EdkUefiDebugLibConOut.mbd b/EdkModulePkg/Library/EdkUefiDebugLibConOut/EdkUefiDebugLibConOut.mbd
new file mode 100644
index 0000000..08bc04d
--- /dev/null
+++ b/EdkModulePkg/Library/EdkUefiDebugLibConOut/EdkUefiDebugLibConOut.mbd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>EdkUefiDebugLibConOut</BaseName>
+ <Guid>7293fe0b-1fff-4f8f-b808-10cb55f6a174</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Created>2006-03-12 17:09</Created>
+ <Modified>2006-03-31 13:14</Modified>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/EdkUefiDebugLibConOut/EdkUefiDebugLibConOut.msa b/EdkModulePkg/Library/EdkUefiDebugLibConOut/EdkUefiDebugLibConOut.msa
new file mode 100644
index 0000000..874c873
--- /dev/null
+++ b/EdkModulePkg/Library/EdkUefiDebugLibConOut/EdkUefiDebugLibConOut.msa
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>EdkUefiDebugLibConOut</BaseName>
+ <ModuleType>DXE_DRIVER</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>7293fe0b-1fff-4f8f-b808-10cb55f6a174</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Abstract>Debug Library for UEFI drivers</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>EFI_SPECIFICATION_VERSION 0x00000000</Specification>
+ <Created>2006-03-12 17:09</Created>
+ <Updated>2006-03-31 13:14</Updated>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PrintLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PcdLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseMemoryLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>DebugLib.c</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+ <Protocols>
+ <Protocol Usage="ALWAYS_PRODUCED">DebugLevel</Protocol>
+ </Protocols>
+ <Externs>
+ <Extern>
+ <Constructor>DebugLibConstructor</Constructor>
+ </Extern>
+ </Externs>
+ <PCDs>
+ <PcdData ItemType="FIXED_AT_BUILD">
+ <C_Name>PcdDebugPropertyMask</C_Name>
+ <Token>0x00000005</Token>
+ <DatumType>UINT8</DatumType>
+ </PcdData>
+ <PcdData ItemType="PATCHABLE_IN_MODULE">
+ <C_Name>PcdDebugPrintErrorLevel</C_Name>
+ <Token>0x00000006</Token>
+ <DatumType>UINT32</DatumType>
+ </PcdData>
+ </PCDs>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/EdkUefiDebugLibConOut/build.xml b/EdkModulePkg/Library/EdkUefiDebugLibConOut/build.xml
new file mode 100644
index 0000000..4a7cb25
--- /dev/null
+++ b/EdkModulePkg/Library/EdkUefiDebugLibConOut/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="EdkUefiDebugLibConOut"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\EdkUefiDebugLibConOut"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="EdkUefiDebugLibConOut">
+ <GenBuild baseName="EdkUefiDebugLibConOut" mbdFilename="${MODULE_DIR}\EdkUefiDebugLibConOut.mbd" msaFilename="${MODULE_DIR}\EdkUefiDebugLibConOut.msa"/>
+ </target>
+ <target depends="EdkUefiDebugLibConOut_clean" name="clean"/>
+ <target depends="EdkUefiDebugLibConOut_cleanall" name="cleanall"/>
+ <target name="EdkUefiDebugLibConOut_clean">
+ <OutputDirSetup baseName="EdkUefiDebugLibConOut" mbdFilename="${MODULE_DIR}\EdkUefiDebugLibConOut.mbd" msaFilename="${MODULE_DIR}\EdkUefiDebugLibConOut.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkUefiDebugLibConOut_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkUefiDebugLibConOut_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="EdkUefiDebugLibConOut_cleanall">
+ <OutputDirSetup baseName="EdkUefiDebugLibConOut" mbdFilename="${MODULE_DIR}\EdkUefiDebugLibConOut.mbd" msaFilename="${MODULE_DIR}\EdkUefiDebugLibConOut.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkUefiDebugLibConOut_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkUefiDebugLibConOut_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**EdkUefiDebugLibConOut*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/EdkUefiDebugLibStdErr/DebugLib.c b/EdkModulePkg/Library/EdkUefiDebugLibStdErr/DebugLib.c
new file mode 100644
index 0000000..1074d6a
--- /dev/null
+++ b/EdkModulePkg/Library/EdkUefiDebugLibStdErr/DebugLib.c
@@ -0,0 +1,255 @@
+/*++
+
+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:
+
+ DebugLib.c
+
+Abstract:
+
+ UEFI Debug Library that uses PrintLib to send messages to STDERR
+
+--*/
+
+static BOOLEAN mDebugLevelInstalled = FALSE;
+static EFI_DEBUG_LEVEL_PROTOCOL mDebugLevel = { 0 };
+
+EFI_STATUS
+DebugLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+
+Arguments:
+
+Returns:
+
+--*/
+{
+ EFI_STATUS Status;
+
+ //
+ // Initialize Debug Level Protocol
+ //
+ mDebugLevel.DebugLevel = PcdGet32(PcdDebugPrintErrorLevel);
+
+ //
+ // Install Debug Level Protocol
+ //
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &ImageHandle,
+ &gEfiDebugLevelProtocolGuid, &mDebugLevel,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Set flag to show that the Debug Level Protocol has been installed
+ //
+ mDebugLevelInstalled = TRUE;
+
+ return EFI_SUCCESS;
+}
+
+VOID
+EFIAPI
+DebugPrint (
+ IN UINTN ErrorLevel,
+ IN CHAR8 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Wrapper for DebugVPrint ()
+
+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
+
+--*/
+{
+ CHAR16 Buffer[0x100];
+ CHAR16 UnicodeBuffer[0x100];
+ UINT32 Index;
+ VA_LIST Marker;
+
+ //
+ // Check to see if STDERR is avilable
+ //
+ if (gST->StdErr == NULL) {
+ return;
+ }
+
+ //
+ // Check driver Debug Level value and global debug level
+ //
+ if (mDebugLevelInstalled) {
+ if ((ErrorLevel & mDebugLevel.DebugLevel) == 0) {
+ return;
+ }
+ } else {
+ if ((ErrorLevel & PcdGet32(PcdDebugPrintErrorLevel)) == 0) {
+ return;
+ }
+ }
+
+ //
+ // BUGBUG: Need print that take CHAR8 Format and returns CHAR16 Buffer
+ //
+ for (Index = 0; Format[Index] != 0; Index++) {
+ UnicodeBuffer[Index] = Format[Index];
+ }
+ UnicodeBuffer[Index] = Format[Index];
+
+ //
+ // Convert the DEBUG() message to a Unicode String
+ //
+ VA_START (Marker, Format);
+ UnicodeVSPrint (Buffer, sizeof (Buffer), UnicodeBuffer, Marker);
+ VA_END (Marker);
+
+ //
+ // Send the print string to the Standard Error device
+ //
+ gST->StdErr->OutputString (gST->StdErr, Buffer);
+}
+
+VOID
+EFIAPI
+DebugAssert (
+ 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 CpuBreakpoint ().
+
+ 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
+
+--*/
+{
+ CHAR16 Buffer[0x100];
+
+ //
+ // Check to see if STDERR is avilable
+ //
+ if (gST->StdErr == NULL) {
+ return;
+ }
+
+ //
+ // Generate the ASSERT() message in Unicode format
+ //
+ UnicodeSPrint (Buffer, sizeof (Buffer), (CHAR16 *)L"ASSERT %s(%d): %s\n", FileName, LineNumber, Description);
+
+ //
+ // Send the print string to the Standard Error device
+ //
+ gST->StdErr->OutputString (gST->StdErr, Buffer);
+
+ //
+ // Put break point in module that contained the error.
+ //
+ CpuBreakpoint ();
+}
+
+/**
+ 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
+ )
+{
+// SetMem (Buffer, Length, PcdGet8(PcdDebugClearMemoryValue));
+ SetMem (Buffer, Length, 0xAF);
+ return Buffer;
+}
+
+BOOLEAN
+EFIAPI
+DebugAssertEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
+}
+
+BOOLEAN
+EFIAPI
+DebugPrintEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
+}
+
+BOOLEAN
+EFIAPI
+DebugCodeEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
+}
+
+BOOLEAN
+EFIAPI
+DebugClearMemoryEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
+}
diff --git a/EdkModulePkg/Library/EdkUefiDebugLibStdErr/EdkUefiDebugLibStdErr.mbd b/EdkModulePkg/Library/EdkUefiDebugLibStdErr/EdkUefiDebugLibStdErr.mbd
new file mode 100644
index 0000000..833b2ee
--- /dev/null
+++ b/EdkModulePkg/Library/EdkUefiDebugLibStdErr/EdkUefiDebugLibStdErr.mbd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>EdkUefiDebugLibStdErr</BaseName>
+ <Guid>8b9968e0-c76b-4b57-aec4-24e17fe602c0</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Created>2006-03-12 17:09</Created>
+ <Modified>2006-03-31 13:14</Modified>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/EdkUefiDebugLibStdErr/EdkUefiDebugLibStdErr.msa b/EdkModulePkg/Library/EdkUefiDebugLibStdErr/EdkUefiDebugLibStdErr.msa
new file mode 100644
index 0000000..3c5fc2b
--- /dev/null
+++ b/EdkModulePkg/Library/EdkUefiDebugLibStdErr/EdkUefiDebugLibStdErr.msa
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>EdkUefiDebugLibStdErr</BaseName>
+ <ModuleType>DXE_DRIVER</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>8b9968e0-c76b-4b57-aec4-24e17fe602c0</Guid>
+ <Version>EDK_RELEASE_VERSION 0x00020000</Version>
+ <Abstract>Debug Library for UEFI drivers</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>EFI_SPECIFICATION_VERSION 0x00000000</Specification>
+ <Created>2006-03-12 17:09</Created>
+ <Updated>2006-03-31 13:14</Updated>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">DebugLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PrintLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">PcdLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">UefiBootServicesTableLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseMemoryLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>DebugLib.c</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+ <Protocols>
+ <Protocol Usage="ALWAYS_PRODUCED">DebugLevel</Protocol>
+ </Protocols>
+ <Externs>
+ <Extern>
+ <Constructor>DebugLibConstructor</Constructor>
+ </Extern>
+ </Externs>
+ <PCDs>
+ <PcdData ItemType="FIXED_AT_BUILD">
+ <C_Name>PcdDebugPropertyMask</C_Name>
+ <Token>0x00000005</Token>
+ <DatumType>UINT8</DatumType>
+ </PcdData>
+ <PcdData ItemType="PATCHABLE_IN_MODULE">
+ <C_Name>PcdDebugPrintErrorLevel</C_Name>
+ <Token>0x00000006</Token>
+ <DatumType>UINT32</DatumType>
+ </PcdData>
+ </PCDs>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/EdkUefiDebugLibStdErr/build.xml b/EdkModulePkg/Library/EdkUefiDebugLibStdErr/build.xml
new file mode 100644
index 0000000..1479581
--- /dev/null
+++ b/EdkModulePkg/Library/EdkUefiDebugLibStdErr/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="EdkUefiDebugLibStdErr"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\EdkUefiDebugLibStdErr"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="EdkUefiDebugLibStdErr">
+ <GenBuild baseName="EdkUefiDebugLibStdErr" mbdFilename="${MODULE_DIR}\EdkUefiDebugLibStdErr.mbd" msaFilename="${MODULE_DIR}\EdkUefiDebugLibStdErr.msa"/>
+ </target>
+ <target depends="EdkUefiDebugLibStdErr_clean" name="clean"/>
+ <target depends="EdkUefiDebugLibStdErr_cleanall" name="cleanall"/>
+ <target name="EdkUefiDebugLibStdErr_clean">
+ <OutputDirSetup baseName="EdkUefiDebugLibStdErr" mbdFilename="${MODULE_DIR}\EdkUefiDebugLibStdErr.mbd" msaFilename="${MODULE_DIR}\EdkUefiDebugLibStdErr.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkUefiDebugLibStdErr_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkUefiDebugLibStdErr_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="EdkUefiDebugLibStdErr_cleanall">
+ <OutputDirSetup baseName="EdkUefiDebugLibStdErr" mbdFilename="${MODULE_DIR}\EdkUefiDebugLibStdErr.mbd" msaFilename="${MODULE_DIR}\EdkUefiDebugLibStdErr.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkUefiDebugLibStdErr_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkUefiDebugLibStdErr_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**EdkUefiDebugLibStdErr*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/EdkUsbLib/EdkUsbLib.mbd b/EdkModulePkg/Library/EdkUsbLib/EdkUsbLib.mbd
new file mode 100644
index 0000000..79fa4b1
--- /dev/null
+++ b/EdkModulePkg/Library/EdkUsbLib/EdkUsbLib.mbd
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleBuildDescription xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MbdLibHeader>
+ <BaseName>EdkUsbLib</BaseName>
+ <Guid>87eb5df9-722a-4241-ad7f-370d0b3a56d7</Guid>
+ <Version>0</Version>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Created>2006-03-12 17:09</Created>
+ <Modified>2006-03-19 15:19</Modified>
+ </MbdLibHeader>
+</LibraryModuleBuildDescription>
diff --git a/EdkModulePkg/Library/EdkUsbLib/EdkUsbLib.msa b/EdkModulePkg/Library/EdkUsbLib/EdkUsbLib.msa
new file mode 100644
index 0000000..f2aa74b
--- /dev/null
+++ b/EdkModulePkg/Library/EdkUsbLib/EdkUsbLib.msa
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<LibraryModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd">
+ <MsaLibHeader>
+ <BaseName>EdkUsbLib</BaseName>
+ <ModuleType>DXE_DRIVER</ModuleType>
+ <ComponentType>LIBRARY</ComponentType>
+ <Guid>87eb5df9-722a-4241-ad7f-370d0b3a56d7</Guid>
+ <Version>0</Version>
+ <Abstract>Component description file for UsbDxeLib module</Abstract>
+ <Description>FIX ME!</Description>
+ <Copyright>Copyright (c) 2004-2006, Intel Corporation</Copyright>
+ <License>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ </License>
+ <Specification>0</Specification>
+ <Created>2006-03-12 17:09</Created>
+ <Updated>2006-03-19 15:19</Updated>
+ </MsaLibHeader>
+ <LibraryClassDefinitions>
+ <LibraryClass Usage="ALWAYS_PRODUCED">EdkUsbLib</LibraryClass>
+ <LibraryClass Usage="ALWAYS_CONSUMED">BaseMemoryLib</LibraryClass>
+ </LibraryClassDefinitions>
+ <SourceFiles>
+ <Filename>UsbDxelib.c</Filename>
+ <Filename>hid.c</Filename>
+ </SourceFiles>
+ <Includes>
+ <PackageName>MdePkg</PackageName>
+ <PackageName>EdkModulePkg</PackageName>
+ </Includes>
+</LibraryModuleSurfaceArea>
diff --git a/EdkModulePkg/Library/EdkUsbLib/UsbDxeLib.c b/EdkModulePkg/Library/EdkUsbLib/UsbDxeLib.c
new file mode 100644
index 0000000..8bbd089
--- /dev/null
+++ b/EdkModulePkg/Library/EdkUsbLib/UsbDxeLib.c
@@ -0,0 +1,699 @@
+/*++
+
+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:
+
+ UsbDxeLib.c
+
+ Abstract:
+
+ Common Dxe Libarary for USB
+
+ Revision History
+
+--*/
+
+//
+// Get Device Descriptor
+//
+EFI_STATUS
+UsbGetDescriptor (
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINT16 Value,
+ IN UINT16 Index,
+ IN UINT16 DescriptorLength,
+ OUT VOID *Descriptor,
+ OUT UINT32 *Status
+ )
+/*++
+
+Routine Description:
+
+ Usb Get Descriptor
+
+Arguments:
+
+ UsbIo - EFI_USB_IO_PROTOCOL
+ Value - Device Request Value
+ Index - Device Request Index
+ DescriptorLength - Descriptor Length
+ Descriptor - Descriptor buffer to contain result
+ Status - Transfer Status
+Returns:
+ EFI_INVALID_PARAMETER - Parameter is error
+ EFI_SUCCESS - Success
+ EFI_TIMEOUT - Device has no response
+
+--*/
+{
+ EFI_USB_DEVICE_REQUEST DevReq;
+
+ if (UsbIo == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
+
+ DevReq.RequestType = USB_DEV_GET_DESCRIPTOR_REQ_TYPE;
+ DevReq.Request = USB_DEV_GET_DESCRIPTOR;
+ DevReq.Value = Value;
+ DevReq.Index = Index;
+ DevReq.Length = DescriptorLength;
+
+ return UsbIo->UsbControlTransfer (
+ UsbIo,
+ &DevReq,
+ EfiUsbDataIn,
+ TIMEOUT_VALUE,
+ Descriptor,
+ DescriptorLength,
+ Status
+ );
+}
+//
+// Set Device Descriptor
+//
+EFI_STATUS
+UsbSetDescriptor (
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINT16 Value,
+ IN UINT16 Index,
+ IN UINT16 DescriptorLength,
+ IN VOID *Descriptor,
+ OUT UINT32 *Status
+ )
+/*++
+
+Routine Description:
+
+ Usb Set Descriptor
+
+Arguments:
+
+ UsbIo - EFI_USB_IO_PROTOCOL
+ Value - Device Request Value
+ Index - Device Request Index
+ DescriptorLength - Descriptor Length
+ Descriptor - Descriptor buffer to set
+ Status - Transfer Status
+Returns:
+ EFI_INVALID_PARAMETER - Parameter is error
+ EFI_SUCCESS - Success
+ EFI_TIMEOUT - Device has no response
+
+--*/
+{
+ EFI_USB_DEVICE_REQUEST DevReq;
+
+ if (UsbIo == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
+
+ DevReq.RequestType = USB_DEV_SET_DESCRIPTOR_REQ_TYPE;
+ DevReq.Request = USB_DEV_SET_DESCRIPTOR;
+ DevReq.Value = Value;
+ DevReq.Index = Index;
+ DevReq.Length = DescriptorLength;
+
+ return UsbIo->UsbControlTransfer (
+ UsbIo,
+ &DevReq,
+ EfiUsbDataOut,
+ TIMEOUT_VALUE,
+ Descriptor,
+ DescriptorLength,
+ Status
+ );
+}
+
+//
+// Get device Interface
+//
+EFI_STATUS
+UsbGetDeviceInterface (
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINT16 Index,
+ OUT UINT8 *AltSetting,
+ OUT UINT32 *Status
+ )
+/*++
+
+Routine Description:
+
+ Usb Get Device Interface
+
+Arguments:
+
+ UsbIo - EFI_USB_IO_PROTOCOL
+ Index - Interface index value
+ AltSetting - Alternate setting
+ Status - Trasnsfer status
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Parameter is error
+ EFI_SUCCESS - Success
+ EFI_TIMEOUT - Device has no response
+
+
+--*/
+{
+ EFI_USB_DEVICE_REQUEST DevReq;
+
+ if (UsbIo == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
+
+ DevReq.RequestType = USB_DEV_GET_INTERFACE_REQ_TYPE;
+ DevReq.Request = USB_DEV_GET_INTERFACE;
+ DevReq.Index = Index;
+ DevReq.Length = 1;
+
+ return UsbIo->UsbControlTransfer (
+ UsbIo,
+ &DevReq,
+ EfiUsbDataIn,
+ TIMEOUT_VALUE,
+ AltSetting,
+ 1,
+ Status
+ );
+}
+//
+// Set device interface
+//
+EFI_STATUS
+UsbSetDeviceInterface (
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINT16 InterfaceNo,
+ IN UINT16 AltSetting,
+ OUT UINT32 *Status
+ )
+/*++
+
+Routine Description:
+
+ Usb Set Device Interface
+
+Arguments:
+
+ UsbIo - EFI_USB_IO_PROTOCOL
+ InterfaceNo - Interface Number
+ AltSetting - Alternate setting
+ Status - Trasnsfer status
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Parameter is error
+ EFI_SUCCESS - Success
+ EFI_TIMEOUT - Device has no response
+
+--*/
+{
+ EFI_USB_DEVICE_REQUEST DevReq;
+
+ if (UsbIo == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
+
+ DevReq.RequestType = USB_DEV_SET_INTERFACE_REQ_TYPE;
+ DevReq.Request = USB_DEV_SET_INTERFACE;
+ DevReq.Value = AltSetting;
+ DevReq.Index = InterfaceNo;
+
+
+ return UsbIo->UsbControlTransfer (
+ UsbIo,
+ &DevReq,
+ EfiUsbNoData,
+ TIMEOUT_VALUE,
+ NULL,
+ 0,
+ Status
+ );
+}
+//
+// Get device configuration
+//
+EFI_STATUS
+UsbGetDeviceConfiguration (
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ OUT UINT8 *ConfigValue,
+ OUT UINT32 *Status
+ )
+/*++
+
+Routine Description:
+
+ Usb Get Device Configuration
+
+Arguments:
+
+ UsbIo - EFI_USB_IO_PROTOCOL
+ ConfigValue - Config Value
+ Status - Transfer Status
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Parameter is error
+ EFI_SUCCESS - Success
+ EFI_TIMEOUT - Device has no response
+
+--*/
+{
+ EFI_USB_DEVICE_REQUEST DevReq;
+
+ if (UsbIo == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
+
+ DevReq.RequestType = USB_DEV_GET_CONFIGURATION_REQ_TYPE;
+ DevReq.Request = USB_DEV_GET_CONFIGURATION;
+ DevReq.Length = 1;
+
+ return UsbIo->UsbControlTransfer (
+ UsbIo,
+ &DevReq,
+ EfiUsbDataIn,
+ TIMEOUT_VALUE,
+ ConfigValue,
+ 1,
+ Status
+ );
+}
+//
+// Set device configuration
+//
+EFI_STATUS
+UsbSetDeviceConfiguration (
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINT16 Value,
+ OUT UINT32 *Status
+ )
+/*++
+
+Routine Description:
+
+ Usb Set Device Configuration
+
+Arguments:
+
+ UsbIo - EFI_USB_IO_PROTOCOL
+ Value - Configuration Value to set
+ Status - Transfer status
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Parameter is error
+ EFI_SUCCESS - Success
+ EFI_TIMEOUT - Device has no response
+
+--*/
+{
+ EFI_USB_DEVICE_REQUEST DevReq;
+
+ if (UsbIo == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
+
+ DevReq.RequestType = USB_DEV_SET_CONFIGURATION_REQ_TYPE;
+ DevReq.Request = USB_DEV_SET_CONFIGURATION;
+ DevReq.Value = Value;
+
+ return UsbIo->UsbControlTransfer (
+ UsbIo,
+ &DevReq,
+ EfiUsbNoData,
+ TIMEOUT_VALUE,
+ NULL,
+ 0,
+ Status
+ );
+}
+//
+// Set Device Feature
+//
+EFI_STATUS
+UsbSetDeviceFeature (
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN EFI_USB_RECIPIENT Recipient,
+ IN UINT16 Value,
+ IN UINT16 Target,
+ OUT UINT32 *Status
+ )
+/*++
+
+Routine Description:
+
+ Usb Set Device Feature
+
+Arguments:
+
+ UsbIo - EFI_USB_IO_PROTOCOL
+ Recipient - Interface/Device/Endpoint
+ Value - Request value
+ Target - Request Index
+ Status - Transfer status
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Parameter is error
+ EFI_SUCCESS - Success
+ EFI_TIMEOUT - Device has no response
+
+--*/
+{
+ EFI_USB_DEVICE_REQUEST DevReq;
+
+ if (UsbIo == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
+
+ switch (Recipient) {
+
+ case EfiUsbDevice:
+ DevReq.RequestType = 0x00;
+ break;
+
+ case EfiUsbInterface:
+ DevReq.RequestType = 0x01;
+ break;
+
+ case EfiUsbEndpoint:
+ DevReq.RequestType = 0x02;
+ break;
+ }
+ //
+ // Fill device request, see USB1.1 spec
+ //
+ DevReq.Request = USB_DEV_SET_FEATURE;
+ DevReq.Value = Value;
+ DevReq.Index = Target;
+
+
+ return UsbIo->UsbControlTransfer (
+ UsbIo,
+ &DevReq,
+ EfiUsbNoData,
+ TIMEOUT_VALUE,
+ NULL,
+ 0,
+ Status
+ );
+}
+//
+// Clear Device Feature
+//
+EFI_STATUS
+UsbClearDeviceFeature (
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN EFI_USB_RECIPIENT Recipient,
+ IN UINT16 Value,
+ IN UINT16 Target,
+ OUT UINT32 *Status
+ )
+/*++
+
+Routine Description:
+
+ Usb Clear Device Feature
+
+Arguments:
+
+ UsbIo - EFI_USB_IO_PROTOCOL
+ Recipient - Interface/Device/Endpoint
+ Value - Request value
+ Target - Request Index
+ Status - Transfer status
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Parameter is error
+ EFI_SUCCESS - Success
+ EFI_TIMEOUT - Device has no response
+
+--*/
+{
+ EFI_USB_DEVICE_REQUEST DevReq;
+
+ if (UsbIo == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
+
+ switch (Recipient) {
+
+ case EfiUsbDevice:
+ DevReq.RequestType = 0x00;
+ break;
+
+ case EfiUsbInterface:
+ DevReq.RequestType = 0x01;
+ break;
+
+ case EfiUsbEndpoint:
+ DevReq.RequestType = 0x02;
+ break;
+ }
+ //
+ // Fill device request, see USB1.1 spec
+ //
+ DevReq.Request = USB_DEV_CLEAR_FEATURE;
+ DevReq.Value = Value;
+ DevReq.Index = Target;
+
+
+ return UsbIo->UsbControlTransfer (
+ UsbIo,
+ &DevReq,
+ EfiUsbNoData,
+ TIMEOUT_VALUE,
+ NULL,
+ 0,
+ Status
+ );
+}
+//
+// Get Device Status
+//
+EFI_STATUS
+UsbGetDeviceStatus (
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN EFI_USB_RECIPIENT Recipient,
+ IN UINT16 Target,
+ OUT UINT16 *DevStatus,
+ OUT UINT32 *Status
+ )
+/*++
+
+Routine Description:
+
+ Usb Get Device Status
+
+Arguments:
+
+ UsbIo - EFI_USB_IO_PROTOCOL
+ Recipient - Interface/Device/Endpoint
+ Target - Request index
+ DevStatus - Device status
+ Status - Transfer status
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Parameter is error
+ EFI_SUCCESS - Success
+ EFI_TIMEOUT - Device has no response
+
+--*/
+{
+ EFI_USB_DEVICE_REQUEST DevReq;
+
+ if (UsbIo == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
+
+ switch (Recipient) {
+
+ case EfiUsbDevice:
+ DevReq.RequestType = 0x80;
+ break;
+
+ case EfiUsbInterface:
+ DevReq.RequestType = 0x81;
+ break;
+
+ case EfiUsbEndpoint:
+ DevReq.RequestType = 0x82;
+ break;
+ }
+ //
+ // Fill device request, see USB1.1 spec
+ //
+ DevReq.Request = USB_DEV_GET_STATUS;
+ DevReq.Value = 0;
+ DevReq.Index = Target;
+ DevReq.Length = 2;
+
+ return UsbIo->UsbControlTransfer (
+ UsbIo,
+ &DevReq,
+ EfiUsbDataIn,
+ TIMEOUT_VALUE,
+ DevStatus,
+ 2,
+ Status
+ );
+}
+//
+// Usb Get String
+//
+EFI_STATUS
+UsbGetString (
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINT16 LangID,
+ IN UINT8 Index,
+ IN VOID *Buf,
+ IN UINTN BufSize,
+ OUT UINT32 *Status
+ )
+/*++
+
+Routine Description:
+
+ Usb Get String
+
+Arguments:
+
+ UsbIo - EFI_USB_IO_PROTOCOL
+ LangID - Language ID
+ Index - Request index
+ Buf - Buffer to store string
+ BufSize - Buffer size
+ Status - Transfer status
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Parameter is error
+ EFI_SUCCESS - Success
+ EFI_TIMEOUT - Device has no response
+
+--*/
+{
+ UINT16 Value;
+
+ if (UsbIo == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // Fill value, see USB1.1 spec
+ //
+ Value = (UINT16) ((USB_DT_STRING << 8) | Index);
+
+ return UsbGetDescriptor (
+ UsbIo,
+ Value,
+ LangID,
+ (UINT16) BufSize,
+ Buf,
+ Status
+ );
+}
+
+EFI_STATUS
+UsbClearEndpointHalt (
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINT8 EndpointNo,
+ OUT UINT32 *Status
+ )
+/*++
+
+Routine Description:
+
+ Clear endpoint stall
+
+Arguments:
+
+ UsbIo - EFI_USB_IO_PROTOCOL
+ EndpointNo - Endpoint Number
+ Status - Transfer Status
+
+Returns:
+
+ EFI_NOT_FOUND - Can't find the Endpoint
+ EFI_DEVICE_ERROR - Hardware error
+ EFI_SUCCESS - Success
+
+--*/
+{
+ EFI_STATUS Result;
+ EFI_USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
+ EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
+ UINT8 Index;
+
+ ZeroMem (&EndpointDescriptor, sizeof (EFI_USB_ENDPOINT_DESCRIPTOR));
+ //
+ // First seach the endpoint descriptor for that endpoint addr
+ //
+ Result = UsbIo->UsbGetInterfaceDescriptor (
+ UsbIo,
+ &InterfaceDescriptor
+ );
+ if (EFI_ERROR (Result)) {
+ return Result;
+ }
+
+ for (Index = 0; Index < InterfaceDescriptor.NumEndpoints; Index++) {
+ Result = UsbIo->UsbGetEndpointDescriptor (
+ UsbIo,
+ Index,
+ &EndpointDescriptor
+ );
+ if (EFI_ERROR (Result)) {
+ continue;
+ }
+
+ if (EndpointDescriptor.EndpointAddress == EndpointNo) {
+ break;
+ }
+ }
+
+ if (Index == InterfaceDescriptor.NumEndpoints) {
+ //
+ // No such endpoint
+ //
+ return EFI_NOT_FOUND;
+ }
+
+ Result = UsbClearDeviceFeature (
+ UsbIo,
+ EfiUsbEndpoint,
+ EfiUsbEndpointHalt,
+ EndpointDescriptor.EndpointAddress,
+ Status
+ );
+
+ return Result;
+}
diff --git a/EdkModulePkg/Library/EdkUsbLib/build.xml b/EdkModulePkg/Library/EdkUsbLib/build.xml
new file mode 100644
index 0000000..0b9eaad
--- /dev/null
+++ b/EdkModulePkg/Library/EdkUsbLib/build.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><!-- 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.-->
+<project basedir="." default="EdkUsbLib"><!--Apply external ANT tasks-->
+ <taskdef resource="GenBuild.tasks"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+ <property environment="env"/>
+ <property name="WORKSPACE_DIR" value="${env.WORKSPACE}"/>
+ <import file="${WORKSPACE_DIR}\Tools\Conf\BuildMacro.xml"/><!--MODULE_RELATIVE PATH is relative to PACKAGE_DIR-->
+ <property name="MODULE_RELATIVE_PATH" value="Library\EdkUsbLib"/>
+ <property name="MODULE_DIR" value="${PACKAGE_DIR}\${MODULE_RELATIVE_PATH}"/>
+ <property name="COMMON_FILE" value="${WORKSPACE_DIR}\Tools\Conf\Common.xml"/>
+ <target name="EdkUsbLib">
+ <GenBuild baseName="EdkUsbLib" mbdFilename="${MODULE_DIR}\EdkUsbLib.mbd" msaFilename="${MODULE_DIR}\EdkUsbLib.msa"/>
+ </target>
+ <target depends="EdkUsbLib_clean" name="clean"/>
+ <target depends="EdkUsbLib_cleanall" name="cleanall"/>
+ <target name="EdkUsbLib_clean">
+ <OutputDirSetup baseName="EdkUsbLib" mbdFilename="${MODULE_DIR}\EdkUsbLib.mbd" msaFilename="${MODULE_DIR}\EdkUsbLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkUsbLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkUsbLib_build.xml" target="clean"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}" excludes="*.xml"/>
+ </target>
+ <target name="EdkUsbLib_cleanall">
+ <OutputDirSetup baseName="EdkUsbLib" mbdFilename="${MODULE_DIR}\EdkUsbLib.mbd" msaFilename="${MODULE_DIR}\EdkUsbLib.msa"/>
+ <if>
+ <available file="${DEST_DIR_OUTPUT}\EdkUsbLib_build.xml"/>
+ <then>
+ <ant antfile="${DEST_DIR_OUTPUT}\EdkUsbLib_build.xml" target="cleanall"/>
+ </then>
+ </if>
+ <delete dir="${DEST_DIR_OUTPUT}"/>
+ <delete dir="${DEST_DIR_DEBUG}"/>
+ <delete>
+ <fileset dir="${BIN_DIR}" includes="**EdkUsbLib*"/>
+ </delete>
+ </target>
+</project> \ No newline at end of file
diff --git a/EdkModulePkg/Library/EdkUsbLib/hid.c b/EdkModulePkg/Library/EdkUsbLib/hid.c
new file mode 100644
index 0000000..edf9a94
--- /dev/null
+++ b/EdkModulePkg/Library/EdkUsbLib/hid.c
@@ -0,0 +1,459 @@
+/*++
+
+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:
+
+ hid.c
+
+ Abstract:
+
+ HID class request
+
+ Revision History
+
+--*/
+
+//
+// Function to get HID descriptor
+//
+EFI_STATUS
+UsbGetHidDescriptor (
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINT8 InterfaceNum,
+ OUT EFI_USB_HID_DESCRIPTOR *HidDescriptor
+ )
+/*++
+
+ Routine Description:
+ Get Hid Descriptor
+
+ Arguments:
+ UsbIo - EFI_USB_IO_PROTOCOL
+ InterfaceNum - Hid interface number
+ HidDescriptor - Caller allocated buffer to store Usb hid descriptor
+ if successfully returned.
+
+ Returns:
+ EFI_SUCCESS
+ EFI_DEVICE_ERROR
+ EFI_TIMEOUT
+
+--*/
+{
+ UINT32 Status;
+ EFI_STATUS Result;
+ EFI_USB_DEVICE_REQUEST Request;
+
+ Request.RequestType = 0x81;
+ Request.Request = 0x06;
+ Request.Value = (UINT16) (0x21 << 8);
+ Request.Index = InterfaceNum;
+ Request.Length = sizeof (EFI_USB_HID_DESCRIPTOR);
+
+ Result = UsbIo->UsbControlTransfer (
+ UsbIo,
+ &Request,
+ EfiUsbDataIn,
+ TIMEOUT_VALUE,
+ HidDescriptor,
+ sizeof (EFI_USB_HID_DESCRIPTOR),
+ &Status
+ );
+
+ return Result;
+
+}
+//
+// Function to get Report Class descriptor
+//
+EFI_STATUS
+UsbGetReportDescriptor (
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINT8 InterfaceNum,
+ IN UINT16 DescriptorSize,
+ OUT UINT8 *DescriptorBuffer
+ )
+/*++
+
+ Routine Description:
+ get Report Class descriptor
+
+ Arguments:
+ UsbIo - EFI_USB_IO_PROTOCOL.
+ InterfaceNum - Report interface number.
+ DescriptorSize - Length of DescriptorBuffer.
+ DescriptorBuffer - Caller allocated buffer to store Usb report descriptor
+ if successfully returned.
+
+ Returns:
+ EFI_SUCCESS
+ EFI_DEVICE_ERROR
+ EFI_TIMEOUT
+
+--*/
+{
+ UINT32 Status;
+ EFI_STATUS Result;
+ EFI_USB_DEVICE_REQUEST Request;
+
+ //
+ // Fill Device request packet
+ //
+ Request.RequestType = 0x81;
+ Request.Request = 0x06;
+ Request.Value = (UINT16) (0x22 << 8);
+ Request.Index = InterfaceNum;
+ Request.Length = DescriptorSize;
+
+ Result = UsbIo->UsbControlTransfer (
+ UsbIo,
+ &Request,
+ EfiUsbDataIn,
+ TIMEOUT_VALUE,
+ DescriptorBuffer,
+ DescriptorSize,
+ &Status
+ );
+
+ return Result;
+
+}
+//
+// Following are HID class request
+//
+EFI_STATUS
+UsbGetProtocolRequest (
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINT8 Interface,
+ IN UINT8 *Protocol
+ )
+/*++
+
+ Routine Description:
+ Get Hid Protocol Request
+
+ Arguments:
+ UsbIo - EFI_USB_IO_PROTOCOL
+ Interface - Which interface the caller wants to get protocol
+ Protocol - Protocol value returned.
+
+ Returns:
+ EFI_SUCCESS
+ EFI_DEVICE_ERROR
+ EFI_TIMEOUT
+
+--*/
+{
+ UINT32 Status;
+ EFI_STATUS Result;
+ EFI_USB_DEVICE_REQUEST Request;
+
+ //
+ // Fill Device request packet
+ //
+ Request.RequestType = 0xa1;
+ //
+ // 10100001b;
+ //
+ Request.Request = EFI_USB_GET_PROTOCOL_REQUEST;
+ Request.Value = 0;
+ Request.Index = Interface;
+ Request.Length = 1;
+
+ Result = UsbIo->UsbControlTransfer (
+ UsbIo,
+ &Request,
+ EfiUsbDataIn,
+ TIMEOUT_VALUE,
+ Protocol,
+ sizeof (UINT8),
+ &Status
+ );
+
+ return Result;
+}
+
+
+EFI_STATUS
+UsbSetProtocolRequest (
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINT8 Interface,
+ IN UINT8 Protocol
+ )
+/*++
+
+ Routine Description:
+ Set Hid Protocol Request
+
+ Arguments:
+ UsbIo - EFI_USB_IO_PROTOCOL
+ Interface - Which interface the caller wants to set protocol
+ Protocol - Protocol value the caller wants to set.
+
+ Returns:
+ EFI_SUCCESS
+ EFI_DEVICE_ERROR
+ EFI_TIMEOUT
+
+--*/
+{
+ UINT32 Status;
+ EFI_STATUS Result;
+ EFI_USB_DEVICE_REQUEST Request;
+
+ //
+ // Fill Device request packet
+ //
+ Request.RequestType = 0x21;
+ //
+ // 00100001b;
+ //
+ Request.Request = EFI_USB_SET_PROTOCOL_REQUEST;
+ Request.Value = Protocol;
+ Request.Index = Interface;
+ Request.Length = 0;
+
+ Result = UsbIo->UsbControlTransfer (
+ UsbIo,
+ &Request,
+ EfiUsbNoData,
+ TIMEOUT_VALUE,
+ NULL,
+ 0,
+ &Status
+ );
+ return Result;
+}
+
+
+EFI_STATUS
+UsbSetIdleRequest (
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINT8 Interface,
+ IN UINT8 ReportId,
+ IN UINT8 Duration
+ )
+/*++
+
+ Routine Description:
+ Set Idel request.
+
+ Arguments:
+ UsbIo - EFI_USB_IO_PROTOCOL
+ Interface - Which interface the caller wants to set.
+ ReportId - Which report the caller wants to set.
+ Duration - Idle rate the caller wants to set.
+
+ Returns:
+ EFI_SUCCESS
+ EFI_DEVICE_ERROR
+ EFI_TIMEOUT
+
+--*/
+{
+ UINT32 Status;
+ EFI_STATUS Result;
+ EFI_USB_DEVICE_REQUEST Request;
+
+ //
+ // Fill Device request packet
+ //
+ Request.RequestType = 0x21;
+ //
+ // 00100001b;
+ //
+ Request.Request = EFI_USB_SET_IDLE_REQUEST;
+ Request.Value = (UINT16) ((Duration << 8) | ReportId);
+ Request.Index = Interface;
+ Request.Length = 0;
+
+ Result = UsbIo->UsbControlTransfer (
+ UsbIo,
+ &Request,
+ EfiUsbNoData,
+ TIMEOUT_VALUE,
+ NULL,
+ 0,
+ &Status
+ );
+ return Result;
+}
+
+EFI_STATUS
+UsbGetIdleRequest (
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINT8 Interface,
+ IN UINT8 ReportId,
+ OUT UINT8 *Duration
+ )
+/*++
+
+ Routine Description:
+ Get Idel request.
+
+ Arguments:
+ UsbIo - EFI_USB_IO_PROTOCOL
+ Interface - Which interface the caller wants to get.
+ ReportId - Which report the caller wants to get.
+ Duration - Idle rate the caller wants to get.
+
+ Returns:
+ EFI_SUCCESS
+ EFI_DEVICE_ERROR
+ EFI_TIMEOUT
+
+--*/
+{
+ UINT32 Status;
+ EFI_STATUS Result;
+ EFI_USB_DEVICE_REQUEST Request;
+
+ //
+ // Fill Device request packet
+ //
+ Request.RequestType = 0xa1;
+ //
+ // 10100001b;
+ //
+ Request.Request = EFI_USB_GET_IDLE_REQUEST;
+ Request.Value = ReportId;
+ Request.Index = Interface;
+ Request.Length = 1;
+
+ Result = UsbIo->UsbControlTransfer (
+ UsbIo,
+ &Request,
+ EfiUsbDataIn,
+ TIMEOUT_VALUE,
+ Duration,
+ 1,
+ &Status
+ );
+
+ return Result;
+}
+
+
+EFI_STATUS
+UsbSetReportRequest (
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINT8 Interface,
+ IN UINT8 ReportId,
+ IN UINT8 ReportType,
+ IN UINT16 ReportLen,
+ IN UINT8 *Report
+ )
+/*++
+
+ Routine Description:
+ Hid Set Report request.
+
+ Arguments:
+ UsbIo - EFI_USB_IO_PROTOCOL
+ Interface - Which interface the caller wants to set.
+ ReportId - Which report the caller wants to set.
+ ReportType - Type of report.
+ ReportLen - Length of report descriptor.
+ Report - Report Descriptor buffer.
+
+ Returns:
+ EFI_SUCCESS
+ EFI_DEVICE_ERROR
+ EFI_TIMEOUT
+
+--*/
+{
+ UINT32 Status;
+ EFI_STATUS Result;
+ EFI_USB_DEVICE_REQUEST Request;
+
+ //
+ // Fill Device request packet
+ //
+ Request.RequestType = 0x21;
+ //
+ // 00100001b;
+ //
+ Request.Request = EFI_USB_SET_REPORT_REQUEST;
+ Request.Value = (UINT16) ((ReportType << 8) | ReportId);
+ Request.Index = Interface;
+ Request.Length = ReportLen;
+
+ Result = UsbIo->UsbControlTransfer (
+ UsbIo,
+ &Request,
+ EfiUsbDataOut,
+ TIMEOUT_VALUE,
+ Report,
+ ReportLen,
+ &Status
+ );
+
+ return Result;
+}
+
+EFI_STATUS
+UsbGetReportRequest (
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN UINT8 Interface,
+ IN UINT8 ReportId,
+ IN UINT8 ReportType,
+ IN UINT16 ReportLen,
+ IN UINT8 *Report
+ )
+/*++
+
+ Routine Description:
+ Hid Set Report request.
+
+ Arguments:
+ UsbIo - EFI_USB_IO_PROTOCOL
+ Interface - Which interface the caller wants to set.
+ ReportId - Which report the caller wants to set.
+ ReportType - Type of report.
+ ReportLen - Length of report descriptor.
+ Report - Caller allocated buffer to store Report Descriptor.
+
+ Returns:
+ EFI_SUCCESS
+ EFI_DEVICE_ERROR
+ EFI_TIMEOUT
+
+--*/
+{
+ UINT32 Status;
+ EFI_STATUS Result;
+ EFI_USB_DEVICE_REQUEST Request;
+
+ //
+ // Fill Device request packet
+ //
+ Request.RequestType = 0xa1;
+ //
+ // 10100001b;
+ //
+ Request.Request = EFI_USB_GET_REPORT_REQUEST;
+ Request.Value = (UINT16) ((ReportType << 8) | ReportId);
+ Request.Index = Interface;
+ Request.Length = ReportLen;
+
+ Result = UsbIo->UsbControlTransfer (
+ UsbIo,
+ &Request,
+ EfiUsbDataIn,
+ TIMEOUT_VALUE,
+ Report,
+ ReportLen,
+ &Status
+ );
+
+ return Result;
+}