2012-02-16 13:56:04 +04:00
|
|
|
/*
|
|
|
|
* Samsung exynos4210 GIC implementation. Based on hw/arm_gic.c
|
|
|
|
*
|
|
|
|
* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Evgeny Voevodin <e.voevodin@samsung.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2016-01-26 21:17:05 +03:00
|
|
|
#include "qemu/osdep.h"
|
2013-02-04 18:40:22 +04:00
|
|
|
#include "hw/sysbus.h"
|
2019-08-12 08:23:45 +03:00
|
|
|
#include "migration/vmstate.h"
|
qdev: Convert uses of qdev_create() with Coccinelle
This is the transformation explained in the commit before previous.
Takes care of just one pattern that needs conversion. More to come in
this series.
Coccinelle script:
@ depends on !(file in "hw/arm/highbank.c")@
expression bus, type_name, dev, expr;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr;
identifier DOWN;
@@
- dev = DOWN(qdev_create(bus, type_name));
+ dev = DOWN(qdev_new(type_name));
... when != dev = expr
- qdev_init_nofail(DEVICE(dev));
+ qdev_realize_and_unref(DEVICE(dev), bus, &error_fatal);
@@
expression bus, type_name, expr;
identifier dev;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr, errp;
symbol true;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
@@
expression bus, type_name, expr, errp;
identifier dev;
symbol true;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
The first rule exempts hw/arm/highbank.c, because it matches along two
control flow paths there, with different @type_name. Covered by the
next commit's manual conversions.
Missing #include "qapi/error.h" added manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-10-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 08:31:58 +03:00
|
|
|
#include "qapi/error.h"
|
2019-05-23 17:35:07 +03:00
|
|
|
#include "qemu/module.h"
|
2013-02-04 18:40:22 +04:00
|
|
|
#include "hw/irq.h"
|
2019-08-12 08:23:51 +03:00
|
|
|
#include "hw/qdev-properties.h"
|
2022-04-04 18:46:48 +03:00
|
|
|
#include "hw/intc/exynos4210_gic.h"
|
2013-02-05 20:06:20 +04:00
|
|
|
#include "hw/arm/exynos4210.h"
|
2020-09-03 23:43:22 +03:00
|
|
|
#include "qom/object.h"
|
2012-02-16 13:56:04 +04:00
|
|
|
|
|
|
|
#define EXYNOS4210_GIC_NIRQ 160
|
|
|
|
|
|
|
|
#define EXYNOS4210_EXT_GIC_CPU_REGION_SIZE 0x10000
|
|
|
|
#define EXYNOS4210_EXT_GIC_DIST_REGION_SIZE 0x10000
|
|
|
|
|
|
|
|
#define EXYNOS4210_EXT_GIC_PER_CPU_OFFSET 0x8000
|
|
|
|
#define EXYNOS4210_EXT_GIC_CPU_GET_OFFSET(n) \
|
|
|
|
((n) * EXYNOS4210_EXT_GIC_PER_CPU_OFFSET)
|
|
|
|
#define EXYNOS4210_EXT_GIC_DIST_GET_OFFSET(n) \
|
|
|
|
((n) * EXYNOS4210_EXT_GIC_PER_CPU_OFFSET)
|
|
|
|
|
|
|
|
#define EXYNOS4210_GIC_CPU_REGION_SIZE 0x100
|
|
|
|
#define EXYNOS4210_GIC_DIST_REGION_SIZE 0x1000
|
|
|
|
|
2012-04-13 15:39:08 +04:00
|
|
|
static void exynos4210_gic_set_irq(void *opaque, int irq, int level)
|
|
|
|
{
|
|
|
|
Exynos4210GicState *s = (Exynos4210GicState *)opaque;
|
|
|
|
qemu_set_irq(qdev_get_gpio_in(s->gic, irq), level);
|
|
|
|
}
|
|
|
|
|
2018-07-23 17:21:27 +03:00
|
|
|
static void exynos4210_gic_realize(DeviceState *dev, Error **errp)
|
2012-02-16 13:56:04 +04:00
|
|
|
{
|
2018-07-23 17:21:27 +03:00
|
|
|
Object *obj = OBJECT(dev);
|
2016-05-12 15:22:24 +03:00
|
|
|
Exynos4210GicState *s = EXYNOS4210_GIC(obj);
|
|
|
|
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
|
2017-06-13 16:56:56 +03:00
|
|
|
SysBusDevice *gicbusdev;
|
2019-12-02 09:08:06 +03:00
|
|
|
uint32_t n = s->num_cpu;
|
2017-06-13 16:56:56 +03:00
|
|
|
uint32_t i;
|
2012-04-13 15:39:08 +04:00
|
|
|
|
qdev: Convert uses of qdev_create() with Coccinelle
This is the transformation explained in the commit before previous.
Takes care of just one pattern that needs conversion. More to come in
this series.
Coccinelle script:
@ depends on !(file in "hw/arm/highbank.c")@
expression bus, type_name, dev, expr;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr;
identifier DOWN;
@@
- dev = DOWN(qdev_create(bus, type_name));
+ dev = DOWN(qdev_new(type_name));
... when != dev = expr
- qdev_init_nofail(DEVICE(dev));
+ qdev_realize_and_unref(DEVICE(dev), bus, &error_fatal);
@@
expression bus, type_name, expr;
identifier dev;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr, errp;
symbol true;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
@@
expression bus, type_name, expr, errp;
identifier dev;
symbol true;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
The first rule exempts hw/arm/highbank.c, because it matches along two
control flow paths there, with different @type_name. Covered by the
next commit's manual conversions.
Missing #include "qapi/error.h" added manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-10-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 08:31:58 +03:00
|
|
|
s->gic = qdev_new("arm_gic");
|
2012-04-13 15:39:08 +04:00
|
|
|
qdev_prop_set_uint32(s->gic, "num-cpu", s->num_cpu);
|
|
|
|
qdev_prop_set_uint32(s->gic, "num-irq", EXYNOS4210_GIC_NIRQ);
|
2017-06-13 16:56:56 +03:00
|
|
|
gicbusdev = SYS_BUS_DEVICE(s->gic);
|
sysbus: Convert to sysbus_realize() etc. with Coccinelle
Convert from qdev_realize(), qdev_realize_and_unref() with null @bus
argument to sysbus_realize(), sysbus_realize_and_unref().
Coccinelle script:
@@
expression dev, errp;
@@
- qdev_realize(DEVICE(dev), NULL, errp);
+ sysbus_realize(SYS_BUS_DEVICE(dev), errp);
@@
expression sysbus_dev, dev, errp;
@@
+ sysbus_dev = SYS_BUS_DEVICE(dev);
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(sysbus_dev, errp);
- sysbus_dev = SYS_BUS_DEVICE(dev);
@@
expression sysbus_dev, dev, errp;
expression expr;
@@
sysbus_dev = SYS_BUS_DEVICE(dev);
... when != dev = expr;
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(sysbus_dev, errp);
@@
expression dev, errp;
@@
- qdev_realize_and_unref(DEVICE(dev), NULL, errp);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp);
@@
expression dev, errp;
@@
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp);
Whitespace changes minimized manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-46-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 08:32:34 +03:00
|
|
|
sysbus_realize_and_unref(gicbusdev, &error_fatal);
|
2012-04-13 15:39:08 +04:00
|
|
|
|
|
|
|
/* Pass through outbound IRQ lines from the GIC */
|
2017-06-13 16:56:56 +03:00
|
|
|
sysbus_pass_irq(sbd, gicbusdev);
|
2012-02-16 13:56:04 +04:00
|
|
|
|
2012-04-13 15:39:08 +04:00
|
|
|
/* Pass through inbound GPIO lines to the GIC */
|
2013-07-26 21:16:20 +04:00
|
|
|
qdev_init_gpio_in(dev, exynos4210_gic_set_irq,
|
2012-04-13 15:39:08 +04:00
|
|
|
EXYNOS4210_GIC_NIRQ - 32);
|
2012-02-16 13:56:04 +04:00
|
|
|
|
2016-05-12 15:22:24 +03:00
|
|
|
memory_region_init(&s->cpu_container, obj, "exynos4210-cpu-container",
|
2012-02-16 13:56:04 +04:00
|
|
|
EXYNOS4210_EXT_GIC_CPU_REGION_SIZE);
|
2016-05-12 15:22:24 +03:00
|
|
|
memory_region_init(&s->dist_container, obj, "exynos4210-dist-container",
|
2012-02-16 13:56:04 +04:00
|
|
|
EXYNOS4210_EXT_GIC_DIST_REGION_SIZE);
|
|
|
|
|
2019-12-02 09:08:06 +03:00
|
|
|
/*
|
|
|
|
* This clues in gcc that our on-stack buffers do, in fact have
|
|
|
|
* enough room for the cpu numbers. gcc 9.2.1 on 32-bit x86
|
|
|
|
* doesn't figure this out, otherwise and gives spurious warnings.
|
|
|
|
*/
|
2022-04-04 18:46:48 +03:00
|
|
|
assert(n <= EXYNOS4210_GIC_NCPUS);
|
2019-12-02 09:08:06 +03:00
|
|
|
for (i = 0; i < n; i++) {
|
2022-04-20 16:25:58 +03:00
|
|
|
g_autofree char *cpu_alias_name = g_strdup_printf("exynos4210-gic-alias_cpu%u", i);
|
|
|
|
g_autofree char *dist_alias_name = g_strdup_printf("exynos4210-gic-alias_dist%u", i);
|
|
|
|
|
2012-02-16 13:56:04 +04:00
|
|
|
/* Map CPU interface per SMP Core */
|
2016-05-12 15:22:24 +03:00
|
|
|
memory_region_init_alias(&s->cpu_alias[i], obj,
|
2012-02-16 13:56:04 +04:00
|
|
|
cpu_alias_name,
|
2017-06-13 16:56:56 +03:00
|
|
|
sysbus_mmio_get_region(gicbusdev, 1),
|
2012-02-16 13:56:04 +04:00
|
|
|
0,
|
|
|
|
EXYNOS4210_GIC_CPU_REGION_SIZE);
|
|
|
|
memory_region_add_subregion(&s->cpu_container,
|
|
|
|
EXYNOS4210_EXT_GIC_CPU_GET_OFFSET(i), &s->cpu_alias[i]);
|
|
|
|
|
|
|
|
/* Map Distributor per SMP Core */
|
2016-05-12 15:22:24 +03:00
|
|
|
memory_region_init_alias(&s->dist_alias[i], obj,
|
2012-02-16 13:56:04 +04:00
|
|
|
dist_alias_name,
|
2017-06-13 16:56:56 +03:00
|
|
|
sysbus_mmio_get_region(gicbusdev, 0),
|
2012-02-16 13:56:04 +04:00
|
|
|
0,
|
|
|
|
EXYNOS4210_GIC_DIST_REGION_SIZE);
|
|
|
|
memory_region_add_subregion(&s->dist_container,
|
|
|
|
EXYNOS4210_EXT_GIC_DIST_GET_OFFSET(i), &s->dist_alias[i]);
|
|
|
|
}
|
|
|
|
|
2013-07-26 21:16:20 +04:00
|
|
|
sysbus_init_mmio(sbd, &s->cpu_container);
|
|
|
|
sysbus_init_mmio(sbd, &s->dist_container);
|
2012-02-16 13:56:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static Property exynos4210_gic_properties[] = {
|
|
|
|
DEFINE_PROP_UINT32("num-cpu", Exynos4210GicState, num_cpu, 1),
|
|
|
|
DEFINE_PROP_END_OF_LIST(),
|
|
|
|
};
|
|
|
|
|
|
|
|
static void exynos4210_gic_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
|
|
|
|
2020-01-10 18:30:32 +03:00
|
|
|
device_class_set_props(dc, exynos4210_gic_properties);
|
2018-07-23 17:21:27 +03:00
|
|
|
dc->realize = exynos4210_gic_realize;
|
2012-02-16 13:56:04 +04:00
|
|
|
}
|
|
|
|
|
2013-01-10 19:19:07 +04:00
|
|
|
static const TypeInfo exynos4210_gic_info = {
|
2013-07-26 21:16:20 +04:00
|
|
|
.name = TYPE_EXYNOS4210_GIC,
|
2012-02-16 13:56:04 +04:00
|
|
|
.parent = TYPE_SYS_BUS_DEVICE,
|
|
|
|
.instance_size = sizeof(Exynos4210GicState),
|
|
|
|
.class_init = exynos4210_gic_class_init,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void exynos4210_gic_register_types(void)
|
|
|
|
{
|
|
|
|
type_register_static(&exynos4210_gic_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
type_init(exynos4210_gic_register_types)
|