]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c
Update code style.
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / IsaSerialDxe / Serial.c
index b21f635feed670cd76278f4fcb896082191a4591..f9d08ce3a0cc6831973b14408b13102d21c9471b 100644 (file)
@@ -1,14 +1,14 @@
-/**@file\r
-       Serial driver for standard UARTS on an ISA bus.\r
-\r
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved. <BR>\r
-This software and associated documentation (if any) is furnished\r
-under a license and may only be used or copied in accordance\r
-with the terms of the license. Except as permitted by such\r
-license, no part of this software or documentation may be\r
-reproduced, stored in a retrieval system, or transmitted in any\r
-form or by any means without the express written consent of\r
-Intel Corporation.\r
+/** @file\r
+  Serial driver for standard UARTS on an ISA bus.\r
+\r
+Copyright (c) 2006 - 2009, 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
 \r
 **/\r
 \r
@@ -27,6 +27,65 @@ EFI_DRIVER_BINDING_PROTOCOL gSerialControllerDriver = {
 };\r
 \r
 \r
+SERIAL_DEV  gSerialDevTempate = {\r
+  SERIAL_DEV_SIGNATURE,\r
+  NULL,\r
+  { // SerialIo\r
+    SERIAL_IO_INTERFACE_REVISION,\r
+    IsaSerialReset,\r
+    IsaSerialSetAttributes,\r
+    IsaSerialSetControl,\r
+    IsaSerialGetControl,\r
+    IsaSerialWrite,\r
+    IsaSerialRead,\r
+    NULL\r
+  },\r
+  { // SerialMode\r
+    SERIAL_PORT_DEFAULT_CONTROL_MASK,\r
+    SERIAL_PORT_DEFAULT_TIMEOUT,\r
+    FixedPcdGet64 (PcdUartDefaultBaudRate),     // BaudRate\r
+    SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH,\r
+    FixedPcdGet8 (PcdUartDefaultDataBits),      // DataBits\r
+    FixedPcdGet8 (PcdUartDefaultParity),        // Parity\r
+    FixedPcdGet8 (PcdUartDefaultStopBits)       // StopBits\r
+  },\r
+  NULL,\r
+  NULL,\r
+  { // UartDevicePath\r
+    {\r
+      MESSAGING_DEVICE_PATH,\r
+      MSG_UART_DP,\r
+      {\r
+        (UINT8) (sizeof (UART_DEVICE_PATH)),\r
+        (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8)\r
+      }\r
+    },\r
+    0,\r
+    FixedPcdGet64 (PcdUartDefaultBaudRate),    \r
+    FixedPcdGet8 (PcdUartDefaultDataBits),\r
+    FixedPcdGet8 (PcdUartDefaultParity),\r
+    FixedPcdGet8 (PcdUartDefaultStopBits)\r
+  },\r
+  NULL,\r
+  0,    //BaseAddress\r
+  {\r
+    0,\r
+    0,\r
+    SERIAL_MAX_BUFFER_SIZE,\r
+    { 0 }\r
+  },\r
+  {\r
+    0,\r
+    0,\r
+    SERIAL_MAX_BUFFER_SIZE,\r
+    { 0 }\r
+  },\r
+  FALSE,\r
+  FALSE,\r
+  Uart16550A,\r
+  NULL\r
+};\r
+\r
 /**\r
   The user Entry Point for module IsaSerial. The user code starts with this function.\r
 \r
@@ -39,7 +98,7 @@ EFI_DRIVER_BINDING_PROTOCOL gSerialControllerDriver = {
 **/\r
 EFI_STATUS\r
 EFIAPI\r
-InitializeIsaSerial(\r
+InitializeIsaSerial (\r
   IN EFI_HANDLE           ImageHandle,\r
   IN EFI_SYSTEM_TABLE     *SystemTable\r
   )\r
@@ -49,14 +108,13 @@ InitializeIsaSerial(
   //\r
   // Install driver model protocol(s).\r
   //\r
-  Status = EfiLibInstallAllDriverProtocols (\r
+  Status = EfiLibInstallDriverBindingComponentName2 (\r
              ImageHandle,\r
              SystemTable,\r
              &gSerialControllerDriver,\r
              ImageHandle,\r
              &gIsaSerialComponentName,\r
-             NULL,\r
-             NULL\r
+             &gIsaSerialComponentName2\r
              );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
@@ -64,7 +122,16 @@ InitializeIsaSerial(
   return Status;\r
 }\r
 \r
+/**\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
 \r
+  @return EFI_SUCCESS          This driver can support the given controller\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 SerialControllerDriverSupported (\r
@@ -72,23 +139,7 @@ SerialControllerDriverSupported (
   IN EFI_HANDLE                     Controller,\r
   IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-    Check to see if this driver supports the given controller\r
-\r
-  Arguments:\r
-\r
-    This - A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-    Controller - The handle of the controller to test.\r
-    RemainingDevicePath - A pointer to the remaining portion of a device path.\r
-\r
-  Returns:\r
 \r
-    EFI_SUCCESS - This driver can support the given controller\r
-\r
---*/\r
 {\r
   EFI_STATUS                                Status;\r
   EFI_DEVICE_PATH_PROTOCOL                  *ParentDevicePath;\r
@@ -207,6 +258,16 @@ Error:
   return Status;\r
 }\r
 \r
+/**\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
+\r
+  @return EFI_SUCCESS   Driver is started successfully\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 SerialControllerDriverStart (\r
@@ -214,23 +275,7 @@ SerialControllerDriverStart (
   IN EFI_HANDLE                     Controller,\r
   IN EFI_DEVICE_PATH_PROTOCOL       *RemainingDevicePath\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
 \r
-    Start to management the controller passed in\r
-\r
-  Arguments:\r
-\r
-    This - A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-    Controller - The handle of the controller to test.\r
-    RemainingDevicePath - A pointer to the remaining portion of a device path.\r
-\r
-  Returns:\r
-\r
-    EFI_SUCCESS - Driver is started successfully\r
-\r
---*/\r
 {\r
   EFI_STATUS                          Status;\r
   EFI_ISA_IO_PROTOCOL                 *IsaIo;\r
@@ -333,19 +378,17 @@ SerialControllerDriverStart (
   //\r
   // Initialize the serial device instance\r
   //\r
-  SerialDevice = AllocatePool (sizeof (SERIAL_DEV));\r
+  SerialDevice = AllocateCopyPool (sizeof (SERIAL_DEV), &gSerialDevTempate);\r
   if (SerialDevice == NULL) {\r
     Status = EFI_OUT_OF_RESOURCES;\r
     goto Error;\r
   }\r
 \r
-  ZeroMem (SerialDevice, sizeof (SERIAL_DEV));\r
-\r
+  SerialDevice->SerialIo.Mode       = &(SerialDevice->SerialMode);\r
   SerialDevice->IsaIo               = IsaIo;\r
   SerialDevice->ParentDevicePath    = ParentDevicePath;\r
-  SerialDevice->ControllerNameTable = NULL;\r
 \r
-  ADD_SERIAL_NAME (SerialDevice, IsaIo);\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
@@ -371,30 +414,6 @@ SerialControllerDriverStart (
     goto Error;\r
   }\r
 \r
-  SerialDevice->Signature               = SERIAL_DEV_SIGNATURE;\r
-  SerialDevice->Type                    = UART16550A;\r
-  SerialDevice->SoftwareLoopbackEnable  = FALSE;\r
-  SerialDevice->HardwareFlowControl     = FALSE;\r
-  SerialDevice->Handle                  = NULL;\r
-  SerialDevice->Receive.First           = 0;\r
-  SerialDevice->Receive.Last            = 0;\r
-  SerialDevice->Receive.Surplus         = SERIAL_MAX_BUFFER_SIZE;\r
-  SerialDevice->Transmit.First          = 0;\r
-  SerialDevice->Transmit.Last           = 0;\r
-  SerialDevice->Transmit.Surplus        = SERIAL_MAX_BUFFER_SIZE;\r
-\r
-  //\r
-  // Serial I/O\r
-  //\r
-  SerialDevice->SerialIo.Revision       = SERIAL_IO_INTERFACE_REVISION;\r
-  SerialDevice->SerialIo.Reset          = IsaSerialReset;\r
-  SerialDevice->SerialIo.SetAttributes  = IsaSerialSetAttributes;\r
-  SerialDevice->SerialIo.SetControl     = IsaSerialSetControl;\r
-  SerialDevice->SerialIo.GetControl     = IsaSerialGetControl;\r
-  SerialDevice->SerialIo.Write          = IsaSerialWrite;\r
-  SerialDevice->SerialIo.Read           = IsaSerialRead;\r
-  SerialDevice->SerialIo.Mode           = &(SerialDevice->SerialMode);\r
-\r
   if (RemainingDevicePath != NULL) {\r
     //\r
     // Match the configuration of the RemainingDevicePath. IsHandleSupported()\r
@@ -404,14 +423,9 @@ SerialControllerDriverStart (
     CopyMem (&SerialDevice->UartDevicePath, RemainingDevicePath, sizeof (UART_DEVICE_PATH));\r
   } else {\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 default setings.\r
+    // Use the values from the gSerialDevTempate as no remaining device path was\r
+    // passed in.\r
     //\r
-    ZeroMem (&SerialDevice->UartDevicePath, sizeof (UART_DEVICE_PATH));\r
-    SerialDevice->UartDevicePath.Header.Type    = MESSAGING_DEVICE_PATH;\r
-    SerialDevice->UartDevicePath.Header.SubType = MSG_UART_DP;\r
-    SetDevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) &SerialDevice->UartDevicePath, sizeof (UART_DEVICE_PATH));\r
   }\r
   //\r
   // Build the device path by appending the UART node to the ParentDevicePath\r
@@ -420,20 +434,17 @@ SerialControllerDriverStart (
   //\r
   SerialDevice->DevicePath = AppendDevicePathNode (\r
                                ParentDevicePath,\r
-                               (EFI_DEVICE_PATH_PROTOCOL *) &SerialDevice->UartDevicePath\r
+                               (EFI_DEVICE_PATH_PROTOCOL *)&SerialDevice->UartDevicePath\r
                                );\r
-\r
   if (SerialDevice->DevicePath == NULL) {\r
     Status = EFI_DEVICE_ERROR;\r
     goto Error;\r
   }\r
+\r
   //\r
   // Fill in Serial I/O Mode structure based on either the RemainingDevicePath or defaults.\r
   //\r
-  SerialDevice->SerialMode.ControlMask      = SERIAL_PORT_DEFAULT_CONTROL_MASK;\r
-  SerialDevice->SerialMode.Timeout          = SERIAL_PORT_DEFAULT_TIMEOUT;\r
   SerialDevice->SerialMode.BaudRate         = SerialDevice->UartDevicePath.BaudRate;\r
-  SerialDevice->SerialMode.ReceiveFifoDepth = SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH;\r
   SerialDevice->SerialMode.DataBits         = SerialDevice->UartDevicePath.DataBits;\r
   SerialDevice->SerialMode.Parity           = SerialDevice->UartDevicePath.Parity;\r
   SerialDevice->SerialMode.StopBits         = SerialDevice->UartDevicePath.StopBits;\r
@@ -490,8 +501,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
@@ -503,6 +514,18 @@ Error:
   return Status;\r
 }\r
 \r
+/**\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
+\r
+  @retval EFI_SUCCESS           Operation successfully\r
+  @retval EFI_DEVICE_ERROR      Cannot stop the driver successfully\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 SerialControllerDriverStop (\r
@@ -511,25 +534,7 @@ SerialControllerDriverStop (
   IN  UINTN                          NumberOfChildren,\r
   IN  EFI_HANDLE                     *ChildHandleBuffer\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-    Disconnect this driver with the controller, uninstall related protocol instance\r
-\r
-  Arguments:\r
-\r
-    This                - A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
-    Controller          - The handle of the controller to test.\r
-    NumberOfChildren    - Number of child device.\r
-    RemainingDevicePath - A pointer to the remaining portion of a device path.\r
 \r
-  Returns:\r
-\r
-    EFI_SUCCESS         - Operation successfully\r
-    EFI_DEVICE_ERROR    - Cannot stop the driver successfully\r
-\r
---*/\r
 {\r
   EFI_STATUS                          Status;\r
   UINTN                               Index;\r
@@ -619,7 +624,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
@@ -640,26 +645,19 @@ SerialControllerDriverStop (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Detect whether specific FIFO is full or not.\r
+\r
+  @param Fifo    A pointer to the Data Structure SERIAL_DEV_FIFO\r
+\r
+  @return whether specific FIFO is full or not\r
+\r
+**/\r
 BOOLEAN\r
 IsaSerialFifoFull (\r
   IN SERIAL_DEV_FIFO *Fifo\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-    Detect whether specific FIFO is full or not\r
-\r
-  Arguments:\r
-\r
-    Fifo  - A pointer to the Data Structure SERIAL_DEV_FIFO\r
-\r
-  Returns:\r
-\r
-    TRUE  - the FIFO is full\r
-    FALSE - the FIFO is not full\r
 \r
---*/\r
 {\r
   if (Fifo->Surplus == 0) {\r
     return TRUE;\r
@@ -668,26 +666,19 @@ IsaSerialFifoFull (
   return FALSE;\r
 }\r
 \r
+/**\r
+  Detect whether specific FIFO is empty or not.\r
\r
+  @param  Fifo    A pointer to the Data Structure SERIAL_DEV_FIFO\r
+\r
+  @return whether specific FIFO is empty or not\r
+\r
+**/\r
 BOOLEAN\r
 IsaSerialFifoEmpty (\r
   IN SERIAL_DEV_FIFO *Fifo\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-    Detect whether specific FIFO is empty or not\r
-\r
-  Arguments:\r
 \r
-    Fifo  - A pointer to the Data Structure SERIAL_DEV_FIFO\r
-\r
-  Returns:\r
-\r
-    TRUE  - the FIFO is empty\r
-    FALSE - the FIFO is not empty\r
-\r
---*/\r
 {\r
   if (Fifo->Surplus == SERIAL_MAX_BUFFER_SIZE) {\r
     return TRUE;\r
@@ -696,28 +687,22 @@ IsaSerialFifoEmpty (
   return FALSE;\r
 }\r
 \r
+/**\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
+\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
 IsaSerialFifoAdd (\r
   IN SERIAL_DEV_FIFO *Fifo,\r
   IN UINT8           Data\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-    Add data to specific FIFO\r
-\r
-  Arguments:\r
-\r
-    Fifo                - A pointer to the Data Structure SERIAL_DEV_FIFO\r
-    Data                - the data added to FIFO\r
-\r
-  Returns:\r
-\r
-    EFI_SUCCESS         - Add data to specific FIFO successfully\r
-    EFI_OUT_OF_RESOURCE - Failed to add data because FIFO is already full\r
 \r
---*/\r
 {\r
   //\r
   // if FIFO full can not add data\r
@@ -738,27 +723,22 @@ IsaSerialFifoAdd (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\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
+\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
 IsaSerialFifoRemove (\r
   IN  SERIAL_DEV_FIFO *Fifo,\r
   OUT UINT8           *Data\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-    Remove data from specific FIFO\r
 \r
-  Arguments:\r
-\r
-    Fifo                - A pointer to the Data Structure SERIAL_DEV_FIFO\r
-    Data                - the data removed from FIFO\r
-\r
-  Returns:\r
-    EFI_SUCCESS         - Remove data from specific FIFO successfully\r
-    EFI_OUT_OF_RESOURCE - Failed to remove data because FIFO is empty\r
-\r
---*/\r
 {\r
   //\r
   // if FIFO is empty, no data can remove\r
@@ -779,27 +759,21 @@ IsaSerialFifoRemove (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Reads and writes all avaliable data.\r
+\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
+                                this happens, pending writes are not done.\r
+\r
+**/\r
 EFI_STATUS\r
 IsaSerialReceiveTransmit (\r
   IN SERIAL_DEV *SerialDevice\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-    Reads and writes all avaliable data.\r
-\r
-  Arguments:\r
-\r
-    SerialDevice        - The device to flush\r
-\r
-  Returns:\r
-\r
-    EFI_SUCCESS         - Data was read/written successfully.\r
-    EFI_OUT_OF_RESOURCE - Failed because software receive FIFO is full.  Note, when\r
-                          this happens, pending writes are not done.\r
 \r
---*/\r
 {\r
   SERIAL_PORT_LSR Lsr;\r
   UINT8           Data;\r
@@ -830,27 +804,19 @@ IsaSerialReceiveTransmit (
     do {\r
       Lsr.Data = READ_LSR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
 \r
-      if (FeaturePcdGet (PcdNtEmulatorEnable)) {\r
-        //\r
-        // This is required for NT to avoid a forever-spin...\r
-        // This would be better if READ_LSR was a polling operation\r
-        // that would timeout.\r
-        //\r
-        Lsr.Bits.THRE = 1;\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
@@ -860,7 +826,7 @@ IsaSerialReceiveTransmit (
           //\r
           if (SerialDevice->HardwareFlowControl) {\r
             Mcr.Data = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-            Mcr.Bits.DTRC &= 0;\r
+            Mcr.Bits.DtrC &= 0;\r
             WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);\r
           }\r
 \r
@@ -871,7 +837,7 @@ IsaSerialReceiveTransmit (
           //\r
           if (SerialDevice->HardwareFlowControl) {\r
             Mcr.Data = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-            Mcr.Bits.DTRC |= 1;\r
+            Mcr.Bits.DtrC |= 1;\r
             WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);\r
           }\r
 \r
@@ -889,7 +855,7 @@ 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
@@ -898,14 +864,14 @@ IsaSerialReceiveTransmit (
           // Send RTS\r
           //\r
           Mcr.Data = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-          Mcr.Bits.RTS |= 1;\r
+          Mcr.Bits.Rts |= 1;\r
           WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);\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.Cts == 0) {\r
             gBS->Stall (TIMEOUT_STALL_INTERVAL);\r
             TimeOut++;\r
             if (TimeOut > 5) {\r
@@ -915,7 +881,7 @@ IsaSerialReceiveTransmit (
             Msr.Data = READ_MSR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
           }\r
 \r
-          if (Msr.Bits.CTS) {\r
+          if (Msr.Bits.Cts == 1) {\r
             IsaSerialFifoRemove (&SerialDevice->Transmit, &Data);\r
             WRITE_THR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Data);\r
           }\r
@@ -935,39 +901,33 @@ IsaSerialReceiveTransmit (
           // Assert RTS\r
           //\r
           Mcr.Data = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
-          Mcr.Bits.RTS &= 0;\r
+          Mcr.Bits.Rts &= 0;\r
           WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.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
 }\r
+\r
 //\r
 // Interface Functions\r
 //\r
+/**\r
+  Reset serial device.\r
+\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
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 IsaSerialReset (\r
   IN EFI_SERIAL_IO_PROTOCOL  *This\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-    Reset serial device\r
-\r
-  Arguments:\r
-\r
-    This             - Pointer to EFI_SERIAL_IO_PROTOCOL\r
-\r
-  Returns:\r
-\r
-    EFI_SUCCESS      - Reset successfully\r
-    EFI_DEVICE_ERROR - Failed to reset\r
-\r
---*/\r
 {\r
   EFI_STATUS      Status;\r
   SERIAL_DEV      *SerialDevice;\r
@@ -994,32 +954,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
@@ -1059,9 +1019,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
@@ -1082,6 +1042,23 @@ IsaSerialReset (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\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
+\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
 EFIAPI\r
 IsaSerialSetAttributes (\r
@@ -1093,30 +1070,6 @@ IsaSerialSetAttributes (
   IN UINT8                   DataBits,\r
   IN EFI_STOP_BITS_TYPE      StopBits\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-    Set new attributes to a serial device\r
-\r
-  Arguments:\r
-\r
-    This                   - Pointer to EFI_SERIAL_IO_PROTOCOL\r
-    BaudRate               - The baudrate of the serial device\r
-    ReceiveFifoDepth       - The depth of receive FIFO buffer\r
-    Timeout                - The request timeout for a single char\r
-    Parity                 - The type of parity used in serial device\r
-    DataBits               - Number of databits used in serial device\r
-    StopBits               - Number of stopbits used in serial device\r
-\r
-  Returns:\r
-\r
-    EFI_SUCCESS            - The new attributes were set\r
-    EFI_INVALID_PARAMETERS - One or more attributes have an unsupported value\r
-    EFI_UNSUPPORTED        - Data Bits can not set to 5 or 6\r
-    EFI_DEVICE_ERROR       - The serial device is not functioning correctly (no return)\r
-\r
---*/\r
 {\r
   EFI_STATUS                Status;\r
   SERIAL_DEV                *SerialDevice;\r
@@ -1132,7 +1085,7 @@ IsaSerialSetAttributes (
   // Check for default settings and fill in actual values.\r
   //\r
   if (BaudRate == 0) {\r
-    BaudRate = SERIAL_PORT_DEFAULT_BAUD_RATE;\r
+    BaudRate = FixedPcdGet64 (PcdUartDefaultBaudRate);\r
   }\r
 \r
   if (ReceiveFifoDepth == 0) {\r
@@ -1144,15 +1097,15 @@ IsaSerialSetAttributes (
   }\r
 \r
   if (Parity == DefaultParity) {\r
-    Parity = SERIAL_PORT_DEFAULT_PARITY;\r
+    Parity = (EFI_PARITY_TYPE)FixedPcdGet8 (PcdUartDefaultParity);\r
   }\r
 \r
   if (DataBits == 0) {\r
-    DataBits = SERIAL_PORT_DEFAULT_DATA_BITS;\r
+    DataBits = FixedPcdGet8 (PcdUartDefaultDataBits);\r
   }\r
 \r
   if (StopBits == DefaultStopBits) {\r
-    StopBits = (EFI_STOP_BITS_TYPE) SERIAL_PORT_DEFAULT_STOP_BITS;\r
+    StopBits = (EFI_STOP_BITS_TYPE) FixedPcdGet8 (PcdUartDefaultStopBits);\r
   }\r
   //\r
   // 5 and 6 data bits can not be verified on a 16550A UART\r
@@ -1251,11 +1204,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
@@ -1270,7 +1223,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
@@ -1282,37 +1235,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
@@ -1321,12 +1274,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
@@ -1335,7 +1288,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
@@ -1389,7 +1342,7 @@ IsaSerialSetAttributes (
     }\r
   }\r
 \r
-  if (SerialDevice->DevicePath) {\r
+  if (SerialDevice->DevicePath != NULL) {\r
     gBS->FreePool (SerialDevice->DevicePath);\r
   }\r
 \r
@@ -1400,29 +1353,22 @@ IsaSerialSetAttributes (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Set Control Bits.\r
+\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
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 IsaSerialSetControl (\r
   IN EFI_SERIAL_IO_PROTOCOL  *This,\r
   IN UINT32                  Control\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-    Set Control Bits\r
-\r
-  Arguments:\r
-\r
-    This            - Pointer to EFI_SERIAL_IO_PROTOCOL\r
-    Control         - Control bits that can be settable\r
-\r
-  Returns:\r
-\r
-    EFI_SUCCESS     - New Control bits were set successfully\r
-    EFI_UNSUPPORTED - The Control bits wanted to set are not supported\r
-\r
---*/\r
 {\r
   SERIAL_DEV      *SerialDevice;\r
   SERIAL_PORT_MCR Mcr;\r
@@ -1440,38 +1386,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
@@ -1480,28 +1426,21 @@ IsaSerialSetControl (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Get ControlBits.\r
+\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
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 IsaSerialGetControl (\r
   IN EFI_SERIAL_IO_PROTOCOL  *This,\r
   OUT UINT32                 *Control\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-    Get ControlBits\r
-\r
-  Arguments:\r
-\r
-    This        - Pointer to EFI_SERIAL_IO_PROTOCOL\r
-    Control     - Control signals of the serial device\r
-\r
-  Returns:\r
-\r
-    EFI_SUCCESS - Get Control signals successfully\r
-\r
---*/\r
 {\r
   SERIAL_DEV      *SerialDevice;\r
   SERIAL_PORT_MSR Msr;\r
@@ -1519,19 +1458,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
@@ -1539,15 +1478,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
@@ -1580,6 +1519,19 @@ IsaSerialGetControl (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\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
+                       data actually written\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
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 IsaSerialWrite (\r
@@ -1587,26 +1539,6 @@ IsaSerialWrite (
   IN OUT UINTN               *BufferSize,\r
   IN VOID                    *Buffer\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-    Write the specified number of bytes to serial device\r
-\r
-  Arguments:\r
-\r
-    This             - Pointer to EFI_SERIAL_IO_PROTOCOL\r
-    BufferSize       - On input the size of Buffer, on output the amount of\r
-                       data actually written\r
-    Buffer           - The buffer of data to write\r
-\r
-  Returns:\r
-\r
-    EFI_SUCCESS      - The data were written successfully\r
-    EFI_DEVICE_ERROR - The device reported an error\r
-    EFI_TIMEOUT      - The write operation was stopped due to timeout\r
-\r
---*/\r
 {\r
   SERIAL_DEV  *SerialDevice;\r
   UINT8       *CharBuffer;\r
@@ -1623,7 +1555,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
@@ -1668,6 +1600,19 @@ IsaSerialWrite (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\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
+\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
 EFIAPI\r
 IsaSerialRead (\r
@@ -1675,26 +1620,6 @@ IsaSerialRead (
   IN OUT UINTN               *BufferSize,\r
   OUT VOID                   *Buffer\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-    Read the specified number of bytes from serial device\r
-\r
-  Arguments:\r
-\r
-    This             - Pointer to EFI_SERIAL_IO_PROTOCOL\r
-    BufferSize       - On input the size of Buffer, on output the amount of\r
-                       data returned in buffer\r
-    Buffer           -  The buffer to return the data into\r
-\r
-  Returns:\r
-\r
-    EFI_SUCCESS      - The data were read successfully\r
-    EFI_DEVICE_ERROR - The device reported an error\r
-    EFI_TIMEOUT      - The read operation was stopped due to timeout\r
-\r
---*/\r
 {\r
   SERIAL_DEV  *SerialDevice;\r
   UINT32      Index;\r
@@ -1710,7 +1635,7 @@ IsaSerialRead (
     return EFI_SUCCESS;\r
   }\r
 \r
-  if (!Buffer) {\r
+  if (Buffer == NULL) {\r
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
@@ -1769,26 +1694,18 @@ IsaSerialRead (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Use scratchpad register to test if this serial port is present.\r
+\r
+  @param SerialDevice   Pointer to serial device structure\r
+\r
+  @return if this serial port is present\r
+**/\r
 BOOLEAN\r
 IsaSerialPortPresent (\r
   IN SERIAL_DEV *SerialDevice\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-    Use scratchpad register to test if this serial port is present\r
-\r
-  Arguments:\r
-\r
-    SerialDevice - Pointer to serial device structure\r
-\r
-  Returns:\r
-\r
-    TRUE         - The serial port is present\r
-    FALSE        - The serial port is NOT present\r
 \r
---*/\r
 {\r
   UINT8   Temp;\r
   BOOLEAN Status;\r
@@ -1801,20 +1718,14 @@ IsaSerialPortPresent (
   Temp = READ_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);\r
   WRITE_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, 0xAA);\r
 \r
-  if (READ_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress) != 0xAA)\r
-  {\r
-    if (!FeaturePcdGet (PcdNtEmulatorEnable)) {\r
-      Status = FALSE;\r
-    }\r
+  if (READ_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress) != 0xAA) {\r
+    Status = FALSE;\r
   }\r
 \r
   WRITE_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, 0x55);\r
 \r
-  if (READ_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress) != 0x55)\r
-  {\r
-    if (!FeaturePcdGet (PcdNtEmulatorEnable)) {\r
-      Status = FALSE;\r
-    }\r
+  if (READ_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress) != 0x55) {\r
+    Status = FALSE;\r
   }\r
   //\r
   // Restore SCR\r
@@ -1823,29 +1734,22 @@ IsaSerialPortPresent (
   return Status;\r
 }\r
 \r
+/**\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
+\r
+  @return Data read from serial port\r
+\r
+**/\r
 UINT8\r
 IsaSerialReadPort (\r
   IN EFI_ISA_IO_PROTOCOL                   *IsaIo,\r
   IN UINT16                                BaseAddress,\r
   IN UINT32                                Offset\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-    Use IsaIo protocol to read serial port\r
-\r
-  Arguments:\r
-\r
-    IsaIo       - Pointer to EFI_ISA_IO_PROTOCOL instance\r
-    BaseAddress - Serial port register group base address\r
-    Offset      - Offset in register group\r
-\r
-  Returns:\r
-\r
-    Data read from serial port\r
-\r
---*/\r
 {\r
   UINT8 Data;\r
 \r
@@ -1862,6 +1766,15 @@ IsaSerialReadPort (
   return Data;\r
 }\r
 \r
+/**\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
+\r
+**/\r
 VOID\r
 IsaSerialWritePort (\r
   IN EFI_ISA_IO_PROTOCOL                 *IsaIo,\r
@@ -1869,24 +1782,6 @@ IsaSerialWritePort (
   IN UINT32                              Offset,\r
   IN UINT8                               Data\r
   )\r
-/*++\r
-\r
-  Routine Description:\r
-\r
-    Use IsaIo protocol to write serial port\r
-\r
-  Arguments:\r
-\r
-    IsaIo       - Pointer to EFI_ISA_IO_PROTOCOL instance\r
-    BaseAddress - Serial port register group base address\r
-    Offset      - Offset in register group\r
-    Data        - data which is to be written to some serial port register\r
-\r
-  Returns:\r
-\r
-    None\r
-\r
---*/\r
 {\r
   //\r
   // Use IsaIo to access IO\r