gem5  v21.1.0.2
clint.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 Huawei International
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #ifndef __DEV_RISCV_CLINT_HH__
39 #define __DEV_RISCV_CLINT_HH__
40 
41 #include "arch/riscv/interrupts.hh"
42 #include "dev/intpin.hh"
43 #include "dev/io_device.hh"
44 #include "dev/mc146818.hh"
45 #include "dev/reg_bank.hh"
46 #include "mem/packet.hh"
47 #include "mem/packet_access.hh"
48 #include "params/Clint.hh"
49 #include "sim/system.hh"
50 
51 namespace gem5
52 {
53 
54 using namespace RiscvISA;
55 
70 class Clint : public BasicPioDevice
71 {
72  // Params
73  protected:
75  int nThread;
77 
78  public:
79  typedef ClintParams Params;
80  Clint(const Params &params);
81 
82  // RTC Signal
83  public:
89  void raiseInterruptPin(int id);
90  void lowerInterruptPin(int id) {}
91 
92  // Register bank
93  public:
94 
104  {
105  public:
106  const Addr mtimecmpStart = 0x4000;
107  const Addr mtimeStart = 0xBFF8;
108  const Addr maxBankSize = 0xC000;
109 
112  Register64 mtime = {"mtime", 0};
114 
115  ClintRegisters(const std::string &name, Addr base, Clint* clint) :
117  clint(clint) {}
118 
120 
121  void init();
122 
123  } registers;
124 
126 
127  uint32_t readMSIP(Register32& reg, const int thread_id);
128  void writeMSIP(Register32& reg, const uint32_t& data, const int thread_id);
129 
130  // External API
131  public:
135  Tick read(PacketPtr pkt) override;
136  Tick write(PacketPtr pkt) override;
137 
141  void init() override;
142  Port & getPort(const std::string &if_name,
143  PortID idx=InvalidPortID) override;
144  void serialize(CheckpointOut &cp) const override;
145  void unserialize(CheckpointIn &cp) override;
146 
147 };
148 
149 } // namespace gem5
150 
151 #endif // __DEV_RISCV_CLINT_HH__
gem5::PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:252
gem5::unserialize
void unserialize(ThreadContext &tc, CheckpointIn &cp)
Definition: thread_context.cc:206
gem5::Clint::nThread
int nThread
Definition: clint.hh:75
io_device.hh
system.hh
data
const char data[]
Definition: circlebuf.test.cc:48
gem5::Clint::signal
IntSinkPin< Clint > signal
Definition: clint.hh:76
gem5::CheckpointIn
Definition: serialize.hh:68
interrupts.hh
std::vector< Register32 >
gem5::X86ISA::base
Bitfield< 51, 12 > base
Definition: pagetable.hh:141
gem5::InvalidPortID
const PortID InvalidPortID
Definition: types.hh:253
gem5::Clint::ClintRegisters::reserved
std::vector< RegisterRaz > reserved
Definition: clint.hh:113
gem5::Clint::system
System * system
Definition: clint.hh:74
gem5::Clint::ClintRegisters::mtimecmp
std::vector< Register64 > mtimecmp
Definition: clint.hh:111
packet.hh
gem5::PioDevice::Params
PioDeviceParams Params
Definition: io_device.hh:134
gem5::System
Definition: system.hh:77
gem5::Clint
NOTE: This implementation of CLINT is based on the SiFive U54MC datasheet: https://sifive....
Definition: clint.hh:70
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:283
gem5::Clint::Register32
ClintRegisters::Register32 Register32
Definition: clint.hh:125
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::Clint::ClintRegisters::ClintRegisters
ClintRegisters(const std::string &name, Addr base, Clint *clint)
Definition: clint.hh:115
gem5::serialize
void serialize(const ThreadContext &tc, CheckpointOut &cp)
Thread context serialization helpers.
Definition: thread_context.cc:157
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
name
const std::string & name()
Definition: trace.cc:49
packet_access.hh
gem5::X86ISA::reg
Bitfield< 5, 3 > reg
Definition: types.hh:92
gem5::Clint::Params
ClintParams Params
Definition: clint.hh:79
gem5::Clint::ClintRegisters
MMIO Registers 0x0000 - 0x3FFF: msip (write-through to misc reg file) ...: reserved[0] 0x4000 - 0xBFF...
Definition: clint.hh:103
gem5::Port
Ports are used to interface objects to each other.
Definition: port.hh:61
gem5::Clint::ClintRegisters::clint
Clint * clint
Definition: clint.hh:119
gem5::IntSinkPin
Definition: intpin.hh:78
gem5::RegisterBank< ByteOrder::little >
gem5::CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:66
gem5::statistics::init
const FlagsType init
This Stat is Initialized.
Definition: info.hh:56
intpin.hh
gem5::Clint::lowerInterruptPin
void lowerInterruptPin(int id)
Definition: clint.hh:90
gem5::RegisterBank< ByteOrder::little >::Register32
Register< uint32_t > Register32
Definition: reg_bank.hh:794
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::Clint::ClintRegisters::msip
std::vector< Register32 > msip
Definition: clint.hh:110
gem5::BasicPioDevice
Definition: io_device.hh:147
gem5::RegisterBank< ByteOrder::little >::Register64
Register< uint64_t > Register64
Definition: reg_bank.hh:797
reg_bank.hh
mc146818.hh

Generated on Tue Sep 21 2021 12:25:18 for gem5 by doxygen 1.8.17