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 *******************************************************************/
16 #include <ioaccess.h> /* port intrinsics */
17 #include <cportlib/cportlib.h>
18 #include <arm/peripherals/pl011.h>
24 /* GLOBALS ********************************************************************/
26 CPPORT DefaultPort
= {0, 0, 0};
29 // We need to build this in the configuration root and use KeFindConfigurationEntry
30 // to recover it later.
34 /* REACTOS FUNCTIONS **********************************************************/
38 KdPortInitializeEx(IN PCPPORT PortInformation
,
39 IN ULONG ComPortNumber
)
41 ULONG Divider
, Remainder
, Fraction
;
42 ULONG Baudrate
= PortInformation
->BaudRate
;
45 // Calculate baudrate clock divider and remainder
47 Divider
= HACK
/ (16 * Baudrate
);
48 Remainder
= HACK
% (16 * Baudrate
);
51 // Calculate the fractional part
53 Fraction
= (8 * Remainder
/ Baudrate
) >> 1;
54 Fraction
+= (8 * Remainder
/ Baudrate
) & 1;
59 WRITE_REGISTER_ULONG(UART_PL011_CR
, 0);
64 WRITE_REGISTER_ULONG(UART_PL011_IBRD
, Divider
);
65 WRITE_REGISTER_ULONG(UART_PL011_FBRD
, Fraction
);
68 // Set 8 bits for data, 1 stop bit, no parity, FIFO enabled
70 WRITE_REGISTER_ULONG(UART_PL011_LCRH
,
71 UART_PL011_LCRH_WLEN_8
| UART_PL011_LCRH_FEN
);
74 // Clear and enable FIFO
76 WRITE_REGISTER_ULONG(UART_PL011_CR
,
77 UART_PL011_CR_UARTEN
|
89 KdPortGetByteEx(IN PCPPORT PortInformation
,
90 OUT PUCHAR ByteReceived
)
99 KdPortPutByteEx(IN PCPPORT PortInformation
,
105 while ((READ_REGISTER_ULONG(UART_PL01x_FR
) & UART_PL01x_FR_TXFF
) != 0);
108 // Send the character
110 WRITE_REGISTER_ULONG(UART_PL01x_DR
, ByteToSend
);