2 * PROJECT: ReactOS Kernel
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: drivers/base/kdcom/arm/kdbg.c
5 * PURPOSE: Serial Port Kernel Debugging Transport Library
6 * PROGRAMMERS: ReactOS Portable Systems Group
9 /* INCLUDES *******************************************************************/
19 #include <arm/peripherals/pl011.h>
24 /* GLOBALS ********************************************************************/
26 typedef struct _KD_PORT_INFORMATION
31 } KD_PORT_INFORMATION
, *PKD_PORT_INFORMATION
;
33 KD_PORT_INFORMATION DefaultPort
= {0, 0, 0};
36 // We need to build this in the configuration root and use KeFindConfigurationEntry
37 // to recover it later.
41 /* REACTOS FUNCTIONS **********************************************************/
45 KdPortInitializeEx(IN PKD_PORT_INFORMATION PortInformation
,
49 ULONG Divider
, Remainder
, Fraction
;
50 ULONG Baudrate
= PortInformation
->BaudRate
;
53 // Calculate baudrate clock divider and remainder
55 Divider
= HACK
/ (16 * Baudrate
);
56 Remainder
= HACK
% (16 * Baudrate
);
59 // Calculate the fractional part
61 Fraction
= (8 * Remainder
/ Baudrate
) >> 1;
62 Fraction
+= (8 * Remainder
/ Baudrate
) & 1;
67 WRITE_REGISTER_ULONG(UART_PL011_CR
, 0);
72 WRITE_REGISTER_ULONG(UART_PL011_IBRD
, Divider
);
73 WRITE_REGISTER_ULONG(UART_PL011_FBRD
, Fraction
);
76 // Set 8 bits for data, 1 stop bit, no parity, FIFO enabled
78 WRITE_REGISTER_ULONG(UART_PL011_LCRH
,
79 UART_PL011_LCRH_WLEN_8
| UART_PL011_LCRH_FEN
);
82 // Clear and enable FIFO
84 WRITE_REGISTER_ULONG(UART_PL011_CR
,
85 UART_PL011_CR_UARTEN
|
97 KdPortGetByteEx(IN PKD_PORT_INFORMATION PortInformation
,
98 OUT PUCHAR ByteReceived
)
107 KdPortPutByteEx(IN PKD_PORT_INFORMATION PortInformation
,
113 while ((READ_REGISTER_ULONG(UART_PL01x_FR
) & UART_PL01x_FR_TXFF
) != 0);
116 // Send the character
118 WRITE_REGISTER_ULONG(UART_PL01x_DR
, ByteToSend
);