summaryrefslogtreecommitdiff
path: root/EdkModulePkg/Library/EdkUefiDebugLibConOut
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/EdkUefiDebugLibConOut
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/EdkUefiDebugLibConOut')
-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
4 files changed, 401 insertions, 0 deletions
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