1
The following changes since commit 7e7eb9f852a46b51a71ae9d82590b2e4d28827ee:
1
Hi; here's the first arm pullreq for 9.1.
2
2
3
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2021-01-28' into staging (2021-01-28 22:43:18 +0000)
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.
10
11
thanks
12
-- PMM
13
14
The following changes since commit 5da72194df36535d773c8bdc951529ecd5e31707:
15
16
Merge tag 'pull-tcg-20240424' of https://gitlab.com/rth7680/qemu into staging (2024-04-24 15:51:49 -0700)
4
17
5
are available in the Git repository at:
18
are available in the Git repository at:
6
19
7
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210129
20
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20240425
8
21
9
for you to fetch changes up to 11749122e1a86866591306d43603d2795a3dea1a:
22
for you to fetch changes up to 214652da123e3821657a64691ee556281e9f6238:
10
23
11
hw/arm/stellaris: Remove board-creation reset of STELLARIS_SYS (2021-01-29 10:47:29 +0000)
24
tests/qtest: Add tests for the STM32L4x5 USART (2024-04-25 10:21:59 +0100)
12
25
13
----------------------------------------------------------------
26
----------------------------------------------------------------
14
target-arm queue:
27
target-arm queue:
15
* Implement ID_PFR2
28
* Implement FEAT_NMI and NMI support in the GICv3
16
* Conditionalize DBGDIDR
29
* hw/dma: avoid apparent overflow in soc_dma_set_request
17
* rename xlnx-zcu102.canbusN properties
30
* linux-user/flatload.c: Remove unused bFLT shared-library and ZFLAT code
18
* provide powerdown/reset mechanism for secure firmware on 'virt' board
31
* Add ResetType argument to Resettable hold and exit phase methods
19
* hw/misc: Fix arith overflow in NPCM7XX PWM module
32
* Add RESET_TYPE_SNAPSHOT_LOAD ResetType
20
* target/arm: Replace magic value by MMU_DATA_LOAD definition
33
* Implement STM32L4x5 USART
21
* configure: fix preadv errors on Catalina macOS with new XCode
22
* Various configure and other cleanups in preparation for iOS support
23
* hvf: Add hypervisor entitlement to output binaries (needed for Big Sur)
24
* Implement pvpanic-pci device
25
* Convert the CMSDK timer devices to the Clock framework
26
34
27
----------------------------------------------------------------
35
----------------------------------------------------------------
28
Alexander Graf (1):
36
Anastasia Belova (1):
29
hvf: Add hypervisor entitlement to output binaries
37
hw/dma: avoid apparent overflow in soc_dma_set_request
30
38
31
Hao Wu (1):
39
Arnaud Minier (5):
32
hw/misc: Fix arith overflow in NPCM7XX PWM module
40
hw/char: Implement STM32L4x5 USART skeleton
33
41
hw/char/stm32l4x5_usart: Enable serial read and write
34
Joelle van Dyne (7):
42
hw/char/stm32l4x5_usart: Add options for serial parameters setting
35
configure: cross-compiling with empty cross_prefix
43
hw/arm: Add the USART to the stm32l4x5 SoC
36
osdep: build with non-working system() function
44
tests/qtest: Add tests for the STM32L4x5 USART
37
darwin: remove redundant dependency declaration
45
38
darwin: fix cross-compiling for Darwin
46
Jinjie Ruan (22):
39
configure: cross compile should use x86_64 cpu_family
47
target/arm: Handle HCR_EL2 accesses for bits introduced with FEAT_NMI
40
darwin: detect CoreAudio for build
48
target/arm: Add PSTATE.ALLINT
41
darwin: remove 64-bit build detection on 32-bit OS
49
target/arm: Add support for FEAT_NMI, Non-maskable Interrupt
42
50
target/arm: Implement ALLINT MSR (immediate)
43
Maxim Uvarov (3):
51
target/arm: Support MSR access to ALLINT
44
hw: gpio: implement gpio-pwr driver for qemu reset/poweroff
52
target/arm: Add support for Non-maskable Interrupt
45
arm-virt: refactor gpios creation
53
target/arm: Add support for NMI in arm_phys_excp_target_el()
46
arm-virt: add secure pl061 for reset/power down
54
target/arm: Handle IS/FS in ISR_EL1 for NMI, VINMI and VFNMI
47
55
target/arm: Handle PSTATE.ALLINT on taking an exception
48
Mihai Carabas (4):
56
hw/intc/arm_gicv3: Add external IRQ lines for NMI
49
hw/misc/pvpanic: split-out generic and bus dependent code
57
hw/arm/virt: Wire NMI and VINMI irq lines from GIC to CPU
50
hw/misc/pvpanic: add PCI interface support
58
target/arm: Handle NMI in arm_cpu_do_interrupt_aarch64()
51
pvpanic : update pvpanic spec document
59
hw/intc/arm_gicv3: Add has-nmi property to GICv3 device
52
tests/qtest: add a test case for pvpanic-pci
60
hw/intc/arm_gicv3_kvm: Not set has-nmi=true for the KVM GICv3
53
61
hw/intc/arm_gicv3: Add irq non-maskable property
54
Paolo Bonzini (1):
62
hw/intc/arm_gicv3_redist: Implement GICR_INMIR0
55
arm: rename xlnx-zcu102.canbusN properties
63
hw/intc/arm_gicv3: Implement GICD_INMIR
56
64
hw/intc/arm_gicv3: Implement NMI interrupt priority
57
Peter Maydell (26):
65
hw/intc/arm_gicv3: Report the NMI interrupt in gicv3_cpuif_update()
58
configure: Move preadv check to meson.build
66
hw/intc/arm_gicv3: Report the VINMI interrupt
59
ptimer: Add new ptimer_set_period_from_clock() function
67
target/arm: Add FEAT_NMI to max
60
clock: Add new clock_has_source() function
68
hw/arm/virt: Enable NMI support in the GIC if the CPU has FEAT_NMI
61
tests: Add a simple test of the CMSDK APB timer
69
62
tests: Add a simple test of the CMSDK APB watchdog
70
Peter Maydell (9):
63
tests: Add a simple test of the CMSDK APB dual timer
71
hw/intc/arm_gicv3: Add NMI handling CPU interface registers
64
hw/timer/cmsdk-apb-timer: Rename CMSDKAPBTIMER struct to CMSDKAPBTimer
72
hw/intc/arm_gicv3: Handle icv_nmiar1_read() for icc_nmiar1_read()
65
hw/timer/cmsdk-apb-timer: Add Clock input
73
linux-user/flatload.c: Remove unused bFLT shared-library and ZFLAT code
66
hw/timer/cmsdk-apb-dualtimer: Add Clock input
74
hw/misc: Don't special case RESET_TYPE_COLD in npcm7xx_clk, gcr
67
hw/watchdog/cmsdk-apb-watchdog: Add Clock input
75
allwinner-i2c, adm1272: Use device_cold_reset() for software-triggered reset
68
hw/arm/armsse: Rename "MAINCLK" property to "MAINCLK_FRQ"
76
scripts/coccinelle: New script to add ResetType to hold and exit phases
69
hw/arm/armsse: Wire up clocks
77
hw, target: Add ResetType argument to hold and exit phase methods
70
hw/arm/mps2: Inline CMSDK_APB_TIMER creation
78
docs/devel/reset: Update to new API for hold and exit phase methods
71
hw/arm/mps2: Create and connect SYSCLK Clock
79
reset: Add RESET_TYPE_SNAPSHOT_LOAD
72
hw/arm/mps2-tz: Create and connect ARMSSE Clocks
80
73
hw/arm/musca: Create and connect ARMSSE Clocks
81
MAINTAINERS | 1 +
74
hw/arm/stellaris: Convert SSYS to QOM device
82
docs/devel/reset.rst | 25 +-
75
hw/arm/stellaris: Create Clock input for watchdog
83
docs/system/arm/b-l475e-iot01a.rst | 2 +-
76
hw/timer/cmsdk-apb-timer: Convert to use Clock input
84
docs/system/arm/emulation.rst | 1 +
77
hw/timer/cmsdk-apb-dualtimer: Convert to use Clock input
85
scripts/coccinelle/reset-type.cocci | 133 ++++++++
78
hw/watchdog/cmsdk-apb-watchdog: Convert to use Clock input
86
hw/intc/gicv3_internal.h | 13 +
79
tests/qtest/cmsdk-apb-watchdog-test: Test clock changes
87
include/hw/arm/stm32l4x5_soc.h | 7 +
80
hw/arm/armsse: Use Clock to set system_clock_scale
88
include/hw/char/stm32l4x5_usart.h | 67 ++++
81
arm: Don't set freq properties on CMSDK timer, dualtimer, watchdog, ARMSSE
89
include/hw/intc/arm_gic_common.h | 2 +
82
arm: Remove frq properties on CMSDK timer, dualtimer, watchdog, ARMSSE
90
include/hw/intc/arm_gicv3_common.h | 14 +
83
hw/arm/stellaris: Remove board-creation reset of STELLARIS_SYS
91
include/hw/resettable.h | 5 +-
84
92
linux-user/flat.h | 5 +-
85
Philippe Mathieu-Daudé (1):
93
target/arm/cpu-features.h | 5 +
86
target/arm: Replace magic value by MMU_DATA_LOAD definition
94
target/arm/cpu-qom.h | 5 +-
87
95
target/arm/cpu.h | 9 +
88
Richard Henderson (2):
96
target/arm/internals.h | 21 ++
89
target/arm: Implement ID_PFR2
97
target/arm/tcg/helper-a64.h | 1 +
90
target/arm: Conditionalize DBGDIDR
98
target/arm/tcg/a64.decode | 1 +
91
99
hw/adc/npcm7xx_adc.c | 2 +-
92
docs/devel/clocks.rst | 16 +++
100
hw/arm/pxa2xx_pic.c | 2 +-
93
docs/specs/pci-ids.txt | 1 +
101
hw/arm/smmu-common.c | 2 +-
94
docs/specs/pvpanic.txt | 13 ++-
102
hw/arm/smmuv3.c | 4 +-
95
docs/system/arm/virt.rst | 2 +
103
hw/arm/stellaris.c | 10 +-
96
configure | 78 ++++++++------
104
hw/arm/stm32l4x5_soc.c | 83 ++++-
97
meson.build | 34 ++++++-
105
hw/arm/virt.c | 29 +-
98
include/hw/arm/armsse.h | 14 ++-
106
hw/audio/asc.c | 2 +-
99
include/hw/arm/virt.h | 2 +
107
hw/char/cadence_uart.c | 2 +-
100
include/hw/clock.h | 15 +++
108
hw/char/sifive_uart.c | 2 +-
101
include/hw/misc/pvpanic.h | 24 ++++-
109
hw/char/stm32l4x5_usart.c | 637 ++++++++++++++++++++++++++++++++++++
102
include/hw/pci/pci.h | 1 +
110
hw/core/cpu-common.c | 2 +-
103
include/hw/ptimer.h | 22 ++++
111
hw/core/qdev.c | 4 +-
104
include/hw/timer/cmsdk-apb-dualtimer.h | 5 +-
112
hw/core/reset.c | 17 +-
105
include/hw/timer/cmsdk-apb-timer.h | 34 ++-----
113
hw/core/resettable.c | 8 +-
106
include/hw/watchdog/cmsdk-apb-watchdog.h | 5 +-
114
hw/display/virtio-vga.c | 4 +-
107
include/qemu/osdep.h | 12 +++
115
hw/dma/soc_dma.c | 4 +-
108
include/qemu/typedefs.h | 1 +
116
hw/gpio/npcm7xx_gpio.c | 2 +-
109
target/arm/cpu.h | 1 +
117
hw/gpio/pl061.c | 2 +-
110
hw/arm/armsse.c | 48 ++++++---
118
hw/gpio/stm32l4x5_gpio.c | 2 +-
111
hw/arm/mps2-tz.c | 14 ++-
119
hw/hyperv/vmbus.c | 2 +-
112
hw/arm/mps2.c | 28 ++++-
120
hw/i2c/allwinner-i2c.c | 5 +-
113
hw/arm/musca.c | 13 ++-
121
hw/i2c/npcm7xx_smbus.c | 2 +-
114
hw/arm/stellaris.c | 170 +++++++++++++++++++++++--------
122
hw/input/adb.c | 2 +-
115
hw/arm/virt.c | 111 ++++++++++++++++----
123
hw/input/ps2.c | 12 +-
116
hw/arm/xlnx-zcu102.c | 4 +-
124
hw/intc/arm_gic_common.c | 2 +-
117
hw/core/ptimer.c | 34 +++++++
125
hw/intc/arm_gic_kvm.c | 4 +-
118
hw/gpio/gpio_pwr.c | 70 +++++++++++++
126
hw/intc/arm_gicv3.c | 67 +++-
119
hw/misc/npcm7xx_pwm.c | 23 ++++-
127
hw/intc/arm_gicv3_common.c | 50 ++-
120
hw/misc/pvpanic-isa.c | 94 +++++++++++++++++
128
hw/intc/arm_gicv3_cpuif.c | 268 ++++++++++++++-
121
hw/misc/pvpanic-pci.c | 94 +++++++++++++++++
129
hw/intc/arm_gicv3_dist.c | 36 ++
122
hw/misc/pvpanic.c | 85 ++--------------
130
hw/intc/arm_gicv3_its.c | 4 +-
123
hw/timer/cmsdk-apb-dualtimer.c | 53 +++++++---
131
hw/intc/arm_gicv3_its_common.c | 2 +-
124
hw/timer/cmsdk-apb-timer.c | 55 +++++-----
132
hw/intc/arm_gicv3_its_kvm.c | 4 +-
125
hw/watchdog/cmsdk-apb-watchdog.c | 29 ++++--
133
hw/intc/arm_gicv3_kvm.c | 9 +-
126
target/arm/helper.c | 27 +++--
134
hw/intc/arm_gicv3_redist.c | 22 ++
127
target/arm/kvm64.c | 2 +
135
hw/intc/xics.c | 2 +-
128
tests/qtest/cmsdk-apb-dualtimer-test.c | 130 +++++++++++++++++++++++
136
hw/m68k/q800-glue.c | 2 +-
129
tests/qtest/cmsdk-apb-timer-test.c | 75 ++++++++++++++
137
hw/misc/djmemc.c | 2 +-
130
tests/qtest/cmsdk-apb-watchdog-test.c | 131 ++++++++++++++++++++++++
138
hw/misc/iosb.c | 2 +-
131
tests/qtest/npcm7xx_pwm-test.c | 4 +-
139
hw/misc/mac_via.c | 8 +-
132
tests/qtest/pvpanic-pci-test.c | 94 +++++++++++++++++
140
hw/misc/macio/cuda.c | 4 +-
133
tests/qtest/xlnx-can-test.c | 30 +++---
141
hw/misc/macio/pmu.c | 4 +-
134
MAINTAINERS | 3 +
142
hw/misc/mos6522.c | 2 +-
135
accel/hvf/entitlements.plist | 8 ++
143
hw/misc/npcm7xx_clk.c | 13 +-
136
hw/arm/Kconfig | 1 +
144
hw/misc/npcm7xx_gcr.c | 12 +-
137
hw/gpio/Kconfig | 3 +
145
hw/misc/npcm7xx_mft.c | 2 +-
138
hw/gpio/meson.build | 1 +
146
hw/misc/npcm7xx_pwm.c | 2 +-
139
hw/i386/Kconfig | 2 +-
147
hw/misc/stm32l4x5_exti.c | 2 +-
140
hw/misc/Kconfig | 12 ++-
148
hw/misc/stm32l4x5_rcc.c | 10 +-
141
hw/misc/meson.build | 4 +-
149
hw/misc/stm32l4x5_syscfg.c | 2 +-
142
scripts/entitlement.sh | 13 +++
150
hw/misc/xlnx-versal-cframe-reg.c | 2 +-
143
tests/qtest/meson.build | 6 +-
151
hw/misc/xlnx-versal-crl.c | 2 +-
144
52 files changed, 1432 insertions(+), 319 deletions(-)
152
hw/misc/xlnx-versal-pmc-iou-slcr.c | 2 +-
145
create mode 100644 hw/gpio/gpio_pwr.c
153
hw/misc/xlnx-versal-trng.c | 2 +-
146
create mode 100644 hw/misc/pvpanic-isa.c
154
hw/misc/xlnx-versal-xramc.c | 2 +-
147
create mode 100644 hw/misc/pvpanic-pci.c
155
hw/misc/xlnx-zynqmp-apu-ctrl.c | 2 +-
148
create mode 100644 tests/qtest/cmsdk-apb-dualtimer-test.c
156
hw/misc/xlnx-zynqmp-crf.c | 2 +-
149
create mode 100644 tests/qtest/cmsdk-apb-timer-test.c
157
hw/misc/zynq_slcr.c | 4 +-
150
create mode 100644 tests/qtest/cmsdk-apb-watchdog-test.c
158
hw/net/can/xlnx-zynqmp-can.c | 2 +-
151
create mode 100644 tests/qtest/pvpanic-pci-test.c
159
hw/net/e1000.c | 2 +-
152
create mode 100644 accel/hvf/entitlements.plist
160
hw/net/e1000e.c | 2 +-
153
create mode 100755 scripts/entitlement.sh
161
hw/net/igb.c | 2 +-
154
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
1
Now that the watchdog device uses its Clock input rather than being
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
passed the value of system_clock_scale at creation time, we can
3
remove the hack where we reset the STELLARIS_SYS at board creation
4
time to force it to set system_clock_scale. Instead it will be reset
5
at the usual point in startup and will inform the watchdog of the
6
clock frequency at that point.
7
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
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Luc Michel <luc@lmichel.fr>
10
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
12
Message-id: 20210128114145.20536-26-peter.maydell@linaro.org
13
Message-id: 20210121190622.22000-26-peter.maydell@linaro.org
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
---
12
---
16
hw/arm/stellaris.c | 10 ----------
13
target/arm/cpu-features.h | 5 +++++
17
1 file changed, 10 deletions(-)
14
target/arm/helper.c | 8 +++++++-
15
2 files changed, 12 insertions(+), 1 deletion(-)
18
16
19
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
17
diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h
20
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/arm/stellaris.c
19
--- a/target/arm/cpu-features.h
22
+++ b/hw/arm/stellaris.c
20
+++ b/target/arm/cpu-features.h
23
@@ -XXX,XX +XXX,XX @@ static DeviceState *stellaris_sys_init(uint32_t base, qemu_irq irq,
21
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_sme(const ARMISARegisters *id)
24
sysbus_mmio_map(sbd, 0, base);
22
return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SME) != 0;
25
sysbus_connect_irq(sbd, 0, irq);
26
27
- /*
28
- * Normally we should not be resetting devices like this during
29
- * board creation. For the moment we need to do so, because
30
- * system_clock_scale will only get set when the STELLARIS_SYS
31
- * device is reset, and we need its initial value to pass to
32
- * the watchdog device. This hack can be removed once the
33
- * watchdog has been converted to use a Clock input instead.
34
- */
35
- device_cold_reset(dev);
36
-
37
return dev;
38
}
23
}
39
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
}
40
--
58
--
41
2.20.1
59
2.34.1
42
43
diff view generated by jsdifflib
1
From: Mihai Carabas <mihai.carabas@oracle.com>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
Add pvpanic PCI device support details in docs/specs/pvpanic.txt.
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.
4
6
5
Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
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>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
17
Message-id: 20240407081733.3231820-3-ruanjinjie@huawei.com
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
19
---
9
docs/specs/pvpanic.txt | 13 ++++++++++++-
20
target/arm/cpu.h | 1 +
10
1 file changed, 12 insertions(+), 1 deletion(-)
21
target/arm/tcg/helper-a64.c | 4 ++--
22
2 files changed, 3 insertions(+), 2 deletions(-)
11
23
12
diff --git a/docs/specs/pvpanic.txt b/docs/specs/pvpanic.txt
24
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
13
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
14
--- a/docs/specs/pvpanic.txt
26
--- a/target/arm/cpu.h
15
+++ b/docs/specs/pvpanic.txt
27
+++ b/target/arm/cpu.h
16
@@ -XXX,XX +XXX,XX @@
28
@@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu);
17
PVPANIC DEVICE
29
#define PSTATE_D (1U << 9)
18
==============
30
#define PSTATE_BTYPE (3U << 10)
19
31
#define PSTATE_SSBS (1U << 12)
20
-pvpanic device is a simulated ISA device, through which a guest panic
32
+#define PSTATE_ALLINT (1U << 13)
21
+pvpanic device is a simulated device, through which a guest panic
33
#define PSTATE_IL (1U << 20)
22
event is sent to qemu, and a QMP event is generated. This allows
34
#define PSTATE_SS (1U << 21)
23
management apps (e.g. libvirt) to be notified and respond to the event.
35
#define PSTATE_PAN (1U << 22)
24
36
diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c
25
@@ -XXX,XX +XXX,XX @@ The management app has the option of waiting for GUEST_PANICKED events,
37
index XXXXXXX..XXXXXXX 100644
26
and/or polling for guest-panicked RunState, to learn when the pvpanic
38
--- a/target/arm/tcg/helper-a64.c
27
device has fired a panic event.
39
+++ b/target/arm/tcg/helper-a64.c
28
40
@@ -XXX,XX +XXX,XX @@ illegal_return:
29
+The pvpanic device can be implemented as an ISA device (using IOPORT) or as a
41
*/
30
+PCI device.
42
env->pstate |= PSTATE_IL;
31
+
43
env->pc = new_pc;
32
ISA Interface
44
- spsr &= PSTATE_NZCV | PSTATE_DAIF;
33
-------------
45
- spsr |= pstate_read(env) & ~(PSTATE_NZCV | PSTATE_DAIF);
34
46
+ spsr &= PSTATE_NZCV | PSTATE_DAIF | PSTATE_ALLINT;
35
@@ -XXX,XX +XXX,XX @@ bit 1: a guest panic has happened and will be handled by the guest;
47
+ spsr |= pstate_read(env) & ~(PSTATE_NZCV | PSTATE_DAIF | PSTATE_ALLINT);
36
the host should record it or report it, but should not affect
48
pstate_write(env, spsr);
37
the execution of the guest.
49
if (!arm_singlestep_active(env)) {
38
50
env->pstate &= ~PSTATE_SS;
39
+PCI Interface
40
+-------------
41
+
42
+The PCI interface is similar to the ISA interface except that it uses an MMIO
43
+address space provided by its BAR0, 1 byte long. Any machine with a PCI bus
44
+can enable a pvpanic device by adding '-device pvpanic-pci' to the command
45
+line.
46
+
47
ACPI Interface
48
--------------
49
50
--
51
--
51
2.20.1
52
2.34.1
52
53
diff view generated by jsdifflib
1
From: Joelle van Dyne <j@getutm.app>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
3
Add support for FEAT_NMI. NMI (FEAT_NMI) is an mandatory feature in
4
Signed-off-by: Joelle van Dyne <j@getutm.app>
4
ARMv8.8-A and ARM v9.3-A.
5
Message-id: 20210126012457.39046-9-j@getutm.app
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
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
11
---
8
configure | 5 ++++-
12
target/arm/internals.h | 3 +++
9
1 file changed, 4 insertions(+), 1 deletion(-)
13
1 file changed, 3 insertions(+)
10
14
11
diff --git a/configure b/configure
15
diff --git a/target/arm/internals.h b/target/arm/internals.h
12
index XXXXXXX..XXXXXXX 100755
16
index XXXXXXX..XXXXXXX 100644
13
--- a/configure
17
--- a/target/arm/internals.h
14
+++ b/configure
18
+++ b/target/arm/internals.h
15
@@ -XXX,XX +XXX,XX @@ if test "$cross_compile" = "yes"; then
19
@@ -XXX,XX +XXX,XX @@ static inline uint32_t aarch64_pstate_valid_mask(const ARMISARegisters *id)
16
echo "system = 'darwin'" >> $cross
20
if (isar_feature_aa64_mte(id)) {
17
fi
21
valid |= PSTATE_TCO;
18
case "$ARCH" in
22
}
19
- i386|x86_64)
23
+ if (isar_feature_aa64_nmi(id)) {
20
+ i386)
24
+ valid |= PSTATE_ALLINT;
21
echo "cpu_family = 'x86'" >> $cross
25
+ }
22
;;
26
23
+ x86_64)
27
return valid;
24
+ echo "cpu_family = 'x86_64'" >> $cross
28
}
25
+ ;;
26
ppc64le)
27
echo "cpu_family = 'ppc64'" >> $cross
28
;;
29
--
29
--
30
2.20.1
30
2.34.1
31
32
diff view generated by jsdifflib
1
From: Maxim Uvarov <maxim.uvarov@linaro.org>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
Add secure pl061 for reset/power down machine from
3
Add ALLINT MSR (immediate) to decodetree, in which the CRm is 0b000x. The
4
the secure world (Arm Trusted Firmware). Connect it
4
EL0 check is necessary to ALLINT, and the EL1 check is necessary when
5
with gpio-pwr driver.
5
imm == 1. So implement it inline for EL2/3, or EL1 with imm==0. Avoid the
6
unconditional write to pc and use raise_exception_ra to unwind.
6
7
7
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
8
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
8
Reviewed-by: Andrew Jones <drjones@redhat.com>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
[PMM: Added mention of the new device to the documentation]
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Message-id: 20240407081733.3231820-5-ruanjinjie@huawei.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
13
---
12
docs/system/arm/virt.rst | 2 ++
14
target/arm/tcg/helper-a64.h | 1 +
13
include/hw/arm/virt.h | 2 ++
15
target/arm/tcg/a64.decode | 1 +
14
hw/arm/virt.c | 56 +++++++++++++++++++++++++++++++++++++++-
16
target/arm/tcg/helper-a64.c | 12 ++++++++++++
15
hw/arm/Kconfig | 1 +
17
target/arm/tcg/translate-a64.c | 19 +++++++++++++++++++
16
4 files changed, 60 insertions(+), 1 deletion(-)
18
4 files changed, 33 insertions(+)
17
19
18
diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst
20
diff --git a/target/arm/tcg/helper-a64.h b/target/arm/tcg/helper-a64.h
19
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
20
--- a/docs/system/arm/virt.rst
22
--- a/target/arm/tcg/helper-a64.h
21
+++ b/docs/system/arm/virt.rst
23
+++ b/target/arm/tcg/helper-a64.h
22
@@ -XXX,XX +XXX,XX @@ The virt board supports:
24
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_1(rbit64, TCG_CALL_NO_RWG_SE, i64, i64)
23
- Secure-World-only devices if the CPU has TrustZone:
25
DEF_HELPER_2(msr_i_spsel, void, env, i32)
24
26
DEF_HELPER_2(msr_i_daifset, void, env, i32)
25
- A second PL011 UART
27
DEF_HELPER_2(msr_i_daifclear, void, env, i32)
26
+ - A second PL061 GPIO controller, with GPIO lines for triggering
28
+DEF_HELPER_1(msr_set_allint_el1, void, env)
27
+ a system reset or system poweroff
29
DEF_HELPER_3(vfp_cmph_a64, i64, f16, f16, ptr)
28
- A secure flash memory
30
DEF_HELPER_3(vfp_cmpeh_a64, i64, f16, f16, ptr)
29
- 16MB of secure RAM
31
DEF_HELPER_3(vfp_cmps_a64, i64, f32, f32, ptr)
30
32
diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode
31
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
32
index XXXXXXX..XXXXXXX 100644
33
index XXXXXXX..XXXXXXX 100644
33
--- a/include/hw/arm/virt.h
34
--- a/target/arm/tcg/a64.decode
34
+++ b/include/hw/arm/virt.h
35
+++ b/target/arm/tcg/a64.decode
35
@@ -XXX,XX +XXX,XX @@ enum {
36
@@ -XXX,XX +XXX,XX @@ MSR_i_DIT 1101 0101 0000 0 011 0100 .... 010 11111 @msr_i
36
VIRT_GPIO,
37
MSR_i_TCO 1101 0101 0000 0 011 0100 .... 100 11111 @msr_i
37
VIRT_SECURE_UART,
38
MSR_i_DAIFSET 1101 0101 0000 0 011 0100 .... 110 11111 @msr_i
38
VIRT_SECURE_MEM,
39
MSR_i_DAIFCLEAR 1101 0101 0000 0 011 0100 .... 111 11111 @msr_i
39
+ VIRT_SECURE_GPIO,
40
+MSR_i_ALLINT 1101 0101 0000 0 001 0100 000 imm:1 000 11111
40
VIRT_PCDIMM_ACPI,
41
MSR_i_SVCR 1101 0101 0000 0 011 0100 0 mask:2 imm:1 011 11111
41
VIRT_ACPI_GED,
42
42
VIRT_NVDIMM_ACPI,
43
# MRS, MSR (register), SYS, SYSL. These are all essentially the
43
@@ -XXX,XX +XXX,XX @@ struct VirtMachineClass {
44
diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c
44
bool kvm_no_adjvtime;
45
bool no_kvm_steal_time;
46
bool acpi_expose_flash;
47
+ bool no_secure_gpio;
48
};
49
50
struct VirtMachineState {
51
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
52
index XXXXXXX..XXXXXXX 100644
45
index XXXXXXX..XXXXXXX 100644
53
--- a/hw/arm/virt.c
46
--- a/target/arm/tcg/helper-a64.c
54
+++ b/hw/arm/virt.c
47
+++ b/target/arm/tcg/helper-a64.c
55
@@ -XXX,XX +XXX,XX @@ static const MemMapEntry base_memmap[] = {
48
@@ -XXX,XX +XXX,XX @@ void HELPER(msr_i_spsel)(CPUARMState *env, uint32_t imm)
56
[VIRT_ACPI_GED] = { 0x09080000, ACPI_GED_EVT_SEL_LEN },
49
update_spsel(env, imm);
57
[VIRT_NVDIMM_ACPI] = { 0x09090000, NVDIMM_ACPI_IO_LEN},
58
[VIRT_PVTIME] = { 0x090a0000, 0x00010000 },
59
+ [VIRT_SECURE_GPIO] = { 0x090b0000, 0x00001000 },
60
[VIRT_MMIO] = { 0x0a000000, 0x00000200 },
61
/* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */
62
[VIRT_PLATFORM_BUS] = { 0x0c000000, 0x02000000 },
63
@@ -XXX,XX +XXX,XX @@ static void create_gpio_keys(const VirtMachineState *vms,
64
"gpios", phandle, 3, 0);
65
}
50
}
66
51
67
+#define SECURE_GPIO_POWEROFF 0
52
+void HELPER(msr_set_allint_el1)(CPUARMState *env)
68
+#define SECURE_GPIO_RESET 1
53
+{
54
+ /* ALLINT update to PSTATE. */
55
+ if (arm_hcrx_el2_eff(env) & HCRX_TALLINT) {
56
+ raise_exception_ra(env, EXCP_UDEF,
57
+ syn_aa64_sysregtrap(0, 1, 0, 4, 1, 0x1f, 0), 2,
58
+ GETPC());
59
+ }
69
+
60
+
70
+static void create_secure_gpio_pwr(const VirtMachineState *vms,
61
+ env->pstate |= PSTATE_ALLINT;
71
+ DeviceState *pl061_dev,
72
+ uint32_t phandle)
73
+{
74
+ DeviceState *gpio_pwr_dev;
75
+
76
+ /* gpio-pwr */
77
+ gpio_pwr_dev = sysbus_create_simple("gpio-pwr", -1, NULL);
78
+
79
+ /* connect secure pl061 to gpio-pwr */
80
+ qdev_connect_gpio_out(pl061_dev, SECURE_GPIO_RESET,
81
+ qdev_get_gpio_in_named(gpio_pwr_dev, "reset", 0));
82
+ qdev_connect_gpio_out(pl061_dev, SECURE_GPIO_POWEROFF,
83
+ qdev_get_gpio_in_named(gpio_pwr_dev, "shutdown", 0));
84
+
85
+ qemu_fdt_add_subnode(vms->fdt, "/gpio-poweroff");
86
+ qemu_fdt_setprop_string(vms->fdt, "/gpio-poweroff", "compatible",
87
+ "gpio-poweroff");
88
+ qemu_fdt_setprop_cells(vms->fdt, "/gpio-poweroff",
89
+ "gpios", phandle, SECURE_GPIO_POWEROFF, 0);
90
+ qemu_fdt_setprop_string(vms->fdt, "/gpio-poweroff", "status", "disabled");
91
+ qemu_fdt_setprop_string(vms->fdt, "/gpio-poweroff", "secure-status",
92
+ "okay");
93
+
94
+ qemu_fdt_add_subnode(vms->fdt, "/gpio-restart");
95
+ qemu_fdt_setprop_string(vms->fdt, "/gpio-restart", "compatible",
96
+ "gpio-restart");
97
+ qemu_fdt_setprop_cells(vms->fdt, "/gpio-restart",
98
+ "gpios", phandle, SECURE_GPIO_RESET, 0);
99
+ qemu_fdt_setprop_string(vms->fdt, "/gpio-restart", "status", "disabled");
100
+ qemu_fdt_setprop_string(vms->fdt, "/gpio-restart", "secure-status",
101
+ "okay");
102
+}
62
+}
103
+
63
+
104
static void create_gpio_devices(const VirtMachineState *vms, int gpio,
64
static void daif_check(CPUARMState *env, uint32_t op,
105
MemoryRegion *mem)
65
uint32_t imm, uintptr_t ra)
106
{
66
{
107
@@ -XXX,XX +XXX,XX @@ static void create_gpio_devices(const VirtMachineState *vms, int gpio,
67
diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c
108
qemu_fdt_setprop_string(vms->fdt, nodename, "clock-names", "apb_pclk");
68
index XXXXXXX..XXXXXXX 100644
109
qemu_fdt_setprop_cell(vms->fdt, nodename, "phandle", phandle);
69
--- a/target/arm/tcg/translate-a64.c
110
70
+++ b/target/arm/tcg/translate-a64.c
111
+ if (gpio != VIRT_GPIO) {
71
@@ -XXX,XX +XXX,XX @@ static bool trans_MSR_i_DAIFCLEAR(DisasContext *s, arg_i *a)
112
+ /* Mark as not usable by the normal world */
72
return true;
113
+ qemu_fdt_setprop_string(vms->fdt, nodename, "status", "disabled");
114
+ qemu_fdt_setprop_string(vms->fdt, nodename, "secure-status", "okay");
115
+ }
116
g_free(nodename);
117
118
/* Child gpio devices */
119
- create_gpio_keys(vms, pl061_dev, phandle);
120
+ if (gpio == VIRT_GPIO) {
121
+ create_gpio_keys(vms, pl061_dev, phandle);
122
+ } else {
123
+ create_secure_gpio_pwr(vms, pl061_dev, phandle);
124
+ }
125
}
73
}
126
74
127
static void create_virtio_devices(const VirtMachineState *vms)
75
+static bool trans_MSR_i_ALLINT(DisasContext *s, arg_i *a)
128
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
76
+{
129
create_gpio_devices(vms, VIRT_GPIO, sysmem);
77
+ if (!dc_isar_feature(aa64_nmi, s) || s->current_el == 0) {
130
}
78
+ return false;
131
132
+ if (vms->secure && !vmc->no_secure_gpio) {
133
+ create_gpio_devices(vms, VIRT_SECURE_GPIO, secure_sysmem);
134
+ }
79
+ }
135
+
80
+
136
/* connect powerdown request */
81
+ if (a->imm == 0) {
137
vms->powerdown_notifier.notify = virt_powerdown_req;
82
+ clear_pstate_bits(PSTATE_ALLINT);
138
qemu_register_powerdown_notifier(&vms->powerdown_notifier);
83
+ } else if (s->current_el > 1) {
139
@@ -XXX,XX +XXX,XX @@ DEFINE_VIRT_MACHINE_AS_LATEST(6, 0)
84
+ set_pstate_bits(PSTATE_ALLINT);
140
85
+ } else {
141
static void virt_machine_5_2_options(MachineClass *mc)
86
+ gen_helper_msr_set_allint_el1(tcg_env);
87
+ }
88
+
89
+ /* Exit the cpu loop to re-evaluate pending IRQs. */
90
+ s->base.is_jmp = DISAS_UPDATE_EXIT;
91
+ return true;
92
+}
93
+
94
static bool trans_MSR_i_SVCR(DisasContext *s, arg_MSR_i_SVCR *a)
142
{
95
{
143
+ VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
96
if (!dc_isar_feature(aa64_sme, s) || a->mask == 0) {
144
+
145
virt_machine_6_0_options(mc);
146
compat_props_add(mc->compat_props, hw_compat_5_2, hw_compat_5_2_len);
147
+ vmc->no_secure_gpio = true;
148
}
149
DEFINE_VIRT_MACHINE(5, 2)
150
151
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
152
index XXXXXXX..XXXXXXX 100644
153
--- a/hw/arm/Kconfig
154
+++ b/hw/arm/Kconfig
155
@@ -XXX,XX +XXX,XX @@ config ARM_VIRT
156
select PL011 # UART
157
select PL031 # RTC
158
select PL061 # GPIO
159
+ select GPIO_PWR
160
select PLATFORM_BUS
161
select SMBIOS
162
select VIRTIO_MMIO
163
--
97
--
164
2.20.1
98
2.34.1
165
166
diff view generated by jsdifflib
1
From: Maxim Uvarov <maxim.uvarov@linaro.org>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
Implement gpio-pwr driver to allow reboot and poweroff machine.
3
Support ALLINT msr access as follow:
4
This is simple driver with just 2 gpios lines. Current use case
4
    mrs <xt>, ALLINT    // read allint
5
is to reboot and poweroff virt machine in secure mode. Secure
5
    msr ALLINT, <xt>    // write allint with imm
6
pl066 gpio chip is needed for that.
7
6
8
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
7
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
9
Reviewed-by: Hao Wu <wuhaotsh@google.com>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 20240407081733.3231820-6-ruanjinjie@huawei.com
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
12
---
13
hw/gpio/gpio_pwr.c | 70 +++++++++++++++++++++++++++++++++++++++++++++
13
target/arm/helper.c | 35 +++++++++++++++++++++++++++++++++++
14
hw/gpio/Kconfig | 3 ++
14
1 file changed, 35 insertions(+)
15
hw/gpio/meson.build | 1 +
16
3 files changed, 74 insertions(+)
17
create mode 100644 hw/gpio/gpio_pwr.c
18
15
19
diff --git a/hw/gpio/gpio_pwr.c b/hw/gpio/gpio_pwr.c
16
diff --git a/target/arm/helper.c b/target/arm/helper.c
20
new file mode 100644
17
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX
18
--- a/target/arm/helper.c
22
--- /dev/null
19
+++ b/target/arm/helper.c
23
+++ b/hw/gpio/gpio_pwr.c
20
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo rme_mte_reginfo[] = {
24
@@ -XXX,XX +XXX,XX @@
21
.opc0 = 1, .opc1 = 6, .crn = 7, .crm = 14, .opc2 = 5,
25
+/*
22
.access = PL3_W, .type = ARM_CP_NOP },
26
+ * GPIO qemu power controller
23
};
27
+ *
28
+ * Copyright (c) 2020 Linaro Limited
29
+ *
30
+ * Author: Maxim Uvarov <maxim.uvarov@linaro.org>
31
+ *
32
+ * Virtual gpio driver which can be used on top of pl061
33
+ * to reboot and shutdown qemu virtual machine. One of use
34
+ * case is gpio driver for secure world application (ARM
35
+ * Trusted Firmware.).
36
+ *
37
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
38
+ * See the COPYING file in the top-level directory.
39
+ * SPDX-License-Identifier: GPL-2.0-or-later
40
+ */
41
+
24
+
42
+/*
25
+static void aa64_allint_write(CPUARMState *env, const ARMCPRegInfo *ri,
43
+ * QEMU interface:
26
+ uint64_t value)
44
+ * two named input GPIO lines:
45
+ * 'reset' : when asserted, trigger system reset
46
+ * 'shutdown' : when asserted, trigger system shutdown
47
+ */
48
+
49
+#include "qemu/osdep.h"
50
+#include "hw/sysbus.h"
51
+#include "sysemu/runstate.h"
52
+
53
+#define TYPE_GPIOPWR "gpio-pwr"
54
+OBJECT_DECLARE_SIMPLE_TYPE(GPIO_PWR_State, GPIOPWR)
55
+
56
+struct GPIO_PWR_State {
57
+ SysBusDevice parent_obj;
58
+};
59
+
60
+static void gpio_pwr_reset(void *opaque, int n, int level)
61
+{
27
+{
62
+ if (level) {
28
+ env->pstate = (env->pstate & ~PSTATE_ALLINT) | (value & PSTATE_ALLINT);
63
+ qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
64
+ }
65
+}
29
+}
66
+
30
+
67
+static void gpio_pwr_shutdown(void *opaque, int n, int level)
31
+static uint64_t aa64_allint_read(CPUARMState *env, const ARMCPRegInfo *ri)
68
+{
32
+{
69
+ if (level) {
33
+ return env->pstate & PSTATE_ALLINT;
70
+ qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
71
+ }
72
+}
34
+}
73
+
35
+
74
+static void gpio_pwr_init(Object *obj)
36
+static CPAccessResult aa64_allint_access(CPUARMState *env,
37
+ const ARMCPRegInfo *ri, bool isread)
75
+{
38
+{
76
+ DeviceState *dev = DEVICE(obj);
39
+ if (!isread && arm_current_el(env) == 1 &&
77
+
40
+ (arm_hcrx_el2_eff(env) & HCRX_TALLINT)) {
78
+ qdev_init_gpio_in_named(dev, gpio_pwr_reset, "reset", 1);
41
+ return CP_ACCESS_TRAP_EL2;
79
+ qdev_init_gpio_in_named(dev, gpio_pwr_shutdown, "shutdown", 1);
42
+ }
43
+ return CP_ACCESS_OK;
80
+}
44
+}
81
+
45
+
82
+static const TypeInfo gpio_pwr_info = {
46
+static const ARMCPRegInfo nmi_reginfo[] = {
83
+ .name = TYPE_GPIOPWR,
47
+ { .name = "ALLINT", .state = ARM_CP_STATE_AA64,
84
+ .parent = TYPE_SYS_BUS_DEVICE,
48
+ .opc0 = 3, .opc1 = 0, .opc2 = 0, .crn = 4, .crm = 3,
85
+ .instance_size = sizeof(GPIO_PWR_State),
49
+ .type = ARM_CP_NO_RAW,
86
+ .instance_init = gpio_pwr_init,
50
+ .access = PL1_RW, .accessfn = aa64_allint_access,
51
+ .fieldoffset = offsetof(CPUARMState, pstate),
52
+ .writefn = aa64_allint_write, .readfn = aa64_allint_read,
53
+ .resetfn = arm_cp_reset_ignore },
87
+};
54
+};
55
#endif /* TARGET_AARCH64 */
56
57
static void define_pmu_regs(ARMCPU *cpu)
58
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
59
if (cpu_isar_feature(aa64_nv2, cpu)) {
60
define_arm_cp_regs(cpu, nv2_reginfo);
61
}
88
+
62
+
89
+static void gpio_pwr_register_types(void)
63
+ if (cpu_isar_feature(aa64_nmi, cpu)) {
90
+{
64
+ define_arm_cp_regs(cpu, nmi_reginfo);
91
+ type_register_static(&gpio_pwr_info);
65
+ }
92
+}
66
#endif
93
+
67
94
+type_init(gpio_pwr_register_types)
68
if (cpu_isar_feature(any_predinv, cpu)) {
95
diff --git a/hw/gpio/Kconfig b/hw/gpio/Kconfig
96
index XXXXXXX..XXXXXXX 100644
97
--- a/hw/gpio/Kconfig
98
+++ b/hw/gpio/Kconfig
99
@@ -XXX,XX +XXX,XX @@ config PL061
100
config GPIO_KEY
101
bool
102
103
+config GPIO_PWR
104
+ bool
105
+
106
config SIFIVE_GPIO
107
bool
108
diff --git a/hw/gpio/meson.build b/hw/gpio/meson.build
109
index XXXXXXX..XXXXXXX 100644
110
--- a/hw/gpio/meson.build
111
+++ b/hw/gpio/meson.build
112
@@ -XXX,XX +XXX,XX @@
113
softmmu_ss.add(when: 'CONFIG_E500', if_true: files('mpc8xxx.c'))
114
softmmu_ss.add(when: 'CONFIG_GPIO_KEY', if_true: files('gpio_key.c'))
115
+softmmu_ss.add(when: 'CONFIG_GPIO_PWR', if_true: files('gpio_pwr.c'))
116
softmmu_ss.add(when: 'CONFIG_MAX7310', if_true: files('max7310.c'))
117
softmmu_ss.add(when: 'CONFIG_PL061', if_true: files('pl061.c'))
118
softmmu_ss.add(when: 'CONFIG_PUV3', if_true: files('puv3_gpio.c'))
119
--
69
--
120
2.20.1
70
2.34.1
121
122
diff view generated by jsdifflib
1
The ptimer API currently provides two methods for setting the period:
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
ptimer_set_period(), which takes a period in nanoseconds, and
3
ptimer_set_freq(), which takes a frequency in Hz. Neither of these
4
lines up nicely with the Clock API, because although both the Clock
5
and the ptimer track the frequency using a representation of whole
6
and fractional nanoseconds, conversion via either period-in-ns or
7
frequency-in-Hz will introduce a rounding error.
8
2
9
Add a new function ptimer_set_period_from_clock() which takes the
3
This only implements the external delivery method via the GICv3.
10
Clock object directly to avoid the rounding issues. This includes a
11
facility for the user to specify that there is a frequency divider
12
between the Clock proper and the timer, as some timer devices like
13
the CMSDK APB dualtimer need this.
14
4
15
To avoid having to drag in clock.h from ptimer.h we add the Clock
5
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
16
type to typedefs.h.
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20240407081733.3231820-7-ruanjinjie@huawei.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/cpu-qom.h | 5 +-
12
target/arm/cpu.h | 6 ++
13
target/arm/internals.h | 18 +++++
14
target/arm/cpu.c | 147 ++++++++++++++++++++++++++++++++++++++---
15
target/arm/helper.c | 33 +++++++--
16
5 files changed, 193 insertions(+), 16 deletions(-)
17
17
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h
19
Reviewed-by: Luc Michel <luc@lmichel.fr>
20
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
21
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
22
Message-id: 20210128114145.20536-2-peter.maydell@linaro.org
23
Message-id: 20210121190622.22000-2-peter.maydell@linaro.org
24
---
25
include/hw/ptimer.h | 22 ++++++++++++++++++++++
26
include/qemu/typedefs.h | 1 +
27
hw/core/ptimer.c | 34 ++++++++++++++++++++++++++++++++++
28
3 files changed, 57 insertions(+)
29
30
diff --git a/include/hw/ptimer.h b/include/hw/ptimer.h
31
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
32
--- a/include/hw/ptimer.h
20
--- a/target/arm/cpu-qom.h
33
+++ b/include/hw/ptimer.h
21
+++ b/target/arm/cpu-qom.h
34
@@ -XXX,XX +XXX,XX @@ void ptimer_transaction_commit(ptimer_state *s);
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
38
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
39
index XXXXXXX..XXXXXXX 100644
40
--- a/target/arm/cpu.h
41
+++ b/target/arm/cpu.h
42
@@ -XXX,XX +XXX,XX @@
43
#define EXCP_DIVBYZERO 23 /* v7M DIVBYZERO UsageFault */
44
#define EXCP_VSERR 24
45
#define EXCP_GPC 25 /* v9 Granule Protection Check Fault */
46
+#define EXCP_NMI 26
47
+#define EXCP_VINMI 27
48
+#define EXCP_VFNMI 28
49
/* NB: add new EXCP_ defines to the array in arm_log_exception() too */
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
62
diff --git a/target/arm/internals.h b/target/arm/internals.h
63
index XXXXXXX..XXXXXXX 100644
64
--- a/target/arm/internals.h
65
+++ b/target/arm/internals.h
66
@@ -XXX,XX +XXX,XX @@ void arm_cpu_update_virq(ARMCPU *cpu);
35
*/
67
*/
36
void ptimer_set_period(ptimer_state *s, int64_t period);
68
void arm_cpu_update_vfiq(ARMCPU *cpu);
37
69
38
+/**
70
+/**
39
+ * ptimer_set_period_from_clock - Set counter increment from a Clock
71
+ * arm_cpu_update_vinmi: Update CPU_INTERRUPT_VINMI bit in cs->interrupt_request
40
+ * @s: ptimer to configure
41
+ * @clk: pointer to Clock object to take period from
42
+ * @divisor: value to scale the clock frequency down by
43
+ *
72
+ *
44
+ * If the ptimer is being driven from a Clock, this is the preferred
73
+ * Update the CPU_INTERRUPT_VINMI bit in cs->interrupt_request, following
45
+ * way to tell the ptimer about the period, because it avoids any
74
+ * a change to either the input VNMI line from the GIC or the HCRX_EL2.VINMI.
46
+ * possible rounding errors that might happen if the internal
75
+ * Must be called with the BQL held.
47
+ * representation of the Clock period was converted to either a period
76
+ */
48
+ * in ns or a frequency in Hz.
77
+void arm_cpu_update_vinmi(ARMCPU *cpu);
78
+
79
+/**
80
+ * arm_cpu_update_vfnmi: Update CPU_INTERRUPT_VFNMI bit in cs->interrupt_request
49
+ *
81
+ *
50
+ * If the ptimer should run at the same frequency as the clock,
82
+ * Update the CPU_INTERRUPT_VFNMI bit in cs->interrupt_request, following
51
+ * pass 1 as the @divisor; if the ptimer should run at half the
83
+ * a change to the HCRX_EL2.VFNMI.
52
+ * frequency, pass 2, and so on.
84
+ * Must be called with the BQL held.
53
+ *
54
+ * This function will assert if it is called outside a
55
+ * ptimer_transaction_begin/commit block.
56
+ */
85
+ */
57
+void ptimer_set_period_from_clock(ptimer_state *s, const Clock *clock,
86
+void arm_cpu_update_vfnmi(ARMCPU *cpu);
58
+ unsigned int divisor);
59
+
87
+
60
/**
88
/**
61
* ptimer_set_freq - Set counter frequency in Hz
89
* arm_cpu_update_vserr: Update CPU_INTERRUPT_VSERR bit
62
* @s: ptimer to configure
90
*
63
diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
91
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
64
index XXXXXXX..XXXXXXX 100644
92
index XXXXXXX..XXXXXXX 100644
65
--- a/include/qemu/typedefs.h
93
--- a/target/arm/cpu.c
66
+++ b/include/qemu/typedefs.h
94
+++ b/target/arm/cpu.c
67
@@ -XXX,XX +XXX,XX @@ typedef struct BlockDriverState BlockDriverState;
95
@@ -XXX,XX +XXX,XX @@ void arm_restore_state_to_opc(CPUState *cs,
68
typedef struct BusClass BusClass;
96
}
69
typedef struct BusState BusState;
97
#endif /* CONFIG_TCG */
70
typedef struct Chardev Chardev;
98
71
+typedef struct Clock Clock;
99
+/*
72
typedef struct CompatProperty CompatProperty;
100
+ * With SCTLR_ELx.NMI == 0, IRQ with Superpriority is masked identically with
73
typedef struct CoMutex CoMutex;
101
+ * IRQ without Superpriority. Moreover, if the GIC is configured so that
74
typedef struct CPUAddressSpace CPUAddressSpace;
102
+ * FEAT_GICv3_NMI is only set if FEAT_NMI is set, then we won't ever see
75
diff --git a/hw/core/ptimer.c b/hw/core/ptimer.c
103
+ * CPU_INTERRUPT_*NMI anyway. So we might as well accept NMI here
76
index XXXXXXX..XXXXXXX 100644
104
+ * unconditionally.
77
--- a/hw/core/ptimer.c
105
+ */
78
+++ b/hw/core/ptimer.c
106
static bool arm_cpu_has_work(CPUState *cs)
79
@@ -XXX,XX +XXX,XX @@
107
{
80
#include "sysemu/qtest.h"
108
ARMCPU *cpu = ARM_CPU(cs);
81
#include "block/aio.h"
109
@@ -XXX,XX +XXX,XX @@ static bool arm_cpu_has_work(CPUState *cs)
82
#include "sysemu/cpus.h"
110
return (cpu->power_state != PSCI_OFF)
83
+#include "hw/clock.h"
111
&& cs->interrupt_request &
84
112
(CPU_INTERRUPT_FIQ | CPU_INTERRUPT_HARD
85
#define DELTA_ADJUST 1
113
+ | CPU_INTERRUPT_NMI | CPU_INTERRUPT_VINMI | CPU_INTERRUPT_VFNMI
86
#define DELTA_NO_ADJUST -1
114
| CPU_INTERRUPT_VFIQ | CPU_INTERRUPT_VIRQ | CPU_INTERRUPT_VSERR
87
@@ -XXX,XX +XXX,XX @@ void ptimer_set_period(ptimer_state *s, int64_t period)
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)
88
}
250
}
89
}
251
}
90
252
91
+/* Set counter increment interval from a Clock */
253
+void arm_cpu_update_vinmi(ARMCPU *cpu)
92
+void ptimer_set_period_from_clock(ptimer_state *s, const Clock *clk,
93
+ unsigned int divisor)
94
+{
254
+{
95
+ /*
255
+ /*
96
+ * The raw clock period is a 64-bit value in units of 2^-32 ns;
256
+ * Update the interrupt level for VINMI, which is the logical OR of
97
+ * put another way it's a 32.32 fixed-point ns value. Our internal
257
+ * the HCRX_EL2.VINMI bit and the input line level from the GIC.
98
+ * representation of the period is 64.32 fixed point ns, so
99
+ * the conversion is simple.
100
+ */
258
+ */
101
+ uint64_t raw_period = clock_get(clk);
259
+ CPUARMState *env = &cpu->env;
102
+ uint64_t period_frac;
260
+ CPUState *cs = CPU(cpu);
103
+
261
+
104
+ assert(s->in_transaction);
262
+ bool new_state = ((arm_hcr_el2_eff(env) & HCR_VI) &&
105
+ s->delta = ptimer_get_count(s);
263
+ (arm_hcrx_el2_eff(env) & HCRX_VINMI)) ||
106
+ s->period = extract64(raw_period, 32, 32);
264
+ (env->irq_line_state & CPU_INTERRUPT_VINMI);
107
+ period_frac = extract64(raw_period, 0, 32);
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
+{
108
+ /*
277
+ /*
109
+ * divisor specifies a possible frequency divisor between the
278
+ * Update the interrupt level for VFNMI, which is the HCRX_EL2.VFNMI bit.
110
+ * clock and the timer, so it is a multiplier on the period.
111
+ * We do the multiply after splitting the raw period out into
112
+ * period and frac to avoid having to do a 32*64->96 multiply.
113
+ */
279
+ */
114
+ s->period *= divisor;
280
+ CPUARMState *env = &cpu->env;
115
+ period_frac *= divisor;
281
+ CPUState *cs = CPU(cpu);
116
+ s->period += extract64(period_frac, 32, 32);
282
+
117
+ s->period_frac = (uint32_t)period_frac;
283
+ bool new_state = (arm_hcr_el2_eff(env) & HCR_VF) &&
118
+
284
+ (arm_hcrx_el2_eff(env) & HCRX_VFNMI);
119
+ if (s->enabled) {
285
+
120
+ s->need_reload = true;
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
+ }
121
+ }
292
+ }
122
+}
293
+}
123
+
294
+
124
/* Set counter frequency in Hz. */
295
void arm_cpu_update_vserr(ARMCPU *cpu)
125
void ptimer_set_freq(ptimer_state *s, uint32_t freq)
126
{
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,
340
diff --git a/target/arm/helper.c b/target/arm/helper.c
341
index XXXXXXX..XXXXXXX 100644
342
--- a/target/arm/helper.c
343
+++ b/target/arm/helper.c
344
@@ -XXX,XX +XXX,XX @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask)
345
* and the state of the input lines from the GIC. (This requires
346
* that we have the BQL, which is done by marking the
347
* reginfo structs as ARM_CP_IO.)
348
- * Note that if a write to HCR pends a VIRQ or VFIQ it is never
349
- * possible for it to be taken immediately, because VIRQ and
350
- * VFIQ are masked unless running at EL0 or EL1, and HCR
351
- * can only be written at EL2.
352
+ * Note that if a write to HCR pends a VIRQ or VFIQ or VINMI or
353
+ * VFNMI, it is never possible for it to be taken immediately
354
+ * because VIRQ, VFIQ, VINMI and VFNMI are masked unless running
355
+ * at EL0 or EL1, and HCR can only be written at EL2.
356
*/
357
g_assert(bql_locked());
358
arm_cpu_update_virq(cpu);
359
arm_cpu_update_vfiq(cpu);
360
arm_cpu_update_vserr(cpu);
361
+ if (cpu_isar_feature(aa64_nmi, cpu)) {
362
+ arm_cpu_update_vinmi(cpu);
363
+ arm_cpu_update_vfnmi(cpu);
364
+ }
365
}
366
367
static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
368
@@ -XXX,XX +XXX,XX @@ static void hcrx_write(CPUARMState *env, const ARMCPRegInfo *ri,
369
370
/* Clear RES0 bits. */
371
env->cp15.hcrx_el2 = value & valid_mask;
372
+
373
+ /*
374
+ * Updates to VINMI and VFNMI require us to update the status of
375
+ * virtual NMI, which are the logical OR of these bits
376
+ * and the state of the input lines from the GIC. (This requires
377
+ * that we have the BQL, which is done by marking the
378
+ * reginfo structs as ARM_CP_IO.)
379
+ * Note that if a write to HCRX pends a VINMI or VFNMI it is never
380
+ * possible for it to be taken immediately, because VINMI and
381
+ * VFNMI are masked unless running at EL0 or EL1, and HCRX
382
+ * can only be written at EL2.
383
+ */
384
+ if (cpu_isar_feature(aa64_nmi, cpu)) {
385
+ g_assert(bql_locked());
386
+ arm_cpu_update_vinmi(cpu);
387
+ arm_cpu_update_vfnmi(cpu);
388
+ }
389
}
390
391
static CPAccessResult access_hxen(CPUARMState *env, const ARMCPRegInfo *ri,
392
@@ -XXX,XX +XXX,XX @@ static CPAccessResult access_hxen(CPUARMState *env, const ARMCPRegInfo *ri,
393
394
static const ARMCPRegInfo hcrx_el2_reginfo = {
395
.name = "HCRX_EL2", .state = ARM_CP_STATE_AA64,
396
+ .type = ARM_CP_IO,
397
.opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 2,
398
.access = PL2_RW, .writefn = hcrx_write, .accessfn = access_hxen,
399
.nv2_redirect_offset = 0xa0,
400
@@ -XXX,XX +XXX,XX @@ void arm_log_exception(CPUState *cs)
401
[EXCP_DIVBYZERO] = "v7M DIVBYZERO UsageFault",
402
[EXCP_VSERR] = "Virtual SERR",
403
[EXCP_GPC] = "Granule Protection Check",
404
+ [EXCP_NMI] = "NMI",
405
+ [EXCP_VINMI] = "Virtual IRQ NMI",
406
+ [EXCP_VFNMI] = "Virtual FIQ NMI",
407
};
408
409
if (idx >= 0 && idx < ARRAY_SIZE(excnames)) {
127
--
410
--
128
2.20.1
411
2.34.1
129
130
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
cpu_get_phys_page_debug() uses 'DATA LOAD' MMU access type.
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().
4
6
5
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
6
Message-id: 20210127232822.3530782-1-f4bug@amsat.org
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 20240407081733.3231820-8-ruanjinjie@huawei.com
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
12
---
10
target/arm/helper.c | 2 +-
13
target/arm/helper.c | 1 +
11
1 file changed, 1 insertion(+), 1 deletion(-)
14
1 file changed, 1 insertion(+)
12
15
13
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
14
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
18
--- a/target/arm/helper.c
16
+++ b/target/arm/helper.c
19
+++ b/target/arm/helper.c
17
@@ -XXX,XX +XXX,XX @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr,
20
@@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx,
18
21
hcr_el2 = arm_hcr_el2_eff(env);
19
*attrs = (MemTxAttrs) {};
22
switch (excp_idx) {
20
23
case EXCP_IRQ:
21
- ret = get_phys_addr(env, addr, 0, mmu_idx, &phys_addr,
24
+ case EXCP_NMI:
22
+ ret = get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &phys_addr,
25
scr = ((env->cp15.scr_el3 & SCR_IRQ) == SCR_IRQ);
23
attrs, &prot, &page_size, &fi, &cacheattrs);
26
hcr = hcr_el2 & HCR_IMO;
24
27
break;
25
if (ret) {
26
--
28
--
27
2.20.1
29
2.34.1
28
29
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
This was defined at some point before ARMv8.4, and will
3
Add IS and FS bit in ISR_EL1 and handle the read. With CPU_INTERRUPT_NMI or
4
shortly be used by new processor descriptions.
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.
5
6
7
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20240407081733.3231820-9-ruanjinjie@huawei.com
8
Message-id: 20210120204400.1056582-1-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 | 1 +
13
target/arm/cpu.h | 2 ++
12
target/arm/helper.c | 4 ++--
14
target/arm/helper.c | 13 +++++++++++++
13
target/arm/kvm64.c | 2 ++
15
2 files changed, 15 insertions(+)
14
3 files changed, 5 insertions(+), 2 deletions(-)
15
16
16
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
17
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/cpu.h
19
--- a/target/arm/cpu.h
19
+++ b/target/arm/cpu.h
20
+++ b/target/arm/cpu.h
20
@@ -XXX,XX +XXX,XX @@ struct ARMCPU {
21
@@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu);
21
uint32_t id_mmfr4;
22
#define CPSR_N (1U << 31)
22
uint32_t id_pfr0;
23
#define CPSR_NZCV (CPSR_N | CPSR_Z | CPSR_C | CPSR_V)
23
uint32_t id_pfr1;
24
#define CPSR_AIF (CPSR_A | CPSR_I | CPSR_F)
24
+ uint32_t id_pfr2;
25
+#define ISR_FS (1U << 9)
25
uint32_t mvfr0;
26
+#define ISR_IS (1U << 10)
26
uint32_t mvfr1;
27
27
uint32_t mvfr2;
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 \
28
diff --git a/target/arm/helper.c b/target/arm/helper.c
30
diff --git a/target/arm/helper.c b/target/arm/helper.c
29
index XXXXXXX..XXXXXXX 100644
31
index XXXXXXX..XXXXXXX 100644
30
--- a/target/arm/helper.c
32
--- a/target/arm/helper.c
31
+++ b/target/arm/helper.c
33
+++ b/target/arm/helper.c
32
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
34
@@ -XXX,XX +XXX,XX @@ static uint64_t isr_read(CPUARMState *env, const ARMCPRegInfo *ri)
33
.access = PL1_R, .type = ARM_CP_CONST,
35
if (cs->interrupt_request & CPU_INTERRUPT_VIRQ) {
34
.accessfn = access_aa64_tid3,
36
ret |= CPSR_I;
35
.resetvalue = 0 },
37
}
36
- { .name = "MVFR4_EL1_RESERVED", .state = ARM_CP_STATE_AA64,
38
+ if (cs->interrupt_request & CPU_INTERRUPT_VINMI) {
37
+ { .name = "ID_PFR2", .state = ARM_CP_STATE_BOTH,
39
+ ret |= ISR_IS;
38
.opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 4,
40
+ ret |= CPSR_I;
39
.access = PL1_R, .type = ARM_CP_CONST,
41
+ }
40
.accessfn = access_aa64_tid3,
42
} else {
41
- .resetvalue = 0 },
43
if (cs->interrupt_request & CPU_INTERRUPT_HARD) {
42
+ .resetvalue = cpu->isar.id_pfr2 },
44
ret |= CPSR_I;
43
{ .name = "MVFR5_EL1_RESERVED", .state = ARM_CP_STATE_AA64,
45
}
44
.opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 5,
46
+
45
.access = PL1_R, .type = ARM_CP_CONST,
47
+ if (cs->interrupt_request & CPU_INTERRUPT_NMI) {
46
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
48
+ ret |= ISR_IS;
47
index XXXXXXX..XXXXXXX 100644
49
+ ret |= CPSR_I;
48
--- a/target/arm/kvm64.c
50
+ }
49
+++ b/target/arm/kvm64.c
51
}
50
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
52
51
ARM64_SYS_REG(3, 0, 0, 1, 0));
53
if (hcr_el2 & HCR_FMO) {
52
err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr1,
54
if (cs->interrupt_request & CPU_INTERRUPT_VFIQ) {
53
ARM64_SYS_REG(3, 0, 0, 1, 1));
55
ret |= CPSR_F;
54
+ err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr2,
56
}
55
+ ARM64_SYS_REG(3, 0, 0, 3, 4));
57
+ if (cs->interrupt_request & CPU_INTERRUPT_VFNMI) {
56
err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_dfr0,
58
+ ret |= ISR_FS;
57
ARM64_SYS_REG(3, 0, 0, 1, 2));
59
+ ret |= CPSR_F;
58
err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr0,
60
+ }
61
} else {
62
if (cs->interrupt_request & CPU_INTERRUPT_FIQ) {
63
ret |= CPSR_F;
59
--
64
--
60
2.20.1
65
2.34.1
61
62
diff view generated by jsdifflib
1
Create and connect the Clock input for the watchdog device on the
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
Stellaris boards. Because the Stellaris boards model the ability to
3
change the clock rate by programming PLL registers, we have to create
4
an output Clock on the ssys_state device and wire it up to the
5
watchdog.
6
2
7
Note that the old comment on ssys_calculate_system_clock() got the
3
Set or clear PSTATE.ALLINT on taking an exception to ELx according to the
8
units wrong -- system_clock_scale is in nanoseconds, not
4
SCTLR_ELx.SPINTMASK bit.
9
milliseconds. Improve the commentary to clarify how we are
10
calculating the period.
11
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
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Luc Michel <luc@lmichel.fr>
14
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
16
Message-id: 20210128114145.20536-18-peter.maydell@linaro.org
17
Message-id: 20210121190622.22000-18-peter.maydell@linaro.org
18
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
19
---
11
---
20
hw/arm/stellaris.c | 43 +++++++++++++++++++++++++++++++------------
12
target/arm/helper.c | 8 ++++++++
21
1 file changed, 31 insertions(+), 12 deletions(-)
13
1 file changed, 8 insertions(+)
22
14
23
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
15
diff --git a/target/arm/helper.c b/target/arm/helper.c
24
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
25
--- a/hw/arm/stellaris.c
17
--- a/target/arm/helper.c
26
+++ b/hw/arm/stellaris.c
18
+++ b/target/arm/helper.c
27
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs)
28
#include "hw/watchdog/cmsdk-apb-watchdog.h"
29
#include "migration/vmstate.h"
30
#include "hw/misc/unimp.h"
31
+#include "hw/qdev-clock.h"
32
#include "cpu.h"
33
#include "qom/object.h"
34
35
@@ -XXX,XX +XXX,XX @@ struct ssys_state {
36
uint32_t clkvclr;
37
uint32_t ldoarst;
38
qemu_irq irq;
39
+ Clock *sysclk;
40
/* Properties (all read-only registers) */
41
uint32_t user0;
42
uint32_t user1;
43
@@ -XXX,XX +XXX,XX @@ static bool ssys_use_rcc2(ssys_state *s)
44
}
45
46
/*
47
- * Caculate the sys. clock period in ms.
48
+ * Calculate the system clock period. We only want to propagate
49
+ * this change to the rest of the system if we're not being called
50
+ * from migration post-load.
51
*/
52
-static void ssys_calculate_system_clock(ssys_state *s)
53
+static void ssys_calculate_system_clock(ssys_state *s, bool propagate_clock)
54
{
55
+ /*
56
+ * SYSDIV field specifies divisor: 0 == /1, 1 == /2, etc. Input
57
+ * clock is 200MHz, which is a period of 5 ns. Dividing the clock
58
+ * frequency by X is the same as multiplying the period by X.
59
+ */
60
if (ssys_use_rcc2(s)) {
61
system_clock_scale = 5 * (((s->rcc2 >> 23) & 0x3f) + 1);
62
} else {
63
system_clock_scale = 5 * (((s->rcc >> 23) & 0xf) + 1);
64
}
65
+ clock_set_ns(s->sysclk, system_clock_scale);
66
+ if (propagate_clock) {
67
+ clock_propagate(s->sysclk);
68
+ }
69
}
70
71
static void ssys_write(void *opaque, hwaddr offset,
72
@@ -XXX,XX +XXX,XX @@ static void ssys_write(void *opaque, hwaddr offset,
73
s->int_status |= (1 << 6);
74
}
75
s->rcc = value;
76
- ssys_calculate_system_clock(s);
77
+ ssys_calculate_system_clock(s, true);
78
break;
79
case 0x070: /* RCC2 */
80
if (ssys_board_class(s) == DID0_CLASS_SANDSTORM) {
81
@@ -XXX,XX +XXX,XX @@ static void ssys_write(void *opaque, hwaddr offset,
82
s->int_status |= (1 << 6);
83
}
84
s->rcc2 = value;
85
- ssys_calculate_system_clock(s);
86
+ ssys_calculate_system_clock(s, true);
87
break;
88
case 0x100: /* RCGC0 */
89
s->rcgc[0] = value;
90
@@ -XXX,XX +XXX,XX @@ static void stellaris_sys_reset_hold(Object *obj)
91
{
92
ssys_state *s = STELLARIS_SYS(obj);
93
94
- ssys_calculate_system_clock(s);
95
+ /* OK to propagate clocks from the hold phase */
96
+ ssys_calculate_system_clock(s, true);
97
}
98
99
static void stellaris_sys_reset_exit(Object *obj)
100
@@ -XXX,XX +XXX,XX @@ static int stellaris_sys_post_load(void *opaque, int version_id)
101
{
102
ssys_state *s = opaque;
103
104
- ssys_calculate_system_clock(s);
105
+ ssys_calculate_system_clock(s, false);
106
107
return 0;
108
}
109
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_stellaris_sys = {
110
VMSTATE_UINT32_ARRAY(dcgc, ssys_state, 3),
111
VMSTATE_UINT32(clkvclr, ssys_state),
112
VMSTATE_UINT32(ldoarst, ssys_state),
113
+ /* No field for sysclk -- handled in post-load instead */
114
VMSTATE_END_OF_LIST()
115
}
116
};
117
@@ -XXX,XX +XXX,XX @@ static void stellaris_sys_instance_init(Object *obj)
118
memory_region_init_io(&s->iomem, obj, &ssys_ops, s, "ssys", 0x00001000);
119
sysbus_init_mmio(sbd, &s->iomem);
120
sysbus_init_irq(sbd, &s->irq);
121
+ s->sysclk = qdev_init_clock_out(DEVICE(s), "SYSCLK");
122
}
123
124
-static int stellaris_sys_init(uint32_t base, qemu_irq irq,
125
- stellaris_board_info * board,
126
- uint8_t *macaddr)
127
+static DeviceState *stellaris_sys_init(uint32_t base, qemu_irq irq,
128
+ stellaris_board_info *board,
129
+ uint8_t *macaddr)
130
{
131
DeviceState *dev = qdev_new(TYPE_STELLARIS_SYS);
132
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
133
@@ -XXX,XX +XXX,XX @@ static int stellaris_sys_init(uint32_t base, qemu_irq irq,
134
*/
135
device_cold_reset(dev);
136
137
- return 0;
138
+ return dev;
139
}
140
141
/* I2C controller. */
142
@@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
143
int flash_size;
144
I2CBus *i2c;
145
DeviceState *dev;
146
+ DeviceState *ssys_dev;
147
int i;
148
int j;
149
150
@@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
151
}
20
}
152
}
21
}
153
22
154
- stellaris_sys_init(0x400fe000, qdev_get_gpio_in(nvic, 28),
23
+ if (cpu_isar_feature(aa64_nmi, cpu)) {
155
- board, nd_table[0].macaddr.a);
24
+ if (!(env->cp15.sctlr_el[new_el] & SCTLR_SPINTMASK)) {
156
+ ssys_dev = stellaris_sys_init(0x400fe000, qdev_get_gpio_in(nvic, 28),
25
+ new_mode |= PSTATE_ALLINT;
157
+ board, nd_table[0].macaddr.a);
26
+ } else {
158
27
+ new_mode &= ~PSTATE_ALLINT;
159
28
+ }
160
if (board->dc1 & (1 << 3)) { /* watchdog present */
29
+ }
161
@@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
30
+
162
/* system_clock_scale is valid now */
31
pstate_write(env, PSTATE_DAIF | new_mode);
163
uint32_t mainclk = NANOSECONDS_PER_SECOND / system_clock_scale;
32
env->aarch64 = true;
164
qdev_prop_set_uint32(dev, "wdogclk-frq", mainclk);
33
aarch64_restore_sp(env, new_el);
165
+ qdev_connect_clock_in(dev, "WDOGCLK",
166
+ qdev_get_clock_out(ssys_dev, "SYSCLK"));
167
168
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
169
sysbus_mmio_map(SYS_BUS_DEVICE(dev),
170
--
34
--
171
2.20.1
35
2.34.1
172
173
diff view generated by jsdifflib
1
From: Alexander Graf <agraf@csgraf.de>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
In macOS 11, QEMU only gets access to Hypervisor.framework if it has the
3
Augment the GICv3's QOM device interface by adding one
4
respective entitlement. Add an entitlement template and automatically self
4
new set of sysbus IRQ line, to signal NMI to each CPU.
5
sign and apply the entitlement in the build.
6
5
7
Signed-off-by: Alexander Graf <agraf@csgraf.de>
6
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
8
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Tested-by: Roman Bolshakov <r.bolshakov@yadro.com>
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>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
11
---
12
meson.build | 29 +++++++++++++++++++++++++----
12
include/hw/intc/arm_gic_common.h | 2 ++
13
accel/hvf/entitlements.plist | 8 ++++++++
13
include/hw/intc/arm_gicv3_common.h | 2 ++
14
scripts/entitlement.sh | 13 +++++++++++++
14
hw/intc/arm_gicv3_common.c | 6 ++++++
15
3 files changed, 46 insertions(+), 4 deletions(-)
15
3 files changed, 10 insertions(+)
16
create mode 100644 accel/hvf/entitlements.plist
17
create mode 100755 scripts/entitlement.sh
18
16
19
diff --git a/meson.build b/meson.build
17
diff --git a/include/hw/intc/arm_gic_common.h b/include/hw/intc/arm_gic_common.h
20
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
21
--- a/meson.build
19
--- a/include/hw/intc/arm_gic_common.h
22
+++ b/meson.build
20
+++ b/include/hw/intc/arm_gic_common.h
23
@@ -XXX,XX +XXX,XX @@ foreach target : target_dirs
21
@@ -XXX,XX +XXX,XX @@ struct GICState {
24
}]
22
qemu_irq parent_fiq[GIC_NCPU];
25
endif
23
qemu_irq parent_virq[GIC_NCPU];
26
foreach exe: execs
24
qemu_irq parent_vfiq[GIC_NCPU];
27
- emulators += {exe['name']:
25
+ qemu_irq parent_nmi[GIC_NCPU];
28
- executable(exe['name'], exe['sources'],
26
+ qemu_irq parent_vnmi[GIC_NCPU];
29
- install: true,
27
qemu_irq maintenance_irq[GIC_NCPU];
30
+ exe_name = exe['name']
28
31
+ exe_sign = 'CONFIG_HVF' in config_target
29
/* GICD_CTLR; for a GIC with the security extensions the NS banked version
32
+ if exe_sign
30
diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h
33
+ exe_name += '-unsigned'
31
index XXXXXXX..XXXXXXX 100644
34
+ endif
32
--- a/include/hw/intc/arm_gicv3_common.h
35
+
33
+++ b/include/hw/intc/arm_gicv3_common.h
36
+ emulator = executable(exe_name, exe['sources'],
34
@@ -XXX,XX +XXX,XX @@ struct GICv3CPUState {
37
+ install: not exe_sign,
35
qemu_irq parent_fiq;
38
c_args: c_args,
36
qemu_irq parent_virq;
39
dependencies: arch_deps + deps + exe['dependencies'],
37
qemu_irq parent_vfiq;
40
objects: lib.extract_all_objects(recursive: true),
38
+ qemu_irq parent_nmi;
41
@@ -XXX,XX +XXX,XX @@ foreach target : target_dirs
39
+ qemu_irq parent_vnmi;
42
link_depends: [block_syms, qemu_syms] + exe.get('link_depends', []),
40
43
link_args: link_args,
41
/* Redistributor */
44
gui_app: exe['gui'])
42
uint32_t level; /* Current IRQ level */
45
- }
43
diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c
46
+
44
index XXXXXXX..XXXXXXX 100644
47
+ if exe_sign
45
--- a/hw/intc/arm_gicv3_common.c
48
+ emulators += {exe['name'] : custom_target(exe['name'],
46
+++ b/hw/intc/arm_gicv3_common.c
49
+ install: true,
47
@@ -XXX,XX +XXX,XX @@ void gicv3_init_irqs_and_mmio(GICv3State *s, qemu_irq_handler handler,
50
+ install_dir: get_option('bindir'),
48
for (i = 0; i < s->num_cpu; i++) {
51
+ depends: emulator,
49
sysbus_init_irq(sbd, &s->cpu[i].parent_vfiq);
52
+ output: exe['name'],
50
}
53
+ command: [
51
+ for (i = 0; i < s->num_cpu; i++) {
54
+ meson.current_source_dir() / 'scripts/entitlement.sh',
52
+ sysbus_init_irq(sbd, &s->cpu[i].parent_nmi);
55
+ meson.current_build_dir() / exe_name,
53
+ }
56
+ meson.current_build_dir() / exe['name'],
54
+ for (i = 0; i < s->num_cpu; i++) {
57
+ meson.current_source_dir() / 'accel/hvf/entitlements.plist'
55
+ sysbus_init_irq(sbd, &s->cpu[i].parent_vnmi);
58
+ ])
56
+ }
59
+ }
57
60
+ else
58
memory_region_init_io(&s->iomem_dist, OBJECT(s), ops, s,
61
+ emulators += {exe['name']: emulator}
59
"gicv3_dist", 0x10000);
62
+ endif
63
64
if 'CONFIG_TRACE_SYSTEMTAP' in config_host
65
foreach stp: [
66
diff --git a/accel/hvf/entitlements.plist b/accel/hvf/entitlements.plist
67
new file mode 100644
68
index XXXXXXX..XXXXXXX
69
--- /dev/null
70
+++ b/accel/hvf/entitlements.plist
71
@@ -XXX,XX +XXX,XX @@
72
+<?xml version="1.0" encoding="UTF-8"?>
73
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
74
+<plist version="1.0">
75
+<dict>
76
+ <key>com.apple.security.hypervisor</key>
77
+ <true/>
78
+</dict>
79
+</plist>
80
diff --git a/scripts/entitlement.sh b/scripts/entitlement.sh
81
new file mode 100755
82
index XXXXXXX..XXXXXXX
83
--- /dev/null
84
+++ b/scripts/entitlement.sh
85
@@ -XXX,XX +XXX,XX @@
86
+#!/bin/sh -e
87
+#
88
+# Helper script for the build process to apply entitlements
89
+
90
+SRC="$1"
91
+DST="$2"
92
+ENTITLEMENT="$3"
93
+
94
+trap 'rm "$DST.tmp"' exit
95
+cp -af "$SRC" "$DST.tmp"
96
+codesign --entitlements "$ENTITLEMENT" --force -s - "$DST.tmp"
97
+mv "$DST.tmp" "$DST"
98
+trap '' exit
99
--
60
--
100
2.20.1
61
2.34.1
101
102
diff view generated by jsdifflib
1
From: Hao Wu <wuhaotsh@google.com>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
Fix potential overflow problem when calculating pwm_duty.
3
Wire the new NMI and VINMI interrupt line from the GIC to each CPU if it
4
1. Ensure p->cmr and p->cnr to be from [0,65535], according to the
4
is not GICv2.
5
hardware specification.
6
2. Changed duty to uint32_t. However, since MAX_DUTY * (p->cmr+1)
7
can excceed UINT32_MAX, we convert them to uint64_t in computation
8
and converted them back to uint32_t.
9
(duty is guaranteed to be <= MAX_DUTY so it won't overflow.)
10
5
11
Fixes: CID 1442342
6
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
12
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Reviewed-by: Doug Evans <dje@google.com>
8
Message-id: 20240407081733.3231820-12-ruanjinjie@huawei.com
14
Signed-off-by: Hao Wu <wuhaotsh@google.com>
15
Message-id: 20210127011142.2122790-1-wuhaotsh@google.com
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
---
10
---
19
hw/misc/npcm7xx_pwm.c | 23 +++++++++++++++++++----
11
hw/arm/virt.c | 10 +++++++++-
20
tests/qtest/npcm7xx_pwm-test.c | 4 ++--
12
1 file changed, 9 insertions(+), 1 deletion(-)
21
2 files changed, 21 insertions(+), 6 deletions(-)
22
13
23
diff --git a/hw/misc/npcm7xx_pwm.c b/hw/misc/npcm7xx_pwm.c
14
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
24
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
25
--- a/hw/misc/npcm7xx_pwm.c
16
--- a/hw/arm/virt.c
26
+++ b/hw/misc/npcm7xx_pwm.c
17
+++ b/hw/arm/virt.c
27
@@ -XXX,XX +XXX,XX @@ REG32(NPCM7XX_PWM_PWDR3, 0x50);
18
@@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem)
28
#define NPCM7XX_CH_INV BIT(2)
19
29
#define NPCM7XX_CH_MOD BIT(3)
20
/* Wire the outputs from each CPU's generic timer and the GICv3
30
21
* maintenance interrupt signal to the appropriate GIC PPI inputs,
31
+#define NPCM7XX_MAX_CMR 65535
22
- * and the GIC's IRQ/FIQ/VIRQ/VFIQ interrupt outputs to the CPU's inputs.
32
+#define NPCM7XX_MAX_CNR 65535
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));
33
+
32
+
34
/* Offset of each PWM channel's prescaler in the PPR register. */
33
+ if (vms->gic_version != VIRT_GIC_VERSION_2) {
35
static const int npcm7xx_ppr_base[] = { 0, 0, 8, 8 };
34
+ sysbus_connect_irq(gicbusdev, i + 4 * smp_cpus,
36
/* Offset of each PWM channel's clock selector in the CSR register. */
35
+ qdev_get_gpio_in(cpudev, ARM_CPU_NMI));
37
@@ -XXX,XX +XXX,XX @@ static uint32_t npcm7xx_pwm_calculate_freq(NPCM7xxPWM *p)
36
+ sysbus_connect_irq(gicbusdev, i + 5 * smp_cpus,
38
37
+ qdev_get_gpio_in(cpudev, ARM_CPU_VINMI));
39
static uint32_t npcm7xx_pwm_calculate_duty(NPCM7xxPWM *p)
40
{
41
- uint64_t duty;
42
+ uint32_t duty;
43
44
if (p->running) {
45
if (p->cnr == 0) {
46
@@ -XXX,XX +XXX,XX @@ static uint32_t npcm7xx_pwm_calculate_duty(NPCM7xxPWM *p)
47
} else if (p->cmr >= p->cnr) {
48
duty = NPCM7XX_PWM_MAX_DUTY;
49
} else {
50
- duty = NPCM7XX_PWM_MAX_DUTY * (p->cmr + 1) / (p->cnr + 1);
51
+ duty = (uint64_t)NPCM7XX_PWM_MAX_DUTY * (p->cmr + 1) / (p->cnr + 1);
52
}
53
} else {
54
duty = 0;
55
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_pwm_write(void *opaque, hwaddr offset,
56
case A_NPCM7XX_PWM_CNR2:
57
case A_NPCM7XX_PWM_CNR3:
58
p = &s->pwm[npcm7xx_cnr_index(offset)];
59
- p->cnr = value;
60
+ if (value > NPCM7XX_MAX_CNR) {
61
+ qemu_log_mask(LOG_GUEST_ERROR,
62
+ "%s: invalid cnr value: %u", __func__, value);
63
+ p->cnr = NPCM7XX_MAX_CNR;
64
+ } else {
65
+ p->cnr = value;
66
+ }
38
+ }
67
npcm7xx_pwm_update_output(p);
68
break;
69
70
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_pwm_write(void *opaque, hwaddr offset,
71
case A_NPCM7XX_PWM_CMR2:
72
case A_NPCM7XX_PWM_CMR3:
73
p = &s->pwm[npcm7xx_cmr_index(offset)];
74
- p->cmr = value;
75
+ if (value > NPCM7XX_MAX_CMR) {
76
+ qemu_log_mask(LOG_GUEST_ERROR,
77
+ "%s: invalid cmr value: %u", __func__, value);
78
+ p->cmr = NPCM7XX_MAX_CMR;
79
+ } else {
80
+ p->cmr = value;
81
+ }
82
npcm7xx_pwm_update_output(p);
83
break;
84
85
diff --git a/tests/qtest/npcm7xx_pwm-test.c b/tests/qtest/npcm7xx_pwm-test.c
86
index XXXXXXX..XXXXXXX 100644
87
--- a/tests/qtest/npcm7xx_pwm-test.c
88
+++ b/tests/qtest/npcm7xx_pwm-test.c
89
@@ -XXX,XX +XXX,XX @@ static uint64_t pwm_compute_freq(QTestState *qts, uint32_t ppr, uint32_t csr,
90
91
static uint64_t pwm_compute_duty(uint32_t cnr, uint32_t cmr, bool inverted)
92
{
93
- uint64_t duty;
94
+ uint32_t duty;
95
96
if (cnr == 0) {
97
/* PWM is stopped. */
98
@@ -XXX,XX +XXX,XX @@ static uint64_t pwm_compute_duty(uint32_t cnr, uint32_t cmr, bool inverted)
99
} else if (cmr >= cnr) {
100
duty = MAX_DUTY;
101
} else {
102
- duty = MAX_DUTY * (cmr + 1) / (cnr + 1);
103
+ duty = (uint64_t)MAX_DUTY * (cmr + 1) / (cnr + 1);
104
}
39
}
105
40
106
if (inverted) {
41
fdt_add_gic_node(vms);
107
--
42
--
108
2.20.1
43
2.34.1
109
110
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
Only define the register if it exists for the cpu.
3
According to Arm GIC section 4.6.3 Interrupt superpriority, the interrupt
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.
4
8
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
6
Message-id: 20210120031656.737646-1-richard.henderson@linaro.org
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>
12
Message-id: 20240407081733.3231820-13-ruanjinjie@huawei.com
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
14
---
10
target/arm/helper.c | 21 +++++++++++++++------
15
target/arm/helper.c | 3 +++
11
1 file changed, 15 insertions(+), 6 deletions(-)
16
1 file changed, 3 insertions(+)
12
17
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
18
diff --git a/target/arm/helper.c b/target/arm/helper.c
14
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
20
--- a/target/arm/helper.c
16
+++ b/target/arm/helper.c
21
+++ b/target/arm/helper.c
17
@@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu)
22
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs)
18
*/
23
break;
19
int i;
24
case EXCP_IRQ:
20
int wrps, brps, ctx_cmps;
25
case EXCP_VIRQ:
21
- ARMCPRegInfo dbgdidr = {
26
+ case EXCP_NMI:
22
- .name = "DBGDIDR", .cp = 14, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 0,
27
+ case EXCP_VINMI:
23
- .access = PL0_R, .accessfn = access_tda,
28
addr += 0x80;
24
- .type = ARM_CP_CONST, .resetvalue = cpu->isar.dbgdidr,
29
break;
25
- };
30
case EXCP_FIQ:
26
+
31
case EXCP_VFIQ:
27
+ /*
32
+ case EXCP_VFNMI:
28
+ * The Arm ARM says DBGDIDR is optional and deprecated if EL1 cannot
33
addr += 0x100;
29
+ * use AArch32. Given that bit 15 is RES1, if the value is 0 then
34
break;
30
+ * the register must not exist for this cpu.
35
case EXCP_VSERR:
31
+ */
32
+ if (cpu->isar.dbgdidr != 0) {
33
+ ARMCPRegInfo dbgdidr = {
34
+ .name = "DBGDIDR", .cp = 14, .crn = 0, .crm = 0,
35
+ .opc1 = 0, .opc2 = 0,
36
+ .access = PL0_R, .accessfn = access_tda,
37
+ .type = ARM_CP_CONST, .resetvalue = cpu->isar.dbgdidr,
38
+ };
39
+ define_one_arm_cp_reg(cpu, &dbgdidr);
40
+ }
41
42
/* Note that all these register fields hold "number of Xs minus 1". */
43
brps = arm_num_brps(cpu);
44
@@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu)
45
46
assert(ctx_cmps <= brps);
47
48
- define_one_arm_cp_reg(cpu, &dbgdidr);
49
define_arm_cp_regs(cpu, debug_cp_reginfo);
50
51
if (arm_feature(&cpu->env, ARM_FEATURE_LPAE)) {
52
--
36
--
53
2.20.1
37
2.34.1
54
55
diff view generated by jsdifflib
Deleted patch
1
From: Paolo Bonzini <pbonzini@redhat.com>
2
1
3
The properties to attach a CANBUS object to the xlnx-zcu102 machine have
4
a period in them. We want to use periods in properties for compound QAPI types,
5
and besides the "xlnx-zcu102." prefix is both unnecessary and different
6
from any other machine property name. Remove it.
7
8
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
9
Message-id: 20210118162537.779542-1-pbonzini@redhat.com
10
Reviewed-by: Vikram Garhwal <fnu.vikram@xilinx.com>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
hw/arm/xlnx-zcu102.c | 4 ++--
14
tests/qtest/xlnx-can-test.c | 30 +++++++++++++++---------------
15
2 files changed, 17 insertions(+), 17 deletions(-)
16
17
diff --git a/hw/arm/xlnx-zcu102.c b/hw/arm/xlnx-zcu102.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/arm/xlnx-zcu102.c
20
+++ b/hw/arm/xlnx-zcu102.c
21
@@ -XXX,XX +XXX,XX @@ static void xlnx_zcu102_machine_instance_init(Object *obj)
22
s->secure = false;
23
/* Default to virt (EL2) being disabled */
24
s->virt = false;
25
- object_property_add_link(obj, "xlnx-zcu102.canbus0", TYPE_CAN_BUS,
26
+ object_property_add_link(obj, "canbus0", TYPE_CAN_BUS,
27
(Object **)&s->canbus[0],
28
object_property_allow_set_link,
29
0);
30
31
- object_property_add_link(obj, "xlnx-zcu102.canbus1", TYPE_CAN_BUS,
32
+ object_property_add_link(obj, "canbus1", TYPE_CAN_BUS,
33
(Object **)&s->canbus[1],
34
object_property_allow_set_link,
35
0);
36
diff --git a/tests/qtest/xlnx-can-test.c b/tests/qtest/xlnx-can-test.c
37
index XXXXXXX..XXXXXXX 100644
38
--- a/tests/qtest/xlnx-can-test.c
39
+++ b/tests/qtest/xlnx-can-test.c
40
@@ -XXX,XX +XXX,XX @@ static void test_can_bus(void)
41
uint8_t can_timestamp = 1;
42
43
QTestState *qts = qtest_init("-machine xlnx-zcu102"
44
- " -object can-bus,id=canbus0"
45
- " -machine xlnx-zcu102.canbus0=canbus0"
46
- " -machine xlnx-zcu102.canbus1=canbus0"
47
+ " -object can-bus,id=canbus"
48
+ " -machine canbus0=canbus"
49
+ " -machine canbus1=canbus"
50
);
51
52
/* Configure the CAN0 and CAN1. */
53
@@ -XXX,XX +XXX,XX @@ static void test_can_loopback(void)
54
uint32_t status = 0;
55
56
QTestState *qts = qtest_init("-machine xlnx-zcu102"
57
- " -object can-bus,id=canbus0"
58
- " -machine xlnx-zcu102.canbus0=canbus0"
59
- " -machine xlnx-zcu102.canbus1=canbus0"
60
+ " -object can-bus,id=canbus"
61
+ " -machine canbus0=canbus"
62
+ " -machine canbus1=canbus"
63
);
64
65
/* Configure the CAN0 in loopback mode. */
66
@@ -XXX,XX +XXX,XX @@ static void test_can_filter(void)
67
uint8_t can_timestamp = 1;
68
69
QTestState *qts = qtest_init("-machine xlnx-zcu102"
70
- " -object can-bus,id=canbus0"
71
- " -machine xlnx-zcu102.canbus0=canbus0"
72
- " -machine xlnx-zcu102.canbus1=canbus0"
73
+ " -object can-bus,id=canbus"
74
+ " -machine canbus0=canbus"
75
+ " -machine canbus1=canbus"
76
);
77
78
/* Configure the CAN0 and CAN1. */
79
@@ -XXX,XX +XXX,XX @@ static void test_can_sleepmode(void)
80
uint8_t can_timestamp = 1;
81
82
QTestState *qts = qtest_init("-machine xlnx-zcu102"
83
- " -object can-bus,id=canbus0"
84
- " -machine xlnx-zcu102.canbus0=canbus0"
85
- " -machine xlnx-zcu102.canbus1=canbus0"
86
+ " -object can-bus,id=canbus"
87
+ " -machine canbus0=canbus"
88
+ " -machine canbus1=canbus"
89
);
90
91
/* Configure the CAN0. */
92
@@ -XXX,XX +XXX,XX @@ static void test_can_snoopmode(void)
93
uint8_t can_timestamp = 1;
94
95
QTestState *qts = qtest_init("-machine xlnx-zcu102"
96
- " -object can-bus,id=canbus0"
97
- " -machine xlnx-zcu102.canbus0=canbus0"
98
- " -machine xlnx-zcu102.canbus1=canbus0"
99
+ " -object can-bus,id=canbus"
100
+ " -machine canbus0=canbus"
101
+ " -machine canbus1=canbus"
102
);
103
104
/* Configure the CAN0. */
105
--
106
2.20.1
107
108
diff view generated by jsdifflib
1
From: Joelle van Dyne <j@getutm.app>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
On iOS there is no CoreAudio, so we should not assume Darwin always
3
Add a property has-nmi to the GICv3 device, and use this to set
4
has it.
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.
5
8
6
Signed-off-by: Joelle van Dyne <j@getutm.app>
9
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20210126012457.39046-11-j@getutm.app
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Message-id: 20240407081733.3231820-14-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
configure | 35 +++++++++++++++++++++++++++++++++--
15
hw/intc/gicv3_internal.h | 1 +
12
1 file changed, 33 insertions(+), 2 deletions(-)
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(+)
13
20
14
diff --git a/configure b/configure
21
diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h
15
index XXXXXXX..XXXXXXX 100755
22
index XXXXXXX..XXXXXXX 100644
16
--- a/configure
23
--- a/hw/intc/gicv3_internal.h
17
+++ b/configure
24
+++ b/hw/intc/gicv3_internal.h
18
@@ -XXX,XX +XXX,XX @@ fdt="auto"
25
@@ -XXX,XX +XXX,XX @@
19
netmap="no"
26
#define GICD_CTLR_E1NWF (1U << 7)
20
sdl="auto"
27
#define GICD_CTLR_RWP (1U << 31)
21
sdl_image="auto"
28
22
+coreaudio="auto"
29
+#define GICD_TYPER_NMI_SHIFT 9
23
virtiofsd="auto"
30
#define GICD_TYPER_LPIS_SHIFT 17
24
virtfs="auto"
31
25
libudev="auto"
32
/* 16 bits EventId */
26
@@ -XXX,XX +XXX,XX @@ Darwin)
33
diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h
27
QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
34
index XXXXXXX..XXXXXXX 100644
28
QEMU_LDFLAGS="-arch x86_64 $QEMU_LDFLAGS"
35
--- a/include/hw/intc/arm_gicv3_common.h
29
fi
36
+++ b/include/hw/intc/arm_gicv3_common.h
30
- audio_drv_list="coreaudio try-sdl"
37
@@ -XXX,XX +XXX,XX @@ struct GICv3State {
31
+ audio_drv_list="try-coreaudio try-sdl"
38
uint32_t num_irq;
32
audio_possible_drivers="coreaudio sdl"
39
uint32_t revision;
33
# Disable attempts to use ObjectiveC features in os/object.h since they
40
bool lpi_enable;
34
# won't work when we're compiling with gcc as a C compiler.
41
+ bool nmi_support;
35
@@ -XXX,XX +XXX,XX @@ EOF
42
bool security_extn;
36
fi
43
bool force_8bit_prio;
37
fi
44
bool irq_reset_nonsecure;
38
45
diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c
39
+##########################################
46
index XXXXXXX..XXXXXXX 100644
40
+# detect CoreAudio
47
--- a/hw/intc/arm_gicv3_common.c
41
+if test "$coreaudio" != "no" ; then
48
+++ b/hw/intc/arm_gicv3_common.c
42
+ coreaudio_libs="-framework CoreAudio"
49
@@ -XXX,XX +XXX,XX @@ static Property arm_gicv3_common_properties[] = {
43
+ cat > $TMPC << EOF
50
DEFINE_PROP_UINT32("num-irq", GICv3State, num_irq, 32),
44
+#include <CoreAudio/CoreAudio.h>
51
DEFINE_PROP_UINT32("revision", GICv3State, revision, 3),
45
+int main(void)
52
DEFINE_PROP_BOOL("has-lpi", GICv3State, lpi_enable, 0),
46
+{
53
+ DEFINE_PROP_BOOL("has-nmi", GICv3State, nmi_support, 0),
47
+ return (int)AudioGetCurrentHostTime();
54
DEFINE_PROP_BOOL("has-security-extensions", GICv3State, security_extn, 0),
48
+}
55
/*
49
+EOF
56
* Compatibility property: force 8 bits of physical priority, even
50
+ if compile_prog "" "$coreaudio_libs" ; then
57
diff --git a/hw/intc/arm_gicv3_dist.c b/hw/intc/arm_gicv3_dist.c
51
+ coreaudio=yes
58
index XXXXXXX..XXXXXXX 100644
52
+ else
59
--- a/hw/intc/arm_gicv3_dist.c
53
+ coreaudio=no
60
+++ b/hw/intc/arm_gicv3_dist.c
54
+ fi
61
@@ -XXX,XX +XXX,XX @@ static bool gicd_readl(GICv3State *s, hwaddr offset,
55
+fi
62
* by GICD_TYPER.IDbits)
56
+
63
* MBIS == 0 (message-based SPIs not supported)
57
##########################################
64
* SecurityExtn == 1 if security extns supported
58
# Sound support libraries probe
65
+ * NMI = 1 if Non-maskable interrupt property is supported
59
66
* CPUNumber == 0 since for us ARE is always 1
60
@@ -XXX,XX +XXX,XX @@ for drv in $audio_drv_list; do
67
* ITLinesNumber == (((max SPI IntID + 1) / 32) - 1)
61
fi
68
*/
62
;;
69
@@ -XXX,XX +XXX,XX @@ static bool gicd_readl(GICv3State *s, hwaddr offset,
63
70
bool dvis = s->revision >= 4;
64
- coreaudio)
71
65
+ coreaudio | try-coreaudio)
72
*data = (1 << 25) | (1 << 24) | (dvis << 18) | (sec_extn << 10) |
66
+ if test "$coreaudio" = "no"; then
73
+ (s->nmi_support << GICD_TYPER_NMI_SHIFT) |
67
+ if test "$drv" = "try-coreaudio"; then
74
(s->lpi_enable << GICD_TYPER_LPIS_SHIFT) |
68
+ audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-coreaudio//')
75
(0xf << 19) | itlinesnumber;
69
+ else
76
return true;
70
+ error_exit "$drv check failed" \
71
+ "Make sure to have the $drv is available."
72
+ fi
73
+ else
74
coreaudio_libs="-framework CoreAudio"
75
+ if test "$drv" = "try-coreaudio"; then
76
+ audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-coreaudio/coreaudio/')
77
+ fi
78
+ fi
79
;;
80
81
dsound)
82
--
77
--
83
2.20.1
78
2.34.1
84
85
diff view generated by jsdifflib
1
The old-style convenience function cmsdk_apb_timer_create() for
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
creating CMSDK_APB_TIMER objects is used in only two places in
3
mps2.c. Most of the rest of the code in that file uses the new
4
"initialize in place" coding style.
5
2
6
We want to connect up a Clock object which should be done between the
3
So far, there is no FEAT_GICv3_NMI support in the in-kernel GIC, so make it
7
object creation and realization; rather than adding a Clock* argument
4
an error to try to set has-nmi=true for the KVM GICv3.
8
to the convenience function, convert the timer creation code in
9
mps2.c to the same style as is used already for the watchdog,
10
dualtimer and other devices, and delete the now-unused convenience
11
function.
12
5
6
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
7
Message-id: 20240407081733.3231820-15-ruanjinjie@huawei.com
8
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
Reviewed-by: Luc Michel <luc@lmichel.fr>
16
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
17
Message-id: 20210128114145.20536-13-peter.maydell@linaro.org
18
Message-id: 20210121190622.22000-13-peter.maydell@linaro.org
19
---
10
---
20
include/hw/timer/cmsdk-apb-timer.h | 21 ---------------------
11
hw/intc/arm_gicv3_kvm.c | 5 +++++
21
hw/arm/mps2.c | 18 ++++++++++++++++--
12
1 file changed, 5 insertions(+)
22
2 files changed, 16 insertions(+), 23 deletions(-)
23
13
24
diff --git a/include/hw/timer/cmsdk-apb-timer.h b/include/hw/timer/cmsdk-apb-timer.h
14
diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c
25
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
26
--- a/include/hw/timer/cmsdk-apb-timer.h
16
--- a/hw/intc/arm_gicv3_kvm.c
27
+++ b/include/hw/timer/cmsdk-apb-timer.h
17
+++ b/hw/intc/arm_gicv3_kvm.c
28
@@ -XXX,XX +XXX,XX @@ struct CMSDKAPBTimer {
18
@@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp)
29
uint32_t intstatus;
19
return;
30
};
31
32
-/**
33
- * cmsdk_apb_timer_create - convenience function to create TYPE_CMSDK_APB_TIMER
34
- * @addr: location in system memory to map registers
35
- * @pclk_frq: frequency in Hz of the PCLK clock (used for calculating baud rate)
36
- */
37
-static inline DeviceState *cmsdk_apb_timer_create(hwaddr addr,
38
- qemu_irq timerint,
39
- uint32_t pclk_frq)
40
-{
41
- DeviceState *dev;
42
- SysBusDevice *s;
43
-
44
- dev = qdev_new(TYPE_CMSDK_APB_TIMER);
45
- s = SYS_BUS_DEVICE(dev);
46
- qdev_prop_set_uint32(dev, "pclk-frq", pclk_frq);
47
- sysbus_realize_and_unref(s, &error_fatal);
48
- sysbus_mmio_map(s, 0, addr);
49
- sysbus_connect_irq(s, 0, timerint);
50
- return dev;
51
-}
52
-
53
#endif
54
diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
55
index XXXXXXX..XXXXXXX 100644
56
--- a/hw/arm/mps2.c
57
+++ b/hw/arm/mps2.c
58
@@ -XXX,XX +XXX,XX @@ struct MPS2MachineState {
59
/* CMSDK APB subsystem */
60
CMSDKAPBDualTimer dualtimer;
61
CMSDKAPBWatchdog watchdog;
62
+ CMSDKAPBTimer timer[2];
63
};
64
65
#define TYPE_MPS2_MACHINE "mps2"
66
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
67
}
20
}
68
21
69
/* CMSDK APB subsystem */
22
+ if (s->nmi_support) {
70
- cmsdk_apb_timer_create(0x40000000, qdev_get_gpio_in(armv7m, 8), SYSCLK_FRQ);
23
+ error_setg(errp, "NMI is not supported with the in-kernel GIC");
71
- cmsdk_apb_timer_create(0x40001000, qdev_get_gpio_in(armv7m, 9), SYSCLK_FRQ);
24
+ return;
72
+ for (i = 0; i < ARRAY_SIZE(mms->timer); i++) {
73
+ g_autofree char *name = g_strdup_printf("timer%d", i);
74
+ hwaddr base = 0x40000000 + i * 0x1000;
75
+ int irqno = 8 + i;
76
+ SysBusDevice *sbd;
77
+
78
+ object_initialize_child(OBJECT(mms), name, &mms->timer[i],
79
+ TYPE_CMSDK_APB_TIMER);
80
+ sbd = SYS_BUS_DEVICE(&mms->timer[i]);
81
+ qdev_prop_set_uint32(DEVICE(&mms->timer[i]), "pclk-frq", SYSCLK_FRQ);
82
+ sysbus_realize_and_unref(sbd, &error_fatal);
83
+ sysbus_mmio_map(sbd, 0, base);
84
+ sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(armv7m, irqno));
85
+ }
25
+ }
86
+
26
+
87
object_initialize_child(OBJECT(mms), "dualtimer", &mms->dualtimer,
27
gicv3_init_irqs_and_mmio(s, kvm_arm_gicv3_set_irq, NULL);
88
TYPE_CMSDK_APB_DUALTIMER);
28
89
qdev_prop_set_uint32(DEVICE(&mms->dualtimer), "pclk-frq", SYSCLK_FRQ);
29
for (i = 0; i < s->num_cpu; i++) {
90
--
30
--
91
2.20.1
31
2.34.1
92
93
diff view generated by jsdifflib
1
Now no users are setting the frq properties on the CMSDK timer,
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
dualtimer, watchdog or ARMSSE SoC devices, we can remove the
3
properties and the struct fields that back them.
4
2
3
A SPI, PPI or SGI interrupt can have non-maskable property. So maintain
4
non-maskable property in PendingIrq and GICR/GICD. Since add new device
5
state, it also needs to be migrated, so also save NMI info in
6
vmstate_gicv3_cpu and vmstate_gicv3.
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
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Luc Michel <luc@lmichel.fr>
8
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-id: 20210128114145.20536-25-peter.maydell@linaro.org
10
Message-id: 20210121190622.22000-25-peter.maydell@linaro.org
11
---
13
---
12
include/hw/arm/armsse.h | 2 --
14
include/hw/intc/arm_gicv3_common.h | 4 ++++
13
include/hw/timer/cmsdk-apb-dualtimer.h | 2 --
15
hw/intc/arm_gicv3_common.c | 38 ++++++++++++++++++++++++++++++
14
include/hw/timer/cmsdk-apb-timer.h | 2 --
16
2 files changed, 42 insertions(+)
15
include/hw/watchdog/cmsdk-apb-watchdog.h | 2 --
16
hw/arm/armsse.c | 2 --
17
hw/timer/cmsdk-apb-dualtimer.c | 6 ------
18
hw/timer/cmsdk-apb-timer.c | 6 ------
19
hw/watchdog/cmsdk-apb-watchdog.c | 6 ------
20
8 files changed, 28 deletions(-)
21
17
22
diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h
18
diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h
23
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
24
--- a/include/hw/arm/armsse.h
20
--- a/include/hw/intc/arm_gicv3_common.h
25
+++ b/include/hw/arm/armsse.h
21
+++ b/include/hw/intc/arm_gicv3_common.h
26
@@ -XXX,XX +XXX,XX @@
22
@@ -XXX,XX +XXX,XX @@ typedef struct {
27
* + Clock input "S32KCLK": slow 32KHz clock used for a few peripherals
23
int irq;
28
* + QOM property "memory" is a MemoryRegion containing the devices provided
24
uint8_t prio;
29
* by the board model.
25
int grp;
30
- * + QOM property "MAINCLK_FRQ" is the frequency of the main system clock
26
+ bool nmi;
31
* + QOM property "EXP_NUMIRQ" sets the number of expansion interrupts.
27
} PendingIrq;
32
* (In hardware, the SSE-200 permits the number of expansion interrupts
28
33
* for the two CPUs to be configured separately, but we restrict it to
29
struct GICv3CPUState {
34
@@ -XXX,XX +XXX,XX @@ struct ARMSSE {
30
@@ -XXX,XX +XXX,XX @@ struct GICv3CPUState {
35
/* Properties */
31
uint32_t gicr_ienabler0;
36
MemoryRegion *board_memory;
32
uint32_t gicr_ipendr0;
37
uint32_t exp_numirq;
33
uint32_t gicr_iactiver0;
38
- uint32_t mainclk_frq;
34
+ uint32_t gicr_inmir0;
39
uint32_t sram_addr_width;
35
uint32_t edge_trigger; /* ICFGR0 and ICFGR1 even bits */
40
uint32_t init_svtor;
36
uint32_t gicr_igrpmodr0;
41
bool cpu_fpu[SSE_MAX_CPUS];
37
uint32_t gicr_nsacr;
42
diff --git a/include/hw/timer/cmsdk-apb-dualtimer.h b/include/hw/timer/cmsdk-apb-dualtimer.h
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
43
index XXXXXXX..XXXXXXX 100644
55
index XXXXXXX..XXXXXXX 100644
44
--- a/include/hw/timer/cmsdk-apb-dualtimer.h
56
--- a/hw/intc/arm_gicv3_common.c
45
+++ b/include/hw/timer/cmsdk-apb-dualtimer.h
57
+++ b/hw/intc/arm_gicv3_common.c
46
@@ -XXX,XX +XXX,XX @@
58
@@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_gicv3_gicv4 = {
47
* https://developer.arm.com/products/system-design/system-design-kits/cortex-m-system-design-kit
48
*
49
* QEMU interface:
50
- * + QOM property "pclk-frq": frequency at which the timer is clocked
51
* + Clock input "TIMCLK": clock (for both timers)
52
* + sysbus MMIO region 0: the register bank
53
* + sysbus IRQ 0: combined timer interrupt TIMINTC
54
@@ -XXX,XX +XXX,XX @@ struct CMSDKAPBDualTimer {
55
/*< public >*/
56
MemoryRegion iomem;
57
qemu_irq timerintc;
58
- uint32_t pclk_frq;
59
Clock *timclk;
60
61
CMSDKAPBDualTimerModule timermod[CMSDK_APB_DUALTIMER_NUM_MODULES];
62
diff --git a/include/hw/timer/cmsdk-apb-timer.h b/include/hw/timer/cmsdk-apb-timer.h
63
index XXXXXXX..XXXXXXX 100644
64
--- a/include/hw/timer/cmsdk-apb-timer.h
65
+++ b/include/hw/timer/cmsdk-apb-timer.h
66
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(CMSDKAPBTimer, CMSDK_APB_TIMER)
67
68
/*
69
* QEMU interface:
70
- * + QOM property "pclk-frq": frequency at which the timer is clocked
71
* + Clock input "pclk": clock for the timer
72
* + sysbus MMIO region 0: the register bank
73
* + sysbus IRQ 0: timer interrupt TIMERINT
74
@@ -XXX,XX +XXX,XX @@ struct CMSDKAPBTimer {
75
/*< public >*/
76
MemoryRegion iomem;
77
qemu_irq timerint;
78
- uint32_t pclk_frq;
79
struct ptimer_state *timer;
80
Clock *pclk;
81
82
diff --git a/include/hw/watchdog/cmsdk-apb-watchdog.h b/include/hw/watchdog/cmsdk-apb-watchdog.h
83
index XXXXXXX..XXXXXXX 100644
84
--- a/include/hw/watchdog/cmsdk-apb-watchdog.h
85
+++ b/include/hw/watchdog/cmsdk-apb-watchdog.h
86
@@ -XXX,XX +XXX,XX @@
87
* https://developer.arm.com/products/system-design/system-design-kits/cortex-m-system-design-kit
88
*
89
* QEMU interface:
90
- * + QOM property "wdogclk-frq": frequency at which the watchdog is clocked
91
* + Clock input "WDOGCLK": clock for the watchdog's timer
92
* + sysbus MMIO region 0: the register bank
93
* + sysbus IRQ 0: watchdog interrupt
94
@@ -XXX,XX +XXX,XX @@ struct CMSDKAPBWatchdog {
95
/*< public >*/
96
MemoryRegion iomem;
97
qemu_irq wdogint;
98
- uint32_t wdogclk_frq;
99
bool is_luminary;
100
struct ptimer_state *timer;
101
Clock *wdogclk;
102
diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c
103
index XXXXXXX..XXXXXXX 100644
104
--- a/hw/arm/armsse.c
105
+++ b/hw/arm/armsse.c
106
@@ -XXX,XX +XXX,XX @@ static Property iotkit_properties[] = {
107
DEFINE_PROP_LINK("memory", ARMSSE, board_memory, TYPE_MEMORY_REGION,
108
MemoryRegion *),
109
DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64),
110
- DEFINE_PROP_UINT32("MAINCLK_FRQ", ARMSSE, mainclk_frq, 0),
111
DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 15),
112
DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000),
113
DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], true),
114
@@ -XXX,XX +XXX,XX @@ static Property armsse_properties[] = {
115
DEFINE_PROP_LINK("memory", ARMSSE, board_memory, TYPE_MEMORY_REGION,
116
MemoryRegion *),
117
DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64),
118
- DEFINE_PROP_UINT32("MAINCLK_FRQ", ARMSSE, mainclk_frq, 0),
119
DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 15),
120
DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000),
121
DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], false),
122
diff --git a/hw/timer/cmsdk-apb-dualtimer.c b/hw/timer/cmsdk-apb-dualtimer.c
123
index XXXXXXX..XXXXXXX 100644
124
--- a/hw/timer/cmsdk-apb-dualtimer.c
125
+++ b/hw/timer/cmsdk-apb-dualtimer.c
126
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription cmsdk_apb_dualtimer_vmstate = {
127
}
59
}
128
};
60
};
129
61
130
-static Property cmsdk_apb_dualtimer_properties[] = {
62
+static bool gicv3_cpu_nmi_needed(void *opaque)
131
- DEFINE_PROP_UINT32("pclk-frq", CMSDKAPBDualTimer, pclk_frq, 0),
63
+{
132
- DEFINE_PROP_END_OF_LIST(),
64
+ GICv3CPUState *cs = opaque;
133
-};
65
+
134
-
66
+ return cs->gic->nmi_support;
135
static void cmsdk_apb_dualtimer_class_init(ObjectClass *klass, void *data)
67
+}
136
{
68
+
137
DeviceClass *dc = DEVICE_CLASS(klass);
69
+static const VMStateDescription vmstate_gicv3_cpu_nmi = {
138
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_dualtimer_class_init(ObjectClass *klass, void *data)
70
+ .name = "arm_gicv3_cpu/nmi",
139
dc->realize = cmsdk_apb_dualtimer_realize;
71
+ .version_id = 1,
140
dc->vmsd = &cmsdk_apb_dualtimer_vmstate;
72
+ .minimum_version_id = 1,
141
dc->reset = cmsdk_apb_dualtimer_reset;
73
+ .needed = gicv3_cpu_nmi_needed,
142
- device_class_set_props(dc, cmsdk_apb_dualtimer_properties);
74
+ .fields = (const VMStateField[]) {
143
}
75
+ VMSTATE_UINT32(gicr_inmir0, GICv3CPUState),
144
76
+ VMSTATE_END_OF_LIST()
145
static const TypeInfo cmsdk_apb_dualtimer_info = {
77
+ }
146
diff --git a/hw/timer/cmsdk-apb-timer.c b/hw/timer/cmsdk-apb-timer.c
78
+};
147
index XXXXXXX..XXXXXXX 100644
79
+
148
--- a/hw/timer/cmsdk-apb-timer.c
80
static const VMStateDescription vmstate_gicv3_cpu = {
149
+++ b/hw/timer/cmsdk-apb-timer.c
81
.name = "arm_gicv3_cpu",
150
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription cmsdk_apb_timer_vmstate = {
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
151
}
89
}
152
};
90
};
153
91
@@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_gicv3_gicd_no_migration_shift_bug = {
154
-static Property cmsdk_apb_timer_properties[] = {
155
- DEFINE_PROP_UINT32("pclk-frq", CMSDKAPBTimer, pclk_frq, 0),
156
- DEFINE_PROP_END_OF_LIST(),
157
-};
158
-
159
static void cmsdk_apb_timer_class_init(ObjectClass *klass, void *data)
160
{
161
DeviceClass *dc = DEVICE_CLASS(klass);
162
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_class_init(ObjectClass *klass, void *data)
163
dc->realize = cmsdk_apb_timer_realize;
164
dc->vmsd = &cmsdk_apb_timer_vmstate;
165
dc->reset = cmsdk_apb_timer_reset;
166
- device_class_set_props(dc, cmsdk_apb_timer_properties);
167
}
168
169
static const TypeInfo cmsdk_apb_timer_info = {
170
diff --git a/hw/watchdog/cmsdk-apb-watchdog.c b/hw/watchdog/cmsdk-apb-watchdog.c
171
index XXXXXXX..XXXXXXX 100644
172
--- a/hw/watchdog/cmsdk-apb-watchdog.c
173
+++ b/hw/watchdog/cmsdk-apb-watchdog.c
174
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription cmsdk_apb_watchdog_vmstate = {
175
}
92
}
176
};
93
};
177
94
178
-static Property cmsdk_apb_watchdog_properties[] = {
95
+static bool gicv3_nmi_needed(void *opaque)
179
- DEFINE_PROP_UINT32("wdogclk-frq", CMSDKAPBWatchdog, wdogclk_frq, 0),
96
+{
180
- DEFINE_PROP_END_OF_LIST(),
97
+ GICv3State *cs = opaque;
181
-};
98
+
182
-
99
+ return cs->nmi_support;
183
static void cmsdk_apb_watchdog_class_init(ObjectClass *klass, void *data)
100
+}
184
{
101
+
185
DeviceClass *dc = DEVICE_CLASS(klass);
102
+const VMStateDescription vmstate_gicv3_gicd_nmi = {
186
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_class_init(ObjectClass *klass, void *data)
103
+ .name = "arm_gicv3/gicd_nmi",
187
dc->realize = cmsdk_apb_watchdog_realize;
104
+ .version_id = 1,
188
dc->vmsd = &cmsdk_apb_watchdog_vmstate;
105
+ .minimum_version_id = 1,
189
dc->reset = cmsdk_apb_watchdog_reset;
106
+ .needed = gicv3_nmi_needed,
190
- device_class_set_props(dc, cmsdk_apb_watchdog_properties);
107
+ .fields = (const VMStateField[]) {
191
}
108
+ VMSTATE_UINT32_ARRAY(nmi, GICv3State, GICV3_BMP_SIZE),
192
109
+ VMSTATE_END_OF_LIST()
193
static const TypeInfo cmsdk_apb_watchdog_info = {
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
122
}
123
};
194
--
124
--
195
2.20.1
125
2.34.1
196
197
diff view generated by jsdifflib
1
Now that the CMSDK APB watchdog uses its Clock input, it will
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
correctly respond when the system clock frequency is changed using
3
the RCC register on in the Stellaris board system registers. Test
4
that when the RCC register is written it causes the watchdog timer to
5
change speed.
6
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
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Reviewed-by: Luc Michel <luc@lmichel.fr>
10
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Message-id: 20210128114145.20536-22-peter.maydell@linaro.org
12
Message-id: 20210121190622.22000-22-peter.maydell@linaro.org
13
---
10
---
14
tests/qtest/cmsdk-apb-watchdog-test.c | 52 +++++++++++++++++++++++++++
11
hw/intc/gicv3_internal.h | 1 +
15
1 file changed, 52 insertions(+)
12
hw/intc/arm_gicv3_redist.c | 19 +++++++++++++++++++
13
2 files changed, 20 insertions(+)
16
14
17
diff --git a/tests/qtest/cmsdk-apb-watchdog-test.c b/tests/qtest/cmsdk-apb-watchdog-test.c
15
diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h
18
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
19
--- a/tests/qtest/cmsdk-apb-watchdog-test.c
17
--- a/hw/intc/gicv3_internal.h
20
+++ b/tests/qtest/cmsdk-apb-watchdog-test.c
18
+++ b/hw/intc/gicv3_internal.h
21
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@
22
*/
20
#define GICR_ICFGR1 (GICR_SGI_OFFSET + 0x0C04)
23
21
#define GICR_IGRPMODR0 (GICR_SGI_OFFSET + 0x0D00)
24
#include "qemu/osdep.h"
22
#define GICR_NSACR (GICR_SGI_OFFSET + 0x0E00)
25
+#include "qemu/bitops.h"
23
+#define GICR_INMIR0 (GICR_SGI_OFFSET + 0x0F80)
26
#include "libqtest-single.h"
24
27
25
/* VLPI redistributor registers, offsets from VLPI_base */
28
/*
26
#define GICR_VPROPBASER (GICR_VLPI_OFFSET + 0x70)
29
@@ -XXX,XX +XXX,XX @@
27
diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c
30
#define WDOGMIS 0x14
28
index XXXXXXX..XXXXXXX 100644
31
#define WDOGLOCK 0xc00
29
--- a/hw/intc/arm_gicv3_redist.c
32
30
+++ b/hw/intc/arm_gicv3_redist.c
33
+#define SSYS_BASE 0x400fe000
31
@@ -XXX,XX +XXX,XX @@ static int gicr_ns_access(GICv3CPUState *cs, int irq)
34
+#define RCC 0x60
32
return extract32(cs->gicr_nsacr, irq * 2, 2);
35
+#define SYSDIV_SHIFT 23
36
+#define SYSDIV_LENGTH 4
37
+
38
static void test_watchdog(void)
39
{
40
g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0);
41
@@ -XXX,XX +XXX,XX @@ static void test_watchdog(void)
42
g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0);
43
}
33
}
44
34
45
+static void test_clock_change(void)
35
+static void gicr_write_bitmap_reg(GICv3CPUState *cs, MemTxAttrs attrs,
36
+ uint32_t *reg, uint32_t val)
46
+{
37
+{
47
+ uint32_t rcc;
38
+ /* Helper routine to implement writing to a "set" register */
48
+
39
+ val &= mask_group(cs, attrs);
49
+ /*
40
+ *reg = val;
50
+ * Test that writing to the stellaris board's RCC register to
41
+ gicv3_redist_update(cs);
51
+ * change the system clock frequency causes the watchdog
52
+ * to change the speed it counts at.
53
+ */
54
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0);
55
+
56
+ writel(WDOG_BASE + WDOGCONTROL, 1);
57
+ writel(WDOG_BASE + WDOGLOAD, 1000);
58
+
59
+ /* Step to just past the 500th tick */
60
+ clock_step(80 * 500 + 1);
61
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0);
62
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 500);
63
+
64
+ /* Rewrite RCC.SYSDIV from 16 to 8, so the clock is now 40ns per tick */
65
+ rcc = readl(SSYS_BASE + RCC);
66
+ g_assert_cmpuint(extract32(rcc, SYSDIV_SHIFT, SYSDIV_LENGTH), ==, 0xf);
67
+ rcc = deposit32(rcc, SYSDIV_SHIFT, SYSDIV_LENGTH, 7);
68
+ writel(SSYS_BASE + RCC, rcc);
69
+
70
+ /* Just past the 1000th tick: timer should have fired */
71
+ clock_step(40 * 500);
72
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 1);
73
+
74
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 0);
75
+
76
+ /* VALUE reloads at following tick */
77
+ clock_step(41);
78
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 1000);
79
+
80
+ /* Writing any value to WDOGINTCLR clears the interrupt and reloads */
81
+ clock_step(40 * 500);
82
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 500);
83
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 1);
84
+ writel(WDOG_BASE + WDOGINTCLR, 0);
85
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 1000);
86
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0);
87
+}
42
+}
88
+
43
+
89
int main(int argc, char **argv)
44
static void gicr_write_set_bitmap_reg(GICv3CPUState *cs, MemTxAttrs attrs,
45
uint32_t *reg, uint32_t val)
90
{
46
{
91
int r;
47
@@ -XXX,XX +XXX,XX @@ static MemTxResult gicr_readl(GICv3CPUState *cs, hwaddr offset,
92
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv)
48
*data = value;
93
qtest_start("-machine lm3s811evb");
49
return MEMTX_OK;
94
50
}
95
qtest_add_func("/cmsdk-apb-watchdog/watchdog", test_watchdog);
51
+ case GICR_INMIR0:
96
+ qtest_add_func("/cmsdk-apb-watchdog/watchdog_clock_change",
52
+ *data = cs->gic->nmi_support ?
97
+ test_clock_change);
53
+ gicr_read_bitmap_reg(cs, attrs, cs->gicr_inmir0) : 0;
98
54
+ return MEMTX_OK;
99
r = g_test_run();
55
case GICR_ICFGR0:
100
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;
101
--
71
--
102
2.20.1
72
2.34.1
103
104
diff view generated by jsdifflib
1
From: Joelle van Dyne <j@getutm.app>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
Meson will find CoreFoundation, IOKit, and Cocoa as needed.
3
Add GICD_INMIR, GICD_INMIRnE register and support access GICD_INMIR0.
4
4
5
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Joelle van Dyne <j@getutm.app>
8
Message-id: 20240407081733.3231820-18-ruanjinjie@huawei.com
7
Message-id: 20210126012457.39046-7-j@getutm.app
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
---
10
configure | 1 -
11
hw/intc/gicv3_internal.h | 2 ++
11
1 file changed, 1 deletion(-)
12
hw/intc/arm_gicv3_dist.c | 34 ++++++++++++++++++++++++++++++++++
13
2 files changed, 36 insertions(+)
12
14
13
diff --git a/configure b/configure
15
diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h
14
index XXXXXXX..XXXXXXX 100755
16
index XXXXXXX..XXXXXXX 100644
15
--- a/configure
17
--- a/hw/intc/gicv3_internal.h
16
+++ b/configure
18
+++ b/hw/intc/gicv3_internal.h
17
@@ -XXX,XX +XXX,XX @@ Darwin)
19
@@ -XXX,XX +XXX,XX @@
18
fi
20
#define GICD_SGIR 0x0F00
19
audio_drv_list="coreaudio try-sdl"
21
#define GICD_CPENDSGIR 0x0F10
20
audio_possible_drivers="coreaudio sdl"
22
#define GICD_SPENDSGIR 0x0F20
21
- QEMU_LDFLAGS="-framework CoreFoundation -framework IOKit $QEMU_LDFLAGS"
23
+#define GICD_INMIR 0x0F80
22
# Disable attempts to use ObjectiveC features in os/object.h since they
24
+#define GICD_INMIRnE 0x3B00
23
# won't work when we're compiling with gcc as a C compiler.
25
#define GICD_IROUTER 0x6000
24
QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
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;
25
--
87
--
26
2.20.1
88
2.34.1
27
28
diff view generated by jsdifflib
1
Switch the CMSDK APB dualtimer device over to using its Clock input;
1
Add the NMIAR CPU interface registers which deal with acknowledging NMI.
2
the pclk-frq property is now ignored.
3
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
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Luc Michel <luc@lmichel.fr>
6
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20210128114145.20536-20-peter.maydell@linaro.org
9
Message-id: 20210121190622.22000-20-peter.maydell@linaro.org
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
---
19
---
12
hw/timer/cmsdk-apb-dualtimer.c | 42 ++++++++++++++++++++++++++++++----
20
hw/intc/gicv3_internal.h | 5 +
13
1 file changed, 37 insertions(+), 5 deletions(-)
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(-)
14
25
15
diff --git a/hw/timer/cmsdk-apb-dualtimer.c b/hw/timer/cmsdk-apb-dualtimer.c
26
diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h
16
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/timer/cmsdk-apb-dualtimer.c
28
--- a/hw/intc/gicv3_internal.h
18
+++ b/hw/timer/cmsdk-apb-dualtimer.c
29
+++ b/hw/intc/gicv3_internal.h
19
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_dualtimer_update(CMSDKAPBDualTimer *s)
30
@@ -XXX,XX +XXX,XX @@ FIELD(GICR_VPENDBASER, VALID, 63, 1)
20
qemu_set_irq(s->timerintc, timintc);
31
#define ICC_CTLR_EL3_A3V (1U << 15)
21
}
32
#define ICC_CTLR_EL3_NDS (1U << 17)
22
33
23
+static int cmsdk_dualtimermod_divisor(CMSDKAPBDualTimerModule *m)
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)
24
+{
84
+{
25
+ /* Return the divisor set by the current CONTROL.PRESCALE value */
85
+ /* todo */
26
+ switch (FIELD_EX32(m->control, CONTROL, PRESCALE)) {
86
+ uint64_t intid = INTID_SPURIOUS;
27
+ case 0:
87
+ return intid;
28
+ return 1;
29
+ case 1:
30
+ return 16;
31
+ case 2:
32
+ case 3: /* UNDEFINED, we treat like 2 (and complained when it was set) */
33
+ return 256;
34
+ default:
35
+ g_assert_not_reached();
36
+ }
37
+}
88
+}
38
+
89
+
39
static void cmsdk_dualtimermod_write_control(CMSDKAPBDualTimerModule *m,
90
static uint32_t icc_fullprio_mask(GICv3CPUState *cs)
40
uint32_t newctrl)
91
{
41
{
92
/*
42
@@ -XXX,XX +XXX,XX @@ static void cmsdk_dualtimermod_write_control(CMSDKAPBDualTimerModule *m,
93
@@ -XXX,XX +XXX,XX @@ static int icc_highest_active_prio(GICv3CPUState *cs)
43
default:
94
*/
44
g_assert_not_reached();
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;
45
}
228
}
46
- ptimer_set_freq(m->timer, m->parent->pclk_frq / divisor);
229
+
47
+ ptimer_set_period_from_clock(m->timer, m->parent->timclk, divisor);
230
+ if (i == 0 && cs->nmi_support && (*papr & ICC_AP1R_EL1_NMI)) {
48
}
231
+ *papr &= (~ICC_AP1R_EL1_NMI);
49
232
+ break;
50
if (changed & R_CONTROL_MODE_MASK) {
233
+ }
51
@@ -XXX,XX +XXX,XX @@ static void cmsdk_dualtimermod_reset(CMSDKAPBDualTimerModule *m)
234
+
52
* limit must both be set to 0xffff, so we wrap at 16 bits.
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)
53
*/
239
*/
54
ptimer_set_limit(m->timer, 0xffff, 1);
55
- ptimer_set_freq(m->timer, m->parent->pclk_frq);
56
+ ptimer_set_period_from_clock(m->timer, m->parent->timclk,
57
+ cmsdk_dualtimermod_divisor(m));
58
ptimer_transaction_commit(m->timer);
59
}
60
61
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_dualtimer_reset(DeviceState *dev)
62
s->timeritop = 0;
63
}
64
65
+static void cmsdk_apb_dualtimer_clk_update(void *opaque)
66
+{
67
+ CMSDKAPBDualTimer *s = CMSDK_APB_DUALTIMER(opaque);
68
+ int i;
69
+
70
+ for (i = 0; i < ARRAY_SIZE(s->timermod); i++) {
71
+ CMSDKAPBDualTimerModule *m = &s->timermod[i];
72
+ ptimer_transaction_begin(m->timer);
73
+ ptimer_set_period_from_clock(m->timer, m->parent->timclk,
74
+ cmsdk_dualtimermod_divisor(m));
75
+ ptimer_transaction_commit(m->timer);
76
+ }
77
+}
78
+
79
static void cmsdk_apb_dualtimer_init(Object *obj)
80
{
81
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
82
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_dualtimer_init(Object *obj)
83
for (i = 0; i < ARRAY_SIZE(s->timermod); i++) {
84
sysbus_init_irq(sbd, &s->timermod[i].timerint);
85
}
86
- s->timclk = qdev_init_clock_in(DEVICE(s), "TIMCLK", NULL, NULL);
87
+ s->timclk = qdev_init_clock_in(DEVICE(s), "TIMCLK",
88
+ cmsdk_apb_dualtimer_clk_update, s);
89
}
90
91
static void cmsdk_apb_dualtimer_realize(DeviceState *dev, Error **errp)
92
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_dualtimer_realize(DeviceState *dev, Error **errp)
93
CMSDKAPBDualTimer *s = CMSDK_APB_DUALTIMER(dev);
94
int i;
240
int i;
95
241
96
- if (s->pclk_frq == 0) {
242
+ if (cs->nmi_support) {
97
- error_setg(errp, "CMSDK APB timer: pclk-frq property must be set");
243
+ if (cs->icc_apr[GICV3_G1][0] & ICC_AP1R_EL1_NMI) {
98
+ if (!clock_has_source(s->timclk)) {
244
+ return GICV3_G1;
99
+ error_setg(errp, "CMSDK APB dualtimer: TIMCLK clock must be connected");
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,
100
return;
255
return;
101
}
256
}
102
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
103
--
347
--
104
2.20.1
348
2.34.1
105
106
diff view generated by jsdifflib
1
Create and connect the two clocks needed by the ARMSSE.
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
4
If FEAT_GICv3_NMI is supported, ich_ap_write() should consider ICV_AP1R_EL1.NMI
5
bit. In icv_activate_irq() and icv_eoir_write(), the ICV_AP1R_EL1.NMI bit
6
should be set or clear according to the Non-maskable property. And the RPR
7
priority should also update the NMI bit according to the APR priority NMI bit.
8
9
By the way, add gicv3_icv_nmiar1_read trace event.
10
11
If the hpp irq is a NMI, the icv iar read should return 1022 and trap for
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]
17
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
18
Message-id: 20240407081733.3231820-20-ruanjinjie@huawei.com
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
5
Reviewed-by: Luc Michel <luc@lmichel.fr>
6
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Message-id: 20210128114145.20536-16-peter.maydell@linaro.org
8
Message-id: 20210121190622.22000-16-peter.maydell@linaro.org
9
---
20
---
10
hw/arm/musca.c | 12 ++++++++++++
21
hw/intc/gicv3_internal.h | 4 ++
11
1 file changed, 12 insertions(+)
22
hw/intc/arm_gicv3_cpuif.c | 105 +++++++++++++++++++++++++++++++++-----
12
23
hw/intc/trace-events | 1 +
13
diff --git a/hw/arm/musca.c b/hw/arm/musca.c
24
3 files changed, 98 insertions(+), 12 deletions(-)
25
26
diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h
14
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/arm/musca.c
28
--- a/hw/intc/gicv3_internal.h
16
+++ b/hw/arm/musca.c
29
+++ b/hw/intc/gicv3_internal.h
17
@@ -XXX,XX +XXX,XX @@
30
@@ -XXX,XX +XXX,XX @@ FIELD(GICR_VPENDBASER, VALID, 63, 1)
18
#include "hw/misc/tz-ppc.h"
31
#define ICH_LR_EL2_PRIORITY_SHIFT 48
19
#include "hw/misc/unimp.h"
32
#define ICH_LR_EL2_PRIORITY_LENGTH 8
20
#include "hw/rtc/pl031.h"
33
#define ICH_LR_EL2_PRIORITY_MASK (0xffULL << ICH_LR_EL2_PRIORITY_SHIFT)
21
+#include "hw/qdev-clock.h"
34
+#define ICH_LR_EL2_NMI (1ULL << 59)
22
#include "qom/object.h"
35
#define ICH_LR_EL2_GROUP (1ULL << 60)
23
36
#define ICH_LR_EL2_HW (1ULL << 61)
24
#define MUSCA_NUMIRQ_MAX 96
37
#define ICH_LR_EL2_STATE_SHIFT 62
25
@@ -XXX,XX +XXX,XX @@ struct MuscaMachineState {
38
@@ -XXX,XX +XXX,XX @@ FIELD(GICR_VPENDBASER, VALID, 63, 1)
26
UnimplementedDeviceState sdio;
39
#define ICH_VTR_EL2_PREBITS_SHIFT 26
27
UnimplementedDeviceState gpio;
40
#define ICH_VTR_EL2_PRIBITS_SHIFT 29
28
UnimplementedDeviceState cryptoisland;
41
29
+ Clock *sysclk;
42
+#define ICV_AP1R_EL1_NMI (1ULL << 63)
30
+ Clock *s32kclk;
43
+#define ICV_RPR_EL1_NMI (1ULL << 63)
31
};
44
+
32
45
/* ITS Registers */
33
#define TYPE_MUSCA_MACHINE "musca"
46
34
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_TYPE(MuscaMachineState, MuscaMachineClass, MUSCA_MACHINE)
47
FIELD(GITS_BASER, SIZE, 0, 8)
35
* don't model that in our SSE-200 model yet.
48
diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c
36
*/
49
index XXXXXXX..XXXXXXX 100644
37
#define SYSCLK_FRQ 40000000
50
--- a/hw/intc/arm_gicv3_cpuif.c
38
+/* Slow 32Khz S32KCLK frequency in Hz */
51
+++ b/hw/intc/arm_gicv3_cpuif.c
39
+#define S32KCLK_FRQ (32 * 1000)
52
@@ -XXX,XX +XXX,XX @@ static int ich_highest_active_virt_prio(GICv3CPUState *cs)
40
53
int i;
41
static qemu_irq get_sse_irq_in(MuscaMachineState *mms, int irqno)
54
int aprmax = ich_num_aprs(cs);
55
56
+ if (cs->ich_apr[GICV3_G1NS][0] & ICV_AP1R_EL1_NMI) {
57
+ return 0x0;
58
+ }
59
+
60
for (i = 0; i < aprmax; i++) {
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
}
92
}
93
@@ -XXX,XX +XXX,XX @@ static bool icv_hppi_can_preempt(GICv3CPUState *cs, uint64_t lr)
94
* equivalent of these checks.
95
*/
96
int grp;
97
+ bool is_nmi;
98
uint32_t mask, prio, rprio, vpmr;
99
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;
113
}
114
@@ -XXX,XX +XXX,XX @@ static bool icv_hppi_can_preempt(GICv3CPUState *cs, uint64_t lr)
115
return true;
116
}
117
118
+ if ((prio & mask) == (rprio & mask) && is_nmi &&
119
+ !(cs->ich_apr[GICV3_G1NS][0] & ICV_AP1R_EL1_NMI)) {
120
+ return true;
121
+ }
122
+
123
return false;
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)
42
{
141
{
43
@@ -XXX,XX +XXX,XX @@ static void musca_init(MachineState *machine)
142
GICv3CPUState *cs = icc_cs_from_env(env);
44
exit(1);
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);
45
}
305
}
46
306
47
+ mms->sysclk = clock_new(OBJECT(machine), "SYSCLK");
307
+ /* Enforce RES0 bit in NMI field when FEAT_GICv3_NMI is not implemented */
48
+ clock_set_hz(mms->sysclk, SYSCLK_FRQ);
308
+ if (!cs->nmi_support) {
49
+ mms->s32kclk = clock_new(OBJECT(machine), "S32KCLK");
309
+ value &= ~ICH_LR_EL2_NMI;
50
+ clock_set_hz(mms->s32kclk, S32KCLK_FRQ);
310
+ }
51
+
311
+
52
object_initialize_child(OBJECT(machine), "sse-200", &mms->sse,
312
cs->ich_lr_el2[regno] = value;
53
TYPE_SSE200);
313
gicv3_cpuif_virt_update(cs);
54
ssedev = DEVICE(&mms->sse);
314
}
55
@@ -XXX,XX +XXX,XX @@ static void musca_init(MachineState *machine)
315
diff --git a/hw/intc/trace-events b/hw/intc/trace-events
56
qdev_prop_set_uint32(ssedev, "init-svtor", mmc->init_svtor);
316
index XXXXXXX..XXXXXXX 100644
57
qdev_prop_set_uint32(ssedev, "SRAM_ADDR_WIDTH", mmc->sram_addr_width);
317
--- a/hw/intc/trace-events
58
qdev_prop_set_uint32(ssedev, "MAINCLK_FRQ", SYSCLK_FRQ);
318
+++ b/hw/intc/trace-events
59
+ qdev_connect_clock_in(ssedev, "MAINCLK", mms->sysclk);
319
@@ -XXX,XX +XXX,XX @@ gicv3_icv_rpr_read(uint32_t cpu, uint64_t val) "GICv3 ICV_RPR read cpu 0x%x valu
60
+ qdev_connect_clock_in(ssedev, "S32KCLK", mms->s32kclk);
320
gicv3_icv_hppir_read(int grp, uint32_t cpu, uint64_t val) "GICv3 ICV_HPPIR%d read cpu 0x%x value 0x%" PRIx64
61
/*
321
gicv3_icv_dir_write(uint32_t cpu, uint64_t val) "GICv3 ICV_DIR write cpu 0x%x value 0x%" PRIx64
62
* Musca-A takes the default SSE-200 FPU/DSP settings (ie no for
322
gicv3_icv_iar_read(int grp, uint32_t cpu, uint64_t val) "GICv3 ICV_IAR%d read cpu 0x%x value 0x%" PRIx64
63
* CPU0 and yes for CPU1); Musca-B1 explicitly enables them for CPU0.
323
+gicv3_icv_nmiar1_read(uint32_t cpu, uint64_t val) "GICv3 ICV_NMIAR1 read cpu 0x%x value 0x%" PRIx64
324
gicv3_icv_eoir_write(int grp, uint32_t cpu, uint64_t val) "GICv3 ICV_EOIR%d write cpu 0x%x value 0x%" PRIx64
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"
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"
64
--
327
--
65
2.20.1
328
2.34.1
66
67
diff view generated by jsdifflib
1
Use the MAINCLK Clock input to set the system_clock_scale variable
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
rather than using the mainclk_frq property.
3
2
3
If GICD_CTLR_DS bit is zero and the NMI is non-secure, the NMI priority is
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.
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-21-ruanjinjie@huawei.com
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Luc Michel <luc@lmichel.fr>
8
Message-id: 20210128114145.20536-23-peter.maydell@linaro.org
9
Message-id: 20210121190622.22000-23-peter.maydell@linaro.org
10
---
14
---
11
hw/arm/armsse.c | 24 +++++++++++++++++++-----
15
hw/intc/arm_gicv3.c | 67 +++++++++++++++++++++++++++++++++-----
12
1 file changed, 19 insertions(+), 5 deletions(-)
16
hw/intc/arm_gicv3_common.c | 3 ++
17
hw/intc/arm_gicv3_redist.c | 3 ++
18
3 files changed, 64 insertions(+), 9 deletions(-)
13
19
14
diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c
20
diff --git a/hw/intc/arm_gicv3.c b/hw/intc/arm_gicv3.c
15
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/arm/armsse.c
22
--- a/hw/intc/arm_gicv3.c
17
+++ b/hw/arm/armsse.c
23
+++ b/hw/intc/arm_gicv3.c
18
@@ -XXX,XX +XXX,XX @@ static void armsse_forward_sec_resp_cfg(ARMSSE *s)
24
@@ -XXX,XX +XXX,XX @@
19
qdev_connect_gpio_out(dev_splitter, 2, s->sec_resp_cfg_in);
25
#include "hw/intc/arm_gicv3.h"
26
#include "gicv3_internal.h"
27
28
-static bool irqbetter(GICv3CPUState *cs, int irq, uint8_t prio)
29
+static bool irqbetter(GICv3CPUState *cs, int irq, uint8_t prio, bool nmi)
30
{
31
/* Return true if this IRQ at this priority should take
32
* precedence over the current recorded highest priority
33
@@ -XXX,XX +XXX,XX @@ static bool irqbetter(GICv3CPUState *cs, int irq, uint8_t prio)
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;
20
}
62
}
21
63
22
+static void armsse_mainclk_update(void *opaque)
64
+static bool gicv3_get_priority(GICv3CPUState *cs, bool is_redist, int irq,
65
+ uint8_t *prio)
23
+{
66
+{
24
+ ARMSSE *s = ARM_SSE(opaque);
67
+ uint32_t nmi = 0x0;
25
+ /*
68
+
26
+ * Set system_clock_scale from our Clock input; this is what
69
+ if (is_redist) {
27
+ * controls the tick rate of the CPU SysTick timer.
70
+ nmi = extract32(cs->gicr_inmir0, irq, 1);
28
+ */
71
+ } else {
29
+ system_clock_scale = clock_ticks_to_ns(s->mainclk, 1);
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;
84
+ }
85
+
86
+ return true;
87
+ }
88
+
89
+ if (is_redist) {
90
+ *prio = cs->gicr_ipriorityr[irq];
91
+ } else {
92
+ *prio = cs->gic->gicd_ipriority[irq];
93
+ }
94
+
95
+ return false;
30
+}
96
+}
31
+
97
+
32
static void armsse_init(Object *obj)
98
/* Update the interrupt status after state in a redistributor
33
{
99
* or CPU interface has changed, but don't tell the CPU i/f.
34
ARMSSE *s = ARM_SSE(obj);
100
*/
35
@@ -XXX,XX +XXX,XX @@ static void armsse_init(Object *obj)
101
@@ -XXX,XX +XXX,XX @@ static void gicv3_redist_update_noirqset(GICv3CPUState *cs)
36
assert(info->sram_banks <= MAX_SRAM_BANKS);
102
uint8_t prio;
37
assert(info->num_cpus <= SSE_MAX_CPUS);
103
int i;
38
104
uint32_t pend;
39
- s->mainclk = qdev_init_clock_in(DEVICE(s), "MAINCLK", NULL, NULL);
105
+ bool nmi = false;
40
+ s->mainclk = qdev_init_clock_in(DEVICE(s), "MAINCLK",
106
41
+ armsse_mainclk_update, s);
107
/* Find out which redistributor interrupts are eligible to be
42
s->s32kclk = qdev_init_clock_in(DEVICE(s), "S32KCLK", NULL, NULL);
108
* signaled to the CPU interface.
43
109
@@ -XXX,XX +XXX,XX @@ static void gicv3_redist_update_noirqset(GICv3CPUState *cs)
44
memory_region_init(&s->container, obj, "armsse-container", UINT64_MAX);
110
if (!(pend & (1 << i))) {
45
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
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
166
index XXXXXXX..XXXXXXX 100644
167
--- a/hw/intc/arm_gicv3_common.c
168
+++ b/hw/intc/arm_gicv3_common.c
169
@@ -XXX,XX +XXX,XX @@ static void arm_gicv3_common_reset_hold(Object *obj)
170
memset(cs->gicr_ipriorityr, 0, sizeof(cs->gicr_ipriorityr));
171
172
cs->hppi.prio = 0xff;
173
+ cs->hppi.nmi = false;
174
cs->hpplpi.prio = 0xff;
175
+ cs->hpplpi.nmi = false;
176
cs->hppvlpi.prio = 0xff;
177
+ cs->hppvlpi.nmi = false;
178
179
/* State in the CPU interface must *not* be reset here, because it
180
* is part of the CPU's reset domain, not the GIC device's.
181
diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c
182
index XXXXXXX..XXXXXXX 100644
183
--- a/hw/intc/arm_gicv3_redist.c
184
+++ b/hw/intc/arm_gicv3_redist.c
185
@@ -XXX,XX +XXX,XX @@ static void update_for_one_lpi(GICv3CPUState *cs, int irq,
186
((prio == hpp->prio) && (irq <= hpp->irq))) {
187
hpp->irq = irq;
188
hpp->prio = prio;
189
+ hpp->nmi = false;
190
/* LPIs and vLPIs are always non-secure Grp1 interrupts */
191
hpp->grp = GICV3_G1NS;
192
}
193
@@ -XXX,XX +XXX,XX @@ static void update_for_all_lpis(GICv3CPUState *cs, uint64_t ptbase,
194
int i, bit;
195
196
hpp->prio = 0xff;
197
+ hpp->nmi = false;
198
199
for (i = GICV3_LPI_INTID_START / 8; i < pendt_size / 8; i++) {
200
address_space_read(as, ptbase + i, MEMTXATTRS_UNSPECIFIED, &pend, 1);
201
@@ -XXX,XX +XXX,XX @@ static void gicv3_redist_update_vlpi_only(GICv3CPUState *cs)
202
203
if (!FIELD_EX64(cs->gicr_vpendbaser, GICR_VPENDBASER, VALID)) {
204
cs->hppvlpi.prio = 0xff;
205
+ cs->hppvlpi.nmi = false;
46
return;
206
return;
47
}
207
}
48
208
49
- if (!s->mainclk_frq) {
50
- error_setg(errp, "MAINCLK_FRQ property was not set");
51
- return;
52
+ if (!clock_has_source(s->mainclk)) {
53
+ error_setg(errp, "MAINCLK clock was not connected");
54
+ }
55
+ if (!clock_has_source(s->s32kclk)) {
56
+ error_setg(errp, "S32KCLK clock was not connected");
57
}
58
59
assert(info->num_cpus <= SSE_MAX_CPUS);
60
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
61
*/
62
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->container);
63
64
- system_clock_scale = NANOSECONDS_PER_SECOND / s->mainclk_frq;
65
+ /* Set initial system_clock_scale from MAINCLK */
66
+ armsse_mainclk_update(s);
67
}
68
69
static void armsse_idau_check(IDAUInterface *ii, uint32_t address,
70
--
209
--
71
2.20.1
210
2.34.1
72
73
diff view generated by jsdifflib
1
From: Joelle van Dyne <j@getutm.app>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
Add objc to the Meson cross file as well as detection of Darwin.
3
In CPU Interface, if the IRQ has the non-maskable property, report NMI to
4
the corresponding PE.
4
5
6
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Joelle van Dyne <j@getutm.app>
9
Message-id: 20240407081733.3231820-22-ruanjinjie@huawei.com
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20210126012457.39046-8-j@getutm.app
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
---
11
configure | 4 ++++
12
hw/intc/arm_gicv3_cpuif.c | 4 ++++
12
1 file changed, 4 insertions(+)
13
1 file changed, 4 insertions(+)
13
14
14
diff --git a/configure b/configure
15
diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c
15
index XXXXXXX..XXXXXXX 100755
16
index XXXXXXX..XXXXXXX 100644
16
--- a/configure
17
--- a/hw/intc/arm_gicv3_cpuif.c
17
+++ b/configure
18
+++ b/hw/intc/arm_gicv3_cpuif.c
18
@@ -XXX,XX +XXX,XX @@ echo "cpp_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
19
@@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_update(GICv3CPUState *cs)
19
echo "[binaries]" >> $cross
20
/* Tell the CPU about its highest priority pending interrupt */
20
echo "c = [$(meson_quote $cc)]" >> $cross
21
int irqlevel = 0;
21
test -n "$cxx" && echo "cpp = [$(meson_quote $cxx)]" >> $cross
22
int fiqlevel = 0;
22
+test -n "$objcc" && echo "objc = [$(meson_quote $objcc)]" >> $cross
23
+ int nmilevel = 0;
23
echo "ar = [$(meson_quote $ar)]" >> $cross
24
ARMCPU *cpu = ARM_CPU(cs->cpu);
24
echo "nm = [$(meson_quote $nm)]" >> $cross
25
CPUARMState *env = &cpu->env;
25
echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
26
26
@@ -XXX,XX +XXX,XX @@ if test "$cross_compile" = "yes"; then
27
@@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_update(GICv3CPUState *cs)
27
if test "$linux" = "yes" ; then
28
28
echo "system = 'linux'" >> $cross
29
if (isfiq) {
29
fi
30
fiqlevel = 1;
30
+ if test "$darwin" = "yes" ; then
31
+ } else if (cs->hppi.nmi) {
31
+ echo "system = 'darwin'" >> $cross
32
+ nmilevel = 1;
32
+ fi
33
} else {
33
case "$ARCH" in
34
irqlevel = 1;
34
i386|x86_64)
35
}
35
echo "cpu_family = 'x86'" >> $cross
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)
36
--
44
--
37
2.20.1
45
2.34.1
38
39
diff view generated by jsdifflib
1
As the first step in converting the CMSDK_APB_DUALTIMER device to the
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
Clock framework, add a Clock input. For the moment we do nothing
3
with this clock; we will change the behaviour from using the pclk-frq
4
property to using the Clock once all the users of this device have
5
been converted to wire up the Clock.
6
2
7
We take the opportunity to correct the name of the clock input to
3
In vCPU Interface, if the vIRQ has the non-maskable property, report
8
match the hardware -- the dual timer names the clock which drives the
4
vINMI to the corresponding vPE.
9
timers TIMCLK. (It does also have a 'pclk' input, which is used only
10
for the register and APB bus logic; on the SSE-200 these clocks are
11
both connected together.)
12
5
13
This is a migration compatibility break for machines mps2-an385,
6
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
14
mps2-an386, mps2-an500, mps2-an511, mps2-an505, mps2-an521, musca-a,
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
musca-b1.
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20240407081733.3231820-23-ruanjinjie@huawei.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
hw/intc/arm_gicv3_cpuif.c | 14 ++++++++++++--
13
1 file changed, 12 insertions(+), 2 deletions(-)
16
14
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c
18
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
19
Reviewed-by: Luc Michel <luc@lmichel.fr>
20
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
21
Message-id: 20210128114145.20536-9-peter.maydell@linaro.org
22
Message-id: 20210121190622.22000-9-peter.maydell@linaro.org
23
---
24
include/hw/timer/cmsdk-apb-dualtimer.h | 3 +++
25
hw/timer/cmsdk-apb-dualtimer.c | 7 +++++--
26
2 files changed, 8 insertions(+), 2 deletions(-)
27
28
diff --git a/include/hw/timer/cmsdk-apb-dualtimer.h b/include/hw/timer/cmsdk-apb-dualtimer.h
29
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
30
--- a/include/hw/timer/cmsdk-apb-dualtimer.h
17
--- a/hw/intc/arm_gicv3_cpuif.c
31
+++ b/include/hw/timer/cmsdk-apb-dualtimer.h
18
+++ b/hw/intc/arm_gicv3_cpuif.c
32
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_virt_irq_fiq_update(GICv3CPUState *cs)
33
*
20
int idx;
34
* QEMU interface:
21
int irqlevel = 0;
35
* + QOM property "pclk-frq": frequency at which the timer is clocked
22
int fiqlevel = 0;
36
+ * + Clock input "TIMCLK": clock (for both timers)
23
+ int nmilevel = 0;
37
* + sysbus MMIO region 0: the register bank
24
38
* + sysbus IRQ 0: combined timer interrupt TIMINTC
25
idx = hppvi_index(cs);
39
* + sysbus IRO 1: timer block 1 interrupt TIMINT1
26
trace_gicv3_cpuif_virt_update(gicv3_redist_affid(cs), idx,
40
@@ -XXX,XX +XXX,XX @@
27
@@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_virt_irq_fiq_update(GICv3CPUState *cs)
41
28
uint64_t lr = cs->ich_lr_el2[idx];
42
#include "hw/sysbus.h"
29
43
#include "hw/ptimer.h"
30
if (icv_hppi_can_preempt(cs, lr)) {
44
+#include "hw/clock.h"
31
- /* Virtual interrupts are simple: G0 are always FIQ, and G1 IRQ */
45
#include "qom/object.h"
32
+ /*
46
33
+ * Virtual interrupts are simple: G0 are always FIQ, and G1 are
47
#define TYPE_CMSDK_APB_DUALTIMER "cmsdk-apb-dualtimer"
34
+ * IRQ or NMI which depends on the ICH_LR<n>_EL2.NMI to have
48
@@ -XXX,XX +XXX,XX @@ struct CMSDKAPBDualTimer {
35
+ * non-maskable property.
49
MemoryRegion iomem;
36
+ */
50
qemu_irq timerintc;
37
if (lr & ICH_LR_EL2_GROUP) {
51
uint32_t pclk_frq;
38
- irqlevel = 1;
52
+ Clock *timclk;
39
+ if (lr & ICH_LR_EL2_NMI) {
53
40
+ nmilevel = 1;
54
CMSDKAPBDualTimerModule timermod[CMSDK_APB_DUALTIMER_NUM_MODULES];
41
+ } else {
55
uint32_t timeritcr;
42
+ irqlevel = 1;
56
diff --git a/hw/timer/cmsdk-apb-dualtimer.c b/hw/timer/cmsdk-apb-dualtimer.c
43
+ }
57
index XXXXXXX..XXXXXXX 100644
44
} else {
58
--- a/hw/timer/cmsdk-apb-dualtimer.c
45
fiqlevel = 1;
59
+++ b/hw/timer/cmsdk-apb-dualtimer.c
46
}
60
@@ -XXX,XX +XXX,XX @@
47
@@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_virt_irq_fiq_update(GICv3CPUState *cs)
61
#include "hw/irq.h"
48
trace_gicv3_cpuif_virt_set_irqs(gicv3_redist_affid(cs), fiqlevel, irqlevel);
62
#include "hw/qdev-properties.h"
49
qemu_set_irq(cs->parent_vfiq, fiqlevel);
63
#include "hw/registerfields.h"
50
qemu_set_irq(cs->parent_virq, irqlevel);
64
+#include "hw/qdev-clock.h"
51
+ qemu_set_irq(cs->parent_vnmi, nmilevel);
65
#include "hw/timer/cmsdk-apb-dualtimer.h"
66
#include "migration/vmstate.h"
67
68
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_dualtimer_init(Object *obj)
69
for (i = 0; i < ARRAY_SIZE(s->timermod); i++) {
70
sysbus_init_irq(sbd, &s->timermod[i].timerint);
71
}
72
+ s->timclk = qdev_init_clock_in(DEVICE(s), "TIMCLK", NULL, NULL);
73
}
52
}
74
53
75
static void cmsdk_apb_dualtimer_realize(DeviceState *dev, Error **errp)
54
static void gicv3_cpuif_virt_update(GICv3CPUState *cs)
76
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription cmsdk_dualtimermod_vmstate = {
77
78
static const VMStateDescription cmsdk_apb_dualtimer_vmstate = {
79
.name = "cmsdk-apb-dualtimer",
80
- .version_id = 1,
81
- .minimum_version_id = 1,
82
+ .version_id = 2,
83
+ .minimum_version_id = 2,
84
.fields = (VMStateField[]) {
85
+ VMSTATE_CLOCK(timclk, CMSDKAPBDualTimer),
86
VMSTATE_STRUCT_ARRAY(timermod, CMSDKAPBDualTimer,
87
CMSDK_APB_DUALTIMER_NUM_MODULES,
88
1, cmsdk_dualtimermod_vmstate,
89
--
55
--
90
2.20.1
56
2.34.1
91
92
diff view generated by jsdifflib
1
From: Joelle van Dyne <j@getutm.app>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
A workaround added in early days of 64-bit OSX forced x86_64 if the
3
Enable FEAT_NMI on the 'max' CPU.
4
host machine had 64-bit support. This creates issues when cross-
5
compiling for ARM64. Additionally, the user can always use --cpu=* to
6
manually set the host CPU and therefore this workaround should be
7
removed.
8
4
5
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
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: Joelle van Dyne <j@getutm.app>
8
Message-id: 20240407081733.3231820-24-ruanjinjie@huawei.com
11
Message-id: 20210126012457.39046-12-j@getutm.app
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
10
---
14
configure | 11 -----------
11
docs/system/arm/emulation.rst | 1 +
15
1 file changed, 11 deletions(-)
12
target/arm/tcg/cpu64.c | 1 +
13
2 files changed, 2 insertions(+)
16
14
17
diff --git a/configure b/configure
15
diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst
18
index XXXXXXX..XXXXXXX 100755
16
index XXXXXXX..XXXXXXX 100644
19
--- a/configure
17
--- a/docs/system/arm/emulation.rst
20
+++ b/configure
18
+++ b/docs/system/arm/emulation.rst
21
@@ -XXX,XX +XXX,XX @@ fi
19
@@ -XXX,XX +XXX,XX @@ the following architecture extensions:
22
# the correct CPU with the --cpu option.
20
- FEAT_MTE (Memory Tagging Extension)
23
case $targetos in
21
- FEAT_MTE2 (Memory Tagging Extension)
24
Darwin)
22
- FEAT_MTE3 (MTE Asymmetric Fault Handling)
25
- # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
23
+- FEAT_NMI (Non-maskable Interrupt)
26
- # run 64-bit userspace code.
24
- FEAT_NV (Nested Virtualization)
27
- # If the user didn't specify a CPU explicitly and the kernel says this is
25
- FEAT_NV2 (Enhanced nested virtualization support)
28
- # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
26
- FEAT_PACIMP (Pointer authentication - IMPLEMENTATION DEFINED algorithm)
29
- if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
27
diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c
30
- cpu="x86_64"
28
index XXXXXXX..XXXXXXX 100644
31
- fi
29
--- a/target/arm/tcg/cpu64.c
32
HOST_DSOSUF=".dylib"
30
+++ b/target/arm/tcg/cpu64.c
33
;;
31
@@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj)
34
SunOS)
32
t = FIELD_DP64(t, ID_AA64PFR1, RAS_FRAC, 0); /* FEAT_RASv1p1 + FEAT_DoubleFault */
35
@@ -XXX,XX +XXX,XX @@ OpenBSD)
33
t = FIELD_DP64(t, ID_AA64PFR1, SME, 1); /* FEAT_SME */
36
Darwin)
34
t = FIELD_DP64(t, ID_AA64PFR1, CSV2_FRAC, 0); /* FEAT_CSV2_2 */
37
bsd="yes"
35
+ t = FIELD_DP64(t, ID_AA64PFR1, NMI, 1); /* FEAT_NMI */
38
darwin="yes"
36
cpu->isar.id_aa64pfr1 = t;
39
- if [ "$cpu" = "x86_64" ] ; then
37
40
- QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
38
t = cpu->isar.id_aa64mmfr0;
41
- QEMU_LDFLAGS="-arch x86_64 $QEMU_LDFLAGS"
42
- fi
43
audio_drv_list="try-coreaudio try-sdl"
44
audio_possible_drivers="coreaudio sdl"
45
# Disable attempts to use ObjectiveC features in os/object.h since they
46
--
39
--
47
2.20.1
40
2.34.1
48
49
diff view generated by jsdifflib
1
From: Maxim Uvarov <maxim.uvarov@linaro.org>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
No functional change. Just refactor code to better
3
If the CPU implements FEAT_NMI, then turn on the NMI support in the
4
support secure and normal world gpios.
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.
5
8
6
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
9
We don't need to gate the enabling of NMI in the GIC behind a
7
Reviewed-by: Andrew Jones <drjones@redhat.com>
10
machine version property, because none of our current CPUs
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
hw/arm/virt.c | 57 ++++++++++++++++++++++++++++++++-------------------
25
hw/arm/virt.c | 19 +++++++++++++++++++
11
1 file changed, 36 insertions(+), 21 deletions(-)
26
1 file changed, 19 insertions(+)
12
27
13
diff --git a/hw/arm/virt.c b/hw/arm/virt.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/hw/arm/virt.c
30
--- a/hw/arm/virt.c
16
+++ b/hw/arm/virt.c
31
+++ b/hw/arm/virt.c
17
@@ -XXX,XX +XXX,XX @@ static void virt_powerdown_req(Notifier *n, void *opaque)
32
@@ -XXX,XX +XXX,XX @@ static void create_v2m(VirtMachineState *vms)
18
}
33
vms->msi_controller = VIRT_MSI_CTRL_GICV2M;
19
}
34
}
20
35
21
-static void create_gpio(const VirtMachineState *vms)
36
+/*
22
+static void create_gpio_keys(const VirtMachineState *vms,
37
+ * If the CPU has FEAT_NMI, then turn on the NMI support in the GICv3 too.
23
+ DeviceState *pl061_dev,
38
+ * It's permitted to have a configuration with NMI in the CPU (and thus the
24
+ uint32_t phandle)
39
+ * GICv3 CPU interface) but not in the distributor/redistributors, but it's
40
+ * not very useful.
41
+ */
42
+static bool gicv3_nmi_present(VirtMachineState *vms)
25
+{
43
+{
26
+ gpio_key_dev = sysbus_create_simple("gpio-key", -1,
44
+ ARMCPU *cpu = ARM_CPU(qemu_get_cpu(0));
27
+ qdev_get_gpio_in(pl061_dev, 3));
28
+
45
+
29
+ qemu_fdt_add_subnode(vms->fdt, "/gpio-keys");
46
+ return tcg_enabled() && cpu_isar_feature(aa64_nmi, cpu) &&
30
+ qemu_fdt_setprop_string(vms->fdt, "/gpio-keys", "compatible", "gpio-keys");
47
+ (vms->gic_version != VIRT_GIC_VERSION_2);
31
+ qemu_fdt_setprop_cell(vms->fdt, "/gpio-keys", "#size-cells", 0);
32
+ qemu_fdt_setprop_cell(vms->fdt, "/gpio-keys", "#address-cells", 1);
33
+
34
+ qemu_fdt_add_subnode(vms->fdt, "/gpio-keys/poweroff");
35
+ qemu_fdt_setprop_string(vms->fdt, "/gpio-keys/poweroff",
36
+ "label", "GPIO Key Poweroff");
37
+ qemu_fdt_setprop_cell(vms->fdt, "/gpio-keys/poweroff", "linux,code",
38
+ KEY_POWER);
39
+ qemu_fdt_setprop_cells(vms->fdt, "/gpio-keys/poweroff",
40
+ "gpios", phandle, 3, 0);
41
+}
48
+}
42
+
49
+
43
+static void create_gpio_devices(const VirtMachineState *vms, int gpio,
50
static void create_gic(VirtMachineState *vms, MemoryRegion *mem)
44
+ MemoryRegion *mem)
45
{
51
{
46
char *nodename;
52
MachineState *ms = MACHINE(vms);
47
DeviceState *pl061_dev;
53
@@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem)
48
- hwaddr base = vms->memmap[VIRT_GPIO].base;
54
vms->virt);
49
- hwaddr size = vms->memmap[VIRT_GPIO].size;
55
}
50
- int irq = vms->irqmap[VIRT_GPIO];
56
}
51
+ hwaddr base = vms->memmap[gpio].base;
52
+ hwaddr size = vms->memmap[gpio].size;
53
+ int irq = vms->irqmap[gpio];
54
const char compat[] = "arm,pl061\0arm,primecell";
55
+ SysBusDevice *s;
56
57
- pl061_dev = sysbus_create_simple("pl061", base,
58
- qdev_get_gpio_in(vms->gic, irq));
59
+ pl061_dev = qdev_new("pl061");
60
+ s = SYS_BUS_DEVICE(pl061_dev);
61
+ sysbus_realize_and_unref(s, &error_fatal);
62
+ memory_region_add_subregion(mem, base, sysbus_mmio_get_region(s, 0));
63
+ sysbus_connect_irq(s, 0, qdev_get_gpio_in(vms->gic, irq));
64
65
uint32_t phandle = qemu_fdt_alloc_phandle(vms->fdt);
66
nodename = g_strdup_printf("/pl061@%" PRIx64, base);
67
@@ -XXX,XX +XXX,XX @@ static void create_gpio(const VirtMachineState *vms)
68
qemu_fdt_setprop_string(vms->fdt, nodename, "clock-names", "apb_pclk");
69
qemu_fdt_setprop_cell(vms->fdt, nodename, "phandle", phandle);
70
71
- gpio_key_dev = sysbus_create_simple("gpio-key", -1,
72
- qdev_get_gpio_in(pl061_dev, 3));
73
- qemu_fdt_add_subnode(vms->fdt, "/gpio-keys");
74
- qemu_fdt_setprop_string(vms->fdt, "/gpio-keys", "compatible", "gpio-keys");
75
- qemu_fdt_setprop_cell(vms->fdt, "/gpio-keys", "#size-cells", 0);
76
- qemu_fdt_setprop_cell(vms->fdt, "/gpio-keys", "#address-cells", 1);
77
-
78
- qemu_fdt_add_subnode(vms->fdt, "/gpio-keys/poweroff");
79
- qemu_fdt_setprop_string(vms->fdt, "/gpio-keys/poweroff",
80
- "label", "GPIO Key Poweroff");
81
- qemu_fdt_setprop_cell(vms->fdt, "/gpio-keys/poweroff", "linux,code",
82
- KEY_POWER);
83
- qemu_fdt_setprop_cells(vms->fdt, "/gpio-keys/poweroff",
84
- "gpios", phandle, 3, 0);
85
g_free(nodename);
86
+
57
+
87
+ /* Child gpio devices */
58
+ if (gicv3_nmi_present(vms)) {
88
+ create_gpio_keys(vms, pl061_dev, phandle);
59
+ qdev_prop_set_bit(vms->gic, "has-nmi", true);
89
}
60
+ }
90
61
+
91
static void create_virtio_devices(const VirtMachineState *vms)
62
gicbusdev = SYS_BUS_DEVICE(vms->gic);
92
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
63
sysbus_realize_and_unref(gicbusdev, &error_fatal);
93
if (has_ged && aarch64 && firmware_loaded && virt_is_acpi_enabled(vms)) {
64
sysbus_mmio_map(gicbusdev, 0, vms->memmap[VIRT_GIC_DIST].base);
94
vms->acpi_dev = create_acpi_ged(vms);
95
} else {
96
- create_gpio(vms);
97
+ create_gpio_devices(vms, VIRT_GPIO, sysmem);
98
}
99
100
/* connect powerdown request */
101
--
65
--
102
2.20.1
66
2.34.1
103
104
diff view generated by jsdifflib
Deleted patch
1
Move the preadv availability check to meson.build. This is what we
2
want to be doing for host-OS-feature-checks anyway, but it also fixes
3
a problem with building for macOS with the most recent XCode SDK on a
4
Catalina host.
5
1
6
On that configuration, 'preadv()' is provided as a weak symbol, so
7
that programs can be built with optional support for it and make a
8
runtime availability check to see whether the preadv() they have is a
9
working one or one which they must not call because it will
10
runtime-assert. QEMU's configure test passes (unless you're building
11
with --enable-werror) because the test program using preadv()
12
compiles, but then QEMU crashes at runtime when preadv() is called,
13
with errors like:
14
15
dyld: lazy symbol binding failed: Symbol not found: _preadv
16
Referenced from: /Users/pm215/src/qemu/./build/x86/tests/test-replication
17
Expected in: /usr/lib/libSystem.B.dylib
18
19
dyld: Symbol not found: _preadv
20
Referenced from: /Users/pm215/src/qemu/./build/x86/tests/test-replication
21
Expected in: /usr/lib/libSystem.B.dylib
22
23
Meson's own function availability check has a special case for macOS
24
which adds '-Wl,-no_weak_imports' to the compiler flags, which forces
25
the test to require the real function, not the macOS-version-too-old
26
stub.
27
28
So this commit fixes the bug where macOS builds on Catalina currently
29
require --disable-werror.
30
31
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
32
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
33
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
34
Message-id: 20210126155846.17109-1-peter.maydell@linaro.org
35
---
36
configure | 16 ----------------
37
meson.build | 4 +++-
38
2 files changed, 3 insertions(+), 17 deletions(-)
39
40
diff --git a/configure b/configure
41
index XXXXXXX..XXXXXXX 100755
42
--- a/configure
43
+++ b/configure
44
@@ -XXX,XX +XXX,XX @@ if compile_prog "" "" ; then
45
iovec=yes
46
fi
47
48
-##########################################
49
-# preadv probe
50
-cat > $TMPC <<EOF
51
-#include <sys/types.h>
52
-#include <sys/uio.h>
53
-#include <unistd.h>
54
-int main(void) { return preadv(0, 0, 0, 0); }
55
-EOF
56
-preadv=no
57
-if compile_prog "" "" ; then
58
- preadv=yes
59
-fi
60
-
61
##########################################
62
# fdt probe
63
64
@@ -XXX,XX +XXX,XX @@ fi
65
if test "$iovec" = "yes" ; then
66
echo "CONFIG_IOVEC=y" >> $config_host_mak
67
fi
68
-if test "$preadv" = "yes" ; then
69
- echo "CONFIG_PREADV=y" >> $config_host_mak
70
-fi
71
if test "$membarrier" = "yes" ; then
72
echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
73
fi
74
diff --git a/meson.build b/meson.build
75
index XXXXXXX..XXXXXXX 100644
76
--- a/meson.build
77
+++ b/meson.build
78
@@ -XXX,XX +XXX,XX @@ config_host_data.set('HAVE_PTY_H', cc.has_header('pty.h'))
79
config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h'))
80
config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h'))
81
82
+config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include <sys/uio.h>'))
83
+
84
ignored = ['CONFIG_QEMU_INTERP_PREFIX'] # actually per-target
85
arrays = ['CONFIG_AUDIO_DRIVERS', 'CONFIG_BDRV_RW_WHITELIST', 'CONFIG_BDRV_RO_WHITELIST']
86
strings = ['HOST_DSOSUF', 'CONFIG_IASL']
87
@@ -XXX,XX +XXX,XX @@ summary_info += {'PIE': get_option('b_pie')}
88
summary_info += {'static build': config_host.has_key('CONFIG_STATIC')}
89
summary_info += {'malloc trim support': has_malloc_trim}
90
summary_info += {'membarrier': config_host.has_key('CONFIG_MEMBARRIER')}
91
-summary_info += {'preadv support': config_host.has_key('CONFIG_PREADV')}
92
+summary_info += {'preadv support': config_host_data.get('CONFIG_PREADV')}
93
summary_info += {'fdatasync': config_host.has_key('CONFIG_FDATASYNC')}
94
summary_info += {'madvise': config_host.has_key('CONFIG_MADVISE')}
95
summary_info += {'posix_madvise': config_host.has_key('CONFIG_POSIX_MADVISE')}
96
--
97
2.20.1
98
99
diff view generated by jsdifflib
Deleted patch
1
From: Joelle van Dyne <j@getutm.app>
2
1
3
The iOS toolchain does not use the host prefix naming convention. So we
4
need to enable cross-compile options while allowing the PREFIX to be
5
blank.
6
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Signed-off-by: Joelle van Dyne <j@getutm.app>
9
Message-id: 20210126012457.39046-3-j@getutm.app
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
configure | 6 ++++--
13
1 file changed, 4 insertions(+), 2 deletions(-)
14
15
diff --git a/configure b/configure
16
index XXXXXXX..XXXXXXX 100755
17
--- a/configure
18
+++ b/configure
19
@@ -XXX,XX +XXX,XX @@ cpu=""
20
iasl="iasl"
21
interp_prefix="/usr/gnemul/qemu-%M"
22
static="no"
23
+cross_compile="no"
24
cross_prefix=""
25
audio_drv_list=""
26
block_drv_rw_whitelist=""
27
@@ -XXX,XX +XXX,XX @@ for opt do
28
optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
29
case "$opt" in
30
--cross-prefix=*) cross_prefix="$optarg"
31
+ cross_compile="yes"
32
;;
33
--cc=*) CC="$optarg"
34
;;
35
@@ -XXX,XX +XXX,XX @@ $(echo Deprecated targets: $deprecated_targets_list | \
36
--target-list-exclude=LIST exclude a set of targets from the default target-list
37
38
Advanced options (experts only):
39
- --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
40
+ --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
41
--cc=CC use C compiler CC [$cc]
42
--iasl=IASL use ACPI compiler IASL [$iasl]
43
--host-cc=CC use C compiler CC [$host_cc] for code run at
44
@@ -XXX,XX +XXX,XX @@ if has $sdl2_config; then
45
fi
46
echo "strip = [$(meson_quote $strip)]" >> $cross
47
echo "windres = [$(meson_quote $windres)]" >> $cross
48
-if test -n "$cross_prefix"; then
49
+if test "$cross_compile" = "yes"; then
50
cross_arg="--cross-file config-meson.cross"
51
echo "[host_machine]" >> $cross
52
if test "$mingw32" = "yes" ; then
53
--
54
2.20.1
55
56
diff view generated by jsdifflib
1
From: Joelle van Dyne <j@getutm.app>
1
From: Anastasia Belova <abelova@astralinux.ru>
2
2
3
Build without error on hosts without a working system(). If system()
3
In soc_dma_set_request() we try to set a bit in a uint64_t, but we
4
is called, return -1 with ENOSYS.
4
do it with "1 << ch->num", which can't set any bits past 31;
5
any use for a channel number of 32 or more would fail due to
6
integer overflow.
5
7
6
Signed-off-by: Joelle van Dyne <j@getutm.app>
8
This doesn't happen in practice for our current use of this code,
7
Message-id: 20210126012457.39046-6-j@getutm.app
9
because the worst case is when we call soc_dma_init() with an
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.
13
14
Add casts to force the shift to be done as 64-bit arithmetic,
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.]
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
24
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
25
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
26
---
11
meson.build | 1 +
27
hw/dma/soc_dma.c | 4 ++--
12
include/qemu/osdep.h | 12 ++++++++++++
28
1 file changed, 2 insertions(+), 2 deletions(-)
13
2 files changed, 13 insertions(+)
14
29
15
diff --git a/meson.build b/meson.build
30
diff --git a/hw/dma/soc_dma.c b/hw/dma/soc_dma.c
16
index XXXXXXX..XXXXXXX 100644
31
index XXXXXXX..XXXXXXX 100644
17
--- a/meson.build
32
--- a/hw/dma/soc_dma.c
18
+++ b/meson.build
33
+++ b/hw/dma/soc_dma.c
19
@@ -XXX,XX +XXX,XX @@ config_host_data.set('HAVE_DRM_H', cc.has_header('libdrm/drm.h'))
34
@@ -XXX,XX +XXX,XX @@ void soc_dma_set_request(struct soc_dma_ch_s *ch, int level)
20
config_host_data.set('HAVE_PTY_H', cc.has_header('pty.h'))
35
dma->enabled_count += level - ch->enable;
21
config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h'))
36
22
config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h'))
37
if (level)
23
+config_host_data.set('HAVE_SYSTEM_FUNCTION', cc.has_function('system', prefix: '#include <stdlib.h>'))
38
- dma->ch_enable_mask |= 1 << ch->num;
24
39
+ dma->ch_enable_mask |= (uint64_t)1 << ch->num;
25
config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include <sys/uio.h>'))
40
else
26
41
- dma->ch_enable_mask &= ~(1 << ch->num);
27
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
42
+ dma->ch_enable_mask &= ~((uint64_t)1 << ch->num);
28
index XXXXXXX..XXXXXXX 100644
43
29
--- a/include/qemu/osdep.h
44
if (level != ch->enable) {
30
+++ b/include/qemu/osdep.h
45
soc_dma_ch_freq_update(dma);
31
@@ -XXX,XX +XXX,XX @@ static inline void qemu_thread_jit_write(void) {}
32
static inline void qemu_thread_jit_execute(void) {}
33
#endif
34
35
+/**
36
+ * Platforms which do not support system() return ENOSYS
37
+ */
38
+#ifndef HAVE_SYSTEM_FUNCTION
39
+#define system platform_does_not_support_system
40
+static inline int platform_does_not_support_system(const char *command)
41
+{
42
+ errno = ENOSYS;
43
+ return -1;
44
+}
45
+#endif /* !HAVE_SYSTEM_FUNCTION */
46
+
47
#endif
48
--
46
--
49
2.20.1
47
2.34.1
50
51
diff view generated by jsdifflib
1
Create and connect the two clocks needed by the ARMSSE.
1
Ever since the bFLT format support was added in 2006, there has been
2
a chunk of code in the file guarded by CONFIG_BINFMT_SHARED_FLAT
3
which is supposedly for shared library support. This is not enabled
4
and it's not possible to enable it, because if you do you'll run into
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.
2
16
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
18
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
Reviewed-by: Luc Michel <luc@lmichel.fr>
19
Message-id: 20240411115313.680433-1-peter.maydell@linaro.org
6
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Message-id: 20210128114145.20536-15-peter.maydell@linaro.org
8
Message-id: 20210121190622.22000-15-peter.maydell@linaro.org
9
---
20
---
10
hw/arm/mps2-tz.c | 13 +++++++++++++
21
linux-user/flat.h | 5 +-
11
1 file changed, 13 insertions(+)
22
linux-user/flatload.c | 293 ++----------------------------------------
12
23
2 files changed, 11 insertions(+), 287 deletions(-)
13
diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.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/arm/mps2-tz.c
27
--- a/linux-user/flat.h
16
+++ b/hw/arm/mps2-tz.c
28
+++ b/linux-user/flat.h
17
@@ -XXX,XX +XXX,XX @@
29
@@ -XXX,XX +XXX,XX @@
18
#include "hw/net/lan9118.h"
30
19
#include "net/net.h"
31
#define    FLAT_VERSION            0x00000004L
20
#include "hw/core/split-irq.h"
32
21
+#include "hw/qdev-clock.h"
33
-#ifdef CONFIG_BINFMT_SHARED_FLAT
22
#include "qom/object.h"
34
-#define    MAX_SHARED_LIBS            (4)
23
35
-#else
24
#define MPS2TZ_NUMIRQ 92
36
+/* QEMU doesn't support bflt shared libraries */
25
@@ -XXX,XX +XXX,XX @@ struct MPS2TZMachineState {
37
#define    MAX_SHARED_LIBS            (1)
26
qemu_or_irq uart_irq_orgate;
38
-#endif
27
DeviceState *lan9118;
39
28
SplitIRQ cpu_irq_splitter[MPS2TZ_NUMIRQ];
40
/*
29
+ Clock *sysclk;
41
* To make everything easier to port and manage cross platform
30
+ Clock *s32kclk;
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? */
31
};
57
};
32
58
33
#define TYPE_MPS2TZ_MACHINE "mps2tz"
59
-#ifdef CONFIG_BINFMT_SHARED_FLAT
34
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_TYPE(MPS2TZMachineState, MPS2TZMachineClass, MPS2TZ_MACHINE)
60
-static int load_flat_shared_library(int id, struct lib_info *p);
35
61
-#endif
36
/* Main SYSCLK frequency in Hz */
62
-
37
#define SYSCLK_FRQ 20000000
63
struct linux_binprm;
38
+/* Slow 32Khz S32KCLK frequency in Hz */
64
39
+#define S32KCLK_FRQ (32 * 1000)
65
/****************************************************************************/
40
66
@@ -XXX,XX +XXX,XX @@ static int target_pread(int fd, abi_ulong ptr, abi_ulong len,
41
/* Create an alias of an entire original MemoryRegion @orig
67
unlock_user(buf, ptr, len);
42
* located at @base in the memory map.
68
return ret;
43
@@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine)
69
}
44
exit(EXIT_FAILURE);
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;
45
}
270
}
46
271
-#endif
47
+ /* These clocks don't need migration because they are fixed-frequency */
48
+ mms->sysclk = clock_new(OBJECT(machine), "SYSCLK");
49
+ clock_set_hz(mms->sysclk, SYSCLK_FRQ);
50
+ mms->s32kclk = clock_new(OBJECT(machine), "S32KCLK");
51
+ clock_set_hz(mms->s32kclk, S32KCLK_FRQ);
52
+
53
object_initialize_child(OBJECT(machine), TYPE_IOTKIT, &mms->iotkit,
54
mmc->armsse_type);
55
iotkitdev = DEVICE(&mms->iotkit);
56
@@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine)
57
OBJECT(system_memory), &error_abort);
58
qdev_prop_set_uint32(iotkitdev, "EXP_NUMIRQ", MPS2TZ_NUMIRQ);
59
qdev_prop_set_uint32(iotkitdev, "MAINCLK_FRQ", SYSCLK_FRQ);
60
+ qdev_connect_clock_in(iotkitdev, "MAINCLK", mms->sysclk);
61
+ qdev_connect_clock_in(iotkitdev, "S32KCLK", mms->s32kclk);
62
sysbus_realize(SYS_BUS_DEVICE(&mms->iotkit), &error_fatal);
63
272
64
/*
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)
384
{
385
struct lib_info libinfo[MAX_SHARED_LIBS];
386
@@ -XXX,XX +XXX,XX @@ int load_flt_binary(struct linux_binprm *bprm, struct image_info *info)
387
*/
388
start_addr = libinfo[0].entry;
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;
65
--
406
--
66
2.20.1
407
2.34.1
67
408
68
409
diff view generated by jsdifflib
1
As the first step in converting the CMSDK_APB_TIMER device to the
1
The npcm7xx_clk and npcm7xx_gcr device reset methods look at
2
Clock framework, add a Clock input. For the moment we do nothing
2
the ResetType argument and only handle RESET_TYPE_COLD,
3
with this clock; we will change the behaviour from using the pclk-frq
3
producing a warning if another reset type is passed. This
4
property to using the Clock once all the users of this device have
4
is different from how every other three-phase-reset method
5
been converted to wire up the Clock.
5
we have works, and makes it difficult to add new reset types.
6
6
7
Since the device doesn't already have a doc comment for its "QEMU
7
A better pattern is "assume that any reset type you don't know
8
interface", we add one including the new Clock.
8
about should be handled like RESET_TYPE_COLD"; switch these
9
9
devices to do that. Then adding a new reset type will only
10
This is a migration compatibility break for machines mps2-an505,
10
need to touch those devices where its behaviour really needs
11
mps2-an521, musca-a, musca-b1.
11
to be different from the standard cold reset.
12
12
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Reviewed-by: Luc Michel <luc@lmichel.fr>
15
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
16
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
16
Reviewed-by: Luc Michel <luc.michel@amd.com>
17
Message-id: 20210128114145.20536-8-peter.maydell@linaro.org
17
Message-id: 20240412160809.1260625-2-peter.maydell@linaro.org
18
Message-id: 20210121190622.22000-8-peter.maydell@linaro.org
19
---
18
---
20
include/hw/timer/cmsdk-apb-timer.h | 9 +++++++++
19
hw/misc/npcm7xx_clk.c | 13 +++----------
21
hw/timer/cmsdk-apb-timer.c | 7 +++++--
20
hw/misc/npcm7xx_gcr.c | 12 ++++--------
22
2 files changed, 14 insertions(+), 2 deletions(-)
21
2 files changed, 7 insertions(+), 18 deletions(-)
23
22
24
diff --git a/include/hw/timer/cmsdk-apb-timer.h b/include/hw/timer/cmsdk-apb-timer.h
23
diff --git a/hw/misc/npcm7xx_clk.c b/hw/misc/npcm7xx_clk.c
25
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
26
--- a/include/hw/timer/cmsdk-apb-timer.h
25
--- a/hw/misc/npcm7xx_clk.c
27
+++ b/include/hw/timer/cmsdk-apb-timer.h
26
+++ b/hw/misc/npcm7xx_clk.c
28
@@ -XXX,XX +XXX,XX @@
27
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_clk_enter_reset(Object *obj, ResetType type)
29
#include "hw/qdev-properties.h"
28
30
#include "hw/sysbus.h"
29
QEMU_BUILD_BUG_ON(sizeof(s->regs) != sizeof(cold_reset_values));
31
#include "hw/ptimer.h"
30
32
+#include "hw/clock.h"
31
- switch (type) {
33
#include "qom/object.h"
32
- case RESET_TYPE_COLD:
34
33
- memcpy(s->regs, cold_reset_values, sizeof(cold_reset_values));
35
#define TYPE_CMSDK_APB_TIMER "cmsdk-apb-timer"
34
- s->ref_ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
36
OBJECT_DECLARE_SIMPLE_TYPE(CMSDKAPBTimer, CMSDK_APB_TIMER)
35
- npcm7xx_clk_update_all_clocks(s);
37
36
- return;
38
+/*
37
- }
39
+ * QEMU interface:
38
-
40
+ * + QOM property "pclk-frq": frequency at which the timer is clocked
39
+ memcpy(s->regs, cold_reset_values, sizeof(cold_reset_values));
41
+ * + Clock input "pclk": clock for the timer
40
+ s->ref_ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
42
+ * + sysbus MMIO region 0: the register bank
41
+ npcm7xx_clk_update_all_clocks(s);
43
+ * + sysbus IRQ 0: timer interrupt TIMERINT
42
/*
44
+ */
43
* A small number of registers need to be reset on a core domain reset,
45
struct CMSDKAPBTimer {
44
* but no such reset type exists yet.
46
/*< private >*/
45
*/
47
SysBusDevice parent_obj;
46
- qemu_log_mask(LOG_UNIMP, "%s: reset type %d not implemented.",
48
@@ -XXX,XX +XXX,XX @@ struct CMSDKAPBTimer {
47
- __func__, type);
49
qemu_irq timerint;
48
}
50
uint32_t pclk_frq;
49
51
struct ptimer_state *timer;
50
static void npcm7xx_clk_init_clock_hierarchy(NPCM7xxCLKState *s)
52
+ Clock *pclk;
51
diff --git a/hw/misc/npcm7xx_gcr.c b/hw/misc/npcm7xx_gcr.c
53
54
uint32_t ctrl;
55
uint32_t value;
56
diff --git a/hw/timer/cmsdk-apb-timer.c b/hw/timer/cmsdk-apb-timer.c
57
index XXXXXXX..XXXXXXX 100644
52
index XXXXXXX..XXXXXXX 100644
58
--- a/hw/timer/cmsdk-apb-timer.c
53
--- a/hw/misc/npcm7xx_gcr.c
59
+++ b/hw/timer/cmsdk-apb-timer.c
54
+++ b/hw/misc/npcm7xx_gcr.c
60
@@ -XXX,XX +XXX,XX @@
55
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_gcr_enter_reset(Object *obj, ResetType type)
61
#include "hw/sysbus.h"
56
62
#include "hw/irq.h"
57
QEMU_BUILD_BUG_ON(sizeof(s->regs) != sizeof(cold_reset_values));
63
#include "hw/registerfields.h"
58
64
+#include "hw/qdev-clock.h"
59
- switch (type) {
65
#include "hw/timer/cmsdk-apb-timer.h"
60
- case RESET_TYPE_COLD:
66
#include "migration/vmstate.h"
61
- memcpy(s->regs, cold_reset_values, sizeof(s->regs));
67
62
- s->regs[NPCM7XX_GCR_PWRON] = s->reset_pwron;
68
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_init(Object *obj)
63
- s->regs[NPCM7XX_GCR_MDLR] = s->reset_mdlr;
69
s, "cmsdk-apb-timer", 0x1000);
64
- s->regs[NPCM7XX_GCR_INTCR3] = s->reset_intcr3;
70
sysbus_init_mmio(sbd, &s->iomem);
65
- break;
71
sysbus_init_irq(sbd, &s->timerint);
66
- }
72
+ s->pclk = qdev_init_clock_in(DEVICE(s), "pclk", NULL, NULL);
67
+ memcpy(s->regs, cold_reset_values, sizeof(s->regs));
68
+ s->regs[NPCM7XX_GCR_PWRON] = s->reset_pwron;
69
+ s->regs[NPCM7XX_GCR_MDLR] = s->reset_mdlr;
70
+ s->regs[NPCM7XX_GCR_INTCR3] = s->reset_intcr3;
73
}
71
}
74
72
75
static void cmsdk_apb_timer_realize(DeviceState *dev, Error **errp)
73
static void npcm7xx_gcr_realize(DeviceState *dev, Error **errp)
76
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_realize(DeviceState *dev, Error **errp)
77
78
static const VMStateDescription cmsdk_apb_timer_vmstate = {
79
.name = "cmsdk-apb-timer",
80
- .version_id = 1,
81
- .minimum_version_id = 1,
82
+ .version_id = 2,
83
+ .minimum_version_id = 2,
84
.fields = (VMStateField[]) {
85
VMSTATE_PTIMER(timer, CMSDKAPBTimer),
86
+ VMSTATE_CLOCK(pclk, CMSDKAPBTimer),
87
VMSTATE_UINT32(ctrl, CMSDKAPBTimer),
88
VMSTATE_UINT32(value, CMSDKAPBTimer),
89
VMSTATE_UINT32(reload, CMSDKAPBTimer),
90
--
74
--
91
2.20.1
75
2.34.1
92
76
93
77
diff view generated by jsdifflib
1
Remove all the code that sets frequency properties on the CMSDK
1
Rather than directly calling the device's implementation of its 'hold'
2
timer, dualtimer and watchdog devices and on the ARMSSE SoC device:
2
reset phase, call device_cold_reset(). This means we don't have to
3
these properties are unused now that the devices rely on their Clock
3
adjust this callsite when we add another argument to the function
4
inputs instead.
4
signature for the hold and exit reset methods.
5
5
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Luc Michel <luc@lmichel.fr>
8
Reviewed-by: Luc Michel <luc.michel@amd.com>
9
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-id: 20240412160809.1260625-3-peter.maydell@linaro.org
10
Message-id: 20210128114145.20536-24-peter.maydell@linaro.org
11
Message-id: 20210121190622.22000-24-peter.maydell@linaro.org
12
---
10
---
13
hw/arm/armsse.c | 7 -------
11
hw/i2c/allwinner-i2c.c | 3 +--
14
hw/arm/mps2-tz.c | 1 -
12
hw/sensor/adm1272.c | 2 +-
15
hw/arm/mps2.c | 3 ---
13
2 files changed, 2 insertions(+), 3 deletions(-)
16
hw/arm/musca.c | 1 -
17
hw/arm/stellaris.c | 3 ---
18
5 files changed, 15 deletions(-)
19
14
20
diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c
15
diff --git a/hw/i2c/allwinner-i2c.c b/hw/i2c/allwinner-i2c.c
21
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/arm/armsse.c
17
--- a/hw/i2c/allwinner-i2c.c
23
+++ b/hw/arm/armsse.c
18
+++ b/hw/i2c/allwinner-i2c.c
24
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
19
@@ -XXX,XX +XXX,XX @@ static void allwinner_i2c_write(void *opaque, hwaddr offset,
25
* it to the appropriate PPC port; then we can realize the PPC and
20
break;
26
* map its upstream ends to the right place in the container.
21
case TWI_SRST_REG:
27
*/
22
if (((value & TWI_SRST_MASK) == 0) && (s->srst & TWI_SRST_MASK)) {
28
- qdev_prop_set_uint32(DEVICE(&s->timer0), "pclk-frq", s->mainclk_frq);
23
- /* Perform reset */
29
qdev_connect_clock_in(DEVICE(&s->timer0), "pclk", s->mainclk);
24
- allwinner_i2c_reset_hold(OBJECT(s));
30
if (!sysbus_realize(SYS_BUS_DEVICE(&s->timer0), errp)) {
25
+ device_cold_reset(DEVICE(s));
31
return;
26
}
32
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
27
s->srst = value & TWI_SRST_MASK;
33
object_property_set_link(OBJECT(&s->apb_ppc0), "port[0]", OBJECT(mr),
28
break;
34
&error_abort);
29
diff --git a/hw/sensor/adm1272.c b/hw/sensor/adm1272.c
35
36
- qdev_prop_set_uint32(DEVICE(&s->timer1), "pclk-frq", s->mainclk_frq);
37
qdev_connect_clock_in(DEVICE(&s->timer1), "pclk", s->mainclk);
38
if (!sysbus_realize(SYS_BUS_DEVICE(&s->timer1), errp)) {
39
return;
40
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
41
object_property_set_link(OBJECT(&s->apb_ppc0), "port[1]", OBJECT(mr),
42
&error_abort);
43
44
- qdev_prop_set_uint32(DEVICE(&s->dualtimer), "pclk-frq", s->mainclk_frq);
45
qdev_connect_clock_in(DEVICE(&s->dualtimer), "TIMCLK", s->mainclk);
46
if (!sysbus_realize(SYS_BUS_DEVICE(&s->dualtimer), errp)) {
47
return;
48
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
49
/* Devices behind APB PPC1:
50
* 0x4002f000: S32K timer
51
*/
52
- qdev_prop_set_uint32(DEVICE(&s->s32ktimer), "pclk-frq", S32KCLK);
53
qdev_connect_clock_in(DEVICE(&s->s32ktimer), "pclk", s->s32kclk);
54
if (!sysbus_realize(SYS_BUS_DEVICE(&s->s32ktimer), errp)) {
55
return;
56
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
57
qdev_connect_gpio_out(DEVICE(&s->nmi_orgate), 0,
58
qdev_get_gpio_in_named(DEVICE(&s->armv7m), "NMI", 0));
59
60
- qdev_prop_set_uint32(DEVICE(&s->s32kwatchdog), "wdogclk-frq", S32KCLK);
61
qdev_connect_clock_in(DEVICE(&s->s32kwatchdog), "WDOGCLK", s->s32kclk);
62
if (!sysbus_realize(SYS_BUS_DEVICE(&s->s32kwatchdog), errp)) {
63
return;
64
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
65
66
/* 0x40080000 .. 0x4008ffff : ARMSSE second Base peripheral region */
67
68
- qdev_prop_set_uint32(DEVICE(&s->nswatchdog), "wdogclk-frq", s->mainclk_frq);
69
qdev_connect_clock_in(DEVICE(&s->nswatchdog), "WDOGCLK", s->mainclk);
70
if (!sysbus_realize(SYS_BUS_DEVICE(&s->nswatchdog), errp)) {
71
return;
72
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
73
armsse_get_common_irq_in(s, 1));
74
sysbus_mmio_map(SYS_BUS_DEVICE(&s->nswatchdog), 0, 0x40081000);
75
76
- qdev_prop_set_uint32(DEVICE(&s->swatchdog), "wdogclk-frq", s->mainclk_frq);
77
qdev_connect_clock_in(DEVICE(&s->swatchdog), "WDOGCLK", s->mainclk);
78
if (!sysbus_realize(SYS_BUS_DEVICE(&s->swatchdog), errp)) {
79
return;
80
diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c
81
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
82
--- a/hw/arm/mps2-tz.c
31
--- a/hw/sensor/adm1272.c
83
+++ b/hw/arm/mps2-tz.c
32
+++ b/hw/sensor/adm1272.c
84
@@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine)
33
@@ -XXX,XX +XXX,XX @@ static int adm1272_write_data(PMBusDevice *pmdev, const uint8_t *buf,
85
object_property_set_link(OBJECT(&mms->iotkit), "memory",
34
break;
86
OBJECT(system_memory), &error_abort);
35
87
qdev_prop_set_uint32(iotkitdev, "EXP_NUMIRQ", MPS2TZ_NUMIRQ);
36
case ADM1272_MFR_POWER_CYCLE:
88
- qdev_prop_set_uint32(iotkitdev, "MAINCLK_FRQ", SYSCLK_FRQ);
37
- adm1272_exit_reset((Object *)s);
89
qdev_connect_clock_in(iotkitdev, "MAINCLK", mms->sysclk);
38
+ device_cold_reset(DEVICE(s));
90
qdev_connect_clock_in(iotkitdev, "S32KCLK", mms->s32kclk);
39
break;
91
sysbus_realize(SYS_BUS_DEVICE(&mms->iotkit), &error_fatal);
40
92
diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
41
case ADM1272_HYSTERESIS_LOW:
93
index XXXXXXX..XXXXXXX 100644
94
--- a/hw/arm/mps2.c
95
+++ b/hw/arm/mps2.c
96
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
97
object_initialize_child(OBJECT(mms), name, &mms->timer[i],
98
TYPE_CMSDK_APB_TIMER);
99
sbd = SYS_BUS_DEVICE(&mms->timer[i]);
100
- qdev_prop_set_uint32(DEVICE(&mms->timer[i]), "pclk-frq", SYSCLK_FRQ);
101
qdev_connect_clock_in(DEVICE(&mms->timer[i]), "pclk", mms->sysclk);
102
sysbus_realize_and_unref(sbd, &error_fatal);
103
sysbus_mmio_map(sbd, 0, base);
104
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
105
106
object_initialize_child(OBJECT(mms), "dualtimer", &mms->dualtimer,
107
TYPE_CMSDK_APB_DUALTIMER);
108
- qdev_prop_set_uint32(DEVICE(&mms->dualtimer), "pclk-frq", SYSCLK_FRQ);
109
qdev_connect_clock_in(DEVICE(&mms->dualtimer), "TIMCLK", mms->sysclk);
110
sysbus_realize(SYS_BUS_DEVICE(&mms->dualtimer), &error_fatal);
111
sysbus_connect_irq(SYS_BUS_DEVICE(&mms->dualtimer), 0,
112
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
113
sysbus_mmio_map(SYS_BUS_DEVICE(&mms->dualtimer), 0, 0x40002000);
114
object_initialize_child(OBJECT(mms), "watchdog", &mms->watchdog,
115
TYPE_CMSDK_APB_WATCHDOG);
116
- qdev_prop_set_uint32(DEVICE(&mms->watchdog), "wdogclk-frq", SYSCLK_FRQ);
117
qdev_connect_clock_in(DEVICE(&mms->watchdog), "WDOGCLK", mms->sysclk);
118
sysbus_realize(SYS_BUS_DEVICE(&mms->watchdog), &error_fatal);
119
sysbus_connect_irq(SYS_BUS_DEVICE(&mms->watchdog), 0,
120
diff --git a/hw/arm/musca.c b/hw/arm/musca.c
121
index XXXXXXX..XXXXXXX 100644
122
--- a/hw/arm/musca.c
123
+++ b/hw/arm/musca.c
124
@@ -XXX,XX +XXX,XX @@ static void musca_init(MachineState *machine)
125
qdev_prop_set_uint32(ssedev, "EXP_NUMIRQ", mmc->num_irqs);
126
qdev_prop_set_uint32(ssedev, "init-svtor", mmc->init_svtor);
127
qdev_prop_set_uint32(ssedev, "SRAM_ADDR_WIDTH", mmc->sram_addr_width);
128
- qdev_prop_set_uint32(ssedev, "MAINCLK_FRQ", SYSCLK_FRQ);
129
qdev_connect_clock_in(ssedev, "MAINCLK", mms->sysclk);
130
qdev_connect_clock_in(ssedev, "S32KCLK", mms->s32kclk);
131
/*
132
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
133
index XXXXXXX..XXXXXXX 100644
134
--- a/hw/arm/stellaris.c
135
+++ b/hw/arm/stellaris.c
136
@@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
137
if (board->dc1 & (1 << 3)) { /* watchdog present */
138
dev = qdev_new(TYPE_LUMINARY_WATCHDOG);
139
140
- /* system_clock_scale is valid now */
141
- uint32_t mainclk = NANOSECONDS_PER_SECOND / system_clock_scale;
142
- qdev_prop_set_uint32(dev, "wdogclk-frq", mainclk);
143
qdev_connect_clock_in(dev, "WDOGCLK",
144
qdev_get_clock_out(ssys_dev, "SYSCLK"));
145
146
--
42
--
147
2.20.1
43
2.34.1
148
149
diff view generated by jsdifflib
1
Add a simple test of the CMSDK dual timer, since we're about to do
1
We pass a ResetType argument to the Resettable class enter phase
2
some refactoring of how it is clocked.
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.
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
3
23
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
25
Reviewed-by: Luc Michel <luc.michel@amd.com>
6
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
26
Message-id: 20240412160809.1260625-4-peter.maydell@linaro.org
7
Reviewed-by: Luc Michel <luc@lmichel.fr>
8
Message-id: 20210128114145.20536-6-peter.maydell@linaro.org
9
Message-id: 20210121190622.22000-6-peter.maydell@linaro.org
10
---
27
---
11
tests/qtest/cmsdk-apb-dualtimer-test.c | 130 +++++++++++++++++++++++++
28
scripts/coccinelle/reset-type.cocci | 133 ++++++++++++++++++++++++++++
12
MAINTAINERS | 1 +
29
1 file changed, 133 insertions(+)
13
tests/qtest/meson.build | 1 +
30
create mode 100644 scripts/coccinelle/reset-type.cocci
14
3 files changed, 132 insertions(+)
15
create mode 100644 tests/qtest/cmsdk-apb-dualtimer-test.c
16
31
17
diff --git a/tests/qtest/cmsdk-apb-dualtimer-test.c b/tests/qtest/cmsdk-apb-dualtimer-test.c
32
diff --git a/scripts/coccinelle/reset-type.cocci b/scripts/coccinelle/reset-type.cocci
18
new file mode 100644
33
new file mode 100644
19
index XXXXXXX..XXXXXXX
34
index XXXXXXX..XXXXXXX
20
--- /dev/null
35
--- /dev/null
21
+++ b/tests/qtest/cmsdk-apb-dualtimer-test.c
36
+++ b/scripts/coccinelle/reset-type.cocci
22
@@ -XXX,XX +XXX,XX @@
37
@@ -XXX,XX +XXX,XX @@
23
+/*
38
+// Convert device code using three-phase reset to add a ResetType
24
+ * QTest testcase for the CMSDK APB dualtimer device
39
+// argument to implementations of ResettableHoldPhase and
25
+ *
40
+// ResettableEnterPhase methods.
26
+ * Copyright (c) 2021 Linaro Limited
41
+//
27
+ *
42
+// Copyright Linaro Ltd 2024
28
+ * This program is free software; you can redistribute it and/or modify it
43
+// SPDX-License-Identifier: GPL-2.0-or-later
29
+ * under the terms of the GNU General Public License as published by the
44
+//
30
+ * Free Software Foundation; either version 2 of the License, or
45
+// for dir in include hw target; do \
31
+ * (at your option) any later version.
46
+// spatch --macro-file scripts/cocci-macro-file.h \
32
+ *
47
+// --sp-file scripts/coccinelle/reset-type.cocci \
33
+ * This program is distributed in the hope that it will be useful, but WITHOUT
48
+// --keep-comments --smpl-spacing --in-place --include-headers \
34
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
49
+// --dir $dir; done
35
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
50
+//
36
+ * for more details.
51
+// This coccinelle script aims to produce a complete change that needs
37
+ */
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.
38
+
57
+
39
+#include "qemu/osdep.h"
58
+// Look for where we use a function as a ResettableHoldPhase method,
40
+#include "libqtest-single.h"
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
+)
41
+
73
+
42
+/* IoTKit/ARMSSE dualtimer; driven at 25MHz in mps2-an385, so 40ns per tick */
74
+// Look for the definition of the function we found in holdfn_assigned,
43
+#define TIMER_BASE 0x40002000
75
+// and add the new argument. If the function calls a hold function
44
+
76
+// itself (probably chaining to the parent class reset) then add the
45
+#define TIMER1LOAD 0
77
+// new argument there too.
46
+#define TIMER1VALUE 4
78
+@ holdfn_defined @
47
+#define TIMER1CONTROL 8
79
+identifier holdfn_assigned.holdfn;
48
+#define TIMER1INTCLR 0xc
80
+typedef Object;
49
+#define TIMER1RIS 0x10
81
+identifier obj;
50
+#define TIMER1MIS 0x14
82
+expression parent;
51
+#define TIMER1BGLOAD 0x18
83
+@@
52
+
84
+-holdfn(Object *obj)
53
+#define TIMER2LOAD 0x20
85
++holdfn(Object *obj, ResetType type)
54
+#define TIMER2VALUE 0x24
55
+#define TIMER2CONTROL 0x28
56
+#define TIMER2INTCLR 0x2c
57
+#define TIMER2RIS 0x30
58
+#define TIMER2MIS 0x34
59
+#define TIMER2BGLOAD 0x38
60
+
61
+#define CTRL_ENABLE (1 << 7)
62
+#define CTRL_PERIODIC (1 << 6)
63
+#define CTRL_INTEN (1 << 5)
64
+#define CTRL_PRESCALE_1 (0 << 2)
65
+#define CTRL_PRESCALE_16 (1 << 2)
66
+#define CTRL_PRESCALE_256 (2 << 2)
67
+#define CTRL_32BIT (1 << 1)
68
+#define CTRL_ONESHOT (1 << 0)
69
+
70
+static void test_dualtimer(void)
71
+{
86
+{
72
+ g_assert_true(readl(TIMER_BASE + TIMER1RIS) == 0);
87
+ <...
73
+
88
+- parent.hold(obj)
74
+ /* Start timer: will fire after 40000 ns */
89
++ parent.hold(obj, type)
75
+ writel(TIMER_BASE + TIMER1LOAD, 1000);
90
+ ...>
76
+ /* enable in free-running, wrapping, interrupt mode */
77
+ writel(TIMER_BASE + TIMER1CONTROL, CTRL_ENABLE | CTRL_INTEN);
78
+
79
+ /* Step to just past the 500th tick and check VALUE */
80
+ clock_step(500 * 40 + 1);
81
+ g_assert_cmpuint(readl(TIMER_BASE + TIMER1RIS), ==, 0);
82
+ g_assert_cmpuint(readl(TIMER_BASE + TIMER1VALUE), ==, 500);
83
+
84
+ /* Just past the 1000th tick: timer should have fired */
85
+ clock_step(500 * 40);
86
+ g_assert_cmpuint(readl(TIMER_BASE + TIMER1RIS), ==, 1);
87
+ g_assert_cmpuint(readl(TIMER_BASE + TIMER1VALUE), ==, 0);
88
+
89
+ /*
90
+ * We are in free-running wrapping 16-bit mode, so on the following
91
+ * tick VALUE should have wrapped round to 0xffff.
92
+ */
93
+ clock_step(40);
94
+ g_assert_cmpuint(readl(TIMER_BASE + TIMER1VALUE), ==, 0xffff);
95
+
96
+ /* Check that any write to INTCLR clears interrupt */
97
+ writel(TIMER_BASE + TIMER1INTCLR, 1);
98
+ g_assert_cmpuint(readl(TIMER_BASE + TIMER1RIS), ==, 0);
99
+
100
+ /* Turn off the timer */
101
+ writel(TIMER_BASE + TIMER1CONTROL, 0);
102
+}
91
+}
103
+
92
+
104
+static void test_prescale(void)
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)
105
+{
114
+{
106
+ g_assert_true(readl(TIMER_BASE + TIMER2RIS) == 0);
115
+ <...
107
+
116
+- parent.exit(obj)
108
+ /* Start timer: will fire after 40 * 256 * 1000 == 1024000 ns */
117
++ parent.exit(obj, type)
109
+ writel(TIMER_BASE + TIMER2LOAD, 1000);
118
+ ...>
110
+ /* enable in periodic, wrapping, interrupt mode, prescale 256 */
111
+ writel(TIMER_BASE + TIMER2CONTROL,
112
+ CTRL_ENABLE | CTRL_INTEN | CTRL_PERIODIC | CTRL_PRESCALE_256);
113
+
114
+ /* Step to just past the 500th tick and check VALUE */
115
+ clock_step(40 * 256 * 501);
116
+ g_assert_cmpuint(readl(TIMER_BASE + TIMER2RIS), ==, 0);
117
+ g_assert_cmpuint(readl(TIMER_BASE + TIMER2VALUE), ==, 500);
118
+
119
+ /* Just past the 1000th tick: timer should have fired */
120
+ clock_step(40 * 256 * 500);
121
+ g_assert_cmpuint(readl(TIMER_BASE + TIMER2RIS), ==, 1);
122
+ g_assert_cmpuint(readl(TIMER_BASE + TIMER2VALUE), ==, 0);
123
+
124
+ /* In periodic mode the tick VALUE now reloads */
125
+ clock_step(40 * 256);
126
+ g_assert_cmpuint(readl(TIMER_BASE + TIMER2VALUE), ==, 1000);
127
+
128
+ /* Check that any write to INTCLR clears interrupt */
129
+ writel(TIMER_BASE + TIMER2INTCLR, 1);
130
+ g_assert_cmpuint(readl(TIMER_BASE + TIMER2RIS), ==, 0);
131
+
132
+ /* Turn off the timer */
133
+ writel(TIMER_BASE + TIMER2CONTROL, 0);
134
+}
119
+}
135
+
120
+
136
+int main(int argc, char **argv)
121
+// SPECIAL CASES ONLY BELOW HERE
137
+{
122
+// We use a python scripted constraint on the position of the match
138
+ int r;
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".
139
+
126
+
140
+ g_test_init(&argc, &argv, NULL);
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);
141
+
133
+
142
+ qtest_start("-machine mps2-an385");
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
+
143
+
144
+ qtest_add_func("/cmsdk-apb-dualtimer/dualtimer", test_dualtimer);
144
+// Special case: in resettable_phase_hold() and resettable_phase_exit()
145
+ qtest_add_func("/cmsdk-apb-dualtimer/prescale", test_prescale);
145
+// we need to pass through the ResetType argument to the method being called
146
+
146
+@ resettable_phase_hold @
147
+ r = g_test_run();
147
+expression obj;
148
+
148
+identifier rc;
149
+ qtest_end();
149
+position p : script:python() { p[0].current_element == "resettable_phase_hold" };
150
+
150
+@@
151
+ return r;
151
+- rc->phases.hold(obj)@p
152
+}
152
++ rc->phases.hold(obj, type)
153
diff --git a/MAINTAINERS b/MAINTAINERS
153
+@ resettable_phase_exit @
154
index XXXXXXX..XXXXXXX 100644
154
+expression obj;
155
--- a/MAINTAINERS
155
+identifier rc;
156
+++ b/MAINTAINERS
156
+position p : script:python() { p[0].current_element == "resettable_phase_exit" };
157
@@ -XXX,XX +XXX,XX @@ F: include/hw/timer/cmsdk-apb-timer.h
157
+@@
158
F: tests/qtest/cmsdk-apb-timer-test.c
158
+- rc->phases.exit(obj)@p
159
F: hw/timer/cmsdk-apb-dualtimer.c
159
++ rc->phases.exit(obj, type)
160
F: include/hw/timer/cmsdk-apb-dualtimer.h
160
+// Special case: the typedefs for the methods need to declare the new argument
161
+F: tests/qtest/cmsdk-apb-dualtimer-test.c
161
+@ phase_typedef_hold @
162
F: hw/char/cmsdk-apb-uart.c
162
+identifier obj;
163
F: include/hw/char/cmsdk-apb-uart.h
163
+@@
164
F: hw/watchdog/cmsdk-apb-watchdog.c
164
+- typedef void (*ResettableHoldPhase)(Object *obj);
165
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
165
++ typedef void (*ResettableHoldPhase)(Object *obj, ResetType type);
166
index XXXXXXX..XXXXXXX 100644
166
+@ phase_typedef_exit @
167
--- a/tests/qtest/meson.build
167
+identifier obj;
168
+++ b/tests/qtest/meson.build
168
+@@
169
@@ -XXX,XX +XXX,XX @@ qtests_npcm7xx = \
169
+- typedef void (*ResettableExitPhase)(Object *obj);
170
'npcm7xx_timer-test',
170
++ typedef void (*ResettableExitPhase)(Object *obj, ResetType type);
171
'npcm7xx_watchdog_timer-test']
172
qtests_arm = \
173
+ (config_all_devices.has_key('CONFIG_CMSDK_APB_DUALTIMER') ? ['cmsdk-apb-dualtimer-test'] : []) + \
174
(config_all_devices.has_key('CONFIG_CMSDK_APB_TIMER') ? ['cmsdk-apb-timer-test'] : []) + \
175
(config_all_devices.has_key('CONFIG_CMSDK_APB_WATCHDOG') ? ['cmsdk-apb-watchdog-test'] : []) + \
176
(config_all_devices.has_key('CONFIG_PFLASH_CFI02') ? ['pflash-cfi02-test'] : []) + \
177
--
171
--
178
2.20.1
172
2.34.1
179
180
diff view generated by jsdifflib
1
Convert the SSYS code in the Stellaris boards (which encapsulates the
1
We pass a ResetType argument to the Resettable class enter
2
system registers) to a proper QOM device. This will provide us with
2
phase method, but we don't pass it to hold and exit, even though
3
somewhere to put the output Clock whose frequency depends on the
3
the callsites have it readily available. This means that if
4
setting of the PLL configuration registers.
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.
5
7
6
This is a migration compatibility break for lm3s811evb, lm3s6965evb.
8
Commit created with
7
9
8
We use 3-phase reset here because the Clock will need to propagate
10
for dir in hw target include; do \
9
its value in the hold phase.
11
spatch --macro-file scripts/cocci-macro-file.h \
12
--sp-file scripts/coccinelle/reset-type.cocci \
13
--keep-comments --smpl-spacing --in-place \
14
--include-headers --dir $dir; done
10
15
11
For the moment we reset the device during the board creation so that
16
and no manual edits.
12
the system_clock_scale global gets set; this will be removed in a
13
subsequent commit.
14
17
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Luc Michel <luc@lmichel.fr>
19
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
17
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
20
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
18
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
21
Reviewed-by: Luc Michel <luc.michel@amd.com>
19
Message-id: 20210128114145.20536-17-peter.maydell@linaro.org
22
Message-id: 20240412160809.1260625-5-peter.maydell@linaro.org
20
Message-id: 20210121190622.22000-17-peter.maydell@linaro.org
21
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
22
---
23
---
23
hw/arm/stellaris.c | 132 ++++++++++++++++++++++++++++++++++++---------
24
include/hw/resettable.h | 4 ++--
24
1 file changed, 107 insertions(+), 25 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(-)
25
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);
26
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
194
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
27
index XXXXXXX..XXXXXXX 100644
195
index XXXXXXX..XXXXXXX 100644
28
--- a/hw/arm/stellaris.c
196
--- a/hw/arm/stellaris.c
29
+++ b/hw/arm/stellaris.c
197
+++ b/hw/arm/stellaris.c
30
@@ -XXX,XX +XXX,XX @@ static void stellaris_gptm_realize(DeviceState *dev, Error **errp)
198
@@ -XXX,XX +XXX,XX @@ static void stellaris_sys_reset_enter(Object *obj, ResetType type)
31
199
s->dcgc[0] = 1;
32
/* System controller. */
200
}
33
201
34
-typedef struct {
202
-static void stellaris_sys_reset_hold(Object *obj)
35
+#define TYPE_STELLARIS_SYS "stellaris-sys"
203
+static void stellaris_sys_reset_hold(Object *obj, ResetType type)
36
+OBJECT_DECLARE_SIMPLE_TYPE(ssys_state, STELLARIS_SYS)
204
{
37
+
205
ssys_state *s = STELLARIS_SYS(obj);
38
+struct ssys_state {
206
39
+ SysBusDevice parent_obj;
207
@@ -XXX,XX +XXX,XX @@ static void stellaris_sys_reset_hold(Object *obj)
40
+
208
ssys_calculate_system_clock(s, true);
41
MemoryRegion iomem;
209
}
42
uint32_t pborctl;
210
43
uint32_t ldopctl;
211
-static void stellaris_sys_reset_exit(Object *obj)
44
@@ -XXX,XX +XXX,XX @@ typedef struct {
212
+static void stellaris_sys_reset_exit(Object *obj, ResetType type)
45
uint32_t dcgc[3];
213
{
46
uint32_t clkvclr;
214
}
47
uint32_t ldoarst;
215
48
+ qemu_irq irq;
216
@@ -XXX,XX +XXX,XX @@ static void stellaris_i2c_reset_enter(Object *obj, ResetType type)
49
+ /* Properties (all read-only registers) */
217
i2c_end_transfer(s->bus);
50
uint32_t user0;
218
}
51
uint32_t user1;
219
52
- qemu_irq irq;
220
-static void stellaris_i2c_reset_hold(Object *obj)
53
- stellaris_board_info *board;
221
+static void stellaris_i2c_reset_hold(Object *obj, ResetType type)
54
-} ssys_state;
222
{
55
+ uint32_t did0;
223
stellaris_i2c_state *s = STELLARIS_I2C(obj);
56
+ uint32_t did1;
224
57
+ uint32_t dc0;
225
@@ -XXX,XX +XXX,XX @@ static void stellaris_i2c_reset_hold(Object *obj)
58
+ uint32_t dc1;
226
s->mcr = 0;
59
+ uint32_t dc2;
227
}
60
+ uint32_t dc3;
228
61
+ uint32_t dc4;
229
-static void stellaris_i2c_reset_exit(Object *obj)
62
+};
230
+static void stellaris_i2c_reset_exit(Object *obj, ResetType type)
63
231
{
64
static void ssys_update(ssys_state *s)
232
stellaris_i2c_state *s = STELLARIS_I2C(obj);
65
{
233
66
@@ -XXX,XX +XXX,XX @@ static uint32_t pllcfg_fury[16] = {
234
@@ -XXX,XX +XXX,XX @@ static void stellaris_adc_trigger(void *opaque, int irq, int level)
67
235
}
68
static int ssys_board_class(const ssys_state *s)
236
}
69
{
237
70
- uint32_t did0 = s->board->did0;
238
-static void stellaris_adc_reset_hold(Object *obj)
71
+ uint32_t did0 = s->did0;
239
+static void stellaris_adc_reset_hold(Object *obj, ResetType type)
72
switch (did0 & DID0_VER_MASK) {
240
{
73
case DID0_VER_0:
241
StellarisADCState *s = STELLARIS_ADC(obj);
74
return DID0_CLASS_SANDSTORM;
242
int n;
75
@@ -XXX,XX +XXX,XX @@ static uint64_t ssys_read(void *opaque, hwaddr offset,
243
diff --git a/hw/audio/asc.c b/hw/audio/asc.c
76
244
index XXXXXXX..XXXXXXX 100644
77
switch (offset) {
245
--- a/hw/audio/asc.c
78
case 0x000: /* DID0 */
246
+++ b/hw/audio/asc.c
79
- return s->board->did0;
247
@@ -XXX,XX +XXX,XX @@ static void asc_fifo_init(ASCFIFOState *fs, int index)
80
+ return s->did0;
248
g_free(name);
81
case 0x004: /* DID1 */
249
}
82
- return s->board->did1;
250
83
+ return s->did1;
251
-static void asc_reset_hold(Object *obj)
84
case 0x008: /* DC0 */
252
+static void asc_reset_hold(Object *obj, ResetType type)
85
- return s->board->dc0;
253
{
86
+ return s->dc0;
254
ASCState *s = ASC(obj);
87
case 0x010: /* DC1 */
255
88
- return s->board->dc1;
256
diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c
89
+ return s->dc1;
257
index XXXXXXX..XXXXXXX 100644
90
case 0x014: /* DC2 */
258
--- a/hw/char/cadence_uart.c
91
- return s->board->dc2;
259
+++ b/hw/char/cadence_uart.c
92
+ return s->dc2;
260
@@ -XXX,XX +XXX,XX @@ static void cadence_uart_reset_init(Object *obj, ResetType type)
93
case 0x018: /* DC3 */
261
s->r[R_TTRIG] = 0x00000020;
94
- return s->board->dc3;
262
}
95
+ return s->dc3;
263
96
case 0x01c: /* DC4 */
264
-static void cadence_uart_reset_hold(Object *obj)
97
- return s->board->dc4;
265
+static void cadence_uart_reset_hold(Object *obj, ResetType type)
98
+ return s->dc4;
266
{
99
case 0x030: /* PBORCTL */
267
CadenceUARTState *s = CADENCE_UART(obj);
100
return s->pborctl;
268
101
case 0x034: /* LDOPCTL */
269
diff --git a/hw/char/sifive_uart.c b/hw/char/sifive_uart.c
102
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps ssys_ops = {
270
index XXXXXXX..XXXXXXX 100644
103
.endianness = DEVICE_NATIVE_ENDIAN,
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
}
104
};
452
};
105
453
106
-static void ssys_reset(void *opaque)
454
-static void adb_bus_reset_hold(Object *obj)
107
+static void stellaris_sys_reset_enter(Object *obj, ResetType type)
455
+static void adb_bus_reset_hold(Object *obj, ResetType type)
108
{
456
{
109
- ssys_state *s = (ssys_state *)opaque;
457
ADBBusState *adb_bus = ADB_BUS(obj);
110
+ ssys_state *s = STELLARIS_SYS(obj);
458
111
459
diff --git a/hw/input/ps2.c b/hw/input/ps2.c
112
s->pborctl = 0x7ffd;
460
index XXXXXXX..XXXXXXX 100644
113
s->rcc = 0x078e3ac0;
461
--- a/hw/input/ps2.c
114
@@ -XXX,XX +XXX,XX @@ static void ssys_reset(void *opaque)
462
+++ b/hw/input/ps2.c
115
s->rcgc[0] = 1;
463
@@ -XXX,XX +XXX,XX @@ void ps2_write_mouse(PS2MouseState *s, int val)
116
s->scgc[0] = 1;
464
}
117
s->dcgc[0] = 1;
465
}
118
+}
466
119
+
467
-static void ps2_reset_hold(Object *obj)
120
+static void stellaris_sys_reset_hold(Object *obj)
468
+static void ps2_reset_hold(Object *obj, ResetType type)
121
+{
469
{
122
+ ssys_state *s = STELLARIS_SYS(obj);
470
PS2State *s = PS2_DEVICE(obj);
123
+
471
124
ssys_calculate_system_clock(s);
472
@@ -XXX,XX +XXX,XX @@ static void ps2_reset_hold(Object *obj)
125
}
473
ps2_reset_queue(s);
126
474
}
127
+static void stellaris_sys_reset_exit(Object *obj)
475
128
+{
476
-static void ps2_reset_exit(Object *obj)
129
+}
477
+static void ps2_reset_exit(Object *obj, ResetType type)
130
+
478
{
131
static int stellaris_sys_post_load(void *opaque, int version_id)
479
PS2State *s = PS2_DEVICE(obj);
132
{
480
133
ssys_state *s = opaque;
481
@@ -XXX,XX +XXX,XX @@ static void ps2_common_post_load(PS2State *s)
134
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_stellaris_sys = {
482
q->cwptr = ccount ? (q->rptr + ccount) & (PS2_BUFFER_SIZE - 1) : -1;
135
}
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,
136
};
684
};
137
685
138
+static Property stellaris_sys_properties[] = {
686
-static void iosb_reset_hold(Object *obj)
139
+ DEFINE_PROP_UINT32("user0", ssys_state, user0, 0),
687
+static void iosb_reset_hold(Object *obj, ResetType type)
140
+ DEFINE_PROP_UINT32("user1", ssys_state, user1, 0),
688
{
141
+ DEFINE_PROP_UINT32("did0", ssys_state, did0, 0),
689
IOSBState *s = IOSB(obj);
142
+ DEFINE_PROP_UINT32("did1", ssys_state, did1, 0),
690
143
+ DEFINE_PROP_UINT32("dc0", ssys_state, dc0, 0),
691
diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c
144
+ DEFINE_PROP_UINT32("dc1", ssys_state, dc1, 0),
692
index XXXXXXX..XXXXXXX 100644
145
+ DEFINE_PROP_UINT32("dc2", ssys_state, dc2, 0),
693
--- a/hw/misc/mac_via.c
146
+ DEFINE_PROP_UINT32("dc3", ssys_state, dc3, 0),
694
+++ b/hw/misc/mac_via.c
147
+ DEFINE_PROP_UINT32("dc4", ssys_state, dc4, 0),
695
@@ -XXX,XX +XXX,XX @@ static int via1_post_load(void *opaque, int version_id)
148
+ DEFINE_PROP_END_OF_LIST()
696
}
149
+};
697
150
+
698
/* VIA 1 */
151
+static void stellaris_sys_instance_init(Object *obj)
699
-static void mos6522_q800_via1_reset_hold(Object *obj)
152
+{
700
+static void mos6522_q800_via1_reset_hold(Object *obj, ResetType type)
153
+ ssys_state *s = STELLARIS_SYS(obj);
701
{
154
+ SysBusDevice *sbd = SYS_BUS_DEVICE(s);
702
MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(obj);
155
+
703
MOS6522State *ms = MOS6522(v1s);
156
+ memory_region_init_io(&s->iomem, obj, &ssys_ops, s, "ssys", 0x00001000);
704
@@ -XXX,XX +XXX,XX @@ static void mos6522_q800_via1_reset_hold(Object *obj)
157
+ sysbus_init_mmio(sbd, &s->iomem);
705
ADBBusState *adb_bus = &v1s->adb_bus;
158
+ sysbus_init_irq(sbd, &s->irq);
706
159
+}
707
if (mdc->parent_phases.hold) {
160
+
708
- mdc->parent_phases.hold(obj);
161
static int stellaris_sys_init(uint32_t base, qemu_irq irq,
709
+ mdc->parent_phases.hold(obj, type);
162
stellaris_board_info * board,
710
}
163
uint8_t *macaddr)
711
164
{
712
ms->timers[0].frequency = VIA_TIMER_FREQ;
165
- ssys_state *s;
713
@@ -XXX,XX +XXX,XX @@ static void mos6522_q800_via2_portB_write(MOS6522State *s)
166
+ DeviceState *dev = qdev_new(TYPE_STELLARIS_SYS);
714
}
167
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
715
}
168
716
169
- s = g_new0(ssys_state, 1);
717
-static void mos6522_q800_via2_reset_hold(Object *obj)
170
- s->irq = irq;
718
+static void mos6522_q800_via2_reset_hold(Object *obj, ResetType type)
171
- s->board = board;
719
{
172
/* Most devices come preprogrammed with a MAC address in the user data. */
720
MOS6522State *ms = MOS6522(obj);
173
- s->user0 = macaddr[0] | (macaddr[1] << 8) | (macaddr[2] << 16);
721
MOS6522DeviceClass *mdc = MOS6522_GET_CLASS(ms);
174
- s->user1 = macaddr[3] | (macaddr[4] << 8) | (macaddr[5] << 16);
722
175
+ qdev_prop_set_uint32(dev, "user0",
723
if (mdc->parent_phases.hold) {
176
+ macaddr[0] | (macaddr[1] << 8) | (macaddr[2] << 16));
724
- mdc->parent_phases.hold(obj);
177
+ qdev_prop_set_uint32(dev, "user1",
725
+ mdc->parent_phases.hold(obj, type);
178
+ macaddr[3] | (macaddr[4] << 8) | (macaddr[5] << 16));
726
}
179
+ qdev_prop_set_uint32(dev, "did0", board->did0);
727
180
+ qdev_prop_set_uint32(dev, "did1", board->did1);
728
ms->timers[0].frequency = VIA_TIMER_FREQ;
181
+ qdev_prop_set_uint32(dev, "dc0", board->dc0);
729
diff --git a/hw/misc/macio/cuda.c b/hw/misc/macio/cuda.c
182
+ qdev_prop_set_uint32(dev, "dc1", board->dc1);
730
index XXXXXXX..XXXXXXX 100644
183
+ qdev_prop_set_uint32(dev, "dc2", board->dc2);
731
--- a/hw/misc/macio/cuda.c
184
+ qdev_prop_set_uint32(dev, "dc3", board->dc3);
732
+++ b/hw/misc/macio/cuda.c
185
+ qdev_prop_set_uint32(dev, "dc4", board->dc4);
733
@@ -XXX,XX +XXX,XX @@ static void mos6522_cuda_portB_write(MOS6522State *s)
186
+
734
cuda_update(cs);
187
+ sysbus_realize_and_unref(sbd, &error_fatal);
735
}
188
+ sysbus_mmio_map(sbd, 0, base);
736
189
+ sysbus_connect_irq(sbd, 0, irq);
737
-static void mos6522_cuda_reset_hold(Object *obj)
190
+
738
+static void mos6522_cuda_reset_hold(Object *obj, ResetType type)
191
+ /*
739
{
192
+ * Normally we should not be resetting devices like this during
740
MOS6522State *ms = MOS6522(obj);
193
+ * board creation. For the moment we need to do so, because
741
MOS6522DeviceClass *mdc = MOS6522_GET_CLASS(ms);
194
+ * system_clock_scale will only get set when the STELLARIS_SYS
742
195
+ * device is reset, and we need its initial value to pass to
743
if (mdc->parent_phases.hold) {
196
+ * the watchdog device. This hack can be removed once the
744
- mdc->parent_phases.hold(obj);
197
+ * watchdog has been converted to use a Clock input instead.
745
+ mdc->parent_phases.hold(obj, type);
198
+ */
746
}
199
+ device_cold_reset(dev);
747
200
748
ms->timers[0].frequency = CUDA_TIMER_FREQ;
201
- memory_region_init_io(&s->iomem, NULL, &ssys_ops, s, "ssys", 0x00001000);
749
diff --git a/hw/misc/macio/pmu.c b/hw/misc/macio/pmu.c
202
- memory_region_add_subregion(get_system_memory(), base, &s->iomem);
750
index XXXXXXX..XXXXXXX 100644
203
- ssys_reset(s);
751
--- a/hw/misc/macio/pmu.c
204
- vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY, &vmstate_stellaris_sys, s);
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,
205
return 0;
1308
return 0;
206
}
1309
}
207
1310
208
-
1311
-static void max31785_exit_reset(Object *obj)
209
/* I2C controller. */
1312
+static void max31785_exit_reset(Object *obj, ResetType type)
210
1313
{
211
#define TYPE_STELLARIS_I2C "stellaris-i2c"
1314
PMBusDevice *pmdev = PMBUS_DEVICE(obj);
212
@@ -XXX,XX +XXX,XX @@ static const TypeInfo stellaris_adc_info = {
1315
MAX31785State *s = MAX31785(obj);
213
.class_init = stellaris_adc_class_init,
1316
diff --git a/hw/sensor/max34451.c b/hw/sensor/max34451.c
214
};
1317
index XXXXXXX..XXXXXXX 100644
215
1318
--- a/hw/sensor/max34451.c
216
+static void stellaris_sys_class_init(ObjectClass *klass, void *data)
1319
+++ b/hw/sensor/max34451.c
217
+{
1320
@@ -XXX,XX +XXX,XX @@ static inline void *memset_word(void *s, uint16_t c, size_t n)
218
+ DeviceClass *dc = DEVICE_CLASS(klass);
1321
return s;
219
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
1322
}
220
+
1323
221
+ dc->vmsd = &vmstate_stellaris_sys;
1324
-static void max34451_exit_reset(Object *obj)
222
+ rc->phases.enter = stellaris_sys_reset_enter;
1325
+static void max34451_exit_reset(Object *obj, ResetType type)
223
+ rc->phases.hold = stellaris_sys_reset_hold;
1326
{
224
+ rc->phases.exit = stellaris_sys_reset_exit;
1327
PMBusDevice *pmdev = PMBUS_DEVICE(obj);
225
+ device_class_set_props(dc, stellaris_sys_properties);
1328
MAX34451State *s = MAX34451(obj);
226
+}
1329
diff --git a/hw/ssi/npcm7xx_fiu.c b/hw/ssi/npcm7xx_fiu.c
227
+
1330
index XXXXXXX..XXXXXXX 100644
228
+static const TypeInfo stellaris_sys_info = {
1331
--- a/hw/ssi/npcm7xx_fiu.c
229
+ .name = TYPE_STELLARIS_SYS,
1332
+++ b/hw/ssi/npcm7xx_fiu.c
230
+ .parent = TYPE_SYS_BUS_DEVICE,
1333
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_fiu_enter_reset(Object *obj, ResetType type)
231
+ .instance_size = sizeof(ssys_state),
1334
s->regs[NPCM7XX_FIU_CFG] = 0x0000000b;
232
+ .instance_init = stellaris_sys_instance_init,
1335
}
233
+ .class_init = stellaris_sys_class_init,
1336
234
+};
1337
-static void npcm7xx_fiu_hold_reset(Object *obj)
235
+
1338
+static void npcm7xx_fiu_hold_reset(Object *obj, ResetType type)
236
static void stellaris_register_types(void)
1339
{
237
{
1340
NPCM7xxFIUState *s = NPCM7XX_FIU(obj);
238
type_register_static(&stellaris_i2c_info);
1341
int i;
239
type_register_static(&stellaris_gptm_info);
1342
diff --git a/hw/timer/etraxfs_timer.c b/hw/timer/etraxfs_timer.c
240
type_register_static(&stellaris_adc_info);
1343
index XXXXXXX..XXXXXXX 100644
241
+ type_register_static(&stellaris_sys_info);
1344
--- a/hw/timer/etraxfs_timer.c
242
}
1345
+++ b/hw/timer/etraxfs_timer.c
243
1346
@@ -XXX,XX +XXX,XX @@ static void etraxfs_timer_reset_enter(Object *obj, ResetType type)
244
type_init(stellaris_register_types)
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);
1432
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
1433
index XXXXXXX..XXXXXXX 100644
1434
--- a/target/arm/cpu.c
1435
+++ b/target/arm/cpu.c
1436
@@ -XXX,XX +XXX,XX @@ static void cp_reg_check_reset(gpointer key, gpointer value, gpointer opaque)
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
{
1682
#ifndef CONFIG_USER_ONLY
1683
uint8_t iprio;
1684
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_reset_hold(Object *obj)
1685
CPURISCVState *env = &cpu->env;
1686
1687
if (mcc->parent_phases.hold) {
1688
- mcc->parent_phases.hold(obj);
1689
+ mcc->parent_phases.hold(obj, type);
1690
}
1691
#ifndef CONFIG_USER_ONLY
1692
env->misa_mxl = mcc->misa_mxl_max;
1693
diff --git a/target/rx/cpu.c b/target/rx/cpu.c
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
}
1783
#endif
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];
245
--
1799
--
246
2.20.1
1800
2.34.1
247
248
diff view generated by jsdifflib
1
While we transition the ARMSSE code from integer properties
1
Update the reset documentation's example code to match the new API
2
specifying clock frequencies to Clock objects, we want to have the
2
for the hold and exit phase method APIs where they take a ResetType
3
device provide both at once. We want the final name of the main
3
argument.
4
input Clock to be "MAINCLK", following the hardware name.
5
Unfortunately creating an input Clock with a name X creates an
6
under-the-hood QOM property X; for "MAINCLK" this clashes with the
7
existing UINT32 property of that name.
8
9
Rename the UINT32 property to MAINCLK_FRQ so it can coexist with the
10
MAINCLK Clock; once the transition is complete MAINCLK_FRQ will be
11
deleted.
12
13
Commit created with:
14
perl -p -i -e 's/MAINCLK/MAINCLK_FRQ/g' hw/arm/{armsse,mps2-tz,musca}.c include/hw/arm/armsse.h
15
4
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
18
Reviewed-by: Luc Michel <luc@lmichel.fr>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
19
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Reviewed-by: Luc Michel <luc.michel@amd.com>
20
Message-id: 20210128114145.20536-11-peter.maydell@linaro.org
9
Message-id: 20240412160809.1260625-6-peter.maydell@linaro.org
21
Message-id: 20210121190622.22000-11-peter.maydell@linaro.org
22
---
10
---
23
include/hw/arm/armsse.h | 2 +-
11
docs/devel/reset.rst | 8 ++++----
24
hw/arm/armsse.c | 6 +++---
12
1 file changed, 4 insertions(+), 4 deletions(-)
25
hw/arm/mps2-tz.c | 2 +-
26
hw/arm/musca.c | 2 +-
27
4 files changed, 6 insertions(+), 6 deletions(-)
28
13
29
diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h
14
diff --git a/docs/devel/reset.rst b/docs/devel/reset.rst
30
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
31
--- a/include/hw/arm/armsse.h
16
--- a/docs/devel/reset.rst
32
+++ b/include/hw/arm/armsse.h
17
+++ b/docs/devel/reset.rst
33
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@ in reset.
34
* QEMU interface:
19
mydev->var = 0;
35
* + QOM property "memory" is a MemoryRegion containing the devices provided
36
* by the board model.
37
- * + QOM property "MAINCLK" is the frequency of the main system clock
38
+ * + QOM property "MAINCLK_FRQ" is the frequency of the main system clock
39
* + QOM property "EXP_NUMIRQ" sets the number of expansion interrupts.
40
* (In hardware, the SSE-200 permits the number of expansion interrupts
41
* for the two CPUs to be configured separately, but we restrict it to
42
diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c
43
index XXXXXXX..XXXXXXX 100644
44
--- a/hw/arm/armsse.c
45
+++ b/hw/arm/armsse.c
46
@@ -XXX,XX +XXX,XX @@ static Property iotkit_properties[] = {
47
DEFINE_PROP_LINK("memory", ARMSSE, board_memory, TYPE_MEMORY_REGION,
48
MemoryRegion *),
49
DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64),
50
- DEFINE_PROP_UINT32("MAINCLK", ARMSSE, mainclk_frq, 0),
51
+ DEFINE_PROP_UINT32("MAINCLK_FRQ", ARMSSE, mainclk_frq, 0),
52
DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 15),
53
DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000),
54
DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], true),
55
@@ -XXX,XX +XXX,XX @@ static Property armsse_properties[] = {
56
DEFINE_PROP_LINK("memory", ARMSSE, board_memory, TYPE_MEMORY_REGION,
57
MemoryRegion *),
58
DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64),
59
- DEFINE_PROP_UINT32("MAINCLK", ARMSSE, mainclk_frq, 0),
60
+ DEFINE_PROP_UINT32("MAINCLK_FRQ", ARMSSE, mainclk_frq, 0),
61
DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 15),
62
DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000),
63
DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], false),
64
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
65
}
20
}
66
21
67
if (!s->mainclk_frq) {
22
- static void mydev_reset_hold(Object *obj)
68
- error_setg(errp, "MAINCLK property was not set");
23
+ static void mydev_reset_hold(Object *obj, ResetType type)
69
+ error_setg(errp, "MAINCLK_FRQ property was not set");
24
{
70
return;
25
MyDevClass *myclass = MYDEV_GET_CLASS(obj);
26
MyDevState *mydev = MYDEV(obj);
27
/* call parent class hold phase */
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);
71
}
34
}
72
35
73
diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c
36
- static void mydev_reset_exit(Object *obj)
74
index XXXXXXX..XXXXXXX 100644
37
+ static void mydev_reset_exit(Object *obj, ResetType type)
75
--- a/hw/arm/mps2-tz.c
38
{
76
+++ b/hw/arm/mps2-tz.c
39
MyDevClass *myclass = MYDEV_GET_CLASS(obj);
77
@@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine)
40
MyDevState *mydev = MYDEV(obj);
78
object_property_set_link(OBJECT(&mms->iotkit), "memory",
41
/* call parent class exit phase */
79
OBJECT(system_memory), &error_abort);
42
if (myclass->parent_phases.exit) {
80
qdev_prop_set_uint32(iotkitdev, "EXP_NUMIRQ", MPS2TZ_NUMIRQ);
43
- myclass->parent_phases.exit(obj);
81
- qdev_prop_set_uint32(iotkitdev, "MAINCLK", SYSCLK_FRQ);
44
+ myclass->parent_phases.exit(obj, type);
82
+ qdev_prop_set_uint32(iotkitdev, "MAINCLK_FRQ", SYSCLK_FRQ);
45
}
83
sysbus_realize(SYS_BUS_DEVICE(&mms->iotkit), &error_fatal);
46
/* clear an IO */
84
47
qemu_set_irq(mydev->irq, 0);
85
/*
86
diff --git a/hw/arm/musca.c b/hw/arm/musca.c
87
index XXXXXXX..XXXXXXX 100644
88
--- a/hw/arm/musca.c
89
+++ b/hw/arm/musca.c
90
@@ -XXX,XX +XXX,XX @@ static void musca_init(MachineState *machine)
91
qdev_prop_set_uint32(ssedev, "EXP_NUMIRQ", mmc->num_irqs);
92
qdev_prop_set_uint32(ssedev, "init-svtor", mmc->init_svtor);
93
qdev_prop_set_uint32(ssedev, "SRAM_ADDR_WIDTH", mmc->sram_addr_width);
94
- qdev_prop_set_uint32(ssedev, "MAINCLK", SYSCLK_FRQ);
95
+ qdev_prop_set_uint32(ssedev, "MAINCLK_FRQ", SYSCLK_FRQ);
96
/*
97
* Musca-A takes the default SSE-200 FPU/DSP settings (ie no for
98
* CPU0 and yes for CPU1); Musca-B1 explicitly enables them for CPU0.
99
--
48
--
100
2.20.1
49
2.34.1
101
50
102
51
diff view generated by jsdifflib
1
Switch the CMSDK APB timer device over to using its Clock input; the
1
Some devices and machines need to handle the reset before a vmsave
2
pclk-frq property is now ignored.
2
snapshot is loaded differently -- the main user is the handling of
3
RNG seed information, which does not want to put a new RNG seed into
4
a ROM blob when we are doing a snapshot load.
5
6
Currently this kind of reset handling is supported only for:
7
* TYPE_MACHINE reset methods, which take a ShutdownCause argument
8
* reset functions registered with qemu_register_reset_nosnapshotload
9
10
To allow a three-phase-reset device to also distinguish "snapshot
11
load" reset from the normal kind, add a new ResetType
12
RESET_TYPE_SNAPSHOT_LOAD. All our existing reset methods ignore
13
the reset type, so we don't need to update any device code.
14
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().
3
19
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
21
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Luc Michel <luc@lmichel.fr>
22
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
23
Reviewed-by: Luc Michel <luc.michel@amd.com>
8
Message-id: 20210128114145.20536-19-peter.maydell@linaro.org
24
Message-id: 20240412160809.1260625-7-peter.maydell@linaro.org
9
Message-id: 20210121190622.22000-19-peter.maydell@linaro.org
10
---
25
---
11
hw/timer/cmsdk-apb-timer.c | 18 ++++++++++++++----
26
docs/devel/reset.rst | 17 ++++++++++++++---
12
1 file changed, 14 insertions(+), 4 deletions(-)
27
include/hw/resettable.h | 1 +
28
hw/core/reset.c | 15 ++++-----------
29
hw/core/resettable.c | 4 ----
30
4 files changed, 19 insertions(+), 18 deletions(-)
13
31
14
diff --git a/hw/timer/cmsdk-apb-timer.c b/hw/timer/cmsdk-apb-timer.c
32
diff --git a/docs/devel/reset.rst b/docs/devel/reset.rst
15
index XXXXXXX..XXXXXXX 100644
33
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/timer/cmsdk-apb-timer.c
34
--- a/docs/devel/reset.rst
17
+++ b/hw/timer/cmsdk-apb-timer.c
35
+++ b/docs/devel/reset.rst
18
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_reset(DeviceState *dev)
36
@@ -XXX,XX +XXX,XX @@ instantly reset an object, without keeping it in reset state, just call
19
ptimer_transaction_commit(s->timer);
37
``resettable_reset()``. These functions take two parameters: a pointer to the
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;
72
*/
73
typedef enum ResetType {
74
RESET_TYPE_COLD,
75
+ RESET_TYPE_SNAPSHOT_LOAD,
76
} ResetType;
77
78
/*
79
diff --git a/hw/core/reset.c b/hw/core/reset.c
80
index XXXXXXX..XXXXXXX 100644
81
--- a/hw/core/reset.c
82
+++ b/hw/core/reset.c
83
@@ -XXX,XX +XXX,XX @@ static ResettableContainer *get_root_reset_container(void)
84
return root_reset_container;
20
}
85
}
21
86
22
+static void cmsdk_apb_timer_clk_update(void *opaque)
87
-/*
23
+{
88
- * Reason why the currently in-progress qemu_devices_reset() was called.
24
+ CMSDKAPBTimer *s = CMSDK_APB_TIMER(opaque);
89
- * If we made at least SHUTDOWN_CAUSE_SNAPSHOT_LOAD have a corresponding
25
+
90
- * ResetType we could perhaps avoid the need for this global.
26
+ ptimer_transaction_begin(s->timer);
91
- */
27
+ ptimer_set_period_from_clock(s->timer, s->pclk, 1);
92
-static ShutdownCause device_reset_reason;
28
+ ptimer_transaction_commit(s->timer);
93
-
29
+}
94
/*
30
+
95
* This is an Object which implements Resettable simply to call the
31
static void cmsdk_apb_timer_init(Object *obj)
96
* callback function in the hold phase.
97
@@ -XXX,XX +XXX,XX @@ static void legacy_reset_hold(Object *obj, ResetType type)
32
{
98
{
33
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
99
LegacyReset *lr = LEGACY_RESET(obj);
34
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_init(Object *obj)
100
35
s, "cmsdk-apb-timer", 0x1000);
101
- if (device_reset_reason == SHUTDOWN_CAUSE_SNAPSHOT_LOAD &&
36
sysbus_init_mmio(sbd, &s->iomem);
102
- lr->skip_on_snapshot_load) {
37
sysbus_init_irq(sbd, &s->timerint);
103
+ if (type == RESET_TYPE_SNAPSHOT_LOAD && lr->skip_on_snapshot_load) {
38
- s->pclk = qdev_init_clock_in(DEVICE(s), "pclk", NULL, NULL);
39
+ s->pclk = qdev_init_clock_in(DEVICE(s), "pclk",
40
+ cmsdk_apb_timer_clk_update, s);
41
}
42
43
static void cmsdk_apb_timer_realize(DeviceState *dev, Error **errp)
44
{
45
CMSDKAPBTimer *s = CMSDK_APB_TIMER(dev);
46
47
- if (s->pclk_frq == 0) {
48
- error_setg(errp, "CMSDK APB timer: pclk-frq property must be set");
49
+ if (!clock_has_source(s->pclk)) {
50
+ error_setg(errp, "CMSDK APB timer: pclk clock must be connected");
51
return;
104
return;
52
}
105
}
53
106
lr->func(lr->opaque);
54
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_realize(DeviceState *dev, Error **errp)
107
@@ -XXX,XX +XXX,XX @@ void qemu_unregister_resettable(Object *obj)
55
PTIMER_POLICY_NO_COUNTER_ROUND_DOWN);
108
56
109
void qemu_devices_reset(ShutdownCause reason)
57
ptimer_transaction_begin(s->timer);
110
{
58
- ptimer_set_freq(s->timer, s->pclk_frq);
111
- device_reset_reason = reason;
59
+ ptimer_set_period_from_clock(s->timer, s->pclk, 1);
112
+ ResetType type = (reason == SHUTDOWN_CAUSE_SNAPSHOT_LOAD) ?
60
ptimer_transaction_commit(s->timer);
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);
61
}
118
}
119
diff --git a/hw/core/resettable.c b/hw/core/resettable.c
120
index XXXXXXX..XXXXXXX 100644
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)
126
{
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);
62
140
63
--
141
--
64
2.20.1
142
2.34.1
65
143
66
144
diff view generated by jsdifflib
1
From: Mihai Carabas <mihai.carabas@oracle.com>
1
From: Arnaud Minier <arnaud.minier@telecom-paris.fr>
2
2
3
Add PCI interface support for PVPANIC device. Create a new file pvpanic-pci.c
3
Add the basic infrastructure (register read/write, type...)
4
where the PCI specific routines reside and update the build system with the new
4
to implement the STM32L4x5 USART.
5
files and config structure.
6
5
7
Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
6
Also create different types for the USART, UART and LPUART
8
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
7
of the STM32L4x5 to deduplicate code and enable the
8
implementation of different behaviors depending on the type.
9
10
Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr>
11
Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
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]
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
17
---
13
docs/specs/pci-ids.txt | 1 +
18
MAINTAINERS | 1 +
14
include/hw/misc/pvpanic.h | 1 +
19
include/hw/char/stm32l4x5_usart.h | 66 +++++
15
include/hw/pci/pci.h | 1 +
20
hw/char/stm32l4x5_usart.c | 396 ++++++++++++++++++++++++++++++
16
hw/misc/pvpanic-pci.c | 94 +++++++++++++++++++++++++++++++++++++++
21
hw/char/Kconfig | 3 +
17
hw/misc/Kconfig | 6 +++
22
hw/char/meson.build | 1 +
18
hw/misc/meson.build | 1 +
23
hw/char/trace-events | 4 +
19
6 files changed, 104 insertions(+)
24
6 files changed, 471 insertions(+)
20
create mode 100644 hw/misc/pvpanic-pci.c
25
create mode 100644 include/hw/char/stm32l4x5_usart.h
26
create mode 100644 hw/char/stm32l4x5_usart.c
21
27
22
diff --git a/docs/specs/pci-ids.txt b/docs/specs/pci-ids.txt
28
diff --git a/MAINTAINERS b/MAINTAINERS
23
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
24
--- a/docs/specs/pci-ids.txt
30
--- a/MAINTAINERS
25
+++ b/docs/specs/pci-ids.txt
31
+++ b/MAINTAINERS
26
@@ -XXX,XX +XXX,XX @@ PCI devices (other than virtio):
32
@@ -XXX,XX +XXX,XX @@ M: Inès Varhol <ines.varhol@telecom-paris.fr>
27
1b36:000d PCI xhci usb host adapter
33
L: qemu-arm@nongnu.org
28
1b36:000f mdpy (mdev sample device), linux/samples/vfio-mdev/mdpy.c
34
S: Maintained
29
1b36:0010 PCIe NVMe device (-device nvme)
35
F: hw/arm/stm32l4x5_soc.c
30
+1b36:0011 PCI PVPanic device (-device pvpanic-pci)
36
+F: hw/char/stm32l4x5_usart.c
31
37
F: hw/misc/stm32l4x5_exti.c
32
All these devices are documented in docs/specs.
38
F: hw/misc/stm32l4x5_syscfg.c
33
39
F: hw/misc/stm32l4x5_rcc.c
34
diff --git a/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.h
40
diff --git a/include/hw/char/stm32l4x5_usart.h b/include/hw/char/stm32l4x5_usart.h
35
index XXXXXXX..XXXXXXX 100644
36
--- a/include/hw/misc/pvpanic.h
37
+++ b/include/hw/misc/pvpanic.h
38
@@ -XXX,XX +XXX,XX @@
39
#include "qom/object.h"
40
41
#define TYPE_PVPANIC_ISA_DEVICE "pvpanic"
42
+#define TYPE_PVPANIC_PCI_DEVICE "pvpanic-pci"
43
44
#define PVPANIC_IOPORT_PROP "ioport"
45
46
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
47
index XXXXXXX..XXXXXXX 100644
48
--- a/include/hw/pci/pci.h
49
+++ b/include/hw/pci/pci.h
50
@@ -XXX,XX +XXX,XX @@ extern bool pci_available;
51
#define PCI_DEVICE_ID_REDHAT_PCIE_BRIDGE 0x000e
52
#define PCI_DEVICE_ID_REDHAT_MDPY 0x000f
53
#define PCI_DEVICE_ID_REDHAT_NVME 0x0010
54
+#define PCI_DEVICE_ID_REDHAT_PVPANIC 0x0011
55
#define PCI_DEVICE_ID_REDHAT_QXL 0x0100
56
57
#define FMT_PCIBUS PRIx64
58
diff --git a/hw/misc/pvpanic-pci.c b/hw/misc/pvpanic-pci.c
59
new file mode 100644
41
new file mode 100644
60
index XXXXXXX..XXXXXXX
42
index XXXXXXX..XXXXXXX
61
--- /dev/null
43
--- /dev/null
62
+++ b/hw/misc/pvpanic-pci.c
44
+++ b/include/hw/char/stm32l4x5_usart.h
63
@@ -XXX,XX +XXX,XX @@
45
@@ -XXX,XX +XXX,XX @@
64
+/*
46
+/*
65
+ * QEMU simulated PCI pvpanic device.
47
+ * STM32L4X5 USART (Universal Synchronous Asynchronous Receiver Transmitter)
66
+ *
48
+ *
67
+ * Copyright (C) 2020 Oracle
49
+ * Copyright (c) 2023 Arnaud Minier <arnaud.minier@telecom-paris.fr>
68
+ *
50
+ * Copyright (c) 2023 Inès Varhol <ines.varhol@telecom-paris.fr>
69
+ * Authors:
51
+ *
70
+ * Mihai Carabas <mihai.carabas@oracle.com>
52
+ * SPDX-License-Identifier: GPL-2.0-or-later
71
+ *
53
+ *
72
+ * 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.
73
+ * See the COPYING file in the top-level directory.
55
+ * See the COPYING file in the top-level directory.
74
+ *
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.
61
+ */
62
+
63
+#ifndef HW_STM32L4X5_USART_H
64
+#define HW_STM32L4X5_USART_H
65
+
66
+#include "hw/sysbus.h"
67
+#include "chardev/char-fe.h"
68
+#include "qom/object.h"
69
+
70
+#define TYPE_STM32L4X5_USART_BASE "stm32l4x5-usart-base"
71
+#define TYPE_STM32L4X5_USART "stm32l4x5-usart"
72
+#define TYPE_STM32L4X5_UART "stm32l4x5-uart"
73
+#define TYPE_STM32L4X5_LPUART "stm32l4x5-lpuart"
74
+OBJECT_DECLARE_TYPE(Stm32l4x5UsartBaseState, Stm32l4x5UsartBaseClass,
75
+ STM32L4X5_USART_BASE)
76
+
77
+typedef enum {
78
+ STM32L4x5_USART,
79
+ STM32L4x5_UART,
80
+ STM32L4x5_LPUART,
81
+} Stm32l4x5UsartType;
82
+
83
+struct Stm32l4x5UsartBaseState {
84
+ SysBusDevice parent_obj;
85
+
86
+ MemoryRegion mmio;
87
+
88
+ uint32_t cr1;
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;
103
+};
104
+
105
+struct Stm32l4x5UsartBaseClass {
106
+ SysBusDeviceClass parent_class;
107
+
108
+ Stm32l4x5UsartType type;
109
+};
110
+
111
+#endif /* HW_STM32L4X5_USART_H */
112
diff --git a/hw/char/stm32l4x5_usart.c b/hw/char/stm32l4x5_usart.c
113
new file mode 100644
114
index XXXXXXX..XXXXXXX
115
--- /dev/null
116
+++ b/hw/char/stm32l4x5_usart.c
117
@@ -XXX,XX +XXX,XX @@
118
+/*
119
+ * STM32L4X5 USART (Universal Synchronous Asynchronous Receiver Transmitter)
120
+ *
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
125
+ *
126
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
127
+ * See the COPYING file in the top-level directory.
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.
75
+ */
133
+ */
76
+
134
+
77
+#include "qemu/osdep.h"
135
+#include "qemu/osdep.h"
78
+#include "qemu/log.h"
136
+#include "qemu/log.h"
79
+#include "qemu/module.h"
137
+#include "qemu/module.h"
80
+#include "sysemu/runstate.h"
138
+#include "qapi/error.h"
81
+
139
+#include "chardev/char-fe.h"
82
+#include "hw/nvram/fw_cfg.h"
140
+#include "chardev/char-serial.h"
141
+#include "migration/vmstate.h"
142
+#include "hw/char/stm32l4x5_usart.h"
143
+#include "hw/clock.h"
144
+#include "hw/irq.h"
145
+#include "hw/qdev-clock.h"
83
+#include "hw/qdev-properties.h"
146
+#include "hw/qdev-properties.h"
84
+#include "migration/vmstate.h"
147
+#include "hw/qdev-properties-system.h"
85
+#include "hw/misc/pvpanic.h"
148
+#include "hw/registerfields.h"
86
+#include "qom/object.h"
149
+#include "trace.h"
87
+#include "hw/pci/pci.h"
150
+
88
+
151
+
89
+OBJECT_DECLARE_SIMPLE_TYPE(PVPanicPCIState, PVPANIC_PCI_DEVICE)
152
+REG32(CR1, 0x00)
90
+
153
+ FIELD(CR1, M1, 28, 1) /* Word length (part 2, see M0) */
91
+/*
154
+ FIELD(CR1, EOBIE, 27, 1) /* End of Block interrupt enable */
92
+ * PVPanicPCIState for PCI device
155
+ FIELD(CR1, RTOIE, 26, 1) /* Receiver timeout interrupt enable */
93
+ */
156
+ FIELD(CR1, DEAT, 21, 5) /* Driver Enable assertion time */
94
+typedef struct PVPanicPCIState {
157
+ FIELD(CR1, DEDT, 16, 5) /* Driver Enable de-assertion time */
95
+ PCIDevice dev;
158
+ FIELD(CR1, OVER8, 15, 1) /* Oversampling mode */
96
+ PVPanicState pvpanic;
159
+ FIELD(CR1, CMIE, 14, 1) /* Character match interrupt enable */
97
+} PVPanicPCIState;
160
+ FIELD(CR1, MME, 13, 1) /* Mute mode enable */
98
+
161
+ FIELD(CR1, M0, 12, 1) /* Word length (part 1, see M1) */
99
+static const VMStateDescription vmstate_pvpanic_pci = {
162
+ FIELD(CR1, WAKE, 11, 1) /* Receiver wakeup method */
100
+ .name = "pvpanic-pci",
163
+ FIELD(CR1, PCE, 10, 1) /* Parity control enable */
164
+ FIELD(CR1, PS, 9, 1) /* Parity selection */
165
+ FIELD(CR1, PEIE, 8, 1) /* PE interrupt enable */
166
+ FIELD(CR1, TXEIE, 7, 1) /* TXE interrupt enable */
167
+ FIELD(CR1, TCIE, 6, 1) /* Transmission complete interrupt enable */
168
+ FIELD(CR1, RXNEIE, 5, 1) /* RXNE interrupt enable */
169
+ FIELD(CR1, IDLEIE, 4, 1) /* IDLE interrupt enable */
170
+ FIELD(CR1, TE, 3, 1) /* Transmitter enable */
171
+ FIELD(CR1, RE, 2, 1) /* Receiver enable */
172
+ FIELD(CR1, UESM, 1, 1) /* USART enable in Stop mode */
173
+ FIELD(CR1, UE, 0, 1) /* USART enable */
174
+REG32(CR2, 0x04)
175
+ FIELD(CR2, ADD_1, 28, 4) /* ADD[7:4] */
176
+ FIELD(CR2, ADD_0, 24, 1) /* ADD[3:0] */
177
+ FIELD(CR2, RTOEN, 23, 1) /* Receiver timeout enable */
178
+ FIELD(CR2, ABRMOD, 21, 2) /* Auto baud rate mode */
179
+ FIELD(CR2, ABREN, 20, 1) /* Auto baud rate enable */
180
+ FIELD(CR2, MSBFIRST, 19, 1) /* Most significant bit first */
181
+ FIELD(CR2, DATAINV, 18, 1) /* Binary data inversion */
182
+ FIELD(CR2, TXINV, 17, 1) /* TX pin active level inversion */
183
+ FIELD(CR2, RXINV, 16, 1) /* RX pin active level inversion */
184
+ FIELD(CR2, SWAP, 15, 1) /* Swap RX/TX pins */
185
+ FIELD(CR2, LINEN, 14, 1) /* LIN mode enable */
186
+ FIELD(CR2, STOP, 12, 2) /* STOP bits */
187
+ FIELD(CR2, CLKEN, 11, 1) /* Clock enable */
188
+ FIELD(CR2, CPOL, 10, 1) /* Clock polarity */
189
+ FIELD(CR2, CPHA, 9, 1) /* Clock phase */
190
+ FIELD(CR2, LBCL, 8, 1) /* Last bit clock pulse */
191
+ FIELD(CR2, LBDIE, 6, 1) /* LIN break detection interrupt enable */
192
+ FIELD(CR2, LBDL, 5, 1) /* LIN break detection length */
193
+ FIELD(CR2, ADDM7, 4, 1) /* 7-bit / 4-bit Address Detection */
194
+
195
+REG32(CR3, 0x08)
196
+ /* TCBGTIE only on STM32L496xx/4A6xx devices */
197
+ FIELD(CR3, UCESM, 23, 1) /* USART Clock Enable in Stop Mode */
198
+ FIELD(CR3, WUFIE, 22, 1) /* Wakeup from Stop mode interrupt enable */
199
+ FIELD(CR3, WUS, 20, 2) /* Wakeup from Stop mode interrupt flag selection */
200
+ FIELD(CR3, SCARCNT, 17, 3) /* Smartcard auto-retry count */
201
+ FIELD(CR3, DEP, 15, 1) /* Driver enable polarity selection */
202
+ FIELD(CR3, DEM, 14, 1) /* Driver enable mode */
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;
333
+ default:
334
+ qemu_log_mask(LOG_GUEST_ERROR,
335
+ "%s: Bad offset 0x%"HWADDR_PRIx"\n", __func__, addr);
336
+ break;
337
+ }
338
+
339
+ trace_stm32l4x5_usart_read(addr, retvalue);
340
+
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,
101
+ .version_id = 1,
430
+ .version_id = 1,
102
+ .minimum_version_id = 1,
431
+ .minimum_version_id = 1,
103
+ .fields = (VMStateField[]) {
432
+ .fields = (VMStateField[]) {
104
+ VMSTATE_PCI_DEVICE(dev, PVPanicPCIState),
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),
105
+ VMSTATE_END_OF_LIST()
443
+ VMSTATE_END_OF_LIST()
106
+ }
444
+ }
107
+};
445
+};
108
+
446
+
109
+static void pvpanic_pci_realizefn(PCIDevice *dev, Error **errp)
447
+
110
+{
448
+static void stm32l4x5_usart_base_realize(DeviceState *dev, Error **errp)
111
+ PVPanicPCIState *s = PVPANIC_PCI_DEVICE(dev);
449
+{
112
+ PVPanicState *ps = &s->pvpanic;
450
+ ERRP_GUARD();
113
+
451
+ Stm32l4x5UsartBaseState *s = STM32L4X5_USART_BASE(dev);
114
+ pvpanic_setup_io(&s->pvpanic, DEVICE(s), 2);
452
+ if (!clock_has_source(s->clk)) {
115
+
453
+ error_setg(errp, "USART clock must be wired up by SoC code");
116
+ pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &ps->mr);
454
+ return;
117
+}
455
+ }
118
+
456
+}
119
+static Property pvpanic_pci_properties[] = {
457
+
120
+ DEFINE_PROP_UINT8("events", PVPanicPCIState, pvpanic.events, PVPANIC_PANICKED | PVPANIC_CRASHLOADED),
458
+static void stm32l4x5_usart_base_class_init(ObjectClass *klass, void *data)
121
+ DEFINE_PROP_END_OF_LIST(),
122
+};
123
+
124
+static void pvpanic_pci_class_init(ObjectClass *klass, void *data)
125
+{
459
+{
126
+ DeviceClass *dc = DEVICE_CLASS(klass);
460
+ DeviceClass *dc = DEVICE_CLASS(klass);
127
+ PCIDeviceClass *pc = PCI_DEVICE_CLASS(klass);
461
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
128
+
462
+
129
+ device_class_set_props(dc, pvpanic_pci_properties);
463
+ rc->phases.hold = stm32l4x5_usart_base_reset_hold;
130
+
464
+ device_class_set_props(dc, stm32l4x5_usart_base_properties);
131
+ pc->realize = pvpanic_pci_realizefn;
465
+ dc->realize = stm32l4x5_usart_base_realize;
132
+ pc->vendor_id = PCI_VENDOR_ID_REDHAT;
466
+ dc->vmsd = &vmstate_stm32l4x5_usart_base;
133
+ pc->device_id = PCI_DEVICE_ID_REDHAT_PVPANIC;
467
+}
134
+ pc->revision = 1;
468
+
135
+ pc->class_id = PCI_CLASS_SYSTEM_OTHER;
469
+static void stm32l4x5_usart_class_init(ObjectClass *oc, void *data)
136
+ dc->vmsd = &vmstate_pvpanic_pci;
470
+{
137
+
471
+ Stm32l4x5UsartBaseClass *subc = STM32L4X5_USART_BASE_CLASS(oc);
138
+ set_bit(DEVICE_CATEGORY_MISC, dc->categories);
472
+
139
+}
473
+ subc->type = STM32L4x5_USART;
140
+
474
+}
141
+static TypeInfo pvpanic_pci_info = {
475
+
142
+ .name = TYPE_PVPANIC_PCI_DEVICE,
476
+static void stm32l4x5_uart_class_init(ObjectClass *oc, void *data)
143
+ .parent = TYPE_PCI_DEVICE,
477
+{
144
+ .instance_size = sizeof(PVPanicPCIState),
478
+ Stm32l4x5UsartBaseClass *subc = STM32L4X5_USART_BASE_CLASS(oc);
145
+ .class_init = pvpanic_pci_class_init,
479
+
146
+ .interfaces = (InterfaceInfo[]) {
480
+ subc->type = STM32L4x5_UART;
147
+ { INTERFACE_CONVENTIONAL_PCI_DEVICE },
481
+}
148
+ { }
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,
149
+ }
510
+ }
150
+};
511
+};
151
+
512
+
152
+static void pvpanic_register_types(void)
513
+DEFINE_TYPES(stm32l4x5_usart_types)
153
+{
514
diff --git a/hw/char/Kconfig b/hw/char/Kconfig
154
+ type_register_static(&pvpanic_pci_info);
155
+}
156
+
157
+type_init(pvpanic_register_types);
158
diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
159
index XXXXXXX..XXXXXXX 100644
515
index XXXXXXX..XXXXXXX 100644
160
--- a/hw/misc/Kconfig
516
--- a/hw/char/Kconfig
161
+++ b/hw/misc/Kconfig
517
+++ b/hw/char/Kconfig
162
@@ -XXX,XX +XXX,XX @@ config IOTKIT_SYSINFO
518
@@ -XXX,XX +XXX,XX @@ config VIRTIO_SERIAL
163
config PVPANIC_COMMON
519
config STM32F2XX_USART
164
bool
520
bool
165
521
166
+config PVPANIC_PCI
522
+config STM32L4X5_USART
167
+ bool
523
+ bool
168
+ default y if PCI_DEVICES
524
+
169
+ depends on PCI
525
config CMSDK_APB_UART
170
+ select PVPANIC_COMMON
171
+
172
config PVPANIC_ISA
173
bool
526
bool
174
depends on ISA_BUS
527
175
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
528
diff --git a/hw/char/meson.build b/hw/char/meson.build
176
index XXXXXXX..XXXXXXX 100644
529
index XXXXXXX..XXXXXXX 100644
177
--- a/hw/misc/meson.build
530
--- a/hw/char/meson.build
178
+++ b/hw/misc/meson.build
531
+++ b/hw/char/meson.build
179
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_ARMSSE_CPUID', if_true: files('armsse-cpuid.c'))
532
@@ -XXX,XX +XXX,XX @@ system_ss.add(when: 'CONFIG_RENESAS_SCI', if_true: files('renesas_sci.c'))
180
softmmu_ss.add(when: 'CONFIG_ARMSSE_MHU', if_true: files('armsse-mhu.c'))
533
system_ss.add(when: 'CONFIG_SIFIVE_UART', if_true: files('sifive_uart.c'))
181
534
system_ss.add(when: 'CONFIG_SH_SCI', if_true: files('sh_serial.c'))
182
softmmu_ss.add(when: 'CONFIG_PVPANIC_ISA', if_true: files('pvpanic-isa.c'))
535
system_ss.add(when: 'CONFIG_STM32F2XX_USART', if_true: files('stm32f2xx_usart.c'))
183
+softmmu_ss.add(when: 'CONFIG_PVPANIC_PCI', if_true: files('pvpanic-pci.c'))
536
+system_ss.add(when: 'CONFIG_STM32L4X5_USART', if_true: files('stm32l4x5_usart.c'))
184
softmmu_ss.add(when: 'CONFIG_AUX', if_true: files('auxbus.c'))
537
system_ss.add(when: 'CONFIG_MCHP_PFSOC_MMUART', if_true: files('mchp_pfsoc_mmuart.c'))
185
softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_scu.c', 'aspeed_sdmc.c', 'aspeed_xdma.c'))
538
system_ss.add(when: 'CONFIG_HTIF', if_true: files('riscv_htif.c'))
186
softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('msf2-sysreg.c'))
539
system_ss.add(when: 'CONFIG_GOLDFISH_TTY', if_true: files('goldfish_tty.c'))
540
diff --git a/hw/char/trace-events b/hw/char/trace-events
541
index XXXXXXX..XXXXXXX 100644
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"
187
--
555
--
188
2.20.1
556
2.34.1
189
557
190
558
diff view generated by jsdifflib
1
Switch the CMSDK APB watchdog device over to using its Clock input;
1
From: Arnaud Minier <arnaud.minier@telecom-paris.fr>
2
the wdogclk_frq property is now ignored.
2
3
3
Implement the ability to read and write characters to the
4
usart using the serial port.
5
6
The character transmission is based on the
7
cmsdk-apb-uart implementation.
8
9
Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr>
10
Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr>
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Message-id: 20240329174402.60382-3-arnaud.minier@telecom-paris.fr
13
[PMM: fixed a few checkpatch nits]
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Reviewed-by: Luc Michel <luc@lmichel.fr>
7
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20210128114145.20536-21-peter.maydell@linaro.org
9
Message-id: 20210121190622.22000-21-peter.maydell@linaro.org
10
---
15
---
11
hw/watchdog/cmsdk-apb-watchdog.c | 18 ++++++++++++++----
16
include/hw/char/stm32l4x5_usart.h | 1 +
12
1 file changed, 14 insertions(+), 4 deletions(-)
17
hw/char/stm32l4x5_usart.c | 143 ++++++++++++++++++++++++++++++
13
18
hw/char/trace-events | 7 ++
14
diff --git a/hw/watchdog/cmsdk-apb-watchdog.c b/hw/watchdog/cmsdk-apb-watchdog.c
19
3 files changed, 151 insertions(+)
20
21
diff --git a/include/hw/char/stm32l4x5_usart.h b/include/hw/char/stm32l4x5_usart.h
15
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/watchdog/cmsdk-apb-watchdog.c
23
--- a/include/hw/char/stm32l4x5_usart.h
17
+++ b/hw/watchdog/cmsdk-apb-watchdog.c
24
+++ b/include/hw/char/stm32l4x5_usart.h
18
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_reset(DeviceState *dev)
25
@@ -XXX,XX +XXX,XX @@ struct Stm32l4x5UsartBaseState {
19
ptimer_transaction_commit(s->timer);
26
Clock *clk;
27
CharBackend chr;
28
qemu_irq irq;
29
+ guint watch_tag;
30
};
31
32
struct Stm32l4x5UsartBaseClass {
33
diff --git a/hw/char/stm32l4x5_usart.c b/hw/char/stm32l4x5_usart.c
34
index XXXXXXX..XXXXXXX 100644
35
--- a/hw/char/stm32l4x5_usart.c
36
+++ b/hw/char/stm32l4x5_usart.c
37
@@ -XXX,XX +XXX,XX @@ REG32(RDR, 0x24)
38
REG32(TDR, 0x28)
39
FIELD(TDR, TDR, 0, 9)
40
41
+static void stm32l4x5_update_irq(Stm32l4x5UsartBaseState *s)
42
+{
43
+ if (((s->isr & R_ISR_WUF_MASK) && (s->cr3 & R_CR3_WUFIE_MASK)) ||
44
+ ((s->isr & R_ISR_CMF_MASK) && (s->cr1 & R_CR1_CMIE_MASK)) ||
45
+ ((s->isr & R_ISR_ABRF_MASK) && (s->cr1 & R_CR1_RXNEIE_MASK)) ||
46
+ ((s->isr & R_ISR_EOBF_MASK) && (s->cr1 & R_CR1_EOBIE_MASK)) ||
47
+ ((s->isr & R_ISR_RTOF_MASK) && (s->cr1 & R_CR1_RTOIE_MASK)) ||
48
+ ((s->isr & R_ISR_CTSIF_MASK) && (s->cr3 & R_CR3_CTSIE_MASK)) ||
49
+ ((s->isr & R_ISR_LBDF_MASK) && (s->cr2 & R_CR2_LBDIE_MASK)) ||
50
+ ((s->isr & R_ISR_TXE_MASK) && (s->cr1 & R_CR1_TXEIE_MASK)) ||
51
+ ((s->isr & R_ISR_TC_MASK) && (s->cr1 & R_CR1_TCIE_MASK)) ||
52
+ ((s->isr & R_ISR_RXNE_MASK) && (s->cr1 & R_CR1_RXNEIE_MASK)) ||
53
+ ((s->isr & R_ISR_IDLE_MASK) && (s->cr1 & R_CR1_IDLEIE_MASK)) ||
54
+ ((s->isr & R_ISR_ORE_MASK) &&
55
+ ((s->cr1 & R_CR1_RXNEIE_MASK) || (s->cr3 & R_CR3_EIE_MASK))) ||
56
+ /* TODO: Handle NF ? */
57
+ ((s->isr & R_ISR_FE_MASK) && (s->cr3 & R_CR3_EIE_MASK)) ||
58
+ ((s->isr & R_ISR_PE_MASK) && (s->cr1 & R_CR1_PEIE_MASK))) {
59
+ qemu_irq_raise(s->irq);
60
+ trace_stm32l4x5_usart_irq_raised(s->isr);
61
+ } else {
62
+ qemu_irq_lower(s->irq);
63
+ trace_stm32l4x5_usart_irq_lowered();
64
+ }
65
+}
66
+
67
+static int stm32l4x5_usart_base_can_receive(void *opaque)
68
+{
69
+ Stm32l4x5UsartBaseState *s = opaque;
70
+
71
+ if (!(s->isr & R_ISR_RXNE_MASK)) {
72
+ return 1;
73
+ }
74
+
75
+ return 0;
76
+}
77
+
78
+static void stm32l4x5_usart_base_receive(void *opaque, const uint8_t *buf,
79
+ int size)
80
+{
81
+ Stm32l4x5UsartBaseState *s = opaque;
82
+
83
+ if (!((s->cr1 & R_CR1_UE_MASK) && (s->cr1 & R_CR1_RE_MASK))) {
84
+ trace_stm32l4x5_usart_receiver_not_enabled(
85
+ FIELD_EX32(s->cr1, CR1, UE), FIELD_EX32(s->cr1, CR1, RE));
86
+ return;
87
+ }
88
+
89
+ /* Check if overrun detection is enabled and if there is an overrun */
90
+ if (!(s->cr3 & R_CR3_OVRDIS_MASK) && (s->isr & R_ISR_RXNE_MASK)) {
91
+ /*
92
+ * A character has been received while
93
+ * the previous has not been read = Overrun.
94
+ */
95
+ s->isr |= R_ISR_ORE_MASK;
96
+ trace_stm32l4x5_usart_overrun_detected(s->rdr, *buf);
97
+ } else {
98
+ /* No overrun */
99
+ s->rdr = *buf;
100
+ s->isr |= R_ISR_RXNE_MASK;
101
+ trace_stm32l4x5_usart_rx(s->rdr);
102
+ }
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);
20
}
181
}
21
182
22
+static void cmsdk_apb_watchdog_clk_update(void *opaque)
183
static uint64_t stm32l4x5_usart_base_read(void *opaque, hwaddr addr,
23
+{
184
@@ -XXX,XX +XXX,XX @@ static uint64_t stm32l4x5_usart_base_read(void *opaque, hwaddr addr,
24
+ CMSDKAPBWatchdog *s = CMSDK_APB_WATCHDOG(opaque);
185
retvalue = FIELD_EX32(s->rdr, RDR, RDR);
25
+
186
/* Reset RXNE flag */
26
+ ptimer_transaction_begin(s->timer);
187
s->isr &= ~R_ISR_RXNE_MASK;
27
+ ptimer_set_period_from_clock(s->timer, s->wdogclk, 1);
188
+ stm32l4x5_update_irq(s);
28
+ ptimer_transaction_commit(s->timer);
189
break;
29
+}
190
case A_TDR:
30
+
191
retvalue = FIELD_EX32(s->tdr, TDR, TDR);
31
static void cmsdk_apb_watchdog_init(Object *obj)
192
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_usart_base_write(void *opaque, hwaddr addr,
32
{
193
switch (addr) {
33
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
194
case A_CR1:
34
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_init(Object *obj)
195
s->cr1 = value;
35
s, "cmsdk-apb-watchdog", 0x1000);
196
+ stm32l4x5_update_irq(s);
36
sysbus_init_mmio(sbd, &s->iomem);
197
return;
37
sysbus_init_irq(sbd, &s->wdogint);
198
case A_CR2:
38
- s->wdogclk = qdev_init_clock_in(DEVICE(s), "WDOGCLK", NULL, NULL);
199
s->cr2 = value;
39
+ s->wdogclk = qdev_init_clock_in(DEVICE(s), "WDOGCLK",
200
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_usart_base_write(void *opaque, hwaddr addr,
40
+ cmsdk_apb_watchdog_clk_update, s);
201
s->rtor = value;
41
202
return;
42
s->is_luminary = false;
203
case A_RQR:
43
s->id = cmsdk_apb_watchdog_id;
204
+ usart_update_rqr(s, value);
44
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_realize(DeviceState *dev, Error **errp)
205
return;
45
{
206
case A_ISR:
46
CMSDKAPBWatchdog *s = CMSDK_APB_WATCHDOG(dev);
207
qemu_log_mask(LOG_GUEST_ERROR,
47
208
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_usart_base_write(void *opaque, hwaddr addr,
48
- if (s->wdogclk_frq == 0) {
209
case A_ICR:
49
+ if (!clock_has_source(s->wdogclk)) {
210
/* Clear the status flags */
50
error_setg(errp,
211
s->isr &= ~value;
51
- "CMSDK APB watchdog: wdogclk-frq property must be set");
212
+ stm32l4x5_update_irq(s);
52
+ "CMSDK APB watchdog: WDOGCLK clock must be connected");
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");
53
return;
227
return;
54
}
228
}
55
229
+
56
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_realize(DeviceState *dev, Error **errp)
230
+ qemu_chr_fe_set_handlers(&s->chr, stm32l4x5_usart_base_can_receive,
57
PTIMER_POLICY_NO_COUNTER_ROUND_DOWN);
231
+ stm32l4x5_usart_base_receive, NULL, NULL,
58
232
+ s, NULL, true);
59
ptimer_transaction_begin(s->timer);
60
- ptimer_set_freq(s->timer, s->wdogclk_frq);
61
+ ptimer_set_period_from_clock(s->timer, s->wdogclk, 1);
62
ptimer_transaction_commit(s->timer);
63
}
233
}
64
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"
65
--
254
--
66
2.20.1
255
2.34.1
67
256
68
257
diff view generated by jsdifflib
1
From: Mihai Carabas <mihai.carabas@oracle.com>
1
From: Arnaud Minier <arnaud.minier@telecom-paris.fr>
2
2
3
To ease the PCI device addition in next patches, split the code as follows:
3
Add a function to change the settings of the
4
- generic code (read/write/setup) is being kept in pvpanic.c
4
serial connection.
5
- ISA dependent code moved to pvpanic-isa.c
6
5
7
Also, rename:
6
Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr>
8
- ISA_PVPANIC_DEVICE -> PVPANIC_ISA_DEVICE.
7
Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr>
9
- TYPE_PVPANIC -> TYPE_PVPANIC_ISA.
10
- MemoryRegion io -> mr.
11
- pvpanic_ioport_* in pvpanic_*.
12
13
Update the build system with the new files and config structure.
14
15
Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20240329174402.60382-4-arnaud.minier@telecom-paris.fr
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
---
11
---
19
include/hw/misc/pvpanic.h | 23 +++++++++-
12
hw/char/stm32l4x5_usart.c | 98 +++++++++++++++++++++++++++++++++++++++
20
hw/misc/pvpanic-isa.c | 94 +++++++++++++++++++++++++++++++++++++++
13
hw/char/trace-events | 1 +
21
hw/misc/pvpanic.c | 85 +++--------------------------------
14
2 files changed, 99 insertions(+)
22
hw/i386/Kconfig | 2 +-
23
hw/misc/Kconfig | 6 ++-
24
hw/misc/meson.build | 3 +-
25
tests/qtest/meson.build | 2 +-
26
7 files changed, 130 insertions(+), 85 deletions(-)
27
create mode 100644 hw/misc/pvpanic-isa.c
28
15
29
diff --git a/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.h
16
diff --git a/hw/char/stm32l4x5_usart.c b/hw/char/stm32l4x5_usart.c
30
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
31
--- a/include/hw/misc/pvpanic.h
18
--- a/hw/char/stm32l4x5_usart.c
32
+++ b/include/hw/misc/pvpanic.h
19
+++ b/hw/char/stm32l4x5_usart.c
33
@@ -XXX,XX +XXX,XX @@
20
@@ -XXX,XX +XXX,XX @@ static void usart_cancel_transmit(Stm32l4x5UsartBaseState *s)
34
21
}
35
#include "qom/object.h"
22
}
36
23
37
-#define TYPE_PVPANIC "pvpanic"
24
+static void stm32l4x5_update_params(Stm32l4x5UsartBaseState *s)
38
+#define TYPE_PVPANIC_ISA_DEVICE "pvpanic"
25
+{
39
26
+ int speed, parity, data_bits, stop_bits;
40
#define PVPANIC_IOPORT_PROP "ioport"
27
+ uint32_t value, usart_div;
41
28
+ QEMUSerialSetParams ssp;
42
+/* The bit of supported pv event, TODO: include uapi header and remove this */
43
+#define PVPANIC_F_PANICKED 0
44
+#define PVPANIC_F_CRASHLOADED 1
45
+
29
+
46
+/* The pv event value */
30
+ /* Select the parity type */
47
+#define PVPANIC_PANICKED (1 << PVPANIC_F_PANICKED)
31
+ if (s->cr1 & R_CR1_PCE_MASK) {
48
+#define PVPANIC_CRASHLOADED (1 << PVPANIC_F_CRASHLOADED)
32
+ if (s->cr1 & R_CR1_PS_MASK) {
33
+ parity = 'O';
34
+ } else {
35
+ parity = 'E';
36
+ }
37
+ } else {
38
+ parity = 'N';
39
+ }
49
+
40
+
50
+/*
41
+ /* Select the number of stop bits */
51
+ * PVPanicState for any device type
42
+ switch (FIELD_EX32(s->cr2, CR2, STOP)) {
52
+ */
43
+ case 0:
53
+typedef struct PVPanicState PVPanicState;
44
+ stop_bits = 1;
54
+struct PVPanicState {
45
+ break;
55
+ MemoryRegion mr;
46
+ case 2:
56
+ uint8_t events;
47
+ stop_bits = 2;
57
+};
48
+ break;
58
+
49
+ default:
59
+void pvpanic_setup_io(PVPanicState *s, DeviceState *dev, unsigned size);
50
+ qemu_log_mask(LOG_UNIMP,
60
+
51
+ "UNIMPLEMENTED: fractionnal stop bits; CR2[13:12] = %u",
61
static inline uint16_t pvpanic_port(void)
52
+ FIELD_EX32(s->cr2, CR2, STOP));
62
{
63
- Object *o = object_resolve_path_type("", TYPE_PVPANIC, NULL);
64
+ Object *o = object_resolve_path_type("", TYPE_PVPANIC_ISA_DEVICE, NULL);
65
if (!o) {
66
return 0;
67
}
68
diff --git a/hw/misc/pvpanic-isa.c b/hw/misc/pvpanic-isa.c
69
new file mode 100644
70
index XXXXXXX..XXXXXXX
71
--- /dev/null
72
+++ b/hw/misc/pvpanic-isa.c
73
@@ -XXX,XX +XXX,XX @@
74
+/*
75
+ * QEMU simulated pvpanic device.
76
+ *
77
+ * Copyright Fujitsu, Corp. 2013
78
+ *
79
+ * Authors:
80
+ * Wen Congyang <wency@cn.fujitsu.com>
81
+ * Hu Tao <hutao@cn.fujitsu.com>
82
+ *
83
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
84
+ * See the COPYING file in the top-level directory.
85
+ *
86
+ */
87
+
88
+#include "qemu/osdep.h"
89
+#include "qemu/log.h"
90
+#include "qemu/module.h"
91
+#include "sysemu/runstate.h"
92
+
93
+#include "hw/nvram/fw_cfg.h"
94
+#include "hw/qdev-properties.h"
95
+#include "hw/misc/pvpanic.h"
96
+#include "qom/object.h"
97
+#include "hw/isa/isa.h"
98
+
99
+OBJECT_DECLARE_SIMPLE_TYPE(PVPanicISAState, PVPANIC_ISA_DEVICE)
100
+
101
+/*
102
+ * PVPanicISAState for ISA device and
103
+ * use ioport.
104
+ */
105
+struct PVPanicISAState {
106
+ ISADevice parent_obj;
107
+
108
+ uint16_t ioport;
109
+ PVPanicState pvpanic;
110
+};
111
+
112
+static void pvpanic_isa_initfn(Object *obj)
113
+{
114
+ PVPanicISAState *s = PVPANIC_ISA_DEVICE(obj);
115
+
116
+ pvpanic_setup_io(&s->pvpanic, DEVICE(s), 1);
117
+}
118
+
119
+static void pvpanic_isa_realizefn(DeviceState *dev, Error **errp)
120
+{
121
+ ISADevice *d = ISA_DEVICE(dev);
122
+ PVPanicISAState *s = PVPANIC_ISA_DEVICE(dev);
123
+ PVPanicState *ps = &s->pvpanic;
124
+ FWCfgState *fw_cfg = fw_cfg_find();
125
+ uint16_t *pvpanic_port;
126
+
127
+ if (!fw_cfg) {
128
+ return;
53
+ return;
129
+ }
54
+ }
130
+
55
+
131
+ pvpanic_port = g_malloc(sizeof(*pvpanic_port));
56
+ /* Select the length of the word */
132
+ *pvpanic_port = cpu_to_le16(s->ioport);
57
+ switch ((FIELD_EX32(s->cr1, CR1, M1) << 1) | FIELD_EX32(s->cr1, CR1, M0)) {
133
+ fw_cfg_add_file(fw_cfg, "etc/pvpanic-port", pvpanic_port,
58
+ case 0:
134
+ sizeof(*pvpanic_port));
59
+ data_bits = 8;
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;
71
+ }
135
+
72
+
136
+ isa_register_ioport(d, &ps->mr, s->ioport);
73
+ /* Select the baud rate */
74
+ value = FIELD_EX32(s->brr, BRR, BRR);
75
+ if (value < 16) {
76
+ qemu_log_mask(LOG_GUEST_ERROR,
77
+ "UNDEFINED: BRR less than 16: %u", value);
78
+ return;
79
+ }
80
+
81
+ if (FIELD_EX32(s->cr1, CR1, OVER8) == 0) {
82
+ /*
83
+ * Oversampling by 16
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);
137
+}
108
+}
138
+
109
+
139
+static Property pvpanic_isa_properties[] = {
110
static void stm32l4x5_usart_base_reset_hold(Object *obj, ResetType type)
140
+ DEFINE_PROP_UINT16(PVPANIC_IOPORT_PROP, PVPanicISAState, ioport, 0x505),
111
{
141
+ DEFINE_PROP_UINT8("events", PVPanicISAState, pvpanic.events, PVPANIC_PANICKED | PVPANIC_CRASHLOADED),
112
Stm32l4x5UsartBaseState *s = STM32L4X5_USART_BASE(obj);
142
+ DEFINE_PROP_END_OF_LIST(),
113
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_usart_base_write(void *opaque, hwaddr addr,
143
+};
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;
144
+
140
+
145
+static void pvpanic_isa_class_init(ObjectClass *klass, void *data)
141
+ stm32l4x5_update_params(s);
146
+{
142
+ return 0;
147
+ DeviceClass *dc = DEVICE_CLASS(klass);
148
+
149
+ dc->realize = pvpanic_isa_realizefn;
150
+ device_class_set_props(dc, pvpanic_isa_properties);
151
+ set_bit(DEVICE_CATEGORY_MISC, dc->categories);
152
+}
143
+}
153
+
144
+
154
+static TypeInfo pvpanic_isa_info = {
145
static const VMStateDescription vmstate_stm32l4x5_usart_base = {
155
+ .name = TYPE_PVPANIC_ISA_DEVICE,
146
.name = TYPE_STM32L4X5_USART_BASE,
156
+ .parent = TYPE_ISA_DEVICE,
147
.version_id = 1,
157
+ .instance_size = sizeof(PVPanicISAState),
148
.minimum_version_id = 1,
158
+ .instance_init = pvpanic_isa_initfn,
149
+ .post_load = stm32l4x5_usart_base_post_load,
159
+ .class_init = pvpanic_isa_class_init,
150
.fields = (VMStateField[]) {
160
+};
151
VMSTATE_UINT32(cr1, Stm32l4x5UsartBaseState),
161
+
152
VMSTATE_UINT32(cr2, Stm32l4x5UsartBaseState),
162
+static void pvpanic_register_types(void)
153
diff --git a/hw/char/trace-events b/hw/char/trace-events
163
+{
164
+ type_register_static(&pvpanic_isa_info);
165
+}
166
+
167
+type_init(pvpanic_register_types)
168
diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c
169
index XXXXXXX..XXXXXXX 100644
154
index XXXXXXX..XXXXXXX 100644
170
--- a/hw/misc/pvpanic.c
155
--- a/hw/char/trace-events
171
+++ b/hw/misc/pvpanic.c
156
+++ b/hw/char/trace-events
172
@@ -XXX,XX +XXX,XX @@
157
@@ -XXX,XX +XXX,XX @@ stm32l4x5_usart_irq_raised(uint32_t reg) "USART: IRQ raised: 0x%08"PRIx32
173
#include "hw/misc/pvpanic.h"
158
stm32l4x5_usart_irq_lowered(void) "USART: IRQ lowered"
174
#include "qom/object.h"
159
stm32l4x5_usart_overrun_detected(uint8_t current, uint8_t received) "USART: Overrun detected, RDR='0x%x', received 0x%x"
175
160
stm32l4x5_usart_receiver_not_enabled(uint8_t ue_bit, uint8_t re_bit) "USART: Receiver not enabled, UE=0x%x, RE=0x%x"
176
-/* The bit of supported pv event, TODO: include uapi header and remove this */
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"
177
-#define PVPANIC_F_PANICKED 0
162
178
-#define PVPANIC_F_CRASHLOADED 1
163
# xen_console.c
179
-
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"
180
-/* The pv event value */
181
-#define PVPANIC_PANICKED (1 << PVPANIC_F_PANICKED)
182
-#define PVPANIC_CRASHLOADED (1 << PVPANIC_F_CRASHLOADED)
183
-
184
-typedef struct PVPanicState PVPanicState;
185
-DECLARE_INSTANCE_CHECKER(PVPanicState, ISA_PVPANIC_DEVICE,
186
- TYPE_PVPANIC)
187
-
188
static void handle_event(int event)
189
{
190
static bool logged;
191
@@ -XXX,XX +XXX,XX @@ static void handle_event(int event)
192
}
193
}
194
195
-#include "hw/isa/isa.h"
196
-
197
-struct PVPanicState {
198
- ISADevice parent_obj;
199
-
200
- MemoryRegion io;
201
- uint16_t ioport;
202
- uint8_t events;
203
-};
204
-
205
/* return supported events on read */
206
-static uint64_t pvpanic_ioport_read(void *opaque, hwaddr addr, unsigned size)
207
+static uint64_t pvpanic_read(void *opaque, hwaddr addr, unsigned size)
208
{
209
PVPanicState *pvp = opaque;
210
return pvp->events;
211
}
212
213
-static void pvpanic_ioport_write(void *opaque, hwaddr addr, uint64_t val,
214
+static void pvpanic_write(void *opaque, hwaddr addr, uint64_t val,
215
unsigned size)
216
{
217
handle_event(val);
218
}
219
220
static const MemoryRegionOps pvpanic_ops = {
221
- .read = pvpanic_ioport_read,
222
- .write = pvpanic_ioport_write,
223
+ .read = pvpanic_read,
224
+ .write = pvpanic_write,
225
.impl = {
226
.min_access_size = 1,
227
.max_access_size = 1,
228
},
229
};
230
231
-static void pvpanic_isa_initfn(Object *obj)
232
+void pvpanic_setup_io(PVPanicState *s, DeviceState *dev, unsigned size)
233
{
234
- PVPanicState *s = ISA_PVPANIC_DEVICE(obj);
235
-
236
- memory_region_init_io(&s->io, OBJECT(s), &pvpanic_ops, s, "pvpanic", 1);
237
+ memory_region_init_io(&s->mr, OBJECT(dev), &pvpanic_ops, s, "pvpanic", size);
238
}
239
-
240
-static void pvpanic_isa_realizefn(DeviceState *dev, Error **errp)
241
-{
242
- ISADevice *d = ISA_DEVICE(dev);
243
- PVPanicState *s = ISA_PVPANIC_DEVICE(dev);
244
- FWCfgState *fw_cfg = fw_cfg_find();
245
- uint16_t *pvpanic_port;
246
-
247
- if (!fw_cfg) {
248
- return;
249
- }
250
-
251
- pvpanic_port = g_malloc(sizeof(*pvpanic_port));
252
- *pvpanic_port = cpu_to_le16(s->ioport);
253
- fw_cfg_add_file(fw_cfg, "etc/pvpanic-port", pvpanic_port,
254
- sizeof(*pvpanic_port));
255
-
256
- isa_register_ioport(d, &s->io, s->ioport);
257
-}
258
-
259
-static Property pvpanic_isa_properties[] = {
260
- DEFINE_PROP_UINT16(PVPANIC_IOPORT_PROP, PVPanicState, ioport, 0x505),
261
- DEFINE_PROP_UINT8("events", PVPanicState, events, PVPANIC_PANICKED | PVPANIC_CRASHLOADED),
262
- DEFINE_PROP_END_OF_LIST(),
263
-};
264
-
265
-static void pvpanic_isa_class_init(ObjectClass *klass, void *data)
266
-{
267
- DeviceClass *dc = DEVICE_CLASS(klass);
268
-
269
- dc->realize = pvpanic_isa_realizefn;
270
- device_class_set_props(dc, pvpanic_isa_properties);
271
- set_bit(DEVICE_CATEGORY_MISC, dc->categories);
272
-}
273
-
274
-static TypeInfo pvpanic_isa_info = {
275
- .name = TYPE_PVPANIC,
276
- .parent = TYPE_ISA_DEVICE,
277
- .instance_size = sizeof(PVPanicState),
278
- .instance_init = pvpanic_isa_initfn,
279
- .class_init = pvpanic_isa_class_init,
280
-};
281
-
282
-static void pvpanic_register_types(void)
283
-{
284
- type_register_static(&pvpanic_isa_info);
285
-}
286
-
287
-type_init(pvpanic_register_types)
288
diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig
289
index XXXXXXX..XXXXXXX 100644
290
--- a/hw/i386/Kconfig
291
+++ b/hw/i386/Kconfig
292
@@ -XXX,XX +XXX,XX @@ config PC
293
imply ISA_DEBUG
294
imply PARALLEL
295
imply PCI_DEVICES
296
- imply PVPANIC
297
+ imply PVPANIC_ISA
298
imply QXL
299
imply SEV
300
imply SGA
301
diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
302
index XXXXXXX..XXXXXXX 100644
303
--- a/hw/misc/Kconfig
304
+++ b/hw/misc/Kconfig
305
@@ -XXX,XX +XXX,XX @@ config IOTKIT_SYSCTL
306
config IOTKIT_SYSINFO
307
bool
308
309
-config PVPANIC
310
+config PVPANIC_COMMON
311
+ bool
312
+
313
+config PVPANIC_ISA
314
bool
315
depends on ISA_BUS
316
+ select PVPANIC_COMMON
317
318
config AUX
319
bool
320
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
321
index XXXXXXX..XXXXXXX 100644
322
--- a/hw/misc/meson.build
323
+++ b/hw/misc/meson.build
324
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_EMC141X', if_true: files('emc141x.c'))
325
softmmu_ss.add(when: 'CONFIG_UNIMP', if_true: files('unimp.c'))
326
softmmu_ss.add(when: 'CONFIG_EMPTY_SLOT', if_true: files('empty_slot.c'))
327
softmmu_ss.add(when: 'CONFIG_LED', if_true: files('led.c'))
328
+softmmu_ss.add(when: 'CONFIG_PVPANIC_COMMON', if_true: files('pvpanic.c'))
329
330
# ARM devices
331
softmmu_ss.add(when: 'CONFIG_PL310', if_true: files('arm_l2x0.c'))
332
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_IOTKIT_SYSINFO', if_true: files('iotkit-sysinfo.c')
333
softmmu_ss.add(when: 'CONFIG_ARMSSE_CPUID', if_true: files('armsse-cpuid.c'))
334
softmmu_ss.add(when: 'CONFIG_ARMSSE_MHU', if_true: files('armsse-mhu.c'))
335
336
-softmmu_ss.add(when: 'CONFIG_PVPANIC', if_true: files('pvpanic.c'))
337
+softmmu_ss.add(when: 'CONFIG_PVPANIC_ISA', if_true: files('pvpanic-isa.c'))
338
softmmu_ss.add(when: 'CONFIG_AUX', if_true: files('auxbus.c'))
339
softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_scu.c', 'aspeed_sdmc.c', 'aspeed_xdma.c'))
340
softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('msf2-sysreg.c'))
341
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
342
index XXXXXXX..XXXXXXX 100644
343
--- a/tests/qtest/meson.build
344
+++ b/tests/qtest/meson.build
345
@@ -XXX,XX +XXX,XX @@ qtests_i386 = \
346
(config_host.has_key('CONFIG_LINUX') and \
347
config_all_devices.has_key('CONFIG_ISA_IPMI_BT') ? ['ipmi-bt-test'] : []) + \
348
(config_all_devices.has_key('CONFIG_WDT_IB700') ? ['wdt_ib700-test'] : []) + \
349
- (config_all_devices.has_key('CONFIG_PVPANIC') ? ['pvpanic-test'] : []) + \
350
+ (config_all_devices.has_key('CONFIG_PVPANIC_ISA') ? ['pvpanic-test'] : []) + \
351
(config_all_devices.has_key('CONFIG_HDA') ? ['intel-hda-test'] : []) + \
352
(config_all_devices.has_key('CONFIG_I82801B11') ? ['i82801b11-test'] : []) + \
353
(config_all_devices.has_key('CONFIG_IOH3420') ? ['ioh3420-test'] : []) + \
354
--
165
--
355
2.20.1
166
2.34.1
356
167
357
168
diff view generated by jsdifflib
1
The state struct for the CMSDK APB timer device doesn't follow our
1
From: Arnaud Minier <arnaud.minier@telecom-paris.fr>
2
usual naming convention of camelcase -- "CMSDK" and "APB" are both
2
3
acronyms, but "TIMER" is not so should not be all-uppercase.
3
Add the USART to the SoC and connect it to the other implemented devices.
4
Globally rename the struct to "CMSDKAPBTimer" (bringing it into line
4
5
with CMSDKAPBWatchdog and CMSDKAPBDualTimer; CMSDKAPBUART remains
5
Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr>
6
as-is because "UART" is an acronym).
6
Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr>
7
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Commit created with:
8
Message-id: 20240329174402.60382-5-arnaud.minier@telecom-paris.fr
9
perl -p -i -e 's/CMSDKAPBTIMER/CMSDKAPBTimer/g' hw/timer/cmsdk-apb-timer.c include/hw/arm/armsse.h include/hw/timer/cmsdk-apb-timer.h
9
[PMM: fixed a few checkpatch nits]
10
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
Reviewed-by: Luc Michel <luc@lmichel.fr>
14
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
Message-id: 20210128114145.20536-7-peter.maydell@linaro.org
16
Message-id: 20210121190622.22000-7-peter.maydell@linaro.org
17
---
11
---
18
include/hw/arm/armsse.h | 6 +++---
12
docs/system/arm/b-l475e-iot01a.rst | 2 +-
19
include/hw/timer/cmsdk-apb-timer.h | 4 ++--
13
include/hw/arm/stm32l4x5_soc.h | 7 +++
20
hw/timer/cmsdk-apb-timer.c | 28 ++++++++++++++--------------
14
hw/arm/stm32l4x5_soc.c | 83 +++++++++++++++++++++++++++---
21
3 files changed, 19 insertions(+), 19 deletions(-)
15
hw/arm/Kconfig | 1 +
22
16
4 files changed, 86 insertions(+), 7 deletions(-)
23
diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h
17
24
index XXXXXXX..XXXXXXX 100644
18
diff --git a/docs/system/arm/b-l475e-iot01a.rst b/docs/system/arm/b-l475e-iot01a.rst
25
--- a/include/hw/arm/armsse.h
19
index XXXXXXX..XXXXXXX 100644
26
+++ b/include/hw/arm/armsse.h
20
--- a/docs/system/arm/b-l475e-iot01a.rst
27
@@ -XXX,XX +XXX,XX @@ struct ARMSSE {
21
+++ b/docs/system/arm/b-l475e-iot01a.rst
28
TZPPC apb_ppc0;
22
@@ -XXX,XX +XXX,XX @@ Currently B-L475E-IOT01A machine's only supports the following devices:
29
TZPPC apb_ppc1;
23
- STM32L4x5 SYSCFG (System configuration controller)
30
TZMPC mpc[IOTS_NUM_MPC];
24
- STM32L4x5 RCC (Reset and clock control)
31
- CMSDKAPBTIMER timer0;
25
- STM32L4x5 GPIOs (General-purpose I/Os)
32
- CMSDKAPBTIMER timer1;
26
+- STM32L4x5 USARTs, UARTs and LPUART (Serial ports)
33
- CMSDKAPBTIMER s32ktimer;
27
34
+ CMSDKAPBTimer timer0;
28
Missing devices
35
+ CMSDKAPBTimer timer1;
29
"""""""""""""""
36
+ CMSDKAPBTimer s32ktimer;
30
37
qemu_or_irq ppc_irq_orgate;
31
The B-L475E-IOT01A does *not* support the following devices:
38
SplitIRQ sec_resp_splitter;
32
39
SplitIRQ ppc_irq_splitter[NUM_PPCS];
33
-- Serial ports (UART)
40
diff --git a/include/hw/timer/cmsdk-apb-timer.h b/include/hw/timer/cmsdk-apb-timer.h
34
- Analog to Digital Converter (ADC)
41
index XXXXXXX..XXXXXXX 100644
35
- SPI controller
42
--- a/include/hw/timer/cmsdk-apb-timer.h
36
- Timer controller (TIMER)
43
+++ b/include/hw/timer/cmsdk-apb-timer.h
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
44
@@ -XXX,XX +XXX,XX @@
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"
45
#include "qom/object.h"
46
#include "qom/object.h"
46
47
47
#define TYPE_CMSDK_APB_TIMER "cmsdk-apb-timer"
48
#define TYPE_STM32L4X5_SOC "stm32l4x5-soc"
48
-OBJECT_DECLARE_SIMPLE_TYPE(CMSDKAPBTIMER, CMSDK_APB_TIMER)
49
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_TYPE(Stm32l4x5SocState, Stm32l4x5SocClass, STM32L4X5_SOC)
49
+OBJECT_DECLARE_SIMPLE_TYPE(CMSDKAPBTimer, CMSDK_APB_TIMER)
50
50
51
#define NUM_EXTI_OR_GATES 4
51
-struct CMSDKAPBTIMER {
52
52
+struct CMSDKAPBTimer {
53
+#define STM_NUM_USARTS 3
53
/*< private >*/
54
+#define STM_NUM_UARTS 2
55
+
56
struct Stm32l4x5SocState {
54
SysBusDevice parent_obj;
57
SysBusDevice parent_obj;
55
58
56
diff --git a/hw/timer/cmsdk-apb-timer.c b/hw/timer/cmsdk-apb-timer.c
59
@@ -XXX,XX +XXX,XX @@ struct Stm32l4x5SocState {
57
index XXXXXXX..XXXXXXX 100644
60
Stm32l4x5SyscfgState syscfg;
58
--- a/hw/timer/cmsdk-apb-timer.c
61
Stm32l4x5RccState rcc;
59
+++ b/hw/timer/cmsdk-apb-timer.c
62
Stm32l4x5GpioState gpio[NUM_GPIOS];
60
@@ -XXX,XX +XXX,XX @@ static const int timer_id[] = {
63
+ Stm32l4x5UsartBaseState usart[STM_NUM_USARTS];
61
0x0d, 0xf0, 0x05, 0xb1, /* CID0..CID3 */
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 },
62
};
83
};
63
84
64
-static void cmsdk_apb_timer_update(CMSDKAPBTIMER *s)
85
+static const hwaddr usart_addr[] = {
65
+static void cmsdk_apb_timer_update(CMSDKAPBTimer *s)
86
+ 0x40013800, /* "USART1", 0x400 */
87
+ 0x40004400, /* "USART2", 0x400 */
88
+ 0x40004800, /* "USART3", 0x400 */
89
+};
90
+static const hwaddr uart_addr[] = {
91
+ 0x40004C00, /* "UART4" , 0x400 */
92
+ 0x40005000 /* "UART5" , 0x400 */
93
+};
94
+
95
+#define LPUART_BASE_ADDRESS 0x40008000
96
+
97
+static const int usart_irq[] = { 37, 38, 39 };
98
+static const int uart_irq[] = { 52, 53 };
99
+#define LPUART_IRQ 70
100
+
101
static void stm32l4x5_soc_initfn(Object *obj)
66
{
102
{
67
qemu_set_irq(s->timerint, !!(s->intstatus & R_INTSTATUS_IRQ_MASK));
103
Stm32l4x5SocState *s = STM32L4X5_SOC(obj);
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);
68
}
120
}
69
121
70
static uint64_t cmsdk_apb_timer_read(void *opaque, hwaddr offset, unsigned size)
122
static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp)
71
{
123
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp)
72
- CMSDKAPBTIMER *s = CMSDK_APB_TIMER(opaque);
124
sysbus_mmio_map(busdev, 0, RCC_BASE_ADDRESS);
73
+ CMSDKAPBTimer *s = CMSDK_APB_TIMER(opaque);
125
sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(armv7m, RCC_IRQ));
74
uint64_t r;
126
75
127
+ /* USART devices */
76
switch (offset) {
128
+ for (int i = 0; i < STM_NUM_USARTS; i++) {
77
@@ -XXX,XX +XXX,XX @@ static uint64_t cmsdk_apb_timer_read(void *opaque, hwaddr offset, unsigned size)
129
+ g_autofree char *name = g_strdup_printf("usart%d-out", i + 1);
78
static void cmsdk_apb_timer_write(void *opaque, hwaddr offset, uint64_t value,
130
+ dev = DEVICE(&(s->usart[i]));
79
unsigned size)
131
+ qdev_prop_set_chr(dev, "chardev", serial_hd(i));
80
{
132
+ qdev_connect_clock_in(dev, "clk",
81
- CMSDKAPBTIMER *s = CMSDK_APB_TIMER(opaque);
133
+ qdev_get_clock_out(DEVICE(&(s->rcc)), name));
82
+ CMSDKAPBTimer *s = CMSDK_APB_TIMER(opaque);
134
+ busdev = SYS_BUS_DEVICE(dev);
83
135
+ if (!sysbus_realize(busdev, errp)) {
84
trace_cmsdk_apb_timer_write(offset, value, size);
136
+ return;
85
137
+ }
86
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps cmsdk_apb_timer_ops = {
138
+ sysbus_mmio_map(busdev, 0, usart_addr[i]);
87
139
+ sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(armv7m, usart_irq[i]));
88
static void cmsdk_apb_timer_tick(void *opaque)
140
+ }
89
{
141
+
90
- CMSDKAPBTIMER *s = CMSDK_APB_TIMER(opaque);
142
+ /*
91
+ CMSDKAPBTimer *s = CMSDK_APB_TIMER(opaque);
143
+ * TODO: Connect the USARTs, UARTs and LPUART to the EXTI once the EXTI
92
144
+ * can handle other gpio-in than the gpios. (e.g. Direct Lines for the
93
if (s->ctrl & R_CTRL_IRQEN_MASK) {
145
+ * usarts)
94
s->intstatus |= R_INTSTATUS_IRQ_MASK;
146
+ */
95
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_tick(void *opaque)
147
+
96
148
+ /* UART devices */
97
static void cmsdk_apb_timer_reset(DeviceState *dev)
149
+ for (int i = 0; i < STM_NUM_UARTS; i++) {
98
{
150
+ g_autofree char *name = g_strdup_printf("uart%d-out", STM_NUM_USARTS + i + 1);
99
- CMSDKAPBTIMER *s = CMSDK_APB_TIMER(dev);
151
+ dev = DEVICE(&(s->uart[i]));
100
+ CMSDKAPBTimer *s = CMSDK_APB_TIMER(dev);
152
+ qdev_prop_set_chr(dev, "chardev", serial_hd(STM_NUM_USARTS + i));
101
153
+ qdev_connect_clock_in(dev, "clk",
102
trace_cmsdk_apb_timer_reset();
154
+ qdev_get_clock_out(DEVICE(&(s->rcc)), name));
103
s->ctrl = 0;
155
+ busdev = SYS_BUS_DEVICE(dev);
104
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_reset(DeviceState *dev)
156
+ if (!sysbus_realize(busdev, errp)) {
105
static void cmsdk_apb_timer_init(Object *obj)
157
+ return;
106
{
158
+ }
107
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
159
+ sysbus_mmio_map(busdev, 0, uart_addr[i]);
108
- CMSDKAPBTIMER *s = CMSDK_APB_TIMER(obj);
160
+ sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(armv7m, uart_irq[i]));
109
+ CMSDKAPBTimer *s = CMSDK_APB_TIMER(obj);
161
+ }
110
162
+
111
memory_region_init_io(&s->iomem, obj, &cmsdk_apb_timer_ops,
163
+ /* LPUART device*/
112
s, "cmsdk-apb-timer", 0x1000);
164
+ dev = DEVICE(&(s->lpuart));
113
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_init(Object *obj)
165
+ qdev_prop_set_chr(dev, "chardev", serial_hd(STM_NUM_USARTS + STM_NUM_UARTS));
114
166
+ qdev_connect_clock_in(dev, "clk",
115
static void cmsdk_apb_timer_realize(DeviceState *dev, Error **errp)
167
+ qdev_get_clock_out(DEVICE(&(s->rcc)), "lpuart1-out"));
116
{
168
+ busdev = SYS_BUS_DEVICE(dev);
117
- CMSDKAPBTIMER *s = CMSDK_APB_TIMER(dev);
169
+ if (!sysbus_realize(busdev, errp)) {
118
+ CMSDKAPBTimer *s = CMSDK_APB_TIMER(dev);
170
+ return;
119
171
+ }
120
if (s->pclk_frq == 0) {
172
+ sysbus_mmio_map(busdev, 0, LPUART_BASE_ADDRESS);
121
error_setg(errp, "CMSDK APB timer: pclk-frq property must be set");
173
+ sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(armv7m, LPUART_IRQ));
122
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription cmsdk_apb_timer_vmstate = {
174
+
123
.version_id = 1,
175
/* APB1 BUS */
124
.minimum_version_id = 1,
176
create_unimplemented_device("TIM2", 0x40000000, 0x400);
125
.fields = (VMStateField[]) {
177
create_unimplemented_device("TIM3", 0x40000400, 0x400);
126
- VMSTATE_PTIMER(timer, CMSDKAPBTIMER),
178
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp)
127
- VMSTATE_UINT32(ctrl, CMSDKAPBTIMER),
179
create_unimplemented_device("SPI2", 0x40003800, 0x400);
128
- VMSTATE_UINT32(value, CMSDKAPBTIMER),
180
create_unimplemented_device("SPI3", 0x40003C00, 0x400);
129
- VMSTATE_UINT32(reload, CMSDKAPBTIMER),
181
/* RESERVED: 0x40004000, 0x400 */
130
- VMSTATE_UINT32(intstatus, CMSDKAPBTIMER),
182
- create_unimplemented_device("USART2", 0x40004400, 0x400);
131
+ VMSTATE_PTIMER(timer, CMSDKAPBTimer),
183
- create_unimplemented_device("USART3", 0x40004800, 0x400);
132
+ VMSTATE_UINT32(ctrl, CMSDKAPBTimer),
184
- create_unimplemented_device("UART4", 0x40004C00, 0x400);
133
+ VMSTATE_UINT32(value, CMSDKAPBTimer),
185
- create_unimplemented_device("UART5", 0x40005000, 0x400);
134
+ VMSTATE_UINT32(reload, CMSDKAPBTimer),
186
create_unimplemented_device("I2C1", 0x40005400, 0x400);
135
+ VMSTATE_UINT32(intstatus, CMSDKAPBTimer),
187
create_unimplemented_device("I2C2", 0x40005800, 0x400);
136
VMSTATE_END_OF_LIST()
188
create_unimplemented_device("I2C3", 0x40005C00, 0x400);
137
}
189
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp)
138
};
190
create_unimplemented_device("DAC1", 0x40007400, 0x400);
139
191
create_unimplemented_device("OPAMP", 0x40007800, 0x400);
140
static Property cmsdk_apb_timer_properties[] = {
192
create_unimplemented_device("LPTIM1", 0x40007C00, 0x400);
141
- DEFINE_PROP_UINT32("pclk-frq", CMSDKAPBTIMER, pclk_frq, 0),
193
- create_unimplemented_device("LPUART1", 0x40008000, 0x400);
142
+ DEFINE_PROP_UINT32("pclk-frq", CMSDKAPBTimer, pclk_frq, 0),
194
/* RESERVED: 0x40008400, 0x400 */
143
DEFINE_PROP_END_OF_LIST(),
195
create_unimplemented_device("SWPMI1", 0x40008800, 0x400);
144
};
196
/* RESERVED: 0x40008C00, 0x800 */
145
197
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp)
146
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_class_init(ObjectClass *klass, void *data)
198
create_unimplemented_device("TIM1", 0x40012C00, 0x400);
147
static const TypeInfo cmsdk_apb_timer_info = {
199
create_unimplemented_device("SPI1", 0x40013000, 0x400);
148
.name = TYPE_CMSDK_APB_TIMER,
200
create_unimplemented_device("TIM8", 0x40013400, 0x400);
149
.parent = TYPE_SYS_BUS_DEVICE,
201
- create_unimplemented_device("USART1", 0x40013800, 0x400);
150
- .instance_size = sizeof(CMSDKAPBTIMER),
202
/* RESERVED: 0x40013C00, 0x400 */
151
+ .instance_size = sizeof(CMSDKAPBTimer),
203
create_unimplemented_device("TIM15", 0x40014000, 0x400);
152
.instance_init = cmsdk_apb_timer_init,
204
create_unimplemented_device("TIM16", 0x40014400, 0x400);
153
.class_init = cmsdk_apb_timer_class_init,
205
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
154
};
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
155
--
217
--
156
2.20.1
218
2.34.1
157
219
158
220
diff view generated by jsdifflib
1
From: Mihai Carabas <mihai.carabas@oracle.com>
1
From: Arnaud Minier <arnaud.minier@telecom-paris.fr>
2
2
3
Add a test case for pvpanic-pci device. The scenario is the same as pvpanic
3
Test:
4
ISA device, but is using the PCI bus.
4
- read/write from/to the usart registers
5
5
- send/receive a character/string over the serial port
6
Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
6
7
Acked-by: Thomas Huth <thuth@redhat.com>
7
Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr>
8
Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
10
Message-id: 20240329174402.60382-6-arnaud.minier@telecom-paris.fr
11
[PMM: fix checkpatch nits, remove commented out code]
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
13
---
12
tests/qtest/pvpanic-pci-test.c | 94 ++++++++++++++++++++++++++++++++++
14
tests/qtest/stm32l4x5_usart-test.c | 315 +++++++++++++++++++++++++++++
13
tests/qtest/meson.build | 1 +
15
tests/qtest/meson.build | 4 +-
14
2 files changed, 95 insertions(+)
16
2 files changed, 318 insertions(+), 1 deletion(-)
15
create mode 100644 tests/qtest/pvpanic-pci-test.c
17
create mode 100644 tests/qtest/stm32l4x5_usart-test.c
16
18
17
diff --git a/tests/qtest/pvpanic-pci-test.c b/tests/qtest/pvpanic-pci-test.c
19
diff --git a/tests/qtest/stm32l4x5_usart-test.c b/tests/qtest/stm32l4x5_usart-test.c
18
new file mode 100644
20
new file mode 100644
19
index XXXXXXX..XXXXXXX
21
index XXXXXXX..XXXXXXX
20
--- /dev/null
22
--- /dev/null
21
+++ b/tests/qtest/pvpanic-pci-test.c
23
+++ b/tests/qtest/stm32l4x5_usart-test.c
22
@@ -XXX,XX +XXX,XX @@
24
@@ -XXX,XX +XXX,XX @@
23
+/*
25
+/*
24
+ * QTest testcase for PV Panic PCI device
26
+ * QTest testcase for STML4X5_USART
25
+ *
27
+ *
26
+ * Copyright (C) 2020 Oracle
28
+ * Copyright (c) 2023 Arnaud Minier <arnaud.minier@telecom-paris.fr>
27
+ *
29
+ * Copyright (c) 2023 Inès Varhol <ines.varhol@telecom-paris.fr>
28
+ * Authors:
29
+ * Mihai Carabas <mihai.carabas@oracle.com>
30
+ *
30
+ *
31
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
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.
32
+ * See the COPYING file in the top-level directory.
33
+ *
34
+ */
33
+ */
35
+
34
+
36
+#include "qemu/osdep.h"
35
+#include "qemu/osdep.h"
37
+#include "libqos/libqtest.h"
36
+#include "libqtest.h"
38
+#include "qapi/qmp/qdict.h"
37
+#include "hw/misc/stm32l4x5_rcc_internals.h"
39
+#include "libqos/pci.h"
38
+#include "hw/registerfields.h"
40
+#include "libqos/pci-pc.h"
39
+
41
+#include "hw/pci/pci_regs.h"
40
+#define RCC_BASE_ADDR 0x40021000
42
+
41
+/* Use USART 1 ADDR, assume the others work the same */
43
+static void test_panic_nopause(void)
42
+#define USART1_BASE_ADDR 0x40013800
44
+{
43
+
45
+ uint8_t val;
44
+/* See stm32l4x5_usart for definitions */
46
+ QDict *response, *data;
45
+REG32(CR1, 0x00)
47
+ QTestState *qts;
46
+ FIELD(CR1, M1, 28, 1)
48
+ QPCIBus *pcibus;
47
+ FIELD(CR1, OVER8, 15, 1)
49
+ QPCIDevice *dev;
48
+ FIELD(CR1, M0, 12, 1)
50
+ QPCIBar bar;
49
+ FIELD(CR1, PCE, 10, 1)
51
+
50
+ FIELD(CR1, TXEIE, 7, 1)
52
+ qts = qtest_init("-device pvpanic-pci,addr=04.0 -action panic=none");
51
+ FIELD(CR1, RXNEIE, 5, 1)
53
+ pcibus = qpci_new_pc(qts, NULL);
52
+ FIELD(CR1, TE, 3, 1)
54
+ dev = qpci_device_find(pcibus, QPCI_DEVFN(0x4, 0x0));
53
+ FIELD(CR1, RE, 2, 1)
55
+ qpci_device_enable(dev);
54
+ FIELD(CR1, UE, 0, 1)
56
+ bar = qpci_iomap(dev, 0, NULL);
55
+REG32(CR2, 0x04)
57
+
56
+REG32(CR3, 0x08)
58
+ qpci_memread(dev, bar, 0, &val, sizeof(val));
57
+ FIELD(CR3, OVRDIS, 12, 1)
59
+ g_assert_cmpuint(val, ==, 3);
58
+REG32(BRR, 0x0C)
60
+
59
+REG32(GTPR, 0x10)
61
+ val = 1;
60
+REG32(RTOR, 0x14)
62
+ qpci_memwrite(dev, bar, 0, &val, sizeof(val));
61
+REG32(RQR, 0x18)
63
+
62
+REG32(ISR, 0x1C)
64
+ response = qtest_qmp_eventwait_ref(qts, "GUEST_PANICKED");
63
+ FIELD(ISR, TXE, 7, 1)
65
+ g_assert(qdict_haskey(response, "data"));
64
+ FIELD(ISR, RXNE, 5, 1)
66
+ data = qdict_get_qdict(response, "data");
65
+ FIELD(ISR, ORE, 3, 1)
67
+ g_assert(qdict_haskey(data, "action"));
66
+REG32(ICR, 0x20)
68
+ g_assert_cmpstr(qdict_get_str(data, "action"), ==, "run");
67
+REG32(RDR, 0x24)
69
+ qobject_unref(response);
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);
70
+
256
+
71
+ qtest_quit(qts);
257
+ qtest_quit(qts);
72
+}
258
+}
73
+
259
+
74
+static void test_panic(void)
260
+static void test_send_char(void)
75
+{
261
+{
76
+ uint8_t val;
262
+ int sock_fd;
77
+ QDict *response, *data;
263
+ char s[1];
78
+ QTestState *qts;
264
+ uint32_t cr1;
79
+ QPCIBus *pcibus;
265
+ QTestState *qts = qtest_init_with_serial("-M b-l475e-iot01a", &sock_fd);
80
+ QPCIDevice *dev;
266
+
81
+ QPCIBar bar;
267
+ init_uart(qts);
82
+
268
+
83
+ qts = qtest_init("-device pvpanic-pci,addr=04.0 -action panic=pause");
269
+ /* Try without initializing IRQ */
84
+ pcibus = qpci_new_pc(qts, NULL);
270
+ qtest_writel(qts, USART1_BASE_ADDR + A_TDR, 'c');
85
+ dev = qpci_device_find(pcibus, QPCI_DEVFN(0x4, 0x0));
271
+ g_assert_true(recv(sock_fd, s, 1, 0) == 1);
86
+ qpci_device_enable(dev);
272
+ g_assert_cmphex(s[0], ==, 'c');
87
+ bar = qpci_iomap(dev, 0, NULL);
273
+ g_assert_false(check_nvic_pending(qts, USART1_IRQ));
88
+
274
+
89
+ qpci_memread(dev, bar, 0, &val, sizeof(val));
275
+ /* Now with the IRQ */
90
+ g_assert_cmpuint(val, ==, 3);
276
+ cr1 = qtest_readl(qts, (USART1_BASE_ADDR + A_CR1));
91
+
277
+ cr1 |= R_CR1_TXEIE_MASK;
92
+ val = 1;
278
+ qtest_writel(qts, USART1_BASE_ADDR + A_CR1, cr1);
93
+ qpci_memwrite(dev, bar, 0, &val, sizeof(val));
279
+ qtest_writel(qts, USART1_BASE_ADDR + A_TDR, 'd');
94
+
280
+ g_assert_true(recv(sock_fd, s, 1, 0) == 1);
95
+ response = qtest_qmp_eventwait_ref(qts, "GUEST_PANICKED");
281
+ g_assert_cmphex(s[0], ==, 'd');
96
+ g_assert(qdict_haskey(response, "data"));
282
+ g_assert_true(check_nvic_pending(qts, USART1_IRQ));
97
+ data = qdict_get_qdict(response, "data");
283
+ clear_nvic_pending(qts, USART1_IRQ);
98
+ g_assert(qdict_haskey(data, "action"));
284
+
99
+ g_assert_cmpstr(qdict_get_str(data, "action"), ==, "pause");
285
+ close(sock_fd);
100
+ qobject_unref(response);
101
+
286
+
102
+ qtest_quit(qts);
287
+ qtest_quit(qts);
103
+}
288
+}
104
+
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
+
105
+int main(int argc, char **argv)
323
+int main(int argc, char **argv)
106
+{
324
+{
107
+ int ret;
325
+ int ret;
108
+
326
+
109
+ g_test_init(&argc, &argv, NULL);
327
+ g_test_init(&argc, &argv, NULL);
110
+ qtest_add_func("/pvpanic-pci/panic", test_panic);
328
+ g_test_set_nonfatal_assertions();
111
+ qtest_add_func("/pvpanic-pci/panic-nopause", test_panic_nopause);
329
+
112
+
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);
113
+ ret = g_test_run();
335
+ ret = g_test_run();
114
+
336
+
115
+ return ret;
337
+ return ret;
116
+}
338
+}
339
+
117
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
340
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
118
index XXXXXXX..XXXXXXX 100644
341
index XXXXXXX..XXXXXXX 100644
119
--- a/tests/qtest/meson.build
342
--- a/tests/qtest/meson.build
120
+++ b/tests/qtest/meson.build
343
+++ b/tests/qtest/meson.build
121
@@ -XXX,XX +XXX,XX @@ qtests_i386 = \
344
@@ -XXX,XX +XXX,XX @@ slow_qtests = {
122
config_all_devices.has_key('CONFIG_ISA_IPMI_BT') ? ['ipmi-bt-test'] : []) + \
345
'npcm7xx_pwm-test': 300,
123
(config_all_devices.has_key('CONFIG_WDT_IB700') ? ['wdt_ib700-test'] : []) + \
346
'npcm7xx_watchdog_timer-test': 120,
124
(config_all_devices.has_key('CONFIG_PVPANIC_ISA') ? ['pvpanic-test'] : []) + \
347
'qom-test' : 900,
125
+ (config_all_devices.has_key('CONFIG_PVPANIC_PCI') ? ['pvpanic-pci-test'] : []) + \
348
+ 'stm32l4x5_usart-test' : 600,
126
(config_all_devices.has_key('CONFIG_HDA') ? ['intel-hda-test'] : []) + \
349
'test-hmp' : 240,
127
(config_all_devices.has_key('CONFIG_I82801B11') ? ['i82801b11-test'] : []) + \
350
'pxe-test': 610,
128
(config_all_devices.has_key('CONFIG_IOH3420') ? ['ioh3420-test'] : []) + \
351
'prom-env-test': 360,
352
@@ -XXX,XX +XXX,XX @@ qtests_stm32l4x5 = \
353
['stm32l4x5_exti-test',
354
'stm32l4x5_syscfg-test',
355
'stm32l4x5_rcc-test',
356
- 'stm32l4x5_gpio-test']
357
+ 'stm32l4x5_gpio-test',
358
+ 'stm32l4x5_usart-test']
359
360
qtests_arm = \
361
(config_all_devices.has_key('CONFIG_MPS2') ? ['sse-timer-test'] : []) + \
129
--
362
--
130
2.20.1
363
2.34.1
131
364
132
365
diff view generated by jsdifflib
Deleted patch
1
Add a function for checking whether a clock has a source. This is
2
useful for devices which have input clocks that must be wired up by
3
the board as it allows them to fail in realize rather than ploughing
4
on with a zero-period clock.
5
1
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Luc Michel <luc@lmichel.fr>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Message-id: 20210128114145.20536-3-peter.maydell@linaro.org
11
Message-id: 20210121190622.22000-3-peter.maydell@linaro.org
12
---
13
docs/devel/clocks.rst | 16 ++++++++++++++++
14
include/hw/clock.h | 15 +++++++++++++++
15
2 files changed, 31 insertions(+)
16
17
diff --git a/docs/devel/clocks.rst b/docs/devel/clocks.rst
18
index XXXXXXX..XXXXXXX 100644
19
--- a/docs/devel/clocks.rst
20
+++ b/docs/devel/clocks.rst
21
@@ -XXX,XX +XXX,XX @@ object during device instance init. For example:
22
/* set initial value to 10ns / 100MHz */
23
clock_set_ns(clk, 10);
24
25
+To enforce that the clock is wired up by the board code, you can
26
+call ``clock_has_source()`` in your device's realize method:
27
+
28
+.. code-block:: c
29
+
30
+ if (!clock_has_source(s->clk)) {
31
+ error_setg(errp, "MyDevice: clk input must be connected");
32
+ return;
33
+ }
34
+
35
+Note that this only checks that the clock has been wired up; it is
36
+still possible that the output clock connected to it is disabled
37
+or has not yet been configured, in which case the period will be
38
+zero. You should use the clock callback to find out when the clock
39
+period changes.
40
+
41
Fetching clock frequency/period
42
-------------------------------
43
44
diff --git a/include/hw/clock.h b/include/hw/clock.h
45
index XXXXXXX..XXXXXXX 100644
46
--- a/include/hw/clock.h
47
+++ b/include/hw/clock.h
48
@@ -XXX,XX +XXX,XX @@ void clock_clear_callback(Clock *clk);
49
*/
50
void clock_set_source(Clock *clk, Clock *src);
51
52
+/**
53
+ * clock_has_source:
54
+ * @clk: the clock
55
+ *
56
+ * Returns true if the clock has a source clock connected to it.
57
+ * This is useful for devices which have input clocks which must
58
+ * be connected by the board/SoC code which creates them. The
59
+ * device code can use this to check in its realize method that
60
+ * the clock has been connected.
61
+ */
62
+static inline bool clock_has_source(const Clock *clk)
63
+{
64
+ return clk->source != NULL;
65
+}
66
+
67
/**
68
* clock_set:
69
* @clk: the clock to initialize.
70
--
71
2.20.1
72
73
diff view generated by jsdifflib
Deleted patch
1
Add a simple test of the CMSDK APB timer, since we're about to do
2
some refactoring of how it is clocked.
3
1
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Reviewed-by: Luc Michel <luc@lmichel.fr>
7
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20210128114145.20536-4-peter.maydell@linaro.org
9
Message-id: 20210121190622.22000-4-peter.maydell@linaro.org
10
---
11
tests/qtest/cmsdk-apb-timer-test.c | 75 ++++++++++++++++++++++++++++++
12
MAINTAINERS | 1 +
13
tests/qtest/meson.build | 1 +
14
3 files changed, 77 insertions(+)
15
create mode 100644 tests/qtest/cmsdk-apb-timer-test.c
16
17
diff --git a/tests/qtest/cmsdk-apb-timer-test.c b/tests/qtest/cmsdk-apb-timer-test.c
18
new file mode 100644
19
index XXXXXXX..XXXXXXX
20
--- /dev/null
21
+++ b/tests/qtest/cmsdk-apb-timer-test.c
22
@@ -XXX,XX +XXX,XX @@
23
+/*
24
+ * QTest testcase for the CMSDK APB timer device
25
+ *
26
+ * Copyright (c) 2021 Linaro Limited
27
+ *
28
+ * This program is free software; you can redistribute it and/or modify it
29
+ * under the terms of the GNU General Public License as published by the
30
+ * Free Software Foundation; either version 2 of the License, or
31
+ * (at your option) any later version.
32
+ *
33
+ * This program is distributed in the hope that it will be useful, but WITHOUT
34
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
35
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
36
+ * for more details.
37
+ */
38
+
39
+#include "qemu/osdep.h"
40
+#include "libqtest-single.h"
41
+
42
+/* IoTKit/ARMSSE-200 timer0; driven at 25MHz in mps2-an385, so 40ns per tick */
43
+#define TIMER_BASE 0x40000000
44
+
45
+#define CTRL 0
46
+#define VALUE 4
47
+#define RELOAD 8
48
+#define INTSTATUS 0xc
49
+
50
+static void test_timer(void)
51
+{
52
+ g_assert_true(readl(TIMER_BASE + INTSTATUS) == 0);
53
+
54
+ /* Start timer: will fire after 40 * 1000 == 40000 ns */
55
+ writel(TIMER_BASE + RELOAD, 1000);
56
+ writel(TIMER_BASE + CTRL, 9);
57
+
58
+ /* Step to just past the 500th tick and check VALUE */
59
+ clock_step(40 * 500 + 1);
60
+ g_assert_cmpuint(readl(TIMER_BASE + INTSTATUS), ==, 0);
61
+ g_assert_cmpuint(readl(TIMER_BASE + VALUE), ==, 500);
62
+
63
+ /* Just past the 1000th tick: timer should have fired */
64
+ clock_step(40 * 500);
65
+ g_assert_cmpuint(readl(TIMER_BASE + INTSTATUS), ==, 1);
66
+ g_assert_cmpuint(readl(TIMER_BASE + VALUE), ==, 0);
67
+
68
+ /* VALUE reloads at the following tick */
69
+ clock_step(40);
70
+ g_assert_cmpuint(readl(TIMER_BASE + VALUE), ==, 1000);
71
+
72
+ /* Check write-1-to-clear behaviour of INTSTATUS */
73
+ writel(TIMER_BASE + INTSTATUS, 0);
74
+ g_assert_cmpuint(readl(TIMER_BASE + INTSTATUS), ==, 1);
75
+ writel(TIMER_BASE + INTSTATUS, 1);
76
+ g_assert_cmpuint(readl(TIMER_BASE + INTSTATUS), ==, 0);
77
+
78
+ /* Turn off the timer */
79
+ writel(TIMER_BASE + CTRL, 0);
80
+}
81
+
82
+int main(int argc, char **argv)
83
+{
84
+ int r;
85
+
86
+ g_test_init(&argc, &argv, NULL);
87
+
88
+ qtest_start("-machine mps2-an385");
89
+
90
+ qtest_add_func("/cmsdk-apb-timer/timer", test_timer);
91
+
92
+ r = g_test_run();
93
+
94
+ qtest_end();
95
+
96
+ return r;
97
+}
98
diff --git a/MAINTAINERS b/MAINTAINERS
99
index XXXXXXX..XXXXXXX 100644
100
--- a/MAINTAINERS
101
+++ b/MAINTAINERS
102
@@ -XXX,XX +XXX,XX @@ F: include/hw/rtc/pl031.h
103
F: include/hw/arm/primecell.h
104
F: hw/timer/cmsdk-apb-timer.c
105
F: include/hw/timer/cmsdk-apb-timer.h
106
+F: tests/qtest/cmsdk-apb-timer-test.c
107
F: hw/timer/cmsdk-apb-dualtimer.c
108
F: include/hw/timer/cmsdk-apb-dualtimer.h
109
F: hw/char/cmsdk-apb-uart.c
110
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
111
index XXXXXXX..XXXXXXX 100644
112
--- a/tests/qtest/meson.build
113
+++ b/tests/qtest/meson.build
114
@@ -XXX,XX +XXX,XX @@ qtests_npcm7xx = \
115
'npcm7xx_timer-test',
116
'npcm7xx_watchdog_timer-test']
117
qtests_arm = \
118
+ (config_all_devices.has_key('CONFIG_CMSDK_APB_TIMER') ? ['cmsdk-apb-timer-test'] : []) + \
119
(config_all_devices.has_key('CONFIG_PFLASH_CFI02') ? ['pflash-cfi02-test'] : []) + \
120
(config_all_devices.has_key('CONFIG_NPCM7XX') ? qtests_npcm7xx : []) + \
121
['arm-cpu-features',
122
--
123
2.20.1
124
125
diff view generated by jsdifflib
Deleted patch
1
Add a simple test of the CMSDK watchdog, since we're about to do some
2
refactoring of how it is clocked.
3
1
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Luc Michel <luc@lmichel.fr>
6
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20210128114145.20536-5-peter.maydell@linaro.org
9
Message-id: 20210121190622.22000-5-peter.maydell@linaro.org
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
---
12
tests/qtest/cmsdk-apb-watchdog-test.c | 79 +++++++++++++++++++++++++++
13
MAINTAINERS | 1 +
14
tests/qtest/meson.build | 1 +
15
3 files changed, 81 insertions(+)
16
create mode 100644 tests/qtest/cmsdk-apb-watchdog-test.c
17
18
diff --git a/tests/qtest/cmsdk-apb-watchdog-test.c b/tests/qtest/cmsdk-apb-watchdog-test.c
19
new file mode 100644
20
index XXXXXXX..XXXXXXX
21
--- /dev/null
22
+++ b/tests/qtest/cmsdk-apb-watchdog-test.c
23
@@ -XXX,XX +XXX,XX @@
24
+/*
25
+ * QTest testcase for the CMSDK APB watchdog device
26
+ *
27
+ * Copyright (c) 2021 Linaro Limited
28
+ *
29
+ * This program is free software; you can redistribute it and/or modify it
30
+ * under the terms of the GNU General Public License as published by the
31
+ * Free Software Foundation; either version 2 of the License, or
32
+ * (at your option) any later version.
33
+ *
34
+ * This program is distributed in the hope that it will be useful, but WITHOUT
35
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
36
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
37
+ * for more details.
38
+ */
39
+
40
+#include "qemu/osdep.h"
41
+#include "libqtest-single.h"
42
+
43
+/*
44
+ * lm3s811evb watchdog; at board startup this runs at 200MHz / 16 == 12.5MHz,
45
+ * which is 80ns per tick.
46
+ */
47
+#define WDOG_BASE 0x40000000
48
+
49
+#define WDOGLOAD 0
50
+#define WDOGVALUE 4
51
+#define WDOGCONTROL 8
52
+#define WDOGINTCLR 0xc
53
+#define WDOGRIS 0x10
54
+#define WDOGMIS 0x14
55
+#define WDOGLOCK 0xc00
56
+
57
+static void test_watchdog(void)
58
+{
59
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0);
60
+
61
+ writel(WDOG_BASE + WDOGCONTROL, 1);
62
+ writel(WDOG_BASE + WDOGLOAD, 1000);
63
+
64
+ /* Step to just past the 500th tick */
65
+ clock_step(500 * 80 + 1);
66
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0);
67
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 500);
68
+
69
+ /* Just past the 1000th tick: timer should have fired */
70
+ clock_step(500 * 80);
71
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 1);
72
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 0);
73
+
74
+ /* VALUE reloads at following tick */
75
+ clock_step(80);
76
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 1000);
77
+
78
+ /* Writing any value to WDOGINTCLR clears the interrupt and reloads */
79
+ clock_step(500 * 80);
80
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 500);
81
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 1);
82
+ writel(WDOG_BASE + WDOGINTCLR, 0);
83
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 1000);
84
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0);
85
+}
86
+
87
+int main(int argc, char **argv)
88
+{
89
+ int r;
90
+
91
+ g_test_init(&argc, &argv, NULL);
92
+
93
+ qtest_start("-machine lm3s811evb");
94
+
95
+ qtest_add_func("/cmsdk-apb-watchdog/watchdog", test_watchdog);
96
+
97
+ r = g_test_run();
98
+
99
+ qtest_end();
100
+
101
+ return r;
102
+}
103
diff --git a/MAINTAINERS b/MAINTAINERS
104
index XXXXXXX..XXXXXXX 100644
105
--- a/MAINTAINERS
106
+++ b/MAINTAINERS
107
@@ -XXX,XX +XXX,XX @@ F: hw/char/cmsdk-apb-uart.c
108
F: include/hw/char/cmsdk-apb-uart.h
109
F: hw/watchdog/cmsdk-apb-watchdog.c
110
F: include/hw/watchdog/cmsdk-apb-watchdog.h
111
+F: tests/qtest/cmsdk-apb-watchdog-test.c
112
F: hw/misc/tz-ppc.c
113
F: include/hw/misc/tz-ppc.h
114
F: hw/misc/tz-mpc.c
115
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
116
index XXXXXXX..XXXXXXX 100644
117
--- a/tests/qtest/meson.build
118
+++ b/tests/qtest/meson.build
119
@@ -XXX,XX +XXX,XX @@ qtests_npcm7xx = \
120
'npcm7xx_watchdog_timer-test']
121
qtests_arm = \
122
(config_all_devices.has_key('CONFIG_CMSDK_APB_TIMER') ? ['cmsdk-apb-timer-test'] : []) + \
123
+ (config_all_devices.has_key('CONFIG_CMSDK_APB_WATCHDOG') ? ['cmsdk-apb-watchdog-test'] : []) + \
124
(config_all_devices.has_key('CONFIG_PFLASH_CFI02') ? ['pflash-cfi02-test'] : []) + \
125
(config_all_devices.has_key('CONFIG_NPCM7XX') ? qtests_npcm7xx : []) + \
126
['arm-cpu-features',
127
--
128
2.20.1
129
130
diff view generated by jsdifflib
Deleted patch
1
As the first step in converting the CMSDK_APB_TIMER device to the
2
Clock framework, add a Clock input. For the moment we do nothing
3
with this clock; we will change the behaviour from using the
4
wdogclk-frq property to using the Clock once all the users of this
5
device have been converted to wire up the Clock.
6
1
7
This is a migration compatibility break for machines mps2-an385,
8
mps2-an386, mps2-an500, mps2-an511, mps2-an505, mps2-an521, musca-a,
9
musca-b1, lm3s811evb, lm3s6965evb.
10
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
Reviewed-by: Luc Michel <luc@lmichel.fr>
14
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
Message-id: 20210128114145.20536-10-peter.maydell@linaro.org
16
Message-id: 20210121190622.22000-10-peter.maydell@linaro.org
17
---
18
include/hw/watchdog/cmsdk-apb-watchdog.h | 3 +++
19
hw/watchdog/cmsdk-apb-watchdog.c | 7 +++++--
20
2 files changed, 8 insertions(+), 2 deletions(-)
21
22
diff --git a/include/hw/watchdog/cmsdk-apb-watchdog.h b/include/hw/watchdog/cmsdk-apb-watchdog.h
23
index XXXXXXX..XXXXXXX 100644
24
--- a/include/hw/watchdog/cmsdk-apb-watchdog.h
25
+++ b/include/hw/watchdog/cmsdk-apb-watchdog.h
26
@@ -XXX,XX +XXX,XX @@
27
*
28
* QEMU interface:
29
* + QOM property "wdogclk-frq": frequency at which the watchdog is clocked
30
+ * + Clock input "WDOGCLK": clock for the watchdog's timer
31
* + sysbus MMIO region 0: the register bank
32
* + sysbus IRQ 0: watchdog interrupt
33
*
34
@@ -XXX,XX +XXX,XX @@
35
36
#include "hw/sysbus.h"
37
#include "hw/ptimer.h"
38
+#include "hw/clock.h"
39
#include "qom/object.h"
40
41
#define TYPE_CMSDK_APB_WATCHDOG "cmsdk-apb-watchdog"
42
@@ -XXX,XX +XXX,XX @@ struct CMSDKAPBWatchdog {
43
uint32_t wdogclk_frq;
44
bool is_luminary;
45
struct ptimer_state *timer;
46
+ Clock *wdogclk;
47
48
uint32_t control;
49
uint32_t intstatus;
50
diff --git a/hw/watchdog/cmsdk-apb-watchdog.c b/hw/watchdog/cmsdk-apb-watchdog.c
51
index XXXXXXX..XXXXXXX 100644
52
--- a/hw/watchdog/cmsdk-apb-watchdog.c
53
+++ b/hw/watchdog/cmsdk-apb-watchdog.c
54
@@ -XXX,XX +XXX,XX @@
55
#include "hw/irq.h"
56
#include "hw/qdev-properties.h"
57
#include "hw/registerfields.h"
58
+#include "hw/qdev-clock.h"
59
#include "hw/watchdog/cmsdk-apb-watchdog.h"
60
#include "migration/vmstate.h"
61
62
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_init(Object *obj)
63
s, "cmsdk-apb-watchdog", 0x1000);
64
sysbus_init_mmio(sbd, &s->iomem);
65
sysbus_init_irq(sbd, &s->wdogint);
66
+ s->wdogclk = qdev_init_clock_in(DEVICE(s), "WDOGCLK", NULL, NULL);
67
68
s->is_luminary = false;
69
s->id = cmsdk_apb_watchdog_id;
70
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_realize(DeviceState *dev, Error **errp)
71
72
static const VMStateDescription cmsdk_apb_watchdog_vmstate = {
73
.name = "cmsdk-apb-watchdog",
74
- .version_id = 1,
75
- .minimum_version_id = 1,
76
+ .version_id = 2,
77
+ .minimum_version_id = 2,
78
.fields = (VMStateField[]) {
79
+ VMSTATE_CLOCK(wdogclk, CMSDKAPBWatchdog),
80
VMSTATE_PTIMER(timer, CMSDKAPBWatchdog),
81
VMSTATE_UINT32(control, CMSDKAPBWatchdog),
82
VMSTATE_UINT32(intstatus, CMSDKAPBWatchdog),
83
--
84
2.20.1
85
86
diff view generated by jsdifflib
Deleted patch
1
Create two input clocks on the ARMSSE devices, one for the normal
2
MAINCLK, and one for the 32KHz S32KCLK, and wire these up to the
3
appropriate devices. The old property-based clock frequency setting
4
will remain in place until conversion is complete.
5
1
6
This is a migration compatibility break for machines mps2-an505,
7
mps2-an521, musca-a, musca-b1.
8
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Reviewed-by: Luc Michel <luc@lmichel.fr>
12
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
Message-id: 20210128114145.20536-12-peter.maydell@linaro.org
14
Message-id: 20210121190622.22000-12-peter.maydell@linaro.org
15
---
16
include/hw/arm/armsse.h | 6 ++++++
17
hw/arm/armsse.c | 17 +++++++++++++++--
18
2 files changed, 21 insertions(+), 2 deletions(-)
19
20
diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h
21
index XXXXXXX..XXXXXXX 100644
22
--- a/include/hw/arm/armsse.h
23
+++ b/include/hw/arm/armsse.h
24
@@ -XXX,XX +XXX,XX @@
25
* per-CPU identity and control register blocks
26
*
27
* QEMU interface:
28
+ * + Clock input "MAINCLK": clock for CPUs and most peripherals
29
+ * + Clock input "S32KCLK": slow 32KHz clock used for a few peripherals
30
* + QOM property "memory" is a MemoryRegion containing the devices provided
31
* by the board model.
32
* + QOM property "MAINCLK_FRQ" is the frequency of the main system clock
33
@@ -XXX,XX +XXX,XX @@
34
#include "hw/misc/armsse-mhu.h"
35
#include "hw/misc/unimp.h"
36
#include "hw/or-irq.h"
37
+#include "hw/clock.h"
38
#include "hw/core/split-irq.h"
39
#include "hw/cpu/cluster.h"
40
#include "qom/object.h"
41
@@ -XXX,XX +XXX,XX @@ struct ARMSSE {
42
43
uint32_t nsccfg;
44
45
+ Clock *mainclk;
46
+ Clock *s32kclk;
47
+
48
/* Properties */
49
MemoryRegion *board_memory;
50
uint32_t exp_numirq;
51
diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c
52
index XXXXXXX..XXXXXXX 100644
53
--- a/hw/arm/armsse.c
54
+++ b/hw/arm/armsse.c
55
@@ -XXX,XX +XXX,XX @@
56
#include "hw/arm/armsse.h"
57
#include "hw/arm/boot.h"
58
#include "hw/irq.h"
59
+#include "hw/qdev-clock.h"
60
61
/* Format of the System Information block SYS_CONFIG register */
62
typedef enum SysConfigFormat {
63
@@ -XXX,XX +XXX,XX @@ static void armsse_init(Object *obj)
64
assert(info->sram_banks <= MAX_SRAM_BANKS);
65
assert(info->num_cpus <= SSE_MAX_CPUS);
66
67
+ s->mainclk = qdev_init_clock_in(DEVICE(s), "MAINCLK", NULL, NULL);
68
+ s->s32kclk = qdev_init_clock_in(DEVICE(s), "S32KCLK", NULL, NULL);
69
+
70
memory_region_init(&s->container, obj, "armsse-container", UINT64_MAX);
71
72
for (i = 0; i < info->num_cpus; i++) {
73
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
74
* map its upstream ends to the right place in the container.
75
*/
76
qdev_prop_set_uint32(DEVICE(&s->timer0), "pclk-frq", s->mainclk_frq);
77
+ qdev_connect_clock_in(DEVICE(&s->timer0), "pclk", s->mainclk);
78
if (!sysbus_realize(SYS_BUS_DEVICE(&s->timer0), errp)) {
79
return;
80
}
81
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
82
&error_abort);
83
84
qdev_prop_set_uint32(DEVICE(&s->timer1), "pclk-frq", s->mainclk_frq);
85
+ qdev_connect_clock_in(DEVICE(&s->timer1), "pclk", s->mainclk);
86
if (!sysbus_realize(SYS_BUS_DEVICE(&s->timer1), errp)) {
87
return;
88
}
89
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
90
&error_abort);
91
92
qdev_prop_set_uint32(DEVICE(&s->dualtimer), "pclk-frq", s->mainclk_frq);
93
+ qdev_connect_clock_in(DEVICE(&s->dualtimer), "TIMCLK", s->mainclk);
94
if (!sysbus_realize(SYS_BUS_DEVICE(&s->dualtimer), errp)) {
95
return;
96
}
97
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
98
* 0x4002f000: S32K timer
99
*/
100
qdev_prop_set_uint32(DEVICE(&s->s32ktimer), "pclk-frq", S32KCLK);
101
+ qdev_connect_clock_in(DEVICE(&s->s32ktimer), "pclk", s->s32kclk);
102
if (!sysbus_realize(SYS_BUS_DEVICE(&s->s32ktimer), errp)) {
103
return;
104
}
105
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
106
qdev_get_gpio_in_named(DEVICE(&s->armv7m), "NMI", 0));
107
108
qdev_prop_set_uint32(DEVICE(&s->s32kwatchdog), "wdogclk-frq", S32KCLK);
109
+ qdev_connect_clock_in(DEVICE(&s->s32kwatchdog), "WDOGCLK", s->s32kclk);
110
if (!sysbus_realize(SYS_BUS_DEVICE(&s->s32kwatchdog), errp)) {
111
return;
112
}
113
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
114
/* 0x40080000 .. 0x4008ffff : ARMSSE second Base peripheral region */
115
116
qdev_prop_set_uint32(DEVICE(&s->nswatchdog), "wdogclk-frq", s->mainclk_frq);
117
+ qdev_connect_clock_in(DEVICE(&s->nswatchdog), "WDOGCLK", s->mainclk);
118
if (!sysbus_realize(SYS_BUS_DEVICE(&s->nswatchdog), errp)) {
119
return;
120
}
121
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
122
sysbus_mmio_map(SYS_BUS_DEVICE(&s->nswatchdog), 0, 0x40081000);
123
124
qdev_prop_set_uint32(DEVICE(&s->swatchdog), "wdogclk-frq", s->mainclk_frq);
125
+ qdev_connect_clock_in(DEVICE(&s->swatchdog), "WDOGCLK", s->mainclk);
126
if (!sysbus_realize(SYS_BUS_DEVICE(&s->swatchdog), errp)) {
127
return;
128
}
129
@@ -XXX,XX +XXX,XX @@ static void armsse_idau_check(IDAUInterface *ii, uint32_t address,
130
131
static const VMStateDescription armsse_vmstate = {
132
.name = "iotkit",
133
- .version_id = 1,
134
- .minimum_version_id = 1,
135
+ .version_id = 2,
136
+ .minimum_version_id = 2,
137
.fields = (VMStateField[]) {
138
+ VMSTATE_CLOCK(mainclk, ARMSSE),
139
+ VMSTATE_CLOCK(s32kclk, ARMSSE),
140
VMSTATE_UINT32(nsccfg, ARMSSE),
141
VMSTATE_END_OF_LIST()
142
}
143
--
144
2.20.1
145
146
diff view generated by jsdifflib
Deleted patch
1
Create a fixed-frequency Clock object to be the SYSCLK, and wire it
2
up to the devices that require it.
3
1
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Reviewed-by: Luc Michel <luc@lmichel.fr>
7
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20210128114145.20536-14-peter.maydell@linaro.org
9
Message-id: 20210121190622.22000-14-peter.maydell@linaro.org
10
---
11
hw/arm/mps2.c | 9 +++++++++
12
1 file changed, 9 insertions(+)
13
14
diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/arm/mps2.c
17
+++ b/hw/arm/mps2.c
18
@@ -XXX,XX +XXX,XX @@
19
#include "hw/net/lan9118.h"
20
#include "net/net.h"
21
#include "hw/watchdog/cmsdk-apb-watchdog.h"
22
+#include "hw/qdev-clock.h"
23
#include "qom/object.h"
24
25
typedef enum MPS2FPGAType {
26
@@ -XXX,XX +XXX,XX @@ struct MPS2MachineState {
27
CMSDKAPBDualTimer dualtimer;
28
CMSDKAPBWatchdog watchdog;
29
CMSDKAPBTimer timer[2];
30
+ Clock *sysclk;
31
};
32
33
#define TYPE_MPS2_MACHINE "mps2"
34
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
35
exit(EXIT_FAILURE);
36
}
37
38
+ /* This clock doesn't need migration because it is fixed-frequency */
39
+ mms->sysclk = clock_new(OBJECT(machine), "SYSCLK");
40
+ clock_set_hz(mms->sysclk, SYSCLK_FRQ);
41
+
42
/* The FPGA images have an odd combination of different RAMs,
43
* because in hardware they are different implementations and
44
* connected to different buses, giving varying performance/size
45
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
46
TYPE_CMSDK_APB_TIMER);
47
sbd = SYS_BUS_DEVICE(&mms->timer[i]);
48
qdev_prop_set_uint32(DEVICE(&mms->timer[i]), "pclk-frq", SYSCLK_FRQ);
49
+ qdev_connect_clock_in(DEVICE(&mms->timer[i]), "pclk", mms->sysclk);
50
sysbus_realize_and_unref(sbd, &error_fatal);
51
sysbus_mmio_map(sbd, 0, base);
52
sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(armv7m, irqno));
53
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
54
object_initialize_child(OBJECT(mms), "dualtimer", &mms->dualtimer,
55
TYPE_CMSDK_APB_DUALTIMER);
56
qdev_prop_set_uint32(DEVICE(&mms->dualtimer), "pclk-frq", SYSCLK_FRQ);
57
+ qdev_connect_clock_in(DEVICE(&mms->dualtimer), "TIMCLK", mms->sysclk);
58
sysbus_realize(SYS_BUS_DEVICE(&mms->dualtimer), &error_fatal);
59
sysbus_connect_irq(SYS_BUS_DEVICE(&mms->dualtimer), 0,
60
qdev_get_gpio_in(armv7m, 10));
61
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
62
object_initialize_child(OBJECT(mms), "watchdog", &mms->watchdog,
63
TYPE_CMSDK_APB_WATCHDOG);
64
qdev_prop_set_uint32(DEVICE(&mms->watchdog), "wdogclk-frq", SYSCLK_FRQ);
65
+ qdev_connect_clock_in(DEVICE(&mms->watchdog), "WDOGCLK", mms->sysclk);
66
sysbus_realize(SYS_BUS_DEVICE(&mms->watchdog), &error_fatal);
67
sysbus_connect_irq(SYS_BUS_DEVICE(&mms->watchdog), 0,
68
qdev_get_gpio_in_named(armv7m, "NMI", 0));
69
--
70
2.20.1
71
72
diff view generated by jsdifflib