summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c
diff options
context:
space:
mode:
authormdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2011-02-10 23:27:12 +0000
committermdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2011-02-10 23:27:12 +0000
commit784ce127276c4a0cb42cd6b24bcec9072d4d3ce9 (patch)
tree8d9493526d7d5f56160fca1d39a483db28ab1a31 /MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c
parentdb662a64a62a42e2c8cdc3ab86c1a6b832f2dc4e (diff)
downloadedk2-platforms-784ce127276c4a0cb42cd6b24bcec9072d4d3ce9.tar.xz
1) Add PcdSerialDetectCable to MdeModulePkg to enable/disable cable detection if hardware flow control is enabled. The default is to not perform cable detection.
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
Diffstat (limited to 'MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c')
-rw-r--r--MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c b/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c
index 04d8ca1949..a6c990dee6 100644
--- a/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c
+++ b/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c
@@ -38,6 +38,7 @@
#define B_UART_LSR_TEMT BIT6
#define R_UART_MSR 6
#define B_UART_MSR_CTS BIT4
+#define B_UART_MSR_DSR BIT5
/**
Read an 8-bit 16550 register. If PcdSerialUseMmio is TRUE, then the value is read from
@@ -226,10 +227,35 @@ SerialPortWrite (
//
for (Index = 0; Index < FifoSize && NumberOfBytes != 0; Index++, NumberOfBytes--, Buffer++) {
if (PcdGetBool (PcdSerialUseHardwareFlowControl)) {
- //
- // Wait for notification from peer to send data
- //
- while ((SerialPortReadRegister (R_UART_MSR) & (B_UART_MSR_CTS)) == 0);
+ if (PcdGetBool (PcdSerialDetectCable)) {
+ //
+ // Wait for both DSR and CTS to be set
+ // DSR is set if a cable is connected.
+ // CTS is set if it is ok to transmit data
+ //
+ // DSR CTS Description Action
+ // === === ======================================== ========
+ // 0 0 No cable connected. Wait
+ // 0 1 No cable connected. Wait
+ // 1 0 Cable connected, but not clear to send. Wait
+ // 1 1 Cable connected, and clear to send. Transmit
+ //
+ while ((SerialPortReadRegister (R_UART_MSR) & (B_UART_MSR_DSR | B_UART_MSR_CTS)) != (B_UART_MSR_DSR | B_UART_MSR_CTS));
+ } else {
+ //
+ // Wait for both DSR and CTS to be set OR for DSR to be clear.
+ // DSR is set if a cable is connected.
+ // CTS is set if it is ok to transmit data
+ //
+ // DSR CTS Description Action
+ // === === ======================================== ========
+ // 0 0 No cable connected. Transmit
+ // 0 1 No cable connected. Transmit
+ // 1 0 Cable connected, but not clear to send. Wait
+ // 1 1 Cable connected, and clar to send. Transmit
+ //
+ while ((SerialPortReadRegister (R_UART_MSR) & (B_UART_MSR_DSR | B_UART_MSR_CTS)) == (B_UART_MSR_DSR));
+ }
}
//