2 * (c) 2008-2012 Adam Lackorznynski <adam@os.inf.tu-dresden.de>
3 * Alexander Warg <alexander.warg@os.inf.tu-dresden.de>
4 * economic rights: Technische Universität Dresden (Germany)
6 * This file is part of TUD:OS and distributed under the terms of the
7 * GNU General Public License 2.
8 * Please see the COPYING-GPL-2 file for details.
12 #include "uart_base.h"
16 class Uart_16550 : public Uart
21 TRB = 0x00, // Transmit/Receive Buffer (read/write)
22 BRD_LOW = 0x00, // Baud Rate Divisor LSB if bit 7 of LCR is set (read/write)
23 IER = 0x01, // Interrupt Enable Register (read/write)
24 BRD_HIGH = 0x01, // Baud Rate Divisor MSB if bit 7 of LCR is set (read/write)
25 IIR = 0x02, // Interrupt Identification Register (read only)
26 FCR = 0x02, // 16550 FIFO Control Register (write only)
27 LCR = 0x03, // Line Control Register (read/write)
28 MCR = 0x04, // Modem Control Register (read/write)
29 LSR = 0x05, // Line Status Register (read only)
30 MSR = 0x06, // Modem Status Register (read only)
31 SPR = 0x07, // Scratch Pad Register (read/write)
52 MODE_8N1 = PAR_NONE | DAT_8 | STOP_1,
53 MODE_7E1 = PAR_EVEN | DAT_7 | STOP_1,
55 // these two values are to leave either mode
56 // or baud rate unchanged on a call to change_mode
60 Base_rate_x86 = 115200,
61 Base_rate_pxa = 921600,
69 explicit Uart_16550(unsigned long base_rate, unsigned char init_flags = 0,
70 unsigned char ier_bits = 0,
71 unsigned char mcr_bits = 0, unsigned char fcr_bits = 0)
72 : _base_rate(base_rate), _init_flags(init_flags), _mcr_bits(mcr_bits),
73 _ier_bits(ier_bits), _fcr_bits(fcr_bits)
76 bool startup(Io_register_block const *regs);
78 bool change_mode(Transfer_mode m, Baud_rate r);
79 int get_char(bool blocking = true) const;
80 int char_avail() const;
81 inline void out_char(char c) const;
82 int write(char const *s, unsigned long count) const;
83 bool enable_rx_irq(bool enable = true);
86 unsigned long _base_rate;
87 unsigned char _init_flags;
88 unsigned char _mcr_bits;
89 unsigned char _ier_bits;
90 unsigned char _fcr_bits;