tracetool: Omit useless QEMU_*_ENABLED() check
[qemu/ar7.git] / hw / a15mpcore.c
blob71142e51f5d86a468581606534da92c3488176a7
1 /*
2 * Cortex-A15MPCore internal peripheral emulation.
4 * Copyright (c) 2012 Linaro Limited.
5 * Written by Peter Maydell.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "sysbus.h"
23 /* Configuration for arm_gic.c:
24 * max number of CPUs, how to ID current CPU
26 #define NCPU 4
28 static inline int gic_get_current_cpu(void)
30 return cpu_single_env->cpu_index;
33 #include "arm_gic.c"
35 /* A15MP private memory region. */
37 typedef struct A15MPPrivState {
38 gic_state gic;
39 uint32_t num_cpu;
40 uint32_t num_irq;
41 MemoryRegion container;
42 } A15MPPrivState;
44 static int a15mp_priv_init(SysBusDevice *dev)
46 A15MPPrivState *s = FROM_SYSBUSGIC(A15MPPrivState, dev);
48 if (s->num_cpu > NCPU) {
49 hw_error("a15mp_priv_init: num-cpu may not be more than %d\n", NCPU);
52 gic_init(&s->gic, s->num_cpu, s->num_irq);
54 /* Memory map (addresses are offsets from PERIPHBASE):
55 * 0x0000-0x0fff -- reserved
56 * 0x1000-0x1fff -- GIC Distributor
57 * 0x2000-0x2fff -- GIC CPU interface
58 * 0x4000-0x4fff -- GIC virtual interface control (not modelled)
59 * 0x5000-0x5fff -- GIC virtual interface control (not modelled)
60 * 0x6000-0x7fff -- GIC virtual CPU interface (not modelled)
62 memory_region_init(&s->container, "a15mp-priv-container", 0x8000);
63 memory_region_add_subregion(&s->container, 0x1000, &s->gic.iomem);
64 memory_region_add_subregion(&s->container, 0x2000, &s->gic.cpuiomem[0]);
66 sysbus_init_mmio(dev, &s->container);
67 return 0;
70 static Property a15mp_priv_properties[] = {
71 DEFINE_PROP_UINT32("num-cpu", A15MPPrivState, num_cpu, 1),
72 /* The Cortex-A15MP may have anything from 0 to 224 external interrupt
73 * IRQ lines (with another 32 internal). We default to 64+32, which
74 * is the number provided by the Cortex-A15MP test chip in the
75 * Versatile Express A15 development board.
76 * Other boards may differ and should set this property appropriately.
78 DEFINE_PROP_UINT32("num-irq", A15MPPrivState, num_irq, 96),
79 DEFINE_PROP_END_OF_LIST(),
82 static void a15mp_priv_class_init(ObjectClass *klass, void *data)
84 DeviceClass *dc = DEVICE_CLASS(klass);
85 SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
86 k->init = a15mp_priv_init;
87 dc->props = a15mp_priv_properties;
88 /* We currently have no savable state outside the common GIC state */
91 static TypeInfo a15mp_priv_info = {
92 .name = "a15mpcore_priv",
93 .parent = TYPE_SYS_BUS_DEVICE,
94 .instance_size = sizeof(A15MPPrivState),
95 .class_init = a15mp_priv_class_init,
98 static void a15mp_register_types(void)
100 type_register_static(&a15mp_priv_info);
103 type_init(a15mp_register_types)