1
Patches for rc1: nothing major, just some minor bugfixes and
1
Arm changes for before softfreeze: mostly my PL061/GPIO patches,
2
code cleanups.
2
but also a new M-profile board and various other things.
3
3
4
thanks
4
-- PMM
5
-- PMM
5
6
6
The following changes since commit f7e1914adad8885a5d4c70239ab90d901ed97e9f:
7
The following changes since commit 05de778b5b8ab0b402996769117b88c7ea5c7c61:
7
8
8
Merge remote-tracking branch 'remotes/alistair/tags/pull-riscv-to-apply-20201109' into staging (2020-11-10 09:24:56 +0000)
9
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2021-07-09 14:30:01 +0100)
9
10
10
are available in the Git repository at:
11
are available in the Git repository at:
11
12
12
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20201110
13
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210709
13
14
14
for you to fetch changes up to b6c56c8a9a4064ea783f352f43c5df6231a110fa:
15
for you to fetch changes up to 05449abb1d4c5f0c69ceb3d8d03cbc75de39b646:
15
16
16
target/arm/translate-neon.c: Handle VTBL UNDEF case before VFP access check (2020-11-10 11:03:48 +0000)
17
hw/intc: Improve formatting of MEMTX_ERROR guest error message (2021-07-09 16:09:12 +0100)
17
18
18
----------------------------------------------------------------
19
----------------------------------------------------------------
19
target-arm queue:
20
target-arm queue:
20
* hw/arm/Kconfig: ARM_V7M depends on PTIMER
21
* New machine type: stm32vldiscovery
21
* Minor coding style fixes
22
* hw/intc/arm_gicv3_cpuif: Fix virtual irq number check in icv_[dir|eoir]_write
22
* docs: add some notes on the sbsa-ref machine
23
* hw/gpio/pl061: Honour Luminary PL061 PUR and PDR registers
23
* hw/arm/virt: Remove dependency on Cortex-A15 MPCore peripherals
24
* virt: Fix implementation of GPIO-based powerdown/shutdown mechanism
24
* target/arm: Fix neon VTBL/VTBX for len > 1
25
* Correct the encoding of MDCCSR_EL0 and DBGDSCRint
25
* hw/arm/armsse: Correct expansion MPC interrupt lines
26
* hw/intc: Improve formatting of MEMTX_ERROR guest error message
26
* hw/misc/stm32f2xx_syscfg: Remove extraneous IRQ
27
* hw/arm/nseries: Remove invalid/unnecessary n8x0_uart_setup()
28
* hw/arm/musicpal: Don't connect two qemu_irqs directly to the same input
29
* hw/arm/musicpal: Only use qdev_get_gpio_in() when necessary
30
* hw/arm/nseries: Check return value from load_image_targphys()
31
* tests/qtest/npcm7xx_rng-test: count runs properly
32
* target/arm/translate-neon.c: Handle VTBL UNDEF case before VFP access check
33
27
34
----------------------------------------------------------------
28
----------------------------------------------------------------
35
Alex Bennée (1):
29
Alexandre Iooss (4):
36
docs: add some notes on the sbsa-ref machine
30
stm32f100: Add the stm32f100 SoC
31
stm32vldiscovery: Add the STM32VLDISCOVERY Machine
32
docs/system: arm: Add stm32 boards description
33
tests/boot-serial-test: Add STM32VLDISCOVERY board testcase
37
34
38
AlexChen (1):
35
Peter Maydell (10):
39
ssi: Fix bad printf format specifiers
36
hw/gpio/pl061: Convert DPRINTF to tracepoints
37
hw/gpio/pl061: Clean up read/write offset handling logic
38
hw/gpio/pl061: Add tracepoints for register read and write
39
hw/gpio/pl061: Document the interface of this device
40
hw/gpio/pl061: Honour Luminary PL061 PUR and PDR registers
41
hw/gpio/pl061: Make pullup/pulldown of outputs configurable
42
hw/arm/virt: Make PL061 GPIO lines pulled low, not high
43
hw/gpio/pl061: Convert to 3-phase reset and assert GPIO lines correctly on reset
44
hw/gpio/pl061: Document a shortcoming in our implementation
45
hw/arm/stellaris: Expand comment about handling of OLED chipselect
40
46
41
Andrew Jones (1):
47
Rebecca Cran (1):
42
hw/arm/Kconfig: ARM_V7M depends on PTIMER
48
hw/intc: Improve formatting of MEMTX_ERROR guest error message
43
49
44
Havard Skinnemoen (1):
50
Ricardo Koller (1):
45
tests/qtest/npcm7xx_rng-test: count runs properly
51
hw/intc/arm_gicv3_cpuif: Fix virtual irq number check in icv_[dir|eoir]_write
46
52
47
Peter Maydell (2):
53
hnick@vmware.com (1):
48
hw/arm/nseries: Check return value from load_image_targphys()
54
target/arm: Correct the encoding of MDCCSR_EL0 and DBGDSCRint
49
target/arm/translate-neon.c: Handle VTBL UNDEF case before VFP access check
50
55
51
Philippe Mathieu-Daudé (6):
56
docs/system/arm/stm32.rst | 66 +++++++
52
hw/arm/virt: Remove dependency on Cortex-A15 MPCore peripherals
57
docs/system/target-arm.rst | 1 +
53
hw/arm/armsse: Correct expansion MPC interrupt lines
58
default-configs/devices/arm-softmmu.mak | 1 +
54
hw/misc/stm32f2xx_syscfg: Remove extraneous IRQ
59
include/hw/arm/stm32f100_soc.h | 57 ++++++
55
hw/arm/nseries: Remove invalid/unnecessary n8x0_uart_setup()
60
hw/arm/stellaris.c | 56 +++++-
56
hw/arm/musicpal: Don't connect two qemu_irqs directly to the same input
61
hw/arm/stm32f100_soc.c | 182 +++++++++++++++++
57
hw/arm/musicpal: Only use qdev_get_gpio_in() when necessary
62
hw/arm/stm32vldiscovery.c | 66 +++++++
63
hw/arm/virt.c | 3 +
64
hw/gpio/pl061.c | 341 +++++++++++++++++++++++++-------
65
hw/intc/arm_gicv3_cpuif.c | 4 +-
66
hw/intc/arm_gicv3_redist.c | 4 +-
67
target/arm/helper.c | 16 +-
68
tests/qtest/boot-serial-test.c | 37 ++++
69
MAINTAINERS | 13 ++
70
hw/arm/Kconfig | 10 +
71
hw/arm/meson.build | 2 +
72
hw/gpio/trace-events | 9 +
73
17 files changed, 790 insertions(+), 78 deletions(-)
74
create mode 100644 docs/system/arm/stm32.rst
75
create mode 100644 include/hw/arm/stm32f100_soc.h
76
create mode 100644 hw/arm/stm32f100_soc.c
77
create mode 100644 hw/arm/stm32vldiscovery.c
58
78
59
Richard Henderson (1):
60
target/arm: Fix neon VTBL/VTBX for len > 1
61
62
Xinhao Zhang (3):
63
target/arm: add spaces around operator
64
target/arm: Don't use '#' flag of printf format
65
target/arm: add space before the open parenthesis '('
66
67
docs/system/arm/sbsa.rst | 32 ++++++++++++++++++++++
68
docs/system/target-arm.rst | 1 +
69
include/hw/misc/stm32f2xx_syscfg.h | 2 --
70
target/arm/helper.h | 2 +-
71
hw/arm/armsse.c | 3 +-
72
hw/arm/musicpal.c | 40 +++++++++++++++++----------
73
hw/arm/nseries.c | 26 ++++++++----------
74
hw/arm/stm32f205_soc.c | 1 -
75
hw/misc/stm32f2xx_syscfg.c | 2 --
76
hw/ssi/imx_spi.c | 2 +-
77
hw/ssi/xilinx_spi.c | 2 +-
78
target/arm/arch_dump.c | 8 +++---
79
target/arm/arm-semi.c | 8 +++---
80
target/arm/helper.c | 2 +-
81
target/arm/op_helper.c | 23 +++++++++-------
82
target/arm/translate-a64.c | 4 +--
83
target/arm/translate.c | 2 +-
84
tests/qtest/npcm7xx_rng-test.c | 2 +-
85
hw/arm/Kconfig | 3 +-
86
target/arm/translate-neon.c.inc | 56 ++++++++++++++------------------------
87
20 files changed, 123 insertions(+), 98 deletions(-)
88
create mode 100644 docs/system/arm/sbsa.rst
89
diff view generated by jsdifflib
1
From: Andrew Jones <drjones@redhat.com>
1
From: Alexandre Iooss <erdnaxe@crans.org>
2
2
3
commit 32bd322a0134 ("hw/timer/armv7m_systick: Rewrite to use ptimers")
3
This SoC is similar to stm32f205 SoC.
4
changed armv7m_systick to build on ptimers. Make sure we have ptimers
4
This will be used by the STM32VLDISCOVERY to create a machine.
5
in the build when building armv7m_systick.
5
6
6
Signed-off-by: Alexandre Iooss <erdnaxe@crans.org>
7
Signed-off-by: Andrew Jones <drjones@redhat.com>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Message-id: 20210617165647.2575955-2-erdnaxe@crans.org
9
Message-id: 20201104103343.30392-1-drjones@redhat.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
10
---
12
hw/arm/Kconfig | 1 +
11
include/hw/arm/stm32f100_soc.h | 57 +++++++++++
13
1 file changed, 1 insertion(+)
12
hw/arm/stm32f100_soc.c | 182 +++++++++++++++++++++++++++++++++
14
13
MAINTAINERS | 6 ++
14
hw/arm/Kconfig | 6 ++
15
hw/arm/meson.build | 1 +
16
5 files changed, 252 insertions(+)
17
create mode 100644 include/hw/arm/stm32f100_soc.h
18
create mode 100644 hw/arm/stm32f100_soc.c
19
20
diff --git a/include/hw/arm/stm32f100_soc.h b/include/hw/arm/stm32f100_soc.h
21
new file mode 100644
22
index XXXXXXX..XXXXXXX
23
--- /dev/null
24
+++ b/include/hw/arm/stm32f100_soc.h
25
@@ -XXX,XX +XXX,XX @@
26
+/*
27
+ * STM32F100 SoC
28
+ *
29
+ * Copyright (c) 2021 Alexandre Iooss <erdnaxe@crans.org>
30
+ *
31
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
32
+ * of this software and associated documentation files (the "Software"), to deal
33
+ * in the Software without restriction, including without limitation the rights
34
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
35
+ * copies of the Software, and to permit persons to whom the Software is
36
+ * furnished to do so, subject to the following conditions:
37
+ *
38
+ * The above copyright notice and this permission notice shall be included in
39
+ * all copies or substantial portions of the Software.
40
+ *
41
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
44
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
45
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
46
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
47
+ * THE SOFTWARE.
48
+ */
49
+
50
+#ifndef HW_ARM_STM32F100_SOC_H
51
+#define HW_ARM_STM32F100_SOC_H
52
+
53
+#include "hw/char/stm32f2xx_usart.h"
54
+#include "hw/ssi/stm32f2xx_spi.h"
55
+#include "hw/arm/armv7m.h"
56
+#include "qom/object.h"
57
+
58
+#define TYPE_STM32F100_SOC "stm32f100-soc"
59
+OBJECT_DECLARE_SIMPLE_TYPE(STM32F100State, STM32F100_SOC)
60
+
61
+#define STM_NUM_USARTS 3
62
+#define STM_NUM_SPIS 2
63
+
64
+#define FLASH_BASE_ADDRESS 0x08000000
65
+#define FLASH_SIZE (128 * 1024)
66
+#define SRAM_BASE_ADDRESS 0x20000000
67
+#define SRAM_SIZE (8 * 1024)
68
+
69
+struct STM32F100State {
70
+ /*< private >*/
71
+ SysBusDevice parent_obj;
72
+
73
+ /*< public >*/
74
+ char *cpu_type;
75
+
76
+ ARMv7MState armv7m;
77
+
78
+ STM32F2XXUsartState usart[STM_NUM_USARTS];
79
+ STM32F2XXSPIState spi[STM_NUM_SPIS];
80
+};
81
+
82
+#endif
83
diff --git a/hw/arm/stm32f100_soc.c b/hw/arm/stm32f100_soc.c
84
new file mode 100644
85
index XXXXXXX..XXXXXXX
86
--- /dev/null
87
+++ b/hw/arm/stm32f100_soc.c
88
@@ -XXX,XX +XXX,XX @@
89
+/*
90
+ * STM32F100 SoC
91
+ *
92
+ * Copyright (c) 2021 Alexandre Iooss <erdnaxe@crans.org>
93
+ * Copyright (c) 2014 Alistair Francis <alistair@alistair23.me>
94
+ *
95
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
96
+ * of this software and associated documentation files (the "Software"), to deal
97
+ * in the Software without restriction, including without limitation the rights
98
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
99
+ * copies of the Software, and to permit persons to whom the Software is
100
+ * furnished to do so, subject to the following conditions:
101
+ *
102
+ * The above copyright notice and this permission notice shall be included in
103
+ * all copies or substantial portions of the Software.
104
+ *
105
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
106
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
107
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
108
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
109
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
110
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
111
+ * THE SOFTWARE.
112
+ */
113
+
114
+#include "qemu/osdep.h"
115
+#include "qapi/error.h"
116
+#include "qemu/module.h"
117
+#include "hw/arm/boot.h"
118
+#include "exec/address-spaces.h"
119
+#include "hw/arm/stm32f100_soc.h"
120
+#include "hw/qdev-properties.h"
121
+#include "hw/misc/unimp.h"
122
+#include "sysemu/sysemu.h"
123
+
124
+/* stm32f100_soc implementation is derived from stm32f205_soc */
125
+
126
+static const uint32_t usart_addr[STM_NUM_USARTS] = { 0x40013800, 0x40004400,
127
+ 0x40004800 };
128
+static const uint32_t spi_addr[STM_NUM_SPIS] = { 0x40013000, 0x40003800 };
129
+
130
+static const int usart_irq[STM_NUM_USARTS] = {37, 38, 39};
131
+static const int spi_irq[STM_NUM_SPIS] = {35, 36};
132
+
133
+static void stm32f100_soc_initfn(Object *obj)
134
+{
135
+ STM32F100State *s = STM32F100_SOC(obj);
136
+ int i;
137
+
138
+ object_initialize_child(obj, "armv7m", &s->armv7m, TYPE_ARMV7M);
139
+
140
+ for (i = 0; i < STM_NUM_USARTS; i++) {
141
+ object_initialize_child(obj, "usart[*]", &s->usart[i],
142
+ TYPE_STM32F2XX_USART);
143
+ }
144
+
145
+ for (i = 0; i < STM_NUM_SPIS; i++) {
146
+ object_initialize_child(obj, "spi[*]", &s->spi[i], TYPE_STM32F2XX_SPI);
147
+ }
148
+}
149
+
150
+static void stm32f100_soc_realize(DeviceState *dev_soc, Error **errp)
151
+{
152
+ STM32F100State *s = STM32F100_SOC(dev_soc);
153
+ DeviceState *dev, *armv7m;
154
+ SysBusDevice *busdev;
155
+ int i;
156
+
157
+ MemoryRegion *system_memory = get_system_memory();
158
+ MemoryRegion *sram = g_new(MemoryRegion, 1);
159
+ MemoryRegion *flash = g_new(MemoryRegion, 1);
160
+ MemoryRegion *flash_alias = g_new(MemoryRegion, 1);
161
+
162
+ /*
163
+ * Init flash region
164
+ * Flash starts at 0x08000000 and then is aliased to boot memory at 0x0
165
+ */
166
+ memory_region_init_rom(flash, OBJECT(dev_soc), "STM32F100.flash",
167
+ FLASH_SIZE, &error_fatal);
168
+ memory_region_init_alias(flash_alias, OBJECT(dev_soc),
169
+ "STM32F100.flash.alias", flash, 0, FLASH_SIZE);
170
+ memory_region_add_subregion(system_memory, FLASH_BASE_ADDRESS, flash);
171
+ memory_region_add_subregion(system_memory, 0, flash_alias);
172
+
173
+ /* Init SRAM region */
174
+ memory_region_init_ram(sram, NULL, "STM32F100.sram", SRAM_SIZE,
175
+ &error_fatal);
176
+ memory_region_add_subregion(system_memory, SRAM_BASE_ADDRESS, sram);
177
+
178
+ /* Init ARMv7m */
179
+ armv7m = DEVICE(&s->armv7m);
180
+ qdev_prop_set_uint32(armv7m, "num-irq", 61);
181
+ qdev_prop_set_string(armv7m, "cpu-type", s->cpu_type);
182
+ qdev_prop_set_bit(armv7m, "enable-bitband", true);
183
+ object_property_set_link(OBJECT(&s->armv7m), "memory",
184
+ OBJECT(get_system_memory()), &error_abort);
185
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->armv7m), errp)) {
186
+ return;
187
+ }
188
+
189
+ /* Attach UART (uses USART registers) and USART controllers */
190
+ for (i = 0; i < STM_NUM_USARTS; i++) {
191
+ dev = DEVICE(&(s->usart[i]));
192
+ qdev_prop_set_chr(dev, "chardev", serial_hd(i));
193
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->usart[i]), errp)) {
194
+ return;
195
+ }
196
+ busdev = SYS_BUS_DEVICE(dev);
197
+ sysbus_mmio_map(busdev, 0, usart_addr[i]);
198
+ sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(armv7m, usart_irq[i]));
199
+ }
200
+
201
+ /* SPI 1 and 2 */
202
+ for (i = 0; i < STM_NUM_SPIS; i++) {
203
+ dev = DEVICE(&(s->spi[i]));
204
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), errp)) {
205
+ return;
206
+ }
207
+ busdev = SYS_BUS_DEVICE(dev);
208
+ sysbus_mmio_map(busdev, 0, spi_addr[i]);
209
+ sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(armv7m, spi_irq[i]));
210
+ }
211
+
212
+ create_unimplemented_device("timer[2]", 0x40000000, 0x400);
213
+ create_unimplemented_device("timer[3]", 0x40000400, 0x400);
214
+ create_unimplemented_device("timer[4]", 0x40000800, 0x400);
215
+ create_unimplemented_device("timer[6]", 0x40001000, 0x400);
216
+ create_unimplemented_device("timer[7]", 0x40001400, 0x400);
217
+ create_unimplemented_device("RTC", 0x40002800, 0x400);
218
+ create_unimplemented_device("WWDG", 0x40002C00, 0x400);
219
+ create_unimplemented_device("IWDG", 0x40003000, 0x400);
220
+ create_unimplemented_device("I2C1", 0x40005400, 0x400);
221
+ create_unimplemented_device("I2C2", 0x40005800, 0x400);
222
+ create_unimplemented_device("BKP", 0x40006C00, 0x400);
223
+ create_unimplemented_device("PWR", 0x40007000, 0x400);
224
+ create_unimplemented_device("DAC", 0x40007400, 0x400);
225
+ create_unimplemented_device("CEC", 0x40007800, 0x400);
226
+ create_unimplemented_device("AFIO", 0x40010000, 0x400);
227
+ create_unimplemented_device("EXTI", 0x40010400, 0x400);
228
+ create_unimplemented_device("GPIOA", 0x40010800, 0x400);
229
+ create_unimplemented_device("GPIOB", 0x40010C00, 0x400);
230
+ create_unimplemented_device("GPIOC", 0x40011000, 0x400);
231
+ create_unimplemented_device("GPIOD", 0x40011400, 0x400);
232
+ create_unimplemented_device("GPIOE", 0x40011800, 0x400);
233
+ create_unimplemented_device("ADC1", 0x40012400, 0x400);
234
+ create_unimplemented_device("timer[1]", 0x40012C00, 0x400);
235
+ create_unimplemented_device("timer[15]", 0x40014000, 0x400);
236
+ create_unimplemented_device("timer[16]", 0x40014400, 0x400);
237
+ create_unimplemented_device("timer[17]", 0x40014800, 0x400);
238
+ create_unimplemented_device("DMA", 0x40020000, 0x400);
239
+ create_unimplemented_device("RCC", 0x40021000, 0x400);
240
+ create_unimplemented_device("Flash Int", 0x40022000, 0x400);
241
+ create_unimplemented_device("CRC", 0x40023000, 0x400);
242
+}
243
+
244
+static Property stm32f100_soc_properties[] = {
245
+ DEFINE_PROP_STRING("cpu-type", STM32F100State, cpu_type),
246
+ DEFINE_PROP_END_OF_LIST(),
247
+};
248
+
249
+static void stm32f100_soc_class_init(ObjectClass *klass, void *data)
250
+{
251
+ DeviceClass *dc = DEVICE_CLASS(klass);
252
+
253
+ dc->realize = stm32f100_soc_realize;
254
+ device_class_set_props(dc, stm32f100_soc_properties);
255
+}
256
+
257
+static const TypeInfo stm32f100_soc_info = {
258
+ .name = TYPE_STM32F100_SOC,
259
+ .parent = TYPE_SYS_BUS_DEVICE,
260
+ .instance_size = sizeof(STM32F100State),
261
+ .instance_init = stm32f100_soc_initfn,
262
+ .class_init = stm32f100_soc_class_init,
263
+};
264
+
265
+static void stm32f100_soc_types(void)
266
+{
267
+ type_register_static(&stm32f100_soc_info);
268
+}
269
+
270
+type_init(stm32f100_soc_types)
271
diff --git a/MAINTAINERS b/MAINTAINERS
272
index XXXXXXX..XXXXXXX 100644
273
--- a/MAINTAINERS
274
+++ b/MAINTAINERS
275
@@ -XXX,XX +XXX,XX @@ L: qemu-arm@nongnu.org
276
S: Maintained
277
F: hw/arm/virt-acpi-build.c
278
279
+STM32F100
280
+M: Alexandre Iooss <erdnaxe@crans.org>
281
+L: qemu-arm@nongnu.org
282
+S: Maintained
283
+F: hw/arm/stm32f100_soc.c
284
+
285
STM32F205
286
M: Alistair Francis <alistair@alistair23.me>
287
M: Peter Maydell <peter.maydell@linaro.org>
15
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
288
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
16
index XXXXXXX..XXXXXXX 100644
289
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/Kconfig
290
--- a/hw/arm/Kconfig
18
+++ b/hw/arm/Kconfig
291
+++ b/hw/arm/Kconfig
19
@@ -XXX,XX +XXX,XX @@ config ZYNQ
292
@@ -XXX,XX +XXX,XX @@ config RASPI
20
293
select SDHCI
21
config ARM_V7M
294
select USB_DWC2
295
296
+config STM32F100_SOC
297
+ bool
298
+ select ARM_V7M
299
+ select STM32F2XX_USART
300
+ select STM32F2XX_SPI
301
+
302
config STM32F205_SOC
22
bool
303
bool
23
+ select PTIMER
304
select ARM_V7M
24
305
diff --git a/hw/arm/meson.build b/hw/arm/meson.build
25
config ALLWINNER_A10
306
index XXXXXXX..XXXXXXX 100644
26
bool
307
--- a/hw/arm/meson.build
308
+++ b/hw/arm/meson.build
309
@@ -XXX,XX +XXX,XX @@ arm_ss.add(when: 'CONFIG_STRONGARM', if_true: files('strongarm.c'))
310
arm_ss.add(when: 'CONFIG_ALLWINNER_A10', if_true: files('allwinner-a10.c', 'cubieboard.c'))
311
arm_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3.c', 'orangepi.c'))
312
arm_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_peripherals.c', 'bcm2836.c', 'raspi.c'))
313
+arm_ss.add(when: 'CONFIG_STM32F100_SOC', if_true: files('stm32f100_soc.c'))
314
arm_ss.add(when: 'CONFIG_STM32F205_SOC', if_true: files('stm32f205_soc.c'))
315
arm_ss.add(when: 'CONFIG_STM32F405_SOC', if_true: files('stm32f405_soc.c'))
316
arm_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx-zynqmp.c', 'xlnx-zcu102.c'))
27
--
317
--
28
2.20.1
318
2.20.1
29
319
30
320
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Alexandre Iooss <erdnaxe@crans.org>
2
2
3
The MusicPal board code connects both of the IRQ outputs of the UART
3
This is a Cortex-M3 based machine. Information can be found at:
4
to the same INTC qemu_irq. Connecting two qemu_irqs outputs directly
4
https://www.st.com/en/evaluation-tools/stm32vldiscovery.html
5
to the same input is not valid as it produces subtly wrong behaviour
6
(for instance if both the IRQ lines are high, and then one goes
7
low, the INTC input will see this as a high-to-low transition
8
even though the second IRQ line should still be holding it high).
9
5
10
This kind of wiring needs an explicitly created OR gate; add one.
6
Signed-off-by: Alexandre Iooss <erdnaxe@crans.org>
11
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
12
Inspired-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20210617165647.2575955-3-erdnaxe@crans.org
13
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
14
Message-id: 20201107193403.436146-5-f4bug@amsat.org
15
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
10
---
18
hw/arm/musicpal.c | 17 +++++++++++++----
11
default-configs/devices/arm-softmmu.mak | 1 +
19
hw/arm/Kconfig | 1 +
12
hw/arm/stm32vldiscovery.c | 66 +++++++++++++++++++++++++
20
2 files changed, 14 insertions(+), 4 deletions(-)
13
MAINTAINERS | 6 +++
14
hw/arm/Kconfig | 4 ++
15
hw/arm/meson.build | 1 +
16
5 files changed, 78 insertions(+)
17
create mode 100644 hw/arm/stm32vldiscovery.c
21
18
22
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
19
diff --git a/default-configs/devices/arm-softmmu.mak b/default-configs/devices/arm-softmmu.mak
23
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
24
--- a/hw/arm/musicpal.c
21
--- a/default-configs/devices/arm-softmmu.mak
25
+++ b/hw/arm/musicpal.c
22
+++ b/default-configs/devices/arm-softmmu.mak
23
@@ -XXX,XX +XXX,XX @@ CONFIG_CHEETAH=y
24
CONFIG_SX1=y
25
CONFIG_NSERIES=y
26
CONFIG_STELLARIS=y
27
+CONFIG_STM32VLDISCOVERY=y
28
CONFIG_REALVIEW=y
29
CONFIG_VERSATILE=y
30
CONFIG_VEXPRESS=y
31
diff --git a/hw/arm/stm32vldiscovery.c b/hw/arm/stm32vldiscovery.c
32
new file mode 100644
33
index XXXXXXX..XXXXXXX
34
--- /dev/null
35
+++ b/hw/arm/stm32vldiscovery.c
26
@@ -XXX,XX +XXX,XX @@
36
@@ -XXX,XX +XXX,XX @@
27
#include "ui/console.h"
37
+/*
28
#include "hw/i2c/i2c.h"
38
+ * ST STM32VLDISCOVERY machine
29
#include "hw/irq.h"
39
+ *
30
+#include "hw/or-irq.h"
40
+ * Copyright (c) 2021 Alexandre Iooss <erdnaxe@crans.org>
31
#include "hw/audio/wm8750.h"
41
+ * Copyright (c) 2014 Alistair Francis <alistair@alistair23.me>
32
#include "sysemu/block-backend.h"
42
+ *
33
#include "sysemu/runstate.h"
43
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
34
@@ -XXX,XX +XXX,XX @@
44
+ * of this software and associated documentation files (the "Software"), to deal
35
#define MP_TIMER4_IRQ 7
45
+ * in the Software without restriction, including without limitation the rights
36
#define MP_EHCI_IRQ 8
46
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
37
#define MP_ETH_IRQ 9
47
+ * copies of the Software, and to permit persons to whom the Software is
38
-#define MP_UART1_IRQ 11
48
+ * furnished to do so, subject to the following conditions:
39
-#define MP_UART2_IRQ 11
49
+ *
40
+#define MP_UART_SHARED_IRQ 11
50
+ * The above copyright notice and this permission notice shall be included in
41
#define MP_GPIO_IRQ 12
51
+ * all copies or substantial portions of the Software.
42
#define MP_RTC_IRQ 28
52
+ *
43
#define MP_AUDIO_IRQ 30
53
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44
@@ -XXX,XX +XXX,XX @@ static void musicpal_init(MachineState *machine)
54
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45
ARMCPU *cpu;
55
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
46
qemu_irq pic[32];
56
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
47
DeviceState *dev;
57
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
48
+ DeviceState *uart_orgate;
58
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
49
DeviceState *i2c_dev;
59
+ * THE SOFTWARE.
50
DeviceState *lcd_dev;
60
+ */
51
DeviceState *key_dev;
52
@@ -XXX,XX +XXX,XX @@ static void musicpal_init(MachineState *machine)
53
pic[MP_TIMER2_IRQ], pic[MP_TIMER3_IRQ],
54
pic[MP_TIMER4_IRQ], NULL);
55
56
- serial_mm_init(address_space_mem, MP_UART1_BASE, 2, pic[MP_UART1_IRQ],
57
+ /* Logically OR both UART IRQs together */
58
+ uart_orgate = DEVICE(object_new(TYPE_OR_IRQ));
59
+ object_property_set_int(OBJECT(uart_orgate), "num-lines", 2, &error_fatal);
60
+ qdev_realize_and_unref(uart_orgate, NULL, &error_fatal);
61
+ qdev_connect_gpio_out(DEVICE(uart_orgate), 0, pic[MP_UART_SHARED_IRQ]);
62
+
61
+
63
+ serial_mm_init(address_space_mem, MP_UART1_BASE, 2,
62
+#include "qemu/osdep.h"
64
+ qdev_get_gpio_in(uart_orgate, 0),
63
+#include "qapi/error.h"
65
1825000, serial_hd(0), DEVICE_NATIVE_ENDIAN);
64
+#include "hw/boards.h"
66
- serial_mm_init(address_space_mem, MP_UART2_BASE, 2, pic[MP_UART2_IRQ],
65
+#include "hw/qdev-properties.h"
67
+ serial_mm_init(address_space_mem, MP_UART2_BASE, 2,
66
+#include "qemu/error-report.h"
68
+ qdev_get_gpio_in(uart_orgate, 1),
67
+#include "hw/arm/stm32f100_soc.h"
69
1825000, serial_hd(1), DEVICE_NATIVE_ENDIAN);
68
+#include "hw/arm/boot.h"
70
69
+
71
/* Register flash */
70
+/* stm32vldiscovery implementation is derived from netduinoplus2 */
71
+
72
+/* Main SYSCLK frequency in Hz (24MHz) */
73
+#define SYSCLK_FRQ 24000000ULL
74
+
75
+static void stm32vldiscovery_init(MachineState *machine)
76
+{
77
+ DeviceState *dev;
78
+
79
+ /*
80
+ * TODO: ideally we would model the SoC RCC and let it handle
81
+ * system_clock_scale, including its ability to define different
82
+ * possible SYSCLK sources.
83
+ */
84
+ system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ;
85
+
86
+ dev = qdev_new(TYPE_STM32F100_SOC);
87
+ qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m3"));
88
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
89
+
90
+ armv7m_load_kernel(ARM_CPU(first_cpu),
91
+ machine->kernel_filename,
92
+ FLASH_SIZE);
93
+}
94
+
95
+static void stm32vldiscovery_machine_init(MachineClass *mc)
96
+{
97
+ mc->desc = "ST STM32VLDISCOVERY (Cortex-M3)";
98
+ mc->init = stm32vldiscovery_init;
99
+}
100
+
101
+DEFINE_MACHINE("stm32vldiscovery", stm32vldiscovery_machine_init)
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/*/stellaris*
108
F: include/hw/input/gamepad.h
109
F: docs/system/arm/stellaris.rst
110
111
+STM32VLDISCOVERY
112
+M: Alexandre Iooss <erdnaxe@crans.org>
113
+L: qemu-arm@nongnu.org
114
+S: Maintained
115
+F: hw/arm/stm32vldiscovery.c
116
+
117
Versatile Express
118
M: Peter Maydell <peter.maydell@linaro.org>
119
L: qemu-arm@nongnu.org
72
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
120
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
73
index XXXXXXX..XXXXXXX 100644
121
index XXXXXXX..XXXXXXX 100644
74
--- a/hw/arm/Kconfig
122
--- a/hw/arm/Kconfig
75
+++ b/hw/arm/Kconfig
123
+++ b/hw/arm/Kconfig
76
@@ -XXX,XX +XXX,XX @@ config MUSCA
124
@@ -XXX,XX +XXX,XX @@ config STELLARIS
77
125
select STELLARIS_ENET # ethernet
78
config MUSICPAL
126
select UNIMP
127
128
+config STM32VLDISCOVERY
129
+ bool
130
+ select STM32F100_SOC
131
+
132
config STRONGARM
79
bool
133
bool
80
+ select OR_IRQ
134
select PXA2XX
81
select BITBANG_I2C
135
diff --git a/hw/arm/meson.build b/hw/arm/meson.build
82
select MARVELL_88W8618
136
index XXXXXXX..XXXXXXX 100644
83
select PTIMER
137
--- a/hw/arm/meson.build
138
+++ b/hw/arm/meson.build
139
@@ -XXX,XX +XXX,XX @@ arm_ss.add(when: 'CONFIG_Z2', if_true: files('z2.c'))
140
arm_ss.add(when: 'CONFIG_REALVIEW', if_true: files('realview.c'))
141
arm_ss.add(when: 'CONFIG_SBSA_REF', if_true: files('sbsa-ref.c'))
142
arm_ss.add(when: 'CONFIG_STELLARIS', if_true: files('stellaris.c'))
143
+arm_ss.add(when: 'CONFIG_STM32VLDISCOVERY', if_true: files('stm32vldiscovery.c'))
144
arm_ss.add(when: 'CONFIG_COLLIE', if_true: files('collie.c'))
145
arm_ss.add(when: 'CONFIG_VERSATILE', if_true: files('versatilepb.c'))
146
arm_ss.add(when: 'CONFIG_VEXPRESS', if_true: files('vexpress.c'))
84
--
147
--
85
2.20.1
148
2.20.1
86
149
87
150
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Alexandre Iooss <erdnaxe@crans.org>
2
2
3
We should at least document what this machine is about.
3
This adds the target guide for Netduino 2, Netduino Plus 2 and STM32VLDISCOVERY.
4
4
5
Reviewed-by: Graeme Gregory <graeme@nuviainc.com>
5
Signed-off-by: Alexandre Iooss <erdnaxe@crans.org>
6
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Message-id: 20201104165254.24822-1-alex.bennee@linaro.org
7
Message-id: 20210617165647.2575955-4-erdnaxe@crans.org
8
Cc: Leif Lindholm <leif@nuviainc.com>
9
Cc: Shashi Mallela <shashi.mallela@linaro.org>
10
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
11
[PMM: fixed filename mismatch]
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
9
---
14
docs/system/arm/sbsa.rst | 32 ++++++++++++++++++++++++++++++++
10
docs/system/arm/stm32.rst | 66 ++++++++++++++++++++++++++++++++++++++
15
docs/system/target-arm.rst | 1 +
11
docs/system/target-arm.rst | 1 +
16
2 files changed, 33 insertions(+)
12
MAINTAINERS | 1 +
17
create mode 100644 docs/system/arm/sbsa.rst
13
3 files changed, 68 insertions(+)
14
create mode 100644 docs/system/arm/stm32.rst
18
15
19
diff --git a/docs/system/arm/sbsa.rst b/docs/system/arm/sbsa.rst
16
diff --git a/docs/system/arm/stm32.rst b/docs/system/arm/stm32.rst
20
new file mode 100644
17
new file mode 100644
21
index XXXXXXX..XXXXXXX
18
index XXXXXXX..XXXXXXX
22
--- /dev/null
19
--- /dev/null
23
+++ b/docs/system/arm/sbsa.rst
20
+++ b/docs/system/arm/stm32.rst
24
@@ -XXX,XX +XXX,XX @@
21
@@ -XXX,XX +XXX,XX @@
25
+Arm Server Base System Architecture Reference board (``sbsa-ref``)
22
+STMicroelectronics STM32 boards (``netduino2``, ``netduinoplus2``, ``stm32vldiscovery``)
26
+==================================================================
23
+========================================================================================
27
+
24
+
28
+While the `virt` board is a generic board platform that doesn't match
25
+The `STM32`_ chips are a family of 32-bit ARM-based microcontroller by
29
+any real hardware the `sbsa-ref` board intends to look like real
26
+STMicroelectronics.
30
+hardware. The `Server Base System Architecture
31
+<https://developer.arm.com/documentation/den0029/latest>` defines a
32
+minimum base line of hardware support and importantly how the firmware
33
+reports that to any operating system. It is a static system that
34
+reports a very minimal DT to the firmware for non-discoverable
35
+information about components affected by the qemu command line (i.e.
36
+cpus and memory). As a result it must have a firmware specifically
37
+built to expect a certain hardware layout (as you would in a real
38
+machine).
39
+
27
+
40
+It is intended to be a machine for developing firmware and testing
28
+.. _STM32: https://www.st.com/en/microcontrollers-microprocessors/stm32-32-bit-arm-cortex-mcus.html
41
+standards compliance with operating systems.
29
+
30
+The STM32F1 series is based on ARM Cortex-M3 core. The following machines are
31
+based on this chip :
32
+
33
+- ``stm32vldiscovery`` STM32VLDISCOVERY board with STM32F100RBT6 microcontroller
34
+
35
+The STM32F2 series is based on ARM Cortex-M3 core. The following machines are
36
+based on this chip :
37
+
38
+- ``netduino2`` Netduino 2 board with STM32F205RFT6 microcontroller
39
+
40
+The STM32F4 series is based on ARM Cortex-M4F core. This series is pin-to-pin
41
+compatible with STM32F2 series. The following machines are based on this chip :
42
+
43
+- ``netduinoplus2`` Netduino Plus 2 board with STM32F405RGT6 microcontroller
44
+
45
+There are many other STM32 series that are currently not supported by QEMU.
42
+
46
+
43
+Supported devices
47
+Supported devices
44
+"""""""""""""""""
48
+-----------------
45
+
49
+
46
+The sbsa-ref board supports:
50
+ * ARM Cortex-M3, Cortex M4F
51
+ * Analog to Digital Converter (ADC)
52
+ * EXTI interrupt
53
+ * Serial ports (USART)
54
+ * SPI controller
55
+ * System configuration (SYSCFG)
56
+ * Timer controller (TIMER)
47
+
57
+
48
+ - A configurable number of AArch64 CPUs
58
+Missing devices
49
+ - GIC version 3
59
+---------------
50
+ - System bus AHCI controller
51
+ - System bus EHCI controller
52
+ - CDROM and hard disc on AHCI bus
53
+ - E1000E ethernet card on PCIe bus
54
+ - VGA display adaptor on PCIe bus
55
+ - A generic SBSA watchdog device
56
+
60
+
61
+ * Camera interface (DCMI)
62
+ * Controller Area Network (CAN)
63
+ * Cycle Redundancy Check (CRC) calculation unit
64
+ * Digital to Analog Converter (DAC)
65
+ * DMA controller
66
+ * Ethernet controller
67
+ * Flash Interface Unit
68
+ * GPIO controller
69
+ * I2C controller
70
+ * Inter-Integrated Sound (I2S) controller
71
+ * Power supply configuration (PWR)
72
+ * Random Number Generator (RNG)
73
+ * Real-Time Clock (RTC) controller
74
+ * Reset and Clock Controller (RCC)
75
+ * Secure Digital Input/Output (SDIO) interface
76
+ * USB OTG
77
+ * Watchdog controller (IWDG, WWDG)
78
+
79
+Boot options
80
+------------
81
+
82
+The STM32 machines can be started using the ``-kernel`` option to load a
83
+firmware. Example:
84
+
85
+.. code-block:: bash
86
+
87
+ $ qemu-system-arm -M stm32vldiscovery -kernel firmware.bin
57
diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst
88
diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst
58
index XXXXXXX..XXXXXXX 100644
89
index XXXXXXX..XXXXXXX 100644
59
--- a/docs/system/target-arm.rst
90
--- a/docs/system/target-arm.rst
60
+++ b/docs/system/target-arm.rst
91
+++ b/docs/system/target-arm.rst
61
@@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running
92
@@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running
62
arm/mps2
93
arm/collie
63
arm/musca
94
arm/sx1
64
arm/realview
95
arm/stellaris
65
+ arm/sbsa
96
+ arm/stm32
66
arm/versatile
97
arm/virt
67
arm/vexpress
98
arm/xlnx-versal-virt
68
arm/aspeed
99
100
diff --git a/MAINTAINERS b/MAINTAINERS
101
index XXXXXXX..XXXXXXX 100644
102
--- a/MAINTAINERS
103
+++ b/MAINTAINERS
104
@@ -XXX,XX +XXX,XX @@ M: Alexandre Iooss <erdnaxe@crans.org>
105
L: qemu-arm@nongnu.org
106
S: Maintained
107
F: hw/arm/stm32vldiscovery.c
108
+F: docs/system/arm/stm32.rst
109
110
Versatile Express
111
M: Peter Maydell <peter.maydell@linaro.org>
69
--
112
--
70
2.20.1
113
2.20.1
71
114
72
115
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Alexandre Iooss <erdnaxe@crans.org>
2
2
3
We can use one MPC per SRAM bank, but we currently only wire the
3
New mini-kernel test for STM32VLDISCOVERY USART1.
4
IRQ from the first expansion MPC to the IRQ splitter. Fix that.
5
4
6
Fixes: bb75e16d5e6 ("hw/arm/iotkit: Wire up MPC interrupt lines")
5
Signed-off-by: Alexandre Iooss <erdnaxe@crans.org>
7
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Acked-by: Thomas Huth <thuth@redhat.com>
8
Message-id: 20201107193403.436146-2-f4bug@amsat.org
7
Acked-by: Alistair Francis <alistair.francis@wdc.com>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20210617165647.2575955-5-erdnaxe@crans.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
10
---
12
hw/arm/armsse.c | 3 ++-
11
tests/qtest/boot-serial-test.c | 37 ++++++++++++++++++++++++++++++++++
13
1 file changed, 2 insertions(+), 1 deletion(-)
12
1 file changed, 37 insertions(+)
14
13
15
diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c
14
diff --git a/tests/qtest/boot-serial-test.c b/tests/qtest/boot-serial-test.c
16
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/armsse.c
16
--- a/tests/qtest/boot-serial-test.c
18
+++ b/hw/arm/armsse.c
17
+++ b/tests/qtest/boot-serial-test.c
19
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
18
@@ -XXX,XX +XXX,XX @@ static const uint8_t kernel_nrf51[] = {
20
qdev_get_gpio_in(dev_splitter, 0));
19
0x1c, 0x25, 0x00, 0x40 /* 0x4000251c = UART TXD */
21
qdev_connect_gpio_out(dev_splitter, 0,
20
};
22
qdev_get_gpio_in_named(dev_secctl,
21
23
- "mpc_status", 0));
22
+static const uint8_t kernel_stm32vldiscovery[] = {
24
+ "mpc_status",
23
+ 0x00, 0x00, 0x00, 0x00, /* Stack top address */
25
+ i - IOTS_NUM_EXP_MPC));
24
+ 0x1d, 0x00, 0x00, 0x00, /* Reset handler address */
26
}
25
+ 0x00, 0x00, 0x00, 0x00, /* NMI */
27
26
+ 0x00, 0x00, 0x00, 0x00, /* Hard fault */
28
qdev_connect_gpio_out(dev_splitter, 1,
27
+ 0x00, 0x00, 0x00, 0x00, /* Memory management fault */
28
+ 0x00, 0x00, 0x00, 0x00, /* Bus fault */
29
+ 0x00, 0x00, 0x00, 0x00, /* Usage fault */
30
+ 0x0b, 0x4b, /* ldr r3, [pc, #44] Get RCC */
31
+ 0x44, 0xf2, 0x04, 0x02, /* movw r2, #16388 */
32
+ 0x1a, 0x60, /* str r2, [r3] */
33
+ 0x0a, 0x4b, /* ldr r3, [pc, #40] Get GPIOA */
34
+ 0x1a, 0x68, /* ldr r2, [r3] */
35
+ 0x22, 0xf0, 0xf0, 0x02, /* bic r2, r2, #240 */
36
+ 0x1a, 0x60, /* str r2, [r3] */
37
+ 0x1a, 0x68, /* ldr r2, [r3] */
38
+ 0x42, 0xf0, 0xb0, 0x02, /* orr r2, r2, #176 */
39
+ 0x1a, 0x60, /* str r2, [r3] */
40
+ 0x07, 0x4b, /* ldr r3, [pc, #26] Get BAUD */
41
+ 0x45, 0x22, /* movs r2, #69 */
42
+ 0x1a, 0x60, /* str r2, [r3] */
43
+ 0x06, 0x4b, /* ldr r3, [pc, #24] Get ENABLE */
44
+ 0x42, 0xf2, 0x08, 0x02, /* movw r2, #8200 */
45
+ 0x1a, 0x60, /* str r2, [r3] */
46
+ 0x05, 0x4b, /* ldr r3, [pc, #20] Get TXD */
47
+ 0x54, 0x22, /* movs r2, 'T' */
48
+ 0x1a, 0x60, /* str r2, [r3] */
49
+ 0xfe, 0xe7, /* b . */
50
+ 0x18, 0x10, 0x02, 0x40, /* 0x40021018 = RCC */
51
+ 0x04, 0x08, 0x01, 0x40, /* 0x40010804 = GPIOA */
52
+ 0x08, 0x38, 0x01, 0x40, /* 0x40013808 = USART1 BAUD */
53
+ 0x0c, 0x38, 0x01, 0x40, /* 0x4001380c = USART1 ENABLE */
54
+ 0x04, 0x38, 0x01, 0x40 /* 0x40013804 = USART1 TXD */
55
+};
56
+
57
typedef struct testdef {
58
const char *arch; /* Target architecture */
59
const char *machine; /* Name of the machine */
60
@@ -XXX,XX +XXX,XX @@ static testdef_t tests[] = {
61
{ "aarch64", "virt", "-cpu max", "TT", sizeof(kernel_aarch64),
62
kernel_aarch64 },
63
{ "arm", "microbit", "", "T", sizeof(kernel_nrf51), kernel_nrf51 },
64
+ { "arm", "stm32vldiscovery", "", "T",
65
+ sizeof(kernel_stm32vldiscovery), kernel_stm32vldiscovery },
66
67
{ NULL }
68
};
29
--
69
--
30
2.20.1
70
2.20.1
31
71
32
72
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Ricardo Koller <ricarkol@google.com>
2
2
3
We don't need to fill the full pic[] array if we only use
3
icv_eoir_write() and icv_dir_write() ignore invalid virtual IRQ numbers
4
few of the interrupt lines. Directly call qdev_get_gpio_in()
4
(like LPIs). The issue is that these functions check against the number
5
when necessary.
5
of implemented IRQs (QEMU's default is num_irq=288) which can be lower
6
than the maximum virtual IRQ number (1020 - 1). The consequence is that
7
if a hypervisor creates an LR for an IRQ between 288 and 1020, then the
8
guest is unable to deactivate the resulting IRQ. Note that other
9
functions that deal with large IRQ numbers, like icv_iar_read, check
10
against 1020 and not against num_irq.
6
11
7
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
12
Fix the checks by using GICV3_MAXIRQ (1020) instead of the number of
8
Message-id: 20201107193403.436146-6-f4bug@amsat.org
13
implemented IRQs.
14
15
Signed-off-by: Ricardo Koller <ricarkol@google.com>
16
Message-id: 20210702233701.3369-1-ricarkol@google.com
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
17
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
19
---
12
hw/arm/musicpal.c | 25 +++++++++++++------------
20
hw/intc/arm_gicv3_cpuif.c | 4 ++--
13
1 file changed, 13 insertions(+), 12 deletions(-)
21
1 file changed, 2 insertions(+), 2 deletions(-)
14
22
15
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
23
diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c
16
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/musicpal.c
25
--- a/hw/intc/arm_gicv3_cpuif.c
18
+++ b/hw/arm/musicpal.c
26
+++ b/hw/intc/arm_gicv3_cpuif.c
19
@@ -XXX,XX +XXX,XX @@ static struct arm_boot_info musicpal_binfo = {
27
@@ -XXX,XX +XXX,XX @@ static void icv_dir_write(CPUARMState *env, const ARMCPRegInfo *ri,
20
static void musicpal_init(MachineState *machine)
28
21
{
29
trace_gicv3_icv_dir_write(gicv3_redist_affid(cs), value);
22
ARMCPU *cpu;
30
23
- qemu_irq pic[32];
31
- if (irq >= cs->gic->num_irq) {
24
DeviceState *dev;
32
+ if (irq >= GICV3_MAXIRQ) {
25
+ DeviceState *pic;
33
/* Also catches special interrupt numbers and LPIs */
26
DeviceState *uart_orgate;
34
return;
27
DeviceState *i2c_dev;
35
}
28
DeviceState *lcd_dev;
36
@@ -XXX,XX +XXX,XX @@ static void icv_eoir_write(CPUARMState *env, const ARMCPRegInfo *ri,
29
@@ -XXX,XX +XXX,XX @@ static void musicpal_init(MachineState *machine)
37
trace_gicv3_icv_eoir_write(ri->crm == 8 ? 0 : 1,
30
&error_fatal);
38
gicv3_redist_affid(cs), value);
31
memory_region_add_subregion(address_space_mem, MP_SRAM_BASE, sram);
39
32
40
- if (irq >= cs->gic->num_irq) {
33
- dev = sysbus_create_simple(TYPE_MV88W8618_PIC, MP_PIC_BASE,
41
+ if (irq >= GICV3_MAXIRQ) {
34
+ pic = sysbus_create_simple(TYPE_MV88W8618_PIC, MP_PIC_BASE,
42
/* Also catches special interrupt numbers and LPIs */
35
qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ));
43
return;
36
- for (i = 0; i < 32; i++) {
44
}
37
- pic[i] = qdev_get_gpio_in(dev, i);
38
- }
39
- sysbus_create_varargs(TYPE_MV88W8618_PIT, MP_PIT_BASE, pic[MP_TIMER1_IRQ],
40
- pic[MP_TIMER2_IRQ], pic[MP_TIMER3_IRQ],
41
- pic[MP_TIMER4_IRQ], NULL);
42
+ sysbus_create_varargs(TYPE_MV88W8618_PIT, MP_PIT_BASE,
43
+ qdev_get_gpio_in(pic, MP_TIMER1_IRQ),
44
+ qdev_get_gpio_in(pic, MP_TIMER2_IRQ),
45
+ qdev_get_gpio_in(pic, MP_TIMER3_IRQ),
46
+ qdev_get_gpio_in(pic, MP_TIMER4_IRQ), NULL);
47
48
/* Logically OR both UART IRQs together */
49
uart_orgate = DEVICE(object_new(TYPE_OR_IRQ));
50
object_property_set_int(OBJECT(uart_orgate), "num-lines", 2, &error_fatal);
51
qdev_realize_and_unref(uart_orgate, NULL, &error_fatal);
52
- qdev_connect_gpio_out(DEVICE(uart_orgate), 0, pic[MP_UART_SHARED_IRQ]);
53
+ qdev_connect_gpio_out(DEVICE(uart_orgate), 0,
54
+ qdev_get_gpio_in(pic, MP_UART_SHARED_IRQ));
55
56
serial_mm_init(address_space_mem, MP_UART1_BASE, 2,
57
qdev_get_gpio_in(uart_orgate, 0),
58
@@ -XXX,XX +XXX,XX @@ static void musicpal_init(MachineState *machine)
59
OBJECT(get_system_memory()), &error_fatal);
60
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
61
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, MP_ETH_BASE);
62
- sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[MP_ETH_IRQ]);
63
+ sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0,
64
+ qdev_get_gpio_in(pic, MP_ETH_IRQ));
65
66
sysbus_create_simple("mv88w8618_wlan", MP_WLAN_BASE, NULL);
67
68
sysbus_create_simple(TYPE_MUSICPAL_MISC, MP_MISC_BASE, NULL);
69
70
dev = sysbus_create_simple(TYPE_MUSICPAL_GPIO, MP_GPIO_BASE,
71
- pic[MP_GPIO_IRQ]);
72
+ qdev_get_gpio_in(pic, MP_GPIO_IRQ));
73
i2c_dev = sysbus_create_simple("gpio_i2c", -1, NULL);
74
i2c = (I2CBus *)qdev_get_child_bus(i2c_dev, "i2c");
75
76
@@ -XXX,XX +XXX,XX @@ static void musicpal_init(MachineState *machine)
77
NULL);
78
sysbus_realize_and_unref(s, &error_fatal);
79
sysbus_mmio_map(s, 0, MP_AUDIO_BASE);
80
- sysbus_connect_irq(s, 0, pic[MP_AUDIO_IRQ]);
81
+ sysbus_connect_irq(s, 0, qdev_get_gpio_in(pic, MP_AUDIO_IRQ));
82
83
musicpal_binfo.ram_size = MP_RAM_DEFAULT_SIZE;
84
arm_load_kernel(cpu, machine, &musicpal_binfo);
85
--
45
--
86
2.20.1
46
2.20.1
87
47
88
48
diff view generated by jsdifflib
New patch
1
Convert the use of the DPRINTF debug macro in the PL061 model to
2
use tracepoints.
1
3
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
---
8
hw/gpio/pl061.c | 27 +++++++++------------------
9
hw/gpio/trace-events | 6 ++++++
10
2 files changed, 15 insertions(+), 18 deletions(-)
11
12
diff --git a/hw/gpio/pl061.c b/hw/gpio/pl061.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/gpio/pl061.c
15
+++ b/hw/gpio/pl061.c
16
@@ -XXX,XX +XXX,XX @@
17
#include "qemu/log.h"
18
#include "qemu/module.h"
19
#include "qom/object.h"
20
-
21
-//#define DEBUG_PL061 1
22
-
23
-#ifdef DEBUG_PL061
24
-#define DPRINTF(fmt, ...) \
25
-do { printf("pl061: " fmt , ## __VA_ARGS__); } while (0)
26
-#define BADF(fmt, ...) \
27
-do { fprintf(stderr, "pl061: error: " fmt , ## __VA_ARGS__); exit(1);} while (0)
28
-#else
29
-#define DPRINTF(fmt, ...) do {} while(0)
30
-#define BADF(fmt, ...) \
31
-do { fprintf(stderr, "pl061: error: " fmt , ## __VA_ARGS__);} while (0)
32
-#endif
33
+#include "trace.h"
34
35
static const uint8_t pl061_id[12] =
36
{ 0x00, 0x00, 0x00, 0x00, 0x61, 0x10, 0x04, 0x00, 0x0d, 0xf0, 0x05, 0xb1 };
37
@@ -XXX,XX +XXX,XX @@ static void pl061_update(PL061State *s)
38
uint8_t out;
39
int i;
40
41
- DPRINTF("dir = %d, data = %d\n", s->dir, s->data);
42
+ trace_pl061_update(DEVICE(s)->canonical_path, s->dir, s->data);
43
44
/* Outputs float high. */
45
/* FIXME: This is board dependent. */
46
@@ -XXX,XX +XXX,XX @@ static void pl061_update(PL061State *s)
47
for (i = 0; i < N_GPIOS; i++) {
48
mask = 1 << i;
49
if (changed & mask) {
50
- DPRINTF("Set output %d = %d\n", i, (out & mask) != 0);
51
- qemu_set_irq(s->out[i], (out & mask) != 0);
52
+ int level = (out & mask) != 0;
53
+ trace_pl061_set_output(DEVICE(s)->canonical_path, i, level);
54
+ qemu_set_irq(s->out[i], level);
55
}
56
}
57
}
58
@@ -XXX,XX +XXX,XX @@ static void pl061_update(PL061State *s)
59
for (i = 0; i < N_GPIOS; i++) {
60
mask = 1 << i;
61
if (changed & mask) {
62
- DPRINTF("Changed input %d = %d\n", i, (s->data & mask) != 0);
63
+ trace_pl061_input_change(DEVICE(s)->canonical_path, i,
64
+ (s->data & mask) != 0);
65
66
if (!(s->isense & mask)) {
67
/* Edge interrupt */
68
@@ -XXX,XX +XXX,XX @@ static void pl061_update(PL061State *s)
69
/* Level interrupt */
70
s->istate |= ~(s->data ^ s->iev) & s->isense;
71
72
- DPRINTF("istate = %02X\n", s->istate);
73
+ trace_pl061_update_istate(DEVICE(s)->canonical_path,
74
+ s->istate, s->im, (s->istate & s->im) != 0);
75
76
qemu_set_irq(s->irq, (s->istate & s->im) != 0);
77
}
78
diff --git a/hw/gpio/trace-events b/hw/gpio/trace-events
79
index XXXXXXX..XXXXXXX 100644
80
--- a/hw/gpio/trace-events
81
+++ b/hw/gpio/trace-events
82
@@ -XXX,XX +XXX,XX @@ nrf51_gpio_write(uint64_t offset, uint64_t value) "offset 0x%" PRIx64 " value 0x
83
nrf51_gpio_set(int64_t line, int64_t value) "line %" PRIi64 " value %" PRIi64
84
nrf51_gpio_update_output_irq(int64_t line, int64_t value) "line %" PRIi64 " value %" PRIi64
85
86
+# pl061.c
87
+pl061_update(const char *id, uint32_t dir, uint32_t data) "%s GPIODIR 0x%x GPIODATA 0x%x"
88
+pl061_set_output(const char *id, int gpio, int level) "%s setting output %d to %d"
89
+pl061_input_change(const char *id, int gpio, int level) "%s input %d changed to %d"
90
+pl061_update_istate(const char *id, uint32_t istate, uint32_t im, int level) "%s GPIORIS 0x%x GPIOIE 0x%x interrupt level %d"
91
+
92
# sifive_gpio.c
93
sifive_gpio_read(uint64_t offset, uint64_t r) "offset 0x%" PRIx64 " value 0x%" PRIx64
94
sifive_gpio_write(uint64_t offset, uint64_t value) "offset 0x%" PRIx64 " value 0x%" PRIx64
95
--
96
2.20.1
97
98
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
Currently the pl061_read() and pl061_write() functions handle offsets
2
2
using a combination of three if() statements and a switch(). Clean
3
The helper function did not get updated when we reorganized
3
this up to use just a switch, using case ranges.
4
the vector register file for SVE. Since then, the neon dregs
4
5
are non-sequential and cannot be simply indexed.
5
This requires that instead of catching accesses to the luminary-only
6
6
registers on a stock PL061 via a check on s->rsvd_start we use
7
At the same time, make the helper function operate on 64-bit
7
an "is this luminary?" check in the cases for each luminary-only
8
quantities so that we do not have to call it twice.
8
register.
9
9
10
Fixes: c39c2b9043e
11
Reported-by: Ard Biesheuvel <ardb@kernel.org>
12
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
13
[PMM: use aa32_vfp_dreg() rather than opencoding]
14
Message-id: 20201105171126.88014-1-richard.henderson@linaro.org
15
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
17
---
12
---
18
target/arm/helper.h | 2 +-
13
hw/gpio/pl061.c | 104 ++++++++++++++++++++++++++++++++++++------------
19
target/arm/op_helper.c | 23 +++++++++--------
14
1 file changed, 79 insertions(+), 25 deletions(-)
20
target/arm/translate-neon.c.inc | 44 +++++++++++----------------------
15
21
3 files changed, 29 insertions(+), 40 deletions(-)
16
diff --git a/hw/gpio/pl061.c b/hw/gpio/pl061.c
22
23
diff --git a/target/arm/helper.h b/target/arm/helper.h
24
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
25
--- a/target/arm/helper.h
18
--- a/hw/gpio/pl061.c
26
+++ b/target/arm/helper.h
19
+++ b/hw/gpio/pl061.c
27
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_2(rsqrte_f32, TCG_CALL_NO_RWG, f32, f32, ptr)
20
@@ -XXX,XX +XXX,XX @@ struct PL061State {
28
DEF_HELPER_FLAGS_2(rsqrte_f64, TCG_CALL_NO_RWG, f64, f64, ptr)
21
qemu_irq irq;
29
DEF_HELPER_FLAGS_1(recpe_u32, TCG_CALL_NO_RWG, i32, i32)
22
qemu_irq out[N_GPIOS];
30
DEF_HELPER_FLAGS_1(rsqrte_u32, TCG_CALL_NO_RWG, i32, i32)
23
const unsigned char *id;
31
-DEF_HELPER_FLAGS_4(neon_tbl, TCG_CALL_NO_RWG, i32, i32, i32, ptr, i32)
24
- uint32_t rsvd_start; /* reserved area: [rsvd_start, 0xfcc] */
32
+DEF_HELPER_FLAGS_4(neon_tbl, TCG_CALL_NO_RWG, i64, env, i32, i64, i64)
25
};
33
26
34
DEF_HELPER_3(shl_cc, i32, env, i32, i32)
27
static const VMStateDescription vmstate_pl061 = {
35
DEF_HELPER_3(shr_cc, i32, env, i32, i32)
28
@@ -XXX,XX +XXX,XX @@ static uint64_t pl061_read(void *opaque, hwaddr offset,
36
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
29
{
37
index XXXXXXX..XXXXXXX 100644
30
PL061State *s = (PL061State *)opaque;
38
--- a/target/arm/op_helper.c
31
39
+++ b/target/arm/op_helper.c
32
- if (offset < 0x400) {
40
@@ -XXX,XX +XXX,XX @@ void raise_exception_ra(CPUARMState *env, uint32_t excp, uint32_t syndrome,
33
- return s->data & (offset >> 2);
41
cpu_loop_exit_restore(cs, ra);
34
- }
35
- if (offset >= s->rsvd_start && offset <= 0xfcc) {
36
- goto err_out;
37
- }
38
- if (offset >= 0xfd0 && offset < 0x1000) {
39
- return s->id[(offset - 0xfd0) >> 2];
40
- }
41
switch (offset) {
42
+ case 0x0 ... 0x3ff: /* Data */
43
+ return s->data & (offset >> 2);
44
case 0x400: /* Direction */
45
return s->dir;
46
case 0x404: /* Interrupt sense */
47
@@ -XXX,XX +XXX,XX @@ static uint64_t pl061_read(void *opaque, hwaddr offset,
48
case 0x420: /* Alternate function select */
49
return s->afsel;
50
case 0x500: /* 2mA drive */
51
+ if (s->id != pl061_id_luminary) {
52
+ goto bad_offset;
53
+ }
54
return s->dr2r;
55
case 0x504: /* 4mA drive */
56
+ if (s->id != pl061_id_luminary) {
57
+ goto bad_offset;
58
+ }
59
return s->dr4r;
60
case 0x508: /* 8mA drive */
61
+ if (s->id != pl061_id_luminary) {
62
+ goto bad_offset;
63
+ }
64
return s->dr8r;
65
case 0x50c: /* Open drain */
66
+ if (s->id != pl061_id_luminary) {
67
+ goto bad_offset;
68
+ }
69
return s->odr;
70
case 0x510: /* Pull-up */
71
+ if (s->id != pl061_id_luminary) {
72
+ goto bad_offset;
73
+ }
74
return s->pur;
75
case 0x514: /* Pull-down */
76
+ if (s->id != pl061_id_luminary) {
77
+ goto bad_offset;
78
+ }
79
return s->pdr;
80
case 0x518: /* Slew rate control */
81
+ if (s->id != pl061_id_luminary) {
82
+ goto bad_offset;
83
+ }
84
return s->slr;
85
case 0x51c: /* Digital enable */
86
+ if (s->id != pl061_id_luminary) {
87
+ goto bad_offset;
88
+ }
89
return s->den;
90
case 0x520: /* Lock */
91
+ if (s->id != pl061_id_luminary) {
92
+ goto bad_offset;
93
+ }
94
return s->locked;
95
case 0x524: /* Commit */
96
+ if (s->id != pl061_id_luminary) {
97
+ goto bad_offset;
98
+ }
99
return s->cr;
100
case 0x528: /* Analog mode select */
101
+ if (s->id != pl061_id_luminary) {
102
+ goto bad_offset;
103
+ }
104
return s->amsel;
105
+ case 0xfd0 ... 0xfff: /* ID registers */
106
+ return s->id[(offset - 0xfd0) >> 2];
107
default:
108
+ bad_offset:
109
+ qemu_log_mask(LOG_GUEST_ERROR,
110
+ "pl061_read: Bad offset %x\n", (int)offset);
111
break;
112
}
113
-err_out:
114
- qemu_log_mask(LOG_GUEST_ERROR,
115
- "pl061_read: Bad offset %x\n", (int)offset);
116
return 0;
42
}
117
}
43
118
44
-uint32_t HELPER(neon_tbl)(uint32_t ireg, uint32_t def, void *vn,
119
@@ -XXX,XX +XXX,XX @@ static void pl061_write(void *opaque, hwaddr offset,
45
- uint32_t maxindex)
120
PL061State *s = (PL061State *)opaque;
46
+uint64_t HELPER(neon_tbl)(CPUARMState *env, uint32_t desc,
121
uint8_t mask;
47
+ uint64_t ireg, uint64_t def)
122
48
{
123
- if (offset < 0x400) {
49
- uint32_t val, shift;
124
+ switch (offset) {
50
- uint64_t *table = vn;
125
+ case 0 ... 0x3ff:
51
+ uint64_t tmp, val = 0;
126
mask = (offset >> 2) & s->dir;
52
+ uint32_t maxindex = ((desc & 3) + 1) * 8;
127
s->data = (s->data & ~mask) | (value & mask);
53
+ uint32_t base_reg = desc >> 2;
128
pl061_update(s);
54
+ uint32_t shift, index, reg;
129
return;
55
130
- }
56
- val = 0;
131
- if (offset >= s->rsvd_start) {
57
- for (shift = 0; shift < 32; shift += 8) {
132
- goto err_out;
58
- uint32_t index = (ireg >> shift) & 0xff;
133
- }
59
+ for (shift = 0; shift < 64; shift += 8) {
134
- switch (offset) {
60
+ index = (ireg >> shift) & 0xff;
135
case 0x400: /* Direction */
61
if (index < maxindex) {
136
s->dir = value & 0xff;
62
- uint32_t tmp = (table[index >> 3] >> ((index & 7) << 3)) & 0xff;
137
break;
63
- val |= tmp << shift;
138
@@ -XXX,XX +XXX,XX @@ static void pl061_write(void *opaque, hwaddr offset,
64
+ reg = base_reg + (index >> 3);
139
s->afsel = (s->afsel & ~mask) | (value & mask);
65
+ tmp = *aa32_vfp_dreg(env, reg);
140
break;
66
+ tmp = ((tmp >> ((index & 7) << 3)) & 0xff) << shift;
141
case 0x500: /* 2mA drive */
67
} else {
142
+ if (s->id != pl061_id_luminary) {
68
- val |= def & (0xff << shift);
143
+ goto bad_offset;
69
+ tmp = def & (0xffull << shift);
144
+ }
70
}
145
s->dr2r = value & 0xff;
71
+ val |= tmp;
146
break;
147
case 0x504: /* 4mA drive */
148
+ if (s->id != pl061_id_luminary) {
149
+ goto bad_offset;
150
+ }
151
s->dr4r = value & 0xff;
152
break;
153
case 0x508: /* 8mA drive */
154
+ if (s->id != pl061_id_luminary) {
155
+ goto bad_offset;
156
+ }
157
s->dr8r = value & 0xff;
158
break;
159
case 0x50c: /* Open drain */
160
+ if (s->id != pl061_id_luminary) {
161
+ goto bad_offset;
162
+ }
163
s->odr = value & 0xff;
164
break;
165
case 0x510: /* Pull-up */
166
+ if (s->id != pl061_id_luminary) {
167
+ goto bad_offset;
168
+ }
169
s->pur = value & 0xff;
170
break;
171
case 0x514: /* Pull-down */
172
+ if (s->id != pl061_id_luminary) {
173
+ goto bad_offset;
174
+ }
175
s->pdr = value & 0xff;
176
break;
177
case 0x518: /* Slew rate control */
178
+ if (s->id != pl061_id_luminary) {
179
+ goto bad_offset;
180
+ }
181
s->slr = value & 0xff;
182
break;
183
case 0x51c: /* Digital enable */
184
+ if (s->id != pl061_id_luminary) {
185
+ goto bad_offset;
186
+ }
187
s->den = value & 0xff;
188
break;
189
case 0x520: /* Lock */
190
+ if (s->id != pl061_id_luminary) {
191
+ goto bad_offset;
192
+ }
193
s->locked = (value != 0xacce551);
194
break;
195
case 0x524: /* Commit */
196
+ if (s->id != pl061_id_luminary) {
197
+ goto bad_offset;
198
+ }
199
if (!s->locked)
200
s->cr = value & 0xff;
201
break;
202
case 0x528:
203
+ if (s->id != pl061_id_luminary) {
204
+ goto bad_offset;
205
+ }
206
s->amsel = value & 0xff;
207
break;
208
default:
209
- goto err_out;
210
+ bad_offset:
211
+ qemu_log_mask(LOG_GUEST_ERROR,
212
+ "pl061_write: Bad offset %x\n", (int)offset);
213
+ return;
72
}
214
}
73
return val;
215
pl061_update(s);
216
return;
217
-err_out:
218
- qemu_log_mask(LOG_GUEST_ERROR,
219
- "pl061_write: Bad offset %x\n", (int)offset);
74
}
220
}
75
diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc
221
76
index XXXXXXX..XXXXXXX 100644
222
static void pl061_reset(DeviceState *dev)
77
--- a/target/arm/translate-neon.c.inc
223
@@ -XXX,XX +XXX,XX @@ static void pl061_luminary_init(Object *obj)
78
+++ b/target/arm/translate-neon.c.inc
224
PL061State *s = PL061(obj);
79
@@ -XXX,XX +XXX,XX @@ static bool trans_VEXT(DisasContext *s, arg_VEXT *a)
225
80
226
s->id = pl061_id_luminary;
81
static bool trans_VTBL(DisasContext *s, arg_VTBL *a)
227
- s->rsvd_start = 0x52c;
82
{
83
- int n;
84
- TCGv_i32 tmp, tmp2, tmp3, tmp4;
85
- TCGv_ptr ptr1;
86
+ TCGv_i64 val, def;
87
+ TCGv_i32 desc;
88
89
if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
90
return false;
91
@@ -XXX,XX +XXX,XX @@ static bool trans_VTBL(DisasContext *s, arg_VTBL *a)
92
return true;
93
}
94
95
- n = a->len + 1;
96
- if ((a->vn + n) > 32) {
97
+ if ((a->vn + a->len + 1) > 32) {
98
/*
99
* This is UNPREDICTABLE; we choose to UNDEF to avoid the
100
* helper function running off the end of the register file.
101
*/
102
return false;
103
}
104
- n <<= 3;
105
- tmp = tcg_temp_new_i32();
106
- if (a->op) {
107
- read_neon_element32(tmp, a->vd, 0, MO_32);
108
- } else {
109
- tcg_gen_movi_i32(tmp, 0);
110
- }
111
- tmp2 = tcg_temp_new_i32();
112
- read_neon_element32(tmp2, a->vm, 0, MO_32);
113
- ptr1 = vfp_reg_ptr(true, a->vn);
114
- tmp4 = tcg_const_i32(n);
115
- gen_helper_neon_tbl(tmp2, tmp2, tmp, ptr1, tmp4);
116
117
+ desc = tcg_const_i32((a->vn << 2) | a->len);
118
+ def = tcg_temp_new_i64();
119
if (a->op) {
120
- read_neon_element32(tmp, a->vd, 1, MO_32);
121
+ read_neon_element64(def, a->vd, 0, MO_64);
122
} else {
123
- tcg_gen_movi_i32(tmp, 0);
124
+ tcg_gen_movi_i64(def, 0);
125
}
126
- tmp3 = tcg_temp_new_i32();
127
- read_neon_element32(tmp3, a->vm, 1, MO_32);
128
- gen_helper_neon_tbl(tmp3, tmp3, tmp, ptr1, tmp4);
129
- tcg_temp_free_i32(tmp);
130
- tcg_temp_free_i32(tmp4);
131
- tcg_temp_free_ptr(ptr1);
132
+ val = tcg_temp_new_i64();
133
+ read_neon_element64(val, a->vm, 0, MO_64);
134
135
- write_neon_element32(tmp2, a->vd, 0, MO_32);
136
- write_neon_element32(tmp3, a->vd, 1, MO_32);
137
- tcg_temp_free_i32(tmp2);
138
- tcg_temp_free_i32(tmp3);
139
+ gen_helper_neon_tbl(val, cpu_env, desc, val, def);
140
+ write_neon_element64(val, a->vd, 0, MO_64);
141
+
142
+ tcg_temp_free_i64(def);
143
+ tcg_temp_free_i64(val);
144
+ tcg_temp_free_i32(desc);
145
return true;
146
}
228
}
147
229
230
static void pl061_init(Object *obj)
231
@@ -XXX,XX +XXX,XX @@ static void pl061_init(Object *obj)
232
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
233
234
s->id = pl061_id;
235
- s->rsvd_start = 0x424;
236
237
memory_region_init_io(&s->iomem, obj, &pl061_ops, s, "pl061", 0x1000);
238
sysbus_init_mmio(sbd, &s->iomem);
148
--
239
--
149
2.20.1
240
2.20.1
150
241
151
242
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
Add tracepoints for reads and writes to the PL061 registers. This requires
2
restructuring pl061_read() to only return after the tracepoint, rather
3
than having lots of early-returns.
2
4
3
When using a Cortex-A15, the Virt machine does not use any
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
MPCore peripherals. Remove the dependency.
6
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
---
9
hw/gpio/pl061.c | 70 ++++++++++++++++++++++++++++++--------------
10
hw/gpio/trace-events | 2 ++
11
2 files changed, 50 insertions(+), 22 deletions(-)
5
12
6
Fixes: 7951c7b7c05 ("hw/arm: Express dependencies of the virt machine with Kconfig")
13
diff --git a/hw/gpio/pl061.c b/hw/gpio/pl061.c
7
Reported-by: Miroslav Rezanina <mrezanin@redhat.com>
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Message-id: 20201107114852.271922-1-philmd@redhat.com
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
hw/arm/Kconfig | 1 -
14
1 file changed, 1 deletion(-)
15
16
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
17
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/arm/Kconfig
15
--- a/hw/gpio/pl061.c
19
+++ b/hw/arm/Kconfig
16
+++ b/hw/gpio/pl061.c
20
@@ -XXX,XX +XXX,XX @@ config ARM_VIRT
17
@@ -XXX,XX +XXX,XX @@ static uint64_t pl061_read(void *opaque, hwaddr offset,
21
imply VFIO_PLATFORM
18
unsigned size)
22
imply VFIO_XGMAC
19
{
23
imply TPM_TIS_SYSBUS
20
PL061State *s = (PL061State *)opaque;
24
- select A15MPCORE
21
+ uint64_t r = 0;
25
select ACPI
22
26
select ARM_SMMUV3
23
switch (offset) {
27
select GPIO_KEY
24
case 0x0 ... 0x3ff: /* Data */
25
- return s->data & (offset >> 2);
26
+ r = s->data & (offset >> 2);
27
+ break;
28
case 0x400: /* Direction */
29
- return s->dir;
30
+ r = s->dir;
31
+ break;
32
case 0x404: /* Interrupt sense */
33
- return s->isense;
34
+ r = s->isense;
35
+ break;
36
case 0x408: /* Interrupt both edges */
37
- return s->ibe;
38
+ r = s->ibe;
39
+ break;
40
case 0x40c: /* Interrupt event */
41
- return s->iev;
42
+ r = s->iev;
43
+ break;
44
case 0x410: /* Interrupt mask */
45
- return s->im;
46
+ r = s->im;
47
+ break;
48
case 0x414: /* Raw interrupt status */
49
- return s->istate;
50
+ r = s->istate;
51
+ break;
52
case 0x418: /* Masked interrupt status */
53
- return s->istate & s->im;
54
+ r = s->istate & s->im;
55
+ break;
56
case 0x420: /* Alternate function select */
57
- return s->afsel;
58
+ r = s->afsel;
59
+ break;
60
case 0x500: /* 2mA drive */
61
if (s->id != pl061_id_luminary) {
62
goto bad_offset;
63
}
64
- return s->dr2r;
65
+ r = s->dr2r;
66
+ break;
67
case 0x504: /* 4mA drive */
68
if (s->id != pl061_id_luminary) {
69
goto bad_offset;
70
}
71
- return s->dr4r;
72
+ r = s->dr4r;
73
+ break;
74
case 0x508: /* 8mA drive */
75
if (s->id != pl061_id_luminary) {
76
goto bad_offset;
77
}
78
- return s->dr8r;
79
+ r = s->dr8r;
80
+ break;
81
case 0x50c: /* Open drain */
82
if (s->id != pl061_id_luminary) {
83
goto bad_offset;
84
}
85
- return s->odr;
86
+ r = s->odr;
87
+ break;
88
case 0x510: /* Pull-up */
89
if (s->id != pl061_id_luminary) {
90
goto bad_offset;
91
}
92
- return s->pur;
93
+ r = s->pur;
94
+ break;
95
case 0x514: /* Pull-down */
96
if (s->id != pl061_id_luminary) {
97
goto bad_offset;
98
}
99
- return s->pdr;
100
+ r = s->pdr;
101
+ break;
102
case 0x518: /* Slew rate control */
103
if (s->id != pl061_id_luminary) {
104
goto bad_offset;
105
}
106
- return s->slr;
107
+ r = s->slr;
108
+ break;
109
case 0x51c: /* Digital enable */
110
if (s->id != pl061_id_luminary) {
111
goto bad_offset;
112
}
113
- return s->den;
114
+ r = s->den;
115
+ break;
116
case 0x520: /* Lock */
117
if (s->id != pl061_id_luminary) {
118
goto bad_offset;
119
}
120
- return s->locked;
121
+ r = s->locked;
122
+ break;
123
case 0x524: /* Commit */
124
if (s->id != pl061_id_luminary) {
125
goto bad_offset;
126
}
127
- return s->cr;
128
+ r = s->cr;
129
+ break;
130
case 0x528: /* Analog mode select */
131
if (s->id != pl061_id_luminary) {
132
goto bad_offset;
133
}
134
- return s->amsel;
135
+ r = s->amsel;
136
+ break;
137
case 0xfd0 ... 0xfff: /* ID registers */
138
- return s->id[(offset - 0xfd0) >> 2];
139
+ r = s->id[(offset - 0xfd0) >> 2];
140
+ break;
141
default:
142
bad_offset:
143
qemu_log_mask(LOG_GUEST_ERROR,
144
"pl061_read: Bad offset %x\n", (int)offset);
145
break;
146
}
147
- return 0;
148
+
149
+ trace_pl061_read(DEVICE(s)->canonical_path, offset, r);
150
+ return r;
151
}
152
153
static void pl061_write(void *opaque, hwaddr offset,
154
@@ -XXX,XX +XXX,XX @@ static void pl061_write(void *opaque, hwaddr offset,
155
PL061State *s = (PL061State *)opaque;
156
uint8_t mask;
157
158
+ trace_pl061_write(DEVICE(s)->canonical_path, offset, value);
159
+
160
switch (offset) {
161
case 0 ... 0x3ff:
162
mask = (offset >> 2) & s->dir;
163
diff --git a/hw/gpio/trace-events b/hw/gpio/trace-events
164
index XXXXXXX..XXXXXXX 100644
165
--- a/hw/gpio/trace-events
166
+++ b/hw/gpio/trace-events
167
@@ -XXX,XX +XXX,XX @@ pl061_update(const char *id, uint32_t dir, uint32_t data) "%s GPIODIR 0x%x GPIOD
168
pl061_set_output(const char *id, int gpio, int level) "%s setting output %d to %d"
169
pl061_input_change(const char *id, int gpio, int level) "%s input %d changed to %d"
170
pl061_update_istate(const char *id, uint32_t istate, uint32_t im, int level) "%s GPIORIS 0x%x GPIOIE 0x%x interrupt level %d"
171
+pl061_read(const char *id, uint64_t offset, uint64_t r) "%s offset 0x%" PRIx64 " value 0x%" PRIx64
172
+pl061_write(const char *id, uint64_t offset, uint64_t value) "%s offset 0x%" PRIx64 " value 0x%" PRIx64
173
174
# sifive_gpio.c
175
sifive_gpio_read(uint64_t offset, uint64_t r) "offset 0x%" PRIx64 " value 0x%" PRIx64
28
--
176
--
29
2.20.1
177
2.20.1
30
178
31
179
diff view generated by jsdifflib
1
Checks for UNDEF cases should go before the "is VFP enabled?" access
1
Add a comment documenting the "QEMU interface" of this device:
2
check, except in special cases. Move a stray UNDEF check in the VTBL
2
which MMIO regions, IRQ lines, GPIO lines, etc it exposes.
3
trans function up above the access check.
4
3
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20201109145324.2859-1-peter.maydell@linaro.org
8
---
6
---
9
target/arm/translate-neon.c.inc | 8 ++++----
7
hw/gpio/pl061.c | 7 +++++++
10
1 file changed, 4 insertions(+), 4 deletions(-)
8
1 file changed, 7 insertions(+)
11
9
12
diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc
10
diff --git a/hw/gpio/pl061.c b/hw/gpio/pl061.c
13
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/translate-neon.c.inc
12
--- a/hw/gpio/pl061.c
15
+++ b/target/arm/translate-neon.c.inc
13
+++ b/hw/gpio/pl061.c
16
@@ -XXX,XX +XXX,XX @@ static bool trans_VTBL(DisasContext *s, arg_VTBL *a)
14
@@ -XXX,XX +XXX,XX @@
17
return false;
15
* Written by Paul Brook
18
}
16
*
19
17
* This code is licensed under the GPL.
20
- if (!vfp_access_check(s)) {
18
+ *
21
- return true;
19
+ * QEMU interface:
22
- }
20
+ * + sysbus MMIO region 0: the device registers
23
-
21
+ * + sysbus IRQ: the GPIOINTR interrupt line
24
if ((a->vn + a->len + 1) > 32) {
22
+ * + unnamed GPIO inputs 0..7: inputs to connect to the emulated GPIO lines
25
/*
23
+ * + unnamed GPIO outputs 0..7: the emulated GPIO lines, considered as
26
* This is UNPREDICTABLE; we choose to UNDEF to avoid the
24
+ * outputs
27
@@ -XXX,XX +XXX,XX @@ static bool trans_VTBL(DisasContext *s, arg_VTBL *a)
25
*/
28
return false;
26
29
}
27
#include "qemu/osdep.h"
30
31
+ if (!vfp_access_check(s)) {
32
+ return true;
33
+ }
34
+
35
desc = tcg_const_i32((a->vn << 2) | a->len);
36
def = tcg_temp_new_i64();
37
if (a->op) {
38
--
28
--
39
2.20.1
29
2.20.1
40
30
41
31
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
The Luminary variant of the PL061 has registers GPIOPUR and GPIOPDR
2
which lets the guest configure whether the GPIO lines are pull-up,
3
pull-down, or truly floating. Instead of assuming all lines are pulled
4
high, honour the PUR and PDR registers.
2
5
3
The system configuration controller (SYSCFG) doesn't have
6
For the plain PL061, continue to assume that lines have an external
4
any output IRQ (and the INTC input #71 belongs to the UART6).
7
pull-up resistor, as we did before.
5
Remove the invalid code.
6
8
7
Fixes: db635521a02 ("stm32f205: Add the stm32f205 SoC")
9
The stellaris board actually relies on this behaviour -- the CD line
8
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
of the ssd0323 display device is connected to GPIO output C7, and it
9
Message-id: 20201107193403.436146-3-f4bug@amsat.org
11
is only because of a different bug which we're about to fix that we
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
weren't incorrectly driving this line high on reset and putting the
13
ssd0323 into data mode.
14
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
---
17
---
13
include/hw/misc/stm32f2xx_syscfg.h | 2 --
18
hw/gpio/pl061.c | 58 +++++++++++++++++++++++++++++++++++++++++---
14
hw/arm/stm32f205_soc.c | 1 -
19
hw/gpio/trace-events | 2 +-
15
hw/misc/stm32f2xx_syscfg.c | 2 --
20
2 files changed, 55 insertions(+), 5 deletions(-)
16
3 files changed, 5 deletions(-)
17
21
18
diff --git a/include/hw/misc/stm32f2xx_syscfg.h b/include/hw/misc/stm32f2xx_syscfg.h
22
diff --git a/hw/gpio/pl061.c b/hw/gpio/pl061.c
19
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
20
--- a/include/hw/misc/stm32f2xx_syscfg.h
24
--- a/hw/gpio/pl061.c
21
+++ b/include/hw/misc/stm32f2xx_syscfg.h
25
+++ b/hw/gpio/pl061.c
22
@@ -XXX,XX +XXX,XX @@ struct STM32F2XXSyscfgState {
26
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_pl061 = {
23
uint32_t syscfg_exticr3;
27
}
24
uint32_t syscfg_exticr4;
25
uint32_t syscfg_cmpcr;
26
-
27
- qemu_irq irq;
28
};
28
};
29
29
30
#endif /* HW_STM32F2XX_SYSCFG_H */
30
+static uint8_t pl061_floating(PL061State *s)
31
diff --git a/hw/arm/stm32f205_soc.c b/hw/arm/stm32f205_soc.c
31
+{
32
+ /*
33
+ * Return mask of bits which correspond to pins configured as inputs
34
+ * and which are floating (neither pulled up to 1 nor down to 0).
35
+ */
36
+ uint8_t floating;
37
+
38
+ if (s->id == pl061_id_luminary) {
39
+ /*
40
+ * If both PUR and PDR bits are clear, there is neither a pullup
41
+ * nor a pulldown in place, and the output truly floats.
42
+ */
43
+ floating = ~(s->pur | s->pdr);
44
+ } else {
45
+ /* Assume outputs are pulled high. FIXME: this is board dependent. */
46
+ floating = 0;
47
+ }
48
+ return floating & ~s->dir;
49
+}
50
+
51
+static uint8_t pl061_pullups(PL061State *s)
52
+{
53
+ /*
54
+ * Return mask of bits which correspond to pins configured as inputs
55
+ * and which are pulled up to 1.
56
+ */
57
+ uint8_t pullups;
58
+
59
+ if (s->id == pl061_id_luminary) {
60
+ /*
61
+ * The Luminary variant of the PL061 has an extra registers which
62
+ * the guest can use to configure whether lines should be pullup
63
+ * or pulldown.
64
+ */
65
+ pullups = s->pur;
66
+ } else {
67
+ /* Assume outputs are pulled high. FIXME: this is board dependent. */
68
+ pullups = 0xff;
69
+ }
70
+ return pullups & ~s->dir;
71
+}
72
+
73
static void pl061_update(PL061State *s)
74
{
75
uint8_t changed;
76
uint8_t mask;
77
uint8_t out;
78
int i;
79
+ uint8_t pullups = pl061_pullups(s);
80
+ uint8_t floating = pl061_floating(s);
81
82
- trace_pl061_update(DEVICE(s)->canonical_path, s->dir, s->data);
83
+ trace_pl061_update(DEVICE(s)->canonical_path, s->dir, s->data,
84
+ pullups, floating);
85
86
- /* Outputs float high. */
87
- /* FIXME: This is board dependent. */
88
- out = (s->data & s->dir) | ~s->dir;
89
+ /*
90
+ * Pins configured as output are driven from the data register;
91
+ * otherwise if they're pulled up they're 1, and if they're floating
92
+ * then we give them the same value they had previously, so we don't
93
+ * report any change to the other end.
94
+ */
95
+ out = (s->data & s->dir) | pullups | (s->old_out_data & floating);
96
changed = s->old_out_data ^ out;
97
if (changed) {
98
s->old_out_data = out;
99
diff --git a/hw/gpio/trace-events b/hw/gpio/trace-events
32
index XXXXXXX..XXXXXXX 100644
100
index XXXXXXX..XXXXXXX 100644
33
--- a/hw/arm/stm32f205_soc.c
101
--- a/hw/gpio/trace-events
34
+++ b/hw/arm/stm32f205_soc.c
102
+++ b/hw/gpio/trace-events
35
@@ -XXX,XX +XXX,XX @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)
103
@@ -XXX,XX +XXX,XX @@ nrf51_gpio_set(int64_t line, int64_t value) "line %" PRIi64 " value %" PRIi64
36
}
104
nrf51_gpio_update_output_irq(int64_t line, int64_t value) "line %" PRIi64 " value %" PRIi64
37
busdev = SYS_BUS_DEVICE(dev);
105
38
sysbus_mmio_map(busdev, 0, 0x40013800);
106
# pl061.c
39
- sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(armv7m, 71));
107
-pl061_update(const char *id, uint32_t dir, uint32_t data) "%s GPIODIR 0x%x GPIODATA 0x%x"
40
108
+pl061_update(const char *id, uint32_t dir, uint32_t data, uint32_t pullups, uint32_t floating) "%s GPIODIR 0x%x GPIODATA 0x%x pullups 0x%x floating 0x%x"
41
/* Attach UART (uses USART registers) and USART controllers */
109
pl061_set_output(const char *id, int gpio, int level) "%s setting output %d to %d"
42
for (i = 0; i < STM_NUM_USARTS; i++) {
110
pl061_input_change(const char *id, int gpio, int level) "%s input %d changed to %d"
43
diff --git a/hw/misc/stm32f2xx_syscfg.c b/hw/misc/stm32f2xx_syscfg.c
111
pl061_update_istate(const char *id, uint32_t istate, uint32_t im, int level) "%s GPIORIS 0x%x GPIOIE 0x%x interrupt level %d"
44
index XXXXXXX..XXXXXXX 100644
45
--- a/hw/misc/stm32f2xx_syscfg.c
46
+++ b/hw/misc/stm32f2xx_syscfg.c
47
@@ -XXX,XX +XXX,XX @@ static void stm32f2xx_syscfg_init(Object *obj)
48
{
49
STM32F2XXSyscfgState *s = STM32F2XX_SYSCFG(obj);
50
51
- sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->irq);
52
-
53
memory_region_init_io(&s->mmio, obj, &stm32f2xx_syscfg_ops, s,
54
TYPE_STM32F2XX_SYSCFG, 0x400);
55
sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio);
56
--
112
--
57
2.20.1
113
2.20.1
58
114
59
115
diff view generated by jsdifflib
1
From: Xinhao Zhang <zhangxinhao1@huawei.com>
1
The PL061 GPIO does not itself include pullup or pulldown resistors
2
to set the value of a GPIO line treated as an output when it is
3
configured as an input (ie when the PL061 itself is not driving it).
4
In real hardware it is up to the board to add suitable pullups or
5
pulldowns. Currently our implementation hardwires this to "outputs
6
pulled high", which is correct for some boards (eg the realview ones:
7
see figure 3-29 in the "RealView Platform Baseboard for ARM926EJ-S
8
User Guide" DUI0224I), but wrong for others.
2
9
3
Fix code style. Space required before the open parenthesis '('.
10
In particular, the wiring in the 'virt' board and the gpio-pwr device
11
assumes that wires should be pulled low, because otherwise the
12
pull-to-high will trigger a shutdown or reset action. (The only
13
reason this doesn't happen immediately on startup is due to another
14
bug in the PL061, where we don't assert the GPIOs to the correct
15
value on reset, but will do so as soon as the guest touches a
16
register and pl061_update() gets called.)
4
17
5
Signed-off-by: Xinhao Zhang <zhangxinhao1@huawei.com>
18
Add properties to the pl061 so the board can configure whether it
6
Signed-off-by: Kai Deng <dengkai1@huawei.com>
19
wants GPIO lines to have pullup, pulldown, or neither.
7
Message-id: 20201103114529.638233-3-zhangxinhao1@huawei.com
20
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
---
23
---
11
target/arm/translate.c | 2 +-
24
hw/gpio/pl061.c | 51 +++++++++++++++++++++++++++++++++++++++++++++----
12
1 file changed, 1 insertion(+), 1 deletion(-)
25
1 file changed, 47 insertions(+), 4 deletions(-)
13
26
14
diff --git a/target/arm/translate.c b/target/arm/translate.c
27
diff --git a/hw/gpio/pl061.c b/hw/gpio/pl061.c
15
index XXXXXXX..XXXXXXX 100644
28
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/translate.c
29
--- a/hw/gpio/pl061.c
17
+++ b/target/arm/translate.c
30
+++ b/hw/gpio/pl061.c
18
@@ -XXX,XX +XXX,XX @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)
31
@@ -XXX,XX +XXX,XX @@
19
- Hardware watchpoints.
32
* + unnamed GPIO inputs 0..7: inputs to connect to the emulated GPIO lines
20
Hardware breakpoints have already been handled and skip this code.
33
* + unnamed GPIO outputs 0..7: the emulated GPIO lines, considered as
34
* outputs
35
+ * + QOM property "pullups": an integer defining whether non-floating lines
36
+ * configured as inputs should be pulled up to logical 1 (ie whether in
37
+ * real hardware they have a pullup resistor on the line out of the PL061).
38
+ * This should be an 8-bit value, where bit 0 is 1 if GPIO line 0 should
39
+ * be pulled high, bit 1 configures line 1, and so on. The default is 0xff,
40
+ * indicating that all GPIO lines are pulled up to logical 1.
41
+ * + QOM property "pulldowns": an integer defining whether non-floating lines
42
+ * configured as inputs should be pulled down to logical 0 (ie whether in
43
+ * real hardware they have a pulldown resistor on the line out of the PL061).
44
+ * This should be an 8-bit value, where bit 0 is 1 if GPIO line 0 should
45
+ * be pulled low, bit 1 configures line 1, and so on. The default is 0x0.
46
+ * It is an error to set a bit in both "pullups" and "pulldowns". If a bit
47
+ * is 0 in both, then the line is considered to be floating, and it will
48
+ * not have qemu_set_irq() called on it when it is configured as an input.
49
*/
50
51
#include "qemu/osdep.h"
52
#include "hw/irq.h"
53
#include "hw/sysbus.h"
54
+#include "hw/qdev-properties.h"
55
#include "migration/vmstate.h"
56
+#include "qapi/error.h"
57
#include "qemu/log.h"
58
#include "qemu/module.h"
59
#include "qom/object.h"
60
@@ -XXX,XX +XXX,XX @@ struct PL061State {
61
qemu_irq irq;
62
qemu_irq out[N_GPIOS];
63
const unsigned char *id;
64
+ /* Properties, for non-Luminary PL061 */
65
+ uint32_t pullups;
66
+ uint32_t pulldowns;
67
};
68
69
static const VMStateDescription vmstate_pl061 = {
70
@@ -XXX,XX +XXX,XX @@ static uint8_t pl061_floating(PL061State *s)
21
*/
71
*/
22
- switch(dc->base.is_jmp) {
72
floating = ~(s->pur | s->pdr);
23
+ switch (dc->base.is_jmp) {
73
} else {
24
case DISAS_NEXT:
74
- /* Assume outputs are pulled high. FIXME: this is board dependent. */
25
case DISAS_TOO_MANY:
75
- floating = 0;
26
gen_goto_tb(dc, 1, dc->base.pc_next);
76
+ floating = ~(s->pullups | s->pulldowns);
77
}
78
return floating & ~s->dir;
79
}
80
@@ -XXX,XX +XXX,XX @@ static uint8_t pl061_pullups(PL061State *s)
81
*/
82
pullups = s->pur;
83
} else {
84
- /* Assume outputs are pulled high. FIXME: this is board dependent. */
85
- pullups = 0xff;
86
+ pullups = s->pullups;
87
}
88
return pullups & ~s->dir;
89
}
90
@@ -XXX,XX +XXX,XX @@ static void pl061_init(Object *obj)
91
qdev_init_gpio_out(dev, s->out, N_GPIOS);
92
}
93
94
+static void pl061_realize(DeviceState *dev, Error **errp)
95
+{
96
+ PL061State *s = PL061(dev);
97
+
98
+ if (s->pullups > 0xff) {
99
+ error_setg(errp, "pullups property must be between 0 and 0xff");
100
+ return;
101
+ }
102
+ if (s->pulldowns > 0xff) {
103
+ error_setg(errp, "pulldowns property must be between 0 and 0xff");
104
+ return;
105
+ }
106
+ if (s->pullups & s->pulldowns) {
107
+ error_setg(errp, "no bit may be set both in pullups and pulldowns");
108
+ return;
109
+ }
110
+}
111
+
112
+static Property pl061_props[] = {
113
+ DEFINE_PROP_UINT32("pullups", PL061State, pullups, 0xff),
114
+ DEFINE_PROP_UINT32("pulldowns", PL061State, pulldowns, 0x0),
115
+ DEFINE_PROP_END_OF_LIST()
116
+};
117
+
118
static void pl061_class_init(ObjectClass *klass, void *data)
119
{
120
DeviceClass *dc = DEVICE_CLASS(klass);
121
122
dc->vmsd = &vmstate_pl061;
123
dc->reset = &pl061_reset;
124
+ dc->realize = pl061_realize;
125
+ device_class_set_props(dc, pl061_props);
126
}
127
128
static const TypeInfo pl061_info = {
27
--
129
--
28
2.20.1
130
2.20.1
29
131
30
132
diff view generated by jsdifflib
1
From: AlexChen <alex.chen@huawei.com>
1
For the virt board we have two PL061 devices -- one for NonSecure which
2
is inputs only, and one for Secure which is outputs only. For the former,
3
we don't care whether its outputs are pulled low or high when the line is
4
configured as an input, because we don't connect them. For the latter,
5
we do care, because we wire the lines up to the gpio-pwr device, which
6
assumes that level 1 means "do the action" and 1 means "do nothing".
7
For consistency in case we add more outputs in future, configure both
8
PL061s to pull GPIO lines down to 0.
2
9
3
We should use printf format specifier "%u" instead of "%d" for
10
Reported-by: Maxim Uvarov <maxim.uvarov@linaro.org>
4
argument of type "unsigned int".
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
---
14
hw/arm/virt.c | 3 +++
15
1 file changed, 3 insertions(+)
5
16
6
Reported-by: Euler Robot <euler.robot@huawei.com>
17
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
7
Signed-off-by: Alex Chen <alex.chen@huawei.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-id: 5FA280F5.8060902@huawei.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
hw/ssi/imx_spi.c | 2 +-
13
hw/ssi/xilinx_spi.c | 2 +-
14
2 files changed, 2 insertions(+), 2 deletions(-)
15
16
diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c
17
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/ssi/imx_spi.c
19
--- a/hw/arm/virt.c
19
+++ b/hw/ssi/imx_spi.c
20
+++ b/hw/arm/virt.c
20
@@ -XXX,XX +XXX,XX @@ static const char *imx_spi_reg_name(uint32_t reg)
21
@@ -XXX,XX +XXX,XX @@ static void create_gpio_devices(const VirtMachineState *vms, int gpio,
21
case ECSPI_MSGDATA:
22
MachineState *ms = MACHINE(vms);
22
return "ECSPI_MSGDATA";
23
23
default:
24
pl061_dev = qdev_new("pl061");
24
- sprintf(unknown, "%d ?", reg);
25
+ /* Pull lines down to 0 if not driven by the PL061 */
25
+ sprintf(unknown, "%u ?", reg);
26
+ qdev_prop_set_uint32(pl061_dev, "pullups", 0);
26
return unknown;
27
+ qdev_prop_set_uint32(pl061_dev, "pulldowns", 0xff);
27
}
28
s = SYS_BUS_DEVICE(pl061_dev);
28
}
29
sysbus_realize_and_unref(s, &error_fatal);
29
diff --git a/hw/ssi/xilinx_spi.c b/hw/ssi/xilinx_spi.c
30
memory_region_add_subregion(mem, base, sysbus_mmio_get_region(s, 0));
30
index XXXXXXX..XXXXXXX 100644
31
--- a/hw/ssi/xilinx_spi.c
32
+++ b/hw/ssi/xilinx_spi.c
33
@@ -XXX,XX +XXX,XX @@ static void xlx_spi_update_irq(XilinxSPI *s)
34
irq chain unless things really changed. */
35
if (pending != s->irqline) {
36
s->irqline = pending;
37
- DB_PRINT("irq_change of state %d ISR:%x IER:%X\n",
38
+ DB_PRINT("irq_change of state %u ISR:%x IER:%X\n",
39
pending, s->regs[R_IPISR], s->regs[R_IPIER]);
40
qemu_set_irq(s->irq, pending);
41
}
42
--
31
--
43
2.20.1
32
2.20.1
44
33
45
34
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
The PL061 comes out of reset with all its lines configured as input,
2
which means they might need to be pulled to 0 or 1 depending on the
3
'pullups' and 'pulldowns' properties. Currently we do not assert
4
these lines on reset; they will only be set whenever the guest first
5
touches a register that triggers a call to pl061_update().
2
6
3
omap2420_mpu_init() introduced in commit 827df9f3c5f ("Add basic
7
Convert the device to three-phase reset so we have a place where we
4
OMAP2 chip support") takes care of creating the 3 UARTs.
8
can safely call qemu_set_irq() to set the floating lines to their
9
correct values.
5
10
6
Then commit 58a26b477e9 ("Emulate a serial bluetooth HCI with H4+
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
extensions and attach to n8x0's UART") added n8x0_uart_setup()
12
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
which create the UART and connects it to an IRQ output,
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
overwritting the existing peripheral and its IRQ connection.
14
---
10
This is incorrect.
15
hw/gpio/pl061.c | 29 +++++++++++++++++++++++++----
16
hw/gpio/trace-events | 1 +
17
2 files changed, 26 insertions(+), 4 deletions(-)
11
18
12
Fortunately we don't need to fix this, because commit 6da68df7f9b
19
diff --git a/hw/gpio/pl061.c b/hw/gpio/pl061.c
13
("hw/arm/nseries: Replace the bluetooth chardev with a "null"
14
chardev") removed the use of this peripheral. We can simply
15
remove the code.
16
17
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
18
Message-id: 20201107193403.436146-4-f4bug@amsat.org
19
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
---
22
hw/arm/nseries.c | 11 -----------
23
1 file changed, 11 deletions(-)
24
25
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
26
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
27
--- a/hw/arm/nseries.c
21
--- a/hw/gpio/pl061.c
28
+++ b/hw/arm/nseries.c
22
+++ b/hw/gpio/pl061.c
29
@@ -XXX,XX +XXX,XX @@ static void n8x0_cbus_setup(struct n800_s *s)
23
@@ -XXX,XX +XXX,XX @@ static void pl061_write(void *opaque, hwaddr offset,
30
cbus_attach(cbus, s->tahvo = tahvo_init(tahvo_irq, 1));
24
return;
31
}
25
}
32
26
33
-static void n8x0_uart_setup(struct n800_s *s)
27
-static void pl061_reset(DeviceState *dev)
34
-{
28
+static void pl061_enter_reset(Object *obj, ResetType type)
35
- Chardev *radio = qemu_chr_new("bt-dummy-uart", "null", NULL);
36
- /*
37
- * Note: We used to connect N8X0_BT_RESET_GPIO and N8X0_BT_WKUP_GPIO
38
- * here, but this code has been removed with the bluetooth backend.
39
- */
40
- omap_uart_attach(s->mpu->uart[BT_UART], radio);
41
-}
42
-
43
static void n8x0_usb_setup(struct n800_s *s)
44
{
29
{
45
SysBusDevice *dev;
30
- PL061State *s = PL061(dev);
46
@@ -XXX,XX +XXX,XX @@ static void n8x0_init(MachineState *machine,
31
+ PL061State *s = PL061(obj);
47
n8x0_spi_setup(s);
32
+
48
n8x0_dss_setup(s);
33
+ trace_pl061_reset(DEVICE(s)->canonical_path);
49
n8x0_cbus_setup(s);
34
50
- n8x0_uart_setup(s);
35
/* reset values from PL061 TRM, Stellaris LM3S5P31 & LM3S8962 Data Sheet */
51
if (machine_usb(machine)) {
36
s->data = 0;
52
n8x0_usb_setup(s);
37
- s->old_out_data = 0;
53
}
38
s->old_in_data = 0;
39
s->dir = 0;
40
s->isense = 0;
41
@@ -XXX,XX +XXX,XX @@ static void pl061_reset(DeviceState *dev)
42
s->amsel = 0;
43
}
44
45
+static void pl061_hold_reset(Object *obj)
46
+{
47
+ PL061State *s = PL061(obj);
48
+ int i, level;
49
+ uint8_t floating = pl061_floating(s);
50
+ uint8_t pullups = pl061_pullups(s);
51
+
52
+ for (i = 0; i < N_GPIOS; i++) {
53
+ if (extract32(floating, i, 1)) {
54
+ continue;
55
+ }
56
+ level = extract32(pullups, i, 1);
57
+ trace_pl061_set_output(DEVICE(s)->canonical_path, i, level);
58
+ qemu_set_irq(s->out[i], level);
59
+ }
60
+ s->old_out_data = pullups;
61
+}
62
+
63
static void pl061_set_irq(void * opaque, int irq, int level)
64
{
65
PL061State *s = (PL061State *)opaque;
66
@@ -XXX,XX +XXX,XX @@ static Property pl061_props[] = {
67
static void pl061_class_init(ObjectClass *klass, void *data)
68
{
69
DeviceClass *dc = DEVICE_CLASS(klass);
70
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
71
72
dc->vmsd = &vmstate_pl061;
73
- dc->reset = &pl061_reset;
74
dc->realize = pl061_realize;
75
device_class_set_props(dc, pl061_props);
76
+ rc->phases.enter = pl061_enter_reset;
77
+ rc->phases.hold = pl061_hold_reset;
78
}
79
80
static const TypeInfo pl061_info = {
81
diff --git a/hw/gpio/trace-events b/hw/gpio/trace-events
82
index XXXXXXX..XXXXXXX 100644
83
--- a/hw/gpio/trace-events
84
+++ b/hw/gpio/trace-events
85
@@ -XXX,XX +XXX,XX @@ pl061_input_change(const char *id, int gpio, int level) "%s input %d changed to
86
pl061_update_istate(const char *id, uint32_t istate, uint32_t im, int level) "%s GPIORIS 0x%x GPIOIE 0x%x interrupt level %d"
87
pl061_read(const char *id, uint64_t offset, uint64_t r) "%s offset 0x%" PRIx64 " value 0x%" PRIx64
88
pl061_write(const char *id, uint64_t offset, uint64_t value) "%s offset 0x%" PRIx64 " value 0x%" PRIx64
89
+pl061_reset(const char *id) "%s reset"
90
91
# sifive_gpio.c
92
sifive_gpio_read(uint64_t offset, uint64_t r) "offset 0x%" PRIx64 " value 0x%" PRIx64
54
--
93
--
55
2.20.1
94
2.20.1
56
95
57
96
diff view generated by jsdifflib
1
The nseries machines have a codepath that allows them to load a
1
The Luminary PL061s in the Stellaris LM3S9695 don't all have the same
2
secondary bootloader. This code wasn't checking that the
2
reset value for GPIOPUR. We can get away with not letting the board
3
load_image_targphys() succeeded. Check the return value and report
3
configure the PUR reset value because we don't actually wire anything
4
the error to the user.
4
up to the lines which should reset to pull-up. Add a comment noting
5
this omission.
5
6
6
While we're in the vicinity, fix the comment style of the
7
comment documenting what this image load is doing.
8
9
Fixes: Coverity CID 1192904
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
12
Message-id: 20201103114918.11807-1-peter.maydell@linaro.org
13
---
9
---
14
hw/arm/nseries.c | 15 +++++++++++----
10
hw/gpio/pl061.c | 9 +++++++++
15
1 file changed, 11 insertions(+), 4 deletions(-)
11
1 file changed, 9 insertions(+)
16
12
17
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
13
diff --git a/hw/gpio/pl061.c b/hw/gpio/pl061.c
18
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/arm/nseries.c
15
--- a/hw/gpio/pl061.c
20
+++ b/hw/arm/nseries.c
16
+++ b/hw/gpio/pl061.c
21
@@ -XXX,XX +XXX,XX @@ static void n8x0_init(MachineState *machine,
17
@@ -XXX,XX +XXX,XX @@ static void pl061_enter_reset(Object *obj, ResetType type)
22
/* No, wait, better start at the ROM. */
18
trace_pl061_reset(DEVICE(s)->canonical_path);
23
s->mpu->cpu->env.regs[15] = OMAP2_Q2_BASE + 0x400000;
19
24
20
/* reset values from PL061 TRM, Stellaris LM3S5P31 & LM3S8962 Data Sheet */
25
- /* This is intended for loading the `secondary.bin' program from
21
+
26
+ /*
22
+ /*
27
+ * This is intended for loading the `secondary.bin' program from
23
+ * FIXME: For the LM3S6965, not all of the PL061 instances have the
28
* Nokia images (the NOLO bootloader). The entry point seems
24
+ * same reset values for GPIOPUR, GPIOAFSEL and GPIODEN, so in theory
29
* to be at OMAP2_Q2_BASE + 0x400000.
25
+ * we should allow the board to configure these via properties.
30
*
26
+ * In practice, we don't wire anything up to the affected GPIO lines
31
@@ -XXX,XX +XXX,XX @@ static void n8x0_init(MachineState *machine,
27
+ * (PB7, PC0, PC1, PC2, PC3 -- they're used for JTAG), so we can
32
* for them the entry point needs to be set to OMAP2_SRAM_BASE.
28
+ * get away with this inaccuracy.
33
*
29
+ */
34
* The code above is for loading the `zImage' file from Nokia
30
s->data = 0;
35
- * images. */
31
s->old_in_data = 0;
36
- load_image_targphys(option_rom[0].name, OMAP2_Q2_BASE + 0x400000,
32
s->dir = 0;
37
- machine->ram_size - 0x400000);
38
+ * images.
39
+ */
40
+ if (load_image_targphys(option_rom[0].name,
41
+ OMAP2_Q2_BASE + 0x400000,
42
+ machine->ram_size - 0x400000) < 0) {
43
+ error_report("Failed to load secondary bootloader %s",
44
+ option_rom[0].name);
45
+ exit(EXIT_FAILURE);
46
+ }
47
48
n800_setup_nolo_tags(nolo_tags);
49
cpu_physical_memory_write(OMAP2_SRAM_BASE, nolo_tags, 0x10000);
50
--
33
--
51
2.20.1
34
2.20.1
52
35
53
36
diff view generated by jsdifflib
1
From: Havard Skinnemoen <hskinnemoen@google.com>
1
The stellaris board doesn't emulate the handling of the OLED
2
chipselect line correctly. Expand the comment describing this,
3
including a sketch of the theoretical correct way to do it.
2
4
3
The number of runs is equal to the number of 0-1 and 1-0 transitions,
4
plus one. Currently, it's counting the number of times these transitions
5
do _not_ happen, plus one.
6
7
Source:
8
https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-22r1a.pdf
9
section 2.3.4 point (3).
10
11
Signed-off-by: Havard Skinnemoen <hskinnemoen@google.com>
12
Message-id: 20201103011457.2959989-2-hskinnemoen@google.com
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
6
---
16
tests/qtest/npcm7xx_rng-test.c | 2 +-
7
hw/arm/stellaris.c | 56 +++++++++++++++++++++++++++++++++++++++++++++-
17
1 file changed, 1 insertion(+), 1 deletion(-)
8
1 file changed, 55 insertions(+), 1 deletion(-)
18
9
19
diff --git a/tests/qtest/npcm7xx_rng-test.c b/tests/qtest/npcm7xx_rng-test.c
10
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
20
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
21
--- a/tests/qtest/npcm7xx_rng-test.c
12
--- a/hw/arm/stellaris.c
22
+++ b/tests/qtest/npcm7xx_rng-test.c
13
+++ b/hw/arm/stellaris.c
23
@@ -XXX,XX +XXX,XX @@ static double calc_runs_p(const unsigned long *buf, unsigned int nr_bits)
14
@@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
24
pi = (double)nr_ones / nr_bits;
15
DeviceState *sddev;
25
16
DeviceState *ssddev;
26
for (k = 0; k < nr_bits - 1; k++) {
17
27
- vn_obs += !(test_bit(k, buf) ^ test_bit(k + 1, buf));
18
- /* Some boards have both an OLED controller and SD card connected to
28
+ vn_obs += (test_bit(k, buf) ^ test_bit(k + 1, buf));
19
+ /*
29
}
20
+ * Some boards have both an OLED controller and SD card connected to
30
vn_obs += 1;
21
* the same SSI port, with the SD card chip select connected to a
22
* GPIO pin. Technically the OLED chip select is connected to the
23
* SSI Fss pin. We do not bother emulating that as both devices
24
* should never be selected simultaneously, and our OLED controller
25
* ignores stray 0xff commands that occur when deselecting the SD
26
* card.
27
+ *
28
+ * The h/w wiring is:
29
+ * - GPIO pin D0 is wired to the active-low SD card chip select
30
+ * - GPIO pin A3 is wired to the active-low OLED chip select
31
+ * - The SoC wiring of the PL061 "auxiliary function" for A3 is
32
+ * SSI0Fss ("frame signal"), which is an output from the SoC's
33
+ * SSI controller. The SSI controller takes SSI0Fss low when it
34
+ * transmits a frame, so it can work as a chip-select signal.
35
+ * - GPIO A4 is aux-function SSI0Rx, and wired to the SD card Tx
36
+ * (the OLED never sends data to the CPU, so no wiring needed)
37
+ * - GPIO A5 is aux-function SSI0Tx, and wired to the SD card Rx
38
+ * and the OLED display-data-in
39
+ * - GPIO A2 is aux-function SSI0Clk, wired to SD card and OLED
40
+ * serial-clock input
41
+ * So a guest that wants to use the OLED can configure the PL061
42
+ * to make pins A2, A3, A5 aux-function, so they are connected
43
+ * directly to the SSI controller. When the SSI controller sends
44
+ * data it asserts SSI0Fss which selects the OLED.
45
+ * A guest that wants to use the SD card configures A2, A4 and A5
46
+ * as aux-function, but leaves A3 as a software-controlled GPIO
47
+ * line. It asserts the SD card chip-select by using the PL061
48
+ * to control pin D0, and lets the SSI controller handle Clk, Tx
49
+ * and Rx. (The SSI controller asserts Fss during tx cycles as
50
+ * usual, but because A3 is not set to aux-function this is not
51
+ * forwarded to the OLED, and so the OLED stays unselected.)
52
+ *
53
+ * The QEMU implementation instead is:
54
+ * - GPIO pin D0 is wired to the active-low SD card chip select,
55
+ * and also to the OLED chip-select which is implemented
56
+ * as *active-high*
57
+ * - SSI controller signals go to the devices regardless of
58
+ * whether the guest programs A2, A4, A5 as aux-function or not
59
+ *
60
+ * The problem with this implementation is if the guest doesn't
61
+ * care about the SD card and only uses the OLED. In that case it
62
+ * may choose never to do anything with D0 (leaving it in its
63
+ * default floating state, which reliably leaves the card disabled
64
+ * because an SD card has a pullup on CS within the card itself),
65
+ * and only set up A2, A3, A5. This for us would mean the OLED
66
+ * never gets the chip-select assert it needs. We work around
67
+ * this with a manual raise of D0 here (despite board creation
68
+ * code being the wrong place to raise IRQ lines) to put the OLED
69
+ * into an initially selected state.
70
+ *
71
+ * In theory the right way to model this would be:
72
+ * - Implement aux-function support in the PL061, with an
73
+ * extra set of AFIN and AFOUT GPIO lines (set up so that
74
+ * if a GPIO line is in auxfn mode the main GPIO in and out
75
+ * track the AFIN and AFOUT lines)
76
+ * - Wire the AFOUT for D0 up to either a line from the
77
+ * SSI controller that's pulled low around every transmit,
78
+ * or at least to an always-0 line here on the board
79
+ * - Make the ssd0323 OLED controller chipselect active-low
80
*/
81
bus = qdev_get_child_bus(dev, "ssi");
31
82
32
--
83
--
33
2.20.1
84
2.20.1
34
85
35
86
diff view generated by jsdifflib
1
From: Xinhao Zhang <zhangxinhao1@huawei.com>
1
From: "hnick@vmware.com" <hnick@vmware.com>
2
2
3
Fix code style. Operator needs spaces both sides.
3
Signed-off-by: Nick Hudson <hnick@vmware.com>
4
5
Signed-off-by: Xinhao Zhang <zhangxinhao1@huawei.com>
6
Signed-off-by: Kai Deng <dengkai1@huawei.com>
7
Message-id: 20201103114529.638233-1-zhangxinhao1@huawei.com
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
6
---
11
target/arm/arch_dump.c | 8 ++++----
7
target/arm/helper.c | 16 +++++++++++++---
12
target/arm/arm-semi.c | 8 ++++----
8
1 file changed, 13 insertions(+), 3 deletions(-)
13
target/arm/helper.c | 2 +-
14
3 files changed, 9 insertions(+), 9 deletions(-)
15
9
16
diff --git a/target/arm/arch_dump.c b/target/arm/arch_dump.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/arch_dump.c
19
+++ b/target/arm/arch_dump.c
20
@@ -XXX,XX +XXX,XX @@ static int aarch64_write_elf64_prfpreg(WriteCoreDumpFunction f,
21
22
for (i = 0; i < 32; ++i) {
23
uint64_t *q = aa64_vfp_qreg(env, i);
24
- note.vfp.vregs[2*i + 0] = cpu_to_dump64(s, q[0]);
25
- note.vfp.vregs[2*i + 1] = cpu_to_dump64(s, q[1]);
26
+ note.vfp.vregs[2 * i + 0] = cpu_to_dump64(s, q[0]);
27
+ note.vfp.vregs[2 * i + 1] = cpu_to_dump64(s, q[1]);
28
}
29
30
if (s->dump_info.d_endian == ELFDATA2MSB) {
31
@@ -XXX,XX +XXX,XX @@ static int aarch64_write_elf64_prfpreg(WriteCoreDumpFunction f,
32
*/
33
for (i = 0; i < 32; ++i) {
34
uint64_t tmp = note.vfp.vregs[2*i];
35
- note.vfp.vregs[2*i] = note.vfp.vregs[2*i+1];
36
- note.vfp.vregs[2*i+1] = tmp;
37
+ note.vfp.vregs[2 * i] = note.vfp.vregs[2 * i + 1];
38
+ note.vfp.vregs[2 * i + 1] = tmp;
39
}
40
}
41
42
diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c
43
index XXXXXXX..XXXXXXX 100644
44
--- a/target/arm/arm-semi.c
45
+++ b/target/arm/arm-semi.c
46
@@ -XXX,XX +XXX,XX @@ target_ulong do_arm_semihosting(CPUARMState *env)
47
if (use_gdb_syscalls()) {
48
arm_semi_open_guestfd = guestfd;
49
ret = arm_gdb_syscall(cpu, arm_semi_open_cb, "open,%s,%x,1a4", arg0,
50
- (int)arg2+1, gdb_open_modeflags[arg1]);
51
+ (int)arg2 + 1, gdb_open_modeflags[arg1]);
52
} else {
53
ret = set_swi_errno(env, open(s, open_modeflags[arg1], 0644));
54
if (ret == (uint32_t)-1) {
55
@@ -XXX,XX +XXX,XX @@ target_ulong do_arm_semihosting(CPUARMState *env)
56
GET_ARG(1);
57
if (use_gdb_syscalls()) {
58
ret = arm_gdb_syscall(cpu, arm_semi_cb, "unlink,%s",
59
- arg0, (int)arg1+1);
60
+ arg0, (int)arg1 + 1);
61
} else {
62
s = lock_user_string(arg0);
63
if (!s) {
64
@@ -XXX,XX +XXX,XX @@ target_ulong do_arm_semihosting(CPUARMState *env)
65
GET_ARG(3);
66
if (use_gdb_syscalls()) {
67
return arm_gdb_syscall(cpu, arm_semi_cb, "rename,%s,%s",
68
- arg0, (int)arg1+1, arg2, (int)arg3+1);
69
+ arg0, (int)arg1 + 1, arg2, (int)arg3 + 1);
70
} else {
71
char *s2;
72
s = lock_user_string(arg0);
73
@@ -XXX,XX +XXX,XX @@ target_ulong do_arm_semihosting(CPUARMState *env)
74
GET_ARG(1);
75
if (use_gdb_syscalls()) {
76
return arm_gdb_syscall(cpu, arm_semi_cb, "system,%s",
77
- arg0, (int)arg1+1);
78
+ arg0, (int)arg1 + 1);
79
} else {
80
s = lock_user_string(arg0);
81
if (!s) {
82
diff --git a/target/arm/helper.c b/target/arm/helper.c
10
diff --git a/target/arm/helper.c b/target/arm/helper.c
83
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
84
--- a/target/arm/helper.c
12
--- a/target/arm/helper.c
85
+++ b/target/arm/helper.c
13
+++ b/target/arm/helper.c
86
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(usad8)(uint32_t a, uint32_t b)
14
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = {
87
uint32_t sum;
15
.access = PL1_RW, .accessfn = access_tda,
88
sum = do_usad(a, b);
16
.fieldoffset = offsetof(CPUARMState, cp15.mdscr_el1),
89
sum += do_usad(a >> 8, b >> 8);
17
.resetvalue = 0 },
90
- sum += do_usad(a >> 16, b >>16);
18
- /* MDCCSR_EL0, aka DBGDSCRint. This is a read-only mirror of MDSCR_EL1.
91
+ sum += do_usad(a >> 16, b >> 16);
19
+ /*
92
sum += do_usad(a >> 24, b >> 24);
20
+ * MDCCSR_EL0[30:29] map to EDSCR[30:29]. Simply RAZ as the external
93
return sum;
21
+ * Debug Communication Channel is not implemented.
94
}
22
+ */
23
+ { .name = "MDCCSR_EL0", .state = ARM_CP_STATE_AA64,
24
+ .opc0 = 2, .opc1 = 3, .crn = 0, .crm = 1, .opc2 = 0,
25
+ .access = PL0_R, .accessfn = access_tda,
26
+ .type = ARM_CP_CONST, .resetvalue = 0 },
27
+ /*
28
+ * DBGDSCRint[15,12,5:2] map to MDSCR_EL1[15,12,5:2]. Map all bits as
29
+ * it is unlikely a guest will care.
30
* We don't implement the configurable EL0 access.
31
*/
32
- { .name = "MDCCSR_EL0", .state = ARM_CP_STATE_BOTH,
33
- .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 0,
34
+ { .name = "DBGDSCRint", .state = ARM_CP_STATE_AA32,
35
+ .cp = 14, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 0,
36
.type = ARM_CP_ALIAS,
37
.access = PL1_R, .accessfn = access_tda,
38
.fieldoffset = offsetof(CPUARMState, cp15.mdscr_el1), },
95
--
39
--
96
2.20.1
40
2.20.1
97
41
98
42
diff view generated by jsdifflib
1
From: Xinhao Zhang <zhangxinhao1@huawei.com>
1
From: Rebecca Cran <rebecca@nuviainc.com>
2
2
3
Fix code style. Don't use '#' flag of printf format ('%#') in
3
Add a space in the message printed when gicr_read*/gicr_write* returns
4
format strings, use '0x' prefix instead
4
MEMTX_ERROR in arm_gicv3_redist.c.
5
5
6
Signed-off-by: Xinhao Zhang <zhangxinhao1@huawei.com>
6
Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
7
Signed-off-by: Kai Deng <dengkai1@huawei.com>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20201103114529.638233-2-zhangxinhao1@huawei.com
8
Message-id: 20210706211432.31902-1-rebecca@nuviainc.com
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
10
---
12
target/arm/translate-a64.c | 4 ++--
11
hw/intc/arm_gicv3_redist.c | 4 ++--
13
1 file changed, 2 insertions(+), 2 deletions(-)
12
1 file changed, 2 insertions(+), 2 deletions(-)
14
13
15
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
14
diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c
16
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/translate-a64.c
16
--- a/hw/intc/arm_gicv3_redist.c
18
+++ b/target/arm/translate-a64.c
17
+++ b/hw/intc/arm_gicv3_redist.c
19
@@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn)
18
@@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_redist_read(void *opaque, hwaddr offset, uint64_t *data,
20
gen_helper_advsimd_acgt_f16(tcg_res, tcg_op1, tcg_op2, fpst);
19
if (r == MEMTX_ERROR) {
21
break;
20
qemu_log_mask(LOG_GUEST_ERROR,
22
default:
21
"%s: invalid guest read at offset " TARGET_FMT_plx
23
- fprintf(stderr, "%s: insn %#04x, fpop %#2x @ %#" PRIx64 "\n",
22
- "size %u\n", __func__, offset, size);
24
+ fprintf(stderr, "%s: insn 0x%04x, fpop 0x%2x @ 0x%" PRIx64 "\n",
23
+ " size %u\n", __func__, offset, size);
25
__func__, insn, fpopcode, s->pc_curr);
24
trace_gicv3_redist_badread(gicv3_redist_affid(cs), offset,
26
g_assert_not_reached();
25
size, attrs.secure);
27
}
26
/* The spec requires that reserved registers are RAZ/WI;
28
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
27
@@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_redist_write(void *opaque, hwaddr offset, uint64_t data,
29
case 0x7f: /* FSQRT (vector) */
28
if (r == MEMTX_ERROR) {
30
break;
29
qemu_log_mask(LOG_GUEST_ERROR,
31
default:
30
"%s: invalid guest write at offset " TARGET_FMT_plx
32
- fprintf(stderr, "%s: insn %#04x fpop %#2x\n", __func__, insn, fpop);
31
- "size %u\n", __func__, offset, size);
33
+ fprintf(stderr, "%s: insn 0x%04x fpop 0x%2x\n", __func__, insn, fpop);
32
+ " size %u\n", __func__, offset, size);
34
g_assert_not_reached();
33
trace_gicv3_redist_badwrite(gicv3_redist_affid(cs), offset, data,
35
}
34
size, attrs.secure);
36
35
/* The spec requires that reserved registers are RAZ/WI;
37
--
36
--
38
2.20.1
37
2.20.1
39
38
40
39
diff view generated by jsdifflib