1 | Hi; here's the latest round of arm patches. I have included also | 1 | Hi; here's the first arm pullreq for 9.1. |
---|---|---|---|
2 | my patchset for the RTC devices to avoid keeping time_t and | 2 | |
3 | time_t diffs in 32-bit variables. | 3 | This includes the reset method function signature change, so it has |
4 | some chance of compile failures due to merge conflicts if some other | ||
5 | pullreq added a device reset method and that pullreq got applied | ||
6 | before this one. If so, the changes needed to fix those up can be | ||
7 | created by running the spatch rune described in the commit message of | ||
8 | the "hw, target: Add ResetType argument to hold and exit phase | ||
9 | methods" commit. | ||
4 | 10 | ||
5 | thanks | 11 | thanks |
6 | -- PMM | 12 | -- PMM |
7 | 13 | ||
8 | The following changes since commit 156618d9ea67f2f2e31d9dedd97f2dcccbe6808c: | 14 | The following changes since commit 5da72194df36535d773c8bdc951529ecd5e31707: |
9 | 15 | ||
10 | Merge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu into staging (2023-08-30 09:20:27 -0400) | 16 | Merge tag 'pull-tcg-20240424' of https://gitlab.com/rth7680/qemu into staging (2024-04-24 15:51:49 -0700) |
11 | 17 | ||
12 | are available in the Git repository at: | 18 | are available in the Git repository at: |
13 | 19 | ||
14 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230831 | 20 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20240425 |
15 | 21 | ||
16 | for you to fetch changes up to e73b8bb8a3e9a162f70e9ffbf922d4fafc96bbfb: | 22 | for you to fetch changes up to 214652da123e3821657a64691ee556281e9f6238: |
17 | 23 | ||
18 | hw/arm: Set number of MPU regions correctly for an505, an521, an524 (2023-08-31 11:07:02 +0100) | 24 | tests/qtest: Add tests for the STM32L4x5 USART (2024-04-25 10:21:59 +0100) |
19 | 25 | ||
20 | ---------------------------------------------------------------- | 26 | ---------------------------------------------------------------- |
21 | target-arm queue: | 27 | target-arm queue: |
22 | * Some of the preliminary patches for Cortex-A710 support | 28 | * Implement FEAT_NMI and NMI support in the GICv3 |
23 | * i.MX7 and i.MX6UL refactoring | 29 | * hw/dma: avoid apparent overflow in soc_dma_set_request |
24 | * Implement SRC device for i.MX7 | 30 | * linux-user/flatload.c: Remove unused bFLT shared-library and ZFLAT code |
25 | * Catch illegal-exception-return from EL3 with bad NSE/NS | 31 | * Add ResetType argument to Resettable hold and exit phase methods |
26 | * Use 64-bit offsets for holding time_t differences in RTC devices | 32 | * Add RESET_TYPE_SNAPSHOT_LOAD ResetType |
27 | * Model correct number of MPU regions for an505, an521, an524 boards | 33 | * Implement STM32L4x5 USART |
28 | 34 | ||
29 | ---------------------------------------------------------------- | 35 | ---------------------------------------------------------------- |
30 | Alex Bennée (1): | 36 | Anastasia Belova (1): |
31 | target/arm: properly document FEAT_CRC32 | 37 | hw/dma: avoid apparent overflow in soc_dma_set_request |
32 | 38 | ||
33 | Jean-Christophe Dubois (6): | 39 | Arnaud Minier (5): |
34 | Remove i.MX7 IOMUX GPR device from i.MX6UL | 40 | hw/char: Implement STM32L4x5 USART skeleton |
35 | Refactor i.MX6UL processor code | 41 | hw/char/stm32l4x5_usart: Enable serial read and write |
36 | Add i.MX6UL missing devices. | 42 | hw/char/stm32l4x5_usart: Add options for serial parameters setting |
37 | Refactor i.MX7 processor code | 43 | hw/arm: Add the USART to the stm32l4x5 SoC |
38 | Add i.MX7 missing TZ devices and memory regions | 44 | tests/qtest: Add tests for the STM32L4x5 USART |
39 | Add i.MX7 SRC device implementation | 45 | |
40 | 46 | Jinjie Ruan (22): | |
41 | Peter Maydell (8): | 47 | target/arm: Handle HCR_EL2 accesses for bits introduced with FEAT_NMI |
42 | target/arm: Catch illegal-exception-return from EL3 with bad NSE/NS | 48 | target/arm: Add PSTATE.ALLINT |
43 | hw/rtc/m48t59: Use 64-bit arithmetic in set_alarm() | 49 | target/arm: Add support for FEAT_NMI, Non-maskable Interrupt |
44 | hw/rtc/twl92230: Use int64_t for sec_offset and alm_sec | 50 | target/arm: Implement ALLINT MSR (immediate) |
45 | hw/rtc/aspeed_rtc: Use 64-bit offset for holding time_t difference | 51 | target/arm: Support MSR access to ALLINT |
46 | rtc: Use time_t for passing and returning time offsets | 52 | target/arm: Add support for Non-maskable Interrupt |
47 | target/arm: Do all "ARM_FEATURE_X implies Y" checks in post_init | 53 | target/arm: Add support for NMI in arm_phys_excp_target_el() |
48 | hw/arm/armv7m: Add mpu-ns-regions and mpu-s-regions properties | 54 | target/arm: Handle IS/FS in ISR_EL1 for NMI, VINMI and VFNMI |
49 | hw/arm: Set number of MPU regions correctly for an505, an521, an524 | 55 | target/arm: Handle PSTATE.ALLINT on taking an exception |
50 | 56 | hw/intc/arm_gicv3: Add external IRQ lines for NMI | |
51 | Richard Henderson (9): | 57 | hw/arm/virt: Wire NMI and VINMI irq lines from GIC to CPU |
52 | target/arm: Reduce dcz_blocksize to uint8_t | 58 | target/arm: Handle NMI in arm_cpu_do_interrupt_aarch64() |
53 | target/arm: Allow cpu to configure GM blocksize | 59 | hw/intc/arm_gicv3: Add has-nmi property to GICv3 device |
54 | target/arm: Support more GM blocksizes | 60 | hw/intc/arm_gicv3_kvm: Not set has-nmi=true for the KVM GICv3 |
55 | target/arm: When tag memory is not present, set MTE=1 | 61 | hw/intc/arm_gicv3: Add irq non-maskable property |
56 | target/arm: Introduce make_ccsidr64 | 62 | hw/intc/arm_gicv3_redist: Implement GICR_INMIR0 |
57 | target/arm: Apply access checks to neoverse-n1 special registers | 63 | hw/intc/arm_gicv3: Implement GICD_INMIR |
58 | target/arm: Apply access checks to neoverse-v1 special registers | 64 | hw/intc/arm_gicv3: Implement NMI interrupt priority |
59 | target/arm: Suppress FEAT_TRBE (Trace Buffer Extension) | 65 | hw/intc/arm_gicv3: Report the NMI interrupt in gicv3_cpuif_update() |
60 | target/arm: Implement FEAT_HPDS2 as a no-op | 66 | hw/intc/arm_gicv3: Report the VINMI interrupt |
61 | 67 | target/arm: Add FEAT_NMI to max | |
62 | docs/system/arm/emulation.rst | 2 + | 68 | hw/arm/virt: Enable NMI support in the GIC if the CPU has FEAT_NMI |
63 | include/hw/arm/armsse.h | 5 + | 69 | |
64 | include/hw/arm/armv7m.h | 8 + | 70 | Peter Maydell (9): |
65 | include/hw/arm/fsl-imx6ul.h | 158 ++++++++++++++++--- | 71 | hw/intc/arm_gicv3: Add NMI handling CPU interface registers |
66 | include/hw/arm/fsl-imx7.h | 338 ++++++++++++++++++++++++++++++----------- | 72 | hw/intc/arm_gicv3: Handle icv_nmiar1_read() for icc_nmiar1_read() |
67 | include/hw/misc/imx7_src.h | 66 ++++++++ | 73 | linux-user/flatload.c: Remove unused bFLT shared-library and ZFLAT code |
68 | include/hw/rtc/aspeed_rtc.h | 2 +- | 74 | hw/misc: Don't special case RESET_TYPE_COLD in npcm7xx_clk, gcr |
69 | include/sysemu/rtc.h | 4 +- | 75 | allwinner-i2c, adm1272: Use device_cold_reset() for software-triggered reset |
70 | target/arm/cpregs.h | 2 + | 76 | scripts/coccinelle: New script to add ResetType to hold and exit phases |
71 | target/arm/cpu.h | 5 +- | 77 | hw, target: Add ResetType argument to hold and exit phase methods |
72 | target/arm/internals.h | 6 - | 78 | docs/devel/reset: Update to new API for hold and exit phase methods |
73 | target/arm/tcg/translate.h | 2 + | 79 | reset: Add RESET_TYPE_SNAPSHOT_LOAD |
74 | hw/arm/armsse.c | 16 ++ | 80 | |
75 | hw/arm/armv7m.c | 21 +++ | 81 | MAINTAINERS | 1 + |
76 | hw/arm/fsl-imx6ul.c | 174 +++++++++++++-------- | 82 | docs/devel/reset.rst | 25 +- |
77 | hw/arm/fsl-imx7.c | 201 +++++++++++++++++++----- | 83 | docs/system/arm/b-l475e-iot01a.rst | 2 +- |
78 | hw/arm/mps2-tz.c | 29 ++++ | 84 | docs/system/arm/emulation.rst | 1 + |
79 | hw/misc/imx7_src.c | 276 +++++++++++++++++++++++++++++++++ | 85 | scripts/coccinelle/reset-type.cocci | 133 ++++++++ |
80 | hw/rtc/aspeed_rtc.c | 5 +- | 86 | hw/intc/gicv3_internal.h | 13 + |
81 | hw/rtc/m48t59.c | 2 +- | 87 | include/hw/arm/stm32l4x5_soc.h | 7 + |
82 | hw/rtc/twl92230.c | 4 +- | 88 | include/hw/char/stm32l4x5_usart.h | 67 ++++ |
83 | softmmu/rtc.c | 4 +- | 89 | include/hw/intc/arm_gic_common.h | 2 + |
84 | target/arm/cpu.c | 207 ++++++++++++++----------- | 90 | include/hw/intc/arm_gicv3_common.h | 14 + |
85 | target/arm/helper.c | 15 +- | 91 | include/hw/resettable.h | 5 +- |
86 | target/arm/tcg/cpu32.c | 2 +- | 92 | linux-user/flat.h | 5 +- |
87 | target/arm/tcg/cpu64.c | 102 +++++++++---- | 93 | target/arm/cpu-features.h | 5 + |
88 | target/arm/tcg/helper-a64.c | 9 ++ | 94 | target/arm/cpu-qom.h | 5 +- |
89 | target/arm/tcg/mte_helper.c | 90 ++++++++--- | 95 | target/arm/cpu.h | 9 + |
90 | target/arm/tcg/translate-a64.c | 5 +- | 96 | target/arm/internals.h | 21 ++ |
91 | hw/misc/meson.build | 1 + | 97 | target/arm/tcg/helper-a64.h | 1 + |
92 | hw/misc/trace-events | 4 + | 98 | target/arm/tcg/a64.decode | 1 + |
93 | 31 files changed, 1393 insertions(+), 372 deletions(-) | 99 | hw/adc/npcm7xx_adc.c | 2 +- |
94 | create mode 100644 include/hw/misc/imx7_src.h | 100 | hw/arm/pxa2xx_pic.c | 2 +- |
95 | create mode 100644 hw/misc/imx7_src.c | 101 | hw/arm/smmu-common.c | 2 +- |
96 | 102 | hw/arm/smmuv3.c | 4 +- | |
103 | hw/arm/stellaris.c | 10 +- | ||
104 | hw/arm/stm32l4x5_soc.c | 83 ++++- | ||
105 | hw/arm/virt.c | 29 +- | ||
106 | hw/audio/asc.c | 2 +- | ||
107 | hw/char/cadence_uart.c | 2 +- | ||
108 | hw/char/sifive_uart.c | 2 +- | ||
109 | hw/char/stm32l4x5_usart.c | 637 ++++++++++++++++++++++++++++++++++++ | ||
110 | hw/core/cpu-common.c | 2 +- | ||
111 | hw/core/qdev.c | 4 +- | ||
112 | hw/core/reset.c | 17 +- | ||
113 | hw/core/resettable.c | 8 +- | ||
114 | hw/display/virtio-vga.c | 4 +- | ||
115 | hw/dma/soc_dma.c | 4 +- | ||
116 | hw/gpio/npcm7xx_gpio.c | 2 +- | ||
117 | hw/gpio/pl061.c | 2 +- | ||
118 | hw/gpio/stm32l4x5_gpio.c | 2 +- | ||
119 | hw/hyperv/vmbus.c | 2 +- | ||
120 | hw/i2c/allwinner-i2c.c | 5 +- | ||
121 | hw/i2c/npcm7xx_smbus.c | 2 +- | ||
122 | hw/input/adb.c | 2 +- | ||
123 | hw/input/ps2.c | 12 +- | ||
124 | hw/intc/arm_gic_common.c | 2 +- | ||
125 | hw/intc/arm_gic_kvm.c | 4 +- | ||
126 | hw/intc/arm_gicv3.c | 67 +++- | ||
127 | hw/intc/arm_gicv3_common.c | 50 ++- | ||
128 | hw/intc/arm_gicv3_cpuif.c | 268 ++++++++++++++- | ||
129 | hw/intc/arm_gicv3_dist.c | 36 ++ | ||
130 | hw/intc/arm_gicv3_its.c | 4 +- | ||
131 | hw/intc/arm_gicv3_its_common.c | 2 +- | ||
132 | hw/intc/arm_gicv3_its_kvm.c | 4 +- | ||
133 | hw/intc/arm_gicv3_kvm.c | 9 +- | ||
134 | hw/intc/arm_gicv3_redist.c | 22 ++ | ||
135 | hw/intc/xics.c | 2 +- | ||
136 | hw/m68k/q800-glue.c | 2 +- | ||
137 | hw/misc/djmemc.c | 2 +- | ||
138 | hw/misc/iosb.c | 2 +- | ||
139 | hw/misc/mac_via.c | 8 +- | ||
140 | hw/misc/macio/cuda.c | 4 +- | ||
141 | hw/misc/macio/pmu.c | 4 +- | ||
142 | hw/misc/mos6522.c | 2 +- | ||
143 | hw/misc/npcm7xx_clk.c | 13 +- | ||
144 | hw/misc/npcm7xx_gcr.c | 12 +- | ||
145 | hw/misc/npcm7xx_mft.c | 2 +- | ||
146 | hw/misc/npcm7xx_pwm.c | 2 +- | ||
147 | hw/misc/stm32l4x5_exti.c | 2 +- | ||
148 | hw/misc/stm32l4x5_rcc.c | 10 +- | ||
149 | hw/misc/stm32l4x5_syscfg.c | 2 +- | ||
150 | hw/misc/xlnx-versal-cframe-reg.c | 2 +- | ||
151 | hw/misc/xlnx-versal-crl.c | 2 +- | ||
152 | hw/misc/xlnx-versal-pmc-iou-slcr.c | 2 +- | ||
153 | hw/misc/xlnx-versal-trng.c | 2 +- | ||
154 | hw/misc/xlnx-versal-xramc.c | 2 +- | ||
155 | hw/misc/xlnx-zynqmp-apu-ctrl.c | 2 +- | ||
156 | hw/misc/xlnx-zynqmp-crf.c | 2 +- | ||
157 | hw/misc/zynq_slcr.c | 4 +- | ||
158 | hw/net/can/xlnx-zynqmp-can.c | 2 +- | ||
159 | hw/net/e1000.c | 2 +- | ||
160 | hw/net/e1000e.c | 2 +- | ||
161 | hw/net/igb.c | 2 +- | ||
162 | hw/net/igbvf.c | 2 +- | ||
163 | hw/nvram/xlnx-bbram.c | 2 +- | ||
164 | hw/nvram/xlnx-versal-efuse-ctrl.c | 2 +- | ||
165 | hw/nvram/xlnx-zynqmp-efuse.c | 2 +- | ||
166 | hw/pci-bridge/cxl_root_port.c | 4 +- | ||
167 | hw/pci-bridge/pcie_root_port.c | 2 +- | ||
168 | hw/pci-host/bonito.c | 2 +- | ||
169 | hw/pci-host/pnv_phb.c | 4 +- | ||
170 | hw/pci-host/pnv_phb3_msi.c | 4 +- | ||
171 | hw/pci/pci.c | 4 +- | ||
172 | hw/rtc/mc146818rtc.c | 2 +- | ||
173 | hw/s390x/css-bridge.c | 2 +- | ||
174 | hw/sensor/adm1266.c | 2 +- | ||
175 | hw/sensor/adm1272.c | 4 +- | ||
176 | hw/sensor/isl_pmbus_vr.c | 10 +- | ||
177 | hw/sensor/max31785.c | 2 +- | ||
178 | hw/sensor/max34451.c | 2 +- | ||
179 | hw/ssi/npcm7xx_fiu.c | 2 +- | ||
180 | hw/timer/etraxfs_timer.c | 2 +- | ||
181 | hw/timer/npcm7xx_timer.c | 2 +- | ||
182 | hw/usb/hcd-dwc2.c | 8 +- | ||
183 | hw/usb/xlnx-versal-usb2-ctrl-regs.c | 2 +- | ||
184 | hw/virtio/virtio-pci.c | 2 +- | ||
185 | linux-user/flatload.c | 293 +---------------- | ||
186 | target/arm/cpu.c | 151 ++++++++- | ||
187 | target/arm/helper.c | 101 +++++- | ||
188 | target/arm/tcg/cpu64.c | 1 + | ||
189 | target/arm/tcg/helper-a64.c | 16 +- | ||
190 | target/arm/tcg/translate-a64.c | 19 ++ | ||
191 | target/avr/cpu.c | 4 +- | ||
192 | target/cris/cpu.c | 4 +- | ||
193 | target/hexagon/cpu.c | 4 +- | ||
194 | target/i386/cpu.c | 4 +- | ||
195 | target/loongarch/cpu.c | 4 +- | ||
196 | target/m68k/cpu.c | 4 +- | ||
197 | target/microblaze/cpu.c | 4 +- | ||
198 | target/mips/cpu.c | 4 +- | ||
199 | target/openrisc/cpu.c | 4 +- | ||
200 | target/ppc/cpu_init.c | 4 +- | ||
201 | target/riscv/cpu.c | 4 +- | ||
202 | target/rx/cpu.c | 4 +- | ||
203 | target/sh4/cpu.c | 4 +- | ||
204 | target/sparc/cpu.c | 4 +- | ||
205 | target/tricore/cpu.c | 4 +- | ||
206 | target/xtensa/cpu.c | 4 +- | ||
207 | tests/qtest/stm32l4x5_usart-test.c | 315 ++++++++++++++++++ | ||
208 | hw/arm/Kconfig | 1 + | ||
209 | hw/char/Kconfig | 3 + | ||
210 | hw/char/meson.build | 1 + | ||
211 | hw/char/trace-events | 12 + | ||
212 | hw/intc/trace-events | 2 + | ||
213 | tests/qtest/meson.build | 4 +- | ||
214 | 133 files changed, 2239 insertions(+), 537 deletions(-) | ||
215 | create mode 100644 scripts/coccinelle/reset-type.cocci | ||
216 | create mode 100644 include/hw/char/stm32l4x5_usart.h | ||
217 | create mode 100644 hw/char/stm32l4x5_usart.c | ||
218 | create mode 100644 tests/qtest/stm32l4x5_usart-test.c | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Jinjie Ruan <ruanjinjie@huawei.com> | ||
1 | 2 | ||
3 | FEAT_NMI defines another three new bits in HCRX_EL2: TALLINT, HCRX_VINMI and | ||
4 | HCRX_VFNMI. When the feature is enabled, allow these bits to be written in | ||
5 | HCRX_EL2. | ||
6 | |||
7 | Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Message-id: 20240407081733.3231820-2-ruanjinjie@huawei.com | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | target/arm/cpu-features.h | 5 +++++ | ||
14 | target/arm/helper.c | 8 +++++++- | ||
15 | 2 files changed, 12 insertions(+), 1 deletion(-) | ||
16 | |||
17 | diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/cpu-features.h | ||
20 | +++ b/target/arm/cpu-features.h | ||
21 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_sme(const ARMISARegisters *id) | ||
22 | return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SME) != 0; | ||
23 | } | ||
24 | |||
25 | +static inline bool isar_feature_aa64_nmi(const ARMISARegisters *id) | ||
26 | +{ | ||
27 | + return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, NMI) != 0; | ||
28 | +} | ||
29 | + | ||
30 | static inline bool isar_feature_aa64_tgran4_lpa2(const ARMISARegisters *id) | ||
31 | { | ||
32 | return FIELD_SEX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN4) >= 1; | ||
33 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/helper.c | ||
36 | +++ b/target/arm/helper.c | ||
37 | @@ -XXX,XX +XXX,XX @@ bool el_is_in_host(CPUARMState *env, int el) | ||
38 | static void hcrx_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
39 | uint64_t value) | ||
40 | { | ||
41 | + ARMCPU *cpu = env_archcpu(env); | ||
42 | uint64_t valid_mask = 0; | ||
43 | |||
44 | /* FEAT_MOPS adds MSCEn and MCE2 */ | ||
45 | - if (cpu_isar_feature(aa64_mops, env_archcpu(env))) { | ||
46 | + if (cpu_isar_feature(aa64_mops, cpu)) { | ||
47 | valid_mask |= HCRX_MSCEN | HCRX_MCE2; | ||
48 | } | ||
49 | |||
50 | + /* FEAT_NMI adds TALLINT, VINMI and VFNMI */ | ||
51 | + if (cpu_isar_feature(aa64_nmi, cpu)) { | ||
52 | + valid_mask |= HCRX_TALLINT | HCRX_VINMI | HCRX_VFNMI; | ||
53 | + } | ||
54 | + | ||
55 | /* Clear RES0 bits. */ | ||
56 | env->cp15.hcrx_el2 = value & valid_mask; | ||
57 | } | ||
58 | -- | ||
59 | 2.34.1 | diff view generated by jsdifflib |
1 | The architecture requires (R_TYTWB) that an attempt to return from EL3 | 1 | From: Jinjie Ruan <ruanjinjie@huawei.com> |
---|---|---|---|
2 | when SCR_EL3.{NSE,NS} are {1,0} is an illegal exception return. (This | ||
3 | enforces that the CPU can't ever be executing below EL3 with the | ||
4 | NSE,NS bits indicating an invalid security state.) | ||
5 | 2 | ||
6 | We were missing this check; add it. | 3 | When PSTATE.ALLINT is set, an IRQ or FIQ interrupt that is targeted to |
4 | ELx, with or without superpriority is masked. As Richard suggested, place | ||
5 | ALLINT bit in PSTATE in env->pstate. | ||
7 | 6 | ||
7 | In the pseudocode, AArch64.ExceptionReturn() calls SetPSTATEFromPSR(), which | ||
8 | treats PSTATE.ALLINT as one of the bits which are reinstated from SPSR to | ||
9 | PSTATE regardless of whether this is an illegal exception return or not. So | ||
10 | handle PSTATE.ALLINT the same way as PSTATE.DAIF in the illegal_return exit | ||
11 | path of the exception_return helper. With the change, exception entry and | ||
12 | return are automatically handled. | ||
13 | |||
14 | Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> | ||
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | Message-id: 20240407081733.3231820-3-ruanjinjie@huawei.com | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20230807150618.101357-1-peter.maydell@linaro.org | ||
11 | --- | 19 | --- |
12 | target/arm/tcg/helper-a64.c | 9 +++++++++ | 20 | target/arm/cpu.h | 1 + |
13 | 1 file changed, 9 insertions(+) | 21 | target/arm/tcg/helper-a64.c | 4 ++-- |
22 | 2 files changed, 3 insertions(+), 2 deletions(-) | ||
14 | 23 | ||
24 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/arm/cpu.h | ||
27 | +++ b/target/arm/cpu.h | ||
28 | @@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu); | ||
29 | #define PSTATE_D (1U << 9) | ||
30 | #define PSTATE_BTYPE (3U << 10) | ||
31 | #define PSTATE_SSBS (1U << 12) | ||
32 | +#define PSTATE_ALLINT (1U << 13) | ||
33 | #define PSTATE_IL (1U << 20) | ||
34 | #define PSTATE_SS (1U << 21) | ||
35 | #define PSTATE_PAN (1U << 22) | ||
15 | diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c | 36 | diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c |
16 | index XXXXXXX..XXXXXXX 100644 | 37 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/tcg/helper-a64.c | 38 | --- a/target/arm/tcg/helper-a64.c |
18 | +++ b/target/arm/tcg/helper-a64.c | 39 | +++ b/target/arm/tcg/helper-a64.c |
19 | @@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc) | 40 | @@ -XXX,XX +XXX,XX @@ illegal_return: |
20 | spsr &= ~PSTATE_SS; | 41 | */ |
21 | } | 42 | env->pstate |= PSTATE_IL; |
22 | 43 | env->pc = new_pc; | |
23 | + /* | 44 | - spsr &= PSTATE_NZCV | PSTATE_DAIF; |
24 | + * FEAT_RME forbids return from EL3 with an invalid security state. | 45 | - spsr |= pstate_read(env) & ~(PSTATE_NZCV | PSTATE_DAIF); |
25 | + * We don't need an explicit check for FEAT_RME here because we enforce | 46 | + spsr &= PSTATE_NZCV | PSTATE_DAIF | PSTATE_ALLINT; |
26 | + * in scr_write() that you can't set the NSE bit without it. | 47 | + spsr |= pstate_read(env) & ~(PSTATE_NZCV | PSTATE_DAIF | PSTATE_ALLINT); |
27 | + */ | 48 | pstate_write(env, spsr); |
28 | + if (cur_el == 3 && (env->cp15.scr_el3 & (SCR_NS | SCR_NSE)) == SCR_NSE) { | 49 | if (!arm_singlestep_active(env)) { |
29 | + goto illegal_return; | 50 | env->pstate &= ~PSTATE_SS; |
30 | + } | ||
31 | + | ||
32 | new_el = el_from_spsr(spsr); | ||
33 | if (new_el == -1) { | ||
34 | goto illegal_return; | ||
35 | -- | 51 | -- |
36 | 2.34.1 | 52 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Jinjie Ruan <ruanjinjie@huawei.com> | ||
1 | 2 | ||
3 | Add support for FEAT_NMI. NMI (FEAT_NMI) is an mandatory feature in | ||
4 | ARMv8.8-A and ARM v9.3-A. | ||
5 | |||
6 | Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Message-id: 20240407081733.3231820-4-ruanjinjie@huawei.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/internals.h | 3 +++ | ||
13 | 1 file changed, 3 insertions(+) | ||
14 | |||
15 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/internals.h | ||
18 | +++ b/target/arm/internals.h | ||
19 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t aarch64_pstate_valid_mask(const ARMISARegisters *id) | ||
20 | if (isar_feature_aa64_mte(id)) { | ||
21 | valid |= PSTATE_TCO; | ||
22 | } | ||
23 | + if (isar_feature_aa64_nmi(id)) { | ||
24 | + valid |= PSTATE_ALLINT; | ||
25 | + } | ||
26 | |||
27 | return valid; | ||
28 | } | ||
29 | -- | ||
30 | 2.34.1 | diff view generated by jsdifflib |
1 | Where architecturally one ARM_FEATURE_X flag implies another | 1 | From: Jinjie Ruan <ruanjinjie@huawei.com> |
---|---|---|---|
2 | ARM_FEATURE_Y, we allow the CPU init function to only set X, and then | ||
3 | set Y for it. Currently we do this in two places -- we set a few | ||
4 | flags in arm_cpu_post_init() because we need them to decide which | ||
5 | properties to create on the CPU object, and then we do the rest in | ||
6 | arm_cpu_realizefn(). However, this is fragile, because it's easy to | ||
7 | add a new property and not notice that this means that an X-implies-Y | ||
8 | check now has to move from realize to post-init. | ||
9 | 2 | ||
10 | As a specific example, the pmsav7-dregion property is conditional | 3 | Add ALLINT MSR (immediate) to decodetree, in which the CRm is 0b000x. The |
11 | on ARM_FEATURE_PMSA && ARM_FEATURE_V7, which means it won't appear | 4 | EL0 check is necessary to ALLINT, and the EL1 check is necessary when |
12 | on the Cortex-M33 and -M55, because they set ARM_FEATURE_V8 and | 5 | imm == 1. So implement it inline for EL2/3, or EL1 with imm==0. Avoid the |
13 | rely on V8-implies-V7, which doesn't happen until the realizefn. | 6 | unconditional write to pc and use raise_exception_ra to unwind. |
14 | 7 | ||
15 | Move all of these X-implies-Y checks into a new function, which | 8 | Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> |
16 | we call at the top of arm_cpu_post_init(), so the feature bits | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
17 | are available at that point. | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Message-id: 20240407081733.3231820-5-ruanjinjie@huawei.com | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | target/arm/tcg/helper-a64.h | 1 + | ||
15 | target/arm/tcg/a64.decode | 1 + | ||
16 | target/arm/tcg/helper-a64.c | 12 ++++++++++++ | ||
17 | target/arm/tcg/translate-a64.c | 19 +++++++++++++++++++ | ||
18 | 4 files changed, 33 insertions(+) | ||
18 | 19 | ||
19 | This does now give us the reverse issue, that if there's a feature | 20 | diff --git a/target/arm/tcg/helper-a64.h b/target/arm/tcg/helper-a64.h |
20 | bit which is enabled or disabled by the setting of a property then | ||
21 | then X-implies-Y features that are dependent on that property need to | ||
22 | be in realize, not in this new function. But the only one of those | ||
23 | is the "EL3 implies VBAR" which is already in the right place, so | ||
24 | putting things this way round seems better to me. | ||
25 | |||
26 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
27 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
28 | Message-id: 20230724174335.2150499-2-peter.maydell@linaro.org | ||
29 | --- | ||
30 | target/arm/cpu.c | 179 +++++++++++++++++++++++++---------------------- | ||
31 | 1 file changed, 97 insertions(+), 82 deletions(-) | ||
32 | |||
33 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/target/arm/cpu.c | 22 | --- a/target/arm/tcg/helper-a64.h |
36 | +++ b/target/arm/cpu.c | 23 | +++ b/target/arm/tcg/helper-a64.h |
37 | @@ -XXX,XX +XXX,XX @@ unsigned int gt_cntfrq_period_ns(ARMCPU *cpu) | 24 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_1(rbit64, TCG_CALL_NO_RWG_SE, i64, i64) |
38 | NANOSECONDS_PER_SECOND / cpu->gt_cntfrq_hz : 1; | 25 | DEF_HELPER_2(msr_i_spsel, void, env, i32) |
26 | DEF_HELPER_2(msr_i_daifset, void, env, i32) | ||
27 | DEF_HELPER_2(msr_i_daifclear, void, env, i32) | ||
28 | +DEF_HELPER_1(msr_set_allint_el1, void, env) | ||
29 | DEF_HELPER_3(vfp_cmph_a64, i64, f16, f16, ptr) | ||
30 | DEF_HELPER_3(vfp_cmpeh_a64, i64, f16, f16, ptr) | ||
31 | DEF_HELPER_3(vfp_cmps_a64, i64, f32, f32, ptr) | ||
32 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/target/arm/tcg/a64.decode | ||
35 | +++ b/target/arm/tcg/a64.decode | ||
36 | @@ -XXX,XX +XXX,XX @@ MSR_i_DIT 1101 0101 0000 0 011 0100 .... 010 11111 @msr_i | ||
37 | MSR_i_TCO 1101 0101 0000 0 011 0100 .... 100 11111 @msr_i | ||
38 | MSR_i_DAIFSET 1101 0101 0000 0 011 0100 .... 110 11111 @msr_i | ||
39 | MSR_i_DAIFCLEAR 1101 0101 0000 0 011 0100 .... 111 11111 @msr_i | ||
40 | +MSR_i_ALLINT 1101 0101 0000 0 001 0100 000 imm:1 000 11111 | ||
41 | MSR_i_SVCR 1101 0101 0000 0 011 0100 0 mask:2 imm:1 011 11111 | ||
42 | |||
43 | # MRS, MSR (register), SYS, SYSL. These are all essentially the | ||
44 | diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/target/arm/tcg/helper-a64.c | ||
47 | +++ b/target/arm/tcg/helper-a64.c | ||
48 | @@ -XXX,XX +XXX,XX @@ void HELPER(msr_i_spsel)(CPUARMState *env, uint32_t imm) | ||
49 | update_spsel(env, imm); | ||
39 | } | 50 | } |
40 | 51 | ||
41 | +static void arm_cpu_propagate_feature_implications(ARMCPU *cpu) | 52 | +void HELPER(msr_set_allint_el1)(CPUARMState *env) |
42 | +{ | 53 | +{ |
43 | + CPUARMState *env = &cpu->env; | 54 | + /* ALLINT update to PSTATE. */ |
44 | + bool no_aa32 = false; | 55 | + if (arm_hcrx_el2_eff(env) & HCRX_TALLINT) { |
45 | + | 56 | + raise_exception_ra(env, EXCP_UDEF, |
46 | + /* | 57 | + syn_aa64_sysregtrap(0, 1, 0, 4, 1, 0x1f, 0), 2, |
47 | + * Some features automatically imply others: set the feature | 58 | + GETPC()); |
48 | + * bits explicitly for these cases. | ||
49 | + */ | ||
50 | + | ||
51 | + if (arm_feature(env, ARM_FEATURE_M)) { | ||
52 | + set_feature(env, ARM_FEATURE_PMSA); | ||
53 | + } | 59 | + } |
54 | + | 60 | + |
55 | + if (arm_feature(env, ARM_FEATURE_V8)) { | 61 | + env->pstate |= PSTATE_ALLINT; |
56 | + if (arm_feature(env, ARM_FEATURE_M)) { | 62 | +} |
57 | + set_feature(env, ARM_FEATURE_V7); | 63 | + |
58 | + } else { | 64 | static void daif_check(CPUARMState *env, uint32_t op, |
59 | + set_feature(env, ARM_FEATURE_V7VE); | 65 | uint32_t imm, uintptr_t ra) |
60 | + } | 66 | { |
67 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
68 | index XXXXXXX..XXXXXXX 100644 | ||
69 | --- a/target/arm/tcg/translate-a64.c | ||
70 | +++ b/target/arm/tcg/translate-a64.c | ||
71 | @@ -XXX,XX +XXX,XX @@ static bool trans_MSR_i_DAIFCLEAR(DisasContext *s, arg_i *a) | ||
72 | return true; | ||
73 | } | ||
74 | |||
75 | +static bool trans_MSR_i_ALLINT(DisasContext *s, arg_i *a) | ||
76 | +{ | ||
77 | + if (!dc_isar_feature(aa64_nmi, s) || s->current_el == 0) { | ||
78 | + return false; | ||
61 | + } | 79 | + } |
62 | + | 80 | + |
63 | + /* | 81 | + if (a->imm == 0) { |
64 | + * There exist AArch64 cpus without AArch32 support. When KVM | 82 | + clear_pstate_bits(PSTATE_ALLINT); |
65 | + * queries ID_ISAR0_EL1 on such a host, the value is UNKNOWN. | 83 | + } else if (s->current_el > 1) { |
66 | + * Similarly, we cannot check ID_AA64PFR0 without AArch64 support. | 84 | + set_pstate_bits(PSTATE_ALLINT); |
67 | + * As a general principle, we also do not make ID register | 85 | + } else { |
68 | + * consistency checks anywhere unless using TCG, because only | 86 | + gen_helper_msr_set_allint_el1(tcg_env); |
69 | + * for TCG would a consistency-check failure be a QEMU bug. | ||
70 | + */ | ||
71 | + if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { | ||
72 | + no_aa32 = !cpu_isar_feature(aa64_aa32, cpu); | ||
73 | + } | 87 | + } |
74 | + | 88 | + |
75 | + if (arm_feature(env, ARM_FEATURE_V7VE)) { | 89 | + /* Exit the cpu loop to re-evaluate pending IRQs. */ |
76 | + /* | 90 | + s->base.is_jmp = DISAS_UPDATE_EXIT; |
77 | + * v7 Virtualization Extensions. In real hardware this implies | 91 | + return true; |
78 | + * EL2 and also the presence of the Security Extensions. | ||
79 | + * For QEMU, for backwards-compatibility we implement some | ||
80 | + * CPUs or CPU configs which have no actual EL2 or EL3 but do | ||
81 | + * include the various other features that V7VE implies. | ||
82 | + * Presence of EL2 itself is ARM_FEATURE_EL2, and of the | ||
83 | + * Security Extensions is ARM_FEATURE_EL3. | ||
84 | + */ | ||
85 | + assert(!tcg_enabled() || no_aa32 || | ||
86 | + cpu_isar_feature(aa32_arm_div, cpu)); | ||
87 | + set_feature(env, ARM_FEATURE_LPAE); | ||
88 | + set_feature(env, ARM_FEATURE_V7); | ||
89 | + } | ||
90 | + if (arm_feature(env, ARM_FEATURE_V7)) { | ||
91 | + set_feature(env, ARM_FEATURE_VAPA); | ||
92 | + set_feature(env, ARM_FEATURE_THUMB2); | ||
93 | + set_feature(env, ARM_FEATURE_MPIDR); | ||
94 | + if (!arm_feature(env, ARM_FEATURE_M)) { | ||
95 | + set_feature(env, ARM_FEATURE_V6K); | ||
96 | + } else { | ||
97 | + set_feature(env, ARM_FEATURE_V6); | ||
98 | + } | ||
99 | + | ||
100 | + /* | ||
101 | + * Always define VBAR for V7 CPUs even if it doesn't exist in | ||
102 | + * non-EL3 configs. This is needed by some legacy boards. | ||
103 | + */ | ||
104 | + set_feature(env, ARM_FEATURE_VBAR); | ||
105 | + } | ||
106 | + if (arm_feature(env, ARM_FEATURE_V6K)) { | ||
107 | + set_feature(env, ARM_FEATURE_V6); | ||
108 | + set_feature(env, ARM_FEATURE_MVFR); | ||
109 | + } | ||
110 | + if (arm_feature(env, ARM_FEATURE_V6)) { | ||
111 | + set_feature(env, ARM_FEATURE_V5); | ||
112 | + if (!arm_feature(env, ARM_FEATURE_M)) { | ||
113 | + assert(!tcg_enabled() || no_aa32 || | ||
114 | + cpu_isar_feature(aa32_jazelle, cpu)); | ||
115 | + set_feature(env, ARM_FEATURE_AUXCR); | ||
116 | + } | ||
117 | + } | ||
118 | + if (arm_feature(env, ARM_FEATURE_V5)) { | ||
119 | + set_feature(env, ARM_FEATURE_V4T); | ||
120 | + } | ||
121 | + if (arm_feature(env, ARM_FEATURE_LPAE)) { | ||
122 | + set_feature(env, ARM_FEATURE_V7MP); | ||
123 | + } | ||
124 | + if (arm_feature(env, ARM_FEATURE_CBAR_RO)) { | ||
125 | + set_feature(env, ARM_FEATURE_CBAR); | ||
126 | + } | ||
127 | + if (arm_feature(env, ARM_FEATURE_THUMB2) && | ||
128 | + !arm_feature(env, ARM_FEATURE_M)) { | ||
129 | + set_feature(env, ARM_FEATURE_THUMB_DSP); | ||
130 | + } | ||
131 | +} | 92 | +} |
132 | + | 93 | + |
133 | void arm_cpu_post_init(Object *obj) | 94 | static bool trans_MSR_i_SVCR(DisasContext *s, arg_MSR_i_SVCR *a) |
134 | { | 95 | { |
135 | ARMCPU *cpu = ARM_CPU(obj); | 96 | if (!dc_isar_feature(aa64_sme, s) || a->mask == 0) { |
136 | |||
137 | - /* M profile implies PMSA. We have to do this here rather than | ||
138 | - * in realize with the other feature-implication checks because | ||
139 | - * we look at the PMSA bit to see if we should add some properties. | ||
140 | + /* | ||
141 | + * Some features imply others. Figure this out now, because we | ||
142 | + * are going to look at the feature bits in deciding which | ||
143 | + * properties to add. | ||
144 | */ | ||
145 | - if (arm_feature(&cpu->env, ARM_FEATURE_M)) { | ||
146 | - set_feature(&cpu->env, ARM_FEATURE_PMSA); | ||
147 | - } | ||
148 | + arm_cpu_propagate_feature_implications(cpu); | ||
149 | |||
150 | if (arm_feature(&cpu->env, ARM_FEATURE_CBAR) || | ||
151 | arm_feature(&cpu->env, ARM_FEATURE_CBAR_RO)) { | ||
152 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
153 | CPUARMState *env = &cpu->env; | ||
154 | int pagebits; | ||
155 | Error *local_err = NULL; | ||
156 | - bool no_aa32 = false; | ||
157 | |||
158 | /* Use pc-relative instructions in system-mode */ | ||
159 | #ifndef CONFIG_USER_ONLY | ||
160 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
161 | cpu->isar.id_isar3 = u; | ||
162 | } | ||
163 | |||
164 | - /* Some features automatically imply others: */ | ||
165 | - if (arm_feature(env, ARM_FEATURE_V8)) { | ||
166 | - if (arm_feature(env, ARM_FEATURE_M)) { | ||
167 | - set_feature(env, ARM_FEATURE_V7); | ||
168 | - } else { | ||
169 | - set_feature(env, ARM_FEATURE_V7VE); | ||
170 | - } | ||
171 | - } | ||
172 | - | ||
173 | - /* | ||
174 | - * There exist AArch64 cpus without AArch32 support. When KVM | ||
175 | - * queries ID_ISAR0_EL1 on such a host, the value is UNKNOWN. | ||
176 | - * Similarly, we cannot check ID_AA64PFR0 without AArch64 support. | ||
177 | - * As a general principle, we also do not make ID register | ||
178 | - * consistency checks anywhere unless using TCG, because only | ||
179 | - * for TCG would a consistency-check failure be a QEMU bug. | ||
180 | - */ | ||
181 | - if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { | ||
182 | - no_aa32 = !cpu_isar_feature(aa64_aa32, cpu); | ||
183 | - } | ||
184 | - | ||
185 | - if (arm_feature(env, ARM_FEATURE_V7VE)) { | ||
186 | - /* v7 Virtualization Extensions. In real hardware this implies | ||
187 | - * EL2 and also the presence of the Security Extensions. | ||
188 | - * For QEMU, for backwards-compatibility we implement some | ||
189 | - * CPUs or CPU configs which have no actual EL2 or EL3 but do | ||
190 | - * include the various other features that V7VE implies. | ||
191 | - * Presence of EL2 itself is ARM_FEATURE_EL2, and of the | ||
192 | - * Security Extensions is ARM_FEATURE_EL3. | ||
193 | - */ | ||
194 | - assert(!tcg_enabled() || no_aa32 || | ||
195 | - cpu_isar_feature(aa32_arm_div, cpu)); | ||
196 | - set_feature(env, ARM_FEATURE_LPAE); | ||
197 | - set_feature(env, ARM_FEATURE_V7); | ||
198 | - } | ||
199 | - if (arm_feature(env, ARM_FEATURE_V7)) { | ||
200 | - set_feature(env, ARM_FEATURE_VAPA); | ||
201 | - set_feature(env, ARM_FEATURE_THUMB2); | ||
202 | - set_feature(env, ARM_FEATURE_MPIDR); | ||
203 | - if (!arm_feature(env, ARM_FEATURE_M)) { | ||
204 | - set_feature(env, ARM_FEATURE_V6K); | ||
205 | - } else { | ||
206 | - set_feature(env, ARM_FEATURE_V6); | ||
207 | - } | ||
208 | - | ||
209 | - /* Always define VBAR for V7 CPUs even if it doesn't exist in | ||
210 | - * non-EL3 configs. This is needed by some legacy boards. | ||
211 | - */ | ||
212 | - set_feature(env, ARM_FEATURE_VBAR); | ||
213 | - } | ||
214 | - if (arm_feature(env, ARM_FEATURE_V6K)) { | ||
215 | - set_feature(env, ARM_FEATURE_V6); | ||
216 | - set_feature(env, ARM_FEATURE_MVFR); | ||
217 | - } | ||
218 | - if (arm_feature(env, ARM_FEATURE_V6)) { | ||
219 | - set_feature(env, ARM_FEATURE_V5); | ||
220 | - if (!arm_feature(env, ARM_FEATURE_M)) { | ||
221 | - assert(!tcg_enabled() || no_aa32 || | ||
222 | - cpu_isar_feature(aa32_jazelle, cpu)); | ||
223 | - set_feature(env, ARM_FEATURE_AUXCR); | ||
224 | - } | ||
225 | - } | ||
226 | - if (arm_feature(env, ARM_FEATURE_V5)) { | ||
227 | - set_feature(env, ARM_FEATURE_V4T); | ||
228 | - } | ||
229 | - if (arm_feature(env, ARM_FEATURE_LPAE)) { | ||
230 | - set_feature(env, ARM_FEATURE_V7MP); | ||
231 | - } | ||
232 | - if (arm_feature(env, ARM_FEATURE_CBAR_RO)) { | ||
233 | - set_feature(env, ARM_FEATURE_CBAR); | ||
234 | - } | ||
235 | - if (arm_feature(env, ARM_FEATURE_THUMB2) && | ||
236 | - !arm_feature(env, ARM_FEATURE_M)) { | ||
237 | - set_feature(env, ARM_FEATURE_THUMB_DSP); | ||
238 | - } | ||
239 | |||
240 | /* | ||
241 | * We rely on no XScale CPU having VFP so we can use the same bits in the | ||
242 | -- | 97 | -- |
243 | 2.34.1 | 98 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Jinjie Ruan <ruanjinjie@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | Access to many of the special registers is enabled or disabled | 3 | Support ALLINT msr access as follow: |
4 | by ACTLR_EL[23], which we implement as constant 0, which means | 4 | mrs <xt>, ALLINT // read allint |
5 | that all writes outside EL3 should trap. | 5 | msr ALLINT, <xt> // write allint with imm |
6 | 6 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Message-id: 20230811214031.171020-7-richard.henderson@linaro.org | 10 | Message-id: 20240407081733.3231820-6-ruanjinjie@huawei.com |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 12 | --- |
12 | target/arm/cpregs.h | 2 ++ | 13 | target/arm/helper.c | 35 +++++++++++++++++++++++++++++++++++ |
13 | target/arm/helper.c | 4 ++-- | 14 | 1 file changed, 35 insertions(+) |
14 | target/arm/tcg/cpu64.c | 46 +++++++++++++++++++++++++++++++++--------- | ||
15 | 3 files changed, 41 insertions(+), 11 deletions(-) | ||
16 | 15 | ||
17 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/cpregs.h | ||
20 | +++ b/target/arm/cpregs.h | ||
21 | @@ -XXX,XX +XXX,XX @@ static inline void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu) { } | ||
22 | void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu); | ||
23 | #endif | ||
24 | |||
25 | +CPAccessResult access_tvm_trvm(CPUARMState *, const ARMCPRegInfo *, bool); | ||
26 | + | ||
27 | #endif /* TARGET_ARM_CPREGS_H */ | ||
28 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 16 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
29 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/target/arm/helper.c | 18 | --- a/target/arm/helper.c |
31 | +++ b/target/arm/helper.c | 19 | +++ b/target/arm/helper.c |
32 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tpm(CPUARMState *env, const ARMCPRegInfo *ri, | 20 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo rme_mte_reginfo[] = { |
33 | } | 21 | .opc0 = 1, .opc1 = 6, .crn = 7, .crm = 14, .opc2 = 5, |
34 | 22 | .access = PL3_W, .type = ARM_CP_NOP }, | |
35 | /* Check for traps from EL1 due to HCR_EL2.TVM and HCR_EL2.TRVM. */ | 23 | }; |
36 | -static CPAccessResult access_tvm_trvm(CPUARMState *env, const ARMCPRegInfo *ri, | 24 | + |
37 | - bool isread) | 25 | +static void aa64_allint_write(CPUARMState *env, const ARMCPRegInfo *ri, |
38 | +CPAccessResult access_tvm_trvm(CPUARMState *env, const ARMCPRegInfo *ri, | 26 | + uint64_t value) |
39 | + bool isread) | ||
40 | { | ||
41 | if (arm_current_el(env) == 1) { | ||
42 | uint64_t trap = isread ? HCR_TRVM : HCR_TVM; | ||
43 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/target/arm/tcg/cpu64.c | ||
46 | +++ b/target/arm/tcg/cpu64.c | ||
47 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a64fx_initfn(Object *obj) | ||
48 | /* TODO: Add A64FX specific HPC extension registers */ | ||
49 | } | ||
50 | |||
51 | +static CPAccessResult access_actlr_w(CPUARMState *env, const ARMCPRegInfo *r, | ||
52 | + bool read) | ||
53 | +{ | 27 | +{ |
54 | + if (!read) { | 28 | + env->pstate = (env->pstate & ~PSTATE_ALLINT) | (value & PSTATE_ALLINT); |
55 | + int el = arm_current_el(env); | 29 | +} |
56 | + | 30 | + |
57 | + /* Because ACTLR_EL2 is constant 0, writes below EL2 trap to EL2. */ | 31 | +static uint64_t aa64_allint_read(CPUARMState *env, const ARMCPRegInfo *ri) |
58 | + if (el < 2 && arm_is_el2_enabled(env)) { | 32 | +{ |
59 | + return CP_ACCESS_TRAP_EL2; | 33 | + return env->pstate & PSTATE_ALLINT; |
60 | + } | 34 | +} |
61 | + /* Because ACTLR_EL3 is constant 0, writes below EL3 trap to EL3. */ | 35 | + |
62 | + if (el < 3 && arm_feature(env, ARM_FEATURE_EL3)) { | 36 | +static CPAccessResult aa64_allint_access(CPUARMState *env, |
63 | + return CP_ACCESS_TRAP_EL3; | 37 | + const ARMCPRegInfo *ri, bool isread) |
64 | + } | 38 | +{ |
39 | + if (!isread && arm_current_el(env) == 1 && | ||
40 | + (arm_hcrx_el2_eff(env) & HCRX_TALLINT)) { | ||
41 | + return CP_ACCESS_TRAP_EL2; | ||
65 | + } | 42 | + } |
66 | + return CP_ACCESS_OK; | 43 | + return CP_ACCESS_OK; |
67 | +} | 44 | +} |
68 | + | 45 | + |
69 | static const ARMCPRegInfo neoverse_n1_cp_reginfo[] = { | 46 | +static const ARMCPRegInfo nmi_reginfo[] = { |
70 | { .name = "ATCR_EL1", .state = ARM_CP_STATE_AA64, | 47 | + { .name = "ALLINT", .state = ARM_CP_STATE_AA64, |
71 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 7, .opc2 = 0, | 48 | + .opc0 = 3, .opc1 = 0, .opc2 = 0, .crn = 4, .crm = 3, |
72 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | 49 | + .type = ARM_CP_NO_RAW, |
73 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, | 50 | + .access = PL1_RW, .accessfn = aa64_allint_access, |
74 | + /* Traps and enables are the same as for TCR_EL1. */ | 51 | + .fieldoffset = offsetof(CPUARMState, pstate), |
75 | + .accessfn = access_tvm_trvm, .fgt = FGT_TCR_EL1, }, | 52 | + .writefn = aa64_allint_write, .readfn = aa64_allint_read, |
76 | { .name = "ATCR_EL2", .state = ARM_CP_STATE_AA64, | 53 | + .resetfn = arm_cp_reset_ignore }, |
77 | .opc0 = 3, .opc1 = 4, .crn = 15, .crm = 7, .opc2 = 0, | 54 | +}; |
78 | .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | 55 | #endif /* TARGET_AARCH64 */ |
79 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo neoverse_n1_cp_reginfo[] = { | 56 | |
80 | .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | 57 | static void define_pmu_regs(ARMCPU *cpu) |
81 | { .name = "CPUACTLR_EL1", .state = ARM_CP_STATE_AA64, | 58 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
82 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 0, | 59 | if (cpu_isar_feature(aa64_nv2, cpu)) { |
83 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | 60 | define_arm_cp_regs(cpu, nv2_reginfo); |
84 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, | 61 | } |
85 | + .accessfn = access_actlr_w }, | 62 | + |
86 | { .name = "CPUACTLR2_EL1", .state = ARM_CP_STATE_AA64, | 63 | + if (cpu_isar_feature(aa64_nmi, cpu)) { |
87 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 1, | 64 | + define_arm_cp_regs(cpu, nmi_reginfo); |
88 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | 65 | + } |
89 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, | 66 | #endif |
90 | + .accessfn = access_actlr_w }, | 67 | |
91 | { .name = "CPUACTLR3_EL1", .state = ARM_CP_STATE_AA64, | 68 | if (cpu_isar_feature(any_predinv, cpu)) { |
92 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 2, | ||
93 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
94 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, | ||
95 | + .accessfn = access_actlr_w }, | ||
96 | /* | ||
97 | * Report CPUCFR_EL1.SCU as 1, as we do not implement the DSU | ||
98 | * (and in particular its system registers). | ||
99 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo neoverse_n1_cp_reginfo[] = { | ||
100 | .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 4 }, | ||
101 | { .name = "CPUECTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
102 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 4, | ||
103 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0x961563010 }, | ||
104 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0x961563010, | ||
105 | + .accessfn = access_actlr_w }, | ||
106 | { .name = "CPUPCR_EL3", .state = ARM_CP_STATE_AA64, | ||
107 | .opc0 = 3, .opc1 = 6, .crn = 15, .crm = 8, .opc2 = 1, | ||
108 | .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
109 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo neoverse_n1_cp_reginfo[] = { | ||
110 | .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
111 | { .name = "CPUPWRCTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
112 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 7, | ||
113 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
114 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, | ||
115 | + .accessfn = access_actlr_w }, | ||
116 | { .name = "ERXPFGCDN_EL1", .state = ARM_CP_STATE_AA64, | ||
117 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 2, | ||
118 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
119 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, | ||
120 | + .accessfn = access_actlr_w }, | ||
121 | { .name = "ERXPFGCTL_EL1", .state = ARM_CP_STATE_AA64, | ||
122 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 1, | ||
123 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
124 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, | ||
125 | + .accessfn = access_actlr_w }, | ||
126 | { .name = "ERXPFGF_EL1", .state = ARM_CP_STATE_AA64, | ||
127 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 0, | ||
128 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
129 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, | ||
130 | + .accessfn = access_actlr_w }, | ||
131 | }; | ||
132 | |||
133 | static void define_neoverse_n1_cp_reginfo(ARMCPU *cpu) | ||
134 | -- | 69 | -- |
135 | 2.34.1 | 70 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Jinjie Ruan <ruanjinjie@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | Previously we hard-coded the blocksize with GMID_EL1_BS. | 3 | This only implements the external delivery method via the GICv3. |
4 | But the value we choose for -cpu max does not match the | ||
5 | value that cortex-a710 uses. | ||
6 | 4 | ||
7 | Mirror the way we handle dcz_blocksize. | 5 | Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> |
8 | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Message-id: 20240407081733.3231820-7-ruanjinjie@huawei.com |
11 | Message-id: 20230811214031.171020-3-richard.henderson@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 10 | --- |
14 | target/arm/cpu.h | 2 ++ | 11 | target/arm/cpu-qom.h | 5 +- |
15 | target/arm/internals.h | 6 ----- | 12 | target/arm/cpu.h | 6 ++ |
16 | target/arm/tcg/translate.h | 2 ++ | 13 | target/arm/internals.h | 18 +++++ |
17 | target/arm/helper.c | 11 +++++--- | 14 | target/arm/cpu.c | 147 ++++++++++++++++++++++++++++++++++++++--- |
18 | target/arm/tcg/cpu64.c | 1 + | 15 | target/arm/helper.c | 33 +++++++-- |
19 | target/arm/tcg/mte_helper.c | 46 ++++++++++++++++++++++------------ | 16 | 5 files changed, 193 insertions(+), 16 deletions(-) |
20 | target/arm/tcg/translate-a64.c | 5 ++-- | ||
21 | 7 files changed, 45 insertions(+), 28 deletions(-) | ||
22 | 17 | ||
18 | diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/cpu-qom.h | ||
21 | +++ b/target/arm/cpu-qom.h | ||
22 | @@ -XXX,XX +XXX,XX @@ DECLARE_CLASS_CHECKERS(AArch64CPUClass, AARCH64_CPU, | ||
23 | #define ARM_CPU_TYPE_SUFFIX "-" TYPE_ARM_CPU | ||
24 | #define ARM_CPU_TYPE_NAME(name) (name ARM_CPU_TYPE_SUFFIX) | ||
25 | |||
26 | -/* Meanings of the ARMCPU object's four inbound GPIO lines */ | ||
27 | +/* Meanings of the ARMCPU object's seven inbound GPIO lines */ | ||
28 | #define ARM_CPU_IRQ 0 | ||
29 | #define ARM_CPU_FIQ 1 | ||
30 | #define ARM_CPU_VIRQ 2 | ||
31 | #define ARM_CPU_VFIQ 3 | ||
32 | +#define ARM_CPU_NMI 4 | ||
33 | +#define ARM_CPU_VINMI 5 | ||
34 | +#define ARM_CPU_VFNMI 6 | ||
35 | |||
36 | /* For M profile, some registers are banked secure vs non-secure; | ||
37 | * these are represented as a 2-element array where the first element | ||
23 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 38 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
24 | index XXXXXXX..XXXXXXX 100644 | 39 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/target/arm/cpu.h | 40 | --- a/target/arm/cpu.h |
26 | +++ b/target/arm/cpu.h | 41 | +++ b/target/arm/cpu.h |
27 | @@ -XXX,XX +XXX,XX @@ struct ArchCPU { | 42 | @@ -XXX,XX +XXX,XX @@ |
28 | 43 | #define EXCP_DIVBYZERO 23 /* v7M DIVBYZERO UsageFault */ | |
29 | /* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */ | 44 | #define EXCP_VSERR 24 |
30 | uint8_t dcz_blocksize; | 45 | #define EXCP_GPC 25 /* v9 Granule Protection Check Fault */ |
31 | + /* GM blocksize, in log_2(words), ie low 4 bits of GMID_EL0 */ | 46 | +#define EXCP_NMI 26 |
32 | + uint8_t gm_blocksize; | 47 | +#define EXCP_VINMI 27 |
33 | 48 | +#define EXCP_VFNMI 28 | |
34 | uint64_t rvbar_prop; /* Property/input signals. */ | 49 | /* NB: add new EXCP_ defines to the array in arm_log_exception() too */ |
35 | 50 | ||
51 | #define ARMV7M_EXCP_RESET 1 | ||
52 | @@ -XXX,XX +XXX,XX @@ | ||
53 | #define CPU_INTERRUPT_VIRQ CPU_INTERRUPT_TGT_EXT_2 | ||
54 | #define CPU_INTERRUPT_VFIQ CPU_INTERRUPT_TGT_EXT_3 | ||
55 | #define CPU_INTERRUPT_VSERR CPU_INTERRUPT_TGT_INT_0 | ||
56 | +#define CPU_INTERRUPT_NMI CPU_INTERRUPT_TGT_EXT_4 | ||
57 | +#define CPU_INTERRUPT_VINMI CPU_INTERRUPT_TGT_EXT_0 | ||
58 | +#define CPU_INTERRUPT_VFNMI CPU_INTERRUPT_TGT_INT_1 | ||
59 | |||
60 | /* The usual mapping for an AArch64 system register to its AArch32 | ||
61 | * counterpart is for the 32 bit world to have access to the lower | ||
36 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 62 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
37 | index XXXXXXX..XXXXXXX 100644 | 63 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/target/arm/internals.h | 64 | --- a/target/arm/internals.h |
39 | +++ b/target/arm/internals.h | 65 | +++ b/target/arm/internals.h |
40 | @@ -XXX,XX +XXX,XX @@ void arm_log_exception(CPUState *cs); | 66 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_update_virq(ARMCPU *cpu); |
41 | 67 | */ | |
42 | #endif /* !CONFIG_USER_ONLY */ | 68 | void arm_cpu_update_vfiq(ARMCPU *cpu); |
43 | 69 | ||
44 | -/* | 70 | +/** |
45 | - * The log2 of the words in the tag block, for GMID_EL1.BS. | 71 | + * arm_cpu_update_vinmi: Update CPU_INTERRUPT_VINMI bit in cs->interrupt_request |
46 | - * The is the maximum, 256 bytes, which manipulates 64-bits of tags. | 72 | + * |
47 | - */ | 73 | + * Update the CPU_INTERRUPT_VINMI bit in cs->interrupt_request, following |
48 | -#define GMID_EL1_BS 6 | 74 | + * a change to either the input VNMI line from the GIC or the HCRX_EL2.VINMI. |
49 | - | 75 | + * Must be called with the BQL held. |
50 | /* | 76 | + */ |
51 | * SVE predicates are 1/8 the size of SVE vectors, and cannot use | 77 | +void arm_cpu_update_vinmi(ARMCPU *cpu); |
52 | * the same simd_desc() encoding due to restrictions on size. | 78 | + |
53 | diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h | 79 | +/** |
80 | + * arm_cpu_update_vfnmi: Update CPU_INTERRUPT_VFNMI bit in cs->interrupt_request | ||
81 | + * | ||
82 | + * Update the CPU_INTERRUPT_VFNMI bit in cs->interrupt_request, following | ||
83 | + * a change to the HCRX_EL2.VFNMI. | ||
84 | + * Must be called with the BQL held. | ||
85 | + */ | ||
86 | +void arm_cpu_update_vfnmi(ARMCPU *cpu); | ||
87 | + | ||
88 | /** | ||
89 | * arm_cpu_update_vserr: Update CPU_INTERRUPT_VSERR bit | ||
90 | * | ||
91 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | 92 | index XXXXXXX..XXXXXXX 100644 |
55 | --- a/target/arm/tcg/translate.h | 93 | --- a/target/arm/cpu.c |
56 | +++ b/target/arm/tcg/translate.h | 94 | +++ b/target/arm/cpu.c |
57 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | 95 | @@ -XXX,XX +XXX,XX @@ void arm_restore_state_to_opc(CPUState *cs, |
58 | int8_t btype; | 96 | } |
59 | /* A copy of cpu->dcz_blocksize. */ | 97 | #endif /* CONFIG_TCG */ |
60 | uint8_t dcz_blocksize; | 98 | |
61 | + /* A copy of cpu->gm_blocksize. */ | 99 | +/* |
62 | + uint8_t gm_blocksize; | 100 | + * With SCTLR_ELx.NMI == 0, IRQ with Superpriority is masked identically with |
63 | /* True if this page is guarded. */ | 101 | + * IRQ without Superpriority. Moreover, if the GIC is configured so that |
64 | bool guarded_page; | 102 | + * FEAT_GICv3_NMI is only set if FEAT_NMI is set, then we won't ever see |
65 | /* Bottom two bits of XScale c15_cpar coprocessor access control reg */ | 103 | + * CPU_INTERRUPT_*NMI anyway. So we might as well accept NMI here |
104 | + * unconditionally. | ||
105 | + */ | ||
106 | static bool arm_cpu_has_work(CPUState *cs) | ||
107 | { | ||
108 | ARMCPU *cpu = ARM_CPU(cs); | ||
109 | @@ -XXX,XX +XXX,XX @@ static bool arm_cpu_has_work(CPUState *cs) | ||
110 | return (cpu->power_state != PSCI_OFF) | ||
111 | && cs->interrupt_request & | ||
112 | (CPU_INTERRUPT_FIQ | CPU_INTERRUPT_HARD | ||
113 | + | CPU_INTERRUPT_NMI | CPU_INTERRUPT_VINMI | CPU_INTERRUPT_VFNMI | ||
114 | | CPU_INTERRUPT_VFIQ | CPU_INTERRUPT_VIRQ | CPU_INTERRUPT_VSERR | ||
115 | | CPU_INTERRUPT_EXITTB); | ||
116 | } | ||
117 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx, | ||
118 | CPUARMState *env = cpu_env(cs); | ||
119 | bool pstate_unmasked; | ||
120 | bool unmasked = false; | ||
121 | + bool allIntMask = false; | ||
122 | |||
123 | /* | ||
124 | * Don't take exceptions if they target a lower EL. | ||
125 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx, | ||
126 | return false; | ||
127 | } | ||
128 | |||
129 | + if (cpu_isar_feature(aa64_nmi, env_archcpu(env)) && | ||
130 | + env->cp15.sctlr_el[target_el] & SCTLR_NMI && cur_el == target_el) { | ||
131 | + allIntMask = env->pstate & PSTATE_ALLINT || | ||
132 | + ((env->cp15.sctlr_el[target_el] & SCTLR_SPINTMASK) && | ||
133 | + (env->pstate & PSTATE_SP)); | ||
134 | + } | ||
135 | + | ||
136 | switch (excp_idx) { | ||
137 | + case EXCP_NMI: | ||
138 | + pstate_unmasked = !allIntMask; | ||
139 | + break; | ||
140 | + | ||
141 | + case EXCP_VINMI: | ||
142 | + if (!(hcr_el2 & HCR_IMO) || (hcr_el2 & HCR_TGE)) { | ||
143 | + /* VINMIs are only taken when hypervized. */ | ||
144 | + return false; | ||
145 | + } | ||
146 | + return !allIntMask; | ||
147 | + case EXCP_VFNMI: | ||
148 | + if (!(hcr_el2 & HCR_FMO) || (hcr_el2 & HCR_TGE)) { | ||
149 | + /* VFNMIs are only taken when hypervized. */ | ||
150 | + return false; | ||
151 | + } | ||
152 | + return !allIntMask; | ||
153 | case EXCP_FIQ: | ||
154 | - pstate_unmasked = !(env->daif & PSTATE_F); | ||
155 | + pstate_unmasked = (!(env->daif & PSTATE_F)) && (!allIntMask); | ||
156 | break; | ||
157 | |||
158 | case EXCP_IRQ: | ||
159 | - pstate_unmasked = !(env->daif & PSTATE_I); | ||
160 | + pstate_unmasked = (!(env->daif & PSTATE_I)) && (!allIntMask); | ||
161 | break; | ||
162 | |||
163 | case EXCP_VFIQ: | ||
164 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx, | ||
165 | /* VFIQs are only taken when hypervized. */ | ||
166 | return false; | ||
167 | } | ||
168 | - return !(env->daif & PSTATE_F); | ||
169 | + return !(env->daif & PSTATE_F) && (!allIntMask); | ||
170 | case EXCP_VIRQ: | ||
171 | if (!(hcr_el2 & HCR_IMO) || (hcr_el2 & HCR_TGE)) { | ||
172 | /* VIRQs are only taken when hypervized. */ | ||
173 | return false; | ||
174 | } | ||
175 | - return !(env->daif & PSTATE_I); | ||
176 | + return !(env->daif & PSTATE_I) && (!allIntMask); | ||
177 | case EXCP_VSERR: | ||
178 | if (!(hcr_el2 & HCR_AMO) || (hcr_el2 & HCR_TGE)) { | ||
179 | /* VIRQs are only taken when hypervized. */ | ||
180 | @@ -XXX,XX +XXX,XX @@ static bool arm_cpu_exec_interrupt(CPUState *cs, int interrupt_request) | ||
181 | |||
182 | /* The prioritization of interrupts is IMPLEMENTATION DEFINED. */ | ||
183 | |||
184 | + if (cpu_isar_feature(aa64_nmi, env_archcpu(env)) && | ||
185 | + (arm_sctlr(env, cur_el) & SCTLR_NMI)) { | ||
186 | + if (interrupt_request & CPU_INTERRUPT_NMI) { | ||
187 | + excp_idx = EXCP_NMI; | ||
188 | + target_el = arm_phys_excp_target_el(cs, excp_idx, cur_el, secure); | ||
189 | + if (arm_excp_unmasked(cs, excp_idx, target_el, | ||
190 | + cur_el, secure, hcr_el2)) { | ||
191 | + goto found; | ||
192 | + } | ||
193 | + } | ||
194 | + if (interrupt_request & CPU_INTERRUPT_VINMI) { | ||
195 | + excp_idx = EXCP_VINMI; | ||
196 | + target_el = 1; | ||
197 | + if (arm_excp_unmasked(cs, excp_idx, target_el, | ||
198 | + cur_el, secure, hcr_el2)) { | ||
199 | + goto found; | ||
200 | + } | ||
201 | + } | ||
202 | + if (interrupt_request & CPU_INTERRUPT_VFNMI) { | ||
203 | + excp_idx = EXCP_VFNMI; | ||
204 | + target_el = 1; | ||
205 | + if (arm_excp_unmasked(cs, excp_idx, target_el, | ||
206 | + cur_el, secure, hcr_el2)) { | ||
207 | + goto found; | ||
208 | + } | ||
209 | + } | ||
210 | + } else { | ||
211 | + /* | ||
212 | + * NMI disabled: interrupts with superpriority are handled | ||
213 | + * as if they didn't have it | ||
214 | + */ | ||
215 | + if (interrupt_request & CPU_INTERRUPT_NMI) { | ||
216 | + interrupt_request |= CPU_INTERRUPT_HARD; | ||
217 | + } | ||
218 | + if (interrupt_request & CPU_INTERRUPT_VINMI) { | ||
219 | + interrupt_request |= CPU_INTERRUPT_VIRQ; | ||
220 | + } | ||
221 | + if (interrupt_request & CPU_INTERRUPT_VFNMI) { | ||
222 | + interrupt_request |= CPU_INTERRUPT_VFIQ; | ||
223 | + } | ||
224 | + } | ||
225 | + | ||
226 | if (interrupt_request & CPU_INTERRUPT_FIQ) { | ||
227 | excp_idx = EXCP_FIQ; | ||
228 | target_el = arm_phys_excp_target_el(cs, excp_idx, cur_el, secure); | ||
229 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_update_virq(ARMCPU *cpu) | ||
230 | CPUARMState *env = &cpu->env; | ||
231 | CPUState *cs = CPU(cpu); | ||
232 | |||
233 | - bool new_state = (env->cp15.hcr_el2 & HCR_VI) || | ||
234 | + bool new_state = ((arm_hcr_el2_eff(env) & HCR_VI) && | ||
235 | + !(arm_hcrx_el2_eff(env) & HCRX_VINMI)) || | ||
236 | (env->irq_line_state & CPU_INTERRUPT_VIRQ); | ||
237 | |||
238 | if (new_state != ((cs->interrupt_request & CPU_INTERRUPT_VIRQ) != 0)) { | ||
239 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_update_vfiq(ARMCPU *cpu) | ||
240 | CPUARMState *env = &cpu->env; | ||
241 | CPUState *cs = CPU(cpu); | ||
242 | |||
243 | - bool new_state = (env->cp15.hcr_el2 & HCR_VF) || | ||
244 | + bool new_state = ((arm_hcr_el2_eff(env) & HCR_VF) && | ||
245 | + !(arm_hcrx_el2_eff(env) & HCRX_VFNMI)) || | ||
246 | (env->irq_line_state & CPU_INTERRUPT_VFIQ); | ||
247 | |||
248 | if (new_state != ((cs->interrupt_request & CPU_INTERRUPT_VFIQ) != 0)) { | ||
249 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_update_vfiq(ARMCPU *cpu) | ||
250 | } | ||
251 | } | ||
252 | |||
253 | +void arm_cpu_update_vinmi(ARMCPU *cpu) | ||
254 | +{ | ||
255 | + /* | ||
256 | + * Update the interrupt level for VINMI, which is the logical OR of | ||
257 | + * the HCRX_EL2.VINMI bit and the input line level from the GIC. | ||
258 | + */ | ||
259 | + CPUARMState *env = &cpu->env; | ||
260 | + CPUState *cs = CPU(cpu); | ||
261 | + | ||
262 | + bool new_state = ((arm_hcr_el2_eff(env) & HCR_VI) && | ||
263 | + (arm_hcrx_el2_eff(env) & HCRX_VINMI)) || | ||
264 | + (env->irq_line_state & CPU_INTERRUPT_VINMI); | ||
265 | + | ||
266 | + if (new_state != ((cs->interrupt_request & CPU_INTERRUPT_VINMI) != 0)) { | ||
267 | + if (new_state) { | ||
268 | + cpu_interrupt(cs, CPU_INTERRUPT_VINMI); | ||
269 | + } else { | ||
270 | + cpu_reset_interrupt(cs, CPU_INTERRUPT_VINMI); | ||
271 | + } | ||
272 | + } | ||
273 | +} | ||
274 | + | ||
275 | +void arm_cpu_update_vfnmi(ARMCPU *cpu) | ||
276 | +{ | ||
277 | + /* | ||
278 | + * Update the interrupt level for VFNMI, which is the HCRX_EL2.VFNMI bit. | ||
279 | + */ | ||
280 | + CPUARMState *env = &cpu->env; | ||
281 | + CPUState *cs = CPU(cpu); | ||
282 | + | ||
283 | + bool new_state = (arm_hcr_el2_eff(env) & HCR_VF) && | ||
284 | + (arm_hcrx_el2_eff(env) & HCRX_VFNMI); | ||
285 | + | ||
286 | + if (new_state != ((cs->interrupt_request & CPU_INTERRUPT_VFNMI) != 0)) { | ||
287 | + if (new_state) { | ||
288 | + cpu_interrupt(cs, CPU_INTERRUPT_VFNMI); | ||
289 | + } else { | ||
290 | + cpu_reset_interrupt(cs, CPU_INTERRUPT_VFNMI); | ||
291 | + } | ||
292 | + } | ||
293 | +} | ||
294 | + | ||
295 | void arm_cpu_update_vserr(ARMCPU *cpu) | ||
296 | { | ||
297 | /* | ||
298 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_set_irq(void *opaque, int irq, int level) | ||
299 | [ARM_CPU_IRQ] = CPU_INTERRUPT_HARD, | ||
300 | [ARM_CPU_FIQ] = CPU_INTERRUPT_FIQ, | ||
301 | [ARM_CPU_VIRQ] = CPU_INTERRUPT_VIRQ, | ||
302 | - [ARM_CPU_VFIQ] = CPU_INTERRUPT_VFIQ | ||
303 | + [ARM_CPU_VFIQ] = CPU_INTERRUPT_VFIQ, | ||
304 | + [ARM_CPU_NMI] = CPU_INTERRUPT_NMI, | ||
305 | + [ARM_CPU_VINMI] = CPU_INTERRUPT_VINMI, | ||
306 | }; | ||
307 | |||
308 | if (!arm_feature(env, ARM_FEATURE_EL2) && | ||
309 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_set_irq(void *opaque, int irq, int level) | ||
310 | case ARM_CPU_VFIQ: | ||
311 | arm_cpu_update_vfiq(cpu); | ||
312 | break; | ||
313 | + case ARM_CPU_VINMI: | ||
314 | + arm_cpu_update_vinmi(cpu); | ||
315 | + break; | ||
316 | case ARM_CPU_IRQ: | ||
317 | case ARM_CPU_FIQ: | ||
318 | + case ARM_CPU_NMI: | ||
319 | if (level) { | ||
320 | cpu_interrupt(cs, mask[irq]); | ||
321 | } else { | ||
322 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_initfn(Object *obj) | ||
323 | #else | ||
324 | /* Our inbound IRQ and FIQ lines */ | ||
325 | if (kvm_enabled()) { | ||
326 | - /* VIRQ and VFIQ are unused with KVM but we add them to maintain | ||
327 | - * the same interface as non-KVM CPUs. | ||
328 | + /* | ||
329 | + * VIRQ, VFIQ, NMI, VINMI are unused with KVM but we add | ||
330 | + * them to maintain the same interface as non-KVM CPUs. | ||
331 | */ | ||
332 | - qdev_init_gpio_in(DEVICE(cpu), arm_cpu_kvm_set_irq, 4); | ||
333 | + qdev_init_gpio_in(DEVICE(cpu), arm_cpu_kvm_set_irq, 6); | ||
334 | } else { | ||
335 | - qdev_init_gpio_in(DEVICE(cpu), arm_cpu_set_irq, 4); | ||
336 | + qdev_init_gpio_in(DEVICE(cpu), arm_cpu_set_irq, 6); | ||
337 | } | ||
338 | |||
339 | qdev_init_gpio_out(DEVICE(cpu), cpu->gt_timer_outputs, | ||
66 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 340 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
67 | index XXXXXXX..XXXXXXX 100644 | 341 | index XXXXXXX..XXXXXXX 100644 |
68 | --- a/target/arm/helper.c | 342 | --- a/target/arm/helper.c |
69 | +++ b/target/arm/helper.c | 343 | +++ b/target/arm/helper.c |
70 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_reginfo[] = { | 344 | @@ -XXX,XX +XXX,XX @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask) |
71 | .opc0 = 3, .opc1 = 0, .crn = 1, .crm = 0, .opc2 = 6, | 345 | * and the state of the input lines from the GIC. (This requires |
72 | .access = PL1_RW, .accessfn = access_mte, | 346 | * that we have the BQL, which is done by marking the |
73 | .fieldoffset = offsetof(CPUARMState, cp15.gcr_el1) }, | 347 | * reginfo structs as ARM_CP_IO.) |
74 | - { .name = "GMID_EL1", .state = ARM_CP_STATE_AA64, | 348 | - * Note that if a write to HCR pends a VIRQ or VFIQ it is never |
75 | - .opc0 = 3, .opc1 = 1, .crn = 0, .crm = 0, .opc2 = 4, | 349 | - * possible for it to be taken immediately, because VIRQ and |
76 | - .access = PL1_R, .accessfn = access_aa64_tid5, | 350 | - * VFIQ are masked unless running at EL0 or EL1, and HCR |
77 | - .type = ARM_CP_CONST, .resetvalue = GMID_EL1_BS }, | 351 | - * can only be written at EL2. |
78 | { .name = "TCO", .state = ARM_CP_STATE_AA64, | 352 | + * Note that if a write to HCR pends a VIRQ or VFIQ or VINMI or |
79 | .opc0 = 3, .opc1 = 3, .crn = 4, .crm = 2, .opc2 = 7, | 353 | + * VFNMI, it is never possible for it to be taken immediately |
80 | .type = ARM_CP_NO_RAW, | 354 | + * because VIRQ, VFIQ, VINMI and VFNMI are masked unless running |
81 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | 355 | + * at EL0 or EL1, and HCR can only be written at EL2. |
82 | * then define only a RAZ/WI version of PSTATE.TCO. | ||
83 | */ | 356 | */ |
84 | if (cpu_isar_feature(aa64_mte, cpu)) { | 357 | g_assert(bql_locked()); |
85 | + ARMCPRegInfo gmid_reginfo = { | 358 | arm_cpu_update_virq(cpu); |
86 | + .name = "GMID_EL1", .state = ARM_CP_STATE_AA64, | 359 | arm_cpu_update_vfiq(cpu); |
87 | + .opc0 = 3, .opc1 = 1, .crn = 0, .crm = 0, .opc2 = 4, | 360 | arm_cpu_update_vserr(cpu); |
88 | + .access = PL1_R, .accessfn = access_aa64_tid5, | 361 | + if (cpu_isar_feature(aa64_nmi, cpu)) { |
89 | + .type = ARM_CP_CONST, .resetvalue = cpu->gm_blocksize, | 362 | + arm_cpu_update_vinmi(cpu); |
90 | + }; | 363 | + arm_cpu_update_vfnmi(cpu); |
91 | + define_one_arm_cp_reg(cpu, &gmid_reginfo); | 364 | + } |
92 | define_arm_cp_regs(cpu, mte_reginfo); | ||
93 | define_arm_cp_regs(cpu, mte_el0_cacheop_reginfo); | ||
94 | } else if (cpu_isar_feature(aa64_mte_insn_reg, cpu)) { | ||
95 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c | ||
96 | index XXXXXXX..XXXXXXX 100644 | ||
97 | --- a/target/arm/tcg/cpu64.c | ||
98 | +++ b/target/arm/tcg/cpu64.c | ||
99 | @@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj) | ||
100 | cpu->ctr = 0x80038003; /* 32 byte I and D cacheline size, VIPT icache */ | ||
101 | cpu->dcz_blocksize = 7; /* 512 bytes */ | ||
102 | #endif | ||
103 | + cpu->gm_blocksize = 6; /* 256 bytes */ | ||
104 | |||
105 | cpu->sve_vq.supported = MAKE_64BIT_MASK(0, ARM_MAX_VQ); | ||
106 | cpu->sme_vq.supported = SVE_VQ_POW2_MAP; | ||
107 | diff --git a/target/arm/tcg/mte_helper.c b/target/arm/tcg/mte_helper.c | ||
108 | index XXXXXXX..XXXXXXX 100644 | ||
109 | --- a/target/arm/tcg/mte_helper.c | ||
110 | +++ b/target/arm/tcg/mte_helper.c | ||
111 | @@ -XXX,XX +XXX,XX @@ void HELPER(st2g_stub)(CPUARMState *env, uint64_t ptr) | ||
112 | } | ||
113 | } | 365 | } |
114 | 366 | ||
115 | -#define LDGM_STGM_SIZE (4 << GMID_EL1_BS) | 367 | static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) |
116 | - | 368 | @@ -XXX,XX +XXX,XX @@ static void hcrx_write(CPUARMState *env, const ARMCPRegInfo *ri, |
117 | uint64_t HELPER(ldgm)(CPUARMState *env, uint64_t ptr) | 369 | |
118 | { | 370 | /* Clear RES0 bits. */ |
119 | int mmu_idx = cpu_mmu_index(env, false); | 371 | env->cp15.hcrx_el2 = value & valid_mask; |
120 | uintptr_t ra = GETPC(); | 372 | + |
121 | + int gm_bs = env_archcpu(env)->gm_blocksize; | 373 | + /* |
122 | + int gm_bs_bytes = 4 << gm_bs; | 374 | + * Updates to VINMI and VFNMI require us to update the status of |
123 | void *tag_mem; | 375 | + * virtual NMI, which are the logical OR of these bits |
124 | 376 | + * and the state of the input lines from the GIC. (This requires | |
125 | - ptr = QEMU_ALIGN_DOWN(ptr, LDGM_STGM_SIZE); | 377 | + * that we have the BQL, which is done by marking the |
126 | + ptr = QEMU_ALIGN_DOWN(ptr, gm_bs_bytes); | 378 | + * reginfo structs as ARM_CP_IO.) |
127 | 379 | + * Note that if a write to HCRX pends a VINMI or VFNMI it is never | |
128 | /* Trap if accessing an invalid page. */ | 380 | + * possible for it to be taken immediately, because VINMI and |
129 | tag_mem = allocation_tag_mem(env, mmu_idx, ptr, MMU_DATA_LOAD, | 381 | + * VFNMI are masked unless running at EL0 or EL1, and HCRX |
130 | - LDGM_STGM_SIZE, MMU_DATA_LOAD, | 382 | + * can only be written at EL2. |
131 | - LDGM_STGM_SIZE / (2 * TAG_GRANULE), ra); | 383 | + */ |
132 | + gm_bs_bytes, MMU_DATA_LOAD, | 384 | + if (cpu_isar_feature(aa64_nmi, cpu)) { |
133 | + gm_bs_bytes / (2 * TAG_GRANULE), ra); | 385 | + g_assert(bql_locked()); |
134 | 386 | + arm_cpu_update_vinmi(cpu); | |
135 | /* The tag is squashed to zero if the page does not support tags. */ | 387 | + arm_cpu_update_vfnmi(cpu); |
136 | if (!tag_mem) { | ||
137 | return 0; | ||
138 | } | ||
139 | |||
140 | - QEMU_BUILD_BUG_ON(GMID_EL1_BS != 6); | ||
141 | /* | ||
142 | - * We are loading 64-bits worth of tags. The ordering of elements | ||
143 | - * within the word corresponds to a 64-bit little-endian operation. | ||
144 | + * The ordering of elements within the word corresponds to | ||
145 | + * a little-endian operation. | ||
146 | */ | ||
147 | - return ldq_le_p(tag_mem); | ||
148 | + switch (gm_bs) { | ||
149 | + case 6: | ||
150 | + /* 256 bytes -> 16 tags -> 64 result bits */ | ||
151 | + return ldq_le_p(tag_mem); | ||
152 | + default: | ||
153 | + /* cpu configured with unsupported gm blocksize. */ | ||
154 | + g_assert_not_reached(); | ||
155 | + } | 388 | + } |
156 | } | 389 | } |
157 | 390 | ||
158 | void HELPER(stgm)(CPUARMState *env, uint64_t ptr, uint64_t val) | 391 | static CPAccessResult access_hxen(CPUARMState *env, const ARMCPRegInfo *ri, |
159 | { | 392 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_hxen(CPUARMState *env, const ARMCPRegInfo *ri, |
160 | int mmu_idx = cpu_mmu_index(env, false); | 393 | |
161 | uintptr_t ra = GETPC(); | 394 | static const ARMCPRegInfo hcrx_el2_reginfo = { |
162 | + int gm_bs = env_archcpu(env)->gm_blocksize; | 395 | .name = "HCRX_EL2", .state = ARM_CP_STATE_AA64, |
163 | + int gm_bs_bytes = 4 << gm_bs; | 396 | + .type = ARM_CP_IO, |
164 | void *tag_mem; | 397 | .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 2, |
165 | 398 | .access = PL2_RW, .writefn = hcrx_write, .accessfn = access_hxen, | |
166 | - ptr = QEMU_ALIGN_DOWN(ptr, LDGM_STGM_SIZE); | 399 | .nv2_redirect_offset = 0xa0, |
167 | + ptr = QEMU_ALIGN_DOWN(ptr, gm_bs_bytes); | 400 | @@ -XXX,XX +XXX,XX @@ void arm_log_exception(CPUState *cs) |
168 | 401 | [EXCP_DIVBYZERO] = "v7M DIVBYZERO UsageFault", | |
169 | /* Trap if accessing an invalid page. */ | 402 | [EXCP_VSERR] = "Virtual SERR", |
170 | tag_mem = allocation_tag_mem(env, mmu_idx, ptr, MMU_DATA_STORE, | 403 | [EXCP_GPC] = "Granule Protection Check", |
171 | - LDGM_STGM_SIZE, MMU_DATA_LOAD, | 404 | + [EXCP_NMI] = "NMI", |
172 | - LDGM_STGM_SIZE / (2 * TAG_GRANULE), ra); | 405 | + [EXCP_VINMI] = "Virtual IRQ NMI", |
173 | + gm_bs_bytes, MMU_DATA_LOAD, | 406 | + [EXCP_VFNMI] = "Virtual FIQ NMI", |
174 | + gm_bs_bytes / (2 * TAG_GRANULE), ra); | 407 | }; |
175 | 408 | ||
176 | /* | 409 | if (idx >= 0 && idx < ARRAY_SIZE(excnames)) { |
177 | * Tag store only happens if the page support tags, | ||
178 | @@ -XXX,XX +XXX,XX @@ void HELPER(stgm)(CPUARMState *env, uint64_t ptr, uint64_t val) | ||
179 | return; | ||
180 | } | ||
181 | |||
182 | - QEMU_BUILD_BUG_ON(GMID_EL1_BS != 6); | ||
183 | /* | ||
184 | - * We are storing 64-bits worth of tags. The ordering of elements | ||
185 | - * within the word corresponds to a 64-bit little-endian operation. | ||
186 | + * The ordering of elements within the word corresponds to | ||
187 | + * a little-endian operation. | ||
188 | */ | ||
189 | - stq_le_p(tag_mem, val); | ||
190 | + switch (gm_bs) { | ||
191 | + case 6: | ||
192 | + stq_le_p(tag_mem, val); | ||
193 | + break; | ||
194 | + default: | ||
195 | + /* cpu configured with unsupported gm blocksize. */ | ||
196 | + g_assert_not_reached(); | ||
197 | + } | ||
198 | } | ||
199 | |||
200 | void HELPER(stzgm_tags)(CPUARMState *env, uint64_t ptr, uint64_t val) | ||
201 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
202 | index XXXXXXX..XXXXXXX 100644 | ||
203 | --- a/target/arm/tcg/translate-a64.c | ||
204 | +++ b/target/arm/tcg/translate-a64.c | ||
205 | @@ -XXX,XX +XXX,XX @@ static bool trans_STGM(DisasContext *s, arg_ldst_tag *a) | ||
206 | gen_helper_stgm(cpu_env, addr, tcg_rt); | ||
207 | } else { | ||
208 | MMUAccessType acc = MMU_DATA_STORE; | ||
209 | - int size = 4 << GMID_EL1_BS; | ||
210 | + int size = 4 << s->gm_blocksize; | ||
211 | |||
212 | clean_addr = clean_data_tbi(s, addr); | ||
213 | tcg_gen_andi_i64(clean_addr, clean_addr, -size); | ||
214 | @@ -XXX,XX +XXX,XX @@ static bool trans_LDGM(DisasContext *s, arg_ldst_tag *a) | ||
215 | gen_helper_ldgm(tcg_rt, cpu_env, addr); | ||
216 | } else { | ||
217 | MMUAccessType acc = MMU_DATA_LOAD; | ||
218 | - int size = 4 << GMID_EL1_BS; | ||
219 | + int size = 4 << s->gm_blocksize; | ||
220 | |||
221 | clean_addr = clean_data_tbi(s, addr); | ||
222 | tcg_gen_andi_i64(clean_addr, clean_addr, -size); | ||
223 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | ||
224 | dc->cp_regs = arm_cpu->cp_regs; | ||
225 | dc->features = env->features; | ||
226 | dc->dcz_blocksize = arm_cpu->dcz_blocksize; | ||
227 | + dc->gm_blocksize = arm_cpu->gm_blocksize; | ||
228 | |||
229 | #ifdef CONFIG_USER_ONLY | ||
230 | /* In sve_probe_page, we assume TBI is enabled. */ | ||
231 | -- | 410 | -- |
232 | 2.34.1 | 411 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Jinjie Ruan <ruanjinjie@huawei.com> | ||
1 | 2 | ||
3 | According to Arm GIC section 4.6.3 Interrupt superpriority, the interrupt | ||
4 | with superpriority is always IRQ, never FIQ, so handle NMI same as IRQ in | ||
5 | arm_phys_excp_target_el(). | ||
6 | |||
7 | Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Message-id: 20240407081733.3231820-8-ruanjinjie@huawei.com | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | target/arm/helper.c | 1 + | ||
14 | 1 file changed, 1 insertion(+) | ||
15 | |||
16 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/helper.c | ||
19 | +++ b/target/arm/helper.c | ||
20 | @@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx, | ||
21 | hcr_el2 = arm_hcr_el2_eff(env); | ||
22 | switch (excp_idx) { | ||
23 | case EXCP_IRQ: | ||
24 | + case EXCP_NMI: | ||
25 | scr = ((env->cp15.scr_el3 & SCR_IRQ) == SCR_IRQ); | ||
26 | hcr = hcr_el2 & HCR_IMO; | ||
27 | break; | ||
28 | -- | ||
29 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Jinjie Ruan <ruanjinjie@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | This value is only 4 bits wide. | 3 | Add IS and FS bit in ISR_EL1 and handle the read. With CPU_INTERRUPT_NMI or |
4 | CPU_INTERRUPT_VINMI, both CPSR_I and ISR_IS must be set. With | ||
5 | CPU_INTERRUPT_VFNMI, both CPSR_F and ISR_FS must be set. | ||
4 | 6 | ||
7 | Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Message-id: 20240407081733.3231820-9-ruanjinjie@huawei.com |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Message-id: 20230811214031.171020-2-richard.henderson@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 | target/arm/cpu.h | 3 ++- | 13 | target/arm/cpu.h | 2 ++ |
12 | 1 file changed, 2 insertions(+), 1 deletion(-) | 14 | target/arm/helper.c | 13 +++++++++++++ |
15 | 2 files changed, 15 insertions(+) | ||
13 | 16 | ||
14 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
15 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/cpu.h | 19 | --- a/target/arm/cpu.h |
17 | +++ b/target/arm/cpu.h | 20 | +++ b/target/arm/cpu.h |
18 | @@ -XXX,XX +XXX,XX @@ struct ArchCPU { | 21 | @@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu); |
19 | bool prop_lpa2; | 22 | #define CPSR_N (1U << 31) |
20 | 23 | #define CPSR_NZCV (CPSR_N | CPSR_Z | CPSR_C | CPSR_V) | |
21 | /* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */ | 24 | #define CPSR_AIF (CPSR_A | CPSR_I | CPSR_F) |
22 | - uint32_t dcz_blocksize; | 25 | +#define ISR_FS (1U << 9) |
23 | + uint8_t dcz_blocksize; | 26 | +#define ISR_IS (1U << 10) |
27 | |||
28 | #define CPSR_IT (CPSR_IT_0_1 | CPSR_IT_2_7) | ||
29 | #define CACHED_CPSR_BITS (CPSR_T | CPSR_AIF | CPSR_GE | CPSR_IT | CPSR_Q \ | ||
30 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/helper.c | ||
33 | +++ b/target/arm/helper.c | ||
34 | @@ -XXX,XX +XXX,XX @@ static uint64_t isr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
35 | if (cs->interrupt_request & CPU_INTERRUPT_VIRQ) { | ||
36 | ret |= CPSR_I; | ||
37 | } | ||
38 | + if (cs->interrupt_request & CPU_INTERRUPT_VINMI) { | ||
39 | + ret |= ISR_IS; | ||
40 | + ret |= CPSR_I; | ||
41 | + } | ||
42 | } else { | ||
43 | if (cs->interrupt_request & CPU_INTERRUPT_HARD) { | ||
44 | ret |= CPSR_I; | ||
45 | } | ||
24 | + | 46 | + |
25 | uint64_t rvbar_prop; /* Property/input signals. */ | 47 | + if (cs->interrupt_request & CPU_INTERRUPT_NMI) { |
26 | 48 | + ret |= ISR_IS; | |
27 | /* Configurable aspects of GIC cpu interface (which is part of the CPU) */ | 49 | + ret |= CPSR_I; |
50 | + } | ||
51 | } | ||
52 | |||
53 | if (hcr_el2 & HCR_FMO) { | ||
54 | if (cs->interrupt_request & CPU_INTERRUPT_VFIQ) { | ||
55 | ret |= CPSR_F; | ||
56 | } | ||
57 | + if (cs->interrupt_request & CPU_INTERRUPT_VFNMI) { | ||
58 | + ret |= ISR_FS; | ||
59 | + ret |= CPSR_F; | ||
60 | + } | ||
61 | } else { | ||
62 | if (cs->interrupt_request & CPU_INTERRUPT_FIQ) { | ||
63 | ret |= CPSR_F; | ||
28 | -- | 64 | -- |
29 | 2.34.1 | 65 | 2.34.1 |
30 | |||
31 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Jinjie Ruan <ruanjinjie@huawei.com> | ||
1 | 2 | ||
3 | Set or clear PSTATE.ALLINT on taking an exception to ELx according to the | ||
4 | SCTLR_ELx.SPINTMASK bit. | ||
5 | |||
6 | Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Message-id: 20240407081733.3231820-10-ruanjinjie@huawei.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/helper.c | 8 ++++++++ | ||
13 | 1 file changed, 8 insertions(+) | ||
14 | |||
15 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/helper.c | ||
18 | +++ b/target/arm/helper.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) | ||
20 | } | ||
21 | } | ||
22 | |||
23 | + if (cpu_isar_feature(aa64_nmi, cpu)) { | ||
24 | + if (!(env->cp15.sctlr_el[new_el] & SCTLR_SPINTMASK)) { | ||
25 | + new_mode |= PSTATE_ALLINT; | ||
26 | + } else { | ||
27 | + new_mode &= ~PSTATE_ALLINT; | ||
28 | + } | ||
29 | + } | ||
30 | + | ||
31 | pstate_write(env, PSTATE_DAIF | new_mode); | ||
32 | env->aarch64 = true; | ||
33 | aarch64_restore_sp(env, new_el); | ||
34 | -- | ||
35 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Jinjie Ruan <ruanjinjie@huawei.com> | ||
1 | 2 | ||
3 | Augment the GICv3's QOM device interface by adding one | ||
4 | new set of sysbus IRQ line, to signal NMI to each CPU. | ||
5 | |||
6 | Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Message-id: 20240407081733.3231820-11-ruanjinjie@huawei.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | include/hw/intc/arm_gic_common.h | 2 ++ | ||
13 | include/hw/intc/arm_gicv3_common.h | 2 ++ | ||
14 | hw/intc/arm_gicv3_common.c | 6 ++++++ | ||
15 | 3 files changed, 10 insertions(+) | ||
16 | |||
17 | diff --git a/include/hw/intc/arm_gic_common.h b/include/hw/intc/arm_gic_common.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/include/hw/intc/arm_gic_common.h | ||
20 | +++ b/include/hw/intc/arm_gic_common.h | ||
21 | @@ -XXX,XX +XXX,XX @@ struct GICState { | ||
22 | qemu_irq parent_fiq[GIC_NCPU]; | ||
23 | qemu_irq parent_virq[GIC_NCPU]; | ||
24 | qemu_irq parent_vfiq[GIC_NCPU]; | ||
25 | + qemu_irq parent_nmi[GIC_NCPU]; | ||
26 | + qemu_irq parent_vnmi[GIC_NCPU]; | ||
27 | qemu_irq maintenance_irq[GIC_NCPU]; | ||
28 | |||
29 | /* GICD_CTLR; for a GIC with the security extensions the NS banked version | ||
30 | diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/include/hw/intc/arm_gicv3_common.h | ||
33 | +++ b/include/hw/intc/arm_gicv3_common.h | ||
34 | @@ -XXX,XX +XXX,XX @@ struct GICv3CPUState { | ||
35 | qemu_irq parent_fiq; | ||
36 | qemu_irq parent_virq; | ||
37 | qemu_irq parent_vfiq; | ||
38 | + qemu_irq parent_nmi; | ||
39 | + qemu_irq parent_vnmi; | ||
40 | |||
41 | /* Redistributor */ | ||
42 | uint32_t level; /* Current IRQ level */ | ||
43 | diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/hw/intc/arm_gicv3_common.c | ||
46 | +++ b/hw/intc/arm_gicv3_common.c | ||
47 | @@ -XXX,XX +XXX,XX @@ void gicv3_init_irqs_and_mmio(GICv3State *s, qemu_irq_handler handler, | ||
48 | for (i = 0; i < s->num_cpu; i++) { | ||
49 | sysbus_init_irq(sbd, &s->cpu[i].parent_vfiq); | ||
50 | } | ||
51 | + for (i = 0; i < s->num_cpu; i++) { | ||
52 | + sysbus_init_irq(sbd, &s->cpu[i].parent_nmi); | ||
53 | + } | ||
54 | + for (i = 0; i < s->num_cpu; i++) { | ||
55 | + sysbus_init_irq(sbd, &s->cpu[i].parent_vnmi); | ||
56 | + } | ||
57 | |||
58 | memory_region_init_io(&s->iomem_dist, OBJECT(s), ops, s, | ||
59 | "gicv3_dist", 0x10000); | ||
60 | -- | ||
61 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Jinjie Ruan <ruanjinjie@huawei.com> | ||
1 | 2 | ||
3 | Wire the new NMI and VINMI interrupt line from the GIC to each CPU if it | ||
4 | is not GICv2. | ||
5 | |||
6 | Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20240407081733.3231820-12-ruanjinjie@huawei.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/arm/virt.c | 10 +++++++++- | ||
12 | 1 file changed, 9 insertions(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/arm/virt.c | ||
17 | +++ b/hw/arm/virt.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem) | ||
19 | |||
20 | /* Wire the outputs from each CPU's generic timer and the GICv3 | ||
21 | * maintenance interrupt signal to the appropriate GIC PPI inputs, | ||
22 | - * and the GIC's IRQ/FIQ/VIRQ/VFIQ interrupt outputs to the CPU's inputs. | ||
23 | + * and the GIC's IRQ/FIQ/VIRQ/VFIQ/NMI/VINMI interrupt outputs to the | ||
24 | + * CPU's inputs. | ||
25 | */ | ||
26 | for (i = 0; i < smp_cpus; i++) { | ||
27 | DeviceState *cpudev = DEVICE(qemu_get_cpu(i)); | ||
28 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem) | ||
29 | qdev_get_gpio_in(cpudev, ARM_CPU_VIRQ)); | ||
30 | sysbus_connect_irq(gicbusdev, i + 3 * smp_cpus, | ||
31 | qdev_get_gpio_in(cpudev, ARM_CPU_VFIQ)); | ||
32 | + | ||
33 | + if (vms->gic_version != VIRT_GIC_VERSION_2) { | ||
34 | + sysbus_connect_irq(gicbusdev, i + 4 * smp_cpus, | ||
35 | + qdev_get_gpio_in(cpudev, ARM_CPU_NMI)); | ||
36 | + sysbus_connect_irq(gicbusdev, i + 5 * smp_cpus, | ||
37 | + qdev_get_gpio_in(cpudev, ARM_CPU_VINMI)); | ||
38 | + } | ||
39 | } | ||
40 | |||
41 | fdt_add_gic_node(vms); | ||
42 | -- | ||
43 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Jinjie Ruan <ruanjinjie@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | Like FEAT_TRF (Self-hosted Trace Extension), suppress tracing | 3 | According to Arm GIC section 4.6.3 Interrupt superpriority, the interrupt |
4 | external to the cpu, which is out of scope for QEMU. | 4 | with superpriority is always IRQ, never FIQ, so the NMI exception trap entry |
5 | behave like IRQ. And VINMI(vIRQ with Superpriority) can be raised from the | ||
6 | GIC or come from the hcrx_el2.HCRX_VINMI bit, VFNMI(vFIQ with Superpriority) | ||
7 | come from the hcrx_el2.HCRX_VFNMI bit. | ||
5 | 8 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20230811214031.171020-10-richard.henderson@linaro.org | 12 | Message-id: 20240407081733.3231820-13-ruanjinjie@huawei.com |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 14 | --- |
11 | target/arm/cpu.c | 3 +++ | 15 | target/arm/helper.c | 3 +++ |
12 | 1 file changed, 3 insertions(+) | 16 | 1 file changed, 3 insertions(+) |
13 | 17 | ||
14 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 18 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
15 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/cpu.c | 20 | --- a/target/arm/helper.c |
17 | +++ b/target/arm/cpu.c | 21 | +++ b/target/arm/helper.c |
18 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | 22 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) |
19 | /* FEAT_SPE (Statistical Profiling Extension) */ | 23 | break; |
20 | cpu->isar.id_aa64dfr0 = | 24 | case EXCP_IRQ: |
21 | FIELD_DP64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, PMSVER, 0); | 25 | case EXCP_VIRQ: |
22 | + /* FEAT_TRBE (Trace Buffer Extension) */ | 26 | + case EXCP_NMI: |
23 | + cpu->isar.id_aa64dfr0 = | 27 | + case EXCP_VINMI: |
24 | + FIELD_DP64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, TRACEBUFFER, 0); | 28 | addr += 0x80; |
25 | /* FEAT_TRF (Self-hosted Trace Extension) */ | 29 | break; |
26 | cpu->isar.id_aa64dfr0 = | 30 | case EXCP_FIQ: |
27 | FIELD_DP64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, TRACEFILT, 0); | 31 | case EXCP_VFIQ: |
32 | + case EXCP_VFNMI: | ||
33 | addr += 0x100; | ||
34 | break; | ||
35 | case EXCP_VSERR: | ||
28 | -- | 36 | -- |
29 | 2.34.1 | 37 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Jinjie Ruan <ruanjinjie@huawei.com> | ||
1 | 2 | ||
3 | Add a property has-nmi to the GICv3 device, and use this to set | ||
4 | the NMI bit in the GICD_TYPER register. This isn't visible to | ||
5 | guests yet because the property defaults to false and we won't | ||
6 | set it in the board code until we've landed all of the changes | ||
7 | needed to implement FEAT_GICV3_NMI. | ||
8 | |||
9 | Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Message-id: 20240407081733.3231820-14-ruanjinjie@huawei.com | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | hw/intc/gicv3_internal.h | 1 + | ||
16 | include/hw/intc/arm_gicv3_common.h | 1 + | ||
17 | hw/intc/arm_gicv3_common.c | 1 + | ||
18 | hw/intc/arm_gicv3_dist.c | 2 ++ | ||
19 | 4 files changed, 5 insertions(+) | ||
20 | |||
21 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/hw/intc/gicv3_internal.h | ||
24 | +++ b/hw/intc/gicv3_internal.h | ||
25 | @@ -XXX,XX +XXX,XX @@ | ||
26 | #define GICD_CTLR_E1NWF (1U << 7) | ||
27 | #define GICD_CTLR_RWP (1U << 31) | ||
28 | |||
29 | +#define GICD_TYPER_NMI_SHIFT 9 | ||
30 | #define GICD_TYPER_LPIS_SHIFT 17 | ||
31 | |||
32 | /* 16 bits EventId */ | ||
33 | diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/include/hw/intc/arm_gicv3_common.h | ||
36 | +++ b/include/hw/intc/arm_gicv3_common.h | ||
37 | @@ -XXX,XX +XXX,XX @@ struct GICv3State { | ||
38 | uint32_t num_irq; | ||
39 | uint32_t revision; | ||
40 | bool lpi_enable; | ||
41 | + bool nmi_support; | ||
42 | bool security_extn; | ||
43 | bool force_8bit_prio; | ||
44 | bool irq_reset_nonsecure; | ||
45 | diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/hw/intc/arm_gicv3_common.c | ||
48 | +++ b/hw/intc/arm_gicv3_common.c | ||
49 | @@ -XXX,XX +XXX,XX @@ static Property arm_gicv3_common_properties[] = { | ||
50 | DEFINE_PROP_UINT32("num-irq", GICv3State, num_irq, 32), | ||
51 | DEFINE_PROP_UINT32("revision", GICv3State, revision, 3), | ||
52 | DEFINE_PROP_BOOL("has-lpi", GICv3State, lpi_enable, 0), | ||
53 | + DEFINE_PROP_BOOL("has-nmi", GICv3State, nmi_support, 0), | ||
54 | DEFINE_PROP_BOOL("has-security-extensions", GICv3State, security_extn, 0), | ||
55 | /* | ||
56 | * Compatibility property: force 8 bits of physical priority, even | ||
57 | diff --git a/hw/intc/arm_gicv3_dist.c b/hw/intc/arm_gicv3_dist.c | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/hw/intc/arm_gicv3_dist.c | ||
60 | +++ b/hw/intc/arm_gicv3_dist.c | ||
61 | @@ -XXX,XX +XXX,XX @@ static bool gicd_readl(GICv3State *s, hwaddr offset, | ||
62 | * by GICD_TYPER.IDbits) | ||
63 | * MBIS == 0 (message-based SPIs not supported) | ||
64 | * SecurityExtn == 1 if security extns supported | ||
65 | + * NMI = 1 if Non-maskable interrupt property is supported | ||
66 | * CPUNumber == 0 since for us ARE is always 1 | ||
67 | * ITLinesNumber == (((max SPI IntID + 1) / 32) - 1) | ||
68 | */ | ||
69 | @@ -XXX,XX +XXX,XX @@ static bool gicd_readl(GICv3State *s, hwaddr offset, | ||
70 | bool dvis = s->revision >= 4; | ||
71 | |||
72 | *data = (1 << 25) | (1 << 24) | (dvis << 18) | (sec_extn << 10) | | ||
73 | + (s->nmi_support << GICD_TYPER_NMI_SHIFT) | | ||
74 | (s->lpi_enable << GICD_TYPER_LPIS_SHIFT) | | ||
75 | (0xf << 19) | itlinesnumber; | ||
76 | return true; | ||
77 | -- | ||
78 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> | 1 | From: Jinjie Ruan <ruanjinjie@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | * Add Addr and size definition for all i.MX7 devices in i.MX7 header file. | 3 | So far, there is no FEAT_GICv3_NMI support in the in-kernel GIC, so make it |
4 | * Use those newly defined named constants whenever possible. | 4 | an error to try to set has-nmi=true for the KVM GICv3. |
5 | * Standardize the way we init a familly of unimplemented devices | ||
6 | - SAI | ||
7 | - PWM | ||
8 | - CAN | ||
9 | * Add/rework few comments | ||
10 | 5 | ||
11 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> | 6 | Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> |
12 | Message-id: 59e195d33e4d486a8d131392acd46633c8c10ed7.1692964892.git.jcd@tribudubois.net | 7 | Message-id: 20240407081733.3231820-15-ruanjinjie@huawei.com |
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 10 | --- |
16 | include/hw/arm/fsl-imx7.h | 330 ++++++++++++++++++++++++++++---------- | 11 | hw/intc/arm_gicv3_kvm.c | 5 +++++ |
17 | hw/arm/fsl-imx7.c | 130 ++++++++++----- | 12 | 1 file changed, 5 insertions(+) |
18 | 2 files changed, 335 insertions(+), 125 deletions(-) | ||
19 | 13 | ||
20 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h | 14 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c |
21 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/hw/arm/fsl-imx7.h | 16 | --- a/hw/intc/arm_gicv3_kvm.c |
23 | +++ b/include/hw/arm/fsl-imx7.h | 17 | +++ b/hw/intc/arm_gicv3_kvm.c |
24 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp) |
25 | #include "hw/misc/imx7_ccm.h" | ||
26 | #include "hw/misc/imx7_snvs.h" | ||
27 | #include "hw/misc/imx7_gpr.h" | ||
28 | -#include "hw/misc/imx6_src.h" | ||
29 | #include "hw/watchdog/wdt_imx2.h" | ||
30 | #include "hw/gpio/imx_gpio.h" | ||
31 | #include "hw/char/imx_serial.h" | ||
32 | @@ -XXX,XX +XXX,XX @@ | ||
33 | #include "hw/usb/chipidea.h" | ||
34 | #include "cpu.h" | ||
35 | #include "qom/object.h" | ||
36 | +#include "qemu/units.h" | ||
37 | |||
38 | #define TYPE_FSL_IMX7 "fsl-imx7" | ||
39 | OBJECT_DECLARE_SIMPLE_TYPE(FslIMX7State, FSL_IMX7) | ||
40 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7Configuration { | ||
41 | FSL_IMX7_NUM_ECSPIS = 4, | ||
42 | FSL_IMX7_NUM_USBS = 3, | ||
43 | FSL_IMX7_NUM_ADCS = 2, | ||
44 | + FSL_IMX7_NUM_SAIS = 3, | ||
45 | + FSL_IMX7_NUM_CANS = 2, | ||
46 | + FSL_IMX7_NUM_PWMS = 4, | ||
47 | }; | ||
48 | |||
49 | struct FslIMX7State { | ||
50 | @@ -XXX,XX +XXX,XX @@ struct FslIMX7State { | ||
51 | |||
52 | enum FslIMX7MemoryMap { | ||
53 | FSL_IMX7_MMDC_ADDR = 0x80000000, | ||
54 | - FSL_IMX7_MMDC_SIZE = 2 * 1024 * 1024 * 1024UL, | ||
55 | + FSL_IMX7_MMDC_SIZE = (2 * GiB), | ||
56 | |||
57 | - FSL_IMX7_GPIO1_ADDR = 0x30200000, | ||
58 | - FSL_IMX7_GPIO2_ADDR = 0x30210000, | ||
59 | - FSL_IMX7_GPIO3_ADDR = 0x30220000, | ||
60 | - FSL_IMX7_GPIO4_ADDR = 0x30230000, | ||
61 | - FSL_IMX7_GPIO5_ADDR = 0x30240000, | ||
62 | - FSL_IMX7_GPIO6_ADDR = 0x30250000, | ||
63 | - FSL_IMX7_GPIO7_ADDR = 0x30260000, | ||
64 | + FSL_IMX7_QSPI1_MEM_ADDR = 0x60000000, | ||
65 | + FSL_IMX7_QSPI1_MEM_SIZE = (256 * MiB), | ||
66 | |||
67 | - FSL_IMX7_IOMUXC_LPSR_GPR_ADDR = 0x30270000, | ||
68 | + FSL_IMX7_PCIE1_MEM_ADDR = 0x40000000, | ||
69 | + FSL_IMX7_PCIE1_MEM_SIZE = (256 * MiB), | ||
70 | |||
71 | - FSL_IMX7_WDOG1_ADDR = 0x30280000, | ||
72 | - FSL_IMX7_WDOG2_ADDR = 0x30290000, | ||
73 | - FSL_IMX7_WDOG3_ADDR = 0x302A0000, | ||
74 | - FSL_IMX7_WDOG4_ADDR = 0x302B0000, | ||
75 | + FSL_IMX7_QSPI1_RX_BUF_ADDR = 0x34000000, | ||
76 | + FSL_IMX7_QSPI1_RX_BUF_SIZE = (32 * MiB), | ||
77 | |||
78 | - FSL_IMX7_IOMUXC_LPSR_ADDR = 0x302C0000, | ||
79 | + /* PCIe Peripherals */ | ||
80 | + FSL_IMX7_PCIE_REG_ADDR = 0x33800000, | ||
81 | |||
82 | - FSL_IMX7_GPT1_ADDR = 0x302D0000, | ||
83 | - FSL_IMX7_GPT2_ADDR = 0x302E0000, | ||
84 | - FSL_IMX7_GPT3_ADDR = 0x302F0000, | ||
85 | - FSL_IMX7_GPT4_ADDR = 0x30300000, | ||
86 | + /* MMAP Peripherals */ | ||
87 | + FSL_IMX7_DMA_APBH_ADDR = 0x33000000, | ||
88 | + FSL_IMX7_DMA_APBH_SIZE = 0x8000, | ||
89 | |||
90 | - FSL_IMX7_IOMUXC_ADDR = 0x30330000, | ||
91 | - FSL_IMX7_IOMUXC_GPR_ADDR = 0x30340000, | ||
92 | - FSL_IMX7_IOMUXCn_SIZE = 0x1000, | ||
93 | + /* GPV configuration */ | ||
94 | + FSL_IMX7_GPV6_ADDR = 0x32600000, | ||
95 | + FSL_IMX7_GPV5_ADDR = 0x32500000, | ||
96 | + FSL_IMX7_GPV4_ADDR = 0x32400000, | ||
97 | + FSL_IMX7_GPV3_ADDR = 0x32300000, | ||
98 | + FSL_IMX7_GPV2_ADDR = 0x32200000, | ||
99 | + FSL_IMX7_GPV1_ADDR = 0x32100000, | ||
100 | + FSL_IMX7_GPV0_ADDR = 0x32000000, | ||
101 | + FSL_IMX7_GPVn_SIZE = (1 * MiB), | ||
102 | |||
103 | - FSL_IMX7_OCOTP_ADDR = 0x30350000, | ||
104 | - FSL_IMX7_OCOTP_SIZE = 0x10000, | ||
105 | + /* Arm Peripherals */ | ||
106 | + FSL_IMX7_A7MPCORE_ADDR = 0x31000000, | ||
107 | |||
108 | - FSL_IMX7_ANALOG_ADDR = 0x30360000, | ||
109 | - FSL_IMX7_SNVS_ADDR = 0x30370000, | ||
110 | - FSL_IMX7_CCM_ADDR = 0x30380000, | ||
111 | + /* AIPS-3 Begin */ | ||
112 | |||
113 | - FSL_IMX7_SRC_ADDR = 0x30390000, | ||
114 | - FSL_IMX7_SRC_SIZE = 0x1000, | ||
115 | + FSL_IMX7_ENET2_ADDR = 0x30BF0000, | ||
116 | + FSL_IMX7_ENET1_ADDR = 0x30BE0000, | ||
117 | |||
118 | - FSL_IMX7_ADC1_ADDR = 0x30610000, | ||
119 | - FSL_IMX7_ADC2_ADDR = 0x30620000, | ||
120 | - FSL_IMX7_ADCn_SIZE = 0x1000, | ||
121 | + FSL_IMX7_SDMA_ADDR = 0x30BD0000, | ||
122 | + FSL_IMX7_SDMA_SIZE = (4 * KiB), | ||
123 | |||
124 | - FSL_IMX7_PWM1_ADDR = 0x30660000, | ||
125 | - FSL_IMX7_PWM2_ADDR = 0x30670000, | ||
126 | - FSL_IMX7_PWM3_ADDR = 0x30680000, | ||
127 | - FSL_IMX7_PWM4_ADDR = 0x30690000, | ||
128 | - FSL_IMX7_PWMn_SIZE = 0x10000, | ||
129 | + FSL_IMX7_EIM_ADDR = 0x30BC0000, | ||
130 | + FSL_IMX7_EIM_SIZE = (4 * KiB), | ||
131 | |||
132 | - FSL_IMX7_PCIE_PHY_ADDR = 0x306D0000, | ||
133 | - FSL_IMX7_PCIE_PHY_SIZE = 0x10000, | ||
134 | + FSL_IMX7_QSPI_ADDR = 0x30BB0000, | ||
135 | + FSL_IMX7_QSPI_SIZE = 0x8000, | ||
136 | |||
137 | - FSL_IMX7_GPC_ADDR = 0x303A0000, | ||
138 | + FSL_IMX7_SIM2_ADDR = 0x30BA0000, | ||
139 | + FSL_IMX7_SIM1_ADDR = 0x30B90000, | ||
140 | + FSL_IMX7_SIMn_SIZE = (4 * KiB), | ||
141 | + | ||
142 | + FSL_IMX7_USDHC3_ADDR = 0x30B60000, | ||
143 | + FSL_IMX7_USDHC2_ADDR = 0x30B50000, | ||
144 | + FSL_IMX7_USDHC1_ADDR = 0x30B40000, | ||
145 | + | ||
146 | + FSL_IMX7_USB3_ADDR = 0x30B30000, | ||
147 | + FSL_IMX7_USBMISC3_ADDR = 0x30B30200, | ||
148 | + FSL_IMX7_USB2_ADDR = 0x30B20000, | ||
149 | + FSL_IMX7_USBMISC2_ADDR = 0x30B20200, | ||
150 | + FSL_IMX7_USB1_ADDR = 0x30B10000, | ||
151 | + FSL_IMX7_USBMISC1_ADDR = 0x30B10200, | ||
152 | + FSL_IMX7_USBMISCn_SIZE = 0x200, | ||
153 | + | ||
154 | + FSL_IMX7_USB_PL301_ADDR = 0x30AD0000, | ||
155 | + FSL_IMX7_USB_PL301_SIZE = (64 * KiB), | ||
156 | + | ||
157 | + FSL_IMX7_SEMAPHORE_HS_ADDR = 0x30AC0000, | ||
158 | + FSL_IMX7_SEMAPHORE_HS_SIZE = (64 * KiB), | ||
159 | + | ||
160 | + FSL_IMX7_MUB_ADDR = 0x30AB0000, | ||
161 | + FSL_IMX7_MUA_ADDR = 0x30AA0000, | ||
162 | + FSL_IMX7_MUn_SIZE = (KiB), | ||
163 | + | ||
164 | + FSL_IMX7_UART7_ADDR = 0x30A90000, | ||
165 | + FSL_IMX7_UART6_ADDR = 0x30A80000, | ||
166 | + FSL_IMX7_UART5_ADDR = 0x30A70000, | ||
167 | + FSL_IMX7_UART4_ADDR = 0x30A60000, | ||
168 | + | ||
169 | + FSL_IMX7_I2C4_ADDR = 0x30A50000, | ||
170 | + FSL_IMX7_I2C3_ADDR = 0x30A40000, | ||
171 | + FSL_IMX7_I2C2_ADDR = 0x30A30000, | ||
172 | + FSL_IMX7_I2C1_ADDR = 0x30A20000, | ||
173 | + | ||
174 | + FSL_IMX7_CAN2_ADDR = 0x30A10000, | ||
175 | + FSL_IMX7_CAN1_ADDR = 0x30A00000, | ||
176 | + FSL_IMX7_CANn_SIZE = (4 * KiB), | ||
177 | + | ||
178 | + FSL_IMX7_AIPS3_CONF_ADDR = 0x309F0000, | ||
179 | + FSL_IMX7_AIPS3_CONF_SIZE = (64 * KiB), | ||
180 | |||
181 | FSL_IMX7_CAAM_ADDR = 0x30900000, | ||
182 | - FSL_IMX7_CAAM_SIZE = 0x40000, | ||
183 | + FSL_IMX7_CAAM_SIZE = (256 * KiB), | ||
184 | |||
185 | - FSL_IMX7_CAN1_ADDR = 0x30A00000, | ||
186 | - FSL_IMX7_CAN2_ADDR = 0x30A10000, | ||
187 | - FSL_IMX7_CANn_SIZE = 0x10000, | ||
188 | + FSL_IMX7_SPBA_ADDR = 0x308F0000, | ||
189 | + FSL_IMX7_SPBA_SIZE = (4 * KiB), | ||
190 | |||
191 | - FSL_IMX7_I2C1_ADDR = 0x30A20000, | ||
192 | - FSL_IMX7_I2C2_ADDR = 0x30A30000, | ||
193 | - FSL_IMX7_I2C3_ADDR = 0x30A40000, | ||
194 | - FSL_IMX7_I2C4_ADDR = 0x30A50000, | ||
195 | + FSL_IMX7_SAI3_ADDR = 0x308C0000, | ||
196 | + FSL_IMX7_SAI2_ADDR = 0x308B0000, | ||
197 | + FSL_IMX7_SAI1_ADDR = 0x308A0000, | ||
198 | + FSL_IMX7_SAIn_SIZE = (4 * KiB), | ||
199 | |||
200 | - FSL_IMX7_ECSPI1_ADDR = 0x30820000, | ||
201 | - FSL_IMX7_ECSPI2_ADDR = 0x30830000, | ||
202 | - FSL_IMX7_ECSPI3_ADDR = 0x30840000, | ||
203 | - FSL_IMX7_ECSPI4_ADDR = 0x30630000, | ||
204 | - | ||
205 | - FSL_IMX7_LCDIF_ADDR = 0x30730000, | ||
206 | - FSL_IMX7_LCDIF_SIZE = 0x1000, | ||
207 | - | ||
208 | - FSL_IMX7_UART1_ADDR = 0x30860000, | ||
209 | + FSL_IMX7_UART3_ADDR = 0x30880000, | ||
210 | /* | ||
211 | * Some versions of the reference manual claim that UART2 is @ | ||
212 | * 0x30870000, but experiments with HW + DT files in upstream | ||
213 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7MemoryMap { | ||
214 | * actually located @ 0x30890000 | ||
215 | */ | ||
216 | FSL_IMX7_UART2_ADDR = 0x30890000, | ||
217 | - FSL_IMX7_UART3_ADDR = 0x30880000, | ||
218 | - FSL_IMX7_UART4_ADDR = 0x30A60000, | ||
219 | - FSL_IMX7_UART5_ADDR = 0x30A70000, | ||
220 | - FSL_IMX7_UART6_ADDR = 0x30A80000, | ||
221 | - FSL_IMX7_UART7_ADDR = 0x30A90000, | ||
222 | + FSL_IMX7_UART1_ADDR = 0x30860000, | ||
223 | |||
224 | - FSL_IMX7_SAI1_ADDR = 0x308A0000, | ||
225 | - FSL_IMX7_SAI2_ADDR = 0x308B0000, | ||
226 | - FSL_IMX7_SAI3_ADDR = 0x308C0000, | ||
227 | - FSL_IMX7_SAIn_SIZE = 0x10000, | ||
228 | + FSL_IMX7_ECSPI3_ADDR = 0x30840000, | ||
229 | + FSL_IMX7_ECSPI2_ADDR = 0x30830000, | ||
230 | + FSL_IMX7_ECSPI1_ADDR = 0x30820000, | ||
231 | + FSL_IMX7_ECSPIn_SIZE = (4 * KiB), | ||
232 | |||
233 | - FSL_IMX7_ENET1_ADDR = 0x30BE0000, | ||
234 | - FSL_IMX7_ENET2_ADDR = 0x30BF0000, | ||
235 | + /* AIPS-3 End */ | ||
236 | |||
237 | - FSL_IMX7_USB1_ADDR = 0x30B10000, | ||
238 | - FSL_IMX7_USBMISC1_ADDR = 0x30B10200, | ||
239 | - FSL_IMX7_USB2_ADDR = 0x30B20000, | ||
240 | - FSL_IMX7_USBMISC2_ADDR = 0x30B20200, | ||
241 | - FSL_IMX7_USB3_ADDR = 0x30B30000, | ||
242 | - FSL_IMX7_USBMISC3_ADDR = 0x30B30200, | ||
243 | - FSL_IMX7_USBMISCn_SIZE = 0x200, | ||
244 | + /* AIPS-2 Begin */ | ||
245 | |||
246 | - FSL_IMX7_USDHC1_ADDR = 0x30B40000, | ||
247 | - FSL_IMX7_USDHC2_ADDR = 0x30B50000, | ||
248 | - FSL_IMX7_USDHC3_ADDR = 0x30B60000, | ||
249 | + FSL_IMX7_AXI_DEBUG_MON_ADDR = 0x307E0000, | ||
250 | + FSL_IMX7_AXI_DEBUG_MON_SIZE = (64 * KiB), | ||
251 | |||
252 | - FSL_IMX7_SDMA_ADDR = 0x30BD0000, | ||
253 | - FSL_IMX7_SDMA_SIZE = 0x1000, | ||
254 | + FSL_IMX7_PERFMON2_ADDR = 0x307D0000, | ||
255 | + FSL_IMX7_PERFMON1_ADDR = 0x307C0000, | ||
256 | + FSL_IMX7_PERFMONn_SIZE = (64 * KiB), | ||
257 | + | ||
258 | + FSL_IMX7_DDRC_ADDR = 0x307A0000, | ||
259 | + FSL_IMX7_DDRC_SIZE = (4 * KiB), | ||
260 | + | ||
261 | + FSL_IMX7_DDRC_PHY_ADDR = 0x30790000, | ||
262 | + FSL_IMX7_DDRC_PHY_SIZE = (4 * KiB), | ||
263 | + | ||
264 | + FSL_IMX7_TZASC_ADDR = 0x30780000, | ||
265 | + FSL_IMX7_TZASC_SIZE = (64 * KiB), | ||
266 | + | ||
267 | + FSL_IMX7_MIPI_DSI_ADDR = 0x30760000, | ||
268 | + FSL_IMX7_MIPI_DSI_SIZE = (4 * KiB), | ||
269 | + | ||
270 | + FSL_IMX7_MIPI_CSI_ADDR = 0x30750000, | ||
271 | + FSL_IMX7_MIPI_CSI_SIZE = 0x4000, | ||
272 | + | ||
273 | + FSL_IMX7_LCDIF_ADDR = 0x30730000, | ||
274 | + FSL_IMX7_LCDIF_SIZE = 0x8000, | ||
275 | + | ||
276 | + FSL_IMX7_CSI_ADDR = 0x30710000, | ||
277 | + FSL_IMX7_CSI_SIZE = (4 * KiB), | ||
278 | + | ||
279 | + FSL_IMX7_PXP_ADDR = 0x30700000, | ||
280 | + FSL_IMX7_PXP_SIZE = 0x4000, | ||
281 | + | ||
282 | + FSL_IMX7_EPDC_ADDR = 0x306F0000, | ||
283 | + FSL_IMX7_EPDC_SIZE = (4 * KiB), | ||
284 | + | ||
285 | + FSL_IMX7_PCIE_PHY_ADDR = 0x306D0000, | ||
286 | + FSL_IMX7_PCIE_PHY_SIZE = (4 * KiB), | ||
287 | + | ||
288 | + FSL_IMX7_SYSCNT_CTRL_ADDR = 0x306C0000, | ||
289 | + FSL_IMX7_SYSCNT_CMP_ADDR = 0x306B0000, | ||
290 | + FSL_IMX7_SYSCNT_RD_ADDR = 0x306A0000, | ||
291 | + | ||
292 | + FSL_IMX7_PWM4_ADDR = 0x30690000, | ||
293 | + FSL_IMX7_PWM3_ADDR = 0x30680000, | ||
294 | + FSL_IMX7_PWM2_ADDR = 0x30670000, | ||
295 | + FSL_IMX7_PWM1_ADDR = 0x30660000, | ||
296 | + FSL_IMX7_PWMn_SIZE = (4 * KiB), | ||
297 | + | ||
298 | + FSL_IMX7_FlEXTIMER2_ADDR = 0x30650000, | ||
299 | + FSL_IMX7_FlEXTIMER1_ADDR = 0x30640000, | ||
300 | + FSL_IMX7_FLEXTIMERn_SIZE = (4 * KiB), | ||
301 | + | ||
302 | + FSL_IMX7_ECSPI4_ADDR = 0x30630000, | ||
303 | + | ||
304 | + FSL_IMX7_ADC2_ADDR = 0x30620000, | ||
305 | + FSL_IMX7_ADC1_ADDR = 0x30610000, | ||
306 | + FSL_IMX7_ADCn_SIZE = (4 * KiB), | ||
307 | + | ||
308 | + FSL_IMX7_AIPS2_CONF_ADDR = 0x305F0000, | ||
309 | + FSL_IMX7_AIPS2_CONF_SIZE = (64 * KiB), | ||
310 | + | ||
311 | + /* AIPS-2 End */ | ||
312 | + | ||
313 | + /* AIPS-1 Begin */ | ||
314 | + | ||
315 | + FSL_IMX7_CSU_ADDR = 0x303E0000, | ||
316 | + FSL_IMX7_CSU_SIZE = (64 * KiB), | ||
317 | + | ||
318 | + FSL_IMX7_RDC_ADDR = 0x303D0000, | ||
319 | + FSL_IMX7_RDC_SIZE = (4 * KiB), | ||
320 | + | ||
321 | + FSL_IMX7_SEMAPHORE2_ADDR = 0x303C0000, | ||
322 | + FSL_IMX7_SEMAPHORE1_ADDR = 0x303B0000, | ||
323 | + FSL_IMX7_SEMAPHOREn_SIZE = (4 * KiB), | ||
324 | + | ||
325 | + FSL_IMX7_GPC_ADDR = 0x303A0000, | ||
326 | + | ||
327 | + FSL_IMX7_SRC_ADDR = 0x30390000, | ||
328 | + FSL_IMX7_SRC_SIZE = (4 * KiB), | ||
329 | + | ||
330 | + FSL_IMX7_CCM_ADDR = 0x30380000, | ||
331 | + | ||
332 | + FSL_IMX7_SNVS_HP_ADDR = 0x30370000, | ||
333 | + | ||
334 | + FSL_IMX7_ANALOG_ADDR = 0x30360000, | ||
335 | + | ||
336 | + FSL_IMX7_OCOTP_ADDR = 0x30350000, | ||
337 | + FSL_IMX7_OCOTP_SIZE = 0x10000, | ||
338 | + | ||
339 | + FSL_IMX7_IOMUXC_GPR_ADDR = 0x30340000, | ||
340 | + FSL_IMX7_IOMUXC_GPR_SIZE = (4 * KiB), | ||
341 | + | ||
342 | + FSL_IMX7_IOMUXC_ADDR = 0x30330000, | ||
343 | + FSL_IMX7_IOMUXC_SIZE = (4 * KiB), | ||
344 | + | ||
345 | + FSL_IMX7_KPP_ADDR = 0x30320000, | ||
346 | + FSL_IMX7_KPP_SIZE = (4 * KiB), | ||
347 | + | ||
348 | + FSL_IMX7_ROMCP_ADDR = 0x30310000, | ||
349 | + FSL_IMX7_ROMCP_SIZE = (4 * KiB), | ||
350 | + | ||
351 | + FSL_IMX7_GPT4_ADDR = 0x30300000, | ||
352 | + FSL_IMX7_GPT3_ADDR = 0x302F0000, | ||
353 | + FSL_IMX7_GPT2_ADDR = 0x302E0000, | ||
354 | + FSL_IMX7_GPT1_ADDR = 0x302D0000, | ||
355 | + | ||
356 | + FSL_IMX7_IOMUXC_LPSR_ADDR = 0x302C0000, | ||
357 | + FSL_IMX7_IOMUXC_LPSR_SIZE = (4 * KiB), | ||
358 | + | ||
359 | + FSL_IMX7_WDOG4_ADDR = 0x302B0000, | ||
360 | + FSL_IMX7_WDOG3_ADDR = 0x302A0000, | ||
361 | + FSL_IMX7_WDOG2_ADDR = 0x30290000, | ||
362 | + FSL_IMX7_WDOG1_ADDR = 0x30280000, | ||
363 | + | ||
364 | + FSL_IMX7_IOMUXC_LPSR_GPR_ADDR = 0x30270000, | ||
365 | + | ||
366 | + FSL_IMX7_GPIO7_ADDR = 0x30260000, | ||
367 | + FSL_IMX7_GPIO6_ADDR = 0x30250000, | ||
368 | + FSL_IMX7_GPIO5_ADDR = 0x30240000, | ||
369 | + FSL_IMX7_GPIO4_ADDR = 0x30230000, | ||
370 | + FSL_IMX7_GPIO3_ADDR = 0x30220000, | ||
371 | + FSL_IMX7_GPIO2_ADDR = 0x30210000, | ||
372 | + FSL_IMX7_GPIO1_ADDR = 0x30200000, | ||
373 | + | ||
374 | + FSL_IMX7_AIPS1_CONF_ADDR = 0x301F0000, | ||
375 | + FSL_IMX7_AIPS1_CONF_SIZE = (64 * KiB), | ||
376 | |||
377 | - FSL_IMX7_A7MPCORE_ADDR = 0x31000000, | ||
378 | FSL_IMX7_A7MPCORE_DAP_ADDR = 0x30000000, | ||
379 | + FSL_IMX7_A7MPCORE_DAP_SIZE = (1 * MiB), | ||
380 | |||
381 | - FSL_IMX7_PCIE_REG_ADDR = 0x33800000, | ||
382 | - FSL_IMX7_PCIE_REG_SIZE = 16 * 1024, | ||
383 | + /* AIPS-1 End */ | ||
384 | |||
385 | - FSL_IMX7_GPR_ADDR = 0x30340000, | ||
386 | + FSL_IMX7_EIM_CS0_ADDR = 0x28000000, | ||
387 | + FSL_IMX7_EIM_CS0_SIZE = (128 * MiB), | ||
388 | |||
389 | - FSL_IMX7_DMA_APBH_ADDR = 0x33000000, | ||
390 | - FSL_IMX7_DMA_APBH_SIZE = 0x2000, | ||
391 | + FSL_IMX7_OCRAM_PXP_ADDR = 0x00940000, | ||
392 | + FSL_IMX7_OCRAM_PXP_SIZE = (32 * KiB), | ||
393 | + | ||
394 | + FSL_IMX7_OCRAM_EPDC_ADDR = 0x00920000, | ||
395 | + FSL_IMX7_OCRAM_EPDC_SIZE = (128 * KiB), | ||
396 | + | ||
397 | + FSL_IMX7_OCRAM_MEM_ADDR = 0x00900000, | ||
398 | + FSL_IMX7_OCRAM_MEM_SIZE = (128 * KiB), | ||
399 | + | ||
400 | + FSL_IMX7_TCMU_ADDR = 0x00800000, | ||
401 | + FSL_IMX7_TCMU_SIZE = (32 * KiB), | ||
402 | + | ||
403 | + FSL_IMX7_TCML_ADDR = 0x007F8000, | ||
404 | + FSL_IMX7_TCML_SIZE = (32 * KiB), | ||
405 | + | ||
406 | + FSL_IMX7_OCRAM_S_ADDR = 0x00180000, | ||
407 | + FSL_IMX7_OCRAM_S_SIZE = (32 * KiB), | ||
408 | + | ||
409 | + FSL_IMX7_CAAM_MEM_ADDR = 0x00100000, | ||
410 | + FSL_IMX7_CAAM_MEM_SIZE = (32 * KiB), | ||
411 | + | ||
412 | + FSL_IMX7_ROM_ADDR = 0x00000000, | ||
413 | + FSL_IMX7_ROM_SIZE = (96 * KiB), | ||
414 | }; | ||
415 | |||
416 | enum FslIMX7IRQs { | ||
417 | diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c | ||
418 | index XXXXXXX..XXXXXXX 100644 | ||
419 | --- a/hw/arm/fsl-imx7.c | ||
420 | +++ b/hw/arm/fsl-imx7.c | ||
421 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
422 | char name[NAME_SIZE]; | ||
423 | int i; | ||
424 | |||
425 | + /* | ||
426 | + * CPUs | ||
427 | + */ | ||
428 | for (i = 0; i < MIN(ms->smp.cpus, FSL_IMX7_NUM_CPUS); i++) { | ||
429 | snprintf(name, NAME_SIZE, "cpu%d", i); | ||
430 | object_initialize_child(obj, name, &s->cpu[i], | ||
431 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
432 | TYPE_A15MPCORE_PRIV); | ||
433 | |||
434 | /* | ||
435 | - * GPIOs 1 to 7 | ||
436 | + * GPIOs | ||
437 | */ | ||
438 | for (i = 0; i < FSL_IMX7_NUM_GPIOS; i++) { | ||
439 | snprintf(name, NAME_SIZE, "gpio%d", i); | ||
440 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
441 | } | ||
442 | |||
443 | /* | ||
444 | - * GPT1, 2, 3, 4 | ||
445 | + * GPTs | ||
446 | */ | ||
447 | for (i = 0; i < FSL_IMX7_NUM_GPTS; i++) { | ||
448 | snprintf(name, NAME_SIZE, "gpt%d", i); | ||
449 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
450 | */ | ||
451 | object_initialize_child(obj, "gpcv2", &s->gpcv2, TYPE_IMX_GPCV2); | ||
452 | |||
453 | + /* | ||
454 | + * ECSPIs | ||
455 | + */ | ||
456 | for (i = 0; i < FSL_IMX7_NUM_ECSPIS; i++) { | ||
457 | snprintf(name, NAME_SIZE, "spi%d", i + 1); | ||
458 | object_initialize_child(obj, name, &s->spi[i], TYPE_IMX_SPI); | ||
459 | } | ||
460 | |||
461 | - | ||
462 | + /* | ||
463 | + * I2Cs | ||
464 | + */ | ||
465 | for (i = 0; i < FSL_IMX7_NUM_I2CS; i++) { | ||
466 | snprintf(name, NAME_SIZE, "i2c%d", i + 1); | ||
467 | object_initialize_child(obj, name, &s->i2c[i], TYPE_IMX_I2C); | ||
468 | } | ||
469 | |||
470 | /* | ||
471 | - * UART | ||
472 | + * UARTs | ||
473 | */ | ||
474 | for (i = 0; i < FSL_IMX7_NUM_UARTS; i++) { | ||
475 | snprintf(name, NAME_SIZE, "uart%d", i); | ||
476 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
477 | } | ||
478 | |||
479 | /* | ||
480 | - * Ethernet | ||
481 | + * Ethernets | ||
482 | */ | ||
483 | for (i = 0; i < FSL_IMX7_NUM_ETHS; i++) { | ||
484 | snprintf(name, NAME_SIZE, "eth%d", i); | ||
485 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
486 | } | ||
487 | |||
488 | /* | ||
489 | - * SDHCI | ||
490 | + * SDHCIs | ||
491 | */ | ||
492 | for (i = 0; i < FSL_IMX7_NUM_USDHCS; i++) { | ||
493 | snprintf(name, NAME_SIZE, "usdhc%d", i); | ||
494 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
495 | object_initialize_child(obj, "snvs", &s->snvs, TYPE_IMX7_SNVS); | ||
496 | |||
497 | /* | ||
498 | - * Watchdog | ||
499 | + * Watchdogs | ||
500 | */ | ||
501 | for (i = 0; i < FSL_IMX7_NUM_WDTS; i++) { | ||
502 | snprintf(name, NAME_SIZE, "wdt%d", i); | ||
503 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | ||
504 | */ | ||
505 | object_initialize_child(obj, "gpr", &s->gpr, TYPE_IMX7_GPR); | ||
506 | |||
507 | + /* | ||
508 | + * PCIE | ||
509 | + */ | ||
510 | object_initialize_child(obj, "pcie", &s->pcie, TYPE_DESIGNWARE_PCIE_HOST); | ||
511 | |||
512 | + /* | ||
513 | + * USBs | ||
514 | + */ | ||
515 | for (i = 0; i < FSL_IMX7_NUM_USBS; i++) { | ||
516 | snprintf(name, NAME_SIZE, "usb%d", i); | ||
517 | object_initialize_child(obj, name, &s->usb[i], TYPE_CHIPIDEA); | ||
518 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
519 | return; | 19 | return; |
520 | } | 20 | } |
521 | 21 | ||
522 | + /* | 22 | + if (s->nmi_support) { |
523 | + * CPUs | 23 | + error_setg(errp, "NMI is not supported with the in-kernel GIC"); |
524 | + */ | 24 | + return; |
525 | for (i = 0; i < smp_cpus; i++) { | 25 | + } |
526 | o = OBJECT(&s->cpu[i]); | ||
527 | |||
528 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
529 | * A7MPCORE DAP | ||
530 | */ | ||
531 | create_unimplemented_device("a7mpcore-dap", FSL_IMX7_A7MPCORE_DAP_ADDR, | ||
532 | - 0x100000); | ||
533 | + FSL_IMX7_A7MPCORE_DAP_SIZE); | ||
534 | |||
535 | /* | ||
536 | - * GPT1, 2, 3, 4 | ||
537 | + * GPTs | ||
538 | */ | ||
539 | for (i = 0; i < FSL_IMX7_NUM_GPTS; i++) { | ||
540 | static const hwaddr FSL_IMX7_GPTn_ADDR[FSL_IMX7_NUM_GPTS] = { | ||
541 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
542 | FSL_IMX7_GPTn_IRQ[i])); | ||
543 | } | ||
544 | |||
545 | + /* | ||
546 | + * GPIOs | ||
547 | + */ | ||
548 | for (i = 0; i < FSL_IMX7_NUM_GPIOS; i++) { | ||
549 | static const hwaddr FSL_IMX7_GPIOn_ADDR[FSL_IMX7_NUM_GPIOS] = { | ||
550 | FSL_IMX7_GPIO1_ADDR, | ||
551 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
552 | /* | ||
553 | * IOMUXC and IOMUXC_LPSR | ||
554 | */ | ||
555 | - for (i = 0; i < FSL_IMX7_NUM_IOMUXCS; i++) { | ||
556 | - static const hwaddr FSL_IMX7_IOMUXCn_ADDR[FSL_IMX7_NUM_IOMUXCS] = { | ||
557 | - FSL_IMX7_IOMUXC_ADDR, | ||
558 | - FSL_IMX7_IOMUXC_LPSR_ADDR, | ||
559 | - }; | ||
560 | - | ||
561 | - snprintf(name, NAME_SIZE, "iomuxc%d", i); | ||
562 | - create_unimplemented_device(name, FSL_IMX7_IOMUXCn_ADDR[i], | ||
563 | - FSL_IMX7_IOMUXCn_SIZE); | ||
564 | - } | ||
565 | + create_unimplemented_device("iomuxc", FSL_IMX7_IOMUXC_ADDR, | ||
566 | + FSL_IMX7_IOMUXC_SIZE); | ||
567 | + create_unimplemented_device("iomuxc_lspr", FSL_IMX7_IOMUXC_LPSR_ADDR, | ||
568 | + FSL_IMX7_IOMUXC_LPSR_SIZE); | ||
569 | |||
570 | /* | ||
571 | * CCM | ||
572 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
573 | sysbus_realize(SYS_BUS_DEVICE(&s->gpcv2), &error_abort); | ||
574 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpcv2), 0, FSL_IMX7_GPC_ADDR); | ||
575 | |||
576 | - /* Initialize all ECSPI */ | ||
577 | + /* | ||
578 | + * ECSPIs | ||
579 | + */ | ||
580 | for (i = 0; i < FSL_IMX7_NUM_ECSPIS; i++) { | ||
581 | static const hwaddr FSL_IMX7_SPIn_ADDR[FSL_IMX7_NUM_ECSPIS] = { | ||
582 | FSL_IMX7_ECSPI1_ADDR, | ||
583 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
584 | FSL_IMX7_SPIn_IRQ[i])); | ||
585 | } | ||
586 | |||
587 | + /* | ||
588 | + * I2Cs | ||
589 | + */ | ||
590 | for (i = 0; i < FSL_IMX7_NUM_I2CS; i++) { | ||
591 | static const hwaddr FSL_IMX7_I2Cn_ADDR[FSL_IMX7_NUM_I2CS] = { | ||
592 | FSL_IMX7_I2C1_ADDR, | ||
593 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
594 | } | ||
595 | |||
596 | /* | ||
597 | - * UART | ||
598 | + * UARTs | ||
599 | */ | ||
600 | for (i = 0; i < FSL_IMX7_NUM_UARTS; i++) { | ||
601 | static const hwaddr FSL_IMX7_UARTn_ADDR[FSL_IMX7_NUM_UARTS] = { | ||
602 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
603 | } | ||
604 | |||
605 | /* | ||
606 | - * Ethernet | ||
607 | + * Ethernets | ||
608 | * | ||
609 | * We must use two loops since phy_connected affects the other interface | ||
610 | * and we have to set all properties before calling sysbus_realize(). | ||
611 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
612 | } | ||
613 | |||
614 | /* | ||
615 | - * USDHC | ||
616 | + * USDHCs | ||
617 | */ | ||
618 | for (i = 0; i < FSL_IMX7_NUM_USDHCS; i++) { | ||
619 | static const hwaddr FSL_IMX7_USDHCn_ADDR[FSL_IMX7_NUM_USDHCS] = { | ||
620 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
621 | * SNVS | ||
622 | */ | ||
623 | sysbus_realize(SYS_BUS_DEVICE(&s->snvs), &error_abort); | ||
624 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->snvs), 0, FSL_IMX7_SNVS_ADDR); | ||
625 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->snvs), 0, FSL_IMX7_SNVS_HP_ADDR); | ||
626 | |||
627 | /* | ||
628 | * SRC | ||
629 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
630 | create_unimplemented_device("src", FSL_IMX7_SRC_ADDR, FSL_IMX7_SRC_SIZE); | ||
631 | |||
632 | /* | ||
633 | - * Watchdog | ||
634 | + * Watchdogs | ||
635 | */ | ||
636 | for (i = 0; i < FSL_IMX7_NUM_WDTS; i++) { | ||
637 | static const hwaddr FSL_IMX7_WDOGn_ADDR[FSL_IMX7_NUM_WDTS] = { | ||
638 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
639 | create_unimplemented_device("caam", FSL_IMX7_CAAM_ADDR, FSL_IMX7_CAAM_SIZE); | ||
640 | |||
641 | /* | ||
642 | - * PWM | ||
643 | + * PWMs | ||
644 | */ | ||
645 | - create_unimplemented_device("pwm1", FSL_IMX7_PWM1_ADDR, FSL_IMX7_PWMn_SIZE); | ||
646 | - create_unimplemented_device("pwm2", FSL_IMX7_PWM2_ADDR, FSL_IMX7_PWMn_SIZE); | ||
647 | - create_unimplemented_device("pwm3", FSL_IMX7_PWM3_ADDR, FSL_IMX7_PWMn_SIZE); | ||
648 | - create_unimplemented_device("pwm4", FSL_IMX7_PWM4_ADDR, FSL_IMX7_PWMn_SIZE); | ||
649 | + for (i = 0; i < FSL_IMX7_NUM_PWMS; i++) { | ||
650 | + static const hwaddr FSL_IMX7_PWMn_ADDR[FSL_IMX7_NUM_PWMS] = { | ||
651 | + FSL_IMX7_PWM1_ADDR, | ||
652 | + FSL_IMX7_PWM2_ADDR, | ||
653 | + FSL_IMX7_PWM3_ADDR, | ||
654 | + FSL_IMX7_PWM4_ADDR, | ||
655 | + }; | ||
656 | + | 26 | + |
657 | + snprintf(name, NAME_SIZE, "pwm%d", i); | 27 | gicv3_init_irqs_and_mmio(s, kvm_arm_gicv3_set_irq, NULL); |
658 | + create_unimplemented_device(name, FSL_IMX7_PWMn_ADDR[i], | 28 | |
659 | + FSL_IMX7_PWMn_SIZE); | 29 | for (i = 0; i < s->num_cpu; i++) { |
660 | + } | ||
661 | |||
662 | /* | ||
663 | - * CAN | ||
664 | + * CANs | ||
665 | */ | ||
666 | - create_unimplemented_device("can1", FSL_IMX7_CAN1_ADDR, FSL_IMX7_CANn_SIZE); | ||
667 | - create_unimplemented_device("can2", FSL_IMX7_CAN2_ADDR, FSL_IMX7_CANn_SIZE); | ||
668 | + for (i = 0; i < FSL_IMX7_NUM_CANS; i++) { | ||
669 | + static const hwaddr FSL_IMX7_CANn_ADDR[FSL_IMX7_NUM_CANS] = { | ||
670 | + FSL_IMX7_CAN1_ADDR, | ||
671 | + FSL_IMX7_CAN2_ADDR, | ||
672 | + }; | ||
673 | + | ||
674 | + snprintf(name, NAME_SIZE, "can%d", i); | ||
675 | + create_unimplemented_device(name, FSL_IMX7_CANn_ADDR[i], | ||
676 | + FSL_IMX7_CANn_SIZE); | ||
677 | + } | ||
678 | |||
679 | /* | ||
680 | - * SAI (Audio SSI (Synchronous Serial Interface)) | ||
681 | + * SAIs (Audio SSI (Synchronous Serial Interface)) | ||
682 | */ | ||
683 | - create_unimplemented_device("sai1", FSL_IMX7_SAI1_ADDR, FSL_IMX7_SAIn_SIZE); | ||
684 | - create_unimplemented_device("sai2", FSL_IMX7_SAI2_ADDR, FSL_IMX7_SAIn_SIZE); | ||
685 | - create_unimplemented_device("sai2", FSL_IMX7_SAI3_ADDR, FSL_IMX7_SAIn_SIZE); | ||
686 | + for (i = 0; i < FSL_IMX7_NUM_SAIS; i++) { | ||
687 | + static const hwaddr FSL_IMX7_SAIn_ADDR[FSL_IMX7_NUM_SAIS] = { | ||
688 | + FSL_IMX7_SAI1_ADDR, | ||
689 | + FSL_IMX7_SAI2_ADDR, | ||
690 | + FSL_IMX7_SAI3_ADDR, | ||
691 | + }; | ||
692 | + | ||
693 | + snprintf(name, NAME_SIZE, "sai%d", i); | ||
694 | + create_unimplemented_device(name, FSL_IMX7_SAIn_ADDR[i], | ||
695 | + FSL_IMX7_SAIn_SIZE); | ||
696 | + } | ||
697 | |||
698 | /* | ||
699 | * OCOTP | ||
700 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
701 | create_unimplemented_device("ocotp", FSL_IMX7_OCOTP_ADDR, | ||
702 | FSL_IMX7_OCOTP_SIZE); | ||
703 | |||
704 | + /* | ||
705 | + * GPR | ||
706 | + */ | ||
707 | sysbus_realize(SYS_BUS_DEVICE(&s->gpr), &error_abort); | ||
708 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpr), 0, FSL_IMX7_GPR_ADDR); | ||
709 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpr), 0, FSL_IMX7_IOMUXC_GPR_ADDR); | ||
710 | |||
711 | + /* | ||
712 | + * PCIE | ||
713 | + */ | ||
714 | sysbus_realize(SYS_BUS_DEVICE(&s->pcie), &error_abort); | ||
715 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->pcie), 0, FSL_IMX7_PCIE_REG_ADDR); | ||
716 | |||
717 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
718 | irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_PCI_INTD_IRQ); | ||
719 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 3, irq); | ||
720 | |||
721 | - | ||
722 | + /* | ||
723 | + * USBs | ||
724 | + */ | ||
725 | for (i = 0; i < FSL_IMX7_NUM_USBS; i++) { | ||
726 | static const hwaddr FSL_IMX7_USBMISCn_ADDR[FSL_IMX7_NUM_USBS] = { | ||
727 | FSL_IMX7_USBMISC1_ADDR, | ||
728 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
729 | */ | ||
730 | create_unimplemented_device("pcie-phy", FSL_IMX7_PCIE_PHY_ADDR, | ||
731 | FSL_IMX7_PCIE_PHY_SIZE); | ||
732 | + | ||
733 | } | ||
734 | |||
735 | static Property fsl_imx7_properties[] = { | ||
736 | -- | 30 | -- |
737 | 2.34.1 | 31 | 2.34.1 | diff view generated by jsdifflib |
1 | In the aspeed_rtc device we store a difference between two time_t | 1 | From: Jinjie Ruan <ruanjinjie@huawei.com> |
---|---|---|---|
2 | values in an 'int'. This is not really correct when time_t could | ||
3 | be 64 bits. Enlarge the field to 'int64_t'. | ||
4 | 2 | ||
5 | This is a migration compatibility break for the aspeed boards. | 3 | A SPI, PPI or SGI interrupt can have non-maskable property. So maintain |
6 | While we are changing the vmstate, remove the accidental | 4 | non-maskable property in PendingIrq and GICR/GICD. Since add new device |
7 | duplicate of the offset field. | 5 | state, it also needs to be migrated, so also save NMI info in |
6 | vmstate_gicv3_cpu and vmstate_gicv3. | ||
8 | 7 | ||
8 | Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> | ||
9 | Acked-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Message-id: 20240407081733.3231820-16-ruanjinjie@huawei.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
11 | --- | 13 | --- |
12 | include/hw/rtc/aspeed_rtc.h | 2 +- | 14 | include/hw/intc/arm_gicv3_common.h | 4 ++++ |
13 | hw/rtc/aspeed_rtc.c | 5 ++--- | 15 | hw/intc/arm_gicv3_common.c | 38 ++++++++++++++++++++++++++++++ |
14 | 2 files changed, 3 insertions(+), 4 deletions(-) | 16 | 2 files changed, 42 insertions(+) |
15 | 17 | ||
16 | diff --git a/include/hw/rtc/aspeed_rtc.h b/include/hw/rtc/aspeed_rtc.h | 18 | diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h |
17 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/include/hw/rtc/aspeed_rtc.h | 20 | --- a/include/hw/intc/arm_gicv3_common.h |
19 | +++ b/include/hw/rtc/aspeed_rtc.h | 21 | +++ b/include/hw/intc/arm_gicv3_common.h |
20 | @@ -XXX,XX +XXX,XX @@ struct AspeedRtcState { | 22 | @@ -XXX,XX +XXX,XX @@ typedef struct { |
21 | qemu_irq irq; | 23 | int irq; |
22 | 24 | uint8_t prio; | |
23 | uint32_t reg[0x18]; | 25 | int grp; |
24 | - int offset; | 26 | + bool nmi; |
25 | + int64_t offset; | 27 | } PendingIrq; |
26 | 28 | ||
29 | struct GICv3CPUState { | ||
30 | @@ -XXX,XX +XXX,XX @@ struct GICv3CPUState { | ||
31 | uint32_t gicr_ienabler0; | ||
32 | uint32_t gicr_ipendr0; | ||
33 | uint32_t gicr_iactiver0; | ||
34 | + uint32_t gicr_inmir0; | ||
35 | uint32_t edge_trigger; /* ICFGR0 and ICFGR1 even bits */ | ||
36 | uint32_t gicr_igrpmodr0; | ||
37 | uint32_t gicr_nsacr; | ||
38 | @@ -XXX,XX +XXX,XX @@ struct GICv3State { | ||
39 | GIC_DECLARE_BITMAP(active); /* GICD_ISACTIVER */ | ||
40 | GIC_DECLARE_BITMAP(level); /* Current level */ | ||
41 | GIC_DECLARE_BITMAP(edge_trigger); /* GICD_ICFGR even bits */ | ||
42 | + GIC_DECLARE_BITMAP(nmi); /* GICD_INMIR */ | ||
43 | uint8_t gicd_ipriority[GICV3_MAXIRQ]; | ||
44 | uint64_t gicd_irouter[GICV3_MAXIRQ]; | ||
45 | /* Cached information: pointer to the cpu i/f for the CPUs specified | ||
46 | @@ -XXX,XX +XXX,XX @@ GICV3_BITMAP_ACCESSORS(pending) | ||
47 | GICV3_BITMAP_ACCESSORS(active) | ||
48 | GICV3_BITMAP_ACCESSORS(level) | ||
49 | GICV3_BITMAP_ACCESSORS(edge_trigger) | ||
50 | +GICV3_BITMAP_ACCESSORS(nmi) | ||
51 | |||
52 | #define TYPE_ARM_GICV3_COMMON "arm-gicv3-common" | ||
53 | typedef struct ARMGICv3CommonClass ARMGICv3CommonClass; | ||
54 | diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/hw/intc/arm_gicv3_common.c | ||
57 | +++ b/hw/intc/arm_gicv3_common.c | ||
58 | @@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_gicv3_gicv4 = { | ||
59 | } | ||
27 | }; | 60 | }; |
28 | 61 | ||
29 | diff --git a/hw/rtc/aspeed_rtc.c b/hw/rtc/aspeed_rtc.c | 62 | +static bool gicv3_cpu_nmi_needed(void *opaque) |
30 | index XXXXXXX..XXXXXXX 100644 | 63 | +{ |
31 | --- a/hw/rtc/aspeed_rtc.c | 64 | + GICv3CPUState *cs = opaque; |
32 | +++ b/hw/rtc/aspeed_rtc.c | 65 | + |
33 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps aspeed_rtc_ops = { | 66 | + return cs->gic->nmi_support; |
34 | 67 | +} | |
35 | static const VMStateDescription vmstate_aspeed_rtc = { | 68 | + |
36 | .name = TYPE_ASPEED_RTC, | 69 | +static const VMStateDescription vmstate_gicv3_cpu_nmi = { |
37 | - .version_id = 1, | 70 | + .name = "arm_gicv3_cpu/nmi", |
38 | + .version_id = 2, | 71 | + .version_id = 1, |
39 | .fields = (VMStateField[]) { | 72 | + .minimum_version_id = 1, |
40 | VMSTATE_UINT32_ARRAY(reg, AspeedRtcState, 0x18), | 73 | + .needed = gicv3_cpu_nmi_needed, |
41 | - VMSTATE_INT32(offset, AspeedRtcState), | 74 | + .fields = (const VMStateField[]) { |
42 | - VMSTATE_INT32(offset, AspeedRtcState), | 75 | + VMSTATE_UINT32(gicr_inmir0, GICv3CPUState), |
43 | + VMSTATE_INT64(offset, AspeedRtcState), | 76 | + VMSTATE_END_OF_LIST() |
44 | VMSTATE_END_OF_LIST() | 77 | + } |
78 | +}; | ||
79 | + | ||
80 | static const VMStateDescription vmstate_gicv3_cpu = { | ||
81 | .name = "arm_gicv3_cpu", | ||
82 | .version_id = 1, | ||
83 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_gicv3_cpu = { | ||
84 | &vmstate_gicv3_cpu_virt, | ||
85 | &vmstate_gicv3_cpu_sre_el1, | ||
86 | &vmstate_gicv3_gicv4, | ||
87 | + &vmstate_gicv3_cpu_nmi, | ||
88 | NULL | ||
89 | } | ||
90 | }; | ||
91 | @@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_gicv3_gicd_no_migration_shift_bug = { | ||
92 | } | ||
93 | }; | ||
94 | |||
95 | +static bool gicv3_nmi_needed(void *opaque) | ||
96 | +{ | ||
97 | + GICv3State *cs = opaque; | ||
98 | + | ||
99 | + return cs->nmi_support; | ||
100 | +} | ||
101 | + | ||
102 | +const VMStateDescription vmstate_gicv3_gicd_nmi = { | ||
103 | + .name = "arm_gicv3/gicd_nmi", | ||
104 | + .version_id = 1, | ||
105 | + .minimum_version_id = 1, | ||
106 | + .needed = gicv3_nmi_needed, | ||
107 | + .fields = (const VMStateField[]) { | ||
108 | + VMSTATE_UINT32_ARRAY(nmi, GICv3State, GICV3_BMP_SIZE), | ||
109 | + VMSTATE_END_OF_LIST() | ||
110 | + } | ||
111 | +}; | ||
112 | + | ||
113 | static const VMStateDescription vmstate_gicv3 = { | ||
114 | .name = "arm_gicv3", | ||
115 | .version_id = 1, | ||
116 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_gicv3 = { | ||
117 | }, | ||
118 | .subsections = (const VMStateDescription * const []) { | ||
119 | &vmstate_gicv3_gicd_no_migration_shift_bug, | ||
120 | + &vmstate_gicv3_gicd_nmi, | ||
121 | NULL | ||
45 | } | 122 | } |
46 | }; | 123 | }; |
47 | -- | 124 | -- |
48 | 2.34.1 | 125 | 2.34.1 |
49 | |||
50 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Jinjie Ruan <ruanjinjie@huawei.com> | ||
1 | 2 | ||
3 | Add GICR_INMIR0 register and support access GICR_INMIR0. | ||
4 | |||
5 | Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Message-id: 20240407081733.3231820-17-ruanjinjie@huawei.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/intc/gicv3_internal.h | 1 + | ||
12 | hw/intc/arm_gicv3_redist.c | 19 +++++++++++++++++++ | ||
13 | 2 files changed, 20 insertions(+) | ||
14 | |||
15 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/intc/gicv3_internal.h | ||
18 | +++ b/hw/intc/gicv3_internal.h | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | #define GICR_ICFGR1 (GICR_SGI_OFFSET + 0x0C04) | ||
21 | #define GICR_IGRPMODR0 (GICR_SGI_OFFSET + 0x0D00) | ||
22 | #define GICR_NSACR (GICR_SGI_OFFSET + 0x0E00) | ||
23 | +#define GICR_INMIR0 (GICR_SGI_OFFSET + 0x0F80) | ||
24 | |||
25 | /* VLPI redistributor registers, offsets from VLPI_base */ | ||
26 | #define GICR_VPROPBASER (GICR_VLPI_OFFSET + 0x70) | ||
27 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/hw/intc/arm_gicv3_redist.c | ||
30 | +++ b/hw/intc/arm_gicv3_redist.c | ||
31 | @@ -XXX,XX +XXX,XX @@ static int gicr_ns_access(GICv3CPUState *cs, int irq) | ||
32 | return extract32(cs->gicr_nsacr, irq * 2, 2); | ||
33 | } | ||
34 | |||
35 | +static void gicr_write_bitmap_reg(GICv3CPUState *cs, MemTxAttrs attrs, | ||
36 | + uint32_t *reg, uint32_t val) | ||
37 | +{ | ||
38 | + /* Helper routine to implement writing to a "set" register */ | ||
39 | + val &= mask_group(cs, attrs); | ||
40 | + *reg = val; | ||
41 | + gicv3_redist_update(cs); | ||
42 | +} | ||
43 | + | ||
44 | static void gicr_write_set_bitmap_reg(GICv3CPUState *cs, MemTxAttrs attrs, | ||
45 | uint32_t *reg, uint32_t val) | ||
46 | { | ||
47 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicr_readl(GICv3CPUState *cs, hwaddr offset, | ||
48 | *data = value; | ||
49 | return MEMTX_OK; | ||
50 | } | ||
51 | + case GICR_INMIR0: | ||
52 | + *data = cs->gic->nmi_support ? | ||
53 | + gicr_read_bitmap_reg(cs, attrs, cs->gicr_inmir0) : 0; | ||
54 | + return MEMTX_OK; | ||
55 | case GICR_ICFGR0: | ||
56 | case GICR_ICFGR1: | ||
57 | { | ||
58 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicr_writel(GICv3CPUState *cs, hwaddr offset, | ||
59 | gicv3_redist_update(cs); | ||
60 | return MEMTX_OK; | ||
61 | } | ||
62 | + case GICR_INMIR0: | ||
63 | + if (cs->gic->nmi_support) { | ||
64 | + gicr_write_bitmap_reg(cs, attrs, &cs->gicr_inmir0, value); | ||
65 | + } | ||
66 | + return MEMTX_OK; | ||
67 | + | ||
68 | case GICR_ICFGR0: | ||
69 | /* Register is all RAZ/WI or RAO/WI bits */ | ||
70 | return MEMTX_OK; | ||
71 | -- | ||
72 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Jinjie Ruan <ruanjinjie@huawei.com> | ||
1 | 2 | ||
3 | Add GICD_INMIR, GICD_INMIRnE register and support access GICD_INMIR0. | ||
4 | |||
5 | Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Message-id: 20240407081733.3231820-18-ruanjinjie@huawei.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/intc/gicv3_internal.h | 2 ++ | ||
12 | hw/intc/arm_gicv3_dist.c | 34 ++++++++++++++++++++++++++++++++++ | ||
13 | 2 files changed, 36 insertions(+) | ||
14 | |||
15 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/intc/gicv3_internal.h | ||
18 | +++ b/hw/intc/gicv3_internal.h | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | #define GICD_SGIR 0x0F00 | ||
21 | #define GICD_CPENDSGIR 0x0F10 | ||
22 | #define GICD_SPENDSGIR 0x0F20 | ||
23 | +#define GICD_INMIR 0x0F80 | ||
24 | +#define GICD_INMIRnE 0x3B00 | ||
25 | #define GICD_IROUTER 0x6000 | ||
26 | #define GICD_IDREGS 0xFFD0 | ||
27 | |||
28 | diff --git a/hw/intc/arm_gicv3_dist.c b/hw/intc/arm_gicv3_dist.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/hw/intc/arm_gicv3_dist.c | ||
31 | +++ b/hw/intc/arm_gicv3_dist.c | ||
32 | @@ -XXX,XX +XXX,XX @@ static int gicd_ns_access(GICv3State *s, int irq) | ||
33 | return extract32(s->gicd_nsacr[irq / 16], (irq % 16) * 2, 2); | ||
34 | } | ||
35 | |||
36 | +static void gicd_write_bitmap_reg(GICv3State *s, MemTxAttrs attrs, | ||
37 | + uint32_t *bmp, maskfn *maskfn, | ||
38 | + int offset, uint32_t val) | ||
39 | +{ | ||
40 | + /* | ||
41 | + * Helper routine to implement writing to a "set" register | ||
42 | + * (GICD_INMIR, etc). | ||
43 | + * Semantics implemented here: | ||
44 | + * RAZ/WI for SGIs, PPIs, unimplemented IRQs | ||
45 | + * Bits corresponding to Group 0 or Secure Group 1 interrupts RAZ/WI. | ||
46 | + * offset should be the offset in bytes of the register from the start | ||
47 | + * of its group. | ||
48 | + */ | ||
49 | + int irq = offset * 8; | ||
50 | + | ||
51 | + if (irq < GIC_INTERNAL || irq >= s->num_irq) { | ||
52 | + return; | ||
53 | + } | ||
54 | + val &= mask_group_and_nsacr(s, attrs, maskfn, irq); | ||
55 | + *gic_bmp_ptr32(bmp, irq) = val; | ||
56 | + gicv3_update(s, irq, 32); | ||
57 | +} | ||
58 | + | ||
59 | static void gicd_write_set_bitmap_reg(GICv3State *s, MemTxAttrs attrs, | ||
60 | uint32_t *bmp, | ||
61 | maskfn *maskfn, | ||
62 | @@ -XXX,XX +XXX,XX @@ static bool gicd_readl(GICv3State *s, hwaddr offset, | ||
63 | /* RAZ/WI since affinity routing is always enabled */ | ||
64 | *data = 0; | ||
65 | return true; | ||
66 | + case GICD_INMIR ... GICD_INMIR + 0x7f: | ||
67 | + *data = (!s->nmi_support) ? 0 : | ||
68 | + gicd_read_bitmap_reg(s, attrs, s->nmi, NULL, | ||
69 | + offset - GICD_INMIR); | ||
70 | + return true; | ||
71 | case GICD_IROUTER ... GICD_IROUTER + 0x1fdf: | ||
72 | { | ||
73 | uint64_t r; | ||
74 | @@ -XXX,XX +XXX,XX @@ static bool gicd_writel(GICv3State *s, hwaddr offset, | ||
75 | case GICD_SPENDSGIR ... GICD_SPENDSGIR + 0xf: | ||
76 | /* RAZ/WI since affinity routing is always enabled */ | ||
77 | return true; | ||
78 | + case GICD_INMIR ... GICD_INMIR + 0x7f: | ||
79 | + if (s->nmi_support) { | ||
80 | + gicd_write_bitmap_reg(s, attrs, s->nmi, NULL, | ||
81 | + offset - GICD_INMIR, value); | ||
82 | + } | ||
83 | + return true; | ||
84 | case GICD_IROUTER ... GICD_IROUTER + 0x1fdf: | ||
85 | { | ||
86 | uint64_t r; | ||
87 | -- | ||
88 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Add the NMIAR CPU interface registers which deal with acknowledging NMI. | ||
1 | 2 | ||
3 | When introduce NMI interrupt, there are some updates to the semantics for the | ||
4 | register ICC_IAR1_EL1 and ICC_HPPIR1_EL1. For ICC_IAR1_EL1 register, it | ||
5 | should return 1022 if the intid has non-maskable property. And for | ||
6 | ICC_NMIAR1_EL1 register, it should return 1023 if the intid do not have | ||
7 | non-maskable property. Howerever, these are not necessary for ICC_HPPIR1_EL1 | ||
8 | register. | ||
9 | |||
10 | And the APR and RPR has NMI bits which should be handled correctly. | ||
11 | |||
12 | Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | [PMM: Separate out whether cpuif supports NMI from whether the | ||
15 | GIC proper (IRI) supports NMI] | ||
16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | Message-id: 20240407081733.3231820-19-ruanjinjie@huawei.com | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | --- | ||
20 | hw/intc/gicv3_internal.h | 5 + | ||
21 | include/hw/intc/arm_gicv3_common.h | 7 ++ | ||
22 | hw/intc/arm_gicv3_cpuif.c | 147 ++++++++++++++++++++++++++++- | ||
23 | hw/intc/trace-events | 1 + | ||
24 | 4 files changed, 155 insertions(+), 5 deletions(-) | ||
25 | |||
26 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/hw/intc/gicv3_internal.h | ||
29 | +++ b/hw/intc/gicv3_internal.h | ||
30 | @@ -XXX,XX +XXX,XX @@ FIELD(GICR_VPENDBASER, VALID, 63, 1) | ||
31 | #define ICC_CTLR_EL3_A3V (1U << 15) | ||
32 | #define ICC_CTLR_EL3_NDS (1U << 17) | ||
33 | |||
34 | +#define ICC_AP1R_EL1_NMI (1ULL << 63) | ||
35 | +#define ICC_RPR_EL1_NSNMI (1ULL << 62) | ||
36 | +#define ICC_RPR_EL1_NMI (1ULL << 63) | ||
37 | + | ||
38 | #define ICH_VMCR_EL2_VENG0_SHIFT 0 | ||
39 | #define ICH_VMCR_EL2_VENG0 (1U << ICH_VMCR_EL2_VENG0_SHIFT) | ||
40 | #define ICH_VMCR_EL2_VENG1_SHIFT 1 | ||
41 | @@ -XXX,XX +XXX,XX @@ FIELD(VTE, RDBASE, 42, RDBASE_PROCNUM_LENGTH) | ||
42 | /* Special interrupt IDs */ | ||
43 | #define INTID_SECURE 1020 | ||
44 | #define INTID_NONSECURE 1021 | ||
45 | +#define INTID_NMI 1022 | ||
46 | #define INTID_SPURIOUS 1023 | ||
47 | |||
48 | /* Functions internal to the emulated GICv3 */ | ||
49 | diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/include/hw/intc/arm_gicv3_common.h | ||
52 | +++ b/include/hw/intc/arm_gicv3_common.h | ||
53 | @@ -XXX,XX +XXX,XX @@ struct GICv3CPUState { | ||
54 | |||
55 | /* This is temporary working state, to avoid a malloc in gicv3_update() */ | ||
56 | bool seenbetter; | ||
57 | + | ||
58 | + /* | ||
59 | + * Whether the CPU interface has NMI support (FEAT_GICv3_NMI). The | ||
60 | + * CPU interface may support NMIs even when the GIC proper (what the | ||
61 | + * spec calls the IRI; the redistributors and distributor) does not. | ||
62 | + */ | ||
63 | + bool nmi_support; | ||
64 | }; | ||
65 | |||
66 | /* | ||
67 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | ||
68 | index XXXXXXX..XXXXXXX 100644 | ||
69 | --- a/hw/intc/arm_gicv3_cpuif.c | ||
70 | +++ b/hw/intc/arm_gicv3_cpuif.c | ||
71 | @@ -XXX,XX +XXX,XX @@ | ||
72 | #include "hw/irq.h" | ||
73 | #include "cpu.h" | ||
74 | #include "target/arm/cpregs.h" | ||
75 | +#include "target/arm/cpu-features.h" | ||
76 | #include "sysemu/tcg.h" | ||
77 | #include "sysemu/qtest.h" | ||
78 | |||
79 | @@ -XXX,XX +XXX,XX @@ static uint64_t icv_iar_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
80 | return intid; | ||
81 | } | ||
82 | |||
83 | +static uint64_t icv_nmiar1_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
84 | +{ | ||
85 | + /* todo */ | ||
86 | + uint64_t intid = INTID_SPURIOUS; | ||
87 | + return intid; | ||
88 | +} | ||
89 | + | ||
90 | static uint32_t icc_fullprio_mask(GICv3CPUState *cs) | ||
91 | { | ||
92 | /* | ||
93 | @@ -XXX,XX +XXX,XX @@ static int icc_highest_active_prio(GICv3CPUState *cs) | ||
94 | */ | ||
95 | int i; | ||
96 | |||
97 | + if (cs->nmi_support) { | ||
98 | + /* | ||
99 | + * If an NMI is active this takes precedence over anything else | ||
100 | + * for priority purposes; the NMI bit is only in the AP1R0 bit. | ||
101 | + * We return here the effective priority of the NMI, which is | ||
102 | + * either 0x0 or 0x80. Callers will need to check NMI again for | ||
103 | + * purposes of either setting the RPR register bits or for | ||
104 | + * prioritization of NMI vs non-NMI. | ||
105 | + */ | ||
106 | + if (cs->icc_apr[GICV3_G1][0] & ICC_AP1R_EL1_NMI) { | ||
107 | + return 0; | ||
108 | + } | ||
109 | + if (cs->icc_apr[GICV3_G1NS][0] & ICC_AP1R_EL1_NMI) { | ||
110 | + return (cs->gic->gicd_ctlr & GICD_CTLR_DS) ? 0 : 0x80; | ||
111 | + } | ||
112 | + } | ||
113 | + | ||
114 | for (i = 0; i < icc_num_aprs(cs); i++) { | ||
115 | uint32_t apr = cs->icc_apr[GICV3_G0][i] | | ||
116 | cs->icc_apr[GICV3_G1][i] | cs->icc_apr[GICV3_G1NS][i]; | ||
117 | @@ -XXX,XX +XXX,XX @@ static bool icc_hppi_can_preempt(GICv3CPUState *cs) | ||
118 | */ | ||
119 | int rprio; | ||
120 | uint32_t mask; | ||
121 | + ARMCPU *cpu = ARM_CPU(cs->cpu); | ||
122 | + CPUARMState *env = &cpu->env; | ||
123 | |||
124 | if (icc_no_enabled_hppi(cs)) { | ||
125 | return false; | ||
126 | } | ||
127 | |||
128 | - if (cs->hppi.prio >= cs->icc_pmr_el1) { | ||
129 | + if (cs->hppi.nmi) { | ||
130 | + if (!(cs->gic->gicd_ctlr & GICD_CTLR_DS) && | ||
131 | + cs->hppi.grp == GICV3_G1NS) { | ||
132 | + if (cs->icc_pmr_el1 < 0x80) { | ||
133 | + return false; | ||
134 | + } | ||
135 | + if (arm_is_secure(env) && cs->icc_pmr_el1 == 0x80) { | ||
136 | + return false; | ||
137 | + } | ||
138 | + } | ||
139 | + } else if (cs->hppi.prio >= cs->icc_pmr_el1) { | ||
140 | /* Priority mask masks this interrupt */ | ||
141 | return false; | ||
142 | } | ||
143 | @@ -XXX,XX +XXX,XX @@ static bool icc_hppi_can_preempt(GICv3CPUState *cs) | ||
144 | return true; | ||
145 | } | ||
146 | |||
147 | + if (cs->hppi.nmi && (cs->hppi.prio & mask) == (rprio & mask)) { | ||
148 | + if (!(cs->icc_apr[cs->hppi.grp][0] & ICC_AP1R_EL1_NMI)) { | ||
149 | + return true; | ||
150 | + } | ||
151 | + } | ||
152 | + | ||
153 | return false; | ||
154 | } | ||
155 | |||
156 | @@ -XXX,XX +XXX,XX @@ static void icc_activate_irq(GICv3CPUState *cs, int irq) | ||
157 | int aprbit = prio >> (8 - cs->prebits); | ||
158 | int regno = aprbit / 32; | ||
159 | int regbit = aprbit % 32; | ||
160 | + bool nmi = cs->hppi.nmi; | ||
161 | |||
162 | - cs->icc_apr[cs->hppi.grp][regno] |= (1 << regbit); | ||
163 | + if (nmi) { | ||
164 | + cs->icc_apr[cs->hppi.grp][regno] |= ICC_AP1R_EL1_NMI; | ||
165 | + } else { | ||
166 | + cs->icc_apr[cs->hppi.grp][regno] |= (1 << regbit); | ||
167 | + } | ||
168 | |||
169 | if (irq < GIC_INTERNAL) { | ||
170 | cs->gicr_iactiver0 = deposit32(cs->gicr_iactiver0, irq, 1, 1); | ||
171 | @@ -XXX,XX +XXX,XX @@ static uint64_t icc_iar0_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
172 | static uint64_t icc_iar1_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
173 | { | ||
174 | GICv3CPUState *cs = icc_cs_from_env(env); | ||
175 | + int el = arm_current_el(env); | ||
176 | uint64_t intid; | ||
177 | |||
178 | if (icv_access(env, HCR_IMO)) { | ||
179 | @@ -XXX,XX +XXX,XX @@ static uint64_t icc_iar1_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
180 | } | ||
181 | |||
182 | if (!gicv3_intid_is_special(intid)) { | ||
183 | - icc_activate_irq(cs, intid); | ||
184 | + if (cs->hppi.nmi && env->cp15.sctlr_el[el] & SCTLR_NMI) { | ||
185 | + intid = INTID_NMI; | ||
186 | + } else { | ||
187 | + icc_activate_irq(cs, intid); | ||
188 | + } | ||
189 | } | ||
190 | |||
191 | trace_gicv3_icc_iar1_read(gicv3_redist_affid(cs), intid); | ||
192 | return intid; | ||
193 | } | ||
194 | |||
195 | +static uint64_t icc_nmiar1_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
196 | +{ | ||
197 | + GICv3CPUState *cs = icc_cs_from_env(env); | ||
198 | + uint64_t intid; | ||
199 | + | ||
200 | + if (icv_access(env, HCR_IMO)) { | ||
201 | + return icv_nmiar1_read(env, ri); | ||
202 | + } | ||
203 | + | ||
204 | + if (!icc_hppi_can_preempt(cs)) { | ||
205 | + intid = INTID_SPURIOUS; | ||
206 | + } else { | ||
207 | + intid = icc_hppir1_value(cs, env); | ||
208 | + } | ||
209 | + | ||
210 | + if (!gicv3_intid_is_special(intid)) { | ||
211 | + if (!cs->hppi.nmi) { | ||
212 | + intid = INTID_SPURIOUS; | ||
213 | + } else { | ||
214 | + icc_activate_irq(cs, intid); | ||
215 | + } | ||
216 | + } | ||
217 | + | ||
218 | + trace_gicv3_icc_nmiar1_read(gicv3_redist_affid(cs), intid); | ||
219 | + return intid; | ||
220 | +} | ||
221 | + | ||
222 | static void icc_drop_prio(GICv3CPUState *cs, int grp) | ||
223 | { | ||
224 | /* Drop the priority of the currently active interrupt in | ||
225 | @@ -XXX,XX +XXX,XX @@ static void icc_drop_prio(GICv3CPUState *cs, int grp) | ||
226 | if (!*papr) { | ||
227 | continue; | ||
228 | } | ||
229 | + | ||
230 | + if (i == 0 && cs->nmi_support && (*papr & ICC_AP1R_EL1_NMI)) { | ||
231 | + *papr &= (~ICC_AP1R_EL1_NMI); | ||
232 | + break; | ||
233 | + } | ||
234 | + | ||
235 | /* Clear the lowest set bit */ | ||
236 | *papr &= *papr - 1; | ||
237 | break; | ||
238 | @@ -XXX,XX +XXX,XX @@ static int icc_highest_active_group(GICv3CPUState *cs) | ||
239 | */ | ||
240 | int i; | ||
241 | |||
242 | + if (cs->nmi_support) { | ||
243 | + if (cs->icc_apr[GICV3_G1][0] & ICC_AP1R_EL1_NMI) { | ||
244 | + return GICV3_G1; | ||
245 | + } | ||
246 | + if (cs->icc_apr[GICV3_G1NS][0] & ICC_AP1R_EL1_NMI) { | ||
247 | + return GICV3_G1NS; | ||
248 | + } | ||
249 | + } | ||
250 | + | ||
251 | for (i = 0; i < ARRAY_SIZE(cs->icc_apr[0]); i++) { | ||
252 | int g0ctz = ctz32(cs->icc_apr[GICV3_G0][i]); | ||
253 | int g1ctz = ctz32(cs->icc_apr[GICV3_G1][i]); | ||
254 | @@ -XXX,XX +XXX,XX @@ static void icc_ap_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
255 | return; | ||
256 | } | ||
257 | |||
258 | - cs->icc_apr[grp][regno] = value & 0xFFFFFFFFU; | ||
259 | + if (cs->nmi_support) { | ||
260 | + cs->icc_apr[grp][regno] = value & (0xFFFFFFFFU | ICC_AP1R_EL1_NMI); | ||
261 | + } else { | ||
262 | + cs->icc_apr[grp][regno] = value & 0xFFFFFFFFU; | ||
263 | + } | ||
264 | gicv3_cpuif_update(cs); | ||
265 | } | ||
266 | |||
267 | @@ -XXX,XX +XXX,XX @@ static void icc_dir_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
268 | static uint64_t icc_rpr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
269 | { | ||
270 | GICv3CPUState *cs = icc_cs_from_env(env); | ||
271 | - int prio; | ||
272 | + uint64_t prio; | ||
273 | |||
274 | if (icv_access(env, HCR_FMO | HCR_IMO)) { | ||
275 | return icv_rpr_read(env, ri); | ||
276 | @@ -XXX,XX +XXX,XX @@ static uint64_t icc_rpr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
277 | } | ||
278 | } | ||
279 | |||
280 | + if (cs->nmi_support) { | ||
281 | + /* NMI info is reported in the high bits of RPR */ | ||
282 | + if (arm_feature(env, ARM_FEATURE_EL3) && !arm_is_secure(env)) { | ||
283 | + if (cs->icc_apr[GICV3_G1NS][0] & ICC_AP1R_EL1_NMI) { | ||
284 | + prio |= ICC_RPR_EL1_NMI; | ||
285 | + } | ||
286 | + } else { | ||
287 | + if (cs->icc_apr[GICV3_G1NS][0] & ICC_AP1R_EL1_NMI) { | ||
288 | + prio |= ICC_RPR_EL1_NSNMI; | ||
289 | + } | ||
290 | + if (cs->icc_apr[GICV3_G1][0] & ICC_AP1R_EL1_NMI) { | ||
291 | + prio |= ICC_RPR_EL1_NMI; | ||
292 | + } | ||
293 | + } | ||
294 | + } | ||
295 | + | ||
296 | trace_gicv3_icc_rpr_read(gicv3_redist_affid(cs), prio); | ||
297 | return prio; | ||
298 | } | ||
299 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_icc_apxr23_reginfo[] = { | ||
300 | }, | ||
301 | }; | ||
302 | |||
303 | +static const ARMCPRegInfo gicv3_cpuif_gicv3_nmi_reginfo[] = { | ||
304 | + { .name = "ICC_NMIAR1_EL1", .state = ARM_CP_STATE_BOTH, | ||
305 | + .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 9, .opc2 = 5, | ||
306 | + .type = ARM_CP_IO | ARM_CP_NO_RAW, | ||
307 | + .access = PL1_R, .accessfn = gicv3_irq_access, | ||
308 | + .readfn = icc_nmiar1_read, | ||
309 | + }, | ||
310 | +}; | ||
311 | + | ||
312 | static uint64_t ich_ap_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
313 | { | ||
314 | GICv3CPUState *cs = icc_cs_from_env(env); | ||
315 | @@ -XXX,XX +XXX,XX @@ void gicv3_init_cpuif(GICv3State *s) | ||
316 | */ | ||
317 | define_arm_cp_regs(cpu, gicv3_cpuif_reginfo); | ||
318 | |||
319 | + /* | ||
320 | + * If the CPU implements FEAT_NMI and FEAT_GICv3 it must also | ||
321 | + * implement FEAT_GICv3_NMI, which is the CPU interface part | ||
322 | + * of NMI support. This is distinct from whether the GIC proper | ||
323 | + * (redistributors and distributor) have NMI support. In QEMU | ||
324 | + * that is a property of the GIC device in s->nmi_support; | ||
325 | + * cs->nmi_support indicates the CPU interface's support. | ||
326 | + */ | ||
327 | + if (cpu_isar_feature(aa64_nmi, cpu)) { | ||
328 | + cs->nmi_support = true; | ||
329 | + define_arm_cp_regs(cpu, gicv3_cpuif_gicv3_nmi_reginfo); | ||
330 | + } | ||
331 | + | ||
332 | /* | ||
333 | * The CPU implementation specifies the number of supported | ||
334 | * bits of physical priority. For backwards compatibility | ||
335 | diff --git a/hw/intc/trace-events b/hw/intc/trace-events | ||
336 | index XXXXXXX..XXXXXXX 100644 | ||
337 | --- a/hw/intc/trace-events | ||
338 | +++ b/hw/intc/trace-events | ||
339 | @@ -XXX,XX +XXX,XX @@ gicv3_cpuif_set_irqs(uint32_t cpuid, int fiqlevel, int irqlevel) "GICv3 CPU i/f | ||
340 | gicv3_icc_generate_sgi(uint32_t cpuid, int irq, int irm, uint32_t aff, uint32_t targetlist) "GICv3 CPU i/f 0x%x generating SGI %d IRM %d target affinity 0x%xxx targetlist 0x%x" | ||
341 | gicv3_icc_iar0_read(uint32_t cpu, uint64_t val) "GICv3 ICC_IAR0 read cpu 0x%x value 0x%" PRIx64 | ||
342 | gicv3_icc_iar1_read(uint32_t cpu, uint64_t val) "GICv3 ICC_IAR1 read cpu 0x%x value 0x%" PRIx64 | ||
343 | +gicv3_icc_nmiar1_read(uint32_t cpu, uint64_t val) "GICv3 ICC_NMIAR1 read cpu 0x%x value 0x%" PRIx64 | ||
344 | gicv3_icc_eoir_write(int grp, uint32_t cpu, uint64_t val) "GICv3 ICC_EOIR%d write cpu 0x%x value 0x%" PRIx64 | ||
345 | gicv3_icc_hppir0_read(uint32_t cpu, uint64_t val) "GICv3 ICC_HPPIR0 read cpu 0x%x value 0x%" PRIx64 | ||
346 | gicv3_icc_hppir1_read(uint32_t cpu, uint64_t val) "GICv3 ICC_HPPIR1 read cpu 0x%x value 0x%" PRIx64 | ||
347 | -- | ||
348 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> | 1 | Implement icv_nmiar1_read() for icc_nmiar1_read(), so add definition for |
---|---|---|---|
2 | 2 | ICH_LR_EL2.NMI and ICH_AP1R_EL2.NMI bit. | |
3 | * Add Addr and size definition for most i.MX6UL devices in i.MX6UL header file. | 3 | |
4 | * Use those newly defined named constants whenever possible. | 4 | If FEAT_GICv3_NMI is supported, ich_ap_write() should consider ICV_AP1R_EL1.NMI |
5 | * Standardize the way we init a familly of unimplemented devices | 5 | bit. In icv_activate_irq() and icv_eoir_write(), the ICV_AP1R_EL1.NMI bit |
6 | - SAI | 6 | should be set or clear according to the Non-maskable property. And the RPR |
7 | - PWM | 7 | priority should also update the NMI bit according to the APR priority NMI bit. |
8 | - CAN | 8 | |
9 | * Add/rework few comments | 9 | By the way, add gicv3_icv_nmiar1_read trace event. |
10 | 10 | ||
11 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> | 11 | If the hpp irq is a NMI, the icv iar read should return 1022 and trap for |
12 | Message-id: d579043fbd4e4b490370783fda43fc02c8e9be75.1692964892.git.jcd@tribudubois.net | 12 | NMI again |
13 | |||
14 | Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> | ||
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | [PMM: use cs->nmi_support instead of cs->gic->nmi_support] | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Message-id: 20240407081733.3231820-20-ruanjinjie@huawei.com | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 20 | --- |
16 | include/hw/arm/fsl-imx6ul.h | 156 +++++++++++++++++++++++++++++++----- | 21 | hw/intc/gicv3_internal.h | 4 ++ |
17 | hw/arm/fsl-imx6ul.c | 147 ++++++++++++++++++++++----------- | 22 | hw/intc/arm_gicv3_cpuif.c | 105 +++++++++++++++++++++++++++++++++----- |
18 | 2 files changed, 232 insertions(+), 71 deletions(-) | 23 | hw/intc/trace-events | 1 + |
19 | 24 | 3 files changed, 98 insertions(+), 12 deletions(-) | |
20 | diff --git a/include/hw/arm/fsl-imx6ul.h b/include/hw/arm/fsl-imx6ul.h | 25 | |
26 | diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/hw/arm/fsl-imx6ul.h | 28 | --- a/hw/intc/gicv3_internal.h |
23 | +++ b/include/hw/arm/fsl-imx6ul.h | 29 | +++ b/hw/intc/gicv3_internal.h |
24 | @@ -XXX,XX +XXX,XX @@ | 30 | @@ -XXX,XX +XXX,XX @@ FIELD(GICR_VPENDBASER, VALID, 63, 1) |
25 | #include "exec/memory.h" | 31 | #define ICH_LR_EL2_PRIORITY_SHIFT 48 |
26 | #include "cpu.h" | 32 | #define ICH_LR_EL2_PRIORITY_LENGTH 8 |
27 | #include "qom/object.h" | 33 | #define ICH_LR_EL2_PRIORITY_MASK (0xffULL << ICH_LR_EL2_PRIORITY_SHIFT) |
28 | +#include "qemu/units.h" | 34 | +#define ICH_LR_EL2_NMI (1ULL << 59) |
29 | 35 | #define ICH_LR_EL2_GROUP (1ULL << 60) | |
30 | #define TYPE_FSL_IMX6UL "fsl-imx6ul" | 36 | #define ICH_LR_EL2_HW (1ULL << 61) |
31 | OBJECT_DECLARE_SIMPLE_TYPE(FslIMX6ULState, FSL_IMX6UL) | 37 | #define ICH_LR_EL2_STATE_SHIFT 62 |
32 | @@ -XXX,XX +XXX,XX @@ enum FslIMX6ULConfiguration { | 38 | @@ -XXX,XX +XXX,XX @@ FIELD(GICR_VPENDBASER, VALID, 63, 1) |
33 | FSL_IMX6UL_NUM_ADCS = 2, | 39 | #define ICH_VTR_EL2_PREBITS_SHIFT 26 |
34 | FSL_IMX6UL_NUM_USB_PHYS = 2, | 40 | #define ICH_VTR_EL2_PRIBITS_SHIFT 29 |
35 | FSL_IMX6UL_NUM_USBS = 2, | 41 | |
36 | + FSL_IMX6UL_NUM_SAIS = 3, | 42 | +#define ICV_AP1R_EL1_NMI (1ULL << 63) |
37 | + FSL_IMX6UL_NUM_CANS = 2, | 43 | +#define ICV_RPR_EL1_NMI (1ULL << 63) |
38 | + FSL_IMX6UL_NUM_PWMS = 4, | 44 | + |
39 | }; | 45 | /* ITS Registers */ |
40 | 46 | ||
41 | struct FslIMX6ULState { | 47 | FIELD(GITS_BASER, SIZE, 0, 8) |
42 | @@ -XXX,XX +XXX,XX @@ struct FslIMX6ULState { | 48 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c |
43 | |||
44 | enum FslIMX6ULMemoryMap { | ||
45 | FSL_IMX6UL_MMDC_ADDR = 0x80000000, | ||
46 | - FSL_IMX6UL_MMDC_SIZE = 2 * 1024 * 1024 * 1024UL, | ||
47 | + FSL_IMX6UL_MMDC_SIZE = (2 * GiB), | ||
48 | |||
49 | FSL_IMX6UL_QSPI1_MEM_ADDR = 0x60000000, | ||
50 | - FSL_IMX6UL_EIM_ALIAS_ADDR = 0x58000000, | ||
51 | - FSL_IMX6UL_EIM_CS_ADDR = 0x50000000, | ||
52 | - FSL_IMX6UL_AES_ENCRYPT_ADDR = 0x10000000, | ||
53 | - FSL_IMX6UL_QSPI1_RX_ADDR = 0x0C000000, | ||
54 | + FSL_IMX6UL_QSPI1_MEM_SIZE = (256 * MiB), | ||
55 | |||
56 | - /* AIPS-2 */ | ||
57 | + FSL_IMX6UL_EIM_ALIAS_ADDR = 0x58000000, | ||
58 | + FSL_IMX6UL_EIM_ALIAS_SIZE = (128 * MiB), | ||
59 | + | ||
60 | + FSL_IMX6UL_EIM_CS_ADDR = 0x50000000, | ||
61 | + FSL_IMX6UL_EIM_CS_SIZE = (128 * MiB), | ||
62 | + | ||
63 | + FSL_IMX6UL_AES_ENCRYPT_ADDR = 0x10000000, | ||
64 | + FSL_IMX6UL_AES_ENCRYPT_SIZE = (1 * MiB), | ||
65 | + | ||
66 | + FSL_IMX6UL_QSPI1_RX_ADDR = 0x0C000000, | ||
67 | + FSL_IMX6UL_QSPI1_RX_SIZE = (32 * MiB), | ||
68 | + | ||
69 | + /* AIPS-2 Begin */ | ||
70 | FSL_IMX6UL_UART6_ADDR = 0x021FC000, | ||
71 | + | ||
72 | FSL_IMX6UL_I2C4_ADDR = 0x021F8000, | ||
73 | + | ||
74 | FSL_IMX6UL_UART5_ADDR = 0x021F4000, | ||
75 | FSL_IMX6UL_UART4_ADDR = 0x021F0000, | ||
76 | FSL_IMX6UL_UART3_ADDR = 0x021EC000, | ||
77 | FSL_IMX6UL_UART2_ADDR = 0x021E8000, | ||
78 | + | ||
79 | FSL_IMX6UL_WDOG3_ADDR = 0x021E4000, | ||
80 | + | ||
81 | FSL_IMX6UL_QSPI_ADDR = 0x021E0000, | ||
82 | + FSL_IMX6UL_QSPI_SIZE = 0x500, | ||
83 | + | ||
84 | FSL_IMX6UL_SYS_CNT_CTRL_ADDR = 0x021DC000, | ||
85 | + FSL_IMX6UL_SYS_CNT_CTRL_SIZE = (16 * KiB), | ||
86 | + | ||
87 | FSL_IMX6UL_SYS_CNT_CMP_ADDR = 0x021D8000, | ||
88 | + FSL_IMX6UL_SYS_CNT_CMP_SIZE = (16 * KiB), | ||
89 | + | ||
90 | FSL_IMX6UL_SYS_CNT_RD_ADDR = 0x021D4000, | ||
91 | + FSL_IMX6UL_SYS_CNT_RD_SIZE = (16 * KiB), | ||
92 | + | ||
93 | FSL_IMX6UL_TZASC_ADDR = 0x021D0000, | ||
94 | + FSL_IMX6UL_TZASC_SIZE = (16 * KiB), | ||
95 | + | ||
96 | FSL_IMX6UL_PXP_ADDR = 0x021CC000, | ||
97 | + FSL_IMX6UL_PXP_SIZE = (16 * KiB), | ||
98 | + | ||
99 | FSL_IMX6UL_LCDIF_ADDR = 0x021C8000, | ||
100 | + FSL_IMX6UL_LCDIF_SIZE = 0x100, | ||
101 | + | ||
102 | FSL_IMX6UL_CSI_ADDR = 0x021C4000, | ||
103 | + FSL_IMX6UL_CSI_SIZE = 0x100, | ||
104 | + | ||
105 | FSL_IMX6UL_CSU_ADDR = 0x021C0000, | ||
106 | + FSL_IMX6UL_CSU_SIZE = (16 * KiB), | ||
107 | + | ||
108 | FSL_IMX6UL_OCOTP_CTRL_ADDR = 0x021BC000, | ||
109 | + FSL_IMX6UL_OCOTP_CTRL_SIZE = (4 * KiB), | ||
110 | + | ||
111 | FSL_IMX6UL_EIM_ADDR = 0x021B8000, | ||
112 | + FSL_IMX6UL_EIM_SIZE = 0x100, | ||
113 | + | ||
114 | FSL_IMX6UL_SIM2_ADDR = 0x021B4000, | ||
115 | + | ||
116 | FSL_IMX6UL_MMDC_CFG_ADDR = 0x021B0000, | ||
117 | + FSL_IMX6UL_MMDC_CFG_SIZE = (4 * KiB), | ||
118 | + | ||
119 | FSL_IMX6UL_ROMCP_ADDR = 0x021AC000, | ||
120 | + FSL_IMX6UL_ROMCP_SIZE = 0x300, | ||
121 | + | ||
122 | FSL_IMX6UL_I2C3_ADDR = 0x021A8000, | ||
123 | FSL_IMX6UL_I2C2_ADDR = 0x021A4000, | ||
124 | FSL_IMX6UL_I2C1_ADDR = 0x021A0000, | ||
125 | + | ||
126 | FSL_IMX6UL_ADC2_ADDR = 0x0219C000, | ||
127 | FSL_IMX6UL_ADC1_ADDR = 0x02198000, | ||
128 | + FSL_IMX6UL_ADCn_SIZE = 0x100, | ||
129 | + | ||
130 | FSL_IMX6UL_USDHC2_ADDR = 0x02194000, | ||
131 | FSL_IMX6UL_USDHC1_ADDR = 0x02190000, | ||
132 | - FSL_IMX6UL_SIM1_ADDR = 0x0218C000, | ||
133 | - FSL_IMX6UL_ENET1_ADDR = 0x02188000, | ||
134 | - FSL_IMX6UL_USBO2_USBMISC_ADDR = 0x02184800, | ||
135 | - FSL_IMX6UL_USBO2_USB_ADDR = 0x02184000, | ||
136 | - FSL_IMX6UL_USBO2_PL301_ADDR = 0x02180000, | ||
137 | - FSL_IMX6UL_AIPS2_CFG_ADDR = 0x0217C000, | ||
138 | - FSL_IMX6UL_CAAM_ADDR = 0x02140000, | ||
139 | - FSL_IMX6UL_A7MPCORE_DAP_ADDR = 0x02100000, | ||
140 | |||
141 | - /* AIPS-1 */ | ||
142 | + FSL_IMX6UL_SIM1_ADDR = 0x0218C000, | ||
143 | + FSL_IMX6UL_SIMn_SIZE = (16 * KiB), | ||
144 | + | ||
145 | + FSL_IMX6UL_ENET1_ADDR = 0x02188000, | ||
146 | + | ||
147 | + FSL_IMX6UL_USBO2_USBMISC_ADDR = 0x02184800, | ||
148 | + FSL_IMX6UL_USBO2_USB1_ADDR = 0x02184000, | ||
149 | + FSL_IMX6UL_USBO2_USB2_ADDR = 0x02184200, | ||
150 | + | ||
151 | + FSL_IMX6UL_USBO2_PL301_ADDR = 0x02180000, | ||
152 | + FSL_IMX6UL_USBO2_PL301_SIZE = (16 * KiB), | ||
153 | + | ||
154 | + FSL_IMX6UL_AIPS2_CFG_ADDR = 0x0217C000, | ||
155 | + FSL_IMX6UL_AIPS2_CFG_SIZE = 0x100, | ||
156 | + | ||
157 | + FSL_IMX6UL_CAAM_ADDR = 0x02140000, | ||
158 | + FSL_IMX6UL_CAAM_SIZE = (16 * KiB), | ||
159 | + | ||
160 | + FSL_IMX6UL_A7MPCORE_DAP_ADDR = 0x02100000, | ||
161 | + FSL_IMX6UL_A7MPCORE_DAP_SIZE = (4 * KiB), | ||
162 | + /* AIPS-2 End */ | ||
163 | + | ||
164 | + /* AIPS-1 Begin */ | ||
165 | FSL_IMX6UL_PWM8_ADDR = 0x020FC000, | ||
166 | FSL_IMX6UL_PWM7_ADDR = 0x020F8000, | ||
167 | FSL_IMX6UL_PWM6_ADDR = 0x020F4000, | ||
168 | FSL_IMX6UL_PWM5_ADDR = 0x020F0000, | ||
169 | + | ||
170 | FSL_IMX6UL_SDMA_ADDR = 0x020EC000, | ||
171 | + FSL_IMX6UL_SDMA_SIZE = 0x300, | ||
172 | + | ||
173 | FSL_IMX6UL_GPT2_ADDR = 0x020E8000, | ||
174 | + | ||
175 | FSL_IMX6UL_IOMUXC_GPR_ADDR = 0x020E4000, | ||
176 | + FSL_IMX6UL_IOMUXC_GPR_SIZE = 0x40, | ||
177 | + | ||
178 | FSL_IMX6UL_IOMUXC_ADDR = 0x020E0000, | ||
179 | + FSL_IMX6UL_IOMUXC_SIZE = 0x700, | ||
180 | + | ||
181 | FSL_IMX6UL_GPC_ADDR = 0x020DC000, | ||
182 | + | ||
183 | FSL_IMX6UL_SRC_ADDR = 0x020D8000, | ||
184 | + | ||
185 | FSL_IMX6UL_EPIT2_ADDR = 0x020D4000, | ||
186 | FSL_IMX6UL_EPIT1_ADDR = 0x020D0000, | ||
187 | + | ||
188 | FSL_IMX6UL_SNVS_HP_ADDR = 0x020CC000, | ||
189 | + | ||
190 | FSL_IMX6UL_USBPHY2_ADDR = 0x020CA000, | ||
191 | - FSL_IMX6UL_USBPHY2_SIZE = (4 * 1024), | ||
192 | FSL_IMX6UL_USBPHY1_ADDR = 0x020C9000, | ||
193 | - FSL_IMX6UL_USBPHY1_SIZE = (4 * 1024), | ||
194 | + | ||
195 | FSL_IMX6UL_ANALOG_ADDR = 0x020C8000, | ||
196 | + FSL_IMX6UL_ANALOG_SIZE = 0x300, | ||
197 | + | ||
198 | FSL_IMX6UL_CCM_ADDR = 0x020C4000, | ||
199 | + | ||
200 | FSL_IMX6UL_WDOG2_ADDR = 0x020C0000, | ||
201 | FSL_IMX6UL_WDOG1_ADDR = 0x020BC000, | ||
202 | + | ||
203 | FSL_IMX6UL_KPP_ADDR = 0x020B8000, | ||
204 | + FSL_IMX6UL_KPP_SIZE = 0x10, | ||
205 | + | ||
206 | FSL_IMX6UL_ENET2_ADDR = 0x020B4000, | ||
207 | + | ||
208 | FSL_IMX6UL_SNVS_LP_ADDR = 0x020B0000, | ||
209 | + FSL_IMX6UL_SNVS_LP_SIZE = (16 * KiB), | ||
210 | + | ||
211 | FSL_IMX6UL_GPIO5_ADDR = 0x020AC000, | ||
212 | FSL_IMX6UL_GPIO4_ADDR = 0x020A8000, | ||
213 | FSL_IMX6UL_GPIO3_ADDR = 0x020A4000, | ||
214 | FSL_IMX6UL_GPIO2_ADDR = 0x020A0000, | ||
215 | FSL_IMX6UL_GPIO1_ADDR = 0x0209C000, | ||
216 | + | ||
217 | FSL_IMX6UL_GPT1_ADDR = 0x02098000, | ||
218 | + | ||
219 | FSL_IMX6UL_CAN2_ADDR = 0x02094000, | ||
220 | FSL_IMX6UL_CAN1_ADDR = 0x02090000, | ||
221 | + FSL_IMX6UL_CANn_SIZE = (4 * KiB), | ||
222 | + | ||
223 | FSL_IMX6UL_PWM4_ADDR = 0x0208C000, | ||
224 | FSL_IMX6UL_PWM3_ADDR = 0x02088000, | ||
225 | FSL_IMX6UL_PWM2_ADDR = 0x02084000, | ||
226 | FSL_IMX6UL_PWM1_ADDR = 0x02080000, | ||
227 | + FSL_IMX6UL_PWMn_SIZE = 0x20, | ||
228 | + | ||
229 | FSL_IMX6UL_AIPS1_CFG_ADDR = 0x0207C000, | ||
230 | + FSL_IMX6UL_AIPS1_CFG_SIZE = (16 * KiB), | ||
231 | + | ||
232 | FSL_IMX6UL_BEE_ADDR = 0x02044000, | ||
233 | + FSL_IMX6UL_BEE_SIZE = (16 * KiB), | ||
234 | + | ||
235 | FSL_IMX6UL_TOUCH_CTRL_ADDR = 0x02040000, | ||
236 | + FSL_IMX6UL_TOUCH_CTRL_SIZE = 0x100, | ||
237 | + | ||
238 | FSL_IMX6UL_SPBA_ADDR = 0x0203C000, | ||
239 | + FSL_IMX6UL_SPBA_SIZE = 0x100, | ||
240 | + | ||
241 | FSL_IMX6UL_ASRC_ADDR = 0x02034000, | ||
242 | + FSL_IMX6UL_ASRC_SIZE = 0x100, | ||
243 | + | ||
244 | FSL_IMX6UL_SAI3_ADDR = 0x02030000, | ||
245 | FSL_IMX6UL_SAI2_ADDR = 0x0202C000, | ||
246 | FSL_IMX6UL_SAI1_ADDR = 0x02028000, | ||
247 | + FSL_IMX6UL_SAIn_SIZE = 0x200, | ||
248 | + | ||
249 | FSL_IMX6UL_UART8_ADDR = 0x02024000, | ||
250 | FSL_IMX6UL_UART1_ADDR = 0x02020000, | ||
251 | FSL_IMX6UL_UART7_ADDR = 0x02018000, | ||
252 | + | ||
253 | FSL_IMX6UL_ECSPI4_ADDR = 0x02014000, | ||
254 | FSL_IMX6UL_ECSPI3_ADDR = 0x02010000, | ||
255 | FSL_IMX6UL_ECSPI2_ADDR = 0x0200C000, | ||
256 | FSL_IMX6UL_ECSPI1_ADDR = 0x02008000, | ||
257 | + | ||
258 | FSL_IMX6UL_SPDIF_ADDR = 0x02004000, | ||
259 | + FSL_IMX6UL_SPDIF_SIZE = 0x100, | ||
260 | + /* AIPS-1 End */ | ||
261 | + | ||
262 | + FSL_IMX6UL_BCH_ADDR = 0x01808000, | ||
263 | + FSL_IMX6UL_BCH_SIZE = 0x200, | ||
264 | + | ||
265 | + FSL_IMX6UL_GPMI_ADDR = 0x01806000, | ||
266 | + FSL_IMX6UL_GPMI_SIZE = 0x200, | ||
267 | |||
268 | FSL_IMX6UL_APBH_DMA_ADDR = 0x01804000, | ||
269 | - FSL_IMX6UL_APBH_DMA_SIZE = (32 * 1024), | ||
270 | + FSL_IMX6UL_APBH_DMA_SIZE = (4 * KiB), | ||
271 | |||
272 | FSL_IMX6UL_A7MPCORE_ADDR = 0x00A00000, | ||
273 | |||
274 | FSL_IMX6UL_OCRAM_ALIAS_ADDR = 0x00920000, | ||
275 | - FSL_IMX6UL_OCRAM_ALIAS_SIZE = 0x00060000, | ||
276 | + FSL_IMX6UL_OCRAM_ALIAS_SIZE = (384 * KiB), | ||
277 | + | ||
278 | FSL_IMX6UL_OCRAM_MEM_ADDR = 0x00900000, | ||
279 | - FSL_IMX6UL_OCRAM_MEM_SIZE = 0x00020000, | ||
280 | + FSL_IMX6UL_OCRAM_MEM_SIZE = (128 * KiB), | ||
281 | + | ||
282 | FSL_IMX6UL_CAAM_MEM_ADDR = 0x00100000, | ||
283 | - FSL_IMX6UL_CAAM_MEM_SIZE = 0x00008000, | ||
284 | + FSL_IMX6UL_CAAM_MEM_SIZE = (32 * KiB), | ||
285 | + | ||
286 | FSL_IMX6UL_ROM_ADDR = 0x00000000, | ||
287 | - FSL_IMX6UL_ROM_SIZE = 0x00018000, | ||
288 | + FSL_IMX6UL_ROM_SIZE = (96 * KiB), | ||
289 | }; | ||
290 | |||
291 | enum FslIMX6ULIRQs { | ||
292 | diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c | ||
293 | index XXXXXXX..XXXXXXX 100644 | 49 | index XXXXXXX..XXXXXXX 100644 |
294 | --- a/hw/arm/fsl-imx6ul.c | 50 | --- a/hw/intc/arm_gicv3_cpuif.c |
295 | +++ b/hw/arm/fsl-imx6ul.c | 51 | +++ b/hw/intc/arm_gicv3_cpuif.c |
296 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | 52 | @@ -XXX,XX +XXX,XX @@ static int ich_highest_active_virt_prio(GICv3CPUState *cs) |
297 | object_initialize_child(obj, "snvs", &s->snvs, TYPE_IMX7_SNVS); | 53 | int i; |
298 | 54 | int aprmax = ich_num_aprs(cs); | |
299 | /* | 55 | |
300 | - * GPIOs 1 to 5 | 56 | + if (cs->ich_apr[GICV3_G1NS][0] & ICV_AP1R_EL1_NMI) { |
301 | + * GPIOs | 57 | + return 0x0; |
302 | */ | 58 | + } |
303 | for (i = 0; i < FSL_IMX6UL_NUM_GPIOS; i++) { | 59 | + |
304 | snprintf(name, NAME_SIZE, "gpio%d", i); | 60 | for (i = 0; i < aprmax; i++) { |
305 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | 61 | uint32_t apr = cs->ich_apr[GICV3_G0][i] | |
62 | cs->ich_apr[GICV3_G1NS][i]; | ||
63 | @@ -XXX,XX +XXX,XX @@ static int hppvi_index(GICv3CPUState *cs) | ||
64 | * correct behaviour. | ||
65 | */ | ||
66 | int prio = 0xff; | ||
67 | + bool nmi = false; | ||
68 | |||
69 | if (!(cs->ich_vmcr_el2 & (ICH_VMCR_EL2_VENG0 | ICH_VMCR_EL2_VENG1))) { | ||
70 | /* Both groups disabled, definitely nothing to do */ | ||
71 | @@ -XXX,XX +XXX,XX @@ static int hppvi_index(GICv3CPUState *cs) | ||
72 | |||
73 | for (i = 0; i < cs->num_list_regs; i++) { | ||
74 | uint64_t lr = cs->ich_lr_el2[i]; | ||
75 | + bool thisnmi; | ||
76 | int thisprio; | ||
77 | |||
78 | if (ich_lr_state(lr) != ICH_LR_EL2_STATE_PENDING) { | ||
79 | @@ -XXX,XX +XXX,XX @@ static int hppvi_index(GICv3CPUState *cs) | ||
80 | } | ||
81 | } | ||
82 | |||
83 | + thisnmi = lr & ICH_LR_EL2_NMI; | ||
84 | thisprio = ich_lr_prio(lr); | ||
85 | |||
86 | - if (thisprio < prio) { | ||
87 | + if ((thisprio < prio) || ((thisprio == prio) && (thisnmi & (!nmi)))) { | ||
88 | prio = thisprio; | ||
89 | + nmi = thisnmi; | ||
90 | idx = i; | ||
91 | } | ||
306 | } | 92 | } |
307 | 93 | @@ -XXX,XX +XXX,XX @@ static bool icv_hppi_can_preempt(GICv3CPUState *cs, uint64_t lr) | |
308 | /* | 94 | * equivalent of these checks. |
309 | - * GPT 1, 2 | 95 | */ |
310 | + * GPTs | 96 | int grp; |
311 | */ | 97 | + bool is_nmi; |
312 | for (i = 0; i < FSL_IMX6UL_NUM_GPTS; i++) { | 98 | uint32_t mask, prio, rprio, vpmr; |
313 | snprintf(name, NAME_SIZE, "gpt%d", i); | 99 | |
314 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | 100 | if (!(cs->ich_hcr_el2 & ICH_HCR_EL2_EN)) { |
101 | @@ -XXX,XX +XXX,XX @@ static bool icv_hppi_can_preempt(GICv3CPUState *cs, uint64_t lr) | ||
102 | */ | ||
103 | |||
104 | prio = ich_lr_prio(lr); | ||
105 | + is_nmi = lr & ICH_LR_EL2_NMI; | ||
106 | vpmr = extract64(cs->ich_vmcr_el2, ICH_VMCR_EL2_VPMR_SHIFT, | ||
107 | ICH_VMCR_EL2_VPMR_LENGTH); | ||
108 | |||
109 | - if (prio >= vpmr) { | ||
110 | + if (!is_nmi && prio >= vpmr) { | ||
111 | /* Priority mask masks this interrupt */ | ||
112 | return false; | ||
315 | } | 113 | } |
316 | 114 | @@ -XXX,XX +XXX,XX @@ static bool icv_hppi_can_preempt(GICv3CPUState *cs, uint64_t lr) | |
317 | /* | 115 | return true; |
318 | - * EPIT 1, 2 | ||
319 | + * EPITs | ||
320 | */ | ||
321 | for (i = 0; i < FSL_IMX6UL_NUM_EPITS; i++) { | ||
322 | snprintf(name, NAME_SIZE, "epit%d", i + 1); | ||
323 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | ||
324 | } | 116 | } |
325 | 117 | ||
326 | /* | 118 | + if ((prio & mask) == (rprio & mask) && is_nmi && |
327 | - * eCSPI | 119 | + !(cs->ich_apr[GICV3_G1NS][0] & ICV_AP1R_EL1_NMI)) { |
328 | + * eCSPIs | 120 | + return true; |
329 | */ | 121 | + } |
330 | for (i = 0; i < FSL_IMX6UL_NUM_ECSPIS; i++) { | 122 | + |
331 | snprintf(name, NAME_SIZE, "spi%d", i + 1); | 123 | return false; |
332 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | 124 | } |
125 | |||
126 | @@ -XXX,XX +XXX,XX @@ static void icv_ap_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
127 | |||
128 | trace_gicv3_icv_ap_write(ri->crm & 1, regno, gicv3_redist_affid(cs), value); | ||
129 | |||
130 | - cs->ich_apr[grp][regno] = value & 0xFFFFFFFFU; | ||
131 | + if (cs->nmi_support) { | ||
132 | + cs->ich_apr[grp][regno] = value & (0xFFFFFFFFU | ICV_AP1R_EL1_NMI); | ||
133 | + } else { | ||
134 | + cs->ich_apr[grp][regno] = value & 0xFFFFFFFFU; | ||
135 | + } | ||
136 | |||
137 | gicv3_cpuif_virt_irq_fiq_update(cs); | ||
138 | return; | ||
139 | @@ -XXX,XX +XXX,XX @@ static void icv_ctlr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
140 | static uint64_t icv_rpr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
141 | { | ||
142 | GICv3CPUState *cs = icc_cs_from_env(env); | ||
143 | - int prio = ich_highest_active_virt_prio(cs); | ||
144 | + uint64_t prio = ich_highest_active_virt_prio(cs); | ||
145 | + | ||
146 | + if (cs->ich_apr[GICV3_G1NS][0] & ICV_AP1R_EL1_NMI) { | ||
147 | + prio |= ICV_RPR_EL1_NMI; | ||
148 | + } | ||
149 | |||
150 | trace_gicv3_icv_rpr_read(gicv3_redist_affid(cs), prio); | ||
151 | return prio; | ||
152 | @@ -XXX,XX +XXX,XX @@ static void icv_activate_irq(GICv3CPUState *cs, int idx, int grp) | ||
153 | */ | ||
154 | uint32_t mask = icv_gprio_mask(cs, grp); | ||
155 | int prio = ich_lr_prio(cs->ich_lr_el2[idx]) & mask; | ||
156 | + bool nmi = cs->ich_lr_el2[idx] & ICH_LR_EL2_NMI; | ||
157 | int aprbit = prio >> (8 - cs->vprebits); | ||
158 | int regno = aprbit / 32; | ||
159 | int regbit = aprbit % 32; | ||
160 | |||
161 | cs->ich_lr_el2[idx] &= ~ICH_LR_EL2_STATE_PENDING_BIT; | ||
162 | cs->ich_lr_el2[idx] |= ICH_LR_EL2_STATE_ACTIVE_BIT; | ||
163 | - cs->ich_apr[grp][regno] |= (1 << regbit); | ||
164 | + | ||
165 | + if (nmi) { | ||
166 | + cs->ich_apr[grp][regno] |= ICV_AP1R_EL1_NMI; | ||
167 | + } else { | ||
168 | + cs->ich_apr[grp][regno] |= (1 << regbit); | ||
169 | + } | ||
170 | } | ||
171 | |||
172 | static void icv_activate_vlpi(GICv3CPUState *cs) | ||
173 | @@ -XXX,XX +XXX,XX @@ static uint64_t icv_iar_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
174 | int grp = ri->crm == 8 ? GICV3_G0 : GICV3_G1NS; | ||
175 | int idx = hppvi_index(cs); | ||
176 | uint64_t intid = INTID_SPURIOUS; | ||
177 | + int el = arm_current_el(env); | ||
178 | |||
179 | if (idx == HPPVI_INDEX_VLPI) { | ||
180 | if (cs->hppvlpi.grp == grp && icv_hppvlpi_can_preempt(cs)) { | ||
181 | @@ -XXX,XX +XXX,XX @@ static uint64_t icv_iar_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
182 | } else if (idx >= 0) { | ||
183 | uint64_t lr = cs->ich_lr_el2[idx]; | ||
184 | int thisgrp = (lr & ICH_LR_EL2_GROUP) ? GICV3_G1NS : GICV3_G0; | ||
185 | + bool nmi = env->cp15.sctlr_el[el] & SCTLR_NMI && lr & ICH_LR_EL2_NMI; | ||
186 | |||
187 | if (thisgrp == grp && icv_hppi_can_preempt(cs, lr)) { | ||
188 | intid = ich_lr_vintid(lr); | ||
189 | if (!gicv3_intid_is_special(intid)) { | ||
190 | - icv_activate_irq(cs, idx, grp); | ||
191 | + if (!nmi) { | ||
192 | + icv_activate_irq(cs, idx, grp); | ||
193 | + } else { | ||
194 | + intid = INTID_NMI; | ||
195 | + } | ||
196 | } else { | ||
197 | /* Interrupt goes from Pending to Invalid */ | ||
198 | cs->ich_lr_el2[idx] &= ~ICH_LR_EL2_STATE_PENDING_BIT; | ||
199 | @@ -XXX,XX +XXX,XX @@ static uint64_t icv_iar_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
200 | |||
201 | static uint64_t icv_nmiar1_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
202 | { | ||
203 | - /* todo */ | ||
204 | + GICv3CPUState *cs = icc_cs_from_env(env); | ||
205 | + int idx = hppvi_index(cs); | ||
206 | uint64_t intid = INTID_SPURIOUS; | ||
207 | + | ||
208 | + if (idx >= 0 && idx != HPPVI_INDEX_VLPI) { | ||
209 | + uint64_t lr = cs->ich_lr_el2[idx]; | ||
210 | + int thisgrp = (lr & ICH_LR_EL2_GROUP) ? GICV3_G1NS : GICV3_G0; | ||
211 | + | ||
212 | + if ((thisgrp == GICV3_G1NS) && icv_hppi_can_preempt(cs, lr)) { | ||
213 | + intid = ich_lr_vintid(lr); | ||
214 | + if (!gicv3_intid_is_special(intid)) { | ||
215 | + if (lr & ICH_LR_EL2_NMI) { | ||
216 | + icv_activate_irq(cs, idx, GICV3_G1NS); | ||
217 | + } else { | ||
218 | + intid = INTID_SPURIOUS; | ||
219 | + } | ||
220 | + } else { | ||
221 | + /* Interrupt goes from Pending to Invalid */ | ||
222 | + cs->ich_lr_el2[idx] &= ~ICH_LR_EL2_STATE_PENDING_BIT; | ||
223 | + /* | ||
224 | + * We will now return the (bogus) ID from the list register, | ||
225 | + * as per the pseudocode. | ||
226 | + */ | ||
227 | + } | ||
228 | + } | ||
229 | + } | ||
230 | + | ||
231 | + trace_gicv3_icv_nmiar1_read(gicv3_redist_affid(cs), intid); | ||
232 | + | ||
233 | + gicv3_cpuif_virt_update(cs); | ||
234 | + | ||
235 | return intid; | ||
236 | } | ||
237 | |||
238 | @@ -XXX,XX +XXX,XX @@ static void icv_increment_eoicount(GICv3CPUState *cs) | ||
239 | ICH_HCR_EL2_EOICOUNT_LENGTH, eoicount + 1); | ||
240 | } | ||
241 | |||
242 | -static int icv_drop_prio(GICv3CPUState *cs) | ||
243 | +static int icv_drop_prio(GICv3CPUState *cs, bool *nmi) | ||
244 | { | ||
245 | /* Drop the priority of the currently active virtual interrupt | ||
246 | * (favouring group 0 if there is a set active bit at | ||
247 | @@ -XXX,XX +XXX,XX @@ static int icv_drop_prio(GICv3CPUState *cs) | ||
248 | continue; | ||
249 | } | ||
250 | |||
251 | + if (i == 0 && cs->nmi_support && (*papr1 & ICV_AP1R_EL1_NMI)) { | ||
252 | + *papr1 &= (~ICV_AP1R_EL1_NMI); | ||
253 | + *nmi = true; | ||
254 | + return 0xff; | ||
255 | + } | ||
256 | + | ||
257 | /* We can't just use the bit-twiddling hack icc_drop_prio() does | ||
258 | * because we need to return the bit number we cleared so | ||
259 | * it can be compared against the list register's priority field. | ||
260 | @@ -XXX,XX +XXX,XX @@ static void icv_eoir_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
261 | int irq = value & 0xffffff; | ||
262 | int grp = ri->crm == 8 ? GICV3_G0 : GICV3_G1NS; | ||
263 | int idx, dropprio; | ||
264 | + bool nmi = false; | ||
265 | |||
266 | trace_gicv3_icv_eoir_write(ri->crm == 8 ? 0 : 1, | ||
267 | gicv3_redist_affid(cs), value); | ||
268 | @@ -XXX,XX +XXX,XX @@ static void icv_eoir_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
269 | * error checks" (because that lets us avoid scanning the AP | ||
270 | * registers twice). | ||
271 | */ | ||
272 | - dropprio = icv_drop_prio(cs); | ||
273 | - if (dropprio == 0xff) { | ||
274 | + dropprio = icv_drop_prio(cs, &nmi); | ||
275 | + if (dropprio == 0xff && !nmi) { | ||
276 | /* No active interrupt. It is CONSTRAINED UNPREDICTABLE | ||
277 | * whether the list registers are checked in this | ||
278 | * situation; we choose not to. | ||
279 | @@ -XXX,XX +XXX,XX @@ static void icv_eoir_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
280 | uint64_t lr = cs->ich_lr_el2[idx]; | ||
281 | int thisgrp = (lr & ICH_LR_EL2_GROUP) ? GICV3_G1NS : GICV3_G0; | ||
282 | int lr_gprio = ich_lr_prio(lr) & icv_gprio_mask(cs, grp); | ||
283 | + bool thisnmi = lr & ICH_LR_EL2_NMI; | ||
284 | |||
285 | - if (thisgrp == grp && lr_gprio == dropprio) { | ||
286 | + if (thisgrp == grp && (lr_gprio == dropprio || (thisnmi & nmi))) { | ||
287 | if (!icv_eoi_split(env, cs) || irq >= GICV3_LPI_INTID_START) { | ||
288 | /* | ||
289 | * Priority drop and deactivate not split: deactivate irq now. | ||
290 | @@ -XXX,XX +XXX,XX @@ static void ich_ap_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
291 | |||
292 | trace_gicv3_ich_ap_write(ri->crm & 1, regno, gicv3_redist_affid(cs), value); | ||
293 | |||
294 | - cs->ich_apr[grp][regno] = value & 0xFFFFFFFFU; | ||
295 | + if (cs->nmi_support) { | ||
296 | + cs->ich_apr[grp][regno] = value & (0xFFFFFFFFU | ICV_AP1R_EL1_NMI); | ||
297 | + } else { | ||
298 | + cs->ich_apr[grp][regno] = value & 0xFFFFFFFFU; | ||
299 | + } | ||
300 | gicv3_cpuif_virt_irq_fiq_update(cs); | ||
301 | } | ||
302 | |||
303 | @@ -XXX,XX +XXX,XX @@ static void ich_lr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
304 | 8 - cs->vpribits, 0); | ||
333 | } | 305 | } |
334 | 306 | ||
335 | /* | 307 | + /* Enforce RES0 bit in NMI field when FEAT_GICv3_NMI is not implemented */ |
336 | - * I2C | 308 | + if (!cs->nmi_support) { |
337 | + * I2Cs | 309 | + value &= ~ICH_LR_EL2_NMI; |
338 | */ | 310 | + } |
339 | for (i = 0; i < FSL_IMX6UL_NUM_I2CS; i++) { | 311 | + |
340 | snprintf(name, NAME_SIZE, "i2c%d", i + 1); | 312 | cs->ich_lr_el2[regno] = value; |
341 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | 313 | gicv3_cpuif_virt_update(cs); |
342 | } | 314 | } |
343 | 315 | diff --git a/hw/intc/trace-events b/hw/intc/trace-events | |
344 | /* | 316 | index XXXXXXX..XXXXXXX 100644 |
345 | - * UART | 317 | --- a/hw/intc/trace-events |
346 | + * UARTs | 318 | +++ b/hw/intc/trace-events |
347 | */ | 319 | @@ -XXX,XX +XXX,XX @@ gicv3_icv_rpr_read(uint32_t cpu, uint64_t val) "GICv3 ICV_RPR read cpu 0x%x valu |
348 | for (i = 0; i < FSL_IMX6UL_NUM_UARTS; i++) { | 320 | gicv3_icv_hppir_read(int grp, uint32_t cpu, uint64_t val) "GICv3 ICV_HPPIR%d read cpu 0x%x value 0x%" PRIx64 |
349 | snprintf(name, NAME_SIZE, "uart%d", i); | 321 | gicv3_icv_dir_write(uint32_t cpu, uint64_t val) "GICv3 ICV_DIR write cpu 0x%x value 0x%" PRIx64 |
350 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | 322 | gicv3_icv_iar_read(int grp, uint32_t cpu, uint64_t val) "GICv3 ICV_IAR%d read cpu 0x%x value 0x%" PRIx64 |
351 | } | 323 | +gicv3_icv_nmiar1_read(uint32_t cpu, uint64_t val) "GICv3 ICV_NMIAR1 read cpu 0x%x value 0x%" PRIx64 |
352 | 324 | gicv3_icv_eoir_write(int grp, uint32_t cpu, uint64_t val) "GICv3 ICV_EOIR%d write cpu 0x%x value 0x%" PRIx64 | |
353 | /* | 325 | gicv3_cpuif_virt_update(uint32_t cpuid, int idx, int hppvlpi, int grp, int prio) "GICv3 CPU i/f 0x%x virt HPPI update LR index %d HPPVLPI %d grp %d prio %d" |
354 | - * Ethernet | 326 | gicv3_cpuif_virt_set_irqs(uint32_t cpuid, int fiqlevel, int irqlevel) "GICv3 CPU i/f 0x%x virt HPPI update: setting FIQ %d IRQ %d" |
355 | + * Ethernets | ||
356 | */ | ||
357 | for (i = 0; i < FSL_IMX6UL_NUM_ETHS; i++) { | ||
358 | snprintf(name, NAME_SIZE, "eth%d", i); | ||
359 | object_initialize_child(obj, name, &s->eth[i], TYPE_IMX_ENET); | ||
360 | } | ||
361 | |||
362 | - /* USB */ | ||
363 | + /* | ||
364 | + * USB PHYs | ||
365 | + */ | ||
366 | for (i = 0; i < FSL_IMX6UL_NUM_USB_PHYS; i++) { | ||
367 | snprintf(name, NAME_SIZE, "usbphy%d", i); | ||
368 | object_initialize_child(obj, name, &s->usbphy[i], TYPE_IMX_USBPHY); | ||
369 | } | ||
370 | + | ||
371 | + /* | ||
372 | + * USBs | ||
373 | + */ | ||
374 | for (i = 0; i < FSL_IMX6UL_NUM_USBS; i++) { | ||
375 | snprintf(name, NAME_SIZE, "usb%d", i); | ||
376 | object_initialize_child(obj, name, &s->usb[i], TYPE_CHIPIDEA); | ||
377 | } | ||
378 | |||
379 | /* | ||
380 | - * SDHCI | ||
381 | + * SDHCIs | ||
382 | */ | ||
383 | for (i = 0; i < FSL_IMX6UL_NUM_USDHCS; i++) { | ||
384 | snprintf(name, NAME_SIZE, "usdhc%d", i); | ||
385 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | ||
386 | } | ||
387 | |||
388 | /* | ||
389 | - * Watchdog | ||
390 | + * Watchdogs | ||
391 | */ | ||
392 | for (i = 0; i < FSL_IMX6UL_NUM_WDTS; i++) { | ||
393 | snprintf(name, NAME_SIZE, "wdt%d", i); | ||
394 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
395 | * A7MPCORE DAP | ||
396 | */ | ||
397 | create_unimplemented_device("a7mpcore-dap", FSL_IMX6UL_A7MPCORE_DAP_ADDR, | ||
398 | - 0x100000); | ||
399 | + FSL_IMX6UL_A7MPCORE_DAP_SIZE); | ||
400 | |||
401 | /* | ||
402 | - * GPT 1, 2 | ||
403 | + * GPTs | ||
404 | */ | ||
405 | for (i = 0; i < FSL_IMX6UL_NUM_GPTS; i++) { | ||
406 | static const hwaddr FSL_IMX6UL_GPTn_ADDR[FSL_IMX6UL_NUM_GPTS] = { | ||
407 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
408 | } | ||
409 | |||
410 | /* | ||
411 | - * EPIT 1, 2 | ||
412 | + * EPITs | ||
413 | */ | ||
414 | for (i = 0; i < FSL_IMX6UL_NUM_EPITS; i++) { | ||
415 | static const hwaddr FSL_IMX6UL_EPITn_ADDR[FSL_IMX6UL_NUM_EPITS] = { | ||
416 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
417 | } | ||
418 | |||
419 | /* | ||
420 | - * GPIO | ||
421 | + * GPIOs | ||
422 | */ | ||
423 | for (i = 0; i < FSL_IMX6UL_NUM_GPIOS; i++) { | ||
424 | static const hwaddr FSL_IMX6UL_GPIOn_ADDR[FSL_IMX6UL_NUM_GPIOS] = { | ||
425 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
426 | } | ||
427 | |||
428 | /* | ||
429 | - * IOMUXC and IOMUXC_GPR | ||
430 | + * IOMUXC | ||
431 | */ | ||
432 | - for (i = 0; i < 1; i++) { | ||
433 | - static const hwaddr FSL_IMX6UL_IOMUXCn_ADDR[FSL_IMX6UL_NUM_IOMUXCS] = { | ||
434 | - FSL_IMX6UL_IOMUXC_ADDR, | ||
435 | - FSL_IMX6UL_IOMUXC_GPR_ADDR, | ||
436 | - }; | ||
437 | - | ||
438 | - snprintf(name, NAME_SIZE, "iomuxc%d", i); | ||
439 | - create_unimplemented_device(name, FSL_IMX6UL_IOMUXCn_ADDR[i], 0x4000); | ||
440 | - } | ||
441 | + create_unimplemented_device("iomuxc", FSL_IMX6UL_IOMUXC_ADDR, | ||
442 | + FSL_IMX6UL_IOMUXC_SIZE); | ||
443 | + create_unimplemented_device("iomuxc_gpr", FSL_IMX6UL_IOMUXC_GPR_ADDR, | ||
444 | + FSL_IMX6UL_IOMUXC_GPR_SIZE); | ||
445 | |||
446 | /* | ||
447 | * CCM | ||
448 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
449 | sysbus_realize(SYS_BUS_DEVICE(&s->gpcv2), &error_abort); | ||
450 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpcv2), 0, FSL_IMX6UL_GPC_ADDR); | ||
451 | |||
452 | - /* Initialize all ECSPI */ | ||
453 | + /* | ||
454 | + * ECSPIs | ||
455 | + */ | ||
456 | for (i = 0; i < FSL_IMX6UL_NUM_ECSPIS; i++) { | ||
457 | static const hwaddr FSL_IMX6UL_SPIn_ADDR[FSL_IMX6UL_NUM_ECSPIS] = { | ||
458 | FSL_IMX6UL_ECSPI1_ADDR, | ||
459 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
460 | } | ||
461 | |||
462 | /* | ||
463 | - * I2C | ||
464 | + * I2Cs | ||
465 | */ | ||
466 | for (i = 0; i < FSL_IMX6UL_NUM_I2CS; i++) { | ||
467 | static const hwaddr FSL_IMX6UL_I2Cn_ADDR[FSL_IMX6UL_NUM_I2CS] = { | ||
468 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
469 | } | ||
470 | |||
471 | /* | ||
472 | - * UART | ||
473 | + * UARTs | ||
474 | */ | ||
475 | for (i = 0; i < FSL_IMX6UL_NUM_UARTS; i++) { | ||
476 | static const hwaddr FSL_IMX6UL_UARTn_ADDR[FSL_IMX6UL_NUM_UARTS] = { | ||
477 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
478 | } | ||
479 | |||
480 | /* | ||
481 | - * Ethernet | ||
482 | + * Ethernets | ||
483 | * | ||
484 | * We must use two loops since phy_connected affects the other interface | ||
485 | * and we have to set all properties before calling sysbus_realize(). | ||
486 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
487 | FSL_IMX6UL_ENETn_TIMER_IRQ[i])); | ||
488 | } | ||
489 | |||
490 | - /* USB */ | ||
491 | + /* | ||
492 | + * USB PHYs | ||
493 | + */ | ||
494 | for (i = 0; i < FSL_IMX6UL_NUM_USB_PHYS; i++) { | ||
495 | + static const hwaddr | ||
496 | + FSL_IMX6UL_USB_PHYn_ADDR[FSL_IMX6UL_NUM_USB_PHYS] = { | ||
497 | + FSL_IMX6UL_USBPHY1_ADDR, | ||
498 | + FSL_IMX6UL_USBPHY2_ADDR, | ||
499 | + }; | ||
500 | + | ||
501 | sysbus_realize(SYS_BUS_DEVICE(&s->usbphy[i]), &error_abort); | ||
502 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->usbphy[i]), 0, | ||
503 | - FSL_IMX6UL_USBPHY1_ADDR + i * 0x1000); | ||
504 | + FSL_IMX6UL_USB_PHYn_ADDR[i]); | ||
505 | } | ||
506 | |||
507 | + /* | ||
508 | + * USBs | ||
509 | + */ | ||
510 | for (i = 0; i < FSL_IMX6UL_NUM_USBS; i++) { | ||
511 | + static const hwaddr FSL_IMX6UL_USB02_USBn_ADDR[FSL_IMX6UL_NUM_USBS] = { | ||
512 | + FSL_IMX6UL_USBO2_USB1_ADDR, | ||
513 | + FSL_IMX6UL_USBO2_USB2_ADDR, | ||
514 | + }; | ||
515 | + | ||
516 | static const int FSL_IMX6UL_USBn_IRQ[] = { | ||
517 | FSL_IMX6UL_USB1_IRQ, | ||
518 | FSL_IMX6UL_USB2_IRQ, | ||
519 | }; | ||
520 | + | ||
521 | sysbus_realize(SYS_BUS_DEVICE(&s->usb[i]), &error_abort); | ||
522 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->usb[i]), 0, | ||
523 | - FSL_IMX6UL_USBO2_USB_ADDR + i * 0x200); | ||
524 | + FSL_IMX6UL_USB02_USBn_ADDR[i]); | ||
525 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->usb[i]), 0, | ||
526 | qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
527 | FSL_IMX6UL_USBn_IRQ[i])); | ||
528 | } | ||
529 | |||
530 | /* | ||
531 | - * USDHC | ||
532 | + * USDHCs | ||
533 | */ | ||
534 | for (i = 0; i < FSL_IMX6UL_NUM_USDHCS; i++) { | ||
535 | static const hwaddr FSL_IMX6UL_USDHCn_ADDR[FSL_IMX6UL_NUM_USDHCS] = { | ||
536 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
537 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->snvs), 0, FSL_IMX6UL_SNVS_HP_ADDR); | ||
538 | |||
539 | /* | ||
540 | - * Watchdog | ||
541 | + * Watchdogs | ||
542 | */ | ||
543 | for (i = 0; i < FSL_IMX6UL_NUM_WDTS; i++) { | ||
544 | static const hwaddr FSL_IMX6UL_WDOGn_ADDR[FSL_IMX6UL_NUM_WDTS] = { | ||
545 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
546 | FSL_IMX6UL_WDOG2_ADDR, | ||
547 | FSL_IMX6UL_WDOG3_ADDR, | ||
548 | }; | ||
549 | + | ||
550 | static const int FSL_IMX6UL_WDOGn_IRQ[FSL_IMX6UL_NUM_WDTS] = { | ||
551 | FSL_IMX6UL_WDOG1_IRQ, | ||
552 | FSL_IMX6UL_WDOG2_IRQ, | ||
553 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
554 | /* | ||
555 | * SDMA | ||
556 | */ | ||
557 | - create_unimplemented_device("sdma", FSL_IMX6UL_SDMA_ADDR, 0x4000); | ||
558 | + create_unimplemented_device("sdma", FSL_IMX6UL_SDMA_ADDR, | ||
559 | + FSL_IMX6UL_SDMA_SIZE); | ||
560 | |||
561 | /* | ||
562 | - * SAI (Audio SSI (Synchronous Serial Interface)) | ||
563 | + * SAIs (Audio SSI (Synchronous Serial Interface)) | ||
564 | */ | ||
565 | - create_unimplemented_device("sai1", FSL_IMX6UL_SAI1_ADDR, 0x4000); | ||
566 | - create_unimplemented_device("sai2", FSL_IMX6UL_SAI2_ADDR, 0x4000); | ||
567 | - create_unimplemented_device("sai3", FSL_IMX6UL_SAI3_ADDR, 0x4000); | ||
568 | + for (i = 0; i < FSL_IMX6UL_NUM_SAIS; i++) { | ||
569 | + static const hwaddr FSL_IMX6UL_SAIn_ADDR[FSL_IMX6UL_NUM_SAIS] = { | ||
570 | + FSL_IMX6UL_SAI1_ADDR, | ||
571 | + FSL_IMX6UL_SAI2_ADDR, | ||
572 | + FSL_IMX6UL_SAI3_ADDR, | ||
573 | + }; | ||
574 | + | ||
575 | + snprintf(name, NAME_SIZE, "sai%d", i); | ||
576 | + create_unimplemented_device(name, FSL_IMX6UL_SAIn_ADDR[i], | ||
577 | + FSL_IMX6UL_SAIn_SIZE); | ||
578 | + } | ||
579 | |||
580 | /* | ||
581 | - * PWM | ||
582 | + * PWMs | ||
583 | */ | ||
584 | - create_unimplemented_device("pwm1", FSL_IMX6UL_PWM1_ADDR, 0x4000); | ||
585 | - create_unimplemented_device("pwm2", FSL_IMX6UL_PWM2_ADDR, 0x4000); | ||
586 | - create_unimplemented_device("pwm3", FSL_IMX6UL_PWM3_ADDR, 0x4000); | ||
587 | - create_unimplemented_device("pwm4", FSL_IMX6UL_PWM4_ADDR, 0x4000); | ||
588 | + for (i = 0; i < FSL_IMX6UL_NUM_PWMS; i++) { | ||
589 | + static const hwaddr FSL_IMX6UL_PWMn_ADDR[FSL_IMX6UL_NUM_PWMS] = { | ||
590 | + FSL_IMX6UL_PWM1_ADDR, | ||
591 | + FSL_IMX6UL_PWM2_ADDR, | ||
592 | + FSL_IMX6UL_PWM3_ADDR, | ||
593 | + FSL_IMX6UL_PWM4_ADDR, | ||
594 | + }; | ||
595 | + | ||
596 | + snprintf(name, NAME_SIZE, "pwm%d", i); | ||
597 | + create_unimplemented_device(name, FSL_IMX6UL_PWMn_ADDR[i], | ||
598 | + FSL_IMX6UL_PWMn_SIZE); | ||
599 | + } | ||
600 | |||
601 | /* | ||
602 | * Audio ASRC (asynchronous sample rate converter) | ||
603 | */ | ||
604 | - create_unimplemented_device("asrc", FSL_IMX6UL_ASRC_ADDR, 0x4000); | ||
605 | + create_unimplemented_device("asrc", FSL_IMX6UL_ASRC_ADDR, | ||
606 | + FSL_IMX6UL_ASRC_SIZE); | ||
607 | |||
608 | /* | ||
609 | - * CAN | ||
610 | + * CANs | ||
611 | */ | ||
612 | - create_unimplemented_device("can1", FSL_IMX6UL_CAN1_ADDR, 0x4000); | ||
613 | - create_unimplemented_device("can2", FSL_IMX6UL_CAN2_ADDR, 0x4000); | ||
614 | + for (i = 0; i < FSL_IMX6UL_NUM_CANS; i++) { | ||
615 | + static const hwaddr FSL_IMX6UL_CANn_ADDR[FSL_IMX6UL_NUM_CANS] = { | ||
616 | + FSL_IMX6UL_CAN1_ADDR, | ||
617 | + FSL_IMX6UL_CAN2_ADDR, | ||
618 | + }; | ||
619 | + | ||
620 | + snprintf(name, NAME_SIZE, "can%d", i); | ||
621 | + create_unimplemented_device(name, FSL_IMX6UL_CANn_ADDR[i], | ||
622 | + FSL_IMX6UL_CANn_SIZE); | ||
623 | + } | ||
624 | |||
625 | /* | ||
626 | * APHB_DMA | ||
627 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
628 | }; | ||
629 | |||
630 | snprintf(name, NAME_SIZE, "adc%d", i); | ||
631 | - create_unimplemented_device(name, FSL_IMX6UL_ADCn_ADDR[i], 0x4000); | ||
632 | + create_unimplemented_device(name, FSL_IMX6UL_ADCn_ADDR[i], | ||
633 | + FSL_IMX6UL_ADCn_SIZE); | ||
634 | } | ||
635 | |||
636 | /* | ||
637 | * LCD | ||
638 | */ | ||
639 | - create_unimplemented_device("lcdif", FSL_IMX6UL_LCDIF_ADDR, 0x4000); | ||
640 | + create_unimplemented_device("lcdif", FSL_IMX6UL_LCDIF_ADDR, | ||
641 | + FSL_IMX6UL_LCDIF_SIZE); | ||
642 | |||
643 | /* | ||
644 | * ROM memory | ||
645 | -- | 327 | -- |
646 | 2.34.1 | 328 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Jinjie Ruan <ruanjinjie@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | Support all of the easy GM block sizes. | 3 | If GICD_CTLR_DS bit is zero and the NMI is non-secure, the NMI priority is |
4 | Use direct memory operations, since the pointers are aligned. | 4 | higher than 0x80, otherwise it is higher than 0x0. And save the interrupt |
5 | non-maskable property in hppi.nmi to deliver NMI exception. Since both GICR | ||
6 | and GICD can deliver NMI, it is both necessary to check whether the pending | ||
7 | irq is NMI in gicv3_redist_update_noirqset and gicv3_update_noirqset. | ||
5 | 8 | ||
6 | While BS=2 (16 bytes, 1 tag) is a legal setting, that requires | 9 | Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> |
7 | an atomic store of one nibble. This is not difficult, but there | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | is also no point in supporting it until required. | ||
9 | |||
10 | Note that cortex-a710 sets GM blocksize to match its cacheline | ||
11 | size of 64 bytes. I expect many implementations will also | ||
12 | match the cacheline, which makes 16 bytes very unlikely. | ||
13 | |||
14 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
16 | Message-id: 20230811214031.171020-4-richard.henderson@linaro.org | 12 | Message-id: 20240407081733.3231820-21-ruanjinjie@huawei.com |
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | --- | 14 | --- |
19 | target/arm/cpu.c | 18 +++++++++--- | 15 | hw/intc/arm_gicv3.c | 67 +++++++++++++++++++++++++++++++++----- |
20 | target/arm/tcg/mte_helper.c | 56 +++++++++++++++++++++++++++++++------ | 16 | hw/intc/arm_gicv3_common.c | 3 ++ |
21 | 2 files changed, 62 insertions(+), 12 deletions(-) | 17 | hw/intc/arm_gicv3_redist.c | 3 ++ |
18 | 3 files changed, 64 insertions(+), 9 deletions(-) | ||
22 | 19 | ||
23 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 20 | diff --git a/hw/intc/arm_gicv3.c b/hw/intc/arm_gicv3.c |
24 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/target/arm/cpu.c | 22 | --- a/hw/intc/arm_gicv3.c |
26 | +++ b/target/arm/cpu.c | 23 | +++ b/hw/intc/arm_gicv3.c |
27 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | 24 | @@ -XXX,XX +XXX,XX @@ |
28 | ID_PFR1, VIRTUALIZATION, 0); | 25 | #include "hw/intc/arm_gicv3.h" |
29 | } | 26 | #include "gicv3_internal.h" |
30 | 27 | ||
31 | + if (cpu_isar_feature(aa64_mte, cpu)) { | 28 | -static bool irqbetter(GICv3CPUState *cs, int irq, uint8_t prio) |
32 | + /* | 29 | +static bool irqbetter(GICv3CPUState *cs, int irq, uint8_t prio, bool nmi) |
33 | + * The architectural range of GM blocksize is 2-6, however qemu | 30 | { |
34 | + * doesn't support blocksize of 2 (see HELPER(ldgm)). | 31 | /* Return true if this IRQ at this priority should take |
35 | + */ | 32 | * precedence over the current recorded highest priority |
36 | + if (tcg_enabled()) { | 33 | @@ -XXX,XX +XXX,XX @@ static bool irqbetter(GICv3CPUState *cs, int irq, uint8_t prio) |
37 | + assert(cpu->gm_blocksize >= 3 && cpu->gm_blocksize <= 6); | 34 | * is the same as this one (a property which the calling code |
35 | * relies on). | ||
36 | */ | ||
37 | - if (prio < cs->hppi.prio) { | ||
38 | - return true; | ||
39 | + if (prio != cs->hppi.prio) { | ||
40 | + return prio < cs->hppi.prio; | ||
41 | } | ||
42 | + | ||
43 | + /* | ||
44 | + * The same priority IRQ with non-maskable property should signal to | ||
45 | + * the CPU as it have the priority higher than the labelled 0x80 or 0x00. | ||
46 | + */ | ||
47 | + if (nmi != cs->hppi.nmi) { | ||
48 | + return nmi; | ||
49 | + } | ||
50 | + | ||
51 | /* If multiple pending interrupts have the same priority then it is an | ||
52 | * IMPDEF choice which of them to signal to the CPU. We choose to | ||
53 | * signal the one with the lowest interrupt number. | ||
54 | */ | ||
55 | - if (prio == cs->hppi.prio && irq <= cs->hppi.irq) { | ||
56 | + if (irq <= cs->hppi.irq) { | ||
57 | return true; | ||
58 | } | ||
59 | return false; | ||
60 | @@ -XXX,XX +XXX,XX @@ static uint32_t gicr_int_pending(GICv3CPUState *cs) | ||
61 | return pend; | ||
62 | } | ||
63 | |||
64 | +static bool gicv3_get_priority(GICv3CPUState *cs, bool is_redist, int irq, | ||
65 | + uint8_t *prio) | ||
66 | +{ | ||
67 | + uint32_t nmi = 0x0; | ||
68 | + | ||
69 | + if (is_redist) { | ||
70 | + nmi = extract32(cs->gicr_inmir0, irq, 1); | ||
71 | + } else { | ||
72 | + nmi = *gic_bmp_ptr32(cs->gic->nmi, irq); | ||
73 | + nmi = nmi & (1 << (irq & 0x1f)); | ||
74 | + } | ||
75 | + | ||
76 | + if (nmi) { | ||
77 | + /* DS = 0 & Non-secure NMI */ | ||
78 | + if (!(cs->gic->gicd_ctlr & GICD_CTLR_DS) && | ||
79 | + ((is_redist && extract32(cs->gicr_igroupr0, irq, 1)) || | ||
80 | + (!is_redist && gicv3_gicd_group_test(cs->gic, irq)))) { | ||
81 | + *prio = 0x80; | ||
82 | + } else { | ||
83 | + *prio = 0x0; | ||
38 | + } | 84 | + } |
39 | + | 85 | + |
40 | #ifndef CONFIG_USER_ONLY | 86 | + return true; |
41 | - if (cpu->tag_memory == NULL && cpu_isar_feature(aa64_mte, cpu)) { | 87 | + } |
42 | /* | 88 | + |
43 | * Disable the MTE feature bits if we do not have tag-memory | 89 | + if (is_redist) { |
44 | * provided by the machine. | 90 | + *prio = cs->gicr_ipriorityr[irq]; |
45 | */ | 91 | + } else { |
46 | - cpu->isar.id_aa64pfr1 = | 92 | + *prio = cs->gic->gicd_ipriority[irq]; |
47 | - FIELD_DP64(cpu->isar.id_aa64pfr1, ID_AA64PFR1, MTE, 0); | 93 | + } |
48 | - } | 94 | + |
49 | + if (cpu->tag_memory == NULL) { | 95 | + return false; |
50 | + cpu->isar.id_aa64pfr1 = | 96 | +} |
51 | + FIELD_DP64(cpu->isar.id_aa64pfr1, ID_AA64PFR1, MTE, 0); | 97 | + |
52 | + } | 98 | /* Update the interrupt status after state in a redistributor |
53 | #endif | 99 | * or CPU interface has changed, but don't tell the CPU i/f. |
54 | + } | 100 | */ |
55 | 101 | @@ -XXX,XX +XXX,XX @@ static void gicv3_redist_update_noirqset(GICv3CPUState *cs) | |
56 | if (tcg_enabled()) { | 102 | uint8_t prio; |
57 | /* | 103 | int i; |
58 | diff --git a/target/arm/tcg/mte_helper.c b/target/arm/tcg/mte_helper.c | 104 | uint32_t pend; |
105 | + bool nmi = false; | ||
106 | |||
107 | /* Find out which redistributor interrupts are eligible to be | ||
108 | * signaled to the CPU interface. | ||
109 | @@ -XXX,XX +XXX,XX @@ static void gicv3_redist_update_noirqset(GICv3CPUState *cs) | ||
110 | if (!(pend & (1 << i))) { | ||
111 | continue; | ||
112 | } | ||
113 | - prio = cs->gicr_ipriorityr[i]; | ||
114 | - if (irqbetter(cs, i, prio)) { | ||
115 | + nmi = gicv3_get_priority(cs, true, i, &prio); | ||
116 | + if (irqbetter(cs, i, prio, nmi)) { | ||
117 | cs->hppi.irq = i; | ||
118 | cs->hppi.prio = prio; | ||
119 | + cs->hppi.nmi = nmi; | ||
120 | seenbetter = true; | ||
121 | } | ||
122 | } | ||
123 | @@ -XXX,XX +XXX,XX @@ static void gicv3_redist_update_noirqset(GICv3CPUState *cs) | ||
124 | if ((cs->gicr_ctlr & GICR_CTLR_ENABLE_LPIS) && cs->gic->lpi_enable && | ||
125 | (cs->gic->gicd_ctlr & GICD_CTLR_EN_GRP1NS) && | ||
126 | (cs->hpplpi.prio != 0xff)) { | ||
127 | - if (irqbetter(cs, cs->hpplpi.irq, cs->hpplpi.prio)) { | ||
128 | + if (irqbetter(cs, cs->hpplpi.irq, cs->hpplpi.prio, cs->hpplpi.nmi)) { | ||
129 | cs->hppi.irq = cs->hpplpi.irq; | ||
130 | cs->hppi.prio = cs->hpplpi.prio; | ||
131 | + cs->hppi.nmi = cs->hpplpi.nmi; | ||
132 | cs->hppi.grp = cs->hpplpi.grp; | ||
133 | seenbetter = true; | ||
134 | } | ||
135 | @@ -XXX,XX +XXX,XX @@ static void gicv3_update_noirqset(GICv3State *s, int start, int len) | ||
136 | int i; | ||
137 | uint8_t prio; | ||
138 | uint32_t pend = 0; | ||
139 | + bool nmi = false; | ||
140 | |||
141 | assert(start >= GIC_INTERNAL); | ||
142 | assert(len > 0); | ||
143 | @@ -XXX,XX +XXX,XX @@ static void gicv3_update_noirqset(GICv3State *s, int start, int len) | ||
144 | */ | ||
145 | continue; | ||
146 | } | ||
147 | - prio = s->gicd_ipriority[i]; | ||
148 | - if (irqbetter(cs, i, prio)) { | ||
149 | + nmi = gicv3_get_priority(cs, false, i, &prio); | ||
150 | + if (irqbetter(cs, i, prio, nmi)) { | ||
151 | cs->hppi.irq = i; | ||
152 | cs->hppi.prio = prio; | ||
153 | + cs->hppi.nmi = nmi; | ||
154 | cs->seenbetter = true; | ||
155 | } | ||
156 | } | ||
157 | @@ -XXX,XX +XXX,XX @@ void gicv3_full_update_noirqset(GICv3State *s) | ||
158 | |||
159 | for (i = 0; i < s->num_cpu; i++) { | ||
160 | s->cpu[i].hppi.prio = 0xff; | ||
161 | + s->cpu[i].hppi.nmi = false; | ||
162 | } | ||
163 | |||
164 | /* Note that we can guarantee that these functions will not | ||
165 | diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c | ||
59 | index XXXXXXX..XXXXXXX 100644 | 166 | index XXXXXXX..XXXXXXX 100644 |
60 | --- a/target/arm/tcg/mte_helper.c | 167 | --- a/hw/intc/arm_gicv3_common.c |
61 | +++ b/target/arm/tcg/mte_helper.c | 168 | +++ b/hw/intc/arm_gicv3_common.c |
62 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(ldgm)(CPUARMState *env, uint64_t ptr) | 169 | @@ -XXX,XX +XXX,XX @@ static void arm_gicv3_common_reset_hold(Object *obj) |
63 | int gm_bs = env_archcpu(env)->gm_blocksize; | 170 | memset(cs->gicr_ipriorityr, 0, sizeof(cs->gicr_ipriorityr)); |
64 | int gm_bs_bytes = 4 << gm_bs; | 171 | |
65 | void *tag_mem; | 172 | cs->hppi.prio = 0xff; |
66 | + uint64_t ret; | 173 | + cs->hppi.nmi = false; |
67 | + int shift; | 174 | cs->hpplpi.prio = 0xff; |
68 | 175 | + cs->hpplpi.nmi = false; | |
69 | ptr = QEMU_ALIGN_DOWN(ptr, gm_bs_bytes); | 176 | cs->hppvlpi.prio = 0xff; |
70 | 177 | + cs->hppvlpi.nmi = false; | |
71 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(ldgm)(CPUARMState *env, uint64_t ptr) | 178 | |
72 | 179 | /* State in the CPU interface must *not* be reset here, because it | |
73 | /* | 180 | * is part of the CPU's reset domain, not the GIC device's. |
74 | * The ordering of elements within the word corresponds to | 181 | diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c |
75 | - * a little-endian operation. | 182 | index XXXXXXX..XXXXXXX 100644 |
76 | + * a little-endian operation. Computation of shift comes from | 183 | --- a/hw/intc/arm_gicv3_redist.c |
77 | + * | 184 | +++ b/hw/intc/arm_gicv3_redist.c |
78 | + * index = address<LOG2_TAG_GRANULE+3:LOG2_TAG_GRANULE> | 185 | @@ -XXX,XX +XXX,XX @@ static void update_for_one_lpi(GICv3CPUState *cs, int irq, |
79 | + * data<index*4+3:index*4> = tag | 186 | ((prio == hpp->prio) && (irq <= hpp->irq))) { |
80 | + * | 187 | hpp->irq = irq; |
81 | + * Because of the alignment of ptr above, BS=6 has shift=0. | 188 | hpp->prio = prio; |
82 | + * All memory operations are aligned. Defer support for BS=2, | 189 | + hpp->nmi = false; |
83 | + * requiring insertion or extraction of a nibble, until we | 190 | /* LPIs and vLPIs are always non-secure Grp1 interrupts */ |
84 | + * support a cpu that requires it. | 191 | hpp->grp = GICV3_G1NS; |
85 | */ | 192 | } |
86 | switch (gm_bs) { | 193 | @@ -XXX,XX +XXX,XX @@ static void update_for_all_lpis(GICv3CPUState *cs, uint64_t ptbase, |
87 | + case 3: | 194 | int i, bit; |
88 | + /* 32 bytes -> 2 tags -> 8 result bits */ | 195 | |
89 | + ret = *(uint8_t *)tag_mem; | 196 | hpp->prio = 0xff; |
90 | + break; | 197 | + hpp->nmi = false; |
91 | + case 4: | 198 | |
92 | + /* 64 bytes -> 4 tags -> 16 result bits */ | 199 | for (i = GICV3_LPI_INTID_START / 8; i < pendt_size / 8; i++) { |
93 | + ret = cpu_to_le16(*(uint16_t *)tag_mem); | 200 | address_space_read(as, ptbase + i, MEMTXATTRS_UNSPECIFIED, &pend, 1); |
94 | + break; | 201 | @@ -XXX,XX +XXX,XX @@ static void gicv3_redist_update_vlpi_only(GICv3CPUState *cs) |
95 | + case 5: | 202 | |
96 | + /* 128 bytes -> 8 tags -> 32 result bits */ | 203 | if (!FIELD_EX64(cs->gicr_vpendbaser, GICR_VPENDBASER, VALID)) { |
97 | + ret = cpu_to_le32(*(uint32_t *)tag_mem); | 204 | cs->hppvlpi.prio = 0xff; |
98 | + break; | 205 | + cs->hppvlpi.nmi = false; |
99 | case 6: | ||
100 | /* 256 bytes -> 16 tags -> 64 result bits */ | ||
101 | - return ldq_le_p(tag_mem); | ||
102 | + return cpu_to_le64(*(uint64_t *)tag_mem); | ||
103 | default: | ||
104 | - /* cpu configured with unsupported gm blocksize. */ | ||
105 | + /* | ||
106 | + * CPU configured with unsupported/invalid gm blocksize. | ||
107 | + * This is detected early in arm_cpu_realizefn. | ||
108 | + */ | ||
109 | g_assert_not_reached(); | ||
110 | } | ||
111 | + shift = extract64(ptr, LOG2_TAG_GRANULE, 4) * 4; | ||
112 | + return ret << shift; | ||
113 | } | ||
114 | |||
115 | void HELPER(stgm)(CPUARMState *env, uint64_t ptr, uint64_t val) | ||
116 | @@ -XXX,XX +XXX,XX @@ void HELPER(stgm)(CPUARMState *env, uint64_t ptr, uint64_t val) | ||
117 | int gm_bs = env_archcpu(env)->gm_blocksize; | ||
118 | int gm_bs_bytes = 4 << gm_bs; | ||
119 | void *tag_mem; | ||
120 | + int shift; | ||
121 | |||
122 | ptr = QEMU_ALIGN_DOWN(ptr, gm_bs_bytes); | ||
123 | |||
124 | @@ -XXX,XX +XXX,XX @@ void HELPER(stgm)(CPUARMState *env, uint64_t ptr, uint64_t val) | ||
125 | return; | 206 | return; |
126 | } | 207 | } |
127 | 208 | ||
128 | - /* | ||
129 | - * The ordering of elements within the word corresponds to | ||
130 | - * a little-endian operation. | ||
131 | - */ | ||
132 | + /* See LDGM for comments on BS and on shift. */ | ||
133 | + shift = extract64(ptr, LOG2_TAG_GRANULE, 4) * 4; | ||
134 | + val >>= shift; | ||
135 | switch (gm_bs) { | ||
136 | + case 3: | ||
137 | + /* 32 bytes -> 2 tags -> 8 result bits */ | ||
138 | + *(uint8_t *)tag_mem = val; | ||
139 | + break; | ||
140 | + case 4: | ||
141 | + /* 64 bytes -> 4 tags -> 16 result bits */ | ||
142 | + *(uint16_t *)tag_mem = cpu_to_le16(val); | ||
143 | + break; | ||
144 | + case 5: | ||
145 | + /* 128 bytes -> 8 tags -> 32 result bits */ | ||
146 | + *(uint32_t *)tag_mem = cpu_to_le32(val); | ||
147 | + break; | ||
148 | case 6: | ||
149 | - stq_le_p(tag_mem, val); | ||
150 | + /* 256 bytes -> 16 tags -> 64 result bits */ | ||
151 | + *(uint64_t *)tag_mem = cpu_to_le64(val); | ||
152 | break; | ||
153 | default: | ||
154 | /* cpu configured with unsupported gm blocksize. */ | ||
155 | -- | 209 | -- |
156 | 2.34.1 | 210 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Jinjie Ruan <ruanjinjie@huawei.com> | ||
1 | 2 | ||
3 | In CPU Interface, if the IRQ has the non-maskable property, report NMI to | ||
4 | the corresponding PE. | ||
5 | |||
6 | Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Message-id: 20240407081733.3231820-22-ruanjinjie@huawei.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/intc/arm_gicv3_cpuif.c | 4 ++++ | ||
13 | 1 file changed, 4 insertions(+) | ||
14 | |||
15 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/intc/arm_gicv3_cpuif.c | ||
18 | +++ b/hw/intc/arm_gicv3_cpuif.c | ||
19 | @@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_update(GICv3CPUState *cs) | ||
20 | /* Tell the CPU about its highest priority pending interrupt */ | ||
21 | int irqlevel = 0; | ||
22 | int fiqlevel = 0; | ||
23 | + int nmilevel = 0; | ||
24 | ARMCPU *cpu = ARM_CPU(cs->cpu); | ||
25 | CPUARMState *env = &cpu->env; | ||
26 | |||
27 | @@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_update(GICv3CPUState *cs) | ||
28 | |||
29 | if (isfiq) { | ||
30 | fiqlevel = 1; | ||
31 | + } else if (cs->hppi.nmi) { | ||
32 | + nmilevel = 1; | ||
33 | } else { | ||
34 | irqlevel = 1; | ||
35 | } | ||
36 | @@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_update(GICv3CPUState *cs) | ||
37 | |||
38 | qemu_set_irq(cs->parent_fiq, fiqlevel); | ||
39 | qemu_set_irq(cs->parent_irq, irqlevel); | ||
40 | + qemu_set_irq(cs->parent_nmi, nmilevel); | ||
41 | } | ||
42 | |||
43 | static uint64_t icc_pmr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
44 | -- | ||
45 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Jinjie Ruan <ruanjinjie@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | There is only one additional EL1 register modeled, which | 3 | In vCPU Interface, if the vIRQ has the non-maskable property, report |
4 | also needs to use access_actlr_w. | 4 | vINMI to the corresponding vPE. |
5 | 5 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20230811214031.171020-8-richard.henderson@linaro.org | 9 | Message-id: 20240407081733.3231820-23-ruanjinjie@huawei.com |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 11 | --- |
11 | target/arm/tcg/cpu64.c | 3 ++- | 12 | hw/intc/arm_gicv3_cpuif.c | 14 ++++++++++++-- |
12 | 1 file changed, 2 insertions(+), 1 deletion(-) | 13 | 1 file changed, 12 insertions(+), 2 deletions(-) |
13 | 14 | ||
14 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c | 15 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/tcg/cpu64.c | 17 | --- a/hw/intc/arm_gicv3_cpuif.c |
17 | +++ b/target/arm/tcg/cpu64.c | 18 | +++ b/hw/intc/arm_gicv3_cpuif.c |
18 | @@ -XXX,XX +XXX,XX @@ static void define_neoverse_n1_cp_reginfo(ARMCPU *cpu) | 19 | @@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_virt_irq_fiq_update(GICv3CPUState *cs) |
19 | static const ARMCPRegInfo neoverse_v1_cp_reginfo[] = { | 20 | int idx; |
20 | { .name = "CPUECTLR2_EL1", .state = ARM_CP_STATE_AA64, | 21 | int irqlevel = 0; |
21 | .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 5, | 22 | int fiqlevel = 0; |
22 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | 23 | + int nmilevel = 0; |
23 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, | 24 | |
24 | + .accessfn = access_actlr_w }, | 25 | idx = hppvi_index(cs); |
25 | { .name = "CPUPPMCR_EL3", .state = ARM_CP_STATE_AA64, | 26 | trace_gicv3_cpuif_virt_update(gicv3_redist_affid(cs), idx, |
26 | .opc0 = 3, .opc1 = 6, .crn = 15, .crm = 2, .opc2 = 0, | 27 | @@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_virt_irq_fiq_update(GICv3CPUState *cs) |
27 | .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | 28 | uint64_t lr = cs->ich_lr_el2[idx]; |
29 | |||
30 | if (icv_hppi_can_preempt(cs, lr)) { | ||
31 | - /* Virtual interrupts are simple: G0 are always FIQ, and G1 IRQ */ | ||
32 | + /* | ||
33 | + * Virtual interrupts are simple: G0 are always FIQ, and G1 are | ||
34 | + * IRQ or NMI which depends on the ICH_LR<n>_EL2.NMI to have | ||
35 | + * non-maskable property. | ||
36 | + */ | ||
37 | if (lr & ICH_LR_EL2_GROUP) { | ||
38 | - irqlevel = 1; | ||
39 | + if (lr & ICH_LR_EL2_NMI) { | ||
40 | + nmilevel = 1; | ||
41 | + } else { | ||
42 | + irqlevel = 1; | ||
43 | + } | ||
44 | } else { | ||
45 | fiqlevel = 1; | ||
46 | } | ||
47 | @@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_virt_irq_fiq_update(GICv3CPUState *cs) | ||
48 | trace_gicv3_cpuif_virt_set_irqs(gicv3_redist_affid(cs), fiqlevel, irqlevel); | ||
49 | qemu_set_irq(cs->parent_vfiq, fiqlevel); | ||
50 | qemu_set_irq(cs->parent_virq, irqlevel); | ||
51 | + qemu_set_irq(cs->parent_vnmi, nmilevel); | ||
52 | } | ||
53 | |||
54 | static void gicv3_cpuif_virt_update(GICv3CPUState *cs) | ||
28 | -- | 55 | -- |
29 | 2.34.1 | 56 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Jinjie Ruan <ruanjinjie@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | This feature allows the operating system to set TCR_ELx.HWU* | 3 | Enable FEAT_NMI on the 'max' CPU. |
4 | to allow the implementation to use the PBHA bits from the | ||
5 | block and page descriptors for for IMPLEMENTATION DEFINED | ||
6 | purposes. Since QEMU has no need to use these bits, we may | ||
7 | simply ignore them. | ||
8 | 4 | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Message-id: 20230811214031.171020-11-richard.henderson@linaro.org | 8 | Message-id: 20240407081733.3231820-24-ruanjinjie@huawei.com |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 10 | --- |
14 | docs/system/arm/emulation.rst | 1 + | 11 | docs/system/arm/emulation.rst | 1 + |
15 | target/arm/tcg/cpu32.c | 2 +- | 12 | target/arm/tcg/cpu64.c | 1 + |
16 | target/arm/tcg/cpu64.c | 2 +- | 13 | 2 files changed, 2 insertions(+) |
17 | 3 files changed, 3 insertions(+), 2 deletions(-) | ||
18 | 14 | ||
19 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst | 15 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
20 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/docs/system/arm/emulation.rst | 17 | --- a/docs/system/arm/emulation.rst |
22 | +++ b/docs/system/arm/emulation.rst | 18 | +++ b/docs/system/arm/emulation.rst |
23 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: | 19 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
24 | - FEAT_HAFDBS (Hardware management of the access flag and dirty bit state) | 20 | - FEAT_MTE (Memory Tagging Extension) |
25 | - FEAT_HCX (Support for the HCRX_EL2 register) | 21 | - FEAT_MTE2 (Memory Tagging Extension) |
26 | - FEAT_HPDS (Hierarchical permission disables) | 22 | - FEAT_MTE3 (MTE Asymmetric Fault Handling) |
27 | +- FEAT_HPDS2 (Translation table page-based hardware attributes) | 23 | +- FEAT_NMI (Non-maskable Interrupt) |
28 | - FEAT_I8MM (AArch64 Int8 matrix multiplication instructions) | 24 | - FEAT_NV (Nested Virtualization) |
29 | - FEAT_IDST (ID space trap handling) | 25 | - FEAT_NV2 (Enhanced nested virtualization support) |
30 | - FEAT_IESB (Implicit error synchronization event) | 26 | - FEAT_PACIMP (Pointer authentication - IMPLEMENTATION DEFINED algorithm) |
31 | diff --git a/target/arm/tcg/cpu32.c b/target/arm/tcg/cpu32.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/target/arm/tcg/cpu32.c | ||
34 | +++ b/target/arm/tcg/cpu32.c | ||
35 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) | ||
36 | cpu->isar.id_mmfr3 = t; | ||
37 | |||
38 | t = cpu->isar.id_mmfr4; | ||
39 | - t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* FEAT_AA32HPD */ | ||
40 | + t = FIELD_DP32(t, ID_MMFR4, HPDS, 2); /* FEAT_HPDS2 */ | ||
41 | t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ | ||
42 | t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* FEAT_TTCNP */ | ||
43 | t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* FEAT_XNX */ | ||
44 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c | 27 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c |
45 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
46 | --- a/target/arm/tcg/cpu64.c | 29 | --- a/target/arm/tcg/cpu64.c |
47 | +++ b/target/arm/tcg/cpu64.c | 30 | +++ b/target/arm/tcg/cpu64.c |
48 | @@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj) | 31 | @@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj) |
49 | t = FIELD_DP64(t, ID_AA64MMFR1, HAFDBS, 2); /* FEAT_HAFDBS */ | 32 | t = FIELD_DP64(t, ID_AA64PFR1, RAS_FRAC, 0); /* FEAT_RASv1p1 + FEAT_DoubleFault */ |
50 | t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* FEAT_VMID16 */ | 33 | t = FIELD_DP64(t, ID_AA64PFR1, SME, 1); /* FEAT_SME */ |
51 | t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1); /* FEAT_VHE */ | 34 | t = FIELD_DP64(t, ID_AA64PFR1, CSV2_FRAC, 0); /* FEAT_CSV2_2 */ |
52 | - t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* FEAT_HPDS */ | 35 | + t = FIELD_DP64(t, ID_AA64PFR1, NMI, 1); /* FEAT_NMI */ |
53 | + t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 2); /* FEAT_HPDS2 */ | 36 | cpu->isar.id_aa64pfr1 = t; |
54 | t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1); /* FEAT_LOR */ | 37 | |
55 | t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 3); /* FEAT_PAN3 */ | 38 | t = cpu->isar.id_aa64mmfr0; |
56 | t = FIELD_DP64(t, ID_AA64MMFR1, XNX, 1); /* FEAT_XNX */ | ||
57 | -- | 39 | -- |
58 | 2.34.1 | 40 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Jinjie Ruan <ruanjinjie@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | Do not hard-code the constants for Neoverse V1. | 3 | If the CPU implements FEAT_NMI, then turn on the NMI support in the |
4 | GICv3 too. It's permitted to have a configuration with FEAT_NMI in | ||
5 | the CPU (and thus NMI support in the CPU interfaces too) but no NMI | ||
6 | support in the distributor and redistributor, but this isn't a very | ||
7 | useful setup as it's close to having no NMI support at all. | ||
4 | 8 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | We don't need to gate the enabling of NMI in the GIC behind a |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | machine version property, because none of our current CPUs |
7 | Message-id: 20230811214031.171020-6-richard.henderson@linaro.org | 11 | implement FEAT_NMI, and '-cpu max' is not something we maintain |
12 | migration compatibility across versions for. So we can always | ||
13 | enable the GIC NMI support when the CPU has it. | ||
14 | |||
15 | Neither hvf nor KVM support NMI in the GIC yet, so we don't enable | ||
16 | it unless we're using TCG. | ||
17 | |||
18 | Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> | ||
19 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
20 | Message-id: 20240407081733.3231820-25-ruanjinjie@huawei.com | ||
21 | [PMM: Update comment and commit message] | ||
22 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 24 | --- |
10 | target/arm/tcg/cpu64.c | 48 ++++++++++++++++++++++++++++-------------- | 25 | hw/arm/virt.c | 19 +++++++++++++++++++ |
11 | 1 file changed, 32 insertions(+), 16 deletions(-) | 26 | 1 file changed, 19 insertions(+) |
12 | 27 | ||
13 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c | 28 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
14 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/tcg/cpu64.c | 30 | --- a/hw/arm/virt.c |
16 | +++ b/target/arm/tcg/cpu64.c | 31 | +++ b/hw/arm/virt.c |
17 | @@ -XXX,XX +XXX,XX @@ | 32 | @@ -XXX,XX +XXX,XX @@ static void create_v2m(VirtMachineState *vms) |
18 | #include "qemu/module.h" | 33 | vms->msi_controller = VIRT_MSI_CTRL_GICV2M; |
19 | #include "qapi/visitor.h" | 34 | } |
20 | #include "hw/qdev-properties.h" | 35 | |
21 | +#include "qemu/units.h" | 36 | +/* |
22 | #include "internals.h" | 37 | + * If the CPU has FEAT_NMI, then turn on the NMI support in the GICv3 too. |
23 | #include "cpregs.h" | 38 | + * It's permitted to have a configuration with NMI in the CPU (and thus the |
24 | 39 | + * GICv3 CPU interface) but not in the distributor/redistributors, but it's | |
25 | +static uint64_t make_ccsidr64(unsigned assoc, unsigned linesize, | 40 | + * not very useful. |
26 | + unsigned cachesize) | 41 | + */ |
42 | +static bool gicv3_nmi_present(VirtMachineState *vms) | ||
27 | +{ | 43 | +{ |
28 | + unsigned lg_linesize = ctz32(linesize); | 44 | + ARMCPU *cpu = ARM_CPU(qemu_get_cpu(0)); |
29 | + unsigned sets; | ||
30 | + | 45 | + |
31 | + /* | 46 | + return tcg_enabled() && cpu_isar_feature(aa64_nmi, cpu) && |
32 | + * The 64-bit CCSIDR_EL1 format is: | 47 | + (vms->gic_version != VIRT_GIC_VERSION_2); |
33 | + * [55:32] number of sets - 1 | ||
34 | + * [23:3] associativity - 1 | ||
35 | + * [2:0] log2(linesize) - 4 | ||
36 | + * so 0 == 16 bytes, 1 == 32 bytes, 2 == 64 bytes, etc | ||
37 | + */ | ||
38 | + assert(assoc != 0); | ||
39 | + assert(is_power_of_2(linesize)); | ||
40 | + assert(lg_linesize >= 4 && lg_linesize <= 7 + 4); | ||
41 | + | ||
42 | + /* sets * associativity * linesize == cachesize. */ | ||
43 | + sets = cachesize / (assoc * linesize); | ||
44 | + assert(cachesize % (assoc * linesize) == 0); | ||
45 | + | ||
46 | + return ((uint64_t)(sets - 1) << 32) | ||
47 | + | ((assoc - 1) << 3) | ||
48 | + | (lg_linesize - 4); | ||
49 | +} | 48 | +} |
50 | + | 49 | + |
51 | static void aarch64_a35_initfn(Object *obj) | 50 | static void create_gic(VirtMachineState *vms, MemoryRegion *mem) |
52 | { | 51 | { |
53 | ARMCPU *cpu = ARM_CPU(obj); | 52 | MachineState *ms = MACHINE(vms); |
54 | @@ -XXX,XX +XXX,XX @@ static void aarch64_neoverse_v1_initfn(Object *obj) | 53 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem) |
55 | * The Neoverse-V1 r1p2 TRM lists 32-bit format CCSIDR_EL1 values, | 54 | vms->virt); |
56 | * but also says it implements CCIDX, which means they should be | 55 | } |
57 | * 64-bit format. So we here use values which are based on the textual | 56 | } |
58 | - * information in chapter 2 of the TRM (and on the fact that | 57 | + |
59 | - * sets * associativity * linesize == cachesize). | 58 | + if (gicv3_nmi_present(vms)) { |
60 | - * | 59 | + qdev_prop_set_bit(vms->gic, "has-nmi", true); |
61 | - * The 64-bit CCSIDR_EL1 format is: | 60 | + } |
62 | - * [55:32] number of sets - 1 | 61 | + |
63 | - * [23:3] associativity - 1 | 62 | gicbusdev = SYS_BUS_DEVICE(vms->gic); |
64 | - * [2:0] log2(linesize) - 4 | 63 | sysbus_realize_and_unref(gicbusdev, &error_fatal); |
65 | - * so 0 == 16 bytes, 1 == 32 bytes, 2 == 64 bytes, etc | 64 | sysbus_mmio_map(gicbusdev, 0, vms->memmap[VIRT_GIC_DIST].base); |
66 | - * | ||
67 | - * L1: 4-way set associative 64-byte line size, total size 64K, | ||
68 | - * so sets is 256. | ||
69 | + * information in chapter 2 of the TRM: | ||
70 | * | ||
71 | + * L1: 4-way set associative 64-byte line size, total size 64K. | ||
72 | * L2: 8-way set associative, 64 byte line size, either 512K or 1MB. | ||
73 | - * We pick 1MB, so this has 2048 sets. | ||
74 | - * | ||
75 | * L3: No L3 (this matches the CLIDR_EL1 value). | ||
76 | */ | ||
77 | - cpu->ccsidr[0] = 0x000000ff0000001aull; /* 64KB L1 dcache */ | ||
78 | - cpu->ccsidr[1] = 0x000000ff0000001aull; /* 64KB L1 icache */ | ||
79 | - cpu->ccsidr[2] = 0x000007ff0000003aull; /* 1MB L2 cache */ | ||
80 | + cpu->ccsidr[0] = make_ccsidr64(4, 64, 64 * KiB); /* L1 dcache */ | ||
81 | + cpu->ccsidr[1] = cpu->ccsidr[0]; /* L1 icache */ | ||
82 | + cpu->ccsidr[2] = make_ccsidr64(8, 64, 1 * MiB); /* L2 cache */ | ||
83 | |||
84 | /* From 3.2.115 SCTLR_EL3 */ | ||
85 | cpu->reset_sctlr = 0x30c50838; | ||
86 | -- | 65 | -- |
87 | 2.34.1 | 66 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> | 1 | From: Anastasia Belova <abelova@astralinux.ru> |
---|---|---|---|
2 | 2 | ||
3 | i.MX7 IOMUX GPR device is not equivalent to i.MX6UL IOMUXC GPR device. | 3 | In soc_dma_set_request() we try to set a bit in a uint64_t, but we |
4 | In particular, register 22 is not present on i.MX6UL and this is actualy | 4 | do it with "1 << ch->num", which can't set any bits past 31; |
5 | The only register that is really emulated in the i.MX7 IOMUX GPR device. | 5 | any use for a channel number of 32 or more would fail due to |
6 | integer overflow. | ||
6 | 7 | ||
7 | Note: The i.MX6UL code is actually also implementing the IOMUX GPR device | 8 | This doesn't happen in practice for our current use of this code, |
8 | as an unimplemented device at the same bus adress and the 2 instantiations | 9 | because the worst case is when we call soc_dma_init() with an |
9 | were actualy colliding. So we go back to the unimplemented device for now. | 10 | argument of 32 for the number of channels, and QEMU builds with |
11 | -fwrapv so the shift into the sign bit is well-defined. However, | ||
12 | it's obviously not the intended behaviour of the code. | ||
10 | 13 | ||
11 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> | 14 | Add casts to force the shift to be done as 64-bit arithmetic, |
12 | Message-id: 48681bf51ee97646479bb261bee19abebbc8074e.1692964892.git.jcd@tribudubois.net | 15 | allowing up to 64 channels. |
16 | |||
17 | Found by Linux Verification Center (linuxtesting.org) with SVACE. | ||
18 | |||
19 | Fixes: afbb5194d4 ("Handle on-chip DMA controllers in one place, convert OMAP DMA to use it.") | ||
20 | Signed-off-by: Anastasia Belova <abelova@astralinux.ru> | ||
21 | Message-id: 20240409115301.21829-1-abelova@astralinux.ru | ||
22 | [PMM: Edit commit message to clarify that this doesn't actually | ||
23 | bite us in our current usage of this code.] | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 24 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 25 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 26 | --- |
16 | include/hw/arm/fsl-imx6ul.h | 2 -- | 27 | hw/dma/soc_dma.c | 4 ++-- |
17 | hw/arm/fsl-imx6ul.c | 11 ----------- | 28 | 1 file changed, 2 insertions(+), 2 deletions(-) |
18 | 2 files changed, 13 deletions(-) | ||
19 | 29 | ||
20 | diff --git a/include/hw/arm/fsl-imx6ul.h b/include/hw/arm/fsl-imx6ul.h | 30 | diff --git a/hw/dma/soc_dma.c b/hw/dma/soc_dma.c |
21 | index XXXXXXX..XXXXXXX 100644 | 31 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/hw/arm/fsl-imx6ul.h | 32 | --- a/hw/dma/soc_dma.c |
23 | +++ b/include/hw/arm/fsl-imx6ul.h | 33 | +++ b/hw/dma/soc_dma.c |
24 | @@ -XXX,XX +XXX,XX @@ | 34 | @@ -XXX,XX +XXX,XX @@ void soc_dma_set_request(struct soc_dma_ch_s *ch, int level) |
25 | #include "hw/misc/imx6ul_ccm.h" | 35 | dma->enabled_count += level - ch->enable; |
26 | #include "hw/misc/imx6_src.h" | 36 | |
27 | #include "hw/misc/imx7_snvs.h" | 37 | if (level) |
28 | -#include "hw/misc/imx7_gpr.h" | 38 | - dma->ch_enable_mask |= 1 << ch->num; |
29 | #include "hw/intc/imx_gpcv2.h" | 39 | + dma->ch_enable_mask |= (uint64_t)1 << ch->num; |
30 | #include "hw/watchdog/wdt_imx2.h" | 40 | else |
31 | #include "hw/gpio/imx_gpio.h" | 41 | - dma->ch_enable_mask &= ~(1 << ch->num); |
32 | @@ -XXX,XX +XXX,XX @@ struct FslIMX6ULState { | 42 | + dma->ch_enable_mask &= ~((uint64_t)1 << ch->num); |
33 | IMX6SRCState src; | 43 | |
34 | IMX7SNVSState snvs; | 44 | if (level != ch->enable) { |
35 | IMXGPCv2State gpcv2; | 45 | soc_dma_ch_freq_update(dma); |
36 | - IMX7GPRState gpr; | ||
37 | IMXSPIState spi[FSL_IMX6UL_NUM_ECSPIS]; | ||
38 | IMXI2CState i2c[FSL_IMX6UL_NUM_I2CS]; | ||
39 | IMXSerialState uart[FSL_IMX6UL_NUM_UARTS]; | ||
40 | diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/hw/arm/fsl-imx6ul.c | ||
43 | +++ b/hw/arm/fsl-imx6ul.c | ||
44 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | ||
45 | */ | ||
46 | object_initialize_child(obj, "snvs", &s->snvs, TYPE_IMX7_SNVS); | ||
47 | |||
48 | - /* | ||
49 | - * GPR | ||
50 | - */ | ||
51 | - object_initialize_child(obj, "gpr", &s->gpr, TYPE_IMX7_GPR); | ||
52 | - | ||
53 | /* | ||
54 | * GPIOs 1 to 5 | ||
55 | */ | ||
56 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
57 | FSL_IMX6UL_WDOGn_IRQ[i])); | ||
58 | } | ||
59 | |||
60 | - /* | ||
61 | - * GPR | ||
62 | - */ | ||
63 | - sysbus_realize(SYS_BUS_DEVICE(&s->gpr), &error_abort); | ||
64 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpr), 0, FSL_IMX6UL_IOMUXC_GPR_ADDR); | ||
65 | - | ||
66 | /* | ||
67 | * SDMA | ||
68 | */ | ||
69 | -- | 46 | -- |
70 | 2.34.1 | 47 | 2.34.1 | diff view generated by jsdifflib |
1 | In the m48t59 device we almost always use 64-bit arithmetic when | 1 | Ever since the bFLT format support was added in 2006, there has been |
---|---|---|---|
2 | dealing with time_t deltas. The one exception is in set_alarm(), | 2 | a chunk of code in the file guarded by CONFIG_BINFMT_SHARED_FLAT |
3 | which currently uses a plain 'int' to hold the difference between two | 3 | which is supposedly for shared library support. This is not enabled |
4 | time_t values. Switch to int64_t instead to avoid any possible | 4 | and it's not possible to enable it, because if you do you'll run into |
5 | overflow issues. | 5 | the "#error needs checking" in the calc_reloc() function. |
6 | |||
7 | Similarly, CONFIG_BINFMT_ZFLAT exists but can't be enabled because of | ||
8 | an "#error code needs checking" in load_flat_file(). | ||
9 | |||
10 | This code is obviously unfinished and has never been used; nobody in | ||
11 | the intervening 18 years has complained about this or fixed it, so | ||
12 | just delete the dead code. If anybody ever wants the feature they | ||
13 | can always pull it out of git, or (perhaps better) write it from | ||
14 | scratch based on the current Linux bFLT loader rather than the one of | ||
15 | 18 years ago. | ||
6 | 16 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 18 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
19 | Message-id: 20240411115313.680433-1-peter.maydell@linaro.org | ||
9 | --- | 20 | --- |
10 | hw/rtc/m48t59.c | 2 +- | 21 | linux-user/flat.h | 5 +- |
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | 22 | linux-user/flatload.c | 293 ++---------------------------------------- |
12 | 23 | 2 files changed, 11 insertions(+), 287 deletions(-) | |
13 | diff --git a/hw/rtc/m48t59.c b/hw/rtc/m48t59.c | 24 | |
25 | diff --git a/linux-user/flat.h b/linux-user/flat.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/rtc/m48t59.c | 27 | --- a/linux-user/flat.h |
16 | +++ b/hw/rtc/m48t59.c | 28 | +++ b/linux-user/flat.h |
17 | @@ -XXX,XX +XXX,XX @@ static void alarm_cb (void *opaque) | 29 | @@ -XXX,XX +XXX,XX @@ |
18 | 30 | ||
19 | static void set_alarm(M48t59State *NVRAM) | 31 | #define FLAT_VERSION 0x00000004L |
32 | |||
33 | -#ifdef CONFIG_BINFMT_SHARED_FLAT | ||
34 | -#define MAX_SHARED_LIBS (4) | ||
35 | -#else | ||
36 | +/* QEMU doesn't support bflt shared libraries */ | ||
37 | #define MAX_SHARED_LIBS (1) | ||
38 | -#endif | ||
39 | |||
40 | /* | ||
41 | * To make everything easier to port and manage cross platform | ||
42 | diff --git a/linux-user/flatload.c b/linux-user/flatload.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/linux-user/flatload.c | ||
45 | +++ b/linux-user/flatload.c | ||
46 | @@ -XXX,XX +XXX,XX @@ | ||
47 | * JAN/99 -- coded full program relocation (gerg@snapgear.com) | ||
48 | */ | ||
49 | |||
50 | -/* ??? ZFLAT and shared library support is currently disabled. */ | ||
51 | - | ||
52 | /****************************************************************************/ | ||
53 | |||
54 | #include "qemu/osdep.h" | ||
55 | @@ -XXX,XX +XXX,XX @@ struct lib_info { | ||
56 | short loaded; /* Has this library been loaded? */ | ||
57 | }; | ||
58 | |||
59 | -#ifdef CONFIG_BINFMT_SHARED_FLAT | ||
60 | -static int load_flat_shared_library(int id, struct lib_info *p); | ||
61 | -#endif | ||
62 | - | ||
63 | struct linux_binprm; | ||
64 | |||
65 | /****************************************************************************/ | ||
66 | @@ -XXX,XX +XXX,XX @@ static int target_pread(int fd, abi_ulong ptr, abi_ulong len, | ||
67 | unlock_user(buf, ptr, len); | ||
68 | return ret; | ||
69 | } | ||
70 | -/****************************************************************************/ | ||
71 | - | ||
72 | -#ifdef CONFIG_BINFMT_ZFLAT | ||
73 | - | ||
74 | -#include <linux/zlib.h> | ||
75 | - | ||
76 | -#define LBUFSIZE 4000 | ||
77 | - | ||
78 | -/* gzip flag byte */ | ||
79 | -#define ASCII_FLAG 0x01 /* bit 0 set: file probably ASCII text */ | ||
80 | -#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */ | ||
81 | -#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ | ||
82 | -#define ORIG_NAME 0x08 /* bit 3 set: original file name present */ | ||
83 | -#define COMMENT 0x10 /* bit 4 set: file comment present */ | ||
84 | -#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */ | ||
85 | -#define RESERVED 0xC0 /* bit 6,7: reserved */ | ||
86 | - | ||
87 | -static int decompress_exec( | ||
88 | - struct linux_binprm *bprm, | ||
89 | - unsigned long offset, | ||
90 | - char *dst, | ||
91 | - long len, | ||
92 | - int fd) | ||
93 | -{ | ||
94 | - unsigned char *buf; | ||
95 | - z_stream strm; | ||
96 | - loff_t fpos; | ||
97 | - int ret, retval; | ||
98 | - | ||
99 | - DBG_FLT("decompress_exec(offset=%x,buf=%x,len=%x)\n",(int)offset, (int)dst, (int)len); | ||
100 | - | ||
101 | - memset(&strm, 0, sizeof(strm)); | ||
102 | - strm.workspace = kmalloc(zlib_inflate_workspacesize(), GFP_KERNEL); | ||
103 | - if (strm.workspace == NULL) { | ||
104 | - DBG_FLT("binfmt_flat: no memory for decompress workspace\n"); | ||
105 | - return -ENOMEM; | ||
106 | - } | ||
107 | - buf = kmalloc(LBUFSIZE, GFP_KERNEL); | ||
108 | - if (buf == NULL) { | ||
109 | - DBG_FLT("binfmt_flat: no memory for read buffer\n"); | ||
110 | - retval = -ENOMEM; | ||
111 | - goto out_free; | ||
112 | - } | ||
113 | - | ||
114 | - /* Read in first chunk of data and parse gzip header. */ | ||
115 | - fpos = offset; | ||
116 | - ret = bprm->file->f_op->read(bprm->file, buf, LBUFSIZE, &fpos); | ||
117 | - | ||
118 | - strm.next_in = buf; | ||
119 | - strm.avail_in = ret; | ||
120 | - strm.total_in = 0; | ||
121 | - | ||
122 | - retval = -ENOEXEC; | ||
123 | - | ||
124 | - /* Check minimum size -- gzip header */ | ||
125 | - if (ret < 10) { | ||
126 | - DBG_FLT("binfmt_flat: file too small?\n"); | ||
127 | - goto out_free_buf; | ||
128 | - } | ||
129 | - | ||
130 | - /* Check gzip magic number */ | ||
131 | - if ((buf[0] != 037) || ((buf[1] != 0213) && (buf[1] != 0236))) { | ||
132 | - DBG_FLT("binfmt_flat: unknown compression magic?\n"); | ||
133 | - goto out_free_buf; | ||
134 | - } | ||
135 | - | ||
136 | - /* Check gzip method */ | ||
137 | - if (buf[2] != 8) { | ||
138 | - DBG_FLT("binfmt_flat: unknown compression method?\n"); | ||
139 | - goto out_free_buf; | ||
140 | - } | ||
141 | - /* Check gzip flags */ | ||
142 | - if ((buf[3] & ENCRYPTED) || (buf[3] & CONTINUATION) || | ||
143 | - (buf[3] & RESERVED)) { | ||
144 | - DBG_FLT("binfmt_flat: unknown flags?\n"); | ||
145 | - goto out_free_buf; | ||
146 | - } | ||
147 | - | ||
148 | - ret = 10; | ||
149 | - if (buf[3] & EXTRA_FIELD) { | ||
150 | - ret += 2 + buf[10] + (buf[11] << 8); | ||
151 | - if (unlikely(LBUFSIZE == ret)) { | ||
152 | - DBG_FLT("binfmt_flat: buffer overflow (EXTRA)?\n"); | ||
153 | - goto out_free_buf; | ||
154 | - } | ||
155 | - } | ||
156 | - if (buf[3] & ORIG_NAME) { | ||
157 | - for (; ret < LBUFSIZE && (buf[ret] != 0); ret++) | ||
158 | - ; | ||
159 | - if (unlikely(LBUFSIZE == ret)) { | ||
160 | - DBG_FLT("binfmt_flat: buffer overflow (ORIG_NAME)?\n"); | ||
161 | - goto out_free_buf; | ||
162 | - } | ||
163 | - } | ||
164 | - if (buf[3] & COMMENT) { | ||
165 | - for (; ret < LBUFSIZE && (buf[ret] != 0); ret++) | ||
166 | - ; | ||
167 | - if (unlikely(LBUFSIZE == ret)) { | ||
168 | - DBG_FLT("binfmt_flat: buffer overflow (COMMENT)?\n"); | ||
169 | - goto out_free_buf; | ||
170 | - } | ||
171 | - } | ||
172 | - | ||
173 | - strm.next_in += ret; | ||
174 | - strm.avail_in -= ret; | ||
175 | - | ||
176 | - strm.next_out = dst; | ||
177 | - strm.avail_out = len; | ||
178 | - strm.total_out = 0; | ||
179 | - | ||
180 | - if (zlib_inflateInit2(&strm, -MAX_WBITS) != Z_OK) { | ||
181 | - DBG_FLT("binfmt_flat: zlib init failed?\n"); | ||
182 | - goto out_free_buf; | ||
183 | - } | ||
184 | - | ||
185 | - while ((ret = zlib_inflate(&strm, Z_NO_FLUSH)) == Z_OK) { | ||
186 | - ret = bprm->file->f_op->read(bprm->file, buf, LBUFSIZE, &fpos); | ||
187 | - if (ret <= 0) | ||
188 | - break; | ||
189 | - if (is_error(ret)) { | ||
190 | - break; | ||
191 | - } | ||
192 | - len -= ret; | ||
193 | - | ||
194 | - strm.next_in = buf; | ||
195 | - strm.avail_in = ret; | ||
196 | - strm.total_in = 0; | ||
197 | - } | ||
198 | - | ||
199 | - if (ret < 0) { | ||
200 | - DBG_FLT("binfmt_flat: decompression failed (%d), %s\n", | ||
201 | - ret, strm.msg); | ||
202 | - goto out_zlib; | ||
203 | - } | ||
204 | - | ||
205 | - retval = 0; | ||
206 | -out_zlib: | ||
207 | - zlib_inflateEnd(&strm); | ||
208 | -out_free_buf: | ||
209 | - kfree(buf); | ||
210 | -out_free: | ||
211 | - kfree(strm.workspace); | ||
212 | -out: | ||
213 | - return retval; | ||
214 | -} | ||
215 | - | ||
216 | -#endif /* CONFIG_BINFMT_ZFLAT */ | ||
217 | |||
218 | /****************************************************************************/ | ||
219 | |||
220 | @@ -XXX,XX +XXX,XX @@ calc_reloc(abi_ulong r, struct lib_info *p, int curid, int internalp) | ||
221 | abi_ulong text_len; | ||
222 | abi_ulong start_code; | ||
223 | |||
224 | -#ifdef CONFIG_BINFMT_SHARED_FLAT | ||
225 | -#error needs checking | ||
226 | - if (r == 0) | ||
227 | - id = curid; /* Relocs of 0 are always self referring */ | ||
228 | - else { | ||
229 | - id = (r >> 24) & 0xff; /* Find ID for this reloc */ | ||
230 | - r &= 0x00ffffff; /* Trim ID off here */ | ||
231 | - } | ||
232 | - if (id >= MAX_SHARED_LIBS) { | ||
233 | - fprintf(stderr, "BINFMT_FLAT: reference 0x%x to shared library %d\n", | ||
234 | - (unsigned) r, id); | ||
235 | - goto failed; | ||
236 | - } | ||
237 | - if (curid != id) { | ||
238 | - if (internalp) { | ||
239 | - fprintf(stderr, "BINFMT_FLAT: reloc address 0x%x not " | ||
240 | - "in same module (%d != %d)\n", | ||
241 | - (unsigned) r, curid, id); | ||
242 | - goto failed; | ||
243 | - } else if (!p[id].loaded && is_error(load_flat_shared_library(id, p))) { | ||
244 | - fprintf(stderr, "BINFMT_FLAT: failed to load library %d\n", id); | ||
245 | - goto failed; | ||
246 | - } | ||
247 | - /* Check versioning information (i.e. time stamps) */ | ||
248 | - if (p[id].build_date && p[curid].build_date | ||
249 | - && p[curid].build_date < p[id].build_date) { | ||
250 | - fprintf(stderr, "BINFMT_FLAT: library %d is younger than %d\n", | ||
251 | - id, curid); | ||
252 | - goto failed; | ||
253 | - } | ||
254 | - } | ||
255 | -#else | ||
256 | id = 0; | ||
257 | -#endif | ||
258 | |||
259 | start_brk = p[id].start_brk; | ||
260 | start_data = p[id].start_data; | ||
261 | @@ -XXX,XX +XXX,XX @@ static int load_flat_file(struct linux_binprm * bprm, | ||
262 | if (rev == OLD_FLAT_VERSION && flat_old_ram_flag(flags)) | ||
263 | flags = FLAT_FLAG_RAM; | ||
264 | |||
265 | -#ifndef CONFIG_BINFMT_ZFLAT | ||
266 | if (flags & (FLAT_FLAG_GZIP|FLAT_FLAG_GZDATA)) { | ||
267 | - fprintf(stderr, "Support for ZFLAT executables is not enabled\n"); | ||
268 | + fprintf(stderr, "ZFLAT executables are not supported\n"); | ||
269 | return -ENOEXEC; | ||
270 | } | ||
271 | -#endif | ||
272 | |||
273 | /* | ||
274 | * calculate the extra space we need to map in | ||
275 | @@ -XXX,XX +XXX,XX @@ static int load_flat_file(struct linux_binprm * bprm, | ||
276 | (int)(data_len + bss_len + stack_len), (int)datapos); | ||
277 | |||
278 | fpos = ntohl(hdr->data_start); | ||
279 | -#ifdef CONFIG_BINFMT_ZFLAT | ||
280 | - if (flags & FLAT_FLAG_GZDATA) { | ||
281 | - result = decompress_exec(bprm, fpos, (char *) datapos, | ||
282 | - data_len + (relocs * sizeof(abi_ulong))) | ||
283 | - } else | ||
284 | -#endif | ||
285 | - { | ||
286 | - result = target_pread(bprm->src.fd, datapos, | ||
287 | - data_len + (relocs * sizeof(abi_ulong)), | ||
288 | - fpos); | ||
289 | - } | ||
290 | + result = target_pread(bprm->src.fd, datapos, | ||
291 | + data_len + (relocs * sizeof(abi_ulong)), | ||
292 | + fpos); | ||
293 | if (result < 0) { | ||
294 | fprintf(stderr, "Unable to read data+bss\n"); | ||
295 | return result; | ||
296 | @@ -XXX,XX +XXX,XX @@ static int load_flat_file(struct linux_binprm * bprm, | ||
297 | datapos = realdatastart + indx_len; | ||
298 | reloc = (textpos + ntohl(hdr->reloc_start) + indx_len); | ||
299 | |||
300 | -#ifdef CONFIG_BINFMT_ZFLAT | ||
301 | -#error code needs checking | ||
302 | - /* | ||
303 | - * load it all in and treat it like a RAM load from now on | ||
304 | - */ | ||
305 | - if (flags & FLAT_FLAG_GZIP) { | ||
306 | - result = decompress_exec(bprm, sizeof (struct flat_hdr), | ||
307 | - (((char *) textpos) + sizeof (struct flat_hdr)), | ||
308 | - (text_len + data_len + (relocs * sizeof(unsigned long)) | ||
309 | - - sizeof (struct flat_hdr)), | ||
310 | - 0); | ||
311 | - memmove((void *) datapos, (void *) realdatastart, | ||
312 | - data_len + (relocs * sizeof(unsigned long))); | ||
313 | - } else if (flags & FLAT_FLAG_GZDATA) { | ||
314 | - fpos = 0; | ||
315 | - result = bprm->file->f_op->read(bprm->file, | ||
316 | - (char *) textpos, text_len, &fpos); | ||
317 | - if (!is_error(result)) { | ||
318 | - result = decompress_exec(bprm, text_len, (char *) datapos, | ||
319 | - data_len + (relocs * sizeof(unsigned long)), 0); | ||
320 | - } | ||
321 | - } | ||
322 | - else | ||
323 | -#endif | ||
324 | - { | ||
325 | - result = target_pread(bprm->src.fd, textpos, | ||
326 | - text_len, 0); | ||
327 | - if (result >= 0) { | ||
328 | - result = target_pread(bprm->src.fd, datapos, | ||
329 | - data_len + (relocs * sizeof(abi_ulong)), | ||
330 | - ntohl(hdr->data_start)); | ||
331 | - } | ||
332 | + result = target_pread(bprm->src.fd, textpos, | ||
333 | + text_len, 0); | ||
334 | + if (result >= 0) { | ||
335 | + result = target_pread(bprm->src.fd, datapos, | ||
336 | + data_len + (relocs * sizeof(abi_ulong)), | ||
337 | + ntohl(hdr->data_start)); | ||
338 | } | ||
339 | if (result < 0) { | ||
340 | fprintf(stderr, "Unable to read code+data+bss\n"); | ||
341 | @@ -XXX,XX +XXX,XX @@ static int load_flat_file(struct linux_binprm * bprm, | ||
342 | |||
343 | |||
344 | /****************************************************************************/ | ||
345 | -#ifdef CONFIG_BINFMT_SHARED_FLAT | ||
346 | - | ||
347 | -/* | ||
348 | - * Load a shared library into memory. The library gets its own data | ||
349 | - * segment (including bss) but not argv/argc/environ. | ||
350 | - */ | ||
351 | - | ||
352 | -static int load_flat_shared_library(int id, struct lib_info *libs) | ||
353 | -{ | ||
354 | - struct linux_binprm bprm; | ||
355 | - int res; | ||
356 | - char buf[16]; | ||
357 | - | ||
358 | - /* Create the file name */ | ||
359 | - sprintf(buf, "/lib/lib%d.so", id); | ||
360 | - | ||
361 | - /* Open the file up */ | ||
362 | - bprm.filename = buf; | ||
363 | - bprm.file = open_exec(bprm.filename); | ||
364 | - res = PTR_ERR(bprm.file); | ||
365 | - if (IS_ERR(bprm.file)) | ||
366 | - return res; | ||
367 | - | ||
368 | - res = prepare_binprm(&bprm); | ||
369 | - | ||
370 | - if (!is_error(res)) { | ||
371 | - res = load_flat_file(&bprm, libs, id, NULL); | ||
372 | - } | ||
373 | - if (bprm.file) { | ||
374 | - allow_write_access(bprm.file); | ||
375 | - fput(bprm.file); | ||
376 | - bprm.file = NULL; | ||
377 | - } | ||
378 | - return(res); | ||
379 | -} | ||
380 | - | ||
381 | -#endif /* CONFIG_BINFMT_SHARED_FLAT */ | ||
382 | - | ||
383 | int load_flt_binary(struct linux_binprm *bprm, struct image_info *info) | ||
20 | { | 384 | { |
21 | - int diff; | 385 | struct lib_info libinfo[MAX_SHARED_LIBS]; |
22 | + int64_t diff; | 386 | @@ -XXX,XX +XXX,XX @@ int load_flt_binary(struct linux_binprm *bprm, struct image_info *info) |
23 | if (NVRAM->alrm_timer != NULL) { | 387 | */ |
24 | timer_del(NVRAM->alrm_timer); | 388 | start_addr = libinfo[0].entry; |
25 | diff = qemu_timedate_diff(&NVRAM->alarm) - NVRAM->time_offset; | 389 | |
390 | -#ifdef CONFIG_BINFMT_SHARED_FLAT | ||
391 | -#error here | ||
392 | - for (i = MAX_SHARED_LIBS-1; i>0; i--) { | ||
393 | - if (libinfo[i].loaded) { | ||
394 | - /* Push previous first to call address */ | ||
395 | - --sp; | ||
396 | - if (put_user_ual(start_addr, sp)) | ||
397 | - return -EFAULT; | ||
398 | - start_addr = libinfo[i].entry; | ||
399 | - } | ||
400 | - } | ||
401 | -#endif | ||
402 | - | ||
403 | /* Stash our initial stack pointer into the mm structure */ | ||
404 | info->start_code = libinfo[0].start_code; | ||
405 | info->end_code = libinfo[0].start_code + libinfo[0].text_len; | ||
26 | -- | 406 | -- |
27 | 2.34.1 | 407 | 2.34.1 |
28 | 408 | ||
29 | 409 | diff view generated by jsdifflib |
1 | The IoTKit, SSE200 and SSE300 all default to 8 MPU regions. The | 1 | The npcm7xx_clk and npcm7xx_gcr device reset methods look at |
---|---|---|---|
2 | MPS2/MPS3 FPGA images don't override these except in the case of | 2 | the ResetType argument and only handle RESET_TYPE_COLD, |
3 | AN547, which uses 16 MPU regions. | 3 | producing a warning if another reset type is passed. This |
4 | is different from how every other three-phase-reset method | ||
5 | we have works, and makes it difficult to add new reset types. | ||
4 | 6 | ||
5 | Define properties on the ARMSSE object for the MPU regions (using the | 7 | A better pattern is "assume that any reset type you don't know |
6 | same names as the documented RTL configuration settings, and | 8 | about should be handled like RESET_TYPE_COLD"; switch these |
7 | following the pattern we already have for this device of using | 9 | devices to do that. Then adding a new reset type will only |
8 | all-caps names as the RTL does), and set them in the board code. | 10 | need to touch those devices where its behaviour really needs |
11 | to be different from the standard cold reset. | ||
9 | 12 | ||
10 | We don't actually need to override the default except on AN547, | ||
11 | but it's simpler code to have the board code set them always | ||
12 | rather than tracking which board subtypes want to set them to | ||
13 | a non-default value separately from what that value is. | ||
14 | |||
15 | Tho overall effect is that for mps2-an505, mps2-an521 and mps3-an524 | ||
16 | we now correctly use 8 MPU regions, while mps3-an547 stays at its | ||
17 | current 16 regions. | ||
18 | |||
19 | It's possible some guest code wrongly depended on the previous | ||
20 | incorrectly modeled number of memory regions. (Such guest code | ||
21 | should ideally check the number of regions via the MPU_TYPE | ||
22 | register.) The old behaviour can be obtained with additional | ||
23 | -global arguments to QEMU: | ||
24 | |||
25 | For mps2-an521 and mps2-an524: | ||
26 | -global sse-200.CPU0_MPU_NS=16 -global sse-200.CPU0_MPU_S=16 -global sse-200.CPU1_MPU_NS=16 -global sse-200.CPU1_MPU_S=16 | ||
27 | |||
28 | For mps2-an505: | ||
29 | -global sse-200.CPU0_MPU_NS=16 -global sse-200.CPU0_MPU_S=16 | ||
30 | |||
31 | NB that the way the implementation allows this use of -global | ||
32 | is slightly fragile: if the board code explicitly sets the | ||
33 | properties on the sse-200 object, this overrides the -global | ||
34 | command line option. So we rely on: | ||
35 | - the boards that need fixing all happen to use the SSE defaults | ||
36 | - we can write the board code to only set the property if it | ||
37 | is different from the default, rather than having all boards | ||
38 | explicitly set the property | ||
39 | - the board that does need to use a non-default value happens | ||
40 | to need to set it to the same value (16) we previously used | ||
41 | This works, but there are some kinds of refactoring of the | ||
42 | mps2-tz.c code that would break the support for -global here. | ||
43 | |||
44 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1772 | ||
45 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
46 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
47 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 15 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
48 | Message-id: 20230724174335.2150499-4-peter.maydell@linaro.org | 16 | Reviewed-by: Luc Michel <luc.michel@amd.com> |
17 | Message-id: 20240412160809.1260625-2-peter.maydell@linaro.org | ||
49 | --- | 18 | --- |
50 | include/hw/arm/armsse.h | 5 +++++ | 19 | hw/misc/npcm7xx_clk.c | 13 +++---------- |
51 | hw/arm/armsse.c | 16 ++++++++++++++++ | 20 | hw/misc/npcm7xx_gcr.c | 12 ++++-------- |
52 | hw/arm/mps2-tz.c | 29 +++++++++++++++++++++++++++++ | 21 | 2 files changed, 7 insertions(+), 18 deletions(-) |
53 | 3 files changed, 50 insertions(+) | ||
54 | 22 | ||
55 | diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h | 23 | diff --git a/hw/misc/npcm7xx_clk.c b/hw/misc/npcm7xx_clk.c |
56 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
57 | --- a/include/hw/arm/armsse.h | 25 | --- a/hw/misc/npcm7xx_clk.c |
58 | +++ b/include/hw/arm/armsse.h | 26 | +++ b/hw/misc/npcm7xx_clk.c |
59 | @@ -XXX,XX +XXX,XX @@ | 27 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_clk_enter_reset(Object *obj, ResetType type) |
60 | * (matching the hardware) is that for CPU0 in an IoTKit and CPU1 in an | 28 | |
61 | * SSE-200 both are present; CPU0 in an SSE-200 has neither. | 29 | QEMU_BUILD_BUG_ON(sizeof(s->regs) != sizeof(cold_reset_values)); |
62 | * Since the IoTKit has only one CPU, it does not have the CPU1_* properties. | 30 | |
63 | + * + QOM properties "CPU0_MPU_NS", "CPU0_MPU_S", "CPU1_MPU_NS" and "CPU1_MPU_S" | 31 | - switch (type) { |
64 | + * which set the number of MPU regions on the CPUs. If there is only one | 32 | - case RESET_TYPE_COLD: |
65 | + * CPU the CPU1 properties are not present. | 33 | - memcpy(s->regs, cold_reset_values, sizeof(cold_reset_values)); |
66 | * + Named GPIO inputs "EXP_IRQ" 0..n are the expansion interrupts for CPU 0, | 34 | - s->ref_ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); |
67 | * which are wired to its NVIC lines 32 .. n+32 | 35 | - npcm7xx_clk_update_all_clocks(s); |
68 | * + Named GPIO inputs "EXP_CPU1_IRQ" 0..n are the expansion interrupts for | 36 | - return; |
69 | @@ -XXX,XX +XXX,XX @@ struct ARMSSE { | 37 | - } |
70 | uint32_t exp_numirq; | 38 | - |
71 | uint32_t sram_addr_width; | 39 | + memcpy(s->regs, cold_reset_values, sizeof(cold_reset_values)); |
72 | uint32_t init_svtor; | 40 | + s->ref_ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); |
73 | + uint32_t cpu_mpu_ns[SSE_MAX_CPUS]; | 41 | + npcm7xx_clk_update_all_clocks(s); |
74 | + uint32_t cpu_mpu_s[SSE_MAX_CPUS]; | 42 | /* |
75 | bool cpu_fpu[SSE_MAX_CPUS]; | 43 | * A small number of registers need to be reset on a core domain reset, |
76 | bool cpu_dsp[SSE_MAX_CPUS]; | 44 | * but no such reset type exists yet. |
77 | }; | 45 | */ |
78 | diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c | 46 | - qemu_log_mask(LOG_UNIMP, "%s: reset type %d not implemented.", |
47 | - __func__, type); | ||
48 | } | ||
49 | |||
50 | static void npcm7xx_clk_init_clock_hierarchy(NPCM7xxCLKState *s) | ||
51 | diff --git a/hw/misc/npcm7xx_gcr.c b/hw/misc/npcm7xx_gcr.c | ||
79 | index XXXXXXX..XXXXXXX 100644 | 52 | index XXXXXXX..XXXXXXX 100644 |
80 | --- a/hw/arm/armsse.c | 53 | --- a/hw/misc/npcm7xx_gcr.c |
81 | +++ b/hw/arm/armsse.c | 54 | +++ b/hw/misc/npcm7xx_gcr.c |
82 | @@ -XXX,XX +XXX,XX @@ static Property iotkit_properties[] = { | 55 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_gcr_enter_reset(Object *obj, ResetType type) |
83 | DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000), | 56 | |
84 | DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], true), | 57 | QEMU_BUILD_BUG_ON(sizeof(s->regs) != sizeof(cold_reset_values)); |
85 | DEFINE_PROP_BOOL("CPU0_DSP", ARMSSE, cpu_dsp[0], true), | 58 | |
86 | + DEFINE_PROP_UINT32("CPU0_MPU_NS", ARMSSE, cpu_mpu_ns[0], 8), | 59 | - switch (type) { |
87 | + DEFINE_PROP_UINT32("CPU0_MPU_S", ARMSSE, cpu_mpu_s[0], 8), | 60 | - case RESET_TYPE_COLD: |
88 | DEFINE_PROP_END_OF_LIST() | 61 | - memcpy(s->regs, cold_reset_values, sizeof(s->regs)); |
89 | }; | 62 | - s->regs[NPCM7XX_GCR_PWRON] = s->reset_pwron; |
90 | 63 | - s->regs[NPCM7XX_GCR_MDLR] = s->reset_mdlr; | |
91 | @@ -XXX,XX +XXX,XX @@ static Property sse200_properties[] = { | 64 | - s->regs[NPCM7XX_GCR_INTCR3] = s->reset_intcr3; |
92 | DEFINE_PROP_BOOL("CPU0_DSP", ARMSSE, cpu_dsp[0], false), | 65 | - break; |
93 | DEFINE_PROP_BOOL("CPU1_FPU", ARMSSE, cpu_fpu[1], true), | 66 | - } |
94 | DEFINE_PROP_BOOL("CPU1_DSP", ARMSSE, cpu_dsp[1], true), | 67 | + memcpy(s->regs, cold_reset_values, sizeof(s->regs)); |
95 | + DEFINE_PROP_UINT32("CPU0_MPU_NS", ARMSSE, cpu_mpu_ns[0], 8), | 68 | + s->regs[NPCM7XX_GCR_PWRON] = s->reset_pwron; |
96 | + DEFINE_PROP_UINT32("CPU0_MPU_S", ARMSSE, cpu_mpu_s[0], 8), | 69 | + s->regs[NPCM7XX_GCR_MDLR] = s->reset_mdlr; |
97 | + DEFINE_PROP_UINT32("CPU1_MPU_NS", ARMSSE, cpu_mpu_ns[1], 8), | 70 | + s->regs[NPCM7XX_GCR_INTCR3] = s->reset_intcr3; |
98 | + DEFINE_PROP_UINT32("CPU1_MPU_S", ARMSSE, cpu_mpu_s[1], 8), | ||
99 | DEFINE_PROP_END_OF_LIST() | ||
100 | }; | ||
101 | |||
102 | @@ -XXX,XX +XXX,XX @@ static Property sse300_properties[] = { | ||
103 | DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000), | ||
104 | DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], true), | ||
105 | DEFINE_PROP_BOOL("CPU0_DSP", ARMSSE, cpu_dsp[0], true), | ||
106 | + DEFINE_PROP_UINT32("CPU0_MPU_NS", ARMSSE, cpu_mpu_ns[0], 8), | ||
107 | + DEFINE_PROP_UINT32("CPU0_MPU_S", ARMSSE, cpu_mpu_s[0], 8), | ||
108 | DEFINE_PROP_END_OF_LIST() | ||
109 | }; | ||
110 | |||
111 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) | ||
112 | return; | ||
113 | } | ||
114 | } | ||
115 | + if (!object_property_set_uint(cpuobj, "mpu-ns-regions", | ||
116 | + s->cpu_mpu_ns[i], errp)) { | ||
117 | + return; | ||
118 | + } | ||
119 | + if (!object_property_set_uint(cpuobj, "mpu-s-regions", | ||
120 | + s->cpu_mpu_s[i], errp)) { | ||
121 | + return; | ||
122 | + } | ||
123 | |||
124 | if (i > 0) { | ||
125 | memory_region_add_subregion_overlap(&s->cpu_container[i], 0, | ||
126 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | ||
127 | index XXXXXXX..XXXXXXX 100644 | ||
128 | --- a/hw/arm/mps2-tz.c | ||
129 | +++ b/hw/arm/mps2-tz.c | ||
130 | @@ -XXX,XX +XXX,XX @@ struct MPS2TZMachineClass { | ||
131 | int uart_overflow_irq; /* number of the combined UART overflow IRQ */ | ||
132 | uint32_t init_svtor; /* init-svtor setting for SSE */ | ||
133 | uint32_t sram_addr_width; /* SRAM_ADDR_WIDTH setting for SSE */ | ||
134 | + uint32_t cpu0_mpu_ns; /* CPU0_MPU_NS setting for SSE */ | ||
135 | + uint32_t cpu0_mpu_s; /* CPU0_MPU_S setting for SSE */ | ||
136 | + uint32_t cpu1_mpu_ns; /* CPU1_MPU_NS setting for SSE */ | ||
137 | + uint32_t cpu1_mpu_s; /* CPU1_MPU_S setting for SSE */ | ||
138 | const RAMInfo *raminfo; | ||
139 | const char *armsse_type; | ||
140 | uint32_t boot_ram_size; /* size of ram at address 0; 0 == find in raminfo */ | ||
141 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_TYPE(MPS2TZMachineState, MPS2TZMachineClass, MPS2TZ_MACHINE) | ||
142 | #define MPS3_DDR_SIZE (2 * GiB) | ||
143 | #endif | ||
144 | |||
145 | +/* For cpu{0,1}_mpu_{ns,s}, means "leave at SSE's default value" */ | ||
146 | +#define MPU_REGION_DEFAULT UINT32_MAX | ||
147 | + | ||
148 | static const uint32_t an505_oscclk[] = { | ||
149 | 40000000, | ||
150 | 24580000, | ||
151 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | ||
152 | OBJECT(system_memory), &error_abort); | ||
153 | qdev_prop_set_uint32(iotkitdev, "EXP_NUMIRQ", mmc->numirq); | ||
154 | qdev_prop_set_uint32(iotkitdev, "init-svtor", mmc->init_svtor); | ||
155 | + if (mmc->cpu0_mpu_ns != MPU_REGION_DEFAULT) { | ||
156 | + qdev_prop_set_uint32(iotkitdev, "CPU0_MPU_NS", mmc->cpu0_mpu_ns); | ||
157 | + } | ||
158 | + if (mmc->cpu0_mpu_s != MPU_REGION_DEFAULT) { | ||
159 | + qdev_prop_set_uint32(iotkitdev, "CPU0_MPU_S", mmc->cpu0_mpu_s); | ||
160 | + } | ||
161 | + if (object_property_find(OBJECT(iotkitdev), "CPU1_MPU_NS")) { | ||
162 | + if (mmc->cpu1_mpu_ns != MPU_REGION_DEFAULT) { | ||
163 | + qdev_prop_set_uint32(iotkitdev, "CPU1_MPU_NS", mmc->cpu1_mpu_ns); | ||
164 | + } | ||
165 | + if (mmc->cpu1_mpu_s != MPU_REGION_DEFAULT) { | ||
166 | + qdev_prop_set_uint32(iotkitdev, "CPU1_MPU_S", mmc->cpu1_mpu_s); | ||
167 | + } | ||
168 | + } | ||
169 | qdev_prop_set_uint32(iotkitdev, "SRAM_ADDR_WIDTH", mmc->sram_addr_width); | ||
170 | qdev_connect_clock_in(iotkitdev, "MAINCLK", mms->sysclk); | ||
171 | qdev_connect_clock_in(iotkitdev, "S32KCLK", mms->s32kclk); | ||
172 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_class_init(ObjectClass *oc, void *data) | ||
173 | { | ||
174 | MachineClass *mc = MACHINE_CLASS(oc); | ||
175 | IDAUInterfaceClass *iic = IDAU_INTERFACE_CLASS(oc); | ||
176 | + MPS2TZMachineClass *mmc = MPS2TZ_MACHINE_CLASS(oc); | ||
177 | |||
178 | mc->init = mps2tz_common_init; | ||
179 | mc->reset = mps2_machine_reset; | ||
180 | iic->check = mps2_tz_idau_check; | ||
181 | + | ||
182 | + /* Most machines leave these at the SSE defaults */ | ||
183 | + mmc->cpu0_mpu_ns = MPU_REGION_DEFAULT; | ||
184 | + mmc->cpu0_mpu_s = MPU_REGION_DEFAULT; | ||
185 | + mmc->cpu1_mpu_ns = MPU_REGION_DEFAULT; | ||
186 | + mmc->cpu1_mpu_s = MPU_REGION_DEFAULT; | ||
187 | } | 71 | } |
188 | 72 | ||
189 | static void mps2tz_set_default_ram_info(MPS2TZMachineClass *mmc) | 73 | static void npcm7xx_gcr_realize(DeviceState *dev, Error **errp) |
190 | @@ -XXX,XX +XXX,XX @@ static void mps3tz_an547_class_init(ObjectClass *oc, void *data) | ||
191 | mmc->numirq = 96; | ||
192 | mmc->uart_overflow_irq = 48; | ||
193 | mmc->init_svtor = 0x00000000; | ||
194 | + mmc->cpu0_mpu_s = mmc->cpu0_mpu_ns = 16; | ||
195 | mmc->sram_addr_width = 21; | ||
196 | mmc->raminfo = an547_raminfo; | ||
197 | mmc->armsse_type = TYPE_SSE300; | ||
198 | -- | 74 | -- |
199 | 2.34.1 | 75 | 2.34.1 |
200 | 76 | ||
201 | 77 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Rather than directly calling the device's implementation of its 'hold' | ||
2 | reset phase, call device_cold_reset(). This means we don't have to | ||
3 | adjust this callsite when we add another argument to the function | ||
4 | signature for the hold and exit reset methods. | ||
1 | 5 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Luc Michel <luc.michel@amd.com> | ||
9 | Message-id: 20240412160809.1260625-3-peter.maydell@linaro.org | ||
10 | --- | ||
11 | hw/i2c/allwinner-i2c.c | 3 +-- | ||
12 | hw/sensor/adm1272.c | 2 +- | ||
13 | 2 files changed, 2 insertions(+), 3 deletions(-) | ||
14 | |||
15 | diff --git a/hw/i2c/allwinner-i2c.c b/hw/i2c/allwinner-i2c.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/i2c/allwinner-i2c.c | ||
18 | +++ b/hw/i2c/allwinner-i2c.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static void allwinner_i2c_write(void *opaque, hwaddr offset, | ||
20 | break; | ||
21 | case TWI_SRST_REG: | ||
22 | if (((value & TWI_SRST_MASK) == 0) && (s->srst & TWI_SRST_MASK)) { | ||
23 | - /* Perform reset */ | ||
24 | - allwinner_i2c_reset_hold(OBJECT(s)); | ||
25 | + device_cold_reset(DEVICE(s)); | ||
26 | } | ||
27 | s->srst = value & TWI_SRST_MASK; | ||
28 | break; | ||
29 | diff --git a/hw/sensor/adm1272.c b/hw/sensor/adm1272.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/hw/sensor/adm1272.c | ||
32 | +++ b/hw/sensor/adm1272.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static int adm1272_write_data(PMBusDevice *pmdev, const uint8_t *buf, | ||
34 | break; | ||
35 | |||
36 | case ADM1272_MFR_POWER_CYCLE: | ||
37 | - adm1272_exit_reset((Object *)s); | ||
38 | + device_cold_reset(DEVICE(s)); | ||
39 | break; | ||
40 | |||
41 | case ADM1272_HYSTERESIS_LOW: | ||
42 | -- | ||
43 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | We pass a ResetType argument to the Resettable class enter phase | ||
2 | method, but we don't pass it to hold and exit, even though the | ||
3 | callsites have it readily available. This means that if a device | ||
4 | cared about the ResetType it would need to record it in the enter | ||
5 | phase method to use later on. We should pass the type to all three | ||
6 | of the phase methods to avoid having to do that. | ||
1 | 7 | ||
8 | This coccinelle script adds the ResetType argument to the hold and | ||
9 | exit phases of the Resettable interface. | ||
10 | |||
11 | The first part of the script (rules holdfn_assigned, holdfn_defined, | ||
12 | exitfn_assigned, exitfn_defined) update implementations of the | ||
13 | interface within device models, both to change the signature of their | ||
14 | method implementations and to pass on the reset type when they invoke | ||
15 | reset on some other device. | ||
16 | |||
17 | The second part of the script is various special cases: | ||
18 | * method callsites in resettable_phase_hold(), resettable_phase_exit() | ||
19 | and device_phases_reset() | ||
20 | * updating the typedefs for the methods | ||
21 | * isl_pmbus_vr.c has some code where one device's reset method directly | ||
22 | calls the implementation of a different device's method | ||
23 | |||
24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
25 | Reviewed-by: Luc Michel <luc.michel@amd.com> | ||
26 | Message-id: 20240412160809.1260625-4-peter.maydell@linaro.org | ||
27 | --- | ||
28 | scripts/coccinelle/reset-type.cocci | 133 ++++++++++++++++++++++++++++ | ||
29 | 1 file changed, 133 insertions(+) | ||
30 | create mode 100644 scripts/coccinelle/reset-type.cocci | ||
31 | |||
32 | diff --git a/scripts/coccinelle/reset-type.cocci b/scripts/coccinelle/reset-type.cocci | ||
33 | new file mode 100644 | ||
34 | index XXXXXXX..XXXXXXX | ||
35 | --- /dev/null | ||
36 | +++ b/scripts/coccinelle/reset-type.cocci | ||
37 | @@ -XXX,XX +XXX,XX @@ | ||
38 | +// Convert device code using three-phase reset to add a ResetType | ||
39 | +// argument to implementations of ResettableHoldPhase and | ||
40 | +// ResettableEnterPhase methods. | ||
41 | +// | ||
42 | +// Copyright Linaro Ltd 2024 | ||
43 | +// SPDX-License-Identifier: GPL-2.0-or-later | ||
44 | +// | ||
45 | +// for dir in include hw target; do \ | ||
46 | +// spatch --macro-file scripts/cocci-macro-file.h \ | ||
47 | +// --sp-file scripts/coccinelle/reset-type.cocci \ | ||
48 | +// --keep-comments --smpl-spacing --in-place --include-headers \ | ||
49 | +// --dir $dir; done | ||
50 | +// | ||
51 | +// This coccinelle script aims to produce a complete change that needs | ||
52 | +// no human interaction, so as well as the generic "update device | ||
53 | +// implementations of the hold and exit phase methods" it includes | ||
54 | +// the special-case transformations needed for the core code and for | ||
55 | +// one device model that does something a bit nonstandard. Those | ||
56 | +// special cases are at the end of the file. | ||
57 | + | ||
58 | +// Look for where we use a function as a ResettableHoldPhase method, | ||
59 | +// either by directly assigning it to phases.hold or by calling | ||
60 | +// resettable_class_set_parent_phases, and remember the function name. | ||
61 | +@ holdfn_assigned @ | ||
62 | +identifier enterfn, holdfn, exitfn; | ||
63 | +identifier rc; | ||
64 | +expression e; | ||
65 | +@@ | ||
66 | +ResettableClass *rc; | ||
67 | +... | ||
68 | +( | ||
69 | + rc->phases.hold = holdfn; | ||
70 | +| | ||
71 | + resettable_class_set_parent_phases(rc, enterfn, holdfn, exitfn, e); | ||
72 | +) | ||
73 | + | ||
74 | +// Look for the definition of the function we found in holdfn_assigned, | ||
75 | +// and add the new argument. If the function calls a hold function | ||
76 | +// itself (probably chaining to the parent class reset) then add the | ||
77 | +// new argument there too. | ||
78 | +@ holdfn_defined @ | ||
79 | +identifier holdfn_assigned.holdfn; | ||
80 | +typedef Object; | ||
81 | +identifier obj; | ||
82 | +expression parent; | ||
83 | +@@ | ||
84 | +-holdfn(Object *obj) | ||
85 | ++holdfn(Object *obj, ResetType type) | ||
86 | +{ | ||
87 | + <... | ||
88 | +- parent.hold(obj) | ||
89 | ++ parent.hold(obj, type) | ||
90 | + ...> | ||
91 | +} | ||
92 | + | ||
93 | +// Similarly for ResettableExitPhase. | ||
94 | +@ exitfn_assigned @ | ||
95 | +identifier enterfn, holdfn, exitfn; | ||
96 | +identifier rc; | ||
97 | +expression e; | ||
98 | +@@ | ||
99 | +ResettableClass *rc; | ||
100 | +... | ||
101 | +( | ||
102 | + rc->phases.exit = exitfn; | ||
103 | +| | ||
104 | + resettable_class_set_parent_phases(rc, enterfn, holdfn, exitfn, e); | ||
105 | +) | ||
106 | +@ exitfn_defined @ | ||
107 | +identifier exitfn_assigned.exitfn; | ||
108 | +typedef Object; | ||
109 | +identifier obj; | ||
110 | +expression parent; | ||
111 | +@@ | ||
112 | +-exitfn(Object *obj) | ||
113 | ++exitfn(Object *obj, ResetType type) | ||
114 | +{ | ||
115 | + <... | ||
116 | +- parent.exit(obj) | ||
117 | ++ parent.exit(obj, type) | ||
118 | + ...> | ||
119 | +} | ||
120 | + | ||
121 | +// SPECIAL CASES ONLY BELOW HERE | ||
122 | +// We use a python scripted constraint on the position of the match | ||
123 | +// to ensure that they only match in a particular function. See | ||
124 | +// https://public-inbox.org/git/alpine.DEB.2.21.1808240652370.2344@hadrien/ | ||
125 | +// which recommends this as the way to do "match only in this function". | ||
126 | + | ||
127 | +// Special case: isl_pmbus_vr.c has some reset methods calling others directly | ||
128 | +@ isl_pmbus_vr @ | ||
129 | +identifier obj; | ||
130 | +@@ | ||
131 | +- isl_pmbus_vr_exit_reset(obj); | ||
132 | ++ isl_pmbus_vr_exit_reset(obj, type); | ||
133 | + | ||
134 | +// Special case: device_phases_reset() needs to pass RESET_TYPE_COLD | ||
135 | +@ device_phases_reset_hold @ | ||
136 | +expression obj; | ||
137 | +identifier rc; | ||
138 | +identifier phase; | ||
139 | +position p : script:python() { p[0].current_element == "device_phases_reset" }; | ||
140 | +@@ | ||
141 | +- rc->phases.phase(obj)@p | ||
142 | ++ rc->phases.phase(obj, RESET_TYPE_COLD) | ||
143 | + | ||
144 | +// Special case: in resettable_phase_hold() and resettable_phase_exit() | ||
145 | +// we need to pass through the ResetType argument to the method being called | ||
146 | +@ resettable_phase_hold @ | ||
147 | +expression obj; | ||
148 | +identifier rc; | ||
149 | +position p : script:python() { p[0].current_element == "resettable_phase_hold" }; | ||
150 | +@@ | ||
151 | +- rc->phases.hold(obj)@p | ||
152 | ++ rc->phases.hold(obj, type) | ||
153 | +@ resettable_phase_exit @ | ||
154 | +expression obj; | ||
155 | +identifier rc; | ||
156 | +position p : script:python() { p[0].current_element == "resettable_phase_exit" }; | ||
157 | +@@ | ||
158 | +- rc->phases.exit(obj)@p | ||
159 | ++ rc->phases.exit(obj, type) | ||
160 | +// Special case: the typedefs for the methods need to declare the new argument | ||
161 | +@ phase_typedef_hold @ | ||
162 | +identifier obj; | ||
163 | +@@ | ||
164 | +- typedef void (*ResettableHoldPhase)(Object *obj); | ||
165 | ++ typedef void (*ResettableHoldPhase)(Object *obj, ResetType type); | ||
166 | +@ phase_typedef_exit @ | ||
167 | +identifier obj; | ||
168 | +@@ | ||
169 | +- typedef void (*ResettableExitPhase)(Object *obj); | ||
170 | ++ typedef void (*ResettableExitPhase)(Object *obj, ResetType type); | ||
171 | -- | ||
172 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | We pass a ResetType argument to the Resettable class enter |
---|---|---|---|
2 | phase method, but we don't pass it to hold and exit, even though | ||
3 | the callsites have it readily available. This means that if | ||
4 | a device cared about the ResetType it would need to record it | ||
5 | in the enter phase method to use later on. Pass the type to | ||
6 | all three of the phase methods to avoid having to do that. | ||
2 | 7 | ||
3 | When the cpu support MTE, but the system does not, reduce cpu | 8 | Commit created with |
4 | support to user instructions at EL0 instead of completely | ||
5 | disabling MTE. If we encounter a cpu implementation which does | ||
6 | something else, we can revisit this setting. | ||
7 | 9 | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 10 | for dir in hw target include; do \ |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | spatch --macro-file scripts/cocci-macro-file.h \ |
10 | Message-id: 20230811214031.171020-5-richard.henderson@linaro.org | 12 | --sp-file scripts/coccinelle/reset-type.cocci \ |
13 | --keep-comments --smpl-spacing --in-place \ | ||
14 | --include-headers --dir $dir; done | ||
15 | |||
16 | and no manual edits. | ||
17 | |||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@amd.com> | ||
20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
21 | Reviewed-by: Luc Michel <luc.michel@amd.com> | ||
22 | Message-id: 20240412160809.1260625-5-peter.maydell@linaro.org | ||
12 | --- | 23 | --- |
13 | target/arm/cpu.c | 7 ++++--- | 24 | include/hw/resettable.h | 4 ++-- |
14 | 1 file changed, 4 insertions(+), 3 deletions(-) | 25 | hw/adc/npcm7xx_adc.c | 2 +- |
26 | hw/arm/pxa2xx_pic.c | 2 +- | ||
27 | hw/arm/smmu-common.c | 2 +- | ||
28 | hw/arm/smmuv3.c | 4 ++-- | ||
29 | hw/arm/stellaris.c | 10 +++++----- | ||
30 | hw/audio/asc.c | 2 +- | ||
31 | hw/char/cadence_uart.c | 2 +- | ||
32 | hw/char/sifive_uart.c | 2 +- | ||
33 | hw/core/cpu-common.c | 2 +- | ||
34 | hw/core/qdev.c | 4 ++-- | ||
35 | hw/core/reset.c | 2 +- | ||
36 | hw/core/resettable.c | 4 ++-- | ||
37 | hw/display/virtio-vga.c | 4 ++-- | ||
38 | hw/gpio/npcm7xx_gpio.c | 2 +- | ||
39 | hw/gpio/pl061.c | 2 +- | ||
40 | hw/gpio/stm32l4x5_gpio.c | 2 +- | ||
41 | hw/hyperv/vmbus.c | 2 +- | ||
42 | hw/i2c/allwinner-i2c.c | 2 +- | ||
43 | hw/i2c/npcm7xx_smbus.c | 2 +- | ||
44 | hw/input/adb.c | 2 +- | ||
45 | hw/input/ps2.c | 12 ++++++------ | ||
46 | hw/intc/arm_gic_common.c | 2 +- | ||
47 | hw/intc/arm_gic_kvm.c | 4 ++-- | ||
48 | hw/intc/arm_gicv3_common.c | 2 +- | ||
49 | hw/intc/arm_gicv3_its.c | 4 ++-- | ||
50 | hw/intc/arm_gicv3_its_common.c | 2 +- | ||
51 | hw/intc/arm_gicv3_its_kvm.c | 4 ++-- | ||
52 | hw/intc/arm_gicv3_kvm.c | 4 ++-- | ||
53 | hw/intc/xics.c | 2 +- | ||
54 | hw/m68k/q800-glue.c | 2 +- | ||
55 | hw/misc/djmemc.c | 2 +- | ||
56 | hw/misc/iosb.c | 2 +- | ||
57 | hw/misc/mac_via.c | 8 ++++---- | ||
58 | hw/misc/macio/cuda.c | 4 ++-- | ||
59 | hw/misc/macio/pmu.c | 4 ++-- | ||
60 | hw/misc/mos6522.c | 2 +- | ||
61 | hw/misc/npcm7xx_mft.c | 2 +- | ||
62 | hw/misc/npcm7xx_pwm.c | 2 +- | ||
63 | hw/misc/stm32l4x5_exti.c | 2 +- | ||
64 | hw/misc/stm32l4x5_rcc.c | 10 +++++----- | ||
65 | hw/misc/stm32l4x5_syscfg.c | 2 +- | ||
66 | hw/misc/xlnx-versal-cframe-reg.c | 2 +- | ||
67 | hw/misc/xlnx-versal-crl.c | 2 +- | ||
68 | hw/misc/xlnx-versal-pmc-iou-slcr.c | 2 +- | ||
69 | hw/misc/xlnx-versal-trng.c | 2 +- | ||
70 | hw/misc/xlnx-versal-xramc.c | 2 +- | ||
71 | hw/misc/xlnx-zynqmp-apu-ctrl.c | 2 +- | ||
72 | hw/misc/xlnx-zynqmp-crf.c | 2 +- | ||
73 | hw/misc/zynq_slcr.c | 4 ++-- | ||
74 | hw/net/can/xlnx-zynqmp-can.c | 2 +- | ||
75 | hw/net/e1000.c | 2 +- | ||
76 | hw/net/e1000e.c | 2 +- | ||
77 | hw/net/igb.c | 2 +- | ||
78 | hw/net/igbvf.c | 2 +- | ||
79 | hw/nvram/xlnx-bbram.c | 2 +- | ||
80 | hw/nvram/xlnx-versal-efuse-ctrl.c | 2 +- | ||
81 | hw/nvram/xlnx-zynqmp-efuse.c | 2 +- | ||
82 | hw/pci-bridge/cxl_root_port.c | 4 ++-- | ||
83 | hw/pci-bridge/pcie_root_port.c | 2 +- | ||
84 | hw/pci-host/bonito.c | 2 +- | ||
85 | hw/pci-host/pnv_phb.c | 4 ++-- | ||
86 | hw/pci-host/pnv_phb3_msi.c | 4 ++-- | ||
87 | hw/pci/pci.c | 4 ++-- | ||
88 | hw/rtc/mc146818rtc.c | 2 +- | ||
89 | hw/s390x/css-bridge.c | 2 +- | ||
90 | hw/sensor/adm1266.c | 2 +- | ||
91 | hw/sensor/adm1272.c | 2 +- | ||
92 | hw/sensor/isl_pmbus_vr.c | 10 +++++----- | ||
93 | hw/sensor/max31785.c | 2 +- | ||
94 | hw/sensor/max34451.c | 2 +- | ||
95 | hw/ssi/npcm7xx_fiu.c | 2 +- | ||
96 | hw/timer/etraxfs_timer.c | 2 +- | ||
97 | hw/timer/npcm7xx_timer.c | 2 +- | ||
98 | hw/usb/hcd-dwc2.c | 8 ++++---- | ||
99 | hw/usb/xlnx-versal-usb2-ctrl-regs.c | 2 +- | ||
100 | hw/virtio/virtio-pci.c | 2 +- | ||
101 | target/arm/cpu.c | 4 ++-- | ||
102 | target/avr/cpu.c | 4 ++-- | ||
103 | target/cris/cpu.c | 4 ++-- | ||
104 | target/hexagon/cpu.c | 4 ++-- | ||
105 | target/i386/cpu.c | 4 ++-- | ||
106 | target/loongarch/cpu.c | 4 ++-- | ||
107 | target/m68k/cpu.c | 4 ++-- | ||
108 | target/microblaze/cpu.c | 4 ++-- | ||
109 | target/mips/cpu.c | 4 ++-- | ||
110 | target/openrisc/cpu.c | 4 ++-- | ||
111 | target/ppc/cpu_init.c | 4 ++-- | ||
112 | target/riscv/cpu.c | 4 ++-- | ||
113 | target/rx/cpu.c | 4 ++-- | ||
114 | target/sh4/cpu.c | 4 ++-- | ||
115 | target/sparc/cpu.c | 4 ++-- | ||
116 | target/tricore/cpu.c | 4 ++-- | ||
117 | target/xtensa/cpu.c | 4 ++-- | ||
118 | 94 files changed, 150 insertions(+), 150 deletions(-) | ||
15 | 119 | ||
120 | diff --git a/include/hw/resettable.h b/include/hw/resettable.h | ||
121 | index XXXXXXX..XXXXXXX 100644 | ||
122 | --- a/include/hw/resettable.h | ||
123 | +++ b/include/hw/resettable.h | ||
124 | @@ -XXX,XX +XXX,XX @@ typedef enum ResetType { | ||
125 | * the callback. | ||
126 | */ | ||
127 | typedef void (*ResettableEnterPhase)(Object *obj, ResetType type); | ||
128 | -typedef void (*ResettableHoldPhase)(Object *obj); | ||
129 | -typedef void (*ResettableExitPhase)(Object *obj); | ||
130 | +typedef void (*ResettableHoldPhase)(Object *obj, ResetType type); | ||
131 | +typedef void (*ResettableExitPhase)(Object *obj, ResetType type); | ||
132 | typedef ResettableState * (*ResettableGetState)(Object *obj); | ||
133 | typedef void (*ResettableTrFunction)(Object *obj); | ||
134 | typedef ResettableTrFunction (*ResettableGetTrFunction)(Object *obj); | ||
135 | diff --git a/hw/adc/npcm7xx_adc.c b/hw/adc/npcm7xx_adc.c | ||
136 | index XXXXXXX..XXXXXXX 100644 | ||
137 | --- a/hw/adc/npcm7xx_adc.c | ||
138 | +++ b/hw/adc/npcm7xx_adc.c | ||
139 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_adc_enter_reset(Object *obj, ResetType type) | ||
140 | npcm7xx_adc_reset(s); | ||
141 | } | ||
142 | |||
143 | -static void npcm7xx_adc_hold_reset(Object *obj) | ||
144 | +static void npcm7xx_adc_hold_reset(Object *obj, ResetType type) | ||
145 | { | ||
146 | NPCM7xxADCState *s = NPCM7XX_ADC(obj); | ||
147 | |||
148 | diff --git a/hw/arm/pxa2xx_pic.c b/hw/arm/pxa2xx_pic.c | ||
149 | index XXXXXXX..XXXXXXX 100644 | ||
150 | --- a/hw/arm/pxa2xx_pic.c | ||
151 | +++ b/hw/arm/pxa2xx_pic.c | ||
152 | @@ -XXX,XX +XXX,XX @@ static int pxa2xx_pic_post_load(void *opaque, int version_id) | ||
153 | return 0; | ||
154 | } | ||
155 | |||
156 | -static void pxa2xx_pic_reset_hold(Object *obj) | ||
157 | +static void pxa2xx_pic_reset_hold(Object *obj, ResetType type) | ||
158 | { | ||
159 | PXA2xxPICState *s = PXA2XX_PIC(obj); | ||
160 | |||
161 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c | ||
162 | index XXXXXXX..XXXXXXX 100644 | ||
163 | --- a/hw/arm/smmu-common.c | ||
164 | +++ b/hw/arm/smmu-common.c | ||
165 | @@ -XXX,XX +XXX,XX @@ static void smmu_base_realize(DeviceState *dev, Error **errp) | ||
166 | } | ||
167 | } | ||
168 | |||
169 | -static void smmu_base_reset_hold(Object *obj) | ||
170 | +static void smmu_base_reset_hold(Object *obj, ResetType type) | ||
171 | { | ||
172 | SMMUState *s = ARM_SMMU(obj); | ||
173 | |||
174 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | ||
175 | index XXXXXXX..XXXXXXX 100644 | ||
176 | --- a/hw/arm/smmuv3.c | ||
177 | +++ b/hw/arm/smmuv3.c | ||
178 | @@ -XXX,XX +XXX,XX @@ static void smmu_init_irq(SMMUv3State *s, SysBusDevice *dev) | ||
179 | } | ||
180 | } | ||
181 | |||
182 | -static void smmu_reset_hold(Object *obj) | ||
183 | +static void smmu_reset_hold(Object *obj, ResetType type) | ||
184 | { | ||
185 | SMMUv3State *s = ARM_SMMUV3(obj); | ||
186 | SMMUv3Class *c = ARM_SMMUV3_GET_CLASS(s); | ||
187 | |||
188 | if (c->parent_phases.hold) { | ||
189 | - c->parent_phases.hold(obj); | ||
190 | + c->parent_phases.hold(obj, type); | ||
191 | } | ||
192 | |||
193 | smmuv3_init_regs(s); | ||
194 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | ||
195 | index XXXXXXX..XXXXXXX 100644 | ||
196 | --- a/hw/arm/stellaris.c | ||
197 | +++ b/hw/arm/stellaris.c | ||
198 | @@ -XXX,XX +XXX,XX @@ static void stellaris_sys_reset_enter(Object *obj, ResetType type) | ||
199 | s->dcgc[0] = 1; | ||
200 | } | ||
201 | |||
202 | -static void stellaris_sys_reset_hold(Object *obj) | ||
203 | +static void stellaris_sys_reset_hold(Object *obj, ResetType type) | ||
204 | { | ||
205 | ssys_state *s = STELLARIS_SYS(obj); | ||
206 | |||
207 | @@ -XXX,XX +XXX,XX @@ static void stellaris_sys_reset_hold(Object *obj) | ||
208 | ssys_calculate_system_clock(s, true); | ||
209 | } | ||
210 | |||
211 | -static void stellaris_sys_reset_exit(Object *obj) | ||
212 | +static void stellaris_sys_reset_exit(Object *obj, ResetType type) | ||
213 | { | ||
214 | } | ||
215 | |||
216 | @@ -XXX,XX +XXX,XX @@ static void stellaris_i2c_reset_enter(Object *obj, ResetType type) | ||
217 | i2c_end_transfer(s->bus); | ||
218 | } | ||
219 | |||
220 | -static void stellaris_i2c_reset_hold(Object *obj) | ||
221 | +static void stellaris_i2c_reset_hold(Object *obj, ResetType type) | ||
222 | { | ||
223 | stellaris_i2c_state *s = STELLARIS_I2C(obj); | ||
224 | |||
225 | @@ -XXX,XX +XXX,XX @@ static void stellaris_i2c_reset_hold(Object *obj) | ||
226 | s->mcr = 0; | ||
227 | } | ||
228 | |||
229 | -static void stellaris_i2c_reset_exit(Object *obj) | ||
230 | +static void stellaris_i2c_reset_exit(Object *obj, ResetType type) | ||
231 | { | ||
232 | stellaris_i2c_state *s = STELLARIS_I2C(obj); | ||
233 | |||
234 | @@ -XXX,XX +XXX,XX @@ static void stellaris_adc_trigger(void *opaque, int irq, int level) | ||
235 | } | ||
236 | } | ||
237 | |||
238 | -static void stellaris_adc_reset_hold(Object *obj) | ||
239 | +static void stellaris_adc_reset_hold(Object *obj, ResetType type) | ||
240 | { | ||
241 | StellarisADCState *s = STELLARIS_ADC(obj); | ||
242 | int n; | ||
243 | diff --git a/hw/audio/asc.c b/hw/audio/asc.c | ||
244 | index XXXXXXX..XXXXXXX 100644 | ||
245 | --- a/hw/audio/asc.c | ||
246 | +++ b/hw/audio/asc.c | ||
247 | @@ -XXX,XX +XXX,XX @@ static void asc_fifo_init(ASCFIFOState *fs, int index) | ||
248 | g_free(name); | ||
249 | } | ||
250 | |||
251 | -static void asc_reset_hold(Object *obj) | ||
252 | +static void asc_reset_hold(Object *obj, ResetType type) | ||
253 | { | ||
254 | ASCState *s = ASC(obj); | ||
255 | |||
256 | diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c | ||
257 | index XXXXXXX..XXXXXXX 100644 | ||
258 | --- a/hw/char/cadence_uart.c | ||
259 | +++ b/hw/char/cadence_uart.c | ||
260 | @@ -XXX,XX +XXX,XX @@ static void cadence_uart_reset_init(Object *obj, ResetType type) | ||
261 | s->r[R_TTRIG] = 0x00000020; | ||
262 | } | ||
263 | |||
264 | -static void cadence_uart_reset_hold(Object *obj) | ||
265 | +static void cadence_uart_reset_hold(Object *obj, ResetType type) | ||
266 | { | ||
267 | CadenceUARTState *s = CADENCE_UART(obj); | ||
268 | |||
269 | diff --git a/hw/char/sifive_uart.c b/hw/char/sifive_uart.c | ||
270 | index XXXXXXX..XXXXXXX 100644 | ||
271 | --- a/hw/char/sifive_uart.c | ||
272 | +++ b/hw/char/sifive_uart.c | ||
273 | @@ -XXX,XX +XXX,XX @@ static void sifive_uart_reset_enter(Object *obj, ResetType type) | ||
274 | s->rx_fifo_len = 0; | ||
275 | } | ||
276 | |||
277 | -static void sifive_uart_reset_hold(Object *obj) | ||
278 | +static void sifive_uart_reset_hold(Object *obj, ResetType type) | ||
279 | { | ||
280 | SiFiveUARTState *s = SIFIVE_UART(obj); | ||
281 | qemu_irq_lower(s->irq); | ||
282 | diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c | ||
283 | index XXXXXXX..XXXXXXX 100644 | ||
284 | --- a/hw/core/cpu-common.c | ||
285 | +++ b/hw/core/cpu-common.c | ||
286 | @@ -XXX,XX +XXX,XX @@ void cpu_reset(CPUState *cpu) | ||
287 | trace_cpu_reset(cpu->cpu_index); | ||
288 | } | ||
289 | |||
290 | -static void cpu_common_reset_hold(Object *obj) | ||
291 | +static void cpu_common_reset_hold(Object *obj, ResetType type) | ||
292 | { | ||
293 | CPUState *cpu = CPU(obj); | ||
294 | CPUClass *cc = CPU_GET_CLASS(cpu); | ||
295 | diff --git a/hw/core/qdev.c b/hw/core/qdev.c | ||
296 | index XXXXXXX..XXXXXXX 100644 | ||
297 | --- a/hw/core/qdev.c | ||
298 | +++ b/hw/core/qdev.c | ||
299 | @@ -XXX,XX +XXX,XX @@ static void device_phases_reset(DeviceState *dev) | ||
300 | rc->phases.enter(OBJECT(dev), RESET_TYPE_COLD); | ||
301 | } | ||
302 | if (rc->phases.hold) { | ||
303 | - rc->phases.hold(OBJECT(dev)); | ||
304 | + rc->phases.hold(OBJECT(dev), RESET_TYPE_COLD); | ||
305 | } | ||
306 | if (rc->phases.exit) { | ||
307 | - rc->phases.exit(OBJECT(dev)); | ||
308 | + rc->phases.exit(OBJECT(dev), RESET_TYPE_COLD); | ||
309 | } | ||
310 | } | ||
311 | |||
312 | diff --git a/hw/core/reset.c b/hw/core/reset.c | ||
313 | index XXXXXXX..XXXXXXX 100644 | ||
314 | --- a/hw/core/reset.c | ||
315 | +++ b/hw/core/reset.c | ||
316 | @@ -XXX,XX +XXX,XX @@ static ResettableState *legacy_reset_get_state(Object *obj) | ||
317 | return &lr->reset_state; | ||
318 | } | ||
319 | |||
320 | -static void legacy_reset_hold(Object *obj) | ||
321 | +static void legacy_reset_hold(Object *obj, ResetType type) | ||
322 | { | ||
323 | LegacyReset *lr = LEGACY_RESET(obj); | ||
324 | |||
325 | diff --git a/hw/core/resettable.c b/hw/core/resettable.c | ||
326 | index XXXXXXX..XXXXXXX 100644 | ||
327 | --- a/hw/core/resettable.c | ||
328 | +++ b/hw/core/resettable.c | ||
329 | @@ -XXX,XX +XXX,XX @@ static void resettable_phase_hold(Object *obj, void *opaque, ResetType type) | ||
330 | trace_resettable_transitional_function(obj, obj_typename); | ||
331 | tr_func(obj); | ||
332 | } else if (rc->phases.hold) { | ||
333 | - rc->phases.hold(obj); | ||
334 | + rc->phases.hold(obj, type); | ||
335 | } | ||
336 | } | ||
337 | trace_resettable_phase_hold_end(obj, obj_typename, s->count); | ||
338 | @@ -XXX,XX +XXX,XX @@ static void resettable_phase_exit(Object *obj, void *opaque, ResetType type) | ||
339 | if (--s->count == 0) { | ||
340 | trace_resettable_phase_exit_exec(obj, obj_typename, !!rc->phases.exit); | ||
341 | if (rc->phases.exit && !resettable_get_tr_func(rc, obj)) { | ||
342 | - rc->phases.exit(obj); | ||
343 | + rc->phases.exit(obj, type); | ||
344 | } | ||
345 | } | ||
346 | s->exit_phase_in_progress = false; | ||
347 | diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c | ||
348 | index XXXXXXX..XXXXXXX 100644 | ||
349 | --- a/hw/display/virtio-vga.c | ||
350 | +++ b/hw/display/virtio-vga.c | ||
351 | @@ -XXX,XX +XXX,XX @@ static void virtio_vga_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp) | ||
352 | } | ||
353 | } | ||
354 | |||
355 | -static void virtio_vga_base_reset_hold(Object *obj) | ||
356 | +static void virtio_vga_base_reset_hold(Object *obj, ResetType type) | ||
357 | { | ||
358 | VirtIOVGABaseClass *klass = VIRTIO_VGA_BASE_GET_CLASS(obj); | ||
359 | VirtIOVGABase *vvga = VIRTIO_VGA_BASE(obj); | ||
360 | |||
361 | /* reset virtio-gpu */ | ||
362 | if (klass->parent_phases.hold) { | ||
363 | - klass->parent_phases.hold(obj); | ||
364 | + klass->parent_phases.hold(obj, type); | ||
365 | } | ||
366 | |||
367 | /* reset vga */ | ||
368 | diff --git a/hw/gpio/npcm7xx_gpio.c b/hw/gpio/npcm7xx_gpio.c | ||
369 | index XXXXXXX..XXXXXXX 100644 | ||
370 | --- a/hw/gpio/npcm7xx_gpio.c | ||
371 | +++ b/hw/gpio/npcm7xx_gpio.c | ||
372 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_gpio_enter_reset(Object *obj, ResetType type) | ||
373 | s->regs[NPCM7XX_GPIO_ODSC] = s->reset_odsc; | ||
374 | } | ||
375 | |||
376 | -static void npcm7xx_gpio_hold_reset(Object *obj) | ||
377 | +static void npcm7xx_gpio_hold_reset(Object *obj, ResetType type) | ||
378 | { | ||
379 | NPCM7xxGPIOState *s = NPCM7XX_GPIO(obj); | ||
380 | |||
381 | diff --git a/hw/gpio/pl061.c b/hw/gpio/pl061.c | ||
382 | index XXXXXXX..XXXXXXX 100644 | ||
383 | --- a/hw/gpio/pl061.c | ||
384 | +++ b/hw/gpio/pl061.c | ||
385 | @@ -XXX,XX +XXX,XX @@ static void pl061_enter_reset(Object *obj, ResetType type) | ||
386 | s->amsel = 0; | ||
387 | } | ||
388 | |||
389 | -static void pl061_hold_reset(Object *obj) | ||
390 | +static void pl061_hold_reset(Object *obj, ResetType type) | ||
391 | { | ||
392 | PL061State *s = PL061(obj); | ||
393 | int i, level; | ||
394 | diff --git a/hw/gpio/stm32l4x5_gpio.c b/hw/gpio/stm32l4x5_gpio.c | ||
395 | index XXXXXXX..XXXXXXX 100644 | ||
396 | --- a/hw/gpio/stm32l4x5_gpio.c | ||
397 | +++ b/hw/gpio/stm32l4x5_gpio.c | ||
398 | @@ -XXX,XX +XXX,XX @@ static bool is_push_pull(Stm32l4x5GpioState *s, unsigned pin) | ||
399 | return extract32(s->otyper, pin, 1) == 0; | ||
400 | } | ||
401 | |||
402 | -static void stm32l4x5_gpio_reset_hold(Object *obj) | ||
403 | +static void stm32l4x5_gpio_reset_hold(Object *obj, ResetType type) | ||
404 | { | ||
405 | Stm32l4x5GpioState *s = STM32L4X5_GPIO(obj); | ||
406 | |||
407 | diff --git a/hw/hyperv/vmbus.c b/hw/hyperv/vmbus.c | ||
408 | index XXXXXXX..XXXXXXX 100644 | ||
409 | --- a/hw/hyperv/vmbus.c | ||
410 | +++ b/hw/hyperv/vmbus.c | ||
411 | @@ -XXX,XX +XXX,XX @@ static void vmbus_unrealize(BusState *bus) | ||
412 | qemu_mutex_destroy(&vmbus->rx_queue_lock); | ||
413 | } | ||
414 | |||
415 | -static void vmbus_reset_hold(Object *obj) | ||
416 | +static void vmbus_reset_hold(Object *obj, ResetType type) | ||
417 | { | ||
418 | vmbus_deinit(VMBUS(obj)); | ||
419 | } | ||
420 | diff --git a/hw/i2c/allwinner-i2c.c b/hw/i2c/allwinner-i2c.c | ||
421 | index XXXXXXX..XXXXXXX 100644 | ||
422 | --- a/hw/i2c/allwinner-i2c.c | ||
423 | +++ b/hw/i2c/allwinner-i2c.c | ||
424 | @@ -XXX,XX +XXX,XX @@ static inline bool allwinner_i2c_interrupt_is_enabled(AWI2CState *s) | ||
425 | return s->cntr & TWI_CNTR_INT_EN; | ||
426 | } | ||
427 | |||
428 | -static void allwinner_i2c_reset_hold(Object *obj) | ||
429 | +static void allwinner_i2c_reset_hold(Object *obj, ResetType type) | ||
430 | { | ||
431 | AWI2CState *s = AW_I2C(obj); | ||
432 | |||
433 | diff --git a/hw/i2c/npcm7xx_smbus.c b/hw/i2c/npcm7xx_smbus.c | ||
434 | index XXXXXXX..XXXXXXX 100644 | ||
435 | --- a/hw/i2c/npcm7xx_smbus.c | ||
436 | +++ b/hw/i2c/npcm7xx_smbus.c | ||
437 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_smbus_enter_reset(Object *obj, ResetType type) | ||
438 | s->rx_cur = 0; | ||
439 | } | ||
440 | |||
441 | -static void npcm7xx_smbus_hold_reset(Object *obj) | ||
442 | +static void npcm7xx_smbus_hold_reset(Object *obj, ResetType type) | ||
443 | { | ||
444 | NPCM7xxSMBusState *s = NPCM7XX_SMBUS(obj); | ||
445 | |||
446 | diff --git a/hw/input/adb.c b/hw/input/adb.c | ||
447 | index XXXXXXX..XXXXXXX 100644 | ||
448 | --- a/hw/input/adb.c | ||
449 | +++ b/hw/input/adb.c | ||
450 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_adb_bus = { | ||
451 | } | ||
452 | }; | ||
453 | |||
454 | -static void adb_bus_reset_hold(Object *obj) | ||
455 | +static void adb_bus_reset_hold(Object *obj, ResetType type) | ||
456 | { | ||
457 | ADBBusState *adb_bus = ADB_BUS(obj); | ||
458 | |||
459 | diff --git a/hw/input/ps2.c b/hw/input/ps2.c | ||
460 | index XXXXXXX..XXXXXXX 100644 | ||
461 | --- a/hw/input/ps2.c | ||
462 | +++ b/hw/input/ps2.c | ||
463 | @@ -XXX,XX +XXX,XX @@ void ps2_write_mouse(PS2MouseState *s, int val) | ||
464 | } | ||
465 | } | ||
466 | |||
467 | -static void ps2_reset_hold(Object *obj) | ||
468 | +static void ps2_reset_hold(Object *obj, ResetType type) | ||
469 | { | ||
470 | PS2State *s = PS2_DEVICE(obj); | ||
471 | |||
472 | @@ -XXX,XX +XXX,XX @@ static void ps2_reset_hold(Object *obj) | ||
473 | ps2_reset_queue(s); | ||
474 | } | ||
475 | |||
476 | -static void ps2_reset_exit(Object *obj) | ||
477 | +static void ps2_reset_exit(Object *obj, ResetType type) | ||
478 | { | ||
479 | PS2State *s = PS2_DEVICE(obj); | ||
480 | |||
481 | @@ -XXX,XX +XXX,XX @@ static void ps2_common_post_load(PS2State *s) | ||
482 | q->cwptr = ccount ? (q->rptr + ccount) & (PS2_BUFFER_SIZE - 1) : -1; | ||
483 | } | ||
484 | |||
485 | -static void ps2_kbd_reset_hold(Object *obj) | ||
486 | +static void ps2_kbd_reset_hold(Object *obj, ResetType type) | ||
487 | { | ||
488 | PS2DeviceClass *ps2dc = PS2_DEVICE_GET_CLASS(obj); | ||
489 | PS2KbdState *s = PS2_KBD_DEVICE(obj); | ||
490 | @@ -XXX,XX +XXX,XX @@ static void ps2_kbd_reset_hold(Object *obj) | ||
491 | trace_ps2_kbd_reset(s); | ||
492 | |||
493 | if (ps2dc->parent_phases.hold) { | ||
494 | - ps2dc->parent_phases.hold(obj); | ||
495 | + ps2dc->parent_phases.hold(obj, type); | ||
496 | } | ||
497 | |||
498 | s->scan_enabled = 1; | ||
499 | @@ -XXX,XX +XXX,XX @@ static void ps2_kbd_reset_hold(Object *obj) | ||
500 | s->modifiers = 0; | ||
501 | } | ||
502 | |||
503 | -static void ps2_mouse_reset_hold(Object *obj) | ||
504 | +static void ps2_mouse_reset_hold(Object *obj, ResetType type) | ||
505 | { | ||
506 | PS2DeviceClass *ps2dc = PS2_DEVICE_GET_CLASS(obj); | ||
507 | PS2MouseState *s = PS2_MOUSE_DEVICE(obj); | ||
508 | @@ -XXX,XX +XXX,XX @@ static void ps2_mouse_reset_hold(Object *obj) | ||
509 | trace_ps2_mouse_reset(s); | ||
510 | |||
511 | if (ps2dc->parent_phases.hold) { | ||
512 | - ps2dc->parent_phases.hold(obj); | ||
513 | + ps2dc->parent_phases.hold(obj, type); | ||
514 | } | ||
515 | |||
516 | s->mouse_status = 0; | ||
517 | diff --git a/hw/intc/arm_gic_common.c b/hw/intc/arm_gic_common.c | ||
518 | index XXXXXXX..XXXXXXX 100644 | ||
519 | --- a/hw/intc/arm_gic_common.c | ||
520 | +++ b/hw/intc/arm_gic_common.c | ||
521 | @@ -XXX,XX +XXX,XX @@ static inline void arm_gic_common_reset_irq_state(GICState *s, int cidx, | ||
522 | } | ||
523 | } | ||
524 | |||
525 | -static void arm_gic_common_reset_hold(Object *obj) | ||
526 | +static void arm_gic_common_reset_hold(Object *obj, ResetType type) | ||
527 | { | ||
528 | GICState *s = ARM_GIC_COMMON(obj); | ||
529 | int i, j; | ||
530 | diff --git a/hw/intc/arm_gic_kvm.c b/hw/intc/arm_gic_kvm.c | ||
531 | index XXXXXXX..XXXXXXX 100644 | ||
532 | --- a/hw/intc/arm_gic_kvm.c | ||
533 | +++ b/hw/intc/arm_gic_kvm.c | ||
534 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gic_get(GICState *s) | ||
535 | } | ||
536 | } | ||
537 | |||
538 | -static void kvm_arm_gic_reset_hold(Object *obj) | ||
539 | +static void kvm_arm_gic_reset_hold(Object *obj, ResetType type) | ||
540 | { | ||
541 | GICState *s = ARM_GIC_COMMON(obj); | ||
542 | KVMARMGICClass *kgc = KVM_ARM_GIC_GET_CLASS(s); | ||
543 | |||
544 | if (kgc->parent_phases.hold) { | ||
545 | - kgc->parent_phases.hold(obj); | ||
546 | + kgc->parent_phases.hold(obj, type); | ||
547 | } | ||
548 | |||
549 | if (kvm_arm_gic_can_save_restore(s)) { | ||
550 | diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c | ||
551 | index XXXXXXX..XXXXXXX 100644 | ||
552 | --- a/hw/intc/arm_gicv3_common.c | ||
553 | +++ b/hw/intc/arm_gicv3_common.c | ||
554 | @@ -XXX,XX +XXX,XX @@ static void arm_gicv3_finalize(Object *obj) | ||
555 | g_free(s->redist_region_count); | ||
556 | } | ||
557 | |||
558 | -static void arm_gicv3_common_reset_hold(Object *obj) | ||
559 | +static void arm_gicv3_common_reset_hold(Object *obj, ResetType type) | ||
560 | { | ||
561 | GICv3State *s = ARM_GICV3_COMMON(obj); | ||
562 | int i; | ||
563 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | ||
564 | index XXXXXXX..XXXXXXX 100644 | ||
565 | --- a/hw/intc/arm_gicv3_its.c | ||
566 | +++ b/hw/intc/arm_gicv3_its.c | ||
567 | @@ -XXX,XX +XXX,XX @@ static void gicv3_arm_its_realize(DeviceState *dev, Error **errp) | ||
568 | } | ||
569 | } | ||
570 | |||
571 | -static void gicv3_its_reset_hold(Object *obj) | ||
572 | +static void gicv3_its_reset_hold(Object *obj, ResetType type) | ||
573 | { | ||
574 | GICv3ITSState *s = ARM_GICV3_ITS_COMMON(obj); | ||
575 | GICv3ITSClass *c = ARM_GICV3_ITS_GET_CLASS(s); | ||
576 | |||
577 | if (c->parent_phases.hold) { | ||
578 | - c->parent_phases.hold(obj); | ||
579 | + c->parent_phases.hold(obj, type); | ||
580 | } | ||
581 | |||
582 | /* Quiescent bit reset to 1 */ | ||
583 | diff --git a/hw/intc/arm_gicv3_its_common.c b/hw/intc/arm_gicv3_its_common.c | ||
584 | index XXXXXXX..XXXXXXX 100644 | ||
585 | --- a/hw/intc/arm_gicv3_its_common.c | ||
586 | +++ b/hw/intc/arm_gicv3_its_common.c | ||
587 | @@ -XXX,XX +XXX,XX @@ void gicv3_its_init_mmio(GICv3ITSState *s, const MemoryRegionOps *ops, | ||
588 | msi_nonbroken = true; | ||
589 | } | ||
590 | |||
591 | -static void gicv3_its_common_reset_hold(Object *obj) | ||
592 | +static void gicv3_its_common_reset_hold(Object *obj, ResetType type) | ||
593 | { | ||
594 | GICv3ITSState *s = ARM_GICV3_ITS_COMMON(obj); | ||
595 | |||
596 | diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c | ||
597 | index XXXXXXX..XXXXXXX 100644 | ||
598 | --- a/hw/intc/arm_gicv3_its_kvm.c | ||
599 | +++ b/hw/intc/arm_gicv3_its_kvm.c | ||
600 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_its_post_load(GICv3ITSState *s) | ||
601 | GITS_CTLR, &s->ctlr, true, &error_abort); | ||
602 | } | ||
603 | |||
604 | -static void kvm_arm_its_reset_hold(Object *obj) | ||
605 | +static void kvm_arm_its_reset_hold(Object *obj, ResetType type) | ||
606 | { | ||
607 | GICv3ITSState *s = ARM_GICV3_ITS_COMMON(obj); | ||
608 | KVMARMITSClass *c = KVM_ARM_ITS_GET_CLASS(s); | ||
609 | int i; | ||
610 | |||
611 | if (c->parent_phases.hold) { | ||
612 | - c->parent_phases.hold(obj); | ||
613 | + c->parent_phases.hold(obj, type); | ||
614 | } | ||
615 | |||
616 | if (kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, | ||
617 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | ||
618 | index XXXXXXX..XXXXXXX 100644 | ||
619 | --- a/hw/intc/arm_gicv3_kvm.c | ||
620 | +++ b/hw/intc/arm_gicv3_kvm.c | ||
621 | @@ -XXX,XX +XXX,XX @@ static void arm_gicv3_icc_reset(CPUARMState *env, const ARMCPRegInfo *ri) | ||
622 | c->icc_ctlr_el1[GICV3_S] = c->icc_ctlr_el1[GICV3_NS]; | ||
623 | } | ||
624 | |||
625 | -static void kvm_arm_gicv3_reset_hold(Object *obj) | ||
626 | +static void kvm_arm_gicv3_reset_hold(Object *obj, ResetType type) | ||
627 | { | ||
628 | GICv3State *s = ARM_GICV3_COMMON(obj); | ||
629 | KVMARMGICv3Class *kgc = KVM_ARM_GICV3_GET_CLASS(s); | ||
630 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_reset_hold(Object *obj) | ||
631 | DPRINTF("Reset\n"); | ||
632 | |||
633 | if (kgc->parent_phases.hold) { | ||
634 | - kgc->parent_phases.hold(obj); | ||
635 | + kgc->parent_phases.hold(obj, type); | ||
636 | } | ||
637 | |||
638 | if (s->migration_blocker) { | ||
639 | diff --git a/hw/intc/xics.c b/hw/intc/xics.c | ||
640 | index XXXXXXX..XXXXXXX 100644 | ||
641 | --- a/hw/intc/xics.c | ||
642 | +++ b/hw/intc/xics.c | ||
643 | @@ -XXX,XX +XXX,XX @@ static void ics_reset_irq(ICSIRQState *irq) | ||
644 | irq->saved_priority = 0xff; | ||
645 | } | ||
646 | |||
647 | -static void ics_reset_hold(Object *obj) | ||
648 | +static void ics_reset_hold(Object *obj, ResetType type) | ||
649 | { | ||
650 | ICSState *ics = ICS(obj); | ||
651 | g_autofree uint8_t *flags = g_malloc(ics->nr_irqs); | ||
652 | diff --git a/hw/m68k/q800-glue.c b/hw/m68k/q800-glue.c | ||
653 | index XXXXXXX..XXXXXXX 100644 | ||
654 | --- a/hw/m68k/q800-glue.c | ||
655 | +++ b/hw/m68k/q800-glue.c | ||
656 | @@ -XXX,XX +XXX,XX @@ static void glue_nmi_release(void *opaque) | ||
657 | GLUE_set_irq(s, GLUE_IRQ_IN_NMI, 0); | ||
658 | } | ||
659 | |||
660 | -static void glue_reset_hold(Object *obj) | ||
661 | +static void glue_reset_hold(Object *obj, ResetType type) | ||
662 | { | ||
663 | GLUEState *s = GLUE(obj); | ||
664 | |||
665 | diff --git a/hw/misc/djmemc.c b/hw/misc/djmemc.c | ||
666 | index XXXXXXX..XXXXXXX 100644 | ||
667 | --- a/hw/misc/djmemc.c | ||
668 | +++ b/hw/misc/djmemc.c | ||
669 | @@ -XXX,XX +XXX,XX @@ static void djmemc_init(Object *obj) | ||
670 | sysbus_init_mmio(sbd, &s->mem_regs); | ||
671 | } | ||
672 | |||
673 | -static void djmemc_reset_hold(Object *obj) | ||
674 | +static void djmemc_reset_hold(Object *obj, ResetType type) | ||
675 | { | ||
676 | DJMEMCState *s = DJMEMC(obj); | ||
677 | |||
678 | diff --git a/hw/misc/iosb.c b/hw/misc/iosb.c | ||
679 | index XXXXXXX..XXXXXXX 100644 | ||
680 | --- a/hw/misc/iosb.c | ||
681 | +++ b/hw/misc/iosb.c | ||
682 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps iosb_mmio_ops = { | ||
683 | .endianness = DEVICE_BIG_ENDIAN, | ||
684 | }; | ||
685 | |||
686 | -static void iosb_reset_hold(Object *obj) | ||
687 | +static void iosb_reset_hold(Object *obj, ResetType type) | ||
688 | { | ||
689 | IOSBState *s = IOSB(obj); | ||
690 | |||
691 | diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c | ||
692 | index XXXXXXX..XXXXXXX 100644 | ||
693 | --- a/hw/misc/mac_via.c | ||
694 | +++ b/hw/misc/mac_via.c | ||
695 | @@ -XXX,XX +XXX,XX @@ static int via1_post_load(void *opaque, int version_id) | ||
696 | } | ||
697 | |||
698 | /* VIA 1 */ | ||
699 | -static void mos6522_q800_via1_reset_hold(Object *obj) | ||
700 | +static void mos6522_q800_via1_reset_hold(Object *obj, ResetType type) | ||
701 | { | ||
702 | MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(obj); | ||
703 | MOS6522State *ms = MOS6522(v1s); | ||
704 | @@ -XXX,XX +XXX,XX @@ static void mos6522_q800_via1_reset_hold(Object *obj) | ||
705 | ADBBusState *adb_bus = &v1s->adb_bus; | ||
706 | |||
707 | if (mdc->parent_phases.hold) { | ||
708 | - mdc->parent_phases.hold(obj); | ||
709 | + mdc->parent_phases.hold(obj, type); | ||
710 | } | ||
711 | |||
712 | ms->timers[0].frequency = VIA_TIMER_FREQ; | ||
713 | @@ -XXX,XX +XXX,XX @@ static void mos6522_q800_via2_portB_write(MOS6522State *s) | ||
714 | } | ||
715 | } | ||
716 | |||
717 | -static void mos6522_q800_via2_reset_hold(Object *obj) | ||
718 | +static void mos6522_q800_via2_reset_hold(Object *obj, ResetType type) | ||
719 | { | ||
720 | MOS6522State *ms = MOS6522(obj); | ||
721 | MOS6522DeviceClass *mdc = MOS6522_GET_CLASS(ms); | ||
722 | |||
723 | if (mdc->parent_phases.hold) { | ||
724 | - mdc->parent_phases.hold(obj); | ||
725 | + mdc->parent_phases.hold(obj, type); | ||
726 | } | ||
727 | |||
728 | ms->timers[0].frequency = VIA_TIMER_FREQ; | ||
729 | diff --git a/hw/misc/macio/cuda.c b/hw/misc/macio/cuda.c | ||
730 | index XXXXXXX..XXXXXXX 100644 | ||
731 | --- a/hw/misc/macio/cuda.c | ||
732 | +++ b/hw/misc/macio/cuda.c | ||
733 | @@ -XXX,XX +XXX,XX @@ static void mos6522_cuda_portB_write(MOS6522State *s) | ||
734 | cuda_update(cs); | ||
735 | } | ||
736 | |||
737 | -static void mos6522_cuda_reset_hold(Object *obj) | ||
738 | +static void mos6522_cuda_reset_hold(Object *obj, ResetType type) | ||
739 | { | ||
740 | MOS6522State *ms = MOS6522(obj); | ||
741 | MOS6522DeviceClass *mdc = MOS6522_GET_CLASS(ms); | ||
742 | |||
743 | if (mdc->parent_phases.hold) { | ||
744 | - mdc->parent_phases.hold(obj); | ||
745 | + mdc->parent_phases.hold(obj, type); | ||
746 | } | ||
747 | |||
748 | ms->timers[0].frequency = CUDA_TIMER_FREQ; | ||
749 | diff --git a/hw/misc/macio/pmu.c b/hw/misc/macio/pmu.c | ||
750 | index XXXXXXX..XXXXXXX 100644 | ||
751 | --- a/hw/misc/macio/pmu.c | ||
752 | +++ b/hw/misc/macio/pmu.c | ||
753 | @@ -XXX,XX +XXX,XX @@ static void mos6522_pmu_portB_write(MOS6522State *s) | ||
754 | pmu_update(ps); | ||
755 | } | ||
756 | |||
757 | -static void mos6522_pmu_reset_hold(Object *obj) | ||
758 | +static void mos6522_pmu_reset_hold(Object *obj, ResetType type) | ||
759 | { | ||
760 | MOS6522State *ms = MOS6522(obj); | ||
761 | MOS6522PMUState *mps = container_of(ms, MOS6522PMUState, parent_obj); | ||
762 | @@ -XXX,XX +XXX,XX @@ static void mos6522_pmu_reset_hold(Object *obj) | ||
763 | MOS6522DeviceClass *mdc = MOS6522_GET_CLASS(ms); | ||
764 | |||
765 | if (mdc->parent_phases.hold) { | ||
766 | - mdc->parent_phases.hold(obj); | ||
767 | + mdc->parent_phases.hold(obj, type); | ||
768 | } | ||
769 | |||
770 | ms->timers[0].frequency = VIA_TIMER_FREQ; | ||
771 | diff --git a/hw/misc/mos6522.c b/hw/misc/mos6522.c | ||
772 | index XXXXXXX..XXXXXXX 100644 | ||
773 | --- a/hw/misc/mos6522.c | ||
774 | +++ b/hw/misc/mos6522.c | ||
775 | @@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_mos6522 = { | ||
776 | } | ||
777 | }; | ||
778 | |||
779 | -static void mos6522_reset_hold(Object *obj) | ||
780 | +static void mos6522_reset_hold(Object *obj, ResetType type) | ||
781 | { | ||
782 | MOS6522State *s = MOS6522(obj); | ||
783 | |||
784 | diff --git a/hw/misc/npcm7xx_mft.c b/hw/misc/npcm7xx_mft.c | ||
785 | index XXXXXXX..XXXXXXX 100644 | ||
786 | --- a/hw/misc/npcm7xx_mft.c | ||
787 | +++ b/hw/misc/npcm7xx_mft.c | ||
788 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_mft_enter_reset(Object *obj, ResetType type) | ||
789 | npcm7xx_mft_reset(s); | ||
790 | } | ||
791 | |||
792 | -static void npcm7xx_mft_hold_reset(Object *obj) | ||
793 | +static void npcm7xx_mft_hold_reset(Object *obj, ResetType type) | ||
794 | { | ||
795 | NPCM7xxMFTState *s = NPCM7XX_MFT(obj); | ||
796 | |||
797 | diff --git a/hw/misc/npcm7xx_pwm.c b/hw/misc/npcm7xx_pwm.c | ||
798 | index XXXXXXX..XXXXXXX 100644 | ||
799 | --- a/hw/misc/npcm7xx_pwm.c | ||
800 | +++ b/hw/misc/npcm7xx_pwm.c | ||
801 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_pwm_enter_reset(Object *obj, ResetType type) | ||
802 | s->piir = 0x00000000; | ||
803 | } | ||
804 | |||
805 | -static void npcm7xx_pwm_hold_reset(Object *obj) | ||
806 | +static void npcm7xx_pwm_hold_reset(Object *obj, ResetType type) | ||
807 | { | ||
808 | NPCM7xxPWMState *s = NPCM7XX_PWM(obj); | ||
809 | int i; | ||
810 | diff --git a/hw/misc/stm32l4x5_exti.c b/hw/misc/stm32l4x5_exti.c | ||
811 | index XXXXXXX..XXXXXXX 100644 | ||
812 | --- a/hw/misc/stm32l4x5_exti.c | ||
813 | +++ b/hw/misc/stm32l4x5_exti.c | ||
814 | @@ -XXX,XX +XXX,XX @@ static unsigned configurable_mask(unsigned bank) | ||
815 | return valid_mask(bank) & ~exti_romask[bank]; | ||
816 | } | ||
817 | |||
818 | -static void stm32l4x5_exti_reset_hold(Object *obj) | ||
819 | +static void stm32l4x5_exti_reset_hold(Object *obj, ResetType type) | ||
820 | { | ||
821 | Stm32l4x5ExtiState *s = STM32L4X5_EXTI(obj); | ||
822 | |||
823 | diff --git a/hw/misc/stm32l4x5_rcc.c b/hw/misc/stm32l4x5_rcc.c | ||
824 | index XXXXXXX..XXXXXXX 100644 | ||
825 | --- a/hw/misc/stm32l4x5_rcc.c | ||
826 | +++ b/hw/misc/stm32l4x5_rcc.c | ||
827 | @@ -XXX,XX +XXX,XX @@ static void clock_mux_reset_enter(Object *obj, ResetType type) | ||
828 | set_clock_mux_init_info(s, s->id); | ||
829 | } | ||
830 | |||
831 | -static void clock_mux_reset_hold(Object *obj) | ||
832 | +static void clock_mux_reset_hold(Object *obj, ResetType type) | ||
833 | { | ||
834 | RccClockMuxState *s = RCC_CLOCK_MUX(obj); | ||
835 | clock_mux_update(s, true); | ||
836 | } | ||
837 | |||
838 | -static void clock_mux_reset_exit(Object *obj) | ||
839 | +static void clock_mux_reset_exit(Object *obj, ResetType type) | ||
840 | { | ||
841 | RccClockMuxState *s = RCC_CLOCK_MUX(obj); | ||
842 | clock_mux_update(s, false); | ||
843 | @@ -XXX,XX +XXX,XX @@ static void pll_reset_enter(Object *obj, ResetType type) | ||
844 | set_pll_init_info(s, s->id); | ||
845 | } | ||
846 | |||
847 | -static void pll_reset_hold(Object *obj) | ||
848 | +static void pll_reset_hold(Object *obj, ResetType type) | ||
849 | { | ||
850 | RccPllState *s = RCC_PLL(obj); | ||
851 | pll_update(s, true); | ||
852 | } | ||
853 | |||
854 | -static void pll_reset_exit(Object *obj) | ||
855 | +static void pll_reset_exit(Object *obj, ResetType type) | ||
856 | { | ||
857 | RccPllState *s = RCC_PLL(obj); | ||
858 | pll_update(s, false); | ||
859 | @@ -XXX,XX +XXX,XX @@ static void rcc_update_csr(Stm32l4x5RccState *s) | ||
860 | rcc_update_irq(s); | ||
861 | } | ||
862 | |||
863 | -static void stm32l4x5_rcc_reset_hold(Object *obj) | ||
864 | +static void stm32l4x5_rcc_reset_hold(Object *obj, ResetType type) | ||
865 | { | ||
866 | Stm32l4x5RccState *s = STM32L4X5_RCC(obj); | ||
867 | s->cr = 0x00000063; | ||
868 | diff --git a/hw/misc/stm32l4x5_syscfg.c b/hw/misc/stm32l4x5_syscfg.c | ||
869 | index XXXXXXX..XXXXXXX 100644 | ||
870 | --- a/hw/misc/stm32l4x5_syscfg.c | ||
871 | +++ b/hw/misc/stm32l4x5_syscfg.c | ||
872 | @@ -XXX,XX +XXX,XX @@ | ||
873 | |||
874 | #define NUM_LINES_PER_EXTICR_REG 4 | ||
875 | |||
876 | -static void stm32l4x5_syscfg_hold_reset(Object *obj) | ||
877 | +static void stm32l4x5_syscfg_hold_reset(Object *obj, ResetType type) | ||
878 | { | ||
879 | Stm32l4x5SyscfgState *s = STM32L4X5_SYSCFG(obj); | ||
880 | |||
881 | diff --git a/hw/misc/xlnx-versal-cframe-reg.c b/hw/misc/xlnx-versal-cframe-reg.c | ||
882 | index XXXXXXX..XXXXXXX 100644 | ||
883 | --- a/hw/misc/xlnx-versal-cframe-reg.c | ||
884 | +++ b/hw/misc/xlnx-versal-cframe-reg.c | ||
885 | @@ -XXX,XX +XXX,XX @@ static void cframe_reg_reset_enter(Object *obj, ResetType type) | ||
886 | } | ||
887 | } | ||
888 | |||
889 | -static void cframe_reg_reset_hold(Object *obj) | ||
890 | +static void cframe_reg_reset_hold(Object *obj, ResetType type) | ||
891 | { | ||
892 | XlnxVersalCFrameReg *s = XLNX_VERSAL_CFRAME_REG(obj); | ||
893 | |||
894 | diff --git a/hw/misc/xlnx-versal-crl.c b/hw/misc/xlnx-versal-crl.c | ||
895 | index XXXXXXX..XXXXXXX 100644 | ||
896 | --- a/hw/misc/xlnx-versal-crl.c | ||
897 | +++ b/hw/misc/xlnx-versal-crl.c | ||
898 | @@ -XXX,XX +XXX,XX @@ static void crl_reset_enter(Object *obj, ResetType type) | ||
899 | } | ||
900 | } | ||
901 | |||
902 | -static void crl_reset_hold(Object *obj) | ||
903 | +static void crl_reset_hold(Object *obj, ResetType type) | ||
904 | { | ||
905 | XlnxVersalCRL *s = XLNX_VERSAL_CRL(obj); | ||
906 | |||
907 | diff --git a/hw/misc/xlnx-versal-pmc-iou-slcr.c b/hw/misc/xlnx-versal-pmc-iou-slcr.c | ||
908 | index XXXXXXX..XXXXXXX 100644 | ||
909 | --- a/hw/misc/xlnx-versal-pmc-iou-slcr.c | ||
910 | +++ b/hw/misc/xlnx-versal-pmc-iou-slcr.c | ||
911 | @@ -XXX,XX +XXX,XX @@ static void xlnx_versal_pmc_iou_slcr_reset_init(Object *obj, ResetType type) | ||
912 | } | ||
913 | } | ||
914 | |||
915 | -static void xlnx_versal_pmc_iou_slcr_reset_hold(Object *obj) | ||
916 | +static void xlnx_versal_pmc_iou_slcr_reset_hold(Object *obj, ResetType type) | ||
917 | { | ||
918 | XlnxVersalPmcIouSlcr *s = XILINX_VERSAL_PMC_IOU_SLCR(obj); | ||
919 | |||
920 | diff --git a/hw/misc/xlnx-versal-trng.c b/hw/misc/xlnx-versal-trng.c | ||
921 | index XXXXXXX..XXXXXXX 100644 | ||
922 | --- a/hw/misc/xlnx-versal-trng.c | ||
923 | +++ b/hw/misc/xlnx-versal-trng.c | ||
924 | @@ -XXX,XX +XXX,XX @@ static void trng_unrealize(DeviceState *dev) | ||
925 | s->prng = NULL; | ||
926 | } | ||
927 | |||
928 | -static void trng_reset_hold(Object *obj) | ||
929 | +static void trng_reset_hold(Object *obj, ResetType type) | ||
930 | { | ||
931 | trng_reset(XLNX_VERSAL_TRNG(obj)); | ||
932 | } | ||
933 | diff --git a/hw/misc/xlnx-versal-xramc.c b/hw/misc/xlnx-versal-xramc.c | ||
934 | index XXXXXXX..XXXXXXX 100644 | ||
935 | --- a/hw/misc/xlnx-versal-xramc.c | ||
936 | +++ b/hw/misc/xlnx-versal-xramc.c | ||
937 | @@ -XXX,XX +XXX,XX @@ static void xram_ctrl_reset_enter(Object *obj, ResetType type) | ||
938 | ARRAY_FIELD_DP32(s->regs, XRAM_IMP, SIZE, s->cfg.encoded_size); | ||
939 | } | ||
940 | |||
941 | -static void xram_ctrl_reset_hold(Object *obj) | ||
942 | +static void xram_ctrl_reset_hold(Object *obj, ResetType type) | ||
943 | { | ||
944 | XlnxXramCtrl *s = XLNX_XRAM_CTRL(obj); | ||
945 | |||
946 | diff --git a/hw/misc/xlnx-zynqmp-apu-ctrl.c b/hw/misc/xlnx-zynqmp-apu-ctrl.c | ||
947 | index XXXXXXX..XXXXXXX 100644 | ||
948 | --- a/hw/misc/xlnx-zynqmp-apu-ctrl.c | ||
949 | +++ b/hw/misc/xlnx-zynqmp-apu-ctrl.c | ||
950 | @@ -XXX,XX +XXX,XX @@ static void zynqmp_apu_reset_enter(Object *obj, ResetType type) | ||
951 | s->cpu_in_wfi = 0; | ||
952 | } | ||
953 | |||
954 | -static void zynqmp_apu_reset_hold(Object *obj) | ||
955 | +static void zynqmp_apu_reset_hold(Object *obj, ResetType type) | ||
956 | { | ||
957 | XlnxZynqMPAPUCtrl *s = XLNX_ZYNQMP_APU_CTRL(obj); | ||
958 | |||
959 | diff --git a/hw/misc/xlnx-zynqmp-crf.c b/hw/misc/xlnx-zynqmp-crf.c | ||
960 | index XXXXXXX..XXXXXXX 100644 | ||
961 | --- a/hw/misc/xlnx-zynqmp-crf.c | ||
962 | +++ b/hw/misc/xlnx-zynqmp-crf.c | ||
963 | @@ -XXX,XX +XXX,XX @@ static void crf_reset_enter(Object *obj, ResetType type) | ||
964 | } | ||
965 | } | ||
966 | |||
967 | -static void crf_reset_hold(Object *obj) | ||
968 | +static void crf_reset_hold(Object *obj, ResetType type) | ||
969 | { | ||
970 | XlnxZynqMPCRF *s = XLNX_ZYNQMP_CRF(obj); | ||
971 | ir_update_irq(s); | ||
972 | diff --git a/hw/misc/zynq_slcr.c b/hw/misc/zynq_slcr.c | ||
973 | index XXXXXXX..XXXXXXX 100644 | ||
974 | --- a/hw/misc/zynq_slcr.c | ||
975 | +++ b/hw/misc/zynq_slcr.c | ||
976 | @@ -XXX,XX +XXX,XX @@ static void zynq_slcr_reset_init(Object *obj, ResetType type) | ||
977 | s->regs[R_DDRIOB + 12] = 0x00000021; | ||
978 | } | ||
979 | |||
980 | -static void zynq_slcr_reset_hold(Object *obj) | ||
981 | +static void zynq_slcr_reset_hold(Object *obj, ResetType type) | ||
982 | { | ||
983 | ZynqSLCRState *s = ZYNQ_SLCR(obj); | ||
984 | |||
985 | @@ -XXX,XX +XXX,XX @@ static void zynq_slcr_reset_hold(Object *obj) | ||
986 | zynq_slcr_propagate_clocks(s); | ||
987 | } | ||
988 | |||
989 | -static void zynq_slcr_reset_exit(Object *obj) | ||
990 | +static void zynq_slcr_reset_exit(Object *obj, ResetType type) | ||
991 | { | ||
992 | ZynqSLCRState *s = ZYNQ_SLCR(obj); | ||
993 | |||
994 | diff --git a/hw/net/can/xlnx-zynqmp-can.c b/hw/net/can/xlnx-zynqmp-can.c | ||
995 | index XXXXXXX..XXXXXXX 100644 | ||
996 | --- a/hw/net/can/xlnx-zynqmp-can.c | ||
997 | +++ b/hw/net/can/xlnx-zynqmp-can.c | ||
998 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_can_reset_init(Object *obj, ResetType type) | ||
999 | ptimer_transaction_commit(s->can_timer); | ||
1000 | } | ||
1001 | |||
1002 | -static void xlnx_zynqmp_can_reset_hold(Object *obj) | ||
1003 | +static void xlnx_zynqmp_can_reset_hold(Object *obj, ResetType type) | ||
1004 | { | ||
1005 | XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(obj); | ||
1006 | unsigned int i; | ||
1007 | diff --git a/hw/net/e1000.c b/hw/net/e1000.c | ||
1008 | index XXXXXXX..XXXXXXX 100644 | ||
1009 | --- a/hw/net/e1000.c | ||
1010 | +++ b/hw/net/e1000.c | ||
1011 | @@ -XXX,XX +XXX,XX @@ static bool e1000_vet_init_need(void *opaque) | ||
1012 | return chkflag(VET); | ||
1013 | } | ||
1014 | |||
1015 | -static void e1000_reset_hold(Object *obj) | ||
1016 | +static void e1000_reset_hold(Object *obj, ResetType type) | ||
1017 | { | ||
1018 | E1000State *d = E1000(obj); | ||
1019 | E1000BaseClass *edc = E1000_GET_CLASS(d); | ||
1020 | diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c | ||
1021 | index XXXXXXX..XXXXXXX 100644 | ||
1022 | --- a/hw/net/e1000e.c | ||
1023 | +++ b/hw/net/e1000e.c | ||
1024 | @@ -XXX,XX +XXX,XX @@ static void e1000e_pci_uninit(PCIDevice *pci_dev) | ||
1025 | msi_uninit(pci_dev); | ||
1026 | } | ||
1027 | |||
1028 | -static void e1000e_qdev_reset_hold(Object *obj) | ||
1029 | +static void e1000e_qdev_reset_hold(Object *obj, ResetType type) | ||
1030 | { | ||
1031 | E1000EState *s = E1000E(obj); | ||
1032 | |||
1033 | diff --git a/hw/net/igb.c b/hw/net/igb.c | ||
1034 | index XXXXXXX..XXXXXXX 100644 | ||
1035 | --- a/hw/net/igb.c | ||
1036 | +++ b/hw/net/igb.c | ||
1037 | @@ -XXX,XX +XXX,XX @@ static void igb_pci_uninit(PCIDevice *pci_dev) | ||
1038 | msi_uninit(pci_dev); | ||
1039 | } | ||
1040 | |||
1041 | -static void igb_qdev_reset_hold(Object *obj) | ||
1042 | +static void igb_qdev_reset_hold(Object *obj, ResetType type) | ||
1043 | { | ||
1044 | IGBState *s = IGB(obj); | ||
1045 | |||
1046 | diff --git a/hw/net/igbvf.c b/hw/net/igbvf.c | ||
1047 | index XXXXXXX..XXXXXXX 100644 | ||
1048 | --- a/hw/net/igbvf.c | ||
1049 | +++ b/hw/net/igbvf.c | ||
1050 | @@ -XXX,XX +XXX,XX @@ static void igbvf_pci_realize(PCIDevice *dev, Error **errp) | ||
1051 | pcie_ari_init(dev, 0x150); | ||
1052 | } | ||
1053 | |||
1054 | -static void igbvf_qdev_reset_hold(Object *obj) | ||
1055 | +static void igbvf_qdev_reset_hold(Object *obj, ResetType type) | ||
1056 | { | ||
1057 | PCIDevice *vf = PCI_DEVICE(obj); | ||
1058 | |||
1059 | diff --git a/hw/nvram/xlnx-bbram.c b/hw/nvram/xlnx-bbram.c | ||
1060 | index XXXXXXX..XXXXXXX 100644 | ||
1061 | --- a/hw/nvram/xlnx-bbram.c | ||
1062 | +++ b/hw/nvram/xlnx-bbram.c | ||
1063 | @@ -XXX,XX +XXX,XX @@ static RegisterAccessInfo bbram_ctrl_regs_info[] = { | ||
1064 | } | ||
1065 | }; | ||
1066 | |||
1067 | -static void bbram_ctrl_reset_hold(Object *obj) | ||
1068 | +static void bbram_ctrl_reset_hold(Object *obj, ResetType type) | ||
1069 | { | ||
1070 | XlnxBBRam *s = XLNX_BBRAM(obj); | ||
1071 | unsigned int i; | ||
1072 | diff --git a/hw/nvram/xlnx-versal-efuse-ctrl.c b/hw/nvram/xlnx-versal-efuse-ctrl.c | ||
1073 | index XXXXXXX..XXXXXXX 100644 | ||
1074 | --- a/hw/nvram/xlnx-versal-efuse-ctrl.c | ||
1075 | +++ b/hw/nvram/xlnx-versal-efuse-ctrl.c | ||
1076 | @@ -XXX,XX +XXX,XX @@ static void efuse_ctrl_register_reset(RegisterInfo *reg) | ||
1077 | register_reset(reg); | ||
1078 | } | ||
1079 | |||
1080 | -static void efuse_ctrl_reset_hold(Object *obj) | ||
1081 | +static void efuse_ctrl_reset_hold(Object *obj, ResetType type) | ||
1082 | { | ||
1083 | XlnxVersalEFuseCtrl *s = XLNX_VERSAL_EFUSE_CTRL(obj); | ||
1084 | unsigned int i; | ||
1085 | diff --git a/hw/nvram/xlnx-zynqmp-efuse.c b/hw/nvram/xlnx-zynqmp-efuse.c | ||
1086 | index XXXXXXX..XXXXXXX 100644 | ||
1087 | --- a/hw/nvram/xlnx-zynqmp-efuse.c | ||
1088 | +++ b/hw/nvram/xlnx-zynqmp-efuse.c | ||
1089 | @@ -XXX,XX +XXX,XX @@ static void zynqmp_efuse_register_reset(RegisterInfo *reg) | ||
1090 | register_reset(reg); | ||
1091 | } | ||
1092 | |||
1093 | -static void zynqmp_efuse_reset_hold(Object *obj) | ||
1094 | +static void zynqmp_efuse_reset_hold(Object *obj, ResetType type) | ||
1095 | { | ||
1096 | XlnxZynqMPEFuse *s = XLNX_ZYNQMP_EFUSE(obj); | ||
1097 | unsigned int i; | ||
1098 | diff --git a/hw/pci-bridge/cxl_root_port.c b/hw/pci-bridge/cxl_root_port.c | ||
1099 | index XXXXXXX..XXXXXXX 100644 | ||
1100 | --- a/hw/pci-bridge/cxl_root_port.c | ||
1101 | +++ b/hw/pci-bridge/cxl_root_port.c | ||
1102 | @@ -XXX,XX +XXX,XX @@ static void cxl_rp_realize(DeviceState *dev, Error **errp) | ||
1103 | component_bar); | ||
1104 | } | ||
1105 | |||
1106 | -static void cxl_rp_reset_hold(Object *obj) | ||
1107 | +static void cxl_rp_reset_hold(Object *obj, ResetType type) | ||
1108 | { | ||
1109 | PCIERootPortClass *rpc = PCIE_ROOT_PORT_GET_CLASS(obj); | ||
1110 | CXLRootPort *crp = CXL_ROOT_PORT(obj); | ||
1111 | |||
1112 | if (rpc->parent_phases.hold) { | ||
1113 | - rpc->parent_phases.hold(obj); | ||
1114 | + rpc->parent_phases.hold(obj, type); | ||
1115 | } | ||
1116 | |||
1117 | latch_registers(crp); | ||
1118 | diff --git a/hw/pci-bridge/pcie_root_port.c b/hw/pci-bridge/pcie_root_port.c | ||
1119 | index XXXXXXX..XXXXXXX 100644 | ||
1120 | --- a/hw/pci-bridge/pcie_root_port.c | ||
1121 | +++ b/hw/pci-bridge/pcie_root_port.c | ||
1122 | @@ -XXX,XX +XXX,XX @@ static void rp_write_config(PCIDevice *d, uint32_t address, | ||
1123 | pcie_aer_root_write_config(d, address, val, len, root_cmd); | ||
1124 | } | ||
1125 | |||
1126 | -static void rp_reset_hold(Object *obj) | ||
1127 | +static void rp_reset_hold(Object *obj, ResetType type) | ||
1128 | { | ||
1129 | PCIDevice *d = PCI_DEVICE(obj); | ||
1130 | DeviceState *qdev = DEVICE(obj); | ||
1131 | diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c | ||
1132 | index XXXXXXX..XXXXXXX 100644 | ||
1133 | --- a/hw/pci-host/bonito.c | ||
1134 | +++ b/hw/pci-host/bonito.c | ||
1135 | @@ -XXX,XX +XXX,XX @@ static int pci_bonito_map_irq(PCIDevice *pci_dev, int irq_num) | ||
1136 | } | ||
1137 | } | ||
1138 | |||
1139 | -static void bonito_reset_hold(Object *obj) | ||
1140 | +static void bonito_reset_hold(Object *obj, ResetType type) | ||
1141 | { | ||
1142 | PCIBonitoState *s = PCI_BONITO(obj); | ||
1143 | uint32_t val = 0; | ||
1144 | diff --git a/hw/pci-host/pnv_phb.c b/hw/pci-host/pnv_phb.c | ||
1145 | index XXXXXXX..XXXXXXX 100644 | ||
1146 | --- a/hw/pci-host/pnv_phb.c | ||
1147 | +++ b/hw/pci-host/pnv_phb.c | ||
1148 | @@ -XXX,XX +XXX,XX @@ static void pnv_phb_class_init(ObjectClass *klass, void *data) | ||
1149 | dc->user_creatable = true; | ||
1150 | } | ||
1151 | |||
1152 | -static void pnv_phb_root_port_reset_hold(Object *obj) | ||
1153 | +static void pnv_phb_root_port_reset_hold(Object *obj, ResetType type) | ||
1154 | { | ||
1155 | PCIERootPortClass *rpc = PCIE_ROOT_PORT_GET_CLASS(obj); | ||
1156 | PnvPHBRootPort *phb_rp = PNV_PHB_ROOT_PORT(obj); | ||
1157 | @@ -XXX,XX +XXX,XX @@ static void pnv_phb_root_port_reset_hold(Object *obj) | ||
1158 | uint8_t *conf = d->config; | ||
1159 | |||
1160 | if (rpc->parent_phases.hold) { | ||
1161 | - rpc->parent_phases.hold(obj); | ||
1162 | + rpc->parent_phases.hold(obj, type); | ||
1163 | } | ||
1164 | |||
1165 | if (phb_rp->version == 3) { | ||
1166 | diff --git a/hw/pci-host/pnv_phb3_msi.c b/hw/pci-host/pnv_phb3_msi.c | ||
1167 | index XXXXXXX..XXXXXXX 100644 | ||
1168 | --- a/hw/pci-host/pnv_phb3_msi.c | ||
1169 | +++ b/hw/pci-host/pnv_phb3_msi.c | ||
1170 | @@ -XXX,XX +XXX,XX @@ static void phb3_msi_resend(ICSState *ics) | ||
1171 | } | ||
1172 | } | ||
1173 | |||
1174 | -static void phb3_msi_reset_hold(Object *obj) | ||
1175 | +static void phb3_msi_reset_hold(Object *obj, ResetType type) | ||
1176 | { | ||
1177 | Phb3MsiState *msi = PHB3_MSI(obj); | ||
1178 | ICSStateClass *icsc = ICS_GET_CLASS(obj); | ||
1179 | |||
1180 | if (icsc->parent_phases.hold) { | ||
1181 | - icsc->parent_phases.hold(obj); | ||
1182 | + icsc->parent_phases.hold(obj, type); | ||
1183 | } | ||
1184 | |||
1185 | memset(msi->rba, 0, sizeof(msi->rba)); | ||
1186 | diff --git a/hw/pci/pci.c b/hw/pci/pci.c | ||
1187 | index XXXXXXX..XXXXXXX 100644 | ||
1188 | --- a/hw/pci/pci.c | ||
1189 | +++ b/hw/pci/pci.c | ||
1190 | @@ -XXX,XX +XXX,XX @@ bool pci_available = true; | ||
1191 | |||
1192 | static char *pcibus_get_dev_path(DeviceState *dev); | ||
1193 | static char *pcibus_get_fw_dev_path(DeviceState *dev); | ||
1194 | -static void pcibus_reset_hold(Object *obj); | ||
1195 | +static void pcibus_reset_hold(Object *obj, ResetType type); | ||
1196 | static bool pcie_has_upstream_port(PCIDevice *dev); | ||
1197 | |||
1198 | static Property pci_props[] = { | ||
1199 | @@ -XXX,XX +XXX,XX @@ void pci_device_reset(PCIDevice *dev) | ||
1200 | * Called via bus_cold_reset on RST# assert, after the devices | ||
1201 | * have been reset device_cold_reset-ed already. | ||
1202 | */ | ||
1203 | -static void pcibus_reset_hold(Object *obj) | ||
1204 | +static void pcibus_reset_hold(Object *obj, ResetType type) | ||
1205 | { | ||
1206 | PCIBus *bus = PCI_BUS(obj); | ||
1207 | int i; | ||
1208 | diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c | ||
1209 | index XXXXXXX..XXXXXXX 100644 | ||
1210 | --- a/hw/rtc/mc146818rtc.c | ||
1211 | +++ b/hw/rtc/mc146818rtc.c | ||
1212 | @@ -XXX,XX +XXX,XX @@ static void rtc_reset_enter(Object *obj, ResetType type) | ||
1213 | } | ||
1214 | } | ||
1215 | |||
1216 | -static void rtc_reset_hold(Object *obj) | ||
1217 | +static void rtc_reset_hold(Object *obj, ResetType type) | ||
1218 | { | ||
1219 | MC146818RtcState *s = MC146818_RTC(obj); | ||
1220 | |||
1221 | diff --git a/hw/s390x/css-bridge.c b/hw/s390x/css-bridge.c | ||
1222 | index XXXXXXX..XXXXXXX 100644 | ||
1223 | --- a/hw/s390x/css-bridge.c | ||
1224 | +++ b/hw/s390x/css-bridge.c | ||
1225 | @@ -XXX,XX +XXX,XX @@ static void ccw_device_unplug(HotplugHandler *hotplug_dev, | ||
1226 | qdev_unrealize(dev); | ||
1227 | } | ||
1228 | |||
1229 | -static void virtual_css_bus_reset_hold(Object *obj) | ||
1230 | +static void virtual_css_bus_reset_hold(Object *obj, ResetType type) | ||
1231 | { | ||
1232 | /* This should actually be modelled via the generic css */ | ||
1233 | css_reset(); | ||
1234 | diff --git a/hw/sensor/adm1266.c b/hw/sensor/adm1266.c | ||
1235 | index XXXXXXX..XXXXXXX 100644 | ||
1236 | --- a/hw/sensor/adm1266.c | ||
1237 | +++ b/hw/sensor/adm1266.c | ||
1238 | @@ -XXX,XX +XXX,XX @@ static const uint8_t adm1266_ic_device_id[] = {0x03, 0x41, 0x12, 0x66}; | ||
1239 | static const uint8_t adm1266_ic_device_rev[] = {0x08, 0x01, 0x08, 0x07, 0x0, | ||
1240 | 0x0, 0x07, 0x41, 0x30}; | ||
1241 | |||
1242 | -static void adm1266_exit_reset(Object *obj) | ||
1243 | +static void adm1266_exit_reset(Object *obj, ResetType type) | ||
1244 | { | ||
1245 | ADM1266State *s = ADM1266(obj); | ||
1246 | PMBusDevice *pmdev = PMBUS_DEVICE(obj); | ||
1247 | diff --git a/hw/sensor/adm1272.c b/hw/sensor/adm1272.c | ||
1248 | index XXXXXXX..XXXXXXX 100644 | ||
1249 | --- a/hw/sensor/adm1272.c | ||
1250 | +++ b/hw/sensor/adm1272.c | ||
1251 | @@ -XXX,XX +XXX,XX @@ static uint32_t adm1272_direct_to_watts(uint16_t value) | ||
1252 | return pmbus_direct_mode2data(c, value); | ||
1253 | } | ||
1254 | |||
1255 | -static void adm1272_exit_reset(Object *obj) | ||
1256 | +static void adm1272_exit_reset(Object *obj, ResetType type) | ||
1257 | { | ||
1258 | ADM1272State *s = ADM1272(obj); | ||
1259 | PMBusDevice *pmdev = PMBUS_DEVICE(obj); | ||
1260 | diff --git a/hw/sensor/isl_pmbus_vr.c b/hw/sensor/isl_pmbus_vr.c | ||
1261 | index XXXXXXX..XXXXXXX 100644 | ||
1262 | --- a/hw/sensor/isl_pmbus_vr.c | ||
1263 | +++ b/hw/sensor/isl_pmbus_vr.c | ||
1264 | @@ -XXX,XX +XXX,XX @@ static void isl_pmbus_vr_set(Object *obj, Visitor *v, const char *name, | ||
1265 | pmbus_check_limits(pmdev); | ||
1266 | } | ||
1267 | |||
1268 | -static void isl_pmbus_vr_exit_reset(Object *obj) | ||
1269 | +static void isl_pmbus_vr_exit_reset(Object *obj, ResetType type) | ||
1270 | { | ||
1271 | PMBusDevice *pmdev = PMBUS_DEVICE(obj); | ||
1272 | |||
1273 | @@ -XXX,XX +XXX,XX @@ static void isl_pmbus_vr_exit_reset(Object *obj) | ||
1274 | } | ||
1275 | |||
1276 | /* The raa228000 uses different direct mode coefficients from most isl devices */ | ||
1277 | -static void raa228000_exit_reset(Object *obj) | ||
1278 | +static void raa228000_exit_reset(Object *obj, ResetType type) | ||
1279 | { | ||
1280 | PMBusDevice *pmdev = PMBUS_DEVICE(obj); | ||
1281 | |||
1282 | - isl_pmbus_vr_exit_reset(obj); | ||
1283 | + isl_pmbus_vr_exit_reset(obj, type); | ||
1284 | |||
1285 | pmdev->pages[0].read_iout = 0; | ||
1286 | pmdev->pages[0].read_pout = 0; | ||
1287 | @@ -XXX,XX +XXX,XX @@ static void raa228000_exit_reset(Object *obj) | ||
1288 | pmdev->pages[0].read_temperature_3 = 0; | ||
1289 | } | ||
1290 | |||
1291 | -static void isl69259_exit_reset(Object *obj) | ||
1292 | +static void isl69259_exit_reset(Object *obj, ResetType type) | ||
1293 | { | ||
1294 | ISLState *s = ISL69260(obj); | ||
1295 | static const uint8_t ic_device_id[] = {0x04, 0x00, 0x81, 0xD2, 0x49, 0x3c}; | ||
1296 | g_assert(sizeof(ic_device_id) <= sizeof(s->ic_device_id)); | ||
1297 | |||
1298 | - isl_pmbus_vr_exit_reset(obj); | ||
1299 | + isl_pmbus_vr_exit_reset(obj, type); | ||
1300 | |||
1301 | s->ic_device_id_len = sizeof(ic_device_id); | ||
1302 | memcpy(s->ic_device_id, ic_device_id, sizeof(ic_device_id)); | ||
1303 | diff --git a/hw/sensor/max31785.c b/hw/sensor/max31785.c | ||
1304 | index XXXXXXX..XXXXXXX 100644 | ||
1305 | --- a/hw/sensor/max31785.c | ||
1306 | +++ b/hw/sensor/max31785.c | ||
1307 | @@ -XXX,XX +XXX,XX @@ static int max31785_write_data(PMBusDevice *pmdev, const uint8_t *buf, | ||
1308 | return 0; | ||
1309 | } | ||
1310 | |||
1311 | -static void max31785_exit_reset(Object *obj) | ||
1312 | +static void max31785_exit_reset(Object *obj, ResetType type) | ||
1313 | { | ||
1314 | PMBusDevice *pmdev = PMBUS_DEVICE(obj); | ||
1315 | MAX31785State *s = MAX31785(obj); | ||
1316 | diff --git a/hw/sensor/max34451.c b/hw/sensor/max34451.c | ||
1317 | index XXXXXXX..XXXXXXX 100644 | ||
1318 | --- a/hw/sensor/max34451.c | ||
1319 | +++ b/hw/sensor/max34451.c | ||
1320 | @@ -XXX,XX +XXX,XX @@ static inline void *memset_word(void *s, uint16_t c, size_t n) | ||
1321 | return s; | ||
1322 | } | ||
1323 | |||
1324 | -static void max34451_exit_reset(Object *obj) | ||
1325 | +static void max34451_exit_reset(Object *obj, ResetType type) | ||
1326 | { | ||
1327 | PMBusDevice *pmdev = PMBUS_DEVICE(obj); | ||
1328 | MAX34451State *s = MAX34451(obj); | ||
1329 | diff --git a/hw/ssi/npcm7xx_fiu.c b/hw/ssi/npcm7xx_fiu.c | ||
1330 | index XXXXXXX..XXXXXXX 100644 | ||
1331 | --- a/hw/ssi/npcm7xx_fiu.c | ||
1332 | +++ b/hw/ssi/npcm7xx_fiu.c | ||
1333 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_fiu_enter_reset(Object *obj, ResetType type) | ||
1334 | s->regs[NPCM7XX_FIU_CFG] = 0x0000000b; | ||
1335 | } | ||
1336 | |||
1337 | -static void npcm7xx_fiu_hold_reset(Object *obj) | ||
1338 | +static void npcm7xx_fiu_hold_reset(Object *obj, ResetType type) | ||
1339 | { | ||
1340 | NPCM7xxFIUState *s = NPCM7XX_FIU(obj); | ||
1341 | int i; | ||
1342 | diff --git a/hw/timer/etraxfs_timer.c b/hw/timer/etraxfs_timer.c | ||
1343 | index XXXXXXX..XXXXXXX 100644 | ||
1344 | --- a/hw/timer/etraxfs_timer.c | ||
1345 | +++ b/hw/timer/etraxfs_timer.c | ||
1346 | @@ -XXX,XX +XXX,XX @@ static void etraxfs_timer_reset_enter(Object *obj, ResetType type) | ||
1347 | t->rw_intr_mask = 0; | ||
1348 | } | ||
1349 | |||
1350 | -static void etraxfs_timer_reset_hold(Object *obj) | ||
1351 | +static void etraxfs_timer_reset_hold(Object *obj, ResetType type) | ||
1352 | { | ||
1353 | ETRAXTimerState *t = ETRAX_TIMER(obj); | ||
1354 | |||
1355 | diff --git a/hw/timer/npcm7xx_timer.c b/hw/timer/npcm7xx_timer.c | ||
1356 | index XXXXXXX..XXXXXXX 100644 | ||
1357 | --- a/hw/timer/npcm7xx_timer.c | ||
1358 | +++ b/hw/timer/npcm7xx_timer.c | ||
1359 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_watchdog_timer_expired(void *opaque) | ||
1360 | } | ||
1361 | } | ||
1362 | |||
1363 | -static void npcm7xx_timer_hold_reset(Object *obj) | ||
1364 | +static void npcm7xx_timer_hold_reset(Object *obj, ResetType type) | ||
1365 | { | ||
1366 | NPCM7xxTimerCtrlState *s = NPCM7XX_TIMER(obj); | ||
1367 | int i; | ||
1368 | diff --git a/hw/usb/hcd-dwc2.c b/hw/usb/hcd-dwc2.c | ||
1369 | index XXXXXXX..XXXXXXX 100644 | ||
1370 | --- a/hw/usb/hcd-dwc2.c | ||
1371 | +++ b/hw/usb/hcd-dwc2.c | ||
1372 | @@ -XXX,XX +XXX,XX @@ static void dwc2_reset_enter(Object *obj, ResetType type) | ||
1373 | } | ||
1374 | } | ||
1375 | |||
1376 | -static void dwc2_reset_hold(Object *obj) | ||
1377 | +static void dwc2_reset_hold(Object *obj, ResetType type) | ||
1378 | { | ||
1379 | DWC2Class *c = DWC2_USB_GET_CLASS(obj); | ||
1380 | DWC2State *s = DWC2_USB(obj); | ||
1381 | @@ -XXX,XX +XXX,XX @@ static void dwc2_reset_hold(Object *obj) | ||
1382 | trace_usb_dwc2_reset_hold(); | ||
1383 | |||
1384 | if (c->parent_phases.hold) { | ||
1385 | - c->parent_phases.hold(obj); | ||
1386 | + c->parent_phases.hold(obj, type); | ||
1387 | } | ||
1388 | |||
1389 | dwc2_update_irq(s); | ||
1390 | } | ||
1391 | |||
1392 | -static void dwc2_reset_exit(Object *obj) | ||
1393 | +static void dwc2_reset_exit(Object *obj, ResetType type) | ||
1394 | { | ||
1395 | DWC2Class *c = DWC2_USB_GET_CLASS(obj); | ||
1396 | DWC2State *s = DWC2_USB(obj); | ||
1397 | @@ -XXX,XX +XXX,XX @@ static void dwc2_reset_exit(Object *obj) | ||
1398 | trace_usb_dwc2_reset_exit(); | ||
1399 | |||
1400 | if (c->parent_phases.exit) { | ||
1401 | - c->parent_phases.exit(obj); | ||
1402 | + c->parent_phases.exit(obj, type); | ||
1403 | } | ||
1404 | |||
1405 | s->hprt0 = HPRT0_PWR; | ||
1406 | diff --git a/hw/usb/xlnx-versal-usb2-ctrl-regs.c b/hw/usb/xlnx-versal-usb2-ctrl-regs.c | ||
1407 | index XXXXXXX..XXXXXXX 100644 | ||
1408 | --- a/hw/usb/xlnx-versal-usb2-ctrl-regs.c | ||
1409 | +++ b/hw/usb/xlnx-versal-usb2-ctrl-regs.c | ||
1410 | @@ -XXX,XX +XXX,XX @@ static void usb2_ctrl_regs_reset_init(Object *obj, ResetType type) | ||
1411 | } | ||
1412 | } | ||
1413 | |||
1414 | -static void usb2_ctrl_regs_reset_hold(Object *obj) | ||
1415 | +static void usb2_ctrl_regs_reset_hold(Object *obj, ResetType type) | ||
1416 | { | ||
1417 | VersalUsb2CtrlRegs *s = XILINX_VERSAL_USB2_CTRL_REGS(obj); | ||
1418 | |||
1419 | diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c | ||
1420 | index XXXXXXX..XXXXXXX 100644 | ||
1421 | --- a/hw/virtio/virtio-pci.c | ||
1422 | +++ b/hw/virtio/virtio-pci.c | ||
1423 | @@ -XXX,XX +XXX,XX @@ static void virtio_pci_reset(DeviceState *qdev) | ||
1424 | } | ||
1425 | } | ||
1426 | |||
1427 | -static void virtio_pci_bus_reset_hold(Object *obj) | ||
1428 | +static void virtio_pci_bus_reset_hold(Object *obj, ResetType type) | ||
1429 | { | ||
1430 | PCIDevice *dev = PCI_DEVICE(obj); | ||
1431 | DeviceState *qdev = DEVICE(obj); | ||
16 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 1432 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
17 | index XXXXXXX..XXXXXXX 100644 | 1433 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/cpu.c | 1434 | --- a/target/arm/cpu.c |
19 | +++ b/target/arm/cpu.c | 1435 | +++ b/target/arm/cpu.c |
20 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | 1436 | @@ -XXX,XX +XXX,XX @@ static void cp_reg_check_reset(gpointer key, gpointer value, gpointer opaque) |
21 | 1437 | assert(oldvalue == newvalue); | |
1438 | } | ||
1439 | |||
1440 | -static void arm_cpu_reset_hold(Object *obj) | ||
1441 | +static void arm_cpu_reset_hold(Object *obj, ResetType type) | ||
1442 | { | ||
1443 | CPUState *cs = CPU(obj); | ||
1444 | ARMCPU *cpu = ARM_CPU(cs); | ||
1445 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset_hold(Object *obj) | ||
1446 | CPUARMState *env = &cpu->env; | ||
1447 | |||
1448 | if (acc->parent_phases.hold) { | ||
1449 | - acc->parent_phases.hold(obj); | ||
1450 | + acc->parent_phases.hold(obj, type); | ||
1451 | } | ||
1452 | |||
1453 | memset(env, 0, offsetof(CPUARMState, end_reset_fields)); | ||
1454 | diff --git a/target/avr/cpu.c b/target/avr/cpu.c | ||
1455 | index XXXXXXX..XXXXXXX 100644 | ||
1456 | --- a/target/avr/cpu.c | ||
1457 | +++ b/target/avr/cpu.c | ||
1458 | @@ -XXX,XX +XXX,XX @@ static void avr_restore_state_to_opc(CPUState *cs, | ||
1459 | cpu_env(cs)->pc_w = data[0]; | ||
1460 | } | ||
1461 | |||
1462 | -static void avr_cpu_reset_hold(Object *obj) | ||
1463 | +static void avr_cpu_reset_hold(Object *obj, ResetType type) | ||
1464 | { | ||
1465 | CPUState *cs = CPU(obj); | ||
1466 | AVRCPU *cpu = AVR_CPU(cs); | ||
1467 | @@ -XXX,XX +XXX,XX @@ static void avr_cpu_reset_hold(Object *obj) | ||
1468 | CPUAVRState *env = &cpu->env; | ||
1469 | |||
1470 | if (mcc->parent_phases.hold) { | ||
1471 | - mcc->parent_phases.hold(obj); | ||
1472 | + mcc->parent_phases.hold(obj, type); | ||
1473 | } | ||
1474 | |||
1475 | env->pc_w = 0; | ||
1476 | diff --git a/target/cris/cpu.c b/target/cris/cpu.c | ||
1477 | index XXXXXXX..XXXXXXX 100644 | ||
1478 | --- a/target/cris/cpu.c | ||
1479 | +++ b/target/cris/cpu.c | ||
1480 | @@ -XXX,XX +XXX,XX @@ static int cris_cpu_mmu_index(CPUState *cs, bool ifetch) | ||
1481 | return !!(cpu_env(cs)->pregs[PR_CCS] & U_FLAG); | ||
1482 | } | ||
1483 | |||
1484 | -static void cris_cpu_reset_hold(Object *obj) | ||
1485 | +static void cris_cpu_reset_hold(Object *obj, ResetType type) | ||
1486 | { | ||
1487 | CPUState *cs = CPU(obj); | ||
1488 | CRISCPUClass *ccc = CRIS_CPU_GET_CLASS(obj); | ||
1489 | @@ -XXX,XX +XXX,XX @@ static void cris_cpu_reset_hold(Object *obj) | ||
1490 | uint32_t vr; | ||
1491 | |||
1492 | if (ccc->parent_phases.hold) { | ||
1493 | - ccc->parent_phases.hold(obj); | ||
1494 | + ccc->parent_phases.hold(obj, type); | ||
1495 | } | ||
1496 | |||
1497 | vr = env->pregs[PR_VR]; | ||
1498 | diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c | ||
1499 | index XXXXXXX..XXXXXXX 100644 | ||
1500 | --- a/target/hexagon/cpu.c | ||
1501 | +++ b/target/hexagon/cpu.c | ||
1502 | @@ -XXX,XX +XXX,XX @@ static void hexagon_restore_state_to_opc(CPUState *cs, | ||
1503 | cpu_env(cs)->gpr[HEX_REG_PC] = data[0]; | ||
1504 | } | ||
1505 | |||
1506 | -static void hexagon_cpu_reset_hold(Object *obj) | ||
1507 | +static void hexagon_cpu_reset_hold(Object *obj, ResetType type) | ||
1508 | { | ||
1509 | CPUState *cs = CPU(obj); | ||
1510 | HexagonCPUClass *mcc = HEXAGON_CPU_GET_CLASS(obj); | ||
1511 | CPUHexagonState *env = cpu_env(cs); | ||
1512 | |||
1513 | if (mcc->parent_phases.hold) { | ||
1514 | - mcc->parent_phases.hold(obj); | ||
1515 | + mcc->parent_phases.hold(obj, type); | ||
1516 | } | ||
1517 | |||
1518 | set_default_nan_mode(1, &env->fp_status); | ||
1519 | diff --git a/target/i386/cpu.c b/target/i386/cpu.c | ||
1520 | index XXXXXXX..XXXXXXX 100644 | ||
1521 | --- a/target/i386/cpu.c | ||
1522 | +++ b/target/i386/cpu.c | ||
1523 | @@ -XXX,XX +XXX,XX @@ static void x86_cpu_set_sgxlepubkeyhash(CPUX86State *env) | ||
1524 | #endif | ||
1525 | } | ||
1526 | |||
1527 | -static void x86_cpu_reset_hold(Object *obj) | ||
1528 | +static void x86_cpu_reset_hold(Object *obj, ResetType type) | ||
1529 | { | ||
1530 | CPUState *cs = CPU(obj); | ||
1531 | X86CPU *cpu = X86_CPU(cs); | ||
1532 | @@ -XXX,XX +XXX,XX @@ static void x86_cpu_reset_hold(Object *obj) | ||
1533 | int i; | ||
1534 | |||
1535 | if (xcc->parent_phases.hold) { | ||
1536 | - xcc->parent_phases.hold(obj); | ||
1537 | + xcc->parent_phases.hold(obj, type); | ||
1538 | } | ||
1539 | |||
1540 | memset(env, 0, offsetof(CPUX86State, end_reset_fields)); | ||
1541 | diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c | ||
1542 | index XXXXXXX..XXXXXXX 100644 | ||
1543 | --- a/target/loongarch/cpu.c | ||
1544 | +++ b/target/loongarch/cpu.c | ||
1545 | @@ -XXX,XX +XXX,XX @@ static void loongarch_max_initfn(Object *obj) | ||
1546 | loongarch_la464_initfn(obj); | ||
1547 | } | ||
1548 | |||
1549 | -static void loongarch_cpu_reset_hold(Object *obj) | ||
1550 | +static void loongarch_cpu_reset_hold(Object *obj, ResetType type) | ||
1551 | { | ||
1552 | CPUState *cs = CPU(obj); | ||
1553 | LoongArchCPUClass *lacc = LOONGARCH_CPU_GET_CLASS(obj); | ||
1554 | CPULoongArchState *env = cpu_env(cs); | ||
1555 | |||
1556 | if (lacc->parent_phases.hold) { | ||
1557 | - lacc->parent_phases.hold(obj); | ||
1558 | + lacc->parent_phases.hold(obj, type); | ||
1559 | } | ||
1560 | |||
1561 | env->fcsr0_mask = FCSR0_M1 | FCSR0_M2 | FCSR0_M3; | ||
1562 | diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c | ||
1563 | index XXXXXXX..XXXXXXX 100644 | ||
1564 | --- a/target/m68k/cpu.c | ||
1565 | +++ b/target/m68k/cpu.c | ||
1566 | @@ -XXX,XX +XXX,XX @@ static void m68k_unset_feature(CPUM68KState *env, int feature) | ||
1567 | env->features &= ~BIT_ULL(feature); | ||
1568 | } | ||
1569 | |||
1570 | -static void m68k_cpu_reset_hold(Object *obj) | ||
1571 | +static void m68k_cpu_reset_hold(Object *obj, ResetType type) | ||
1572 | { | ||
1573 | CPUState *cs = CPU(obj); | ||
1574 | M68kCPUClass *mcc = M68K_CPU_GET_CLASS(obj); | ||
1575 | @@ -XXX,XX +XXX,XX @@ static void m68k_cpu_reset_hold(Object *obj) | ||
1576 | int i; | ||
1577 | |||
1578 | if (mcc->parent_phases.hold) { | ||
1579 | - mcc->parent_phases.hold(obj); | ||
1580 | + mcc->parent_phases.hold(obj, type); | ||
1581 | } | ||
1582 | |||
1583 | memset(env, 0, offsetof(CPUM68KState, end_reset_fields)); | ||
1584 | diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c | ||
1585 | index XXXXXXX..XXXXXXX 100644 | ||
1586 | --- a/target/microblaze/cpu.c | ||
1587 | +++ b/target/microblaze/cpu.c | ||
1588 | @@ -XXX,XX +XXX,XX @@ static void microblaze_cpu_set_irq(void *opaque, int irq, int level) | ||
1589 | } | ||
1590 | #endif | ||
1591 | |||
1592 | -static void mb_cpu_reset_hold(Object *obj) | ||
1593 | +static void mb_cpu_reset_hold(Object *obj, ResetType type) | ||
1594 | { | ||
1595 | CPUState *cs = CPU(obj); | ||
1596 | MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs); | ||
1597 | @@ -XXX,XX +XXX,XX @@ static void mb_cpu_reset_hold(Object *obj) | ||
1598 | CPUMBState *env = &cpu->env; | ||
1599 | |||
1600 | if (mcc->parent_phases.hold) { | ||
1601 | - mcc->parent_phases.hold(obj); | ||
1602 | + mcc->parent_phases.hold(obj, type); | ||
1603 | } | ||
1604 | |||
1605 | memset(env, 0, offsetof(CPUMBState, end_reset_fields)); | ||
1606 | diff --git a/target/mips/cpu.c b/target/mips/cpu.c | ||
1607 | index XXXXXXX..XXXXXXX 100644 | ||
1608 | --- a/target/mips/cpu.c | ||
1609 | +++ b/target/mips/cpu.c | ||
1610 | @@ -XXX,XX +XXX,XX @@ static int mips_cpu_mmu_index(CPUState *cs, bool ifunc) | ||
1611 | |||
1612 | #include "cpu-defs.c.inc" | ||
1613 | |||
1614 | -static void mips_cpu_reset_hold(Object *obj) | ||
1615 | +static void mips_cpu_reset_hold(Object *obj, ResetType type) | ||
1616 | { | ||
1617 | CPUState *cs = CPU(obj); | ||
1618 | MIPSCPU *cpu = MIPS_CPU(cs); | ||
1619 | @@ -XXX,XX +XXX,XX @@ static void mips_cpu_reset_hold(Object *obj) | ||
1620 | CPUMIPSState *env = &cpu->env; | ||
1621 | |||
1622 | if (mcc->parent_phases.hold) { | ||
1623 | - mcc->parent_phases.hold(obj); | ||
1624 | + mcc->parent_phases.hold(obj, type); | ||
1625 | } | ||
1626 | |||
1627 | memset(env, 0, offsetof(CPUMIPSState, end_reset_fields)); | ||
1628 | diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c | ||
1629 | index XXXXXXX..XXXXXXX 100644 | ||
1630 | --- a/target/openrisc/cpu.c | ||
1631 | +++ b/target/openrisc/cpu.c | ||
1632 | @@ -XXX,XX +XXX,XX @@ static void openrisc_disas_set_info(CPUState *cpu, disassemble_info *info) | ||
1633 | info->print_insn = print_insn_or1k; | ||
1634 | } | ||
1635 | |||
1636 | -static void openrisc_cpu_reset_hold(Object *obj) | ||
1637 | +static void openrisc_cpu_reset_hold(Object *obj, ResetType type) | ||
1638 | { | ||
1639 | CPUState *cs = CPU(obj); | ||
1640 | OpenRISCCPU *cpu = OPENRISC_CPU(cs); | ||
1641 | OpenRISCCPUClass *occ = OPENRISC_CPU_GET_CLASS(obj); | ||
1642 | |||
1643 | if (occ->parent_phases.hold) { | ||
1644 | - occ->parent_phases.hold(obj); | ||
1645 | + occ->parent_phases.hold(obj, type); | ||
1646 | } | ||
1647 | |||
1648 | memset(&cpu->env, 0, offsetof(CPUOpenRISCState, end_reset_fields)); | ||
1649 | diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c | ||
1650 | index XXXXXXX..XXXXXXX 100644 | ||
1651 | --- a/target/ppc/cpu_init.c | ||
1652 | +++ b/target/ppc/cpu_init.c | ||
1653 | @@ -XXX,XX +XXX,XX @@ static int ppc_cpu_mmu_index(CPUState *cs, bool ifetch) | ||
1654 | return ppc_env_mmu_index(cpu_env(cs), ifetch); | ||
1655 | } | ||
1656 | |||
1657 | -static void ppc_cpu_reset_hold(Object *obj) | ||
1658 | +static void ppc_cpu_reset_hold(Object *obj, ResetType type) | ||
1659 | { | ||
1660 | CPUState *cs = CPU(obj); | ||
1661 | PowerPCCPU *cpu = POWERPC_CPU(cs); | ||
1662 | @@ -XXX,XX +XXX,XX @@ static void ppc_cpu_reset_hold(Object *obj) | ||
1663 | int i; | ||
1664 | |||
1665 | if (pcc->parent_phases.hold) { | ||
1666 | - pcc->parent_phases.hold(obj); | ||
1667 | + pcc->parent_phases.hold(obj, type); | ||
1668 | } | ||
1669 | |||
1670 | msr = (target_ulong)0; | ||
1671 | diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c | ||
1672 | index XXXXXXX..XXXXXXX 100644 | ||
1673 | --- a/target/riscv/cpu.c | ||
1674 | +++ b/target/riscv/cpu.c | ||
1675 | @@ -XXX,XX +XXX,XX @@ static int riscv_cpu_mmu_index(CPUState *cs, bool ifetch) | ||
1676 | return riscv_env_mmu_index(cpu_env(cs), ifetch); | ||
1677 | } | ||
1678 | |||
1679 | -static void riscv_cpu_reset_hold(Object *obj) | ||
1680 | +static void riscv_cpu_reset_hold(Object *obj, ResetType type) | ||
1681 | { | ||
22 | #ifndef CONFIG_USER_ONLY | 1682 | #ifndef CONFIG_USER_ONLY |
23 | /* | 1683 | uint8_t iprio; |
24 | - * Disable the MTE feature bits if we do not have tag-memory | 1684 | @@ -XXX,XX +XXX,XX @@ static void riscv_cpu_reset_hold(Object *obj) |
25 | - * provided by the machine. | 1685 | CPURISCVState *env = &cpu->env; |
26 | + * If we do not have tag-memory provided by the machine, | 1686 | |
27 | + * reduce MTE support to instructions enabled at EL0. | 1687 | if (mcc->parent_phases.hold) { |
28 | + * This matches Cortex-A710 BROADCASTMTE input being LOW. | 1688 | - mcc->parent_phases.hold(obj); |
29 | */ | 1689 | + mcc->parent_phases.hold(obj, type); |
30 | if (cpu->tag_memory == NULL) { | 1690 | } |
31 | cpu->isar.id_aa64pfr1 = | 1691 | #ifndef CONFIG_USER_ONLY |
32 | - FIELD_DP64(cpu->isar.id_aa64pfr1, ID_AA64PFR1, MTE, 0); | 1692 | env->misa_mxl = mcc->misa_mxl_max; |
33 | + FIELD_DP64(cpu->isar.id_aa64pfr1, ID_AA64PFR1, MTE, 1); | 1693 | diff --git a/target/rx/cpu.c b/target/rx/cpu.c |
34 | } | 1694 | index XXXXXXX..XXXXXXX 100644 |
1695 | --- a/target/rx/cpu.c | ||
1696 | +++ b/target/rx/cpu.c | ||
1697 | @@ -XXX,XX +XXX,XX @@ static int riscv_cpu_mmu_index(CPUState *cs, bool ifunc) | ||
1698 | return 0; | ||
1699 | } | ||
1700 | |||
1701 | -static void rx_cpu_reset_hold(Object *obj) | ||
1702 | +static void rx_cpu_reset_hold(Object *obj, ResetType type) | ||
1703 | { | ||
1704 | CPUState *cs = CPU(obj); | ||
1705 | RXCPUClass *rcc = RX_CPU_GET_CLASS(obj); | ||
1706 | @@ -XXX,XX +XXX,XX @@ static void rx_cpu_reset_hold(Object *obj) | ||
1707 | uint32_t *resetvec; | ||
1708 | |||
1709 | if (rcc->parent_phases.hold) { | ||
1710 | - rcc->parent_phases.hold(obj); | ||
1711 | + rcc->parent_phases.hold(obj, type); | ||
1712 | } | ||
1713 | |||
1714 | memset(env, 0, offsetof(CPURXState, end_reset_fields)); | ||
1715 | diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c | ||
1716 | index XXXXXXX..XXXXXXX 100644 | ||
1717 | --- a/target/sh4/cpu.c | ||
1718 | +++ b/target/sh4/cpu.c | ||
1719 | @@ -XXX,XX +XXX,XX @@ static int sh4_cpu_mmu_index(CPUState *cs, bool ifetch) | ||
1720 | } | ||
1721 | } | ||
1722 | |||
1723 | -static void superh_cpu_reset_hold(Object *obj) | ||
1724 | +static void superh_cpu_reset_hold(Object *obj, ResetType type) | ||
1725 | { | ||
1726 | CPUState *cs = CPU(obj); | ||
1727 | SuperHCPUClass *scc = SUPERH_CPU_GET_CLASS(obj); | ||
1728 | CPUSH4State *env = cpu_env(cs); | ||
1729 | |||
1730 | if (scc->parent_phases.hold) { | ||
1731 | - scc->parent_phases.hold(obj); | ||
1732 | + scc->parent_phases.hold(obj, type); | ||
1733 | } | ||
1734 | |||
1735 | memset(env, 0, offsetof(CPUSH4State, end_reset_fields)); | ||
1736 | diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c | ||
1737 | index XXXXXXX..XXXXXXX 100644 | ||
1738 | --- a/target/sparc/cpu.c | ||
1739 | +++ b/target/sparc/cpu.c | ||
1740 | @@ -XXX,XX +XXX,XX @@ | ||
1741 | |||
1742 | //#define DEBUG_FEATURES | ||
1743 | |||
1744 | -static void sparc_cpu_reset_hold(Object *obj) | ||
1745 | +static void sparc_cpu_reset_hold(Object *obj, ResetType type) | ||
1746 | { | ||
1747 | CPUState *cs = CPU(obj); | ||
1748 | SPARCCPUClass *scc = SPARC_CPU_GET_CLASS(obj); | ||
1749 | CPUSPARCState *env = cpu_env(cs); | ||
1750 | |||
1751 | if (scc->parent_phases.hold) { | ||
1752 | - scc->parent_phases.hold(obj); | ||
1753 | + scc->parent_phases.hold(obj, type); | ||
1754 | } | ||
1755 | |||
1756 | memset(env, 0, offsetof(CPUSPARCState, end_reset_fields)); | ||
1757 | diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c | ||
1758 | index XXXXXXX..XXXXXXX 100644 | ||
1759 | --- a/target/tricore/cpu.c | ||
1760 | +++ b/target/tricore/cpu.c | ||
1761 | @@ -XXX,XX +XXX,XX @@ static void tricore_restore_state_to_opc(CPUState *cs, | ||
1762 | cpu_env(cs)->PC = data[0]; | ||
1763 | } | ||
1764 | |||
1765 | -static void tricore_cpu_reset_hold(Object *obj) | ||
1766 | +static void tricore_cpu_reset_hold(Object *obj, ResetType type) | ||
1767 | { | ||
1768 | CPUState *cs = CPU(obj); | ||
1769 | TriCoreCPUClass *tcc = TRICORE_CPU_GET_CLASS(obj); | ||
1770 | |||
1771 | if (tcc->parent_phases.hold) { | ||
1772 | - tcc->parent_phases.hold(obj); | ||
1773 | + tcc->parent_phases.hold(obj, type); | ||
1774 | } | ||
1775 | |||
1776 | cpu_state_reset(cpu_env(cs)); | ||
1777 | diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c | ||
1778 | index XXXXXXX..XXXXXXX 100644 | ||
1779 | --- a/target/xtensa/cpu.c | ||
1780 | +++ b/target/xtensa/cpu.c | ||
1781 | @@ -XXX,XX +XXX,XX @@ bool xtensa_abi_call0(void) | ||
1782 | } | ||
35 | #endif | 1783 | #endif |
36 | } | 1784 | |
1785 | -static void xtensa_cpu_reset_hold(Object *obj) | ||
1786 | +static void xtensa_cpu_reset_hold(Object *obj, ResetType type) | ||
1787 | { | ||
1788 | CPUState *cs = CPU(obj); | ||
1789 | XtensaCPUClass *xcc = XTENSA_CPU_GET_CLASS(obj); | ||
1790 | @@ -XXX,XX +XXX,XX @@ static void xtensa_cpu_reset_hold(Object *obj) | ||
1791 | XTENSA_OPTION_DFP_COPROCESSOR); | ||
1792 | |||
1793 | if (xcc->parent_phases.hold) { | ||
1794 | - xcc->parent_phases.hold(obj); | ||
1795 | + xcc->parent_phases.hold(obj, type); | ||
1796 | } | ||
1797 | |||
1798 | env->pc = env->config->exception_vector[EXC_RESET0 + env->static_vectors]; | ||
37 | -- | 1799 | -- |
38 | 2.34.1 | 1800 | 2.34.1 | diff view generated by jsdifflib |
1 | In the twl92230 device, use int64_t for the two state fields | 1 | Update the reset documentation's example code to match the new API |
---|---|---|---|
2 | sec_offset and alm_sec, because we set these to values that | 2 | for the hold and exit phase method APIs where they take a ResetType |
3 | are either time_t or differences between two time_t values. | 3 | argument. |
4 | |||
5 | These fields aren't saved in vmstate anywhere, so we can | ||
6 | safely widen them. | ||
7 | 4 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | Reviewed-by: Luc Michel <luc.michel@amd.com> | ||
9 | Message-id: 20240412160809.1260625-6-peter.maydell@linaro.org | ||
10 | --- | 10 | --- |
11 | hw/rtc/twl92230.c | 4 ++-- | 11 | docs/devel/reset.rst | 8 ++++---- |
12 | 1 file changed, 2 insertions(+), 2 deletions(-) | 12 | 1 file changed, 4 insertions(+), 4 deletions(-) |
13 | 13 | ||
14 | diff --git a/hw/rtc/twl92230.c b/hw/rtc/twl92230.c | 14 | diff --git a/docs/devel/reset.rst b/docs/devel/reset.rst |
15 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/rtc/twl92230.c | 16 | --- a/docs/devel/reset.rst |
17 | +++ b/hw/rtc/twl92230.c | 17 | +++ b/docs/devel/reset.rst |
18 | @@ -XXX,XX +XXX,XX @@ struct MenelausState { | 18 | @@ -XXX,XX +XXX,XX @@ in reset. |
19 | struct tm tm; | 19 | mydev->var = 0; |
20 | struct tm new; | 20 | } |
21 | struct tm alm; | 21 | |
22 | - int sec_offset; | 22 | - static void mydev_reset_hold(Object *obj) |
23 | - int alm_sec; | 23 | + static void mydev_reset_hold(Object *obj, ResetType type) |
24 | + int64_t sec_offset; | 24 | { |
25 | + int64_t alm_sec; | 25 | MyDevClass *myclass = MYDEV_GET_CLASS(obj); |
26 | int next_comp; | 26 | MyDevState *mydev = MYDEV(obj); |
27 | } rtc; | 27 | /* call parent class hold phase */ |
28 | uint16_t rtc_next_vmstate; | 28 | if (myclass->parent_phases.hold) { |
29 | - myclass->parent_phases.hold(obj); | ||
30 | + myclass->parent_phases.hold(obj, type); | ||
31 | } | ||
32 | /* set an IO */ | ||
33 | qemu_set_irq(mydev->irq, 1); | ||
34 | } | ||
35 | |||
36 | - static void mydev_reset_exit(Object *obj) | ||
37 | + static void mydev_reset_exit(Object *obj, ResetType type) | ||
38 | { | ||
39 | MyDevClass *myclass = MYDEV_GET_CLASS(obj); | ||
40 | MyDevState *mydev = MYDEV(obj); | ||
41 | /* call parent class exit phase */ | ||
42 | if (myclass->parent_phases.exit) { | ||
43 | - myclass->parent_phases.exit(obj); | ||
44 | + myclass->parent_phases.exit(obj, type); | ||
45 | } | ||
46 | /* clear an IO */ | ||
47 | qemu_set_irq(mydev->irq, 0); | ||
29 | -- | 48 | -- |
30 | 2.34.1 | 49 | 2.34.1 |
31 | 50 | ||
32 | 51 | diff view generated by jsdifflib |
1 | The functions qemu_get_timedate() and qemu_timedate_diff() take | 1 | Some devices and machines need to handle the reset before a vmsave |
---|---|---|---|
2 | and return a time offset as an integer. Coverity points out that | 2 | snapshot is loaded differently -- the main user is the handling of |
3 | means that when an RTC device implementation holds an offset | 3 | RNG seed information, which does not want to put a new RNG seed into |
4 | as a time_t, as the m48t59 does, the time_t will get truncated. | 4 | a ROM blob when we are doing a snapshot load. |
5 | (CID 1507157, 1517772). | ||
6 | 5 | ||
7 | The functions work with time_t internally, so make them use that type | 6 | Currently this kind of reset handling is supported only for: |
8 | in their APIs. | 7 | * TYPE_MACHINE reset methods, which take a ShutdownCause argument |
8 | * reset functions registered with qemu_register_reset_nosnapshotload | ||
9 | 9 | ||
10 | Note that this won't help any Y2038 issues where either the device | 10 | To allow a three-phase-reset device to also distinguish "snapshot |
11 | model itself is keeping the offset in a 32-bit integer, or where the | 11 | load" reset from the normal kind, add a new ResetType |
12 | hardware under emulation has Y2038 or other rollover problems. If we | 12 | RESET_TYPE_SNAPSHOT_LOAD. All our existing reset methods ignore |
13 | missed any cases of the former then hopefully Coverity will warn us | 13 | the reset type, so we don't need to update any device code. |
14 | about them since after this patch we'd be truncating a time_t in | 14 | |
15 | assignments from qemu_timedate_diff().) | 15 | Add the enum type, and make qemu_devices_reset() use the |
16 | right reset type for the ShutdownCause it is passed. This | ||
17 | allows us to get rid of the device_reset_reason global we | ||
18 | were using to implement qemu_register_reset_nosnapshotload(). | ||
16 | 19 | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
21 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
18 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 22 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
23 | Reviewed-by: Luc Michel <luc.michel@amd.com> | ||
24 | Message-id: 20240412160809.1260625-7-peter.maydell@linaro.org | ||
19 | --- | 25 | --- |
20 | include/sysemu/rtc.h | 4 ++-- | 26 | docs/devel/reset.rst | 17 ++++++++++++++--- |
21 | softmmu/rtc.c | 4 ++-- | 27 | include/hw/resettable.h | 1 + |
22 | 2 files changed, 4 insertions(+), 4 deletions(-) | 28 | hw/core/reset.c | 15 ++++----------- |
29 | hw/core/resettable.c | 4 ---- | ||
30 | 4 files changed, 19 insertions(+), 18 deletions(-) | ||
23 | 31 | ||
24 | diff --git a/include/sysemu/rtc.h b/include/sysemu/rtc.h | 32 | diff --git a/docs/devel/reset.rst b/docs/devel/reset.rst |
25 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/sysemu/rtc.h | 34 | --- a/docs/devel/reset.rst |
27 | +++ b/include/sysemu/rtc.h | 35 | +++ b/docs/devel/reset.rst |
28 | @@ -XXX,XX +XXX,XX @@ | 36 | @@ -XXX,XX +XXX,XX @@ instantly reset an object, without keeping it in reset state, just call |
29 | * The behaviour of the clock whose value this function returns will | 37 | ``resettable_reset()``. These functions take two parameters: a pointer to the |
30 | * depend on the -rtc command line option passed by the user. | 38 | object to reset and a reset type. |
39 | |||
40 | -Several types of reset will be supported. For now only cold reset is defined; | ||
41 | -others may be added later. The Resettable interface handles reset types with an | ||
42 | -enum: | ||
43 | +The Resettable interface handles reset types with an enum ``ResetType``: | ||
44 | |||
45 | ``RESET_TYPE_COLD`` | ||
46 | Cold reset is supported by every resettable object. In QEMU, it means we reset | ||
47 | @@ -XXX,XX +XXX,XX @@ enum: | ||
48 | from what is a real hardware cold reset. It differs from other resets (like | ||
49 | warm or bus resets) which may keep certain parts untouched. | ||
50 | |||
51 | +``RESET_TYPE_SNAPSHOT_LOAD`` | ||
52 | + This is called for a reset which is being done to put the system into a | ||
53 | + clean state prior to loading a snapshot. (This corresponds to a reset | ||
54 | + with ``SHUTDOWN_CAUSE_SNAPSHOT_LOAD``.) Almost all devices should treat | ||
55 | + this the same as ``RESET_TYPE_COLD``. The main exception is devices which | ||
56 | + have some non-deterministic state they want to reinitialize to a different | ||
57 | + value on each cold reset, such as RNG seed information, and which they | ||
58 | + must not reinitialize on a snapshot-load reset. | ||
59 | + | ||
60 | +Devices which implement reset methods must treat any unknown ``ResetType`` | ||
61 | +as equivalent to ``RESET_TYPE_COLD``; this will reduce the amount of | ||
62 | +existing code we need to change if we add more types in future. | ||
63 | + | ||
64 | Calling ``resettable_reset()`` is equivalent to calling | ||
65 | ``resettable_assert_reset()`` then ``resettable_release_reset()``. It is | ||
66 | possible to interleave multiple calls to these three functions. There may | ||
67 | diff --git a/include/hw/resettable.h b/include/hw/resettable.h | ||
68 | index XXXXXXX..XXXXXXX 100644 | ||
69 | --- a/include/hw/resettable.h | ||
70 | +++ b/include/hw/resettable.h | ||
71 | @@ -XXX,XX +XXX,XX @@ typedef struct ResettableState ResettableState; | ||
31 | */ | 72 | */ |
32 | -void qemu_get_timedate(struct tm *tm, int offset); | 73 | typedef enum ResetType { |
33 | +void qemu_get_timedate(struct tm *tm, time_t offset); | 74 | RESET_TYPE_COLD, |
34 | 75 | + RESET_TYPE_SNAPSHOT_LOAD, | |
35 | /** | 76 | } ResetType; |
36 | * qemu_timedate_diff: Return difference between a struct tm and the RTC | 77 | |
37 | @@ -XXX,XX +XXX,XX @@ void qemu_get_timedate(struct tm *tm, int offset); | 78 | /* |
38 | * a timestamp one hour further ahead than the current RTC time | 79 | diff --git a/hw/core/reset.c b/hw/core/reset.c |
39 | * then this function will return 3600. | ||
40 | */ | ||
41 | -int qemu_timedate_diff(struct tm *tm); | ||
42 | +time_t qemu_timedate_diff(struct tm *tm); | ||
43 | |||
44 | #endif | ||
45 | diff --git a/softmmu/rtc.c b/softmmu/rtc.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | 80 | index XXXXXXX..XXXXXXX 100644 |
47 | --- a/softmmu/rtc.c | 81 | --- a/hw/core/reset.c |
48 | +++ b/softmmu/rtc.c | 82 | +++ b/hw/core/reset.c |
49 | @@ -XXX,XX +XXX,XX @@ static time_t qemu_ref_timedate(QEMUClockType clock) | 83 | @@ -XXX,XX +XXX,XX @@ static ResettableContainer *get_root_reset_container(void) |
50 | return value; | 84 | return root_reset_container; |
51 | } | 85 | } |
52 | 86 | ||
53 | -void qemu_get_timedate(struct tm *tm, int offset) | 87 | -/* |
54 | +void qemu_get_timedate(struct tm *tm, time_t offset) | 88 | - * Reason why the currently in-progress qemu_devices_reset() was called. |
89 | - * If we made at least SHUTDOWN_CAUSE_SNAPSHOT_LOAD have a corresponding | ||
90 | - * ResetType we could perhaps avoid the need for this global. | ||
91 | - */ | ||
92 | -static ShutdownCause device_reset_reason; | ||
93 | - | ||
94 | /* | ||
95 | * This is an Object which implements Resettable simply to call the | ||
96 | * callback function in the hold phase. | ||
97 | @@ -XXX,XX +XXX,XX @@ static void legacy_reset_hold(Object *obj, ResetType type) | ||
55 | { | 98 | { |
56 | time_t ti = qemu_ref_timedate(rtc_clock); | 99 | LegacyReset *lr = LEGACY_RESET(obj); |
57 | 100 | ||
58 | @@ -XXX,XX +XXX,XX @@ void qemu_get_timedate(struct tm *tm, int offset) | 101 | - if (device_reset_reason == SHUTDOWN_CAUSE_SNAPSHOT_LOAD && |
102 | - lr->skip_on_snapshot_load) { | ||
103 | + if (type == RESET_TYPE_SNAPSHOT_LOAD && lr->skip_on_snapshot_load) { | ||
104 | return; | ||
59 | } | 105 | } |
106 | lr->func(lr->opaque); | ||
107 | @@ -XXX,XX +XXX,XX @@ void qemu_unregister_resettable(Object *obj) | ||
108 | |||
109 | void qemu_devices_reset(ShutdownCause reason) | ||
110 | { | ||
111 | - device_reset_reason = reason; | ||
112 | + ResetType type = (reason == SHUTDOWN_CAUSE_SNAPSHOT_LOAD) ? | ||
113 | + RESET_TYPE_SNAPSHOT_LOAD : RESET_TYPE_COLD; | ||
114 | |||
115 | /* Reset the simulation */ | ||
116 | - resettable_reset(OBJECT(get_root_reset_container()), RESET_TYPE_COLD); | ||
117 | + resettable_reset(OBJECT(get_root_reset_container()), type); | ||
60 | } | 118 | } |
61 | 119 | diff --git a/hw/core/resettable.c b/hw/core/resettable.c | |
62 | -int qemu_timedate_diff(struct tm *tm) | 120 | index XXXXXXX..XXXXXXX 100644 |
63 | +time_t qemu_timedate_diff(struct tm *tm) | 121 | --- a/hw/core/resettable.c |
122 | +++ b/hw/core/resettable.c | ||
123 | @@ -XXX,XX +XXX,XX @@ void resettable_reset(Object *obj, ResetType type) | ||
124 | |||
125 | void resettable_assert_reset(Object *obj, ResetType type) | ||
64 | { | 126 | { |
65 | time_t seconds; | 127 | - /* TODO: change this assert when adding support for other reset types */ |
128 | - assert(type == RESET_TYPE_COLD); | ||
129 | trace_resettable_reset_assert_begin(obj, type); | ||
130 | assert(!enter_phase_in_progress); | ||
131 | |||
132 | @@ -XXX,XX +XXX,XX @@ void resettable_assert_reset(Object *obj, ResetType type) | ||
133 | |||
134 | void resettable_release_reset(Object *obj, ResetType type) | ||
135 | { | ||
136 | - /* TODO: change this assert when adding support for other reset types */ | ||
137 | - assert(type == RESET_TYPE_COLD); | ||
138 | trace_resettable_reset_release_begin(obj, type); | ||
139 | assert(!enter_phase_in_progress); | ||
66 | 140 | ||
67 | -- | 141 | -- |
68 | 2.34.1 | 142 | 2.34.1 |
69 | 143 | ||
70 | 144 | diff view generated by jsdifflib |
1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> | 1 | From: Arnaud Minier <arnaud.minier@telecom-paris.fr> |
---|---|---|---|
2 | 2 | ||
3 | The SRC device is normally used to start the secondary CPU. | 3 | Add the basic infrastructure (register read/write, type...) |
4 | to implement the STM32L4x5 USART. | ||
4 | 5 | ||
5 | When running Linux directly, QEMU is emulating a PSCI interface that UBOOT | 6 | Also create different types for the USART, UART and LPUART |
6 | is installing at boot time and therefore the fact that the SRC device is | 7 | of the STM32L4x5 to deduplicate code and enable the |
7 | unimplemented is hidden as Qemu respond directly to PSCI requets without | 8 | implementation of different behaviors depending on the type. |
8 | using the SRC device. | ||
9 | 9 | ||
10 | But if you try to run a more bare metal application (maybe uboot itself), | 10 | Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> |
11 | then it is not possible to start the secondary CPU as the SRC is an | 11 | Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> |
12 | unimplemented device. | ||
13 | |||
14 | This patch adds the ability to start the secondary CPU through the SRC | ||
15 | device so that you can use this feature in bare metal applications. | ||
16 | |||
17 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> | ||
18 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
19 | Message-id: ce9a0162defd2acee5dc7f8a674743de0cded569.1692964892.git.jcd@tribudubois.net | 13 | Message-id: 20240329174402.60382-2-arnaud.minier@telecom-paris.fr |
14 | [PMM: update to new reset hold method signature; | ||
15 | fixed a few checkpatch nits] | ||
20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
21 | --- | 17 | --- |
22 | include/hw/arm/fsl-imx7.h | 3 +- | 18 | MAINTAINERS | 1 + |
23 | include/hw/misc/imx7_src.h | 66 +++++++++ | 19 | include/hw/char/stm32l4x5_usart.h | 66 +++++ |
24 | hw/arm/fsl-imx7.c | 8 +- | 20 | hw/char/stm32l4x5_usart.c | 396 ++++++++++++++++++++++++++++++ |
25 | hw/misc/imx7_src.c | 276 +++++++++++++++++++++++++++++++++++++ | 21 | hw/char/Kconfig | 3 + |
26 | hw/misc/meson.build | 1 + | 22 | hw/char/meson.build | 1 + |
27 | hw/misc/trace-events | 4 + | 23 | hw/char/trace-events | 4 + |
28 | 6 files changed, 356 insertions(+), 2 deletions(-) | 24 | 6 files changed, 471 insertions(+) |
29 | create mode 100644 include/hw/misc/imx7_src.h | 25 | create mode 100644 include/hw/char/stm32l4x5_usart.h |
30 | create mode 100644 hw/misc/imx7_src.c | 26 | create mode 100644 hw/char/stm32l4x5_usart.c |
31 | 27 | ||
32 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h | 28 | diff --git a/MAINTAINERS b/MAINTAINERS |
33 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/include/hw/arm/fsl-imx7.h | 30 | --- a/MAINTAINERS |
35 | +++ b/include/hw/arm/fsl-imx7.h | 31 | +++ b/MAINTAINERS |
36 | @@ -XXX,XX +XXX,XX @@ | 32 | @@ -XXX,XX +XXX,XX @@ M: Inès Varhol <ines.varhol@telecom-paris.fr> |
37 | #include "hw/misc/imx7_ccm.h" | 33 | L: qemu-arm@nongnu.org |
38 | #include "hw/misc/imx7_snvs.h" | 34 | S: Maintained |
39 | #include "hw/misc/imx7_gpr.h" | 35 | F: hw/arm/stm32l4x5_soc.c |
40 | +#include "hw/misc/imx7_src.h" | 36 | +F: hw/char/stm32l4x5_usart.c |
41 | #include "hw/watchdog/wdt_imx2.h" | 37 | F: hw/misc/stm32l4x5_exti.c |
42 | #include "hw/gpio/imx_gpio.h" | 38 | F: hw/misc/stm32l4x5_syscfg.c |
43 | #include "hw/char/imx_serial.h" | 39 | F: hw/misc/stm32l4x5_rcc.c |
44 | @@ -XXX,XX +XXX,XX @@ struct FslIMX7State { | 40 | diff --git a/include/hw/char/stm32l4x5_usart.h b/include/hw/char/stm32l4x5_usart.h |
45 | IMX7CCMState ccm; | ||
46 | IMX7AnalogState analog; | ||
47 | IMX7SNVSState snvs; | ||
48 | + IMX7SRCState src; | ||
49 | IMXGPCv2State gpcv2; | ||
50 | IMXSPIState spi[FSL_IMX7_NUM_ECSPIS]; | ||
51 | IMXI2CState i2c[FSL_IMX7_NUM_I2CS]; | ||
52 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7MemoryMap { | ||
53 | FSL_IMX7_GPC_ADDR = 0x303A0000, | ||
54 | |||
55 | FSL_IMX7_SRC_ADDR = 0x30390000, | ||
56 | - FSL_IMX7_SRC_SIZE = (4 * KiB), | ||
57 | |||
58 | FSL_IMX7_CCM_ADDR = 0x30380000, | ||
59 | |||
60 | diff --git a/include/hw/misc/imx7_src.h b/include/hw/misc/imx7_src.h | ||
61 | new file mode 100644 | 41 | new file mode 100644 |
62 | index XXXXXXX..XXXXXXX | 42 | index XXXXXXX..XXXXXXX |
63 | --- /dev/null | 43 | --- /dev/null |
64 | +++ b/include/hw/misc/imx7_src.h | 44 | +++ b/include/hw/char/stm32l4x5_usart.h |
65 | @@ -XXX,XX +XXX,XX @@ | 45 | @@ -XXX,XX +XXX,XX @@ |
66 | +/* | 46 | +/* |
67 | + * IMX7 System Reset Controller | 47 | + * STM32L4X5 USART (Universal Synchronous Asynchronous Receiver Transmitter) |
68 | + * | 48 | + * |
69 | + * Copyright (C) 2023 Jean-Christophe Dubois <jcd@tribudubois.net> | 49 | + * Copyright (c) 2023 Arnaud Minier <arnaud.minier@telecom-paris.fr> |
50 | + * Copyright (c) 2023 Inès Varhol <ines.varhol@telecom-paris.fr> | ||
51 | + * | ||
52 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
70 | + * | 53 | + * |
71 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | 54 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. |
72 | + * See the COPYING file in the top-level directory. | 55 | + * See the COPYING file in the top-level directory. |
56 | + * | ||
57 | + * The STM32L4X5 USART is heavily inspired by the stm32f2xx_usart | ||
58 | + * by Alistair Francis. | ||
59 | + * The reference used is the STMicroElectronics RM0351 Reference manual | ||
60 | + * for STM32L4x5 and STM32L4x6 advanced Arm ® -based 32-bit MCUs. | ||
73 | + */ | 61 | + */ |
74 | + | 62 | + |
75 | +#ifndef IMX7_SRC_H | 63 | +#ifndef HW_STM32L4X5_USART_H |
76 | +#define IMX7_SRC_H | 64 | +#define HW_STM32L4X5_USART_H |
77 | + | 65 | + |
78 | +#include "hw/sysbus.h" | 66 | +#include "hw/sysbus.h" |
79 | +#include "qemu/bitops.h" | 67 | +#include "chardev/char-fe.h" |
80 | +#include "qom/object.h" | 68 | +#include "qom/object.h" |
81 | + | 69 | + |
82 | +#define SRC_SCR 0 | 70 | +#define TYPE_STM32L4X5_USART_BASE "stm32l4x5-usart-base" |
83 | +#define SRC_A7RCR0 1 | 71 | +#define TYPE_STM32L4X5_USART "stm32l4x5-usart" |
84 | +#define SRC_A7RCR1 2 | 72 | +#define TYPE_STM32L4X5_UART "stm32l4x5-uart" |
85 | +#define SRC_M4RCR 3 | 73 | +#define TYPE_STM32L4X5_LPUART "stm32l4x5-lpuart" |
86 | +#define SRC_ERCR 5 | 74 | +OBJECT_DECLARE_TYPE(Stm32l4x5UsartBaseState, Stm32l4x5UsartBaseClass, |
87 | +#define SRC_HSICPHY_RCR 7 | 75 | + STM32L4X5_USART_BASE) |
88 | +#define SRC_USBOPHY1_RCR 8 | 76 | + |
89 | +#define SRC_USBOPHY2_RCR 9 | 77 | +typedef enum { |
90 | +#define SRC_MPIPHY_RCR 10 | 78 | + STM32L4x5_USART, |
91 | +#define SRC_PCIEPHY_RCR 11 | 79 | + STM32L4x5_UART, |
92 | +#define SRC_SBMR1 22 | 80 | + STM32L4x5_LPUART, |
93 | +#define SRC_SRSR 23 | 81 | +} Stm32l4x5UsartType; |
94 | +#define SRC_SISR 26 | 82 | + |
95 | +#define SRC_SIMR 27 | 83 | +struct Stm32l4x5UsartBaseState { |
96 | +#define SRC_SBMR2 28 | ||
97 | +#define SRC_GPR1 29 | ||
98 | +#define SRC_GPR2 30 | ||
99 | +#define SRC_GPR3 31 | ||
100 | +#define SRC_GPR4 32 | ||
101 | +#define SRC_GPR5 33 | ||
102 | +#define SRC_GPR6 34 | ||
103 | +#define SRC_GPR7 35 | ||
104 | +#define SRC_GPR8 36 | ||
105 | +#define SRC_GPR9 37 | ||
106 | +#define SRC_GPR10 38 | ||
107 | +#define SRC_MAX 39 | ||
108 | + | ||
109 | +/* SRC_A7SCR1 */ | ||
110 | +#define R_CORE1_ENABLE_SHIFT 1 | ||
111 | +#define R_CORE1_ENABLE_LENGTH 1 | ||
112 | +/* SRC_A7SCR0 */ | ||
113 | +#define R_CORE1_RST_SHIFT 5 | ||
114 | +#define R_CORE1_RST_LENGTH 1 | ||
115 | +#define R_CORE0_RST_SHIFT 4 | ||
116 | +#define R_CORE0_RST_LENGTH 1 | ||
117 | + | ||
118 | +#define TYPE_IMX7_SRC "imx7.src" | ||
119 | +OBJECT_DECLARE_SIMPLE_TYPE(IMX7SRCState, IMX7_SRC) | ||
120 | + | ||
121 | +struct IMX7SRCState { | ||
122 | + /* <private> */ | ||
123 | + SysBusDevice parent_obj; | 84 | + SysBusDevice parent_obj; |
124 | + | 85 | + |
125 | + /* <public> */ | 86 | + MemoryRegion mmio; |
126 | + MemoryRegion iomem; | 87 | + |
127 | + | 88 | + uint32_t cr1; |
128 | + uint32_t regs[SRC_MAX]; | 89 | + uint32_t cr2; |
90 | + uint32_t cr3; | ||
91 | + uint32_t brr; | ||
92 | + uint32_t gtpr; | ||
93 | + uint32_t rtor; | ||
94 | + /* rqr is write-only */ | ||
95 | + uint32_t isr; | ||
96 | + /* icr is a clear register */ | ||
97 | + uint32_t rdr; | ||
98 | + uint32_t tdr; | ||
99 | + | ||
100 | + Clock *clk; | ||
101 | + CharBackend chr; | ||
102 | + qemu_irq irq; | ||
129 | +}; | 103 | +}; |
130 | + | 104 | + |
131 | +#endif /* IMX7_SRC_H */ | 105 | +struct Stm32l4x5UsartBaseClass { |
132 | diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c | 106 | + SysBusDeviceClass parent_class; |
133 | index XXXXXXX..XXXXXXX 100644 | 107 | + |
134 | --- a/hw/arm/fsl-imx7.c | 108 | + Stm32l4x5UsartType type; |
135 | +++ b/hw/arm/fsl-imx7.c | 109 | +}; |
136 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_init(Object *obj) | 110 | + |
137 | */ | 111 | +#endif /* HW_STM32L4X5_USART_H */ |
138 | object_initialize_child(obj, "gpcv2", &s->gpcv2, TYPE_IMX_GPCV2); | 112 | diff --git a/hw/char/stm32l4x5_usart.c b/hw/char/stm32l4x5_usart.c |
139 | |||
140 | + /* | ||
141 | + * SRC | ||
142 | + */ | ||
143 | + object_initialize_child(obj, "src", &s->src, TYPE_IMX7_SRC); | ||
144 | + | ||
145 | /* | ||
146 | * ECSPIs | ||
147 | */ | ||
148 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
149 | /* | ||
150 | * SRC | ||
151 | */ | ||
152 | - create_unimplemented_device("src", FSL_IMX7_SRC_ADDR, FSL_IMX7_SRC_SIZE); | ||
153 | + sysbus_realize(SYS_BUS_DEVICE(&s->src), &error_abort); | ||
154 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->src), 0, FSL_IMX7_SRC_ADDR); | ||
155 | |||
156 | /* | ||
157 | * Watchdogs | ||
158 | diff --git a/hw/misc/imx7_src.c b/hw/misc/imx7_src.c | ||
159 | new file mode 100644 | 113 | new file mode 100644 |
160 | index XXXXXXX..XXXXXXX | 114 | index XXXXXXX..XXXXXXX |
161 | --- /dev/null | 115 | --- /dev/null |
162 | +++ b/hw/misc/imx7_src.c | 116 | +++ b/hw/char/stm32l4x5_usart.c |
163 | @@ -XXX,XX +XXX,XX @@ | 117 | @@ -XXX,XX +XXX,XX @@ |
164 | +/* | 118 | +/* |
165 | + * IMX7 System Reset Controller | 119 | + * STM32L4X5 USART (Universal Synchronous Asynchronous Receiver Transmitter) |
166 | + * | 120 | + * |
167 | + * Copyright (c) 2023 Jean-Christophe Dubois <jcd@tribudubois.net> | 121 | + * Copyright (c) 2023 Arnaud Minier <arnaud.minier@telecom-paris.fr> |
122 | + * Copyright (c) 2023 Inès Varhol <ines.varhol@telecom-paris.fr> | ||
123 | + * | ||
124 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
168 | + * | 125 | + * |
169 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | 126 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. |
170 | + * See the COPYING file in the top-level directory. | 127 | + * See the COPYING file in the top-level directory. |
171 | + * | 128 | + * |
129 | + * The STM32L4X5 USART is heavily inspired by the stm32f2xx_usart | ||
130 | + * by Alistair Francis. | ||
131 | + * The reference used is the STMicroElectronics RM0351 Reference manual | ||
132 | + * for STM32L4x5 and STM32L4x6 advanced Arm ® -based 32-bit MCUs. | ||
172 | + */ | 133 | + */ |
173 | + | 134 | + |
174 | +#include "qemu/osdep.h" | 135 | +#include "qemu/osdep.h" |
175 | +#include "hw/misc/imx7_src.h" | 136 | +#include "qemu/log.h" |
137 | +#include "qemu/module.h" | ||
138 | +#include "qapi/error.h" | ||
139 | +#include "chardev/char-fe.h" | ||
140 | +#include "chardev/char-serial.h" | ||
176 | +#include "migration/vmstate.h" | 141 | +#include "migration/vmstate.h" |
177 | +#include "qemu/bitops.h" | 142 | +#include "hw/char/stm32l4x5_usart.h" |
178 | +#include "qemu/log.h" | 143 | +#include "hw/clock.h" |
179 | +#include "qemu/main-loop.h" | 144 | +#include "hw/irq.h" |
180 | +#include "qemu/module.h" | 145 | +#include "hw/qdev-clock.h" |
181 | +#include "target/arm/arm-powerctl.h" | 146 | +#include "hw/qdev-properties.h" |
182 | +#include "hw/core/cpu.h" | 147 | +#include "hw/qdev-properties-system.h" |
183 | +#include "hw/registerfields.h" | 148 | +#include "hw/registerfields.h" |
184 | + | ||
185 | +#include "trace.h" | 149 | +#include "trace.h" |
186 | + | 150 | + |
187 | +static const char *imx7_src_reg_name(uint32_t reg) | 151 | + |
188 | +{ | 152 | +REG32(CR1, 0x00) |
189 | + static char unknown[20]; | 153 | + FIELD(CR1, M1, 28, 1) /* Word length (part 2, see M0) */ |
190 | + | 154 | + FIELD(CR1, EOBIE, 27, 1) /* End of Block interrupt enable */ |
191 | + switch (reg) { | 155 | + FIELD(CR1, RTOIE, 26, 1) /* Receiver timeout interrupt enable */ |
192 | + case SRC_SCR: | 156 | + FIELD(CR1, DEAT, 21, 5) /* Driver Enable assertion time */ |
193 | + return "SRC_SCR"; | 157 | + FIELD(CR1, DEDT, 16, 5) /* Driver Enable de-assertion time */ |
194 | + case SRC_A7RCR0: | 158 | + FIELD(CR1, OVER8, 15, 1) /* Oversampling mode */ |
195 | + return "SRC_A7RCR0"; | 159 | + FIELD(CR1, CMIE, 14, 1) /* Character match interrupt enable */ |
196 | + case SRC_A7RCR1: | 160 | + FIELD(CR1, MME, 13, 1) /* Mute mode enable */ |
197 | + return "SRC_A7RCR1"; | 161 | + FIELD(CR1, M0, 12, 1) /* Word length (part 1, see M1) */ |
198 | + case SRC_M4RCR: | 162 | + FIELD(CR1, WAKE, 11, 1) /* Receiver wakeup method */ |
199 | + return "SRC_M4RCR"; | 163 | + FIELD(CR1, PCE, 10, 1) /* Parity control enable */ |
200 | + case SRC_ERCR: | 164 | + FIELD(CR1, PS, 9, 1) /* Parity selection */ |
201 | + return "SRC_ERCR"; | 165 | + FIELD(CR1, PEIE, 8, 1) /* PE interrupt enable */ |
202 | + case SRC_HSICPHY_RCR: | 166 | + FIELD(CR1, TXEIE, 7, 1) /* TXE interrupt enable */ |
203 | + return "SRC_HSICPHY_RCR"; | 167 | + FIELD(CR1, TCIE, 6, 1) /* Transmission complete interrupt enable */ |
204 | + case SRC_USBOPHY1_RCR: | 168 | + FIELD(CR1, RXNEIE, 5, 1) /* RXNE interrupt enable */ |
205 | + return "SRC_USBOPHY1_RCR"; | 169 | + FIELD(CR1, IDLEIE, 4, 1) /* IDLE interrupt enable */ |
206 | + case SRC_USBOPHY2_RCR: | 170 | + FIELD(CR1, TE, 3, 1) /* Transmitter enable */ |
207 | + return "SRC_USBOPHY2_RCR"; | 171 | + FIELD(CR1, RE, 2, 1) /* Receiver enable */ |
208 | + case SRC_PCIEPHY_RCR: | 172 | + FIELD(CR1, UESM, 1, 1) /* USART enable in Stop mode */ |
209 | + return "SRC_PCIEPHY_RCR"; | 173 | + FIELD(CR1, UE, 0, 1) /* USART enable */ |
210 | + case SRC_SBMR1: | 174 | +REG32(CR2, 0x04) |
211 | + return "SRC_SBMR1"; | 175 | + FIELD(CR2, ADD_1, 28, 4) /* ADD[7:4] */ |
212 | + case SRC_SRSR: | 176 | + FIELD(CR2, ADD_0, 24, 1) /* ADD[3:0] */ |
213 | + return "SRC_SRSR"; | 177 | + FIELD(CR2, RTOEN, 23, 1) /* Receiver timeout enable */ |
214 | + case SRC_SISR: | 178 | + FIELD(CR2, ABRMOD, 21, 2) /* Auto baud rate mode */ |
215 | + return "SRC_SISR"; | 179 | + FIELD(CR2, ABREN, 20, 1) /* Auto baud rate enable */ |
216 | + case SRC_SIMR: | 180 | + FIELD(CR2, MSBFIRST, 19, 1) /* Most significant bit first */ |
217 | + return "SRC_SIMR"; | 181 | + FIELD(CR2, DATAINV, 18, 1) /* Binary data inversion */ |
218 | + case SRC_SBMR2: | 182 | + FIELD(CR2, TXINV, 17, 1) /* TX pin active level inversion */ |
219 | + return "SRC_SBMR2"; | 183 | + FIELD(CR2, RXINV, 16, 1) /* RX pin active level inversion */ |
220 | + case SRC_GPR1: | 184 | + FIELD(CR2, SWAP, 15, 1) /* Swap RX/TX pins */ |
221 | + return "SRC_GPR1"; | 185 | + FIELD(CR2, LINEN, 14, 1) /* LIN mode enable */ |
222 | + case SRC_GPR2: | 186 | + FIELD(CR2, STOP, 12, 2) /* STOP bits */ |
223 | + return "SRC_GPR2"; | 187 | + FIELD(CR2, CLKEN, 11, 1) /* Clock enable */ |
224 | + case SRC_GPR3: | 188 | + FIELD(CR2, CPOL, 10, 1) /* Clock polarity */ |
225 | + return "SRC_GPR3"; | 189 | + FIELD(CR2, CPHA, 9, 1) /* Clock phase */ |
226 | + case SRC_GPR4: | 190 | + FIELD(CR2, LBCL, 8, 1) /* Last bit clock pulse */ |
227 | + return "SRC_GPR4"; | 191 | + FIELD(CR2, LBDIE, 6, 1) /* LIN break detection interrupt enable */ |
228 | + case SRC_GPR5: | 192 | + FIELD(CR2, LBDL, 5, 1) /* LIN break detection length */ |
229 | + return "SRC_GPR5"; | 193 | + FIELD(CR2, ADDM7, 4, 1) /* 7-bit / 4-bit Address Detection */ |
230 | + case SRC_GPR6: | 194 | + |
231 | + return "SRC_GPR6"; | 195 | +REG32(CR3, 0x08) |
232 | + case SRC_GPR7: | 196 | + /* TCBGTIE only on STM32L496xx/4A6xx devices */ |
233 | + return "SRC_GPR7"; | 197 | + FIELD(CR3, UCESM, 23, 1) /* USART Clock Enable in Stop Mode */ |
234 | + case SRC_GPR8: | 198 | + FIELD(CR3, WUFIE, 22, 1) /* Wakeup from Stop mode interrupt enable */ |
235 | + return "SRC_GPR8"; | 199 | + FIELD(CR3, WUS, 20, 2) /* Wakeup from Stop mode interrupt flag selection */ |
236 | + case SRC_GPR9: | 200 | + FIELD(CR3, SCARCNT, 17, 3) /* Smartcard auto-retry count */ |
237 | + return "SRC_GPR9"; | 201 | + FIELD(CR3, DEP, 15, 1) /* Driver enable polarity selection */ |
238 | + case SRC_GPR10: | 202 | + FIELD(CR3, DEM, 14, 1) /* Driver enable mode */ |
239 | + return "SRC_GPR10"; | 203 | + FIELD(CR3, DDRE, 13, 1) /* DMA Disable on Reception Error */ |
204 | + FIELD(CR3, OVRDIS, 12, 1) /* Overrun Disable */ | ||
205 | + FIELD(CR3, ONEBIT, 11, 1) /* One sample bit method enable */ | ||
206 | + FIELD(CR3, CTSIE, 10, 1) /* CTS interrupt enable */ | ||
207 | + FIELD(CR3, CTSE, 9, 1) /* CTS enable */ | ||
208 | + FIELD(CR3, RTSE, 8, 1) /* RTS enable */ | ||
209 | + FIELD(CR3, DMAT, 7, 1) /* DMA enable transmitter */ | ||
210 | + FIELD(CR3, DMAR, 6, 1) /* DMA enable receiver */ | ||
211 | + FIELD(CR3, SCEN, 5, 1) /* Smartcard mode enable */ | ||
212 | + FIELD(CR3, NACK, 4, 1) /* Smartcard NACK enable */ | ||
213 | + FIELD(CR3, HDSEL, 3, 1) /* Half-duplex selection */ | ||
214 | + FIELD(CR3, IRLP, 2, 1) /* IrDA low-power */ | ||
215 | + FIELD(CR3, IREN, 1, 1) /* IrDA mode enable */ | ||
216 | + FIELD(CR3, EIE, 0, 1) /* Error interrupt enable */ | ||
217 | +REG32(BRR, 0x0C) | ||
218 | + FIELD(BRR, BRR, 0, 16) | ||
219 | +REG32(GTPR, 0x10) | ||
220 | + FIELD(GTPR, GT, 8, 8) /* Guard time value */ | ||
221 | + FIELD(GTPR, PSC, 0, 8) /* Prescaler value */ | ||
222 | +REG32(RTOR, 0x14) | ||
223 | + FIELD(RTOR, BLEN, 24, 8) /* Block Length */ | ||
224 | + FIELD(RTOR, RTO, 0, 24) /* Receiver timeout value */ | ||
225 | +REG32(RQR, 0x18) | ||
226 | + FIELD(RQR, TXFRQ, 4, 1) /* Transmit data flush request */ | ||
227 | + FIELD(RQR, RXFRQ, 3, 1) /* Receive data flush request */ | ||
228 | + FIELD(RQR, MMRQ, 2, 1) /* Mute mode request */ | ||
229 | + FIELD(RQR, SBKRQ, 1, 1) /* Send break request */ | ||
230 | + FIELD(RQR, ABBRRQ, 0, 1) /* Auto baud rate request */ | ||
231 | +REG32(ISR, 0x1C) | ||
232 | + /* TCBGT only for STM32L475xx/476xx/486xx devices */ | ||
233 | + FIELD(ISR, REACK, 22, 1) /* Receive enable acknowledge flag */ | ||
234 | + FIELD(ISR, TEACK, 21, 1) /* Transmit enable acknowledge flag */ | ||
235 | + FIELD(ISR, WUF, 20, 1) /* Wakeup from Stop mode flag */ | ||
236 | + FIELD(ISR, RWU, 19, 1) /* Receiver wakeup from Mute mode */ | ||
237 | + FIELD(ISR, SBKF, 18, 1) /* Send break flag */ | ||
238 | + FIELD(ISR, CMF, 17, 1) /* Character match flag */ | ||
239 | + FIELD(ISR, BUSY, 16, 1) /* Busy flag */ | ||
240 | + FIELD(ISR, ABRF, 15, 1) /* Auto Baud rate flag */ | ||
241 | + FIELD(ISR, ABRE, 14, 1) /* Auto Baud rate error */ | ||
242 | + FIELD(ISR, EOBF, 12, 1) /* End of block flag */ | ||
243 | + FIELD(ISR, RTOF, 11, 1) /* Receiver timeout */ | ||
244 | + FIELD(ISR, CTS, 10, 1) /* CTS flag */ | ||
245 | + FIELD(ISR, CTSIF, 9, 1) /* CTS interrupt flag */ | ||
246 | + FIELD(ISR, LBDF, 8, 1) /* LIN break detection flag */ | ||
247 | + FIELD(ISR, TXE, 7, 1) /* Transmit data register empty */ | ||
248 | + FIELD(ISR, TC, 6, 1) /* Transmission complete */ | ||
249 | + FIELD(ISR, RXNE, 5, 1) /* Read data register not empty */ | ||
250 | + FIELD(ISR, IDLE, 4, 1) /* Idle line detected */ | ||
251 | + FIELD(ISR, ORE, 3, 1) /* Overrun error */ | ||
252 | + FIELD(ISR, NF, 2, 1) /* START bit Noise detection flag */ | ||
253 | + FIELD(ISR, FE, 1, 1) /* Framing Error */ | ||
254 | + FIELD(ISR, PE, 0, 1) /* Parity Error */ | ||
255 | +REG32(ICR, 0x20) | ||
256 | + FIELD(ICR, WUCF, 20, 1) /* Wakeup from Stop mode clear flag */ | ||
257 | + FIELD(ICR, CMCF, 17, 1) /* Character match clear flag */ | ||
258 | + FIELD(ICR, EOBCF, 12, 1) /* End of block clear flag */ | ||
259 | + FIELD(ICR, RTOCF, 11, 1) /* Receiver timeout clear flag */ | ||
260 | + FIELD(ICR, CTSCF, 9, 1) /* CTS clear flag */ | ||
261 | + FIELD(ICR, LBDCF, 8, 1) /* LIN break detection clear flag */ | ||
262 | + /* TCBGTCF only on STM32L496xx/4A6xx devices */ | ||
263 | + FIELD(ICR, TCCF, 6, 1) /* Transmission complete clear flag */ | ||
264 | + FIELD(ICR, IDLECF, 4, 1) /* Idle line detected clear flag */ | ||
265 | + FIELD(ICR, ORECF, 3, 1) /* Overrun error clear flag */ | ||
266 | + FIELD(ICR, NCF, 2, 1) /* Noise detected clear flag */ | ||
267 | + FIELD(ICR, FECF, 1, 1) /* Framing error clear flag */ | ||
268 | + FIELD(ICR, PECF, 0, 1) /* Parity error clear flag */ | ||
269 | +REG32(RDR, 0x24) | ||
270 | + FIELD(RDR, RDR, 0, 9) | ||
271 | +REG32(TDR, 0x28) | ||
272 | + FIELD(TDR, TDR, 0, 9) | ||
273 | + | ||
274 | +static void stm32l4x5_usart_base_reset_hold(Object *obj, ResetType type) | ||
275 | +{ | ||
276 | + Stm32l4x5UsartBaseState *s = STM32L4X5_USART_BASE(obj); | ||
277 | + | ||
278 | + s->cr1 = 0x00000000; | ||
279 | + s->cr2 = 0x00000000; | ||
280 | + s->cr3 = 0x00000000; | ||
281 | + s->brr = 0x00000000; | ||
282 | + s->gtpr = 0x00000000; | ||
283 | + s->rtor = 0x00000000; | ||
284 | + s->isr = 0x020000C0; | ||
285 | + s->rdr = 0x00000000; | ||
286 | + s->tdr = 0x00000000; | ||
287 | +} | ||
288 | + | ||
289 | +static uint64_t stm32l4x5_usart_base_read(void *opaque, hwaddr addr, | ||
290 | + unsigned int size) | ||
291 | +{ | ||
292 | + Stm32l4x5UsartBaseState *s = opaque; | ||
293 | + uint64_t retvalue = 0; | ||
294 | + | ||
295 | + switch (addr) { | ||
296 | + case A_CR1: | ||
297 | + retvalue = s->cr1; | ||
298 | + break; | ||
299 | + case A_CR2: | ||
300 | + retvalue = s->cr2; | ||
301 | + break; | ||
302 | + case A_CR3: | ||
303 | + retvalue = s->cr3; | ||
304 | + break; | ||
305 | + case A_BRR: | ||
306 | + retvalue = FIELD_EX32(s->brr, BRR, BRR); | ||
307 | + break; | ||
308 | + case A_GTPR: | ||
309 | + retvalue = s->gtpr; | ||
310 | + break; | ||
311 | + case A_RTOR: | ||
312 | + retvalue = s->rtor; | ||
313 | + break; | ||
314 | + case A_RQR: | ||
315 | + /* RQR is a write only register */ | ||
316 | + retvalue = 0x00000000; | ||
317 | + break; | ||
318 | + case A_ISR: | ||
319 | + retvalue = s->isr; | ||
320 | + break; | ||
321 | + case A_ICR: | ||
322 | + /* ICR is a clear register */ | ||
323 | + retvalue = 0x00000000; | ||
324 | + break; | ||
325 | + case A_RDR: | ||
326 | + retvalue = FIELD_EX32(s->rdr, RDR, RDR); | ||
327 | + /* Reset RXNE flag */ | ||
328 | + s->isr &= ~R_ISR_RXNE_MASK; | ||
329 | + break; | ||
330 | + case A_TDR: | ||
331 | + retvalue = FIELD_EX32(s->tdr, TDR, TDR); | ||
332 | + break; | ||
240 | + default: | 333 | + default: |
241 | + sprintf(unknown, "%u ?", reg); | 334 | + qemu_log_mask(LOG_GUEST_ERROR, |
242 | + return unknown; | 335 | + "%s: Bad offset 0x%"HWADDR_PRIx"\n", __func__, addr); |
336 | + break; | ||
243 | + } | 337 | + } |
244 | +} | 338 | + |
245 | + | 339 | + trace_stm32l4x5_usart_read(addr, retvalue); |
246 | +static const VMStateDescription vmstate_imx7_src = { | 340 | + |
247 | + .name = TYPE_IMX7_SRC, | 341 | + return retvalue; |
342 | +} | ||
343 | + | ||
344 | +static void stm32l4x5_usart_base_write(void *opaque, hwaddr addr, | ||
345 | + uint64_t val64, unsigned int size) | ||
346 | +{ | ||
347 | + Stm32l4x5UsartBaseState *s = opaque; | ||
348 | + const uint32_t value = val64; | ||
349 | + | ||
350 | + trace_stm32l4x5_usart_write(addr, value); | ||
351 | + | ||
352 | + switch (addr) { | ||
353 | + case A_CR1: | ||
354 | + s->cr1 = value; | ||
355 | + return; | ||
356 | + case A_CR2: | ||
357 | + s->cr2 = value; | ||
358 | + return; | ||
359 | + case A_CR3: | ||
360 | + s->cr3 = value; | ||
361 | + return; | ||
362 | + case A_BRR: | ||
363 | + s->brr = value; | ||
364 | + return; | ||
365 | + case A_GTPR: | ||
366 | + s->gtpr = value; | ||
367 | + return; | ||
368 | + case A_RTOR: | ||
369 | + s->rtor = value; | ||
370 | + return; | ||
371 | + case A_RQR: | ||
372 | + return; | ||
373 | + case A_ISR: | ||
374 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
375 | + "%s: ISR is read only !\n", __func__); | ||
376 | + return; | ||
377 | + case A_ICR: | ||
378 | + /* Clear the status flags */ | ||
379 | + s->isr &= ~value; | ||
380 | + return; | ||
381 | + case A_RDR: | ||
382 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
383 | + "%s: RDR is read only !\n", __func__); | ||
384 | + return; | ||
385 | + case A_TDR: | ||
386 | + s->tdr = value; | ||
387 | + return; | ||
388 | + default: | ||
389 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
390 | + "%s: Bad offset 0x%"HWADDR_PRIx"\n", __func__, addr); | ||
391 | + } | ||
392 | +} | ||
393 | + | ||
394 | +static const MemoryRegionOps stm32l4x5_usart_base_ops = { | ||
395 | + .read = stm32l4x5_usart_base_read, | ||
396 | + .write = stm32l4x5_usart_base_write, | ||
397 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
398 | + .valid = { | ||
399 | + .max_access_size = 4, | ||
400 | + .min_access_size = 4, | ||
401 | + .unaligned = false | ||
402 | + }, | ||
403 | + .impl = { | ||
404 | + .max_access_size = 4, | ||
405 | + .min_access_size = 4, | ||
406 | + .unaligned = false | ||
407 | + }, | ||
408 | +}; | ||
409 | + | ||
410 | +static Property stm32l4x5_usart_base_properties[] = { | ||
411 | + DEFINE_PROP_CHR("chardev", Stm32l4x5UsartBaseState, chr), | ||
412 | + DEFINE_PROP_END_OF_LIST(), | ||
413 | +}; | ||
414 | + | ||
415 | +static void stm32l4x5_usart_base_init(Object *obj) | ||
416 | +{ | ||
417 | + Stm32l4x5UsartBaseState *s = STM32L4X5_USART_BASE(obj); | ||
418 | + | ||
419 | + sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->irq); | ||
420 | + | ||
421 | + memory_region_init_io(&s->mmio, obj, &stm32l4x5_usart_base_ops, s, | ||
422 | + TYPE_STM32L4X5_USART_BASE, 0x400); | ||
423 | + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); | ||
424 | + | ||
425 | + s->clk = qdev_init_clock_in(DEVICE(s), "clk", NULL, s, 0); | ||
426 | +} | ||
427 | + | ||
428 | +static const VMStateDescription vmstate_stm32l4x5_usart_base = { | ||
429 | + .name = TYPE_STM32L4X5_USART_BASE, | ||
248 | + .version_id = 1, | 430 | + .version_id = 1, |
249 | + .minimum_version_id = 1, | 431 | + .minimum_version_id = 1, |
250 | + .fields = (VMStateField[]) { | 432 | + .fields = (VMStateField[]) { |
251 | + VMSTATE_UINT32_ARRAY(regs, IMX7SRCState, SRC_MAX), | 433 | + VMSTATE_UINT32(cr1, Stm32l4x5UsartBaseState), |
434 | + VMSTATE_UINT32(cr2, Stm32l4x5UsartBaseState), | ||
435 | + VMSTATE_UINT32(cr3, Stm32l4x5UsartBaseState), | ||
436 | + VMSTATE_UINT32(brr, Stm32l4x5UsartBaseState), | ||
437 | + VMSTATE_UINT32(gtpr, Stm32l4x5UsartBaseState), | ||
438 | + VMSTATE_UINT32(rtor, Stm32l4x5UsartBaseState), | ||
439 | + VMSTATE_UINT32(isr, Stm32l4x5UsartBaseState), | ||
440 | + VMSTATE_UINT32(rdr, Stm32l4x5UsartBaseState), | ||
441 | + VMSTATE_UINT32(tdr, Stm32l4x5UsartBaseState), | ||
442 | + VMSTATE_CLOCK(clk, Stm32l4x5UsartBaseState), | ||
252 | + VMSTATE_END_OF_LIST() | 443 | + VMSTATE_END_OF_LIST() |
253 | + }, | 444 | + } |
254 | +}; | 445 | +}; |
255 | + | 446 | + |
256 | +static void imx7_src_reset(DeviceState *dev) | 447 | + |
257 | +{ | 448 | +static void stm32l4x5_usart_base_realize(DeviceState *dev, Error **errp) |
258 | + IMX7SRCState *s = IMX7_SRC(dev); | 449 | +{ |
259 | + | 450 | + ERRP_GUARD(); |
260 | + memset(s->regs, 0, sizeof(s->regs)); | 451 | + Stm32l4x5UsartBaseState *s = STM32L4X5_USART_BASE(dev); |
261 | + | 452 | + if (!clock_has_source(s->clk)) { |
262 | + /* Set reset values */ | 453 | + error_setg(errp, "USART clock must be wired up by SoC code"); |
263 | + s->regs[SRC_SCR] = 0xA0; | 454 | + return; |
264 | + s->regs[SRC_SRSR] = 0x1; | ||
265 | + s->regs[SRC_SIMR] = 0x1F; | ||
266 | +} | ||
267 | + | ||
268 | +static uint64_t imx7_src_read(void *opaque, hwaddr offset, unsigned size) | ||
269 | +{ | ||
270 | + uint32_t value = 0; | ||
271 | + IMX7SRCState *s = (IMX7SRCState *)opaque; | ||
272 | + uint32_t index = offset >> 2; | ||
273 | + | ||
274 | + if (index < SRC_MAX) { | ||
275 | + value = s->regs[index]; | ||
276 | + } else { | ||
277 | + qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad register at offset 0x%" | ||
278 | + HWADDR_PRIx "\n", TYPE_IMX7_SRC, __func__, offset); | ||
279 | + } | 455 | + } |
280 | + | 456 | +} |
281 | + trace_imx7_src_read(imx7_src_reg_name(index), value); | 457 | + |
282 | + | 458 | +static void stm32l4x5_usart_base_class_init(ObjectClass *klass, void *data) |
283 | + return value; | 459 | +{ |
284 | +} | 460 | + DeviceClass *dc = DEVICE_CLASS(klass); |
285 | + | 461 | + ResettableClass *rc = RESETTABLE_CLASS(klass); |
286 | + | 462 | + |
287 | +/* | 463 | + rc->phases.hold = stm32l4x5_usart_base_reset_hold; |
288 | + * The reset is asynchronous so we need to defer clearing the reset | 464 | + device_class_set_props(dc, stm32l4x5_usart_base_properties); |
289 | + * bit until the work is completed. | 465 | + dc->realize = stm32l4x5_usart_base_realize; |
290 | + */ | 466 | + dc->vmsd = &vmstate_stm32l4x5_usart_base; |
291 | + | 467 | +} |
292 | +struct SRCSCRResetInfo { | 468 | + |
293 | + IMX7SRCState *s; | 469 | +static void stm32l4x5_usart_class_init(ObjectClass *oc, void *data) |
294 | + uint32_t reset_bit; | 470 | +{ |
471 | + Stm32l4x5UsartBaseClass *subc = STM32L4X5_USART_BASE_CLASS(oc); | ||
472 | + | ||
473 | + subc->type = STM32L4x5_USART; | ||
474 | +} | ||
475 | + | ||
476 | +static void stm32l4x5_uart_class_init(ObjectClass *oc, void *data) | ||
477 | +{ | ||
478 | + Stm32l4x5UsartBaseClass *subc = STM32L4X5_USART_BASE_CLASS(oc); | ||
479 | + | ||
480 | + subc->type = STM32L4x5_UART; | ||
481 | +} | ||
482 | + | ||
483 | +static void stm32l4x5_lpuart_class_init(ObjectClass *oc, void *data) | ||
484 | +{ | ||
485 | + Stm32l4x5UsartBaseClass *subc = STM32L4X5_USART_BASE_CLASS(oc); | ||
486 | + | ||
487 | + subc->type = STM32L4x5_LPUART; | ||
488 | +} | ||
489 | + | ||
490 | +static const TypeInfo stm32l4x5_usart_types[] = { | ||
491 | + { | ||
492 | + .name = TYPE_STM32L4X5_USART_BASE, | ||
493 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
494 | + .instance_size = sizeof(Stm32l4x5UsartBaseState), | ||
495 | + .instance_init = stm32l4x5_usart_base_init, | ||
496 | + .class_init = stm32l4x5_usart_base_class_init, | ||
497 | + .abstract = true, | ||
498 | + }, { | ||
499 | + .name = TYPE_STM32L4X5_USART, | ||
500 | + .parent = TYPE_STM32L4X5_USART_BASE, | ||
501 | + .class_init = stm32l4x5_usart_class_init, | ||
502 | + }, { | ||
503 | + .name = TYPE_STM32L4X5_UART, | ||
504 | + .parent = TYPE_STM32L4X5_USART_BASE, | ||
505 | + .class_init = stm32l4x5_uart_class_init, | ||
506 | + }, { | ||
507 | + .name = TYPE_STM32L4X5_LPUART, | ||
508 | + .parent = TYPE_STM32L4X5_USART_BASE, | ||
509 | + .class_init = stm32l4x5_lpuart_class_init, | ||
510 | + } | ||
295 | +}; | 511 | +}; |
296 | + | 512 | + |
297 | +static void imx7_clear_reset_bit(CPUState *cpu, run_on_cpu_data data) | 513 | +DEFINE_TYPES(stm32l4x5_usart_types) |
298 | +{ | 514 | diff --git a/hw/char/Kconfig b/hw/char/Kconfig |
299 | + struct SRCSCRResetInfo *ri = data.host_ptr; | ||
300 | + IMX7SRCState *s = ri->s; | ||
301 | + | ||
302 | + assert(qemu_mutex_iothread_locked()); | ||
303 | + | ||
304 | + s->regs[SRC_A7RCR0] = deposit32(s->regs[SRC_A7RCR0], ri->reset_bit, 1, 0); | ||
305 | + | ||
306 | + trace_imx7_src_write(imx7_src_reg_name(SRC_A7RCR0), s->regs[SRC_A7RCR0]); | ||
307 | + | ||
308 | + g_free(ri); | ||
309 | +} | ||
310 | + | ||
311 | +static void imx7_defer_clear_reset_bit(uint32_t cpuid, | ||
312 | + IMX7SRCState *s, | ||
313 | + uint32_t reset_shift) | ||
314 | +{ | ||
315 | + struct SRCSCRResetInfo *ri; | ||
316 | + CPUState *cpu = arm_get_cpu_by_id(cpuid); | ||
317 | + | ||
318 | + if (!cpu) { | ||
319 | + return; | ||
320 | + } | ||
321 | + | ||
322 | + ri = g_new(struct SRCSCRResetInfo, 1); | ||
323 | + ri->s = s; | ||
324 | + ri->reset_bit = reset_shift; | ||
325 | + | ||
326 | + async_run_on_cpu(cpu, imx7_clear_reset_bit, RUN_ON_CPU_HOST_PTR(ri)); | ||
327 | +} | ||
328 | + | ||
329 | + | ||
330 | +static void imx7_src_write(void *opaque, hwaddr offset, uint64_t value, | ||
331 | + unsigned size) | ||
332 | +{ | ||
333 | + IMX7SRCState *s = (IMX7SRCState *)opaque; | ||
334 | + uint32_t index = offset >> 2; | ||
335 | + long unsigned int change_mask; | ||
336 | + uint32_t current_value = value; | ||
337 | + | ||
338 | + if (index >= SRC_MAX) { | ||
339 | + qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad register at offset 0x%" | ||
340 | + HWADDR_PRIx "\n", TYPE_IMX7_SRC, __func__, offset); | ||
341 | + return; | ||
342 | + } | ||
343 | + | ||
344 | + trace_imx7_src_write(imx7_src_reg_name(SRC_A7RCR0), s->regs[SRC_A7RCR0]); | ||
345 | + | ||
346 | + change_mask = s->regs[index] ^ (uint32_t)current_value; | ||
347 | + | ||
348 | + switch (index) { | ||
349 | + case SRC_A7RCR0: | ||
350 | + if (FIELD_EX32(change_mask, CORE0, RST)) { | ||
351 | + arm_reset_cpu(0); | ||
352 | + imx7_defer_clear_reset_bit(0, s, R_CORE0_RST_SHIFT); | ||
353 | + } | ||
354 | + if (FIELD_EX32(change_mask, CORE1, RST)) { | ||
355 | + arm_reset_cpu(1); | ||
356 | + imx7_defer_clear_reset_bit(1, s, R_CORE1_RST_SHIFT); | ||
357 | + } | ||
358 | + s->regs[index] = current_value; | ||
359 | + break; | ||
360 | + case SRC_A7RCR1: | ||
361 | + /* | ||
362 | + * On real hardware when the system reset controller starts a | ||
363 | + * secondary CPU it runs through some boot ROM code which reads | ||
364 | + * the SRC_GPRX registers controlling the start address and branches | ||
365 | + * to it. | ||
366 | + * Here we are taking a short cut and branching directly to the | ||
367 | + * requested address (we don't want to run the boot ROM code inside | ||
368 | + * QEMU) | ||
369 | + */ | ||
370 | + if (FIELD_EX32(change_mask, CORE1, ENABLE)) { | ||
371 | + if (FIELD_EX32(current_value, CORE1, ENABLE)) { | ||
372 | + /* CORE 1 is brought up */ | ||
373 | + arm_set_cpu_on(1, s->regs[SRC_GPR3], s->regs[SRC_GPR4], | ||
374 | + 3, false); | ||
375 | + } else { | ||
376 | + /* CORE 1 is shut down */ | ||
377 | + arm_set_cpu_off(1); | ||
378 | + } | ||
379 | + /* We clear the reset bits as the processor changed state */ | ||
380 | + imx7_defer_clear_reset_bit(1, s, R_CORE1_RST_SHIFT); | ||
381 | + clear_bit(R_CORE1_RST_SHIFT, &change_mask); | ||
382 | + } | ||
383 | + s->regs[index] = current_value; | ||
384 | + break; | ||
385 | + default: | ||
386 | + s->regs[index] = current_value; | ||
387 | + break; | ||
388 | + } | ||
389 | +} | ||
390 | + | ||
391 | +static const struct MemoryRegionOps imx7_src_ops = { | ||
392 | + .read = imx7_src_read, | ||
393 | + .write = imx7_src_write, | ||
394 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
395 | + .valid = { | ||
396 | + /* | ||
397 | + * Our device would not work correctly if the guest was doing | ||
398 | + * unaligned access. This might not be a limitation on the real | ||
399 | + * device but in practice there is no reason for a guest to access | ||
400 | + * this device unaligned. | ||
401 | + */ | ||
402 | + .min_access_size = 4, | ||
403 | + .max_access_size = 4, | ||
404 | + .unaligned = false, | ||
405 | + }, | ||
406 | +}; | ||
407 | + | ||
408 | +static void imx7_src_realize(DeviceState *dev, Error **errp) | ||
409 | +{ | ||
410 | + IMX7SRCState *s = IMX7_SRC(dev); | ||
411 | + | ||
412 | + memory_region_init_io(&s->iomem, OBJECT(dev), &imx7_src_ops, s, | ||
413 | + TYPE_IMX7_SRC, 0x1000); | ||
414 | + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem); | ||
415 | +} | ||
416 | + | ||
417 | +static void imx7_src_class_init(ObjectClass *klass, void *data) | ||
418 | +{ | ||
419 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
420 | + | ||
421 | + dc->realize = imx7_src_realize; | ||
422 | + dc->reset = imx7_src_reset; | ||
423 | + dc->vmsd = &vmstate_imx7_src; | ||
424 | + dc->desc = "i.MX6 System Reset Controller"; | ||
425 | +} | ||
426 | + | ||
427 | +static const TypeInfo imx7_src_info = { | ||
428 | + .name = TYPE_IMX7_SRC, | ||
429 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
430 | + .instance_size = sizeof(IMX7SRCState), | ||
431 | + .class_init = imx7_src_class_init, | ||
432 | +}; | ||
433 | + | ||
434 | +static void imx7_src_register_types(void) | ||
435 | +{ | ||
436 | + type_register_static(&imx7_src_info); | ||
437 | +} | ||
438 | + | ||
439 | +type_init(imx7_src_register_types) | ||
440 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build | ||
441 | index XXXXXXX..XXXXXXX 100644 | 515 | index XXXXXXX..XXXXXXX 100644 |
442 | --- a/hw/misc/meson.build | 516 | --- a/hw/char/Kconfig |
443 | +++ b/hw/misc/meson.build | 517 | +++ b/hw/char/Kconfig |
444 | @@ -XXX,XX +XXX,XX @@ system_ss.add(when: 'CONFIG_IMX', if_true: files( | 518 | @@ -XXX,XX +XXX,XX @@ config VIRTIO_SERIAL |
445 | 'imx6_src.c', | 519 | config STM32F2XX_USART |
446 | 'imx6ul_ccm.c', | 520 | bool |
447 | 'imx7_ccm.c', | 521 | |
448 | + 'imx7_src.c', | 522 | +config STM32L4X5_USART |
449 | 'imx7_gpr.c', | 523 | + bool |
450 | 'imx7_snvs.c', | 524 | + |
451 | 'imx_ccm.c', | 525 | config CMSDK_APB_UART |
452 | diff --git a/hw/misc/trace-events b/hw/misc/trace-events | 526 | bool |
527 | |||
528 | diff --git a/hw/char/meson.build b/hw/char/meson.build | ||
453 | index XXXXXXX..XXXXXXX 100644 | 529 | index XXXXXXX..XXXXXXX 100644 |
454 | --- a/hw/misc/trace-events | 530 | --- a/hw/char/meson.build |
455 | +++ b/hw/misc/trace-events | 531 | +++ b/hw/char/meson.build |
456 | @@ -XXX,XX +XXX,XX @@ ccm_clock_freq(uint32_t clock, uint32_t freq) "(Clock = %d) = %d" | 532 | @@ -XXX,XX +XXX,XX @@ system_ss.add(when: 'CONFIG_RENESAS_SCI', if_true: files('renesas_sci.c')) |
457 | ccm_read_reg(const char *reg_name, uint32_t value) "reg[%s] <= 0x%" PRIx32 | 533 | system_ss.add(when: 'CONFIG_SIFIVE_UART', if_true: files('sifive_uart.c')) |
458 | ccm_write_reg(const char *reg_name, uint32_t value) "reg[%s] => 0x%" PRIx32 | 534 | system_ss.add(when: 'CONFIG_SH_SCI', if_true: files('sh_serial.c')) |
459 | 535 | system_ss.add(when: 'CONFIG_STM32F2XX_USART', if_true: files('stm32f2xx_usart.c')) | |
460 | +# imx7_src.c | 536 | +system_ss.add(when: 'CONFIG_STM32L4X5_USART', if_true: files('stm32l4x5_usart.c')) |
461 | +imx7_src_read(const char *reg_name, uint32_t value) "reg[%s] => 0x%" PRIx32 | 537 | system_ss.add(when: 'CONFIG_MCHP_PFSOC_MMUART', if_true: files('mchp_pfsoc_mmuart.c')) |
462 | +imx7_src_write(const char *reg_name, uint32_t value) "reg[%s] <= 0x%" PRIx32 | 538 | system_ss.add(when: 'CONFIG_HTIF', if_true: files('riscv_htif.c')) |
463 | + | 539 | system_ss.add(when: 'CONFIG_GOLDFISH_TTY', if_true: files('goldfish_tty.c')) |
464 | # iotkit-sysinfo.c | 540 | diff --git a/hw/char/trace-events b/hw/char/trace-events |
465 | iotkit_sysinfo_read(uint64_t offset, uint64_t data, unsigned size) "IoTKit SysInfo read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" | 541 | index XXXXXXX..XXXXXXX 100644 |
466 | iotkit_sysinfo_write(uint64_t offset, uint64_t data, unsigned size) "IoTKit SysInfo write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" | 542 | --- a/hw/char/trace-events |
543 | +++ b/hw/char/trace-events | ||
544 | @@ -XXX,XX +XXX,XX @@ cadence_uart_baudrate(unsigned baudrate) "baudrate %u" | ||
545 | sh_serial_read(char *id, unsigned size, uint64_t offs, uint64_t val) " %s size %d offs 0x%02" PRIx64 " -> 0x%02" PRIx64 | ||
546 | sh_serial_write(char *id, unsigned size, uint64_t offs, uint64_t val) "%s size %d offs 0x%02" PRIx64 " <- 0x%02" PRIx64 | ||
547 | |||
548 | +# stm32l4x5_usart.c | ||
549 | +stm32l4x5_usart_read(uint64_t addr, uint32_t data) "USART: Read <0x%" PRIx64 "> -> 0x%" PRIx32 "" | ||
550 | +stm32l4x5_usart_write(uint64_t addr, uint32_t data) "USART: Write <0x%" PRIx64 "> <- 0x%" PRIx32 "" | ||
551 | + | ||
552 | # xen_console.c | ||
553 | xen_console_connect(unsigned int idx, unsigned int ring_ref, unsigned int port, unsigned int limit) "idx %u ring_ref %u port %u limit %u" | ||
554 | xen_console_disconnect(unsigned int idx) "idx %u" | ||
467 | -- | 555 | -- |
468 | 2.34.1 | 556 | 2.34.1 |
557 | |||
558 | diff view generated by jsdifflib |
1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> | 1 | From: Arnaud Minier <arnaud.minier@telecom-paris.fr> |
---|---|---|---|
2 | 2 | ||
3 | * Add TZASC as unimplemented device. | 3 | Implement the ability to read and write characters to the |
4 | - Allow bare metal application to access this (unimplemented) device | 4 | usart using the serial port. |
5 | * Add CSU as unimplemented device. | 5 | |
6 | - Allow bare metal application to access this (unimplemented) device | 6 | The character transmission is based on the |
7 | * Add various memory segments | 7 | cmsdk-apb-uart implementation. |
8 | - OCRAM | 8 | |
9 | - OCRAM EPDC | 9 | Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> |
10 | - OCRAM PXP | 10 | Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> |
11 | - OCRAM S | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
12 | - ROM | 12 | Message-id: 20240329174402.60382-3-arnaud.minier@telecom-paris.fr |
13 | - CAAM | 13 | [PMM: fixed a few checkpatch nits] |
14 | |||
15 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> | ||
16 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
17 | Message-id: f887a3483996ba06d40bd62ffdfb0ecf68621987.1692964892.git.jcd@tribudubois.net | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | --- | 15 | --- |
20 | include/hw/arm/fsl-imx7.h | 7 +++++ | 16 | include/hw/char/stm32l4x5_usart.h | 1 + |
21 | hw/arm/fsl-imx7.c | 63 +++++++++++++++++++++++++++++++++++++++ | 17 | hw/char/stm32l4x5_usart.c | 143 ++++++++++++++++++++++++++++++ |
22 | 2 files changed, 70 insertions(+) | 18 | hw/char/trace-events | 7 ++ |
23 | 19 | 3 files changed, 151 insertions(+) | |
24 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h | 20 | |
21 | diff --git a/include/hw/char/stm32l4x5_usart.h b/include/hw/char/stm32l4x5_usart.h | ||
25 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/hw/arm/fsl-imx7.h | 23 | --- a/include/hw/char/stm32l4x5_usart.h |
27 | +++ b/include/hw/arm/fsl-imx7.h | 24 | +++ b/include/hw/char/stm32l4x5_usart.h |
28 | @@ -XXX,XX +XXX,XX @@ struct FslIMX7State { | 25 | @@ -XXX,XX +XXX,XX @@ struct Stm32l4x5UsartBaseState { |
29 | IMX7GPRState gpr; | 26 | Clock *clk; |
30 | ChipideaState usb[FSL_IMX7_NUM_USBS]; | 27 | CharBackend chr; |
31 | DesignwarePCIEHost pcie; | 28 | qemu_irq irq; |
32 | + MemoryRegion rom; | 29 | + guint watch_tag; |
33 | + MemoryRegion caam; | ||
34 | + MemoryRegion ocram; | ||
35 | + MemoryRegion ocram_epdc; | ||
36 | + MemoryRegion ocram_pxp; | ||
37 | + MemoryRegion ocram_s; | ||
38 | + | ||
39 | uint32_t phy_num[FSL_IMX7_NUM_ETHS]; | ||
40 | bool phy_connected[FSL_IMX7_NUM_ETHS]; | ||
41 | }; | 30 | }; |
42 | diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c | 31 | |
32 | struct Stm32l4x5UsartBaseClass { | ||
33 | diff --git a/hw/char/stm32l4x5_usart.c b/hw/char/stm32l4x5_usart.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
44 | --- a/hw/arm/fsl-imx7.c | 35 | --- a/hw/char/stm32l4x5_usart.c |
45 | +++ b/hw/arm/fsl-imx7.c | 36 | +++ b/hw/char/stm32l4x5_usart.c |
46 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | 37 | @@ -XXX,XX +XXX,XX @@ REG32(RDR, 0x24) |
47 | create_unimplemented_device("pcie-phy", FSL_IMX7_PCIE_PHY_ADDR, | 38 | REG32(TDR, 0x28) |
48 | FSL_IMX7_PCIE_PHY_SIZE); | 39 | FIELD(TDR, TDR, 0, 9) |
49 | 40 | ||
50 | + /* | 41 | +static void stm32l4x5_update_irq(Stm32l4x5UsartBaseState *s) |
51 | + * CSU | 42 | +{ |
52 | + */ | 43 | + if (((s->isr & R_ISR_WUF_MASK) && (s->cr3 & R_CR3_WUFIE_MASK)) || |
53 | + create_unimplemented_device("csu", FSL_IMX7_CSU_ADDR, | 44 | + ((s->isr & R_ISR_CMF_MASK) && (s->cr1 & R_CR1_CMIE_MASK)) || |
54 | + FSL_IMX7_CSU_SIZE); | 45 | + ((s->isr & R_ISR_ABRF_MASK) && (s->cr1 & R_CR1_RXNEIE_MASK)) || |
55 | + | 46 | + ((s->isr & R_ISR_EOBF_MASK) && (s->cr1 & R_CR1_EOBIE_MASK)) || |
56 | + /* | 47 | + ((s->isr & R_ISR_RTOF_MASK) && (s->cr1 & R_CR1_RTOIE_MASK)) || |
57 | + * TZASC | 48 | + ((s->isr & R_ISR_CTSIF_MASK) && (s->cr3 & R_CR3_CTSIE_MASK)) || |
58 | + */ | 49 | + ((s->isr & R_ISR_LBDF_MASK) && (s->cr2 & R_CR2_LBDIE_MASK)) || |
59 | + create_unimplemented_device("tzasc", FSL_IMX7_TZASC_ADDR, | 50 | + ((s->isr & R_ISR_TXE_MASK) && (s->cr1 & R_CR1_TXEIE_MASK)) || |
60 | + FSL_IMX7_TZASC_SIZE); | 51 | + ((s->isr & R_ISR_TC_MASK) && (s->cr1 & R_CR1_TCIE_MASK)) || |
61 | + | 52 | + ((s->isr & R_ISR_RXNE_MASK) && (s->cr1 & R_CR1_RXNEIE_MASK)) || |
62 | + /* | 53 | + ((s->isr & R_ISR_IDLE_MASK) && (s->cr1 & R_CR1_IDLEIE_MASK)) || |
63 | + * OCRAM memory | 54 | + ((s->isr & R_ISR_ORE_MASK) && |
64 | + */ | 55 | + ((s->cr1 & R_CR1_RXNEIE_MASK) || (s->cr3 & R_CR3_EIE_MASK))) || |
65 | + memory_region_init_ram(&s->ocram, NULL, "imx7.ocram", | 56 | + /* TODO: Handle NF ? */ |
66 | + FSL_IMX7_OCRAM_MEM_SIZE, | 57 | + ((s->isr & R_ISR_FE_MASK) && (s->cr3 & R_CR3_EIE_MASK)) || |
67 | + &error_abort); | 58 | + ((s->isr & R_ISR_PE_MASK) && (s->cr1 & R_CR1_PEIE_MASK))) { |
68 | + memory_region_add_subregion(get_system_memory(), FSL_IMX7_OCRAM_MEM_ADDR, | 59 | + qemu_irq_raise(s->irq); |
69 | + &s->ocram); | 60 | + trace_stm32l4x5_usart_irq_raised(s->isr); |
70 | + | 61 | + } else { |
71 | + /* | 62 | + qemu_irq_lower(s->irq); |
72 | + * OCRAM EPDC memory | 63 | + trace_stm32l4x5_usart_irq_lowered(); |
73 | + */ | 64 | + } |
74 | + memory_region_init_ram(&s->ocram_epdc, NULL, "imx7.ocram_epdc", | 65 | +} |
75 | + FSL_IMX7_OCRAM_EPDC_SIZE, | 66 | + |
76 | + &error_abort); | 67 | +static int stm32l4x5_usart_base_can_receive(void *opaque) |
77 | + memory_region_add_subregion(get_system_memory(), FSL_IMX7_OCRAM_EPDC_ADDR, | 68 | +{ |
78 | + &s->ocram_epdc); | 69 | + Stm32l4x5UsartBaseState *s = opaque; |
79 | + | 70 | + |
80 | + /* | 71 | + if (!(s->isr & R_ISR_RXNE_MASK)) { |
81 | + * OCRAM PXP memory | 72 | + return 1; |
82 | + */ | 73 | + } |
83 | + memory_region_init_ram(&s->ocram_pxp, NULL, "imx7.ocram_pxp", | 74 | + |
84 | + FSL_IMX7_OCRAM_PXP_SIZE, | 75 | + return 0; |
85 | + &error_abort); | 76 | +} |
86 | + memory_region_add_subregion(get_system_memory(), FSL_IMX7_OCRAM_PXP_ADDR, | 77 | + |
87 | + &s->ocram_pxp); | 78 | +static void stm32l4x5_usart_base_receive(void *opaque, const uint8_t *buf, |
88 | + | 79 | + int size) |
89 | + /* | 80 | +{ |
90 | + * OCRAM_S memory | 81 | + Stm32l4x5UsartBaseState *s = opaque; |
91 | + */ | 82 | + |
92 | + memory_region_init_ram(&s->ocram_s, NULL, "imx7.ocram_s", | 83 | + if (!((s->cr1 & R_CR1_UE_MASK) && (s->cr1 & R_CR1_RE_MASK))) { |
93 | + FSL_IMX7_OCRAM_S_SIZE, | 84 | + trace_stm32l4x5_usart_receiver_not_enabled( |
94 | + &error_abort); | 85 | + FIELD_EX32(s->cr1, CR1, UE), FIELD_EX32(s->cr1, CR1, RE)); |
95 | + memory_region_add_subregion(get_system_memory(), FSL_IMX7_OCRAM_S_ADDR, | 86 | + return; |
96 | + &s->ocram_s); | 87 | + } |
97 | + | 88 | + |
98 | + /* | 89 | + /* Check if overrun detection is enabled and if there is an overrun */ |
99 | + * ROM memory | 90 | + if (!(s->cr3 & R_CR3_OVRDIS_MASK) && (s->isr & R_ISR_RXNE_MASK)) { |
100 | + */ | 91 | + /* |
101 | + memory_region_init_rom(&s->rom, OBJECT(dev), "imx7.rom", | 92 | + * A character has been received while |
102 | + FSL_IMX7_ROM_SIZE, &error_abort); | 93 | + * the previous has not been read = Overrun. |
103 | + memory_region_add_subregion(get_system_memory(), FSL_IMX7_ROM_ADDR, | 94 | + */ |
104 | + &s->rom); | 95 | + s->isr |= R_ISR_ORE_MASK; |
105 | + | 96 | + trace_stm32l4x5_usart_overrun_detected(s->rdr, *buf); |
106 | + /* | 97 | + } else { |
107 | + * CAAM memory | 98 | + /* No overrun */ |
108 | + */ | 99 | + s->rdr = *buf; |
109 | + memory_region_init_rom(&s->caam, OBJECT(dev), "imx7.caam", | 100 | + s->isr |= R_ISR_RXNE_MASK; |
110 | + FSL_IMX7_CAAM_MEM_SIZE, &error_abort); | 101 | + trace_stm32l4x5_usart_rx(s->rdr); |
111 | + memory_region_add_subregion(get_system_memory(), FSL_IMX7_CAAM_MEM_ADDR, | 102 | + } |
112 | + &s->caam); | 103 | + |
104 | + stm32l4x5_update_irq(s); | ||
105 | +} | ||
106 | + | ||
107 | +/* | ||
108 | + * Try to send tx data, and arrange to be called back later if | ||
109 | + * we can't (ie the char backend is busy/blocking). | ||
110 | + */ | ||
111 | +static gboolean usart_transmit(void *do_not_use, GIOCondition cond, | ||
112 | + void *opaque) | ||
113 | +{ | ||
114 | + Stm32l4x5UsartBaseState *s = STM32L4X5_USART_BASE(opaque); | ||
115 | + int ret; | ||
116 | + /* TODO: Handle 9 bits transmission */ | ||
117 | + uint8_t ch = s->tdr; | ||
118 | + | ||
119 | + s->watch_tag = 0; | ||
120 | + | ||
121 | + if (!(s->cr1 & R_CR1_TE_MASK) || (s->isr & R_ISR_TXE_MASK)) { | ||
122 | + return G_SOURCE_REMOVE; | ||
123 | + } | ||
124 | + | ||
125 | + ret = qemu_chr_fe_write(&s->chr, &ch, 1); | ||
126 | + if (ret <= 0) { | ||
127 | + s->watch_tag = qemu_chr_fe_add_watch(&s->chr, G_IO_OUT | G_IO_HUP, | ||
128 | + usart_transmit, s); | ||
129 | + if (!s->watch_tag) { | ||
130 | + /* | ||
131 | + * Most common reason to be here is "no chardev backend": | ||
132 | + * just insta-drain the buffer, so the serial output | ||
133 | + * goes into a void, rather than blocking the guest. | ||
134 | + */ | ||
135 | + goto buffer_drained; | ||
136 | + } | ||
137 | + /* Transmit pending */ | ||
138 | + trace_stm32l4x5_usart_tx_pending(); | ||
139 | + return G_SOURCE_REMOVE; | ||
140 | + } | ||
141 | + | ||
142 | +buffer_drained: | ||
143 | + /* Character successfully sent */ | ||
144 | + trace_stm32l4x5_usart_tx(ch); | ||
145 | + s->isr |= R_ISR_TC_MASK | R_ISR_TXE_MASK; | ||
146 | + stm32l4x5_update_irq(s); | ||
147 | + return G_SOURCE_REMOVE; | ||
148 | +} | ||
149 | + | ||
150 | +static void usart_cancel_transmit(Stm32l4x5UsartBaseState *s) | ||
151 | +{ | ||
152 | + if (s->watch_tag) { | ||
153 | + g_source_remove(s->watch_tag); | ||
154 | + s->watch_tag = 0; | ||
155 | + } | ||
156 | +} | ||
157 | + | ||
158 | static void stm32l4x5_usart_base_reset_hold(Object *obj, ResetType type) | ||
159 | { | ||
160 | Stm32l4x5UsartBaseState *s = STM32L4X5_USART_BASE(obj); | ||
161 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_usart_base_reset_hold(Object *obj, ResetType type) | ||
162 | s->isr = 0x020000C0; | ||
163 | s->rdr = 0x00000000; | ||
164 | s->tdr = 0x00000000; | ||
165 | + | ||
166 | + usart_cancel_transmit(s); | ||
167 | + stm32l4x5_update_irq(s); | ||
168 | +} | ||
169 | + | ||
170 | +static void usart_update_rqr(Stm32l4x5UsartBaseState *s, uint32_t value) | ||
171 | +{ | ||
172 | + /* TXFRQ */ | ||
173 | + /* Reset RXNE flag */ | ||
174 | + if (value & R_RQR_RXFRQ_MASK) { | ||
175 | + s->isr &= ~R_ISR_RXNE_MASK; | ||
176 | + } | ||
177 | + /* MMRQ */ | ||
178 | + /* SBKRQ */ | ||
179 | + /* ABRRQ */ | ||
180 | + stm32l4x5_update_irq(s); | ||
113 | } | 181 | } |
114 | 182 | ||
115 | static Property fsl_imx7_properties[] = { | 183 | static uint64_t stm32l4x5_usart_base_read(void *opaque, hwaddr addr, |
184 | @@ -XXX,XX +XXX,XX @@ static uint64_t stm32l4x5_usart_base_read(void *opaque, hwaddr addr, | ||
185 | retvalue = FIELD_EX32(s->rdr, RDR, RDR); | ||
186 | /* Reset RXNE flag */ | ||
187 | s->isr &= ~R_ISR_RXNE_MASK; | ||
188 | + stm32l4x5_update_irq(s); | ||
189 | break; | ||
190 | case A_TDR: | ||
191 | retvalue = FIELD_EX32(s->tdr, TDR, TDR); | ||
192 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_usart_base_write(void *opaque, hwaddr addr, | ||
193 | switch (addr) { | ||
194 | case A_CR1: | ||
195 | s->cr1 = value; | ||
196 | + stm32l4x5_update_irq(s); | ||
197 | return; | ||
198 | case A_CR2: | ||
199 | s->cr2 = value; | ||
200 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_usart_base_write(void *opaque, hwaddr addr, | ||
201 | s->rtor = value; | ||
202 | return; | ||
203 | case A_RQR: | ||
204 | + usart_update_rqr(s, value); | ||
205 | return; | ||
206 | case A_ISR: | ||
207 | qemu_log_mask(LOG_GUEST_ERROR, | ||
208 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_usart_base_write(void *opaque, hwaddr addr, | ||
209 | case A_ICR: | ||
210 | /* Clear the status flags */ | ||
211 | s->isr &= ~value; | ||
212 | + stm32l4x5_update_irq(s); | ||
213 | return; | ||
214 | case A_RDR: | ||
215 | qemu_log_mask(LOG_GUEST_ERROR, | ||
216 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_usart_base_write(void *opaque, hwaddr addr, | ||
217 | return; | ||
218 | case A_TDR: | ||
219 | s->tdr = value; | ||
220 | + s->isr &= ~R_ISR_TXE_MASK; | ||
221 | + usart_transmit(NULL, G_IO_OUT, s); | ||
222 | return; | ||
223 | default: | ||
224 | qemu_log_mask(LOG_GUEST_ERROR, | ||
225 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_usart_base_realize(DeviceState *dev, Error **errp) | ||
226 | error_setg(errp, "USART clock must be wired up by SoC code"); | ||
227 | return; | ||
228 | } | ||
229 | + | ||
230 | + qemu_chr_fe_set_handlers(&s->chr, stm32l4x5_usart_base_can_receive, | ||
231 | + stm32l4x5_usart_base_receive, NULL, NULL, | ||
232 | + s, NULL, true); | ||
233 | } | ||
234 | |||
235 | static void stm32l4x5_usart_base_class_init(ObjectClass *klass, void *data) | ||
236 | diff --git a/hw/char/trace-events b/hw/char/trace-events | ||
237 | index XXXXXXX..XXXXXXX 100644 | ||
238 | --- a/hw/char/trace-events | ||
239 | +++ b/hw/char/trace-events | ||
240 | @@ -XXX,XX +XXX,XX @@ sh_serial_write(char *id, unsigned size, uint64_t offs, uint64_t val) "%s size % | ||
241 | # stm32l4x5_usart.c | ||
242 | stm32l4x5_usart_read(uint64_t addr, uint32_t data) "USART: Read <0x%" PRIx64 "> -> 0x%" PRIx32 "" | ||
243 | stm32l4x5_usart_write(uint64_t addr, uint32_t data) "USART: Write <0x%" PRIx64 "> <- 0x%" PRIx32 "" | ||
244 | +stm32l4x5_usart_rx(uint8_t c) "USART: got character 0x%x from backend" | ||
245 | +stm32l4x5_usart_tx(uint8_t c) "USART: character 0x%x sent to backend" | ||
246 | +stm32l4x5_usart_tx_pending(void) "USART: character send to backend pending" | ||
247 | +stm32l4x5_usart_irq_raised(uint32_t reg) "USART: IRQ raised: 0x%08"PRIx32 | ||
248 | +stm32l4x5_usart_irq_lowered(void) "USART: IRQ lowered" | ||
249 | +stm32l4x5_usart_overrun_detected(uint8_t current, uint8_t received) "USART: Overrun detected, RDR='0x%x', received 0x%x" | ||
250 | +stm32l4x5_usart_receiver_not_enabled(uint8_t ue_bit, uint8_t re_bit) "USART: Receiver not enabled, UE=0x%x, RE=0x%x" | ||
251 | |||
252 | # xen_console.c | ||
253 | xen_console_connect(unsigned int idx, unsigned int ring_ref, unsigned int port, unsigned int limit) "idx %u ring_ref %u port %u limit %u" | ||
116 | -- | 254 | -- |
117 | 2.34.1 | 255 | 2.34.1 |
118 | 256 | ||
119 | 257 | diff view generated by jsdifflib |
1 | M-profile CPUs generally allow configuration of the number of MPU | 1 | From: Arnaud Minier <arnaud.minier@telecom-paris.fr> |
---|---|---|---|
2 | regions that they have. We don't currently model this, so our | ||
3 | implementations of some of the board models provide CPUs with the | ||
4 | wrong number of regions. RTOSes like Zephyr that hardcode the | ||
5 | expected number of regions may therefore not run on the model if they | ||
6 | are set up to run on real hardware. | ||
7 | 2 | ||
8 | Add properties mpu-ns-regions and mpu-s-regions to the ARMV7M object, | 3 | Add a function to change the settings of the |
9 | matching the ability of hardware to configure the number of Secure | 4 | serial connection. |
10 | and NonSecure regions separately. Our actual CPU implementation | ||
11 | doesn't currently support that, and it happens that none of the MPS | ||
12 | boards we model set the number of regions differently for Secure vs | ||
13 | NonSecure, so we provide an interface to the boards and SoCs that | ||
14 | won't need to change if we ever do add that functionality in future, | ||
15 | but make it an error to configure the two properties to different | ||
16 | values. | ||
17 | 5 | ||
18 | (The property name on the CPU is the somewhat misnamed-for-M-profile | 6 | Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> |
19 | "pmsav7-dregion", so we don't follow that naming convention for | 7 | Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> |
20 | the properties here. The TRM doesn't say what the CPU configuration | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
21 | variable names are, so we pick something, and follow the lowercase | 9 | Message-id: 20240329174402.60382-4-arnaud.minier@telecom-paris.fr |
22 | convention we already have for properties here.) | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | ||
12 | hw/char/stm32l4x5_usart.c | 98 +++++++++++++++++++++++++++++++++++++++ | ||
13 | hw/char/trace-events | 1 + | ||
14 | 2 files changed, 99 insertions(+) | ||
23 | 15 | ||
24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | diff --git a/hw/char/stm32l4x5_usart.c b/hw/char/stm32l4x5_usart.c |
25 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
26 | Message-id: 20230724174335.2150499-3-peter.maydell@linaro.org | ||
27 | --- | ||
28 | include/hw/arm/armv7m.h | 8 ++++++++ | ||
29 | hw/arm/armv7m.c | 21 +++++++++++++++++++++ | ||
30 | 2 files changed, 29 insertions(+) | ||
31 | |||
32 | diff --git a/include/hw/arm/armv7m.h b/include/hw/arm/armv7m.h | ||
33 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/include/hw/arm/armv7m.h | 18 | --- a/hw/char/stm32l4x5_usart.c |
35 | +++ b/include/hw/arm/armv7m.h | 19 | +++ b/hw/char/stm32l4x5_usart.c |
36 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(ARMv7MState, ARMV7M) | 20 | @@ -XXX,XX +XXX,XX @@ static void usart_cancel_transmit(Stm32l4x5UsartBaseState *s) |
37 | * + Property "vfp": enable VFP (forwarded to CPU object) | ||
38 | * + Property "dsp": enable DSP (forwarded to CPU object) | ||
39 | * + Property "enable-bitband": expose bitbanded IO | ||
40 | + * + Property "mpu-ns-regions": number of Non-Secure MPU regions (forwarded | ||
41 | + * to CPU object pmsav7-dregion property; default is whatever the default | ||
42 | + * for the CPU is) | ||
43 | + * + Property "mpu-s-regions": number of Secure MPU regions (default is | ||
44 | + * whatever the default for the CPU is; must currently be set to the same | ||
45 | + * value as mpu-ns-regions if the CPU implements the Security Extension) | ||
46 | * + Clock input "refclk" is the external reference clock for the systick timers | ||
47 | * + Clock input "cpuclk" is the main CPU clock | ||
48 | */ | ||
49 | @@ -XXX,XX +XXX,XX @@ struct ARMv7MState { | ||
50 | Object *idau; | ||
51 | uint32_t init_svtor; | ||
52 | uint32_t init_nsvtor; | ||
53 | + uint32_t mpu_ns_regions; | ||
54 | + uint32_t mpu_s_regions; | ||
55 | bool enable_bitband; | ||
56 | bool start_powered_off; | ||
57 | bool vfp; | ||
58 | diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c | ||
59 | index XXXXXXX..XXXXXXX 100644 | ||
60 | --- a/hw/arm/armv7m.c | ||
61 | +++ b/hw/arm/armv7m.c | ||
62 | @@ -XXX,XX +XXX,XX @@ static void armv7m_realize(DeviceState *dev, Error **errp) | ||
63 | } | ||
64 | } | 21 | } |
65 | 22 | } | |
66 | + /* | 23 | |
67 | + * Real M-profile hardware can be configured with a different number of | 24 | +static void stm32l4x5_update_params(Stm32l4x5UsartBaseState *s) |
68 | + * MPU regions for Secure vs NonSecure. QEMU's CPU implementation doesn't | 25 | +{ |
69 | + * support that yet, so catch attempts to select that. | 26 | + int speed, parity, data_bits, stop_bits; |
70 | + */ | 27 | + uint32_t value, usart_div; |
71 | + if (arm_feature(&s->cpu->env, ARM_FEATURE_M_SECURITY) && | 28 | + QEMUSerialSetParams ssp; |
72 | + s->mpu_ns_regions != s->mpu_s_regions) { | 29 | + |
73 | + error_setg(errp, | 30 | + /* Select the parity type */ |
74 | + "mpu-ns-regions and mpu-s-regions properties must have the same value"); | 31 | + if (s->cr1 & R_CR1_PCE_MASK) { |
32 | + if (s->cr1 & R_CR1_PS_MASK) { | ||
33 | + parity = 'O'; | ||
34 | + } else { | ||
35 | + parity = 'E'; | ||
36 | + } | ||
37 | + } else { | ||
38 | + parity = 'N'; | ||
39 | + } | ||
40 | + | ||
41 | + /* Select the number of stop bits */ | ||
42 | + switch (FIELD_EX32(s->cr2, CR2, STOP)) { | ||
43 | + case 0: | ||
44 | + stop_bits = 1; | ||
45 | + break; | ||
46 | + case 2: | ||
47 | + stop_bits = 2; | ||
48 | + break; | ||
49 | + default: | ||
50 | + qemu_log_mask(LOG_UNIMP, | ||
51 | + "UNIMPLEMENTED: fractionnal stop bits; CR2[13:12] = %u", | ||
52 | + FIELD_EX32(s->cr2, CR2, STOP)); | ||
75 | + return; | 53 | + return; |
76 | + } | 54 | + } |
77 | + if (s->mpu_ns_regions != UINT_MAX && | 55 | + |
78 | + object_property_find(OBJECT(s->cpu), "pmsav7-dregion")) { | 56 | + /* Select the length of the word */ |
79 | + if (!object_property_set_uint(OBJECT(s->cpu), "pmsav7-dregion", | 57 | + switch ((FIELD_EX32(s->cr1, CR1, M1) << 1) | FIELD_EX32(s->cr1, CR1, M0)) { |
80 | + s->mpu_ns_regions, errp)) { | 58 | + case 0: |
81 | + return; | 59 | + data_bits = 8; |
82 | + } | 60 | + break; |
61 | + case 1: | ||
62 | + data_bits = 9; | ||
63 | + break; | ||
64 | + case 2: | ||
65 | + data_bits = 7; | ||
66 | + break; | ||
67 | + default: | ||
68 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
69 | + "UNDEFINED: invalid word length, CR1.M = 0b11"); | ||
70 | + return; | ||
83 | + } | 71 | + } |
84 | + | 72 | + |
85 | /* | 73 | + /* Select the baud rate */ |
86 | * Tell the CPU where the NVIC is; it will fail realize if it doesn't | 74 | + value = FIELD_EX32(s->brr, BRR, BRR); |
87 | * have one. Similarly, tell the NVIC where its CPU is. | 75 | + if (value < 16) { |
88 | @@ -XXX,XX +XXX,XX @@ static Property armv7m_properties[] = { | 76 | + qemu_log_mask(LOG_GUEST_ERROR, |
89 | false), | 77 | + "UNDEFINED: BRR less than 16: %u", value); |
90 | DEFINE_PROP_BOOL("vfp", ARMv7MState, vfp, true), | 78 | + return; |
91 | DEFINE_PROP_BOOL("dsp", ARMv7MState, dsp, true), | 79 | + } |
92 | + DEFINE_PROP_UINT32("mpu-ns-regions", ARMv7MState, mpu_ns_regions, UINT_MAX), | 80 | + |
93 | + DEFINE_PROP_UINT32("mpu-s-regions", ARMv7MState, mpu_s_regions, UINT_MAX), | 81 | + if (FIELD_EX32(s->cr1, CR1, OVER8) == 0) { |
94 | DEFINE_PROP_END_OF_LIST(), | 82 | + /* |
95 | }; | 83 | + * Oversampling by 16 |
96 | 84 | + * BRR = USARTDIV | |
85 | + */ | ||
86 | + usart_div = value; | ||
87 | + } else { | ||
88 | + /* | ||
89 | + * Oversampling by 8 | ||
90 | + * - BRR[2:0] = USARTDIV[3:0] shifted 1 bit to the right. | ||
91 | + * - BRR[3] must be kept cleared. | ||
92 | + * - BRR[15:4] = USARTDIV[15:4] | ||
93 | + * - The frequency is multiplied by 2 | ||
94 | + */ | ||
95 | + usart_div = ((value & 0xFFF0) | ((value & 0x0007) << 1)) / 2; | ||
96 | + } | ||
97 | + | ||
98 | + speed = clock_get_hz(s->clk) / usart_div; | ||
99 | + | ||
100 | + ssp.speed = speed; | ||
101 | + ssp.parity = parity; | ||
102 | + ssp.data_bits = data_bits; | ||
103 | + ssp.stop_bits = stop_bits; | ||
104 | + | ||
105 | + qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_SERIAL_SET_PARAMS, &ssp); | ||
106 | + | ||
107 | + trace_stm32l4x5_usart_update_params(speed, parity, data_bits, stop_bits); | ||
108 | +} | ||
109 | + | ||
110 | static void stm32l4x5_usart_base_reset_hold(Object *obj, ResetType type) | ||
111 | { | ||
112 | Stm32l4x5UsartBaseState *s = STM32L4X5_USART_BASE(obj); | ||
113 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_usart_base_write(void *opaque, hwaddr addr, | ||
114 | switch (addr) { | ||
115 | case A_CR1: | ||
116 | s->cr1 = value; | ||
117 | + stm32l4x5_update_params(s); | ||
118 | stm32l4x5_update_irq(s); | ||
119 | return; | ||
120 | case A_CR2: | ||
121 | s->cr2 = value; | ||
122 | + stm32l4x5_update_params(s); | ||
123 | return; | ||
124 | case A_CR3: | ||
125 | s->cr3 = value; | ||
126 | return; | ||
127 | case A_BRR: | ||
128 | s->brr = value; | ||
129 | + stm32l4x5_update_params(s); | ||
130 | return; | ||
131 | case A_GTPR: | ||
132 | s->gtpr = value; | ||
133 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_usart_base_init(Object *obj) | ||
134 | s->clk = qdev_init_clock_in(DEVICE(s), "clk", NULL, s, 0); | ||
135 | } | ||
136 | |||
137 | +static int stm32l4x5_usart_base_post_load(void *opaque, int version_id) | ||
138 | +{ | ||
139 | + Stm32l4x5UsartBaseState *s = (Stm32l4x5UsartBaseState *)opaque; | ||
140 | + | ||
141 | + stm32l4x5_update_params(s); | ||
142 | + return 0; | ||
143 | +} | ||
144 | + | ||
145 | static const VMStateDescription vmstate_stm32l4x5_usart_base = { | ||
146 | .name = TYPE_STM32L4X5_USART_BASE, | ||
147 | .version_id = 1, | ||
148 | .minimum_version_id = 1, | ||
149 | + .post_load = stm32l4x5_usart_base_post_load, | ||
150 | .fields = (VMStateField[]) { | ||
151 | VMSTATE_UINT32(cr1, Stm32l4x5UsartBaseState), | ||
152 | VMSTATE_UINT32(cr2, Stm32l4x5UsartBaseState), | ||
153 | diff --git a/hw/char/trace-events b/hw/char/trace-events | ||
154 | index XXXXXXX..XXXXXXX 100644 | ||
155 | --- a/hw/char/trace-events | ||
156 | +++ b/hw/char/trace-events | ||
157 | @@ -XXX,XX +XXX,XX @@ stm32l4x5_usart_irq_raised(uint32_t reg) "USART: IRQ raised: 0x%08"PRIx32 | ||
158 | stm32l4x5_usart_irq_lowered(void) "USART: IRQ lowered" | ||
159 | stm32l4x5_usart_overrun_detected(uint8_t current, uint8_t received) "USART: Overrun detected, RDR='0x%x', received 0x%x" | ||
160 | stm32l4x5_usart_receiver_not_enabled(uint8_t ue_bit, uint8_t re_bit) "USART: Receiver not enabled, UE=0x%x, RE=0x%x" | ||
161 | +stm32l4x5_usart_update_params(int speed, uint8_t parity, int data, int stop) "USART: speed: %d, parity: %c, data bits: %d, stop bits: %d" | ||
162 | |||
163 | # xen_console.c | ||
164 | xen_console_connect(unsigned int idx, unsigned int ring_ref, unsigned int port, unsigned int limit) "idx %u ring_ref %u port %u limit %u" | ||
97 | -- | 165 | -- |
98 | 2.34.1 | 166 | 2.34.1 |
99 | 167 | ||
100 | 168 | diff view generated by jsdifflib |
1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> | 1 | From: Arnaud Minier <arnaud.minier@telecom-paris.fr> |
---|---|---|---|
2 | 2 | ||
3 | * Add TZASC as unimplemented device. | 3 | Add the USART to the SoC and connect it to the other implemented devices. |
4 | - Allow bare metal application to access this (unimplemented) device | 4 | |
5 | * Add CSU as unimplemented device. | 5 | Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> |
6 | - Allow bare metal application to access this (unimplemented) device | 6 | Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> |
7 | * Add 4 missing PWM devices | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | 8 | Message-id: 20240329174402.60382-5-arnaud.minier@telecom-paris.fr | |
9 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> | 9 | [PMM: fixed a few checkpatch nits] |
10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
11 | Message-id: 59e4dc56e14eccfefd379275ec19048dff9c10b3.1692964892.git.jcd@tribudubois.net | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 11 | --- |
14 | include/hw/arm/fsl-imx6ul.h | 2 +- | 12 | docs/system/arm/b-l475e-iot01a.rst | 2 +- |
15 | hw/arm/fsl-imx6ul.c | 16 ++++++++++++++++ | 13 | include/hw/arm/stm32l4x5_soc.h | 7 +++ |
16 | 2 files changed, 17 insertions(+), 1 deletion(-) | 14 | hw/arm/stm32l4x5_soc.c | 83 +++++++++++++++++++++++++++--- |
17 | 15 | hw/arm/Kconfig | 1 + | |
18 | diff --git a/include/hw/arm/fsl-imx6ul.h b/include/hw/arm/fsl-imx6ul.h | 16 | 4 files changed, 86 insertions(+), 7 deletions(-) |
19 | index XXXXXXX..XXXXXXX 100644 | 17 | |
20 | --- a/include/hw/arm/fsl-imx6ul.h | 18 | diff --git a/docs/system/arm/b-l475e-iot01a.rst b/docs/system/arm/b-l475e-iot01a.rst |
21 | +++ b/include/hw/arm/fsl-imx6ul.h | 19 | index XXXXXXX..XXXXXXX 100644 |
22 | @@ -XXX,XX +XXX,XX @@ enum FslIMX6ULConfiguration { | 20 | --- a/docs/system/arm/b-l475e-iot01a.rst |
23 | FSL_IMX6UL_NUM_USBS = 2, | 21 | +++ b/docs/system/arm/b-l475e-iot01a.rst |
24 | FSL_IMX6UL_NUM_SAIS = 3, | 22 | @@ -XXX,XX +XXX,XX @@ Currently B-L475E-IOT01A machine's only supports the following devices: |
25 | FSL_IMX6UL_NUM_CANS = 2, | 23 | - STM32L4x5 SYSCFG (System configuration controller) |
26 | - FSL_IMX6UL_NUM_PWMS = 4, | 24 | - STM32L4x5 RCC (Reset and clock control) |
27 | + FSL_IMX6UL_NUM_PWMS = 8, | 25 | - STM32L4x5 GPIOs (General-purpose I/Os) |
26 | +- STM32L4x5 USARTs, UARTs and LPUART (Serial ports) | ||
27 | |||
28 | Missing devices | ||
29 | """"""""""""""" | ||
30 | |||
31 | The B-L475E-IOT01A does *not* support the following devices: | ||
32 | |||
33 | -- Serial ports (UART) | ||
34 | - Analog to Digital Converter (ADC) | ||
35 | - SPI controller | ||
36 | - Timer controller (TIMER) | ||
37 | diff --git a/include/hw/arm/stm32l4x5_soc.h b/include/hw/arm/stm32l4x5_soc.h | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/include/hw/arm/stm32l4x5_soc.h | ||
40 | +++ b/include/hw/arm/stm32l4x5_soc.h | ||
41 | @@ -XXX,XX +XXX,XX @@ | ||
42 | #include "hw/misc/stm32l4x5_exti.h" | ||
43 | #include "hw/misc/stm32l4x5_rcc.h" | ||
44 | #include "hw/gpio/stm32l4x5_gpio.h" | ||
45 | +#include "hw/char/stm32l4x5_usart.h" | ||
46 | #include "qom/object.h" | ||
47 | |||
48 | #define TYPE_STM32L4X5_SOC "stm32l4x5-soc" | ||
49 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_TYPE(Stm32l4x5SocState, Stm32l4x5SocClass, STM32L4X5_SOC) | ||
50 | |||
51 | #define NUM_EXTI_OR_GATES 4 | ||
52 | |||
53 | +#define STM_NUM_USARTS 3 | ||
54 | +#define STM_NUM_UARTS 2 | ||
55 | + | ||
56 | struct Stm32l4x5SocState { | ||
57 | SysBusDevice parent_obj; | ||
58 | |||
59 | @@ -XXX,XX +XXX,XX @@ struct Stm32l4x5SocState { | ||
60 | Stm32l4x5SyscfgState syscfg; | ||
61 | Stm32l4x5RccState rcc; | ||
62 | Stm32l4x5GpioState gpio[NUM_GPIOS]; | ||
63 | + Stm32l4x5UsartBaseState usart[STM_NUM_USARTS]; | ||
64 | + Stm32l4x5UsartBaseState uart[STM_NUM_UARTS]; | ||
65 | + Stm32l4x5UsartBaseState lpuart; | ||
66 | |||
67 | MemoryRegion sram1; | ||
68 | MemoryRegion sram2; | ||
69 | diff --git a/hw/arm/stm32l4x5_soc.c b/hw/arm/stm32l4x5_soc.c | ||
70 | index XXXXXXX..XXXXXXX 100644 | ||
71 | --- a/hw/arm/stm32l4x5_soc.c | ||
72 | +++ b/hw/arm/stm32l4x5_soc.c | ||
73 | @@ -XXX,XX +XXX,XX @@ | ||
74 | #include "sysemu/sysemu.h" | ||
75 | #include "hw/or-irq.h" | ||
76 | #include "hw/arm/stm32l4x5_soc.h" | ||
77 | +#include "hw/char/stm32l4x5_usart.h" | ||
78 | #include "hw/gpio/stm32l4x5_gpio.h" | ||
79 | #include "hw/qdev-clock.h" | ||
80 | #include "hw/misc/unimp.h" | ||
81 | @@ -XXX,XX +XXX,XX @@ static const struct { | ||
82 | { 0x48001C00, 0x0000000F, 0x00000000, 0x00000000 }, | ||
28 | }; | 83 | }; |
29 | 84 | ||
30 | struct FslIMX6ULState { | 85 | +static const hwaddr usart_addr[] = { |
31 | diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c | 86 | + 0x40013800, /* "USART1", 0x400 */ |
32 | index XXXXXXX..XXXXXXX 100644 | 87 | + 0x40004400, /* "USART2", 0x400 */ |
33 | --- a/hw/arm/fsl-imx6ul.c | 88 | + 0x40004800, /* "USART3", 0x400 */ |
34 | +++ b/hw/arm/fsl-imx6ul.c | 89 | +}; |
35 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | 90 | +static const hwaddr uart_addr[] = { |
36 | FSL_IMX6UL_PWM2_ADDR, | 91 | + 0x40004C00, /* "UART4" , 0x400 */ |
37 | FSL_IMX6UL_PWM3_ADDR, | 92 | + 0x40005000 /* "UART5" , 0x400 */ |
38 | FSL_IMX6UL_PWM4_ADDR, | 93 | +}; |
39 | + FSL_IMX6UL_PWM5_ADDR, | 94 | + |
40 | + FSL_IMX6UL_PWM6_ADDR, | 95 | +#define LPUART_BASE_ADDRESS 0x40008000 |
41 | + FSL_IMX6UL_PWM7_ADDR, | 96 | + |
42 | + FSL_IMX6UL_PWM8_ADDR, | 97 | +static const int usart_irq[] = { 37, 38, 39 }; |
43 | }; | 98 | +static const int uart_irq[] = { 52, 53 }; |
44 | 99 | +#define LPUART_IRQ 70 | |
45 | snprintf(name, NAME_SIZE, "pwm%d", i); | 100 | + |
46 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | 101 | static void stm32l4x5_soc_initfn(Object *obj) |
47 | create_unimplemented_device("lcdif", FSL_IMX6UL_LCDIF_ADDR, | 102 | { |
48 | FSL_IMX6UL_LCDIF_SIZE); | 103 | Stm32l4x5SocState *s = STM32L4X5_SOC(obj); |
49 | 104 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_initfn(Object *obj) | |
105 | g_autofree char *name = g_strdup_printf("gpio%c", 'a' + i); | ||
106 | object_initialize_child(obj, name, &s->gpio[i], TYPE_STM32L4X5_GPIO); | ||
107 | } | ||
108 | + | ||
109 | + for (int i = 0; i < STM_NUM_USARTS; i++) { | ||
110 | + object_initialize_child(obj, "usart[*]", &s->usart[i], | ||
111 | + TYPE_STM32L4X5_USART); | ||
112 | + } | ||
113 | + | ||
114 | + for (int i = 0; i < STM_NUM_UARTS; i++) { | ||
115 | + object_initialize_child(obj, "uart[*]", &s->uart[i], | ||
116 | + TYPE_STM32L4X5_UART); | ||
117 | + } | ||
118 | + object_initialize_child(obj, "lpuart1", &s->lpuart, | ||
119 | + TYPE_STM32L4X5_LPUART); | ||
120 | } | ||
121 | |||
122 | static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp) | ||
123 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp) | ||
124 | sysbus_mmio_map(busdev, 0, RCC_BASE_ADDRESS); | ||
125 | sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(armv7m, RCC_IRQ)); | ||
126 | |||
127 | + /* USART devices */ | ||
128 | + for (int i = 0; i < STM_NUM_USARTS; i++) { | ||
129 | + g_autofree char *name = g_strdup_printf("usart%d-out", i + 1); | ||
130 | + dev = DEVICE(&(s->usart[i])); | ||
131 | + qdev_prop_set_chr(dev, "chardev", serial_hd(i)); | ||
132 | + qdev_connect_clock_in(dev, "clk", | ||
133 | + qdev_get_clock_out(DEVICE(&(s->rcc)), name)); | ||
134 | + busdev = SYS_BUS_DEVICE(dev); | ||
135 | + if (!sysbus_realize(busdev, errp)) { | ||
136 | + return; | ||
137 | + } | ||
138 | + sysbus_mmio_map(busdev, 0, usart_addr[i]); | ||
139 | + sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(armv7m, usart_irq[i])); | ||
140 | + } | ||
141 | + | ||
50 | + /* | 142 | + /* |
51 | + * CSU | 143 | + * TODO: Connect the USARTs, UARTs and LPUART to the EXTI once the EXTI |
144 | + * can handle other gpio-in than the gpios. (e.g. Direct Lines for the | ||
145 | + * usarts) | ||
52 | + */ | 146 | + */ |
53 | + create_unimplemented_device("csu", FSL_IMX6UL_CSU_ADDR, | 147 | + |
54 | + FSL_IMX6UL_CSU_SIZE); | 148 | + /* UART devices */ |
55 | + | 149 | + for (int i = 0; i < STM_NUM_UARTS; i++) { |
56 | + /* | 150 | + g_autofree char *name = g_strdup_printf("uart%d-out", STM_NUM_USARTS + i + 1); |
57 | + * TZASC | 151 | + dev = DEVICE(&(s->uart[i])); |
58 | + */ | 152 | + qdev_prop_set_chr(dev, "chardev", serial_hd(STM_NUM_USARTS + i)); |
59 | + create_unimplemented_device("tzasc", FSL_IMX6UL_TZASC_ADDR, | 153 | + qdev_connect_clock_in(dev, "clk", |
60 | + FSL_IMX6UL_TZASC_SIZE); | 154 | + qdev_get_clock_out(DEVICE(&(s->rcc)), name)); |
61 | + | 155 | + busdev = SYS_BUS_DEVICE(dev); |
62 | /* | 156 | + if (!sysbus_realize(busdev, errp)) { |
63 | * ROM memory | 157 | + return; |
64 | */ | 158 | + } |
159 | + sysbus_mmio_map(busdev, 0, uart_addr[i]); | ||
160 | + sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(armv7m, uart_irq[i])); | ||
161 | + } | ||
162 | + | ||
163 | + /* LPUART device*/ | ||
164 | + dev = DEVICE(&(s->lpuart)); | ||
165 | + qdev_prop_set_chr(dev, "chardev", serial_hd(STM_NUM_USARTS + STM_NUM_UARTS)); | ||
166 | + qdev_connect_clock_in(dev, "clk", | ||
167 | + qdev_get_clock_out(DEVICE(&(s->rcc)), "lpuart1-out")); | ||
168 | + busdev = SYS_BUS_DEVICE(dev); | ||
169 | + if (!sysbus_realize(busdev, errp)) { | ||
170 | + return; | ||
171 | + } | ||
172 | + sysbus_mmio_map(busdev, 0, LPUART_BASE_ADDRESS); | ||
173 | + sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(armv7m, LPUART_IRQ)); | ||
174 | + | ||
175 | /* APB1 BUS */ | ||
176 | create_unimplemented_device("TIM2", 0x40000000, 0x400); | ||
177 | create_unimplemented_device("TIM3", 0x40000400, 0x400); | ||
178 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp) | ||
179 | create_unimplemented_device("SPI2", 0x40003800, 0x400); | ||
180 | create_unimplemented_device("SPI3", 0x40003C00, 0x400); | ||
181 | /* RESERVED: 0x40004000, 0x400 */ | ||
182 | - create_unimplemented_device("USART2", 0x40004400, 0x400); | ||
183 | - create_unimplemented_device("USART3", 0x40004800, 0x400); | ||
184 | - create_unimplemented_device("UART4", 0x40004C00, 0x400); | ||
185 | - create_unimplemented_device("UART5", 0x40005000, 0x400); | ||
186 | create_unimplemented_device("I2C1", 0x40005400, 0x400); | ||
187 | create_unimplemented_device("I2C2", 0x40005800, 0x400); | ||
188 | create_unimplemented_device("I2C3", 0x40005C00, 0x400); | ||
189 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp) | ||
190 | create_unimplemented_device("DAC1", 0x40007400, 0x400); | ||
191 | create_unimplemented_device("OPAMP", 0x40007800, 0x400); | ||
192 | create_unimplemented_device("LPTIM1", 0x40007C00, 0x400); | ||
193 | - create_unimplemented_device("LPUART1", 0x40008000, 0x400); | ||
194 | /* RESERVED: 0x40008400, 0x400 */ | ||
195 | create_unimplemented_device("SWPMI1", 0x40008800, 0x400); | ||
196 | /* RESERVED: 0x40008C00, 0x800 */ | ||
197 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp) | ||
198 | create_unimplemented_device("TIM1", 0x40012C00, 0x400); | ||
199 | create_unimplemented_device("SPI1", 0x40013000, 0x400); | ||
200 | create_unimplemented_device("TIM8", 0x40013400, 0x400); | ||
201 | - create_unimplemented_device("USART1", 0x40013800, 0x400); | ||
202 | /* RESERVED: 0x40013C00, 0x400 */ | ||
203 | create_unimplemented_device("TIM15", 0x40014000, 0x400); | ||
204 | create_unimplemented_device("TIM16", 0x40014400, 0x400); | ||
205 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | ||
206 | index XXXXXXX..XXXXXXX 100644 | ||
207 | --- a/hw/arm/Kconfig | ||
208 | +++ b/hw/arm/Kconfig | ||
209 | @@ -XXX,XX +XXX,XX @@ config STM32L4X5_SOC | ||
210 | select STM32L4X5_SYSCFG | ||
211 | select STM32L4X5_RCC | ||
212 | select STM32L4X5_GPIO | ||
213 | + select STM32L4X5_USART | ||
214 | |||
215 | config XLNX_ZYNQMP_ARM | ||
216 | bool | ||
65 | -- | 217 | -- |
66 | 2.34.1 | 218 | 2.34.1 |
67 | 219 | ||
68 | 220 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | From: Arnaud Minier <arnaud.minier@telecom-paris.fr> |
---|---|---|---|
2 | 2 | ||
3 | This is a mandatory feature for Armv8.1 architectures but we don't | 3 | Test: |
4 | state the feature clearly in our emulation list. Also include | 4 | - read/write from/to the usart registers |
5 | FEAT_CRC32 comment in aarch64_max_tcg_initfn for ease of grepping. | 5 | - send/receive a character/string over the serial port |
6 | 6 | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 7 | Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> |
8 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 8 | Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> |
9 | Message-id: 20230824075406.1515566-1-alex.bennee@linaro.org | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Cc: qemu-stable@nongnu.org | 10 | Message-id: 20240329174402.60382-6-arnaud.minier@telecom-paris.fr |
11 | Message-Id: <20230222110104.3996971-1-alex.bennee@linaro.org> | 11 | [PMM: fix checkpatch nits, remove commented out code] |
12 | [PMM: pluralize 'instructions' in docs] | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 13 | --- |
15 | docs/system/arm/emulation.rst | 1 + | 14 | tests/qtest/stm32l4x5_usart-test.c | 315 +++++++++++++++++++++++++++++ |
16 | target/arm/tcg/cpu64.c | 2 +- | 15 | tests/qtest/meson.build | 4 +- |
17 | 2 files changed, 2 insertions(+), 1 deletion(-) | 16 | 2 files changed, 318 insertions(+), 1 deletion(-) |
18 | 17 | create mode 100644 tests/qtest/stm32l4x5_usart-test.c | |
19 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst | 18 | |
19 | diff --git a/tests/qtest/stm32l4x5_usart-test.c b/tests/qtest/stm32l4x5_usart-test.c | ||
20 | new file mode 100644 | ||
21 | index XXXXXXX..XXXXXXX | ||
22 | --- /dev/null | ||
23 | +++ b/tests/qtest/stm32l4x5_usart-test.c | ||
24 | @@ -XXX,XX +XXX,XX @@ | ||
25 | +/* | ||
26 | + * QTest testcase for STML4X5_USART | ||
27 | + * | ||
28 | + * Copyright (c) 2023 Arnaud Minier <arnaud.minier@telecom-paris.fr> | ||
29 | + * Copyright (c) 2023 Inès Varhol <ines.varhol@telecom-paris.fr> | ||
30 | + * | ||
31 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
32 | + * See the COPYING file in the top-level directory. | ||
33 | + */ | ||
34 | + | ||
35 | +#include "qemu/osdep.h" | ||
36 | +#include "libqtest.h" | ||
37 | +#include "hw/misc/stm32l4x5_rcc_internals.h" | ||
38 | +#include "hw/registerfields.h" | ||
39 | + | ||
40 | +#define RCC_BASE_ADDR 0x40021000 | ||
41 | +/* Use USART 1 ADDR, assume the others work the same */ | ||
42 | +#define USART1_BASE_ADDR 0x40013800 | ||
43 | + | ||
44 | +/* See stm32l4x5_usart for definitions */ | ||
45 | +REG32(CR1, 0x00) | ||
46 | + FIELD(CR1, M1, 28, 1) | ||
47 | + FIELD(CR1, OVER8, 15, 1) | ||
48 | + FIELD(CR1, M0, 12, 1) | ||
49 | + FIELD(CR1, PCE, 10, 1) | ||
50 | + FIELD(CR1, TXEIE, 7, 1) | ||
51 | + FIELD(CR1, RXNEIE, 5, 1) | ||
52 | + FIELD(CR1, TE, 3, 1) | ||
53 | + FIELD(CR1, RE, 2, 1) | ||
54 | + FIELD(CR1, UE, 0, 1) | ||
55 | +REG32(CR2, 0x04) | ||
56 | +REG32(CR3, 0x08) | ||
57 | + FIELD(CR3, OVRDIS, 12, 1) | ||
58 | +REG32(BRR, 0x0C) | ||
59 | +REG32(GTPR, 0x10) | ||
60 | +REG32(RTOR, 0x14) | ||
61 | +REG32(RQR, 0x18) | ||
62 | +REG32(ISR, 0x1C) | ||
63 | + FIELD(ISR, TXE, 7, 1) | ||
64 | + FIELD(ISR, RXNE, 5, 1) | ||
65 | + FIELD(ISR, ORE, 3, 1) | ||
66 | +REG32(ICR, 0x20) | ||
67 | +REG32(RDR, 0x24) | ||
68 | +REG32(TDR, 0x28) | ||
69 | + | ||
70 | +#define NVIC_ISPR1 0XE000E204 | ||
71 | +#define NVIC_ICPR1 0xE000E284 | ||
72 | +#define USART1_IRQ 37 | ||
73 | + | ||
74 | +static bool check_nvic_pending(QTestState *qts, unsigned int n) | ||
75 | +{ | ||
76 | + /* No USART interrupts are less than 32 */ | ||
77 | + assert(n > 32); | ||
78 | + n -= 32; | ||
79 | + return qtest_readl(qts, NVIC_ISPR1) & (1 << n); | ||
80 | +} | ||
81 | + | ||
82 | +static bool clear_nvic_pending(QTestState *qts, unsigned int n) | ||
83 | +{ | ||
84 | + /* No USART interrupts are less than 32 */ | ||
85 | + assert(n > 32); | ||
86 | + n -= 32; | ||
87 | + qtest_writel(qts, NVIC_ICPR1, (1 << n)); | ||
88 | + return true; | ||
89 | +} | ||
90 | + | ||
91 | +/* | ||
92 | + * Wait indefinitely for the flag to be updated. | ||
93 | + * If this is run on a slow CI runner, | ||
94 | + * the meson harness will timeout after 10 minutes for us. | ||
95 | + */ | ||
96 | +static bool usart_wait_for_flag(QTestState *qts, uint32_t event_addr, | ||
97 | + uint32_t flag) | ||
98 | +{ | ||
99 | + while (true) { | ||
100 | + if ((qtest_readl(qts, event_addr) & flag)) { | ||
101 | + return true; | ||
102 | + } | ||
103 | + g_usleep(1000); | ||
104 | + } | ||
105 | + | ||
106 | + return false; | ||
107 | +} | ||
108 | + | ||
109 | +static void usart_receive_string(QTestState *qts, int sock_fd, const char *in, | ||
110 | + char *out) | ||
111 | +{ | ||
112 | + int i, in_len = strlen(in); | ||
113 | + | ||
114 | + g_assert_true(send(sock_fd, in, in_len, 0) == in_len); | ||
115 | + for (i = 0; i < in_len; i++) { | ||
116 | + g_assert_true(usart_wait_for_flag(qts, | ||
117 | + USART1_BASE_ADDR + A_ISR, R_ISR_RXNE_MASK)); | ||
118 | + out[i] = qtest_readl(qts, USART1_BASE_ADDR + A_RDR); | ||
119 | + } | ||
120 | + out[i] = '\0'; | ||
121 | +} | ||
122 | + | ||
123 | +static void usart_send_string(QTestState *qts, const char *in) | ||
124 | +{ | ||
125 | + int i, in_len = strlen(in); | ||
126 | + | ||
127 | + for (i = 0; i < in_len; i++) { | ||
128 | + qtest_writel(qts, USART1_BASE_ADDR + A_TDR, in[i]); | ||
129 | + g_assert_true(usart_wait_for_flag(qts, | ||
130 | + USART1_BASE_ADDR + A_ISR, R_ISR_TXE_MASK)); | ||
131 | + } | ||
132 | +} | ||
133 | + | ||
134 | +/* Init the RCC clocks to run at 80 MHz */ | ||
135 | +static void init_clocks(QTestState *qts) | ||
136 | +{ | ||
137 | + uint32_t value; | ||
138 | + | ||
139 | + /* MSIRANGE can be set only when MSI is OFF or READY */ | ||
140 | + qtest_writel(qts, (RCC_BASE_ADDR + A_CR), R_CR_MSION_MASK); | ||
141 | + | ||
142 | + /* Clocking from MSI, in case MSI was not the default source */ | ||
143 | + qtest_writel(qts, (RCC_BASE_ADDR + A_CFGR), 0); | ||
144 | + | ||
145 | + /* | ||
146 | + * Update PLL and set MSI as the source clock. | ||
147 | + * PLLM = 1 --> 000 | ||
148 | + * PLLN = 40 --> 40 | ||
149 | + * PPLLR = 2 --> 00 | ||
150 | + * PLLDIV = unused, PLLP = unused (SAI3), PLLQ = unused (48M1) | ||
151 | + * SRC = MSI --> 01 | ||
152 | + */ | ||
153 | + qtest_writel(qts, (RCC_BASE_ADDR + A_PLLCFGR), R_PLLCFGR_PLLREN_MASK | | ||
154 | + (40 << R_PLLCFGR_PLLN_SHIFT) | | ||
155 | + (0b01 << R_PLLCFGR_PLLSRC_SHIFT)); | ||
156 | + | ||
157 | + /* PLL activation */ | ||
158 | + | ||
159 | + value = qtest_readl(qts, (RCC_BASE_ADDR + A_CR)); | ||
160 | + qtest_writel(qts, (RCC_BASE_ADDR + A_CR), value | R_CR_PLLON_MASK); | ||
161 | + | ||
162 | + /* RCC_CFGR is OK by defaut */ | ||
163 | + qtest_writel(qts, (RCC_BASE_ADDR + A_CFGR), 0); | ||
164 | + | ||
165 | + /* CCIPR : no periph clock by default */ | ||
166 | + qtest_writel(qts, (RCC_BASE_ADDR + A_CCIPR), 0); | ||
167 | + | ||
168 | + /* Switches on the PLL clock source */ | ||
169 | + value = qtest_readl(qts, (RCC_BASE_ADDR + A_CFGR)); | ||
170 | + qtest_writel(qts, (RCC_BASE_ADDR + A_CFGR), (value & ~R_CFGR_SW_MASK) | | ||
171 | + (0b11 << R_CFGR_SW_SHIFT)); | ||
172 | + | ||
173 | + /* Enable SYSCFG clock enabled */ | ||
174 | + qtest_writel(qts, (RCC_BASE_ADDR + A_APB2ENR), R_APB2ENR_SYSCFGEN_MASK); | ||
175 | + | ||
176 | + /* Enable the IO port B clock (See p.252) */ | ||
177 | + qtest_writel(qts, (RCC_BASE_ADDR + A_AHB2ENR), R_AHB2ENR_GPIOBEN_MASK); | ||
178 | + | ||
179 | + /* Enable the clock for USART1 (cf p.259) */ | ||
180 | + /* We rewrite SYSCFGEN to not disable it */ | ||
181 | + qtest_writel(qts, (RCC_BASE_ADDR + A_APB2ENR), | ||
182 | + R_APB2ENR_SYSCFGEN_MASK | R_APB2ENR_USART1EN_MASK); | ||
183 | + | ||
184 | + /* TODO: Enable usart via gpio */ | ||
185 | + | ||
186 | + /* Set PCLK as the clock for USART1(cf p.272) i.e. reset both bits */ | ||
187 | + qtest_writel(qts, (RCC_BASE_ADDR + A_CCIPR), 0); | ||
188 | + | ||
189 | + /* Reset USART1 (see p.249) */ | ||
190 | + qtest_writel(qts, (RCC_BASE_ADDR + A_APB2RSTR), 1 << 14); | ||
191 | + qtest_writel(qts, (RCC_BASE_ADDR + A_APB2RSTR), 0); | ||
192 | +} | ||
193 | + | ||
194 | +static void init_uart(QTestState *qts) | ||
195 | +{ | ||
196 | + uint32_t cr1; | ||
197 | + | ||
198 | + init_clocks(qts); | ||
199 | + | ||
200 | + /* | ||
201 | + * For 115200 bauds, see p.1349. | ||
202 | + * The clock has a frequency of 80Mhz, | ||
203 | + * for 115200, we have to put a divider of 695 = 0x2B7. | ||
204 | + */ | ||
205 | + qtest_writel(qts, (USART1_BASE_ADDR + A_BRR), 0x2B7); | ||
206 | + | ||
207 | + /* | ||
208 | + * Set the oversampling by 16, | ||
209 | + * disable the parity control and | ||
210 | + * set the word length to 8. (cf p.1377) | ||
211 | + */ | ||
212 | + cr1 = qtest_readl(qts, (USART1_BASE_ADDR + A_CR1)); | ||
213 | + cr1 &= ~(R_CR1_M1_MASK | R_CR1_M0_MASK | R_CR1_OVER8_MASK | R_CR1_PCE_MASK); | ||
214 | + qtest_writel(qts, (USART1_BASE_ADDR + A_CR1), cr1); | ||
215 | + | ||
216 | + /* Enable the transmitter, the receiver and the USART. */ | ||
217 | + qtest_writel(qts, (USART1_BASE_ADDR + A_CR1), | ||
218 | + R_CR1_UE_MASK | R_CR1_RE_MASK | R_CR1_TE_MASK); | ||
219 | +} | ||
220 | + | ||
221 | +static void test_write_read(void) | ||
222 | +{ | ||
223 | + QTestState *qts = qtest_init("-M b-l475e-iot01a"); | ||
224 | + | ||
225 | + /* Test that we can write and retrieve a value from the device */ | ||
226 | + qtest_writel(qts, USART1_BASE_ADDR + A_TDR, 0xFFFFFFFF); | ||
227 | + const uint32_t tdr = qtest_readl(qts, USART1_BASE_ADDR + A_TDR); | ||
228 | + g_assert_cmpuint(tdr, ==, 0x000001FF); | ||
229 | +} | ||
230 | + | ||
231 | +static void test_receive_char(void) | ||
232 | +{ | ||
233 | + int sock_fd; | ||
234 | + uint32_t cr1; | ||
235 | + QTestState *qts = qtest_init_with_serial("-M b-l475e-iot01a", &sock_fd); | ||
236 | + | ||
237 | + init_uart(qts); | ||
238 | + | ||
239 | + /* Try without initializing IRQ */ | ||
240 | + g_assert_true(send(sock_fd, "a", 1, 0) == 1); | ||
241 | + usart_wait_for_flag(qts, USART1_BASE_ADDR + A_ISR, R_ISR_RXNE_MASK); | ||
242 | + g_assert_cmphex(qtest_readl(qts, USART1_BASE_ADDR + A_RDR), ==, 'a'); | ||
243 | + g_assert_false(check_nvic_pending(qts, USART1_IRQ)); | ||
244 | + | ||
245 | + /* Now with the IRQ */ | ||
246 | + cr1 = qtest_readl(qts, (USART1_BASE_ADDR + A_CR1)); | ||
247 | + cr1 |= R_CR1_RXNEIE_MASK; | ||
248 | + qtest_writel(qts, USART1_BASE_ADDR + A_CR1, cr1); | ||
249 | + g_assert_true(send(sock_fd, "b", 1, 0) == 1); | ||
250 | + usart_wait_for_flag(qts, USART1_BASE_ADDR + A_ISR, R_ISR_RXNE_MASK); | ||
251 | + g_assert_cmphex(qtest_readl(qts, USART1_BASE_ADDR + A_RDR), ==, 'b'); | ||
252 | + g_assert_true(check_nvic_pending(qts, USART1_IRQ)); | ||
253 | + clear_nvic_pending(qts, USART1_IRQ); | ||
254 | + | ||
255 | + close(sock_fd); | ||
256 | + | ||
257 | + qtest_quit(qts); | ||
258 | +} | ||
259 | + | ||
260 | +static void test_send_char(void) | ||
261 | +{ | ||
262 | + int sock_fd; | ||
263 | + char s[1]; | ||
264 | + uint32_t cr1; | ||
265 | + QTestState *qts = qtest_init_with_serial("-M b-l475e-iot01a", &sock_fd); | ||
266 | + | ||
267 | + init_uart(qts); | ||
268 | + | ||
269 | + /* Try without initializing IRQ */ | ||
270 | + qtest_writel(qts, USART1_BASE_ADDR + A_TDR, 'c'); | ||
271 | + g_assert_true(recv(sock_fd, s, 1, 0) == 1); | ||
272 | + g_assert_cmphex(s[0], ==, 'c'); | ||
273 | + g_assert_false(check_nvic_pending(qts, USART1_IRQ)); | ||
274 | + | ||
275 | + /* Now with the IRQ */ | ||
276 | + cr1 = qtest_readl(qts, (USART1_BASE_ADDR + A_CR1)); | ||
277 | + cr1 |= R_CR1_TXEIE_MASK; | ||
278 | + qtest_writel(qts, USART1_BASE_ADDR + A_CR1, cr1); | ||
279 | + qtest_writel(qts, USART1_BASE_ADDR + A_TDR, 'd'); | ||
280 | + g_assert_true(recv(sock_fd, s, 1, 0) == 1); | ||
281 | + g_assert_cmphex(s[0], ==, 'd'); | ||
282 | + g_assert_true(check_nvic_pending(qts, USART1_IRQ)); | ||
283 | + clear_nvic_pending(qts, USART1_IRQ); | ||
284 | + | ||
285 | + close(sock_fd); | ||
286 | + | ||
287 | + qtest_quit(qts); | ||
288 | +} | ||
289 | + | ||
290 | +static void test_receive_str(void) | ||
291 | +{ | ||
292 | + int sock_fd; | ||
293 | + char s[10]; | ||
294 | + QTestState *qts = qtest_init_with_serial("-M b-l475e-iot01a", &sock_fd); | ||
295 | + | ||
296 | + init_uart(qts); | ||
297 | + | ||
298 | + usart_receive_string(qts, sock_fd, "hello", s); | ||
299 | + g_assert_true(memcmp(s, "hello", 5) == 0); | ||
300 | + | ||
301 | + close(sock_fd); | ||
302 | + | ||
303 | + qtest_quit(qts); | ||
304 | +} | ||
305 | + | ||
306 | +static void test_send_str(void) | ||
307 | +{ | ||
308 | + int sock_fd; | ||
309 | + char s[10]; | ||
310 | + QTestState *qts = qtest_init_with_serial("-M b-l475e-iot01a", &sock_fd); | ||
311 | + | ||
312 | + init_uart(qts); | ||
313 | + | ||
314 | + usart_send_string(qts, "world"); | ||
315 | + g_assert_true(recv(sock_fd, s, 10, 0) == 5); | ||
316 | + g_assert_true(memcmp(s, "world", 5) == 0); | ||
317 | + | ||
318 | + close(sock_fd); | ||
319 | + | ||
320 | + qtest_quit(qts); | ||
321 | +} | ||
322 | + | ||
323 | +int main(int argc, char **argv) | ||
324 | +{ | ||
325 | + int ret; | ||
326 | + | ||
327 | + g_test_init(&argc, &argv, NULL); | ||
328 | + g_test_set_nonfatal_assertions(); | ||
329 | + | ||
330 | + qtest_add_func("stm32l4x5/usart/write_read", test_write_read); | ||
331 | + qtest_add_func("stm32l4x5/usart/receive_char", test_receive_char); | ||
332 | + qtest_add_func("stm32l4x5/usart/send_char", test_send_char); | ||
333 | + qtest_add_func("stm32l4x5/usart/receive_str", test_receive_str); | ||
334 | + qtest_add_func("stm32l4x5/usart/send_str", test_send_str); | ||
335 | + ret = g_test_run(); | ||
336 | + | ||
337 | + return ret; | ||
338 | +} | ||
339 | + | ||
340 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build | ||
20 | index XXXXXXX..XXXXXXX 100644 | 341 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/docs/system/arm/emulation.rst | 342 | --- a/tests/qtest/meson.build |
22 | +++ b/docs/system/arm/emulation.rst | 343 | +++ b/tests/qtest/meson.build |
23 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: | 344 | @@ -XXX,XX +XXX,XX @@ slow_qtests = { |
24 | - FEAT_BBM at level 2 (Translation table break-before-make levels) | 345 | 'npcm7xx_pwm-test': 300, |
25 | - FEAT_BF16 (AArch64 BFloat16 instructions) | 346 | 'npcm7xx_watchdog_timer-test': 120, |
26 | - FEAT_BTI (Branch Target Identification) | 347 | 'qom-test' : 900, |
27 | +- FEAT_CRC32 (CRC32 instructions) | 348 | + 'stm32l4x5_usart-test' : 600, |
28 | - FEAT_CSV2 (Cache speculation variant 2) | 349 | 'test-hmp' : 240, |
29 | - FEAT_CSV2_1p1 (Cache speculation variant 2, version 1.1) | 350 | 'pxe-test': 610, |
30 | - FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2) | 351 | 'prom-env-test': 360, |
31 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c | 352 | @@ -XXX,XX +XXX,XX @@ qtests_stm32l4x5 = \ |
32 | index XXXXXXX..XXXXXXX 100644 | 353 | ['stm32l4x5_exti-test', |
33 | --- a/target/arm/tcg/cpu64.c | 354 | 'stm32l4x5_syscfg-test', |
34 | +++ b/target/arm/tcg/cpu64.c | 355 | 'stm32l4x5_rcc-test', |
35 | @@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj) | 356 | - 'stm32l4x5_gpio-test'] |
36 | t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2); /* FEAT_PMULL */ | 357 | + 'stm32l4x5_gpio-test', |
37 | t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1); /* FEAT_SHA1 */ | 358 | + 'stm32l4x5_usart-test'] |
38 | t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 2); /* FEAT_SHA512 */ | 359 | |
39 | - t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1); | 360 | qtests_arm = \ |
40 | + t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1); /* FEAT_CRC32 */ | 361 | (config_all_devices.has_key('CONFIG_MPS2') ? ['sse-timer-test'] : []) + \ |
41 | t = FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2); /* FEAT_LSE */ | ||
42 | t = FIELD_DP64(t, ID_AA64ISAR0, RDM, 1); /* FEAT_RDM */ | ||
43 | t = FIELD_DP64(t, ID_AA64ISAR0, SHA3, 1); /* FEAT_SHA3 */ | ||
44 | -- | 362 | -- |
45 | 2.34.1 | 363 | 2.34.1 |
46 | 364 | ||
47 | 365 | diff view generated by jsdifflib |