Refactor part 6
All checks were successful
Builds / ExectOS (amd64) (push) Successful in 27s
Builds / ExectOS (i686) (push) Successful in 46s

This commit is contained in:
2023-12-04 16:32:07 +01:00
parent 9a3e0f69fa
commit 2b2efd0dd3
8 changed files with 162 additions and 88 deletions

View File

@@ -43,7 +43,7 @@ BlDebugPrint(IN PUINT16 Format,
}
/* Check if screen debug port is enabled and Boot Services are still available */
if((BlpConfiguration.DebugPort & XTBL_DEBUGPORT_SCREEN) && (EfiSystemTable->BootServices != 0))
if((BlpConfiguration.DebugPort & XTBL_DEBUGPORT_SCREEN) && (BlpStatus.BootServices == TRUE))
{
/* Format and print the string to the screen */
BlpStringPrint(BlpConsolePrintChar, Format, Arguments);
@@ -54,68 +54,6 @@ BlDebugPrint(IN PUINT16 Format,
}
}
/**
* This routine initializes the serial debug console.
*
* @param PortNumber
* Supplies a port number.
*
* @param PortAddress
* Supplies an address of the COM port.
*
* @param BaudRate
* Supplies an optional port baud rate.
*
* @return This routine returns a status code.
*
* @since XT 1.0
*/
XTCDECL
EFI_STATUS
BlpDebugInitializeComPort(IN ULONG PortNumber,
IN ULONG PortAddress,
IN ULONG BaudRate)
{
EFI_STATUS EfiStatus;
XTSTATUS Status;
/* Print debug message depending on port settings */
if(PortAddress)
{
BlConsolePrint(L"Initializing serial console at COM port address: 0x%lx\n", PortAddress);
}
else
{
BlConsolePrint(L"Initializing serial console at port COM%d\n", PortNumber);
}
/* Initialize COM port */
Status = HlInitializeComPort(&BlpSerialPort, PortNumber, UlongToPtr(PortAddress), BaudRate);
/* Port not found under supplied address */
if(Status == STATUS_NOT_FOUND && PortAddress)
{
/* This might be PCI(E) serial controller, try to activate I/O space access first */
EfiStatus = BlpActivateSerialIOController();
if(EfiStatus == STATUS_EFI_SUCCESS)
{
/* Try to reinitialize COM port */
BlConsolePrint(L"Enabled I/O space access for all PCI(E) serial controllers found\n");
Status = HlInitializeComPort(&BlpSerialPort, PortNumber, UlongToPtr(PortAddress), BaudRate);
}
}
/* Check COM port initialization status code */
if(Status != STATUS_SUCCESS)
{
/* Serial port initialization failed, mark as not ready */
return STATUS_EFI_NOT_READY;
}
/* Return success */
return STATUS_EFI_SUCCESS;
}
/**
* This routine initializes the XTLDR debug console.
*
@@ -125,7 +63,7 @@ BlpDebugInitializeComPort(IN ULONG PortNumber,
*/
XTCDECL
EFI_STATUS
BlpDebugInitializeConsole()
BlpInitializeDebugConsole()
{
ULONG PortAddress, PortNumber, BaudRate;
PWCHAR DebugPort, LastPort;
@@ -223,7 +161,7 @@ BlpDebugInitializeConsole()
if(BlpConfiguration.DebugPort & XTBL_DEBUGPORT_SERIAL)
{
/* Try to initialize COM port */
Status = BlpDebugInitializeComPort(PortNumber, PortAddress, BaudRate);
Status = BlpInitializeSerialPort(PortNumber, PortAddress, BaudRate);
if(Status != STATUS_EFI_SUCCESS)
{
/* Remove serial debug port, as COM port initialization failed and return */
@@ -236,6 +174,68 @@ BlpDebugInitializeConsole()
return STATUS_EFI_SUCCESS;
}
/**
* This routine initializes the serial debug console.
*
* @param PortNumber
* Supplies a port number.
*
* @param PortAddress
* Supplies an address of the COM port.
*
* @param BaudRate
* Supplies an optional port baud rate.
*
* @return This routine returns a status code.
*
* @since XT 1.0
*/
XTCDECL
EFI_STATUS
BlpInitializeSerialPort(IN ULONG PortNumber,
IN ULONG PortAddress,
IN ULONG BaudRate)
{
EFI_STATUS EfiStatus;
XTSTATUS Status;
/* Print debug message depending on port settings */
if(PortAddress)
{
BlConsolePrint(L"Initializing serial console at COM port address: 0x%lx\n", PortAddress);
}
else
{
BlConsolePrint(L"Initializing serial console at port COM%d\n", PortNumber);
}
/* Initialize COM port */
Status = HlInitializeComPort(&BlpSerialPort, PortNumber, UlongToPtr(PortAddress), BaudRate);
/* Port not found under supplied address */
if(Status == STATUS_NOT_FOUND && PortAddress)
{
/* This might be PCI(E) serial controller, try to activate I/O space access first */
EfiStatus = BlpActivateSerialIOController();
if(EfiStatus == STATUS_EFI_SUCCESS)
{
/* Try to reinitialize COM port */
BlConsolePrint(L"Enabled I/O space access for all PCI(E) serial controllers found\n");
Status = HlInitializeComPort(&BlpSerialPort, PortNumber, UlongToPtr(PortAddress), BaudRate);
}
}
/* Check COM port initialization status code */
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.
*