]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/ConsoleOption.c
Add missing braces around initializer.
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / BdsDxe / BootMaint / ConsoleOption.c
index 9d32c380fbc5023806918e18e78208cbe1050f98..f216b4a03f0c4737bac1b8de5fcdfaf83c1c4c25 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   handles console redirection from boot manager\r
 \r
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r
 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
@@ -14,6 +14,41 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include "BootMaint.h"\r
 \r
+UART_FLOW_CONTROL_DEVICE_PATH mFlowControlDevicePath =\r
+{\r
+  {\r
+    MESSAGING_DEVICE_PATH,\r
+    MSG_VENDOR_DP,\r
+    {\r
+      (UINT8)(sizeof(UART_FLOW_CONTROL_DEVICE_PATH)),\r
+      (UINT8)((sizeof(UART_FLOW_CONTROL_DEVICE_PATH)) >> 8)\r
+    }\r
+  },\r
+  DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL,\r
+  UART_FLOW_CONTROL_HARDWARE\r
+};\r
+\r
+/**\r
+  Check the device path node whether it's the Flow Control node or not.\r
+\r
+  @param[in] FlowControl    The device path node to be checked.\r
+  \r
+  @retval TRUE              It's the Flow Control node.\r
+  @retval FALSE             It's not.\r
+\r
+**/\r
+BOOLEAN\r
+IsUartFlowControlNode (\r
+  IN UART_FLOW_CONTROL_DEVICE_PATH *FlowControl\r
+  )\r
+{\r
+  return (BOOLEAN) (\r
+           (DevicePathType (FlowControl) == MESSAGING_DEVICE_PATH) &&\r
+           (DevicePathSubType (FlowControl) == MSG_VENDOR_DP) &&\r
+           (CompareGuid (&FlowControl->Guid, &gEfiUartDevicePathGuid))\r
+           );\r
+}\r
+\r
 /**\r
   Check whether the device path node is ISA Serial Node.\r
 \r
@@ -62,7 +97,7 @@ UpdateComAttributeFromVariable (
 **/\r
 EFI_STATUS\r
 ChangeTerminalDevicePath (\r
-  IN OUT    EFI_DEVICE_PATH_PROTOCOL  *DevicePath,\r
+  IN OUT    EFI_DEVICE_PATH_PROTOCOL  **DevicePath,\r
   IN        BOOLEAN                   ChangeTerminal\r
   )\r
 {\r
@@ -74,8 +109,9 @@ ChangeTerminalDevicePath (
   UINTN                     Com;\r
   BM_TERMINAL_CONTEXT       *NewTerminalContext;\r
   BM_MENU_ENTRY             *NewMenuEntry;\r
+  UART_FLOW_CONTROL_DEVICE_PATH *FlowControlNode;\r
 \r
-  Node  = DevicePath;\r
+  Node  = *DevicePath;\r
   Node  = NextDevicePathNode (Node);\r
   Com   = 0;\r
   while (!IsDevicePathEnd (Node)) {\r
@@ -112,6 +148,23 @@ ChangeTerminalDevicePath (
         &NewTerminalContext->StopBits,\r
         sizeof (UINT8)\r
         );\r
+\r
+      FlowControlNode = (UART_FLOW_CONTROL_DEVICE_PATH *) NextDevicePathNode (Node);\r
+      if (IsUartFlowControlNode (FlowControlNode)) {\r
+        FlowControlNode->FlowControlMap = NewTerminalContext->FlowControl;\r
+      } else {\r
+        //\r
+        // Append the Flow control device node when user enable flow control.\r
+        //\r
+        if (NewTerminalContext->FlowControl != 0) {\r
+          mFlowControlDevicePath.FlowControlMap = NewTerminalContext->FlowControl;\r
+          *DevicePath = AppendDevicePathNode (\r
+                                       *DevicePath,\r
+                                       (EFI_DEVICE_PATH_PROTOCOL *) (&mFlowControlDevicePath)\r
+                                       );\r
+        }\r
+      }\r
+\r
       //\r
       // Change the device path in the ComPort\r
       //\r
@@ -372,6 +425,7 @@ LocateSerialIo (
   BM_TERMINAL_CONTEXT       *NewTerminalContext;\r
   EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
   VENDOR_DEVICE_PATH        Vendor;\r
+  UINT32                    FlowControl;\r
   //\r
   // Get all handles that have SerialIo protocol installed\r
   //\r
@@ -470,6 +524,13 @@ LocateSerialIo (
         &SerialIo->Mode->StopBits,\r
         sizeof (UINT8)\r
         );\r
+\r
+      NewTerminalContext->FlowControl = 0;\r
+      SerialIo->GetControl(SerialIo, &FlowControl);\r
+      if ((FlowControl & EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE) != 0) {\r
+        NewTerminalContext->FlowControl = UART_FLOW_CONTROL_HARDWARE;\r
+      }\r
+\r
       InsertTailList (&TerminalMenu.Head, &NewMenuEntry->Link);\r
       TerminalMenu.MenuNumber++;\r
     }\r
@@ -570,7 +631,10 @@ UpdateComAttributeFromVariable (
   BM_MENU_ENTRY             *NewMenuEntry;\r
   BM_TERMINAL_CONTEXT       *NewTerminalContext;\r
   UINTN                     Index;\r
+  UART_FLOW_CONTROL_DEVICE_PATH *FlowControlNode;\r
+  BOOLEAN                   HasFlowControlNode;\r
 \r
+  HasFlowControlNode = FALSE;\r
   Node            = DevicePath;\r
   Node            = NextDevicePathNode (Node);\r
   TerminalNumber  = 0;\r
@@ -613,6 +677,17 @@ UpdateComAttributeFromVariable (
           sizeof (UINT8)\r
           );\r
 \r
+        FlowControlNode = (UART_FLOW_CONTROL_DEVICE_PATH *) NextDevicePathNode (Node);\r
+        if (IsUartFlowControlNode (FlowControlNode)) {\r
+          HasFlowControlNode = TRUE;\r
+          NewTerminalContext->FlowControl = (UINT8) ReadUnaligned32 (&FlowControlNode->FlowControlMap);\r
+        } else if (NewTerminalContext->FlowControl != 0) {\r
+          //\r
+          // No Flow Control device path node, assumption no Flow control\r
+          //\r
+          NewTerminalContext->FlowControl = 0;\r
+        }\r
+\r
         SerialNode  = NewTerminalContext->DevicePath;\r
         SerialNode  = NextDevicePathNode (SerialNode);\r
         while (!IsDevicePathEnd (SerialNode)) {\r
@@ -644,6 +719,18 @@ UpdateComAttributeFromVariable (
               sizeof (UINT8)\r
               );\r
 \r
+            FlowControlNode = (UART_FLOW_CONTROL_DEVICE_PATH *) NextDevicePathNode (SerialNode);\r
+            if (IsUartFlowControlNode (FlowControlNode)) {\r
+              FlowControlNode->FlowControlMap = NewTerminalContext->FlowControl;\r
+            } else {\r
+              if (HasFlowControlNode) {\r
+                mFlowControlDevicePath.FlowControlMap = NewTerminalContext->FlowControl;\r
+                NewTerminalContext->DevicePath = AppendDevicePathNode (\r
+                                             NewTerminalContext->DevicePath,\r
+                                             (EFI_DEVICE_PATH_PROTOCOL *) (&mFlowControlDevicePath)\r
+                                             );\r
+              }\r
+            }\r
             break;\r
           }\r
 \r
@@ -950,8 +1037,8 @@ GetConsoleOutMode (
   ConOut   = gST->ConOut;\r
   MaxMode  = (UINTN) (ConOut->Mode->MaxMode);\r
 \r
-  CurrentCol = PcdGet32 (PcdConOutColumn);\r
-  CurrentRow = PcdGet32 (PcdConOutRow);\r
+  CurrentCol = PcdGet32 (PcdSetupConOutColumn);\r
+  CurrentRow = PcdGet32 (PcdSetupConOutRow);\r
   for (Mode = 0; Mode < MaxMode; Mode++) {\r
     Status = ConOut->QueryMode (ConOut, Mode, &Col, &Row);\r
     if (!EFI_ERROR(Status)) {\r