alcyone/BOOT/ENVIRON/LIB/EFI/eficon.c

92 lines
1.2 KiB
C

/*++
Copyright (c) 2024, Quinn Stephens.
Provided under the BSD 3-Clause license.
Module Name:
eficon.c
Abstract:
Provides EFI console utilities.
--*/
#include <stdarg.h>
#include <wchar.h>
#include "bootlib.h"
VOID
ConsolePrint (
IN PWSTR String
)
/*++
Routine Description:
Prints a string to the console.
Arguments:
String.
Return Value:
None.
--*/
{
EXECUTION_CONTEXT_TYPE ContextType;
ContextType = CurrentExecutionContext->Type;
if (ContextType != ExecutionContextFirmware) {
BlpArchSwitchContext(ExecutionContextFirmware);
}
EfiConOut->OutputString(EfiConOut, String);
if (ContextType != ExecutionContextFirmware) {
BlpArchSwitchContext(ContextType);
}
}
VOID
ConsolePrintf (
IN PWSTR Format,
...
)
/*++
Routine Description:
Prints a formatted string to the console.
Arguments:
Format - Format string handled by vswprintf().
... - Arguments.
Return Value:
None.
--*/
{
int Status;
va_list Args;
WCHAR Buffer[256];
va_start(Args, Format);
Status = vswprintf(Buffer, sizeof(Buffer) / sizeof(WCHAR) - 1, Format, Args);
va_end(Args);
if (Status > 0) {
ConsolePrint(Buffer);
}
}