gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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_pl390.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 Pl390
172 {
173  public: // SimObject / Serializable / Drainable
174  MuxingKvmGic(const MuxingKvmGicParams *p);
175  ~MuxingKvmGic();
176 
177  void loadState(CheckpointIn &cp) override;
178 
179  void startup() override;
180  DrainState drain() override;
181  void drainResume() override;
182 
183  void serialize(CheckpointOut &cp) const override;
184  void unserialize(CheckpointIn &cp) override;
185 
186  public: // PioDevice
187  Tick read(PacketPtr pkt) override;
188  Tick write(PacketPtr pkt) override;
189 
190  public: // Pl390
191  void sendInt(uint32_t num) override;
192  void clearInt(uint32_t num) override;
193 
194  void sendPPInt(uint32_t num, uint32_t cpu) override;
195  void clearPPInt(uint32_t num, uint32_t cpu) override;
196 
197  protected:
199  bool validKvmEnvironment() const;
200 
203 
206 
207  private:
208  bool usingKvm;
209 
211  void fromPl390ToKvm();
212  void fromKvmToPl390();
213 
215 
217  ContextID ctx, Addr daddr);
219  ContextID ctx, Addr daddr);
220 
222  Addr daddr, size_t size);
224  Addr daddr, size_t size);
226  Addr daddr, size_t size);
228  Addr daddr, size_t size);
229 };
230 
231 #endif // __ARCH_ARM_KVM_GIC_HH__
void writeDistributor(ContextID ctx, Addr daddr, uint32_t data) override
Definition: gic.cc:151
void fromPl390ToKvm()
Multiplexing implementation.
Definition: gic.cc:430
uint32_t getGicReg(unsigned group, unsigned vcpu, unsigned offset)
Get value of GIC register "from" a cpu.
Definition: gic.cc:109
System & system
System this interrupt controller belongs to.
Definition: gic.hh:202
void sendInt(uint32_t num) override
Post an interrupt from a device that is connected to the GIC.
Definition: gic.cc:252
void setPPI(unsigned vcpu, unsigned ppi)
Raise a private peripheral interrupt.
Definition: gic.cc:82
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: gic.cc:234
void clearPPInt(uint32_t num, uint32_t cpu) override
Definition: gic.cc:281
void fromKvmToPl390()
Definition: gic.cc:436
DrainState
Object drain/handover states.
Definition: drain.hh:71
void copyDistRange(BaseGicRegisters *from, BaseGicRegisters *to, Addr daddr, size_t size)
Definition: gic.cc:341
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: gic.cc:221
void loadState(CheckpointIn &cp) override
loadState() is called on each SimObject when restoring from a checkpoint.
Definition: gic.cc:183
void sendPPInt(uint32_t num, uint32_t cpu) override
Interface call for private peripheral interrupts.
Definition: gic.cc:272
Definition: system.hh:83
Bitfield< 23, 0 > offset
Definition: types.hh:149
void setIntState(unsigned type, unsigned vcpu, unsigned irq, bool high)
Update the kernel's VGIC interrupt state.
Definition: gic.cc:94
bool usingKvm
Definition: gic.hh:208
const char data[]
Definition: circlebuf.cc:43
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: gic.cc:228
bool validKvmEnvironment() const
Verify gem5 configuration will support KVM emulation.
Definition: gic.cc:291
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition: addr_range.hh:72
void clearDistRange(BaseGicRegisters *to, Addr daddr, size_t size)
Definition: gic.cc:349
~MuxingKvmGic()
Definition: gic.cc:178
KvmKernelGicV2 & operator=(const KvmKernelGicV2 &&rhs)=delete
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: gic.cc:243
KVM device wrapper.
Definition: device.hh:59
uint64_t Tick
Tick count type.
Definition: types.hh:63
void copyCpuRegister(BaseGicRegisters *from, BaseGicRegisters *to, ContextID ctx, Addr daddr)
Definition: gic.cc:314
void clearBankedDistRange(BaseGicRegisters *to, Addr daddr, size_t size)
Definition: gic.cc:332
DrainState drain() override
Notify an object that it needs to drain its state.
Definition: gic.cc:198
void copyBankedDistRange(BaseGicRegisters *from, BaseGicRegisters *to, Addr daddr, size_t size)
Definition: gic.cc:323
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:88
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:245
const AddrRange cpuRange
Address range for the CPU interfaces.
Definition: gic.hh:116
Implementation of a PL390 GIC.
void copyDistRegister(BaseGicRegisters *from, BaseGicRegisters *to, ContextID ctx, Addr daddr)
Definition: gic.cc:305
KvmKernelGicV2 * kernelGic
Kernel GIC device.
Definition: gic.hh:205
void startup() override
startup() is the final initialization call before simulation.
Definition: gic.cc:189
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:158
type
Definition: misc.hh:728
Generic interface for platforms.
KVM VM container.
Definition: vm.hh:291
int size()
Definition: pagetable.hh:146
Bitfield< 1 > irq
Definition: miscregs.hh:1520
KVM in-kernel GIC abstraction.
Definition: gic.hh:57
std::ostream CheckpointOut
Definition: serialize.hh:67
KvmVM & vm
KVM VM in the parent system.
Definition: gic.hh:162
virtual ~KvmKernelGicV2()
Definition: gic.cc:65
void drainResume() override
Resume execution after a successful drain.
Definition: gic.cc:206
void copyGicState(BaseGicRegisters *from, BaseGicRegisters *to)
Definition: gic.cc:357
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:70
void setGicReg(unsigned group, unsigned vcpu, unsigned offset, unsigned value)
Set value of GIC register "from" a cpu.
Definition: gic.cc:123
void clearSPI(unsigned spi)
Clear a shared peripheral interrupt.
Definition: gic.cc:76
void clearInt(uint32_t num) override
Clear an interrupt from a device that is connected to the GIC.
Definition: gic.cc:262
Bitfield< 0 > p
MuxingKvmGic(const MuxingKvmGicParams *p)
Definition: gic.cc:166
int ContextID
Globally unique thread context ID.
Definition: types.hh:175
uint32_t readDistributor(ContextID ctx, Addr daddr) override
BaseGicRegisters interface.
Definition: gic.cc:137
uint32_t readCpu(ContextID ctx, Addr daddr) override
Definition: gic.cc:144

Generated on Fri Jun 9 2017 13:03:39 for gem5 by doxygen 1.8.6