summaryrefslogtreecommitdiff
path: root/src/arch/arm/kvm/gic.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/arm/kvm/gic.hh')
-rw-r--r--src/arch/arm/kvm/gic.hh115
1 files changed, 94 insertions, 21 deletions
diff --git a/src/arch/arm/kvm/gic.hh b/src/arch/arm/kvm/gic.hh
index f6360858b..77a7b5e53 100644
--- a/src/arch/arm/kvm/gic.hh
+++ b/src/arch/arm/kvm/gic.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 ARM Limited
+ * Copyright (c) 2015-2016 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
@@ -46,7 +46,95 @@
#include "dev/arm/base_gic.hh"
#include "dev/platform.hh"
-class KvmGicParams;
+/**
+ * KVM in-kernel GIC abstraction
+ *
+ * This class defines a high-level interface to the KVM in-kernel GIC
+ * model. It exposes an API that is similar to that of
+ * software-emulated GIC models in gem5.
+ */
+class KvmKernelGicV2
+{
+ public:
+ /**
+ * Instantiate a KVM in-kernel GIC model.
+ *
+ * This constructor instantiates an in-kernel GIC model and wires
+ * it up to the virtual memory system.
+ *
+ * @param vm KVM VM representing this system
+ * @param cpu_addr GIC CPU interface base address
+ * @param dist_addr GIC distributor base address
+ */
+ KvmKernelGicV2(KvmVM &vm, Addr cpu_addr, Addr dist_addr);
+ virtual ~KvmKernelGicV2();
+
+ KvmKernelGicV2(const KvmKernelGicV2 &other) = delete;
+ KvmKernelGicV2(const KvmKernelGicV2 &&other) = delete;
+ KvmKernelGicV2 &operator=(const KvmKernelGicV2 &&rhs) = delete;
+ KvmKernelGicV2 &operator=(const KvmKernelGicV2 &rhs) = delete;
+
+ public:
+ /**
+ * @{
+ * @name In-kernel GIC API
+ */
+
+ /**
+ * Raise a shared peripheral interrupt
+ *
+ * @param spi SPI number
+ */
+ void setSPI(unsigned spi);
+ /**
+ * Clear a shared peripheral interrupt
+ *
+ * @param spi SPI number
+ */
+ void clearSPI(unsigned spi);
+
+ /**
+ * Raise a private peripheral interrupt
+ *
+ * @param vcpu KVM virtual CPU number
+ * @parma ppi PPI interrupt number
+ */
+ void setPPI(unsigned vcpu, unsigned ppi);
+
+ /**
+ * Clear a private peripheral interrupt
+ *
+ * @param vcpu KVM virtual CPU number
+ * @parma ppi PPI interrupt number
+ */
+ void clearPPI(unsigned vcpu, unsigned ppi);
+
+ /** Address range for the CPU interfaces */
+ const AddrRange cpuRange;
+ /** Address range for the distributor interface */
+ const AddrRange distRange;
+
+ /* @} */
+
+ protected:
+ /**
+ * Update the kernel's VGIC interrupt state
+ *
+ * @param type Interrupt type (KVM_ARM_IRQ_TYPE_PPI/KVM_ARM_IRQ_TYPE_SPI)
+ * @param vcpu CPU id within KVM (ignored for SPIs)
+ * @param irq Interrupt number
+ * @param high True to signal an interrupt, false to clear it.
+ */
+ void setIntState(unsigned type, unsigned vcpu, unsigned irq, bool high);
+
+ /** KVM VM in the parent system */
+ KvmVM &vm;
+
+ /** Kernel interface to the GIC */
+ KvmDevice kdev;
+};
+
+struct KvmGicParams;
/**
* In-kernel GIC model.
@@ -80,7 +168,7 @@ class KvmGic : public BaseGic
void drainResume() override { verifyMemoryMode(); }
void serialize(CheckpointOut &cp) const override;
- void unserialize(CheckpointIn &cp) override;
+ void unserialize(CheckpointIn &cp) override;
public: // PioDevice
AddrRangeList getAddrRanges() const { return addrRanges; }
@@ -105,27 +193,12 @@ class KvmGic : public BaseGic
*/
void verifyMemoryMode() const;
- /**
- * Update the kernel's VGIC interrupt state
- *
- * @param type Interrupt type (KVM_ARM_IRQ_TYPE_PPI/KVM_ARM_IRQ_TYPE_SPI)
- * @param vcpu CPU id within KVM (ignored for SPIs)
- * @param irq Interrupt number
- * @param high True to signal an interrupt, false to clear it.
- */
- void setIntState(uint8_t type, uint8_t vcpu, uint16_t irq, bool high);
-
/** System this interrupt controller belongs to */
System &system;
- /** VM for this system */
- KvmVM &vm;
- /** Kernel interface to the GIC */
- KvmDevice kdev;
- /** Address range for the distributor interface */
- const AddrRange distRange;
- /** Address range for the CPU interfaces */
- const AddrRange cpuRange;
+ /** Kernel GIC device */
+ KvmKernelGicV2 kernelGic;
+
/** Union of all memory */
const AddrRangeList addrRanges;
};