VBoxDebugLib.c revision 8075cc001549198c1002b13c720c274814b8397c
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync * VBoxDebugLib.c - Debug logging and assertions support routines using DevEFI.
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync * Copyright (C) 2009-2012 Oracle Corporation
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync * available from http://www.virtualbox.org. This file is free software;
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync * you can redistribute it and/or modify it under the terms of the GNU
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync * General Public License (GPL) as published by the Free Software
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync * The contents of this file may alternatively be used under the terms
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync * of the Common Development and Distribution License Version 1.0
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync * VirtualBox OSE distribution, in which case the provisions of the
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync * CDDL are applicable instead of those of the GPL.
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync * You may elect to license modified versions of this file under the
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync * terms and conditions of either the GPL or the CDDL or both.
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync/*******************************************************************************
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync* Header Files *
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync*******************************************************************************/
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsyncstatic EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *g_DevPath2Txt;
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsyncDebugPrint(IN UINTN ErrorLevel, IN CONST CHAR8 *Format, ...)
9127c416edfd6f9266e387f7abd7aa9904eecbc9vboxsync /* No pool noise, please. */
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync cch = AsciiVSPrint(szBuf, sizeof(szBuf), Format, va);
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync /* make sure it's terminated and doesn't end with a newline */
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync while (cch > 0 && (szBuf[cch - 1] == '\n' || szBuf[cch - 1] == '\r'))
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync /* Output the log string. */
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync * Our own log worker function, avoid the dbg/00000xxx prefix and makes it clear
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync * which log statements we added..
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync * @param pszFormat Format string. EFI style!
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync * @param ... Argument referneced in the format string.
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync /* Format it. */
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync /* Output the log string. */
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync * Adds a character to the panic message.
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync * @param ch The ASCII char to add.
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync ASMOutU16(EFI_PANIC_PORT, EFI_PANIC_CMD_MSG_FROM_CHAR(ch));
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync * Adds a string to the panic message.
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync * @param pszString The string to add.
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync * Adds a unsigned decimal number to the panic message.
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync * @param uValue The value.
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsyncDebugAssert(IN CONST CHAR8 *FileName, IN UINTN LineNumber, IN CONST CHAR8 *Description)
if (!g_DevPath2Txt)
DEBUG((DEBUG_INFO, "gEfiDevicePathToTextProtocolGuid:%g isn't instantied\n", gEfiDevicePathToTextProtocolGuid));
return NULL;
return NULL;
NULL,
rc,
hHandle));
return NULL;
return psz16TxtDevicePath;
return NULL;
if (!g_DevPath2Txt)
DEBUG((DEBUG_INFO, "gEfiDevicePathToTextProtocolGuid:%g isn't instantied\n", gEfiDevicePathToTextProtocolGuid));
return NULL;
return NULL;
return Buffer;
return TRUE;
return TRUE;
return TRUE;
return FALSE;