155 lines
3.4 KiB
C
155 lines
3.4 KiB
C
/**
|
|
* PROJECT: ExectOS
|
|
* COPYRIGHT: See COPYING.md in the top level directory
|
|
* FILE: xtldr/console.c
|
|
* DESCRIPTION: EFI console support
|
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
*/
|
|
|
|
#include <xtldr.h>
|
|
|
|
|
|
/**
|
|
* This routine clears the UEFI console screen.
|
|
*
|
|
* @return This routine does not return any value.
|
|
*
|
|
* @since XT 1.0
|
|
*/
|
|
XTCDECL
|
|
VOID
|
|
BlConsoleClearScreen()
|
|
{
|
|
/* Clear screen */
|
|
EfiSystemTable->ConOut->ClearScreen(EfiSystemTable->ConOut);
|
|
}
|
|
|
|
/**
|
|
* Disables the cursor on the UEFI console.
|
|
*
|
|
* @return This routine does not return any value.
|
|
*
|
|
* @since XT 1.0
|
|
*/
|
|
XTCDECL
|
|
VOID
|
|
BlConsoleDisableCursor()
|
|
{
|
|
EfiSystemTable->ConOut->EnableCursor(EfiSystemTable->ConOut, FALSE);
|
|
}
|
|
|
|
/**
|
|
* Enables the cursor on the UEFI console.
|
|
*
|
|
* @return This routine does not return any value.
|
|
*
|
|
* @since XT 1.0
|
|
*/
|
|
XTCDECL
|
|
VOID
|
|
BlConsoleEnableCursor()
|
|
{
|
|
EfiSystemTable->ConOut->EnableCursor(EfiSystemTable->ConOut, TRUE);
|
|
}
|
|
|
|
/**
|
|
* This routine formats the input string and prints it out to the stdout and serial console.
|
|
*
|
|
* @param Format
|
|
* The formatted string that is to be written to the output.
|
|
*
|
|
* @param ...
|
|
* Depending on the format string, this routine might expect a sequence of additional arguments.
|
|
*
|
|
* @return This routine does not return any value.
|
|
*
|
|
* @since XT 1.0
|
|
*/
|
|
XTCDECL
|
|
VOID
|
|
BlConsolePrint(IN PUINT16 Format,
|
|
IN ...)
|
|
{
|
|
VA_LIST Arguments;
|
|
|
|
/* Initialise the va_list */
|
|
VA_START(Arguments, Format);
|
|
|
|
/* Format and print the string to the stdout */
|
|
BlpStringPrint(BlpConsolePrintChar, Format, Arguments);
|
|
|
|
/* Print to serial console only if not running under OVMF */
|
|
if(RtlCompareWideString(EfiSystemTable->FirmwareVendor, L"EDK II", 6) != 0)
|
|
{
|
|
/* Check if debugging enabled and if EFI serial port is fully initialized */
|
|
if(DEBUG && (BlpSerialPort.Flags & COMPORT_FLAG_INIT))
|
|
{
|
|
/* Format and print the string to the serial console */
|
|
BlpStringPrint(BlpDebugPutChar, Format, Arguments);
|
|
}
|
|
}
|
|
|
|
/* Clean up the va_list */
|
|
VA_END(Arguments);
|
|
}
|
|
|
|
/**
|
|
* Displays the string on the device at the current cursor location.
|
|
*
|
|
* @param String
|
|
* The string to be displayed.
|
|
*
|
|
* @return This routine does not return any value.
|
|
*
|
|
* @since XT 1.0
|
|
*/
|
|
XTCDECL
|
|
VOID
|
|
BlConsoleWrite(IN PUSHORT String)
|
|
{
|
|
EfiSystemTable->ConOut->OutputString(EfiSystemTable->ConOut, String);
|
|
}
|
|
|
|
/**
|
|
* This routine initializes the EFI console.
|
|
*
|
|
* @return This routine returns status code.
|
|
*
|
|
* @since XT 1.0
|
|
*/
|
|
XTCDECL
|
|
VOID
|
|
BlpInitializeConsole()
|
|
{
|
|
/* Clear console buffers */
|
|
EfiSystemTable->ConIn->Reset(EfiSystemTable->ConIn, TRUE);
|
|
EfiSystemTable->ConOut->Reset(EfiSystemTable->ConOut, TRUE);
|
|
EfiSystemTable->StdErr->Reset(EfiSystemTable->StdErr, TRUE);
|
|
|
|
/* Clear screen and enable cursor */
|
|
BlConsoleClearScreen();
|
|
BlConsoleEnableCursor();
|
|
}
|
|
|
|
/**
|
|
* Writes a character to the default EFI console.
|
|
*
|
|
* @param Character
|
|
* The integer promotion of the character to be written.
|
|
*
|
|
* @return This routine does not return any value.
|
|
*
|
|
* @since XT 1.0
|
|
*/
|
|
XTCDECL
|
|
VOID
|
|
BlpConsolePrintChar(IN USHORT Character)
|
|
{
|
|
USHORT Buffer[2];
|
|
|
|
/* Write character to the screen console */
|
|
Buffer[0] = Character;
|
|
Buffer[1] = 0;
|
|
EfiSystemTable->ConOut->OutputString(EfiSystemTable->ConOut, Buffer);
|
|
}
|