gem5  v20.1.0.0
uart8250.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2005 The Regents of The University of Michigan
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met: redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
33 #ifndef __DEV_UART8250_HH__
34 #define __DEV_UART8250_HH__
35 
36 #include "dev/io_device.hh"
37 #include "dev/serial/uart.hh"
38 #include "params/Uart8250.hh"
39 
40 /* UART8250 Interrupt ID Register
41  * bit 0 Interrupt Pending 0 = true, 1 = false
42  * bit 2:1 ID of highest priority interrupt
43  * bit 7:3 zeroes
44  */
45 const uint8_t IIR_NOPEND = 0x1;
46 
47 // Interrupt IDs
48 const uint8_t IIR_MODEM = 0x00; /* Modem Status (lowest priority) */
49 const uint8_t IIR_TXID = 0x02; /* Tx Data */
50 const uint8_t IIR_RXID = 0x04; /* Rx Data */
51 const uint8_t IIR_LINE = 0x06; /* Rx Line Status (highest priority)*/
52 
53 const uint8_t UART_IER_RDI = 0x01;
54 const uint8_t UART_IER_THRI = 0x02;
55 const uint8_t UART_IER_RLSI = 0x04;
56 
57 
58 const uint8_t UART_LSR_TEMT = 0x40;
59 const uint8_t UART_LSR_THRE = 0x20;
60 const uint8_t UART_LSR_DR = 0x01;
61 
62 const uint8_t UART_MCR_LOOP = 0x10;
63 
64 
65 class Terminal;
66 class Platform;
67 
68 class Uart8250 : public Uart
69 {
70  protected:
71  uint8_t IER, DLAB, LCR, MCR;
73 
74  void processIntrEvent(int intrBit);
75  void scheduleIntr(Event *event);
76 
79 
80  public:
81  typedef Uart8250Params Params;
82  const Params *
83  params() const
84  {
85  return dynamic_cast<const Params *>(_params);
86  }
87  Uart8250(const Params *p);
88 
89  Tick read(PacketPtr pkt) override;
90  Tick write(PacketPtr pkt) override;
91  AddrRangeList getAddrRanges() const override;
92 
96  void dataAvailable() override;
97 
98 
103  virtual bool intStatus() { return status ? true : false; }
104 
105  void serialize(CheckpointOut &cp) const override;
106  void unserialize(CheckpointIn &cp) override;
107 };
108 
109 #endif // __TSUNAMI_UART_HH__
io_device.hh
UART_IER_RLSI
const uint8_t UART_IER_RLSI
Definition: uart8250.hh:55
Uart8250::DLAB
uint8_t DLAB
Definition: uart8250.hh:71
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
Uart8250::processIntrEvent
void processIntrEvent(int intrBit)
Definition: uart8250.cc:48
IIR_RXID
const uint8_t IIR_RXID
Definition: uart8250.hh:50
EventFunctionWrapper
Definition: eventq.hh:1101
Uart8250::txIntrEvent
EventFunctionWrapper txIntrEvent
Definition: uart8250.hh:77
Uart8250::getAddrRanges
AddrRangeList getAddrRanges() const override
Determine the address ranges that this device responds to.
Definition: uart8250.cc:276
Uart8250::MCR
uint8_t MCR
Definition: uart8250.hh:71
Uart8250::Uart8250
Uart8250(const Params *p)
Definition: uart8250.cc:86
Uart8250::write
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: uart8250.cc:175
cp
Definition: cprintf.cc:40
Uart
Definition: uart.hh:46
Uart8250::params
const Params * params() const
Definition: uart8250.hh:83
Event
Definition: eventq.hh:246
Uart8250::Params
Uart8250Params Params
Definition: uart8250.hh:81
Uart8250
Definition: uart8250.hh:68
uart.hh
MipsISA::event
Bitfield< 10, 5 > event
Definition: pra_constants.hh:297
PioDevice::Params
PioDeviceParams Params
Definition: io_device.hh:131
UART_LSR_TEMT
const uint8_t UART_LSR_TEMT
Definition: uart8250.hh:58
Uart::status
int status
Definition: uart.hh:49
IIR_NOPEND
const uint8_t IIR_NOPEND
Definition: uart8250.hh:45
Platform
Definition: platform.hh:49
IIR_MODEM
const uint8_t IIR_MODEM
Definition: uart8250.hh:48
Uart8250::read
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: uart8250.cc:94
Uart8250::scheduleIntr
void scheduleIntr(Event *event)
Definition: uart8250.cc:74
IIR_TXID
const uint8_t IIR_TXID
Definition: uart8250.hh:49
Uart8250::lastTxInt
Tick lastTxInt
Definition: uart8250.hh:72
Uart8250::rxIntrEvent
EventFunctionWrapper rxIntrEvent
Definition: uart8250.hh:78
UART_IER_RDI
const uint8_t UART_IER_RDI
Definition: uart8250.hh:53
Uart8250::intStatus
virtual bool intStatus()
Return if we have an interrupt pending.
Definition: uart8250.hh:103
Uart8250::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: uart8250.cc:284
Uart8250::IER
uint8_t IER
Definition: uart8250.hh:71
SimObject::_params
const SimObjectParams * _params
Cached copy of the object parameters.
Definition: sim_object.hh:110
UART_MCR_LOOP
const uint8_t UART_MCR_LOOP
Definition: uart8250.hh:62
UART_IER_THRI
const uint8_t UART_IER_THRI
Definition: uart8250.hh:54
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
Uart8250::dataAvailable
void dataAvailable() override
Inform the uart that there is data available.
Definition: uart8250.cc:264
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
std::list< AddrRange >
CheckpointIn
Definition: serialize.hh:67
IIR_LINE
const uint8_t IIR_LINE
Definition: uart8250.hh:51
UART_LSR_DR
const uint8_t UART_LSR_DR
Definition: uart8250.hh:60
Uart8250::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: uart8250.cc:306
Uart8250::LCR
uint8_t LCR
Definition: uart8250.hh:71
Terminal
Definition: terminal.hh:61
UART_LSR_THRE
const uint8_t UART_LSR_THRE
Definition: uart8250.hh:59

Generated on Wed Sep 30 2020 14:02:11 for gem5 by doxygen 1.8.17