Beispiel #1
0
static int
snprintf(char *str, size_t n, char const *fmt, ...)
{
    va_list ap;
    int rval;

#ifdef VSPRINTF_CHARSTAR
    char *rp;
    VA_START(ap, fmt);
    rp = vsprintf(str, fmt, ap);
    VA_END(ap);
    rval = strlen(rp);

#else
    VA_START(ap, fmt);
    rval = vsprintf(str, fmt, ap);
    VA_END(ap);
#endif

    if (rval > n) {
        fprintf(stderr, "snprintf buffer overrun %d > %d\n", rval, (int)n);
        abort();
    }
    return rval;
}
Beispiel #2
0
/**
  Uninstalls a list of protocol interface in the boot services environment.
  This function calls UnisatllProtocolInterface() in a loop. This is
  basically a lib function to save space.

  @param  Handle                 The handle to uninstall the protocol
  @param  ...                    EFI_GUID followed by protocol instance. A NULL
                                 terminates the  list. The pairs are the
                                 arguments to UninstallProtocolInterface(). All
                                 the protocols are added to Handle.

  @return Status code

**/
EFI_STATUS
EFIAPI
CoreUninstallMultipleProtocolInterfaces (
  IN EFI_HANDLE           Handle,
  ...
  )
{
  EFI_STATUS      Status;
  VA_LIST         Args;
  EFI_GUID        *Protocol;
  VOID            *Interface;
  UINTN           Index;

  VA_START (Args, Handle);
  for (Index = 0, Status = EFI_SUCCESS; !EFI_ERROR (Status); Index++) {
    //
    // If protocol is NULL, then it's the end of the list
    //
    Protocol = VA_ARG (Args, EFI_GUID *);
    if (Protocol == NULL) {
      break;
    }

    Interface = VA_ARG (Args, VOID *);

    //
    // Uninstall it
    //
    Status = CoreUninstallProtocolInterface (Handle, Protocol, Interface);
  }
  VA_END (Args);

  //
  // If there was an error, add all the interfaces that were
  // uninstalled without any errors
  //
  if (EFI_ERROR (Status)) {
    //
    // Reset the va_arg back to the first argument.
    //
    VA_START (Args, Handle);
    for (; Index > 1; Index--) {
      Protocol = VA_ARG(Args, EFI_GUID *);
      Interface = VA_ARG(Args, VOID *);
      CoreInstallProtocolInterface (&Handle, Protocol, EFI_NATIVE_INTERFACE, Interface);
    }
    VA_END (Args);
  }

  return Status;
}
void Logging::Printf(const TDesC8& aSubTag, TLogEntryType aType, TRefByValue<const TDesC8> aFmt, ...)
    {
	VA_LIST list;
	VA_START(list,aFmt);
	Printf(aSubTag, aType, aFmt, list);
	VA_END(list);
    }
// ---------------------------------------------------------------------------
// Writes to log.
// ---------------------------------------------------------------------------
//
void CKmdDebugLogger::LogWriteF( TRefByValue<const TDesC8> aFmt, ... )
    {
    VA_LIST list;
    VA_START( list,aFmt );

    iFileLogger.WriteFormat( aFmt, list );    
    }
void Logging::Printf(const TDesC8& aSubTag, TRefByValue<const TDesC8> aFmt, ...)
    {
	VA_LIST list;
	VA_START(list,aFmt);
	Printf(aSubTag, Logging::ELogInfo, aFmt, list);
	VA_END(list);
    }
Beispiel #6
0
/**

  Prints a debug message to the debug output device if the specified error level is enabled.

  If any bit in ErrorLevel is also set in PcdDebugPrintErrorLevel, then print 
  the message specified by Format and the associated variable argument list to 
  the debug output device.

  If Format is NULL, then ASSERT().

  @param  ErrorLevel  The error level of the debug message.
  @param  Format      Format string for the debug message to print.

**/
VOID
EFIAPI
DebugPrint (
  IN  UINTN        ErrorLevel,
  IN  CONST CHAR8  *Format,
  ...
  )
{
  CHAR8    AsciiBuffer[MAX_DEBUG_MESSAGE_LENGTH];
  VA_LIST  Marker;

  //
  // If Format is NULL, then ASSERT().
  //
  ASSERT (Format != NULL);

  //
  // Check driver debug mask value and global mask
  //
  if ((ErrorLevel & PcdGet32(PcdDebugPrintErrorLevel)) == 0) {
    return;
  }

  //
  // Convert the DEBUG() message to a Unicode String
  //
  VA_START (Marker, Format);
  AsciiVSPrint (AsciiBuffer, sizeof (AsciiBuffer), Format, Marker);
  VA_END (Marker);

  SemihostWriteString (AsciiBuffer);
}
/**
    prints a line to the console and copies it to the debug log if LOGGING_ENABLED
*/
void LogPrint(TRefByValue<const TDesC> aFmt,...)
    {
    VA_LIST list;
    VA_START(list, aFmt);

    TBuf<0x100> buf;
    buf.FormatList(aFmt, list); //-- ignore overflows

    if(console)
        console->Write(buf);

#ifdef LOGGING_ENABLED
    //-- print out the line via RDebug::Print
    const TInt bufLen = buf.Length();
    if(bufLen >0 && buf[bufLen-1] == '\n')
        {
        buf.Insert(bufLen-1, _L("\r"));
        }
    else
        {
        buf.Append(_L("\r\n"));
        }

    RDebug::RawPrint(buf);
#endif
    }
Beispiel #8
0
static int send_msg(process *pp, int act, const char *fmt, ...)
   {int nl;
    char msg[BFLRG];
    char *p;
    dbgrsp *gr;
    atdbgdes *st;

    VA_START(fmt);

    if (fmt == NULL)
       p = NULL;
    else
       {VSNPRINTF(msg, BFLRG, fmt);
	p  = msg;};

    VA_END;

    gr = (dbgrsp *) pp->a;
    st = gr->st;
    gr->action = act;

/* log the message sent */
    if ((st->log != NULL) && (p != NULL))
       fprintf(st->log, "SND: %s\n", p);

    nl = job_response(pp, 30000, p);

    return(nl);}
Beispiel #9
0
/**
  This function prints a series of strings.

  @param  ConOut                Pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
  @param  ...                   A variable argument list containing series of
                                strings, the last string must be NULL.

  @retval EFI_SUCCESS           Success print out the string using ConOut.
  @retval EFI_STATUS            Return the status of the ConOut->OutputString ().

**/
EFI_STATUS
EFIAPI
BdsLibOutputStrings (
  IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL   *ConOut,
  ...
  )
{
  VA_LIST     Args;
  EFI_STATUS  Status;
  CHAR16      *String;

  Status = EFI_SUCCESS;
  VA_START (Args, ConOut);

  while (!EFI_ERROR (Status)) {
    //
    // If String is NULL, then it's the end of the list
    //
    String = VA_ARG (Args, CHAR16 *);
    if (String == NULL) {
      break;
    }

    Status = ConOut->OutputString (ConOut, String);

    if (EFI_ERROR (Status)) {
      break;
    }
  }
  
  VA_END(Args);
  return Status;
}
Beispiel #10
0
void CDTSYLogger::WriteFormat(TRefByValue<const TDesC8> aFmt,...)
	{
	TBuf8<KGenericBufferSize> buf;
    VA_LIST list;
    VA_START(list,aFmt);
    buf.FormatList(aFmt,list);
	TChar tmpchar;
	for(TInt i=0;i<buf.Length();i++)
		{
		tmpchar=buf[i];
		if(!((tmpchar.IsPrint()) || (tmpchar=='\n') || (tmpchar=='\r') || (tmpchar=='\t')))
			buf[i]='.';
		}
#ifdef __EXE__
	CDTSYLogger* context=aScriptLoggerContext;
#else
	CDTSYLogger* context=(CDTSYLogger*) Dll::Tls();
#endif
	if(context==NULL)
		{
		TRAPD(ret,context=CDTSYLogger::NewL());
		if (ret==KErrNone)
			{	
#ifdef __EXE__
			aScriptLoggerContext=context;
#else
			Dll::SetTls(context);
#endif
			}
		else return;
		}
	if(context->iValid)
		context->WriteRecord(buf);
	}
void CTestTransaction::Log(TRefByValue<const TDesC> aFmt, ... )
	{
	VA_LIST list;
	VA_START(list, aFmt);

	Machine()->MsgPrintfln(aFmt, list);
	}
Beispiel #12
0
UINTN
Aprint (
  IN CONST CHAR8  *Format,
  ...
  )
/*++

Routine Description:

  Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii 
  characters.

Arguments:

  Format - Ascii format string see file header for more details.

  ...    - Vararg list consumed by processing Format.

Returns: 

  Number of characters printed.

--*/
{
  UINTN   Return;
  VA_LIST Marker;
  UINTN   Index;
  UINTN   MaxIndex;
  CHAR16  Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
  CHAR16  UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];

  MaxIndex = EfiAsciiStrLen ((CHAR8 *) Format);
  if (MaxIndex >= EFI_DRIVER_LIB_MAX_PRINT_BUFFER) {
    //
    // Format string was too long for use to process.
    //
    return 0;
  }

  for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER; Index++) {
    UnicodeFormat[Index] = (CHAR16) Format[Index];
  }

  VA_START (Marker, Format);
  Return = VSPrint (Buffer, sizeof (Buffer), UnicodeFormat, Marker);
  VA_END (Marker);

  //
  // Need to convert to Unicode to do an OutputString
  //

  if (gST->ConOut != NULL) {
    //
    // To be extra safe make sure ConOut has been initialized
    //
    gST->ConOut->OutputString (gST->ConOut, Buffer);
  }

  return Return;
}
Beispiel #13
0
/**
  Transfers control to a function starting with a new stack.

  Transfers control to the function specified by EntryPoint using the new stack
  new stack specified by NewStack and passing in the parameters specified
  by Context1 and Context2.  Context1 and Context2 are optional and may
  be NULL.  The function EntryPoint must never return.  This function
  supports a variable number of arguments following the NewStack parameter.
  These additional arguments are ignored on IA-32, x64, and EBC.
  IPF CPUs expect one additional parameter of type VOID * that specifies
  the new backing store pointer.

  If EntryPoint is NULL, then ASSERT().
  If NewStack is NULL, then ASSERT().

  @param  EntryPoint  A pointer to function to call with the new stack.
  @param  Context1    A pointer to the context to pass into the EntryPoint
                      function.
  @param  Context2    A pointer to the context to pass into the EntryPoint
                      function.
  @param  NewStack    A pointer to the new stack to use for the EntryPoint
                      function.

**/
VOID
EFIAPI
SwitchStack (
  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,
  IN      VOID                      *Context1,  OPTIONAL
  IN      VOID                      *Context2,  OPTIONAL
  IN      VOID                      *NewStack,
  ...
  )
{
  VA_LIST    Marker;

  ASSERT (EntryPoint != NULL);
  ASSERT (NewStack != NULL);

  VA_START (Marker, NewStack);

  InternalSwitchStack (EntryPoint, Context1, Context2, NewStack, Marker);

  VA_END (Marker);
  //
  // InternalSwitchStack () will never return
  //
  ASSERT (FALSE);
}
GLDEF_C void Debug( TRefByValue<const TDesC> aText, ... )
    {
    #ifdef WINS
    VA_LIST args;
    VA_START( args, aText );

    TBuf<KLogLineLength> buf;
    buf.FormatList( aText, args );

    RFileLogger logger;
    TInt ret=logger.Connect();
    if (ret==KErrNone)
        {
        logger.SetDateAndTime( EFalse,EFalse );
        logger.CreateLog( KLogFolder, KLogFileName, EFileLoggingModeAppend );       
        TBuf<KLogTimeFormatLength> timeStamp;
        TTime now;
        now.HomeTime();
        TDateTime dateTime;
        dateTime = now.DateTime();
        timeStamp.Format( KLogTimeFormat, 
            dateTime.Hour(), dateTime.Minute(),
            dateTime.Second(), dateTime.MicroSecond() );
        buf.Insert( 0, timeStamp );

        logger.Write(buf);
        }

    logger.Close();

    VA_END( args );
    #else
    RDebug::Print(aText);
    #endif
    }
Beispiel #15
0
void PredLog::Printf(TRefByValue<const TDesC> aFmt, ...)
	{

	VA_LIST list;
	VA_START(list,aFmt);
	RFileLogger::WriteFormat(KPredLogFolder(),KPredLogFile(),EFileLoggingModeAppend,aFmt,list);
	}
Beispiel #16
0
EFI_STATUS
EFIAPI
EfiBootManagerRegisterContinueKeyOption (
  IN UINT32           Modifier,
  ...
  )
{
  EFI_STATUS                   Status;
  EFI_BOOT_MANAGER_KEY_OPTION  KeyOption;
  VA_LIST                      Args;
  
  if (mContinueKeyOption != NULL) {
    return EFI_ALREADY_STARTED;
  }

  ZeroMem (&KeyOption, sizeof (EFI_BOOT_MANAGER_KEY_OPTION));
  VA_START (Args, Modifier);
  Status = InitializeKeyFields (Modifier, Args, &KeyOption);
  VA_END (Args);

  if (!EFI_ERROR (Status)) {
    mContinueKeyOption = AllocateCopyPool (sizeof (EFI_BOOT_MANAGER_KEY_OPTION), &KeyOption);
    ASSERT (mContinueKeyOption != NULL);
    if (mHotkeyServiceStarted) {
      ProcessKeyOption (mContinueKeyOption);
    }
  }

  return Status;
}
Beispiel #17
0
VOID
UhciError (
  IN  CHAR8               *Format,
  ...
  )
/*++

Routine Description:

  Debug error print interface for UHCI

Arguments:

  Format  - String to use for the print, followed by print arguments

Returns:

  None

--*/
{
  VA_LIST                 Marker;

  VA_START (Marker, Format);
  EfiDebugVPrint (EFI_D_ERROR, Format, Marker);
  VA_END (Marker); 
}
Beispiel #18
0
VOID
EfiDebugPrint (
  IN  UINTN     ErrorLevel,
  IN  CHAR8     *Format,
  ...
  )
/*++

Routine Description:

  Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT
  information. If Error Logging hub is not loaded do nothing.
  
Arguments:

  ErrorLevel - If error level is set do the debug print.

  Format     - String to use for the print, followed by Print arguments.
  
Returns:
  
  None

--*/
{
  VA_LIST Marker;

  VA_START (Marker, Format);
  if (mDebugAssert != NULL) {
    mDebugAssert->Print (mDebugAssert, ErrorLevel, Format, Marker);
  }

  VA_END (Marker);
}
Beispiel #19
0
/**
  Formatted Print using a Hii Token to reference the localized format string.

  @param[in]  Token   A HII token associated with a localized Unicode string.
  @param[in]  ...     The variable argument list.

  @return             The number of characters converted by UnicodeVSPrint().

**/
UINTN
EFIAPI
PrintToken (
  IN UINT16           Token,
  ...
  )
{
  VA_LIST           Marker;
  EFI_STRING        StringPtr;
  UINTN             Return;
  UINTN             BufferSize;

  StringPtr = HiiGetString (gHiiHandle, Token, NULL);
  ASSERT (StringPtr != NULL);

  VA_START (Marker, Token);

  BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);

  if (mPrintTokenBuffer == NULL) {
    mPrintTokenBuffer = AllocatePool (BufferSize);
    ASSERT (mPrintTokenBuffer != NULL);
  }
  SetMem( mPrintTokenBuffer, BufferSize, 0);

  Return = UnicodeVSPrint (mPrintTokenBuffer, BufferSize, StringPtr, Marker);
  VA_END (Marker);

  if (Return > 0 && gST->ConOut != NULL) {
    gST->ConOut->OutputString (gST->ConOut, mPrintTokenBuffer);
  }
  FreePool (StringPtr);
  return Return;
}
Beispiel #20
0
UINTN
EFIAPI
PrintToken (
  IN UINT16             Token,
  IN EFI_HII_HANDLE     Handle,
  ...
  )
{
  VA_LIST Marker;
  UINTN   Return;
  CHAR16  *Format;

  VA_START (Marker, Handle);

  Format = HiiGetString (Handle, Token, NULL);
  ASSERT (Format != NULL);

  Return = InternalPrintToken (Format, gST->ConOut, Marker);

  FreePool (Format);

  VA_END (Marker);

  return Return;
}
TInt CTestTransaction::Error( TInt aError, TRefByValue<const TDesC> aFmt, ... )
	{
	VA_LIST list;
	VA_START(list, aFmt);
	Machine()->MsgPrintfln(aFmt, list);
	return aError;
	}
Beispiel #22
0
void
int_error(int t_num, const char str[], va_dcl)
#endif
{
#ifdef VA_START
    va_list args;
#endif

    char error_message[128] = {'\0'};

    /* reprint line if screen has been written to */

    if (t_num == DATAFILE) {
	df_showdata();
    } else if (t_num != NO_CARET) { /* put caret under error */
	if (!screen_ok)
	    PRINT_MESSAGE_TO_STDERR;

	PRINT_SPACES_UNDER_PROMPT;
	PRINT_SPACES_UPTO_TOKEN;
	PRINT_CARET;
    }
    PRINT_SPACES_UNDER_PROMPT;
    PRINT_FILE_AND_LINE;

#ifdef VA_START
    VA_START(args, str);
# if defined(HAVE_VFPRINTF) || _LIBC
    vsnprintf(error_message, sizeof(error_message), str, args);
    fprintf(stderr,"%.120s",error_message);
# else
    _doprnt(str, args, stderr);
# endif
    va_end(args);
#else
    fprintf(stderr, str, a1, a2, a3, a4, a5, a6, a7, a8);
#ifdef HAVE_SNPRINTF
    snprintf(error_message, sizeof(error_message), str, a1, a2, a3, a4, a5, a6, a7, a8);
#else
    sprintf(error_message, str, a1, a2, a3, a4, a5, a6, a7, a8);
#endif
#endif

    fputs("\n\n", stderr);

    /* We are bailing out of nested context without ever reaching */
    /* the normal cleanup code. Reset any flags before bailing.   */
    df_reset_after_error();
    eval_reset_after_error();
    clause_reset_after_error();
    parse_reset_after_error();
    scanning_range_in_progress = FALSE;
    inside_zoom = FALSE;

    /* Load error state variables */
    update_gpval_variables(2);
    fill_gpval_string("GPVAL_ERRMSG", error_message);

    bail_to_command_line();
}
Beispiel #23
0
void
graph_error(const char *fmt, va_dcl)
#endif
{
#ifdef VA_START
    va_list args;
#endif

    multiplot = FALSE;
    term_end_plot();

#ifdef VA_START
    VA_START(args, fmt);
    /* HBB 20001120: instead, copy the core code from int_error() to
     * here: */
    PRINT_SPACES_UNDER_PROMPT;
    PRINT_FILE_AND_LINE;

# if defined(HAVE_VFPRINTF) || _LIBC
    vfprintf(stderr, fmt, args);
# else
    _doprnt(fmt, args, stderr);
# endif
    va_end(args);
    fputs("\n\n", stderr);

    bail_to_command_line();
    va_end(args);
#else
    int_error(NO_CARET, fmt, a1, a2, a3, a4, a5, a6, a7, a8);
#endif

}
void CMainControlEngine::WriteLog16(TRefByValue<const TDesC> aFmt, ...)
{
#ifdef __WRITE_LOG__
	//UtilityTools::WriteLogsL(_L("WriteLog16"));
	TBuf<400> tBuf;
	VA_LIST	list;
	VA_START(list,aFmt);
	tBuf.Zero();
	tBuf.AppendFormatList(aFmt,list);
	VA_END(list);

	HBufC8* buf=CnvUtfConverter::ConvertFromUnicodeToUtf8L(tBuf);
	ASSERT(buf);
	CleanupStack::PushL(buf);

	TBuf<64>	time16;
	TBuf8<64>	time8;
	TTime	tTime;
	tTime.HomeTime();
	tTime.FormatL(time16, _L("%D%M%Y%2/%3 %H:%T:%S "));
	time8.Copy(time16);

	iFile.Write(time8);
	iFile.Write(*buf);
	iFile.Write(_L8("\x0a\x0d"));
	CleanupStack::PopAndDestroy(1);
	//UtilityTools::WriteLogsL(_L("WriteLog16 End"));
#endif
}
Beispiel #25
0
VOID EFIAPI
DebugPrint(IN UINTN ErrorLevel, IN CONST CHAR8 *Format, ...)
{
    CHAR8       szBuf[256];
    VA_LIST     va;
    UINTN       cch;
    RTCCUINTREG SavedFlags;

    /* No pool noise, please. */
    if (ErrorLevel == DEBUG_POOL)
        return;

    VA_START(va, Format);
    cch = AsciiVSPrint(szBuf, sizeof(szBuf), Format, va);
    VA_END(va);

    /* make sure it's terminated and doesn't end with a newline */
    if (cch >= sizeof(szBuf))
        cch = sizeof(szBuf) - 1;
    while (cch > 0 && (szBuf[cch - 1] == '\n' || szBuf[cch - 1] == '\r'))
        cch--;
    szBuf[cch] = '\0';

    SavedFlags = ASMIntDisableFlags();

    VBoxPrintString("dbg/");
    VBoxPrintHex(ErrorLevel, sizeof(ErrorLevel));
    VBoxPrintChar(' ');
    VBoxPrintString(szBuf);
    VBoxPrintChar('\n');

    ASMSetFlags(SavedFlags);

}
void CMsvScheduleSend::FLog(TRefByValue<const TDesC8> aFormat, ...)
	{
	VA_LIST list;
	VA_START(list, aFormat);
	RFileLogger::WriteFormat(KSchSendLogDir, KSchSendLogFile, EFileLoggingModeAppend,
		aFormat, list);
	}
Beispiel #27
0
UINTN
USPrint (
  OUT CHAR16        *Buffer,
  IN  UINTN         BufferSize,
  IN  CONST CHAR16  *Format,
  ...
  )
/*++

Routine Description:

  Process format and place the results in Buffer for wide chars.

Arguments:

  Buffer      - Wide char buffer to print the results of the parsing of Format into.
  BufferSize  - Maximum number of characters to put into buffer.
  Format      - Format string
  ...         - Vararg list consumed by processing Format.

Returns:

  Number of characters printed.

--*/
{
  UINTN   Return;
  VA_LIST Marker;

  VA_START (Marker, Format);
  Return = UnicodeVSPrint (Buffer, BufferSize, Format, Marker);
  VA_END (Marker);

  return Return;
}
EXPORT_C void CSenLogger::WriteFormatWithClientIdToMainLogs(TInt aClientId, TInt aLevel, TRefByValue<const TDesC8> aFmt, ...)
    {
    VA_LIST list;
    VA_START(list,aFmt);
    WriteFormatWithClientId( aClientId, KSenClientSessionLogChannelBase+aClientId, aLevel, aFmt, list );
    WriteFormatWithClientId( aClientId, KSenCoreServiceManagerLogChannelBase, aLevel, aFmt, list );
    }
Beispiel #29
0
VOID
EFIAPI
PrintString (
  IN CONST CHAR8  *FormatString,
  ...
  )
{
#if (DEBUG_PRINT_LEVEL & 0x7FFFFFFF)
  UINTN           Index;
  CHAR8           PrintBuffer[1000];
  VA_LIST         Marker;

  VA_START (Marker, FormatString);
  AsciiVSPrint (PrintBuffer, sizeof (PrintBuffer), FormatString, Marker);
  VA_END (Marker);

  for (Index = 0; PrintBuffer[Index] != 0; Index++) {
    if (PrintBuffer[Index] == '\n') {
      mCursor = (UINT8 *) (UINTN) (0xb8000 + (((((UINTN)mCursor - 0xb8000) + 160) / 160) * 160));
    } else if (PrintBuffer[Index] != '\r') { // skip non-displayable character
      *mCursor = (UINT8) PrintBuffer[Index];
      mCursor += 2;
    }
  }

  //
  // All information also output to serial port.
  //
  SerialPortWrite ((UINT8 *) PrintBuffer, Index);
#endif
}
/**
  Prints a debug message to the debug output device if the specified error level is enabled.

  If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
  GetDebugPrintErrorLevel (), then print the message specified by Format and the
  associated variable argument list to the debug output device.

  If Format is NULL, then ASSERT().

  @param  ErrorLevel  The error level of the debug message.
  @param  Format      Format string for the debug message to print.
  @param  ...         A variable argument list whose contents are accessed
                      based on the format string specified by Format.

**/
VOID
EFIAPI
DebugPrint (
  IN  UINTN        ErrorLevel,
  IN  CONST CHAR8  *Format,
  ...
  )
{
  CHAR8      Buffer[MAX_DEBUG_MESSAGE_LENGTH];
  VA_LIST    Marker;

  //
  // If Format is NULL, then ASSERT().
  //
  ASSERT (Format != NULL);

  //
  // Check driver debug mask value and global mask
  //
  if ((ErrorLevel & GetDebugPrintErrorLevel ()) == 0) {
    return;
  }

  //
  // Convert the DEBUG() message to an ASCII String
  //
  VA_START (Marker, Format);
  AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker);
  VA_END (Marker);

  //
  // Send the print string to EFI_DEBUGPORT_PROTOCOL.Write.
  //
  UefiDebugLibDebugPortProtocolWrite (Buffer, AsciiStrLen (Buffer));
}