gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  * Authors: Andreas Sandberg
38  * Curtis Dunham
39  */
40 
41 #ifndef __ARCH_ARM_KVM_GIC_HH__
42 #define __ARCH_ARM_KVM_GIC_HH__
43 
44 #include "arch/arm/system.hh"
45 #include "cpu/kvm/device.hh"
46 #include "cpu/kvm/vm.hh"
47 #include "dev/arm/gic_v2.hh"
48 #include "dev/platform.hh"
49 
58 {
59  public:
71  KvmKernelGicV2(KvmVM &vm, Addr cpu_addr, Addr dist_addr,
72  unsigned it_lines);
73  virtual ~KvmKernelGicV2();
74 
75  KvmKernelGicV2(const KvmKernelGicV2 &other) = delete;
76  KvmKernelGicV2(const KvmKernelGicV2 &&other) = delete;
77  KvmKernelGicV2 &operator=(const KvmKernelGicV2 &&rhs) = delete;
78  KvmKernelGicV2 &operator=(const KvmKernelGicV2 &rhs) = delete;
79 
80  public:
91  void setSPI(unsigned spi);
97  void clearSPI(unsigned spi);
98 
105  void setPPI(unsigned vcpu, unsigned ppi);
106 
113  void clearPPI(unsigned vcpu, unsigned ppi);
114 
119 
121  uint32_t readDistributor(ContextID ctx, Addr daddr) override;
122  uint32_t readCpu(ContextID ctx, Addr daddr) override;
123 
124  void writeDistributor(ContextID ctx, Addr daddr,
125  uint32_t data) override;
126  void writeCpu(ContextID ctx, Addr daddr, uint32_t data) override;
127 
128  /* @} */
129 
130  protected:
139  void setIntState(unsigned type, unsigned vcpu, unsigned irq, bool high);
140 
148  uint32_t getGicReg(unsigned group, unsigned vcpu, unsigned offset);
149 
158  void setGicReg(unsigned group, unsigned vcpu, unsigned offset,
159  unsigned value);
160 
163 
166 };
167 
168 
169 struct MuxingKvmGicParams;
170 
171 class MuxingKvmGic : public GicV2
172 {
173  public: // SimObject / Serializable / Drainable
174  MuxingKvmGic(const MuxingKvmGicParams *p);
175  ~MuxingKvmGic();
176 
177  void startup() override;
178  DrainState drain() override;
179  void drainResume() override;
180 
181  public: // PioDevice
182  Tick read(PacketPtr pkt) override;
183  Tick write(PacketPtr pkt) override;
184 
185  public: // GicV2
186  void sendInt(uint32_t num) override;
187  void clearInt(uint32_t num) override;
188 
189  void sendPPInt(uint32_t num, uint32_t cpu) override;
190  void clearPPInt(uint32_t num, uint32_t cpu) override;
191 
192  protected: // GicV2
193  void updateIntState(int hint) override;
194 
195  protected:
198 
201 
202  private:
203  bool usingKvm;
204 
206  void fromGicV2ToKvm();
207  void fromKvmToGicV2();
208 
209  void copyGicState(BaseGicRegisters* from, BaseGicRegisters* to);
210 
211  void copyDistRegister(BaseGicRegisters* from, BaseGicRegisters* to,
212  ContextID ctx, Addr daddr);
213  void copyCpuRegister(BaseGicRegisters* from, BaseGicRegisters* to,
214  ContextID ctx, Addr daddr);
215 
216  void copyBankedDistRange(BaseGicRegisters* from, BaseGicRegisters* to,
217  Addr daddr, size_t size);
218  void clearBankedDistRange(BaseGicRegisters* to,
219  Addr daddr, size_t size);
220  void copyDistRange(BaseGicRegisters* from, BaseGicRegisters* to,
221  Addr daddr, size_t size);
222  void clearDistRange(BaseGicRegisters* to,
223  Addr daddr, size_t size);
224 };
225 
226 #endif // __ARCH_ARM_KVM_GIC_HH__
void writeDistributor(ContextID ctx, Addr daddr, uint32_t data) override
Definition: gic.cc:155
uint32_t getGicReg(unsigned group, unsigned vcpu, unsigned offset)
Get value of GIC register "from" a cpu.
Definition: gic.cc:113
System & system
System this interrupt controller belongs to.
Definition: gic.hh:197
void setPPI(unsigned vcpu, unsigned ppi)
Raise a private peripheral interrupt.
Definition: gic.cc:86
DrainState
Object drain/handover states.
Definition: drain.hh:71
Definition: system.hh:77
Bitfield< 23, 0 > offset
Definition: types.hh:154
void setIntState(unsigned type, unsigned vcpu, unsigned irq, bool high)
Update the kernel&#39;s VGIC interrupt state.
Definition: gic.cc:98
bool usingKvm
Definition: gic.hh:203
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition: addr_range.hh:72
uint8_t type
Definition: inet.hh:333
KvmKernelGicV2 & operator=(const KvmKernelGicV2 &&rhs)=delete
KVM device wrapper.
Definition: device.hh:59
uint64_t Tick
Tick count type.
Definition: types.hh:63
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
void clearPPI(unsigned vcpu, unsigned ppi)
Clear a private peripheral interrupt.
Definition: gic.cc:92
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
const AddrRange cpuRange
Address range for the CPU interfaces.
Definition: gic.hh:116
KvmKernelGicV2 * kernelGic
Kernel GIC device.
Definition: gic.hh:200
Definition: gic_v2.hh:61
const AddrRange distRange
Address range for the distributor interface.
Definition: gic.hh:118
void writeCpu(ContextID ctx, Addr daddr, uint32_t data) override
Definition: gic.cc:162
Generic interface for platforms.
KVM VM container.
Definition: vm.hh:291
Bitfield< 1 > irq
KVM in-kernel GIC abstraction.
Definition: gic.hh:57
KvmVM & vm
KVM VM in the parent system.
Definition: gic.hh:162
virtual ~KvmKernelGicV2()
Definition: gic.cc:69
Implementation of a GICv2.
KvmDevice kdev
Kernel interface to the GIC.
Definition: gic.hh:165
KvmKernelGicV2(KvmVM &vm, Addr cpu_addr, Addr dist_addr, unsigned it_lines)
Instantiate a KVM in-kernel GIC model.
Definition: gic.cc:50
void setSPI(unsigned spi)
Raise a shared peripheral interrupt.
Definition: gic.cc:74
void setGicReg(unsigned group, unsigned vcpu, unsigned offset, unsigned value)
Set value of GIC register "from" a cpu.
Definition: gic.cc:127
void clearSPI(unsigned spi)
Clear a shared peripheral interrupt.
Definition: gic.cc:80
Bitfield< 0 > p
const char data[]
int ContextID
Globally unique thread context ID.
Definition: types.hh:231
uint32_t readDistributor(ContextID ctx, Addr daddr) override
BaseGicRegisters interface.
Definition: gic.cc:141
uint32_t readCpu(ContextID ctx, Addr daddr) override
Definition: gic.cc:148

Generated on Fri Feb 28 2020 16:26:56 for gem5 by doxygen 1.8.13