diff options
author | Andreas Sandberg <andreas.sandberg@arm.com> | 2016-04-27 15:34:31 +0100 |
---|---|---|
committer | Andreas Sandberg <andreas.sandberg@arm.com> | 2016-04-27 15:34:31 +0100 |
commit | d5e78923505b18cd5af6a7a2996605569fb2e4b9 (patch) | |
tree | 57939b5541663aaf7fb664e81faa7f84f29aed66 /src/arch/arm/kvm/gic.hh | |
parent | 6d74892b38d48e48c4aa69ff9205ef32b222c974 (diff) | |
download | gem5-d5e78923505b18cd5af6a7a2996605569fb2e4b9.tar.xz |
kvm, arm: Refactor KVM GIC device
Factor out the kernel device wrapper from the KvmGIC and put it in a
separate class. This will simplify a future kernel/gem5 hybrid GIC.
Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Radhika Jagtap <radhika.jagtap@arm.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Diffstat (limited to 'src/arch/arm/kvm/gic.hh')
-rw-r--r-- | src/arch/arm/kvm/gic.hh | 115 |
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; }; |