gem5 v24.0.0.0
Loading...
Searching...
No Matches
interrupts.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Google
3 * Copyright (c) 2024 University of Rostock
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#ifndef __ARCH_RISCV_INTERRUPT_HH__
31#define __ARCH_RISCV_INTERRUPT_HH__
32
33#include <bitset>
34#include <memory>
35
37#include "arch/riscv/faults.hh"
39#include "base/logging.hh"
40#include "cpu/base.hh"
41#include "cpu/thread_context.hh"
42#include "debug/Interrupt.hh"
43#include "dev/intpin.hh"
44#include "params/RiscvInterrupts.hh"
45#include "sim/sim_object.hh"
46
47namespace gem5
48{
49
50class BaseCPU;
51class ThreadContext;
52
53namespace RiscvISA {
54
55/*
56 * This is based on version 1.10 of the RISC-V privileged ISA reference,
57 * chapter 3.1.14.
58 */
60{
61 private:
62 std::bitset<NumInterruptTypes> ip;
63 std::bitset<NumInterruptTypes> ie;
64
66 public:
67 using Params = RiscvInterruptsParams;
68
69 Interrupts(const Params &p);
70
71 std::bitset<NumInterruptTypes> globalMask() const;
72
73 bool
78
79 bool checkInterrupt(int num) const { return ip[num] && ie[num]; }
80 bool checkInterrupts() const override
81 {
82 return checkNonMaskableInterrupt() || (ip & ie & globalMask()).any();
83 }
84
85 Fault getInterrupt() override;
86
87 void updateIntrInfo() override {}
88
89 void post(int int_num, int index) override;
90
91 void clear(int int_num, int index) override;
92
95
96 void clearAll() override;
97
98 uint64_t readIP() const { return (uint64_t)ip.to_ulong(); }
99 uint64_t readIE() const { return (uint64_t)ie.to_ulong(); }
100 void setIP(const uint64_t& val) { ip = val; }
101 void setIE(const uint64_t& val) { ie = val; }
102
103 void serialize(CheckpointOut &cp) const override;
104
105 void unserialize(CheckpointIn &cp) override;
106
107 Port &getPort(const std::string &if_name, PortID idx) override;
108
109 void raiseInterruptPin(uint32_t num);
110 void lowerInterruptPin(uint32_t num) {};
111};
112
113} // namespace RiscvISA
114} // namespace gem5
115
116#endif // __ARCH_RISCV_INTERRUPT_HH__
ThreadContext * tc
Definition interrupts.hh:44
Ports are used to interface objects to each other.
Definition port.hh:62
std::vector< gem5::IntSinkPin< Interrupts > * > localInterruptPins
Definition interrupts.hh:65
void setIP(const uint64_t &val)
void setIE(const uint64_t &val)
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Interrupts(const Params &p)
Definition interrupts.cc:39
uint64_t readIE() const
Definition interrupts.hh:99
void clear(int int_num, int index) override
bool checkInterrupts() const override
Definition interrupts.hh:80
bool checkNonMaskableInterrupt() const
Definition interrupts.hh:74
uint64_t readIP() const
Definition interrupts.hh:98
void lowerInterruptPin(uint32_t num)
void post(int int_num, int index) override
void serialize(CheckpointOut &cp) const override
Serialize an object.
void raiseInterruptPin(uint32_t num)
Port & getPort(const std::string &if_name, PortID idx) override
Get a port with a given name and index.
RiscvInterruptsParams Params
Definition interrupts.hh:67
void updateIntrInfo() override
Definition interrupts.hh:87
std::bitset< NumInterruptTypes > globalMask() const
Definition interrupts.cc:58
std::bitset< NumInterruptTypes > ip
Definition interrupts.hh:62
bool checkInterrupt(int num) const
Definition interrupts.hh:79
Fault getInterrupt() override
std::bitset< NumInterruptTypes > ie
Definition interrupts.hh:63
virtual RegVal readMiscReg(RegIndex misc_reg)=0
virtual void setMiscReg(RegIndex misc_reg, RegVal val)=0
STL vector class.
Definition stl.hh:37
Bitfield< 0 > p
Bitfield< 30, 0 > index
Bitfield< 63 > val
Definition misc.hh:804
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
std::shared_ptr< FaultBase > Fault
Definition types.hh:249
std::ostream CheckpointOut
Definition serialize.hh:66
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition types.hh:245

Generated on Tue Jun 18 2024 16:23:57 for gem5 by doxygen 1.11.0