ReactOS  0.4.15-dev-1070-ge1a01de
hwuart.c File Reference
#include "precomp.h"
Include dependency graph for hwuart.c:

Go to the source code of this file.

Macros

#define UART_PL01x_DR   (LlbHwVersaUartBase + 0x00)
 
#define UART_PL01x_RSR   (LlbHwVersaUartBase + 0x04)
 
#define UART_PL01x_ECR   (LlbHwVersaUartBase + 0x04)
 
#define UART_PL01x_FR   (LlbHwVersaUartBase + 0x18)
 
#define UART_PL011_IBRD   (LlbHwVersaUartBase + 0x24)
 
#define UART_PL011_FBRD   (LlbHwVersaUartBase + 0x28)
 
#define UART_PL011_LCRH   (LlbHwVersaUartBase + 0x2C)
 
#define UART_PL011_CR   (LlbHwVersaUartBase + 0x30)
 
#define UART_PL011_IMSC   (LlbHwVersaUartBase + 0x38)
 
#define UART_PL011_LCRH_WLEN_8   0x60
 
#define UART_PL011_LCRH_FEN   0x10
 
#define UART_PL011_CR_UARTEN   0x01
 
#define UART_PL011_CR_TXE   0x100
 
#define UART_PL011_CR_RXE   0x200
 
#define UART_PL01x_FR_RXFE   0x10
 
#define UART_PL01x_FR_TXFF   0x20
 

Functions

VOID NTAPI LlbHwVersaUartInitialize (VOID)
 
VOID NTAPI LlbHwUartSendChar (IN CHAR Char)
 
BOOLEAN NTAPI LlbHwUartTxReady (VOID)
 
ULONG NTAPI LlbHwGetUartBase (IN ULONG Port)
 

Variables

static const ULONG LlbHwVersaUartBase = 0x101F1000
 

Macro Definition Documentation

◆ UART_PL011_CR

#define UART_PL011_CR   (LlbHwVersaUartBase + 0x30)

Definition at line 21 of file hwuart.c.

◆ UART_PL011_CR_RXE

#define UART_PL011_CR_RXE   0x200

Definition at line 35 of file hwuart.c.

◆ UART_PL011_CR_TXE

#define UART_PL011_CR_TXE   0x100

Definition at line 34 of file hwuart.c.

◆ UART_PL011_CR_UARTEN

#define UART_PL011_CR_UARTEN   0x01

Definition at line 33 of file hwuart.c.

◆ UART_PL011_FBRD

#define UART_PL011_FBRD   (LlbHwVersaUartBase + 0x28)

Definition at line 19 of file hwuart.c.

◆ UART_PL011_IBRD

#define UART_PL011_IBRD   (LlbHwVersaUartBase + 0x24)

Definition at line 18 of file hwuart.c.

◆ UART_PL011_IMSC

#define UART_PL011_IMSC   (LlbHwVersaUartBase + 0x38)

Definition at line 22 of file hwuart.c.

◆ UART_PL011_LCRH

#define UART_PL011_LCRH   (LlbHwVersaUartBase + 0x2C)

Definition at line 20 of file hwuart.c.

◆ UART_PL011_LCRH_FEN

#define UART_PL011_LCRH_FEN   0x10

Definition at line 28 of file hwuart.c.

◆ UART_PL011_LCRH_WLEN_8

#define UART_PL011_LCRH_WLEN_8   0x60

Definition at line 27 of file hwuart.c.

◆ UART_PL01x_DR

#define UART_PL01x_DR   (LlbHwVersaUartBase + 0x00)

Definition at line 14 of file hwuart.c.

◆ UART_PL01x_ECR

#define UART_PL01x_ECR   (LlbHwVersaUartBase + 0x04)

Definition at line 16 of file hwuart.c.

◆ UART_PL01x_FR

#define UART_PL01x_FR   (LlbHwVersaUartBase + 0x18)

Definition at line 17 of file hwuart.c.

◆ UART_PL01x_FR_RXFE

#define UART_PL01x_FR_RXFE   0x10

Definition at line 40 of file hwuart.c.

◆ UART_PL01x_FR_TXFF

#define UART_PL01x_FR_TXFF   0x20

Definition at line 41 of file hwuart.c.

◆ UART_PL01x_RSR

#define UART_PL01x_RSR   (LlbHwVersaUartBase + 0x04)

Definition at line 15 of file hwuart.c.

Function Documentation

◆ LlbHwGetUartBase()

ULONG NTAPI LlbHwGetUartBase ( IN ULONG  Port)

Definition at line 101 of file hwuart.c.

102 {
103  if (Port == 0)
104  {
105  return 0x101F1000;
106  }
107  else if (Port == 1)
108  {
109  return 0x101F2000;
110  }
111 
112  return 0;
113 }
CPPORT Port[4]
Definition: headless.c:34

◆ LlbHwUartSendChar()

VOID NTAPI LlbHwUartSendChar ( IN CHAR  Char)

Definition at line 85 of file hwuart.c.

86 {
87  /* Send the character */
89 }
NTKERNELAPI VOID NTAPI WRITE_REGISTER_ULONG(IN PULONG Register, IN ULONG Value)
#define UART_PL01x_DR
Definition: hwuart.c:14

◆ LlbHwUartTxReady()

BOOLEAN NTAPI LlbHwUartTxReady ( VOID  )

Definition at line 93 of file hwuart.c.

94 {
95  /* TX output buffer is ready? */
97 }
NTKERNELAPI ULONG NTAPI READ_REGISTER_ULONG(IN PULONG Register)
#define UART_PL01x_FR
Definition: hwuart.c:17
#define UART_PL01x_FR_TXFF
Definition: hwuart.c:41

◆ LlbHwVersaUartInitialize()

VOID NTAPI LlbHwVersaUartInitialize ( VOID  )

Definition at line 49 of file hwuart.c.

50 {
51  ULONG Divider, Remainder, Fraction, ClockRate, Baudrate;
52 
53  /* Query peripheral rate, hardcore baudrate */
54  ClockRate = LlbHwGetPClk();
55  Baudrate = 115200;
56 
57  /* Calculate baudrate clock divider and remainder */
58  Divider = ClockRate / (16 * Baudrate);
59  Remainder = ClockRate % (16 * Baudrate);
60 
61  /* Calculate the fractional part */
62  Fraction = (8 * Remainder / Baudrate) >> 1;
63  Fraction += (8 * Remainder / Baudrate) & 1;
64 
65  /* Disable interrupts */
67 
68  /* Set the baud rate to 115200 bps */
71 
72  /* Set 8 bits for data, 1 stop bit, no parity, FIFO enabled */
75 
76  /* Clear and enable FIFO */
81 }
NTKERNELAPI VOID NTAPI WRITE_REGISTER_ULONG(IN PULONG Register, IN ULONG Value)
#define UART_PL011_LCRH_WLEN_8
Definition: hwuart.c:27
#define UART_PL011_CR_UARTEN
Definition: hwuart.c:33
#define UART_PL011_CR
Definition: hwuart.c:21
#define UART_PL011_CR_TXE
Definition: hwuart.c:34
#define UART_PL011_LCRH_FEN
Definition: hwuart.c:28
#define UART_PL011_IBRD
Definition: hwuart.c:18
ULONG NTAPI LlbHwGetPClk(VOID)
Definition: hwinfo.c:20
#define UART_PL011_FBRD
Definition: hwuart.c:19
#define UART_PL011_LCRH
Definition: hwuart.c:20
unsigned int ULONG
Definition: retypes.h:1
#define UART_PL011_CR_RXE
Definition: hwuart.c:35
_In_ LARGE_INTEGER _Out_opt_ PLARGE_INTEGER Remainder
Definition: rtlfuncs.h:3046

Referenced by LlbHwInitialize().

Variable Documentation

◆ LlbHwVersaUartBase

const ULONG LlbHwVersaUartBase = 0x101F1000
static

Definition at line 43 of file hwuart.c.