a15mpcore: Embed GICState
This covers both emulated and KVM GIC. Prepares for QOM realize. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Andreas Färber <andreas.faerber@web.de>
This commit is contained in:
parent
b9ed148d24
commit
524a2d8e26
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "hw/sysbus.h"
|
#include "hw/sysbus.h"
|
||||||
#include "sysemu/kvm.h"
|
#include "sysemu/kvm.h"
|
||||||
|
#include "hw/intc/arm_gic.h"
|
||||||
|
|
||||||
/* A15MP private memory region. */
|
/* A15MP private memory region. */
|
||||||
|
|
||||||
@ -35,41 +36,49 @@ typedef struct A15MPPrivState {
|
|||||||
uint32_t num_cpu;
|
uint32_t num_cpu;
|
||||||
uint32_t num_irq;
|
uint32_t num_irq;
|
||||||
MemoryRegion container;
|
MemoryRegion container;
|
||||||
DeviceState *gic;
|
|
||||||
|
GICState gic;
|
||||||
} A15MPPrivState;
|
} A15MPPrivState;
|
||||||
|
|
||||||
static void a15mp_priv_set_irq(void *opaque, int irq, int level)
|
static void a15mp_priv_set_irq(void *opaque, int irq, int level)
|
||||||
{
|
{
|
||||||
A15MPPrivState *s = (A15MPPrivState *)opaque;
|
A15MPPrivState *s = (A15MPPrivState *)opaque;
|
||||||
qemu_set_irq(qdev_get_gpio_in(s->gic, irq), level);
|
|
||||||
|
qemu_set_irq(qdev_get_gpio_in(DEVICE(&s->gic), irq), level);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void a15mp_priv_initfn(Object *obj)
|
static void a15mp_priv_initfn(Object *obj)
|
||||||
{
|
{
|
||||||
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
|
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
|
||||||
A15MPPrivState *s = A15MPCORE_PRIV(obj);
|
A15MPPrivState *s = A15MPCORE_PRIV(obj);
|
||||||
|
DeviceState *gicdev;
|
||||||
memory_region_init(&s->container, obj, "a15mp-priv-container", 0x8000);
|
|
||||||
sysbus_init_mmio(sbd, &s->container);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int a15mp_priv_init(SysBusDevice *dev)
|
|
||||||
{
|
|
||||||
A15MPPrivState *s = A15MPCORE_PRIV(dev);
|
|
||||||
SysBusDevice *busdev;
|
|
||||||
const char *gictype = "arm_gic";
|
const char *gictype = "arm_gic";
|
||||||
int i;
|
|
||||||
|
|
||||||
if (kvm_irqchip_in_kernel()) {
|
if (kvm_irqchip_in_kernel()) {
|
||||||
gictype = "kvm-arm-gic";
|
gictype = "kvm-arm-gic";
|
||||||
}
|
}
|
||||||
|
|
||||||
s->gic = qdev_create(NULL, gictype);
|
memory_region_init(&s->container, obj, "a15mp-priv-container", 0x8000);
|
||||||
qdev_prop_set_uint32(s->gic, "num-cpu", s->num_cpu);
|
sysbus_init_mmio(sbd, &s->container);
|
||||||
qdev_prop_set_uint32(s->gic, "num-irq", s->num_irq);
|
|
||||||
qdev_prop_set_uint32(s->gic, "revision", 2);
|
object_initialize(&s->gic, sizeof(s->gic), gictype);
|
||||||
qdev_init_nofail(s->gic);
|
gicdev = DEVICE(&s->gic);
|
||||||
busdev = SYS_BUS_DEVICE(s->gic);
|
qdev_set_parent_bus(gicdev, sysbus_get_default());
|
||||||
|
qdev_prop_set_uint32(gicdev, "revision", 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int a15mp_priv_init(SysBusDevice *dev)
|
||||||
|
{
|
||||||
|
A15MPPrivState *s = A15MPCORE_PRIV(dev);
|
||||||
|
DeviceState *gicdev;
|
||||||
|
SysBusDevice *busdev;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
gicdev = DEVICE(&s->gic);
|
||||||
|
qdev_prop_set_uint32(gicdev, "num-cpu", s->num_cpu);
|
||||||
|
qdev_prop_set_uint32(gicdev, "num-irq", s->num_irq);
|
||||||
|
qdev_init_nofail(gicdev);
|
||||||
|
busdev = SYS_BUS_DEVICE(&s->gic);
|
||||||
|
|
||||||
/* Pass through outbound IRQ lines from the GIC */
|
/* Pass through outbound IRQ lines from the GIC */
|
||||||
sysbus_pass_irq(dev, busdev);
|
sysbus_pass_irq(dev, busdev);
|
||||||
@ -87,10 +96,10 @@ static int a15mp_priv_init(SysBusDevice *dev)
|
|||||||
* since a real A15 always has TrustZone but QEMU doesn't.
|
* since a real A15 always has TrustZone but QEMU doesn't.
|
||||||
*/
|
*/
|
||||||
qdev_connect_gpio_out(cpudev, 0,
|
qdev_connect_gpio_out(cpudev, 0,
|
||||||
qdev_get_gpio_in(s->gic, ppibase + 30));
|
qdev_get_gpio_in(gicdev, ppibase + 30));
|
||||||
/* virtual timer */
|
/* virtual timer */
|
||||||
qdev_connect_gpio_out(cpudev, 1,
|
qdev_connect_gpio_out(cpudev, 1,
|
||||||
qdev_get_gpio_in(s->gic, ppibase + 27));
|
qdev_get_gpio_in(gicdev, ppibase + 27));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Memory map (addresses are offsets from PERIPHBASE):
|
/* Memory map (addresses are offsets from PERIPHBASE):
|
||||||
|
Loading…
Reference in New Issue
Block a user