EDK2 doxygen online documents - Firmware Encoding Index 1
EDK2 doxygen online documents - Firmware Encoding Index

VBoxPkg/Library/VBoxDebugLib/VBoxDebugLib.c

Go to the documentation of this file.
00001 /* $Id: VBoxDebugLib.c 28800 2010-04-27 08:22:32Z vboxsync $ */
00006 /*
00007  * Copyright (C) 2009-2010 Oracle Corporation
00008  *
00009  * This file is part of VirtualBox Open Source Edition (OSE), as
00010  * available from http://www.virtualbox.org. This file is free software;
00011  * you can redistribute it and/or modify it under the terms of the GNU
00012  * General Public License (GPL) as published by the Free Software
00013  * Foundation, in version 2 as it comes in the "COPYING" file of the
00014  * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
00015  * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
00016  */
00017 
00018 /*******************************************************************************
00019 *   Header Files                                                               *
00020 *******************************************************************************/
00021 #include <Base.h>
00022 #include <Library/PrintLib.h>
00023 #include <Library/DebugLib.h>
00024 
00025 #include "VBoxDebugLib.h"
00026 #include "DevEFI.h"
00027 
00028 
00029 
00030 VOID EFIAPI
00031 DebugPrint(IN UINTN ErrorLevel, IN CONST CHAR8 *Format, ...)
00032 {
00033     CHAR8       szBuf[256];
00034     VA_LIST     va;
00035     UINTN       cch;
00036     RTCCUINTREG SavedFlags;
00037 
00038     /* No pool noise, please. */
00039     if (ErrorLevel == DEBUG_POOL)
00040         return;
00041 
00042     VA_START(va, Format);
00043     cch = AsciiVSPrint(szBuf, sizeof(szBuf), Format, va);
00044     VA_END(va);
00045 
00046     /* make sure it's terminated and doesn't end with a newline */
00047     if (cch >= sizeof(szBuf))
00048         cch = sizeof(szBuf) - 1;
00049     while (cch > 0 && (szBuf[cch - 1] == '\n' || szBuf[cch - 1] == '\r'))
00050         cch--;
00051     szBuf[cch] = '\0';
00052 
00053     SavedFlags = ASMIntDisableFlags();
00054 
00055     VBoxPrintString("dbg/");
00056     VBoxPrintHex(ErrorLevel, sizeof(ErrorLevel));
00057     VBoxPrintChar(' ');
00058     VBoxPrintString(szBuf);
00059     VBoxPrintChar('\n');
00060 
00061     ASMSetFlags(SavedFlags);
00062 
00063 }
00064 
00065 
00066 VOID EFIAPI
00067 DebugAssert(IN CONST CHAR8 *FileName, IN UINTN LineNumber, IN CONST CHAR8 *Description)
00068 {
00069     RTCCUINTREG SavedFlags = ASMIntDisableFlags();
00070 
00071     VBoxPrintString("EFI Assertion failed! File=");
00072     VBoxPrintString(FileName ? FileName : "<NULL>");
00073     VBoxPrintString(" line=0x");
00074     VBoxPrintHex(LineNumber, sizeof(LineNumber));
00075     VBoxPrintString("\nDescription: ");
00076     VBoxPrintString(Description ? Description : "<NULL>");
00077 
00078     ASMOutU8(EFI_PANIC_PORT, 2); 
00080     ASMSetFlags(SavedFlags);
00081 }
00082 
00083 
00084 VOID * EFIAPI
00085 DebugClearMemory(OUT VOID *Buffer, IN UINTN Length)
00086 {
00087     return Buffer;
00088 }
00089 
00090 
00091 BOOLEAN EFIAPI
00092 DebugAssertEnabled(VOID)
00093 {
00094     return TRUE;
00095 }
00096 
00097 
00098 BOOLEAN EFIAPI
00099 DebugPrintEnabled(VOID)
00100 {
00102     return TRUE;
00103 }
00104 
00105 
00106 BOOLEAN EFIAPI
00107 DebugCodeEnabled(VOID)
00108 {
00110     return TRUE;
00111 }
00112 
00113 
00114 BOOLEAN EFIAPI
00115 DebugClearMemoryEnabled(VOID)
00116 {
00117     return FALSE;
00118 }
00119 
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Defines