19#define BAUD_LOW_OFFSET 0x00
20#define BAUD_HIGH_OFFSET 0x01
21#define IER_OFFSET 0x01
22#define LCR_SHADOW_OFFSET 0x01
23#define FCR_SHADOW_OFFSET 0x02
24#define IR_CONTROL_OFFSET 0x02
25#define FCR_OFFSET 0x02
26#define EIR_OFFSET 0x02
27#define BSR_OFFSET 0x03
28#define LCR_OFFSET 0x03
29#define MCR_OFFSET 0x04
30#define LSR_OFFSET 0x05
31#define MSR_OFFSET 0x06
36#define LSR_TXRDY 0x20U
39#define ENABLE_FIFO 0x01U
40#define CLEAR_FIFOS 0x06U
68 BaudRate =
PcdGet64 (PcdGdbBaudRate);
69 Parity =
PcdGet8 (PcdGdbParity);
70 DataBits =
PcdGet8 (PcdGdbDataBits);
71 StopBits =
PcdGet8 (PcdGdbStopBits);
116 Data = (UINT8)(DataBits - (UINT8)5);
121 Divisor = 115200/(
UINTN)BaudRate;
126 OutputData = (UINT8)((DLAB << 7) | ((BreakSet << 6) | ((Parity << 3) | ((StopBits << 2) | Data))));
127 IoWrite8 (gPort + LCR_OFFSET, OutputData);
132 IoWrite8 (gPort + BAUD_HIGH_OFFSET, (UINT8)(Divisor >> 8));
133 IoWrite8 (gPort + BAUD_LOW_OFFSET, (UINT8)(Divisor & 0xff));
138 OutputData = (UINT8)((~DLAB<<7)|((BreakSet<<6)|((Parity<<3)|((StopBits<<2)| Data))));
139 IoWrite8 (gPort + LCR_OFFSET, OutputData);
143 IoWrite8 (gPort + FCR_SHADOW_OFFSET, ENABLE_FIFO);
165 Data =
IoRead8 (gPort + LSR_OFFSET);
167 return ((Data & LSR_RXDA) == LSR_RXDA);
187 Data =
IoRead8 (gPort + LSR_OFFSET);
188 }
while ((Data & LSR_RXDA) == 0);
193 DEBUG ((DEBUG_ERROR,
"<%c<", Char));
213 DEBUG ((DEBUG_ERROR,
">%c>", Char));
217 Data =
IoRead8 (gPort + LSR_OFFSET);
218 }
while ((Data & LSR_TXRDY) == 0);
235 while (*String !=
'\0') {
VOID GdbPutString(IN CHAR8 *String)
CHAR8 EFIAPI GdbGetChar(VOID)
BOOLEAN EFIAPI GdbIsCharAvailable(VOID)
VOID EFIAPI GdbPutChar(IN CHAR8 Char)
RETURN_STATUS EFIAPI GdbSerialLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
RETURN_STATUS EFIAPI GdbSerialInit(IN UINT64 BaudRate, IN UINT8 Parity, IN UINT8 DataBits, IN UINT8 StopBits)
UINT8 EFIAPI IoWrite8(IN UINTN Port, IN UINT8 Value)
UINT8 EFIAPI IoRead8(IN UINTN Port)
#define DEBUG(Expression)
#define PcdGet64(TokenName)
#define PcdGet8(TokenName)
#define PcdGet32(TokenName)