1
/* $Id: VBoxDebugLib.c $ */
3
* VBoxDebugLib.c - Debug logging and assertions support routines using DevEFI.
7
* Copyright (C) 2009-2010 Sun Microsystems, Inc.
9
* This file is part of VirtualBox Open Source Edition (OSE), as
10
* available from http://www.virtualbox.org. This file is free software;
11
* you can redistribute it and/or modify it under the terms of the GNU
12
* General Public License (GPL) as published by the Free Software
13
* Foundation, in version 2 as it comes in the "COPYING" file of the
14
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18
* Clara, CA 95054 USA or visit http://www.sun.com if you need
19
* additional information or have any questions.
22
/*******************************************************************************
24
*******************************************************************************/
26
#include <Library/PrintLib.h>
27
#include <Library/DebugLib.h>
29
#include "VBoxDebugLib.h"
35
DebugPrint(IN UINTN ErrorLevel, IN CONST CHAR8 *Format, ...)
40
RTCCUINTREG SavedFlags;
42
/* No pool noise, please. */
43
if (ErrorLevel == DEBUG_POOL)
47
cch = AsciiVSPrint(szBuf, sizeof(szBuf), Format, va);
50
/* make sure it's terminated and doesn't end with a newline */
51
if (cch >= sizeof(szBuf))
52
cch = sizeof(szBuf) - 1;
53
while (cch > 0 && (szBuf[cch - 1] == '\n' || szBuf[cch - 1] == '\r'))
57
SavedFlags = ASMIntDisableFlags();
59
VBoxPrintString("dbg/");
60
VBoxPrintHex(ErrorLevel, sizeof(ErrorLevel));
62
VBoxPrintString(szBuf);
65
ASMSetFlags(SavedFlags);
71
DebugAssert(IN CONST CHAR8 *FileName, IN UINTN LineNumber, IN CONST CHAR8 *Description)
73
RTCCUINTREG SavedFlags = ASMIntDisableFlags();
75
VBoxPrintString("EFI Assertion failed! File=");
76
VBoxPrintString(FileName ? FileName : "<NULL>");
77
VBoxPrintString(" line=0x");
78
VBoxPrintHex(LineNumber, sizeof(LineNumber));
79
VBoxPrintString("\nDescription: ");
80
VBoxPrintString(Description ? Description : "<NULL>");
82
ASMOutU8(EFI_PANIC_PORT, 2); /** @todo fix this. */
84
ASMSetFlags(SavedFlags);
89
DebugClearMemory(OUT VOID *Buffer, IN UINTN Length)
96
DebugAssertEnabled(VOID)
103
DebugPrintEnabled(VOID)
105
/** @todo some PCD for this so we can disable it in release builds. */
111
DebugCodeEnabled(VOID)
119
DebugClearMemoryEnabled(VOID)