From: Giacomo Travaglini Date: Fri, 5 Apr 2019 12:12:08 +0000 (+0100) Subject: dev-arm: Add GICv4 extension switch in GICv3 X-Git-Tag: v19.0.0.0~941 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=84c4fd063ab2286893e950d53acfabdfb216e952;p=gem5.git dev-arm: Add GICv4 extension switch in GICv3 This is currently used only for determining which is the correct size of redistributors in memory (256KB in GICv4 and 128KB in GICv3) Change-Id: I2c07005e97167fde03548313c9927176788f31dd Signed-off-by: Giacomo Travaglini Reviewed-by: Andreas Sandberg Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18391 Maintainer: Andreas Sandberg Tested-by: kokoro --- diff --git a/src/dev/arm/Gic.py b/src/dev/arm/Gic.py index 8bc155fff..63ecc923b 100644 --- a/src/dev/arm/Gic.py +++ b/src/dev/arm/Gic.py @@ -182,3 +182,5 @@ class Gicv3(BaseGic): cpu_max = Param.Unsigned(256, "Maximum number of PE. This is affecting the maximum number of " "redistributors") + + gicv4 = Param.Bool(True, "GICv4 extension available") diff --git a/src/dev/arm/gic_v3.cc b/src/dev/arm/gic_v3.cc index cfc7df579..2832d33f8 100644 --- a/src/dev/arm/gic_v3.cc +++ b/src/dev/arm/gic_v3.cc @@ -48,12 +48,6 @@ Gicv3::Gicv3(const Params * p) void Gicv3::init() { - distRange = RangeSize(params()->dist_addr, - Gicv3Distributor::ADDR_RANGE_SIZE - 1); - redistRange = RangeSize(params()->redist_addr, - Gicv3Redistributor::ADDR_RANGE_SIZE * sys->numContexts() - 1); - addrRanges = {distRange, redistRange}; - BaseGic::init(); distributor = new Gicv3Distributor(this, params()->it_lines); redistributors.resize(sys->numContexts(), nullptr); cpuInterfaces.resize(sys->numContexts(), nullptr); @@ -68,12 +62,23 @@ Gicv3::init() cpuInterfaces[i] = new Gicv3CPUInterface(this, i); } + distRange = RangeSize(params()->dist_addr, + Gicv3Distributor::ADDR_RANGE_SIZE - 1); + + redistSize = redistributors[0]->addrRangeSize; + redistRange = RangeSize(params()->redist_addr, + redistSize * sys->numContexts() - 1); + + addrRanges = {distRange, redistRange}; + distributor->init(); for (int i = 0; i < sys->numContexts(); i++) { redistributors[i]->init(); cpuInterfaces[i]->init(); } + + BaseGic::init(); } void @@ -107,8 +112,8 @@ Gicv3::read(PacketPtr pkt) } else if (redistRange.contains(addr)) { Addr daddr = addr - redistRange.start(); uint32_t redistributor_id = - daddr / Gicv3Redistributor::ADDR_RANGE_SIZE; - daddr = daddr % Gicv3Redistributor::ADDR_RANGE_SIZE; + daddr / redistSize; + daddr = daddr % redistSize; panic_if(redistributor_id >= redistributors.size(), "Invalid redistributor_id!"); panic_if(!redistributors[redistributor_id], "Redistributor is null!"); @@ -148,8 +153,8 @@ Gicv3::write(PacketPtr pkt) } else if (redistRange.contains(addr)) { Addr daddr = addr - redistRange.start(); uint32_t redistributor_id = - daddr / Gicv3Redistributor::ADDR_RANGE_SIZE; - daddr = daddr % Gicv3Redistributor::ADDR_RANGE_SIZE; + daddr / redistSize; + daddr = daddr % redistSize; panic_if(redistributor_id >= redistributors.size(), "Invalid redistributor_id!"); panic_if(!redistributors[redistributor_id], "Redistributor is null!"); diff --git a/src/dev/arm/gic_v3.hh b/src/dev/arm/gic_v3.hh index 3a1a8761b..48cc52029 100644 --- a/src/dev/arm/gic_v3.hh +++ b/src/dev/arm/gic_v3.hh @@ -42,6 +42,7 @@ class Gicv3 : public BaseGic { protected: friend class Gicv3CPUInterface; + friend class Gicv3Redistributor; typedef Gicv3Params Params; Gicv3Distributor * distributor; @@ -50,6 +51,7 @@ class Gicv3 : public BaseGic AddrRange distRange; AddrRange redistRange; AddrRangeList addrRanges; + uint64_t redistSize; public: diff --git a/src/dev/arm/gic_v3_redistributor.cc b/src/dev/arm/gic_v3_redistributor.cc index 01ec9c511..eb5767a16 100644 --- a/src/dev/arm/gic_v3_redistributor.cc +++ b/src/dev/arm/gic_v3_redistributor.cc @@ -51,7 +51,8 @@ Gicv3Redistributor::Gicv3Redistributor(Gicv3 * gic, uint32_t cpu_id) irqPriority(Gicv3::SGI_MAX + Gicv3::PPI_MAX), irqConfig(Gicv3::SGI_MAX + Gicv3::PPI_MAX), irqGrpmod(Gicv3::SGI_MAX + Gicv3::PPI_MAX), - irqNsacr(Gicv3::SGI_MAX + Gicv3::PPI_MAX) + irqNsacr(Gicv3::SGI_MAX + Gicv3::PPI_MAX), + addrRangeSize(gic->params()->gicv4 ? 0x40000 : 0x20000) { } diff --git a/src/dev/arm/gic_v3_redistributor.hh b/src/dev/arm/gic_v3_redistributor.hh index 578cba105..36504be19 100644 --- a/src/dev/arm/gic_v3_redistributor.hh +++ b/src/dev/arm/gic_v3_redistributor.hh @@ -177,7 +177,7 @@ class Gicv3Redistributor : public Serializable * Note this must match with DTB/DTS GIC node definition and boot * loader code. */ - static const uint32_t ADDR_RANGE_SIZE = 0x40000; + const uint32_t addrRangeSize; static const uint32_t SMALLEST_LPI_ID = 8192;