/* Sets the baud rate, receive FIFO depth, transmit/receive time out, parity, data buts, and stop bits on a serial device. This call is optional as the serial port will be set up with defaults base on PCD values. */
RETURN_STATUS EFIAPI GdbSerialInit(IN UINT64 BaudRate, IN UINT8 Parity, IN UINT8 DataBits, IN UINT8 StopBits)
/* Sets the baud rate, receive FIFO depth, transmit/receive time out, parity, data buts, and stop bits on a serial device. This call is optional as the serial port will be set up with defaults base on PCD values. */
RETURN_STATUS EFIAPI GdbSerialInit(IN UINT64 BaudRate, IN UINT8 Parity, IN UINT8 DataBits, IN UINT8 StopBits)
{
  UINTN  Divisor;
  UINT8  OutputData;
  UINT8  Data;
  UINT8  BreakSet = 0;
  Data = (UINT8)(DataBits - (UINT8)5);
  Divisor = 115200/(UINTN)BaudRate;
  OutputData = (UINT8)((DLAB << 7) | ((BreakSet << 6) | ((Parity << 3) | ((StopBits << 2) | Data))));
  IoWrite8 (gPort + LCR_OFFSET, OutputData);
  IoWrite8 (gPort + BAUD_HIGH_OFFSET, (UINT8)(Divisor >> 8));
  IoWrite8 (gPort + BAUD_LOW_OFFSET, (UINT8)(Divisor & 0xff));
  OutputData = (UINT8)((~DLAB<<7)|((BreakSet<<6)|((Parity<<3)|((StopBits<<2)| Data))));
  IoWrite8 (gPort + LCR_OFFSET, OutputData);
  IoWrite8 (gPort + FCR_SHADOW_OFFSET, ENABLE_FIFO);
  return RETURN_SUCCESS;
}