Go to the documentation of this file.
40 #include <linux/kvm.h>
43 #include "debug/GIC.hh"
44 #include "debug/Interrupt.hh"
45 #include "params/MuxingKvmGic.hh"
49 : cpuRange(
RangeSize(cpu_addr, KVM_VGIC_V2_CPU_SIZE)),
50 distRange(
RangeSize(dist_addr, KVM_VGIC_V2_DIST_SIZE)),
52 kdev(
vm.createDevice(KVM_DEV_TYPE_ARM_VGIC_V2))
59 KVM_DEV_ARM_VGIC_GRP_ADDR, KVM_VGIC_V2_ADDR_TYPE_DIST, dist_addr);
61 KVM_DEV_ARM_VGIC_GRP_ADDR, KVM_VGIC_V2_ADDR_TYPE_CPU, cpu_addr);
63 kdev.
setAttr<uint32_t>(KVM_DEV_ARM_VGIC_GRP_NR_IRQS, 0, it_lines);
91 setIntState(KVM_ARM_IRQ_TYPE_PPI, vcpu, ppi,
false);
98 assert(
type <= KVM_ARM_IRQ_TYPE_MASK);
99 assert(vcpu <= KVM_ARM_IRQ_VCPU_MASK);
100 assert(
irq <= KVM_ARM_IRQ_NUM_MASK);
102 (
type << KVM_ARM_IRQ_TYPE_SHIFT) |
103 (vcpu << KVM_ARM_IRQ_VCPU_SHIFT) |
104 (
irq << KVM_ARM_IRQ_NUM_SHIFT));
114 assert(vcpu <= KVM_ARM_IRQ_VCPU_MASK);
116 ((uint64_t)vcpu << KVM_DEV_ARM_VGIC_CPUID_SHIFT) |
117 (
offset << KVM_DEV_ARM_VGIC_OFFSET_SHIFT));
120 return (uint32_t)
reg;
127 uint64_t
reg = value;
129 assert(vcpu <= KVM_ARM_IRQ_VCPU_MASK);
131 ((uint64_t)vcpu << KVM_DEV_ARM_VGIC_CPUID_SHIFT) |
132 (
offset << KVM_DEV_ARM_VGIC_OFFSET_SHIFT));
141 return getGicReg(KVM_DEV_ARM_VGIC_GRP_DIST_REGS, vcpu, daddr);
148 return getGicReg(KVM_DEV_ARM_VGIC_GRP_CPU_REGS, vcpu, daddr);
155 setGicReg(KVM_DEV_ARM_VGIC_GRP_DIST_REGS, vcpu, daddr,
data);
221 panic(
"MuxingKvmGic: PIO from gem5 is currently unsupported\n");
230 panic(
"MuxingKvmGic: PIO from gem5 is currently unsupported\n");
239 DPRINTF(Interrupt,
"Set SPI %d\n", num);
249 DPRINTF(Interrupt,
"Clear SPI %d\n", num);
258 DPRINTF(Interrupt,
"Set PPI %d:%d\n", cpu, num);
268 DPRINTF(Interrupt,
"Clear PPI %d:%d\n", cpu, num);
288 DPRINTF(GIC,
"copy dist 0x%x 0x%08x\n", daddr,
val);
297 DPRINTF(GIC,
"copy cpu 0x%x 0x%08x\n", daddr,
val);
303 Addr daddr,
size_t size)
306 for (
auto a = daddr;
a < daddr + size;
a += 4)
312 Addr daddr,
size_t size)
315 for (
auto a = daddr;
a < daddr + size;
a += 4)
321 Addr daddr,
size_t size)
323 for (
auto a = daddr;
a < daddr + size;
a += 4)
329 Addr daddr,
size_t size)
331 for (
auto a = daddr;
a < daddr + size;
a += 4)
363 set += 4, clear += 4, size -= 4;
374 set += 4, clear += 4, size -= 4;
385 set += 4, clear += 4, size -= 4;
430 MuxingKvmGicParams::create()
void fromGicV2ToKvm()
Multiplexing implementation.
void setSPI(unsigned spi)
Raise a shared peripheral interrupt.
Tick write(PacketPtr pkt) override
A PIO read to the device, immediately split up into writeDistributor() or writeCpu()
static const AddrRange GICD_ISENABLER
void writeCpu(ContextID ctx, Addr daddr, uint32_t data) override
void getAttrPtr(uint32_t group, uint64_t attr, void *data) const
void clearPPInt(uint32_t num, uint32_t cpu) override
void clearInt(ContextID ctx, uint32_t int_num)
Clears a cpu IRQ or FIQ signal.
KVM in-kernel GIC abstraction.
int ContextID
Globally unique thread context ID.
uint64_t Tick
Tick count type.
uint32_t readDistributor(ContextID ctx, Addr daddr) override
BaseGicRegisters interface.
Tick read(PacketPtr pkt) override
A PIO read to the device, immediately split up into readDistributor() or readCpu()
void copyDistRange(BaseGicRegisters *from, BaseGicRegisters *to, Addr daddr, size_t size)
void drainResume() override
Resume execution after a successful drain.
KvmKernelGicV2(KvmVM &vm, Addr cpu_addr, Addr dist_addr, unsigned it_lines)
Instantiate a KVM in-kernel GIC model.
DrainState drain() override
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
void clearPPI(unsigned vcpu, unsigned ppi)
Clear a private peripheral interrupt.
KvmVM * getKvmVM()
Get a pointer to the Kernel Virtual Machine (KVM) SimObject, if present.
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
bool validKvmEnvironment() const
Verify gem5 configuration will support KVM emulation.
uint32_t getGicReg(unsigned group, unsigned vcpu, unsigned offset)
Get value of GIC register "from" a cpu.
void enableKernelIRQChip()
Tell the VM and VCPUs to use an in-kernel IRQ chip for interrupt delivery.
long contextIdToVCpuId(ContextID ctx) const
Get the VCPUID for a given context.
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
static const AddrRange GICD_ICENABLER
virtual void updateIntState(int hint)
See if some processor interrupt flags need to be enabled/disabled.
void writeDistributor(ContextID ctx, Addr daddr, uint32_t data) override
virtual void startup()
startup() is the final initialization call before simulation.
DrainState
Object drain/handover states.
void setAttr(uint32_t group, uint64_t attr, const T &data) const
Get the value of an attribute.
KvmKernelGicV2 * kernelGic
Kernel GIC device.
void sendPPInt(uint32_t num, uint32_t cpu) override
Interface call for private peripheral interrupts.
virtual ~KvmKernelGicV2()
static const AddrRange GICD_ISACTIVER
static const AddrRange GICD_IPRIORITYR
void setGicReg(unsigned group, unsigned vcpu, unsigned offset, unsigned value)
Set value of GIC register "from" a cpu.
uint8_t cpuPriority[CPU_MAX]
CPU priority.
System & system
System this interrupt controller belongs to.
AddrRange RangeSize(Addr start, Addr size)
static const AddrRange GICD_ICACTIVER
KvmVM & vm
KVM VM in the parent system.
virtual void writeCpu(ContextID ctx, Addr daddr, uint32_t data)=0
uint32_t readCpu(ContextID ctx, Addr daddr) override
virtual void writeDistributor(ContextID ctx, Addr daddr, uint32_t data)=0
void sendInt(uint32_t number) override
Post an interrupt from a device that is connected to the GIC.
void setAttrPtr(uint32_t group, uint64_t attr, const void *data) const
uint32_t itLines
Number of itLines enabled.
DrainState drain() override
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
void setIntState(unsigned type, unsigned vcpu, unsigned irq, bool high)
Update the kernel's VGIC interrupt state.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
void clearInt(uint32_t num) override
Clear an interrupt from a device that is connected to the GIC.
KvmDevice kdev
Kernel interface to the GIC.
void clearDistRange(BaseGicRegisters *to, Addr daddr, size_t size)
static const AddrRange GICD_ICFGR
virtual uint32_t readDistributor(ContextID ctx, Addr daddr)=0
void copyCpuRegister(BaseGicRegisters *from, BaseGicRegisters *to, ContextID ctx, Addr daddr)
static const AddrRange GICD_ISPENDR
void updateIntState(int hint) override
See if some processor interrupt flags need to be enabled/disabled.
Addr start() const
Get the start address of the range.
void clearPPInt(uint32_t num, uint32_t cpu) override
void copyBankedDistRange(BaseGicRegisters *from, BaseGicRegisters *to, Addr daddr, size_t size)
void setIRQLine(uint32_t irq, bool high)
Set the status of an IRQ line using KVM_IRQ_LINE.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
void setPPI(unsigned vcpu, unsigned ppi)
Raise a private peripheral interrupt.
MuxingKvmGic(const MuxingKvmGicParams *p)
static const AddrRange GICD_ITARGETSR
static const AddrRange GICD_ICPENDR
void clearBankedDistRange(BaseGicRegisters *to, Addr daddr, size_t size)
void drainResume() override
Resume execution after a successful drain.
void sendPPInt(uint32_t num, uint32_t cpu) override
Interface call for private peripheral interrupts.
void clearSPI(unsigned spi)
Clear a shared peripheral interrupt.
void copyDistRegister(BaseGicRegisters *from, BaseGicRegisters *to, ContextID ctx, Addr daddr)
void copyGicState(BaseGicRegisters *from, BaseGicRegisters *to)
void sendInt(uint32_t num) override
Post an interrupt from a device that is connected to the GIC.
virtual uint32_t readCpu(ContextID ctx, Addr daddr)=0
void startup() override
startup() is the final initialization call before simulation.
#define panic(...)
This implements a cprintf based panic() function.
Generated on Wed Sep 30 2020 14:01:58 for gem5 by doxygen 1.8.17