forked from xt-sys/exectos
Refactor COM port support, to get rid of global variables in library
This commit is contained in:
@@ -232,18 +232,35 @@ BlpInitializeSerialPort(IN ULONG PortNumber,
|
||||
EFI_STATUS EfiStatus;
|
||||
XTSTATUS Status;
|
||||
|
||||
/* Print debug message depending on port settings */
|
||||
if(PortAddress)
|
||||
/* Check if custom COM port address supplied */
|
||||
if(!PortAddress)
|
||||
{
|
||||
BlConsolePrint(L"Initializing serial console at COM port address: 0x%lX\n", PortAddress);
|
||||
/* We support only a pre-defined number of ports */
|
||||
if(PortNumber > COMPORT_COUNT)
|
||||
{
|
||||
/* Fail if wrong/unsupported port used */
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
/* Check if serial port is set */
|
||||
if(PortNumber == 0)
|
||||
{
|
||||
/* Use COM1 by default */
|
||||
PortNumber = 1;
|
||||
}
|
||||
|
||||
/* Set custom port address based on the port number and print debug message */
|
||||
PortAddress = BlComPortList[PortNumber - 1];
|
||||
BlConsolePrint(L"Initializing serial console at port COM%d\n", PortNumber);
|
||||
}
|
||||
else
|
||||
{
|
||||
BlConsolePrint(L"Initializing serial console at port COM%d\n", PortNumber);
|
||||
/* Custom port address supplied, print debug message */
|
||||
BlConsolePrint(L"Initializing serial console at COM port address: 0x%lX\n", PortAddress);
|
||||
}
|
||||
|
||||
/* Initialize COM port */
|
||||
Status = HlInitializeComPort(&BlpStatus.SerialPort, PortNumber, UlongToPtr(PortAddress), BaudRate);
|
||||
Status = HlInitializeComPort(&BlpStatus.SerialPort, UlongToPtr(PortAddress), BaudRate);
|
||||
|
||||
/* Port not found under supplied address */
|
||||
if(Status == STATUS_NOT_FOUND && PortAddress)
|
||||
@@ -254,7 +271,7 @@ BlpInitializeSerialPort(IN ULONG PortNumber,
|
||||
{
|
||||
/* Try to reinitialize COM port */
|
||||
BlConsolePrint(L"Enabled I/O space access for all PCI(E) serial controllers found\n");
|
||||
Status = HlInitializeComPort(&BlpStatus.SerialPort, PortNumber, UlongToPtr(PortAddress), BaudRate);
|
||||
Status = HlInitializeComPort(&BlpStatus.SerialPort, UlongToPtr(PortAddress), BaudRate);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -12,6 +12,9 @@
|
||||
/* XT Boot Loader registered boot protocol list */
|
||||
LIST_ENTRY BlpBootProtocols;
|
||||
|
||||
/* XT Boot Loader serial ports list */
|
||||
ULONG BlComPortList[COMPORT_COUNT] = COMPORT_ADDRESS;
|
||||
|
||||
/* XT Boot Loader configuration list */
|
||||
LIST_ENTRY BlpConfig;
|
||||
|
||||
|
@@ -15,6 +15,9 @@
|
||||
/* XT Boot Loader registered boot protocol list */
|
||||
EXTERN LIST_ENTRY BlpBootProtocols;
|
||||
|
||||
/* XT Boot Loader serial ports list */
|
||||
EXTERN ULONG BlComPortList[COMPORT_COUNT];
|
||||
|
||||
/* XT Boot Loader configuration list */
|
||||
EXTERN LIST_ENTRY BlpConfig;
|
||||
|
||||
|
Reference in New Issue
Block a user