Initialize console without error reporting and allow serial port configuration to be passed via EFI shell
All checks were successful
ci/woodpecker/push/build Pipeline was successful
All checks were successful
ci/woodpecker/push/build Pipeline was successful
This commit is contained in:
parent
35b3c59270
commit
a6d892bf08
@ -29,15 +29,9 @@ BlConsoleClearScreen()
|
|||||||
*
|
*
|
||||||
* @since XT 1.0
|
* @since XT 1.0
|
||||||
*/
|
*/
|
||||||
EFI_STATUS
|
VOID
|
||||||
BlConsoleInitialize()
|
BlConsoleInitialize()
|
||||||
{
|
{
|
||||||
/* Check the console support */
|
|
||||||
if(!EfiSystemTable->ConOut)
|
|
||||||
{
|
|
||||||
return STATUS_EFI_UNSUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Clear console buffers */
|
/* Clear console buffers */
|
||||||
EfiSystemTable->ConIn->Reset(EfiSystemTable->ConIn, TRUE);
|
EfiSystemTable->ConIn->Reset(EfiSystemTable->ConIn, TRUE);
|
||||||
EfiSystemTable->ConOut->Reset(EfiSystemTable->ConOut, TRUE);
|
EfiSystemTable->ConOut->Reset(EfiSystemTable->ConOut, TRUE);
|
||||||
@ -48,9 +42,6 @@ BlConsoleInitialize()
|
|||||||
|
|
||||||
/* Enable cursor */
|
/* Enable cursor */
|
||||||
EfiSystemTable->ConOut->EnableCursor(EfiSystemTable->ConOut, TRUE);
|
EfiSystemTable->ConOut->EnableCursor(EfiSystemTable->ConOut, TRUE);
|
||||||
|
|
||||||
/* Return success */
|
|
||||||
return STATUS_EFI_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
113
xtldr/efiutil.c
113
xtldr/efiutil.c
@ -9,6 +9,119 @@
|
|||||||
#include <xtbl.h>
|
#include <xtbl.h>
|
||||||
|
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
BlComPortInitialize()
|
||||||
|
{
|
||||||
|
EFI_GUID LIPGuid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
|
||||||
|
PEFI_LOADED_IMAGE_PROTOCOL LoadedImage;
|
||||||
|
ULONG PortNumber, BaudRate;
|
||||||
|
PWCHAR Argument, CommandLine, LastArg;
|
||||||
|
EFI_STATUS EfiStatus;
|
||||||
|
XTSTATUS Status;
|
||||||
|
|
||||||
|
/* Set default serial port options */
|
||||||
|
PortNumber = 0;
|
||||||
|
BaudRate = 0;
|
||||||
|
|
||||||
|
/* Handle loaded image protocol */
|
||||||
|
EfiStatus = EfiSystemTable->BootServices->HandleProtocol(EfiImageHandle, &LIPGuid, (PVOID *)&LoadedImage);
|
||||||
|
if(EfiStatus == STATUS_EFI_SUCCESS)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* Check if launched from UEFI shell */
|
||||||
|
if(LoadedImage && LoadedImage->LoadOptions)
|
||||||
|
{
|
||||||
|
/* Store arguments passed from UEFI shell */
|
||||||
|
CommandLine = (PWCHAR)LoadedImage->LoadOptions;
|
||||||
|
|
||||||
|
/* Find command in command line */
|
||||||
|
Argument = RtlWideStringTokenize(CommandLine, L" ", &LastArg);
|
||||||
|
|
||||||
|
/* Iterate over all arguments passed to boot loader */
|
||||||
|
while(Argument != NULL)
|
||||||
|
{
|
||||||
|
/* Check if this is DEBUG parameter */
|
||||||
|
if(RtlWideStringCompare(Argument, L"DEBUG=", 6) == 0)
|
||||||
|
{
|
||||||
|
/* Skip to the argument value */
|
||||||
|
Argument += 6;
|
||||||
|
|
||||||
|
/* Make sure COM port is being used */
|
||||||
|
if(RtlWideStringCompare(Argument, L"COM", 3))
|
||||||
|
{
|
||||||
|
/* Invalid debug port specified */
|
||||||
|
BlEfiPrint(L"ERROR: Invalid debug port specified, falling back to defaults\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read COM port number */
|
||||||
|
Argument += 3;
|
||||||
|
while(*Argument >= '0' && *Argument <= '9')
|
||||||
|
{
|
||||||
|
/* Get port number */
|
||||||
|
PortNumber *= 10;
|
||||||
|
PortNumber += *Argument - '0';
|
||||||
|
Argument++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Look for additional COM port parameters */
|
||||||
|
if(*Argument == ',')
|
||||||
|
{
|
||||||
|
/* Baud rate provided */
|
||||||
|
Argument++;
|
||||||
|
while(*Argument >= '0' && *Argument <= '9')
|
||||||
|
{
|
||||||
|
/* Get baud rate */
|
||||||
|
BaudRate *= 10;
|
||||||
|
BaudRate += *Argument - '0';
|
||||||
|
Argument++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* No need to check next arguments */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Take next argument */
|
||||||
|
Argument = RtlWideStringTokenize(NULL, L" ", &LastArg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialize COM port */
|
||||||
|
Status = HlInitializeComPort(&EfiSerialPort, PortNumber, BaudRate);
|
||||||
|
if(Status != STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
/* Serial port initialization failed, mark as not ready */
|
||||||
|
return STATUS_EFI_NOT_READY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return success */
|
||||||
|
return STATUS_EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes a character to the serial console.
|
||||||
|
*
|
||||||
|
* @param Character
|
||||||
|
* The integer promotion of the character to be written.
|
||||||
|
*
|
||||||
|
* @return This routine does not return any value.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
VOID
|
||||||
|
BlComPortPutChar(IN USHORT Character)
|
||||||
|
{
|
||||||
|
USHORT Buffer[2];
|
||||||
|
|
||||||
|
/* Write character to the serial console */
|
||||||
|
Buffer[0] = Character;
|
||||||
|
Buffer[1] = 0;
|
||||||
|
|
||||||
|
HlComPortPutByte(&EfiSerialPort, Buffer[0]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This routine formats the input string and prints it out to the serial console.
|
* This routine formats the input string and prints it out to the serial console.
|
||||||
*
|
*
|
||||||
|
@ -22,13 +22,16 @@ EXTERN EFI_SYSTEM_TABLE *EfiSystemTable;
|
|||||||
/* Serial port configuration */
|
/* Serial port configuration */
|
||||||
EXTERN CPPORT EfiSerialPort;
|
EXTERN CPPORT EfiSerialPort;
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
BlComPortInitialize();
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
BlComPortPutChar(IN USHORT Character);
|
BlComPortPutChar(IN USHORT Character);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
BlConsoleClearScreen();
|
BlConsoleClearScreen();
|
||||||
|
|
||||||
EFI_STATUS
|
VOID
|
||||||
BlConsoleInitialize();
|
BlConsoleInitialize();
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
@ -18,28 +18,6 @@ PEFI_SYSTEM_TABLE EfiSystemTable;
|
|||||||
/* Serial port configuration */
|
/* Serial port configuration */
|
||||||
CPPORT EfiSerialPort;
|
CPPORT EfiSerialPort;
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes a character to the serial console.
|
|
||||||
*
|
|
||||||
* @param Character
|
|
||||||
* The integer promotion of the character to be written.
|
|
||||||
*
|
|
||||||
* @return This routine does not return any value.
|
|
||||||
*
|
|
||||||
* @since XT 1.0
|
|
||||||
*/
|
|
||||||
VOID
|
|
||||||
BlComPortPutChar(IN USHORT Character)
|
|
||||||
{
|
|
||||||
USHORT Buffer[2];
|
|
||||||
|
|
||||||
/* Write character to the serial console */
|
|
||||||
Buffer[0] = Character;
|
|
||||||
Buffer[1] = 0;
|
|
||||||
|
|
||||||
HlComPortPutByte(&EfiSerialPort, Buffer[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This routine is the entry point of the XT EFI boot loader.
|
* This routine is the entry point of the XT EFI boot loader.
|
||||||
*
|
*
|
||||||
@ -63,22 +41,15 @@ BlStartXtLoader(IN EFI_HANDLE ImageHandle,
|
|||||||
EfiImageHandle = ImageHandle;
|
EfiImageHandle = ImageHandle;
|
||||||
EfiSystemTable = SystemTable;
|
EfiSystemTable = SystemTable;
|
||||||
|
|
||||||
/* Early initialize COM port for debugging (115200 8n1) */
|
/* Initialize EFI console */
|
||||||
Status = HlInitializeComPort(&EfiSerialPort, 1, 0);
|
BlConsoleInitialize();
|
||||||
if(Status != STATUS_SUCCESS)
|
|
||||||
|
/* Early initialize COM port for debugging */
|
||||||
|
Status = BlComPortInitialize();
|
||||||
|
if(Status != STATUS_EFI_SUCCESS)
|
||||||
{
|
{
|
||||||
/* Initialization failed, try printing error to stdout and serial console */
|
/* Initialization failed, try printing error to stdout and serial console */
|
||||||
BlEfiPrint(L"Failed to initialize serial console");
|
BlEfiPrint(L"ERROR: Failed to initialize serial console");
|
||||||
}
|
|
||||||
|
|
||||||
/* Initialize EFI console */
|
|
||||||
Status = BlConsoleInitialize();
|
|
||||||
if(Status != STATUS_EFI_SUCCESS) {
|
|
||||||
/* Initialization failed, try printing error to stdout and serial console */
|
|
||||||
BlEfiPrint(L"Failed to initialize EFI console services");
|
|
||||||
|
|
||||||
/* Consider it as unsupported EFI implementation */
|
|
||||||
return STATUS_EFI_INCOMPATIBLE_VERSION;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Disable watchdog timer */
|
/* Disable watchdog timer */
|
||||||
|
Loading…
Reference in New Issue
Block a user