1 | The following changes since commit dccbaf0cc0f1744ffd7562a3dc60e4fc99fd9d44: | 1 | The following changes since commit 131c58469f6fb68c89b38fee6aba8bbb20c7f4bf: |
---|---|---|---|
2 | 2 | ||
3 | Merge tag 'hw-misc-20240227' of https://github.com/philmd/qemu into staging (2024-02-27 10:11:07 +0000) | 3 | rust: add --rust-target option for bindgen (2025-02-06 13:51:46 -0500) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20240227 | 7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20250210 |
8 | 8 | ||
9 | for you to fetch changes up to 48f471ab5450ef8981298e39583118729f6b2aa2: | 9 | for you to fetch changes up to 27a8d899c7a100fd5aa040a8b993bb257687c393: |
10 | 10 | ||
11 | docs/system/arm: Add RPi4B to raspi.rst (2024-02-27 13:01:43 +0000) | 11 | linux-user: Do not define struct sched_attr if libc headers do (2025-02-07 16:09:20 +0000) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | target-arm queue: | 14 | target-arm queue: |
15 | * Handle atomic updates of page tables entries in MMIO during PTW | 15 | * Deprecate pxa2xx CPUs, iwMMXt emulation, -old-param option |
16 | * Advertise Cortex-A53 erratum #843419 fix via REVIDR | 16 | * Drop unused AArch64DecodeTable typedefs |
17 | * MAINTAINERS: Cover hw/ide/ahci-allwinner.c with AllWinner A10 machine | 17 | * Minor code cleanups |
18 | * misc: m48t59: replace qemu_system_reset_request() call with watchdog_perform_action() | 18 | * hw/net/cadence_gem: Fix the mask/compare/disable-mask logic |
19 | * misc: pxa2xx_timer: replace qemu_system_reset_request() call with watchdog_perform_action() | 19 | * linux-user: Do not define struct sched_attr if libc headers do |
20 | * xlnx-versal-ospi: disable reentrancy detection for iomem_dac | ||
21 | * sbsa-ref: Simplify init since PCIe is always enabled | ||
22 | * stm32l4x5: Use TYPE_OR_IRQ when connecting STM32L4x5 EXTI fan-in IRQs | ||
23 | * pl031: Update last RTCLR value on write in case it's read back | ||
24 | * block: m25p80: Add support of mt35xu02gbba | ||
25 | * xlnx-versal-virt: Add machine property ospi-flash | ||
26 | * reset: refactor system reset to be three-phase aware | ||
27 | * new board model raspi4b | ||
28 | 20 | ||
29 | ---------------------------------------------------------------- | 21 | ---------------------------------------------------------------- |
30 | Abhiram Tilak (2): | 22 | Andrew Yuan (1): |
31 | misc: m48t59: replace qemu_system_reset_request() call with watchdog_perform_action() | 23 | hw/net/cadence_gem: Fix the mask/compare/disable-mask logic |
32 | misc: pxa2xx_timer: replace qemu_system_reset_request() call with watchdog_perform_action() | ||
33 | 24 | ||
34 | Ard Biesheuvel (1): | 25 | Khem Raj (1): |
35 | target/arm: Advertise Cortex-A53 erratum #843419 fix via REVIDR | 26 | linux-user: Do not define struct sched_attr if libc headers do |
36 | 27 | ||
37 | Inès Varhol (2): | 28 | Peter Maydell (4): |
38 | hw/arm: Use TYPE_OR_IRQ when connecting STM32L4x5 EXTI fan-in IRQs | 29 | target/arm: deprecate the pxa2xx CPUs and iwMMXt emulation |
39 | tests/qtest: Check that EXTI fan-in irqs are correctly connected | 30 | tests/tcg/arm: Remove test-arm-iwmmxt test |
31 | target/arm: Drop unused AArch64DecodeTable typedefs | ||
32 | qemu-options: Deprecate -old-param command line option | ||
40 | 33 | ||
41 | Jessica Clarke (1): | 34 | Philippe Mathieu-Daudé (6): |
42 | pl031: Update last RTCLR value on write in case it's read back | 35 | hw/arm/boot: Propagate vCPU to arm_load_dtb() |
36 | hw/arm/fsl-imx6: Add local 'mpcore/gic' variables | ||
37 | hw/arm/fsl-imx6ul: Add local 'mpcore/gic' variables | ||
38 | hw/arm/fsl-imx7: Add local 'mpcore/gic' variables | ||
39 | hw/cpu/arm: Alias 'num-cpu' property on TYPE_REALVIEW_MPCORE | ||
40 | hw/cpu/arm: Declare CPU QOM types using DEFINE_TYPES() macro | ||
43 | 41 | ||
44 | Jonathan Cameron (1): | 42 | docs/about/deprecated.rst | 34 ++++++++++++++++++++++ |
45 | arm/ptw: Handle atomic updates of page tables entries in MMIO during PTW. | 43 | include/hw/arm/boot.h | 4 ++- |
44 | target/arm/cpu.h | 1 + | ||
45 | hw/arm/boot.c | 11 +++---- | ||
46 | hw/arm/fsl-imx6.c | 52 ++++++++++++++------------------- | ||
47 | hw/arm/fsl-imx6ul.c | 64 +++++++++++++++++------------------------ | ||
48 | hw/arm/fsl-imx7.c | 52 +++++++++++++++------------------ | ||
49 | hw/arm/virt.c | 2 +- | ||
50 | hw/cpu/a15mpcore.c | 21 ++++++-------- | ||
51 | hw/cpu/a9mpcore.c | 21 ++++++-------- | ||
52 | hw/cpu/arm11mpcore.c | 21 ++++++-------- | ||
53 | hw/cpu/realview_mpcore.c | 29 +++++++------------ | ||
54 | hw/net/cadence_gem.c | 26 +++++++++++++---- | ||
55 | linux-user/syscall.c | 4 ++- | ||
56 | system/vl.c | 1 + | ||
57 | target/arm/cpu.c | 3 ++ | ||
58 | target/arm/tcg/cpu32.c | 36 +++++++++++++++-------- | ||
59 | target/arm/tcg/translate-a64.c | 11 ------- | ||
60 | tests/tcg/arm/Makefile.target | 7 ----- | ||
61 | tests/tcg/arm/README | 5 ---- | ||
62 | tests/tcg/arm/test-arm-iwmmxt.S | 49 ------------------------------- | ||
63 | 21 files changed, 205 insertions(+), 249 deletions(-) | ||
64 | delete mode 100644 tests/tcg/arm/test-arm-iwmmxt.S | ||
46 | 65 | ||
47 | Marcin Juszkiewicz (1): | ||
48 | hw/arm/sbsa-ref: Simplify init since PCIe is always enabled | ||
49 | |||
50 | Peter Maydell (9): | ||
51 | system/bootdevice: Don't unregister reset handler in restore_boot_order() | ||
52 | include/qom/object.h: New OBJECT_DEFINE_SIMPLE_TYPE{, _WITH_INTERFACES} macros | ||
53 | hw/core: Add documentation and license comments to reset.h | ||
54 | hw/core: Add ResetContainer which holds objects implementing Resettable | ||
55 | hw/core/reset: Add qemu_{register, unregister}_resettable() | ||
56 | hw/core/reset: Implement qemu_register_reset via qemu_register_resettable | ||
57 | hw/core/machine: Use qemu_register_resettable for sysbus reset | ||
58 | docs/devel/reset: Update to discuss system reset | ||
59 | tests/avocado/boot_linux_console.py: Add Rpi4b boot tests | ||
60 | |||
61 | Philippe Mathieu-Daudé (1): | ||
62 | MAINTAINERS: Cover hw/ide/ahci-allwinner.c with AllWinner A10 machine | ||
63 | |||
64 | Sai Pavan Boddu (3): | ||
65 | xlnx-versal-ospi: disable reentrancy detection for iomem_dac | ||
66 | block: m25p80: Add support of mt35xu02gbba | ||
67 | arm: xlnx-versal-virt: Add machine property ospi-flash | ||
68 | |||
69 | Sergey Kambalin (24): | ||
70 | hw/arm/bcm2836: Split out common part of BCM283X classes | ||
71 | hw/arm/bcm2853_peripherals: Split out common part of peripherals | ||
72 | hw/arm/raspi: Split out raspi machine common part | ||
73 | hw/arm: Introduce BCM2838 SoC | ||
74 | hw/arm/bcm2838: Add GIC-400 to BCM2838 SoC | ||
75 | hw/gpio: Add BCM2838 GPIO stub | ||
76 | hw/gpio: Implement BCM2838 GPIO functionality | ||
77 | hw/gpio: Connect SD controller to BCM2838 GPIO | ||
78 | hw/arm: Add GPIO and SD to BCM2838 periph | ||
79 | hw/arm: Introduce Raspberry PI 4 machine | ||
80 | hw/arm/raspi4b: Temporarily disable unimplemented rpi4b devices | ||
81 | hw/arm: Add memory region for BCM2837 RPiVid ASB | ||
82 | hw/arm/bcm2838_peripherals: Add clock_isp stub | ||
83 | tests/qtest: Add bcm2838 mailbox test stub | ||
84 | tests/qtest/bcm2828-mailbox: Add mailbox test constants | ||
85 | tests/qtest/bcm2828-mailbox: Add mailbox tests tags. Part 1 | ||
86 | tests/qtest/bcm2828-mailbox: Add mailbox tests tags. Part 2 | ||
87 | tests/qtest/bcm2828-mailbox: Add mailbox tests tags. Part 3 | ||
88 | tests/qtest/bcm2828-mailbox: Add mailbox property tests. Part 1 | ||
89 | tests/qtest/bcm2828-mailbox: Add mailbox property tests. Part 2 | ||
90 | tests/qtest/bcm2828-mailbox: Add mailbox property tests. Part 3 | ||
91 | hw/misc/bcm2835_property: Add missed BCM2835 properties | ||
92 | tests/qtest/bcm2828-mailbox: Append added properties to mailbox test | ||
93 | docs/system/arm: Add RPi4B to raspi.rst | ||
94 | |||
95 | MAINTAINERS | 11 + | ||
96 | docs/devel/qom.rst | 34 +- | ||
97 | docs/devel/reset.rst | 44 ++- | ||
98 | docs/system/arm/raspi.rst | 12 +- | ||
99 | hw/block/m25p80_sfdp.h | 1 + | ||
100 | include/hw/arm/bcm2835_peripherals.h | 29 +- | ||
101 | include/hw/arm/bcm2836.h | 27 +- | ||
102 | include/hw/arm/bcm2838.h | 31 ++ | ||
103 | include/hw/arm/bcm2838_peripherals.h | 84 ++++ | ||
104 | include/hw/arm/raspberrypi-fw-defs.h | 11 + | ||
105 | include/hw/arm/raspi_platform.h | 38 +- | ||
106 | include/hw/arm/stm32l4x5_soc.h | 4 + | ||
107 | include/hw/core/resetcontainer.h | 48 +++ | ||
108 | include/hw/display/bcm2835_fb.h | 2 + | ||
109 | include/hw/gpio/bcm2838_gpio.h | 45 +++ | ||
110 | include/qom/object.h | 114 ++++-- | ||
111 | include/sysemu/reset.h | 113 ++++++ | ||
112 | tests/qtest/bcm2838-mailbox.h | 532 ++++++++++++++++++++++++++ | ||
113 | hw/arm/bcm2835_peripherals.c | 215 ++++++----- | ||
114 | hw/arm/bcm2836.c | 117 +++--- | ||
115 | hw/arm/bcm2838.c | 263 +++++++++++++ | ||
116 | hw/arm/bcm2838_peripherals.c | 224 +++++++++++ | ||
117 | hw/arm/raspi.c | 130 ++++--- | ||
118 | hw/arm/raspi4b.c | 132 +++++++ | ||
119 | hw/arm/sbsa-ref.c | 5 +- | ||
120 | hw/arm/stm32l4x5_soc.c | 80 +++- | ||
121 | hw/arm/xlnx-versal-virt.c | 44 ++- | ||
122 | hw/block/m25p80.c | 3 + | ||
123 | hw/block/m25p80_sfdp.c | 36 ++ | ||
124 | hw/core/machine.c | 7 +- | ||
125 | hw/core/reset.c | 166 ++++++-- | ||
126 | hw/core/resetcontainer.c | 77 ++++ | ||
127 | hw/gpio/bcm2838_gpio.c | 390 +++++++++++++++++++ | ||
128 | hw/misc/bcm2835_property.c | 21 + | ||
129 | hw/rtc/m48t59.c | 4 +- | ||
130 | hw/rtc/pl031.c | 1 + | ||
131 | hw/ssi/xlnx-versal-ospi.c | 6 + | ||
132 | hw/timer/pxa2xx_timer.c | 3 +- | ||
133 | system/bootdevice.c | 25 +- | ||
134 | target/arm/cpu64.c | 2 +- | ||
135 | target/arm/ptw.c | 64 +++- | ||
136 | tests/qtest/bcm2838-mailbox.c | 60 +++ | ||
137 | tests/qtest/bcm2838-mbox-property-test.c | 631 +++++++++++++++++++++++++++++++ | ||
138 | tests/qtest/stm32l4x5_exti-test.c | 37 ++ | ||
139 | hw/arm/meson.build | 2 + | ||
140 | hw/arm/trace-events | 3 + | ||
141 | hw/core/meson.build | 1 + | ||
142 | hw/gpio/meson.build | 5 +- | ||
143 | tests/avocado/boot_linux_console.py | 97 +++++ | ||
144 | tests/qtest/meson.build | 3 +- | ||
145 | 50 files changed, 3728 insertions(+), 306 deletions(-) | ||
146 | create mode 100644 include/hw/arm/bcm2838.h | ||
147 | create mode 100644 include/hw/arm/bcm2838_peripherals.h | ||
148 | create mode 100644 include/hw/core/resetcontainer.h | ||
149 | create mode 100644 include/hw/gpio/bcm2838_gpio.h | ||
150 | create mode 100644 tests/qtest/bcm2838-mailbox.h | ||
151 | create mode 100644 hw/arm/bcm2838.c | ||
152 | create mode 100644 hw/arm/bcm2838_peripherals.c | ||
153 | create mode 100644 hw/arm/raspi4b.c | ||
154 | create mode 100644 hw/core/resetcontainer.c | ||
155 | create mode 100644 hw/gpio/bcm2838_gpio.c | ||
156 | create mode 100644 tests/qtest/bcm2838-mailbox.c | ||
157 | create mode 100644 tests/qtest/bcm2838-mbox-property-test.c | ||
158 | diff view generated by jsdifflib |
1 | Add the usual boilerplate license/copyright comment to reset.h (using | 1 | The pxa2xx CPUs are now only useful with user-mode emulation, because |
---|---|---|---|
2 | the text from reset.c), and document the existing functions. | 2 | we dropped all the machine types that used them in 9.2. (Technically |
3 | you could alse use "-cpu pxa270" with a board model like versatilepb | ||
4 | which doesn't sanity-check the CPU type, but that has never been a | ||
5 | supported config.) | ||
6 | |||
7 | To use them (or iwMMXt emulation) with QEMU user-mode you would need | ||
8 | to explicitly select them with the -cpu option or the QEMU_CPU | ||
9 | environment variable. A google search finds no examples of anybody | ||
10 | doing this in the last decade; I don't believe the GCC folks are | ||
11 | using QEMU to test their iwMMXt codegen either. In fact, GCC is in | ||
12 | the process of dropping support for iwMMXT entirely. | ||
13 | |||
14 | The iwMMXt emulation is thousands of lines of code in QEMU, and | ||
15 | is now the only bit of Arm insn decode which doesn't use decodetree. | ||
16 | We have no way to test or validate changes to it. This code is | ||
17 | just dead weight that is almost certainly not being used by anybody. | ||
18 | Mark it as deprecated. | ||
3 | 19 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 21 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 22 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | 23 | Message-id: 20250127112715.2936555-2-peter.maydell@linaro.org |
9 | Message-id: 20240220160622.114437-6-peter.maydell@linaro.org | ||
10 | --- | 24 | --- |
11 | include/sysemu/reset.h | 79 ++++++++++++++++++++++++++++++++++++++++++ | 25 | docs/about/deprecated.rst | 21 +++++++++++++++++++++ |
12 | 1 file changed, 79 insertions(+) | 26 | target/arm/cpu.h | 1 + |
27 | target/arm/cpu.c | 3 +++ | ||
28 | target/arm/tcg/cpu32.c | 36 ++++++++++++++++++++++++------------ | ||
29 | 4 files changed, 49 insertions(+), 12 deletions(-) | ||
13 | 30 | ||
14 | diff --git a/include/sysemu/reset.h b/include/sysemu/reset.h | 31 | diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst |
15 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/include/sysemu/reset.h | 33 | --- a/docs/about/deprecated.rst |
17 | +++ b/include/sysemu/reset.h | 34 | +++ b/docs/about/deprecated.rst |
18 | @@ -XXX,XX +XXX,XX @@ | 35 | @@ -XXX,XX +XXX,XX @@ is going to be so much slower it wouldn't make sense for any serious |
19 | +/* | 36 | instrumentation. Due to implementation differences there will also be |
20 | + * Reset handlers. | 37 | anomalies in things like memory instrumentation. |
21 | + * | 38 | |
22 | + * Copyright (c) 2003-2008 Fabrice Bellard | 39 | +linux-user mode CPUs |
23 | + * Copyright (c) 2016 Red Hat, Inc. | 40 | +-------------------- |
24 | + * Copyright (c) 2024 Linaro, Ltd. | ||
25 | + * | ||
26 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
27 | + * of this software and associated documentation files (the "Software"), to deal | ||
28 | + * in the Software without restriction, including without limitation the rights | ||
29 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
30 | + * copies of the Software, and to permit persons to whom the Software is | ||
31 | + * furnished to do so, subject to the following conditions: | ||
32 | + * | ||
33 | + * The above copyright notice and this permission notice shall be included in | ||
34 | + * all copies or substantial portions of the Software. | ||
35 | + * | ||
36 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
37 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
38 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
39 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
40 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
41 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
42 | + * THE SOFTWARE. | ||
43 | + */ | ||
44 | + | 41 | + |
45 | #ifndef QEMU_SYSEMU_RESET_H | 42 | +iwMMXt emulation and the ``pxa`` CPUs (since 10.0) |
46 | #define QEMU_SYSEMU_RESET_H | 43 | +'''''''''''''''''''''''''''''''''''''''''''''''''' |
47 | |||
48 | @@ -XXX,XX +XXX,XX @@ | ||
49 | |||
50 | typedef void QEMUResetHandler(void *opaque); | ||
51 | |||
52 | +/** | ||
53 | + * qemu_register_reset: Register a callback for system reset | ||
54 | + * @func: function to call | ||
55 | + * @opaque: opaque data to pass to @func | ||
56 | + * | ||
57 | + * Register @func on the list of functions which are called when the | ||
58 | + * entire system is reset. The functions are called in the order in | ||
59 | + * which they are registered. | ||
60 | + * | ||
61 | + * In general this function should not be used in new code where possible; | ||
62 | + * for instance, device model reset is better accomplished using the | ||
63 | + * methods on DeviceState. | ||
64 | + * | ||
65 | + * It is not permitted to register or unregister reset functions from | ||
66 | + * within the @func callback. | ||
67 | + * | ||
68 | + * We assume that the caller holds the BQL. | ||
69 | + */ | ||
70 | void qemu_register_reset(QEMUResetHandler *func, void *opaque); | ||
71 | + | 44 | + |
72 | +/** | 45 | +The ``pxa`` CPU family (``pxa250``, ``pxa255``, ``pxa260``, |
73 | + * qemu_register_reset_nosnapshotload: Register a callback for system reset | 46 | +``pxa261``, ``pxa262``, ``pxa270-a0``, ``pxa270-a1``, ``pxa270``, |
74 | + * @func: function to call | 47 | +``pxa270-b0``, ``pxa270-b1``, ``pxa270-c0``, ``pxa270-c5``) are no |
75 | + * @opaque: opaque data to pass to @func | 48 | +longer used in system emulation, because all the machine types which |
76 | + * | 49 | +used these CPUs were removed in the QEMU 9.2 release. These CPUs can |
77 | + * This is the same as qemu_register_reset(), except that @func is | 50 | +now only be used in linux-user mode, and to do that you would have to |
78 | + * not called if the reason that the system is being reset is to | 51 | +explicitly select one of these CPUs with the ``-cpu`` command line |
79 | + * put it into a clean state prior to loading a snapshot (i.e. for | 52 | +option or the ``QEMU_CPU`` environment variable. |
80 | + * SHUTDOWN_CAUSE_SNAPSHOT_LOAD). | ||
81 | + */ | ||
82 | void qemu_register_reset_nosnapshotload(QEMUResetHandler *func, void *opaque); | ||
83 | + | 53 | + |
84 | +/** | 54 | +We don't believe that anybody is using the iwMMXt emulation, and we do |
85 | + * qemu_unregister_reset: Unregister a system reset callback | 55 | +not have any tests to validate it or any real hardware or similar |
86 | + * @func: function registered with qemu_register_reset() | 56 | +known-good implementation to test against. GCC is in the process of |
87 | + * @opaque: the same opaque data that was passed to qemu_register_reset() | 57 | +dropping their support for iwMMXt codegen. These CPU types are |
88 | + * | 58 | +therefore deprecated in QEMU, and will be removed in a future release. |
89 | + * Undo the effects of a qemu_register_reset(). The @func and @opaque | ||
90 | + * must both match the arguments originally used with qemu_register_reset(). | ||
91 | + * | ||
92 | + * We assume that the caller holds the BQL. | ||
93 | + */ | ||
94 | void qemu_unregister_reset(QEMUResetHandler *func, void *opaque); | ||
95 | + | 59 | + |
96 | +/** | 60 | System emulator CPUs |
97 | + * qemu_devices_reset: Perform a complete system reset | 61 | -------------------- |
98 | + * @reason: reason for the reset | 62 | |
99 | + * | 63 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
100 | + * This function performs the low-level work needed to do a complete reset | 64 | index XXXXXXX..XXXXXXX 100644 |
101 | + * of the system (calling all the callbacks registered with | 65 | --- a/target/arm/cpu.h |
102 | + * qemu_register_reset()). It should only be called by the code in a | 66 | +++ b/target/arm/cpu.h |
103 | + * MachineClass reset method. | 67 | @@ -XXX,XX +XXX,XX @@ struct ArchCPU { |
104 | + * | 68 | |
105 | + * If you want to trigger a system reset from, for instance, a device | 69 | typedef struct ARMCPUInfo { |
106 | + * model, don't use this function. Use qemu_system_reset_request(). | 70 | const char *name; |
107 | + */ | 71 | + const char *deprecation_note; |
108 | void qemu_devices_reset(ShutdownCause reason); | 72 | void (*initfn)(Object *obj); |
109 | 73 | void (*class_init)(ObjectClass *oc, void *data); | |
74 | } ARMCPUInfo; | ||
75 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
76 | index XXXXXXX..XXXXXXX 100644 | ||
77 | --- a/target/arm/cpu.c | ||
78 | +++ b/target/arm/cpu.c | ||
79 | @@ -XXX,XX +XXX,XX @@ static void cpu_register_class_init(ObjectClass *oc, void *data) | ||
80 | |||
81 | acc->info = data; | ||
82 | cc->gdb_core_xml_file = "arm-core.xml"; | ||
83 | + if (acc->info->deprecation_note) { | ||
84 | + cc->deprecation_note = acc->info->deprecation_note; | ||
85 | + } | ||
86 | } | ||
87 | |||
88 | void arm_cpu_register(const ARMCPUInfo *info) | ||
89 | diff --git a/target/arm/tcg/cpu32.c b/target/arm/tcg/cpu32.c | ||
90 | index XXXXXXX..XXXXXXX 100644 | ||
91 | --- a/target/arm/tcg/cpu32.c | ||
92 | +++ b/target/arm/tcg/cpu32.c | ||
93 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_tcg_cpus[] = { | ||
94 | { .name = "ti925t", .initfn = ti925t_initfn }, | ||
95 | { .name = "sa1100", .initfn = sa1100_initfn }, | ||
96 | { .name = "sa1110", .initfn = sa1110_initfn }, | ||
97 | - { .name = "pxa250", .initfn = pxa250_initfn }, | ||
98 | - { .name = "pxa255", .initfn = pxa255_initfn }, | ||
99 | - { .name = "pxa260", .initfn = pxa260_initfn }, | ||
100 | - { .name = "pxa261", .initfn = pxa261_initfn }, | ||
101 | - { .name = "pxa262", .initfn = pxa262_initfn }, | ||
102 | + { .name = "pxa250", .initfn = pxa250_initfn, | ||
103 | + .deprecation_note = "iwMMXt CPUs are no longer supported", }, | ||
104 | + { .name = "pxa255", .initfn = pxa255_initfn, | ||
105 | + .deprecation_note = "iwMMXt CPUs are no longer supported", }, | ||
106 | + { .name = "pxa260", .initfn = pxa260_initfn, | ||
107 | + .deprecation_note = "iwMMXt CPUs are no longer supported", }, | ||
108 | + { .name = "pxa261", .initfn = pxa261_initfn, | ||
109 | + .deprecation_note = "iwMMXt CPUs are no longer supported", }, | ||
110 | + { .name = "pxa262", .initfn = pxa262_initfn, | ||
111 | + .deprecation_note = "iwMMXt CPUs are no longer supported", }, | ||
112 | /* "pxa270" is an alias for "pxa270-a0" */ | ||
113 | - { .name = "pxa270", .initfn = pxa270a0_initfn }, | ||
114 | - { .name = "pxa270-a0", .initfn = pxa270a0_initfn }, | ||
115 | - { .name = "pxa270-a1", .initfn = pxa270a1_initfn }, | ||
116 | - { .name = "pxa270-b0", .initfn = pxa270b0_initfn }, | ||
117 | - { .name = "pxa270-b1", .initfn = pxa270b1_initfn }, | ||
118 | - { .name = "pxa270-c0", .initfn = pxa270c0_initfn }, | ||
119 | - { .name = "pxa270-c5", .initfn = pxa270c5_initfn }, | ||
120 | + { .name = "pxa270", .initfn = pxa270a0_initfn, | ||
121 | + .deprecation_note = "iwMMXt CPUs are no longer supported", }, | ||
122 | + { .name = "pxa270-a0", .initfn = pxa270a0_initfn, | ||
123 | + .deprecation_note = "iwMMXt CPUs are no longer supported", }, | ||
124 | + { .name = "pxa270-a1", .initfn = pxa270a1_initfn, | ||
125 | + .deprecation_note = "iwMMXt CPUs are no longer supported", }, | ||
126 | + { .name = "pxa270-b0", .initfn = pxa270b0_initfn, | ||
127 | + .deprecation_note = "iwMMXt CPUs are no longer supported", }, | ||
128 | + { .name = "pxa270-b1", .initfn = pxa270b1_initfn, | ||
129 | + .deprecation_note = "iwMMXt CPUs are no longer supported", }, | ||
130 | + { .name = "pxa270-c0", .initfn = pxa270c0_initfn, | ||
131 | + .deprecation_note = "iwMMXt CPUs are no longer supported", }, | ||
132 | + { .name = "pxa270-c5", .initfn = pxa270c5_initfn, | ||
133 | + .deprecation_note = "iwMMXt CPUs are no longer supported", }, | ||
134 | #ifndef TARGET_AARCH64 | ||
135 | { .name = "max", .initfn = arm_max_initfn }, | ||
110 | #endif | 136 | #endif |
111 | -- | 137 | -- |
112 | 2.34.1 | 138 | 2.34.1 |
113 | 139 | ||
114 | 140 | diff view generated by jsdifflib |
1 | Implement a ResetContainer. This is a subclass of Object, and it | 1 | The test-arm-iwmmmxt test isn't testing what it thinks it's testing. |
---|---|---|---|
2 | implements the Resettable interface. The container holds a list of | ||
3 | arbitrary other objects which implement Resettable, and when the | ||
4 | container is reset, all the objects it contains are also reset. | ||
5 | 2 | ||
6 | This will allow us to have a 3-phase-reset equivalent of the old | 3 | If you run it with a CPU type that supports iwMMXt then it will crash |
7 | qemu_register_reset() API: we will have a single "simulation reset" | 4 | immediately with a SIGILL, because (even with -marm) GCC will link it |
8 | top level ResetContainer, and objects in it are the equivalent of the | 5 | against startup code that is in Thumb mode, and no iwMMXt CPU has |
9 | old QEMUResetHandler functions. | 6 | Thumb: |
10 | 7 | ||
11 | The qemu_register_reset() API manages its list of callbacks using a | 8 | 00010338 <_start>: |
12 | QTAILQ, but here we use a GPtrArray for our list of Resettable | 9 | 10338: f04f 0b00 mov.w fp, #0 |
13 | children: we expect the "remove" operation (which will need to do an | 10 | 1033c: f04f 0e00 mov.w lr, #0 |
14 | iteration through the list) to be fairly uncommon, and we get simpler | ||
15 | code with fewer memory allocations. | ||
16 | 11 | ||
17 | Since there is currently no listed owner in MAINTAINERS for the | 12 | If you run it with a CPU type which does *not* support iwMMXt, which |
18 | existing reset-related source files, create a new section for | 13 | is what 'make check-tcg' does, then QEMU will not try to handle the |
19 | them, and add these new files there also. | 14 | insns as iwMMXt. Instead the translator turns them into illegal |
15 | instructions. Then in the linux-user cpu_loop() code we identify | ||
16 | them as FPA11 instructions inside emulate_arm_fpa11(), because the | ||
17 | FPA11 happened to use the same coprocessor number as these iwMMXt | ||
18 | insns. So we execute a completely different set of FPA11 insns, | ||
19 | which means we don't crash, but we will print garbage to stdout. | ||
20 | Then the test binary always exits with a 0 return code, so 'make | ||
21 | check-tcg' thinks the test passes. | ||
22 | |||
23 | Modern gnueabihf toolchains assume in their startup code that the CPU | ||
24 | is not so old as to not support Thumb, so there's no way to get them | ||
25 | to generate a binary that actually does what the test wants. Since | ||
26 | we're deprecating iwMMXt emulation anyway, it's not worth trying to | ||
27 | salvage the test case to get it to really test the iwMMXt insns. | ||
28 | |||
29 | Delete the test entirely. | ||
20 | 30 | ||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 31 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
22 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> | ||
23 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 32 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
24 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 33 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
25 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | 34 | Message-id: 20250127112715.2936555-3-peter.maydell@linaro.org |
26 | Message-id: 20240220160622.114437-7-peter.maydell@linaro.org | ||
27 | Reviewed-by: Zhao Liu <zhao1.liu@intel.com> | ||
28 | --- | 35 | --- |
29 | MAINTAINERS | 10 +++++ | 36 | tests/tcg/arm/Makefile.target | 7 ----- |
30 | include/hw/core/resetcontainer.h | 48 ++++++++++++++++++++ | 37 | tests/tcg/arm/README | 5 ---- |
31 | hw/core/resetcontainer.c | 77 ++++++++++++++++++++++++++++++++ | 38 | tests/tcg/arm/test-arm-iwmmxt.S | 49 --------------------------------- |
32 | hw/core/meson.build | 1 + | 39 | 3 files changed, 61 deletions(-) |
33 | 4 files changed, 136 insertions(+) | 40 | delete mode 100644 tests/tcg/arm/test-arm-iwmmxt.S |
34 | create mode 100644 include/hw/core/resetcontainer.h | ||
35 | create mode 100644 hw/core/resetcontainer.c | ||
36 | 41 | ||
37 | diff --git a/MAINTAINERS b/MAINTAINERS | 42 | diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target |
38 | index XXXXXXX..XXXXXXX 100644 | 43 | index XXXXXXX..XXXXXXX 100644 |
39 | --- a/MAINTAINERS | 44 | --- a/tests/tcg/arm/Makefile.target |
40 | +++ b/MAINTAINERS | 45 | +++ b/tests/tcg/arm/Makefile.target |
41 | @@ -XXX,XX +XXX,XX @@ F: hw/core/clock-vmstate.c | 46 | @@ -XXX,XX +XXX,XX @@ ARM_TESTS = hello-arm |
42 | F: hw/core/qdev-clock.c | 47 | hello-arm: CFLAGS+=-marm -ffreestanding -fno-stack-protector |
43 | F: docs/devel/clocks.rst | 48 | hello-arm: LDFLAGS+=-nostdlib |
44 | 49 | ||
45 | +Reset framework | 50 | -# IWMXT floating point extensions |
46 | +M: Peter Maydell <peter.maydell@linaro.org> | 51 | -ARM_TESTS += test-arm-iwmmxt |
47 | +S: Maintained | 52 | -# Clang assembler does not support IWMXT, so use the external assembler. |
48 | +F: include/hw/resettable.h | 53 | -test-arm-iwmmxt: CFLAGS += -marm -march=iwmmxt -mabi=aapcs -mfpu=fpv4-sp-d16 $(CROSS_CC_HAS_FNIA) |
49 | +F: include/hw/core/resetcontainer.h | 54 | -test-arm-iwmmxt: test-arm-iwmmxt.S |
50 | +F: include/sysemu/reset.h | 55 | - $(CC) $(CFLAGS) -Wa,--noexecstack $< -o $@ $(LDFLAGS) |
51 | +F: hw/core/reset.c | 56 | - |
52 | +F: hw/core/resettable.c | 57 | # Float-convert Tests |
53 | +F: hw/core/resetcontainer.c | 58 | ARM_TESTS += fcvt |
54 | + | 59 | fcvt: LDFLAGS += -lm |
55 | Usermode Emulation | 60 | diff --git a/tests/tcg/arm/README b/tests/tcg/arm/README |
56 | ------------------ | 61 | index XXXXXXX..XXXXXXX 100644 |
57 | Overall usermode emulation | 62 | --- a/tests/tcg/arm/README |
58 | diff --git a/include/hw/core/resetcontainer.h b/include/hw/core/resetcontainer.h | 63 | +++ b/tests/tcg/arm/README |
59 | new file mode 100644 | 64 | @@ -XXX,XX +XXX,XX @@ hello-arm |
65 | --------- | ||
66 | |||
67 | A very simple inline assembly, write syscall based hello world | ||
68 | - | ||
69 | -test-arm-iwmmxt | ||
70 | ---------------- | ||
71 | - | ||
72 | -A simple test case for older iwmmxt extended ARMs | ||
73 | diff --git a/tests/tcg/arm/test-arm-iwmmxt.S b/tests/tcg/arm/test-arm-iwmmxt.S | ||
74 | deleted file mode 100644 | ||
60 | index XXXXXXX..XXXXXXX | 75 | index XXXXXXX..XXXXXXX |
61 | --- /dev/null | 76 | --- a/tests/tcg/arm/test-arm-iwmmxt.S |
62 | +++ b/include/hw/core/resetcontainer.h | 77 | +++ /dev/null |
63 | @@ -XXX,XX +XXX,XX @@ | 78 | @@ -XXX,XX +XXX,XX @@ |
64 | +/* | 79 | -@ Checks whether iwMMXt is functional. |
65 | + * Reset container | 80 | -.code 32 |
66 | + * | 81 | -.globl main |
67 | + * Copyright (c) 2024 Linaro, Ltd | 82 | - |
68 | + * | 83 | -main: |
69 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | 84 | -ldr r0, =data0 |
70 | + * See the COPYING file in the top-level directory. | 85 | -ldr r1, =data1 |
71 | + */ | 86 | -ldr r2, =data2 |
72 | + | 87 | -#ifndef FPA |
73 | +#ifndef HW_RESETCONTAINER_H | 88 | -wldrd wr0, [r0, #0] |
74 | +#define HW_RESETCONTAINER_H | 89 | -wldrd wr1, [r0, #8] |
75 | + | 90 | -wldrd wr2, [r1, #0] |
76 | +/* | 91 | -wldrd wr3, [r1, #8] |
77 | + * The "reset container" is an object which implements the Resettable | 92 | -wsubb wr2, wr2, wr0 |
78 | + * interface. It contains a list of arbitrary other objects which also | 93 | -wsubb wr3, wr3, wr1 |
79 | + * implement Resettable. Resetting the reset container resets all the | 94 | -wldrd wr0, [r2, #0] |
80 | + * objects in it. | 95 | -wldrd wr1, [r2, #8] |
81 | + */ | 96 | -waddb wr0, wr0, wr2 |
82 | + | 97 | -waddb wr1, wr1, wr3 |
83 | +#include "qom/object.h" | 98 | -wstrd wr0, [r2, #0] |
84 | + | 99 | -wstrd wr1, [r2, #8] |
85 | +#define TYPE_RESETTABLE_CONTAINER "resettable-container" | 100 | -#else |
86 | +OBJECT_DECLARE_TYPE(ResettableContainer, ResettableContainerClass, RESETTABLE_CONTAINER) | 101 | -ldfe f0, [r0, #0] |
87 | + | 102 | -ldfe f1, [r0, #8] |
88 | +/** | 103 | -ldfe f2, [r1, #0] |
89 | + * resettable_container_add: Add a resettable object to the container | 104 | -ldfe f3, [r1, #8] |
90 | + * @rc: container | 105 | -adfdp f2, f2, f0 |
91 | + * @obj: object to add to the container | 106 | -adfdp f3, f3, f1 |
92 | + * | 107 | -ldfe f0, [r2, #0] |
93 | + * Add @obj to the ResettableContainer @rc. @obj must implement the | 108 | -ldfe f1, [r2, #8] |
94 | + * Resettable interface. | 109 | -adfd f0, f0, f2 |
95 | + * | 110 | -adfd f1, f1, f3 |
96 | + * When @rc is reset, it will reset every object that has been added | 111 | -stfe f0, [r2, #0] |
97 | + * to it, in the order they were added. | 112 | -stfe f1, [r2, #8] |
98 | + */ | 113 | -#endif |
99 | +void resettable_container_add(ResettableContainer *rc, Object *obj); | 114 | -mov r0, #1 |
100 | + | 115 | -mov r1, r2 |
101 | +/** | 116 | -mov r2, #0x11 |
102 | + * resettable_container_remove: Remove an object from the container | 117 | -swi #0x900004 |
103 | + * @rc: container | 118 | -mov r0, #0 |
104 | + * @obj: object to remove from the container | 119 | -swi #0x900001 |
105 | + * | 120 | - |
106 | + * Remove @obj from the ResettableContainer @rc. @obj must have been | 121 | -.data |
107 | + * previously added to this container. | 122 | -data0: |
108 | + */ | 123 | -.string "aaaabbbbccccdddd" |
109 | +void resettable_container_remove(ResettableContainer *rc, Object *obj); | 124 | -data1: |
110 | + | 125 | -.string "bbbbccccddddeeee" |
111 | +#endif | 126 | -data2: |
112 | diff --git a/hw/core/resetcontainer.c b/hw/core/resetcontainer.c | 127 | -.string "hvLLWs\x1fsdrs9\x1fNJ-\n" |
113 | new file mode 100644 | ||
114 | index XXXXXXX..XXXXXXX | ||
115 | --- /dev/null | ||
116 | +++ b/hw/core/resetcontainer.c | ||
117 | @@ -XXX,XX +XXX,XX @@ | ||
118 | +/* | ||
119 | + * Reset container | ||
120 | + * | ||
121 | + * Copyright (c) 2024 Linaro, Ltd | ||
122 | + * | ||
123 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
124 | + * See the COPYING file in the top-level directory. | ||
125 | + */ | ||
126 | + | ||
127 | +/* | ||
128 | + * The "reset container" is an object which implements the Resettable | ||
129 | + * interface. It contains a list of arbitrary other objects which also | ||
130 | + * implement Resettable. Resetting the reset container resets all the | ||
131 | + * objects in it. | ||
132 | + */ | ||
133 | + | ||
134 | +#include "qemu/osdep.h" | ||
135 | +#include "hw/resettable.h" | ||
136 | +#include "hw/core/resetcontainer.h" | ||
137 | + | ||
138 | +struct ResettableContainer { | ||
139 | + Object parent; | ||
140 | + ResettableState reset_state; | ||
141 | + GPtrArray *children; | ||
142 | +}; | ||
143 | + | ||
144 | +OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES(ResettableContainer, resettable_container, RESETTABLE_CONTAINER, OBJECT, { TYPE_RESETTABLE_INTERFACE }, { }) | ||
145 | + | ||
146 | +void resettable_container_add(ResettableContainer *rc, Object *obj) | ||
147 | +{ | ||
148 | + INTERFACE_CHECK(void, obj, TYPE_RESETTABLE_INTERFACE); | ||
149 | + g_ptr_array_add(rc->children, obj); | ||
150 | +} | ||
151 | + | ||
152 | +void resettable_container_remove(ResettableContainer *rc, Object *obj) | ||
153 | +{ | ||
154 | + g_ptr_array_remove(rc->children, obj); | ||
155 | +} | ||
156 | + | ||
157 | +static ResettableState *resettable_container_get_state(Object *obj) | ||
158 | +{ | ||
159 | + ResettableContainer *rc = RESETTABLE_CONTAINER(obj); | ||
160 | + return &rc->reset_state; | ||
161 | +} | ||
162 | + | ||
163 | +static void resettable_container_child_foreach(Object *obj, | ||
164 | + ResettableChildCallback cb, | ||
165 | + void *opaque, ResetType type) | ||
166 | +{ | ||
167 | + ResettableContainer *rc = RESETTABLE_CONTAINER(obj); | ||
168 | + unsigned int len = rc->children->len; | ||
169 | + | ||
170 | + for (unsigned int i = 0; i < len; i++) { | ||
171 | + cb(g_ptr_array_index(rc->children, i), opaque, type); | ||
172 | + /* Detect callbacks trying to unregister themselves */ | ||
173 | + assert(len == rc->children->len); | ||
174 | + } | ||
175 | +} | ||
176 | + | ||
177 | +static void resettable_container_init(Object *obj) | ||
178 | +{ | ||
179 | + ResettableContainer *rc = RESETTABLE_CONTAINER(obj); | ||
180 | + | ||
181 | + rc->children = g_ptr_array_new(); | ||
182 | +} | ||
183 | + | ||
184 | +static void resettable_container_finalize(Object *obj) | ||
185 | +{ | ||
186 | +} | ||
187 | + | ||
188 | +static void resettable_container_class_init(ObjectClass *klass, void *data) | ||
189 | +{ | ||
190 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
191 | + | ||
192 | + rc->get_state = resettable_container_get_state; | ||
193 | + rc->child_foreach = resettable_container_child_foreach; | ||
194 | +} | ||
195 | diff --git a/hw/core/meson.build b/hw/core/meson.build | ||
196 | index XXXXXXX..XXXXXXX 100644 | ||
197 | --- a/hw/core/meson.build | ||
198 | +++ b/hw/core/meson.build | ||
199 | @@ -XXX,XX +XXX,XX @@ hwcore_ss.add(files( | ||
200 | 'qdev-properties.c', | ||
201 | 'qdev.c', | ||
202 | 'reset.c', | ||
203 | + 'resetcontainer.c', | ||
204 | 'resettable.c', | ||
205 | 'vmstate-if.c', | ||
206 | # irq.c needed for qdev GPIO handling: | ||
207 | -- | 128 | -- |
208 | 2.34.1 | 129 | 2.34.1 |
209 | 130 | ||
210 | 131 | diff view generated by jsdifflib |
1 | From: Sergey Kambalin <serg.oker@gmail.com> | 1 | We removed the old table-based decoder in favour of decodetree, but |
---|---|---|---|
2 | we left a couple of typedefs that are now unused; delete them. | ||
2 | 3 | ||
3 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Message-id: 20240226000259.2752893-42-sergey.kambalin@auriga.com | ||
6 | [PMM: list PCIE and GENET as 'missing' for now, until we land | ||
7 | the patches which add those devices] | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20250128135046.4108775-1-peter.maydell@linaro.org | ||
9 | --- | 7 | --- |
10 | docs/system/arm/raspi.rst | 12 +++++++----- | 8 | target/arm/tcg/translate-a64.c | 11 ----------- |
11 | 1 file changed, 7 insertions(+), 5 deletions(-) | 9 | 1 file changed, 11 deletions(-) |
12 | 10 | ||
13 | diff --git a/docs/system/arm/raspi.rst b/docs/system/arm/raspi.rst | 11 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c |
14 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/docs/system/arm/raspi.rst | 13 | --- a/target/arm/tcg/translate-a64.c |
16 | +++ b/docs/system/arm/raspi.rst | 14 | +++ b/target/arm/tcg/translate-a64.c |
17 | @@ -XXX,XX +XXX,XX @@ | 15 | @@ -XXX,XX +XXX,XX @@ static int scale_by_log2_tag_granule(DisasContext *s, int x) |
18 | -Raspberry Pi boards (``raspi0``, ``raspi1ap``, ``raspi2b``, ``raspi3ap``, ``raspi3b``) | 16 | #include "decode-sme-fa64.c.inc" |
19 | -====================================================================================== | 17 | #include "decode-a64.c.inc" |
20 | +Raspberry Pi boards (``raspi0``, ``raspi1ap``, ``raspi2b``, ``raspi3ap``, ``raspi3b``, ``raspi4b``) | 18 | |
21 | +=================================================================================================== | 19 | -/* Table based decoder typedefs - used when the relevant bits for decode |
22 | 20 | - * are too awkwardly scattered across the instruction (eg SIMD). | |
23 | 21 | - */ | |
24 | QEMU provides models of the following Raspberry Pi boards: | 22 | -typedef void AArch64DecodeFn(DisasContext *s, uint32_t insn); |
25 | @@ -XXX,XX +XXX,XX @@ QEMU provides models of the following Raspberry Pi boards: | ||
26 | Cortex-A53 (4 cores), 512 MiB of RAM | ||
27 | ``raspi3b`` | ||
28 | Cortex-A53 (4 cores), 1 GiB of RAM | ||
29 | - | 23 | - |
30 | +``raspi4b`` | 24 | -typedef struct AArch64DecodeTable { |
31 | + Cortex-A72 (4 cores), 2 GiB of RAM | 25 | - uint32_t pattern; |
32 | 26 | - uint32_t mask; | |
33 | Implemented devices | 27 | - AArch64DecodeFn *disas_fn; |
34 | ------------------- | 28 | -} AArch64DecodeTable; |
35 | |||
36 | - * ARM1176JZF-S, Cortex-A7 or Cortex-A53 CPU | ||
37 | + * ARM1176JZF-S, Cortex-A7, Cortex-A53 or Cortex-A72 CPU | ||
38 | * Interrupt controller | ||
39 | * DMA controller | ||
40 | * Clock and reset controller (CPRMAN) | ||
41 | @@ -XXX,XX +XXX,XX @@ Implemented devices | ||
42 | * VideoCore firmware (property) | ||
43 | * Peripheral SPI controller (SPI) | ||
44 | |||
45 | - | 29 | - |
46 | Missing devices | 30 | /* initialize TCG globals. */ |
47 | --------------- | 31 | void a64_translate_init(void) |
48 | 32 | { | |
49 | * Analog to Digital Converter (ADC) | ||
50 | * Pulse Width Modulation (PWM) | ||
51 | + * PCIE Root Port (raspi4b) | ||
52 | + * GENET Ethernet Controller (raspi4b) | ||
53 | -- | 33 | -- |
54 | 2.34.1 | 34 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | There is no point in checking do we have PCIe if first thing after check | 3 | In heterogeneous setup the first vCPU might not be |
4 | is adding PCIe card without checking. | 4 | the one expected, better pass it explicitly. |
5 | 5 | ||
6 | Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> | 6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
8 | Message-id: 20240215153311.186772-1-marcin.juszkiewicz@linaro.org | 8 | Message-id: 20250130112615.3219-2-philmd@linaro.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 10 | --- |
11 | hw/arm/sbsa-ref.c | 5 ++--- | 11 | include/hw/arm/boot.h | 4 +++- |
12 | 1 file changed, 2 insertions(+), 3 deletions(-) | 12 | hw/arm/boot.c | 11 ++++++----- |
13 | hw/arm/virt.c | 2 +- | ||
14 | 3 files changed, 10 insertions(+), 7 deletions(-) | ||
13 | 15 | ||
14 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c | 16 | diff --git a/include/hw/arm/boot.h b/include/hw/arm/boot.h |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/arm/sbsa-ref.c | 18 | --- a/include/hw/arm/boot.h |
17 | +++ b/hw/arm/sbsa-ref.c | 19 | +++ b/include/hw/arm/boot.h |
18 | @@ -XXX,XX +XXX,XX @@ static void create_pcie(SBSAMachineState *sms) | 20 | @@ -XXX,XX +XXX,XX @@ AddressSpace *arm_boot_address_space(ARMCPU *cpu, |
21 | * @binfo: struct describing the boot environment | ||
22 | * @addr_limit: upper limit of the available memory area at @addr | ||
23 | * @as: address space to load image to | ||
24 | + * @cpu: ARM CPU object | ||
25 | * | ||
26 | * Load a device tree supplied by the machine or by the user with the | ||
27 | * '-dtb' command line option, and put it at offset @addr in target | ||
28 | @@ -XXX,XX +XXX,XX @@ AddressSpace *arm_boot_address_space(ARMCPU *cpu, | ||
29 | * Note: Must not be called unless have_dtb(binfo) is true. | ||
30 | */ | ||
31 | int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, | ||
32 | - hwaddr addr_limit, AddressSpace *as, MachineState *ms); | ||
33 | + hwaddr addr_limit, AddressSpace *as, MachineState *ms, | ||
34 | + ARMCPU *cpu); | ||
35 | |||
36 | /* Write a secure board setup routine with a dummy handler for SMCs */ | ||
37 | void arm_write_secure_board_setup_dummy_smc(ARMCPU *cpu, | ||
38 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/hw/arm/boot.c | ||
41 | +++ b/hw/arm/boot.c | ||
42 | @@ -XXX,XX +XXX,XX @@ out: | ||
43 | return ret; | ||
44 | } | ||
45 | |||
46 | -static void fdt_add_psci_node(void *fdt) | ||
47 | +static void fdt_add_psci_node(void *fdt, ARMCPU *armcpu) | ||
48 | { | ||
49 | uint32_t cpu_suspend_fn; | ||
50 | uint32_t cpu_off_fn; | ||
51 | uint32_t cpu_on_fn; | ||
52 | uint32_t migrate_fn; | ||
53 | - ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(0)); | ||
54 | const char *psci_method; | ||
55 | int64_t psci_conduit; | ||
56 | int rc; | ||
57 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_psci_node(void *fdt) | ||
58 | } | ||
59 | |||
60 | int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, | ||
61 | - hwaddr addr_limit, AddressSpace *as, MachineState *ms) | ||
62 | + hwaddr addr_limit, AddressSpace *as, MachineState *ms, | ||
63 | + ARMCPU *cpu) | ||
64 | { | ||
65 | void *fdt = NULL; | ||
66 | int size, rc, n = 0; | ||
67 | @@ -XXX,XX +XXX,XX @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, | ||
68 | } | ||
19 | } | 69 | } |
20 | 70 | ||
21 | pci = PCI_HOST_BRIDGE(dev); | 71 | - fdt_add_psci_node(fdt); |
22 | - if (pci->bus) { | 72 | + fdt_add_psci_node(fdt, cpu); |
23 | - pci_init_nic_devices(pci->bus, mc->default_nic); | 73 | |
24 | - } | 74 | if (binfo->modify_dtb) { |
25 | + | 75 | binfo->modify_dtb(binfo, fdt); |
26 | + pci_init_nic_devices(pci->bus, mc->default_nic); | 76 | @@ -XXX,XX +XXX,XX @@ void arm_load_kernel(ARMCPU *cpu, MachineState *ms, struct arm_boot_info *info) |
27 | 77 | * decided whether to enable PSCI and set the psci-conduit CPU properties. | |
28 | pci_create_simple(pci->bus, -1, "bochs-display"); | 78 | */ |
79 | if (!info->skip_dtb_autoload && have_dtb(info)) { | ||
80 | - if (arm_load_dtb(info->dtb_start, info, info->dtb_limit, as, ms) < 0) { | ||
81 | + if (arm_load_dtb(info->dtb_start, info, info->dtb_limit, | ||
82 | + as, ms, cpu) < 0) { | ||
83 | exit(1); | ||
84 | } | ||
85 | } | ||
86 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
87 | index XXXXXXX..XXXXXXX 100644 | ||
88 | --- a/hw/arm/virt.c | ||
89 | +++ b/hw/arm/virt.c | ||
90 | @@ -XXX,XX +XXX,XX @@ void virt_machine_done(Notifier *notifier, void *data) | ||
91 | vms->memmap[VIRT_PLATFORM_BUS].size, | ||
92 | vms->irqmap[VIRT_PLATFORM_BUS]); | ||
93 | } | ||
94 | - if (arm_load_dtb(info->dtb_start, info, info->dtb_limit, as, ms) < 0) { | ||
95 | + if (arm_load_dtb(info->dtb_start, info, info->dtb_limit, as, ms, cpu) < 0) { | ||
96 | exit(1); | ||
97 | } | ||
29 | 98 | ||
30 | -- | 99 | -- |
31 | 2.34.1 | 100 | 2.34.1 |
32 | 101 | ||
33 | 102 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Ard Biesheuvel <ardb@kernel.org> | ||
2 | 1 | ||
3 | The Cortex-A53 r0p4 revision that QEMU emulates is affected by a CatA | ||
4 | erratum #843419 (i.e., the most severe), which requires workarounds in | ||
5 | the toolchain as well as the OS. | ||
6 | |||
7 | Since the emulation is obviously not affected in the same way, we can | ||
8 | indicate this via REVIDR bit #8, which on r0p4 has the meaning that no | ||
9 | workarounds for erratum #843419 are needed. | ||
10 | |||
11 | Signed-off-by: Ard Biesheuvel <ardb@kernel.org> | ||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20240215160202.2803452-1-ardb+git@google.com | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | target/arm/cpu64.c | 2 +- | ||
17 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
18 | |||
19 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/target/arm/cpu64.c | ||
22 | +++ b/target/arm/cpu64.c | ||
23 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a53_initfn(Object *obj) | ||
24 | set_feature(&cpu->env, ARM_FEATURE_PMU); | ||
25 | cpu->kvm_target = QEMU_KVM_ARM_TARGET_CORTEX_A53; | ||
26 | cpu->midr = 0x410fd034; | ||
27 | - cpu->revidr = 0x00000000; | ||
28 | + cpu->revidr = 0x00000100; | ||
29 | cpu->reset_fpsid = 0x41034070; | ||
30 | cpu->isar.mvfr0 = 0x10110222; | ||
31 | cpu->isar.mvfr1 = 0x12111111; | ||
32 | -- | ||
33 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Inès Varhol <ines.varhol@telecom-paris.fr> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Fixes: 52671f69f7a4 ("[PATCH v8 0/3] Add device STM32L4x5 EXTI") | 3 | The A9MPCore forward the IRQs from its internal GIC. |
4 | Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> | 4 | To make the code clearer, add the 'mpcore' and 'gic' |
5 | Message-id: 20240220184145.106107-2-ines.varhol@telecom-paris.fr | 5 | variables. |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
9 | Message-id: 20250130112615.3219-3-philmd@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 11 | --- |
10 | include/hw/arm/stm32l4x5_soc.h | 4 ++ | 12 | hw/arm/fsl-imx6.c | 52 +++++++++++++++++++---------------------------- |
11 | hw/arm/stm32l4x5_soc.c | 80 +++++++++++++++++++++++++++++----- | 13 | 1 file changed, 21 insertions(+), 31 deletions(-) |
12 | 2 files changed, 74 insertions(+), 10 deletions(-) | ||
13 | 14 | ||
14 | diff --git a/include/hw/arm/stm32l4x5_soc.h b/include/hw/arm/stm32l4x5_soc.h | 15 | diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/include/hw/arm/stm32l4x5_soc.h | 17 | --- a/hw/arm/fsl-imx6.c |
17 | +++ b/include/hw/arm/stm32l4x5_soc.h | 18 | +++ b/hw/arm/fsl-imx6.c |
18 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) |
19 | 20 | uint16_t i; | |
20 | #include "exec/memory.h" | 21 | qemu_irq irq; |
21 | #include "hw/arm/armv7m.h" | 22 | unsigned int smp_cpus = ms->smp.cpus; |
22 | +#include "hw/or-irq.h" | 23 | + DeviceState *mpcore = DEVICE(&s->a9mpcore); |
23 | #include "hw/misc/stm32l4x5_syscfg.h" | 24 | + DeviceState *gic; |
24 | #include "hw/misc/stm32l4x5_exti.h" | 25 | |
25 | #include "qom/object.h" | 26 | if (smp_cpus > FSL_IMX6_NUM_CPUS) { |
26 | @@ -XXX,XX +XXX,XX @@ | 27 | error_setg(errp, "%s: Only %d CPUs are supported (%d requested)", |
27 | #define TYPE_STM32L4X5XG_SOC "stm32l4x5xg-soc" | 28 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) |
28 | OBJECT_DECLARE_TYPE(Stm32l4x5SocState, Stm32l4x5SocClass, STM32L4X5_SOC) | 29 | } |
29 | 30 | } | |
30 | +#define NUM_EXTI_OR_GATES 4 | 31 | |
31 | + | 32 | - object_property_set_int(OBJECT(&s->a9mpcore), "num-cpu", smp_cpus, |
32 | struct Stm32l4x5SocState { | 33 | - &error_abort); |
33 | SysBusDevice parent_obj; | 34 | + object_property_set_int(OBJECT(mpcore), "num-cpu", smp_cpus, &error_abort); |
34 | 35 | ||
35 | ARMv7MState armv7m; | 36 | - object_property_set_int(OBJECT(&s->a9mpcore), "num-irq", |
36 | 37 | + object_property_set_int(OBJECT(mpcore), "num-irq", | |
37 | Stm32l4x5ExtiState exti; | 38 | FSL_IMX6_MAX_IRQ + GIC_INTERNAL, &error_abort); |
38 | + OrIRQState exti_or_gates[NUM_EXTI_OR_GATES]; | 39 | |
39 | Stm32l4x5SyscfgState syscfg; | 40 | - if (!sysbus_realize(SYS_BUS_DEVICE(&s->a9mpcore), errp)) { |
40 | 41 | + if (!sysbus_realize(SYS_BUS_DEVICE(mpcore), errp)) { | |
41 | MemoryRegion sram1; | ||
42 | diff --git a/hw/arm/stm32l4x5_soc.c b/hw/arm/stm32l4x5_soc.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/hw/arm/stm32l4x5_soc.c | ||
45 | +++ b/hw/arm/stm32l4x5_soc.c | ||
46 | @@ -XXX,XX +XXX,XX @@ | ||
47 | #include "qapi/error.h" | ||
48 | #include "exec/address-spaces.h" | ||
49 | #include "sysemu/sysemu.h" | ||
50 | +#include "hw/or-irq.h" | ||
51 | #include "hw/arm/stm32l4x5_soc.h" | ||
52 | #include "hw/qdev-clock.h" | ||
53 | #include "hw/misc/unimp.h" | ||
54 | @@ -XXX,XX +XXX,XX @@ | ||
55 | #define NUM_EXTI_IRQ 40 | ||
56 | /* Match exti line connections with their CPU IRQ number */ | ||
57 | /* See Vector Table (Reference Manual p.396) */ | ||
58 | +/* | ||
59 | + * Some IRQs are connected to the same CPU IRQ (denoted by -1) | ||
60 | + * and require an intermediary OR gate to function correctly. | ||
61 | + */ | ||
62 | static const int exti_irq[NUM_EXTI_IRQ] = { | ||
63 | 6, /* GPIO[0] */ | ||
64 | 7, /* GPIO[1] */ | ||
65 | 8, /* GPIO[2] */ | ||
66 | 9, /* GPIO[3] */ | ||
67 | 10, /* GPIO[4] */ | ||
68 | - 23, 23, 23, 23, 23, /* GPIO[5..9] */ | ||
69 | - 40, 40, 40, 40, 40, 40, /* GPIO[10..15] */ | ||
70 | - 1, /* PVD */ | ||
71 | + -1, -1, -1, -1, -1, /* GPIO[5..9] OR gate 23 */ | ||
72 | + -1, -1, -1, -1, -1, -1, /* GPIO[10..15] OR gate 40 */ | ||
73 | + -1, /* PVD OR gate 1 */ | ||
74 | 67, /* OTG_FS_WKUP, Direct */ | ||
75 | 41, /* RTC_ALARM */ | ||
76 | 2, /* RTC_TAMP_STAMP2/CSS_LSE */ | ||
77 | 3, /* RTC wakeup timer */ | ||
78 | - 63, /* COMP1 */ | ||
79 | - 63, /* COMP2 */ | ||
80 | + -1, -1, /* COMP[1..2] OR gate 63 */ | ||
81 | 31, /* I2C1 wakeup, Direct */ | ||
82 | 33, /* I2C2 wakeup, Direct */ | ||
83 | 72, /* I2C3 wakeup, Direct */ | ||
84 | @@ -XXX,XX +XXX,XX @@ static const int exti_irq[NUM_EXTI_IRQ] = { | ||
85 | 65, /* LPTIM1, Direct */ | ||
86 | 66, /* LPTIM2, Direct */ | ||
87 | 76, /* SWPMI1 wakeup, Direct */ | ||
88 | - 1, /* PVM1 wakeup */ | ||
89 | - 1, /* PVM2 wakeup */ | ||
90 | - 1, /* PVM3 wakeup */ | ||
91 | - 1, /* PVM4 wakeup */ | ||
92 | + -1, -1, -1, -1, /* PVM[1..4] OR gate 1 */ | ||
93 | 78 /* LCD wakeup, Direct */ | ||
94 | }; | ||
95 | |||
96 | +static const int exti_or_gates_out[NUM_EXTI_OR_GATES] = { | ||
97 | + 23, 40, 63, 1, | ||
98 | +}; | ||
99 | + | ||
100 | +static const int exti_or_gates_num_lines_in[NUM_EXTI_OR_GATES] = { | ||
101 | + 5, 6, 2, 5, | ||
102 | +}; | ||
103 | + | ||
104 | +/* 3 OR gates with consecutive inputs */ | ||
105 | +#define NUM_EXTI_SIMPLE_OR_GATES 3 | ||
106 | +static const int exti_or_gates_first_line_in[NUM_EXTI_SIMPLE_OR_GATES] = { | ||
107 | + 5, 10, 21, | ||
108 | +}; | ||
109 | + | ||
110 | +/* 1 OR gate with non-consecutive inputs */ | ||
111 | +#define EXTI_OR_GATE1_NUM_LINES_IN 5 | ||
112 | +static const int exti_or_gate1_lines_in[EXTI_OR_GATE1_NUM_LINES_IN] = { | ||
113 | + 16, 35, 36, 37, 38, | ||
114 | +}; | ||
115 | + | ||
116 | static void stm32l4x5_soc_initfn(Object *obj) | ||
117 | { | ||
118 | Stm32l4x5SocState *s = STM32L4X5_SOC(obj); | ||
119 | |||
120 | object_initialize_child(obj, "exti", &s->exti, TYPE_STM32L4X5_EXTI); | ||
121 | + for (unsigned i = 0; i < NUM_EXTI_OR_GATES; i++) { | ||
122 | + object_initialize_child(obj, "exti_or_gates[*]", &s->exti_or_gates[i], | ||
123 | + TYPE_OR_IRQ); | ||
124 | + } | ||
125 | object_initialize_child(obj, "syscfg", &s->syscfg, TYPE_STM32L4X5_SYSCFG); | ||
126 | |||
127 | s->sysclk = qdev_init_clock_in(DEVICE(s), "sysclk", NULL, NULL, 0); | ||
128 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp) | ||
129 | return; | 42 | return; |
130 | } | 43 | } |
131 | sysbus_mmio_map(busdev, 0, EXTI_ADDR); | 44 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->a9mpcore), 0, FSL_IMX6_A9MPCORE_ADDR); |
132 | + | 45 | + sysbus_mmio_map(SYS_BUS_DEVICE(mpcore), 0, FSL_IMX6_A9MPCORE_ADDR); |
133 | + /* IRQs with fan-in that require an OR gate */ | 46 | |
134 | + for (unsigned i = 0; i < NUM_EXTI_OR_GATES; i++) { | 47 | + gic = mpcore; |
135 | + if (!object_property_set_int(OBJECT(&s->exti_or_gates[i]), "num-lines", | 48 | for (i = 0; i < smp_cpus; i++) { |
136 | + exti_or_gates_num_lines_in[i], errp)) { | 49 | - sysbus_connect_irq(SYS_BUS_DEVICE(&s->a9mpcore), i, |
137 | + return; | 50 | + sysbus_connect_irq(SYS_BUS_DEVICE(gic), i, |
138 | + } | 51 | qdev_get_gpio_in(DEVICE(&s->cpu[i]), ARM_CPU_IRQ)); |
139 | + if (!qdev_realize(DEVICE(&s->exti_or_gates[i]), NULL, errp)) { | 52 | - sysbus_connect_irq(SYS_BUS_DEVICE(&s->a9mpcore), i + smp_cpus, |
140 | + return; | 53 | + sysbus_connect_irq(SYS_BUS_DEVICE(gic), i + smp_cpus, |
141 | + } | 54 | qdev_get_gpio_in(DEVICE(&s->cpu[i]), ARM_CPU_FIQ)); |
142 | + | ||
143 | + qdev_connect_gpio_out(DEVICE(&s->exti_or_gates[i]), 0, | ||
144 | + qdev_get_gpio_in(armv7m, exti_or_gates_out[i])); | ||
145 | + | ||
146 | + if (i < NUM_EXTI_SIMPLE_OR_GATES) { | ||
147 | + /* consecutive inputs for OR gates 23, 40, 63 */ | ||
148 | + for (unsigned j = 0; j < exti_or_gates_num_lines_in[i]; j++) { | ||
149 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->exti), | ||
150 | + exti_or_gates_first_line_in[i] + j, | ||
151 | + qdev_get_gpio_in(DEVICE(&s->exti_or_gates[i]), j)); | ||
152 | + } | ||
153 | + } else { | ||
154 | + /* non-consecutive inputs for OR gate 1 */ | ||
155 | + for (unsigned j = 0; j < EXTI_OR_GATE1_NUM_LINES_IN; j++) { | ||
156 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->exti), | ||
157 | + exti_or_gate1_lines_in[j], | ||
158 | + qdev_get_gpio_in(DEVICE(&s->exti_or_gates[i]), j)); | ||
159 | + } | ||
160 | + } | ||
161 | + } | ||
162 | + | ||
163 | + /* IRQs that don't require fan-in */ | ||
164 | for (unsigned i = 0; i < NUM_EXTI_IRQ; i++) { | ||
165 | - sysbus_connect_irq(busdev, i, qdev_get_gpio_in(armv7m, exti_irq[i])); | ||
166 | + if (exti_irq[i] != -1) { | ||
167 | + sysbus_connect_irq(busdev, i, | ||
168 | + qdev_get_gpio_in(armv7m, exti_irq[i])); | ||
169 | + } | ||
170 | } | 55 | } |
171 | 56 | ||
172 | for (unsigned i = 0; i < 16; i++) { | 57 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) |
58 | |||
59 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0, serial_table[i].addr); | ||
60 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart[i]), 0, | ||
61 | - qdev_get_gpio_in(DEVICE(&s->a9mpcore), | ||
62 | - serial_table[i].irq)); | ||
63 | + qdev_get_gpio_in(gic, serial_table[i].irq)); | ||
64 | } | ||
65 | |||
66 | s->gpt.ccm = IMX_CCM(&s->ccm); | ||
67 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) | ||
68 | |||
69 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpt), 0, FSL_IMX6_GPT_ADDR); | ||
70 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpt), 0, | ||
71 | - qdev_get_gpio_in(DEVICE(&s->a9mpcore), | ||
72 | - FSL_IMX6_GPT_IRQ)); | ||
73 | + qdev_get_gpio_in(gic, FSL_IMX6_GPT_IRQ)); | ||
74 | |||
75 | /* Initialize all EPIT timers */ | ||
76 | for (i = 0; i < FSL_IMX6_NUM_EPITS; i++) { | ||
77 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) | ||
78 | |||
79 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->epit[i]), 0, epit_table[i].addr); | ||
80 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->epit[i]), 0, | ||
81 | - qdev_get_gpio_in(DEVICE(&s->a9mpcore), | ||
82 | - epit_table[i].irq)); | ||
83 | + qdev_get_gpio_in(gic, epit_table[i].irq)); | ||
84 | } | ||
85 | |||
86 | /* Initialize all I2C */ | ||
87 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) | ||
88 | |||
89 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c[i]), 0, i2c_table[i].addr); | ||
90 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c[i]), 0, | ||
91 | - qdev_get_gpio_in(DEVICE(&s->a9mpcore), | ||
92 | - i2c_table[i].irq)); | ||
93 | + qdev_get_gpio_in(gic, i2c_table[i].irq)); | ||
94 | } | ||
95 | |||
96 | /* Initialize all GPIOs */ | ||
97 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) | ||
98 | |||
99 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0, gpio_table[i].addr); | ||
100 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 0, | ||
101 | - qdev_get_gpio_in(DEVICE(&s->a9mpcore), | ||
102 | - gpio_table[i].irq_low)); | ||
103 | + qdev_get_gpio_in(gic, gpio_table[i].irq_low)); | ||
104 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 1, | ||
105 | - qdev_get_gpio_in(DEVICE(&s->a9mpcore), | ||
106 | - gpio_table[i].irq_high)); | ||
107 | + qdev_get_gpio_in(gic, gpio_table[i].irq_high)); | ||
108 | } | ||
109 | |||
110 | /* Initialize all SDHC */ | ||
111 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) | ||
112 | } | ||
113 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->esdhc[i]), 0, esdhc_table[i].addr); | ||
114 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->esdhc[i]), 0, | ||
115 | - qdev_get_gpio_in(DEVICE(&s->a9mpcore), | ||
116 | - esdhc_table[i].irq)); | ||
117 | + qdev_get_gpio_in(gic, esdhc_table[i].irq)); | ||
118 | } | ||
119 | |||
120 | /* USB */ | ||
121 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) | ||
122 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->usb[i]), 0, | ||
123 | FSL_IMX6_USBOH3_USB_ADDR + i * 0x200); | ||
124 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->usb[i]), 0, | ||
125 | - qdev_get_gpio_in(DEVICE(&s->a9mpcore), | ||
126 | - FSL_IMX6_USBn_IRQ[i])); | ||
127 | + qdev_get_gpio_in(gic, FSL_IMX6_USBn_IRQ[i])); | ||
128 | } | ||
129 | |||
130 | /* Initialize all ECSPI */ | ||
131 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) | ||
132 | |||
133 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, spi_table[i].addr); | ||
134 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0, | ||
135 | - qdev_get_gpio_in(DEVICE(&s->a9mpcore), | ||
136 | - spi_table[i].irq)); | ||
137 | + qdev_get_gpio_in(gic, spi_table[i].irq)); | ||
138 | } | ||
139 | |||
140 | object_property_set_uint(OBJECT(&s->eth), "phy-num", s->phy_num, | ||
141 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) | ||
142 | } | ||
143 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->eth), 0, FSL_IMX6_ENET_ADDR); | ||
144 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->eth), 0, | ||
145 | - qdev_get_gpio_in(DEVICE(&s->a9mpcore), | ||
146 | - FSL_IMX6_ENET_MAC_IRQ)); | ||
147 | + qdev_get_gpio_in(gic, FSL_IMX6_ENET_MAC_IRQ)); | ||
148 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->eth), 1, | ||
149 | - qdev_get_gpio_in(DEVICE(&s->a9mpcore), | ||
150 | - FSL_IMX6_ENET_MAC_1588_IRQ)); | ||
151 | + qdev_get_gpio_in(gic, FSL_IMX6_ENET_MAC_1588_IRQ)); | ||
152 | |||
153 | /* | ||
154 | * SNVS | ||
155 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) | ||
156 | |||
157 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt[i]), 0, FSL_IMX6_WDOGn_ADDR[i]); | ||
158 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->wdt[i]), 0, | ||
159 | - qdev_get_gpio_in(DEVICE(&s->a9mpcore), | ||
160 | - FSL_IMX6_WDOGn_IRQ[i])); | ||
161 | + qdev_get_gpio_in(gic, FSL_IMX6_WDOGn_IRQ[i])); | ||
162 | } | ||
163 | |||
164 | /* | ||
173 | -- | 165 | -- |
174 | 2.34.1 | 166 | 2.34.1 |
175 | 167 | ||
176 | 168 | diff view generated by jsdifflib |
1 | From: Sergey Kambalin <serg.oker@gmail.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Pre setup for BCM2838 introduction | 3 | The A7MPCore forward the IRQs from its internal GIC. |
4 | To make the code clearer, add the 'mpcore' and 'gic' | ||
5 | variables. Rename 'd' variable as 'cpu'. | ||
4 | 6 | ||
5 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> | 7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | Message-id: 20240226000259.2752893-2-sergey.kambalin@auriga.com | 9 | Message-id: 20250130112615.3219-4-philmd@linaro.org |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 11 | --- |
10 | include/hw/arm/bcm2836.h | 26 +++++++++- | 12 | hw/arm/fsl-imx6ul.c | 64 +++++++++++++++++++-------------------------- |
11 | hw/arm/bcm2836.c | 103 ++++++++++++++++++++++----------------- | 13 | 1 file changed, 27 insertions(+), 37 deletions(-) |
12 | hw/arm/raspi.c | 2 +- | ||
13 | 3 files changed, 84 insertions(+), 47 deletions(-) | ||
14 | 14 | ||
15 | diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h | 15 | diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c |
16 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/include/hw/arm/bcm2836.h | 17 | --- a/hw/arm/fsl-imx6ul.c |
18 | +++ b/include/hw/arm/bcm2836.h | 18 | +++ b/hw/arm/fsl-imx6ul.c |
19 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) |
20 | #include "target/arm/cpu.h" | ||
21 | #include "qom/object.h" | ||
22 | |||
23 | +#define TYPE_BCM283X_BASE "bcm283x-base" | ||
24 | +OBJECT_DECLARE_TYPE(BCM283XBaseState, BCM283XBaseClass, BCM283X_BASE) | ||
25 | #define TYPE_BCM283X "bcm283x" | ||
26 | -OBJECT_DECLARE_TYPE(BCM283XState, BCM283XClass, BCM283X) | ||
27 | +OBJECT_DECLARE_SIMPLE_TYPE(BCM283XState, BCM283X) | ||
28 | |||
29 | #define BCM283X_NCPUS 4 | ||
30 | |||
31 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_TYPE(BCM283XState, BCM283XClass, BCM283X) | ||
32 | #define TYPE_BCM2836 "bcm2836" | ||
33 | #define TYPE_BCM2837 "bcm2837" | ||
34 | |||
35 | -struct BCM283XState { | ||
36 | +struct BCM283XBaseState { | ||
37 | /*< private >*/ | ||
38 | DeviceState parent_obj; | ||
39 | /*< public >*/ | ||
40 | @@ -XXX,XX +XXX,XX @@ struct BCM283XState { | ||
41 | ARMCPU core; | ||
42 | } cpu[BCM283X_NCPUS]; | ||
43 | BCM2836ControlState control; | ||
44 | +}; | ||
45 | + | ||
46 | +struct BCM283XBaseClass { | ||
47 | + /*< private >*/ | ||
48 | + DeviceClass parent_class; | ||
49 | + /*< public >*/ | ||
50 | + const char *name; | ||
51 | + const char *cpu_type; | ||
52 | + unsigned core_count; | ||
53 | + hwaddr peri_base; /* Peripheral base address seen by the CPU */ | ||
54 | + hwaddr ctrl_base; /* Interrupt controller and mailboxes etc. */ | ||
55 | + int clusterid; | ||
56 | +}; | ||
57 | + | ||
58 | +struct BCM283XState { | ||
59 | + /*< private >*/ | ||
60 | + BCM283XBaseState parent_obj; | ||
61 | + /*< public >*/ | ||
62 | BCM2835PeripheralState peripherals; | ||
63 | }; | ||
64 | |||
65 | +bool bcm283x_common_realize(DeviceState *dev, Error **errp); | ||
66 | + | ||
67 | #endif /* BCM2836_H */ | ||
68 | diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/hw/arm/bcm2836.c | ||
71 | +++ b/hw/arm/bcm2836.c | ||
72 | @@ -XXX,XX +XXX,XX @@ struct BCM283XClass { | ||
73 | }; | ||
74 | |||
75 | static Property bcm2836_enabled_cores_property = | ||
76 | - DEFINE_PROP_UINT32("enabled-cpus", BCM283XState, enabled_cpus, 0); | ||
77 | + DEFINE_PROP_UINT32("enabled-cpus", BCM283XBaseState, enabled_cpus, 0); | ||
78 | |||
79 | -static void bcm2836_init(Object *obj) | ||
80 | +static void bcm283x_base_init(Object *obj) | ||
81 | { | 20 | { |
82 | - BCM283XState *s = BCM283X(obj); | 21 | MachineState *ms = MACHINE(qdev_get_machine()); |
83 | - BCM283XClass *bc = BCM283X_GET_CLASS(obj); | 22 | FslIMX6ULState *s = FSL_IMX6UL(dev); |
84 | + BCM283XBaseState *s = BCM283X_BASE(obj); | 23 | + DeviceState *mpcore = DEVICE(&s->a7mpcore); |
85 | + BCM283XBaseClass *bc = BCM283X_BASE_GET_CLASS(obj); | 24 | int i; |
86 | int n; | 25 | char name[NAME_SIZE]; |
87 | 26 | - SysBusDevice *sbd; | |
88 | for (n = 0; n < bc->core_count; n++) { | 27 | - DeviceState *d; |
89 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_init(Object *obj) | 28 | + DeviceState *gic; |
90 | object_initialize_child(obj, "control", &s->control, | 29 | + SysBusDevice *gicsbd; |
91 | TYPE_BCM2836_CONTROL); | 30 | + DeviceState *cpu; |
31 | |||
32 | if (ms->smp.cpus > 1) { | ||
33 | error_setg(errp, "%s: Only a single CPU is supported (%d requested)", | ||
34 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
35 | /* | ||
36 | * A7MPCORE | ||
37 | */ | ||
38 | - object_property_set_int(OBJECT(&s->a7mpcore), "num-cpu", 1, &error_abort); | ||
39 | - object_property_set_int(OBJECT(&s->a7mpcore), "num-irq", | ||
40 | + object_property_set_int(OBJECT(mpcore), "num-cpu", 1, &error_abort); | ||
41 | + object_property_set_int(OBJECT(mpcore), "num-irq", | ||
42 | FSL_IMX6UL_MAX_IRQ + GIC_INTERNAL, &error_abort); | ||
43 | - sysbus_realize(SYS_BUS_DEVICE(&s->a7mpcore), &error_abort); | ||
44 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->a7mpcore), 0, FSL_IMX6UL_A7MPCORE_ADDR); | ||
45 | + sysbus_realize(SYS_BUS_DEVICE(mpcore), &error_abort); | ||
46 | + sysbus_mmio_map(SYS_BUS_DEVICE(mpcore), 0, FSL_IMX6UL_A7MPCORE_ADDR); | ||
47 | |||
48 | - sbd = SYS_BUS_DEVICE(&s->a7mpcore); | ||
49 | - d = DEVICE(&s->cpu); | ||
50 | - | ||
51 | - sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(d, ARM_CPU_IRQ)); | ||
52 | - sysbus_connect_irq(sbd, 1, qdev_get_gpio_in(d, ARM_CPU_FIQ)); | ||
53 | - sysbus_connect_irq(sbd, 2, qdev_get_gpio_in(d, ARM_CPU_VIRQ)); | ||
54 | - sysbus_connect_irq(sbd, 3, qdev_get_gpio_in(d, ARM_CPU_VFIQ)); | ||
55 | + gic = mpcore; | ||
56 | + gicsbd = SYS_BUS_DEVICE(gic); | ||
57 | + cpu = DEVICE(&s->cpu); | ||
58 | + sysbus_connect_irq(gicsbd, 0, qdev_get_gpio_in(cpu, ARM_CPU_IRQ)); | ||
59 | + sysbus_connect_irq(gicsbd, 1, qdev_get_gpio_in(cpu, ARM_CPU_FIQ)); | ||
60 | + sysbus_connect_irq(gicsbd, 2, qdev_get_gpio_in(cpu, ARM_CPU_VIRQ)); | ||
61 | + sysbus_connect_irq(gicsbd, 3, qdev_get_gpio_in(cpu, ARM_CPU_VFIQ)); | ||
62 | |||
63 | /* | ||
64 | * A7MPCORE DAP | ||
65 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
66 | FSL_IMX6UL_GPTn_ADDR[i]); | ||
67 | |||
68 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpt[i]), 0, | ||
69 | - qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
70 | - FSL_IMX6UL_GPTn_IRQ[i])); | ||
71 | + qdev_get_gpio_in(gic, FSL_IMX6UL_GPTn_IRQ[i])); | ||
92 | } | 72 | } |
93 | +} | 73 | |
94 | + | 74 | /* |
95 | +static void bcm283x_init(Object *obj) | 75 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) |
96 | +{ | 76 | FSL_IMX6UL_EPITn_ADDR[i]); |
97 | + BCM283XState *s = BCM283X(obj); | 77 | |
98 | 78 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->epit[i]), 0, | |
99 | object_initialize_child(obj, "peripherals", &s->peripherals, | 79 | - qdev_get_gpio_in(DEVICE(&s->a7mpcore), |
100 | TYPE_BCM2835_PERIPHERALS); | 80 | - FSL_IMX6UL_EPITn_IRQ[i])); |
101 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_init(Object *obj) | 81 | + qdev_get_gpio_in(gic, FSL_IMX6UL_EPITn_IRQ[i])); |
102 | "vcram-size"); | ||
103 | } | ||
104 | |||
105 | -static bool bcm283x_common_realize(DeviceState *dev, Error **errp) | ||
106 | +bool bcm283x_common_realize(DeviceState *dev, Error **errp) | ||
107 | { | ||
108 | BCM283XState *s = BCM283X(dev); | ||
109 | - BCM283XClass *bc = BCM283X_GET_CLASS(dev); | ||
110 | + BCM283XBaseState *s_base = BCM283X_BASE(dev); | ||
111 | + BCM283XBaseClass *bc = BCM283X_BASE_GET_CLASS(dev); | ||
112 | Object *obj; | ||
113 | |||
114 | /* common peripherals from bcm2835 */ | ||
115 | @@ -XXX,XX +XXX,XX @@ static bool bcm283x_common_realize(DeviceState *dev, Error **errp) | ||
116 | return false; | ||
117 | } | 82 | } |
118 | 83 | ||
119 | - object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(&s->peripherals), | 84 | /* |
120 | - "sd-bus"); | 85 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) |
121 | + object_property_add_alias(OBJECT(s_base), "sd-bus", | 86 | FSL_IMX6UL_GPIOn_ADDR[i]); |
122 | + OBJECT(&s->peripherals), "sd-bus"); | 87 | |
123 | 88 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 0, | |
124 | - sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->peripherals), 0, | 89 | - qdev_get_gpio_in(DEVICE(&s->a7mpcore), |
125 | - bc->peri_base, 1); | 90 | - FSL_IMX6UL_GPIOn_LOW_IRQ[i])); |
126 | + sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->peripherals), | 91 | + qdev_get_gpio_in(gic, FSL_IMX6UL_GPIOn_LOW_IRQ[i])); |
127 | + 0, bc->peri_base, 1); | 92 | |
128 | return true; | 93 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 1, |
129 | } | 94 | - qdev_get_gpio_in(DEVICE(&s->a7mpcore), |
130 | 95 | - FSL_IMX6UL_GPIOn_HIGH_IRQ[i])); | |
131 | static void bcm2835_realize(DeviceState *dev, Error **errp) | 96 | + qdev_get_gpio_in(gic, FSL_IMX6UL_GPIOn_HIGH_IRQ[i])); |
132 | { | ||
133 | BCM283XState *s = BCM283X(dev); | ||
134 | + BCM283XBaseState *s_base = BCM283X_BASE(dev); | ||
135 | |||
136 | if (!bcm283x_common_realize(dev, errp)) { | ||
137 | return; | ||
138 | } | 97 | } |
139 | 98 | ||
140 | - if (!qdev_realize(DEVICE(&s->cpu[0].core), NULL, errp)) { | 99 | /* |
141 | + if (!qdev_realize(DEVICE(&s_base->cpu[0].core), NULL, errp)) { | 100 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) |
142 | return; | 101 | FSL_IMX6UL_SPIn_ADDR[i]); |
102 | |||
103 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0, | ||
104 | - qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
105 | - FSL_IMX6UL_SPIn_IRQ[i])); | ||
106 | + qdev_get_gpio_in(gic, FSL_IMX6UL_SPIn_IRQ[i])); | ||
143 | } | 107 | } |
144 | 108 | ||
145 | /* Connect irq/fiq outputs from the interrupt controller. */ | 109 | /* |
146 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 0, | 110 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) |
147 | - qdev_get_gpio_in(DEVICE(&s->cpu[0].core), ARM_CPU_IRQ)); | 111 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c[i]), 0, FSL_IMX6UL_I2Cn_ADDR[i]); |
148 | + qdev_get_gpio_in(DEVICE(&s_base->cpu[0].core), ARM_CPU_IRQ)); | 112 | |
149 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 1, | 113 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c[i]), 0, |
150 | - qdev_get_gpio_in(DEVICE(&s->cpu[0].core), ARM_CPU_FIQ)); | 114 | - qdev_get_gpio_in(DEVICE(&s->a7mpcore), |
151 | + qdev_get_gpio_in(DEVICE(&s_base->cpu[0].core), ARM_CPU_FIQ)); | 115 | - FSL_IMX6UL_I2Cn_IRQ[i])); |
152 | } | 116 | + qdev_get_gpio_in(gic, FSL_IMX6UL_I2Cn_IRQ[i])); |
153 | |||
154 | static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
155 | { | ||
156 | - BCM283XState *s = BCM283X(dev); | ||
157 | - BCM283XClass *bc = BCM283X_GET_CLASS(dev); | ||
158 | int n; | ||
159 | + BCM283XState *s = BCM283X(dev); | ||
160 | + BCM283XBaseState *s_base = BCM283X_BASE(dev); | ||
161 | + BCM283XBaseClass *bc = BCM283X_BASE_GET_CLASS(dev); | ||
162 | |||
163 | if (!bcm283x_common_realize(dev, errp)) { | ||
164 | return; | ||
165 | } | 117 | } |
166 | 118 | ||
167 | /* bcm2836 interrupt controller (and mailboxes, etc.) */ | 119 | /* |
168 | - if (!sysbus_realize(SYS_BUS_DEVICE(&s->control), errp)) { | 120 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) |
169 | + if (!sysbus_realize(SYS_BUS_DEVICE(&s_base->control), errp)) { | 121 | FSL_IMX6UL_UARTn_ADDR[i]); |
170 | return; | 122 | |
123 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart[i]), 0, | ||
124 | - qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
125 | - FSL_IMX6UL_UARTn_IRQ[i])); | ||
126 | + qdev_get_gpio_in(gic, FSL_IMX6UL_UARTn_IRQ[i])); | ||
171 | } | 127 | } |
172 | 128 | ||
173 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->control), 0, bc->ctrl_base); | 129 | /* |
174 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s_base->control), 0, bc->ctrl_base); | 130 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) |
175 | 131 | FSL_IMX6UL_ENETn_ADDR[i]); | |
176 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 0, | 132 | |
177 | - qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-irq", 0)); | 133 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->eth[i]), 0, |
178 | + qdev_get_gpio_in_named(DEVICE(&s_base->control), "gpu-irq", 0)); | 134 | - qdev_get_gpio_in(DEVICE(&s->a7mpcore), |
179 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 1, | 135 | - FSL_IMX6UL_ENETn_IRQ[i])); |
180 | - qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-fiq", 0)); | 136 | + qdev_get_gpio_in(gic, FSL_IMX6UL_ENETn_IRQ[i])); |
181 | + qdev_get_gpio_in_named(DEVICE(&s_base->control), "gpu-fiq", 0)); | 137 | |
182 | 138 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->eth[i]), 1, | |
183 | for (n = 0; n < BCM283X_NCPUS; n++) { | 139 | - qdev_get_gpio_in(DEVICE(&s->a7mpcore), |
184 | - object_property_set_int(OBJECT(&s->cpu[n].core), "mp-affinity", | 140 | - FSL_IMX6UL_ENETn_TIMER_IRQ[i])); |
185 | + object_property_set_int(OBJECT(&s_base->cpu[n].core), "mp-affinity", | 141 | + qdev_get_gpio_in(gic, FSL_IMX6UL_ENETn_TIMER_IRQ[i])); |
186 | (bc->clusterid << 8) | n, &error_abort); | ||
187 | |||
188 | /* set periphbase/CBAR value for CPU-local registers */ | ||
189 | - object_property_set_int(OBJECT(&s->cpu[n].core), "reset-cbar", | ||
190 | + object_property_set_int(OBJECT(&s_base->cpu[n].core), "reset-cbar", | ||
191 | bc->peri_base, &error_abort); | ||
192 | |||
193 | /* start powered off if not enabled */ | ||
194 | - object_property_set_bool(OBJECT(&s->cpu[n].core), "start-powered-off", | ||
195 | - n >= s->enabled_cpus, &error_abort); | ||
196 | + object_property_set_bool(OBJECT(&s_base->cpu[n].core), | ||
197 | + "start-powered-off", | ||
198 | + n >= s_base->enabled_cpus, &error_abort); | ||
199 | |||
200 | - if (!qdev_realize(DEVICE(&s->cpu[n].core), NULL, errp)) { | ||
201 | + if (!qdev_realize(DEVICE(&s_base->cpu[n].core), NULL, errp)) { | ||
202 | return; | ||
203 | } | ||
204 | |||
205 | /* Connect irq/fiq outputs from the interrupt controller. */ | ||
206 | - qdev_connect_gpio_out_named(DEVICE(&s->control), "irq", n, | ||
207 | - qdev_get_gpio_in(DEVICE(&s->cpu[n].core), ARM_CPU_IRQ)); | ||
208 | - qdev_connect_gpio_out_named(DEVICE(&s->control), "fiq", n, | ||
209 | - qdev_get_gpio_in(DEVICE(&s->cpu[n].core), ARM_CPU_FIQ)); | ||
210 | + qdev_connect_gpio_out_named(DEVICE(&s_base->control), "irq", n, | ||
211 | + qdev_get_gpio_in(DEVICE(&s_base->cpu[n].core), ARM_CPU_IRQ)); | ||
212 | + qdev_connect_gpio_out_named(DEVICE(&s_base->control), "fiq", n, | ||
213 | + qdev_get_gpio_in(DEVICE(&s_base->cpu[n].core), ARM_CPU_FIQ)); | ||
214 | |||
215 | /* Connect timers from the CPU to the interrupt controller */ | ||
216 | - qdev_connect_gpio_out(DEVICE(&s->cpu[n].core), GTIMER_PHYS, | ||
217 | - qdev_get_gpio_in_named(DEVICE(&s->control), "cntpnsirq", n)); | ||
218 | - qdev_connect_gpio_out(DEVICE(&s->cpu[n].core), GTIMER_VIRT, | ||
219 | - qdev_get_gpio_in_named(DEVICE(&s->control), "cntvirq", n)); | ||
220 | - qdev_connect_gpio_out(DEVICE(&s->cpu[n].core), GTIMER_HYP, | ||
221 | - qdev_get_gpio_in_named(DEVICE(&s->control), "cnthpirq", n)); | ||
222 | - qdev_connect_gpio_out(DEVICE(&s->cpu[n].core), GTIMER_SEC, | ||
223 | - qdev_get_gpio_in_named(DEVICE(&s->control), "cntpsirq", n)); | ||
224 | + qdev_connect_gpio_out(DEVICE(&s_base->cpu[n].core), GTIMER_PHYS, | ||
225 | + qdev_get_gpio_in_named(DEVICE(&s_base->control), "cntpnsirq", n)); | ||
226 | + qdev_connect_gpio_out(DEVICE(&s_base->cpu[n].core), GTIMER_VIRT, | ||
227 | + qdev_get_gpio_in_named(DEVICE(&s_base->control), "cntvirq", n)); | ||
228 | + qdev_connect_gpio_out(DEVICE(&s_base->cpu[n].core), GTIMER_HYP, | ||
229 | + qdev_get_gpio_in_named(DEVICE(&s_base->control), "cnthpirq", n)); | ||
230 | + qdev_connect_gpio_out(DEVICE(&s_base->cpu[n].core), GTIMER_SEC, | ||
231 | + qdev_get_gpio_in_named(DEVICE(&s_base->control), "cntpsirq", n)); | ||
232 | } | 142 | } |
233 | } | 143 | |
234 | 144 | /* | |
235 | -static void bcm283x_class_init(ObjectClass *oc, void *data) | 145 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) |
236 | +static void bcm283x_base_class_init(ObjectClass *oc, void *data) | 146 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->usb[i]), 0, |
237 | { | 147 | FSL_IMX6UL_USB02_USBn_ADDR[i]); |
238 | DeviceClass *dc = DEVICE_CLASS(oc); | 148 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->usb[i]), 0, |
239 | 149 | - qdev_get_gpio_in(DEVICE(&s->a7mpcore), | |
240 | @@ -XXX,XX +XXX,XX @@ static void bcm283x_class_init(ObjectClass *oc, void *data) | 150 | - FSL_IMX6UL_USBn_IRQ[i])); |
241 | static void bcm2835_class_init(ObjectClass *oc, void *data) | 151 | + qdev_get_gpio_in(gic, FSL_IMX6UL_USBn_IRQ[i])); |
242 | { | ||
243 | DeviceClass *dc = DEVICE_CLASS(oc); | ||
244 | - BCM283XClass *bc = BCM283X_CLASS(oc); | ||
245 | + BCM283XBaseClass *bc = BCM283X_BASE_CLASS(oc); | ||
246 | |||
247 | bc->cpu_type = ARM_CPU_TYPE_NAME("arm1176"); | ||
248 | bc->core_count = 1; | ||
249 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_class_init(ObjectClass *oc, void *data) | ||
250 | static void bcm2836_class_init(ObjectClass *oc, void *data) | ||
251 | { | ||
252 | DeviceClass *dc = DEVICE_CLASS(oc); | ||
253 | - BCM283XClass *bc = BCM283X_CLASS(oc); | ||
254 | + BCM283XBaseClass *bc = BCM283X_BASE_CLASS(oc); | ||
255 | |||
256 | bc->cpu_type = ARM_CPU_TYPE_NAME("cortex-a7"); | ||
257 | bc->core_count = BCM283X_NCPUS; | ||
258 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_class_init(ObjectClass *oc, void *data) | ||
259 | static void bcm2837_class_init(ObjectClass *oc, void *data) | ||
260 | { | ||
261 | DeviceClass *dc = DEVICE_CLASS(oc); | ||
262 | - BCM283XClass *bc = BCM283X_CLASS(oc); | ||
263 | + BCM283XBaseClass *bc = BCM283X_BASE_CLASS(oc); | ||
264 | |||
265 | bc->cpu_type = ARM_CPU_TYPE_NAME("cortex-a53"); | ||
266 | bc->core_count = BCM283X_NCPUS; | ||
267 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo bcm283x_types[] = { | ||
268 | #endif | ||
269 | }, { | ||
270 | .name = TYPE_BCM283X, | ||
271 | - .parent = TYPE_DEVICE, | ||
272 | + .parent = TYPE_BCM283X_BASE, | ||
273 | .instance_size = sizeof(BCM283XState), | ||
274 | - .instance_init = bcm2836_init, | ||
275 | - .class_size = sizeof(BCM283XClass), | ||
276 | - .class_init = bcm283x_class_init, | ||
277 | + .instance_init = bcm283x_init, | ||
278 | + .abstract = true, | ||
279 | + }, { | ||
280 | + .name = TYPE_BCM283X_BASE, | ||
281 | + .parent = TYPE_DEVICE, | ||
282 | + .instance_size = sizeof(BCM283XBaseState), | ||
283 | + .instance_init = bcm283x_base_init, | ||
284 | + .class_size = sizeof(BCM283XBaseClass), | ||
285 | + .class_init = bcm283x_base_class_init, | ||
286 | .abstract = true, | ||
287 | } | 152 | } |
288 | }; | 153 | |
289 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | 154 | /* |
290 | index XXXXXXX..XXXXXXX 100644 | 155 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) |
291 | --- a/hw/arm/raspi.c | 156 | FSL_IMX6UL_USDHCn_ADDR[i]); |
292 | +++ b/hw/arm/raspi.c | 157 | |
293 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, RaspiProcessorId processor_id, | 158 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->usdhc[i]), 0, |
294 | s->binfo.firmware_loaded = true; | 159 | - qdev_get_gpio_in(DEVICE(&s->a7mpcore), |
160 | - FSL_IMX6UL_USDHCn_IRQ[i])); | ||
161 | + qdev_get_gpio_in(gic, FSL_IMX6UL_USDHCn_IRQ[i])); | ||
295 | } | 162 | } |
296 | 163 | ||
297 | - arm_load_kernel(&s->soc.cpu[0].core, machine, &s->binfo); | 164 | /* |
298 | + arm_load_kernel(&s->soc.parent_obj.cpu[0].core, machine, &s->binfo); | 165 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) |
299 | } | 166 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt[i]), 0, |
300 | 167 | FSL_IMX6UL_WDOGn_ADDR[i]); | |
301 | static void raspi_machine_init(MachineState *machine) | 168 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->wdt[i]), 0, |
169 | - qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
170 | - FSL_IMX6UL_WDOGn_IRQ[i])); | ||
171 | + qdev_get_gpio_in(gic, FSL_IMX6UL_WDOGn_IRQ[i])); | ||
172 | } | ||
173 | |||
174 | /* | ||
302 | -- | 175 | -- |
303 | 2.34.1 | 176 | 2.34.1 |
177 | |||
178 | diff view generated by jsdifflib |
1 | From: Sergey Kambalin <serg.oker@gmail.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Pre-setup for BCM2838 introduction | 3 | The A7MPCore forward the IRQs from its internal GIC. |
4 | To make the code clearer, add the 'mpcore' and 'gic' | ||
5 | variables. | ||
4 | 6 | ||
5 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> | 7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | Message-id: 20240226000259.2752893-3-sergey.kambalin@auriga.com | 9 | Message-id: 20250130112615.3219-5-philmd@linaro.org |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 11 | --- |
10 | include/hw/arm/bcm2835_peripherals.h | 29 +++- | 12 | hw/arm/fsl-imx7.c | 52 +++++++++++++++++++++-------------------------- |
11 | include/hw/arm/bcm2836.h | 3 +- | 13 | 1 file changed, 23 insertions(+), 29 deletions(-) |
12 | hw/arm/bcm2835_peripherals.c | 198 +++++++++++++++------------ | ||
13 | hw/arm/bcm2836.c | 24 ++-- | ||
14 | 4 files changed, 154 insertions(+), 100 deletions(-) | ||
15 | 14 | ||
16 | diff --git a/include/hw/arm/bcm2835_peripherals.h b/include/hw/arm/bcm2835_peripherals.h | 15 | diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c |
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/include/hw/arm/bcm2835_peripherals.h | 17 | --- a/hw/arm/fsl-imx7.c |
19 | +++ b/include/hw/arm/bcm2835_peripherals.h | 18 | +++ b/hw/arm/fsl-imx7.c |
20 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) |
21 | #include "hw/misc/unimp.h" | ||
22 | #include "qom/object.h" | ||
23 | |||
24 | +#define TYPE_BCM_SOC_PERIPHERALS_BASE "bcm-soc-peripherals-base" | ||
25 | +OBJECT_DECLARE_TYPE(BCMSocPeripheralBaseState, BCMSocPeripheralBaseClass, | ||
26 | + BCM_SOC_PERIPHERALS_BASE) | ||
27 | #define TYPE_BCM2835_PERIPHERALS "bcm2835-peripherals" | ||
28 | OBJECT_DECLARE_SIMPLE_TYPE(BCM2835PeripheralState, BCM2835_PERIPHERALS) | ||
29 | |||
30 | -struct BCM2835PeripheralState { | ||
31 | +struct BCMSocPeripheralBaseState { | ||
32 | /*< private >*/ | ||
33 | SysBusDevice parent_obj; | ||
34 | /*< public >*/ | ||
35 | @@ -XXX,XX +XXX,XX @@ struct BCM2835PeripheralState { | ||
36 | OrIRQState orgated_dma_irq; | ||
37 | BCM2835ICState ic; | ||
38 | BCM2835PropertyState property; | ||
39 | - BCM2835RngState rng; | ||
40 | BCM2835MboxState mboxes; | ||
41 | SDHCIState sdhci; | ||
42 | BCM2835SDHostState sdhost; | ||
43 | - BCM2835GpioState gpio; | ||
44 | - Bcm2835ThermalState thermal; | ||
45 | UnimplementedDeviceState i2s; | ||
46 | BCM2835SPIState spi[1]; | ||
47 | UnimplementedDeviceState i2c[3]; | ||
48 | @@ -XXX,XX +XXX,XX @@ struct BCM2835PeripheralState { | ||
49 | UnimplementedDeviceState sdramc; | ||
50 | }; | ||
51 | |||
52 | +struct BCMSocPeripheralBaseClass { | ||
53 | + /*< private >*/ | ||
54 | + SysBusDeviceClass parent_class; | ||
55 | + /*< public >*/ | ||
56 | + uint64_t peri_size; /* Peripheral range size */ | ||
57 | +}; | ||
58 | + | ||
59 | +struct BCM2835PeripheralState { | ||
60 | + /*< private >*/ | ||
61 | + BCMSocPeripheralBaseState parent_obj; | ||
62 | + /*< public >*/ | ||
63 | + BCM2835RngState rng; | ||
64 | + Bcm2835ThermalState thermal; | ||
65 | + BCM2835GpioState gpio; | ||
66 | +}; | ||
67 | + | ||
68 | +void create_unimp(BCMSocPeripheralBaseState *ps, | ||
69 | + UnimplementedDeviceState *uds, | ||
70 | + const char *name, hwaddr ofs, hwaddr size); | ||
71 | +void bcm_soc_peripherals_common_realize(DeviceState *dev, Error **errp); | ||
72 | + | ||
73 | #endif /* BCM2835_PERIPHERALS_H */ | ||
74 | diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h | ||
75 | index XXXXXXX..XXXXXXX 100644 | ||
76 | --- a/include/hw/arm/bcm2836.h | ||
77 | +++ b/include/hw/arm/bcm2836.h | ||
78 | @@ -XXX,XX +XXX,XX @@ struct BCM283XState { | ||
79 | BCM2835PeripheralState peripherals; | ||
80 | }; | ||
81 | |||
82 | -bool bcm283x_common_realize(DeviceState *dev, Error **errp); | ||
83 | +bool bcm283x_common_realize(DeviceState *dev, BCMSocPeripheralBaseState *ps, | ||
84 | + Error **errp); | ||
85 | |||
86 | #endif /* BCM2836_H */ | ||
87 | diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c | ||
88 | index XXXXXXX..XXXXXXX 100644 | ||
89 | --- a/hw/arm/bcm2835_peripherals.c | ||
90 | +++ b/hw/arm/bcm2835_peripherals.c | ||
91 | @@ -XXX,XX +XXX,XX @@ | ||
92 | #define SEPARATE_DMA_IRQ_MAX 10 | ||
93 | #define ORGATED_DMA_IRQ_COUNT 4 | ||
94 | |||
95 | -static void create_unimp(BCM2835PeripheralState *ps, | ||
96 | - UnimplementedDeviceState *uds, | ||
97 | - const char *name, hwaddr ofs, hwaddr size) | ||
98 | +void create_unimp(BCMSocPeripheralBaseState *ps, | ||
99 | + UnimplementedDeviceState *uds, | ||
100 | + const char *name, hwaddr ofs, hwaddr size) | ||
101 | { | 20 | { |
102 | object_initialize_child(OBJECT(ps), name, uds, TYPE_UNIMPLEMENTED_DEVICE); | 21 | MachineState *ms = MACHINE(qdev_get_machine()); |
103 | qdev_prop_set_string(DEVICE(uds), "name", name); | 22 | FslIMX7State *s = FSL_IMX7(dev); |
104 | @@ -XXX,XX +XXX,XX @@ static void create_unimp(BCM2835PeripheralState *ps, | 23 | - Object *o; |
105 | static void bcm2835_peripherals_init(Object *obj) | 24 | + DeviceState *mpcore = DEVICE(&s->a7mpcore); |
106 | { | 25 | + DeviceState *gic; |
107 | BCM2835PeripheralState *s = BCM2835_PERIPHERALS(obj); | 26 | int i; |
108 | + BCMSocPeripheralBaseState *s_base = BCM_SOC_PERIPHERALS_BASE(obj); | 27 | qemu_irq irq; |
109 | + | 28 | char name[NAME_SIZE]; |
110 | + /* Random Number Generator */ | 29 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) |
111 | + object_initialize_child(obj, "rng", &s->rng, TYPE_BCM2835_RNG); | 30 | * CPUs |
112 | + | 31 | */ |
113 | + /* Thermal */ | 32 | for (i = 0; i < smp_cpus; i++) { |
114 | + object_initialize_child(obj, "thermal", &s->thermal, TYPE_BCM2835_THERMAL); | 33 | - o = OBJECT(&s->cpu[i]); |
115 | + | 34 | + Object *o = OBJECT(&s->cpu[i]); |
116 | + /* GPIO */ | 35 | |
117 | + object_initialize_child(obj, "gpio", &s->gpio, TYPE_BCM2835_GPIO); | 36 | /* On uniprocessor, the CBAR is set to 0 */ |
118 | + | 37 | if (smp_cpus > 1) { |
119 | + object_property_add_const_link(OBJECT(&s->gpio), "sdbus-sdhci", | 38 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) |
120 | + OBJECT(&s_base->sdhci.sdbus)); | 39 | /* |
121 | + object_property_add_const_link(OBJECT(&s->gpio), "sdbus-sdhost", | 40 | * A7MPCORE |
122 | + OBJECT(&s_base->sdhost.sdbus)); | 41 | */ |
123 | + | 42 | - object_property_set_int(OBJECT(&s->a7mpcore), "num-cpu", smp_cpus, |
124 | + /* Gated DMA interrupts */ | 43 | - &error_abort); |
125 | + object_initialize_child(obj, "orgated-dma-irq", | 44 | - object_property_set_int(OBJECT(&s->a7mpcore), "num-irq", |
126 | + &s_base->orgated_dma_irq, TYPE_OR_IRQ); | 45 | + object_property_set_int(OBJECT(mpcore), "num-cpu", smp_cpus, &error_abort); |
127 | + object_property_set_int(OBJECT(&s_base->orgated_dma_irq), "num-lines", | 46 | + object_property_set_int(OBJECT(mpcore), "num-irq", |
128 | + ORGATED_DMA_IRQ_COUNT, &error_abort); | 47 | FSL_IMX7_MAX_IRQ + GIC_INTERNAL, &error_abort); |
129 | +} | 48 | + sysbus_realize(SYS_BUS_DEVICE(mpcore), &error_abort); |
130 | + | 49 | + sysbus_mmio_map(SYS_BUS_DEVICE(mpcore), 0, FSL_IMX7_A7MPCORE_ADDR); |
131 | +static void raspi_peripherals_base_init(Object *obj) | 50 | |
132 | +{ | 51 | - sysbus_realize(SYS_BUS_DEVICE(&s->a7mpcore), &error_abort); |
133 | + BCMSocPeripheralBaseState *s = BCM_SOC_PERIPHERALS_BASE(obj); | 52 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->a7mpcore), 0, FSL_IMX7_A7MPCORE_ADDR); |
134 | + BCMSocPeripheralBaseClass *bc = BCM_SOC_PERIPHERALS_BASE_GET_CLASS(obj); | ||
135 | |||
136 | /* Memory region for peripheral devices, which we export to our parent */ | ||
137 | - memory_region_init(&s->peri_mr, obj,"bcm2835-peripherals", 0x1000000); | ||
138 | + memory_region_init(&s->peri_mr, obj, "bcm2835-peripherals", bc->peri_size); | ||
139 | sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->peri_mr); | ||
140 | |||
141 | /* Internal memory region for peripheral bus addresses (not exported) */ | ||
142 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_init(Object *obj) | ||
143 | object_property_add_const_link(OBJECT(&s->property), "dma-mr", | ||
144 | OBJECT(&s->gpu_bus_mr)); | ||
145 | |||
146 | - /* Random Number Generator */ | ||
147 | - object_initialize_child(obj, "rng", &s->rng, TYPE_BCM2835_RNG); | ||
148 | - | 53 | - |
149 | /* Extended Mass Media Controller */ | 54 | + gic = mpcore; |
150 | object_initialize_child(obj, "sdhci", &s->sdhci, TYPE_SYSBUS_SDHCI); | 55 | for (i = 0; i < smp_cpus; i++) { |
151 | 56 | - SysBusDevice *sbd = SYS_BUS_DEVICE(&s->a7mpcore); | |
152 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_init(Object *obj) | 57 | + SysBusDevice *sbd = SYS_BUS_DEVICE(gic); |
153 | /* DMA Channels */ | 58 | DeviceState *d = DEVICE(qemu_get_cpu(i)); |
154 | object_initialize_child(obj, "dma", &s->dma, TYPE_BCM2835_DMA); | 59 | |
155 | 60 | irq = qdev_get_gpio_in(d, ARM_CPU_IRQ); | |
156 | - object_initialize_child(obj, "orgated-dma-irq", | 61 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) |
157 | - &s->orgated_dma_irq, TYPE_OR_IRQ); | 62 | sysbus_realize(SYS_BUS_DEVICE(&s->gpt[i]), &error_abort); |
158 | - object_property_set_int(OBJECT(&s->orgated_dma_irq), "num-lines", | 63 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpt[i]), 0, FSL_IMX7_GPTn_ADDR[i]); |
159 | - ORGATED_DMA_IRQ_COUNT, &error_abort); | 64 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpt[i]), 0, |
160 | - | 65 | - qdev_get_gpio_in(DEVICE(&s->a7mpcore), |
161 | object_property_add_const_link(OBJECT(&s->dma), "dma-mr", | 66 | - FSL_IMX7_GPTn_IRQ[i])); |
162 | OBJECT(&s->gpu_bus_mr)); | 67 | + qdev_get_gpio_in(gic, FSL_IMX7_GPTn_IRQ[i])); |
163 | |||
164 | - /* Thermal */ | ||
165 | - object_initialize_child(obj, "thermal", &s->thermal, TYPE_BCM2835_THERMAL); | ||
166 | - | ||
167 | - /* GPIO */ | ||
168 | - object_initialize_child(obj, "gpio", &s->gpio, TYPE_BCM2835_GPIO); | ||
169 | - | ||
170 | - object_property_add_const_link(OBJECT(&s->gpio), "sdbus-sdhci", | ||
171 | - OBJECT(&s->sdhci.sdbus)); | ||
172 | - object_property_add_const_link(OBJECT(&s->gpio), "sdbus-sdhost", | ||
173 | - OBJECT(&s->sdhost.sdbus)); | ||
174 | - | ||
175 | /* Mphi */ | ||
176 | object_initialize_child(obj, "mphi", &s->mphi, TYPE_BCM2835_MPHI); | ||
177 | |||
178 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_init(Object *obj) | ||
179 | |||
180 | static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | ||
181 | { | ||
182 | + MemoryRegion *mphi_mr; | ||
183 | BCM2835PeripheralState *s = BCM2835_PERIPHERALS(dev); | ||
184 | + BCMSocPeripheralBaseState *s_base = BCM_SOC_PERIPHERALS_BASE(dev); | ||
185 | + int n; | ||
186 | + | ||
187 | + bcm_soc_peripherals_common_realize(dev, errp); | ||
188 | + | ||
189 | + /* Extended Mass Media Controller */ | ||
190 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s_base->sdhci), 0, | ||
191 | + qdev_get_gpio_in_named(DEVICE(&s_base->ic), BCM2835_IC_GPU_IRQ, | ||
192 | + INTERRUPT_ARASANSDIO)); | ||
193 | + | ||
194 | + /* Connect DMA 0-12 to the interrupt controller */ | ||
195 | + for (n = 0; n <= SEPARATE_DMA_IRQ_MAX; n++) { | ||
196 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s_base->dma), n, | ||
197 | + qdev_get_gpio_in_named(DEVICE(&s_base->ic), | ||
198 | + BCM2835_IC_GPU_IRQ, | ||
199 | + INTERRUPT_DMA0 + n)); | ||
200 | + } | ||
201 | + | ||
202 | + if (!qdev_realize(DEVICE(&s_base->orgated_dma_irq), NULL, errp)) { | ||
203 | + return; | ||
204 | + } | ||
205 | + for (n = 0; n < ORGATED_DMA_IRQ_COUNT; n++) { | ||
206 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s_base->dma), | ||
207 | + SEPARATE_DMA_IRQ_MAX + 1 + n, | ||
208 | + qdev_get_gpio_in(DEVICE(&s_base->orgated_dma_irq), n)); | ||
209 | + } | ||
210 | + qdev_connect_gpio_out(DEVICE(&s_base->orgated_dma_irq), 0, | ||
211 | + qdev_get_gpio_in_named(DEVICE(&s_base->ic), | ||
212 | + BCM2835_IC_GPU_IRQ, | ||
213 | + INTERRUPT_DMA0 + SEPARATE_DMA_IRQ_MAX + 1)); | ||
214 | + | ||
215 | + /* Random Number Generator */ | ||
216 | + if (!sysbus_realize(SYS_BUS_DEVICE(&s->rng), errp)) { | ||
217 | + return; | ||
218 | + } | ||
219 | + memory_region_add_subregion( | ||
220 | + &s_base->peri_mr, RNG_OFFSET, | ||
221 | + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->rng), 0)); | ||
222 | + | ||
223 | + /* THERMAL */ | ||
224 | + if (!sysbus_realize(SYS_BUS_DEVICE(&s->thermal), errp)) { | ||
225 | + return; | ||
226 | + } | ||
227 | + memory_region_add_subregion(&s_base->peri_mr, THERMAL_OFFSET, | ||
228 | + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->thermal), 0)); | ||
229 | + | ||
230 | + /* Map MPHI to the peripherals memory map */ | ||
231 | + mphi_mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s_base->mphi), 0); | ||
232 | + memory_region_add_subregion(&s_base->peri_mr, MPHI_OFFSET, mphi_mr); | ||
233 | + | ||
234 | + /* GPIO */ | ||
235 | + if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) { | ||
236 | + return; | ||
237 | + } | ||
238 | + memory_region_add_subregion( | ||
239 | + &s_base->peri_mr, GPIO_OFFSET, | ||
240 | + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->gpio), 0)); | ||
241 | + | ||
242 | + object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(&s->gpio), "sd-bus"); | ||
243 | +} | ||
244 | + | ||
245 | +void bcm_soc_peripherals_common_realize(DeviceState *dev, Error **errp) | ||
246 | +{ | ||
247 | + BCMSocPeripheralBaseState *s = BCM_SOC_PERIPHERALS_BASE(dev); | ||
248 | Object *obj; | ||
249 | MemoryRegion *ram; | ||
250 | Error *err = NULL; | ||
251 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | ||
252 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->property), 0, | ||
253 | qdev_get_gpio_in(DEVICE(&s->mboxes), MBOX_CHAN_PROPERTY)); | ||
254 | |||
255 | - /* Random Number Generator */ | ||
256 | - if (!sysbus_realize(SYS_BUS_DEVICE(&s->rng), errp)) { | ||
257 | - return; | ||
258 | - } | ||
259 | - | ||
260 | - memory_region_add_subregion(&s->peri_mr, RNG_OFFSET, | ||
261 | - sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->rng), 0)); | ||
262 | - | ||
263 | /* Extended Mass Media Controller | ||
264 | * | ||
265 | * Compatible with: | ||
266 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | ||
267 | |||
268 | memory_region_add_subregion(&s->peri_mr, EMMC1_OFFSET, | ||
269 | sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->sdhci), 0)); | ||
270 | - sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci), 0, | ||
271 | - qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, | ||
272 | - INTERRUPT_ARASANSDIO)); | ||
273 | |||
274 | /* SDHOST */ | ||
275 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdhost), errp)) { | ||
276 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | ||
277 | memory_region_add_subregion(&s->peri_mr, DMA15_OFFSET, | ||
278 | sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->dma), 1)); | ||
279 | |||
280 | - for (n = 0; n <= SEPARATE_DMA_IRQ_MAX; n++) { | ||
281 | - sysbus_connect_irq(SYS_BUS_DEVICE(&s->dma), n, | ||
282 | - qdev_get_gpio_in_named(DEVICE(&s->ic), | ||
283 | - BCM2835_IC_GPU_IRQ, | ||
284 | - INTERRUPT_DMA0 + n)); | ||
285 | - } | ||
286 | - if (!qdev_realize(DEVICE(&s->orgated_dma_irq), NULL, errp)) { | ||
287 | - return; | ||
288 | - } | ||
289 | - for (n = 0; n < ORGATED_DMA_IRQ_COUNT; n++) { | ||
290 | - sysbus_connect_irq(SYS_BUS_DEVICE(&s->dma), | ||
291 | - SEPARATE_DMA_IRQ_MAX + 1 + n, | ||
292 | - qdev_get_gpio_in(DEVICE(&s->orgated_dma_irq), n)); | ||
293 | - } | ||
294 | - qdev_connect_gpio_out(DEVICE(&s->orgated_dma_irq), 0, | ||
295 | - qdev_get_gpio_in_named(DEVICE(&s->ic), | ||
296 | - BCM2835_IC_GPU_IRQ, | ||
297 | - INTERRUPT_DMA0 + SEPARATE_DMA_IRQ_MAX + 1)); | ||
298 | - | ||
299 | - /* THERMAL */ | ||
300 | - if (!sysbus_realize(SYS_BUS_DEVICE(&s->thermal), errp)) { | ||
301 | - return; | ||
302 | - } | ||
303 | - memory_region_add_subregion(&s->peri_mr, THERMAL_OFFSET, | ||
304 | - sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->thermal), 0)); | ||
305 | - | ||
306 | - /* GPIO */ | ||
307 | - if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) { | ||
308 | - return; | ||
309 | - } | ||
310 | - | ||
311 | - memory_region_add_subregion(&s->peri_mr, GPIO_OFFSET, | ||
312 | - sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->gpio), 0)); | ||
313 | - | ||
314 | - object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(&s->gpio), "sd-bus"); | ||
315 | - | ||
316 | /* Mphi */ | ||
317 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->mphi), errp)) { | ||
318 | return; | ||
319 | } | 68 | } |
320 | 69 | ||
321 | - memory_region_add_subregion(&s->peri_mr, MPHI_OFFSET, | 70 | /* |
322 | - sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->mphi), 0)); | 71 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) |
323 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->mphi), 0, | 72 | FSL_IMX7_GPIOn_ADDR[i]); |
324 | qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, | 73 | |
325 | INTERRUPT_HOSTPORT)); | 74 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 0, |
326 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | 75 | - qdev_get_gpio_in(DEVICE(&s->a7mpcore), |
327 | static void bcm2835_peripherals_class_init(ObjectClass *oc, void *data) | 76 | - FSL_IMX7_GPIOn_LOW_IRQ[i])); |
328 | { | 77 | + qdev_get_gpio_in(gic, FSL_IMX7_GPIOn_LOW_IRQ[i])); |
329 | DeviceClass *dc = DEVICE_CLASS(oc); | 78 | |
330 | + BCMSocPeripheralBaseClass *bc = BCM_SOC_PERIPHERALS_BASE_CLASS(oc); | 79 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 1, |
331 | 80 | - qdev_get_gpio_in(DEVICE(&s->a7mpcore), | |
332 | + bc->peri_size = 0x1000000; | 81 | - FSL_IMX7_GPIOn_HIGH_IRQ[i])); |
333 | dc->realize = bcm2835_peripherals_realize; | 82 | + qdev_get_gpio_in(gic, FSL_IMX7_GPIOn_HIGH_IRQ[i])); |
334 | } | ||
335 | |||
336 | -static const TypeInfo bcm2835_peripherals_type_info = { | ||
337 | - .name = TYPE_BCM2835_PERIPHERALS, | ||
338 | - .parent = TYPE_SYS_BUS_DEVICE, | ||
339 | - .instance_size = sizeof(BCM2835PeripheralState), | ||
340 | - .instance_init = bcm2835_peripherals_init, | ||
341 | - .class_init = bcm2835_peripherals_class_init, | ||
342 | +static const TypeInfo bcm2835_peripherals_types[] = { | ||
343 | + { | ||
344 | + .name = TYPE_BCM2835_PERIPHERALS, | ||
345 | + .parent = TYPE_BCM_SOC_PERIPHERALS_BASE, | ||
346 | + .instance_size = sizeof(BCM2835PeripheralState), | ||
347 | + .instance_init = bcm2835_peripherals_init, | ||
348 | + .class_init = bcm2835_peripherals_class_init, | ||
349 | + }, { | ||
350 | + .name = TYPE_BCM_SOC_PERIPHERALS_BASE, | ||
351 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
352 | + .instance_size = sizeof(BCMSocPeripheralBaseState), | ||
353 | + .instance_init = raspi_peripherals_base_init, | ||
354 | + .class_size = sizeof(BCMSocPeripheralBaseClass), | ||
355 | + .abstract = true, | ||
356 | + } | ||
357 | }; | ||
358 | |||
359 | -static void bcm2835_peripherals_register_types(void) | ||
360 | -{ | ||
361 | - type_register_static(&bcm2835_peripherals_type_info); | ||
362 | -} | ||
363 | - | ||
364 | -type_init(bcm2835_peripherals_register_types) | ||
365 | +DEFINE_TYPES(bcm2835_peripherals_types) | ||
366 | diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c | ||
367 | index XXXXXXX..XXXXXXX 100644 | ||
368 | --- a/hw/arm/bcm2836.c | ||
369 | +++ b/hw/arm/bcm2836.c | ||
370 | @@ -XXX,XX +XXX,XX @@ static void bcm283x_init(Object *obj) | ||
371 | "vcram-size"); | ||
372 | } | ||
373 | |||
374 | -bool bcm283x_common_realize(DeviceState *dev, Error **errp) | ||
375 | +bool bcm283x_common_realize(DeviceState *dev, BCMSocPeripheralBaseState *ps, | ||
376 | + Error **errp) | ||
377 | { | ||
378 | - BCM283XState *s = BCM283X(dev); | ||
379 | - BCM283XBaseState *s_base = BCM283X_BASE(dev); | ||
380 | + BCM283XBaseState *s = BCM283X_BASE(dev); | ||
381 | BCM283XBaseClass *bc = BCM283X_BASE_GET_CLASS(dev); | ||
382 | Object *obj; | ||
383 | |||
384 | @@ -XXX,XX +XXX,XX @@ bool bcm283x_common_realize(DeviceState *dev, Error **errp) | ||
385 | |||
386 | obj = object_property_get_link(OBJECT(dev), "ram", &error_abort); | ||
387 | |||
388 | - object_property_add_const_link(OBJECT(&s->peripherals), "ram", obj); | ||
389 | + object_property_add_const_link(OBJECT(ps), "ram", obj); | ||
390 | |||
391 | - if (!sysbus_realize(SYS_BUS_DEVICE(&s->peripherals), errp)) { | ||
392 | + if (!sysbus_realize(SYS_BUS_DEVICE(ps), errp)) { | ||
393 | return false; | ||
394 | } | 83 | } |
395 | 84 | ||
396 | - object_property_add_alias(OBJECT(s_base), "sd-bus", | 85 | /* |
397 | - OBJECT(&s->peripherals), "sd-bus"); | 86 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) |
398 | + object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(ps), "sd-bus"); | 87 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, |
399 | 88 | FSL_IMX7_SPIn_ADDR[i]); | |
400 | - sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->peripherals), | 89 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0, |
401 | - 0, bc->peri_base, 1); | 90 | - qdev_get_gpio_in(DEVICE(&s->a7mpcore), |
402 | + sysbus_mmio_map_overlap(SYS_BUS_DEVICE(ps), 0, bc->peri_base, 1); | 91 | - FSL_IMX7_SPIn_IRQ[i])); |
403 | return true; | 92 | + qdev_get_gpio_in(gic, FSL_IMX7_SPIn_IRQ[i])); |
404 | } | ||
405 | |||
406 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_realize(DeviceState *dev, Error **errp) | ||
407 | { | ||
408 | BCM283XState *s = BCM283X(dev); | ||
409 | BCM283XBaseState *s_base = BCM283X_BASE(dev); | ||
410 | + BCMSocPeripheralBaseState *ps_base | ||
411 | + = BCM_SOC_PERIPHERALS_BASE(&s->peripherals); | ||
412 | |||
413 | - if (!bcm283x_common_realize(dev, errp)) { | ||
414 | + if (!bcm283x_common_realize(dev, ps_base, errp)) { | ||
415 | return; | ||
416 | } | 93 | } |
417 | 94 | ||
418 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) | 95 | /* |
419 | BCM283XState *s = BCM283X(dev); | 96 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) |
420 | BCM283XBaseState *s_base = BCM283X_BASE(dev); | 97 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c[i]), 0, FSL_IMX7_I2Cn_ADDR[i]); |
421 | BCM283XBaseClass *bc = BCM283X_BASE_GET_CLASS(dev); | 98 | |
422 | + BCMSocPeripheralBaseState *ps_base | 99 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c[i]), 0, |
423 | + = BCM_SOC_PERIPHERALS_BASE(&s->peripherals); | 100 | - qdev_get_gpio_in(DEVICE(&s->a7mpcore), |
424 | 101 | - FSL_IMX7_I2Cn_IRQ[i])); | |
425 | - if (!bcm283x_common_realize(dev, errp)) { | 102 | + qdev_get_gpio_in(gic, FSL_IMX7_I2Cn_IRQ[i])); |
426 | + if (!bcm283x_common_realize(dev, ps_base, errp)) { | ||
427 | return; | ||
428 | } | 103 | } |
429 | 104 | ||
105 | /* | ||
106 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
107 | |||
108 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0, FSL_IMX7_UARTn_ADDR[i]); | ||
109 | |||
110 | - irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_UARTn_IRQ[i]); | ||
111 | + irq = qdev_get_gpio_in(gic, FSL_IMX7_UARTn_IRQ[i]); | ||
112 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart[i]), 0, irq); | ||
113 | } | ||
114 | |||
115 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
116 | |||
117 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->eth[i]), 0, FSL_IMX7_ENETn_ADDR[i]); | ||
118 | |||
119 | - irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_ENET_IRQ(i, 0)); | ||
120 | + irq = qdev_get_gpio_in(gic, FSL_IMX7_ENET_IRQ(i, 0)); | ||
121 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->eth[i]), 0, irq); | ||
122 | - irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_ENET_IRQ(i, 3)); | ||
123 | + irq = qdev_get_gpio_in(gic, FSL_IMX7_ENET_IRQ(i, 3)); | ||
124 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->eth[i]), 1, irq); | ||
125 | } | ||
126 | |||
127 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
128 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->usdhc[i]), 0, | ||
129 | FSL_IMX7_USDHCn_ADDR[i]); | ||
130 | |||
131 | - irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_USDHCn_IRQ[i]); | ||
132 | + irq = qdev_get_gpio_in(gic, FSL_IMX7_USDHCn_IRQ[i]); | ||
133 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->usdhc[i]), 0, irq); | ||
134 | } | ||
135 | |||
136 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
137 | |||
138 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt[i]), 0, FSL_IMX7_WDOGn_ADDR[i]); | ||
139 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->wdt[i]), 0, | ||
140 | - qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
141 | - FSL_IMX7_WDOGn_IRQ[i])); | ||
142 | + qdev_get_gpio_in(gic, FSL_IMX7_WDOGn_IRQ[i])); | ||
143 | } | ||
144 | |||
145 | /* | ||
146 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
147 | irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_PCI_INTD_MSI_IRQ); | ||
148 | qdev_connect_gpio_out(DEVICE(&s->pcie4_msi_irq), 0, irq); | ||
149 | |||
150 | - irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_PCI_INTA_IRQ); | ||
151 | + irq = qdev_get_gpio_in(gic, FSL_IMX7_PCI_INTA_IRQ); | ||
152 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 0, irq); | ||
153 | - irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_PCI_INTB_IRQ); | ||
154 | + irq = qdev_get_gpio_in(gic, FSL_IMX7_PCI_INTB_IRQ); | ||
155 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 1, irq); | ||
156 | - irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_PCI_INTC_IRQ); | ||
157 | + irq = qdev_get_gpio_in(gic, FSL_IMX7_PCI_INTC_IRQ); | ||
158 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 2, irq); | ||
159 | irq = qdev_get_gpio_in(DEVICE(&s->pcie4_msi_irq), 0); | ||
160 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 3, irq); | ||
161 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | ||
162 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->usb[i]), 0, | ||
163 | FSL_IMX7_USBn_ADDR[i]); | ||
164 | |||
165 | - irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), FSL_IMX7_USBn_IRQ[i]); | ||
166 | + irq = qdev_get_gpio_in(gic, FSL_IMX7_USBn_IRQ[i]); | ||
167 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->usb[i]), 0, irq); | ||
168 | |||
169 | snprintf(name, NAME_SIZE, "usbmisc%d", i); | ||
430 | -- | 170 | -- |
431 | 2.34.1 | 171 | 2.34.1 |
172 | |||
173 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This code -- which was moved many times around -- was added in | 3 | No need to duplicate and forward the 'num-cpu' property from |
4 | commit 377e214539 ("ahci: Add allwinner AHCI") and belong to the | 4 | TYPE_ARM11MPCORE_PRIV to TYPE_REALVIEW_MPCORE, alias it with |
5 | AllWinner machines. See also commit dca625768a ("arm: allwinner-a10: | 5 | QOM object_property_add_alias(). |
6 | Add SATA"). | ||
7 | 6 | ||
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
9 | Message-id: 20240215160713.80409-1-philmd@linaro.org | 8 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
9 | Message-id: 20250130112615.3219-6-philmd@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 11 | --- |
12 | MAINTAINERS | 1 + | 12 | hw/cpu/realview_mpcore.c | 8 +------- |
13 | 1 file changed, 1 insertion(+) | 13 | 1 file changed, 1 insertion(+), 7 deletions(-) |
14 | 14 | ||
15 | diff --git a/MAINTAINERS b/MAINTAINERS | 15 | diff --git a/hw/cpu/realview_mpcore.c b/hw/cpu/realview_mpcore.c |
16 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/MAINTAINERS | 17 | --- a/hw/cpu/realview_mpcore.c |
18 | +++ b/MAINTAINERS | 18 | +++ b/hw/cpu/realview_mpcore.c |
19 | @@ -XXX,XX +XXX,XX @@ R: Strahinja Jankovic <strahinja.p.jankovic@gmail.com> | 19 | @@ -XXX,XX +XXX,XX @@ |
20 | L: qemu-arm@nongnu.org | 20 | #include "hw/cpu/arm11mpcore.h" |
21 | S: Odd Fixes | 21 | #include "hw/intc/realview_gic.h" |
22 | F: hw/*/allwinner* | 22 | #include "hw/irq.h" |
23 | +F: hw/ide/ahci-allwinner.c | 23 | -#include "hw/qdev-properties.h" |
24 | F: include/hw/*/allwinner* | 24 | #include "qom/object.h" |
25 | F: hw/arm/cubieboard.c | 25 | |
26 | F: docs/system/arm/cubieboard.rst | 26 | #define TYPE_REALVIEW_MPCORE_RIRQ "realview_mpcore" |
27 | @@ -XXX,XX +XXX,XX @@ static void realview_mpcore_realize(DeviceState *dev, Error **errp) | ||
28 | int n; | ||
29 | int i; | ||
30 | |||
31 | - qdev_prop_set_uint32(priv, "num-cpu", s->num_cpu); | ||
32 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->priv), errp)) { | ||
33 | return; | ||
34 | } | ||
35 | @@ -XXX,XX +XXX,XX @@ static void mpcore_rirq_init(Object *obj) | ||
36 | int i; | ||
37 | |||
38 | object_initialize_child(obj, "a11priv", &s->priv, TYPE_ARM11MPCORE_PRIV); | ||
39 | + object_property_add_alias(obj, "num-cpu", OBJECT(&s->priv), "num-cpu"); | ||
40 | privbusdev = SYS_BUS_DEVICE(&s->priv); | ||
41 | sysbus_init_mmio(sbd, sysbus_mmio_get_region(privbusdev, 0)); | ||
42 | |||
43 | @@ -XXX,XX +XXX,XX @@ static void mpcore_rirq_init(Object *obj) | ||
44 | } | ||
45 | } | ||
46 | |||
47 | -static const Property mpcore_rirq_properties[] = { | ||
48 | - DEFINE_PROP_UINT32("num-cpu", mpcore_rirq_state, num_cpu, 1), | ||
49 | -}; | ||
50 | - | ||
51 | static void mpcore_rirq_class_init(ObjectClass *klass, void *data) | ||
52 | { | ||
53 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
54 | |||
55 | dc->realize = realview_mpcore_realize; | ||
56 | - device_class_set_props(dc, mpcore_rirq_properties); | ||
57 | } | ||
58 | |||
59 | static const TypeInfo mpcore_rirq_info = { | ||
27 | -- | 60 | -- |
28 | 2.34.1 | 61 | 2.34.1 |
29 | 62 | ||
30 | 63 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Abhiram Tilak <atp.exp@gmail.com> | ||
2 | 1 | ||
3 | A few watchdog devices use qemu_system_reset_request(). This is not ideal since | ||
4 | behaviour of watchdog-expiry can't be changed by QMP using `watchdog_action`. | ||
5 | As stated in BiteSizedTasks wiki page, instead of using qemu_system_reset_request() | ||
6 | to reset when a watchdog timer expires, let watchdog_perform_action() decide | ||
7 | what to do. | ||
8 | |||
9 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2124 | ||
10 | Signed-off-by: Abhiram Tilak <atp.exp@gmail.com> | ||
11 | Message-id: 20240216192612.30838-4-atp.exp@gmail.com | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | hw/rtc/m48t59.c | 4 ++-- | ||
16 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
17 | |||
18 | diff --git a/hw/rtc/m48t59.c b/hw/rtc/m48t59.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/hw/rtc/m48t59.c | ||
21 | +++ b/hw/rtc/m48t59.c | ||
22 | @@ -XXX,XX +XXX,XX @@ | ||
23 | #include "qemu/bcd.h" | ||
24 | #include "qemu/module.h" | ||
25 | #include "trace.h" | ||
26 | +#include "sysemu/watchdog.h" | ||
27 | |||
28 | #include "m48t59-internal.h" | ||
29 | #include "migration/vmstate.h" | ||
30 | @@ -XXX,XX +XXX,XX @@ static void watchdog_cb (void *opaque) | ||
31 | if (NVRAM->buffer[0x1FF7] & 0x80) { | ||
32 | NVRAM->buffer[0x1FF7] = 0x00; | ||
33 | NVRAM->buffer[0x1FFC] &= ~0x40; | ||
34 | - /* May it be a hw CPU Reset instead ? */ | ||
35 | - qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); | ||
36 | + watchdog_perform_action(); | ||
37 | } else { | ||
38 | qemu_set_irq(NVRAM->IRQ, 1); | ||
39 | qemu_set_irq(NVRAM->IRQ, 0); | ||
40 | -- | ||
41 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Abhiram Tilak <atp.exp@gmail.com> | ||
2 | 1 | ||
3 | A few watchdog devices use qemu_system_reset_request(). This is not ideal since | ||
4 | behaviour of watchdog-expiry can't be changed by QMP using `watchdog_action`. | ||
5 | As stated in BiteSizedTasks wiki page, instead of using qemu_system_reset_request() | ||
6 | to reset when a watchdog timer expires, let watchdog_perform_action() decide | ||
7 | what to do. | ||
8 | |||
9 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2124 | ||
10 | Signed-off-by: Abhiram Tilak <atp.exp@gmail.com> | ||
11 | Message-id: 20240216192612.30838-5-atp.exp@gmail.com | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | hw/timer/pxa2xx_timer.c | 3 ++- | ||
16 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
17 | |||
18 | diff --git a/hw/timer/pxa2xx_timer.c b/hw/timer/pxa2xx_timer.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/hw/timer/pxa2xx_timer.c | ||
21 | +++ b/hw/timer/pxa2xx_timer.c | ||
22 | @@ -XXX,XX +XXX,XX @@ | ||
23 | #include "qemu/log.h" | ||
24 | #include "qemu/module.h" | ||
25 | #include "qom/object.h" | ||
26 | +#include "sysemu/watchdog.h" | ||
27 | |||
28 | #define OSMR0 0x00 | ||
29 | #define OSMR1 0x04 | ||
30 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_timer_tick(void *opaque) | ||
31 | if (t->num == 3) | ||
32 | if (i->reset3 & 1) { | ||
33 | i->reset3 = 0; | ||
34 | - qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); | ||
35 | + watchdog_perform_action(); | ||
36 | } | ||
37 | } | ||
38 | |||
39 | -- | ||
40 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Sai Pavan Boddu <sai.pavan.boddu@amd.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This property allows users to change flash model on command line as | 3 | When multiple QOM types are registered in the same file, |
4 | below. | 4 | it is simpler to use the the DEFINE_TYPES() macro. In |
5 | particular because type array declared with such macro | ||
6 | are easier to review. | ||
5 | 7 | ||
6 | ex: "-M xlnx-versal-virt,ospi-flash=mt35xu02gbba" | 8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | 9 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | |
8 | Signed-off-by: Sai Pavan Boddu <sai.pavan.boddu@amd.com> | 10 | Message-id: 20250130112615.3219-7-philmd@linaro.org |
9 | Message-id: 20240220091721.82954-3-sai.pavan.boddu@amd.com | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 12 | --- |
13 | hw/arm/xlnx-versal-virt.c | 44 ++++++++++++++++++++++++++++++++++++++- | 13 | hw/cpu/a15mpcore.c | 21 +++++++++------------ |
14 | 1 file changed, 43 insertions(+), 1 deletion(-) | 14 | hw/cpu/a9mpcore.c | 21 +++++++++------------ |
15 | hw/cpu/arm11mpcore.c | 21 +++++++++------------ | ||
16 | hw/cpu/realview_mpcore.c | 21 +++++++++------------ | ||
17 | 4 files changed, 36 insertions(+), 48 deletions(-) | ||
15 | 18 | ||
16 | diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c | 19 | diff --git a/hw/cpu/a15mpcore.c b/hw/cpu/a15mpcore.c |
17 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/arm/xlnx-versal-virt.c | 21 | --- a/hw/cpu/a15mpcore.c |
19 | +++ b/hw/arm/xlnx-versal-virt.c | 22 | +++ b/hw/cpu/a15mpcore.c |
20 | @@ -XXX,XX +XXX,XX @@ struct VersalVirt { | 23 | @@ -XXX,XX +XXX,XX @@ static void a15mp_priv_class_init(ObjectClass *klass, void *data) |
21 | struct { | 24 | /* We currently have no saveable state */ |
22 | bool secure; | 25 | } |
23 | } cfg; | 26 | |
24 | + char *ospi_model; | 27 | -static const TypeInfo a15mp_priv_info = { |
28 | - .name = TYPE_A15MPCORE_PRIV, | ||
29 | - .parent = TYPE_SYS_BUS_DEVICE, | ||
30 | - .instance_size = sizeof(A15MPPrivState), | ||
31 | - .instance_init = a15mp_priv_initfn, | ||
32 | - .class_init = a15mp_priv_class_init, | ||
33 | +static const TypeInfo a15mp_types[] = { | ||
34 | + { | ||
35 | + .name = TYPE_A15MPCORE_PRIV, | ||
36 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
37 | + .instance_size = sizeof(A15MPPrivState), | ||
38 | + .instance_init = a15mp_priv_initfn, | ||
39 | + .class_init = a15mp_priv_class_init, | ||
40 | + }, | ||
25 | }; | 41 | }; |
26 | 42 | ||
27 | static void fdt_create(VersalVirt *s) | 43 | -static void a15mp_register_types(void) |
28 | @@ -XXX,XX +XXX,XX @@ static void sd_plugin_card(SDHCIState *sd, DriveInfo *di) | 44 | -{ |
29 | &error_fatal); | 45 | - type_register_static(&a15mp_priv_info); |
46 | -} | ||
47 | - | ||
48 | -type_init(a15mp_register_types) | ||
49 | +DEFINE_TYPES(a15mp_types) | ||
50 | diff --git a/hw/cpu/a9mpcore.c b/hw/cpu/a9mpcore.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/hw/cpu/a9mpcore.c | ||
53 | +++ b/hw/cpu/a9mpcore.c | ||
54 | @@ -XXX,XX +XXX,XX @@ static void a9mp_priv_class_init(ObjectClass *klass, void *data) | ||
55 | device_class_set_props(dc, a9mp_priv_properties); | ||
30 | } | 56 | } |
31 | 57 | ||
32 | +static char *versal_get_ospi_model(Object *obj, Error **errp) | 58 | -static const TypeInfo a9mp_priv_info = { |
33 | +{ | 59 | - .name = TYPE_A9MPCORE_PRIV, |
34 | + VersalVirt *s = XLNX_VERSAL_VIRT_MACHINE(obj); | 60 | - .parent = TYPE_SYS_BUS_DEVICE, |
35 | + | 61 | - .instance_size = sizeof(A9MPPrivState), |
36 | + return g_strdup(s->ospi_model); | 62 | - .instance_init = a9mp_priv_initfn, |
37 | +} | 63 | - .class_init = a9mp_priv_class_init, |
38 | + | 64 | +static const TypeInfo a9mp_types[] = { |
39 | +static void versal_set_ospi_model(Object *obj, const char *value, Error **errp) | 65 | + { |
40 | +{ | 66 | + .name = TYPE_A9MPCORE_PRIV, |
41 | + VersalVirt *s = XLNX_VERSAL_VIRT_MACHINE(obj); | 67 | + .parent = TYPE_SYS_BUS_DEVICE, |
42 | + | 68 | + .instance_size = sizeof(A9MPPrivState), |
43 | + g_free(s->ospi_model); | 69 | + .instance_init = a9mp_priv_initfn, |
44 | + s->ospi_model = g_strdup(value); | 70 | + .class_init = a9mp_priv_class_init, |
45 | +} | 71 | + }, |
46 | + | 72 | }; |
47 | + | 73 | |
48 | static void versal_virt_init(MachineState *machine) | 74 | -static void a9mp_register_types(void) |
49 | { | 75 | -{ |
50 | VersalVirt *s = XLNX_VERSAL_VIRT_MACHINE(machine); | 76 | - type_register_static(&a9mp_priv_info); |
51 | @@ -XXX,XX +XXX,XX @@ static void versal_virt_init(MachineState *machine) | 77 | -} |
52 | for (i = 0; i < XLNX_VERSAL_NUM_OSPI_FLASH; i++) { | 78 | - |
53 | BusState *spi_bus; | 79 | -type_init(a9mp_register_types) |
54 | DeviceState *flash_dev; | 80 | +DEFINE_TYPES(a9mp_types) |
55 | + ObjectClass *flash_klass; | 81 | diff --git a/hw/cpu/arm11mpcore.c b/hw/cpu/arm11mpcore.c |
56 | qemu_irq cs_line; | 82 | index XXXXXXX..XXXXXXX 100644 |
57 | DriveInfo *dinfo = drive_get(IF_MTD, 0, i); | 83 | --- a/hw/cpu/arm11mpcore.c |
58 | 84 | +++ b/hw/cpu/arm11mpcore.c | |
59 | spi_bus = qdev_get_child_bus(DEVICE(&s->soc.pmc.iou.ospi), "spi0"); | 85 | @@ -XXX,XX +XXX,XX @@ static void mpcore_priv_class_init(ObjectClass *klass, void *data) |
60 | 86 | device_class_set_props(dc, mpcore_priv_properties); | |
61 | - flash_dev = qdev_new("mt35xu01g"); | ||
62 | + if (s->ospi_model) { | ||
63 | + flash_klass = object_class_by_name(s->ospi_model); | ||
64 | + if (!flash_klass || | ||
65 | + object_class_is_abstract(flash_klass) || | ||
66 | + !object_class_dynamic_cast(flash_klass, "m25p80-generic")) { | ||
67 | + error_setg(&error_fatal, "'%s' is either abstract or" | ||
68 | + " not a subtype of m25p80", s->ospi_model); | ||
69 | + return; | ||
70 | + } | ||
71 | + } | ||
72 | + | ||
73 | + flash_dev = qdev_new(s->ospi_model ? s->ospi_model : "mt35xu01g"); | ||
74 | + | ||
75 | if (dinfo) { | ||
76 | qdev_prop_set_drive_err(flash_dev, "drive", | ||
77 | blk_by_legacy_dinfo(dinfo), &error_fatal); | ||
78 | @@ -XXX,XX +XXX,XX @@ static void versal_virt_machine_instance_init(Object *obj) | ||
79 | 0); | ||
80 | } | 87 | } |
81 | 88 | ||
82 | +static void versal_virt_machine_finalize(Object *obj) | 89 | -static const TypeInfo mpcore_priv_info = { |
83 | +{ | 90 | - .name = TYPE_ARM11MPCORE_PRIV, |
84 | + VersalVirt *s = XLNX_VERSAL_VIRT_MACHINE(obj); | 91 | - .parent = TYPE_SYS_BUS_DEVICE, |
85 | + | 92 | - .instance_size = sizeof(ARM11MPCorePriveState), |
86 | + g_free(s->ospi_model); | 93 | - .instance_init = mpcore_priv_initfn, |
87 | +} | 94 | - .class_init = mpcore_priv_class_init, |
88 | + | 95 | +static const TypeInfo arm11mp_types[] = { |
89 | static void versal_virt_machine_class_init(ObjectClass *oc, void *data) | 96 | + { |
90 | { | 97 | + .name = TYPE_ARM11MPCORE_PRIV, |
91 | MachineClass *mc = MACHINE_CLASS(oc); | 98 | + .parent = TYPE_SYS_BUS_DEVICE, |
92 | @@ -XXX,XX +XXX,XX @@ static void versal_virt_machine_class_init(ObjectClass *oc, void *data) | 99 | + .instance_size = sizeof(ARM11MPCorePriveState), |
93 | mc->default_cpus = XLNX_VERSAL_NR_ACPUS + XLNX_VERSAL_NR_RCPUS; | 100 | + .instance_init = mpcore_priv_initfn, |
94 | mc->no_cdrom = true; | 101 | + .class_init = mpcore_priv_class_init, |
95 | mc->default_ram_id = "ddr"; | 102 | + }, |
96 | + object_class_property_add_str(oc, "ospi-flash", versal_get_ospi_model, | 103 | }; |
97 | + versal_set_ospi_model); | 104 | |
98 | + object_class_property_set_description(oc, "ospi-flash", | 105 | -static void arm11mpcore_register_types(void) |
99 | + "Change the OSPI Flash model"); | 106 | -{ |
107 | - type_register_static(&mpcore_priv_info); | ||
108 | -} | ||
109 | - | ||
110 | -type_init(arm11mpcore_register_types) | ||
111 | +DEFINE_TYPES(arm11mp_types) | ||
112 | diff --git a/hw/cpu/realview_mpcore.c b/hw/cpu/realview_mpcore.c | ||
113 | index XXXXXXX..XXXXXXX 100644 | ||
114 | --- a/hw/cpu/realview_mpcore.c | ||
115 | +++ b/hw/cpu/realview_mpcore.c | ||
116 | @@ -XXX,XX +XXX,XX @@ static void mpcore_rirq_class_init(ObjectClass *klass, void *data) | ||
117 | dc->realize = realview_mpcore_realize; | ||
100 | } | 118 | } |
101 | 119 | ||
102 | static const TypeInfo versal_virt_machine_init_typeinfo = { | 120 | -static const TypeInfo mpcore_rirq_info = { |
103 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo versal_virt_machine_init_typeinfo = { | 121 | - .name = TYPE_REALVIEW_MPCORE_RIRQ, |
104 | .class_init = versal_virt_machine_class_init, | 122 | - .parent = TYPE_SYS_BUS_DEVICE, |
105 | .instance_init = versal_virt_machine_instance_init, | 123 | - .instance_size = sizeof(mpcore_rirq_state), |
106 | .instance_size = sizeof(VersalVirt), | 124 | - .instance_init = mpcore_rirq_init, |
107 | + .instance_finalize = versal_virt_machine_finalize, | 125 | - .class_init = mpcore_rirq_class_init, |
126 | +static const TypeInfo realview_mpcore_types[] = { | ||
127 | + { | ||
128 | + .name = TYPE_REALVIEW_MPCORE_RIRQ, | ||
129 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
130 | + .instance_size = sizeof(mpcore_rirq_state), | ||
131 | + .instance_init = mpcore_rirq_init, | ||
132 | + .class_init = mpcore_rirq_class_init, | ||
133 | + }, | ||
108 | }; | 134 | }; |
109 | 135 | ||
110 | static void versal_virt_machine_init_register_types(void) | 136 | -static void realview_mpcore_register_types(void) |
137 | -{ | ||
138 | - type_register_static(&mpcore_rirq_info); | ||
139 | -} | ||
140 | - | ||
141 | -type_init(realview_mpcore_register_types) | ||
142 | +DEFINE_TYPES(realview_mpcore_types) | ||
111 | -- | 143 | -- |
112 | 2.34.1 | 144 | 2.34.1 |
145 | |||
146 | diff view generated by jsdifflib |
1 | From: Jessica Clarke <jrtc27@jrtc27.com> | 1 | From: Andrew Yuan <andrew.yuan@jaguarmicro.com> |
---|---|---|---|
2 | 2 | ||
3 | The PL031 allows you to read RTCLR, which is meant to give you the last | 3 | Our current handling of the mask/compare logic in the Cadence |
4 | value written. PL031State has an lr field which is used when reading | 4 | GEM ethernet device is wrong: |
5 | from RTCLR, and is present in the VM migration state, but we never | 5 | (1) we load the same byte twice from rx_buf when |
6 | actually update it, so it always reads as its initial 0 value. | 6 | creating the compare value |
7 | (2) we ignore the DISABLE_MASK flag | ||
7 | 8 | ||
8 | Cc: qemu-stable@nongnu.org | 9 | The "Cadence IP for Gigabit Ethernet MAC Part Number: IP7014 IP Rev: |
9 | Signed-off-by: Jessica Clarke <jrtc27@jrtc27.com> | 10 | R1p12 - Doc Rev: 1.3 User Guide" states that if the DISABLE_MASK bit |
10 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 11 | in type2_compare_x_word_1 is set, the mask_value field in |
11 | Message-id: 20240222000341.1562443-1-jrtc27@jrtc27.com | 12 | type2_compare_x_word_0 is used as an additional 2 byte Compare Value. |
13 | |||
14 | Correct these bugs: | ||
15 | * in the !disable_mask codepath, use lduw_le_p() so we | ||
16 | correctly load a 16-bit value for comparison | ||
17 | * in the disable_mask codepath, we load a full 4-byte value | ||
18 | from rx_buf for the comparison, set the compare value to | ||
19 | the whole of the cr0 register (i.e. the concatenation of | ||
20 | the mask and compare fields), and set mask to 0xffffffff | ||
21 | to force a 32-bit comparison | ||
22 | |||
23 | Signed-off-by: Andrew Yuan <andrew.yuan@jaguarmicro.com> | ||
24 | Message-id: 20241219061658.805-1-andrew.yuan@jaguarmicro.com | ||
25 | Suggested-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
26 | [PMM: Expand commit message and comment] | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 27 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
28 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@gmail.com> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 29 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 30 | --- |
15 | hw/rtc/pl031.c | 1 + | 31 | hw/net/cadence_gem.c | 26 +++++++++++++++++++++----- |
16 | 1 file changed, 1 insertion(+) | 32 | 1 file changed, 21 insertions(+), 5 deletions(-) |
17 | 33 | ||
18 | diff --git a/hw/rtc/pl031.c b/hw/rtc/pl031.c | 34 | diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c |
19 | index XXXXXXX..XXXXXXX 100644 | 35 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/rtc/pl031.c | 36 | --- a/hw/net/cadence_gem.c |
21 | +++ b/hw/rtc/pl031.c | 37 | +++ b/hw/net/cadence_gem.c |
22 | @@ -XXX,XX +XXX,XX @@ static void pl031_write(void * opaque, hwaddr offset, | 38 | @@ -XXX,XX +XXX,XX @@ static int get_queue_from_screen(CadenceGEMState *s, uint8_t *rxbuf_ptr, |
23 | g_autofree const char *qom_path = object_get_canonical_path(opaque); | 39 | |
24 | struct tm tm; | 40 | /* Compare A, B, C */ |
25 | 41 | for (j = 0; j < 3; j++) { | |
26 | + s->lr = value; | 42 | - uint32_t cr0, cr1, mask, compare; |
27 | s->tick_offset += value - pl031_get_count(s); | 43 | - uint16_t rx_cmp; |
28 | 44 | + uint32_t cr0, cr1, mask, compare, disable_mask; | |
29 | qemu_get_timedate(&tm, s->tick_offset); | 45 | + uint32_t rx_cmp; |
46 | int offset; | ||
47 | int cr_idx = extract32(reg, R_SCREENING_TYPE2_REG0_COMPARE_A_SHIFT + j * 6, | ||
48 | R_SCREENING_TYPE2_REG0_COMPARE_A_LENGTH); | ||
49 | @@ -XXX,XX +XXX,XX @@ static int get_queue_from_screen(CadenceGEMState *s, uint8_t *rxbuf_ptr, | ||
50 | break; | ||
51 | } | ||
52 | |||
53 | - rx_cmp = rxbuf_ptr[offset] << 8 | rxbuf_ptr[offset]; | ||
54 | - mask = FIELD_EX32(cr0, TYPE2_COMPARE_0_WORD_0, MASK_VALUE); | ||
55 | - compare = FIELD_EX32(cr0, TYPE2_COMPARE_0_WORD_0, COMPARE_VALUE); | ||
56 | + disable_mask = | ||
57 | + FIELD_EX32(cr1, TYPE2_COMPARE_0_WORD_1, DISABLE_MASK); | ||
58 | + if (disable_mask) { | ||
59 | + /* | ||
60 | + * If disable_mask is set, mask_value is used as an | ||
61 | + * additional 2 byte Compare Value; that is equivalent | ||
62 | + * to using the whole cr0 register as the comparison value. | ||
63 | + * Load 32 bits of data from rx_buf, and set mask to | ||
64 | + * all-ones so we compare all 32 bits. | ||
65 | + */ | ||
66 | + rx_cmp = ldl_le_p(rxbuf_ptr + offset); | ||
67 | + mask = 0xFFFFFFFF; | ||
68 | + compare = cr0; | ||
69 | + } else { | ||
70 | + rx_cmp = lduw_le_p(rxbuf_ptr + offset); | ||
71 | + mask = FIELD_EX32(cr0, TYPE2_COMPARE_0_WORD_0, MASK_VALUE); | ||
72 | + compare = | ||
73 | + FIELD_EX32(cr0, TYPE2_COMPARE_0_WORD_0, COMPARE_VALUE); | ||
74 | + } | ||
75 | |||
76 | if ((rx_cmp & mask) == (compare & mask)) { | ||
77 | matched = true; | ||
30 | -- | 78 | -- |
31 | 2.34.1 | 79 | 2.34.1 |
32 | 80 | ||
33 | 81 | diff view generated by jsdifflib |
1 | Currently the qemu_register_reset() API permits the reset handler functions | 1 | The '-old-param' command line option is specific to Arm targets; it |
---|---|---|---|
2 | registered with it to remove themselves from within the callback function. | 2 | is very briefly documented as "old param mode". What this option |
3 | This is fine with our current implementation, but is a bit odd, because | 3 | actually does is change the behaviour when directly booting a guest |
4 | generally reset is supposed to be idempotent, and doesn't fit well in a | 4 | kernel, so that command line arguments are passed to the kernel using |
5 | three-phase-reset world where a resettable object will get multiple | 5 | the extremely old "param_struct" ABI, rather than the newer ATAGS or |
6 | callbacks as the system is reset. | 6 | even newer DTB mechanisms. |
7 | 7 | ||
8 | We now have only one user of qemu_register_reset() which makes use of | 8 | This support was added back in 2007 to support an old vendor kernel |
9 | the ability to unregister itself within the callback: | 9 | on the akita/terrier board types: |
10 | restore_boot_order(). We want to change our implementation of | 10 | https://mail.gnu.org/archive/html/qemu-devel/2007-07/msg00344.html |
11 | qemu_register_reset() to something where it would be awkward to | 11 | Even then, it was an out-of-date mechanism from the kernel's |
12 | maintain the "can self-unregister" feature. Rather than making that | 12 | point of view -- the kernel has had a comment since 2001 marking |
13 | reimplementation complicated, change restore_boot_order() so that it | 13 | it as deprecated. As of mid-2024, the kernel only retained |
14 | doesn't unregister itself but instead returns doing nothing for any | 14 | param_struct support for the RiscPC and Footbridge platforms: |
15 | calls after it has done the "restore the boot order" work. | 15 | https://lore.kernel.org/linux-arm-kernel/2831c5a6-cfbf-4fe0-b51c-0396e5b0aeb7@app.fastmail.com/ |
16 | |||
17 | None of the board types QEMU supports need param_struct support; | ||
18 | mark this option as deprecated. | ||
16 | 19 | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> | 21 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> |
19 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 22 | Message-id: 20250127123113.2947620-1-peter.maydell@linaro.org |
20 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
21 | Acked-by: Richard Henderson <richard.henderson@linaro.org> | ||
22 | Message-id: 20240220160622.114437-4-peter.maydell@linaro.org | ||
23 | Reviewed-by: Zhao Liu <zhao1.liu@intel.com> | ||
24 | --- | 23 | --- |
25 | system/bootdevice.c | 25 ++++++++++++++----------- | 24 | docs/about/deprecated.rst | 13 +++++++++++++ |
26 | 1 file changed, 14 insertions(+), 11 deletions(-) | 25 | system/vl.c | 1 + |
26 | 2 files changed, 14 insertions(+) | ||
27 | 27 | ||
28 | diff --git a/system/bootdevice.c b/system/bootdevice.c | 28 | diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst |
29 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/system/bootdevice.c | 30 | --- a/docs/about/deprecated.rst |
31 | +++ b/system/bootdevice.c | 31 | +++ b/docs/about/deprecated.rst |
32 | @@ -XXX,XX +XXX,XX @@ void validate_bootdevices(const char *devices, Error **errp) | 32 | @@ -XXX,XX +XXX,XX @@ configurations (e.g. -smp drawers=1,books=1,clusters=1 for x86 PC machine) is |
33 | void restore_boot_order(void *opaque) | 33 | marked deprecated since 9.0, users have to ensure that all the topology members |
34 | { | 34 | described with -smp are supported by the target machine. |
35 | char *normal_boot_order = opaque; | 35 | |
36 | - static int first = 1; | 36 | +``-old-param`` option for booting Arm kernels via param_struct (since 10.0) |
37 | + static int bootcount; | 37 | +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' |
38 | 38 | + | |
39 | - /* Restore boot order and remove ourselves after the first boot */ | 39 | +The ``-old-param`` command line option is specific to Arm targets: |
40 | - if (first) { | 40 | +it is used when directly booting a guest kernel to pass it the |
41 | - first = 0; | 41 | +command line and other information via the old ``param_struct`` ABI, |
42 | + switch (bootcount++) { | 42 | +rather than the newer ATAGS or DTB mechanisms. This option was only |
43 | + case 0: | 43 | +ever needed to support ancient kernels on some old board types |
44 | + /* First boot: use the one-time config */ | 44 | +like the ``akita`` or ``terrier``; it has been deprecated in the |
45 | + return; | 45 | +kernel since 2001. None of the board types QEMU supports need |
46 | + case 1: | 46 | +``param_struct`` support, so this option has been deprecated and will |
47 | + /* Second boot: restore normal boot order */ | 47 | +be removed in a future QEMU version. |
48 | + if (boot_set_handler) { | 48 | + |
49 | + qemu_boot_set(normal_boot_order, &error_abort); | 49 | User-mode emulator command line arguments |
50 | + } | 50 | ----------------------------------------- |
51 | + g_free(normal_boot_order); | 51 | |
52 | + return; | 52 | diff --git a/system/vl.c b/system/vl.c |
53 | + default: | 53 | index XXXXXXX..XXXXXXX 100644 |
54 | + /* Subsequent boots: keep using normal boot order */ | 54 | --- a/system/vl.c |
55 | return; | 55 | +++ b/system/vl.c |
56 | } | 56 | @@ -XXX,XX +XXX,XX @@ void qemu_init(int argc, char **argv) |
57 | - | 57 | nb_prom_envs++; |
58 | - if (boot_set_handler) { | 58 | break; |
59 | - qemu_boot_set(normal_boot_order, &error_abort); | 59 | case QEMU_OPTION_old_param: |
60 | - } | 60 | + warn_report("-old-param is deprecated"); |
61 | - | 61 | old_param = 1; |
62 | - qemu_unregister_reset(restore_boot_order, normal_boot_order); | 62 | break; |
63 | - g_free(normal_boot_order); | 63 | case QEMU_OPTION_rtc: |
64 | } | ||
65 | |||
66 | void check_boot_index(int32_t bootindex, Error **errp) | ||
67 | -- | 64 | -- |
68 | 2.34.1 | 65 | 2.34.1 |
69 | 66 | ||
70 | 67 | diff view generated by jsdifflib |
1 | From: Sai Pavan Boddu <sai.pavan.boddu@amd.com> | 1 | From: Khem Raj <raj.khem@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | The OSPI DMA reads flash data through the OSPI linear address space (the | 3 | glibc 2.41+ has added [1] definitions for sched_setattr and |
4 | iomem_dac region), because of this the reentrancy guard introduced in | 4 | sched_getattr functions and struct sched_attr. Therefore, it needs |
5 | commit a2e1753b ("memory: prevent dma-reentracy issues") is disabled for | 5 | to be checked for here as well before defining sched_attr, to avoid |
6 | the memory region. | 6 | a compilation failure. |
7 | 7 | ||
8 | Signed-off-by: Sai Pavan Boddu <sai.pavan.boddu@amd.com> | 8 | Define sched_attr conditionally only when SCHED_ATTR_SIZE_VER0 is |
9 | Message-id: 20240219105637.65052-1-sai.pavan.boddu@amd.com | 9 | not defined. |
10 | |||
11 | [1] https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=21571ca0d70302909cf72707b2a7736cf12190a0;hp=298bc488fdc047da37482f4003023cb9adef78f8 | ||
12 | |||
13 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
14 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2799 | ||
15 | Cc: qemu-stable@nongnu.org | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 18 | --- |
13 | hw/ssi/xlnx-versal-ospi.c | 6 ++++++ | 19 | linux-user/syscall.c | 4 +++- |
14 | 1 file changed, 6 insertions(+) | 20 | 1 file changed, 3 insertions(+), 1 deletion(-) |
15 | 21 | ||
16 | diff --git a/hw/ssi/xlnx-versal-ospi.c b/hw/ssi/xlnx-versal-ospi.c | 22 | diff --git a/linux-user/syscall.c b/linux-user/syscall.c |
17 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/ssi/xlnx-versal-ospi.c | 24 | --- a/linux-user/syscall.c |
19 | +++ b/hw/ssi/xlnx-versal-ospi.c | 25 | +++ b/linux-user/syscall.c |
20 | @@ -XXX,XX +XXX,XX @@ static void xlnx_versal_ospi_init(Object *obj) | 26 | @@ -XXX,XX +XXX,XX @@ _syscall3(int, sys_sched_getaffinity, pid_t, pid, unsigned int, len, |
21 | memory_region_init_io(&s->iomem_dac, obj, &ospi_dac_ops, s, | 27 | #define __NR_sys_sched_setaffinity __NR_sched_setaffinity |
22 | TYPE_XILINX_VERSAL_OSPI "-dac", 0x20000000); | 28 | _syscall3(int, sys_sched_setaffinity, pid_t, pid, unsigned int, len, |
23 | sysbus_init_mmio(sbd, &s->iomem_dac); | 29 | unsigned long *, user_mask_ptr); |
24 | + /* | 30 | -/* sched_attr is not defined in glibc */ |
25 | + * The OSPI DMA reads flash data through the OSPI linear address space (the | 31 | +/* sched_attr is not defined in glibc < 2.41 */ |
26 | + * iomem_dac region), because of this the reentrancy guard needs to be | 32 | +#ifndef SCHED_ATTR_SIZE_VER0 |
27 | + * disabled. | 33 | struct sched_attr { |
28 | + */ | 34 | uint32_t size; |
29 | + s->iomem_dac.disable_reentrancy_guard = true; | 35 | uint32_t sched_policy; |
30 | 36 | @@ -XXX,XX +XXX,XX @@ struct sched_attr { | |
31 | sysbus_init_irq(sbd, &s->irq); | 37 | uint32_t sched_util_min; |
32 | 38 | uint32_t sched_util_max; | |
39 | }; | ||
40 | +#endif | ||
41 | #define __NR_sys_sched_getattr __NR_sched_getattr | ||
42 | _syscall4(int, sys_sched_getattr, pid_t, pid, struct sched_attr *, attr, | ||
43 | unsigned int, size, unsigned int, flags); | ||
33 | -- | 44 | -- |
34 | 2.34.1 | 45 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Inès Varhol <ines.varhol@telecom-paris.fr> | ||
2 | 1 | ||
3 | This commit adds a QTest that verifies each input line of a specific | ||
4 | EXTI OR gate can influence the output line. | ||
5 | |||
6 | Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Message-id: 20240220184145.106107-3-ines.varhol@telecom-paris.fr | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | tests/qtest/stm32l4x5_exti-test.c | 37 +++++++++++++++++++++++++++++++ | ||
12 | 1 file changed, 37 insertions(+) | ||
13 | |||
14 | diff --git a/tests/qtest/stm32l4x5_exti-test.c b/tests/qtest/stm32l4x5_exti-test.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/tests/qtest/stm32l4x5_exti-test.c | ||
17 | +++ b/tests/qtest/stm32l4x5_exti-test.c | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | |||
20 | #define EXTI0_IRQ 6 | ||
21 | #define EXTI1_IRQ 7 | ||
22 | +#define EXTI5_9_IRQ 23 | ||
23 | #define EXTI35_IRQ 1 | ||
24 | |||
25 | static void enable_nvic_irq(unsigned int n) | ||
26 | @@ -XXX,XX +XXX,XX @@ static void test_interrupt(void) | ||
27 | g_assert_false(check_nvic_pending(EXTI1_IRQ)); | ||
28 | } | ||
29 | |||
30 | +static void test_orred_interrupts(void) | ||
31 | +{ | ||
32 | + /* | ||
33 | + * For lines EXTI5..9 (fanned-in to NVIC irq 23), | ||
34 | + * test that raising the line pends interrupt | ||
35 | + * 23 in NVIC. | ||
36 | + */ | ||
37 | + enable_nvic_irq(EXTI5_9_IRQ); | ||
38 | + /* Check that there are no interrupts already pending in PR */ | ||
39 | + g_assert_cmpuint(exti_readl(EXTI_PR1), ==, 0x00000000); | ||
40 | + /* Check that this specific interrupt isn't pending in NVIC */ | ||
41 | + g_assert_false(check_nvic_pending(EXTI5_9_IRQ)); | ||
42 | + | ||
43 | + /* Enable interrupt lines EXTI[5..9] */ | ||
44 | + exti_writel(EXTI_IMR1, (0x1F << 5)); | ||
45 | + | ||
46 | + /* Configure interrupt on rising edge */ | ||
47 | + exti_writel(EXTI_RTSR1, (0x1F << 5)); | ||
48 | + | ||
49 | + /* Raise GPIO line i, check that the interrupt is pending */ | ||
50 | + for (unsigned i = 5; i < 10; i++) { | ||
51 | + exti_set_irq(i, 1); | ||
52 | + g_assert_cmpuint(exti_readl(EXTI_PR1), ==, 1 << i); | ||
53 | + g_assert_true(check_nvic_pending(EXTI5_9_IRQ)); | ||
54 | + | ||
55 | + exti_writel(EXTI_PR1, 1 << i); | ||
56 | + g_assert_cmpuint(exti_readl(EXTI_PR1), ==, 0x00000000); | ||
57 | + g_assert_true(check_nvic_pending(EXTI5_9_IRQ)); | ||
58 | + | ||
59 | + unpend_nvic_irq(EXTI5_9_IRQ); | ||
60 | + g_assert_false(check_nvic_pending(EXTI5_9_IRQ)); | ||
61 | + } | ||
62 | +} | ||
63 | + | ||
64 | int main(int argc, char **argv) | ||
65 | { | ||
66 | int ret; | ||
67 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) | ||
68 | qtest_add_func("stm32l4x5/exti/masked_interrupt", test_masked_interrupt); | ||
69 | qtest_add_func("stm32l4x5/exti/interrupt", test_interrupt); | ||
70 | qtest_add_func("stm32l4x5/exti/test_edge_selector", test_edge_selector); | ||
71 | + qtest_add_func("stm32l4x5/exti/test_orred_interrupts", | ||
72 | + test_orred_interrupts); | ||
73 | |||
74 | qtest_start("-machine b-l475e-iot01a"); | ||
75 | ret = g_test_run(); | ||
76 | -- | ||
77 | 2.34.1 | ||
78 | |||
79 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Sai Pavan Boddu <sai.pavan.boddu@amd.com> | ||
2 | 1 | ||
3 | Add Micro 2Gb OSPI flash part with sfdp data. | ||
4 | |||
5 | Signed-off-by: Sai Pavan Boddu <sai.pavan.boddu@amd.com> | ||
6 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | ||
7 | Message-id: 20240220091721.82954-2-sai.pavan.boddu@amd.com | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | hw/block/m25p80_sfdp.h | 1 + | ||
11 | hw/block/m25p80.c | 3 +++ | ||
12 | hw/block/m25p80_sfdp.c | 36 ++++++++++++++++++++++++++++++++++++ | ||
13 | 3 files changed, 40 insertions(+) | ||
14 | |||
15 | diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/block/m25p80_sfdp.h | ||
18 | +++ b/hw/block/m25p80_sfdp.h | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | #define M25P80_SFDP_MAX_SIZE (1 << 24) | ||
21 | |||
22 | uint8_t m25p80_sfdp_n25q256a(uint32_t addr); | ||
23 | +uint8_t m25p80_sfdp_mt35xu02g(uint32_t addr); | ||
24 | |||
25 | uint8_t m25p80_sfdp_mx25l25635e(uint32_t addr); | ||
26 | uint8_t m25p80_sfdp_mx25l25635f(uint32_t addr); | ||
27 | diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/hw/block/m25p80.c | ||
30 | +++ b/hw/block/m25p80.c | ||
31 | @@ -XXX,XX +XXX,XX @@ static const FlashPartInfo known_devices[] = { | ||
32 | { INFO("mt25ql512ab", 0x20ba20, 0x1044, 64 << 10, 1024, ER_4K | ER_32K) }, | ||
33 | { INFO_STACKED("mt35xu01g", 0x2c5b1b, 0x104100, 128 << 10, 1024, | ||
34 | ER_4K | ER_32K, 2) }, | ||
35 | + { INFO_STACKED("mt35xu02gbba", 0x2c5b1c, 0x104100, 128 << 10, 2048, | ||
36 | + ER_4K | ER_32K, 4), | ||
37 | + .sfdp_read = m25p80_sfdp_mt35xu02g }, | ||
38 | { INFO_STACKED("n25q00", 0x20ba21, 0x1000, 64 << 10, 2048, ER_4K, 4) }, | ||
39 | { INFO_STACKED("n25q00a", 0x20bb21, 0x1000, 64 << 10, 2048, ER_4K, 4) }, | ||
40 | { INFO_STACKED("mt25ql01g", 0x20ba21, 0x1040, 64 << 10, 2048, ER_4K, 2) }, | ||
41 | diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/hw/block/m25p80_sfdp.c | ||
44 | +++ b/hw/block/m25p80_sfdp.c | ||
45 | @@ -XXX,XX +XXX,XX @@ static const uint8_t sfdp_n25q256a[] = { | ||
46 | }; | ||
47 | define_sfdp_read(n25q256a); | ||
48 | |||
49 | +static const uint8_t sfdp_mt35xu02g[] = { | ||
50 | + 0x53, 0x46, 0x44, 0x50, 0x06, 0x01, 0x01, 0xff, | ||
51 | + 0x00, 0x06, 0x01, 0x10, 0x30, 0x00, 0x00, 0xff, | ||
52 | + 0x84, 0x00, 0x01, 0x02, 0x80, 0x00, 0x00, 0xff, | ||
53 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
54 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
55 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
56 | + 0xe5, 0x20, 0x8a, 0xff, 0xff, 0xff, 0xff, 0x7f, | ||
57 | + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
58 | + 0xee, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, | ||
59 | + 0xff, 0xff, 0x00, 0x00, 0x0c, 0x20, 0x11, 0xd8, | ||
60 | + 0x0f, 0x52, 0x00, 0x00, 0x24, 0x5a, 0x99, 0x00, | ||
61 | + 0x8b, 0x8e, 0x03, 0xe1, 0xac, 0x01, 0x27, 0x38, | ||
62 | + 0x7a, 0x75, 0x7a, 0x75, 0xfb, 0xbd, 0xd5, 0x5c, | ||
63 | + 0x00, 0x00, 0x70, 0xff, 0x81, 0xb0, 0x38, 0x36, | ||
64 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
65 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
66 | + 0x43, 0x0e, 0xff, 0xff, 0x21, 0xdc, 0x5c, 0xff, | ||
67 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
68 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
69 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
70 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
71 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
72 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
73 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
74 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
75 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
76 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
77 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
78 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
79 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
80 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
81 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
82 | +}; | ||
83 | + | ||
84 | +define_sfdp_read(mt35xu02g); | ||
85 | |||
86 | /* | ||
87 | * Matronix | ||
88 | -- | ||
89 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Jonathan Cameron <Jonathan.Cameron@huawei.com> | ||
2 | 1 | ||
3 | I'm far from confident this handling here is correct. Hence | ||
4 | RFC. In particular not sure on what locks I should hold for this | ||
5 | to be even moderately safe. | ||
6 | |||
7 | The function already appears to be inconsistent in what it returns | ||
8 | as the CONFIG_ATOMIC64 block returns the endian converted 'eventual' | ||
9 | value of the cmpxchg whereas the TCG_OVERSIZED_GUEST case returns | ||
10 | the previous value. | ||
11 | |||
12 | Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> | ||
13 | Message-id: 20240219161229.11776-1-Jonathan.Cameron@huawei.com | ||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | target/arm/ptw.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++-- | ||
18 | 1 file changed, 62 insertions(+), 2 deletions(-) | ||
19 | |||
20 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/target/arm/ptw.c | ||
23 | +++ b/target/arm/ptw.c | ||
24 | @@ -XXX,XX +XXX,XX @@ static uint64_t arm_casq_ptw(CPUARMState *env, uint64_t old_val, | ||
25 | void *host = ptw->out_host; | ||
26 | |||
27 | if (unlikely(!host)) { | ||
28 | - fi->type = ARMFault_UnsuppAtomicUpdate; | ||
29 | - return 0; | ||
30 | + /* Page table in MMIO Memory Region */ | ||
31 | + CPUState *cs = env_cpu(env); | ||
32 | + MemTxAttrs attrs = { | ||
33 | + .space = ptw->out_space, | ||
34 | + .secure = arm_space_is_secure(ptw->out_space), | ||
35 | + }; | ||
36 | + AddressSpace *as = arm_addressspace(cs, attrs); | ||
37 | + MemTxResult result = MEMTX_OK; | ||
38 | + bool need_lock = !bql_locked(); | ||
39 | + | ||
40 | + if (need_lock) { | ||
41 | + bql_lock(); | ||
42 | + } | ||
43 | + if (ptw->out_be) { | ||
44 | + cur_val = address_space_ldq_be(as, ptw->out_phys, attrs, &result); | ||
45 | + if (unlikely(result != MEMTX_OK)) { | ||
46 | + fi->type = ARMFault_SyncExternalOnWalk; | ||
47 | + fi->ea = arm_extabort_type(result); | ||
48 | + if (need_lock) { | ||
49 | + bql_unlock(); | ||
50 | + } | ||
51 | + return old_val; | ||
52 | + } | ||
53 | + if (cur_val == old_val) { | ||
54 | + address_space_stq_be(as, ptw->out_phys, new_val, attrs, &result); | ||
55 | + if (unlikely(result != MEMTX_OK)) { | ||
56 | + fi->type = ARMFault_SyncExternalOnWalk; | ||
57 | + fi->ea = arm_extabort_type(result); | ||
58 | + if (need_lock) { | ||
59 | + bql_unlock(); | ||
60 | + } | ||
61 | + return old_val; | ||
62 | + } | ||
63 | + cur_val = new_val; | ||
64 | + } | ||
65 | + } else { | ||
66 | + cur_val = address_space_ldq_le(as, ptw->out_phys, attrs, &result); | ||
67 | + if (unlikely(result != MEMTX_OK)) { | ||
68 | + fi->type = ARMFault_SyncExternalOnWalk; | ||
69 | + fi->ea = arm_extabort_type(result); | ||
70 | + if (need_lock) { | ||
71 | + bql_unlock(); | ||
72 | + } | ||
73 | + return old_val; | ||
74 | + } | ||
75 | + if (cur_val == old_val) { | ||
76 | + address_space_stq_le(as, ptw->out_phys, new_val, attrs, &result); | ||
77 | + if (unlikely(result != MEMTX_OK)) { | ||
78 | + fi->type = ARMFault_SyncExternalOnWalk; | ||
79 | + fi->ea = arm_extabort_type(result); | ||
80 | + if (need_lock) { | ||
81 | + bql_unlock(); | ||
82 | + } | ||
83 | + return old_val; | ||
84 | + } | ||
85 | + cur_val = new_val; | ||
86 | + } | ||
87 | + } | ||
88 | + if (need_lock) { | ||
89 | + bql_unlock(); | ||
90 | + } | ||
91 | + return cur_val; | ||
92 | } | ||
93 | |||
94 | /* | ||
95 | -- | ||
96 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | We have an OBJECT_DEFINE_TYPE_EXTENDED macro, plus several variations | ||
2 | on it, which emits the boilerplate for the TypeInfo and ensures it is | ||
3 | registered with the type system. However, all the existing macros | ||
4 | insist that the type being defined has its own FooClass struct, so | ||
5 | they aren't useful for the common case of a simple leaf class which | ||
6 | doesn't have any new methods or any other need for its own class | ||
7 | struct (that is, for the kind of type that OBJECT_DECLARE_SIMPLE_TYPE | ||
8 | declares). | ||
9 | 1 | ||
10 | Pull the actual implementation of OBJECT_DEFINE_TYPE_EXTENDED out | ||
11 | into a new DO_OBJECT_DEFINE_TYPE_EXTENDED which parameterizes the | ||
12 | value we use for the class_size field. This lets us add a new | ||
13 | OBJECT_DEFINE_SIMPLE_TYPE which does the same job as the various | ||
14 | existing OBJECT_DEFINE_*_TYPE_* family macros for this kind of simple | ||
15 | type, and the variant OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES for | ||
16 | when the type will implement some interfaces. | ||
17 | |||
18 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> | ||
21 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
22 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
23 | Message-id: 20240220160622.114437-5-peter.maydell@linaro.org | ||
24 | Reviewed-by: Zhao Liu <zhao1.liu@intel.com> | ||
25 | --- | ||
26 | docs/devel/qom.rst | 34 +++++++++++-- | ||
27 | include/qom/object.h | 114 +++++++++++++++++++++++++++++++++---------- | ||
28 | 2 files changed, 117 insertions(+), 31 deletions(-) | ||
29 | |||
30 | diff --git a/docs/devel/qom.rst b/docs/devel/qom.rst | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/docs/devel/qom.rst | ||
33 | +++ b/docs/devel/qom.rst | ||
34 | @@ -XXX,XX +XXX,XX @@ used. This does the same as OBJECT_DECLARE_SIMPLE_TYPE(), but without | ||
35 | the 'struct MyDeviceClass' definition. | ||
36 | |||
37 | To implement the type, the OBJECT_DEFINE macro family is available. | ||
38 | -In the simple case the OBJECT_DEFINE_TYPE macro is suitable: | ||
39 | +For the simplest case of a leaf class which doesn't need any of its | ||
40 | +own virtual functions (i.e. which was declared with OBJECT_DECLARE_SIMPLE_TYPE) | ||
41 | +the OBJECT_DEFINE_SIMPLE_TYPE macro is suitable: | ||
42 | |||
43 | .. code-block:: c | ||
44 | :caption: Defining a simple type | ||
45 | |||
46 | - OBJECT_DEFINE_TYPE(MyDevice, my_device, MY_DEVICE, DEVICE) | ||
47 | + OBJECT_DEFINE_SIMPLE_TYPE(MyDevice, my_device, MY_DEVICE, DEVICE) | ||
48 | |||
49 | This is equivalent to the following: | ||
50 | |||
51 | @@ -XXX,XX +XXX,XX @@ This is equivalent to the following: | ||
52 | .instance_size = sizeof(MyDevice), | ||
53 | .instance_init = my_device_init, | ||
54 | .instance_finalize = my_device_finalize, | ||
55 | - .class_size = sizeof(MyDeviceClass), | ||
56 | .class_init = my_device_class_init, | ||
57 | }; | ||
58 | |||
59 | @@ -XXX,XX +XXX,XX @@ This is sufficient to get the type registered with the type | ||
60 | system, and the three standard methods now need to be implemented | ||
61 | along with any other logic required for the type. | ||
62 | |||
63 | +If the class needs its own virtual methods, or has some other | ||
64 | +per-class state it needs to store in its own class struct, | ||
65 | +then you can use the OBJECT_DEFINE_TYPE macro. This does the | ||
66 | +same thing as OBJECT_DEFINE_SIMPLE_TYPE, but it also sets the | ||
67 | +class_size of the type to the size of the class struct. | ||
68 | + | ||
69 | +.. code-block:: c | ||
70 | + :caption: Defining a type which needs a class struct | ||
71 | + | ||
72 | + OBJECT_DEFINE_TYPE(MyDevice, my_device, MY_DEVICE, DEVICE) | ||
73 | + | ||
74 | If the type needs to implement one or more interfaces, then the | ||
75 | -OBJECT_DEFINE_TYPE_WITH_INTERFACES() macro can be used instead. | ||
76 | -This accepts an array of interface type names. | ||
77 | +OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES() and | ||
78 | +OBJECT_DEFINE_TYPE_WITH_INTERFACES() macros can be used instead. | ||
79 | +These accept an array of interface type names. The difference between | ||
80 | +them is that the former is for simple leaf classes that don't need | ||
81 | +a class struct, and the latter is for when you will be defining | ||
82 | +a class struct. | ||
83 | |||
84 | .. code-block:: c | ||
85 | :caption: Defining a simple type implementing interfaces | ||
86 | |||
87 | + OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES(MyDevice, my_device, | ||
88 | + MY_DEVICE, DEVICE, | ||
89 | + { TYPE_USER_CREATABLE }, | ||
90 | + { NULL }) | ||
91 | + | ||
92 | +.. code-block:: c | ||
93 | + :caption: Defining a type implementing interfaces | ||
94 | + | ||
95 | OBJECT_DEFINE_TYPE_WITH_INTERFACES(MyDevice, my_device, | ||
96 | MY_DEVICE, DEVICE, | ||
97 | { TYPE_USER_CREATABLE }, | ||
98 | diff --git a/include/qom/object.h b/include/qom/object.h | ||
99 | index XXXXXXX..XXXXXXX 100644 | ||
100 | --- a/include/qom/object.h | ||
101 | +++ b/include/qom/object.h | ||
102 | @@ -XXX,XX +XXX,XX @@ struct Object | ||
103 | DECLARE_INSTANCE_CHECKER(InstanceType, MODULE_OBJ_NAME, TYPE_##MODULE_OBJ_NAME) | ||
104 | |||
105 | |||
106 | +/** | ||
107 | + * DO_OBJECT_DEFINE_TYPE_EXTENDED: | ||
108 | + * @ModuleObjName: the object name with initial caps | ||
109 | + * @module_obj_name: the object name in lowercase with underscore separators | ||
110 | + * @MODULE_OBJ_NAME: the object name in uppercase with underscore separators | ||
111 | + * @PARENT_MODULE_OBJ_NAME: the parent object name in uppercase with underscore | ||
112 | + * separators | ||
113 | + * @ABSTRACT: boolean flag to indicate whether the object can be instantiated | ||
114 | + * @CLASS_SIZE: size of the type's class | ||
115 | + * @...: list of initializers for "InterfaceInfo" to declare implemented interfaces | ||
116 | + * | ||
117 | + * This is the base macro used to implement all the OBJECT_DEFINE_* | ||
118 | + * macros. It should never be used directly in a source file. | ||
119 | + */ | ||
120 | +#define DO_OBJECT_DEFINE_TYPE_EXTENDED(ModuleObjName, module_obj_name, \ | ||
121 | + MODULE_OBJ_NAME, \ | ||
122 | + PARENT_MODULE_OBJ_NAME, \ | ||
123 | + ABSTRACT, CLASS_SIZE, ...) \ | ||
124 | + static void \ | ||
125 | + module_obj_name##_finalize(Object *obj); \ | ||
126 | + static void \ | ||
127 | + module_obj_name##_class_init(ObjectClass *oc, void *data); \ | ||
128 | + static void \ | ||
129 | + module_obj_name##_init(Object *obj); \ | ||
130 | + \ | ||
131 | + static const TypeInfo module_obj_name##_info = { \ | ||
132 | + .parent = TYPE_##PARENT_MODULE_OBJ_NAME, \ | ||
133 | + .name = TYPE_##MODULE_OBJ_NAME, \ | ||
134 | + .instance_size = sizeof(ModuleObjName), \ | ||
135 | + .instance_align = __alignof__(ModuleObjName), \ | ||
136 | + .instance_init = module_obj_name##_init, \ | ||
137 | + .instance_finalize = module_obj_name##_finalize, \ | ||
138 | + .class_size = CLASS_SIZE, \ | ||
139 | + .class_init = module_obj_name##_class_init, \ | ||
140 | + .abstract = ABSTRACT, \ | ||
141 | + .interfaces = (InterfaceInfo[]) { __VA_ARGS__ } , \ | ||
142 | + }; \ | ||
143 | + \ | ||
144 | + static void \ | ||
145 | + module_obj_name##_register_types(void) \ | ||
146 | + { \ | ||
147 | + type_register_static(&module_obj_name##_info); \ | ||
148 | + } \ | ||
149 | + type_init(module_obj_name##_register_types); | ||
150 | + | ||
151 | /** | ||
152 | * OBJECT_DEFINE_TYPE_EXTENDED: | ||
153 | * @ModuleObjName: the object name with initial caps | ||
154 | @@ -XXX,XX +XXX,XX @@ struct Object | ||
155 | #define OBJECT_DEFINE_TYPE_EXTENDED(ModuleObjName, module_obj_name, \ | ||
156 | MODULE_OBJ_NAME, PARENT_MODULE_OBJ_NAME, \ | ||
157 | ABSTRACT, ...) \ | ||
158 | - static void \ | ||
159 | - module_obj_name##_finalize(Object *obj); \ | ||
160 | - static void \ | ||
161 | - module_obj_name##_class_init(ObjectClass *oc, void *data); \ | ||
162 | - static void \ | ||
163 | - module_obj_name##_init(Object *obj); \ | ||
164 | - \ | ||
165 | - static const TypeInfo module_obj_name##_info = { \ | ||
166 | - .parent = TYPE_##PARENT_MODULE_OBJ_NAME, \ | ||
167 | - .name = TYPE_##MODULE_OBJ_NAME, \ | ||
168 | - .instance_size = sizeof(ModuleObjName), \ | ||
169 | - .instance_align = __alignof__(ModuleObjName), \ | ||
170 | - .instance_init = module_obj_name##_init, \ | ||
171 | - .instance_finalize = module_obj_name##_finalize, \ | ||
172 | - .class_size = sizeof(ModuleObjName##Class), \ | ||
173 | - .class_init = module_obj_name##_class_init, \ | ||
174 | - .abstract = ABSTRACT, \ | ||
175 | - .interfaces = (InterfaceInfo[]) { __VA_ARGS__ } , \ | ||
176 | - }; \ | ||
177 | - \ | ||
178 | - static void \ | ||
179 | - module_obj_name##_register_types(void) \ | ||
180 | - { \ | ||
181 | - type_register_static(&module_obj_name##_info); \ | ||
182 | - } \ | ||
183 | - type_init(module_obj_name##_register_types); | ||
184 | + DO_OBJECT_DEFINE_TYPE_EXTENDED(ModuleObjName, module_obj_name, \ | ||
185 | + MODULE_OBJ_NAME, PARENT_MODULE_OBJ_NAME, \ | ||
186 | + ABSTRACT, sizeof(ModuleObjName##Class), \ | ||
187 | + __VA_ARGS__) | ||
188 | |||
189 | /** | ||
190 | * OBJECT_DEFINE_TYPE: | ||
191 | @@ -XXX,XX +XXX,XX @@ struct Object | ||
192 | MODULE_OBJ_NAME, PARENT_MODULE_OBJ_NAME, \ | ||
193 | true, { NULL }) | ||
194 | |||
195 | +/** | ||
196 | + * OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES: | ||
197 | + * @ModuleObjName: the object name with initial caps | ||
198 | + * @module_obj_name: the object name in lowercase with underscore separators | ||
199 | + * @MODULE_OBJ_NAME: the object name in uppercase with underscore separators | ||
200 | + * @PARENT_MODULE_OBJ_NAME: the parent object name in uppercase with underscore | ||
201 | + * separators | ||
202 | + * | ||
203 | + * This is a variant of OBJECT_DEFINE_TYPE_EXTENDED, which is suitable for | ||
204 | + * the case of a non-abstract type, with interfaces, and with no requirement | ||
205 | + * for a class struct. | ||
206 | + */ | ||
207 | +#define OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES(ModuleObjName, \ | ||
208 | + module_obj_name, \ | ||
209 | + MODULE_OBJ_NAME, \ | ||
210 | + PARENT_MODULE_OBJ_NAME, ...) \ | ||
211 | + DO_OBJECT_DEFINE_TYPE_EXTENDED(ModuleObjName, module_obj_name, \ | ||
212 | + MODULE_OBJ_NAME, PARENT_MODULE_OBJ_NAME, \ | ||
213 | + false, 0, __VA_ARGS__) | ||
214 | + | ||
215 | +/** | ||
216 | + * OBJECT_DEFINE_SIMPLE_TYPE: | ||
217 | + * @ModuleObjName: the object name with initial caps | ||
218 | + * @module_obj_name: the object name in lowercase with underscore separators | ||
219 | + * @MODULE_OBJ_NAME: the object name in uppercase with underscore separators | ||
220 | + * @PARENT_MODULE_OBJ_NAME: the parent object name in uppercase with underscore | ||
221 | + * separators | ||
222 | + * | ||
223 | + * This is a variant of OBJECT_DEFINE_TYPE_EXTENDED, which is suitable for | ||
224 | + * the common case of a non-abstract type, without any interfaces, and with | ||
225 | + * no requirement for a class struct. If you declared your type with | ||
226 | + * OBJECT_DECLARE_SIMPLE_TYPE then this is probably the right choice for | ||
227 | + * defining it. | ||
228 | + */ | ||
229 | +#define OBJECT_DEFINE_SIMPLE_TYPE(ModuleObjName, module_obj_name, \ | ||
230 | + MODULE_OBJ_NAME, PARENT_MODULE_OBJ_NAME) \ | ||
231 | + OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES(ModuleObjName, module_obj_name, \ | ||
232 | + MODULE_OBJ_NAME, PARENT_MODULE_OBJ_NAME, { NULL }) | ||
233 | + | ||
234 | /** | ||
235 | * struct TypeInfo: | ||
236 | * @name: The name of the type. | ||
237 | -- | ||
238 | 2.34.1 | ||
239 | |||
240 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement new functions qemu_register_resettable() and | ||
2 | qemu_unregister_resettable(). These are intended to be | ||
3 | three-phase-reset aware equivalents of the old qemu_register_reset() | ||
4 | and qemu_unregister_reset(). Instead of passing in a function | ||
5 | pointer and opaque, you register any QOM object that implements the | ||
6 | Resettable interface. | ||
7 | 1 | ||
8 | The implementation is simple: we have a single global instance of a | ||
9 | ResettableContainer, which we reset in qemu_devices_reset(), and | ||
10 | the Resettable objects passed to qemu_register_resettable() are | ||
11 | added to it. | ||
12 | |||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> | ||
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
17 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
18 | Message-id: 20240220160622.114437-8-peter.maydell@linaro.org | ||
19 | Reviewed-by: Zhao Liu <zhao1.liu@intel.com> | ||
20 | --- | ||
21 | include/sysemu/reset.h | 37 ++++++++++++++++++++++++++++++++++--- | ||
22 | hw/core/reset.c | 31 +++++++++++++++++++++++++++++-- | ||
23 | 2 files changed, 63 insertions(+), 5 deletions(-) | ||
24 | |||
25 | diff --git a/include/sysemu/reset.h b/include/sysemu/reset.h | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/include/sysemu/reset.h | ||
28 | +++ b/include/sysemu/reset.h | ||
29 | @@ -XXX,XX +XXX,XX @@ | ||
30 | |||
31 | typedef void QEMUResetHandler(void *opaque); | ||
32 | |||
33 | +/** | ||
34 | + * qemu_register_resettable: Register an object to be reset | ||
35 | + * @obj: object to be reset: it must implement the Resettable interface | ||
36 | + * | ||
37 | + * Register @obj on the list of objects which will be reset when the | ||
38 | + * simulation is reset. These objects will be reset in the order | ||
39 | + * they were added, using the three-phase Resettable protocol, | ||
40 | + * so first all objects go through the enter phase, then all objects | ||
41 | + * go through the hold phase, and then finally all go through the | ||
42 | + * exit phase. | ||
43 | + * | ||
44 | + * It is not permitted to register or unregister reset functions or | ||
45 | + * resettable objects from within any of the reset phase methods of @obj. | ||
46 | + * | ||
47 | + * We assume that the caller holds the BQL. | ||
48 | + */ | ||
49 | +void qemu_register_resettable(Object *obj); | ||
50 | + | ||
51 | +/** | ||
52 | + * qemu_unregister_resettable: Unregister an object to be reset | ||
53 | + * @obj: object to unregister | ||
54 | + * | ||
55 | + * Remove @obj from the list of objects which are reset when the | ||
56 | + * simulation is reset. It must have been previously added to | ||
57 | + * the list via qemu_register_resettable(). | ||
58 | + * | ||
59 | + * We assume that the caller holds the BQL. | ||
60 | + */ | ||
61 | +void qemu_unregister_resettable(Object *obj); | ||
62 | + | ||
63 | /** | ||
64 | * qemu_register_reset: Register a callback for system reset | ||
65 | * @func: function to call | ||
66 | @@ -XXX,XX +XXX,XX @@ typedef void QEMUResetHandler(void *opaque); | ||
67 | * for instance, device model reset is better accomplished using the | ||
68 | * methods on DeviceState. | ||
69 | * | ||
70 | - * It is not permitted to register or unregister reset functions from | ||
71 | - * within the @func callback. | ||
72 | + * It is not permitted to register or unregister reset functions or | ||
73 | + * resettable objects from within the @func callback. | ||
74 | * | ||
75 | * We assume that the caller holds the BQL. | ||
76 | */ | ||
77 | @@ -XXX,XX +XXX,XX @@ void qemu_unregister_reset(QEMUResetHandler *func, void *opaque); | ||
78 | * | ||
79 | * This function performs the low-level work needed to do a complete reset | ||
80 | * of the system (calling all the callbacks registered with | ||
81 | - * qemu_register_reset()). It should only be called by the code in a | ||
82 | + * qemu_register_reset() and resetting all the Resettable objects registered | ||
83 | + * with qemu_register_resettable()). It should only be called by the code in a | ||
84 | * MachineClass reset method. | ||
85 | * | ||
86 | * If you want to trigger a system reset from, for instance, a device | ||
87 | diff --git a/hw/core/reset.c b/hw/core/reset.c | ||
88 | index XXXXXXX..XXXXXXX 100644 | ||
89 | --- a/hw/core/reset.c | ||
90 | +++ b/hw/core/reset.c | ||
91 | @@ -XXX,XX +XXX,XX @@ | ||
92 | #include "qemu/osdep.h" | ||
93 | #include "qemu/queue.h" | ||
94 | #include "sysemu/reset.h" | ||
95 | +#include "hw/resettable.h" | ||
96 | +#include "hw/core/resetcontainer.h" | ||
97 | |||
98 | -/* reset/shutdown handler */ | ||
99 | +/* | ||
100 | + * Return a pointer to the singleton container that holds all the Resettable | ||
101 | + * items that will be reset when qemu_devices_reset() is called. | ||
102 | + */ | ||
103 | +static ResettableContainer *get_root_reset_container(void) | ||
104 | +{ | ||
105 | + static ResettableContainer *root_reset_container; | ||
106 | + | ||
107 | + if (!root_reset_container) { | ||
108 | + root_reset_container = | ||
109 | + RESETTABLE_CONTAINER(object_new(TYPE_RESETTABLE_CONTAINER)); | ||
110 | + } | ||
111 | + return root_reset_container; | ||
112 | +} | ||
113 | |||
114 | typedef struct QEMUResetEntry { | ||
115 | QTAILQ_ENTRY(QEMUResetEntry) entry; | ||
116 | @@ -XXX,XX +XXX,XX @@ void qemu_unregister_reset(QEMUResetHandler *func, void *opaque) | ||
117 | } | ||
118 | } | ||
119 | |||
120 | +void qemu_register_resettable(Object *obj) | ||
121 | +{ | ||
122 | + resettable_container_add(get_root_reset_container(), obj); | ||
123 | +} | ||
124 | + | ||
125 | +void qemu_unregister_resettable(Object *obj) | ||
126 | +{ | ||
127 | + resettable_container_remove(get_root_reset_container(), obj); | ||
128 | +} | ||
129 | + | ||
130 | void qemu_devices_reset(ShutdownCause reason) | ||
131 | { | ||
132 | QEMUResetEntry *re, *nre; | ||
133 | @@ -XXX,XX +XXX,XX @@ void qemu_devices_reset(ShutdownCause reason) | ||
134 | } | ||
135 | re->func(re->opaque); | ||
136 | } | ||
137 | -} | ||
138 | |||
139 | + /* Reset the simulation */ | ||
140 | + resettable_reset(OBJECT(get_root_reset_container()), RESET_TYPE_COLD); | ||
141 | +} | ||
142 | -- | ||
143 | 2.34.1 | ||
144 | |||
145 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Reimplement qemu_register_reset() via qemu_register_resettable(). | ||
2 | 1 | ||
3 | We define a new LegacyReset object which implements Resettable and | ||
4 | defines its reset hold phase method to call a QEMUResetHandler | ||
5 | function. When qemu_register_reset() is called, we create a new | ||
6 | LegacyReset object and add it to the simulation_reset | ||
7 | ResettableContainer. When qemu_unregister_reset() is called, we find | ||
8 | the LegacyReset object in the container and remove it. | ||
9 | |||
10 | This implementation of qemu_unregister_reset() means we'll end up | ||
11 | scanning the ResetContainer's list of child objects twice, once | ||
12 | to find the LegacyReset object, and once in g_ptr_array_remove(). | ||
13 | In theory we could avoid this by having the ResettableContainer | ||
14 | interface include a resettable_container_remove_with_equal_func() | ||
15 | that took a callback method so that we could use | ||
16 | g_ptr_array_find_with_equal_func() and g_ptr_array_remove_index(). | ||
17 | But we don't expect qemu_unregister_reset() to be called frequently | ||
18 | or in hot paths, and we expect the simulation_reset container to | ||
19 | usually not have many children. | ||
20 | |||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
22 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> | ||
23 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
24 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
25 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
26 | Message-id: 20240220160622.114437-9-peter.maydell@linaro.org | ||
27 | Reviewed-by: Zhao Liu <zhao1.liu@intel.com> | ||
28 | --- | ||
29 | include/sysemu/reset.h | 7 ++- | ||
30 | hw/core/reset.c | 137 +++++++++++++++++++++++++++++++---------- | ||
31 | 2 files changed, 110 insertions(+), 34 deletions(-) | ||
32 | |||
33 | diff --git a/include/sysemu/reset.h b/include/sysemu/reset.h | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/include/sysemu/reset.h | ||
36 | +++ b/include/sysemu/reset.h | ||
37 | @@ -XXX,XX +XXX,XX @@ void qemu_unregister_resettable(Object *obj); | ||
38 | * @opaque: opaque data to pass to @func | ||
39 | * | ||
40 | * Register @func on the list of functions which are called when the | ||
41 | - * entire system is reset. The functions are called in the order in | ||
42 | - * which they are registered. | ||
43 | + * entire system is reset. Functions registered with this API and | ||
44 | + * Resettable objects registered with qemu_register_resettable() are | ||
45 | + * handled together, in the order in which they were registered. | ||
46 | + * Functions registered with this API are called in the 'hold' phase | ||
47 | + * of the 3-phase reset. | ||
48 | * | ||
49 | * In general this function should not be used in new code where possible; | ||
50 | * for instance, device model reset is better accomplished using the | ||
51 | diff --git a/hw/core/reset.c b/hw/core/reset.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/hw/core/reset.c | ||
54 | +++ b/hw/core/reset.c | ||
55 | @@ -XXX,XX +XXX,XX @@ | ||
56 | */ | ||
57 | |||
58 | #include "qemu/osdep.h" | ||
59 | -#include "qemu/queue.h" | ||
60 | #include "sysemu/reset.h" | ||
61 | #include "hw/resettable.h" | ||
62 | #include "hw/core/resetcontainer.h" | ||
63 | @@ -XXX,XX +XXX,XX @@ static ResettableContainer *get_root_reset_container(void) | ||
64 | return root_reset_container; | ||
65 | } | ||
66 | |||
67 | -typedef struct QEMUResetEntry { | ||
68 | - QTAILQ_ENTRY(QEMUResetEntry) entry; | ||
69 | +/* | ||
70 | + * Reason why the currently in-progress qemu_devices_reset() was called. | ||
71 | + * If we made at least SHUTDOWN_CAUSE_SNAPSHOT_LOAD have a corresponding | ||
72 | + * ResetType we could perhaps avoid the need for this global. | ||
73 | + */ | ||
74 | +static ShutdownCause device_reset_reason; | ||
75 | + | ||
76 | +/* | ||
77 | + * This is an Object which implements Resettable simply to call the | ||
78 | + * callback function in the hold phase. | ||
79 | + */ | ||
80 | +#define TYPE_LEGACY_RESET "legacy-reset" | ||
81 | +OBJECT_DECLARE_SIMPLE_TYPE(LegacyReset, LEGACY_RESET) | ||
82 | + | ||
83 | +struct LegacyReset { | ||
84 | + Object parent; | ||
85 | + ResettableState reset_state; | ||
86 | QEMUResetHandler *func; | ||
87 | void *opaque; | ||
88 | bool skip_on_snapshot_load; | ||
89 | -} QEMUResetEntry; | ||
90 | +}; | ||
91 | |||
92 | -static QTAILQ_HEAD(, QEMUResetEntry) reset_handlers = | ||
93 | - QTAILQ_HEAD_INITIALIZER(reset_handlers); | ||
94 | +OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES(LegacyReset, legacy_reset, LEGACY_RESET, OBJECT, { TYPE_RESETTABLE_INTERFACE }, { }) | ||
95 | + | ||
96 | +static ResettableState *legacy_reset_get_state(Object *obj) | ||
97 | +{ | ||
98 | + LegacyReset *lr = LEGACY_RESET(obj); | ||
99 | + return &lr->reset_state; | ||
100 | +} | ||
101 | + | ||
102 | +static void legacy_reset_hold(Object *obj) | ||
103 | +{ | ||
104 | + LegacyReset *lr = LEGACY_RESET(obj); | ||
105 | + | ||
106 | + if (device_reset_reason == SHUTDOWN_CAUSE_SNAPSHOT_LOAD && | ||
107 | + lr->skip_on_snapshot_load) { | ||
108 | + return; | ||
109 | + } | ||
110 | + lr->func(lr->opaque); | ||
111 | +} | ||
112 | + | ||
113 | +static void legacy_reset_init(Object *obj) | ||
114 | +{ | ||
115 | +} | ||
116 | + | ||
117 | +static void legacy_reset_finalize(Object *obj) | ||
118 | +{ | ||
119 | +} | ||
120 | + | ||
121 | +static void legacy_reset_class_init(ObjectClass *klass, void *data) | ||
122 | +{ | ||
123 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
124 | + | ||
125 | + rc->get_state = legacy_reset_get_state; | ||
126 | + rc->phases.hold = legacy_reset_hold; | ||
127 | +} | ||
128 | |||
129 | void qemu_register_reset(QEMUResetHandler *func, void *opaque) | ||
130 | { | ||
131 | - QEMUResetEntry *re = g_new0(QEMUResetEntry, 1); | ||
132 | + Object *obj = object_new(TYPE_LEGACY_RESET); | ||
133 | + LegacyReset *lr = LEGACY_RESET(obj); | ||
134 | |||
135 | - re->func = func; | ||
136 | - re->opaque = opaque; | ||
137 | - QTAILQ_INSERT_TAIL(&reset_handlers, re, entry); | ||
138 | + lr->func = func; | ||
139 | + lr->opaque = opaque; | ||
140 | + qemu_register_resettable(obj); | ||
141 | } | ||
142 | |||
143 | void qemu_register_reset_nosnapshotload(QEMUResetHandler *func, void *opaque) | ||
144 | { | ||
145 | - QEMUResetEntry *re = g_new0(QEMUResetEntry, 1); | ||
146 | + Object *obj = object_new(TYPE_LEGACY_RESET); | ||
147 | + LegacyReset *lr = LEGACY_RESET(obj); | ||
148 | |||
149 | - re->func = func; | ||
150 | - re->opaque = opaque; | ||
151 | - re->skip_on_snapshot_load = true; | ||
152 | - QTAILQ_INSERT_TAIL(&reset_handlers, re, entry); | ||
153 | + lr->func = func; | ||
154 | + lr->opaque = opaque; | ||
155 | + lr->skip_on_snapshot_load = true; | ||
156 | + qemu_register_resettable(obj); | ||
157 | +} | ||
158 | + | ||
159 | +typedef struct FindLegacyInfo { | ||
160 | + QEMUResetHandler *func; | ||
161 | + void *opaque; | ||
162 | + LegacyReset *lr; | ||
163 | +} FindLegacyInfo; | ||
164 | + | ||
165 | +static void find_legacy_reset_cb(Object *obj, void *opaque, ResetType type) | ||
166 | +{ | ||
167 | + LegacyReset *lr; | ||
168 | + FindLegacyInfo *fli = opaque; | ||
169 | + | ||
170 | + /* Not everything in the ResettableContainer will be a LegacyReset */ | ||
171 | + lr = LEGACY_RESET(object_dynamic_cast(obj, TYPE_LEGACY_RESET)); | ||
172 | + if (lr && lr->func == fli->func && lr->opaque == fli->opaque) { | ||
173 | + fli->lr = lr; | ||
174 | + } | ||
175 | +} | ||
176 | + | ||
177 | +static LegacyReset *find_legacy_reset(QEMUResetHandler *func, void *opaque) | ||
178 | +{ | ||
179 | + /* | ||
180 | + * Find the LegacyReset with the specified func and opaque, | ||
181 | + * by getting the ResettableContainer to call our callback for | ||
182 | + * every item in it. | ||
183 | + */ | ||
184 | + ResettableContainer *rootcon = get_root_reset_container(); | ||
185 | + ResettableClass *rc = RESETTABLE_GET_CLASS(rootcon); | ||
186 | + FindLegacyInfo fli; | ||
187 | + | ||
188 | + fli.func = func; | ||
189 | + fli.opaque = opaque; | ||
190 | + fli.lr = NULL; | ||
191 | + rc->child_foreach(OBJECT(rootcon), find_legacy_reset_cb, | ||
192 | + &fli, RESET_TYPE_COLD); | ||
193 | + return fli.lr; | ||
194 | } | ||
195 | |||
196 | void qemu_unregister_reset(QEMUResetHandler *func, void *opaque) | ||
197 | { | ||
198 | - QEMUResetEntry *re; | ||
199 | + Object *obj = OBJECT(find_legacy_reset(func, opaque)); | ||
200 | |||
201 | - QTAILQ_FOREACH(re, &reset_handlers, entry) { | ||
202 | - if (re->func == func && re->opaque == opaque) { | ||
203 | - QTAILQ_REMOVE(&reset_handlers, re, entry); | ||
204 | - g_free(re); | ||
205 | - return; | ||
206 | - } | ||
207 | + if (obj) { | ||
208 | + qemu_unregister_resettable(obj); | ||
209 | + object_unref(obj); | ||
210 | } | ||
211 | } | ||
212 | |||
213 | @@ -XXX,XX +XXX,XX @@ void qemu_unregister_resettable(Object *obj) | ||
214 | |||
215 | void qemu_devices_reset(ShutdownCause reason) | ||
216 | { | ||
217 | - QEMUResetEntry *re, *nre; | ||
218 | - | ||
219 | - /* reset all devices */ | ||
220 | - QTAILQ_FOREACH_SAFE(re, &reset_handlers, entry, nre) { | ||
221 | - if (reason == SHUTDOWN_CAUSE_SNAPSHOT_LOAD && | ||
222 | - re->skip_on_snapshot_load) { | ||
223 | - continue; | ||
224 | - } | ||
225 | - re->func(re->opaque); | ||
226 | - } | ||
227 | + device_reset_reason = reason; | ||
228 | |||
229 | /* Reset the simulation */ | ||
230 | resettable_reset(OBJECT(get_root_reset_container()), RESET_TYPE_COLD); | ||
231 | -- | ||
232 | 2.34.1 | ||
233 | |||
234 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Move the reset of the sysbus (and thus all devices and buses anywhere | ||
2 | on the qbus tree) from qemu_register_reset() to qemu_register_resettable(). | ||
3 | 1 | ||
4 | This is a behaviour change: because qemu_register_resettable() is | ||
5 | aware of three-phase reset, this now means that: | ||
6 | * 'enter' phase reset methods of devices and buses are called | ||
7 | before any legacy reset callbacks registered with qemu_register_reset() | ||
8 | * 'exit' phase reset methods of devices and buses are called | ||
9 | after any legacy qemu_register_reset() callbacks | ||
10 | |||
11 | Put another way, a qemu_register_reset() callback is now correctly | ||
12 | ordered in the 'hold' phase along with any other 'hold' phase methods. | ||
13 | |||
14 | The motivation for doing this is that we will now be able to resolve | ||
15 | some reset-ordering issues using the three-phase mechanism, because | ||
16 | the 'exit' phase is always after the 'hold' phase, even when the | ||
17 | 'hold' phase function was registered with qemu_register_reset(). | ||
18 | |||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> | ||
21 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
22 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
23 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
24 | Message-id: 20240220160622.114437-10-peter.maydell@linaro.org | ||
25 | Reviewed-by: Zhao Liu <zhao1.liu@intel.com> | ||
26 | --- | ||
27 | hw/core/machine.c | 7 +++---- | ||
28 | 1 file changed, 3 insertions(+), 4 deletions(-) | ||
29 | |||
30 | diff --git a/hw/core/machine.c b/hw/core/machine.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/hw/core/machine.c | ||
33 | +++ b/hw/core/machine.c | ||
34 | @@ -XXX,XX +XXX,XX @@ void qdev_machine_creation_done(void) | ||
35 | /* TODO: once all bus devices are qdevified, this should be done | ||
36 | * when bus is created by qdev.c */ | ||
37 | /* | ||
38 | - * TODO: If we had a main 'reset container' that the whole system | ||
39 | - * lived in, we could reset that using the multi-phase reset | ||
40 | - * APIs. For the moment, we just reset the sysbus, which will cause | ||
41 | + * This is where we arrange for the sysbus to be reset when the | ||
42 | + * whole simulation is reset. In turn, resetting the sysbus will cause | ||
43 | * all devices hanging off it (and all their child buses, recursively) | ||
44 | * to be reset. Note that this will *not* reset any Device objects | ||
45 | * which are not attached to some part of the qbus tree! | ||
46 | */ | ||
47 | - qemu_register_reset(resettable_cold_reset_fn, sysbus_get_default()); | ||
48 | + qemu_register_resettable(OBJECT(sysbus_get_default())); | ||
49 | |||
50 | notifier_list_notify(&machine_init_done_notifiers, NULL); | ||
51 | |||
52 | -- | ||
53 | 2.34.1 | ||
54 | |||
55 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Now that system reset uses a three-phase-reset, update the reset | ||
2 | documentation to include a section describing how this works. | ||
3 | Include documentation of the current major beartrap in reset, which | ||
4 | is that only devices on the qbus tree will get automatically reset. | ||
5 | 1 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
10 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
11 | Message-id: 20240220160622.114437-11-peter.maydell@linaro.org | ||
12 | Reviewed-by: Zhao Liu <zhao1.liu@intel.com> | ||
13 | --- | ||
14 | docs/devel/reset.rst | 44 ++++++++++++++++++++++++++++++++++++++++++-- | ||
15 | 1 file changed, 42 insertions(+), 2 deletions(-) | ||
16 | |||
17 | diff --git a/docs/devel/reset.rst b/docs/devel/reset.rst | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/docs/devel/reset.rst | ||
20 | +++ b/docs/devel/reset.rst | ||
21 | @@ -XXX,XX +XXX,XX @@ whole group can be reset consistently. Each individual member object does not | ||
22 | have to care about others; in particular, problems of order (which object is | ||
23 | reset first) are addressed. | ||
24 | |||
25 | -As of now DeviceClass and BusClass implement this interface. | ||
26 | - | ||
27 | +The main object types which implement this interface are DeviceClass | ||
28 | +and BusClass. | ||
29 | |||
30 | Triggering reset | ||
31 | ---------------- | ||
32 | @@ -XXX,XX +XXX,XX @@ There is currently 2 cases where this function is used: | ||
33 | 2. *hot bus change*; it means an existing live device is added, moved or | ||
34 | removed in the bus hierarchy. At the moment, it occurs only in the raspi | ||
35 | machines for changing the sdbus used by sd card. | ||
36 | + | ||
37 | +Reset of the complete system | ||
38 | +---------------------------- | ||
39 | + | ||
40 | +Reset of the complete system is a little complicated. The typical | ||
41 | +flow is: | ||
42 | + | ||
43 | +1. Code which wishes to reset the entire system does so by calling | ||
44 | + ``qemu_system_reset_request()``. This schedules a reset, but the | ||
45 | + reset will happen asynchronously after the function returns. | ||
46 | + That makes this safe to call from, for example, device models. | ||
47 | + | ||
48 | +2. The function which is called to make the reset happen is | ||
49 | + ``qemu_system_reset()``. Generally only core system code should | ||
50 | + call this directly. | ||
51 | + | ||
52 | +3. ``qemu_system_reset()`` calls the ``MachineClass::reset`` method of | ||
53 | + the current machine, if it has one. That method must call | ||
54 | + ``qemu_devices_reset()``. If the machine has no reset method, | ||
55 | + ``qemu_system_reset()`` calls ``qemu_devices_reset()`` directly. | ||
56 | + | ||
57 | +4. ``qemu_devices_reset()`` performs a reset of the system, using | ||
58 | + the three-phase mechanism listed above. It resets all objects | ||
59 | + that were registered with it using ``qemu_register_resettable()``. | ||
60 | + It also calls all the functions registered with it using | ||
61 | + ``qemu_register_reset()``. Those functions are called during the | ||
62 | + "hold" phase of this reset. | ||
63 | + | ||
64 | +5. The most important object that this reset resets is the | ||
65 | + 'sysbus' bus. The sysbus bus is the root of the qbus tree. This | ||
66 | + means that all devices on the sysbus are reset, and all their | ||
67 | + child buses, and all the devices on those child buses. | ||
68 | + | ||
69 | +6. Devices which are not on the qbus tree are *not* automatically | ||
70 | + reset! (The most obvious example of this is CPU objects, but | ||
71 | + anything that directly inherits from ``TYPE_OBJECT`` or ``TYPE_DEVICE`` | ||
72 | + rather than from ``TYPE_SYS_BUS_DEVICE`` or some other plugs-into-a-bus | ||
73 | + type will be in this category.) You need to therefore arrange for these | ||
74 | + to be reset in some other way (e.g. using ``qemu_register_resettable()`` | ||
75 | + or ``qemu_register_reset()``). | ||
76 | -- | ||
77 | 2.34.1 | ||
78 | |||
79 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Sergey Kambalin <serg.oker@gmail.com> | ||
2 | 1 | ||
3 | Pre-setup for raspberry pi 4 introduction | ||
4 | |||
5 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Message-id: 20240226000259.2752893-4-sergey.kambalin@auriga.com | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | include/hw/arm/raspi_platform.h | 21 ++++++ | ||
11 | hw/arm/raspi.c | 112 ++++++++++++++++++-------------- | ||
12 | 2 files changed, 85 insertions(+), 48 deletions(-) | ||
13 | |||
14 | diff --git a/include/hw/arm/raspi_platform.h b/include/hw/arm/raspi_platform.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/include/hw/arm/raspi_platform.h | ||
17 | +++ b/include/hw/arm/raspi_platform.h | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | #ifndef HW_ARM_RASPI_PLATFORM_H | ||
20 | #define HW_ARM_RASPI_PLATFORM_H | ||
21 | |||
22 | +#include "hw/boards.h" | ||
23 | +#include "hw/arm/boot.h" | ||
24 | + | ||
25 | +#define TYPE_RASPI_BASE_MACHINE MACHINE_TYPE_NAME("raspi-base") | ||
26 | +OBJECT_DECLARE_TYPE(RaspiBaseMachineState, RaspiBaseMachineClass, | ||
27 | + RASPI_BASE_MACHINE) | ||
28 | + | ||
29 | +struct RaspiBaseMachineState { | ||
30 | + /*< private >*/ | ||
31 | + MachineState parent_obj; | ||
32 | + /*< public >*/ | ||
33 | + struct arm_boot_info binfo; | ||
34 | +}; | ||
35 | + | ||
36 | +struct RaspiBaseMachineClass { | ||
37 | + /*< private >*/ | ||
38 | + MachineClass parent_obj; | ||
39 | + /*< public >*/ | ||
40 | + uint32_t board_rev; | ||
41 | +}; | ||
42 | + | ||
43 | #define MSYNC_OFFSET 0x0000 /* Multicore Sync Block */ | ||
44 | #define CCPT_OFFSET 0x1000 /* Compact Camera Port 2 TX */ | ||
45 | #define INTE_OFFSET 0x2000 /* VC Interrupt controller */ | ||
46 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/hw/arm/raspi.c | ||
49 | +++ b/hw/arm/raspi.c | ||
50 | @@ -XXX,XX +XXX,XX @@ | ||
51 | #include "qapi/error.h" | ||
52 | #include "hw/arm/boot.h" | ||
53 | #include "hw/arm/bcm2836.h" | ||
54 | +#include "hw/arm/raspi_platform.h" | ||
55 | #include "hw/registerfields.h" | ||
56 | #include "qemu/error-report.h" | ||
57 | #include "hw/boards.h" | ||
58 | @@ -XXX,XX +XXX,XX @@ | ||
59 | #include "hw/arm/boot.h" | ||
60 | #include "qom/object.h" | ||
61 | |||
62 | +#define TYPE_RASPI_MACHINE MACHINE_TYPE_NAME("raspi-common") | ||
63 | +OBJECT_DECLARE_SIMPLE_TYPE(RaspiMachineState, RASPI_MACHINE) | ||
64 | + | ||
65 | #define SMPBOOT_ADDR 0x300 /* this should leave enough space for ATAGS */ | ||
66 | #define MVBAR_ADDR 0x400 /* secure vectors */ | ||
67 | #define BOARDSETUP_ADDR (MVBAR_ADDR + 0x20) /* board setup code */ | ||
68 | @@ -XXX,XX +XXX,XX @@ | ||
69 | |||
70 | struct RaspiMachineState { | ||
71 | /*< private >*/ | ||
72 | - MachineState parent_obj; | ||
73 | + RaspiBaseMachineState parent_obj; | ||
74 | /*< public >*/ | ||
75 | BCM283XState soc; | ||
76 | - struct arm_boot_info binfo; | ||
77 | }; | ||
78 | -typedef struct RaspiMachineState RaspiMachineState; | ||
79 | - | ||
80 | -struct RaspiMachineClass { | ||
81 | - /*< private >*/ | ||
82 | - MachineClass parent_obj; | ||
83 | - /*< public >*/ | ||
84 | - uint32_t board_rev; | ||
85 | -}; | ||
86 | -typedef struct RaspiMachineClass RaspiMachineClass; | ||
87 | - | ||
88 | -#define TYPE_RASPI_MACHINE MACHINE_TYPE_NAME("raspi-common") | ||
89 | -DECLARE_OBJ_CHECKERS(RaspiMachineState, RaspiMachineClass, | ||
90 | - RASPI_MACHINE, TYPE_RASPI_MACHINE) | ||
91 | - | ||
92 | |||
93 | /* | ||
94 | * Board revision codes: | ||
95 | @@ -XXX,XX +XXX,XX @@ static const struct { | ||
96 | [PROCESSOR_ID_BCM2837] = {TYPE_BCM2837, BCM283X_NCPUS}, | ||
97 | }; | ||
98 | |||
99 | +static void raspi_base_machine_init(MachineState *machine, | ||
100 | + BCM283XBaseState *soc); | ||
101 | +static void raspi_machine_class_common_init(MachineClass *mc, | ||
102 | + uint32_t board_rev); | ||
103 | + | ||
104 | static uint64_t board_ram_size(uint32_t board_rev) | ||
105 | { | ||
106 | assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */ | ||
107 | @@ -XXX,XX +XXX,XX @@ static void reset_secondary(ARMCPU *cpu, const struct arm_boot_info *info) | ||
108 | cpu_set_pc(cs, info->smp_loader_start); | ||
109 | } | ||
110 | |||
111 | -static void setup_boot(MachineState *machine, RaspiProcessorId processor_id, | ||
112 | - size_t ram_size) | ||
113 | +static void setup_boot(MachineState *machine, ARMCPU *cpu, | ||
114 | + RaspiProcessorId processor_id, size_t ram_size) | ||
115 | { | ||
116 | - RaspiMachineState *s = RASPI_MACHINE(machine); | ||
117 | + RaspiBaseMachineState *s = RASPI_BASE_MACHINE(machine); | ||
118 | int r; | ||
119 | |||
120 | - s->binfo.board_id = MACH_TYPE_BCM2708; | ||
121 | s->binfo.ram_size = ram_size; | ||
122 | |||
123 | if (processor_id <= PROCESSOR_ID_BCM2836) { | ||
124 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, RaspiProcessorId processor_id, | ||
125 | s->binfo.firmware_loaded = true; | ||
126 | } | ||
127 | |||
128 | - arm_load_kernel(&s->soc.parent_obj.cpu[0].core, machine, &s->binfo); | ||
129 | + arm_load_kernel(cpu, machine, &s->binfo); | ||
130 | } | ||
131 | |||
132 | -static void raspi_machine_init(MachineState *machine) | ||
133 | +static void raspi_base_machine_init(MachineState *machine, | ||
134 | + BCM283XBaseState *soc) | ||
135 | { | ||
136 | - RaspiMachineClass *mc = RASPI_MACHINE_GET_CLASS(machine); | ||
137 | - RaspiMachineState *s = RASPI_MACHINE(machine); | ||
138 | + RaspiBaseMachineClass *mc = RASPI_BASE_MACHINE_GET_CLASS(machine); | ||
139 | uint32_t board_rev = mc->board_rev; | ||
140 | uint64_t ram_size = board_ram_size(board_rev); | ||
141 | uint32_t vcram_size; | ||
142 | @@ -XXX,XX +XXX,XX @@ static void raspi_machine_init(MachineState *machine) | ||
143 | machine->ram, 0); | ||
144 | |||
145 | /* Setup the SOC */ | ||
146 | - object_initialize_child(OBJECT(machine), "soc", &s->soc, | ||
147 | - board_soc_type(board_rev)); | ||
148 | - object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(machine->ram)); | ||
149 | - object_property_set_int(OBJECT(&s->soc), "board-rev", board_rev, | ||
150 | + object_property_add_const_link(OBJECT(soc), "ram", OBJECT(machine->ram)); | ||
151 | + object_property_set_int(OBJECT(soc), "board-rev", board_rev, | ||
152 | &error_abort); | ||
153 | - object_property_set_str(OBJECT(&s->soc), "command-line", | ||
154 | + object_property_set_str(OBJECT(soc), "command-line", | ||
155 | machine->kernel_cmdline, &error_abort); | ||
156 | - qdev_realize(DEVICE(&s->soc), NULL, &error_fatal); | ||
157 | + qdev_realize(DEVICE(soc), NULL, &error_fatal); | ||
158 | |||
159 | /* Create and plug in the SD cards */ | ||
160 | di = drive_get(IF_SD, 0, 0); | ||
161 | blk = di ? blk_by_legacy_dinfo(di) : NULL; | ||
162 | - bus = qdev_get_child_bus(DEVICE(&s->soc), "sd-bus"); | ||
163 | + bus = qdev_get_child_bus(DEVICE(soc), "sd-bus"); | ||
164 | if (bus == NULL) { | ||
165 | error_report("No SD bus found in SOC object"); | ||
166 | exit(1); | ||
167 | @@ -XXX,XX +XXX,XX @@ static void raspi_machine_init(MachineState *machine) | ||
168 | qdev_prop_set_drive_err(carddev, "drive", blk, &error_fatal); | ||
169 | qdev_realize_and_unref(carddev, bus, &error_fatal); | ||
170 | |||
171 | - vcram_size = object_property_get_uint(OBJECT(&s->soc), "vcram-size", | ||
172 | + vcram_size = object_property_get_uint(OBJECT(soc), "vcram-size", | ||
173 | &error_abort); | ||
174 | - setup_boot(machine, board_processor_id(mc->board_rev), | ||
175 | + setup_boot(machine, &soc->cpu[0].core, board_processor_id(board_rev), | ||
176 | machine->ram_size - vcram_size); | ||
177 | } | ||
178 | |||
179 | -static void raspi_machine_class_common_init(MachineClass *mc, | ||
180 | - uint32_t board_rev) | ||
181 | +static void raspi_machine_init(MachineState *machine) | ||
182 | +{ | ||
183 | + RaspiMachineState *s = RASPI_MACHINE(machine); | ||
184 | + RaspiBaseMachineState *s_base = RASPI_BASE_MACHINE(machine); | ||
185 | + RaspiBaseMachineClass *mc = RASPI_BASE_MACHINE_GET_CLASS(machine); | ||
186 | + BCM283XState *soc = &s->soc; | ||
187 | + | ||
188 | + s_base->binfo.board_id = MACH_TYPE_BCM2708; | ||
189 | + | ||
190 | + object_initialize_child(OBJECT(machine), "soc", soc, | ||
191 | + board_soc_type(mc->board_rev)); | ||
192 | + raspi_base_machine_init(machine, &soc->parent_obj); | ||
193 | +} | ||
194 | + | ||
195 | +void raspi_machine_class_common_init(MachineClass *mc, | ||
196 | + uint32_t board_rev) | ||
197 | { | ||
198 | mc->desc = g_strdup_printf("Raspberry Pi %s (revision 1.%u)", | ||
199 | board_type(board_rev), | ||
200 | FIELD_EX32(board_rev, REV_CODE, REVISION)); | ||
201 | - mc->init = raspi_machine_init; | ||
202 | mc->block_default_type = IF_SD; | ||
203 | mc->no_parallel = 1; | ||
204 | mc->no_floppy = 1; | ||
205 | @@ -XXX,XX +XXX,XX @@ static void raspi_machine_class_common_init(MachineClass *mc, | ||
206 | mc->default_ram_id = "ram"; | ||
207 | }; | ||
208 | |||
209 | +static void raspi_machine_class_init(MachineClass *mc, | ||
210 | + uint32_t board_rev) | ||
211 | +{ | ||
212 | + raspi_machine_class_common_init(mc, board_rev); | ||
213 | + mc->init = raspi_machine_init; | ||
214 | +}; | ||
215 | + | ||
216 | static void raspi0_machine_class_init(ObjectClass *oc, void *data) | ||
217 | { | ||
218 | MachineClass *mc = MACHINE_CLASS(oc); | ||
219 | - RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc); | ||
220 | + RaspiBaseMachineClass *rmc = RASPI_BASE_MACHINE_CLASS(oc); | ||
221 | |||
222 | rmc->board_rev = 0x920092; /* Revision 1.2 */ | ||
223 | - raspi_machine_class_common_init(mc, rmc->board_rev); | ||
224 | + raspi_machine_class_init(mc, rmc->board_rev); | ||
225 | }; | ||
226 | |||
227 | static void raspi1ap_machine_class_init(ObjectClass *oc, void *data) | ||
228 | { | ||
229 | MachineClass *mc = MACHINE_CLASS(oc); | ||
230 | - RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc); | ||
231 | + RaspiBaseMachineClass *rmc = RASPI_BASE_MACHINE_CLASS(oc); | ||
232 | |||
233 | rmc->board_rev = 0x900021; /* Revision 1.1 */ | ||
234 | - raspi_machine_class_common_init(mc, rmc->board_rev); | ||
235 | + raspi_machine_class_init(mc, rmc->board_rev); | ||
236 | }; | ||
237 | |||
238 | static void raspi2b_machine_class_init(ObjectClass *oc, void *data) | ||
239 | { | ||
240 | MachineClass *mc = MACHINE_CLASS(oc); | ||
241 | - RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc); | ||
242 | + RaspiBaseMachineClass *rmc = RASPI_BASE_MACHINE_CLASS(oc); | ||
243 | |||
244 | rmc->board_rev = 0xa21041; | ||
245 | - raspi_machine_class_common_init(mc, rmc->board_rev); | ||
246 | + raspi_machine_class_init(mc, rmc->board_rev); | ||
247 | }; | ||
248 | |||
249 | #ifdef TARGET_AARCH64 | ||
250 | static void raspi3ap_machine_class_init(ObjectClass *oc, void *data) | ||
251 | { | ||
252 | MachineClass *mc = MACHINE_CLASS(oc); | ||
253 | - RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc); | ||
254 | + RaspiBaseMachineClass *rmc = RASPI_BASE_MACHINE_CLASS(oc); | ||
255 | |||
256 | rmc->board_rev = 0x9020e0; /* Revision 1.0 */ | ||
257 | - raspi_machine_class_common_init(mc, rmc->board_rev); | ||
258 | + raspi_machine_class_init(mc, rmc->board_rev); | ||
259 | }; | ||
260 | |||
261 | static void raspi3b_machine_class_init(ObjectClass *oc, void *data) | ||
262 | { | ||
263 | MachineClass *mc = MACHINE_CLASS(oc); | ||
264 | - RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc); | ||
265 | + RaspiBaseMachineClass *rmc = RASPI_BASE_MACHINE_CLASS(oc); | ||
266 | |||
267 | rmc->board_rev = 0xa02082; | ||
268 | - raspi_machine_class_common_init(mc, rmc->board_rev); | ||
269 | + raspi_machine_class_init(mc, rmc->board_rev); | ||
270 | }; | ||
271 | #endif /* TARGET_AARCH64 */ | ||
272 | |||
273 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo raspi_machine_types[] = { | ||
274 | #endif | ||
275 | }, { | ||
276 | .name = TYPE_RASPI_MACHINE, | ||
277 | - .parent = TYPE_MACHINE, | ||
278 | + .parent = TYPE_RASPI_BASE_MACHINE, | ||
279 | .instance_size = sizeof(RaspiMachineState), | ||
280 | - .class_size = sizeof(RaspiMachineClass), | ||
281 | + .abstract = true, | ||
282 | + }, { | ||
283 | + .name = TYPE_RASPI_BASE_MACHINE, | ||
284 | + .parent = TYPE_MACHINE, | ||
285 | + .instance_size = sizeof(RaspiBaseMachineState), | ||
286 | + .class_size = sizeof(RaspiBaseMachineClass), | ||
287 | .abstract = true, | ||
288 | } | ||
289 | }; | ||
290 | -- | ||
291 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Sergey Kambalin <serg.oker@gmail.com> | ||
2 | 1 | ||
3 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Message-id: 20240226000259.2752893-5-sergey.kambalin@auriga.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | include/hw/arm/bcm2838.h | 29 ++++++++ | ||
9 | include/hw/arm/bcm2838_peripherals.h | 36 ++++++++++ | ||
10 | hw/arm/bcm2838.c | 98 ++++++++++++++++++++++++++++ | ||
11 | hw/arm/bcm2838_peripherals.c | 72 ++++++++++++++++++++ | ||
12 | hw/arm/meson.build | 2 + | ||
13 | 5 files changed, 237 insertions(+) | ||
14 | create mode 100644 include/hw/arm/bcm2838.h | ||
15 | create mode 100644 include/hw/arm/bcm2838_peripherals.h | ||
16 | create mode 100644 hw/arm/bcm2838.c | ||
17 | create mode 100644 hw/arm/bcm2838_peripherals.c | ||
18 | |||
19 | diff --git a/include/hw/arm/bcm2838.h b/include/hw/arm/bcm2838.h | ||
20 | new file mode 100644 | ||
21 | index XXXXXXX..XXXXXXX | ||
22 | --- /dev/null | ||
23 | +++ b/include/hw/arm/bcm2838.h | ||
24 | @@ -XXX,XX +XXX,XX @@ | ||
25 | +/* | ||
26 | + * BCM2838 SoC emulation | ||
27 | + * | ||
28 | + * Copyright (C) 2022 Ovchinnikov Vitalii <vitalii.ovchinnikov@auriga.com> | ||
29 | + * | ||
30 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
31 | + */ | ||
32 | + | ||
33 | +#ifndef BCM2838_H | ||
34 | +#define BCM2838_H | ||
35 | + | ||
36 | +#include "hw/arm/bcm2836.h" | ||
37 | +#include "hw/arm/bcm2838_peripherals.h" | ||
38 | + | ||
39 | +#define BCM2838_PERI_LOW_BASE 0xfc000000 | ||
40 | +#define BCM2838_GIC_BASE 0x40000 | ||
41 | + | ||
42 | +#define TYPE_BCM2838 "bcm2838" | ||
43 | + | ||
44 | +OBJECT_DECLARE_TYPE(BCM2838State, BCM2838Class, BCM2838) | ||
45 | + | ||
46 | +struct BCM2838State { | ||
47 | + /*< private >*/ | ||
48 | + BCM283XBaseState parent_obj; | ||
49 | + /*< public >*/ | ||
50 | + BCM2838PeripheralState peripherals; | ||
51 | +}; | ||
52 | + | ||
53 | +#endif /* BCM2838_H */ | ||
54 | diff --git a/include/hw/arm/bcm2838_peripherals.h b/include/hw/arm/bcm2838_peripherals.h | ||
55 | new file mode 100644 | ||
56 | index XXXXXXX..XXXXXXX | ||
57 | --- /dev/null | ||
58 | +++ b/include/hw/arm/bcm2838_peripherals.h | ||
59 | @@ -XXX,XX +XXX,XX @@ | ||
60 | +/* | ||
61 | + * BCM2838 peripherals emulation | ||
62 | + * | ||
63 | + * Copyright (C) 2022 Ovchinnikov Vitalii <vitalii.ovchinnikov@auriga.com> | ||
64 | + * | ||
65 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
66 | + */ | ||
67 | + | ||
68 | +#ifndef BCM2838_PERIPHERALS_H | ||
69 | +#define BCM2838_PERIPHERALS_H | ||
70 | + | ||
71 | +#include "hw/arm/bcm2835_peripherals.h" | ||
72 | + | ||
73 | + | ||
74 | +#define TYPE_BCM2838_PERIPHERALS "bcm2838-peripherals" | ||
75 | +OBJECT_DECLARE_TYPE(BCM2838PeripheralState, BCM2838PeripheralClass, | ||
76 | + BCM2838_PERIPHERALS) | ||
77 | + | ||
78 | +struct BCM2838PeripheralState { | ||
79 | + /*< private >*/ | ||
80 | + BCMSocPeripheralBaseState parent_obj; | ||
81 | + | ||
82 | + /*< public >*/ | ||
83 | + MemoryRegion peri_low_mr; | ||
84 | + MemoryRegion peri_low_mr_alias; | ||
85 | + MemoryRegion mphi_mr_alias; | ||
86 | +}; | ||
87 | + | ||
88 | +struct BCM2838PeripheralClass { | ||
89 | + /*< private >*/ | ||
90 | + BCMSocPeripheralBaseClass parent_class; | ||
91 | + /*< public >*/ | ||
92 | + uint64_t peri_low_size; /* Peripheral lower range size */ | ||
93 | +}; | ||
94 | + | ||
95 | +#endif /* BCM2838_PERIPHERALS_H */ | ||
96 | diff --git a/hw/arm/bcm2838.c b/hw/arm/bcm2838.c | ||
97 | new file mode 100644 | ||
98 | index XXXXXXX..XXXXXXX | ||
99 | --- /dev/null | ||
100 | +++ b/hw/arm/bcm2838.c | ||
101 | @@ -XXX,XX +XXX,XX @@ | ||
102 | +/* | ||
103 | + * BCM2838 SoC emulation | ||
104 | + * | ||
105 | + * Copyright (C) 2022 Ovchinnikov Vitalii <vitalii.ovchinnikov@auriga.com> | ||
106 | + * | ||
107 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
108 | + */ | ||
109 | + | ||
110 | +#include "qemu/osdep.h" | ||
111 | +#include "qapi/error.h" | ||
112 | +#include "qemu/module.h" | ||
113 | +#include "hw/arm/raspi_platform.h" | ||
114 | +#include "hw/sysbus.h" | ||
115 | +#include "hw/arm/bcm2838.h" | ||
116 | +#include "trace.h" | ||
117 | + | ||
118 | +#define VIRTUAL_PMU_IRQ 7 | ||
119 | + | ||
120 | +static void bcm2838_init(Object *obj) | ||
121 | +{ | ||
122 | + BCM2838State *s = BCM2838(obj); | ||
123 | + | ||
124 | + object_initialize_child(obj, "peripherals", &s->peripherals, | ||
125 | + TYPE_BCM2838_PERIPHERALS); | ||
126 | + object_property_add_alias(obj, "board-rev", OBJECT(&s->peripherals), | ||
127 | + "board-rev"); | ||
128 | + object_property_add_alias(obj, "vcram-size", OBJECT(&s->peripherals), | ||
129 | + "vcram-size"); | ||
130 | + object_property_add_alias(obj, "command-line", OBJECT(&s->peripherals), | ||
131 | + "command-line"); | ||
132 | +} | ||
133 | + | ||
134 | +static void bcm2838_realize(DeviceState *dev, Error **errp) | ||
135 | +{ | ||
136 | + int n; | ||
137 | + BCM2838State *s = BCM2838(dev); | ||
138 | + BCM283XBaseState *s_base = BCM283X_BASE(dev); | ||
139 | + BCM283XBaseClass *bc_base = BCM283X_BASE_GET_CLASS(dev); | ||
140 | + BCM2838PeripheralState *ps = BCM2838_PERIPHERALS(&s->peripherals); | ||
141 | + BCMSocPeripheralBaseState *ps_base = | ||
142 | + BCM_SOC_PERIPHERALS_BASE(&s->peripherals); | ||
143 | + | ||
144 | + if (!bcm283x_common_realize(dev, ps_base, errp)) { | ||
145 | + return; | ||
146 | + } | ||
147 | + sysbus_mmio_map_overlap(SYS_BUS_DEVICE(ps), 1, BCM2838_PERI_LOW_BASE, 1); | ||
148 | + | ||
149 | + /* bcm2836 interrupt controller (and mailboxes, etc.) */ | ||
150 | + if (!sysbus_realize(SYS_BUS_DEVICE(&s_base->control), errp)) { | ||
151 | + return; | ||
152 | + } | ||
153 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s_base->control), 0, bc_base->ctrl_base); | ||
154 | + | ||
155 | + /* Create cores */ | ||
156 | + for (n = 0; n < bc_base->core_count; n++) { | ||
157 | + | ||
158 | + object_property_set_int(OBJECT(&s_base->cpu[n].core), "mp-affinity", | ||
159 | + (bc_base->clusterid << 8) | n, &error_abort); | ||
160 | + | ||
161 | + /* start powered off if not enabled */ | ||
162 | + object_property_set_bool(OBJECT(&s_base->cpu[n].core), | ||
163 | + "start-powered-off", | ||
164 | + n >= s_base->enabled_cpus, &error_abort); | ||
165 | + | ||
166 | + if (!qdev_realize(DEVICE(&s_base->cpu[n].core), NULL, errp)) { | ||
167 | + return; | ||
168 | + } | ||
169 | + } | ||
170 | +} | ||
171 | + | ||
172 | +static void bcm2838_class_init(ObjectClass *oc, void *data) | ||
173 | +{ | ||
174 | + DeviceClass *dc = DEVICE_CLASS(oc); | ||
175 | + BCM283XBaseClass *bc_base = BCM283X_BASE_CLASS(oc); | ||
176 | + | ||
177 | + bc_base->cpu_type = ARM_CPU_TYPE_NAME("cortex-a72"); | ||
178 | + bc_base->core_count = BCM283X_NCPUS; | ||
179 | + bc_base->peri_base = 0xfe000000; | ||
180 | + bc_base->ctrl_base = 0xff800000; | ||
181 | + bc_base->clusterid = 0x0; | ||
182 | + dc->realize = bcm2838_realize; | ||
183 | +} | ||
184 | + | ||
185 | +static const TypeInfo bcm2838_type = { | ||
186 | + .name = TYPE_BCM2838, | ||
187 | + .parent = TYPE_BCM283X_BASE, | ||
188 | + .instance_size = sizeof(BCM2838State), | ||
189 | + .instance_init = bcm2838_init, | ||
190 | + .class_size = sizeof(BCM283XBaseClass), | ||
191 | + .class_init = bcm2838_class_init, | ||
192 | +}; | ||
193 | + | ||
194 | +static void bcm2838_register_types(void) | ||
195 | +{ | ||
196 | + type_register_static(&bcm2838_type); | ||
197 | +} | ||
198 | + | ||
199 | +type_init(bcm2838_register_types); | ||
200 | diff --git a/hw/arm/bcm2838_peripherals.c b/hw/arm/bcm2838_peripherals.c | ||
201 | new file mode 100644 | ||
202 | index XXXXXXX..XXXXXXX | ||
203 | --- /dev/null | ||
204 | +++ b/hw/arm/bcm2838_peripherals.c | ||
205 | @@ -XXX,XX +XXX,XX @@ | ||
206 | +/* | ||
207 | + * BCM2838 peripherals emulation | ||
208 | + * | ||
209 | + * Copyright (C) 2022 Ovchinnikov Vitalii <vitalii.ovchinnikov@auriga.com> | ||
210 | + * | ||
211 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
212 | + */ | ||
213 | + | ||
214 | +#include "qemu/osdep.h" | ||
215 | +#include "qapi/error.h" | ||
216 | +#include "qemu/module.h" | ||
217 | +#include "hw/arm/raspi_platform.h" | ||
218 | +#include "hw/arm/bcm2838_peripherals.h" | ||
219 | + | ||
220 | +/* Lower peripheral base address on the VC (GPU) system bus */ | ||
221 | +#define BCM2838_VC_PERI_LOW_BASE 0x7c000000 | ||
222 | + | ||
223 | +static void bcm2838_peripherals_init(Object *obj) | ||
224 | +{ | ||
225 | + BCM2838PeripheralState *s = BCM2838_PERIPHERALS(obj); | ||
226 | + BCM2838PeripheralClass *bc = BCM2838_PERIPHERALS_GET_CLASS(obj); | ||
227 | + | ||
228 | + /* Lower memory region for peripheral devices (exported to the Soc) */ | ||
229 | + memory_region_init(&s->peri_low_mr, obj, "bcm2838-peripherals", | ||
230 | + bc->peri_low_size); | ||
231 | + sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->peri_low_mr); | ||
232 | + | ||
233 | +} | ||
234 | + | ||
235 | +static void bcm2838_peripherals_realize(DeviceState *dev, Error **errp) | ||
236 | +{ | ||
237 | + BCM2838PeripheralState *s = BCM2838_PERIPHERALS(dev); | ||
238 | + BCMSocPeripheralBaseState *s_base = BCM_SOC_PERIPHERALS_BASE(dev); | ||
239 | + | ||
240 | + bcm_soc_peripherals_common_realize(dev, errp); | ||
241 | + | ||
242 | + /* Map lower peripherals into the GPU address space */ | ||
243 | + memory_region_init_alias(&s->peri_low_mr_alias, OBJECT(s), | ||
244 | + "bcm2838-peripherals", &s->peri_low_mr, 0, | ||
245 | + memory_region_size(&s->peri_low_mr)); | ||
246 | + memory_region_add_subregion_overlap(&s_base->gpu_bus_mr, | ||
247 | + BCM2838_VC_PERI_LOW_BASE, | ||
248 | + &s->peri_low_mr_alias, 1); | ||
249 | + | ||
250 | +} | ||
251 | + | ||
252 | +static void bcm2838_peripherals_class_init(ObjectClass *oc, void *data) | ||
253 | +{ | ||
254 | + DeviceClass *dc = DEVICE_CLASS(oc); | ||
255 | + BCM2838PeripheralClass *bc = BCM2838_PERIPHERALS_CLASS(oc); | ||
256 | + BCMSocPeripheralBaseClass *bc_base = BCM_SOC_PERIPHERALS_BASE_CLASS(oc); | ||
257 | + | ||
258 | + bc->peri_low_size = 0x2000000; | ||
259 | + bc_base->peri_size = 0x1800000; | ||
260 | + dc->realize = bcm2838_peripherals_realize; | ||
261 | +} | ||
262 | + | ||
263 | +static const TypeInfo bcm2838_peripherals_type_info = { | ||
264 | + .name = TYPE_BCM2838_PERIPHERALS, | ||
265 | + .parent = TYPE_BCM_SOC_PERIPHERALS_BASE, | ||
266 | + .instance_size = sizeof(BCM2838PeripheralState), | ||
267 | + .instance_init = bcm2838_peripherals_init, | ||
268 | + .class_size = sizeof(BCM2838PeripheralClass), | ||
269 | + .class_init = bcm2838_peripherals_class_init, | ||
270 | +}; | ||
271 | + | ||
272 | +static void bcm2838_peripherals_register_types(void) | ||
273 | +{ | ||
274 | + type_register_static(&bcm2838_peripherals_type_info); | ||
275 | +} | ||
276 | + | ||
277 | +type_init(bcm2838_peripherals_register_types) | ||
278 | diff --git a/hw/arm/meson.build b/hw/arm/meson.build | ||
279 | index XXXXXXX..XXXXXXX 100644 | ||
280 | --- a/hw/arm/meson.build | ||
281 | +++ b/hw/arm/meson.build | ||
282 | @@ -XXX,XX +XXX,XX @@ arm_ss.add(when: 'CONFIG_ALLWINNER_A10', if_true: files('allwinner-a10.c', 'cubi | ||
283 | arm_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3.c', 'orangepi.c')) | ||
284 | arm_ss.add(when: 'CONFIG_ALLWINNER_R40', if_true: files('allwinner-r40.c', 'bananapi_m2u.c')) | ||
285 | arm_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2836.c', 'raspi.c')) | ||
286 | +arm_ss.add(when: ['CONFIG_RASPI', 'TARGET_AARCH64'], if_true: files('bcm2838.c')) | ||
287 | arm_ss.add(when: 'CONFIG_STM32F100_SOC', if_true: files('stm32f100_soc.c')) | ||
288 | arm_ss.add(when: 'CONFIG_STM32F205_SOC', if_true: files('stm32f205_soc.c')) | ||
289 | arm_ss.add(when: 'CONFIG_STM32F405_SOC', if_true: files('stm32f405_soc.c')) | ||
290 | @@ -XXX,XX +XXX,XX @@ system_ss.add(when: 'CONFIG_GUMSTIX', if_true: files('gumstix.c')) | ||
291 | system_ss.add(when: 'CONFIG_NETDUINO2', if_true: files('netduino2.c')) | ||
292 | system_ss.add(when: 'CONFIG_OMAP', if_true: files('omap2.c')) | ||
293 | system_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_peripherals.c')) | ||
294 | +system_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2838_peripherals.c')) | ||
295 | system_ss.add(when: 'CONFIG_SPITZ', if_true: files('spitz.c')) | ||
296 | system_ss.add(when: 'CONFIG_STRONGARM', if_true: files('strongarm.c')) | ||
297 | system_ss.add(when: 'CONFIG_SX1', if_true: files('omap_sx1.c')) | ||
298 | -- | ||
299 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Sergey Kambalin <serg.oker@gmail.com> | ||
2 | 1 | ||
3 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Message-id: 20240226000259.2752893-6-sergey.kambalin@auriga.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | include/hw/arm/bcm2838.h | 2 + | ||
9 | include/hw/arm/bcm2838_peripherals.h | 37 ++++++ | ||
10 | hw/arm/bcm2838.c | 167 ++++++++++++++++++++++++++- | ||
11 | hw/arm/trace-events | 3 + | ||
12 | 4 files changed, 207 insertions(+), 2 deletions(-) | ||
13 | |||
14 | diff --git a/include/hw/arm/bcm2838.h b/include/hw/arm/bcm2838.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/include/hw/arm/bcm2838.h | ||
17 | +++ b/include/hw/arm/bcm2838.h | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | #define BCM2838_H | ||
20 | |||
21 | #include "hw/arm/bcm2836.h" | ||
22 | +#include "hw/intc/arm_gic.h" | ||
23 | #include "hw/arm/bcm2838_peripherals.h" | ||
24 | |||
25 | #define BCM2838_PERI_LOW_BASE 0xfc000000 | ||
26 | @@ -XXX,XX +XXX,XX @@ struct BCM2838State { | ||
27 | BCM283XBaseState parent_obj; | ||
28 | /*< public >*/ | ||
29 | BCM2838PeripheralState peripherals; | ||
30 | + GICState gic; | ||
31 | }; | ||
32 | |||
33 | #endif /* BCM2838_H */ | ||
34 | diff --git a/include/hw/arm/bcm2838_peripherals.h b/include/hw/arm/bcm2838_peripherals.h | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/include/hw/arm/bcm2838_peripherals.h | ||
37 | +++ b/include/hw/arm/bcm2838_peripherals.h | ||
38 | @@ -XXX,XX +XXX,XX @@ | ||
39 | |||
40 | #include "hw/arm/bcm2835_peripherals.h" | ||
41 | |||
42 | +/* SPI */ | ||
43 | +#define GIC_SPI_INTERRUPT_MBOX 33 | ||
44 | +#define GIC_SPI_INTERRUPT_MPHI 40 | ||
45 | +#define GIC_SPI_INTERRUPT_DWC2 73 | ||
46 | +#define GIC_SPI_INTERRUPT_DMA_0 80 | ||
47 | +#define GIC_SPI_INTERRUPT_DMA_6 86 | ||
48 | +#define GIC_SPI_INTERRUPT_DMA_7_8 87 | ||
49 | +#define GIC_SPI_INTERRUPT_DMA_9_10 88 | ||
50 | +#define GIC_SPI_INTERRUPT_AUX_UART1 93 | ||
51 | +#define GIC_SPI_INTERRUPT_SDHOST 120 | ||
52 | +#define GIC_SPI_INTERRUPT_UART0 121 | ||
53 | +#define GIC_SPI_INTERRUPT_RNG200 125 | ||
54 | +#define GIC_SPI_INTERRUPT_EMMC_EMMC2 126 | ||
55 | +#define GIC_SPI_INTERRUPT_PCI_INT_A 143 | ||
56 | +#define GIC_SPI_INTERRUPT_GENET_A 157 | ||
57 | +#define GIC_SPI_INTERRUPT_GENET_B 158 | ||
58 | + | ||
59 | + | ||
60 | +/* GPU (legacy) DMA interrupts */ | ||
61 | +#define GPU_INTERRUPT_DMA0 16 | ||
62 | +#define GPU_INTERRUPT_DMA1 17 | ||
63 | +#define GPU_INTERRUPT_DMA2 18 | ||
64 | +#define GPU_INTERRUPT_DMA3 19 | ||
65 | +#define GPU_INTERRUPT_DMA4 20 | ||
66 | +#define GPU_INTERRUPT_DMA5 21 | ||
67 | +#define GPU_INTERRUPT_DMA6 22 | ||
68 | +#define GPU_INTERRUPT_DMA7_8 23 | ||
69 | +#define GPU_INTERRUPT_DMA9_10 24 | ||
70 | +#define GPU_INTERRUPT_DMA11 25 | ||
71 | +#define GPU_INTERRUPT_DMA12 26 | ||
72 | +#define GPU_INTERRUPT_DMA13 27 | ||
73 | +#define GPU_INTERRUPT_DMA14 28 | ||
74 | +#define GPU_INTERRUPT_DMA15 31 | ||
75 | |||
76 | #define TYPE_BCM2838_PERIPHERALS "bcm2838-peripherals" | ||
77 | OBJECT_DECLARE_TYPE(BCM2838PeripheralState, BCM2838PeripheralClass, | ||
78 | @@ -XXX,XX +XXX,XX @@ struct BCM2838PeripheralState { | ||
79 | MemoryRegion peri_low_mr; | ||
80 | MemoryRegion peri_low_mr_alias; | ||
81 | MemoryRegion mphi_mr_alias; | ||
82 | + | ||
83 | + OrIRQState mmc_irq_orgate; | ||
84 | + OrIRQState dma_7_8_irq_orgate; | ||
85 | + OrIRQState dma_9_10_irq_orgate; | ||
86 | }; | ||
87 | |||
88 | struct BCM2838PeripheralClass { | ||
89 | diff --git a/hw/arm/bcm2838.c b/hw/arm/bcm2838.c | ||
90 | index XXXXXXX..XXXXXXX 100644 | ||
91 | --- a/hw/arm/bcm2838.c | ||
92 | +++ b/hw/arm/bcm2838.c | ||
93 | @@ -XXX,XX +XXX,XX @@ | ||
94 | #include "hw/arm/bcm2838.h" | ||
95 | #include "trace.h" | ||
96 | |||
97 | +#define GIC400_MAINTENANCE_IRQ 9 | ||
98 | +#define GIC400_TIMER_NS_EL2_IRQ 10 | ||
99 | +#define GIC400_TIMER_VIRT_IRQ 11 | ||
100 | +#define GIC400_LEGACY_FIQ 12 | ||
101 | +#define GIC400_TIMER_S_EL1_IRQ 13 | ||
102 | +#define GIC400_TIMER_NS_EL1_IRQ 14 | ||
103 | +#define GIC400_LEGACY_IRQ 15 | ||
104 | + | ||
105 | +/* Number of external interrupt lines to configure the GIC with */ | ||
106 | +#define GIC_NUM_IRQS 192 | ||
107 | + | ||
108 | +#define PPI(cpu, irq) (GIC_NUM_IRQS + (cpu) * GIC_INTERNAL + GIC_NR_SGIS + irq) | ||
109 | + | ||
110 | +#define GIC_BASE_OFS 0x0000 | ||
111 | +#define GIC_DIST_OFS 0x1000 | ||
112 | +#define GIC_CPU_OFS 0x2000 | ||
113 | +#define GIC_VIFACE_THIS_OFS 0x4000 | ||
114 | +#define GIC_VIFACE_OTHER_OFS(cpu) (0x5000 + (cpu) * 0x200) | ||
115 | +#define GIC_VCPU_OFS 0x6000 | ||
116 | + | ||
117 | #define VIRTUAL_PMU_IRQ 7 | ||
118 | |||
119 | +static void bcm2838_gic_set_irq(void *opaque, int irq, int level) | ||
120 | +{ | ||
121 | + BCM2838State *s = (BCM2838State *)opaque; | ||
122 | + | ||
123 | + trace_bcm2838_gic_set_irq(irq, level); | ||
124 | + qemu_set_irq(qdev_get_gpio_in(DEVICE(&s->gic), irq), level); | ||
125 | +} | ||
126 | + | ||
127 | static void bcm2838_init(Object *obj) | ||
128 | { | ||
129 | BCM2838State *s = BCM2838(obj); | ||
130 | @@ -XXX,XX +XXX,XX @@ static void bcm2838_init(Object *obj) | ||
131 | "vcram-size"); | ||
132 | object_property_add_alias(obj, "command-line", OBJECT(&s->peripherals), | ||
133 | "command-line"); | ||
134 | + | ||
135 | + object_initialize_child(obj, "gic", &s->gic, TYPE_ARM_GIC); | ||
136 | } | ||
137 | |||
138 | static void bcm2838_realize(DeviceState *dev, Error **errp) | ||
139 | { | ||
140 | - int n; | ||
141 | BCM2838State *s = BCM2838(dev); | ||
142 | BCM283XBaseState *s_base = BCM283X_BASE(dev); | ||
143 | BCM283XBaseClass *bc_base = BCM283X_BASE_GET_CLASS(dev); | ||
144 | @@ -XXX,XX +XXX,XX @@ static void bcm2838_realize(DeviceState *dev, Error **errp) | ||
145 | BCMSocPeripheralBaseState *ps_base = | ||
146 | BCM_SOC_PERIPHERALS_BASE(&s->peripherals); | ||
147 | |||
148 | + DeviceState *gicdev = NULL; | ||
149 | + | ||
150 | if (!bcm283x_common_realize(dev, ps_base, errp)) { | ||
151 | return; | ||
152 | } | ||
153 | @@ -XXX,XX +XXX,XX @@ static void bcm2838_realize(DeviceState *dev, Error **errp) | ||
154 | sysbus_mmio_map(SYS_BUS_DEVICE(&s_base->control), 0, bc_base->ctrl_base); | ||
155 | |||
156 | /* Create cores */ | ||
157 | - for (n = 0; n < bc_base->core_count; n++) { | ||
158 | + for (int n = 0; n < bc_base->core_count; n++) { | ||
159 | |||
160 | object_property_set_int(OBJECT(&s_base->cpu[n].core), "mp-affinity", | ||
161 | (bc_base->clusterid << 8) | n, &error_abort); | ||
162 | |||
163 | + /* set periphbase/CBAR value for CPU-local registers */ | ||
164 | + object_property_set_int(OBJECT(&s_base->cpu[n].core), "reset-cbar", | ||
165 | + bc_base->peri_base, &error_abort); | ||
166 | + | ||
167 | /* start powered off if not enabled */ | ||
168 | object_property_set_bool(OBJECT(&s_base->cpu[n].core), | ||
169 | "start-powered-off", | ||
170 | @@ -XXX,XX +XXX,XX @@ static void bcm2838_realize(DeviceState *dev, Error **errp) | ||
171 | return; | ||
172 | } | ||
173 | } | ||
174 | + | ||
175 | + if (!object_property_set_uint(OBJECT(&s->gic), "revision", 2, errp)) { | ||
176 | + return; | ||
177 | + } | ||
178 | + | ||
179 | + if (!object_property_set_uint(OBJECT(&s->gic), "num-cpu", BCM283X_NCPUS, | ||
180 | + errp)) { | ||
181 | + return; | ||
182 | + } | ||
183 | + | ||
184 | + if (!object_property_set_uint(OBJECT(&s->gic), "num-irq", | ||
185 | + GIC_NUM_IRQS + GIC_INTERNAL, errp)) { | ||
186 | + return; | ||
187 | + } | ||
188 | + | ||
189 | + if (!object_property_set_bool(OBJECT(&s->gic), | ||
190 | + "has-virtualization-extensions", true, | ||
191 | + errp)) { | ||
192 | + return; | ||
193 | + } | ||
194 | + | ||
195 | + if (!sysbus_realize(SYS_BUS_DEVICE(&s->gic), errp)) { | ||
196 | + return; | ||
197 | + } | ||
198 | + | ||
199 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gic), 0, | ||
200 | + bc_base->ctrl_base + BCM2838_GIC_BASE + GIC_DIST_OFS); | ||
201 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gic), 1, | ||
202 | + bc_base->ctrl_base + BCM2838_GIC_BASE + GIC_CPU_OFS); | ||
203 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gic), 2, | ||
204 | + bc_base->ctrl_base + BCM2838_GIC_BASE + GIC_VIFACE_THIS_OFS); | ||
205 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gic), 3, | ||
206 | + bc_base->ctrl_base + BCM2838_GIC_BASE + GIC_VCPU_OFS); | ||
207 | + | ||
208 | + for (int n = 0; n < BCM283X_NCPUS; n++) { | ||
209 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gic), 4 + n, | ||
210 | + bc_base->ctrl_base + BCM2838_GIC_BASE | ||
211 | + + GIC_VIFACE_OTHER_OFS(n)); | ||
212 | + } | ||
213 | + | ||
214 | + gicdev = DEVICE(&s->gic); | ||
215 | + | ||
216 | + for (int n = 0; n < BCM283X_NCPUS; n++) { | ||
217 | + DeviceState *cpudev = DEVICE(&s_base->cpu[n]); | ||
218 | + | ||
219 | + /* Connect the GICv2 outputs to the CPU */ | ||
220 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), n, | ||
221 | + qdev_get_gpio_in(cpudev, ARM_CPU_IRQ)); | ||
222 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), n + BCM283X_NCPUS, | ||
223 | + qdev_get_gpio_in(cpudev, ARM_CPU_FIQ)); | ||
224 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), n + 2 * BCM283X_NCPUS, | ||
225 | + qdev_get_gpio_in(cpudev, ARM_CPU_VIRQ)); | ||
226 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), n + 3 * BCM283X_NCPUS, | ||
227 | + qdev_get_gpio_in(cpudev, ARM_CPU_VFIQ)); | ||
228 | + | ||
229 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), n + 4 * BCM283X_NCPUS, | ||
230 | + qdev_get_gpio_in(gicdev, | ||
231 | + PPI(n, GIC400_MAINTENANCE_IRQ))); | ||
232 | + | ||
233 | + /* Connect timers from the CPU to the interrupt controller */ | ||
234 | + qdev_connect_gpio_out(cpudev, GTIMER_PHYS, | ||
235 | + qdev_get_gpio_in(gicdev, PPI(n, GIC400_TIMER_NS_EL1_IRQ))); | ||
236 | + qdev_connect_gpio_out(cpudev, GTIMER_VIRT, | ||
237 | + qdev_get_gpio_in(gicdev, PPI(n, GIC400_TIMER_VIRT_IRQ))); | ||
238 | + qdev_connect_gpio_out(cpudev, GTIMER_HYP, | ||
239 | + qdev_get_gpio_in(gicdev, PPI(n, GIC400_TIMER_NS_EL2_IRQ))); | ||
240 | + qdev_connect_gpio_out(cpudev, GTIMER_SEC, | ||
241 | + qdev_get_gpio_in(gicdev, PPI(n, GIC400_TIMER_S_EL1_IRQ))); | ||
242 | + /* PMU interrupt */ | ||
243 | + qdev_connect_gpio_out_named(cpudev, "pmu-interrupt", 0, | ||
244 | + qdev_get_gpio_in(gicdev, PPI(n, VIRTUAL_PMU_IRQ))); | ||
245 | + } | ||
246 | + | ||
247 | + /* Connect UART0 to the interrupt controller */ | ||
248 | + sysbus_connect_irq(SYS_BUS_DEVICE(&ps_base->uart0), 0, | ||
249 | + qdev_get_gpio_in(gicdev, GIC_SPI_INTERRUPT_UART0)); | ||
250 | + | ||
251 | + /* Connect AUX / UART1 to the interrupt controller */ | ||
252 | + sysbus_connect_irq(SYS_BUS_DEVICE(&ps_base->aux), 0, | ||
253 | + qdev_get_gpio_in(gicdev, GIC_SPI_INTERRUPT_AUX_UART1)); | ||
254 | + | ||
255 | + /* Connect VC mailbox to the interrupt controller */ | ||
256 | + sysbus_connect_irq(SYS_BUS_DEVICE(&ps_base->mboxes), 0, | ||
257 | + qdev_get_gpio_in(gicdev, GIC_SPI_INTERRUPT_MBOX)); | ||
258 | + | ||
259 | + /* Connect SD host to the interrupt controller */ | ||
260 | + sysbus_connect_irq(SYS_BUS_DEVICE(&ps_base->sdhost), 0, | ||
261 | + qdev_get_gpio_in(gicdev, GIC_SPI_INTERRUPT_SDHOST)); | ||
262 | + | ||
263 | + /* According to DTS, EMMC and EMMC2 share one irq */ | ||
264 | + DeviceState *mmc_irq_orgate = DEVICE(&ps->mmc_irq_orgate); | ||
265 | + | ||
266 | + /* Connect EMMC and EMMC2 to the interrupt controller */ | ||
267 | + qdev_connect_gpio_out(mmc_irq_orgate, 0, | ||
268 | + qdev_get_gpio_in(gicdev, GIC_SPI_INTERRUPT_EMMC_EMMC2)); | ||
269 | + | ||
270 | + /* Connect USB OTG and MPHI to the interrupt controller */ | ||
271 | + sysbus_connect_irq(SYS_BUS_DEVICE(&ps_base->mphi), 0, | ||
272 | + qdev_get_gpio_in(gicdev, GIC_SPI_INTERRUPT_MPHI)); | ||
273 | + sysbus_connect_irq(SYS_BUS_DEVICE(&ps_base->dwc2), 0, | ||
274 | + qdev_get_gpio_in(gicdev, GIC_SPI_INTERRUPT_DWC2)); | ||
275 | + | ||
276 | + /* Connect DMA 0-6 to the interrupt controller */ | ||
277 | + for (int n = GIC_SPI_INTERRUPT_DMA_0; n <= GIC_SPI_INTERRUPT_DMA_6; n++) { | ||
278 | + sysbus_connect_irq(SYS_BUS_DEVICE(&ps_base->dma), | ||
279 | + n - GIC_SPI_INTERRUPT_DMA_0, | ||
280 | + qdev_get_gpio_in(gicdev, n)); | ||
281 | + } | ||
282 | + | ||
283 | + /* According to DTS, DMA 7 and 8 share one irq */ | ||
284 | + DeviceState *dma_7_8_irq_orgate = DEVICE(&ps->dma_7_8_irq_orgate); | ||
285 | + | ||
286 | + /* Connect DMA 7-8 to the interrupt controller */ | ||
287 | + qdev_connect_gpio_out(dma_7_8_irq_orgate, 0, | ||
288 | + qdev_get_gpio_in(gicdev, GIC_SPI_INTERRUPT_DMA_7_8)); | ||
289 | + | ||
290 | + /* According to DTS, DMA 9 and 10 share one irq */ | ||
291 | + DeviceState *dma_9_10_irq_orgate = DEVICE(&ps->dma_9_10_irq_orgate); | ||
292 | + | ||
293 | + /* Connect DMA 9-10 to the interrupt controller */ | ||
294 | + qdev_connect_gpio_out(dma_9_10_irq_orgate, 0, | ||
295 | + qdev_get_gpio_in(gicdev, GIC_SPI_INTERRUPT_DMA_9_10)); | ||
296 | + | ||
297 | + /* Pass through inbound GPIO lines to the GIC */ | ||
298 | + qdev_init_gpio_in(dev, bcm2838_gic_set_irq, GIC_NUM_IRQS); | ||
299 | + | ||
300 | + /* Pass through outbound IRQ lines from the GIC */ | ||
301 | + qdev_pass_gpios(DEVICE(&s->gic), DEVICE(&s->peripherals), NULL); | ||
302 | } | ||
303 | |||
304 | static void bcm2838_class_init(ObjectClass *oc, void *data) | ||
305 | diff --git a/hw/arm/trace-events b/hw/arm/trace-events | ||
306 | index XXXXXXX..XXXXXXX 100644 | ||
307 | --- a/hw/arm/trace-events | ||
308 | +++ b/hw/arm/trace-events | ||
309 | @@ -XXX,XX +XXX,XX @@ z2_aer915_event(int8_t event, int8_t len) "i2c event =0x%x len=%d bytes" | ||
310 | xen_create_virtio_mmio_devices(int i, int irq, uint64_t base) "Created virtio-mmio device %d: irq %d base 0x%"PRIx64 | ||
311 | xen_init_ram(uint64_t machine_ram_size) "Initialized xen ram with size 0x%"PRIx64 | ||
312 | xen_enable_tpm(uint64_t addr) "Connected tpmdev at address 0x%"PRIx64 | ||
313 | + | ||
314 | +# bcm2838.c | ||
315 | +bcm2838_gic_set_irq(int irq, int level) "gic irq:%d lvl:%d" | ||
316 | -- | ||
317 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Sergey Kambalin <serg.oker@gmail.com> | ||
2 | 1 | ||
3 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Message-id: 20240226000259.2752893-7-sergey.kambalin@auriga.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | include/hw/gpio/bcm2838_gpio.h | 40 +++++++++ | ||
9 | hw/gpio/bcm2838_gpio.c | 153 +++++++++++++++++++++++++++++++++ | ||
10 | hw/gpio/meson.build | 5 +- | ||
11 | 3 files changed, 197 insertions(+), 1 deletion(-) | ||
12 | create mode 100644 include/hw/gpio/bcm2838_gpio.h | ||
13 | create mode 100644 hw/gpio/bcm2838_gpio.c | ||
14 | |||
15 | diff --git a/include/hw/gpio/bcm2838_gpio.h b/include/hw/gpio/bcm2838_gpio.h | ||
16 | new file mode 100644 | ||
17 | index XXXXXXX..XXXXXXX | ||
18 | --- /dev/null | ||
19 | +++ b/include/hw/gpio/bcm2838_gpio.h | ||
20 | @@ -XXX,XX +XXX,XX @@ | ||
21 | +/* | ||
22 | + * Raspberry Pi (BCM2838) GPIO Controller | ||
23 | + * This implementation is based on bcm2835_gpio (hw/gpio/bcm2835_gpio.c) | ||
24 | + * | ||
25 | + * Copyright (c) 2022 Auriga LLC | ||
26 | + * | ||
27 | + * Authors: | ||
28 | + * Lotosh, Aleksey <aleksey.lotosh@auriga.com> | ||
29 | + * | ||
30 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
31 | + * See the COPYING file in the top-level directory. | ||
32 | + */ | ||
33 | + | ||
34 | +#ifndef BCM2838_GPIO_H | ||
35 | +#define BCM2838_GPIO_H | ||
36 | + | ||
37 | +#include "hw/sysbus.h" | ||
38 | +#include "qom/object.h" | ||
39 | + | ||
40 | +#define TYPE_BCM2838_GPIO "bcm2838-gpio" | ||
41 | +OBJECT_DECLARE_SIMPLE_TYPE(BCM2838GpioState, BCM2838_GPIO) | ||
42 | + | ||
43 | +#define BCM2838_GPIO_REGS_SIZE 0x1000 | ||
44 | +#define BCM2838_GPIO_NUM 58 | ||
45 | +#define GPIO_PUP_PDN_CNTRL_NUM 4 | ||
46 | + | ||
47 | +struct BCM2838GpioState { | ||
48 | + SysBusDevice parent_obj; | ||
49 | + | ||
50 | + MemoryRegion iomem; | ||
51 | + | ||
52 | + | ||
53 | + uint8_t fsel[BCM2838_GPIO_NUM]; | ||
54 | + uint32_t lev0, lev1; | ||
55 | + uint8_t sd_fsel; | ||
56 | + qemu_irq out[BCM2838_GPIO_NUM]; | ||
57 | + uint32_t pup_cntrl_reg[GPIO_PUP_PDN_CNTRL_NUM]; | ||
58 | +}; | ||
59 | + | ||
60 | +#endif | ||
61 | diff --git a/hw/gpio/bcm2838_gpio.c b/hw/gpio/bcm2838_gpio.c | ||
62 | new file mode 100644 | ||
63 | index XXXXXXX..XXXXXXX | ||
64 | --- /dev/null | ||
65 | +++ b/hw/gpio/bcm2838_gpio.c | ||
66 | @@ -XXX,XX +XXX,XX @@ | ||
67 | +/* | ||
68 | + * Raspberry Pi (BCM2838) GPIO Controller | ||
69 | + * This implementation is based on bcm2835_gpio (hw/gpio/bcm2835_gpio.c) | ||
70 | + * | ||
71 | + * Copyright (c) 2022 Auriga LLC | ||
72 | + * | ||
73 | + * Authors: | ||
74 | + * Lotosh, Aleksey <aleksey.lotosh@auriga.com> | ||
75 | + * | ||
76 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
77 | + */ | ||
78 | + | ||
79 | +#include "qemu/osdep.h" | ||
80 | +#include "qemu/log.h" | ||
81 | +#include "qemu/module.h" | ||
82 | +#include "qemu/timer.h" | ||
83 | +#include "qapi/error.h" | ||
84 | +#include "hw/sysbus.h" | ||
85 | +#include "migration/vmstate.h" | ||
86 | +#include "hw/gpio/bcm2838_gpio.h" | ||
87 | + | ||
88 | +#define GPFSEL0 0x00 | ||
89 | +#define GPFSEL1 0x04 | ||
90 | +#define GPFSEL2 0x08 | ||
91 | +#define GPFSEL3 0x0C | ||
92 | +#define GPFSEL4 0x10 | ||
93 | +#define GPFSEL5 0x14 | ||
94 | +#define GPSET0 0x1C | ||
95 | +#define GPSET1 0x20 | ||
96 | +#define GPCLR0 0x28 | ||
97 | +#define GPCLR1 0x2C | ||
98 | +#define GPLEV0 0x34 | ||
99 | +#define GPLEV1 0x38 | ||
100 | +#define GPEDS0 0x40 | ||
101 | +#define GPEDS1 0x44 | ||
102 | +#define GPREN0 0x4C | ||
103 | +#define GPREN1 0x50 | ||
104 | +#define GPFEN0 0x58 | ||
105 | +#define GPFEN1 0x5C | ||
106 | +#define GPHEN0 0x64 | ||
107 | +#define GPHEN1 0x68 | ||
108 | +#define GPLEN0 0x70 | ||
109 | +#define GPLEN1 0x74 | ||
110 | +#define GPAREN0 0x7C | ||
111 | +#define GPAREN1 0x80 | ||
112 | +#define GPAFEN0 0x88 | ||
113 | +#define GPAFEN1 0x8C | ||
114 | + | ||
115 | +#define GPIO_PUP_PDN_CNTRL_REG0 0xE4 | ||
116 | +#define GPIO_PUP_PDN_CNTRL_REG1 0xE8 | ||
117 | +#define GPIO_PUP_PDN_CNTRL_REG2 0xEC | ||
118 | +#define GPIO_PUP_PDN_CNTRL_REG3 0xF0 | ||
119 | + | ||
120 | +#define RESET_VAL_CNTRL_REG0 0xAAA95555 | ||
121 | +#define RESET_VAL_CNTRL_REG1 0xA0AAAAAA | ||
122 | +#define RESET_VAL_CNTRL_REG2 0x50AAA95A | ||
123 | +#define RESET_VAL_CNTRL_REG3 0x00055555 | ||
124 | + | ||
125 | +#define BYTES_IN_WORD 4 | ||
126 | + | ||
127 | +static uint64_t bcm2838_gpio_read(void *opaque, hwaddr offset, unsigned size) | ||
128 | +{ | ||
129 | + uint64_t value = 0; | ||
130 | + | ||
131 | + qemu_log_mask(LOG_UNIMP, "%s: %s: not implemented for %"HWADDR_PRIx"\n", | ||
132 | + TYPE_BCM2838_GPIO, __func__, offset); | ||
133 | + | ||
134 | + return value; | ||
135 | +} | ||
136 | + | ||
137 | +static void bcm2838_gpio_write(void *opaque, hwaddr offset, uint64_t value, | ||
138 | + unsigned size) | ||
139 | +{ | ||
140 | + qemu_log_mask(LOG_UNIMP, "%s: %s: not implemented for %"HWADDR_PRIx"\n", | ||
141 | + TYPE_BCM2838_GPIO, __func__, offset); | ||
142 | +} | ||
143 | + | ||
144 | +static void bcm2838_gpio_reset(DeviceState *dev) | ||
145 | +{ | ||
146 | + BCM2838GpioState *s = BCM2838_GPIO(dev); | ||
147 | + | ||
148 | + s->lev0 = 0; | ||
149 | + s->lev1 = 0; | ||
150 | + | ||
151 | + memset(s->fsel, 0, sizeof(s->fsel)); | ||
152 | + | ||
153 | + s->pup_cntrl_reg[0] = RESET_VAL_CNTRL_REG0; | ||
154 | + s->pup_cntrl_reg[1] = RESET_VAL_CNTRL_REG1; | ||
155 | + s->pup_cntrl_reg[2] = RESET_VAL_CNTRL_REG2; | ||
156 | + s->pup_cntrl_reg[3] = RESET_VAL_CNTRL_REG3; | ||
157 | +} | ||
158 | + | ||
159 | +static const MemoryRegionOps bcm2838_gpio_ops = { | ||
160 | + .read = bcm2838_gpio_read, | ||
161 | + .write = bcm2838_gpio_write, | ||
162 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
163 | +}; | ||
164 | + | ||
165 | +static const VMStateDescription vmstate_bcm2838_gpio = { | ||
166 | + .name = "bcm2838_gpio", | ||
167 | + .version_id = 1, | ||
168 | + .minimum_version_id = 1, | ||
169 | + .fields = (VMStateField[]) { | ||
170 | + VMSTATE_UINT8_ARRAY(fsel, BCM2838GpioState, BCM2838_GPIO_NUM), | ||
171 | + VMSTATE_UINT32(lev0, BCM2838GpioState), | ||
172 | + VMSTATE_UINT32(lev1, BCM2838GpioState), | ||
173 | + VMSTATE_UINT8(sd_fsel, BCM2838GpioState), | ||
174 | + VMSTATE_UINT32_ARRAY(pup_cntrl_reg, BCM2838GpioState, | ||
175 | + GPIO_PUP_PDN_CNTRL_NUM), | ||
176 | + VMSTATE_END_OF_LIST() | ||
177 | + } | ||
178 | +}; | ||
179 | + | ||
180 | +static void bcm2838_gpio_init(Object *obj) | ||
181 | +{ | ||
182 | + BCM2838GpioState *s = BCM2838_GPIO(obj); | ||
183 | + DeviceState *dev = DEVICE(obj); | ||
184 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
185 | + | ||
186 | + memory_region_init_io(&s->iomem, obj, &bcm2838_gpio_ops, s, | ||
187 | + "bcm2838_gpio", BCM2838_GPIO_REGS_SIZE); | ||
188 | + sysbus_init_mmio(sbd, &s->iomem); | ||
189 | + qdev_init_gpio_out(dev, s->out, BCM2838_GPIO_NUM); | ||
190 | +} | ||
191 | + | ||
192 | +static void bcm2838_gpio_realize(DeviceState *dev, Error **errp) | ||
193 | +{ | ||
194 | + /* Temporary stub. Do nothing */ | ||
195 | +} | ||
196 | + | ||
197 | +static void bcm2838_gpio_class_init(ObjectClass *klass, void *data) | ||
198 | +{ | ||
199 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
200 | + | ||
201 | + dc->vmsd = &vmstate_bcm2838_gpio; | ||
202 | + dc->realize = &bcm2838_gpio_realize; | ||
203 | + dc->reset = &bcm2838_gpio_reset; | ||
204 | +} | ||
205 | + | ||
206 | +static const TypeInfo bcm2838_gpio_info = { | ||
207 | + .name = TYPE_BCM2838_GPIO, | ||
208 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
209 | + .instance_size = sizeof(BCM2838GpioState), | ||
210 | + .instance_init = bcm2838_gpio_init, | ||
211 | + .class_init = bcm2838_gpio_class_init, | ||
212 | +}; | ||
213 | + | ||
214 | +static void bcm2838_gpio_register_types(void) | ||
215 | +{ | ||
216 | + type_register_static(&bcm2838_gpio_info); | ||
217 | +} | ||
218 | + | ||
219 | +type_init(bcm2838_gpio_register_types) | ||
220 | diff --git a/hw/gpio/meson.build b/hw/gpio/meson.build | ||
221 | index XXXXXXX..XXXXXXX 100644 | ||
222 | --- a/hw/gpio/meson.build | ||
223 | +++ b/hw/gpio/meson.build | ||
224 | @@ -XXX,XX +XXX,XX @@ system_ss.add(when: 'CONFIG_IMX', if_true: files('imx_gpio.c')) | ||
225 | system_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_gpio.c')) | ||
226 | system_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_gpio.c')) | ||
227 | system_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_gpio.c')) | ||
228 | -system_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_gpio.c')) | ||
229 | +system_ss.add(when: 'CONFIG_RASPI', if_true: files( | ||
230 | + 'bcm2835_gpio.c', | ||
231 | + 'bcm2838_gpio.c' | ||
232 | +)) | ||
233 | system_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_gpio.c')) | ||
234 | system_ss.add(when: 'CONFIG_SIFIVE_GPIO', if_true: files('sifive_gpio.c')) | ||
235 | -- | ||
236 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Sergey Kambalin <serg.oker@gmail.com> | ||
2 | 1 | ||
3 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Message-id: 20240226000259.2752893-8-sergey.kambalin@auriga.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | hw/gpio/bcm2838_gpio.c | 193 ++++++++++++++++++++++++++++++++++++++++- | ||
9 | 1 file changed, 190 insertions(+), 3 deletions(-) | ||
10 | |||
11 | diff --git a/hw/gpio/bcm2838_gpio.c b/hw/gpio/bcm2838_gpio.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/hw/gpio/bcm2838_gpio.c | ||
14 | +++ b/hw/gpio/bcm2838_gpio.c | ||
15 | @@ -XXX,XX +XXX,XX @@ | ||
16 | #include "hw/sysbus.h" | ||
17 | #include "migration/vmstate.h" | ||
18 | #include "hw/gpio/bcm2838_gpio.h" | ||
19 | +#include "hw/irq.h" | ||
20 | |||
21 | #define GPFSEL0 0x00 | ||
22 | #define GPFSEL1 0x04 | ||
23 | @@ -XXX,XX +XXX,XX @@ | ||
24 | #define RESET_VAL_CNTRL_REG2 0x50AAA95A | ||
25 | #define RESET_VAL_CNTRL_REG3 0x00055555 | ||
26 | |||
27 | +#define NUM_FSELN_IN_GPFSELN 10 | ||
28 | +#define NUM_BITS_FSELN 3 | ||
29 | +#define MASK_FSELN 0x7 | ||
30 | + | ||
31 | #define BYTES_IN_WORD 4 | ||
32 | |||
33 | +static uint32_t gpfsel_get(BCM2838GpioState *s, uint8_t reg) | ||
34 | +{ | ||
35 | + int i; | ||
36 | + uint32_t value = 0; | ||
37 | + for (i = 0; i < NUM_FSELN_IN_GPFSELN; i++) { | ||
38 | + uint32_t index = NUM_FSELN_IN_GPFSELN * reg + i; | ||
39 | + if (index < sizeof(s->fsel)) { | ||
40 | + value |= (s->fsel[index] & MASK_FSELN) << (NUM_BITS_FSELN * i); | ||
41 | + } | ||
42 | + } | ||
43 | + return value; | ||
44 | +} | ||
45 | + | ||
46 | +static void gpfsel_set(BCM2838GpioState *s, uint8_t reg, uint32_t value) | ||
47 | +{ | ||
48 | + int i; | ||
49 | + for (i = 0; i < NUM_FSELN_IN_GPFSELN; i++) { | ||
50 | + uint32_t index = NUM_FSELN_IN_GPFSELN * reg + i; | ||
51 | + if (index < sizeof(s->fsel)) { | ||
52 | + int fsel = (value >> (NUM_BITS_FSELN * i)) & MASK_FSELN; | ||
53 | + s->fsel[index] = fsel; | ||
54 | + } | ||
55 | + } | ||
56 | +} | ||
57 | + | ||
58 | +static int gpfsel_is_out(BCM2838GpioState *s, int index) | ||
59 | +{ | ||
60 | + if (index >= 0 && index < BCM2838_GPIO_NUM) { | ||
61 | + return s->fsel[index] == 1; | ||
62 | + } | ||
63 | + return 0; | ||
64 | +} | ||
65 | + | ||
66 | +static void gpset(BCM2838GpioState *s, uint32_t val, uint8_t start, | ||
67 | + uint8_t count, uint32_t *lev) | ||
68 | +{ | ||
69 | + uint32_t changes = val & ~*lev; | ||
70 | + uint32_t cur = 1; | ||
71 | + | ||
72 | + int i; | ||
73 | + for (i = 0; i < count; i++) { | ||
74 | + if ((changes & cur) && (gpfsel_is_out(s, start + i))) { | ||
75 | + qemu_set_irq(s->out[start + i], 1); | ||
76 | + } | ||
77 | + cur <<= 1; | ||
78 | + } | ||
79 | + | ||
80 | + *lev |= val; | ||
81 | +} | ||
82 | + | ||
83 | +static void gpclr(BCM2838GpioState *s, uint32_t val, uint8_t start, | ||
84 | + uint8_t count, uint32_t *lev) | ||
85 | +{ | ||
86 | + uint32_t changes = val & *lev; | ||
87 | + uint32_t cur = 1; | ||
88 | + | ||
89 | + int i; | ||
90 | + for (i = 0; i < count; i++) { | ||
91 | + if ((changes & cur) && (gpfsel_is_out(s, start + i))) { | ||
92 | + qemu_set_irq(s->out[start + i], 0); | ||
93 | + } | ||
94 | + cur <<= 1; | ||
95 | + } | ||
96 | + | ||
97 | + *lev &= ~val; | ||
98 | +} | ||
99 | + | ||
100 | static uint64_t bcm2838_gpio_read(void *opaque, hwaddr offset, unsigned size) | ||
101 | { | ||
102 | + BCM2838GpioState *s = (BCM2838GpioState *)opaque; | ||
103 | uint64_t value = 0; | ||
104 | |||
105 | - qemu_log_mask(LOG_UNIMP, "%s: %s: not implemented for %"HWADDR_PRIx"\n", | ||
106 | - TYPE_BCM2838_GPIO, __func__, offset); | ||
107 | + switch (offset) { | ||
108 | + case GPFSEL0: | ||
109 | + case GPFSEL1: | ||
110 | + case GPFSEL2: | ||
111 | + case GPFSEL3: | ||
112 | + case GPFSEL4: | ||
113 | + case GPFSEL5: | ||
114 | + value = gpfsel_get(s, offset / BYTES_IN_WORD); | ||
115 | + break; | ||
116 | + case GPSET0: | ||
117 | + case GPSET1: | ||
118 | + case GPCLR0: | ||
119 | + case GPCLR1: | ||
120 | + /* Write Only */ | ||
121 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: %s: Attempt reading from write only" | ||
122 | + " register. 0x%"PRIx64" will be returned." | ||
123 | + " Address 0x%"HWADDR_PRIx", size %u\n", | ||
124 | + TYPE_BCM2838_GPIO, __func__, value, offset, size); | ||
125 | + break; | ||
126 | + case GPLEV0: | ||
127 | + value = s->lev0; | ||
128 | + break; | ||
129 | + case GPLEV1: | ||
130 | + value = s->lev1; | ||
131 | + break; | ||
132 | + case GPEDS0: | ||
133 | + case GPEDS1: | ||
134 | + case GPREN0: | ||
135 | + case GPREN1: | ||
136 | + case GPFEN0: | ||
137 | + case GPFEN1: | ||
138 | + case GPHEN0: | ||
139 | + case GPHEN1: | ||
140 | + case GPLEN0: | ||
141 | + case GPLEN1: | ||
142 | + case GPAREN0: | ||
143 | + case GPAREN1: | ||
144 | + case GPAFEN0: | ||
145 | + case GPAFEN1: | ||
146 | + /* Not implemented */ | ||
147 | + qemu_log_mask(LOG_UNIMP, "%s: %s: not implemented for %"HWADDR_PRIx"\n", | ||
148 | + TYPE_BCM2838_GPIO, __func__, offset); | ||
149 | + break; | ||
150 | + case GPIO_PUP_PDN_CNTRL_REG0: | ||
151 | + case GPIO_PUP_PDN_CNTRL_REG1: | ||
152 | + case GPIO_PUP_PDN_CNTRL_REG2: | ||
153 | + case GPIO_PUP_PDN_CNTRL_REG3: | ||
154 | + value = s->pup_cntrl_reg[(offset - GPIO_PUP_PDN_CNTRL_REG0) | ||
155 | + / sizeof(s->pup_cntrl_reg[0])]; | ||
156 | + break; | ||
157 | + default: | ||
158 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: %s: bad offset %"HWADDR_PRIx"\n", | ||
159 | + TYPE_BCM2838_GPIO, __func__, offset); | ||
160 | + break; | ||
161 | + } | ||
162 | |||
163 | return value; | ||
164 | } | ||
165 | @@ -XXX,XX +XXX,XX @@ static uint64_t bcm2838_gpio_read(void *opaque, hwaddr offset, unsigned size) | ||
166 | static void bcm2838_gpio_write(void *opaque, hwaddr offset, uint64_t value, | ||
167 | unsigned size) | ||
168 | { | ||
169 | - qemu_log_mask(LOG_UNIMP, "%s: %s: not implemented for %"HWADDR_PRIx"\n", | ||
170 | + BCM2838GpioState *s = (BCM2838GpioState *)opaque; | ||
171 | + | ||
172 | + switch (offset) { | ||
173 | + case GPFSEL0: | ||
174 | + case GPFSEL1: | ||
175 | + case GPFSEL2: | ||
176 | + case GPFSEL3: | ||
177 | + case GPFSEL4: | ||
178 | + case GPFSEL5: | ||
179 | + gpfsel_set(s, offset / BYTES_IN_WORD, value); | ||
180 | + break; | ||
181 | + case GPSET0: | ||
182 | + gpset(s, value, 0, 32, &s->lev0); | ||
183 | + break; | ||
184 | + case GPSET1: | ||
185 | + gpset(s, value, 32, 22, &s->lev1); | ||
186 | + break; | ||
187 | + case GPCLR0: | ||
188 | + gpclr(s, value, 0, 32, &s->lev0); | ||
189 | + break; | ||
190 | + case GPCLR1: | ||
191 | + gpclr(s, value, 32, 22, &s->lev1); | ||
192 | + break; | ||
193 | + case GPLEV0: | ||
194 | + case GPLEV1: | ||
195 | + /* Read Only */ | ||
196 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: %s: Attempt writing 0x%"PRIx64"" | ||
197 | + " to read only register. Ignored." | ||
198 | + " Address 0x%"HWADDR_PRIx", size %u\n", | ||
199 | + TYPE_BCM2838_GPIO, __func__, value, offset, size); | ||
200 | + break; | ||
201 | + case GPEDS0: | ||
202 | + case GPEDS1: | ||
203 | + case GPREN0: | ||
204 | + case GPREN1: | ||
205 | + case GPFEN0: | ||
206 | + case GPFEN1: | ||
207 | + case GPHEN0: | ||
208 | + case GPHEN1: | ||
209 | + case GPLEN0: | ||
210 | + case GPLEN1: | ||
211 | + case GPAREN0: | ||
212 | + case GPAREN1: | ||
213 | + case GPAFEN0: | ||
214 | + case GPAFEN1: | ||
215 | + /* Not implemented */ | ||
216 | + qemu_log_mask(LOG_UNIMP, "%s: %s: not implemented for %"HWADDR_PRIx"\n", | ||
217 | + TYPE_BCM2838_GPIO, __func__, offset); | ||
218 | + break; | ||
219 | + case GPIO_PUP_PDN_CNTRL_REG0: | ||
220 | + case GPIO_PUP_PDN_CNTRL_REG1: | ||
221 | + case GPIO_PUP_PDN_CNTRL_REG2: | ||
222 | + case GPIO_PUP_PDN_CNTRL_REG3: | ||
223 | + s->pup_cntrl_reg[(offset - GPIO_PUP_PDN_CNTRL_REG0) | ||
224 | + / sizeof(s->pup_cntrl_reg[0])] = value; | ||
225 | + break; | ||
226 | + default: | ||
227 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: %s: bad offset %"HWADDR_PRIx"\n", | ||
228 | TYPE_BCM2838_GPIO, __func__, offset); | ||
229 | + } | ||
230 | + return; | ||
231 | } | ||
232 | |||
233 | static void bcm2838_gpio_reset(DeviceState *dev) | ||
234 | { | ||
235 | BCM2838GpioState *s = BCM2838_GPIO(dev); | ||
236 | |||
237 | + memset(s->fsel, 0, sizeof(s->fsel)); | ||
238 | + | ||
239 | s->lev0 = 0; | ||
240 | s->lev1 = 0; | ||
241 | |||
242 | -- | ||
243 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Sergey Kambalin <serg.oker@gmail.com> | ||
2 | 1 | ||
3 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Message-id: 20240226000259.2752893-9-sergey.kambalin@auriga.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | include/hw/gpio/bcm2838_gpio.h | 5 ++++ | ||
9 | hw/gpio/bcm2838_gpio.c | 52 +++++++++++++++++++++++++++++++++- | ||
10 | 2 files changed, 56 insertions(+), 1 deletion(-) | ||
11 | |||
12 | diff --git a/include/hw/gpio/bcm2838_gpio.h b/include/hw/gpio/bcm2838_gpio.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/include/hw/gpio/bcm2838_gpio.h | ||
15 | +++ b/include/hw/gpio/bcm2838_gpio.h | ||
16 | @@ -XXX,XX +XXX,XX @@ | ||
17 | #ifndef BCM2838_GPIO_H | ||
18 | #define BCM2838_GPIO_H | ||
19 | |||
20 | +#include "hw/sd/sd.h" | ||
21 | #include "hw/sysbus.h" | ||
22 | #include "qom/object.h" | ||
23 | |||
24 | @@ -XXX,XX +XXX,XX @@ struct BCM2838GpioState { | ||
25 | |||
26 | MemoryRegion iomem; | ||
27 | |||
28 | + /* SDBus selector */ | ||
29 | + SDBus sdbus; | ||
30 | + SDBus *sdbus_sdhci; | ||
31 | + SDBus *sdbus_sdhost; | ||
32 | |||
33 | uint8_t fsel[BCM2838_GPIO_NUM]; | ||
34 | uint32_t lev0, lev1; | ||
35 | diff --git a/hw/gpio/bcm2838_gpio.c b/hw/gpio/bcm2838_gpio.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/hw/gpio/bcm2838_gpio.c | ||
38 | +++ b/hw/gpio/bcm2838_gpio.c | ||
39 | @@ -XXX,XX +XXX,XX @@ | ||
40 | #include "qapi/error.h" | ||
41 | #include "hw/sysbus.h" | ||
42 | #include "migration/vmstate.h" | ||
43 | +#include "hw/sd/sd.h" | ||
44 | #include "hw/gpio/bcm2838_gpio.h" | ||
45 | #include "hw/irq.h" | ||
46 | |||
47 | @@ -XXX,XX +XXX,XX @@ | ||
48 | |||
49 | #define BYTES_IN_WORD 4 | ||
50 | |||
51 | +/* bcm,function property */ | ||
52 | +#define BCM2838_FSEL_GPIO_IN 0 | ||
53 | +#define BCM2838_FSEL_GPIO_OUT 1 | ||
54 | +#define BCM2838_FSEL_ALT5 2 | ||
55 | +#define BCM2838_FSEL_ALT4 3 | ||
56 | +#define BCM2838_FSEL_ALT0 4 | ||
57 | +#define BCM2838_FSEL_ALT1 5 | ||
58 | +#define BCM2838_FSEL_ALT2 6 | ||
59 | +#define BCM2838_FSEL_ALT3 7 | ||
60 | + | ||
61 | static uint32_t gpfsel_get(BCM2838GpioState *s, uint8_t reg) | ||
62 | { | ||
63 | int i; | ||
64 | @@ -XXX,XX +XXX,XX @@ static void gpfsel_set(BCM2838GpioState *s, uint8_t reg, uint32_t value) | ||
65 | s->fsel[index] = fsel; | ||
66 | } | ||
67 | } | ||
68 | + | ||
69 | + /* SD controller selection (48-53) */ | ||
70 | + if (s->sd_fsel != BCM2838_FSEL_GPIO_IN | ||
71 | + && (s->fsel[48] == BCM2838_FSEL_GPIO_IN) | ||
72 | + && (s->fsel[49] == BCM2838_FSEL_GPIO_IN) | ||
73 | + && (s->fsel[50] == BCM2838_FSEL_GPIO_IN) | ||
74 | + && (s->fsel[51] == BCM2838_FSEL_GPIO_IN) | ||
75 | + && (s->fsel[52] == BCM2838_FSEL_GPIO_IN) | ||
76 | + && (s->fsel[53] == BCM2838_FSEL_GPIO_IN) | ||
77 | + ) { | ||
78 | + /* SDHCI controller selected */ | ||
79 | + sdbus_reparent_card(s->sdbus_sdhost, s->sdbus_sdhci); | ||
80 | + s->sd_fsel = BCM2838_FSEL_GPIO_IN; | ||
81 | + } else if (s->sd_fsel != BCM2838_FSEL_ALT0 | ||
82 | + && (s->fsel[48] == BCM2838_FSEL_ALT0) /* SD_CLK_R */ | ||
83 | + && (s->fsel[49] == BCM2838_FSEL_ALT0) /* SD_CMD_R */ | ||
84 | + && (s->fsel[50] == BCM2838_FSEL_ALT0) /* SD_DATA0_R */ | ||
85 | + && (s->fsel[51] == BCM2838_FSEL_ALT0) /* SD_DATA1_R */ | ||
86 | + && (s->fsel[52] == BCM2838_FSEL_ALT0) /* SD_DATA2_R */ | ||
87 | + && (s->fsel[53] == BCM2838_FSEL_ALT0) /* SD_DATA3_R */ | ||
88 | + ) { | ||
89 | + /* SDHost controller selected */ | ||
90 | + sdbus_reparent_card(s->sdbus_sdhci, s->sdbus_sdhost); | ||
91 | + s->sd_fsel = BCM2838_FSEL_ALT0; | ||
92 | + } | ||
93 | } | ||
94 | |||
95 | static int gpfsel_is_out(BCM2838GpioState *s, int index) | ||
96 | @@ -XXX,XX +XXX,XX @@ static void bcm2838_gpio_reset(DeviceState *dev) | ||
97 | |||
98 | memset(s->fsel, 0, sizeof(s->fsel)); | ||
99 | |||
100 | + s->sd_fsel = 0; | ||
101 | + | ||
102 | + /* SDHCI is selected by default */ | ||
103 | + sdbus_reparent_card(&s->sdbus, s->sdbus_sdhci); | ||
104 | + | ||
105 | s->lev0 = 0; | ||
106 | s->lev1 = 0; | ||
107 | |||
108 | @@ -XXX,XX +XXX,XX @@ static void bcm2838_gpio_init(Object *obj) | ||
109 | DeviceState *dev = DEVICE(obj); | ||
110 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
111 | |||
112 | + qbus_init(&s->sdbus, sizeof(s->sdbus), TYPE_SD_BUS, DEVICE(s), "sd-bus"); | ||
113 | + | ||
114 | memory_region_init_io(&s->iomem, obj, &bcm2838_gpio_ops, s, | ||
115 | "bcm2838_gpio", BCM2838_GPIO_REGS_SIZE); | ||
116 | sysbus_init_mmio(sbd, &s->iomem); | ||
117 | @@ -XXX,XX +XXX,XX @@ static void bcm2838_gpio_init(Object *obj) | ||
118 | |||
119 | static void bcm2838_gpio_realize(DeviceState *dev, Error **errp) | ||
120 | { | ||
121 | - /* Temporary stub. Do nothing */ | ||
122 | + BCM2838GpioState *s = BCM2838_GPIO(dev); | ||
123 | + Object *obj; | ||
124 | + | ||
125 | + obj = object_property_get_link(OBJECT(dev), "sdbus-sdhci", &error_abort); | ||
126 | + s->sdbus_sdhci = SD_BUS(obj); | ||
127 | + | ||
128 | + obj = object_property_get_link(OBJECT(dev), "sdbus-sdhost", &error_abort); | ||
129 | + s->sdbus_sdhost = SD_BUS(obj); | ||
130 | } | ||
131 | |||
132 | static void bcm2838_gpio_class_init(ObjectClass *klass, void *data) | ||
133 | -- | ||
134 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Sergey Kambalin <serg.oker@gmail.com> | ||
2 | 1 | ||
3 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Message-id: 20240226000259.2752893-10-sergey.kambalin@auriga.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | include/hw/arm/bcm2838_peripherals.h | 8 ++ | ||
9 | hw/arm/bcm2838_peripherals.c | 143 +++++++++++++++++++++++++++ | ||
10 | 2 files changed, 151 insertions(+) | ||
11 | |||
12 | diff --git a/include/hw/arm/bcm2838_peripherals.h b/include/hw/arm/bcm2838_peripherals.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/include/hw/arm/bcm2838_peripherals.h | ||
15 | +++ b/include/hw/arm/bcm2838_peripherals.h | ||
16 | @@ -XXX,XX +XXX,XX @@ | ||
17 | #define BCM2838_PERIPHERALS_H | ||
18 | |||
19 | #include "hw/arm/bcm2835_peripherals.h" | ||
20 | +#include "hw/sd/sdhci.h" | ||
21 | +#include "hw/gpio/bcm2838_gpio.h" | ||
22 | |||
23 | /* SPI */ | ||
24 | #define GIC_SPI_INTERRUPT_MBOX 33 | ||
25 | @@ -XXX,XX +XXX,XX @@ | ||
26 | #define GPU_INTERRUPT_DMA14 28 | ||
27 | #define GPU_INTERRUPT_DMA15 31 | ||
28 | |||
29 | +#define BCM2838_MPHI_OFFSET 0xb200 | ||
30 | +#define BCM2838_MPHI_SIZE 0x200 | ||
31 | + | ||
32 | #define TYPE_BCM2838_PERIPHERALS "bcm2838-peripherals" | ||
33 | OBJECT_DECLARE_TYPE(BCM2838PeripheralState, BCM2838PeripheralClass, | ||
34 | BCM2838_PERIPHERALS) | ||
35 | @@ -XXX,XX +XXX,XX @@ struct BCM2838PeripheralState { | ||
36 | MemoryRegion peri_low_mr_alias; | ||
37 | MemoryRegion mphi_mr_alias; | ||
38 | |||
39 | + SDHCIState emmc2; | ||
40 | + BCM2838GpioState gpio; | ||
41 | + | ||
42 | OrIRQState mmc_irq_orgate; | ||
43 | OrIRQState dma_7_8_irq_orgate; | ||
44 | OrIRQState dma_9_10_irq_orgate; | ||
45 | diff --git a/hw/arm/bcm2838_peripherals.c b/hw/arm/bcm2838_peripherals.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/hw/arm/bcm2838_peripherals.c | ||
48 | +++ b/hw/arm/bcm2838_peripherals.c | ||
49 | @@ -XXX,XX +XXX,XX @@ | ||
50 | /* Lower peripheral base address on the VC (GPU) system bus */ | ||
51 | #define BCM2838_VC_PERI_LOW_BASE 0x7c000000 | ||
52 | |||
53 | +/* Capabilities for SD controller: no DMA, high-speed, default clocks etc. */ | ||
54 | +#define BCM2835_SDHC_CAPAREG 0x52134b4 | ||
55 | + | ||
56 | static void bcm2838_peripherals_init(Object *obj) | ||
57 | { | ||
58 | BCM2838PeripheralState *s = BCM2838_PERIPHERALS(obj); | ||
59 | BCM2838PeripheralClass *bc = BCM2838_PERIPHERALS_GET_CLASS(obj); | ||
60 | + BCMSocPeripheralBaseState *s_base = BCM_SOC_PERIPHERALS_BASE(obj); | ||
61 | |||
62 | /* Lower memory region for peripheral devices (exported to the Soc) */ | ||
63 | memory_region_init(&s->peri_low_mr, obj, "bcm2838-peripherals", | ||
64 | bc->peri_low_size); | ||
65 | sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->peri_low_mr); | ||
66 | |||
67 | + /* Extended Mass Media Controller 2 */ | ||
68 | + object_initialize_child(obj, "emmc2", &s->emmc2, TYPE_SYSBUS_SDHCI); | ||
69 | + | ||
70 | + /* GPIO */ | ||
71 | + object_initialize_child(obj, "gpio", &s->gpio, TYPE_BCM2838_GPIO); | ||
72 | + | ||
73 | + object_property_add_const_link(OBJECT(&s->gpio), "sdbus-sdhci", | ||
74 | + OBJECT(&s_base->sdhci.sdbus)); | ||
75 | + object_property_add_const_link(OBJECT(&s->gpio), "sdbus-sdhost", | ||
76 | + OBJECT(&s_base->sdhost.sdbus)); | ||
77 | + | ||
78 | + object_initialize_child(obj, "mmc_irq_orgate", &s->mmc_irq_orgate, | ||
79 | + TYPE_OR_IRQ); | ||
80 | + object_property_set_int(OBJECT(&s->mmc_irq_orgate), "num-lines", 2, | ||
81 | + &error_abort); | ||
82 | + | ||
83 | + object_initialize_child(obj, "dma_7_8_irq_orgate", &s->dma_7_8_irq_orgate, | ||
84 | + TYPE_OR_IRQ); | ||
85 | + object_property_set_int(OBJECT(&s->dma_7_8_irq_orgate), "num-lines", 2, | ||
86 | + &error_abort); | ||
87 | + | ||
88 | + object_initialize_child(obj, "dma_9_10_irq_orgate", &s->dma_9_10_irq_orgate, | ||
89 | + TYPE_OR_IRQ); | ||
90 | + object_property_set_int(OBJECT(&s->dma_9_10_irq_orgate), "num-lines", 2, | ||
91 | + &error_abort); | ||
92 | } | ||
93 | |||
94 | static void bcm2838_peripherals_realize(DeviceState *dev, Error **errp) | ||
95 | { | ||
96 | + DeviceState *mmc_irq_orgate; | ||
97 | + DeviceState *dma_7_8_irq_orgate; | ||
98 | + DeviceState *dma_9_10_irq_orgate; | ||
99 | + MemoryRegion *mphi_mr; | ||
100 | BCM2838PeripheralState *s = BCM2838_PERIPHERALS(dev); | ||
101 | BCMSocPeripheralBaseState *s_base = BCM_SOC_PERIPHERALS_BASE(dev); | ||
102 | + int n; | ||
103 | |||
104 | bcm_soc_peripherals_common_realize(dev, errp); | ||
105 | |||
106 | @@ -XXX,XX +XXX,XX @@ static void bcm2838_peripherals_realize(DeviceState *dev, Error **errp) | ||
107 | BCM2838_VC_PERI_LOW_BASE, | ||
108 | &s->peri_low_mr_alias, 1); | ||
109 | |||
110 | + /* Extended Mass Media Controller 2 */ | ||
111 | + object_property_set_uint(OBJECT(&s->emmc2), "sd-spec-version", 3, | ||
112 | + &error_abort); | ||
113 | + object_property_set_uint(OBJECT(&s->emmc2), "capareg", | ||
114 | + BCM2835_SDHC_CAPAREG, &error_abort); | ||
115 | + object_property_set_bool(OBJECT(&s->emmc2), "pending-insert-quirk", true, | ||
116 | + &error_abort); | ||
117 | + if (!sysbus_realize(SYS_BUS_DEVICE(&s->emmc2), errp)) { | ||
118 | + return; | ||
119 | + } | ||
120 | + | ||
121 | + memory_region_add_subregion(&s_base->peri_mr, EMMC2_OFFSET, | ||
122 | + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->emmc2), | ||
123 | + 0)); | ||
124 | + | ||
125 | + /* According to DTS, EMMC and EMMC2 share one irq */ | ||
126 | + if (!qdev_realize(DEVICE(&s->mmc_irq_orgate), NULL, errp)) { | ||
127 | + return; | ||
128 | + } | ||
129 | + | ||
130 | + mmc_irq_orgate = DEVICE(&s->mmc_irq_orgate); | ||
131 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->emmc2), 0, | ||
132 | + qdev_get_gpio_in(mmc_irq_orgate, 0)); | ||
133 | + | ||
134 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s_base->sdhci), 0, | ||
135 | + qdev_get_gpio_in(mmc_irq_orgate, 1)); | ||
136 | + | ||
137 | + /* Connect EMMC and EMMC2 to the interrupt controller */ | ||
138 | + qdev_connect_gpio_out(mmc_irq_orgate, 0, | ||
139 | + qdev_get_gpio_in_named(DEVICE(&s_base->ic), | ||
140 | + BCM2835_IC_GPU_IRQ, | ||
141 | + INTERRUPT_ARASANSDIO)); | ||
142 | + | ||
143 | + /* Connect DMA 0-6 to the interrupt controller */ | ||
144 | + for (n = 0; n < 7; n++) { | ||
145 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s_base->dma), n, | ||
146 | + qdev_get_gpio_in_named(DEVICE(&s_base->ic), | ||
147 | + BCM2835_IC_GPU_IRQ, | ||
148 | + GPU_INTERRUPT_DMA0 + n)); | ||
149 | + } | ||
150 | + | ||
151 | + /* According to DTS, DMA 7 and 8 share one irq */ | ||
152 | + if (!qdev_realize(DEVICE(&s->dma_7_8_irq_orgate), NULL, errp)) { | ||
153 | + return; | ||
154 | + } | ||
155 | + dma_7_8_irq_orgate = DEVICE(&s->dma_7_8_irq_orgate); | ||
156 | + | ||
157 | + /* Connect DMA 7-8 to the interrupt controller */ | ||
158 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s_base->dma), 7, | ||
159 | + qdev_get_gpio_in(dma_7_8_irq_orgate, 0)); | ||
160 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s_base->dma), 8, | ||
161 | + qdev_get_gpio_in(dma_7_8_irq_orgate, 1)); | ||
162 | + | ||
163 | + qdev_connect_gpio_out(dma_7_8_irq_orgate, 0, | ||
164 | + qdev_get_gpio_in_named(DEVICE(&s_base->ic), | ||
165 | + BCM2835_IC_GPU_IRQ, | ||
166 | + GPU_INTERRUPT_DMA7_8)); | ||
167 | + | ||
168 | + /* According to DTS, DMA 9 and 10 share one irq */ | ||
169 | + if (!qdev_realize(DEVICE(&s->dma_9_10_irq_orgate), NULL, errp)) { | ||
170 | + return; | ||
171 | + } | ||
172 | + dma_9_10_irq_orgate = DEVICE(&s->dma_9_10_irq_orgate); | ||
173 | + | ||
174 | + /* Connect DMA 9-10 to the interrupt controller */ | ||
175 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s_base->dma), 9, | ||
176 | + qdev_get_gpio_in(dma_9_10_irq_orgate, 0)); | ||
177 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s_base->dma), 10, | ||
178 | + qdev_get_gpio_in(dma_9_10_irq_orgate, 1)); | ||
179 | + | ||
180 | + qdev_connect_gpio_out(dma_9_10_irq_orgate, 0, | ||
181 | + qdev_get_gpio_in_named(DEVICE(&s_base->ic), | ||
182 | + BCM2835_IC_GPU_IRQ, | ||
183 | + GPU_INTERRUPT_DMA9_10)); | ||
184 | + | ||
185 | + /* Connect DMA 11-14 to the interrupt controller */ | ||
186 | + for (n = 11; n < 15; n++) { | ||
187 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s_base->dma), n, | ||
188 | + qdev_get_gpio_in_named(DEVICE(&s_base->ic), | ||
189 | + BCM2835_IC_GPU_IRQ, | ||
190 | + GPU_INTERRUPT_DMA11 + n | ||
191 | + - 11)); | ||
192 | + } | ||
193 | + | ||
194 | + /* | ||
195 | + * Connect DMA 15 to the interrupt controller, it is physically removed | ||
196 | + * from other DMA channels and exclusively used by the GPU | ||
197 | + */ | ||
198 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s_base->dma), 15, | ||
199 | + qdev_get_gpio_in_named(DEVICE(&s_base->ic), | ||
200 | + BCM2835_IC_GPU_IRQ, | ||
201 | + GPU_INTERRUPT_DMA15)); | ||
202 | + | ||
203 | + /* Map MPHI to BCM2838 memory map */ | ||
204 | + mphi_mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s_base->mphi), 0); | ||
205 | + memory_region_init_alias(&s->mphi_mr_alias, OBJECT(s), "mphi", mphi_mr, 0, | ||
206 | + BCM2838_MPHI_SIZE); | ||
207 | + memory_region_add_subregion(&s_base->peri_mr, BCM2838_MPHI_OFFSET, | ||
208 | + &s->mphi_mr_alias); | ||
209 | + | ||
210 | + /* GPIO */ | ||
211 | + if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) { | ||
212 | + return; | ||
213 | + } | ||
214 | + memory_region_add_subregion( | ||
215 | + &s_base->peri_mr, GPIO_OFFSET, | ||
216 | + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->gpio), 0)); | ||
217 | + | ||
218 | + object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(&s->gpio), "sd-bus"); | ||
219 | } | ||
220 | |||
221 | static void bcm2838_peripherals_class_init(ObjectClass *oc, void *data) | ||
222 | -- | ||
223 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Sergey Kambalin <serg.oker@gmail.com> | ||
2 | 1 | ||
3 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Message-id: 20240226000259.2752893-11-sergey.kambalin@auriga.com | ||
6 | [PMM: Change name to 'raspi4b', not 'raspi4b-2g'] | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | --- | ||
9 | include/hw/arm/raspi_platform.h | 11 ++++++ | ||
10 | include/hw/display/bcm2835_fb.h | 2 + | ||
11 | hw/arm/bcm2835_peripherals.c | 17 ++++++-- | ||
12 | hw/arm/bcm2836.c | 2 + | ||
13 | hw/arm/bcm2838.c | 2 + | ||
14 | hw/arm/raspi.c | 27 ++++++++----- | ||
15 | hw/arm/raspi4b.c | 70 +++++++++++++++++++++++++++++++++ | ||
16 | hw/arm/meson.build | 2 +- | ||
17 | 8 files changed, 119 insertions(+), 14 deletions(-) | ||
18 | create mode 100644 hw/arm/raspi4b.c | ||
19 | |||
20 | diff --git a/include/hw/arm/raspi_platform.h b/include/hw/arm/raspi_platform.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/include/hw/arm/raspi_platform.h | ||
23 | +++ b/include/hw/arm/raspi_platform.h | ||
24 | @@ -XXX,XX +XXX,XX @@ struct RaspiBaseMachineClass { | ||
25 | uint32_t board_rev; | ||
26 | }; | ||
27 | |||
28 | +/* Common functions for raspberry pi machines */ | ||
29 | +const char *board_soc_type(uint32_t board_rev); | ||
30 | +void raspi_machine_init(MachineState *machine); | ||
31 | + | ||
32 | +typedef struct BCM283XBaseState BCM283XBaseState; | ||
33 | +void raspi_base_machine_init(MachineState *machine, | ||
34 | + BCM283XBaseState *soc); | ||
35 | + | ||
36 | +void raspi_machine_class_common_init(MachineClass *mc, | ||
37 | + uint32_t board_rev); | ||
38 | + | ||
39 | #define MSYNC_OFFSET 0x0000 /* Multicore Sync Block */ | ||
40 | #define CCPT_OFFSET 0x1000 /* Compact Camera Port 2 TX */ | ||
41 | #define INTE_OFFSET 0x2000 /* VC Interrupt controller */ | ||
42 | diff --git a/include/hw/display/bcm2835_fb.h b/include/hw/display/bcm2835_fb.h | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/include/hw/display/bcm2835_fb.h | ||
45 | +++ b/include/hw/display/bcm2835_fb.h | ||
46 | @@ -XXX,XX +XXX,XX @@ | ||
47 | #include "ui/console.h" | ||
48 | #include "qom/object.h" | ||
49 | |||
50 | +#define UPPER_RAM_BASE 0x40000000 | ||
51 | + | ||
52 | #define TYPE_BCM2835_FB "bcm2835-fb" | ||
53 | OBJECT_DECLARE_SIMPLE_TYPE(BCM2835FBState, BCM2835_FB) | ||
54 | |||
55 | diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/hw/arm/bcm2835_peripherals.c | ||
58 | +++ b/hw/arm/bcm2835_peripherals.c | ||
59 | @@ -XXX,XX +XXX,XX @@ static void raspi_peripherals_base_init(Object *obj) | ||
60 | /* Framebuffer */ | ||
61 | object_initialize_child(obj, "fb", &s->fb, TYPE_BCM2835_FB); | ||
62 | object_property_add_alias(obj, "vcram-size", OBJECT(&s->fb), "vcram-size"); | ||
63 | + object_property_add_alias(obj, "vcram-base", OBJECT(&s->fb), "vcram-base"); | ||
64 | |||
65 | object_property_add_const_link(OBJECT(&s->fb), "dma-mr", | ||
66 | OBJECT(&s->gpu_bus_mr)); | ||
67 | @@ -XXX,XX +XXX,XX @@ void bcm_soc_peripherals_common_realize(DeviceState *dev, Error **errp) | ||
68 | Object *obj; | ||
69 | MemoryRegion *ram; | ||
70 | Error *err = NULL; | ||
71 | - uint64_t ram_size, vcram_size; | ||
72 | + uint64_t ram_size, vcram_size, vcram_base; | ||
73 | int n; | ||
74 | |||
75 | obj = object_property_get_link(OBJECT(dev), "ram", &error_abort); | ||
76 | @@ -XXX,XX +XXX,XX @@ void bcm_soc_peripherals_common_realize(DeviceState *dev, Error **errp) | ||
77 | return; | ||
78 | } | ||
79 | |||
80 | - if (!object_property_set_uint(OBJECT(&s->fb), "vcram-base", | ||
81 | - ram_size - vcram_size, errp)) { | ||
82 | + vcram_base = object_property_get_uint(OBJECT(s), "vcram-base", &err); | ||
83 | + if (err) { | ||
84 | + error_propagate(errp, err); | ||
85 | return; | ||
86 | } | ||
87 | |||
88 | + if (vcram_base == 0) { | ||
89 | + vcram_base = ram_size - vcram_size; | ||
90 | + } | ||
91 | + vcram_base = MIN(vcram_base, UPPER_RAM_BASE - vcram_size); | ||
92 | + | ||
93 | + if (!object_property_set_uint(OBJECT(&s->fb), "vcram-base", vcram_base, | ||
94 | + errp)) { | ||
95 | + return; | ||
96 | + } | ||
97 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->fb), errp)) { | ||
98 | return; | ||
99 | } | ||
100 | diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c | ||
101 | index XXXXXXX..XXXXXXX 100644 | ||
102 | --- a/hw/arm/bcm2836.c | ||
103 | +++ b/hw/arm/bcm2836.c | ||
104 | @@ -XXX,XX +XXX,XX @@ static void bcm283x_init(Object *obj) | ||
105 | "command-line"); | ||
106 | object_property_add_alias(obj, "vcram-size", OBJECT(&s->peripherals), | ||
107 | "vcram-size"); | ||
108 | + object_property_add_alias(obj, "vcram-base", OBJECT(&s->peripherals), | ||
109 | + "vcram-base"); | ||
110 | } | ||
111 | |||
112 | bool bcm283x_common_realize(DeviceState *dev, BCMSocPeripheralBaseState *ps, | ||
113 | diff --git a/hw/arm/bcm2838.c b/hw/arm/bcm2838.c | ||
114 | index XXXXXXX..XXXXXXX 100644 | ||
115 | --- a/hw/arm/bcm2838.c | ||
116 | +++ b/hw/arm/bcm2838.c | ||
117 | @@ -XXX,XX +XXX,XX @@ static void bcm2838_init(Object *obj) | ||
118 | "board-rev"); | ||
119 | object_property_add_alias(obj, "vcram-size", OBJECT(&s->peripherals), | ||
120 | "vcram-size"); | ||
121 | + object_property_add_alias(obj, "vcram-base", OBJECT(&s->peripherals), | ||
122 | + "vcram-base"); | ||
123 | object_property_add_alias(obj, "command-line", OBJECT(&s->peripherals), | ||
124 | "command-line"); | ||
125 | |||
126 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | ||
127 | index XXXXXXX..XXXXXXX 100644 | ||
128 | --- a/hw/arm/raspi.c | ||
129 | +++ b/hw/arm/raspi.c | ||
130 | @@ -XXX,XX +XXX,XX @@ | ||
131 | #include "qapi/error.h" | ||
132 | #include "hw/arm/boot.h" | ||
133 | #include "hw/arm/bcm2836.h" | ||
134 | +#include "hw/arm/bcm2838.h" | ||
135 | #include "hw/arm/raspi_platform.h" | ||
136 | #include "hw/registerfields.h" | ||
137 | #include "qemu/error-report.h" | ||
138 | @@ -XXX,XX +XXX,XX @@ typedef enum RaspiProcessorId { | ||
139 | PROCESSOR_ID_BCM2835 = 0, | ||
140 | PROCESSOR_ID_BCM2836 = 1, | ||
141 | PROCESSOR_ID_BCM2837 = 2, | ||
142 | + PROCESSOR_ID_BCM2838 = 3, | ||
143 | } RaspiProcessorId; | ||
144 | |||
145 | static const struct { | ||
146 | @@ -XXX,XX +XXX,XX @@ static const struct { | ||
147 | [PROCESSOR_ID_BCM2835] = {TYPE_BCM2835, 1}, | ||
148 | [PROCESSOR_ID_BCM2836] = {TYPE_BCM2836, BCM283X_NCPUS}, | ||
149 | [PROCESSOR_ID_BCM2837] = {TYPE_BCM2837, BCM283X_NCPUS}, | ||
150 | + [PROCESSOR_ID_BCM2838] = {TYPE_BCM2838, BCM283X_NCPUS}, | ||
151 | }; | ||
152 | |||
153 | -static void raspi_base_machine_init(MachineState *machine, | ||
154 | - BCM283XBaseState *soc); | ||
155 | -static void raspi_machine_class_common_init(MachineClass *mc, | ||
156 | - uint32_t board_rev); | ||
157 | - | ||
158 | static uint64_t board_ram_size(uint32_t board_rev) | ||
159 | { | ||
160 | assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */ | ||
161 | @@ -XXX,XX +XXX,XX @@ static RaspiProcessorId board_processor_id(uint32_t board_rev) | ||
162 | return proc_id; | ||
163 | } | ||
164 | |||
165 | -static const char *board_soc_type(uint32_t board_rev) | ||
166 | +const char *board_soc_type(uint32_t board_rev) | ||
167 | { | ||
168 | return soc_property[board_processor_id(board_rev)].type; | ||
169 | } | ||
170 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, ARMCPU *cpu, | ||
171 | arm_load_kernel(cpu, machine, &s->binfo); | ||
172 | } | ||
173 | |||
174 | -static void raspi_base_machine_init(MachineState *machine, | ||
175 | +void raspi_base_machine_init(MachineState *machine, | ||
176 | BCM283XBaseState *soc) | ||
177 | { | ||
178 | RaspiBaseMachineClass *mc = RASPI_BASE_MACHINE_GET_CLASS(machine); | ||
179 | uint32_t board_rev = mc->board_rev; | ||
180 | uint64_t ram_size = board_ram_size(board_rev); | ||
181 | - uint32_t vcram_size; | ||
182 | + uint32_t vcram_base, vcram_size; | ||
183 | + size_t boot_ram_size; | ||
184 | DriveInfo *di; | ||
185 | BlockBackend *blk; | ||
186 | BusState *bus; | ||
187 | @@ -XXX,XX +XXX,XX @@ static void raspi_base_machine_init(MachineState *machine, | ||
188 | |||
189 | vcram_size = object_property_get_uint(OBJECT(soc), "vcram-size", | ||
190 | &error_abort); | ||
191 | + vcram_base = object_property_get_uint(OBJECT(soc), "vcram-base", | ||
192 | + &error_abort); | ||
193 | + | ||
194 | + if (vcram_base == 0) { | ||
195 | + vcram_base = ram_size - vcram_size; | ||
196 | + } | ||
197 | + boot_ram_size = MIN(vcram_base, UPPER_RAM_BASE - vcram_size); | ||
198 | + | ||
199 | setup_boot(machine, &soc->cpu[0].core, board_processor_id(board_rev), | ||
200 | - machine->ram_size - vcram_size); | ||
201 | + boot_ram_size); | ||
202 | } | ||
203 | |||
204 | -static void raspi_machine_init(MachineState *machine) | ||
205 | +void raspi_machine_init(MachineState *machine) | ||
206 | { | ||
207 | RaspiMachineState *s = RASPI_MACHINE(machine); | ||
208 | RaspiBaseMachineState *s_base = RASPI_BASE_MACHINE(machine); | ||
209 | diff --git a/hw/arm/raspi4b.c b/hw/arm/raspi4b.c | ||
210 | new file mode 100644 | ||
211 | index XXXXXXX..XXXXXXX | ||
212 | --- /dev/null | ||
213 | +++ b/hw/arm/raspi4b.c | ||
214 | @@ -XXX,XX +XXX,XX @@ | ||
215 | +/* | ||
216 | + * Raspberry Pi 4B emulation | ||
217 | + * | ||
218 | + * Copyright (C) 2022 Ovchinnikov Vitalii <vitalii.ovchinnikov@auriga.com> | ||
219 | + * | ||
220 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
221 | + */ | ||
222 | + | ||
223 | +#include "qemu/osdep.h" | ||
224 | +#include "qemu/units.h" | ||
225 | +#include "qemu/cutils.h" | ||
226 | +#include "qapi/error.h" | ||
227 | +#include "qapi/visitor.h" | ||
228 | +#include "hw/arm/raspi_platform.h" | ||
229 | +#include "hw/display/bcm2835_fb.h" | ||
230 | +#include "hw/registerfields.h" | ||
231 | +#include "qemu/error-report.h" | ||
232 | +#include "sysemu/device_tree.h" | ||
233 | +#include "hw/boards.h" | ||
234 | +#include "hw/loader.h" | ||
235 | +#include "hw/arm/boot.h" | ||
236 | +#include "qom/object.h" | ||
237 | +#include "hw/arm/bcm2838.h" | ||
238 | + | ||
239 | +#define TYPE_RASPI4B_MACHINE MACHINE_TYPE_NAME("raspi4b") | ||
240 | +OBJECT_DECLARE_SIMPLE_TYPE(Raspi4bMachineState, RASPI4B_MACHINE) | ||
241 | + | ||
242 | +struct Raspi4bMachineState { | ||
243 | + RaspiBaseMachineState parent_obj; | ||
244 | + BCM2838State soc; | ||
245 | +}; | ||
246 | + | ||
247 | +static void raspi4b_machine_init(MachineState *machine) | ||
248 | +{ | ||
249 | + Raspi4bMachineState *s = RASPI4B_MACHINE(machine); | ||
250 | + RaspiBaseMachineState *s_base = RASPI_BASE_MACHINE(machine); | ||
251 | + RaspiBaseMachineClass *mc = RASPI_BASE_MACHINE_GET_CLASS(machine); | ||
252 | + BCM2838State *soc = &s->soc; | ||
253 | + | ||
254 | + s_base->binfo.board_id = mc->board_rev; | ||
255 | + | ||
256 | + object_initialize_child(OBJECT(machine), "soc", soc, | ||
257 | + board_soc_type(mc->board_rev)); | ||
258 | + | ||
259 | + raspi_base_machine_init(machine, &soc->parent_obj); | ||
260 | +} | ||
261 | + | ||
262 | +static void raspi4b_machine_class_init(ObjectClass *oc, void *data) | ||
263 | +{ | ||
264 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
265 | + RaspiBaseMachineClass *rmc = RASPI_BASE_MACHINE_CLASS(oc); | ||
266 | + | ||
267 | + rmc->board_rev = 0xb03115; /* Revision 1.5, 2 Gb RAM */ | ||
268 | + raspi_machine_class_common_init(mc, rmc->board_rev); | ||
269 | + mc->init = raspi4b_machine_init; | ||
270 | +} | ||
271 | + | ||
272 | +static const TypeInfo raspi4b_machine_type = { | ||
273 | + .name = TYPE_RASPI4B_MACHINE, | ||
274 | + .parent = TYPE_RASPI_BASE_MACHINE, | ||
275 | + .instance_size = sizeof(Raspi4bMachineState), | ||
276 | + .class_init = raspi4b_machine_class_init, | ||
277 | +}; | ||
278 | + | ||
279 | +static void raspi4b_machine_register_type(void) | ||
280 | +{ | ||
281 | + type_register_static(&raspi4b_machine_type); | ||
282 | +} | ||
283 | + | ||
284 | +type_init(raspi4b_machine_register_type) | ||
285 | diff --git a/hw/arm/meson.build b/hw/arm/meson.build | ||
286 | index XXXXXXX..XXXXXXX 100644 | ||
287 | --- a/hw/arm/meson.build | ||
288 | +++ b/hw/arm/meson.build | ||
289 | @@ -XXX,XX +XXX,XX @@ arm_ss.add(when: 'CONFIG_ALLWINNER_A10', if_true: files('allwinner-a10.c', 'cubi | ||
290 | arm_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3.c', 'orangepi.c')) | ||
291 | arm_ss.add(when: 'CONFIG_ALLWINNER_R40', if_true: files('allwinner-r40.c', 'bananapi_m2u.c')) | ||
292 | arm_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2836.c', 'raspi.c')) | ||
293 | -arm_ss.add(when: ['CONFIG_RASPI', 'TARGET_AARCH64'], if_true: files('bcm2838.c')) | ||
294 | +arm_ss.add(when: ['CONFIG_RASPI', 'TARGET_AARCH64'], if_true: files('bcm2838.c', 'raspi4b.c')) | ||
295 | arm_ss.add(when: 'CONFIG_STM32F100_SOC', if_true: files('stm32f100_soc.c')) | ||
296 | arm_ss.add(when: 'CONFIG_STM32F205_SOC', if_true: files('stm32f205_soc.c')) | ||
297 | arm_ss.add(when: 'CONFIG_STM32F405_SOC', if_true: files('stm32f405_soc.c')) | ||
298 | -- | ||
299 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Sergey Kambalin <serg.oker@gmail.com> | ||
2 | 1 | ||
3 | This commit adds RPi4B device tree modifications: | ||
4 | - disable pcie, rng200, thermal sensor and genet devices | ||
5 | (they're going to be re-enabled in the following commits) | ||
6 | - create additional memory region in device tree | ||
7 | if RAM amount exceeds VC base address. | ||
8 | |||
9 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Message-id: 20240226000259.2752893-12-sergey.kambalin@auriga.com | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | include/hw/arm/raspi_platform.h | 4 +++ | ||
15 | hw/arm/raspi.c | 5 +-- | ||
16 | hw/arm/raspi4b.c | 62 +++++++++++++++++++++++++++++++++ | ||
17 | 3 files changed, 67 insertions(+), 4 deletions(-) | ||
18 | |||
19 | diff --git a/include/hw/arm/raspi_platform.h b/include/hw/arm/raspi_platform.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/include/hw/arm/raspi_platform.h | ||
22 | +++ b/include/hw/arm/raspi_platform.h | ||
23 | @@ -XXX,XX +XXX,XX @@ | ||
24 | #include "hw/boards.h" | ||
25 | #include "hw/arm/boot.h" | ||
26 | |||
27 | +/* Registered machine type (matches RPi Foundation bootloader and U-Boot) */ | ||
28 | +#define MACH_TYPE_BCM2708 3138 | ||
29 | + | ||
30 | #define TYPE_RASPI_BASE_MACHINE MACHINE_TYPE_NAME("raspi-base") | ||
31 | OBJECT_DECLARE_TYPE(RaspiBaseMachineState, RaspiBaseMachineClass, | ||
32 | RASPI_BASE_MACHINE) | ||
33 | @@ -XXX,XX +XXX,XX @@ void raspi_base_machine_init(MachineState *machine, | ||
34 | |||
35 | void raspi_machine_class_common_init(MachineClass *mc, | ||
36 | uint32_t board_rev); | ||
37 | +uint64_t board_ram_size(uint32_t board_rev); | ||
38 | |||
39 | #define MSYNC_OFFSET 0x0000 /* Multicore Sync Block */ | ||
40 | #define CCPT_OFFSET 0x1000 /* Compact Camera Port 2 TX */ | ||
41 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/hw/arm/raspi.c | ||
44 | +++ b/hw/arm/raspi.c | ||
45 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(RaspiMachineState, RASPI_MACHINE) | ||
46 | #define FIRMWARE_ADDR_3 0x80000 /* Pi 3 loads kernel.img here by default */ | ||
47 | #define SPINTABLE_ADDR 0xd8 /* Pi 3 bootloader spintable */ | ||
48 | |||
49 | -/* Registered machine type (matches RPi Foundation bootloader and U-Boot) */ | ||
50 | -#define MACH_TYPE_BCM2708 3138 | ||
51 | - | ||
52 | struct RaspiMachineState { | ||
53 | /*< private >*/ | ||
54 | RaspiBaseMachineState parent_obj; | ||
55 | @@ -XXX,XX +XXX,XX @@ static const struct { | ||
56 | [PROCESSOR_ID_BCM2838] = {TYPE_BCM2838, BCM283X_NCPUS}, | ||
57 | }; | ||
58 | |||
59 | -static uint64_t board_ram_size(uint32_t board_rev) | ||
60 | +uint64_t board_ram_size(uint32_t board_rev) | ||
61 | { | ||
62 | assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */ | ||
63 | return 256 * MiB << FIELD_EX32(board_rev, REV_CODE, MEMORY_SIZE); | ||
64 | diff --git a/hw/arm/raspi4b.c b/hw/arm/raspi4b.c | ||
65 | index XXXXXXX..XXXXXXX 100644 | ||
66 | --- a/hw/arm/raspi4b.c | ||
67 | +++ b/hw/arm/raspi4b.c | ||
68 | @@ -XXX,XX +XXX,XX @@ | ||
69 | #include "hw/arm/boot.h" | ||
70 | #include "qom/object.h" | ||
71 | #include "hw/arm/bcm2838.h" | ||
72 | +#include <libfdt.h> | ||
73 | |||
74 | #define TYPE_RASPI4B_MACHINE MACHINE_TYPE_NAME("raspi4b") | ||
75 | OBJECT_DECLARE_SIMPLE_TYPE(Raspi4bMachineState, RASPI4B_MACHINE) | ||
76 | @@ -XXX,XX +XXX,XX @@ struct Raspi4bMachineState { | ||
77 | BCM2838State soc; | ||
78 | }; | ||
79 | |||
80 | +/* | ||
81 | + * Add second memory region if board RAM amount exceeds VC base address | ||
82 | + * (see https://datasheets.raspberrypi.com/bcm2711/bcm2711-peripherals.pdf | ||
83 | + * 1.2 Address Map) | ||
84 | + */ | ||
85 | +static int raspi_add_memory_node(void *fdt, hwaddr mem_base, hwaddr mem_len) | ||
86 | +{ | ||
87 | + int ret; | ||
88 | + uint32_t acells, scells; | ||
89 | + char *nodename = g_strdup_printf("/memory@%" PRIx64, mem_base); | ||
90 | + | ||
91 | + acells = qemu_fdt_getprop_cell(fdt, "/", "#address-cells", | ||
92 | + NULL, &error_fatal); | ||
93 | + scells = qemu_fdt_getprop_cell(fdt, "/", "#size-cells", | ||
94 | + NULL, &error_fatal); | ||
95 | + if (acells == 0 || scells == 0) { | ||
96 | + fprintf(stderr, "dtb file invalid (#address-cells or #size-cells 0)\n"); | ||
97 | + ret = -1; | ||
98 | + } else { | ||
99 | + qemu_fdt_add_subnode(fdt, nodename); | ||
100 | + qemu_fdt_setprop_string(fdt, nodename, "device_type", "memory"); | ||
101 | + ret = qemu_fdt_setprop_sized_cells(fdt, nodename, "reg", | ||
102 | + acells, mem_base, | ||
103 | + scells, mem_len); | ||
104 | + } | ||
105 | + | ||
106 | + g_free(nodename); | ||
107 | + return ret; | ||
108 | +} | ||
109 | + | ||
110 | +static void raspi4_modify_dtb(const struct arm_boot_info *info, void *fdt) | ||
111 | +{ | ||
112 | + uint64_t ram_size; | ||
113 | + | ||
114 | + /* Temporarily disable following devices until they are implemented */ | ||
115 | + const char *nodes_to_remove[] = { | ||
116 | + "brcm,bcm2711-pcie", | ||
117 | + "brcm,bcm2711-rng200", | ||
118 | + "brcm,bcm2711-thermal", | ||
119 | + "brcm,bcm2711-genet-v5", | ||
120 | + }; | ||
121 | + | ||
122 | + for (int i = 0; i < ARRAY_SIZE(nodes_to_remove); i++) { | ||
123 | + const char *dev_str = nodes_to_remove[i]; | ||
124 | + | ||
125 | + int offset = fdt_node_offset_by_compatible(fdt, -1, dev_str); | ||
126 | + if (offset >= 0) { | ||
127 | + if (!fdt_nop_node(fdt, offset)) { | ||
128 | + warn_report("bcm2711 dtc: %s has been disabled!", dev_str); | ||
129 | + } | ||
130 | + } | ||
131 | + } | ||
132 | + | ||
133 | + ram_size = board_ram_size(info->board_id); | ||
134 | + | ||
135 | + if (info->ram_size > UPPER_RAM_BASE) { | ||
136 | + raspi_add_memory_node(fdt, UPPER_RAM_BASE, ram_size - UPPER_RAM_BASE); | ||
137 | + } | ||
138 | +} | ||
139 | + | ||
140 | static void raspi4b_machine_init(MachineState *machine) | ||
141 | { | ||
142 | Raspi4bMachineState *s = RASPI4B_MACHINE(machine); | ||
143 | @@ -XXX,XX +XXX,XX @@ static void raspi4b_machine_init(MachineState *machine) | ||
144 | RaspiBaseMachineClass *mc = RASPI_BASE_MACHINE_GET_CLASS(machine); | ||
145 | BCM2838State *soc = &s->soc; | ||
146 | |||
147 | + s_base->binfo.modify_dtb = raspi4_modify_dtb; | ||
148 | s_base->binfo.board_id = mc->board_rev; | ||
149 | |||
150 | object_initialize_child(OBJECT(machine), "soc", soc, | ||
151 | -- | ||
152 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Sergey Kambalin <serg.oker@gmail.com> | ||
2 | 1 | ||
3 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Message-id: 20240226000259.2752893-13-sergey.kambalin@auriga.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | include/hw/arm/bcm2838_peripherals.h | 2 ++ | ||
9 | include/hw/arm/raspi_platform.h | 2 +- | ||
10 | hw/arm/bcm2838_peripherals.c | 3 +++ | ||
11 | 3 files changed, 6 insertions(+), 1 deletion(-) | ||
12 | |||
13 | diff --git a/include/hw/arm/bcm2838_peripherals.h b/include/hw/arm/bcm2838_peripherals.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/include/hw/arm/bcm2838_peripherals.h | ||
16 | +++ b/include/hw/arm/bcm2838_peripherals.h | ||
17 | @@ -XXX,XX +XXX,XX @@ struct BCM2838PeripheralState { | ||
18 | OrIRQState mmc_irq_orgate; | ||
19 | OrIRQState dma_7_8_irq_orgate; | ||
20 | OrIRQState dma_9_10_irq_orgate; | ||
21 | + | ||
22 | + UnimplementedDeviceState asb; | ||
23 | }; | ||
24 | |||
25 | struct BCM2838PeripheralClass { | ||
26 | diff --git a/include/hw/arm/raspi_platform.h b/include/hw/arm/raspi_platform.h | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/include/hw/arm/raspi_platform.h | ||
29 | +++ b/include/hw/arm/raspi_platform.h | ||
30 | @@ -XXX,XX +XXX,XX @@ uint64_t board_ram_size(uint32_t board_rev); | ||
31 | #define MPHI_OFFSET 0x6000 /* Message-based Parallel Host Intf. */ | ||
32 | #define DMA_OFFSET 0x7000 /* DMA controller, channels 0-14 */ | ||
33 | #define ARBA_OFFSET 0x9000 | ||
34 | -#define BRDG_OFFSET 0xa000 | ||
35 | +#define BRDG_OFFSET 0xa000 /* RPiVid ASB for BCM2838 (BCM2711) */ | ||
36 | #define ARM_OFFSET 0xB000 /* ARM control block */ | ||
37 | #define ARMCTRL_OFFSET (ARM_OFFSET + 0x000) | ||
38 | #define ARMCTRL_IC_OFFSET (ARM_OFFSET + 0x200) /* Interrupt controller */ | ||
39 | diff --git a/hw/arm/bcm2838_peripherals.c b/hw/arm/bcm2838_peripherals.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/hw/arm/bcm2838_peripherals.c | ||
42 | +++ b/hw/arm/bcm2838_peripherals.c | ||
43 | @@ -XXX,XX +XXX,XX @@ static void bcm2838_peripherals_realize(DeviceState *dev, Error **errp) | ||
44 | sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->gpio), 0)); | ||
45 | |||
46 | object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(&s->gpio), "sd-bus"); | ||
47 | + | ||
48 | + /* BCM2838 RPiVid ASB must be mapped to prevent kernel crash */ | ||
49 | + create_unimp(s_base, &s->asb, "bcm2838-asb", BRDG_OFFSET, 0x24); | ||
50 | } | ||
51 | |||
52 | static void bcm2838_peripherals_class_init(ObjectClass *oc, void *data) | ||
53 | -- | ||
54 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Sergey Kambalin <serg.oker@gmail.com> | ||
2 | 1 | ||
3 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | include/hw/arm/bcm2838_peripherals.h | 1 + | ||
9 | hw/arm/bcm2838_peripherals.c | 6 ++++++ | ||
10 | 2 files changed, 7 insertions(+) | ||
11 | |||
12 | diff --git a/include/hw/arm/bcm2838_peripherals.h b/include/hw/arm/bcm2838_peripherals.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/include/hw/arm/bcm2838_peripherals.h | ||
15 | +++ b/include/hw/arm/bcm2838_peripherals.h | ||
16 | @@ -XXX,XX +XXX,XX @@ struct BCM2838PeripheralState { | ||
17 | OrIRQState dma_9_10_irq_orgate; | ||
18 | |||
19 | UnimplementedDeviceState asb; | ||
20 | + UnimplementedDeviceState clkisp; | ||
21 | }; | ||
22 | |||
23 | struct BCM2838PeripheralClass { | ||
24 | diff --git a/hw/arm/bcm2838_peripherals.c b/hw/arm/bcm2838_peripherals.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/hw/arm/bcm2838_peripherals.c | ||
27 | +++ b/hw/arm/bcm2838_peripherals.c | ||
28 | @@ -XXX,XX +XXX,XX @@ | ||
29 | #include "hw/arm/raspi_platform.h" | ||
30 | #include "hw/arm/bcm2838_peripherals.h" | ||
31 | |||
32 | +#define CLOCK_ISP_OFFSET 0xc11000 | ||
33 | +#define CLOCK_ISP_SIZE 0x100 | ||
34 | + | ||
35 | /* Lower peripheral base address on the VC (GPU) system bus */ | ||
36 | #define BCM2838_VC_PERI_LOW_BASE 0x7c000000 | ||
37 | |||
38 | @@ -XXX,XX +XXX,XX @@ static void bcm2838_peripherals_realize(DeviceState *dev, Error **errp) | ||
39 | memory_region_add_subregion(&s_base->peri_mr, BCM2838_MPHI_OFFSET, | ||
40 | &s->mphi_mr_alias); | ||
41 | |||
42 | + create_unimp(s_base, &s->clkisp, "bcm2835-clkisp", CLOCK_ISP_OFFSET, | ||
43 | + CLOCK_ISP_SIZE); | ||
44 | + | ||
45 | /* GPIO */ | ||
46 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) { | ||
47 | return; | ||
48 | -- | ||
49 | 2.34.1 | ||
50 | |||
51 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> | ||
2 | Message-id: 20240226000259.2752893-31-sergey.kambalin@auriga.com | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | [PMM: Comment out use of USB, which depends on PCI] | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | --- | ||
7 | tests/avocado/boot_linux_console.py | 97 +++++++++++++++++++++++++++++ | ||
8 | 1 file changed, 97 insertions(+) | ||
9 | 1 | ||
10 | diff --git a/tests/avocado/boot_linux_console.py b/tests/avocado/boot_linux_console.py | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/tests/avocado/boot_linux_console.py | ||
13 | +++ b/tests/avocado/boot_linux_console.py | ||
14 | @@ -XXX,XX +XXX,XX @@ def test_arm_raspi2_initrd(self): | ||
15 | # Wait for VM to shut down gracefully | ||
16 | self.vm.wait() | ||
17 | |||
18 | + def test_arm_raspi4(self): | ||
19 | + """ | ||
20 | + :avocado: tags=arch:aarch64 | ||
21 | + :avocado: tags=machine:raspi4b | ||
22 | + :avocado: tags=device:pl011 | ||
23 | + :avocado: tags=accel:tcg | ||
24 | + :avocado: tags=rpi4b | ||
25 | + | ||
26 | + The kernel can be rebuilt using the kernel source referenced | ||
27 | + and following the instructions on the on: | ||
28 | + https://www.raspberrypi.org/documentation/linux/kernel/building.md | ||
29 | + """ | ||
30 | + | ||
31 | + deb_url = ('http://archive.raspberrypi.org/debian/' | ||
32 | + 'pool/main/r/raspberrypi-firmware/' | ||
33 | + 'raspberrypi-kernel_1.20230106-1_arm64.deb') | ||
34 | + deb_hash = '08dc55696535b18a6d4fe6fa10d4c0d905cbb2ed' | ||
35 | + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) | ||
36 | + kernel_path = self.extract_from_deb(deb_path, '/boot/kernel8.img') | ||
37 | + dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2711-rpi-4-b.dtb') | ||
38 | + | ||
39 | + self.vm.set_console() | ||
40 | + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + | ||
41 | + 'earlycon=pl011,mmio32,0xfe201000 ' + | ||
42 | + 'console=ttyAMA0,115200 ' + | ||
43 | + 'root=/dev/mmcblk1p2 rootwait ' + | ||
44 | + 'dwc_otg.fiq_fsm_enable=0') | ||
45 | + self.vm.add_args('-kernel', kernel_path, | ||
46 | + '-dtb', dtb_path, | ||
47 | + '-append', kernel_command_line) | ||
48 | + # When PCI is supported we can add a USB controller: | ||
49 | + # '-device', 'qemu-xhci,bus=pcie.1,id=xhci', | ||
50 | + # '-device', 'usb-kbd,bus=xhci.0', | ||
51 | + self.vm.launch() | ||
52 | + console_pattern = 'Kernel command line: %s' % kernel_command_line | ||
53 | + self.wait_for_console_pattern(console_pattern) | ||
54 | + # When USB is enabled we can look for this | ||
55 | + # console_pattern = 'Product: QEMU USB Keyboard' | ||
56 | + # self.wait_for_console_pattern(console_pattern) | ||
57 | + console_pattern = 'Waiting for root device' | ||
58 | + self.wait_for_console_pattern(console_pattern) | ||
59 | + | ||
60 | + | ||
61 | + def test_arm_raspi4_initrd(self): | ||
62 | + """ | ||
63 | + :avocado: tags=arch:aarch64 | ||
64 | + :avocado: tags=machine:raspi4b | ||
65 | + :avocado: tags=device:pl011 | ||
66 | + :avocado: tags=accel:tcg | ||
67 | + :avocado: tags=rpi4b | ||
68 | + | ||
69 | + The kernel can be rebuilt using the kernel source referenced | ||
70 | + and following the instructions on the on: | ||
71 | + https://www.raspberrypi.org/documentation/linux/kernel/building.md | ||
72 | + """ | ||
73 | + deb_url = ('http://archive.raspberrypi.org/debian/' | ||
74 | + 'pool/main/r/raspberrypi-firmware/' | ||
75 | + 'raspberrypi-kernel_1.20230106-1_arm64.deb') | ||
76 | + deb_hash = '08dc55696535b18a6d4fe6fa10d4c0d905cbb2ed' | ||
77 | + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) | ||
78 | + kernel_path = self.extract_from_deb(deb_path, '/boot/kernel8.img') | ||
79 | + dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2711-rpi-4-b.dtb') | ||
80 | + | ||
81 | + initrd_url = ('https://github.com/groeck/linux-build-test/raw/' | ||
82 | + '86b2be1384d41c8c388e63078a847f1e1c4cb1de/rootfs/' | ||
83 | + 'arm64/rootfs.cpio.gz') | ||
84 | + initrd_hash = 'f3d4f9fa92a49aa542f1b44d34be77bbf8ca5b9d' | ||
85 | + initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash) | ||
86 | + initrd_path = os.path.join(self.workdir, 'rootfs.cpio') | ||
87 | + archive.gzip_uncompress(initrd_path_gz, initrd_path) | ||
88 | + | ||
89 | + self.vm.set_console() | ||
90 | + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + | ||
91 | + 'earlycon=pl011,mmio32,0xfe201000 ' + | ||
92 | + 'console=ttyAMA0,115200 ' + | ||
93 | + 'panic=-1 noreboot ' + | ||
94 | + 'dwc_otg.fiq_fsm_enable=0') | ||
95 | + self.vm.add_args('-kernel', kernel_path, | ||
96 | + '-dtb', dtb_path, | ||
97 | + '-initrd', initrd_path, | ||
98 | + '-append', kernel_command_line, | ||
99 | + '-no-reboot') | ||
100 | + # When PCI is supported we can add a USB controller: | ||
101 | + # '-device', 'qemu-xhci,bus=pcie.1,id=xhci', | ||
102 | + # '-device', 'usb-kbd,bus=xhci.0', | ||
103 | + self.vm.launch() | ||
104 | + self.wait_for_console_pattern('Boot successful.') | ||
105 | + | ||
106 | + exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', | ||
107 | + 'BCM2835') | ||
108 | + exec_command_and_wait_for_pattern(self, 'cat /proc/iomem', | ||
109 | + 'cprman@7e101000') | ||
110 | + exec_command_and_wait_for_pattern(self, 'halt', 'reboot: System halted') | ||
111 | + # TODO: Raspberry Pi4 doesn't shut down properly with recent kernels | ||
112 | + # Wait for VM to shut down gracefully | ||
113 | + #self.vm.wait() | ||
114 | + | ||
115 | def test_arm_exynos4210_initrd(self): | ||
116 | """ | ||
117 | :avocado: tags=arch:arm | ||
118 | -- | ||
119 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Sergey Kambalin <serg.oker@gmail.com> | ||
2 | 1 | ||
3 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> | ||
4 | Message-id: 20240226000259.2752893-32-sergey.kambalin@auriga.com | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | tests/qtest/bcm2838-mailbox.h | 37 +++++++++++++++++++++ | ||
9 | tests/qtest/bcm2838-mailbox.c | 60 +++++++++++++++++++++++++++++++++++ | ||
10 | tests/qtest/meson.build | 1 + | ||
11 | 3 files changed, 98 insertions(+) | ||
12 | create mode 100644 tests/qtest/bcm2838-mailbox.h | ||
13 | create mode 100644 tests/qtest/bcm2838-mailbox.c | ||
14 | |||
15 | diff --git a/tests/qtest/bcm2838-mailbox.h b/tests/qtest/bcm2838-mailbox.h | ||
16 | new file mode 100644 | ||
17 | index XXXXXXX..XXXXXXX | ||
18 | --- /dev/null | ||
19 | +++ b/tests/qtest/bcm2838-mailbox.h | ||
20 | @@ -XXX,XX +XXX,XX @@ | ||
21 | +/* | ||
22 | + * Declarations for BCM2838 mailbox test. | ||
23 | + * | ||
24 | + * Copyright (c) 2023 Auriga LLC | ||
25 | + * | ||
26 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
27 | + * See the COPYING file in the top-level directory. | ||
28 | + */ | ||
29 | + | ||
30 | +typedef struct { | ||
31 | + uint32_t size; | ||
32 | + uint32_t req_resp_code; | ||
33 | +} MboxBufHeader; | ||
34 | + | ||
35 | +#define DECLARE_TAG_TYPE(TypeName, RequestValueType, ResponseValueType) \ | ||
36 | +typedef struct { \ | ||
37 | + uint32_t id; \ | ||
38 | + uint32_t value_buffer_size; \ | ||
39 | + union { \ | ||
40 | + struct { \ | ||
41 | + uint32_t zero; \ | ||
42 | + RequestValueType value; \ | ||
43 | + } request; \ | ||
44 | + struct { \ | ||
45 | + uint32_t size_stat; \ | ||
46 | + ResponseValueType value; \ | ||
47 | + } response; \ | ||
48 | + }; \ | ||
49 | +} TypeName | ||
50 | + | ||
51 | + | ||
52 | +int mbox0_has_data(void); | ||
53 | +void mbox0_read_message(uint8_t channel, void *msgbuf, size_t msgbuf_size); | ||
54 | +void mbox1_write_message(uint8_t channel, uint32_t msg_addr); | ||
55 | +int qtest_mbox0_has_data(QTestState *s); | ||
56 | +void qtest_mbox0_read_message(QTestState *s, uint8_t channel, void *msgbuf, size_t msgbuf_size); | ||
57 | +void qtest_mbox1_write_message(QTestState *s, uint8_t channel, uint32_t msg_addr); | ||
58 | diff --git a/tests/qtest/bcm2838-mailbox.c b/tests/qtest/bcm2838-mailbox.c | ||
59 | new file mode 100644 | ||
60 | index XXXXXXX..XXXXXXX | ||
61 | --- /dev/null | ||
62 | +++ b/tests/qtest/bcm2838-mailbox.c | ||
63 | @@ -XXX,XX +XXX,XX @@ | ||
64 | +/* | ||
65 | + * Helper functions to work with BCM2838 mailbox via qtest interface. | ||
66 | + * | ||
67 | + * Copyright (c) 2023 Auriga LLC | ||
68 | + * | ||
69 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
70 | + * See the COPYING file in the top-level directory. | ||
71 | + */ | ||
72 | + | ||
73 | +#include "qemu/osdep.h" | ||
74 | +#include "hw/registerfields.h" | ||
75 | +#include "libqtest-single.h" | ||
76 | +#include "bcm2838-mailbox.h" | ||
77 | + | ||
78 | +REG32(MBOX_EXCHNG_REG, 0) | ||
79 | +FIELD(MBOX_EXCHNG_REG, CHANNEL, 0, 4) | ||
80 | +FIELD(MBOX_EXCHNG_REG, DATA, 4, 28) | ||
81 | + | ||
82 | +static uint32_t qtest_mbox0_read_reg32(QTestState *s, uint32_t offset) | ||
83 | +{ | ||
84 | + return qtest_readl(s, MBOX0_BASE + offset); | ||
85 | +} | ||
86 | + | ||
87 | +static void qtest_mbox1_write_reg32(QTestState *s, uint32_t offset, uint32_t value) | ||
88 | +{ | ||
89 | + return qtest_writel(s, MBOX1_BASE + offset, value); | ||
90 | +} | ||
91 | + | ||
92 | +static void qtest_mbox1_write(QTestState *s, uint8_t channel, uint32_t data) | ||
93 | +{ | ||
94 | + uint32_t mbox_reg = 0; | ||
95 | + | ||
96 | + mbox_reg = FIELD_DP32(mbox_reg, MBOX_EXCHNG_REG, CHANNEL, channel); | ||
97 | + mbox_reg = FIELD_DP32(mbox_reg, MBOX_EXCHNG_REG, DATA, data); | ||
98 | + qtest_mbox1_write_reg32(s, MBOX_REG_WRITE, mbox_reg); | ||
99 | +} | ||
100 | + | ||
101 | +int qtest_mbox0_has_data(QTestState *s) { | ||
102 | + return !(qtest_mbox0_read_reg32(s, MBOX_REG_STATUS) & MBOX_READ_EMPTY); | ||
103 | +} | ||
104 | + | ||
105 | +void qtest_mbox0_read_message(QTestState *s, | ||
106 | + uint8_t channel, | ||
107 | + void *msgbuf, | ||
108 | + size_t msgbuf_size) | ||
109 | +{ | ||
110 | + uint32_t mbox_reg; | ||
111 | + uint32_t msgaddr; | ||
112 | + | ||
113 | + g_assert(qtest_mbox0_has_data(s)); | ||
114 | + mbox_reg = qtest_mbox0_read_reg32(s, MBOX_REG_READ); | ||
115 | + g_assert_cmphex(FIELD_EX32(mbox_reg, MBOX_EXCHNG_REG, CHANNEL), ==, channel); | ||
116 | + msgaddr = FIELD_EX32(mbox_reg, MBOX_EXCHNG_REG, DATA) << 4; | ||
117 | + qtest_memread(s, msgaddr, msgbuf, msgbuf_size); | ||
118 | +} | ||
119 | + | ||
120 | +void qtest_mbox1_write_message(QTestState *s, uint8_t channel, uint32_t msg_addr) | ||
121 | +{ | ||
122 | + qtest_mbox1_write(s, channel, msg_addr >> 4); | ||
123 | +} | ||
124 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build | ||
125 | index XXXXXXX..XXXXXXX 100644 | ||
126 | --- a/tests/qtest/meson.build | ||
127 | +++ b/tests/qtest/meson.build | ||
128 | @@ -XXX,XX +XXX,XX @@ qtests = { | ||
129 | 'virtio-net-failover': files('migration-helpers.c'), | ||
130 | 'vmgenid-test': files('boot-sector.c', 'acpi-utils.c'), | ||
131 | 'netdev-socket': files('netdev-socket.c', '../unit/socket-helpers.c'), | ||
132 | + 'bcm2838-mbox-property-test' : files('bcm2838-mailbox.c'), | ||
133 | } | ||
134 | |||
135 | if vnc.found() | ||
136 | -- | ||
137 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Sergey Kambalin <serg.oker@gmail.com> | ||
2 | 1 | ||
3 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> | ||
4 | Message-id: 20240226000259.2752893-33-sergey.kambalin@auriga.com | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | tests/qtest/bcm2838-mailbox.h | 88 +++++++++++++++++++++++++++++++++++ | ||
9 | tests/qtest/bcm2838-mailbox.c | 1 + | ||
10 | 2 files changed, 89 insertions(+) | ||
11 | |||
12 | diff --git a/tests/qtest/bcm2838-mailbox.h b/tests/qtest/bcm2838-mailbox.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/tests/qtest/bcm2838-mailbox.h | ||
15 | +++ b/tests/qtest/bcm2838-mailbox.h | ||
16 | @@ -XXX,XX +XXX,XX @@ | ||
17 | * See the COPYING file in the top-level directory. | ||
18 | */ | ||
19 | |||
20 | +#define MBOX0_BASE 0xFE00B880 | ||
21 | +#define MBOX1_BASE 0xFE00B8A0 | ||
22 | + | ||
23 | +#define MBOX_REG_READ 0x00 | ||
24 | +#define MBOX_REG_WRITE 0x00 | ||
25 | +#define MBOX_REG_PEEK 0x10 | ||
26 | +#define MBOX_REG_SENDER 0x14 | ||
27 | +#define MBOX_REG_STATUS 0x18 | ||
28 | +#define MBOX_REG_CONFIG 0x1C | ||
29 | + | ||
30 | +#define MBOX_READ_EMPTY 0x40000000 | ||
31 | + | ||
32 | +#define MBOX_CHANNEL_ID_PROPERTY 8 | ||
33 | + | ||
34 | +#define MBOX_PROCESS_REQUEST 0x00000000 | ||
35 | +#define MBOX_SUCCESS 0x80000000 | ||
36 | +#define MBOX_ERROR_PARSING_BUFFER 0x80000001 | ||
37 | + | ||
38 | +#define BOARD_REVISION 0xB03115 | ||
39 | +#define FIRMWARE_REVISION 0x548E1 | ||
40 | +#define FIRMWARE_VARIANT 0x77777777 /* TODO: Find the real value */ | ||
41 | + | ||
42 | +#define ARM_MEMORY_BASE 0x00000000 | ||
43 | +#define ARM_MEMORY_SIZE 0x3c000000 | ||
44 | +#define VC_MEMORY_BASE 0x3c000000 | ||
45 | +#define VC_MEMORY_SIZE 0x04000000 | ||
46 | +#define VC_FB_BASE 0x3c100000 | ||
47 | +#define VC_FB_SIZE 0x00096000 | ||
48 | + | ||
49 | +#define CLOCK_ID_ROOT 0x00000000 | ||
50 | +#define CLOCK_ID_EMMC 0x00000001 | ||
51 | +#define CLOCK_ID_UART 0x00000002 | ||
52 | +#define CLOCK_ID_ARM 0x00000003 | ||
53 | +#define CLOCK_ID_CORE 0x00000004 | ||
54 | +#define CLOCK_ID_UNDEFINED 0x12345678 | ||
55 | + | ||
56 | +#define CLOCK_RATE_EMMC 50000000 | ||
57 | +#define CLOCK_RATE_UART 3000000 | ||
58 | +#define CLOCK_RATE_CORE 350000000 | ||
59 | +#define CLOCK_RATE_ANY 700000000 | ||
60 | + | ||
61 | +#define DEVICE_ID_SD_CARD 0x00000000 | ||
62 | +#define DEVICE_ID_UART0 0x00000001 | ||
63 | +#define DEVICE_ID_UART1 0x00000002 | ||
64 | +#define DEVICE_ID_USB HCD 0x00000003 | ||
65 | +#define DEVICE_ID_I2C0 0x00000004 | ||
66 | +#define DEVICE_ID_I2C1 0x00000005 | ||
67 | +#define DEVICE_ID_I2C2 0x00000006 | ||
68 | +#define DEVICE_ID_SPI 0x00000007 | ||
69 | +#define DEVICE_ID_CCP2TX 0x00000008 | ||
70 | +#define DEVICE_ID_UNKNOWN_0 0x00000009 | ||
71 | +#define DEVICE_ID_UNKNOWN_1 0x0000000a | ||
72 | + | ||
73 | +#define TEMPERATURE_ID_SOC 0x00000000 | ||
74 | + | ||
75 | +#define TEMPERATURE_SOC 25000 | ||
76 | +#define TEMPERATURE_SOC_MAX 99000 | ||
77 | + | ||
78 | +#define ALIGN_4K 4096 | ||
79 | + | ||
80 | +#define PIXEL_ORDER_BGR 0 | ||
81 | +#define PIXEL_ORDER_RGB 1 | ||
82 | + | ||
83 | +#define ALPHA_MODE_ENABLED 0 | ||
84 | +#define ALPHA_MODE_REVERSED 1 | ||
85 | +#define ALPHA_MODE_IGNORED 2 | ||
86 | + | ||
87 | +#define GPIO_MASK 0x003c | ||
88 | + | ||
89 | +#define GPIO_0 0x00000080 | ||
90 | + | ||
91 | +#define GPIO_DIRECTION_IN 0 | ||
92 | +#define GPIO_DIRECTION_OUT 1 | ||
93 | + | ||
94 | +#define GPIO_TERMINATION_DISABLED 0 | ||
95 | +#define GPIO_TERMINATION_ENABLED 1 | ||
96 | + | ||
97 | +#define GPIO_TERMINATION_PULLUP_DISABLED 0 | ||
98 | +#define GPIO_TERMINATION_PULLUP_ENABLED 1 | ||
99 | + | ||
100 | +#define GPIO_POLARITY_LOW 0 | ||
101 | +#define GPIO_POLARITY_HIGH 1 | ||
102 | + | ||
103 | +#define GPIO_STATE_DOWN 0 | ||
104 | + | ||
105 | +/* Used to test stubs that don't perform actual work */ | ||
106 | +#define DUMMY_VALUE 0x12345678 | ||
107 | + | ||
108 | typedef struct { | ||
109 | uint32_t size; | ||
110 | uint32_t req_resp_code; | ||
111 | diff --git a/tests/qtest/bcm2838-mailbox.c b/tests/qtest/bcm2838-mailbox.c | ||
112 | index XXXXXXX..XXXXXXX 100644 | ||
113 | --- a/tests/qtest/bcm2838-mailbox.c | ||
114 | +++ b/tests/qtest/bcm2838-mailbox.c | ||
115 | @@ -XXX,XX +XXX,XX @@ | ||
116 | #include "hw/registerfields.h" | ||
117 | #include "libqtest-single.h" | ||
118 | #include "bcm2838-mailbox.h" | ||
119 | +#include "hw/arm/raspberrypi-fw-defs.h" | ||
120 | |||
121 | REG32(MBOX_EXCHNG_REG, 0) | ||
122 | FIELD(MBOX_EXCHNG_REG, CHANNEL, 0, 4) | ||
123 | -- | ||
124 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Sergey Kambalin <serg.oker@gmail.com> | ||
2 | 1 | ||
3 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> | ||
4 | Message-id: 20240226000259.2752893-34-sergey.kambalin@auriga.com | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | tests/qtest/bcm2838-mailbox.h | 177 ++++++++++++++++++++++++++++++++++ | ||
9 | 1 file changed, 177 insertions(+) | ||
10 | |||
11 | diff --git a/tests/qtest/bcm2838-mailbox.h b/tests/qtest/bcm2838-mailbox.h | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/tests/qtest/bcm2838-mailbox.h | ||
14 | +++ b/tests/qtest/bcm2838-mailbox.h | ||
15 | @@ -XXX,XX +XXX,XX @@ typedef struct { \ | ||
16 | }; \ | ||
17 | } TypeName | ||
18 | |||
19 | +DECLARE_TAG_TYPE(TAG_GET_FIRMWARE_REVISION_t, | ||
20 | + struct {}, | ||
21 | + struct { | ||
22 | + uint32_t revision; | ||
23 | + }); | ||
24 | + | ||
25 | +DECLARE_TAG_TYPE(TAG_GET_FIRMWARE_VARIANT_t, | ||
26 | + struct {}, | ||
27 | + struct { | ||
28 | + uint32_t variant; | ||
29 | + }); | ||
30 | + | ||
31 | +DECLARE_TAG_TYPE(TAG_GET_BOARD_REVISION_t, | ||
32 | + struct {}, | ||
33 | + struct { | ||
34 | + uint32_t revision; | ||
35 | + }); | ||
36 | + | ||
37 | +DECLARE_TAG_TYPE(TAG_GET_ARM_MEMORY_t, | ||
38 | + struct {}, | ||
39 | + struct { | ||
40 | + uint32_t base; | ||
41 | + uint32_t size; | ||
42 | + }); | ||
43 | + | ||
44 | +DECLARE_TAG_TYPE(TAG_GET_VC_MEMORY_t, | ||
45 | + struct {}, | ||
46 | + struct { | ||
47 | + uint32_t base; | ||
48 | + uint32_t size; | ||
49 | + }); | ||
50 | + | ||
51 | +DECLARE_TAG_TYPE(TAG_SET_POWER_STATE_t, | ||
52 | + struct { | ||
53 | + uint32_t device_id; | ||
54 | + uint32_t cmd; | ||
55 | + }, | ||
56 | + struct { | ||
57 | + uint32_t device_id; | ||
58 | + uint32_t cmd; | ||
59 | + }); | ||
60 | + | ||
61 | +DECLARE_TAG_TYPE(TAG_GET_CLOCK_STATE_t, | ||
62 | + struct { | ||
63 | + uint32_t clock_id; | ||
64 | + }, | ||
65 | + struct { | ||
66 | + uint32_t clock_id; | ||
67 | + uint32_t cmd; | ||
68 | + }); | ||
69 | + | ||
70 | +DECLARE_TAG_TYPE(TAG_GET_CLOCK_RATE_t, | ||
71 | + struct { | ||
72 | + uint32_t clock_id; | ||
73 | + }, | ||
74 | + struct { | ||
75 | + uint32_t clock_id; | ||
76 | + uint32_t rate; | ||
77 | + }); | ||
78 | + | ||
79 | +DECLARE_TAG_TYPE(TAG_GET_MAX_CLOCK_RATE_t, | ||
80 | + struct { | ||
81 | + uint32_t clock_id; | ||
82 | + }, | ||
83 | + struct { | ||
84 | + uint32_t clock_id; | ||
85 | + uint32_t rate; | ||
86 | + }); | ||
87 | + | ||
88 | +DECLARE_TAG_TYPE(TAG_GET_MIN_CLOCK_RATE_t, | ||
89 | + struct { | ||
90 | + uint32_t clock_id; | ||
91 | + }, | ||
92 | + struct { | ||
93 | + uint32_t clock_id; | ||
94 | + uint32_t rate; | ||
95 | + }); | ||
96 | + | ||
97 | +DECLARE_TAG_TYPE(TAG_GET_CLOCKS_t, | ||
98 | + struct {}, | ||
99 | + struct { | ||
100 | + uint32_t root_clock; | ||
101 | + uint32_t arm_clock; | ||
102 | + }); | ||
103 | + | ||
104 | +DECLARE_TAG_TYPE(TAG_GET_TEMPERATURE_t, | ||
105 | + struct { | ||
106 | + uint32_t temperature_id; | ||
107 | + }, | ||
108 | + struct { | ||
109 | + uint32_t temperature_id; | ||
110 | + uint32_t temperature; | ||
111 | + }); | ||
112 | + | ||
113 | +DECLARE_TAG_TYPE(TAG_GET_MAX_TEMPERATURE_t, | ||
114 | + struct { | ||
115 | + uint32_t temperature_id; | ||
116 | + }, | ||
117 | + struct { | ||
118 | + uint32_t temperature_id; | ||
119 | + uint32_t temperature; | ||
120 | + }); | ||
121 | + | ||
122 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_ALLOCATE_t, | ||
123 | + struct { | ||
124 | + uint32_t alignment; | ||
125 | + }, | ||
126 | + struct { | ||
127 | + uint32_t base; | ||
128 | + uint32_t size; | ||
129 | + }); | ||
130 | + | ||
131 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_RELEASE_t, | ||
132 | + struct {}, | ||
133 | + struct {}); | ||
134 | + | ||
135 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_BLANK_t, | ||
136 | + struct { | ||
137 | + uint32_t on; | ||
138 | + }, | ||
139 | + struct { | ||
140 | + uint32_t on; | ||
141 | + }); | ||
142 | + | ||
143 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_GET_PHYSICAL_WIDTH_HEIGHT_t, | ||
144 | + struct {}, | ||
145 | + struct { | ||
146 | + uint32_t width; | ||
147 | + uint32_t height; | ||
148 | + }); | ||
149 | + | ||
150 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_TEST_PHYSICAL_WIDTH_HEIGHT_t, | ||
151 | + struct { | ||
152 | + uint32_t width; | ||
153 | + uint32_t height; | ||
154 | + }, | ||
155 | + struct { | ||
156 | + uint32_t width; | ||
157 | + uint32_t height; | ||
158 | + }); | ||
159 | + | ||
160 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_SET_PHYSICAL_WIDTH_HEIGHT_t, | ||
161 | + struct { | ||
162 | + uint32_t width; | ||
163 | + uint32_t height; | ||
164 | + }, | ||
165 | + struct { | ||
166 | + uint32_t width; | ||
167 | + uint32_t height; | ||
168 | + }); | ||
169 | + | ||
170 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_GET_VIRTUAL_WIDTH_HEIGHT_t, | ||
171 | + struct {}, | ||
172 | + struct { | ||
173 | + uint32_t width; | ||
174 | + uint32_t height; | ||
175 | + }); | ||
176 | + | ||
177 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_TEST_VIRTUAL_WIDTH_HEIGHT_t, | ||
178 | + struct { | ||
179 | + uint32_t width; | ||
180 | + uint32_t height; | ||
181 | + }, | ||
182 | + struct { | ||
183 | + uint32_t width; | ||
184 | + uint32_t height; | ||
185 | + }); | ||
186 | + | ||
187 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_SET_VIRTUAL_WIDTH_HEIGHT_t, | ||
188 | + struct { | ||
189 | + uint32_t width; | ||
190 | + uint32_t height; | ||
191 | + }, | ||
192 | + struct { | ||
193 | + uint32_t width; | ||
194 | + uint32_t height; | ||
195 | + }); | ||
196 | |||
197 | int mbox0_has_data(void); | ||
198 | void mbox0_read_message(uint8_t channel, void *msgbuf, size_t msgbuf_size); | ||
199 | -- | ||
200 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Sergey Kambalin <serg.oker@gmail.com> | ||
2 | 1 | ||
3 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> | ||
4 | Message-id: 20240226000259.2752893-35-sergey.kambalin@auriga.com | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | tests/qtest/bcm2838-mailbox.h | 152 ++++++++++++++++++++++++++++++++++ | ||
9 | 1 file changed, 152 insertions(+) | ||
10 | |||
11 | diff --git a/tests/qtest/bcm2838-mailbox.h b/tests/qtest/bcm2838-mailbox.h | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/tests/qtest/bcm2838-mailbox.h | ||
14 | +++ b/tests/qtest/bcm2838-mailbox.h | ||
15 | @@ -XXX,XX +XXX,XX @@ DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_SET_VIRTUAL_WIDTH_HEIGHT_t, | ||
16 | uint32_t height; | ||
17 | }); | ||
18 | |||
19 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_GET_DEPTH_t, | ||
20 | + struct {}, | ||
21 | + struct { | ||
22 | + uint32_t bpp; | ||
23 | + }); | ||
24 | + | ||
25 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_TEST_DEPTH_t, | ||
26 | + struct { | ||
27 | + uint32_t bpp; | ||
28 | + }, | ||
29 | + struct { | ||
30 | + uint32_t bpp; | ||
31 | + }); | ||
32 | + | ||
33 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_SET_DEPTH_t, | ||
34 | + struct { | ||
35 | + uint32_t bpp; | ||
36 | + }, | ||
37 | + struct { | ||
38 | + uint32_t bpp; | ||
39 | + }); | ||
40 | + | ||
41 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_GET_PIXEL_ORDER_t, | ||
42 | + struct {}, | ||
43 | + struct { | ||
44 | + uint32_t pixel_order; | ||
45 | + }); | ||
46 | + | ||
47 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_TEST_PIXEL_ORDER_t, | ||
48 | + struct { | ||
49 | + uint32_t pixel_order; | ||
50 | + }, | ||
51 | + struct { | ||
52 | + uint32_t pixel_order; | ||
53 | + }); | ||
54 | + | ||
55 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_SET_PIXEL_ORDER_t, | ||
56 | + struct { | ||
57 | + uint32_t pixel_order; | ||
58 | + }, | ||
59 | + struct { | ||
60 | + uint32_t pixel_order; | ||
61 | + }); | ||
62 | + | ||
63 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_GET_ALPHA_MODE_t, | ||
64 | + struct {}, | ||
65 | + struct { | ||
66 | + uint32_t alpha_mode; | ||
67 | + }); | ||
68 | + | ||
69 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_TEST_ALPHA_MODE_t, | ||
70 | + struct { | ||
71 | + uint32_t alpha_mode; | ||
72 | + }, | ||
73 | + struct { | ||
74 | + uint32_t alpha_mode; | ||
75 | + }); | ||
76 | + | ||
77 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_SET_ALPHA_MODE_t, | ||
78 | + struct { | ||
79 | + uint32_t alpha_mode; | ||
80 | + }, | ||
81 | + struct { | ||
82 | + uint32_t alpha_mode; | ||
83 | + }); | ||
84 | + | ||
85 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_GET_PITCH_t, | ||
86 | + struct {}, | ||
87 | + struct { | ||
88 | + uint32_t pitch; | ||
89 | + }); | ||
90 | + | ||
91 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_SET_PITCH_t, | ||
92 | + struct { | ||
93 | + uint32_t pitch; | ||
94 | + }, | ||
95 | + struct {}); | ||
96 | + | ||
97 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_GET_VIRTUAL_OFFSET_t, | ||
98 | + struct {}, | ||
99 | + struct { | ||
100 | + uint32_t x; | ||
101 | + uint32_t y; | ||
102 | + }); | ||
103 | + | ||
104 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_TEST_VIRTUAL_OFFSET_t, | ||
105 | + struct { | ||
106 | + uint32_t x; | ||
107 | + uint32_t y; | ||
108 | + }, | ||
109 | + struct { | ||
110 | + uint32_t x; | ||
111 | + uint32_t y; | ||
112 | + }); | ||
113 | + | ||
114 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_SET_VIRTUAL_OFFSET_t, | ||
115 | + struct { | ||
116 | + uint32_t x; | ||
117 | + uint32_t y; | ||
118 | + }, | ||
119 | + struct { | ||
120 | + uint32_t x; | ||
121 | + uint32_t y; | ||
122 | + }); | ||
123 | + | ||
124 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_GET_OVERSCAN_t, | ||
125 | + struct {}, | ||
126 | + struct { | ||
127 | + uint32_t top; | ||
128 | + uint32_t bottom; | ||
129 | + uint32_t left; | ||
130 | + uint32_t right; | ||
131 | + }); | ||
132 | + | ||
133 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_TEST_OVERSCAN_t, | ||
134 | + struct { | ||
135 | + uint32_t top; | ||
136 | + uint32_t bottom; | ||
137 | + uint32_t left; | ||
138 | + uint32_t right; | ||
139 | + }, | ||
140 | + struct { | ||
141 | + uint32_t top; | ||
142 | + uint32_t bottom; | ||
143 | + uint32_t left; | ||
144 | + uint32_t right; | ||
145 | + }); | ||
146 | + | ||
147 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_SET_OVERSCAN_t, | ||
148 | + struct { | ||
149 | + uint32_t top; | ||
150 | + uint32_t bottom; | ||
151 | + uint32_t left; | ||
152 | + uint32_t right; | ||
153 | + }, | ||
154 | + struct { | ||
155 | + uint32_t top; | ||
156 | + uint32_t bottom; | ||
157 | + uint32_t left; | ||
158 | + uint32_t right; | ||
159 | + }); | ||
160 | + | ||
161 | +DECLARE_TAG_TYPE(TAG_GET_COMMAND_LINE_t, | ||
162 | + struct {}, | ||
163 | + struct {}); | ||
164 | + | ||
165 | +DECLARE_TAG_TYPE(TAG_GET_DMA_CHANNELS_t, | ||
166 | + struct {}, | ||
167 | + struct { | ||
168 | + uint32_t mask; | ||
169 | + }); | ||
170 | + | ||
171 | int mbox0_has_data(void); | ||
172 | void mbox0_read_message(uint8_t channel, void *msgbuf, size_t msgbuf_size); | ||
173 | void mbox1_write_message(uint8_t channel, uint32_t msg_addr); | ||
174 | -- | ||
175 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Sergey Kambalin <serg.oker@gmail.com> | ||
2 | 1 | ||
3 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> | ||
4 | Message-id: 20240226000259.2752893-36-sergey.kambalin@auriga.com | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | tests/qtest/bcm2838-mailbox.h | 78 +++++++++++++++++++++++++++++++++++ | ||
9 | 1 file changed, 78 insertions(+) | ||
10 | |||
11 | diff --git a/tests/qtest/bcm2838-mailbox.h b/tests/qtest/bcm2838-mailbox.h | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/tests/qtest/bcm2838-mailbox.h | ||
14 | +++ b/tests/qtest/bcm2838-mailbox.h | ||
15 | @@ -XXX,XX +XXX,XX @@ DECLARE_TAG_TYPE(TAG_GET_DMA_CHANNELS_t, | ||
16 | uint32_t mask; | ||
17 | }); | ||
18 | |||
19 | +DECLARE_TAG_TYPE(TAG_GET_THROTTLED_t, | ||
20 | + struct {}, | ||
21 | + struct { | ||
22 | + uint32_t throttled; | ||
23 | + }); | ||
24 | + | ||
25 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_GET_NUM_DISPLAYS_t, | ||
26 | + struct {}, | ||
27 | + struct { | ||
28 | + uint32_t num_displays; | ||
29 | + }); | ||
30 | + | ||
31 | +DECLARE_TAG_TYPE(TAG_FRAMEBUFFER_GET_DISPLAY_SETTINGS_t, | ||
32 | + struct {}, | ||
33 | + struct { | ||
34 | + uint32_t display_num; | ||
35 | + uint32_t phys_width; | ||
36 | + uint32_t phys_height; | ||
37 | + uint32_t bpp; | ||
38 | + uint16_t pitch; | ||
39 | + uint32_t virt_width; | ||
40 | + uint32_t virt_height; | ||
41 | + uint16_t virt_width_offset; | ||
42 | + uint32_t virt_height_offset; | ||
43 | + uint32_t fb_bus_address_lo; | ||
44 | + uint32_t fb_bus_address_hi; | ||
45 | + }); | ||
46 | + | ||
47 | +DECLARE_TAG_TYPE(TAG_GET_GPIO_CONFIG_t, | ||
48 | + struct { | ||
49 | + uint32_t gpio_num; | ||
50 | + }, | ||
51 | + struct { | ||
52 | + uint32_t zero; | ||
53 | + uint32_t direction; | ||
54 | + uint32_t polarity; | ||
55 | + uint32_t term_en; | ||
56 | + uint32_t term_pull_up; | ||
57 | + }); | ||
58 | + | ||
59 | + | ||
60 | +DECLARE_TAG_TYPE(TAG_SET_GPIO_CONFIG_t, | ||
61 | + struct { | ||
62 | + uint32_t gpio_num; | ||
63 | + uint32_t direction; | ||
64 | + uint32_t polarity; | ||
65 | + uint32_t term_en; | ||
66 | + uint32_t term_pull_up; | ||
67 | + uint32_t state; | ||
68 | + }, | ||
69 | + struct { | ||
70 | + uint32_t zero; | ||
71 | + }); | ||
72 | + | ||
73 | +DECLARE_TAG_TYPE(TAG_GET_GPIO_STATE_t, | ||
74 | + struct { | ||
75 | + uint32_t gpio_num; | ||
76 | + }, | ||
77 | + struct { | ||
78 | + uint32_t zero; | ||
79 | + uint32_t state; | ||
80 | + }); | ||
81 | + | ||
82 | +DECLARE_TAG_TYPE(TAG_SET_GPIO_STATE_t, | ||
83 | + struct { | ||
84 | + uint32_t gpio_num; | ||
85 | + uint32_t state; | ||
86 | + }, | ||
87 | + struct { | ||
88 | + uint32_t zero; | ||
89 | + }); | ||
90 | + | ||
91 | +DECLARE_TAG_TYPE(TAG_VCHIQ_INIT_t, | ||
92 | + struct {}, | ||
93 | + struct { | ||
94 | + uint32_t zero; | ||
95 | + }); | ||
96 | + | ||
97 | int mbox0_has_data(void); | ||
98 | void mbox0_read_message(uint8_t channel, void *msgbuf, size_t msgbuf_size); | ||
99 | void mbox1_write_message(uint8_t channel, uint32_t msg_addr); | ||
100 | -- | ||
101 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Sergey Kambalin <serg.oker@gmail.com> | ||
2 | 1 | ||
3 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> | ||
4 | Message-id: 20240226000259.2752893-37-sergey.kambalin@auriga.com | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | tests/qtest/bcm2838-mailbox.c | 1 - | ||
9 | tests/qtest/bcm2838-mbox-property-test.c | 207 +++++++++++++++++++++++ | ||
10 | tests/qtest/meson.build | 2 +- | ||
11 | 3 files changed, 208 insertions(+), 2 deletions(-) | ||
12 | create mode 100644 tests/qtest/bcm2838-mbox-property-test.c | ||
13 | |||
14 | diff --git a/tests/qtest/bcm2838-mailbox.c b/tests/qtest/bcm2838-mailbox.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/tests/qtest/bcm2838-mailbox.c | ||
17 | +++ b/tests/qtest/bcm2838-mailbox.c | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | #include "hw/registerfields.h" | ||
20 | #include "libqtest-single.h" | ||
21 | #include "bcm2838-mailbox.h" | ||
22 | -#include "hw/arm/raspberrypi-fw-defs.h" | ||
23 | |||
24 | REG32(MBOX_EXCHNG_REG, 0) | ||
25 | FIELD(MBOX_EXCHNG_REG, CHANNEL, 0, 4) | ||
26 | diff --git a/tests/qtest/bcm2838-mbox-property-test.c b/tests/qtest/bcm2838-mbox-property-test.c | ||
27 | new file mode 100644 | ||
28 | index XXXXXXX..XXXXXXX | ||
29 | --- /dev/null | ||
30 | +++ b/tests/qtest/bcm2838-mbox-property-test.c | ||
31 | @@ -XXX,XX +XXX,XX @@ | ||
32 | +/* | ||
33 | + * Tests set for BCM2838 mailbox property interface. | ||
34 | + * | ||
35 | + * Copyright (c) 2022 Auriga | ||
36 | + * | ||
37 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
38 | + * See the COPYING file in the top-level directory. | ||
39 | + */ | ||
40 | + | ||
41 | +#include "qemu/osdep.h" | ||
42 | +#include "hw/registerfields.h" | ||
43 | +#include "libqtest-single.h" | ||
44 | +#include "bcm2838-mailbox.h" | ||
45 | +#include "hw/arm/raspberrypi-fw-defs.h" | ||
46 | + | ||
47 | +REG32(MBOX_SIZE_STAT, 0) | ||
48 | +FIELD(MBOX_SIZE_STAT, SIZE, 0, 31) | ||
49 | +FIELD(MBOX_SIZE_STAT, SUCCESS, 31, 1) | ||
50 | + | ||
51 | +REG32(SET_POWER_STATE_CMD, 0) | ||
52 | +FIELD(SET_POWER_STATE_CMD, EN, 0, 1) | ||
53 | +FIELD(SET_POWER_STATE_CMD, WAIT, 1, 1) | ||
54 | + | ||
55 | +REG32(GET_CLOCK_STATE_CMD, 0) | ||
56 | +FIELD(GET_CLOCK_STATE_CMD, EN, 0, 1) | ||
57 | +FIELD(GET_CLOCK_STATE_CMD, NPRES, 1, 1) | ||
58 | + | ||
59 | +#define MBOX_TEST_MESSAGE_ADDRESS 0x10000000 | ||
60 | + | ||
61 | +#define TEST_TAG(x) RPI_FWREQ_ ## x | ||
62 | +#define TEST_TAG_TYPE(x) TAG_##x##_t | ||
63 | + | ||
64 | +#define TEST_FN_NAME(test, subtest) \ | ||
65 | + test ## _ ## subtest ## _test | ||
66 | + | ||
67 | +#define SETUP_FN_NAME(test, subtest) \ | ||
68 | + test ## _ ## subtest ## _setup | ||
69 | + | ||
70 | +#define CHECK_FN_NAME(test, subtest) \ | ||
71 | + test ## _ ## subtest ## _spec_check | ||
72 | + | ||
73 | +#define DECLARE_TEST_CASE_SETUP(testname, ...) \ | ||
74 | + void SETUP_FN_NAME(testname, __VA_ARGS__) \ | ||
75 | + (TEST_TAG_TYPE(testname) * tag) | ||
76 | + | ||
77 | +/*----------------------------------------------------------------------------*/ | ||
78 | +#define DECLARE_TEST_CASE(testname, ...) \ | ||
79 | + __attribute__((weak)) \ | ||
80 | + void SETUP_FN_NAME(testname, __VA_ARGS__) \ | ||
81 | + (TEST_TAG_TYPE(testname) * tag); \ | ||
82 | + static void CHECK_FN_NAME(testname, __VA_ARGS__) \ | ||
83 | + (TEST_TAG_TYPE(testname) *tag); \ | ||
84 | + static void TEST_FN_NAME(testname, __VA_ARGS__)(void) { \ | ||
85 | + struct { \ | ||
86 | + MboxBufHeader header; \ | ||
87 | + TEST_TAG_TYPE(testname) tag; \ | ||
88 | + uint32_t end_tag; \ | ||
89 | + } mailbox_buffer = { 0 }; \ | ||
90 | + \ | ||
91 | + QTestState *qts = qtest_init("-machine raspi4b"); \ | ||
92 | + \ | ||
93 | + mailbox_buffer.header.size = sizeof(mailbox_buffer); \ | ||
94 | + mailbox_buffer.header.req_resp_code = MBOX_PROCESS_REQUEST; \ | ||
95 | + \ | ||
96 | + mailbox_buffer.tag.id = TEST_TAG(testname); \ | ||
97 | + mailbox_buffer.tag.value_buffer_size = MAX( \ | ||
98 | + sizeof(mailbox_buffer.tag.request.value), \ | ||
99 | + sizeof(mailbox_buffer.tag.response.value)); \ | ||
100 | + mailbox_buffer.tag.request.zero = 0; \ | ||
101 | + \ | ||
102 | + mailbox_buffer.end_tag = RPI_FWREQ_PROPERTY_END; \ | ||
103 | + \ | ||
104 | + if (SETUP_FN_NAME(testname, __VA_ARGS__)) { \ | ||
105 | + SETUP_FN_NAME(testname, __VA_ARGS__)(&mailbox_buffer.tag); \ | ||
106 | + } \ | ||
107 | + \ | ||
108 | + qtest_memwrite(qts, MBOX_TEST_MESSAGE_ADDRESS, \ | ||
109 | + &mailbox_buffer, sizeof(mailbox_buffer)); \ | ||
110 | + qtest_mbox1_write_message(qts, MBOX_CHANNEL_ID_PROPERTY, \ | ||
111 | + MBOX_TEST_MESSAGE_ADDRESS); \ | ||
112 | + \ | ||
113 | + qtest_mbox0_read_message(qts, MBOX_CHANNEL_ID_PROPERTY, \ | ||
114 | + &mailbox_buffer, sizeof(mailbox_buffer)); \ | ||
115 | + \ | ||
116 | + g_assert_cmphex(mailbox_buffer.header.req_resp_code, ==, MBOX_SUCCESS);\ | ||
117 | + \ | ||
118 | + g_assert_cmphex(mailbox_buffer.tag.id, ==, TEST_TAG(testname)); \ | ||
119 | + \ | ||
120 | + uint32_t size = FIELD_EX32(mailbox_buffer.tag.response.size_stat, \ | ||
121 | + MBOX_SIZE_STAT, SIZE); \ | ||
122 | + uint32_t success = FIELD_EX32(mailbox_buffer.tag.response.size_stat, \ | ||
123 | + MBOX_SIZE_STAT, SUCCESS); \ | ||
124 | + g_assert_cmpint(size, ==, sizeof(mailbox_buffer.tag.response.value)); \ | ||
125 | + g_assert_cmpint(success, ==, 1); \ | ||
126 | + \ | ||
127 | + CHECK_FN_NAME(testname, __VA_ARGS__)(&mailbox_buffer.tag); \ | ||
128 | + \ | ||
129 | + qtest_quit(qts); \ | ||
130 | + } \ | ||
131 | + static void CHECK_FN_NAME(testname, __VA_ARGS__) \ | ||
132 | + (TEST_TAG_TYPE(testname) * tag) | ||
133 | + | ||
134 | +/*----------------------------------------------------------------------------*/ | ||
135 | + | ||
136 | +#define QTEST_ADD_TEST_CASE(testname, ...) \ | ||
137 | + qtest_add_func(stringify(/bcm2838/mbox/property/ \ | ||
138 | + TEST_FN_NAME(testname, __VA_ARGS__)-test), \ | ||
139 | + TEST_FN_NAME(testname, __VA_ARGS__)) | ||
140 | + | ||
141 | +/*----------------------------------------------------------------------------*/ | ||
142 | +DECLARE_TEST_CASE(GET_FIRMWARE_REVISION) { | ||
143 | + g_assert_cmpint(tag->response.value.revision, ==, FIRMWARE_REVISION); | ||
144 | +} | ||
145 | + | ||
146 | +/*----------------------------------------------------------------------------*/ | ||
147 | +DECLARE_TEST_CASE(GET_BOARD_REVISION) { | ||
148 | + g_assert_cmpint(tag->response.value.revision, ==, BOARD_REVISION); | ||
149 | +} | ||
150 | + | ||
151 | +/*----------------------------------------------------------------------------*/ | ||
152 | +DECLARE_TEST_CASE(GET_ARM_MEMORY) { | ||
153 | + g_assert_cmphex(tag->response.value.base, ==, ARM_MEMORY_BASE); | ||
154 | + g_assert_cmphex(tag->response.value.size, ==, ARM_MEMORY_SIZE); | ||
155 | +} | ||
156 | + | ||
157 | +/*----------------------------------------------------------------------------*/ | ||
158 | +DECLARE_TEST_CASE(GET_VC_MEMORY) { | ||
159 | + g_assert_cmphex(tag->response.value.base, ==, VC_MEMORY_BASE); | ||
160 | + g_assert_cmphex(tag->response.value.size, ==, VC_MEMORY_SIZE); | ||
161 | +} | ||
162 | + | ||
163 | +/*----------------------------------------------------------------------------*/ | ||
164 | +DECLARE_TEST_CASE(SET_POWER_STATE) { | ||
165 | + uint32_t enabled = | ||
166 | + FIELD_EX32(tag->response.value.cmd, SET_POWER_STATE_CMD, EN); | ||
167 | + uint32_t wait = | ||
168 | + FIELD_EX32(tag->response.value.cmd, SET_POWER_STATE_CMD, WAIT); | ||
169 | + g_assert_cmphex(tag->response.value.device_id, ==, DEVICE_ID_UART0); | ||
170 | + g_assert_cmpint(enabled, ==, 1); | ||
171 | + g_assert_cmpint(wait, ==, 0); | ||
172 | +} | ||
173 | +DECLARE_TEST_CASE_SETUP(SET_POWER_STATE) { | ||
174 | + tag->request.value.device_id = DEVICE_ID_UART0; | ||
175 | + tag->response.value.cmd = | ||
176 | + FIELD_DP32(tag->response.value.cmd, SET_POWER_STATE_CMD, EN, 1); | ||
177 | + tag->response.value.cmd = | ||
178 | + FIELD_DP32(tag->response.value.cmd, SET_POWER_STATE_CMD, WAIT, 1); | ||
179 | +} | ||
180 | + | ||
181 | +/*----------------------------------------------------------------------------*/ | ||
182 | +DECLARE_TEST_CASE(GET_CLOCK_STATE) { | ||
183 | + uint32_t enabled = | ||
184 | + FIELD_EX32(tag->response.value.cmd, GET_CLOCK_STATE_CMD, EN); | ||
185 | + uint32_t not_present = | ||
186 | + FIELD_EX32(tag->response.value.cmd, GET_CLOCK_STATE_CMD, NPRES); | ||
187 | + g_assert_cmphex(tag->response.value.clock_id, ==, CLOCK_ID_CORE); | ||
188 | + g_assert_cmphex(enabled, ==, 1); | ||
189 | + g_assert_cmphex(not_present, ==, 0); | ||
190 | +} | ||
191 | +DECLARE_TEST_CASE_SETUP(GET_CLOCK_STATE) { | ||
192 | + tag->request.value.clock_id = CLOCK_ID_CORE; | ||
193 | +} | ||
194 | + | ||
195 | +/*----------------------------------------------------------------------------*/ | ||
196 | +DECLARE_TEST_CASE(GET_CLOCK_RATE, EMMC) { | ||
197 | + g_assert_cmphex(tag->response.value.clock_id, ==, CLOCK_ID_EMMC); | ||
198 | + g_assert_cmphex(tag->response.value.rate, ==, CLOCK_RATE_EMMC); | ||
199 | +} | ||
200 | +DECLARE_TEST_CASE_SETUP(GET_CLOCK_RATE, EMMC) { | ||
201 | + tag->request.value.clock_id = CLOCK_ID_EMMC; | ||
202 | +} | ||
203 | + | ||
204 | +/*----------------------------------------------------------------------------*/ | ||
205 | +DECLARE_TEST_CASE(GET_MAX_CLOCK_RATE, EMMC) { | ||
206 | + g_assert_cmphex(tag->response.value.clock_id, ==, CLOCK_ID_EMMC); | ||
207 | + g_assert_cmphex(tag->response.value.rate, ==, CLOCK_RATE_EMMC); | ||
208 | +} | ||
209 | +DECLARE_TEST_CASE_SETUP(GET_MAX_CLOCK_RATE, EMMC) { | ||
210 | + tag->request.value.clock_id = CLOCK_ID_EMMC; | ||
211 | +} | ||
212 | + | ||
213 | +/*----------------------------------------------------------------------------*/ | ||
214 | +DECLARE_TEST_CASE(GET_MIN_CLOCK_RATE, EMMC) { | ||
215 | + g_assert_cmphex(tag->response.value.clock_id, ==, CLOCK_ID_EMMC); | ||
216 | + g_assert_cmphex(tag->response.value.rate, ==, CLOCK_RATE_EMMC); | ||
217 | +} | ||
218 | +DECLARE_TEST_CASE_SETUP(GET_MIN_CLOCK_RATE, EMMC) { | ||
219 | + tag->request.value.clock_id = CLOCK_ID_EMMC; | ||
220 | +} | ||
221 | + | ||
222 | +/*----------------------------------------------------------------------------*/ | ||
223 | +int main(int argc, char **argv) | ||
224 | +{ | ||
225 | + g_test_init(&argc, &argv, NULL); | ||
226 | + | ||
227 | + QTEST_ADD_TEST_CASE(GET_FIRMWARE_REVISION); | ||
228 | + QTEST_ADD_TEST_CASE(GET_BOARD_REVISION); | ||
229 | + QTEST_ADD_TEST_CASE(GET_ARM_MEMORY); | ||
230 | + QTEST_ADD_TEST_CASE(GET_VC_MEMORY); | ||
231 | + QTEST_ADD_TEST_CASE(SET_POWER_STATE); | ||
232 | + QTEST_ADD_TEST_CASE(GET_CLOCK_STATE); | ||
233 | + QTEST_ADD_TEST_CASE(GET_CLOCK_RATE, EMMC); | ||
234 | + QTEST_ADD_TEST_CASE(GET_MAX_CLOCK_RATE, EMMC); | ||
235 | + QTEST_ADD_TEST_CASE(GET_MIN_CLOCK_RATE, EMMC); | ||
236 | + | ||
237 | + return g_test_run(); | ||
238 | +} | ||
239 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build | ||
240 | index XXXXXXX..XXXXXXX 100644 | ||
241 | --- a/tests/qtest/meson.build | ||
242 | +++ b/tests/qtest/meson.build | ||
243 | @@ -XXX,XX +XXX,XX @@ qtests_aarch64 = \ | ||
244 | ['tpm-tis-device-test', 'tpm-tis-device-swtpm-test'] : []) + \ | ||
245 | (config_all_devices.has_key('CONFIG_XLNX_ZYNQMP_ARM') ? ['xlnx-can-test', 'fuzz-xlnx-dp-test'] : []) + \ | ||
246 | (config_all_devices.has_key('CONFIG_XLNX_VERSAL') ? ['xlnx-canfd-test', 'xlnx-versal-trng-test'] : []) + \ | ||
247 | - (config_all_devices.has_key('CONFIG_RASPI') ? ['bcm2835-dma-test'] : []) + \ | ||
248 | + (config_all_devices.has_key('CONFIG_RASPI') ? ['bcm2835-dma-test', 'bcm2838-mbox-property-test'] : []) + \ | ||
249 | (config_all_accel.has_key('CONFIG_TCG') and \ | ||
250 | config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test'] : []) + \ | ||
251 | ['arm-cpu-features', | ||
252 | -- | ||
253 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Sergey Kambalin <serg.oker@gmail.com> | ||
2 | 1 | ||
3 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> | ||
4 | Message-id: 20240226000259.2752893-38-sergey.kambalin@auriga.com | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | tests/qtest/bcm2838-mbox-property-test.c | 196 ++++++++++++++++++++++- | ||
9 | 1 file changed, 195 insertions(+), 1 deletion(-) | ||
10 | |||
11 | diff --git a/tests/qtest/bcm2838-mbox-property-test.c b/tests/qtest/bcm2838-mbox-property-test.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/tests/qtest/bcm2838-mbox-property-test.c | ||
14 | +++ b/tests/qtest/bcm2838-mbox-property-test.c | ||
15 | @@ -XXX,XX +XXX,XX @@ FIELD(GET_CLOCK_STATE_CMD, NPRES, 1, 1) | ||
16 | (TEST_TAG_TYPE(testname) * tag); \ | ||
17 | static void CHECK_FN_NAME(testname, __VA_ARGS__) \ | ||
18 | (TEST_TAG_TYPE(testname) *tag); \ | ||
19 | - static void TEST_FN_NAME(testname, __VA_ARGS__)(void) { \ | ||
20 | + static void TEST_FN_NAME(testname, __VA_ARGS__)(void) \ | ||
21 | + { \ | ||
22 | struct { \ | ||
23 | MboxBufHeader header; \ | ||
24 | TEST_TAG_TYPE(testname) tag; \ | ||
25 | @@ -XXX,XX +XXX,XX @@ DECLARE_TEST_CASE_SETUP(GET_MIN_CLOCK_RATE, EMMC) { | ||
26 | tag->request.value.clock_id = CLOCK_ID_EMMC; | ||
27 | } | ||
28 | |||
29 | +/*----------------------------------------------------------------------------*/ | ||
30 | +DECLARE_TEST_CASE(GET_CLOCK_RATE, UART) { | ||
31 | + g_assert_cmphex(tag->response.value.clock_id, ==, CLOCK_ID_UART); | ||
32 | + g_assert_cmphex(tag->response.value.rate, ==, CLOCK_RATE_UART); | ||
33 | +} | ||
34 | +DECLARE_TEST_CASE_SETUP(GET_CLOCK_RATE, UART) { | ||
35 | + tag->request.value.clock_id = CLOCK_ID_UART; | ||
36 | +} | ||
37 | + | ||
38 | +/*----------------------------------------------------------------------------*/ | ||
39 | +DECLARE_TEST_CASE(GET_MAX_CLOCK_RATE, UART) { | ||
40 | + g_assert_cmphex(tag->response.value.clock_id, ==, CLOCK_ID_UART); | ||
41 | + g_assert_cmphex(tag->response.value.rate, ==, CLOCK_RATE_UART); | ||
42 | +} | ||
43 | +DECLARE_TEST_CASE_SETUP(GET_MAX_CLOCK_RATE, UART) { | ||
44 | + tag->request.value.clock_id = CLOCK_ID_UART; | ||
45 | +} | ||
46 | + | ||
47 | +/*----------------------------------------------------------------------------*/ | ||
48 | +DECLARE_TEST_CASE(GET_MIN_CLOCK_RATE, UART) { | ||
49 | + g_assert_cmphex(tag->response.value.clock_id, ==, CLOCK_ID_UART); | ||
50 | + g_assert_cmphex(tag->response.value.rate, ==, CLOCK_RATE_UART); | ||
51 | +} | ||
52 | +DECLARE_TEST_CASE_SETUP(GET_MIN_CLOCK_RATE, UART) { | ||
53 | + tag->request.value.clock_id = CLOCK_ID_UART; | ||
54 | +} | ||
55 | + | ||
56 | +/*----------------------------------------------------------------------------*/ | ||
57 | +DECLARE_TEST_CASE(GET_CLOCK_RATE, CORE) { | ||
58 | + g_assert_cmphex(tag->response.value.clock_id, ==, CLOCK_ID_CORE); | ||
59 | + g_assert_cmphex(tag->response.value.rate, ==, CLOCK_RATE_CORE); | ||
60 | +} | ||
61 | +DECLARE_TEST_CASE_SETUP(GET_CLOCK_RATE, CORE) { | ||
62 | + tag->request.value.clock_id = CLOCK_ID_CORE; | ||
63 | +} | ||
64 | + | ||
65 | +/*----------------------------------------------------------------------------*/ | ||
66 | +DECLARE_TEST_CASE(GET_MAX_CLOCK_RATE, CORE) { | ||
67 | + g_assert_cmphex(tag->response.value.clock_id, ==, CLOCK_ID_CORE); | ||
68 | + g_assert_cmphex(tag->response.value.rate, ==, CLOCK_RATE_CORE); | ||
69 | +} | ||
70 | +DECLARE_TEST_CASE_SETUP(GET_MAX_CLOCK_RATE, CORE) { | ||
71 | + tag->request.value.clock_id = CLOCK_ID_CORE; | ||
72 | +} | ||
73 | + | ||
74 | +/*----------------------------------------------------------------------------*/ | ||
75 | +DECLARE_TEST_CASE(GET_MIN_CLOCK_RATE, CORE) { | ||
76 | + g_assert_cmphex(tag->response.value.clock_id, ==, CLOCK_ID_CORE); | ||
77 | + g_assert_cmphex(tag->response.value.rate, ==, CLOCK_RATE_CORE); | ||
78 | +} | ||
79 | +DECLARE_TEST_CASE_SETUP(GET_MIN_CLOCK_RATE, CORE) { | ||
80 | + tag->request.value.clock_id = CLOCK_ID_CORE; | ||
81 | +} | ||
82 | + | ||
83 | +/*----------------------------------------------------------------------------*/ | ||
84 | +DECLARE_TEST_CASE(GET_CLOCK_RATE, ANY) { | ||
85 | + g_assert_cmphex(tag->response.value.clock_id, ==, CLOCK_ID_UNDEFINED); | ||
86 | + g_assert_cmphex(tag->response.value.rate, ==, CLOCK_RATE_ANY); | ||
87 | +} | ||
88 | +DECLARE_TEST_CASE_SETUP(GET_CLOCK_RATE, ANY) { | ||
89 | + tag->request.value.clock_id = CLOCK_ID_UNDEFINED; | ||
90 | +} | ||
91 | + | ||
92 | +/*----------------------------------------------------------------------------*/ | ||
93 | +DECLARE_TEST_CASE(GET_MAX_CLOCK_RATE, ANY) { | ||
94 | + g_assert_cmphex(tag->response.value.clock_id, ==, CLOCK_ID_UNDEFINED); | ||
95 | + g_assert_cmphex(tag->response.value.rate, ==, CLOCK_RATE_ANY); | ||
96 | +} | ||
97 | +DECLARE_TEST_CASE_SETUP(GET_MAX_CLOCK_RATE, ANY) { | ||
98 | + tag->request.value.clock_id = CLOCK_ID_UNDEFINED; | ||
99 | +} | ||
100 | + | ||
101 | +/*----------------------------------------------------------------------------*/ | ||
102 | +DECLARE_TEST_CASE(GET_MIN_CLOCK_RATE, ANY) { | ||
103 | + g_assert_cmphex(tag->response.value.clock_id, ==, CLOCK_ID_UNDEFINED); | ||
104 | + g_assert_cmphex(tag->response.value.rate, ==, CLOCK_RATE_ANY); | ||
105 | +} | ||
106 | +DECLARE_TEST_CASE_SETUP(GET_MIN_CLOCK_RATE, ANY) { | ||
107 | + tag->request.value.clock_id = CLOCK_ID_UNDEFINED; | ||
108 | +} | ||
109 | + | ||
110 | +/*----------------------------------------------------------------------------*/ | ||
111 | +DECLARE_TEST_CASE(GET_TEMPERATURE) { | ||
112 | + g_assert_cmphex(tag->response.value.temperature_id, ==, TEMPERATURE_ID_SOC); | ||
113 | + g_assert_cmpint(tag->response.value.temperature, ==, TEMPERATURE_SOC); | ||
114 | +} | ||
115 | +DECLARE_TEST_CASE_SETUP(GET_TEMPERATURE) { | ||
116 | + tag->request.value.temperature_id = TEMPERATURE_ID_SOC; | ||
117 | +} | ||
118 | + | ||
119 | +/*----------------------------------------------------------------------------*/ | ||
120 | +DECLARE_TEST_CASE(GET_MAX_TEMPERATURE) { | ||
121 | + g_assert_cmphex(tag->response.value.temperature_id, ==, TEMPERATURE_ID_SOC); | ||
122 | + g_assert_cmpint(tag->response.value.temperature, ==, TEMPERATURE_SOC_MAX); | ||
123 | +} | ||
124 | +DECLARE_TEST_CASE_SETUP(GET_MAX_TEMPERATURE) { | ||
125 | + tag->request.value.temperature_id = TEMPERATURE_ID_SOC; | ||
126 | +} | ||
127 | + | ||
128 | +/*----------------------------------------------------------------------------*/ | ||
129 | +DECLARE_TEST_CASE(FRAMEBUFFER_ALLOCATE) { | ||
130 | + g_assert_cmphex(tag->response.value.base, ==, VC_FB_BASE); | ||
131 | + g_assert_cmphex(tag->response.value.size, ==, VC_FB_SIZE); | ||
132 | +} | ||
133 | +DECLARE_TEST_CASE_SETUP(FRAMEBUFFER_ALLOCATE) { | ||
134 | + tag->request.value.alignment = ALIGN_4K; | ||
135 | +} | ||
136 | + | ||
137 | +/*----------------------------------------------------------------------------*/ | ||
138 | +DECLARE_TEST_CASE(FRAMEBUFFER_RELEASE) { | ||
139 | + /* No special checks are needed for this test */ | ||
140 | +} | ||
141 | + | ||
142 | +/*----------------------------------------------------------------------------*/ | ||
143 | +DECLARE_TEST_CASE(FRAMEBUFFER_BLANK) { | ||
144 | + g_assert_cmphex(tag->response.value.on, ==, 0); | ||
145 | +} | ||
146 | +DECLARE_TEST_CASE_SETUP(FRAMEBUFFER_BLANK) { | ||
147 | + tag->request.value.on = 0; | ||
148 | +} | ||
149 | + | ||
150 | +/*----------------------------------------------------------------------------*/ | ||
151 | +DECLARE_TEST_CASE(FRAMEBUFFER_TEST_PHYSICAL_WIDTH_HEIGHT) { | ||
152 | + g_assert_cmpint(tag->response.value.width, ==, DUMMY_VALUE); | ||
153 | + g_assert_cmpint(tag->response.value.height, ==, DUMMY_VALUE); | ||
154 | +} | ||
155 | +DECLARE_TEST_CASE_SETUP(FRAMEBUFFER_TEST_PHYSICAL_WIDTH_HEIGHT) { | ||
156 | + tag->request.value.width = DUMMY_VALUE; | ||
157 | + tag->request.value.height = DUMMY_VALUE; | ||
158 | +} | ||
159 | + | ||
160 | +/*----------------------------------------------------------------------------*/ | ||
161 | +DECLARE_TEST_CASE(FRAMEBUFFER_GET_PHYSICAL_WIDTH_HEIGHT, INITIAL) { | ||
162 | + g_assert_cmpint(tag->response.value.width, ==, 640); | ||
163 | + g_assert_cmpint(tag->response.value.height, ==, 480); | ||
164 | +} | ||
165 | + | ||
166 | +/*----------------------------------------------------------------------------*/ | ||
167 | +DECLARE_TEST_CASE(FRAMEBUFFER_SET_PHYSICAL_WIDTH_HEIGHT) { | ||
168 | + g_assert_cmpint(tag->response.value.width, ==, 800); | ||
169 | + g_assert_cmpint(tag->response.value.height, ==, 600); | ||
170 | +} | ||
171 | +DECLARE_TEST_CASE_SETUP(FRAMEBUFFER_SET_PHYSICAL_WIDTH_HEIGHT) { | ||
172 | + tag->request.value.width = 800; | ||
173 | + tag->request.value.height = 600; | ||
174 | +} | ||
175 | + | ||
176 | +/*----------------------------------------------------------------------------*/ | ||
177 | +DECLARE_TEST_CASE(FRAMEBUFFER_TEST_VIRTUAL_WIDTH_HEIGHT) { | ||
178 | + g_assert_cmpint(tag->response.value.width, ==, DUMMY_VALUE); | ||
179 | + g_assert_cmpint(tag->response.value.height, ==, DUMMY_VALUE); | ||
180 | +} | ||
181 | +DECLARE_TEST_CASE_SETUP(FRAMEBUFFER_TEST_VIRTUAL_WIDTH_HEIGHT) { | ||
182 | + tag->request.value.width = DUMMY_VALUE; | ||
183 | + tag->request.value.height = DUMMY_VALUE; | ||
184 | +} | ||
185 | + | ||
186 | +/*----------------------------------------------------------------------------*/ | ||
187 | +DECLARE_TEST_CASE(FRAMEBUFFER_GET_VIRTUAL_WIDTH_HEIGHT, INITIAL) { | ||
188 | + g_assert_cmpint(tag->response.value.width, ==, 640); | ||
189 | + g_assert_cmpint(tag->response.value.height, ==, 480); | ||
190 | +} | ||
191 | + | ||
192 | +/*----------------------------------------------------------------------------*/ | ||
193 | +DECLARE_TEST_CASE(FRAMEBUFFER_SET_VIRTUAL_WIDTH_HEIGHT) { | ||
194 | + g_assert_cmpint(tag->response.value.width, ==, 800); | ||
195 | + g_assert_cmpint(tag->response.value.height, ==, 600); | ||
196 | +} | ||
197 | +DECLARE_TEST_CASE_SETUP(FRAMEBUFFER_SET_VIRTUAL_WIDTH_HEIGHT) { | ||
198 | + tag->request.value.width = 800; | ||
199 | + tag->request.value.height = 600; | ||
200 | +} | ||
201 | + | ||
202 | /*----------------------------------------------------------------------------*/ | ||
203 | int main(int argc, char **argv) | ||
204 | { | ||
205 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) | ||
206 | QTEST_ADD_TEST_CASE(GET_CLOCK_RATE, EMMC); | ||
207 | QTEST_ADD_TEST_CASE(GET_MAX_CLOCK_RATE, EMMC); | ||
208 | QTEST_ADD_TEST_CASE(GET_MIN_CLOCK_RATE, EMMC); | ||
209 | + QTEST_ADD_TEST_CASE(GET_CLOCK_RATE, UART); | ||
210 | + QTEST_ADD_TEST_CASE(GET_MAX_CLOCK_RATE, UART); | ||
211 | + QTEST_ADD_TEST_CASE(GET_MIN_CLOCK_RATE, UART); | ||
212 | + QTEST_ADD_TEST_CASE(GET_CLOCK_RATE, CORE); | ||
213 | + QTEST_ADD_TEST_CASE(GET_MAX_CLOCK_RATE, CORE); | ||
214 | + QTEST_ADD_TEST_CASE(GET_MIN_CLOCK_RATE, CORE); | ||
215 | + QTEST_ADD_TEST_CASE(GET_CLOCK_RATE, ANY); | ||
216 | + QTEST_ADD_TEST_CASE(GET_MAX_CLOCK_RATE, ANY); | ||
217 | + QTEST_ADD_TEST_CASE(GET_MIN_CLOCK_RATE, ANY); | ||
218 | + QTEST_ADD_TEST_CASE(GET_TEMPERATURE); | ||
219 | + QTEST_ADD_TEST_CASE(GET_MAX_TEMPERATURE); | ||
220 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_ALLOCATE); | ||
221 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_RELEASE); | ||
222 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_BLANK); | ||
223 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_TEST_PHYSICAL_WIDTH_HEIGHT); | ||
224 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_GET_PHYSICAL_WIDTH_HEIGHT, INITIAL); | ||
225 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_SET_PHYSICAL_WIDTH_HEIGHT); | ||
226 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_TEST_VIRTUAL_WIDTH_HEIGHT); | ||
227 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_GET_VIRTUAL_WIDTH_HEIGHT, INITIAL); | ||
228 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_SET_VIRTUAL_WIDTH_HEIGHT); | ||
229 | |||
230 | return g_test_run(); | ||
231 | } | ||
232 | -- | ||
233 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Sergey Kambalin <serg.oker@gmail.com> | ||
2 | 1 | ||
3 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> | ||
4 | Message-id: 20240226000259.2752893-39-sergey.kambalin@auriga.com | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | tests/qtest/bcm2838-mbox-property-test.c | 211 +++++++++++++++++++++++ | ||
9 | 1 file changed, 211 insertions(+) | ||
10 | |||
11 | diff --git a/tests/qtest/bcm2838-mbox-property-test.c b/tests/qtest/bcm2838-mbox-property-test.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/tests/qtest/bcm2838-mbox-property-test.c | ||
14 | +++ b/tests/qtest/bcm2838-mbox-property-test.c | ||
15 | @@ -XXX,XX +XXX,XX @@ DECLARE_TEST_CASE_SETUP(FRAMEBUFFER_SET_VIRTUAL_WIDTH_HEIGHT) { | ||
16 | tag->request.value.height = 600; | ||
17 | } | ||
18 | |||
19 | +/*----------------------------------------------------------------------------*/ | ||
20 | +DECLARE_TEST_CASE(FRAMEBUFFER_TEST_DEPTH) { | ||
21 | + g_assert_cmpint(tag->response.value.bpp, ==, DUMMY_VALUE); | ||
22 | +} | ||
23 | +DECLARE_TEST_CASE_SETUP(FRAMEBUFFER_TEST_DEPTH) { | ||
24 | + tag->request.value.bpp = DUMMY_VALUE; | ||
25 | +} | ||
26 | + | ||
27 | +/*----------------------------------------------------------------------------*/ | ||
28 | +DECLARE_TEST_CASE(FRAMEBUFFER_GET_DEPTH) { | ||
29 | + g_assert_cmpint(tag->response.value.bpp, ==, 16); | ||
30 | +} | ||
31 | + | ||
32 | +/*----------------------------------------------------------------------------*/ | ||
33 | +DECLARE_TEST_CASE(FRAMEBUFFER_SET_DEPTH) { | ||
34 | + g_assert_cmpint(tag->response.value.bpp, ==, 24); | ||
35 | +} | ||
36 | +DECLARE_TEST_CASE_SETUP(FRAMEBUFFER_SET_DEPTH) { | ||
37 | + tag->request.value.bpp = 24; | ||
38 | +} | ||
39 | + | ||
40 | +/*----------------------------------------------------------------------------*/ | ||
41 | +DECLARE_TEST_CASE(FRAMEBUFFER_TEST_PIXEL_ORDER) { | ||
42 | + g_assert_cmphex(tag->response.value.pixel_order, ==, DUMMY_VALUE); | ||
43 | +} | ||
44 | +DECLARE_TEST_CASE_SETUP(FRAMEBUFFER_TEST_PIXEL_ORDER) { | ||
45 | + tag->request.value.pixel_order = DUMMY_VALUE; | ||
46 | +} | ||
47 | + | ||
48 | +/*----------------------------------------------------------------------------*/ | ||
49 | +DECLARE_TEST_CASE(FRAMEBUFFER_GET_PIXEL_ORDER) { | ||
50 | + g_assert_cmphex(tag->response.value.pixel_order, ==, PIXEL_ORDER_RGB); | ||
51 | +} | ||
52 | + | ||
53 | +/*----------------------------------------------------------------------------*/ | ||
54 | +DECLARE_TEST_CASE(FRAMEBUFFER_SET_PIXEL_ORDER, BGR) { | ||
55 | + g_assert_cmphex(tag->response.value.pixel_order, ==, PIXEL_ORDER_BGR); | ||
56 | +} | ||
57 | +DECLARE_TEST_CASE_SETUP(FRAMEBUFFER_SET_PIXEL_ORDER, BGR) { | ||
58 | + tag->request.value.pixel_order = PIXEL_ORDER_BGR; | ||
59 | +} | ||
60 | + | ||
61 | +/*----------------------------------------------------------------------------*/ | ||
62 | +DECLARE_TEST_CASE(FRAMEBUFFER_SET_PIXEL_ORDER, RGB) { | ||
63 | + g_assert_cmphex(tag->response.value.pixel_order, ==, PIXEL_ORDER_BGR); | ||
64 | +} | ||
65 | +DECLARE_TEST_CASE_SETUP(FRAMEBUFFER_SET_PIXEL_ORDER, RGB) { | ||
66 | + tag->request.value.pixel_order = PIXEL_ORDER_BGR; | ||
67 | +} | ||
68 | + | ||
69 | +/*----------------------------------------------------------------------------*/ | ||
70 | +DECLARE_TEST_CASE(FRAMEBUFFER_TEST_ALPHA_MODE) { | ||
71 | + g_assert_cmphex(tag->response.value.alpha_mode, ==, DUMMY_VALUE); | ||
72 | +} | ||
73 | +DECLARE_TEST_CASE_SETUP(FRAMEBUFFER_TEST_ALPHA_MODE) { | ||
74 | + tag->request.value.alpha_mode = DUMMY_VALUE; | ||
75 | +} | ||
76 | + | ||
77 | +/*----------------------------------------------------------------------------*/ | ||
78 | +DECLARE_TEST_CASE(FRAMEBUFFER_GET_ALPHA_MODE) { | ||
79 | + g_assert_cmphex(tag->response.value.alpha_mode, ==, ALPHA_MODE_IGNORED); | ||
80 | +} | ||
81 | + | ||
82 | +/*----------------------------------------------------------------------------*/ | ||
83 | +DECLARE_TEST_CASE(FRAMEBUFFER_SET_ALPHA_MODE, ENABLED) { | ||
84 | + g_assert_cmphex(tag->response.value.alpha_mode, ==, ALPHA_MODE_ENABLED); | ||
85 | +} | ||
86 | +DECLARE_TEST_CASE_SETUP(FRAMEBUFFER_SET_ALPHA_MODE, ENABLED) { | ||
87 | + tag->request.value.alpha_mode = ALPHA_MODE_ENABLED; | ||
88 | +} | ||
89 | + | ||
90 | +/*----------------------------------------------------------------------------*/ | ||
91 | +DECLARE_TEST_CASE(FRAMEBUFFER_SET_ALPHA_MODE, REVERSED) { | ||
92 | + g_assert_cmphex(tag->response.value.alpha_mode, ==, ALPHA_MODE_REVERSED); | ||
93 | +} | ||
94 | +DECLARE_TEST_CASE_SETUP(FRAMEBUFFER_SET_ALPHA_MODE, REVERSED) { | ||
95 | + tag->request.value.alpha_mode = ALPHA_MODE_REVERSED; | ||
96 | +} | ||
97 | + | ||
98 | +/*----------------------------------------------------------------------------*/ | ||
99 | +DECLARE_TEST_CASE(FRAMEBUFFER_SET_ALPHA_MODE, IGNORED) { | ||
100 | + g_assert_cmphex(tag->response.value.alpha_mode, ==, ALPHA_MODE_IGNORED); | ||
101 | +} | ||
102 | +DECLARE_TEST_CASE_SETUP(FRAMEBUFFER_SET_ALPHA_MODE, IGNORED) { | ||
103 | + tag->request.value.alpha_mode = ALPHA_MODE_IGNORED; | ||
104 | +} | ||
105 | + | ||
106 | +/*----------------------------------------------------------------------------*/ | ||
107 | +DECLARE_TEST_CASE(FRAMEBUFFER_GET_PITCH) { | ||
108 | + g_assert_cmpint(tag->response.value.pitch, ==, 1280); | ||
109 | +} | ||
110 | + | ||
111 | +/*----------------------------------------------------------------------------*/ | ||
112 | +DECLARE_TEST_CASE(FRAMEBUFFER_TEST_VIRTUAL_OFFSET) { | ||
113 | + g_assert_cmpint(tag->response.value.x, ==, DUMMY_VALUE); | ||
114 | + g_assert_cmpint(tag->response.value.y, ==, DUMMY_VALUE); | ||
115 | +} | ||
116 | +DECLARE_TEST_CASE_SETUP(FRAMEBUFFER_TEST_VIRTUAL_OFFSET) { | ||
117 | + tag->request.value.x = DUMMY_VALUE; | ||
118 | + tag->request.value.y = DUMMY_VALUE; | ||
119 | +} | ||
120 | + | ||
121 | +/*----------------------------------------------------------------------------*/ | ||
122 | +DECLARE_TEST_CASE(FRAMEBUFFER_GET_VIRTUAL_OFFSET) { | ||
123 | + g_assert_cmpint(tag->response.value.x, ==, 0); | ||
124 | + g_assert_cmpint(tag->response.value.y, ==, 0); | ||
125 | +} | ||
126 | + | ||
127 | +/*----------------------------------------------------------------------------*/ | ||
128 | +DECLARE_TEST_CASE(FRAMEBUFFER_SET_VIRTUAL_OFFSET, _0_) { | ||
129 | + g_assert_cmpint(tag->response.value.x, ==, 0); | ||
130 | + g_assert_cmpint(tag->response.value.y, ==, 0); | ||
131 | +} | ||
132 | +DECLARE_TEST_CASE_SETUP(FRAMEBUFFER_SET_VIRTUAL_OFFSET, _0_) { | ||
133 | + tag->request.value.x = 0; | ||
134 | + tag->request.value.y = 0; | ||
135 | +} | ||
136 | + | ||
137 | +/*----------------------------------------------------------------------------*/ | ||
138 | +DECLARE_TEST_CASE(FRAMEBUFFER_SET_VIRTUAL_OFFSET, _42_) { | ||
139 | + g_assert_cmpint(tag->response.value.x, ==, 42); | ||
140 | + g_assert_cmpint(tag->response.value.y, ==, 42); | ||
141 | +} | ||
142 | +DECLARE_TEST_CASE_SETUP(FRAMEBUFFER_SET_VIRTUAL_OFFSET, _42_) { | ||
143 | + tag->request.value.x = 42; | ||
144 | + tag->request.value.y = 42; | ||
145 | +} | ||
146 | + | ||
147 | +/*----------------------------------------------------------------------------*/ | ||
148 | +DECLARE_TEST_CASE(FRAMEBUFFER_GET_OVERSCAN) { | ||
149 | + g_assert_cmpint(tag->response.value.top, ==, 0); | ||
150 | + g_assert_cmpint(tag->response.value.bottom, ==, 0); | ||
151 | + g_assert_cmpint(tag->response.value.left, ==, 0); | ||
152 | + g_assert_cmpint(tag->response.value.right, ==, 0); | ||
153 | +} | ||
154 | + | ||
155 | +/*----------------------------------------------------------------------------*/ | ||
156 | +DECLARE_TEST_CASE(FRAMEBUFFER_TEST_OVERSCAN) { | ||
157 | + g_assert_cmpint(tag->response.value.top, ==, 0); | ||
158 | + g_assert_cmpint(tag->response.value.bottom, ==, 0); | ||
159 | + g_assert_cmpint(tag->response.value.left, ==, 0); | ||
160 | + g_assert_cmpint(tag->response.value.right, ==, 0); | ||
161 | +} | ||
162 | +DECLARE_TEST_CASE_SETUP(FRAMEBUFFER_TEST_OVERSCAN) { | ||
163 | + tag->request.value.top = DUMMY_VALUE; | ||
164 | + tag->request.value.bottom = DUMMY_VALUE; | ||
165 | + tag->request.value.left = DUMMY_VALUE; | ||
166 | + tag->request.value.right = DUMMY_VALUE; | ||
167 | +} | ||
168 | + | ||
169 | +/*----------------------------------------------------------------------------*/ | ||
170 | +DECLARE_TEST_CASE(FRAMEBUFFER_SET_OVERSCAN) { | ||
171 | + g_assert_cmpint(tag->response.value.top, ==, 0); | ||
172 | + g_assert_cmpint(tag->response.value.bottom, ==, 0); | ||
173 | + g_assert_cmpint(tag->response.value.left, ==, 0); | ||
174 | + g_assert_cmpint(tag->response.value.right, ==, 0); | ||
175 | +} | ||
176 | +DECLARE_TEST_CASE_SETUP(FRAMEBUFFER_SET_OVERSCAN) { | ||
177 | + tag->request.value.top = DUMMY_VALUE; | ||
178 | + tag->request.value.bottom = DUMMY_VALUE; | ||
179 | + tag->request.value.left = DUMMY_VALUE; | ||
180 | + tag->request.value.right = DUMMY_VALUE; | ||
181 | +} | ||
182 | + | ||
183 | +/*----------------------------------------------------------------------------*/ | ||
184 | +DECLARE_TEST_CASE(GET_DMA_CHANNELS) { | ||
185 | + g_assert_cmphex(tag->response.value.mask, ==, GPIO_MASK); | ||
186 | +} | ||
187 | + | ||
188 | +/*----------------------------------------------------------------------------*/ | ||
189 | +DECLARE_TEST_CASE(GET_COMMAND_LINE) { | ||
190 | + /* No special checks are needed for this test case */ | ||
191 | +} | ||
192 | + | ||
193 | +/*----------------------------------------------------------------------------*/ | ||
194 | +DECLARE_TEST_CASE(FRAMEBUFFER_GET_NUM_DISPLAYS) { | ||
195 | + g_assert_cmpint(tag->response.value.num_displays, ==, 1); | ||
196 | +} | ||
197 | + | ||
198 | +/*----------------------------------------------------------------------------*/ | ||
199 | +DECLARE_TEST_CASE(FRAMEBUFFER_SET_PITCH) { | ||
200 | + /* No special checks are needed for this test case */ | ||
201 | +} | ||
202 | +DECLARE_TEST_CASE_SETUP(FRAMEBUFFER_SET_PITCH) { | ||
203 | + tag->request.value.pitch = DUMMY_VALUE; | ||
204 | +} | ||
205 | + | ||
206 | /*----------------------------------------------------------------------------*/ | ||
207 | int main(int argc, char **argv) | ||
208 | { | ||
209 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) | ||
210 | QTEST_ADD_TEST_CASE(FRAMEBUFFER_TEST_VIRTUAL_WIDTH_HEIGHT); | ||
211 | QTEST_ADD_TEST_CASE(FRAMEBUFFER_GET_VIRTUAL_WIDTH_HEIGHT, INITIAL); | ||
212 | QTEST_ADD_TEST_CASE(FRAMEBUFFER_SET_VIRTUAL_WIDTH_HEIGHT); | ||
213 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_TEST_DEPTH); | ||
214 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_GET_DEPTH); | ||
215 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_SET_DEPTH); | ||
216 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_TEST_PIXEL_ORDER); | ||
217 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_GET_PIXEL_ORDER); | ||
218 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_SET_PIXEL_ORDER, BGR); | ||
219 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_SET_PIXEL_ORDER, RGB); | ||
220 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_TEST_ALPHA_MODE); | ||
221 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_GET_ALPHA_MODE); | ||
222 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_SET_ALPHA_MODE, ENABLED); | ||
223 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_SET_ALPHA_MODE, REVERSED); | ||
224 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_SET_ALPHA_MODE, IGNORED); | ||
225 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_GET_PITCH); | ||
226 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_TEST_VIRTUAL_OFFSET); | ||
227 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_GET_VIRTUAL_OFFSET); | ||
228 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_SET_VIRTUAL_OFFSET, _0_); | ||
229 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_SET_VIRTUAL_OFFSET, _42_); | ||
230 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_GET_OVERSCAN); | ||
231 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_TEST_OVERSCAN); | ||
232 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_SET_OVERSCAN); | ||
233 | + QTEST_ADD_TEST_CASE(GET_DMA_CHANNELS); | ||
234 | + QTEST_ADD_TEST_CASE(GET_COMMAND_LINE); | ||
235 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_GET_NUM_DISPLAYS); | ||
236 | + QTEST_ADD_TEST_CASE(FRAMEBUFFER_SET_PITCH); | ||
237 | |||
238 | return g_test_run(); | ||
239 | } | ||
240 | -- | ||
241 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Sergey Kambalin <serg.oker@gmail.com> | ||
2 | 1 | ||
3 | Our model of the bcm2835 mailbox is missing a few properties | ||
4 | that we need for the raspi4 kernel: | ||
5 | * RPI_FWREQ_GET_CLOCKS | ||
6 | * RPI_FWREQ_GET_THROTTLED | ||
7 | * RPI_FWREQ_VCHIQ_INIT | ||
8 | |||
9 | Add minimal implementations of them. | ||
10 | |||
11 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> | ||
12 | Message-id: 20240226000259.2752893-40-sergey.kambalin@auriga.com | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | [PMM: improved commit message] | ||
15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | include/hw/arm/raspberrypi-fw-defs.h | 11 +++++++++++ | ||
18 | hw/misc/bcm2835_property.c | 21 +++++++++++++++++++++ | ||
19 | 2 files changed, 32 insertions(+) | ||
20 | |||
21 | diff --git a/include/hw/arm/raspberrypi-fw-defs.h b/include/hw/arm/raspberrypi-fw-defs.h | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/include/hw/arm/raspberrypi-fw-defs.h | ||
24 | +++ b/include/hw/arm/raspberrypi-fw-defs.h | ||
25 | @@ -XXX,XX +XXX,XX @@ enum rpi_firmware_clk_id { | ||
26 | RPI_FIRMWARE_NUM_CLK_ID, | ||
27 | }; | ||
28 | |||
29 | +struct rpi_firmware_property_tag_header { | ||
30 | + uint32_t tag; | ||
31 | + uint32_t buf_size; | ||
32 | + uint32_t req_resp_size; | ||
33 | +}; | ||
34 | + | ||
35 | +typedef struct rpi_firmware_prop_request { | ||
36 | + struct rpi_firmware_property_tag_header hdr; | ||
37 | + uint8_t payload[0]; | ||
38 | +} rpi_firmware_prop_request_t; | ||
39 | + | ||
40 | #endif /* INCLUDE_HW_MISC_RASPBERRYPI_FW_DEFS_H_ */ | ||
41 | diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/hw/misc/bcm2835_property.c | ||
44 | +++ b/hw/misc/bcm2835_property.c | ||
45 | @@ -XXX,XX +XXX,XX @@ | ||
46 | #include "trace.h" | ||
47 | #include "hw/arm/raspi_platform.h" | ||
48 | |||
49 | +#define VCHI_BUSADDR_SIZE sizeof(uint32_t) | ||
50 | + | ||
51 | /* https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface */ | ||
52 | |||
53 | static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value) | ||
54 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value) | ||
55 | resplen = 8; | ||
56 | break; | ||
57 | |||
58 | + case RPI_FWREQ_GET_CLOCKS: | ||
59 | + /* TODO: add more clock IDs if needed */ | ||
60 | + stl_le_phys(&s->dma_as, value + 12, 0); | ||
61 | + stl_le_phys(&s->dma_as, value + 16, RPI_FIRMWARE_ARM_CLK_ID); | ||
62 | + resplen = 8; | ||
63 | + break; | ||
64 | + | ||
65 | case RPI_FWREQ_SET_CLOCK_RATE: | ||
66 | case RPI_FWREQ_SET_MAX_CLOCK_RATE: | ||
67 | case RPI_FWREQ_SET_MIN_CLOCK_RATE: | ||
68 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value) | ||
69 | stl_le_phys(&s->dma_as, value + 12, 0); | ||
70 | resplen = 4; | ||
71 | break; | ||
72 | + | ||
73 | case RPI_FWREQ_FRAMEBUFFER_GET_NUM_DISPLAYS: | ||
74 | stl_le_phys(&s->dma_as, value + 12, 1); | ||
75 | resplen = 4; | ||
76 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value) | ||
77 | resplen); | ||
78 | break; | ||
79 | |||
80 | + case RPI_FWREQ_GET_THROTTLED: | ||
81 | + stl_le_phys(&s->dma_as, value + 12, 0); | ||
82 | + resplen = 4; | ||
83 | + break; | ||
84 | + | ||
85 | + case RPI_FWREQ_VCHIQ_INIT: | ||
86 | + stl_le_phys(&s->dma_as, | ||
87 | + value + offsetof(rpi_firmware_prop_request_t, payload), | ||
88 | + 0); | ||
89 | + resplen = VCHI_BUSADDR_SIZE; | ||
90 | + break; | ||
91 | default: | ||
92 | qemu_log_mask(LOG_UNIMP, | ||
93 | "bcm2835_property: unhandled tag 0x%08x\n", tag); | ||
94 | -- | ||
95 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Sergey Kambalin <serg.oker@gmail.com> | ||
2 | 1 | ||
3 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> | ||
4 | Message-id: 20240226000259.2752893-41-sergey.kambalin@auriga.com | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | tests/qtest/bcm2838-mbox-property-test.c | 19 +++++++++++++++++++ | ||
9 | 1 file changed, 19 insertions(+) | ||
10 | |||
11 | diff --git a/tests/qtest/bcm2838-mbox-property-test.c b/tests/qtest/bcm2838-mbox-property-test.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/tests/qtest/bcm2838-mbox-property-test.c | ||
14 | +++ b/tests/qtest/bcm2838-mbox-property-test.c | ||
15 | @@ -XXX,XX +XXX,XX @@ DECLARE_TEST_CASE_SETUP(GET_MIN_CLOCK_RATE, ANY) { | ||
16 | tag->request.value.clock_id = CLOCK_ID_UNDEFINED; | ||
17 | } | ||
18 | |||
19 | +/*----------------------------------------------------------------------------*/ | ||
20 | +DECLARE_TEST_CASE(GET_CLOCKS) { | ||
21 | + g_assert_cmphex(tag->response.value.root_clock, ==, CLOCK_ID_ROOT); | ||
22 | + g_assert_cmphex(tag->response.value.arm_clock, ==, CLOCK_ID_ARM); | ||
23 | +} | ||
24 | + | ||
25 | /*----------------------------------------------------------------------------*/ | ||
26 | DECLARE_TEST_CASE(GET_TEMPERATURE) { | ||
27 | g_assert_cmphex(tag->response.value.temperature_id, ==, TEMPERATURE_ID_SOC); | ||
28 | @@ -XXX,XX +XXX,XX @@ DECLARE_TEST_CASE(GET_COMMAND_LINE) { | ||
29 | /* No special checks are needed for this test case */ | ||
30 | } | ||
31 | |||
32 | +/*----------------------------------------------------------------------------*/ | ||
33 | +DECLARE_TEST_CASE(GET_THROTTLED) { | ||
34 | + g_assert_cmpint(tag->response.value.throttled, ==, 0); | ||
35 | +} | ||
36 | + | ||
37 | /*----------------------------------------------------------------------------*/ | ||
38 | DECLARE_TEST_CASE(FRAMEBUFFER_GET_NUM_DISPLAYS) { | ||
39 | g_assert_cmpint(tag->response.value.num_displays, ==, 1); | ||
40 | @@ -XXX,XX +XXX,XX @@ DECLARE_TEST_CASE_SETUP(FRAMEBUFFER_SET_PITCH) { | ||
41 | tag->request.value.pitch = DUMMY_VALUE; | ||
42 | } | ||
43 | |||
44 | +/*----------------------------------------------------------------------------*/ | ||
45 | +DECLARE_TEST_CASE(VCHIQ_INIT) { | ||
46 | + g_assert_cmpint(tag->response.value.zero, ==, 0); | ||
47 | +} | ||
48 | + | ||
49 | /*----------------------------------------------------------------------------*/ | ||
50 | int main(int argc, char **argv) | ||
51 | { | ||
52 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) | ||
53 | QTEST_ADD_TEST_CASE(GET_CLOCK_RATE, ANY); | ||
54 | QTEST_ADD_TEST_CASE(GET_MAX_CLOCK_RATE, ANY); | ||
55 | QTEST_ADD_TEST_CASE(GET_MIN_CLOCK_RATE, ANY); | ||
56 | + QTEST_ADD_TEST_CASE(GET_CLOCKS); | ||
57 | QTEST_ADD_TEST_CASE(GET_TEMPERATURE); | ||
58 | QTEST_ADD_TEST_CASE(GET_MAX_TEMPERATURE); | ||
59 | QTEST_ADD_TEST_CASE(FRAMEBUFFER_ALLOCATE); | ||
60 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) | ||
61 | QTEST_ADD_TEST_CASE(GET_COMMAND_LINE); | ||
62 | QTEST_ADD_TEST_CASE(FRAMEBUFFER_GET_NUM_DISPLAYS); | ||
63 | QTEST_ADD_TEST_CASE(FRAMEBUFFER_SET_PITCH); | ||
64 | + QTEST_ADD_TEST_CASE(GET_THROTTLED); | ||
65 | + QTEST_ADD_TEST_CASE(VCHIQ_INIT); | ||
66 | |||
67 | return g_test_run(); | ||
68 | } | ||
69 | -- | ||
70 | 2.34.1 | diff view generated by jsdifflib |