]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c
Minor code enhancement.
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / IsaSerialDxe / Serial.c
index 6a7713cdaf5f16b3a24d85d0bc2ec59ac0fa04d4..03049180e78a85ade8b0e4f0609e8e5a972a5fc9 100644 (file)
@@ -1,14 +1,14 @@
-/**@file\r
+/** @file\r
   Serial driver for standard UARTS on an ISA bus.\r
 \r
-  Copyright (c) 2006 - 2007, Intel Corporation<BR>\r
-  All rights reserved. This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
+Copyright (c) 2006 - 2010, Intel Corporation<BR>\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
 \r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
 **/\r
 \r
@@ -82,7 +82,7 @@ SERIAL_DEV  gSerialDevTempate = {
   },\r
   FALSE,\r
   FALSE,\r
-  UART16550A,\r
+  Uart16550A,\r
   NULL\r
 };\r
 \r
@@ -125,11 +125,11 @@ InitializeIsaSerial (
 /**\r
   Check to see if this driver supports the given controller\r
 \r
-  @param  This - A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param  Controller - The handle of the controller to test.\r
-  @param  RemainingDevicePath - A pointer to the remaining portion of a device path.\r
+  @param  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param  Controller           The handle of the controller to test.\r
+  @param  RemainingDevicePath  A pointer to the remaining portion of a device path.\r
 \r
-  @return EFI_SUCCESS - This driver can support the given controller\r
+  @return EFI_SUCCESS          This driver can support the given controller\r
 \r
 **/\r
 EFI_STATUS\r
@@ -144,18 +144,66 @@ SerialControllerDriverSupported (
   EFI_STATUS                                Status;\r
   EFI_DEVICE_PATH_PROTOCOL                  *ParentDevicePath;\r
   EFI_ISA_IO_PROTOCOL                       *IsaIo;\r
-  UART_DEVICE_PATH                          UartNode;\r
+  UART_DEVICE_PATH                          *UartNode;\r
 \r
   //\r
-  // Ignore the RemainingDevicePath\r
+  // Check RemainingDevicePath validation\r
   //\r
+  if (RemainingDevicePath != NULL) {\r
+    //\r
+    // Check if RemainingDevicePath is the End of Device Path Node, \r
+    // if yes, go on checking other conditions\r
+    //\r
+    if (!IsDevicePathEnd (RemainingDevicePath)) {\r
+      //\r
+      // If RemainingDevicePath isn't the End of Device Path Node,\r
+      // check its validation\r
+      //\r
+      Status = EFI_UNSUPPORTED;\r
+\r
+      UartNode = (UART_DEVICE_PATH *) RemainingDevicePath;\r
+      if (UartNode->Header.Type != MESSAGING_DEVICE_PATH ||\r
+          UartNode->Header.SubType != MSG_UART_DP ||\r
+          sizeof (UART_DEVICE_PATH) != DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) UartNode)\r
+                                        ) {\r
+        goto Error;\r
+      }\r
+  \r
+      if (UartNode->BaudRate > SERIAL_PORT_MAX_BAUD_RATE) {\r
+        goto Error;\r
+      }\r
+  \r
+      if (UartNode->Parity < NoParity || UartNode->Parity > SpaceParity) {\r
+        goto Error;\r
+      }\r
+  \r
+      if (UartNode->DataBits < 5 || UartNode->DataBits > 8) {\r
+        goto Error;\r
+      }\r
+  \r
+      if (UartNode->StopBits < OneStopBit || UartNode->StopBits > TwoStopBits) {\r
+        goto Error;\r
+      }\r
+  \r
+      if ((UartNode->DataBits == 5) && (UartNode->StopBits == TwoStopBits)) {\r
+        goto Error;\r
+      }\r
+  \r
+      if ((UartNode->DataBits >= 6) && (UartNode->DataBits <= 8) && (UartNode->StopBits == OneFiveStopBits)) {\r
+        goto Error;\r
+      }\r
+  \r
+      Status = EFI_SUCCESS;\r
+    }\r
+  }\r
+\r
   //\r
   // Open the IO Abstraction(s) needed to perform the supported test\r
   //\r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID **) &ParentDevicePath,\r
+                  &gEfiIsaIoProtocolGuid,\r
+                  (VOID **) &IsaIo,\r
                   This->DriverBindingHandle,\r
                   Controller,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
@@ -168,22 +216,27 @@ SerialControllerDriverSupported (
     return Status;\r
   }\r
 \r
+  //\r
+  // Close the I/O Abstraction(s) used to perform the supported test\r
+  //\r
   gBS->CloseProtocol (\r
          Controller,\r
-         &gEfiDevicePathProtocolGuid,\r
+         &gEfiIsaIoProtocolGuid,\r
          This->DriverBindingHandle,\r
          Controller\r
          );\r
 \r
+  //\r
+  // Open the EFI Device Path protocol needed to perform the supported test\r
+  //\r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
-                  &gEfiIsaIoProtocolGuid,\r
-                  (VOID **) &IsaIo,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID **) &ParentDevicePath,\r
                   This->DriverBindingHandle,\r
                   Controller,\r
                   EFI_OPEN_PROTOCOL_BY_DRIVER\r
                   );\r
-\r
   if (Status == EFI_ALREADY_STARTED) {\r
     return EFI_SUCCESS;\r
   }\r
@@ -200,57 +253,14 @@ SerialControllerDriverSupported (
     Status = EFI_UNSUPPORTED;\r
     goto Error;\r
   }\r
-  //\r
-  // Make sure RemainingDevicePath is valid\r
-  //\r
-  if (RemainingDevicePath != NULL) {\r
-    Status = EFI_UNSUPPORTED;\r
-    CopyMem (\r
-      &UartNode,\r
-      (UART_DEVICE_PATH *) RemainingDevicePath,\r
-      sizeof (UART_DEVICE_PATH)\r
-      );\r
-    if (UartNode.Header.Type != MESSAGING_DEVICE_PATH ||\r
-        UartNode.Header.SubType != MSG_UART_DP ||\r
-        sizeof (UART_DEVICE_PATH) != DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) &UartNode)\r
-                                      ) {\r
-      goto Error;\r
-    }\r
-\r
-    if (UartNode.BaudRate > SERIAL_PORT_MAX_BAUD_RATE) {\r
-      goto Error;\r
-    }\r
-\r
-    if (UartNode.Parity < NoParity || UartNode.Parity > SpaceParity) {\r
-      goto Error;\r
-    }\r
-\r
-    if (UartNode.DataBits < 5 || UartNode.DataBits > 8) {\r
-      goto Error;\r
-    }\r
-\r
-    if (UartNode.StopBits < OneStopBit || UartNode.StopBits > TwoStopBits) {\r
-      goto Error;\r
-    }\r
-\r
-    if ((UartNode.DataBits == 5) && (UartNode.StopBits == TwoStopBits)) {\r
-      goto Error;\r
-    }\r
-\r
-    if ((UartNode.DataBits >= 6) && (UartNode.DataBits <= 8) && (UartNode.StopBits == OneFiveStopBits)) {\r
-      goto Error;\r
-    }\r
-\r
-    Status = EFI_SUCCESS;\r
-  }\r
 \r
 Error:\r
   //\r
-  // Close the I/O Abstraction(s) used to perform the supported test\r
+  // Close protocol, don't use device path protocol in the Support() function\r
   //\r
   gBS->CloseProtocol (\r
          Controller,\r
-         &gEfiIsaIoProtocolGuid,\r
+         &gEfiDevicePathProtocolGuid,\r
          This->DriverBindingHandle,\r
          Controller\r
          );\r
@@ -261,11 +271,11 @@ Error:
 /**\r
   Start to management the controller passed in\r
 \r
-  @param  This - A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param  Controller - The handle of the controller to test.\r
-  @param  RemainingDevicePath - A pointer to the remaining portion of a device path.\r
+  @param  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param  Controller           The handle of the controller to test.\r
+  @param  RemainingDevicePath  A pointer to the remaining portion of a device path.\r
 \r
-  @return EFI_SUCCESS - Driver is started successfully\r
+  @return EFI_SUCCESS   Driver is started successfully\r
 \r
 **/\r
 EFI_STATUS\r
@@ -281,11 +291,11 @@ SerialControllerDriverStart (
   EFI_ISA_IO_PROTOCOL                 *IsaIo;\r
   SERIAL_DEV                          *SerialDevice;\r
   UINTN                               Index;\r
-  UART_DEVICE_PATH                    Node;\r
   EFI_DEVICE_PATH_PROTOCOL            *ParentDevicePath;\r
   EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;\r
   UINTN                               EntryCount;\r
   EFI_SERIAL_IO_PROTOCOL              *SerialIo;\r
+  UART_DEVICE_PATH                    *UartNode;\r
 \r
   SerialDevice = NULL;\r
   //\r
@@ -328,9 +338,13 @@ SerialControllerDriverStart (
 \r
   if (Status == EFI_ALREADY_STARTED) {\r
 \r
-    if (RemainingDevicePath == NULL) {\r
+    if (RemainingDevicePath == NULL || IsDevicePathEnd (RemainingDevicePath)) {\r
+      //\r
+      // If RemainingDevicePath is NULL or is the End of Device Path Node\r
+      //\r
       return EFI_SUCCESS;\r
     }\r
+\r
     //\r
     // Make sure a child handle does not already exist.  This driver can only\r
     // produce one child per serial port.\r
@@ -347,7 +361,7 @@ SerialControllerDriverStart (
 \r
     Status = EFI_ALREADY_STARTED;\r
     for (Index = 0; Index < EntryCount; Index++) {\r
-      if (OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) {\r
+      if ((OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {\r
         Status = gBS->OpenProtocol (\r
                         OpenInfoBuffer[Index].ControllerHandle,\r
                         &gEfiSerialIoProtocolGuid,\r
@@ -357,24 +371,35 @@ SerialControllerDriverStart (
                         EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
                         );\r
         if (!EFI_ERROR (Status)) {\r
-          CopyMem (&Node, RemainingDevicePath, sizeof (UART_DEVICE_PATH));\r
+          UartNode = (UART_DEVICE_PATH *) RemainingDevicePath;\r
           Status = SerialIo->SetAttributes (\r
                                SerialIo,\r
-                               Node.BaudRate,\r
+                               UartNode->BaudRate,\r
                                SerialIo->Mode->ReceiveFifoDepth,\r
                                SerialIo->Mode->Timeout,\r
-                               (EFI_PARITY_TYPE) Node.Parity,\r
-                               Node.DataBits,\r
-                               (EFI_STOP_BITS_TYPE) Node.StopBits\r
+                               (EFI_PARITY_TYPE) UartNode->Parity,\r
+                               UartNode->DataBits,\r
+                               (EFI_STOP_BITS_TYPE) UartNode->StopBits\r
                                );\r
         }\r
         break;\r
       }\r
     }\r
 \r
-    gBS->FreePool (OpenInfoBuffer);\r
+    FreePool (OpenInfoBuffer);\r
     return Status;\r
   }\r
+\r
+  if (RemainingDevicePath != NULL) {\r
+    if (IsDevicePathEnd (RemainingDevicePath)) {\r
+      //\r
+      // If RemainingDevicePath is the End of Device Path Node,\r
+      // skip enumerate any device and return EFI_SUCESSS\r
+      // \r
+      return EFI_SUCCESS;\r
+    }\r
+  }\r
+\r
   //\r
   // Initialize the serial device instance\r
   //\r
@@ -388,7 +413,22 @@ SerialControllerDriverStart (
   SerialDevice->IsaIo               = IsaIo;\r
   SerialDevice->ParentDevicePath    = ParentDevicePath;\r
 \r
-  ADD_SERIAL_NAME (SerialDevice, IsaIo);\r
+  //\r
+  // Check if RemainingDevicePath is NULL, \r
+  // if yes, use the values from the gSerialDevTempate as no remaining device path was\r
+  // passed in.\r
+  //\r
+  if (RemainingDevicePath != NULL) {\r
+    //\r
+    // If RemainingDevicePath isn't NULL, \r
+    // match the configuration of the RemainingDevicePath. IsHandleSupported()\r
+    // already checked to make sure the RemainingDevicePath contains settings\r
+    // that we can support.\r
+    //\r
+    CopyMem (&SerialDevice->UartDevicePath, RemainingDevicePath, sizeof (UART_DEVICE_PATH));\r
+  }\r
+\r
+  AddName (SerialDevice, IsaIo);\r
 \r
   for (Index = 0; SerialDevice->IsaIo->ResourceList->ResourceItem[Index].Type != EfiIsaAcpiResourceEndOfList; Index++) {\r
     if (SerialDevice->IsaIo->ResourceList->ResourceItem[Index].Type == EfiIsaAcpiResourceIo) {\r
@@ -414,23 +454,10 @@ SerialControllerDriverStart (
     goto Error;\r
   }\r
 \r
-  if (RemainingDevicePath != NULL) {\r
-    //\r
-    // Match the configuration of the RemainingDevicePath. IsHandleSupported()\r
-    // already checked to make sure the RemainingDevicePath contains settings\r
-    // that we can support.\r
-    //\r
-    CopyMem (&SerialDevice->UartDevicePath, RemainingDevicePath, sizeof (UART_DEVICE_PATH));\r
-  } else {\r
-    //\r
-    // Use the values from the gSerialDevTempate as no remaining device path was\r
-    // passed in.\r
-    //\r
-  }\r
   //\r
-  // Build the device path by appending the UART node to the ParentDevicePath\r
-  // from the WinNtIo handle. The Uart setings are zero here, since\r
-  // SetAttribute() will update them to match the current setings.\r
+  // Build the device path by appending the UART node to the ParentDevicePath.\r
+  //The Uart setings are zero here, since  SetAttribute() will update them to match \r
+  // the default setings.\r
   //\r
   SerialDevice->DevicePath = AppendDevicePathNode (\r
                                ParentDevicePath,\r
@@ -501,8 +528,8 @@ Error:
            This->DriverBindingHandle,\r
            Controller\r
            );\r
-    if (SerialDevice) {\r
-      if (SerialDevice->DevicePath) {\r
+    if (SerialDevice != NULL) {\r
+      if (SerialDevice->DevicePath != NULL) {\r
         gBS->FreePool (SerialDevice->DevicePath);\r
       }\r
 \r
@@ -517,13 +544,13 @@ Error:
 /**\r
   Disconnect this driver with the controller, uninstall related protocol instance\r
 \r
-  @param  This                - A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-  @param  Controller          - The handle of the controller to test.\r
-  @param  NumberOfChildren    - Number of child device.\r
-  @param  ChildHandleBuffer   - A pointer to the remaining portion of a device path.\r
+  @param  This                  A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+  @param  Controller            The handle of the controller to test.\r
+  @param  NumberOfChildren      Number of child device.\r
+  @param  ChildHandleBuffer     A pointer to the remaining portion of a device path.\r
 \r
-  @retval EFI_SUCCESS         - Operation successfully\r
-  @retval EFI_DEVICE_ERROR    - Cannot stop the driver successfully\r
+  @retval EFI_SUCCESS           Operation successfully\r
+  @retval EFI_DEVICE_ERROR      Cannot stop the driver successfully\r
 \r
 **/\r
 EFI_STATUS\r
@@ -624,7 +651,7 @@ SerialControllerDriverStop (
                EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
                );\r
       } else {\r
-        if (SerialDevice->DevicePath) {\r
+        if (SerialDevice->DevicePath != NULL) {\r
           gBS->FreePool (SerialDevice->DevicePath);\r
         }\r
 \r
@@ -646,9 +673,9 @@ SerialControllerDriverStop (
 }\r
 \r
 /**\r
-  Detect whether specific FIFO is full or not\r
+  Detect whether specific FIFO is full or not.\r
 \r
-  @param Fifo  - A pointer to the Data Structure SERIAL_DEV_FIFO\r
+  @param Fifo    A pointer to the Data Structure SERIAL_DEV_FIFO\r
 \r
   @return whether specific FIFO is full or not\r
 \r
@@ -667,10 +694,9 @@ IsaSerialFifoFull (
 }\r
 \r
 /**\r
-  Detect whether specific FIFO is empty or not\r
-\r
+  Detect whether specific FIFO is empty or not.\r
  \r
-  @param  Fifo  - A pointer to the Data Structure SERIAL_DEV_FIFO\r
+  @param  Fifo    A pointer to the Data Structure SERIAL_DEV_FIFO\r
 \r
   @return whether specific FIFO is empty or not\r
 \r
@@ -689,13 +715,13 @@ IsaSerialFifoEmpty (
 }\r
 \r
 /**\r
-  Add data to specific FIFO\r
+  Add data to specific FIFO.\r
 \r
-  @param Fifo                - A pointer to the Data Structure SERIAL_DEV_FIFO\r
-  @param Data                - the data added to FIFO\r
+  @param Fifo                  A pointer to the Data Structure SERIAL_DEV_FIFO\r
+  @param Data                  the data added to FIFO\r
 \r
-  @retval EFI_SUCCESS         - Add data to specific FIFO successfully\r
-  @retval EFI_OUT_OF_RESOURCE - Failed to add data because FIFO is already full\r
+  @retval EFI_SUCCESS           Add data to specific FIFO successfully\r
+  @retval EFI_OUT_OF_RESOURCE   Failed to add data because FIFO is already full\r
 \r
 **/\r
 EFI_STATUS\r
@@ -725,13 +751,13 @@ IsaSerialFifoAdd (
 }\r
 \r
 /**\r
-  Remove data from specific FIFO\r
+  Remove data from specific FIFO.\r
 \r
-  @param Fifo                - A pointer to the Data Structure SERIAL_DEV_FIFO\r
-  @param Data                - the data removed from FIFO\r
+  @param Fifo                  A pointer to the Data Structure SERIAL_DEV_FIFO\r
+  @param Data                  the data removed from FIFO\r
 \r
-  @retval EFI_SUCCESS         - Remove data from specific FIFO successfully\r
-  @retval EFI_OUT_OF_RESOURCE - Failed to remove data because FIFO is empty\r
+  @retval EFI_SUCCESS           Remove data from specific FIFO successfully\r
+  @retval EFI_OUT_OF_RESOURCE   Failed to remove data because FIFO is empty\r
 \r
 **/\r
 EFI_STATUS\r
@@ -763,10 +789,10 @@ IsaSerialFifoRemove (
 /**\r
   Reads and writes all avaliable data.\r
 \r
-  @param SerialDevice         - The device to flush\r
+  @param SerialDevice           The device to flush\r
 \r
-  @retval EFI_SUCCESS         - Data was read/written successfully.\r
-  @retval EFI_OUT_OF_RESOURCE - Failed because software receive FIFO is full.  Note, when\r
+  @retval EFI_SUCCESS           Data was read/written successfully.\r
+  @retval EFI_OUT_OF_RESOURCE   Failed because software receive FIFO is full.  Note, when\r
                                 this happens, pending writes are not done.\r
 \r
 **/\r
@@ -802,47 +828,56 @@ IsaSerialReceiveTransmit (
     } while (!IsaSerialFifoEmpty (&SerialDevice->Transmit));\r
   } else {\r
     ReceiveFifoFull = IsaSerialFifoFull (&SerialDevice->Receive);\r
+    //\r
+    // For full handshake flow control, tell the peer to send data\r
+    // if receive buffer is available.\r
+    //\r
+    if (SerialDevice->HardwareFlowControl &&\r
+        !FeaturePcdGet(PcdIsaBusSerialUseHalfHandshake)&&\r
+        !ReceiveFifoFull\r
+        ) {\r
+      Mcr.Data     = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
+      Mcr.Bits.Rts = 1;\r
+      WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);\r
+    }\r
     do {\r
       Lsr.Data = READ_LSR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
 \r
       //\r
       // Flush incomming data to prevent a an overrun during a long write\r
       //\r
-      if (Lsr.Bits.DR && !ReceiveFifoFull) {\r
+      if ((Lsr.Bits.Dr == 1) && !ReceiveFifoFull) {\r
         ReceiveFifoFull = IsaSerialFifoFull (&SerialDevice->Receive);\r
         if (!ReceiveFifoFull) {\r
-          if (Lsr.Bits.FIFOE || Lsr.Bits.OE || Lsr.Bits.PE || Lsr.Bits.FE || Lsr.Bits.BI) {\r
+          if (Lsr.Bits.FIFOe == 1 || Lsr.Bits.Oe == 1 || Lsr.Bits.Pe == 1 || Lsr.Bits.Fe == 1 || Lsr.Bits.Bi == 1) {\r
             REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
               EFI_ERROR_CODE,\r
               EFI_P_EC_INPUT_ERROR | EFI_PERIPHERAL_SERIAL_PORT,\r
               SerialDevice->DevicePath\r
               );\r
-            if (Lsr.Bits.FIFOE || Lsr.Bits.PE || Lsr.Bits.FE || Lsr.Bits.BI) {\r
+            if (Lsr.Bits.FIFOe == 1 || Lsr.Bits.Pe == 1|| Lsr.Bits.Fe == 1 || Lsr.Bits.Bi == 1) {\r
               Data = READ_RBR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
               continue;\r
             }\r
           }\r
-          //\r
-          // Make sure the receive data will not be missed, Assert DTR\r
-          //\r
-          if (SerialDevice->HardwareFlowControl) {\r
-            Mcr.Data = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-            Mcr.Bits.DTRC &= 0;\r
-            WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);\r
-          }\r
 \r
           Data = READ_RBR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
 \r
+          IsaSerialFifoAdd (&SerialDevice->Receive, Data);\r
+          \r
           //\r
-          // Deassert DTR\r
+          // For full handshake flow control, if receive buffer full\r
+          // tell the peer to stop sending data.\r
           //\r
-          if (SerialDevice->HardwareFlowControl) {\r
-            Mcr.Data = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-            Mcr.Bits.DTRC |= 1;\r
+          if (SerialDevice->HardwareFlowControl &&\r
+              !FeaturePcdGet(PcdIsaBusSerialUseHalfHandshake)   &&\r
+              IsaSerialFifoFull (&SerialDevice->Receive)\r
+              ) {\r
+            Mcr.Data     = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
+            Mcr.Bits.Rts = 0;\r
             WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);\r
           }\r
 \r
-          IsaSerialFifoAdd (&SerialDevice->Receive, Data);\r
 \r
           continue;\r
         } else {\r
@@ -856,23 +891,25 @@ IsaSerialReceiveTransmit (
       //\r
       // Do the write\r
       //\r
-      if (Lsr.Bits.THRE && !IsaSerialFifoEmpty (&SerialDevice->Transmit)) {\r
+      if (Lsr.Bits.Thre == 1 && !IsaSerialFifoEmpty (&SerialDevice->Transmit)) {\r
         //\r
         // Make sure the transmit data will not be missed\r
         //\r
         if (SerialDevice->HardwareFlowControl) {\r
           //\r
-          // Send RTS\r
+          // For half handshake flow control assert RTS before sending.\r
           //\r
-          Mcr.Data = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-          Mcr.Bits.RTS |= 1;\r
-          WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);\r
+          if (FeaturePcdGet(PcdIsaBusSerialUseHalfHandshake)) {\r
+            Mcr.Data     = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
+            Mcr.Bits.Rts= 0;\r
+            WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);\r
+          }\r
           //\r
           // Wait for CTS\r
           //\r
           TimeOut   = 0;\r
           Msr.Data  = READ_MSR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-          while (!Msr.Bits.CTS) {\r
+          while ((Msr.Bits.Dcd == 1) && ((Msr.Bits.Cts == 0) || FeaturePcdGet(PcdIsaBusSerialUseHalfHandshake))) {\r
             gBS->Stall (TIMEOUT_STALL_INTERVAL);\r
             TimeOut++;\r
             if (TimeOut > 5) {\r
@@ -882,31 +919,25 @@ IsaSerialReceiveTransmit (
             Msr.Data = READ_MSR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
           }\r
 \r
-          if (Msr.Bits.CTS) {\r
+          if ((Msr.Bits.Dcd == 0) && ((Msr.Bits.Cts == 1) || FeaturePcdGet(PcdIsaBusSerialUseHalfHandshake))) {\r
             IsaSerialFifoRemove (&SerialDevice->Transmit, &Data);\r
             WRITE_THR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Data);\r
           }\r
-        }\r
-        //\r
-        // write the data out\r
-        //\r
-        if (!SerialDevice->HardwareFlowControl) {\r
-          IsaSerialFifoRemove (&SerialDevice->Transmit, &Data);\r
-          WRITE_THR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Data);\r
-        }\r
-        //\r
-        // Make sure the transmit data will not be missed\r
-        //\r
-        if (SerialDevice->HardwareFlowControl) {\r
+\r
           //\r
-          // Assert RTS\r
+          // For half handshake flow control, tell DCE we are done.\r
           //\r
-          Mcr.Data = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-          Mcr.Bits.RTS &= 0;\r
-          WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);\r
+          if (FeaturePcdGet(PcdIsaBusSerialUseHalfHandshake)) {\r
+            Mcr.Data = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
+            Mcr.Bits.Rts = 1;\r
+            WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);\r
+          }\r
+        } else {\r
+          IsaSerialFifoRemove (&SerialDevice->Transmit, &Data);\r
+          WRITE_THR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Data);\r
         }\r
       }\r
-    } while (Lsr.Bits.THRE && !IsaSerialFifoEmpty (&SerialDevice->Transmit));\r
+    } while (Lsr.Bits.Thre == 1 && !IsaSerialFifoEmpty (&SerialDevice->Transmit));\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -916,12 +947,12 @@ IsaSerialReceiveTransmit (
 // Interface Functions\r
 //\r
 /**\r
-  Reset serial device\r
+  Reset serial device.\r
 \r
-  @param This             - Pointer to EFI_SERIAL_IO_PROTOCOL\r
+  @param This               Pointer to EFI_SERIAL_IO_PROTOCOL\r
 \r
-  @retval EFI_SUCCESS      - Reset successfully\r
-  @retval EFI_DEVICE_ERROR - Failed to reset\r
+  @retval EFI_SUCCESS        Reset successfully\r
+  @retval EFI_DEVICE_ERROR   Failed to reset\r
 \r
 **/\r
 EFI_STATUS\r
@@ -955,32 +986,32 @@ IsaSerialReset (
   // Make sure DLAB is 0.\r
   //\r
   Lcr.Data      = READ_LCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-  Lcr.Bits.DLAB = 0;\r
+  Lcr.Bits.DLab = 0;\r
   WRITE_LCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Lcr.Data);\r
 \r
   //\r
   // Turn off all interrupts\r
   //\r
   Ier.Data        = READ_IER (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-  Ier.Bits.RAVIE  = 0;\r
-  Ier.Bits.THEIE  = 0;\r
-  Ier.Bits.RIE    = 0;\r
-  Ier.Bits.MIE    = 0;\r
+  Ier.Bits.Ravie  = 0;\r
+  Ier.Bits.Theie  = 0;\r
+  Ier.Bits.Rie    = 0;\r
+  Ier.Bits.Mie    = 0;\r
   WRITE_IER (SerialDevice->IsaIo, SerialDevice->BaseAddress, Ier.Data);\r
 \r
   //\r
   // Disable the FIFO.\r
   //\r
-  Fcr.Bits.TRFIFOE = 0;\r
+  Fcr.Bits.TrFIFOE = 0;\r
   WRITE_FCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Fcr.Data);\r
 \r
   //\r
   // Turn off loopback and disable device interrupt.\r
   //\r
   Mcr.Data      = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-  Mcr.Bits.OUT1 = 0;\r
-  Mcr.Bits.OUT2 = 0;\r
-  Mcr.Bits.LME  = 0;\r
+  Mcr.Bits.Out1 = 0;\r
+  Mcr.Bits.Out2 = 0;\r
+  Mcr.Bits.Lme  = 0;\r
   WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);\r
 \r
   //\r
@@ -1020,9 +1051,9 @@ IsaSerialReset (
   //\r
   // for 16550A enable FIFO, 16550 disable FIFO\r
   //\r
-  Fcr.Bits.TRFIFOE  = 1;\r
-  Fcr.Bits.RESETRF  = 1;\r
-  Fcr.Bits.RESETTF  = 1;\r
+  Fcr.Bits.TrFIFOE  = 1;\r
+  Fcr.Bits.ResetRF  = 1;\r
+  Fcr.Bits.ResetTF  = 1;\r
   WRITE_FCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Fcr.Data);\r
 \r
   //\r
@@ -1044,20 +1075,20 @@ IsaSerialReset (
 }\r
 \r
 /**\r
-  Set new attributes to a serial device\r
+  Set new attributes to a serial device.\r
 \r
-  @param This                   - Pointer to EFI_SERIAL_IO_PROTOCOL\r
-  @param  BaudRate               - The baudrate of the serial device\r
-  @param  ReceiveFifoDepth       - The depth of receive FIFO buffer\r
-  @param  Timeout                - The request timeout for a single char\r
-  @param  Parity                 - The type of parity used in serial device\r
-  @param  DataBits               - Number of databits used in serial device\r
-  @param  StopBits               - Number of stopbits used in serial device\r
+  @param This                     Pointer to EFI_SERIAL_IO_PROTOCOL\r
+  @param  BaudRate                 The baudrate of the serial device\r
+  @param  ReceiveFifoDepth         The depth of receive FIFO buffer\r
+  @param  Timeout                  The request timeout for a single char\r
+  @param  Parity                   The type of parity used in serial device\r
+  @param  DataBits                 Number of databits used in serial device\r
+  @param  StopBits                 Number of stopbits used in serial device\r
 \r
-  @retval  EFI_SUCCESS            - The new attributes were set\r
-  @retval  EFI_INVALID_PARAMETERS - One or more attributes have an unsupported value\r
-  @retval  EFI_UNSUPPORTED        - Data Bits can not set to 5 or 6\r
-  @retval  EFI_DEVICE_ERROR       - The serial device is not functioning correctly (no return)\r
+  @retval  EFI_SUCCESS              The new attributes were set\r
+  @retval  EFI_INVALID_PARAMETERS   One or more attributes have an unsupported value\r
+  @retval  EFI_UNSUPPORTED          Data Bits can not set to 5 or 6\r
+  @retval  EFI_DEVICE_ERROR         The serial device is not functioning correctly (no return)\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1184,12 +1215,7 @@ IsaSerialSetAttributes (
   if ((StopBits < OneStopBit) || (StopBits > TwoStopBits)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
-  //\r
-  // for DataBits = 5, StopBits can not set TwoStopBits\r
-  //\r
-  // if ((DataBits == 5) && (StopBits == TwoStopBits)) {\r
-  //  return EFI_INVALID_PARAMETER;\r
-  // }\r
+\r
   //\r
   // for DataBits = 6,7,8, StopBits can not set OneFiveStopBits\r
   //\r
@@ -1205,11 +1231,11 @@ IsaSerialSetAttributes (
                        ((UINT32) BaudRate * 16),\r
                        &Remained\r
                        );\r
-  if (Remained) {\r
+  if (Remained != 0) {\r
     Divisor += 1;\r
   }\r
 \r
-  if ((Divisor == 0) || (Divisor & 0xffff0000)) {\r
+  if ((Divisor == 0) || ((Divisor & 0xffff0000) != 0)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -1224,7 +1250,7 @@ IsaSerialSetAttributes (
   // Put serial port on Divisor Latch Mode\r
   //\r
   Lcr.Data      = READ_LCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-  Lcr.Bits.DLAB = 1;\r
+  Lcr.Bits.DLab = 1;\r
   WRITE_LCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Lcr.Data);\r
 \r
   //\r
@@ -1236,37 +1262,37 @@ IsaSerialSetAttributes (
   //\r
   // Put serial port back in normal mode and set remaining attributes.\r
   //\r
-  Lcr.Bits.DLAB = 0;\r
+  Lcr.Bits.DLab = 0;\r
 \r
   switch (Parity) {\r
   case NoParity:\r
-    Lcr.Bits.PAREN    = 0;\r
-    Lcr.Bits.EVENPAR  = 0;\r
-    Lcr.Bits.STICPAR  = 0;\r
+    Lcr.Bits.ParEn    = 0;\r
+    Lcr.Bits.EvenPar  = 0;\r
+    Lcr.Bits.SticPar  = 0;\r
     break;\r
 \r
   case EvenParity:\r
-    Lcr.Bits.PAREN    = 1;\r
-    Lcr.Bits.EVENPAR  = 1;\r
-    Lcr.Bits.STICPAR  = 0;\r
+    Lcr.Bits.ParEn    = 1;\r
+    Lcr.Bits.EvenPar  = 1;\r
+    Lcr.Bits.SticPar  = 0;\r
     break;\r
 \r
   case OddParity:\r
-    Lcr.Bits.PAREN    = 1;\r
-    Lcr.Bits.EVENPAR  = 0;\r
-    Lcr.Bits.STICPAR  = 0;\r
+    Lcr.Bits.ParEn    = 1;\r
+    Lcr.Bits.EvenPar  = 0;\r
+    Lcr.Bits.SticPar  = 0;\r
     break;\r
 \r
   case SpaceParity:\r
-    Lcr.Bits.PAREN    = 1;\r
-    Lcr.Bits.EVENPAR  = 1;\r
-    Lcr.Bits.STICPAR  = 1;\r
+    Lcr.Bits.ParEn    = 1;\r
+    Lcr.Bits.EvenPar  = 1;\r
+    Lcr.Bits.SticPar  = 1;\r
     break;\r
 \r
   case MarkParity:\r
-    Lcr.Bits.PAREN    = 1;\r
-    Lcr.Bits.EVENPAR  = 0;\r
-    Lcr.Bits.STICPAR  = 1;\r
+    Lcr.Bits.ParEn    = 1;\r
+    Lcr.Bits.EvenPar  = 0;\r
+    Lcr.Bits.SticPar  = 1;\r
     break;\r
 \r
   default:\r
@@ -1275,12 +1301,12 @@ IsaSerialSetAttributes (
 \r
   switch (StopBits) {\r
   case OneStopBit:\r
-    Lcr.Bits.STOPB = 0;\r
+    Lcr.Bits.StopB = 0;\r
     break;\r
 \r
   case OneFiveStopBits:\r
   case TwoStopBits:\r
-    Lcr.Bits.STOPB = 1;\r
+    Lcr.Bits.StopB = 1;\r
     break;\r
 \r
   default:\r
@@ -1289,7 +1315,7 @@ IsaSerialSetAttributes (
   //\r
   // DataBits\r
   //\r
-  Lcr.Bits.SERIALDB = (UINT8) ((DataBits - 5) & 0x03);\r
+  Lcr.Bits.SerialDB = (UINT8) ((DataBits - 5) & 0x03);\r
   WRITE_LCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Lcr.Data);\r
 \r
   //\r
@@ -1343,7 +1369,7 @@ IsaSerialSetAttributes (
     }\r
   }\r
 \r
-  if (SerialDevice->DevicePath) {\r
+  if (SerialDevice->DevicePath != NULL) {\r
     gBS->FreePool (SerialDevice->DevicePath);\r
   }\r
 \r
@@ -1355,13 +1381,13 @@ IsaSerialSetAttributes (
 }\r
 \r
 /**\r
-  Set Control Bits\r
+  Set Control Bits.\r
 \r
-  @param This            - Pointer to EFI_SERIAL_IO_PROTOCOL\r
-  @param Control         - Control bits that can be settable\r
+  @param This              Pointer to EFI_SERIAL_IO_PROTOCOL\r
+  @param Control           Control bits that can be settable\r
 \r
-  @retval EFI_SUCCESS     - New Control bits were set successfully\r
-  @retval EFI_UNSUPPORTED - The Control bits wanted to set are not supported\r
+  @retval EFI_SUCCESS       New Control bits were set successfully\r
+  @retval EFI_UNSUPPORTED   The Control bits wanted to set are not supported\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1387,38 +1413,38 @@ IsaSerialSetControl (
   //\r
   // first determine the parameter is invalid\r
   //\r
-  if (Control & 0xffff8ffc) {\r
+  if ((Control & 0xffff8ffc) != 0) {\r
     return EFI_UNSUPPORTED;\r
   }\r
 \r
   Tpl = gBS->RaiseTPL (TPL_NOTIFY);\r
 \r
   Mcr.Data = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-  Mcr.Bits.DTRC = 0;\r
-  Mcr.Bits.RTS = 0;\r
-  Mcr.Bits.LME = 0;\r
+  Mcr.Bits.DtrC = 0;\r
+  Mcr.Bits.Rts = 0;\r
+  Mcr.Bits.Lme = 0;\r
   SerialDevice->SoftwareLoopbackEnable = FALSE;\r
   SerialDevice->HardwareFlowControl = FALSE;\r
 \r
-  if (Control & EFI_SERIAL_DATA_TERMINAL_READY) {\r
-    Mcr.Bits.DTRC = 1;\r
+  if ((Control & EFI_SERIAL_DATA_TERMINAL_READY) == EFI_SERIAL_DATA_TERMINAL_READY) {\r
+    Mcr.Bits.DtrC = 1;\r
   }\r
 \r
-  if (Control & EFI_SERIAL_REQUEST_TO_SEND) {\r
-    Mcr.Bits.RTS = 1;\r
+  if ((Control & EFI_SERIAL_REQUEST_TO_SEND) == EFI_SERIAL_REQUEST_TO_SEND) {\r
+    Mcr.Bits.Rts = 1;\r
   }\r
 \r
-  if (Control & EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE) {\r
-    Mcr.Bits.LME = 1;\r
+  if ((Control & EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE) == EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE) {\r
+    Mcr.Bits.Lme = 1;\r
   }\r
 \r
-  if (Control & EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE) {\r
+  if ((Control & EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE) == EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE) {\r
     SerialDevice->HardwareFlowControl = TRUE;\r
   }\r
 \r
   WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);\r
 \r
-  if (Control & EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE) {\r
+  if ((Control & EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE) == EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE) {\r
     SerialDevice->SoftwareLoopbackEnable = TRUE;\r
   }\r
 \r
@@ -1428,12 +1454,12 @@ IsaSerialSetControl (
 }\r
 \r
 /**\r
-  Get ControlBits\r
+  Get ControlBits.\r
 \r
-  @param This        - Pointer to EFI_SERIAL_IO_PROTOCOL\r
-  @param Control     - Control signals of the serial device\r
+  @param This          Pointer to EFI_SERIAL_IO_PROTOCOL\r
+  @param Control       Control signals of the serial device\r
 \r
-  @retval EFI_SUCCESS - Get Control signals successfully\r
+  @retval EFI_SUCCESS   Get Control signals successfully\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1459,19 +1485,19 @@ IsaSerialGetControl (
   //\r
   Msr.Data = READ_MSR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
 \r
-  if (Msr.Bits.CTS) {\r
+  if (Msr.Bits.Cts == 1) {\r
     *Control |= EFI_SERIAL_CLEAR_TO_SEND;\r
   }\r
 \r
-  if (Msr.Bits.DSR) {\r
+  if (Msr.Bits.Dsr == 1) {\r
     *Control |= EFI_SERIAL_DATA_SET_READY;\r
   }\r
 \r
-  if (Msr.Bits.RI) {\r
+  if (Msr.Bits.Ri == 1) {\r
     *Control |= EFI_SERIAL_RING_INDICATE;\r
   }\r
 \r
-  if (Msr.Bits.DCD) {\r
+  if (Msr.Bits.Dcd == 1) {\r
     *Control |= EFI_SERIAL_CARRIER_DETECT;\r
   }\r
   //\r
@@ -1479,15 +1505,15 @@ IsaSerialGetControl (
   //\r
   Mcr.Data = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
 \r
-  if (Mcr.Bits.DTRC) {\r
+  if (Mcr.Bits.DtrC == 1) {\r
     *Control |= EFI_SERIAL_DATA_TERMINAL_READY;\r
   }\r
 \r
-  if (Mcr.Bits.RTS) {\r
+  if (Mcr.Bits.Rts == 1) {\r
     *Control |= EFI_SERIAL_REQUEST_TO_SEND;\r
   }\r
 \r
-  if (Mcr.Bits.LME) {\r
+  if (Mcr.Bits.Lme == 1) {\r
     *Control |= EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE;\r
   }\r
 \r
@@ -1521,16 +1547,16 @@ IsaSerialGetControl (
 }\r
 \r
 /**\r
-  Write the specified number of bytes to serial device\r
+  Write the specified number of bytes to serial device.\r
 \r
-  @param This             - Pointer to EFI_SERIAL_IO_PROTOCOL\r
-  @param  BufferSize       - On input the size of Buffer, on output the amount of\r
+  @param This               Pointer to EFI_SERIAL_IO_PROTOCOL\r
+  @param  BufferSize         On input the size of Buffer, on output the amount of\r
                        data actually written\r
-  @param  Buffer           - The buffer of data to write\r
+  @param  Buffer             The buffer of data to write\r
 \r
-  @retval EFI_SUCCESS      - The data were written successfully\r
-  @retval EFI_DEVICE_ERROR - The device reported an error\r
-  @retval EFI_TIMEOUT      - The write operation was stopped due to timeout\r
+  @retval EFI_SUCCESS        The data were written successfully\r
+  @retval EFI_DEVICE_ERROR   The device reported an error\r
+  @retval EFI_TIMEOUT        The write operation was stopped due to timeout\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1556,7 +1582,7 @@ IsaSerialWrite (
     return EFI_SUCCESS;\r
   }\r
 \r
-  if (!Buffer) {\r
+  if (Buffer == NULL) {\r
     REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
       EFI_ERROR_CODE,\r
       EFI_P_EC_OUTPUT_ERROR | EFI_PERIPHERAL_SERIAL_PORT,\r
@@ -1602,16 +1628,16 @@ IsaSerialWrite (
 }\r
 \r
 /**\r
-  Read the specified number of bytes from serial device\r
+  Read the specified number of bytes from serial device.\r
 \r
-  @param This             - Pointer to EFI_SERIAL_IO_PROTOCOL\r
-  @param BufferSize       - On input the size of Buffer, on output the amount of\r
-                       data returned in buffer\r
-  @param Buffer           -  The buffer to return the data into\r
+  @param This               Pointer to EFI_SERIAL_IO_PROTOCOL\r
+  @param BufferSize         On input the size of Buffer, on output the amount of\r
+                            data returned in buffer\r
+  @param Buffer             The buffer to return the data into\r
 \r
-  @retval EFI_SUCCESS      - The data were read successfully\r
-  @retval EFI_DEVICE_ERROR - The device reported an error\r
-  @retval EFI_TIMEOUT      - The read operation was stopped due to timeout\r
+  @retval EFI_SUCCESS        The data were read successfully\r
+  @retval EFI_DEVICE_ERROR   The device reported an error\r
+  @retval EFI_TIMEOUT        The read operation was stopped due to timeout\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1636,7 +1662,7 @@ IsaSerialRead (
     return EFI_SUCCESS;\r
   }\r
 \r
-  if (!Buffer) {\r
+  if (Buffer == NULL) {\r
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
@@ -1696,9 +1722,9 @@ IsaSerialRead (
 }\r
 \r
 /**\r
-  Use scratchpad register to test if this serial port is present\r
+  Use scratchpad register to test if this serial port is present.\r
 \r
-  @param SerialDevice - Pointer to serial device structure\r
+  @param SerialDevice   Pointer to serial device structure\r
 \r
   @return if this serial port is present\r
 **/\r
@@ -1736,11 +1762,11 @@ IsaSerialPortPresent (
 }\r
 \r
 /**\r
-  Use IsaIo protocol to read serial port\r
+  Use IsaIo protocol to read serial port.\r
 \r
-  @param IsaIo       - Pointer to EFI_ISA_IO_PROTOCOL instance\r
-  @param BaseAddress - Serial port register group base address\r
-  @param Offset      - Offset in register group\r
+  @param IsaIo         Pointer to EFI_ISA_IO_PROTOCOL instance\r
+  @param BaseAddress   Serial port register group base address\r
+  @param Offset        Offset in register group\r
 \r
   @return Data read from serial port\r
 \r
@@ -1768,12 +1794,12 @@ IsaSerialReadPort (
 }\r
 \r
 /**\r
-  Use IsaIo protocol to write serial port\r
+  Use IsaIo protocol to write serial port.\r
 \r
-  @param  IsaIo       - Pointer to EFI_ISA_IO_PROTOCOL instance\r
-  @param  BaseAddress - Serial port register group base address\r
-  @param  Offset      - Offset in register group\r
-  @param  Data        - data which is to be written to some serial port register\r
+  @param  IsaIo         Pointer to EFI_ISA_IO_PROTOCOL instance\r
+  @param  BaseAddress   Serial port register group base address\r
+  @param  Offset        Offset in register group\r
+  @param  Data          data which is to be written to some serial port register\r
 \r
 **/\r
 VOID\r