gem5 [DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
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
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
51namespace gem5
52{
53
54using namespace RiscvISA;
55
64
70class Clint : public BasicPioDevice
71{
72 // Params
73 protected:
79
80 public:
81 typedef ClintParams Params;
82 Clint(const Params &params);
83
84 // RTC Signal
85 public:
91 void raiseInterruptPin(int id);
92 void lowerInterruptPin(int id) {}
93
94 // Interrupt ID
96 {
97 INT_RTC = 0, // received from RTC(signal port)
98 INT_RESET, // received from reset port
99 };
100
101 // Register bank
102 public:
103
114 {
115 public:
116 const Addr mtimecmpStart = 0x4000;
117 const Addr mtimeStart = 0xBFF8;
118 const Addr minBankSize = 0xC000;
119
122 Register64 mtime = {"mtime", 0};
124
125 ClintRegisters(const std::string &name, Addr base, Clint* clint,
126 uint64_t mtimecmp_reset_value) :
128 clint(clint),
129 mtimecmpResetValue(mtimecmp_reset_value) {}
130
133
134 void init();
135
137
139
140 void writeMSIP(Register32& reg, const uint32_t& data, const int thread_id);
141
142 // External API
143 public:
147 Tick read(PacketPtr pkt) override;
148 Tick write(PacketPtr pkt) override;
149
153 void init() override;
154 Port & getPort(const std::string &if_name,
155 PortID idx=InvalidPortID) override;
156 void serialize(CheckpointOut &cp) const override;
157 void unserialize(CheckpointIn &cp) override;
158
162 void updateMSIP(const int thread_id);
163
164 // CLINT reset
165 public:
166 void doReset();
167
168};
169
170} // namespace gem5
171
172#endif // __DEV_RISCV_CLINT_HH__
const char data[]
BasicPioDevice(const Params &p, Addr size)
Definition io_device.cc:75
std::vector< Register64 > mtimecmp
Definition clint.hh:121
ClintRegisters(const std::string &name, Addr base, Clint *clint, uint64_t mtimecmp_reset_value)
Definition clint.hh:125
std::vector< RegisterRaz > reserved
Definition clint.hh:123
std::vector< Register32 > msip
Definition clint.hh:120
void updateMSIP(const int thread_id)
Software Interrupt.
Definition clint.cc:239
void raiseInterruptPin(int id)
Timer tick callback.
Definition clint.cc:70
Clint(const Params &params)
Definition clint.cc:52
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition clint.cc:204
System * system
Definition clint.hh:74
void init() override
SimObject functions.
Definition clint.cc:197
int nThread
Definition clint.hh:75
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition clint.cc:183
SignalSinkPort< bool > reset
Definition clint.hh:77
ClintRegisters::Register32 Register32
Definition clint.hh:138
IntSinkPin< Clint > signal
Definition clint.hh:76
void lowerInterruptPin(int id)
Definition clint.hh:92
void writeMSIP(Register32 &reg, const uint32_t &data, const int thread_id)
Definition clint.cc:154
gem5::Clint::ClintRegisters registers
@ INT_RESET
Definition clint.hh:98
void doReset()
Definition clint.cc:254
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition clint.cc:227
bool resetMtimecmp
Definition clint.hh:78
ClintParams Params
Definition clint.hh:81
Tick read(PacketPtr pkt) override
PioDevice interface functions.
Definition clint.cc:161
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition clint.cc:215
Ports are used to interface objects to each other.
Definition port.hh:62
const std::string & name() const
Definition reg_bank.hh:1028
STL vector class.
Definition stl.hh:37
const Params & params() const
Bitfield< 5, 3 > reg
Definition types.hh:92
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
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
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
Packet * PacketPtr
RegisterBank< ByteOrder::little > RegisterBankLE
Definition reg_bank.hh:1128
IntSinkPinBase IntSinkPin
Definition intpin.hh:77
Declaration of the Packet class.

Generated on Mon May 26 2025 09:19:10 for gem5 by doxygen 1.13.2