FreeNOS
PL011.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Niek Linnenbank
3  * Copyright (C) 2013 Goswin von Brederlow <goswin-v-b@web.de>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef __SERVER_SERIAL_PL011_H
20 #define __SERVER_SERIAL_PL011_H
21 
22 #include <Log.h>
23 #include <Types.h>
24 #include "SerialDevice.h"
25 
39 class PL011 : public SerialDevice
40 {
41  private:
42 
46  enum {
47  PL011_DR = (0x00),
48  PL011_RSRECR = (0x04),
49 
50  PL011_FR = (0x18),
51  PL011_FR_RXFE = (1 << 4),
52  PL011_FR_TXFE = (1 << 7),
53 
54  PL011_ILPR = (0x20),
55  PL011_IBRD = (0x24),
56  PL011_FBRD = (0x28),
57 
58  PL011_LCRH = (0x2C),
59  PL011_LCRH_WLEN_8BIT = (0b11<<5),
60 
61  PL011_CR = (0x30),
62  PL011_IFLS = (0x34),
63 
64  PL011_IMSC = (0x38),
65  PL011_IMSC_RXIM = (1 << 4),
66  PL011_IMSC_TXIM = (1 << 5),
67 
68  PL011_RIS = (0x3C),
69 
70  PL011_MIS = (0x40),
71  PL011_MIS_RXMIS = (1 << 4),
72  PL011_MIS_TXMIS = (1 << 5),
73 
74  PL011_ICR = (0x44),
75  PL011_ICR_TXIC = (1 << 5),
76  PL011_ICR_RXIC = (1 << 4),
77 
78  PL011_DMACR = (0x48),
79  PL011_ITCR = (0x80),
80  PL011_ITIP = (0x84),
81  PL011_ITOP = (0x88),
82  PL011_TDR = (0x8C)
83  };
84 
85  public:
86 
90  PL011(const u32 irq);
91 
98 
106  virtual FileSystem::Result interrupt(const Size vector);
107 
118  virtual FileSystem::Result read(IOBuffer & buffer,
119  Size & size,
120  const Size offset);
121 
132  virtual FileSystem::Result write(IOBuffer & buffer,
133  Size & size,
134  const Size offset);
135 };
136 
142 #endif /* __SERVER_SERIAL_PL011_H */
PL011::PL011_ILPR
@ PL011_ILPR
Definition: PL011.h:54
PL011::write
virtual FileSystem::Result write(IOBuffer &buffer, Size &size, const Size offset)
Write bytes to the device.
Definition: PL011.cpp:139
PL011::PL011_TDR
@ PL011_TDR
Definition: PL011.h:82
PL011::PL011_DR
@ PL011_DR
Definition: PL011.h:47
PL011::PL011_IFLS
@ PL011_IFLS
Definition: PL011.h:62
SerialDevice.h
Types.h
PL011
The PL011 is a commonly available UART device frequently found in ARM systems.
Definition: PL011.h:39
PL011::PL011_LCRH
@ PL011_LCRH
Definition: PL011.h:58
PL011::PL011_DMACR
@ PL011_DMACR
Definition: PL011.h:78
PL011::PL011_IMSC_RXIM
@ PL011_IMSC_RXIM
Definition: PL011.h:65
PL011::PL011
PL011(const u32 irq)
Constructor.
Definition: PL011.cpp:28
PL011::PL011_ITIP
@ PL011_ITIP
Definition: PL011.h:80
PL011::PL011_RIS
@ PL011_RIS
Definition: PL011.h:68
PL011::PL011_CR
@ PL011_CR
Definition: PL011.h:61
PL011::PL011_FR_RXFE
@ PL011_FR_RXFE
Definition: PL011.h:51
PL011::PL011_FBRD
@ PL011_FBRD
Definition: PL011.h:56
PL011::PL011_ICR
@ PL011_ICR
Definition: PL011.h:74
Log.h
PL011::PL011_ITCR
@ PL011_ITCR
Definition: PL011.h:79
PL011::PL011_FR
@ PL011_FR
Definition: PL011.h:50
PL011::PL011_IBRD
@ PL011_IBRD
Definition: PL011.h:55
IOBuffer
Abstract Input/Output buffer.
Definition: IOBuffer.h:37
u32
unsigned int u32
Unsigned 32-bit number.
Definition: Types.h:53
Size
unsigned int Size
Any sane size indicator cannot go negative.
Definition: Types.h:128
PL011::PL011_IMSC_TXIM
@ PL011_IMSC_TXIM
Definition: PL011.h:66
PL011::PL011_ICR_RXIC
@ PL011_ICR_RXIC
Definition: PL011.h:76
PL011::PL011_IMSC
@ PL011_IMSC
Definition: PL011.h:64
PL011::PL011_LCRH_WLEN_8BIT
@ PL011_LCRH_WLEN_8BIT
Definition: PL011.h:59
SerialDevice
Provides sequential byte stream of incoming (RX) and outgoing (TX) data.
Definition: SerialDevice.h:37
PL011::PL011_MIS
@ PL011_MIS
Definition: PL011.h:70
PL011::PL011_MIS_RXMIS
@ PL011_MIS_RXMIS
Definition: PL011.h:71
PL011::PL011_RSRECR
@ PL011_RSRECR
Definition: PL011.h:48
FileSystem::Result
Result
Result code for filesystem Actions.
Definition: FileSystem.h:52
PL011::PL011_ITOP
@ PL011_ITOP
Definition: PL011.h:81
PL011::interrupt
virtual FileSystem::Result interrupt(const Size vector)
Called when an interrupt has been triggered for this device.
Definition: PL011.cpp:87
PL011::PL011_MIS_TXMIS
@ PL011_MIS_TXMIS
Definition: PL011.h:72
PL011::read
virtual FileSystem::Result read(IOBuffer &buffer, Size &size, const Size offset)
Read bytes from the device.
Definition: PL011.cpp:108
PL011::initialize
virtual FileSystem::Result initialize()
Initializes the UART.
Definition: PL011.cpp:34
PL011::PL011_FR_TXFE
@ PL011_FR_TXFE
Definition: PL011.h:52
PL011::PL011_ICR_TXIC
@ PL011_ICR_TXIC
Definition: PL011.h:75