gem5  v22.1.0.0
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__
const char data[]
MMIO Registers 0x0000 - 0x3FFF: msip (write-through to misc reg file) ...: reserved[0] 0x4000 - 0xBFF...
Definition: clint.hh:104
ClintRegisters(const std::string &name, Addr base, Clint *clint)
Definition: clint.hh:115
std::vector< Register64 > mtimecmp
Definition: clint.hh:111
std::vector< RegisterRaz > reserved
Definition: clint.hh:113
std::vector< Register32 > msip
Definition: clint.hh:110
NOTE: This implementation of CLINT is based on the SiFive U54MC datasheet: https://sifive....
Definition: clint.hh:71
System * system
Definition: clint.hh:74
int nThread
Definition: clint.hh:75
ClintRegisters::Register32 Register32
Definition: clint.hh:125
IntSinkPin< Clint > signal
Definition: clint.hh:76
void lowerInterruptPin(int id)
Definition: clint.hh:90
ClintParams Params
Definition: clint.hh:79
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
PioDeviceParams Params
Definition: io_device.hh:134
Ports are used to interface objects to each other.
Definition: port.hh:62
Bitfield< 5, 3 > reg
Definition: types.hh:92
Bitfield< 51, 12 > base
Definition: pagetable.hh:141
const FlagsType init
This Stat is Initialized.
Definition: info.hh:56
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
const PortID InvalidPortID
Definition: types.hh:246
std::ostream CheckpointOut
Definition: serialize.hh:66
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
void unserialize(ThreadContext &tc, CheckpointIn &cp)
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:245
uint64_t Tick
Tick count type.
Definition: types.hh:58
void serialize(const ThreadContext &tc, CheckpointOut &cp)
Thread context serialization helpers.
Declaration of the Packet class.
const std::string & name()
Definition: trace.cc:49

Generated on Wed Dec 21 2022 10:22:34 for gem5 by doxygen 1.9.1