/** * PROJECT: ExectOS * COPYRIGHT: See COPYING.md in the top level directory * FILE: xtldr/console.c * DESCRIPTION: EFI console support * DEVELOPERS: Rafal Kupiec */ #include /** * 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 BlpConsoleInitialize() { /* 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); }