exectos/xtldr2/console.c
Rafal Kupiec 0cea10ad42
All checks were successful
Builds / ExectOS (amd64) (push) Successful in 46s
Builds / ExectOS (i686) (push) Successful in 25s
Store all configuration in a linked list, read config from INI file and EFI shell
2023-12-11 16:31:15 +01:00

138 lines
3.1 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);
}
/**
* 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);
}