Refactor part 6
This commit is contained in:
130
xtldr2/debug.c
130
xtldr2/debug.c
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user