@@ -299,7 +299,7 @@ void gicv3_init_irqs_and_mmio(GICv3State *s, qemu_irq_handler handler,
memory_region_init_io(&s->iomem_redist[i], OBJECT(s),
ops ? &ops[1] : NULL, s, name,
- s->redist_region_count[i] * GICV3_REDIST_SIZE);
+ s->redist_region_count[i] * gicv3_redist_size(s));
sysbus_init_mmio(sbd, &s->iomem_redist[i]);
g_free(name);
}
@@ -14,6 +14,11 @@
#include "trace.h"
#include "gicv3_internal.h"
+int gicv3_redist_size(GICv3State *s)
+{
+ return (s->revision == 3 ? GICV3_REDIST_SIZE : GICV4_REDIST_SIZE);
+}
+
static uint32_t mask_group(GICv3CPUState *cs, MemTxAttrs attrs)
{
/* Return a 32-bit mask which should be applied for this set of 32
@@ -429,8 +434,8 @@ MemTxResult gicv3_redist_read(void *opaque, hwaddr offset, uint64_t *data,
* want to allow splitting of redistributor pages into several
* blocks so we can support more CPUs.
*/
- cpuidx = offset / 0x20000;
- offset %= 0x20000;
+ cpuidx = offset / gicv3_redist_size(s);
+ offset %= gicv3_redist_size(s);
assert(cpuidx < s->num_cpu);
cs = &s->cpu[cpuidx];
@@ -486,8 +491,8 @@ MemTxResult gicv3_redist_write(void *opaque, hwaddr offset, uint64_t data,
* want to allow splitting of redistributor pages into several
* blocks so we can support more CPUs.
*/
- cpuidx = offset / 0x20000;
- offset %= 0x20000;
+ cpuidx = offset / gicv3_redist_size(s);
+ offset %= gicv3_redist_size(s);
assert(cpuidx < s->num_cpu);
cs = &s->cpu[cpuidx];
@@ -37,6 +37,7 @@
#define GICV3_MAXSPI (GICV3_MAXIRQ - GIC_INTERNAL)
#define GICV3_REDIST_SIZE 0x20000
+#define GICV4_REDIST_SIZE (GICV3_REDIST_SIZE + 0x20000)
/* Number of SGI target-list bits */
#define GICV3_TARGETLIST_BITS 16
@@ -295,4 +296,6 @@ struct ARMGICv3CommonClass {
void gicv3_init_irqs_and_mmio(GICv3State *s, qemu_irq_handler handler,
const MemoryRegionOps *ops, Error **errp);
+int gicv3_redist_size(GICv3State *s);
+
#endif
GICv3 sets aside 128K for each redistributor block, whereas GICv4 sets aside 256K. To enable use of the gicv3 model for gicv4, abstract this away as the helper function gicv3_redist_size() and replace the current hardcoded locations with calls to this function. Signed-off-by: Leif Lindholm <leif@nuviainc.com> --- hw/intc/arm_gicv3_common.c | 2 +- hw/intc/arm_gicv3_redist.c | 13 +++++++++---- include/hw/intc/arm_gicv3_common.h | 3 +++ 3 files changed, 13 insertions(+), 5 deletions(-)