MdeModulePkg/SerialDxe: Fix not able to change serial attributes

Issue : When try to change serial attributes using sermode
command, the default values are set with the execute flow
as below.

The sermode command calls SerialSetAttributes, which sets H/W
attributes of Serial device. After that the SerialIo protocol is
reinstalled, which causes MdeModulePkg/Universal/Console/TerminalDxe
and MdeModulePkg/Universal/Console/ConPlatformDxe drivers' bindings
to stop and then start. This in turn calls SerialReset, which undoes
changes of SerialSetAttributes.

Cause : The SerialReset command resets the attributes' values
to default.
Fix : Serial Reset command should set the attributes which have
been changed by user after calling SerialSetAttributes.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Pankaj Bansal <pankaj.bansal@nxp.com>
Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
This commit is contained in:
Pankaj Bansal 2017-09-18 15:42:45 +08:00 committed by Star Zeng
parent 7f2f96f1a8
commit 91cc526b15
1 changed files with 18 additions and 48 deletions

View File

@ -220,7 +220,6 @@ SerialReset (
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_TPL Tpl;
Status = SerialPortInitialize (); Status = SerialPortInitialize ();
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -228,50 +227,18 @@ SerialReset (
} }
// //
// Set the Serial I/O mode and update the device path // Go set the current attributes
// //
Status = This->SetAttributes (
Tpl = gBS->RaiseTPL (TPL_NOTIFY); This,
This->Mode->BaudRate,
// This->Mode->ReceiveFifoDepth,
// Set the Serial I/O mode This->Mode->Timeout,
// (EFI_PARITY_TYPE) This->Mode->Parity,
This->Mode->ReceiveFifoDepth = PcdGet16 (PcdUartDefaultReceiveFifoDepth); (UINT8) This->Mode->DataBits,
This->Mode->Timeout = 1000 * 1000; (EFI_STOP_BITS_TYPE) This->Mode->StopBits
This->Mode->BaudRate = PcdGet64 (PcdUartDefaultBaudRate);
This->Mode->DataBits = (UINT32) PcdGet8 (PcdUartDefaultDataBits);
This->Mode->Parity = (UINT32) PcdGet8 (PcdUartDefaultParity);
This->Mode->StopBits = (UINT32) PcdGet8 (PcdUartDefaultStopBits);
//
// Check if the device path has actually changed
//
if (mSerialDevicePath.Uart.BaudRate == This->Mode->BaudRate &&
mSerialDevicePath.Uart.DataBits == (UINT8) This->Mode->DataBits &&
mSerialDevicePath.Uart.Parity == (UINT8) This->Mode->Parity &&
mSerialDevicePath.Uart.StopBits == (UINT8) This->Mode->StopBits
) {
gBS->RestoreTPL (Tpl);
return EFI_SUCCESS;
}
//
// Update the device path
//
mSerialDevicePath.Uart.BaudRate = This->Mode->BaudRate;
mSerialDevicePath.Uart.DataBits = (UINT8) This->Mode->DataBits;
mSerialDevicePath.Uart.Parity = (UINT8) This->Mode->Parity;
mSerialDevicePath.Uart.StopBits = (UINT8) This->Mode->StopBits;
Status = gBS->ReinstallProtocolInterface (
mSerialHandle,
&gEfiDevicePathProtocolGuid,
&mSerialDevicePath,
&mSerialDevicePath
); );
gBS->RestoreTPL (Tpl);
return Status; return Status;
} }
@ -513,11 +480,6 @@ SerialDxeInitialize (
{ {
EFI_STATUS Status; EFI_STATUS Status;
Status = SerialPortInitialize ();
if (EFI_ERROR (Status)) {
return Status;
}
mSerialIoMode.BaudRate = PcdGet64 (PcdUartDefaultBaudRate); mSerialIoMode.BaudRate = PcdGet64 (PcdUartDefaultBaudRate);
mSerialIoMode.DataBits = (UINT32) PcdGet8 (PcdUartDefaultDataBits); mSerialIoMode.DataBits = (UINT32) PcdGet8 (PcdUartDefaultDataBits);
mSerialIoMode.Parity = (UINT32) PcdGet8 (PcdUartDefaultParity); mSerialIoMode.Parity = (UINT32) PcdGet8 (PcdUartDefaultParity);
@ -528,6 +490,14 @@ SerialDxeInitialize (
mSerialDevicePath.Uart.Parity = PcdGet8 (PcdUartDefaultParity); mSerialDevicePath.Uart.Parity = PcdGet8 (PcdUartDefaultParity);
mSerialDevicePath.Uart.StopBits = PcdGet8 (PcdUartDefaultStopBits); mSerialDevicePath.Uart.StopBits = PcdGet8 (PcdUartDefaultStopBits);
//
// Issue a reset to initialize the Serial Port
//
Status = mSerialIoTemplate.Reset (&mSerialIoTemplate);
if (EFI_ERROR (Status)) {
return Status;
}
// //
// Make a new handle with Serial IO protocol and its device path on it. // Make a new handle with Serial IO protocol and its device path on it.
// //