1 | First arm pullreq for 7.1. The bulk of this is the qemu_split_irq | 1 | Hi; here's a queue of arm patches (plus a few elf2dmp changes); |
---|---|---|---|
2 | removal. | 2 | mostly these are minor cleanups and bugfixes. |
3 | |||
4 | I have enough stuff in my to-review queue that I expect to do another | ||
5 | pullreq early next week, but 31 patches is enough to not hang on to. | ||
6 | 3 | ||
7 | thanks | 4 | thanks |
8 | -- PMM | 5 | -- PMM |
9 | 6 | ||
10 | The following changes since commit 9c125d17e9402c232c46610802e5931b3639d77b: | 7 | The following changes since commit deaca3fd30d3a8829160f8d3705d65ad83176800: |
11 | 8 | ||
12 | Merge tag 'pull-tcg-20220420' of https://gitlab.com/rth7680/qemu into staging (2022-04-20 16:43:11 -0700) | 9 | Merge tag 'pull-vfio-20231018' of https://github.com/legoater/qemu into staging (2023-10-18 06:21:15 -0400) |
13 | 10 | ||
14 | are available in the Git repository at: | 11 | are available in the Git repository at: |
15 | 12 | ||
16 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220421 | 13 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20231019 |
17 | 14 | ||
18 | for you to fetch changes up to 5b415dd61bdbf61fb4be0e9f1a7172b8bce682c6: | 15 | for you to fetch changes up to 2a052b4ee01b3c413cef2ef49cb780cde17d4ba1: |
19 | 16 | ||
20 | hw/arm: Use bit fields for NPCM7XX PWRON STRAPs (2022-04-21 11:37:05 +0100) | 17 | contrib/elf2dmp: Use g_malloc(), g_new() and g_free() (2023-10-19 14:32:13 +0100) |
21 | 18 | ||
22 | ---------------------------------------------------------------- | 19 | ---------------------------------------------------------------- |
23 | target-arm queue: | 20 | target-arm queue: |
24 | * hw/arm/virt: Check for attempt to use TrustZone with KVM or HVF | 21 | * hw/arm: Move raspberrypi-fw-defs.h to the include/hw/arm/ folder |
25 | * versal: Add the Cortex-R5s in the Real-Time Processing Unit (RPU) subsystem | 22 | * hw/arm/exynos4210: Get arm_boot_info declaration from 'hw/arm/boot' |
26 | * versal: model enough of the Clock/Reset Low-power domain (CRL) to allow control of the Cortex-R5s | 23 | * xlnx devices: remove deprecated device reset |
27 | * xlnx-zynqmp: Connect 4 TTC timers | 24 | * xlnx-bbram: hw/nvram: Use dot in device type name |
28 | * exynos4210: Refactor GIC/combiner code to stop using qemu_split_irq | 25 | * elf2dmp: fix coverity issues |
29 | * realview: replace 'qemu_split_irq' with 'TYPE_SPLIT_IRQ' | 26 | * elf2dmp: convert to g_malloc, g_new and g_free |
30 | * stellaris: replace 'qemu_split_irq' with 'TYPE_SPLIT_IRQ' | 27 | * target/arm: Fix CNTPCT_EL0 trapping from EL0 when HCR_EL2.E2H is 0 |
31 | * hw/core/irq: remove unused 'qemu_irq_split' function | 28 | * hw/arm: refactor virt PPI logic |
32 | * npcm7xx: use symbolic constants for PWRON STRAP bit fields | 29 | * arm/kvm: convert to kvm_set_one_reg, kvm_get_one_reg |
33 | * virt: document impact of gic-version on max CPUs | 30 | * target/arm: Permit T32 LDM with single register |
31 | * smmuv3: Advertise SMMUv3.1-XNX | ||
32 | * target/arm: Implement FEAT_HPMN0 | ||
33 | * Remove some unnecessary include lines | ||
34 | * target/arm/arm-powerctl: Correctly init CPUs when powered on to lower EL | ||
35 | * hw/timer/npcm7xx_timer: Prevent timer from counting down past zero | ||
34 | 36 | ||
35 | ---------------------------------------------------------------- | 37 | ---------------------------------------------------------------- |
36 | Edgar E. Iglesias (6): | 38 | Chris Rauer (1): |
37 | timer: cadence_ttc: Break out header file to allow embedding | 39 | hw/timer/npcm7xx_timer: Prevent timer from counting down past zero |
38 | hw/arm/xlnx-zynqmp: Connect 4 TTC timers | ||
39 | hw/arm: versal: Create an APU CPU Cluster | ||
40 | hw/arm: versal: Add the Cortex-R5Fs | ||
41 | hw/misc: Add a model of the Xilinx Versal CRL | ||
42 | hw/arm: versal: Connect the CRL | ||
43 | 40 | ||
44 | Hao Wu (2): | 41 | Cornelia Huck (2): |
45 | hw/misc: Add PWRON STRAP bit fields in GCR module | 42 | arm/kvm: convert to kvm_set_one_reg |
46 | hw/arm: Use bit fields for NPCM7XX PWRON STRAPs | 43 | arm/kvm: convert to kvm_get_one_reg |
47 | 44 | ||
48 | Heinrich Schuchardt (1): | 45 | Leif Lindholm (3): |
49 | hw/arm/virt: impact of gic-version on max CPUs | 46 | {include/}hw/arm: refactor virt PPI logic |
47 | include/hw/arm: move BSA definitions to bsa.h | ||
48 | hw/arm/sbsa-ref: use bsa.h for PPI definitions | ||
50 | 49 | ||
51 | Peter Maydell (19): | 50 | Michal Orzel (1): |
52 | hw/arm/virt: Check for attempt to use TrustZone with KVM or HVF | 51 | target/arm: Fix CNTPCT_EL0 trapping from EL0 when HCR_EL2.E2H is 0 |
53 | hw/arm/exynos4210: Use TYPE_OR_IRQ instead of custom OR-gate device | ||
54 | hw/intc/exynos4210_gic: Remove unused TYPE_EXYNOS4210_IRQ_GATE | ||
55 | hw/arm/exynos4210: Put a9mpcore device into state struct | ||
56 | hw/arm/exynos4210: Drop int_gic_irq[] from Exynos4210Irq struct | ||
57 | hw/arm/exynos4210: Coalesce board_irqs and irq_table | ||
58 | hw/arm/exynos4210: Fix code style nit in combiner_grp_to_gic_id[] | ||
59 | hw/arm/exynos4210: Move exynos4210_init_board_irqs() into exynos4210.c | ||
60 | hw/arm/exynos4210: Put external GIC into state struct | ||
61 | hw/arm/exynos4210: Drop ext_gic_irq[] from Exynos4210Irq struct | ||
62 | hw/arm/exynos4210: Move exynos4210_combiner_get_gpioin() into exynos4210.c | ||
63 | hw/arm/exynos4210: Delete unused macro definitions | ||
64 | hw/arm/exynos4210: Use TYPE_SPLIT_IRQ in exynos4210_init_board_irqs() | ||
65 | hw/arm/exynos4210: Fill in irq_table[] for internal-combiner-only IRQ lines | ||
66 | hw/arm/exynos4210: Connect MCT_G0 and MCT_G1 to both combiners | ||
67 | hw/arm/exynos4210: Don't connect multiple lines to external GIC inputs | ||
68 | hw/arm/exynos4210: Fold combiner splits into exynos4210_init_board_irqs() | ||
69 | hw/arm/exynos4210: Put combiners into state struct | ||
70 | hw/arm/exynos4210: Drop Exynos4210Irq struct | ||
71 | 52 | ||
72 | Zongyuan Li (3): | 53 | Peter Maydell (8): |
73 | hw/arm/realview: replace 'qemu_split_irq' with 'TYPE_SPLIT_IRQ' | 54 | target/arm: Permit T32 LDM with single register |
74 | hw/arm/stellaris: replace 'qemu_split_irq' with 'TYPE_SPLIT_IRQ' | 55 | hw/arm/smmuv3: Update ID register bit field definitions |
75 | hw/core/irq: remove unused 'qemu_irq_split' function | 56 | hw/arm/smmuv3: Sort ID register setting into field order |
57 | hw/arm/smmuv3: Advertise SMMUv3.1-XNX feature | ||
58 | target/arm: Implement FEAT_HPMN0 | ||
59 | target/arm/kvm64.c: Remove unused include | ||
60 | target/arm/common-semi-target.h: Remove unnecessary boot.h include | ||
61 | target/arm/arm-powerctl: Correctly init CPUs when powered on to lower EL | ||
76 | 62 | ||
77 | docs/system/arm/virt.rst | 4 +- | 63 | Philippe Mathieu-Daudé (1): |
78 | include/hw/arm/exynos4210.h | 50 ++-- | 64 | hw/arm/exynos4210: Get arm_boot_info declaration from 'hw/arm/boot.h' |
79 | include/hw/arm/xlnx-versal.h | 16 ++ | 65 | |
80 | include/hw/arm/xlnx-zynqmp.h | 4 + | 66 | Suraj Shirvankar (1): |
81 | include/hw/intc/exynos4210_combiner.h | 57 +++++ | 67 | contrib/elf2dmp: Use g_malloc(), g_new() and g_free() |
82 | include/hw/intc/exynos4210_gic.h | 43 ++++ | 68 | |
83 | include/hw/irq.h | 5 - | 69 | Thomas Huth (1): |
84 | include/hw/misc/npcm7xx_gcr.h | 30 +++ | 70 | hw/arm: Move raspberrypi-fw-defs.h to the include/hw/arm/ folder |
85 | include/hw/misc/xlnx-versal-crl.h | 235 +++++++++++++++++++ | 71 | |
86 | include/hw/timer/cadence_ttc.h | 54 +++++ | 72 | Tong Ho (4): |
87 | hw/arm/exynos4210.c | 430 ++++++++++++++++++++++++++++++---- | 73 | xlnx-bbram: hw/nvram: Remove deprecated device reset |
88 | hw/arm/npcm7xx_boards.c | 24 +- | 74 | xlnx-zynqmp-efuse: hw/nvram: Remove deprecated device reset |
89 | hw/arm/realview.c | 33 ++- | 75 | xlnx-versal-efuse: hw/nvram: Remove deprecated device reset |
90 | hw/arm/stellaris.c | 15 +- | 76 | xlnx-bbram: hw/nvram: Use dot in device type name |
91 | hw/arm/virt.c | 7 + | 77 | |
92 | hw/arm/xlnx-versal-virt.c | 6 +- | 78 | Viktor Prutyanov (2): |
93 | hw/arm/xlnx-versal.c | 99 +++++++- | 79 | elf2dmp: limit print length for sign_rsds |
94 | hw/arm/xlnx-zynqmp.c | 22 ++ | 80 | elf2dmp: check array bounds in pdb_get_file_size |
95 | hw/core/irq.c | 15 -- | 81 | |
96 | hw/intc/exynos4210_combiner.c | 108 +-------- | 82 | MAINTAINERS | 2 +- |
97 | hw/intc/exynos4210_gic.c | 344 +-------------------------- | 83 | docs/system/arm/emulation.rst | 1 + |
98 | hw/misc/xlnx-versal-crl.c | 421 +++++++++++++++++++++++++++++++++ | 84 | hw/arm/smmuv3-internal.h | 38 ++++++++ |
99 | hw/timer/cadence_ttc.c | 32 +-- | 85 | include/hw/arm/bsa.h | 35 +++++++ |
100 | MAINTAINERS | 2 +- | 86 | include/hw/arm/exynos4210.h | 2 +- |
101 | hw/misc/meson.build | 1 + | 87 | include/hw/{misc => arm}/raspberrypi-fw-defs.h | 0 |
102 | 25 files changed, 1457 insertions(+), 600 deletions(-) | 88 | include/hw/arm/virt.h | 12 +-- |
103 | create mode 100644 include/hw/intc/exynos4210_combiner.h | 89 | include/hw/nvram/xlnx-bbram.h | 2 +- |
104 | create mode 100644 include/hw/intc/exynos4210_gic.h | 90 | target/arm/common-semi-target.h | 4 +- |
105 | create mode 100644 include/hw/misc/xlnx-versal-crl.h | 91 | target/arm/cpu-qom.h | 2 - |
106 | create mode 100644 include/hw/timer/cadence_ttc.h | 92 | target/arm/cpu.h | 22 +++++ |
107 | create mode 100644 hw/misc/xlnx-versal-crl.c | 93 | contrib/elf2dmp/addrspace.c | 7 +- |
94 | contrib/elf2dmp/main.c | 11 +-- | ||
95 | contrib/elf2dmp/pdb.c | 32 ++++--- | ||
96 | contrib/elf2dmp/qemu_elf.c | 7 +- | ||
97 | hw/arm/boot.c | 95 +++++-------------- | ||
98 | hw/arm/sbsa-ref.c | 21 ++--- | ||
99 | hw/arm/smmuv3.c | 8 +- | ||
100 | hw/arm/virt-acpi-build.c | 12 +-- | ||
101 | hw/arm/virt.c | 24 +++-- | ||
102 | hw/misc/bcm2835_property.c | 2 +- | ||
103 | hw/nvram/xlnx-bbram.c | 8 +- | ||
104 | hw/nvram/xlnx-versal-efuse-ctrl.c | 8 +- | ||
105 | hw/nvram/xlnx-zynqmp-efuse.c | 8 +- | ||
106 | hw/timer/npcm7xx_timer.c | 3 + | ||
107 | target/arm/arm-powerctl.c | 53 +---------- | ||
108 | target/arm/cpu.c | 95 +++++++++++++++++++ | ||
109 | target/arm/helper.c | 19 +--- | ||
110 | target/arm/kvm.c | 28 ++---- | ||
111 | target/arm/kvm64.c | 124 +++++++------------------ | ||
112 | target/arm/tcg/cpu32.c | 4 + | ||
113 | target/arm/tcg/cpu64.c | 1 + | ||
114 | target/arm/tcg/translate.c | 37 +++++--- | ||
115 | 33 files changed, 368 insertions(+), 359 deletions(-) | ||
116 | create mode 100644 include/hw/arm/bsa.h | ||
117 | rename include/hw/{misc => arm}/raspberrypi-fw-defs.h (100%) | ||
118 | diff view generated by jsdifflib |
1 | Switch the creation of the external GIC to the new-style "embedded in | 1 | From: Thomas Huth <thuth@redhat.com> |
---|---|---|---|
2 | state struct" approach, so we can easily refer to the object | ||
3 | elsewhere during realize. | ||
4 | 2 | ||
3 | The file is obviously related to the raspberrypi machine, so | ||
4 | it should reside in hw/arm/ instead of hw/misc/. And while we're | ||
5 | at it, also adjust the wildcard in MAINTAINERS so that it covers | ||
6 | this file, too. | ||
7 | |||
8 | Signed-off-by: Thomas Huth <thuth@redhat.com> | ||
9 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
10 | Acked-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
11 | Message-id: 20231012073458.860187-1-thuth@redhat.com | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220404154658.565020-9-peter.maydell@linaro.org | ||
8 | --- | 13 | --- |
9 | include/hw/arm/exynos4210.h | 2 ++ | 14 | MAINTAINERS | 2 +- |
10 | include/hw/intc/exynos4210_gic.h | 43 ++++++++++++++++++++++++++++++++ | 15 | include/hw/{misc => arm}/raspberrypi-fw-defs.h | 0 |
11 | hw/arm/exynos4210.c | 10 ++++---- | 16 | hw/misc/bcm2835_property.c | 2 +- |
12 | hw/intc/exynos4210_gic.c | 17 ++----------- | 17 | 3 files changed, 2 insertions(+), 2 deletions(-) |
13 | MAINTAINERS | 2 +- | 18 | rename include/hw/{misc => arm}/raspberrypi-fw-defs.h (100%) |
14 | 5 files changed, 53 insertions(+), 21 deletions(-) | ||
15 | create mode 100644 include/hw/intc/exynos4210_gic.h | ||
16 | 19 | ||
17 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/include/hw/arm/exynos4210.h | ||
20 | +++ b/include/hw/arm/exynos4210.h | ||
21 | @@ -XXX,XX +XXX,XX @@ | ||
22 | #include "hw/or-irq.h" | ||
23 | #include "hw/sysbus.h" | ||
24 | #include "hw/cpu/a9mpcore.h" | ||
25 | +#include "hw/intc/exynos4210_gic.h" | ||
26 | #include "target/arm/cpu-qom.h" | ||
27 | #include "qom/object.h" | ||
28 | |||
29 | @@ -XXX,XX +XXX,XX @@ struct Exynos4210State { | ||
30 | qemu_or_irq pl330_irq_orgate[EXYNOS4210_NUM_DMA]; | ||
31 | qemu_or_irq cpu_irq_orgate[EXYNOS4210_NCPUS]; | ||
32 | A9MPPrivState a9mpcore; | ||
33 | + Exynos4210GicState ext_gic; | ||
34 | }; | ||
35 | |||
36 | #define TYPE_EXYNOS4210_SOC "exynos4210" | ||
37 | diff --git a/include/hw/intc/exynos4210_gic.h b/include/hw/intc/exynos4210_gic.h | ||
38 | new file mode 100644 | ||
39 | index XXXXXXX..XXXXXXX | ||
40 | --- /dev/null | ||
41 | +++ b/include/hw/intc/exynos4210_gic.h | ||
42 | @@ -XXX,XX +XXX,XX @@ | ||
43 | +/* | ||
44 | + * Samsung exynos4210 GIC implementation. Based on hw/arm_gic.c | ||
45 | + * | ||
46 | + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. | ||
47 | + * All rights reserved. | ||
48 | + * | ||
49 | + * Evgeny Voevodin <e.voevodin@samsung.com> | ||
50 | + * | ||
51 | + * This program is free software; you can redistribute it and/or modify it | ||
52 | + * under the terms of the GNU General Public License as published by the | ||
53 | + * Free Software Foundation; either version 2 of the License, or (at your | ||
54 | + * option) any later version. | ||
55 | + * | ||
56 | + * This program is distributed in the hope that it will be useful, | ||
57 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
58 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
59 | + * See the GNU General Public License for more details. | ||
60 | + * | ||
61 | + * You should have received a copy of the GNU General Public License along | ||
62 | + * with this program; if not, see <http://www.gnu.org/licenses/>. | ||
63 | + */ | ||
64 | +#ifndef HW_INTC_EXYNOS4210_GIC_H | ||
65 | +#define HW_INTC_EXYNOS4210_GIC_H | ||
66 | + | ||
67 | +#include "hw/sysbus.h" | ||
68 | + | ||
69 | +#define TYPE_EXYNOS4210_GIC "exynos4210.gic" | ||
70 | +OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210GicState, EXYNOS4210_GIC) | ||
71 | + | ||
72 | +#define EXYNOS4210_GIC_NCPUS 2 | ||
73 | + | ||
74 | +struct Exynos4210GicState { | ||
75 | + SysBusDevice parent_obj; | ||
76 | + | ||
77 | + MemoryRegion cpu_container; | ||
78 | + MemoryRegion dist_container; | ||
79 | + MemoryRegion cpu_alias[EXYNOS4210_GIC_NCPUS]; | ||
80 | + MemoryRegion dist_alias[EXYNOS4210_GIC_NCPUS]; | ||
81 | + uint32_t num_cpu; | ||
82 | + DeviceState *gic; | ||
83 | +}; | ||
84 | + | ||
85 | +#endif | ||
86 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
87 | index XXXXXXX..XXXXXXX 100644 | ||
88 | --- a/hw/arm/exynos4210.c | ||
89 | +++ b/hw/arm/exynos4210.c | ||
90 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
91 | sysbus_create_simple("l2x0", EXYNOS4210_L2X0_BASE_ADDR, NULL); | ||
92 | |||
93 | /* External GIC */ | ||
94 | - dev = qdev_new("exynos4210.gic"); | ||
95 | - qdev_prop_set_uint32(dev, "num-cpu", EXYNOS4210_NCPUS); | ||
96 | - busdev = SYS_BUS_DEVICE(dev); | ||
97 | - sysbus_realize_and_unref(busdev, &error_fatal); | ||
98 | + qdev_prop_set_uint32(DEVICE(&s->ext_gic), "num-cpu", EXYNOS4210_NCPUS); | ||
99 | + busdev = SYS_BUS_DEVICE(&s->ext_gic); | ||
100 | + sysbus_realize(busdev, &error_fatal); | ||
101 | /* Map CPU interface */ | ||
102 | sysbus_mmio_map(busdev, 0, EXYNOS4210_EXT_GIC_CPU_BASE_ADDR); | ||
103 | /* Map Distributer interface */ | ||
104 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
105 | qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 1)); | ||
106 | } | ||
107 | for (n = 0; n < EXYNOS4210_EXT_GIC_NIRQ; n++) { | ||
108 | - s->irqs.ext_gic_irq[n] = qdev_get_gpio_in(dev, n); | ||
109 | + s->irqs.ext_gic_irq[n] = qdev_get_gpio_in(DEVICE(&s->ext_gic), n); | ||
110 | } | ||
111 | |||
112 | /* Internal Interrupt Combiner */ | ||
113 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init(Object *obj) | ||
114 | } | ||
115 | |||
116 | object_initialize_child(obj, "a9mpcore", &s->a9mpcore, TYPE_A9MPCORE_PRIV); | ||
117 | + object_initialize_child(obj, "ext-gic", &s->ext_gic, TYPE_EXYNOS4210_GIC); | ||
118 | } | ||
119 | |||
120 | static void exynos4210_class_init(ObjectClass *klass, void *data) | ||
121 | diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c | ||
122 | index XXXXXXX..XXXXXXX 100644 | ||
123 | --- a/hw/intc/exynos4210_gic.c | ||
124 | +++ b/hw/intc/exynos4210_gic.c | ||
125 | @@ -XXX,XX +XXX,XX @@ | ||
126 | #include "qemu/module.h" | ||
127 | #include "hw/irq.h" | ||
128 | #include "hw/qdev-properties.h" | ||
129 | +#include "hw/intc/exynos4210_gic.h" | ||
130 | #include "hw/arm/exynos4210.h" | ||
131 | #include "qom/object.h" | ||
132 | |||
133 | @@ -XXX,XX +XXX,XX @@ | ||
134 | #define EXYNOS4210_GIC_CPU_REGION_SIZE 0x100 | ||
135 | #define EXYNOS4210_GIC_DIST_REGION_SIZE 0x1000 | ||
136 | |||
137 | -#define TYPE_EXYNOS4210_GIC "exynos4210.gic" | ||
138 | -OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210GicState, EXYNOS4210_GIC) | ||
139 | - | ||
140 | -struct Exynos4210GicState { | ||
141 | - SysBusDevice parent_obj; | ||
142 | - | ||
143 | - MemoryRegion cpu_container; | ||
144 | - MemoryRegion dist_container; | ||
145 | - MemoryRegion cpu_alias[EXYNOS4210_NCPUS]; | ||
146 | - MemoryRegion dist_alias[EXYNOS4210_NCPUS]; | ||
147 | - uint32_t num_cpu; | ||
148 | - DeviceState *gic; | ||
149 | -}; | ||
150 | - | ||
151 | static void exynos4210_gic_set_irq(void *opaque, int irq, int level) | ||
152 | { | ||
153 | Exynos4210GicState *s = (Exynos4210GicState *)opaque; | ||
154 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_gic_realize(DeviceState *dev, Error **errp) | ||
155 | * enough room for the cpu numbers. gcc 9.2.1 on 32-bit x86 | ||
156 | * doesn't figure this out, otherwise and gives spurious warnings. | ||
157 | */ | ||
158 | - assert(n <= EXYNOS4210_NCPUS); | ||
159 | + assert(n <= EXYNOS4210_GIC_NCPUS); | ||
160 | for (i = 0; i < n; i++) { | ||
161 | /* Map CPU interface per SMP Core */ | ||
162 | sprintf(cpu_alias_name, "%s%x", cpu_prefix, i); | ||
163 | diff --git a/MAINTAINERS b/MAINTAINERS | 20 | diff --git a/MAINTAINERS b/MAINTAINERS |
164 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
165 | --- a/MAINTAINERS | 22 | --- a/MAINTAINERS |
166 | +++ b/MAINTAINERS | 23 | +++ b/MAINTAINERS |
167 | @@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org> | 24 | @@ -XXX,XX +XXX,XX @@ S: Odd Fixes |
168 | L: qemu-arm@nongnu.org | 25 | F: hw/arm/raspi.c |
169 | S: Odd Fixes | 26 | F: hw/arm/raspi_platform.h |
170 | F: hw/*/exynos* | 27 | F: hw/*/bcm283* |
171 | -F: include/hw/arm/exynos4210.h | 28 | -F: include/hw/arm/raspi* |
172 | +F: include/hw/*/exynos* | 29 | +F: include/hw/arm/rasp* |
173 | 30 | F: include/hw/*/bcm283* | |
174 | Calxeda Highbank | 31 | F: docs/system/arm/raspi.rst |
175 | M: Rob Herring <robh@kernel.org> | 32 | |
33 | diff --git a/include/hw/misc/raspberrypi-fw-defs.h b/include/hw/arm/raspberrypi-fw-defs.h | ||
34 | similarity index 100% | ||
35 | rename from include/hw/misc/raspberrypi-fw-defs.h | ||
36 | rename to include/hw/arm/raspberrypi-fw-defs.h | ||
37 | diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/hw/misc/bcm2835_property.c | ||
40 | +++ b/hw/misc/bcm2835_property.c | ||
41 | @@ -XXX,XX +XXX,XX @@ | ||
42 | #include "migration/vmstate.h" | ||
43 | #include "hw/irq.h" | ||
44 | #include "hw/misc/bcm2835_mbox_defs.h" | ||
45 | -#include "hw/misc/raspberrypi-fw-defs.h" | ||
46 | +#include "hw/arm/raspberrypi-fw-defs.h" | ||
47 | #include "sysemu/dma.h" | ||
48 | #include "qemu/log.h" | ||
49 | #include "qemu/module.h" | ||
176 | -- | 50 | -- |
177 | 2.25.1 | 51 | 2.34.1 |
52 | |||
53 | diff view generated by jsdifflib |
1 | In exynos4210_init_board_irqs(), use the TYPE_SPLIT_IRQ device | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | instead of qemu_irq_split(). | ||
3 | 2 | ||
3 | struct arm_boot_info is declared in "hw/arm/boot.h". | ||
4 | By including the correct header we don't need to declare | ||
5 | it again in "target/arm/cpu-qom.h". | ||
6 | |||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20231013130214.95742-1-philmd@linaro.org | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20220404154658.565020-13-peter.maydell@linaro.org | ||
7 | --- | 11 | --- |
8 | include/hw/arm/exynos4210.h | 9 ++++++++ | 12 | include/hw/arm/exynos4210.h | 2 +- |
9 | hw/arm/exynos4210.c | 41 +++++++++++++++++++++++++++++-------- | 13 | target/arm/cpu-qom.h | 2 -- |
10 | 2 files changed, 42 insertions(+), 8 deletions(-) | 14 | 2 files changed, 1 insertion(+), 3 deletions(-) |
11 | 15 | ||
12 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | 16 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
13 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/include/hw/arm/exynos4210.h | 18 | --- a/include/hw/arm/exynos4210.h |
15 | +++ b/include/hw/arm/exynos4210.h | 19 | +++ b/include/hw/arm/exynos4210.h |
16 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ |
17 | #include "hw/sysbus.h" | ||
18 | #include "hw/cpu/a9mpcore.h" | ||
19 | #include "hw/intc/exynos4210_gic.h" | 21 | #include "hw/intc/exynos4210_gic.h" |
20 | +#include "hw/core/split-irq.h" | 22 | #include "hw/intc/exynos4210_combiner.h" |
21 | #include "target/arm/cpu-qom.h" | 23 | #include "hw/core/split-irq.h" |
24 | -#include "target/arm/cpu-qom.h" | ||
25 | +#include "hw/arm/boot.h" | ||
22 | #include "qom/object.h" | 26 | #include "qom/object.h" |
23 | 27 | ||
28 | #define EXYNOS4210_NCPUS 2 | ||
29 | diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/cpu-qom.h | ||
32 | +++ b/target/arm/cpu-qom.h | ||
24 | @@ -XXX,XX +XXX,XX @@ | 33 | @@ -XXX,XX +XXX,XX @@ |
25 | 34 | #include "hw/core/cpu.h" | |
26 | #define EXYNOS4210_NUM_DMA 3 | 35 | #include "qom/object.h" |
27 | 36 | ||
28 | +/* | 37 | -struct arm_boot_info; |
29 | + * We need one splitter for every external combiner input, plus | 38 | - |
30 | + * one for every non-zero entry in combiner_grp_to_gic_id[]. | 39 | #define TYPE_ARM_CPU "arm-cpu" |
31 | + * We'll assert in exynos4210_init_board_irqs() if this is wrong. | 40 | |
32 | + */ | 41 | OBJECT_DECLARE_CPU_TYPE(ARMCPU, ARMCPUClass, ARM_CPU) |
33 | +#define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 60) | ||
34 | + | ||
35 | typedef struct Exynos4210Irq { | ||
36 | qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | ||
37 | qemu_irq ext_combiner_irq[EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ]; | ||
38 | @@ -XXX,XX +XXX,XX @@ struct Exynos4210State { | ||
39 | qemu_or_irq cpu_irq_orgate[EXYNOS4210_NCPUS]; | ||
40 | A9MPPrivState a9mpcore; | ||
41 | Exynos4210GicState ext_gic; | ||
42 | + SplitIRQ splitter[EXYNOS4210_NUM_SPLITTERS]; | ||
43 | }; | ||
44 | |||
45 | #define TYPE_EXYNOS4210_SOC "exynos4210" | ||
46 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/hw/arm/exynos4210.c | ||
49 | +++ b/hw/arm/exynos4210.c | ||
50 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
51 | uint32_t grp, bit, irq_id, n; | ||
52 | Exynos4210Irq *is = &s->irqs; | ||
53 | DeviceState *extgicdev = DEVICE(&s->ext_gic); | ||
54 | + int splitcount = 0; | ||
55 | + DeviceState *splitter; | ||
56 | |||
57 | for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { | ||
58 | irq_id = 0; | ||
59 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
60 | /* MCT_G1 is passed to External and GIC */ | ||
61 | irq_id = EXT_GIC_ID_MCT_G1; | ||
62 | } | ||
63 | + | ||
64 | + assert(splitcount < EXYNOS4210_NUM_SPLITTERS); | ||
65 | + splitter = DEVICE(&s->splitter[splitcount]); | ||
66 | + qdev_prop_set_uint16(splitter, "num-lines", 2); | ||
67 | + qdev_realize(splitter, NULL, &error_abort); | ||
68 | + splitcount++; | ||
69 | + s->irq_table[n] = qdev_get_gpio_in(splitter, 0); | ||
70 | + qdev_connect_gpio_out(splitter, 0, is->int_combiner_irq[n]); | ||
71 | if (irq_id) { | ||
72 | - s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
73 | - qdev_get_gpio_in(extgicdev, | ||
74 | - irq_id - 32)); | ||
75 | + qdev_connect_gpio_out(splitter, 1, | ||
76 | + qdev_get_gpio_in(extgicdev, irq_id - 32)); | ||
77 | } else { | ||
78 | - s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
79 | - is->ext_combiner_irq[n]); | ||
80 | + qdev_connect_gpio_out(splitter, 1, is->ext_combiner_irq[n]); | ||
81 | } | ||
82 | } | ||
83 | for (; n < EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; n++) { | ||
84 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
85 | EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][bit]; | ||
86 | |||
87 | if (irq_id) { | ||
88 | - s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
89 | - qdev_get_gpio_in(extgicdev, | ||
90 | - irq_id - 32)); | ||
91 | + assert(splitcount < EXYNOS4210_NUM_SPLITTERS); | ||
92 | + splitter = DEVICE(&s->splitter[splitcount]); | ||
93 | + qdev_prop_set_uint16(splitter, "num-lines", 2); | ||
94 | + qdev_realize(splitter, NULL, &error_abort); | ||
95 | + splitcount++; | ||
96 | + s->irq_table[n] = qdev_get_gpio_in(splitter, 0); | ||
97 | + qdev_connect_gpio_out(splitter, 0, is->int_combiner_irq[n]); | ||
98 | + qdev_connect_gpio_out(splitter, 1, | ||
99 | + qdev_get_gpio_in(extgicdev, irq_id - 32)); | ||
100 | } | ||
101 | } | ||
102 | + /* | ||
103 | + * We check this here to avoid a more obscure assert later when | ||
104 | + * qdev_assert_realized_properly() checks that we realized every | ||
105 | + * child object we initialized. | ||
106 | + */ | ||
107 | + assert(splitcount == EXYNOS4210_NUM_SPLITTERS); | ||
108 | } | ||
109 | |||
110 | /* | ||
111 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init(Object *obj) | ||
112 | object_initialize_child(obj, name, &s->cpu_irq_orgate[i], TYPE_OR_IRQ); | ||
113 | } | ||
114 | |||
115 | + for (i = 0; i < ARRAY_SIZE(s->splitter); i++) { | ||
116 | + g_autofree char *name = g_strdup_printf("irq-splitter%d", i); | ||
117 | + object_initialize_child(obj, name, &s->splitter[i], TYPE_SPLIT_IRQ); | ||
118 | + } | ||
119 | + | ||
120 | object_initialize_child(obj, "a9mpcore", &s->a9mpcore, TYPE_A9MPCORE_PRIV); | ||
121 | object_initialize_child(obj, "ext-gic", &s->ext_gic, TYPE_EXYNOS4210_GIC); | ||
122 | } | ||
123 | -- | 42 | -- |
124 | 2.25.1 | 43 | 2.34.1 |
44 | |||
45 | diff view generated by jsdifflib |
1 | From: Zongyuan Li <zongyuan.li@smartx.com> | 1 | From: Tong Ho <tong.ho@amd.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Zongyuan Li <zongyuan.li@smartx.com> | 3 | This change implements the ResettableClass interface for the device. |
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | |
5 | Message-id: 20220324181557.203805-2-zongyuan.li@smartx.com | 5 | Signed-off-by: Tong Ho <tong.ho@amd.com> |
6 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
7 | Message-id: 20231003052345.199725-1-tong.ho@amd.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 9 | --- |
8 | hw/arm/realview.c | 33 ++++++++++++++++++++++++--------- | 10 | hw/nvram/xlnx-bbram.c | 8 +++++--- |
9 | 1 file changed, 24 insertions(+), 9 deletions(-) | 11 | 1 file changed, 5 insertions(+), 3 deletions(-) |
10 | 12 | ||
11 | diff --git a/hw/arm/realview.c b/hw/arm/realview.c | 13 | diff --git a/hw/nvram/xlnx-bbram.c b/hw/nvram/xlnx-bbram.c |
12 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/arm/realview.c | 15 | --- a/hw/nvram/xlnx-bbram.c |
14 | +++ b/hw/arm/realview.c | 16 | +++ b/hw/nvram/xlnx-bbram.c |
15 | @@ -XXX,XX +XXX,XX @@ | 17 | @@ -XXX,XX +XXX,XX @@ |
16 | #include "hw/sysbus.h" | 18 | * QEMU model of the Xilinx BBRAM Battery Backed RAM |
17 | #include "hw/arm/boot.h" | 19 | * |
18 | #include "hw/arm/primecell.h" | 20 | * Copyright (c) 2014-2021 Xilinx Inc. |
19 | +#include "hw/core/split-irq.h" | 21 | + * Copyright (c) 2023 Advanced Micro Devices, Inc. |
20 | #include "hw/net/lan9118.h" | 22 | * |
21 | #include "hw/net/smc91c111.h" | 23 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
22 | #include "hw/pci/pci.h" | 24 | * of this software and associated documentation files (the "Software"), to deal |
23 | +#include "hw/qdev-core.h" | 25 | @@ -XXX,XX +XXX,XX @@ static RegisterAccessInfo bbram_ctrl_regs_info[] = { |
24 | #include "net/net.h" | 26 | } |
25 | #include "sysemu/sysemu.h" | ||
26 | #include "hw/boards.h" | ||
27 | @@ -XXX,XX +XXX,XX @@ static const int realview_board_id[] = { | ||
28 | 0x76d | ||
29 | }; | 27 | }; |
30 | 28 | ||
31 | +static void split_irq_from_named(DeviceState *src, const char* outname, | 29 | -static void bbram_ctrl_reset(DeviceState *dev) |
32 | + qemu_irq out1, qemu_irq out2) { | 30 | +static void bbram_ctrl_reset_hold(Object *obj) |
33 | + DeviceState *splitter = qdev_new(TYPE_SPLIT_IRQ); | ||
34 | + | ||
35 | + qdev_prop_set_uint32(splitter, "num-lines", 2); | ||
36 | + | ||
37 | + qdev_realize_and_unref(splitter, NULL, &error_fatal); | ||
38 | + | ||
39 | + qdev_connect_gpio_out(splitter, 0, out1); | ||
40 | + qdev_connect_gpio_out(splitter, 1, out2); | ||
41 | + qdev_connect_gpio_out_named(src, outname, 0, | ||
42 | + qdev_get_gpio_in(splitter, 0)); | ||
43 | +} | ||
44 | + | ||
45 | static void realview_init(MachineState *machine, | ||
46 | enum realview_board_type board_type) | ||
47 | { | 31 | { |
48 | @@ -XXX,XX +XXX,XX @@ static void realview_init(MachineState *machine, | 32 | - XlnxBBRam *s = XLNX_BBRAM(dev); |
49 | DeviceState *dev, *sysctl, *gpio2, *pl041; | 33 | + XlnxBBRam *s = XLNX_BBRAM(obj); |
50 | SysBusDevice *busdev; | 34 | unsigned int i; |
51 | qemu_irq pic[64]; | 35 | |
52 | - qemu_irq mmc_irq[2]; | 36 | for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) { |
53 | PCIBus *pci_bus = NULL; | 37 | @@ -XXX,XX +XXX,XX @@ static Property bbram_ctrl_props[] = { |
54 | NICInfo *nd; | 38 | static void bbram_ctrl_class_init(ObjectClass *klass, void *data) |
55 | DriveInfo *dinfo; | 39 | { |
56 | @@ -XXX,XX +XXX,XX @@ static void realview_init(MachineState *machine, | 40 | DeviceClass *dc = DEVICE_CLASS(klass); |
57 | * and the PL061 has them the other way about. Also the card | 41 | + ResettableClass *rc = RESETTABLE_CLASS(klass); |
58 | * detect line is inverted. | 42 | |
59 | */ | 43 | - dc->reset = bbram_ctrl_reset; |
60 | - mmc_irq[0] = qemu_irq_split( | 44 | + rc->phases.hold = bbram_ctrl_reset_hold; |
61 | - qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_WPROT), | 45 | dc->realize = bbram_ctrl_realize; |
62 | - qdev_get_gpio_in(gpio2, 1)); | 46 | dc->vmsd = &vmstate_bbram_ctrl; |
63 | - mmc_irq[1] = qemu_irq_split( | 47 | device_class_set_props(dc, bbram_ctrl_props); |
64 | - qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_CARDIN), | ||
65 | - qemu_irq_invert(qdev_get_gpio_in(gpio2, 0))); | ||
66 | - qdev_connect_gpio_out_named(dev, "card-read-only", 0, mmc_irq[0]); | ||
67 | - qdev_connect_gpio_out_named(dev, "card-inserted", 0, mmc_irq[1]); | ||
68 | + split_irq_from_named(dev, "card-read-only", | ||
69 | + qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_WPROT), | ||
70 | + qdev_get_gpio_in(gpio2, 1)); | ||
71 | + | ||
72 | + split_irq_from_named(dev, "card-inserted", | ||
73 | + qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_CARDIN), | ||
74 | + qemu_irq_invert(qdev_get_gpio_in(gpio2, 0))); | ||
75 | + | ||
76 | dinfo = drive_get(IF_SD, 0, 0); | ||
77 | if (dinfo) { | ||
78 | DeviceState *card; | ||
79 | -- | 48 | -- |
80 | 2.25.1 | 49 | 2.34.1 |
50 | |||
51 | diff view generated by jsdifflib |
1 | From: Zongyuan Li <zongyuan.li@smartx.com> | 1 | From: Tong Ho <tong.ho@amd.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Zongyuan Li <zongyuan.li@smartx.com> | 3 | This change implements the ResettableClass interface for the device. |
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | |
5 | Message-id: 20220324181557.203805-5-zongyuan.li@smartx.com | 5 | Signed-off-by: Tong Ho <tong.ho@amd.com> |
6 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/811 | 6 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> |
7 | Message-id: 20231004055713.324009-1-tong.ho@amd.com | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 9 | --- |
9 | include/hw/irq.h | 5 ----- | 10 | hw/nvram/xlnx-zynqmp-efuse.c | 8 +++++--- |
10 | hw/core/irq.c | 15 --------------- | 11 | 1 file changed, 5 insertions(+), 3 deletions(-) |
11 | 2 files changed, 20 deletions(-) | ||
12 | 12 | ||
13 | diff --git a/include/hw/irq.h b/include/hw/irq.h | 13 | diff --git a/hw/nvram/xlnx-zynqmp-efuse.c b/hw/nvram/xlnx-zynqmp-efuse.c |
14 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/include/hw/irq.h | 15 | --- a/hw/nvram/xlnx-zynqmp-efuse.c |
16 | +++ b/include/hw/irq.h | 16 | +++ b/hw/nvram/xlnx-zynqmp-efuse.c |
17 | @@ -XXX,XX +XXX,XX @@ void qemu_free_irq(qemu_irq irq); | 17 | @@ -XXX,XX +XXX,XX @@ |
18 | /* Returns a new IRQ with opposite polarity. */ | 18 | * QEMU model of the ZynqMP eFuse |
19 | qemu_irq qemu_irq_invert(qemu_irq irq); | 19 | * |
20 | 20 | * Copyright (c) 2015 Xilinx Inc. | |
21 | -/* Returns a new IRQ which feeds into both the passed IRQs. | 21 | + * Copyright (c) 2023 Advanced Micro Devices, Inc. |
22 | - * It's probably better to use the TYPE_SPLIT_IRQ device instead. | 22 | * |
23 | - */ | 23 | * Written by Edgar E. Iglesias <edgari@xilinx.com> |
24 | -qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2); | 24 | * |
25 | - | 25 | @@ -XXX,XX +XXX,XX @@ static void zynqmp_efuse_register_reset(RegisterInfo *reg) |
26 | /* For internal use in qtest. Similar to qemu_irq_split, but operating | 26 | register_reset(reg); |
27 | on an existing vector of qemu_irq. */ | ||
28 | void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, int n); | ||
29 | diff --git a/hw/core/irq.c b/hw/core/irq.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/hw/core/irq.c | ||
32 | +++ b/hw/core/irq.c | ||
33 | @@ -XXX,XX +XXX,XX @@ qemu_irq qemu_irq_invert(qemu_irq irq) | ||
34 | return qemu_allocate_irq(qemu_notirq, irq, 0); | ||
35 | } | 27 | } |
36 | 28 | ||
37 | -static void qemu_splitirq(void *opaque, int line, int level) | 29 | -static void zynqmp_efuse_reset(DeviceState *dev) |
38 | -{ | 30 | +static void zynqmp_efuse_reset_hold(Object *obj) |
39 | - struct IRQState **irq = opaque; | ||
40 | - irq[0]->handler(irq[0]->opaque, irq[0]->n, level); | ||
41 | - irq[1]->handler(irq[1]->opaque, irq[1]->n, level); | ||
42 | -} | ||
43 | - | ||
44 | -qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2) | ||
45 | -{ | ||
46 | - qemu_irq *s = g_new0(qemu_irq, 2); | ||
47 | - s[0] = irq1; | ||
48 | - s[1] = irq2; | ||
49 | - return qemu_allocate_irq(qemu_splitirq, s, 0); | ||
50 | -} | ||
51 | - | ||
52 | void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, int n) | ||
53 | { | 31 | { |
54 | int i; | 32 | - XlnxZynqMPEFuse *s = XLNX_ZYNQMP_EFUSE(dev); |
33 | + XlnxZynqMPEFuse *s = XLNX_ZYNQMP_EFUSE(obj); | ||
34 | unsigned int i; | ||
35 | |||
36 | for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) { | ||
37 | @@ -XXX,XX +XXX,XX @@ static Property zynqmp_efuse_props[] = { | ||
38 | static void zynqmp_efuse_class_init(ObjectClass *klass, void *data) | ||
39 | { | ||
40 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
41 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
42 | |||
43 | - dc->reset = zynqmp_efuse_reset; | ||
44 | + rc->phases.hold = zynqmp_efuse_reset_hold; | ||
45 | dc->realize = zynqmp_efuse_realize; | ||
46 | dc->vmsd = &vmstate_efuse; | ||
47 | device_class_set_props(dc, zynqmp_efuse_props); | ||
55 | -- | 48 | -- |
56 | 2.25.1 | 49 | 2.34.1 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> | 1 | From: Tong Ho <tong.ho@amd.com> |
---|---|---|---|
2 | 2 | ||
3 | Connect the 4 TTC timers on the ZynqMP. | 3 | This change implements the ResettableClass interface for the device. |
4 | 4 | ||
5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> | 5 | Signed-off-by: Tong Ho <tong.ho@amd.com> |
6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
7 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
8 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | 6 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> |
9 | Message-id: 20220331222017.2914409-3-edgar.iglesias@gmail.com | 7 | Message-id: 20231004055339.323833-1-tong.ho@amd.com |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 9 | --- |
12 | include/hw/arm/xlnx-zynqmp.h | 4 ++++ | 10 | hw/nvram/xlnx-versal-efuse-ctrl.c | 8 +++++--- |
13 | hw/arm/xlnx-zynqmp.c | 22 ++++++++++++++++++++++ | 11 | 1 file changed, 5 insertions(+), 3 deletions(-) |
14 | 2 files changed, 26 insertions(+) | ||
15 | 12 | ||
16 | diff --git a/include/hw/arm/xlnx-zynqmp.h b/include/hw/arm/xlnx-zynqmp.h | 13 | diff --git a/hw/nvram/xlnx-versal-efuse-ctrl.c b/hw/nvram/xlnx-versal-efuse-ctrl.c |
17 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/include/hw/arm/xlnx-zynqmp.h | 15 | --- a/hw/nvram/xlnx-versal-efuse-ctrl.c |
19 | +++ b/include/hw/arm/xlnx-zynqmp.h | 16 | +++ b/hw/nvram/xlnx-versal-efuse-ctrl.c |
20 | @@ -XXX,XX +XXX,XX @@ | 17 | @@ -XXX,XX +XXX,XX @@ |
21 | #include "hw/or-irq.h" | 18 | * QEMU model of the Versal eFuse controller |
22 | #include "hw/misc/xlnx-zynqmp-apu-ctrl.h" | 19 | * |
23 | #include "hw/misc/xlnx-zynqmp-crf.h" | 20 | * Copyright (c) 2020 Xilinx Inc. |
24 | +#include "hw/timer/cadence_ttc.h" | 21 | + * Copyright (c) 2023 Advanced Micro Devices, Inc. |
25 | 22 | * | |
26 | #define TYPE_XLNX_ZYNQMP "xlnx-zynqmp" | 23 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
27 | OBJECT_DECLARE_SIMPLE_TYPE(XlnxZynqMPState, XLNX_ZYNQMP) | 24 | * of this software and associated documentation files (the "Software"), to deal |
28 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(XlnxZynqMPState, XLNX_ZYNQMP) | 25 | @@ -XXX,XX +XXX,XX @@ static void efuse_ctrl_register_reset(RegisterInfo *reg) |
29 | #define XLNX_ZYNQMP_MAX_RAM_SIZE (XLNX_ZYNQMP_MAX_LOW_RAM_SIZE + \ | 26 | register_reset(reg); |
30 | XLNX_ZYNQMP_MAX_HIGH_RAM_SIZE) | ||
31 | |||
32 | +#define XLNX_ZYNQMP_NUM_TTC 4 | ||
33 | + | ||
34 | /* | ||
35 | * Unimplemented mmio regions needed to boot some images. | ||
36 | */ | ||
37 | @@ -XXX,XX +XXX,XX @@ struct XlnxZynqMPState { | ||
38 | qemu_or_irq qspi_irq_orgate; | ||
39 | XlnxZynqMPAPUCtrl apu_ctrl; | ||
40 | XlnxZynqMPCRF crf; | ||
41 | + CadenceTTCState ttc[XLNX_ZYNQMP_NUM_TTC]; | ||
42 | |||
43 | char *boot_cpu; | ||
44 | ARMCPU *boot_cpu_ptr; | ||
45 | diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/hw/arm/xlnx-zynqmp.c | ||
48 | +++ b/hw/arm/xlnx-zynqmp.c | ||
49 | @@ -XXX,XX +XXX,XX @@ | ||
50 | #define APU_ADDR 0xfd5c0000 | ||
51 | #define APU_IRQ 153 | ||
52 | |||
53 | +#define TTC0_ADDR 0xFF110000 | ||
54 | +#define TTC0_IRQ 36 | ||
55 | + | ||
56 | #define IPI_ADDR 0xFF300000 | ||
57 | #define IPI_IRQ 64 | ||
58 | |||
59 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_create_crf(XlnxZynqMPState *s, qemu_irq *gic) | ||
60 | sysbus_connect_irq(sbd, 0, gic[CRF_IRQ]); | ||
61 | } | 27 | } |
62 | 28 | ||
63 | +static void xlnx_zynqmp_create_ttc(XlnxZynqMPState *s, qemu_irq *gic) | 29 | -static void efuse_ctrl_reset(DeviceState *dev) |
64 | +{ | 30 | +static void efuse_ctrl_reset_hold(Object *obj) |
65 | + SysBusDevice *sbd; | ||
66 | + int i, irq; | ||
67 | + | ||
68 | + for (i = 0; i < XLNX_ZYNQMP_NUM_TTC; i++) { | ||
69 | + object_initialize_child(OBJECT(s), "ttc[*]", &s->ttc[i], | ||
70 | + TYPE_CADENCE_TTC); | ||
71 | + sbd = SYS_BUS_DEVICE(&s->ttc[i]); | ||
72 | + | ||
73 | + sysbus_realize(sbd, &error_fatal); | ||
74 | + sysbus_mmio_map(sbd, 0, TTC0_ADDR + i * 0x10000); | ||
75 | + for (irq = 0; irq < 3; irq++) { | ||
76 | + sysbus_connect_irq(sbd, irq, gic[TTC0_IRQ + i * 3 + irq]); | ||
77 | + } | ||
78 | + } | ||
79 | +} | ||
80 | + | ||
81 | static void xlnx_zynqmp_create_unimp_mmio(XlnxZynqMPState *s) | ||
82 | { | 31 | { |
83 | static const struct UnimpInfo { | 32 | - XlnxVersalEFuseCtrl *s = XLNX_VERSAL_EFUSE_CTRL(dev); |
84 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) | 33 | + XlnxVersalEFuseCtrl *s = XLNX_VERSAL_EFUSE_CTRL(obj); |
85 | xlnx_zynqmp_create_efuse(s, gic_spi); | 34 | unsigned int i; |
86 | xlnx_zynqmp_create_apu_ctrl(s, gic_spi); | 35 | |
87 | xlnx_zynqmp_create_crf(s, gic_spi); | 36 | for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) { |
88 | + xlnx_zynqmp_create_ttc(s, gic_spi); | 37 | @@ -XXX,XX +XXX,XX @@ static Property efuse_ctrl_props[] = { |
89 | xlnx_zynqmp_create_unimp_mmio(s); | 38 | static void efuse_ctrl_class_init(ObjectClass *klass, void *data) |
90 | 39 | { | |
91 | for (i = 0; i < XLNX_ZYNQMP_NUM_GDMA_CH; i++) { | 40 | DeviceClass *dc = DEVICE_CLASS(klass); |
41 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
42 | |||
43 | - dc->reset = efuse_ctrl_reset; | ||
44 | + rc->phases.hold = efuse_ctrl_reset_hold; | ||
45 | dc->realize = efuse_ctrl_realize; | ||
46 | dc->vmsd = &vmstate_efuse_ctrl; | ||
47 | device_class_set_props(dc, efuse_ctrl_props); | ||
92 | -- | 48 | -- |
93 | 2.25.1 | 49 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Zongyuan Li <zongyuan.li@smartx.com> | 1 | From: Tong Ho <tong.ho@amd.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Zongyuan Li <zongyuan.li@smartx.com> | 3 | This replaces the comma (,) to dot (.) in the device type name |
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | so the name can be used with the 'driver=' command line option. |
5 | Message-id: 20220324181557.203805-3-zongyuan.li@smartx.com | 5 | |
6 | Signed-off-by: Tong Ho <tong.ho@amd.com> | ||
7 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | ||
8 | Message-id: 20231003052139.199665-1-tong.ho@amd.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 10 | --- |
8 | hw/arm/stellaris.c | 15 +++++++++++++-- | 11 | include/hw/nvram/xlnx-bbram.h | 2 +- |
9 | 1 file changed, 13 insertions(+), 2 deletions(-) | 12 | 1 file changed, 1 insertion(+), 1 deletion(-) |
10 | 13 | ||
11 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | 14 | diff --git a/include/hw/nvram/xlnx-bbram.h b/include/hw/nvram/xlnx-bbram.h |
12 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/arm/stellaris.c | 16 | --- a/include/hw/nvram/xlnx-bbram.h |
14 | +++ b/hw/arm/stellaris.c | 17 | +++ b/include/hw/nvram/xlnx-bbram.h |
15 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ |
16 | 19 | ||
17 | #include "qemu/osdep.h" | 20 | #define RMAX_XLNX_BBRAM ((0x4c / 4) + 1) |
18 | #include "qapi/error.h" | 21 | |
19 | +#include "hw/core/split-irq.h" | 22 | -#define TYPE_XLNX_BBRAM "xlnx,bbram-ctrl" |
20 | #include "hw/sysbus.h" | 23 | +#define TYPE_XLNX_BBRAM "xlnx.bbram-ctrl" |
21 | #include "hw/sd/sd.h" | 24 | OBJECT_DECLARE_SIMPLE_TYPE(XlnxBBRam, XLNX_BBRAM); |
22 | #include "hw/ssi/ssi.h" | 25 | |
23 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | 26 | struct XlnxBBRam { |
24 | DeviceState *ssddev; | ||
25 | DriveInfo *dinfo; | ||
26 | DeviceState *carddev; | ||
27 | + DeviceState *gpio_d_splitter; | ||
28 | BlockBackend *blk; | ||
29 | |||
30 | /* | ||
31 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
32 | &error_fatal); | ||
33 | |||
34 | ssddev = ssi_create_peripheral(bus, "ssd0323"); | ||
35 | - gpio_out[GPIO_D][0] = qemu_irq_split( | ||
36 | - qdev_get_gpio_in_named(sddev, SSI_GPIO_CS, 0), | ||
37 | + | ||
38 | + gpio_d_splitter = qdev_new(TYPE_SPLIT_IRQ); | ||
39 | + qdev_prop_set_uint32(gpio_d_splitter, "num-lines", 2); | ||
40 | + qdev_realize_and_unref(gpio_d_splitter, NULL, &error_fatal); | ||
41 | + qdev_connect_gpio_out( | ||
42 | + gpio_d_splitter, 0, | ||
43 | + qdev_get_gpio_in_named(sddev, SSI_GPIO_CS, 0)); | ||
44 | + qdev_connect_gpio_out( | ||
45 | + gpio_d_splitter, 1, | ||
46 | qdev_get_gpio_in_named(ssddev, SSI_GPIO_CS, 0)); | ||
47 | + gpio_out[GPIO_D][0] = qdev_get_gpio_in(gpio_d_splitter, 0); | ||
48 | + | ||
49 | gpio_out[GPIO_C][7] = qdev_get_gpio_in(ssddev, 0); | ||
50 | |||
51 | /* Make sure the select pin is high. */ | ||
52 | -- | 27 | -- |
53 | 2.25.1 | 28 | 2.34.1 | diff view generated by jsdifflib |
1 | Switch the creation of the combiner devices to the new-style | 1 | From: Viktor Prutyanov <viktor@daynix.com> |
---|---|---|---|
2 | "embedded in state struct" approach, so we can easily refer | ||
3 | to the object elsewhere during realize. | ||
4 | 2 | ||
3 | String sign_rsds isn't terminated, so the print length must be limited. | ||
4 | |||
5 | Fixes: Coverity CID 1521598 | ||
6 | Signed-off-by: Viktor Prutyanov <viktor@daynix.com> | ||
7 | Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
8 | Message-id: 20230930235317.11469-2-viktor@daynix.com | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220404154658.565020-18-peter.maydell@linaro.org | ||
8 | --- | 10 | --- |
9 | include/hw/arm/exynos4210.h | 3 ++ | 11 | contrib/elf2dmp/main.c | 2 +- |
10 | include/hw/intc/exynos4210_combiner.h | 57 +++++++++++++++++++++++++++ | 12 | 1 file changed, 1 insertion(+), 1 deletion(-) |
11 | hw/arm/exynos4210.c | 20 +++++----- | ||
12 | hw/intc/exynos4210_combiner.c | 31 +-------------- | ||
13 | 4 files changed, 72 insertions(+), 39 deletions(-) | ||
14 | create mode 100644 include/hw/intc/exynos4210_combiner.h | ||
15 | 13 | ||
16 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | 14 | diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c |
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/include/hw/arm/exynos4210.h | 16 | --- a/contrib/elf2dmp/main.c |
19 | +++ b/include/hw/arm/exynos4210.h | 17 | +++ b/contrib/elf2dmp/main.c |
20 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ static bool pe_check_pdb_name(uint64_t base, void *start_addr, |
21 | #include "hw/sysbus.h" | ||
22 | #include "hw/cpu/a9mpcore.h" | ||
23 | #include "hw/intc/exynos4210_gic.h" | ||
24 | +#include "hw/intc/exynos4210_combiner.h" | ||
25 | #include "hw/core/split-irq.h" | ||
26 | #include "target/arm/cpu-qom.h" | ||
27 | #include "qom/object.h" | ||
28 | @@ -XXX,XX +XXX,XX @@ struct Exynos4210State { | ||
29 | qemu_or_irq cpu_irq_orgate[EXYNOS4210_NCPUS]; | ||
30 | A9MPPrivState a9mpcore; | ||
31 | Exynos4210GicState ext_gic; | ||
32 | + Exynos4210CombinerState int_combiner; | ||
33 | + Exynos4210CombinerState ext_combiner; | ||
34 | SplitIRQ splitter[EXYNOS4210_NUM_SPLITTERS]; | ||
35 | }; | ||
36 | |||
37 | diff --git a/include/hw/intc/exynos4210_combiner.h b/include/hw/intc/exynos4210_combiner.h | ||
38 | new file mode 100644 | ||
39 | index XXXXXXX..XXXXXXX | ||
40 | --- /dev/null | ||
41 | +++ b/include/hw/intc/exynos4210_combiner.h | ||
42 | @@ -XXX,XX +XXX,XX @@ | ||
43 | +/* | ||
44 | + * Samsung exynos4210 Interrupt Combiner | ||
45 | + * | ||
46 | + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. | ||
47 | + * All rights reserved. | ||
48 | + * | ||
49 | + * Evgeny Voevodin <e.voevodin@samsung.com> | ||
50 | + * | ||
51 | + * This program is free software; you can redistribute it and/or modify it | ||
52 | + * under the terms of the GNU General Public License as published by the | ||
53 | + * Free Software Foundation; either version 2 of the License, or (at your | ||
54 | + * option) any later version. | ||
55 | + * | ||
56 | + * This program is distributed in the hope that it will be useful, | ||
57 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
58 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
59 | + * See the GNU General Public License for more details. | ||
60 | + * | ||
61 | + * You should have received a copy of the GNU General Public License along | ||
62 | + * with this program; if not, see <http://www.gnu.org/licenses/>. | ||
63 | + */ | ||
64 | + | ||
65 | +#ifndef HW_INTC_EXYNOS4210_COMBINER | ||
66 | +#define HW_INTC_EXYNOS4210_COMBINER | ||
67 | + | ||
68 | +#include "hw/sysbus.h" | ||
69 | + | ||
70 | +/* | ||
71 | + * State for each output signal of internal combiner | ||
72 | + */ | ||
73 | +typedef struct CombinerGroupState { | ||
74 | + uint8_t src_mask; /* 1 - source enabled, 0 - disabled */ | ||
75 | + uint8_t src_pending; /* Pending source interrupts before masking */ | ||
76 | +} CombinerGroupState; | ||
77 | + | ||
78 | +#define TYPE_EXYNOS4210_COMBINER "exynos4210.combiner" | ||
79 | +OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210CombinerState, EXYNOS4210_COMBINER) | ||
80 | + | ||
81 | +/* Number of groups and total number of interrupts for the internal combiner */ | ||
82 | +#define IIC_NGRP 64 | ||
83 | +#define IIC_NIRQ (IIC_NGRP * 8) | ||
84 | +#define IIC_REGSET_SIZE 0x41 | ||
85 | + | ||
86 | +struct Exynos4210CombinerState { | ||
87 | + SysBusDevice parent_obj; | ||
88 | + | ||
89 | + MemoryRegion iomem; | ||
90 | + | ||
91 | + struct CombinerGroupState group[IIC_NGRP]; | ||
92 | + uint32_t reg_set[IIC_REGSET_SIZE]; | ||
93 | + uint32_t icipsr[2]; | ||
94 | + uint32_t external; /* 1 means that this combiner is external */ | ||
95 | + | ||
96 | + qemu_irq output_irq[IIC_NGRP]; | ||
97 | +}; | ||
98 | + | ||
99 | +#endif | ||
100 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
101 | index XXXXXXX..XXXXXXX 100644 | ||
102 | --- a/hw/arm/exynos4210.c | ||
103 | +++ b/hw/arm/exynos4210.c | ||
104 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
105 | } | 19 | } |
106 | 20 | ||
107 | /* Internal Interrupt Combiner */ | 21 | if (memcmp(&rsds->Signature, sign_rsds, sizeof(sign_rsds))) { |
108 | - dev = qdev_new("exynos4210.combiner"); | 22 | - eprintf("CodeView signature is \'%.4s\', \'%s\' expected\n", |
109 | - busdev = SYS_BUS_DEVICE(dev); | 23 | + eprintf("CodeView signature is \'%.4s\', \'%.4s\' expected\n", |
110 | - sysbus_realize_and_unref(busdev, &error_fatal); | 24 | rsds->Signature, sign_rsds); |
111 | + busdev = SYS_BUS_DEVICE(&s->int_combiner); | 25 | return false; |
112 | + sysbus_realize(busdev, &error_fatal); | ||
113 | for (n = 0; n < EXYNOS4210_MAX_INT_COMBINER_OUT_IRQ; n++) { | ||
114 | sysbus_connect_irq(busdev, n, | ||
115 | qdev_get_gpio_in(DEVICE(&s->a9mpcore), n)); | ||
116 | } | 26 | } |
117 | - exynos4210_combiner_get_gpioin(&s->irqs, dev, 0); | ||
118 | + exynos4210_combiner_get_gpioin(&s->irqs, DEVICE(&s->int_combiner), 0); | ||
119 | sysbus_mmio_map(busdev, 0, EXYNOS4210_INT_COMBINER_BASE_ADDR); | ||
120 | |||
121 | /* External Interrupt Combiner */ | ||
122 | - dev = qdev_new("exynos4210.combiner"); | ||
123 | - qdev_prop_set_uint32(dev, "external", 1); | ||
124 | - busdev = SYS_BUS_DEVICE(dev); | ||
125 | - sysbus_realize_and_unref(busdev, &error_fatal); | ||
126 | + qdev_prop_set_uint32(DEVICE(&s->ext_combiner), "external", 1); | ||
127 | + busdev = SYS_BUS_DEVICE(&s->ext_combiner); | ||
128 | + sysbus_realize(busdev, &error_fatal); | ||
129 | for (n = 0; n < EXYNOS4210_MAX_INT_COMBINER_OUT_IRQ; n++) { | ||
130 | sysbus_connect_irq(busdev, n, qdev_get_gpio_in(DEVICE(&s->ext_gic), n)); | ||
131 | } | ||
132 | - exynos4210_combiner_get_gpioin(&s->irqs, dev, 1); | ||
133 | + exynos4210_combiner_get_gpioin(&s->irqs, DEVICE(&s->ext_combiner), 1); | ||
134 | sysbus_mmio_map(busdev, 0, EXYNOS4210_EXT_COMBINER_BASE_ADDR); | ||
135 | |||
136 | /* Initialize board IRQs. */ | ||
137 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init(Object *obj) | ||
138 | |||
139 | object_initialize_child(obj, "a9mpcore", &s->a9mpcore, TYPE_A9MPCORE_PRIV); | ||
140 | object_initialize_child(obj, "ext-gic", &s->ext_gic, TYPE_EXYNOS4210_GIC); | ||
141 | + object_initialize_child(obj, "int-combiner", &s->int_combiner, | ||
142 | + TYPE_EXYNOS4210_COMBINER); | ||
143 | + object_initialize_child(obj, "ext-combiner", &s->ext_combiner, | ||
144 | + TYPE_EXYNOS4210_COMBINER); | ||
145 | } | ||
146 | |||
147 | static void exynos4210_class_init(ObjectClass *klass, void *data) | ||
148 | diff --git a/hw/intc/exynos4210_combiner.c b/hw/intc/exynos4210_combiner.c | ||
149 | index XXXXXXX..XXXXXXX 100644 | ||
150 | --- a/hw/intc/exynos4210_combiner.c | ||
151 | +++ b/hw/intc/exynos4210_combiner.c | ||
152 | @@ -XXX,XX +XXX,XX @@ | ||
153 | #include "hw/sysbus.h" | ||
154 | #include "migration/vmstate.h" | ||
155 | #include "qemu/module.h" | ||
156 | - | ||
157 | +#include "hw/intc/exynos4210_combiner.h" | ||
158 | #include "hw/arm/exynos4210.h" | ||
159 | #include "hw/hw.h" | ||
160 | #include "hw/irq.h" | ||
161 | @@ -XXX,XX +XXX,XX @@ | ||
162 | #define DPRINTF(fmt, ...) do {} while (0) | ||
163 | #endif | ||
164 | |||
165 | -#define IIC_NGRP 64 /* Internal Interrupt Combiner | ||
166 | - Groups number */ | ||
167 | -#define IIC_NIRQ (IIC_NGRP * 8)/* Internal Interrupt Combiner | ||
168 | - Interrupts number */ | ||
169 | #define IIC_REGION_SIZE 0x108 /* Size of memory mapped region */ | ||
170 | -#define IIC_REGSET_SIZE 0x41 | ||
171 | - | ||
172 | -/* | ||
173 | - * State for each output signal of internal combiner | ||
174 | - */ | ||
175 | -typedef struct CombinerGroupState { | ||
176 | - uint8_t src_mask; /* 1 - source enabled, 0 - disabled */ | ||
177 | - uint8_t src_pending; /* Pending source interrupts before masking */ | ||
178 | -} CombinerGroupState; | ||
179 | - | ||
180 | -#define TYPE_EXYNOS4210_COMBINER "exynos4210.combiner" | ||
181 | -OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210CombinerState, EXYNOS4210_COMBINER) | ||
182 | - | ||
183 | -struct Exynos4210CombinerState { | ||
184 | - SysBusDevice parent_obj; | ||
185 | - | ||
186 | - MemoryRegion iomem; | ||
187 | - | ||
188 | - struct CombinerGroupState group[IIC_NGRP]; | ||
189 | - uint32_t reg_set[IIC_REGSET_SIZE]; | ||
190 | - uint32_t icipsr[2]; | ||
191 | - uint32_t external; /* 1 means that this combiner is external */ | ||
192 | - | ||
193 | - qemu_irq output_irq[IIC_NGRP]; | ||
194 | -}; | ||
195 | |||
196 | static const VMStateDescription vmstate_exynos4210_combiner_group_state = { | ||
197 | .name = "exynos4210.combiner.groupstate", | ||
198 | -- | 27 | -- |
199 | 2.25.1 | 28 | 2.34.1 | diff view generated by jsdifflib |
1 | At this point, the function exynos4210_init_board_irqs() splits input | 1 | From: Viktor Prutyanov <viktor@daynix.com> |
---|---|---|---|
2 | IRQ lines to connect them to the input combiner, output combiner and | ||
3 | external GIC. The function exynos4210_combiner_get_gpioin() splits | ||
4 | some of the combiner input lines further to connect them to multiple | ||
5 | different inputs on the combiner. | ||
6 | 2 | ||
7 | Because (unlike qemu_irq_split()) the TYPE_SPLIT_IRQ device has a | 3 | Index in file_size array must be checked against num_files, because the |
8 | configurable number of outputs, we can do all this in one place, by | 4 | entries we are looking for may be absent in the PDB. |
9 | making exynos4210_init_board_irqs() add extra outputs to the splitter | ||
10 | device when it must be connected to more than one input on each | ||
11 | combiner. | ||
12 | 5 | ||
13 | We do this with a new data structure, the combinermap, which is an | 6 | Fixes: Coverity CID 1521597 |
14 | array each of whose elements is a list of the interrupt IDs on the | 7 | Signed-off-by: Viktor Prutyanov <viktor@daynix.com> |
15 | combiner which must be tied together. As we loop through each | 8 | Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> |
16 | interrupt ID, if we find that it is the first one in one of these | 9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
17 | lists, we configure the splitter device with eonugh extra outputs and | 10 | Message-id: 20230930235317.11469-3-viktor@daynix.com |
18 | wire them up to the other interrupt IDs in the list. | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | ||
13 | contrib/elf2dmp/pdb.c | 13 +++++++++---- | ||
14 | 1 file changed, 9 insertions(+), 4 deletions(-) | ||
19 | 15 | ||
20 | Conveniently, for all the cases where this is necessary, the | 16 | diff --git a/contrib/elf2dmp/pdb.c b/contrib/elf2dmp/pdb.c |
21 | lowest-numbered interrupt ID in each group is in the range of the | ||
22 | external combiner, so we only need to code for this in the first of | ||
23 | the two loops in exynos4210_init_board_irqs(). | ||
24 | |||
25 | The old code in exynos4210_combiner_get_gpioin() which is being | ||
26 | deleted here had several problems which don't exist in the new code | ||
27 | in its handling of the multi-core timer interrupts: | ||
28 | (1) the case labels specified bits 4 ... 8, but bit '8' doesn't | ||
29 | exist; these should have been 4 ... 7 | ||
30 | (2) it used the input irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)] | ||
31 | multiple times as the input of several different splitters, | ||
32 | which isn't allowed | ||
33 | (3) in an apparent cut-and-paste error, the cases for all the | ||
34 | multi-core timer inputs used "bit + 4" even though the | ||
35 | bit range for the case was (intended to be) 4 ... 7, which | ||
36 | meant it was looking at non-existent bits 8 ... 11. | ||
37 | None of these exist in the new code. | ||
38 | |||
39 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
40 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
41 | Message-id: 20220404154658.565020-17-peter.maydell@linaro.org | ||
42 | --- | ||
43 | include/hw/arm/exynos4210.h | 6 +- | ||
44 | hw/arm/exynos4210.c | 178 +++++++++++++++++++++++------------- | ||
45 | 2 files changed, 119 insertions(+), 65 deletions(-) | ||
46 | |||
47 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | ||
48 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
49 | --- a/include/hw/arm/exynos4210.h | 18 | --- a/contrib/elf2dmp/pdb.c |
50 | +++ b/include/hw/arm/exynos4210.h | 19 | +++ b/contrib/elf2dmp/pdb.c |
51 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ |
52 | 21 | ||
53 | /* | 22 | static uint32_t pdb_get_file_size(const struct pdb_reader *r, unsigned idx) |
54 | * We need one splitter for every external combiner input, plus | 23 | { |
55 | - * one for every non-zero entry in combiner_grp_to_gic_id[]. | 24 | + if (idx >= r->ds.toc->num_files) { |
56 | + * one for every non-zero entry in combiner_grp_to_gic_id[], | 25 | + return 0; |
57 | + * minus one for every external combiner ID in second or later | 26 | + } |
58 | + * places in a combinermap[] line. | ||
59 | * We'll assert in exynos4210_init_board_irqs() if this is wrong. | ||
60 | */ | ||
61 | -#define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 54) | ||
62 | +#define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 38) | ||
63 | |||
64 | typedef struct Exynos4210Irq { | ||
65 | qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | ||
66 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/hw/arm/exynos4210.c | ||
69 | +++ b/hw/arm/exynos4210.c | ||
70 | @@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | ||
71 | #define EXYNOS4210_COMBINER_GET_BIT_NUM(irq) \ | ||
72 | ((irq) - 8 * EXYNOS4210_COMBINER_GET_GRP_NUM(irq)) | ||
73 | |||
74 | +/* | ||
75 | + * Some interrupt lines go to multiple combiner inputs. | ||
76 | + * This data structure defines those: each array element is | ||
77 | + * a list of combiner inputs which are connected together; | ||
78 | + * the one with the smallest interrupt ID value must be first. | ||
79 | + * As with combiner_grp_to_gic_id[], we rely on (0, 0) not being | ||
80 | + * wired to anything so we can use 0 as a terminator. | ||
81 | + */ | ||
82 | +#define IRQNO(G, B) EXYNOS4210_COMBINER_GET_IRQ_NUM(G, B) | ||
83 | +#define IRQNONE 0 | ||
84 | + | 27 | + |
85 | +#define COMBINERMAP_SIZE 16 | 28 | return r->ds.toc->file_size[idx]; |
86 | + | 29 | } |
87 | +static const int combinermap[COMBINERMAP_SIZE][6] = { | 30 | |
88 | + /* MDNIE_LCD1 */ | 31 | @@ -XXX,XX +XXX,XX @@ static void *pdb_ds_read_file(struct pdb_reader* r, uint32_t file_number) |
89 | + { IRQNO(0, 4), IRQNO(1, 0), IRQNONE }, | 32 | |
90 | + { IRQNO(0, 5), IRQNO(1, 1), IRQNONE }, | 33 | static int pdb_init_segments(struct pdb_reader *r) |
91 | + { IRQNO(0, 6), IRQNO(1, 2), IRQNONE }, | 34 | { |
92 | + { IRQNO(0, 7), IRQNO(1, 3), IRQNONE }, | 35 | - char *segs; |
93 | + /* TMU */ | 36 | unsigned stream_idx = r->segments; |
94 | + { IRQNO(2, 4), IRQNO(3, 4), IRQNONE }, | 37 | |
95 | + { IRQNO(2, 5), IRQNO(3, 5), IRQNONE }, | 38 | - segs = pdb_ds_read_file(r, stream_idx); |
96 | + { IRQNO(2, 6), IRQNO(3, 6), IRQNONE }, | 39 | - if (!segs) { |
97 | + { IRQNO(2, 7), IRQNO(3, 7), IRQNONE }, | 40 | + r->segs = pdb_ds_read_file(r, stream_idx); |
98 | + /* LCD1 */ | 41 | + if (!r->segs) { |
99 | + { IRQNO(11, 4), IRQNO(12, 0), IRQNONE }, | 42 | return 1; |
100 | + { IRQNO(11, 5), IRQNO(12, 1), IRQNONE }, | 43 | } |
101 | + { IRQNO(11, 6), IRQNO(12, 2), IRQNONE }, | 44 | |
102 | + { IRQNO(11, 7), IRQNO(12, 3), IRQNONE }, | 45 | - r->segs = segs; |
103 | + /* Multi-core timer */ | 46 | r->segs_size = pdb_get_file_size(r, stream_idx); |
104 | + { IRQNO(1, 4), IRQNO(12, 4), IRQNO(35, 4), IRQNO(51, 4), IRQNO(53, 4), IRQNONE }, | 47 | + if (!r->segs_size) { |
105 | + { IRQNO(1, 5), IRQNO(12, 5), IRQNO(35, 5), IRQNO(51, 5), IRQNO(53, 5), IRQNONE }, | ||
106 | + { IRQNO(1, 6), IRQNO(12, 6), IRQNO(35, 6), IRQNO(51, 6), IRQNO(53, 6), IRQNONE }, | ||
107 | + { IRQNO(1, 7), IRQNO(12, 7), IRQNO(35, 7), IRQNO(51, 7), IRQNO(53, 7), IRQNONE }, | ||
108 | +}; | ||
109 | + | ||
110 | +#undef IRQNO | ||
111 | + | ||
112 | +static const int *combinermap_entry(int irq) | ||
113 | +{ | ||
114 | + /* | ||
115 | + * If the interrupt number passed in is the first entry in some | ||
116 | + * line of the combinermap, return a pointer to that line; | ||
117 | + * otherwise return NULL. | ||
118 | + */ | ||
119 | + int i; | ||
120 | + for (i = 0; i < COMBINERMAP_SIZE; i++) { | ||
121 | + if (combinermap[i][0] == irq) { | ||
122 | + return combinermap[i]; | ||
123 | + } | ||
124 | + } | ||
125 | + return NULL; | ||
126 | +} | ||
127 | + | ||
128 | +static int mapline_size(const int *mapline) | ||
129 | +{ | ||
130 | + /* Return number of entries in this mapline in total */ | ||
131 | + int i = 0; | ||
132 | + | ||
133 | + if (!mapline) { | ||
134 | + /* Not in the map? IRQ goes to exactly one combiner input */ | ||
135 | + return 1; | 48 | + return 1; |
136 | + } | 49 | + } |
137 | + while (*mapline != IRQNONE) { | 50 | |
138 | + mapline++; | 51 | return 0; |
139 | + i++; | ||
140 | + } | ||
141 | + return i; | ||
142 | +} | ||
143 | + | ||
144 | /* | ||
145 | * Initialize board IRQs. | ||
146 | * These IRQs contain splitted Int/External Combiner and External Gic IRQs. | ||
147 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
148 | DeviceState *extgicdev = DEVICE(&s->ext_gic); | ||
149 | int splitcount = 0; | ||
150 | DeviceState *splitter; | ||
151 | + const int *mapline; | ||
152 | + int numlines, splitin, in; | ||
153 | |||
154 | for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { | ||
155 | irq_id = 0; | ||
156 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
157 | irq_id = EXT_GIC_ID_MCT_G1; | ||
158 | } | ||
159 | |||
160 | + if (s->irq_table[n]) { | ||
161 | + /* | ||
162 | + * This must be some non-first entry in a combinermap line, | ||
163 | + * and we've already filled it in. | ||
164 | + */ | ||
165 | + continue; | ||
166 | + } | ||
167 | + mapline = combinermap_entry(n); | ||
168 | + /* | ||
169 | + * We need to connect the IRQ to multiple inputs on both combiners | ||
170 | + * and possibly also to the external GIC. | ||
171 | + */ | ||
172 | + numlines = 2 * mapline_size(mapline); | ||
173 | + if (irq_id) { | ||
174 | + numlines++; | ||
175 | + } | ||
176 | assert(splitcount < EXYNOS4210_NUM_SPLITTERS); | ||
177 | splitter = DEVICE(&s->splitter[splitcount]); | ||
178 | - qdev_prop_set_uint16(splitter, "num-lines", irq_id ? 3 : 2); | ||
179 | + qdev_prop_set_uint16(splitter, "num-lines", numlines); | ||
180 | qdev_realize(splitter, NULL, &error_abort); | ||
181 | splitcount++; | ||
182 | - s->irq_table[n] = qdev_get_gpio_in(splitter, 0); | ||
183 | - qdev_connect_gpio_out(splitter, 0, is->int_combiner_irq[n]); | ||
184 | - qdev_connect_gpio_out(splitter, 1, is->ext_combiner_irq[n]); | ||
185 | + | ||
186 | + in = n; | ||
187 | + splitin = 0; | ||
188 | + for (;;) { | ||
189 | + s->irq_table[in] = qdev_get_gpio_in(splitter, 0); | ||
190 | + qdev_connect_gpio_out(splitter, splitin, is->int_combiner_irq[in]); | ||
191 | + qdev_connect_gpio_out(splitter, splitin + 1, is->ext_combiner_irq[in]); | ||
192 | + splitin += 2; | ||
193 | + if (!mapline) { | ||
194 | + break; | ||
195 | + } | ||
196 | + mapline++; | ||
197 | + in = *mapline; | ||
198 | + if (in == IRQNONE) { | ||
199 | + break; | ||
200 | + } | ||
201 | + } | ||
202 | if (irq_id) { | ||
203 | - qdev_connect_gpio_out(splitter, 2, | ||
204 | + qdev_connect_gpio_out(splitter, splitin, | ||
205 | qdev_get_gpio_in(extgicdev, irq_id - 32)); | ||
206 | } | ||
207 | } | ||
208 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
209 | irq_id = combiner_grp_to_gic_id[grp - | ||
210 | EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][bit]; | ||
211 | |||
212 | + if (s->irq_table[n]) { | ||
213 | + /* | ||
214 | + * This must be some non-first entry in a combinermap line, | ||
215 | + * and we've already filled it in. | ||
216 | + */ | ||
217 | + continue; | ||
218 | + } | ||
219 | + | ||
220 | if (irq_id) { | ||
221 | assert(splitcount < EXYNOS4210_NUM_SPLITTERS); | ||
222 | splitter = DEVICE(&s->splitter[splitcount]); | ||
223 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, | ||
224 | DeviceState *dev, int ext) | ||
225 | { | ||
226 | int n; | ||
227 | - int bit; | ||
228 | int max; | ||
229 | qemu_irq *irq; | ||
230 | |||
231 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, | ||
232 | EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; | ||
233 | irq = ext ? irqs->ext_combiner_irq : irqs->int_combiner_irq; | ||
234 | |||
235 | - /* | ||
236 | - * Some IRQs of Int/External Combiner are going to two Combiners groups, | ||
237 | - * so let split them. | ||
238 | - */ | ||
239 | for (n = 0; n < max; n++) { | ||
240 | - | ||
241 | - bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n); | ||
242 | - | ||
243 | - switch (n) { | ||
244 | - /* MDNIE_LCD1 INTG1 */ | ||
245 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 0) ... | ||
246 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 3): | ||
247 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
248 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(0, bit + 4)]); | ||
249 | - continue; | ||
250 | - | ||
251 | - /* TMU INTG3 */ | ||
252 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(3, 4): | ||
253 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
254 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(2, bit)]); | ||
255 | - continue; | ||
256 | - | ||
257 | - /* LCD1 INTG12 */ | ||
258 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 0) ... | ||
259 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 3): | ||
260 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
261 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(11, bit + 4)]); | ||
262 | - continue; | ||
263 | - | ||
264 | - /* Multi-Core Timer INTG12 */ | ||
265 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4) ... | ||
266 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 8): | ||
267 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
268 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
269 | - continue; | ||
270 | - | ||
271 | - /* Multi-Core Timer INTG35 */ | ||
272 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 4) ... | ||
273 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 8): | ||
274 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
275 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
276 | - continue; | ||
277 | - | ||
278 | - /* Multi-Core Timer INTG51 */ | ||
279 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(51, 4) ... | ||
280 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(51, 8): | ||
281 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
282 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
283 | - continue; | ||
284 | - | ||
285 | - /* Multi-Core Timer INTG53 */ | ||
286 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(53, 4) ... | ||
287 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(53, 8): | ||
288 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
289 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
290 | - continue; | ||
291 | - } | ||
292 | - | ||
293 | irq[n] = qdev_get_gpio_in(dev, n); | ||
294 | } | ||
295 | } | 52 | } |
296 | -- | 53 | -- |
297 | 2.25.1 | 54 | 2.34.1 |
55 | |||
56 | diff view generated by jsdifflib |
1 | From: Hao Wu <wuhaotsh@google.com> | 1 | From: Michal Orzel <michal.orzel@amd.com> |
---|---|---|---|
2 | 2 | ||
3 | This patch uses the defined fields to describe PWRON STRAPs for | 3 | On an attempt to access CNTPCT_EL0 from EL0 using a guest running on top |
4 | better readability. | 4 | of Xen, a trap from EL2 was observed which is something not reproducible |
5 | on HW (also, Xen does not trap accesses to physical counter). | ||
5 | 6 | ||
6 | Signed-off-by: Hao Wu <wuhaotsh@google.com> | 7 | This is because gt_counter_access() checks for an incorrect bit (1 |
7 | Reviewed-by: Patrick Venture <venture@google.com> | 8 | instead of 0) of CNTHCTL_EL2 if HCR_EL2.E2H is 0 and access is made to |
8 | Message-id: 20220411165842.3912945-3-wuhaotsh@google.com | 9 | physical counter. Refer ARM ARM DDI 0487J.a, D19.12.2: |
10 | When HCR_EL2.E2H is 0: | ||
11 | - EL1PCTEN, bit [0]: refers to physical counter | ||
12 | - EL1PCEN, bit [1]: refers to physical timer registers | ||
13 | |||
14 | Drop entire block "if (hcr & HCR_E2H) {...} else {...}" from EL0 case | ||
15 | and fall through to EL1 case, given that after fixing checking for the | ||
16 | correct bit, the handling is the same. | ||
17 | |||
18 | Fixes: 5bc8437136fb ("target/arm: Update timer access for VHE") | ||
19 | Signed-off-by: Michal Orzel <michal.orzel@amd.com> | ||
20 | Tested-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com> | ||
21 | Message-id: 20230928094404.20802-1-michal.orzel@amd.com | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 22 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 24 | --- |
12 | hw/arm/npcm7xx_boards.c | 24 +++++++++++++++++++----- | 25 | target/arm/helper.c | 17 +---------------- |
13 | 1 file changed, 19 insertions(+), 5 deletions(-) | 26 | 1 file changed, 1 insertion(+), 16 deletions(-) |
14 | 27 | ||
15 | diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c | 28 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
16 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/npcm7xx_boards.c | 30 | --- a/target/arm/helper.c |
18 | +++ b/hw/arm/npcm7xx_boards.c | 31 | +++ b/target/arm/helper.c |
19 | @@ -XXX,XX +XXX,XX @@ | 32 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult gt_counter_access(CPUARMState *env, int timeridx, |
20 | #include "sysemu/sysemu.h" | 33 | if (!extract32(env->cp15.c14_cntkctl, timeridx, 1)) { |
21 | #include "sysemu/block-backend.h" | 34 | return CP_ACCESS_TRAP; |
22 | 35 | } | |
23 | -#define NPCM750_EVB_POWER_ON_STRAPS 0x00001ff7 | 36 | - |
24 | -#define QUANTA_GSJ_POWER_ON_STRAPS 0x00001fff | 37 | - /* If HCR_EL2.<E2H,TGE> == '10': check CNTHCTL_EL2.EL1PCTEN. */ |
25 | -#define QUANTA_GBS_POWER_ON_STRAPS 0x000017ff | 38 | - if (hcr & HCR_E2H) { |
26 | -#define KUDO_BMC_POWER_ON_STRAPS 0x00001fff | 39 | - if (timeridx == GTIMER_PHYS && |
27 | -#define MORI_BMC_POWER_ON_STRAPS 0x00001fff | 40 | - !extract32(env->cp15.cnthctl_el2, 10, 1)) { |
28 | +#define NPCM7XX_POWER_ON_STRAPS_DEFAULT ( \ | 41 | - return CP_ACCESS_TRAP_EL2; |
29 | + NPCM7XX_PWRON_STRAP_SPI0F18 | \ | 42 | - } |
30 | + NPCM7XX_PWRON_STRAP_SFAB | \ | 43 | - } else { |
31 | + NPCM7XX_PWRON_STRAP_BSPA | \ | 44 | - /* If HCR_EL2.<E2H> == 0: check CNTHCTL_EL2.EL1PCEN. */ |
32 | + NPCM7XX_PWRON_STRAP_FUP(FUP_NORM_UART2) | \ | 45 | - if (has_el2 && timeridx == GTIMER_PHYS && |
33 | + NPCM7XX_PWRON_STRAP_SECEN | \ | 46 | - !extract32(env->cp15.cnthctl_el2, 1, 1)) { |
34 | + NPCM7XX_PWRON_STRAP_HIZ | \ | 47 | - return CP_ACCESS_TRAP_EL2; |
35 | + NPCM7XX_PWRON_STRAP_ECC | \ | 48 | - } |
36 | + NPCM7XX_PWRON_STRAP_RESERVE1 | \ | 49 | - } |
37 | + NPCM7XX_PWRON_STRAP_J2EN | \ | 50 | - break; |
38 | + NPCM7XX_PWRON_STRAP_CKFRQ(CKFRQ_DEFAULT)) | 51 | - |
39 | + | 52 | + /* fall through */ |
40 | +#define NPCM750_EVB_POWER_ON_STRAPS ( \ | 53 | case 1: |
41 | + NPCM7XX_POWER_ON_STRAPS_DEFAULT & ~NPCM7XX_PWRON_STRAP_J2EN) | 54 | /* Check CNTHCTL_EL2.EL1PCTEN, which changes location based on E2H. */ |
42 | +#define QUANTA_GSJ_POWER_ON_STRAPS NPCM7XX_POWER_ON_STRAPS_DEFAULT | 55 | if (has_el2 && timeridx == GTIMER_PHYS && |
43 | +#define QUANTA_GBS_POWER_ON_STRAPS ( \ | ||
44 | + NPCM7XX_POWER_ON_STRAPS_DEFAULT & ~NPCM7XX_PWRON_STRAP_SFAB) | ||
45 | +#define KUDO_BMC_POWER_ON_STRAPS NPCM7XX_POWER_ON_STRAPS_DEFAULT | ||
46 | +#define MORI_BMC_POWER_ON_STRAPS NPCM7XX_POWER_ON_STRAPS_DEFAULT | ||
47 | |||
48 | static const char npcm7xx_default_bootrom[] = "npcm7xx_bootrom.bin"; | ||
49 | |||
50 | -- | 56 | -- |
51 | 2.25.1 | 57 | 2.34.1 | diff view generated by jsdifflib |
1 | It's not possible to provide the guest with the Security extensions | 1 | From: Leif Lindholm <quic_llindhol@quicinc.com> |
---|---|---|---|
2 | (TrustZone) when using KVM or HVF, because the hardware | ||
3 | virtualization extensions don't permit running EL3 guest code. | ||
4 | However, we weren't checking for this combination, with the result | ||
5 | that QEMU would assert if you tried it: | ||
6 | 2 | ||
7 | $ qemu-system-aarch64 -enable-kvm -machine virt,secure=on -cpu host -display none | 3 | GIC Private Peripheral Interrupts (PPI) are defined as GIC INTID 16-31. |
8 | Unexpected error in object_property_find_err() at ../../qom/object.c:1304: | 4 | As in, PPI0 is INTID16 .. PPI15 is INTID31. |
9 | qemu-system-aarch64: Property 'host-arm-cpu.secure-memory' not found | 5 | Arm's Base System Architecture specification (BSA) lists the mandated and |
10 | Aborted | 6 | recommended private interrupt IDs by INTID, not by PPI index. But current |
7 | definitions in virt define them by PPI index, complicating cross | ||
8 | referencing. | ||
11 | 9 | ||
12 | Check for this combination of options and report an error, in the | 10 | Meanwhile, the PPI(x) macro counterintuitively adds 16 to the input value, |
13 | same way we already do for attempts to give a KVM or HVF guest the | 11 | converting a PPI index to an INTID. |
14 | Virtualization or MTE extensions. Now we will report: | ||
15 | 12 | ||
16 | qemu-system-aarch64: mach-virt: KVM does not support providing Security extensions (TrustZone) to the guest CPU | 13 | Resolve this by redefining the BSA-allocated PPIs by their INTIDs, |
14 | and replacing the PPI(x) macro with an INTID_TO_PPI(x) one where required. | ||
17 | 15 | ||
18 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/961 | 16 | Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com> |
17 | Message-id: 20230919090229.188092-2-quic_llindhol@quicinc.com | ||
18 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
21 | Message-id: 20220404155301.566542-1-peter.maydell@linaro.org | ||
22 | --- | 20 | --- |
23 | hw/arm/virt.c | 7 +++++++ | 21 | include/hw/arm/virt.h | 14 +++++++------- |
24 | 1 file changed, 7 insertions(+) | 22 | hw/arm/virt-acpi-build.c | 12 ++++++------ |
23 | hw/arm/virt.c | 24 ++++++++++++++---------- | ||
24 | 3 files changed, 27 insertions(+), 23 deletions(-) | ||
25 | 25 | ||
26 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/include/hw/arm/virt.h | ||
29 | +++ b/include/hw/arm/virt.h | ||
30 | @@ -XXX,XX +XXX,XX @@ | ||
31 | #define NUM_VIRTIO_TRANSPORTS 32 | ||
32 | #define NUM_SMMU_IRQS 4 | ||
33 | |||
34 | -#define ARCH_GIC_MAINT_IRQ 9 | ||
35 | +#define ARCH_GIC_MAINT_IRQ 25 | ||
36 | |||
37 | -#define ARCH_TIMER_VIRT_IRQ 11 | ||
38 | -#define ARCH_TIMER_S_EL1_IRQ 13 | ||
39 | -#define ARCH_TIMER_NS_EL1_IRQ 14 | ||
40 | -#define ARCH_TIMER_NS_EL2_IRQ 10 | ||
41 | +#define ARCH_TIMER_VIRT_IRQ 27 | ||
42 | +#define ARCH_TIMER_S_EL1_IRQ 29 | ||
43 | +#define ARCH_TIMER_NS_EL1_IRQ 30 | ||
44 | +#define ARCH_TIMER_NS_EL2_IRQ 26 | ||
45 | |||
46 | -#define VIRTUAL_PMU_IRQ 7 | ||
47 | +#define VIRTUAL_PMU_IRQ 23 | ||
48 | |||
49 | -#define PPI(irq) ((irq) + 16) | ||
50 | +#define INTID_TO_PPI(irq) ((irq) - 16) | ||
51 | |||
52 | /* See Linux kernel arch/arm64/include/asm/pvclock-abi.h */ | ||
53 | #define PVTIME_SIZE_PER_CPU 64 | ||
54 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/hw/arm/virt-acpi-build.c | ||
57 | +++ b/hw/arm/virt-acpi-build.c | ||
58 | @@ -XXX,XX +XXX,XX @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | ||
59 | * The interrupt values are the same with the device tree when adding 16 | ||
60 | */ | ||
61 | /* Secure EL1 timer GSIV */ | ||
62 | - build_append_int_noprefix(table_data, ARCH_TIMER_S_EL1_IRQ + 16, 4); | ||
63 | + build_append_int_noprefix(table_data, ARCH_TIMER_S_EL1_IRQ, 4); | ||
64 | /* Secure EL1 timer Flags */ | ||
65 | build_append_int_noprefix(table_data, irqflags, 4); | ||
66 | /* Non-Secure EL1 timer GSIV */ | ||
67 | - build_append_int_noprefix(table_data, ARCH_TIMER_NS_EL1_IRQ + 16, 4); | ||
68 | + build_append_int_noprefix(table_data, ARCH_TIMER_NS_EL1_IRQ, 4); | ||
69 | /* Non-Secure EL1 timer Flags */ | ||
70 | build_append_int_noprefix(table_data, irqflags | | ||
71 | 1UL << 2, /* Always-on Capability */ | ||
72 | 4); | ||
73 | /* Virtual timer GSIV */ | ||
74 | - build_append_int_noprefix(table_data, ARCH_TIMER_VIRT_IRQ + 16, 4); | ||
75 | + build_append_int_noprefix(table_data, ARCH_TIMER_VIRT_IRQ, 4); | ||
76 | /* Virtual Timer Flags */ | ||
77 | build_append_int_noprefix(table_data, irqflags, 4); | ||
78 | /* Non-Secure EL2 timer GSIV */ | ||
79 | - build_append_int_noprefix(table_data, ARCH_TIMER_NS_EL2_IRQ + 16, 4); | ||
80 | + build_append_int_noprefix(table_data, ARCH_TIMER_NS_EL2_IRQ, 4); | ||
81 | /* Non-Secure EL2 timer Flags */ | ||
82 | build_append_int_noprefix(table_data, irqflags, 4); | ||
83 | /* CntReadBase Physical address */ | ||
84 | @@ -XXX,XX +XXX,XX @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | ||
85 | for (i = 0; i < MACHINE(vms)->smp.cpus; i++) { | ||
86 | ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(i)); | ||
87 | uint64_t physical_base_address = 0, gich = 0, gicv = 0; | ||
88 | - uint32_t vgic_interrupt = vms->virt ? PPI(ARCH_GIC_MAINT_IRQ) : 0; | ||
89 | + uint32_t vgic_interrupt = vms->virt ? ARCH_GIC_MAINT_IRQ : 0; | ||
90 | uint32_t pmu_interrupt = arm_feature(&armcpu->env, ARM_FEATURE_PMU) ? | ||
91 | - PPI(VIRTUAL_PMU_IRQ) : 0; | ||
92 | + VIRTUAL_PMU_IRQ : 0; | ||
93 | |||
94 | if (vms->gic_version == VIRT_GIC_VERSION_2) { | ||
95 | physical_base_address = memmap[VIRT_GIC_CPU].base; | ||
26 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 96 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
27 | index XXXXXXX..XXXXXXX 100644 | 97 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/hw/arm/virt.c | 98 | --- a/hw/arm/virt.c |
29 | +++ b/hw/arm/virt.c | 99 | +++ b/hw/arm/virt.c |
30 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | 100 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_timer_nodes(const VirtMachineState *vms) |
31 | exit(1); | ||
32 | } | 101 | } |
33 | 102 | qemu_fdt_setprop(ms->fdt, "/timer", "always-on", NULL, 0); | |
34 | + if (vms->secure && (kvm_enabled() || hvf_enabled())) { | 103 | qemu_fdt_setprop_cells(ms->fdt, "/timer", "interrupts", |
35 | + error_report("mach-virt: %s does not support providing " | 104 | - GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_S_EL1_IRQ, irqflags, |
36 | + "Security extensions (TrustZone) to the guest CPU", | 105 | - GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_NS_EL1_IRQ, irqflags, |
37 | + kvm_enabled() ? "KVM" : "HVF"); | 106 | - GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_VIRT_IRQ, irqflags, |
38 | + exit(1); | 107 | - GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_NS_EL2_IRQ, irqflags); |
39 | + } | 108 | + GIC_FDT_IRQ_TYPE_PPI, |
40 | + | 109 | + INTID_TO_PPI(ARCH_TIMER_S_EL1_IRQ), irqflags, |
41 | if (vms->virt && (kvm_enabled() || hvf_enabled())) { | 110 | + GIC_FDT_IRQ_TYPE_PPI, |
42 | error_report("mach-virt: %s does not support providing " | 111 | + INTID_TO_PPI(ARCH_TIMER_NS_EL1_IRQ), irqflags, |
43 | "Virtualization extensions to the guest CPU", | 112 | + GIC_FDT_IRQ_TYPE_PPI, |
113 | + INTID_TO_PPI(ARCH_TIMER_VIRT_IRQ), irqflags, | ||
114 | + GIC_FDT_IRQ_TYPE_PPI, | ||
115 | + INTID_TO_PPI(ARCH_TIMER_NS_EL2_IRQ), irqflags); | ||
116 | } | ||
117 | |||
118 | static void fdt_add_cpu_nodes(const VirtMachineState *vms) | ||
119 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem) | ||
120 | */ | ||
121 | for (i = 0; i < smp_cpus; i++) { | ||
122 | DeviceState *cpudev = DEVICE(qemu_get_cpu(i)); | ||
123 | - int ppibase = NUM_IRQS + i * GIC_INTERNAL + GIC_NR_SGIS; | ||
124 | + int intidbase = NUM_IRQS + i * GIC_INTERNAL; | ||
125 | /* Mapping from the output timer irq lines from the CPU to the | ||
126 | * GIC PPI inputs we use for the virt board. | ||
127 | */ | ||
128 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem) | ||
129 | for (unsigned irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) { | ||
130 | qdev_connect_gpio_out(cpudev, irq, | ||
131 | qdev_get_gpio_in(vms->gic, | ||
132 | - ppibase + timer_irq[irq])); | ||
133 | + intidbase + timer_irq[irq])); | ||
134 | } | ||
135 | |||
136 | if (vms->gic_version != VIRT_GIC_VERSION_2) { | ||
137 | qemu_irq irq = qdev_get_gpio_in(vms->gic, | ||
138 | - ppibase + ARCH_GIC_MAINT_IRQ); | ||
139 | + intidbase + ARCH_GIC_MAINT_IRQ); | ||
140 | qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interrupt", | ||
141 | 0, irq); | ||
142 | } else if (vms->virt) { | ||
143 | qemu_irq irq = qdev_get_gpio_in(vms->gic, | ||
144 | - ppibase + ARCH_GIC_MAINT_IRQ); | ||
145 | + intidbase + ARCH_GIC_MAINT_IRQ); | ||
146 | sysbus_connect_irq(gicbusdev, i + 4 * smp_cpus, irq); | ||
147 | } | ||
148 | |||
149 | qdev_connect_gpio_out_named(cpudev, "pmu-interrupt", 0, | ||
150 | - qdev_get_gpio_in(vms->gic, ppibase | ||
151 | + qdev_get_gpio_in(vms->gic, intidbase | ||
152 | + VIRTUAL_PMU_IRQ)); | ||
153 | |||
154 | sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ)); | ||
155 | @@ -XXX,XX +XXX,XX @@ static void virt_cpu_post_init(VirtMachineState *vms, MemoryRegion *sysmem) | ||
156 | if (pmu) { | ||
157 | assert(arm_feature(&ARM_CPU(cpu)->env, ARM_FEATURE_PMU)); | ||
158 | if (kvm_irqchip_in_kernel()) { | ||
159 | - kvm_arm_pmu_set_irq(cpu, PPI(VIRTUAL_PMU_IRQ)); | ||
160 | + kvm_arm_pmu_set_irq(cpu, VIRTUAL_PMU_IRQ); | ||
161 | } | ||
162 | kvm_arm_pmu_init(cpu); | ||
163 | } | ||
44 | -- | 164 | -- |
45 | 2.25.1 | 165 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> | ||
2 | 1 | ||
3 | Break out header file to allow embedding of the the TTC. | ||
4 | |||
5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> | ||
6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
7 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
8 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | ||
9 | Message-id: 20220331222017.2914409-2-edgar.iglesias@gmail.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | include/hw/timer/cadence_ttc.h | 54 ++++++++++++++++++++++++++++++++++ | ||
13 | hw/timer/cadence_ttc.c | 32 ++------------------ | ||
14 | 2 files changed, 56 insertions(+), 30 deletions(-) | ||
15 | create mode 100644 include/hw/timer/cadence_ttc.h | ||
16 | |||
17 | diff --git a/include/hw/timer/cadence_ttc.h b/include/hw/timer/cadence_ttc.h | ||
18 | new file mode 100644 | ||
19 | index XXXXXXX..XXXXXXX | ||
20 | --- /dev/null | ||
21 | +++ b/include/hw/timer/cadence_ttc.h | ||
22 | @@ -XXX,XX +XXX,XX @@ | ||
23 | +/* | ||
24 | + * Xilinx Zynq cadence TTC model | ||
25 | + * | ||
26 | + * Copyright (c) 2011 Xilinx Inc. | ||
27 | + * Copyright (c) 2012 Peter A.G. Crosthwaite (peter.crosthwaite@petalogix.com) | ||
28 | + * Copyright (c) 2012 PetaLogix Pty Ltd. | ||
29 | + * Written By Haibing Ma | ||
30 | + * M. Habib | ||
31 | + * | ||
32 | + * This program is free software; you can redistribute it and/or | ||
33 | + * modify it under the terms of the GNU General Public License | ||
34 | + * as published by the Free Software Foundation; either version | ||
35 | + * 2 of the License, or (at your option) any later version. | ||
36 | + * | ||
37 | + * You should have received a copy of the GNU General Public License along | ||
38 | + * with this program; if not, see <http://www.gnu.org/licenses/>. | ||
39 | + */ | ||
40 | +#ifndef HW_TIMER_CADENCE_TTC_H | ||
41 | +#define HW_TIMER_CADENCE_TTC_H | ||
42 | + | ||
43 | +#include "hw/sysbus.h" | ||
44 | +#include "qemu/timer.h" | ||
45 | + | ||
46 | +typedef struct { | ||
47 | + QEMUTimer *timer; | ||
48 | + int freq; | ||
49 | + | ||
50 | + uint32_t reg_clock; | ||
51 | + uint32_t reg_count; | ||
52 | + uint32_t reg_value; | ||
53 | + uint16_t reg_interval; | ||
54 | + uint16_t reg_match[3]; | ||
55 | + uint32_t reg_intr; | ||
56 | + uint32_t reg_intr_en; | ||
57 | + uint32_t reg_event_ctrl; | ||
58 | + uint32_t reg_event; | ||
59 | + | ||
60 | + uint64_t cpu_time; | ||
61 | + unsigned int cpu_time_valid; | ||
62 | + | ||
63 | + qemu_irq irq; | ||
64 | +} CadenceTimerState; | ||
65 | + | ||
66 | +#define TYPE_CADENCE_TTC "cadence_ttc" | ||
67 | +OBJECT_DECLARE_SIMPLE_TYPE(CadenceTTCState, CADENCE_TTC) | ||
68 | + | ||
69 | +struct CadenceTTCState { | ||
70 | + SysBusDevice parent_obj; | ||
71 | + | ||
72 | + MemoryRegion iomem; | ||
73 | + CadenceTimerState timer[3]; | ||
74 | +}; | ||
75 | + | ||
76 | +#endif | ||
77 | diff --git a/hw/timer/cadence_ttc.c b/hw/timer/cadence_ttc.c | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | --- a/hw/timer/cadence_ttc.c | ||
80 | +++ b/hw/timer/cadence_ttc.c | ||
81 | @@ -XXX,XX +XXX,XX @@ | ||
82 | #include "qemu/timer.h" | ||
83 | #include "qom/object.h" | ||
84 | |||
85 | +#include "hw/timer/cadence_ttc.h" | ||
86 | + | ||
87 | #ifdef CADENCE_TTC_ERR_DEBUG | ||
88 | #define DB_PRINT(...) do { \ | ||
89 | fprintf(stderr, ": %s: ", __func__); \ | ||
90 | @@ -XXX,XX +XXX,XX @@ | ||
91 | #define CLOCK_CTRL_PS_EN 0x00000001 | ||
92 | #define CLOCK_CTRL_PS_V 0x0000001e | ||
93 | |||
94 | -typedef struct { | ||
95 | - QEMUTimer *timer; | ||
96 | - int freq; | ||
97 | - | ||
98 | - uint32_t reg_clock; | ||
99 | - uint32_t reg_count; | ||
100 | - uint32_t reg_value; | ||
101 | - uint16_t reg_interval; | ||
102 | - uint16_t reg_match[3]; | ||
103 | - uint32_t reg_intr; | ||
104 | - uint32_t reg_intr_en; | ||
105 | - uint32_t reg_event_ctrl; | ||
106 | - uint32_t reg_event; | ||
107 | - | ||
108 | - uint64_t cpu_time; | ||
109 | - unsigned int cpu_time_valid; | ||
110 | - | ||
111 | - qemu_irq irq; | ||
112 | -} CadenceTimerState; | ||
113 | - | ||
114 | -#define TYPE_CADENCE_TTC "cadence_ttc" | ||
115 | -OBJECT_DECLARE_SIMPLE_TYPE(CadenceTTCState, CADENCE_TTC) | ||
116 | - | ||
117 | -struct CadenceTTCState { | ||
118 | - SysBusDevice parent_obj; | ||
119 | - | ||
120 | - MemoryRegion iomem; | ||
121 | - CadenceTimerState timer[3]; | ||
122 | -}; | ||
123 | - | ||
124 | static void cadence_timer_update(CadenceTimerState *s) | ||
125 | { | ||
126 | qemu_set_irq(s->irq, !!(s->reg_intr & s->reg_intr_en)); | ||
127 | -- | ||
128 | 2.25.1 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> | 1 | From: Leif Lindholm <quic_llindhol@quicinc.com> |
---|---|---|---|
2 | 2 | ||
3 | Add a model of the Xilinx Versal CRL. | 3 | virt.h defines a number of IRQs that are ultimately described by Arm's |
4 | Base System Architecture specification. Move these to a dedicated header | ||
5 | so that they can be reused by other platforms that do the same. | ||
6 | Include that header from virt.h to minimise churn. | ||
4 | 7 | ||
5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> | 8 | While we're moving the definitions, sort them into numerical order, |
6 | Reviewed-by: Frederic Konrad <fkonrad@amd.com> | 9 | and add the ARCH_TIMER_NS_EL2_VIRT_IRQ definition used by sbsa-ref |
7 | Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com> | 10 | and which will eventually be needed by virt also. |
8 | Message-id: 20220406174303.2022038-4-edgar.iglesias@xilinx.com | 11 | |
12 | Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com> | ||
13 | Message-id: 20230919090229.188092-3-quic_llindhol@quicinc.com | ||
14 | [PMM: Remove unused PPI_TO_INTID macro; sort numerically; | ||
15 | add ARCH_TIMER_NS_EL2_VIRT_IRQ] | ||
16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 18 | --- |
11 | include/hw/misc/xlnx-versal-crl.h | 235 +++++++++++++++++ | 19 | include/hw/arm/bsa.h | 35 +++++++++++++++++++++++++++++++++++ |
12 | hw/misc/xlnx-versal-crl.c | 421 ++++++++++++++++++++++++++++++ | 20 | include/hw/arm/virt.h | 12 +----------- |
13 | hw/misc/meson.build | 1 + | 21 | 2 files changed, 36 insertions(+), 11 deletions(-) |
14 | 3 files changed, 657 insertions(+) | 22 | create mode 100644 include/hw/arm/bsa.h |
15 | create mode 100644 include/hw/misc/xlnx-versal-crl.h | ||
16 | create mode 100644 hw/misc/xlnx-versal-crl.c | ||
17 | 23 | ||
18 | diff --git a/include/hw/misc/xlnx-versal-crl.h b/include/hw/misc/xlnx-versal-crl.h | 24 | diff --git a/include/hw/arm/bsa.h b/include/hw/arm/bsa.h |
19 | new file mode 100644 | 25 | new file mode 100644 |
20 | index XXXXXXX..XXXXXXX | 26 | index XXXXXXX..XXXXXXX |
21 | --- /dev/null | 27 | --- /dev/null |
22 | +++ b/include/hw/misc/xlnx-versal-crl.h | 28 | +++ b/include/hw/arm/bsa.h |
23 | @@ -XXX,XX +XXX,XX @@ | 29 | @@ -XXX,XX +XXX,XX @@ |
24 | +/* | 30 | +/* |
25 | + * QEMU model of the Clock-Reset-LPD (CRL). | 31 | + * Common definitions for Arm Base System Architecture (BSA) platforms. |
26 | + * | 32 | + * |
27 | + * Copyright (c) 2022 Xilinx Inc. | 33 | + * Copyright (c) 2015 Linaro Limited |
28 | + * SPDX-License-Identifier: GPL-2.0-or-later | 34 | + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. |
29 | + * | 35 | + * |
30 | + * Written by Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 36 | + * This program is free software; you can redistribute it and/or modify it |
31 | + */ | 37 | + * under the terms and conditions of the GNU General Public License, |
32 | +#ifndef HW_MISC_XLNX_VERSAL_CRL_H | 38 | + * version 2 or later, as published by the Free Software Foundation. |
33 | +#define HW_MISC_XLNX_VERSAL_CRL_H | ||
34 | + | ||
35 | +#include "hw/sysbus.h" | ||
36 | +#include "hw/register.h" | ||
37 | +#include "target/arm/cpu.h" | ||
38 | + | ||
39 | +#define TYPE_XLNX_VERSAL_CRL "xlnx,versal-crl" | ||
40 | +OBJECT_DECLARE_SIMPLE_TYPE(XlnxVersalCRL, XLNX_VERSAL_CRL) | ||
41 | + | ||
42 | +REG32(ERR_CTRL, 0x0) | ||
43 | + FIELD(ERR_CTRL, SLVERR_ENABLE, 0, 1) | ||
44 | +REG32(IR_STATUS, 0x4) | ||
45 | + FIELD(IR_STATUS, ADDR_DECODE_ERR, 0, 1) | ||
46 | +REG32(IR_MASK, 0x8) | ||
47 | + FIELD(IR_MASK, ADDR_DECODE_ERR, 0, 1) | ||
48 | +REG32(IR_ENABLE, 0xc) | ||
49 | + FIELD(IR_ENABLE, ADDR_DECODE_ERR, 0, 1) | ||
50 | +REG32(IR_DISABLE, 0x10) | ||
51 | + FIELD(IR_DISABLE, ADDR_DECODE_ERR, 0, 1) | ||
52 | +REG32(WPROT, 0x1c) | ||
53 | + FIELD(WPROT, ACTIVE, 0, 1) | ||
54 | +REG32(PLL_CLK_OTHER_DMN, 0x20) | ||
55 | + FIELD(PLL_CLK_OTHER_DMN, APLL_BYPASS, 0, 1) | ||
56 | +REG32(RPLL_CTRL, 0x40) | ||
57 | + FIELD(RPLL_CTRL, POST_SRC, 24, 3) | ||
58 | + FIELD(RPLL_CTRL, PRE_SRC, 20, 3) | ||
59 | + FIELD(RPLL_CTRL, CLKOUTDIV, 16, 2) | ||
60 | + FIELD(RPLL_CTRL, FBDIV, 8, 8) | ||
61 | + FIELD(RPLL_CTRL, BYPASS, 3, 1) | ||
62 | + FIELD(RPLL_CTRL, RESET, 0, 1) | ||
63 | +REG32(RPLL_CFG, 0x44) | ||
64 | + FIELD(RPLL_CFG, LOCK_DLY, 25, 7) | ||
65 | + FIELD(RPLL_CFG, LOCK_CNT, 13, 10) | ||
66 | + FIELD(RPLL_CFG, LFHF, 10, 2) | ||
67 | + FIELD(RPLL_CFG, CP, 5, 4) | ||
68 | + FIELD(RPLL_CFG, RES, 0, 4) | ||
69 | +REG32(RPLL_FRAC_CFG, 0x48) | ||
70 | + FIELD(RPLL_FRAC_CFG, ENABLED, 31, 1) | ||
71 | + FIELD(RPLL_FRAC_CFG, SEED, 22, 3) | ||
72 | + FIELD(RPLL_FRAC_CFG, ALGRTHM, 19, 1) | ||
73 | + FIELD(RPLL_FRAC_CFG, ORDER, 18, 1) | ||
74 | + FIELD(RPLL_FRAC_CFG, DATA, 0, 16) | ||
75 | +REG32(PLL_STATUS, 0x50) | ||
76 | + FIELD(PLL_STATUS, RPLL_STABLE, 2, 1) | ||
77 | + FIELD(PLL_STATUS, RPLL_LOCK, 0, 1) | ||
78 | +REG32(RPLL_TO_XPD_CTRL, 0x100) | ||
79 | + FIELD(RPLL_TO_XPD_CTRL, CLKACT, 25, 1) | ||
80 | + FIELD(RPLL_TO_XPD_CTRL, DIVISOR0, 8, 10) | ||
81 | +REG32(LPD_TOP_SWITCH_CTRL, 0x104) | ||
82 | + FIELD(LPD_TOP_SWITCH_CTRL, CLKACT_ADMA, 26, 1) | ||
83 | + FIELD(LPD_TOP_SWITCH_CTRL, CLKACT, 25, 1) | ||
84 | + FIELD(LPD_TOP_SWITCH_CTRL, DIVISOR0, 8, 10) | ||
85 | + FIELD(LPD_TOP_SWITCH_CTRL, SRCSEL, 0, 3) | ||
86 | +REG32(LPD_LSBUS_CTRL, 0x108) | ||
87 | + FIELD(LPD_LSBUS_CTRL, CLKACT, 25, 1) | ||
88 | + FIELD(LPD_LSBUS_CTRL, DIVISOR0, 8, 10) | ||
89 | + FIELD(LPD_LSBUS_CTRL, SRCSEL, 0, 3) | ||
90 | +REG32(CPU_R5_CTRL, 0x10c) | ||
91 | + FIELD(CPU_R5_CTRL, CLKACT_OCM2, 28, 1) | ||
92 | + FIELD(CPU_R5_CTRL, CLKACT_OCM, 27, 1) | ||
93 | + FIELD(CPU_R5_CTRL, CLKACT_CORE, 26, 1) | ||
94 | + FIELD(CPU_R5_CTRL, CLKACT, 25, 1) | ||
95 | + FIELD(CPU_R5_CTRL, DIVISOR0, 8, 10) | ||
96 | + FIELD(CPU_R5_CTRL, SRCSEL, 0, 3) | ||
97 | +REG32(IOU_SWITCH_CTRL, 0x114) | ||
98 | + FIELD(IOU_SWITCH_CTRL, CLKACT, 25, 1) | ||
99 | + FIELD(IOU_SWITCH_CTRL, DIVISOR0, 8, 10) | ||
100 | + FIELD(IOU_SWITCH_CTRL, SRCSEL, 0, 3) | ||
101 | +REG32(GEM0_REF_CTRL, 0x118) | ||
102 | + FIELD(GEM0_REF_CTRL, CLKACT_RX, 27, 1) | ||
103 | + FIELD(GEM0_REF_CTRL, CLKACT_TX, 26, 1) | ||
104 | + FIELD(GEM0_REF_CTRL, CLKACT, 25, 1) | ||
105 | + FIELD(GEM0_REF_CTRL, DIVISOR0, 8, 10) | ||
106 | + FIELD(GEM0_REF_CTRL, SRCSEL, 0, 3) | ||
107 | +REG32(GEM1_REF_CTRL, 0x11c) | ||
108 | + FIELD(GEM1_REF_CTRL, CLKACT_RX, 27, 1) | ||
109 | + FIELD(GEM1_REF_CTRL, CLKACT_TX, 26, 1) | ||
110 | + FIELD(GEM1_REF_CTRL, CLKACT, 25, 1) | ||
111 | + FIELD(GEM1_REF_CTRL, DIVISOR0, 8, 10) | ||
112 | + FIELD(GEM1_REF_CTRL, SRCSEL, 0, 3) | ||
113 | +REG32(GEM_TSU_REF_CTRL, 0x120) | ||
114 | + FIELD(GEM_TSU_REF_CTRL, CLKACT, 25, 1) | ||
115 | + FIELD(GEM_TSU_REF_CTRL, DIVISOR0, 8, 10) | ||
116 | + FIELD(GEM_TSU_REF_CTRL, SRCSEL, 0, 3) | ||
117 | +REG32(USB0_BUS_REF_CTRL, 0x124) | ||
118 | + FIELD(USB0_BUS_REF_CTRL, CLKACT, 25, 1) | ||
119 | + FIELD(USB0_BUS_REF_CTRL, DIVISOR0, 8, 10) | ||
120 | + FIELD(USB0_BUS_REF_CTRL, SRCSEL, 0, 3) | ||
121 | +REG32(UART0_REF_CTRL, 0x128) | ||
122 | + FIELD(UART0_REF_CTRL, CLKACT, 25, 1) | ||
123 | + FIELD(UART0_REF_CTRL, DIVISOR0, 8, 10) | ||
124 | + FIELD(UART0_REF_CTRL, SRCSEL, 0, 3) | ||
125 | +REG32(UART1_REF_CTRL, 0x12c) | ||
126 | + FIELD(UART1_REF_CTRL, CLKACT, 25, 1) | ||
127 | + FIELD(UART1_REF_CTRL, DIVISOR0, 8, 10) | ||
128 | + FIELD(UART1_REF_CTRL, SRCSEL, 0, 3) | ||
129 | +REG32(SPI0_REF_CTRL, 0x130) | ||
130 | + FIELD(SPI0_REF_CTRL, CLKACT, 25, 1) | ||
131 | + FIELD(SPI0_REF_CTRL, DIVISOR0, 8, 10) | ||
132 | + FIELD(SPI0_REF_CTRL, SRCSEL, 0, 3) | ||
133 | +REG32(SPI1_REF_CTRL, 0x134) | ||
134 | + FIELD(SPI1_REF_CTRL, CLKACT, 25, 1) | ||
135 | + FIELD(SPI1_REF_CTRL, DIVISOR0, 8, 10) | ||
136 | + FIELD(SPI1_REF_CTRL, SRCSEL, 0, 3) | ||
137 | +REG32(CAN0_REF_CTRL, 0x138) | ||
138 | + FIELD(CAN0_REF_CTRL, CLKACT, 25, 1) | ||
139 | + FIELD(CAN0_REF_CTRL, DIVISOR0, 8, 10) | ||
140 | + FIELD(CAN0_REF_CTRL, SRCSEL, 0, 3) | ||
141 | +REG32(CAN1_REF_CTRL, 0x13c) | ||
142 | + FIELD(CAN1_REF_CTRL, CLKACT, 25, 1) | ||
143 | + FIELD(CAN1_REF_CTRL, DIVISOR0, 8, 10) | ||
144 | + FIELD(CAN1_REF_CTRL, SRCSEL, 0, 3) | ||
145 | +REG32(I2C0_REF_CTRL, 0x140) | ||
146 | + FIELD(I2C0_REF_CTRL, CLKACT, 25, 1) | ||
147 | + FIELD(I2C0_REF_CTRL, DIVISOR0, 8, 10) | ||
148 | + FIELD(I2C0_REF_CTRL, SRCSEL, 0, 3) | ||
149 | +REG32(I2C1_REF_CTRL, 0x144) | ||
150 | + FIELD(I2C1_REF_CTRL, CLKACT, 25, 1) | ||
151 | + FIELD(I2C1_REF_CTRL, DIVISOR0, 8, 10) | ||
152 | + FIELD(I2C1_REF_CTRL, SRCSEL, 0, 3) | ||
153 | +REG32(DBG_LPD_CTRL, 0x148) | ||
154 | + FIELD(DBG_LPD_CTRL, CLKACT, 25, 1) | ||
155 | + FIELD(DBG_LPD_CTRL, DIVISOR0, 8, 10) | ||
156 | + FIELD(DBG_LPD_CTRL, SRCSEL, 0, 3) | ||
157 | +REG32(TIMESTAMP_REF_CTRL, 0x14c) | ||
158 | + FIELD(TIMESTAMP_REF_CTRL, CLKACT, 25, 1) | ||
159 | + FIELD(TIMESTAMP_REF_CTRL, DIVISOR0, 8, 10) | ||
160 | + FIELD(TIMESTAMP_REF_CTRL, SRCSEL, 0, 3) | ||
161 | +REG32(CRL_SAFETY_CHK, 0x150) | ||
162 | +REG32(PSM_REF_CTRL, 0x154) | ||
163 | + FIELD(PSM_REF_CTRL, DIVISOR0, 8, 10) | ||
164 | + FIELD(PSM_REF_CTRL, SRCSEL, 0, 3) | ||
165 | +REG32(DBG_TSTMP_CTRL, 0x158) | ||
166 | + FIELD(DBG_TSTMP_CTRL, CLKACT, 25, 1) | ||
167 | + FIELD(DBG_TSTMP_CTRL, DIVISOR0, 8, 10) | ||
168 | + FIELD(DBG_TSTMP_CTRL, SRCSEL, 0, 3) | ||
169 | +REG32(CPM_TOPSW_REF_CTRL, 0x15c) | ||
170 | + FIELD(CPM_TOPSW_REF_CTRL, CLKACT, 25, 1) | ||
171 | + FIELD(CPM_TOPSW_REF_CTRL, DIVISOR0, 8, 10) | ||
172 | + FIELD(CPM_TOPSW_REF_CTRL, SRCSEL, 0, 3) | ||
173 | +REG32(USB3_DUAL_REF_CTRL, 0x160) | ||
174 | + FIELD(USB3_DUAL_REF_CTRL, CLKACT, 25, 1) | ||
175 | + FIELD(USB3_DUAL_REF_CTRL, DIVISOR0, 8, 10) | ||
176 | + FIELD(USB3_DUAL_REF_CTRL, SRCSEL, 0, 3) | ||
177 | +REG32(RST_CPU_R5, 0x300) | ||
178 | + FIELD(RST_CPU_R5, RESET_PGE, 4, 1) | ||
179 | + FIELD(RST_CPU_R5, RESET_AMBA, 2, 1) | ||
180 | + FIELD(RST_CPU_R5, RESET_CPU1, 1, 1) | ||
181 | + FIELD(RST_CPU_R5, RESET_CPU0, 0, 1) | ||
182 | +REG32(RST_ADMA, 0x304) | ||
183 | + FIELD(RST_ADMA, RESET, 0, 1) | ||
184 | +REG32(RST_GEM0, 0x308) | ||
185 | + FIELD(RST_GEM0, RESET, 0, 1) | ||
186 | +REG32(RST_GEM1, 0x30c) | ||
187 | + FIELD(RST_GEM1, RESET, 0, 1) | ||
188 | +REG32(RST_SPARE, 0x310) | ||
189 | + FIELD(RST_SPARE, RESET, 0, 1) | ||
190 | +REG32(RST_USB0, 0x314) | ||
191 | + FIELD(RST_USB0, RESET, 0, 1) | ||
192 | +REG32(RST_UART0, 0x318) | ||
193 | + FIELD(RST_UART0, RESET, 0, 1) | ||
194 | +REG32(RST_UART1, 0x31c) | ||
195 | + FIELD(RST_UART1, RESET, 0, 1) | ||
196 | +REG32(RST_SPI0, 0x320) | ||
197 | + FIELD(RST_SPI0, RESET, 0, 1) | ||
198 | +REG32(RST_SPI1, 0x324) | ||
199 | + FIELD(RST_SPI1, RESET, 0, 1) | ||
200 | +REG32(RST_CAN0, 0x328) | ||
201 | + FIELD(RST_CAN0, RESET, 0, 1) | ||
202 | +REG32(RST_CAN1, 0x32c) | ||
203 | + FIELD(RST_CAN1, RESET, 0, 1) | ||
204 | +REG32(RST_I2C0, 0x330) | ||
205 | + FIELD(RST_I2C0, RESET, 0, 1) | ||
206 | +REG32(RST_I2C1, 0x334) | ||
207 | + FIELD(RST_I2C1, RESET, 0, 1) | ||
208 | +REG32(RST_DBG_LPD, 0x338) | ||
209 | + FIELD(RST_DBG_LPD, RPU_DBG1_RESET, 5, 1) | ||
210 | + FIELD(RST_DBG_LPD, RPU_DBG0_RESET, 4, 1) | ||
211 | + FIELD(RST_DBG_LPD, RESET_HSDP, 1, 1) | ||
212 | + FIELD(RST_DBG_LPD, RESET, 0, 1) | ||
213 | +REG32(RST_GPIO, 0x33c) | ||
214 | + FIELD(RST_GPIO, RESET, 0, 1) | ||
215 | +REG32(RST_TTC, 0x344) | ||
216 | + FIELD(RST_TTC, TTC3_RESET, 3, 1) | ||
217 | + FIELD(RST_TTC, TTC2_RESET, 2, 1) | ||
218 | + FIELD(RST_TTC, TTC1_RESET, 1, 1) | ||
219 | + FIELD(RST_TTC, TTC0_RESET, 0, 1) | ||
220 | +REG32(RST_TIMESTAMP, 0x348) | ||
221 | + FIELD(RST_TIMESTAMP, RESET, 0, 1) | ||
222 | +REG32(RST_SWDT, 0x34c) | ||
223 | + FIELD(RST_SWDT, RESET, 0, 1) | ||
224 | +REG32(RST_OCM, 0x350) | ||
225 | + FIELD(RST_OCM, RESET, 0, 1) | ||
226 | +REG32(RST_IPI, 0x354) | ||
227 | + FIELD(RST_IPI, RESET, 0, 1) | ||
228 | +REG32(RST_SYSMON, 0x358) | ||
229 | + FIELD(RST_SYSMON, SEQ_RST, 1, 1) | ||
230 | + FIELD(RST_SYSMON, CFG_RST, 0, 1) | ||
231 | +REG32(RST_FPD, 0x360) | ||
232 | + FIELD(RST_FPD, SRST, 1, 1) | ||
233 | + FIELD(RST_FPD, POR, 0, 1) | ||
234 | +REG32(PSM_RST_MODE, 0x370) | ||
235 | + FIELD(PSM_RST_MODE, WAKEUP, 2, 1) | ||
236 | + FIELD(PSM_RST_MODE, RST_MODE, 0, 2) | ||
237 | + | ||
238 | +#define CRL_R_MAX (R_PSM_RST_MODE + 1) | ||
239 | + | ||
240 | +#define RPU_MAX_CPU 2 | ||
241 | + | ||
242 | +struct XlnxVersalCRL { | ||
243 | + SysBusDevice parent_obj; | ||
244 | + qemu_irq irq; | ||
245 | + | ||
246 | + struct { | ||
247 | + ARMCPU *cpu_r5[RPU_MAX_CPU]; | ||
248 | + DeviceState *adma[8]; | ||
249 | + DeviceState *uart[2]; | ||
250 | + DeviceState *gem[2]; | ||
251 | + DeviceState *usb; | ||
252 | + } cfg; | ||
253 | + | ||
254 | + RegisterInfoArray *reg_array; | ||
255 | + uint32_t regs[CRL_R_MAX]; | ||
256 | + RegisterInfo regs_info[CRL_R_MAX]; | ||
257 | +}; | ||
258 | +#endif | ||
259 | diff --git a/hw/misc/xlnx-versal-crl.c b/hw/misc/xlnx-versal-crl.c | ||
260 | new file mode 100644 | ||
261 | index XXXXXXX..XXXXXXX | ||
262 | --- /dev/null | ||
263 | +++ b/hw/misc/xlnx-versal-crl.c | ||
264 | @@ -XXX,XX +XXX,XX @@ | ||
265 | +/* | ||
266 | + * QEMU model of the Clock-Reset-LPD (CRL). | ||
267 | + * | 39 | + * |
268 | + * Copyright (c) 2022 Advanced Micro Devices, Inc. | 40 | + * This program is distributed in the hope it will be useful, but WITHOUT |
269 | + * SPDX-License-Identifier: GPL-2.0-or-later | 41 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
42 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
43 | + * more details. | ||
270 | + * | 44 | + * |
271 | + * Written by Edgar E. Iglesias <edgar.iglesias@amd.com> | 45 | + * You should have received a copy of the GNU General Public License along with |
46 | + * this program. If not, see <http://www.gnu.org/licenses/>. | ||
47 | + * | ||
272 | + */ | 48 | + */ |
273 | + | 49 | + |
274 | +#include "qemu/osdep.h" | 50 | +#ifndef QEMU_ARM_BSA_H |
275 | +#include "qapi/error.h" | 51 | +#define QEMU_ARM_BSA_H |
276 | +#include "qemu/log.h" | ||
277 | +#include "qemu/bitops.h" | ||
278 | +#include "migration/vmstate.h" | ||
279 | +#include "hw/qdev-properties.h" | ||
280 | +#include "hw/sysbus.h" | ||
281 | +#include "hw/irq.h" | ||
282 | +#include "hw/register.h" | ||
283 | +#include "hw/resettable.h" | ||
284 | + | 52 | + |
285 | +#include "target/arm/arm-powerctl.h" | 53 | +/* These are architectural INTID values */ |
286 | +#include "hw/misc/xlnx-versal-crl.h" | 54 | +#define VIRTUAL_PMU_IRQ 23 |
55 | +#define ARCH_GIC_MAINT_IRQ 25 | ||
56 | +#define ARCH_TIMER_NS_EL2_IRQ 26 | ||
57 | +#define ARCH_TIMER_VIRT_IRQ 27 | ||
58 | +#define ARCH_TIMER_NS_EL2_VIRT_IRQ 28 | ||
59 | +#define ARCH_TIMER_S_EL1_IRQ 29 | ||
60 | +#define ARCH_TIMER_NS_EL1_IRQ 30 | ||
287 | + | 61 | + |
288 | +#ifndef XLNX_VERSAL_CRL_ERR_DEBUG | 62 | +#define INTID_TO_PPI(irq) ((irq) - 16) |
289 | +#define XLNX_VERSAL_CRL_ERR_DEBUG 0 | ||
290 | +#endif | ||
291 | + | 63 | + |
292 | +static void crl_update_irq(XlnxVersalCRL *s) | 64 | +#endif /* QEMU_ARM_BSA_H */ |
293 | +{ | 65 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h |
294 | + bool pending = s->regs[R_IR_STATUS] & ~s->regs[R_IR_MASK]; | ||
295 | + qemu_set_irq(s->irq, pending); | ||
296 | +} | ||
297 | + | ||
298 | +static void crl_status_postw(RegisterInfo *reg, uint64_t val64) | ||
299 | +{ | ||
300 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | ||
301 | + crl_update_irq(s); | ||
302 | +} | ||
303 | + | ||
304 | +static uint64_t crl_enable_prew(RegisterInfo *reg, uint64_t val64) | ||
305 | +{ | ||
306 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | ||
307 | + uint32_t val = val64; | ||
308 | + | ||
309 | + s->regs[R_IR_MASK] &= ~val; | ||
310 | + crl_update_irq(s); | ||
311 | + return 0; | ||
312 | +} | ||
313 | + | ||
314 | +static uint64_t crl_disable_prew(RegisterInfo *reg, uint64_t val64) | ||
315 | +{ | ||
316 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | ||
317 | + uint32_t val = val64; | ||
318 | + | ||
319 | + s->regs[R_IR_MASK] |= val; | ||
320 | + crl_update_irq(s); | ||
321 | + return 0; | ||
322 | +} | ||
323 | + | ||
324 | +static void crl_reset_dev(XlnxVersalCRL *s, DeviceState *dev, | ||
325 | + bool rst_old, bool rst_new) | ||
326 | +{ | ||
327 | + device_cold_reset(dev); | ||
328 | +} | ||
329 | + | ||
330 | +static void crl_reset_cpu(XlnxVersalCRL *s, ARMCPU *armcpu, | ||
331 | + bool rst_old, bool rst_new) | ||
332 | +{ | ||
333 | + if (rst_new) { | ||
334 | + arm_set_cpu_off(armcpu->mp_affinity); | ||
335 | + } else { | ||
336 | + arm_set_cpu_on_and_reset(armcpu->mp_affinity); | ||
337 | + } | ||
338 | +} | ||
339 | + | ||
340 | +#define REGFIELD_RESET(type, s, reg, f, new_val, dev) { \ | ||
341 | + bool old_f = ARRAY_FIELD_EX32((s)->regs, reg, f); \ | ||
342 | + bool new_f = FIELD_EX32(new_val, reg, f); \ | ||
343 | + \ | ||
344 | + /* Detect edges. */ \ | ||
345 | + if (dev && old_f != new_f) { \ | ||
346 | + crl_reset_ ## type(s, dev, old_f, new_f); \ | ||
347 | + } \ | ||
348 | +} | ||
349 | + | ||
350 | +static uint64_t crl_rst_r5_prew(RegisterInfo *reg, uint64_t val64) | ||
351 | +{ | ||
352 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | ||
353 | + | ||
354 | + REGFIELD_RESET(cpu, s, RST_CPU_R5, RESET_CPU0, val64, s->cfg.cpu_r5[0]); | ||
355 | + REGFIELD_RESET(cpu, s, RST_CPU_R5, RESET_CPU1, val64, s->cfg.cpu_r5[1]); | ||
356 | + return val64; | ||
357 | +} | ||
358 | + | ||
359 | +static uint64_t crl_rst_adma_prew(RegisterInfo *reg, uint64_t val64) | ||
360 | +{ | ||
361 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | ||
362 | + int i; | ||
363 | + | ||
364 | + /* A single register fans out to all ADMA reset inputs. */ | ||
365 | + for (i = 0; i < ARRAY_SIZE(s->cfg.adma); i++) { | ||
366 | + REGFIELD_RESET(dev, s, RST_ADMA, RESET, val64, s->cfg.adma[i]); | ||
367 | + } | ||
368 | + return val64; | ||
369 | +} | ||
370 | + | ||
371 | +static uint64_t crl_rst_uart0_prew(RegisterInfo *reg, uint64_t val64) | ||
372 | +{ | ||
373 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | ||
374 | + | ||
375 | + REGFIELD_RESET(dev, s, RST_UART0, RESET, val64, s->cfg.uart[0]); | ||
376 | + return val64; | ||
377 | +} | ||
378 | + | ||
379 | +static uint64_t crl_rst_uart1_prew(RegisterInfo *reg, uint64_t val64) | ||
380 | +{ | ||
381 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | ||
382 | + | ||
383 | + REGFIELD_RESET(dev, s, RST_UART1, RESET, val64, s->cfg.uart[1]); | ||
384 | + return val64; | ||
385 | +} | ||
386 | + | ||
387 | +static uint64_t crl_rst_gem0_prew(RegisterInfo *reg, uint64_t val64) | ||
388 | +{ | ||
389 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | ||
390 | + | ||
391 | + REGFIELD_RESET(dev, s, RST_GEM0, RESET, val64, s->cfg.gem[0]); | ||
392 | + return val64; | ||
393 | +} | ||
394 | + | ||
395 | +static uint64_t crl_rst_gem1_prew(RegisterInfo *reg, uint64_t val64) | ||
396 | +{ | ||
397 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | ||
398 | + | ||
399 | + REGFIELD_RESET(dev, s, RST_GEM1, RESET, val64, s->cfg.gem[1]); | ||
400 | + return val64; | ||
401 | +} | ||
402 | + | ||
403 | +static uint64_t crl_rst_usb_prew(RegisterInfo *reg, uint64_t val64) | ||
404 | +{ | ||
405 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | ||
406 | + | ||
407 | + REGFIELD_RESET(dev, s, RST_USB0, RESET, val64, s->cfg.usb); | ||
408 | + return val64; | ||
409 | +} | ||
410 | + | ||
411 | +static const RegisterAccessInfo crl_regs_info[] = { | ||
412 | + { .name = "ERR_CTRL", .addr = A_ERR_CTRL, | ||
413 | + },{ .name = "IR_STATUS", .addr = A_IR_STATUS, | ||
414 | + .w1c = 0x1, | ||
415 | + .post_write = crl_status_postw, | ||
416 | + },{ .name = "IR_MASK", .addr = A_IR_MASK, | ||
417 | + .reset = 0x1, | ||
418 | + .ro = 0x1, | ||
419 | + },{ .name = "IR_ENABLE", .addr = A_IR_ENABLE, | ||
420 | + .pre_write = crl_enable_prew, | ||
421 | + },{ .name = "IR_DISABLE", .addr = A_IR_DISABLE, | ||
422 | + .pre_write = crl_disable_prew, | ||
423 | + },{ .name = "WPROT", .addr = A_WPROT, | ||
424 | + },{ .name = "PLL_CLK_OTHER_DMN", .addr = A_PLL_CLK_OTHER_DMN, | ||
425 | + .reset = 0x1, | ||
426 | + .rsvd = 0xe, | ||
427 | + },{ .name = "RPLL_CTRL", .addr = A_RPLL_CTRL, | ||
428 | + .reset = 0x24809, | ||
429 | + .rsvd = 0xf88c00f6, | ||
430 | + },{ .name = "RPLL_CFG", .addr = A_RPLL_CFG, | ||
431 | + .reset = 0x2000000, | ||
432 | + .rsvd = 0x1801210, | ||
433 | + },{ .name = "RPLL_FRAC_CFG", .addr = A_RPLL_FRAC_CFG, | ||
434 | + .rsvd = 0x7e330000, | ||
435 | + },{ .name = "PLL_STATUS", .addr = A_PLL_STATUS, | ||
436 | + .reset = R_PLL_STATUS_RPLL_STABLE_MASK | | ||
437 | + R_PLL_STATUS_RPLL_LOCK_MASK, | ||
438 | + .rsvd = 0xfa, | ||
439 | + .ro = 0x5, | ||
440 | + },{ .name = "RPLL_TO_XPD_CTRL", .addr = A_RPLL_TO_XPD_CTRL, | ||
441 | + .reset = 0x2000100, | ||
442 | + .rsvd = 0xfdfc00ff, | ||
443 | + },{ .name = "LPD_TOP_SWITCH_CTRL", .addr = A_LPD_TOP_SWITCH_CTRL, | ||
444 | + .reset = 0x6000300, | ||
445 | + .rsvd = 0xf9fc00f8, | ||
446 | + },{ .name = "LPD_LSBUS_CTRL", .addr = A_LPD_LSBUS_CTRL, | ||
447 | + .reset = 0x2000800, | ||
448 | + .rsvd = 0xfdfc00f8, | ||
449 | + },{ .name = "CPU_R5_CTRL", .addr = A_CPU_R5_CTRL, | ||
450 | + .reset = 0xe000300, | ||
451 | + .rsvd = 0xe1fc00f8, | ||
452 | + },{ .name = "IOU_SWITCH_CTRL", .addr = A_IOU_SWITCH_CTRL, | ||
453 | + .reset = 0x2000500, | ||
454 | + .rsvd = 0xfdfc00f8, | ||
455 | + },{ .name = "GEM0_REF_CTRL", .addr = A_GEM0_REF_CTRL, | ||
456 | + .reset = 0xe000a00, | ||
457 | + .rsvd = 0xf1fc00f8, | ||
458 | + },{ .name = "GEM1_REF_CTRL", .addr = A_GEM1_REF_CTRL, | ||
459 | + .reset = 0xe000a00, | ||
460 | + .rsvd = 0xf1fc00f8, | ||
461 | + },{ .name = "GEM_TSU_REF_CTRL", .addr = A_GEM_TSU_REF_CTRL, | ||
462 | + .reset = 0x300, | ||
463 | + .rsvd = 0xfdfc00f8, | ||
464 | + },{ .name = "USB0_BUS_REF_CTRL", .addr = A_USB0_BUS_REF_CTRL, | ||
465 | + .reset = 0x2001900, | ||
466 | + .rsvd = 0xfdfc00f8, | ||
467 | + },{ .name = "UART0_REF_CTRL", .addr = A_UART0_REF_CTRL, | ||
468 | + .reset = 0xc00, | ||
469 | + .rsvd = 0xfdfc00f8, | ||
470 | + },{ .name = "UART1_REF_CTRL", .addr = A_UART1_REF_CTRL, | ||
471 | + .reset = 0xc00, | ||
472 | + .rsvd = 0xfdfc00f8, | ||
473 | + },{ .name = "SPI0_REF_CTRL", .addr = A_SPI0_REF_CTRL, | ||
474 | + .reset = 0x600, | ||
475 | + .rsvd = 0xfdfc00f8, | ||
476 | + },{ .name = "SPI1_REF_CTRL", .addr = A_SPI1_REF_CTRL, | ||
477 | + .reset = 0x600, | ||
478 | + .rsvd = 0xfdfc00f8, | ||
479 | + },{ .name = "CAN0_REF_CTRL", .addr = A_CAN0_REF_CTRL, | ||
480 | + .reset = 0xc00, | ||
481 | + .rsvd = 0xfdfc00f8, | ||
482 | + },{ .name = "CAN1_REF_CTRL", .addr = A_CAN1_REF_CTRL, | ||
483 | + .reset = 0xc00, | ||
484 | + .rsvd = 0xfdfc00f8, | ||
485 | + },{ .name = "I2C0_REF_CTRL", .addr = A_I2C0_REF_CTRL, | ||
486 | + .reset = 0xc00, | ||
487 | + .rsvd = 0xfdfc00f8, | ||
488 | + },{ .name = "I2C1_REF_CTRL", .addr = A_I2C1_REF_CTRL, | ||
489 | + .reset = 0xc00, | ||
490 | + .rsvd = 0xfdfc00f8, | ||
491 | + },{ .name = "DBG_LPD_CTRL", .addr = A_DBG_LPD_CTRL, | ||
492 | + .reset = 0x300, | ||
493 | + .rsvd = 0xfdfc00f8, | ||
494 | + },{ .name = "TIMESTAMP_REF_CTRL", .addr = A_TIMESTAMP_REF_CTRL, | ||
495 | + .reset = 0x2000c00, | ||
496 | + .rsvd = 0xfdfc00f8, | ||
497 | + },{ .name = "CRL_SAFETY_CHK", .addr = A_CRL_SAFETY_CHK, | ||
498 | + },{ .name = "PSM_REF_CTRL", .addr = A_PSM_REF_CTRL, | ||
499 | + .reset = 0xf04, | ||
500 | + .rsvd = 0xfffc00f8, | ||
501 | + },{ .name = "DBG_TSTMP_CTRL", .addr = A_DBG_TSTMP_CTRL, | ||
502 | + .reset = 0x300, | ||
503 | + .rsvd = 0xfdfc00f8, | ||
504 | + },{ .name = "CPM_TOPSW_REF_CTRL", .addr = A_CPM_TOPSW_REF_CTRL, | ||
505 | + .reset = 0x300, | ||
506 | + .rsvd = 0xfdfc00f8, | ||
507 | + },{ .name = "USB3_DUAL_REF_CTRL", .addr = A_USB3_DUAL_REF_CTRL, | ||
508 | + .reset = 0x3c00, | ||
509 | + .rsvd = 0xfdfc00f8, | ||
510 | + },{ .name = "RST_CPU_R5", .addr = A_RST_CPU_R5, | ||
511 | + .reset = 0x17, | ||
512 | + .rsvd = 0x8, | ||
513 | + .pre_write = crl_rst_r5_prew, | ||
514 | + },{ .name = "RST_ADMA", .addr = A_RST_ADMA, | ||
515 | + .reset = 0x1, | ||
516 | + .pre_write = crl_rst_adma_prew, | ||
517 | + },{ .name = "RST_GEM0", .addr = A_RST_GEM0, | ||
518 | + .reset = 0x1, | ||
519 | + .pre_write = crl_rst_gem0_prew, | ||
520 | + },{ .name = "RST_GEM1", .addr = A_RST_GEM1, | ||
521 | + .reset = 0x1, | ||
522 | + .pre_write = crl_rst_gem1_prew, | ||
523 | + },{ .name = "RST_SPARE", .addr = A_RST_SPARE, | ||
524 | + .reset = 0x1, | ||
525 | + },{ .name = "RST_USB0", .addr = A_RST_USB0, | ||
526 | + .reset = 0x1, | ||
527 | + .pre_write = crl_rst_usb_prew, | ||
528 | + },{ .name = "RST_UART0", .addr = A_RST_UART0, | ||
529 | + .reset = 0x1, | ||
530 | + .pre_write = crl_rst_uart0_prew, | ||
531 | + },{ .name = "RST_UART1", .addr = A_RST_UART1, | ||
532 | + .reset = 0x1, | ||
533 | + .pre_write = crl_rst_uart1_prew, | ||
534 | + },{ .name = "RST_SPI0", .addr = A_RST_SPI0, | ||
535 | + .reset = 0x1, | ||
536 | + },{ .name = "RST_SPI1", .addr = A_RST_SPI1, | ||
537 | + .reset = 0x1, | ||
538 | + },{ .name = "RST_CAN0", .addr = A_RST_CAN0, | ||
539 | + .reset = 0x1, | ||
540 | + },{ .name = "RST_CAN1", .addr = A_RST_CAN1, | ||
541 | + .reset = 0x1, | ||
542 | + },{ .name = "RST_I2C0", .addr = A_RST_I2C0, | ||
543 | + .reset = 0x1, | ||
544 | + },{ .name = "RST_I2C1", .addr = A_RST_I2C1, | ||
545 | + .reset = 0x1, | ||
546 | + },{ .name = "RST_DBG_LPD", .addr = A_RST_DBG_LPD, | ||
547 | + .reset = 0x33, | ||
548 | + .rsvd = 0xcc, | ||
549 | + },{ .name = "RST_GPIO", .addr = A_RST_GPIO, | ||
550 | + .reset = 0x1, | ||
551 | + },{ .name = "RST_TTC", .addr = A_RST_TTC, | ||
552 | + .reset = 0xf, | ||
553 | + },{ .name = "RST_TIMESTAMP", .addr = A_RST_TIMESTAMP, | ||
554 | + .reset = 0x1, | ||
555 | + },{ .name = "RST_SWDT", .addr = A_RST_SWDT, | ||
556 | + .reset = 0x1, | ||
557 | + },{ .name = "RST_OCM", .addr = A_RST_OCM, | ||
558 | + },{ .name = "RST_IPI", .addr = A_RST_IPI, | ||
559 | + },{ .name = "RST_FPD", .addr = A_RST_FPD, | ||
560 | + .reset = 0x3, | ||
561 | + },{ .name = "PSM_RST_MODE", .addr = A_PSM_RST_MODE, | ||
562 | + .reset = 0x1, | ||
563 | + .rsvd = 0xf8, | ||
564 | + } | ||
565 | +}; | ||
566 | + | ||
567 | +static void crl_reset_enter(Object *obj, ResetType type) | ||
568 | +{ | ||
569 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(obj); | ||
570 | + unsigned int i; | ||
571 | + | ||
572 | + for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) { | ||
573 | + register_reset(&s->regs_info[i]); | ||
574 | + } | ||
575 | +} | ||
576 | + | ||
577 | +static void crl_reset_hold(Object *obj) | ||
578 | +{ | ||
579 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(obj); | ||
580 | + | ||
581 | + crl_update_irq(s); | ||
582 | +} | ||
583 | + | ||
584 | +static const MemoryRegionOps crl_ops = { | ||
585 | + .read = register_read_memory, | ||
586 | + .write = register_write_memory, | ||
587 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
588 | + .valid = { | ||
589 | + .min_access_size = 4, | ||
590 | + .max_access_size = 4, | ||
591 | + }, | ||
592 | +}; | ||
593 | + | ||
594 | +static void crl_init(Object *obj) | ||
595 | +{ | ||
596 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(obj); | ||
597 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
598 | + int i; | ||
599 | + | ||
600 | + s->reg_array = | ||
601 | + register_init_block32(DEVICE(obj), crl_regs_info, | ||
602 | + ARRAY_SIZE(crl_regs_info), | ||
603 | + s->regs_info, s->regs, | ||
604 | + &crl_ops, | ||
605 | + XLNX_VERSAL_CRL_ERR_DEBUG, | ||
606 | + CRL_R_MAX * 4); | ||
607 | + sysbus_init_mmio(sbd, &s->reg_array->mem); | ||
608 | + sysbus_init_irq(sbd, &s->irq); | ||
609 | + | ||
610 | + for (i = 0; i < ARRAY_SIZE(s->cfg.cpu_r5); ++i) { | ||
611 | + object_property_add_link(obj, "cpu_r5[*]", TYPE_ARM_CPU, | ||
612 | + (Object **)&s->cfg.cpu_r5[i], | ||
613 | + qdev_prop_allow_set_link_before_realize, | ||
614 | + OBJ_PROP_LINK_STRONG); | ||
615 | + } | ||
616 | + | ||
617 | + for (i = 0; i < ARRAY_SIZE(s->cfg.adma); ++i) { | ||
618 | + object_property_add_link(obj, "adma[*]", TYPE_DEVICE, | ||
619 | + (Object **)&s->cfg.adma[i], | ||
620 | + qdev_prop_allow_set_link_before_realize, | ||
621 | + OBJ_PROP_LINK_STRONG); | ||
622 | + } | ||
623 | + | ||
624 | + for (i = 0; i < ARRAY_SIZE(s->cfg.uart); ++i) { | ||
625 | + object_property_add_link(obj, "uart[*]", TYPE_DEVICE, | ||
626 | + (Object **)&s->cfg.uart[i], | ||
627 | + qdev_prop_allow_set_link_before_realize, | ||
628 | + OBJ_PROP_LINK_STRONG); | ||
629 | + } | ||
630 | + | ||
631 | + for (i = 0; i < ARRAY_SIZE(s->cfg.gem); ++i) { | ||
632 | + object_property_add_link(obj, "gem[*]", TYPE_DEVICE, | ||
633 | + (Object **)&s->cfg.gem[i], | ||
634 | + qdev_prop_allow_set_link_before_realize, | ||
635 | + OBJ_PROP_LINK_STRONG); | ||
636 | + } | ||
637 | + | ||
638 | + object_property_add_link(obj, "usb", TYPE_DEVICE, | ||
639 | + (Object **)&s->cfg.gem[i], | ||
640 | + qdev_prop_allow_set_link_before_realize, | ||
641 | + OBJ_PROP_LINK_STRONG); | ||
642 | +} | ||
643 | + | ||
644 | +static void crl_finalize(Object *obj) | ||
645 | +{ | ||
646 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(obj); | ||
647 | + register_finalize_block(s->reg_array); | ||
648 | +} | ||
649 | + | ||
650 | +static const VMStateDescription vmstate_crl = { | ||
651 | + .name = TYPE_XLNX_VERSAL_CRL, | ||
652 | + .version_id = 1, | ||
653 | + .minimum_version_id = 1, | ||
654 | + .fields = (VMStateField[]) { | ||
655 | + VMSTATE_UINT32_ARRAY(regs, XlnxVersalCRL, CRL_R_MAX), | ||
656 | + VMSTATE_END_OF_LIST(), | ||
657 | + } | ||
658 | +}; | ||
659 | + | ||
660 | +static void crl_class_init(ObjectClass *klass, void *data) | ||
661 | +{ | ||
662 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
663 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
664 | + | ||
665 | + dc->vmsd = &vmstate_crl; | ||
666 | + | ||
667 | + rc->phases.enter = crl_reset_enter; | ||
668 | + rc->phases.hold = crl_reset_hold; | ||
669 | +} | ||
670 | + | ||
671 | +static const TypeInfo crl_info = { | ||
672 | + .name = TYPE_XLNX_VERSAL_CRL, | ||
673 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
674 | + .instance_size = sizeof(XlnxVersalCRL), | ||
675 | + .class_init = crl_class_init, | ||
676 | + .instance_init = crl_init, | ||
677 | + .instance_finalize = crl_finalize, | ||
678 | +}; | ||
679 | + | ||
680 | +static void crl_register_types(void) | ||
681 | +{ | ||
682 | + type_register_static(&crl_info); | ||
683 | +} | ||
684 | + | ||
685 | +type_init(crl_register_types) | ||
686 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build | ||
687 | index XXXXXXX..XXXXXXX 100644 | 66 | index XXXXXXX..XXXXXXX 100644 |
688 | --- a/hw/misc/meson.build | 67 | --- a/include/hw/arm/virt.h |
689 | +++ b/hw/misc/meson.build | 68 | +++ b/include/hw/arm/virt.h |
690 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_SLAVIO', if_true: files('slavio_misc.c')) | 69 | @@ -XXX,XX +XXX,XX @@ |
691 | softmmu_ss.add(when: 'CONFIG_ZYNQ', if_true: files('zynq_slcr.c')) | 70 | #include "qemu/notify.h" |
692 | specific_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx-zynqmp-crf.c')) | 71 | #include "hw/boards.h" |
693 | specific_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx-zynqmp-apu-ctrl.c')) | 72 | #include "hw/arm/boot.h" |
694 | +specific_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files('xlnx-versal-crl.c')) | 73 | +#include "hw/arm/bsa.h" |
695 | softmmu_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files( | 74 | #include "hw/block/flash.h" |
696 | 'xlnx-versal-xramc.c', | 75 | #include "sysemu/kvm.h" |
697 | 'xlnx-versal-pmc-iou-slcr.c', | 76 | #include "hw/intc/arm_gicv3_common.h" |
77 | @@ -XXX,XX +XXX,XX @@ | ||
78 | #define NUM_VIRTIO_TRANSPORTS 32 | ||
79 | #define NUM_SMMU_IRQS 4 | ||
80 | |||
81 | -#define ARCH_GIC_MAINT_IRQ 25 | ||
82 | - | ||
83 | -#define ARCH_TIMER_VIRT_IRQ 27 | ||
84 | -#define ARCH_TIMER_S_EL1_IRQ 29 | ||
85 | -#define ARCH_TIMER_NS_EL1_IRQ 30 | ||
86 | -#define ARCH_TIMER_NS_EL2_IRQ 26 | ||
87 | - | ||
88 | -#define VIRTUAL_PMU_IRQ 23 | ||
89 | - | ||
90 | -#define INTID_TO_PPI(irq) ((irq) - 16) | ||
91 | - | ||
92 | /* See Linux kernel arch/arm64/include/asm/pvclock-abi.h */ | ||
93 | #define PVTIME_SIZE_PER_CPU 64 | ||
94 | |||
698 | -- | 95 | -- |
699 | 2.25.1 | 96 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Hao Wu <wuhaotsh@google.com> | 1 | From: Leif Lindholm <quic_llindhol@quicinc.com> |
---|---|---|---|
2 | 2 | ||
3 | Similar to the Aspeed code in include/misc/aspeed_scu.h, we define | 3 | Use the private peripheral interrupt definitions from bsa.h instead of |
4 | the PWRON STRAP fields in their corresponding module for NPCM7XX. | 4 | defining them locally. Refactor to use the INTIDs defined there instead |
5 | of the PPI# used previously. | ||
5 | 6 | ||
6 | Signed-off-by: Hao Wu <wuhaotsh@google.com> | 7 | Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com> |
7 | Reviewed-by: Patrick Venture <venture@google.com> | 8 | Message-id: 20230919090229.188092-4-quic_llindhol@quicinc.com |
8 | Message-id: 20220411165842.3912945-2-wuhaotsh@google.com | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 11 | --- |
12 | include/hw/misc/npcm7xx_gcr.h | 30 ++++++++++++++++++++++++++++++ | 12 | hw/arm/sbsa-ref.c | 21 +++++++++------------ |
13 | 1 file changed, 30 insertions(+) | 13 | 1 file changed, 9 insertions(+), 12 deletions(-) |
14 | 14 | ||
15 | diff --git a/include/hw/misc/npcm7xx_gcr.h b/include/hw/misc/npcm7xx_gcr.h | 15 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
16 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/include/hw/misc/npcm7xx_gcr.h | 17 | --- a/hw/arm/sbsa-ref.c |
18 | +++ b/include/hw/misc/npcm7xx_gcr.h | 18 | +++ b/hw/arm/sbsa-ref.c |
19 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ |
20 | #include "exec/memory.h" | 20 | * ARM SBSA Reference Platform emulation |
21 | #include "hw/sysbus.h" | 21 | * |
22 | 22 | * Copyright (c) 2018 Linaro Limited | |
23 | +/* | 23 | + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. |
24 | + * NPCM7XX PWRON STRAP bit fields | 24 | * Written by Hongbo Zhang <hongbo.zhang@linaro.org> |
25 | + * 12: SPI0 powered by VSBV3 at 1.8V | 25 | * |
26 | + * 11: System flash attached to BMC | 26 | * This program is free software; you can redistribute it and/or modify it |
27 | + * 10: BSP alternative pins. | 27 | @@ -XXX,XX +XXX,XX @@ |
28 | + * 9:8: Flash UART command route enabled. | 28 | #include "exec/hwaddr.h" |
29 | + * 7: Security enabled. | 29 | #include "kvm_arm.h" |
30 | + * 6: HI-Z state control. | 30 | #include "hw/arm/boot.h" |
31 | + * 5: ECC disabled. | 31 | +#include "hw/arm/bsa.h" |
32 | + * 4: Reserved | 32 | #include "hw/arm/fdt.h" |
33 | + * 3: JTAG2 enabled. | 33 | #include "hw/arm/smmuv3.h" |
34 | + * 2:0: CPU and DRAM clock frequency. | 34 | #include "hw/block/flash.h" |
35 | + */ | 35 | @@ -XXX,XX +XXX,XX @@ |
36 | +#define NPCM7XX_PWRON_STRAP_SPI0F18 BIT(12) | 36 | #define NUM_SMMU_IRQS 4 |
37 | +#define NPCM7XX_PWRON_STRAP_SFAB BIT(11) | 37 | #define NUM_SATA_PORTS 6 |
38 | +#define NPCM7XX_PWRON_STRAP_BSPA BIT(10) | 38 | |
39 | +#define NPCM7XX_PWRON_STRAP_FUP(x) ((x) << 8) | 39 | -#define VIRTUAL_PMU_IRQ 7 |
40 | +#define FUP_NORM_UART2 3 | 40 | -#define ARCH_GIC_MAINT_IRQ 9 |
41 | +#define FUP_PROG_UART3 2 | 41 | -#define ARCH_TIMER_VIRT_IRQ 11 |
42 | +#define FUP_PROG_UART2 1 | 42 | -#define ARCH_TIMER_S_EL1_IRQ 13 |
43 | +#define FUP_NORM_UART3 0 | 43 | -#define ARCH_TIMER_NS_EL1_IRQ 14 |
44 | +#define NPCM7XX_PWRON_STRAP_SECEN BIT(7) | 44 | -#define ARCH_TIMER_NS_EL2_IRQ 10 |
45 | +#define NPCM7XX_PWRON_STRAP_HIZ BIT(6) | 45 | -#define ARCH_TIMER_NS_EL2_VIRT_IRQ 12 |
46 | +#define NPCM7XX_PWRON_STRAP_ECC BIT(5) | 46 | - |
47 | +#define NPCM7XX_PWRON_STRAP_RESERVE1 BIT(4) | 47 | enum { |
48 | +#define NPCM7XX_PWRON_STRAP_J2EN BIT(3) | 48 | SBSA_FLASH, |
49 | +#define NPCM7XX_PWRON_STRAP_CKFRQ(x) (x) | 49 | SBSA_MEM, |
50 | +#define CKFRQ_SKIPINIT 0x000 | 50 | @@ -XXX,XX +XXX,XX @@ static void create_gic(SBSAMachineState *sms, MemoryRegion *mem) |
51 | +#define CKFRQ_DEFAULT 0x111 | 51 | */ |
52 | for (i = 0; i < smp_cpus; i++) { | ||
53 | DeviceState *cpudev = DEVICE(qemu_get_cpu(i)); | ||
54 | - int ppibase = NUM_IRQS + i * GIC_INTERNAL + GIC_NR_SGIS; | ||
55 | + int intidbase = NUM_IRQS + i * GIC_INTERNAL; | ||
56 | int irq; | ||
57 | /* | ||
58 | * Mapping from the output timer irq lines from the CPU to the | ||
59 | @@ -XXX,XX +XXX,XX @@ static void create_gic(SBSAMachineState *sms, MemoryRegion *mem) | ||
60 | for (irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) { | ||
61 | qdev_connect_gpio_out(cpudev, irq, | ||
62 | qdev_get_gpio_in(sms->gic, | ||
63 | - ppibase + timer_irq[irq])); | ||
64 | + intidbase + timer_irq[irq])); | ||
65 | } | ||
66 | |||
67 | qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interrupt", 0, | ||
68 | - qdev_get_gpio_in(sms->gic, ppibase | ||
69 | + qdev_get_gpio_in(sms->gic, | ||
70 | + intidbase | ||
71 | + ARCH_GIC_MAINT_IRQ)); | ||
52 | + | 72 | + |
53 | /* | 73 | qdev_connect_gpio_out_named(cpudev, "pmu-interrupt", 0, |
54 | * Number of registers in our device state structure. Don't change this without | 74 | - qdev_get_gpio_in(sms->gic, ppibase |
55 | * incrementing the version_id in the vmstate. | 75 | + qdev_get_gpio_in(sms->gic, |
76 | + intidbase | ||
77 | + VIRTUAL_PMU_IRQ)); | ||
78 | |||
79 | sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ)); | ||
56 | -- | 80 | -- |
57 | 2.25.1 | 81 | 2.34.1 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> | 1 | From: Cornelia Huck <cohuck@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Create an APU CPU Cluster. This is in preparation to add the RPU. | 3 | We can neaten the code by switching to the kvm_set_one_reg function. |
4 | 4 | ||
5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> | 5 | Reviewed-by: Gavin Shan <gshan@redhat.com> |
6 | Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com> | 6 | Signed-off-by: Cornelia Huck <cohuck@redhat.com> |
7 | Message-id: 20220406174303.2022038-2-edgar.iglesias@xilinx.com | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | Message-id: 20231010142453.224369-2-cohuck@redhat.com | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 11 | --- |
10 | include/hw/arm/xlnx-versal.h | 2 ++ | 12 | target/arm/kvm.c | 13 +++------ |
11 | hw/arm/xlnx-versal.c | 9 ++++++++- | 13 | target/arm/kvm64.c | 66 +++++++++++++--------------------------------- |
12 | 2 files changed, 10 insertions(+), 1 deletion(-) | 14 | 2 files changed, 21 insertions(+), 58 deletions(-) |
13 | 15 | ||
14 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h | 16 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/include/hw/arm/xlnx-versal.h | 18 | --- a/target/arm/kvm.c |
17 | +++ b/include/hw/arm/xlnx-versal.h | 19 | +++ b/target/arm/kvm.c |
18 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ bool write_list_to_kvmstate(ARMCPU *cpu, int level) |
19 | 21 | bool ok = true; | |
20 | #include "hw/sysbus.h" | 22 | |
21 | #include "hw/arm/boot.h" | 23 | for (i = 0; i < cpu->cpreg_array_len; i++) { |
22 | +#include "hw/cpu/cluster.h" | 24 | - struct kvm_one_reg r; |
23 | #include "hw/or-irq.h" | 25 | uint64_t regidx = cpu->cpreg_indexes[i]; |
24 | #include "hw/sd/sdhci.h" | 26 | uint32_t v32; |
25 | #include "hw/intc/arm_gicv3.h" | 27 | int ret; |
26 | @@ -XXX,XX +XXX,XX @@ struct Versal { | 28 | @@ -XXX,XX +XXX,XX @@ bool write_list_to_kvmstate(ARMCPU *cpu, int level) |
27 | struct { | 29 | continue; |
28 | struct { | 30 | } |
29 | MemoryRegion mr; | 31 | |
30 | + CPUClusterState cluster; | 32 | - r.id = regidx; |
31 | ARMCPU cpu[XLNX_VERSAL_NR_ACPUS]; | 33 | switch (regidx & KVM_REG_SIZE_MASK) { |
32 | GICv3State gic; | 34 | case KVM_REG_SIZE_U32: |
33 | } apu; | 35 | v32 = cpu->cpreg_values[i]; |
34 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c | 36 | - r.addr = (uintptr_t)&v32; |
37 | + ret = kvm_set_one_reg(cs, regidx, &v32); | ||
38 | break; | ||
39 | case KVM_REG_SIZE_U64: | ||
40 | - r.addr = (uintptr_t)(cpu->cpreg_values + i); | ||
41 | + ret = kvm_set_one_reg(cs, regidx, cpu->cpreg_values + i); | ||
42 | break; | ||
43 | default: | ||
44 | g_assert_not_reached(); | ||
45 | } | ||
46 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &r); | ||
47 | if (ret) { | ||
48 | /* We might fail for "unknown register" and also for | ||
49 | * "you tried to set a register which is constant with | ||
50 | @@ -XXX,XX +XXX,XX @@ void kvm_arm_get_virtual_time(CPUState *cs) | ||
51 | void kvm_arm_put_virtual_time(CPUState *cs) | ||
52 | { | ||
53 | ARMCPU *cpu = ARM_CPU(cs); | ||
54 | - struct kvm_one_reg reg = { | ||
55 | - .id = KVM_REG_ARM_TIMER_CNT, | ||
56 | - .addr = (uintptr_t)&cpu->kvm_vtime, | ||
57 | - }; | ||
58 | int ret; | ||
59 | |||
60 | if (!cpu->kvm_vtime_dirty) { | ||
61 | return; | ||
62 | } | ||
63 | |||
64 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
65 | + ret = kvm_set_one_reg(cs, KVM_REG_ARM_TIMER_CNT, &cpu->kvm_vtime); | ||
66 | if (ret) { | ||
67 | error_report("Failed to set KVM_REG_ARM_TIMER_CNT"); | ||
68 | abort(); | ||
69 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | 70 | index XXXXXXX..XXXXXXX 100644 |
36 | --- a/hw/arm/xlnx-versal.c | 71 | --- a/target/arm/kvm64.c |
37 | +++ b/hw/arm/xlnx-versal.c | 72 | +++ b/target/arm/kvm64.c |
38 | @@ -XXX,XX +XXX,XX @@ static void versal_create_apu_cpus(Versal *s) | 73 | @@ -XXX,XX +XXX,XX @@ static int kvm_arm_sve_set_vls(CPUState *cs) |
39 | { | 74 | { |
40 | int i; | 75 | ARMCPU *cpu = ARM_CPU(cs); |
41 | 76 | uint64_t vls[KVM_ARM64_SVE_VLS_WORDS] = { cpu->sve_vq.map }; | |
42 | + object_initialize_child(OBJECT(s), "apu-cluster", &s->fpd.apu.cluster, | 77 | - struct kvm_one_reg reg = { |
43 | + TYPE_CPU_CLUSTER); | 78 | - .id = KVM_REG_ARM64_SVE_VLS, |
44 | + qdev_prop_set_uint32(DEVICE(&s->fpd.apu.cluster), "cluster-id", 0); | 79 | - .addr = (uint64_t)&vls[0], |
45 | + | 80 | - }; |
46 | for (i = 0; i < ARRAY_SIZE(s->fpd.apu.cpu); i++) { | 81 | |
47 | Object *obj; | 82 | assert(cpu->sve_max_vq <= KVM_ARM64_SVE_VQ_MAX); |
48 | 83 | ||
49 | - object_initialize_child(OBJECT(s), "apu-cpu[*]", &s->fpd.apu.cpu[i], | 84 | - return kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); |
50 | + object_initialize_child(OBJECT(&s->fpd.apu.cluster), | 85 | + return kvm_set_one_reg(cs, KVM_REG_ARM64_SVE_VLS, &vls[0]); |
51 | + "apu-cpu[*]", &s->fpd.apu.cpu[i], | ||
52 | XLNX_VERSAL_ACPU_TYPE); | ||
53 | obj = OBJECT(&s->fpd.apu.cpu[i]); | ||
54 | if (i) { | ||
55 | @@ -XXX,XX +XXX,XX @@ static void versal_create_apu_cpus(Versal *s) | ||
56 | &error_abort); | ||
57 | qdev_realize(DEVICE(obj), NULL, &error_fatal); | ||
58 | } | ||
59 | + | ||
60 | + qdev_realize(DEVICE(&s->fpd.apu.cluster), NULL, &error_fatal); | ||
61 | } | 86 | } |
62 | 87 | ||
63 | static void versal_create_apu_gic(Versal *s, qemu_irq *pic) | 88 | #define ARM_CPU_ID_MPIDR 3, 0, 0, 0, 5 |
89 | @@ -XXX,XX +XXX,XX @@ static void kvm_inject_arm_sea(CPUState *c) | ||
90 | static int kvm_arch_put_fpsimd(CPUState *cs) | ||
91 | { | ||
92 | CPUARMState *env = &ARM_CPU(cs)->env; | ||
93 | - struct kvm_one_reg reg; | ||
94 | int i, ret; | ||
95 | |||
96 | for (i = 0; i < 32; i++) { | ||
97 | uint64_t *q = aa64_vfp_qreg(env, i); | ||
98 | #if HOST_BIG_ENDIAN | ||
99 | uint64_t fp_val[2] = { q[1], q[0] }; | ||
100 | - reg.addr = (uintptr_t)fp_val; | ||
101 | + ret = kvm_set_one_reg(cs, AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]), | ||
102 | + fp_val); | ||
103 | #else | ||
104 | - reg.addr = (uintptr_t)q; | ||
105 | + ret = kvm_set_one_reg(cs, AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]), q); | ||
106 | #endif | ||
107 | - reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); | ||
108 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
109 | if (ret) { | ||
110 | return ret; | ||
111 | } | ||
112 | @@ -XXX,XX +XXX,XX @@ static int kvm_arch_put_sve(CPUState *cs) | ||
113 | CPUARMState *env = &cpu->env; | ||
114 | uint64_t tmp[ARM_MAX_VQ * 2]; | ||
115 | uint64_t *r; | ||
116 | - struct kvm_one_reg reg; | ||
117 | int n, ret; | ||
118 | |||
119 | for (n = 0; n < KVM_ARM64_SVE_NUM_ZREGS; ++n) { | ||
120 | r = sve_bswap64(tmp, &env->vfp.zregs[n].d[0], cpu->sve_max_vq * 2); | ||
121 | - reg.addr = (uintptr_t)r; | ||
122 | - reg.id = KVM_REG_ARM64_SVE_ZREG(n, 0); | ||
123 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
124 | + ret = kvm_set_one_reg(cs, KVM_REG_ARM64_SVE_ZREG(n, 0), r); | ||
125 | if (ret) { | ||
126 | return ret; | ||
127 | } | ||
128 | @@ -XXX,XX +XXX,XX @@ static int kvm_arch_put_sve(CPUState *cs) | ||
129 | for (n = 0; n < KVM_ARM64_SVE_NUM_PREGS; ++n) { | ||
130 | r = sve_bswap64(tmp, r = &env->vfp.pregs[n].p[0], | ||
131 | DIV_ROUND_UP(cpu->sve_max_vq * 2, 8)); | ||
132 | - reg.addr = (uintptr_t)r; | ||
133 | - reg.id = KVM_REG_ARM64_SVE_PREG(n, 0); | ||
134 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
135 | + ret = kvm_set_one_reg(cs, KVM_REG_ARM64_SVE_PREG(n, 0), r); | ||
136 | if (ret) { | ||
137 | return ret; | ||
138 | } | ||
139 | @@ -XXX,XX +XXX,XX @@ static int kvm_arch_put_sve(CPUState *cs) | ||
140 | |||
141 | r = sve_bswap64(tmp, &env->vfp.pregs[FFR_PRED_NUM].p[0], | ||
142 | DIV_ROUND_UP(cpu->sve_max_vq * 2, 8)); | ||
143 | - reg.addr = (uintptr_t)r; | ||
144 | - reg.id = KVM_REG_ARM64_SVE_FFR(0); | ||
145 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
146 | + ret = kvm_set_one_reg(cs, KVM_REG_ARM64_SVE_FFR(0), r); | ||
147 | if (ret) { | ||
148 | return ret; | ||
149 | } | ||
150 | @@ -XXX,XX +XXX,XX @@ static int kvm_arch_put_sve(CPUState *cs) | ||
151 | |||
152 | int kvm_arch_put_registers(CPUState *cs, int level) | ||
153 | { | ||
154 | - struct kvm_one_reg reg; | ||
155 | uint64_t val; | ||
156 | uint32_t fpr; | ||
157 | int i, ret; | ||
158 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | ||
159 | } | ||
160 | |||
161 | for (i = 0; i < 31; i++) { | ||
162 | - reg.id = AARCH64_CORE_REG(regs.regs[i]); | ||
163 | - reg.addr = (uintptr_t) &env->xregs[i]; | ||
164 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
165 | + ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(regs.regs[i]), | ||
166 | + &env->xregs[i]); | ||
167 | if (ret) { | ||
168 | return ret; | ||
169 | } | ||
170 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | ||
171 | */ | ||
172 | aarch64_save_sp(env, 1); | ||
173 | |||
174 | - reg.id = AARCH64_CORE_REG(regs.sp); | ||
175 | - reg.addr = (uintptr_t) &env->sp_el[0]; | ||
176 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
177 | + ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(regs.sp), &env->sp_el[0]); | ||
178 | if (ret) { | ||
179 | return ret; | ||
180 | } | ||
181 | |||
182 | - reg.id = AARCH64_CORE_REG(sp_el1); | ||
183 | - reg.addr = (uintptr_t) &env->sp_el[1]; | ||
184 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
185 | + ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(sp_el1), &env->sp_el[1]); | ||
186 | if (ret) { | ||
187 | return ret; | ||
188 | } | ||
189 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | ||
190 | } else { | ||
191 | val = cpsr_read(env); | ||
192 | } | ||
193 | - reg.id = AARCH64_CORE_REG(regs.pstate); | ||
194 | - reg.addr = (uintptr_t) &val; | ||
195 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
196 | + ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(regs.pstate), &val); | ||
197 | if (ret) { | ||
198 | return ret; | ||
199 | } | ||
200 | |||
201 | - reg.id = AARCH64_CORE_REG(regs.pc); | ||
202 | - reg.addr = (uintptr_t) &env->pc; | ||
203 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
204 | + ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(regs.pc), &env->pc); | ||
205 | if (ret) { | ||
206 | return ret; | ||
207 | } | ||
208 | |||
209 | - reg.id = AARCH64_CORE_REG(elr_el1); | ||
210 | - reg.addr = (uintptr_t) &env->elr_el[1]; | ||
211 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
212 | + ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(elr_el1), &env->elr_el[1]); | ||
213 | if (ret) { | ||
214 | return ret; | ||
215 | } | ||
216 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | ||
217 | |||
218 | /* KVM 0-4 map to QEMU banks 1-5 */ | ||
219 | for (i = 0; i < KVM_NR_SPSR; i++) { | ||
220 | - reg.id = AARCH64_CORE_REG(spsr[i]); | ||
221 | - reg.addr = (uintptr_t) &env->banked_spsr[i + 1]; | ||
222 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
223 | + ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(spsr[i]), | ||
224 | + &env->banked_spsr[i + 1]); | ||
225 | if (ret) { | ||
226 | return ret; | ||
227 | } | ||
228 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | ||
229 | return ret; | ||
230 | } | ||
231 | |||
232 | - reg.addr = (uintptr_t)(&fpr); | ||
233 | fpr = vfp_get_fpsr(env); | ||
234 | - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); | ||
235 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
236 | + ret = kvm_set_one_reg(cs, AARCH64_SIMD_CTRL_REG(fp_regs.fpsr), &fpr); | ||
237 | if (ret) { | ||
238 | return ret; | ||
239 | } | ||
240 | |||
241 | - reg.addr = (uintptr_t)(&fpr); | ||
242 | fpr = vfp_get_fpcr(env); | ||
243 | - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); | ||
244 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
245 | + ret = kvm_set_one_reg(cs, AARCH64_SIMD_CTRL_REG(fp_regs.fpcr), &fpr); | ||
246 | if (ret) { | ||
247 | return ret; | ||
248 | } | ||
64 | -- | 249 | -- |
65 | 2.25.1 | 250 | 2.34.1 |
251 | |||
252 | diff view generated by jsdifflib |
1 | From: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> | 1 | From: Cornelia Huck <cohuck@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Describe that the gic-version influences the maximum number of CPUs. | 3 | We can neaten the code by switching the callers that work on a |
4 | 4 | CPUstate to the kvm_get_one_reg function. | |
5 | Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> | 5 | |
6 | Message-id: 20220413231456.35811-1-heinrich.schuchardt@canonical.com | 6 | Reviewed-by: Gavin Shan <gshan@redhat.com> |
7 | [PMM: minor punctuation tweaks] | 7 | Signed-off-by: Cornelia Huck <cohuck@redhat.com> |
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
9 | Message-id: 20231010142453.224369-3-cohuck@redhat.com | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 12 | --- |
11 | docs/system/arm/virt.rst | 4 ++-- | 13 | target/arm/kvm.c | 15 +++--------- |
12 | 1 file changed, 2 insertions(+), 2 deletions(-) | 14 | target/arm/kvm64.c | 57 ++++++++++++---------------------------------- |
13 | 15 | 2 files changed, 18 insertions(+), 54 deletions(-) | |
14 | diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst | 16 | |
17 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/docs/system/arm/virt.rst | 19 | --- a/target/arm/kvm.c |
17 | +++ b/docs/system/arm/virt.rst | 20 | +++ b/target/arm/kvm.c |
18 | @@ -XXX,XX +XXX,XX @@ gic-version | 21 | @@ -XXX,XX +XXX,XX @@ bool write_kvmstate_to_list(ARMCPU *cpu) |
19 | Valid values are: | 22 | bool ok = true; |
20 | 23 | ||
21 | ``2`` | 24 | for (i = 0; i < cpu->cpreg_array_len; i++) { |
22 | - GICv2 | 25 | - struct kvm_one_reg r; |
23 | + GICv2. Note that this limits the number of CPUs to 8. | 26 | uint64_t regidx = cpu->cpreg_indexes[i]; |
24 | ``3`` | 27 | uint32_t v32; |
25 | - GICv3 | 28 | int ret; |
26 | + GICv3. This allows up to 512 CPUs. | 29 | |
27 | ``host`` | 30 | - r.id = regidx; |
28 | Use the same GIC version the host provides, when using KVM | 31 | - |
29 | ``max`` | 32 | switch (regidx & KVM_REG_SIZE_MASK) { |
33 | case KVM_REG_SIZE_U32: | ||
34 | - r.addr = (uintptr_t)&v32; | ||
35 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &r); | ||
36 | + ret = kvm_get_one_reg(cs, regidx, &v32); | ||
37 | if (!ret) { | ||
38 | cpu->cpreg_values[i] = v32; | ||
39 | } | ||
40 | break; | ||
41 | case KVM_REG_SIZE_U64: | ||
42 | - r.addr = (uintptr_t)(cpu->cpreg_values + i); | ||
43 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &r); | ||
44 | + ret = kvm_get_one_reg(cs, regidx, cpu->cpreg_values + i); | ||
45 | break; | ||
46 | default: | ||
47 | g_assert_not_reached(); | ||
48 | @@ -XXX,XX +XXX,XX @@ int kvm_arm_sync_mpstate_to_qemu(ARMCPU *cpu) | ||
49 | void kvm_arm_get_virtual_time(CPUState *cs) | ||
50 | { | ||
51 | ARMCPU *cpu = ARM_CPU(cs); | ||
52 | - struct kvm_one_reg reg = { | ||
53 | - .id = KVM_REG_ARM_TIMER_CNT, | ||
54 | - .addr = (uintptr_t)&cpu->kvm_vtime, | ||
55 | - }; | ||
56 | int ret; | ||
57 | |||
58 | if (cpu->kvm_vtime_dirty) { | ||
59 | return; | ||
60 | } | ||
61 | |||
62 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
63 | + ret = kvm_get_one_reg(cs, KVM_REG_ARM_TIMER_CNT, &cpu->kvm_vtime); | ||
64 | if (ret) { | ||
65 | error_report("Failed to get KVM_REG_ARM_TIMER_CNT"); | ||
66 | abort(); | ||
67 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
68 | index XXXXXXX..XXXXXXX 100644 | ||
69 | --- a/target/arm/kvm64.c | ||
70 | +++ b/target/arm/kvm64.c | ||
71 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | ||
72 | static int kvm_arch_get_fpsimd(CPUState *cs) | ||
73 | { | ||
74 | CPUARMState *env = &ARM_CPU(cs)->env; | ||
75 | - struct kvm_one_reg reg; | ||
76 | int i, ret; | ||
77 | |||
78 | for (i = 0; i < 32; i++) { | ||
79 | uint64_t *q = aa64_vfp_qreg(env, i); | ||
80 | - reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); | ||
81 | - reg.addr = (uintptr_t)q; | ||
82 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
83 | + ret = kvm_get_one_reg(cs, AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]), q); | ||
84 | if (ret) { | ||
85 | return ret; | ||
86 | } else { | ||
87 | @@ -XXX,XX +XXX,XX @@ static int kvm_arch_get_sve(CPUState *cs) | ||
88 | { | ||
89 | ARMCPU *cpu = ARM_CPU(cs); | ||
90 | CPUARMState *env = &cpu->env; | ||
91 | - struct kvm_one_reg reg; | ||
92 | uint64_t *r; | ||
93 | int n, ret; | ||
94 | |||
95 | for (n = 0; n < KVM_ARM64_SVE_NUM_ZREGS; ++n) { | ||
96 | r = &env->vfp.zregs[n].d[0]; | ||
97 | - reg.addr = (uintptr_t)r; | ||
98 | - reg.id = KVM_REG_ARM64_SVE_ZREG(n, 0); | ||
99 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
100 | + ret = kvm_get_one_reg(cs, KVM_REG_ARM64_SVE_ZREG(n, 0), r); | ||
101 | if (ret) { | ||
102 | return ret; | ||
103 | } | ||
104 | @@ -XXX,XX +XXX,XX @@ static int kvm_arch_get_sve(CPUState *cs) | ||
105 | |||
106 | for (n = 0; n < KVM_ARM64_SVE_NUM_PREGS; ++n) { | ||
107 | r = &env->vfp.pregs[n].p[0]; | ||
108 | - reg.addr = (uintptr_t)r; | ||
109 | - reg.id = KVM_REG_ARM64_SVE_PREG(n, 0); | ||
110 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
111 | + ret = kvm_get_one_reg(cs, KVM_REG_ARM64_SVE_PREG(n, 0), r); | ||
112 | if (ret) { | ||
113 | return ret; | ||
114 | } | ||
115 | @@ -XXX,XX +XXX,XX @@ static int kvm_arch_get_sve(CPUState *cs) | ||
116 | } | ||
117 | |||
118 | r = &env->vfp.pregs[FFR_PRED_NUM].p[0]; | ||
119 | - reg.addr = (uintptr_t)r; | ||
120 | - reg.id = KVM_REG_ARM64_SVE_FFR(0); | ||
121 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
122 | + ret = kvm_get_one_reg(cs, KVM_REG_ARM64_SVE_FFR(0), r); | ||
123 | if (ret) { | ||
124 | return ret; | ||
125 | } | ||
126 | @@ -XXX,XX +XXX,XX @@ static int kvm_arch_get_sve(CPUState *cs) | ||
127 | |||
128 | int kvm_arch_get_registers(CPUState *cs) | ||
129 | { | ||
130 | - struct kvm_one_reg reg; | ||
131 | uint64_t val; | ||
132 | unsigned int el; | ||
133 | uint32_t fpr; | ||
134 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs) | ||
135 | CPUARMState *env = &cpu->env; | ||
136 | |||
137 | for (i = 0; i < 31; i++) { | ||
138 | - reg.id = AARCH64_CORE_REG(regs.regs[i]); | ||
139 | - reg.addr = (uintptr_t) &env->xregs[i]; | ||
140 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
141 | + ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(regs.regs[i]), | ||
142 | + &env->xregs[i]); | ||
143 | if (ret) { | ||
144 | return ret; | ||
145 | } | ||
146 | } | ||
147 | |||
148 | - reg.id = AARCH64_CORE_REG(regs.sp); | ||
149 | - reg.addr = (uintptr_t) &env->sp_el[0]; | ||
150 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
151 | + ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(regs.sp), &env->sp_el[0]); | ||
152 | if (ret) { | ||
153 | return ret; | ||
154 | } | ||
155 | |||
156 | - reg.id = AARCH64_CORE_REG(sp_el1); | ||
157 | - reg.addr = (uintptr_t) &env->sp_el[1]; | ||
158 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
159 | + ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(sp_el1), &env->sp_el[1]); | ||
160 | if (ret) { | ||
161 | return ret; | ||
162 | } | ||
163 | |||
164 | - reg.id = AARCH64_CORE_REG(regs.pstate); | ||
165 | - reg.addr = (uintptr_t) &val; | ||
166 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
167 | + ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(regs.pstate), &val); | ||
168 | if (ret) { | ||
169 | return ret; | ||
170 | } | ||
171 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs) | ||
172 | */ | ||
173 | aarch64_restore_sp(env, 1); | ||
174 | |||
175 | - reg.id = AARCH64_CORE_REG(regs.pc); | ||
176 | - reg.addr = (uintptr_t) &env->pc; | ||
177 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
178 | + ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(regs.pc), &env->pc); | ||
179 | if (ret) { | ||
180 | return ret; | ||
181 | } | ||
182 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs) | ||
183 | aarch64_sync_64_to_32(env); | ||
184 | } | ||
185 | |||
186 | - reg.id = AARCH64_CORE_REG(elr_el1); | ||
187 | - reg.addr = (uintptr_t) &env->elr_el[1]; | ||
188 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
189 | + ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(elr_el1), &env->elr_el[1]); | ||
190 | if (ret) { | ||
191 | return ret; | ||
192 | } | ||
193 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs) | ||
194 | * KVM SPSRs 0-4 map to QEMU banks 1-5 | ||
195 | */ | ||
196 | for (i = 0; i < KVM_NR_SPSR; i++) { | ||
197 | - reg.id = AARCH64_CORE_REG(spsr[i]); | ||
198 | - reg.addr = (uintptr_t) &env->banked_spsr[i + 1]; | ||
199 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
200 | + ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(spsr[i]), | ||
201 | + &env->banked_spsr[i + 1]); | ||
202 | if (ret) { | ||
203 | return ret; | ||
204 | } | ||
205 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs) | ||
206 | return ret; | ||
207 | } | ||
208 | |||
209 | - reg.addr = (uintptr_t)(&fpr); | ||
210 | - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); | ||
211 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
212 | + ret = kvm_get_one_reg(cs, AARCH64_SIMD_CTRL_REG(fp_regs.fpsr), &fpr); | ||
213 | if (ret) { | ||
214 | return ret; | ||
215 | } | ||
216 | vfp_set_fpsr(env, fpr); | ||
217 | |||
218 | - reg.addr = (uintptr_t)(&fpr); | ||
219 | - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); | ||
220 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
221 | + ret = kvm_get_one_reg(cs, AARCH64_SIMD_CTRL_REG(fp_regs.fpcr), &fpr); | ||
222 | if (ret) { | ||
223 | return ret; | ||
224 | } | ||
30 | -- | 225 | -- |
31 | 2.25.1 | 226 | 2.34.1 |
227 | |||
228 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> | 1 | For the Thumb T32 encoding of LDM, if only a single register is |
---|---|---|---|
2 | specified in the register list this instruction is UNPREDICTABLE, | ||
3 | with the following choices: | ||
4 | * instruction UNDEFs | ||
5 | * instruction is a NOP | ||
6 | * instruction loads a single register | ||
7 | * instruction loads an unspecified set of registers | ||
2 | 8 | ||
3 | Add the Cortex-R5Fs of the Versal RPU (Real-time Processing Unit) | 9 | Currently we choose to UNDEF (a behaviour chosen in commit |
4 | subsystem. | 10 | 4b222545dbf30 in 2019; previously we treated it as "load the |
11 | specified single register"). | ||
5 | 12 | ||
6 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> | 13 | Unfortunately there is real world code out there (which shipped in at |
7 | Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com> | 14 | least Android 11, 12 and 13) which incorrectly uses this |
8 | Message-id: 20220406174303.2022038-3-edgar.iglesias@xilinx.com | 15 | UNPREDICTABLE insn on the assumption that it does a single register |
16 | load, which is (presumably) what it happens to do on real hardware, | ||
17 | and is also what it does on the equivalent A32 encoding. | ||
18 | |||
19 | Revert to the pre-4b222545dbf30 behaviour of not UNDEFing | ||
20 | for this T32 encoding. | ||
21 | |||
22 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1799 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
24 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
25 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
26 | Message-id: 20230927101853.39288-1-peter.maydell@linaro.org | ||
10 | --- | 27 | --- |
11 | include/hw/arm/xlnx-versal.h | 10 ++++++++++ | 28 | target/arm/tcg/translate.c | 37 +++++++++++++++++++++++-------------- |
12 | hw/arm/xlnx-versal-virt.c | 6 +++--- | 29 | 1 file changed, 23 insertions(+), 14 deletions(-) |
13 | hw/arm/xlnx-versal.c | 36 ++++++++++++++++++++++++++++++++++++ | ||
14 | 3 files changed, 49 insertions(+), 3 deletions(-) | ||
15 | 30 | ||
16 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h | 31 | diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c |
17 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/include/hw/arm/xlnx-versal.h | 33 | --- a/target/arm/tcg/translate.c |
19 | +++ b/include/hw/arm/xlnx-versal.h | 34 | +++ b/target/arm/tcg/translate.c |
20 | @@ -XXX,XX +XXX,XX @@ | 35 | @@ -XXX,XX +XXX,XX @@ static void op_addr_block_post(DisasContext *s, arg_ldst_block *a, |
21 | OBJECT_DECLARE_SIMPLE_TYPE(Versal, XLNX_VERSAL) | ||
22 | |||
23 | #define XLNX_VERSAL_NR_ACPUS 2 | ||
24 | +#define XLNX_VERSAL_NR_RCPUS 2 | ||
25 | #define XLNX_VERSAL_NR_UARTS 2 | ||
26 | #define XLNX_VERSAL_NR_GEMS 2 | ||
27 | #define XLNX_VERSAL_NR_ADMAS 8 | ||
28 | @@ -XXX,XX +XXX,XX @@ struct Versal { | ||
29 | VersalUsb2 usb; | ||
30 | } iou; | ||
31 | |||
32 | + /* Real-time Processing Unit. */ | ||
33 | + struct { | ||
34 | + MemoryRegion mr; | ||
35 | + MemoryRegion mr_ps_alias; | ||
36 | + | ||
37 | + CPUClusterState cluster; | ||
38 | + ARMCPU cpu[XLNX_VERSAL_NR_RCPUS]; | ||
39 | + } rpu; | ||
40 | + | ||
41 | struct { | ||
42 | qemu_or_irq irq_orgate; | ||
43 | XlnxXramCtrl ctrl[XLNX_VERSAL_NR_XRAM]; | ||
44 | diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/hw/arm/xlnx-versal-virt.c | ||
47 | +++ b/hw/arm/xlnx-versal-virt.c | ||
48 | @@ -XXX,XX +XXX,XX @@ static void versal_virt_machine_class_init(ObjectClass *oc, void *data) | ||
49 | |||
50 | mc->desc = "Xilinx Versal Virtual development board"; | ||
51 | mc->init = versal_virt_init; | ||
52 | - mc->min_cpus = XLNX_VERSAL_NR_ACPUS; | ||
53 | - mc->max_cpus = XLNX_VERSAL_NR_ACPUS; | ||
54 | - mc->default_cpus = XLNX_VERSAL_NR_ACPUS; | ||
55 | + mc->min_cpus = XLNX_VERSAL_NR_ACPUS + XLNX_VERSAL_NR_RCPUS; | ||
56 | + mc->max_cpus = XLNX_VERSAL_NR_ACPUS + XLNX_VERSAL_NR_RCPUS; | ||
57 | + mc->default_cpus = XLNX_VERSAL_NR_ACPUS + XLNX_VERSAL_NR_RCPUS; | ||
58 | mc->no_cdrom = true; | ||
59 | mc->default_ram_id = "ddr"; | ||
60 | } | ||
61 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/hw/arm/xlnx-versal.c | ||
64 | +++ b/hw/arm/xlnx-versal.c | ||
65 | @@ -XXX,XX +XXX,XX @@ | ||
66 | #include "hw/sysbus.h" | ||
67 | |||
68 | #define XLNX_VERSAL_ACPU_TYPE ARM_CPU_TYPE_NAME("cortex-a72") | ||
69 | +#define XLNX_VERSAL_RCPU_TYPE ARM_CPU_TYPE_NAME("cortex-r5f") | ||
70 | #define GEM_REVISION 0x40070106 | ||
71 | |||
72 | #define VERSAL_NUM_PMC_APB_IRQS 3 | ||
73 | @@ -XXX,XX +XXX,XX @@ static void versal_create_apu_gic(Versal *s, qemu_irq *pic) | ||
74 | } | 36 | } |
75 | } | 37 | } |
76 | 38 | ||
77 | +static void versal_create_rpu_cpus(Versal *s) | 39 | -static bool op_stm(DisasContext *s, arg_ldst_block *a, int min_n) |
78 | +{ | 40 | +static bool op_stm(DisasContext *s, arg_ldst_block *a) |
79 | + int i; | ||
80 | + | ||
81 | + object_initialize_child(OBJECT(s), "rpu-cluster", &s->lpd.rpu.cluster, | ||
82 | + TYPE_CPU_CLUSTER); | ||
83 | + qdev_prop_set_uint32(DEVICE(&s->lpd.rpu.cluster), "cluster-id", 1); | ||
84 | + | ||
85 | + for (i = 0; i < ARRAY_SIZE(s->lpd.rpu.cpu); i++) { | ||
86 | + Object *obj; | ||
87 | + | ||
88 | + object_initialize_child(OBJECT(&s->lpd.rpu.cluster), | ||
89 | + "rpu-cpu[*]", &s->lpd.rpu.cpu[i], | ||
90 | + XLNX_VERSAL_RCPU_TYPE); | ||
91 | + obj = OBJECT(&s->lpd.rpu.cpu[i]); | ||
92 | + object_property_set_bool(obj, "start-powered-off", true, | ||
93 | + &error_abort); | ||
94 | + | ||
95 | + object_property_set_int(obj, "mp-affinity", 0x100 | i, &error_abort); | ||
96 | + object_property_set_int(obj, "core-count", ARRAY_SIZE(s->lpd.rpu.cpu), | ||
97 | + &error_abort); | ||
98 | + object_property_set_link(obj, "memory", OBJECT(&s->lpd.rpu.mr), | ||
99 | + &error_abort); | ||
100 | + qdev_realize(DEVICE(obj), NULL, &error_fatal); | ||
101 | + } | ||
102 | + | ||
103 | + qdev_realize(DEVICE(&s->lpd.rpu.cluster), NULL, &error_fatal); | ||
104 | +} | ||
105 | + | ||
106 | static void versal_create_uarts(Versal *s, qemu_irq *pic) | ||
107 | { | 41 | { |
108 | int i; | 42 | int i, j, n, list, mem_idx; |
109 | @@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp) | 43 | bool user = a->u; |
110 | 44 | @@ -XXX,XX +XXX,XX @@ static bool op_stm(DisasContext *s, arg_ldst_block *a, int min_n) | |
111 | versal_create_apu_cpus(s); | 45 | |
112 | versal_create_apu_gic(s, pic); | 46 | list = a->list; |
113 | + versal_create_rpu_cpus(s); | 47 | n = ctpop16(list); |
114 | versal_create_uarts(s, pic); | 48 | - if (n < min_n || a->rn == 15) { |
115 | versal_create_usbs(s, pic); | 49 | + /* |
116 | versal_create_gems(s, pic); | 50 | + * This is UNPREDICTABLE for n < 1 in all encodings, and we choose |
117 | @@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp) | 51 | + * to UNDEF. In the T32 STM encoding n == 1 is also UNPREDICTABLE, |
118 | 52 | + * but hardware treats it like the A32 version and implements the | |
119 | memory_region_add_subregion_overlap(&s->mr_ps, MM_OCM, &s->lpd.mr_ocm, 0); | 53 | + * single-register-store, and some in-the-wild (buggy) software |
120 | memory_region_add_subregion_overlap(&s->fpd.apu.mr, 0, &s->mr_ps, 0); | 54 | + * assumes that, so we don't UNDEF on that case. |
121 | + memory_region_add_subregion_overlap(&s->lpd.rpu.mr, 0, | 55 | + */ |
122 | + &s->lpd.rpu.mr_ps_alias, 0); | 56 | + if (n < 1 || a->rn == 15) { |
57 | unallocated_encoding(s); | ||
58 | return true; | ||
59 | } | ||
60 | @@ -XXX,XX +XXX,XX @@ static bool op_stm(DisasContext *s, arg_ldst_block *a, int min_n) | ||
61 | |||
62 | static bool trans_STM(DisasContext *s, arg_ldst_block *a) | ||
63 | { | ||
64 | - /* BitCount(list) < 1 is UNPREDICTABLE */ | ||
65 | - return op_stm(s, a, 1); | ||
66 | + return op_stm(s, a); | ||
123 | } | 67 | } |
124 | 68 | ||
125 | static void versal_init(Object *obj) | 69 | static bool trans_STM_t32(DisasContext *s, arg_ldst_block *a) |
126 | @@ -XXX,XX +XXX,XX @@ static void versal_init(Object *obj) | 70 | @@ -XXX,XX +XXX,XX @@ static bool trans_STM_t32(DisasContext *s, arg_ldst_block *a) |
127 | Versal *s = XLNX_VERSAL(obj); | 71 | unallocated_encoding(s); |
128 | 72 | return true; | |
129 | memory_region_init(&s->fpd.apu.mr, obj, "mr-apu", UINT64_MAX); | 73 | } |
130 | + memory_region_init(&s->lpd.rpu.mr, obj, "mr-rpu", UINT64_MAX); | 74 | - /* BitCount(list) < 2 is UNPREDICTABLE */ |
131 | memory_region_init(&s->mr_ps, obj, "mr-ps-switch", UINT64_MAX); | 75 | - return op_stm(s, a, 2); |
132 | + memory_region_init_alias(&s->lpd.rpu.mr_ps_alias, OBJECT(s), | 76 | + return op_stm(s, a); |
133 | + "mr-rpu-ps-alias", &s->mr_ps, 0, UINT64_MAX); | ||
134 | } | 77 | } |
135 | 78 | ||
136 | static Property versal_properties[] = { | 79 | -static bool do_ldm(DisasContext *s, arg_ldst_block *a, int min_n) |
80 | +static bool do_ldm(DisasContext *s, arg_ldst_block *a) | ||
81 | { | ||
82 | int i, j, n, list, mem_idx; | ||
83 | bool loaded_base; | ||
84 | @@ -XXX,XX +XXX,XX @@ static bool do_ldm(DisasContext *s, arg_ldst_block *a, int min_n) | ||
85 | |||
86 | list = a->list; | ||
87 | n = ctpop16(list); | ||
88 | - if (n < min_n || a->rn == 15) { | ||
89 | + /* | ||
90 | + * This is UNPREDICTABLE for n < 1 in all encodings, and we choose | ||
91 | + * to UNDEF. In the T32 LDM encoding n == 1 is also UNPREDICTABLE, | ||
92 | + * but hardware treats it like the A32 version and implements the | ||
93 | + * single-register-load, and some in-the-wild (buggy) software | ||
94 | + * assumes that, so we don't UNDEF on that case. | ||
95 | + */ | ||
96 | + if (n < 1 || a->rn == 15) { | ||
97 | unallocated_encoding(s); | ||
98 | return true; | ||
99 | } | ||
100 | @@ -XXX,XX +XXX,XX @@ static bool trans_LDM_a32(DisasContext *s, arg_ldst_block *a) | ||
101 | unallocated_encoding(s); | ||
102 | return true; | ||
103 | } | ||
104 | - /* BitCount(list) < 1 is UNPREDICTABLE */ | ||
105 | - return do_ldm(s, a, 1); | ||
106 | + return do_ldm(s, a); | ||
107 | } | ||
108 | |||
109 | static bool trans_LDM_t32(DisasContext *s, arg_ldst_block *a) | ||
110 | @@ -XXX,XX +XXX,XX @@ static bool trans_LDM_t32(DisasContext *s, arg_ldst_block *a) | ||
111 | unallocated_encoding(s); | ||
112 | return true; | ||
113 | } | ||
114 | - /* BitCount(list) < 2 is UNPREDICTABLE */ | ||
115 | - return do_ldm(s, a, 2); | ||
116 | + return do_ldm(s, a); | ||
117 | } | ||
118 | |||
119 | static bool trans_LDM_t16(DisasContext *s, arg_ldst_block *a) | ||
120 | { | ||
121 | /* Writeback is conditional on the base register not being loaded. */ | ||
122 | a->w = !(a->list & (1 << a->rn)); | ||
123 | - /* BitCount(list) < 1 is UNPREDICTABLE */ | ||
124 | - return do_ldm(s, a, 1); | ||
125 | + return do_ldm(s, a); | ||
126 | } | ||
127 | |||
128 | static bool trans_CLRM(DisasContext *s, arg_CLRM *a) | ||
137 | -- | 129 | -- |
138 | 2.25.1 | 130 | 2.34.1 |
131 | |||
132 | diff view generated by jsdifflib |
1 | The combiner_grp_to_gic_id[] array includes the EXT_GIC_ID_MCT_G0 | 1 | Update the SMMUv3 ID register bit field definitions to the |
---|---|---|---|
2 | and EXT_GIC_ID_MCT_G1 multiple times. This means that we will | 2 | set in the most recent specification (IHI0700 F.a). |
3 | connect multiple IRQs up to the same external GIC input, which | ||
4 | is not permitted. We do the same thing in the code in | ||
5 | exynos4210_init_board_irqs() because the conditionals selecting | ||
6 | an irq_id in the first loop match multiple interrupt IDs. | ||
7 | |||
8 | Overall we do this for interrupt IDs | ||
9 | (1, 4), (12, 4), (35, 4), (51, 4), (53, 4) for EXT_GIC_ID_MCT_G0 | ||
10 | and | ||
11 | (1, 5), (12, 5), (35, 5), (51, 5), (53, 5) for EXT_GIC_ID_MCT_G1 | ||
12 | |||
13 | These correspond to the cases for the multi-core timer that we are | ||
14 | wiring up to multiple inputs on the combiner in | ||
15 | exynos4210_combiner_get_gpioin(). That code already deals with all | ||
16 | these interrupt IDs being the same input source, so we don't need to | ||
17 | connect the external GIC interrupt for any of them except the first | ||
18 | (1, 4) and (1, 5). Remove the array entries and conditionals which | ||
19 | were incorrectly causing us to wire up extra lines. | ||
20 | |||
21 | This bug didn't cause any visible effects, because we only connect | ||
22 | up a device to the "primary" ID values (1, 4) and (1, 5), so the | ||
23 | extra lines would never be set to a level. | ||
24 | 3 | ||
25 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
26 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
27 | Message-id: 20220404154658.565020-16-peter.maydell@linaro.org | 6 | Reviewed-by: Mostafa Saleh <smostafa@google.com> |
7 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
8 | Message-id: 20230914145705.1648377-2-peter.maydell@linaro.org | ||
28 | --- | 9 | --- |
29 | include/hw/arm/exynos4210.h | 2 +- | 10 | hw/arm/smmuv3-internal.h | 38 ++++++++++++++++++++++++++++++++++++++ |
30 | hw/arm/exynos4210.c | 12 +++++------- | 11 | 1 file changed, 38 insertions(+) |
31 | 2 files changed, 6 insertions(+), 8 deletions(-) | ||
32 | 12 | ||
33 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | 13 | diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h |
34 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/include/hw/arm/exynos4210.h | 15 | --- a/hw/arm/smmuv3-internal.h |
36 | +++ b/include/hw/arm/exynos4210.h | 16 | +++ b/hw/arm/smmuv3-internal.h |
37 | @@ -XXX,XX +XXX,XX @@ | 17 | @@ -XXX,XX +XXX,XX @@ REG32(IDR0, 0x0) |
38 | * one for every non-zero entry in combiner_grp_to_gic_id[]. | 18 | FIELD(IDR0, S1P, 1 , 1) |
39 | * We'll assert in exynos4210_init_board_irqs() if this is wrong. | 19 | FIELD(IDR0, TTF, 2 , 2) |
40 | */ | 20 | FIELD(IDR0, COHACC, 4 , 1) |
41 | -#define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 60) | 21 | + FIELD(IDR0, BTM, 5 , 1) |
42 | +#define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 54) | 22 | + FIELD(IDR0, HTTU, 6 , 2) |
43 | 23 | + FIELD(IDR0, DORMHINT, 8 , 1) | |
44 | typedef struct Exynos4210Irq { | 24 | + FIELD(IDR0, HYP, 9 , 1) |
45 | qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | 25 | + FIELD(IDR0, ATS, 10, 1) |
46 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | 26 | + FIELD(IDR0, NS1ATS, 11, 1) |
47 | index XXXXXXX..XXXXXXX 100644 | 27 | FIELD(IDR0, ASID16, 12, 1) |
48 | --- a/hw/arm/exynos4210.c | 28 | + FIELD(IDR0, MSI, 13, 1) |
49 | +++ b/hw/arm/exynos4210.c | 29 | + FIELD(IDR0, SEV, 14, 1) |
50 | @@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | 30 | + FIELD(IDR0, ATOS, 15, 1) |
51 | /* int combiner group 34 */ | 31 | + FIELD(IDR0, PRI, 16, 1) |
52 | { EXT_GIC_ID_ONENAND_AUDI, EXT_GIC_ID_NFC }, | 32 | + FIELD(IDR0, VMW, 17, 1) |
53 | /* int combiner group 35 */ | 33 | FIELD(IDR0, VMID16, 18, 1) |
54 | - { 0, 0, 0, EXT_GIC_ID_MCT_L1, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | 34 | + FIELD(IDR0, CD2L, 19, 1) |
55 | + { 0, 0, 0, EXT_GIC_ID_MCT_L1 }, | 35 | + FIELD(IDR0, VATOS, 20, 1) |
56 | /* int combiner group 36 */ | 36 | FIELD(IDR0, TTENDIAN, 21, 2) |
57 | { EXT_GIC_ID_MIXER }, | 37 | + FIELD(IDR0, ATSRECERR, 23, 1) |
58 | /* int combiner group 37 */ | 38 | FIELD(IDR0, STALL_MODEL, 24, 2) |
59 | @@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | 39 | FIELD(IDR0, TERM_MODEL, 26, 1) |
60 | /* groups 38-50 */ | 40 | FIELD(IDR0, STLEVEL, 27, 2) |
61 | { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, | 41 | + FIELD(IDR0, RME_IMPL, 30, 1) |
62 | /* int combiner group 51 */ | 42 | |
63 | - { EXT_GIC_ID_MCT_L0, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | 43 | REG32(IDR1, 0x4) |
64 | + { EXT_GIC_ID_MCT_L0 }, | 44 | FIELD(IDR1, SIDSIZE, 0 , 6) |
65 | /* group 52 */ | 45 | + FIELD(IDR1, SSIDSIZE, 6 , 5) |
66 | { }, | 46 | + FIELD(IDR1, PRIQS, 11, 5) |
67 | /* int combiner group 53 */ | 47 | FIELD(IDR1, EVENTQS, 16, 5) |
68 | - { EXT_GIC_ID_WDT, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | 48 | FIELD(IDR1, CMDQS, 21, 5) |
69 | + { EXT_GIC_ID_WDT }, | 49 | + FIELD(IDR1, ATTR_PERMS_OVR, 26, 1) |
70 | /* groups 54-63 */ | 50 | + FIELD(IDR1, ATTR_TYPES_OVR, 27, 1) |
71 | { }, { }, { }, { }, { }, { }, { }, { }, { }, { } | 51 | + FIELD(IDR1, REL, 28, 1) |
72 | }; | 52 | + FIELD(IDR1, QUEUES_PRESET, 29, 1) |
73 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | 53 | + FIELD(IDR1, TABLES_PRESET, 30, 1) |
74 | 54 | + FIELD(IDR1, ECMDQ, 31, 1) | |
75 | for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { | 55 | |
76 | irq_id = 0; | 56 | #define SMMU_IDR1_SIDSIZE 16 |
77 | - if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 4) || | 57 | #define SMMU_CMDQS 19 |
78 | - n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4)) { | 58 | #define SMMU_EVENTQS 19 |
79 | + if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 4)) { | 59 | |
80 | /* MCT_G0 is passed to External GIC */ | 60 | REG32(IDR2, 0x8) |
81 | irq_id = EXT_GIC_ID_MCT_G0; | 61 | + FIELD(IDR2, BA_VATOS, 0, 10) |
82 | } | 62 | + |
83 | - if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 5) || | 63 | REG32(IDR3, 0xc) |
84 | - n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 5)) { | 64 | FIELD(IDR3, HAD, 2, 1); |
85 | + if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 5)) { | 65 | + FIELD(IDR3, PBHA, 3, 1); |
86 | /* MCT_G1 is passed to External and GIC */ | 66 | + FIELD(IDR3, XNX, 4, 1); |
87 | irq_id = EXT_GIC_ID_MCT_G1; | 67 | + FIELD(IDR3, PPS, 5, 1); |
88 | } | 68 | + FIELD(IDR3, MPAM, 7, 1); |
69 | + FIELD(IDR3, FWB, 8, 1); | ||
70 | + FIELD(IDR3, STT, 9, 1); | ||
71 | FIELD(IDR3, RIL, 10, 1); | ||
72 | FIELD(IDR3, BBML, 11, 2); | ||
73 | + FIELD(IDR3, E0PD, 13, 1); | ||
74 | + FIELD(IDR3, PTWNNC, 14, 1); | ||
75 | + FIELD(IDR3, DPT, 15, 1); | ||
76 | + | ||
77 | REG32(IDR4, 0x10) | ||
78 | + | ||
79 | REG32(IDR5, 0x14) | ||
80 | FIELD(IDR5, OAS, 0, 3); | ||
81 | FIELD(IDR5, GRAN4K, 4, 1); | ||
82 | FIELD(IDR5, GRAN16K, 5, 1); | ||
83 | FIELD(IDR5, GRAN64K, 6, 1); | ||
84 | + FIELD(IDR5, VAX, 10, 2); | ||
85 | + FIELD(IDR5, STALL_MAX, 16, 16); | ||
86 | |||
87 | #define SMMU_IDR5_OAS 4 | ||
88 | |||
89 | -- | 89 | -- |
90 | 2.25.1 | 90 | 2.34.1 | diff view generated by jsdifflib |
1 | Currently for the interrupts MCT_G0 and MCT_G1 which are | 1 | In smmuv3_init_regs() when we set the various bits in the ID |
---|---|---|---|
2 | the only ones in the input range of the external combiner | 2 | registers, we do this almost in order of the fields in the |
3 | and which are also wired to the external GIC, we connect | 3 | registers, but not quite. Move the initialization of |
4 | them only to the internal combiner and the external GIC. | 4 | SMMU_IDR3.RIL and SMMU_IDR5.OAS into their correct places. |
5 | This seems likely to be a bug, as all other interrupts | ||
6 | which are in the input range of both combiners are | ||
7 | connected to both combiners. (The fact that the code in | ||
8 | exynos4210_combiner_get_gpioin() is also trying to wire | ||
9 | up these inputs on both combiners also suggests this.) | ||
10 | |||
11 | Wire these interrupts up to both combiners, like the rest. | ||
12 | 5 | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
15 | Message-id: 20220404154658.565020-15-peter.maydell@linaro.org | 8 | Reviewed-by: Mostafa Saleh <smostafa@google.com> |
9 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
10 | Message-id: 20230914145705.1648377-3-peter.maydell@linaro.org | ||
16 | --- | 11 | --- |
17 | hw/arm/exynos4210.c | 7 +++---- | 12 | hw/arm/smmuv3.c | 4 ++-- |
18 | 1 file changed, 3 insertions(+), 4 deletions(-) | 13 | 1 file changed, 2 insertions(+), 2 deletions(-) |
19 | 14 | ||
20 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | 15 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c |
21 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/arm/exynos4210.c | 17 | --- a/hw/arm/smmuv3.c |
23 | +++ b/hw/arm/exynos4210.c | 18 | +++ b/hw/arm/smmuv3.c |
24 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | 19 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_init_regs(SMMUv3State *s) |
25 | 20 | s->idr[1] = FIELD_DP32(s->idr[1], IDR1, EVENTQS, SMMU_EVENTQS); | |
26 | assert(splitcount < EXYNOS4210_NUM_SPLITTERS); | 21 | s->idr[1] = FIELD_DP32(s->idr[1], IDR1, CMDQS, SMMU_CMDQS); |
27 | splitter = DEVICE(&s->splitter[splitcount]); | 22 | |
28 | - qdev_prop_set_uint16(splitter, "num-lines", 2); | 23 | - s->idr[3] = FIELD_DP32(s->idr[3], IDR3, RIL, 1); |
29 | + qdev_prop_set_uint16(splitter, "num-lines", irq_id ? 3 : 2); | 24 | s->idr[3] = FIELD_DP32(s->idr[3], IDR3, HAD, 1); |
30 | qdev_realize(splitter, NULL, &error_abort); | 25 | + s->idr[3] = FIELD_DP32(s->idr[3], IDR3, RIL, 1); |
31 | splitcount++; | 26 | s->idr[3] = FIELD_DP32(s->idr[3], IDR3, BBML, 2); |
32 | s->irq_table[n] = qdev_get_gpio_in(splitter, 0); | 27 | |
33 | qdev_connect_gpio_out(splitter, 0, is->int_combiner_irq[n]); | 28 | + s->idr[5] = FIELD_DP32(s->idr[5], IDR5, OAS, SMMU_IDR5_OAS); /* 44 bits */ |
34 | + qdev_connect_gpio_out(splitter, 1, is->ext_combiner_irq[n]); | 29 | /* 4K, 16K and 64K granule support */ |
35 | if (irq_id) { | 30 | s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN4K, 1); |
36 | - qdev_connect_gpio_out(splitter, 1, | 31 | s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN16K, 1); |
37 | + qdev_connect_gpio_out(splitter, 2, | 32 | s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN64K, 1); |
38 | qdev_get_gpio_in(extgicdev, irq_id - 32)); | 33 | - s->idr[5] = FIELD_DP32(s->idr[5], IDR5, OAS, SMMU_IDR5_OAS); /* 44 bits */ |
39 | - } else { | 34 | |
40 | - qdev_connect_gpio_out(splitter, 1, is->ext_combiner_irq[n]); | 35 | s->cmdq.base = deposit64(s->cmdq.base, 0, 5, SMMU_CMDQS); |
41 | } | 36 | s->cmdq.prod = 0; |
42 | } | ||
43 | for (; n < EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; n++) { | ||
44 | -- | 37 | -- |
45 | 2.25.1 | 38 | 2.34.1 | diff view generated by jsdifflib |
1 | In exynos4210_init_board_irqs(), the loop that handles IRQ lines that | 1 | The SMMUv3.1-XNX feature is mandatory for an SMMUv3.1 if S2P is |
---|---|---|---|
2 | are in a range that applies to the internal combiner only creates a | 2 | supported, so we should theoretically have implemented it as part of |
3 | splitter for those interrupts which go to both the internal combiner | 3 | the recent S2P work. Fortunately, for us the implementation is a |
4 | and to the external GIC, but it does nothing at all for the | 4 | no-op. |
5 | interrupts which don't go to the external GIC, leaving the | ||
6 | irq_table[] array element empty for those. (This will result in | ||
7 | those interrupts simply being lost, not in a QEMU crash.) | ||
8 | 5 | ||
9 | I don't have a reliable datasheet for this SoC, but since we do wire | 6 | This feature is about interpretation of the stage 2 page table |
10 | up one interrupt line in this category (the HDMI I2C device on | 7 | descriptor XN bits, which control execute permissions. |
11 | interrupt 16,1), this seems like it must be a bug in the existing | ||
12 | QEMU code. Fill in the irq_table[] entries where we're not splitting | ||
13 | the IRQ to both the internal combiner and the external GIC with the | ||
14 | IRQ line of the internal combiner. (That is, these IRQ lines go to | ||
15 | just one device, not multiple.) | ||
16 | 8 | ||
17 | This bug didn't have any visible guest effects because the only | 9 | For QEMU, the permission bits passed to an IOMMU (via MemTxAttrs and |
18 | implemented device that was affected was the HDMI I2C controller, | 10 | IOMMUAccessFlags) only indicate read and write; we do not distinguish |
19 | and we never connect any I2C devices to that bus. | 11 | data reads from instruction reads outside the CPU proper. In the |
12 | SMMU architecture's terms, our interconnect between the client device | ||
13 | and the SMMU doesn't have the ability to convey the INST attribute, | ||
14 | and we therefore use the default value of "data" for this attribute. | ||
15 | |||
16 | We also do not support the bits in the Stream Table Entry that can | ||
17 | override the on-the-bus transaction attribute permissions (we do not | ||
18 | set SMMU_IDR1.ATTR_PERMS_OVR=1). | ||
19 | |||
20 | These two things together mean that for our implementation, it never | ||
21 | has to deal with transactions with the INST attribute, and so it can | ||
22 | correctly ignore the XN bits entirely. So we already implement | ||
23 | FEAT_XNX's "XN field is now 2 bits, not 1" behaviour to the extent | ||
24 | that we need to. | ||
25 | |||
26 | Advertise the presence of the feature in SMMU_IDR3.XNX. | ||
20 | 27 | ||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 28 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
22 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 29 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
23 | Message-id: 20220404154658.565020-14-peter.maydell@linaro.org | 30 | Reviewed-by: Mostafa Saleh <smostafa@google.com> |
31 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
32 | Message-id: 20230914145705.1648377-4-peter.maydell@linaro.org | ||
24 | --- | 33 | --- |
25 | hw/arm/exynos4210.c | 2 ++ | 34 | hw/arm/smmuv3.c | 4 ++++ |
26 | 1 file changed, 2 insertions(+) | 35 | 1 file changed, 4 insertions(+) |
27 | 36 | ||
28 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | 37 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c |
29 | index XXXXXXX..XXXXXXX 100644 | 38 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/hw/arm/exynos4210.c | 39 | --- a/hw/arm/smmuv3.c |
31 | +++ b/hw/arm/exynos4210.c | 40 | +++ b/hw/arm/smmuv3.c |
32 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | 41 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_init_regs(SMMUv3State *s) |
33 | qdev_connect_gpio_out(splitter, 0, is->int_combiner_irq[n]); | 42 | s->idr[1] = FIELD_DP32(s->idr[1], IDR1, CMDQS, SMMU_CMDQS); |
34 | qdev_connect_gpio_out(splitter, 1, | 43 | |
35 | qdev_get_gpio_in(extgicdev, irq_id - 32)); | 44 | s->idr[3] = FIELD_DP32(s->idr[3], IDR3, HAD, 1); |
36 | + } else { | 45 | + if (FIELD_EX32(s->idr[0], IDR0, S2P)) { |
37 | + s->irq_table[n] = is->int_combiner_irq[n]; | 46 | + /* XNX is a stage-2-specific feature */ |
38 | } | 47 | + s->idr[3] = FIELD_DP32(s->idr[3], IDR3, XNX, 1); |
39 | } | 48 | + } |
40 | /* | 49 | s->idr[3] = FIELD_DP32(s->idr[3], IDR3, RIL, 1); |
50 | s->idr[3] = FIELD_DP32(s->idr[3], IDR3, BBML, 2); | ||
51 | |||
41 | -- | 52 | -- |
42 | 2.25.1 | 53 | 2.34.1 | diff view generated by jsdifflib |
1 | The only time we use the int_combiner_irq[] and ext_combiner_irq[] | 1 | FEAT_HPMN0 is a small feature which defines that it is valid for |
---|---|---|---|
2 | arrays in the Exynos4210Irq struct is during realize of the SoC -- we | 2 | MDCR_EL2.HPMN to be set to 0, meaning "no PMU event counters provided |
3 | initialize them with the input IRQs of the combiner devices, and then | 3 | to an EL1 guest" (previously this setting was reserved). QEMU's |
4 | connect those to outputs of other devices in | 4 | implementation almost gets HPMN == 0 right, but we need to fix |
5 | exynos4210_init_board_irqs(). Now that the combiner objects are | 5 | one check in pmevcntr_is_64_bit(). That is enough for us to |
6 | easily accessible as s->int_combiner and s->ext_combiner we can make | 6 | advertise the feature in the 'max' CPU. |
7 | the connections directly from one device to the other without going | ||
8 | via these arrays. | ||
9 | 7 | ||
10 | Since these are the only two remaining elements of Exynos4210Irq, | 8 | (We don't need to make the behaviour conditional on feature |
11 | we can remove that struct entirely. | 9 | presence, because the FEAT_HPMN0 behaviour is within the range |
10 | of permitted UNPREDICTABLE behaviour for a non-FEAT_HPMN0 | ||
11 | implementation.) | ||
12 | 12 | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
15 | Message-id: 20220404154658.565020-19-peter.maydell@linaro.org | 15 | Message-id: 20230921185445.3339214-1-peter.maydell@linaro.org |
16 | --- | 16 | --- |
17 | include/hw/arm/exynos4210.h | 6 ------ | 17 | docs/system/arm/emulation.rst | 1 + |
18 | hw/arm/exynos4210.c | 34 ++++++++-------------------------- | 18 | target/arm/helper.c | 2 +- |
19 | 2 files changed, 8 insertions(+), 32 deletions(-) | 19 | target/arm/tcg/cpu32.c | 4 ++++ |
20 | target/arm/tcg/cpu64.c | 1 + | ||
21 | 4 files changed, 7 insertions(+), 1 deletion(-) | ||
20 | 22 | ||
21 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | 23 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
22 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/include/hw/arm/exynos4210.h | 25 | --- a/docs/system/arm/emulation.rst |
24 | +++ b/include/hw/arm/exynos4210.h | 26 | +++ b/docs/system/arm/emulation.rst |
25 | @@ -XXX,XX +XXX,XX @@ | 27 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
26 | */ | 28 | - FEAT_HCX (Support for the HCRX_EL2 register) |
27 | #define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 38) | 29 | - FEAT_HPDS (Hierarchical permission disables) |
28 | 30 | - FEAT_HPDS2 (Translation table page-based hardware attributes) | |
29 | -typedef struct Exynos4210Irq { | 31 | +- FEAT_HPMN0 (Setting of MDCR_EL2.HPMN to zero) |
30 | - qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | 32 | - FEAT_I8MM (AArch64 Int8 matrix multiplication instructions) |
31 | - qemu_irq ext_combiner_irq[EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ]; | 33 | - FEAT_IDST (ID space trap handling) |
32 | -} Exynos4210Irq; | 34 | - FEAT_IESB (Implicit error synchronization event) |
33 | - | 35 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
34 | struct Exynos4210State { | ||
35 | /*< private >*/ | ||
36 | SysBusDevice parent_obj; | ||
37 | /*< public >*/ | ||
38 | ARMCPU *cpu[EXYNOS4210_NCPUS]; | ||
39 | - Exynos4210Irq irqs; | ||
40 | qemu_irq irq_table[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | ||
41 | |||
42 | MemoryRegion chipid_mem; | ||
43 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | 36 | index XXXXXXX..XXXXXXX 100644 |
45 | --- a/hw/arm/exynos4210.c | 37 | --- a/target/arm/helper.c |
46 | +++ b/hw/arm/exynos4210.c | 38 | +++ b/target/arm/helper.c |
47 | @@ -XXX,XX +XXX,XX @@ static int mapline_size(const int *mapline) | 39 | @@ -XXX,XX +XXX,XX @@ static bool pmevcntr_is_64_bit(CPUARMState *env, int counter) |
48 | static void exynos4210_init_board_irqs(Exynos4210State *s) | 40 | bool hlp = env->cp15.mdcr_el2 & MDCR_HLP; |
49 | { | 41 | int hpmn = env->cp15.mdcr_el2 & MDCR_HPMN; |
50 | uint32_t grp, bit, irq_id, n; | 42 | |
51 | - Exynos4210Irq *is = &s->irqs; | 43 | - if (hpmn != 0 && counter >= hpmn) { |
52 | DeviceState *extgicdev = DEVICE(&s->ext_gic); | 44 | + if (counter >= hpmn) { |
53 | + DeviceState *intcdev = DEVICE(&s->int_combiner); | 45 | return hlp; |
54 | + DeviceState *extcdev = DEVICE(&s->ext_combiner); | ||
55 | int splitcount = 0; | ||
56 | DeviceState *splitter; | ||
57 | const int *mapline; | ||
58 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
59 | splitin = 0; | ||
60 | for (;;) { | ||
61 | s->irq_table[in] = qdev_get_gpio_in(splitter, 0); | ||
62 | - qdev_connect_gpio_out(splitter, splitin, is->int_combiner_irq[in]); | ||
63 | - qdev_connect_gpio_out(splitter, splitin + 1, is->ext_combiner_irq[in]); | ||
64 | + qdev_connect_gpio_out(splitter, splitin, | ||
65 | + qdev_get_gpio_in(intcdev, in)); | ||
66 | + qdev_connect_gpio_out(splitter, splitin + 1, | ||
67 | + qdev_get_gpio_in(extcdev, in)); | ||
68 | splitin += 2; | ||
69 | if (!mapline) { | ||
70 | break; | ||
71 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
72 | qdev_realize(splitter, NULL, &error_abort); | ||
73 | splitcount++; | ||
74 | s->irq_table[n] = qdev_get_gpio_in(splitter, 0); | ||
75 | - qdev_connect_gpio_out(splitter, 0, is->int_combiner_irq[n]); | ||
76 | + qdev_connect_gpio_out(splitter, 0, qdev_get_gpio_in(intcdev, n)); | ||
77 | qdev_connect_gpio_out(splitter, 1, | ||
78 | qdev_get_gpio_in(extgicdev, irq_id - 32)); | ||
79 | } else { | ||
80 | - s->irq_table[n] = is->int_combiner_irq[n]; | ||
81 | + s->irq_table[n] = qdev_get_gpio_in(intcdev, n); | ||
82 | } | 46 | } |
83 | } | 47 | } |
84 | /* | 48 | diff --git a/target/arm/tcg/cpu32.c b/target/arm/tcg/cpu32.c |
85 | @@ -XXX,XX +XXX,XX @@ uint32_t exynos4210_get_irq(uint32_t grp, uint32_t bit) | 49 | index XXXXXXX..XXXXXXX 100644 |
86 | return EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit); | 50 | --- a/target/arm/tcg/cpu32.c |
51 | +++ b/target/arm/tcg/cpu32.c | ||
52 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) | ||
53 | t = FIELD_DP32(t, ID_DFR0, COPSDBG, 9); /* FEAT_Debugv8p4 */ | ||
54 | t = FIELD_DP32(t, ID_DFR0, PERFMON, 6); /* FEAT_PMUv3p5 */ | ||
55 | cpu->isar.id_dfr0 = t; | ||
56 | + | ||
57 | + t = cpu->isar.id_dfr1; | ||
58 | + t = FIELD_DP32(t, ID_DFR1, HPMN0, 1); /* FEAT_HPMN0 */ | ||
59 | + cpu->isar.id_dfr1 = t; | ||
87 | } | 60 | } |
88 | 61 | ||
89 | -/* | 62 | /* CPU models. These are not needed for the AArch64 linux-user build. */ |
90 | - * Get Combiner input GPIO into irqs structure | 63 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c |
91 | - */ | 64 | index XXXXXXX..XXXXXXX 100644 |
92 | -static void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, | 65 | --- a/target/arm/tcg/cpu64.c |
93 | - DeviceState *dev, int ext) | 66 | +++ b/target/arm/tcg/cpu64.c |
94 | -{ | 67 | @@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj) |
95 | - int n; | 68 | t = cpu->isar.id_aa64dfr0; |
96 | - int max; | 69 | t = FIELD_DP64(t, ID_AA64DFR0, DEBUGVER, 9); /* FEAT_Debugv8p4 */ |
97 | - qemu_irq *irq; | 70 | t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 6); /* FEAT_PMUv3p5 */ |
98 | - | 71 | + t = FIELD_DP64(t, ID_AA64DFR0, HPMN0, 1); /* FEAT_HPMN0 */ |
99 | - max = ext ? EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ : | 72 | cpu->isar.id_aa64dfr0 = t; |
100 | - EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; | 73 | |
101 | - irq = ext ? irqs->ext_combiner_irq : irqs->int_combiner_irq; | 74 | t = cpu->isar.id_aa64smfr0; |
102 | - | ||
103 | - for (n = 0; n < max; n++) { | ||
104 | - irq[n] = qdev_get_gpio_in(dev, n); | ||
105 | - } | ||
106 | -} | ||
107 | - | ||
108 | static uint8_t chipid_and_omr[] = { 0x11, 0x02, 0x21, 0x43, | ||
109 | 0x09, 0x00, 0x00, 0x00 }; | ||
110 | |||
111 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
112 | sysbus_connect_irq(busdev, n, | ||
113 | qdev_get_gpio_in(DEVICE(&s->a9mpcore), n)); | ||
114 | } | ||
115 | - exynos4210_combiner_get_gpioin(&s->irqs, DEVICE(&s->int_combiner), 0); | ||
116 | sysbus_mmio_map(busdev, 0, EXYNOS4210_INT_COMBINER_BASE_ADDR); | ||
117 | |||
118 | /* External Interrupt Combiner */ | ||
119 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
120 | for (n = 0; n < EXYNOS4210_MAX_INT_COMBINER_OUT_IRQ; n++) { | ||
121 | sysbus_connect_irq(busdev, n, qdev_get_gpio_in(DEVICE(&s->ext_gic), n)); | ||
122 | } | ||
123 | - exynos4210_combiner_get_gpioin(&s->irqs, DEVICE(&s->ext_combiner), 1); | ||
124 | sysbus_mmio_map(busdev, 0, EXYNOS4210_EXT_COMBINER_BASE_ADDR); | ||
125 | |||
126 | /* Initialize board IRQs. */ | ||
127 | -- | 75 | -- |
128 | 2.25.1 | 76 | 2.34.1 | diff view generated by jsdifflib |
1 | The function exynos4210_init_board_irqs() currently lives in | 1 | The include of hw/arm/virt.h in kvm64.c is unnecessary and also a |
---|---|---|---|
2 | exynos4210_gic.c, but it isn't really part of the exynos4210.gic | 2 | layering violation since the generic KVM code shouldn't need to know |
3 | device -- it is a function that implements (some of) the wiring up of | 3 | anything about board-specifics. The include line is an accidental |
4 | interrupts between the SoC's GIC and combiner components. This means | 4 | leftover from commit 15613357ba53a4763, where we cleaned up the code |
5 | it fits better in exynos4210.c, which is the SoC-level code. Move it | 5 | to not depend on virt board internals but forgot to also remove the |
6 | there. Similarly, exynos4210_git_irq() is used almost only in the | 6 | now-redundant include line. |
7 | SoC-level code, so move it too. | ||
8 | 7 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Reviewed-by: Gavin Shan <gshan@redhat.com> |
11 | Message-id: 20220404154658.565020-8-peter.maydell@linaro.org | 10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
11 | Message-id: 20230925110429.3917202-1-peter.maydell@linaro.org | ||
12 | --- | 12 | --- |
13 | include/hw/arm/exynos4210.h | 4 - | 13 | target/arm/kvm64.c | 1 - |
14 | hw/arm/exynos4210.c | 202 +++++++++++++++++++++++++++++++++++ | 14 | 1 file changed, 1 deletion(-) |
15 | hw/intc/exynos4210_gic.c | 204 ------------------------------------ | ||
16 | 3 files changed, 202 insertions(+), 208 deletions(-) | ||
17 | 15 | ||
18 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | 16 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c |
19 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/include/hw/arm/exynos4210.h | 18 | --- a/target/arm/kvm64.c |
21 | +++ b/include/hw/arm/exynos4210.h | 19 | +++ b/target/arm/kvm64.c |
22 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210State, EXYNOS4210_SOC) | ||
23 | void exynos4210_write_secondary(ARMCPU *cpu, | ||
24 | const struct arm_boot_info *info); | ||
25 | |||
26 | -/* Initialize board IRQs. | ||
27 | - * These IRQs contain splitted Int/External Combiner and External Gic IRQs */ | ||
28 | -void exynos4210_init_board_irqs(Exynos4210State *s); | ||
29 | - | ||
30 | /* Get IRQ number from exynos4210 IRQ subsystem stub. | ||
31 | * To identify IRQ source use internal combiner group and bit number | ||
32 | * grp - group number | ||
33 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/hw/arm/exynos4210.c | ||
36 | +++ b/hw/arm/exynos4210.c | ||
37 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ |
38 | #define EXYNOS4210_PL330_BASE1_ADDR 0x12690000 | 21 | #include "internals.h" |
39 | #define EXYNOS4210_PL330_BASE2_ADDR 0x12850000 | 22 | #include "hw/acpi/acpi.h" |
40 | 23 | #include "hw/acpi/ghes.h" | |
41 | +enum ExtGicId { | 24 | -#include "hw/arm/virt.h" |
42 | + EXT_GIC_ID_MDMA_LCD0 = 66, | 25 | |
43 | + EXT_GIC_ID_PDMA0, | 26 | static bool have_guest_debug; |
44 | + EXT_GIC_ID_PDMA1, | ||
45 | + EXT_GIC_ID_TIMER0, | ||
46 | + EXT_GIC_ID_TIMER1, | ||
47 | + EXT_GIC_ID_TIMER2, | ||
48 | + EXT_GIC_ID_TIMER3, | ||
49 | + EXT_GIC_ID_TIMER4, | ||
50 | + EXT_GIC_ID_MCT_L0, | ||
51 | + EXT_GIC_ID_WDT, | ||
52 | + EXT_GIC_ID_RTC_ALARM, | ||
53 | + EXT_GIC_ID_RTC_TIC, | ||
54 | + EXT_GIC_ID_GPIO_XB, | ||
55 | + EXT_GIC_ID_GPIO_XA, | ||
56 | + EXT_GIC_ID_MCT_L1, | ||
57 | + EXT_GIC_ID_IEM_APC, | ||
58 | + EXT_GIC_ID_IEM_IEC, | ||
59 | + EXT_GIC_ID_NFC, | ||
60 | + EXT_GIC_ID_UART0, | ||
61 | + EXT_GIC_ID_UART1, | ||
62 | + EXT_GIC_ID_UART2, | ||
63 | + EXT_GIC_ID_UART3, | ||
64 | + EXT_GIC_ID_UART4, | ||
65 | + EXT_GIC_ID_MCT_G0, | ||
66 | + EXT_GIC_ID_I2C0, | ||
67 | + EXT_GIC_ID_I2C1, | ||
68 | + EXT_GIC_ID_I2C2, | ||
69 | + EXT_GIC_ID_I2C3, | ||
70 | + EXT_GIC_ID_I2C4, | ||
71 | + EXT_GIC_ID_I2C5, | ||
72 | + EXT_GIC_ID_I2C6, | ||
73 | + EXT_GIC_ID_I2C7, | ||
74 | + EXT_GIC_ID_SPI0, | ||
75 | + EXT_GIC_ID_SPI1, | ||
76 | + EXT_GIC_ID_SPI2, | ||
77 | + EXT_GIC_ID_MCT_G1, | ||
78 | + EXT_GIC_ID_USB_HOST, | ||
79 | + EXT_GIC_ID_USB_DEVICE, | ||
80 | + EXT_GIC_ID_MODEMIF, | ||
81 | + EXT_GIC_ID_HSMMC0, | ||
82 | + EXT_GIC_ID_HSMMC1, | ||
83 | + EXT_GIC_ID_HSMMC2, | ||
84 | + EXT_GIC_ID_HSMMC3, | ||
85 | + EXT_GIC_ID_SDMMC, | ||
86 | + EXT_GIC_ID_MIPI_CSI_4LANE, | ||
87 | + EXT_GIC_ID_MIPI_DSI_4LANE, | ||
88 | + EXT_GIC_ID_MIPI_CSI_2LANE, | ||
89 | + EXT_GIC_ID_MIPI_DSI_2LANE, | ||
90 | + EXT_GIC_ID_ONENAND_AUDI, | ||
91 | + EXT_GIC_ID_ROTATOR, | ||
92 | + EXT_GIC_ID_FIMC0, | ||
93 | + EXT_GIC_ID_FIMC1, | ||
94 | + EXT_GIC_ID_FIMC2, | ||
95 | + EXT_GIC_ID_FIMC3, | ||
96 | + EXT_GIC_ID_JPEG, | ||
97 | + EXT_GIC_ID_2D, | ||
98 | + EXT_GIC_ID_PCIe, | ||
99 | + EXT_GIC_ID_MIXER, | ||
100 | + EXT_GIC_ID_HDMI, | ||
101 | + EXT_GIC_ID_HDMI_I2C, | ||
102 | + EXT_GIC_ID_MFC, | ||
103 | + EXT_GIC_ID_TVENC, | ||
104 | +}; | ||
105 | + | ||
106 | +enum ExtInt { | ||
107 | + EXT_GIC_ID_EXTINT0 = 48, | ||
108 | + EXT_GIC_ID_EXTINT1, | ||
109 | + EXT_GIC_ID_EXTINT2, | ||
110 | + EXT_GIC_ID_EXTINT3, | ||
111 | + EXT_GIC_ID_EXTINT4, | ||
112 | + EXT_GIC_ID_EXTINT5, | ||
113 | + EXT_GIC_ID_EXTINT6, | ||
114 | + EXT_GIC_ID_EXTINT7, | ||
115 | + EXT_GIC_ID_EXTINT8, | ||
116 | + EXT_GIC_ID_EXTINT9, | ||
117 | + EXT_GIC_ID_EXTINT10, | ||
118 | + EXT_GIC_ID_EXTINT11, | ||
119 | + EXT_GIC_ID_EXTINT12, | ||
120 | + EXT_GIC_ID_EXTINT13, | ||
121 | + EXT_GIC_ID_EXTINT14, | ||
122 | + EXT_GIC_ID_EXTINT15 | ||
123 | +}; | ||
124 | + | ||
125 | +/* | ||
126 | + * External GIC sources which are not from External Interrupt Combiner or | ||
127 | + * External Interrupts are starting from EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ, | ||
128 | + * which is INTG16 in Internal Interrupt Combiner. | ||
129 | + */ | ||
130 | + | ||
131 | +static const uint32_t | ||
132 | +combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | ||
133 | + /* int combiner groups 16-19 */ | ||
134 | + { }, { }, { }, { }, | ||
135 | + /* int combiner group 20 */ | ||
136 | + { 0, EXT_GIC_ID_MDMA_LCD0 }, | ||
137 | + /* int combiner group 21 */ | ||
138 | + { EXT_GIC_ID_PDMA0, EXT_GIC_ID_PDMA1 }, | ||
139 | + /* int combiner group 22 */ | ||
140 | + { EXT_GIC_ID_TIMER0, EXT_GIC_ID_TIMER1, EXT_GIC_ID_TIMER2, | ||
141 | + EXT_GIC_ID_TIMER3, EXT_GIC_ID_TIMER4 }, | ||
142 | + /* int combiner group 23 */ | ||
143 | + { EXT_GIC_ID_RTC_ALARM, EXT_GIC_ID_RTC_TIC }, | ||
144 | + /* int combiner group 24 */ | ||
145 | + { EXT_GIC_ID_GPIO_XB, EXT_GIC_ID_GPIO_XA }, | ||
146 | + /* int combiner group 25 */ | ||
147 | + { EXT_GIC_ID_IEM_APC, EXT_GIC_ID_IEM_IEC }, | ||
148 | + /* int combiner group 26 */ | ||
149 | + { EXT_GIC_ID_UART0, EXT_GIC_ID_UART1, EXT_GIC_ID_UART2, EXT_GIC_ID_UART3, | ||
150 | + EXT_GIC_ID_UART4 }, | ||
151 | + /* int combiner group 27 */ | ||
152 | + { EXT_GIC_ID_I2C0, EXT_GIC_ID_I2C1, EXT_GIC_ID_I2C2, EXT_GIC_ID_I2C3, | ||
153 | + EXT_GIC_ID_I2C4, EXT_GIC_ID_I2C5, EXT_GIC_ID_I2C6, | ||
154 | + EXT_GIC_ID_I2C7 }, | ||
155 | + /* int combiner group 28 */ | ||
156 | + { EXT_GIC_ID_SPI0, EXT_GIC_ID_SPI1, EXT_GIC_ID_SPI2 , EXT_GIC_ID_USB_HOST}, | ||
157 | + /* int combiner group 29 */ | ||
158 | + { EXT_GIC_ID_HSMMC0, EXT_GIC_ID_HSMMC1, EXT_GIC_ID_HSMMC2, | ||
159 | + EXT_GIC_ID_HSMMC3, EXT_GIC_ID_SDMMC }, | ||
160 | + /* int combiner group 30 */ | ||
161 | + { EXT_GIC_ID_MIPI_CSI_4LANE, EXT_GIC_ID_MIPI_CSI_2LANE }, | ||
162 | + /* int combiner group 31 */ | ||
163 | + { EXT_GIC_ID_MIPI_DSI_4LANE, EXT_GIC_ID_MIPI_DSI_2LANE }, | ||
164 | + /* int combiner group 32 */ | ||
165 | + { EXT_GIC_ID_FIMC0, EXT_GIC_ID_FIMC1 }, | ||
166 | + /* int combiner group 33 */ | ||
167 | + { EXT_GIC_ID_FIMC2, EXT_GIC_ID_FIMC3 }, | ||
168 | + /* int combiner group 34 */ | ||
169 | + { EXT_GIC_ID_ONENAND_AUDI, EXT_GIC_ID_NFC }, | ||
170 | + /* int combiner group 35 */ | ||
171 | + { 0, 0, 0, EXT_GIC_ID_MCT_L1, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | ||
172 | + /* int combiner group 36 */ | ||
173 | + { EXT_GIC_ID_MIXER }, | ||
174 | + /* int combiner group 37 */ | ||
175 | + { EXT_GIC_ID_EXTINT4, EXT_GIC_ID_EXTINT5, EXT_GIC_ID_EXTINT6, | ||
176 | + EXT_GIC_ID_EXTINT7 }, | ||
177 | + /* groups 38-50 */ | ||
178 | + { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, | ||
179 | + /* int combiner group 51 */ | ||
180 | + { EXT_GIC_ID_MCT_L0, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | ||
181 | + /* group 52 */ | ||
182 | + { }, | ||
183 | + /* int combiner group 53 */ | ||
184 | + { EXT_GIC_ID_WDT, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | ||
185 | + /* groups 54-63 */ | ||
186 | + { }, { }, { }, { }, { }, { }, { }, { }, { }, { } | ||
187 | +}; | ||
188 | + | ||
189 | +/* | ||
190 | + * Initialize board IRQs. | ||
191 | + * These IRQs contain splitted Int/External Combiner and External Gic IRQs. | ||
192 | + */ | ||
193 | +static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
194 | +{ | ||
195 | + uint32_t grp, bit, irq_id, n; | ||
196 | + Exynos4210Irq *is = &s->irqs; | ||
197 | + | ||
198 | + for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { | ||
199 | + irq_id = 0; | ||
200 | + if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 4) || | ||
201 | + n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4)) { | ||
202 | + /* MCT_G0 is passed to External GIC */ | ||
203 | + irq_id = EXT_GIC_ID_MCT_G0; | ||
204 | + } | ||
205 | + if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 5) || | ||
206 | + n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 5)) { | ||
207 | + /* MCT_G1 is passed to External and GIC */ | ||
208 | + irq_id = EXT_GIC_ID_MCT_G1; | ||
209 | + } | ||
210 | + if (irq_id) { | ||
211 | + s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
212 | + is->ext_gic_irq[irq_id - 32]); | ||
213 | + } else { | ||
214 | + s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
215 | + is->ext_combiner_irq[n]); | ||
216 | + } | ||
217 | + } | ||
218 | + for (; n < EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; n++) { | ||
219 | + /* these IDs are passed to Internal Combiner and External GIC */ | ||
220 | + grp = EXYNOS4210_COMBINER_GET_GRP_NUM(n); | ||
221 | + bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n); | ||
222 | + irq_id = combiner_grp_to_gic_id[grp - | ||
223 | + EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][bit]; | ||
224 | + | ||
225 | + if (irq_id) { | ||
226 | + s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
227 | + is->ext_gic_irq[irq_id - 32]); | ||
228 | + } | ||
229 | + } | ||
230 | +} | ||
231 | + | ||
232 | +/* | ||
233 | + * Get IRQ number from exynos4210 IRQ subsystem stub. | ||
234 | + * To identify IRQ source use internal combiner group and bit number | ||
235 | + * grp - group number | ||
236 | + * bit - bit number inside group | ||
237 | + */ | ||
238 | +uint32_t exynos4210_get_irq(uint32_t grp, uint32_t bit) | ||
239 | +{ | ||
240 | + return EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit); | ||
241 | +} | ||
242 | + | ||
243 | static uint8_t chipid_and_omr[] = { 0x11, 0x02, 0x21, 0x43, | ||
244 | 0x09, 0x00, 0x00, 0x00 }; | ||
245 | |||
246 | diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c | ||
247 | index XXXXXXX..XXXXXXX 100644 | ||
248 | --- a/hw/intc/exynos4210_gic.c | ||
249 | +++ b/hw/intc/exynos4210_gic.c | ||
250 | @@ -XXX,XX +XXX,XX @@ | ||
251 | #include "hw/arm/exynos4210.h" | ||
252 | #include "qom/object.h" | ||
253 | |||
254 | -enum ExtGicId { | ||
255 | - EXT_GIC_ID_MDMA_LCD0 = 66, | ||
256 | - EXT_GIC_ID_PDMA0, | ||
257 | - EXT_GIC_ID_PDMA1, | ||
258 | - EXT_GIC_ID_TIMER0, | ||
259 | - EXT_GIC_ID_TIMER1, | ||
260 | - EXT_GIC_ID_TIMER2, | ||
261 | - EXT_GIC_ID_TIMER3, | ||
262 | - EXT_GIC_ID_TIMER4, | ||
263 | - EXT_GIC_ID_MCT_L0, | ||
264 | - EXT_GIC_ID_WDT, | ||
265 | - EXT_GIC_ID_RTC_ALARM, | ||
266 | - EXT_GIC_ID_RTC_TIC, | ||
267 | - EXT_GIC_ID_GPIO_XB, | ||
268 | - EXT_GIC_ID_GPIO_XA, | ||
269 | - EXT_GIC_ID_MCT_L1, | ||
270 | - EXT_GIC_ID_IEM_APC, | ||
271 | - EXT_GIC_ID_IEM_IEC, | ||
272 | - EXT_GIC_ID_NFC, | ||
273 | - EXT_GIC_ID_UART0, | ||
274 | - EXT_GIC_ID_UART1, | ||
275 | - EXT_GIC_ID_UART2, | ||
276 | - EXT_GIC_ID_UART3, | ||
277 | - EXT_GIC_ID_UART4, | ||
278 | - EXT_GIC_ID_MCT_G0, | ||
279 | - EXT_GIC_ID_I2C0, | ||
280 | - EXT_GIC_ID_I2C1, | ||
281 | - EXT_GIC_ID_I2C2, | ||
282 | - EXT_GIC_ID_I2C3, | ||
283 | - EXT_GIC_ID_I2C4, | ||
284 | - EXT_GIC_ID_I2C5, | ||
285 | - EXT_GIC_ID_I2C6, | ||
286 | - EXT_GIC_ID_I2C7, | ||
287 | - EXT_GIC_ID_SPI0, | ||
288 | - EXT_GIC_ID_SPI1, | ||
289 | - EXT_GIC_ID_SPI2, | ||
290 | - EXT_GIC_ID_MCT_G1, | ||
291 | - EXT_GIC_ID_USB_HOST, | ||
292 | - EXT_GIC_ID_USB_DEVICE, | ||
293 | - EXT_GIC_ID_MODEMIF, | ||
294 | - EXT_GIC_ID_HSMMC0, | ||
295 | - EXT_GIC_ID_HSMMC1, | ||
296 | - EXT_GIC_ID_HSMMC2, | ||
297 | - EXT_GIC_ID_HSMMC3, | ||
298 | - EXT_GIC_ID_SDMMC, | ||
299 | - EXT_GIC_ID_MIPI_CSI_4LANE, | ||
300 | - EXT_GIC_ID_MIPI_DSI_4LANE, | ||
301 | - EXT_GIC_ID_MIPI_CSI_2LANE, | ||
302 | - EXT_GIC_ID_MIPI_DSI_2LANE, | ||
303 | - EXT_GIC_ID_ONENAND_AUDI, | ||
304 | - EXT_GIC_ID_ROTATOR, | ||
305 | - EXT_GIC_ID_FIMC0, | ||
306 | - EXT_GIC_ID_FIMC1, | ||
307 | - EXT_GIC_ID_FIMC2, | ||
308 | - EXT_GIC_ID_FIMC3, | ||
309 | - EXT_GIC_ID_JPEG, | ||
310 | - EXT_GIC_ID_2D, | ||
311 | - EXT_GIC_ID_PCIe, | ||
312 | - EXT_GIC_ID_MIXER, | ||
313 | - EXT_GIC_ID_HDMI, | ||
314 | - EXT_GIC_ID_HDMI_I2C, | ||
315 | - EXT_GIC_ID_MFC, | ||
316 | - EXT_GIC_ID_TVENC, | ||
317 | -}; | ||
318 | - | ||
319 | -enum ExtInt { | ||
320 | - EXT_GIC_ID_EXTINT0 = 48, | ||
321 | - EXT_GIC_ID_EXTINT1, | ||
322 | - EXT_GIC_ID_EXTINT2, | ||
323 | - EXT_GIC_ID_EXTINT3, | ||
324 | - EXT_GIC_ID_EXTINT4, | ||
325 | - EXT_GIC_ID_EXTINT5, | ||
326 | - EXT_GIC_ID_EXTINT6, | ||
327 | - EXT_GIC_ID_EXTINT7, | ||
328 | - EXT_GIC_ID_EXTINT8, | ||
329 | - EXT_GIC_ID_EXTINT9, | ||
330 | - EXT_GIC_ID_EXTINT10, | ||
331 | - EXT_GIC_ID_EXTINT11, | ||
332 | - EXT_GIC_ID_EXTINT12, | ||
333 | - EXT_GIC_ID_EXTINT13, | ||
334 | - EXT_GIC_ID_EXTINT14, | ||
335 | - EXT_GIC_ID_EXTINT15 | ||
336 | -}; | ||
337 | - | ||
338 | -/* | ||
339 | - * External GIC sources which are not from External Interrupt Combiner or | ||
340 | - * External Interrupts are starting from EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ, | ||
341 | - * which is INTG16 in Internal Interrupt Combiner. | ||
342 | - */ | ||
343 | - | ||
344 | -static const uint32_t | ||
345 | -combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | ||
346 | - /* int combiner groups 16-19 */ | ||
347 | - { }, { }, { }, { }, | ||
348 | - /* int combiner group 20 */ | ||
349 | - { 0, EXT_GIC_ID_MDMA_LCD0 }, | ||
350 | - /* int combiner group 21 */ | ||
351 | - { EXT_GIC_ID_PDMA0, EXT_GIC_ID_PDMA1 }, | ||
352 | - /* int combiner group 22 */ | ||
353 | - { EXT_GIC_ID_TIMER0, EXT_GIC_ID_TIMER1, EXT_GIC_ID_TIMER2, | ||
354 | - EXT_GIC_ID_TIMER3, EXT_GIC_ID_TIMER4 }, | ||
355 | - /* int combiner group 23 */ | ||
356 | - { EXT_GIC_ID_RTC_ALARM, EXT_GIC_ID_RTC_TIC }, | ||
357 | - /* int combiner group 24 */ | ||
358 | - { EXT_GIC_ID_GPIO_XB, EXT_GIC_ID_GPIO_XA }, | ||
359 | - /* int combiner group 25 */ | ||
360 | - { EXT_GIC_ID_IEM_APC, EXT_GIC_ID_IEM_IEC }, | ||
361 | - /* int combiner group 26 */ | ||
362 | - { EXT_GIC_ID_UART0, EXT_GIC_ID_UART1, EXT_GIC_ID_UART2, EXT_GIC_ID_UART3, | ||
363 | - EXT_GIC_ID_UART4 }, | ||
364 | - /* int combiner group 27 */ | ||
365 | - { EXT_GIC_ID_I2C0, EXT_GIC_ID_I2C1, EXT_GIC_ID_I2C2, EXT_GIC_ID_I2C3, | ||
366 | - EXT_GIC_ID_I2C4, EXT_GIC_ID_I2C5, EXT_GIC_ID_I2C6, | ||
367 | - EXT_GIC_ID_I2C7 }, | ||
368 | - /* int combiner group 28 */ | ||
369 | - { EXT_GIC_ID_SPI0, EXT_GIC_ID_SPI1, EXT_GIC_ID_SPI2 , EXT_GIC_ID_USB_HOST}, | ||
370 | - /* int combiner group 29 */ | ||
371 | - { EXT_GIC_ID_HSMMC0, EXT_GIC_ID_HSMMC1, EXT_GIC_ID_HSMMC2, | ||
372 | - EXT_GIC_ID_HSMMC3, EXT_GIC_ID_SDMMC }, | ||
373 | - /* int combiner group 30 */ | ||
374 | - { EXT_GIC_ID_MIPI_CSI_4LANE, EXT_GIC_ID_MIPI_CSI_2LANE }, | ||
375 | - /* int combiner group 31 */ | ||
376 | - { EXT_GIC_ID_MIPI_DSI_4LANE, EXT_GIC_ID_MIPI_DSI_2LANE }, | ||
377 | - /* int combiner group 32 */ | ||
378 | - { EXT_GIC_ID_FIMC0, EXT_GIC_ID_FIMC1 }, | ||
379 | - /* int combiner group 33 */ | ||
380 | - { EXT_GIC_ID_FIMC2, EXT_GIC_ID_FIMC3 }, | ||
381 | - /* int combiner group 34 */ | ||
382 | - { EXT_GIC_ID_ONENAND_AUDI, EXT_GIC_ID_NFC }, | ||
383 | - /* int combiner group 35 */ | ||
384 | - { 0, 0, 0, EXT_GIC_ID_MCT_L1, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | ||
385 | - /* int combiner group 36 */ | ||
386 | - { EXT_GIC_ID_MIXER }, | ||
387 | - /* int combiner group 37 */ | ||
388 | - { EXT_GIC_ID_EXTINT4, EXT_GIC_ID_EXTINT5, EXT_GIC_ID_EXTINT6, | ||
389 | - EXT_GIC_ID_EXTINT7 }, | ||
390 | - /* groups 38-50 */ | ||
391 | - { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, | ||
392 | - /* int combiner group 51 */ | ||
393 | - { EXT_GIC_ID_MCT_L0, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | ||
394 | - /* group 52 */ | ||
395 | - { }, | ||
396 | - /* int combiner group 53 */ | ||
397 | - { EXT_GIC_ID_WDT, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | ||
398 | - /* groups 54-63 */ | ||
399 | - { }, { }, { }, { }, { }, { }, { }, { }, { }, { } | ||
400 | -}; | ||
401 | - | ||
402 | #define EXYNOS4210_GIC_NIRQ 160 | ||
403 | |||
404 | #define EXYNOS4210_EXT_GIC_CPU_REGION_SIZE 0x10000 | ||
405 | @@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | ||
406 | #define EXYNOS4210_GIC_CPU_REGION_SIZE 0x100 | ||
407 | #define EXYNOS4210_GIC_DIST_REGION_SIZE 0x1000 | ||
408 | |||
409 | -/* | ||
410 | - * Initialize board IRQs. | ||
411 | - * These IRQs contain splitted Int/External Combiner and External Gic IRQs. | ||
412 | - */ | ||
413 | -void exynos4210_init_board_irqs(Exynos4210State *s) | ||
414 | -{ | ||
415 | - uint32_t grp, bit, irq_id, n; | ||
416 | - Exynos4210Irq *is = &s->irqs; | ||
417 | - | ||
418 | - for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { | ||
419 | - irq_id = 0; | ||
420 | - if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 4) || | ||
421 | - n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4)) { | ||
422 | - /* MCT_G0 is passed to External GIC */ | ||
423 | - irq_id = EXT_GIC_ID_MCT_G0; | ||
424 | - } | ||
425 | - if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 5) || | ||
426 | - n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 5)) { | ||
427 | - /* MCT_G1 is passed to External and GIC */ | ||
428 | - irq_id = EXT_GIC_ID_MCT_G1; | ||
429 | - } | ||
430 | - if (irq_id) { | ||
431 | - s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
432 | - is->ext_gic_irq[irq_id - 32]); | ||
433 | - } else { | ||
434 | - s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
435 | - is->ext_combiner_irq[n]); | ||
436 | - } | ||
437 | - } | ||
438 | - for (; n < EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; n++) { | ||
439 | - /* these IDs are passed to Internal Combiner and External GIC */ | ||
440 | - grp = EXYNOS4210_COMBINER_GET_GRP_NUM(n); | ||
441 | - bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n); | ||
442 | - irq_id = combiner_grp_to_gic_id[grp - | ||
443 | - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][bit]; | ||
444 | - | ||
445 | - if (irq_id) { | ||
446 | - s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
447 | - is->ext_gic_irq[irq_id - 32]); | ||
448 | - } | ||
449 | - } | ||
450 | -} | ||
451 | - | ||
452 | -/* | ||
453 | - * Get IRQ number from exynos4210 IRQ subsystem stub. | ||
454 | - * To identify IRQ source use internal combiner group and bit number | ||
455 | - * grp - group number | ||
456 | - * bit - bit number inside group | ||
457 | - */ | ||
458 | -uint32_t exynos4210_get_irq(uint32_t grp, uint32_t bit) | ||
459 | -{ | ||
460 | - return EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit); | ||
461 | -} | ||
462 | - | ||
463 | -/********* GIC part *********/ | ||
464 | - | ||
465 | #define TYPE_EXYNOS4210_GIC "exynos4210.gic" | ||
466 | OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210GicState, EXYNOS4210_GIC) | ||
467 | 27 | ||
468 | -- | 28 | -- |
469 | 2.25.1 | 29 | 2.34.1 |
30 | |||
31 | diff view generated by jsdifflib |
1 | The function exynos4210_combiner_get_gpioin() currently lives in | 1 | The hw/arm/boot.h include in common-semi-target.h is not actually |
---|---|---|---|
2 | exynos4210_combiner.c, but it isn't really part of the combiner | 2 | needed, and it's a bit odd because it pulls a hw/arm header into a |
3 | device itself -- it is a function that implements the wiring up of | 3 | target/arm file. |
4 | some interrupt sources to multiple combiner inputs. Move it to live | 4 | |
5 | with the other SoC-level code in exynos4210.c, along with a few | 5 | This include was originally needed because the semihosting code used |
6 | macros previously defined in exynos4210.h which are now used only | 6 | the arm_boot_info struct to get the base address of the RAM in system |
7 | in exynos4210.c. | 7 | emulation, to use in a (bad) heuristic for the return values for the |
8 | SYS_HEAPINFO semihosting call. We've since overhauled how we | ||
9 | calculate the HEAPINFO values in system emulation, and the code no | ||
10 | longer uses the arm_boot_info struct. | ||
11 | |||
12 | Remove the now-redundant include line, and instead directly include | ||
13 | the cpu-qom.h header that we were previously getting via boot.h. | ||
8 | 14 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Message-id: 20220404154658.565020-11-peter.maydell@linaro.org | 17 | Message-id: 20230925112219.3919261-1-peter.maydell@linaro.org |
12 | --- | 18 | --- |
13 | include/hw/arm/exynos4210.h | 11 ----- | 19 | target/arm/common-semi-target.h | 4 +--- |
14 | hw/arm/exynos4210.c | 82 +++++++++++++++++++++++++++++++++++ | 20 | 1 file changed, 1 insertion(+), 3 deletions(-) |
15 | hw/intc/exynos4210_combiner.c | 77 -------------------------------- | ||
16 | 3 files changed, 82 insertions(+), 88 deletions(-) | ||
17 | 21 | ||
18 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | 22 | diff --git a/target/arm/common-semi-target.h b/target/arm/common-semi-target.h |
19 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/include/hw/arm/exynos4210.h | 24 | --- a/target/arm/common-semi-target.h |
21 | +++ b/include/hw/arm/exynos4210.h | 25 | +++ b/target/arm/common-semi-target.h |
22 | @@ -XXX,XX +XXX,XX @@ | 26 | @@ -XXX,XX +XXX,XX @@ |
23 | #define EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ \ | 27 | #ifndef TARGET_ARM_COMMON_SEMI_TARGET_H |
24 | (EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ * 8) | 28 | #define TARGET_ARM_COMMON_SEMI_TARGET_H |
25 | 29 | ||
26 | -#define EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit) ((grp)*8 + (bit)) | 30 | -#ifndef CONFIG_USER_ONLY |
27 | -#define EXYNOS4210_COMBINER_GET_GRP_NUM(irq) ((irq) / 8) | 31 | -#include "hw/arm/boot.h" |
28 | -#define EXYNOS4210_COMBINER_GET_BIT_NUM(irq) \ | 32 | -#endif |
29 | - ((irq) - 8 * EXYNOS4210_COMBINER_GET_GRP_NUM(irq)) | 33 | +#include "target/arm/cpu-qom.h" |
30 | - | 34 | |
31 | /* IRQs number for external and internal GIC */ | 35 | static inline target_ulong common_semi_arg(CPUState *cs, int argno) |
32 | #define EXYNOS4210_EXT_GIC_NIRQ (160-32) | ||
33 | #define EXYNOS4210_INT_GIC_NIRQ 64 | ||
34 | @@ -XXX,XX +XXX,XX @@ void exynos4210_write_secondary(ARMCPU *cpu, | ||
35 | * bit - bit number inside group */ | ||
36 | uint32_t exynos4210_get_irq(uint32_t grp, uint32_t bit); | ||
37 | |||
38 | -/* | ||
39 | - * Get Combiner input GPIO into irqs structure | ||
40 | - */ | ||
41 | -void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, DeviceState *dev, | ||
42 | - int ext); | ||
43 | - | ||
44 | /* | ||
45 | * exynos4210 UART | ||
46 | */ | ||
47 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/hw/arm/exynos4210.c | ||
50 | +++ b/hw/arm/exynos4210.c | ||
51 | @@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | ||
52 | { }, { }, { }, { }, { }, { }, { }, { }, { }, { } | ||
53 | }; | ||
54 | |||
55 | +#define EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit) ((grp) * 8 + (bit)) | ||
56 | +#define EXYNOS4210_COMBINER_GET_GRP_NUM(irq) ((irq) / 8) | ||
57 | +#define EXYNOS4210_COMBINER_GET_BIT_NUM(irq) \ | ||
58 | + ((irq) - 8 * EXYNOS4210_COMBINER_GET_GRP_NUM(irq)) | ||
59 | + | ||
60 | /* | ||
61 | * Initialize board IRQs. | ||
62 | * These IRQs contain splitted Int/External Combiner and External Gic IRQs. | ||
63 | @@ -XXX,XX +XXX,XX @@ uint32_t exynos4210_get_irq(uint32_t grp, uint32_t bit) | ||
64 | return EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit); | ||
65 | } | ||
66 | |||
67 | +/* | ||
68 | + * Get Combiner input GPIO into irqs structure | ||
69 | + */ | ||
70 | +static void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, | ||
71 | + DeviceState *dev, int ext) | ||
72 | +{ | ||
73 | + int n; | ||
74 | + int bit; | ||
75 | + int max; | ||
76 | + qemu_irq *irq; | ||
77 | + | ||
78 | + max = ext ? EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ : | ||
79 | + EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; | ||
80 | + irq = ext ? irqs->ext_combiner_irq : irqs->int_combiner_irq; | ||
81 | + | ||
82 | + /* | ||
83 | + * Some IRQs of Int/External Combiner are going to two Combiners groups, | ||
84 | + * so let split them. | ||
85 | + */ | ||
86 | + for (n = 0; n < max; n++) { | ||
87 | + | ||
88 | + bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n); | ||
89 | + | ||
90 | + switch (n) { | ||
91 | + /* MDNIE_LCD1 INTG1 */ | ||
92 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 0) ... | ||
93 | + EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 3): | ||
94 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
95 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(0, bit + 4)]); | ||
96 | + continue; | ||
97 | + | ||
98 | + /* TMU INTG3 */ | ||
99 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(3, 4): | ||
100 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
101 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(2, bit)]); | ||
102 | + continue; | ||
103 | + | ||
104 | + /* LCD1 INTG12 */ | ||
105 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 0) ... | ||
106 | + EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 3): | ||
107 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
108 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(11, bit + 4)]); | ||
109 | + continue; | ||
110 | + | ||
111 | + /* Multi-Core Timer INTG12 */ | ||
112 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4) ... | ||
113 | + EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 8): | ||
114 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
115 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
116 | + continue; | ||
117 | + | ||
118 | + /* Multi-Core Timer INTG35 */ | ||
119 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 4) ... | ||
120 | + EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 8): | ||
121 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
122 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
123 | + continue; | ||
124 | + | ||
125 | + /* Multi-Core Timer INTG51 */ | ||
126 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(51, 4) ... | ||
127 | + EXYNOS4210_COMBINER_GET_IRQ_NUM(51, 8): | ||
128 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
129 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
130 | + continue; | ||
131 | + | ||
132 | + /* Multi-Core Timer INTG53 */ | ||
133 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(53, 4) ... | ||
134 | + EXYNOS4210_COMBINER_GET_IRQ_NUM(53, 8): | ||
135 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
136 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
137 | + continue; | ||
138 | + } | ||
139 | + | ||
140 | + irq[n] = qdev_get_gpio_in(dev, n); | ||
141 | + } | ||
142 | +} | ||
143 | + | ||
144 | static uint8_t chipid_and_omr[] = { 0x11, 0x02, 0x21, 0x43, | ||
145 | 0x09, 0x00, 0x00, 0x00 }; | ||
146 | |||
147 | diff --git a/hw/intc/exynos4210_combiner.c b/hw/intc/exynos4210_combiner.c | ||
148 | index XXXXXXX..XXXXXXX 100644 | ||
149 | --- a/hw/intc/exynos4210_combiner.c | ||
150 | +++ b/hw/intc/exynos4210_combiner.c | ||
151 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_exynos4210_combiner = { | ||
152 | } | ||
153 | }; | ||
154 | |||
155 | -/* | ||
156 | - * Get Combiner input GPIO into irqs structure | ||
157 | - */ | ||
158 | -void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, DeviceState *dev, | ||
159 | - int ext) | ||
160 | -{ | ||
161 | - int n; | ||
162 | - int bit; | ||
163 | - int max; | ||
164 | - qemu_irq *irq; | ||
165 | - | ||
166 | - max = ext ? EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ : | ||
167 | - EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; | ||
168 | - irq = ext ? irqs->ext_combiner_irq : irqs->int_combiner_irq; | ||
169 | - | ||
170 | - /* | ||
171 | - * Some IRQs of Int/External Combiner are going to two Combiners groups, | ||
172 | - * so let split them. | ||
173 | - */ | ||
174 | - for (n = 0; n < max; n++) { | ||
175 | - | ||
176 | - bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n); | ||
177 | - | ||
178 | - switch (n) { | ||
179 | - /* MDNIE_LCD1 INTG1 */ | ||
180 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 0) ... | ||
181 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 3): | ||
182 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
183 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(0, bit + 4)]); | ||
184 | - continue; | ||
185 | - | ||
186 | - /* TMU INTG3 */ | ||
187 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(3, 4): | ||
188 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
189 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(2, bit)]); | ||
190 | - continue; | ||
191 | - | ||
192 | - /* LCD1 INTG12 */ | ||
193 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 0) ... | ||
194 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 3): | ||
195 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
196 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(11, bit + 4)]); | ||
197 | - continue; | ||
198 | - | ||
199 | - /* Multi-Core Timer INTG12 */ | ||
200 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4) ... | ||
201 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 8): | ||
202 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
203 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
204 | - continue; | ||
205 | - | ||
206 | - /* Multi-Core Timer INTG35 */ | ||
207 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 4) ... | ||
208 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 8): | ||
209 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
210 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
211 | - continue; | ||
212 | - | ||
213 | - /* Multi-Core Timer INTG51 */ | ||
214 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(51, 4) ... | ||
215 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(51, 8): | ||
216 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
217 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
218 | - continue; | ||
219 | - | ||
220 | - /* Multi-Core Timer INTG53 */ | ||
221 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(53, 4) ... | ||
222 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(53, 8): | ||
223 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
224 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
225 | - continue; | ||
226 | - } | ||
227 | - | ||
228 | - irq[n] = qdev_get_gpio_in(dev, n); | ||
229 | - } | ||
230 | -} | ||
231 | - | ||
232 | static uint64_t | ||
233 | exynos4210_combiner_read(void *opaque, hwaddr offset, unsigned size) | ||
234 | { | 36 | { |
235 | -- | 37 | -- |
236 | 2.25.1 | 38 | 2.34.1 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> | 1 | The code for powering on a CPU in arm-powerctl.c has two separate |
---|---|---|---|
2 | 2 | use cases: | |
3 | Connect the CRL (Clock Reset LPD) to the Versal SoC. | 3 | * emulation of a real hardware power controller |
4 | 4 | * emulation of firmware interfaces (primarily PSCI) with | |
5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> | 5 | CPU on/off APIs |
6 | Reviewed-by: Frederic Konrad <fkonrad@amd.com> | 6 | |
7 | Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com> | 7 | For the first case, we only need to reset the CPU and set its |
8 | Message-id: 20220406174303.2022038-5-edgar.iglesias@xilinx.com | 8 | starting PC and X0. For the second case, because we're emulating the |
9 | firmware we need to ensure that it's in the state that the firmware | ||
10 | provides. In particular, when we reset to a lower EL than the | ||
11 | highest one we are emulating, we need to put the CPU into a state | ||
12 | that permits correct running at that lower EL. We already do a | ||
13 | little of this in arm-powerctl.c (for instance we set SCR_HCE to | ||
14 | enable the HVC insn) but we don't do enough of it. This means that | ||
15 | in the case where we are emulating EL3 but also providing emulated | ||
16 | PSCI the guest will crash when a secondary core tries to use a | ||
17 | feature that needs an SCR_EL3 bit to be set, such as MTE or PAuth. | ||
18 | |||
19 | The hw/arm/boot.c code also has to support this "start guest code in | ||
20 | an EL that's lower than the highest emulated EL" case in order to do | ||
21 | direct guest kernel booting; it has all the necessary initialization | ||
22 | code to set the SCR_EL3 bits. Pull the relevant boot.c code out into | ||
23 | a separate function so we can share it between there and | ||
24 | arm-powerctl.c. | ||
25 | |||
26 | This refactoring has a few code changes that look like they | ||
27 | might be behaviour changes but aren't: | ||
28 | * if info->secure_boot is false and info->secure_board_setup is | ||
29 | true, then the old code would start the first CPU in Hyp | ||
30 | mode but without changing SCR.NS and NSACR.{CP11,CP10}. | ||
31 | This was wrong behaviour because there's no such thing | ||
32 | as Secure Hyp mode. The new code will leave the CPU in SVC. | ||
33 | (There is no board which sets secure_boot to false and | ||
34 | secure_board_setup to true, so this isn't a behaviour | ||
35 | change for any of our boards.) | ||
36 | * we don't explicitly clear SCR.NS when arm-powerctl.c | ||
37 | does a CPU-on to EL3. This was a no-op because CPU reset | ||
38 | will reset to NS == 0. | ||
39 | |||
40 | And some real behaviour changes: | ||
41 | * we no longer set HCR_EL2.RW when booting into EL2: the guest | ||
42 | can and should do that themselves before dropping into their | ||
43 | EL1 code. (arm-powerctl and boot did this differently; I | ||
44 | opted to use the logic from arm-powerctl, which only sets | ||
45 | HCR_EL2.RW when it's directly starting the guest in EL1, | ||
46 | because it's more correct, and I don't expect guests to be | ||
47 | accidentally depending on our having set the RW bit for them.) | ||
48 | * if we are booting a CPU into AArch32 Secure SVC then we won't | ||
49 | set SCR.HCE any more. This affects only the vexpress-a15 and | ||
50 | raspi2b machine types. Guests booting in this case will either: | ||
51 | - be able to set SCR.HCE themselves as part of moving from | ||
52 | Secure SVC into NS Hyp mode | ||
53 | - will move from Secure SVC to NS SVC, and won't care about | ||
54 | behaviour of the HVC insn | ||
55 | - will stay in Secure SVC, and won't care about HVC | ||
56 | * on an arm-powerctl CPU-on we will now set the SCR bits for | ||
57 | pauth/mte/sve/sme/hcx/fgt features | ||
58 | |||
59 | The first two of these are very minor and I don't expect guest | ||
60 | code to trip over them, so I didn't judge it worth convoluting | ||
61 | the code in an attempt to keep exactly the same boot.c behaviour. | ||
62 | The third change fixes issue 1899. | ||
63 | |||
64 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1899 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 65 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
66 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
67 | Message-id: 20230926155619.4028618-1-peter.maydell@linaro.org | ||
10 | --- | 68 | --- |
11 | include/hw/arm/xlnx-versal.h | 4 +++ | 69 | target/arm/cpu.h | 22 +++++++++ |
12 | hw/arm/xlnx-versal.c | 54 ++++++++++++++++++++++++++++++++++-- | 70 | hw/arm/boot.c | 95 ++++++++++----------------------------- |
13 | 2 files changed, 56 insertions(+), 2 deletions(-) | 71 | target/arm/arm-powerctl.c | 53 +--------------------- |
14 | 72 | target/arm/cpu.c | 95 +++++++++++++++++++++++++++++++++++++++ | |
15 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h | 73 | 4 files changed, 141 insertions(+), 124 deletions(-) |
74 | |||
75 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | 76 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/include/hw/arm/xlnx-versal.h | 77 | --- a/target/arm/cpu.h |
18 | +++ b/include/hw/arm/xlnx-versal.h | 78 | +++ b/target/arm/cpu.h |
19 | @@ -XXX,XX +XXX,XX @@ | 79 | @@ -XXX,XX +XXX,XX @@ int arm_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, |
20 | #include "hw/nvram/xlnx-versal-efuse.h" | 80 | int arm_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs, |
21 | #include "hw/ssi/xlnx-versal-ospi.h" | 81 | int cpuid, DumpState *s); |
22 | #include "hw/dma/xlnx_csu_dma.h" | 82 | |
23 | +#include "hw/misc/xlnx-versal-crl.h" | 83 | +/** |
24 | #include "hw/misc/xlnx-versal-pmc-iou-slcr.h" | 84 | + * arm_emulate_firmware_reset: Emulate firmware CPU reset handling |
25 | 85 | + * @cpu: CPU (which must have been freshly reset) | |
26 | #define TYPE_XLNX_VERSAL "xlnx-versal" | 86 | + * @target_el: exception level to put the CPU into |
27 | @@ -XXX,XX +XXX,XX @@ struct Versal { | 87 | + * @secure: whether to put the CPU in secure state |
28 | qemu_or_irq irq_orgate; | 88 | + * |
29 | XlnxXramCtrl ctrl[XLNX_VERSAL_NR_XRAM]; | 89 | + * When QEMU is directly running a guest kernel at a lower level than |
30 | } xram; | 90 | + * EL3 it implicitly emulates some aspects of the guest firmware. |
31 | + | 91 | + * This includes that on reset we need to configure the parts of the |
32 | + XlnxVersalCRL crl; | 92 | + * CPU corresponding to EL3 so that the real guest code can run at its |
33 | } lpd; | 93 | + * lower exception level. This function does that post-reset CPU setup, |
34 | 94 | + * for when we do direct boot of a guest kernel, and for when we | |
35 | /* The Platform Management Controller subsystem. */ | 95 | + * emulate PSCI and similar firmware interfaces starting a CPU at a |
36 | @@ -XXX,XX +XXX,XX @@ struct Versal { | 96 | + * lower exception level. |
37 | #define VERSAL_TIMER_NS_EL1_IRQ 14 | 97 | + * |
38 | #define VERSAL_TIMER_NS_EL2_IRQ 10 | 98 | + * @target_el must be an EL implemented by the CPU between 1 and 3. |
39 | 99 | + * We do not support dropping into a Secure EL other than 3. | |
40 | +#define VERSAL_CRL_IRQ 10 | 100 | + * |
41 | #define VERSAL_UART0_IRQ_0 18 | 101 | + * It is the responsibility of the caller to call arm_rebuild_hflags(). |
42 | #define VERSAL_UART1_IRQ_0 19 | 102 | + */ |
43 | #define VERSAL_USB0_IRQ_0 22 | 103 | +void arm_emulate_firmware_reset(CPUState *cpustate, int target_el); |
44 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c | 104 | + |
105 | #ifdef TARGET_AARCH64 | ||
106 | int aarch64_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); | ||
107 | int aarch64_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); | ||
108 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | 109 | index XXXXXXX..XXXXXXX 100644 |
46 | --- a/hw/arm/xlnx-versal.c | 110 | --- a/hw/arm/boot.c |
47 | +++ b/hw/arm/xlnx-versal.c | 111 | +++ b/hw/arm/boot.c |
48 | @@ -XXX,XX +XXX,XX @@ static void versal_create_ospi(Versal *s, qemu_irq *pic) | 112 | @@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque) |
49 | qdev_connect_gpio_out(orgate, 0, pic[VERSAL_OSPI_IRQ]); | 113 | |
114 | cpu_set_pc(cs, entry); | ||
115 | } else { | ||
116 | - /* If we are booting Linux then we need to check whether we are | ||
117 | - * booting into secure or non-secure state and adjust the state | ||
118 | - * accordingly. Out of reset, ARM is defined to be in secure state | ||
119 | - * (SCR.NS = 0), we change that here if non-secure boot has been | ||
120 | - * requested. | ||
121 | + /* | ||
122 | + * If we are booting Linux then we might need to do so at: | ||
123 | + * - AArch64 NS EL2 or NS EL1 | ||
124 | + * - AArch32 Secure SVC (EL3) | ||
125 | + * - AArch32 NS Hyp (EL2) | ||
126 | + * - AArch32 NS SVC (EL1) | ||
127 | + * Configure the CPU in the way boot firmware would do to | ||
128 | + * drop us down to the appropriate level. | ||
129 | */ | ||
130 | - if (arm_feature(env, ARM_FEATURE_EL3)) { | ||
131 | - /* AArch64 is defined to come out of reset into EL3 if enabled. | ||
132 | - * If we are booting Linux then we need to adjust our EL as | ||
133 | - * Linux expects us to be in EL2 or EL1. AArch32 resets into | ||
134 | - * SVC, which Linux expects, so no privilege/exception level to | ||
135 | - * adjust. | ||
136 | - */ | ||
137 | - if (env->aarch64) { | ||
138 | - env->cp15.scr_el3 |= SCR_RW; | ||
139 | - if (arm_feature(env, ARM_FEATURE_EL2)) { | ||
140 | - env->cp15.hcr_el2 |= HCR_RW; | ||
141 | - env->pstate = PSTATE_MODE_EL2h; | ||
142 | - } else { | ||
143 | - env->pstate = PSTATE_MODE_EL1h; | ||
144 | - } | ||
145 | - if (cpu_isar_feature(aa64_pauth, cpu)) { | ||
146 | - env->cp15.scr_el3 |= SCR_API | SCR_APK; | ||
147 | - } | ||
148 | - if (cpu_isar_feature(aa64_mte, cpu)) { | ||
149 | - env->cp15.scr_el3 |= SCR_ATA; | ||
150 | - } | ||
151 | - if (cpu_isar_feature(aa64_sve, cpu)) { | ||
152 | - env->cp15.cptr_el[3] |= R_CPTR_EL3_EZ_MASK; | ||
153 | - env->vfp.zcr_el[3] = 0xf; | ||
154 | - } | ||
155 | - if (cpu_isar_feature(aa64_sme, cpu)) { | ||
156 | - env->cp15.cptr_el[3] |= R_CPTR_EL3_ESM_MASK; | ||
157 | - env->cp15.scr_el3 |= SCR_ENTP2; | ||
158 | - env->vfp.smcr_el[3] = 0xf; | ||
159 | - } | ||
160 | - if (cpu_isar_feature(aa64_hcx, cpu)) { | ||
161 | - env->cp15.scr_el3 |= SCR_HXEN; | ||
162 | - } | ||
163 | - if (cpu_isar_feature(aa64_fgt, cpu)) { | ||
164 | - env->cp15.scr_el3 |= SCR_FGTEN; | ||
165 | - } | ||
166 | + int target_el = arm_feature(env, ARM_FEATURE_EL2) ? 2 : 1; | ||
167 | |||
168 | - /* AArch64 kernels never boot in secure mode */ | ||
169 | - assert(!info->secure_boot); | ||
170 | - /* This hook is only supported for AArch32 currently: | ||
171 | - * bootloader_aarch64[] will not call the hook, and | ||
172 | - * the code above has already dropped us into EL2 or EL1. | ||
173 | - */ | ||
174 | - assert(!info->secure_board_setup); | ||
175 | - } | ||
176 | - | ||
177 | - if (arm_feature(env, ARM_FEATURE_EL2)) { | ||
178 | - /* If we have EL2 then Linux expects the HVC insn to work */ | ||
179 | - env->cp15.scr_el3 |= SCR_HCE; | ||
180 | - } | ||
181 | - | ||
182 | - /* Set to non-secure if not a secure boot */ | ||
183 | - if (!info->secure_boot && | ||
184 | - (cs != first_cpu || !info->secure_board_setup)) { | ||
185 | - /* Linux expects non-secure state */ | ||
186 | - env->cp15.scr_el3 |= SCR_NS; | ||
187 | - /* Set NSACR.{CP11,CP10} so NS can access the FPU */ | ||
188 | - env->cp15.nsacr |= 3 << 10; | ||
189 | - } | ||
190 | - } | ||
191 | - | ||
192 | - if (!env->aarch64 && !info->secure_boot && | ||
193 | - arm_feature(env, ARM_FEATURE_EL2)) { | ||
194 | + if (env->aarch64) { | ||
195 | /* | ||
196 | - * This is an AArch32 boot not to Secure state, and | ||
197 | - * we have Hyp mode available, so boot the kernel into | ||
198 | - * Hyp mode. This is not how the CPU comes out of reset, | ||
199 | - * so we need to manually put it there. | ||
200 | + * AArch64 kernels never boot in secure mode, and we don't | ||
201 | + * support the secure_board_setup hook for AArch64. | ||
202 | */ | ||
203 | - cpsr_write(env, ARM_CPU_MODE_HYP, CPSR_M, CPSRWriteRaw); | ||
204 | + assert(!info->secure_boot); | ||
205 | + assert(!info->secure_board_setup); | ||
206 | + } else { | ||
207 | + if (arm_feature(env, ARM_FEATURE_EL3) && | ||
208 | + (info->secure_boot || | ||
209 | + (info->secure_board_setup && cs == first_cpu))) { | ||
210 | + /* Start this CPU in Secure SVC */ | ||
211 | + target_el = 3; | ||
212 | + } | ||
213 | } | ||
214 | |||
215 | + arm_emulate_firmware_reset(cs, target_el); | ||
216 | + | ||
217 | if (cs == first_cpu) { | ||
218 | AddressSpace *as = arm_boot_address_space(cpu, info); | ||
219 | |||
220 | diff --git a/target/arm/arm-powerctl.c b/target/arm/arm-powerctl.c | ||
221 | index XXXXXXX..XXXXXXX 100644 | ||
222 | --- a/target/arm/arm-powerctl.c | ||
223 | +++ b/target/arm/arm-powerctl.c | ||
224 | @@ -XXX,XX +XXX,XX @@ static void arm_set_cpu_on_async_work(CPUState *target_cpu_state, | ||
225 | |||
226 | /* Initialize the cpu we are turning on */ | ||
227 | cpu_reset(target_cpu_state); | ||
228 | + arm_emulate_firmware_reset(target_cpu_state, info->target_el); | ||
229 | target_cpu_state->halted = 0; | ||
230 | |||
231 | - if (info->target_aa64) { | ||
232 | - if ((info->target_el < 3) && arm_feature(&target_cpu->env, | ||
233 | - ARM_FEATURE_EL3)) { | ||
234 | - /* | ||
235 | - * As target mode is AArch64, we need to set lower | ||
236 | - * exception level (the requested level 2) to AArch64 | ||
237 | - */ | ||
238 | - target_cpu->env.cp15.scr_el3 |= SCR_RW; | ||
239 | - } | ||
240 | - | ||
241 | - if ((info->target_el < 2) && arm_feature(&target_cpu->env, | ||
242 | - ARM_FEATURE_EL2)) { | ||
243 | - /* | ||
244 | - * As target mode is AArch64, we need to set lower | ||
245 | - * exception level (the requested level 1) to AArch64 | ||
246 | - */ | ||
247 | - target_cpu->env.cp15.hcr_el2 |= HCR_RW; | ||
248 | - } | ||
249 | - | ||
250 | - target_cpu->env.pstate = aarch64_pstate_mode(info->target_el, true); | ||
251 | - } else { | ||
252 | - /* We are requested to boot in AArch32 mode */ | ||
253 | - static const uint32_t mode_for_el[] = { 0, | ||
254 | - ARM_CPU_MODE_SVC, | ||
255 | - ARM_CPU_MODE_HYP, | ||
256 | - ARM_CPU_MODE_SVC }; | ||
257 | - | ||
258 | - cpsr_write(&target_cpu->env, mode_for_el[info->target_el], CPSR_M, | ||
259 | - CPSRWriteRaw); | ||
260 | - } | ||
261 | - | ||
262 | - if (info->target_el == 3) { | ||
263 | - /* Processor is in secure mode */ | ||
264 | - target_cpu->env.cp15.scr_el3 &= ~SCR_NS; | ||
265 | - } else { | ||
266 | - /* Processor is not in secure mode */ | ||
267 | - target_cpu->env.cp15.scr_el3 |= SCR_NS; | ||
268 | - | ||
269 | - /* Set NSACR.{CP11,CP10} so NS can access the FPU */ | ||
270 | - target_cpu->env.cp15.nsacr |= 3 << 10; | ||
271 | - | ||
272 | - /* | ||
273 | - * If QEMU is providing the equivalent of EL3 firmware, then we need | ||
274 | - * to make sure a CPU targeting EL2 comes out of reset with a | ||
275 | - * functional HVC insn. | ||
276 | - */ | ||
277 | - if (arm_feature(&target_cpu->env, ARM_FEATURE_EL3) | ||
278 | - && info->target_el == 2) { | ||
279 | - target_cpu->env.cp15.scr_el3 |= SCR_HCE; | ||
280 | - } | ||
281 | - } | ||
282 | - | ||
283 | /* We check if the started CPU is now at the correct level */ | ||
284 | assert(info->target_el == arm_current_el(&target_cpu->env)); | ||
285 | |||
286 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
287 | index XXXXXXX..XXXXXXX 100644 | ||
288 | --- a/target/arm/cpu.c | ||
289 | +++ b/target/arm/cpu.c | ||
290 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset_hold(Object *obj) | ||
291 | } | ||
50 | } | 292 | } |
51 | 293 | ||
52 | +static void versal_create_crl(Versal *s, qemu_irq *pic) | 294 | +void arm_emulate_firmware_reset(CPUState *cpustate, int target_el) |
53 | +{ | 295 | +{ |
54 | + SysBusDevice *sbd; | 296 | + ARMCPU *cpu = ARM_CPU(cpustate); |
55 | + int i; | 297 | + CPUARMState *env = &cpu->env; |
56 | + | 298 | + bool have_el3 = arm_feature(env, ARM_FEATURE_EL3); |
57 | + object_initialize_child(OBJECT(s), "crl", &s->lpd.crl, | 299 | + bool have_el2 = arm_feature(env, ARM_FEATURE_EL2); |
58 | + TYPE_XLNX_VERSAL_CRL); | 300 | + |
59 | + sbd = SYS_BUS_DEVICE(&s->lpd.crl); | 301 | + /* |
60 | + | 302 | + * Check we have the EL we're aiming for. If that is the |
61 | + for (i = 0; i < ARRAY_SIZE(s->lpd.rpu.cpu); i++) { | 303 | + * highest implemented EL, then cpu_reset has already done |
62 | + g_autofree gchar *name = g_strdup_printf("cpu_r5[%d]", i); | 304 | + * all the work. |
63 | + | 305 | + */ |
64 | + object_property_set_link(OBJECT(&s->lpd.crl), | 306 | + switch (target_el) { |
65 | + name, OBJECT(&s->lpd.rpu.cpu[i]), | 307 | + case 3: |
66 | + &error_abort); | 308 | + assert(have_el3); |
309 | + return; | ||
310 | + case 2: | ||
311 | + assert(have_el2); | ||
312 | + if (!have_el3) { | ||
313 | + return; | ||
314 | + } | ||
315 | + break; | ||
316 | + case 1: | ||
317 | + if (!have_el3 && !have_el2) { | ||
318 | + return; | ||
319 | + } | ||
320 | + break; | ||
321 | + default: | ||
322 | + g_assert_not_reached(); | ||
67 | + } | 323 | + } |
68 | + | 324 | + |
69 | + for (i = 0; i < ARRAY_SIZE(s->lpd.iou.gem); i++) { | 325 | + if (have_el3) { |
70 | + g_autofree gchar *name = g_strdup_printf("gem[%d]", i); | 326 | + /* |
71 | + | 327 | + * Set the EL3 state so code can run at EL2. This should match |
72 | + object_property_set_link(OBJECT(&s->lpd.crl), | 328 | + * the requirements set by Linux in its booting spec. |
73 | + name, OBJECT(&s->lpd.iou.gem[i]), | 329 | + */ |
74 | + &error_abort); | 330 | + if (env->aarch64) { |
331 | + env->cp15.scr_el3 |= SCR_RW; | ||
332 | + if (cpu_isar_feature(aa64_pauth, cpu)) { | ||
333 | + env->cp15.scr_el3 |= SCR_API | SCR_APK; | ||
334 | + } | ||
335 | + if (cpu_isar_feature(aa64_mte, cpu)) { | ||
336 | + env->cp15.scr_el3 |= SCR_ATA; | ||
337 | + } | ||
338 | + if (cpu_isar_feature(aa64_sve, cpu)) { | ||
339 | + env->cp15.cptr_el[3] |= R_CPTR_EL3_EZ_MASK; | ||
340 | + env->vfp.zcr_el[3] = 0xf; | ||
341 | + } | ||
342 | + if (cpu_isar_feature(aa64_sme, cpu)) { | ||
343 | + env->cp15.cptr_el[3] |= R_CPTR_EL3_ESM_MASK; | ||
344 | + env->cp15.scr_el3 |= SCR_ENTP2; | ||
345 | + env->vfp.smcr_el[3] = 0xf; | ||
346 | + } | ||
347 | + if (cpu_isar_feature(aa64_hcx, cpu)) { | ||
348 | + env->cp15.scr_el3 |= SCR_HXEN; | ||
349 | + } | ||
350 | + if (cpu_isar_feature(aa64_fgt, cpu)) { | ||
351 | + env->cp15.scr_el3 |= SCR_FGTEN; | ||
352 | + } | ||
353 | + } | ||
354 | + | ||
355 | + if (target_el == 2) { | ||
356 | + /* If the guest is at EL2 then Linux expects the HVC insn to work */ | ||
357 | + env->cp15.scr_el3 |= SCR_HCE; | ||
358 | + } | ||
359 | + | ||
360 | + /* Put CPU into non-secure state */ | ||
361 | + env->cp15.scr_el3 |= SCR_NS; | ||
362 | + /* Set NSACR.{CP11,CP10} so NS can access the FPU */ | ||
363 | + env->cp15.nsacr |= 3 << 10; | ||
75 | + } | 364 | + } |
76 | + | 365 | + |
77 | + for (i = 0; i < ARRAY_SIZE(s->lpd.iou.adma); i++) { | 366 | + if (have_el2 && target_el < 2) { |
78 | + g_autofree gchar *name = g_strdup_printf("adma[%d]", i); | 367 | + /* Set EL2 state so code can run at EL1. */ |
79 | + | 368 | + if (env->aarch64) { |
80 | + object_property_set_link(OBJECT(&s->lpd.crl), | 369 | + env->cp15.hcr_el2 |= HCR_RW; |
81 | + name, OBJECT(&s->lpd.iou.adma[i]), | 370 | + } |
82 | + &error_abort); | ||
83 | + } | 371 | + } |
84 | + | 372 | + |
85 | + for (i = 0; i < ARRAY_SIZE(s->lpd.iou.uart); i++) { | 373 | + /* Set the CPU to the desired state */ |
86 | + g_autofree gchar *name = g_strdup_printf("uart[%d]", i); | 374 | + if (env->aarch64) { |
87 | + | 375 | + env->pstate = aarch64_pstate_mode(target_el, true); |
88 | + object_property_set_link(OBJECT(&s->lpd.crl), | 376 | + } else { |
89 | + name, OBJECT(&s->lpd.iou.uart[i]), | 377 | + static const uint32_t mode_for_el[] = { |
90 | + &error_abort); | 378 | + 0, |
379 | + ARM_CPU_MODE_SVC, | ||
380 | + ARM_CPU_MODE_HYP, | ||
381 | + ARM_CPU_MODE_SVC, | ||
382 | + }; | ||
383 | + | ||
384 | + cpsr_write(env, mode_for_el[target_el], CPSR_M, CPSRWriteRaw); | ||
91 | + } | 385 | + } |
92 | + | ||
93 | + object_property_set_link(OBJECT(&s->lpd.crl), | ||
94 | + "usb", OBJECT(&s->lpd.iou.usb), | ||
95 | + &error_abort); | ||
96 | + | ||
97 | + sysbus_realize(sbd, &error_fatal); | ||
98 | + memory_region_add_subregion(&s->mr_ps, MM_CRL, | ||
99 | + sysbus_mmio_get_region(sbd, 0)); | ||
100 | + sysbus_connect_irq(sbd, 0, pic[VERSAL_CRL_IRQ]); | ||
101 | +} | 386 | +} |
102 | + | 387 | + |
103 | /* This takes the board allocated linear DDR memory and creates aliases | 388 | + |
104 | * for each split DDR range/aperture on the Versal address map. | 389 | #if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY) |
105 | */ | 390 | |
106 | @@ -XXX,XX +XXX,XX @@ static void versal_unimp(Versal *s) | 391 | static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx, |
107 | |||
108 | versal_unimp_area(s, "psm", &s->mr_ps, | ||
109 | MM_PSM_START, MM_PSM_END - MM_PSM_START); | ||
110 | - versal_unimp_area(s, "crl", &s->mr_ps, | ||
111 | - MM_CRL, MM_CRL_SIZE); | ||
112 | versal_unimp_area(s, "crf", &s->mr_ps, | ||
113 | MM_FPD_CRF, MM_FPD_CRF_SIZE); | ||
114 | versal_unimp_area(s, "apu", &s->mr_ps, | ||
115 | @@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp) | ||
116 | versal_create_efuse(s, pic); | ||
117 | versal_create_pmc_iou_slcr(s, pic); | ||
118 | versal_create_ospi(s, pic); | ||
119 | + versal_create_crl(s, pic); | ||
120 | versal_map_ddr(s); | ||
121 | versal_unimp(s); | ||
122 | |||
123 | -- | 392 | -- |
124 | 2.25.1 | 393 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The Exynos4210 SoC device currently uses a custom device | ||
2 | "exynos4210.irq_gate" to model the OR gate that feeds each CPU's IRQ | ||
3 | line. We have a standard TYPE_OR_IRQ device for this now, so use | ||
4 | that instead. | ||
5 | 1 | ||
6 | (This is a migration compatibility break, but that is OK for this | ||
7 | machine type.) | ||
8 | |||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20220404154658.565020-2-peter.maydell@linaro.org | ||
12 | --- | ||
13 | include/hw/arm/exynos4210.h | 1 + | ||
14 | hw/arm/exynos4210.c | 31 ++++++++++++++++--------------- | ||
15 | 2 files changed, 17 insertions(+), 15 deletions(-) | ||
16 | |||
17 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/include/hw/arm/exynos4210.h | ||
20 | +++ b/include/hw/arm/exynos4210.h | ||
21 | @@ -XXX,XX +XXX,XX @@ struct Exynos4210State { | ||
22 | MemoryRegion bootreg_mem; | ||
23 | I2CBus *i2c_if[EXYNOS4210_I2C_NUMBER]; | ||
24 | qemu_or_irq pl330_irq_orgate[EXYNOS4210_NUM_DMA]; | ||
25 | + qemu_or_irq cpu_irq_orgate[EXYNOS4210_NCPUS]; | ||
26 | }; | ||
27 | |||
28 | #define TYPE_EXYNOS4210_SOC "exynos4210" | ||
29 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/hw/arm/exynos4210.c | ||
32 | +++ b/hw/arm/exynos4210.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
34 | { | ||
35 | Exynos4210State *s = EXYNOS4210_SOC(socdev); | ||
36 | MemoryRegion *system_mem = get_system_memory(); | ||
37 | - qemu_irq gate_irq[EXYNOS4210_NCPUS][EXYNOS4210_IRQ_GATE_NINPUTS]; | ||
38 | SysBusDevice *busdev; | ||
39 | DeviceState *dev, *uart[4], *pl330[3]; | ||
40 | int i, n; | ||
41 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
42 | |||
43 | /* IRQ Gate */ | ||
44 | for (i = 0; i < EXYNOS4210_NCPUS; i++) { | ||
45 | - dev = qdev_new("exynos4210.irq_gate"); | ||
46 | - qdev_prop_set_uint32(dev, "n_in", EXYNOS4210_IRQ_GATE_NINPUTS); | ||
47 | - sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); | ||
48 | - /* Get IRQ Gate input in gate_irq */ | ||
49 | - for (n = 0; n < EXYNOS4210_IRQ_GATE_NINPUTS; n++) { | ||
50 | - gate_irq[i][n] = qdev_get_gpio_in(dev, n); | ||
51 | - } | ||
52 | - busdev = SYS_BUS_DEVICE(dev); | ||
53 | - | ||
54 | - /* Connect IRQ Gate output to CPU's IRQ line */ | ||
55 | - sysbus_connect_irq(busdev, 0, | ||
56 | - qdev_get_gpio_in(DEVICE(s->cpu[i]), ARM_CPU_IRQ)); | ||
57 | + DeviceState *orgate = DEVICE(&s->cpu_irq_orgate[i]); | ||
58 | + object_property_set_int(OBJECT(orgate), "num-lines", | ||
59 | + EXYNOS4210_IRQ_GATE_NINPUTS, | ||
60 | + &error_abort); | ||
61 | + qdev_realize(orgate, NULL, &error_abort); | ||
62 | + qdev_connect_gpio_out(orgate, 0, | ||
63 | + qdev_get_gpio_in(DEVICE(s->cpu[i]), ARM_CPU_IRQ)); | ||
64 | } | ||
65 | |||
66 | /* Private memory region and Internal GIC */ | ||
67 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
68 | sysbus_realize_and_unref(busdev, &error_fatal); | ||
69 | sysbus_mmio_map(busdev, 0, EXYNOS4210_SMP_PRIVATE_BASE_ADDR); | ||
70 | for (n = 0; n < EXYNOS4210_NCPUS; n++) { | ||
71 | - sysbus_connect_irq(busdev, n, gate_irq[n][0]); | ||
72 | + sysbus_connect_irq(busdev, n, | ||
73 | + qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 0)); | ||
74 | } | ||
75 | for (n = 0; n < EXYNOS4210_INT_GIC_NIRQ; n++) { | ||
76 | s->irqs.int_gic_irq[n] = qdev_get_gpio_in(dev, n); | ||
77 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
78 | /* Map Distributer interface */ | ||
79 | sysbus_mmio_map(busdev, 1, EXYNOS4210_EXT_GIC_DIST_BASE_ADDR); | ||
80 | for (n = 0; n < EXYNOS4210_NCPUS; n++) { | ||
81 | - sysbus_connect_irq(busdev, n, gate_irq[n][1]); | ||
82 | + sysbus_connect_irq(busdev, n, | ||
83 | + qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 1)); | ||
84 | } | ||
85 | for (n = 0; n < EXYNOS4210_EXT_GIC_NIRQ; n++) { | ||
86 | s->irqs.ext_gic_irq[n] = qdev_get_gpio_in(dev, n); | ||
87 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init(Object *obj) | ||
88 | object_initialize_child(obj, name, orgate, TYPE_OR_IRQ); | ||
89 | g_free(name); | ||
90 | } | ||
91 | + | ||
92 | + for (i = 0; i < ARRAY_SIZE(s->cpu_irq_orgate); i++) { | ||
93 | + g_autofree char *name = g_strdup_printf("cpu-irq-orgate%d", i); | ||
94 | + object_initialize_child(obj, name, &s->cpu_irq_orgate[i], TYPE_OR_IRQ); | ||
95 | + } | ||
96 | } | ||
97 | |||
98 | static void exynos4210_class_init(ObjectClass *klass, void *data) | ||
99 | -- | ||
100 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Now we have removed the only use of TYPE_EXYNOS4210_IRQ_GATE we can | ||
2 | delete the device entirely. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | ||
6 | Message-id: 20220404154658.565020-3-peter.maydell@linaro.org | ||
7 | --- | ||
8 | hw/intc/exynos4210_gic.c | 107 --------------------------------------- | ||
9 | 1 file changed, 107 deletions(-) | ||
10 | |||
11 | diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/hw/intc/exynos4210_gic.c | ||
14 | +++ b/hw/intc/exynos4210_gic.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_gic_register_types(void) | ||
16 | } | ||
17 | |||
18 | type_init(exynos4210_gic_register_types) | ||
19 | - | ||
20 | -/* IRQ OR Gate struct. | ||
21 | - * | ||
22 | - * This device models an OR gate. There are n_in input qdev gpio lines and one | ||
23 | - * output sysbus IRQ line. The output IRQ level is formed as OR between all | ||
24 | - * gpio inputs. | ||
25 | - */ | ||
26 | - | ||
27 | -#define TYPE_EXYNOS4210_IRQ_GATE "exynos4210.irq_gate" | ||
28 | -OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210IRQGateState, EXYNOS4210_IRQ_GATE) | ||
29 | - | ||
30 | -struct Exynos4210IRQGateState { | ||
31 | - SysBusDevice parent_obj; | ||
32 | - | ||
33 | - uint32_t n_in; /* inputs amount */ | ||
34 | - uint32_t *level; /* input levels */ | ||
35 | - qemu_irq out; /* output IRQ */ | ||
36 | -}; | ||
37 | - | ||
38 | -static Property exynos4210_irq_gate_properties[] = { | ||
39 | - DEFINE_PROP_UINT32("n_in", Exynos4210IRQGateState, n_in, 1), | ||
40 | - DEFINE_PROP_END_OF_LIST(), | ||
41 | -}; | ||
42 | - | ||
43 | -static const VMStateDescription vmstate_exynos4210_irq_gate = { | ||
44 | - .name = "exynos4210.irq_gate", | ||
45 | - .version_id = 2, | ||
46 | - .minimum_version_id = 2, | ||
47 | - .fields = (VMStateField[]) { | ||
48 | - VMSTATE_VBUFFER_UINT32(level, Exynos4210IRQGateState, 1, NULL, n_in), | ||
49 | - VMSTATE_END_OF_LIST() | ||
50 | - } | ||
51 | -}; | ||
52 | - | ||
53 | -/* Process a change in IRQ input. */ | ||
54 | -static void exynos4210_irq_gate_handler(void *opaque, int irq, int level) | ||
55 | -{ | ||
56 | - Exynos4210IRQGateState *s = (Exynos4210IRQGateState *)opaque; | ||
57 | - uint32_t i; | ||
58 | - | ||
59 | - assert(irq < s->n_in); | ||
60 | - | ||
61 | - s->level[irq] = level; | ||
62 | - | ||
63 | - for (i = 0; i < s->n_in; i++) { | ||
64 | - if (s->level[i] >= 1) { | ||
65 | - qemu_irq_raise(s->out); | ||
66 | - return; | ||
67 | - } | ||
68 | - } | ||
69 | - | ||
70 | - qemu_irq_lower(s->out); | ||
71 | -} | ||
72 | - | ||
73 | -static void exynos4210_irq_gate_reset(DeviceState *d) | ||
74 | -{ | ||
75 | - Exynos4210IRQGateState *s = EXYNOS4210_IRQ_GATE(d); | ||
76 | - | ||
77 | - memset(s->level, 0, s->n_in * sizeof(*s->level)); | ||
78 | -} | ||
79 | - | ||
80 | -/* | ||
81 | - * IRQ Gate initialization. | ||
82 | - */ | ||
83 | -static void exynos4210_irq_gate_init(Object *obj) | ||
84 | -{ | ||
85 | - Exynos4210IRQGateState *s = EXYNOS4210_IRQ_GATE(obj); | ||
86 | - SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
87 | - | ||
88 | - sysbus_init_irq(sbd, &s->out); | ||
89 | -} | ||
90 | - | ||
91 | -static void exynos4210_irq_gate_realize(DeviceState *dev, Error **errp) | ||
92 | -{ | ||
93 | - Exynos4210IRQGateState *s = EXYNOS4210_IRQ_GATE(dev); | ||
94 | - | ||
95 | - /* Allocate general purpose input signals and connect a handler to each of | ||
96 | - * them */ | ||
97 | - qdev_init_gpio_in(dev, exynos4210_irq_gate_handler, s->n_in); | ||
98 | - | ||
99 | - s->level = g_malloc0(s->n_in * sizeof(*s->level)); | ||
100 | -} | ||
101 | - | ||
102 | -static void exynos4210_irq_gate_class_init(ObjectClass *klass, void *data) | ||
103 | -{ | ||
104 | - DeviceClass *dc = DEVICE_CLASS(klass); | ||
105 | - | ||
106 | - dc->reset = exynos4210_irq_gate_reset; | ||
107 | - dc->vmsd = &vmstate_exynos4210_irq_gate; | ||
108 | - device_class_set_props(dc, exynos4210_irq_gate_properties); | ||
109 | - dc->realize = exynos4210_irq_gate_realize; | ||
110 | -} | ||
111 | - | ||
112 | -static const TypeInfo exynos4210_irq_gate_info = { | ||
113 | - .name = TYPE_EXYNOS4210_IRQ_GATE, | ||
114 | - .parent = TYPE_SYS_BUS_DEVICE, | ||
115 | - .instance_size = sizeof(Exynos4210IRQGateState), | ||
116 | - .instance_init = exynos4210_irq_gate_init, | ||
117 | - .class_init = exynos4210_irq_gate_class_init, | ||
118 | -}; | ||
119 | - | ||
120 | -static void exynos4210_irq_gate_register_types(void) | ||
121 | -{ | ||
122 | - type_register_static(&exynos4210_irq_gate_info); | ||
123 | -} | ||
124 | - | ||
125 | -type_init(exynos4210_irq_gate_register_types) | ||
126 | -- | ||
127 | 2.25.1 | diff view generated by jsdifflib |
1 | The exynos4210 code currently has two very similar arrays of IRQs: | 1 | From: Chris Rauer <crauer@google.com> |
---|---|---|---|
2 | 2 | ||
3 | * board_irqs is a field of the Exynos4210Irq struct which is filled | 3 | The counter register is only 24-bits and counts down. If the timer is |
4 | in by exynos4210_init_board_irqs() with the appropriate qemu_irqs | 4 | running but the qtimer to reset it hasn't fired off yet, there is a chance |
5 | for each IRQ the board/SoC can assert | 5 | the regster read can return an invalid result. |
6 | * irq_table is a set of qemu_irqs pointed to from the | ||
7 | Exynos4210State struct. It's allocated in exynos4210_init_irq, | ||
8 | and the only behaviour these irqs have is that they pass on the | ||
9 | level to the equivalent board_irqs[] irq | ||
10 | 6 | ||
11 | The extra indirection through irq_table is unnecessary, so coalesce | 7 | Signed-off-by: Chris Rauer <crauer@google.com> |
12 | these into a single irq_table[] array as a direct field in | 8 | Message-id: 20230922181411.2697135-1-crauer@google.com |
13 | Exynos4210State which exynos4210_init_board_irqs() fills in. | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/timer/npcm7xx_timer.c | 3 +++ | ||
13 | 1 file changed, 3 insertions(+) | ||
14 | 14 | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | diff --git a/hw/timer/npcm7xx_timer.c b/hw/timer/npcm7xx_timer.c |
16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
17 | Message-id: 20220404154658.565020-6-peter.maydell@linaro.org | ||
18 | --- | ||
19 | include/hw/arm/exynos4210.h | 8 ++------ | ||
20 | hw/arm/exynos4210.c | 6 +----- | ||
21 | hw/intc/exynos4210_gic.c | 32 ++++++++------------------------ | ||
22 | 3 files changed, 11 insertions(+), 35 deletions(-) | ||
23 | |||
24 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | ||
25 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/hw/arm/exynos4210.h | 17 | --- a/hw/timer/npcm7xx_timer.c |
27 | +++ b/include/hw/arm/exynos4210.h | 18 | +++ b/hw/timer/npcm7xx_timer.c |
28 | @@ -XXX,XX +XXX,XX @@ typedef struct Exynos4210Irq { | 19 | @@ -XXX,XX +XXX,XX @@ static int64_t npcm7xx_timer_count_to_ns(NPCM7xxTimer *t, uint32_t count) |
29 | qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | 20 | /* Convert a time interval in nanoseconds to a timer cycle count. */ |
30 | qemu_irq ext_combiner_irq[EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ]; | 21 | static uint32_t npcm7xx_timer_ns_to_count(NPCM7xxTimer *t, int64_t ns) |
31 | qemu_irq ext_gic_irq[EXYNOS4210_EXT_GIC_NIRQ]; | ||
32 | - qemu_irq board_irqs[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | ||
33 | } Exynos4210Irq; | ||
34 | |||
35 | struct Exynos4210State { | ||
36 | @@ -XXX,XX +XXX,XX @@ struct Exynos4210State { | ||
37 | /*< public >*/ | ||
38 | ARMCPU *cpu[EXYNOS4210_NCPUS]; | ||
39 | Exynos4210Irq irqs; | ||
40 | - qemu_irq *irq_table; | ||
41 | + qemu_irq irq_table[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | ||
42 | |||
43 | MemoryRegion chipid_mem; | ||
44 | MemoryRegion iram_mem; | ||
45 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210State, EXYNOS4210_SOC) | ||
46 | void exynos4210_write_secondary(ARMCPU *cpu, | ||
47 | const struct arm_boot_info *info); | ||
48 | |||
49 | -/* Initialize exynos4210 IRQ subsystem stub */ | ||
50 | -qemu_irq *exynos4210_init_irq(Exynos4210Irq *env); | ||
51 | - | ||
52 | /* Initialize board IRQs. | ||
53 | * These IRQs contain splitted Int/External Combiner and External Gic IRQs */ | ||
54 | -void exynos4210_init_board_irqs(Exynos4210Irq *s); | ||
55 | +void exynos4210_init_board_irqs(Exynos4210State *s); | ||
56 | |||
57 | /* Get IRQ number from exynos4210 IRQ subsystem stub. | ||
58 | * To identify IRQ source use internal combiner group and bit number | ||
59 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/hw/arm/exynos4210.c | ||
62 | +++ b/hw/arm/exynos4210.c | ||
63 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
64 | qdev_realize(DEVICE(cpuobj), NULL, &error_fatal); | ||
65 | } | ||
66 | |||
67 | - /*** IRQs ***/ | ||
68 | - | ||
69 | - s->irq_table = exynos4210_init_irq(&s->irqs); | ||
70 | - | ||
71 | /* IRQ Gate */ | ||
72 | for (i = 0; i < EXYNOS4210_NCPUS; i++) { | ||
73 | DeviceState *orgate = DEVICE(&s->cpu_irq_orgate[i]); | ||
74 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
75 | sysbus_mmio_map(busdev, 0, EXYNOS4210_EXT_COMBINER_BASE_ADDR); | ||
76 | |||
77 | /* Initialize board IRQs. */ | ||
78 | - exynos4210_init_board_irqs(&s->irqs); | ||
79 | + exynos4210_init_board_irqs(s); | ||
80 | |||
81 | /*** Memory ***/ | ||
82 | |||
83 | diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c | ||
84 | index XXXXXXX..XXXXXXX 100644 | ||
85 | --- a/hw/intc/exynos4210_gic.c | ||
86 | +++ b/hw/intc/exynos4210_gic.c | ||
87 | @@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64-EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | ||
88 | #define EXYNOS4210_GIC_CPU_REGION_SIZE 0x100 | ||
89 | #define EXYNOS4210_GIC_DIST_REGION_SIZE 0x1000 | ||
90 | |||
91 | -static void exynos4210_irq_handler(void *opaque, int irq, int level) | ||
92 | -{ | ||
93 | - Exynos4210Irq *s = (Exynos4210Irq *)opaque; | ||
94 | - | ||
95 | - /* Bypass */ | ||
96 | - qemu_set_irq(s->board_irqs[irq], level); | ||
97 | -} | ||
98 | - | ||
99 | -/* | ||
100 | - * Initialize exynos4210 IRQ subsystem stub. | ||
101 | - */ | ||
102 | -qemu_irq *exynos4210_init_irq(Exynos4210Irq *s) | ||
103 | -{ | ||
104 | - return qemu_allocate_irqs(exynos4210_irq_handler, s, | ||
105 | - EXYNOS4210_MAX_INT_COMBINER_IN_IRQ); | ||
106 | -} | ||
107 | - | ||
108 | /* | ||
109 | * Initialize board IRQs. | ||
110 | * These IRQs contain splitted Int/External Combiner and External Gic IRQs. | ||
111 | */ | ||
112 | -void exynos4210_init_board_irqs(Exynos4210Irq *s) | ||
113 | +void exynos4210_init_board_irqs(Exynos4210State *s) | ||
114 | { | 22 | { |
115 | uint32_t grp, bit, irq_id, n; | 23 | + if (ns < 0) { |
116 | + Exynos4210Irq *is = &s->irqs; | 24 | + return 0; |
117 | 25 | + } | |
118 | for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { | 26 | return clock_ns_to_ticks(t->ctrl->clock, ns) / |
119 | irq_id = 0; | 27 | npcm7xx_tcsr_prescaler(t->tcsr); |
120 | @@ -XXX,XX +XXX,XX @@ void exynos4210_init_board_irqs(Exynos4210Irq *s) | ||
121 | irq_id = EXT_GIC_ID_MCT_G1; | ||
122 | } | ||
123 | if (irq_id) { | ||
124 | - s->board_irqs[n] = qemu_irq_split(s->int_combiner_irq[n], | ||
125 | - s->ext_gic_irq[irq_id-32]); | ||
126 | + s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
127 | + is->ext_gic_irq[irq_id - 32]); | ||
128 | } else { | ||
129 | - s->board_irqs[n] = qemu_irq_split(s->int_combiner_irq[n], | ||
130 | - s->ext_combiner_irq[n]); | ||
131 | + s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
132 | + is->ext_combiner_irq[n]); | ||
133 | } | ||
134 | } | ||
135 | for (; n < EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; n++) { | ||
136 | @@ -XXX,XX +XXX,XX @@ void exynos4210_init_board_irqs(Exynos4210Irq *s) | ||
137 | EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][bit]; | ||
138 | |||
139 | if (irq_id) { | ||
140 | - s->board_irqs[n] = qemu_irq_split(s->int_combiner_irq[n], | ||
141 | - s->ext_gic_irq[irq_id-32]); | ||
142 | + s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
143 | + is->ext_gic_irq[irq_id - 32]); | ||
144 | } | ||
145 | } | ||
146 | } | 28 | } |
147 | -- | 29 | -- |
148 | 2.25.1 | 30 | 2.34.1 | diff view generated by jsdifflib |
1 | The exynos4210 SoC mostly creates its child devices as if it were | 1 | From: Suraj Shirvankar <surajshirvankar@gmail.com> |
---|---|---|---|
2 | board code. This includes the a9mpcore object. Switch that to a | ||
3 | new-style "embedded in the state struct" creation, because in the | ||
4 | next commit we're going to want to refer to the object again further | ||
5 | down in the exynos4210_realize() function. | ||
6 | 2 | ||
3 | QEMU coding style uses the glib memory allocation APIs, not | ||
4 | the raw libc malloc/free. Switch the allocation and free | ||
5 | calls in elf2dmp to use these functions (dropping the now-unneeded | ||
6 | checks for failure). | ||
7 | |||
8 | Signed-off-by: Suraj Shirvankar <surajshirvankar@gmail.com> | ||
9 | Message-id: 169753938460.23804.11418813007617535750-1@git.sr.ht | ||
10 | [PMM: also remove NULL checks from g_malloc() calls; | ||
11 | beef up commit message] | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20220404154658.565020-4-peter.maydell@linaro.org | ||
10 | --- | 14 | --- |
11 | include/hw/arm/exynos4210.h | 2 ++ | 15 | contrib/elf2dmp/addrspace.c | 7 ++----- |
12 | hw/arm/exynos4210.c | 11 ++++++----- | 16 | contrib/elf2dmp/main.c | 9 +++------ |
13 | 2 files changed, 8 insertions(+), 5 deletions(-) | 17 | contrib/elf2dmp/pdb.c | 19 ++++++++----------- |
18 | contrib/elf2dmp/qemu_elf.c | 7 ++----- | ||
19 | 4 files changed, 15 insertions(+), 27 deletions(-) | ||
14 | 20 | ||
15 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | 21 | diff --git a/contrib/elf2dmp/addrspace.c b/contrib/elf2dmp/addrspace.c |
16 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/include/hw/arm/exynos4210.h | 23 | --- a/contrib/elf2dmp/addrspace.c |
18 | +++ b/include/hw/arm/exynos4210.h | 24 | +++ b/contrib/elf2dmp/addrspace.c |
19 | @@ -XXX,XX +XXX,XX @@ | 25 | @@ -XXX,XX +XXX,XX @@ int pa_space_create(struct pa_space *ps, QEMU_Elf *qemu_elf) |
20 | 26 | } | |
21 | #include "hw/or-irq.h" | 27 | } |
22 | #include "hw/sysbus.h" | 28 | |
23 | +#include "hw/cpu/a9mpcore.h" | 29 | - ps->block = malloc(sizeof(*ps->block) * ps->block_nr); |
24 | #include "target/arm/cpu-qom.h" | 30 | - if (!ps->block) { |
25 | #include "qom/object.h" | 31 | - return 1; |
26 | 32 | - } | |
27 | @@ -XXX,XX +XXX,XX @@ struct Exynos4210State { | 33 | + ps->block = g_new(struct pa_block, ps->block_nr); |
28 | I2CBus *i2c_if[EXYNOS4210_I2C_NUMBER]; | 34 | |
29 | qemu_or_irq pl330_irq_orgate[EXYNOS4210_NUM_DMA]; | 35 | for (i = 0; i < phdr_nr; i++) { |
30 | qemu_or_irq cpu_irq_orgate[EXYNOS4210_NCPUS]; | 36 | if (phdr[i].p_type == PT_LOAD) { |
31 | + A9MPPrivState a9mpcore; | 37 | @@ -XXX,XX +XXX,XX @@ int pa_space_create(struct pa_space *ps, QEMU_Elf *qemu_elf) |
32 | }; | 38 | void pa_space_destroy(struct pa_space *ps) |
33 | 39 | { | |
34 | #define TYPE_EXYNOS4210_SOC "exynos4210" | 40 | ps->block_nr = 0; |
35 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | 41 | - free(ps->block); |
42 | + g_free(ps->block); | ||
43 | } | ||
44 | |||
45 | void va_space_set_dtb(struct va_space *vs, uint64_t dtb) | ||
46 | diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | 47 | index XXXXXXX..XXXXXXX 100644 |
37 | --- a/hw/arm/exynos4210.c | 48 | --- a/contrib/elf2dmp/main.c |
38 | +++ b/hw/arm/exynos4210.c | 49 | +++ b/contrib/elf2dmp/main.c |
39 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | 50 | @@ -XXX,XX +XXX,XX @@ static KDDEBUGGER_DATA64 *get_kdbg(uint64_t KernBase, struct pdb_reader *pdb, |
51 | } | ||
40 | } | 52 | } |
41 | 53 | ||
42 | /* Private memory region and Internal GIC */ | 54 | - kdbg = malloc(kdbg_hdr.Size); |
43 | - dev = qdev_new(TYPE_A9MPCORE_PRIV); | 55 | - if (!kdbg) { |
44 | - qdev_prop_set_uint32(dev, "num-cpu", EXYNOS4210_NCPUS); | 56 | - return NULL; |
45 | - busdev = SYS_BUS_DEVICE(dev); | 57 | - } |
46 | - sysbus_realize_and_unref(busdev, &error_fatal); | 58 | + kdbg = g_malloc(kdbg_hdr.Size); |
47 | + qdev_prop_set_uint32(DEVICE(&s->a9mpcore), "num-cpu", EXYNOS4210_NCPUS); | 59 | |
48 | + busdev = SYS_BUS_DEVICE(&s->a9mpcore); | 60 | if (va_space_rw(vs, KdDebuggerDataBlock, kdbg, kdbg_hdr.Size, 0)) { |
49 | + sysbus_realize(busdev, &error_fatal); | 61 | eprintf("Failed to extract entire KDBG\n"); |
50 | sysbus_mmio_map(busdev, 0, EXYNOS4210_SMP_PRIVATE_BASE_ADDR); | 62 | - free(kdbg); |
51 | for (n = 0; n < EXYNOS4210_NCPUS; n++) { | 63 | + g_free(kdbg); |
52 | sysbus_connect_irq(busdev, n, | 64 | return NULL; |
53 | qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 0)); | ||
54 | } | 65 | } |
55 | for (n = 0; n < EXYNOS4210_INT_GIC_NIRQ; n++) { | 66 | |
56 | - s->irqs.int_gic_irq[n] = qdev_get_gpio_in(dev, n); | 67 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char *argv[]) |
57 | + s->irqs.int_gic_irq[n] = qdev_get_gpio_in(DEVICE(&s->a9mpcore), n); | ||
58 | } | 68 | } |
59 | 69 | ||
60 | /* Cache controller */ | 70 | out_kdbg: |
61 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init(Object *obj) | 71 | - free(kdbg); |
62 | g_autofree char *name = g_strdup_printf("cpu-irq-orgate%d", i); | 72 | + g_free(kdbg); |
63 | object_initialize_child(obj, name, &s->cpu_irq_orgate[i], TYPE_OR_IRQ); | 73 | out_pdb: |
64 | } | 74 | pdb_exit(&pdb); |
65 | + | 75 | out_pdb_file: |
66 | + object_initialize_child(obj, "a9mpcore", &s->a9mpcore, TYPE_A9MPCORE_PRIV); | 76 | diff --git a/contrib/elf2dmp/pdb.c b/contrib/elf2dmp/pdb.c |
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/contrib/elf2dmp/pdb.c | ||
79 | +++ b/contrib/elf2dmp/pdb.c | ||
80 | @@ -XXX,XX +XXX,XX @@ uint64_t pdb_resolve(uint64_t img_base, struct pdb_reader *r, const char *name) | ||
81 | |||
82 | static void pdb_reader_ds_exit(struct pdb_reader *r) | ||
83 | { | ||
84 | - free(r->ds.toc); | ||
85 | + g_free(r->ds.toc); | ||
67 | } | 86 | } |
68 | 87 | ||
69 | static void exynos4210_class_init(ObjectClass *klass, void *data) | 88 | static void pdb_exit_symbols(struct pdb_reader *r) |
89 | { | ||
90 | - free(r->modimage); | ||
91 | - free(r->symbols); | ||
92 | + g_free(r->modimage); | ||
93 | + g_free(r->symbols); | ||
94 | } | ||
95 | |||
96 | static void pdb_exit_segments(struct pdb_reader *r) | ||
97 | { | ||
98 | - free(r->segs); | ||
99 | + g_free(r->segs); | ||
100 | } | ||
101 | |||
102 | static void *pdb_ds_read(const PDB_DS_HEADER *header, | ||
103 | @@ -XXX,XX +XXX,XX @@ static void *pdb_ds_read(const PDB_DS_HEADER *header, | ||
104 | |||
105 | nBlocks = (size + header->block_size - 1) / header->block_size; | ||
106 | |||
107 | - buffer = malloc(nBlocks * header->block_size); | ||
108 | - if (!buffer) { | ||
109 | - return NULL; | ||
110 | - } | ||
111 | + buffer = g_malloc(nBlocks * header->block_size); | ||
112 | |||
113 | for (i = 0; i < nBlocks; i++) { | ||
114 | memcpy(buffer + i * header->block_size, (const char *)header + | ||
115 | @@ -XXX,XX +XXX,XX @@ static int pdb_init_symbols(struct pdb_reader *r) | ||
116 | return 0; | ||
117 | |||
118 | out_symbols: | ||
119 | - free(symbols); | ||
120 | + g_free(symbols); | ||
121 | |||
122 | return err; | ||
123 | } | ||
124 | @@ -XXX,XX +XXX,XX @@ static int pdb_reader_init(struct pdb_reader *r, void *data) | ||
125 | out_sym: | ||
126 | pdb_exit_symbols(r); | ||
127 | out_root: | ||
128 | - free(r->ds.root); | ||
129 | + g_free(r->ds.root); | ||
130 | out_ds: | ||
131 | pdb_reader_ds_exit(r); | ||
132 | |||
133 | @@ -XXX,XX +XXX,XX @@ static void pdb_reader_exit(struct pdb_reader *r) | ||
134 | { | ||
135 | pdb_exit_segments(r); | ||
136 | pdb_exit_symbols(r); | ||
137 | - free(r->ds.root); | ||
138 | + g_free(r->ds.root); | ||
139 | pdb_reader_ds_exit(r); | ||
140 | } | ||
141 | |||
142 | diff --git a/contrib/elf2dmp/qemu_elf.c b/contrib/elf2dmp/qemu_elf.c | ||
143 | index XXXXXXX..XXXXXXX 100644 | ||
144 | --- a/contrib/elf2dmp/qemu_elf.c | ||
145 | +++ b/contrib/elf2dmp/qemu_elf.c | ||
146 | @@ -XXX,XX +XXX,XX @@ static int init_states(QEMU_Elf *qe) | ||
147 | |||
148 | printf("%zu CPU states has been found\n", cpu_nr); | ||
149 | |||
150 | - qe->state = malloc(sizeof(*qe->state) * cpu_nr); | ||
151 | - if (!qe->state) { | ||
152 | - return 1; | ||
153 | - } | ||
154 | + qe->state = g_new(QEMUCPUState*, cpu_nr); | ||
155 | |||
156 | cpu_nr = 0; | ||
157 | |||
158 | @@ -XXX,XX +XXX,XX @@ static int init_states(QEMU_Elf *qe) | ||
159 | |||
160 | static void exit_states(QEMU_Elf *qe) | ||
161 | { | ||
162 | - free(qe->state); | ||
163 | + g_free(qe->state); | ||
164 | } | ||
165 | |||
166 | static bool check_ehdr(QEMU_Elf *qe) | ||
70 | -- | 167 | -- |
71 | 2.25.1 | 168 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The only time we use the int_gic_irq[] array in the Exynos4210Irq | ||
2 | struct is in the exynos4210_realize() function: we initialize it with | ||
3 | the GPIO inputs of the a9mpcore device, and then a bit later on we | ||
4 | connect those to the outputs of the internal combiner. Now that the | ||
5 | a9mpcore object is easily accessible as s->a9mpcore we can make the | ||
6 | connection directly from one device to the other without going via | ||
7 | this array. | ||
8 | 1 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20220404154658.565020-5-peter.maydell@linaro.org | ||
12 | --- | ||
13 | include/hw/arm/exynos4210.h | 1 - | ||
14 | hw/arm/exynos4210.c | 6 ++---- | ||
15 | 2 files changed, 2 insertions(+), 5 deletions(-) | ||
16 | |||
17 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/include/hw/arm/exynos4210.h | ||
20 | +++ b/include/hw/arm/exynos4210.h | ||
21 | @@ -XXX,XX +XXX,XX @@ | ||
22 | typedef struct Exynos4210Irq { | ||
23 | qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | ||
24 | qemu_irq ext_combiner_irq[EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ]; | ||
25 | - qemu_irq int_gic_irq[EXYNOS4210_INT_GIC_NIRQ]; | ||
26 | qemu_irq ext_gic_irq[EXYNOS4210_EXT_GIC_NIRQ]; | ||
27 | qemu_irq board_irqs[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | ||
28 | } Exynos4210Irq; | ||
29 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/hw/arm/exynos4210.c | ||
32 | +++ b/hw/arm/exynos4210.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
34 | sysbus_connect_irq(busdev, n, | ||
35 | qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 0)); | ||
36 | } | ||
37 | - for (n = 0; n < EXYNOS4210_INT_GIC_NIRQ; n++) { | ||
38 | - s->irqs.int_gic_irq[n] = qdev_get_gpio_in(DEVICE(&s->a9mpcore), n); | ||
39 | - } | ||
40 | |||
41 | /* Cache controller */ | ||
42 | sysbus_create_simple("l2x0", EXYNOS4210_L2X0_BASE_ADDR, NULL); | ||
43 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
44 | busdev = SYS_BUS_DEVICE(dev); | ||
45 | sysbus_realize_and_unref(busdev, &error_fatal); | ||
46 | for (n = 0; n < EXYNOS4210_MAX_INT_COMBINER_OUT_IRQ; n++) { | ||
47 | - sysbus_connect_irq(busdev, n, s->irqs.int_gic_irq[n]); | ||
48 | + sysbus_connect_irq(busdev, n, | ||
49 | + qdev_get_gpio_in(DEVICE(&s->a9mpcore), n)); | ||
50 | } | ||
51 | exynos4210_combiner_get_gpioin(&s->irqs, dev, 0); | ||
52 | sysbus_mmio_map(busdev, 0, EXYNOS4210_INT_COMBINER_BASE_ADDR); | ||
53 | -- | ||
54 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Fix a missing set of spaces around '-' in the definition of | ||
2 | combiner_grp_to_gic_id[]. We're about to move this code, so | ||
3 | fix the style issue first to keep checkpatch happy with the | ||
4 | code-motion patch. | ||
5 | 1 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220404154658.565020-7-peter.maydell@linaro.org | ||
9 | --- | ||
10 | hw/intc/exynos4210_gic.c | 2 +- | ||
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
12 | |||
13 | diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/intc/exynos4210_gic.c | ||
16 | +++ b/hw/intc/exynos4210_gic.c | ||
17 | @@ -XXX,XX +XXX,XX @@ enum ExtInt { | ||
18 | */ | ||
19 | |||
20 | static const uint32_t | ||
21 | -combiner_grp_to_gic_id[64-EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | ||
22 | +combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | ||
23 | /* int combiner groups 16-19 */ | ||
24 | { }, { }, { }, { }, | ||
25 | /* int combiner group 20 */ | ||
26 | -- | ||
27 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The only time we use the ext_gic_irq[] array in the Exynos4210Irq | ||
2 | struct is during realize of the SoC -- we initialize it with the | ||
3 | input IRQs of the external GIC device, and then connect those to | ||
4 | outputs of other devices further on in realize (including in the | ||
5 | exynos4210_init_board_irqs() function). Now that the ext_gic object | ||
6 | is easily accessible as s->ext_gic we can make the connections | ||
7 | directly from one device to the other without going via this array. | ||
8 | 1 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20220404154658.565020-10-peter.maydell@linaro.org | ||
12 | --- | ||
13 | include/hw/arm/exynos4210.h | 1 - | ||
14 | hw/arm/exynos4210.c | 12 ++++++------ | ||
15 | 2 files changed, 6 insertions(+), 7 deletions(-) | ||
16 | |||
17 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/include/hw/arm/exynos4210.h | ||
20 | +++ b/include/hw/arm/exynos4210.h | ||
21 | @@ -XXX,XX +XXX,XX @@ | ||
22 | typedef struct Exynos4210Irq { | ||
23 | qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | ||
24 | qemu_irq ext_combiner_irq[EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ]; | ||
25 | - qemu_irq ext_gic_irq[EXYNOS4210_EXT_GIC_NIRQ]; | ||
26 | } Exynos4210Irq; | ||
27 | |||
28 | struct Exynos4210State { | ||
29 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/hw/arm/exynos4210.c | ||
32 | +++ b/hw/arm/exynos4210.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
34 | { | ||
35 | uint32_t grp, bit, irq_id, n; | ||
36 | Exynos4210Irq *is = &s->irqs; | ||
37 | + DeviceState *extgicdev = DEVICE(&s->ext_gic); | ||
38 | |||
39 | for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { | ||
40 | irq_id = 0; | ||
41 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
42 | } | ||
43 | if (irq_id) { | ||
44 | s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
45 | - is->ext_gic_irq[irq_id - 32]); | ||
46 | + qdev_get_gpio_in(extgicdev, | ||
47 | + irq_id - 32)); | ||
48 | } else { | ||
49 | s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
50 | is->ext_combiner_irq[n]); | ||
51 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
52 | |||
53 | if (irq_id) { | ||
54 | s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
55 | - is->ext_gic_irq[irq_id - 32]); | ||
56 | + qdev_get_gpio_in(extgicdev, | ||
57 | + irq_id - 32)); | ||
58 | } | ||
59 | } | ||
60 | } | ||
61 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
62 | sysbus_connect_irq(busdev, n, | ||
63 | qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 1)); | ||
64 | } | ||
65 | - for (n = 0; n < EXYNOS4210_EXT_GIC_NIRQ; n++) { | ||
66 | - s->irqs.ext_gic_irq[n] = qdev_get_gpio_in(DEVICE(&s->ext_gic), n); | ||
67 | - } | ||
68 | |||
69 | /* Internal Interrupt Combiner */ | ||
70 | dev = qdev_new("exynos4210.combiner"); | ||
71 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
72 | busdev = SYS_BUS_DEVICE(dev); | ||
73 | sysbus_realize_and_unref(busdev, &error_fatal); | ||
74 | for (n = 0; n < EXYNOS4210_MAX_INT_COMBINER_OUT_IRQ; n++) { | ||
75 | - sysbus_connect_irq(busdev, n, s->irqs.ext_gic_irq[n]); | ||
76 | + sysbus_connect_irq(busdev, n, qdev_get_gpio_in(DEVICE(&s->ext_gic), n)); | ||
77 | } | ||
78 | exynos4210_combiner_get_gpioin(&s->irqs, dev, 1); | ||
79 | sysbus_mmio_map(busdev, 0, EXYNOS4210_EXT_COMBINER_BASE_ADDR); | ||
80 | -- | ||
81 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Delete a couple of #defines which are never used. | ||
2 | 1 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20220404154658.565020-12-peter.maydell@linaro.org | ||
6 | --- | ||
7 | include/hw/arm/exynos4210.h | 4 ---- | ||
8 | 1 file changed, 4 deletions(-) | ||
9 | |||
10 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/include/hw/arm/exynos4210.h | ||
13 | +++ b/include/hw/arm/exynos4210.h | ||
14 | @@ -XXX,XX +XXX,XX @@ | ||
15 | #define EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ \ | ||
16 | (EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ * 8) | ||
17 | |||
18 | -/* IRQs number for external and internal GIC */ | ||
19 | -#define EXYNOS4210_EXT_GIC_NIRQ (160-32) | ||
20 | -#define EXYNOS4210_INT_GIC_NIRQ 64 | ||
21 | - | ||
22 | #define EXYNOS4210_I2C_NUMBER 9 | ||
23 | |||
24 | #define EXYNOS4210_NUM_DMA 3 | ||
25 | -- | ||
26 | 2.25.1 | diff view generated by jsdifflib |