/* Return whether the hardware flow control signal allows writing. */
BOOLEAN SerialPortWritable(UINTN SerialRegisterBase)
/* Return whether the hardware flow control signal allows writing. */
BOOLEAN SerialPortWritable(UINTN SerialRegisterBase)
{
  if (PcdGetBool (PcdSerialUseHardwareFlowControl)) {
    if (PcdGetBool (PcdSerialDetectCable)) {
      return (BOOLEAN)((SerialPortReadRegister (SerialRegisterBase, R_UART_MSR) & (B_UART_MSR_DSR | B_UART_MSR_CTS)) == (B_UART_MSR_DSR | B_UART_MSR_CTS));
    } else {
      return (BOOLEAN)((SerialPortReadRegister (SerialRegisterBase, R_UART_MSR) & (B_UART_MSR_DSR | B_UART_MSR_CTS)) != (B_UART_MSR_DSR));
    }
  }
  return TRUE;
}