]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1) Add PcdSerialDetectCable to MdeModulePkg to enable/disable cable detection if...
authormdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 10 Feb 2011 23:27:12 +0000 (23:27 +0000)
committermdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 10 Feb 2011 23:27:12 +0000 (23:27 +0000)
2) Update BaseSerialPortLib16550 to use this new PCD.

This addresses an issue that was introduced on Feb 3, 2011 when all references to Carrier Detect(CD) were removed from the BaseSerialPortLib16550.  When that change was made, a target would block on the first Tx operation if hardware flow control was enabled and no cable or serial application was running on a host. Now the behavior when no cable is connected or no serial app is running on the host is controlled through a PCD.  The default is for the target to continue execution even if there is no cable or serial app running.  If PcdSerialDetectCable is set to TRUE, then the target will block on any transmit that does not have a cable connected or a serial app running in the host.

If hardware flow control is disabled, then this update will have no impact on behavior.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11301 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c
MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
MdeModulePkg/MdeModulePkg.dec

index 04d8ca194934ead73b66e684dd539f97237ab0c9..a6c990dee6019b410095d2fc071f8db3ec57ae8b 100644 (file)
@@ -38,6 +38,7 @@
 #define   B_UART_LSR_TEMT     BIT6\r
 #define R_UART_MSR            6\r
 #define   B_UART_MSR_CTS      BIT4\r
+#define   B_UART_MSR_DSR      BIT5\r
 \r
 /**\r
   Read an 8-bit 16550 register.  If PcdSerialUseMmio is TRUE, then the value is read from \r
@@ -226,10 +227,35 @@ SerialPortWrite (
     //\r
     for (Index = 0; Index < FifoSize && NumberOfBytes != 0; Index++, NumberOfBytes--, Buffer++) {\r
       if (PcdGetBool (PcdSerialUseHardwareFlowControl)) {\r
-        //\r
-        // Wait for notification from peer to send data\r
-        //\r
-        while ((SerialPortReadRegister (R_UART_MSR) & (B_UART_MSR_CTS)) == 0);\r
+        if (PcdGetBool (PcdSerialDetectCable)) {\r
+          //\r
+          // Wait for both DSR and CTS to be set\r
+          //   DSR is set if a cable is connected.\r
+          //   CTS is set if it is ok to transmit data\r
+          //\r
+          //   DSR  CTS  Description                               Action\r
+          //   ===  ===  ========================================  ========\r
+          //    0    0   No cable connected.                       Wait\r
+          //    0    1   No cable connected.                       Wait\r
+          //    1    0   Cable connected, but not clear to send.   Wait\r
+          //    1    1   Cable connected, and clear to send.       Transmit\r
+          //\r
+          while ((SerialPortReadRegister (R_UART_MSR) & (B_UART_MSR_DSR | B_UART_MSR_CTS)) != (B_UART_MSR_DSR | B_UART_MSR_CTS));\r
+        } else {\r
+          //\r
+          // Wait for both DSR and CTS to be set OR for DSR to be clear.  \r
+          //   DSR is set if a cable is connected.\r
+          //   CTS is set if it is ok to transmit data\r
+          //\r
+          //   DSR  CTS  Description                               Action\r
+          //   ===  ===  ========================================  ========\r
+          //    0    0   No cable connected.                       Transmit\r
+          //    0    1   No cable connected.                       Transmit\r
+          //    1    0   Cable connected, but not clear to send.   Wait\r
+          //    1    1   Cable connected, and clar to send.        Transmit\r
+          //\r
+          while ((SerialPortReadRegister (R_UART_MSR) & (B_UART_MSR_DSR | B_UART_MSR_CTS)) == (B_UART_MSR_DSR));\r
+        }\r
       }\r
       \r
       //\r
index 251f35388443f4d6cb553c9de129e619ce3a954b..3f223667c7a6b01a841a5de1f239919c8a207ada 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 #   SerialPortLib instance for 16550 UART\r
 #\r
-#  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2006 - 2011, 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
@@ -35,6 +35,7 @@
 [Pcd]\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseHardwareFlowControl\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialDetectCable\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdSerialLineControl\r
index 63297bb11b06cef2ab2134d704d68f7b1c083750..093eeae1800055d46cb9e44d83fa7b6076f36840 100644 (file)
@@ -4,7 +4,7 @@
 # It also provides the defintions(including PPIs/PROTOCOLs/GUIDs and library classes)\r
 # and libraries instances, which are used for those modules.\r
 #\r
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials are licensed and made available under \r
 # the terms and conditions of the BSD License that accompanies this distribution.  \r
 # The full text of the license may be found at\r
   #  If FALSE, then the 16550 serial port hardware flow control is disabled.  Default value.\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseHardwareFlowControl|FALSE|BOOLEAN|0x00020001\r
 \r
+  ## If TRUE, then 16550 serial Tx operations will block if DSR is not asserted (no cable).\r
+  #  If FALSE, then the 16550 serial Tx operations will not be blocked if DSR is not asserted. Default value.\r
+  #  This PCD is ignored if PcdSerialUseHardwareFlowControl is FALSE.\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialDetectCable|FALSE|BOOLEAN|0x00020006\r
+    \r
   ## Base address of 16550 serial port registers in MMIO or I/O space.  Default is 0x3F8.\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x03F8|UINT64|0x00020002\r
 \r