1 | The following changes since commit ec397e90d21269037280633b6058d1f280e27667: | 1 | target-arm queue: mostly aspeed changes from Cédric. |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/alistair/tags/pull-riscv-to-apply-20210901-2' into staging (2021-09-01 08:33:02 +0100) | 3 | thanks |
4 | -- PMM | ||
5 | |||
6 | The following changes since commit 85182c96de61f0b600bbe834d5a23e713162e892: | ||
7 | |||
8 | Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20190912a' into staging (2019-09-13 14:37:48 +0100) | ||
4 | 9 | ||
5 | are available in the Git repository at: | 10 | are available in the Git repository at: |
6 | 11 | ||
7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210901 | 12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190913 |
8 | 13 | ||
9 | for you to fetch changes up to 683754c7b61f9e2ff098720ec80c9ab86c54663d: | 14 | for you to fetch changes up to 27a296fce9821e3608d537756cffa6e43a46df3b: |
10 | 15 | ||
11 | arm: Remove system_clock_scale global (2021-09-01 11:08:21 +0100) | 16 | qemu-ga: Convert invocation documentation to rST (2019-09-13 16:05:01 +0100) |
12 | 17 | ||
13 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
14 | * Refactor M-profile systick to use Clocks instead of system_clock_scale global | 19 | target-arm queue: |
15 | * clock: Provide builtin multiplier/divider | 20 | * aspeed: add a GPIO controller to the SoC |
16 | * Add A64FX processor model | 21 | * aspeed: Various refactorings |
17 | * Enable MVE emulation in Cortex-M55 | 22 | * aspeed: Improve DMA controller modelling |
18 | * hw: Add compat machines for 6.2 | 23 | * atomic_template: fix indentation in GEN_ATOMIC_HELPER |
19 | * hw/intc/arm_gicv3: Replace mis-used MEMTX_* constants by booleans | 24 | * qemu-ga: Convert invocation documentation to rST |
20 | * hw/arm/raspi: Remove deprecated raspi2/raspi3 aliases | ||
21 | 25 | ||
22 | ---------------------------------------------------------------- | 26 | ---------------------------------------------------------------- |
23 | Peter Maydell (43): | 27 | Christian Svensson (1): |
24 | target/arm: Implement MVE VADD (floating-point) | 28 | aspeed/smc: Calculate checksum on normal DMA |
25 | target/arm: Implement MVE VSUB, VMUL, VABD, VMAXNM, VMINNM | ||
26 | target/arm: Implement MVE VCADD | ||
27 | target/arm: Implement MVE VFMA and VFMS | ||
28 | target/arm: Implement MVE VCMUL and VCMLA | ||
29 | target/arm: Implement MVE VMAXNMA and VMINNMA | ||
30 | target/arm: Implement MVE scalar fp insns | ||
31 | target/arm: Implement MVE fp-with-scalar VFMA, VFMAS | ||
32 | softfloat: Remove assertion preventing silencing of NaN in default-NaN mode | ||
33 | target/arm: Implement MVE FP max/min across vector | ||
34 | target/arm: Implement MVE fp vector comparisons | ||
35 | target/arm: Implement MVE fp scalar comparisons | ||
36 | target/arm: Implement MVE VCVT between floating and fixed point | ||
37 | target/arm: Implement MVE VCVT between fp and integer | ||
38 | target/arm: Implement MVE VCVT with specified rounding mode | ||
39 | target/arm: Implement MVE VCVT between single and half precision | ||
40 | target/arm: Implement MVE VRINT insns | ||
41 | target/arm: Enable MVE in Cortex-M55 | ||
42 | arm: Move M-profile RAS register block into its own device | ||
43 | arm: Move systick device creation from NVIC to ARMv7M object | ||
44 | arm: Move system PPB container handling to armv7m | ||
45 | hw/timer/armv7m_systick: Add usual QEMU interface comment | ||
46 | hw/timer/armv7m_systick: Add input clocks | ||
47 | hw/arm/armv7m: Create input clocks | ||
48 | armsse: Wire up systick cpuclk clock | ||
49 | hw/arm/mps2.c: Connect up armv7m clocks | ||
50 | clock: Provide builtin multiplier/divider | ||
51 | hw/arm: Don't allocate separate MemoryRegions in stm32 SoC realize | ||
52 | hw/arm/stm32f100: Wire up sysclk and refclk | ||
53 | hw/arm/stm32f205: Wire up sysclk and refclk | ||
54 | hw/arm/stm32f405: Wire up sysclk and refclk | ||
55 | hw/arm/stm32vldiscovery: Delete trailing blank line | ||
56 | hw/arm/nrf51: Wire up sysclk | ||
57 | hw/arm/stellaris: split stellaris_sys_init() | ||
58 | hw/arm/stellaris: Wire sysclk up to armv7m | ||
59 | hw/arm/msf2_soc: Don't allocate separate MemoryRegions | ||
60 | hw/arm/msf2: Use Clock input to MSF2_SOC instead of m3clk property | ||
61 | hw/arm/msf2-soc: Wire up refclk | ||
62 | hw/timer/armv7m_systick: Use clock inputs instead of system_clock_scale | ||
63 | hw/arm/stellaris: Fix code style issues in GPTM code | ||
64 | hw/arm/stellaris: Split stellaris-gptm into its own file | ||
65 | hw/timer/stellaris-gptm: Use Clock input instead of system_clock_scale | ||
66 | arm: Remove system_clock_scale global | ||
67 | 29 | ||
68 | Philippe Mathieu-Daudé (4): | 30 | Cédric Le Goater (7): |
69 | tests: Remove uses of deprecated raspi2/raspi3 machine names | 31 | aspeed: Remove unused SoC definitions |
70 | hw/arm/raspi: Remove deprecated raspi2/raspi3 aliases | 32 | aspeed: Use consistent typenames |
71 | hw/intc/arm_gicv3_dist: Rename 64-bit accessors with 'q' suffix | 33 | aspeed/smc: Add support for DMAs |
72 | hw/intc/arm_gicv3: Replace mis-used MEMTX_* constants by booleans | 34 | aspeed/smc: Add DMA calibration settings |
35 | aspeed/smc: Inject errors in DMA checksum | ||
36 | aspeed/scu: Introduce per-SoC SCU types | ||
37 | aspeed/scu: Introduce a aspeed_scu_get_apb_freq() routine | ||
73 | 38 | ||
74 | Shuuichirou Ishii (3): | 39 | Emilio G. Cota (1): |
75 | target-arm: Add support for Fujitsu A64FX | 40 | atomic_template: fix indentation in GEN_ATOMIC_HELPER |
76 | hw/arm/virt: target-arm: Add A64FX processor support to virt machine | ||
77 | tests/arm-cpu-features: Add A64FX processor related tests | ||
78 | 41 | ||
79 | Yanan Wang (1): | 42 | Peter Maydell (1): |
80 | hw: Add compat machines for 6.2 | 43 | qemu-ga: Convert invocation documentation to rST |
81 | 44 | ||
82 | docs/about/deprecated.rst | 7 - | 45 | Rashmica Gupta (2): |
83 | docs/about/removed-features.rst | 7 + | 46 | hw/gpio: Add basic Aspeed GPIO model for AST2400 and AST2500 |
84 | docs/devel/clocks.rst | 23 ++ | 47 | aspeed: add a GPIO controller to the SoC |
85 | docs/devel/qgraph.rst | 38 +- | ||
86 | docs/system/arm/virt.rst | 1 + | ||
87 | include/hw/arm/armv7m.h | 24 ++ | ||
88 | include/hw/arm/msf2-soc.h | 8 +- | ||
89 | include/hw/arm/nrf51_soc.h | 2 + | ||
90 | include/hw/arm/stm32f100_soc.h | 8 + | ||
91 | include/hw/arm/stm32f205_soc.h | 8 + | ||
92 | include/hw/arm/stm32f405_soc.h | 3 + | ||
93 | include/hw/boards.h | 3 + | ||
94 | include/hw/clock.h | 29 ++ | ||
95 | include/hw/i386/pc.h | 3 + | ||
96 | include/hw/intc/armv7m_nvic.h | 8 - | ||
97 | include/hw/misc/armv7m_ras.h | 37 ++ | ||
98 | include/hw/timer/armv7m_systick.h | 36 +- | ||
99 | include/hw/timer/stellaris-gptm.h | 51 +++ | ||
100 | target/arm/helper-mve.h | 142 +++++++ | ||
101 | target/arm/translate.h | 6 + | ||
102 | tests/qtest/libqos/qgraph.h | 6 +- | ||
103 | tests/qtest/libqos/qgraph_internal.h | 2 +- | ||
104 | target/arm/mve.decode | 297 +++++++++++++-- | ||
105 | hw/arm/armsse.c | 20 +- | ||
106 | hw/arm/armv7m.c | 260 ++++++++++++- | ||
107 | hw/arm/mps2.c | 17 +- | ||
108 | hw/arm/msf2-soc.c | 68 ++-- | ||
109 | hw/arm/msf2-som.c | 7 +- | ||
110 | hw/arm/netduino2.c | 12 +- | ||
111 | hw/arm/netduinoplus2.c | 12 +- | ||
112 | hw/arm/nrf51_soc.c | 20 +- | ||
113 | hw/arm/raspi.c | 2 - | ||
114 | hw/arm/stellaris.c | 396 +++---------------- | ||
115 | hw/arm/stm32f100_soc.c | 47 ++- | ||
116 | hw/arm/stm32f205_soc.c | 47 ++- | ||
117 | hw/arm/stm32f405_soc.c | 30 ++ | ||
118 | hw/arm/stm32vldiscovery.c | 13 +- | ||
119 | hw/arm/virt.c | 12 +- | ||
120 | hw/core/clock-vmstate.c | 40 +- | ||
121 | hw/core/clock.c | 31 +- | ||
122 | hw/core/machine.c | 3 + | ||
123 | hw/i386/pc.c | 3 + | ||
124 | hw/i386/pc_piix.c | 14 +- | ||
125 | hw/i386/pc_q35.c | 13 +- | ||
126 | hw/intc/arm_gicv3_dist.c | 205 +++++----- | ||
127 | hw/intc/armv7m_nvic.c | 274 +------------- | ||
128 | hw/misc/armv7m_ras.c | 93 +++++ | ||
129 | hw/ppc/spapr.c | 17 +- | ||
130 | hw/s390x/s390-virtio-ccw.c | 14 +- | ||
131 | hw/timer/armv7m_systick.c | 118 ++++-- | ||
132 | hw/timer/stellaris-gptm.c | 332 ++++++++++++++++ | ||
133 | target/arm/cpu64.c | 48 +++ | ||
134 | target/arm/cpu_tcg.c | 7 +- | ||
135 | target/arm/mve_helper.c | 650 ++++++++++++++++++++++++++++++++ | ||
136 | target/arm/translate-mve.c | 277 +++++++++++++- | ||
137 | target/arm/translate-neon.c | 6 - | ||
138 | tests/qtest/arm-cpu-features.c | 13 + | ||
139 | tests/qtest/boot-serial-test.c | 2 +- | ||
140 | tests/qtest/libqos/arm-raspi2-machine.c | 8 +- | ||
141 | tests/unit/test-qgraph.c | 2 +- | ||
142 | fpu/softfloat-specialize.c.inc | 1 - | ||
143 | MAINTAINERS | 2 + | ||
144 | hw/arm/Kconfig | 1 + | ||
145 | hw/core/trace-events | 1 + | ||
146 | hw/misc/meson.build | 2 + | ||
147 | hw/timer/Kconfig | 3 + | ||
148 | hw/timer/meson.build | 1 + | ||
149 | tests/acceptance/boot_linux_console.py | 6 +- | ||
150 | 68 files changed, 2928 insertions(+), 971 deletions(-) | ||
151 | create mode 100644 include/hw/misc/armv7m_ras.h | ||
152 | create mode 100644 include/hw/timer/stellaris-gptm.h | ||
153 | create mode 100644 hw/misc/armv7m_ras.c | ||
154 | create mode 100644 hw/timer/stellaris-gptm.c | ||
155 | 48 | ||
49 | Makefile | 24 +- | ||
50 | hw/gpio/Makefile.objs | 1 + | ||
51 | accel/tcg/atomic_template.h | 2 +- | ||
52 | include/hw/arm/aspeed_soc.h | 4 +- | ||
53 | include/hw/gpio/aspeed_gpio.h | 100 +++++ | ||
54 | include/hw/misc/aspeed_scu.h | 21 +- | ||
55 | include/hw/ssi/aspeed_smc.h | 7 + | ||
56 | hw/arm/aspeed.c | 2 + | ||
57 | hw/arm/aspeed_soc.c | 63 ++- | ||
58 | hw/gpio/aspeed_gpio.c | 884 ++++++++++++++++++++++++++++++++++++++++++ | ||
59 | hw/misc/aspeed_scu.c | 102 ++--- | ||
60 | hw/ssi/aspeed_smc.c | 335 +++++++++++++++- | ||
61 | hw/timer/aspeed_timer.c | 3 +- | ||
62 | MAINTAINERS | 2 +- | ||
63 | docs/conf.py | 18 +- | ||
64 | docs/interop/conf.py | 7 + | ||
65 | docs/interop/index.rst | 1 + | ||
66 | docs/interop/qemu-ga.rst | 133 +++++++ | ||
67 | qemu-doc.texi | 5 - | ||
68 | qemu-ga.texi | 137 ------- | ||
69 | 20 files changed, 1585 insertions(+), 266 deletions(-) | ||
70 | create mode 100644 include/hw/gpio/aspeed_gpio.h | ||
71 | create mode 100644 hw/gpio/aspeed_gpio.c | ||
72 | create mode 100644 docs/interop/qemu-ga.rst | ||
73 | delete mode 100644 qemu-ga.texi | ||
74 | diff view generated by jsdifflib |
1 | Currently we implement the RAS register block within the NVIC device. | 1 | From: Rashmica Gupta <rashmica.g@gmail.com> |
---|---|---|---|
2 | It isn't really very tightly coupled with the NVIC proper, so instead | ||
3 | move it out into a sysbus device of its own and have the top level | ||
4 | ARMv7M container create it and map it into memory at the right | ||
5 | address. | ||
6 | 2 | ||
3 | GPIO pins are arranged in groups of 8 pins labeled A,B,..,Y,Z,AA,AB,AC. | ||
4 | (Note that the ast2400 controller only goes up to group AB). | ||
5 | A set has four groups (except set AC which only has one) and is | ||
6 | referred to by the groups it is composed of (eg ABCD,EFGH,...,YZAAAB). | ||
7 | Each set is accessed and controlled by a bank of 14 registers. | ||
8 | |||
9 | These registers operate on a per pin level where each bit in the register | ||
10 | corresponds to a pin, except for the command source registers. The command | ||
11 | source registers operate on a per group level where bits 24, 16, 8 and 0 | ||
12 | correspond to each group in the set. | ||
13 | |||
14 | eg. registers for set ABCD: | ||
15 | |D7...D0|C7...C0|B7...B0|A7...A0| <- GPIOs | ||
16 | |31...24|23...16|15....8|7.....0| <- bit position | ||
17 | |||
18 | Note that there are a couple of groups that only have 4 pins. | ||
19 | |||
20 | There are two ways that this model deviates from the behaviour of the | ||
21 | actual controller: | ||
22 | (1) The only control source driving the GPIO pins in the model is the ARM | ||
23 | model (as there currently aren't models for the LPC or Coprocessor). | ||
24 | |||
25 | (2) None of the registers in the model are reset tolerant (needs | ||
26 | integration with the watchdog). | ||
27 | |||
28 | Signed-off-by: Rashmica Gupta <rashmica.g@gmail.com> | ||
29 | Tested-by: Andrew Jeffery <andrew@aj.id.au> | ||
30 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
31 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
32 | Message-id: 20190904070506.1052-2-clg@kaod.org | ||
33 | [clg: fixed missing header files | ||
34 | made use of HWADDR_PRIx to fix compilation on windows ] | ||
35 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 36 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Alexandre Iooss <erdnaxe@crans.org> | ||
9 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
10 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
11 | Reviewed-by: Damien Hedde <damien.hedde@greensocs.com> | ||
12 | Message-id: 20210812093356.1946-2-peter.maydell@linaro.org | ||
13 | --- | 37 | --- |
14 | include/hw/arm/armv7m.h | 2 + | 38 | hw/gpio/Makefile.objs | 1 + |
15 | include/hw/intc/armv7m_nvic.h | 1 - | 39 | include/hw/gpio/aspeed_gpio.h | 100 ++++ |
16 | include/hw/misc/armv7m_ras.h | 37 ++++++++++++++ | 40 | hw/gpio/aspeed_gpio.c | 884 ++++++++++++++++++++++++++++++++++ |
17 | hw/arm/armv7m.c | 12 +++++ | 41 | 3 files changed, 985 insertions(+) |
18 | hw/intc/armv7m_nvic.c | 56 --------------------- | 42 | create mode 100644 include/hw/gpio/aspeed_gpio.h |
19 | hw/misc/armv7m_ras.c | 93 +++++++++++++++++++++++++++++++++++ | 43 | create mode 100644 hw/gpio/aspeed_gpio.c |
20 | MAINTAINERS | 2 + | ||
21 | hw/misc/meson.build | 2 + | ||
22 | 8 files changed, 148 insertions(+), 57 deletions(-) | ||
23 | create mode 100644 include/hw/misc/armv7m_ras.h | ||
24 | create mode 100644 hw/misc/armv7m_ras.c | ||
25 | 44 | ||
26 | diff --git a/include/hw/arm/armv7m.h b/include/hw/arm/armv7m.h | 45 | diff --git a/hw/gpio/Makefile.objs b/hw/gpio/Makefile.objs |
27 | index XXXXXXX..XXXXXXX 100644 | 46 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/include/hw/arm/armv7m.h | 47 | --- a/hw/gpio/Makefile.objs |
29 | +++ b/include/hw/arm/armv7m.h | 48 | +++ b/hw/gpio/Makefile.objs |
30 | @@ -XXX,XX +XXX,XX @@ | 49 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_OMAP) += omap_gpio.o |
31 | 50 | obj-$(CONFIG_IMX) += imx_gpio.o | |
32 | #include "hw/sysbus.h" | 51 | obj-$(CONFIG_RASPI) += bcm2835_gpio.o |
33 | #include "hw/intc/armv7m_nvic.h" | 52 | obj-$(CONFIG_NRF51_SOC) += nrf51_gpio.o |
34 | +#include "hw/misc/armv7m_ras.h" | 53 | +obj-$(CONFIG_ASPEED_SOC) += aspeed_gpio.o |
35 | #include "target/arm/idau.h" | 54 | diff --git a/include/hw/gpio/aspeed_gpio.h b/include/hw/gpio/aspeed_gpio.h |
36 | #include "qom/object.h" | ||
37 | |||
38 | @@ -XXX,XX +XXX,XX @@ struct ARMv7MState { | ||
39 | NVICState nvic; | ||
40 | BitBandState bitband[ARMV7M_NUM_BITBANDS]; | ||
41 | ARMCPU *cpu; | ||
42 | + ARMv7MRAS ras; | ||
43 | |||
44 | /* MemoryRegion we pass to the CPU, with our devices layered on | ||
45 | * top of the ones the board provides in board_memory. | ||
46 | diff --git a/include/hw/intc/armv7m_nvic.h b/include/hw/intc/armv7m_nvic.h | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/include/hw/intc/armv7m_nvic.h | ||
49 | +++ b/include/hw/intc/armv7m_nvic.h | ||
50 | @@ -XXX,XX +XXX,XX @@ struct NVICState { | ||
51 | MemoryRegion sysreg_ns_mem; | ||
52 | MemoryRegion systickmem; | ||
53 | MemoryRegion systick_ns_mem; | ||
54 | - MemoryRegion ras_mem; | ||
55 | MemoryRegion container; | ||
56 | MemoryRegion defaultmem; | ||
57 | |||
58 | diff --git a/include/hw/misc/armv7m_ras.h b/include/hw/misc/armv7m_ras.h | ||
59 | new file mode 100644 | 55 | new file mode 100644 |
60 | index XXXXXXX..XXXXXXX | 56 | index XXXXXXX..XXXXXXX |
61 | --- /dev/null | 57 | --- /dev/null |
62 | +++ b/include/hw/misc/armv7m_ras.h | 58 | +++ b/include/hw/gpio/aspeed_gpio.h |
63 | @@ -XXX,XX +XXX,XX @@ | 59 | @@ -XXX,XX +XXX,XX @@ |
64 | +/* | 60 | +/* |
65 | + * Arm M-profile RAS (Reliability, Availability and Serviceability) block | 61 | + * ASPEED GPIO Controller |
66 | + * | 62 | + * |
67 | + * Copyright (c) 2021 Linaro Limited | 63 | + * Copyright (C) 2017-2018 IBM Corp. |
68 | + * | 64 | + * |
69 | + * This program is free software; you can redistribute it and/or modify | 65 | + * This code is licensed under the GPL version 2 or later. See |
70 | + * it under the terms of the GNU General Public License version 2 or | 66 | + * the COPYING file in the top-level directory. |
71 | + * (at your option) any later version. | ||
72 | + */ | 67 | + */ |
73 | + | 68 | + |
74 | +/* | 69 | +#ifndef ASPEED_GPIO_H |
75 | + * This is a model of the RAS register block of an M-profile CPU | 70 | +#define ASPEED_GPIO_H |
76 | + * (the registers starting at 0xE0005000 with ERRFRn). | ||
77 | + * | ||
78 | + * QEMU interface: | ||
79 | + * + sysbus MMIO region 0: the register bank | ||
80 | + * | ||
81 | + * The QEMU implementation currently provides "minimal RAS" only. | ||
82 | + */ | ||
83 | + | ||
84 | +#ifndef HW_MISC_ARMV7M_RAS_H | ||
85 | +#define HW_MISC_ARMV7M_RAS_H | ||
86 | + | 71 | + |
87 | +#include "hw/sysbus.h" | 72 | +#include "hw/sysbus.h" |
88 | + | 73 | + |
89 | +#define TYPE_ARMV7M_RAS "armv7m-ras" | 74 | +#define TYPE_ASPEED_GPIO "aspeed.gpio" |
90 | +OBJECT_DECLARE_SIMPLE_TYPE(ARMv7MRAS, ARMV7M_RAS) | 75 | +#define ASPEED_GPIO(obj) OBJECT_CHECK(AspeedGPIOState, (obj), TYPE_ASPEED_GPIO) |
91 | + | 76 | +#define ASPEED_GPIO_CLASS(klass) \ |
92 | +struct ARMv7MRAS { | 77 | + OBJECT_CLASS_CHECK(AspeedGPIOClass, (klass), TYPE_ASPEED_GPIO) |
93 | + /*< private >*/ | 78 | +#define ASPEED_GPIO_GET_CLASS(obj) \ |
79 | + OBJECT_GET_CLASS(AspeedGPIOClass, (obj), TYPE_ASPEED_GPIO) | ||
80 | + | ||
81 | +#define ASPEED_GPIO_MAX_NR_SETS 8 | ||
82 | +#define ASPEED_REGS_PER_BANK 14 | ||
83 | +#define ASPEED_GPIO_MAX_NR_REGS (ASPEED_REGS_PER_BANK * ASPEED_GPIO_MAX_NR_SETS) | ||
84 | +#define ASPEED_GPIO_NR_PINS 228 | ||
85 | +#define ASPEED_GROUPS_PER_SET 4 | ||
86 | +#define ASPEED_GPIO_NR_DEBOUNCE_REGS 3 | ||
87 | +#define ASPEED_CHARS_PER_GROUP_LABEL 4 | ||
88 | + | ||
89 | +typedef struct GPIOSets GPIOSets; | ||
90 | + | ||
91 | +typedef struct GPIOSetProperties { | ||
92 | + uint32_t input; | ||
93 | + uint32_t output; | ||
94 | + char group_label[ASPEED_GROUPS_PER_SET][ASPEED_CHARS_PER_GROUP_LABEL]; | ||
95 | +} GPIOSetProperties; | ||
96 | + | ||
97 | +enum GPIORegType { | ||
98 | + gpio_not_a_reg, | ||
99 | + gpio_reg_data_value, | ||
100 | + gpio_reg_direction, | ||
101 | + gpio_reg_int_enable, | ||
102 | + gpio_reg_int_sens_0, | ||
103 | + gpio_reg_int_sens_1, | ||
104 | + gpio_reg_int_sens_2, | ||
105 | + gpio_reg_int_status, | ||
106 | + gpio_reg_reset_tolerant, | ||
107 | + gpio_reg_debounce_1, | ||
108 | + gpio_reg_debounce_2, | ||
109 | + gpio_reg_cmd_source_0, | ||
110 | + gpio_reg_cmd_source_1, | ||
111 | + gpio_reg_data_read, | ||
112 | + gpio_reg_input_mask, | ||
113 | +}; | ||
114 | + | ||
115 | +typedef struct AspeedGPIOReg { | ||
116 | + uint16_t set_idx; | ||
117 | + enum GPIORegType type; | ||
118 | + } AspeedGPIOReg; | ||
119 | + | ||
120 | +typedef struct AspeedGPIOClass { | ||
94 | + SysBusDevice parent_obj; | 121 | + SysBusDevice parent_obj; |
122 | + const GPIOSetProperties *props; | ||
123 | + uint32_t nr_gpio_pins; | ||
124 | + uint32_t nr_gpio_sets; | ||
125 | + uint32_t gap; | ||
126 | + const AspeedGPIOReg *reg_table; | ||
127 | +} AspeedGPIOClass; | ||
128 | + | ||
129 | +typedef struct AspeedGPIOState { | ||
130 | + /* <private> */ | ||
131 | + SysBusDevice parent; | ||
95 | + | 132 | + |
96 | + /*< public >*/ | 133 | + /*< public >*/ |
97 | + MemoryRegion iomem; | 134 | + MemoryRegion iomem; |
98 | +}; | 135 | + int pending; |
99 | + | 136 | + qemu_irq irq; |
100 | +#endif | 137 | + qemu_irq gpios[ASPEED_GPIO_NR_PINS]; |
101 | diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c | 138 | + |
102 | index XXXXXXX..XXXXXXX 100644 | 139 | +/* Parallel GPIO Registers */ |
103 | --- a/hw/arm/armv7m.c | 140 | + uint32_t debounce_regs[ASPEED_GPIO_NR_DEBOUNCE_REGS]; |
104 | +++ b/hw/arm/armv7m.c | 141 | + struct GPIOSets { |
105 | @@ -XXX,XX +XXX,XX @@ static void armv7m_realize(DeviceState *dev, Error **errp) | 142 | + uint32_t data_value; /* Reflects pin values */ |
106 | memory_region_add_subregion(&s->container, 0xe0000000, | 143 | + uint32_t data_read; /* Contains last value written to data value */ |
107 | sysbus_mmio_get_region(sbd, 0)); | 144 | + uint32_t direction; |
108 | 145 | + uint32_t int_enable; | |
109 | + /* If the CPU has RAS support, create the RAS register block */ | 146 | + uint32_t int_sens_0; |
110 | + if (cpu_isar_feature(aa32_ras, s->cpu)) { | 147 | + uint32_t int_sens_1; |
111 | + object_initialize_child(OBJECT(dev), "armv7m-ras", | 148 | + uint32_t int_sens_2; |
112 | + &s->ras, TYPE_ARMV7M_RAS); | 149 | + uint32_t int_status; |
113 | + sbd = SYS_BUS_DEVICE(&s->ras); | 150 | + uint32_t reset_tol; |
114 | + if (!sysbus_realize(sbd, errp)) { | 151 | + uint32_t cmd_source_0; |
115 | + return; | 152 | + uint32_t cmd_source_1; |
116 | + } | 153 | + uint32_t debounce_1; |
117 | + memory_region_add_subregion_overlap(&s->container, 0xe0005000, | 154 | + uint32_t debounce_2; |
118 | + sysbus_mmio_get_region(sbd, 0), 1); | 155 | + uint32_t input_mask; |
119 | + } | 156 | + } sets[ASPEED_GPIO_MAX_NR_SETS]; |
120 | + | 157 | +} AspeedGPIOState; |
121 | for (i = 0; i < ARRAY_SIZE(s->bitband); i++) { | 158 | + |
122 | if (s->enable_bitband) { | 159 | +#endif /* _ASPEED_GPIO_H_ */ |
123 | Object *obj = OBJECT(&s->bitband[i]); | 160 | diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c |
124 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
125 | index XXXXXXX..XXXXXXX 100644 | ||
126 | --- a/hw/intc/armv7m_nvic.c | ||
127 | +++ b/hw/intc/armv7m_nvic.c | ||
128 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps nvic_systick_ops = { | ||
129 | .endianness = DEVICE_NATIVE_ENDIAN, | ||
130 | }; | ||
131 | |||
132 | - | ||
133 | -static MemTxResult ras_read(void *opaque, hwaddr addr, | ||
134 | - uint64_t *data, unsigned size, | ||
135 | - MemTxAttrs attrs) | ||
136 | -{ | ||
137 | - if (attrs.user) { | ||
138 | - return MEMTX_ERROR; | ||
139 | - } | ||
140 | - | ||
141 | - switch (addr) { | ||
142 | - case 0xe10: /* ERRIIDR */ | ||
143 | - /* architect field = Arm; product/variant/revision 0 */ | ||
144 | - *data = 0x43b; | ||
145 | - break; | ||
146 | - case 0xfc8: /* ERRDEVID */ | ||
147 | - /* Minimal RAS: we implement 0 error record indexes */ | ||
148 | - *data = 0; | ||
149 | - break; | ||
150 | - default: | ||
151 | - qemu_log_mask(LOG_UNIMP, "Read RAS register offset 0x%x\n", | ||
152 | - (uint32_t)addr); | ||
153 | - *data = 0; | ||
154 | - break; | ||
155 | - } | ||
156 | - return MEMTX_OK; | ||
157 | -} | ||
158 | - | ||
159 | -static MemTxResult ras_write(void *opaque, hwaddr addr, | ||
160 | - uint64_t value, unsigned size, | ||
161 | - MemTxAttrs attrs) | ||
162 | -{ | ||
163 | - if (attrs.user) { | ||
164 | - return MEMTX_ERROR; | ||
165 | - } | ||
166 | - | ||
167 | - switch (addr) { | ||
168 | - default: | ||
169 | - qemu_log_mask(LOG_UNIMP, "Write to RAS register offset 0x%x\n", | ||
170 | - (uint32_t)addr); | ||
171 | - break; | ||
172 | - } | ||
173 | - return MEMTX_OK; | ||
174 | -} | ||
175 | - | ||
176 | -static const MemoryRegionOps ras_ops = { | ||
177 | - .read_with_attrs = ras_read, | ||
178 | - .write_with_attrs = ras_write, | ||
179 | - .endianness = DEVICE_NATIVE_ENDIAN, | ||
180 | -}; | ||
181 | - | ||
182 | /* | ||
183 | * Unassigned portions of the PPB space are RAZ/WI for privileged | ||
184 | * accesses, and fault for non-privileged accesses. | ||
185 | @@ -XXX,XX +XXX,XX @@ static void armv7m_nvic_realize(DeviceState *dev, Error **errp) | ||
186 | &s->systick_ns_mem, 1); | ||
187 | } | ||
188 | |||
189 | - if (cpu_isar_feature(aa32_ras, s->cpu)) { | ||
190 | - memory_region_init_io(&s->ras_mem, OBJECT(s), | ||
191 | - &ras_ops, s, "nvic_ras", 0x1000); | ||
192 | - memory_region_add_subregion(&s->container, 0x5000, &s->ras_mem); | ||
193 | - } | ||
194 | - | ||
195 | sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->container); | ||
196 | } | ||
197 | |||
198 | diff --git a/hw/misc/armv7m_ras.c b/hw/misc/armv7m_ras.c | ||
199 | new file mode 100644 | 161 | new file mode 100644 |
200 | index XXXXXXX..XXXXXXX | 162 | index XXXXXXX..XXXXXXX |
201 | --- /dev/null | 163 | --- /dev/null |
202 | +++ b/hw/misc/armv7m_ras.c | 164 | +++ b/hw/gpio/aspeed_gpio.c |
203 | @@ -XXX,XX +XXX,XX @@ | 165 | @@ -XXX,XX +XXX,XX @@ |
204 | +/* | 166 | +/* |
205 | + * Arm M-profile RAS (Reliability, Availability and Serviceability) block | 167 | + * ASPEED GPIO Controller |
206 | + * | 168 | + * |
207 | + * Copyright (c) 2021 Linaro Limited | 169 | + * Copyright (C) 2017-2019 IBM Corp. |
208 | + * | 170 | + * |
209 | + * This program is free software; you can redistribute it and/or modify | 171 | + * SPDX-License-Identifier: GPL-2.0-or-later |
210 | + * it under the terms of the GNU General Public License version 2 or | ||
211 | + * (at your option) any later version. | ||
212 | + */ | 172 | + */ |
213 | + | 173 | + |
174 | +#include <assert.h> | ||
175 | + | ||
214 | +#include "qemu/osdep.h" | 176 | +#include "qemu/osdep.h" |
215 | +#include "hw/misc/armv7m_ras.h" | 177 | +#include "qemu/host-utils.h" |
216 | +#include "qemu/log.h" | 178 | +#include "qemu/log.h" |
217 | + | 179 | +#include "hw/gpio/aspeed_gpio.h" |
218 | +static MemTxResult ras_read(void *opaque, hwaddr addr, | 180 | +#include "include/hw/misc/aspeed_scu.h" |
219 | + uint64_t *data, unsigned size, | 181 | +#include "qapi/error.h" |
220 | + MemTxAttrs attrs) | 182 | +#include "qapi/visitor.h" |
221 | +{ | 183 | +#include "hw/irq.h" |
222 | + if (attrs.user) { | 184 | +#include "migration/vmstate.h" |
223 | + return MEMTX_ERROR; | 185 | + |
224 | + } | 186 | +#define GPIOS_PER_REG 32 |
225 | + | 187 | +#define GPIOS_PER_SET GPIOS_PER_REG |
226 | + switch (addr) { | 188 | +#define GPIO_PIN_GAP_SIZE 4 |
227 | + case 0xe10: /* ERRIIDR */ | 189 | +#define GPIOS_PER_GROUP 8 |
228 | + /* architect field = Arm; product/variant/revision 0 */ | 190 | +#define GPIO_GROUP_SHIFT 3 |
229 | + *data = 0x43b; | 191 | + |
192 | +/* GPIO Source Types */ | ||
193 | +#define ASPEED_CMD_SRC_MASK 0x01010101 | ||
194 | +#define ASPEED_SOURCE_ARM 0 | ||
195 | +#define ASPEED_SOURCE_LPC 1 | ||
196 | +#define ASPEED_SOURCE_COPROCESSOR 2 | ||
197 | +#define ASPEED_SOURCE_RESERVED 3 | ||
198 | + | ||
199 | +/* GPIO Interrupt Triggers */ | ||
200 | +/* | ||
201 | + * For each set of gpios there are three sensitivity registers that control | ||
202 | + * the interrupt trigger mode. | ||
203 | + * | ||
204 | + * | 2 | 1 | 0 | trigger mode | ||
205 | + * ----------------------------- | ||
206 | + * | 0 | 0 | 0 | falling-edge | ||
207 | + * | 0 | 0 | 1 | rising-edge | ||
208 | + * | 0 | 1 | 0 | level-low | ||
209 | + * | 0 | 1 | 1 | level-high | ||
210 | + * | 1 | X | X | dual-edge | ||
211 | + */ | ||
212 | +#define ASPEED_FALLING_EDGE 0 | ||
213 | +#define ASPEED_RISING_EDGE 1 | ||
214 | +#define ASPEED_LEVEL_LOW 2 | ||
215 | +#define ASPEED_LEVEL_HIGH 3 | ||
216 | +#define ASPEED_DUAL_EDGE 4 | ||
217 | + | ||
218 | +/* GPIO Register Address Offsets */ | ||
219 | +#define GPIO_ABCD_DATA_VALUE (0x000 >> 2) | ||
220 | +#define GPIO_ABCD_DIRECTION (0x004 >> 2) | ||
221 | +#define GPIO_ABCD_INT_ENABLE (0x008 >> 2) | ||
222 | +#define GPIO_ABCD_INT_SENS_0 (0x00C >> 2) | ||
223 | +#define GPIO_ABCD_INT_SENS_1 (0x010 >> 2) | ||
224 | +#define GPIO_ABCD_INT_SENS_2 (0x014 >> 2) | ||
225 | +#define GPIO_ABCD_INT_STATUS (0x018 >> 2) | ||
226 | +#define GPIO_ABCD_RESET_TOLERANT (0x01C >> 2) | ||
227 | +#define GPIO_EFGH_DATA_VALUE (0x020 >> 2) | ||
228 | +#define GPIO_EFGH_DIRECTION (0x024 >> 2) | ||
229 | +#define GPIO_EFGH_INT_ENABLE (0x028 >> 2) | ||
230 | +#define GPIO_EFGH_INT_SENS_0 (0x02C >> 2) | ||
231 | +#define GPIO_EFGH_INT_SENS_1 (0x030 >> 2) | ||
232 | +#define GPIO_EFGH_INT_SENS_2 (0x034 >> 2) | ||
233 | +#define GPIO_EFGH_INT_STATUS (0x038 >> 2) | ||
234 | +#define GPIO_EFGH_RESET_TOLERANT (0x03C >> 2) | ||
235 | +#define GPIO_ABCD_DEBOUNCE_1 (0x040 >> 2) | ||
236 | +#define GPIO_ABCD_DEBOUNCE_2 (0x044 >> 2) | ||
237 | +#define GPIO_EFGH_DEBOUNCE_1 (0x048 >> 2) | ||
238 | +#define GPIO_EFGH_DEBOUNCE_2 (0x04C >> 2) | ||
239 | +#define GPIO_DEBOUNCE_TIME_1 (0x050 >> 2) | ||
240 | +#define GPIO_DEBOUNCE_TIME_2 (0x054 >> 2) | ||
241 | +#define GPIO_DEBOUNCE_TIME_3 (0x058 >> 2) | ||
242 | +#define GPIO_ABCD_COMMAND_SRC_0 (0x060 >> 2) | ||
243 | +#define GPIO_ABCD_COMMAND_SRC_1 (0x064 >> 2) | ||
244 | +#define GPIO_EFGH_COMMAND_SRC_0 (0x068 >> 2) | ||
245 | +#define GPIO_EFGH_COMMAND_SRC_1 (0x06C >> 2) | ||
246 | +#define GPIO_IJKL_DATA_VALUE (0x070 >> 2) | ||
247 | +#define GPIO_IJKL_DIRECTION (0x074 >> 2) | ||
248 | +#define GPIO_MNOP_DATA_VALUE (0x078 >> 2) | ||
249 | +#define GPIO_MNOP_DIRECTION (0x07C >> 2) | ||
250 | +#define GPIO_QRST_DATA_VALUE (0x080 >> 2) | ||
251 | +#define GPIO_QRST_DIRECTION (0x084 >> 2) | ||
252 | +#define GPIO_UVWX_DATA_VALUE (0x088 >> 2) | ||
253 | +#define GPIO_UVWX_DIRECTION (0x08C >> 2) | ||
254 | +#define GPIO_IJKL_COMMAND_SRC_0 (0x090 >> 2) | ||
255 | +#define GPIO_IJKL_COMMAND_SRC_1 (0x094 >> 2) | ||
256 | +#define GPIO_IJKL_INT_ENABLE (0x098 >> 2) | ||
257 | +#define GPIO_IJKL_INT_SENS_0 (0x09C >> 2) | ||
258 | +#define GPIO_IJKL_INT_SENS_1 (0x0A0 >> 2) | ||
259 | +#define GPIO_IJKL_INT_SENS_2 (0x0A4 >> 2) | ||
260 | +#define GPIO_IJKL_INT_STATUS (0x0A8 >> 2) | ||
261 | +#define GPIO_IJKL_RESET_TOLERANT (0x0AC >> 2) | ||
262 | +#define GPIO_IJKL_DEBOUNCE_1 (0x0B0 >> 2) | ||
263 | +#define GPIO_IJKL_DEBOUNCE_2 (0x0B4 >> 2) | ||
264 | +#define GPIO_IJKL_INPUT_MASK (0x0B8 >> 2) | ||
265 | +#define GPIO_ABCD_DATA_READ (0x0C0 >> 2) | ||
266 | +#define GPIO_EFGH_DATA_READ (0x0C4 >> 2) | ||
267 | +#define GPIO_IJKL_DATA_READ (0x0C8 >> 2) | ||
268 | +#define GPIO_MNOP_DATA_READ (0x0CC >> 2) | ||
269 | +#define GPIO_QRST_DATA_READ (0x0D0 >> 2) | ||
270 | +#define GPIO_UVWX_DATA_READ (0x0D4 >> 2) | ||
271 | +#define GPIO_YZAAAB_DATA_READ (0x0D8 >> 2) | ||
272 | +#define GPIO_AC_DATA_READ (0x0DC >> 2) | ||
273 | +#define GPIO_MNOP_COMMAND_SRC_0 (0x0E0 >> 2) | ||
274 | +#define GPIO_MNOP_COMMAND_SRC_1 (0x0E4 >> 2) | ||
275 | +#define GPIO_MNOP_INT_ENABLE (0x0E8 >> 2) | ||
276 | +#define GPIO_MNOP_INT_SENS_0 (0x0EC >> 2) | ||
277 | +#define GPIO_MNOP_INT_SENS_1 (0x0F0 >> 2) | ||
278 | +#define GPIO_MNOP_INT_SENS_2 (0x0F4 >> 2) | ||
279 | +#define GPIO_MNOP_INT_STATUS (0x0F8 >> 2) | ||
280 | +#define GPIO_MNOP_RESET_TOLERANT (0x0FC >> 2) | ||
281 | +#define GPIO_MNOP_DEBOUNCE_1 (0x100 >> 2) | ||
282 | +#define GPIO_MNOP_DEBOUNCE_2 (0x104 >> 2) | ||
283 | +#define GPIO_MNOP_INPUT_MASK (0x108 >> 2) | ||
284 | +#define GPIO_QRST_COMMAND_SRC_0 (0x110 >> 2) | ||
285 | +#define GPIO_QRST_COMMAND_SRC_1 (0x114 >> 2) | ||
286 | +#define GPIO_QRST_INT_ENABLE (0x118 >> 2) | ||
287 | +#define GPIO_QRST_INT_SENS_0 (0x11C >> 2) | ||
288 | +#define GPIO_QRST_INT_SENS_1 (0x120 >> 2) | ||
289 | +#define GPIO_QRST_INT_SENS_2 (0x124 >> 2) | ||
290 | +#define GPIO_QRST_INT_STATUS (0x128 >> 2) | ||
291 | +#define GPIO_QRST_RESET_TOLERANT (0x12C >> 2) | ||
292 | +#define GPIO_QRST_DEBOUNCE_1 (0x130 >> 2) | ||
293 | +#define GPIO_QRST_DEBOUNCE_2 (0x134 >> 2) | ||
294 | +#define GPIO_QRST_INPUT_MASK (0x138 >> 2) | ||
295 | +#define GPIO_UVWX_COMMAND_SRC_0 (0x140 >> 2) | ||
296 | +#define GPIO_UVWX_COMMAND_SRC_1 (0x144 >> 2) | ||
297 | +#define GPIO_UVWX_INT_ENABLE (0x148 >> 2) | ||
298 | +#define GPIO_UVWX_INT_SENS_0 (0x14C >> 2) | ||
299 | +#define GPIO_UVWX_INT_SENS_1 (0x150 >> 2) | ||
300 | +#define GPIO_UVWX_INT_SENS_2 (0x154 >> 2) | ||
301 | +#define GPIO_UVWX_INT_STATUS (0x158 >> 2) | ||
302 | +#define GPIO_UVWX_RESET_TOLERANT (0x15C >> 2) | ||
303 | +#define GPIO_UVWX_DEBOUNCE_1 (0x160 >> 2) | ||
304 | +#define GPIO_UVWX_DEBOUNCE_2 (0x164 >> 2) | ||
305 | +#define GPIO_UVWX_INPUT_MASK (0x168 >> 2) | ||
306 | +#define GPIO_YZAAAB_COMMAND_SRC_0 (0x170 >> 2) | ||
307 | +#define GPIO_YZAAAB_COMMAND_SRC_1 (0x174 >> 2) | ||
308 | +#define GPIO_YZAAAB_INT_ENABLE (0x178 >> 2) | ||
309 | +#define GPIO_YZAAAB_INT_SENS_0 (0x17C >> 2) | ||
310 | +#define GPIO_YZAAAB_INT_SENS_1 (0x180 >> 2) | ||
311 | +#define GPIO_YZAAAB_INT_SENS_2 (0x184 >> 2) | ||
312 | +#define GPIO_YZAAAB_INT_STATUS (0x188 >> 2) | ||
313 | +#define GPIO_YZAAAB_RESET_TOLERANT (0x18C >> 2) | ||
314 | +#define GPIO_YZAAAB_DEBOUNCE_1 (0x190 >> 2) | ||
315 | +#define GPIO_YZAAAB_DEBOUNCE_2 (0x194 >> 2) | ||
316 | +#define GPIO_YZAAAB_INPUT_MASK (0x198 >> 2) | ||
317 | +#define GPIO_AC_COMMAND_SRC_0 (0x1A0 >> 2) | ||
318 | +#define GPIO_AC_COMMAND_SRC_1 (0x1A4 >> 2) | ||
319 | +#define GPIO_AC_INT_ENABLE (0x1A8 >> 2) | ||
320 | +#define GPIO_AC_INT_SENS_0 (0x1AC >> 2) | ||
321 | +#define GPIO_AC_INT_SENS_1 (0x1B0 >> 2) | ||
322 | +#define GPIO_AC_INT_SENS_2 (0x1B4 >> 2) | ||
323 | +#define GPIO_AC_INT_STATUS (0x1B8 >> 2) | ||
324 | +#define GPIO_AC_RESET_TOLERANT (0x1BC >> 2) | ||
325 | +#define GPIO_AC_DEBOUNCE_1 (0x1C0 >> 2) | ||
326 | +#define GPIO_AC_DEBOUNCE_2 (0x1C4 >> 2) | ||
327 | +#define GPIO_AC_INPUT_MASK (0x1C8 >> 2) | ||
328 | +#define GPIO_ABCD_INPUT_MASK (0x1D0 >> 2) | ||
329 | +#define GPIO_EFGH_INPUT_MASK (0x1D4 >> 2) | ||
330 | +#define GPIO_YZAAAB_DATA_VALUE (0x1E0 >> 2) | ||
331 | +#define GPIO_YZAAAB_DIRECTION (0x1E4 >> 2) | ||
332 | +#define GPIO_AC_DATA_VALUE (0x1E8 >> 2) | ||
333 | +#define GPIO_AC_DIRECTION (0x1EC >> 2) | ||
334 | +#define GPIO_3_6V_MEM_SIZE 0x1F0 | ||
335 | +#define GPIO_3_6V_REG_ARRAY_SIZE (GPIO_3_6V_MEM_SIZE >> 2) | ||
336 | + | ||
337 | +static int aspeed_evaluate_irq(GPIOSets *regs, int gpio_prev_high, int gpio) | ||
338 | +{ | ||
339 | + uint32_t falling_edge = 0, rising_edge = 0; | ||
340 | + uint32_t int_trigger = extract32(regs->int_sens_0, gpio, 1) | ||
341 | + | extract32(regs->int_sens_1, gpio, 1) << 1 | ||
342 | + | extract32(regs->int_sens_2, gpio, 1) << 2; | ||
343 | + uint32_t gpio_curr_high = extract32(regs->data_value, gpio, 1); | ||
344 | + uint32_t gpio_int_enabled = extract32(regs->int_enable, gpio, 1); | ||
345 | + | ||
346 | + if (!gpio_int_enabled) { | ||
347 | + return 0; | ||
348 | + } | ||
349 | + | ||
350 | + /* Detect edges */ | ||
351 | + if (gpio_curr_high && !gpio_prev_high) { | ||
352 | + rising_edge = 1; | ||
353 | + } else if (!gpio_curr_high && gpio_prev_high) { | ||
354 | + falling_edge = 1; | ||
355 | + } | ||
356 | + | ||
357 | + if (((int_trigger == ASPEED_FALLING_EDGE) && falling_edge) || | ||
358 | + ((int_trigger == ASPEED_RISING_EDGE) && rising_edge) || | ||
359 | + ((int_trigger == ASPEED_LEVEL_LOW) && !gpio_curr_high) || | ||
360 | + ((int_trigger == ASPEED_LEVEL_HIGH) && gpio_curr_high) || | ||
361 | + ((int_trigger >= ASPEED_DUAL_EDGE) && (rising_edge || falling_edge))) | ||
362 | + { | ||
363 | + regs->int_status = deposit32(regs->int_status, gpio, 1, 1); | ||
364 | + return 1; | ||
365 | + } | ||
366 | + return 0; | ||
367 | +} | ||
368 | + | ||
369 | +#define nested_struct_index(ta, pa, m, tb, pb) \ | ||
370 | + (pb - ((tb *)(((char *)pa) + offsetof(ta, m)))) | ||
371 | + | ||
372 | +static ptrdiff_t aspeed_gpio_set_idx(AspeedGPIOState *s, GPIOSets *regs) | ||
373 | +{ | ||
374 | + return nested_struct_index(AspeedGPIOState, s, sets, GPIOSets, regs); | ||
375 | +} | ||
376 | + | ||
377 | +static void aspeed_gpio_update(AspeedGPIOState *s, GPIOSets *regs, | ||
378 | + uint32_t value) | ||
379 | +{ | ||
380 | + uint32_t input_mask = regs->input_mask; | ||
381 | + uint32_t direction = regs->direction; | ||
382 | + uint32_t old = regs->data_value; | ||
383 | + uint32_t new = value; | ||
384 | + uint32_t diff; | ||
385 | + int gpio; | ||
386 | + | ||
387 | + diff = old ^ new; | ||
388 | + if (diff) { | ||
389 | + for (gpio = 0; gpio < GPIOS_PER_REG; gpio++) { | ||
390 | + uint32_t mask = 1 << gpio; | ||
391 | + | ||
392 | + /* If the gpio needs to be updated... */ | ||
393 | + if (!(diff & mask)) { | ||
394 | + continue; | ||
395 | + } | ||
396 | + | ||
397 | + /* ...and we're output or not input-masked... */ | ||
398 | + if (!(direction & mask) && (input_mask & mask)) { | ||
399 | + continue; | ||
400 | + } | ||
401 | + | ||
402 | + /* ...then update the state. */ | ||
403 | + if (mask & new) { | ||
404 | + regs->data_value |= mask; | ||
405 | + } else { | ||
406 | + regs->data_value &= ~mask; | ||
407 | + } | ||
408 | + | ||
409 | + /* If the gpio is set to output... */ | ||
410 | + if (direction & mask) { | ||
411 | + /* ...trigger the line-state IRQ */ | ||
412 | + ptrdiff_t set = aspeed_gpio_set_idx(s, regs); | ||
413 | + size_t offset = set * GPIOS_PER_SET + gpio; | ||
414 | + qemu_set_irq(s->gpios[offset], !!(new & mask)); | ||
415 | + } else { | ||
416 | + /* ...otherwise if we meet the line's current IRQ policy... */ | ||
417 | + if (aspeed_evaluate_irq(regs, old & mask, gpio)) { | ||
418 | + /* ...trigger the VIC IRQ */ | ||
419 | + s->pending++; | ||
420 | + } | ||
421 | + } | ||
422 | + } | ||
423 | + } | ||
424 | + qemu_set_irq(s->irq, !!(s->pending)); | ||
425 | +} | ||
426 | + | ||
427 | +static uint32_t aspeed_adjust_pin(AspeedGPIOState *s, uint32_t pin) | ||
428 | +{ | ||
429 | + AspeedGPIOClass *agc = ASPEED_GPIO_GET_CLASS(s); | ||
430 | + /* | ||
431 | + * The 2500 has a 4 pin gap in group AB and the 2400 has a 4 pin | ||
432 | + * gap in group Y (and only four pins in AB but this is the last group so | ||
433 | + * it doesn't matter). | ||
434 | + */ | ||
435 | + if (agc->gap && pin >= agc->gap) { | ||
436 | + pin += GPIO_PIN_GAP_SIZE; | ||
437 | + } | ||
438 | + | ||
439 | + return pin; | ||
440 | +} | ||
441 | + | ||
442 | +static bool aspeed_gpio_get_pin_level(AspeedGPIOState *s, uint32_t set_idx, | ||
443 | + uint32_t pin) | ||
444 | +{ | ||
445 | + uint32_t reg_val; | ||
446 | + uint32_t pin_mask = 1 << pin; | ||
447 | + | ||
448 | + reg_val = s->sets[set_idx].data_value; | ||
449 | + | ||
450 | + return !!(reg_val & pin_mask); | ||
451 | +} | ||
452 | + | ||
453 | +static void aspeed_gpio_set_pin_level(AspeedGPIOState *s, uint32_t set_idx, | ||
454 | + uint32_t pin, bool level) | ||
455 | +{ | ||
456 | + uint32_t value = s->sets[set_idx].data_value; | ||
457 | + uint32_t pin_mask = 1 << pin; | ||
458 | + | ||
459 | + if (level) { | ||
460 | + value |= pin_mask; | ||
461 | + } else { | ||
462 | + value &= !pin_mask; | ||
463 | + } | ||
464 | + | ||
465 | + aspeed_gpio_update(s, &s->sets[set_idx], value); | ||
466 | +} | ||
467 | + | ||
468 | +/* | ||
469 | + * | src_1 | src_2 | source | | ||
470 | + * |-----------------------------| | ||
471 | + * | 0 | 0 | ARM | | ||
472 | + * | 0 | 1 | LPC | | ||
473 | + * | 1 | 0 | Coprocessor| | ||
474 | + * | 1 | 1 | Reserved | | ||
475 | + * | ||
476 | + * Once the source of a set is programmed, corresponding bits in the | ||
477 | + * data_value, direction, interrupt [enable, sens[0-2]], reset_tol and | ||
478 | + * debounce registers can only be written by the source. | ||
479 | + * | ||
480 | + * Source is ARM by default | ||
481 | + * only bits 24, 16, 8, and 0 can be set | ||
482 | + * | ||
483 | + * we don't currently have a model for the LPC or Coprocessor | ||
484 | + */ | ||
485 | +static uint32_t update_value_control_source(GPIOSets *regs, uint32_t old_value, | ||
486 | + uint32_t value) | ||
487 | +{ | ||
488 | + int i; | ||
489 | + int cmd_source; | ||
490 | + | ||
491 | + /* assume the source is always ARM for now */ | ||
492 | + int source = ASPEED_SOURCE_ARM; | ||
493 | + | ||
494 | + uint32_t new_value = 0; | ||
495 | + | ||
496 | + /* for each group in set */ | ||
497 | + for (i = 0; i < GPIOS_PER_REG; i += GPIOS_PER_GROUP) { | ||
498 | + cmd_source = extract32(regs->cmd_source_0, i, 1) | ||
499 | + | (extract32(regs->cmd_source_1, i, 1) << 1); | ||
500 | + | ||
501 | + if (source == cmd_source) { | ||
502 | + new_value |= (0xff << i) & value; | ||
503 | + } else { | ||
504 | + new_value |= (0xff << i) & old_value; | ||
505 | + } | ||
506 | + } | ||
507 | + return new_value; | ||
508 | +} | ||
509 | + | ||
510 | +static const AspeedGPIOReg aspeed_3_6v_gpios[GPIO_3_6V_REG_ARRAY_SIZE] = { | ||
511 | + /* Set ABCD */ | ||
512 | + [GPIO_ABCD_DATA_VALUE] = { 0, gpio_reg_data_value }, | ||
513 | + [GPIO_ABCD_DIRECTION] = { 0, gpio_reg_direction }, | ||
514 | + [GPIO_ABCD_INT_ENABLE] = { 0, gpio_reg_int_enable }, | ||
515 | + [GPIO_ABCD_INT_SENS_0] = { 0, gpio_reg_int_sens_0 }, | ||
516 | + [GPIO_ABCD_INT_SENS_1] = { 0, gpio_reg_int_sens_1 }, | ||
517 | + [GPIO_ABCD_INT_SENS_2] = { 0, gpio_reg_int_sens_2 }, | ||
518 | + [GPIO_ABCD_INT_STATUS] = { 0, gpio_reg_int_status }, | ||
519 | + [GPIO_ABCD_RESET_TOLERANT] = { 0, gpio_reg_reset_tolerant }, | ||
520 | + [GPIO_ABCD_DEBOUNCE_1] = { 0, gpio_reg_debounce_1 }, | ||
521 | + [GPIO_ABCD_DEBOUNCE_2] = { 0, gpio_reg_debounce_2 }, | ||
522 | + [GPIO_ABCD_COMMAND_SRC_0] = { 0, gpio_reg_cmd_source_0 }, | ||
523 | + [GPIO_ABCD_COMMAND_SRC_1] = { 0, gpio_reg_cmd_source_1 }, | ||
524 | + [GPIO_ABCD_DATA_READ] = { 0, gpio_reg_data_read }, | ||
525 | + [GPIO_ABCD_INPUT_MASK] = { 0, gpio_reg_input_mask }, | ||
526 | + /* Set EFGH */ | ||
527 | + [GPIO_EFGH_DATA_VALUE] = { 1, gpio_reg_data_value }, | ||
528 | + [GPIO_EFGH_DIRECTION] = { 1, gpio_reg_direction }, | ||
529 | + [GPIO_EFGH_INT_ENABLE] = { 1, gpio_reg_int_enable }, | ||
530 | + [GPIO_EFGH_INT_SENS_0] = { 1, gpio_reg_int_sens_0 }, | ||
531 | + [GPIO_EFGH_INT_SENS_1] = { 1, gpio_reg_int_sens_1 }, | ||
532 | + [GPIO_EFGH_INT_SENS_2] = { 1, gpio_reg_int_sens_2 }, | ||
533 | + [GPIO_EFGH_INT_STATUS] = { 1, gpio_reg_int_status }, | ||
534 | + [GPIO_EFGH_RESET_TOLERANT] = { 1, gpio_reg_reset_tolerant }, | ||
535 | + [GPIO_EFGH_DEBOUNCE_1] = { 1, gpio_reg_debounce_1 }, | ||
536 | + [GPIO_EFGH_DEBOUNCE_2] = { 1, gpio_reg_debounce_2 }, | ||
537 | + [GPIO_EFGH_COMMAND_SRC_0] = { 1, gpio_reg_cmd_source_0 }, | ||
538 | + [GPIO_EFGH_COMMAND_SRC_1] = { 1, gpio_reg_cmd_source_1 }, | ||
539 | + [GPIO_EFGH_DATA_READ] = { 1, gpio_reg_data_read }, | ||
540 | + [GPIO_EFGH_INPUT_MASK] = { 1, gpio_reg_input_mask }, | ||
541 | + /* Set IJKL */ | ||
542 | + [GPIO_IJKL_DATA_VALUE] = { 2, gpio_reg_data_value }, | ||
543 | + [GPIO_IJKL_DIRECTION] = { 2, gpio_reg_direction }, | ||
544 | + [GPIO_IJKL_INT_ENABLE] = { 2, gpio_reg_int_enable }, | ||
545 | + [GPIO_IJKL_INT_SENS_0] = { 2, gpio_reg_int_sens_0 }, | ||
546 | + [GPIO_IJKL_INT_SENS_1] = { 2, gpio_reg_int_sens_1 }, | ||
547 | + [GPIO_IJKL_INT_SENS_2] = { 2, gpio_reg_int_sens_2 }, | ||
548 | + [GPIO_IJKL_INT_STATUS] = { 2, gpio_reg_int_status }, | ||
549 | + [GPIO_IJKL_RESET_TOLERANT] = { 2, gpio_reg_reset_tolerant }, | ||
550 | + [GPIO_IJKL_DEBOUNCE_1] = { 2, gpio_reg_debounce_1 }, | ||
551 | + [GPIO_IJKL_DEBOUNCE_2] = { 2, gpio_reg_debounce_2 }, | ||
552 | + [GPIO_IJKL_COMMAND_SRC_0] = { 2, gpio_reg_cmd_source_0 }, | ||
553 | + [GPIO_IJKL_COMMAND_SRC_1] = { 2, gpio_reg_cmd_source_1 }, | ||
554 | + [GPIO_IJKL_DATA_READ] = { 2, gpio_reg_data_read }, | ||
555 | + [GPIO_IJKL_INPUT_MASK] = { 2, gpio_reg_input_mask }, | ||
556 | + /* Set MNOP */ | ||
557 | + [GPIO_MNOP_DATA_VALUE] = { 3, gpio_reg_data_value }, | ||
558 | + [GPIO_MNOP_DIRECTION] = { 3, gpio_reg_direction }, | ||
559 | + [GPIO_MNOP_INT_ENABLE] = { 3, gpio_reg_int_enable }, | ||
560 | + [GPIO_MNOP_INT_SENS_0] = { 3, gpio_reg_int_sens_0 }, | ||
561 | + [GPIO_MNOP_INT_SENS_1] = { 3, gpio_reg_int_sens_1 }, | ||
562 | + [GPIO_MNOP_INT_SENS_2] = { 3, gpio_reg_int_sens_2 }, | ||
563 | + [GPIO_MNOP_INT_STATUS] = { 3, gpio_reg_int_status }, | ||
564 | + [GPIO_MNOP_RESET_TOLERANT] = { 3, gpio_reg_reset_tolerant }, | ||
565 | + [GPIO_MNOP_DEBOUNCE_1] = { 3, gpio_reg_debounce_1 }, | ||
566 | + [GPIO_MNOP_DEBOUNCE_2] = { 3, gpio_reg_debounce_2 }, | ||
567 | + [GPIO_MNOP_COMMAND_SRC_0] = { 3, gpio_reg_cmd_source_0 }, | ||
568 | + [GPIO_MNOP_COMMAND_SRC_1] = { 3, gpio_reg_cmd_source_1 }, | ||
569 | + [GPIO_MNOP_DATA_READ] = { 3, gpio_reg_data_read }, | ||
570 | + [GPIO_MNOP_INPUT_MASK] = { 3, gpio_reg_input_mask }, | ||
571 | + /* Set QRST */ | ||
572 | + [GPIO_QRST_DATA_VALUE] = { 4, gpio_reg_data_value }, | ||
573 | + [GPIO_QRST_DIRECTION] = { 4, gpio_reg_direction }, | ||
574 | + [GPIO_QRST_INT_ENABLE] = { 4, gpio_reg_int_enable }, | ||
575 | + [GPIO_QRST_INT_SENS_0] = { 4, gpio_reg_int_sens_0 }, | ||
576 | + [GPIO_QRST_INT_SENS_1] = { 4, gpio_reg_int_sens_1 }, | ||
577 | + [GPIO_QRST_INT_SENS_2] = { 4, gpio_reg_int_sens_2 }, | ||
578 | + [GPIO_QRST_INT_STATUS] = { 4, gpio_reg_int_status }, | ||
579 | + [GPIO_QRST_RESET_TOLERANT] = { 4, gpio_reg_reset_tolerant }, | ||
580 | + [GPIO_QRST_DEBOUNCE_1] = { 4, gpio_reg_debounce_1 }, | ||
581 | + [GPIO_QRST_DEBOUNCE_2] = { 4, gpio_reg_debounce_2 }, | ||
582 | + [GPIO_QRST_COMMAND_SRC_0] = { 4, gpio_reg_cmd_source_0 }, | ||
583 | + [GPIO_QRST_COMMAND_SRC_1] = { 4, gpio_reg_cmd_source_1 }, | ||
584 | + [GPIO_QRST_DATA_READ] = { 4, gpio_reg_data_read }, | ||
585 | + [GPIO_QRST_INPUT_MASK] = { 4, gpio_reg_input_mask }, | ||
586 | + /* Set UVWX */ | ||
587 | + [GPIO_UVWX_DATA_VALUE] = { 5, gpio_reg_data_value }, | ||
588 | + [GPIO_UVWX_DIRECTION] = { 5, gpio_reg_direction }, | ||
589 | + [GPIO_UVWX_INT_ENABLE] = { 5, gpio_reg_int_enable }, | ||
590 | + [GPIO_UVWX_INT_SENS_0] = { 5, gpio_reg_int_sens_0 }, | ||
591 | + [GPIO_UVWX_INT_SENS_1] = { 5, gpio_reg_int_sens_1 }, | ||
592 | + [GPIO_UVWX_INT_SENS_2] = { 5, gpio_reg_int_sens_2 }, | ||
593 | + [GPIO_UVWX_INT_STATUS] = { 5, gpio_reg_int_status }, | ||
594 | + [GPIO_UVWX_RESET_TOLERANT] = { 5, gpio_reg_reset_tolerant }, | ||
595 | + [GPIO_UVWX_DEBOUNCE_1] = { 5, gpio_reg_debounce_1 }, | ||
596 | + [GPIO_UVWX_DEBOUNCE_2] = { 5, gpio_reg_debounce_2 }, | ||
597 | + [GPIO_UVWX_COMMAND_SRC_0] = { 5, gpio_reg_cmd_source_0 }, | ||
598 | + [GPIO_UVWX_COMMAND_SRC_1] = { 5, gpio_reg_cmd_source_1 }, | ||
599 | + [GPIO_UVWX_DATA_READ] = { 5, gpio_reg_data_read }, | ||
600 | + [GPIO_UVWX_INPUT_MASK] = { 5, gpio_reg_input_mask }, | ||
601 | + /* Set YZAAAB */ | ||
602 | + [GPIO_YZAAAB_DATA_VALUE] = { 6, gpio_reg_data_value }, | ||
603 | + [GPIO_YZAAAB_DIRECTION] = { 6, gpio_reg_direction }, | ||
604 | + [GPIO_YZAAAB_INT_ENABLE] = { 6, gpio_reg_int_enable }, | ||
605 | + [GPIO_YZAAAB_INT_SENS_0] = { 6, gpio_reg_int_sens_0 }, | ||
606 | + [GPIO_YZAAAB_INT_SENS_1] = { 6, gpio_reg_int_sens_1 }, | ||
607 | + [GPIO_YZAAAB_INT_SENS_2] = { 6, gpio_reg_int_sens_2 }, | ||
608 | + [GPIO_YZAAAB_INT_STATUS] = { 6, gpio_reg_int_status }, | ||
609 | + [GPIO_YZAAAB_RESET_TOLERANT] = { 6, gpio_reg_reset_tolerant }, | ||
610 | + [GPIO_YZAAAB_DEBOUNCE_1] = { 6, gpio_reg_debounce_1 }, | ||
611 | + [GPIO_YZAAAB_DEBOUNCE_2] = { 6, gpio_reg_debounce_2 }, | ||
612 | + [GPIO_YZAAAB_COMMAND_SRC_0] = { 6, gpio_reg_cmd_source_0 }, | ||
613 | + [GPIO_YZAAAB_COMMAND_SRC_1] = { 6, gpio_reg_cmd_source_1 }, | ||
614 | + [GPIO_YZAAAB_DATA_READ] = { 6, gpio_reg_data_read }, | ||
615 | + [GPIO_YZAAAB_INPUT_MASK] = { 6, gpio_reg_input_mask }, | ||
616 | + /* Set AC (ast2500 only) */ | ||
617 | + [GPIO_AC_DATA_VALUE] = { 7, gpio_reg_data_value }, | ||
618 | + [GPIO_AC_DIRECTION] = { 7, gpio_reg_direction }, | ||
619 | + [GPIO_AC_INT_ENABLE] = { 7, gpio_reg_int_enable }, | ||
620 | + [GPIO_AC_INT_SENS_0] = { 7, gpio_reg_int_sens_0 }, | ||
621 | + [GPIO_AC_INT_SENS_1] = { 7, gpio_reg_int_sens_1 }, | ||
622 | + [GPIO_AC_INT_SENS_2] = { 7, gpio_reg_int_sens_2 }, | ||
623 | + [GPIO_AC_INT_STATUS] = { 7, gpio_reg_int_status }, | ||
624 | + [GPIO_AC_RESET_TOLERANT] = { 7, gpio_reg_reset_tolerant }, | ||
625 | + [GPIO_AC_DEBOUNCE_1] = { 7, gpio_reg_debounce_1 }, | ||
626 | + [GPIO_AC_DEBOUNCE_2] = { 7, gpio_reg_debounce_2 }, | ||
627 | + [GPIO_AC_COMMAND_SRC_0] = { 7, gpio_reg_cmd_source_0 }, | ||
628 | + [GPIO_AC_COMMAND_SRC_1] = { 7, gpio_reg_cmd_source_1 }, | ||
629 | + [GPIO_AC_DATA_READ] = { 7, gpio_reg_data_read }, | ||
630 | + [GPIO_AC_INPUT_MASK] = { 7, gpio_reg_input_mask }, | ||
631 | +}; | ||
632 | + | ||
633 | +static uint64_t aspeed_gpio_read(void *opaque, hwaddr offset, uint32_t size) | ||
634 | +{ | ||
635 | + AspeedGPIOState *s = ASPEED_GPIO(opaque); | ||
636 | + AspeedGPIOClass *agc = ASPEED_GPIO_GET_CLASS(s); | ||
637 | + uint64_t idx = -1; | ||
638 | + const AspeedGPIOReg *reg; | ||
639 | + GPIOSets *set; | ||
640 | + | ||
641 | + idx = offset >> 2; | ||
642 | + if (idx >= GPIO_DEBOUNCE_TIME_1 && idx <= GPIO_DEBOUNCE_TIME_3) { | ||
643 | + idx -= GPIO_DEBOUNCE_TIME_1; | ||
644 | + return (uint64_t) s->debounce_regs[idx]; | ||
645 | + } | ||
646 | + | ||
647 | + reg = &agc->reg_table[idx]; | ||
648 | + if (reg->set_idx >= agc->nr_gpio_sets) { | ||
649 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: no getter for offset 0x%" | ||
650 | + HWADDR_PRIx"\n", __func__, offset); | ||
651 | + return 0; | ||
652 | + } | ||
653 | + | ||
654 | + set = &s->sets[reg->set_idx]; | ||
655 | + switch (reg->type) { | ||
656 | + case gpio_reg_data_value: | ||
657 | + return set->data_value; | ||
658 | + case gpio_reg_direction: | ||
659 | + return set->direction; | ||
660 | + case gpio_reg_int_enable: | ||
661 | + return set->int_enable; | ||
662 | + case gpio_reg_int_sens_0: | ||
663 | + return set->int_sens_0; | ||
664 | + case gpio_reg_int_sens_1: | ||
665 | + return set->int_sens_1; | ||
666 | + case gpio_reg_int_sens_2: | ||
667 | + return set->int_sens_2; | ||
668 | + case gpio_reg_int_status: | ||
669 | + return set->int_status; | ||
670 | + case gpio_reg_reset_tolerant: | ||
671 | + return set->reset_tol; | ||
672 | + case gpio_reg_debounce_1: | ||
673 | + return set->debounce_1; | ||
674 | + case gpio_reg_debounce_2: | ||
675 | + return set->debounce_2; | ||
676 | + case gpio_reg_cmd_source_0: | ||
677 | + return set->cmd_source_0; | ||
678 | + case gpio_reg_cmd_source_1: | ||
679 | + return set->cmd_source_1; | ||
680 | + case gpio_reg_data_read: | ||
681 | + return set->data_read; | ||
682 | + case gpio_reg_input_mask: | ||
683 | + return set->input_mask; | ||
684 | + default: | ||
685 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: no getter for offset 0x%" | ||
686 | + HWADDR_PRIx"\n", __func__, offset); | ||
687 | + return 0; | ||
688 | + }; | ||
689 | +} | ||
690 | + | ||
691 | +static void aspeed_gpio_write(void *opaque, hwaddr offset, uint64_t data, | ||
692 | + uint32_t size) | ||
693 | +{ | ||
694 | + AspeedGPIOState *s = ASPEED_GPIO(opaque); | ||
695 | + AspeedGPIOClass *agc = ASPEED_GPIO_GET_CLASS(s); | ||
696 | + const GPIOSetProperties *props; | ||
697 | + uint64_t idx = -1; | ||
698 | + const AspeedGPIOReg *reg; | ||
699 | + GPIOSets *set; | ||
700 | + uint32_t cleared; | ||
701 | + | ||
702 | + idx = offset >> 2; | ||
703 | + if (idx >= GPIO_DEBOUNCE_TIME_1 && idx <= GPIO_DEBOUNCE_TIME_3) { | ||
704 | + idx -= GPIO_DEBOUNCE_TIME_1; | ||
705 | + s->debounce_regs[idx] = (uint32_t) data; | ||
706 | + return; | ||
707 | + } | ||
708 | + | ||
709 | + reg = &agc->reg_table[idx]; | ||
710 | + if (reg->set_idx >= agc->nr_gpio_sets) { | ||
711 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: no setter for offset 0x%" | ||
712 | + HWADDR_PRIx"\n", __func__, offset); | ||
713 | + return; | ||
714 | + } | ||
715 | + | ||
716 | + set = &s->sets[reg->set_idx]; | ||
717 | + props = &agc->props[reg->set_idx]; | ||
718 | + | ||
719 | + switch (reg->type) { | ||
720 | + case gpio_reg_data_value: | ||
721 | + data &= props->output; | ||
722 | + data = update_value_control_source(set, set->data_value, data); | ||
723 | + set->data_read = data; | ||
724 | + aspeed_gpio_update(s, set, data); | ||
725 | + return; | ||
726 | + case gpio_reg_direction: | ||
727 | + /* | ||
728 | + * where data is the value attempted to be written to the pin: | ||
729 | + * pin type | input mask | output mask | expected value | ||
730 | + * ------------------------------------------------------------ | ||
731 | + * bidirectional | 1 | 1 | data | ||
732 | + * input only | 1 | 0 | 0 | ||
733 | + * output only | 0 | 1 | 1 | ||
734 | + * no pin / gap | 0 | 0 | 0 | ||
735 | + * | ||
736 | + * which is captured by: | ||
737 | + * data = ( data | ~input) & output; | ||
738 | + */ | ||
739 | + data = (data | ~props->input) & props->output; | ||
740 | + set->direction = update_value_control_source(set, set->direction, data); | ||
230 | + break; | 741 | + break; |
231 | + case 0xfc8: /* ERRDEVID */ | 742 | + case gpio_reg_int_enable: |
232 | + /* Minimal RAS: we implement 0 error record indexes */ | 743 | + set->int_enable = update_value_control_source(set, set->int_enable, |
233 | + *data = 0; | 744 | + data); |
745 | + break; | ||
746 | + case gpio_reg_int_sens_0: | ||
747 | + set->int_sens_0 = update_value_control_source(set, set->int_sens_0, | ||
748 | + data); | ||
749 | + break; | ||
750 | + case gpio_reg_int_sens_1: | ||
751 | + set->int_sens_1 = update_value_control_source(set, set->int_sens_1, | ||
752 | + data); | ||
753 | + break; | ||
754 | + case gpio_reg_int_sens_2: | ||
755 | + set->int_sens_2 = update_value_control_source(set, set->int_sens_2, | ||
756 | + data); | ||
757 | + break; | ||
758 | + case gpio_reg_int_status: | ||
759 | + cleared = ctpop32(data & set->int_status); | ||
760 | + if (s->pending && cleared) { | ||
761 | + assert(s->pending >= cleared); | ||
762 | + s->pending -= cleared; | ||
763 | + } | ||
764 | + set->int_status &= ~data; | ||
765 | + break; | ||
766 | + case gpio_reg_reset_tolerant: | ||
767 | + set->reset_tol = update_value_control_source(set, set->reset_tol, | ||
768 | + data); | ||
769 | + return; | ||
770 | + case gpio_reg_debounce_1: | ||
771 | + set->debounce_1 = update_value_control_source(set, set->debounce_1, | ||
772 | + data); | ||
773 | + return; | ||
774 | + case gpio_reg_debounce_2: | ||
775 | + set->debounce_2 = update_value_control_source(set, set->debounce_2, | ||
776 | + data); | ||
777 | + return; | ||
778 | + case gpio_reg_cmd_source_0: | ||
779 | + set->cmd_source_0 = data & ASPEED_CMD_SRC_MASK; | ||
780 | + return; | ||
781 | + case gpio_reg_cmd_source_1: | ||
782 | + set->cmd_source_1 = data & ASPEED_CMD_SRC_MASK; | ||
783 | + return; | ||
784 | + case gpio_reg_data_read: | ||
785 | + /* Read only register */ | ||
786 | + return; | ||
787 | + case gpio_reg_input_mask: | ||
788 | + /* | ||
789 | + * feeds into interrupt generation | ||
790 | + * 0: read from data value reg will be updated | ||
791 | + * 1: read from data value reg will not be updated | ||
792 | + */ | ||
793 | + set->input_mask = data & props->input; | ||
234 | + break; | 794 | + break; |
235 | + default: | 795 | + default: |
236 | + qemu_log_mask(LOG_UNIMP, "Read RAS register offset 0x%x\n", | 796 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: no setter for offset 0x%" |
237 | + (uint32_t)addr); | 797 | + HWADDR_PRIx"\n", __func__, offset); |
238 | + *data = 0; | 798 | + return; |
239 | + break; | 799 | + } |
240 | + } | 800 | + aspeed_gpio_update(s, set, set->data_value); |
241 | + return MEMTX_OK; | 801 | + return; |
242 | +} | 802 | +} |
243 | + | 803 | + |
244 | +static MemTxResult ras_write(void *opaque, hwaddr addr, | 804 | +static int get_set_idx(AspeedGPIOState *s, const char *group, int *group_idx) |
245 | + uint64_t value, unsigned size, | 805 | +{ |
246 | + MemTxAttrs attrs) | 806 | + AspeedGPIOClass *agc = ASPEED_GPIO_GET_CLASS(s); |
247 | +{ | 807 | + int set_idx, g_idx = *group_idx; |
248 | + if (attrs.user) { | 808 | + |
249 | + return MEMTX_ERROR; | 809 | + for (set_idx = 0; set_idx < agc->nr_gpio_sets; set_idx++) { |
250 | + } | 810 | + const GPIOSetProperties *set_props = &agc->props[set_idx]; |
251 | + | 811 | + for (g_idx = 0; g_idx < ASPEED_GROUPS_PER_SET; g_idx++) { |
252 | + switch (addr) { | 812 | + if (!strncmp(group, set_props->group_label[g_idx], strlen(group))) { |
253 | + default: | 813 | + *group_idx = g_idx; |
254 | + qemu_log_mask(LOG_UNIMP, "Write to RAS register offset 0x%x\n", | 814 | + return set_idx; |
255 | + (uint32_t)addr); | 815 | + } |
256 | + break; | 816 | + } |
257 | + } | 817 | + } |
258 | + return MEMTX_OK; | 818 | + return -1; |
259 | +} | 819 | +} |
260 | + | 820 | + |
261 | +static const MemoryRegionOps ras_ops = { | 821 | +static void aspeed_gpio_get_pin(Object *obj, Visitor *v, const char *name, |
262 | + .read_with_attrs = ras_read, | 822 | + void *opaque, Error **errp) |
263 | + .write_with_attrs = ras_write, | 823 | +{ |
264 | + .endianness = DEVICE_NATIVE_ENDIAN, | 824 | + int pin = 0xfff; |
825 | + bool level = true; | ||
826 | + char group[3]; | ||
827 | + AspeedGPIOState *s = ASPEED_GPIO(obj); | ||
828 | + int set_idx, group_idx = 0; | ||
829 | + | ||
830 | + if (sscanf(name, "gpio%2[A-Z]%1d", group, &pin) != 2) { | ||
831 | + error_setg(errp, "%s: error reading %s", __func__, name); | ||
832 | + return; | ||
833 | + } | ||
834 | + set_idx = get_set_idx(s, group, &group_idx); | ||
835 | + if (set_idx == -1) { | ||
836 | + error_setg(errp, "%s: invalid group %s", __func__, group); | ||
837 | + return; | ||
838 | + } | ||
839 | + pin = pin + group_idx * GPIOS_PER_GROUP; | ||
840 | + level = aspeed_gpio_get_pin_level(s, set_idx, pin); | ||
841 | + visit_type_bool(v, name, &level, errp); | ||
842 | +} | ||
843 | + | ||
844 | +static void aspeed_gpio_set_pin(Object *obj, Visitor *v, const char *name, | ||
845 | + void *opaque, Error **errp) | ||
846 | +{ | ||
847 | + Error *local_err = NULL; | ||
848 | + bool level; | ||
849 | + int pin = 0xfff; | ||
850 | + char group[3]; | ||
851 | + AspeedGPIOState *s = ASPEED_GPIO(obj); | ||
852 | + int set_idx, group_idx = 0; | ||
853 | + | ||
854 | + visit_type_bool(v, name, &level, &local_err); | ||
855 | + if (local_err) { | ||
856 | + error_propagate(errp, local_err); | ||
857 | + return; | ||
858 | + } | ||
859 | + if (sscanf(name, "gpio%2[A-Z]%1d", group, &pin) != 2) { | ||
860 | + error_setg(errp, "%s: error reading %s", __func__, name); | ||
861 | + return; | ||
862 | + } | ||
863 | + set_idx = get_set_idx(s, group, &group_idx); | ||
864 | + if (set_idx == -1) { | ||
865 | + error_setg(errp, "%s: invalid group %s", __func__, group); | ||
866 | + return; | ||
867 | + } | ||
868 | + pin = pin + group_idx * GPIOS_PER_GROUP; | ||
869 | + aspeed_gpio_set_pin_level(s, set_idx, pin, level); | ||
870 | +} | ||
871 | + | ||
872 | +/****************** Setup functions ******************/ | ||
873 | +static const GPIOSetProperties ast2400_set_props[] = { | ||
874 | + [0] = {0xffffffff, 0xffffffff, {"A", "B", "C", "D"} }, | ||
875 | + [1] = {0xffffffff, 0xffffffff, {"E", "F", "G", "H"} }, | ||
876 | + [2] = {0xffffffff, 0xffffffff, {"I", "J", "K", "L"} }, | ||
877 | + [3] = {0xffffffff, 0xffffffff, {"M", "N", "O", "P"} }, | ||
878 | + [4] = {0xffffffff, 0xffffffff, {"Q", "R", "S", "T"} }, | ||
879 | + [5] = {0xffffffff, 0x0000ffff, {"U", "V", "W", "X"} }, | ||
880 | + [6] = {0x0000000f, 0x0fffff0f, {"Y", "Z", "AA", "AB"} }, | ||
265 | +}; | 881 | +}; |
266 | + | 882 | + |
267 | + | 883 | +static const GPIOSetProperties ast2500_set_props[] = { |
268 | +static void armv7m_ras_init(Object *obj) | 884 | + [0] = {0xffffffff, 0xffffffff, {"A", "B", "C", "D"} }, |
269 | +{ | 885 | + [1] = {0xffffffff, 0xffffffff, {"E", "F", "G", "H"} }, |
270 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | 886 | + [2] = {0xffffffff, 0xffffffff, {"I", "J", "K", "L"} }, |
271 | + ARMv7MRAS *s = ARMV7M_RAS(obj); | 887 | + [3] = {0xffffffff, 0xffffffff, {"M", "N", "O", "P"} }, |
272 | + | 888 | + [4] = {0xffffffff, 0xffffffff, {"Q", "R", "S", "T"} }, |
273 | + memory_region_init_io(&s->iomem, obj, &ras_ops, | 889 | + [5] = {0xffffffff, 0x0000ffff, {"U", "V", "W", "X"} }, |
274 | + s, "armv7m-ras", 0x1000); | 890 | + [6] = {0xffffff0f, 0x0fffff0f, {"Y", "Z", "AA", "AB"} }, |
891 | + [7] = {0x000000ff, 0x000000ff, {"AC"} }, | ||
892 | +}; | ||
893 | + | ||
894 | +static const MemoryRegionOps aspeed_gpio_ops = { | ||
895 | + .read = aspeed_gpio_read, | ||
896 | + .write = aspeed_gpio_write, | ||
897 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
898 | + .valid.min_access_size = 4, | ||
899 | + .valid.max_access_size = 4, | ||
900 | +}; | ||
901 | + | ||
902 | +static void aspeed_gpio_reset(DeviceState *dev) | ||
903 | +{ | ||
904 | + AspeedGPIOState *s = ASPEED_GPIO(dev); | ||
905 | + | ||
906 | + /* TODO: respect the reset tolerance registers */ | ||
907 | + memset(s->sets, 0, sizeof(s->sets)); | ||
908 | +} | ||
909 | + | ||
910 | +static void aspeed_gpio_realize(DeviceState *dev, Error **errp) | ||
911 | +{ | ||
912 | + AspeedGPIOState *s = ASPEED_GPIO(dev); | ||
913 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
914 | + AspeedGPIOClass *agc = ASPEED_GPIO_GET_CLASS(s); | ||
915 | + int pin; | ||
916 | + | ||
917 | + /* Interrupt parent line */ | ||
918 | + sysbus_init_irq(sbd, &s->irq); | ||
919 | + | ||
920 | + /* Individual GPIOs */ | ||
921 | + for (pin = 0; pin < agc->nr_gpio_pins; pin++) { | ||
922 | + sysbus_init_irq(sbd, &s->gpios[pin]); | ||
923 | + } | ||
924 | + | ||
925 | + memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_gpio_ops, s, | ||
926 | + TYPE_ASPEED_GPIO, GPIO_3_6V_MEM_SIZE); | ||
927 | + | ||
275 | + sysbus_init_mmio(sbd, &s->iomem); | 928 | + sysbus_init_mmio(sbd, &s->iomem); |
276 | +} | 929 | +} |
277 | + | 930 | + |
278 | +static void armv7m_ras_class_init(ObjectClass *klass, void *data) | 931 | +static void aspeed_gpio_init(Object *obj) |
279 | +{ | 932 | +{ |
280 | + /* This device has no state: no need for vmstate or reset */ | 933 | + AspeedGPIOState *s = ASPEED_GPIO(obj); |
281 | +} | 934 | + AspeedGPIOClass *agc = ASPEED_GPIO_GET_CLASS(s); |
282 | + | 935 | + int pin; |
283 | +static const TypeInfo armv7m_ras_info = { | 936 | + |
284 | + .name = TYPE_ARMV7M_RAS, | 937 | + for (pin = 0; pin < agc->nr_gpio_pins; pin++) { |
285 | + .parent = TYPE_SYS_BUS_DEVICE, | 938 | + char *name; |
286 | + .instance_size = sizeof(ARMv7MRAS), | 939 | + int set_idx = pin / GPIOS_PER_SET; |
287 | + .instance_init = armv7m_ras_init, | 940 | + int pin_idx = aspeed_adjust_pin(s, pin) - (set_idx * GPIOS_PER_SET); |
288 | + .class_init = armv7m_ras_class_init, | 941 | + int group_idx = pin_idx >> GPIO_GROUP_SHIFT; |
942 | + const GPIOSetProperties *props = &agc->props[set_idx]; | ||
943 | + | ||
944 | + name = g_strdup_printf("gpio%s%d", props->group_label[group_idx], | ||
945 | + pin_idx % GPIOS_PER_GROUP); | ||
946 | + object_property_add(obj, name, "bool", aspeed_gpio_get_pin, | ||
947 | + aspeed_gpio_set_pin, NULL, NULL, NULL); | ||
948 | + } | ||
949 | +} | ||
950 | + | ||
951 | +static const VMStateDescription vmstate_gpio_regs = { | ||
952 | + .name = TYPE_ASPEED_GPIO"/regs", | ||
953 | + .version_id = 1, | ||
954 | + .minimum_version_id = 1, | ||
955 | + .fields = (VMStateField[]) { | ||
956 | + VMSTATE_UINT32(data_value, GPIOSets), | ||
957 | + VMSTATE_UINT32(data_read, GPIOSets), | ||
958 | + VMSTATE_UINT32(direction, GPIOSets), | ||
959 | + VMSTATE_UINT32(int_enable, GPIOSets), | ||
960 | + VMSTATE_UINT32(int_sens_0, GPIOSets), | ||
961 | + VMSTATE_UINT32(int_sens_1, GPIOSets), | ||
962 | + VMSTATE_UINT32(int_sens_2, GPIOSets), | ||
963 | + VMSTATE_UINT32(int_status, GPIOSets), | ||
964 | + VMSTATE_UINT32(reset_tol, GPIOSets), | ||
965 | + VMSTATE_UINT32(cmd_source_0, GPIOSets), | ||
966 | + VMSTATE_UINT32(cmd_source_1, GPIOSets), | ||
967 | + VMSTATE_UINT32(debounce_1, GPIOSets), | ||
968 | + VMSTATE_UINT32(debounce_2, GPIOSets), | ||
969 | + VMSTATE_UINT32(input_mask, GPIOSets), | ||
970 | + VMSTATE_END_OF_LIST(), | ||
971 | + } | ||
289 | +}; | 972 | +}; |
290 | + | 973 | + |
291 | +static void armv7m_ras_register_types(void) | 974 | +static const VMStateDescription vmstate_aspeed_gpio = { |
292 | +{ | 975 | + .name = TYPE_ASPEED_GPIO, |
293 | + type_register_static(&armv7m_ras_info); | 976 | + .version_id = 1, |
294 | +} | 977 | + .minimum_version_id = 1, |
295 | + | 978 | + .fields = (VMStateField[]) { |
296 | +type_init(armv7m_ras_register_types); | 979 | + VMSTATE_STRUCT_ARRAY(sets, AspeedGPIOState, ASPEED_GPIO_MAX_NR_SETS, |
297 | diff --git a/MAINTAINERS b/MAINTAINERS | 980 | + 1, vmstate_gpio_regs, GPIOSets), |
298 | index XXXXXXX..XXXXXXX 100644 | 981 | + VMSTATE_UINT32_ARRAY(debounce_regs, AspeedGPIOState, |
299 | --- a/MAINTAINERS | 982 | + ASPEED_GPIO_NR_DEBOUNCE_REGS), |
300 | +++ b/MAINTAINERS | 983 | + VMSTATE_END_OF_LIST(), |
301 | @@ -XXX,XX +XXX,XX @@ F: hw/intc/gic_internal.h | 984 | + } |
302 | F: hw/misc/a9scu.c | 985 | +}; |
303 | F: hw/misc/arm11scu.c | 986 | + |
304 | F: hw/misc/arm_l2x0.c | 987 | +static void aspeed_gpio_class_init(ObjectClass *klass, void *data) |
305 | +F: hw/misc/armv7m_ras.c | 988 | +{ |
306 | F: hw/timer/a9gtimer* | 989 | + DeviceClass *dc = DEVICE_CLASS(klass); |
307 | F: hw/timer/arm* | 990 | + |
308 | F: include/hw/arm/arm*.h | 991 | + dc->realize = aspeed_gpio_realize; |
309 | @@ -XXX,XX +XXX,XX @@ F: include/hw/misc/arm11scu.h | 992 | + dc->reset = aspeed_gpio_reset; |
310 | F: include/hw/timer/a9gtimer.h | 993 | + dc->desc = "Aspeed GPIO Controller"; |
311 | F: include/hw/timer/arm_mptimer.h | 994 | + dc->vmsd = &vmstate_aspeed_gpio; |
312 | F: include/hw/timer/armv7m_systick.h | 995 | +} |
313 | +F: include/hw/misc/armv7m_ras.h | 996 | + |
314 | F: tests/qtest/test-arm-mptimer.c | 997 | +static void aspeed_gpio_ast2400_class_init(ObjectClass *klass, void *data) |
315 | 998 | +{ | |
316 | Exynos | 999 | + AspeedGPIOClass *agc = ASPEED_GPIO_CLASS(klass); |
317 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build | 1000 | + |
318 | index XXXXXXX..XXXXXXX 100644 | 1001 | + agc->props = ast2400_set_props; |
319 | --- a/hw/misc/meson.build | 1002 | + agc->nr_gpio_pins = 216; |
320 | +++ b/hw/misc/meson.build | 1003 | + agc->nr_gpio_sets = 7; |
321 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_INTEGRATOR_DEBUG', if_true: files('arm_integrator_d | 1004 | + agc->gap = 196; |
322 | softmmu_ss.add(when: 'CONFIG_A9SCU', if_true: files('a9scu.c')) | 1005 | + agc->reg_table = aspeed_3_6v_gpios; |
323 | softmmu_ss.add(when: 'CONFIG_ARM11SCU', if_true: files('arm11scu.c')) | 1006 | +} |
324 | 1007 | + | |
325 | +softmmu_ss.add(when: 'CONFIG_ARM_V7M', if_true: files('armv7m_ras.c')) | 1008 | +static void aspeed_gpio_2500_class_init(ObjectClass *klass, void *data) |
326 | + | 1009 | +{ |
327 | # Mac devices | 1010 | + AspeedGPIOClass *agc = ASPEED_GPIO_CLASS(klass); |
328 | softmmu_ss.add(when: 'CONFIG_MOS6522', if_true: files('mos6522.c')) | 1011 | + |
329 | 1012 | + agc->props = ast2500_set_props; | |
1013 | + agc->nr_gpio_pins = 228; | ||
1014 | + agc->nr_gpio_sets = 8; | ||
1015 | + agc->gap = 220; | ||
1016 | + agc->reg_table = aspeed_3_6v_gpios; | ||
1017 | +} | ||
1018 | + | ||
1019 | +static const TypeInfo aspeed_gpio_info = { | ||
1020 | + .name = TYPE_ASPEED_GPIO, | ||
1021 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
1022 | + .instance_size = sizeof(AspeedGPIOState), | ||
1023 | + .class_size = sizeof(AspeedGPIOClass), | ||
1024 | + .class_init = aspeed_gpio_class_init, | ||
1025 | + .abstract = true, | ||
1026 | +}; | ||
1027 | + | ||
1028 | +static const TypeInfo aspeed_gpio_ast2400_info = { | ||
1029 | + .name = TYPE_ASPEED_GPIO "-ast2400", | ||
1030 | + .parent = TYPE_ASPEED_GPIO, | ||
1031 | + .class_init = aspeed_gpio_ast2400_class_init, | ||
1032 | + .instance_init = aspeed_gpio_init, | ||
1033 | +}; | ||
1034 | + | ||
1035 | +static const TypeInfo aspeed_gpio_ast2500_info = { | ||
1036 | + .name = TYPE_ASPEED_GPIO "-ast2500", | ||
1037 | + .parent = TYPE_ASPEED_GPIO, | ||
1038 | + .class_init = aspeed_gpio_2500_class_init, | ||
1039 | + .instance_init = aspeed_gpio_init, | ||
1040 | +}; | ||
1041 | + | ||
1042 | +static void aspeed_gpio_register_types(void) | ||
1043 | +{ | ||
1044 | + type_register_static(&aspeed_gpio_info); | ||
1045 | + type_register_static(&aspeed_gpio_ast2400_info); | ||
1046 | + type_register_static(&aspeed_gpio_ast2500_info); | ||
1047 | +} | ||
1048 | + | ||
1049 | +type_init(aspeed_gpio_register_types); | ||
330 | -- | 1050 | -- |
331 | 2.20.1 | 1051 | 2.20.1 |
332 | 1052 | ||
333 | 1053 | diff view generated by jsdifflib |
1 | Wire up the refclk for the msf2 SoC. This SoC runs the refclk at a | 1 | From: Rashmica Gupta <rashmica.g@gmail.com> |
---|---|---|---|
2 | frequency which is programmably either /4, /8, /16 or /32 of the main | ||
3 | CPU clock. We don't currently model the register which allows the | ||
4 | guest to set the divisor, so implement the refclk as a fixed /32 of | ||
5 | the CPU clock (which is the value of the divisor at reset). | ||
6 | 2 | ||
3 | Signed-off-by: Rashmica Gupta <rashmica.g@gmail.com> | ||
4 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
5 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
6 | Message-id: 20190904070506.1052-3-clg@kaod.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Damien Hedde <damien.hedde@greensocs.com> | ||
9 | Message-id: 20210812093356.1946-21-peter.maydell@linaro.org | ||
10 | --- | 8 | --- |
11 | include/hw/arm/msf2-soc.h | 1 + | 9 | include/hw/arm/aspeed_soc.h | 3 +++ |
12 | hw/arm/msf2-soc.c | 23 +++++++++++++++++++++++ | 10 | hw/arm/aspeed_soc.c | 17 +++++++++++++++++ |
13 | 2 files changed, 24 insertions(+) | 11 | 2 files changed, 20 insertions(+) |
14 | 12 | ||
15 | diff --git a/include/hw/arm/msf2-soc.h b/include/hw/arm/msf2-soc.h | 13 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h |
16 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/include/hw/arm/msf2-soc.h | 15 | --- a/include/hw/arm/aspeed_soc.h |
18 | +++ b/include/hw/arm/msf2-soc.h | 16 | +++ b/include/hw/arm/aspeed_soc.h |
19 | @@ -XXX,XX +XXX,XX @@ struct MSF2State { | 17 | @@ -XXX,XX +XXX,XX @@ |
20 | uint64_t esram_size; | 18 | #include "hw/watchdog/wdt_aspeed.h" |
21 | 19 | #include "hw/net/ftgmac100.h" | |
22 | Clock *m3clk; | 20 | #include "target/arm/cpu.h" |
23 | + Clock *refclk; | 21 | +#include "hw/gpio/aspeed_gpio.h" |
24 | uint8_t apb0div; | 22 | |
25 | uint8_t apb1div; | 23 | #define ASPEED_SPIS_NUM 2 |
26 | 24 | #define ASPEED_WDTS_NUM 3 | |
27 | diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c | 25 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState { |
26 | AspeedSDMCState sdmc; | ||
27 | AspeedWDTState wdt[ASPEED_WDTS_NUM]; | ||
28 | FTGMAC100State ftgmac100[ASPEED_MACS_NUM]; | ||
29 | + AspeedGPIOState gpio; | ||
30 | } AspeedSoCState; | ||
31 | |||
32 | #define TYPE_ASPEED_SOC "aspeed-soc" | ||
33 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCInfo { | ||
34 | int spis_num; | ||
35 | const char *fmc_typename; | ||
36 | const char **spi_typename; | ||
37 | + const char *gpio_typename; | ||
38 | int wdts_num; | ||
39 | const int *irqmap; | ||
40 | const hwaddr *memmap; | ||
41 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | 42 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/hw/arm/msf2-soc.c | 43 | --- a/hw/arm/aspeed_soc.c |
30 | +++ b/hw/arm/msf2-soc.c | 44 | +++ b/hw/arm/aspeed_soc.c |
31 | @@ -XXX,XX +XXX,XX @@ static void m2sxxx_soc_initfn(Object *obj) | 45 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { |
32 | object_initialize_child(obj, "emac", &s->emac, TYPE_MSS_EMAC); | 46 | .spis_num = 1, |
33 | 47 | .fmc_typename = "aspeed.smc.fmc", | |
34 | s->m3clk = qdev_init_clock_in(DEVICE(obj), "m3clk", NULL, NULL, 0); | 48 | .spi_typename = aspeed_soc_ast2400_typenames, |
35 | + s->refclk = qdev_init_clock_in(DEVICE(obj), "refclk", NULL, NULL, 0); | 49 | + .gpio_typename = "aspeed.gpio-ast2400", |
50 | .wdts_num = 2, | ||
51 | .irqmap = aspeed_soc_ast2400_irqmap, | ||
52 | .memmap = aspeed_soc_ast2400_memmap, | ||
53 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | ||
54 | .spis_num = 1, | ||
55 | .fmc_typename = "aspeed.smc.fmc", | ||
56 | .spi_typename = aspeed_soc_ast2400_typenames, | ||
57 | + .gpio_typename = "aspeed.gpio-ast2400", | ||
58 | .wdts_num = 2, | ||
59 | .irqmap = aspeed_soc_ast2400_irqmap, | ||
60 | .memmap = aspeed_soc_ast2400_memmap, | ||
61 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | ||
62 | .spis_num = 1, | ||
63 | .fmc_typename = "aspeed.smc.fmc", | ||
64 | .spi_typename = aspeed_soc_ast2400_typenames, | ||
65 | + .gpio_typename = "aspeed.gpio-ast2400", | ||
66 | .wdts_num = 2, | ||
67 | .irqmap = aspeed_soc_ast2400_irqmap, | ||
68 | .memmap = aspeed_soc_ast2400_memmap, | ||
69 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | ||
70 | .spis_num = 2, | ||
71 | .fmc_typename = "aspeed.smc.ast2500-fmc", | ||
72 | .spi_typename = aspeed_soc_ast2500_typenames, | ||
73 | + .gpio_typename = "aspeed.gpio-ast2500", | ||
74 | .wdts_num = 3, | ||
75 | .irqmap = aspeed_soc_ast2500_irqmap, | ||
76 | .memmap = aspeed_soc_ast2500_memmap, | ||
77 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | ||
78 | |||
79 | sysbus_init_child_obj(obj, "xdma", OBJECT(&s->xdma), sizeof(s->xdma), | ||
80 | TYPE_ASPEED_XDMA); | ||
81 | + | ||
82 | + sysbus_init_child_obj(obj, "gpio", OBJECT(&s->gpio), sizeof(s->gpio), | ||
83 | + sc->info->gpio_typename); | ||
36 | } | 84 | } |
37 | 85 | ||
38 | static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp) | 86 | static void aspeed_soc_realize(DeviceState *dev, Error **errp) |
39 | @@ -XXX,XX +XXX,XX @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp) | 87 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) |
40 | return; | 88 | sc->info->memmap[ASPEED_XDMA]); |
41 | } | 89 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->xdma), 0, |
42 | 90 | aspeed_soc_get_irq(s, ASPEED_XDMA)); | |
43 | + /* | 91 | + |
44 | + * We use s->refclk internally and only define it with qdev_init_clock_in() | 92 | + /* GPIO */ |
45 | + * so it is correctly parented and not leaked on an init/deinit; it is not | 93 | + object_property_set_bool(OBJECT(&s->gpio), true, "realized", &err); |
46 | + * intended as an externally exposed clock. | 94 | + if (err) { |
47 | + */ | 95 | + error_propagate(errp, err); |
48 | + if (clock_has_source(s->refclk)) { | ||
49 | + error_setg(errp, "refclk must not be wired up by the board code"); | ||
50 | + return; | 96 | + return; |
51 | + } | 97 | + } |
52 | + | 98 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio), 0, sc->info->memmap[ASPEED_GPIO]); |
53 | + /* | 99 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio), 0, |
54 | + * TODO: ideally we should model the SoC SYSTICK_CR register at 0xe0042038, | 100 | + aspeed_soc_get_irq(s, ASPEED_GPIO)); |
55 | + * which allows the guest to program the divisor between the m3clk and | 101 | } |
56 | + * the systick refclk to either /4, /8, /16 or /32, as well as setting | 102 | static Property aspeed_soc_properties[] = { |
57 | + * the value the guest can read in the STCALIB register. Currently we | 103 | DEFINE_PROP_UINT32("num-cpus", AspeedSoCState, num_cpus, 0), |
58 | + * implement the divisor as a fixed /32, which matches the reset value | ||
59 | + * of SYSTICK_CR. | ||
60 | + */ | ||
61 | + clock_set_mul_div(s->refclk, 32, 1); | ||
62 | + clock_set_source(s->refclk, s->m3clk); | ||
63 | + | ||
64 | memory_region_init_rom(&s->nvm, OBJECT(dev_soc), "MSF2.eNVM", s->envm_size, | ||
65 | &error_fatal); | ||
66 | /* | ||
67 | @@ -XXX,XX +XXX,XX @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp) | ||
68 | qdev_prop_set_string(armv7m, "cpu-type", s->cpu_type); | ||
69 | qdev_prop_set_bit(armv7m, "enable-bitband", true); | ||
70 | qdev_connect_clock_in(armv7m, "cpuclk", s->m3clk); | ||
71 | + qdev_connect_clock_in(armv7m, "refclk", s->refclk); | ||
72 | object_property_set_link(OBJECT(&s->armv7m), "memory", | ||
73 | OBJECT(get_system_memory()), &error_abort); | ||
74 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->armv7m), errp)) { | ||
75 | -- | 104 | -- |
76 | 2.20.1 | 105 | 2.20.1 |
77 | 106 | ||
78 | 107 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | 2 | ||
3 | Remove the raspi2/raspi3 machine aliases, | 3 | There are no QEMU Aspeed machines using the SoCs "ast2400-a0" or |
4 | deprecated since commit 155e1c82ed0. | 4 | "ast2400". |
5 | 5 | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 6 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
7 | Message-id: 20210827060815.2384760-3-f4bug@amsat.org | 7 | Message-id: 20190904070506.1052-4-clg@kaod.org |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@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 | docs/about/deprecated.rst | 7 ------- | 11 | hw/arm/aspeed_soc.c | 26 -------------------------- |
12 | docs/about/removed-features.rst | 7 +++++++ | 12 | 1 file changed, 26 deletions(-) |
13 | hw/arm/raspi.c | 2 -- | ||
14 | 3 files changed, 7 insertions(+), 9 deletions(-) | ||
15 | 13 | ||
16 | diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst | 14 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c |
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/docs/about/deprecated.rst | 16 | --- a/hw/arm/aspeed_soc.c |
19 | +++ b/docs/about/deprecated.rst | 17 | +++ b/hw/arm/aspeed_soc.c |
20 | @@ -XXX,XX +XXX,XX @@ this CPU is also deprecated. | 18 | @@ -XXX,XX +XXX,XX @@ static const char *aspeed_soc_ast2500_typenames[] = { |
21 | System emulator machines | 19 | |
22 | ------------------------ | 20 | static const AspeedSoCInfo aspeed_socs[] = { |
23 | 21 | { | |
24 | -Raspberry Pi ``raspi2`` and ``raspi3`` machines (since 5.2) | 22 | - .name = "ast2400-a0", |
25 | -''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | 23 | - .cpu_type = ARM_CPU_TYPE_NAME("arm926"), |
26 | - | 24 | - .silicon_rev = AST2400_A0_SILICON_REV, |
27 | -The Raspberry Pi machines come in various models (A, A+, B, B+). To be able | 25 | - .sram_size = 0x8000, |
28 | -to distinguish which model QEMU is implementing, the ``raspi2`` and ``raspi3`` | 26 | - .spis_num = 1, |
29 | -machines have been renamed ``raspi2b`` and ``raspi3b``. | 27 | - .fmc_typename = "aspeed.smc.fmc", |
30 | - | 28 | - .spi_typename = aspeed_soc_ast2400_typenames, |
31 | Aspeed ``swift-bmc`` machine (since 6.1) | 29 | - .gpio_typename = "aspeed.gpio-ast2400", |
32 | '''''''''''''''''''''''''''''''''''''''' | 30 | - .wdts_num = 2, |
33 | 31 | - .irqmap = aspeed_soc_ast2400_irqmap, | |
34 | diff --git a/docs/about/removed-features.rst b/docs/about/removed-features.rst | 32 | - .memmap = aspeed_soc_ast2400_memmap, |
35 | index XXXXXXX..XXXXXXX 100644 | 33 | - .num_cpus = 1, |
36 | --- a/docs/about/removed-features.rst | 34 | - }, { |
37 | +++ b/docs/about/removed-features.rst | 35 | .name = "ast2400-a1", |
38 | @@ -XXX,XX +XXX,XX @@ This machine has been renamed ``fuloong2e``. | 36 | .cpu_type = ARM_CPU_TYPE_NAME("arm926"), |
39 | These machine types were very old and likely could not be used for live | 37 | .silicon_rev = AST2400_A1_SILICON_REV, |
40 | migration from old QEMU versions anymore. Use a newer machine type instead. | 38 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { |
41 | 39 | .irqmap = aspeed_soc_ast2400_irqmap, | |
42 | +Raspberry Pi ``raspi2`` and ``raspi3`` machines (removed in 6.2) | 40 | .memmap = aspeed_soc_ast2400_memmap, |
43 | +'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | 41 | .num_cpus = 1, |
44 | + | 42 | - }, { |
45 | +The Raspberry Pi machines come in various models (A, A+, B, B+). To be able | 43 | - .name = "ast2400", |
46 | +to distinguish which model QEMU is implementing, the ``raspi2`` and ``raspi3`` | 44 | - .cpu_type = ARM_CPU_TYPE_NAME("arm926"), |
47 | +machines have been renamed ``raspi2b`` and ``raspi3b``. | 45 | - .silicon_rev = AST2400_A0_SILICON_REV, |
48 | + | 46 | - .sram_size = 0x8000, |
49 | 47 | - .spis_num = 1, | |
50 | linux-user mode CPUs | 48 | - .fmc_typename = "aspeed.smc.fmc", |
51 | -------------------- | 49 | - .spi_typename = aspeed_soc_ast2400_typenames, |
52 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | 50 | - .gpio_typename = "aspeed.gpio-ast2400", |
53 | index XXXXXXX..XXXXXXX 100644 | 51 | - .wdts_num = 2, |
54 | --- a/hw/arm/raspi.c | 52 | - .irqmap = aspeed_soc_ast2400_irqmap, |
55 | +++ b/hw/arm/raspi.c | 53 | - .memmap = aspeed_soc_ast2400_memmap, |
56 | @@ -XXX,XX +XXX,XX @@ static void raspi2b_machine_class_init(ObjectClass *oc, void *data) | 54 | - .num_cpus = 1, |
57 | MachineClass *mc = MACHINE_CLASS(oc); | 55 | }, { |
58 | RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc); | 56 | .name = "ast2500-a1", |
59 | 57 | .cpu_type = ARM_CPU_TYPE_NAME("arm1176"), | |
60 | - mc->alias = "raspi2"; | ||
61 | rmc->board_rev = 0xa21041; | ||
62 | raspi_machine_class_common_init(mc, rmc->board_rev); | ||
63 | }; | ||
64 | @@ -XXX,XX +XXX,XX @@ static void raspi3b_machine_class_init(ObjectClass *oc, void *data) | ||
65 | MachineClass *mc = MACHINE_CLASS(oc); | ||
66 | RaspiMachineClass *rmc = RASPI_MACHINE_CLASS(oc); | ||
67 | |||
68 | - mc->alias = "raspi3"; | ||
69 | rmc->board_rev = 0xa02082; | ||
70 | raspi_machine_class_common_init(mc, rmc->board_rev); | ||
71 | }; | ||
72 | -- | 58 | -- |
73 | 2.20.1 | 59 | 2.20.1 |
74 | 60 | ||
75 | 61 | diff view generated by jsdifflib |
1 | Wire up the sysclk input to the armv7m object. | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | 2 | ||
3 | Strictly this SoC should not have a systick device at all, but our | 3 | Improve the naming of the different controller models to ease their |
4 | armv7m container object doesn't currently support disabling the | 4 | generation when initializing the SoC. The rename of the SMC types is |
5 | systick device. For the moment, add a TODO comment, but note that | 5 | breaking migration compatibility. |
6 | this is why we aren't wiring up a refclk (no need for one). | ||
7 | 6 | ||
7 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
8 | Message-id: 20190904070506.1052-5-clg@kaod.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Alexandre Iooss <erdnaxe@crans.org> | ||
10 | Message-id: 20210812093356.1946-16-peter.maydell@linaro.org | ||
11 | --- | 11 | --- |
12 | include/hw/arm/nrf51_soc.h | 2 ++ | 12 | include/hw/arm/aspeed_soc.h | 3 --- |
13 | hw/arm/nrf51_soc.c | 20 ++++++++++++++++++++ | 13 | hw/arm/aspeed_soc.c | 25 ++++++++++++------------- |
14 | 2 files changed, 22 insertions(+) | 14 | hw/ssi/aspeed_smc.c | 12 ++++++------ |
15 | 3 files changed, 18 insertions(+), 22 deletions(-) | ||
15 | 16 | ||
16 | diff --git a/include/hw/arm/nrf51_soc.h b/include/hw/arm/nrf51_soc.h | 17 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h |
17 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/include/hw/arm/nrf51_soc.h | 19 | --- a/include/hw/arm/aspeed_soc.h |
19 | +++ b/include/hw/arm/nrf51_soc.h | 20 | +++ b/include/hw/arm/aspeed_soc.h |
20 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCInfo { |
21 | #include "hw/gpio/nrf51_gpio.h" | 22 | uint32_t silicon_rev; |
22 | #include "hw/nvram/nrf51_nvm.h" | 23 | uint64_t sram_size; |
23 | #include "hw/timer/nrf51_timer.h" | 24 | int spis_num; |
24 | +#include "hw/clock.h" | 25 | - const char *fmc_typename; |
25 | #include "qom/object.h" | 26 | - const char **spi_typename; |
26 | 27 | - const char *gpio_typename; | |
27 | #define TYPE_NRF51_SOC "nrf51-soc" | 28 | int wdts_num; |
28 | @@ -XXX,XX +XXX,XX @@ struct NRF51State { | 29 | const int *irqmap; |
29 | 30 | const hwaddr *memmap; | |
30 | MemoryRegion container; | 31 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c |
31 | |||
32 | + Clock *sysclk; | ||
33 | }; | ||
34 | |||
35 | #endif | ||
36 | diff --git a/hw/arm/nrf51_soc.c b/hw/arm/nrf51_soc.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/hw/arm/nrf51_soc.c | 33 | --- a/hw/arm/aspeed_soc.c |
39 | +++ b/hw/arm/nrf51_soc.c | 34 | +++ b/hw/arm/aspeed_soc.c |
40 | @@ -XXX,XX +XXX,XX @@ | 35 | @@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2400_irqmap[] = { |
41 | #include "qapi/error.h" | 36 | |
42 | #include "hw/arm/boot.h" | 37 | #define aspeed_soc_ast2500_irqmap aspeed_soc_ast2400_irqmap |
43 | #include "hw/sysbus.h" | 38 | |
44 | +#include "hw/qdev-clock.h" | 39 | -static const char *aspeed_soc_ast2400_typenames[] = { "aspeed.smc.spi" }; |
45 | #include "hw/misc/unimp.h" | 40 | -static const char *aspeed_soc_ast2500_typenames[] = { |
46 | #include "qemu/log.h" | 41 | - "aspeed.smc.ast2500-spi1", "aspeed.smc.ast2500-spi2" }; |
47 | 42 | - | |
48 | @@ -XXX,XX +XXX,XX @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp) | 43 | static const AspeedSoCInfo aspeed_socs[] = { |
49 | return; | 44 | { |
45 | .name = "ast2400-a1", | ||
46 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | ||
47 | .silicon_rev = AST2400_A1_SILICON_REV, | ||
48 | .sram_size = 0x8000, | ||
49 | .spis_num = 1, | ||
50 | - .fmc_typename = "aspeed.smc.fmc", | ||
51 | - .spi_typename = aspeed_soc_ast2400_typenames, | ||
52 | - .gpio_typename = "aspeed.gpio-ast2400", | ||
53 | .wdts_num = 2, | ||
54 | .irqmap = aspeed_soc_ast2400_irqmap, | ||
55 | .memmap = aspeed_soc_ast2400_memmap, | ||
56 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | ||
57 | .silicon_rev = AST2500_A1_SILICON_REV, | ||
58 | .sram_size = 0x9000, | ||
59 | .spis_num = 2, | ||
60 | - .fmc_typename = "aspeed.smc.ast2500-fmc", | ||
61 | - .spi_typename = aspeed_soc_ast2500_typenames, | ||
62 | - .gpio_typename = "aspeed.gpio-ast2500", | ||
63 | .wdts_num = 3, | ||
64 | .irqmap = aspeed_soc_ast2500_irqmap, | ||
65 | .memmap = aspeed_soc_ast2500_memmap, | ||
66 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | ||
67 | AspeedSoCState *s = ASPEED_SOC(obj); | ||
68 | AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); | ||
69 | int i; | ||
70 | + char socname[8]; | ||
71 | + char typename[64]; | ||
72 | + | ||
73 | + if (sscanf(sc->info->name, "%7s", socname) != 1) { | ||
74 | + g_assert_not_reached(); | ||
75 | + } | ||
76 | |||
77 | for (i = 0; i < sc->info->num_cpus; i++) { | ||
78 | object_initialize_child(obj, "cpu[*]", OBJECT(&s->cpu[i]), | ||
79 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | ||
80 | sysbus_init_child_obj(obj, "i2c", OBJECT(&s->i2c), sizeof(s->i2c), | ||
81 | TYPE_ASPEED_I2C); | ||
82 | |||
83 | + snprintf(typename, sizeof(typename), "aspeed.fmc-%s", socname); | ||
84 | sysbus_init_child_obj(obj, "fmc", OBJECT(&s->fmc), sizeof(s->fmc), | ||
85 | - sc->info->fmc_typename); | ||
86 | + typename); | ||
87 | object_property_add_alias(obj, "num-cs", OBJECT(&s->fmc), "num-cs", | ||
88 | &error_abort); | ||
89 | |||
90 | for (i = 0; i < sc->info->spis_num; i++) { | ||
91 | + snprintf(typename, sizeof(typename), "aspeed.spi%d-%s", i + 1, socname); | ||
92 | sysbus_init_child_obj(obj, "spi[*]", OBJECT(&s->spi[i]), | ||
93 | - sizeof(s->spi[i]), sc->info->spi_typename[i]); | ||
94 | + sizeof(s->spi[i]), typename); | ||
50 | } | 95 | } |
51 | 96 | ||
52 | + /* | 97 | sysbus_init_child_obj(obj, "sdmc", OBJECT(&s->sdmc), sizeof(s->sdmc), |
53 | + * HCLK on this SoC is fixed, so we set up sysclk ourselves and | 98 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) |
54 | + * the board shouldn't connect it. | 99 | sysbus_init_child_obj(obj, "xdma", OBJECT(&s->xdma), sizeof(s->xdma), |
55 | + */ | 100 | TYPE_ASPEED_XDMA); |
56 | + if (clock_has_source(s->sysclk)) { | 101 | |
57 | + error_setg(errp, "sysclk clock must not be wired up by the board code"); | 102 | + snprintf(typename, sizeof(typename), "aspeed.gpio-%s", socname); |
58 | + return; | 103 | sysbus_init_child_obj(obj, "gpio", OBJECT(&s->gpio), sizeof(s->gpio), |
59 | + } | 104 | - sc->info->gpio_typename); |
60 | + /* This clock doesn't need migration because it is fixed-frequency */ | 105 | + typename); |
61 | + clock_set_hz(s->sysclk, HCLK_FRQ); | ||
62 | + qdev_connect_clock_in(DEVICE(&s->cpu), "cpuclk", s->sysclk); | ||
63 | + /* | ||
64 | + * This SoC has no systick device, so don't connect refclk. | ||
65 | + * TODO: model the lack of systick (currently the armv7m object | ||
66 | + * will always provide one). | ||
67 | + */ | ||
68 | + | ||
69 | system_clock_scale = NANOSECONDS_PER_SECOND / HCLK_FRQ; | ||
70 | |||
71 | object_property_set_link(OBJECT(&s->cpu), "memory", OBJECT(&s->container), | ||
72 | @@ -XXX,XX +XXX,XX @@ static void nrf51_soc_init(Object *obj) | ||
73 | TYPE_NRF51_TIMER); | ||
74 | |||
75 | } | ||
76 | + | ||
77 | + s->sysclk = qdev_init_clock_in(DEVICE(s), "sysclk", NULL, NULL, 0); | ||
78 | } | 106 | } |
79 | 107 | ||
80 | static Property nrf51_soc_properties[] = { | 108 | static void aspeed_soc_realize(DeviceState *dev, Error **errp) |
109 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c | ||
110 | index XXXXXXX..XXXXXXX 100644 | ||
111 | --- a/hw/ssi/aspeed_smc.c | ||
112 | +++ b/hw/ssi/aspeed_smc.c | ||
113 | @@ -XXX,XX +XXX,XX @@ static const AspeedSegments aspeed_segments_ast2500_spi2[] = { | ||
114 | |||
115 | static const AspeedSMCController controllers[] = { | ||
116 | { | ||
117 | - .name = "aspeed.smc.smc", | ||
118 | + .name = "aspeed.smc-ast2400", | ||
119 | .r_conf = R_CONF, | ||
120 | .r_ce_ctrl = R_CE_CTRL, | ||
121 | .r_ctrl0 = R_CTRL0, | ||
122 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
123 | .has_dma = false, | ||
124 | .nregs = ASPEED_SMC_R_SMC_MAX, | ||
125 | }, { | ||
126 | - .name = "aspeed.smc.fmc", | ||
127 | + .name = "aspeed.fmc-ast2400", | ||
128 | .r_conf = R_CONF, | ||
129 | .r_ce_ctrl = R_CE_CTRL, | ||
130 | .r_ctrl0 = R_CTRL0, | ||
131 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
132 | .has_dma = true, | ||
133 | .nregs = ASPEED_SMC_R_MAX, | ||
134 | }, { | ||
135 | - .name = "aspeed.smc.spi", | ||
136 | + .name = "aspeed.spi1-ast2400", | ||
137 | .r_conf = R_SPI_CONF, | ||
138 | .r_ce_ctrl = 0xff, | ||
139 | .r_ctrl0 = R_SPI_CTRL0, | ||
140 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
141 | .has_dma = false, | ||
142 | .nregs = ASPEED_SMC_R_SPI_MAX, | ||
143 | }, { | ||
144 | - .name = "aspeed.smc.ast2500-fmc", | ||
145 | + .name = "aspeed.fmc-ast2500", | ||
146 | .r_conf = R_CONF, | ||
147 | .r_ce_ctrl = R_CE_CTRL, | ||
148 | .r_ctrl0 = R_CTRL0, | ||
149 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
150 | .has_dma = true, | ||
151 | .nregs = ASPEED_SMC_R_MAX, | ||
152 | }, { | ||
153 | - .name = "aspeed.smc.ast2500-spi1", | ||
154 | + .name = "aspeed.spi1-ast2500", | ||
155 | .r_conf = R_CONF, | ||
156 | .r_ce_ctrl = R_CE_CTRL, | ||
157 | .r_ctrl0 = R_CTRL0, | ||
158 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
159 | .has_dma = false, | ||
160 | .nregs = ASPEED_SMC_R_MAX, | ||
161 | }, { | ||
162 | - .name = "aspeed.smc.ast2500-spi2", | ||
163 | + .name = "aspeed.spi2-ast2500", | ||
164 | .r_conf = R_CONF, | ||
165 | .r_ce_ctrl = R_CE_CTRL, | ||
166 | .r_ctrl0 = R_CTRL0, | ||
81 | -- | 167 | -- |
82 | 2.20.1 | 168 | 2.20.1 |
83 | 169 | ||
84 | 170 | diff view generated by jsdifflib |
1 | Instead of passing the MSF2 SoC an integer property specifying the | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | CPU clock rate, pass it a Clock instead. This lets us wire that | 2 | |
3 | clock up to the armv7m object. | 3 | The FMC controller on the Aspeed SoCs support DMA to access the flash |
4 | 4 | modules. It can operate in a normal mode, to copy to or from the flash | |
5 | module mapping window, or in a checksum calculation mode, to evaluate | ||
6 | the best clock settings for reads. | ||
7 | |||
8 | The model introduces two custom address spaces for DMAs: one for the | ||
9 | AHB window of the FMC flash devices and one for the DRAM. The latter | ||
10 | is populated using a "dram" link set from the machine with the RAM | ||
11 | container region. | ||
12 | |||
13 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
14 | Acked-by: Joel Stanley <joel@jms.id.au> | ||
15 | Message-id: 20190904070506.1052-6-clg@kaod.org | ||
16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Alexandre Iooss <erdnaxe@crans.org> | ||
7 | Message-id: 20210812093356.1946-20-peter.maydell@linaro.org | ||
8 | --- | 18 | --- |
9 | include/hw/arm/msf2-soc.h | 3 ++- | 19 | include/hw/ssi/aspeed_smc.h | 6 + |
10 | hw/arm/msf2-soc.c | 28 +++++++++++++++++----------- | 20 | hw/arm/aspeed.c | 2 + |
11 | hw/arm/msf2-som.c | 7 ++++++- | 21 | hw/arm/aspeed_soc.c | 2 + |
12 | 3 files changed, 25 insertions(+), 13 deletions(-) | 22 | hw/ssi/aspeed_smc.c | 222 +++++++++++++++++++++++++++++++++++- |
13 | 23 | 4 files changed, 226 insertions(+), 6 deletions(-) | |
14 | diff --git a/include/hw/arm/msf2-soc.h b/include/hw/arm/msf2-soc.h | 24 | |
25 | diff --git a/include/hw/ssi/aspeed_smc.h b/include/hw/ssi/aspeed_smc.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/include/hw/arm/msf2-soc.h | 27 | --- a/include/hw/ssi/aspeed_smc.h |
17 | +++ b/include/hw/arm/msf2-soc.h | 28 | +++ b/include/hw/ssi/aspeed_smc.h |
29 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSMCController { | ||
30 | hwaddr flash_window_base; | ||
31 | uint32_t flash_window_size; | ||
32 | bool has_dma; | ||
33 | + hwaddr dma_flash_mask; | ||
34 | + hwaddr dma_dram_mask; | ||
35 | uint32_t nregs; | ||
36 | } AspeedSMCController; | ||
37 | |||
38 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSMCState { | ||
39 | /* for DMA support */ | ||
40 | uint64_t sdram_base; | ||
41 | |||
42 | + AddressSpace flash_as; | ||
43 | + MemoryRegion *dram_mr; | ||
44 | + AddressSpace dram_as; | ||
45 | + | ||
46 | AspeedSMCFlash *flashes; | ||
47 | |||
48 | uint8_t snoop_index; | ||
49 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/hw/arm/aspeed.c | ||
52 | +++ b/hw/arm/aspeed.c | ||
53 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | ||
54 | &error_abort); | ||
55 | object_property_set_int(OBJECT(&bmc->soc), machine->smp.cpus, "num-cpus", | ||
56 | &error_abort); | ||
57 | + object_property_set_link(OBJECT(&bmc->soc), OBJECT(&bmc->ram_container), | ||
58 | + "dram", &error_abort); | ||
59 | if (machine->kernel_filename) { | ||
60 | /* | ||
61 | * When booting with a -kernel command line there is no u-boot | ||
62 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/hw/arm/aspeed_soc.c | ||
65 | +++ b/hw/arm/aspeed_soc.c | ||
66 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | ||
67 | typename); | ||
68 | object_property_add_alias(obj, "num-cs", OBJECT(&s->fmc), "num-cs", | ||
69 | &error_abort); | ||
70 | + object_property_add_alias(obj, "dram", OBJECT(&s->fmc), "dram", | ||
71 | + &error_abort); | ||
72 | |||
73 | for (i = 0; i < sc->info->spis_num; i++) { | ||
74 | snprintf(typename, sizeof(typename), "aspeed.spi%d-%s", i + 1, socname); | ||
75 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c | ||
76 | index XXXXXXX..XXXXXXX 100644 | ||
77 | --- a/hw/ssi/aspeed_smc.c | ||
78 | +++ b/hw/ssi/aspeed_smc.c | ||
18 | @@ -XXX,XX +XXX,XX @@ | 79 | @@ -XXX,XX +XXX,XX @@ |
19 | #include "hw/misc/msf2-sysreg.h" | 80 | #include "qemu/log.h" |
20 | #include "hw/ssi/mss-spi.h" | 81 | #include "qemu/module.h" |
21 | #include "hw/net/msf2-emac.h" | 82 | #include "qemu/error-report.h" |
22 | +#include "hw/clock.h" | 83 | +#include "qapi/error.h" |
23 | #include "qom/object.h" | 84 | +#include "exec/address-spaces.h" |
24 | 85 | ||
25 | #define TYPE_MSF2_SOC "msf2-soc" | 86 | #include "hw/irq.h" |
26 | @@ -XXX,XX +XXX,XX @@ struct MSF2State { | 87 | #include "hw/qdev-properties.h" |
27 | uint64_t envm_size; | ||
28 | uint64_t esram_size; | ||
29 | |||
30 | - uint32_t m3clk; | ||
31 | + Clock *m3clk; | ||
32 | uint8_t apb0div; | ||
33 | uint8_t apb1div; | ||
34 | |||
35 | diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/hw/arm/msf2-soc.c | ||
38 | +++ b/hw/arm/msf2-soc.c | ||
39 | @@ -XXX,XX +XXX,XX @@ | 88 | @@ -XXX,XX +XXX,XX @@ |
40 | #include "hw/char/serial.h" | 89 | #define DMA_CTRL_FREQ_SHIFT 4 |
41 | #include "hw/arm/msf2-soc.h" | 90 | #define DMA_CTRL_MODE (1 << 3) |
42 | #include "hw/misc/unimp.h" | 91 | #define DMA_CTRL_CKSUM (1 << 2) |
43 | +#include "hw/qdev-clock.h" | 92 | -#define DMA_CTRL_DIR (1 << 1) |
44 | #include "sysemu/sysemu.h" | 93 | -#define DMA_CTRL_EN (1 << 0) |
45 | 94 | +#define DMA_CTRL_WRITE (1 << 1) | |
46 | #define MSF2_TIMER_BASE 0x40004000 | 95 | +#define DMA_CTRL_ENABLE (1 << 0) |
47 | @@ -XXX,XX +XXX,XX @@ static void m2sxxx_soc_initfn(Object *obj) | 96 | |
97 | /* DMA Flash Side Address */ | ||
98 | #define R_DMA_FLASH_ADDR (0x84 / 4) | ||
99 | @@ -XXX,XX +XXX,XX @@ | ||
100 | #define ASPEED_SOC_SPI_FLASH_BASE 0x30000000 | ||
101 | #define ASPEED_SOC_SPI2_FLASH_BASE 0x38000000 | ||
102 | |||
103 | +/* | ||
104 | + * DMA DRAM addresses should be 4 bytes aligned and the valid address | ||
105 | + * range is 0x40000000 - 0x5FFFFFFF (AST2400) | ||
106 | + * 0x80000000 - 0xBFFFFFFF (AST2500) | ||
107 | + * | ||
108 | + * DMA flash addresses should be 4 bytes aligned and the valid address | ||
109 | + * range is 0x20000000 - 0x2FFFFFFF. | ||
110 | + * | ||
111 | + * DMA length is from 4 bytes to 32MB | ||
112 | + * 0: 4 bytes | ||
113 | + * 0x7FFFFF: 32M bytes | ||
114 | + */ | ||
115 | +#define DMA_DRAM_ADDR(s, val) ((s)->sdram_base | \ | ||
116 | + ((val) & (s)->ctrl->dma_dram_mask)) | ||
117 | +#define DMA_FLASH_ADDR(s, val) ((s)->ctrl->flash_window_base | \ | ||
118 | + ((val) & (s)->ctrl->dma_flash_mask)) | ||
119 | +#define DMA_LENGTH(val) ((val) & 0x01FFFFFC) | ||
120 | + | ||
121 | /* Flash opcodes. */ | ||
122 | #define SPI_OP_READ 0x03 /* Read data bytes (low frequency) */ | ||
123 | |||
124 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
125 | .flash_window_base = ASPEED_SOC_FMC_FLASH_BASE, | ||
126 | .flash_window_size = 0x10000000, | ||
127 | .has_dma = true, | ||
128 | + .dma_flash_mask = 0x0FFFFFFC, | ||
129 | + .dma_dram_mask = 0x1FFFFFFC, | ||
130 | .nregs = ASPEED_SMC_R_MAX, | ||
131 | }, { | ||
132 | .name = "aspeed.spi1-ast2400", | ||
133 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
134 | .flash_window_base = ASPEED_SOC_FMC_FLASH_BASE, | ||
135 | .flash_window_size = 0x10000000, | ||
136 | .has_dma = true, | ||
137 | + .dma_flash_mask = 0x0FFFFFFC, | ||
138 | + .dma_dram_mask = 0x3FFFFFFC, | ||
139 | .nregs = ASPEED_SMC_R_MAX, | ||
140 | }, { | ||
141 | .name = "aspeed.spi1-ast2500", | ||
142 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_reset(DeviceState *d) | ||
143 | |||
144 | memset(s->regs, 0, sizeof s->regs); | ||
145 | |||
146 | - /* Pretend DMA is done (u-boot initialization) */ | ||
147 | - s->regs[R_INTR_CTRL] = INTR_CTRL_DMA_STATUS; | ||
148 | - | ||
149 | /* Unselect all slaves */ | ||
150 | for (i = 0; i < s->num_cs; ++i) { | ||
151 | s->regs[s->r_ctrl0 + i] |= CTRL_CE_STOP_ACTIVE; | ||
152 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_smc_read(void *opaque, hwaddr addr, unsigned int size) | ||
153 | addr == s->r_ce_ctrl || | ||
154 | addr == R_INTR_CTRL || | ||
155 | addr == R_DUMMY_DATA || | ||
156 | + (s->ctrl->has_dma && addr == R_DMA_CTRL) || | ||
157 | + (s->ctrl->has_dma && addr == R_DMA_FLASH_ADDR) || | ||
158 | + (s->ctrl->has_dma && addr == R_DMA_DRAM_ADDR) || | ||
159 | + (s->ctrl->has_dma && addr == R_DMA_LEN) || | ||
160 | + (s->ctrl->has_dma && addr == R_DMA_CHECKSUM) || | ||
161 | (addr >= R_SEG_ADDR0 && addr < R_SEG_ADDR0 + s->ctrl->max_slaves) || | ||
162 | (addr >= s->r_ctrl0 && addr < s->r_ctrl0 + s->ctrl->max_slaves)) { | ||
163 | return s->regs[addr]; | ||
164 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_smc_read(void *opaque, hwaddr addr, unsigned int size) | ||
48 | } | 165 | } |
49 | |||
50 | object_initialize_child(obj, "emac", &s->emac, TYPE_MSS_EMAC); | ||
51 | + | ||
52 | + s->m3clk = qdev_init_clock_in(DEVICE(obj), "m3clk", NULL, NULL, 0); | ||
53 | } | 166 | } |
54 | 167 | ||
55 | static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp) | 168 | +/* |
56 | @@ -XXX,XX +XXX,XX @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp) | 169 | + * Accumulate the result of the reads to provide a checksum that will |
57 | 170 | + * be used to validate the read timing settings. | |
58 | MemoryRegion *system_memory = get_system_memory(); | 171 | + */ |
59 | 172 | +static void aspeed_smc_dma_checksum(AspeedSMCState *s) | |
60 | + if (!clock_has_source(s->m3clk)) { | 173 | +{ |
61 | + error_setg(errp, "m3clk must be wired up by the board code"); | 174 | + MemTxResult result; |
175 | + uint32_t data; | ||
176 | + | ||
177 | + if (s->regs[R_DMA_CTRL] & DMA_CTRL_WRITE) { | ||
178 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
179 | + "%s: invalid direction for DMA checksum\n", __func__); | ||
62 | + return; | 180 | + return; |
63 | + } | 181 | + } |
64 | + | 182 | + |
65 | memory_region_init_rom(&s->nvm, OBJECT(dev_soc), "MSF2.eNVM", s->envm_size, | 183 | + while (s->regs[R_DMA_LEN]) { |
66 | &error_fatal); | 184 | + data = address_space_ldl_le(&s->flash_as, s->regs[R_DMA_FLASH_ADDR], |
67 | /* | 185 | + MEMTXATTRS_UNSPECIFIED, &result); |
68 | @@ -XXX,XX +XXX,XX @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp) | 186 | + if (result != MEMTX_OK) { |
69 | qdev_prop_set_uint32(armv7m, "num-irq", 81); | 187 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Flash read failed @%08x\n", |
70 | qdev_prop_set_string(armv7m, "cpu-type", s->cpu_type); | 188 | + __func__, s->regs[R_DMA_FLASH_ADDR]); |
71 | qdev_prop_set_bit(armv7m, "enable-bitband", true); | 189 | + return; |
72 | + qdev_connect_clock_in(armv7m, "cpuclk", s->m3clk); | 190 | + } |
73 | object_property_set_link(OBJECT(&s->armv7m), "memory", | 191 | + |
74 | OBJECT(get_system_memory()), &error_abort); | 192 | + /* |
75 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->armv7m), errp)) { | 193 | + * When the DMA is on-going, the DMA registers are updated |
76 | return; | 194 | + * with the current working addresses and length. |
195 | + */ | ||
196 | + s->regs[R_DMA_CHECKSUM] += data; | ||
197 | + s->regs[R_DMA_FLASH_ADDR] += 4; | ||
198 | + s->regs[R_DMA_LEN] -= 4; | ||
199 | + } | ||
200 | +} | ||
201 | + | ||
202 | +static void aspeed_smc_dma_rw(AspeedSMCState *s) | ||
203 | +{ | ||
204 | + MemTxResult result; | ||
205 | + uint32_t data; | ||
206 | + | ||
207 | + while (s->regs[R_DMA_LEN]) { | ||
208 | + if (s->regs[R_DMA_CTRL] & DMA_CTRL_WRITE) { | ||
209 | + data = address_space_ldl_le(&s->dram_as, s->regs[R_DMA_DRAM_ADDR], | ||
210 | + MEMTXATTRS_UNSPECIFIED, &result); | ||
211 | + if (result != MEMTX_OK) { | ||
212 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: DRAM read failed @%08x\n", | ||
213 | + __func__, s->regs[R_DMA_DRAM_ADDR]); | ||
214 | + return; | ||
215 | + } | ||
216 | + | ||
217 | + address_space_stl_le(&s->flash_as, s->regs[R_DMA_FLASH_ADDR], | ||
218 | + data, MEMTXATTRS_UNSPECIFIED, &result); | ||
219 | + if (result != MEMTX_OK) { | ||
220 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Flash write failed @%08x\n", | ||
221 | + __func__, s->regs[R_DMA_FLASH_ADDR]); | ||
222 | + return; | ||
223 | + } | ||
224 | + } else { | ||
225 | + data = address_space_ldl_le(&s->flash_as, s->regs[R_DMA_FLASH_ADDR], | ||
226 | + MEMTXATTRS_UNSPECIFIED, &result); | ||
227 | + if (result != MEMTX_OK) { | ||
228 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Flash read failed @%08x\n", | ||
229 | + __func__, s->regs[R_DMA_FLASH_ADDR]); | ||
230 | + return; | ||
231 | + } | ||
232 | + | ||
233 | + address_space_stl_le(&s->dram_as, s->regs[R_DMA_DRAM_ADDR], | ||
234 | + data, MEMTXATTRS_UNSPECIFIED, &result); | ||
235 | + if (result != MEMTX_OK) { | ||
236 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: DRAM write failed @%08x\n", | ||
237 | + __func__, s->regs[R_DMA_DRAM_ADDR]); | ||
238 | + return; | ||
239 | + } | ||
240 | + } | ||
241 | + | ||
242 | + /* | ||
243 | + * When the DMA is on-going, the DMA registers are updated | ||
244 | + * with the current working addresses and length. | ||
245 | + */ | ||
246 | + s->regs[R_DMA_FLASH_ADDR] += 4; | ||
247 | + s->regs[R_DMA_DRAM_ADDR] += 4; | ||
248 | + s->regs[R_DMA_LEN] -= 4; | ||
249 | + } | ||
250 | +} | ||
251 | + | ||
252 | +static void aspeed_smc_dma_stop(AspeedSMCState *s) | ||
253 | +{ | ||
254 | + /* | ||
255 | + * When the DMA is disabled, INTR_CTRL_DMA_STATUS=0 means the | ||
256 | + * engine is idle | ||
257 | + */ | ||
258 | + s->regs[R_INTR_CTRL] &= ~INTR_CTRL_DMA_STATUS; | ||
259 | + s->regs[R_DMA_CHECKSUM] = 0; | ||
260 | + | ||
261 | + /* | ||
262 | + * Lower the DMA irq in any case. The IRQ control register could | ||
263 | + * have been cleared before disabling the DMA. | ||
264 | + */ | ||
265 | + qemu_irq_lower(s->irq); | ||
266 | +} | ||
267 | + | ||
268 | +/* | ||
269 | + * When INTR_CTRL_DMA_STATUS=1, the DMA has completed and a new DMA | ||
270 | + * can start even if the result of the previous was not collected. | ||
271 | + */ | ||
272 | +static bool aspeed_smc_dma_in_progress(AspeedSMCState *s) | ||
273 | +{ | ||
274 | + return s->regs[R_DMA_CTRL] & DMA_CTRL_ENABLE && | ||
275 | + !(s->regs[R_INTR_CTRL] & INTR_CTRL_DMA_STATUS); | ||
276 | +} | ||
277 | + | ||
278 | +static void aspeed_smc_dma_done(AspeedSMCState *s) | ||
279 | +{ | ||
280 | + s->regs[R_INTR_CTRL] |= INTR_CTRL_DMA_STATUS; | ||
281 | + if (s->regs[R_INTR_CTRL] & INTR_CTRL_DMA_EN) { | ||
282 | + qemu_irq_raise(s->irq); | ||
283 | + } | ||
284 | +} | ||
285 | + | ||
286 | +static void aspeed_smc_dma_ctrl(AspeedSMCState *s, uint64_t dma_ctrl) | ||
287 | +{ | ||
288 | + if (!(dma_ctrl & DMA_CTRL_ENABLE)) { | ||
289 | + s->regs[R_DMA_CTRL] = dma_ctrl; | ||
290 | + | ||
291 | + aspeed_smc_dma_stop(s); | ||
292 | + return; | ||
293 | + } | ||
294 | + | ||
295 | + if (aspeed_smc_dma_in_progress(s)) { | ||
296 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: DMA in progress\n", __func__); | ||
297 | + return; | ||
298 | + } | ||
299 | + | ||
300 | + s->regs[R_DMA_CTRL] = dma_ctrl; | ||
301 | + | ||
302 | + if (s->regs[R_DMA_CTRL] & DMA_CTRL_CKSUM) { | ||
303 | + aspeed_smc_dma_checksum(s); | ||
304 | + } else { | ||
305 | + aspeed_smc_dma_rw(s); | ||
306 | + } | ||
307 | + | ||
308 | + aspeed_smc_dma_done(s); | ||
309 | +} | ||
310 | + | ||
311 | static void aspeed_smc_write(void *opaque, hwaddr addr, uint64_t data, | ||
312 | unsigned int size) | ||
313 | { | ||
314 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_write(void *opaque, hwaddr addr, uint64_t data, | ||
315 | } | ||
316 | } else if (addr == R_DUMMY_DATA) { | ||
317 | s->regs[addr] = value & 0xff; | ||
318 | + } else if (addr == R_INTR_CTRL) { | ||
319 | + s->regs[addr] = value; | ||
320 | + } else if (s->ctrl->has_dma && addr == R_DMA_CTRL) { | ||
321 | + aspeed_smc_dma_ctrl(s, value); | ||
322 | + } else if (s->ctrl->has_dma && addr == R_DMA_DRAM_ADDR) { | ||
323 | + s->regs[addr] = DMA_DRAM_ADDR(s, value); | ||
324 | + } else if (s->ctrl->has_dma && addr == R_DMA_FLASH_ADDR) { | ||
325 | + s->regs[addr] = DMA_FLASH_ADDR(s, value); | ||
326 | + } else if (s->ctrl->has_dma && addr == R_DMA_LEN) { | ||
327 | + s->regs[addr] = DMA_LENGTH(value); | ||
328 | } else { | ||
329 | qemu_log_mask(LOG_UNIMP, "%s: not implemented: 0x%" HWADDR_PRIx "\n", | ||
330 | __func__, addr); | ||
331 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps aspeed_smc_ops = { | ||
332 | .valid.unaligned = true, | ||
333 | }; | ||
334 | |||
335 | + | ||
336 | +/* | ||
337 | + * Initialize the custom address spaces for DMAs | ||
338 | + */ | ||
339 | +static void aspeed_smc_dma_setup(AspeedSMCState *s, Error **errp) | ||
340 | +{ | ||
341 | + char *name; | ||
342 | + | ||
343 | + if (!s->dram_mr) { | ||
344 | + error_setg(errp, TYPE_ASPEED_SMC ": 'dram' link not set"); | ||
345 | + return; | ||
346 | + } | ||
347 | + | ||
348 | + name = g_strdup_printf("%s-dma-flash", s->ctrl->name); | ||
349 | + address_space_init(&s->flash_as, &s->mmio_flash, name); | ||
350 | + g_free(name); | ||
351 | + | ||
352 | + name = g_strdup_printf("%s-dma-dram", s->ctrl->name); | ||
353 | + address_space_init(&s->dram_as, s->dram_mr, name); | ||
354 | + g_free(name); | ||
355 | +} | ||
356 | + | ||
357 | static void aspeed_smc_realize(DeviceState *dev, Error **errp) | ||
358 | { | ||
359 | SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
360 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_realize(DeviceState *dev, Error **errp) | ||
361 | s->num_cs = s->ctrl->max_slaves; | ||
77 | } | 362 | } |
78 | 363 | ||
79 | - if (!s->m3clk) { | 364 | + /* DMA irq. Keep it first for the initialization in the SoC */ |
80 | - error_setg(errp, "Invalid m3clk value"); | 365 | + sysbus_init_irq(sbd, &s->irq); |
81 | - error_append_hint(errp, "m3clk can not be zero\n"); | 366 | + |
82 | - return; | 367 | s->spi = ssi_create_bus(dev, "spi"); |
83 | - } | 368 | |
84 | - | 369 | /* Setup cs_lines for slaves */ |
85 | - system_clock_scale = NANOSECONDS_PER_SECOND / s->m3clk; | 370 | - sysbus_init_irq(sbd, &s->irq); |
86 | + system_clock_scale = clock_ticks_to_ns(s->m3clk, 1); | 371 | s->cs_lines = g_new0(qemu_irq, s->num_cs); |
87 | 372 | ssi_auto_connect_slaves(dev, s->cs_lines, s->spi); | |
88 | for (i = 0; i < MSF2_NUM_UARTS; i++) { | 373 | |
89 | if (serial_hd(i)) { | 374 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_realize(DeviceState *dev, Error **errp) |
90 | @@ -XXX,XX +XXX,XX @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp) | 375 | memory_region_add_subregion(&s->mmio_flash, offset, &fl->mmio); |
376 | offset += fl->size; | ||
91 | } | 377 | } |
92 | 378 | + | |
93 | dev = DEVICE(&s->timer); | 379 | + /* DMA support */ |
94 | - /* APB0 clock is the timer input clock */ | 380 | + if (s->ctrl->has_dma) { |
95 | - qdev_prop_set_uint32(dev, "clock-frequency", s->m3clk / s->apb0div); | 381 | + aspeed_smc_dma_setup(s, errp); |
96 | + /* | 382 | + } |
97 | + * APB0 clock is the timer input clock. | 383 | } |
98 | + * TODO: ideally the MSF2 timer device should use a Clock rather than a | 384 | |
99 | + * clock-frequency integer property. | 385 | static const VMStateDescription vmstate_aspeed_smc = { |
100 | + */ | 386 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_aspeed_smc = { |
101 | + qdev_prop_set_uint32(dev, "clock-frequency", | 387 | static Property aspeed_smc_properties[] = { |
102 | + clock_get_hz(s->m3clk) / s->apb0div); | 388 | DEFINE_PROP_UINT32("num-cs", AspeedSMCState, num_cs, 1), |
103 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->timer), errp)) { | 389 | DEFINE_PROP_UINT64("sdram-base", AspeedSMCState, sdram_base, 0), |
104 | return; | 390 | + DEFINE_PROP_LINK("dram", AspeedSMCState, dram_mr, |
105 | } | 391 | + TYPE_MEMORY_REGION, MemoryRegion *), |
106 | @@ -XXX,XX +XXX,XX @@ static Property m2sxxx_soc_properties[] = { | 392 | DEFINE_PROP_END_OF_LIST(), |
107 | DEFINE_PROP_UINT64("eNVM-size", MSF2State, envm_size, MSF2_ENVM_MAX_SIZE), | 393 | }; |
108 | DEFINE_PROP_UINT64("eSRAM-size", MSF2State, esram_size, | ||
109 | MSF2_ESRAM_MAX_SIZE), | ||
110 | - /* Libero GUI shows 100Mhz as default for clocks */ | ||
111 | - DEFINE_PROP_UINT32("m3clk", MSF2State, m3clk, 100 * 1000000), | ||
112 | /* default divisors in Libero GUI */ | ||
113 | DEFINE_PROP_UINT8("apb0div", MSF2State, apb0div, 2), | ||
114 | DEFINE_PROP_UINT8("apb1div", MSF2State, apb1div, 2), | ||
115 | diff --git a/hw/arm/msf2-som.c b/hw/arm/msf2-som.c | ||
116 | index XXXXXXX..XXXXXXX 100644 | ||
117 | --- a/hw/arm/msf2-som.c | ||
118 | +++ b/hw/arm/msf2-som.c | ||
119 | @@ -XXX,XX +XXX,XX @@ | ||
120 | #include "hw/boards.h" | ||
121 | #include "hw/qdev-properties.h" | ||
122 | #include "hw/arm/boot.h" | ||
123 | +#include "hw/qdev-clock.h" | ||
124 | #include "exec/address-spaces.h" | ||
125 | #include "hw/arm/msf2-soc.h" | ||
126 | |||
127 | @@ -XXX,XX +XXX,XX @@ static void emcraft_sf2_s2s010_init(MachineState *machine) | ||
128 | BusState *spi_bus; | ||
129 | MemoryRegion *sysmem = get_system_memory(); | ||
130 | MemoryRegion *ddr = g_new(MemoryRegion, 1); | ||
131 | + Clock *m3clk; | ||
132 | |||
133 | if (strcmp(machine->cpu_type, mc->default_cpu_type) != 0) { | ||
134 | error_report("This board can only be used with CPU %s", | ||
135 | @@ -XXX,XX +XXX,XX @@ static void emcraft_sf2_s2s010_init(MachineState *machine) | ||
136 | * in Libero. CPU clock is divided by APB0 and APB1 divisors for | ||
137 | * peripherals. Emcraft's SoM kit comes with these settings by default. | ||
138 | */ | ||
139 | - qdev_prop_set_uint32(dev, "m3clk", 142 * 1000000); | ||
140 | + /* This clock doesn't need migration because it is fixed-frequency */ | ||
141 | + m3clk = clock_new(OBJECT(machine), "m3clk"); | ||
142 | + clock_set_hz(m3clk, 142 * 1000000); | ||
143 | + qdev_connect_clock_in(dev, "m3clk", m3clk); | ||
144 | qdev_prop_set_uint32(dev, "apb0div", 2); | ||
145 | qdev_prop_set_uint32(dev, "apb1div", 2); | ||
146 | 394 | ||
147 | -- | 395 | -- |
148 | 2.20.1 | 396 | 2.20.1 |
149 | 397 | ||
150 | 398 | diff view generated by jsdifflib |
1 | Now that all users of the systick devices wire up the clock inputs, | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | use those instead of the system_clock_scale and the hardwired 1MHz | ||
3 | value for the reference clock. | ||
4 | 2 | ||
5 | This will fix various board models where we were incorrectly | 3 | When doing calibration, the SPI clock rate in the CE0 Control Register |
6 | providing a 1MHz reference clock instead of some other value or | 4 | and the read delay cycles in the Read Timing Compensation Register are |
7 | instead of providing no reference clock at all. | 5 | set using bit[11:4] of the DMA Control Register. |
8 | 6 | ||
7 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
8 | Acked-by: Joel Stanley <joel@jms.id.au> | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Message-id: 20190904070506.1052-7-clg@kaod.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Damien Hedde <damien.hedde@greensocs.com> | ||
11 | Message-id: 20210812093356.1946-22-peter.maydell@linaro.org | ||
12 | --- | 12 | --- |
13 | hw/timer/armv7m_systick.c | 112 ++++++++++++++++++++++++++++---------- | 13 | hw/ssi/aspeed_smc.c | 64 ++++++++++++++++++++++++++++++++++++++++++++- |
14 | 1 file changed, 84 insertions(+), 28 deletions(-) | 14 | 1 file changed, 63 insertions(+), 1 deletion(-) |
15 | 15 | ||
16 | diff --git a/hw/timer/armv7m_systick.c b/hw/timer/armv7m_systick.c | 16 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c |
17 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/timer/armv7m_systick.c | 18 | --- a/hw/ssi/aspeed_smc.c |
19 | +++ b/hw/timer/armv7m_systick.c | 19 | +++ b/hw/ssi/aspeed_smc.c |
20 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ |
21 | #include "qemu/timer.h" | 21 | #define CTRL_CMD_MASK 0xff |
22 | #include "qemu/log.h" | 22 | #define CTRL_DUMMY_HIGH_SHIFT 14 |
23 | #include "qemu/module.h" | 23 | #define CTRL_AST2400_SPI_4BYTE (1 << 13) |
24 | +#include "qapi/error.h" | 24 | +#define CE_CTRL_CLOCK_FREQ_SHIFT 8 |
25 | #include "trace.h" | 25 | +#define CE_CTRL_CLOCK_FREQ_MASK 0xf |
26 | 26 | +#define CE_CTRL_CLOCK_FREQ(div) \ | |
27 | -/* qemu timers run at 1GHz. We want something closer to 1MHz. */ | 27 | + (((div) & CE_CTRL_CLOCK_FREQ_MASK) << CE_CTRL_CLOCK_FREQ_SHIFT) |
28 | -#define SYSTICK_SCALE 1000ULL | 28 | #define CTRL_DUMMY_LOW_SHIFT 6 /* 2 bits [7:6] */ |
29 | - | 29 | #define CTRL_CE_STOP_ACTIVE (1 << 2) |
30 | #define SYSTICK_ENABLE (1 << 0) | 30 | #define CTRL_CMD_MODE_MASK 0x3 |
31 | #define SYSTICK_TICKINT (1 << 1) | 31 | @@ -XXX,XX +XXX,XX @@ |
32 | #define SYSTICK_CLKSOURCE (1 << 2) | 32 | #define DMA_CTRL_DELAY_SHIFT 8 |
33 | #define SYSTICK_COUNTFLAG (1 << 16) | 33 | #define DMA_CTRL_FREQ_MASK 0xf |
34 | 34 | #define DMA_CTRL_FREQ_SHIFT 4 | |
35 | +#define SYSCALIB_NOREF (1U << 31) | 35 | -#define DMA_CTRL_MODE (1 << 3) |
36 | +#define SYSCALIB_SKEW (1U << 30) | 36 | +#define DMA_CTRL_CALIB (1 << 3) |
37 | +#define SYSCALIB_TENMS ((1U << 24) - 1) | 37 | #define DMA_CTRL_CKSUM (1 << 2) |
38 | + | 38 | #define DMA_CTRL_WRITE (1 << 1) |
39 | int system_clock_scale; | 39 | #define DMA_CTRL_ENABLE (1 << 0) |
40 | 40 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_smc_read(void *opaque, hwaddr addr, unsigned int size) | |
41 | -/* Conversion factor from qemu timer to SysTick frequencies. */ | ||
42 | -static inline int64_t systick_scale(SysTickState *s) | ||
43 | +static void systick_set_period_from_clock(SysTickState *s) | ||
44 | { | ||
45 | + /* | ||
46 | + * Set the ptimer period from whichever clock is selected. | ||
47 | + * Must be called from within a ptimer transaction block. | ||
48 | + */ | ||
49 | if (s->control & SYSTICK_CLKSOURCE) { | ||
50 | - return system_clock_scale; | ||
51 | + ptimer_set_period_from_clock(s->ptimer, s->cpuclk, 1); | ||
52 | } else { | ||
53 | - return 1000; | ||
54 | + ptimer_set_period_from_clock(s->ptimer, s->refclk, 1); | ||
55 | } | 41 | } |
56 | } | 42 | } |
57 | 43 | ||
58 | @@ -XXX,XX +XXX,XX @@ static MemTxResult systick_read(void *opaque, hwaddr addr, uint64_t *data, | 44 | +static uint8_t aspeed_smc_hclk_divisor(uint8_t hclk_mask) |
59 | val = ptimer_get_count(s->ptimer); | 45 | +{ |
60 | break; | 46 | + /* HCLK/1 .. HCLK/16 */ |
61 | case 0xc: /* SysTick Calibration Value. */ | 47 | + const uint8_t hclk_divisors[] = { |
62 | - val = 10000; | 48 | + 15, 7, 14, 6, 13, 5, 12, 4, 11, 3, 10, 2, 9, 1, 8, 0 |
63 | + /* | 49 | + }; |
64 | + * In real hardware it is possible to make this register report | 50 | + int i; |
65 | + * a different value from what the reference clock is actually | 51 | + |
66 | + * running at. We don't model that (which usually happens due | 52 | + for (i = 0; i < ARRAY_SIZE(hclk_divisors); i++) { |
67 | + * to integration errors in the real hardware) and instead always | 53 | + if (hclk_mask == hclk_divisors[i]) { |
68 | + * report the theoretical correct value as described in the | 54 | + return i + 1; |
69 | + * knowledgebase article at | ||
70 | + * https://developer.arm.com/documentation/ka001325/latest | ||
71 | + * If necessary, we could implement an extra QOM property on this | ||
72 | + * device to force the STCALIB value to something different from | ||
73 | + * the "correct" value. | ||
74 | + */ | ||
75 | + if (!clock_has_source(s->refclk)) { | ||
76 | + val = SYSCALIB_NOREF; | ||
77 | + break; | ||
78 | + } | 55 | + } |
79 | + val = clock_ns_to_ticks(s->refclk, 10 * SCALE_MS) - 1; | 56 | + } |
80 | + val &= SYSCALIB_TENMS; | ||
81 | + if (clock_ticks_to_ns(s->refclk, val + 1) != 10 * SCALE_MS) { | ||
82 | + /* report that tick count does not yield exactly 10ms */ | ||
83 | + val |= SYSCALIB_SKEW; | ||
84 | + } | ||
85 | break; | ||
86 | default: | ||
87 | val = 0; | ||
88 | @@ -XXX,XX +XXX,XX @@ static MemTxResult systick_write(void *opaque, hwaddr addr, | ||
89 | { | ||
90 | uint32_t oldval; | ||
91 | |||
92 | + if (!clock_has_source(s->refclk)) { | ||
93 | + /* This bit is always 1 if there is no external refclk */ | ||
94 | + value |= SYSTICK_CLKSOURCE; | ||
95 | + } | ||
96 | + | 57 | + |
97 | ptimer_transaction_begin(s->ptimer); | 58 | + qemu_log_mask(LOG_GUEST_ERROR, "invalid HCLK mask %x", hclk_mask); |
98 | oldval = s->control; | 59 | + return 0; |
99 | s->control &= 0xfffffff8; | ||
100 | @@ -XXX,XX +XXX,XX @@ static MemTxResult systick_write(void *opaque, hwaddr addr, | ||
101 | |||
102 | if ((oldval ^ value) & SYSTICK_ENABLE) { | ||
103 | if (value & SYSTICK_ENABLE) { | ||
104 | - /* | ||
105 | - * Always reload the period in case board code has | ||
106 | - * changed system_clock_scale. If we ever replace that | ||
107 | - * global with a more sensible API then we might be able | ||
108 | - * to set the period only when it actually changes. | ||
109 | - */ | ||
110 | - ptimer_set_period(s->ptimer, systick_scale(s)); | ||
111 | ptimer_run(s->ptimer, 0); | ||
112 | } else { | ||
113 | ptimer_stop(s->ptimer); | ||
114 | } | ||
115 | - } else if ((oldval ^ value) & SYSTICK_CLKSOURCE) { | ||
116 | - ptimer_set_period(s->ptimer, systick_scale(s)); | ||
117 | + } | ||
118 | + | ||
119 | + if ((oldval ^ value) & SYSTICK_CLKSOURCE) { | ||
120 | + systick_set_period_from_clock(s); | ||
121 | } | ||
122 | ptimer_transaction_commit(s->ptimer); | ||
123 | break; | ||
124 | @@ -XXX,XX +XXX,XX @@ static void systick_reset(DeviceState *dev) | ||
125 | { | ||
126 | SysTickState *s = SYSTICK(dev); | ||
127 | |||
128 | - /* | ||
129 | - * Forgetting to set system_clock_scale is always a board code | ||
130 | - * bug. We can't check this earlier because for some boards | ||
131 | - * (like stellaris) it is not yet configured at the point where | ||
132 | - * the systick device is realized. | ||
133 | - */ | ||
134 | - assert(system_clock_scale != 0); | ||
135 | - | ||
136 | ptimer_transaction_begin(s->ptimer); | ||
137 | s->control = 0; | ||
138 | + if (!clock_has_source(s->refclk)) { | ||
139 | + /* This bit is always 1 if there is no external refclk */ | ||
140 | + s->control |= SYSTICK_CLKSOURCE; | ||
141 | + } | ||
142 | ptimer_stop(s->ptimer); | ||
143 | ptimer_set_count(s->ptimer, 0); | ||
144 | ptimer_set_limit(s->ptimer, 0, 0); | ||
145 | - ptimer_set_period(s->ptimer, systick_scale(s)); | ||
146 | + systick_set_period_from_clock(s); | ||
147 | + ptimer_transaction_commit(s->ptimer); | ||
148 | +} | 60 | +} |
149 | + | 61 | + |
150 | +static void systick_cpuclk_update(void *opaque, ClockEvent event) | 62 | +/* |
63 | + * When doing calibration, the SPI clock rate in the CE0 Control | ||
64 | + * Register and the read delay cycles in the Read Timing Compensation | ||
65 | + * Register are set using bit[11:4] of the DMA Control Register. | ||
66 | + */ | ||
67 | +static void aspeed_smc_dma_calibration(AspeedSMCState *s) | ||
151 | +{ | 68 | +{ |
152 | + SysTickState *s = SYSTICK(opaque); | 69 | + uint8_t delay = |
70 | + (s->regs[R_DMA_CTRL] >> DMA_CTRL_DELAY_SHIFT) & DMA_CTRL_DELAY_MASK; | ||
71 | + uint8_t hclk_mask = | ||
72 | + (s->regs[R_DMA_CTRL] >> DMA_CTRL_FREQ_SHIFT) & DMA_CTRL_FREQ_MASK; | ||
73 | + uint8_t hclk_div = aspeed_smc_hclk_divisor(hclk_mask); | ||
74 | + uint32_t hclk_shift = (hclk_div - 1) << 2; | ||
75 | + uint8_t cs; | ||
153 | + | 76 | + |
154 | + if (!(s->control & SYSTICK_CLKSOURCE)) { | 77 | + /* |
155 | + /* currently using refclk, we can ignore cpuclk changes */ | 78 | + * The Read Timing Compensation Register values apply to all CS on |
79 | + * the SPI bus and only HCLK/1 - HCLK/5 can have tunable delays | ||
80 | + */ | ||
81 | + if (hclk_div && hclk_div < 6) { | ||
82 | + s->regs[s->r_timings] &= ~(0xf << hclk_shift); | ||
83 | + s->regs[s->r_timings] |= delay << hclk_shift; | ||
156 | + } | 84 | + } |
157 | + | 85 | + |
158 | + ptimer_transaction_begin(s->ptimer); | 86 | + /* |
159 | + ptimer_set_period_from_clock(s->ptimer, s->cpuclk, 1); | 87 | + * TODO: compute the CS from the DMA address and the segment |
160 | + ptimer_transaction_commit(s->ptimer); | 88 | + * registers. This is not really a problem for now because the |
89 | + * Timing Register values apply to all CS and software uses CS0 to | ||
90 | + * do calibration. | ||
91 | + */ | ||
92 | + cs = 0; | ||
93 | + s->regs[s->r_ctrl0 + cs] &= | ||
94 | + ~(CE_CTRL_CLOCK_FREQ_MASK << CE_CTRL_CLOCK_FREQ_SHIFT); | ||
95 | + s->regs[s->r_ctrl0 + cs] |= CE_CTRL_CLOCK_FREQ(hclk_div); | ||
161 | +} | 96 | +} |
162 | + | 97 | + |
163 | +static void systick_refclk_update(void *opaque, ClockEvent event) | 98 | /* |
164 | +{ | 99 | * Accumulate the result of the reads to provide a checksum that will |
165 | + SysTickState *s = SYSTICK(opaque); | 100 | * be used to validate the read timing settings. |
166 | + | 101 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_dma_checksum(AspeedSMCState *s) |
167 | + if (s->control & SYSTICK_CLKSOURCE) { | 102 | return; |
168 | + /* currently using cpuclk, we can ignore refclk changes */ | 103 | } |
104 | |||
105 | + if (s->regs[R_DMA_CTRL] & DMA_CTRL_CALIB) { | ||
106 | + aspeed_smc_dma_calibration(s); | ||
169 | + } | 107 | + } |
170 | + | 108 | + |
171 | + ptimer_transaction_begin(s->ptimer); | 109 | while (s->regs[R_DMA_LEN]) { |
172 | + ptimer_set_period_from_clock(s->ptimer, s->refclk, 1); | 110 | data = address_space_ldl_le(&s->flash_as, s->regs[R_DMA_FLASH_ADDR], |
173 | ptimer_transaction_commit(s->ptimer); | 111 | MEMTXATTRS_UNSPECIFIED, &result); |
174 | } | ||
175 | |||
176 | @@ -XXX,XX +XXX,XX @@ static void systick_instance_init(Object *obj) | ||
177 | sysbus_init_mmio(sbd, &s->iomem); | ||
178 | sysbus_init_irq(sbd, &s->irq); | ||
179 | |||
180 | - s->refclk = qdev_init_clock_in(DEVICE(obj), "refclk", NULL, NULL, 0); | ||
181 | - s->cpuclk = qdev_init_clock_in(DEVICE(obj), "cpuclk", NULL, NULL, 0); | ||
182 | + s->refclk = qdev_init_clock_in(DEVICE(obj), "refclk", | ||
183 | + systick_refclk_update, s, ClockUpdate); | ||
184 | + s->cpuclk = qdev_init_clock_in(DEVICE(obj), "cpuclk", | ||
185 | + systick_cpuclk_update, s, ClockUpdate); | ||
186 | } | ||
187 | |||
188 | static void systick_realize(DeviceState *dev, Error **errp) | ||
189 | @@ -XXX,XX +XXX,XX @@ static void systick_realize(DeviceState *dev, Error **errp) | ||
190 | PTIMER_POLICY_NO_COUNTER_ROUND_DOWN | | ||
191 | PTIMER_POLICY_NO_IMMEDIATE_RELOAD | | ||
192 | PTIMER_POLICY_TRIGGER_ONLY_ON_DECREMENT); | ||
193 | + | ||
194 | + if (!clock_has_source(s->cpuclk)) { | ||
195 | + error_setg(errp, "systick: cpuclk must be connected"); | ||
196 | + return; | ||
197 | + } | ||
198 | + /* It's OK not to connect the refclk */ | ||
199 | } | ||
200 | |||
201 | static const VMStateDescription vmstate_systick = { | ||
202 | -- | 112 | -- |
203 | 2.20.1 | 113 | 2.20.1 |
204 | 114 | ||
205 | 115 | diff view generated by jsdifflib |
1 | Implement the MVE VADD (floating-point) insn. Handling of this is | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | similar to the 2-operand integer insns, except that we must take care | ||
3 | to only update the floating point exception status if the least | ||
4 | significant bit of the predicate mask for each element is active. | ||
5 | 2 | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 3 | Emulate read errors in the DMA Checksum Register for high frequencies |
4 | and optimistic settings of the Read Timing Compensation Register. This | ||
5 | will help in tuning the SPI timing calibration algorithm. Errors are | ||
6 | only injected when the property "inject_failure" is set to true as | ||
7 | suggested by Philippe. | ||
8 | |||
9 | The values below are those to expect from the first flash device of | ||
10 | the FMC controller of a palmetto-bmc machine. | ||
11 | |||
12 | Cc: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
13 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
14 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
15 | Message-id: 20190904070506.1052-8-clg@kaod.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 17 | --- |
9 | target/arm/helper-mve.h | 3 +++ | 18 | include/hw/ssi/aspeed_smc.h | 1 + |
10 | target/arm/translate.h | 6 ++++++ | 19 | hw/ssi/aspeed_smc.c | 36 ++++++++++++++++++++++++++++++++++++ |
11 | target/arm/mve.decode | 10 ++++++++++ | 20 | 2 files changed, 37 insertions(+) |
12 | target/arm/mve_helper.c | 40 +++++++++++++++++++++++++++++++++++++ | ||
13 | target/arm/translate-mve.c | 17 ++++++++++++++++ | ||
14 | target/arm/translate-neon.c | 6 ------ | ||
15 | 6 files changed, 76 insertions(+), 6 deletions(-) | ||
16 | 21 | ||
17 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | 22 | diff --git a/include/hw/ssi/aspeed_smc.h b/include/hw/ssi/aspeed_smc.h |
18 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper-mve.h | 24 | --- a/include/hw/ssi/aspeed_smc.h |
20 | +++ b/target/arm/helper-mve.h | 25 | +++ b/include/hw/ssi/aspeed_smc.h |
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vhcadd270b, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 26 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSMCState { |
22 | DEF_HELPER_FLAGS_4(mve_vhcadd270h, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 27 | |
23 | DEF_HELPER_FLAGS_4(mve_vhcadd270w, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 28 | uint32_t num_cs; |
24 | 29 | qemu_irq *cs_lines; | |
25 | +DEF_HELPER_FLAGS_4(mve_vfaddh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 30 | + bool inject_failure; |
26 | +DEF_HELPER_FLAGS_4(mve_vfadds, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | 31 | |
32 | SSIBus *spi; | ||
33 | |||
34 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/hw/ssi/aspeed_smc.c | ||
37 | +++ b/hw/ssi/aspeed_smc.c | ||
38 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_dma_calibration(AspeedSMCState *s) | ||
39 | s->regs[s->r_ctrl0 + cs] |= CE_CTRL_CLOCK_FREQ(hclk_div); | ||
40 | } | ||
41 | |||
42 | +/* | ||
43 | + * Emulate read errors in the DMA Checksum Register for high | ||
44 | + * frequencies and optimistic settings of the Read Timing Compensation | ||
45 | + * Register. This will help in tuning the SPI timing calibration | ||
46 | + * algorithm. | ||
47 | + */ | ||
48 | +static bool aspeed_smc_inject_read_failure(AspeedSMCState *s) | ||
49 | +{ | ||
50 | + uint8_t delay = | ||
51 | + (s->regs[R_DMA_CTRL] >> DMA_CTRL_DELAY_SHIFT) & DMA_CTRL_DELAY_MASK; | ||
52 | + uint8_t hclk_mask = | ||
53 | + (s->regs[R_DMA_CTRL] >> DMA_CTRL_FREQ_SHIFT) & DMA_CTRL_FREQ_MASK; | ||
27 | + | 54 | + |
28 | DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 55 | + /* |
29 | DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 56 | + * Typical values of a palmetto-bmc machine. |
30 | DEF_HELPER_FLAGS_4(mve_vadd_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | 57 | + */ |
31 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 58 | + switch (aspeed_smc_hclk_divisor(hclk_mask)) { |
32 | index XXXXXXX..XXXXXXX 100644 | 59 | + case 4 ... 16: |
33 | --- a/target/arm/translate.h | 60 | + return false; |
34 | +++ b/target/arm/translate.h | 61 | + case 3: /* at least one HCLK cycle delay */ |
35 | @@ -XXX,XX +XXX,XX @@ static inline int rsub_8(DisasContext *s, int x) | 62 | + return (delay & 0x7) < 1; |
36 | return 8 - x; | 63 | + case 2: /* at least two HCLK cycle delay */ |
37 | } | 64 | + return (delay & 0x7) < 2; |
38 | 65 | + case 1: /* (> 100MHz) is above the max freq of the controller */ | |
39 | +static inline int neon_3same_fp_size(DisasContext *s, int x) | 66 | + return true; |
40 | +{ | 67 | + default: |
41 | + /* Convert 0==fp32, 1==fp16 into a MO_* value */ | 68 | + g_assert_not_reached(); |
42 | + return MO_32 - x; | 69 | + } |
43 | +} | 70 | +} |
44 | + | 71 | + |
45 | static inline int arm_dc_feature(DisasContext *dc, int feature) | 72 | /* |
46 | { | 73 | * Accumulate the result of the reads to provide a checksum that will |
47 | return (dc->features & (1ULL << feature)) != 0; | 74 | * be used to validate the read timing settings. |
48 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | 75 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_dma_checksum(AspeedSMCState *s) |
49 | index XXXXXXX..XXXXXXX 100644 | 76 | s->regs[R_DMA_FLASH_ADDR] += 4; |
50 | --- a/target/arm/mve.decode | 77 | s->regs[R_DMA_LEN] -= 4; |
51 | +++ b/target/arm/mve.decode | 78 | } |
52 | @@ -XXX,XX +XXX,XX @@ | ||
53 | # VQDMULL has size in bit 28: 0 for 16 bit, 1 for 32 bit | ||
54 | %size_28 28:1 !function=plus_1 | ||
55 | |||
56 | +# 2 operand fp insns have size in bit 20: 1 for 16 bit, 0 for 32 bit, | ||
57 | +# like Neon FP insns. | ||
58 | +%2op_fp_size 20:1 !function=neon_3same_fp_size | ||
59 | + | 79 | + |
60 | # 1imm format immediate | 80 | + if (s->inject_failure && aspeed_smc_inject_read_failure(s)) { |
61 | %imm_28_16_0 28:1 16:3 0:4 | 81 | + s->regs[R_DMA_CHECKSUM] = 0xbadc0de; |
62 | |||
63 | @@ -XXX,XX +XXX,XX @@ | ||
64 | |||
65 | @vmaxv .... .... .... size:2 .. rda:4 .... .... .... &vmaxv qm=%qm | ||
66 | |||
67 | +@2op_fp .... .... .... .... .... .... .... .... &2op \ | ||
68 | + qd=%qd qn=%qn qm=%qm size=%2op_fp_size | ||
69 | + | ||
70 | # Vector loads and stores | ||
71 | |||
72 | # Widening loads and narrowing stores: | ||
73 | @@ -XXX,XX +XXX,XX @@ VCMPGE_scalar 1111 1110 0 . .. ... 1 ... 1 1111 0 1 0 0 .... @vcmp_scalar | ||
74 | VCMPLT_scalar 1111 1110 0 . .. ... 1 ... 1 1111 1 1 0 0 .... @vcmp_scalar | ||
75 | VCMPGT_scalar 1111 1110 0 . .. ... 1 ... 1 1111 0 1 1 0 .... @vcmp_scalar | ||
76 | VCMPLE_scalar 1111 1110 0 . .. ... 1 ... 1 1111 1 1 1 0 .... @vcmp_scalar | ||
77 | + | ||
78 | +# 2-operand FP | ||
79 | +VADD_fp 1110 1111 0 . 0 . ... 0 ... 0 1101 . 1 . 0 ... 0 @2op_fp | ||
80 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
81 | index XXXXXXX..XXXXXXX 100644 | ||
82 | --- a/target/arm/mve_helper.c | ||
83 | +++ b/target/arm/mve_helper.c | ||
84 | @@ -XXX,XX +XXX,XX @@ | ||
85 | #include "exec/cpu_ldst.h" | ||
86 | #include "exec/exec-all.h" | ||
87 | #include "tcg/tcg.h" | ||
88 | +#include "fpu/softfloat.h" | ||
89 | |||
90 | static uint16_t mve_eci_mask(CPUARMState *env) | ||
91 | { | ||
92 | @@ -XXX,XX +XXX,XX @@ DO_VMAXMINA(vmaxaw, 4, int32_t, uint32_t, DO_MAX) | ||
93 | DO_VMAXMINA(vminab, 1, int8_t, uint8_t, DO_MIN) | ||
94 | DO_VMAXMINA(vminah, 2, int16_t, uint16_t, DO_MIN) | ||
95 | DO_VMAXMINA(vminaw, 4, int32_t, uint32_t, DO_MIN) | ||
96 | + | ||
97 | +/* | ||
98 | + * 2-operand floating point. Note that if an element is partially | ||
99 | + * predicated we must do the FP operation to update the non-predicated | ||
100 | + * bytes, but we must be careful to avoid updating the FP exception | ||
101 | + * state unless byte 0 of the element was unpredicated. | ||
102 | + */ | ||
103 | +#define DO_2OP_FP(OP, ESIZE, TYPE, FN) \ | ||
104 | + void HELPER(glue(mve_, OP))(CPUARMState *env, \ | ||
105 | + void *vd, void *vn, void *vm) \ | ||
106 | + { \ | ||
107 | + TYPE *d = vd, *n = vn, *m = vm; \ | ||
108 | + TYPE r; \ | ||
109 | + uint16_t mask = mve_element_mask(env); \ | ||
110 | + unsigned e; \ | ||
111 | + float_status *fpst; \ | ||
112 | + float_status scratch_fpst; \ | ||
113 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
114 | + if ((mask & MAKE_64BIT_MASK(0, ESIZE)) == 0) { \ | ||
115 | + continue; \ | ||
116 | + } \ | ||
117 | + fpst = (ESIZE == 2) ? &env->vfp.standard_fp_status_f16 : \ | ||
118 | + &env->vfp.standard_fp_status; \ | ||
119 | + if (!(mask & 1)) { \ | ||
120 | + /* We need the result but without updating flags */ \ | ||
121 | + scratch_fpst = *fpst; \ | ||
122 | + fpst = &scratch_fpst; \ | ||
123 | + } \ | ||
124 | + r = FN(n[H##ESIZE(e)], m[H##ESIZE(e)], fpst); \ | ||
125 | + mergemask(&d[H##ESIZE(e)], r, mask); \ | ||
126 | + } \ | ||
127 | + mve_advance_vpt(env); \ | ||
128 | + } | 82 | + } |
129 | + | 83 | + |
130 | +#define DO_2OP_FP_ALL(OP, FN) \ | ||
131 | + DO_2OP_FP(OP##h, 2, float16, float16_##FN) \ | ||
132 | + DO_2OP_FP(OP##s, 4, float32, float32_##FN) | ||
133 | + | ||
134 | +DO_2OP_FP_ALL(vfadd, add) | ||
135 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
136 | index XXXXXXX..XXXXXXX 100644 | ||
137 | --- a/target/arm/translate-mve.c | ||
138 | +++ b/target/arm/translate-mve.c | ||
139 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSBCI(DisasContext *s, arg_2op *a) | ||
140 | return do_2op(s, a, gen_helper_mve_vsbci); | ||
141 | } | 84 | } |
142 | 85 | ||
143 | +#define DO_2OP_FP(INSN, FN) \ | 86 | static void aspeed_smc_dma_rw(AspeedSMCState *s) |
144 | + static bool trans_##INSN(DisasContext *s, arg_2op *a) \ | 87 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_aspeed_smc = { |
145 | + { \ | 88 | |
146 | + static MVEGenTwoOpFn * const fns[] = { \ | 89 | static Property aspeed_smc_properties[] = { |
147 | + NULL, \ | 90 | DEFINE_PROP_UINT32("num-cs", AspeedSMCState, num_cs, 1), |
148 | + gen_helper_mve_##FN##h, \ | 91 | + DEFINE_PROP_BOOL("inject-failure", AspeedSMCState, inject_failure, false), |
149 | + gen_helper_mve_##FN##s, \ | 92 | DEFINE_PROP_UINT64("sdram-base", AspeedSMCState, sdram_base, 0), |
150 | + NULL, \ | 93 | DEFINE_PROP_LINK("dram", AspeedSMCState, dram_mr, |
151 | + }; \ | 94 | TYPE_MEMORY_REGION, MemoryRegion *), |
152 | + if (!dc_isar_feature(aa32_mve_fp, s)) { \ | ||
153 | + return false; \ | ||
154 | + } \ | ||
155 | + return do_2op(s, a, fns[a->size]); \ | ||
156 | + } | ||
157 | + | ||
158 | +DO_2OP_FP(VADD_fp, vfadd) | ||
159 | + | ||
160 | static bool do_2op_scalar(DisasContext *s, arg_2scalar *a, | ||
161 | MVEGenTwoOpScalarFn fn) | ||
162 | { | ||
163 | diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c | ||
164 | index XXXXXXX..XXXXXXX 100644 | ||
165 | --- a/target/arm/translate-neon.c | ||
166 | +++ b/target/arm/translate-neon.c | ||
167 | @@ -XXX,XX +XXX,XX @@ | ||
168 | #include "translate.h" | ||
169 | #include "translate-a32.h" | ||
170 | |||
171 | -static inline int neon_3same_fp_size(DisasContext *s, int x) | ||
172 | -{ | ||
173 | - /* Convert 0==fp32, 1==fp16 into a MO_* value */ | ||
174 | - return MO_32 - x; | ||
175 | -} | ||
176 | - | ||
177 | /* Include the generated Neon decoder */ | ||
178 | #include "decode-neon-dp.c.inc" | ||
179 | #include "decode-neon-ls.c.inc" | ||
180 | -- | 95 | -- |
181 | 2.20.1 | 96 | 2.20.1 |
182 | 97 | ||
183 | 98 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Christian Svensson <bluecmd@google.com> |
---|---|---|---|
2 | 2 | ||
3 | Quoting Peter Maydell: | 3 | This patch adds the missing checksum calculation on normal DMA transfer. |
4 | According to the datasheet this is how the SMC should behave. | ||
4 | 5 | ||
5 | These MEMTX_* aren't from the memory transaction API functions; | 6 | Verified on AST1250 that the hardware matches the behaviour. |
6 | they're just being used by gicd_readl() and friends as a way to | ||
7 | indicate a success/failure so that the actual MemoryRegionOps | ||
8 | read/write fns like gicv3_dist_read() can log a guest error. | ||
9 | Arguably this is a bit of a misuse of the MEMTX_* constants and | ||
10 | perhaps we should have gicd_readl etc return a bool instead. | ||
11 | 7 | ||
12 | Follow his suggestion and replace the MEMTX_* constants by | 8 | Signed-off-by: Christian Svensson <bluecmd@google.com> |
13 | boolean values, simplifying a bit the gicv3_dist_read() / | 9 | Reviewed-by: Joel Stanley <joel@jms.id.au> |
14 | gicv3_dist_write() handlers. | 10 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
15 | 11 | Message-id: 20190904070506.1052-9-clg@kaod.org | |
16 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
18 | Message-id: 20210826180704.2131949-3-philmd@redhat.com | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
20 | --- | 13 | --- |
21 | hw/intc/arm_gicv3_dist.c | 201 +++++++++++++++++++++------------------ | 14 | hw/ssi/aspeed_smc.c | 1 + |
22 | 1 file changed, 106 insertions(+), 95 deletions(-) | 15 | 1 file changed, 1 insertion(+) |
23 | 16 | ||
24 | diff --git a/hw/intc/arm_gicv3_dist.c b/hw/intc/arm_gicv3_dist.c | 17 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c |
25 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/hw/intc/arm_gicv3_dist.c | 19 | --- a/hw/ssi/aspeed_smc.c |
27 | +++ b/hw/intc/arm_gicv3_dist.c | 20 | +++ b/hw/ssi/aspeed_smc.c |
28 | @@ -XXX,XX +XXX,XX @@ static void gicd_write_irouter(GICv3State *s, MemTxAttrs attrs, int irq, | 21 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_dma_rw(AspeedSMCState *s) |
29 | gicv3_update(s, irq, 1); | 22 | s->regs[R_DMA_FLASH_ADDR] += 4; |
30 | } | 23 | s->regs[R_DMA_DRAM_ADDR] += 4; |
31 | 24 | s->regs[R_DMA_LEN] -= 4; | |
32 | -static MemTxResult gicd_readb(GICv3State *s, hwaddr offset, | 25 | + s->regs[R_DMA_CHECKSUM] += data; |
33 | - uint64_t *data, MemTxAttrs attrs) | ||
34 | +/** | ||
35 | + * gicd_readb | ||
36 | + * gicd_readw | ||
37 | + * gicd_readl | ||
38 | + * gicd_readq | ||
39 | + * gicd_writeb | ||
40 | + * gicd_writew | ||
41 | + * gicd_writel | ||
42 | + * gicd_writeq | ||
43 | + * | ||
44 | + * Return %true if the operation succeeded, %false otherwise. | ||
45 | + */ | ||
46 | + | ||
47 | +static bool gicd_readb(GICv3State *s, hwaddr offset, | ||
48 | + uint64_t *data, MemTxAttrs attrs) | ||
49 | { | ||
50 | /* Most GICv3 distributor registers do not support byte accesses. */ | ||
51 | switch (offset) { | ||
52 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicd_readb(GICv3State *s, hwaddr offset, | ||
53 | /* This GIC implementation always has affinity routing enabled, | ||
54 | * so these registers are all RAZ/WI. | ||
55 | */ | ||
56 | - return MEMTX_OK; | ||
57 | + return true; | ||
58 | case GICD_IPRIORITYR ... GICD_IPRIORITYR + 0x3ff: | ||
59 | *data = gicd_read_ipriorityr(s, attrs, offset - GICD_IPRIORITYR); | ||
60 | - return MEMTX_OK; | ||
61 | + return true; | ||
62 | default: | ||
63 | - return MEMTX_ERROR; | ||
64 | + return false; | ||
65 | } | 26 | } |
66 | } | 27 | } |
67 | 28 | ||
68 | -static MemTxResult gicd_writeb(GICv3State *s, hwaddr offset, | ||
69 | - uint64_t value, MemTxAttrs attrs) | ||
70 | +static bool gicd_writeb(GICv3State *s, hwaddr offset, | ||
71 | + uint64_t value, MemTxAttrs attrs) | ||
72 | { | ||
73 | /* Most GICv3 distributor registers do not support byte accesses. */ | ||
74 | switch (offset) { | ||
75 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicd_writeb(GICv3State *s, hwaddr offset, | ||
76 | /* This GIC implementation always has affinity routing enabled, | ||
77 | * so these registers are all RAZ/WI. | ||
78 | */ | ||
79 | - return MEMTX_OK; | ||
80 | + return true; | ||
81 | case GICD_IPRIORITYR ... GICD_IPRIORITYR + 0x3ff: | ||
82 | { | ||
83 | int irq = offset - GICD_IPRIORITYR; | ||
84 | |||
85 | if (irq < GIC_INTERNAL || irq >= s->num_irq) { | ||
86 | - return MEMTX_OK; | ||
87 | + return true; | ||
88 | } | ||
89 | gicd_write_ipriorityr(s, attrs, irq, value); | ||
90 | gicv3_update(s, irq, 1); | ||
91 | - return MEMTX_OK; | ||
92 | + return true; | ||
93 | } | ||
94 | default: | ||
95 | - return MEMTX_ERROR; | ||
96 | + return false; | ||
97 | } | ||
98 | } | ||
99 | |||
100 | -static MemTxResult gicd_readw(GICv3State *s, hwaddr offset, | ||
101 | - uint64_t *data, MemTxAttrs attrs) | ||
102 | +static bool gicd_readw(GICv3State *s, hwaddr offset, | ||
103 | + uint64_t *data, MemTxAttrs attrs) | ||
104 | { | ||
105 | /* Only GICD_SETSPI_NSR, GICD_CLRSPI_NSR, GICD_SETSPI_SR and GICD_SETSPI_NSR | ||
106 | * support 16 bit accesses, and those registers are all part of the | ||
107 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicd_readw(GICv3State *s, hwaddr offset, | ||
108 | * implement (ie for us GICD_TYPER.MBIS == 0), so for us they are | ||
109 | * reserved. | ||
110 | */ | ||
111 | - return MEMTX_ERROR; | ||
112 | + return false; | ||
113 | } | ||
114 | |||
115 | -static MemTxResult gicd_writew(GICv3State *s, hwaddr offset, | ||
116 | - uint64_t value, MemTxAttrs attrs) | ||
117 | +static bool gicd_writew(GICv3State *s, hwaddr offset, | ||
118 | + uint64_t value, MemTxAttrs attrs) | ||
119 | { | ||
120 | /* Only GICD_SETSPI_NSR, GICD_CLRSPI_NSR, GICD_SETSPI_SR and GICD_SETSPI_NSR | ||
121 | * support 16 bit accesses, and those registers are all part of the | ||
122 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicd_writew(GICv3State *s, hwaddr offset, | ||
123 | * implement (ie for us GICD_TYPER.MBIS == 0), so for us they are | ||
124 | * reserved. | ||
125 | */ | ||
126 | - return MEMTX_ERROR; | ||
127 | + return false; | ||
128 | } | ||
129 | |||
130 | -static MemTxResult gicd_readl(GICv3State *s, hwaddr offset, | ||
131 | - uint64_t *data, MemTxAttrs attrs) | ||
132 | +static bool gicd_readl(GICv3State *s, hwaddr offset, | ||
133 | + uint64_t *data, MemTxAttrs attrs) | ||
134 | { | ||
135 | /* Almost all GICv3 distributor registers are 32-bit. | ||
136 | * Note that WO registers must return an UNKNOWN value on reads, | ||
137 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicd_readl(GICv3State *s, hwaddr offset, | ||
138 | } else { | ||
139 | *data = s->gicd_ctlr; | ||
140 | } | ||
141 | - return MEMTX_OK; | ||
142 | + return true; | ||
143 | case GICD_TYPER: | ||
144 | { | ||
145 | /* For this implementation: | ||
146 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicd_readl(GICv3State *s, hwaddr offset, | ||
147 | |||
148 | *data = (1 << 25) | (1 << 24) | (sec_extn << 10) | | ||
149 | (0xf << 19) | itlinesnumber; | ||
150 | - return MEMTX_OK; | ||
151 | + return true; | ||
152 | } | ||
153 | case GICD_IIDR: | ||
154 | /* We claim to be an ARM r0p0 with a zero ProductID. | ||
155 | * This is the same as an r0p0 GIC-500. | ||
156 | */ | ||
157 | *data = gicv3_iidr(); | ||
158 | - return MEMTX_OK; | ||
159 | + return true; | ||
160 | case GICD_STATUSR: | ||
161 | /* RAZ/WI for us (this is an optional register and our implementation | ||
162 | * does not track RO/WO/reserved violations to report them to the guest) | ||
163 | */ | ||
164 | *data = 0; | ||
165 | - return MEMTX_OK; | ||
166 | + return true; | ||
167 | case GICD_IGROUPR ... GICD_IGROUPR + 0x7f: | ||
168 | { | ||
169 | int irq; | ||
170 | |||
171 | if (!attrs.secure && !(s->gicd_ctlr & GICD_CTLR_DS)) { | ||
172 | *data = 0; | ||
173 | - return MEMTX_OK; | ||
174 | + return true; | ||
175 | } | ||
176 | /* RAZ/WI for SGIs, PPIs, unimplemented irqs */ | ||
177 | irq = (offset - GICD_IGROUPR) * 8; | ||
178 | if (irq < GIC_INTERNAL || irq >= s->num_irq) { | ||
179 | *data = 0; | ||
180 | - return MEMTX_OK; | ||
181 | + return true; | ||
182 | } | ||
183 | *data = *gic_bmp_ptr32(s->group, irq); | ||
184 | - return MEMTX_OK; | ||
185 | + return true; | ||
186 | } | ||
187 | case GICD_ISENABLER ... GICD_ISENABLER + 0x7f: | ||
188 | *data = gicd_read_bitmap_reg(s, attrs, s->enabled, NULL, | ||
189 | offset - GICD_ISENABLER); | ||
190 | - return MEMTX_OK; | ||
191 | + return true; | ||
192 | case GICD_ICENABLER ... GICD_ICENABLER + 0x7f: | ||
193 | *data = gicd_read_bitmap_reg(s, attrs, s->enabled, NULL, | ||
194 | offset - GICD_ICENABLER); | ||
195 | - return MEMTX_OK; | ||
196 | + return true; | ||
197 | case GICD_ISPENDR ... GICD_ISPENDR + 0x7f: | ||
198 | *data = gicd_read_bitmap_reg(s, attrs, s->pending, mask_nsacr_ge1, | ||
199 | offset - GICD_ISPENDR); | ||
200 | - return MEMTX_OK; | ||
201 | + return true; | ||
202 | case GICD_ICPENDR ... GICD_ICPENDR + 0x7f: | ||
203 | *data = gicd_read_bitmap_reg(s, attrs, s->pending, mask_nsacr_ge2, | ||
204 | offset - GICD_ICPENDR); | ||
205 | - return MEMTX_OK; | ||
206 | + return true; | ||
207 | case GICD_ISACTIVER ... GICD_ISACTIVER + 0x7f: | ||
208 | *data = gicd_read_bitmap_reg(s, attrs, s->active, mask_nsacr_ge2, | ||
209 | offset - GICD_ISACTIVER); | ||
210 | - return MEMTX_OK; | ||
211 | + return true; | ||
212 | case GICD_ICACTIVER ... GICD_ICACTIVER + 0x7f: | ||
213 | *data = gicd_read_bitmap_reg(s, attrs, s->active, mask_nsacr_ge2, | ||
214 | offset - GICD_ICACTIVER); | ||
215 | - return MEMTX_OK; | ||
216 | + return true; | ||
217 | case GICD_IPRIORITYR ... GICD_IPRIORITYR + 0x3ff: | ||
218 | { | ||
219 | int i, irq = offset - GICD_IPRIORITYR; | ||
220 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicd_readl(GICv3State *s, hwaddr offset, | ||
221 | value |= gicd_read_ipriorityr(s, attrs, i); | ||
222 | } | ||
223 | *data = value; | ||
224 | - return MEMTX_OK; | ||
225 | + return true; | ||
226 | } | ||
227 | case GICD_ITARGETSR ... GICD_ITARGETSR + 0x3ff: | ||
228 | /* RAZ/WI since affinity routing is always enabled */ | ||
229 | *data = 0; | ||
230 | - return MEMTX_OK; | ||
231 | + return true; | ||
232 | case GICD_ICFGR ... GICD_ICFGR + 0xff: | ||
233 | { | ||
234 | /* Here only the even bits are used; odd bits are RES0 */ | ||
235 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicd_readl(GICv3State *s, hwaddr offset, | ||
236 | |||
237 | if (irq < GIC_INTERNAL || irq >= s->num_irq) { | ||
238 | *data = 0; | ||
239 | - return MEMTX_OK; | ||
240 | + return true; | ||
241 | } | ||
242 | |||
243 | /* Since our edge_trigger bitmap is one bit per irq, we only need | ||
244 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicd_readl(GICv3State *s, hwaddr offset, | ||
245 | value = extract32(value, (irq & 0x1f) ? 16 : 0, 16); | ||
246 | value = half_shuffle32(value) << 1; | ||
247 | *data = value; | ||
248 | - return MEMTX_OK; | ||
249 | + return true; | ||
250 | } | ||
251 | case GICD_IGRPMODR ... GICD_IGRPMODR + 0xff: | ||
252 | { | ||
253 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicd_readl(GICv3State *s, hwaddr offset, | ||
254 | * security enabled and this is an NS access | ||
255 | */ | ||
256 | *data = 0; | ||
257 | - return MEMTX_OK; | ||
258 | + return true; | ||
259 | } | ||
260 | /* RAZ/WI for SGIs, PPIs, unimplemented irqs */ | ||
261 | irq = (offset - GICD_IGRPMODR) * 8; | ||
262 | if (irq < GIC_INTERNAL || irq >= s->num_irq) { | ||
263 | *data = 0; | ||
264 | - return MEMTX_OK; | ||
265 | + return true; | ||
266 | } | ||
267 | *data = *gic_bmp_ptr32(s->grpmod, irq); | ||
268 | - return MEMTX_OK; | ||
269 | + return true; | ||
270 | } | ||
271 | case GICD_NSACR ... GICD_NSACR + 0xff: | ||
272 | { | ||
273 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicd_readl(GICv3State *s, hwaddr offset, | ||
274 | |||
275 | if (irq < GIC_INTERNAL || irq >= s->num_irq) { | ||
276 | *data = 0; | ||
277 | - return MEMTX_OK; | ||
278 | + return true; | ||
279 | } | ||
280 | |||
281 | if ((s->gicd_ctlr & GICD_CTLR_DS) || !attrs.secure) { | ||
282 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicd_readl(GICv3State *s, hwaddr offset, | ||
283 | * security enabled and this is an NS access | ||
284 | */ | ||
285 | *data = 0; | ||
286 | - return MEMTX_OK; | ||
287 | + return true; | ||
288 | } | ||
289 | |||
290 | *data = s->gicd_nsacr[irq / 16]; | ||
291 | - return MEMTX_OK; | ||
292 | + return true; | ||
293 | } | ||
294 | case GICD_CPENDSGIR ... GICD_CPENDSGIR + 0xf: | ||
295 | case GICD_SPENDSGIR ... GICD_SPENDSGIR + 0xf: | ||
296 | /* RAZ/WI since affinity routing is always enabled */ | ||
297 | *data = 0; | ||
298 | - return MEMTX_OK; | ||
299 | + return true; | ||
300 | case GICD_IROUTER ... GICD_IROUTER + 0x1fdf: | ||
301 | { | ||
302 | uint64_t r; | ||
303 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicd_readl(GICv3State *s, hwaddr offset, | ||
304 | } else { | ||
305 | *data = (uint32_t)r; | ||
306 | } | ||
307 | - return MEMTX_OK; | ||
308 | + return true; | ||
309 | } | ||
310 | case GICD_IDREGS ... GICD_IDREGS + 0x2f: | ||
311 | /* ID registers */ | ||
312 | *data = gicv3_idreg(offset - GICD_IDREGS); | ||
313 | - return MEMTX_OK; | ||
314 | + return true; | ||
315 | case GICD_SGIR: | ||
316 | /* WO registers, return unknown value */ | ||
317 | qemu_log_mask(LOG_GUEST_ERROR, | ||
318 | "%s: invalid guest read from WO register at offset " | ||
319 | TARGET_FMT_plx "\n", __func__, offset); | ||
320 | *data = 0; | ||
321 | - return MEMTX_OK; | ||
322 | + return true; | ||
323 | default: | ||
324 | - return MEMTX_ERROR; | ||
325 | + return false; | ||
326 | } | ||
327 | } | ||
328 | |||
329 | -static MemTxResult gicd_writel(GICv3State *s, hwaddr offset, | ||
330 | - uint64_t value, MemTxAttrs attrs) | ||
331 | +static bool gicd_writel(GICv3State *s, hwaddr offset, | ||
332 | + uint64_t value, MemTxAttrs attrs) | ||
333 | { | ||
334 | /* Almost all GICv3 distributor registers are 32-bit. Note that | ||
335 | * RO registers must ignore writes, not abort. | ||
336 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicd_writel(GICv3State *s, hwaddr offset, | ||
337 | s->gicd_ctlr &= ~(GICD_CTLR_EN_GRP1S | GICD_CTLR_ARE_NS); | ||
338 | } | ||
339 | gicv3_full_update(s); | ||
340 | - return MEMTX_OK; | ||
341 | + return true; | ||
342 | } | ||
343 | case GICD_STATUSR: | ||
344 | /* RAZ/WI for our implementation */ | ||
345 | - return MEMTX_OK; | ||
346 | + return true; | ||
347 | case GICD_IGROUPR ... GICD_IGROUPR + 0x7f: | ||
348 | { | ||
349 | int irq; | ||
350 | |||
351 | if (!attrs.secure && !(s->gicd_ctlr & GICD_CTLR_DS)) { | ||
352 | - return MEMTX_OK; | ||
353 | + return true; | ||
354 | } | ||
355 | /* RAZ/WI for SGIs, PPIs, unimplemented irqs */ | ||
356 | irq = (offset - GICD_IGROUPR) * 8; | ||
357 | if (irq < GIC_INTERNAL || irq >= s->num_irq) { | ||
358 | - return MEMTX_OK; | ||
359 | + return true; | ||
360 | } | ||
361 | *gic_bmp_ptr32(s->group, irq) = value; | ||
362 | gicv3_update(s, irq, 32); | ||
363 | - return MEMTX_OK; | ||
364 | + return true; | ||
365 | } | ||
366 | case GICD_ISENABLER ... GICD_ISENABLER + 0x7f: | ||
367 | gicd_write_set_bitmap_reg(s, attrs, s->enabled, NULL, | ||
368 | offset - GICD_ISENABLER, value); | ||
369 | - return MEMTX_OK; | ||
370 | + return true; | ||
371 | case GICD_ICENABLER ... GICD_ICENABLER + 0x7f: | ||
372 | gicd_write_clear_bitmap_reg(s, attrs, s->enabled, NULL, | ||
373 | offset - GICD_ICENABLER, value); | ||
374 | - return MEMTX_OK; | ||
375 | + return true; | ||
376 | case GICD_ISPENDR ... GICD_ISPENDR + 0x7f: | ||
377 | gicd_write_set_bitmap_reg(s, attrs, s->pending, mask_nsacr_ge1, | ||
378 | offset - GICD_ISPENDR, value); | ||
379 | - return MEMTX_OK; | ||
380 | + return true; | ||
381 | case GICD_ICPENDR ... GICD_ICPENDR + 0x7f: | ||
382 | gicd_write_clear_bitmap_reg(s, attrs, s->pending, mask_nsacr_ge2, | ||
383 | offset - GICD_ICPENDR, value); | ||
384 | - return MEMTX_OK; | ||
385 | + return true; | ||
386 | case GICD_ISACTIVER ... GICD_ISACTIVER + 0x7f: | ||
387 | gicd_write_set_bitmap_reg(s, attrs, s->active, NULL, | ||
388 | offset - GICD_ISACTIVER, value); | ||
389 | - return MEMTX_OK; | ||
390 | + return true; | ||
391 | case GICD_ICACTIVER ... GICD_ICACTIVER + 0x7f: | ||
392 | gicd_write_clear_bitmap_reg(s, attrs, s->active, NULL, | ||
393 | offset - GICD_ICACTIVER, value); | ||
394 | - return MEMTX_OK; | ||
395 | + return true; | ||
396 | case GICD_IPRIORITYR ... GICD_IPRIORITYR + 0x3ff: | ||
397 | { | ||
398 | int i, irq = offset - GICD_IPRIORITYR; | ||
399 | |||
400 | if (irq < GIC_INTERNAL || irq + 3 >= s->num_irq) { | ||
401 | - return MEMTX_OK; | ||
402 | + return true; | ||
403 | } | ||
404 | |||
405 | for (i = irq; i < irq + 4; i++, value >>= 8) { | ||
406 | gicd_write_ipriorityr(s, attrs, i, value); | ||
407 | } | ||
408 | gicv3_update(s, irq, 4); | ||
409 | - return MEMTX_OK; | ||
410 | + return true; | ||
411 | } | ||
412 | case GICD_ITARGETSR ... GICD_ITARGETSR + 0x3ff: | ||
413 | /* RAZ/WI since affinity routing is always enabled */ | ||
414 | - return MEMTX_OK; | ||
415 | + return true; | ||
416 | case GICD_ICFGR ... GICD_ICFGR + 0xff: | ||
417 | { | ||
418 | /* Here only the odd bits are used; even bits are RES0 */ | ||
419 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicd_writel(GICv3State *s, hwaddr offset, | ||
420 | uint32_t mask, oldval; | ||
421 | |||
422 | if (irq < GIC_INTERNAL || irq >= s->num_irq) { | ||
423 | - return MEMTX_OK; | ||
424 | + return true; | ||
425 | } | ||
426 | |||
427 | /* Since our edge_trigger bitmap is one bit per irq, our input | ||
428 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicd_writel(GICv3State *s, hwaddr offset, | ||
429 | oldval = *gic_bmp_ptr32(s->edge_trigger, (irq & ~0x1f)); | ||
430 | value = (oldval & ~mask) | (value & mask); | ||
431 | *gic_bmp_ptr32(s->edge_trigger, irq & ~0x1f) = value; | ||
432 | - return MEMTX_OK; | ||
433 | + return true; | ||
434 | } | ||
435 | case GICD_IGRPMODR ... GICD_IGRPMODR + 0xff: | ||
436 | { | ||
437 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicd_writel(GICv3State *s, hwaddr offset, | ||
438 | /* RAZ/WI if security disabled, or if | ||
439 | * security enabled and this is an NS access | ||
440 | */ | ||
441 | - return MEMTX_OK; | ||
442 | + return true; | ||
443 | } | ||
444 | /* RAZ/WI for SGIs, PPIs, unimplemented irqs */ | ||
445 | irq = (offset - GICD_IGRPMODR) * 8; | ||
446 | if (irq < GIC_INTERNAL || irq >= s->num_irq) { | ||
447 | - return MEMTX_OK; | ||
448 | + return true; | ||
449 | } | ||
450 | *gic_bmp_ptr32(s->grpmod, irq) = value; | ||
451 | gicv3_update(s, irq, 32); | ||
452 | - return MEMTX_OK; | ||
453 | + return true; | ||
454 | } | ||
455 | case GICD_NSACR ... GICD_NSACR + 0xff: | ||
456 | { | ||
457 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicd_writel(GICv3State *s, hwaddr offset, | ||
458 | int irq = (offset - GICD_NSACR) * 4; | ||
459 | |||
460 | if (irq < GIC_INTERNAL || irq >= s->num_irq) { | ||
461 | - return MEMTX_OK; | ||
462 | + return true; | ||
463 | } | ||
464 | |||
465 | if ((s->gicd_ctlr & GICD_CTLR_DS) || !attrs.secure) { | ||
466 | /* RAZ/WI if security disabled, or if | ||
467 | * security enabled and this is an NS access | ||
468 | */ | ||
469 | - return MEMTX_OK; | ||
470 | + return true; | ||
471 | } | ||
472 | |||
473 | s->gicd_nsacr[irq / 16] = value; | ||
474 | /* No update required as this only affects access permission checks */ | ||
475 | - return MEMTX_OK; | ||
476 | + return true; | ||
477 | } | ||
478 | case GICD_SGIR: | ||
479 | /* RES0 if affinity routing is enabled */ | ||
480 | - return MEMTX_OK; | ||
481 | + return true; | ||
482 | case GICD_CPENDSGIR ... GICD_CPENDSGIR + 0xf: | ||
483 | case GICD_SPENDSGIR ... GICD_SPENDSGIR + 0xf: | ||
484 | /* RAZ/WI since affinity routing is always enabled */ | ||
485 | - return MEMTX_OK; | ||
486 | + return true; | ||
487 | case GICD_IROUTER ... GICD_IROUTER + 0x1fdf: | ||
488 | { | ||
489 | uint64_t r; | ||
490 | int irq = (offset - GICD_IROUTER) / 8; | ||
491 | |||
492 | if (irq < GIC_INTERNAL || irq >= s->num_irq) { | ||
493 | - return MEMTX_OK; | ||
494 | + return true; | ||
495 | } | ||
496 | |||
497 | /* Write half of the 64-bit register */ | ||
498 | r = gicd_read_irouter(s, attrs, irq); | ||
499 | r = deposit64(r, (offset & 7) ? 32 : 0, 32, value); | ||
500 | gicd_write_irouter(s, attrs, irq, r); | ||
501 | - return MEMTX_OK; | ||
502 | + return true; | ||
503 | } | ||
504 | case GICD_IDREGS ... GICD_IDREGS + 0x2f: | ||
505 | case GICD_TYPER: | ||
506 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicd_writel(GICv3State *s, hwaddr offset, | ||
507 | qemu_log_mask(LOG_GUEST_ERROR, | ||
508 | "%s: invalid guest write to RO register at offset " | ||
509 | TARGET_FMT_plx "\n", __func__, offset); | ||
510 | - return MEMTX_OK; | ||
511 | + return true; | ||
512 | default: | ||
513 | - return MEMTX_ERROR; | ||
514 | + return false; | ||
515 | } | ||
516 | } | ||
517 | |||
518 | -static MemTxResult gicd_writeq(GICv3State *s, hwaddr offset, | ||
519 | - uint64_t value, MemTxAttrs attrs) | ||
520 | +static bool gicd_writeq(GICv3State *s, hwaddr offset, | ||
521 | + uint64_t value, MemTxAttrs attrs) | ||
522 | { | ||
523 | /* Our only 64-bit registers are GICD_IROUTER<n> */ | ||
524 | int irq; | ||
525 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicd_writeq(GICv3State *s, hwaddr offset, | ||
526 | case GICD_IROUTER ... GICD_IROUTER + 0x1fdf: | ||
527 | irq = (offset - GICD_IROUTER) / 8; | ||
528 | gicd_write_irouter(s, attrs, irq, value); | ||
529 | - return MEMTX_OK; | ||
530 | + return true; | ||
531 | default: | ||
532 | - return MEMTX_ERROR; | ||
533 | + return false; | ||
534 | } | ||
535 | } | ||
536 | |||
537 | -static MemTxResult gicd_readq(GICv3State *s, hwaddr offset, | ||
538 | - uint64_t *data, MemTxAttrs attrs) | ||
539 | +static bool gicd_readq(GICv3State *s, hwaddr offset, | ||
540 | + uint64_t *data, MemTxAttrs attrs) | ||
541 | { | ||
542 | /* Our only 64-bit registers are GICD_IROUTER<n> */ | ||
543 | int irq; | ||
544 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicd_readq(GICv3State *s, hwaddr offset, | ||
545 | case GICD_IROUTER ... GICD_IROUTER + 0x1fdf: | ||
546 | irq = (offset - GICD_IROUTER) / 8; | ||
547 | *data = gicd_read_irouter(s, attrs, irq); | ||
548 | - return MEMTX_OK; | ||
549 | + return true; | ||
550 | default: | ||
551 | - return MEMTX_ERROR; | ||
552 | + return false; | ||
553 | } | ||
554 | } | ||
555 | |||
556 | @@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_dist_read(void *opaque, hwaddr offset, uint64_t *data, | ||
557 | unsigned size, MemTxAttrs attrs) | ||
558 | { | ||
559 | GICv3State *s = (GICv3State *)opaque; | ||
560 | - MemTxResult r; | ||
561 | + bool r; | ||
562 | |||
563 | switch (size) { | ||
564 | case 1: | ||
565 | @@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_dist_read(void *opaque, hwaddr offset, uint64_t *data, | ||
566 | r = gicd_readq(s, offset, data, attrs); | ||
567 | break; | ||
568 | default: | ||
569 | - r = MEMTX_ERROR; | ||
570 | + r = false; | ||
571 | break; | ||
572 | } | ||
573 | |||
574 | - if (r == MEMTX_ERROR) { | ||
575 | + if (!r) { | ||
576 | qemu_log_mask(LOG_GUEST_ERROR, | ||
577 | "%s: invalid guest read at offset " TARGET_FMT_plx | ||
578 | "size %u\n", __func__, offset, size); | ||
579 | @@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_dist_read(void *opaque, hwaddr offset, uint64_t *data, | ||
580 | * trigger the guest-error logging but don't return it to | ||
581 | * the caller, or we'll cause a spurious guest data abort. | ||
582 | */ | ||
583 | - r = MEMTX_OK; | ||
584 | *data = 0; | ||
585 | } else { | ||
586 | trace_gicv3_dist_read(offset, *data, size, attrs.secure); | ||
587 | } | ||
588 | - return r; | ||
589 | + return MEMTX_OK; | ||
590 | } | ||
591 | |||
592 | MemTxResult gicv3_dist_write(void *opaque, hwaddr offset, uint64_t data, | ||
593 | unsigned size, MemTxAttrs attrs) | ||
594 | { | ||
595 | GICv3State *s = (GICv3State *)opaque; | ||
596 | - MemTxResult r; | ||
597 | + bool r; | ||
598 | |||
599 | switch (size) { | ||
600 | case 1: | ||
601 | @@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_dist_write(void *opaque, hwaddr offset, uint64_t data, | ||
602 | r = gicd_writeq(s, offset, data, attrs); | ||
603 | break; | ||
604 | default: | ||
605 | - r = MEMTX_ERROR; | ||
606 | + r = false; | ||
607 | break; | ||
608 | } | ||
609 | |||
610 | - if (r == MEMTX_ERROR) { | ||
611 | + if (!r) { | ||
612 | qemu_log_mask(LOG_GUEST_ERROR, | ||
613 | "%s: invalid guest write at offset " TARGET_FMT_plx | ||
614 | "size %u\n", __func__, offset, size); | ||
615 | @@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_dist_write(void *opaque, hwaddr offset, uint64_t data, | ||
616 | * trigger the guest-error logging but don't return it to | ||
617 | * the caller, or we'll cause a spurious guest data abort. | ||
618 | */ | ||
619 | - r = MEMTX_OK; | ||
620 | } else { | ||
621 | trace_gicv3_dist_write(offset, data, size, attrs.secure); | ||
622 | } | ||
623 | - return r; | ||
624 | + return MEMTX_OK; | ||
625 | } | ||
626 | |||
627 | void gicv3_dist_set_irq(GICv3State *s, int irq, int level) | ||
628 | -- | 29 | -- |
629 | 2.20.1 | 30 | 2.20.1 |
630 | 31 | ||
631 | 32 | diff view generated by jsdifflib |
1 | The implementation of the Stellaris general purpose timer module | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | device stellaris-gptm is currently in the same source file as the | 2 | |
3 | board model. Split it out into its own source file in hw/timer. | 3 | and use a class AspeedSCUClass to define each SoC characteristics. |
4 | 4 | ||
5 | Apart from the new file comment headers and the Kconfig and | 5 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
6 | meson.build changes, this is just code movement. | 6 | Message-id: 20190904070506.1052-10-clg@kaod.org |
7 | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Damien Hedde <damien.hedde@greensocs.com> | ||
10 | Message-id: 20210812093356.1946-24-peter.maydell@linaro.org | ||
11 | --- | 9 | --- |
12 | include/hw/timer/stellaris-gptm.h | 48 +++++ | 10 | include/hw/misc/aspeed_scu.h | 15 +++++++ |
13 | hw/arm/stellaris.c | 321 +----------------------------- | 11 | hw/arm/aspeed_soc.c | 3 +- |
14 | hw/timer/stellaris-gptm.c | 314 +++++++++++++++++++++++++++++ | 12 | hw/misc/aspeed_scu.c | 83 ++++++++++++++++++++---------------- |
15 | hw/arm/Kconfig | 1 + | 13 | 3 files changed, 64 insertions(+), 37 deletions(-) |
16 | hw/timer/Kconfig | 3 + | 14 | |
17 | hw/timer/meson.build | 1 + | 15 | diff --git a/include/hw/misc/aspeed_scu.h b/include/hw/misc/aspeed_scu.h |
18 | 6 files changed, 368 insertions(+), 320 deletions(-) | 16 | index XXXXXXX..XXXXXXX 100644 |
19 | create mode 100644 include/hw/timer/stellaris-gptm.h | 17 | --- a/include/hw/misc/aspeed_scu.h |
20 | create mode 100644 hw/timer/stellaris-gptm.c | 18 | +++ b/include/hw/misc/aspeed_scu.h |
21 | |||
22 | diff --git a/include/hw/timer/stellaris-gptm.h b/include/hw/timer/stellaris-gptm.h | ||
23 | new file mode 100644 | ||
24 | index XXXXXXX..XXXXXXX | ||
25 | --- /dev/null | ||
26 | +++ b/include/hw/timer/stellaris-gptm.h | ||
27 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ |
28 | +/* | 20 | |
29 | + * Luminary Micro Stellaris General Purpose Timer Module | 21 | #define TYPE_ASPEED_SCU "aspeed.scu" |
30 | + * | 22 | #define ASPEED_SCU(obj) OBJECT_CHECK(AspeedSCUState, (obj), TYPE_ASPEED_SCU) |
31 | + * Copyright (c) 2006 CodeSourcery. | 23 | +#define TYPE_ASPEED_2400_SCU TYPE_ASPEED_SCU "-ast2400" |
32 | + * Written by Paul Brook | 24 | +#define TYPE_ASPEED_2500_SCU TYPE_ASPEED_SCU "-ast2500" |
33 | + * | 25 | |
34 | + * This code is licensed under the GPL. | 26 | #define ASPEED_SCU_NR_REGS (0x1A8 >> 2) |
35 | + */ | 27 | |
36 | + | 28 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSCUState { |
37 | +#ifndef HW_TIMER_STELLARIS_GPTM_H | 29 | |
38 | +#define HW_TIMER_STELLARIS_GPTM_H | 30 | extern bool is_supported_silicon_rev(uint32_t silicon_rev); |
39 | + | 31 | |
40 | +#include "qom/object.h" | 32 | +#define ASPEED_SCU_CLASS(klass) \ |
41 | +#include "hw/sysbus.h" | 33 | + OBJECT_CLASS_CHECK(AspeedSCUClass, (klass), TYPE_ASPEED_SCU) |
42 | +#include "hw/irq.h" | 34 | +#define ASPEED_SCU_GET_CLASS(obj) \ |
43 | + | 35 | + OBJECT_GET_CLASS(AspeedSCUClass, (obj), TYPE_ASPEED_SCU) |
44 | +#define TYPE_STELLARIS_GPTM "stellaris-gptm" | 36 | + |
45 | +OBJECT_DECLARE_SIMPLE_TYPE(gptm_state, STELLARIS_GPTM) | 37 | +typedef struct AspeedSCUClass { |
46 | + | 38 | + SysBusDeviceClass parent_class; |
47 | +/* | 39 | + |
48 | + * QEMU interface: | 40 | + const uint32_t *resets; |
49 | + * + sysbus MMIO region 0: register bank | 41 | + uint32_t (*calc_hpll)(AspeedSCUState *s); |
50 | + * + sysbus IRQ 0: timer interrupt | 42 | + uint32_t apb_divider; |
51 | + * + unnamed GPIO output 0: trigger output for the ADC | 43 | +} AspeedSCUClass; |
52 | + */ | 44 | + |
53 | +struct gptm_state { | 45 | #define ASPEED_SCU_PROT_KEY 0x1688A8A8 |
54 | + SysBusDevice parent_obj; | 46 | |
55 | + | 47 | /* |
56 | + MemoryRegion iomem; | 48 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c |
57 | + uint32_t config; | ||
58 | + uint32_t mode[2]; | ||
59 | + uint32_t control; | ||
60 | + uint32_t state; | ||
61 | + uint32_t mask; | ||
62 | + uint32_t load[2]; | ||
63 | + uint32_t match[2]; | ||
64 | + uint32_t prescale[2]; | ||
65 | + uint32_t match_prescale[2]; | ||
66 | + uint32_t rtc; | ||
67 | + int64_t tick[2]; | ||
68 | + struct gptm_state *opaque[2]; | ||
69 | + QEMUTimer *timer[2]; | ||
70 | + /* The timers have an alternate output used to trigger the ADC. */ | ||
71 | + qemu_irq trigger; | ||
72 | + qemu_irq irq; | ||
73 | +}; | ||
74 | + | ||
75 | +#endif | ||
76 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | ||
77 | index XXXXXXX..XXXXXXX 100644 | 49 | index XXXXXXX..XXXXXXX 100644 |
78 | --- a/hw/arm/stellaris.c | 50 | --- a/hw/arm/aspeed_soc.c |
79 | +++ b/hw/arm/stellaris.c | 51 | +++ b/hw/arm/aspeed_soc.c |
80 | @@ -XXX,XX +XXX,XX @@ | 52 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) |
81 | #include "hw/watchdog/cmsdk-apb-watchdog.h" | 53 | &error_abort, NULL); |
82 | #include "migration/vmstate.h" | 54 | } |
83 | #include "hw/misc/unimp.h" | 55 | |
84 | +#include "hw/timer/stellaris-gptm.h" | 56 | + snprintf(typename, sizeof(typename), "aspeed.scu-%s", socname); |
85 | #include "hw/qdev-clock.h" | 57 | sysbus_init_child_obj(obj, "scu", OBJECT(&s->scu), sizeof(s->scu), |
86 | #include "qom/object.h" | 58 | - TYPE_ASPEED_SCU); |
87 | 59 | + typename); | |
88 | @@ -XXX,XX +XXX,XX @@ typedef const struct { | 60 | qdev_prop_set_uint32(DEVICE(&s->scu), "silicon-rev", |
89 | uint32_t peripherals; | 61 | sc->info->silicon_rev); |
90 | } stellaris_board_info; | 62 | object_property_add_alias(obj, "hw-strap1", OBJECT(&s->scu), |
91 | 63 | diff --git a/hw/misc/aspeed_scu.c b/hw/misc/aspeed_scu.c | |
92 | -/* General purpose timer module. */ | 64 | index XXXXXXX..XXXXXXX 100644 |
65 | --- a/hw/misc/aspeed_scu.c | ||
66 | +++ b/hw/misc/aspeed_scu.c | ||
67 | @@ -XXX,XX +XXX,XX @@ static uint32_t aspeed_scu_get_random(void) | ||
68 | |||
69 | static void aspeed_scu_set_apb_freq(AspeedSCUState *s) | ||
70 | { | ||
71 | - uint32_t apb_divider; | ||
93 | - | 72 | - |
94 | -#define TYPE_STELLARIS_GPTM "stellaris-gptm" | 73 | - switch (s->silicon_rev) { |
95 | -OBJECT_DECLARE_SIMPLE_TYPE(gptm_state, STELLARIS_GPTM) | 74 | - case AST2400_A0_SILICON_REV: |
96 | - | 75 | - case AST2400_A1_SILICON_REV: |
97 | -struct gptm_state { | 76 | - apb_divider = 2; |
98 | - SysBusDevice parent_obj; | 77 | - break; |
99 | - | 78 | - case AST2500_A0_SILICON_REV: |
100 | - MemoryRegion iomem; | 79 | - case AST2500_A1_SILICON_REV: |
101 | - uint32_t config; | 80 | - apb_divider = 4; |
102 | - uint32_t mode[2]; | 81 | - break; |
103 | - uint32_t control; | 82 | - default: |
104 | - uint32_t state; | 83 | - g_assert_not_reached(); |
105 | - uint32_t mask; | 84 | - } |
106 | - uint32_t load[2]; | 85 | + AspeedSCUClass *asc = ASPEED_SCU_GET_CLASS(s); |
107 | - uint32_t match[2]; | 86 | |
108 | - uint32_t prescale[2]; | 87 | s->apb_freq = s->hpll / (SCU_CLK_GET_PCLK_DIV(s->regs[CLK_SEL]) + 1) |
109 | - uint32_t match_prescale[2]; | 88 | - / apb_divider; |
110 | - uint32_t rtc; | 89 | + / asc->apb_divider; |
111 | - int64_t tick[2]; | 90 | } |
112 | - struct gptm_state *opaque[2]; | 91 | |
113 | - QEMUTimer *timer[2]; | 92 | static uint64_t aspeed_scu_read(void *opaque, hwaddr offset, unsigned size) |
114 | - /* The timers have an alternate output used to trigger the ADC. */ | 93 | @@ -XXX,XX +XXX,XX @@ static const uint32_t hpll_ast2400_freqs[][4] = { |
115 | - qemu_irq trigger; | 94 | { 400, 375, 350, 425 }, /* 25MHz */ |
116 | - qemu_irq irq; | 95 | }; |
117 | -}; | 96 | |
118 | - | 97 | -static uint32_t aspeed_scu_calc_hpll_ast2400(AspeedSCUState *s) |
119 | -static void gptm_update_irq(gptm_state *s) | 98 | +static uint32_t aspeed_2400_scu_calc_hpll(AspeedSCUState *s) |
120 | -{ | 99 | { |
121 | - int level; | 100 | uint32_t hpll_reg = s->regs[HPLL_PARAM]; |
122 | - level = (s->state & s->mask) != 0; | 101 | uint8_t freq_select; |
123 | - qemu_set_irq(s->irq, level); | 102 | @@ -XXX,XX +XXX,XX @@ static uint32_t aspeed_scu_calc_hpll_ast2400(AspeedSCUState *s) |
124 | -} | 103 | return hpll_ast2400_freqs[clk_25m_in][freq_select] * 1000000; |
125 | - | 104 | } |
126 | -static void gptm_stop(gptm_state *s, int n) | 105 | |
127 | -{ | 106 | -static uint32_t aspeed_scu_calc_hpll_ast2500(AspeedSCUState *s) |
128 | - timer_del(s->timer[n]); | 107 | +static uint32_t aspeed_2500_scu_calc_hpll(AspeedSCUState *s) |
129 | -} | 108 | { |
130 | - | 109 | uint32_t hpll_reg = s->regs[HPLL_PARAM]; |
131 | -static void gptm_reload(gptm_state *s, int n, int reset) | 110 | uint32_t multiplier = 1; |
132 | -{ | 111 | @@ -XXX,XX +XXX,XX @@ static uint32_t aspeed_scu_calc_hpll_ast2500(AspeedSCUState *s) |
133 | - int64_t tick; | 112 | static void aspeed_scu_reset(DeviceState *dev) |
134 | - if (reset) { | 113 | { |
135 | - tick = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | 114 | AspeedSCUState *s = ASPEED_SCU(dev); |
136 | - } else { | 115 | - const uint32_t *reset; |
137 | - tick = s->tick[n]; | 116 | - uint32_t (*calc_hpll)(AspeedSCUState *s); |
117 | + AspeedSCUClass *asc = ASPEED_SCU_GET_CLASS(dev); | ||
118 | |||
119 | - switch (s->silicon_rev) { | ||
120 | - case AST2400_A0_SILICON_REV: | ||
121 | - case AST2400_A1_SILICON_REV: | ||
122 | - reset = ast2400_a0_resets; | ||
123 | - calc_hpll = aspeed_scu_calc_hpll_ast2400; | ||
124 | - break; | ||
125 | - case AST2500_A0_SILICON_REV: | ||
126 | - case AST2500_A1_SILICON_REV: | ||
127 | - reset = ast2500_a1_resets; | ||
128 | - calc_hpll = aspeed_scu_calc_hpll_ast2500; | ||
129 | - break; | ||
130 | - default: | ||
131 | - g_assert_not_reached(); | ||
138 | - } | 132 | - } |
139 | - | 133 | - |
140 | - if (s->config == 0) { | 134 | - memcpy(s->regs, reset, sizeof(s->regs)); |
141 | - /* 32-bit CountDown. */ | 135 | + memcpy(s->regs, asc->resets, sizeof(s->regs)); |
142 | - uint32_t count; | 136 | s->regs[SILICON_REV] = s->silicon_rev; |
143 | - count = s->load[0] | (s->load[1] << 16); | 137 | s->regs[HW_STRAP1] = s->hw_strap1; |
144 | - tick += (int64_t)count * system_clock_scale; | 138 | s->regs[HW_STRAP2] = s->hw_strap2; |
145 | - } else if (s->config == 1) { | 139 | @@ -XXX,XX +XXX,XX @@ static void aspeed_scu_reset(DeviceState *dev) |
146 | - /* 32-bit RTC. 1Hz tick. */ | 140 | * All registers are set. Now compute the frequencies of the main clocks |
147 | - tick += NANOSECONDS_PER_SECOND; | 141 | */ |
148 | - } else if (s->mode[n] == 0xa) { | 142 | s->clkin = aspeed_scu_get_clkin(s); |
149 | - /* PWM mode. Not implemented. */ | 143 | - s->hpll = calc_hpll(s); |
150 | - } else { | 144 | + s->hpll = asc->calc_hpll(s); |
151 | - qemu_log_mask(LOG_UNIMP, | 145 | aspeed_scu_set_apb_freq(s); |
152 | - "GPTM: 16-bit timer mode unimplemented: 0x%x\n", | 146 | } |
153 | - s->mode[n]); | 147 | |
154 | - return; | 148 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo aspeed_scu_info = { |
155 | - } | 149 | .parent = TYPE_SYS_BUS_DEVICE, |
156 | - s->tick[n] = tick; | 150 | .instance_size = sizeof(AspeedSCUState), |
157 | - timer_mod(s->timer[n], tick); | 151 | .class_init = aspeed_scu_class_init, |
158 | -} | 152 | + .class_size = sizeof(AspeedSCUClass), |
159 | - | 153 | + .abstract = true, |
160 | -static void gptm_tick(void *opaque) | ||
161 | -{ | ||
162 | - gptm_state **p = (gptm_state **)opaque; | ||
163 | - gptm_state *s; | ||
164 | - int n; | ||
165 | - | ||
166 | - s = *p; | ||
167 | - n = p - s->opaque; | ||
168 | - if (s->config == 0) { | ||
169 | - s->state |= 1; | ||
170 | - if ((s->control & 0x20)) { | ||
171 | - /* Output trigger. */ | ||
172 | - qemu_irq_pulse(s->trigger); | ||
173 | - } | ||
174 | - if (s->mode[0] & 1) { | ||
175 | - /* One-shot. */ | ||
176 | - s->control &= ~1; | ||
177 | - } else { | ||
178 | - /* Periodic. */ | ||
179 | - gptm_reload(s, 0, 0); | ||
180 | - } | ||
181 | - } else if (s->config == 1) { | ||
182 | - /* RTC. */ | ||
183 | - uint32_t match; | ||
184 | - s->rtc++; | ||
185 | - match = s->match[0] | (s->match[1] << 16); | ||
186 | - if (s->rtc > match) | ||
187 | - s->rtc = 0; | ||
188 | - if (s->rtc == 0) { | ||
189 | - s->state |= 8; | ||
190 | - } | ||
191 | - gptm_reload(s, 0, 0); | ||
192 | - } else if (s->mode[n] == 0xa) { | ||
193 | - /* PWM mode. Not implemented. */ | ||
194 | - } else { | ||
195 | - qemu_log_mask(LOG_UNIMP, | ||
196 | - "GPTM: 16-bit timer mode unimplemented: 0x%x\n", | ||
197 | - s->mode[n]); | ||
198 | - } | ||
199 | - gptm_update_irq(s); | ||
200 | -} | ||
201 | - | ||
202 | -static uint64_t gptm_read(void *opaque, hwaddr offset, | ||
203 | - unsigned size) | ||
204 | -{ | ||
205 | - gptm_state *s = (gptm_state *)opaque; | ||
206 | - | ||
207 | - switch (offset) { | ||
208 | - case 0x00: /* CFG */ | ||
209 | - return s->config; | ||
210 | - case 0x04: /* TAMR */ | ||
211 | - return s->mode[0]; | ||
212 | - case 0x08: /* TBMR */ | ||
213 | - return s->mode[1]; | ||
214 | - case 0x0c: /* CTL */ | ||
215 | - return s->control; | ||
216 | - case 0x18: /* IMR */ | ||
217 | - return s->mask; | ||
218 | - case 0x1c: /* RIS */ | ||
219 | - return s->state; | ||
220 | - case 0x20: /* MIS */ | ||
221 | - return s->state & s->mask; | ||
222 | - case 0x24: /* CR */ | ||
223 | - return 0; | ||
224 | - case 0x28: /* TAILR */ | ||
225 | - return s->load[0] | ((s->config < 4) ? (s->load[1] << 16) : 0); | ||
226 | - case 0x2c: /* TBILR */ | ||
227 | - return s->load[1]; | ||
228 | - case 0x30: /* TAMARCHR */ | ||
229 | - return s->match[0] | ((s->config < 4) ? (s->match[1] << 16) : 0); | ||
230 | - case 0x34: /* TBMATCHR */ | ||
231 | - return s->match[1]; | ||
232 | - case 0x38: /* TAPR */ | ||
233 | - return s->prescale[0]; | ||
234 | - case 0x3c: /* TBPR */ | ||
235 | - return s->prescale[1]; | ||
236 | - case 0x40: /* TAPMR */ | ||
237 | - return s->match_prescale[0]; | ||
238 | - case 0x44: /* TBPMR */ | ||
239 | - return s->match_prescale[1]; | ||
240 | - case 0x48: /* TAR */ | ||
241 | - if (s->config == 1) { | ||
242 | - return s->rtc; | ||
243 | - } | ||
244 | - qemu_log_mask(LOG_UNIMP, | ||
245 | - "GPTM: read of TAR but timer read not supported\n"); | ||
246 | - return 0; | ||
247 | - case 0x4c: /* TBR */ | ||
248 | - qemu_log_mask(LOG_UNIMP, | ||
249 | - "GPTM: read of TBR but timer read not supported\n"); | ||
250 | - return 0; | ||
251 | - default: | ||
252 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
253 | - "GPTM: read at bad offset 0x02%" HWADDR_PRIx "\n", | ||
254 | - offset); | ||
255 | - return 0; | ||
256 | - } | ||
257 | -} | ||
258 | - | ||
259 | -static void gptm_write(void *opaque, hwaddr offset, | ||
260 | - uint64_t value, unsigned size) | ||
261 | -{ | ||
262 | - gptm_state *s = (gptm_state *)opaque; | ||
263 | - uint32_t oldval; | ||
264 | - | ||
265 | - /* | ||
266 | - * The timers should be disabled before changing the configuration. | ||
267 | - * We take advantage of this and defer everything until the timer | ||
268 | - * is enabled. | ||
269 | - */ | ||
270 | - switch (offset) { | ||
271 | - case 0x00: /* CFG */ | ||
272 | - s->config = value; | ||
273 | - break; | ||
274 | - case 0x04: /* TAMR */ | ||
275 | - s->mode[0] = value; | ||
276 | - break; | ||
277 | - case 0x08: /* TBMR */ | ||
278 | - s->mode[1] = value; | ||
279 | - break; | ||
280 | - case 0x0c: /* CTL */ | ||
281 | - oldval = s->control; | ||
282 | - s->control = value; | ||
283 | - /* TODO: Implement pause. */ | ||
284 | - if ((oldval ^ value) & 1) { | ||
285 | - if (value & 1) { | ||
286 | - gptm_reload(s, 0, 1); | ||
287 | - } else { | ||
288 | - gptm_stop(s, 0); | ||
289 | - } | ||
290 | - } | ||
291 | - if (((oldval ^ value) & 0x100) && s->config >= 4) { | ||
292 | - if (value & 0x100) { | ||
293 | - gptm_reload(s, 1, 1); | ||
294 | - } else { | ||
295 | - gptm_stop(s, 1); | ||
296 | - } | ||
297 | - } | ||
298 | - break; | ||
299 | - case 0x18: /* IMR */ | ||
300 | - s->mask = value & 0x77; | ||
301 | - gptm_update_irq(s); | ||
302 | - break; | ||
303 | - case 0x24: /* CR */ | ||
304 | - s->state &= ~value; | ||
305 | - break; | ||
306 | - case 0x28: /* TAILR */ | ||
307 | - s->load[0] = value & 0xffff; | ||
308 | - if (s->config < 4) { | ||
309 | - s->load[1] = value >> 16; | ||
310 | - } | ||
311 | - break; | ||
312 | - case 0x2c: /* TBILR */ | ||
313 | - s->load[1] = value & 0xffff; | ||
314 | - break; | ||
315 | - case 0x30: /* TAMARCHR */ | ||
316 | - s->match[0] = value & 0xffff; | ||
317 | - if (s->config < 4) { | ||
318 | - s->match[1] = value >> 16; | ||
319 | - } | ||
320 | - break; | ||
321 | - case 0x34: /* TBMATCHR */ | ||
322 | - s->match[1] = value >> 16; | ||
323 | - break; | ||
324 | - case 0x38: /* TAPR */ | ||
325 | - s->prescale[0] = value; | ||
326 | - break; | ||
327 | - case 0x3c: /* TBPR */ | ||
328 | - s->prescale[1] = value; | ||
329 | - break; | ||
330 | - case 0x40: /* TAPMR */ | ||
331 | - s->match_prescale[0] = value; | ||
332 | - break; | ||
333 | - case 0x44: /* TBPMR */ | ||
334 | - s->match_prescale[0] = value; | ||
335 | - break; | ||
336 | - default: | ||
337 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
338 | - "GPTM: write at bad offset 0x02%" HWADDR_PRIx "\n", | ||
339 | - offset); | ||
340 | - } | ||
341 | - gptm_update_irq(s); | ||
342 | -} | ||
343 | - | ||
344 | -static const MemoryRegionOps gptm_ops = { | ||
345 | - .read = gptm_read, | ||
346 | - .write = gptm_write, | ||
347 | - .endianness = DEVICE_NATIVE_ENDIAN, | ||
348 | -}; | ||
349 | - | ||
350 | -static const VMStateDescription vmstate_stellaris_gptm = { | ||
351 | - .name = "stellaris_gptm", | ||
352 | - .version_id = 1, | ||
353 | - .minimum_version_id = 1, | ||
354 | - .fields = (VMStateField[]) { | ||
355 | - VMSTATE_UINT32(config, gptm_state), | ||
356 | - VMSTATE_UINT32_ARRAY(mode, gptm_state, 2), | ||
357 | - VMSTATE_UINT32(control, gptm_state), | ||
358 | - VMSTATE_UINT32(state, gptm_state), | ||
359 | - VMSTATE_UINT32(mask, gptm_state), | ||
360 | - VMSTATE_UNUSED(8), | ||
361 | - VMSTATE_UINT32_ARRAY(load, gptm_state, 2), | ||
362 | - VMSTATE_UINT32_ARRAY(match, gptm_state, 2), | ||
363 | - VMSTATE_UINT32_ARRAY(prescale, gptm_state, 2), | ||
364 | - VMSTATE_UINT32_ARRAY(match_prescale, gptm_state, 2), | ||
365 | - VMSTATE_UINT32(rtc, gptm_state), | ||
366 | - VMSTATE_INT64_ARRAY(tick, gptm_state, 2), | ||
367 | - VMSTATE_TIMER_PTR_ARRAY(timer, gptm_state, 2), | ||
368 | - VMSTATE_END_OF_LIST() | ||
369 | - } | ||
370 | -}; | ||
371 | - | ||
372 | -static void stellaris_gptm_init(Object *obj) | ||
373 | -{ | ||
374 | - DeviceState *dev = DEVICE(obj); | ||
375 | - gptm_state *s = STELLARIS_GPTM(obj); | ||
376 | - SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
377 | - | ||
378 | - sysbus_init_irq(sbd, &s->irq); | ||
379 | - qdev_init_gpio_out(dev, &s->trigger, 1); | ||
380 | - | ||
381 | - memory_region_init_io(&s->iomem, obj, &gptm_ops, s, | ||
382 | - "gptm", 0x1000); | ||
383 | - sysbus_init_mmio(sbd, &s->iomem); | ||
384 | - | ||
385 | - s->opaque[0] = s->opaque[1] = s; | ||
386 | -} | ||
387 | - | ||
388 | -static void stellaris_gptm_realize(DeviceState *dev, Error **errp) | ||
389 | -{ | ||
390 | - gptm_state *s = STELLARIS_GPTM(dev); | ||
391 | - s->timer[0] = timer_new_ns(QEMU_CLOCK_VIRTUAL, gptm_tick, &s->opaque[0]); | ||
392 | - s->timer[1] = timer_new_ns(QEMU_CLOCK_VIRTUAL, gptm_tick, &s->opaque[1]); | ||
393 | -} | ||
394 | - | ||
395 | /* System controller. */ | ||
396 | |||
397 | #define TYPE_STELLARIS_SYS "stellaris-sys" | ||
398 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo stellaris_i2c_info = { | ||
399 | .class_init = stellaris_i2c_class_init, | ||
400 | }; | ||
401 | |||
402 | -static void stellaris_gptm_class_init(ObjectClass *klass, void *data) | ||
403 | -{ | ||
404 | - DeviceClass *dc = DEVICE_CLASS(klass); | ||
405 | - | ||
406 | - dc->vmsd = &vmstate_stellaris_gptm; | ||
407 | - dc->realize = stellaris_gptm_realize; | ||
408 | -} | ||
409 | - | ||
410 | -static const TypeInfo stellaris_gptm_info = { | ||
411 | - .name = TYPE_STELLARIS_GPTM, | ||
412 | - .parent = TYPE_SYS_BUS_DEVICE, | ||
413 | - .instance_size = sizeof(gptm_state), | ||
414 | - .instance_init = stellaris_gptm_init, | ||
415 | - .class_init = stellaris_gptm_class_init, | ||
416 | -}; | ||
417 | - | ||
418 | static void stellaris_adc_class_init(ObjectClass *klass, void *data) | ||
419 | { | ||
420 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
421 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo stellaris_sys_info = { | ||
422 | static void stellaris_register_types(void) | ||
423 | { | ||
424 | type_register_static(&stellaris_i2c_info); | ||
425 | - type_register_static(&stellaris_gptm_info); | ||
426 | type_register_static(&stellaris_adc_info); | ||
427 | type_register_static(&stellaris_sys_info); | ||
428 | } | ||
429 | diff --git a/hw/timer/stellaris-gptm.c b/hw/timer/stellaris-gptm.c | ||
430 | new file mode 100644 | ||
431 | index XXXXXXX..XXXXXXX | ||
432 | --- /dev/null | ||
433 | +++ b/hw/timer/stellaris-gptm.c | ||
434 | @@ -XXX,XX +XXX,XX @@ | ||
435 | +/* | ||
436 | + * Luminary Micro Stellaris General Purpose Timer Module | ||
437 | + * | ||
438 | + * Copyright (c) 2006 CodeSourcery. | ||
439 | + * Written by Paul Brook | ||
440 | + * | ||
441 | + * This code is licensed under the GPL. | ||
442 | + */ | ||
443 | + | ||
444 | +#include "qemu/osdep.h" | ||
445 | +#include "qemu/log.h" | ||
446 | +#include "qemu/timer.h" | ||
447 | +#include "migration/vmstate.h" | ||
448 | +#include "hw/timer/stellaris-gptm.h" | ||
449 | +#include "hw/timer/armv7m_systick.h" /* Needed only for system_clock_scale */ | ||
450 | + | ||
451 | +static void gptm_update_irq(gptm_state *s) | ||
452 | +{ | ||
453 | + int level; | ||
454 | + level = (s->state & s->mask) != 0; | ||
455 | + qemu_set_irq(s->irq, level); | ||
456 | +} | ||
457 | + | ||
458 | +static void gptm_stop(gptm_state *s, int n) | ||
459 | +{ | ||
460 | + timer_del(s->timer[n]); | ||
461 | +} | ||
462 | + | ||
463 | +static void gptm_reload(gptm_state *s, int n, int reset) | ||
464 | +{ | ||
465 | + int64_t tick; | ||
466 | + if (reset) { | ||
467 | + tick = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | ||
468 | + } else { | ||
469 | + tick = s->tick[n]; | ||
470 | + } | ||
471 | + | ||
472 | + if (s->config == 0) { | ||
473 | + /* 32-bit CountDown. */ | ||
474 | + uint32_t count; | ||
475 | + count = s->load[0] | (s->load[1] << 16); | ||
476 | + tick += (int64_t)count * system_clock_scale; | ||
477 | + } else if (s->config == 1) { | ||
478 | + /* 32-bit RTC. 1Hz tick. */ | ||
479 | + tick += NANOSECONDS_PER_SECOND; | ||
480 | + } else if (s->mode[n] == 0xa) { | ||
481 | + /* PWM mode. Not implemented. */ | ||
482 | + } else { | ||
483 | + qemu_log_mask(LOG_UNIMP, | ||
484 | + "GPTM: 16-bit timer mode unimplemented: 0x%x\n", | ||
485 | + s->mode[n]); | ||
486 | + return; | ||
487 | + } | ||
488 | + s->tick[n] = tick; | ||
489 | + timer_mod(s->timer[n], tick); | ||
490 | +} | ||
491 | + | ||
492 | +static void gptm_tick(void *opaque) | ||
493 | +{ | ||
494 | + gptm_state **p = (gptm_state **)opaque; | ||
495 | + gptm_state *s; | ||
496 | + int n; | ||
497 | + | ||
498 | + s = *p; | ||
499 | + n = p - s->opaque; | ||
500 | + if (s->config == 0) { | ||
501 | + s->state |= 1; | ||
502 | + if ((s->control & 0x20)) { | ||
503 | + /* Output trigger. */ | ||
504 | + qemu_irq_pulse(s->trigger); | ||
505 | + } | ||
506 | + if (s->mode[0] & 1) { | ||
507 | + /* One-shot. */ | ||
508 | + s->control &= ~1; | ||
509 | + } else { | ||
510 | + /* Periodic. */ | ||
511 | + gptm_reload(s, 0, 0); | ||
512 | + } | ||
513 | + } else if (s->config == 1) { | ||
514 | + /* RTC. */ | ||
515 | + uint32_t match; | ||
516 | + s->rtc++; | ||
517 | + match = s->match[0] | (s->match[1] << 16); | ||
518 | + if (s->rtc > match) | ||
519 | + s->rtc = 0; | ||
520 | + if (s->rtc == 0) { | ||
521 | + s->state |= 8; | ||
522 | + } | ||
523 | + gptm_reload(s, 0, 0); | ||
524 | + } else if (s->mode[n] == 0xa) { | ||
525 | + /* PWM mode. Not implemented. */ | ||
526 | + } else { | ||
527 | + qemu_log_mask(LOG_UNIMP, | ||
528 | + "GPTM: 16-bit timer mode unimplemented: 0x%x\n", | ||
529 | + s->mode[n]); | ||
530 | + } | ||
531 | + gptm_update_irq(s); | ||
532 | +} | ||
533 | + | ||
534 | +static uint64_t gptm_read(void *opaque, hwaddr offset, | ||
535 | + unsigned size) | ||
536 | +{ | ||
537 | + gptm_state *s = (gptm_state *)opaque; | ||
538 | + | ||
539 | + switch (offset) { | ||
540 | + case 0x00: /* CFG */ | ||
541 | + return s->config; | ||
542 | + case 0x04: /* TAMR */ | ||
543 | + return s->mode[0]; | ||
544 | + case 0x08: /* TBMR */ | ||
545 | + return s->mode[1]; | ||
546 | + case 0x0c: /* CTL */ | ||
547 | + return s->control; | ||
548 | + case 0x18: /* IMR */ | ||
549 | + return s->mask; | ||
550 | + case 0x1c: /* RIS */ | ||
551 | + return s->state; | ||
552 | + case 0x20: /* MIS */ | ||
553 | + return s->state & s->mask; | ||
554 | + case 0x24: /* CR */ | ||
555 | + return 0; | ||
556 | + case 0x28: /* TAILR */ | ||
557 | + return s->load[0] | ((s->config < 4) ? (s->load[1] << 16) : 0); | ||
558 | + case 0x2c: /* TBILR */ | ||
559 | + return s->load[1]; | ||
560 | + case 0x30: /* TAMARCHR */ | ||
561 | + return s->match[0] | ((s->config < 4) ? (s->match[1] << 16) : 0); | ||
562 | + case 0x34: /* TBMATCHR */ | ||
563 | + return s->match[1]; | ||
564 | + case 0x38: /* TAPR */ | ||
565 | + return s->prescale[0]; | ||
566 | + case 0x3c: /* TBPR */ | ||
567 | + return s->prescale[1]; | ||
568 | + case 0x40: /* TAPMR */ | ||
569 | + return s->match_prescale[0]; | ||
570 | + case 0x44: /* TBPMR */ | ||
571 | + return s->match_prescale[1]; | ||
572 | + case 0x48: /* TAR */ | ||
573 | + if (s->config == 1) { | ||
574 | + return s->rtc; | ||
575 | + } | ||
576 | + qemu_log_mask(LOG_UNIMP, | ||
577 | + "GPTM: read of TAR but timer read not supported\n"); | ||
578 | + return 0; | ||
579 | + case 0x4c: /* TBR */ | ||
580 | + qemu_log_mask(LOG_UNIMP, | ||
581 | + "GPTM: read of TBR but timer read not supported\n"); | ||
582 | + return 0; | ||
583 | + default: | ||
584 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
585 | + "GPTM: read at bad offset 0x02%" HWADDR_PRIx "\n", | ||
586 | + offset); | ||
587 | + return 0; | ||
588 | + } | ||
589 | +} | ||
590 | + | ||
591 | +static void gptm_write(void *opaque, hwaddr offset, | ||
592 | + uint64_t value, unsigned size) | ||
593 | +{ | ||
594 | + gptm_state *s = (gptm_state *)opaque; | ||
595 | + uint32_t oldval; | ||
596 | + | ||
597 | + /* | ||
598 | + * The timers should be disabled before changing the configuration. | ||
599 | + * We take advantage of this and defer everything until the timer | ||
600 | + * is enabled. | ||
601 | + */ | ||
602 | + switch (offset) { | ||
603 | + case 0x00: /* CFG */ | ||
604 | + s->config = value; | ||
605 | + break; | ||
606 | + case 0x04: /* TAMR */ | ||
607 | + s->mode[0] = value; | ||
608 | + break; | ||
609 | + case 0x08: /* TBMR */ | ||
610 | + s->mode[1] = value; | ||
611 | + break; | ||
612 | + case 0x0c: /* CTL */ | ||
613 | + oldval = s->control; | ||
614 | + s->control = value; | ||
615 | + /* TODO: Implement pause. */ | ||
616 | + if ((oldval ^ value) & 1) { | ||
617 | + if (value & 1) { | ||
618 | + gptm_reload(s, 0, 1); | ||
619 | + } else { | ||
620 | + gptm_stop(s, 0); | ||
621 | + } | ||
622 | + } | ||
623 | + if (((oldval ^ value) & 0x100) && s->config >= 4) { | ||
624 | + if (value & 0x100) { | ||
625 | + gptm_reload(s, 1, 1); | ||
626 | + } else { | ||
627 | + gptm_stop(s, 1); | ||
628 | + } | ||
629 | + } | ||
630 | + break; | ||
631 | + case 0x18: /* IMR */ | ||
632 | + s->mask = value & 0x77; | ||
633 | + gptm_update_irq(s); | ||
634 | + break; | ||
635 | + case 0x24: /* CR */ | ||
636 | + s->state &= ~value; | ||
637 | + break; | ||
638 | + case 0x28: /* TAILR */ | ||
639 | + s->load[0] = value & 0xffff; | ||
640 | + if (s->config < 4) { | ||
641 | + s->load[1] = value >> 16; | ||
642 | + } | ||
643 | + break; | ||
644 | + case 0x2c: /* TBILR */ | ||
645 | + s->load[1] = value & 0xffff; | ||
646 | + break; | ||
647 | + case 0x30: /* TAMARCHR */ | ||
648 | + s->match[0] = value & 0xffff; | ||
649 | + if (s->config < 4) { | ||
650 | + s->match[1] = value >> 16; | ||
651 | + } | ||
652 | + break; | ||
653 | + case 0x34: /* TBMATCHR */ | ||
654 | + s->match[1] = value >> 16; | ||
655 | + break; | ||
656 | + case 0x38: /* TAPR */ | ||
657 | + s->prescale[0] = value; | ||
658 | + break; | ||
659 | + case 0x3c: /* TBPR */ | ||
660 | + s->prescale[1] = value; | ||
661 | + break; | ||
662 | + case 0x40: /* TAPMR */ | ||
663 | + s->match_prescale[0] = value; | ||
664 | + break; | ||
665 | + case 0x44: /* TBPMR */ | ||
666 | + s->match_prescale[0] = value; | ||
667 | + break; | ||
668 | + default: | ||
669 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
670 | + "GPTM: write at bad offset 0x02%" HWADDR_PRIx "\n", | ||
671 | + offset); | ||
672 | + } | ||
673 | + gptm_update_irq(s); | ||
674 | +} | ||
675 | + | ||
676 | +static const MemoryRegionOps gptm_ops = { | ||
677 | + .read = gptm_read, | ||
678 | + .write = gptm_write, | ||
679 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
680 | +}; | 154 | +}; |
681 | + | 155 | + |
682 | +static const VMStateDescription vmstate_stellaris_gptm = { | 156 | +static void aspeed_2400_scu_class_init(ObjectClass *klass, void *data) |
683 | + .name = "stellaris_gptm", | ||
684 | + .version_id = 1, | ||
685 | + .minimum_version_id = 1, | ||
686 | + .fields = (VMStateField[]) { | ||
687 | + VMSTATE_UINT32(config, gptm_state), | ||
688 | + VMSTATE_UINT32_ARRAY(mode, gptm_state, 2), | ||
689 | + VMSTATE_UINT32(control, gptm_state), | ||
690 | + VMSTATE_UINT32(state, gptm_state), | ||
691 | + VMSTATE_UINT32(mask, gptm_state), | ||
692 | + VMSTATE_UNUSED(8), | ||
693 | + VMSTATE_UINT32_ARRAY(load, gptm_state, 2), | ||
694 | + VMSTATE_UINT32_ARRAY(match, gptm_state, 2), | ||
695 | + VMSTATE_UINT32_ARRAY(prescale, gptm_state, 2), | ||
696 | + VMSTATE_UINT32_ARRAY(match_prescale, gptm_state, 2), | ||
697 | + VMSTATE_UINT32(rtc, gptm_state), | ||
698 | + VMSTATE_INT64_ARRAY(tick, gptm_state, 2), | ||
699 | + VMSTATE_TIMER_PTR_ARRAY(timer, gptm_state, 2), | ||
700 | + VMSTATE_END_OF_LIST() | ||
701 | + } | ||
702 | +}; | ||
703 | + | ||
704 | +static void stellaris_gptm_init(Object *obj) | ||
705 | +{ | ||
706 | + DeviceState *dev = DEVICE(obj); | ||
707 | + gptm_state *s = STELLARIS_GPTM(obj); | ||
708 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
709 | + | ||
710 | + sysbus_init_irq(sbd, &s->irq); | ||
711 | + qdev_init_gpio_out(dev, &s->trigger, 1); | ||
712 | + | ||
713 | + memory_region_init_io(&s->iomem, obj, &gptm_ops, s, | ||
714 | + "gptm", 0x1000); | ||
715 | + sysbus_init_mmio(sbd, &s->iomem); | ||
716 | + | ||
717 | + s->opaque[0] = s->opaque[1] = s; | ||
718 | +} | ||
719 | + | ||
720 | +static void stellaris_gptm_realize(DeviceState *dev, Error **errp) | ||
721 | +{ | ||
722 | + gptm_state *s = STELLARIS_GPTM(dev); | ||
723 | + s->timer[0] = timer_new_ns(QEMU_CLOCK_VIRTUAL, gptm_tick, &s->opaque[0]); | ||
724 | + s->timer[1] = timer_new_ns(QEMU_CLOCK_VIRTUAL, gptm_tick, &s->opaque[1]); | ||
725 | +} | ||
726 | + | ||
727 | +static void stellaris_gptm_class_init(ObjectClass *klass, void *data) | ||
728 | +{ | 157 | +{ |
729 | + DeviceClass *dc = DEVICE_CLASS(klass); | 158 | + DeviceClass *dc = DEVICE_CLASS(klass); |
730 | + | 159 | + AspeedSCUClass *asc = ASPEED_SCU_CLASS(klass); |
731 | + dc->vmsd = &vmstate_stellaris_gptm; | 160 | + |
732 | + dc->realize = stellaris_gptm_realize; | 161 | + dc->desc = "ASPEED 2400 System Control Unit"; |
162 | + asc->resets = ast2400_a0_resets; | ||
163 | + asc->calc_hpll = aspeed_2400_scu_calc_hpll; | ||
164 | + asc->apb_divider = 2; | ||
733 | +} | 165 | +} |
734 | + | 166 | + |
735 | +static const TypeInfo stellaris_gptm_info = { | 167 | +static const TypeInfo aspeed_2400_scu_info = { |
736 | + .name = TYPE_STELLARIS_GPTM, | 168 | + .name = TYPE_ASPEED_2400_SCU, |
737 | + .parent = TYPE_SYS_BUS_DEVICE, | 169 | + .parent = TYPE_ASPEED_SCU, |
738 | + .instance_size = sizeof(gptm_state), | 170 | + .instance_size = sizeof(AspeedSCUState), |
739 | + .instance_init = stellaris_gptm_init, | 171 | + .class_init = aspeed_2400_scu_class_init, |
740 | + .class_init = stellaris_gptm_class_init, | ||
741 | +}; | 172 | +}; |
742 | + | 173 | + |
743 | +static void stellaris_gptm_register_types(void) | 174 | +static void aspeed_2500_scu_class_init(ObjectClass *klass, void *data) |
744 | +{ | 175 | +{ |
745 | + type_register_static(&stellaris_gptm_info); | 176 | + DeviceClass *dc = DEVICE_CLASS(klass); |
177 | + AspeedSCUClass *asc = ASPEED_SCU_CLASS(klass); | ||
178 | + | ||
179 | + dc->desc = "ASPEED 2500 System Control Unit"; | ||
180 | + asc->resets = ast2500_a1_resets; | ||
181 | + asc->calc_hpll = aspeed_2500_scu_calc_hpll; | ||
182 | + asc->apb_divider = 4; | ||
746 | +} | 183 | +} |
747 | + | 184 | + |
748 | +type_init(stellaris_gptm_register_types) | 185 | +static const TypeInfo aspeed_2500_scu_info = { |
749 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | 186 | + .name = TYPE_ASPEED_2500_SCU, |
750 | index XXXXXXX..XXXXXXX 100644 | 187 | + .parent = TYPE_ASPEED_SCU, |
751 | --- a/hw/arm/Kconfig | 188 | + .instance_size = sizeof(AspeedSCUState), |
752 | +++ b/hw/arm/Kconfig | 189 | + .class_init = aspeed_2500_scu_class_init, |
753 | @@ -XXX,XX +XXX,XX @@ config STELLARIS | 190 | }; |
754 | select SSI_SD | 191 | |
755 | select STELLARIS_INPUT | 192 | static void aspeed_scu_register_types(void) |
756 | select STELLARIS_ENET # ethernet | 193 | { |
757 | + select STELLARIS_GPTM # general purpose timer module | 194 | type_register_static(&aspeed_scu_info); |
758 | select UNIMP | 195 | + type_register_static(&aspeed_2400_scu_info); |
759 | 196 | + type_register_static(&aspeed_2500_scu_info); | |
760 | config STM32VLDISCOVERY | 197 | } |
761 | diff --git a/hw/timer/Kconfig b/hw/timer/Kconfig | 198 | |
762 | index XXXXXXX..XXXXXXX 100644 | 199 | type_init(aspeed_scu_register_types); |
763 | --- a/hw/timer/Kconfig | ||
764 | +++ b/hw/timer/Kconfig | ||
765 | @@ -XXX,XX +XXX,XX @@ config SSE_COUNTER | ||
766 | config SSE_TIMER | ||
767 | bool | ||
768 | |||
769 | +config STELLARIS_GPTM | ||
770 | + bool | ||
771 | + | ||
772 | config AVR_TIMER16 | ||
773 | bool | ||
774 | diff --git a/hw/timer/meson.build b/hw/timer/meson.build | ||
775 | index XXXXXXX..XXXXXXX 100644 | ||
776 | --- a/hw/timer/meson.build | ||
777 | +++ b/hw/timer/meson.build | ||
778 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_SH_TIMER', if_true: files('sh_timer.c')) | ||
779 | softmmu_ss.add(when: 'CONFIG_SLAVIO', if_true: files('slavio_timer.c')) | ||
780 | softmmu_ss.add(when: 'CONFIG_SSE_COUNTER', if_true: files('sse-counter.c')) | ||
781 | softmmu_ss.add(when: 'CONFIG_SSE_TIMER', if_true: files('sse-timer.c')) | ||
782 | +softmmu_ss.add(when: 'CONFIG_STELLARIS_GPTM', if_true: files('stellaris-gptm.c')) | ||
783 | softmmu_ss.add(when: 'CONFIG_STM32F2XX_TIMER', if_true: files('stm32f2xx_timer.c')) | ||
784 | softmmu_ss.add(when: 'CONFIG_XILINX', if_true: files('xilinx_timer.c')) | ||
785 | specific_ss.add(when: 'CONFIG_IBEX', if_true: files('ibex_timer.c')) | ||
786 | -- | 200 | -- |
787 | 2.20.1 | 201 | 2.20.1 |
788 | 202 | ||
789 | 203 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Cédric Le Goater <clg@kaod.org> |
---|---|---|---|
2 | 2 | ||
3 | Commit 155e1c82ed0 deprecated the raspi2/raspi3 machine names. | 3 | The APB frequency can be calculated directly when needed from the |
4 | Use the recommended new names: raspi2b and raspi3b. | 4 | HPLL_PARAM and CLK_SEL register values. This removes useless state in |
5 | the model. | ||
5 | 6 | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
7 | Reviewed-by: Thomas Huth <thuth@redhat.com> | 8 | Message-id: 20190904070506.1052-11-clg@kaod.org |
8 | Reviewed-by: Willian Rampazzo <willianr@redhat.com> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Message-id: 20210827060815.2384760-2-f4bug@amsat.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 11 | --- |
12 | docs/devel/qgraph.rst | 38 ++++++++++++------------- | 12 | include/hw/misc/aspeed_scu.h | 8 +++----- |
13 | tests/qtest/libqos/qgraph.h | 6 ++-- | 13 | hw/misc/aspeed_scu.c | 25 +++++++++---------------- |
14 | tests/qtest/libqos/qgraph_internal.h | 2 +- | 14 | hw/timer/aspeed_timer.c | 3 ++- |
15 | tests/qtest/boot-serial-test.c | 2 +- | 15 | 3 files changed, 14 insertions(+), 22 deletions(-) |
16 | tests/qtest/libqos/arm-raspi2-machine.c | 8 +++--- | ||
17 | tests/unit/test-qgraph.c | 2 +- | ||
18 | tests/acceptance/boot_linux_console.py | 6 ++-- | ||
19 | 7 files changed, 32 insertions(+), 32 deletions(-) | ||
20 | 16 | ||
21 | diff --git a/docs/devel/qgraph.rst b/docs/devel/qgraph.rst | 17 | diff --git a/include/hw/misc/aspeed_scu.h b/include/hw/misc/aspeed_scu.h |
22 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/docs/devel/qgraph.rst | 19 | --- a/include/hw/misc/aspeed_scu.h |
24 | +++ b/docs/devel/qgraph.rst | 20 | +++ b/include/hw/misc/aspeed_scu.h |
25 | @@ -XXX,XX +XXX,XX @@ Nodes | 21 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSCUState { |
26 | 22 | uint32_t hw_strap1; | |
27 | A node can be of four types: | 23 | uint32_t hw_strap2; |
28 | 24 | uint32_t hw_prot_key; | |
29 | -- **QNODE_MACHINE**: for example ``arm/raspi2`` | 25 | - |
30 | +- **QNODE_MACHINE**: for example ``arm/raspi2b`` | 26 | - uint32_t clkin; |
31 | - **QNODE_DRIVER**: for example ``generic-sdhci`` | 27 | - uint32_t hpll; |
32 | - **QNODE_INTERFACE**: for example ``sdhci`` (interface for all ``-sdhci`` | 28 | - uint32_t apb_freq; |
33 | drivers). | 29 | } AspeedSCUState; |
34 | @@ -XXX,XX +XXX,XX @@ It is possible to troubleshoot unavailable tests by running:: | 30 | |
35 | # |-> dest='i440FX-pcihost' type=0 (node=0x5591421117f0) | 31 | #define AST2400_A0_SILICON_REV 0x02000303U |
36 | # src='' | 32 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSCUClass { |
37 | # |-> dest='x86_64/pc' type=0 (node=0x559142111600) | 33 | SysBusDeviceClass parent_class; |
38 | - # |-> dest='arm/raspi2' type=0 (node=0x559142110740) | 34 | |
39 | + # |-> dest='arm/raspi2b' type=0 (node=0x559142110740) | 35 | const uint32_t *resets; |
40 | ... | 36 | - uint32_t (*calc_hpll)(AspeedSCUState *s); |
41 | # } | 37 | + uint32_t (*calc_hpll)(AspeedSCUState *s, uint32_t hpll_reg); |
42 | # ALL QGRAPH NODES: { | 38 | uint32_t apb_divider; |
43 | # name='virtio-net-tests/announce-self' type=3 cmd_line='(null)' [available] | 39 | } AspeedSCUClass; |
44 | - # name='arm/raspi2' type=0 cmd_line='-M raspi2 ' [UNAVAILABLE] | 40 | |
45 | + # name='arm/raspi2b' type=0 cmd_line='-M raspi2b ' [UNAVAILABLE] | 41 | #define ASPEED_SCU_PROT_KEY 0x1688A8A8 |
46 | ... | 42 | |
47 | # } | 43 | +uint32_t aspeed_scu_get_apb_freq(AspeedSCUState *s); |
48 | 44 | + | |
49 | @@ -XXX,XX +XXX,XX @@ qgraph path in the "ALL QGRAPH EDGES" output as follows: '' -> 'x86_64/pc' -> | 45 | /* |
50 | 'virtio-net'. The root of the qgraph is '' and the depth first search begins | 46 | * Extracted from Aspeed SDK v00.03.21. Fixes and extra definitions |
51 | there. | 47 | * were added. |
52 | 48 | diff --git a/hw/misc/aspeed_scu.c b/hw/misc/aspeed_scu.c | |
53 | -The ``arm/raspi`` machine node is listed as "UNAVAILABLE". Although it is | 49 | index XXXXXXX..XXXXXXX 100644 |
54 | -reachable from the root via '' -> 'arm/raspi2' the node is unavailable because | 50 | --- a/hw/misc/aspeed_scu.c |
55 | +The ``arm/raspi2b`` machine node is listed as "UNAVAILABLE". Although it is | 51 | +++ b/hw/misc/aspeed_scu.c |
56 | +reachable from the root via '' -> 'arm/raspi2b' the node is unavailable because | 52 | @@ -XXX,XX +XXX,XX @@ static uint32_t aspeed_scu_get_random(void) |
57 | the QEMU binary did not list it when queried by the framework. This is expected | 53 | return num; |
58 | because we used the ``qemu-system-x86_64`` binary which does not support ARM | 54 | } |
59 | machine types. | 55 | |
60 | @@ -XXX,XX +XXX,XX @@ Here we continue the ``sdhci`` use case, with the following scenario: | 56 | -static void aspeed_scu_set_apb_freq(AspeedSCUState *s) |
61 | - ``sdhci-test`` aims to test the ``read[q,w], writeq`` functions | 57 | +uint32_t aspeed_scu_get_apb_freq(AspeedSCUState *s) |
62 | offered by the ``sdhci`` drivers. | 58 | { |
63 | - The current ``sdhci`` device is supported by both ``x86_64/pc`` and ``ARM`` | 59 | AspeedSCUClass *asc = ASPEED_SCU_GET_CLASS(s); |
64 | - (in this example we focus on the ``arm-raspi2``) machines. | 60 | + uint32_t hpll = asc->calc_hpll(s, s->regs[HPLL_PARAM]); |
65 | + (in this example we focus on the ``arm-raspi2b``) machines. | 61 | |
66 | - QEMU offers 2 types of drivers: ``QSDHCI_MemoryMapped`` for ``ARM`` and | 62 | - s->apb_freq = s->hpll / (SCU_CLK_GET_PCLK_DIV(s->regs[CLK_SEL]) + 1) |
67 | ``QSDHCI_PCI`` for ``x86_64/pc``. Both implement the | 63 | + return hpll / (SCU_CLK_GET_PCLK_DIV(s->regs[CLK_SEL]) + 1) |
68 | ``read[q,w], writeq`` functions. | 64 | / asc->apb_divider; |
69 | @@ -XXX,XX +XXX,XX @@ In order to implement such scenario in qgraph, the test developer needs to: | 65 | } |
70 | all the pci drivers available) | 66 | |
71 | 67 | @@ -XXX,XX +XXX,XX @@ static void aspeed_scu_write(void *opaque, hwaddr offset, uint64_t data, | |
72 | ``sdhci-pci --consumes--> pci-bus`` | 68 | return; |
73 | -- Create an ``arm/raspi2`` machine node. This machine ``contains`` | 69 | case CLK_SEL: |
74 | +- Create an ``arm/raspi2b`` machine node. This machine ``contains`` | 70 | s->regs[reg] = data; |
75 | a ``generic-sdhci`` memory mapped ``sdhci`` driver node, representing | 71 | - aspeed_scu_set_apb_freq(s); |
76 | ``QSDHCI_MemoryMapped``. | 72 | break; |
77 | 73 | case HW_STRAP1: | |
78 | - ``arm/raspi2 --contains--> generic-sdhci`` | 74 | if (ASPEED_IS_AST2500(s->regs[SILICON_REV])) { |
79 | + ``arm/raspi2b --contains--> generic-sdhci`` | 75 | @@ -XXX,XX +XXX,XX @@ static const uint32_t hpll_ast2400_freqs[][4] = { |
80 | - Create the ``sdhci`` interface node. This interface offers the | 76 | { 400, 375, 350, 425 }, /* 25MHz */ |
81 | functions that are shared by all ``sdhci`` devices. | 77 | }; |
82 | The interface is produced by ``sdhci-pci`` and ``generic-sdhci``, | 78 | |
83 | @@ -XXX,XX +XXX,XX @@ In order to implement such scenario in qgraph, the test developer needs to: | 79 | -static uint32_t aspeed_2400_scu_calc_hpll(AspeedSCUState *s) |
84 | 80 | +static uint32_t aspeed_2400_scu_calc_hpll(AspeedSCUState *s, uint32_t hpll_reg) | |
85 | ``sdhci-test --consumes--> sdhci`` | 81 | { |
86 | 82 | - uint32_t hpll_reg = s->regs[HPLL_PARAM]; | |
87 | -``arm-raspi2`` machine, simplified from | 83 | uint8_t freq_select; |
88 | +``arm-raspi2b`` machine, simplified from | 84 | bool clk_25m_in; |
89 | ``tests/qtest/libqos/arm-raspi2-machine.c``:: | 85 | + uint32_t clkin = aspeed_scu_get_clkin(s); |
90 | 86 | ||
91 | #include "qgraph.h" | 87 | if (hpll_reg & SCU_AST2400_H_PLL_OFF) { |
92 | @@ -XXX,XX +XXX,XX @@ In order to implement such scenario in qgraph, the test developer needs to: | 88 | return 0; |
93 | return &machine->alloc; | 89 | @@ -XXX,XX +XXX,XX @@ static uint32_t aspeed_2400_scu_calc_hpll(AspeedSCUState *s) |
90 | multiplier = (2 - od) * ((n + 2) / (d + 1)); | ||
94 | } | 91 | } |
95 | 92 | ||
96 | - fprintf(stderr, "%s not present in arm/raspi2\n", interface); | 93 | - return s->clkin * multiplier; |
97 | + fprintf(stderr, "%s not present in arm/raspi2b\n", interface); | 94 | + return clkin * multiplier; |
98 | g_assert_not_reached(); | ||
99 | } | 95 | } |
100 | 96 | ||
101 | @@ -XXX,XX +XXX,XX @@ In order to implement such scenario in qgraph, the test developer needs to: | 97 | /* HW strapping */ |
102 | return &machine->sdhci.obj; | 98 | @@ -XXX,XX +XXX,XX @@ static uint32_t aspeed_2400_scu_calc_hpll(AspeedSCUState *s) |
103 | } | 99 | return hpll_ast2400_freqs[clk_25m_in][freq_select] * 1000000; |
104 | 100 | } | |
105 | - fprintf(stderr, "%s not present in arm/raspi2\n", device); | 101 | |
106 | + fprintf(stderr, "%s not present in arm/raspi2b\n", device); | 102 | -static uint32_t aspeed_2500_scu_calc_hpll(AspeedSCUState *s) |
107 | g_assert_not_reached(); | 103 | +static uint32_t aspeed_2500_scu_calc_hpll(AspeedSCUState *s, uint32_t hpll_reg) |
104 | { | ||
105 | - uint32_t hpll_reg = s->regs[HPLL_PARAM]; | ||
106 | uint32_t multiplier = 1; | ||
107 | + uint32_t clkin = aspeed_scu_get_clkin(s); | ||
108 | |||
109 | if (hpll_reg & SCU_H_PLL_OFF) { | ||
110 | return 0; | ||
111 | @@ -XXX,XX +XXX,XX @@ static uint32_t aspeed_2500_scu_calc_hpll(AspeedSCUState *s) | ||
112 | multiplier = ((m + 1) / (n + 1)) / (p + 1); | ||
108 | } | 113 | } |
109 | 114 | ||
110 | @@ -XXX,XX +XXX,XX @@ In order to implement such scenario in qgraph, the test developer needs to: | 115 | - return s->clkin * multiplier; |
111 | 116 | + return clkin * multiplier; | |
112 | static void raspi2_register_nodes(void) | 117 | } |
113 | { | 118 | |
114 | - /* arm/raspi2 --contains--> generic-sdhci */ | 119 | static void aspeed_scu_reset(DeviceState *dev) |
115 | - qos_node_create_machine("arm/raspi2", | 120 | @@ -XXX,XX +XXX,XX @@ static void aspeed_scu_reset(DeviceState *dev) |
116 | + /* arm/raspi2b --contains--> generic-sdhci */ | 121 | s->regs[HW_STRAP1] = s->hw_strap1; |
117 | + qos_node_create_machine("arm/raspi2b", | 122 | s->regs[HW_STRAP2] = s->hw_strap2; |
118 | qos_create_machine_arm_raspi2); | 123 | s->regs[PROT_KEY] = s->hw_prot_key; |
119 | - qos_node_contains("arm/raspi2", "generic-sdhci", NULL); | 124 | - |
120 | + qos_node_contains("arm/raspi2b", "generic-sdhci", NULL); | 125 | - /* |
121 | } | 126 | - * All registers are set. Now compute the frequencies of the main clocks |
122 | 127 | - */ | |
123 | libqos_init(raspi2_register_nodes); | 128 | - s->clkin = aspeed_scu_get_clkin(s); |
124 | @@ -XXX,XX +XXX,XX @@ In the above example, all possible types of relations are created:: | 129 | - s->hpll = asc->calc_hpll(s); |
125 | | | 130 | - aspeed_scu_set_apb_freq(s); |
126 | +--produces-- + | 131 | } |
127 | | | 132 | |
128 | - arm/raspi2 --contains--> generic-sdhci | 133 | static uint32_t aspeed_silicon_revs[] = { |
129 | + arm/raspi2b --contains--> generic-sdhci | 134 | diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c |
130 | |||
131 | or inverting the consumes edge in consumed_by:: | ||
132 | |||
133 | @@ -XXX,XX +XXX,XX @@ or inverting the consumes edge in consumed_by:: | ||
134 | | | ||
135 | +--produces-- + | ||
136 | | | ||
137 | - arm/raspi2 --contains--> generic-sdhci | ||
138 | + arm/raspi2b --contains--> generic-sdhci | ||
139 | |||
140 | Adding a new test | ||
141 | """"""""""""""""" | ||
142 | @@ -XXX,XX +XXX,XX @@ Final graph will be like this:: | ||
143 | | | ||
144 | +--produces-- + | ||
145 | | | ||
146 | - arm/raspi2 --contains--> generic-sdhci | ||
147 | + arm/raspi2b --contains--> generic-sdhci | ||
148 | |||
149 | or inverting the consumes edge in consumed_by:: | ||
150 | |||
151 | @@ -XXX,XX +XXX,XX @@ or inverting the consumes edge in consumed_by:: | ||
152 | | | ||
153 | +--produces-- + | ||
154 | | | ||
155 | - arm/raspi2 --contains--> generic-sdhci | ||
156 | + arm/raspi2b --contains--> generic-sdhci | ||
157 | |||
158 | Assuming there the binary is | ||
159 | ``QTEST_QEMU_BINARY=./qemu-system-x86_64`` | ||
160 | @@ -XXX,XX +XXX,XX @@ a valid test path will be: | ||
161 | |||
162 | and for the binary ``QTEST_QEMU_BINARY=./qemu-system-arm``: | ||
163 | |||
164 | -``/arm/raspi2/generic-sdhci/sdhci/sdhci-test`` | ||
165 | +``/arm/raspi2b/generic-sdhci/sdhci/sdhci-test`` | ||
166 | |||
167 | Additional examples are also in ``test-qgraph.c`` | ||
168 | |||
169 | diff --git a/tests/qtest/libqos/qgraph.h b/tests/qtest/libqos/qgraph.h | ||
170 | index XXXXXXX..XXXXXXX 100644 | 135 | index XXXXXXX..XXXXXXX 100644 |
171 | --- a/tests/qtest/libqos/qgraph.h | 136 | --- a/hw/timer/aspeed_timer.c |
172 | +++ b/tests/qtest/libqos/qgraph.h | 137 | +++ b/hw/timer/aspeed_timer.c |
173 | @@ -XXX,XX +XXX,XX @@ void qos_node_create_driver_named(const char *name, const char *qemu_name, | 138 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t calculate_rate(struct AspeedTimer *t) |
174 | * This function can be useful when there are multiple devices | 139 | { |
175 | * with the same node name contained in a machine/other node | 140 | AspeedTimerCtrlState *s = timer_to_ctrl(t); |
176 | * | 141 | |
177 | - * For example, if ``arm/raspi2`` contains 2 ``generic-sdhci`` | 142 | - return timer_external_clock(t) ? TIMER_CLOCK_EXT_HZ : s->scu->apb_freq; |
178 | + * For example, if ``arm/raspi2b`` contains 2 ``generic-sdhci`` | 143 | + return timer_external_clock(t) ? TIMER_CLOCK_EXT_HZ : |
179 | * devices, the right commands will be: | 144 | + aspeed_scu_get_apb_freq(s->scu); |
180 | * | ||
181 | * .. code:: | ||
182 | * | ||
183 | - * qos_node_create_machine("arm/raspi2"); | ||
184 | + * qos_node_create_machine("arm/raspi2b"); | ||
185 | * qos_node_create_driver("generic-sdhci", constructor); | ||
186 | * // assume rest of the fields are set NULL | ||
187 | * QOSGraphEdgeOptions op1 = { .edge_name = "emmc" }; | ||
188 | * QOSGraphEdgeOptions op2 = { .edge_name = "sdcard" }; | ||
189 | - * qos_node_contains("arm/raspi2", "generic-sdhci", &op1, &op2, NULL); | ||
190 | + * qos_node_contains("arm/raspi2b", "generic-sdhci", &op1, &op2, NULL); | ||
191 | * | ||
192 | * Of course this also requires that the @container's get_device function | ||
193 | * should implement a case for "emmc" and "sdcard". | ||
194 | diff --git a/tests/qtest/libqos/qgraph_internal.h b/tests/qtest/libqos/qgraph_internal.h | ||
195 | index XXXXXXX..XXXXXXX 100644 | ||
196 | --- a/tests/qtest/libqos/qgraph_internal.h | ||
197 | +++ b/tests/qtest/libqos/qgraph_internal.h | ||
198 | @@ -XXX,XX +XXX,XX @@ void qos_graph_foreach_test_path(QOSTestCallback fn); | ||
199 | /** | ||
200 | * qos_get_machine_type(): return QEMU machine type for a machine node. | ||
201 | * This function requires every machine @name to be in the form | ||
202 | - * <arch>/<machine_name>, like "arm/raspi2" or "x86_64/pc". | ||
203 | + * <arch>/<machine_name>, like "arm/raspi2b" or "x86_64/pc". | ||
204 | * | ||
205 | * The function will validate the format and return a pointer to | ||
206 | * @machine to <machine_name>. For example, when passed "x86_64/pc" | ||
207 | diff --git a/tests/qtest/boot-serial-test.c b/tests/qtest/boot-serial-test.c | ||
208 | index XXXXXXX..XXXXXXX 100644 | ||
209 | --- a/tests/qtest/boot-serial-test.c | ||
210 | +++ b/tests/qtest/boot-serial-test.c | ||
211 | @@ -XXX,XX +XXX,XX @@ static testdef_t tests[] = { | ||
212 | sizeof(kernel_pls3adsp1800), kernel_pls3adsp1800 }, | ||
213 | { "microblazeel", "petalogix-ml605", "", "TT", | ||
214 | sizeof(kernel_plml605), kernel_plml605 }, | ||
215 | - { "arm", "raspi2", "", "TT", sizeof(bios_raspi2), 0, bios_raspi2 }, | ||
216 | + { "arm", "raspi2b", "", "TT", sizeof(bios_raspi2), 0, bios_raspi2 }, | ||
217 | /* For hppa, force bios to output to serial by disabling graphics. */ | ||
218 | { "hppa", "hppa", "-vga none", "SeaBIOS wants SYSTEM HALT" }, | ||
219 | { "aarch64", "virt", "-cpu max", "TT", sizeof(kernel_aarch64), | ||
220 | diff --git a/tests/qtest/libqos/arm-raspi2-machine.c b/tests/qtest/libqos/arm-raspi2-machine.c | ||
221 | index XXXXXXX..XXXXXXX 100644 | ||
222 | --- a/tests/qtest/libqos/arm-raspi2-machine.c | ||
223 | +++ b/tests/qtest/libqos/arm-raspi2-machine.c | ||
224 | @@ -XXX,XX +XXX,XX @@ static void *raspi2_get_driver(void *object, const char *interface) | ||
225 | return &machine->alloc; | ||
226 | } | ||
227 | |||
228 | - fprintf(stderr, "%s not present in arm/raspi2\n", interface); | ||
229 | + fprintf(stderr, "%s not present in arm/raspi2b\n", interface); | ||
230 | g_assert_not_reached(); | ||
231 | } | 145 | } |
232 | 146 | ||
233 | @@ -XXX,XX +XXX,XX @@ static QOSGraphObject *raspi2_get_device(void *obj, const char *device) | 147 | static inline uint32_t calculate_ticks(struct AspeedTimer *t, uint64_t now_ns) |
234 | return &machine->sdhci.obj; | ||
235 | } | ||
236 | |||
237 | - fprintf(stderr, "%s not present in arm/raspi2\n", device); | ||
238 | + fprintf(stderr, "%s not present in arm/raspi2b\n", device); | ||
239 | g_assert_not_reached(); | ||
240 | } | ||
241 | |||
242 | @@ -XXX,XX +XXX,XX @@ static void *qos_create_machine_arm_raspi2(QTestState *qts) | ||
243 | |||
244 | static void raspi2_register_nodes(void) | ||
245 | { | ||
246 | - qos_node_create_machine("arm/raspi2", qos_create_machine_arm_raspi2); | ||
247 | - qos_node_contains("arm/raspi2", "generic-sdhci", NULL); | ||
248 | + qos_node_create_machine("arm/raspi2b", qos_create_machine_arm_raspi2); | ||
249 | + qos_node_contains("arm/raspi2b", "generic-sdhci", NULL); | ||
250 | } | ||
251 | |||
252 | libqos_init(raspi2_register_nodes); | ||
253 | diff --git a/tests/unit/test-qgraph.c b/tests/unit/test-qgraph.c | ||
254 | index XXXXXXX..XXXXXXX 100644 | ||
255 | --- a/tests/unit/test-qgraph.c | ||
256 | +++ b/tests/unit/test-qgraph.c | ||
257 | @@ -XXX,XX +XXX,XX @@ | ||
258 | #include "../qtest/libqos/qgraph_internal.h" | ||
259 | |||
260 | #define MACHINE_PC "x86_64/pc" | ||
261 | -#define MACHINE_RASPI2 "arm/raspi2" | ||
262 | +#define MACHINE_RASPI2 "arm/raspi2b" | ||
263 | #define I440FX "i440FX-pcihost" | ||
264 | #define PCIBUS_PC "pcibus-pc" | ||
265 | #define SDHCI "sdhci" | ||
266 | diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py | ||
267 | index XXXXXXX..XXXXXXX 100644 | ||
268 | --- a/tests/acceptance/boot_linux_console.py | ||
269 | +++ b/tests/acceptance/boot_linux_console.py | ||
270 | @@ -XXX,XX +XXX,XX @@ def do_test_arm_raspi2(self, uart_id): | ||
271 | def test_arm_raspi2_uart0(self): | ||
272 | """ | ||
273 | :avocado: tags=arch:arm | ||
274 | - :avocado: tags=machine:raspi2 | ||
275 | + :avocado: tags=machine:raspi2b | ||
276 | :avocado: tags=device:pl011 | ||
277 | :avocado: tags=accel:tcg | ||
278 | """ | ||
279 | @@ -XXX,XX +XXX,XX @@ def test_arm_raspi2_uart0(self): | ||
280 | def test_arm_raspi2_initrd(self): | ||
281 | """ | ||
282 | :avocado: tags=arch:arm | ||
283 | - :avocado: tags=machine:raspi2 | ||
284 | + :avocado: tags=machine:raspi2b | ||
285 | """ | ||
286 | deb_url = ('http://archive.raspberrypi.org/debian/' | ||
287 | 'pool/main/r/raspberrypi-firmware/' | ||
288 | @@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_uboot_netbsd9(self): | ||
289 | def test_aarch64_raspi3_atf(self): | ||
290 | """ | ||
291 | :avocado: tags=arch:aarch64 | ||
292 | - :avocado: tags=machine:raspi3 | ||
293 | + :avocado: tags=machine:raspi3b | ||
294 | :avocado: tags=cpu:cortex-a53 | ||
295 | :avocado: tags=device:pl011 | ||
296 | :avocado: tags=atf | ||
297 | -- | 148 | -- |
298 | 2.20.1 | 149 | 2.20.1 |
299 | 150 | ||
300 | 151 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
2 | 1 | ||
3 | QEMU load/store API (docs/devel/loads-stores.rst) uses the 'q' | ||
4 | suffix for 64-bit accesses. Rename the current 'll' suffix to | ||
5 | have the GIC dist accessors better match the rest of the codebase. | ||
6 | |||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Message-id: 20210826180704.2131949-2-philmd@redhat.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/intc/arm_gicv3_dist.c | 12 ++++++------ | ||
12 | 1 file changed, 6 insertions(+), 6 deletions(-) | ||
13 | |||
14 | diff --git a/hw/intc/arm_gicv3_dist.c b/hw/intc/arm_gicv3_dist.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/intc/arm_gicv3_dist.c | ||
17 | +++ b/hw/intc/arm_gicv3_dist.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicd_writel(GICv3State *s, hwaddr offset, | ||
19 | } | ||
20 | } | ||
21 | |||
22 | -static MemTxResult gicd_writell(GICv3State *s, hwaddr offset, | ||
23 | - uint64_t value, MemTxAttrs attrs) | ||
24 | +static MemTxResult gicd_writeq(GICv3State *s, hwaddr offset, | ||
25 | + uint64_t value, MemTxAttrs attrs) | ||
26 | { | ||
27 | /* Our only 64-bit registers are GICD_IROUTER<n> */ | ||
28 | int irq; | ||
29 | @@ -XXX,XX +XXX,XX @@ static MemTxResult gicd_writell(GICv3State *s, hwaddr offset, | ||
30 | } | ||
31 | } | ||
32 | |||
33 | -static MemTxResult gicd_readll(GICv3State *s, hwaddr offset, | ||
34 | - uint64_t *data, MemTxAttrs attrs) | ||
35 | +static MemTxResult gicd_readq(GICv3State *s, hwaddr offset, | ||
36 | + uint64_t *data, MemTxAttrs attrs) | ||
37 | { | ||
38 | /* Our only 64-bit registers are GICD_IROUTER<n> */ | ||
39 | int irq; | ||
40 | @@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_dist_read(void *opaque, hwaddr offset, uint64_t *data, | ||
41 | r = gicd_readl(s, offset, data, attrs); | ||
42 | break; | ||
43 | case 8: | ||
44 | - r = gicd_readll(s, offset, data, attrs); | ||
45 | + r = gicd_readq(s, offset, data, attrs); | ||
46 | break; | ||
47 | default: | ||
48 | r = MEMTX_ERROR; | ||
49 | @@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_dist_write(void *opaque, hwaddr offset, uint64_t data, | ||
50 | r = gicd_writel(s, offset, data, attrs); | ||
51 | break; | ||
52 | case 8: | ||
53 | - r = gicd_writell(s, offset, data, attrs); | ||
54 | + r = gicd_writeq(s, offset, data, attrs); | ||
55 | break; | ||
56 | default: | ||
57 | r = MEMTX_ERROR; | ||
58 | -- | ||
59 | 2.20.1 | ||
60 | |||
61 | diff view generated by jsdifflib |
1 | From: Yanan Wang <wangyanan55@huawei.com> | 1 | From: "Emilio G. Cota" <cota@braap.org> |
---|---|---|---|
2 | 2 | ||
3 | Add 6.2 machine types for arm/i440fx/q35/s390x/spapr. | 3 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
4 | 4 | Signed-off-by: Emilio G. Cota <cota@braap.org> | |
5 | Signed-off-by: Yanan Wang <wangyanan55@huawei.com> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Acked-by: David Gibson <david@gibson.dropbear.id.au> | 6 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> |
7 | Reviewed-by: Andrew Jones <drjones@redhat.com> | ||
8 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> | ||
9 | Reviewed-by: Pankaj Gupta <pankaj.gupta@ionos.com> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 8 | --- |
12 | include/hw/boards.h | 3 +++ | 9 | accel/tcg/atomic_template.h | 2 +- |
13 | include/hw/i386/pc.h | 3 +++ | 10 | 1 file changed, 1 insertion(+), 1 deletion(-) |
14 | hw/arm/virt.c | 11 +++++++++-- | ||
15 | hw/core/machine.c | 3 +++ | ||
16 | hw/i386/pc.c | 3 +++ | ||
17 | hw/i386/pc_piix.c | 14 +++++++++++++- | ||
18 | hw/i386/pc_q35.c | 13 ++++++++++++- | ||
19 | hw/ppc/spapr.c | 17 ++++++++++++++--- | ||
20 | hw/s390x/s390-virtio-ccw.c | 14 +++++++++++++- | ||
21 | 9 files changed, 73 insertions(+), 8 deletions(-) | ||
22 | 11 | ||
23 | diff --git a/include/hw/boards.h b/include/hw/boards.h | 12 | diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h |
24 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/include/hw/boards.h | 14 | --- a/accel/tcg/atomic_template.h |
26 | +++ b/include/hw/boards.h | 15 | +++ b/accel/tcg/atomic_template.h |
27 | @@ -XXX,XX +XXX,XX @@ struct MachineState { | 16 | @@ -XXX,XX +XXX,XX @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, target_ulong addr, |
28 | } \ | 17 | |
29 | type_init(machine_initfn##_register_types) | 18 | #define GEN_ATOMIC_HELPER(X) \ |
30 | 19 | ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \ | |
31 | +extern GlobalProperty hw_compat_6_1[]; | 20 | - ABI_TYPE val EXTRA_ARGS) \ |
32 | +extern const size_t hw_compat_6_1_len; | 21 | + ABI_TYPE val EXTRA_ARGS) \ |
33 | + | 22 | { \ |
34 | extern GlobalProperty hw_compat_6_0[]; | 23 | ATOMIC_MMU_DECLS; \ |
35 | extern const size_t hw_compat_6_0_len; | 24 | DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; \ |
36 | |||
37 | diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/include/hw/i386/pc.h | ||
40 | +++ b/include/hw/i386/pc.h | ||
41 | @@ -XXX,XX +XXX,XX @@ void pc_system_parse_ovmf_flash(uint8_t *flash_ptr, size_t flash_size); | ||
42 | void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, | ||
43 | const CPUArchIdList *apic_ids, GArray *entry); | ||
44 | |||
45 | +extern GlobalProperty pc_compat_6_1[]; | ||
46 | +extern const size_t pc_compat_6_1_len; | ||
47 | + | ||
48 | extern GlobalProperty pc_compat_6_0[]; | ||
49 | extern const size_t pc_compat_6_0_len; | ||
50 | |||
51 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/hw/arm/virt.c | ||
54 | +++ b/hw/arm/virt.c | ||
55 | @@ -XXX,XX +XXX,XX @@ static void machvirt_machine_init(void) | ||
56 | } | ||
57 | type_init(machvirt_machine_init); | ||
58 | |||
59 | -static void virt_machine_6_1_options(MachineClass *mc) | ||
60 | +static void virt_machine_6_2_options(MachineClass *mc) | ||
61 | { | ||
62 | } | ||
63 | -DEFINE_VIRT_MACHINE_AS_LATEST(6, 1) | ||
64 | +DEFINE_VIRT_MACHINE_AS_LATEST(6, 2) | ||
65 | + | ||
66 | +static void virt_machine_6_1_options(MachineClass *mc) | ||
67 | +{ | ||
68 | + virt_machine_6_2_options(mc); | ||
69 | + compat_props_add(mc->compat_props, hw_compat_6_1, hw_compat_6_1_len); | ||
70 | +} | ||
71 | +DEFINE_VIRT_MACHINE(6, 1) | ||
72 | |||
73 | static void virt_machine_6_0_options(MachineClass *mc) | ||
74 | { | ||
75 | diff --git a/hw/core/machine.c b/hw/core/machine.c | ||
76 | index XXXXXXX..XXXXXXX 100644 | ||
77 | --- a/hw/core/machine.c | ||
78 | +++ b/hw/core/machine.c | ||
79 | @@ -XXX,XX +XXX,XX @@ | ||
80 | #include "hw/virtio/virtio.h" | ||
81 | #include "hw/virtio/virtio-pci.h" | ||
82 | |||
83 | +GlobalProperty hw_compat_6_1[] = {}; | ||
84 | +const size_t hw_compat_6_1_len = G_N_ELEMENTS(hw_compat_6_1); | ||
85 | + | ||
86 | GlobalProperty hw_compat_6_0[] = { | ||
87 | { "gpex-pcihost", "allow-unmapped-accesses", "false" }, | ||
88 | { "i8042", "extended-state", "false"}, | ||
89 | diff --git a/hw/i386/pc.c b/hw/i386/pc.c | ||
90 | index XXXXXXX..XXXXXXX 100644 | ||
91 | --- a/hw/i386/pc.c | ||
92 | +++ b/hw/i386/pc.c | ||
93 | @@ -XXX,XX +XXX,XX @@ | ||
94 | #include "trace.h" | ||
95 | #include CONFIG_DEVICES | ||
96 | |||
97 | +GlobalProperty pc_compat_6_1[] = {}; | ||
98 | +const size_t pc_compat_6_1_len = G_N_ELEMENTS(pc_compat_6_1); | ||
99 | + | ||
100 | GlobalProperty pc_compat_6_0[] = { | ||
101 | { "qemu64" "-" TYPE_X86_CPU, "family", "6" }, | ||
102 | { "qemu64" "-" TYPE_X86_CPU, "model", "6" }, | ||
103 | diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c | ||
104 | index XXXXXXX..XXXXXXX 100644 | ||
105 | --- a/hw/i386/pc_piix.c | ||
106 | +++ b/hw/i386/pc_piix.c | ||
107 | @@ -XXX,XX +XXX,XX @@ static void pc_i440fx_machine_options(MachineClass *m) | ||
108 | machine_class_allow_dynamic_sysbus_dev(m, TYPE_VMBUS_BRIDGE); | ||
109 | } | ||
110 | |||
111 | -static void pc_i440fx_6_1_machine_options(MachineClass *m) | ||
112 | +static void pc_i440fx_6_2_machine_options(MachineClass *m) | ||
113 | { | ||
114 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); | ||
115 | pc_i440fx_machine_options(m); | ||
116 | @@ -XXX,XX +XXX,XX @@ static void pc_i440fx_6_1_machine_options(MachineClass *m) | ||
117 | pcmc->default_cpu_version = 1; | ||
118 | } | ||
119 | |||
120 | +DEFINE_I440FX_MACHINE(v6_2, "pc-i440fx-6.2", NULL, | ||
121 | + pc_i440fx_6_2_machine_options); | ||
122 | + | ||
123 | +static void pc_i440fx_6_1_machine_options(MachineClass *m) | ||
124 | +{ | ||
125 | + pc_i440fx_6_2_machine_options(m); | ||
126 | + m->alias = NULL; | ||
127 | + m->is_default = false; | ||
128 | + compat_props_add(m->compat_props, hw_compat_6_1, hw_compat_6_1_len); | ||
129 | + compat_props_add(m->compat_props, pc_compat_6_1, pc_compat_6_1_len); | ||
130 | +} | ||
131 | + | ||
132 | DEFINE_I440FX_MACHINE(v6_1, "pc-i440fx-6.1", NULL, | ||
133 | pc_i440fx_6_1_machine_options); | ||
134 | |||
135 | diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c | ||
136 | index XXXXXXX..XXXXXXX 100644 | ||
137 | --- a/hw/i386/pc_q35.c | ||
138 | +++ b/hw/i386/pc_q35.c | ||
139 | @@ -XXX,XX +XXX,XX @@ static void pc_q35_machine_options(MachineClass *m) | ||
140 | m->max_cpus = 288; | ||
141 | } | ||
142 | |||
143 | -static void pc_q35_6_1_machine_options(MachineClass *m) | ||
144 | +static void pc_q35_6_2_machine_options(MachineClass *m) | ||
145 | { | ||
146 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); | ||
147 | pc_q35_machine_options(m); | ||
148 | @@ -XXX,XX +XXX,XX @@ static void pc_q35_6_1_machine_options(MachineClass *m) | ||
149 | pcmc->default_cpu_version = 1; | ||
150 | } | ||
151 | |||
152 | +DEFINE_Q35_MACHINE(v6_2, "pc-q35-6.2", NULL, | ||
153 | + pc_q35_6_2_machine_options); | ||
154 | + | ||
155 | +static void pc_q35_6_1_machine_options(MachineClass *m) | ||
156 | +{ | ||
157 | + pc_q35_6_2_machine_options(m); | ||
158 | + m->alias = NULL; | ||
159 | + compat_props_add(m->compat_props, hw_compat_6_1, hw_compat_6_1_len); | ||
160 | + compat_props_add(m->compat_props, pc_compat_6_1, pc_compat_6_1_len); | ||
161 | +} | ||
162 | + | ||
163 | DEFINE_Q35_MACHINE(v6_1, "pc-q35-6.1", NULL, | ||
164 | pc_q35_6_1_machine_options); | ||
165 | |||
166 | diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c | ||
167 | index XXXXXXX..XXXXXXX 100644 | ||
168 | --- a/hw/ppc/spapr.c | ||
169 | +++ b/hw/ppc/spapr.c | ||
170 | @@ -XXX,XX +XXX,XX @@ static void spapr_machine_latest_class_options(MachineClass *mc) | ||
171 | type_init(spapr_machine_register_##suffix) | ||
172 | |||
173 | /* | ||
174 | - * pseries-6.1 | ||
175 | + * pseries-6.2 | ||
176 | */ | ||
177 | -static void spapr_machine_6_1_class_options(MachineClass *mc) | ||
178 | +static void spapr_machine_6_2_class_options(MachineClass *mc) | ||
179 | { | ||
180 | /* Defaults for the latest behaviour inherited from the base class */ | ||
181 | } | ||
182 | |||
183 | -DEFINE_SPAPR_MACHINE(6_1, "6.1", true); | ||
184 | +DEFINE_SPAPR_MACHINE(6_2, "6.2", true); | ||
185 | + | ||
186 | +/* | ||
187 | + * pseries-6.1 | ||
188 | + */ | ||
189 | +static void spapr_machine_6_1_class_options(MachineClass *mc) | ||
190 | +{ | ||
191 | + spapr_machine_6_2_class_options(mc); | ||
192 | + compat_props_add(mc->compat_props, hw_compat_6_1, hw_compat_6_1_len); | ||
193 | +} | ||
194 | + | ||
195 | +DEFINE_SPAPR_MACHINE(6_1, "6.1", false); | ||
196 | |||
197 | /* | ||
198 | * pseries-6.0 | ||
199 | diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c | ||
200 | index XXXXXXX..XXXXXXX 100644 | ||
201 | --- a/hw/s390x/s390-virtio-ccw.c | ||
202 | +++ b/hw/s390x/s390-virtio-ccw.c | ||
203 | @@ -XXX,XX +XXX,XX @@ bool css_migration_enabled(void) | ||
204 | } \ | ||
205 | type_init(ccw_machine_register_##suffix) | ||
206 | |||
207 | +static void ccw_machine_6_2_instance_options(MachineState *machine) | ||
208 | +{ | ||
209 | +} | ||
210 | + | ||
211 | +static void ccw_machine_6_2_class_options(MachineClass *mc) | ||
212 | +{ | ||
213 | +} | ||
214 | +DEFINE_CCW_MACHINE(6_2, "6.2", true); | ||
215 | + | ||
216 | static void ccw_machine_6_1_instance_options(MachineState *machine) | ||
217 | { | ||
218 | + ccw_machine_6_2_instance_options(machine); | ||
219 | } | ||
220 | |||
221 | static void ccw_machine_6_1_class_options(MachineClass *mc) | ||
222 | { | ||
223 | + ccw_machine_6_2_class_options(mc); | ||
224 | + compat_props_add(mc->compat_props, hw_compat_6_1, hw_compat_6_1_len); | ||
225 | } | ||
226 | -DEFINE_CCW_MACHINE(6_1, "6.1", true); | ||
227 | +DEFINE_CCW_MACHINE(6_1, "6.1", false); | ||
228 | |||
229 | static void ccw_machine_6_0_instance_options(MachineState *machine) | ||
230 | { | ||
231 | -- | 25 | -- |
232 | 2.20.1 | 26 | 2.20.1 |
233 | 27 | ||
234 | 28 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement more simple 2-operand floating point MVE insns. | ||
2 | 1 | ||
3 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | --- | ||
6 | target/arm/helper-mve.h | 15 +++++++++++++++ | ||
7 | target/arm/mve.decode | 6 ++++++ | ||
8 | target/arm/mve_helper.c | 16 ++++++++++++++++ | ||
9 | target/arm/translate-mve.c | 5 +++++ | ||
10 | 4 files changed, 42 insertions(+) | ||
11 | |||
12 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/helper-mve.h | ||
15 | +++ b/target/arm/helper-mve.h | ||
16 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vhcadd270w, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
17 | DEF_HELPER_FLAGS_4(mve_vfaddh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
18 | DEF_HELPER_FLAGS_4(mve_vfadds, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
19 | |||
20 | +DEF_HELPER_FLAGS_4(mve_vfsubh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
21 | +DEF_HELPER_FLAGS_4(mve_vfsubs, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
22 | + | ||
23 | +DEF_HELPER_FLAGS_4(mve_vfmulh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
24 | +DEF_HELPER_FLAGS_4(mve_vfmuls, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
25 | + | ||
26 | +DEF_HELPER_FLAGS_4(mve_vfabdh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vfabds, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
28 | + | ||
29 | +DEF_HELPER_FLAGS_4(mve_vmaxnmh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
30 | +DEF_HELPER_FLAGS_4(mve_vmaxnms, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
31 | + | ||
32 | +DEF_HELPER_FLAGS_4(mve_vminnmh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
33 | +DEF_HELPER_FLAGS_4(mve_vminnms, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
34 | + | ||
35 | DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
36 | DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
37 | DEF_HELPER_FLAGS_4(mve_vadd_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
38 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/target/arm/mve.decode | ||
41 | +++ b/target/arm/mve.decode | ||
42 | @@ -XXX,XX +XXX,XX @@ VCMPLE_scalar 1111 1110 0 . .. ... 1 ... 1 1111 1 1 1 0 .... @vcmp_scalar | ||
43 | |||
44 | # 2-operand FP | ||
45 | VADD_fp 1110 1111 0 . 0 . ... 0 ... 0 1101 . 1 . 0 ... 0 @2op_fp | ||
46 | +VSUB_fp 1110 1111 0 . 1 . ... 0 ... 0 1101 . 1 . 0 ... 0 @2op_fp | ||
47 | +VMUL_fp 1111 1111 0 . 0 . ... 0 ... 0 1101 . 1 . 1 ... 0 @2op_fp | ||
48 | +VABD_fp 1111 1111 0 . 1 . ... 0 ... 0 1101 . 1 . 0 ... 0 @2op_fp | ||
49 | + | ||
50 | +VMAXNM 1111 1111 0 . 0 . ... 0 ... 0 1111 . 1 . 1 ... 0 @2op_fp | ||
51 | +VMINNM 1111 1111 0 . 1 . ... 0 ... 0 1111 . 1 . 1 ... 0 @2op_fp | ||
52 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/target/arm/mve_helper.c | ||
55 | +++ b/target/arm/mve_helper.c | ||
56 | @@ -XXX,XX +XXX,XX @@ DO_VMAXMINA(vminaw, 4, int32_t, uint32_t, DO_MIN) | ||
57 | DO_2OP_FP(OP##s, 4, float32, float32_##FN) | ||
58 | |||
59 | DO_2OP_FP_ALL(vfadd, add) | ||
60 | +DO_2OP_FP_ALL(vfsub, sub) | ||
61 | +DO_2OP_FP_ALL(vfmul, mul) | ||
62 | + | ||
63 | +static inline float16 float16_abd(float16 a, float16 b, float_status *s) | ||
64 | +{ | ||
65 | + return float16_abs(float16_sub(a, b, s)); | ||
66 | +} | ||
67 | + | ||
68 | +static inline float32 float32_abd(float32 a, float32 b, float_status *s) | ||
69 | +{ | ||
70 | + return float32_abs(float32_sub(a, b, s)); | ||
71 | +} | ||
72 | + | ||
73 | +DO_2OP_FP_ALL(vfabd, abd) | ||
74 | +DO_2OP_FP_ALL(vmaxnm, maxnum) | ||
75 | +DO_2OP_FP_ALL(vminnm, minnum) | ||
76 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/target/arm/translate-mve.c | ||
79 | +++ b/target/arm/translate-mve.c | ||
80 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSBCI(DisasContext *s, arg_2op *a) | ||
81 | } | ||
82 | |||
83 | DO_2OP_FP(VADD_fp, vfadd) | ||
84 | +DO_2OP_FP(VSUB_fp, vfsub) | ||
85 | +DO_2OP_FP(VMUL_fp, vfmul) | ||
86 | +DO_2OP_FP(VABD_fp, vfabd) | ||
87 | +DO_2OP_FP(VMAXNM, vmaxnm) | ||
88 | +DO_2OP_FP(VMINNM, vminnm) | ||
89 | |||
90 | static bool do_2op_scalar(DisasContext *s, arg_2scalar *a, | ||
91 | MVEGenTwoOpScalarFn fn) | ||
92 | -- | ||
93 | 2.20.1 | ||
94 | |||
95 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VCADD insn. Note that here the size bit is the | ||
2 | opposite sense to the other 2-operand fp insns. | ||
3 | 1 | ||
4 | We don't check for the sz == 1 && Qd == Qm UNPREDICTABLE case, | ||
5 | because that would mean we can't use the DO_2OP_FP macro in | ||
6 | translate-mve.c. | ||
7 | |||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/helper-mve.h | 6 ++++++ | ||
12 | target/arm/mve.decode | 8 ++++++++ | ||
13 | target/arm/mve_helper.c | 40 ++++++++++++++++++++++++++++++++++++++ | ||
14 | target/arm/translate-mve.c | 4 +++- | ||
15 | 4 files changed, 57 insertions(+), 1 deletion(-) | ||
16 | |||
17 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/helper-mve.h | ||
20 | +++ b/target/arm/helper-mve.h | ||
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vmaxnms, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
22 | DEF_HELPER_FLAGS_4(mve_vminnmh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
23 | DEF_HELPER_FLAGS_4(mve_vminnms, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
24 | |||
25 | +DEF_HELPER_FLAGS_4(mve_vfcadd90h, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vfcadd90s, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
27 | + | ||
28 | +DEF_HELPER_FLAGS_4(mve_vfcadd270h, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
29 | +DEF_HELPER_FLAGS_4(mve_vfcadd270s, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
30 | + | ||
31 | DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
32 | DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
33 | DEF_HELPER_FLAGS_4(mve_vadd_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
34 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/target/arm/mve.decode | ||
37 | +++ b/target/arm/mve.decode | ||
38 | @@ -XXX,XX +XXX,XX @@ | ||
39 | # 2 operand fp insns have size in bit 20: 1 for 16 bit, 0 for 32 bit, | ||
40 | # like Neon FP insns. | ||
41 | %2op_fp_size 20:1 !function=neon_3same_fp_size | ||
42 | +# VCADD is an exception, where bit 20 is 0 for 16 bit and 1 for 32 bit | ||
43 | +%2op_fp_size_rev 20:1 !function=plus_1 | ||
44 | |||
45 | # 1imm format immediate | ||
46 | %imm_28_16_0 28:1 16:3 0:4 | ||
47 | @@ -XXX,XX +XXX,XX @@ | ||
48 | @2op_fp .... .... .... .... .... .... .... .... &2op \ | ||
49 | qd=%qd qn=%qn qm=%qm size=%2op_fp_size | ||
50 | |||
51 | +@2op_fp_size_rev .... .... .... .... .... .... .... .... &2op \ | ||
52 | + qd=%qd qn=%qn qm=%qm size=%2op_fp_size_rev | ||
53 | + | ||
54 | # Vector loads and stores | ||
55 | |||
56 | # Widening loads and narrowing stores: | ||
57 | @@ -XXX,XX +XXX,XX @@ VABD_fp 1111 1111 0 . 1 . ... 0 ... 0 1101 . 1 . 0 ... 0 @2op_fp | ||
58 | |||
59 | VMAXNM 1111 1111 0 . 0 . ... 0 ... 0 1111 . 1 . 1 ... 0 @2op_fp | ||
60 | VMINNM 1111 1111 0 . 1 . ... 0 ... 0 1111 . 1 . 1 ... 0 @2op_fp | ||
61 | + | ||
62 | +VCADD90_fp 1111 1100 1 . 0 . ... 0 ... 0 1000 . 1 . 0 ... 0 @2op_fp_size_rev | ||
63 | +VCADD270_fp 1111 1101 1 . 0 . ... 0 ... 0 1000 . 1 . 0 ... 0 @2op_fp_size_rev | ||
64 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
65 | index XXXXXXX..XXXXXXX 100644 | ||
66 | --- a/target/arm/mve_helper.c | ||
67 | +++ b/target/arm/mve_helper.c | ||
68 | @@ -XXX,XX +XXX,XX @@ static inline float32 float32_abd(float32 a, float32 b, float_status *s) | ||
69 | DO_2OP_FP_ALL(vfabd, abd) | ||
70 | DO_2OP_FP_ALL(vmaxnm, maxnum) | ||
71 | DO_2OP_FP_ALL(vminnm, minnum) | ||
72 | + | ||
73 | +#define DO_VCADD_FP(OP, ESIZE, TYPE, FN0, FN1) \ | ||
74 | + void HELPER(glue(mve_, OP))(CPUARMState *env, \ | ||
75 | + void *vd, void *vn, void *vm) \ | ||
76 | + { \ | ||
77 | + TYPE *d = vd, *n = vn, *m = vm; \ | ||
78 | + TYPE r[16 / ESIZE]; \ | ||
79 | + uint16_t tm, mask = mve_element_mask(env); \ | ||
80 | + unsigned e; \ | ||
81 | + float_status *fpst; \ | ||
82 | + float_status scratch_fpst; \ | ||
83 | + /* Calculate all results first to avoid overwriting inputs */ \ | ||
84 | + for (e = 0, tm = mask; e < 16 / ESIZE; e++, tm >>= ESIZE) { \ | ||
85 | + if ((tm & MAKE_64BIT_MASK(0, ESIZE)) == 0) { \ | ||
86 | + r[e] = 0; \ | ||
87 | + continue; \ | ||
88 | + } \ | ||
89 | + fpst = (ESIZE == 2) ? &env->vfp.standard_fp_status_f16 : \ | ||
90 | + &env->vfp.standard_fp_status; \ | ||
91 | + if (!(tm & 1)) { \ | ||
92 | + /* We need the result but without updating flags */ \ | ||
93 | + scratch_fpst = *fpst; \ | ||
94 | + fpst = &scratch_fpst; \ | ||
95 | + } \ | ||
96 | + if (!(e & 1)) { \ | ||
97 | + r[e] = FN0(n[H##ESIZE(e)], m[H##ESIZE(e + 1)], fpst); \ | ||
98 | + } else { \ | ||
99 | + r[e] = FN1(n[H##ESIZE(e)], m[H##ESIZE(e - 1)], fpst); \ | ||
100 | + } \ | ||
101 | + } \ | ||
102 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
103 | + mergemask(&d[H##ESIZE(e)], r[e], mask); \ | ||
104 | + } \ | ||
105 | + mve_advance_vpt(env); \ | ||
106 | + } | ||
107 | + | ||
108 | +DO_VCADD_FP(vfcadd90h, 2, float16, float16_sub, float16_add) | ||
109 | +DO_VCADD_FP(vfcadd90s, 4, float32, float32_sub, float32_add) | ||
110 | +DO_VCADD_FP(vfcadd270h, 2, float16, float16_add, float16_sub) | ||
111 | +DO_VCADD_FP(vfcadd270s, 4, float32, float32_add, float32_sub) | ||
112 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
113 | index XXXXXXX..XXXXXXX 100644 | ||
114 | --- a/target/arm/translate-mve.c | ||
115 | +++ b/target/arm/translate-mve.c | ||
116 | @@ -XXX,XX +XXX,XX @@ DO_2OP_FP(VMUL_fp, vfmul) | ||
117 | DO_2OP_FP(VABD_fp, vfabd) | ||
118 | DO_2OP_FP(VMAXNM, vmaxnm) | ||
119 | DO_2OP_FP(VMINNM, vminnm) | ||
120 | +DO_2OP_FP(VCADD90_fp, vfcadd90) | ||
121 | +DO_2OP_FP(VCADD270_fp, vfcadd270) | ||
122 | |||
123 | static bool do_2op_scalar(DisasContext *s, arg_2scalar *a, | ||
124 | MVEGenTwoOpScalarFn fn) | ||
125 | @@ -XXX,XX +XXX,XX @@ static bool do_2op_scalar(DisasContext *s, arg_2scalar *a, | ||
126 | return true; | ||
127 | } | ||
128 | |||
129 | -#define DO_2OP_SCALAR(INSN, FN) \ | ||
130 | +#define DO_2OP_SCALAR(INSN, FN) \ | ||
131 | static bool trans_##INSN(DisasContext *s, arg_2scalar *a) \ | ||
132 | { \ | ||
133 | static MVEGenTwoOpScalarFn * const fns[] = { \ | ||
134 | -- | ||
135 | 2.20.1 | ||
136 | |||
137 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VFMA and VFMS insns. | ||
2 | 1 | ||
3 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | --- | ||
6 | target/arm/helper-mve.h | 6 ++++++ | ||
7 | target/arm/mve.decode | 3 +++ | ||
8 | target/arm/mve_helper.c | 37 +++++++++++++++++++++++++++++++++++++ | ||
9 | target/arm/translate-mve.c | 2 ++ | ||
10 | 4 files changed, 48 insertions(+) | ||
11 | |||
12 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/helper-mve.h | ||
15 | +++ b/target/arm/helper-mve.h | ||
16 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vfcadd90s, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
17 | DEF_HELPER_FLAGS_4(mve_vfcadd270h, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
18 | DEF_HELPER_FLAGS_4(mve_vfcadd270s, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
19 | |||
20 | +DEF_HELPER_FLAGS_4(mve_vfmah, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
21 | +DEF_HELPER_FLAGS_4(mve_vfmas, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
22 | + | ||
23 | +DEF_HELPER_FLAGS_4(mve_vfmsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
24 | +DEF_HELPER_FLAGS_4(mve_vfmss, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
25 | + | ||
26 | DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
27 | DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | DEF_HELPER_FLAGS_4(mve_vadd_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
29 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/mve.decode | ||
32 | +++ b/target/arm/mve.decode | ||
33 | @@ -XXX,XX +XXX,XX @@ VMINNM 1111 1111 0 . 1 . ... 0 ... 0 1111 . 1 . 1 ... 0 @2op_fp | ||
34 | |||
35 | VCADD90_fp 1111 1100 1 . 0 . ... 0 ... 0 1000 . 1 . 0 ... 0 @2op_fp_size_rev | ||
36 | VCADD270_fp 1111 1101 1 . 0 . ... 0 ... 0 1000 . 1 . 0 ... 0 @2op_fp_size_rev | ||
37 | + | ||
38 | +VFMA 1110 1111 0 . 0 . ... 0 ... 0 1100 . 1 . 1 ... 0 @2op_fp | ||
39 | +VFMS 1110 1111 0 . 1 . ... 0 ... 0 1100 . 1 . 1 ... 0 @2op_fp | ||
40 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/arm/mve_helper.c | ||
43 | +++ b/target/arm/mve_helper.c | ||
44 | @@ -XXX,XX +XXX,XX @@ DO_VCADD_FP(vfcadd90h, 2, float16, float16_sub, float16_add) | ||
45 | DO_VCADD_FP(vfcadd90s, 4, float32, float32_sub, float32_add) | ||
46 | DO_VCADD_FP(vfcadd270h, 2, float16, float16_add, float16_sub) | ||
47 | DO_VCADD_FP(vfcadd270s, 4, float32, float32_add, float32_sub) | ||
48 | + | ||
49 | +#define DO_VFMA(OP, ESIZE, TYPE, CHS) \ | ||
50 | + void HELPER(glue(mve_, OP))(CPUARMState *env, \ | ||
51 | + void *vd, void *vn, void *vm) \ | ||
52 | + { \ | ||
53 | + TYPE *d = vd, *n = vn, *m = vm; \ | ||
54 | + TYPE r; \ | ||
55 | + uint16_t mask = mve_element_mask(env); \ | ||
56 | + unsigned e; \ | ||
57 | + float_status *fpst; \ | ||
58 | + float_status scratch_fpst; \ | ||
59 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
60 | + if ((mask & MAKE_64BIT_MASK(0, ESIZE)) == 0) { \ | ||
61 | + continue; \ | ||
62 | + } \ | ||
63 | + fpst = (ESIZE == 2) ? &env->vfp.standard_fp_status_f16 : \ | ||
64 | + &env->vfp.standard_fp_status; \ | ||
65 | + if (!(mask & 1)) { \ | ||
66 | + /* We need the result but without updating flags */ \ | ||
67 | + scratch_fpst = *fpst; \ | ||
68 | + fpst = &scratch_fpst; \ | ||
69 | + } \ | ||
70 | + r = n[H##ESIZE(e)]; \ | ||
71 | + if (CHS) { \ | ||
72 | + r = TYPE##_chs(r); \ | ||
73 | + } \ | ||
74 | + r = TYPE##_muladd(r, m[H##ESIZE(e)], d[H##ESIZE(e)], \ | ||
75 | + 0, fpst); \ | ||
76 | + mergemask(&d[H##ESIZE(e)], r, mask); \ | ||
77 | + } \ | ||
78 | + mve_advance_vpt(env); \ | ||
79 | + } | ||
80 | + | ||
81 | +DO_VFMA(vfmah, 2, float16, false) | ||
82 | +DO_VFMA(vfmas, 4, float32, false) | ||
83 | +DO_VFMA(vfmsh, 2, float16, true) | ||
84 | +DO_VFMA(vfmss, 4, float32, true) | ||
85 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
86 | index XXXXXXX..XXXXXXX 100644 | ||
87 | --- a/target/arm/translate-mve.c | ||
88 | +++ b/target/arm/translate-mve.c | ||
89 | @@ -XXX,XX +XXX,XX @@ DO_2OP_FP(VMAXNM, vmaxnm) | ||
90 | DO_2OP_FP(VMINNM, vminnm) | ||
91 | DO_2OP_FP(VCADD90_fp, vfcadd90) | ||
92 | DO_2OP_FP(VCADD270_fp, vfcadd270) | ||
93 | +DO_2OP_FP(VFMA, vfma) | ||
94 | +DO_2OP_FP(VFMS, vfms) | ||
95 | |||
96 | static bool do_2op_scalar(DisasContext *s, arg_2scalar *a, | ||
97 | MVEGenTwoOpScalarFn fn) | ||
98 | -- | ||
99 | 2.20.1 | ||
100 | |||
101 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VCMUL and VCMLA insns. | ||
2 | 1 | ||
3 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | --- | ||
6 | target/arm/helper-mve.h | 18 ++++++++ | ||
7 | target/arm/mve.decode | 35 ++++++++++++---- | ||
8 | target/arm/mve_helper.c | 86 ++++++++++++++++++++++++++++++++++++++ | ||
9 | target/arm/translate-mve.c | 8 ++++ | ||
10 | 4 files changed, 139 insertions(+), 8 deletions(-) | ||
11 | |||
12 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/helper-mve.h | ||
15 | +++ b/target/arm/helper-mve.h | ||
16 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vfmas, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
17 | DEF_HELPER_FLAGS_4(mve_vfmsh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
18 | DEF_HELPER_FLAGS_4(mve_vfmss, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
19 | |||
20 | +DEF_HELPER_FLAGS_4(mve_vcmul0h, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
21 | +DEF_HELPER_FLAGS_4(mve_vcmul0s, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
22 | +DEF_HELPER_FLAGS_4(mve_vcmul90h, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
23 | +DEF_HELPER_FLAGS_4(mve_vcmul90s, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
24 | +DEF_HELPER_FLAGS_4(mve_vcmul180h, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
25 | +DEF_HELPER_FLAGS_4(mve_vcmul180s, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vcmul270h, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vcmul270s, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
28 | + | ||
29 | +DEF_HELPER_FLAGS_4(mve_vcmla0h, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
30 | +DEF_HELPER_FLAGS_4(mve_vcmla0s, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
31 | +DEF_HELPER_FLAGS_4(mve_vcmla90h, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
32 | +DEF_HELPER_FLAGS_4(mve_vcmla90s, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
33 | +DEF_HELPER_FLAGS_4(mve_vcmla180h, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
34 | +DEF_HELPER_FLAGS_4(mve_vcmla180s, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
35 | +DEF_HELPER_FLAGS_4(mve_vcmla270h, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
36 | +DEF_HELPER_FLAGS_4(mve_vcmla270s, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
37 | + | ||
38 | DEF_HELPER_FLAGS_4(mve_vadd_scalarb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
39 | DEF_HELPER_FLAGS_4(mve_vadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
40 | DEF_HELPER_FLAGS_4(mve_vadd_scalarw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
41 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/target/arm/mve.decode | ||
44 | +++ b/target/arm/mve.decode | ||
45 | @@ -XXX,XX +XXX,XX @@ VQSHL_U 111 1 1111 0 . .. ... 0 ... 0 0100 . 1 . 1 ... 0 @2op_rev | ||
46 | VQRSHL_S 111 0 1111 0 . .. ... 0 ... 0 0101 . 1 . 1 ... 0 @2op_rev | ||
47 | VQRSHL_U 111 1 1111 0 . .. ... 0 ... 0 0101 . 1 . 1 ... 0 @2op_rev | ||
48 | |||
49 | -VQDMLADH 1110 1110 0 . .. ... 0 ... 0 1110 . 0 . 0 ... 0 @2op | ||
50 | -VQDMLADHX 1110 1110 0 . .. ... 0 ... 1 1110 . 0 . 0 ... 0 @2op | ||
51 | -VQRDMLADH 1110 1110 0 . .. ... 0 ... 0 1110 . 0 . 0 ... 1 @2op | ||
52 | -VQRDMLADHX 1110 1110 0 . .. ... 0 ... 1 1110 . 0 . 0 ... 1 @2op | ||
53 | +{ | ||
54 | + VCMUL0 111 . 1110 0 . 11 ... 0 ... 0 1110 . 0 . 0 ... 0 @2op_sz28 | ||
55 | + VQDMLADH 1110 1110 0 . .. ... 0 ... 0 1110 . 0 . 0 ... 0 @2op | ||
56 | + VQDMLSDH 1111 1110 0 . .. ... 0 ... 0 1110 . 0 . 0 ... 0 @2op | ||
57 | +} | ||
58 | |||
59 | -VQDMLSDH 1111 1110 0 . .. ... 0 ... 0 1110 . 0 . 0 ... 0 @2op | ||
60 | -VQDMLSDHX 1111 1110 0 . .. ... 0 ... 1 1110 . 0 . 0 ... 0 @2op | ||
61 | -VQRDMLSDH 1111 1110 0 . .. ... 0 ... 0 1110 . 0 . 0 ... 1 @2op | ||
62 | -VQRDMLSDHX 1111 1110 0 . .. ... 0 ... 1 1110 . 0 . 0 ... 1 @2op | ||
63 | +{ | ||
64 | + VCMUL180 111 . 1110 0 . 11 ... 0 ... 1 1110 . 0 . 0 ... 0 @2op_sz28 | ||
65 | + VQDMLADHX 111 0 1110 0 . .. ... 0 ... 1 1110 . 0 . 0 ... 0 @2op | ||
66 | + VQDMLSDHX 111 1 1110 0 . .. ... 0 ... 1 1110 . 0 . 0 ... 0 @2op | ||
67 | +} | ||
68 | + | ||
69 | +{ | ||
70 | + VCMUL90 111 . 1110 0 . 11 ... 0 ... 0 1110 . 0 . 0 ... 1 @2op_sz28 | ||
71 | + VQRDMLADH 111 0 1110 0 . .. ... 0 ... 0 1110 . 0 . 0 ... 1 @2op | ||
72 | + VQRDMLSDH 111 1 1110 0 . .. ... 0 ... 0 1110 . 0 . 0 ... 1 @2op | ||
73 | +} | ||
74 | + | ||
75 | +{ | ||
76 | + VCMUL270 111 . 1110 0 . 11 ... 0 ... 1 1110 . 0 . 0 ... 1 @2op_sz28 | ||
77 | + VQRDMLADHX 111 0 1110 0 . .. ... 0 ... 1 1110 . 0 . 0 ... 1 @2op | ||
78 | + VQRDMLSDHX 111 1 1110 0 . .. ... 0 ... 1 1110 . 0 . 0 ... 1 @2op | ||
79 | +} | ||
80 | |||
81 | VQDMULLB 111 . 1110 0 . 11 ... 0 ... 0 1111 . 0 . 0 ... 1 @2op_sz28 | ||
82 | VQDMULLT 111 . 1110 0 . 11 ... 0 ... 1 1111 . 0 . 0 ... 1 @2op_sz28 | ||
83 | @@ -XXX,XX +XXX,XX @@ VCADD270_fp 1111 1101 1 . 0 . ... 0 ... 0 1000 . 1 . 0 ... 0 @2op_fp_size_ | ||
84 | |||
85 | VFMA 1110 1111 0 . 0 . ... 0 ... 0 1100 . 1 . 1 ... 0 @2op_fp | ||
86 | VFMS 1110 1111 0 . 1 . ... 0 ... 0 1100 . 1 . 1 ... 0 @2op_fp | ||
87 | + | ||
88 | +VCMLA0 1111 110 00 . 1 . ... 0 ... 0 1000 . 1 . 0 ... 0 @2op_fp_size_rev | ||
89 | +VCMLA90 1111 110 01 . 1 . ... 0 ... 0 1000 . 1 . 0 ... 0 @2op_fp_size_rev | ||
90 | +VCMLA180 1111 110 10 . 1 . ... 0 ... 0 1000 . 1 . 0 ... 0 @2op_fp_size_rev | ||
91 | +VCMLA270 1111 110 11 . 1 . ... 0 ... 0 1000 . 1 . 0 ... 0 @2op_fp_size_rev | ||
92 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
93 | index XXXXXXX..XXXXXXX 100644 | ||
94 | --- a/target/arm/mve_helper.c | ||
95 | +++ b/target/arm/mve_helper.c | ||
96 | @@ -XXX,XX +XXX,XX @@ DO_VFMA(vfmah, 2, float16, false) | ||
97 | DO_VFMA(vfmas, 4, float32, false) | ||
98 | DO_VFMA(vfmsh, 2, float16, true) | ||
99 | DO_VFMA(vfmss, 4, float32, true) | ||
100 | + | ||
101 | +#define DO_VCMLA(OP, ESIZE, TYPE, ROT, FN) \ | ||
102 | + void HELPER(glue(mve_, OP))(CPUARMState *env, \ | ||
103 | + void *vd, void *vn, void *vm) \ | ||
104 | + { \ | ||
105 | + TYPE *d = vd, *n = vn, *m = vm; \ | ||
106 | + TYPE r0, r1, e1, e2, e3, e4; \ | ||
107 | + uint16_t mask = mve_element_mask(env); \ | ||
108 | + unsigned e; \ | ||
109 | + float_status *fpst0, *fpst1; \ | ||
110 | + float_status scratch_fpst; \ | ||
111 | + /* We loop through pairs of elements at a time */ \ | ||
112 | + for (e = 0; e < 16 / ESIZE; e += 2, mask >>= ESIZE * 2) { \ | ||
113 | + if ((mask & MAKE_64BIT_MASK(0, ESIZE * 2)) == 0) { \ | ||
114 | + continue; \ | ||
115 | + } \ | ||
116 | + fpst0 = (ESIZE == 2) ? &env->vfp.standard_fp_status_f16 : \ | ||
117 | + &env->vfp.standard_fp_status; \ | ||
118 | + fpst1 = fpst0; \ | ||
119 | + if (!(mask & 1)) { \ | ||
120 | + scratch_fpst = *fpst0; \ | ||
121 | + fpst0 = &scratch_fpst; \ | ||
122 | + } \ | ||
123 | + if (!(mask & (1 << ESIZE))) { \ | ||
124 | + scratch_fpst = *fpst1; \ | ||
125 | + fpst1 = &scratch_fpst; \ | ||
126 | + } \ | ||
127 | + switch (ROT) { \ | ||
128 | + case 0: \ | ||
129 | + e1 = m[H##ESIZE(e)]; \ | ||
130 | + e2 = n[H##ESIZE(e)]; \ | ||
131 | + e3 = m[H##ESIZE(e + 1)]; \ | ||
132 | + e4 = n[H##ESIZE(e)]; \ | ||
133 | + break; \ | ||
134 | + case 1: \ | ||
135 | + e1 = TYPE##_chs(m[H##ESIZE(e + 1)]); \ | ||
136 | + e2 = n[H##ESIZE(e + 1)]; \ | ||
137 | + e3 = m[H##ESIZE(e)]; \ | ||
138 | + e4 = n[H##ESIZE(e + 1)]; \ | ||
139 | + break; \ | ||
140 | + case 2: \ | ||
141 | + e1 = TYPE##_chs(m[H##ESIZE(e)]); \ | ||
142 | + e2 = n[H##ESIZE(e)]; \ | ||
143 | + e3 = TYPE##_chs(m[H##ESIZE(e + 1)]); \ | ||
144 | + e4 = n[H##ESIZE(e)]; \ | ||
145 | + break; \ | ||
146 | + case 3: \ | ||
147 | + e1 = m[H##ESIZE(e + 1)]; \ | ||
148 | + e2 = n[H##ESIZE(e + 1)]; \ | ||
149 | + e3 = TYPE##_chs(m[H##ESIZE(e)]); \ | ||
150 | + e4 = n[H##ESIZE(e + 1)]; \ | ||
151 | + break; \ | ||
152 | + default: \ | ||
153 | + g_assert_not_reached(); \ | ||
154 | + } \ | ||
155 | + r0 = FN(e2, e1, d[H##ESIZE(e)], fpst0); \ | ||
156 | + r1 = FN(e4, e3, d[H##ESIZE(e + 1)], fpst1); \ | ||
157 | + mergemask(&d[H##ESIZE(e)], r0, mask); \ | ||
158 | + mergemask(&d[H##ESIZE(e + 1)], r1, mask >> ESIZE); \ | ||
159 | + } \ | ||
160 | + mve_advance_vpt(env); \ | ||
161 | + } | ||
162 | + | ||
163 | +#define DO_VCMULH(N, M, D, S) float16_mul(N, M, S) | ||
164 | +#define DO_VCMULS(N, M, D, S) float32_mul(N, M, S) | ||
165 | + | ||
166 | +#define DO_VCMLAH(N, M, D, S) float16_muladd(N, M, D, 0, S) | ||
167 | +#define DO_VCMLAS(N, M, D, S) float32_muladd(N, M, D, 0, S) | ||
168 | + | ||
169 | +DO_VCMLA(vcmul0h, 2, float16, 0, DO_VCMULH) | ||
170 | +DO_VCMLA(vcmul0s, 4, float32, 0, DO_VCMULS) | ||
171 | +DO_VCMLA(vcmul90h, 2, float16, 1, DO_VCMULH) | ||
172 | +DO_VCMLA(vcmul90s, 4, float32, 1, DO_VCMULS) | ||
173 | +DO_VCMLA(vcmul180h, 2, float16, 2, DO_VCMULH) | ||
174 | +DO_VCMLA(vcmul180s, 4, float32, 2, DO_VCMULS) | ||
175 | +DO_VCMLA(vcmul270h, 2, float16, 3, DO_VCMULH) | ||
176 | +DO_VCMLA(vcmul270s, 4, float32, 3, DO_VCMULS) | ||
177 | + | ||
178 | +DO_VCMLA(vcmla0h, 2, float16, 0, DO_VCMLAH) | ||
179 | +DO_VCMLA(vcmla0s, 4, float32, 0, DO_VCMLAS) | ||
180 | +DO_VCMLA(vcmla90h, 2, float16, 1, DO_VCMLAH) | ||
181 | +DO_VCMLA(vcmla90s, 4, float32, 1, DO_VCMLAS) | ||
182 | +DO_VCMLA(vcmla180h, 2, float16, 2, DO_VCMLAH) | ||
183 | +DO_VCMLA(vcmla180s, 4, float32, 2, DO_VCMLAS) | ||
184 | +DO_VCMLA(vcmla270h, 2, float16, 3, DO_VCMLAH) | ||
185 | +DO_VCMLA(vcmla270s, 4, float32, 3, DO_VCMLAS) | ||
186 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
187 | index XXXXXXX..XXXXXXX 100644 | ||
188 | --- a/target/arm/translate-mve.c | ||
189 | +++ b/target/arm/translate-mve.c | ||
190 | @@ -XXX,XX +XXX,XX @@ DO_2OP_FP(VCADD90_fp, vfcadd90) | ||
191 | DO_2OP_FP(VCADD270_fp, vfcadd270) | ||
192 | DO_2OP_FP(VFMA, vfma) | ||
193 | DO_2OP_FP(VFMS, vfms) | ||
194 | +DO_2OP_FP(VCMUL0, vcmul0) | ||
195 | +DO_2OP_FP(VCMUL90, vcmul90) | ||
196 | +DO_2OP_FP(VCMUL180, vcmul180) | ||
197 | +DO_2OP_FP(VCMUL270, vcmul270) | ||
198 | +DO_2OP_FP(VCMLA0, vcmla0) | ||
199 | +DO_2OP_FP(VCMLA90, vcmla90) | ||
200 | +DO_2OP_FP(VCMLA180, vcmla180) | ||
201 | +DO_2OP_FP(VCMLA270, vcmla270) | ||
202 | |||
203 | static bool do_2op_scalar(DisasContext *s, arg_2scalar *a, | ||
204 | MVEGenTwoOpScalarFn fn) | ||
205 | -- | ||
206 | 2.20.1 | ||
207 | |||
208 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VMAXNMA and VMINNMA insns; these are 2-operand, but | ||
2 | the destination register must be the same as one of the source | ||
3 | registers. | ||
4 | 1 | ||
5 | We defer the decode of the size in bit 28 to the individual insn | ||
6 | patterns rather than doing it in the format, because otherwise we | ||
7 | would have a single insn pattern that overlapped with two groups (eg | ||
8 | VMAXNMA with the VMULH_S and VMULH_U groups). Having two insn | ||
9 | patterns per insn seems clearer than a complex multilevel nesting | ||
10 | of overlapping and non-overlapping groups. | ||
11 | |||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | target/arm/helper-mve.h | 6 ++++++ | ||
16 | target/arm/mve.decode | 11 +++++++++++ | ||
17 | target/arm/mve_helper.c | 23 +++++++++++++++++++++++ | ||
18 | target/arm/translate-mve.c | 2 ++ | ||
19 | 4 files changed, 42 insertions(+) | ||
20 | |||
21 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/target/arm/helper-mve.h | ||
24 | +++ b/target/arm/helper-mve.h | ||
25 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vmaxnms, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
26 | DEF_HELPER_FLAGS_4(mve_vminnmh, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
27 | DEF_HELPER_FLAGS_4(mve_vminnms, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
28 | |||
29 | +DEF_HELPER_FLAGS_4(mve_vmaxnmah, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
30 | +DEF_HELPER_FLAGS_4(mve_vmaxnmas, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
31 | + | ||
32 | +DEF_HELPER_FLAGS_4(mve_vminnmah, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
33 | +DEF_HELPER_FLAGS_4(mve_vminnmas, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
34 | + | ||
35 | DEF_HELPER_FLAGS_4(mve_vfcadd90h, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
36 | DEF_HELPER_FLAGS_4(mve_vfcadd90s, TCG_CALL_NO_WG, void, env, ptr, ptr, ptr) | ||
37 | |||
38 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/target/arm/mve.decode | ||
41 | +++ b/target/arm/mve.decode | ||
42 | @@ -XXX,XX +XXX,XX @@ | ||
43 | @2op_fp_size_rev .... .... .... .... .... .... .... .... &2op \ | ||
44 | qd=%qd qn=%qn qm=%qm size=%2op_fp_size_rev | ||
45 | |||
46 | +# 2-operand, but Qd and Qn share a field. Size is in bit 28, but we | ||
47 | +# don't decode it in this format | ||
48 | +@vmaxnma .... .... .... .... .... .... .... .... &2op \ | ||
49 | + qd=%qd qn=%qd qm=%qm | ||
50 | + | ||
51 | # Vector loads and stores | ||
52 | |||
53 | # Widening loads and narrowing stores: | ||
54 | @@ -XXX,XX +XXX,XX @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
55 | # The VSHLL T2 encoding is not a @2op pattern, but is here because it | ||
56 | # overlaps what would be size=0b11 VMULH/VRMULH | ||
57 | { | ||
58 | + VMAXNMA 111 0 1110 0 . 11 1111 ... 0 1110 1 0 . 0 ... 1 @vmaxnma size=2 | ||
59 | + | ||
60 | VSHLL_BS 111 0 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_b | ||
61 | VSHLL_BS 111 0 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
62 | |||
63 | @@ -XXX,XX +XXX,XX @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
64 | } | ||
65 | |||
66 | { | ||
67 | + VMAXNMA 111 1 1110 0 . 11 1111 ... 0 1110 1 0 . 0 ... 1 @vmaxnma size=1 | ||
68 | + | ||
69 | VSHLL_BU 111 1 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_b | ||
70 | VSHLL_BU 111 1 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
71 | |||
72 | @@ -XXX,XX +XXX,XX @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
73 | } | ||
74 | |||
75 | { | ||
76 | + VMINNMA 111 0 1110 0 . 11 1111 ... 1 1110 1 0 . 0 ... 1 @vmaxnma size=2 | ||
77 | VSHLL_TS 111 0 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_b | ||
78 | VSHLL_TS 111 0 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
79 | |||
80 | @@ -XXX,XX +XXX,XX @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
81 | } | ||
82 | |||
83 | { | ||
84 | + VMINNMA 111 1 1110 0 . 11 1111 ... 1 1110 1 0 . 0 ... 1 @vmaxnma size=1 | ||
85 | VSHLL_TU 111 1 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_b | ||
86 | VSHLL_TU 111 1 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
87 | |||
88 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
89 | index XXXXXXX..XXXXXXX 100644 | ||
90 | --- a/target/arm/mve_helper.c | ||
91 | +++ b/target/arm/mve_helper.c | ||
92 | @@ -XXX,XX +XXX,XX @@ DO_2OP_FP_ALL(vfabd, abd) | ||
93 | DO_2OP_FP_ALL(vmaxnm, maxnum) | ||
94 | DO_2OP_FP_ALL(vminnm, minnum) | ||
95 | |||
96 | +static inline float16 float16_maxnuma(float16 a, float16 b, float_status *s) | ||
97 | +{ | ||
98 | + return float16_maxnum(float16_abs(a), float16_abs(b), s); | ||
99 | +} | ||
100 | + | ||
101 | +static inline float32 float32_maxnuma(float32 a, float32 b, float_status *s) | ||
102 | +{ | ||
103 | + return float32_maxnum(float32_abs(a), float32_abs(b), s); | ||
104 | +} | ||
105 | + | ||
106 | +static inline float16 float16_minnuma(float16 a, float16 b, float_status *s) | ||
107 | +{ | ||
108 | + return float16_minnum(float16_abs(a), float16_abs(b), s); | ||
109 | +} | ||
110 | + | ||
111 | +static inline float32 float32_minnuma(float32 a, float32 b, float_status *s) | ||
112 | +{ | ||
113 | + return float32_minnum(float32_abs(a), float32_abs(b), s); | ||
114 | +} | ||
115 | + | ||
116 | +DO_2OP_FP_ALL(vmaxnma, maxnuma) | ||
117 | +DO_2OP_FP_ALL(vminnma, minnuma) | ||
118 | + | ||
119 | #define DO_VCADD_FP(OP, ESIZE, TYPE, FN0, FN1) \ | ||
120 | void HELPER(glue(mve_, OP))(CPUARMState *env, \ | ||
121 | void *vd, void *vn, void *vm) \ | ||
122 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
123 | index XXXXXXX..XXXXXXX 100644 | ||
124 | --- a/target/arm/translate-mve.c | ||
125 | +++ b/target/arm/translate-mve.c | ||
126 | @@ -XXX,XX +XXX,XX @@ DO_2OP_FP(VCMLA0, vcmla0) | ||
127 | DO_2OP_FP(VCMLA90, vcmla90) | ||
128 | DO_2OP_FP(VCMLA180, vcmla180) | ||
129 | DO_2OP_FP(VCMLA270, vcmla270) | ||
130 | +DO_2OP_FP(VMAXNMA, vmaxnma) | ||
131 | +DO_2OP_FP(VMINNMA, vminnma) | ||
132 | |||
133 | static bool do_2op_scalar(DisasContext *s, arg_2scalar *a, | ||
134 | MVEGenTwoOpScalarFn fn) | ||
135 | -- | ||
136 | 2.20.1 | ||
137 | |||
138 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE scalar floating point insns VADD, VSUB and VMUL. | ||
2 | 1 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | --- | ||
6 | target/arm/helper-mve.h | 9 +++++++++ | ||
7 | target/arm/mve.decode | 27 +++++++++++++++++++++------ | ||
8 | target/arm/mve_helper.c | 35 +++++++++++++++++++++++++++++++++++ | ||
9 | target/arm/translate-mve.c | 20 ++++++++++++++++++++ | ||
10 | 4 files changed, 85 insertions(+), 6 deletions(-) | ||
11 | |||
12 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/helper-mve.h | ||
15 | +++ b/target/arm/helper-mve.h | ||
16 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vcmpgt_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
17 | DEF_HELPER_FLAGS_3(mve_vcmple_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
18 | DEF_HELPER_FLAGS_3(mve_vcmple_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
19 | DEF_HELPER_FLAGS_3(mve_vcmple_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
20 | + | ||
21 | +DEF_HELPER_FLAGS_4(mve_vfadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
22 | +DEF_HELPER_FLAGS_4(mve_vfadd_scalars, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
23 | + | ||
24 | +DEF_HELPER_FLAGS_4(mve_vfsub_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
25 | +DEF_HELPER_FLAGS_4(mve_vfsub_scalars, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
26 | + | ||
27 | +DEF_HELPER_FLAGS_4(mve_vfmul_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_4(mve_vfmul_scalars, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
29 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/mve.decode | ||
32 | +++ b/target/arm/mve.decode | ||
33 | @@ -XXX,XX +XXX,XX @@ | ||
34 | %2op_fp_size 20:1 !function=neon_3same_fp_size | ||
35 | # VCADD is an exception, where bit 20 is 0 for 16 bit and 1 for 32 bit | ||
36 | %2op_fp_size_rev 20:1 !function=plus_1 | ||
37 | +# FP scalars have size in bit 28, 1 for 16 bit, 0 for 32 bit | ||
38 | +%2op_fp_scalar_size 28:1 !function=neon_3same_fp_size | ||
39 | |||
40 | # 1imm format immediate | ||
41 | %imm_28_16_0 28:1 16:3 0:4 | ||
42 | @@ -XXX,XX +XXX,XX @@ | ||
43 | @vmaxnma .... .... .... .... .... .... .... .... &2op \ | ||
44 | qd=%qd qn=%qd qm=%qm | ||
45 | |||
46 | +@2op_fp_scalar .... .... .... .... .... .... .... rm:4 &2scalar \ | ||
47 | + qd=%qd qn=%qn size=%2op_fp_scalar_size | ||
48 | + | ||
49 | # Vector loads and stores | ||
50 | |||
51 | # Widening loads and narrowing stores: | ||
52 | @@ -XXX,XX +XXX,XX @@ VSUB_scalar 1110 1110 0 . .. ... 1 ... 1 1111 . 100 .... @2scalar | ||
53 | VBRSR 1111 1110 0 . .. ... 1 ... 1 1110 . 110 .... @2scalar | ||
54 | } | ||
55 | |||
56 | -VHADD_S_scalar 1110 1110 0 . .. ... 0 ... 0 1111 . 100 .... @2scalar | ||
57 | -VHADD_U_scalar 1111 1110 0 . .. ... 0 ... 0 1111 . 100 .... @2scalar | ||
58 | -VHSUB_S_scalar 1110 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar | ||
59 | -VHSUB_U_scalar 1111 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar | ||
60 | +{ | ||
61 | + VADD_fp_scalar 111 . 1110 0 . 11 ... 0 ... 0 1111 . 100 .... @2op_fp_scalar | ||
62 | + VHADD_S_scalar 1110 1110 0 . .. ... 0 ... 0 1111 . 100 .... @2scalar | ||
63 | + VHADD_U_scalar 1111 1110 0 . .. ... 0 ... 0 1111 . 100 .... @2scalar | ||
64 | +} | ||
65 | + | ||
66 | +{ | ||
67 | + VSUB_fp_scalar 111 . 1110 0 . 11 ... 0 ... 1 1111 . 100 .... @2op_fp_scalar | ||
68 | + VHSUB_S_scalar 1110 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar | ||
69 | + VHSUB_U_scalar 1111 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar | ||
70 | +} | ||
71 | |||
72 | { | ||
73 | VQADD_S_scalar 1110 1110 0 . .. ... 0 ... 0 1111 . 110 .... @2scalar | ||
74 | @@ -XXX,XX +XXX,XX @@ VHSUB_U_scalar 1111 1110 0 . .. ... 0 ... 1 1111 . 100 .... @2scalar | ||
75 | size=%size_28 | ||
76 | } | ||
77 | |||
78 | -VQDMULH_scalar 1110 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
79 | -VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
80 | +{ | ||
81 | + VMUL_fp_scalar 111 . 1110 0 . 11 ... 1 ... 0 1110 . 110 .... @2op_fp_scalar | ||
82 | + VQDMULH_scalar 1110 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
83 | + VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
84 | +} | ||
85 | |||
86 | # The U bit (28) is don't-care because it does not affect the result | ||
87 | VMLA 111- 1110 0 . .. ... 1 ... 0 1110 . 100 .... @2scalar | ||
88 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
89 | index XXXXXXX..XXXXXXX 100644 | ||
90 | --- a/target/arm/mve_helper.c | ||
91 | +++ b/target/arm/mve_helper.c | ||
92 | @@ -XXX,XX +XXX,XX @@ DO_VCMLA(vcmla180h, 2, float16, 2, DO_VCMLAH) | ||
93 | DO_VCMLA(vcmla180s, 4, float32, 2, DO_VCMLAS) | ||
94 | DO_VCMLA(vcmla270h, 2, float16, 3, DO_VCMLAH) | ||
95 | DO_VCMLA(vcmla270s, 4, float32, 3, DO_VCMLAS) | ||
96 | + | ||
97 | +#define DO_2OP_FP_SCALAR(OP, ESIZE, TYPE, FN) \ | ||
98 | + void HELPER(glue(mve_, OP))(CPUARMState *env, \ | ||
99 | + void *vd, void *vn, uint32_t rm) \ | ||
100 | + { \ | ||
101 | + TYPE *d = vd, *n = vn; \ | ||
102 | + TYPE r, m = rm; \ | ||
103 | + uint16_t mask = mve_element_mask(env); \ | ||
104 | + unsigned e; \ | ||
105 | + float_status *fpst; \ | ||
106 | + float_status scratch_fpst; \ | ||
107 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
108 | + if ((mask & MAKE_64BIT_MASK(0, ESIZE)) == 0) { \ | ||
109 | + continue; \ | ||
110 | + } \ | ||
111 | + fpst = (ESIZE == 2) ? &env->vfp.standard_fp_status_f16 : \ | ||
112 | + &env->vfp.standard_fp_status; \ | ||
113 | + if (!(mask & 1)) { \ | ||
114 | + /* We need the result but without updating flags */ \ | ||
115 | + scratch_fpst = *fpst; \ | ||
116 | + fpst = &scratch_fpst; \ | ||
117 | + } \ | ||
118 | + r = FN(n[H##ESIZE(e)], m, fpst); \ | ||
119 | + mergemask(&d[H##ESIZE(e)], r, mask); \ | ||
120 | + } \ | ||
121 | + mve_advance_vpt(env); \ | ||
122 | + } | ||
123 | + | ||
124 | +#define DO_2OP_FP_SCALAR_ALL(OP, FN) \ | ||
125 | + DO_2OP_FP_SCALAR(OP##h, 2, float16, float16_##FN) \ | ||
126 | + DO_2OP_FP_SCALAR(OP##s, 4, float32, float32_##FN) | ||
127 | + | ||
128 | +DO_2OP_FP_SCALAR_ALL(vfadd_scalar, add) | ||
129 | +DO_2OP_FP_SCALAR_ALL(vfsub_scalar, sub) | ||
130 | +DO_2OP_FP_SCALAR_ALL(vfmul_scalar, mul) | ||
131 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
132 | index XXXXXXX..XXXXXXX 100644 | ||
133 | --- a/target/arm/translate-mve.c | ||
134 | +++ b/target/arm/translate-mve.c | ||
135 | @@ -XXX,XX +XXX,XX @@ static bool trans_VQDMULLT_scalar(DisasContext *s, arg_2scalar *a) | ||
136 | return do_2op_scalar(s, a, fns[a->size]); | ||
137 | } | ||
138 | |||
139 | + | ||
140 | +#define DO_2OP_FP_SCALAR(INSN, FN) \ | ||
141 | + static bool trans_##INSN(DisasContext *s, arg_2scalar *a) \ | ||
142 | + { \ | ||
143 | + static MVEGenTwoOpScalarFn * const fns[] = { \ | ||
144 | + NULL, \ | ||
145 | + gen_helper_mve_##FN##h, \ | ||
146 | + gen_helper_mve_##FN##s, \ | ||
147 | + NULL, \ | ||
148 | + }; \ | ||
149 | + if (!dc_isar_feature(aa32_mve_fp, s)) { \ | ||
150 | + return false; \ | ||
151 | + } \ | ||
152 | + return do_2op_scalar(s, a, fns[a->size]); \ | ||
153 | + } | ||
154 | + | ||
155 | +DO_2OP_FP_SCALAR(VADD_fp_scalar, vfadd_scalar) | ||
156 | +DO_2OP_FP_SCALAR(VSUB_fp_scalar, vfsub_scalar) | ||
157 | +DO_2OP_FP_SCALAR(VMUL_fp_scalar, vfmul_scalar) | ||
158 | + | ||
159 | static bool do_long_dual_acc(DisasContext *s, arg_vmlaldav *a, | ||
160 | MVEGenLongDualAccOpFn *fn) | ||
161 | { | ||
162 | -- | ||
163 | 2.20.1 | ||
164 | |||
165 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE fp-with-scalar VFMA and VFMAS insns. | ||
2 | 1 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | --- | ||
6 | target/arm/helper-mve.h | 6 ++++++ | ||
7 | target/arm/mve.decode | 14 +++++++++++--- | ||
8 | target/arm/mve_helper.c | 37 +++++++++++++++++++++++++++++++++++++ | ||
9 | target/arm/translate-mve.c | 2 ++ | ||
10 | 4 files changed, 56 insertions(+), 3 deletions(-) | ||
11 | |||
12 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/helper-mve.h | ||
15 | +++ b/target/arm/helper-mve.h | ||
16 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vfsub_scalars, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
17 | |||
18 | DEF_HELPER_FLAGS_4(mve_vfmul_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
19 | DEF_HELPER_FLAGS_4(mve_vfmul_scalars, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
20 | + | ||
21 | +DEF_HELPER_FLAGS_4(mve_vfma_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
22 | +DEF_HELPER_FLAGS_4(mve_vfma_scalars, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
23 | + | ||
24 | +DEF_HELPER_FLAGS_4(mve_vfmas_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
25 | +DEF_HELPER_FLAGS_4(mve_vfmas_scalars, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
26 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/target/arm/mve.decode | ||
29 | +++ b/target/arm/mve.decode | ||
30 | @@ -XXX,XX +XXX,XX @@ VSUB_scalar 1110 1110 0 . .. ... 1 ... 1 1111 . 100 .... @2scalar | ||
31 | VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
32 | } | ||
33 | |||
34 | -# The U bit (28) is don't-care because it does not affect the result | ||
35 | -VMLA 111- 1110 0 . .. ... 1 ... 0 1110 . 100 .... @2scalar | ||
36 | -VMLAS 111- 1110 0 . .. ... 1 ... 1 1110 . 100 .... @2scalar | ||
37 | +{ | ||
38 | + VFMA_scalar 111 . 1110 0 . 11 ... 1 ... 0 1110 . 100 .... @2op_fp_scalar | ||
39 | + # The U bit (28) is don't-care because it does not affect the result | ||
40 | + VMLA 111 - 1110 0 . .. ... 1 ... 0 1110 . 100 .... @2scalar | ||
41 | +} | ||
42 | + | ||
43 | +{ | ||
44 | + VFMAS_scalar 111 . 1110 0 . 11 ... 1 ... 1 1110 . 100 .... @2op_fp_scalar | ||
45 | + # The U bit (28) is don't-care because it does not affect the result | ||
46 | + VMLAS 111 - 1110 0 . .. ... 1 ... 1 1110 . 100 .... @2scalar | ||
47 | +} | ||
48 | |||
49 | VQRDMLAH 1110 1110 0 . .. ... 0 ... 0 1110 . 100 .... @2scalar | ||
50 | VQRDMLASH 1110 1110 0 . .. ... 0 ... 1 1110 . 100 .... @2scalar | ||
51 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/target/arm/mve_helper.c | ||
54 | +++ b/target/arm/mve_helper.c | ||
55 | @@ -XXX,XX +XXX,XX @@ DO_VCMLA(vcmla270s, 4, float32, 3, DO_VCMLAS) | ||
56 | DO_2OP_FP_SCALAR_ALL(vfadd_scalar, add) | ||
57 | DO_2OP_FP_SCALAR_ALL(vfsub_scalar, sub) | ||
58 | DO_2OP_FP_SCALAR_ALL(vfmul_scalar, mul) | ||
59 | + | ||
60 | +#define DO_2OP_FP_ACC_SCALAR(OP, ESIZE, TYPE, FN) \ | ||
61 | + void HELPER(glue(mve_, OP))(CPUARMState *env, \ | ||
62 | + void *vd, void *vn, uint32_t rm) \ | ||
63 | + { \ | ||
64 | + TYPE *d = vd, *n = vn; \ | ||
65 | + TYPE r, m = rm; \ | ||
66 | + uint16_t mask = mve_element_mask(env); \ | ||
67 | + unsigned e; \ | ||
68 | + float_status *fpst; \ | ||
69 | + float_status scratch_fpst; \ | ||
70 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
71 | + if ((mask & MAKE_64BIT_MASK(0, ESIZE)) == 0) { \ | ||
72 | + continue; \ | ||
73 | + } \ | ||
74 | + fpst = (ESIZE == 2) ? &env->vfp.standard_fp_status_f16 : \ | ||
75 | + &env->vfp.standard_fp_status; \ | ||
76 | + if (!(mask & 1)) { \ | ||
77 | + /* We need the result but without updating flags */ \ | ||
78 | + scratch_fpst = *fpst; \ | ||
79 | + fpst = &scratch_fpst; \ | ||
80 | + } \ | ||
81 | + r = FN(n[H##ESIZE(e)], m, d[H##ESIZE(e)], 0, fpst); \ | ||
82 | + mergemask(&d[H##ESIZE(e)], r, mask); \ | ||
83 | + } \ | ||
84 | + mve_advance_vpt(env); \ | ||
85 | + } | ||
86 | + | ||
87 | +/* VFMAS is vector * vector + scalar, so swap op2 and op3 */ | ||
88 | +#define DO_VFMAS_SCALARH(N, M, D, F, S) float16_muladd(N, D, M, F, S) | ||
89 | +#define DO_VFMAS_SCALARS(N, M, D, F, S) float32_muladd(N, D, M, F, S) | ||
90 | + | ||
91 | +/* VFMA is vector * scalar + vector */ | ||
92 | +DO_2OP_FP_ACC_SCALAR(vfma_scalarh, 2, float16, float16_muladd) | ||
93 | +DO_2OP_FP_ACC_SCALAR(vfma_scalars, 4, float32, float32_muladd) | ||
94 | +DO_2OP_FP_ACC_SCALAR(vfmas_scalarh, 2, float16, DO_VFMAS_SCALARH) | ||
95 | +DO_2OP_FP_ACC_SCALAR(vfmas_scalars, 4, float32, DO_VFMAS_SCALARS) | ||
96 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
97 | index XXXXXXX..XXXXXXX 100644 | ||
98 | --- a/target/arm/translate-mve.c | ||
99 | +++ b/target/arm/translate-mve.c | ||
100 | @@ -XXX,XX +XXX,XX @@ static bool trans_VQDMULLT_scalar(DisasContext *s, arg_2scalar *a) | ||
101 | DO_2OP_FP_SCALAR(VADD_fp_scalar, vfadd_scalar) | ||
102 | DO_2OP_FP_SCALAR(VSUB_fp_scalar, vfsub_scalar) | ||
103 | DO_2OP_FP_SCALAR(VMUL_fp_scalar, vfmul_scalar) | ||
104 | +DO_2OP_FP_SCALAR(VFMA_scalar, vfma_scalar) | ||
105 | +DO_2OP_FP_SCALAR(VFMAS_scalar, vfmas_scalar) | ||
106 | |||
107 | static bool do_long_dual_acc(DisasContext *s, arg_vmlaldav *a, | ||
108 | MVEGenLongDualAccOpFn *fn) | ||
109 | -- | ||
110 | 2.20.1 | ||
111 | |||
112 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | In commit a777d6033447a we added an assertion to parts_silence_nan() that | ||
2 | prohibits calling float*_silence_nan() when in default-NaN mode. | ||
3 | This ties together a property of the output ("do we generate a default | ||
4 | NaN when the result is a NaN?") with an operation on an input ("silence | ||
5 | this input NaN"). | ||
6 | 1 | ||
7 | It's true that most of the time when in default-NaN mode you won't | ||
8 | need to silence an input NaN, because you can just produce the | ||
9 | default NaN as the result instead. But some functions like | ||
10 | float*_maxnum() are defined to be able to work with quiet NaNs, so | ||
11 | silencing an input SNaN is still reasonable. In particular, the | ||
12 | upcoming implementation of MVE VMAXNMV would fall over this assertion | ||
13 | if we didn't delete it. | ||
14 | |||
15 | Delete the assertion. | ||
16 | |||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
19 | --- | ||
20 | fpu/softfloat-specialize.c.inc | 1 - | ||
21 | 1 file changed, 1 deletion(-) | ||
22 | |||
23 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/fpu/softfloat-specialize.c.inc | ||
26 | +++ b/fpu/softfloat-specialize.c.inc | ||
27 | @@ -XXX,XX +XXX,XX @@ static void parts128_default_nan(FloatParts128 *p, float_status *status) | ||
28 | static uint64_t parts_silence_nan_frac(uint64_t frac, float_status *status) | ||
29 | { | ||
30 | g_assert(!no_signaling_nans(status)); | ||
31 | - g_assert(!status->default_nan_mode); | ||
32 | |||
33 | /* The only snan_bit_is_one target without default_nan_mode is HPPA. */ | ||
34 | if (snan_bit_is_one(status)) { | ||
35 | -- | ||
36 | 2.20.1 | ||
37 | |||
38 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VMAXNMV, VMINNMV, VMAXNMAV, VMINNMAV insns. These | ||
2 | calculate the maximum or minimum of floating point elements across a | ||
3 | vector, starting with a value in a general purpose register and | ||
4 | returning the result there. | ||
5 | 1 | ||
6 | The pseudocode silences a possible SNaN in the accumulating result | ||
7 | on every iteration (by calling FPConvertNaN), but we do it only | ||
8 | on the input ra, because if none of the inputs to float*_maxnum | ||
9 | or float*_minnum are SNaNs then the result can't be an SNaN. | ||
10 | |||
11 | Note that we can't use the float*_maxnuma() etc functions we defined | ||
12 | earlier for VMAXNMA and VMINNMA, because we mustn't take the absolute | ||
13 | value of the starting general-purpose register value, which could be | ||
14 | negative. | ||
15 | |||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
18 | --- | ||
19 | target/arm/helper-mve.h | 12 +++++++++++ | ||
20 | target/arm/mve.decode | 32 +++++++++++++++++++++------ | ||
21 | target/arm/mve_helper.c | 44 ++++++++++++++++++++++++++++++++++++++ | ||
22 | target/arm/translate-mve.c | 20 +++++++++++++++++ | ||
23 | 4 files changed, 102 insertions(+), 6 deletions(-) | ||
24 | |||
25 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/target/arm/helper-mve.h | ||
28 | +++ b/target/arm/helper-mve.h | ||
29 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vminavb, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
30 | DEF_HELPER_FLAGS_3(mve_vminavh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
31 | DEF_HELPER_FLAGS_3(mve_vminavw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
32 | |||
33 | +DEF_HELPER_FLAGS_3(mve_vmaxnmvh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
34 | +DEF_HELPER_FLAGS_3(mve_vmaxnmvs, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
35 | + | ||
36 | +DEF_HELPER_FLAGS_3(mve_vminnmvh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
37 | +DEF_HELPER_FLAGS_3(mve_vminnmvs, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
38 | + | ||
39 | +DEF_HELPER_FLAGS_3(mve_vmaxnmavh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
40 | +DEF_HELPER_FLAGS_3(mve_vmaxnmavs, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
41 | + | ||
42 | +DEF_HELPER_FLAGS_3(mve_vminnmavh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
43 | +DEF_HELPER_FLAGS_3(mve_vminnmavs, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
44 | + | ||
45 | DEF_HELPER_FLAGS_3(mve_vaddlv_s, TCG_CALL_NO_WG, i64, env, ptr, i64) | ||
46 | DEF_HELPER_FLAGS_3(mve_vaddlv_u, TCG_CALL_NO_WG, i64, env, ptr, i64) | ||
47 | |||
48 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/target/arm/mve.decode | ||
51 | +++ b/target/arm/mve.decode | ||
52 | @@ -XXX,XX +XXX,XX @@ | ||
53 | @vmaxnma .... .... .... .... .... .... .... .... &2op \ | ||
54 | qd=%qd qn=%qd qm=%qm | ||
55 | |||
56 | +# Here also we don't decode the bit 28 size in the format to avoid | ||
57 | +# awkward nested overlap groups | ||
58 | +@vmaxnmv .... .... .... .... rda:4 .... .... .... &vmaxv qm=%qm | ||
59 | + | ||
60 | @2op_fp_scalar .... .... .... .... .... .... .... rm:4 &2scalar \ | ||
61 | qd=%qd qn=%qn size=%2op_fp_scalar_size | ||
62 | |||
63 | @@ -XXX,XX +XXX,XX @@ VMLADAV_S 1110 1110 1111 ... 0 ... . 1111 . 0 . 0 ... 1 @vmladav_nosz | ||
64 | VMLADAV_U 1111 1110 1111 ... 0 ... . 1111 . 0 . 0 ... 1 @vmladav_nosz | ||
65 | |||
66 | { | ||
67 | - VMAXV_S 1110 1110 1110 .. 10 .... 1111 0 0 . 0 ... 0 @vmaxv | ||
68 | - VMINV_S 1110 1110 1110 .. 10 .... 1111 1 0 . 0 ... 0 @vmaxv | ||
69 | - VMAXAV 1110 1110 1110 .. 00 .... 1111 0 0 . 0 ... 0 @vmaxv | ||
70 | - VMINAV 1110 1110 1110 .. 00 .... 1111 1 0 . 0 ... 0 @vmaxv | ||
71 | + [ | ||
72 | + VMAXNMAV 1110 1110 1110 11 00 .... 1111 0 0 . 0 ... 0 @vmaxnmv size=2 | ||
73 | + VMINNMAV 1110 1110 1110 11 00 .... 1111 1 0 . 0 ... 0 @vmaxnmv size=2 | ||
74 | + VMAXNMV 1110 1110 1110 11 10 .... 1111 0 0 . 0 ... 0 @vmaxnmv size=2 | ||
75 | + VMINNMV 1110 1110 1110 11 10 .... 1111 1 0 . 0 ... 0 @vmaxnmv size=2 | ||
76 | + ] | ||
77 | + [ | ||
78 | + VMAXV_S 1110 1110 1110 .. 10 .... 1111 0 0 . 0 ... 0 @vmaxv | ||
79 | + VMINV_S 1110 1110 1110 .. 10 .... 1111 1 0 . 0 ... 0 @vmaxv | ||
80 | + VMAXAV 1110 1110 1110 .. 00 .... 1111 0 0 . 0 ... 0 @vmaxv | ||
81 | + VMINAV 1110 1110 1110 .. 00 .... 1111 1 0 . 0 ... 0 @vmaxv | ||
82 | + ] | ||
83 | VMLADAV_S 1110 1110 1111 ... 0 ... . 1111 . 0 . 0 ... 0 @vmladav_nosz | ||
84 | VRMLALDAVH_S 1110 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz | ||
85 | } | ||
86 | |||
87 | { | ||
88 | - VMAXV_U 1111 1110 1110 .. 10 .... 1111 0 0 . 0 ... 0 @vmaxv | ||
89 | - VMINV_U 1111 1110 1110 .. 10 .... 1111 1 0 . 0 ... 0 @vmaxv | ||
90 | + [ | ||
91 | + VMAXNMAV 1111 1110 1110 11 00 .... 1111 0 0 . 0 ... 0 @vmaxnmv size=1 | ||
92 | + VMINNMAV 1111 1110 1110 11 00 .... 1111 1 0 . 0 ... 0 @vmaxnmv size=1 | ||
93 | + VMAXNMV 1111 1110 1110 11 10 .... 1111 0 0 . 0 ... 0 @vmaxnmv size=1 | ||
94 | + VMINNMV 1111 1110 1110 11 10 .... 1111 1 0 . 0 ... 0 @vmaxnmv size=1 | ||
95 | + ] | ||
96 | + [ | ||
97 | + VMAXV_U 1111 1110 1110 .. 10 .... 1111 0 0 . 0 ... 0 @vmaxv | ||
98 | + VMINV_U 1111 1110 1110 .. 10 .... 1111 1 0 . 0 ... 0 @vmaxv | ||
99 | + ] | ||
100 | VMLADAV_U 1111 1110 1111 ... 0 ... . 1111 . 0 . 0 ... 0 @vmladav_nosz | ||
101 | VRMLALDAVH_U 1111 1110 1 ... ... 0 ... . 1111 . 0 . 0 ... 0 @vmlaldav_nosz | ||
102 | } | ||
103 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
104 | index XXXXXXX..XXXXXXX 100644 | ||
105 | --- a/target/arm/mve_helper.c | ||
106 | +++ b/target/arm/mve_helper.c | ||
107 | @@ -XXX,XX +XXX,XX @@ DO_2OP_FP_ACC_SCALAR(vfma_scalarh, 2, float16, float16_muladd) | ||
108 | DO_2OP_FP_ACC_SCALAR(vfma_scalars, 4, float32, float32_muladd) | ||
109 | DO_2OP_FP_ACC_SCALAR(vfmas_scalarh, 2, float16, DO_VFMAS_SCALARH) | ||
110 | DO_2OP_FP_ACC_SCALAR(vfmas_scalars, 4, float32, DO_VFMAS_SCALARS) | ||
111 | + | ||
112 | +/* Floating point max/min across vector. */ | ||
113 | +#define DO_FP_VMAXMINV(OP, ESIZE, TYPE, ABS, FN) \ | ||
114 | + uint32_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vm, \ | ||
115 | + uint32_t ra_in) \ | ||
116 | + { \ | ||
117 | + uint16_t mask = mve_element_mask(env); \ | ||
118 | + unsigned e; \ | ||
119 | + TYPE *m = vm; \ | ||
120 | + TYPE ra = (TYPE)ra_in; \ | ||
121 | + float_status *fpst = (ESIZE == 2) ? \ | ||
122 | + &env->vfp.standard_fp_status_f16 : \ | ||
123 | + &env->vfp.standard_fp_status; \ | ||
124 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
125 | + if (mask & 1) { \ | ||
126 | + TYPE v = m[H##ESIZE(e)]; \ | ||
127 | + if (TYPE##_is_signaling_nan(ra, fpst)) { \ | ||
128 | + ra = TYPE##_silence_nan(ra, fpst); \ | ||
129 | + float_raise(float_flag_invalid, fpst); \ | ||
130 | + } \ | ||
131 | + if (TYPE##_is_signaling_nan(v, fpst)) { \ | ||
132 | + v = TYPE##_silence_nan(v, fpst); \ | ||
133 | + float_raise(float_flag_invalid, fpst); \ | ||
134 | + } \ | ||
135 | + if (ABS) { \ | ||
136 | + v = TYPE##_abs(v); \ | ||
137 | + } \ | ||
138 | + ra = FN(ra, v, fpst); \ | ||
139 | + } \ | ||
140 | + } \ | ||
141 | + mve_advance_vpt(env); \ | ||
142 | + return ra; \ | ||
143 | + } \ | ||
144 | + | ||
145 | +#define NOP(X) (X) | ||
146 | + | ||
147 | +DO_FP_VMAXMINV(vmaxnmvh, 2, float16, false, float16_maxnum) | ||
148 | +DO_FP_VMAXMINV(vmaxnmvs, 4, float32, false, float32_maxnum) | ||
149 | +DO_FP_VMAXMINV(vminnmvh, 2, float16, false, float16_minnum) | ||
150 | +DO_FP_VMAXMINV(vminnmvs, 4, float32, false, float32_minnum) | ||
151 | +DO_FP_VMAXMINV(vmaxnmavh, 2, float16, true, float16_maxnum) | ||
152 | +DO_FP_VMAXMINV(vmaxnmavs, 4, float32, true, float32_maxnum) | ||
153 | +DO_FP_VMAXMINV(vminnmavh, 2, float16, true, float16_minnum) | ||
154 | +DO_FP_VMAXMINV(vminnmavs, 4, float32, true, float32_minnum) | ||
155 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
156 | index XXXXXXX..XXXXXXX 100644 | ||
157 | --- a/target/arm/translate-mve.c | ||
158 | +++ b/target/arm/translate-mve.c | ||
159 | @@ -XXX,XX +XXX,XX @@ DO_VMAXV(VMINV_S, vminvs) | ||
160 | DO_VMAXV(VMINV_U, vminvu) | ||
161 | DO_VMAXV(VMINAV, vminav) | ||
162 | |||
163 | +#define DO_VMAXV_FP(INSN, FN) \ | ||
164 | + static bool trans_##INSN(DisasContext *s, arg_vmaxv *a) \ | ||
165 | + { \ | ||
166 | + static MVEGenVADDVFn * const fns[] = { \ | ||
167 | + NULL, \ | ||
168 | + gen_helper_mve_##FN##h, \ | ||
169 | + gen_helper_mve_##FN##s, \ | ||
170 | + NULL, \ | ||
171 | + }; \ | ||
172 | + if (!dc_isar_feature(aa32_mve_fp, s)) { \ | ||
173 | + return false; \ | ||
174 | + } \ | ||
175 | + return do_vmaxv(s, a, fns[a->size]); \ | ||
176 | + } | ||
177 | + | ||
178 | +DO_VMAXV_FP(VMAXNMV, vmaxnmv) | ||
179 | +DO_VMAXV_FP(VMINNMV, vminnmv) | ||
180 | +DO_VMAXV_FP(VMAXNMAV, vmaxnmav) | ||
181 | +DO_VMAXV_FP(VMINNMAV, vminnmav) | ||
182 | + | ||
183 | static bool do_vabav(DisasContext *s, arg_vabav *a, MVEGenVABAVFn *fn) | ||
184 | { | ||
185 | /* Absolute difference accumulated across vector */ | ||
186 | -- | ||
187 | 2.20.1 | ||
188 | |||
189 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE fp vector comparisons VCMP and VPT. | ||
2 | 1 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | --- | ||
6 | target/arm/helper-mve.h | 18 +++++++++++ | ||
7 | target/arm/mve.decode | 39 +++++++++++++++++++---- | ||
8 | target/arm/mve_helper.c | 64 ++++++++++++++++++++++++++++++++++++++ | ||
9 | target/arm/translate-mve.c | 22 +++++++++++++ | ||
10 | 4 files changed, 137 insertions(+), 6 deletions(-) | ||
11 | |||
12 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/helper-mve.h | ||
15 | +++ b/target/arm/helper-mve.h | ||
16 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vcmple_scalarb, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
17 | DEF_HELPER_FLAGS_3(mve_vcmple_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
18 | DEF_HELPER_FLAGS_3(mve_vcmple_scalarw, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
19 | |||
20 | +DEF_HELPER_FLAGS_3(mve_vfcmpeqh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
21 | +DEF_HELPER_FLAGS_3(mve_vfcmpeqs, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
22 | + | ||
23 | +DEF_HELPER_FLAGS_3(mve_vfcmpneh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
24 | +DEF_HELPER_FLAGS_3(mve_vfcmpnes, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
25 | + | ||
26 | +DEF_HELPER_FLAGS_3(mve_vfcmpgeh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
27 | +DEF_HELPER_FLAGS_3(mve_vfcmpges, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
28 | + | ||
29 | +DEF_HELPER_FLAGS_3(mve_vfcmplth, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
30 | +DEF_HELPER_FLAGS_3(mve_vfcmplts, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
31 | + | ||
32 | +DEF_HELPER_FLAGS_3(mve_vfcmpgth, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
33 | +DEF_HELPER_FLAGS_3(mve_vfcmpgts, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
34 | + | ||
35 | +DEF_HELPER_FLAGS_3(mve_vfcmpleh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
36 | +DEF_HELPER_FLAGS_3(mve_vfcmples, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
37 | + | ||
38 | DEF_HELPER_FLAGS_4(mve_vfadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
39 | DEF_HELPER_FLAGS_4(mve_vfadd_scalars, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
40 | |||
41 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/target/arm/mve.decode | ||
44 | +++ b/target/arm/mve.decode | ||
45 | @@ -XXX,XX +XXX,XX @@ | ||
46 | @vcmp_scalar .... .... .. size:2 qn:3 . .... .... .... rm:4 &vcmp_scalar \ | ||
47 | mask=%mask_22_13 | ||
48 | |||
49 | +@vcmp_fp .... .... .... qn:3 . .... .... .... .... &vcmp \ | ||
50 | + qm=%qm size=%2op_fp_scalar_size mask=%mask_22_13 | ||
51 | + | ||
52 | @vmaxv .... .... .... size:2 .. rda:4 .... .... .... &vmaxv qm=%qm | ||
53 | |||
54 | @2op_fp .... .... .... .... .... .... .... .... &2op \ | ||
55 | @@ -XXX,XX +XXX,XX @@ VSHLC 111 0 1110 1 . 1 imm:5 ... 0 1111 1100 rdm:4 qd=%qd | ||
56 | # Comparisons. We expand out the conditions which are split across | ||
57 | # encodings T1, T2, T3 and the fc bits. These include VPT, which is | ||
58 | # effectively "VCMP then VPST". A plain "VCMP" has a mask field of zero. | ||
59 | -VCMPEQ 1111 1110 0 . .. ... 1 ... 0 1111 0 0 . 0 ... 0 @vcmp | ||
60 | -VCMPNE 1111 1110 0 . .. ... 1 ... 0 1111 1 0 . 0 ... 0 @vcmp | ||
61 | +{ | ||
62 | + VCMPEQ_fp 111 . 1110 0 . 11 ... 1 ... 0 1111 0 0 . 0 ... 0 @vcmp_fp | ||
63 | + VCMPEQ 111 1 1110 0 . .. ... 1 ... 0 1111 0 0 . 0 ... 0 @vcmp | ||
64 | +} | ||
65 | + | ||
66 | +{ | ||
67 | + VCMPNE_fp 111 . 1110 0 . 11 ... 1 ... 0 1111 1 0 . 0 ... 0 @vcmp_fp | ||
68 | + VCMPNE 111 1 1110 0 . .. ... 1 ... 0 1111 1 0 . 0 ... 0 @vcmp | ||
69 | +} | ||
70 | + | ||
71 | +{ | ||
72 | + VCMPGE_fp 111 . 1110 0 . 11 ... 1 ... 1 1111 0 0 . 0 ... 0 @vcmp_fp | ||
73 | + VCMPGE 111 1 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 0 @vcmp | ||
74 | +} | ||
75 | + | ||
76 | +{ | ||
77 | + VCMPLT_fp 111 . 1110 0 . 11 ... 1 ... 1 1111 1 0 . 0 ... 0 @vcmp_fp | ||
78 | + VCMPLT 111 1 1110 0 . .. ... 1 ... 1 1111 1 0 . 0 ... 0 @vcmp | ||
79 | +} | ||
80 | + | ||
81 | +{ | ||
82 | + VCMPGT_fp 111 . 1110 0 . 11 ... 1 ... 1 1111 0 0 . 0 ... 1 @vcmp_fp | ||
83 | + VCMPGT 111 1 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 1 @vcmp | ||
84 | +} | ||
85 | + | ||
86 | +{ | ||
87 | + VCMPLE_fp 111 . 1110 0 . 11 ... 1 ... 1 1111 1 0 . 0 ... 1 @vcmp_fp | ||
88 | + VCMPLE 1111 1110 0 . .. ... 1 ... 1 1111 1 0 . 0 ... 1 @vcmp | ||
89 | +} | ||
90 | + | ||
91 | { | ||
92 | VPSEL 1111 1110 0 . 11 ... 1 ... 0 1111 . 0 . 0 ... 1 @2op_nosz | ||
93 | VCMPCS 1111 1110 0 . .. ... 1 ... 0 1111 0 0 . 0 ... 1 @vcmp | ||
94 | VCMPHI 1111 1110 0 . .. ... 1 ... 0 1111 1 0 . 0 ... 1 @vcmp | ||
95 | } | ||
96 | -VCMPGE 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 0 @vcmp | ||
97 | -VCMPLT 1111 1110 0 . .. ... 1 ... 1 1111 1 0 . 0 ... 0 @vcmp | ||
98 | -VCMPGT 1111 1110 0 . .. ... 1 ... 1 1111 0 0 . 0 ... 1 @vcmp | ||
99 | -VCMPLE 1111 1110 0 . .. ... 1 ... 1 1111 1 0 . 0 ... 1 @vcmp | ||
100 | |||
101 | { | ||
102 | VPNOT 1111 1110 0 0 11 000 1 000 0 1111 0100 1101 | ||
103 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
104 | index XXXXXXX..XXXXXXX 100644 | ||
105 | --- a/target/arm/mve_helper.c | ||
106 | +++ b/target/arm/mve_helper.c | ||
107 | @@ -XXX,XX +XXX,XX @@ DO_FP_VMAXMINV(vmaxnmavh, 2, float16, true, float16_maxnum) | ||
108 | DO_FP_VMAXMINV(vmaxnmavs, 4, float32, true, float32_maxnum) | ||
109 | DO_FP_VMAXMINV(vminnmavh, 2, float16, true, float16_minnum) | ||
110 | DO_FP_VMAXMINV(vminnmavs, 4, float32, true, float32_minnum) | ||
111 | + | ||
112 | +/* FP compares; note that all comparisons signal InvalidOp for QNaNs */ | ||
113 | +#define DO_VCMP_FP(OP, ESIZE, TYPE, FN) \ | ||
114 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, void *vm) \ | ||
115 | + { \ | ||
116 | + TYPE *n = vn, *m = vm; \ | ||
117 | + uint16_t mask = mve_element_mask(env); \ | ||
118 | + uint16_t eci_mask = mve_eci_mask(env); \ | ||
119 | + uint16_t beatpred = 0; \ | ||
120 | + uint16_t emask = MAKE_64BIT_MASK(0, ESIZE); \ | ||
121 | + unsigned e; \ | ||
122 | + float_status *fpst; \ | ||
123 | + float_status scratch_fpst; \ | ||
124 | + bool r; \ | ||
125 | + for (e = 0; e < 16 / ESIZE; e++, emask <<= ESIZE) { \ | ||
126 | + if ((mask & emask) == 0) { \ | ||
127 | + continue; \ | ||
128 | + } \ | ||
129 | + fpst = (ESIZE == 2) ? &env->vfp.standard_fp_status_f16 : \ | ||
130 | + &env->vfp.standard_fp_status; \ | ||
131 | + if (!(mask & (1 << (e * ESIZE)))) { \ | ||
132 | + /* We need the result but without updating flags */ \ | ||
133 | + scratch_fpst = *fpst; \ | ||
134 | + fpst = &scratch_fpst; \ | ||
135 | + } \ | ||
136 | + r = FN(n[H##ESIZE(e)], m[H##ESIZE(e)], fpst); \ | ||
137 | + /* Comparison sets 0/1 bits for each byte in the element */ \ | ||
138 | + beatpred |= r * emask; \ | ||
139 | + } \ | ||
140 | + beatpred &= mask; \ | ||
141 | + env->v7m.vpr = (env->v7m.vpr & ~(uint32_t)eci_mask) | \ | ||
142 | + (beatpred & eci_mask); \ | ||
143 | + mve_advance_vpt(env); \ | ||
144 | + } | ||
145 | + | ||
146 | +/* | ||
147 | + * Some care is needed here to get the correct result for the unordered case. | ||
148 | + * Architecturally EQ, GE and GT are defined to be false for unordered, but | ||
149 | + * the NE, LT and LE comparisons are defined as simple logical inverses of | ||
150 | + * EQ, GE and GT and so they must return true for unordered. The softfloat | ||
151 | + * comparison functions float*_{eq,le,lt} all return false for unordered. | ||
152 | + */ | ||
153 | +#define DO_GE16(X, Y, S) float16_le(Y, X, S) | ||
154 | +#define DO_GE32(X, Y, S) float32_le(Y, X, S) | ||
155 | +#define DO_GT16(X, Y, S) float16_lt(Y, X, S) | ||
156 | +#define DO_GT32(X, Y, S) float32_lt(Y, X, S) | ||
157 | + | ||
158 | +DO_VCMP_FP(vfcmpeqh, 2, float16, float16_eq) | ||
159 | +DO_VCMP_FP(vfcmpeqs, 4, float32, float32_eq) | ||
160 | + | ||
161 | +DO_VCMP_FP(vfcmpneh, 2, float16, !float16_eq) | ||
162 | +DO_VCMP_FP(vfcmpnes, 4, float32, !float32_eq) | ||
163 | + | ||
164 | +DO_VCMP_FP(vfcmpgeh, 2, float16, DO_GE16) | ||
165 | +DO_VCMP_FP(vfcmpges, 4, float32, DO_GE32) | ||
166 | + | ||
167 | +DO_VCMP_FP(vfcmplth, 2, float16, !DO_GE16) | ||
168 | +DO_VCMP_FP(vfcmplts, 4, float32, !DO_GE32) | ||
169 | + | ||
170 | +DO_VCMP_FP(vfcmpgth, 2, float16, DO_GT16) | ||
171 | +DO_VCMP_FP(vfcmpgts, 4, float32, DO_GT32) | ||
172 | + | ||
173 | +DO_VCMP_FP(vfcmpleh, 2, float16, !DO_GT16) | ||
174 | +DO_VCMP_FP(vfcmples, 4, float32, !DO_GT32) | ||
175 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
176 | index XXXXXXX..XXXXXXX 100644 | ||
177 | --- a/target/arm/translate-mve.c | ||
178 | +++ b/target/arm/translate-mve.c | ||
179 | @@ -XXX,XX +XXX,XX @@ DO_VCMP(VCMPLT, vcmplt) | ||
180 | DO_VCMP(VCMPGT, vcmpgt) | ||
181 | DO_VCMP(VCMPLE, vcmple) | ||
182 | |||
183 | +#define DO_VCMP_FP(INSN, FN) \ | ||
184 | + static bool trans_##INSN(DisasContext *s, arg_vcmp *a) \ | ||
185 | + { \ | ||
186 | + static MVEGenCmpFn * const fns[] = { \ | ||
187 | + NULL, \ | ||
188 | + gen_helper_mve_##FN##h, \ | ||
189 | + gen_helper_mve_##FN##s, \ | ||
190 | + NULL, \ | ||
191 | + }; \ | ||
192 | + if (!dc_isar_feature(aa32_mve_fp, s)) { \ | ||
193 | + return false; \ | ||
194 | + } \ | ||
195 | + return do_vcmp(s, a, fns[a->size]); \ | ||
196 | + } | ||
197 | + | ||
198 | +DO_VCMP_FP(VCMPEQ_fp, vfcmpeq) | ||
199 | +DO_VCMP_FP(VCMPNE_fp, vfcmpne) | ||
200 | +DO_VCMP_FP(VCMPGE_fp, vfcmpge) | ||
201 | +DO_VCMP_FP(VCMPLT_fp, vfcmplt) | ||
202 | +DO_VCMP_FP(VCMPGT_fp, vfcmpgt) | ||
203 | +DO_VCMP_FP(VCMPLE_fp, vfcmple) | ||
204 | + | ||
205 | static bool do_vmaxv(DisasContext *s, arg_vmaxv *a, MVEGenVADDVFn fn) | ||
206 | { | ||
207 | /* | ||
208 | -- | ||
209 | 2.20.1 | ||
210 | |||
211 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE fp scalar comparisons VCMP and VPT. | ||
2 | 1 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | --- | ||
6 | target/arm/helper-mve.h | 18 +++++++++++ | ||
7 | target/arm/mve.decode | 61 +++++++++++++++++++++++++++++-------- | ||
8 | target/arm/mve_helper.c | 62 ++++++++++++++++++++++++++++++-------- | ||
9 | target/arm/translate-mve.c | 14 +++++++++ | ||
10 | 4 files changed, 131 insertions(+), 24 deletions(-) | ||
11 | |||
12 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/helper-mve.h | ||
15 | +++ b/target/arm/helper-mve.h | ||
16 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vfcmpgts, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
17 | DEF_HELPER_FLAGS_3(mve_vfcmpleh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
18 | DEF_HELPER_FLAGS_3(mve_vfcmples, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
19 | |||
20 | +DEF_HELPER_FLAGS_3(mve_vfcmpeq_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
21 | +DEF_HELPER_FLAGS_3(mve_vfcmpeq_scalars, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
22 | + | ||
23 | +DEF_HELPER_FLAGS_3(mve_vfcmpne_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
24 | +DEF_HELPER_FLAGS_3(mve_vfcmpne_scalars, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
25 | + | ||
26 | +DEF_HELPER_FLAGS_3(mve_vfcmpge_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_3(mve_vfcmpge_scalars, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
28 | + | ||
29 | +DEF_HELPER_FLAGS_3(mve_vfcmplt_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
30 | +DEF_HELPER_FLAGS_3(mve_vfcmplt_scalars, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
31 | + | ||
32 | +DEF_HELPER_FLAGS_3(mve_vfcmpgt_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
33 | +DEF_HELPER_FLAGS_3(mve_vfcmpgt_scalars, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
34 | + | ||
35 | +DEF_HELPER_FLAGS_3(mve_vfcmple_scalarh, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
36 | +DEF_HELPER_FLAGS_3(mve_vfcmple_scalars, TCG_CALL_NO_WG, void, env, ptr, i32) | ||
37 | + | ||
38 | DEF_HELPER_FLAGS_4(mve_vfadd_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
39 | DEF_HELPER_FLAGS_4(mve_vfadd_scalars, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
40 | |||
41 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/target/arm/mve.decode | ||
44 | +++ b/target/arm/mve.decode | ||
45 | @@ -XXX,XX +XXX,XX @@ | ||
46 | @vcmp_fp .... .... .... qn:3 . .... .... .... .... &vcmp \ | ||
47 | qm=%qm size=%2op_fp_scalar_size mask=%mask_22_13 | ||
48 | |||
49 | +# Bit 28 is a 2op_fp_scalar_size bit, but we do not decode it in this | ||
50 | +# format to avoid complicated overlapping-instruction-groups | ||
51 | +@vcmp_fp_scalar .... .... .... qn:3 . .... .... .... rm:4 &vcmp_scalar \ | ||
52 | + mask=%mask_22_13 | ||
53 | + | ||
54 | @vmaxv .... .... .... size:2 .. rda:4 .... .... .... &vmaxv qm=%qm | ||
55 | |||
56 | @2op_fp .... .... .... .... .... .... .... .... &2op \ | ||
57 | @@ -XXX,XX +XXX,XX @@ VDUP 1110 1110 1 0 10 ... 0 .... 1011 . 0 0 1 0000 @vdup size=2 | ||
58 | VIWDUP 1110 1110 0 . .. ... 1 ... 0 1111 . 110 ... . @viwdup | ||
59 | } | ||
60 | { | ||
61 | - VDDUP 1110 1110 0 . .. ... 1 ... 1 1111 . 110 111 . @vidup | ||
62 | - VDWDUP 1110 1110 0 . .. ... 1 ... 1 1111 . 110 ... . @viwdup | ||
63 | + VCMPGT_fp_scalar 1110 1110 0 . 11 ... 1 ... 1 1111 0110 .... @vcmp_fp_scalar size=2 | ||
64 | + VCMPLE_fp_scalar 1110 1110 0 . 11 ... 1 ... 1 1111 1110 .... @vcmp_fp_scalar size=2 | ||
65 | + VDDUP 1110 1110 0 . .. ... 1 ... 1 1111 . 110 111 . @vidup | ||
66 | + VDWDUP 1110 1110 0 . .. ... 1 ... 1 1111 . 110 ... . @viwdup | ||
67 | } | ||
68 | |||
69 | # multiply-add long dual accumulate | ||
70 | @@ -XXX,XX +XXX,XX @@ VMLADAV_U 1111 1110 1111 ... 0 ... . 1111 . 0 . 0 ... 1 @vmladav_nosz | ||
71 | |||
72 | # Scalar operations | ||
73 | |||
74 | -VADD_scalar 1110 1110 0 . .. ... 1 ... 0 1111 . 100 .... @2scalar | ||
75 | -VSUB_scalar 1110 1110 0 . .. ... 1 ... 1 1111 . 100 .... @2scalar | ||
76 | +{ | ||
77 | + VCMPEQ_fp_scalar 1110 1110 0 . 11 ... 1 ... 0 1111 0100 .... @vcmp_fp_scalar size=2 | ||
78 | + VCMPNE_fp_scalar 1110 1110 0 . 11 ... 1 ... 0 1111 1100 .... @vcmp_fp_scalar size=2 | ||
79 | + VADD_scalar 1110 1110 0 . .. ... 1 ... 0 1111 . 100 .... @2scalar | ||
80 | +} | ||
81 | + | ||
82 | +{ | ||
83 | + VCMPLT_fp_scalar 1110 1110 0 . 11 ... 1 ... 1 1111 1100 .... @vcmp_fp_scalar size=2 | ||
84 | + VCMPGE_fp_scalar 1110 1110 0 . 11 ... 1 ... 1 1111 0100 .... @vcmp_fp_scalar size=2 | ||
85 | + VSUB_scalar 1110 1110 0 . .. ... 1 ... 1 1111 . 100 .... @2scalar | ||
86 | +} | ||
87 | |||
88 | { | ||
89 | VSHL_S_scalar 1110 1110 0 . 11 .. 01 ... 1 1110 0110 .... @shl_scalar | ||
90 | @@ -XXX,XX +XXX,XX @@ VSHLC 111 0 1110 1 . 1 imm:5 ... 0 1111 1100 rdm:4 qd=%qd | ||
91 | } | ||
92 | |||
93 | { | ||
94 | - VPNOT 1111 1110 0 0 11 000 1 000 0 1111 0100 1101 | ||
95 | - VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 | ||
96 | - VCMPEQ_scalar 1111 1110 0 . .. ... 1 ... 0 1111 0 1 0 0 .... @vcmp_scalar | ||
97 | + VPNOT 1111 1110 0 0 11 000 1 000 0 1111 0100 1101 | ||
98 | + VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 | ||
99 | + VCMPEQ_fp_scalar 1111 1110 0 . 11 ... 1 ... 0 1111 0100 .... @vcmp_fp_scalar size=1 | ||
100 | + VCMPEQ_scalar 1111 1110 0 . .. ... 1 ... 0 1111 0100 .... @vcmp_scalar | ||
101 | } | ||
102 | -VCMPNE_scalar 1111 1110 0 . .. ... 1 ... 0 1111 1 1 0 0 .... @vcmp_scalar | ||
103 | + | ||
104 | +{ | ||
105 | + VCMPNE_fp_scalar 1111 1110 0 . 11 ... 1 ... 0 1111 1100 .... @vcmp_fp_scalar size=1 | ||
106 | + VCMPNE_scalar 1111 1110 0 . .. ... 1 ... 0 1111 1100 .... @vcmp_scalar | ||
107 | +} | ||
108 | + | ||
109 | +{ | ||
110 | + VCMPGT_fp_scalar 1111 1110 0 . 11 ... 1 ... 1 1111 0110 .... @vcmp_fp_scalar size=1 | ||
111 | + VCMPGT_scalar 1111 1110 0 . .. ... 1 ... 1 1111 0110 .... @vcmp_scalar | ||
112 | +} | ||
113 | + | ||
114 | +{ | ||
115 | + VCMPLE_fp_scalar 1111 1110 0 . 11 ... 1 ... 1 1111 1110 .... @vcmp_fp_scalar size=1 | ||
116 | + VCMPLE_scalar 1111 1110 0 . .. ... 1 ... 1 1111 1110 .... @vcmp_scalar | ||
117 | +} | ||
118 | + | ||
119 | +{ | ||
120 | + VCMPGE_fp_scalar 1111 1110 0 . 11 ... 1 ... 1 1111 0100 .... @vcmp_fp_scalar size=1 | ||
121 | + VCMPGE_scalar 1111 1110 0 . .. ... 1 ... 1 1111 0100 .... @vcmp_scalar | ||
122 | +} | ||
123 | +{ | ||
124 | + VCMPLT_fp_scalar 1111 1110 0 . 11 ... 1 ... 1 1111 1100 .... @vcmp_fp_scalar size=1 | ||
125 | + VCMPLT_scalar 1111 1110 0 . .. ... 1 ... 1 1111 1100 .... @vcmp_scalar | ||
126 | +} | ||
127 | + | ||
128 | VCMPCS_scalar 1111 1110 0 . .. ... 1 ... 0 1111 0 1 1 0 .... @vcmp_scalar | ||
129 | VCMPHI_scalar 1111 1110 0 . .. ... 1 ... 0 1111 1 1 1 0 .... @vcmp_scalar | ||
130 | -VCMPGE_scalar 1111 1110 0 . .. ... 1 ... 1 1111 0 1 0 0 .... @vcmp_scalar | ||
131 | -VCMPLT_scalar 1111 1110 0 . .. ... 1 ... 1 1111 1 1 0 0 .... @vcmp_scalar | ||
132 | -VCMPGT_scalar 1111 1110 0 . .. ... 1 ... 1 1111 0 1 1 0 .... @vcmp_scalar | ||
133 | -VCMPLE_scalar 1111 1110 0 . .. ... 1 ... 1 1111 1 1 1 0 .... @vcmp_scalar | ||
134 | |||
135 | # 2-operand FP | ||
136 | VADD_fp 1110 1111 0 . 0 . ... 0 ... 0 1101 . 1 . 0 ... 0 @2op_fp | ||
137 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
138 | index XXXXXXX..XXXXXXX 100644 | ||
139 | --- a/target/arm/mve_helper.c | ||
140 | +++ b/target/arm/mve_helper.c | ||
141 | @@ -XXX,XX +XXX,XX @@ DO_FP_VMAXMINV(vminnmavs, 4, float32, true, float32_minnum) | ||
142 | mve_advance_vpt(env); \ | ||
143 | } | ||
144 | |||
145 | +#define DO_VCMP_FP_SCALAR(OP, ESIZE, TYPE, FN) \ | ||
146 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, \ | ||
147 | + uint32_t rm) \ | ||
148 | + { \ | ||
149 | + TYPE *n = vn; \ | ||
150 | + uint16_t mask = mve_element_mask(env); \ | ||
151 | + uint16_t eci_mask = mve_eci_mask(env); \ | ||
152 | + uint16_t beatpred = 0; \ | ||
153 | + uint16_t emask = MAKE_64BIT_MASK(0, ESIZE); \ | ||
154 | + unsigned e; \ | ||
155 | + float_status *fpst; \ | ||
156 | + float_status scratch_fpst; \ | ||
157 | + bool r; \ | ||
158 | + for (e = 0; e < 16 / ESIZE; e++, emask <<= ESIZE) { \ | ||
159 | + if ((mask & emask) == 0) { \ | ||
160 | + continue; \ | ||
161 | + } \ | ||
162 | + fpst = (ESIZE == 2) ? &env->vfp.standard_fp_status_f16 : \ | ||
163 | + &env->vfp.standard_fp_status; \ | ||
164 | + if (!(mask & (1 << (e * ESIZE)))) { \ | ||
165 | + /* We need the result but without updating flags */ \ | ||
166 | + scratch_fpst = *fpst; \ | ||
167 | + fpst = &scratch_fpst; \ | ||
168 | + } \ | ||
169 | + r = FN(n[H##ESIZE(e)], (TYPE)rm, fpst); \ | ||
170 | + /* Comparison sets 0/1 bits for each byte in the element */ \ | ||
171 | + beatpred |= r * emask; \ | ||
172 | + } \ | ||
173 | + beatpred &= mask; \ | ||
174 | + env->v7m.vpr = (env->v7m.vpr & ~(uint32_t)eci_mask) | \ | ||
175 | + (beatpred & eci_mask); \ | ||
176 | + mve_advance_vpt(env); \ | ||
177 | + } | ||
178 | + | ||
179 | +#define DO_VCMP_FP_BOTH(VOP, SOP, ESIZE, TYPE, FN) \ | ||
180 | + DO_VCMP_FP(VOP, ESIZE, TYPE, FN) \ | ||
181 | + DO_VCMP_FP_SCALAR(SOP, ESIZE, TYPE, FN) | ||
182 | + | ||
183 | /* | ||
184 | * Some care is needed here to get the correct result for the unordered case. | ||
185 | * Architecturally EQ, GE and GT are defined to be false for unordered, but | ||
186 | @@ -XXX,XX +XXX,XX @@ DO_FP_VMAXMINV(vminnmavs, 4, float32, true, float32_minnum) | ||
187 | #define DO_GT16(X, Y, S) float16_lt(Y, X, S) | ||
188 | #define DO_GT32(X, Y, S) float32_lt(Y, X, S) | ||
189 | |||
190 | -DO_VCMP_FP(vfcmpeqh, 2, float16, float16_eq) | ||
191 | -DO_VCMP_FP(vfcmpeqs, 4, float32, float32_eq) | ||
192 | +DO_VCMP_FP_BOTH(vfcmpeqh, vfcmpeq_scalarh, 2, float16, float16_eq) | ||
193 | +DO_VCMP_FP_BOTH(vfcmpeqs, vfcmpeq_scalars, 4, float32, float32_eq) | ||
194 | |||
195 | -DO_VCMP_FP(vfcmpneh, 2, float16, !float16_eq) | ||
196 | -DO_VCMP_FP(vfcmpnes, 4, float32, !float32_eq) | ||
197 | +DO_VCMP_FP_BOTH(vfcmpneh, vfcmpne_scalarh, 2, float16, !float16_eq) | ||
198 | +DO_VCMP_FP_BOTH(vfcmpnes, vfcmpne_scalars, 4, float32, !float32_eq) | ||
199 | |||
200 | -DO_VCMP_FP(vfcmpgeh, 2, float16, DO_GE16) | ||
201 | -DO_VCMP_FP(vfcmpges, 4, float32, DO_GE32) | ||
202 | +DO_VCMP_FP_BOTH(vfcmpgeh, vfcmpge_scalarh, 2, float16, DO_GE16) | ||
203 | +DO_VCMP_FP_BOTH(vfcmpges, vfcmpge_scalars, 4, float32, DO_GE32) | ||
204 | |||
205 | -DO_VCMP_FP(vfcmplth, 2, float16, !DO_GE16) | ||
206 | -DO_VCMP_FP(vfcmplts, 4, float32, !DO_GE32) | ||
207 | +DO_VCMP_FP_BOTH(vfcmplth, vfcmplt_scalarh, 2, float16, !DO_GE16) | ||
208 | +DO_VCMP_FP_BOTH(vfcmplts, vfcmplt_scalars, 4, float32, !DO_GE32) | ||
209 | |||
210 | -DO_VCMP_FP(vfcmpgth, 2, float16, DO_GT16) | ||
211 | -DO_VCMP_FP(vfcmpgts, 4, float32, DO_GT32) | ||
212 | +DO_VCMP_FP_BOTH(vfcmpgth, vfcmpgt_scalarh, 2, float16, DO_GT16) | ||
213 | +DO_VCMP_FP_BOTH(vfcmpgts, vfcmpgt_scalars, 4, float32, DO_GT32) | ||
214 | |||
215 | -DO_VCMP_FP(vfcmpleh, 2, float16, !DO_GT16) | ||
216 | -DO_VCMP_FP(vfcmples, 4, float32, !DO_GT32) | ||
217 | +DO_VCMP_FP_BOTH(vfcmpleh, vfcmple_scalarh, 2, float16, !DO_GT16) | ||
218 | +DO_VCMP_FP_BOTH(vfcmples, vfcmple_scalars, 4, float32, !DO_GT32) | ||
219 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
220 | index XXXXXXX..XXXXXXX 100644 | ||
221 | --- a/target/arm/translate-mve.c | ||
222 | +++ b/target/arm/translate-mve.c | ||
223 | @@ -XXX,XX +XXX,XX @@ DO_VCMP(VCMPLE, vcmple) | ||
224 | return false; \ | ||
225 | } \ | ||
226 | return do_vcmp(s, a, fns[a->size]); \ | ||
227 | + } \ | ||
228 | + static bool trans_##INSN##_scalar(DisasContext *s, \ | ||
229 | + arg_vcmp_scalar *a) \ | ||
230 | + { \ | ||
231 | + static MVEGenScalarCmpFn * const fns[] = { \ | ||
232 | + NULL, \ | ||
233 | + gen_helper_mve_##FN##_scalarh, \ | ||
234 | + gen_helper_mve_##FN##_scalars, \ | ||
235 | + NULL, \ | ||
236 | + }; \ | ||
237 | + if (!dc_isar_feature(aa32_mve_fp, s)) { \ | ||
238 | + return false; \ | ||
239 | + } \ | ||
240 | + return do_vcmp_scalar(s, a, fns[a->size]); \ | ||
241 | } | ||
242 | |||
243 | DO_VCMP_FP(VCMPEQ_fp, vfcmpeq) | ||
244 | -- | ||
245 | 2.20.1 | ||
246 | |||
247 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VCVT insns which convert between floating and fixed | ||
2 | point. As with the Neon equivalents, these use essentially the same | ||
3 | constant encoding as right-shift-by-immediate. | ||
4 | 1 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | --- | ||
8 | target/arm/helper-mve.h | 9 +++++++++ | ||
9 | target/arm/mve.decode | 19 +++++++++++++++++++ | ||
10 | target/arm/mve_helper.c | 36 ++++++++++++++++++++++++++++++++++++ | ||
11 | target/arm/translate-mve.c | 18 ++++++++++++++++++ | ||
12 | 4 files changed, 82 insertions(+) | ||
13 | |||
14 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/helper-mve.h | ||
17 | +++ b/target/arm/helper-mve.h | ||
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vfma_scalars, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
19 | |||
20 | DEF_HELPER_FLAGS_4(mve_vfmas_scalarh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
21 | DEF_HELPER_FLAGS_4(mve_vfmas_scalars, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
22 | + | ||
23 | +DEF_HELPER_FLAGS_4(mve_vcvt_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
24 | +DEF_HELPER_FLAGS_4(mve_vcvt_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
25 | +DEF_HELPER_FLAGS_4(mve_vcvt_hs, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vcvt_hu, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vcvt_sf, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_4(mve_vcvt_uf, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
29 | +DEF_HELPER_FLAGS_4(mve_vcvt_fs, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
30 | +DEF_HELPER_FLAGS_4(mve_vcvt_fu, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
31 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/target/arm/mve.decode | ||
34 | +++ b/target/arm/mve.decode | ||
35 | @@ -XXX,XX +XXX,XX @@ VCMLA0 1111 110 00 . 1 . ... 0 ... 0 1000 . 1 . 0 ... 0 @2op_fp_size_ | ||
36 | VCMLA90 1111 110 01 . 1 . ... 0 ... 0 1000 . 1 . 0 ... 0 @2op_fp_size_rev | ||
37 | VCMLA180 1111 110 10 . 1 . ... 0 ... 0 1000 . 1 . 0 ... 0 @2op_fp_size_rev | ||
38 | VCMLA270 1111 110 11 . 1 . ... 0 ... 0 1000 . 1 . 0 ... 0 @2op_fp_size_rev | ||
39 | + | ||
40 | +# floating-point <-> fixed-point conversions. Naming convention: | ||
41 | +# VCVT_<from><to>, S = signed int, U = unsigned int, H = halfprec, F = singleprec | ||
42 | +@vcvt .... .... .. 1 ..... .... .. 1 . .... .... &2shift \ | ||
43 | + qd=%qd qm=%qm shift=%rshift_i5 size=2 | ||
44 | +@vcvt_f16 .... .... .. 11 .... .... .. 0 . .... .... &2shift \ | ||
45 | + qd=%qd qm=%qm shift=%rshift_i4 size=1 | ||
46 | + | ||
47 | +VCVT_SH_fixed 1110 1111 1 . ...... ... 0 11 . 0 01 . 1 ... 0 @vcvt_f16 | ||
48 | +VCVT_UH_fixed 1111 1111 1 . ...... ... 0 11 . 0 01 . 1 ... 0 @vcvt_f16 | ||
49 | + | ||
50 | +VCVT_HS_fixed 1110 1111 1 . ...... ... 0 11 . 1 01 . 1 ... 0 @vcvt_f16 | ||
51 | +VCVT_HU_fixed 1111 1111 1 . ...... ... 0 11 . 1 01 . 1 ... 0 @vcvt_f16 | ||
52 | + | ||
53 | +VCVT_SF_fixed 1110 1111 1 . ...... ... 0 11 . 0 01 . 1 ... 0 @vcvt | ||
54 | +VCVT_UF_fixed 1111 1111 1 . ...... ... 0 11 . 0 01 . 1 ... 0 @vcvt | ||
55 | + | ||
56 | +VCVT_FS_fixed 1110 1111 1 . ...... ... 0 11 . 1 01 . 1 ... 0 @vcvt | ||
57 | +VCVT_FU_fixed 1111 1111 1 . ...... ... 0 11 . 1 01 . 1 ... 0 @vcvt | ||
58 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
59 | index XXXXXXX..XXXXXXX 100644 | ||
60 | --- a/target/arm/mve_helper.c | ||
61 | +++ b/target/arm/mve_helper.c | ||
62 | @@ -XXX,XX +XXX,XX @@ DO_VCMP_FP_BOTH(vfcmpgts, vfcmpgt_scalars, 4, float32, DO_GT32) | ||
63 | |||
64 | DO_VCMP_FP_BOTH(vfcmpleh, vfcmple_scalarh, 2, float16, !DO_GT16) | ||
65 | DO_VCMP_FP_BOTH(vfcmples, vfcmple_scalars, 4, float32, !DO_GT32) | ||
66 | + | ||
67 | +#define DO_VCVT_FIXED(OP, ESIZE, TYPE, FN) \ | ||
68 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vm, \ | ||
69 | + uint32_t shift) \ | ||
70 | + { \ | ||
71 | + TYPE *d = vd, *m = vm; \ | ||
72 | + TYPE r; \ | ||
73 | + uint16_t mask = mve_element_mask(env); \ | ||
74 | + unsigned e; \ | ||
75 | + float_status *fpst; \ | ||
76 | + float_status scratch_fpst; \ | ||
77 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
78 | + if ((mask & MAKE_64BIT_MASK(0, ESIZE)) == 0) { \ | ||
79 | + continue; \ | ||
80 | + } \ | ||
81 | + fpst = (ESIZE == 2) ? &env->vfp.standard_fp_status_f16 : \ | ||
82 | + &env->vfp.standard_fp_status; \ | ||
83 | + if (!(mask & 1)) { \ | ||
84 | + /* We need the result but without updating flags */ \ | ||
85 | + scratch_fpst = *fpst; \ | ||
86 | + fpst = &scratch_fpst; \ | ||
87 | + } \ | ||
88 | + r = FN(m[H##ESIZE(e)], shift, fpst); \ | ||
89 | + mergemask(&d[H##ESIZE(e)], r, mask); \ | ||
90 | + } \ | ||
91 | + mve_advance_vpt(env); \ | ||
92 | + } | ||
93 | + | ||
94 | +DO_VCVT_FIXED(vcvt_sh, 2, int16_t, helper_vfp_shtoh) | ||
95 | +DO_VCVT_FIXED(vcvt_uh, 2, uint16_t, helper_vfp_uhtoh) | ||
96 | +DO_VCVT_FIXED(vcvt_hs, 2, int16_t, helper_vfp_toshh_round_to_zero) | ||
97 | +DO_VCVT_FIXED(vcvt_hu, 2, uint16_t, helper_vfp_touhh_round_to_zero) | ||
98 | +DO_VCVT_FIXED(vcvt_sf, 4, int32_t, helper_vfp_sltos) | ||
99 | +DO_VCVT_FIXED(vcvt_uf, 4, uint32_t, helper_vfp_ultos) | ||
100 | +DO_VCVT_FIXED(vcvt_fs, 4, int32_t, helper_vfp_tosls_round_to_zero) | ||
101 | +DO_VCVT_FIXED(vcvt_fu, 4, uint32_t, helper_vfp_touls_round_to_zero) | ||
102 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
103 | index XXXXXXX..XXXXXXX 100644 | ||
104 | --- a/target/arm/translate-mve.c | ||
105 | +++ b/target/arm/translate-mve.c | ||
106 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT(VRSHRI_U, vrshli_u, true) | ||
107 | DO_2SHIFT(VSRI, vsri, false) | ||
108 | DO_2SHIFT(VSLI, vsli, false) | ||
109 | |||
110 | +#define DO_2SHIFT_FP(INSN, FN) \ | ||
111 | + static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ | ||
112 | + { \ | ||
113 | + if (!dc_isar_feature(aa32_mve_fp, s)) { \ | ||
114 | + return false; \ | ||
115 | + } \ | ||
116 | + return do_2shift(s, a, gen_helper_mve_##FN, false); \ | ||
117 | + } | ||
118 | + | ||
119 | +DO_2SHIFT_FP(VCVT_SH_fixed, vcvt_sh) | ||
120 | +DO_2SHIFT_FP(VCVT_UH_fixed, vcvt_uh) | ||
121 | +DO_2SHIFT_FP(VCVT_HS_fixed, vcvt_hs) | ||
122 | +DO_2SHIFT_FP(VCVT_HU_fixed, vcvt_hu) | ||
123 | +DO_2SHIFT_FP(VCVT_SF_fixed, vcvt_sf) | ||
124 | +DO_2SHIFT_FP(VCVT_UF_fixed, vcvt_uf) | ||
125 | +DO_2SHIFT_FP(VCVT_FS_fixed, vcvt_fs) | ||
126 | +DO_2SHIFT_FP(VCVT_FU_fixed, vcvt_fu) | ||
127 | + | ||
128 | static bool do_2shift_scalar(DisasContext *s, arg_shl_scalar *a, | ||
129 | MVEGenTwoOpShiftFn *fn) | ||
130 | { | ||
131 | -- | ||
132 | 2.20.1 | ||
133 | |||
134 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE "VCVT (between floating-point and integer)" insn. | ||
2 | 1 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | --- | ||
6 | target/arm/mve.decode | 7 +++++++ | ||
7 | target/arm/translate-mve.c | 32 ++++++++++++++++++++++++++++++++ | ||
8 | 2 files changed, 39 insertions(+) | ||
9 | |||
10 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/target/arm/mve.decode | ||
13 | +++ b/target/arm/mve.decode | ||
14 | @@ -XXX,XX +XXX,XX @@ VCVT_UF_fixed 1111 1111 1 . ...... ... 0 11 . 0 01 . 1 ... 0 @vcvt | ||
15 | |||
16 | VCVT_FS_fixed 1110 1111 1 . ...... ... 0 11 . 1 01 . 1 ... 0 @vcvt | ||
17 | VCVT_FU_fixed 1111 1111 1 . ...... ... 0 11 . 1 01 . 1 ... 0 @vcvt | ||
18 | + | ||
19 | +# VCVT between floating point and integer (halfprec and single); | ||
20 | +# VCVT_<from><to>, S = signed int, U = unsigned int, F = float | ||
21 | +VCVT_SF 1111 1111 1 . 11 .. 11 ... 0 011 00 1 . 0 ... 0 @1op | ||
22 | +VCVT_UF 1111 1111 1 . 11 .. 11 ... 0 011 01 1 . 0 ... 0 @1op | ||
23 | +VCVT_FS 1111 1111 1 . 11 .. 11 ... 0 011 10 1 . 0 ... 0 @1op | ||
24 | +VCVT_FU 1111 1111 1 . 11 .. 11 ... 0 011 11 1 . 0 ... 0 @1op | ||
25 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/target/arm/translate-mve.c | ||
28 | +++ b/target/arm/translate-mve.c | ||
29 | @@ -XXX,XX +XXX,XX @@ DO_1OP(VQNEG, vqneg) | ||
30 | DO_1OP(VMAXA, vmaxa) | ||
31 | DO_1OP(VMINA, vmina) | ||
32 | |||
33 | +/* | ||
34 | + * For simple float/int conversions we use the fixed-point | ||
35 | + * conversion helpers with a zero shift count | ||
36 | + */ | ||
37 | +#define DO_VCVT(INSN, HFN, SFN) \ | ||
38 | + static void gen_##INSN##h(TCGv_ptr env, TCGv_ptr qd, TCGv_ptr qm) \ | ||
39 | + { \ | ||
40 | + gen_helper_mve_##HFN(env, qd, qm, tcg_constant_i32(0)); \ | ||
41 | + } \ | ||
42 | + static void gen_##INSN##s(TCGv_ptr env, TCGv_ptr qd, TCGv_ptr qm) \ | ||
43 | + { \ | ||
44 | + gen_helper_mve_##SFN(env, qd, qm, tcg_constant_i32(0)); \ | ||
45 | + } \ | ||
46 | + static bool trans_##INSN(DisasContext *s, arg_1op *a) \ | ||
47 | + { \ | ||
48 | + static MVEGenOneOpFn * const fns[] = { \ | ||
49 | + NULL, \ | ||
50 | + gen_##INSN##h, \ | ||
51 | + gen_##INSN##s, \ | ||
52 | + NULL, \ | ||
53 | + }; \ | ||
54 | + if (!dc_isar_feature(aa32_mve_fp, s)) { \ | ||
55 | + return false; \ | ||
56 | + } \ | ||
57 | + return do_1op(s, a, fns[a->size]); \ | ||
58 | + } | ||
59 | + | ||
60 | +DO_VCVT(VCVT_SF, vcvt_sh, vcvt_sf) | ||
61 | +DO_VCVT(VCVT_UF, vcvt_uh, vcvt_uf) | ||
62 | +DO_VCVT(VCVT_FS, vcvt_hs, vcvt_fs) | ||
63 | +DO_VCVT(VCVT_FU, vcvt_hu, vcvt_fu) | ||
64 | + | ||
65 | /* Narrowing moves: only size 0 and 1 are valid */ | ||
66 | #define DO_VMOVN(INSN, FN) \ | ||
67 | static bool trans_##INSN(DisasContext *s, arg_1op *a) \ | ||
68 | -- | ||
69 | 2.20.1 | ||
70 | |||
71 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VCVT which converts from floating-point to integer | ||
2 | using a rounding mode specified by the instruction. We implement | ||
3 | this similarly to the Neon equivalents, by passing the required | ||
4 | rounding mode as an extra integer parameter to the helper functions. | ||
5 | 1 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | --- | ||
9 | target/arm/helper-mve.h | 5 ++++ | ||
10 | target/arm/mve.decode | 10 ++++++++ | ||
11 | target/arm/mve_helper.c | 38 ++++++++++++++++++++++++++++ | ||
12 | target/arm/translate-mve.c | 52 ++++++++++++++++++++++++++++++++++++++ | ||
13 | 4 files changed, 105 insertions(+) | ||
14 | |||
15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/helper-mve.h | ||
18 | +++ b/target/arm/helper-mve.h | ||
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vminab, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
20 | DEF_HELPER_FLAGS_3(mve_vminah, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
21 | DEF_HELPER_FLAGS_3(mve_vminaw, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
22 | |||
23 | +DEF_HELPER_FLAGS_4(mve_vcvt_rm_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
24 | +DEF_HELPER_FLAGS_4(mve_vcvt_rm_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
25 | +DEF_HELPER_FLAGS_4(mve_vcvt_rm_ss, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vcvt_rm_us, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
27 | + | ||
28 | DEF_HELPER_FLAGS_3(mve_vmovnbb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
29 | DEF_HELPER_FLAGS_3(mve_vmovnbh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
30 | DEF_HELPER_FLAGS_3(mve_vmovntb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
31 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/target/arm/mve.decode | ||
34 | +++ b/target/arm/mve.decode | ||
35 | @@ -XXX,XX +XXX,XX @@ VCVT_SF 1111 1111 1 . 11 .. 11 ... 0 011 00 1 . 0 ... 0 @1op | ||
36 | VCVT_UF 1111 1111 1 . 11 .. 11 ... 0 011 01 1 . 0 ... 0 @1op | ||
37 | VCVT_FS 1111 1111 1 . 11 .. 11 ... 0 011 10 1 . 0 ... 0 @1op | ||
38 | VCVT_FU 1111 1111 1 . 11 .. 11 ... 0 011 11 1 . 0 ... 0 @1op | ||
39 | + | ||
40 | +# VCVT from floating point to integer with specified rounding mode | ||
41 | +VCVTAS 1111 1111 1 . 11 .. 11 ... 000 00 0 1 . 0 ... 0 @1op | ||
42 | +VCVTAU 1111 1111 1 . 11 .. 11 ... 000 00 1 1 . 0 ... 0 @1op | ||
43 | +VCVTNS 1111 1111 1 . 11 .. 11 ... 000 01 0 1 . 0 ... 0 @1op | ||
44 | +VCVTNU 1111 1111 1 . 11 .. 11 ... 000 01 1 1 . 0 ... 0 @1op | ||
45 | +VCVTPS 1111 1111 1 . 11 .. 11 ... 000 10 0 1 . 0 ... 0 @1op | ||
46 | +VCVTPU 1111 1111 1 . 11 .. 11 ... 000 10 1 1 . 0 ... 0 @1op | ||
47 | +VCVTMS 1111 1111 1 . 11 .. 11 ... 000 11 0 1 . 0 ... 0 @1op | ||
48 | +VCVTMU 1111 1111 1 . 11 .. 11 ... 000 11 1 1 . 0 ... 0 @1op | ||
49 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/target/arm/mve_helper.c | ||
52 | +++ b/target/arm/mve_helper.c | ||
53 | @@ -XXX,XX +XXX,XX @@ DO_VCVT_FIXED(vcvt_sf, 4, int32_t, helper_vfp_sltos) | ||
54 | DO_VCVT_FIXED(vcvt_uf, 4, uint32_t, helper_vfp_ultos) | ||
55 | DO_VCVT_FIXED(vcvt_fs, 4, int32_t, helper_vfp_tosls_round_to_zero) | ||
56 | DO_VCVT_FIXED(vcvt_fu, 4, uint32_t, helper_vfp_touls_round_to_zero) | ||
57 | + | ||
58 | +/* VCVT with specified rmode */ | ||
59 | +#define DO_VCVT_RMODE(OP, ESIZE, TYPE, FN) \ | ||
60 | + void HELPER(glue(mve_, OP))(CPUARMState *env, \ | ||
61 | + void *vd, void *vm, uint32_t rmode) \ | ||
62 | + { \ | ||
63 | + TYPE *d = vd, *m = vm; \ | ||
64 | + TYPE r; \ | ||
65 | + uint16_t mask = mve_element_mask(env); \ | ||
66 | + unsigned e; \ | ||
67 | + float_status *fpst; \ | ||
68 | + float_status scratch_fpst; \ | ||
69 | + float_status *base_fpst = (ESIZE == 2) ? \ | ||
70 | + &env->vfp.standard_fp_status_f16 : \ | ||
71 | + &env->vfp.standard_fp_status; \ | ||
72 | + uint32_t prev_rmode = get_float_rounding_mode(base_fpst); \ | ||
73 | + set_float_rounding_mode(rmode, base_fpst); \ | ||
74 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
75 | + if ((mask & MAKE_64BIT_MASK(0, ESIZE)) == 0) { \ | ||
76 | + continue; \ | ||
77 | + } \ | ||
78 | + fpst = base_fpst; \ | ||
79 | + if (!(mask & 1)) { \ | ||
80 | + /* We need the result but without updating flags */ \ | ||
81 | + scratch_fpst = *fpst; \ | ||
82 | + fpst = &scratch_fpst; \ | ||
83 | + } \ | ||
84 | + r = FN(m[H##ESIZE(e)], 0, fpst); \ | ||
85 | + mergemask(&d[H##ESIZE(e)], r, mask); \ | ||
86 | + } \ | ||
87 | + set_float_rounding_mode(prev_rmode, base_fpst); \ | ||
88 | + mve_advance_vpt(env); \ | ||
89 | + } | ||
90 | + | ||
91 | +DO_VCVT_RMODE(vcvt_rm_sh, 2, uint16_t, helper_vfp_toshh) | ||
92 | +DO_VCVT_RMODE(vcvt_rm_uh, 2, uint16_t, helper_vfp_touhh) | ||
93 | +DO_VCVT_RMODE(vcvt_rm_ss, 4, uint32_t, helper_vfp_tosls) | ||
94 | +DO_VCVT_RMODE(vcvt_rm_us, 4, uint32_t, helper_vfp_touls) | ||
95 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
96 | index XXXXXXX..XXXXXXX 100644 | ||
97 | --- a/target/arm/translate-mve.c | ||
98 | +++ b/target/arm/translate-mve.c | ||
99 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenCmpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
100 | typedef void MVEGenScalarCmpFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
101 | typedef void MVEGenVABAVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
102 | typedef void MVEGenDualAccOpFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
103 | +typedef void MVEGenVCVTRmodeFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
104 | |||
105 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ | ||
106 | static inline long mve_qreg_offset(unsigned reg) | ||
107 | @@ -XXX,XX +XXX,XX @@ DO_VCVT(VCVT_UF, vcvt_uh, vcvt_uf) | ||
108 | DO_VCVT(VCVT_FS, vcvt_hs, vcvt_fs) | ||
109 | DO_VCVT(VCVT_FU, vcvt_hu, vcvt_fu) | ||
110 | |||
111 | +static bool do_vcvt_rmode(DisasContext *s, arg_1op *a, | ||
112 | + enum arm_fprounding rmode, bool u) | ||
113 | +{ | ||
114 | + /* | ||
115 | + * Handle VCVT fp to int with specified rounding mode. | ||
116 | + * This is a 1op fn but we must pass the rounding mode as | ||
117 | + * an immediate to the helper. | ||
118 | + */ | ||
119 | + TCGv_ptr qd, qm; | ||
120 | + static MVEGenVCVTRmodeFn * const fns[4][2] = { | ||
121 | + { NULL, NULL }, | ||
122 | + { gen_helper_mve_vcvt_rm_sh, gen_helper_mve_vcvt_rm_uh }, | ||
123 | + { gen_helper_mve_vcvt_rm_ss, gen_helper_mve_vcvt_rm_us }, | ||
124 | + { NULL, NULL }, | ||
125 | + }; | ||
126 | + MVEGenVCVTRmodeFn *fn = fns[a->size][u]; | ||
127 | + | ||
128 | + if (!dc_isar_feature(aa32_mve_fp, s) || | ||
129 | + !mve_check_qreg_bank(s, a->qd | a->qm) || | ||
130 | + !fn) { | ||
131 | + return false; | ||
132 | + } | ||
133 | + | ||
134 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
135 | + return true; | ||
136 | + } | ||
137 | + | ||
138 | + qd = mve_qreg_ptr(a->qd); | ||
139 | + qm = mve_qreg_ptr(a->qm); | ||
140 | + fn(cpu_env, qd, qm, tcg_constant_i32(arm_rmode_to_sf(rmode))); | ||
141 | + tcg_temp_free_ptr(qd); | ||
142 | + tcg_temp_free_ptr(qm); | ||
143 | + mve_update_eci(s); | ||
144 | + return true; | ||
145 | +} | ||
146 | + | ||
147 | +#define DO_VCVT_RMODE(INSN, RMODE, U) \ | ||
148 | + static bool trans_##INSN(DisasContext *s, arg_1op *a) \ | ||
149 | + { \ | ||
150 | + return do_vcvt_rmode(s, a, RMODE, U); \ | ||
151 | + } \ | ||
152 | + | ||
153 | +DO_VCVT_RMODE(VCVTAS, FPROUNDING_TIEAWAY, false) | ||
154 | +DO_VCVT_RMODE(VCVTAU, FPROUNDING_TIEAWAY, true) | ||
155 | +DO_VCVT_RMODE(VCVTNS, FPROUNDING_TIEEVEN, false) | ||
156 | +DO_VCVT_RMODE(VCVTNU, FPROUNDING_TIEEVEN, true) | ||
157 | +DO_VCVT_RMODE(VCVTPS, FPROUNDING_POSINF, false) | ||
158 | +DO_VCVT_RMODE(VCVTPU, FPROUNDING_POSINF, true) | ||
159 | +DO_VCVT_RMODE(VCVTMS, FPROUNDING_NEGINF, false) | ||
160 | +DO_VCVT_RMODE(VCVTMU, FPROUNDING_NEGINF, true) | ||
161 | + | ||
162 | /* Narrowing moves: only size 0 and 1 are valid */ | ||
163 | #define DO_VMOVN(INSN, FN) \ | ||
164 | static bool trans_##INSN(DisasContext *s, arg_1op *a) \ | ||
165 | -- | ||
166 | 2.20.1 | ||
167 | |||
168 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VCVT instruction which converts between single | ||
2 | and half precision floating point. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | target/arm/helper-mve.h | 5 +++ | ||
8 | target/arm/mve.decode | 8 ++++ | ||
9 | target/arm/mve_helper.c | 81 ++++++++++++++++++++++++++++++++++++++ | ||
10 | target/arm/translate-mve.c | 14 +++++++ | ||
11 | 4 files changed, 108 insertions(+) | ||
12 | |||
13 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/helper-mve.h | ||
16 | +++ b/target/arm/helper-mve.h | ||
17 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vcvt_rm_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
18 | DEF_HELPER_FLAGS_4(mve_vcvt_rm_ss, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
19 | DEF_HELPER_FLAGS_4(mve_vcvt_rm_us, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
20 | |||
21 | +DEF_HELPER_FLAGS_3(mve_vcvtb_sh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
22 | +DEF_HELPER_FLAGS_3(mve_vcvtt_sh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
23 | +DEF_HELPER_FLAGS_3(mve_vcvtb_hs, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
24 | +DEF_HELPER_FLAGS_3(mve_vcvtt_hs, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
25 | + | ||
26 | DEF_HELPER_FLAGS_3(mve_vmovnbb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
27 | DEF_HELPER_FLAGS_3(mve_vmovnbh, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
28 | DEF_HELPER_FLAGS_3(mve_vmovntb, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
29 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/mve.decode | ||
32 | +++ b/target/arm/mve.decode | ||
33 | @@ -XXX,XX +XXX,XX @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
34 | # The VSHLL T2 encoding is not a @2op pattern, but is here because it | ||
35 | # overlaps what would be size=0b11 VMULH/VRMULH | ||
36 | { | ||
37 | + VCVTB_SH 111 0 1110 0 . 11 1111 ... 0 1110 0 0 . 0 ... 1 @1op_nosz | ||
38 | + | ||
39 | VMAXNMA 111 0 1110 0 . 11 1111 ... 0 1110 1 0 . 0 ... 1 @vmaxnma size=2 | ||
40 | |||
41 | VSHLL_BS 111 0 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_b | ||
42 | @@ -XXX,XX +XXX,XX @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
43 | } | ||
44 | |||
45 | { | ||
46 | + VCVTB_HS 111 1 1110 0 . 11 1111 ... 0 1110 0 0 . 0 ... 1 @1op_nosz | ||
47 | + | ||
48 | VMAXNMA 111 1 1110 0 . 11 1111 ... 0 1110 1 0 . 0 ... 1 @vmaxnma size=1 | ||
49 | |||
50 | VSHLL_BU 111 1 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_b | ||
51 | @@ -XXX,XX +XXX,XX @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
52 | } | ||
53 | |||
54 | { | ||
55 | + VCVTT_SH 111 0 1110 0 . 11 1111 ... 1 1110 0 0 . 0 ... 1 @1op_nosz | ||
56 | + | ||
57 | VMINNMA 111 0 1110 0 . 11 1111 ... 1 1110 1 0 . 0 ... 1 @vmaxnma size=2 | ||
58 | VSHLL_TS 111 0 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_b | ||
59 | VSHLL_TS 111 0 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
60 | @@ -XXX,XX +XXX,XX @@ VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
61 | } | ||
62 | |||
63 | { | ||
64 | + VCVTT_HS 111 1 1110 0 . 11 1111 ... 1 1110 0 0 . 0 ... 1 @1op_nosz | ||
65 | + | ||
66 | VMINNMA 111 1 1110 0 . 11 1111 ... 1 1110 1 0 . 0 ... 1 @vmaxnma size=1 | ||
67 | VSHLL_TU 111 1 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_b | ||
68 | VSHLL_TU 111 1 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
69 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
70 | index XXXXXXX..XXXXXXX 100644 | ||
71 | --- a/target/arm/mve_helper.c | ||
72 | +++ b/target/arm/mve_helper.c | ||
73 | @@ -XXX,XX +XXX,XX @@ DO_VCVT_RMODE(vcvt_rm_sh, 2, uint16_t, helper_vfp_toshh) | ||
74 | DO_VCVT_RMODE(vcvt_rm_uh, 2, uint16_t, helper_vfp_touhh) | ||
75 | DO_VCVT_RMODE(vcvt_rm_ss, 4, uint32_t, helper_vfp_tosls) | ||
76 | DO_VCVT_RMODE(vcvt_rm_us, 4, uint32_t, helper_vfp_touls) | ||
77 | + | ||
78 | +/* | ||
79 | + * VCVT between halfprec and singleprec. As usual for halfprec | ||
80 | + * conversions, FZ16 is ignored and AHP is observed. | ||
81 | + */ | ||
82 | +static void do_vcvt_sh(CPUARMState *env, void *vd, void *vm, int top) | ||
83 | +{ | ||
84 | + uint16_t *d = vd; | ||
85 | + uint32_t *m = vm; | ||
86 | + uint16_t r; | ||
87 | + uint16_t mask = mve_element_mask(env); | ||
88 | + bool ieee = !(env->vfp.xregs[ARM_VFP_FPSCR] & FPCR_AHP); | ||
89 | + unsigned e; | ||
90 | + float_status *fpst; | ||
91 | + float_status scratch_fpst; | ||
92 | + float_status *base_fpst = &env->vfp.standard_fp_status; | ||
93 | + bool old_fz = get_flush_to_zero(base_fpst); | ||
94 | + set_flush_to_zero(false, base_fpst); | ||
95 | + for (e = 0; e < 16 / 4; e++, mask >>= 4) { | ||
96 | + if ((mask & MAKE_64BIT_MASK(0, 4)) == 0) { | ||
97 | + continue; | ||
98 | + } | ||
99 | + fpst = base_fpst; | ||
100 | + if (!(mask & 1)) { | ||
101 | + /* We need the result but without updating flags */ | ||
102 | + scratch_fpst = *fpst; | ||
103 | + fpst = &scratch_fpst; | ||
104 | + } | ||
105 | + r = float32_to_float16(m[H4(e)], ieee, fpst); | ||
106 | + mergemask(&d[H2(e * 2 + top)], r, mask >> (top * 2)); | ||
107 | + } | ||
108 | + set_flush_to_zero(old_fz, base_fpst); | ||
109 | + mve_advance_vpt(env); | ||
110 | +} | ||
111 | + | ||
112 | +static void do_vcvt_hs(CPUARMState *env, void *vd, void *vm, int top) | ||
113 | +{ | ||
114 | + uint32_t *d = vd; | ||
115 | + uint16_t *m = vm; | ||
116 | + uint32_t r; | ||
117 | + uint16_t mask = mve_element_mask(env); | ||
118 | + bool ieee = !(env->vfp.xregs[ARM_VFP_FPSCR] & FPCR_AHP); | ||
119 | + unsigned e; | ||
120 | + float_status *fpst; | ||
121 | + float_status scratch_fpst; | ||
122 | + float_status *base_fpst = &env->vfp.standard_fp_status; | ||
123 | + bool old_fiz = get_flush_inputs_to_zero(base_fpst); | ||
124 | + set_flush_inputs_to_zero(false, base_fpst); | ||
125 | + for (e = 0; e < 16 / 4; e++, mask >>= 4) { | ||
126 | + if ((mask & MAKE_64BIT_MASK(0, 4)) == 0) { | ||
127 | + continue; | ||
128 | + } | ||
129 | + fpst = base_fpst; | ||
130 | + if (!(mask & (1 << (top * 2)))) { | ||
131 | + /* We need the result but without updating flags */ | ||
132 | + scratch_fpst = *fpst; | ||
133 | + fpst = &scratch_fpst; | ||
134 | + } | ||
135 | + r = float16_to_float32(m[H2(e * 2 + top)], ieee, fpst); | ||
136 | + mergemask(&d[H4(e)], r, mask); | ||
137 | + } | ||
138 | + set_flush_inputs_to_zero(old_fiz, base_fpst); | ||
139 | + mve_advance_vpt(env); | ||
140 | +} | ||
141 | + | ||
142 | +void HELPER(mve_vcvtb_sh)(CPUARMState *env, void *vd, void *vm) | ||
143 | +{ | ||
144 | + do_vcvt_sh(env, vd, vm, 0); | ||
145 | +} | ||
146 | +void HELPER(mve_vcvtt_sh)(CPUARMState *env, void *vd, void *vm) | ||
147 | +{ | ||
148 | + do_vcvt_sh(env, vd, vm, 1); | ||
149 | +} | ||
150 | +void HELPER(mve_vcvtb_hs)(CPUARMState *env, void *vd, void *vm) | ||
151 | +{ | ||
152 | + do_vcvt_hs(env, vd, vm, 0); | ||
153 | +} | ||
154 | +void HELPER(mve_vcvtt_hs)(CPUARMState *env, void *vd, void *vm) | ||
155 | +{ | ||
156 | + do_vcvt_hs(env, vd, vm, 1); | ||
157 | +} | ||
158 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
159 | index XXXXXXX..XXXXXXX 100644 | ||
160 | --- a/target/arm/translate-mve.c | ||
161 | +++ b/target/arm/translate-mve.c | ||
162 | @@ -XXX,XX +XXX,XX @@ DO_VCVT_RMODE(VCVTPU, FPROUNDING_POSINF, true) | ||
163 | DO_VCVT_RMODE(VCVTMS, FPROUNDING_NEGINF, false) | ||
164 | DO_VCVT_RMODE(VCVTMU, FPROUNDING_NEGINF, true) | ||
165 | |||
166 | +#define DO_VCVT_SH(INSN, FN) \ | ||
167 | + static bool trans_##INSN(DisasContext *s, arg_1op *a) \ | ||
168 | + { \ | ||
169 | + if (!dc_isar_feature(aa32_mve_fp, s)) { \ | ||
170 | + return false; \ | ||
171 | + } \ | ||
172 | + return do_1op(s, a, gen_helper_mve_##FN); \ | ||
173 | + } \ | ||
174 | + | ||
175 | +DO_VCVT_SH(VCVTB_SH, vcvtb_sh) | ||
176 | +DO_VCVT_SH(VCVTT_SH, vcvtt_sh) | ||
177 | +DO_VCVT_SH(VCVTB_HS, vcvtb_hs) | ||
178 | +DO_VCVT_SH(VCVTT_HS, vcvtt_hs) | ||
179 | + | ||
180 | /* Narrowing moves: only size 0 and 1 are valid */ | ||
181 | #define DO_VMOVN(INSN, FN) \ | ||
182 | static bool trans_##INSN(DisasContext *s, arg_1op *a) \ | ||
183 | -- | ||
184 | 2.20.1 | ||
185 | |||
186 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Implement the MVE VRINT insns, which round floating point inputs | ||
2 | to integer values, leaving them in floating point format. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | target/arm/helper-mve.h | 6 +++++ | ||
8 | target/arm/mve.decode | 7 ++++++ | ||
9 | target/arm/mve_helper.c | 35 +++++++++++++++++++++++++++++ | ||
10 | target/arm/translate-mve.c | 45 ++++++++++++++++++++++++++++++++++++++ | ||
11 | 4 files changed, 93 insertions(+) | ||
12 | |||
13 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/helper-mve.h | ||
16 | +++ b/target/arm/helper-mve.h | ||
17 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vcvt_sf, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
18 | DEF_HELPER_FLAGS_4(mve_vcvt_uf, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
19 | DEF_HELPER_FLAGS_4(mve_vcvt_fs, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
20 | DEF_HELPER_FLAGS_4(mve_vcvt_fu, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
21 | + | ||
22 | +DEF_HELPER_FLAGS_4(mve_vrint_rm_h, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
23 | +DEF_HELPER_FLAGS_4(mve_vrint_rm_s, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
24 | + | ||
25 | +DEF_HELPER_FLAGS_3(mve_vrintx_h, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
26 | +DEF_HELPER_FLAGS_3(mve_vrintx_s, TCG_CALL_NO_WG, void, env, ptr, ptr) | ||
27 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/arm/mve.decode | ||
30 | +++ b/target/arm/mve.decode | ||
31 | @@ -XXX,XX +XXX,XX @@ VCVTPS 1111 1111 1 . 11 .. 11 ... 000 10 0 1 . 0 ... 0 @1op | ||
32 | VCVTPU 1111 1111 1 . 11 .. 11 ... 000 10 1 1 . 0 ... 0 @1op | ||
33 | VCVTMS 1111 1111 1 . 11 .. 11 ... 000 11 0 1 . 0 ... 0 @1op | ||
34 | VCVTMU 1111 1111 1 . 11 .. 11 ... 000 11 1 1 . 0 ... 0 @1op | ||
35 | + | ||
36 | +VRINTN 1111 1111 1 . 11 .. 10 ... 001 000 1 . 0 ... 0 @1op | ||
37 | +VRINTX 1111 1111 1 . 11 .. 10 ... 001 001 1 . 0 ... 0 @1op | ||
38 | +VRINTA 1111 1111 1 . 11 .. 10 ... 001 010 1 . 0 ... 0 @1op | ||
39 | +VRINTZ 1111 1111 1 . 11 .. 10 ... 001 011 1 . 0 ... 0 @1op | ||
40 | +VRINTM 1111 1111 1 . 11 .. 10 ... 001 101 1 . 0 ... 0 @1op | ||
41 | +VRINTP 1111 1111 1 . 11 .. 10 ... 001 111 1 . 0 ... 0 @1op | ||
42 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/target/arm/mve_helper.c | ||
45 | +++ b/target/arm/mve_helper.c | ||
46 | @@ -XXX,XX +XXX,XX @@ DO_VCVT_RMODE(vcvt_rm_uh, 2, uint16_t, helper_vfp_touhh) | ||
47 | DO_VCVT_RMODE(vcvt_rm_ss, 4, uint32_t, helper_vfp_tosls) | ||
48 | DO_VCVT_RMODE(vcvt_rm_us, 4, uint32_t, helper_vfp_touls) | ||
49 | |||
50 | +#define DO_VRINT_RM_H(M, F, S) helper_rinth(M, S) | ||
51 | +#define DO_VRINT_RM_S(M, F, S) helper_rints(M, S) | ||
52 | + | ||
53 | +DO_VCVT_RMODE(vrint_rm_h, 2, uint16_t, DO_VRINT_RM_H) | ||
54 | +DO_VCVT_RMODE(vrint_rm_s, 4, uint32_t, DO_VRINT_RM_S) | ||
55 | + | ||
56 | /* | ||
57 | * VCVT between halfprec and singleprec. As usual for halfprec | ||
58 | * conversions, FZ16 is ignored and AHP is observed. | ||
59 | @@ -XXX,XX +XXX,XX @@ void HELPER(mve_vcvtt_hs)(CPUARMState *env, void *vd, void *vm) | ||
60 | { | ||
61 | do_vcvt_hs(env, vd, vm, 1); | ||
62 | } | ||
63 | + | ||
64 | +#define DO_1OP_FP(OP, ESIZE, TYPE, FN) \ | ||
65 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, void *vm) \ | ||
66 | + { \ | ||
67 | + TYPE *d = vd, *m = vm; \ | ||
68 | + TYPE r; \ | ||
69 | + uint16_t mask = mve_element_mask(env); \ | ||
70 | + unsigned e; \ | ||
71 | + float_status *fpst; \ | ||
72 | + float_status scratch_fpst; \ | ||
73 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
74 | + if ((mask & MAKE_64BIT_MASK(0, ESIZE)) == 0) { \ | ||
75 | + continue; \ | ||
76 | + } \ | ||
77 | + fpst = (ESIZE == 2) ? &env->vfp.standard_fp_status_f16 : \ | ||
78 | + &env->vfp.standard_fp_status; \ | ||
79 | + if (!(mask & 1)) { \ | ||
80 | + /* We need the result but without updating flags */ \ | ||
81 | + scratch_fpst = *fpst; \ | ||
82 | + fpst = &scratch_fpst; \ | ||
83 | + } \ | ||
84 | + r = FN(m[H##ESIZE(e)], fpst); \ | ||
85 | + mergemask(&d[H##ESIZE(e)], r, mask); \ | ||
86 | + } \ | ||
87 | + mve_advance_vpt(env); \ | ||
88 | + } | ||
89 | + | ||
90 | +DO_1OP_FP(vrintx_h, 2, float16, float16_round_to_int) | ||
91 | +DO_1OP_FP(vrintx_s, 4, float32, float32_round_to_int) | ||
92 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
93 | index XXXXXXX..XXXXXXX 100644 | ||
94 | --- a/target/arm/translate-mve.c | ||
95 | +++ b/target/arm/translate-mve.c | ||
96 | @@ -XXX,XX +XXX,XX @@ DO_VCVT_SH(VCVTT_SH, vcvtt_sh) | ||
97 | DO_VCVT_SH(VCVTB_HS, vcvtb_hs) | ||
98 | DO_VCVT_SH(VCVTT_HS, vcvtt_hs) | ||
99 | |||
100 | +#define DO_VRINT(INSN, RMODE) \ | ||
101 | + static void gen_##INSN##h(TCGv_ptr env, TCGv_ptr qd, TCGv_ptr qm) \ | ||
102 | + { \ | ||
103 | + gen_helper_mve_vrint_rm_h(env, qd, qm, \ | ||
104 | + tcg_constant_i32(arm_rmode_to_sf(RMODE))); \ | ||
105 | + } \ | ||
106 | + static void gen_##INSN##s(TCGv_ptr env, TCGv_ptr qd, TCGv_ptr qm) \ | ||
107 | + { \ | ||
108 | + gen_helper_mve_vrint_rm_s(env, qd, qm, \ | ||
109 | + tcg_constant_i32(arm_rmode_to_sf(RMODE))); \ | ||
110 | + } \ | ||
111 | + static bool trans_##INSN(DisasContext *s, arg_1op *a) \ | ||
112 | + { \ | ||
113 | + static MVEGenOneOpFn * const fns[] = { \ | ||
114 | + NULL, \ | ||
115 | + gen_##INSN##h, \ | ||
116 | + gen_##INSN##s, \ | ||
117 | + NULL, \ | ||
118 | + }; \ | ||
119 | + if (!dc_isar_feature(aa32_mve_fp, s)) { \ | ||
120 | + return false; \ | ||
121 | + } \ | ||
122 | + return do_1op(s, a, fns[a->size]); \ | ||
123 | + } | ||
124 | + | ||
125 | +DO_VRINT(VRINTN, FPROUNDING_TIEEVEN) | ||
126 | +DO_VRINT(VRINTA, FPROUNDING_TIEAWAY) | ||
127 | +DO_VRINT(VRINTZ, FPROUNDING_ZERO) | ||
128 | +DO_VRINT(VRINTM, FPROUNDING_NEGINF) | ||
129 | +DO_VRINT(VRINTP, FPROUNDING_POSINF) | ||
130 | + | ||
131 | +static bool trans_VRINTX(DisasContext *s, arg_1op *a) | ||
132 | +{ | ||
133 | + static MVEGenOneOpFn * const fns[] = { | ||
134 | + NULL, | ||
135 | + gen_helper_mve_vrintx_h, | ||
136 | + gen_helper_mve_vrintx_s, | ||
137 | + NULL, | ||
138 | + }; | ||
139 | + if (!dc_isar_feature(aa32_mve_fp, s)) { | ||
140 | + return false; | ||
141 | + } | ||
142 | + return do_1op(s, a, fns[a->size]); | ||
143 | +} | ||
144 | + | ||
145 | /* Narrowing moves: only size 0 and 1 are valid */ | ||
146 | #define DO_VMOVN(INSN, FN) \ | ||
147 | static bool trans_##INSN(DisasContext *s, arg_1op *a) \ | ||
148 | -- | ||
149 | 2.20.1 | ||
150 | |||
151 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | We now have a complete MVE emulation, so we can enable it in our | ||
2 | Cortex-M55 model by setting the ID registers to match those of a | ||
3 | Cortex-M55 with full MVE support. | ||
4 | 1 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | --- | ||
8 | target/arm/cpu_tcg.c | 7 ++----- | ||
9 | 1 file changed, 2 insertions(+), 5 deletions(-) | ||
10 | |||
11 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/arm/cpu_tcg.c | ||
14 | +++ b/target/arm/cpu_tcg.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static void cortex_m55_initfn(Object *obj) | ||
16 | cpu->revidr = 0; | ||
17 | cpu->pmsav7_dregion = 16; | ||
18 | cpu->sau_sregion = 8; | ||
19 | - /* | ||
20 | - * These are the MVFR* values for the FPU, no MVE configuration; | ||
21 | - * we will update them later when we implement MVE | ||
22 | - */ | ||
23 | + /* These are the MVFR* values for the FPU + full MVE configuration */ | ||
24 | cpu->isar.mvfr0 = 0x10110221; | ||
25 | - cpu->isar.mvfr1 = 0x12100011; | ||
26 | + cpu->isar.mvfr1 = 0x12100211; | ||
27 | cpu->isar.mvfr2 = 0x00000040; | ||
28 | cpu->isar.id_pfr0 = 0x20000030; | ||
29 | cpu->isar.id_pfr1 = 0x00000230; | ||
30 | -- | ||
31 | 2.20.1 | ||
32 | |||
33 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Shuuichirou Ishii <ishii.shuuichir@fujitsu.com> | ||
2 | 1 | ||
3 | Add a definition for the Fujitsu A64FX processor. | ||
4 | |||
5 | The A64FX processor does not implement the AArch32 Execution state, | ||
6 | so there are no associated AArch32 Identification registers. | ||
7 | |||
8 | For SVE, the A64FX processor supports only 128,256 and 512bit vector | ||
9 | lengths. | ||
10 | |||
11 | The Identification register values are defined based on the FX700, | ||
12 | and have been tested and confirmed. | ||
13 | |||
14 | Signed-off-by: Shuuichirou Ishii <ishii.shuuichir@fujitsu.com> | ||
15 | Reviewed-by: Andrew Jones <drjones@redhat.com> | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | --- | ||
18 | target/arm/cpu64.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++ | ||
19 | 1 file changed, 48 insertions(+) | ||
20 | |||
21 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/target/arm/cpu64.c | ||
24 | +++ b/target/arm/cpu64.c | ||
25 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
26 | cpu_max_set_sve_max_vq, NULL, NULL); | ||
27 | } | ||
28 | |||
29 | +static void aarch64_a64fx_initfn(Object *obj) | ||
30 | +{ | ||
31 | + ARMCPU *cpu = ARM_CPU(obj); | ||
32 | + | ||
33 | + cpu->dtb_compatible = "arm,a64fx"; | ||
34 | + set_feature(&cpu->env, ARM_FEATURE_V8); | ||
35 | + set_feature(&cpu->env, ARM_FEATURE_NEON); | ||
36 | + set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); | ||
37 | + set_feature(&cpu->env, ARM_FEATURE_AARCH64); | ||
38 | + set_feature(&cpu->env, ARM_FEATURE_EL2); | ||
39 | + set_feature(&cpu->env, ARM_FEATURE_EL3); | ||
40 | + set_feature(&cpu->env, ARM_FEATURE_PMU); | ||
41 | + cpu->midr = 0x461f0010; | ||
42 | + cpu->revidr = 0x00000000; | ||
43 | + cpu->ctr = 0x86668006; | ||
44 | + cpu->reset_sctlr = 0x30000180; | ||
45 | + cpu->isar.id_aa64pfr0 = 0x0000000101111111; /* No RAS Extensions */ | ||
46 | + cpu->isar.id_aa64pfr1 = 0x0000000000000000; | ||
47 | + cpu->isar.id_aa64dfr0 = 0x0000000010305408; | ||
48 | + cpu->isar.id_aa64dfr1 = 0x0000000000000000; | ||
49 | + cpu->id_aa64afr0 = 0x0000000000000000; | ||
50 | + cpu->id_aa64afr1 = 0x0000000000000000; | ||
51 | + cpu->isar.id_aa64mmfr0 = 0x0000000000001122; | ||
52 | + cpu->isar.id_aa64mmfr1 = 0x0000000011212100; | ||
53 | + cpu->isar.id_aa64mmfr2 = 0x0000000000001011; | ||
54 | + cpu->isar.id_aa64isar0 = 0x0000000010211120; | ||
55 | + cpu->isar.id_aa64isar1 = 0x0000000000010001; | ||
56 | + cpu->isar.id_aa64zfr0 = 0x0000000000000000; | ||
57 | + cpu->clidr = 0x0000000080000023; | ||
58 | + cpu->ccsidr[0] = 0x7007e01c; /* 64KB L1 dcache */ | ||
59 | + cpu->ccsidr[1] = 0x2007e01c; /* 64KB L1 icache */ | ||
60 | + cpu->ccsidr[2] = 0x70ffe07c; /* 8MB L2 cache */ | ||
61 | + cpu->dcz_blocksize = 6; /* 256 bytes */ | ||
62 | + cpu->gic_num_lrs = 4; | ||
63 | + cpu->gic_vpribits = 5; | ||
64 | + cpu->gic_vprebits = 5; | ||
65 | + | ||
66 | + /* Suppport of A64FX's vector length are 128,256 and 512bit only */ | ||
67 | + aarch64_add_sve_properties(obj); | ||
68 | + bitmap_zero(cpu->sve_vq_supported, ARM_MAX_VQ); | ||
69 | + set_bit(0, cpu->sve_vq_supported); /* 128bit */ | ||
70 | + set_bit(1, cpu->sve_vq_supported); /* 256bit */ | ||
71 | + set_bit(3, cpu->sve_vq_supported); /* 512bit */ | ||
72 | + | ||
73 | + /* TODO: Add A64FX specific HPC extension registers */ | ||
74 | +} | ||
75 | + | ||
76 | static const ARMCPUInfo aarch64_cpus[] = { | ||
77 | { .name = "cortex-a57", .initfn = aarch64_a57_initfn }, | ||
78 | { .name = "cortex-a53", .initfn = aarch64_a53_initfn }, | ||
79 | { .name = "cortex-a72", .initfn = aarch64_a72_initfn }, | ||
80 | + { .name = "a64fx", .initfn = aarch64_a64fx_initfn }, | ||
81 | { .name = "max", .initfn = aarch64_max_initfn }, | ||
82 | }; | ||
83 | |||
84 | -- | ||
85 | 2.20.1 | ||
86 | |||
87 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Shuuichirou Ishii <ishii.shuuichir@fujitsu.com> | ||
2 | 1 | ||
3 | Add -cpu a64fx to use A64FX processor when -machine virt option is | ||
4 | specified. In addition, add a64fx to the Supported guest CPU types | ||
5 | in the virt.rst document. | ||
6 | |||
7 | Signed-off-by: Shuuichirou Ishii <ishii.shuuichir@fujitsu.com> | ||
8 | Reviewed-by: Andrew Jones <drjones@redhat.com> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | docs/system/arm/virt.rst | 1 + | ||
12 | hw/arm/virt.c | 1 + | ||
13 | 2 files changed, 2 insertions(+) | ||
14 | |||
15 | diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/docs/system/arm/virt.rst | ||
18 | +++ b/docs/system/arm/virt.rst | ||
19 | @@ -XXX,XX +XXX,XX @@ Supported guest CPU types: | ||
20 | - ``cortex-a53`` (64-bit) | ||
21 | - ``cortex-a57`` (64-bit) | ||
22 | - ``cortex-a72`` (64-bit) | ||
23 | +- ``a64fx`` (64-bit) | ||
24 | - ``host`` (with KVM only) | ||
25 | - ``max`` (same as ``host`` for KVM; best possible emulation with TCG) | ||
26 | |||
27 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/hw/arm/virt.c | ||
30 | +++ b/hw/arm/virt.c | ||
31 | @@ -XXX,XX +XXX,XX @@ static const char *valid_cpus[] = { | ||
32 | ARM_CPU_TYPE_NAME("cortex-a53"), | ||
33 | ARM_CPU_TYPE_NAME("cortex-a57"), | ||
34 | ARM_CPU_TYPE_NAME("cortex-a72"), | ||
35 | + ARM_CPU_TYPE_NAME("a64fx"), | ||
36 | ARM_CPU_TYPE_NAME("host"), | ||
37 | ARM_CPU_TYPE_NAME("max"), | ||
38 | }; | ||
39 | -- | ||
40 | 2.20.1 | ||
41 | |||
42 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Shuuichirou Ishii <ishii.shuuichir@fujitsu.com> | ||
2 | 1 | ||
3 | Add tests that the A64FX CPU model exposes the expected features. | ||
4 | |||
5 | Signed-off-by: Shuuichirou Ishii <ishii.shuuichir@fujitsu.com> | ||
6 | Reviewed-by: Andrew Jones <drjones@redhat.com> | ||
7 | [PMM: added commit message body] | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | tests/qtest/arm-cpu-features.c | 13 +++++++++++++ | ||
11 | 1 file changed, 13 insertions(+) | ||
12 | |||
13 | diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/tests/qtest/arm-cpu-features.c | ||
16 | +++ b/tests/qtest/arm-cpu-features.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion(const void *data) | ||
18 | assert_has_feature_enabled(qts, "cortex-a57", "pmu"); | ||
19 | assert_has_feature_enabled(qts, "cortex-a57", "aarch64"); | ||
20 | |||
21 | + assert_has_feature_enabled(qts, "a64fx", "pmu"); | ||
22 | + assert_has_feature_enabled(qts, "a64fx", "aarch64"); | ||
23 | + /* | ||
24 | + * A64FX does not support any other vector lengths besides those | ||
25 | + * that are enabled by default(128bit, 256bits, 512bit). | ||
26 | + */ | ||
27 | + assert_has_feature_enabled(qts, "a64fx", "sve"); | ||
28 | + assert_sve_vls(qts, "a64fx", 0xb, NULL); | ||
29 | + assert_error(qts, "a64fx", "cannot enable sve384", | ||
30 | + "{ 'sve384': true }"); | ||
31 | + assert_error(qts, "a64fx", "cannot enable sve640", | ||
32 | + "{ 'sve640': true }"); | ||
33 | + | ||
34 | sve_tests_default(qts, "max"); | ||
35 | pauth_tests_default(qts, "max"); | ||
36 | |||
37 | -- | ||
38 | 2.20.1 | ||
39 | |||
40 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | There's no particular reason why the NVIC should be owning the | ||
2 | SysTick device objects; move them into the ARMv7M container object | ||
3 | instead, as part of consolidating the "create the devices which are | ||
4 | built into an M-profile CPU and map them into their architected | ||
5 | locations in the address space" work into one place. | ||
6 | 1 | ||
7 | This involves temporarily creating a duplicate copy of the | ||
8 | nvic_sysreg_ns_ops struct and its read/write functions (renamed as | ||
9 | v7m_sysreg_ns_*), but we will delete the NVIC's copy of this code in | ||
10 | a subsequent patch. | ||
11 | |||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Acked-by: Alistair Francis <alistair.francis@wdc.com> | ||
14 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
15 | Message-id: 20210812093356.1946-3-peter.maydell@linaro.org | ||
16 | --- | ||
17 | include/hw/arm/armv7m.h | 12 ++++ | ||
18 | include/hw/intc/armv7m_nvic.h | 4 -- | ||
19 | hw/arm/armv7m.c | 125 ++++++++++++++++++++++++++++++++++ | ||
20 | hw/intc/armv7m_nvic.c | 73 -------------------- | ||
21 | 4 files changed, 137 insertions(+), 77 deletions(-) | ||
22 | |||
23 | diff --git a/include/hw/arm/armv7m.h b/include/hw/arm/armv7m.h | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/include/hw/arm/armv7m.h | ||
26 | +++ b/include/hw/arm/armv7m.h | ||
27 | @@ -XXX,XX +XXX,XX @@ struct ARMv7MState { | ||
28 | BitBandState bitband[ARMV7M_NUM_BITBANDS]; | ||
29 | ARMCPU *cpu; | ||
30 | ARMv7MRAS ras; | ||
31 | + SysTickState systick[M_REG_NUM_BANKS]; | ||
32 | |||
33 | /* MemoryRegion we pass to the CPU, with our devices layered on | ||
34 | * top of the ones the board provides in board_memory. | ||
35 | */ | ||
36 | MemoryRegion container; | ||
37 | + /* | ||
38 | + * MemoryRegion which passes the transaction to either the S or the | ||
39 | + * NS systick device depending on the transaction attributes | ||
40 | + */ | ||
41 | + MemoryRegion systickmem; | ||
42 | + /* | ||
43 | + * MemoryRegion which enforces the S/NS handling of the systick | ||
44 | + * device NS alias region and passes the transaction to the | ||
45 | + * NS systick device if appropriate. | ||
46 | + */ | ||
47 | + MemoryRegion systick_ns_mem; | ||
48 | |||
49 | /* Properties */ | ||
50 | char *cpu_type; | ||
51 | diff --git a/include/hw/intc/armv7m_nvic.h b/include/hw/intc/armv7m_nvic.h | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/include/hw/intc/armv7m_nvic.h | ||
54 | +++ b/include/hw/intc/armv7m_nvic.h | ||
55 | @@ -XXX,XX +XXX,XX @@ struct NVICState { | ||
56 | |||
57 | MemoryRegion sysregmem; | ||
58 | MemoryRegion sysreg_ns_mem; | ||
59 | - MemoryRegion systickmem; | ||
60 | - MemoryRegion systick_ns_mem; | ||
61 | MemoryRegion container; | ||
62 | MemoryRegion defaultmem; | ||
63 | |||
64 | uint32_t num_irq; | ||
65 | qemu_irq excpout; | ||
66 | qemu_irq sysresetreq; | ||
67 | - | ||
68 | - SysTickState systick[M_REG_NUM_BANKS]; | ||
69 | }; | ||
70 | |||
71 | #endif | ||
72 | diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c | ||
73 | index XXXXXXX..XXXXXXX 100644 | ||
74 | --- a/hw/arm/armv7m.c | ||
75 | +++ b/hw/arm/armv7m.c | ||
76 | @@ -XXX,XX +XXX,XX @@ static const hwaddr bitband_output_addr[ARMV7M_NUM_BITBANDS] = { | ||
77 | 0x22000000, 0x42000000 | ||
78 | }; | ||
79 | |||
80 | +static MemTxResult v7m_sysreg_ns_write(void *opaque, hwaddr addr, | ||
81 | + uint64_t value, unsigned size, | ||
82 | + MemTxAttrs attrs) | ||
83 | +{ | ||
84 | + MemoryRegion *mr = opaque; | ||
85 | + | ||
86 | + if (attrs.secure) { | ||
87 | + /* S accesses to the alias act like NS accesses to the real region */ | ||
88 | + attrs.secure = 0; | ||
89 | + return memory_region_dispatch_write(mr, addr, value, | ||
90 | + size_memop(size) | MO_TE, attrs); | ||
91 | + } else { | ||
92 | + /* NS attrs are RAZ/WI for privileged, and BusFault for user */ | ||
93 | + if (attrs.user) { | ||
94 | + return MEMTX_ERROR; | ||
95 | + } | ||
96 | + return MEMTX_OK; | ||
97 | + } | ||
98 | +} | ||
99 | + | ||
100 | +static MemTxResult v7m_sysreg_ns_read(void *opaque, hwaddr addr, | ||
101 | + uint64_t *data, unsigned size, | ||
102 | + MemTxAttrs attrs) | ||
103 | +{ | ||
104 | + MemoryRegion *mr = opaque; | ||
105 | + | ||
106 | + if (attrs.secure) { | ||
107 | + /* S accesses to the alias act like NS accesses to the real region */ | ||
108 | + attrs.secure = 0; | ||
109 | + return memory_region_dispatch_read(mr, addr, data, | ||
110 | + size_memop(size) | MO_TE, attrs); | ||
111 | + } else { | ||
112 | + /* NS attrs are RAZ/WI for privileged, and BusFault for user */ | ||
113 | + if (attrs.user) { | ||
114 | + return MEMTX_ERROR; | ||
115 | + } | ||
116 | + *data = 0; | ||
117 | + return MEMTX_OK; | ||
118 | + } | ||
119 | +} | ||
120 | + | ||
121 | +static const MemoryRegionOps v7m_sysreg_ns_ops = { | ||
122 | + .read_with_attrs = v7m_sysreg_ns_read, | ||
123 | + .write_with_attrs = v7m_sysreg_ns_write, | ||
124 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
125 | +}; | ||
126 | + | ||
127 | +static MemTxResult v7m_systick_write(void *opaque, hwaddr addr, | ||
128 | + uint64_t value, unsigned size, | ||
129 | + MemTxAttrs attrs) | ||
130 | +{ | ||
131 | + ARMv7MState *s = opaque; | ||
132 | + MemoryRegion *mr; | ||
133 | + | ||
134 | + /* Direct the access to the correct systick */ | ||
135 | + mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->systick[attrs.secure]), 0); | ||
136 | + return memory_region_dispatch_write(mr, addr, value, | ||
137 | + size_memop(size) | MO_TE, attrs); | ||
138 | +} | ||
139 | + | ||
140 | +static MemTxResult v7m_systick_read(void *opaque, hwaddr addr, | ||
141 | + uint64_t *data, unsigned size, | ||
142 | + MemTxAttrs attrs) | ||
143 | +{ | ||
144 | + ARMv7MState *s = opaque; | ||
145 | + MemoryRegion *mr; | ||
146 | + | ||
147 | + /* Direct the access to the correct systick */ | ||
148 | + mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->systick[attrs.secure]), 0); | ||
149 | + return memory_region_dispatch_read(mr, addr, data, size_memop(size) | MO_TE, | ||
150 | + attrs); | ||
151 | +} | ||
152 | + | ||
153 | +static const MemoryRegionOps v7m_systick_ops = { | ||
154 | + .read_with_attrs = v7m_systick_read, | ||
155 | + .write_with_attrs = v7m_systick_write, | ||
156 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
157 | +}; | ||
158 | + | ||
159 | static void armv7m_instance_init(Object *obj) | ||
160 | { | ||
161 | ARMv7MState *s = ARMV7M(obj); | ||
162 | @@ -XXX,XX +XXX,XX @@ static void armv7m_instance_init(Object *obj) | ||
163 | object_property_add_alias(obj, "num-irq", | ||
164 | OBJECT(&s->nvic), "num-irq"); | ||
165 | |||
166 | + object_initialize_child(obj, "systick-reg-ns", &s->systick[M_REG_NS], | ||
167 | + TYPE_SYSTICK); | ||
168 | + /* | ||
169 | + * We can't initialize the secure systick here, as we don't know | ||
170 | + * yet if we need it. | ||
171 | + */ | ||
172 | + | ||
173 | for (i = 0; i < ARRAY_SIZE(s->bitband); i++) { | ||
174 | object_initialize_child(obj, "bitband[*]", &s->bitband[i], | ||
175 | TYPE_BITBAND); | ||
176 | @@ -XXX,XX +XXX,XX @@ static void armv7m_realize(DeviceState *dev, Error **errp) | ||
177 | memory_region_add_subregion(&s->container, 0xe0000000, | ||
178 | sysbus_mmio_get_region(sbd, 0)); | ||
179 | |||
180 | + /* Create and map the systick devices */ | ||
181 | + if (!sysbus_realize(SYS_BUS_DEVICE(&s->systick[M_REG_NS]), errp)) { | ||
182 | + return; | ||
183 | + } | ||
184 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->systick[M_REG_NS]), 0, | ||
185 | + qdev_get_gpio_in_named(DEVICE(&s->nvic), | ||
186 | + "systick-trigger", M_REG_NS)); | ||
187 | + | ||
188 | + if (arm_feature(&s->cpu->env, ARM_FEATURE_M_SECURITY)) { | ||
189 | + /* | ||
190 | + * We couldn't init the secure systick device in instance_init | ||
191 | + * as we didn't know then if the CPU had the security extensions; | ||
192 | + * so we have to do it here. | ||
193 | + */ | ||
194 | + object_initialize_child(OBJECT(dev), "systick-reg-s", | ||
195 | + &s->systick[M_REG_S], TYPE_SYSTICK); | ||
196 | + | ||
197 | + if (!sysbus_realize(SYS_BUS_DEVICE(&s->systick[M_REG_S]), errp)) { | ||
198 | + return; | ||
199 | + } | ||
200 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->systick[M_REG_S]), 0, | ||
201 | + qdev_get_gpio_in_named(DEVICE(&s->nvic), | ||
202 | + "systick-trigger", M_REG_S)); | ||
203 | + } | ||
204 | + | ||
205 | + memory_region_init_io(&s->systickmem, OBJECT(s), | ||
206 | + &v7m_systick_ops, s, | ||
207 | + "v7m_systick", 0xe0); | ||
208 | + | ||
209 | + memory_region_add_subregion_overlap(&s->container, 0xe000e010, | ||
210 | + &s->systickmem, 1); | ||
211 | + if (arm_feature(&s->cpu->env, ARM_FEATURE_V8)) { | ||
212 | + memory_region_init_io(&s->systick_ns_mem, OBJECT(s), | ||
213 | + &v7m_sysreg_ns_ops, &s->systickmem, | ||
214 | + "v7m_systick_ns", 0xe0); | ||
215 | + memory_region_add_subregion_overlap(&s->container, 0xe002e010, | ||
216 | + &s->systick_ns_mem, 1); | ||
217 | + } | ||
218 | + | ||
219 | /* If the CPU has RAS support, create the RAS register block */ | ||
220 | if (cpu_isar_feature(aa32_ras, s->cpu)) { | ||
221 | object_initialize_child(OBJECT(dev), "armv7m-ras", | ||
222 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
223 | index XXXXXXX..XXXXXXX 100644 | ||
224 | --- a/hw/intc/armv7m_nvic.c | ||
225 | +++ b/hw/intc/armv7m_nvic.c | ||
226 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps nvic_sysreg_ns_ops = { | ||
227 | .endianness = DEVICE_NATIVE_ENDIAN, | ||
228 | }; | ||
229 | |||
230 | -static MemTxResult nvic_systick_write(void *opaque, hwaddr addr, | ||
231 | - uint64_t value, unsigned size, | ||
232 | - MemTxAttrs attrs) | ||
233 | -{ | ||
234 | - NVICState *s = opaque; | ||
235 | - MemoryRegion *mr; | ||
236 | - | ||
237 | - /* Direct the access to the correct systick */ | ||
238 | - mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->systick[attrs.secure]), 0); | ||
239 | - return memory_region_dispatch_write(mr, addr, value, | ||
240 | - size_memop(size) | MO_TE, attrs); | ||
241 | -} | ||
242 | - | ||
243 | -static MemTxResult nvic_systick_read(void *opaque, hwaddr addr, | ||
244 | - uint64_t *data, unsigned size, | ||
245 | - MemTxAttrs attrs) | ||
246 | -{ | ||
247 | - NVICState *s = opaque; | ||
248 | - MemoryRegion *mr; | ||
249 | - | ||
250 | - /* Direct the access to the correct systick */ | ||
251 | - mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->systick[attrs.secure]), 0); | ||
252 | - return memory_region_dispatch_read(mr, addr, data, size_memop(size) | MO_TE, | ||
253 | - attrs); | ||
254 | -} | ||
255 | - | ||
256 | -static const MemoryRegionOps nvic_systick_ops = { | ||
257 | - .read_with_attrs = nvic_systick_read, | ||
258 | - .write_with_attrs = nvic_systick_write, | ||
259 | - .endianness = DEVICE_NATIVE_ENDIAN, | ||
260 | -}; | ||
261 | - | ||
262 | /* | ||
263 | * Unassigned portions of the PPB space are RAZ/WI for privileged | ||
264 | * accesses, and fault for non-privileged accesses. | ||
265 | @@ -XXX,XX +XXX,XX @@ static void armv7m_nvic_realize(DeviceState *dev, Error **errp) | ||
266 | |||
267 | s->num_prio_bits = arm_feature(&s->cpu->env, ARM_FEATURE_V7) ? 8 : 2; | ||
268 | |||
269 | - if (!sysbus_realize(SYS_BUS_DEVICE(&s->systick[M_REG_NS]), errp)) { | ||
270 | - return; | ||
271 | - } | ||
272 | - sysbus_connect_irq(SYS_BUS_DEVICE(&s->systick[M_REG_NS]), 0, | ||
273 | - qdev_get_gpio_in_named(dev, "systick-trigger", | ||
274 | - M_REG_NS)); | ||
275 | - | ||
276 | - if (arm_feature(&s->cpu->env, ARM_FEATURE_M_SECURITY)) { | ||
277 | - /* We couldn't init the secure systick device in instance_init | ||
278 | - * as we didn't know then if the CPU had the security extensions; | ||
279 | - * so we have to do it here. | ||
280 | - */ | ||
281 | - object_initialize_child(OBJECT(dev), "systick-reg-s", | ||
282 | - &s->systick[M_REG_S], TYPE_SYSTICK); | ||
283 | - | ||
284 | - if (!sysbus_realize(SYS_BUS_DEVICE(&s->systick[M_REG_S]), errp)) { | ||
285 | - return; | ||
286 | - } | ||
287 | - sysbus_connect_irq(SYS_BUS_DEVICE(&s->systick[M_REG_S]), 0, | ||
288 | - qdev_get_gpio_in_named(dev, "systick-trigger", | ||
289 | - M_REG_S)); | ||
290 | - } | ||
291 | - | ||
292 | /* | ||
293 | * This device provides a single sysbus memory region which | ||
294 | * represents the whole of the "System PPB" space. This is the | ||
295 | @@ -XXX,XX +XXX,XX @@ static void armv7m_nvic_realize(DeviceState *dev, Error **errp) | ||
296 | "nvic_sysregs", 0x1000); | ||
297 | memory_region_add_subregion(&s->container, 0xe000, &s->sysregmem); | ||
298 | |||
299 | - memory_region_init_io(&s->systickmem, OBJECT(s), | ||
300 | - &nvic_systick_ops, s, | ||
301 | - "nvic_systick", 0xe0); | ||
302 | - | ||
303 | - memory_region_add_subregion_overlap(&s->container, 0xe010, | ||
304 | - &s->systickmem, 1); | ||
305 | - | ||
306 | if (arm_feature(&s->cpu->env, ARM_FEATURE_V8)) { | ||
307 | memory_region_init_io(&s->sysreg_ns_mem, OBJECT(s), | ||
308 | &nvic_sysreg_ns_ops, &s->sysregmem, | ||
309 | "nvic_sysregs_ns", 0x1000); | ||
310 | memory_region_add_subregion(&s->container, 0x2e000, &s->sysreg_ns_mem); | ||
311 | - memory_region_init_io(&s->systick_ns_mem, OBJECT(s), | ||
312 | - &nvic_sysreg_ns_ops, &s->systickmem, | ||
313 | - "nvic_systick_ns", 0xe0); | ||
314 | - memory_region_add_subregion_overlap(&s->container, 0x2e010, | ||
315 | - &s->systick_ns_mem, 1); | ||
316 | } | ||
317 | |||
318 | sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->container); | ||
319 | @@ -XXX,XX +XXX,XX @@ static void armv7m_nvic_instance_init(Object *obj) | ||
320 | NVICState *nvic = NVIC(obj); | ||
321 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
322 | |||
323 | - object_initialize_child(obj, "systick-reg-ns", &nvic->systick[M_REG_NS], | ||
324 | - TYPE_SYSTICK); | ||
325 | - /* We can't initialize the secure systick here, as we don't know | ||
326 | - * yet if we need it. | ||
327 | - */ | ||
328 | - | ||
329 | sysbus_init_irq(sbd, &nvic->excpout); | ||
330 | qdev_init_gpio_out_named(dev, &nvic->sysresetreq, "SYSRESETREQ", 1); | ||
331 | qdev_init_gpio_in_named(dev, nvic_systick_trigger, "systick-trigger", | ||
332 | -- | ||
333 | 2.20.1 | ||
334 | |||
335 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Instead of having the NVIC device provide a single sysbus memory | ||
2 | region covering the whole of the "System PPB" space, which implements | ||
3 | the default behaviour for unimplemented ranges and provides the NS | ||
4 | alias window to the sysregs as well as the main sysreg MR, move this | ||
5 | handling to the container armv7m device. The NVIC now provides a | ||
6 | single memory region which just implements the system registers. | ||
7 | This consolidates all the handling of "map various devices in the | ||
8 | PPB" into the armv7m container where it belongs. | ||
9 | 1 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Alexandre Iooss <erdnaxe@crans.org> | ||
12 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
13 | Message-id: 20210812093356.1946-4-peter.maydell@linaro.org | ||
14 | --- | ||
15 | include/hw/arm/armv7m.h | 4 + | ||
16 | include/hw/intc/armv7m_nvic.h | 3 - | ||
17 | hw/arm/armv7m.c | 100 ++++++++++++++++++++++- | ||
18 | hw/intc/armv7m_nvic.c | 145 +--------------------------------- | ||
19 | 4 files changed, 107 insertions(+), 145 deletions(-) | ||
20 | |||
21 | diff --git a/include/hw/arm/armv7m.h b/include/hw/arm/armv7m.h | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/include/hw/arm/armv7m.h | ||
24 | +++ b/include/hw/arm/armv7m.h | ||
25 | @@ -XXX,XX +XXX,XX @@ struct ARMv7MState { | ||
26 | * NS systick device if appropriate. | ||
27 | */ | ||
28 | MemoryRegion systick_ns_mem; | ||
29 | + /* Ditto, for the sysregs region provided by the NVIC */ | ||
30 | + MemoryRegion sysreg_ns_mem; | ||
31 | + /* MR providing default PPB behaviour */ | ||
32 | + MemoryRegion defaultmem; | ||
33 | |||
34 | /* Properties */ | ||
35 | char *cpu_type; | ||
36 | diff --git a/include/hw/intc/armv7m_nvic.h b/include/hw/intc/armv7m_nvic.h | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/include/hw/intc/armv7m_nvic.h | ||
39 | +++ b/include/hw/intc/armv7m_nvic.h | ||
40 | @@ -XXX,XX +XXX,XX @@ struct NVICState { | ||
41 | int vectpending_prio; /* group prio of the exeception in vectpending */ | ||
42 | |||
43 | MemoryRegion sysregmem; | ||
44 | - MemoryRegion sysreg_ns_mem; | ||
45 | - MemoryRegion container; | ||
46 | - MemoryRegion defaultmem; | ||
47 | |||
48 | uint32_t num_irq; | ||
49 | qemu_irq excpout; | ||
50 | diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/hw/arm/armv7m.c | ||
53 | +++ b/hw/arm/armv7m.c | ||
54 | @@ -XXX,XX +XXX,XX @@ | ||
55 | #include "sysemu/reset.h" | ||
56 | #include "qemu/error-report.h" | ||
57 | #include "qemu/module.h" | ||
58 | +#include "qemu/log.h" | ||
59 | #include "target/arm/idau.h" | ||
60 | |||
61 | /* Bitbanded IO. Each word corresponds to a single bit. */ | ||
62 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps v7m_systick_ops = { | ||
63 | .endianness = DEVICE_NATIVE_ENDIAN, | ||
64 | }; | ||
65 | |||
66 | +/* | ||
67 | + * Unassigned portions of the PPB space are RAZ/WI for privileged | ||
68 | + * accesses, and fault for non-privileged accesses. | ||
69 | + */ | ||
70 | +static MemTxResult ppb_default_read(void *opaque, hwaddr addr, | ||
71 | + uint64_t *data, unsigned size, | ||
72 | + MemTxAttrs attrs) | ||
73 | +{ | ||
74 | + qemu_log_mask(LOG_UNIMP, "Read of unassigned area of PPB: offset 0x%x\n", | ||
75 | + (uint32_t)addr); | ||
76 | + if (attrs.user) { | ||
77 | + return MEMTX_ERROR; | ||
78 | + } | ||
79 | + *data = 0; | ||
80 | + return MEMTX_OK; | ||
81 | +} | ||
82 | + | ||
83 | +static MemTxResult ppb_default_write(void *opaque, hwaddr addr, | ||
84 | + uint64_t value, unsigned size, | ||
85 | + MemTxAttrs attrs) | ||
86 | +{ | ||
87 | + qemu_log_mask(LOG_UNIMP, "Write of unassigned area of PPB: offset 0x%x\n", | ||
88 | + (uint32_t)addr); | ||
89 | + if (attrs.user) { | ||
90 | + return MEMTX_ERROR; | ||
91 | + } | ||
92 | + return MEMTX_OK; | ||
93 | +} | ||
94 | + | ||
95 | +static const MemoryRegionOps ppb_default_ops = { | ||
96 | + .read_with_attrs = ppb_default_read, | ||
97 | + .write_with_attrs = ppb_default_write, | ||
98 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
99 | + .valid.min_access_size = 1, | ||
100 | + .valid.max_access_size = 8, | ||
101 | +}; | ||
102 | + | ||
103 | static void armv7m_instance_init(Object *obj) | ||
104 | { | ||
105 | ARMv7MState *s = ARMV7M(obj); | ||
106 | @@ -XXX,XX +XXX,XX @@ static void armv7m_realize(DeviceState *dev, Error **errp) | ||
107 | qdev_pass_gpios(DEVICE(&s->nvic), dev, "SYSRESETREQ"); | ||
108 | qdev_pass_gpios(DEVICE(&s->nvic), dev, "NMI"); | ||
109 | |||
110 | + /* | ||
111 | + * We map various devices into the container MR at their architected | ||
112 | + * addresses. In particular, we map everything corresponding to the | ||
113 | + * "System PPB" space. This is the range from 0xe0000000 to 0xe00fffff | ||
114 | + * and includes the NVIC, the System Control Space (system registers), | ||
115 | + * the systick timer, and for CPUs with the Security extension an NS | ||
116 | + * banked version of all of these. | ||
117 | + * | ||
118 | + * The default behaviour for unimplemented registers/ranges | ||
119 | + * (for instance the Data Watchpoint and Trace unit at 0xe0001000) | ||
120 | + * is to RAZ/WI for privileged access and BusFault for non-privileged | ||
121 | + * access. | ||
122 | + * | ||
123 | + * The NVIC and System Control Space (SCS) starts at 0xe000e000 | ||
124 | + * and looks like this: | ||
125 | + * 0x004 - ICTR | ||
126 | + * 0x010 - 0xff - systick | ||
127 | + * 0x100..0x7ec - NVIC | ||
128 | + * 0x7f0..0xcff - Reserved | ||
129 | + * 0xd00..0xd3c - SCS registers | ||
130 | + * 0xd40..0xeff - Reserved or Not implemented | ||
131 | + * 0xf00 - STIR | ||
132 | + * | ||
133 | + * Some registers within this space are banked between security states. | ||
134 | + * In v8M there is a second range 0xe002e000..0xe002efff which is the | ||
135 | + * NonSecure alias SCS; secure accesses to this behave like NS accesses | ||
136 | + * to the main SCS range, and non-secure accesses (including when | ||
137 | + * the security extension is not implemented) are RAZ/WI. | ||
138 | + * Note that both the main SCS range and the alias range are defined | ||
139 | + * to be exempt from memory attribution (R_BLJT) and so the memory | ||
140 | + * transaction attribute always matches the current CPU security | ||
141 | + * state (attrs.secure == env->v7m.secure). In the v7m_sysreg_ns_ops | ||
142 | + * wrappers we change attrs.secure to indicate the NS access; so | ||
143 | + * generally code determining which banked register to use should | ||
144 | + * use attrs.secure; code determining actual behaviour of the system | ||
145 | + * should use env->v7m.secure. | ||
146 | + * | ||
147 | + * Within the PPB space, some MRs overlap, and the priority | ||
148 | + * of overlapping regions is: | ||
149 | + * - default region (for RAZ/WI and BusFault) : -1 | ||
150 | + * - system register regions (provided by the NVIC) : 0 | ||
151 | + * - systick : 1 | ||
152 | + * This is because the systick device is a small block of registers | ||
153 | + * in the middle of the other system control registers. | ||
154 | + */ | ||
155 | + | ||
156 | + memory_region_init_io(&s->defaultmem, OBJECT(s), &ppb_default_ops, s, | ||
157 | + "nvic-default", 0x100000); | ||
158 | + memory_region_add_subregion_overlap(&s->container, 0xe0000000, | ||
159 | + &s->defaultmem, -1); | ||
160 | + | ||
161 | /* Wire the NVIC up to the CPU */ | ||
162 | sbd = SYS_BUS_DEVICE(&s->nvic); | ||
163 | sysbus_connect_irq(sbd, 0, | ||
164 | qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_IRQ)); | ||
165 | |||
166 | - memory_region_add_subregion(&s->container, 0xe0000000, | ||
167 | + memory_region_add_subregion(&s->container, 0xe000e000, | ||
168 | sysbus_mmio_get_region(sbd, 0)); | ||
169 | + if (arm_feature(&s->cpu->env, ARM_FEATURE_V8)) { | ||
170 | + /* Create the NS alias region for the NVIC sysregs */ | ||
171 | + memory_region_init_io(&s->sysreg_ns_mem, OBJECT(s), | ||
172 | + &v7m_sysreg_ns_ops, | ||
173 | + sysbus_mmio_get_region(sbd, 0), | ||
174 | + "nvic_sysregs_ns", 0x1000); | ||
175 | + memory_region_add_subregion(&s->container, 0xe002e000, | ||
176 | + &s->sysreg_ns_mem); | ||
177 | + } | ||
178 | |||
179 | /* Create and map the systick devices */ | ||
180 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->systick[M_REG_NS]), errp)) { | ||
181 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
182 | index XXXXXXX..XXXXXXX 100644 | ||
183 | --- a/hw/intc/armv7m_nvic.c | ||
184 | +++ b/hw/intc/armv7m_nvic.c | ||
185 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps nvic_sysreg_ops = { | ||
186 | .endianness = DEVICE_NATIVE_ENDIAN, | ||
187 | }; | ||
188 | |||
189 | -static MemTxResult nvic_sysreg_ns_write(void *opaque, hwaddr addr, | ||
190 | - uint64_t value, unsigned size, | ||
191 | - MemTxAttrs attrs) | ||
192 | -{ | ||
193 | - MemoryRegion *mr = opaque; | ||
194 | - | ||
195 | - if (attrs.secure) { | ||
196 | - /* S accesses to the alias act like NS accesses to the real region */ | ||
197 | - attrs.secure = 0; | ||
198 | - return memory_region_dispatch_write(mr, addr, value, | ||
199 | - size_memop(size) | MO_TE, attrs); | ||
200 | - } else { | ||
201 | - /* NS attrs are RAZ/WI for privileged, and BusFault for user */ | ||
202 | - if (attrs.user) { | ||
203 | - return MEMTX_ERROR; | ||
204 | - } | ||
205 | - return MEMTX_OK; | ||
206 | - } | ||
207 | -} | ||
208 | - | ||
209 | -static MemTxResult nvic_sysreg_ns_read(void *opaque, hwaddr addr, | ||
210 | - uint64_t *data, unsigned size, | ||
211 | - MemTxAttrs attrs) | ||
212 | -{ | ||
213 | - MemoryRegion *mr = opaque; | ||
214 | - | ||
215 | - if (attrs.secure) { | ||
216 | - /* S accesses to the alias act like NS accesses to the real region */ | ||
217 | - attrs.secure = 0; | ||
218 | - return memory_region_dispatch_read(mr, addr, data, | ||
219 | - size_memop(size) | MO_TE, attrs); | ||
220 | - } else { | ||
221 | - /* NS attrs are RAZ/WI for privileged, and BusFault for user */ | ||
222 | - if (attrs.user) { | ||
223 | - return MEMTX_ERROR; | ||
224 | - } | ||
225 | - *data = 0; | ||
226 | - return MEMTX_OK; | ||
227 | - } | ||
228 | -} | ||
229 | - | ||
230 | -static const MemoryRegionOps nvic_sysreg_ns_ops = { | ||
231 | - .read_with_attrs = nvic_sysreg_ns_read, | ||
232 | - .write_with_attrs = nvic_sysreg_ns_write, | ||
233 | - .endianness = DEVICE_NATIVE_ENDIAN, | ||
234 | -}; | ||
235 | - | ||
236 | -/* | ||
237 | - * Unassigned portions of the PPB space are RAZ/WI for privileged | ||
238 | - * accesses, and fault for non-privileged accesses. | ||
239 | - */ | ||
240 | -static MemTxResult ppb_default_read(void *opaque, hwaddr addr, | ||
241 | - uint64_t *data, unsigned size, | ||
242 | - MemTxAttrs attrs) | ||
243 | -{ | ||
244 | - qemu_log_mask(LOG_UNIMP, "Read of unassigned area of PPB: offset 0x%x\n", | ||
245 | - (uint32_t)addr); | ||
246 | - if (attrs.user) { | ||
247 | - return MEMTX_ERROR; | ||
248 | - } | ||
249 | - *data = 0; | ||
250 | - return MEMTX_OK; | ||
251 | -} | ||
252 | - | ||
253 | -static MemTxResult ppb_default_write(void *opaque, hwaddr addr, | ||
254 | - uint64_t value, unsigned size, | ||
255 | - MemTxAttrs attrs) | ||
256 | -{ | ||
257 | - qemu_log_mask(LOG_UNIMP, "Write of unassigned area of PPB: offset 0x%x\n", | ||
258 | - (uint32_t)addr); | ||
259 | - if (attrs.user) { | ||
260 | - return MEMTX_ERROR; | ||
261 | - } | ||
262 | - return MEMTX_OK; | ||
263 | -} | ||
264 | - | ||
265 | -static const MemoryRegionOps ppb_default_ops = { | ||
266 | - .read_with_attrs = ppb_default_read, | ||
267 | - .write_with_attrs = ppb_default_write, | ||
268 | - .endianness = DEVICE_NATIVE_ENDIAN, | ||
269 | - .valid.min_access_size = 1, | ||
270 | - .valid.max_access_size = 8, | ||
271 | -}; | ||
272 | - | ||
273 | static int nvic_post_load(void *opaque, int version_id) | ||
274 | { | ||
275 | NVICState *s = opaque; | ||
276 | @@ -XXX,XX +XXX,XX @@ static void armv7m_nvic_realize(DeviceState *dev, Error **errp) | ||
277 | s->num_prio_bits = arm_feature(&s->cpu->env, ARM_FEATURE_V7) ? 8 : 2; | ||
278 | |||
279 | /* | ||
280 | - * This device provides a single sysbus memory region which | ||
281 | - * represents the whole of the "System PPB" space. This is the | ||
282 | - * range from 0xe0000000 to 0xe00fffff and includes the NVIC, | ||
283 | - * the System Control Space (system registers), the systick timer, | ||
284 | - * and for CPUs with the Security extension an NS banked version | ||
285 | - * of all of these. | ||
286 | - * | ||
287 | - * The default behaviour for unimplemented registers/ranges | ||
288 | - * (for instance the Data Watchpoint and Trace unit at 0xe0001000) | ||
289 | - * is to RAZ/WI for privileged access and BusFault for non-privileged | ||
290 | - * access. | ||
291 | - * | ||
292 | - * The NVIC and System Control Space (SCS) starts at 0xe000e000 | ||
293 | - * and looks like this: | ||
294 | - * 0x004 - ICTR | ||
295 | - * 0x010 - 0xff - systick | ||
296 | - * 0x100..0x7ec - NVIC | ||
297 | - * 0x7f0..0xcff - Reserved | ||
298 | - * 0xd00..0xd3c - SCS registers | ||
299 | - * 0xd40..0xeff - Reserved or Not implemented | ||
300 | - * 0xf00 - STIR | ||
301 | - * | ||
302 | - * Some registers within this space are banked between security states. | ||
303 | - * In v8M there is a second range 0xe002e000..0xe002efff which is the | ||
304 | - * NonSecure alias SCS; secure accesses to this behave like NS accesses | ||
305 | - * to the main SCS range, and non-secure accesses (including when | ||
306 | - * the security extension is not implemented) are RAZ/WI. | ||
307 | - * Note that both the main SCS range and the alias range are defined | ||
308 | - * to be exempt from memory attribution (R_BLJT) and so the memory | ||
309 | - * transaction attribute always matches the current CPU security | ||
310 | - * state (attrs.secure == env->v7m.secure). In the nvic_sysreg_ns_ops | ||
311 | - * wrappers we change attrs.secure to indicate the NS access; so | ||
312 | - * generally code determining which banked register to use should | ||
313 | - * use attrs.secure; code determining actual behaviour of the system | ||
314 | - * should use env->v7m.secure. | ||
315 | - * | ||
316 | - * The container covers the whole PPB space. Within it the priority | ||
317 | - * of overlapping regions is: | ||
318 | - * - default region (for RAZ/WI and BusFault) : -1 | ||
319 | - * - system register regions : 0 | ||
320 | - * - systick : 1 | ||
321 | - * This is because the systick device is a small block of registers | ||
322 | - * in the middle of the other system control registers. | ||
323 | + * This device provides a single memory region which covers the | ||
324 | + * sysreg/NVIC registers from 0xE000E000 .. 0xE000EFFF, with the | ||
325 | + * exception of the systick timer registers 0xE000E010 .. 0xE000E0FF. | ||
326 | */ | ||
327 | - memory_region_init(&s->container, OBJECT(s), "nvic", 0x100000); | ||
328 | - memory_region_init_io(&s->defaultmem, OBJECT(s), &ppb_default_ops, s, | ||
329 | - "nvic-default", 0x100000); | ||
330 | - memory_region_add_subregion_overlap(&s->container, 0, &s->defaultmem, -1); | ||
331 | memory_region_init_io(&s->sysregmem, OBJECT(s), &nvic_sysreg_ops, s, | ||
332 | "nvic_sysregs", 0x1000); | ||
333 | - memory_region_add_subregion(&s->container, 0xe000, &s->sysregmem); | ||
334 | - | ||
335 | - if (arm_feature(&s->cpu->env, ARM_FEATURE_V8)) { | ||
336 | - memory_region_init_io(&s->sysreg_ns_mem, OBJECT(s), | ||
337 | - &nvic_sysreg_ns_ops, &s->sysregmem, | ||
338 | - "nvic_sysregs_ns", 0x1000); | ||
339 | - memory_region_add_subregion(&s->container, 0x2e000, &s->sysreg_ns_mem); | ||
340 | - } | ||
341 | - | ||
342 | - sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->container); | ||
343 | + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->sysregmem); | ||
344 | } | ||
345 | |||
346 | static void armv7m_nvic_instance_init(Object *obj) | ||
347 | -- | ||
348 | 2.20.1 | ||
349 | |||
350 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Add the usual-style QEMU interface comment documenting what | ||
2 | properties, etc, this device exposes. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
7 | Message-id: 20210812093356.1946-5-peter.maydell@linaro.org | ||
8 | --- | ||
9 | include/hw/timer/armv7m_systick.h | 7 +++++++ | ||
10 | 1 file changed, 7 insertions(+) | ||
11 | |||
12 | diff --git a/include/hw/timer/armv7m_systick.h b/include/hw/timer/armv7m_systick.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/include/hw/timer/armv7m_systick.h | ||
15 | +++ b/include/hw/timer/armv7m_systick.h | ||
16 | @@ -XXX,XX +XXX,XX @@ | ||
17 | |||
18 | OBJECT_DECLARE_SIMPLE_TYPE(SysTickState, SYSTICK) | ||
19 | |||
20 | +/* | ||
21 | + * QEMU interface: | ||
22 | + * + sysbus MMIO region 0 is the register interface (covering | ||
23 | + * the registers which are mapped at address 0xE000E010) | ||
24 | + * + sysbus IRQ 0 is the interrupt line to the NVIC | ||
25 | + */ | ||
26 | + | ||
27 | struct SysTickState { | ||
28 | /*< private >*/ | ||
29 | SysBusDevice parent_obj; | ||
30 | -- | ||
31 | 2.20.1 | ||
32 | |||
33 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The v7M systick timer can be programmed to run from either of | ||
2 | two clocks: | ||
3 | * an "external reference clock" (when SYST_CSR.CLKSOURCE == 0) | ||
4 | * the main CPU clock (when SYST_CSR.CLKSOURCE == 1) | ||
5 | 1 | ||
6 | Our implementation currently hardwires the external reference clock | ||
7 | to be 1MHz, and allows boards to set the main CPU clock frequency via | ||
8 | the global 'system_clock_scale'. (Most boards set that to a constant | ||
9 | value; the Stellaris boards allow the guest to reprogram it via the | ||
10 | board-specific RCC registers). | ||
11 | |||
12 | As the first step in converting this to use the Clock infrastructure, | ||
13 | add input clocks to the systick device for the reference clock and | ||
14 | the CPU clock. The device implementation ignores them; once we have | ||
15 | made all the users of the device correctly wire up the new Clocks we | ||
16 | will switch the implementation to use them and ignore the old | ||
17 | system_clock_scale. | ||
18 | |||
19 | This is a migration compat break for all M-profile boards, because of | ||
20 | the addition of the new clock objects to the vmstate struct. | ||
21 | |||
22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
23 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
24 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
25 | Message-id: 20210812093356.1946-6-peter.maydell@linaro.org | ||
26 | --- | ||
27 | include/hw/timer/armv7m_systick.h | 7 +++++++ | ||
28 | hw/timer/armv7m_systick.c | 10 ++++++++-- | ||
29 | 2 files changed, 15 insertions(+), 2 deletions(-) | ||
30 | |||
31 | diff --git a/include/hw/timer/armv7m_systick.h b/include/hw/timer/armv7m_systick.h | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/include/hw/timer/armv7m_systick.h | ||
34 | +++ b/include/hw/timer/armv7m_systick.h | ||
35 | @@ -XXX,XX +XXX,XX @@ | ||
36 | #include "hw/sysbus.h" | ||
37 | #include "qom/object.h" | ||
38 | #include "hw/ptimer.h" | ||
39 | +#include "hw/clock.h" | ||
40 | |||
41 | #define TYPE_SYSTICK "armv7m_systick" | ||
42 | |||
43 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(SysTickState, SYSTICK) | ||
44 | * + sysbus MMIO region 0 is the register interface (covering | ||
45 | * the registers which are mapped at address 0xE000E010) | ||
46 | * + sysbus IRQ 0 is the interrupt line to the NVIC | ||
47 | + * + Clock input "refclk" is the external reference clock | ||
48 | + * (used when SYST_CSR.CLKSOURCE == 0) | ||
49 | + * + Clock input "cpuclk" is the main CPU clock | ||
50 | + * (used when SYST_CSR.CLKSOURCE == 1) | ||
51 | */ | ||
52 | |||
53 | struct SysTickState { | ||
54 | @@ -XXX,XX +XXX,XX @@ struct SysTickState { | ||
55 | ptimer_state *ptimer; | ||
56 | MemoryRegion iomem; | ||
57 | qemu_irq irq; | ||
58 | + Clock *refclk; | ||
59 | + Clock *cpuclk; | ||
60 | }; | ||
61 | |||
62 | /* | ||
63 | diff --git a/hw/timer/armv7m_systick.c b/hw/timer/armv7m_systick.c | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/hw/timer/armv7m_systick.c | ||
66 | +++ b/hw/timer/armv7m_systick.c | ||
67 | @@ -XXX,XX +XXX,XX @@ | ||
68 | #include "migration/vmstate.h" | ||
69 | #include "hw/irq.h" | ||
70 | #include "hw/sysbus.h" | ||
71 | +#include "hw/qdev-clock.h" | ||
72 | #include "qemu/timer.h" | ||
73 | #include "qemu/log.h" | ||
74 | #include "qemu/module.h" | ||
75 | @@ -XXX,XX +XXX,XX @@ static void systick_instance_init(Object *obj) | ||
76 | memory_region_init_io(&s->iomem, obj, &systick_ops, s, "systick", 0xe0); | ||
77 | sysbus_init_mmio(sbd, &s->iomem); | ||
78 | sysbus_init_irq(sbd, &s->irq); | ||
79 | + | ||
80 | + s->refclk = qdev_init_clock_in(DEVICE(obj), "refclk", NULL, NULL, 0); | ||
81 | + s->cpuclk = qdev_init_clock_in(DEVICE(obj), "cpuclk", NULL, NULL, 0); | ||
82 | } | ||
83 | |||
84 | static void systick_realize(DeviceState *dev, Error **errp) | ||
85 | @@ -XXX,XX +XXX,XX @@ static void systick_realize(DeviceState *dev, Error **errp) | ||
86 | |||
87 | static const VMStateDescription vmstate_systick = { | ||
88 | .name = "armv7m_systick", | ||
89 | - .version_id = 2, | ||
90 | - .minimum_version_id = 2, | ||
91 | + .version_id = 3, | ||
92 | + .minimum_version_id = 3, | ||
93 | .fields = (VMStateField[]) { | ||
94 | + VMSTATE_CLOCK(refclk, SysTickState), | ||
95 | + VMSTATE_CLOCK(cpuclk, SysTickState), | ||
96 | VMSTATE_UINT32(control, SysTickState), | ||
97 | VMSTATE_INT64(tick, SysTickState), | ||
98 | VMSTATE_PTIMER(ptimer, SysTickState), | ||
99 | -- | ||
100 | 2.20.1 | ||
101 | |||
102 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Create input clocks on the armv7m container object which pass through | ||
2 | to the systick timers, so that users of the armv7m object can specify | ||
3 | the clocks being used. | ||
4 | 1 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
7 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
8 | Message-id: 20210812093356.1946-7-peter.maydell@linaro.org | ||
9 | --- | ||
10 | include/hw/arm/armv7m.h | 6 ++++++ | ||
11 | hw/arm/armv7m.c | 23 +++++++++++++++++++++++ | ||
12 | 2 files changed, 29 insertions(+) | ||
13 | |||
14 | diff --git a/include/hw/arm/armv7m.h b/include/hw/arm/armv7m.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/include/hw/arm/armv7m.h | ||
17 | +++ b/include/hw/arm/armv7m.h | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | #include "hw/misc/armv7m_ras.h" | ||
20 | #include "target/arm/idau.h" | ||
21 | #include "qom/object.h" | ||
22 | +#include "hw/clock.h" | ||
23 | |||
24 | #define TYPE_BITBAND "ARM-bitband-memory" | ||
25 | OBJECT_DECLARE_SIMPLE_TYPE(BitBandState, BITBAND) | ||
26 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(ARMv7MState, ARMV7M) | ||
27 | * + Property "vfp": enable VFP (forwarded to CPU object) | ||
28 | * + Property "dsp": enable DSP (forwarded to CPU object) | ||
29 | * + Property "enable-bitband": expose bitbanded IO | ||
30 | + * + Clock input "refclk" is the external reference clock for the systick timers | ||
31 | + * + Clock input "cpuclk" is the main CPU clock | ||
32 | */ | ||
33 | struct ARMv7MState { | ||
34 | /*< private >*/ | ||
35 | @@ -XXX,XX +XXX,XX @@ struct ARMv7MState { | ||
36 | /* MR providing default PPB behaviour */ | ||
37 | MemoryRegion defaultmem; | ||
38 | |||
39 | + Clock *refclk; | ||
40 | + Clock *cpuclk; | ||
41 | + | ||
42 | /* Properties */ | ||
43 | char *cpu_type; | ||
44 | /* MemoryRegion the board provides to us (with its devices, RAM, etc) */ | ||
45 | diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/hw/arm/armv7m.c | ||
48 | +++ b/hw/arm/armv7m.c | ||
49 | @@ -XXX,XX +XXX,XX @@ | ||
50 | #include "hw/arm/boot.h" | ||
51 | #include "hw/loader.h" | ||
52 | #include "hw/qdev-properties.h" | ||
53 | +#include "hw/qdev-clock.h" | ||
54 | #include "elf.h" | ||
55 | #include "sysemu/reset.h" | ||
56 | #include "qemu/error-report.h" | ||
57 | #include "qemu/module.h" | ||
58 | #include "qemu/log.h" | ||
59 | #include "target/arm/idau.h" | ||
60 | +#include "migration/vmstate.h" | ||
61 | |||
62 | /* Bitbanded IO. Each word corresponds to a single bit. */ | ||
63 | |||
64 | @@ -XXX,XX +XXX,XX @@ static void armv7m_instance_init(Object *obj) | ||
65 | object_initialize_child(obj, "bitband[*]", &s->bitband[i], | ||
66 | TYPE_BITBAND); | ||
67 | } | ||
68 | + | ||
69 | + s->refclk = qdev_init_clock_in(DEVICE(obj), "refclk", NULL, NULL, 0); | ||
70 | + s->cpuclk = qdev_init_clock_in(DEVICE(obj), "cpuclk", NULL, NULL, 0); | ||
71 | } | ||
72 | |||
73 | static void armv7m_realize(DeviceState *dev, Error **errp) | ||
74 | @@ -XXX,XX +XXX,XX @@ static void armv7m_realize(DeviceState *dev, Error **errp) | ||
75 | } | ||
76 | |||
77 | /* Create and map the systick devices */ | ||
78 | + qdev_connect_clock_in(DEVICE(&s->systick[M_REG_NS]), "refclk", s->refclk); | ||
79 | + qdev_connect_clock_in(DEVICE(&s->systick[M_REG_NS]), "cpuclk", s->cpuclk); | ||
80 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->systick[M_REG_NS]), errp)) { | ||
81 | return; | ||
82 | } | ||
83 | @@ -XXX,XX +XXX,XX @@ static void armv7m_realize(DeviceState *dev, Error **errp) | ||
84 | */ | ||
85 | object_initialize_child(OBJECT(dev), "systick-reg-s", | ||
86 | &s->systick[M_REG_S], TYPE_SYSTICK); | ||
87 | + qdev_connect_clock_in(DEVICE(&s->systick[M_REG_S]), "refclk", | ||
88 | + s->refclk); | ||
89 | + qdev_connect_clock_in(DEVICE(&s->systick[M_REG_S]), "cpuclk", | ||
90 | + s->cpuclk); | ||
91 | |||
92 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->systick[M_REG_S]), errp)) { | ||
93 | return; | ||
94 | @@ -XXX,XX +XXX,XX @@ static Property armv7m_properties[] = { | ||
95 | DEFINE_PROP_END_OF_LIST(), | ||
96 | }; | ||
97 | |||
98 | +static const VMStateDescription vmstate_armv7m = { | ||
99 | + .name = "armv7m", | ||
100 | + .version_id = 1, | ||
101 | + .minimum_version_id = 1, | ||
102 | + .fields = (VMStateField[]) { | ||
103 | + VMSTATE_CLOCK(refclk, SysTickState), | ||
104 | + VMSTATE_CLOCK(cpuclk, SysTickState), | ||
105 | + VMSTATE_END_OF_LIST() | ||
106 | + } | ||
107 | +}; | ||
108 | + | ||
109 | static void armv7m_class_init(ObjectClass *klass, void *data) | ||
110 | { | ||
111 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
112 | |||
113 | dc->realize = armv7m_realize; | ||
114 | + dc->vmsd = &vmstate_armv7m; | ||
115 | device_class_set_props(dc, armv7m_properties); | ||
116 | } | ||
117 | |||
118 | -- | ||
119 | 2.20.1 | ||
120 | |||
121 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Wire up the cpuclk for the systick devices to the SSE object's | ||
2 | existing mainclk clock. | ||
3 | 1 | ||
4 | We do not wire up the refclk because the SSE subsystems do not | ||
5 | provide a refclk. (This is documented in the IoTKit and SSE-200 | ||
6 | TRMs; the SSE-300 TRM doesn't mention it but we assume it follows the | ||
7 | same approach.) When we update the systick device later to honour "no | ||
8 | refclk connected" this will fix a minor emulation inaccuracy for the | ||
9 | SSE-based boards. | ||
10 | |||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Acked-by: Alistair Francis <alistair.francis@wdc.com> | ||
13 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
14 | Message-id: 20210812093356.1946-8-peter.maydell@linaro.org | ||
15 | --- | ||
16 | hw/arm/armsse.c | 3 +++ | ||
17 | 1 file changed, 3 insertions(+) | ||
18 | |||
19 | diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/hw/arm/armsse.c | ||
22 | +++ b/hw/arm/armsse.c | ||
23 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) | ||
24 | int j; | ||
25 | char *gpioname; | ||
26 | |||
27 | + qdev_connect_clock_in(cpudev, "cpuclk", s->mainclk); | ||
28 | + /* The SSE subsystems do not wire up a systick refclk */ | ||
29 | + | ||
30 | qdev_prop_set_uint32(cpudev, "num-irq", s->exp_numirq + NUM_SSE_IRQS); | ||
31 | /* | ||
32 | * In real hardware the initial Secure VTOR is set from the INITSVTOR* | ||
33 | -- | ||
34 | 2.20.1 | ||
35 | |||
36 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Connect up the armv7m clocks on the mps2-an385/386/500/511. | ||
2 | 1 | ||
3 | Connect up the armv7m object's clocks on the MPS boards defined in | ||
4 | mps2.c. The documentation for these FPGA images doesn't specify what | ||
5 | systick reference clock is used (if any), so for the moment we | ||
6 | provide a 1MHz refclock, which will result in no behavioural change | ||
7 | from the current hardwired 1MHz clock implemented in | ||
8 | armv7m_systick.c:systick_scale(). | ||
9 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
12 | Message-id: 20210812093356.1946-9-peter.maydell@linaro.org | ||
13 | --- | ||
14 | hw/arm/mps2.c | 15 +++++++++++++++ | ||
15 | 1 file changed, 15 insertions(+) | ||
16 | |||
17 | diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/hw/arm/mps2.c | ||
20 | +++ b/hw/arm/mps2.c | ||
21 | @@ -XXX,XX +XXX,XX @@ struct MPS2MachineState { | ||
22 | CMSDKAPBWatchdog watchdog; | ||
23 | CMSDKAPBTimer timer[2]; | ||
24 | Clock *sysclk; | ||
25 | + Clock *refclk; | ||
26 | }; | ||
27 | |||
28 | #define TYPE_MPS2_MACHINE "mps2" | ||
29 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_TYPE(MPS2MachineState, MPS2MachineClass, MPS2_MACHINE) | ||
30 | /* Main SYSCLK frequency in Hz */ | ||
31 | #define SYSCLK_FRQ 25000000 | ||
32 | |||
33 | +/* | ||
34 | + * The Application Notes don't say anything about how the | ||
35 | + * systick reference clock is configured. (Quite possibly | ||
36 | + * they don't have one at all.) This 1MHz clock matches the | ||
37 | + * pre-existing behaviour that used to be hardcoded in the | ||
38 | + * armv7m_systick implementation. | ||
39 | + */ | ||
40 | +#define REFCLK_FRQ (1 * 1000 * 1000) | ||
41 | + | ||
42 | /* Initialize the auxiliary RAM region @mr and map it into | ||
43 | * the memory map at @base. | ||
44 | */ | ||
45 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) | ||
46 | mms->sysclk = clock_new(OBJECT(machine), "SYSCLK"); | ||
47 | clock_set_hz(mms->sysclk, SYSCLK_FRQ); | ||
48 | |||
49 | + mms->refclk = clock_new(OBJECT(machine), "REFCLK"); | ||
50 | + clock_set_hz(mms->refclk, REFCLK_FRQ); | ||
51 | + | ||
52 | /* The FPGA images have an odd combination of different RAMs, | ||
53 | * because in hardware they are different implementations and | ||
54 | * connected to different buses, giving varying performance/size | ||
55 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) | ||
56 | default: | ||
57 | g_assert_not_reached(); | ||
58 | } | ||
59 | + qdev_connect_clock_in(armv7m, "cpuclk", mms->sysclk); | ||
60 | + qdev_connect_clock_in(armv7m, "refclk", mms->refclk); | ||
61 | qdev_prop_set_string(armv7m, "cpu-type", machine->cpu_type); | ||
62 | qdev_prop_set_bit(armv7m, "enable-bitband", true); | ||
63 | object_property_set_link(OBJECT(&mms->armv7m), "memory", | ||
64 | -- | ||
65 | 2.20.1 | ||
66 | |||
67 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | It is quite common for a clock tree to involve possibly programmable | ||
2 | clock multipliers or dividers, where the frequency of a clock is for | ||
3 | instance divided by 8 to produce a slower clock to feed to a | ||
4 | particular device. | ||
5 | 1 | ||
6 | Currently we provide no convenient mechanism for modelling this. You | ||
7 | can implement it by having an input Clock and an output Clock, and | ||
8 | manually setting the period of the output clock in the period-changed | ||
9 | callback of the input clock, but that's quite clunky. | ||
10 | |||
11 | This patch adds support in the Clock objects themselves for setting a | ||
12 | multiplier or divider. The effect of setting this on a clock is that | ||
13 | when the clock's period is changed, all the children of the clock are | ||
14 | set to period * multiplier / divider, rather than being set to the | ||
15 | same period as the parent clock. | ||
16 | |||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | Reviewed-by: Alexandre Iooss <erdnaxe@crans.org> | ||
19 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
20 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
21 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
22 | Reviewed-by: Damien Hedde <damien.hedde@greensocs.com> | ||
23 | Message-id: 20210812093356.1946-10-peter.maydell@linaro.org | ||
24 | --- | ||
25 | docs/devel/clocks.rst | 23 +++++++++++++++++++++++ | ||
26 | include/hw/clock.h | 29 +++++++++++++++++++++++++++++ | ||
27 | hw/core/clock-vmstate.c | 40 +++++++++++++++++++++++++++++++++++++++- | ||
28 | hw/core/clock.c | 31 +++++++++++++++++++++++++++---- | ||
29 | hw/core/trace-events | 1 + | ||
30 | 5 files changed, 119 insertions(+), 5 deletions(-) | ||
31 | |||
32 | diff --git a/docs/devel/clocks.rst b/docs/devel/clocks.rst | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/docs/devel/clocks.rst | ||
35 | +++ b/docs/devel/clocks.rst | ||
36 | @@ -XXX,XX +XXX,XX @@ clocks get the new clock period value: *Clock 2*, *Clock 3* and *Clock 4*. | ||
37 | It is not possible to disconnect a clock or to change the clock connection | ||
38 | after it is connected. | ||
39 | |||
40 | +Clock multiplier and divider settings | ||
41 | +------------------------------------- | ||
42 | + | ||
43 | +By default, when clocks are connected together, the child | ||
44 | +clocks run with the same period as their source (parent) clock. | ||
45 | +The Clock API supports a built-in period multiplier/divider | ||
46 | +mechanism so you can configure a clock to make its children | ||
47 | +run at a different period from its own. If you call the | ||
48 | +``clock_set_mul_div()`` function you can specify the clock's | ||
49 | +multiplier and divider values. The children of that clock | ||
50 | +will all run with a period of ``parent_period * multiplier / divider``. | ||
51 | +For instance, if the clock has a frequency of 8MHz and you set its | ||
52 | +multiplier to 2 and its divider to 3, the child clocks will run | ||
53 | +at 12MHz. | ||
54 | + | ||
55 | +You can change the multiplier and divider of a clock at runtime, | ||
56 | +so you can use this to model clock controller devices which | ||
57 | +have guest-programmable frequency multipliers or dividers. | ||
58 | + | ||
59 | +Note that ``clock_set_mul_div()`` does not automatically call | ||
60 | +``clock_propagate()``. If you make a runtime change to the | ||
61 | +multiplier or divider you must call clock_propagate() yourself. | ||
62 | + | ||
63 | Unconnected input clocks | ||
64 | ------------------------ | ||
65 | |||
66 | diff --git a/include/hw/clock.h b/include/hw/clock.h | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/include/hw/clock.h | ||
69 | +++ b/include/hw/clock.h | ||
70 | @@ -XXX,XX +XXX,XX @@ struct Clock { | ||
71 | void *callback_opaque; | ||
72 | unsigned int callback_events; | ||
73 | |||
74 | + /* Ratio of the parent clock to run the child clocks at */ | ||
75 | + uint32_t multiplier; | ||
76 | + uint32_t divider; | ||
77 | + | ||
78 | /* Clocks are organized in a clock tree */ | ||
79 | Clock *source; | ||
80 | QLIST_HEAD(, Clock) children; | ||
81 | @@ -XXX,XX +XXX,XX @@ static inline bool clock_is_enabled(const Clock *clk) | ||
82 | */ | ||
83 | char *clock_display_freq(Clock *clk); | ||
84 | |||
85 | +/** | ||
86 | + * clock_set_mul_div: set multiplier/divider for child clocks | ||
87 | + * @clk: clock | ||
88 | + * @multiplier: multiplier value | ||
89 | + * @divider: divider value | ||
90 | + * | ||
91 | + * By default, a Clock's children will all run with the same period | ||
92 | + * as their parent. This function allows you to adjust the multiplier | ||
93 | + * and divider used to derive the child clock frequency. | ||
94 | + * For example, setting a multiplier of 2 and a divider of 3 | ||
95 | + * will run child clocks with a period 2/3 of the parent clock, | ||
96 | + * so if the parent clock is an 8MHz clock the children will | ||
97 | + * be 12MHz. | ||
98 | + * | ||
99 | + * Setting the multiplier to 0 will stop the child clocks. | ||
100 | + * Setting the divider to 0 is a programming error (diagnosed with | ||
101 | + * an assertion failure). | ||
102 | + * Setting a multiplier value that results in the child period | ||
103 | + * overflowing is not diagnosed. | ||
104 | + * | ||
105 | + * Note that this function does not call clock_propagate(); the | ||
106 | + * caller should do that if necessary. | ||
107 | + */ | ||
108 | +void clock_set_mul_div(Clock *clk, uint32_t multiplier, uint32_t divider); | ||
109 | + | ||
110 | #endif /* QEMU_HW_CLOCK_H */ | ||
111 | diff --git a/hw/core/clock-vmstate.c b/hw/core/clock-vmstate.c | ||
112 | index XXXXXXX..XXXXXXX 100644 | ||
113 | --- a/hw/core/clock-vmstate.c | ||
114 | +++ b/hw/core/clock-vmstate.c | ||
115 | @@ -XXX,XX +XXX,XX @@ | ||
116 | #include "migration/vmstate.h" | ||
117 | #include "hw/clock.h" | ||
118 | |||
119 | +static bool muldiv_needed(void *opaque) | ||
120 | +{ | ||
121 | + Clock *clk = opaque; | ||
122 | + | ||
123 | + return clk->multiplier != 1 || clk->divider != 1; | ||
124 | +} | ||
125 | + | ||
126 | +static int clock_pre_load(void *opaque) | ||
127 | +{ | ||
128 | + Clock *clk = opaque; | ||
129 | + /* | ||
130 | + * The initial out-of-reset settings of the Clock might have been | ||
131 | + * configured by the device to be different from what we set | ||
132 | + * in clock_initfn(), so we must here set the default values to | ||
133 | + * be used if they are not in the inbound migration state. | ||
134 | + */ | ||
135 | + clk->multiplier = 1; | ||
136 | + clk->divider = 1; | ||
137 | + | ||
138 | + return 0; | ||
139 | +} | ||
140 | + | ||
141 | +const VMStateDescription vmstate_muldiv = { | ||
142 | + .name = "clock/muldiv", | ||
143 | + .version_id = 1, | ||
144 | + .minimum_version_id = 1, | ||
145 | + .needed = muldiv_needed, | ||
146 | + .fields = (VMStateField[]) { | ||
147 | + VMSTATE_UINT32(multiplier, Clock), | ||
148 | + VMSTATE_UINT32(divider, Clock), | ||
149 | + }, | ||
150 | +}; | ||
151 | + | ||
152 | const VMStateDescription vmstate_clock = { | ||
153 | .name = "clock", | ||
154 | .version_id = 0, | ||
155 | .minimum_version_id = 0, | ||
156 | + .pre_load = clock_pre_load, | ||
157 | .fields = (VMStateField[]) { | ||
158 | VMSTATE_UINT64(period, Clock), | ||
159 | VMSTATE_END_OF_LIST() | ||
160 | - } | ||
161 | + }, | ||
162 | + .subsections = (const VMStateDescription*[]) { | ||
163 | + &vmstate_muldiv, | ||
164 | + NULL | ||
165 | + }, | ||
166 | }; | ||
167 | diff --git a/hw/core/clock.c b/hw/core/clock.c | ||
168 | index XXXXXXX..XXXXXXX 100644 | ||
169 | --- a/hw/core/clock.c | ||
170 | +++ b/hw/core/clock.c | ||
171 | @@ -XXX,XX +XXX,XX @@ bool clock_set(Clock *clk, uint64_t period) | ||
172 | return true; | ||
173 | } | ||
174 | |||
175 | +static uint64_t clock_get_child_period(Clock *clk) | ||
176 | +{ | ||
177 | + /* | ||
178 | + * Return the period to be used for child clocks, which is the parent | ||
179 | + * clock period adjusted for for multiplier and divider effects. | ||
180 | + */ | ||
181 | + return muldiv64(clk->period, clk->multiplier, clk->divider); | ||
182 | +} | ||
183 | + | ||
184 | static void clock_call_callback(Clock *clk, ClockEvent event) | ||
185 | { | ||
186 | /* | ||
187 | @@ -XXX,XX +XXX,XX @@ static void clock_call_callback(Clock *clk, ClockEvent event) | ||
188 | static void clock_propagate_period(Clock *clk, bool call_callbacks) | ||
189 | { | ||
190 | Clock *child; | ||
191 | + uint64_t child_period = clock_get_child_period(clk); | ||
192 | |||
193 | QLIST_FOREACH(child, &clk->children, sibling) { | ||
194 | - if (child->period != clk->period) { | ||
195 | + if (child->period != child_period) { | ||
196 | if (call_callbacks) { | ||
197 | clock_call_callback(child, ClockPreUpdate); | ||
198 | } | ||
199 | - child->period = clk->period; | ||
200 | + child->period = child_period; | ||
201 | trace_clock_update(CLOCK_PATH(child), CLOCK_PATH(clk), | ||
202 | - CLOCK_PERIOD_TO_HZ(clk->period), | ||
203 | + CLOCK_PERIOD_TO_HZ(child->period), | ||
204 | call_callbacks); | ||
205 | if (call_callbacks) { | ||
206 | clock_call_callback(child, ClockUpdate); | ||
207 | @@ -XXX,XX +XXX,XX @@ void clock_set_source(Clock *clk, Clock *src) | ||
208 | |||
209 | trace_clock_set_source(CLOCK_PATH(clk), CLOCK_PATH(src)); | ||
210 | |||
211 | - clk->period = src->period; | ||
212 | + clk->period = clock_get_child_period(src); | ||
213 | QLIST_INSERT_HEAD(&src->children, clk, sibling); | ||
214 | clk->source = src; | ||
215 | clock_propagate_period(clk, false); | ||
216 | @@ -XXX,XX +XXX,XX @@ char *clock_display_freq(Clock *clk) | ||
217 | return freq_to_str(clock_get_hz(clk)); | ||
218 | } | ||
219 | |||
220 | +void clock_set_mul_div(Clock *clk, uint32_t multiplier, uint32_t divider) | ||
221 | +{ | ||
222 | + assert(divider != 0); | ||
223 | + | ||
224 | + trace_clock_set_mul_div(CLOCK_PATH(clk), clk->multiplier, multiplier, | ||
225 | + clk->divider, divider); | ||
226 | + clk->multiplier = multiplier; | ||
227 | + clk->divider = divider; | ||
228 | +} | ||
229 | + | ||
230 | static void clock_initfn(Object *obj) | ||
231 | { | ||
232 | Clock *clk = CLOCK(obj); | ||
233 | |||
234 | + clk->multiplier = 1; | ||
235 | + clk->divider = 1; | ||
236 | + | ||
237 | QLIST_INIT(&clk->children); | ||
238 | } | ||
239 | |||
240 | diff --git a/hw/core/trace-events b/hw/core/trace-events | ||
241 | index XXXXXXX..XXXXXXX 100644 | ||
242 | --- a/hw/core/trace-events | ||
243 | +++ b/hw/core/trace-events | ||
244 | @@ -XXX,XX +XXX,XX @@ clock_disconnect(const char *clk) "'%s'" | ||
245 | clock_set(const char *clk, uint64_t old, uint64_t new) "'%s', %"PRIu64"Hz->%"PRIu64"Hz" | ||
246 | clock_propagate(const char *clk) "'%s'" | ||
247 | clock_update(const char *clk, const char *src, uint64_t hz, int cb) "'%s', src='%s', val=%"PRIu64"Hz cb=%d" | ||
248 | +clock_set_mul_div(const char *clk, uint32_t oldmul, uint32_t mul, uint32_t olddiv, uint32_t div) "'%s', mul: %u -> %u, div: %u -> %u" | ||
249 | -- | ||
250 | 2.20.1 | ||
251 | |||
252 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | In the realize methods of the stm32f100 and stm32f205 SoC objects, we | ||
2 | call g_new() to create new MemoryRegion objects for the sram, flash, | ||
3 | and flash_alias. This is unnecessary (and leaves open the | ||
4 | possibility of leaking the allocations if we exit from realize with | ||
5 | an error). Make these MemoryRegions member fields of the device | ||
6 | state struct instead, as stm32f405 already does. | ||
7 | 1 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Reviewed-by: Alexandre Iooss <erdnaxe@crans.org> | ||
10 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
11 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
12 | Message-id: 20210812093356.1946-11-peter.maydell@linaro.org | ||
13 | --- | ||
14 | include/hw/arm/stm32f100_soc.h | 4 ++++ | ||
15 | include/hw/arm/stm32f205_soc.h | 4 ++++ | ||
16 | hw/arm/stm32f100_soc.c | 17 +++++++---------- | ||
17 | hw/arm/stm32f205_soc.c | 17 +++++++---------- | ||
18 | 4 files changed, 22 insertions(+), 20 deletions(-) | ||
19 | |||
20 | diff --git a/include/hw/arm/stm32f100_soc.h b/include/hw/arm/stm32f100_soc.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/include/hw/arm/stm32f100_soc.h | ||
23 | +++ b/include/hw/arm/stm32f100_soc.h | ||
24 | @@ -XXX,XX +XXX,XX @@ struct STM32F100State { | ||
25 | |||
26 | STM32F2XXUsartState usart[STM_NUM_USARTS]; | ||
27 | STM32F2XXSPIState spi[STM_NUM_SPIS]; | ||
28 | + | ||
29 | + MemoryRegion sram; | ||
30 | + MemoryRegion flash; | ||
31 | + MemoryRegion flash_alias; | ||
32 | }; | ||
33 | |||
34 | #endif | ||
35 | diff --git a/include/hw/arm/stm32f205_soc.h b/include/hw/arm/stm32f205_soc.h | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/include/hw/arm/stm32f205_soc.h | ||
38 | +++ b/include/hw/arm/stm32f205_soc.h | ||
39 | @@ -XXX,XX +XXX,XX @@ struct STM32F205State { | ||
40 | STM32F2XXSPIState spi[STM_NUM_SPIS]; | ||
41 | |||
42 | qemu_or_irq *adc_irqs; | ||
43 | + | ||
44 | + MemoryRegion sram; | ||
45 | + MemoryRegion flash; | ||
46 | + MemoryRegion flash_alias; | ||
47 | }; | ||
48 | |||
49 | #endif | ||
50 | diff --git a/hw/arm/stm32f100_soc.c b/hw/arm/stm32f100_soc.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/hw/arm/stm32f100_soc.c | ||
53 | +++ b/hw/arm/stm32f100_soc.c | ||
54 | @@ -XXX,XX +XXX,XX @@ static void stm32f100_soc_realize(DeviceState *dev_soc, Error **errp) | ||
55 | int i; | ||
56 | |||
57 | MemoryRegion *system_memory = get_system_memory(); | ||
58 | - MemoryRegion *sram = g_new(MemoryRegion, 1); | ||
59 | - MemoryRegion *flash = g_new(MemoryRegion, 1); | ||
60 | - MemoryRegion *flash_alias = g_new(MemoryRegion, 1); | ||
61 | |||
62 | /* | ||
63 | * Init flash region | ||
64 | * Flash starts at 0x08000000 and then is aliased to boot memory at 0x0 | ||
65 | */ | ||
66 | - memory_region_init_rom(flash, OBJECT(dev_soc), "STM32F100.flash", | ||
67 | + memory_region_init_rom(&s->flash, OBJECT(dev_soc), "STM32F100.flash", | ||
68 | FLASH_SIZE, &error_fatal); | ||
69 | - memory_region_init_alias(flash_alias, OBJECT(dev_soc), | ||
70 | - "STM32F100.flash.alias", flash, 0, FLASH_SIZE); | ||
71 | - memory_region_add_subregion(system_memory, FLASH_BASE_ADDRESS, flash); | ||
72 | - memory_region_add_subregion(system_memory, 0, flash_alias); | ||
73 | + memory_region_init_alias(&s->flash_alias, OBJECT(dev_soc), | ||
74 | + "STM32F100.flash.alias", &s->flash, 0, FLASH_SIZE); | ||
75 | + memory_region_add_subregion(system_memory, FLASH_BASE_ADDRESS, &s->flash); | ||
76 | + memory_region_add_subregion(system_memory, 0, &s->flash_alias); | ||
77 | |||
78 | /* Init SRAM region */ | ||
79 | - memory_region_init_ram(sram, NULL, "STM32F100.sram", SRAM_SIZE, | ||
80 | + memory_region_init_ram(&s->sram, NULL, "STM32F100.sram", SRAM_SIZE, | ||
81 | &error_fatal); | ||
82 | - memory_region_add_subregion(system_memory, SRAM_BASE_ADDRESS, sram); | ||
83 | + memory_region_add_subregion(system_memory, SRAM_BASE_ADDRESS, &s->sram); | ||
84 | |||
85 | /* Init ARMv7m */ | ||
86 | armv7m = DEVICE(&s->armv7m); | ||
87 | diff --git a/hw/arm/stm32f205_soc.c b/hw/arm/stm32f205_soc.c | ||
88 | index XXXXXXX..XXXXXXX 100644 | ||
89 | --- a/hw/arm/stm32f205_soc.c | ||
90 | +++ b/hw/arm/stm32f205_soc.c | ||
91 | @@ -XXX,XX +XXX,XX @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp) | ||
92 | int i; | ||
93 | |||
94 | MemoryRegion *system_memory = get_system_memory(); | ||
95 | - MemoryRegion *sram = g_new(MemoryRegion, 1); | ||
96 | - MemoryRegion *flash = g_new(MemoryRegion, 1); | ||
97 | - MemoryRegion *flash_alias = g_new(MemoryRegion, 1); | ||
98 | |||
99 | - memory_region_init_rom(flash, OBJECT(dev_soc), "STM32F205.flash", | ||
100 | + memory_region_init_rom(&s->flash, OBJECT(dev_soc), "STM32F205.flash", | ||
101 | FLASH_SIZE, &error_fatal); | ||
102 | - memory_region_init_alias(flash_alias, OBJECT(dev_soc), | ||
103 | - "STM32F205.flash.alias", flash, 0, FLASH_SIZE); | ||
104 | + memory_region_init_alias(&s->flash_alias, OBJECT(dev_soc), | ||
105 | + "STM32F205.flash.alias", &s->flash, 0, FLASH_SIZE); | ||
106 | |||
107 | - memory_region_add_subregion(system_memory, FLASH_BASE_ADDRESS, flash); | ||
108 | - memory_region_add_subregion(system_memory, 0, flash_alias); | ||
109 | + memory_region_add_subregion(system_memory, FLASH_BASE_ADDRESS, &s->flash); | ||
110 | + memory_region_add_subregion(system_memory, 0, &s->flash_alias); | ||
111 | |||
112 | - memory_region_init_ram(sram, NULL, "STM32F205.sram", SRAM_SIZE, | ||
113 | + memory_region_init_ram(&s->sram, NULL, "STM32F205.sram", SRAM_SIZE, | ||
114 | &error_fatal); | ||
115 | - memory_region_add_subregion(system_memory, SRAM_BASE_ADDRESS, sram); | ||
116 | + memory_region_add_subregion(system_memory, SRAM_BASE_ADDRESS, &s->sram); | ||
117 | |||
118 | armv7m = DEVICE(&s->armv7m); | ||
119 | qdev_prop_set_uint32(armv7m, "num-irq", 96); | ||
120 | -- | ||
121 | 2.20.1 | ||
122 | |||
123 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Wire up the sysclk and refclk for the stm32f100 SoC. This SoC always | ||
2 | runs the systick refclk at 1/8 the frequency of the main CPU clock, | ||
3 | so the board code only needs to provide a single sysclk clock. | ||
4 | 1 | ||
5 | Because there is only one board using this SoC, we convert the SoC | ||
6 | and the board together, rather than splitting it into "add clock to | ||
7 | SoC; connect clock in board; add error check in SoC code that clock | ||
8 | is wired up". | ||
9 | |||
10 | When the systick device starts honouring its clock inputs, this will | ||
11 | fix an emulation inaccuracy in the stm32vldiscovery board where the | ||
12 | systick reference clock was running at 1MHz rather than 3MHz. | ||
13 | |||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
16 | Reviewed-by: Alexandre Iooss <erdnaxe@crans.org> | ||
17 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
18 | Message-id: 20210812093356.1946-12-peter.maydell@linaro.org | ||
19 | --- | ||
20 | include/hw/arm/stm32f100_soc.h | 4 ++++ | ||
21 | hw/arm/stm32f100_soc.c | 30 ++++++++++++++++++++++++++++++ | ||
22 | hw/arm/stm32vldiscovery.c | 12 +++++++----- | ||
23 | 3 files changed, 41 insertions(+), 5 deletions(-) | ||
24 | |||
25 | diff --git a/include/hw/arm/stm32f100_soc.h b/include/hw/arm/stm32f100_soc.h | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/include/hw/arm/stm32f100_soc.h | ||
28 | +++ b/include/hw/arm/stm32f100_soc.h | ||
29 | @@ -XXX,XX +XXX,XX @@ | ||
30 | #include "hw/ssi/stm32f2xx_spi.h" | ||
31 | #include "hw/arm/armv7m.h" | ||
32 | #include "qom/object.h" | ||
33 | +#include "hw/clock.h" | ||
34 | |||
35 | #define TYPE_STM32F100_SOC "stm32f100-soc" | ||
36 | OBJECT_DECLARE_SIMPLE_TYPE(STM32F100State, STM32F100_SOC) | ||
37 | @@ -XXX,XX +XXX,XX @@ struct STM32F100State { | ||
38 | MemoryRegion sram; | ||
39 | MemoryRegion flash; | ||
40 | MemoryRegion flash_alias; | ||
41 | + | ||
42 | + Clock *sysclk; | ||
43 | + Clock *refclk; | ||
44 | }; | ||
45 | |||
46 | #endif | ||
47 | diff --git a/hw/arm/stm32f100_soc.c b/hw/arm/stm32f100_soc.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/hw/arm/stm32f100_soc.c | ||
50 | +++ b/hw/arm/stm32f100_soc.c | ||
51 | @@ -XXX,XX +XXX,XX @@ | ||
52 | #include "exec/address-spaces.h" | ||
53 | #include "hw/arm/stm32f100_soc.h" | ||
54 | #include "hw/qdev-properties.h" | ||
55 | +#include "hw/qdev-clock.h" | ||
56 | #include "hw/misc/unimp.h" | ||
57 | #include "sysemu/sysemu.h" | ||
58 | |||
59 | @@ -XXX,XX +XXX,XX @@ static void stm32f100_soc_initfn(Object *obj) | ||
60 | for (i = 0; i < STM_NUM_SPIS; i++) { | ||
61 | object_initialize_child(obj, "spi[*]", &s->spi[i], TYPE_STM32F2XX_SPI); | ||
62 | } | ||
63 | + | ||
64 | + s->sysclk = qdev_init_clock_in(DEVICE(s), "sysclk", NULL, NULL, 0); | ||
65 | + s->refclk = qdev_init_clock_in(DEVICE(s), "refclk", NULL, NULL, 0); | ||
66 | } | ||
67 | |||
68 | static void stm32f100_soc_realize(DeviceState *dev_soc, Error **errp) | ||
69 | @@ -XXX,XX +XXX,XX @@ static void stm32f100_soc_realize(DeviceState *dev_soc, Error **errp) | ||
70 | |||
71 | MemoryRegion *system_memory = get_system_memory(); | ||
72 | |||
73 | + /* | ||
74 | + * We use s->refclk internally and only define it with qdev_init_clock_in() | ||
75 | + * so it is correctly parented and not leaked on an init/deinit; it is not | ||
76 | + * intended as an externally exposed clock. | ||
77 | + */ | ||
78 | + if (clock_has_source(s->refclk)) { | ||
79 | + error_setg(errp, "refclk clock must not be wired up by the board code"); | ||
80 | + return; | ||
81 | + } | ||
82 | + | ||
83 | + if (!clock_has_source(s->sysclk)) { | ||
84 | + error_setg(errp, "sysclk clock must be wired up by the board code"); | ||
85 | + return; | ||
86 | + } | ||
87 | + | ||
88 | + /* | ||
89 | + * TODO: ideally we should model the SoC RCC and its ability to | ||
90 | + * change the sysclk frequency and define different sysclk sources. | ||
91 | + */ | ||
92 | + | ||
93 | + /* The refclk always runs at frequency HCLK / 8 */ | ||
94 | + clock_set_mul_div(s->refclk, 8, 1); | ||
95 | + clock_set_source(s->refclk, s->sysclk); | ||
96 | + | ||
97 | /* | ||
98 | * Init flash region | ||
99 | * Flash starts at 0x08000000 and then is aliased to boot memory at 0x0 | ||
100 | @@ -XXX,XX +XXX,XX @@ static void stm32f100_soc_realize(DeviceState *dev_soc, Error **errp) | ||
101 | qdev_prop_set_uint32(armv7m, "num-irq", 61); | ||
102 | qdev_prop_set_string(armv7m, "cpu-type", s->cpu_type); | ||
103 | qdev_prop_set_bit(armv7m, "enable-bitband", true); | ||
104 | + qdev_connect_clock_in(armv7m, "cpuclk", s->sysclk); | ||
105 | + qdev_connect_clock_in(armv7m, "refclk", s->refclk); | ||
106 | object_property_set_link(OBJECT(&s->armv7m), "memory", | ||
107 | OBJECT(get_system_memory()), &error_abort); | ||
108 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->armv7m), errp)) { | ||
109 | diff --git a/hw/arm/stm32vldiscovery.c b/hw/arm/stm32vldiscovery.c | ||
110 | index XXXXXXX..XXXXXXX 100644 | ||
111 | --- a/hw/arm/stm32vldiscovery.c | ||
112 | +++ b/hw/arm/stm32vldiscovery.c | ||
113 | @@ -XXX,XX +XXX,XX @@ | ||
114 | #include "qapi/error.h" | ||
115 | #include "hw/boards.h" | ||
116 | #include "hw/qdev-properties.h" | ||
117 | +#include "hw/qdev-clock.h" | ||
118 | #include "qemu/error-report.h" | ||
119 | #include "hw/arm/stm32f100_soc.h" | ||
120 | #include "hw/arm/boot.h" | ||
121 | @@ -XXX,XX +XXX,XX @@ | ||
122 | static void stm32vldiscovery_init(MachineState *machine) | ||
123 | { | ||
124 | DeviceState *dev; | ||
125 | + Clock *sysclk; | ||
126 | |||
127 | - /* | ||
128 | - * TODO: ideally we would model the SoC RCC and let it handle | ||
129 | - * system_clock_scale, including its ability to define different | ||
130 | - * possible SYSCLK sources. | ||
131 | - */ | ||
132 | system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ; | ||
133 | |||
134 | + /* This clock doesn't need migration because it is fixed-frequency */ | ||
135 | + sysclk = clock_new(OBJECT(machine), "SYSCLK"); | ||
136 | + clock_set_hz(sysclk, SYSCLK_FRQ); | ||
137 | + | ||
138 | dev = qdev_new(TYPE_STM32F100_SOC); | ||
139 | qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m3")); | ||
140 | + qdev_connect_clock_in(dev, "sysclk", sysclk); | ||
141 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); | ||
142 | |||
143 | armv7m_load_kernel(ARM_CPU(first_cpu), | ||
144 | -- | ||
145 | 2.20.1 | ||
146 | |||
147 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Wire up the sysclk and refclk for the stm32f205 SoC. This SoC always | ||
2 | runs the systick refclk at 1/8 the frequency of the main CPU clock, | ||
3 | so the board code only needs to provide a single sysclk clock. | ||
4 | 1 | ||
5 | Because there is only one board using this SoC, we convert the SoC | ||
6 | and the board together, rather than splitting it into "add clock to | ||
7 | SoC; connect clock in board; add error check in SoC code that clock | ||
8 | is wired up". | ||
9 | |||
10 | When the systick device starts honouring its clock inputs, this will | ||
11 | fix an emulation inaccuracy in the netduino2 board where the systick | ||
12 | reference clock was running at 1MHz rather than 15MHz. | ||
13 | |||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
16 | Reviewed-by: Alexandre Iooss <erdnaxe@crans.org> | ||
17 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
18 | Message-id: 20210812093356.1946-13-peter.maydell@linaro.org | ||
19 | --- | ||
20 | include/hw/arm/stm32f205_soc.h | 4 ++++ | ||
21 | hw/arm/netduino2.c | 12 +++++++----- | ||
22 | hw/arm/stm32f205_soc.c | 30 ++++++++++++++++++++++++++++++ | ||
23 | 3 files changed, 41 insertions(+), 5 deletions(-) | ||
24 | |||
25 | diff --git a/include/hw/arm/stm32f205_soc.h b/include/hw/arm/stm32f205_soc.h | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/include/hw/arm/stm32f205_soc.h | ||
28 | +++ b/include/hw/arm/stm32f205_soc.h | ||
29 | @@ -XXX,XX +XXX,XX @@ | ||
30 | #include "hw/or-irq.h" | ||
31 | #include "hw/ssi/stm32f2xx_spi.h" | ||
32 | #include "hw/arm/armv7m.h" | ||
33 | +#include "hw/clock.h" | ||
34 | #include "qom/object.h" | ||
35 | |||
36 | #define TYPE_STM32F205_SOC "stm32f205-soc" | ||
37 | @@ -XXX,XX +XXX,XX @@ struct STM32F205State { | ||
38 | MemoryRegion sram; | ||
39 | MemoryRegion flash; | ||
40 | MemoryRegion flash_alias; | ||
41 | + | ||
42 | + Clock *sysclk; | ||
43 | + Clock *refclk; | ||
44 | }; | ||
45 | |||
46 | #endif | ||
47 | diff --git a/hw/arm/netduino2.c b/hw/arm/netduino2.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/hw/arm/netduino2.c | ||
50 | +++ b/hw/arm/netduino2.c | ||
51 | @@ -XXX,XX +XXX,XX @@ | ||
52 | #include "qapi/error.h" | ||
53 | #include "hw/boards.h" | ||
54 | #include "hw/qdev-properties.h" | ||
55 | +#include "hw/qdev-clock.h" | ||
56 | #include "qemu/error-report.h" | ||
57 | #include "hw/arm/stm32f205_soc.h" | ||
58 | #include "hw/arm/boot.h" | ||
59 | @@ -XXX,XX +XXX,XX @@ | ||
60 | static void netduino2_init(MachineState *machine) | ||
61 | { | ||
62 | DeviceState *dev; | ||
63 | + Clock *sysclk; | ||
64 | |||
65 | - /* | ||
66 | - * TODO: ideally we would model the SoC RCC and let it handle | ||
67 | - * system_clock_scale, including its ability to define different | ||
68 | - * possible SYSCLK sources. | ||
69 | - */ | ||
70 | system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ; | ||
71 | |||
72 | + /* This clock doesn't need migration because it is fixed-frequency */ | ||
73 | + sysclk = clock_new(OBJECT(machine), "SYSCLK"); | ||
74 | + clock_set_hz(sysclk, SYSCLK_FRQ); | ||
75 | + | ||
76 | dev = qdev_new(TYPE_STM32F205_SOC); | ||
77 | qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m3")); | ||
78 | + qdev_connect_clock_in(dev, "sysclk", sysclk); | ||
79 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); | ||
80 | |||
81 | armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, | ||
82 | diff --git a/hw/arm/stm32f205_soc.c b/hw/arm/stm32f205_soc.c | ||
83 | index XXXXXXX..XXXXXXX 100644 | ||
84 | --- a/hw/arm/stm32f205_soc.c | ||
85 | +++ b/hw/arm/stm32f205_soc.c | ||
86 | @@ -XXX,XX +XXX,XX @@ | ||
87 | #include "exec/address-spaces.h" | ||
88 | #include "hw/arm/stm32f205_soc.h" | ||
89 | #include "hw/qdev-properties.h" | ||
90 | +#include "hw/qdev-clock.h" | ||
91 | #include "sysemu/sysemu.h" | ||
92 | |||
93 | /* At the moment only Timer 2 to 5 are modelled */ | ||
94 | @@ -XXX,XX +XXX,XX @@ static void stm32f205_soc_initfn(Object *obj) | ||
95 | for (i = 0; i < STM_NUM_SPIS; i++) { | ||
96 | object_initialize_child(obj, "spi[*]", &s->spi[i], TYPE_STM32F2XX_SPI); | ||
97 | } | ||
98 | + | ||
99 | + s->sysclk = qdev_init_clock_in(DEVICE(s), "sysclk", NULL, NULL, 0); | ||
100 | + s->refclk = qdev_init_clock_in(DEVICE(s), "refclk", NULL, NULL, 0); | ||
101 | } | ||
102 | |||
103 | static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp) | ||
104 | @@ -XXX,XX +XXX,XX @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp) | ||
105 | |||
106 | MemoryRegion *system_memory = get_system_memory(); | ||
107 | |||
108 | + /* | ||
109 | + * We use s->refclk internally and only define it with qdev_init_clock_in() | ||
110 | + * so it is correctly parented and not leaked on an init/deinit; it is not | ||
111 | + * intended as an externally exposed clock. | ||
112 | + */ | ||
113 | + if (clock_has_source(s->refclk)) { | ||
114 | + error_setg(errp, "refclk clock must not be wired up by the board code"); | ||
115 | + return; | ||
116 | + } | ||
117 | + | ||
118 | + if (!clock_has_source(s->sysclk)) { | ||
119 | + error_setg(errp, "sysclk clock must be wired up by the board code"); | ||
120 | + return; | ||
121 | + } | ||
122 | + | ||
123 | + /* | ||
124 | + * TODO: ideally we should model the SoC RCC and its ability to | ||
125 | + * change the sysclk frequency and define different sysclk sources. | ||
126 | + */ | ||
127 | + | ||
128 | + /* The refclk always runs at frequency HCLK / 8 */ | ||
129 | + clock_set_mul_div(s->refclk, 8, 1); | ||
130 | + clock_set_source(s->refclk, s->sysclk); | ||
131 | + | ||
132 | memory_region_init_rom(&s->flash, OBJECT(dev_soc), "STM32F205.flash", | ||
133 | FLASH_SIZE, &error_fatal); | ||
134 | memory_region_init_alias(&s->flash_alias, OBJECT(dev_soc), | ||
135 | @@ -XXX,XX +XXX,XX @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp) | ||
136 | qdev_prop_set_uint32(armv7m, "num-irq", 96); | ||
137 | qdev_prop_set_string(armv7m, "cpu-type", s->cpu_type); | ||
138 | qdev_prop_set_bit(armv7m, "enable-bitband", true); | ||
139 | + qdev_connect_clock_in(armv7m, "cpuclk", s->sysclk); | ||
140 | + qdev_connect_clock_in(armv7m, "refclk", s->refclk); | ||
141 | object_property_set_link(OBJECT(&s->armv7m), "memory", | ||
142 | OBJECT(get_system_memory()), &error_abort); | ||
143 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->armv7m), errp)) { | ||
144 | -- | ||
145 | 2.20.1 | ||
146 | |||
147 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Wire up the sysclk and refclk for the stm32f405 SoC. This SoC always | ||
2 | runs the systick refclk at 1/8 the frequency of the main CPU clock, | ||
3 | so the board code only needs to provide a single sysclk clock. | ||
4 | 1 | ||
5 | Because there is only one board using this SoC, we convert the SoC | ||
6 | and the board together, rather than splitting it into "add clock to | ||
7 | SoC; connect clock in board; add error check in SoC code that clock | ||
8 | is wired up". | ||
9 | |||
10 | When the systick device starts honouring its clock inputs, this will | ||
11 | fix an emulation inaccuracy in the netduinoplus2 board where the | ||
12 | systick reference clock was running at 1MHz rather than 21MHz. | ||
13 | |||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
16 | Reviewed-by: Alexandre Iooss <erdnaxe@crans.org> | ||
17 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
18 | Message-id: 20210812093356.1946-14-peter.maydell@linaro.org | ||
19 | --- | ||
20 | include/hw/arm/stm32f405_soc.h | 3 +++ | ||
21 | hw/arm/netduinoplus2.c | 12 +++++++----- | ||
22 | hw/arm/stm32f405_soc.c | 30 ++++++++++++++++++++++++++++++ | ||
23 | 3 files changed, 40 insertions(+), 5 deletions(-) | ||
24 | |||
25 | diff --git a/include/hw/arm/stm32f405_soc.h b/include/hw/arm/stm32f405_soc.h | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/include/hw/arm/stm32f405_soc.h | ||
28 | +++ b/include/hw/arm/stm32f405_soc.h | ||
29 | @@ -XXX,XX +XXX,XX @@ struct STM32F405State { | ||
30 | MemoryRegion sram; | ||
31 | MemoryRegion flash; | ||
32 | MemoryRegion flash_alias; | ||
33 | + | ||
34 | + Clock *sysclk; | ||
35 | + Clock *refclk; | ||
36 | }; | ||
37 | |||
38 | #endif | ||
39 | diff --git a/hw/arm/netduinoplus2.c b/hw/arm/netduinoplus2.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/hw/arm/netduinoplus2.c | ||
42 | +++ b/hw/arm/netduinoplus2.c | ||
43 | @@ -XXX,XX +XXX,XX @@ | ||
44 | #include "qapi/error.h" | ||
45 | #include "hw/boards.h" | ||
46 | #include "hw/qdev-properties.h" | ||
47 | +#include "hw/qdev-clock.h" | ||
48 | #include "qemu/error-report.h" | ||
49 | #include "hw/arm/stm32f405_soc.h" | ||
50 | #include "hw/arm/boot.h" | ||
51 | @@ -XXX,XX +XXX,XX @@ | ||
52 | static void netduinoplus2_init(MachineState *machine) | ||
53 | { | ||
54 | DeviceState *dev; | ||
55 | + Clock *sysclk; | ||
56 | |||
57 | - /* | ||
58 | - * TODO: ideally we would model the SoC RCC and let it handle | ||
59 | - * system_clock_scale, including its ability to define different | ||
60 | - * possible SYSCLK sources. | ||
61 | - */ | ||
62 | system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ; | ||
63 | |||
64 | + /* This clock doesn't need migration because it is fixed-frequency */ | ||
65 | + sysclk = clock_new(OBJECT(machine), "SYSCLK"); | ||
66 | + clock_set_hz(sysclk, SYSCLK_FRQ); | ||
67 | + | ||
68 | dev = qdev_new(TYPE_STM32F405_SOC); | ||
69 | qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m4")); | ||
70 | + qdev_connect_clock_in(dev, "sysclk", sysclk); | ||
71 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); | ||
72 | |||
73 | armv7m_load_kernel(ARM_CPU(first_cpu), | ||
74 | diff --git a/hw/arm/stm32f405_soc.c b/hw/arm/stm32f405_soc.c | ||
75 | index XXXXXXX..XXXXXXX 100644 | ||
76 | --- a/hw/arm/stm32f405_soc.c | ||
77 | +++ b/hw/arm/stm32f405_soc.c | ||
78 | @@ -XXX,XX +XXX,XX @@ | ||
79 | #include "exec/address-spaces.h" | ||
80 | #include "sysemu/sysemu.h" | ||
81 | #include "hw/arm/stm32f405_soc.h" | ||
82 | +#include "hw/qdev-clock.h" | ||
83 | #include "hw/misc/unimp.h" | ||
84 | |||
85 | #define SYSCFG_ADD 0x40013800 | ||
86 | @@ -XXX,XX +XXX,XX @@ static void stm32f405_soc_initfn(Object *obj) | ||
87 | } | ||
88 | |||
89 | object_initialize_child(obj, "exti", &s->exti, TYPE_STM32F4XX_EXTI); | ||
90 | + | ||
91 | + s->sysclk = qdev_init_clock_in(DEVICE(s), "sysclk", NULL, NULL, 0); | ||
92 | + s->refclk = qdev_init_clock_in(DEVICE(s), "refclk", NULL, NULL, 0); | ||
93 | } | ||
94 | |||
95 | static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp) | ||
96 | @@ -XXX,XX +XXX,XX @@ static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp) | ||
97 | Error *err = NULL; | ||
98 | int i; | ||
99 | |||
100 | + /* | ||
101 | + * We use s->refclk internally and only define it with qdev_init_clock_in() | ||
102 | + * so it is correctly parented and not leaked on an init/deinit; it is not | ||
103 | + * intended as an externally exposed clock. | ||
104 | + */ | ||
105 | + if (clock_has_source(s->refclk)) { | ||
106 | + error_setg(errp, "refclk clock must not be wired up by the board code"); | ||
107 | + return; | ||
108 | + } | ||
109 | + | ||
110 | + if (!clock_has_source(s->sysclk)) { | ||
111 | + error_setg(errp, "sysclk clock must be wired up by the board code"); | ||
112 | + return; | ||
113 | + } | ||
114 | + | ||
115 | + /* | ||
116 | + * TODO: ideally we should model the SoC RCC and its ability to | ||
117 | + * change the sysclk frequency and define different sysclk sources. | ||
118 | + */ | ||
119 | + | ||
120 | + /* The refclk always runs at frequency HCLK / 8 */ | ||
121 | + clock_set_mul_div(s->refclk, 8, 1); | ||
122 | + clock_set_source(s->refclk, s->sysclk); | ||
123 | + | ||
124 | memory_region_init_rom(&s->flash, OBJECT(dev_soc), "STM32F405.flash", | ||
125 | FLASH_SIZE, &err); | ||
126 | if (err != NULL) { | ||
127 | @@ -XXX,XX +XXX,XX @@ static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp) | ||
128 | qdev_prop_set_uint32(armv7m, "num-irq", 96); | ||
129 | qdev_prop_set_string(armv7m, "cpu-type", s->cpu_type); | ||
130 | qdev_prop_set_bit(armv7m, "enable-bitband", true); | ||
131 | + qdev_connect_clock_in(armv7m, "cpuclk", s->sysclk); | ||
132 | + qdev_connect_clock_in(armv7m, "refclk", s->refclk); | ||
133 | object_property_set_link(OBJECT(&s->armv7m), "memory", | ||
134 | OBJECT(system_memory), &error_abort); | ||
135 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->armv7m), errp)) { | ||
136 | -- | ||
137 | 2.20.1 | ||
138 | |||
139 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Delete the trailing blank line at the end of the source file. | ||
2 | 1 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Alexandre Iooss <erdnaxe@crans.org> | ||
5 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
6 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
7 | Message-id: 20210812093356.1946-15-peter.maydell@linaro.org | ||
8 | --- | ||
9 | hw/arm/stm32vldiscovery.c | 1 - | ||
10 | 1 file changed, 1 deletion(-) | ||
11 | |||
12 | diff --git a/hw/arm/stm32vldiscovery.c b/hw/arm/stm32vldiscovery.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/hw/arm/stm32vldiscovery.c | ||
15 | +++ b/hw/arm/stm32vldiscovery.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static void stm32vldiscovery_machine_init(MachineClass *mc) | ||
17 | } | ||
18 | |||
19 | DEFINE_MACHINE("stm32vldiscovery", stm32vldiscovery_machine_init) | ||
20 | - | ||
21 | -- | ||
22 | 2.20.1 | ||
23 | |||
24 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Currently the stellaris_sys_init() function creates the | ||
2 | TYPE_STELLARIS_SYS object, sets its properties, realizes it, maps its | ||
3 | MMIO region and connects its IRQ. In order to support wiring the | ||
4 | sysclk up to the armv7m object, we need to split this function apart, | ||
5 | because to connect the clock output of the STELLARIS_SYS object to | ||
6 | the armv7m object we need to create the STELLARIS_SYS object before | ||
7 | the armv7m object, but we can't wire up the IRQ until after we've | ||
8 | created the armv7m object. | ||
9 | 1 | ||
10 | Remove the stellaris_sys_init() function, and instead put the | ||
11 | create/configure/realize parts before we create the armv7m object and | ||
12 | the mmio/irq connection parts afterwards. | ||
13 | |||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Reviewed-by: Alexandre Iooss <erdnaxe@crans.org> | ||
16 | Message-id: 20210812093356.1946-17-peter.maydell@linaro.org | ||
17 | --- | ||
18 | hw/arm/stellaris.c | 56 +++++++++++++++++++++------------------------- | ||
19 | 1 file changed, 25 insertions(+), 31 deletions(-) | ||
20 | |||
21 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/hw/arm/stellaris.c | ||
24 | +++ b/hw/arm/stellaris.c | ||
25 | @@ -XXX,XX +XXX,XX @@ static void stellaris_sys_instance_init(Object *obj) | ||
26 | s->sysclk = qdev_init_clock_out(DEVICE(s), "SYSCLK"); | ||
27 | } | ||
28 | |||
29 | -static DeviceState *stellaris_sys_init(uint32_t base, qemu_irq irq, | ||
30 | - stellaris_board_info *board, | ||
31 | - uint8_t *macaddr) | ||
32 | -{ | ||
33 | - DeviceState *dev = qdev_new(TYPE_STELLARIS_SYS); | ||
34 | - SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
35 | - | ||
36 | - /* Most devices come preprogrammed with a MAC address in the user data. */ | ||
37 | - qdev_prop_set_uint32(dev, "user0", | ||
38 | - macaddr[0] | (macaddr[1] << 8) | (macaddr[2] << 16)); | ||
39 | - qdev_prop_set_uint32(dev, "user1", | ||
40 | - macaddr[3] | (macaddr[4] << 8) | (macaddr[5] << 16)); | ||
41 | - qdev_prop_set_uint32(dev, "did0", board->did0); | ||
42 | - qdev_prop_set_uint32(dev, "did1", board->did1); | ||
43 | - qdev_prop_set_uint32(dev, "dc0", board->dc0); | ||
44 | - qdev_prop_set_uint32(dev, "dc1", board->dc1); | ||
45 | - qdev_prop_set_uint32(dev, "dc2", board->dc2); | ||
46 | - qdev_prop_set_uint32(dev, "dc3", board->dc3); | ||
47 | - qdev_prop_set_uint32(dev, "dc4", board->dc4); | ||
48 | - | ||
49 | - sysbus_realize_and_unref(sbd, &error_fatal); | ||
50 | - sysbus_mmio_map(sbd, 0, base); | ||
51 | - sysbus_connect_irq(sbd, 0, irq); | ||
52 | - | ||
53 | - return dev; | ||
54 | -} | ||
55 | - | ||
56 | /* I2C controller. */ | ||
57 | |||
58 | #define TYPE_STELLARIS_I2C "stellaris-i2c" | ||
59 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
60 | DeviceState *ssys_dev; | ||
61 | int i; | ||
62 | int j; | ||
63 | + uint8_t *macaddr; | ||
64 | |||
65 | MemoryRegion *sram = g_new(MemoryRegion, 1); | ||
66 | MemoryRegion *flash = g_new(MemoryRegion, 1); | ||
67 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
68 | &error_fatal); | ||
69 | memory_region_add_subregion(system_memory, 0x20000000, sram); | ||
70 | |||
71 | + /* | ||
72 | + * Create the system-registers object early, because we will | ||
73 | + * need its sysclk output. | ||
74 | + */ | ||
75 | + ssys_dev = qdev_new(TYPE_STELLARIS_SYS); | ||
76 | + /* Most devices come preprogrammed with a MAC address in the user data. */ | ||
77 | + macaddr = nd_table[0].macaddr.a; | ||
78 | + qdev_prop_set_uint32(ssys_dev, "user0", | ||
79 | + macaddr[0] | (macaddr[1] << 8) | (macaddr[2] << 16)); | ||
80 | + qdev_prop_set_uint32(ssys_dev, "user1", | ||
81 | + macaddr[3] | (macaddr[4] << 8) | (macaddr[5] << 16)); | ||
82 | + qdev_prop_set_uint32(ssys_dev, "did0", board->did0); | ||
83 | + qdev_prop_set_uint32(ssys_dev, "did1", board->did1); | ||
84 | + qdev_prop_set_uint32(ssys_dev, "dc0", board->dc0); | ||
85 | + qdev_prop_set_uint32(ssys_dev, "dc1", board->dc1); | ||
86 | + qdev_prop_set_uint32(ssys_dev, "dc2", board->dc2); | ||
87 | + qdev_prop_set_uint32(ssys_dev, "dc3", board->dc3); | ||
88 | + qdev_prop_set_uint32(ssys_dev, "dc4", board->dc4); | ||
89 | + sysbus_realize_and_unref(SYS_BUS_DEVICE(ssys_dev), &error_fatal); | ||
90 | + | ||
91 | nvic = qdev_new(TYPE_ARMV7M); | ||
92 | qdev_prop_set_uint32(nvic, "num-irq", NUM_IRQ_LINES); | ||
93 | qdev_prop_set_string(nvic, "cpu-type", ms->cpu_type); | ||
94 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
95 | /* This will exit with an error if the user passed us a bad cpu_type */ | ||
96 | sysbus_realize_and_unref(SYS_BUS_DEVICE(nvic), &error_fatal); | ||
97 | |||
98 | + /* Now we can wire up the IRQ and MMIO of the system registers */ | ||
99 | + sysbus_mmio_map(SYS_BUS_DEVICE(ssys_dev), 0, 0x400fe000); | ||
100 | + sysbus_connect_irq(SYS_BUS_DEVICE(ssys_dev), 0, qdev_get_gpio_in(nvic, 28)); | ||
101 | + | ||
102 | if (board->dc1 & (1 << 16)) { | ||
103 | dev = sysbus_create_varargs(TYPE_STELLARIS_ADC, 0x40038000, | ||
104 | qdev_get_gpio_in(nvic, 14), | ||
105 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
106 | } | ||
107 | } | ||
108 | |||
109 | - ssys_dev = stellaris_sys_init(0x400fe000, qdev_get_gpio_in(nvic, 28), | ||
110 | - board, nd_table[0].macaddr.a); | ||
111 | - | ||
112 | - | ||
113 | if (board->dc1 & (1 << 3)) { /* watchdog present */ | ||
114 | dev = qdev_new(TYPE_LUMINARY_WATCHDOG); | ||
115 | |||
116 | -- | ||
117 | 2.20.1 | ||
118 | |||
119 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Connect the sysclk to the armv7m object. This board's SoC does not | ||
2 | connect up the systick reference clock, so we don't need to connect a | ||
3 | refclk. | ||
4 | 1 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Alexandre Iooss <erdnaxe@crans.org> | ||
7 | Message-id: 20210812093356.1946-18-peter.maydell@linaro.org | ||
8 | --- | ||
9 | hw/arm/stellaris.c | 5 ++++- | ||
10 | 1 file changed, 4 insertions(+), 1 deletion(-) | ||
11 | |||
12 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/hw/arm/stellaris.c | ||
15 | +++ b/hw/arm/stellaris.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
17 | DeviceState *ssys_dev; | ||
18 | int i; | ||
19 | int j; | ||
20 | - uint8_t *macaddr; | ||
21 | + const uint8_t *macaddr; | ||
22 | |||
23 | MemoryRegion *sram = g_new(MemoryRegion, 1); | ||
24 | MemoryRegion *flash = g_new(MemoryRegion, 1); | ||
25 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
26 | qdev_prop_set_uint32(nvic, "num-irq", NUM_IRQ_LINES); | ||
27 | qdev_prop_set_string(nvic, "cpu-type", ms->cpu_type); | ||
28 | qdev_prop_set_bit(nvic, "enable-bitband", true); | ||
29 | + qdev_connect_clock_in(nvic, "cpuclk", | ||
30 | + qdev_get_clock_out(ssys_dev, "SYSCLK")); | ||
31 | + /* This SoC does not connect the systick reference clock */ | ||
32 | object_property_set_link(OBJECT(nvic), "memory", | ||
33 | OBJECT(get_system_memory()), &error_abort); | ||
34 | /* This will exit with an error if the user passed us a bad cpu_type */ | ||
35 | -- | ||
36 | 2.20.1 | ||
37 | |||
38 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | In the realize method of the msf2-soc SoC object, we call g_new() to | ||
2 | create new MemoryRegion objects for the nvm, nvm_alias, and sram. | ||
3 | This is unnecessary; make these MemoryRegions member fields of the | ||
4 | device state struct instead. | ||
5 | 1 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Alexandre Iooss <erdnaxe@crans.org> | ||
8 | Message-id: 20210812093356.1946-19-peter.maydell@linaro.org | ||
9 | --- | ||
10 | include/hw/arm/msf2-soc.h | 4 ++++ | ||
11 | hw/arm/msf2-soc.c | 17 +++++++---------- | ||
12 | 2 files changed, 11 insertions(+), 10 deletions(-) | ||
13 | |||
14 | diff --git a/include/hw/arm/msf2-soc.h b/include/hw/arm/msf2-soc.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/include/hw/arm/msf2-soc.h | ||
17 | +++ b/include/hw/arm/msf2-soc.h | ||
18 | @@ -XXX,XX +XXX,XX @@ struct MSF2State { | ||
19 | MSSTimerState timer; | ||
20 | MSSSpiState spi[MSF2_NUM_SPIS]; | ||
21 | MSF2EmacState emac; | ||
22 | + | ||
23 | + MemoryRegion nvm; | ||
24 | + MemoryRegion nvm_alias; | ||
25 | + MemoryRegion sram; | ||
26 | }; | ||
27 | |||
28 | #endif | ||
29 | diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/hw/arm/msf2-soc.c | ||
32 | +++ b/hw/arm/msf2-soc.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp) | ||
34 | int i; | ||
35 | |||
36 | MemoryRegion *system_memory = get_system_memory(); | ||
37 | - MemoryRegion *nvm = g_new(MemoryRegion, 1); | ||
38 | - MemoryRegion *nvm_alias = g_new(MemoryRegion, 1); | ||
39 | - MemoryRegion *sram = g_new(MemoryRegion, 1); | ||
40 | |||
41 | - memory_region_init_rom(nvm, OBJECT(dev_soc), "MSF2.eNVM", s->envm_size, | ||
42 | + memory_region_init_rom(&s->nvm, OBJECT(dev_soc), "MSF2.eNVM", s->envm_size, | ||
43 | &error_fatal); | ||
44 | /* | ||
45 | * On power-on, the eNVM region 0x60000000 is automatically | ||
46 | @@ -XXX,XX +XXX,XX @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp) | ||
47 | * start address (0x0). We do not support remapping other eNVM, | ||
48 | * eSRAM and DDR regions by guest(via Sysreg) currently. | ||
49 | */ | ||
50 | - memory_region_init_alias(nvm_alias, OBJECT(dev_soc), "MSF2.eNVM", nvm, 0, | ||
51 | - s->envm_size); | ||
52 | + memory_region_init_alias(&s->nvm_alias, OBJECT(dev_soc), "MSF2.eNVM", | ||
53 | + &s->nvm, 0, s->envm_size); | ||
54 | |||
55 | - memory_region_add_subregion(system_memory, ENVM_BASE_ADDRESS, nvm); | ||
56 | - memory_region_add_subregion(system_memory, 0, nvm_alias); | ||
57 | + memory_region_add_subregion(system_memory, ENVM_BASE_ADDRESS, &s->nvm); | ||
58 | + memory_region_add_subregion(system_memory, 0, &s->nvm_alias); | ||
59 | |||
60 | - memory_region_init_ram(sram, NULL, "MSF2.eSRAM", s->esram_size, | ||
61 | + memory_region_init_ram(&s->sram, NULL, "MSF2.eSRAM", s->esram_size, | ||
62 | &error_fatal); | ||
63 | - memory_region_add_subregion(system_memory, SRAM_BASE_ADDRESS, sram); | ||
64 | + memory_region_add_subregion(system_memory, SRAM_BASE_ADDRESS, &s->sram); | ||
65 | |||
66 | armv7m = DEVICE(&s->armv7m); | ||
67 | qdev_prop_set_uint32(armv7m, "num-irq", 81); | ||
68 | -- | ||
69 | 2.20.1 | ||
70 | |||
71 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Fix the code style issues in the Stellaris general purpose timer | ||
2 | module code, so that when we move it to a different file in a | ||
3 | following patch checkpatch doesn't complain. | ||
4 | 1 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Alexandre Iooss <erdnaxe@crans.org> | ||
7 | Message-id: 20210812093356.1946-23-peter.maydell@linaro.org | ||
8 | --- | ||
9 | hw/arm/stellaris.c | 13 ++++++++----- | ||
10 | 1 file changed, 8 insertions(+), 5 deletions(-) | ||
11 | |||
12 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/hw/arm/stellaris.c | ||
15 | +++ b/hw/arm/stellaris.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static void gptm_stop(gptm_state *s, int n) | ||
17 | static void gptm_reload(gptm_state *s, int n, int reset) | ||
18 | { | ||
19 | int64_t tick; | ||
20 | - if (reset) | ||
21 | + if (reset) { | ||
22 | tick = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | ||
23 | - else | ||
24 | + } else { | ||
25 | tick = s->tick[n]; | ||
26 | + } | ||
27 | |||
28 | if (s->config == 0) { | ||
29 | /* 32-bit CountDown. */ | ||
30 | @@ -XXX,XX +XXX,XX @@ static void gptm_write(void *opaque, hwaddr offset, | ||
31 | gptm_state *s = (gptm_state *)opaque; | ||
32 | uint32_t oldval; | ||
33 | |||
34 | - /* The timers should be disabled before changing the configuration. | ||
35 | - We take advantage of this and defer everything until the timer | ||
36 | - is enabled. */ | ||
37 | + /* | ||
38 | + * The timers should be disabled before changing the configuration. | ||
39 | + * We take advantage of this and defer everything until the timer | ||
40 | + * is enabled. | ||
41 | + */ | ||
42 | switch (offset) { | ||
43 | case 0x00: /* CFG */ | ||
44 | s->config = value; | ||
45 | -- | ||
46 | 2.20.1 | ||
47 | |||
48 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The stellaris-gptm timer currently uses system_clock_scale for one of | ||
2 | its timer modes where the timer runs at the CPU clock rate. Make it | ||
3 | use a Clock input instead. | ||
4 | 1 | ||
5 | We don't try to make the timer handle changes in the clock frequency | ||
6 | while the downcounter is running. This is not a change in behaviour | ||
7 | from the previous system_clock_scale implementation -- we will pick | ||
8 | up the new frequency only when the downcounter hits zero. Handling | ||
9 | dynamic clock changes when the counter is running would require state | ||
10 | that the current gptm implementation doesn't have. | ||
11 | |||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Reviewed-by: Damien Hedde <damien.hedde@greensocs.com> | ||
14 | Message-id: 20210812093356.1946-25-peter.maydell@linaro.org | ||
15 | --- | ||
16 | include/hw/timer/stellaris-gptm.h | 3 +++ | ||
17 | hw/arm/stellaris.c | 12 +++++++++--- | ||
18 | hw/timer/stellaris-gptm.c | 26 ++++++++++++++++++++++---- | ||
19 | 3 files changed, 34 insertions(+), 7 deletions(-) | ||
20 | |||
21 | diff --git a/include/hw/timer/stellaris-gptm.h b/include/hw/timer/stellaris-gptm.h | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/include/hw/timer/stellaris-gptm.h | ||
24 | +++ b/include/hw/timer/stellaris-gptm.h | ||
25 | @@ -XXX,XX +XXX,XX @@ | ||
26 | #include "qom/object.h" | ||
27 | #include "hw/sysbus.h" | ||
28 | #include "hw/irq.h" | ||
29 | +#include "hw/clock.h" | ||
30 | |||
31 | #define TYPE_STELLARIS_GPTM "stellaris-gptm" | ||
32 | OBJECT_DECLARE_SIMPLE_TYPE(gptm_state, STELLARIS_GPTM) | ||
33 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(gptm_state, STELLARIS_GPTM) | ||
34 | * + sysbus MMIO region 0: register bank | ||
35 | * + sysbus IRQ 0: timer interrupt | ||
36 | * + unnamed GPIO output 0: trigger output for the ADC | ||
37 | + * + Clock input "clk": the 32-bit countdown timer runs at this speed | ||
38 | */ | ||
39 | struct gptm_state { | ||
40 | SysBusDevice parent_obj; | ||
41 | @@ -XXX,XX +XXX,XX @@ struct gptm_state { | ||
42 | /* The timers have an alternate output used to trigger the ADC. */ | ||
43 | qemu_irq trigger; | ||
44 | qemu_irq irq; | ||
45 | + Clock *clk; | ||
46 | }; | ||
47 | |||
48 | #endif | ||
49 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/hw/arm/stellaris.c | ||
52 | +++ b/hw/arm/stellaris.c | ||
53 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
54 | } | ||
55 | for (i = 0; i < 4; i++) { | ||
56 | if (board->dc2 & (0x10000 << i)) { | ||
57 | - dev = sysbus_create_simple(TYPE_STELLARIS_GPTM, | ||
58 | - 0x40030000 + i * 0x1000, | ||
59 | - qdev_get_gpio_in(nvic, timer_irq[i])); | ||
60 | + SysBusDevice *sbd; | ||
61 | + | ||
62 | + dev = qdev_new(TYPE_STELLARIS_GPTM); | ||
63 | + sbd = SYS_BUS_DEVICE(dev); | ||
64 | + qdev_connect_clock_in(dev, "clk", | ||
65 | + qdev_get_clock_out(ssys_dev, "SYSCLK")); | ||
66 | + sysbus_realize_and_unref(sbd, &error_fatal); | ||
67 | + sysbus_mmio_map(sbd, 0, 0x40030000 + i * 0x1000); | ||
68 | + sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(nvic, timer_irq[i])); | ||
69 | /* TODO: This is incorrect, but we get away with it because | ||
70 | the ADC output is only ever pulsed. */ | ||
71 | qdev_connect_gpio_out(dev, 0, adc); | ||
72 | diff --git a/hw/timer/stellaris-gptm.c b/hw/timer/stellaris-gptm.c | ||
73 | index XXXXXXX..XXXXXXX 100644 | ||
74 | --- a/hw/timer/stellaris-gptm.c | ||
75 | +++ b/hw/timer/stellaris-gptm.c | ||
76 | @@ -XXX,XX +XXX,XX @@ | ||
77 | #include "qemu/osdep.h" | ||
78 | #include "qemu/log.h" | ||
79 | #include "qemu/timer.h" | ||
80 | +#include "qapi/error.h" | ||
81 | #include "migration/vmstate.h" | ||
82 | +#include "hw/qdev-clock.h" | ||
83 | #include "hw/timer/stellaris-gptm.h" | ||
84 | -#include "hw/timer/armv7m_systick.h" /* Needed only for system_clock_scale */ | ||
85 | |||
86 | static void gptm_update_irq(gptm_state *s) | ||
87 | { | ||
88 | @@ -XXX,XX +XXX,XX @@ static void gptm_reload(gptm_state *s, int n, int reset) | ||
89 | /* 32-bit CountDown. */ | ||
90 | uint32_t count; | ||
91 | count = s->load[0] | (s->load[1] << 16); | ||
92 | - tick += (int64_t)count * system_clock_scale; | ||
93 | + tick += clock_ticks_to_ns(s->clk, count); | ||
94 | } else if (s->config == 1) { | ||
95 | /* 32-bit RTC. 1Hz tick. */ | ||
96 | tick += NANOSECONDS_PER_SECOND; | ||
97 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps gptm_ops = { | ||
98 | |||
99 | static const VMStateDescription vmstate_stellaris_gptm = { | ||
100 | .name = "stellaris_gptm", | ||
101 | - .version_id = 1, | ||
102 | - .minimum_version_id = 1, | ||
103 | + .version_id = 2, | ||
104 | + .minimum_version_id = 2, | ||
105 | .fields = (VMStateField[]) { | ||
106 | VMSTATE_UINT32(config, gptm_state), | ||
107 | VMSTATE_UINT32_ARRAY(mode, gptm_state, 2), | ||
108 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_stellaris_gptm = { | ||
109 | VMSTATE_UINT32(rtc, gptm_state), | ||
110 | VMSTATE_INT64_ARRAY(tick, gptm_state, 2), | ||
111 | VMSTATE_TIMER_PTR_ARRAY(timer, gptm_state, 2), | ||
112 | + VMSTATE_CLOCK(clk, gptm_state), | ||
113 | VMSTATE_END_OF_LIST() | ||
114 | } | ||
115 | }; | ||
116 | @@ -XXX,XX +XXX,XX @@ static void stellaris_gptm_init(Object *obj) | ||
117 | sysbus_init_mmio(sbd, &s->iomem); | ||
118 | |||
119 | s->opaque[0] = s->opaque[1] = s; | ||
120 | + | ||
121 | + /* | ||
122 | + * TODO: in an ideal world we would model the effects of changing | ||
123 | + * the input clock frequency while the countdown timer is active. | ||
124 | + * The best way to do this would be to convert the device to use | ||
125 | + * ptimer instead of hand-rolling its own timer. This would also | ||
126 | + * make it easy to implement reading the current count from the | ||
127 | + * TAR and TBR registers. | ||
128 | + */ | ||
129 | + s->clk = qdev_init_clock_in(dev, "clk", NULL, NULL, 0); | ||
130 | } | ||
131 | |||
132 | static void stellaris_gptm_realize(DeviceState *dev, Error **errp) | ||
133 | { | ||
134 | gptm_state *s = STELLARIS_GPTM(dev); | ||
135 | + | ||
136 | + if (!clock_has_source(s->clk)) { | ||
137 | + error_setg(errp, "stellaris-gptm: clk must be connected"); | ||
138 | + return; | ||
139 | + } | ||
140 | + | ||
141 | s->timer[0] = timer_new_ns(QEMU_CLOCK_VIRTUAL, gptm_tick, &s->opaque[0]); | ||
142 | s->timer[1] = timer_new_ns(QEMU_CLOCK_VIRTUAL, gptm_tick, &s->opaque[1]); | ||
143 | } | ||
144 | -- | ||
145 | 2.20.1 | ||
146 | |||
147 | diff view generated by jsdifflib |
1 | All the devices that used to use system_clock_scale have now been | 1 | The qemu-ga documentation is currently in qemu-ga.texi in |
---|---|---|---|
2 | converted to use Clock inputs instead, so the global is no longer | 2 | Texinfo format, which we present to the user as: |
3 | needed; remove it and all the code that sets it. | 3 | * a qemu-ga manpage |
4 | * a section of the main qemu-doc HTML documentation | ||
5 | |||
6 | Convert the documentation to rST format, and present it to | ||
7 | the user as: | ||
8 | * a qemu-ga manpage | ||
9 | * part of the interop/ Sphinx manual | ||
4 | 10 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 12 | Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> |
7 | Message-id: 20210812093356.1946-26-peter.maydell@linaro.org | 13 | Tested-by: Michael Roth <mdroth@linux.vnet.ibm.com> |
14 | Message-id: 20190905131040.8350-1-peter.maydell@linaro.org | ||
8 | --- | 15 | --- |
9 | include/hw/timer/armv7m_systick.h | 22 ---------------------- | 16 | Makefile | 24 ++++--- |
10 | hw/arm/armsse.c | 17 +---------------- | 17 | MAINTAINERS | 2 +- |
11 | hw/arm/mps2.c | 2 -- | 18 | docs/conf.py | 18 ++--- |
12 | hw/arm/msf2-soc.c | 2 -- | 19 | docs/interop/conf.py | 7 ++ |
13 | hw/arm/netduino2.c | 2 -- | 20 | docs/interop/index.rst | 1 + |
14 | hw/arm/netduinoplus2.c | 2 -- | 21 | docs/interop/qemu-ga.rst | 133 +++++++++++++++++++++++++++++++++++++ |
15 | hw/arm/nrf51_soc.c | 2 -- | 22 | qemu-doc.texi | 5 -- |
16 | hw/arm/stellaris.c | 7 ++++--- | 23 | qemu-ga.texi | 137 --------------------------------------- |
17 | hw/arm/stm32vldiscovery.c | 2 -- | 24 | 8 files changed, 166 insertions(+), 161 deletions(-) |
18 | hw/timer/armv7m_systick.c | 2 -- | 25 | create mode 100644 docs/interop/qemu-ga.rst |
19 | 10 files changed, 5 insertions(+), 55 deletions(-) | 26 | delete mode 100644 qemu-ga.texi |
20 | 27 | ||
21 | diff --git a/include/hw/timer/armv7m_systick.h b/include/hw/timer/armv7m_systick.h | 28 | diff --git a/Makefile b/Makefile |
22 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/include/hw/timer/armv7m_systick.h | 30 | --- a/Makefile |
24 | +++ b/include/hw/timer/armv7m_systick.h | 31 | +++ b/Makefile |
25 | @@ -XXX,XX +XXX,XX @@ struct SysTickState { | 32 | @@ -XXX,XX +XXX,XX @@ endif |
26 | Clock *cpuclk; | 33 | endif |
27 | }; | 34 | |
28 | 35 | ifdef BUILD_DOCS | |
29 | -/* | 36 | -DOCS=qemu-doc.html qemu-doc.txt qemu.1 qemu-img.1 qemu-nbd.8 qemu-ga.8 |
30 | - * Multiplication factor to convert from system clock ticks to qemu timer | 37 | +DOCS=qemu-doc.html qemu-doc.txt qemu.1 qemu-img.1 qemu-nbd.8 docs/interop/qemu-ga.8 |
31 | - * ticks. This should be set (by board code, usually) to a value | 38 | DOCS+=docs/interop/qemu-qmp-ref.html docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7 |
32 | - * equal to NANOSECONDS_PER_SECOND / frq, where frq is the clock frequency | 39 | DOCS+=docs/interop/qemu-ga-ref.html docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7 |
33 | - * in Hz of the CPU. | 40 | DOCS+=docs/qemu-block-drivers.7 |
34 | - * | 41 | @@ -XXX,XX +XXX,XX @@ DESCS= |
35 | - * This value is used by the systick device when it is running in | 42 | endif |
36 | - * its "use the CPU clock" mode (ie when SYST_CSR.CLKSOURCE == 1) to | 43 | |
37 | - * set how fast the timer should tick. | 44 | # Note that we manually filter-out the non-Sphinx documentation which |
38 | - * | 45 | -# is currently built into the docs/interop directory in the build tree. |
39 | - * TODO: we should refactor this so that rather than using a global | 46 | +# is currently built into the docs/interop directory in the build tree, |
40 | - * we use a device property or something similar. This is complicated | 47 | +# and also any sphinx-built manpages. |
41 | - * because (a) the property would need to be plumbed through from the | 48 | define install-manual = |
42 | - * board code down through various layers to the systick device | 49 | for d in $$(cd $(MANUAL_BUILDDIR) && find $1 -type d); do $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/$$d"; done |
43 | - * and (b) the property needs to be modifiable after realize, because | 50 | -for f in $$(cd $(MANUAL_BUILDDIR) && find $1 -type f -a '!' '(' -name 'qemu-*-qapi.*' -o -name 'qemu-*-ref.*' ')' ); do $(INSTALL_DATA) "$(MANUAL_BUILDDIR)/$$f" "$(DESTDIR)$(qemu_docdir)/$$f"; done |
44 | - * the stellaris board uses this to implement the behaviour where the | 51 | +for f in $$(cd $(MANUAL_BUILDDIR) && find $1 -type f -a '!' '(' -name '*.[0-9]' -o -name 'qemu-*-qapi.*' -o -name 'qemu-*-ref.*' ')' ); do $(INSTALL_DATA) "$(MANUAL_BUILDDIR)/$$f" "$(DESTDIR)$(qemu_docdir)/$$f"; done |
45 | - * guest can reprogram the PLL registers to downclock the CPU, and the | 52 | endef |
46 | - * systick device needs to react accordingly. Possibly this should | 53 | |
47 | - * be deferred until we have a good API for modelling clock trees. | 54 | # Note that we deliberately do not install the "devel" manual: it is |
48 | - */ | 55 | @@ -XXX,XX +XXX,XX @@ ifdef CONFIG_TRACE_SYSTEMTAP |
49 | -extern int system_clock_scale; | 56 | $(INSTALL_DATA) scripts/qemu-trace-stap.1 "$(DESTDIR)$(mandir)/man1" |
50 | - | 57 | endif |
51 | #endif | 58 | ifneq (,$(findstring qemu-ga,$(TOOLS))) |
52 | diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c | 59 | - $(INSTALL_DATA) qemu-ga.8 "$(DESTDIR)$(mandir)/man8" |
53 | index XXXXXXX..XXXXXXX 100644 | 60 | + $(INSTALL_DATA) docs/interop/qemu-ga.8 "$(DESTDIR)$(mandir)/man8" |
54 | --- a/hw/arm/armsse.c | 61 | $(INSTALL_DATA) docs/interop/qemu-ga-ref.html "$(DESTDIR)$(qemu_docdir)" |
55 | +++ b/hw/arm/armsse.c | 62 | $(INSTALL_DATA) docs/interop/qemu-ga-ref.txt "$(DESTDIR)$(qemu_docdir)" |
56 | @@ -XXX,XX +XXX,XX @@ static void armsse_forward_sec_resp_cfg(ARMSSE *s) | 63 | $(INSTALL_DATA) docs/interop/qemu-ga-ref.7 "$(DESTDIR)$(mandir)/man7" |
57 | qdev_connect_gpio_out(dev_splitter, 2, s->sec_resp_cfg_in); | 64 | @@ -XXX,XX +XXX,XX @@ docs/version.texi: $(SRC_PATH)/VERSION config-host.mak |
58 | } | 65 | sphinxdocs: $(MANUAL_BUILDDIR)/devel/index.html $(MANUAL_BUILDDIR)/interop/index.html $(MANUAL_BUILDDIR)/specs/index.html |
59 | 66 | ||
60 | -static void armsse_mainclk_update(void *opaque, ClockEvent event) | 67 | # Canned command to build a single manual |
61 | -{ | 68 | -build-manual = $(call quiet-command,sphinx-build $(if $(V),,-q) -W -n -b html -D version=$(VERSION) -D release="$(FULL_VERSION)" -d .doctrees/$1 $(SRC_PATH)/docs/$1 $(MANUAL_BUILDDIR)/$1 ,"SPHINX","$(MANUAL_BUILDDIR)/$1") |
62 | - ARMSSE *s = ARM_SSE(opaque); | 69 | +# Arguments: $1 = manual name, $2 = Sphinx builder ('html' or 'man') |
63 | - | 70 | +build-manual = $(call quiet-command,CONFDIR="$(qemu_confdir)" sphinx-build $(if $(V),,-q) -W -n -b $2 -D version=$(VERSION) -D release="$(FULL_VERSION)" -d .doctrees/$1 $(SRC_PATH)/docs/$1 $(MANUAL_BUILDDIR)/$1 ,"SPHINX","$(MANUAL_BUILDDIR)/$1") |
64 | - /* | 71 | # We assume all RST files in the manual's directory are used in it |
65 | - * Set system_clock_scale from our Clock input; this is what | 72 | manual-deps = $(wildcard $(SRC_PATH)/docs/$1/*.rst) $(SRC_PATH)/docs/$1/conf.py $(SRC_PATH)/docs/conf.py |
66 | - * controls the tick rate of the CPU SysTick timer. | 73 | |
67 | - */ | 74 | $(MANUAL_BUILDDIR)/devel/index.html: $(call manual-deps,devel) |
68 | - system_clock_scale = clock_ticks_to_ns(s->mainclk, 1); | 75 | - $(call build-manual,devel) |
69 | -} | 76 | + $(call build-manual,devel,html) |
70 | - | 77 | |
71 | static void armsse_init(Object *obj) | 78 | $(MANUAL_BUILDDIR)/interop/index.html: $(call manual-deps,interop) |
72 | { | 79 | - $(call build-manual,interop) |
73 | ARMSSE *s = ARM_SSE(obj); | 80 | + $(call build-manual,interop,html) |
74 | @@ -XXX,XX +XXX,XX @@ static void armsse_init(Object *obj) | 81 | |
75 | assert(info->sram_banks <= MAX_SRAM_BANKS); | 82 | $(MANUAL_BUILDDIR)/specs/index.html: $(call manual-deps,specs) |
76 | assert(info->num_cpus <= SSE_MAX_CPUS); | 83 | - $(call build-manual,specs) |
77 | 84 | + $(call build-manual,specs,html) | |
78 | - s->mainclk = qdev_init_clock_in(DEVICE(s), "MAINCLK", | 85 | + |
79 | - armsse_mainclk_update, s, ClockUpdate); | 86 | +$(MANUAL_BUILDDIR)/interop/qemu-ga.8: $(call manual-deps,interop) |
80 | + s->mainclk = qdev_init_clock_in(DEVICE(s), "MAINCLK", NULL, NULL, 0); | 87 | + $(call build-manual,interop,man) |
81 | s->s32kclk = qdev_init_clock_in(DEVICE(s), "S32KCLK", NULL, NULL, 0); | 88 | |
82 | 89 | qemu-options.texi: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool | |
83 | memory_region_init(&s->container, obj, "armsse-container", UINT64_MAX); | 90 | $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@") |
84 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) | 91 | @@ -XXX,XX +XXX,XX @@ qemu.1: qemu-option-trace.texi |
85 | * devices in the ARMSSE. | 92 | qemu-img.1: qemu-img.texi qemu-option-trace.texi qemu-img-cmds.texi |
86 | */ | 93 | fsdev/virtfs-proxy-helper.1: fsdev/virtfs-proxy-helper.texi |
87 | sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->container); | 94 | qemu-nbd.8: qemu-nbd.texi qemu-option-trace.texi |
88 | - | 95 | -qemu-ga.8: qemu-ga.texi |
89 | - /* Set initial system_clock_scale from MAINCLK */ | 96 | docs/qemu-block-drivers.7: docs/qemu-block-drivers.texi |
90 | - armsse_mainclk_update(s, ClockUpdate); | 97 | docs/qemu-cpu-models.7: docs/qemu-cpu-models.texi |
91 | } | 98 | scripts/qemu-trace-stap.1: scripts/qemu-trace-stap.texi |
92 | 99 | @@ -XXX,XX +XXX,XX @@ txt: qemu-doc.txt docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt | |
93 | static void armsse_idau_check(IDAUInterface *ii, uint32_t address, | 100 | qemu-doc.html qemu-doc.info qemu-doc.pdf qemu-doc.txt: \ |
94 | diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c | 101 | qemu-img.texi qemu-nbd.texi qemu-options.texi \ |
95 | index XXXXXXX..XXXXXXX 100644 | 102 | qemu-tech.texi qemu-option-trace.texi \ |
96 | --- a/hw/arm/mps2.c | 103 | - qemu-deprecated.texi qemu-monitor.texi qemu-img-cmds.texi qemu-ga.texi \ |
97 | +++ b/hw/arm/mps2.c | 104 | + qemu-deprecated.texi qemu-monitor.texi qemu-img-cmds.texi \ |
98 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) | 105 | qemu-monitor-info.texi docs/qemu-block-drivers.texi \ |
99 | qdev_get_gpio_in(armv7m, | 106 | docs/qemu-cpu-models.texi docs/security.texi |
100 | mmc->fpga_type == FPGA_AN511 ? 47 : 13)); | 107 | |
101 | 108 | diff --git a/MAINTAINERS b/MAINTAINERS | |
102 | - system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ; | 109 | index XXXXXXX..XXXXXXX 100644 |
103 | - | 110 | --- a/MAINTAINERS |
104 | armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, | 111 | +++ b/MAINTAINERS |
105 | 0x400000); | 112 | @@ -XXX,XX +XXX,XX @@ QEMU Guest Agent |
106 | } | 113 | M: Michael Roth <mdroth@linux.vnet.ibm.com> |
107 | diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c | 114 | S: Maintained |
108 | index XXXXXXX..XXXXXXX 100644 | 115 | F: qga/ |
109 | --- a/hw/arm/msf2-soc.c | 116 | -F: qemu-ga.texi |
110 | +++ b/hw/arm/msf2-soc.c | 117 | +F: docs/interop/qemu-ga.rst |
111 | @@ -XXX,XX +XXX,XX @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp) | 118 | F: scripts/qemu-guest-agent/ |
112 | return; | 119 | F: tests/test-qga.c |
113 | } | 120 | F: docs/interop/qemu-ga-ref.texi |
114 | 121 | diff --git a/docs/conf.py b/docs/conf.py | |
115 | - system_clock_scale = clock_ticks_to_ns(s->m3clk, 1); | 122 | index XXXXXXX..XXXXXXX 100644 |
116 | - | 123 | --- a/docs/conf.py |
117 | for (i = 0; i < MSF2_NUM_UARTS; i++) { | 124 | +++ b/docs/conf.py |
118 | if (serial_hd(i)) { | 125 | @@ -XXX,XX +XXX,XX @@ todo_include_todos = False |
119 | serial_mm_init(get_system_memory(), uart_addr[i], 2, | 126 | # with "option::" in the document being processed. Turn that off. |
120 | diff --git a/hw/arm/netduino2.c b/hw/arm/netduino2.c | 127 | suppress_warnings = ["ref.option"] |
121 | index XXXXXXX..XXXXXXX 100644 | 128 | |
122 | --- a/hw/arm/netduino2.c | 129 | +# The rst_epilog fragment is effectively included in every rST file. |
123 | +++ b/hw/arm/netduino2.c | 130 | +# We use it to define substitutions based on build config that |
124 | @@ -XXX,XX +XXX,XX @@ static void netduino2_init(MachineState *machine) | 131 | +# can then be used in the documentation. The fallback if the |
125 | DeviceState *dev; | 132 | +# environment variable is not set is for the benefit of readthedocs |
126 | Clock *sysclk; | 133 | +# style document building; our Makefile always sets the variable. |
127 | 134 | +confdir = os.getenv('CONFDIR', "/etc/qemu") | |
128 | - system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ; | 135 | +rst_epilog = ".. |CONFDIR| replace:: ``" + confdir + "``\n" |
129 | - | 136 | + |
130 | /* This clock doesn't need migration because it is fixed-frequency */ | 137 | # -- Options for HTML output ---------------------------------------------- |
131 | sysclk = clock_new(OBJECT(machine), "SYSCLK"); | 138 | |
132 | clock_set_hz(sysclk, SYSCLK_FRQ); | 139 | # The theme to use for HTML and HTML Help pages. See the documentation for |
133 | diff --git a/hw/arm/netduinoplus2.c b/hw/arm/netduinoplus2.c | 140 | @@ -XXX,XX +XXX,XX @@ latex_documents = [ |
134 | index XXXXXXX..XXXXXXX 100644 | 141 | |
135 | --- a/hw/arm/netduinoplus2.c | 142 | |
136 | +++ b/hw/arm/netduinoplus2.c | 143 | # -- Options for manual page output --------------------------------------- |
137 | @@ -XXX,XX +XXX,XX @@ static void netduinoplus2_init(MachineState *machine) | 144 | - |
138 | DeviceState *dev; | 145 | -# One entry per manual page. List of tuples |
139 | Clock *sysclk; | 146 | -# (source start file, name, description, authors, manual section). |
140 | 147 | -man_pages = [ | |
141 | - system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ; | 148 | - (master_doc, 'qemu', u'QEMU Documentation', |
142 | - | 149 | - [author], 1) |
143 | /* This clock doesn't need migration because it is fixed-frequency */ | 150 | -] |
144 | sysclk = clock_new(OBJECT(machine), "SYSCLK"); | 151 | - |
145 | clock_set_hz(sysclk, SYSCLK_FRQ); | 152 | +# Individual manual/conf.py can override this to create man pages |
146 | diff --git a/hw/arm/nrf51_soc.c b/hw/arm/nrf51_soc.c | 153 | +man_pages = [] |
147 | index XXXXXXX..XXXXXXX 100644 | 154 | |
148 | --- a/hw/arm/nrf51_soc.c | 155 | # -- Options for Texinfo output ------------------------------------------- |
149 | +++ b/hw/arm/nrf51_soc.c | 156 | |
150 | @@ -XXX,XX +XXX,XX @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp) | 157 | diff --git a/docs/interop/conf.py b/docs/interop/conf.py |
151 | * will always provide one). | 158 | index XXXXXXX..XXXXXXX 100644 |
152 | */ | 159 | --- a/docs/interop/conf.py |
153 | 160 | +++ b/docs/interop/conf.py | |
154 | - system_clock_scale = NANOSECONDS_PER_SECOND / HCLK_FRQ; | 161 | @@ -XXX,XX +XXX,XX @@ exec(compile(open(parent_config, "rb").read(), parent_config, 'exec')) |
155 | - | 162 | # This slightly misuses the 'description', but is the best way to get |
156 | object_property_set_link(OBJECT(&s->cpu), "memory", OBJECT(&s->container), | 163 | # the manual title to appear in the sidebar. |
157 | &error_abort); | 164 | html_theme_options['description'] = u'System Emulation Management and Interoperability Guide' |
158 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->cpu), errp)) { | 165 | + |
159 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | 166 | +# One entry per manual page. List of tuples |
160 | index XXXXXXX..XXXXXXX 100644 | 167 | +# (source start file, name, description, authors, manual section). |
161 | --- a/hw/arm/stellaris.c | 168 | +man_pages = [ |
162 | +++ b/hw/arm/stellaris.c | 169 | + ('qemu-ga', 'qemu-ga', u'QEMU Guest Agent', |
163 | @@ -XXX,XX +XXX,XX @@ static bool ssys_use_rcc2(ssys_state *s) | 170 | + ['Michael Roth <mdroth@linux.vnet.ibm.com>'], 8) |
164 | */ | 171 | +] |
165 | static void ssys_calculate_system_clock(ssys_state *s, bool propagate_clock) | 172 | diff --git a/docs/interop/index.rst b/docs/interop/index.rst |
166 | { | 173 | index XXXXXXX..XXXXXXX 100644 |
167 | + int period_ns; | 174 | --- a/docs/interop/index.rst |
168 | /* | 175 | +++ b/docs/interop/index.rst |
169 | * SYSDIV field specifies divisor: 0 == /1, 1 == /2, etc. Input | 176 | @@ -XXX,XX +XXX,XX @@ Contents: |
170 | * clock is 200MHz, which is a period of 5 ns. Dividing the clock | 177 | bitmaps |
171 | * frequency by X is the same as multiplying the period by X. | 178 | live-block-operations |
172 | */ | 179 | pr-helper |
173 | if (ssys_use_rcc2(s)) { | 180 | + qemu-ga |
174 | - system_clock_scale = 5 * (((s->rcc2 >> 23) & 0x3f) + 1); | 181 | vhost-user |
175 | + period_ns = 5 * (((s->rcc2 >> 23) & 0x3f) + 1); | 182 | vhost-user-gpu |
176 | } else { | 183 | diff --git a/docs/interop/qemu-ga.rst b/docs/interop/qemu-ga.rst |
177 | - system_clock_scale = 5 * (((s->rcc >> 23) & 0xf) + 1); | 184 | new file mode 100644 |
178 | + period_ns = 5 * (((s->rcc >> 23) & 0xf) + 1); | 185 | index XXXXXXX..XXXXXXX |
179 | } | 186 | --- /dev/null |
180 | - clock_set_ns(s->sysclk, system_clock_scale); | 187 | +++ b/docs/interop/qemu-ga.rst |
181 | + clock_set_ns(s->sysclk, period_ns); | ||
182 | if (propagate_clock) { | ||
183 | clock_propagate(s->sysclk); | ||
184 | } | ||
185 | diff --git a/hw/arm/stm32vldiscovery.c b/hw/arm/stm32vldiscovery.c | ||
186 | index XXXXXXX..XXXXXXX 100644 | ||
187 | --- a/hw/arm/stm32vldiscovery.c | ||
188 | +++ b/hw/arm/stm32vldiscovery.c | ||
189 | @@ -XXX,XX +XXX,XX @@ static void stm32vldiscovery_init(MachineState *machine) | ||
190 | DeviceState *dev; | ||
191 | Clock *sysclk; | ||
192 | |||
193 | - system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ; | ||
194 | - | ||
195 | /* This clock doesn't need migration because it is fixed-frequency */ | ||
196 | sysclk = clock_new(OBJECT(machine), "SYSCLK"); | ||
197 | clock_set_hz(sysclk, SYSCLK_FRQ); | ||
198 | diff --git a/hw/timer/armv7m_systick.c b/hw/timer/armv7m_systick.c | ||
199 | index XXXXXXX..XXXXXXX 100644 | ||
200 | --- a/hw/timer/armv7m_systick.c | ||
201 | +++ b/hw/timer/armv7m_systick.c | ||
202 | @@ -XXX,XX +XXX,XX @@ | 188 | @@ -XXX,XX +XXX,XX @@ |
203 | #define SYSCALIB_SKEW (1U << 30) | 189 | +QEMU Guest Agent |
204 | #define SYSCALIB_TENMS ((1U << 24) - 1) | 190 | +================ |
205 | 191 | + | |
206 | -int system_clock_scale; | 192 | +Synopsis |
207 | - | 193 | +-------- |
208 | static void systick_set_period_from_clock(SysTickState *s) | 194 | + |
209 | { | 195 | +**qemu-ga** [*OPTIONS*] |
210 | /* | 196 | + |
197 | +Description | ||
198 | +----------- | ||
199 | + | ||
200 | +The QEMU Guest Agent is a daemon intended to be run within virtual | ||
201 | +machines. It allows the hypervisor host to perform various operations | ||
202 | +in the guest, such as: | ||
203 | + | ||
204 | +- get information from the guest | ||
205 | +- set the guest's system time | ||
206 | +- read/write a file | ||
207 | +- sync and freeze the filesystems | ||
208 | +- suspend the guest | ||
209 | +- reconfigure guest local processors | ||
210 | +- set user's password | ||
211 | +- ... | ||
212 | + | ||
213 | +qemu-ga will read a system configuration file on startup (located at | ||
214 | +|CONFDIR|\ ``/qemu-ga.conf`` by default), then parse remaining | ||
215 | +configuration options on the command line. For the same key, the last | ||
216 | +option wins, but the lists accumulate (see below for configuration | ||
217 | +file format). | ||
218 | + | ||
219 | +Options | ||
220 | +------- | ||
221 | + | ||
222 | +.. program:: qemu-ga | ||
223 | + | ||
224 | +.. option:: -m, --method=METHOD | ||
225 | + | ||
226 | + Transport method: one of ``unix-listen``, ``virtio-serial``, or | ||
227 | + ``isa-serial`` (``virtio-serial`` is the default). | ||
228 | + | ||
229 | +.. option:: -p, --path=PATH | ||
230 | + | ||
231 | + Device/socket path (the default for virtio-serial is | ||
232 | + ``/dev/virtio-ports/org.qemu.guest_agent.0``, | ||
233 | + the default for isa-serial is ``/dev/ttyS0``) | ||
234 | + | ||
235 | +.. option:: -l, --logfile=PATH | ||
236 | + | ||
237 | + Set log file path (default is stderr). | ||
238 | + | ||
239 | +.. option:: -f, --pidfile=PATH | ||
240 | + | ||
241 | + Specify pid file (default is ``/var/run/qemu-ga.pid``). | ||
242 | + | ||
243 | +.. option:: -F, --fsfreeze-hook=PATH | ||
244 | + | ||
245 | + Enable fsfreeze hook. Accepts an optional argument that specifies | ||
246 | + script to run on freeze/thaw. Script will be called with | ||
247 | + 'freeze'/'thaw' arguments accordingly (default is | ||
248 | + |CONFDIR|\ ``/fsfreeze-hook``). If using -F with an argument, do | ||
249 | + not follow -F with a space (for example: | ||
250 | + ``-F/var/run/fsfreezehook.sh``). | ||
251 | + | ||
252 | +.. option:: -t, --statedir=PATH | ||
253 | + | ||
254 | + Specify the directory to store state information (absolute paths only, | ||
255 | + default is ``/var/run``). | ||
256 | + | ||
257 | +.. option:: -v, --verbose | ||
258 | + | ||
259 | + Log extra debugging information. | ||
260 | + | ||
261 | +.. option:: -V, --version | ||
262 | + | ||
263 | + Print version information and exit. | ||
264 | + | ||
265 | +.. option:: -d, --daemon | ||
266 | + | ||
267 | + Daemonize after startup (detach from terminal). | ||
268 | + | ||
269 | +.. option:: -b, --blacklist=LIST | ||
270 | + | ||
271 | + Comma-separated list of RPCs to disable (no spaces, ``?`` to list | ||
272 | + available RPCs). | ||
273 | + | ||
274 | +.. option:: -D, --dump-conf | ||
275 | + | ||
276 | + Dump the configuration in a format compatible with ``qemu-ga.conf`` | ||
277 | + and exit. | ||
278 | + | ||
279 | +.. option:: -h, --help | ||
280 | + | ||
281 | + Display this help and exit. | ||
282 | + | ||
283 | +Files | ||
284 | +----- | ||
285 | + | ||
286 | + | ||
287 | +The syntax of the ``qemu-ga.conf`` configuration file follows the | ||
288 | +Desktop Entry Specification, here is a quick summary: it consists of | ||
289 | +groups of key-value pairs, interspersed with comments. | ||
290 | + | ||
291 | +:: | ||
292 | + | ||
293 | + # qemu-ga configuration sample | ||
294 | + [general] | ||
295 | + daemonize = 0 | ||
296 | + pidfile = /var/run/qemu-ga.pid | ||
297 | + verbose = 0 | ||
298 | + method = virtio-serial | ||
299 | + path = /dev/virtio-ports/org.qemu.guest_agent.0 | ||
300 | + statedir = /var/run | ||
301 | + | ||
302 | +The list of keys follows the command line options: | ||
303 | + | ||
304 | +============= =========== | ||
305 | +Key Key type | ||
306 | +============= =========== | ||
307 | +daemon boolean | ||
308 | +method string | ||
309 | +path string | ||
310 | +logfile string | ||
311 | +pidfile string | ||
312 | +fsfreeze-hook string | ||
313 | +statedir string | ||
314 | +verbose boolean | ||
315 | +blacklist string list | ||
316 | +============= =========== | ||
317 | + | ||
318 | +See also | ||
319 | +-------- | ||
320 | + | ||
321 | +:manpage:`qemu(1)` | ||
322 | diff --git a/qemu-doc.texi b/qemu-doc.texi | ||
323 | index XXXXXXX..XXXXXXX 100644 | ||
324 | --- a/qemu-doc.texi | ||
325 | +++ b/qemu-doc.texi | ||
326 | @@ -XXX,XX +XXX,XX @@ so should only be used with trusted guest OS. | ||
327 | |||
328 | @c man end | ||
329 | |||
330 | -@node QEMU Guest Agent | ||
331 | -@chapter QEMU Guest Agent invocation | ||
332 | - | ||
333 | -@include qemu-ga.texi | ||
334 | - | ||
335 | @node QEMU User space emulator | ||
336 | @chapter QEMU User space emulator | ||
337 | |||
338 | diff --git a/qemu-ga.texi b/qemu-ga.texi | ||
339 | deleted file mode 100644 | ||
340 | index XXXXXXX..XXXXXXX | ||
341 | --- a/qemu-ga.texi | ||
342 | +++ /dev/null | ||
343 | @@ -XXX,XX +XXX,XX @@ | ||
344 | -@example | ||
345 | -@c man begin SYNOPSIS | ||
346 | -@command{qemu-ga} [@var{OPTIONS}] | ||
347 | -@c man end | ||
348 | -@end example | ||
349 | - | ||
350 | -@c man begin DESCRIPTION | ||
351 | - | ||
352 | -The QEMU Guest Agent is a daemon intended to be run within virtual | ||
353 | -machines. It allows the hypervisor host to perform various operations | ||
354 | -in the guest, such as: | ||
355 | - | ||
356 | -@itemize | ||
357 | -@item | ||
358 | -get information from the guest | ||
359 | -@item | ||
360 | -set the guest's system time | ||
361 | -@item | ||
362 | -read/write a file | ||
363 | -@item | ||
364 | -sync and freeze the filesystems | ||
365 | -@item | ||
366 | -suspend the guest | ||
367 | -@item | ||
368 | -reconfigure guest local processors | ||
369 | -@item | ||
370 | -set user's password | ||
371 | -@item | ||
372 | -... | ||
373 | -@end itemize | ||
374 | - | ||
375 | -qemu-ga will read a system configuration file on startup (located at | ||
376 | -@file{@value{CONFDIR}/qemu-ga.conf} by default), then parse remaining | ||
377 | -configuration options on the command line. For the same key, the last | ||
378 | -option wins, but the lists accumulate (see below for configuration | ||
379 | -file format). | ||
380 | - | ||
381 | -@c man end | ||
382 | - | ||
383 | -@c man begin OPTIONS | ||
384 | -@table @option | ||
385 | -@item -m, --method=@var{method} | ||
386 | - Transport method: one of @samp{unix-listen}, @samp{virtio-serial}, or | ||
387 | - @samp{isa-serial} (@samp{virtio-serial} is the default). | ||
388 | - | ||
389 | -@item -p, --path=@var{path} | ||
390 | - Device/socket path (the default for virtio-serial is | ||
391 | - @samp{/dev/virtio-ports/org.qemu.guest_agent.0}, | ||
392 | - the default for isa-serial is @samp{/dev/ttyS0}) | ||
393 | - | ||
394 | -@item -l, --logfile=@var{path} | ||
395 | - Set log file path (default is stderr). | ||
396 | - | ||
397 | -@item -f, --pidfile=@var{path} | ||
398 | - Specify pid file (default is @samp{/var/run/qemu-ga.pid}). | ||
399 | - | ||
400 | -@item -F, --fsfreeze-hook=@var{path} | ||
401 | - Enable fsfreeze hook. Accepts an optional argument that specifies | ||
402 | - script to run on freeze/thaw. Script will be called with | ||
403 | - 'freeze'/'thaw' arguments accordingly (default is | ||
404 | - @samp{@value{CONFDIR}/fsfreeze-hook}). If using -F with an argument, do | ||
405 | - not follow -F with a space (for example: | ||
406 | - @samp{-F/var/run/fsfreezehook.sh}). | ||
407 | - | ||
408 | -@item -t, --statedir=@var{path} | ||
409 | - Specify the directory to store state information (absolute paths only, | ||
410 | - default is @samp{/var/run}). | ||
411 | - | ||
412 | -@item -v, --verbose | ||
413 | - Log extra debugging information. | ||
414 | - | ||
415 | -@item -V, --version | ||
416 | - Print version information and exit. | ||
417 | - | ||
418 | -@item -d, --daemon | ||
419 | - Daemonize after startup (detach from terminal). | ||
420 | - | ||
421 | -@item -b, --blacklist=@var{list} | ||
422 | - Comma-separated list of RPCs to disable (no spaces, @samp{?} to list | ||
423 | - available RPCs). | ||
424 | - | ||
425 | -@item -D, --dump-conf | ||
426 | - Dump the configuration in a format compatible with @file{qemu-ga.conf} | ||
427 | - and exit. | ||
428 | - | ||
429 | -@item -h, --help | ||
430 | - Display this help and exit. | ||
431 | -@end table | ||
432 | - | ||
433 | -@c man end | ||
434 | - | ||
435 | -@c man begin FILES | ||
436 | - | ||
437 | -The syntax of the @file{qemu-ga.conf} configuration file follows the | ||
438 | -Desktop Entry Specification, here is a quick summary: it consists of | ||
439 | -groups of key-value pairs, interspersed with comments. | ||
440 | - | ||
441 | -@example | ||
442 | -# qemu-ga configuration sample | ||
443 | -[general] | ||
444 | -daemonize = 0 | ||
445 | -pidfile = /var/run/qemu-ga.pid | ||
446 | -verbose = 0 | ||
447 | -method = virtio-serial | ||
448 | -path = /dev/virtio-ports/org.qemu.guest_agent.0 | ||
449 | -statedir = /var/run | ||
450 | -@end example | ||
451 | - | ||
452 | -The list of keys follows the command line options: | ||
453 | -@table @option | ||
454 | -@item daemon= boolean | ||
455 | -@item method= string | ||
456 | -@item path= string | ||
457 | -@item logfile= string | ||
458 | -@item pidfile= string | ||
459 | -@item fsfreeze-hook= string | ||
460 | -@item statedir= string | ||
461 | -@item verbose= boolean | ||
462 | -@item blacklist= string list | ||
463 | -@end table | ||
464 | - | ||
465 | -@c man end | ||
466 | - | ||
467 | -@ignore | ||
468 | - | ||
469 | -@setfilename qemu-ga | ||
470 | -@settitle QEMU Guest Agent | ||
471 | - | ||
472 | -@c man begin AUTHOR | ||
473 | -Michael Roth <mdroth@linux.vnet.ibm.com> | ||
474 | -@c man end | ||
475 | - | ||
476 | -@c man begin SEEALSO | ||
477 | -qemu(1) | ||
478 | -@c man end | ||
479 | - | ||
480 | -@end ignore | ||
211 | -- | 481 | -- |
212 | 2.20.1 | 482 | 2.20.1 |
213 | 483 | ||
214 | 484 | diff view generated by jsdifflib |