]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/SerialDxe: Fix not able to change serial attributes
authorPankaj Bansal <pankaj.bansal@nxp.com>
Mon, 18 Sep 2017 07:42:45 +0000 (15:42 +0800)
committerStar Zeng <star.zeng@intel.com>
Tue, 19 Sep 2017 03:02:56 +0000 (11:02 +0800)
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>
MdeModulePkg/Universal/SerialDxe/SerialIo.c

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