public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Zeng, Star" <star.zeng@intel.com>
To: Pankaj Bansal <pankaj.bansal@nxp.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Ni, Ruiyu" <ruiyu.ni@intel.com>,
	"Laszlo Ersek (lersek@redhat.com)" <lersek@redhat.com>,
	"Zeng, Star" <star.zeng@intel.com>
Subject: Re: [PATCH] Fix not able to change serial attributes
Date: Sat, 16 Sep 2017 01:21:13 +0000	[thread overview]
Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B969DE8@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <decb896fbf1e6f6a9200faef9b8bef817357100a.1505480851.git.pankaj.bansal@nxp.com>

Pankaj,

Thanks for the contribution.
Could you help update the title to be like MdeModulePkg SerialDxe: XXXXXXXXXX?

In fact, I agree the fix as it matches the code at MdeModulePkg/Bus/Pci/PciSioSerialDxe/SerialIo.c and IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c.
But I am curious about how you reproduce the issue by sermode command as I see sermode command only calls SerialIo->SetAttributes() but not SerialIo->Reset().


Ray, Laszlo,
Do you have any comment?



Thanks,
Star
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Pankaj Bansal
Sent: Friday, September 15, 2017 9:14 PM
To: edk2-devel@lists.01.org
Cc: Pankaj Bansal <pankaj.bansal@nxp.com>
Subject: [edk2] [PATCH] Fix not able to change serial attributes

Issue : When try to change serial attributes using sermode command, the default values are set 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>
---
 MdeModulePkg/Universal/SerialDxe/SerialIo.c | 66 ++++++++---------------------
 1 file changed, 18 insertions(+), 48 deletions(-)

diff --git a/MdeModulePkg/Universal/SerialDxe/SerialIo.c b/MdeModulePkg/Universal/SerialDxe/SerialIo.c
index 43d33db..dc7e13a 100644
--- a/MdeModulePkg/Universal/SerialDxe/SerialIo.c
+++ b/MdeModulePkg/Universal/SerialDxe/SerialIo.c
@@ -220,7 +220,6 @@ SerialReset (
   )
 {
   EFI_STATUS    Status;
-  EFI_TPL       Tpl;
 
   Status = SerialPortInitialize ();
   if (EFI_ERROR (Status)) {
@@ -228,49 +227,17 @@ SerialReset (
   }
 
   //
-  // Set the Serial I/O mode and update the device path
-  //
-
-  Tpl = gBS->RaiseTPL (TPL_NOTIFY);
-
-  //
-  // Set the Serial I/O mode
-  //
-  This->Mode->ReceiveFifoDepth  = PcdGet16 (PcdUartDefaultReceiveFifoDepth);
-  This->Mode->Timeout           = 1000 * 1000;
-  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
+  // Go set the current attributes
   //
-  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);
+  Status = This->SetAttributes (
+                   This,
+                   This->Mode->BaudRate,
+                   This->Mode->ReceiveFifoDepth,
+                   This->Mode->Timeout,
+                   (EFI_PARITY_TYPE) This->Mode->Parity,
+                   (UINT8) This->Mode->DataBits,
+                   (EFI_STOP_BITS_TYPE) This->Mode->StopBits
+                   );
 
   return Status;
 }
@@ -513,11 +480,6 @@ SerialDxeInitialize (  {
   EFI_STATUS            Status;
 
-  Status = SerialPortInitialize ();
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
   mSerialIoMode.BaudRate = PcdGet64 (PcdUartDefaultBaudRate);
   mSerialIoMode.DataBits = (UINT32) PcdGet8 (PcdUartDefaultDataBits);
   mSerialIoMode.Parity   = (UINT32) PcdGet8 (PcdUartDefaultParity);
@@ -529,6 +491,14 @@ SerialDxeInitialize (
   mSerialDevicePath.Uart.StopBits = PcdGet8 (PcdUartDefaultStopBits);
 
   //
+  // Issue a reset to initialize the COM 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.
   //
   Status = gBS->InstallMultipleProtocolInterfaces (
--
2.7.4

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


  reply	other threads:[~2017-09-16  1:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-15 13:13 [PATCH] Fix not able to change serial attributes Pankaj Bansal
2017-09-16  1:21 ` Zeng, Star [this message]
2017-09-16 20:17   ` Laszlo Ersek
2017-09-18 10:22     ` Zeng, Star
2017-09-18 10:24       ` Pankaj Bansal
2017-09-18 15:55       ` Laszlo Ersek
2017-09-19  1:57         ` Zeng, Star
2017-09-18  7:42 ` (No subject) Pankaj Bansal
2017-09-18  7:42   ` [PATCH v2] MdeModulePkg/SerialDxe: Fix not able to change serial attributes Pankaj Bansal
2017-09-18 10:11     ` Zeng, Star
2017-09-19  3:00       ` Zeng, Star
2017-09-19  3:05         ` Pankaj Bansal
2017-09-19  3:22           ` Zeng, Star

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0C09AFA07DD0434D9E2A0C6AEB0483103B969DE8@shsmsx102.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox