gem5  v20.1.0.0
gic.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2017 ARM Limited
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 __ARCH_ARM_KVM_GIC_HH__
39 #define __ARCH_ARM_KVM_GIC_HH__
40 
41 #include "arch/arm/system.hh"
42 #include "cpu/kvm/device.hh"
43 #include "cpu/kvm/vm.hh"
44 #include "dev/arm/gic_v2.hh"
45 #include "dev/platform.hh"
46 
55 {
56  public:
68  KvmKernelGicV2(KvmVM &vm, Addr cpu_addr, Addr dist_addr,
69  unsigned it_lines);
70  virtual ~KvmKernelGicV2();
71 
72  KvmKernelGicV2(const KvmKernelGicV2 &other) = delete;
73  KvmKernelGicV2(const KvmKernelGicV2 &&other) = delete;
74  KvmKernelGicV2 &operator=(const KvmKernelGicV2 &&rhs) = delete;
75  KvmKernelGicV2 &operator=(const KvmKernelGicV2 &rhs) = delete;
76 
77  public:
88  void setSPI(unsigned spi);
94  void clearSPI(unsigned spi);
95 
102  void setPPI(unsigned vcpu, unsigned ppi);
103 
110  void clearPPI(unsigned vcpu, unsigned ppi);
111 
116 
118  uint32_t readDistributor(ContextID ctx, Addr daddr) override;
119  uint32_t readCpu(ContextID ctx, Addr daddr) override;
120 
121  void writeDistributor(ContextID ctx, Addr daddr,
122  uint32_t data) override;
123  void writeCpu(ContextID ctx, Addr daddr, uint32_t data) override;
124 
125  /* @} */
126 
127  protected:
136  void setIntState(unsigned type, unsigned vcpu, unsigned irq, bool high);
137 
145  uint32_t getGicReg(unsigned group, unsigned vcpu, unsigned offset);
146 
155  void setGicReg(unsigned group, unsigned vcpu, unsigned offset,
156  unsigned value);
157 
160 
163 };
164 
165 
166 struct MuxingKvmGicParams;
167 
168 class MuxingKvmGic : public GicV2
169 {
170  public: // SimObject / Serializable / Drainable
171  MuxingKvmGic(const MuxingKvmGicParams *p);
172  ~MuxingKvmGic();
173 
174  void startup() override;
175  DrainState drain() override;
176  void drainResume() override;
177 
178  public: // PioDevice
179  Tick read(PacketPtr pkt) override;
180  Tick write(PacketPtr pkt) override;
181 
182  public: // GicV2
183  void sendInt(uint32_t num) override;
184  void clearInt(uint32_t num) override;
185 
186  void sendPPInt(uint32_t num, uint32_t cpu) override;
187  void clearPPInt(uint32_t num, uint32_t cpu) override;
188 
189  protected: // GicV2
190  void updateIntState(int hint) override;
191 
192  protected:
195 
198 
199  private:
200  bool usingKvm;
201 
203  void fromGicV2ToKvm();
204  void fromKvmToGicV2();
205 
207 
209  ContextID ctx, Addr daddr);
211  ContextID ctx, Addr daddr);
212 
214  Addr daddr, size_t size);
216  Addr daddr, size_t size);
218  Addr daddr, size_t size);
220  Addr daddr, size_t size);
221 };
222 
223 #endif // __ARCH_ARM_KVM_GIC_HH__
KvmVM
KVM VM container.
Definition: vm.hh:289
MuxingKvmGic::fromGicV2ToKvm
void fromGicV2ToKvm()
Multiplexing implementation.
Definition: gic.cc:409
KvmKernelGicV2::setSPI
void setSPI(unsigned spi)
Raise a shared peripheral interrupt.
Definition: gic.cc:71
KvmKernelGicV2::writeCpu
void writeCpu(ContextID ctx, Addr daddr, uint32_t data) override
Definition: gic.cc:159
data
const char data[]
Definition: circlebuf.test.cc:42
MuxingKvmGic::clearPPInt
void clearPPInt(uint32_t num, uint32_t cpu) override
Definition: gic.cc:263
MuxingKvmGic::fromKvmToGicV2
void fromKvmToGicV2()
Definition: gic.cc:415
KvmKernelGicV2
KVM in-kernel GIC abstraction.
Definition: gic.hh:54
ContextID
int ContextID
Globally unique thread context ID.
Definition: types.hh:231
KvmDevice
KVM device wrapper.
Definition: device.hh:57
type
uint8_t type
Definition: inet.hh:421
GicV2
Definition: gic_v2.hh:60
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
KvmKernelGicV2::readDistributor
uint32_t readDistributor(ContextID ctx, Addr daddr) override
BaseGicRegisters interface.
Definition: gic.cc:138
MuxingKvmGic::copyDistRange
void copyDistRange(BaseGicRegisters *from, BaseGicRegisters *to, Addr daddr, size_t size)
Definition: gic.cc:320
MuxingKvmGic::drainResume
void drainResume() override
Resume execution after a successful drain.
Definition: gic.cc:201
KvmKernelGicV2::KvmKernelGicV2
KvmKernelGicV2(KvmVM &vm, Addr cpu_addr, Addr dist_addr, unsigned it_lines)
Instantiate a KVM in-kernel GIC model.
Definition: gic.cc:47
MuxingKvmGic::drain
DrainState drain() override
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
Definition: gic.cc:193
KvmKernelGicV2::clearPPI
void clearPPI(unsigned vcpu, unsigned ppi)
Clear a private peripheral interrupt.
Definition: gic.cc:89
MuxingKvmGic::read
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: gic.cc:216
KvmKernelGicV2::getGicReg
uint32_t getGicReg(unsigned group, unsigned vcpu, unsigned offset)
Get value of GIC register "from" a cpu.
Definition: gic.cc:110
system.hh
MuxingKvmGic::write
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: gic.cc:225
KvmKernelGicV2::writeDistributor
void writeDistributor(ContextID ctx, Addr daddr, uint32_t data) override
Definition: gic.cc:152
DrainState
DrainState
Object drain/handover states.
Definition: drain.hh:71
MuxingKvmGic::kernelGic
KvmKernelGicV2 * kernelGic
Kernel GIC device.
Definition: gic.hh:197
MuxingKvmGic::sendPPInt
void sendPPInt(uint32_t num, uint32_t cpu) override
Interface call for private peripheral interrupts.
Definition: gic.cc:254
AddrRange
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition: addr_range.hh:68
KvmKernelGicV2::~KvmKernelGicV2
virtual ~KvmKernelGicV2()
Definition: gic.cc:66
BaseGicRegisters
Definition: base_gic.hh:117
System
Definition: system.hh:73
KvmKernelGicV2::cpuRange
const AddrRange cpuRange
Address range for the CPU interfaces.
Definition: gic.hh:113
KvmKernelGicV2::setGicReg
void setGicReg(unsigned group, unsigned vcpu, unsigned offset, unsigned value)
Set value of GIC register "from" a cpu.
Definition: gic.cc:124
device.hh
MuxingKvmGic::system
System & system
System this interrupt controller belongs to.
Definition: gic.hh:194
KvmKernelGicV2::vm
KvmVM & vm
KVM VM in the parent system.
Definition: gic.hh:159
KvmKernelGicV2::readCpu
uint32_t readCpu(ContextID ctx, Addr daddr) override
Definition: gic.cc:145
MuxingKvmGic::usingKvm
bool usingKvm
Definition: gic.hh:200
platform.hh
KvmKernelGicV2::setIntState
void setIntState(unsigned type, unsigned vcpu, unsigned irq, bool high)
Update the kernel's VGIC interrupt state.
Definition: gic.cc:95
MuxingKvmGic::~MuxingKvmGic
~MuxingKvmGic()
Definition: gic.cc:179
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
vm.hh
MuxingKvmGic::clearInt
void clearInt(uint32_t num) override
Clear an interrupt from a device that is connected to the GIC.
Definition: gic.cc:244
ArmISA::irq
Bitfield< 1 > irq
Definition: miscregs_types.hh:327
KvmKernelGicV2::kdev
KvmDevice kdev
Kernel interface to the GIC.
Definition: gic.hh:162
MuxingKvmGic::clearDistRange
void clearDistRange(BaseGicRegisters *to, Addr daddr, size_t size)
Definition: gic.cc:328
MuxingKvmGic::copyCpuRegister
void copyCpuRegister(BaseGicRegisters *from, BaseGicRegisters *to, ContextID ctx, Addr daddr)
Definition: gic.cc:293
MuxingKvmGic::updateIntState
void updateIntState(int hint) override
See if some processor interrupt flags need to be enabled/disabled.
Definition: gic.cc:273
MuxingKvmGic::copyBankedDistRange
void copyBankedDistRange(BaseGicRegisters *from, BaseGicRegisters *to, Addr daddr, size_t size)
Definition: gic.cc:302
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
KvmKernelGicV2::setPPI
void setPPI(unsigned vcpu, unsigned ppi)
Raise a private peripheral interrupt.
Definition: gic.cc:83
MuxingKvmGic::MuxingKvmGic
MuxingKvmGic(const MuxingKvmGicParams *p)
Definition: gic.cc:167
MuxingKvmGic::clearBankedDistRange
void clearBankedDistRange(BaseGicRegisters *to, Addr daddr, size_t size)
Definition: gic.cc:311
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
gic_v2.hh
KvmKernelGicV2::operator=
KvmKernelGicV2 & operator=(const KvmKernelGicV2 &&rhs)=delete
KvmKernelGicV2::clearSPI
void clearSPI(unsigned spi)
Clear a shared peripheral interrupt.
Definition: gic.cc:77
MuxingKvmGic::copyDistRegister
void copyDistRegister(BaseGicRegisters *from, BaseGicRegisters *to, ContextID ctx, Addr daddr)
Definition: gic.cc:284
KvmKernelGicV2::distRange
const AddrRange distRange
Address range for the distributor interface.
Definition: gic.hh:115
MuxingKvmGic
Definition: gic.hh:168
MuxingKvmGic::copyGicState
void copyGicState(BaseGicRegisters *from, BaseGicRegisters *to)
Definition: gic.cc:336
MuxingKvmGic::sendInt
void sendInt(uint32_t num) override
Post an interrupt from a device that is connected to the GIC.
Definition: gic.cc:234
MuxingKvmGic::startup
void startup() override
startup() is the final initialization call before simulation.
Definition: gic.cc:184
ArmISA::offset
Bitfield< 23, 0 > offset
Definition: types.hh:153

Generated on Wed Sep 30 2020 14:01:58 for gem5 by doxygen 1.8.17