1 | Second pull request of the week; mostly RTH's support for some | 1 | The following changes since commit 3db29dcac23da85486704ef9e7a8e7217f7829cd: |
---|---|---|---|
2 | new-in-v8.1/v8.3 instructions, and my v8M board model. | ||
3 | 2 | ||
4 | thanks | 3 | Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2023-01-12 13:51:36 +0000) |
5 | -- PMM | ||
6 | |||
7 | The following changes since commit 427cbc7e4136a061628cb4315cc8182ea36d772f: | ||
8 | |||
9 | Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2018-03-01 18:46:41 +0000) | ||
10 | 4 | ||
11 | are available in the Git repository at: | 5 | are available in the Git repository at: |
12 | 6 | ||
13 | git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180302 | 7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230113 |
14 | 8 | ||
15 | for you to fetch changes up to e66a67bf28e1b4fce2e3d72a2610dbd48d9d3078: | 9 | for you to fetch changes up to 08899b5c68a55a3780d707e2464073c8f2670d31: |
16 | 10 | ||
17 | target/arm: Enable ARM_FEATURE_V8_FCMA (2018-03-02 11:03:45 +0000) | 11 | target/arm: allow writes to SCR_EL3.HXEn bit when FEAT_HCX is enabled (2023-01-13 13:19:36 +0000) |
18 | 12 | ||
19 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
20 | target-arm queue: | 14 | target-arm queue: |
21 | * implement FCMA and RDM v8.1 and v8.3 instructions | 15 | hw/arm/stm32f405: correctly describe the memory layout |
22 | * enable Cortex-M33 v8M core, and provide new mps2-an505 board model | 16 | hw/arm: Add Olimex H405 board |
23 | that uses it | 17 | cubieboard: Support booting from an SD card image with u-boot on it |
24 | * decodetree: Propagate return value from translate subroutines | 18 | target/arm: Fix sve_probe_page |
25 | * xlnx-zynqmp: Implement the RTC device | 19 | target/arm: allow writes to SCR_EL3.HXEn bit when FEAT_HCX is enabled |
20 | various code cleanups | ||
26 | 21 | ||
27 | ---------------------------------------------------------------- | 22 | ---------------------------------------------------------------- |
28 | Alistair Francis (3): | 23 | Evgeny Iakovlev (1): |
29 | xlnx-zynqmp-rtc: Initial commit | 24 | target/arm: allow writes to SCR_EL3.HXEn bit when FEAT_HCX is enabled |
30 | xlnx-zynqmp-rtc: Add basic time support | ||
31 | xlnx-zynqmp: Connect the RTC device | ||
32 | 25 | ||
33 | Peter Maydell (19): | 26 | Felipe Balbi (2): |
34 | loader: Add new load_ramdisk_as() | 27 | hw/arm/stm32f405: correctly describe the memory layout |
35 | hw/arm/boot: Honour CPU's address space for image loads | 28 | hw/arm: Add Olimex H405 |
36 | hw/arm/armv7m: Honour CPU's address space for image loads | ||
37 | target/arm: Define an IDAU interface | ||
38 | armv7m: Forward idau property to CPU object | ||
39 | target/arm: Define init-svtor property for the reset secure VTOR value | ||
40 | armv7m: Forward init-svtor property to CPU object | ||
41 | target/arm: Add Cortex-M33 | ||
42 | hw/misc/unimp: Move struct to header file | ||
43 | include/hw/or-irq.h: Add missing include guard | ||
44 | qdev: Add new qdev_init_gpio_in_named_with_opaque() | ||
45 | hw/core/split-irq: Device that splits IRQ lines | ||
46 | hw/misc/mps2-fpgaio: FPGA control block for MPS2 AN505 | ||
47 | hw/misc/tz-ppc: Model TrustZone peripheral protection controller | ||
48 | hw/misc/iotkit-secctl: Arm IoT Kit security controller initial skeleton | ||
49 | hw/misc/iotkit-secctl: Add handling for PPCs | ||
50 | hw/misc/iotkit-secctl: Add remaining simple registers | ||
51 | hw/arm/iotkit: Model Arm IOT Kit | ||
52 | mps2-an505: New board model: MPS2 with AN505 Cortex-M33 FPGA image | ||
53 | 29 | ||
54 | Richard Henderson (17): | 30 | Philippe Mathieu-Daudé (27): |
55 | decodetree: Propagate return value from translate subroutines | 31 | hw/arm/pxa2xx: Simplify pxa255_init() |
56 | target/arm: Add ARM_FEATURE_V8_RDM | 32 | hw/arm/pxa2xx: Simplify pxa270_init() |
57 | target/arm: Refactor disas_simd_indexed decode | 33 | hw/arm/collie: Use the IEC binary prefix definitions |
58 | target/arm: Refactor disas_simd_indexed size checks | 34 | hw/arm/collie: Simplify flash creation using for() loop |
59 | target/arm: Decode aa64 armv8.1 scalar three same extra | 35 | hw/arm/gumstix: Improve documentation |
60 | target/arm: Decode aa64 armv8.1 three same extra | 36 | hw/arm/gumstix: Use the IEC binary prefix definitions |
61 | target/arm: Decode aa64 armv8.1 scalar/vector x indexed element | 37 | hw/arm/mainstone: Use the IEC binary prefix definitions |
62 | target/arm: Decode aa32 armv8.1 three same | 38 | hw/arm/musicpal: Use the IEC binary prefix definitions |
63 | target/arm: Decode aa32 armv8.1 two reg and a scalar | 39 | hw/arm/omap_sx1: Remove unused 'total_ram' definitions |
64 | target/arm: Enable ARM_FEATURE_V8_RDM | 40 | hw/arm/omap_sx1: Use the IEC binary prefix definitions |
65 | target/arm: Add ARM_FEATURE_V8_FCMA | 41 | hw/arm/z2: Use the IEC binary prefix definitions |
66 | target/arm: Decode aa64 armv8.3 fcadd | 42 | hw/arm/vexpress: Remove dead code in vexpress_common_init() |
67 | target/arm: Decode aa64 armv8.3 fcmla | 43 | hw/arm: Remove unreachable code calling pflash_cfi01_register() |
68 | target/arm: Decode aa32 armv8.3 3-same | 44 | hw/arm/pxa: Avoid forward-declaring PXA2xxI2CState |
69 | target/arm: Decode aa32 armv8.3 2-reg-index | 45 | hw/gpio/omap_gpio: Add local variable to avoid embedded cast |
70 | target/arm: Decode t32 simd 3reg and 2reg_scalar extension | 46 | hw/arm/omap: Drop useless casts from void * to pointer |
71 | target/arm: Enable ARM_FEATURE_V8_FCMA | 47 | hw/gpio/omap_gpio: Use CamelCase for TYPE_OMAP1_GPIO type name |
48 | hw/gpio/omap_gpio: Use CamelCase for TYPE_OMAP2_GPIO type name | ||
49 | hw/intc/omap_intc: Use CamelCase for TYPE_OMAP_INTC type name | ||
50 | hw/arm/stellaris: Drop useless casts from void * to pointer | ||
51 | hw/arm/stellaris: Use CamelCase for STELLARIS_ADC type name | ||
52 | hw/arm/bcm2836: Remove definitions generated by OBJECT_DECLARE_TYPE() | ||
53 | hw/arm/npcm7xx: Declare QOM macros using OBJECT_DECLARE_SIMPLE_TYPE() | ||
54 | hw/misc/sbsa_ec: Rename TYPE_SBSA_EC -> TYPE_SBSA_SECURE_EC | ||
55 | hw/misc/sbsa_ec: Declare QOM macros using OBJECT_DECLARE_SIMPLE_TYPE() | ||
56 | hw/intc/xilinx_intc: Use 'XpsIntc' typedef instead of 'struct xlx_pic' | ||
57 | hw/timer/xilinx_timer: Use XpsTimerState instead of 'struct timerblock' | ||
72 | 58 | ||
73 | hw/arm/Makefile.objs | 2 + | 59 | Richard Henderson (1): |
74 | hw/core/Makefile.objs | 1 + | 60 | target/arm: Fix sve_probe_page |
75 | hw/misc/Makefile.objs | 4 + | ||
76 | hw/timer/Makefile.objs | 1 + | ||
77 | target/arm/Makefile.objs | 2 +- | ||
78 | include/hw/arm/armv7m.h | 5 + | ||
79 | include/hw/arm/iotkit.h | 109 ++++++ | ||
80 | include/hw/arm/xlnx-zynqmp.h | 2 + | ||
81 | include/hw/core/split-irq.h | 57 +++ | ||
82 | include/hw/irq.h | 4 +- | ||
83 | include/hw/loader.h | 12 +- | ||
84 | include/hw/misc/iotkit-secctl.h | 103 ++++++ | ||
85 | include/hw/misc/mps2-fpgaio.h | 43 +++ | ||
86 | include/hw/misc/tz-ppc.h | 101 ++++++ | ||
87 | include/hw/misc/unimp.h | 10 + | ||
88 | include/hw/or-irq.h | 5 + | ||
89 | include/hw/qdev-core.h | 30 +- | ||
90 | include/hw/timer/xlnx-zynqmp-rtc.h | 86 +++++ | ||
91 | target/arm/cpu.h | 8 + | ||
92 | target/arm/helper.h | 31 ++ | ||
93 | target/arm/idau.h | 61 ++++ | ||
94 | hw/arm/armv7m.c | 35 +- | ||
95 | hw/arm/boot.c | 119 ++++--- | ||
96 | hw/arm/iotkit.c | 598 +++++++++++++++++++++++++++++++ | ||
97 | hw/arm/mps2-tz.c | 503 ++++++++++++++++++++++++++ | ||
98 | hw/arm/xlnx-zynqmp.c | 14 + | ||
99 | hw/core/loader.c | 8 +- | ||
100 | hw/core/qdev.c | 8 +- | ||
101 | hw/core/split-irq.c | 89 +++++ | ||
102 | hw/misc/iotkit-secctl.c | 704 +++++++++++++++++++++++++++++++++++++ | ||
103 | hw/misc/mps2-fpgaio.c | 176 ++++++++++ | ||
104 | hw/misc/tz-ppc.c | 302 ++++++++++++++++ | ||
105 | hw/misc/unimp.c | 10 - | ||
106 | hw/timer/xlnx-zynqmp-rtc.c | 272 ++++++++++++++ | ||
107 | linux-user/elfload.c | 2 + | ||
108 | target/arm/cpu.c | 66 +++- | ||
109 | target/arm/cpu64.c | 2 + | ||
110 | target/arm/helper.c | 28 +- | ||
111 | target/arm/translate-a64.c | 514 +++++++++++++++++++++------ | ||
112 | target/arm/translate.c | 275 +++++++++++++-- | ||
113 | target/arm/vec_helper.c | 429 ++++++++++++++++++++++ | ||
114 | default-configs/arm-softmmu.mak | 5 + | ||
115 | hw/misc/trace-events | 24 ++ | ||
116 | hw/timer/trace-events | 3 + | ||
117 | scripts/decodetree.py | 5 +- | ||
118 | 45 files changed, 4668 insertions(+), 200 deletions(-) | ||
119 | create mode 100644 include/hw/arm/iotkit.h | ||
120 | create mode 100644 include/hw/core/split-irq.h | ||
121 | create mode 100644 include/hw/misc/iotkit-secctl.h | ||
122 | create mode 100644 include/hw/misc/mps2-fpgaio.h | ||
123 | create mode 100644 include/hw/misc/tz-ppc.h | ||
124 | create mode 100644 include/hw/timer/xlnx-zynqmp-rtc.h | ||
125 | create mode 100644 target/arm/idau.h | ||
126 | create mode 100644 hw/arm/iotkit.c | ||
127 | create mode 100644 hw/arm/mps2-tz.c | ||
128 | create mode 100644 hw/core/split-irq.c | ||
129 | create mode 100644 hw/misc/iotkit-secctl.c | ||
130 | create mode 100644 hw/misc/mps2-fpgaio.c | ||
131 | create mode 100644 hw/misc/tz-ppc.c | ||
132 | create mode 100644 hw/timer/xlnx-zynqmp-rtc.c | ||
133 | create mode 100644 target/arm/vec_helper.c | ||
134 | 61 | ||
62 | Strahinja Jankovic (7): | ||
63 | hw/misc: Allwinner-A10 Clock Controller Module Emulation | ||
64 | hw/misc: Allwinner A10 DRAM Controller Emulation | ||
65 | {hw/i2c,docs/system/arm}: Allwinner TWI/I2C Emulation | ||
66 | hw/misc: AXP209 PMU Emulation | ||
67 | hw/arm: Add AXP209 to Cubieboard | ||
68 | hw/arm: Allwinner A10 enable SPL load from MMC | ||
69 | tests/avocado: Add SD boot test to Cubieboard | ||
70 | |||
71 | docs/system/arm/cubieboard.rst | 1 + | ||
72 | docs/system/arm/orangepi.rst | 1 + | ||
73 | docs/system/arm/stm32.rst | 1 + | ||
74 | configs/devices/arm-softmmu/default.mak | 1 + | ||
75 | include/hw/adc/npcm7xx_adc.h | 7 +- | ||
76 | include/hw/arm/allwinner-a10.h | 27 ++ | ||
77 | include/hw/arm/allwinner-h3.h | 3 + | ||
78 | include/hw/arm/npcm7xx.h | 18 +- | ||
79 | include/hw/arm/omap.h | 24 +- | ||
80 | include/hw/arm/pxa.h | 11 +- | ||
81 | include/hw/arm/stm32f405_soc.h | 5 +- | ||
82 | include/hw/i2c/allwinner-i2c.h | 55 ++++ | ||
83 | include/hw/i2c/npcm7xx_smbus.h | 7 +- | ||
84 | include/hw/misc/allwinner-a10-ccm.h | 67 +++++ | ||
85 | include/hw/misc/allwinner-a10-dramc.h | 68 +++++ | ||
86 | include/hw/misc/npcm7xx_clk.h | 2 +- | ||
87 | include/hw/misc/npcm7xx_gcr.h | 6 +- | ||
88 | include/hw/misc/npcm7xx_mft.h | 7 +- | ||
89 | include/hw/misc/npcm7xx_pwm.h | 3 +- | ||
90 | include/hw/misc/npcm7xx_rng.h | 6 +- | ||
91 | include/hw/net/npcm7xx_emc.h | 5 +- | ||
92 | include/hw/sd/npcm7xx_sdhci.h | 4 +- | ||
93 | hw/arm/allwinner-a10.c | 40 +++ | ||
94 | hw/arm/allwinner-h3.c | 11 +- | ||
95 | hw/arm/bcm2836.c | 9 +- | ||
96 | hw/arm/collie.c | 25 +- | ||
97 | hw/arm/cubieboard.c | 11 + | ||
98 | hw/arm/gumstix.c | 45 ++-- | ||
99 | hw/arm/mainstone.c | 37 ++- | ||
100 | hw/arm/musicpal.c | 9 +- | ||
101 | hw/arm/olimex-stm32-h405.c | 69 +++++ | ||
102 | hw/arm/omap1.c | 115 ++++---- | ||
103 | hw/arm/omap2.c | 40 ++- | ||
104 | hw/arm/omap_sx1.c | 53 ++-- | ||
105 | hw/arm/palm.c | 2 +- | ||
106 | hw/arm/pxa2xx.c | 8 +- | ||
107 | hw/arm/spitz.c | 6 +- | ||
108 | hw/arm/stellaris.c | 73 +++-- | ||
109 | hw/arm/stm32f405_soc.c | 8 + | ||
110 | hw/arm/tosa.c | 2 +- | ||
111 | hw/arm/versatilepb.c | 6 +- | ||
112 | hw/arm/vexpress.c | 10 +- | ||
113 | hw/arm/z2.c | 16 +- | ||
114 | hw/char/omap_uart.c | 7 +- | ||
115 | hw/display/omap_dss.c | 15 +- | ||
116 | hw/display/omap_lcdc.c | 9 +- | ||
117 | hw/dma/omap_dma.c | 15 +- | ||
118 | hw/gpio/omap_gpio.c | 48 ++-- | ||
119 | hw/i2c/allwinner-i2c.c | 459 ++++++++++++++++++++++++++++++++ | ||
120 | hw/intc/omap_intc.c | 38 +-- | ||
121 | hw/intc/xilinx_intc.c | 28 +- | ||
122 | hw/misc/allwinner-a10-ccm.c | 224 ++++++++++++++++ | ||
123 | hw/misc/allwinner-a10-dramc.c | 179 +++++++++++++ | ||
124 | hw/misc/axp209.c | 238 +++++++++++++++++ | ||
125 | hw/misc/omap_gpmc.c | 12 +- | ||
126 | hw/misc/omap_l4.c | 7 +- | ||
127 | hw/misc/omap_sdrc.c | 7 +- | ||
128 | hw/misc/omap_tap.c | 5 +- | ||
129 | hw/misc/sbsa_ec.c | 12 +- | ||
130 | hw/sd/omap_mmc.c | 9 +- | ||
131 | hw/ssi/omap_spi.c | 7 +- | ||
132 | hw/timer/omap_gptimer.c | 22 +- | ||
133 | hw/timer/omap_synctimer.c | 4 +- | ||
134 | hw/timer/xilinx_timer.c | 27 +- | ||
135 | target/arm/helper.c | 3 + | ||
136 | target/arm/sve_helper.c | 14 +- | ||
137 | MAINTAINERS | 8 + | ||
138 | hw/arm/Kconfig | 9 + | ||
139 | hw/arm/meson.build | 1 + | ||
140 | hw/i2c/Kconfig | 4 + | ||
141 | hw/i2c/meson.build | 1 + | ||
142 | hw/i2c/trace-events | 5 + | ||
143 | hw/misc/Kconfig | 10 + | ||
144 | hw/misc/meson.build | 3 + | ||
145 | hw/misc/trace-events | 5 + | ||
146 | tests/avocado/boot_linux_console.py | 47 ++++ | ||
147 | 76 files changed, 1951 insertions(+), 455 deletions(-) | ||
148 | create mode 100644 include/hw/i2c/allwinner-i2c.h | ||
149 | create mode 100644 include/hw/misc/allwinner-a10-ccm.h | ||
150 | create mode 100644 include/hw/misc/allwinner-a10-dramc.h | ||
151 | create mode 100644 hw/arm/olimex-stm32-h405.c | ||
152 | create mode 100644 hw/i2c/allwinner-i2c.c | ||
153 | create mode 100644 hw/misc/allwinner-a10-ccm.c | ||
154 | create mode 100644 hw/misc/allwinner-a10-dramc.c | ||
155 | create mode 100644 hw/misc/axp209.c | ||
156 | diff view generated by jsdifflib |
1 | Model the Arm IoT Kit documented in | 1 | From: Felipe Balbi <balbi@kernel.org> |
---|---|---|---|
2 | http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ecm0601256/index.html | ||
3 | 2 | ||
4 | The Arm IoT Kit is a subsystem which includes a CPU and some devices, | 3 | STM32F405 has 128K of SRAM and another 64K of CCM (Core-coupled |
5 | and is intended be extended by adding extra devices to form a | 4 | Memory) at a different base address. Correctly describe the memory |
6 | complete system. It is used in the MPS2 board's AN505 image for the | 5 | layout to give existing FW images a chance to run unmodified. |
7 | Cortex-M33. | ||
8 | 6 | ||
7 | Reviewed-by: Alistair Francis <alistair@alistair23.me> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
9 | Signed-off-by: Felipe Balbi <balbi@kernel.org> | ||
10 | Message-id: 20221230145733.200496-2-balbi@kernel.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20180220180325.29818-19-peter.maydell@linaro.org | ||
12 | --- | 12 | --- |
13 | hw/arm/Makefile.objs | 1 + | 13 | include/hw/arm/stm32f405_soc.h | 5 ++++- |
14 | include/hw/arm/iotkit.h | 109 ++++++++ | 14 | hw/arm/stm32f405_soc.c | 8 ++++++++ |
15 | hw/arm/iotkit.c | 598 ++++++++++++++++++++++++++++++++++++++++ | 15 | 2 files changed, 12 insertions(+), 1 deletion(-) |
16 | default-configs/arm-softmmu.mak | 1 + | ||
17 | 4 files changed, 709 insertions(+) | ||
18 | create mode 100644 include/hw/arm/iotkit.h | ||
19 | create mode 100644 hw/arm/iotkit.c | ||
20 | 16 | ||
21 | diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs | 17 | diff --git a/include/hw/arm/stm32f405_soc.h b/include/hw/arm/stm32f405_soc.h |
22 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/hw/arm/Makefile.objs | 19 | --- a/include/hw/arm/stm32f405_soc.h |
24 | +++ b/hw/arm/Makefile.objs | 20 | +++ b/include/hw/arm/stm32f405_soc.h |
25 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_FSL_IMX6) += fsl-imx6.o sabrelite.o | 21 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(STM32F405State, STM32F405_SOC) |
26 | obj-$(CONFIG_ASPEED_SOC) += aspeed_soc.o aspeed.o | 22 | #define FLASH_BASE_ADDRESS 0x08000000 |
27 | obj-$(CONFIG_MPS2) += mps2.o | 23 | #define FLASH_SIZE (1024 * 1024) |
28 | obj-$(CONFIG_MSF2) += msf2-soc.o msf2-som.o | 24 | #define SRAM_BASE_ADDRESS 0x20000000 |
29 | +obj-$(CONFIG_IOTKIT) += iotkit.o | 25 | -#define SRAM_SIZE (192 * 1024) |
30 | diff --git a/include/hw/arm/iotkit.h b/include/hw/arm/iotkit.h | 26 | +#define SRAM_SIZE (128 * 1024) |
31 | new file mode 100644 | 27 | +#define CCM_BASE_ADDRESS 0x10000000 |
32 | index XXXXXXX..XXXXXXX | 28 | +#define CCM_SIZE (64 * 1024) |
33 | --- /dev/null | 29 | |
34 | +++ b/include/hw/arm/iotkit.h | 30 | struct STM32F405State { |
35 | @@ -XXX,XX +XXX,XX @@ | 31 | /*< private >*/ |
36 | +/* | 32 | @@ -XXX,XX +XXX,XX @@ struct STM32F405State { |
37 | + * ARM IoT Kit | 33 | STM32F2XXADCState adc[STM_NUM_ADCS]; |
38 | + * | 34 | STM32F2XXSPIState spi[STM_NUM_SPIS]; |
39 | + * Copyright (c) 2018 Linaro Limited | 35 | |
40 | + * Written by Peter Maydell | 36 | + MemoryRegion ccm; |
41 | + * | 37 | MemoryRegion sram; |
42 | + * This program is free software; you can redistribute it and/or modify | 38 | MemoryRegion flash; |
43 | + * it under the terms of the GNU General Public License version 2 or | 39 | MemoryRegion flash_alias; |
44 | + * (at your option) any later version. | 40 | diff --git a/hw/arm/stm32f405_soc.c b/hw/arm/stm32f405_soc.c |
45 | + */ | 41 | index XXXXXXX..XXXXXXX 100644 |
46 | + | 42 | --- a/hw/arm/stm32f405_soc.c |
47 | +/* This is a model of the Arm IoT Kit which is documented in | 43 | +++ b/hw/arm/stm32f405_soc.c |
48 | + * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ecm0601256/index.html | 44 | @@ -XXX,XX +XXX,XX @@ static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp) |
49 | + * It contains: | 45 | } |
50 | + * a Cortex-M33 | 46 | memory_region_add_subregion(system_memory, SRAM_BASE_ADDRESS, &s->sram); |
51 | + * the IDAU | 47 | |
52 | + * some timers and watchdogs | 48 | + memory_region_init_ram(&s->ccm, NULL, "STM32F405.ccm", CCM_SIZE, |
53 | + * two peripheral protection controllers | 49 | + &err); |
54 | + * a memory protection controller | 50 | + if (err != NULL) { |
55 | + * a security controller | ||
56 | + * a bus fabric which arranges that some parts of the address | ||
57 | + * space are secure and non-secure aliases of each other | ||
58 | + * | ||
59 | + * QEMU interface: | ||
60 | + * + QOM property "memory" is a MemoryRegion containing the devices provided | ||
61 | + * by the board model. | ||
62 | + * + QOM property "MAINCLK" is the frequency of the main system clock | ||
63 | + * + QOM property "EXP_NUMIRQ" sets the number of expansion interrupts | ||
64 | + * + Named GPIO inputs "EXP_IRQ" 0..n are the expansion interrupts, which | ||
65 | + * are wired to the NVIC lines 32 .. n+32 | ||
66 | + * Controlling up to 4 AHB expansion PPBs which a system using the IoTKit | ||
67 | + * might provide: | ||
68 | + * + named GPIO outputs apb_ppcexp{0,1,2,3}_nonsec[0..15] | ||
69 | + * + named GPIO outputs apb_ppcexp{0,1,2,3}_ap[0..15] | ||
70 | + * + named GPIO outputs apb_ppcexp{0,1,2,3}_irq_enable | ||
71 | + * + named GPIO outputs apb_ppcexp{0,1,2,3}_irq_clear | ||
72 | + * + named GPIO inputs apb_ppcexp{0,1,2,3}_irq_status | ||
73 | + * Controlling each of the 4 expansion AHB PPCs which a system using the IoTKit | ||
74 | + * might provide: | ||
75 | + * + named GPIO outputs ahb_ppcexp{0,1,2,3}_nonsec[0..15] | ||
76 | + * + named GPIO outputs ahb_ppcexp{0,1,2,3}_ap[0..15] | ||
77 | + * + named GPIO outputs ahb_ppcexp{0,1,2,3}_irq_enable | ||
78 | + * + named GPIO outputs ahb_ppcexp{0,1,2,3}_irq_clear | ||
79 | + * + named GPIO inputs ahb_ppcexp{0,1,2,3}_irq_status | ||
80 | + */ | ||
81 | + | ||
82 | +#ifndef IOTKIT_H | ||
83 | +#define IOTKIT_H | ||
84 | + | ||
85 | +#include "hw/sysbus.h" | ||
86 | +#include "hw/arm/armv7m.h" | ||
87 | +#include "hw/misc/iotkit-secctl.h" | ||
88 | +#include "hw/misc/tz-ppc.h" | ||
89 | +#include "hw/timer/cmsdk-apb-timer.h" | ||
90 | +#include "hw/misc/unimp.h" | ||
91 | +#include "hw/or-irq.h" | ||
92 | +#include "hw/core/split-irq.h" | ||
93 | + | ||
94 | +#define TYPE_IOTKIT "iotkit" | ||
95 | +#define IOTKIT(obj) OBJECT_CHECK(IoTKit, (obj), TYPE_IOTKIT) | ||
96 | + | ||
97 | +/* We have an IRQ splitter and an OR gate input for each external PPC | ||
98 | + * and the 2 internal PPCs | ||
99 | + */ | ||
100 | +#define NUM_EXTERNAL_PPCS (IOTS_NUM_AHB_EXP_PPC + IOTS_NUM_APB_EXP_PPC) | ||
101 | +#define NUM_PPCS (NUM_EXTERNAL_PPCS + 2) | ||
102 | + | ||
103 | +typedef struct IoTKit { | ||
104 | + /*< private >*/ | ||
105 | + SysBusDevice parent_obj; | ||
106 | + | ||
107 | + /*< public >*/ | ||
108 | + ARMv7MState armv7m; | ||
109 | + IoTKitSecCtl secctl; | ||
110 | + TZPPC apb_ppc0; | ||
111 | + TZPPC apb_ppc1; | ||
112 | + CMSDKAPBTIMER timer0; | ||
113 | + CMSDKAPBTIMER timer1; | ||
114 | + qemu_or_irq ppc_irq_orgate; | ||
115 | + SplitIRQ sec_resp_splitter; | ||
116 | + SplitIRQ ppc_irq_splitter[NUM_PPCS]; | ||
117 | + | ||
118 | + UnimplementedDeviceState dualtimer; | ||
119 | + UnimplementedDeviceState s32ktimer; | ||
120 | + | ||
121 | + MemoryRegion container; | ||
122 | + MemoryRegion alias1; | ||
123 | + MemoryRegion alias2; | ||
124 | + MemoryRegion alias3; | ||
125 | + MemoryRegion sram0; | ||
126 | + | ||
127 | + qemu_irq *exp_irqs; | ||
128 | + qemu_irq ppc0_irq; | ||
129 | + qemu_irq ppc1_irq; | ||
130 | + qemu_irq sec_resp_cfg; | ||
131 | + qemu_irq sec_resp_cfg_in; | ||
132 | + qemu_irq nsc_cfg_in; | ||
133 | + | ||
134 | + qemu_irq irq_status_in[NUM_EXTERNAL_PPCS]; | ||
135 | + | ||
136 | + uint32_t nsccfg; | ||
137 | + | ||
138 | + /* Properties */ | ||
139 | + MemoryRegion *board_memory; | ||
140 | + uint32_t exp_numirq; | ||
141 | + uint32_t mainclk_frq; | ||
142 | +} IoTKit; | ||
143 | + | ||
144 | +#endif | ||
145 | diff --git a/hw/arm/iotkit.c b/hw/arm/iotkit.c | ||
146 | new file mode 100644 | ||
147 | index XXXXXXX..XXXXXXX | ||
148 | --- /dev/null | ||
149 | +++ b/hw/arm/iotkit.c | ||
150 | @@ -XXX,XX +XXX,XX @@ | ||
151 | +/* | ||
152 | + * Arm IoT Kit | ||
153 | + * | ||
154 | + * Copyright (c) 2018 Linaro Limited | ||
155 | + * Written by Peter Maydell | ||
156 | + * | ||
157 | + * This program is free software; you can redistribute it and/or modify | ||
158 | + * it under the terms of the GNU General Public License version 2 or | ||
159 | + * (at your option) any later version. | ||
160 | + */ | ||
161 | + | ||
162 | +#include "qemu/osdep.h" | ||
163 | +#include "qemu/log.h" | ||
164 | +#include "qapi/error.h" | ||
165 | +#include "trace.h" | ||
166 | +#include "hw/sysbus.h" | ||
167 | +#include "hw/registerfields.h" | ||
168 | +#include "hw/arm/iotkit.h" | ||
169 | +#include "hw/misc/unimp.h" | ||
170 | +#include "hw/arm/arm.h" | ||
171 | + | ||
172 | +/* Create an alias region of @size bytes starting at @base | ||
173 | + * which mirrors the memory starting at @orig. | ||
174 | + */ | ||
175 | +static void make_alias(IoTKit *s, MemoryRegion *mr, const char *name, | ||
176 | + hwaddr base, hwaddr size, hwaddr orig) | ||
177 | +{ | ||
178 | + memory_region_init_alias(mr, NULL, name, &s->container, orig, size); | ||
179 | + /* The alias is even lower priority than unimplemented_device regions */ | ||
180 | + memory_region_add_subregion_overlap(&s->container, base, mr, -1500); | ||
181 | +} | ||
182 | + | ||
183 | +static void init_sysbus_child(Object *parent, const char *childname, | ||
184 | + void *child, size_t childsize, | ||
185 | + const char *childtype) | ||
186 | +{ | ||
187 | + object_initialize(child, childsize, childtype); | ||
188 | + object_property_add_child(parent, childname, OBJECT(child), &error_abort); | ||
189 | + qdev_set_parent_bus(DEVICE(child), sysbus_get_default()); | ||
190 | +} | ||
191 | + | ||
192 | +static void irq_status_forwarder(void *opaque, int n, int level) | ||
193 | +{ | ||
194 | + qemu_irq destirq = opaque; | ||
195 | + | ||
196 | + qemu_set_irq(destirq, level); | ||
197 | +} | ||
198 | + | ||
199 | +static void nsccfg_handler(void *opaque, int n, int level) | ||
200 | +{ | ||
201 | + IoTKit *s = IOTKIT(opaque); | ||
202 | + | ||
203 | + s->nsccfg = level; | ||
204 | +} | ||
205 | + | ||
206 | +static void iotkit_forward_ppc(IoTKit *s, const char *ppcname, int ppcnum) | ||
207 | +{ | ||
208 | + /* Each of the 4 AHB and 4 APB PPCs that might be present in a | ||
209 | + * system using the IoTKit has a collection of control lines which | ||
210 | + * are provided by the security controller and which we want to | ||
211 | + * expose as control lines on the IoTKit device itself, so the | ||
212 | + * code using the IoTKit can wire them up to the PPCs. | ||
213 | + */ | ||
214 | + SplitIRQ *splitter = &s->ppc_irq_splitter[ppcnum]; | ||
215 | + DeviceState *iotkitdev = DEVICE(s); | ||
216 | + DeviceState *dev_secctl = DEVICE(&s->secctl); | ||
217 | + DeviceState *dev_splitter = DEVICE(splitter); | ||
218 | + char *name; | ||
219 | + | ||
220 | + name = g_strdup_printf("%s_nonsec", ppcname); | ||
221 | + qdev_pass_gpios(dev_secctl, iotkitdev, name); | ||
222 | + g_free(name); | ||
223 | + name = g_strdup_printf("%s_ap", ppcname); | ||
224 | + qdev_pass_gpios(dev_secctl, iotkitdev, name); | ||
225 | + g_free(name); | ||
226 | + name = g_strdup_printf("%s_irq_enable", ppcname); | ||
227 | + qdev_pass_gpios(dev_secctl, iotkitdev, name); | ||
228 | + g_free(name); | ||
229 | + name = g_strdup_printf("%s_irq_clear", ppcname); | ||
230 | + qdev_pass_gpios(dev_secctl, iotkitdev, name); | ||
231 | + g_free(name); | ||
232 | + | ||
233 | + /* irq_status is a little more tricky, because we need to | ||
234 | + * split it so we can send it both to the security controller | ||
235 | + * and to our OR gate for the NVIC interrupt line. | ||
236 | + * Connect up the splitter's outputs, and create a GPIO input | ||
237 | + * which will pass the line state to the input splitter. | ||
238 | + */ | ||
239 | + name = g_strdup_printf("%s_irq_status", ppcname); | ||
240 | + qdev_connect_gpio_out(dev_splitter, 0, | ||
241 | + qdev_get_gpio_in_named(dev_secctl, | ||
242 | + name, 0)); | ||
243 | + qdev_connect_gpio_out(dev_splitter, 1, | ||
244 | + qdev_get_gpio_in(DEVICE(&s->ppc_irq_orgate), ppcnum)); | ||
245 | + s->irq_status_in[ppcnum] = qdev_get_gpio_in(dev_splitter, 0); | ||
246 | + qdev_init_gpio_in_named_with_opaque(iotkitdev, irq_status_forwarder, | ||
247 | + s->irq_status_in[ppcnum], name, 1); | ||
248 | + g_free(name); | ||
249 | +} | ||
250 | + | ||
251 | +static void iotkit_forward_sec_resp_cfg(IoTKit *s) | ||
252 | +{ | ||
253 | + /* Forward the 3rd output from the splitter device as a | ||
254 | + * named GPIO output of the iotkit object. | ||
255 | + */ | ||
256 | + DeviceState *dev = DEVICE(s); | ||
257 | + DeviceState *dev_splitter = DEVICE(&s->sec_resp_splitter); | ||
258 | + | ||
259 | + qdev_init_gpio_out_named(dev, &s->sec_resp_cfg, "sec_resp_cfg", 1); | ||
260 | + s->sec_resp_cfg_in = qemu_allocate_irq(irq_status_forwarder, | ||
261 | + s->sec_resp_cfg, 1); | ||
262 | + qdev_connect_gpio_out(dev_splitter, 2, s->sec_resp_cfg_in); | ||
263 | +} | ||
264 | + | ||
265 | +static void iotkit_init(Object *obj) | ||
266 | +{ | ||
267 | + IoTKit *s = IOTKIT(obj); | ||
268 | + int i; | ||
269 | + | ||
270 | + memory_region_init(&s->container, obj, "iotkit-container", UINT64_MAX); | ||
271 | + | ||
272 | + init_sysbus_child(obj, "armv7m", &s->armv7m, sizeof(s->armv7m), | ||
273 | + TYPE_ARMV7M); | ||
274 | + qdev_prop_set_string(DEVICE(&s->armv7m), "cpu-type", | ||
275 | + ARM_CPU_TYPE_NAME("cortex-m33")); | ||
276 | + | ||
277 | + init_sysbus_child(obj, "secctl", &s->secctl, sizeof(s->secctl), | ||
278 | + TYPE_IOTKIT_SECCTL); | ||
279 | + init_sysbus_child(obj, "apb-ppc0", &s->apb_ppc0, sizeof(s->apb_ppc0), | ||
280 | + TYPE_TZ_PPC); | ||
281 | + init_sysbus_child(obj, "apb-ppc1", &s->apb_ppc1, sizeof(s->apb_ppc1), | ||
282 | + TYPE_TZ_PPC); | ||
283 | + init_sysbus_child(obj, "timer0", &s->timer0, sizeof(s->timer0), | ||
284 | + TYPE_CMSDK_APB_TIMER); | ||
285 | + init_sysbus_child(obj, "timer1", &s->timer1, sizeof(s->timer1), | ||
286 | + TYPE_CMSDK_APB_TIMER); | ||
287 | + init_sysbus_child(obj, "dualtimer", &s->dualtimer, sizeof(s->dualtimer), | ||
288 | + TYPE_UNIMPLEMENTED_DEVICE); | ||
289 | + object_initialize(&s->ppc_irq_orgate, sizeof(s->ppc_irq_orgate), | ||
290 | + TYPE_OR_IRQ); | ||
291 | + object_property_add_child(obj, "ppc-irq-orgate", | ||
292 | + OBJECT(&s->ppc_irq_orgate), &error_abort); | ||
293 | + object_initialize(&s->sec_resp_splitter, sizeof(s->sec_resp_splitter), | ||
294 | + TYPE_SPLIT_IRQ); | ||
295 | + object_property_add_child(obj, "sec-resp-splitter", | ||
296 | + OBJECT(&s->sec_resp_splitter), &error_abort); | ||
297 | + for (i = 0; i < ARRAY_SIZE(s->ppc_irq_splitter); i++) { | ||
298 | + char *name = g_strdup_printf("ppc-irq-splitter-%d", i); | ||
299 | + SplitIRQ *splitter = &s->ppc_irq_splitter[i]; | ||
300 | + | ||
301 | + object_initialize(splitter, sizeof(*splitter), TYPE_SPLIT_IRQ); | ||
302 | + object_property_add_child(obj, name, OBJECT(splitter), &error_abort); | ||
303 | + } | ||
304 | + init_sysbus_child(obj, "s32ktimer", &s->s32ktimer, sizeof(s->s32ktimer), | ||
305 | + TYPE_UNIMPLEMENTED_DEVICE); | ||
306 | +} | ||
307 | + | ||
308 | +static void iotkit_exp_irq(void *opaque, int n, int level) | ||
309 | +{ | ||
310 | + IoTKit *s = IOTKIT(opaque); | ||
311 | + | ||
312 | + qemu_set_irq(s->exp_irqs[n], level); | ||
313 | +} | ||
314 | + | ||
315 | +static void iotkit_realize(DeviceState *dev, Error **errp) | ||
316 | +{ | ||
317 | + IoTKit *s = IOTKIT(dev); | ||
318 | + int i; | ||
319 | + MemoryRegion *mr; | ||
320 | + Error *err = NULL; | ||
321 | + SysBusDevice *sbd_apb_ppc0; | ||
322 | + SysBusDevice *sbd_secctl; | ||
323 | + DeviceState *dev_apb_ppc0; | ||
324 | + DeviceState *dev_apb_ppc1; | ||
325 | + DeviceState *dev_secctl; | ||
326 | + DeviceState *dev_splitter; | ||
327 | + | ||
328 | + if (!s->board_memory) { | ||
329 | + error_setg(errp, "memory property was not set"); | ||
330 | + return; | ||
331 | + } | ||
332 | + | ||
333 | + if (!s->mainclk_frq) { | ||
334 | + error_setg(errp, "MAINCLK property was not set"); | ||
335 | + return; | ||
336 | + } | ||
337 | + | ||
338 | + /* Handling of which devices should be available only to secure | ||
339 | + * code is usually done differently for M profile than for A profile. | ||
340 | + * Instead of putting some devices only into the secure address space, | ||
341 | + * devices exist in both address spaces but with hard-wired security | ||
342 | + * permissions that will cause the CPU to fault for non-secure accesses. | ||
343 | + * | ||
344 | + * The IoTKit has an IDAU (Implementation Defined Access Unit), | ||
345 | + * which specifies hard-wired security permissions for different | ||
346 | + * areas of the physical address space. For the IoTKit IDAU, the | ||
347 | + * top 4 bits of the physical address are the IDAU region ID, and | ||
348 | + * if bit 28 (ie the lowest bit of the ID) is 0 then this is an NS | ||
349 | + * region, otherwise it is an S region. | ||
350 | + * | ||
351 | + * The various devices and RAMs are generally all mapped twice, | ||
352 | + * once into a region that the IDAU defines as secure and once | ||
353 | + * into a non-secure region. They sit behind either a Memory | ||
354 | + * Protection Controller (for RAM) or a Peripheral Protection | ||
355 | + * Controller (for devices), which allow a more fine grained | ||
356 | + * configuration of whether non-secure accesses are permitted. | ||
357 | + * | ||
358 | + * (The other place that guest software can configure security | ||
359 | + * permissions is in the architected SAU (Security Attribution | ||
360 | + * Unit), which is entirely inside the CPU. The IDAU can upgrade | ||
361 | + * the security attributes for a region to more restrictive than | ||
362 | + * the SAU specifies, but cannot downgrade them.) | ||
363 | + * | ||
364 | + * 0x10000000..0x1fffffff alias of 0x00000000..0x0fffffff | ||
365 | + * 0x20000000..0x2007ffff 32KB FPGA block RAM | ||
366 | + * 0x30000000..0x3fffffff alias of 0x20000000..0x2fffffff | ||
367 | + * 0x40000000..0x4000ffff base peripheral region 1 | ||
368 | + * 0x40010000..0x4001ffff CPU peripherals (none for IoTKit) | ||
369 | + * 0x40020000..0x4002ffff system control element peripherals | ||
370 | + * 0x40080000..0x400fffff base peripheral region 2 | ||
371 | + * 0x50000000..0x5fffffff alias of 0x40000000..0x4fffffff | ||
372 | + */ | ||
373 | + | ||
374 | + memory_region_add_subregion_overlap(&s->container, 0, s->board_memory, -1); | ||
375 | + | ||
376 | + qdev_prop_set_uint32(DEVICE(&s->armv7m), "num-irq", s->exp_numirq + 32); | ||
377 | + /* In real hardware the initial Secure VTOR is set from the INITSVTOR0 | ||
378 | + * register in the IoT Kit System Control Register block, and the | ||
379 | + * initial value of that is in turn specifiable by the FPGA that | ||
380 | + * instantiates the IoT Kit. In QEMU we don't implement this wrinkle, | ||
381 | + * and simply set the CPU's init-svtor to the IoT Kit default value. | ||
382 | + */ | ||
383 | + qdev_prop_set_uint32(DEVICE(&s->armv7m), "init-svtor", 0x10000000); | ||
384 | + object_property_set_link(OBJECT(&s->armv7m), OBJECT(&s->container), | ||
385 | + "memory", &err); | ||
386 | + if (err) { | ||
387 | + error_propagate(errp, err); | 51 | + error_propagate(errp, err); |
388 | + return; | 52 | + return; |
389 | + } | 53 | + } |
390 | + object_property_set_link(OBJECT(&s->armv7m), OBJECT(s), "idau", &err); | 54 | + memory_region_add_subregion(system_memory, CCM_BASE_ADDRESS, &s->ccm); |
391 | + if (err) { | ||
392 | + error_propagate(errp, err); | ||
393 | + return; | ||
394 | + } | ||
395 | + object_property_set_bool(OBJECT(&s->armv7m), true, "realized", &err); | ||
396 | + if (err) { | ||
397 | + error_propagate(errp, err); | ||
398 | + return; | ||
399 | + } | ||
400 | + | 55 | + |
401 | + /* Connect our EXP_IRQ GPIOs to the NVIC's lines 32 and up. */ | 56 | armv7m = DEVICE(&s->armv7m); |
402 | + s->exp_irqs = g_new(qemu_irq, s->exp_numirq); | 57 | qdev_prop_set_uint32(armv7m, "num-irq", 96); |
403 | + for (i = 0; i < s->exp_numirq; i++) { | 58 | qdev_prop_set_string(armv7m, "cpu-type", s->cpu_type); |
404 | + s->exp_irqs[i] = qdev_get_gpio_in(DEVICE(&s->armv7m), i + 32); | ||
405 | + } | ||
406 | + qdev_init_gpio_in_named(dev, iotkit_exp_irq, "EXP_IRQ", s->exp_numirq); | ||
407 | + | ||
408 | + /* Set up the big aliases first */ | ||
409 | + make_alias(s, &s->alias1, "alias 1", 0x10000000, 0x10000000, 0x00000000); | ||
410 | + make_alias(s, &s->alias2, "alias 2", 0x30000000, 0x10000000, 0x20000000); | ||
411 | + /* The 0x50000000..0x5fffffff region is not a pure alias: it has | ||
412 | + * a few extra devices that only appear there (generally the | ||
413 | + * control interfaces for the protection controllers). | ||
414 | + * We implement this by mapping those devices over the top of this | ||
415 | + * alias MR at a higher priority. | ||
416 | + */ | ||
417 | + make_alias(s, &s->alias3, "alias 3", 0x50000000, 0x10000000, 0x40000000); | ||
418 | + | ||
419 | + /* This RAM should be behind a Memory Protection Controller, but we | ||
420 | + * don't implement that yet. | ||
421 | + */ | ||
422 | + memory_region_init_ram(&s->sram0, NULL, "iotkit.sram0", 0x00008000, &err); | ||
423 | + if (err) { | ||
424 | + error_propagate(errp, err); | ||
425 | + return; | ||
426 | + } | ||
427 | + memory_region_add_subregion(&s->container, 0x20000000, &s->sram0); | ||
428 | + | ||
429 | + /* Security controller */ | ||
430 | + object_property_set_bool(OBJECT(&s->secctl), true, "realized", &err); | ||
431 | + if (err) { | ||
432 | + error_propagate(errp, err); | ||
433 | + return; | ||
434 | + } | ||
435 | + sbd_secctl = SYS_BUS_DEVICE(&s->secctl); | ||
436 | + dev_secctl = DEVICE(&s->secctl); | ||
437 | + sysbus_mmio_map(sbd_secctl, 0, 0x50080000); | ||
438 | + sysbus_mmio_map(sbd_secctl, 1, 0x40080000); | ||
439 | + | ||
440 | + s->nsc_cfg_in = qemu_allocate_irq(nsccfg_handler, s, 1); | ||
441 | + qdev_connect_gpio_out_named(dev_secctl, "nsc_cfg", 0, s->nsc_cfg_in); | ||
442 | + | ||
443 | + /* The sec_resp_cfg output from the security controller must be split into | ||
444 | + * multiple lines, one for each of the PPCs within the IoTKit and one | ||
445 | + * that will be an output from the IoTKit to the system. | ||
446 | + */ | ||
447 | + object_property_set_int(OBJECT(&s->sec_resp_splitter), 3, | ||
448 | + "num-lines", &err); | ||
449 | + if (err) { | ||
450 | + error_propagate(errp, err); | ||
451 | + return; | ||
452 | + } | ||
453 | + object_property_set_bool(OBJECT(&s->sec_resp_splitter), true, | ||
454 | + "realized", &err); | ||
455 | + if (err) { | ||
456 | + error_propagate(errp, err); | ||
457 | + return; | ||
458 | + } | ||
459 | + dev_splitter = DEVICE(&s->sec_resp_splitter); | ||
460 | + qdev_connect_gpio_out_named(dev_secctl, "sec_resp_cfg", 0, | ||
461 | + qdev_get_gpio_in(dev_splitter, 0)); | ||
462 | + | ||
463 | + /* Devices behind APB PPC0: | ||
464 | + * 0x40000000: timer0 | ||
465 | + * 0x40001000: timer1 | ||
466 | + * 0x40002000: dual timer | ||
467 | + * We must configure and realize each downstream device and connect | ||
468 | + * it to the appropriate PPC port; then we can realize the PPC and | ||
469 | + * map its upstream ends to the right place in the container. | ||
470 | + */ | ||
471 | + qdev_prop_set_uint32(DEVICE(&s->timer0), "pclk-frq", s->mainclk_frq); | ||
472 | + object_property_set_bool(OBJECT(&s->timer0), true, "realized", &err); | ||
473 | + if (err) { | ||
474 | + error_propagate(errp, err); | ||
475 | + return; | ||
476 | + } | ||
477 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->timer0), 0, | ||
478 | + qdev_get_gpio_in(DEVICE(&s->armv7m), 3)); | ||
479 | + mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->timer0), 0); | ||
480 | + object_property_set_link(OBJECT(&s->apb_ppc0), OBJECT(mr), "port[0]", &err); | ||
481 | + if (err) { | ||
482 | + error_propagate(errp, err); | ||
483 | + return; | ||
484 | + } | ||
485 | + | ||
486 | + qdev_prop_set_uint32(DEVICE(&s->timer1), "pclk-frq", s->mainclk_frq); | ||
487 | + object_property_set_bool(OBJECT(&s->timer1), true, "realized", &err); | ||
488 | + if (err) { | ||
489 | + error_propagate(errp, err); | ||
490 | + return; | ||
491 | + } | ||
492 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->timer1), 0, | ||
493 | + qdev_get_gpio_in(DEVICE(&s->armv7m), 3)); | ||
494 | + mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->timer1), 0); | ||
495 | + object_property_set_link(OBJECT(&s->apb_ppc0), OBJECT(mr), "port[1]", &err); | ||
496 | + if (err) { | ||
497 | + error_propagate(errp, err); | ||
498 | + return; | ||
499 | + } | ||
500 | + | ||
501 | + qdev_prop_set_string(DEVICE(&s->dualtimer), "name", "Dual timer"); | ||
502 | + qdev_prop_set_uint64(DEVICE(&s->dualtimer), "size", 0x1000); | ||
503 | + object_property_set_bool(OBJECT(&s->dualtimer), true, "realized", &err); | ||
504 | + if (err) { | ||
505 | + error_propagate(errp, err); | ||
506 | + return; | ||
507 | + } | ||
508 | + mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->dualtimer), 0); | ||
509 | + object_property_set_link(OBJECT(&s->apb_ppc0), OBJECT(mr), "port[2]", &err); | ||
510 | + if (err) { | ||
511 | + error_propagate(errp, err); | ||
512 | + return; | ||
513 | + } | ||
514 | + | ||
515 | + object_property_set_bool(OBJECT(&s->apb_ppc0), true, "realized", &err); | ||
516 | + if (err) { | ||
517 | + error_propagate(errp, err); | ||
518 | + return; | ||
519 | + } | ||
520 | + | ||
521 | + sbd_apb_ppc0 = SYS_BUS_DEVICE(&s->apb_ppc0); | ||
522 | + dev_apb_ppc0 = DEVICE(&s->apb_ppc0); | ||
523 | + | ||
524 | + mr = sysbus_mmio_get_region(sbd_apb_ppc0, 0); | ||
525 | + memory_region_add_subregion(&s->container, 0x40000000, mr); | ||
526 | + mr = sysbus_mmio_get_region(sbd_apb_ppc0, 1); | ||
527 | + memory_region_add_subregion(&s->container, 0x40001000, mr); | ||
528 | + mr = sysbus_mmio_get_region(sbd_apb_ppc0, 2); | ||
529 | + memory_region_add_subregion(&s->container, 0x40002000, mr); | ||
530 | + for (i = 0; i < IOTS_APB_PPC0_NUM_PORTS; i++) { | ||
531 | + qdev_connect_gpio_out_named(dev_secctl, "apb_ppc0_nonsec", i, | ||
532 | + qdev_get_gpio_in_named(dev_apb_ppc0, | ||
533 | + "cfg_nonsec", i)); | ||
534 | + qdev_connect_gpio_out_named(dev_secctl, "apb_ppc0_ap", i, | ||
535 | + qdev_get_gpio_in_named(dev_apb_ppc0, | ||
536 | + "cfg_ap", i)); | ||
537 | + } | ||
538 | + qdev_connect_gpio_out_named(dev_secctl, "apb_ppc0_irq_enable", 0, | ||
539 | + qdev_get_gpio_in_named(dev_apb_ppc0, | ||
540 | + "irq_enable", 0)); | ||
541 | + qdev_connect_gpio_out_named(dev_secctl, "apb_ppc0_irq_clear", 0, | ||
542 | + qdev_get_gpio_in_named(dev_apb_ppc0, | ||
543 | + "irq_clear", 0)); | ||
544 | + qdev_connect_gpio_out(dev_splitter, 0, | ||
545 | + qdev_get_gpio_in_named(dev_apb_ppc0, | ||
546 | + "cfg_sec_resp", 0)); | ||
547 | + | ||
548 | + /* All the PPC irq lines (from the 2 internal PPCs and the 8 external | ||
549 | + * ones) are sent individually to the security controller, and also | ||
550 | + * ORed together to give a single combined PPC interrupt to the NVIC. | ||
551 | + */ | ||
552 | + object_property_set_int(OBJECT(&s->ppc_irq_orgate), | ||
553 | + NUM_PPCS, "num-lines", &err); | ||
554 | + if (err) { | ||
555 | + error_propagate(errp, err); | ||
556 | + return; | ||
557 | + } | ||
558 | + object_property_set_bool(OBJECT(&s->ppc_irq_orgate), true, | ||
559 | + "realized", &err); | ||
560 | + if (err) { | ||
561 | + error_propagate(errp, err); | ||
562 | + return; | ||
563 | + } | ||
564 | + qdev_connect_gpio_out(DEVICE(&s->ppc_irq_orgate), 0, | ||
565 | + qdev_get_gpio_in(DEVICE(&s->armv7m), 10)); | ||
566 | + | ||
567 | + /* 0x40010000 .. 0x4001ffff: private CPU region: unused in IoTKit */ | ||
568 | + | ||
569 | + /* 0x40020000 .. 0x4002ffff : IoTKit system control peripheral region */ | ||
570 | + /* Devices behind APB PPC1: | ||
571 | + * 0x4002f000: S32K timer | ||
572 | + */ | ||
573 | + qdev_prop_set_string(DEVICE(&s->s32ktimer), "name", "S32KTIMER"); | ||
574 | + qdev_prop_set_uint64(DEVICE(&s->s32ktimer), "size", 0x1000); | ||
575 | + object_property_set_bool(OBJECT(&s->s32ktimer), true, "realized", &err); | ||
576 | + if (err) { | ||
577 | + error_propagate(errp, err); | ||
578 | + return; | ||
579 | + } | ||
580 | + mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->s32ktimer), 0); | ||
581 | + object_property_set_link(OBJECT(&s->apb_ppc1), OBJECT(mr), "port[0]", &err); | ||
582 | + if (err) { | ||
583 | + error_propagate(errp, err); | ||
584 | + return; | ||
585 | + } | ||
586 | + | ||
587 | + object_property_set_bool(OBJECT(&s->apb_ppc1), true, "realized", &err); | ||
588 | + if (err) { | ||
589 | + error_propagate(errp, err); | ||
590 | + return; | ||
591 | + } | ||
592 | + mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->apb_ppc1), 0); | ||
593 | + memory_region_add_subregion(&s->container, 0x4002f000, mr); | ||
594 | + | ||
595 | + dev_apb_ppc1 = DEVICE(&s->apb_ppc1); | ||
596 | + qdev_connect_gpio_out_named(dev_secctl, "apb_ppc1_nonsec", 0, | ||
597 | + qdev_get_gpio_in_named(dev_apb_ppc1, | ||
598 | + "cfg_nonsec", 0)); | ||
599 | + qdev_connect_gpio_out_named(dev_secctl, "apb_ppc1_ap", 0, | ||
600 | + qdev_get_gpio_in_named(dev_apb_ppc1, | ||
601 | + "cfg_ap", 0)); | ||
602 | + qdev_connect_gpio_out_named(dev_secctl, "apb_ppc1_irq_enable", 0, | ||
603 | + qdev_get_gpio_in_named(dev_apb_ppc1, | ||
604 | + "irq_enable", 0)); | ||
605 | + qdev_connect_gpio_out_named(dev_secctl, "apb_ppc1_irq_clear", 0, | ||
606 | + qdev_get_gpio_in_named(dev_apb_ppc1, | ||
607 | + "irq_clear", 0)); | ||
608 | + qdev_connect_gpio_out(dev_splitter, 1, | ||
609 | + qdev_get_gpio_in_named(dev_apb_ppc1, | ||
610 | + "cfg_sec_resp", 0)); | ||
611 | + | ||
612 | + /* Using create_unimplemented_device() maps the stub into the | ||
613 | + * system address space rather than into our container, but the | ||
614 | + * overall effect to the guest is the same. | ||
615 | + */ | ||
616 | + create_unimplemented_device("SYSINFO", 0x40020000, 0x1000); | ||
617 | + | ||
618 | + create_unimplemented_device("SYSCONTROL", 0x50021000, 0x1000); | ||
619 | + create_unimplemented_device("S32KWATCHDOG", 0x5002e000, 0x1000); | ||
620 | + | ||
621 | + /* 0x40080000 .. 0x4008ffff : IoTKit second Base peripheral region */ | ||
622 | + | ||
623 | + create_unimplemented_device("NS watchdog", 0x40081000, 0x1000); | ||
624 | + create_unimplemented_device("S watchdog", 0x50081000, 0x1000); | ||
625 | + | ||
626 | + create_unimplemented_device("SRAM0 MPC", 0x50083000, 0x1000); | ||
627 | + | ||
628 | + for (i = 0; i < ARRAY_SIZE(s->ppc_irq_splitter); i++) { | ||
629 | + Object *splitter = OBJECT(&s->ppc_irq_splitter[i]); | ||
630 | + | ||
631 | + object_property_set_int(splitter, 2, "num-lines", &err); | ||
632 | + if (err) { | ||
633 | + error_propagate(errp, err); | ||
634 | + return; | ||
635 | + } | ||
636 | + object_property_set_bool(splitter, true, "realized", &err); | ||
637 | + if (err) { | ||
638 | + error_propagate(errp, err); | ||
639 | + return; | ||
640 | + } | ||
641 | + } | ||
642 | + | ||
643 | + for (i = 0; i < IOTS_NUM_AHB_EXP_PPC; i++) { | ||
644 | + char *ppcname = g_strdup_printf("ahb_ppcexp%d", i); | ||
645 | + | ||
646 | + iotkit_forward_ppc(s, ppcname, i); | ||
647 | + g_free(ppcname); | ||
648 | + } | ||
649 | + | ||
650 | + for (i = 0; i < IOTS_NUM_APB_EXP_PPC; i++) { | ||
651 | + char *ppcname = g_strdup_printf("apb_ppcexp%d", i); | ||
652 | + | ||
653 | + iotkit_forward_ppc(s, ppcname, i + IOTS_NUM_AHB_EXP_PPC); | ||
654 | + g_free(ppcname); | ||
655 | + } | ||
656 | + | ||
657 | + for (i = NUM_EXTERNAL_PPCS; i < NUM_PPCS; i++) { | ||
658 | + /* Wire up IRQ splitter for internal PPCs */ | ||
659 | + DeviceState *devs = DEVICE(&s->ppc_irq_splitter[i]); | ||
660 | + char *gpioname = g_strdup_printf("apb_ppc%d_irq_status", | ||
661 | + i - NUM_EXTERNAL_PPCS); | ||
662 | + TZPPC *ppc = (i == NUM_EXTERNAL_PPCS) ? &s->apb_ppc0 : &s->apb_ppc1; | ||
663 | + | ||
664 | + qdev_connect_gpio_out(devs, 0, | ||
665 | + qdev_get_gpio_in_named(dev_secctl, gpioname, 0)); | ||
666 | + qdev_connect_gpio_out(devs, 1, | ||
667 | + qdev_get_gpio_in(DEVICE(&s->ppc_irq_orgate), i)); | ||
668 | + qdev_connect_gpio_out_named(DEVICE(ppc), "irq", 0, | ||
669 | + qdev_get_gpio_in(devs, 0)); | ||
670 | + } | ||
671 | + | ||
672 | + iotkit_forward_sec_resp_cfg(s); | ||
673 | + | ||
674 | + system_clock_scale = NANOSECONDS_PER_SECOND / s->mainclk_frq; | ||
675 | +} | ||
676 | + | ||
677 | +static void iotkit_idau_check(IDAUInterface *ii, uint32_t address, | ||
678 | + int *iregion, bool *exempt, bool *ns, bool *nsc) | ||
679 | +{ | ||
680 | + /* For IoTKit systems the IDAU responses are simple logical functions | ||
681 | + * of the address bits. The NSC attribute is guest-adjustable via the | ||
682 | + * NSCCFG register in the security controller. | ||
683 | + */ | ||
684 | + IoTKit *s = IOTKIT(ii); | ||
685 | + int region = extract32(address, 28, 4); | ||
686 | + | ||
687 | + *ns = !(region & 1); | ||
688 | + *nsc = (region == 1 && (s->nsccfg & 1)) || (region == 3 && (s->nsccfg & 2)); | ||
689 | + /* 0xe0000000..0xe00fffff and 0xf0000000..0xf00fffff are exempt */ | ||
690 | + *exempt = (address & 0xeff00000) == 0xe0000000; | ||
691 | + *iregion = region; | ||
692 | +} | ||
693 | + | ||
694 | +static const VMStateDescription iotkit_vmstate = { | ||
695 | + .name = "iotkit", | ||
696 | + .version_id = 1, | ||
697 | + .minimum_version_id = 1, | ||
698 | + .fields = (VMStateField[]) { | ||
699 | + VMSTATE_UINT32(nsccfg, IoTKit), | ||
700 | + VMSTATE_END_OF_LIST() | ||
701 | + } | ||
702 | +}; | ||
703 | + | ||
704 | +static Property iotkit_properties[] = { | ||
705 | + DEFINE_PROP_LINK("memory", IoTKit, board_memory, TYPE_MEMORY_REGION, | ||
706 | + MemoryRegion *), | ||
707 | + DEFINE_PROP_UINT32("EXP_NUMIRQ", IoTKit, exp_numirq, 64), | ||
708 | + DEFINE_PROP_UINT32("MAINCLK", IoTKit, mainclk_frq, 0), | ||
709 | + DEFINE_PROP_END_OF_LIST() | ||
710 | +}; | ||
711 | + | ||
712 | +static void iotkit_reset(DeviceState *dev) | ||
713 | +{ | ||
714 | + IoTKit *s = IOTKIT(dev); | ||
715 | + | ||
716 | + s->nsccfg = 0; | ||
717 | +} | ||
718 | + | ||
719 | +static void iotkit_class_init(ObjectClass *klass, void *data) | ||
720 | +{ | ||
721 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
722 | + IDAUInterfaceClass *iic = IDAU_INTERFACE_CLASS(klass); | ||
723 | + | ||
724 | + dc->realize = iotkit_realize; | ||
725 | + dc->vmsd = &iotkit_vmstate; | ||
726 | + dc->props = iotkit_properties; | ||
727 | + dc->reset = iotkit_reset; | ||
728 | + iic->check = iotkit_idau_check; | ||
729 | +} | ||
730 | + | ||
731 | +static const TypeInfo iotkit_info = { | ||
732 | + .name = TYPE_IOTKIT, | ||
733 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
734 | + .instance_size = sizeof(IoTKit), | ||
735 | + .instance_init = iotkit_init, | ||
736 | + .class_init = iotkit_class_init, | ||
737 | + .interfaces = (InterfaceInfo[]) { | ||
738 | + { TYPE_IDAU_INTERFACE }, | ||
739 | + { } | ||
740 | + } | ||
741 | +}; | ||
742 | + | ||
743 | +static void iotkit_register_types(void) | ||
744 | +{ | ||
745 | + type_register_static(&iotkit_info); | ||
746 | +} | ||
747 | + | ||
748 | +type_init(iotkit_register_types); | ||
749 | diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak | ||
750 | index XXXXXXX..XXXXXXX 100644 | ||
751 | --- a/default-configs/arm-softmmu.mak | ||
752 | +++ b/default-configs/arm-softmmu.mak | ||
753 | @@ -XXX,XX +XXX,XX @@ CONFIG_MPS2_FPGAIO=y | ||
754 | CONFIG_MPS2_SCC=y | ||
755 | |||
756 | CONFIG_TZ_PPC=y | ||
757 | +CONFIG_IOTKIT=y | ||
758 | CONFIG_IOTKIT_SECCTL=y | ||
759 | |||
760 | CONFIG_VERSATILE_PCI=y | ||
761 | -- | 59 | -- |
762 | 2.16.2 | 60 | 2.34.1 |
763 | 61 | ||
764 | 62 | diff view generated by jsdifflib |
1 | In some board or SoC models it is necessary to split a qemu_irq line | 1 | From: Felipe Balbi <balbi@kernel.org> |
---|---|---|---|
2 | so that one input can feed multiple outputs. We currently have | ||
3 | qemu_irq_split() for this, but that has several deficiencies: | ||
4 | * it can only handle splitting a line into two | ||
5 | * it unavoidably leaks memory, so it can't be used | ||
6 | in a device that can be deleted | ||
7 | 2 | ||
8 | Implement a qdev device that encapsulates splitting of IRQs, with a | 3 | Olimex makes a series of low-cost STM32 boards. This commit introduces |
9 | configurable number of outputs. (This is in some ways the inverse of | 4 | the minimum setup to support SMT32-H405. See [1] for details |
10 | the TYPE_OR_IRQ device.) | ||
11 | 5 | ||
6 | [1] https://www.olimex.com/Products/ARM/ST/STM32-H405/ | ||
7 | |||
8 | Signed-off-by: Felipe Balbi <balbi@kernel.org> | ||
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
10 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
11 | Message-id: 20221230145733.200496-3-balbi@kernel.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20180220180325.29818-13-peter.maydell@linaro.org | ||
15 | --- | 13 | --- |
16 | hw/core/Makefile.objs | 1 + | 14 | docs/system/arm/stm32.rst | 1 + |
17 | include/hw/core/split-irq.h | 57 +++++++++++++++++++++++++++++ | 15 | configs/devices/arm-softmmu/default.mak | 1 + |
18 | include/hw/irq.h | 4 +- | 16 | hw/arm/olimex-stm32-h405.c | 69 +++++++++++++++++++++++++ |
19 | hw/core/split-irq.c | 89 +++++++++++++++++++++++++++++++++++++++++++++ | 17 | MAINTAINERS | 6 +++ |
20 | 4 files changed, 150 insertions(+), 1 deletion(-) | 18 | hw/arm/Kconfig | 4 ++ |
21 | create mode 100644 include/hw/core/split-irq.h | 19 | hw/arm/meson.build | 1 + |
22 | create mode 100644 hw/core/split-irq.c | 20 | 6 files changed, 82 insertions(+) |
21 | create mode 100644 hw/arm/olimex-stm32-h405.c | ||
23 | 22 | ||
24 | diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs | 23 | diff --git a/docs/system/arm/stm32.rst b/docs/system/arm/stm32.rst |
25 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/hw/core/Makefile.objs | 25 | --- a/docs/system/arm/stm32.rst |
27 | +++ b/hw/core/Makefile.objs | 26 | +++ b/docs/system/arm/stm32.rst |
28 | @@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_FITLOADER) += loader-fit.o | 27 | @@ -XXX,XX +XXX,XX @@ The STM32F4 series is based on ARM Cortex-M4F core. This series is pin-to-pin |
29 | common-obj-$(CONFIG_SOFTMMU) += qdev-properties-system.o | 28 | compatible with STM32F2 series. The following machines are based on this chip : |
30 | common-obj-$(CONFIG_SOFTMMU) += register.o | 29 | |
31 | common-obj-$(CONFIG_SOFTMMU) += or-irq.o | 30 | - ``netduinoplus2`` Netduino Plus 2 board with STM32F405RGT6 microcontroller |
32 | +common-obj-$(CONFIG_SOFTMMU) += split-irq.o | 31 | +- ``olimex-stm32-h405`` Olimex STM32 H405 board with STM32F405RGT6 microcontroller |
33 | common-obj-$(CONFIG_PLATFORM_BUS) += platform-bus.o | 32 | |
34 | 33 | There are many other STM32 series that are currently not supported by QEMU. | |
35 | obj-$(CONFIG_SOFTMMU) += generic-loader.o | 34 | |
36 | diff --git a/include/hw/core/split-irq.h b/include/hw/core/split-irq.h | 35 | diff --git a/configs/devices/arm-softmmu/default.mak b/configs/devices/arm-softmmu/default.mak |
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/configs/devices/arm-softmmu/default.mak | ||
38 | +++ b/configs/devices/arm-softmmu/default.mak | ||
39 | @@ -XXX,XX +XXX,XX @@ CONFIG_COLLIE=y | ||
40 | CONFIG_ASPEED_SOC=y | ||
41 | CONFIG_NETDUINO2=y | ||
42 | CONFIG_NETDUINOPLUS2=y | ||
43 | +CONFIG_OLIMEX_STM32_H405=y | ||
44 | CONFIG_MPS2=y | ||
45 | CONFIG_RASPI=y | ||
46 | CONFIG_DIGIC=y | ||
47 | diff --git a/hw/arm/olimex-stm32-h405.c b/hw/arm/olimex-stm32-h405.c | ||
37 | new file mode 100644 | 48 | new file mode 100644 |
38 | index XXXXXXX..XXXXXXX | 49 | index XXXXXXX..XXXXXXX |
39 | --- /dev/null | 50 | --- /dev/null |
40 | +++ b/include/hw/core/split-irq.h | 51 | +++ b/hw/arm/olimex-stm32-h405.c |
41 | @@ -XXX,XX +XXX,XX @@ | 52 | @@ -XXX,XX +XXX,XX @@ |
42 | +/* | 53 | +/* |
43 | + * IRQ splitter device. | 54 | + * ST STM32VLDISCOVERY machine |
55 | + * Olimex STM32-H405 machine | ||
44 | + * | 56 | + * |
45 | + * Copyright (c) 2018 Linaro Limited. | 57 | + * Copyright (c) 2022 Felipe Balbi <balbi@kernel.org> |
46 | + * Written by Peter Maydell | ||
47 | + * | ||
48 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
49 | + * of this software and associated documentation files (the "Software"), to deal | ||
50 | + * in the Software without restriction, including without limitation the rights | ||
51 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
52 | + * copies of the Software, and to permit persons to whom the Software is | ||
53 | + * furnished to do so, subject to the following conditions: | ||
54 | + * | ||
55 | + * The above copyright notice and this permission notice shall be included in | ||
56 | + * all copies or substantial portions of the Software. | ||
57 | + * | ||
58 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
59 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
60 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
61 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
62 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
63 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
64 | + * THE SOFTWARE. | ||
65 | + */ | ||
66 | + | ||
67 | +/* This is a simple device which has one GPIO input line and multiple | ||
68 | + * GPIO output lines. Any change on the input line is forwarded to all | ||
69 | + * of the outputs. | ||
70 | + * | ||
71 | + * QEMU interface: | ||
72 | + * + one unnamed GPIO input: the input line | ||
73 | + * + N unnamed GPIO outputs: the output lines | ||
74 | + * + QOM property "num-lines": sets the number of output lines | ||
75 | + */ | ||
76 | +#ifndef HW_SPLIT_IRQ_H | ||
77 | +#define HW_SPLIT_IRQ_H | ||
78 | + | ||
79 | +#include "hw/irq.h" | ||
80 | +#include "hw/sysbus.h" | ||
81 | +#include "qom/object.h" | ||
82 | + | ||
83 | +#define TYPE_SPLIT_IRQ "split-irq" | ||
84 | + | ||
85 | +#define MAX_SPLIT_LINES 16 | ||
86 | + | ||
87 | +typedef struct SplitIRQ SplitIRQ; | ||
88 | + | ||
89 | +#define SPLIT_IRQ(obj) OBJECT_CHECK(SplitIRQ, (obj), TYPE_SPLIT_IRQ) | ||
90 | + | ||
91 | +struct SplitIRQ { | ||
92 | + DeviceState parent_obj; | ||
93 | + | ||
94 | + qemu_irq out_irq[MAX_SPLIT_LINES]; | ||
95 | + uint16_t num_lines; | ||
96 | +}; | ||
97 | + | ||
98 | +#endif | ||
99 | diff --git a/include/hw/irq.h b/include/hw/irq.h | ||
100 | index XXXXXXX..XXXXXXX 100644 | ||
101 | --- a/include/hw/irq.h | ||
102 | +++ b/include/hw/irq.h | ||
103 | @@ -XXX,XX +XXX,XX @@ void qemu_free_irq(qemu_irq irq); | ||
104 | /* Returns a new IRQ with opposite polarity. */ | ||
105 | qemu_irq qemu_irq_invert(qemu_irq irq); | ||
106 | |||
107 | -/* Returns a new IRQ which feeds into both the passed IRQs */ | ||
108 | +/* Returns a new IRQ which feeds into both the passed IRQs. | ||
109 | + * It's probably better to use the TYPE_SPLIT_IRQ device instead. | ||
110 | + */ | ||
111 | qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2); | ||
112 | |||
113 | /* Returns a new IRQ set which connects 1:1 to another IRQ set, which | ||
114 | diff --git a/hw/core/split-irq.c b/hw/core/split-irq.c | ||
115 | new file mode 100644 | ||
116 | index XXXXXXX..XXXXXXX | ||
117 | --- /dev/null | ||
118 | +++ b/hw/core/split-irq.c | ||
119 | @@ -XXX,XX +XXX,XX @@ | ||
120 | +/* | ||
121 | + * IRQ splitter device. | ||
122 | + * | ||
123 | + * Copyright (c) 2018 Linaro Limited. | ||
124 | + * Written by Peter Maydell | ||
125 | + * | 58 | + * |
126 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | 59 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
127 | + * of this software and associated documentation files (the "Software"), to deal | 60 | + * of this software and associated documentation files (the "Software"), to deal |
128 | + * in the Software without restriction, including without limitation the rights | 61 | + * in the Software without restriction, including without limitation the rights |
129 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 62 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
... | ... | ||
141 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | 74 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
142 | + * THE SOFTWARE. | 75 | + * THE SOFTWARE. |
143 | + */ | 76 | + */ |
144 | + | 77 | + |
145 | +#include "qemu/osdep.h" | 78 | +#include "qemu/osdep.h" |
146 | +#include "hw/core/split-irq.h" | ||
147 | +#include "qapi/error.h" | 79 | +#include "qapi/error.h" |
80 | +#include "hw/boards.h" | ||
81 | +#include "hw/qdev-properties.h" | ||
82 | +#include "hw/qdev-clock.h" | ||
83 | +#include "qemu/error-report.h" | ||
84 | +#include "hw/arm/stm32f405_soc.h" | ||
85 | +#include "hw/arm/boot.h" | ||
148 | + | 86 | + |
149 | +static void split_irq_handler(void *opaque, int n, int level) | 87 | +/* olimex-stm32-h405 implementation is derived from netduinoplus2 */ |
88 | + | ||
89 | +/* Main SYSCLK frequency in Hz (168MHz) */ | ||
90 | +#define SYSCLK_FRQ 168000000ULL | ||
91 | + | ||
92 | +static void olimex_stm32_h405_init(MachineState *machine) | ||
150 | +{ | 93 | +{ |
151 | + SplitIRQ *s = SPLIT_IRQ(opaque); | 94 | + DeviceState *dev; |
152 | + int i; | 95 | + Clock *sysclk; |
153 | + | 96 | + |
154 | + for (i = 0; i < s->num_lines; i++) { | 97 | + /* This clock doesn't need migration because it is fixed-frequency */ |
155 | + qemu_set_irq(s->out_irq[i], level); | 98 | + sysclk = clock_new(OBJECT(machine), "SYSCLK"); |
156 | + } | 99 | + clock_set_hz(sysclk, SYSCLK_FRQ); |
100 | + | ||
101 | + dev = qdev_new(TYPE_STM32F405_SOC); | ||
102 | + qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m4")); | ||
103 | + qdev_connect_clock_in(dev, "sysclk", sysclk); | ||
104 | + sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); | ||
105 | + | ||
106 | + armv7m_load_kernel(ARM_CPU(first_cpu), | ||
107 | + machine->kernel_filename, | ||
108 | + 0, FLASH_SIZE); | ||
157 | +} | 109 | +} |
158 | + | 110 | + |
159 | +static void split_irq_init(Object *obj) | 111 | +static void olimex_stm32_h405_machine_init(MachineClass *mc) |
160 | +{ | 112 | +{ |
161 | + qdev_init_gpio_in(DEVICE(obj), split_irq_handler, 1); | 113 | + mc->desc = "Olimex STM32-H405 (Cortex-M4)"; |
114 | + mc->init = olimex_stm32_h405_init; | ||
115 | + mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m4"); | ||
116 | + | ||
117 | + /* SRAM pre-allocated as part of the SoC instantiation */ | ||
118 | + mc->default_ram_size = 0; | ||
162 | +} | 119 | +} |
163 | + | 120 | + |
164 | +static void split_irq_realize(DeviceState *dev, Error **errp) | 121 | +DEFINE_MACHINE("olimex-stm32-h405", olimex_stm32_h405_machine_init) |
165 | +{ | 122 | diff --git a/MAINTAINERS b/MAINTAINERS |
166 | + SplitIRQ *s = SPLIT_IRQ(dev); | 123 | index XXXXXXX..XXXXXXX 100644 |
124 | --- a/MAINTAINERS | ||
125 | +++ b/MAINTAINERS | ||
126 | @@ -XXX,XX +XXX,XX @@ L: qemu-arm@nongnu.org | ||
127 | S: Maintained | ||
128 | F: hw/arm/netduinoplus2.c | ||
129 | |||
130 | +Olimex STM32 H405 | ||
131 | +M: Felipe Balbi <balbi@kernel.org> | ||
132 | +L: qemu-arm@nongnu.org | ||
133 | +S: Maintained | ||
134 | +F: hw/arm/olimex-stm32-h405.c | ||
167 | + | 135 | + |
168 | + if (s->num_lines < 1 || s->num_lines >= MAX_SPLIT_LINES) { | 136 | SmartFusion2 |
169 | + error_setg(errp, | 137 | M: Subbaraya Sundeep <sundeep.lkml@gmail.com> |
170 | + "IRQ splitter number of lines %d is not between 1 and %d", | 138 | M: Peter Maydell <peter.maydell@linaro.org> |
171 | + s->num_lines, MAX_SPLIT_LINES); | 139 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig |
172 | + return; | 140 | index XXXXXXX..XXXXXXX 100644 |
173 | + } | 141 | --- a/hw/arm/Kconfig |
142 | +++ b/hw/arm/Kconfig | ||
143 | @@ -XXX,XX +XXX,XX @@ config NETDUINOPLUS2 | ||
144 | bool | ||
145 | select STM32F405_SOC | ||
146 | |||
147 | +config OLIMEX_STM32_H405 | ||
148 | + bool | ||
149 | + select STM32F405_SOC | ||
174 | + | 150 | + |
175 | + qdev_init_gpio_out(dev, s->out_irq, s->num_lines); | 151 | config NSERIES |
176 | +} | 152 | bool |
177 | + | 153 | select OMAP |
178 | +static Property split_irq_properties[] = { | 154 | diff --git a/hw/arm/meson.build b/hw/arm/meson.build |
179 | + DEFINE_PROP_UINT16("num-lines", SplitIRQ, num_lines, 1), | 155 | index XXXXXXX..XXXXXXX 100644 |
180 | + DEFINE_PROP_END_OF_LIST(), | 156 | --- a/hw/arm/meson.build |
181 | +}; | 157 | +++ b/hw/arm/meson.build |
182 | + | 158 | @@ -XXX,XX +XXX,XX @@ arm_ss.add(when: 'CONFIG_MICROBIT', if_true: files('microbit.c')) |
183 | +static void split_irq_class_init(ObjectClass *klass, void *data) | 159 | arm_ss.add(when: 'CONFIG_MUSICPAL', if_true: files('musicpal.c')) |
184 | +{ | 160 | arm_ss.add(when: 'CONFIG_NETDUINO2', if_true: files('netduino2.c')) |
185 | + DeviceClass *dc = DEVICE_CLASS(klass); | 161 | arm_ss.add(when: 'CONFIG_NETDUINOPLUS2', if_true: files('netduinoplus2.c')) |
186 | + | 162 | +arm_ss.add(when: 'CONFIG_OLIMEX_STM32_H405', if_true: files('olimex-stm32-h405.c')) |
187 | + /* No state to reset or migrate */ | 163 | arm_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx.c', 'npcm7xx_boards.c')) |
188 | + dc->props = split_irq_properties; | 164 | arm_ss.add(when: 'CONFIG_NSERIES', if_true: files('nseries.c')) |
189 | + dc->realize = split_irq_realize; | 165 | arm_ss.add(when: 'CONFIG_SX1', if_true: files('omap_sx1.c')) |
190 | + | ||
191 | + /* Reason: Needs to be wired up to work */ | ||
192 | + dc->user_creatable = false; | ||
193 | +} | ||
194 | + | ||
195 | +static const TypeInfo split_irq_type_info = { | ||
196 | + .name = TYPE_SPLIT_IRQ, | ||
197 | + .parent = TYPE_DEVICE, | ||
198 | + .instance_size = sizeof(SplitIRQ), | ||
199 | + .instance_init = split_irq_init, | ||
200 | + .class_init = split_irq_class_init, | ||
201 | +}; | ||
202 | + | ||
203 | +static void split_irq_register_types(void) | ||
204 | +{ | ||
205 | + type_register_static(&split_irq_type_info); | ||
206 | +} | ||
207 | + | ||
208 | +type_init(split_irq_register_types) | ||
209 | -- | 166 | -- |
210 | 2.16.2 | 167 | 2.34.1 |
211 | 168 | ||
212 | 169 | diff view generated by jsdifflib |
1 | The Arm IoT Kit includes a "security controller" which is largely a | 1 | From: Strahinja Jankovic <strahinjapjankovic@gmail.com> |
---|---|---|---|
2 | collection of registers for controlling the PPCs and other bits of | ||
3 | glue in the system. This commit provides the initial skeleton of the | ||
4 | device, implementing just the ID registers, and a couple of read-only | ||
5 | read-as-zero registers. | ||
6 | 2 | ||
3 | During SPL boot several Clock Controller Module (CCM) registers are | ||
4 | read, most important are PLL and Tuning, as well as divisor registers. | ||
5 | |||
6 | This patch adds these registers and initializes reset values from user's | ||
7 | guide. | ||
8 | |||
9 | Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com> | ||
10 | |||
11 | Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com> | ||
12 | Message-id: 20221226220303.14420-2-strahinja.p.jankovic@gmail.com | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20180220180325.29818-16-peter.maydell@linaro.org | ||
10 | --- | 14 | --- |
11 | hw/misc/Makefile.objs | 1 + | 15 | include/hw/arm/allwinner-a10.h | 2 + |
12 | include/hw/misc/iotkit-secctl.h | 39 ++++ | 16 | include/hw/misc/allwinner-a10-ccm.h | 67 +++++++++ |
13 | hw/misc/iotkit-secctl.c | 448 ++++++++++++++++++++++++++++++++++++++++ | 17 | hw/arm/allwinner-a10.c | 7 + |
14 | default-configs/arm-softmmu.mak | 1 + | 18 | hw/misc/allwinner-a10-ccm.c | 224 ++++++++++++++++++++++++++++ |
15 | hw/misc/trace-events | 7 + | 19 | hw/arm/Kconfig | 1 + |
16 | 5 files changed, 496 insertions(+) | 20 | hw/misc/Kconfig | 3 + |
17 | create mode 100644 include/hw/misc/iotkit-secctl.h | 21 | hw/misc/meson.build | 1 + |
18 | create mode 100644 hw/misc/iotkit-secctl.c | 22 | 7 files changed, 305 insertions(+) |
23 | create mode 100644 include/hw/misc/allwinner-a10-ccm.h | ||
24 | create mode 100644 hw/misc/allwinner-a10-ccm.c | ||
19 | 25 | ||
20 | diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs | 26 | diff --git a/include/hw/arm/allwinner-a10.h b/include/hw/arm/allwinner-a10.h |
21 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/misc/Makefile.objs | 28 | --- a/include/hw/arm/allwinner-a10.h |
23 | +++ b/hw/misc/Makefile.objs | 29 | +++ b/include/hw/arm/allwinner-a10.h |
24 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_MPS2_FPGAIO) += mps2-fpgaio.o | 30 | @@ -XXX,XX +XXX,XX @@ |
25 | obj-$(CONFIG_MPS2_SCC) += mps2-scc.o | 31 | #include "hw/usb/hcd-ohci.h" |
26 | 32 | #include "hw/usb/hcd-ehci.h" | |
27 | obj-$(CONFIG_TZ_PPC) += tz-ppc.o | 33 | #include "hw/rtc/allwinner-rtc.h" |
28 | +obj-$(CONFIG_IOTKIT_SECCTL) += iotkit-secctl.o | 34 | +#include "hw/misc/allwinner-a10-ccm.h" |
29 | 35 | ||
30 | obj-$(CONFIG_PVPANIC) += pvpanic.o | 36 | #include "target/arm/cpu.h" |
31 | obj-$(CONFIG_HYPERV_TESTDEV) += hyperv_testdev.o | 37 | #include "qom/object.h" |
32 | diff --git a/include/hw/misc/iotkit-secctl.h b/include/hw/misc/iotkit-secctl.h | 38 | @@ -XXX,XX +XXX,XX @@ struct AwA10State { |
39 | /*< public >*/ | ||
40 | |||
41 | ARMCPU cpu; | ||
42 | + AwA10ClockCtlState ccm; | ||
43 | AwA10PITState timer; | ||
44 | AwA10PICState intc; | ||
45 | AwEmacState emac; | ||
46 | diff --git a/include/hw/misc/allwinner-a10-ccm.h b/include/hw/misc/allwinner-a10-ccm.h | ||
33 | new file mode 100644 | 47 | new file mode 100644 |
34 | index XXXXXXX..XXXXXXX | 48 | index XXXXXXX..XXXXXXX |
35 | --- /dev/null | 49 | --- /dev/null |
36 | +++ b/include/hw/misc/iotkit-secctl.h | 50 | +++ b/include/hw/misc/allwinner-a10-ccm.h |
37 | @@ -XXX,XX +XXX,XX @@ | 51 | @@ -XXX,XX +XXX,XX @@ |
38 | +/* | 52 | +/* |
39 | + * ARM IoT Kit security controller | 53 | + * Allwinner A10 Clock Control Module emulation |
40 | + * | 54 | + * |
41 | + * Copyright (c) 2018 Linaro Limited | 55 | + * Copyright (C) 2022 Strahinja Jankovic <strahinja.p.jankovic@gmail.com> |
42 | + * Written by Peter Maydell | 56 | + * |
43 | + * | 57 | + * This file is derived from Allwinner H3 CCU, |
44 | + * This program is free software; you can redistribute it and/or modify | 58 | + * by Niek Linnenbank. |
45 | + * it under the terms of the GNU General Public License version 2 or | 59 | + * |
60 | + * This program is free software: you can redistribute it and/or modify | ||
61 | + * it under the terms of the GNU General Public License as published by | ||
62 | + * the Free Software Foundation, either version 2 of the License, or | ||
46 | + * (at your option) any later version. | 63 | + * (at your option) any later version. |
64 | + * | ||
65 | + * This program is distributed in the hope that it will be useful, | ||
66 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
67 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
68 | + * GNU General Public License for more details. | ||
69 | + * | ||
70 | + * You should have received a copy of the GNU General Public License | ||
71 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
47 | + */ | 72 | + */ |
48 | + | 73 | + |
49 | +/* This is a model of the security controller which is part of the | 74 | +#ifndef HW_MISC_ALLWINNER_A10_CCM_H |
50 | + * Arm IoT Kit and documented in | 75 | +#define HW_MISC_ALLWINNER_A10_CCM_H |
51 | + * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ecm0601256/index.html | 76 | + |
52 | + * | 77 | +#include "qom/object.h" |
53 | + * QEMU interface: | 78 | +#include "hw/sysbus.h" |
54 | + * + sysbus MMIO region 0 is the "secure privilege control block" registers | 79 | + |
55 | + * + sysbus MMIO region 1 is the "non-secure privilege control block" registers | 80 | +/** |
81 | + * @name Constants | ||
82 | + * @{ | ||
56 | + */ | 83 | + */ |
57 | + | 84 | + |
58 | +#ifndef IOTKIT_SECCTL_H | 85 | +/** Size of register I/O address space used by CCM device */ |
59 | +#define IOTKIT_SECCTL_H | 86 | +#define AW_A10_CCM_IOSIZE (0x400) |
60 | + | 87 | + |
61 | +#include "hw/sysbus.h" | 88 | +/** Total number of known registers */ |
62 | + | 89 | +#define AW_A10_CCM_REGS_NUM (AW_A10_CCM_IOSIZE / sizeof(uint32_t)) |
63 | +#define TYPE_IOTKIT_SECCTL "iotkit-secctl" | 90 | + |
64 | +#define IOTKIT_SECCTL(obj) OBJECT_CHECK(IoTKitSecCtl, (obj), TYPE_IOTKIT_SECCTL) | 91 | +/** @} */ |
65 | + | 92 | + |
66 | +typedef struct IoTKitSecCtl { | 93 | +/** |
94 | + * @name Object model | ||
95 | + * @{ | ||
96 | + */ | ||
97 | + | ||
98 | +#define TYPE_AW_A10_CCM "allwinner-a10-ccm" | ||
99 | +OBJECT_DECLARE_SIMPLE_TYPE(AwA10ClockCtlState, AW_A10_CCM) | ||
100 | + | ||
101 | +/** @} */ | ||
102 | + | ||
103 | +/** | ||
104 | + * Allwinner A10 CCM object instance state. | ||
105 | + */ | ||
106 | +struct AwA10ClockCtlState { | ||
67 | + /*< private >*/ | 107 | + /*< private >*/ |
68 | + SysBusDevice parent_obj; | 108 | + SysBusDevice parent_obj; |
69 | + | ||
70 | + /*< public >*/ | 109 | + /*< public >*/ |
71 | + | 110 | + |
72 | + MemoryRegion s_regs; | 111 | + /** Maps I/O registers in physical memory */ |
73 | + MemoryRegion ns_regs; | 112 | + MemoryRegion iomem; |
74 | +} IoTKitSecCtl; | 113 | + |
75 | + | 114 | + /** Array of hardware registers */ |
76 | +#endif | 115 | + uint32_t regs[AW_A10_CCM_REGS_NUM]; |
77 | diff --git a/hw/misc/iotkit-secctl.c b/hw/misc/iotkit-secctl.c | 116 | +}; |
117 | + | ||
118 | +#endif /* HW_MISC_ALLWINNER_H3_CCU_H */ | ||
119 | diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c | ||
120 | index XXXXXXX..XXXXXXX 100644 | ||
121 | --- a/hw/arm/allwinner-a10.c | ||
122 | +++ b/hw/arm/allwinner-a10.c | ||
123 | @@ -XXX,XX +XXX,XX @@ | ||
124 | #include "hw/usb/hcd-ohci.h" | ||
125 | |||
126 | #define AW_A10_MMC0_BASE 0x01c0f000 | ||
127 | +#define AW_A10_CCM_BASE 0x01c20000 | ||
128 | #define AW_A10_PIC_REG_BASE 0x01c20400 | ||
129 | #define AW_A10_PIT_REG_BASE 0x01c20c00 | ||
130 | #define AW_A10_UART0_REG_BASE 0x01c28000 | ||
131 | @@ -XXX,XX +XXX,XX @@ static void aw_a10_init(Object *obj) | ||
132 | |||
133 | object_initialize_child(obj, "timer", &s->timer, TYPE_AW_A10_PIT); | ||
134 | |||
135 | + object_initialize_child(obj, "ccm", &s->ccm, TYPE_AW_A10_CCM); | ||
136 | + | ||
137 | object_initialize_child(obj, "emac", &s->emac, TYPE_AW_EMAC); | ||
138 | |||
139 | object_initialize_child(obj, "sata", &s->sata, TYPE_ALLWINNER_AHCI); | ||
140 | @@ -XXX,XX +XXX,XX @@ static void aw_a10_realize(DeviceState *dev, Error **errp) | ||
141 | memory_region_add_subregion(get_system_memory(), 0x00000000, &s->sram_a); | ||
142 | create_unimplemented_device("a10-sram-ctrl", 0x01c00000, 4 * KiB); | ||
143 | |||
144 | + /* Clock Control Module */ | ||
145 | + sysbus_realize(SYS_BUS_DEVICE(&s->ccm), &error_fatal); | ||
146 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->ccm), 0, AW_A10_CCM_BASE); | ||
147 | + | ||
148 | /* FIXME use qdev NIC properties instead of nd_table[] */ | ||
149 | if (nd_table[0].used) { | ||
150 | qemu_check_nic_model(&nd_table[0], TYPE_AW_EMAC); | ||
151 | diff --git a/hw/misc/allwinner-a10-ccm.c b/hw/misc/allwinner-a10-ccm.c | ||
78 | new file mode 100644 | 152 | new file mode 100644 |
79 | index XXXXXXX..XXXXXXX | 153 | index XXXXXXX..XXXXXXX |
80 | --- /dev/null | 154 | --- /dev/null |
81 | +++ b/hw/misc/iotkit-secctl.c | 155 | +++ b/hw/misc/allwinner-a10-ccm.c |
82 | @@ -XXX,XX +XXX,XX @@ | 156 | @@ -XXX,XX +XXX,XX @@ |
83 | +/* | 157 | +/* |
84 | + * Arm IoT Kit security controller | 158 | + * Allwinner A10 Clock Control Module emulation |
85 | + * | 159 | + * |
86 | + * Copyright (c) 2018 Linaro Limited | 160 | + * Copyright (C) 2022 Strahinja Jankovic <strahinja.p.jankovic@gmail.com> |
87 | + * Written by Peter Maydell | 161 | + * |
88 | + * | 162 | + * This file is derived from Allwinner H3 CCU, |
89 | + * This program is free software; you can redistribute it and/or modify | 163 | + * by Niek Linnenbank. |
90 | + * it under the terms of the GNU General Public License version 2 or | 164 | + * |
165 | + * This program is free software: you can redistribute it and/or modify | ||
166 | + * it under the terms of the GNU General Public License as published by | ||
167 | + * the Free Software Foundation, either version 2 of the License, or | ||
91 | + * (at your option) any later version. | 168 | + * (at your option) any later version. |
169 | + * | ||
170 | + * This program is distributed in the hope that it will be useful, | ||
171 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
172 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
173 | + * GNU General Public License for more details. | ||
174 | + * | ||
175 | + * You should have received a copy of the GNU General Public License | ||
176 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
92 | + */ | 177 | + */ |
93 | + | 178 | + |
94 | +#include "qemu/osdep.h" | 179 | +#include "qemu/osdep.h" |
180 | +#include "qemu/units.h" | ||
181 | +#include "hw/sysbus.h" | ||
182 | +#include "migration/vmstate.h" | ||
95 | +#include "qemu/log.h" | 183 | +#include "qemu/log.h" |
96 | +#include "qapi/error.h" | 184 | +#include "qemu/module.h" |
97 | +#include "trace.h" | 185 | +#include "hw/misc/allwinner-a10-ccm.h" |
98 | +#include "hw/sysbus.h" | 186 | + |
99 | +#include "hw/registerfields.h" | 187 | +/* CCM register offsets */ |
100 | +#include "hw/misc/iotkit-secctl.h" | 188 | +enum { |
101 | + | 189 | + REG_PLL1_CFG = 0x0000, /* PLL1 Control */ |
102 | +/* Registers in the secure privilege control block */ | 190 | + REG_PLL1_TUN = 0x0004, /* PLL1 Tuning */ |
103 | +REG32(SECRESPCFG, 0x10) | 191 | + REG_PLL2_CFG = 0x0008, /* PLL2 Control */ |
104 | +REG32(NSCCFG, 0x14) | 192 | + REG_PLL2_TUN = 0x000C, /* PLL2 Tuning */ |
105 | +REG32(SECMPCINTSTATUS, 0x1c) | 193 | + REG_PLL3_CFG = 0x0010, /* PLL3 Control */ |
106 | +REG32(SECPPCINTSTAT, 0x20) | 194 | + REG_PLL4_CFG = 0x0018, /* PLL4 Control */ |
107 | +REG32(SECPPCINTCLR, 0x24) | 195 | + REG_PLL5_CFG = 0x0020, /* PLL5 Control */ |
108 | +REG32(SECPPCINTEN, 0x28) | 196 | + REG_PLL5_TUN = 0x0024, /* PLL5 Tuning */ |
109 | +REG32(SECMSCINTSTAT, 0x30) | 197 | + REG_PLL6_CFG = 0x0028, /* PLL6 Control */ |
110 | +REG32(SECMSCINTCLR, 0x34) | 198 | + REG_PLL6_TUN = 0x002C, /* PLL6 Tuning */ |
111 | +REG32(SECMSCINTEN, 0x38) | 199 | + REG_PLL7_CFG = 0x0030, /* PLL7 Control */ |
112 | +REG32(BRGINTSTAT, 0x40) | 200 | + REG_PLL1_TUN2 = 0x0038, /* PLL1 Tuning2 */ |
113 | +REG32(BRGINTCLR, 0x44) | 201 | + REG_PLL5_TUN2 = 0x003C, /* PLL5 Tuning2 */ |
114 | +REG32(BRGINTEN, 0x48) | 202 | + REG_PLL8_CFG = 0x0040, /* PLL8 Control */ |
115 | +REG32(AHBNSPPC0, 0x50) | 203 | + REG_OSC24M_CFG = 0x0050, /* OSC24M Control */ |
116 | +REG32(AHBNSPPCEXP0, 0x60) | 204 | + REG_CPU_AHB_APB0_CFG = 0x0054, /* CPU, AHB and APB0 Divide Ratio */ |
117 | +REG32(AHBNSPPCEXP1, 0x64) | 205 | +}; |
118 | +REG32(AHBNSPPCEXP2, 0x68) | 206 | + |
119 | +REG32(AHBNSPPCEXP3, 0x6c) | 207 | +#define REG_INDEX(offset) (offset / sizeof(uint32_t)) |
120 | +REG32(APBNSPPC0, 0x70) | 208 | + |
121 | +REG32(APBNSPPC1, 0x74) | 209 | +/* CCM register reset values */ |
122 | +REG32(APBNSPPCEXP0, 0x80) | 210 | +enum { |
123 | +REG32(APBNSPPCEXP1, 0x84) | 211 | + REG_PLL1_CFG_RST = 0x21005000, |
124 | +REG32(APBNSPPCEXP2, 0x88) | 212 | + REG_PLL1_TUN_RST = 0x0A101000, |
125 | +REG32(APBNSPPCEXP3, 0x8c) | 213 | + REG_PLL2_CFG_RST = 0x08100010, |
126 | +REG32(AHBSPPPC0, 0x90) | 214 | + REG_PLL2_TUN_RST = 0x00000000, |
127 | +REG32(AHBSPPPCEXP0, 0xa0) | 215 | + REG_PLL3_CFG_RST = 0x0010D063, |
128 | +REG32(AHBSPPPCEXP1, 0xa4) | 216 | + REG_PLL4_CFG_RST = 0x21009911, |
129 | +REG32(AHBSPPPCEXP2, 0xa8) | 217 | + REG_PLL5_CFG_RST = 0x11049280, |
130 | +REG32(AHBSPPPCEXP3, 0xac) | 218 | + REG_PLL5_TUN_RST = 0x14888000, |
131 | +REG32(APBSPPPC0, 0xb0) | 219 | + REG_PLL6_CFG_RST = 0x21009911, |
132 | +REG32(APBSPPPC1, 0xb4) | 220 | + REG_PLL6_TUN_RST = 0x00000000, |
133 | +REG32(APBSPPPCEXP0, 0xc0) | 221 | + REG_PLL7_CFG_RST = 0x0010D063, |
134 | +REG32(APBSPPPCEXP1, 0xc4) | 222 | + REG_PLL1_TUN2_RST = 0x00000000, |
135 | +REG32(APBSPPPCEXP2, 0xc8) | 223 | + REG_PLL5_TUN2_RST = 0x00000000, |
136 | +REG32(APBSPPPCEXP3, 0xcc) | 224 | + REG_PLL8_CFG_RST = 0x21009911, |
137 | +REG32(NSMSCEXP, 0xd0) | 225 | + REG_OSC24M_CFG_RST = 0x00138013, |
138 | +REG32(PID4, 0xfd0) | 226 | + REG_CPU_AHB_APB0_CFG_RST = 0x00010010, |
139 | +REG32(PID5, 0xfd4) | 227 | +}; |
140 | +REG32(PID6, 0xfd8) | 228 | + |
141 | +REG32(PID7, 0xfdc) | 229 | +static uint64_t allwinner_a10_ccm_read(void *opaque, hwaddr offset, |
142 | +REG32(PID0, 0xfe0) | 230 | + unsigned size) |
143 | +REG32(PID1, 0xfe4) | 231 | +{ |
144 | +REG32(PID2, 0xfe8) | 232 | + const AwA10ClockCtlState *s = AW_A10_CCM(opaque); |
145 | +REG32(PID3, 0xfec) | 233 | + const uint32_t idx = REG_INDEX(offset); |
146 | +REG32(CID0, 0xff0) | ||
147 | +REG32(CID1, 0xff4) | ||
148 | +REG32(CID2, 0xff8) | ||
149 | +REG32(CID3, 0xffc) | ||
150 | + | ||
151 | +/* Registers in the non-secure privilege control block */ | ||
152 | +REG32(AHBNSPPPC0, 0x90) | ||
153 | +REG32(AHBNSPPPCEXP0, 0xa0) | ||
154 | +REG32(AHBNSPPPCEXP1, 0xa4) | ||
155 | +REG32(AHBNSPPPCEXP2, 0xa8) | ||
156 | +REG32(AHBNSPPPCEXP3, 0xac) | ||
157 | +REG32(APBNSPPPC0, 0xb0) | ||
158 | +REG32(APBNSPPPC1, 0xb4) | ||
159 | +REG32(APBNSPPPCEXP0, 0xc0) | ||
160 | +REG32(APBNSPPPCEXP1, 0xc4) | ||
161 | +REG32(APBNSPPPCEXP2, 0xc8) | ||
162 | +REG32(APBNSPPPCEXP3, 0xcc) | ||
163 | +/* PID and CID registers are also present in the NS block */ | ||
164 | + | ||
165 | +static const uint8_t iotkit_secctl_s_idregs[] = { | ||
166 | + 0x04, 0x00, 0x00, 0x00, | ||
167 | + 0x52, 0xb8, 0x0b, 0x00, | ||
168 | + 0x0d, 0xf0, 0x05, 0xb1, | ||
169 | +}; | ||
170 | + | ||
171 | +static const uint8_t iotkit_secctl_ns_idregs[] = { | ||
172 | + 0x04, 0x00, 0x00, 0x00, | ||
173 | + 0x53, 0xb8, 0x0b, 0x00, | ||
174 | + 0x0d, 0xf0, 0x05, 0xb1, | ||
175 | +}; | ||
176 | + | ||
177 | +static MemTxResult iotkit_secctl_s_read(void *opaque, hwaddr addr, | ||
178 | + uint64_t *pdata, | ||
179 | + unsigned size, MemTxAttrs attrs) | ||
180 | +{ | ||
181 | + uint64_t r; | ||
182 | + uint32_t offset = addr & ~0x3; | ||
183 | + | 234 | + |
184 | + switch (offset) { | 235 | + switch (offset) { |
185 | + case A_AHBNSPPC0: | 236 | + case REG_PLL1_CFG: |
186 | + case A_AHBSPPPC0: | 237 | + case REG_PLL1_TUN: |
187 | + r = 0; | 238 | + case REG_PLL2_CFG: |
239 | + case REG_PLL2_TUN: | ||
240 | + case REG_PLL3_CFG: | ||
241 | + case REG_PLL4_CFG: | ||
242 | + case REG_PLL5_CFG: | ||
243 | + case REG_PLL5_TUN: | ||
244 | + case REG_PLL6_CFG: | ||
245 | + case REG_PLL6_TUN: | ||
246 | + case REG_PLL7_CFG: | ||
247 | + case REG_PLL1_TUN2: | ||
248 | + case REG_PLL5_TUN2: | ||
249 | + case REG_PLL8_CFG: | ||
250 | + case REG_OSC24M_CFG: | ||
251 | + case REG_CPU_AHB_APB0_CFG: | ||
188 | + break; | 252 | + break; |
189 | + case A_SECRESPCFG: | 253 | + case 0x158 ... AW_A10_CCM_IOSIZE: |
190 | + case A_NSCCFG: | 254 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: out-of-bounds offset 0x%04x\n", |
191 | + case A_SECMPCINTSTATUS: | 255 | + __func__, (uint32_t)offset); |
192 | + case A_SECPPCINTSTAT: | 256 | + return 0; |
193 | + case A_SECPPCINTEN: | 257 | + default: |
194 | + case A_SECMSCINTSTAT: | 258 | + qemu_log_mask(LOG_UNIMP, "%s: unimplemented read offset 0x%04x\n", |
195 | + case A_SECMSCINTEN: | 259 | + __func__, (uint32_t)offset); |
196 | + case A_BRGINTSTAT: | 260 | + return 0; |
197 | + case A_BRGINTEN: | 261 | + } |
198 | + case A_AHBNSPPCEXP0: | 262 | + |
199 | + case A_AHBNSPPCEXP1: | 263 | + return s->regs[idx]; |
200 | + case A_AHBNSPPCEXP2: | 264 | +} |
201 | + case A_AHBNSPPCEXP3: | 265 | + |
202 | + case A_APBNSPPC0: | 266 | +static void allwinner_a10_ccm_write(void *opaque, hwaddr offset, |
203 | + case A_APBNSPPC1: | 267 | + uint64_t val, unsigned size) |
204 | + case A_APBNSPPCEXP0: | 268 | +{ |
205 | + case A_APBNSPPCEXP1: | 269 | + AwA10ClockCtlState *s = AW_A10_CCM(opaque); |
206 | + case A_APBNSPPCEXP2: | 270 | + const uint32_t idx = REG_INDEX(offset); |
207 | + case A_APBNSPPCEXP3: | 271 | + |
208 | + case A_AHBSPPPCEXP0: | 272 | + switch (offset) { |
209 | + case A_AHBSPPPCEXP1: | 273 | + case REG_PLL1_CFG: |
210 | + case A_AHBSPPPCEXP2: | 274 | + case REG_PLL1_TUN: |
211 | + case A_AHBSPPPCEXP3: | 275 | + case REG_PLL2_CFG: |
212 | + case A_APBSPPPC0: | 276 | + case REG_PLL2_TUN: |
213 | + case A_APBSPPPC1: | 277 | + case REG_PLL3_CFG: |
214 | + case A_APBSPPPCEXP0: | 278 | + case REG_PLL4_CFG: |
215 | + case A_APBSPPPCEXP1: | 279 | + case REG_PLL5_CFG: |
216 | + case A_APBSPPPCEXP2: | 280 | + case REG_PLL5_TUN: |
217 | + case A_APBSPPPCEXP3: | 281 | + case REG_PLL6_CFG: |
218 | + case A_NSMSCEXP: | 282 | + case REG_PLL6_TUN: |
219 | + qemu_log_mask(LOG_UNIMP, | 283 | + case REG_PLL7_CFG: |
220 | + "IoTKit SecCtl S block read: " | 284 | + case REG_PLL1_TUN2: |
221 | + "unimplemented offset 0x%x\n", offset); | 285 | + case REG_PLL5_TUN2: |
222 | + r = 0; | 286 | + case REG_PLL8_CFG: |
287 | + case REG_OSC24M_CFG: | ||
288 | + case REG_CPU_AHB_APB0_CFG: | ||
223 | + break; | 289 | + break; |
224 | + case A_PID4: | 290 | + case 0x158 ... AW_A10_CCM_IOSIZE: |
225 | + case A_PID5: | 291 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: out-of-bounds offset 0x%04x\n", |
226 | + case A_PID6: | 292 | + __func__, (uint32_t)offset); |
227 | + case A_PID7: | ||
228 | + case A_PID0: | ||
229 | + case A_PID1: | ||
230 | + case A_PID2: | ||
231 | + case A_PID3: | ||
232 | + case A_CID0: | ||
233 | + case A_CID1: | ||
234 | + case A_CID2: | ||
235 | + case A_CID3: | ||
236 | + r = iotkit_secctl_s_idregs[(offset - A_PID4) / 4]; | ||
237 | + break; | ||
238 | + case A_SECPPCINTCLR: | ||
239 | + case A_SECMSCINTCLR: | ||
240 | + case A_BRGINTCLR: | ||
241 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
242 | + "IotKit SecCtl S block read: write-only offset 0x%x\n", | ||
243 | + offset); | ||
244 | + r = 0; | ||
245 | + break; | 293 | + break; |
246 | + default: | 294 | + default: |
247 | + qemu_log_mask(LOG_GUEST_ERROR, | 295 | + qemu_log_mask(LOG_UNIMP, "%s: unimplemented write offset 0x%04x\n", |
248 | + "IotKit SecCtl S block read: bad offset 0x%x\n", offset); | 296 | + __func__, (uint32_t)offset); |
249 | + r = 0; | ||
250 | + break; | 297 | + break; |
251 | + } | 298 | + } |
252 | + | 299 | + |
253 | + if (size != 4) { | 300 | + s->regs[idx] = (uint32_t) val; |
254 | + /* None of our registers are access-sensitive, so just pull the right | 301 | +} |
255 | + * byte out of the word read result. | 302 | + |
256 | + */ | 303 | +static const MemoryRegionOps allwinner_a10_ccm_ops = { |
257 | + r = extract32(r, (addr & 3) * 8, size * 8); | 304 | + .read = allwinner_a10_ccm_read, |
258 | + } | 305 | + .write = allwinner_a10_ccm_write, |
259 | + | 306 | + .endianness = DEVICE_NATIVE_ENDIAN, |
260 | + trace_iotkit_secctl_s_read(offset, r, size); | 307 | + .valid = { |
261 | + *pdata = r; | 308 | + .min_access_size = 4, |
262 | + return MEMTX_OK; | 309 | + .max_access_size = 4, |
263 | +} | 310 | + }, |
264 | + | 311 | + .impl.min_access_size = 4, |
265 | +static MemTxResult iotkit_secctl_s_write(void *opaque, hwaddr addr, | 312 | +}; |
266 | + uint64_t value, | 313 | + |
267 | + unsigned size, MemTxAttrs attrs) | 314 | +static void allwinner_a10_ccm_reset_enter(Object *obj, ResetType type) |
268 | +{ | 315 | +{ |
269 | + uint32_t offset = addr; | 316 | + AwA10ClockCtlState *s = AW_A10_CCM(obj); |
270 | + | 317 | + |
271 | + trace_iotkit_secctl_s_write(offset, value, size); | 318 | + /* Set default values for registers */ |
272 | + | 319 | + s->regs[REG_INDEX(REG_PLL1_CFG)] = REG_PLL1_CFG_RST; |
273 | + if (size != 4) { | 320 | + s->regs[REG_INDEX(REG_PLL1_TUN)] = REG_PLL1_TUN_RST; |
274 | + /* Byte and halfword writes are ignored */ | 321 | + s->regs[REG_INDEX(REG_PLL2_CFG)] = REG_PLL2_CFG_RST; |
275 | + qemu_log_mask(LOG_GUEST_ERROR, | 322 | + s->regs[REG_INDEX(REG_PLL2_TUN)] = REG_PLL2_TUN_RST; |
276 | + "IotKit SecCtl S block write: bad size, ignored\n"); | 323 | + s->regs[REG_INDEX(REG_PLL3_CFG)] = REG_PLL3_CFG_RST; |
277 | + return MEMTX_OK; | 324 | + s->regs[REG_INDEX(REG_PLL4_CFG)] = REG_PLL4_CFG_RST; |
278 | + } | 325 | + s->regs[REG_INDEX(REG_PLL5_CFG)] = REG_PLL5_CFG_RST; |
279 | + | 326 | + s->regs[REG_INDEX(REG_PLL5_TUN)] = REG_PLL5_TUN_RST; |
280 | + switch (offset) { | 327 | + s->regs[REG_INDEX(REG_PLL6_CFG)] = REG_PLL6_CFG_RST; |
281 | + case A_SECRESPCFG: | 328 | + s->regs[REG_INDEX(REG_PLL6_TUN)] = REG_PLL6_TUN_RST; |
282 | + case A_NSCCFG: | 329 | + s->regs[REG_INDEX(REG_PLL7_CFG)] = REG_PLL7_CFG_RST; |
283 | + case A_SECPPCINTCLR: | 330 | + s->regs[REG_INDEX(REG_PLL1_TUN2)] = REG_PLL1_TUN2_RST; |
284 | + case A_SECPPCINTEN: | 331 | + s->regs[REG_INDEX(REG_PLL5_TUN2)] = REG_PLL5_TUN2_RST; |
285 | + case A_SECMSCINTCLR: | 332 | + s->regs[REG_INDEX(REG_PLL8_CFG)] = REG_PLL8_CFG_RST; |
286 | + case A_SECMSCINTEN: | 333 | + s->regs[REG_INDEX(REG_OSC24M_CFG)] = REG_OSC24M_CFG_RST; |
287 | + case A_BRGINTCLR: | 334 | + s->regs[REG_INDEX(REG_CPU_AHB_APB0_CFG)] = REG_CPU_AHB_APB0_CFG_RST; |
288 | + case A_BRGINTEN: | 335 | +} |
289 | + case A_AHBNSPPCEXP0: | 336 | + |
290 | + case A_AHBNSPPCEXP1: | 337 | +static void allwinner_a10_ccm_init(Object *obj) |
291 | + case A_AHBNSPPCEXP2: | 338 | +{ |
292 | + case A_AHBNSPPCEXP3: | ||
293 | + case A_APBNSPPC0: | ||
294 | + case A_APBNSPPC1: | ||
295 | + case A_APBNSPPCEXP0: | ||
296 | + case A_APBNSPPCEXP1: | ||
297 | + case A_APBNSPPCEXP2: | ||
298 | + case A_APBNSPPCEXP3: | ||
299 | + case A_AHBSPPPCEXP0: | ||
300 | + case A_AHBSPPPCEXP1: | ||
301 | + case A_AHBSPPPCEXP2: | ||
302 | + case A_AHBSPPPCEXP3: | ||
303 | + case A_APBSPPPC0: | ||
304 | + case A_APBSPPPC1: | ||
305 | + case A_APBSPPPCEXP0: | ||
306 | + case A_APBSPPPCEXP1: | ||
307 | + case A_APBSPPPCEXP2: | ||
308 | + case A_APBSPPPCEXP3: | ||
309 | + qemu_log_mask(LOG_UNIMP, | ||
310 | + "IoTKit SecCtl S block write: " | ||
311 | + "unimplemented offset 0x%x\n", offset); | ||
312 | + break; | ||
313 | + case A_SECMPCINTSTATUS: | ||
314 | + case A_SECPPCINTSTAT: | ||
315 | + case A_SECMSCINTSTAT: | ||
316 | + case A_BRGINTSTAT: | ||
317 | + case A_AHBNSPPC0: | ||
318 | + case A_AHBSPPPC0: | ||
319 | + case A_NSMSCEXP: | ||
320 | + case A_PID4: | ||
321 | + case A_PID5: | ||
322 | + case A_PID6: | ||
323 | + case A_PID7: | ||
324 | + case A_PID0: | ||
325 | + case A_PID1: | ||
326 | + case A_PID2: | ||
327 | + case A_PID3: | ||
328 | + case A_CID0: | ||
329 | + case A_CID1: | ||
330 | + case A_CID2: | ||
331 | + case A_CID3: | ||
332 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
333 | + "IoTKit SecCtl S block write: " | ||
334 | + "read-only offset 0x%x\n", offset); | ||
335 | + break; | ||
336 | + default: | ||
337 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
338 | + "IotKit SecCtl S block write: bad offset 0x%x\n", | ||
339 | + offset); | ||
340 | + break; | ||
341 | + } | ||
342 | + | ||
343 | + return MEMTX_OK; | ||
344 | +} | ||
345 | + | ||
346 | +static MemTxResult iotkit_secctl_ns_read(void *opaque, hwaddr addr, | ||
347 | + uint64_t *pdata, | ||
348 | + unsigned size, MemTxAttrs attrs) | ||
349 | +{ | ||
350 | + uint64_t r; | ||
351 | + uint32_t offset = addr & ~0x3; | ||
352 | + | ||
353 | + switch (offset) { | ||
354 | + case A_AHBNSPPPC0: | ||
355 | + r = 0; | ||
356 | + break; | ||
357 | + case A_AHBNSPPPCEXP0: | ||
358 | + case A_AHBNSPPPCEXP1: | ||
359 | + case A_AHBNSPPPCEXP2: | ||
360 | + case A_AHBNSPPPCEXP3: | ||
361 | + case A_APBNSPPPC0: | ||
362 | + case A_APBNSPPPC1: | ||
363 | + case A_APBNSPPPCEXP0: | ||
364 | + case A_APBNSPPPCEXP1: | ||
365 | + case A_APBNSPPPCEXP2: | ||
366 | + case A_APBNSPPPCEXP3: | ||
367 | + qemu_log_mask(LOG_UNIMP, | ||
368 | + "IoTKit SecCtl NS block read: " | ||
369 | + "unimplemented offset 0x%x\n", offset); | ||
370 | + break; | ||
371 | + case A_PID4: | ||
372 | + case A_PID5: | ||
373 | + case A_PID6: | ||
374 | + case A_PID7: | ||
375 | + case A_PID0: | ||
376 | + case A_PID1: | ||
377 | + case A_PID2: | ||
378 | + case A_PID3: | ||
379 | + case A_CID0: | ||
380 | + case A_CID1: | ||
381 | + case A_CID2: | ||
382 | + case A_CID3: | ||
383 | + r = iotkit_secctl_ns_idregs[(offset - A_PID4) / 4]; | ||
384 | + break; | ||
385 | + default: | ||
386 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
387 | + "IotKit SecCtl NS block write: bad offset 0x%x\n", | ||
388 | + offset); | ||
389 | + r = 0; | ||
390 | + break; | ||
391 | + } | ||
392 | + | ||
393 | + if (size != 4) { | ||
394 | + /* None of our registers are access-sensitive, so just pull the right | ||
395 | + * byte out of the word read result. | ||
396 | + */ | ||
397 | + r = extract32(r, (addr & 3) * 8, size * 8); | ||
398 | + } | ||
399 | + | ||
400 | + trace_iotkit_secctl_ns_read(offset, r, size); | ||
401 | + *pdata = r; | ||
402 | + return MEMTX_OK; | ||
403 | +} | ||
404 | + | ||
405 | +static MemTxResult iotkit_secctl_ns_write(void *opaque, hwaddr addr, | ||
406 | + uint64_t value, | ||
407 | + unsigned size, MemTxAttrs attrs) | ||
408 | +{ | ||
409 | + uint32_t offset = addr; | ||
410 | + | ||
411 | + trace_iotkit_secctl_ns_write(offset, value, size); | ||
412 | + | ||
413 | + if (size != 4) { | ||
414 | + /* Byte and halfword writes are ignored */ | ||
415 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
416 | + "IotKit SecCtl NS block write: bad size, ignored\n"); | ||
417 | + return MEMTX_OK; | ||
418 | + } | ||
419 | + | ||
420 | + switch (offset) { | ||
421 | + case A_AHBNSPPPCEXP0: | ||
422 | + case A_AHBNSPPPCEXP1: | ||
423 | + case A_AHBNSPPPCEXP2: | ||
424 | + case A_AHBNSPPPCEXP3: | ||
425 | + case A_APBNSPPPC0: | ||
426 | + case A_APBNSPPPC1: | ||
427 | + case A_APBNSPPPCEXP0: | ||
428 | + case A_APBNSPPPCEXP1: | ||
429 | + case A_APBNSPPPCEXP2: | ||
430 | + case A_APBNSPPPCEXP3: | ||
431 | + qemu_log_mask(LOG_UNIMP, | ||
432 | + "IoTKit SecCtl NS block write: " | ||
433 | + "unimplemented offset 0x%x\n", offset); | ||
434 | + break; | ||
435 | + case A_AHBNSPPPC0: | ||
436 | + case A_PID4: | ||
437 | + case A_PID5: | ||
438 | + case A_PID6: | ||
439 | + case A_PID7: | ||
440 | + case A_PID0: | ||
441 | + case A_PID1: | ||
442 | + case A_PID2: | ||
443 | + case A_PID3: | ||
444 | + case A_CID0: | ||
445 | + case A_CID1: | ||
446 | + case A_CID2: | ||
447 | + case A_CID3: | ||
448 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
449 | + "IoTKit SecCtl NS block write: " | ||
450 | + "read-only offset 0x%x\n", offset); | ||
451 | + break; | ||
452 | + default: | ||
453 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
454 | + "IotKit SecCtl NS block write: bad offset 0x%x\n", | ||
455 | + offset); | ||
456 | + break; | ||
457 | + } | ||
458 | + | ||
459 | + return MEMTX_OK; | ||
460 | +} | ||
461 | + | ||
462 | +static const MemoryRegionOps iotkit_secctl_s_ops = { | ||
463 | + .read_with_attrs = iotkit_secctl_s_read, | ||
464 | + .write_with_attrs = iotkit_secctl_s_write, | ||
465 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
466 | + .valid.min_access_size = 1, | ||
467 | + .valid.max_access_size = 4, | ||
468 | + .impl.min_access_size = 1, | ||
469 | + .impl.max_access_size = 4, | ||
470 | +}; | ||
471 | + | ||
472 | +static const MemoryRegionOps iotkit_secctl_ns_ops = { | ||
473 | + .read_with_attrs = iotkit_secctl_ns_read, | ||
474 | + .write_with_attrs = iotkit_secctl_ns_write, | ||
475 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
476 | + .valid.min_access_size = 1, | ||
477 | + .valid.max_access_size = 4, | ||
478 | + .impl.min_access_size = 1, | ||
479 | + .impl.max_access_size = 4, | ||
480 | +}; | ||
481 | + | ||
482 | +static void iotkit_secctl_reset(DeviceState *dev) | ||
483 | +{ | ||
484 | + | ||
485 | +} | ||
486 | + | ||
487 | +static void iotkit_secctl_init(Object *obj) | ||
488 | +{ | ||
489 | + IoTKitSecCtl *s = IOTKIT_SECCTL(obj); | ||
490 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | 339 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); |
491 | + | 340 | + AwA10ClockCtlState *s = AW_A10_CCM(obj); |
492 | + memory_region_init_io(&s->s_regs, obj, &iotkit_secctl_s_ops, | 341 | + |
493 | + s, "iotkit-secctl-s-regs", 0x1000); | 342 | + /* Memory mapping */ |
494 | + memory_region_init_io(&s->ns_regs, obj, &iotkit_secctl_ns_ops, | 343 | + memory_region_init_io(&s->iomem, OBJECT(s), &allwinner_a10_ccm_ops, s, |
495 | + s, "iotkit-secctl-ns-regs", 0x1000); | 344 | + TYPE_AW_A10_CCM, AW_A10_CCM_IOSIZE); |
496 | + sysbus_init_mmio(sbd, &s->s_regs); | 345 | + sysbus_init_mmio(sbd, &s->iomem); |
497 | + sysbus_init_mmio(sbd, &s->ns_regs); | 346 | +} |
498 | +} | 347 | + |
499 | + | 348 | +static const VMStateDescription allwinner_a10_ccm_vmstate = { |
500 | +static const VMStateDescription iotkit_secctl_vmstate = { | 349 | + .name = "allwinner-a10-ccm", |
501 | + .name = "iotkit-secctl", | ||
502 | + .version_id = 1, | 350 | + .version_id = 1, |
503 | + .minimum_version_id = 1, | 351 | + .minimum_version_id = 1, |
504 | + .fields = (VMStateField[]) { | 352 | + .fields = (VMStateField[]) { |
353 | + VMSTATE_UINT32_ARRAY(regs, AwA10ClockCtlState, AW_A10_CCM_REGS_NUM), | ||
505 | + VMSTATE_END_OF_LIST() | 354 | + VMSTATE_END_OF_LIST() |
506 | + } | 355 | + } |
507 | +}; | 356 | +}; |
508 | + | 357 | + |
509 | +static void iotkit_secctl_class_init(ObjectClass *klass, void *data) | 358 | +static void allwinner_a10_ccm_class_init(ObjectClass *klass, void *data) |
510 | +{ | 359 | +{ |
511 | + DeviceClass *dc = DEVICE_CLASS(klass); | 360 | + DeviceClass *dc = DEVICE_CLASS(klass); |
512 | + | 361 | + ResettableClass *rc = RESETTABLE_CLASS(klass); |
513 | + dc->vmsd = &iotkit_secctl_vmstate; | 362 | + |
514 | + dc->reset = iotkit_secctl_reset; | 363 | + rc->phases.enter = allwinner_a10_ccm_reset_enter; |
515 | +} | 364 | + dc->vmsd = &allwinner_a10_ccm_vmstate; |
516 | + | 365 | +} |
517 | +static const TypeInfo iotkit_secctl_info = { | 366 | + |
518 | + .name = TYPE_IOTKIT_SECCTL, | 367 | +static const TypeInfo allwinner_a10_ccm_info = { |
519 | + .parent = TYPE_SYS_BUS_DEVICE, | 368 | + .name = TYPE_AW_A10_CCM, |
520 | + .instance_size = sizeof(IoTKitSecCtl), | 369 | + .parent = TYPE_SYS_BUS_DEVICE, |
521 | + .instance_init = iotkit_secctl_init, | 370 | + .instance_init = allwinner_a10_ccm_init, |
522 | + .class_init = iotkit_secctl_class_init, | 371 | + .instance_size = sizeof(AwA10ClockCtlState), |
523 | +}; | 372 | + .class_init = allwinner_a10_ccm_class_init, |
524 | + | 373 | +}; |
525 | +static void iotkit_secctl_register_types(void) | 374 | + |
526 | +{ | 375 | +static void allwinner_a10_ccm_register(void) |
527 | + type_register_static(&iotkit_secctl_info); | 376 | +{ |
528 | +} | 377 | + type_register_static(&allwinner_a10_ccm_info); |
529 | + | 378 | +} |
530 | +type_init(iotkit_secctl_register_types); | 379 | + |
531 | diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak | 380 | +type_init(allwinner_a10_ccm_register) |
381 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | ||
532 | index XXXXXXX..XXXXXXX 100644 | 382 | index XXXXXXX..XXXXXXX 100644 |
533 | --- a/default-configs/arm-softmmu.mak | 383 | --- a/hw/arm/Kconfig |
534 | +++ b/default-configs/arm-softmmu.mak | 384 | +++ b/hw/arm/Kconfig |
535 | @@ -XXX,XX +XXX,XX @@ CONFIG_MPS2_FPGAIO=y | 385 | @@ -XXX,XX +XXX,XX @@ config ALLWINNER_A10 |
536 | CONFIG_MPS2_SCC=y | 386 | select AHCI |
537 | 387 | select ALLWINNER_A10_PIT | |
538 | CONFIG_TZ_PPC=y | 388 | select ALLWINNER_A10_PIC |
539 | +CONFIG_IOTKIT_SECCTL=y | 389 | + select ALLWINNER_A10_CCM |
540 | 390 | select ALLWINNER_EMAC | |
541 | CONFIG_VERSATILE_PCI=y | 391 | select SERIAL |
542 | CONFIG_VERSATILE_I2C=y | 392 | select UNIMP |
543 | diff --git a/hw/misc/trace-events b/hw/misc/trace-events | 393 | diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig |
544 | index XXXXXXX..XXXXXXX 100644 | 394 | index XXXXXXX..XXXXXXX 100644 |
545 | --- a/hw/misc/trace-events | 395 | --- a/hw/misc/Kconfig |
546 | +++ b/hw/misc/trace-events | 396 | +++ b/hw/misc/Kconfig |
547 | @@ -XXX,XX +XXX,XX @@ tz_ppc_irq_clear(int level) "TZ PPC: int_clear = %d" | 397 | @@ -XXX,XX +XXX,XX @@ config VIRT_CTRL |
548 | tz_ppc_update_irq(int level) "TZ PPC: setting irq line to %d" | 398 | config LASI |
549 | tz_ppc_read_blocked(int n, hwaddr offset, bool secure, bool user) "TZ PPC: port %d offset 0x%" HWADDR_PRIx " read (secure %d user %d) blocked" | 399 | bool |
550 | tz_ppc_write_blocked(int n, hwaddr offset, bool secure, bool user) "TZ PPC: port %d offset 0x%" HWADDR_PRIx " write (secure %d user %d) blocked" | 400 | |
551 | + | 401 | +config ALLWINNER_A10_CCM |
552 | +# hw/misc/iotkit-secctl.c | 402 | + bool |
553 | +iotkit_secctl_s_read(uint32_t offset, uint64_t data, unsigned size) "IoTKit SecCtl S regs read: offset 0x%x data 0x%" PRIx64 " size %u" | 403 | + |
554 | +iotkit_secctl_s_write(uint32_t offset, uint64_t data, unsigned size) "IoTKit SecCtl S regs write: offset 0x%x data 0x%" PRIx64 " size %u" | 404 | source macio/Kconfig |
555 | +iotkit_secctl_ns_read(uint32_t offset, uint64_t data, unsigned size) "IoTKit SecCtl NS regs read: offset 0x%x data 0x%" PRIx64 " size %u" | 405 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build |
556 | +iotkit_secctl_ns_write(uint32_t offset, uint64_t data, unsigned size) "IoTKit SecCtl NS regs write: offset 0x%x data 0x%" PRIx64 " size %u" | 406 | index XXXXXXX..XXXXXXX 100644 |
557 | +iotkit_secctl_reset(void) "IoTKit SecCtl: reset" | 407 | --- a/hw/misc/meson.build |
408 | +++ b/hw/misc/meson.build | ||
409 | @@ -XXX,XX +XXX,XX @@ subdir('macio') | ||
410 | |||
411 | softmmu_ss.add(when: 'CONFIG_IVSHMEM_DEVICE', if_true: files('ivshmem.c')) | ||
412 | |||
413 | +softmmu_ss.add(when: 'CONFIG_ALLWINNER_A10_CCM', if_true: files('allwinner-a10-ccm.c')) | ||
414 | softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-ccu.c')) | ||
415 | specific_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-cpucfg.c')) | ||
416 | softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-dramc.c')) | ||
558 | -- | 417 | -- |
559 | 2.16.2 | 418 | 2.34.1 |
560 | |||
561 | diff view generated by jsdifflib |
1 | The MPS2 AN505 FPGA image includes a "FPGA control block" | 1 | From: Strahinja Jankovic <strahinjapjankovic@gmail.com> |
---|---|---|---|
2 | which is a small set of registers handling LEDs, buttons | 2 | |
3 | and some counters. | 3 | During SPL boot several DRAM Controller registers are used. Most |
4 | 4 | important registers are those related to DRAM initialization and | |
5 | calibration, where SPL initiates process and waits until certain bit is | ||
6 | set/cleared. | ||
7 | |||
8 | This patch adds these registers, initializes reset values from user's | ||
9 | guide and updates state of registers as SPL expects it. | ||
10 | |||
11 | Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com> | ||
12 | |||
13 | Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com> | ||
14 | Message-id: 20221226220303.14420-3-strahinja.p.jankovic@gmail.com | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20180220180325.29818-14-peter.maydell@linaro.org | ||
8 | --- | 16 | --- |
9 | hw/misc/Makefile.objs | 1 + | 17 | include/hw/arm/allwinner-a10.h | 2 + |
10 | include/hw/misc/mps2-fpgaio.h | 43 ++++++++++ | 18 | include/hw/misc/allwinner-a10-dramc.h | 68 ++++++++++ |
11 | hw/misc/mps2-fpgaio.c | 176 ++++++++++++++++++++++++++++++++++++++++ | 19 | hw/arm/allwinner-a10.c | 7 + |
12 | default-configs/arm-softmmu.mak | 1 + | 20 | hw/misc/allwinner-a10-dramc.c | 179 ++++++++++++++++++++++++++ |
13 | hw/misc/trace-events | 6 ++ | 21 | hw/arm/Kconfig | 1 + |
14 | 5 files changed, 227 insertions(+) | 22 | hw/misc/Kconfig | 3 + |
15 | create mode 100644 include/hw/misc/mps2-fpgaio.h | 23 | hw/misc/meson.build | 1 + |
16 | create mode 100644 hw/misc/mps2-fpgaio.c | 24 | 7 files changed, 261 insertions(+) |
17 | 25 | create mode 100644 include/hw/misc/allwinner-a10-dramc.h | |
18 | diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs | 26 | create mode 100644 hw/misc/allwinner-a10-dramc.c |
19 | index XXXXXXX..XXXXXXX 100644 | 27 | |
20 | --- a/hw/misc/Makefile.objs | 28 | diff --git a/include/hw/arm/allwinner-a10.h b/include/hw/arm/allwinner-a10.h |
21 | +++ b/hw/misc/Makefile.objs | 29 | index XXXXXXX..XXXXXXX 100644 |
22 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_STM32F2XX_SYSCFG) += stm32f2xx_syscfg.o | 30 | --- a/include/hw/arm/allwinner-a10.h |
23 | obj-$(CONFIG_MIPS_CPS) += mips_cmgcr.o | 31 | +++ b/include/hw/arm/allwinner-a10.h |
24 | obj-$(CONFIG_MIPS_CPS) += mips_cpc.o | 32 | @@ -XXX,XX +XXX,XX @@ |
25 | obj-$(CONFIG_MIPS_ITU) += mips_itu.o | 33 | #include "hw/usb/hcd-ehci.h" |
26 | +obj-$(CONFIG_MPS2_FPGAIO) += mps2-fpgaio.o | 34 | #include "hw/rtc/allwinner-rtc.h" |
27 | obj-$(CONFIG_MPS2_SCC) += mps2-scc.o | 35 | #include "hw/misc/allwinner-a10-ccm.h" |
28 | 36 | +#include "hw/misc/allwinner-a10-dramc.h" | |
29 | obj-$(CONFIG_PVPANIC) += pvpanic.o | 37 | |
30 | diff --git a/include/hw/misc/mps2-fpgaio.h b/include/hw/misc/mps2-fpgaio.h | 38 | #include "target/arm/cpu.h" |
39 | #include "qom/object.h" | ||
40 | @@ -XXX,XX +XXX,XX @@ struct AwA10State { | ||
41 | |||
42 | ARMCPU cpu; | ||
43 | AwA10ClockCtlState ccm; | ||
44 | + AwA10DramControllerState dramc; | ||
45 | AwA10PITState timer; | ||
46 | AwA10PICState intc; | ||
47 | AwEmacState emac; | ||
48 | diff --git a/include/hw/misc/allwinner-a10-dramc.h b/include/hw/misc/allwinner-a10-dramc.h | ||
31 | new file mode 100644 | 49 | new file mode 100644 |
32 | index XXXXXXX..XXXXXXX | 50 | index XXXXXXX..XXXXXXX |
33 | --- /dev/null | 51 | --- /dev/null |
34 | +++ b/include/hw/misc/mps2-fpgaio.h | 52 | +++ b/include/hw/misc/allwinner-a10-dramc.h |
35 | @@ -XXX,XX +XXX,XX @@ | 53 | @@ -XXX,XX +XXX,XX @@ |
36 | +/* | 54 | +/* |
37 | + * ARM MPS2 FPGAIO emulation | 55 | + * Allwinner A10 DRAM Controller emulation |
38 | + * | 56 | + * |
39 | + * Copyright (c) 2018 Linaro Limited | 57 | + * Copyright (C) 2022 Strahinja Jankovic <strahinja.p.jankovic@gmail.com> |
40 | + * Written by Peter Maydell | 58 | + * |
41 | + * | 59 | + * This file is derived from Allwinner H3 DRAMC, |
42 | + * This program is free software; you can redistribute it and/or modify | 60 | + * by Niek Linnenbank. |
43 | + * it under the terms of the GNU General Public License version 2 or | 61 | + * |
44 | + * (at your option) any later version. | 62 | + * This program is free software: you can redistribute it and/or modify |
45 | + */ | 63 | + * it under the terms of the GNU General Public License as published by |
46 | + | 64 | + * the Free Software Foundation, either version 2 of the License, or |
47 | +/* This is a model of the FPGAIO register block in the AN505 | 65 | + * (at your option) any later version. |
48 | + * FPGA image for the MPS2 dev board; it is documented in the | 66 | + * |
49 | + * application note: | 67 | + * This program is distributed in the hope that it will be useful, |
50 | + * http://infocenter.arm.com/help/topic/com.arm.doc.dai0505b/index.html | 68 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
51 | + * | 69 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
52 | + * QEMU interface: | 70 | + * GNU General Public License for more details. |
53 | + * + sysbus MMIO region 0: the register bank | 71 | + * |
54 | + */ | 72 | + * You should have received a copy of the GNU General Public License |
55 | + | 73 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
56 | +#ifndef MPS2_FPGAIO_H | 74 | + */ |
57 | +#define MPS2_FPGAIO_H | 75 | + |
58 | + | 76 | +#ifndef HW_MISC_ALLWINNER_A10_DRAMC_H |
77 | +#define HW_MISC_ALLWINNER_A10_DRAMC_H | ||
78 | + | ||
79 | +#include "qom/object.h" | ||
59 | +#include "hw/sysbus.h" | 80 | +#include "hw/sysbus.h" |
60 | + | 81 | +#include "hw/register.h" |
61 | +#define TYPE_MPS2_FPGAIO "mps2-fpgaio" | 82 | + |
62 | +#define MPS2_FPGAIO(obj) OBJECT_CHECK(MPS2FPGAIO, (obj), TYPE_MPS2_FPGAIO) | 83 | +/** |
63 | + | 84 | + * @name Constants |
64 | +typedef struct { | 85 | + * @{ |
86 | + */ | ||
87 | + | ||
88 | +/** Size of register I/O address space used by DRAMC device */ | ||
89 | +#define AW_A10_DRAMC_IOSIZE (0x1000) | ||
90 | + | ||
91 | +/** Total number of known registers */ | ||
92 | +#define AW_A10_DRAMC_REGS_NUM (AW_A10_DRAMC_IOSIZE / sizeof(uint32_t)) | ||
93 | + | ||
94 | +/** @} */ | ||
95 | + | ||
96 | +/** | ||
97 | + * @name Object model | ||
98 | + * @{ | ||
99 | + */ | ||
100 | + | ||
101 | +#define TYPE_AW_A10_DRAMC "allwinner-a10-dramc" | ||
102 | +OBJECT_DECLARE_SIMPLE_TYPE(AwA10DramControllerState, AW_A10_DRAMC) | ||
103 | + | ||
104 | +/** @} */ | ||
105 | + | ||
106 | +/** | ||
107 | + * Allwinner A10 DRAMC object instance state. | ||
108 | + */ | ||
109 | +struct AwA10DramControllerState { | ||
65 | + /*< private >*/ | 110 | + /*< private >*/ |
66 | + SysBusDevice parent_obj; | 111 | + SysBusDevice parent_obj; |
67 | + | ||
68 | + /*< public >*/ | 112 | + /*< public >*/ |
113 | + | ||
114 | + /** Maps I/O registers in physical memory */ | ||
69 | + MemoryRegion iomem; | 115 | + MemoryRegion iomem; |
70 | + | 116 | + |
71 | + uint32_t led0; | 117 | + /** Array of hardware registers */ |
72 | + uint32_t prescale; | 118 | + uint32_t regs[AW_A10_DRAMC_REGS_NUM]; |
73 | + uint32_t misc; | 119 | +}; |
74 | + | 120 | + |
75 | + uint32_t prescale_clk; | 121 | +#endif /* HW_MISC_ALLWINNER_A10_DRAMC_H */ |
76 | +} MPS2FPGAIO; | 122 | diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c |
77 | + | 123 | index XXXXXXX..XXXXXXX 100644 |
78 | +#endif | 124 | --- a/hw/arm/allwinner-a10.c |
79 | diff --git a/hw/misc/mps2-fpgaio.c b/hw/misc/mps2-fpgaio.c | 125 | +++ b/hw/arm/allwinner-a10.c |
126 | @@ -XXX,XX +XXX,XX @@ | ||
127 | #include "hw/boards.h" | ||
128 | #include "hw/usb/hcd-ohci.h" | ||
129 | |||
130 | +#define AW_A10_DRAMC_BASE 0x01c01000 | ||
131 | #define AW_A10_MMC0_BASE 0x01c0f000 | ||
132 | #define AW_A10_CCM_BASE 0x01c20000 | ||
133 | #define AW_A10_PIC_REG_BASE 0x01c20400 | ||
134 | @@ -XXX,XX +XXX,XX @@ static void aw_a10_init(Object *obj) | ||
135 | |||
136 | object_initialize_child(obj, "ccm", &s->ccm, TYPE_AW_A10_CCM); | ||
137 | |||
138 | + object_initialize_child(obj, "dramc", &s->dramc, TYPE_AW_A10_DRAMC); | ||
139 | + | ||
140 | object_initialize_child(obj, "emac", &s->emac, TYPE_AW_EMAC); | ||
141 | |||
142 | object_initialize_child(obj, "sata", &s->sata, TYPE_ALLWINNER_AHCI); | ||
143 | @@ -XXX,XX +XXX,XX @@ static void aw_a10_realize(DeviceState *dev, Error **errp) | ||
144 | sysbus_realize(SYS_BUS_DEVICE(&s->ccm), &error_fatal); | ||
145 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->ccm), 0, AW_A10_CCM_BASE); | ||
146 | |||
147 | + /* DRAM Control Module */ | ||
148 | + sysbus_realize(SYS_BUS_DEVICE(&s->dramc), &error_fatal); | ||
149 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->dramc), 0, AW_A10_DRAMC_BASE); | ||
150 | + | ||
151 | /* FIXME use qdev NIC properties instead of nd_table[] */ | ||
152 | if (nd_table[0].used) { | ||
153 | qemu_check_nic_model(&nd_table[0], TYPE_AW_EMAC); | ||
154 | diff --git a/hw/misc/allwinner-a10-dramc.c b/hw/misc/allwinner-a10-dramc.c | ||
80 | new file mode 100644 | 155 | new file mode 100644 |
81 | index XXXXXXX..XXXXXXX | 156 | index XXXXXXX..XXXXXXX |
82 | --- /dev/null | 157 | --- /dev/null |
83 | +++ b/hw/misc/mps2-fpgaio.c | 158 | +++ b/hw/misc/allwinner-a10-dramc.c |
84 | @@ -XXX,XX +XXX,XX @@ | 159 | @@ -XXX,XX +XXX,XX @@ |
85 | +/* | 160 | +/* |
86 | + * ARM MPS2 AN505 FPGAIO emulation | 161 | + * Allwinner A10 DRAM Controller emulation |
87 | + * | 162 | + * |
88 | + * Copyright (c) 2018 Linaro Limited | 163 | + * Copyright (C) 2022 Strahinja Jankovic <strahinja.p.jankovic@gmail.com> |
89 | + * Written by Peter Maydell | 164 | + * |
90 | + * | 165 | + * This file is derived from Allwinner H3 DRAMC, |
91 | + * This program is free software; you can redistribute it and/or modify | 166 | + * by Niek Linnenbank. |
92 | + * it under the terms of the GNU General Public License version 2 or | 167 | + * |
93 | + * (at your option) any later version. | 168 | + * This program is free software: you can redistribute it and/or modify |
94 | + */ | 169 | + * it under the terms of the GNU General Public License as published by |
95 | + | 170 | + * the Free Software Foundation, either version 2 of the License, or |
96 | +/* This is a model of the "FPGA system control and I/O" block found | 171 | + * (at your option) any later version. |
97 | + * in the AN505 FPGA image for the MPS2 devboard. | 172 | + * |
98 | + * It is documented in AN505: | 173 | + * This program is distributed in the hope that it will be useful, |
99 | + * http://infocenter.arm.com/help/topic/com.arm.doc.dai0505b/index.html | 174 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
175 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
176 | + * GNU General Public License for more details. | ||
177 | + * | ||
178 | + * You should have received a copy of the GNU General Public License | ||
179 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
100 | + */ | 180 | + */ |
101 | + | 181 | + |
102 | +#include "qemu/osdep.h" | 182 | +#include "qemu/osdep.h" |
183 | +#include "qemu/units.h" | ||
184 | +#include "hw/sysbus.h" | ||
185 | +#include "migration/vmstate.h" | ||
103 | +#include "qemu/log.h" | 186 | +#include "qemu/log.h" |
104 | +#include "qapi/error.h" | 187 | +#include "qemu/module.h" |
105 | +#include "trace.h" | 188 | +#include "hw/misc/allwinner-a10-dramc.h" |
106 | +#include "hw/sysbus.h" | 189 | + |
107 | +#include "hw/registerfields.h" | 190 | +/* DRAMC register offsets */ |
108 | +#include "hw/misc/mps2-fpgaio.h" | 191 | +enum { |
109 | + | 192 | + REG_SDR_CCR = 0x0000, |
110 | +REG32(LED0, 0) | 193 | + REG_SDR_ZQCR0 = 0x00a8, |
111 | +REG32(BUTTON, 8) | 194 | + REG_SDR_ZQSR = 0x00b0 |
112 | +REG32(CLK1HZ, 0x10) | 195 | +}; |
113 | +REG32(CLK100HZ, 0x14) | 196 | + |
114 | +REG32(COUNTER, 0x18) | 197 | +#define REG_INDEX(offset) (offset / sizeof(uint32_t)) |
115 | +REG32(PRESCALE, 0x1c) | 198 | + |
116 | +REG32(PSCNTR, 0x20) | 199 | +/* DRAMC register flags */ |
117 | +REG32(MISC, 0x4c) | 200 | +enum { |
118 | + | 201 | + REG_SDR_CCR_DATA_TRAINING = (1 << 30), |
119 | +static uint64_t mps2_fpgaio_read(void *opaque, hwaddr offset, unsigned size) | 202 | + REG_SDR_CCR_DRAM_INIT = (1 << 31), |
120 | +{ | 203 | +}; |
121 | + MPS2FPGAIO *s = MPS2_FPGAIO(opaque); | 204 | +enum { |
122 | + uint64_t r; | 205 | + REG_SDR_ZQSR_ZCAL = (1 << 31), |
206 | +}; | ||
207 | + | ||
208 | +/* DRAMC register reset values */ | ||
209 | +enum { | ||
210 | + REG_SDR_CCR_RESET = 0x80020000, | ||
211 | + REG_SDR_ZQCR0_RESET = 0x07b00000, | ||
212 | + REG_SDR_ZQSR_RESET = 0x80000000 | ||
213 | +}; | ||
214 | + | ||
215 | +static uint64_t allwinner_a10_dramc_read(void *opaque, hwaddr offset, | ||
216 | + unsigned size) | ||
217 | +{ | ||
218 | + const AwA10DramControllerState *s = AW_A10_DRAMC(opaque); | ||
219 | + const uint32_t idx = REG_INDEX(offset); | ||
123 | + | 220 | + |
124 | + switch (offset) { | 221 | + switch (offset) { |
125 | + case A_LED0: | 222 | + case REG_SDR_CCR: |
126 | + r = s->led0; | 223 | + case REG_SDR_ZQCR0: |
127 | + break; | 224 | + case REG_SDR_ZQSR: |
128 | + case A_BUTTON: | 225 | + break; |
129 | + /* User-pressable board buttons. We don't model that, so just return | 226 | + case 0x2e4 ... AW_A10_DRAMC_IOSIZE: |
130 | + * zeroes. | 227 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: out-of-bounds offset 0x%04x\n", |
131 | + */ | 228 | + __func__, (uint32_t)offset); |
132 | + r = 0; | 229 | + return 0; |
133 | + break; | ||
134 | + case A_PRESCALE: | ||
135 | + r = s->prescale; | ||
136 | + break; | ||
137 | + case A_MISC: | ||
138 | + r = s->misc; | ||
139 | + break; | ||
140 | + case A_CLK1HZ: | ||
141 | + case A_CLK100HZ: | ||
142 | + case A_COUNTER: | ||
143 | + case A_PSCNTR: | ||
144 | + /* These are all upcounters of various frequencies. */ | ||
145 | + qemu_log_mask(LOG_UNIMP, "MPS2 FPGAIO: counters unimplemented\n"); | ||
146 | + r = 0; | ||
147 | + break; | ||
148 | + default: | 230 | + default: |
149 | + qemu_log_mask(LOG_GUEST_ERROR, | 231 | + qemu_log_mask(LOG_UNIMP, "%s: unimplemented read offset 0x%04x\n", |
150 | + "MPS2 FPGAIO read: bad offset %x\n", (int) offset); | 232 | + __func__, (uint32_t)offset); |
151 | + r = 0; | 233 | + return 0; |
152 | + break; | ||
153 | + } | 234 | + } |
154 | + | 235 | + |
155 | + trace_mps2_fpgaio_read(offset, r, size); | 236 | + return s->regs[idx]; |
156 | + return r; | 237 | +} |
157 | +} | 238 | + |
158 | + | 239 | +static void allwinner_a10_dramc_write(void *opaque, hwaddr offset, |
159 | +static void mps2_fpgaio_write(void *opaque, hwaddr offset, uint64_t value, | 240 | + uint64_t val, unsigned size) |
160 | + unsigned size) | 241 | +{ |
161 | +{ | 242 | + AwA10DramControllerState *s = AW_A10_DRAMC(opaque); |
162 | + MPS2FPGAIO *s = MPS2_FPGAIO(opaque); | 243 | + const uint32_t idx = REG_INDEX(offset); |
163 | + | ||
164 | + trace_mps2_fpgaio_write(offset, value, size); | ||
165 | + | 244 | + |
166 | + switch (offset) { | 245 | + switch (offset) { |
167 | + case A_LED0: | 246 | + case REG_SDR_CCR: |
168 | + /* LED bits [1:0] control board LEDs. We don't currently have | 247 | + if (val & REG_SDR_CCR_DRAM_INIT) { |
169 | + * a mechanism for displaying this graphically, so use a trace event. | 248 | + /* Clear DRAM_INIT to indicate process is done. */ |
170 | + */ | 249 | + val &= ~REG_SDR_CCR_DRAM_INIT; |
171 | + trace_mps2_fpgaio_leds(value & 0x02 ? '*' : '.', | 250 | + } |
172 | + value & 0x01 ? '*' : '.'); | 251 | + if (val & REG_SDR_CCR_DATA_TRAINING) { |
173 | + s->led0 = value & 0x3; | 252 | + /* Clear DATA_TRAINING to indicate process is done. */ |
174 | + break; | 253 | + val &= ~REG_SDR_CCR_DATA_TRAINING; |
175 | + case A_PRESCALE: | 254 | + } |
176 | + s->prescale = value; | 255 | + break; |
177 | + break; | 256 | + case REG_SDR_ZQCR0: |
178 | + case A_MISC: | 257 | + /* Set ZCAL in ZQSR to indicate calibration is done. */ |
179 | + /* These are control bits for some of the other devices on the | 258 | + s->regs[REG_INDEX(REG_SDR_ZQSR)] |= REG_SDR_ZQSR_ZCAL; |
180 | + * board (SPI, CLCD, etc). We don't implement that yet, so just | 259 | + break; |
181 | + * make the bits read as written. | 260 | + case 0x2e4 ... AW_A10_DRAMC_IOSIZE: |
182 | + */ | 261 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: out-of-bounds offset 0x%04x\n", |
183 | + qemu_log_mask(LOG_UNIMP, | 262 | + __func__, (uint32_t)offset); |
184 | + "MPS2 FPGAIO: MISC control bits unimplemented\n"); | ||
185 | + s->misc = value; | ||
186 | + break; | 263 | + break; |
187 | + default: | 264 | + default: |
188 | + qemu_log_mask(LOG_GUEST_ERROR, | 265 | + qemu_log_mask(LOG_UNIMP, "%s: unimplemented write offset 0x%04x\n", |
189 | + "MPS2 FPGAIO write: bad offset 0x%x\n", (int) offset); | 266 | + __func__, (uint32_t)offset); |
190 | + break; | 267 | + break; |
191 | + } | 268 | + } |
192 | +} | 269 | + |
193 | + | 270 | + s->regs[idx] = (uint32_t) val; |
194 | +static const MemoryRegionOps mps2_fpgaio_ops = { | 271 | +} |
195 | + .read = mps2_fpgaio_read, | 272 | + |
196 | + .write = mps2_fpgaio_write, | 273 | +static const MemoryRegionOps allwinner_a10_dramc_ops = { |
197 | + .endianness = DEVICE_LITTLE_ENDIAN, | 274 | + .read = allwinner_a10_dramc_read, |
198 | +}; | 275 | + .write = allwinner_a10_dramc_write, |
199 | + | 276 | + .endianness = DEVICE_NATIVE_ENDIAN, |
200 | +static void mps2_fpgaio_reset(DeviceState *dev) | 277 | + .valid = { |
201 | +{ | 278 | + .min_access_size = 4, |
202 | + MPS2FPGAIO *s = MPS2_FPGAIO(dev); | 279 | + .max_access_size = 4, |
203 | + | 280 | + }, |
204 | + trace_mps2_fpgaio_reset(); | 281 | + .impl.min_access_size = 4, |
205 | + s->led0 = 0; | 282 | +}; |
206 | + s->prescale = 0; | 283 | + |
207 | + s->misc = 0; | 284 | +static void allwinner_a10_dramc_reset_enter(Object *obj, ResetType type) |
208 | +} | 285 | +{ |
209 | + | 286 | + AwA10DramControllerState *s = AW_A10_DRAMC(obj); |
210 | +static void mps2_fpgaio_init(Object *obj) | 287 | + |
288 | + /* Set default values for registers */ | ||
289 | + s->regs[REG_INDEX(REG_SDR_CCR)] = REG_SDR_CCR_RESET; | ||
290 | + s->regs[REG_INDEX(REG_SDR_ZQCR0)] = REG_SDR_ZQCR0_RESET; | ||
291 | + s->regs[REG_INDEX(REG_SDR_ZQSR)] = REG_SDR_ZQSR_RESET; | ||
292 | +} | ||
293 | + | ||
294 | +static void allwinner_a10_dramc_init(Object *obj) | ||
211 | +{ | 295 | +{ |
212 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | 296 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); |
213 | + MPS2FPGAIO *s = MPS2_FPGAIO(obj); | 297 | + AwA10DramControllerState *s = AW_A10_DRAMC(obj); |
214 | + | 298 | + |
215 | + memory_region_init_io(&s->iomem, obj, &mps2_fpgaio_ops, s, | 299 | + /* Memory mapping */ |
216 | + "mps2-fpgaio", 0x1000); | 300 | + memory_region_init_io(&s->iomem, OBJECT(s), &allwinner_a10_dramc_ops, s, |
301 | + TYPE_AW_A10_DRAMC, AW_A10_DRAMC_IOSIZE); | ||
217 | + sysbus_init_mmio(sbd, &s->iomem); | 302 | + sysbus_init_mmio(sbd, &s->iomem); |
218 | +} | 303 | +} |
219 | + | 304 | + |
220 | +static const VMStateDescription mps2_fpgaio_vmstate = { | 305 | +static const VMStateDescription allwinner_a10_dramc_vmstate = { |
221 | + .name = "mps2-fpgaio", | 306 | + .name = "allwinner-a10-dramc", |
222 | + .version_id = 1, | 307 | + .version_id = 1, |
223 | + .minimum_version_id = 1, | 308 | + .minimum_version_id = 1, |
224 | + .fields = (VMStateField[]) { | 309 | + .fields = (VMStateField[]) { |
225 | + VMSTATE_UINT32(led0, MPS2FPGAIO), | 310 | + VMSTATE_UINT32_ARRAY(regs, AwA10DramControllerState, |
226 | + VMSTATE_UINT32(prescale, MPS2FPGAIO), | 311 | + AW_A10_DRAMC_REGS_NUM), |
227 | + VMSTATE_UINT32(misc, MPS2FPGAIO), | ||
228 | + VMSTATE_END_OF_LIST() | 312 | + VMSTATE_END_OF_LIST() |
229 | + } | 313 | + } |
230 | +}; | 314 | +}; |
231 | + | 315 | + |
232 | +static Property mps2_fpgaio_properties[] = { | 316 | +static void allwinner_a10_dramc_class_init(ObjectClass *klass, void *data) |
233 | + /* Frequency of the prescale counter */ | ||
234 | + DEFINE_PROP_UINT32("prescale-clk", MPS2FPGAIO, prescale_clk, 20000000), | ||
235 | + DEFINE_PROP_END_OF_LIST(), | ||
236 | +}; | ||
237 | + | ||
238 | +static void mps2_fpgaio_class_init(ObjectClass *klass, void *data) | ||
239 | +{ | 317 | +{ |
240 | + DeviceClass *dc = DEVICE_CLASS(klass); | 318 | + DeviceClass *dc = DEVICE_CLASS(klass); |
241 | + | 319 | + ResettableClass *rc = RESETTABLE_CLASS(klass); |
242 | + dc->vmsd = &mps2_fpgaio_vmstate; | 320 | + |
243 | + dc->reset = mps2_fpgaio_reset; | 321 | + rc->phases.enter = allwinner_a10_dramc_reset_enter; |
244 | + dc->props = mps2_fpgaio_properties; | 322 | + dc->vmsd = &allwinner_a10_dramc_vmstate; |
245 | +} | 323 | +} |
246 | + | 324 | + |
247 | +static const TypeInfo mps2_fpgaio_info = { | 325 | +static const TypeInfo allwinner_a10_dramc_info = { |
248 | + .name = TYPE_MPS2_FPGAIO, | 326 | + .name = TYPE_AW_A10_DRAMC, |
249 | + .parent = TYPE_SYS_BUS_DEVICE, | 327 | + .parent = TYPE_SYS_BUS_DEVICE, |
250 | + .instance_size = sizeof(MPS2FPGAIO), | 328 | + .instance_init = allwinner_a10_dramc_init, |
251 | + .instance_init = mps2_fpgaio_init, | 329 | + .instance_size = sizeof(AwA10DramControllerState), |
252 | + .class_init = mps2_fpgaio_class_init, | 330 | + .class_init = allwinner_a10_dramc_class_init, |
253 | +}; | 331 | +}; |
254 | + | 332 | + |
255 | +static void mps2_fpgaio_register_types(void) | 333 | +static void allwinner_a10_dramc_register(void) |
256 | +{ | 334 | +{ |
257 | + type_register_static(&mps2_fpgaio_info); | 335 | + type_register_static(&allwinner_a10_dramc_info); |
258 | +} | 336 | +} |
259 | + | 337 | + |
260 | +type_init(mps2_fpgaio_register_types); | 338 | +type_init(allwinner_a10_dramc_register) |
261 | diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak | 339 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig |
262 | index XXXXXXX..XXXXXXX 100644 | 340 | index XXXXXXX..XXXXXXX 100644 |
263 | --- a/default-configs/arm-softmmu.mak | 341 | --- a/hw/arm/Kconfig |
264 | +++ b/default-configs/arm-softmmu.mak | 342 | +++ b/hw/arm/Kconfig |
265 | @@ -XXX,XX +XXX,XX @@ CONFIG_STM32F205_SOC=y | 343 | @@ -XXX,XX +XXX,XX @@ config ALLWINNER_A10 |
266 | CONFIG_CMSDK_APB_TIMER=y | 344 | select ALLWINNER_A10_PIT |
267 | CONFIG_CMSDK_APB_UART=y | 345 | select ALLWINNER_A10_PIC |
268 | 346 | select ALLWINNER_A10_CCM | |
269 | +CONFIG_MPS2_FPGAIO=y | 347 | + select ALLWINNER_A10_DRAMC |
270 | CONFIG_MPS2_SCC=y | 348 | select ALLWINNER_EMAC |
271 | 349 | select SERIAL | |
272 | CONFIG_VERSATILE_PCI=y | 350 | select UNIMP |
273 | diff --git a/hw/misc/trace-events b/hw/misc/trace-events | 351 | diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig |
274 | index XXXXXXX..XXXXXXX 100644 | 352 | index XXXXXXX..XXXXXXX 100644 |
275 | --- a/hw/misc/trace-events | 353 | --- a/hw/misc/Kconfig |
276 | +++ b/hw/misc/trace-events | 354 | +++ b/hw/misc/Kconfig |
277 | @@ -XXX,XX +XXX,XX @@ mps2_scc_leds(char led7, char led6, char led5, char led4, char led3, char led2, | 355 | @@ -XXX,XX +XXX,XX @@ config LASI |
278 | mps2_scc_cfg_write(unsigned function, unsigned device, uint32_t value) "MPS2 SCC config write: function %d device %d data 0x%" PRIx32 | 356 | config ALLWINNER_A10_CCM |
279 | mps2_scc_cfg_read(unsigned function, unsigned device, uint32_t value) "MPS2 SCC config read: function %d device %d data 0x%" PRIx32 | 357 | bool |
280 | 358 | ||
281 | +# hw/misc/mps2_fpgaio.c | 359 | +config ALLWINNER_A10_DRAMC |
282 | +mps2_fpgaio_read(uint64_t offset, uint64_t data, unsigned size) "MPS2 FPGAIO read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" | 360 | + bool |
283 | +mps2_fpgaio_write(uint64_t offset, uint64_t data, unsigned size) "MPS2 FPGAIO write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" | 361 | + |
284 | +mps2_fpgaio_reset(void) "MPS2 FPGAIO: reset" | 362 | source macio/Kconfig |
285 | +mps2_fpgaio_leds(char led1, char led0) "MPS2 FPGAIO LEDs: %c%c" | 363 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build |
286 | + | 364 | index XXXXXXX..XXXXXXX 100644 |
287 | # hw/misc/msf2-sysreg.c | 365 | --- a/hw/misc/meson.build |
288 | msf2_sysreg_write(uint64_t offset, uint32_t val, uint32_t prev) "msf2-sysreg write: addr 0x%08" HWADDR_PRIx " data 0x%" PRIx32 " prev 0x%" PRIx32 | 366 | +++ b/hw/misc/meson.build |
289 | msf2_sysreg_read(uint64_t offset, uint32_t val) "msf2-sysreg read: addr 0x%08" HWADDR_PRIx " data 0x%08" PRIx32 | 367 | @@ -XXX,XX +XXX,XX @@ subdir('macio') |
368 | softmmu_ss.add(when: 'CONFIG_IVSHMEM_DEVICE', if_true: files('ivshmem.c')) | ||
369 | |||
370 | softmmu_ss.add(when: 'CONFIG_ALLWINNER_A10_CCM', if_true: files('allwinner-a10-ccm.c')) | ||
371 | +softmmu_ss.add(when: 'CONFIG_ALLWINNER_A10_DRAMC', if_true: files('allwinner-a10-dramc.c')) | ||
372 | softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-ccu.c')) | ||
373 | specific_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-cpucfg.c')) | ||
374 | softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-dramc.c')) | ||
290 | -- | 375 | -- |
291 | 2.16.2 | 376 | 2.34.1 |
292 | |||
293 | diff view generated by jsdifflib |
1 | Add a model of the TrustZone peripheral protection controller (PPC), | 1 | From: Strahinja Jankovic <strahinjapjankovic@gmail.com> |
---|---|---|---|
2 | which is used to gate transactions to non-TZ-aware peripherals so | ||
3 | that secure software can configure them to not be accessible to | ||
4 | non-secure software. | ||
5 | 2 | ||
3 | This patch implements Allwinner TWI/I2C controller emulation. Only | ||
4 | master-mode functionality is implemented. | ||
5 | |||
6 | The SPL boot for Cubieboard expects AXP209 PMIC on TWI0/I2C0 bus, so this is | ||
7 | first part enabling the TWI/I2C bus operation. | ||
8 | |||
9 | Since both Allwinner A10 and H3 use the same module, it is added for | ||
10 | both boards. | ||
11 | |||
12 | Docs are also updated for Cubieboard and Orangepi-PC board to indicate | ||
13 | I2C availability. | ||
14 | |||
15 | Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com> | ||
16 | Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com> | ||
17 | Message-id: 20221226220303.14420-4-strahinja.p.jankovic@gmail.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20180220180325.29818-15-peter.maydell@linaro.org | ||
9 | --- | 19 | --- |
10 | hw/misc/Makefile.objs | 2 + | 20 | docs/system/arm/cubieboard.rst | 1 + |
11 | include/hw/misc/tz-ppc.h | 101 ++++++++++++++ | 21 | docs/system/arm/orangepi.rst | 1 + |
12 | hw/misc/tz-ppc.c | 302 ++++++++++++++++++++++++++++++++++++++++ | 22 | include/hw/arm/allwinner-a10.h | 2 + |
13 | default-configs/arm-softmmu.mak | 2 + | 23 | include/hw/arm/allwinner-h3.h | 3 + |
14 | hw/misc/trace-events | 11 ++ | 24 | include/hw/i2c/allwinner-i2c.h | 55 ++++ |
15 | 5 files changed, 418 insertions(+) | 25 | hw/arm/allwinner-a10.c | 8 + |
16 | create mode 100644 include/hw/misc/tz-ppc.h | 26 | hw/arm/allwinner-h3.c | 11 +- |
17 | create mode 100644 hw/misc/tz-ppc.c | 27 | hw/i2c/allwinner-i2c.c | 459 +++++++++++++++++++++++++++++++++ |
28 | hw/arm/Kconfig | 2 + | ||
29 | hw/i2c/Kconfig | 4 + | ||
30 | hw/i2c/meson.build | 1 + | ||
31 | hw/i2c/trace-events | 5 + | ||
32 | 12 files changed, 551 insertions(+), 1 deletion(-) | ||
33 | create mode 100644 include/hw/i2c/allwinner-i2c.h | ||
34 | create mode 100644 hw/i2c/allwinner-i2c.c | ||
18 | 35 | ||
19 | diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs | 36 | diff --git a/docs/system/arm/cubieboard.rst b/docs/system/arm/cubieboard.rst |
20 | index XXXXXXX..XXXXXXX 100644 | 37 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/misc/Makefile.objs | 38 | --- a/docs/system/arm/cubieboard.rst |
22 | +++ b/hw/misc/Makefile.objs | 39 | +++ b/docs/system/arm/cubieboard.rst |
23 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_MIPS_ITU) += mips_itu.o | 40 | @@ -XXX,XX +XXX,XX @@ Emulated devices: |
24 | obj-$(CONFIG_MPS2_FPGAIO) += mps2-fpgaio.o | 41 | - SDHCI |
25 | obj-$(CONFIG_MPS2_SCC) += mps2-scc.o | 42 | - USB controller |
26 | 43 | - SATA controller | |
27 | +obj-$(CONFIG_TZ_PPC) += tz-ppc.o | 44 | +- TWI (I2C) controller |
28 | + | 45 | diff --git a/docs/system/arm/orangepi.rst b/docs/system/arm/orangepi.rst |
29 | obj-$(CONFIG_PVPANIC) += pvpanic.o | 46 | index XXXXXXX..XXXXXXX 100644 |
30 | obj-$(CONFIG_HYPERV_TESTDEV) += hyperv_testdev.o | 47 | --- a/docs/system/arm/orangepi.rst |
31 | obj-$(CONFIG_AUX) += auxbus.o | 48 | +++ b/docs/system/arm/orangepi.rst |
32 | diff --git a/include/hw/misc/tz-ppc.h b/include/hw/misc/tz-ppc.h | 49 | @@ -XXX,XX +XXX,XX @@ The Orange Pi PC machine supports the following devices: |
50 | * Clock Control Unit | ||
51 | * System Control module | ||
52 | * Security Identifier device | ||
53 | + * TWI (I2C) | ||
54 | |||
55 | Limitations | ||
56 | """"""""""" | ||
57 | diff --git a/include/hw/arm/allwinner-a10.h b/include/hw/arm/allwinner-a10.h | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/include/hw/arm/allwinner-a10.h | ||
60 | +++ b/include/hw/arm/allwinner-a10.h | ||
61 | @@ -XXX,XX +XXX,XX @@ | ||
62 | #include "hw/rtc/allwinner-rtc.h" | ||
63 | #include "hw/misc/allwinner-a10-ccm.h" | ||
64 | #include "hw/misc/allwinner-a10-dramc.h" | ||
65 | +#include "hw/i2c/allwinner-i2c.h" | ||
66 | |||
67 | #include "target/arm/cpu.h" | ||
68 | #include "qom/object.h" | ||
69 | @@ -XXX,XX +XXX,XX @@ struct AwA10State { | ||
70 | AwEmacState emac; | ||
71 | AllwinnerAHCIState sata; | ||
72 | AwSdHostState mmc0; | ||
73 | + AWI2CState i2c0; | ||
74 | AwRtcState rtc; | ||
75 | MemoryRegion sram_a; | ||
76 | EHCISysBusState ehci[AW_A10_NUM_USB]; | ||
77 | diff --git a/include/hw/arm/allwinner-h3.h b/include/hw/arm/allwinner-h3.h | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | --- a/include/hw/arm/allwinner-h3.h | ||
80 | +++ b/include/hw/arm/allwinner-h3.h | ||
81 | @@ -XXX,XX +XXX,XX @@ | ||
82 | #include "hw/sd/allwinner-sdhost.h" | ||
83 | #include "hw/net/allwinner-sun8i-emac.h" | ||
84 | #include "hw/rtc/allwinner-rtc.h" | ||
85 | +#include "hw/i2c/allwinner-i2c.h" | ||
86 | #include "target/arm/cpu.h" | ||
87 | #include "sysemu/block-backend.h" | ||
88 | |||
89 | @@ -XXX,XX +XXX,XX @@ enum { | ||
90 | AW_H3_DEV_UART2, | ||
91 | AW_H3_DEV_UART3, | ||
92 | AW_H3_DEV_EMAC, | ||
93 | + AW_H3_DEV_TWI0, | ||
94 | AW_H3_DEV_DRAMCOM, | ||
95 | AW_H3_DEV_DRAMCTL, | ||
96 | AW_H3_DEV_DRAMPHY, | ||
97 | @@ -XXX,XX +XXX,XX @@ struct AwH3State { | ||
98 | AwH3SysCtrlState sysctrl; | ||
99 | AwSidState sid; | ||
100 | AwSdHostState mmc0; | ||
101 | + AWI2CState i2c0; | ||
102 | AwSun8iEmacState emac; | ||
103 | AwRtcState rtc; | ||
104 | GICState gic; | ||
105 | diff --git a/include/hw/i2c/allwinner-i2c.h b/include/hw/i2c/allwinner-i2c.h | ||
33 | new file mode 100644 | 106 | new file mode 100644 |
34 | index XXXXXXX..XXXXXXX | 107 | index XXXXXXX..XXXXXXX |
35 | --- /dev/null | 108 | --- /dev/null |
36 | +++ b/include/hw/misc/tz-ppc.h | 109 | +++ b/include/hw/i2c/allwinner-i2c.h |
37 | @@ -XXX,XX +XXX,XX @@ | 110 | @@ -XXX,XX +XXX,XX @@ |
38 | +/* | 111 | +/* |
39 | + * ARM TrustZone peripheral protection controller emulation | 112 | + * Allwinner I2C Bus Serial Interface registers definition |
40 | + * | 113 | + * |
41 | + * Copyright (c) 2018 Linaro Limited | 114 | + * Copyright (C) 2022 Strahinja Jankovic. <strahinja.p.jankovic@gmail.com> |
42 | + * Written by Peter Maydell | 115 | + * |
43 | + * | 116 | + * This file is derived from IMX I2C controller, |
44 | + * This program is free software; you can redistribute it and/or modify | 117 | + * by Jean-Christophe DUBOIS . |
45 | + * it under the terms of the GNU General Public License version 2 or | 118 | + * |
46 | + * (at your option) any later version. | 119 | + * This program is free software; you can redistribute it and/or modify it |
120 | + * under the terms of the GNU General Public License as published by the | ||
121 | + * Free Software Foundation; either version 2 of the License, or | ||
122 | + * (at your option) any later version. | ||
123 | + * | ||
124 | + * This program is distributed in the hope that it will be useful, but WITHOUT | ||
125 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
126 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
127 | + * for more details. | ||
128 | + * | ||
129 | + * You should have received a copy of the GNU General Public License along | ||
130 | + * with this program; if not, see <http://www.gnu.org/licenses/>. | ||
131 | + * | ||
47 | + */ | 132 | + */ |
48 | + | 133 | + |
49 | +/* This is a model of the TrustZone peripheral protection controller (PPC). | 134 | +#ifndef ALLWINNER_I2C_H |
50 | + * It is documented in the ARM CoreLink SIE-200 System IP for Embedded TRM | 135 | +#define ALLWINNER_I2C_H |
51 | + * (DDI 0571G): | ||
52 | + * https://developer.arm.com/products/architecture/m-profile/docs/ddi0571/g | ||
53 | + * | ||
54 | + * The PPC sits in front of peripherals and allows secure software to | ||
55 | + * configure it to either pass through or reject transactions. | ||
56 | + * Rejected transactions may be configured to either be aborted, or to | ||
57 | + * behave as RAZ/WI. An interrupt can be signalled for a rejected transaction. | ||
58 | + * | ||
59 | + * The PPC has no register interface -- it is configured purely by a | ||
60 | + * collection of input signals from other hardware in the system. Typically | ||
61 | + * they are either hardwired or exposed in an ad-hoc register interface by | ||
62 | + * the SoC that uses the PPC. | ||
63 | + * | ||
64 | + * This QEMU model can be used to model either the AHB5 or APB4 TZ PPC, | ||
65 | + * since the only difference between them is that the AHB version has a | ||
66 | + * "default" port which has no security checks applied. In QEMU the default | ||
67 | + * port can be emulated simply by wiring its downstream devices directly | ||
68 | + * into the parent address space, since the PPC does not need to intercept | ||
69 | + * transactions there. | ||
70 | + * | ||
71 | + * In the hardware, selection of which downstream port to use is done by | ||
72 | + * the user's decode logic asserting one of the hsel[] signals. In QEMU, | ||
73 | + * we provide 16 MMIO regions, one per port, and the user maps these into | ||
74 | + * the desired addresses to implement the address decode. | ||
75 | + * | ||
76 | + * QEMU interface: | ||
77 | + * + sysbus MMIO regions 0..15: MemoryRegions defining the upstream end | ||
78 | + * of each of the 16 ports of the PPC | ||
79 | + * + Property "port[0..15]": MemoryRegion defining the downstream device(s) | ||
80 | + * for each of the 16 ports of the PPC | ||
81 | + * + Named GPIO inputs "cfg_nonsec[0..15]": set to 1 if the port should be | ||
82 | + * accessible to NonSecure transactions | ||
83 | + * + Named GPIO inputs "cfg_ap[0..15]": set to 1 if the port should be | ||
84 | + * accessible to non-privileged transactions | ||
85 | + * + Named GPIO input "cfg_sec_resp": set to 1 if a rejected transaction should | ||
86 | + * result in a transaction error, or 0 for the transaction to RAZ/WI | ||
87 | + * + Named GPIO input "irq_enable": set to 1 to enable interrupts | ||
88 | + * + Named GPIO input "irq_clear": set to 1 to clear a pending interrupt | ||
89 | + * + Named GPIO output "irq": set for a transaction-failed interrupt | ||
90 | + * + Property "NONSEC_MASK": if a bit is set in this mask then accesses to | ||
91 | + * the associated port do not have the TZ security check performed. (This | ||
92 | + * corresponds to the hardware allowing this to be set as a Verilog | ||
93 | + * parameter.) | ||
94 | + */ | ||
95 | + | ||
96 | +#ifndef TZ_PPC_H | ||
97 | +#define TZ_PPC_H | ||
98 | + | 136 | + |
99 | +#include "hw/sysbus.h" | 137 | +#include "hw/sysbus.h" |
100 | + | 138 | +#include "qom/object.h" |
101 | +#define TYPE_TZ_PPC "tz-ppc" | 139 | + |
102 | +#define TZ_PPC(obj) OBJECT_CHECK(TZPPC, (obj), TYPE_TZ_PPC) | 140 | +#define TYPE_AW_I2C "allwinner.i2c" |
103 | + | 141 | +OBJECT_DECLARE_SIMPLE_TYPE(AWI2CState, AW_I2C) |
104 | +#define TZ_NUM_PORTS 16 | 142 | + |
105 | + | 143 | +#define AW_I2C_MEM_SIZE 0x24 |
106 | +typedef struct TZPPC TZPPC; | 144 | + |
107 | + | 145 | +struct AWI2CState { |
108 | +typedef struct TZPPCPort { | ||
109 | + TZPPC *ppc; | ||
110 | + MemoryRegion upstream; | ||
111 | + AddressSpace downstream_as; | ||
112 | + MemoryRegion *downstream; | ||
113 | +} TZPPCPort; | ||
114 | + | ||
115 | +struct TZPPC { | ||
116 | + /*< private >*/ | 146 | + /*< private >*/ |
117 | + SysBusDevice parent_obj; | 147 | + SysBusDevice parent_obj; |
118 | + | 148 | + |
119 | + /*< public >*/ | 149 | + /*< public >*/ |
120 | + | 150 | + MemoryRegion iomem; |
121 | + /* State: these just track the values of our input signals */ | 151 | + I2CBus *bus; |
122 | + bool cfg_nonsec[TZ_NUM_PORTS]; | ||
123 | + bool cfg_ap[TZ_NUM_PORTS]; | ||
124 | + bool cfg_sec_resp; | ||
125 | + bool irq_enable; | ||
126 | + bool irq_clear; | ||
127 | + /* State: are we asserting irq ? */ | ||
128 | + bool irq_status; | ||
129 | + | ||
130 | + qemu_irq irq; | 152 | + qemu_irq irq; |
131 | + | 153 | + |
132 | + /* Properties */ | 154 | + uint8_t addr; |
133 | + uint32_t nonsec_mask; | 155 | + uint8_t xaddr; |
134 | + | 156 | + uint8_t data; |
135 | + TZPPCPort port[TZ_NUM_PORTS]; | 157 | + uint8_t cntr; |
158 | + uint8_t stat; | ||
159 | + uint8_t ccr; | ||
160 | + uint8_t srst; | ||
161 | + uint8_t efr; | ||
162 | + uint8_t lcr; | ||
136 | +}; | 163 | +}; |
137 | + | 164 | + |
138 | +#endif | 165 | +#endif /* ALLWINNER_I2C_H */ |
139 | diff --git a/hw/misc/tz-ppc.c b/hw/misc/tz-ppc.c | 166 | diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c |
167 | index XXXXXXX..XXXXXXX 100644 | ||
168 | --- a/hw/arm/allwinner-a10.c | ||
169 | +++ b/hw/arm/allwinner-a10.c | ||
170 | @@ -XXX,XX +XXX,XX @@ | ||
171 | #define AW_A10_OHCI_BASE 0x01c14400 | ||
172 | #define AW_A10_SATA_BASE 0x01c18000 | ||
173 | #define AW_A10_RTC_BASE 0x01c20d00 | ||
174 | +#define AW_A10_I2C0_BASE 0x01c2ac00 | ||
175 | |||
176 | static void aw_a10_init(Object *obj) | ||
177 | { | ||
178 | @@ -XXX,XX +XXX,XX @@ static void aw_a10_init(Object *obj) | ||
179 | |||
180 | object_initialize_child(obj, "sata", &s->sata, TYPE_ALLWINNER_AHCI); | ||
181 | |||
182 | + object_initialize_child(obj, "i2c0", &s->i2c0, TYPE_AW_I2C); | ||
183 | + | ||
184 | if (machine_usb(current_machine)) { | ||
185 | int i; | ||
186 | |||
187 | @@ -XXX,XX +XXX,XX @@ static void aw_a10_realize(DeviceState *dev, Error **errp) | ||
188 | /* RTC */ | ||
189 | sysbus_realize(SYS_BUS_DEVICE(&s->rtc), &error_fatal); | ||
190 | sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->rtc), 0, AW_A10_RTC_BASE, 10); | ||
191 | + | ||
192 | + /* I2C */ | ||
193 | + sysbus_realize(SYS_BUS_DEVICE(&s->i2c0), &error_fatal); | ||
194 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c0), 0, AW_A10_I2C0_BASE); | ||
195 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c0), 0, qdev_get_gpio_in(dev, 7)); | ||
196 | } | ||
197 | |||
198 | static void aw_a10_class_init(ObjectClass *oc, void *data) | ||
199 | diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c | ||
200 | index XXXXXXX..XXXXXXX 100644 | ||
201 | --- a/hw/arm/allwinner-h3.c | ||
202 | +++ b/hw/arm/allwinner-h3.c | ||
203 | @@ -XXX,XX +XXX,XX @@ const hwaddr allwinner_h3_memmap[] = { | ||
204 | [AW_H3_DEV_UART1] = 0x01c28400, | ||
205 | [AW_H3_DEV_UART2] = 0x01c28800, | ||
206 | [AW_H3_DEV_UART3] = 0x01c28c00, | ||
207 | + [AW_H3_DEV_TWI0] = 0x01c2ac00, | ||
208 | [AW_H3_DEV_EMAC] = 0x01c30000, | ||
209 | [AW_H3_DEV_DRAMCOM] = 0x01c62000, | ||
210 | [AW_H3_DEV_DRAMCTL] = 0x01c63000, | ||
211 | @@ -XXX,XX +XXX,XX @@ struct AwH3Unimplemented { | ||
212 | { "uart1", 0x01c28400, 1 * KiB }, | ||
213 | { "uart2", 0x01c28800, 1 * KiB }, | ||
214 | { "uart3", 0x01c28c00, 1 * KiB }, | ||
215 | - { "twi0", 0x01c2ac00, 1 * KiB }, | ||
216 | { "twi1", 0x01c2b000, 1 * KiB }, | ||
217 | { "twi2", 0x01c2b400, 1 * KiB }, | ||
218 | { "scr", 0x01c2c400, 1 * KiB }, | ||
219 | @@ -XXX,XX +XXX,XX @@ enum { | ||
220 | AW_H3_GIC_SPI_UART1 = 1, | ||
221 | AW_H3_GIC_SPI_UART2 = 2, | ||
222 | AW_H3_GIC_SPI_UART3 = 3, | ||
223 | + AW_H3_GIC_SPI_TWI0 = 6, | ||
224 | AW_H3_GIC_SPI_TIMER0 = 18, | ||
225 | AW_H3_GIC_SPI_TIMER1 = 19, | ||
226 | AW_H3_GIC_SPI_MMC0 = 60, | ||
227 | @@ -XXX,XX +XXX,XX @@ static void allwinner_h3_init(Object *obj) | ||
228 | "ram-size"); | ||
229 | |||
230 | object_initialize_child(obj, "rtc", &s->rtc, TYPE_AW_RTC_SUN6I); | ||
231 | + | ||
232 | + object_initialize_child(obj, "twi0", &s->i2c0, TYPE_AW_I2C); | ||
233 | } | ||
234 | |||
235 | static void allwinner_h3_realize(DeviceState *dev, Error **errp) | ||
236 | @@ -XXX,XX +XXX,XX @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp) | ||
237 | sysbus_realize(SYS_BUS_DEVICE(&s->rtc), &error_fatal); | ||
238 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->rtc), 0, s->memmap[AW_H3_DEV_RTC]); | ||
239 | |||
240 | + /* I2C */ | ||
241 | + sysbus_realize(SYS_BUS_DEVICE(&s->i2c0), &error_fatal); | ||
242 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c0), 0, s->memmap[AW_H3_DEV_TWI0]); | ||
243 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c0), 0, | ||
244 | + qdev_get_gpio_in(DEVICE(&s->gic), AW_H3_GIC_SPI_TWI0)); | ||
245 | + | ||
246 | /* Unimplemented devices */ | ||
247 | for (i = 0; i < ARRAY_SIZE(unimplemented); i++) { | ||
248 | create_unimplemented_device(unimplemented[i].device_name, | ||
249 | diff --git a/hw/i2c/allwinner-i2c.c b/hw/i2c/allwinner-i2c.c | ||
140 | new file mode 100644 | 250 | new file mode 100644 |
141 | index XXXXXXX..XXXXXXX | 251 | index XXXXXXX..XXXXXXX |
142 | --- /dev/null | 252 | --- /dev/null |
143 | +++ b/hw/misc/tz-ppc.c | 253 | +++ b/hw/i2c/allwinner-i2c.c |
144 | @@ -XXX,XX +XXX,XX @@ | 254 | @@ -XXX,XX +XXX,XX @@ |
145 | +/* | 255 | +/* |
146 | + * ARM TrustZone peripheral protection controller emulation | 256 | + * Allwinner I2C Bus Serial Interface Emulation |
147 | + * | 257 | + * |
148 | + * Copyright (c) 2018 Linaro Limited | 258 | + * Copyright (C) 2022 Strahinja Jankovic <strahinja.p.jankovic@gmail.com> |
149 | + * Written by Peter Maydell | 259 | + * |
150 | + * | 260 | + * This file is derived from IMX I2C controller, |
151 | + * This program is free software; you can redistribute it and/or modify | 261 | + * by Jean-Christophe DUBOIS . |
152 | + * it under the terms of the GNU General Public License version 2 or | 262 | + * |
153 | + * (at your option) any later version. | 263 | + * This program is free software; you can redistribute it and/or modify it |
264 | + * under the terms of the GNU General Public License as published by the | ||
265 | + * Free Software Foundation; either version 2 of the License, or | ||
266 | + * (at your option) any later version. | ||
267 | + * | ||
268 | + * This program is distributed in the hope that it will be useful, but WITHOUT | ||
269 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
270 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
271 | + * for more details. | ||
272 | + * | ||
273 | + * You should have received a copy of the GNU General Public License along | ||
274 | + * with this program; if not, see <http://www.gnu.org/licenses/>. | ||
275 | + * | ||
276 | + * SPDX-License-Identifier: MIT | ||
154 | + */ | 277 | + */ |
155 | + | 278 | + |
156 | +#include "qemu/osdep.h" | 279 | +#include "qemu/osdep.h" |
280 | +#include "hw/i2c/allwinner-i2c.h" | ||
281 | +#include "hw/irq.h" | ||
282 | +#include "migration/vmstate.h" | ||
283 | +#include "hw/i2c/i2c.h" | ||
157 | +#include "qemu/log.h" | 284 | +#include "qemu/log.h" |
158 | +#include "qapi/error.h" | ||
159 | +#include "trace.h" | 285 | +#include "trace.h" |
160 | +#include "hw/sysbus.h" | 286 | +#include "qemu/module.h" |
161 | +#include "hw/registerfields.h" | 287 | + |
162 | +#include "hw/misc/tz-ppc.h" | 288 | +/* Allwinner I2C memory map */ |
163 | + | 289 | +#define TWI_ADDR_REG 0x00 /* slave address register */ |
164 | +static void tz_ppc_update_irq(TZPPC *s) | 290 | +#define TWI_XADDR_REG 0x04 /* extended slave address register */ |
165 | +{ | 291 | +#define TWI_DATA_REG 0x08 /* data register */ |
166 | + bool level = s->irq_status && s->irq_enable; | 292 | +#define TWI_CNTR_REG 0x0c /* control register */ |
167 | + | 293 | +#define TWI_STAT_REG 0x10 /* status register */ |
168 | + trace_tz_ppc_update_irq(level); | 294 | +#define TWI_CCR_REG 0x14 /* clock control register */ |
169 | + qemu_set_irq(s->irq, level); | 295 | +#define TWI_SRST_REG 0x18 /* software reset register */ |
170 | +} | 296 | +#define TWI_EFR_REG 0x1c /* enhance feature register */ |
171 | + | 297 | +#define TWI_LCR_REG 0x20 /* line control register */ |
172 | +static void tz_ppc_cfg_nonsec(void *opaque, int n, int level) | 298 | + |
173 | +{ | 299 | +/* Used only in slave mode, do not set */ |
174 | + TZPPC *s = TZ_PPC(opaque); | 300 | +#define TWI_ADDR_RESET 0 |
175 | + | 301 | +#define TWI_XADDR_RESET 0 |
176 | + assert(n < TZ_NUM_PORTS); | 302 | + |
177 | + trace_tz_ppc_cfg_nonsec(n, level); | 303 | +/* Data register */ |
178 | + s->cfg_nonsec[n] = level; | 304 | +#define TWI_DATA_MASK 0xFF |
179 | +} | 305 | +#define TWI_DATA_RESET 0 |
180 | + | 306 | + |
181 | +static void tz_ppc_cfg_ap(void *opaque, int n, int level) | 307 | +/* Control register */ |
182 | +{ | 308 | +#define TWI_CNTR_INT_EN (1 << 7) |
183 | + TZPPC *s = TZ_PPC(opaque); | 309 | +#define TWI_CNTR_BUS_EN (1 << 6) |
184 | + | 310 | +#define TWI_CNTR_M_STA (1 << 5) |
185 | + assert(n < TZ_NUM_PORTS); | 311 | +#define TWI_CNTR_M_STP (1 << 4) |
186 | + trace_tz_ppc_cfg_ap(n, level); | 312 | +#define TWI_CNTR_INT_FLAG (1 << 3) |
187 | + s->cfg_ap[n] = level; | 313 | +#define TWI_CNTR_A_ACK (1 << 2) |
188 | +} | 314 | +#define TWI_CNTR_MASK 0xFC |
189 | + | 315 | +#define TWI_CNTR_RESET 0 |
190 | +static void tz_ppc_cfg_sec_resp(void *opaque, int n, int level) | 316 | + |
191 | +{ | 317 | +/* Status register */ |
192 | + TZPPC *s = TZ_PPC(opaque); | 318 | +#define TWI_STAT_MASK 0xF8 |
193 | + | 319 | +#define TWI_STAT_RESET 0xF8 |
194 | + trace_tz_ppc_cfg_sec_resp(level); | 320 | + |
195 | + s->cfg_sec_resp = level; | 321 | +/* Clock register */ |
196 | +} | 322 | +#define TWI_CCR_CLK_M_MASK 0x78 |
197 | + | 323 | +#define TWI_CCR_CLK_N_MASK 0x07 |
198 | +static void tz_ppc_irq_enable(void *opaque, int n, int level) | 324 | +#define TWI_CCR_MASK 0x7F |
199 | +{ | 325 | +#define TWI_CCR_RESET 0 |
200 | + TZPPC *s = TZ_PPC(opaque); | 326 | + |
201 | + | 327 | +/* Soft reset */ |
202 | + trace_tz_ppc_irq_enable(level); | 328 | +#define TWI_SRST_MASK 0x01 |
203 | + s->irq_enable = level; | 329 | +#define TWI_SRST_RESET 0 |
204 | + tz_ppc_update_irq(s); | 330 | + |
205 | +} | 331 | +/* Enhance feature */ |
206 | + | 332 | +#define TWI_EFR_MASK 0x03 |
207 | +static void tz_ppc_irq_clear(void *opaque, int n, int level) | 333 | +#define TWI_EFR_RESET 0 |
208 | +{ | 334 | + |
209 | + TZPPC *s = TZ_PPC(opaque); | 335 | +/* Line control */ |
210 | + | 336 | +#define TWI_LCR_SCL_STATE (1 << 5) |
211 | + trace_tz_ppc_irq_clear(level); | 337 | +#define TWI_LCR_SDA_STATE (1 << 4) |
212 | + | 338 | +#define TWI_LCR_SCL_CTL (1 << 3) |
213 | + s->irq_clear = level; | 339 | +#define TWI_LCR_SCL_CTL_EN (1 << 2) |
214 | + if (level) { | 340 | +#define TWI_LCR_SDA_CTL (1 << 1) |
215 | + s->irq_status = false; | 341 | +#define TWI_LCR_SDA_CTL_EN (1 << 0) |
216 | + tz_ppc_update_irq(s); | 342 | +#define TWI_LCR_MASK 0x3F |
343 | +#define TWI_LCR_RESET 0x3A | ||
344 | + | ||
345 | +/* Status value in STAT register is shifted by 3 bits */ | ||
346 | +#define TWI_STAT_SHIFT 3 | ||
347 | +#define STAT_FROM_STA(x) ((x) << TWI_STAT_SHIFT) | ||
348 | +#define STAT_TO_STA(x) ((x) >> TWI_STAT_SHIFT) | ||
349 | + | ||
350 | +enum { | ||
351 | + STAT_BUS_ERROR = 0, | ||
352 | + /* Master mode */ | ||
353 | + STAT_M_STA_TX, | ||
354 | + STAT_M_RSTA_TX, | ||
355 | + STAT_M_ADDR_WR_ACK, | ||
356 | + STAT_M_ADDR_WR_NACK, | ||
357 | + STAT_M_DATA_TX_ACK, | ||
358 | + STAT_M_DATA_TX_NACK, | ||
359 | + STAT_M_ARB_LOST, | ||
360 | + STAT_M_ADDR_RD_ACK, | ||
361 | + STAT_M_ADDR_RD_NACK, | ||
362 | + STAT_M_DATA_RX_ACK, | ||
363 | + STAT_M_DATA_RX_NACK, | ||
364 | + /* Slave mode */ | ||
365 | + STAT_S_ADDR_WR_ACK, | ||
366 | + STAT_S_ARB_LOST_AW_ACK, | ||
367 | + STAT_S_GCA_ACK, | ||
368 | + STAT_S_ARB_LOST_GCA_ACK, | ||
369 | + STAT_S_DATA_RX_SA_ACK, | ||
370 | + STAT_S_DATA_RX_SA_NACK, | ||
371 | + STAT_S_DATA_RX_GCA_ACK, | ||
372 | + STAT_S_DATA_RX_GCA_NACK, | ||
373 | + STAT_S_STP_RSTA, | ||
374 | + STAT_S_ADDR_RD_ACK, | ||
375 | + STAT_S_ARB_LOST_AR_ACK, | ||
376 | + STAT_S_DATA_TX_ACK, | ||
377 | + STAT_S_DATA_TX_NACK, | ||
378 | + STAT_S_LB_TX_ACK, | ||
379 | + /* Master mode, 10-bit */ | ||
380 | + STAT_M_2ND_ADDR_WR_ACK, | ||
381 | + STAT_M_2ND_ADDR_WR_NACK, | ||
382 | + /* Idle */ | ||
383 | + STAT_IDLE = 0x1f | ||
384 | +} TWI_STAT_STA; | ||
385 | + | ||
386 | +static const char *allwinner_i2c_get_regname(unsigned offset) | ||
387 | +{ | ||
388 | + switch (offset) { | ||
389 | + case TWI_ADDR_REG: | ||
390 | + return "ADDR"; | ||
391 | + case TWI_XADDR_REG: | ||
392 | + return "XADDR"; | ||
393 | + case TWI_DATA_REG: | ||
394 | + return "DATA"; | ||
395 | + case TWI_CNTR_REG: | ||
396 | + return "CNTR"; | ||
397 | + case TWI_STAT_REG: | ||
398 | + return "STAT"; | ||
399 | + case TWI_CCR_REG: | ||
400 | + return "CCR"; | ||
401 | + case TWI_SRST_REG: | ||
402 | + return "SRST"; | ||
403 | + case TWI_EFR_REG: | ||
404 | + return "EFR"; | ||
405 | + case TWI_LCR_REG: | ||
406 | + return "LCR"; | ||
407 | + default: | ||
408 | + return "[?]"; | ||
217 | + } | 409 | + } |
218 | +} | 410 | +} |
219 | + | 411 | + |
220 | +static bool tz_ppc_check(TZPPC *s, int n, MemTxAttrs attrs) | 412 | +static inline bool allwinner_i2c_is_reset(AWI2CState *s) |
221 | +{ | 413 | +{ |
222 | + /* Check whether to allow an access to port n; return true if | 414 | + return s->srst & TWI_SRST_MASK; |
223 | + * the check passes, and false if the transaction must be blocked. | 415 | +} |
224 | + * If the latter, the caller must check cfg_sec_resp to determine | 416 | + |
225 | + * whether to abort or RAZ/WI the transaction. | 417 | +static inline bool allwinner_i2c_bus_is_enabled(AWI2CState *s) |
226 | + * The checks are: | 418 | +{ |
227 | + * + nonsec_mask suppresses any check of the secure attribute | 419 | + return s->cntr & TWI_CNTR_BUS_EN; |
228 | + * + otherwise, block if cfg_nonsec is 1 and transaction is secure, | 420 | +} |
229 | + * or if cfg_nonsec is 0 and transaction is non-secure | 421 | + |
230 | + * + block if transaction is usermode and cfg_ap is 0 | 422 | +static inline bool allwinner_i2c_interrupt_is_enabled(AWI2CState *s) |
423 | +{ | ||
424 | + return s->cntr & TWI_CNTR_INT_EN; | ||
425 | +} | ||
426 | + | ||
427 | +static void allwinner_i2c_reset_hold(Object *obj) | ||
428 | +{ | ||
429 | + AWI2CState *s = AW_I2C(obj); | ||
430 | + | ||
431 | + if (STAT_TO_STA(s->stat) != STAT_IDLE) { | ||
432 | + i2c_end_transfer(s->bus); | ||
433 | + } | ||
434 | + | ||
435 | + s->addr = TWI_ADDR_RESET; | ||
436 | + s->xaddr = TWI_XADDR_RESET; | ||
437 | + s->data = TWI_DATA_RESET; | ||
438 | + s->cntr = TWI_CNTR_RESET; | ||
439 | + s->stat = TWI_STAT_RESET; | ||
440 | + s->ccr = TWI_CCR_RESET; | ||
441 | + s->srst = TWI_SRST_RESET; | ||
442 | + s->efr = TWI_EFR_RESET; | ||
443 | + s->lcr = TWI_LCR_RESET; | ||
444 | +} | ||
445 | + | ||
446 | +static inline void allwinner_i2c_raise_interrupt(AWI2CState *s) | ||
447 | +{ | ||
448 | + /* | ||
449 | + * Raise an interrupt if the device is not reset and it is configured | ||
450 | + * to generate some interrupts. | ||
231 | + */ | 451 | + */ |
232 | + if ((attrs.secure == s->cfg_nonsec[n] && !(s->nonsec_mask & (1 << n))) || | 452 | + if (!allwinner_i2c_is_reset(s) && allwinner_i2c_bus_is_enabled(s)) { |
233 | + (attrs.user && !s->cfg_ap[n])) { | 453 | + if (STAT_TO_STA(s->stat) != STAT_IDLE) { |
234 | + /* Block the transaction. */ | 454 | + s->cntr |= TWI_CNTR_INT_FLAG; |
235 | + if (!s->irq_clear) { | 455 | + if (allwinner_i2c_interrupt_is_enabled(s)) { |
236 | + /* Note that holding irq_clear high suppresses interrupts */ | 456 | + qemu_irq_raise(s->irq); |
237 | + s->irq_status = true; | 457 | + } |
238 | + tz_ppc_update_irq(s); | ||
239 | + } | ||
240 | + return false; | ||
241 | + } | ||
242 | + return true; | ||
243 | +} | ||
244 | + | ||
245 | +static MemTxResult tz_ppc_read(void *opaque, hwaddr addr, uint64_t *pdata, | ||
246 | + unsigned size, MemTxAttrs attrs) | ||
247 | +{ | ||
248 | + TZPPCPort *p = opaque; | ||
249 | + TZPPC *s = p->ppc; | ||
250 | + int n = p - s->port; | ||
251 | + AddressSpace *as = &p->downstream_as; | ||
252 | + uint64_t data; | ||
253 | + MemTxResult res; | ||
254 | + | ||
255 | + if (!tz_ppc_check(s, n, attrs)) { | ||
256 | + trace_tz_ppc_read_blocked(n, addr, attrs.secure, attrs.user); | ||
257 | + if (s->cfg_sec_resp) { | ||
258 | + return MEMTX_ERROR; | ||
259 | + } else { | ||
260 | + *pdata = 0; | ||
261 | + return MEMTX_OK; | ||
262 | + } | 458 | + } |
263 | + } | 459 | + } |
264 | + | 460 | +} |
265 | + switch (size) { | 461 | + |
266 | + case 1: | 462 | +static uint64_t allwinner_i2c_read(void *opaque, hwaddr offset, |
267 | + data = address_space_ldub(as, addr, attrs, &res); | 463 | + unsigned size) |
268 | + break; | 464 | +{ |
269 | + case 2: | 465 | + uint16_t value; |
270 | + data = address_space_lduw_le(as, addr, attrs, &res); | 466 | + AWI2CState *s = AW_I2C(opaque); |
271 | + break; | 467 | + |
272 | + case 4: | 468 | + switch (offset) { |
273 | + data = address_space_ldl_le(as, addr, attrs, &res); | 469 | + case TWI_ADDR_REG: |
274 | + break; | 470 | + value = s->addr; |
275 | + case 8: | 471 | + break; |
276 | + data = address_space_ldq_le(as, addr, attrs, &res); | 472 | + case TWI_XADDR_REG: |
473 | + value = s->xaddr; | ||
474 | + break; | ||
475 | + case TWI_DATA_REG: | ||
476 | + if ((STAT_TO_STA(s->stat) == STAT_M_ADDR_RD_ACK) || | ||
477 | + (STAT_TO_STA(s->stat) == STAT_M_DATA_RX_ACK) || | ||
478 | + (STAT_TO_STA(s->stat) == STAT_M_DATA_RX_NACK)) { | ||
479 | + /* Get the next byte */ | ||
480 | + s->data = i2c_recv(s->bus); | ||
481 | + | ||
482 | + if (s->cntr & TWI_CNTR_A_ACK) { | ||
483 | + s->stat = STAT_FROM_STA(STAT_M_DATA_RX_ACK); | ||
484 | + } else { | ||
485 | + s->stat = STAT_FROM_STA(STAT_M_DATA_RX_NACK); | ||
486 | + } | ||
487 | + allwinner_i2c_raise_interrupt(s); | ||
488 | + } | ||
489 | + value = s->data; | ||
490 | + break; | ||
491 | + case TWI_CNTR_REG: | ||
492 | + value = s->cntr; | ||
493 | + break; | ||
494 | + case TWI_STAT_REG: | ||
495 | + value = s->stat; | ||
496 | + /* | ||
497 | + * If polling when reading then change state to indicate data | ||
498 | + * is available | ||
499 | + */ | ||
500 | + if (STAT_TO_STA(s->stat) == STAT_M_ADDR_RD_ACK) { | ||
501 | + if (s->cntr & TWI_CNTR_A_ACK) { | ||
502 | + s->stat = STAT_FROM_STA(STAT_M_DATA_RX_ACK); | ||
503 | + } else { | ||
504 | + s->stat = STAT_FROM_STA(STAT_M_DATA_RX_NACK); | ||
505 | + } | ||
506 | + allwinner_i2c_raise_interrupt(s); | ||
507 | + } | ||
508 | + break; | ||
509 | + case TWI_CCR_REG: | ||
510 | + value = s->ccr; | ||
511 | + break; | ||
512 | + case TWI_SRST_REG: | ||
513 | + value = s->srst; | ||
514 | + break; | ||
515 | + case TWI_EFR_REG: | ||
516 | + value = s->efr; | ||
517 | + break; | ||
518 | + case TWI_LCR_REG: | ||
519 | + value = s->lcr; | ||
277 | + break; | 520 | + break; |
278 | + default: | 521 | + default: |
279 | + g_assert_not_reached(); | 522 | + qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad address at offset 0x%" |
523 | + HWADDR_PRIx "\n", TYPE_AW_I2C, __func__, offset); | ||
524 | + value = 0; | ||
525 | + break; | ||
280 | + } | 526 | + } |
281 | + *pdata = data; | 527 | + |
282 | + return res; | 528 | + trace_allwinner_i2c_read(allwinner_i2c_get_regname(offset), offset, value); |
283 | +} | 529 | + |
284 | + | 530 | + return (uint64_t)value; |
285 | +static MemTxResult tz_ppc_write(void *opaque, hwaddr addr, uint64_t val, | 531 | +} |
286 | + unsigned size, MemTxAttrs attrs) | 532 | + |
287 | +{ | 533 | +static void allwinner_i2c_write(void *opaque, hwaddr offset, |
288 | + TZPPCPort *p = opaque; | 534 | + uint64_t value, unsigned size) |
289 | + TZPPC *s = p->ppc; | 535 | +{ |
290 | + AddressSpace *as = &p->downstream_as; | 536 | + AWI2CState *s = AW_I2C(opaque); |
291 | + int n = p - s->port; | 537 | + |
292 | + MemTxResult res; | 538 | + value &= 0xff; |
293 | + | 539 | + |
294 | + if (!tz_ppc_check(s, n, attrs)) { | 540 | + trace_allwinner_i2c_write(allwinner_i2c_get_regname(offset), offset, value); |
295 | + trace_tz_ppc_write_blocked(n, addr, attrs.secure, attrs.user); | 541 | + |
296 | + if (s->cfg_sec_resp) { | 542 | + switch (offset) { |
297 | + return MEMTX_ERROR; | 543 | + case TWI_ADDR_REG: |
298 | + } else { | 544 | + s->addr = (uint8_t)value; |
299 | + return MEMTX_OK; | 545 | + break; |
546 | + case TWI_XADDR_REG: | ||
547 | + s->xaddr = (uint8_t)value; | ||
548 | + break; | ||
549 | + case TWI_DATA_REG: | ||
550 | + /* If the device is in reset or not enabled, nothing to do */ | ||
551 | + if (allwinner_i2c_is_reset(s) || (!allwinner_i2c_bus_is_enabled(s))) { | ||
552 | + break; | ||
300 | + } | 553 | + } |
554 | + | ||
555 | + s->data = value & TWI_DATA_MASK; | ||
556 | + | ||
557 | + switch (STAT_TO_STA(s->stat)) { | ||
558 | + case STAT_M_STA_TX: | ||
559 | + case STAT_M_RSTA_TX: | ||
560 | + /* Send address */ | ||
561 | + if (i2c_start_transfer(s->bus, extract32(s->data, 1, 7), | ||
562 | + extract32(s->data, 0, 1))) { | ||
563 | + /* If non zero is returned, the address is not valid */ | ||
564 | + s->stat = STAT_FROM_STA(STAT_M_ADDR_WR_NACK); | ||
565 | + } else { | ||
566 | + /* Determine if read of write */ | ||
567 | + if (extract32(s->data, 0, 1)) { | ||
568 | + s->stat = STAT_FROM_STA(STAT_M_ADDR_RD_ACK); | ||
569 | + } else { | ||
570 | + s->stat = STAT_FROM_STA(STAT_M_ADDR_WR_ACK); | ||
571 | + } | ||
572 | + allwinner_i2c_raise_interrupt(s); | ||
573 | + } | ||
574 | + break; | ||
575 | + case STAT_M_ADDR_WR_ACK: | ||
576 | + case STAT_M_DATA_TX_ACK: | ||
577 | + if (i2c_send(s->bus, s->data)) { | ||
578 | + /* If the target return non zero then end the transfer */ | ||
579 | + s->stat = STAT_FROM_STA(STAT_M_DATA_TX_NACK); | ||
580 | + i2c_end_transfer(s->bus); | ||
581 | + } else { | ||
582 | + s->stat = STAT_FROM_STA(STAT_M_DATA_TX_ACK); | ||
583 | + allwinner_i2c_raise_interrupt(s); | ||
584 | + } | ||
585 | + break; | ||
586 | + default: | ||
587 | + break; | ||
588 | + } | ||
589 | + break; | ||
590 | + case TWI_CNTR_REG: | ||
591 | + if (!allwinner_i2c_is_reset(s)) { | ||
592 | + /* Do something only if not in software reset */ | ||
593 | + s->cntr = value & TWI_CNTR_MASK; | ||
594 | + | ||
595 | + /* Check if start condition should be sent */ | ||
596 | + if (s->cntr & TWI_CNTR_M_STA) { | ||
597 | + /* Update status */ | ||
598 | + if (STAT_TO_STA(s->stat) == STAT_IDLE) { | ||
599 | + /* Send start condition */ | ||
600 | + s->stat = STAT_FROM_STA(STAT_M_STA_TX); | ||
601 | + } else { | ||
602 | + /* Send repeated start condition */ | ||
603 | + s->stat = STAT_FROM_STA(STAT_M_RSTA_TX); | ||
604 | + } | ||
605 | + /* Clear start condition */ | ||
606 | + s->cntr &= ~TWI_CNTR_M_STA; | ||
607 | + } | ||
608 | + if (s->cntr & TWI_CNTR_M_STP) { | ||
609 | + /* Update status */ | ||
610 | + i2c_end_transfer(s->bus); | ||
611 | + s->stat = STAT_FROM_STA(STAT_IDLE); | ||
612 | + s->cntr &= ~TWI_CNTR_M_STP; | ||
613 | + } | ||
614 | + if ((s->cntr & TWI_CNTR_INT_FLAG) == 0) { | ||
615 | + /* Interrupt flag cleared */ | ||
616 | + qemu_irq_lower(s->irq); | ||
617 | + } | ||
618 | + if ((s->cntr & TWI_CNTR_A_ACK) == 0) { | ||
619 | + if (STAT_TO_STA(s->stat) == STAT_M_DATA_RX_ACK) { | ||
620 | + s->stat = STAT_FROM_STA(STAT_M_DATA_RX_NACK); | ||
621 | + } | ||
622 | + } else { | ||
623 | + if (STAT_TO_STA(s->stat) == STAT_M_DATA_RX_NACK) { | ||
624 | + s->stat = STAT_FROM_STA(STAT_M_DATA_RX_ACK); | ||
625 | + } | ||
626 | + } | ||
627 | + allwinner_i2c_raise_interrupt(s); | ||
628 | + | ||
629 | + } | ||
630 | + break; | ||
631 | + case TWI_CCR_REG: | ||
632 | + s->ccr = value & TWI_CCR_MASK; | ||
633 | + break; | ||
634 | + case TWI_SRST_REG: | ||
635 | + if (((value & TWI_SRST_MASK) == 0) && (s->srst & TWI_SRST_MASK)) { | ||
636 | + /* Perform reset */ | ||
637 | + allwinner_i2c_reset_hold(OBJECT(s)); | ||
638 | + } | ||
639 | + s->srst = value & TWI_SRST_MASK; | ||
640 | + break; | ||
641 | + case TWI_EFR_REG: | ||
642 | + s->efr = value & TWI_EFR_MASK; | ||
643 | + break; | ||
644 | + case TWI_LCR_REG: | ||
645 | + s->lcr = value & TWI_LCR_MASK; | ||
646 | + break; | ||
647 | + default: | ||
648 | + qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad address at offset 0x%" | ||
649 | + HWADDR_PRIx "\n", TYPE_AW_I2C, __func__, offset); | ||
650 | + break; | ||
301 | + } | 651 | + } |
302 | + | 652 | +} |
303 | + switch (size) { | 653 | + |
304 | + case 1: | 654 | +static const MemoryRegionOps allwinner_i2c_ops = { |
305 | + address_space_stb(as, addr, val, attrs, &res); | 655 | + .read = allwinner_i2c_read, |
306 | + break; | 656 | + .write = allwinner_i2c_write, |
307 | + case 2: | 657 | + .valid.min_access_size = 1, |
308 | + address_space_stw_le(as, addr, val, attrs, &res); | 658 | + .valid.max_access_size = 4, |
309 | + break; | 659 | + .endianness = DEVICE_NATIVE_ENDIAN, |
310 | + case 4: | ||
311 | + address_space_stl_le(as, addr, val, attrs, &res); | ||
312 | + break; | ||
313 | + case 8: | ||
314 | + address_space_stq_le(as, addr, val, attrs, &res); | ||
315 | + break; | ||
316 | + default: | ||
317 | + g_assert_not_reached(); | ||
318 | + } | ||
319 | + return res; | ||
320 | +} | ||
321 | + | ||
322 | +static const MemoryRegionOps tz_ppc_ops = { | ||
323 | + .read_with_attrs = tz_ppc_read, | ||
324 | + .write_with_attrs = tz_ppc_write, | ||
325 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
326 | +}; | 660 | +}; |
327 | + | 661 | + |
328 | +static void tz_ppc_reset(DeviceState *dev) | 662 | +static const VMStateDescription allwinner_i2c_vmstate = { |
329 | +{ | 663 | + .name = TYPE_AW_I2C, |
330 | + TZPPC *s = TZ_PPC(dev); | ||
331 | + | ||
332 | + trace_tz_ppc_reset(); | ||
333 | + s->cfg_sec_resp = false; | ||
334 | + memset(s->cfg_nonsec, 0, sizeof(s->cfg_nonsec)); | ||
335 | + memset(s->cfg_ap, 0, sizeof(s->cfg_ap)); | ||
336 | +} | ||
337 | + | ||
338 | +static void tz_ppc_init(Object *obj) | ||
339 | +{ | ||
340 | + DeviceState *dev = DEVICE(obj); | ||
341 | + TZPPC *s = TZ_PPC(obj); | ||
342 | + | ||
343 | + qdev_init_gpio_in_named(dev, tz_ppc_cfg_nonsec, "cfg_nonsec", TZ_NUM_PORTS); | ||
344 | + qdev_init_gpio_in_named(dev, tz_ppc_cfg_ap, "cfg_ap", TZ_NUM_PORTS); | ||
345 | + qdev_init_gpio_in_named(dev, tz_ppc_cfg_sec_resp, "cfg_sec_resp", 1); | ||
346 | + qdev_init_gpio_in_named(dev, tz_ppc_irq_enable, "irq_enable", 1); | ||
347 | + qdev_init_gpio_in_named(dev, tz_ppc_irq_clear, "irq_clear", 1); | ||
348 | + qdev_init_gpio_out_named(dev, &s->irq, "irq", 1); | ||
349 | +} | ||
350 | + | ||
351 | +static void tz_ppc_realize(DeviceState *dev, Error **errp) | ||
352 | +{ | ||
353 | + Object *obj = OBJECT(dev); | ||
354 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
355 | + TZPPC *s = TZ_PPC(dev); | ||
356 | + int i; | ||
357 | + | ||
358 | + /* We can't create the upstream end of the port until realize, | ||
359 | + * as we don't know the size of the MR used as the downstream until then. | ||
360 | + */ | ||
361 | + for (i = 0; i < TZ_NUM_PORTS; i++) { | ||
362 | + TZPPCPort *port = &s->port[i]; | ||
363 | + char *name; | ||
364 | + uint64_t size; | ||
365 | + | ||
366 | + if (!port->downstream) { | ||
367 | + continue; | ||
368 | + } | ||
369 | + | ||
370 | + name = g_strdup_printf("tz-ppc-port[%d]", i); | ||
371 | + | ||
372 | + port->ppc = s; | ||
373 | + address_space_init(&port->downstream_as, port->downstream, name); | ||
374 | + | ||
375 | + size = memory_region_size(port->downstream); | ||
376 | + memory_region_init_io(&port->upstream, obj, &tz_ppc_ops, | ||
377 | + port, name, size); | ||
378 | + sysbus_init_mmio(sbd, &port->upstream); | ||
379 | + g_free(name); | ||
380 | + } | ||
381 | +} | ||
382 | + | ||
383 | +static const VMStateDescription tz_ppc_vmstate = { | ||
384 | + .name = "tz-ppc", | ||
385 | + .version_id = 1, | 664 | + .version_id = 1, |
386 | + .minimum_version_id = 1, | 665 | + .minimum_version_id = 1, |
387 | + .fields = (VMStateField[]) { | 666 | + .fields = (VMStateField[]) { |
388 | + VMSTATE_BOOL_ARRAY(cfg_nonsec, TZPPC, 16), | 667 | + VMSTATE_UINT8(addr, AWI2CState), |
389 | + VMSTATE_BOOL_ARRAY(cfg_ap, TZPPC, 16), | 668 | + VMSTATE_UINT8(xaddr, AWI2CState), |
390 | + VMSTATE_BOOL(cfg_sec_resp, TZPPC), | 669 | + VMSTATE_UINT8(data, AWI2CState), |
391 | + VMSTATE_BOOL(irq_enable, TZPPC), | 670 | + VMSTATE_UINT8(cntr, AWI2CState), |
392 | + VMSTATE_BOOL(irq_clear, TZPPC), | 671 | + VMSTATE_UINT8(ccr, AWI2CState), |
393 | + VMSTATE_BOOL(irq_status, TZPPC), | 672 | + VMSTATE_UINT8(srst, AWI2CState), |
673 | + VMSTATE_UINT8(efr, AWI2CState), | ||
674 | + VMSTATE_UINT8(lcr, AWI2CState), | ||
394 | + VMSTATE_END_OF_LIST() | 675 | + VMSTATE_END_OF_LIST() |
395 | + } | 676 | + } |
396 | +}; | 677 | +}; |
397 | + | 678 | + |
398 | +#define DEFINE_PORT(N) \ | 679 | +static void allwinner_i2c_realize(DeviceState *dev, Error **errp) |
399 | + DEFINE_PROP_LINK("port[" #N "]", TZPPC, port[N].downstream, \ | 680 | +{ |
400 | + TYPE_MEMORY_REGION, MemoryRegion *) | 681 | + AWI2CState *s = AW_I2C(dev); |
401 | + | 682 | + |
402 | +static Property tz_ppc_properties[] = { | 683 | + memory_region_init_io(&s->iomem, OBJECT(s), &allwinner_i2c_ops, s, |
403 | + DEFINE_PROP_UINT32("NONSEC_MASK", TZPPC, nonsec_mask, 0), | 684 | + TYPE_AW_I2C, AW_I2C_MEM_SIZE); |
404 | + DEFINE_PORT(0), | 685 | + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem); |
405 | + DEFINE_PORT(1), | 686 | + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq); |
406 | + DEFINE_PORT(2), | 687 | + s->bus = i2c_init_bus(dev, "i2c"); |
407 | + DEFINE_PORT(3), | 688 | +} |
408 | + DEFINE_PORT(4), | 689 | + |
409 | + DEFINE_PORT(5), | 690 | +static void allwinner_i2c_class_init(ObjectClass *klass, void *data) |
410 | + DEFINE_PORT(6), | 691 | +{ |
411 | + DEFINE_PORT(7), | 692 | + DeviceClass *dc = DEVICE_CLASS(klass); |
412 | + DEFINE_PORT(8), | 693 | + ResettableClass *rc = RESETTABLE_CLASS(klass); |
413 | + DEFINE_PORT(9), | 694 | + |
414 | + DEFINE_PORT(10), | 695 | + rc->phases.hold = allwinner_i2c_reset_hold; |
415 | + DEFINE_PORT(11), | 696 | + dc->vmsd = &allwinner_i2c_vmstate; |
416 | + DEFINE_PORT(12), | 697 | + dc->realize = allwinner_i2c_realize; |
417 | + DEFINE_PORT(13), | 698 | + dc->desc = "Allwinner I2C Controller"; |
418 | + DEFINE_PORT(14), | 699 | +} |
419 | + DEFINE_PORT(15), | 700 | + |
420 | + DEFINE_PROP_END_OF_LIST(), | 701 | +static const TypeInfo allwinner_i2c_type_info = { |
702 | + .name = TYPE_AW_I2C, | ||
703 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
704 | + .instance_size = sizeof(AWI2CState), | ||
705 | + .class_init = allwinner_i2c_class_init, | ||
421 | +}; | 706 | +}; |
422 | + | 707 | + |
423 | +static void tz_ppc_class_init(ObjectClass *klass, void *data) | 708 | +static void allwinner_i2c_register_types(void) |
424 | +{ | 709 | +{ |
425 | + DeviceClass *dc = DEVICE_CLASS(klass); | 710 | + type_register_static(&allwinner_i2c_type_info); |
426 | + | 711 | +} |
427 | + dc->realize = tz_ppc_realize; | 712 | + |
428 | + dc->vmsd = &tz_ppc_vmstate; | 713 | +type_init(allwinner_i2c_register_types) |
429 | + dc->reset = tz_ppc_reset; | 714 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig |
430 | + dc->props = tz_ppc_properties; | 715 | index XXXXXXX..XXXXXXX 100644 |
431 | +} | 716 | --- a/hw/arm/Kconfig |
432 | + | 717 | +++ b/hw/arm/Kconfig |
433 | +static const TypeInfo tz_ppc_info = { | 718 | @@ -XXX,XX +XXX,XX @@ config ALLWINNER_A10 |
434 | + .name = TYPE_TZ_PPC, | 719 | select ALLWINNER_A10_CCM |
435 | + .parent = TYPE_SYS_BUS_DEVICE, | 720 | select ALLWINNER_A10_DRAMC |
436 | + .instance_size = sizeof(TZPPC), | 721 | select ALLWINNER_EMAC |
437 | + .instance_init = tz_ppc_init, | 722 | + select ALLWINNER_I2C |
438 | + .class_init = tz_ppc_class_init, | 723 | select SERIAL |
439 | +}; | 724 | select UNIMP |
440 | + | 725 | |
441 | +static void tz_ppc_register_types(void) | 726 | @@ -XXX,XX +XXX,XX @@ config ALLWINNER_H3 |
442 | +{ | 727 | bool |
443 | + type_register_static(&tz_ppc_info); | 728 | select ALLWINNER_A10_PIT |
444 | +} | 729 | select ALLWINNER_SUN8I_EMAC |
445 | + | 730 | + select ALLWINNER_I2C |
446 | +type_init(tz_ppc_register_types); | 731 | select SERIAL |
447 | diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak | 732 | select ARM_TIMER |
448 | index XXXXXXX..XXXXXXX 100644 | 733 | select ARM_GIC |
449 | --- a/default-configs/arm-softmmu.mak | 734 | diff --git a/hw/i2c/Kconfig b/hw/i2c/Kconfig |
450 | +++ b/default-configs/arm-softmmu.mak | 735 | index XXXXXXX..XXXXXXX 100644 |
451 | @@ -XXX,XX +XXX,XX @@ CONFIG_CMSDK_APB_UART=y | 736 | --- a/hw/i2c/Kconfig |
452 | CONFIG_MPS2_FPGAIO=y | 737 | +++ b/hw/i2c/Kconfig |
453 | CONFIG_MPS2_SCC=y | 738 | @@ -XXX,XX +XXX,XX @@ config MPC_I2C |
454 | 739 | bool | |
455 | +CONFIG_TZ_PPC=y | 740 | select I2C |
456 | + | 741 | |
457 | CONFIG_VERSATILE_PCI=y | 742 | +config ALLWINNER_I2C |
458 | CONFIG_VERSATILE_I2C=y | 743 | + bool |
459 | 744 | + select I2C | |
460 | diff --git a/hw/misc/trace-events b/hw/misc/trace-events | 745 | + |
461 | index XXXXXXX..XXXXXXX 100644 | 746 | config PCA954X |
462 | --- a/hw/misc/trace-events | 747 | bool |
463 | +++ b/hw/misc/trace-events | 748 | select I2C |
464 | @@ -XXX,XX +XXX,XX @@ mos6522_get_next_irq_time(uint16_t latch, int64_t d, int64_t delta) "latch=%d co | 749 | diff --git a/hw/i2c/meson.build b/hw/i2c/meson.build |
465 | mos6522_set_sr_int(void) "set sr_int" | 750 | index XXXXXXX..XXXXXXX 100644 |
466 | mos6522_write(uint64_t addr, uint64_t val) "reg=0x%"PRIx64 " val=0x%"PRIx64 | 751 | --- a/hw/i2c/meson.build |
467 | mos6522_read(uint64_t addr, unsigned val) "reg=0x%"PRIx64 " val=0x%x" | 752 | +++ b/hw/i2c/meson.build |
468 | + | 753 | @@ -XXX,XX +XXX,XX @@ i2c_ss.add(when: 'CONFIG_BITBANG_I2C', if_true: files('bitbang_i2c.c')) |
469 | +# hw/misc/tz-ppc.c | 754 | i2c_ss.add(when: 'CONFIG_EXYNOS4', if_true: files('exynos4210_i2c.c')) |
470 | +tz_ppc_reset(void) "TZ PPC: reset" | 755 | i2c_ss.add(when: 'CONFIG_IMX_I2C', if_true: files('imx_i2c.c')) |
471 | +tz_ppc_cfg_nonsec(int n, int level) "TZ PPC: cfg_nonsec[%d] = %d" | 756 | i2c_ss.add(when: 'CONFIG_MPC_I2C', if_true: files('mpc_i2c.c')) |
472 | +tz_ppc_cfg_ap(int n, int level) "TZ PPC: cfg_ap[%d] = %d" | 757 | +i2c_ss.add(when: 'CONFIG_ALLWINNER_I2C', if_true: files('allwinner-i2c.c')) |
473 | +tz_ppc_cfg_sec_resp(int level) "TZ PPC: cfg_sec_resp = %d" | 758 | i2c_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('microbit_i2c.c')) |
474 | +tz_ppc_irq_enable(int level) "TZ PPC: int_enable = %d" | 759 | i2c_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_smbus.c')) |
475 | +tz_ppc_irq_clear(int level) "TZ PPC: int_clear = %d" | 760 | i2c_ss.add(when: 'CONFIG_SMBUS_EEPROM', if_true: files('smbus_eeprom.c')) |
476 | +tz_ppc_update_irq(int level) "TZ PPC: setting irq line to %d" | 761 | diff --git a/hw/i2c/trace-events b/hw/i2c/trace-events |
477 | +tz_ppc_read_blocked(int n, hwaddr offset, bool secure, bool user) "TZ PPC: port %d offset 0x%" HWADDR_PRIx " read (secure %d user %d) blocked" | 762 | index XXXXXXX..XXXXXXX 100644 |
478 | +tz_ppc_write_blocked(int n, hwaddr offset, bool secure, bool user) "TZ PPC: port %d offset 0x%" HWADDR_PRIx " write (secure %d user %d) blocked" | 763 | --- a/hw/i2c/trace-events |
764 | +++ b/hw/i2c/trace-events | ||
765 | @@ -XXX,XX +XXX,XX @@ i2c_send_async(uint8_t address, uint8_t data) "send_async(addr:0x%02x) data:0x%0 | ||
766 | i2c_recv(uint8_t address, uint8_t data) "recv(addr:0x%02x) data:0x%02x" | ||
767 | i2c_ack(void) "" | ||
768 | |||
769 | +# allwinner_i2c.c | ||
770 | + | ||
771 | +allwinner_i2c_read(const char* reg_name, uint64_t offset, uint64_t value) "read %s [0x%" PRIx64 "]: -> 0x%" PRIx64 | ||
772 | +allwinner_i2c_write(const char* reg_name, uint64_t offset, uint64_t value) "write %s [0x%" PRIx64 "]: <- 0x%" PRIx64 | ||
773 | + | ||
774 | # aspeed_i2c.c | ||
775 | |||
776 | aspeed_i2c_bus_cmd(uint32_t cmd, const char *cmd_flags, uint32_t count, uint32_t intr_status) "handling cmd=0x%x %s count=%d intr=0x%x" | ||
479 | -- | 777 | -- |
480 | 2.16.2 | 778 | 2.34.1 |
481 | |||
482 | diff view generated by jsdifflib |
1 | From: Alistair Francis <alistair.francis@xilinx.com> | 1 | From: Strahinja Jankovic <strahinjapjankovic@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | Initial commit of the ZynqMP RTC device. | 3 | This patch adds minimal support for AXP-209 PMU. |
4 | Most important is chip ID since U-Boot SPL expects version 0x1. Besides | ||
5 | the chip ID register, reset values for two more registers used by A10 | ||
6 | U-Boot SPL are covered. | ||
4 | 7 | ||
5 | Signed-off-by: Alistair Francis <alistair.francis@xilinx.com> | 8 | Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com> |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 9 | Message-id: 20221226220303.14420-5-strahinja.p.jankovic@gmail.com |
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 12 | --- |
9 | hw/timer/Makefile.objs | 1 + | 13 | hw/misc/axp209.c | 238 +++++++++++++++++++++++++++++++++++++++++++ |
10 | include/hw/timer/xlnx-zynqmp-rtc.h | 84 +++++++++++++++ | 14 | MAINTAINERS | 2 + |
11 | hw/timer/xlnx-zynqmp-rtc.c | 214 +++++++++++++++++++++++++++++++++++++ | 15 | hw/misc/Kconfig | 4 + |
12 | 3 files changed, 299 insertions(+) | 16 | hw/misc/meson.build | 1 + |
13 | create mode 100644 include/hw/timer/xlnx-zynqmp-rtc.h | 17 | hw/misc/trace-events | 5 + |
14 | create mode 100644 hw/timer/xlnx-zynqmp-rtc.c | 18 | 5 files changed, 250 insertions(+) |
19 | create mode 100644 hw/misc/axp209.c | ||
15 | 20 | ||
16 | diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs | 21 | diff --git a/hw/misc/axp209.c b/hw/misc/axp209.c |
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/hw/timer/Makefile.objs | ||
19 | +++ b/hw/timer/Makefile.objs | ||
20 | @@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_IMX) += imx_epit.o | ||
21 | common-obj-$(CONFIG_IMX) += imx_gpt.o | ||
22 | common-obj-$(CONFIG_LM32) += lm32_timer.o | ||
23 | common-obj-$(CONFIG_MILKYMIST) += milkymist-sysctl.o | ||
24 | +common-obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp-rtc.o | ||
25 | |||
26 | obj-$(CONFIG_ALTERA_TIMER) += altera_timer.o | ||
27 | obj-$(CONFIG_EXYNOS4) += exynos4210_mct.o | ||
28 | diff --git a/include/hw/timer/xlnx-zynqmp-rtc.h b/include/hw/timer/xlnx-zynqmp-rtc.h | ||
29 | new file mode 100644 | 22 | new file mode 100644 |
30 | index XXXXXXX..XXXXXXX | 23 | index XXXXXXX..XXXXXXX |
31 | --- /dev/null | 24 | --- /dev/null |
32 | +++ b/include/hw/timer/xlnx-zynqmp-rtc.h | 25 | +++ b/hw/misc/axp209.c |
33 | @@ -XXX,XX +XXX,XX @@ | 26 | @@ -XXX,XX +XXX,XX @@ |
34 | +/* | 27 | +/* |
35 | + * QEMU model of the Xilinx ZynqMP Real Time Clock (RTC). | 28 | + * AXP-209 PMU Emulation |
36 | + * | 29 | + * |
37 | + * Copyright (c) 2017 Xilinx Inc. | 30 | + * Copyright (C) 2022 Strahinja Jankovic <strahinja.p.jankovic@gmail.com> |
38 | + * | 31 | + * |
39 | + * Written-by: Alistair Francis <alistair.francis@xilinx.com> | 32 | + * Permission is hereby granted, free of charge, to any person obtaining a |
40 | + * | 33 | + * copy of this software and associated documentation files (the "Software"), |
41 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | 34 | + * to deal in the Software without restriction, including without limitation |
42 | + * of this software and associated documentation files (the "Software"), to deal | 35 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
43 | + * in the Software without restriction, including without limitation the rights | 36 | + * and/or sell copies of the Software, and to permit persons to whom the |
44 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 37 | + * Software is furnished to do so, subject to the following conditions: |
45 | + * copies of the Software, and to permit persons to whom the Software is | ||
46 | + * furnished to do so, subject to the following conditions: | ||
47 | + * | 38 | + * |
48 | + * The above copyright notice and this permission notice shall be included in | 39 | + * The above copyright notice and this permission notice shall be included in |
49 | + * all copies or substantial portions of the Software. | 40 | + * all copies or substantial portions of the Software. |
50 | + * | 41 | + * |
51 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 42 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
52 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 43 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
53 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | 44 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
54 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 45 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
55 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 46 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
56 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | 47 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
57 | + * THE SOFTWARE. | 48 | + * DEALINGS IN THE SOFTWARE. |
49 | + * | ||
50 | + * SPDX-License-Identifier: MIT | ||
58 | + */ | 51 | + */ |
59 | + | 52 | + |
60 | +#include "hw/register.h" | 53 | +#include "qemu/osdep.h" |
61 | + | 54 | +#include "qemu/log.h" |
62 | +#define TYPE_XLNX_ZYNQMP_RTC "xlnx-zynmp.rtc" | 55 | +#include "trace.h" |
63 | + | 56 | +#include "hw/i2c/i2c.h" |
64 | +#define XLNX_ZYNQMP_RTC(obj) \ | 57 | +#include "migration/vmstate.h" |
65 | + OBJECT_CHECK(XlnxZynqMPRTC, (obj), TYPE_XLNX_ZYNQMP_RTC) | 58 | + |
66 | + | 59 | +#define TYPE_AXP209_PMU "axp209_pmu" |
67 | +REG32(SET_TIME_WRITE, 0x0) | 60 | + |
68 | +REG32(SET_TIME_READ, 0x4) | 61 | +#define AXP209(obj) \ |
69 | +REG32(CALIB_WRITE, 0x8) | 62 | + OBJECT_CHECK(AXP209I2CState, (obj), TYPE_AXP209_PMU) |
70 | + FIELD(CALIB_WRITE, FRACTION_EN, 20, 1) | 63 | + |
71 | + FIELD(CALIB_WRITE, FRACTION_DATA, 16, 4) | 64 | +/* registers */ |
72 | + FIELD(CALIB_WRITE, MAX_TICK, 0, 16) | 65 | +enum { |
73 | +REG32(CALIB_READ, 0xc) | 66 | + REG_POWER_STATUS = 0x0u, |
74 | + FIELD(CALIB_READ, FRACTION_EN, 20, 1) | 67 | + REG_OPERATING_MODE, |
75 | + FIELD(CALIB_READ, FRACTION_DATA, 16, 4) | 68 | + REG_OTG_VBUS_STATUS, |
76 | + FIELD(CALIB_READ, MAX_TICK, 0, 16) | 69 | + REG_CHIP_VERSION, |
77 | +REG32(CURRENT_TIME, 0x10) | 70 | + REG_DATA_CACHE_0, |
78 | +REG32(CURRENT_TICK, 0x14) | 71 | + REG_DATA_CACHE_1, |
79 | + FIELD(CURRENT_TICK, VALUE, 0, 16) | 72 | + REG_DATA_CACHE_2, |
80 | +REG32(ALARM, 0x18) | 73 | + REG_DATA_CACHE_3, |
81 | +REG32(RTC_INT_STATUS, 0x20) | 74 | + REG_DATA_CACHE_4, |
82 | + FIELD(RTC_INT_STATUS, ALARM, 1, 1) | 75 | + REG_DATA_CACHE_5, |
83 | + FIELD(RTC_INT_STATUS, SECONDS, 0, 1) | 76 | + REG_DATA_CACHE_6, |
84 | +REG32(RTC_INT_MASK, 0x24) | 77 | + REG_DATA_CACHE_7, |
85 | + FIELD(RTC_INT_MASK, ALARM, 1, 1) | 78 | + REG_DATA_CACHE_8, |
86 | + FIELD(RTC_INT_MASK, SECONDS, 0, 1) | 79 | + REG_DATA_CACHE_9, |
87 | +REG32(RTC_INT_EN, 0x28) | 80 | + REG_DATA_CACHE_A, |
88 | + FIELD(RTC_INT_EN, ALARM, 1, 1) | 81 | + REG_DATA_CACHE_B, |
89 | + FIELD(RTC_INT_EN, SECONDS, 0, 1) | 82 | + REG_POWER_OUTPUT_CTRL = 0x12u, |
90 | +REG32(RTC_INT_DIS, 0x2c) | 83 | + REG_DC_DC2_OUT_V_CTRL = 0x23u, |
91 | + FIELD(RTC_INT_DIS, ALARM, 1, 1) | 84 | + REG_DC_DC2_DVS_CTRL = 0x25u, |
92 | + FIELD(RTC_INT_DIS, SECONDS, 0, 1) | 85 | + REG_DC_DC3_OUT_V_CTRL = 0x27u, |
93 | +REG32(ADDR_ERROR, 0x30) | 86 | + REG_LDO2_4_OUT_V_CTRL, |
94 | + FIELD(ADDR_ERROR, STATUS, 0, 1) | 87 | + REG_LDO3_OUT_V_CTRL, |
95 | +REG32(ADDR_ERROR_INT_MASK, 0x34) | 88 | + REG_VBUS_CH_MGMT = 0x30u, |
96 | + FIELD(ADDR_ERROR_INT_MASK, MASK, 0, 1) | 89 | + REG_SHUTDOWN_V_CTRL, |
97 | +REG32(ADDR_ERROR_INT_EN, 0x38) | 90 | + REG_SHUTDOWN_CTRL, |
98 | + FIELD(ADDR_ERROR_INT_EN, MASK, 0, 1) | 91 | + REG_CHARGE_CTRL_1, |
99 | +REG32(ADDR_ERROR_INT_DIS, 0x3c) | 92 | + REG_CHARGE_CTRL_2, |
100 | + FIELD(ADDR_ERROR_INT_DIS, MASK, 0, 1) | 93 | + REG_SPARE_CHARGE_CTRL, |
101 | +REG32(CONTROL, 0x40) | 94 | + REG_PEK_KEY_CTRL, |
102 | + FIELD(CONTROL, BATTERY_DISABLE, 31, 1) | 95 | + REG_DC_DC_FREQ_SET, |
103 | + FIELD(CONTROL, OSC_CNTRL, 24, 4) | 96 | + REG_CHR_TEMP_TH_SET, |
104 | + FIELD(CONTROL, SLVERR_ENABLE, 0, 1) | 97 | + REG_CHR_HIGH_TEMP_TH_CTRL, |
105 | +REG32(SAFETY_CHK, 0x50) | 98 | + REG_IPSOUT_WARN_L1, |
106 | + | 99 | + REG_IPSOUT_WARN_L2, |
107 | +#define XLNX_ZYNQMP_RTC_R_MAX (R_SAFETY_CHK + 1) | 100 | + REG_DISCHR_TEMP_TH_SET, |
108 | + | 101 | + REG_DISCHR_HIGH_TEMP_TH_CTRL, |
109 | +typedef struct XlnxZynqMPRTC { | 102 | + REG_IRQ_BANK_1_CTRL = 0x40u, |
110 | + SysBusDevice parent_obj; | 103 | + REG_IRQ_BANK_2_CTRL, |
111 | + MemoryRegion iomem; | 104 | + REG_IRQ_BANK_3_CTRL, |
112 | + qemu_irq irq_rtc_int; | 105 | + REG_IRQ_BANK_4_CTRL, |
113 | + qemu_irq irq_addr_error_int; | 106 | + REG_IRQ_BANK_5_CTRL, |
114 | + | 107 | + REG_IRQ_BANK_1_STAT = 0x48u, |
115 | + uint32_t regs[XLNX_ZYNQMP_RTC_R_MAX]; | 108 | + REG_IRQ_BANK_2_STAT, |
116 | + RegisterInfo regs_info[XLNX_ZYNQMP_RTC_R_MAX]; | 109 | + REG_IRQ_BANK_3_STAT, |
117 | +} XlnxZynqMPRTC; | 110 | + REG_IRQ_BANK_4_STAT, |
118 | diff --git a/hw/timer/xlnx-zynqmp-rtc.c b/hw/timer/xlnx-zynqmp-rtc.c | 111 | + REG_IRQ_BANK_5_STAT, |
119 | new file mode 100644 | 112 | + REG_ADC_ACIN_V_H = 0x56u, |
120 | index XXXXXXX..XXXXXXX | 113 | + REG_ADC_ACIN_V_L, |
121 | --- /dev/null | 114 | + REG_ADC_ACIN_CURR_H, |
122 | +++ b/hw/timer/xlnx-zynqmp-rtc.c | 115 | + REG_ADC_ACIN_CURR_L, |
123 | @@ -XXX,XX +XXX,XX @@ | 116 | + REG_ADC_VBUS_V_H, |
117 | + REG_ADC_VBUS_V_L, | ||
118 | + REG_ADC_VBUS_CURR_H, | ||
119 | + REG_ADC_VBUS_CURR_L, | ||
120 | + REG_ADC_INT_TEMP_H, | ||
121 | + REG_ADC_INT_TEMP_L, | ||
122 | + REG_ADC_TEMP_SENS_V_H = 0x62u, | ||
123 | + REG_ADC_TEMP_SENS_V_L, | ||
124 | + REG_ADC_BAT_V_H = 0x78u, | ||
125 | + REG_ADC_BAT_V_L, | ||
126 | + REG_ADC_BAT_DISCHR_CURR_H, | ||
127 | + REG_ADC_BAT_DISCHR_CURR_L, | ||
128 | + REG_ADC_BAT_CHR_CURR_H, | ||
129 | + REG_ADC_BAT_CHR_CURR_L, | ||
130 | + REG_ADC_IPSOUT_V_H, | ||
131 | + REG_ADC_IPSOUT_V_L, | ||
132 | + REG_DC_DC_MOD_SEL = 0x80u, | ||
133 | + REG_ADC_EN_1, | ||
134 | + REG_ADC_EN_2, | ||
135 | + REG_ADC_SR_CTRL, | ||
136 | + REG_ADC_IN_RANGE, | ||
137 | + REG_GPIO1_ADC_IRQ_RISING_TH, | ||
138 | + REG_GPIO1_ADC_IRQ_FALLING_TH, | ||
139 | + REG_TIMER_CTRL = 0x8au, | ||
140 | + REG_VBUS_CTRL_MON_SRP, | ||
141 | + REG_OVER_TEMP_SHUTDOWN = 0x8fu, | ||
142 | + REG_GPIO0_FEAT_SET, | ||
143 | + REG_GPIO_OUT_HIGH_SET, | ||
144 | + REG_GPIO1_FEAT_SET, | ||
145 | + REG_GPIO2_FEAT_SET, | ||
146 | + REG_GPIO_SIG_STATE_SET_MON, | ||
147 | + REG_GPIO3_SET, | ||
148 | + REG_COULOMB_CNTR_CTRL = 0xb8u, | ||
149 | + REG_POWER_MEAS_RES, | ||
150 | + NR_REGS | ||
151 | +}; | ||
152 | + | ||
153 | +#define AXP209_CHIP_VERSION_ID (0x01) | ||
154 | +#define AXP209_DC_DC2_OUT_V_CTRL_RESET (0x16) | ||
155 | +#define AXP209_IRQ_BANK_1_CTRL_RESET (0xd8) | ||
156 | + | ||
157 | +/* A simple I2C slave which returns values of ID or CNT register. */ | ||
158 | +typedef struct AXP209I2CState { | ||
159 | + /*< private >*/ | ||
160 | + I2CSlave i2c; | ||
161 | + /*< public >*/ | ||
162 | + uint8_t regs[NR_REGS]; /* peripheral registers */ | ||
163 | + uint8_t ptr; /* current register index */ | ||
164 | + uint8_t count; /* counter used for tx/rx */ | ||
165 | +} AXP209I2CState; | ||
166 | + | ||
167 | +/* Reset all counters and load ID register */ | ||
168 | +static void axp209_reset_enter(Object *obj, ResetType type) | ||
169 | +{ | ||
170 | + AXP209I2CState *s = AXP209(obj); | ||
171 | + | ||
172 | + memset(s->regs, 0, NR_REGS); | ||
173 | + s->ptr = 0; | ||
174 | + s->count = 0; | ||
175 | + s->regs[REG_CHIP_VERSION] = AXP209_CHIP_VERSION_ID; | ||
176 | + s->regs[REG_DC_DC2_OUT_V_CTRL] = AXP209_DC_DC2_OUT_V_CTRL_RESET; | ||
177 | + s->regs[REG_IRQ_BANK_1_CTRL] = AXP209_IRQ_BANK_1_CTRL_RESET; | ||
178 | +} | ||
179 | + | ||
180 | +/* Handle events from master. */ | ||
181 | +static int axp209_event(I2CSlave *i2c, enum i2c_event event) | ||
182 | +{ | ||
183 | + AXP209I2CState *s = AXP209(i2c); | ||
184 | + | ||
185 | + s->count = 0; | ||
186 | + | ||
187 | + return 0; | ||
188 | +} | ||
189 | + | ||
190 | +/* Called when master requests read */ | ||
191 | +static uint8_t axp209_rx(I2CSlave *i2c) | ||
192 | +{ | ||
193 | + AXP209I2CState *s = AXP209(i2c); | ||
194 | + uint8_t ret = 0xff; | ||
195 | + | ||
196 | + if (s->ptr < NR_REGS) { | ||
197 | + ret = s->regs[s->ptr++]; | ||
198 | + } | ||
199 | + | ||
200 | + trace_axp209_rx(s->ptr - 1, ret); | ||
201 | + | ||
202 | + return ret; | ||
203 | +} | ||
204 | + | ||
124 | +/* | 205 | +/* |
125 | + * QEMU model of the Xilinx ZynqMP Real Time Clock (RTC). | 206 | + * Called when master sends write. |
126 | + * | 207 | + * Update ptr with byte 0, then perform write with second byte. |
127 | + * Copyright (c) 2017 Xilinx Inc. | ||
128 | + * | ||
129 | + * Written-by: Alistair Francis <alistair.francis@xilinx.com> | ||
130 | + * | ||
131 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
132 | + * of this software and associated documentation files (the "Software"), to deal | ||
133 | + * in the Software without restriction, including without limitation the rights | ||
134 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
135 | + * copies of the Software, and to permit persons to whom the Software is | ||
136 | + * furnished to do so, subject to the following conditions: | ||
137 | + * | ||
138 | + * The above copyright notice and this permission notice shall be included in | ||
139 | + * all copies or substantial portions of the Software. | ||
140 | + * | ||
141 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
142 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
143 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
144 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
145 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
146 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
147 | + * THE SOFTWARE. | ||
148 | + */ | 208 | + */ |
149 | + | 209 | +static int axp209_tx(I2CSlave *i2c, uint8_t data) |
150 | +#include "qemu/osdep.h" | 210 | +{ |
151 | +#include "hw/sysbus.h" | 211 | + AXP209I2CState *s = AXP209(i2c); |
152 | +#include "hw/register.h" | 212 | + |
153 | +#include "qemu/bitops.h" | 213 | + if (s->count == 0) { |
154 | +#include "qemu/log.h" | 214 | + /* Store register address */ |
155 | +#include "hw/timer/xlnx-zynqmp-rtc.h" | 215 | + s->ptr = data; |
156 | + | 216 | + s->count++; |
157 | +#ifndef XLNX_ZYNQMP_RTC_ERR_DEBUG | 217 | + trace_axp209_select(data); |
158 | +#define XLNX_ZYNQMP_RTC_ERR_DEBUG 0 | 218 | + } else { |
159 | +#endif | 219 | + trace_axp209_tx(s->ptr, data); |
160 | + | 220 | + if (s->ptr == REG_DC_DC2_OUT_V_CTRL) { |
161 | +static void rtc_int_update_irq(XlnxZynqMPRTC *s) | 221 | + s->regs[s->ptr++] = data; |
162 | +{ | 222 | + } |
163 | + bool pending = s->regs[R_RTC_INT_STATUS] & ~s->regs[R_RTC_INT_MASK]; | 223 | + } |
164 | + qemu_set_irq(s->irq_rtc_int, pending); | 224 | + |
165 | +} | ||
166 | + | ||
167 | +static void addr_error_int_update_irq(XlnxZynqMPRTC *s) | ||
168 | +{ | ||
169 | + bool pending = s->regs[R_ADDR_ERROR] & ~s->regs[R_ADDR_ERROR_INT_MASK]; | ||
170 | + qemu_set_irq(s->irq_addr_error_int, pending); | ||
171 | +} | ||
172 | + | ||
173 | +static void rtc_int_status_postw(RegisterInfo *reg, uint64_t val64) | ||
174 | +{ | ||
175 | + XlnxZynqMPRTC *s = XLNX_ZYNQMP_RTC(reg->opaque); | ||
176 | + rtc_int_update_irq(s); | ||
177 | +} | ||
178 | + | ||
179 | +static uint64_t rtc_int_en_prew(RegisterInfo *reg, uint64_t val64) | ||
180 | +{ | ||
181 | + XlnxZynqMPRTC *s = XLNX_ZYNQMP_RTC(reg->opaque); | ||
182 | + | ||
183 | + s->regs[R_RTC_INT_MASK] &= (uint32_t) ~val64; | ||
184 | + rtc_int_update_irq(s); | ||
185 | + return 0; | 225 | + return 0; |
186 | +} | 226 | +} |
187 | + | 227 | + |
188 | +static uint64_t rtc_int_dis_prew(RegisterInfo *reg, uint64_t val64) | 228 | +static const VMStateDescription vmstate_axp209 = { |
189 | +{ | 229 | + .name = TYPE_AXP209_PMU, |
190 | + XlnxZynqMPRTC *s = XLNX_ZYNQMP_RTC(reg->opaque); | 230 | + .version_id = 1, |
191 | + | 231 | + .fields = (VMStateField[]) { |
192 | + s->regs[R_RTC_INT_MASK] |= (uint32_t) val64; | 232 | + VMSTATE_UINT8_ARRAY(regs, AXP209I2CState, NR_REGS), |
193 | + rtc_int_update_irq(s); | 233 | + VMSTATE_UINT8(count, AXP209I2CState), |
194 | + return 0; | 234 | + VMSTATE_UINT8(ptr, AXP209I2CState), |
195 | +} | 235 | + VMSTATE_END_OF_LIST() |
196 | + | ||
197 | +static void addr_error_postw(RegisterInfo *reg, uint64_t val64) | ||
198 | +{ | ||
199 | + XlnxZynqMPRTC *s = XLNX_ZYNQMP_RTC(reg->opaque); | ||
200 | + addr_error_int_update_irq(s); | ||
201 | +} | ||
202 | + | ||
203 | +static uint64_t addr_error_int_en_prew(RegisterInfo *reg, uint64_t val64) | ||
204 | +{ | ||
205 | + XlnxZynqMPRTC *s = XLNX_ZYNQMP_RTC(reg->opaque); | ||
206 | + | ||
207 | + s->regs[R_ADDR_ERROR_INT_MASK] &= (uint32_t) ~val64; | ||
208 | + addr_error_int_update_irq(s); | ||
209 | + return 0; | ||
210 | +} | ||
211 | + | ||
212 | +static uint64_t addr_error_int_dis_prew(RegisterInfo *reg, uint64_t val64) | ||
213 | +{ | ||
214 | + XlnxZynqMPRTC *s = XLNX_ZYNQMP_RTC(reg->opaque); | ||
215 | + | ||
216 | + s->regs[R_ADDR_ERROR_INT_MASK] |= (uint32_t) val64; | ||
217 | + addr_error_int_update_irq(s); | ||
218 | + return 0; | ||
219 | +} | ||
220 | + | ||
221 | +static const RegisterAccessInfo rtc_regs_info[] = { | ||
222 | + { .name = "SET_TIME_WRITE", .addr = A_SET_TIME_WRITE, | ||
223 | + },{ .name = "SET_TIME_READ", .addr = A_SET_TIME_READ, | ||
224 | + .ro = 0xffffffff, | ||
225 | + },{ .name = "CALIB_WRITE", .addr = A_CALIB_WRITE, | ||
226 | + },{ .name = "CALIB_READ", .addr = A_CALIB_READ, | ||
227 | + .ro = 0x1fffff, | ||
228 | + },{ .name = "CURRENT_TIME", .addr = A_CURRENT_TIME, | ||
229 | + .ro = 0xffffffff, | ||
230 | + },{ .name = "CURRENT_TICK", .addr = A_CURRENT_TICK, | ||
231 | + .ro = 0xffff, | ||
232 | + },{ .name = "ALARM", .addr = A_ALARM, | ||
233 | + },{ .name = "RTC_INT_STATUS", .addr = A_RTC_INT_STATUS, | ||
234 | + .w1c = 0x3, | ||
235 | + .post_write = rtc_int_status_postw, | ||
236 | + },{ .name = "RTC_INT_MASK", .addr = A_RTC_INT_MASK, | ||
237 | + .reset = 0x3, | ||
238 | + .ro = 0x3, | ||
239 | + },{ .name = "RTC_INT_EN", .addr = A_RTC_INT_EN, | ||
240 | + .pre_write = rtc_int_en_prew, | ||
241 | + },{ .name = "RTC_INT_DIS", .addr = A_RTC_INT_DIS, | ||
242 | + .pre_write = rtc_int_dis_prew, | ||
243 | + },{ .name = "ADDR_ERROR", .addr = A_ADDR_ERROR, | ||
244 | + .w1c = 0x1, | ||
245 | + .post_write = addr_error_postw, | ||
246 | + },{ .name = "ADDR_ERROR_INT_MASK", .addr = A_ADDR_ERROR_INT_MASK, | ||
247 | + .reset = 0x1, | ||
248 | + .ro = 0x1, | ||
249 | + },{ .name = "ADDR_ERROR_INT_EN", .addr = A_ADDR_ERROR_INT_EN, | ||
250 | + .pre_write = addr_error_int_en_prew, | ||
251 | + },{ .name = "ADDR_ERROR_INT_DIS", .addr = A_ADDR_ERROR_INT_DIS, | ||
252 | + .pre_write = addr_error_int_dis_prew, | ||
253 | + },{ .name = "CONTROL", .addr = A_CONTROL, | ||
254 | + .reset = 0x1000000, | ||
255 | + .rsvd = 0x70fffffe, | ||
256 | + },{ .name = "SAFETY_CHK", .addr = A_SAFETY_CHK, | ||
257 | + } | 236 | + } |
258 | +}; | 237 | +}; |
259 | + | 238 | + |
260 | +static void rtc_reset(DeviceState *dev) | 239 | +static void axp209_class_init(ObjectClass *oc, void *data) |
261 | +{ | 240 | +{ |
262 | + XlnxZynqMPRTC *s = XLNX_ZYNQMP_RTC(dev); | 241 | + DeviceClass *dc = DEVICE_CLASS(oc); |
263 | + unsigned int i; | 242 | + I2CSlaveClass *isc = I2C_SLAVE_CLASS(oc); |
264 | + | 243 | + ResettableClass *rc = RESETTABLE_CLASS(oc); |
265 | + for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) { | 244 | + |
266 | + register_reset(&s->regs_info[i]); | 245 | + rc->phases.enter = axp209_reset_enter; |
267 | + } | 246 | + dc->vmsd = &vmstate_axp209; |
268 | + | 247 | + isc->event = axp209_event; |
269 | + rtc_int_update_irq(s); | 248 | + isc->recv = axp209_rx; |
270 | + addr_error_int_update_irq(s); | 249 | + isc->send = axp209_tx; |
271 | +} | 250 | +} |
272 | + | 251 | + |
273 | +static const MemoryRegionOps rtc_ops = { | 252 | +static const TypeInfo axp209_info = { |
274 | + .read = register_read_memory, | 253 | + .name = TYPE_AXP209_PMU, |
275 | + .write = register_write_memory, | 254 | + .parent = TYPE_I2C_SLAVE, |
276 | + .endianness = DEVICE_LITTLE_ENDIAN, | 255 | + .instance_size = sizeof(AXP209I2CState), |
277 | + .valid = { | 256 | + .class_init = axp209_class_init |
278 | + .min_access_size = 4, | ||
279 | + .max_access_size = 4, | ||
280 | + }, | ||
281 | +}; | 257 | +}; |
282 | + | 258 | + |
283 | +static void rtc_init(Object *obj) | 259 | +static void axp209_register_devices(void) |
284 | +{ | 260 | +{ |
285 | + XlnxZynqMPRTC *s = XLNX_ZYNQMP_RTC(obj); | 261 | + type_register_static(&axp209_info); |
286 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | 262 | +} |
287 | + RegisterInfoArray *reg_array; | 263 | + |
288 | + | 264 | +type_init(axp209_register_devices); |
289 | + memory_region_init(&s->iomem, obj, TYPE_XLNX_ZYNQMP_RTC, | 265 | diff --git a/MAINTAINERS b/MAINTAINERS |
290 | + XLNX_ZYNQMP_RTC_R_MAX * 4); | 266 | index XXXXXXX..XXXXXXX 100644 |
291 | + reg_array = | 267 | --- a/MAINTAINERS |
292 | + register_init_block32(DEVICE(obj), rtc_regs_info, | 268 | +++ b/MAINTAINERS |
293 | + ARRAY_SIZE(rtc_regs_info), | 269 | @@ -XXX,XX +XXX,XX @@ ARM Machines |
294 | + s->regs_info, s->regs, | 270 | Allwinner-a10 |
295 | + &rtc_ops, | 271 | M: Beniamino Galvani <b.galvani@gmail.com> |
296 | + XLNX_ZYNQMP_RTC_ERR_DEBUG, | 272 | M: Peter Maydell <peter.maydell@linaro.org> |
297 | + XLNX_ZYNQMP_RTC_R_MAX * 4); | 273 | +R: Strahinja Jankovic <strahinja.p.jankovic@gmail.com> |
298 | + memory_region_add_subregion(&s->iomem, | 274 | L: qemu-arm@nongnu.org |
299 | + 0x0, | 275 | S: Odd Fixes |
300 | + ®_array->mem); | 276 | F: hw/*/allwinner* |
301 | + sysbus_init_mmio(sbd, &s->iomem); | 277 | F: include/hw/*/allwinner* |
302 | + sysbus_init_irq(sbd, &s->irq_rtc_int); | 278 | F: hw/arm/cubieboard.c |
303 | + sysbus_init_irq(sbd, &s->irq_addr_error_int); | 279 | F: docs/system/arm/cubieboard.rst |
304 | +} | 280 | +F: hw/misc/axp209.c |
305 | + | 281 | |
306 | +static const VMStateDescription vmstate_rtc = { | 282 | Allwinner-h3 |
307 | + .name = TYPE_XLNX_ZYNQMP_RTC, | 283 | M: Niek Linnenbank <nieklinnenbank@gmail.com> |
308 | + .version_id = 1, | 284 | diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig |
309 | + .minimum_version_id = 1, | 285 | index XXXXXXX..XXXXXXX 100644 |
310 | + .fields = (VMStateField[]) { | 286 | --- a/hw/misc/Kconfig |
311 | + VMSTATE_UINT32_ARRAY(regs, XlnxZynqMPRTC, XLNX_ZYNQMP_RTC_R_MAX), | 287 | +++ b/hw/misc/Kconfig |
312 | + VMSTATE_END_OF_LIST(), | 288 | @@ -XXX,XX +XXX,XX @@ config ALLWINNER_A10_CCM |
313 | + } | 289 | config ALLWINNER_A10_DRAMC |
314 | +}; | 290 | bool |
315 | + | 291 | |
316 | +static void rtc_class_init(ObjectClass *klass, void *data) | 292 | +config AXP209_PMU |
317 | +{ | 293 | + bool |
318 | + DeviceClass *dc = DEVICE_CLASS(klass); | 294 | + depends on I2C |
319 | + | 295 | + |
320 | + dc->reset = rtc_reset; | 296 | source macio/Kconfig |
321 | + dc->vmsd = &vmstate_rtc; | 297 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build |
322 | +} | 298 | index XXXXXXX..XXXXXXX 100644 |
323 | + | 299 | --- a/hw/misc/meson.build |
324 | +static const TypeInfo rtc_info = { | 300 | +++ b/hw/misc/meson.build |
325 | + .name = TYPE_XLNX_ZYNQMP_RTC, | 301 | @@ -XXX,XX +XXX,XX @@ specific_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-cpucfg.c' |
326 | + .parent = TYPE_SYS_BUS_DEVICE, | 302 | softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-dramc.c')) |
327 | + .instance_size = sizeof(XlnxZynqMPRTC), | 303 | softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-sysctrl.c')) |
328 | + .class_init = rtc_class_init, | 304 | softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-sid.c')) |
329 | + .instance_init = rtc_init, | 305 | +softmmu_ss.add(when: 'CONFIG_AXP209_PMU', if_true: files('axp209.c')) |
330 | +}; | 306 | softmmu_ss.add(when: 'CONFIG_REALVIEW', if_true: files('arm_sysctl.c')) |
331 | + | 307 | softmmu_ss.add(when: 'CONFIG_NSERIES', if_true: files('cbus.c')) |
332 | +static void rtc_register_types(void) | 308 | softmmu_ss.add(when: 'CONFIG_ECCMEMCTL', if_true: files('eccmemctl.c')) |
333 | +{ | 309 | diff --git a/hw/misc/trace-events b/hw/misc/trace-events |
334 | + type_register_static(&rtc_info); | 310 | index XXXXXXX..XXXXXXX 100644 |
335 | +} | 311 | --- a/hw/misc/trace-events |
336 | + | 312 | +++ b/hw/misc/trace-events |
337 | +type_init(rtc_register_types) | 313 | @@ -XXX,XX +XXX,XX @@ allwinner_sid_write(uint64_t offset, uint64_t data, unsigned size) "offset 0x%" |
314 | avr_power_read(uint8_t value) "power_reduc read value:%u" | ||
315 | avr_power_write(uint8_t value) "power_reduc write value:%u" | ||
316 | |||
317 | +# axp209.c | ||
318 | +axp209_rx(uint8_t reg, uint8_t data) "Read reg 0x%" PRIx8 " : 0x%" PRIx8 | ||
319 | +axp209_select(uint8_t reg) "Accessing reg 0x%" PRIx8 | ||
320 | +axp209_tx(uint8_t reg, uint8_t data) "Write reg 0x%" PRIx8 " : 0x%" PRIx8 | ||
321 | + | ||
322 | # eccmemctl.c | ||
323 | ecc_mem_writel_mer(uint32_t val) "Write memory enable 0x%08x" | ||
324 | ecc_mem_writel_mdr(uint32_t val) "Write memory delay 0x%08x" | ||
338 | -- | 325 | -- |
339 | 2.16.2 | 326 | 2.34.1 |
340 | |||
341 | diff view generated by jsdifflib |
1 | Instead of loading guest images to the system address space, use the | 1 | From: Strahinja Jankovic <strahinjapjankovic@gmail.com> |
---|---|---|---|
2 | CPU's address space. This is important if we're trying to load the | ||
3 | file to memory or via an alias memory region that is provided by an | ||
4 | SoC object and thus not mapped into the system address space. | ||
5 | 2 | ||
3 | SPL Boot for Cubieboard expects AXP209 connected to I2C0 bus. | ||
4 | |||
5 | Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com> | ||
6 | |||
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Message-id: 20221226220303.14420-6-strahinja.p.jankovic@gmail.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20180220180325.29818-4-peter.maydell@linaro.org | ||
10 | --- | 10 | --- |
11 | hw/arm/armv7m.c | 17 ++++++++++++++--- | 11 | hw/arm/cubieboard.c | 6 ++++++ |
12 | 1 file changed, 14 insertions(+), 3 deletions(-) | 12 | hw/arm/Kconfig | 1 + |
13 | 2 files changed, 7 insertions(+) | ||
13 | 14 | ||
14 | diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c | 15 | diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/arm/armv7m.c | 17 | --- a/hw/arm/cubieboard.c |
17 | +++ b/hw/arm/armv7m.c | 18 | +++ b/hw/arm/cubieboard.c |
18 | @@ -XXX,XX +XXX,XX @@ void armv7m_load_kernel(ARMCPU *cpu, const char *kernel_filename, int mem_size) | 19 | @@ -XXX,XX +XXX,XX @@ |
19 | uint64_t entry; | 20 | #include "hw/boards.h" |
20 | uint64_t lowaddr; | 21 | #include "hw/qdev-properties.h" |
21 | int big_endian; | 22 | #include "hw/arm/allwinner-a10.h" |
22 | + AddressSpace *as; | 23 | +#include "hw/i2c/i2c.h" |
23 | + int asidx; | 24 | |
24 | + CPUState *cs = CPU(cpu); | 25 | static struct arm_boot_info cubieboard_binfo = { |
25 | 26 | .loader_start = AW_A10_SDRAM_BASE, | |
26 | #ifdef TARGET_WORDS_BIGENDIAN | 27 | @@ -XXX,XX +XXX,XX @@ static void cubieboard_init(MachineState *machine) |
27 | big_endian = 1; | 28 | BlockBackend *blk; |
28 | @@ -XXX,XX +XXX,XX @@ void armv7m_load_kernel(ARMCPU *cpu, const char *kernel_filename, int mem_size) | 29 | BusState *bus; |
30 | DeviceState *carddev; | ||
31 | + I2CBus *i2c; | ||
32 | |||
33 | /* BIOS is not supported by this board */ | ||
34 | if (machine->firmware) { | ||
35 | @@ -XXX,XX +XXX,XX @@ static void cubieboard_init(MachineState *machine) | ||
29 | exit(1); | 36 | exit(1); |
30 | } | 37 | } |
31 | 38 | ||
32 | + if (arm_feature(&cpu->env, ARM_FEATURE_EL3)) { | 39 | + /* Connect AXP 209 */ |
33 | + asidx = ARMASIdx_S; | 40 | + i2c = I2C_BUS(qdev_get_child_bus(DEVICE(&a10->i2c0), "i2c")); |
34 | + } else { | 41 | + i2c_slave_create_simple(i2c, "axp209_pmu", 0x34); |
35 | + asidx = ARMASIdx_NS; | ||
36 | + } | ||
37 | + as = cpu_get_address_space(cs, asidx); | ||
38 | + | 42 | + |
39 | if (kernel_filename) { | 43 | /* Retrieve SD bus */ |
40 | - image_size = load_elf(kernel_filename, NULL, NULL, &entry, &lowaddr, | 44 | di = drive_get(IF_SD, 0, 0); |
41 | - NULL, big_endian, EM_ARM, 1, 0); | 45 | blk = di ? blk_by_legacy_dinfo(di) : NULL; |
42 | + image_size = load_elf_as(kernel_filename, NULL, NULL, &entry, &lowaddr, | 46 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig |
43 | + NULL, big_endian, EM_ARM, 1, 0, as); | 47 | index XXXXXXX..XXXXXXX 100644 |
44 | if (image_size < 0) { | 48 | --- a/hw/arm/Kconfig |
45 | - image_size = load_image_targphys(kernel_filename, 0, mem_size); | 49 | +++ b/hw/arm/Kconfig |
46 | + image_size = load_image_targphys_as(kernel_filename, 0, | 50 | @@ -XXX,XX +XXX,XX @@ config ALLWINNER_A10 |
47 | + mem_size, as); | 51 | select ALLWINNER_A10_DRAMC |
48 | lowaddr = 0; | 52 | select ALLWINNER_EMAC |
49 | } | 53 | select ALLWINNER_I2C |
50 | if (image_size < 0) { | 54 | + select AXP209_PMU |
55 | select SERIAL | ||
56 | select UNIMP | ||
57 | |||
51 | -- | 58 | -- |
52 | 2.16.2 | 59 | 2.34.1 |
53 | 60 | ||
54 | 61 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Strahinja Jankovic <strahinjapjankovic@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 3 | This patch enables copying of SPL from MMC if `-kernel` parameter is not |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | passed when starting QEMU. SPL is copied to SRAM_A. |
5 | Message-id: 20180228193125.20577-5-richard.henderson@linaro.org | 5 | |
6 | The approach is reused from Allwinner H3 implementation. | ||
7 | |||
8 | Tested with Armbian and custom Yocto image. | ||
9 | |||
10 | Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com> | ||
11 | |||
12 | Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com> | ||
13 | Message-id: 20221226220303.14420-7-strahinja.p.jankovic@gmail.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 15 | --- |
8 | target/arm/Makefile.objs | 2 +- | 16 | include/hw/arm/allwinner-a10.h | 21 +++++++++++++++++++++ |
9 | target/arm/helper.h | 4 ++ | 17 | hw/arm/allwinner-a10.c | 18 ++++++++++++++++++ |
10 | target/arm/translate-a64.c | 84 ++++++++++++++++++++++++++++++++++ | 18 | hw/arm/cubieboard.c | 5 +++++ |
11 | target/arm/vec_helper.c | 109 +++++++++++++++++++++++++++++++++++++++++++++ | 19 | 3 files changed, 44 insertions(+) |
12 | 4 files changed, 198 insertions(+), 1 deletion(-) | ||
13 | create mode 100644 target/arm/vec_helper.c | ||
14 | 20 | ||
15 | diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs | 21 | diff --git a/include/hw/arm/allwinner-a10.h b/include/hw/arm/allwinner-a10.h |
16 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/Makefile.objs | 23 | --- a/include/hw/arm/allwinner-a10.h |
18 | +++ b/target/arm/Makefile.objs | 24 | +++ b/include/hw/arm/allwinner-a10.h |
19 | @@ -XXX,XX +XXX,XX @@ obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o | 25 | @@ -XXX,XX +XXX,XX @@ |
20 | obj-$(call land,$(CONFIG_KVM),$(TARGET_AARCH64)) += kvm64.o | 26 | #include "hw/misc/allwinner-a10-ccm.h" |
21 | obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o | 27 | #include "hw/misc/allwinner-a10-dramc.h" |
22 | obj-y += translate.o op_helper.o helper.o cpu.o | 28 | #include "hw/i2c/allwinner-i2c.h" |
23 | -obj-y += neon_helper.o iwmmxt_helper.o | 29 | +#include "sysemu/block-backend.h" |
24 | +obj-y += neon_helper.o iwmmxt_helper.o vec_helper.o | 30 | |
25 | obj-y += gdbstub.o | 31 | #include "target/arm/cpu.h" |
26 | obj-$(TARGET_AARCH64) += cpu64.o translate-a64.o helper-a64.o gdbstub64.o | 32 | #include "qom/object.h" |
27 | obj-y += crypto_helper.o | 33 | @@ -XXX,XX +XXX,XX @@ struct AwA10State { |
28 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 34 | OHCISysBusState ohci[AW_A10_NUM_USB]; |
35 | }; | ||
36 | |||
37 | +/** | ||
38 | + * Emulate Boot ROM firmware setup functionality. | ||
39 | + * | ||
40 | + * A real Allwinner A10 SoC contains a Boot ROM | ||
41 | + * which is the first code that runs right after | ||
42 | + * the SoC is powered on. The Boot ROM is responsible | ||
43 | + * for loading user code (e.g. a bootloader) from any | ||
44 | + * of the supported external devices and writing the | ||
45 | + * downloaded code to internal SRAM. After loading the SoC | ||
46 | + * begins executing the code written to SRAM. | ||
47 | + * | ||
48 | + * This function emulates the Boot ROM by copying 32 KiB | ||
49 | + * of data at offset 8 KiB from the given block device and writes it to | ||
50 | + * the start of the first internal SRAM memory. | ||
51 | + * | ||
52 | + * @s: Allwinner A10 state object pointer | ||
53 | + * @blk: Block backend device object pointer | ||
54 | + */ | ||
55 | +void allwinner_a10_bootrom_setup(AwA10State *s, BlockBackend *blk); | ||
56 | + | ||
57 | #endif | ||
58 | diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | 59 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/target/arm/helper.h | 60 | --- a/hw/arm/allwinner-a10.c |
31 | +++ b/target/arm/helper.h | 61 | +++ b/hw/arm/allwinner-a10.c |
32 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_1(neon_rbit_u8, TCG_CALL_NO_RWG_SE, i32, i32) | 62 | @@ -XXX,XX +XXX,XX @@ |
33 | 63 | #include "sysemu/sysemu.h" | |
34 | DEF_HELPER_3(neon_qdmulh_s16, i32, env, i32, i32) | 64 | #include "hw/boards.h" |
35 | DEF_HELPER_3(neon_qrdmulh_s16, i32, env, i32, i32) | 65 | #include "hw/usb/hcd-ohci.h" |
36 | +DEF_HELPER_4(neon_qrdmlah_s16, i32, env, i32, i32, i32) | 66 | +#include "hw/loader.h" |
37 | +DEF_HELPER_4(neon_qrdmlsh_s16, i32, env, i32, i32, i32) | 67 | |
38 | DEF_HELPER_3(neon_qdmulh_s32, i32, env, i32, i32) | 68 | +#define AW_A10_SRAM_A_BASE 0x00000000 |
39 | DEF_HELPER_3(neon_qrdmulh_s32, i32, env, i32, i32) | 69 | #define AW_A10_DRAMC_BASE 0x01c01000 |
40 | +DEF_HELPER_4(neon_qrdmlah_s32, i32, env, s32, s32, s32) | 70 | #define AW_A10_MMC0_BASE 0x01c0f000 |
41 | +DEF_HELPER_4(neon_qrdmlsh_s32, i32, env, s32, s32, s32) | 71 | #define AW_A10_CCM_BASE 0x01c20000 |
42 | 72 | @@ -XXX,XX +XXX,XX @@ | |
43 | DEF_HELPER_1(neon_narrow_u8, i32, i64) | 73 | #define AW_A10_RTC_BASE 0x01c20d00 |
44 | DEF_HELPER_1(neon_narrow_u16, i32, i64) | 74 | #define AW_A10_I2C0_BASE 0x01c2ac00 |
45 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 75 | |
46 | index XXXXXXX..XXXXXXX 100644 | 76 | +void allwinner_a10_bootrom_setup(AwA10State *s, BlockBackend *blk) |
47 | --- a/target/arm/translate-a64.c | ||
48 | +++ b/target/arm/translate-a64.c | ||
49 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_three_reg_same_fp16(DisasContext *s, | ||
50 | tcg_temp_free_ptr(fpst); | ||
51 | } | ||
52 | |||
53 | +/* AdvSIMD scalar three same extra | ||
54 | + * 31 30 29 28 24 23 22 21 20 16 15 14 11 10 9 5 4 0 | ||
55 | + * +-----+---+-----------+------+---+------+---+--------+---+----+----+ | ||
56 | + * | 0 1 | U | 1 1 1 1 0 | size | 0 | Rm | 1 | opcode | 1 | Rn | Rd | | ||
57 | + * +-----+---+-----------+------+---+------+---+--------+---+----+----+ | ||
58 | + */ | ||
59 | +static void disas_simd_scalar_three_reg_same_extra(DisasContext *s, | ||
60 | + uint32_t insn) | ||
61 | +{ | 77 | +{ |
62 | + int rd = extract32(insn, 0, 5); | 78 | + const int64_t rom_size = 32 * KiB; |
63 | + int rn = extract32(insn, 5, 5); | 79 | + g_autofree uint8_t *buffer = g_new0(uint8_t, rom_size); |
64 | + int opcode = extract32(insn, 11, 4); | ||
65 | + int rm = extract32(insn, 16, 5); | ||
66 | + int size = extract32(insn, 22, 2); | ||
67 | + bool u = extract32(insn, 29, 1); | ||
68 | + TCGv_i32 ele1, ele2, ele3; | ||
69 | + TCGv_i64 res; | ||
70 | + int feature; | ||
71 | + | 80 | + |
72 | + switch (u * 16 + opcode) { | 81 | + if (blk_pread(blk, 8 * KiB, rom_size, buffer, 0) < 0) { |
73 | + case 0x10: /* SQRDMLAH (vector) */ | 82 | + error_setg(&error_fatal, "%s: failed to read BlockBackend data", |
74 | + case 0x11: /* SQRDMLSH (vector) */ | 83 | + __func__); |
75 | + if (size != 1 && size != 2) { | ||
76 | + unallocated_encoding(s); | ||
77 | + return; | ||
78 | + } | ||
79 | + feature = ARM_FEATURE_V8_RDM; | ||
80 | + break; | ||
81 | + default: | ||
82 | + unallocated_encoding(s); | ||
83 | + return; | ||
84 | + } | ||
85 | + if (!arm_dc_feature(s, feature)) { | ||
86 | + unallocated_encoding(s); | ||
87 | + return; | ||
88 | + } | ||
89 | + if (!fp_access_check(s)) { | ||
90 | + return; | 84 | + return; |
91 | + } | 85 | + } |
92 | + | 86 | + |
93 | + /* Do a single operation on the lowest element in the vector. | 87 | + rom_add_blob("allwinner-a10.bootrom", buffer, rom_size, |
94 | + * We use the standard Neon helpers and rely on 0 OP 0 == 0 | 88 | + rom_size, AW_A10_SRAM_A_BASE, |
95 | + * with no side effects for all these operations. | 89 | + NULL, NULL, NULL, NULL, false); |
96 | + * OPTME: special-purpose helpers would avoid doing some | ||
97 | + * unnecessary work in the helper for the 16 bit cases. | ||
98 | + */ | ||
99 | + ele1 = tcg_temp_new_i32(); | ||
100 | + ele2 = tcg_temp_new_i32(); | ||
101 | + ele3 = tcg_temp_new_i32(); | ||
102 | + | ||
103 | + read_vec_element_i32(s, ele1, rn, 0, size); | ||
104 | + read_vec_element_i32(s, ele2, rm, 0, size); | ||
105 | + read_vec_element_i32(s, ele3, rd, 0, size); | ||
106 | + | ||
107 | + switch (opcode) { | ||
108 | + case 0x0: /* SQRDMLAH */ | ||
109 | + if (size == 1) { | ||
110 | + gen_helper_neon_qrdmlah_s16(ele3, cpu_env, ele1, ele2, ele3); | ||
111 | + } else { | ||
112 | + gen_helper_neon_qrdmlah_s32(ele3, cpu_env, ele1, ele2, ele3); | ||
113 | + } | ||
114 | + break; | ||
115 | + case 0x1: /* SQRDMLSH */ | ||
116 | + if (size == 1) { | ||
117 | + gen_helper_neon_qrdmlsh_s16(ele3, cpu_env, ele1, ele2, ele3); | ||
118 | + } else { | ||
119 | + gen_helper_neon_qrdmlsh_s32(ele3, cpu_env, ele1, ele2, ele3); | ||
120 | + } | ||
121 | + break; | ||
122 | + default: | ||
123 | + g_assert_not_reached(); | ||
124 | + } | ||
125 | + tcg_temp_free_i32(ele1); | ||
126 | + tcg_temp_free_i32(ele2); | ||
127 | + | ||
128 | + res = tcg_temp_new_i64(); | ||
129 | + tcg_gen_extu_i32_i64(res, ele3); | ||
130 | + tcg_temp_free_i32(ele3); | ||
131 | + | ||
132 | + write_fp_dreg(s, rd, res); | ||
133 | + tcg_temp_free_i64(res); | ||
134 | +} | 90 | +} |
135 | + | 91 | + |
136 | static void handle_2misc_64(DisasContext *s, int opcode, bool u, | 92 | static void aw_a10_init(Object *obj) |
137 | TCGv_i64 tcg_rd, TCGv_i64 tcg_rn, | 93 | { |
138 | TCGv_i32 tcg_rmode, TCGv_ptr tcg_fpstatus) | 94 | AwA10State *s = AW_A10(obj); |
139 | @@ -XXX,XX +XXX,XX @@ static const AArch64DecodeTable data_proc_simd[] = { | 95 | diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c |
140 | { 0x0e000800, 0xbf208c00, disas_simd_zip_trn }, | 96 | index XXXXXXX..XXXXXXX 100644 |
141 | { 0x2e000000, 0xbf208400, disas_simd_ext }, | 97 | --- a/hw/arm/cubieboard.c |
142 | { 0x5e200400, 0xdf200400, disas_simd_scalar_three_reg_same }, | 98 | +++ b/hw/arm/cubieboard.c |
143 | + { 0x5e008400, 0xdf208400, disas_simd_scalar_three_reg_same_extra }, | 99 | @@ -XXX,XX +XXX,XX @@ static void cubieboard_init(MachineState *machine) |
144 | { 0x5e200000, 0xdf200c00, disas_simd_scalar_three_reg_diff }, | 100 | memory_region_add_subregion(get_system_memory(), AW_A10_SDRAM_BASE, |
145 | { 0x5e200800, 0xdf3e0c00, disas_simd_scalar_two_reg_misc }, | 101 | machine->ram); |
146 | { 0x5e300800, 0xdf3e0c00, disas_simd_scalar_pairwise }, | 102 | |
147 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | 103 | + /* Load target kernel or start using BootROM */ |
148 | new file mode 100644 | 104 | + if (!machine->kernel_filename && blk && blk_is_available(blk)) { |
149 | index XXXXXXX..XXXXXXX | 105 | + /* Use Boot ROM to copy data from SD card to SRAM */ |
150 | --- /dev/null | 106 | + allwinner_a10_bootrom_setup(a10, blk); |
151 | +++ b/target/arm/vec_helper.c | ||
152 | @@ -XXX,XX +XXX,XX @@ | ||
153 | +/* | ||
154 | + * ARM AdvSIMD / SVE Vector Operations | ||
155 | + * | ||
156 | + * Copyright (c) 2018 Linaro | ||
157 | + * | ||
158 | + * This library is free software; you can redistribute it and/or | ||
159 | + * modify it under the terms of the GNU Lesser General Public | ||
160 | + * License as published by the Free Software Foundation; either | ||
161 | + * version 2 of the License, or (at your option) any later version. | ||
162 | + * | ||
163 | + * This library is distributed in the hope that it will be useful, | ||
164 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
165 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
166 | + * Lesser General Public License for more details. | ||
167 | + * | ||
168 | + * You should have received a copy of the GNU Lesser General Public | ||
169 | + * License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
170 | + */ | ||
171 | + | ||
172 | +#include "qemu/osdep.h" | ||
173 | +#include "cpu.h" | ||
174 | +#include "exec/exec-all.h" | ||
175 | +#include "exec/helper-proto.h" | ||
176 | +#include "tcg/tcg-gvec-desc.h" | ||
177 | + | ||
178 | + | ||
179 | +#define SET_QC() env->vfp.xregs[ARM_VFP_FPSCR] |= CPSR_Q | ||
180 | + | ||
181 | +/* Signed saturating rounding doubling multiply-accumulate high half, 16-bit */ | ||
182 | +static uint16_t inl_qrdmlah_s16(CPUARMState *env, int16_t src1, | ||
183 | + int16_t src2, int16_t src3) | ||
184 | +{ | ||
185 | + /* Simplify: | ||
186 | + * = ((a3 << 16) + ((e1 * e2) << 1) + (1 << 15)) >> 16 | ||
187 | + * = ((a3 << 15) + (e1 * e2) + (1 << 14)) >> 15 | ||
188 | + */ | ||
189 | + int32_t ret = (int32_t)src1 * src2; | ||
190 | + ret = ((int32_t)src3 << 15) + ret + (1 << 14); | ||
191 | + ret >>= 15; | ||
192 | + if (ret != (int16_t)ret) { | ||
193 | + SET_QC(); | ||
194 | + ret = (ret < 0 ? -0x8000 : 0x7fff); | ||
195 | + } | 107 | + } |
196 | + return ret; | 108 | /* TODO create and connect IDE devices for ide_drive_get() */ |
197 | +} | 109 | |
198 | + | 110 | cubieboard_binfo.ram_size = machine->ram_size; |
199 | +uint32_t HELPER(neon_qrdmlah_s16)(CPUARMState *env, uint32_t src1, | ||
200 | + uint32_t src2, uint32_t src3) | ||
201 | +{ | ||
202 | + uint16_t e1 = inl_qrdmlah_s16(env, src1, src2, src3); | ||
203 | + uint16_t e2 = inl_qrdmlah_s16(env, src1 >> 16, src2 >> 16, src3 >> 16); | ||
204 | + return deposit32(e1, 16, 16, e2); | ||
205 | +} | ||
206 | + | ||
207 | +/* Signed saturating rounding doubling multiply-subtract high half, 16-bit */ | ||
208 | +static uint16_t inl_qrdmlsh_s16(CPUARMState *env, int16_t src1, | ||
209 | + int16_t src2, int16_t src3) | ||
210 | +{ | ||
211 | + /* Similarly, using subtraction: | ||
212 | + * = ((a3 << 16) - ((e1 * e2) << 1) + (1 << 15)) >> 16 | ||
213 | + * = ((a3 << 15) - (e1 * e2) + (1 << 14)) >> 15 | ||
214 | + */ | ||
215 | + int32_t ret = (int32_t)src1 * src2; | ||
216 | + ret = ((int32_t)src3 << 15) - ret + (1 << 14); | ||
217 | + ret >>= 15; | ||
218 | + if (ret != (int16_t)ret) { | ||
219 | + SET_QC(); | ||
220 | + ret = (ret < 0 ? -0x8000 : 0x7fff); | ||
221 | + } | ||
222 | + return ret; | ||
223 | +} | ||
224 | + | ||
225 | +uint32_t HELPER(neon_qrdmlsh_s16)(CPUARMState *env, uint32_t src1, | ||
226 | + uint32_t src2, uint32_t src3) | ||
227 | +{ | ||
228 | + uint16_t e1 = inl_qrdmlsh_s16(env, src1, src2, src3); | ||
229 | + uint16_t e2 = inl_qrdmlsh_s16(env, src1 >> 16, src2 >> 16, src3 >> 16); | ||
230 | + return deposit32(e1, 16, 16, e2); | ||
231 | +} | ||
232 | + | ||
233 | +/* Signed saturating rounding doubling multiply-accumulate high half, 32-bit */ | ||
234 | +uint32_t HELPER(neon_qrdmlah_s32)(CPUARMState *env, int32_t src1, | ||
235 | + int32_t src2, int32_t src3) | ||
236 | +{ | ||
237 | + /* Simplify similarly to int_qrdmlah_s16 above. */ | ||
238 | + int64_t ret = (int64_t)src1 * src2; | ||
239 | + ret = ((int64_t)src3 << 31) + ret + (1 << 30); | ||
240 | + ret >>= 31; | ||
241 | + if (ret != (int32_t)ret) { | ||
242 | + SET_QC(); | ||
243 | + ret = (ret < 0 ? INT32_MIN : INT32_MAX); | ||
244 | + } | ||
245 | + return ret; | ||
246 | +} | ||
247 | + | ||
248 | +/* Signed saturating rounding doubling multiply-subtract high half, 32-bit */ | ||
249 | +uint32_t HELPER(neon_qrdmlsh_s32)(CPUARMState *env, int32_t src1, | ||
250 | + int32_t src2, int32_t src3) | ||
251 | +{ | ||
252 | + /* Simplify similarly to int_qrdmlsh_s16 above. */ | ||
253 | + int64_t ret = (int64_t)src1 * src2; | ||
254 | + ret = ((int64_t)src3 << 31) - ret + (1 << 30); | ||
255 | + ret >>= 31; | ||
256 | + if (ret != (int32_t)ret) { | ||
257 | + SET_QC(); | ||
258 | + ret = (ret < 0 ? INT32_MIN : INT32_MAX); | ||
259 | + } | ||
260 | + return ret; | ||
261 | +} | ||
262 | -- | 111 | -- |
263 | 2.16.2 | 112 | 2.34.1 |
264 | |||
265 | diff view generated by jsdifflib |
1 | Define a new board model for the MPS2 with an AN505 FPGA image | 1 | From: Strahinja Jankovic <strahinjapjankovic@gmail.com> |
---|---|---|---|
2 | containing a Cortex-M33. Since the FPGA images for TrustZone | ||
3 | cores (AN505, and the similar AN519 for Cortex-M23) have a | ||
4 | significantly different layout of devices to the non-TrustZone | ||
5 | images, we use a new source file rather than shoehorning them | ||
6 | into the existing mps2.c. | ||
7 | 2 | ||
3 | Cubieboard now can boot directly from SD card, without the need to pass | ||
4 | `-kernel` parameter. Update Avocado tests to cover this functionality. | ||
5 | |||
6 | Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com> | ||
7 | Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com> | ||
8 | Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com> | ||
9 | Message-id: 20221226220303.14420-8-strahinja.p.jankovic@gmail.com | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20180220180325.29818-20-peter.maydell@linaro.org | ||
11 | --- | 11 | --- |
12 | hw/arm/Makefile.objs | 1 + | 12 | tests/avocado/boot_linux_console.py | 47 +++++++++++++++++++++++++++++ |
13 | hw/arm/mps2-tz.c | 503 +++++++++++++++++++++++++++++++++++++++++++++++++++ | 13 | 1 file changed, 47 insertions(+) |
14 | 2 files changed, 504 insertions(+) | ||
15 | create mode 100644 hw/arm/mps2-tz.c | ||
16 | 14 | ||
17 | diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs | 15 | diff --git a/tests/avocado/boot_linux_console.py b/tests/avocado/boot_linux_console.py |
18 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/arm/Makefile.objs | 17 | --- a/tests/avocado/boot_linux_console.py |
20 | +++ b/hw/arm/Makefile.objs | 18 | +++ b/tests/avocado/boot_linux_console.py |
21 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_FSL_IMX31) += fsl-imx31.o kzm.o | 19 | @@ -XXX,XX +XXX,XX @@ def test_arm_cubieboard_sata(self): |
22 | obj-$(CONFIG_FSL_IMX6) += fsl-imx6.o sabrelite.o | 20 | 'sda') |
23 | obj-$(CONFIG_ASPEED_SOC) += aspeed_soc.o aspeed.o | 21 | # cubieboard's reboot is not functioning; omit reboot test. |
24 | obj-$(CONFIG_MPS2) += mps2.o | 22 | |
25 | +obj-$(CONFIG_MPS2) += mps2-tz.o | 23 | + @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited') |
26 | obj-$(CONFIG_MSF2) += msf2-soc.o msf2-som.o | 24 | + def test_arm_cubieboard_openwrt_22_03_2(self): |
27 | obj-$(CONFIG_IOTKIT) += iotkit.o | 25 | + """ |
28 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | 26 | + :avocado: tags=arch:arm |
29 | new file mode 100644 | 27 | + :avocado: tags=machine:cubieboard |
30 | index XXXXXXX..XXXXXXX | 28 | + :avocado: tags=device:sd |
31 | --- /dev/null | 29 | + """ |
32 | +++ b/hw/arm/mps2-tz.c | ||
33 | @@ -XXX,XX +XXX,XX @@ | ||
34 | +/* | ||
35 | + * ARM V2M MPS2 board emulation, trustzone aware FPGA images | ||
36 | + * | ||
37 | + * Copyright (c) 2017 Linaro Limited | ||
38 | + * Written by Peter Maydell | ||
39 | + * | ||
40 | + * This program is free software; you can redistribute it and/or modify | ||
41 | + * it under the terms of the GNU General Public License version 2 or | ||
42 | + * (at your option) any later version. | ||
43 | + */ | ||
44 | + | 30 | + |
45 | +/* The MPS2 and MPS2+ dev boards are FPGA based (the 2+ has a bigger | 31 | + # This test download a 7.5 MiB compressed image and expand it |
46 | + * FPGA but is otherwise the same as the 2). Since the CPU itself | 32 | + # to 126 MiB. |
47 | + * and most of the devices are in the FPGA, the details of the board | 33 | + image_url = ('https://downloads.openwrt.org/releases/22.03.2/targets/' |
48 | + * as seen by the guest depend significantly on the FPGA image. | 34 | + 'sunxi/cortexa8/openwrt-22.03.2-sunxi-cortexa8-' |
49 | + * This source file covers the following FPGA images, for TrustZone cores: | 35 | + 'cubietech_a10-cubieboard-ext4-sdcard.img.gz') |
50 | + * "mps2-an505" -- Cortex-M33 as documented in ARM Application Note AN505 | 36 | + image_hash = ('94b5ecbfbc0b3b56276e5146b899eafa' |
51 | + * | 37 | + '2ac5dc2d08733d6705af9f144f39f554') |
52 | + * Links to the TRM for the board itself and to the various Application | 38 | + image_path_gz = self.fetch_asset(image_url, asset_hash=image_hash, |
53 | + * Notes which document the FPGA images can be found here: | 39 | + algorithm='sha256') |
54 | + * https://developer.arm.com/products/system-design/development-boards/fpga-prototyping-boards/mps2 | 40 | + image_path = archive.extract(image_path_gz, self.workdir) |
55 | + * | 41 | + image_pow2ceil_expand(image_path) |
56 | + * Board TRM: | ||
57 | + * http://infocenter.arm.com/help/topic/com.arm.doc.100112_0200_06_en/versatile_express_cortex_m_prototyping_systems_v2m_mps2_and_v2m_mps2plus_technical_reference_100112_0200_06_en.pdf | ||
58 | + * Application Note AN505: | ||
59 | + * http://infocenter.arm.com/help/topic/com.arm.doc.dai0505b/index.html | ||
60 | + * | ||
61 | + * The AN505 defers to the Cortex-M33 processor ARMv8M IoT Kit FVP User Guide | ||
62 | + * (ARM ECM0601256) for the details of some of the device layout: | ||
63 | + * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ecm0601256/index.html | ||
64 | + */ | ||
65 | + | 42 | + |
66 | +#include "qemu/osdep.h" | 43 | + self.vm.set_console() |
67 | +#include "qapi/error.h" | 44 | + self.vm.add_args('-drive', 'file=' + image_path + ',if=sd,format=raw', |
68 | +#include "qemu/error-report.h" | 45 | + '-nic', 'user', |
69 | +#include "hw/arm/arm.h" | 46 | + '-no-reboot') |
70 | +#include "hw/arm/armv7m.h" | 47 | + self.vm.launch() |
71 | +#include "hw/or-irq.h" | ||
72 | +#include "hw/boards.h" | ||
73 | +#include "exec/address-spaces.h" | ||
74 | +#include "sysemu/sysemu.h" | ||
75 | +#include "hw/misc/unimp.h" | ||
76 | +#include "hw/char/cmsdk-apb-uart.h" | ||
77 | +#include "hw/timer/cmsdk-apb-timer.h" | ||
78 | +#include "hw/misc/mps2-scc.h" | ||
79 | +#include "hw/misc/mps2-fpgaio.h" | ||
80 | +#include "hw/arm/iotkit.h" | ||
81 | +#include "hw/devices.h" | ||
82 | +#include "net/net.h" | ||
83 | +#include "hw/core/split-irq.h" | ||
84 | + | 48 | + |
85 | +typedef enum MPS2TZFPGAType { | 49 | + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + |
86 | + FPGA_AN505, | 50 | + 'usbcore.nousb ' |
87 | +} MPS2TZFPGAType; | 51 | + 'noreboot') |
88 | + | 52 | + |
89 | +typedef struct { | 53 | + self.wait_for_console_pattern('U-Boot SPL') |
90 | + MachineClass parent; | ||
91 | + MPS2TZFPGAType fpga_type; | ||
92 | + uint32_t scc_id; | ||
93 | +} MPS2TZMachineClass; | ||
94 | + | 54 | + |
95 | +typedef struct { | 55 | + interrupt_interactive_console_until_pattern( |
96 | + MachineState parent; | 56 | + self, 'Hit any key to stop autoboot:', '=>') |
57 | + exec_command_and_wait_for_pattern(self, "setenv extraargs '" + | ||
58 | + kernel_command_line + "'", '=>') | ||
59 | + exec_command_and_wait_for_pattern(self, 'boot', 'Starting kernel ...'); | ||
97 | + | 60 | + |
98 | + IoTKit iotkit; | 61 | + self.wait_for_console_pattern( |
99 | + MemoryRegion psram; | 62 | + 'Please press Enter to activate this console.') |
100 | + MemoryRegion ssram1; | ||
101 | + MemoryRegion ssram1_m; | ||
102 | + MemoryRegion ssram23; | ||
103 | + MPS2SCC scc; | ||
104 | + MPS2FPGAIO fpgaio; | ||
105 | + TZPPC ppc[5]; | ||
106 | + UnimplementedDeviceState ssram_mpc[3]; | ||
107 | + UnimplementedDeviceState spi[5]; | ||
108 | + UnimplementedDeviceState i2c[4]; | ||
109 | + UnimplementedDeviceState i2s_audio; | ||
110 | + UnimplementedDeviceState gpio[5]; | ||
111 | + UnimplementedDeviceState dma[4]; | ||
112 | + UnimplementedDeviceState gfx; | ||
113 | + CMSDKAPBUART uart[5]; | ||
114 | + SplitIRQ sec_resp_splitter; | ||
115 | + qemu_or_irq uart_irq_orgate; | ||
116 | +} MPS2TZMachineState; | ||
117 | + | 63 | + |
118 | +#define TYPE_MPS2TZ_MACHINE "mps2tz" | 64 | + exec_command_and_wait_for_pattern(self, ' ', 'root@') |
119 | +#define TYPE_MPS2TZ_AN505_MACHINE MACHINE_TYPE_NAME("mps2-an505") | ||
120 | + | 65 | + |
121 | +#define MPS2TZ_MACHINE(obj) \ | 66 | + exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', |
122 | + OBJECT_CHECK(MPS2TZMachineState, obj, TYPE_MPS2TZ_MACHINE) | 67 | + 'Allwinner sun4i/sun5i') |
123 | +#define MPS2TZ_MACHINE_GET_CLASS(obj) \ | 68 | + # cubieboard's reboot is not functioning; omit reboot test. |
124 | + OBJECT_GET_CLASS(MPS2TZMachineClass, obj, TYPE_MPS2TZ_MACHINE) | ||
125 | +#define MPS2TZ_MACHINE_CLASS(klass) \ | ||
126 | + OBJECT_CLASS_CHECK(MPS2TZMachineClass, klass, TYPE_MPS2TZ_MACHINE) | ||
127 | + | 69 | + |
128 | +/* Main SYSCLK frequency in Hz */ | 70 | @skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might timeout') |
129 | +#define SYSCLK_FRQ 20000000 | 71 | def test_arm_quanta_gsj(self): |
130 | + | 72 | """ |
131 | +/* Initialize the auxiliary RAM region @mr and map it into | ||
132 | + * the memory map at @base. | ||
133 | + */ | ||
134 | +static void make_ram(MemoryRegion *mr, const char *name, | ||
135 | + hwaddr base, hwaddr size) | ||
136 | +{ | ||
137 | + memory_region_init_ram(mr, NULL, name, size, &error_fatal); | ||
138 | + memory_region_add_subregion(get_system_memory(), base, mr); | ||
139 | +} | ||
140 | + | ||
141 | +/* Create an alias of an entire original MemoryRegion @orig | ||
142 | + * located at @base in the memory map. | ||
143 | + */ | ||
144 | +static void make_ram_alias(MemoryRegion *mr, const char *name, | ||
145 | + MemoryRegion *orig, hwaddr base) | ||
146 | +{ | ||
147 | + memory_region_init_alias(mr, NULL, name, orig, 0, | ||
148 | + memory_region_size(orig)); | ||
149 | + memory_region_add_subregion(get_system_memory(), base, mr); | ||
150 | +} | ||
151 | + | ||
152 | +static void init_sysbus_child(Object *parent, const char *childname, | ||
153 | + void *child, size_t childsize, | ||
154 | + const char *childtype) | ||
155 | +{ | ||
156 | + object_initialize(child, childsize, childtype); | ||
157 | + object_property_add_child(parent, childname, OBJECT(child), &error_abort); | ||
158 | + qdev_set_parent_bus(DEVICE(child), sysbus_get_default()); | ||
159 | + | ||
160 | +} | ||
161 | + | ||
162 | +/* Most of the devices in the AN505 FPGA image sit behind | ||
163 | + * Peripheral Protection Controllers. These data structures | ||
164 | + * define the layout of which devices sit behind which PPCs. | ||
165 | + * The devfn for each port is a function which creates, configures | ||
166 | + * and initializes the device, returning the MemoryRegion which | ||
167 | + * needs to be plugged into the downstream end of the PPC port. | ||
168 | + */ | ||
169 | +typedef MemoryRegion *MakeDevFn(MPS2TZMachineState *mms, void *opaque, | ||
170 | + const char *name, hwaddr size); | ||
171 | + | ||
172 | +typedef struct PPCPortInfo { | ||
173 | + const char *name; | ||
174 | + MakeDevFn *devfn; | ||
175 | + void *opaque; | ||
176 | + hwaddr addr; | ||
177 | + hwaddr size; | ||
178 | +} PPCPortInfo; | ||
179 | + | ||
180 | +typedef struct PPCInfo { | ||
181 | + const char *name; | ||
182 | + PPCPortInfo ports[TZ_NUM_PORTS]; | ||
183 | +} PPCInfo; | ||
184 | + | ||
185 | +static MemoryRegion *make_unimp_dev(MPS2TZMachineState *mms, | ||
186 | + void *opaque, | ||
187 | + const char *name, hwaddr size) | ||
188 | +{ | ||
189 | + /* Initialize, configure and realize a TYPE_UNIMPLEMENTED_DEVICE, | ||
190 | + * and return a pointer to its MemoryRegion. | ||
191 | + */ | ||
192 | + UnimplementedDeviceState *uds = opaque; | ||
193 | + | ||
194 | + init_sysbus_child(OBJECT(mms), name, uds, | ||
195 | + sizeof(UnimplementedDeviceState), | ||
196 | + TYPE_UNIMPLEMENTED_DEVICE); | ||
197 | + qdev_prop_set_string(DEVICE(uds), "name", name); | ||
198 | + qdev_prop_set_uint64(DEVICE(uds), "size", size); | ||
199 | + object_property_set_bool(OBJECT(uds), true, "realized", &error_fatal); | ||
200 | + return sysbus_mmio_get_region(SYS_BUS_DEVICE(uds), 0); | ||
201 | +} | ||
202 | + | ||
203 | +static MemoryRegion *make_uart(MPS2TZMachineState *mms, void *opaque, | ||
204 | + const char *name, hwaddr size) | ||
205 | +{ | ||
206 | + CMSDKAPBUART *uart = opaque; | ||
207 | + int i = uart - &mms->uart[0]; | ||
208 | + Chardev *uartchr = i < MAX_SERIAL_PORTS ? serial_hds[i] : NULL; | ||
209 | + int rxirqno = i * 2; | ||
210 | + int txirqno = i * 2 + 1; | ||
211 | + int combirqno = i + 10; | ||
212 | + SysBusDevice *s; | ||
213 | + DeviceState *iotkitdev = DEVICE(&mms->iotkit); | ||
214 | + DeviceState *orgate_dev = DEVICE(&mms->uart_irq_orgate); | ||
215 | + | ||
216 | + init_sysbus_child(OBJECT(mms), name, uart, | ||
217 | + sizeof(mms->uart[0]), TYPE_CMSDK_APB_UART); | ||
218 | + qdev_prop_set_chr(DEVICE(uart), "chardev", uartchr); | ||
219 | + qdev_prop_set_uint32(DEVICE(uart), "pclk-frq", SYSCLK_FRQ); | ||
220 | + object_property_set_bool(OBJECT(uart), true, "realized", &error_fatal); | ||
221 | + s = SYS_BUS_DEVICE(uart); | ||
222 | + sysbus_connect_irq(s, 0, qdev_get_gpio_in_named(iotkitdev, | ||
223 | + "EXP_IRQ", txirqno)); | ||
224 | + sysbus_connect_irq(s, 1, qdev_get_gpio_in_named(iotkitdev, | ||
225 | + "EXP_IRQ", rxirqno)); | ||
226 | + sysbus_connect_irq(s, 2, qdev_get_gpio_in(orgate_dev, i * 2)); | ||
227 | + sysbus_connect_irq(s, 3, qdev_get_gpio_in(orgate_dev, i * 2 + 1)); | ||
228 | + sysbus_connect_irq(s, 4, qdev_get_gpio_in_named(iotkitdev, | ||
229 | + "EXP_IRQ", combirqno)); | ||
230 | + return sysbus_mmio_get_region(SYS_BUS_DEVICE(uart), 0); | ||
231 | +} | ||
232 | + | ||
233 | +static MemoryRegion *make_scc(MPS2TZMachineState *mms, void *opaque, | ||
234 | + const char *name, hwaddr size) | ||
235 | +{ | ||
236 | + MPS2SCC *scc = opaque; | ||
237 | + DeviceState *sccdev; | ||
238 | + MPS2TZMachineClass *mmc = MPS2TZ_MACHINE_GET_CLASS(mms); | ||
239 | + | ||
240 | + object_initialize(scc, sizeof(mms->scc), TYPE_MPS2_SCC); | ||
241 | + sccdev = DEVICE(scc); | ||
242 | + qdev_set_parent_bus(sccdev, sysbus_get_default()); | ||
243 | + qdev_prop_set_uint32(sccdev, "scc-cfg4", 0x2); | ||
244 | + qdev_prop_set_uint32(sccdev, "scc-aid", 0x02000008); | ||
245 | + qdev_prop_set_uint32(sccdev, "scc-id", mmc->scc_id); | ||
246 | + object_property_set_bool(OBJECT(scc), true, "realized", &error_fatal); | ||
247 | + return sysbus_mmio_get_region(SYS_BUS_DEVICE(sccdev), 0); | ||
248 | +} | ||
249 | + | ||
250 | +static MemoryRegion *make_fpgaio(MPS2TZMachineState *mms, void *opaque, | ||
251 | + const char *name, hwaddr size) | ||
252 | +{ | ||
253 | + MPS2FPGAIO *fpgaio = opaque; | ||
254 | + | ||
255 | + object_initialize(fpgaio, sizeof(mms->fpgaio), TYPE_MPS2_FPGAIO); | ||
256 | + qdev_set_parent_bus(DEVICE(fpgaio), sysbus_get_default()); | ||
257 | + object_property_set_bool(OBJECT(fpgaio), true, "realized", &error_fatal); | ||
258 | + return sysbus_mmio_get_region(SYS_BUS_DEVICE(fpgaio), 0); | ||
259 | +} | ||
260 | + | ||
261 | +static void mps2tz_common_init(MachineState *machine) | ||
262 | +{ | ||
263 | + MPS2TZMachineState *mms = MPS2TZ_MACHINE(machine); | ||
264 | + MachineClass *mc = MACHINE_GET_CLASS(machine); | ||
265 | + MemoryRegion *system_memory = get_system_memory(); | ||
266 | + DeviceState *iotkitdev; | ||
267 | + DeviceState *dev_splitter; | ||
268 | + int i; | ||
269 | + | ||
270 | + if (strcmp(machine->cpu_type, mc->default_cpu_type) != 0) { | ||
271 | + error_report("This board can only be used with CPU %s", | ||
272 | + mc->default_cpu_type); | ||
273 | + exit(1); | ||
274 | + } | ||
275 | + | ||
276 | + init_sysbus_child(OBJECT(machine), "iotkit", &mms->iotkit, | ||
277 | + sizeof(mms->iotkit), TYPE_IOTKIT); | ||
278 | + iotkitdev = DEVICE(&mms->iotkit); | ||
279 | + object_property_set_link(OBJECT(&mms->iotkit), OBJECT(system_memory), | ||
280 | + "memory", &error_abort); | ||
281 | + qdev_prop_set_uint32(iotkitdev, "EXP_NUMIRQ", 92); | ||
282 | + qdev_prop_set_uint32(iotkitdev, "MAINCLK", SYSCLK_FRQ); | ||
283 | + object_property_set_bool(OBJECT(&mms->iotkit), true, "realized", | ||
284 | + &error_fatal); | ||
285 | + | ||
286 | + /* The sec_resp_cfg output from the IoTKit must be split into multiple | ||
287 | + * lines, one for each of the PPCs we create here. | ||
288 | + */ | ||
289 | + object_initialize(&mms->sec_resp_splitter, sizeof(mms->sec_resp_splitter), | ||
290 | + TYPE_SPLIT_IRQ); | ||
291 | + object_property_add_child(OBJECT(machine), "sec-resp-splitter", | ||
292 | + OBJECT(&mms->sec_resp_splitter), &error_abort); | ||
293 | + object_property_set_int(OBJECT(&mms->sec_resp_splitter), 5, | ||
294 | + "num-lines", &error_fatal); | ||
295 | + object_property_set_bool(OBJECT(&mms->sec_resp_splitter), true, | ||
296 | + "realized", &error_fatal); | ||
297 | + dev_splitter = DEVICE(&mms->sec_resp_splitter); | ||
298 | + qdev_connect_gpio_out_named(iotkitdev, "sec_resp_cfg", 0, | ||
299 | + qdev_get_gpio_in(dev_splitter, 0)); | ||
300 | + | ||
301 | + /* The IoTKit sets up much of the memory layout, including | ||
302 | + * the aliases between secure and non-secure regions in the | ||
303 | + * address space. The FPGA itself contains: | ||
304 | + * | ||
305 | + * 0x00000000..0x003fffff SSRAM1 | ||
306 | + * 0x00400000..0x007fffff alias of SSRAM1 | ||
307 | + * 0x28000000..0x283fffff 4MB SSRAM2 + SSRAM3 | ||
308 | + * 0x40100000..0x4fffffff AHB Master Expansion 1 interface devices | ||
309 | + * 0x80000000..0x80ffffff 16MB PSRAM | ||
310 | + */ | ||
311 | + | ||
312 | + /* The FPGA images have an odd combination of different RAMs, | ||
313 | + * because in hardware they are different implementations and | ||
314 | + * connected to different buses, giving varying performance/size | ||
315 | + * tradeoffs. For QEMU they're all just RAM, though. We arbitrarily | ||
316 | + * call the 16MB our "system memory", as it's the largest lump. | ||
317 | + */ | ||
318 | + memory_region_allocate_system_memory(&mms->psram, | ||
319 | + NULL, "mps.ram", 0x01000000); | ||
320 | + memory_region_add_subregion(system_memory, 0x80000000, &mms->psram); | ||
321 | + | ||
322 | + /* The SSRAM memories should all be behind Memory Protection Controllers, | ||
323 | + * but we don't implement that yet. | ||
324 | + */ | ||
325 | + make_ram(&mms->ssram1, "mps.ssram1", 0x00000000, 0x00400000); | ||
326 | + make_ram_alias(&mms->ssram1_m, "mps.ssram1_m", &mms->ssram1, 0x00400000); | ||
327 | + | ||
328 | + make_ram(&mms->ssram23, "mps.ssram23", 0x28000000, 0x00400000); | ||
329 | + | ||
330 | + /* The overflow IRQs for all UARTs are ORed together. | ||
331 | + * Tx, Rx and "combined" IRQs are sent to the NVIC separately. | ||
332 | + * Create the OR gate for this. | ||
333 | + */ | ||
334 | + object_initialize(&mms->uart_irq_orgate, sizeof(mms->uart_irq_orgate), | ||
335 | + TYPE_OR_IRQ); | ||
336 | + object_property_add_child(OBJECT(mms), "uart-irq-orgate", | ||
337 | + OBJECT(&mms->uart_irq_orgate), &error_abort); | ||
338 | + object_property_set_int(OBJECT(&mms->uart_irq_orgate), 10, "num-lines", | ||
339 | + &error_fatal); | ||
340 | + object_property_set_bool(OBJECT(&mms->uart_irq_orgate), true, | ||
341 | + "realized", &error_fatal); | ||
342 | + qdev_connect_gpio_out(DEVICE(&mms->uart_irq_orgate), 0, | ||
343 | + qdev_get_gpio_in_named(iotkitdev, "EXP_IRQ", 15)); | ||
344 | + | ||
345 | + /* Most of the devices in the FPGA are behind Peripheral Protection | ||
346 | + * Controllers. The required order for initializing things is: | ||
347 | + * + initialize the PPC | ||
348 | + * + initialize, configure and realize downstream devices | ||
349 | + * + connect downstream device MemoryRegions to the PPC | ||
350 | + * + realize the PPC | ||
351 | + * + map the PPC's MemoryRegions to the places in the address map | ||
352 | + * where the downstream devices should appear | ||
353 | + * + wire up the PPC's control lines to the IoTKit object | ||
354 | + */ | ||
355 | + | ||
356 | + const PPCInfo ppcs[] = { { | ||
357 | + .name = "apb_ppcexp0", | ||
358 | + .ports = { | ||
359 | + { "ssram-mpc0", make_unimp_dev, &mms->ssram_mpc[0], | ||
360 | + 0x58007000, 0x1000 }, | ||
361 | + { "ssram-mpc1", make_unimp_dev, &mms->ssram_mpc[1], | ||
362 | + 0x58008000, 0x1000 }, | ||
363 | + { "ssram-mpc2", make_unimp_dev, &mms->ssram_mpc[2], | ||
364 | + 0x58009000, 0x1000 }, | ||
365 | + }, | ||
366 | + }, { | ||
367 | + .name = "apb_ppcexp1", | ||
368 | + .ports = { | ||
369 | + { "spi0", make_unimp_dev, &mms->spi[0], 0x40205000, 0x1000 }, | ||
370 | + { "spi1", make_unimp_dev, &mms->spi[1], 0x40206000, 0x1000 }, | ||
371 | + { "spi2", make_unimp_dev, &mms->spi[2], 0x40209000, 0x1000 }, | ||
372 | + { "spi3", make_unimp_dev, &mms->spi[3], 0x4020a000, 0x1000 }, | ||
373 | + { "spi4", make_unimp_dev, &mms->spi[4], 0x4020b000, 0x1000 }, | ||
374 | + { "uart0", make_uart, &mms->uart[0], 0x40200000, 0x1000 }, | ||
375 | + { "uart1", make_uart, &mms->uart[1], 0x40201000, 0x1000 }, | ||
376 | + { "uart2", make_uart, &mms->uart[2], 0x40202000, 0x1000 }, | ||
377 | + { "uart3", make_uart, &mms->uart[3], 0x40203000, 0x1000 }, | ||
378 | + { "uart4", make_uart, &mms->uart[4], 0x40204000, 0x1000 }, | ||
379 | + { "i2c0", make_unimp_dev, &mms->i2c[0], 0x40207000, 0x1000 }, | ||
380 | + { "i2c1", make_unimp_dev, &mms->i2c[1], 0x40208000, 0x1000 }, | ||
381 | + { "i2c2", make_unimp_dev, &mms->i2c[2], 0x4020c000, 0x1000 }, | ||
382 | + { "i2c3", make_unimp_dev, &mms->i2c[3], 0x4020d000, 0x1000 }, | ||
383 | + }, | ||
384 | + }, { | ||
385 | + .name = "apb_ppcexp2", | ||
386 | + .ports = { | ||
387 | + { "scc", make_scc, &mms->scc, 0x40300000, 0x1000 }, | ||
388 | + { "i2s-audio", make_unimp_dev, &mms->i2s_audio, | ||
389 | + 0x40301000, 0x1000 }, | ||
390 | + { "fpgaio", make_fpgaio, &mms->fpgaio, 0x40302000, 0x1000 }, | ||
391 | + }, | ||
392 | + }, { | ||
393 | + .name = "ahb_ppcexp0", | ||
394 | + .ports = { | ||
395 | + { "gfx", make_unimp_dev, &mms->gfx, 0x41000000, 0x140000 }, | ||
396 | + { "gpio0", make_unimp_dev, &mms->gpio[0], 0x40100000, 0x1000 }, | ||
397 | + { "gpio1", make_unimp_dev, &mms->gpio[1], 0x40101000, 0x1000 }, | ||
398 | + { "gpio2", make_unimp_dev, &mms->gpio[2], 0x40102000, 0x1000 }, | ||
399 | + { "gpio3", make_unimp_dev, &mms->gpio[3], 0x40103000, 0x1000 }, | ||
400 | + { "gpio4", make_unimp_dev, &mms->gpio[4], 0x40104000, 0x1000 }, | ||
401 | + }, | ||
402 | + }, { | ||
403 | + .name = "ahb_ppcexp1", | ||
404 | + .ports = { | ||
405 | + { "dma0", make_unimp_dev, &mms->dma[0], 0x40110000, 0x1000 }, | ||
406 | + { "dma1", make_unimp_dev, &mms->dma[1], 0x40111000, 0x1000 }, | ||
407 | + { "dma2", make_unimp_dev, &mms->dma[2], 0x40112000, 0x1000 }, | ||
408 | + { "dma3", make_unimp_dev, &mms->dma[3], 0x40113000, 0x1000 }, | ||
409 | + }, | ||
410 | + }, | ||
411 | + }; | ||
412 | + | ||
413 | + for (i = 0; i < ARRAY_SIZE(ppcs); i++) { | ||
414 | + const PPCInfo *ppcinfo = &ppcs[i]; | ||
415 | + TZPPC *ppc = &mms->ppc[i]; | ||
416 | + DeviceState *ppcdev; | ||
417 | + int port; | ||
418 | + char *gpioname; | ||
419 | + | ||
420 | + init_sysbus_child(OBJECT(machine), ppcinfo->name, ppc, | ||
421 | + sizeof(TZPPC), TYPE_TZ_PPC); | ||
422 | + ppcdev = DEVICE(ppc); | ||
423 | + | ||
424 | + for (port = 0; port < TZ_NUM_PORTS; port++) { | ||
425 | + const PPCPortInfo *pinfo = &ppcinfo->ports[port]; | ||
426 | + MemoryRegion *mr; | ||
427 | + char *portname; | ||
428 | + | ||
429 | + if (!pinfo->devfn) { | ||
430 | + continue; | ||
431 | + } | ||
432 | + | ||
433 | + mr = pinfo->devfn(mms, pinfo->opaque, pinfo->name, pinfo->size); | ||
434 | + portname = g_strdup_printf("port[%d]", port); | ||
435 | + object_property_set_link(OBJECT(ppc), OBJECT(mr), | ||
436 | + portname, &error_fatal); | ||
437 | + g_free(portname); | ||
438 | + } | ||
439 | + | ||
440 | + object_property_set_bool(OBJECT(ppc), true, "realized", &error_fatal); | ||
441 | + | ||
442 | + for (port = 0; port < TZ_NUM_PORTS; port++) { | ||
443 | + const PPCPortInfo *pinfo = &ppcinfo->ports[port]; | ||
444 | + | ||
445 | + if (!pinfo->devfn) { | ||
446 | + continue; | ||
447 | + } | ||
448 | + sysbus_mmio_map(SYS_BUS_DEVICE(ppc), port, pinfo->addr); | ||
449 | + | ||
450 | + gpioname = g_strdup_printf("%s_nonsec", ppcinfo->name); | ||
451 | + qdev_connect_gpio_out_named(iotkitdev, gpioname, port, | ||
452 | + qdev_get_gpio_in_named(ppcdev, | ||
453 | + "cfg_nonsec", | ||
454 | + port)); | ||
455 | + g_free(gpioname); | ||
456 | + gpioname = g_strdup_printf("%s_ap", ppcinfo->name); | ||
457 | + qdev_connect_gpio_out_named(iotkitdev, gpioname, port, | ||
458 | + qdev_get_gpio_in_named(ppcdev, | ||
459 | + "cfg_ap", port)); | ||
460 | + g_free(gpioname); | ||
461 | + } | ||
462 | + | ||
463 | + gpioname = g_strdup_printf("%s_irq_enable", ppcinfo->name); | ||
464 | + qdev_connect_gpio_out_named(iotkitdev, gpioname, 0, | ||
465 | + qdev_get_gpio_in_named(ppcdev, | ||
466 | + "irq_enable", 0)); | ||
467 | + g_free(gpioname); | ||
468 | + gpioname = g_strdup_printf("%s_irq_clear", ppcinfo->name); | ||
469 | + qdev_connect_gpio_out_named(iotkitdev, gpioname, 0, | ||
470 | + qdev_get_gpio_in_named(ppcdev, | ||
471 | + "irq_clear", 0)); | ||
472 | + g_free(gpioname); | ||
473 | + gpioname = g_strdup_printf("%s_irq_status", ppcinfo->name); | ||
474 | + qdev_connect_gpio_out_named(ppcdev, "irq", 0, | ||
475 | + qdev_get_gpio_in_named(iotkitdev, | ||
476 | + gpioname, 0)); | ||
477 | + g_free(gpioname); | ||
478 | + | ||
479 | + qdev_connect_gpio_out(dev_splitter, i, | ||
480 | + qdev_get_gpio_in_named(ppcdev, | ||
481 | + "cfg_sec_resp", 0)); | ||
482 | + } | ||
483 | + | ||
484 | + /* In hardware this is a LAN9220; the LAN9118 is software compatible | ||
485 | + * except that it doesn't support the checksum-offload feature. | ||
486 | + * The ethernet controller is not behind a PPC. | ||
487 | + */ | ||
488 | + lan9118_init(&nd_table[0], 0x42000000, | ||
489 | + qdev_get_gpio_in_named(iotkitdev, "EXP_IRQ", 16)); | ||
490 | + | ||
491 | + create_unimplemented_device("FPGA NS PC", 0x48007000, 0x1000); | ||
492 | + | ||
493 | + armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, 0x400000); | ||
494 | +} | ||
495 | + | ||
496 | +static void mps2tz_class_init(ObjectClass *oc, void *data) | ||
497 | +{ | ||
498 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
499 | + | ||
500 | + mc->init = mps2tz_common_init; | ||
501 | + mc->max_cpus = 1; | ||
502 | +} | ||
503 | + | ||
504 | +static void mps2tz_an505_class_init(ObjectClass *oc, void *data) | ||
505 | +{ | ||
506 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
507 | + MPS2TZMachineClass *mmc = MPS2TZ_MACHINE_CLASS(oc); | ||
508 | + | ||
509 | + mc->desc = "ARM MPS2 with AN505 FPGA image for Cortex-M33"; | ||
510 | + mmc->fpga_type = FPGA_AN505; | ||
511 | + mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m33"); | ||
512 | + mmc->scc_id = 0x41040000 | (505 << 4); | ||
513 | +} | ||
514 | + | ||
515 | +static const TypeInfo mps2tz_info = { | ||
516 | + .name = TYPE_MPS2TZ_MACHINE, | ||
517 | + .parent = TYPE_MACHINE, | ||
518 | + .abstract = true, | ||
519 | + .instance_size = sizeof(MPS2TZMachineState), | ||
520 | + .class_size = sizeof(MPS2TZMachineClass), | ||
521 | + .class_init = mps2tz_class_init, | ||
522 | +}; | ||
523 | + | ||
524 | +static const TypeInfo mps2tz_an505_info = { | ||
525 | + .name = TYPE_MPS2TZ_AN505_MACHINE, | ||
526 | + .parent = TYPE_MPS2TZ_MACHINE, | ||
527 | + .class_init = mps2tz_an505_class_init, | ||
528 | +}; | ||
529 | + | ||
530 | +static void mps2tz_machine_init(void) | ||
531 | +{ | ||
532 | + type_register_static(&mps2tz_info); | ||
533 | + type_register_static(&mps2tz_an505_info); | ||
534 | +} | ||
535 | + | ||
536 | +type_init(mps2tz_machine_init); | ||
537 | -- | 73 | -- |
538 | 2.16.2 | 74 | 2.34.1 |
539 | |||
540 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 3 | Don't dereference CPUTLBEntryFull until we verify that |
4 | the page is valid. Move the other user-only info field | ||
5 | updates after the valid check to match. | ||
6 | |||
7 | Cc: qemu-stable@nongnu.org | ||
8 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1412 | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Message-id: 20180228193125.20577-12-richard.henderson@linaro.org | 10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
11 | Message-id: 20230104190056.305143-1-richard.henderson@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 13 | --- |
8 | target/arm/helper.h | 7 ++++ | 14 | target/arm/sve_helper.c | 14 +++++++++----- |
9 | target/arm/translate-a64.c | 48 ++++++++++++++++++++++- | 15 | 1 file changed, 9 insertions(+), 5 deletions(-) |
10 | target/arm/vec_helper.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++ | ||
11 | 3 files changed, 151 insertions(+), 1 deletion(-) | ||
12 | 16 | ||
13 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 17 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c |
14 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/helper.h | 19 | --- a/target/arm/sve_helper.c |
16 | +++ b/target/arm/helper.h | 20 | +++ b/target/arm/sve_helper.c |
17 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(gvec_qrdmlah_s32, TCG_CALL_NO_RWG, | 21 | @@ -XXX,XX +XXX,XX @@ bool sve_probe_page(SVEHostPage *info, bool nofault, CPUARMState *env, |
18 | DEF_HELPER_FLAGS_5(gvec_qrdmlsh_s32, TCG_CALL_NO_RWG, | 22 | #ifdef CONFIG_USER_ONLY |
19 | void, ptr, ptr, ptr, ptr, i32) | 23 | flags = probe_access_flags(env, addr, access_type, mmu_idx, nofault, |
20 | 24 | &info->host, retaddr); | |
21 | +DEF_HELPER_FLAGS_5(gvec_fcaddh, TCG_CALL_NO_RWG, | 25 | - memset(&info->attrs, 0, sizeof(info->attrs)); |
22 | + void, ptr, ptr, ptr, ptr, i32) | 26 | - /* Require both ANON and MTE; see allocation_tag_mem(). */ |
23 | +DEF_HELPER_FLAGS_5(gvec_fcadds, TCG_CALL_NO_RWG, | 27 | - info->tagged = (flags & PAGE_ANON) && (flags & PAGE_MTE); |
24 | + void, ptr, ptr, ptr, ptr, i32) | 28 | #else |
25 | +DEF_HELPER_FLAGS_5(gvec_fcaddd, TCG_CALL_NO_RWG, | 29 | CPUTLBEntryFull *full; |
26 | + void, ptr, ptr, ptr, ptr, i32) | 30 | flags = probe_access_full(env, addr, access_type, mmu_idx, nofault, |
27 | + | 31 | &info->host, &full, retaddr); |
28 | #ifdef TARGET_AARCH64 | 32 | - info->attrs = full->attrs; |
29 | #include "helper-a64.h" | 33 | - info->tagged = full->pte_attrs == 0xf0; |
30 | #endif | 34 | #endif |
31 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 35 | info->flags = flags; |
32 | index XXXXXXX..XXXXXXX 100644 | 36 | |
33 | --- a/target/arm/translate-a64.c | 37 | @@ -XXX,XX +XXX,XX @@ bool sve_probe_page(SVEHostPage *info, bool nofault, CPUARMState *env, |
34 | +++ b/target/arm/translate-a64.c | 38 | return false; |
35 | @@ -XXX,XX +XXX,XX @@ static void gen_gvec_op3_env(DisasContext *s, bool is_q, int rd, | ||
36 | is_q ? 16 : 8, vec_full_reg_size(s), 0, fn); | ||
37 | } | ||
38 | |||
39 | +/* Expand a 3-operand + fpstatus pointer + simd data value operation using | ||
40 | + * an out-of-line helper. | ||
41 | + */ | ||
42 | +static void gen_gvec_op3_fpst(DisasContext *s, bool is_q, int rd, int rn, | ||
43 | + int rm, bool is_fp16, int data, | ||
44 | + gen_helper_gvec_3_ptr *fn) | ||
45 | +{ | ||
46 | + TCGv_ptr fpst = get_fpstatus_ptr(is_fp16); | ||
47 | + tcg_gen_gvec_3_ptr(vec_full_reg_offset(s, rd), | ||
48 | + vec_full_reg_offset(s, rn), | ||
49 | + vec_full_reg_offset(s, rm), fpst, | ||
50 | + is_q ? 16 : 8, vec_full_reg_size(s), data, fn); | ||
51 | + tcg_temp_free_ptr(fpst); | ||
52 | +} | ||
53 | + | ||
54 | /* Set ZF and NF based on a 64 bit result. This is alas fiddlier | ||
55 | * than the 32 bit equivalent. | ||
56 | */ | ||
57 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) | ||
58 | int size = extract32(insn, 22, 2); | ||
59 | bool u = extract32(insn, 29, 1); | ||
60 | bool is_q = extract32(insn, 30, 1); | ||
61 | - int feature; | ||
62 | + int feature, rot; | ||
63 | |||
64 | switch (u * 16 + opcode) { | ||
65 | case 0x10: /* SQRDMLAH (vector) */ | ||
66 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) | ||
67 | } | ||
68 | feature = ARM_FEATURE_V8_RDM; | ||
69 | break; | ||
70 | + case 0xc: /* FCADD, #90 */ | ||
71 | + case 0xe: /* FCADD, #270 */ | ||
72 | + if (size == 0 | ||
73 | + || (size == 1 && !arm_dc_feature(s, ARM_FEATURE_V8_FP16)) | ||
74 | + || (size == 3 && !is_q)) { | ||
75 | + unallocated_encoding(s); | ||
76 | + return; | ||
77 | + } | ||
78 | + feature = ARM_FEATURE_V8_FCMA; | ||
79 | + break; | ||
80 | default: | ||
81 | unallocated_encoding(s); | ||
82 | return; | ||
83 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) | ||
84 | } | ||
85 | return; | ||
86 | |||
87 | + case 0xc: /* FCADD, #90 */ | ||
88 | + case 0xe: /* FCADD, #270 */ | ||
89 | + rot = extract32(opcode, 1, 1); | ||
90 | + switch (size) { | ||
91 | + case 1: | ||
92 | + gen_gvec_op3_fpst(s, is_q, rd, rn, rm, size == 1, rot, | ||
93 | + gen_helper_gvec_fcaddh); | ||
94 | + break; | ||
95 | + case 2: | ||
96 | + gen_gvec_op3_fpst(s, is_q, rd, rn, rm, size == 1, rot, | ||
97 | + gen_helper_gvec_fcadds); | ||
98 | + break; | ||
99 | + case 3: | ||
100 | + gen_gvec_op3_fpst(s, is_q, rd, rn, rm, size == 1, rot, | ||
101 | + gen_helper_gvec_fcaddd); | ||
102 | + break; | ||
103 | + default: | ||
104 | + g_assert_not_reached(); | ||
105 | + } | ||
106 | + return; | ||
107 | + | ||
108 | default: | ||
109 | g_assert_not_reached(); | ||
110 | } | 39 | } |
111 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | 40 | |
112 | index XXXXXXX..XXXXXXX 100644 | 41 | +#ifdef CONFIG_USER_ONLY |
113 | --- a/target/arm/vec_helper.c | 42 | + memset(&info->attrs, 0, sizeof(info->attrs)); |
114 | +++ b/target/arm/vec_helper.c | 43 | + /* Require both ANON and MTE; see allocation_tag_mem(). */ |
115 | @@ -XXX,XX +XXX,XX @@ | 44 | + info->tagged = (flags & PAGE_ANON) && (flags & PAGE_MTE); |
116 | #include "exec/exec-all.h" | ||
117 | #include "exec/helper-proto.h" | ||
118 | #include "tcg/tcg-gvec-desc.h" | ||
119 | +#include "fpu/softfloat.h" | ||
120 | |||
121 | |||
122 | +/* Note that vector data is stored in host-endian 64-bit chunks, | ||
123 | + so addressing units smaller than that needs a host-endian fixup. */ | ||
124 | +#ifdef HOST_WORDS_BIGENDIAN | ||
125 | +#define H1(x) ((x) ^ 7) | ||
126 | +#define H2(x) ((x) ^ 3) | ||
127 | +#define H4(x) ((x) ^ 1) | ||
128 | +#else | 45 | +#else |
129 | +#define H1(x) (x) | 46 | + info->attrs = full->attrs; |
130 | +#define H2(x) (x) | 47 | + info->tagged = full->pte_attrs == 0xf0; |
131 | +#define H4(x) (x) | ||
132 | +#endif | 48 | +#endif |
133 | + | 49 | + |
134 | #define SET_QC() env->vfp.xregs[ARM_VFP_FPSCR] |= CPSR_Q | 50 | /* Ensure that info->host[] is relative to addr, not addr + mem_off. */ |
135 | 51 | info->host -= mem_off; | |
136 | static void clear_tail(void *vd, uintptr_t opr_sz, uintptr_t max_sz) | 52 | return true; |
137 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_qrdmlsh_s32)(void *vd, void *vn, void *vm, | ||
138 | } | ||
139 | clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
140 | } | ||
141 | + | ||
142 | +void HELPER(gvec_fcaddh)(void *vd, void *vn, void *vm, | ||
143 | + void *vfpst, uint32_t desc) | ||
144 | +{ | ||
145 | + uintptr_t opr_sz = simd_oprsz(desc); | ||
146 | + float16 *d = vd; | ||
147 | + float16 *n = vn; | ||
148 | + float16 *m = vm; | ||
149 | + float_status *fpst = vfpst; | ||
150 | + uint32_t neg_real = extract32(desc, SIMD_DATA_SHIFT, 1); | ||
151 | + uint32_t neg_imag = neg_real ^ 1; | ||
152 | + uintptr_t i; | ||
153 | + | ||
154 | + /* Shift boolean to the sign bit so we can xor to negate. */ | ||
155 | + neg_real <<= 15; | ||
156 | + neg_imag <<= 15; | ||
157 | + | ||
158 | + for (i = 0; i < opr_sz / 2; i += 2) { | ||
159 | + float16 e0 = n[H2(i)]; | ||
160 | + float16 e1 = m[H2(i + 1)] ^ neg_imag; | ||
161 | + float16 e2 = n[H2(i + 1)]; | ||
162 | + float16 e3 = m[H2(i)] ^ neg_real; | ||
163 | + | ||
164 | + d[H2(i)] = float16_add(e0, e1, fpst); | ||
165 | + d[H2(i + 1)] = float16_add(e2, e3, fpst); | ||
166 | + } | ||
167 | + clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
168 | +} | ||
169 | + | ||
170 | +void HELPER(gvec_fcadds)(void *vd, void *vn, void *vm, | ||
171 | + void *vfpst, uint32_t desc) | ||
172 | +{ | ||
173 | + uintptr_t opr_sz = simd_oprsz(desc); | ||
174 | + float32 *d = vd; | ||
175 | + float32 *n = vn; | ||
176 | + float32 *m = vm; | ||
177 | + float_status *fpst = vfpst; | ||
178 | + uint32_t neg_real = extract32(desc, SIMD_DATA_SHIFT, 1); | ||
179 | + uint32_t neg_imag = neg_real ^ 1; | ||
180 | + uintptr_t i; | ||
181 | + | ||
182 | + /* Shift boolean to the sign bit so we can xor to negate. */ | ||
183 | + neg_real <<= 31; | ||
184 | + neg_imag <<= 31; | ||
185 | + | ||
186 | + for (i = 0; i < opr_sz / 4; i += 2) { | ||
187 | + float32 e0 = n[H4(i)]; | ||
188 | + float32 e1 = m[H4(i + 1)] ^ neg_imag; | ||
189 | + float32 e2 = n[H4(i + 1)]; | ||
190 | + float32 e3 = m[H4(i)] ^ neg_real; | ||
191 | + | ||
192 | + d[H4(i)] = float32_add(e0, e1, fpst); | ||
193 | + d[H4(i + 1)] = float32_add(e2, e3, fpst); | ||
194 | + } | ||
195 | + clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
196 | +} | ||
197 | + | ||
198 | +void HELPER(gvec_fcaddd)(void *vd, void *vn, void *vm, | ||
199 | + void *vfpst, uint32_t desc) | ||
200 | +{ | ||
201 | + uintptr_t opr_sz = simd_oprsz(desc); | ||
202 | + float64 *d = vd; | ||
203 | + float64 *n = vn; | ||
204 | + float64 *m = vm; | ||
205 | + float_status *fpst = vfpst; | ||
206 | + uint64_t neg_real = extract64(desc, SIMD_DATA_SHIFT, 1); | ||
207 | + uint64_t neg_imag = neg_real ^ 1; | ||
208 | + uintptr_t i; | ||
209 | + | ||
210 | + /* Shift boolean to the sign bit so we can xor to negate. */ | ||
211 | + neg_real <<= 63; | ||
212 | + neg_imag <<= 63; | ||
213 | + | ||
214 | + for (i = 0; i < opr_sz / 8; i += 2) { | ||
215 | + float64 e0 = n[i]; | ||
216 | + float64 e1 = m[i + 1] ^ neg_imag; | ||
217 | + float64 e2 = n[i + 1]; | ||
218 | + float64 e3 = m[i] ^ neg_real; | ||
219 | + | ||
220 | + d[i] = float64_add(e0, e1, fpst); | ||
221 | + d[i + 1] = float64_add(e2, e3, fpst); | ||
222 | + } | ||
223 | + clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
224 | +} | ||
225 | -- | 53 | -- |
226 | 2.16.2 | 54 | 2.34.1 |
227 | 55 | ||
228 | 56 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 3 | Since pxa255_init() must map the device in the system memory, |
4 | Message-id: 20180228193125.20577-15-richard.henderson@linaro.org | 4 | there is no point in passing get_system_memory() by argument. |
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 5 | |
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20230109115316.2235-2-philmd@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 10 | --- |
8 | target/arm/translate.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++ | 11 | include/hw/arm/pxa.h | 2 +- |
9 | 1 file changed, 61 insertions(+) | 12 | hw/arm/gumstix.c | 3 +-- |
13 | hw/arm/pxa2xx.c | 4 +++- | ||
14 | hw/arm/tosa.c | 2 +- | ||
15 | 4 files changed, 6 insertions(+), 5 deletions(-) | ||
10 | 16 | ||
11 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 17 | diff --git a/include/hw/arm/pxa.h b/include/hw/arm/pxa.h |
12 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate.c | 19 | --- a/include/hw/arm/pxa.h |
14 | +++ b/target/arm/translate.c | 20 | +++ b/include/hw/arm/pxa.h |
15 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn) | 21 | @@ -XXX,XX +XXX,XX @@ struct PXA2xxI2SState { |
16 | return 0; | 22 | |
23 | PXA2xxState *pxa270_init(MemoryRegion *address_space, unsigned int sdram_size, | ||
24 | const char *revision); | ||
25 | -PXA2xxState *pxa255_init(MemoryRegion *address_space, unsigned int sdram_size); | ||
26 | +PXA2xxState *pxa255_init(unsigned int sdram_size); | ||
27 | |||
28 | #endif /* PXA_H */ | ||
29 | diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/hw/arm/gumstix.c | ||
32 | +++ b/hw/arm/gumstix.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static void connex_init(MachineState *machine) | ||
34 | { | ||
35 | PXA2xxState *cpu; | ||
36 | DriveInfo *dinfo; | ||
37 | - MemoryRegion *address_space_mem = get_system_memory(); | ||
38 | |||
39 | uint32_t connex_rom = 0x01000000; | ||
40 | uint32_t connex_ram = 0x04000000; | ||
41 | |||
42 | - cpu = pxa255_init(address_space_mem, connex_ram); | ||
43 | + cpu = pxa255_init(connex_ram); | ||
44 | |||
45 | dinfo = drive_get(IF_PFLASH, 0, 0); | ||
46 | if (!dinfo && !qtest_enabled()) { | ||
47 | diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/hw/arm/pxa2xx.c | ||
50 | +++ b/hw/arm/pxa2xx.c | ||
51 | @@ -XXX,XX +XXX,XX @@ | ||
52 | #include "qemu/error-report.h" | ||
53 | #include "qemu/module.h" | ||
54 | #include "qapi/error.h" | ||
55 | +#include "exec/address-spaces.h" | ||
56 | #include "cpu.h" | ||
57 | #include "hw/sysbus.h" | ||
58 | #include "migration/vmstate.h" | ||
59 | @@ -XXX,XX +XXX,XX @@ PXA2xxState *pxa270_init(MemoryRegion *address_space, | ||
17 | } | 60 | } |
18 | 61 | ||
19 | +/* Advanced SIMD two registers and a scalar extension. | 62 | /* Initialise a PXA255 integrated chip (ARM based core). */ |
20 | + * 31 24 23 22 20 16 12 11 10 9 8 3 0 | 63 | -PXA2xxState *pxa255_init(MemoryRegion *address_space, unsigned int sdram_size) |
21 | + * +-----------------+----+---+----+----+----+---+----+---+----+---------+----+ | 64 | +PXA2xxState *pxa255_init(unsigned int sdram_size) |
22 | + * | 1 1 1 1 1 1 1 0 | o1 | D | o2 | Vn | Vd | 1 | o3 | 0 | o4 | N Q M U | Vm | | ||
23 | + * +-----------------+----+---+----+----+----+---+----+---+----+---------+----+ | ||
24 | + * | ||
25 | + */ | ||
26 | + | ||
27 | +static int disas_neon_insn_2reg_scalar_ext(DisasContext *s, uint32_t insn) | ||
28 | +{ | ||
29 | + int rd, rn, rm, rot, size, opr_sz; | ||
30 | + TCGv_ptr fpst; | ||
31 | + bool q; | ||
32 | + | ||
33 | + q = extract32(insn, 6, 1); | ||
34 | + VFP_DREG_D(rd, insn); | ||
35 | + VFP_DREG_N(rn, insn); | ||
36 | + VFP_DREG_M(rm, insn); | ||
37 | + if ((rd | rn) & q) { | ||
38 | + return 1; | ||
39 | + } | ||
40 | + | ||
41 | + if ((insn & 0xff000f10) == 0xfe000800) { | ||
42 | + /* VCMLA (indexed) -- 1111 1110 S.RR .... .... 1000 ...0 .... */ | ||
43 | + rot = extract32(insn, 20, 2); | ||
44 | + size = extract32(insn, 23, 1); | ||
45 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_FCMA) | ||
46 | + || (!size && !arm_dc_feature(s, ARM_FEATURE_V8_FP16))) { | ||
47 | + return 1; | ||
48 | + } | ||
49 | + } else { | ||
50 | + return 1; | ||
51 | + } | ||
52 | + | ||
53 | + if (s->fp_excp_el) { | ||
54 | + gen_exception_insn(s, 4, EXCP_UDEF, | ||
55 | + syn_fp_access_trap(1, 0xe, false), s->fp_excp_el); | ||
56 | + return 0; | ||
57 | + } | ||
58 | + if (!s->vfp_enabled) { | ||
59 | + return 1; | ||
60 | + } | ||
61 | + | ||
62 | + opr_sz = (1 + q) * 8; | ||
63 | + fpst = get_fpstatus_ptr(1); | ||
64 | + tcg_gen_gvec_3_ptr(vfp_reg_offset(1, rd), | ||
65 | + vfp_reg_offset(1, rn), | ||
66 | + vfp_reg_offset(1, rm), fpst, | ||
67 | + opr_sz, opr_sz, rot, | ||
68 | + size ? gen_helper_gvec_fcmlas_idx | ||
69 | + : gen_helper_gvec_fcmlah_idx); | ||
70 | + tcg_temp_free_ptr(fpst); | ||
71 | + return 0; | ||
72 | +} | ||
73 | + | ||
74 | static int disas_coproc_insn(DisasContext *s, uint32_t insn) | ||
75 | { | 65 | { |
76 | int cpnum, is64, crn, crm, opc1, opc2, isread, rt, rt2; | 66 | + MemoryRegion *address_space = get_system_memory(); |
77 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 67 | PXA2xxState *s; |
78 | goto illegal_op; | 68 | int i; |
79 | } | 69 | DriveInfo *dinfo; |
80 | return; | 70 | diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c |
81 | + } else if ((insn & 0x0f000a00) == 0x0e000800 | 71 | index XXXXXXX..XXXXXXX 100644 |
82 | + && arm_dc_feature(s, ARM_FEATURE_V8)) { | 72 | --- a/hw/arm/tosa.c |
83 | + if (disas_neon_insn_2reg_scalar_ext(s, insn)) { | 73 | +++ b/hw/arm/tosa.c |
84 | + goto illegal_op; | 74 | @@ -XXX,XX +XXX,XX @@ static void tosa_init(MachineState *machine) |
85 | + } | 75 | TC6393xbState *tmio; |
86 | + return; | 76 | DeviceState *scp0, *scp1; |
87 | } else if ((insn & 0x0fe00000) == 0x0c400000) { | 77 | |
88 | /* Coprocessor double register transfer. */ | 78 | - mpu = pxa255_init(address_space_mem, tosa_binfo.ram_size); |
89 | ARCH(5TE); | 79 | + mpu = pxa255_init(tosa_binfo.ram_size); |
80 | |||
81 | memory_region_init_rom(rom, NULL, "tosa.rom", TOSA_ROM, &error_fatal); | ||
82 | memory_region_add_subregion(address_space_mem, 0, rom); | ||
90 | -- | 83 | -- |
91 | 2.16.2 | 84 | 2.34.1 |
92 | 85 | ||
93 | 86 | diff view generated by jsdifflib |
1 | Add a Cortex-M33 definition. The M33 is an M profile CPU | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | which implements the ARM v8M architecture, including the | ||
3 | M profile Security Extension. | ||
4 | 2 | ||
3 | Since pxa270_init() must map the device in the system memory, | ||
4 | there is no point in passing get_system_memory() by argument. | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20230109115316.2235-3-philmd@linaro.org | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20180220180325.29818-9-peter.maydell@linaro.org | ||
8 | --- | 10 | --- |
9 | target/arm/cpu.c | 31 +++++++++++++++++++++++++++++++ | 11 | include/hw/arm/pxa.h | 3 +-- |
10 | 1 file changed, 31 insertions(+) | 12 | hw/arm/gumstix.c | 3 +-- |
13 | hw/arm/mainstone.c | 10 ++++------ | ||
14 | hw/arm/pxa2xx.c | 4 ++-- | ||
15 | hw/arm/spitz.c | 6 ++---- | ||
16 | hw/arm/z2.c | 3 +-- | ||
17 | 6 files changed, 11 insertions(+), 18 deletions(-) | ||
11 | 18 | ||
12 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 19 | diff --git a/include/hw/arm/pxa.h b/include/hw/arm/pxa.h |
13 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/cpu.c | 21 | --- a/include/hw/arm/pxa.h |
15 | +++ b/target/arm/cpu.c | 22 | +++ b/include/hw/arm/pxa.h |
16 | @@ -XXX,XX +XXX,XX @@ static void cortex_m4_initfn(Object *obj) | 23 | @@ -XXX,XX +XXX,XX @@ struct PXA2xxI2SState { |
17 | cpu->id_isar5 = 0x00000000; | 24 | |
25 | # define PA_FMT "0x%08lx" | ||
26 | |||
27 | -PXA2xxState *pxa270_init(MemoryRegion *address_space, unsigned int sdram_size, | ||
28 | - const char *revision); | ||
29 | +PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision); | ||
30 | PXA2xxState *pxa255_init(unsigned int sdram_size); | ||
31 | |||
32 | #endif /* PXA_H */ | ||
33 | diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/hw/arm/gumstix.c | ||
36 | +++ b/hw/arm/gumstix.c | ||
37 | @@ -XXX,XX +XXX,XX @@ static void verdex_init(MachineState *machine) | ||
38 | { | ||
39 | PXA2xxState *cpu; | ||
40 | DriveInfo *dinfo; | ||
41 | - MemoryRegion *address_space_mem = get_system_memory(); | ||
42 | |||
43 | uint32_t verdex_rom = 0x02000000; | ||
44 | uint32_t verdex_ram = 0x10000000; | ||
45 | |||
46 | - cpu = pxa270_init(address_space_mem, verdex_ram, machine->cpu_type); | ||
47 | + cpu = pxa270_init(verdex_ram, machine->cpu_type); | ||
48 | |||
49 | dinfo = drive_get(IF_PFLASH, 0, 0); | ||
50 | if (!dinfo && !qtest_enabled()) { | ||
51 | diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/hw/arm/mainstone.c | ||
54 | +++ b/hw/arm/mainstone.c | ||
55 | @@ -XXX,XX +XXX,XX @@ static struct arm_boot_info mainstone_binfo = { | ||
56 | .ram_size = 0x04000000, | ||
57 | }; | ||
58 | |||
59 | -static void mainstone_common_init(MemoryRegion *address_space_mem, | ||
60 | - MachineState *machine, | ||
61 | +static void mainstone_common_init(MachineState *machine, | ||
62 | enum mainstone_model_e model, int arm_id) | ||
63 | { | ||
64 | uint32_t sector_len = 256 * 1024; | ||
65 | @@ -XXX,XX +XXX,XX @@ static void mainstone_common_init(MemoryRegion *address_space_mem, | ||
66 | MemoryRegion *rom = g_new(MemoryRegion, 1); | ||
67 | |||
68 | /* Setup CPU & memory */ | ||
69 | - mpu = pxa270_init(address_space_mem, mainstone_binfo.ram_size, | ||
70 | - machine->cpu_type); | ||
71 | + mpu = pxa270_init(mainstone_binfo.ram_size, machine->cpu_type); | ||
72 | memory_region_init_rom(rom, NULL, "mainstone.rom", MAINSTONE_ROM, | ||
73 | &error_fatal); | ||
74 | - memory_region_add_subregion(address_space_mem, 0, rom); | ||
75 | + memory_region_add_subregion(get_system_memory(), 0x00000000, rom); | ||
76 | |||
77 | /* There are two 32MiB flash devices on the board */ | ||
78 | for (i = 0; i < 2; i ++) { | ||
79 | @@ -XXX,XX +XXX,XX @@ static void mainstone_common_init(MemoryRegion *address_space_mem, | ||
80 | |||
81 | static void mainstone_init(MachineState *machine) | ||
82 | { | ||
83 | - mainstone_common_init(get_system_memory(), machine, mainstone, 0x196); | ||
84 | + mainstone_common_init(machine, mainstone, 0x196); | ||
18 | } | 85 | } |
19 | 86 | ||
20 | +static void cortex_m33_initfn(Object *obj) | 87 | static void mainstone2_machine_init(MachineClass *mc) |
21 | +{ | 88 | diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c |
22 | + ARMCPU *cpu = ARM_CPU(obj); | 89 | index XXXXXXX..XXXXXXX 100644 |
23 | + | 90 | --- a/hw/arm/pxa2xx.c |
24 | + set_feature(&cpu->env, ARM_FEATURE_V8); | 91 | +++ b/hw/arm/pxa2xx.c |
25 | + set_feature(&cpu->env, ARM_FEATURE_M); | 92 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_reset(void *opaque, int line, int level) |
26 | + set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); | 93 | } |
27 | + set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | 94 | |
28 | + cpu->midr = 0x410fd213; /* r0p3 */ | 95 | /* Initialise a PXA270 integrated chip (ARM based core). */ |
29 | + cpu->pmsav7_dregion = 16; | 96 | -PXA2xxState *pxa270_init(MemoryRegion *address_space, |
30 | + cpu->sau_sregion = 8; | 97 | - unsigned int sdram_size, const char *cpu_type) |
31 | + cpu->id_pfr0 = 0x00000030; | 98 | +PXA2xxState *pxa270_init(unsigned int sdram_size, const char *cpu_type) |
32 | + cpu->id_pfr1 = 0x00000210; | ||
33 | + cpu->id_dfr0 = 0x00200000; | ||
34 | + cpu->id_afr0 = 0x00000000; | ||
35 | + cpu->id_mmfr0 = 0x00101F40; | ||
36 | + cpu->id_mmfr1 = 0x00000000; | ||
37 | + cpu->id_mmfr2 = 0x01000000; | ||
38 | + cpu->id_mmfr3 = 0x00000000; | ||
39 | + cpu->id_isar0 = 0x01101110; | ||
40 | + cpu->id_isar1 = 0x02212000; | ||
41 | + cpu->id_isar2 = 0x20232232; | ||
42 | + cpu->id_isar3 = 0x01111131; | ||
43 | + cpu->id_isar4 = 0x01310132; | ||
44 | + cpu->id_isar5 = 0x00000000; | ||
45 | + cpu->clidr = 0x00000000; | ||
46 | + cpu->ctr = 0x8000c000; | ||
47 | +} | ||
48 | + | ||
49 | static void arm_v7m_class_init(ObjectClass *oc, void *data) | ||
50 | { | 99 | { |
51 | CPUClass *cc = CPU_CLASS(oc); | 100 | + MemoryRegion *address_space = get_system_memory(); |
52 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_cpus[] = { | 101 | PXA2xxState *s; |
53 | .class_init = arm_v7m_class_init }, | 102 | int i; |
54 | { .name = "cortex-m4", .initfn = cortex_m4_initfn, | 103 | DriveInfo *dinfo; |
55 | .class_init = arm_v7m_class_init }, | 104 | diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c |
56 | + { .name = "cortex-m33", .initfn = cortex_m33_initfn, | 105 | index XXXXXXX..XXXXXXX 100644 |
57 | + .class_init = arm_v7m_class_init }, | 106 | --- a/hw/arm/spitz.c |
58 | { .name = "cortex-r5", .initfn = cortex_r5_initfn }, | 107 | +++ b/hw/arm/spitz.c |
59 | { .name = "cortex-a7", .initfn = cortex_a7_initfn }, | 108 | @@ -XXX,XX +XXX,XX @@ static void spitz_common_init(MachineState *machine) |
60 | { .name = "cortex-a8", .initfn = cortex_a8_initfn }, | 109 | SpitzMachineState *sms = SPITZ_MACHINE(machine); |
110 | enum spitz_model_e model = smc->model; | ||
111 | PXA2xxState *mpu; | ||
112 | - MemoryRegion *address_space_mem = get_system_memory(); | ||
113 | MemoryRegion *rom = g_new(MemoryRegion, 1); | ||
114 | |||
115 | /* Setup CPU & memory */ | ||
116 | - mpu = pxa270_init(address_space_mem, spitz_binfo.ram_size, | ||
117 | - machine->cpu_type); | ||
118 | + mpu = pxa270_init(spitz_binfo.ram_size, machine->cpu_type); | ||
119 | sms->mpu = mpu; | ||
120 | |||
121 | sl_flash_register(mpu, (model == spitz) ? FLASH_128M : FLASH_1024M); | ||
122 | |||
123 | memory_region_init_rom(rom, NULL, "spitz.rom", SPITZ_ROM, &error_fatal); | ||
124 | - memory_region_add_subregion(address_space_mem, 0, rom); | ||
125 | + memory_region_add_subregion(get_system_memory(), 0, rom); | ||
126 | |||
127 | /* Setup peripherals */ | ||
128 | spitz_keyboard_register(mpu); | ||
129 | diff --git a/hw/arm/z2.c b/hw/arm/z2.c | ||
130 | index XXXXXXX..XXXXXXX 100644 | ||
131 | --- a/hw/arm/z2.c | ||
132 | +++ b/hw/arm/z2.c | ||
133 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo aer915_info = { | ||
134 | |||
135 | static void z2_init(MachineState *machine) | ||
136 | { | ||
137 | - MemoryRegion *address_space_mem = get_system_memory(); | ||
138 | uint32_t sector_len = 0x10000; | ||
139 | PXA2xxState *mpu; | ||
140 | DriveInfo *dinfo; | ||
141 | @@ -XXX,XX +XXX,XX @@ static void z2_init(MachineState *machine) | ||
142 | DeviceState *wm; | ||
143 | |||
144 | /* Setup CPU & memory */ | ||
145 | - mpu = pxa270_init(address_space_mem, z2_binfo.ram_size, machine->cpu_type); | ||
146 | + mpu = pxa270_init(z2_binfo.ram_size, machine->cpu_type); | ||
147 | |||
148 | dinfo = drive_get(IF_PFLASH, 0, 0); | ||
149 | if (!pflash_cfi01_register(Z2_FLASH_BASE, "z2.flash0", Z2_FLASH_SIZE, | ||
61 | -- | 150 | -- |
62 | 2.16.2 | 151 | 2.34.1 |
63 | 152 | ||
64 | 153 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 3 | IEC binary prefixes ease code review: the unit is explicit. |
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | |
5 | Message-id: 20180228193125.20577-14-richard.henderson@linaro.org | 5 | Add definitions for RAM / Flash / Flash blocksize. |
6 | |||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20230109115316.2235-4-philmd@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 11 | --- |
8 | target/arm/translate.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ | 12 | hw/arm/collie.c | 16 ++++++++++------ |
9 | 1 file changed, 68 insertions(+) | 13 | 1 file changed, 10 insertions(+), 6 deletions(-) |
10 | 14 | ||
11 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 15 | diff --git a/hw/arm/collie.c b/hw/arm/collie.c |
12 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate.c | 17 | --- a/hw/arm/collie.c |
14 | +++ b/target/arm/translate.c | 18 | +++ b/hw/arm/collie.c |
15 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 19 | @@ -XXX,XX +XXX,XX @@ |
16 | return 0; | 20 | #include "cpu.h" |
21 | #include "qom/object.h" | ||
22 | |||
23 | +#define RAM_SIZE (512 * MiB) | ||
24 | +#define FLASH_SIZE (32 * MiB) | ||
25 | +#define FLASH_SECTOR_SIZE (64 * KiB) | ||
26 | + | ||
27 | struct CollieMachineState { | ||
28 | MachineState parent; | ||
29 | |||
30 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(CollieMachineState, COLLIE_MACHINE) | ||
31 | |||
32 | static struct arm_boot_info collie_binfo = { | ||
33 | .loader_start = SA_SDCS0, | ||
34 | - .ram_size = 0x20000000, | ||
35 | + .ram_size = RAM_SIZE, | ||
36 | }; | ||
37 | |||
38 | static void collie_init(MachineState *machine) | ||
39 | @@ -XXX,XX +XXX,XX @@ static void collie_init(MachineState *machine) | ||
40 | memory_region_add_subregion(get_system_memory(), SA_SDCS0, machine->ram); | ||
41 | |||
42 | dinfo = drive_get(IF_PFLASH, 0, 0); | ||
43 | - pflash_cfi01_register(SA_CS0, "collie.fl1", 0x02000000, | ||
44 | + pflash_cfi01_register(SA_CS0, "collie.fl1", FLASH_SIZE, | ||
45 | dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, | ||
46 | - 64 * KiB, 4, 0x00, 0x00, 0x00, 0x00, 0); | ||
47 | + FLASH_SECTOR_SIZE, 4, 0x00, 0x00, 0x00, 0x00, 0); | ||
48 | |||
49 | dinfo = drive_get(IF_PFLASH, 0, 1); | ||
50 | - pflash_cfi01_register(SA_CS1, "collie.fl2", 0x02000000, | ||
51 | + pflash_cfi01_register(SA_CS1, "collie.fl2", FLASH_SIZE, | ||
52 | dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, | ||
53 | - 64 * KiB, 4, 0x00, 0x00, 0x00, 0x00, 0); | ||
54 | + FLASH_SECTOR_SIZE, 4, 0x00, 0x00, 0x00, 0x00, 0); | ||
55 | |||
56 | sysbus_create_simple("scoop", 0x40800000, NULL); | ||
57 | |||
58 | @@ -XXX,XX +XXX,XX @@ static void collie_machine_class_init(ObjectClass *oc, void *data) | ||
59 | mc->init = collie_init; | ||
60 | mc->ignore_memory_transaction_failures = true; | ||
61 | mc->default_cpu_type = ARM_CPU_TYPE_NAME("sa1110"); | ||
62 | - mc->default_ram_size = 0x20000000; | ||
63 | + mc->default_ram_size = RAM_SIZE; | ||
64 | mc->default_ram_id = "strongarm.sdram"; | ||
17 | } | 65 | } |
18 | 66 | ||
19 | +/* Advanced SIMD three registers of the same length extension. | ||
20 | + * 31 25 23 22 20 16 12 11 10 9 8 3 0 | ||
21 | + * +---------------+-----+---+-----+----+----+---+----+---+----+---------+----+ | ||
22 | + * | 1 1 1 1 1 1 0 | op1 | D | op2 | Vn | Vd | 1 | o3 | 0 | o4 | N Q M U | Vm | | ||
23 | + * +---------------+-----+---+-----+----+----+---+----+---+----+---------+----+ | ||
24 | + */ | ||
25 | +static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn) | ||
26 | +{ | ||
27 | + gen_helper_gvec_3_ptr *fn_gvec_ptr; | ||
28 | + int rd, rn, rm, rot, size, opr_sz; | ||
29 | + TCGv_ptr fpst; | ||
30 | + bool q; | ||
31 | + | ||
32 | + q = extract32(insn, 6, 1); | ||
33 | + VFP_DREG_D(rd, insn); | ||
34 | + VFP_DREG_N(rn, insn); | ||
35 | + VFP_DREG_M(rm, insn); | ||
36 | + if ((rd | rn | rm) & q) { | ||
37 | + return 1; | ||
38 | + } | ||
39 | + | ||
40 | + if ((insn & 0xfe200f10) == 0xfc200800) { | ||
41 | + /* VCMLA -- 1111 110R R.1S .... .... 1000 ...0 .... */ | ||
42 | + size = extract32(insn, 20, 1); | ||
43 | + rot = extract32(insn, 23, 2); | ||
44 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_FCMA) | ||
45 | + || (!size && !arm_dc_feature(s, ARM_FEATURE_V8_FP16))) { | ||
46 | + return 1; | ||
47 | + } | ||
48 | + fn_gvec_ptr = size ? gen_helper_gvec_fcmlas : gen_helper_gvec_fcmlah; | ||
49 | + } else if ((insn & 0xfea00f10) == 0xfc800800) { | ||
50 | + /* VCADD -- 1111 110R 1.0S .... .... 1000 ...0 .... */ | ||
51 | + size = extract32(insn, 20, 1); | ||
52 | + rot = extract32(insn, 24, 1); | ||
53 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_FCMA) | ||
54 | + || (!size && !arm_dc_feature(s, ARM_FEATURE_V8_FP16))) { | ||
55 | + return 1; | ||
56 | + } | ||
57 | + fn_gvec_ptr = size ? gen_helper_gvec_fcadds : gen_helper_gvec_fcaddh; | ||
58 | + } else { | ||
59 | + return 1; | ||
60 | + } | ||
61 | + | ||
62 | + if (s->fp_excp_el) { | ||
63 | + gen_exception_insn(s, 4, EXCP_UDEF, | ||
64 | + syn_fp_access_trap(1, 0xe, false), s->fp_excp_el); | ||
65 | + return 0; | ||
66 | + } | ||
67 | + if (!s->vfp_enabled) { | ||
68 | + return 1; | ||
69 | + } | ||
70 | + | ||
71 | + opr_sz = (1 + q) * 8; | ||
72 | + fpst = get_fpstatus_ptr(1); | ||
73 | + tcg_gen_gvec_3_ptr(vfp_reg_offset(1, rd), | ||
74 | + vfp_reg_offset(1, rn), | ||
75 | + vfp_reg_offset(1, rm), fpst, | ||
76 | + opr_sz, opr_sz, rot, fn_gvec_ptr); | ||
77 | + tcg_temp_free_ptr(fpst); | ||
78 | + return 0; | ||
79 | +} | ||
80 | + | ||
81 | static int disas_coproc_insn(DisasContext *s, uint32_t insn) | ||
82 | { | ||
83 | int cpnum, is64, crn, crm, opc1, opc2, isread, rt, rt2; | ||
84 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
85 | } | ||
86 | } | ||
87 | } | ||
88 | + } else if ((insn & 0x0e000a00) == 0x0c000800 | ||
89 | + && arm_dc_feature(s, ARM_FEATURE_V8)) { | ||
90 | + if (disas_neon_insn_3same_ext(s, insn)) { | ||
91 | + goto illegal_op; | ||
92 | + } | ||
93 | + return; | ||
94 | } else if ((insn & 0x0fe00000) == 0x0c400000) { | ||
95 | /* Coprocessor double register transfer. */ | ||
96 | ARCH(5TE); | ||
97 | -- | 67 | -- |
98 | 2.16.2 | 68 | 2.34.1 |
99 | 69 | ||
100 | 70 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Allow the translate subroutines to return false for invalid insns. | 3 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
4 | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | |
5 | At present we can of course invoke an invalid insn exception from within | 5 | Message-id: 20230109115316.2235-5-philmd@linaro.org |
6 | the translate subroutine, but in the short term this consolidates code. | ||
7 | In the long term it would allow the decodetree language to support | ||
8 | overlapping patterns for ISA extensions. | ||
9 | |||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20180227232618.2908-1-richard.henderson@linaro.org | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 7 | --- |
15 | scripts/decodetree.py | 5 ++--- | 8 | hw/arm/collie.c | 17 +++++++---------- |
16 | 1 file changed, 2 insertions(+), 3 deletions(-) | 9 | 1 file changed, 7 insertions(+), 10 deletions(-) |
17 | 10 | ||
18 | diff --git a/scripts/decodetree.py b/scripts/decodetree.py | 11 | diff --git a/hw/arm/collie.c b/hw/arm/collie.c |
19 | index XXXXXXX..XXXXXXX 100755 | 12 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/scripts/decodetree.py | 13 | --- a/hw/arm/collie.c |
21 | +++ b/scripts/decodetree.py | 14 | +++ b/hw/arm/collie.c |
22 | @@ -XXX,XX +XXX,XX @@ class Pattern(General): | 15 | @@ -XXX,XX +XXX,XX @@ static struct arm_boot_info collie_binfo = { |
23 | global translate_prefix | 16 | |
24 | output('typedef ', self.base.base.struct_name(), | 17 | static void collie_init(MachineState *machine) |
25 | ' arg_', self.name, ';\n') | 18 | { |
26 | - output(translate_scope, 'void ', translate_prefix, '_', self.name, | 19 | - DriveInfo *dinfo; |
27 | + output(translate_scope, 'bool ', translate_prefix, '_', self.name, | 20 | MachineClass *mc = MACHINE_GET_CLASS(machine); |
28 | '(DisasContext *ctx, arg_', self.name, | 21 | CollieMachineState *cms = COLLIE_MACHINE(machine); |
29 | ' *a, ', insntype, ' insn);\n') | 22 | |
30 | 23 | @@ -XXX,XX +XXX,XX @@ static void collie_init(MachineState *machine) | |
31 | @@ -XXX,XX +XXX,XX @@ class Pattern(General): | 24 | |
32 | output(ind, self.base.extract_name(), '(&u.f_', arg, ', insn);\n') | 25 | memory_region_add_subregion(get_system_memory(), SA_SDCS0, machine->ram); |
33 | for n, f in self.fields.items(): | 26 | |
34 | output(ind, 'u.f_', arg, '.', n, ' = ', f.str_extract(), ';\n') | 27 | - dinfo = drive_get(IF_PFLASH, 0, 0); |
35 | - output(ind, translate_prefix, '_', self.name, | 28 | - pflash_cfi01_register(SA_CS0, "collie.fl1", FLASH_SIZE, |
36 | + output(ind, 'return ', translate_prefix, '_', self.name, | 29 | - dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, |
37 | '(ctx, &u.f_', arg, ', insn);\n') | 30 | - FLASH_SECTOR_SIZE, 4, 0x00, 0x00, 0x00, 0x00, 0); |
38 | - output(ind, 'return true;\n') | 31 | - |
39 | # end Pattern | 32 | - dinfo = drive_get(IF_PFLASH, 0, 1); |
40 | 33 | - pflash_cfi01_register(SA_CS1, "collie.fl2", FLASH_SIZE, | |
34 | - dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, | ||
35 | - FLASH_SECTOR_SIZE, 4, 0x00, 0x00, 0x00, 0x00, 0); | ||
36 | + for (unsigned i = 0; i < 2; i++) { | ||
37 | + DriveInfo *dinfo = drive_get(IF_PFLASH, 0, i); | ||
38 | + pflash_cfi01_register(i ? SA_CS1 : SA_CS0, | ||
39 | + i ? "collie.fl2" : "collie.fl1", FLASH_SIZE, | ||
40 | + dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, | ||
41 | + FLASH_SECTOR_SIZE, 4, 0x00, 0x00, 0x00, 0x00, 0); | ||
42 | + } | ||
43 | |||
44 | sysbus_create_simple("scoop", 0x40800000, NULL); | ||
41 | 45 | ||
42 | -- | 46 | -- |
43 | 2.16.2 | 47 | 2.34.1 |
44 | 48 | ||
45 | 49 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 3 | Add a comment describing the Connex uses a Numonyx RC28F128J3F75 |
4 | Message-id: 20180228193125.20577-13-richard.henderson@linaro.org | 4 | flash, and the Verdex uses a Micron RC28F256P30TFA. |
5 | |||
6 | Correct the Verdex machine description (we model the 'Pro' board). | ||
7 | |||
8 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20230109115316.2235-6-philmd@linaro.org | ||
11 | Message-Id: <20200223231044.8003-3-philmd@redhat.com> | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | [PMM: renamed e1/e2/e3/e4 to use the same naming as the version | ||
7 | of the pseudocode in the Arm ARM] | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | 13 | --- |
10 | target/arm/helper.h | 11 ++++ | 14 | hw/arm/gumstix.c | 6 ++++-- |
11 | target/arm/translate-a64.c | 94 +++++++++++++++++++++++++--- | 15 | 1 file changed, 4 insertions(+), 2 deletions(-) |
12 | target/arm/vec_helper.c | 149 +++++++++++++++++++++++++++++++++++++++++++++ | ||
13 | 3 files changed, 246 insertions(+), 8 deletions(-) | ||
14 | 16 | ||
15 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 17 | diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c |
16 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/helper.h | 19 | --- a/hw/arm/gumstix.c |
18 | +++ b/target/arm/helper.h | 20 | +++ b/hw/arm/gumstix.c |
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(gvec_fcadds, TCG_CALL_NO_RWG, | 21 | @@ -XXX,XX +XXX,XX @@ |
20 | DEF_HELPER_FLAGS_5(gvec_fcaddd, TCG_CALL_NO_RWG, | 22 | * Contributions after 2012-01-13 are licensed under the terms of the |
21 | void, ptr, ptr, ptr, ptr, i32) | 23 | * GNU GPL, version 2 or (at your option) any later version. |
22 | 24 | */ | |
23 | +DEF_HELPER_FLAGS_5(gvec_fcmlah, TCG_CALL_NO_RWG, | 25 | - |
24 | + void, ptr, ptr, ptr, ptr, i32) | ||
25 | +DEF_HELPER_FLAGS_5(gvec_fcmlah_idx, TCG_CALL_NO_RWG, | ||
26 | + void, ptr, ptr, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_5(gvec_fcmlas, TCG_CALL_NO_RWG, | ||
28 | + void, ptr, ptr, ptr, ptr, i32) | ||
29 | +DEF_HELPER_FLAGS_5(gvec_fcmlas_idx, TCG_CALL_NO_RWG, | ||
30 | + void, ptr, ptr, ptr, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_5(gvec_fcmlad, TCG_CALL_NO_RWG, | ||
32 | + void, ptr, ptr, ptr, ptr, i32) | ||
33 | + | 26 | + |
34 | #ifdef TARGET_AARCH64 | 27 | /* |
35 | #include "helper-a64.h" | 28 | * Example usage: |
36 | #endif | 29 | * |
37 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 30 | @@ -XXX,XX +XXX,XX @@ static void connex_init(MachineState *machine) |
38 | index XXXXXXX..XXXXXXX 100644 | 31 | exit(1); |
39 | --- a/target/arm/translate-a64.c | ||
40 | +++ b/target/arm/translate-a64.c | ||
41 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) | ||
42 | } | ||
43 | feature = ARM_FEATURE_V8_RDM; | ||
44 | break; | ||
45 | + case 0x8: /* FCMLA, #0 */ | ||
46 | + case 0x9: /* FCMLA, #90 */ | ||
47 | + case 0xa: /* FCMLA, #180 */ | ||
48 | + case 0xb: /* FCMLA, #270 */ | ||
49 | case 0xc: /* FCADD, #90 */ | ||
50 | case 0xe: /* FCADD, #270 */ | ||
51 | if (size == 0 | ||
52 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) | ||
53 | } | ||
54 | return; | ||
55 | |||
56 | + case 0x8: /* FCMLA, #0 */ | ||
57 | + case 0x9: /* FCMLA, #90 */ | ||
58 | + case 0xa: /* FCMLA, #180 */ | ||
59 | + case 0xb: /* FCMLA, #270 */ | ||
60 | + rot = extract32(opcode, 0, 2); | ||
61 | + switch (size) { | ||
62 | + case 1: | ||
63 | + gen_gvec_op3_fpst(s, is_q, rd, rn, rm, true, rot, | ||
64 | + gen_helper_gvec_fcmlah); | ||
65 | + break; | ||
66 | + case 2: | ||
67 | + gen_gvec_op3_fpst(s, is_q, rd, rn, rm, false, rot, | ||
68 | + gen_helper_gvec_fcmlas); | ||
69 | + break; | ||
70 | + case 3: | ||
71 | + gen_gvec_op3_fpst(s, is_q, rd, rn, rm, false, rot, | ||
72 | + gen_helper_gvec_fcmlad); | ||
73 | + break; | ||
74 | + default: | ||
75 | + g_assert_not_reached(); | ||
76 | + } | ||
77 | + return; | ||
78 | + | ||
79 | case 0xc: /* FCADD, #90 */ | ||
80 | case 0xe: /* FCADD, #270 */ | ||
81 | rot = extract32(opcode, 1, 1); | ||
82 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | ||
83 | int rn = extract32(insn, 5, 5); | ||
84 | int rd = extract32(insn, 0, 5); | ||
85 | bool is_long = false; | ||
86 | - bool is_fp = false; | ||
87 | + int is_fp = 0; | ||
88 | bool is_fp16 = false; | ||
89 | int index; | ||
90 | TCGv_ptr fpst; | ||
91 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | ||
92 | case 0x05: /* FMLS */ | ||
93 | case 0x09: /* FMUL */ | ||
94 | case 0x19: /* FMULX */ | ||
95 | - is_fp = true; | ||
96 | + is_fp = 1; | ||
97 | break; | ||
98 | case 0x1d: /* SQRDMLAH */ | ||
99 | case 0x1f: /* SQRDMLSH */ | ||
100 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | ||
101 | return; | ||
102 | } | ||
103 | break; | ||
104 | + case 0x11: /* FCMLA #0 */ | ||
105 | + case 0x13: /* FCMLA #90 */ | ||
106 | + case 0x15: /* FCMLA #180 */ | ||
107 | + case 0x17: /* FCMLA #270 */ | ||
108 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_FCMA)) { | ||
109 | + unallocated_encoding(s); | ||
110 | + return; | ||
111 | + } | ||
112 | + is_fp = 2; | ||
113 | + break; | ||
114 | default: | ||
115 | unallocated_encoding(s); | ||
116 | return; | ||
117 | } | 32 | } |
118 | 33 | ||
119 | - if (is_fp) { | 34 | + /* Numonyx RC28F128J3F75 */ |
120 | + switch (is_fp) { | 35 | if (!pflash_cfi01_register(0x00000000, "connext.rom", connex_rom, |
121 | + case 1: /* normal fp */ | 36 | dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, |
122 | /* convert insn encoded size to TCGMemOp size */ | 37 | sector_len, 2, 0, 0, 0, 0, 0)) { |
123 | switch (size) { | 38 | @@ -XXX,XX +XXX,XX @@ static void verdex_init(MachineState *machine) |
124 | case 0: /* half-precision */ | 39 | exit(1); |
125 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
126 | - unallocated_encoding(s); | ||
127 | - return; | ||
128 | - } | ||
129 | size = MO_16; | ||
130 | + is_fp16 = true; | ||
131 | break; | ||
132 | case MO_32: /* single precision */ | ||
133 | case MO_64: /* double precision */ | ||
134 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | ||
135 | unallocated_encoding(s); | ||
136 | return; | ||
137 | } | ||
138 | - } else { | ||
139 | + break; | ||
140 | + | ||
141 | + case 2: /* complex fp */ | ||
142 | + /* Each indexable element is a complex pair. */ | ||
143 | + size <<= 1; | ||
144 | + switch (size) { | ||
145 | + case MO_32: | ||
146 | + if (h && !is_q) { | ||
147 | + unallocated_encoding(s); | ||
148 | + return; | ||
149 | + } | ||
150 | + is_fp16 = true; | ||
151 | + break; | ||
152 | + case MO_64: | ||
153 | + break; | ||
154 | + default: | ||
155 | + unallocated_encoding(s); | ||
156 | + return; | ||
157 | + } | ||
158 | + break; | ||
159 | + | ||
160 | + default: /* integer */ | ||
161 | switch (size) { | ||
162 | case MO_8: | ||
163 | case MO_64: | ||
164 | unallocated_encoding(s); | ||
165 | return; | ||
166 | } | ||
167 | + break; | ||
168 | + } | ||
169 | + if (is_fp16 && !arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
170 | + unallocated_encoding(s); | ||
171 | + return; | ||
172 | } | 40 | } |
173 | 41 | ||
174 | /* Given TCGMemOp size, adjust register and indexing. */ | 42 | + /* Micron RC28F256P30TFA */ |
175 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | 43 | if (!pflash_cfi01_register(0x00000000, "verdex.rom", verdex_rom, |
176 | fpst = NULL; | 44 | dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, |
177 | } | 45 | sector_len, 2, 0, 0, 0, 0, 0)) { |
178 | 46 | @@ -XXX,XX +XXX,XX @@ static void verdex_class_init(ObjectClass *oc, void *data) | |
179 | + switch (16 * u + opcode) { | 47 | { |
180 | + case 0x11: /* FCMLA #0 */ | 48 | MachineClass *mc = MACHINE_CLASS(oc); |
181 | + case 0x13: /* FCMLA #90 */ | 49 | |
182 | + case 0x15: /* FCMLA #180 */ | 50 | - mc->desc = "Gumstix Verdex (PXA270)"; |
183 | + case 0x17: /* FCMLA #270 */ | 51 | + mc->desc = "Gumstix Verdex Pro XL6P COMs (PXA270)"; |
184 | + tcg_gen_gvec_3_ptr(vec_full_reg_offset(s, rd), | 52 | mc->init = verdex_init; |
185 | + vec_full_reg_offset(s, rn), | 53 | mc->ignore_memory_transaction_failures = true; |
186 | + vec_reg_offset(s, rm, index, size), fpst, | 54 | mc->default_cpu_type = ARM_CPU_TYPE_NAME("pxa270-c0"); |
187 | + is_q ? 16 : 8, vec_full_reg_size(s), | ||
188 | + extract32(insn, 13, 2), /* rot */ | ||
189 | + size == MO_64 | ||
190 | + ? gen_helper_gvec_fcmlas_idx | ||
191 | + : gen_helper_gvec_fcmlah_idx); | ||
192 | + tcg_temp_free_ptr(fpst); | ||
193 | + return; | ||
194 | + } | ||
195 | + | ||
196 | if (size == 3) { | ||
197 | TCGv_i64 tcg_idx = tcg_temp_new_i64(); | ||
198 | int pass; | ||
199 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | ||
200 | index XXXXXXX..XXXXXXX 100644 | ||
201 | --- a/target/arm/vec_helper.c | ||
202 | +++ b/target/arm/vec_helper.c | ||
203 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_fcaddd)(void *vd, void *vn, void *vm, | ||
204 | } | ||
205 | clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
206 | } | ||
207 | + | ||
208 | +void HELPER(gvec_fcmlah)(void *vd, void *vn, void *vm, | ||
209 | + void *vfpst, uint32_t desc) | ||
210 | +{ | ||
211 | + uintptr_t opr_sz = simd_oprsz(desc); | ||
212 | + float16 *d = vd; | ||
213 | + float16 *n = vn; | ||
214 | + float16 *m = vm; | ||
215 | + float_status *fpst = vfpst; | ||
216 | + intptr_t flip = extract32(desc, SIMD_DATA_SHIFT, 1); | ||
217 | + uint32_t neg_imag = extract32(desc, SIMD_DATA_SHIFT + 1, 1); | ||
218 | + uint32_t neg_real = flip ^ neg_imag; | ||
219 | + uintptr_t i; | ||
220 | + | ||
221 | + /* Shift boolean to the sign bit so we can xor to negate. */ | ||
222 | + neg_real <<= 15; | ||
223 | + neg_imag <<= 15; | ||
224 | + | ||
225 | + for (i = 0; i < opr_sz / 2; i += 2) { | ||
226 | + float16 e2 = n[H2(i + flip)]; | ||
227 | + float16 e1 = m[H2(i + flip)] ^ neg_real; | ||
228 | + float16 e4 = e2; | ||
229 | + float16 e3 = m[H2(i + 1 - flip)] ^ neg_imag; | ||
230 | + | ||
231 | + d[H2(i)] = float16_muladd(e2, e1, d[H2(i)], 0, fpst); | ||
232 | + d[H2(i + 1)] = float16_muladd(e4, e3, d[H2(i + 1)], 0, fpst); | ||
233 | + } | ||
234 | + clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
235 | +} | ||
236 | + | ||
237 | +void HELPER(gvec_fcmlah_idx)(void *vd, void *vn, void *vm, | ||
238 | + void *vfpst, uint32_t desc) | ||
239 | +{ | ||
240 | + uintptr_t opr_sz = simd_oprsz(desc); | ||
241 | + float16 *d = vd; | ||
242 | + float16 *n = vn; | ||
243 | + float16 *m = vm; | ||
244 | + float_status *fpst = vfpst; | ||
245 | + intptr_t flip = extract32(desc, SIMD_DATA_SHIFT, 1); | ||
246 | + uint32_t neg_imag = extract32(desc, SIMD_DATA_SHIFT + 1, 1); | ||
247 | + uint32_t neg_real = flip ^ neg_imag; | ||
248 | + uintptr_t i; | ||
249 | + float16 e1 = m[H2(flip)]; | ||
250 | + float16 e3 = m[H2(1 - flip)]; | ||
251 | + | ||
252 | + /* Shift boolean to the sign bit so we can xor to negate. */ | ||
253 | + neg_real <<= 15; | ||
254 | + neg_imag <<= 15; | ||
255 | + e1 ^= neg_real; | ||
256 | + e3 ^= neg_imag; | ||
257 | + | ||
258 | + for (i = 0; i < opr_sz / 2; i += 2) { | ||
259 | + float16 e2 = n[H2(i + flip)]; | ||
260 | + float16 e4 = e2; | ||
261 | + | ||
262 | + d[H2(i)] = float16_muladd(e2, e1, d[H2(i)], 0, fpst); | ||
263 | + d[H2(i + 1)] = float16_muladd(e4, e3, d[H2(i + 1)], 0, fpst); | ||
264 | + } | ||
265 | + clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
266 | +} | ||
267 | + | ||
268 | +void HELPER(gvec_fcmlas)(void *vd, void *vn, void *vm, | ||
269 | + void *vfpst, uint32_t desc) | ||
270 | +{ | ||
271 | + uintptr_t opr_sz = simd_oprsz(desc); | ||
272 | + float32 *d = vd; | ||
273 | + float32 *n = vn; | ||
274 | + float32 *m = vm; | ||
275 | + float_status *fpst = vfpst; | ||
276 | + intptr_t flip = extract32(desc, SIMD_DATA_SHIFT, 1); | ||
277 | + uint32_t neg_imag = extract32(desc, SIMD_DATA_SHIFT + 1, 1); | ||
278 | + uint32_t neg_real = flip ^ neg_imag; | ||
279 | + uintptr_t i; | ||
280 | + | ||
281 | + /* Shift boolean to the sign bit so we can xor to negate. */ | ||
282 | + neg_real <<= 31; | ||
283 | + neg_imag <<= 31; | ||
284 | + | ||
285 | + for (i = 0; i < opr_sz / 4; i += 2) { | ||
286 | + float32 e2 = n[H4(i + flip)]; | ||
287 | + float32 e1 = m[H4(i + flip)] ^ neg_real; | ||
288 | + float32 e4 = e2; | ||
289 | + float32 e3 = m[H4(i + 1 - flip)] ^ neg_imag; | ||
290 | + | ||
291 | + d[H4(i)] = float32_muladd(e2, e1, d[H4(i)], 0, fpst); | ||
292 | + d[H4(i + 1)] = float32_muladd(e4, e3, d[H4(i + 1)], 0, fpst); | ||
293 | + } | ||
294 | + clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
295 | +} | ||
296 | + | ||
297 | +void HELPER(gvec_fcmlas_idx)(void *vd, void *vn, void *vm, | ||
298 | + void *vfpst, uint32_t desc) | ||
299 | +{ | ||
300 | + uintptr_t opr_sz = simd_oprsz(desc); | ||
301 | + float32 *d = vd; | ||
302 | + float32 *n = vn; | ||
303 | + float32 *m = vm; | ||
304 | + float_status *fpst = vfpst; | ||
305 | + intptr_t flip = extract32(desc, SIMD_DATA_SHIFT, 1); | ||
306 | + uint32_t neg_imag = extract32(desc, SIMD_DATA_SHIFT + 1, 1); | ||
307 | + uint32_t neg_real = flip ^ neg_imag; | ||
308 | + uintptr_t i; | ||
309 | + float32 e1 = m[H4(flip)]; | ||
310 | + float32 e3 = m[H4(1 - flip)]; | ||
311 | + | ||
312 | + /* Shift boolean to the sign bit so we can xor to negate. */ | ||
313 | + neg_real <<= 31; | ||
314 | + neg_imag <<= 31; | ||
315 | + e1 ^= neg_real; | ||
316 | + e3 ^= neg_imag; | ||
317 | + | ||
318 | + for (i = 0; i < opr_sz / 4; i += 2) { | ||
319 | + float32 e2 = n[H4(i + flip)]; | ||
320 | + float32 e4 = e2; | ||
321 | + | ||
322 | + d[H4(i)] = float32_muladd(e2, e1, d[H4(i)], 0, fpst); | ||
323 | + d[H4(i + 1)] = float32_muladd(e4, e3, d[H4(i + 1)], 0, fpst); | ||
324 | + } | ||
325 | + clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
326 | +} | ||
327 | + | ||
328 | +void HELPER(gvec_fcmlad)(void *vd, void *vn, void *vm, | ||
329 | + void *vfpst, uint32_t desc) | ||
330 | +{ | ||
331 | + uintptr_t opr_sz = simd_oprsz(desc); | ||
332 | + float64 *d = vd; | ||
333 | + float64 *n = vn; | ||
334 | + float64 *m = vm; | ||
335 | + float_status *fpst = vfpst; | ||
336 | + intptr_t flip = extract32(desc, SIMD_DATA_SHIFT, 1); | ||
337 | + uint64_t neg_imag = extract32(desc, SIMD_DATA_SHIFT + 1, 1); | ||
338 | + uint64_t neg_real = flip ^ neg_imag; | ||
339 | + uintptr_t i; | ||
340 | + | ||
341 | + /* Shift boolean to the sign bit so we can xor to negate. */ | ||
342 | + neg_real <<= 63; | ||
343 | + neg_imag <<= 63; | ||
344 | + | ||
345 | + for (i = 0; i < opr_sz / 8; i += 2) { | ||
346 | + float64 e2 = n[i + flip]; | ||
347 | + float64 e1 = m[i + flip] ^ neg_real; | ||
348 | + float64 e4 = e2; | ||
349 | + float64 e3 = m[i + 1 - flip] ^ neg_imag; | ||
350 | + | ||
351 | + d[i] = float64_muladd(e2, e1, d[i], 0, fpst); | ||
352 | + d[i + 1] = float64_muladd(e4, e3, d[i + 1], 0, fpst); | ||
353 | + } | ||
354 | + clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
355 | +} | ||
356 | -- | 55 | -- |
357 | 2.16.2 | 56 | 2.34.1 |
358 | 57 | ||
359 | 58 | diff view generated by jsdifflib |
1 | In v8M, the Implementation Defined Attribution Unit (IDAU) is | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | a small piece of hardware typically implemented in the SoC | ||
3 | which provides board or SoC specific security attribution | ||
4 | information for each address that the CPU performs MPU/SAU | ||
5 | checks on. For QEMU, we model this with a QOM interface which | ||
6 | is implemented by the board or SoC object and connected to | ||
7 | the CPU using a link property. | ||
8 | 2 | ||
9 | This commit defines the new interface class, adds the link | 3 | IEC binary prefixes ease code review: the unit is explicit. |
10 | property to the CPU object, and makes the SAU checking | ||
11 | code call the IDAU interface if one is present. | ||
12 | 4 | ||
5 | Add definitions for RAM / Flash / Flash blocksize. | ||
6 | |||
7 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20230109115316.2235-7-philmd@linaro.org | ||
10 | Message-Id: <20200223231044.8003-3-philmd@redhat.com> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Message-id: 20180220180325.29818-5-peter.maydell@linaro.org | ||
16 | --- | 12 | --- |
17 | target/arm/cpu.h | 3 +++ | 13 | hw/arm/gumstix.c | 27 ++++++++++++++------------- |
18 | target/arm/idau.h | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ | 14 | 1 file changed, 14 insertions(+), 13 deletions(-) |
19 | target/arm/cpu.c | 15 +++++++++++++ | ||
20 | target/arm/helper.c | 28 +++++++++++++++++++++--- | ||
21 | 4 files changed, 104 insertions(+), 3 deletions(-) | ||
22 | create mode 100644 target/arm/idau.h | ||
23 | 15 | ||
24 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 16 | diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c |
25 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/target/arm/cpu.h | 18 | --- a/hw/arm/gumstix.c |
27 | +++ b/target/arm/cpu.h | 19 | +++ b/hw/arm/gumstix.c |
28 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | ||
29 | /* MemoryRegion to use for secure physical accesses */ | ||
30 | MemoryRegion *secure_memory; | ||
31 | |||
32 | + /* For v8M, pointer to the IDAU interface provided by board/SoC */ | ||
33 | + Object *idau; | ||
34 | + | ||
35 | /* 'compatible' string for this CPU for Linux device trees */ | ||
36 | const char *dtb_compatible; | ||
37 | |||
38 | diff --git a/target/arm/idau.h b/target/arm/idau.h | ||
39 | new file mode 100644 | ||
40 | index XXXXXXX..XXXXXXX | ||
41 | --- /dev/null | ||
42 | +++ b/target/arm/idau.h | ||
43 | @@ -XXX,XX +XXX,XX @@ | ||
44 | +/* | ||
45 | + * QEMU ARM CPU -- interface for the Arm v8M IDAU | ||
46 | + * | ||
47 | + * Copyright (c) 2018 Linaro Ltd | ||
48 | + * | ||
49 | + * This program is free software; you can redistribute it and/or | ||
50 | + * modify it under the terms of the GNU General Public License | ||
51 | + * as published by the Free Software Foundation; either version 2 | ||
52 | + * of the License, or (at your option) any later version. | ||
53 | + * | ||
54 | + * This program is distributed in the hope that it will be useful, | ||
55 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
56 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
57 | + * GNU General Public License for more details. | ||
58 | + * | ||
59 | + * You should have received a copy of the GNU General Public License | ||
60 | + * along with this program; if not, see | ||
61 | + * <http://www.gnu.org/licenses/gpl-2.0.html> | ||
62 | + * | ||
63 | + * In the v8M architecture, the IDAU is a small piece of hardware | ||
64 | + * typically implemented in the SoC which provides board or SoC | ||
65 | + * specific security attribution information for each address that | ||
66 | + * the CPU performs MPU/SAU checks on. For QEMU, we model this with a | ||
67 | + * QOM interface which is implemented by the board or SoC object and | ||
68 | + * connected to the CPU using a link property. | ||
69 | + */ | ||
70 | + | ||
71 | +#ifndef TARGET_ARM_IDAU_H | ||
72 | +#define TARGET_ARM_IDAU_H | ||
73 | + | ||
74 | +#include "qom/object.h" | ||
75 | + | ||
76 | +#define TYPE_IDAU_INTERFACE "idau-interface" | ||
77 | +#define IDAU_INTERFACE(obj) \ | ||
78 | + INTERFACE_CHECK(IDAUInterface, (obj), TYPE_IDAU_INTERFACE) | ||
79 | +#define IDAU_INTERFACE_CLASS(class) \ | ||
80 | + OBJECT_CLASS_CHECK(IDAUInterfaceClass, (class), TYPE_IDAU_INTERFACE) | ||
81 | +#define IDAU_INTERFACE_GET_CLASS(obj) \ | ||
82 | + OBJECT_GET_CLASS(IDAUInterfaceClass, (obj), TYPE_IDAU_INTERFACE) | ||
83 | + | ||
84 | +typedef struct IDAUInterface { | ||
85 | + Object parent; | ||
86 | +} IDAUInterface; | ||
87 | + | ||
88 | +#define IREGION_NOTVALID -1 | ||
89 | + | ||
90 | +typedef struct IDAUInterfaceClass { | ||
91 | + InterfaceClass parent; | ||
92 | + | ||
93 | + /* Check the specified address and return the IDAU security information | ||
94 | + * for it by filling in iregion, exempt, ns and nsc: | ||
95 | + * iregion: IDAU region number, or IREGION_NOTVALID if not valid | ||
96 | + * exempt: true if address is exempt from security attribution | ||
97 | + * ns: true if the address is NonSecure | ||
98 | + * nsc: true if the address is NonSecure-callable | ||
99 | + */ | ||
100 | + void (*check)(IDAUInterface *ii, uint32_t address, int *iregion, | ||
101 | + bool *exempt, bool *ns, bool *nsc); | ||
102 | +} IDAUInterfaceClass; | ||
103 | + | ||
104 | +#endif | ||
105 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
106 | index XXXXXXX..XXXXXXX 100644 | ||
107 | --- a/target/arm/cpu.c | ||
108 | +++ b/target/arm/cpu.c | ||
109 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ |
110 | */ | 21 | */ |
111 | 22 | ||
112 | #include "qemu/osdep.h" | 23 | #include "qemu/osdep.h" |
113 | +#include "target/arm/idau.h" | 24 | +#include "qemu/units.h" |
114 | #include "qemu/error-report.h" | 25 | #include "qemu/error-report.h" |
115 | #include "qapi/error.h" | 26 | #include "hw/arm/pxa.h" |
27 | #include "net/net.h" | ||
28 | @@ -XXX,XX +XXX,XX @@ | ||
29 | #include "sysemu/qtest.h" | ||
116 | #include "cpu.h" | 30 | #include "cpu.h" |
117 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_post_init(Object *obj) | 31 | |
118 | } | 32 | -static const int sector_len = 128 * 1024; |
33 | +#define CONNEX_FLASH_SIZE (16 * MiB) | ||
34 | +#define CONNEX_RAM_SIZE (64 * MiB) | ||
35 | + | ||
36 | +#define VERDEX_FLASH_SIZE (32 * MiB) | ||
37 | +#define VERDEX_RAM_SIZE (256 * MiB) | ||
38 | + | ||
39 | +#define FLASH_SECTOR_SIZE (128 * KiB) | ||
40 | |||
41 | static void connex_init(MachineState *machine) | ||
42 | { | ||
43 | PXA2xxState *cpu; | ||
44 | DriveInfo *dinfo; | ||
45 | |||
46 | - uint32_t connex_rom = 0x01000000; | ||
47 | - uint32_t connex_ram = 0x04000000; | ||
48 | - | ||
49 | - cpu = pxa255_init(connex_ram); | ||
50 | + cpu = pxa255_init(CONNEX_RAM_SIZE); | ||
51 | |||
52 | dinfo = drive_get(IF_PFLASH, 0, 0); | ||
53 | if (!dinfo && !qtest_enabled()) { | ||
54 | @@ -XXX,XX +XXX,XX @@ static void connex_init(MachineState *machine) | ||
119 | } | 55 | } |
120 | 56 | ||
121 | + if (arm_feature(&cpu->env, ARM_FEATURE_M_SECURITY)) { | 57 | /* Numonyx RC28F128J3F75 */ |
122 | + object_property_add_link(obj, "idau", TYPE_IDAU_INTERFACE, &cpu->idau, | 58 | - if (!pflash_cfi01_register(0x00000000, "connext.rom", connex_rom, |
123 | + qdev_prop_allow_set_link_before_realize, | 59 | + if (!pflash_cfi01_register(0x00000000, "connext.rom", CONNEX_FLASH_SIZE, |
124 | + OBJ_PROP_LINK_UNREF_ON_RELEASE, | 60 | dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, |
125 | + &error_abort); | 61 | - sector_len, 2, 0, 0, 0, 0, 0)) { |
126 | + } | 62 | + FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0)) { |
127 | + | 63 | error_report("Error registering flash memory"); |
128 | qdev_property_add_static(DEVICE(obj), &arm_cpu_cfgend_property, | 64 | exit(1); |
129 | &error_abort); | ||
130 | } | ||
131 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo arm_cpu_type_info = { | ||
132 | .class_init = arm_cpu_class_init, | ||
133 | }; | ||
134 | |||
135 | +static const TypeInfo idau_interface_type_info = { | ||
136 | + .name = TYPE_IDAU_INTERFACE, | ||
137 | + .parent = TYPE_INTERFACE, | ||
138 | + .class_size = sizeof(IDAUInterfaceClass), | ||
139 | +}; | ||
140 | + | ||
141 | static void arm_cpu_register_types(void) | ||
142 | { | ||
143 | const ARMCPUInfo *info = arm_cpus; | ||
144 | |||
145 | type_register_static(&arm_cpu_type_info); | ||
146 | + type_register_static(&idau_interface_type_info); | ||
147 | |||
148 | while (info->name) { | ||
149 | cpu_register(info); | ||
150 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
151 | index XXXXXXX..XXXXXXX 100644 | ||
152 | --- a/target/arm/helper.c | ||
153 | +++ b/target/arm/helper.c | ||
154 | @@ -XXX,XX +XXX,XX @@ | ||
155 | #include "qemu/osdep.h" | ||
156 | +#include "target/arm/idau.h" | ||
157 | #include "trace.h" | ||
158 | #include "cpu.h" | ||
159 | #include "internals.h" | ||
160 | @@ -XXX,XX +XXX,XX @@ static void v8m_security_lookup(CPUARMState *env, uint32_t address, | ||
161 | */ | ||
162 | ARMCPU *cpu = arm_env_get_cpu(env); | ||
163 | int r; | ||
164 | + bool idau_exempt = false, idau_ns = true, idau_nsc = true; | ||
165 | + int idau_region = IREGION_NOTVALID; | ||
166 | |||
167 | - /* TODO: implement IDAU */ | ||
168 | + if (cpu->idau) { | ||
169 | + IDAUInterfaceClass *iic = IDAU_INTERFACE_GET_CLASS(cpu->idau); | ||
170 | + IDAUInterface *ii = IDAU_INTERFACE(cpu->idau); | ||
171 | + | ||
172 | + iic->check(ii, address, &idau_region, &idau_exempt, &idau_ns, | ||
173 | + &idau_nsc); | ||
174 | + } | ||
175 | |||
176 | if (access_type == MMU_INST_FETCH && extract32(address, 28, 4) == 0xf) { | ||
177 | /* 0xf0000000..0xffffffff is always S for insn fetches */ | ||
178 | return; | ||
179 | } | 65 | } |
180 | 66 | @@ -XXX,XX +XXX,XX @@ static void verdex_init(MachineState *machine) | |
181 | - if (v8m_is_sau_exempt(env, address, access_type)) { | 67 | PXA2xxState *cpu; |
182 | + if (idau_exempt || v8m_is_sau_exempt(env, address, access_type)) { | 68 | DriveInfo *dinfo; |
183 | sattrs->ns = !regime_is_secure(env, mmu_idx); | 69 | |
184 | return; | 70 | - uint32_t verdex_rom = 0x02000000; |
71 | - uint32_t verdex_ram = 0x10000000; | ||
72 | - | ||
73 | - cpu = pxa270_init(verdex_ram, machine->cpu_type); | ||
74 | + cpu = pxa270_init(VERDEX_RAM_SIZE, machine->cpu_type); | ||
75 | |||
76 | dinfo = drive_get(IF_PFLASH, 0, 0); | ||
77 | if (!dinfo && !qtest_enabled()) { | ||
78 | @@ -XXX,XX +XXX,XX @@ static void verdex_init(MachineState *machine) | ||
185 | } | 79 | } |
186 | 80 | ||
187 | + if (idau_region != IREGION_NOTVALID) { | 81 | /* Micron RC28F256P30TFA */ |
188 | + sattrs->irvalid = true; | 82 | - if (!pflash_cfi01_register(0x00000000, "verdex.rom", verdex_rom, |
189 | + sattrs->iregion = idau_region; | 83 | + if (!pflash_cfi01_register(0x00000000, "verdex.rom", VERDEX_FLASH_SIZE, |
190 | + } | 84 | dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, |
191 | + | 85 | - sector_len, 2, 0, 0, 0, 0, 0)) { |
192 | switch (env->sau.ctrl & 3) { | 86 | + FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0)) { |
193 | case 0: /* SAU.ENABLE == 0, SAU.ALLNS == 0 */ | 87 | error_report("Error registering flash memory"); |
194 | break; | 88 | exit(1); |
195 | @@ -XXX,XX +XXX,XX @@ static void v8m_security_lookup(CPUARMState *env, uint32_t address, | ||
196 | } | ||
197 | } | ||
198 | |||
199 | - /* TODO when we support the IDAU then it may override the result here */ | ||
200 | + /* The IDAU will override the SAU lookup results if it specifies | ||
201 | + * higher security than the SAU does. | ||
202 | + */ | ||
203 | + if (!idau_ns) { | ||
204 | + if (sattrs->ns || (!idau_nsc && sattrs->nsc)) { | ||
205 | + sattrs->ns = false; | ||
206 | + sattrs->nsc = idau_nsc; | ||
207 | + } | ||
208 | + } | ||
209 | break; | ||
210 | } | 89 | } |
211 | } | ||
212 | -- | 90 | -- |
213 | 2.16.2 | 91 | 2.34.1 |
214 | 92 | ||
215 | 93 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Not enabled anywhere yet. | 3 | IEC binary prefixes ease code review: the unit is explicit. |
4 | 4 | ||
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 5 | Add the FLASH_SECTOR_SIZE definition. |
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | |
7 | Message-id: 20180228193125.20577-11-richard.henderson@linaro.org | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20230109115316.2235-8-philmd@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 11 | --- |
10 | target/arm/cpu.h | 1 + | 12 | hw/arm/mainstone.c | 18 ++++++++++-------- |
11 | linux-user/elfload.c | 1 + | 13 | 1 file changed, 10 insertions(+), 8 deletions(-) |
12 | 2 files changed, 2 insertions(+) | ||
13 | 14 | ||
14 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 15 | diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/cpu.h | 17 | --- a/hw/arm/mainstone.c |
17 | +++ b/target/arm/cpu.h | 18 | +++ b/hw/arm/mainstone.c |
18 | @@ -XXX,XX +XXX,XX @@ enum arm_features { | 19 | @@ -XXX,XX +XXX,XX @@ |
19 | ARM_FEATURE_V8_SM4, /* implements SM4 part of v8 Crypto Extensions */ | 20 | * GNU GPL, version 2 or (at your option) any later version. |
20 | ARM_FEATURE_V8_RDM, /* implements v8.1 simd round multiply */ | 21 | */ |
21 | ARM_FEATURE_V8_FP16, /* implements v8.2 half-precision float */ | 22 | #include "qemu/osdep.h" |
22 | + ARM_FEATURE_V8_FCMA, /* has complex number part of v8.3 extensions. */ | 23 | +#include "qemu/units.h" |
24 | #include "qemu/error-report.h" | ||
25 | #include "qapi/error.h" | ||
26 | #include "hw/arm/pxa.h" | ||
27 | @@ -XXX,XX +XXX,XX @@ static const struct keymap map[0xE0] = { | ||
28 | |||
29 | enum mainstone_model_e { mainstone }; | ||
30 | |||
31 | -#define MAINSTONE_RAM 0x04000000 | ||
32 | -#define MAINSTONE_ROM 0x00800000 | ||
33 | -#define MAINSTONE_FLASH 0x02000000 | ||
34 | +#define MAINSTONE_RAM_SIZE (64 * MiB) | ||
35 | +#define MAINSTONE_ROM_SIZE (8 * MiB) | ||
36 | +#define MAINSTONE_FLASH_SIZE (32 * MiB) | ||
37 | |||
38 | static struct arm_boot_info mainstone_binfo = { | ||
39 | .loader_start = PXA2XX_SDRAM_BASE, | ||
40 | - .ram_size = 0x04000000, | ||
41 | + .ram_size = MAINSTONE_RAM_SIZE, | ||
23 | }; | 42 | }; |
24 | 43 | ||
25 | static inline int arm_feature(CPUARMState *env, int feature) | 44 | +#define FLASH_SECTOR_SIZE (256 * KiB) |
26 | diff --git a/linux-user/elfload.c b/linux-user/elfload.c | 45 | + |
27 | index XXXXXXX..XXXXXXX 100644 | 46 | static void mainstone_common_init(MachineState *machine, |
28 | --- a/linux-user/elfload.c | 47 | enum mainstone_model_e model, int arm_id) |
29 | +++ b/linux-user/elfload.c | 48 | { |
30 | @@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap(void) | 49 | - uint32_t sector_len = 256 * 1024; |
31 | GET_FEATURE(ARM_FEATURE_V8_FP16, | 50 | hwaddr mainstone_flash_base[] = { MST_FLASH_0, MST_FLASH_1 }; |
32 | ARM_HWCAP_A64_FPHP | ARM_HWCAP_A64_ASIMDHP); | 51 | PXA2xxState *mpu; |
33 | GET_FEATURE(ARM_FEATURE_V8_RDM, ARM_HWCAP_A64_ASIMDRDM); | 52 | DeviceState *mst_irq; |
34 | + GET_FEATURE(ARM_FEATURE_V8_FCMA, ARM_HWCAP_A64_FCMA); | 53 | @@ -XXX,XX +XXX,XX @@ static void mainstone_common_init(MachineState *machine, |
35 | #undef GET_FEATURE | 54 | |
36 | 55 | /* Setup CPU & memory */ | |
37 | return hwcaps; | 56 | mpu = pxa270_init(mainstone_binfo.ram_size, machine->cpu_type); |
57 | - memory_region_init_rom(rom, NULL, "mainstone.rom", MAINSTONE_ROM, | ||
58 | + memory_region_init_rom(rom, NULL, "mainstone.rom", MAINSTONE_ROM_SIZE, | ||
59 | &error_fatal); | ||
60 | memory_region_add_subregion(get_system_memory(), 0x00000000, rom); | ||
61 | |||
62 | @@ -XXX,XX +XXX,XX @@ static void mainstone_common_init(MachineState *machine, | ||
63 | dinfo = drive_get(IF_PFLASH, 0, i); | ||
64 | if (!pflash_cfi01_register(mainstone_flash_base[i], | ||
65 | i ? "mainstone.flash1" : "mainstone.flash0", | ||
66 | - MAINSTONE_FLASH, | ||
67 | + MAINSTONE_FLASH_SIZE, | ||
68 | dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, | ||
69 | - sector_len, 4, 0, 0, 0, 0, 0)) { | ||
70 | + FLASH_SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) { | ||
71 | error_report("Error registering flash memory"); | ||
72 | exit(1); | ||
73 | } | ||
38 | -- | 74 | -- |
39 | 2.16.2 | 75 | 2.34.1 |
40 | 76 | ||
41 | 77 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 3 | IEC binary prefixes ease code review: the unit is explicit. |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | |
5 | Message-id: 20180228193125.20577-8-richard.henderson@linaro.org | 5 | Add the FLASH_SECTOR_SIZE definition. |
6 | |||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20230109115316.2235-9-philmd@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 11 | --- |
8 | target/arm/translate.c | 86 +++++++++++++++++++++++++++++++++++++++----------- | 12 | hw/arm/musicpal.c | 9 ++++++--- |
9 | 1 file changed, 67 insertions(+), 19 deletions(-) | 13 | 1 file changed, 6 insertions(+), 3 deletions(-) |
10 | 14 | ||
11 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 15 | diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c |
12 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate.c | 17 | --- a/hw/arm/musicpal.c |
14 | +++ b/target/arm/translate.c | 18 | +++ b/hw/arm/musicpal.c |
15 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ |
16 | #include "disas/disas.h" | 20 | */ |
17 | #include "exec/exec-all.h" | 21 | |
18 | #include "tcg-op.h" | 22 | #include "qemu/osdep.h" |
19 | +#include "tcg-op-gvec.h" | 23 | +#include "qemu/units.h" |
20 | #include "qemu/log.h" | 24 | #include "qapi/error.h" |
21 | #include "qemu/bitops.h" | 25 | #include "cpu.h" |
22 | #include "arm_ldst.h" | 26 | #include "hw/sysbus.h" |
23 | @@ -XXX,XX +XXX,XX @@ static void gen_neon_narrow_op(int op, int u, int size, | 27 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo musicpal_key_info = { |
24 | #define NEON_3R_VPMAX 20 | 28 | .class_init = musicpal_key_class_init, |
25 | #define NEON_3R_VPMIN 21 | ||
26 | #define NEON_3R_VQDMULH_VQRDMULH 22 | ||
27 | -#define NEON_3R_VPADD 23 | ||
28 | +#define NEON_3R_VPADD_VQRDMLAH 23 | ||
29 | #define NEON_3R_SHA 24 /* SHA1C,SHA1P,SHA1M,SHA1SU0,SHA256H{2},SHA256SU1 */ | ||
30 | -#define NEON_3R_VFM 25 /* VFMA, VFMS : float fused multiply-add */ | ||
31 | +#define NEON_3R_VFM_VQRDMLSH 25 /* VFMA, VFMS, VQRDMLSH */ | ||
32 | #define NEON_3R_FLOAT_ARITH 26 /* float VADD, VSUB, VPADD, VABD */ | ||
33 | #define NEON_3R_FLOAT_MULTIPLY 27 /* float VMLA, VMLS, VMUL */ | ||
34 | #define NEON_3R_FLOAT_CMP 28 /* float VCEQ, VCGE, VCGT */ | ||
35 | @@ -XXX,XX +XXX,XX @@ static const uint8_t neon_3r_sizes[] = { | ||
36 | [NEON_3R_VPMAX] = 0x7, | ||
37 | [NEON_3R_VPMIN] = 0x7, | ||
38 | [NEON_3R_VQDMULH_VQRDMULH] = 0x6, | ||
39 | - [NEON_3R_VPADD] = 0x7, | ||
40 | + [NEON_3R_VPADD_VQRDMLAH] = 0x7, | ||
41 | [NEON_3R_SHA] = 0xf, /* size field encodes op type */ | ||
42 | - [NEON_3R_VFM] = 0x5, /* size bit 1 encodes op */ | ||
43 | + [NEON_3R_VFM_VQRDMLSH] = 0x7, /* For VFM, size bit 1 encodes op */ | ||
44 | [NEON_3R_FLOAT_ARITH] = 0x5, /* size bit 1 encodes op */ | ||
45 | [NEON_3R_FLOAT_MULTIPLY] = 0x5, /* size bit 1 encodes op */ | ||
46 | [NEON_3R_FLOAT_CMP] = 0x5, /* size bit 1 encodes op */ | ||
47 | @@ -XXX,XX +XXX,XX @@ static const uint8_t neon_2rm_sizes[] = { | ||
48 | [NEON_2RM_VCVT_UF] = 0x4, | ||
49 | }; | 29 | }; |
50 | 30 | ||
31 | +#define FLASH_SECTOR_SIZE (64 * KiB) | ||
51 | + | 32 | + |
52 | +/* Expand v8.1 simd helper. */ | 33 | static struct arm_boot_info musicpal_binfo = { |
53 | +static int do_v81_helper(DisasContext *s, gen_helper_gvec_3_ptr *fn, | 34 | .loader_start = 0x0, |
54 | + int q, int rd, int rn, int rm) | 35 | .board_id = 0x20e, |
55 | +{ | 36 | @@ -XXX,XX +XXX,XX @@ static void musicpal_init(MachineState *machine) |
56 | + if (arm_dc_feature(s, ARM_FEATURE_V8_RDM)) { | 37 | BlockBackend *blk = blk_by_legacy_dinfo(dinfo); |
57 | + int opr_sz = (1 + q) * 8; | 38 | |
58 | + tcg_gen_gvec_3_ptr(vfp_reg_offset(1, rd), | 39 | flash_size = blk_getlength(blk); |
59 | + vfp_reg_offset(1, rn), | 40 | - if (flash_size != 8*1024*1024 && flash_size != 16*1024*1024 && |
60 | + vfp_reg_offset(1, rm), cpu_env, | 41 | - flash_size != 32*1024*1024) { |
61 | + opr_sz, opr_sz, 0, fn); | 42 | + if (flash_size != 8 * MiB && flash_size != 16 * MiB && |
62 | + return 0; | 43 | + flash_size != 32 * MiB) { |
63 | + } | 44 | error_report("Invalid flash image size"); |
64 | + return 1; | 45 | exit(1); |
65 | +} | ||
66 | + | ||
67 | /* Translate a NEON data processing instruction. Return nonzero if the | ||
68 | instruction is invalid. | ||
69 | We process data in a mixture of 32-bit and 64-bit chunks. | ||
70 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
71 | if (q && ((rd | rn | rm) & 1)) { | ||
72 | return 1; | ||
73 | } | 46 | } |
74 | - /* | 47 | @@ -XXX,XX +XXX,XX @@ static void musicpal_init(MachineState *machine) |
75 | - * The SHA-1/SHA-256 3-register instructions require special treatment | 48 | */ |
76 | - * here, as their size field is overloaded as an op type selector, and | 49 | pflash_cfi02_register(0x100000000ULL - MP_FLASH_SIZE_MAX, |
77 | - * they all consume their input in a single pass. | 50 | "musicpal.flash", flash_size, |
78 | - */ | 51 | - blk, 0x10000, |
79 | - if (op == NEON_3R_SHA) { | 52 | + blk, FLASH_SECTOR_SIZE, |
80 | + switch (op) { | 53 | MP_FLASH_SIZE_MAX / flash_size, |
81 | + case NEON_3R_SHA: | 54 | 2, 0x00BF, 0x236D, 0x0000, 0x0000, |
82 | + /* The SHA-1/SHA-256 3-register instructions require special | 55 | 0x5555, 0x2AAA, 0); |
83 | + * treatment here, as their size field is overloaded as an | ||
84 | + * op type selector, and they all consume their input in a | ||
85 | + * single pass. | ||
86 | + */ | ||
87 | if (!q) { | ||
88 | return 1; | ||
89 | } | ||
90 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
91 | tcg_temp_free_ptr(ptr2); | ||
92 | tcg_temp_free_ptr(ptr3); | ||
93 | return 0; | ||
94 | + | ||
95 | + case NEON_3R_VPADD_VQRDMLAH: | ||
96 | + if (!u) { | ||
97 | + break; /* VPADD */ | ||
98 | + } | ||
99 | + /* VQRDMLAH */ | ||
100 | + switch (size) { | ||
101 | + case 1: | ||
102 | + return do_v81_helper(s, gen_helper_gvec_qrdmlah_s16, | ||
103 | + q, rd, rn, rm); | ||
104 | + case 2: | ||
105 | + return do_v81_helper(s, gen_helper_gvec_qrdmlah_s32, | ||
106 | + q, rd, rn, rm); | ||
107 | + } | ||
108 | + return 1; | ||
109 | + | ||
110 | + case NEON_3R_VFM_VQRDMLSH: | ||
111 | + if (!u) { | ||
112 | + /* VFM, VFMS */ | ||
113 | + if (size == 1) { | ||
114 | + return 1; | ||
115 | + } | ||
116 | + break; | ||
117 | + } | ||
118 | + /* VQRDMLSH */ | ||
119 | + switch (size) { | ||
120 | + case 1: | ||
121 | + return do_v81_helper(s, gen_helper_gvec_qrdmlsh_s16, | ||
122 | + q, rd, rn, rm); | ||
123 | + case 2: | ||
124 | + return do_v81_helper(s, gen_helper_gvec_qrdmlsh_s32, | ||
125 | + q, rd, rn, rm); | ||
126 | + } | ||
127 | + return 1; | ||
128 | } | ||
129 | if (size == 3 && op != NEON_3R_LOGIC) { | ||
130 | /* 64-bit element instructions. */ | ||
131 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
132 | rm = rtmp; | ||
133 | } | ||
134 | break; | ||
135 | - case NEON_3R_VPADD: | ||
136 | - if (u) { | ||
137 | - return 1; | ||
138 | - } | ||
139 | - /* Fall through */ | ||
140 | + case NEON_3R_VPADD_VQRDMLAH: | ||
141 | case NEON_3R_VPMAX: | ||
142 | case NEON_3R_VPMIN: | ||
143 | pairwise = 1; | ||
144 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
145 | return 1; | ||
146 | } | ||
147 | break; | ||
148 | - case NEON_3R_VFM: | ||
149 | - if (!arm_dc_feature(s, ARM_FEATURE_VFP4) || u) { | ||
150 | + case NEON_3R_VFM_VQRDMLSH: | ||
151 | + if (!arm_dc_feature(s, ARM_FEATURE_VFP4)) { | ||
152 | return 1; | ||
153 | } | ||
154 | break; | ||
155 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
156 | } | ||
157 | } | ||
158 | break; | ||
159 | - case NEON_3R_VPADD: | ||
160 | + case NEON_3R_VPADD_VQRDMLAH: | ||
161 | switch (size) { | ||
162 | case 0: gen_helper_neon_padd_u8(tmp, tmp, tmp2); break; | ||
163 | case 1: gen_helper_neon_padd_u16(tmp, tmp, tmp2); break; | ||
164 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
165 | } | ||
166 | } | ||
167 | break; | ||
168 | - case NEON_3R_VFM: | ||
169 | + case NEON_3R_VFM_VQRDMLSH: | ||
170 | { | ||
171 | /* VFMA, VFMS: fused multiply-add */ | ||
172 | TCGv_ptr fpstatus = get_fpstatus_ptr(1); | ||
173 | -- | 56 | -- |
174 | 2.16.2 | 57 | 2.34.1 |
175 | 58 | ||
176 | 59 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Enable it for the "any" CPU used by *-linux-user. | 3 | The total_ram_v1/total_ram_v2 definitions were never used. |
4 | 4 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20180228193125.20577-17-richard.henderson@linaro.org | 7 | Message-id: 20230109115316.2235-10-philmd@linaro.org |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 9 | --- |
10 | target/arm/cpu.c | 1 + | 10 | hw/arm/omap_sx1.c | 2 -- |
11 | target/arm/cpu64.c | 1 + | 11 | 1 file changed, 2 deletions(-) |
12 | 2 files changed, 2 insertions(+) | ||
13 | 12 | ||
14 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 13 | diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c |
15 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/cpu.c | 15 | --- a/hw/arm/omap_sx1.c |
17 | +++ b/target/arm/cpu.c | 16 | +++ b/hw/arm/omap_sx1.c |
18 | @@ -XXX,XX +XXX,XX @@ static void arm_any_initfn(Object *obj) | 17 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps static_ops = { |
19 | set_feature(&cpu->env, ARM_FEATURE_V8_PMULL); | 18 | #define flash0_size (16 * 1024 * 1024) |
20 | set_feature(&cpu->env, ARM_FEATURE_CRC); | 19 | #define flash1_size ( 8 * 1024 * 1024) |
21 | set_feature(&cpu->env, ARM_FEATURE_V8_RDM); | 20 | #define flash2_size (32 * 1024 * 1024) |
22 | + set_feature(&cpu->env, ARM_FEATURE_V8_FCMA); | 21 | -#define total_ram_v1 (sdram_size + flash0_size + flash1_size + OMAP15XX_SRAM_SIZE) |
23 | cpu->midr = 0xffffffff; | 22 | -#define total_ram_v2 (sdram_size + flash2_size + OMAP15XX_SRAM_SIZE) |
24 | } | 23 | |
25 | #endif | 24 | static struct arm_boot_info sx1_binfo = { |
26 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 25 | .loader_start = OMAP_EMIFF_BASE, |
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/target/arm/cpu64.c | ||
29 | +++ b/target/arm/cpu64.c | ||
30 | @@ -XXX,XX +XXX,XX @@ static void aarch64_any_initfn(Object *obj) | ||
31 | set_feature(&cpu->env, ARM_FEATURE_CRC); | ||
32 | set_feature(&cpu->env, ARM_FEATURE_V8_RDM); | ||
33 | set_feature(&cpu->env, ARM_FEATURE_V8_FP16); | ||
34 | + set_feature(&cpu->env, ARM_FEATURE_V8_FCMA); | ||
35 | cpu->ctr = 0x80038003; /* 32 byte I and D cacheline size, VIPT icache */ | ||
36 | cpu->dcz_blocksize = 7; /* 512 bytes */ | ||
37 | } | ||
38 | -- | 26 | -- |
39 | 2.16.2 | 27 | 2.34.1 |
40 | 28 | ||
41 | 29 | diff view generated by jsdifflib |
1 | Instead of loading kernels, device trees, and the like to | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | the system address space, use the CPU's address space. This | ||
3 | is important if we're trying to load the file to memory or | ||
4 | via an alias memory region that is provided by an SoC | ||
5 | object and thus not mapped into the system address space. | ||
6 | 2 | ||
3 | IEC binary prefixes ease code review: the unit is explicit. | ||
4 | |||
5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20230109115316.2235-11-philmd@linaro.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20180220180325.29818-3-peter.maydell@linaro.org | ||
11 | --- | 9 | --- |
12 | hw/arm/boot.c | 119 +++++++++++++++++++++++++++++++++++++--------------------- | 10 | hw/arm/omap_sx1.c | 33 +++++++++++++++++---------------- |
13 | 1 file changed, 76 insertions(+), 43 deletions(-) | 11 | 1 file changed, 17 insertions(+), 16 deletions(-) |
14 | 12 | ||
15 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | 13 | diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c |
16 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/boot.c | 15 | --- a/hw/arm/omap_sx1.c |
18 | +++ b/hw/arm/boot.c | 16 | +++ b/hw/arm/omap_sx1.c |
19 | @@ -XXX,XX +XXX,XX @@ | 17 | @@ -XXX,XX +XXX,XX @@ |
20 | #define ARM64_TEXT_OFFSET_OFFSET 8 | 18 | * with this program; if not, see <http://www.gnu.org/licenses/>. |
21 | #define ARM64_MAGIC_OFFSET 56 | 19 | */ |
22 | 20 | #include "qemu/osdep.h" | |
23 | +static AddressSpace *arm_boot_address_space(ARMCPU *cpu, | 21 | +#include "qemu/units.h" |
24 | + const struct arm_boot_info *info) | 22 | #include "qapi/error.h" |
25 | +{ | 23 | #include "ui/console.h" |
26 | + /* Return the address space to use for bootloader reads and writes. | 24 | #include "hw/arm/omap.h" |
27 | + * We prefer the secure address space if the CPU has it and we're | 25 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps static_ops = { |
28 | + * going to boot the guest into it. | 26 | .endianness = DEVICE_NATIVE_ENDIAN, |
29 | + */ | ||
30 | + int asidx; | ||
31 | + CPUState *cs = CPU(cpu); | ||
32 | + | ||
33 | + if (arm_feature(&cpu->env, ARM_FEATURE_EL3) && info->secure_boot) { | ||
34 | + asidx = ARMASIdx_S; | ||
35 | + } else { | ||
36 | + asidx = ARMASIdx_NS; | ||
37 | + } | ||
38 | + | ||
39 | + return cpu_get_address_space(cs, asidx); | ||
40 | +} | ||
41 | + | ||
42 | typedef enum { | ||
43 | FIXUP_NONE = 0, /* do nothing */ | ||
44 | FIXUP_TERMINATOR, /* end of insns */ | ||
45 | @@ -XXX,XX +XXX,XX @@ static const ARMInsnFixup smpboot[] = { | ||
46 | }; | 27 | }; |
47 | 28 | ||
48 | static void write_bootloader(const char *name, hwaddr addr, | 29 | -#define sdram_size 0x02000000 |
49 | - const ARMInsnFixup *insns, uint32_t *fixupcontext) | 30 | -#define sector_size (128 * 1024) |
50 | + const ARMInsnFixup *insns, uint32_t *fixupcontext, | 31 | -#define flash0_size (16 * 1024 * 1024) |
51 | + AddressSpace *as) | 32 | -#define flash1_size ( 8 * 1024 * 1024) |
52 | { | 33 | -#define flash2_size (32 * 1024 * 1024) |
53 | /* Fix up the specified bootloader fragment and write it into | 34 | +#define SDRAM_SIZE (32 * MiB) |
54 | * guest memory using rom_add_blob_fixed(). fixupcontext is | 35 | +#define SECTOR_SIZE (128 * KiB) |
55 | @@ -XXX,XX +XXX,XX @@ static void write_bootloader(const char *name, hwaddr addr, | 36 | +#define FLASH0_SIZE (16 * MiB) |
56 | code[i] = tswap32(insn); | 37 | +#define FLASH1_SIZE (8 * MiB) |
38 | +#define FLASH2_SIZE (32 * MiB) | ||
39 | |||
40 | static struct arm_boot_info sx1_binfo = { | ||
41 | .loader_start = OMAP_EMIFF_BASE, | ||
42 | - .ram_size = sdram_size, | ||
43 | + .ram_size = SDRAM_SIZE, | ||
44 | .board_id = 0x265, | ||
45 | }; | ||
46 | |||
47 | @@ -XXX,XX +XXX,XX @@ static void sx1_init(MachineState *machine, const int version) | ||
48 | static uint32_t cs3val = 0x00001139; | ||
49 | DriveInfo *dinfo; | ||
50 | int fl_idx; | ||
51 | - uint32_t flash_size = flash0_size; | ||
52 | + uint32_t flash_size = FLASH0_SIZE; | ||
53 | |||
54 | if (machine->ram_size != mc->default_ram_size) { | ||
55 | char *sz = size_to_str(mc->default_ram_size); | ||
56 | @@ -XXX,XX +XXX,XX @@ static void sx1_init(MachineState *machine, const int version) | ||
57 | } | 57 | } |
58 | 58 | ||
59 | - rom_add_blob_fixed(name, code, len * sizeof(uint32_t), addr); | 59 | if (version == 2) { |
60 | + rom_add_blob_fixed_as(name, code, len * sizeof(uint32_t), addr, as); | 60 | - flash_size = flash2_size; |
61 | 61 | + flash_size = FLASH2_SIZE; | |
62 | g_free(code); | 62 | } |
63 | |||
64 | memory_region_add_subregion(address_space, OMAP_EMIFF_BASE, machine->ram); | ||
65 | @@ -XXX,XX +XXX,XX @@ static void sx1_init(MachineState *machine, const int version) | ||
66 | if (!pflash_cfi01_register(OMAP_CS0_BASE, | ||
67 | "omap_sx1.flash0-1", flash_size, | ||
68 | blk_by_legacy_dinfo(dinfo), | ||
69 | - sector_size, 4, 0, 0, 0, 0, 0)) { | ||
70 | + SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) { | ||
71 | fprintf(stderr, "qemu: Error registering flash memory %d.\n", | ||
72 | fl_idx); | ||
73 | } | ||
74 | @@ -XXX,XX +XXX,XX @@ static void sx1_init(MachineState *machine, const int version) | ||
75 | (dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) { | ||
76 | MemoryRegion *flash_1 = g_new(MemoryRegion, 1); | ||
77 | memory_region_init_rom(flash_1, NULL, "omap_sx1.flash1-0", | ||
78 | - flash1_size, &error_fatal); | ||
79 | + FLASH1_SIZE, &error_fatal); | ||
80 | memory_region_add_subregion(address_space, OMAP_CS1_BASE, flash_1); | ||
81 | |||
82 | memory_region_init_io(&cs[1], NULL, &static_ops, &cs1val, | ||
83 | - "sx1.cs1", OMAP_CS1_SIZE - flash1_size); | ||
84 | + "sx1.cs1", OMAP_CS1_SIZE - FLASH1_SIZE); | ||
85 | memory_region_add_subregion(address_space, | ||
86 | - OMAP_CS1_BASE + flash1_size, &cs[1]); | ||
87 | + OMAP_CS1_BASE + FLASH1_SIZE, &cs[1]); | ||
88 | |||
89 | if (!pflash_cfi01_register(OMAP_CS1_BASE, | ||
90 | - "omap_sx1.flash1-1", flash1_size, | ||
91 | + "omap_sx1.flash1-1", FLASH1_SIZE, | ||
92 | blk_by_legacy_dinfo(dinfo), | ||
93 | - sector_size, 4, 0, 0, 0, 0, 0)) { | ||
94 | + SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) { | ||
95 | fprintf(stderr, "qemu: Error registering flash memory %d.\n", | ||
96 | fl_idx); | ||
97 | } | ||
98 | @@ -XXX,XX +XXX,XX @@ static void sx1_machine_v2_class_init(ObjectClass *oc, void *data) | ||
99 | mc->init = sx1_init_v2; | ||
100 | mc->ignore_memory_transaction_failures = true; | ||
101 | mc->default_cpu_type = ARM_CPU_TYPE_NAME("ti925t"); | ||
102 | - mc->default_ram_size = sdram_size; | ||
103 | + mc->default_ram_size = SDRAM_SIZE; | ||
104 | mc->default_ram_id = "omap1.dram"; | ||
63 | } | 105 | } |
64 | @@ -XXX,XX +XXX,XX @@ static void default_write_secondary(ARMCPU *cpu, | 106 | |
65 | const struct arm_boot_info *info) | 107 | @@ -XXX,XX +XXX,XX @@ static void sx1_machine_v1_class_init(ObjectClass *oc, void *data) |
66 | { | 108 | mc->init = sx1_init_v1; |
67 | uint32_t fixupcontext[FIXUP_MAX]; | 109 | mc->ignore_memory_transaction_failures = true; |
68 | + AddressSpace *as = arm_boot_address_space(cpu, info); | 110 | mc->default_cpu_type = ARM_CPU_TYPE_NAME("ti925t"); |
69 | 111 | - mc->default_ram_size = sdram_size; | |
70 | fixupcontext[FIXUP_GIC_CPU_IF] = info->gic_cpu_if_addr; | 112 | + mc->default_ram_size = SDRAM_SIZE; |
71 | fixupcontext[FIXUP_BOOTREG] = info->smp_bootreg_addr; | 113 | mc->default_ram_id = "omap1.dram"; |
72 | @@ -XXX,XX +XXX,XX @@ static void default_write_secondary(ARMCPU *cpu, | ||
73 | } | ||
74 | |||
75 | write_bootloader("smpboot", info->smp_loader_start, | ||
76 | - smpboot, fixupcontext); | ||
77 | + smpboot, fixupcontext, as); | ||
78 | } | 114 | } |
79 | 115 | ||
80 | void arm_write_secure_board_setup_dummy_smc(ARMCPU *cpu, | ||
81 | const struct arm_boot_info *info, | ||
82 | hwaddr mvbar_addr) | ||
83 | { | ||
84 | + AddressSpace *as = arm_boot_address_space(cpu, info); | ||
85 | int n; | ||
86 | uint32_t mvbar_blob[] = { | ||
87 | /* mvbar_addr: secure monitor vectors | ||
88 | @@ -XXX,XX +XXX,XX @@ void arm_write_secure_board_setup_dummy_smc(ARMCPU *cpu, | ||
89 | for (n = 0; n < ARRAY_SIZE(mvbar_blob); n++) { | ||
90 | mvbar_blob[n] = tswap32(mvbar_blob[n]); | ||
91 | } | ||
92 | - rom_add_blob_fixed("board-setup-mvbar", mvbar_blob, sizeof(mvbar_blob), | ||
93 | - mvbar_addr); | ||
94 | + rom_add_blob_fixed_as("board-setup-mvbar", mvbar_blob, sizeof(mvbar_blob), | ||
95 | + mvbar_addr, as); | ||
96 | |||
97 | for (n = 0; n < ARRAY_SIZE(board_setup_blob); n++) { | ||
98 | board_setup_blob[n] = tswap32(board_setup_blob[n]); | ||
99 | } | ||
100 | - rom_add_blob_fixed("board-setup", board_setup_blob, | ||
101 | - sizeof(board_setup_blob), info->board_setup_addr); | ||
102 | + rom_add_blob_fixed_as("board-setup", board_setup_blob, | ||
103 | + sizeof(board_setup_blob), info->board_setup_addr, as); | ||
104 | } | ||
105 | |||
106 | static void default_reset_secondary(ARMCPU *cpu, | ||
107 | const struct arm_boot_info *info) | ||
108 | { | ||
109 | + AddressSpace *as = arm_boot_address_space(cpu, info); | ||
110 | CPUState *cs = CPU(cpu); | ||
111 | |||
112 | - address_space_stl_notdirty(&address_space_memory, info->smp_bootreg_addr, | ||
113 | + address_space_stl_notdirty(as, info->smp_bootreg_addr, | ||
114 | 0, MEMTXATTRS_UNSPECIFIED, NULL); | ||
115 | cpu_set_pc(cs, info->smp_loader_start); | ||
116 | } | ||
117 | @@ -XXX,XX +XXX,XX @@ static inline bool have_dtb(const struct arm_boot_info *info) | ||
118 | } | ||
119 | |||
120 | #define WRITE_WORD(p, value) do { \ | ||
121 | - address_space_stl_notdirty(&address_space_memory, p, value, \ | ||
122 | + address_space_stl_notdirty(as, p, value, \ | ||
123 | MEMTXATTRS_UNSPECIFIED, NULL); \ | ||
124 | p += 4; \ | ||
125 | } while (0) | ||
126 | |||
127 | -static void set_kernel_args(const struct arm_boot_info *info) | ||
128 | +static void set_kernel_args(const struct arm_boot_info *info, AddressSpace *as) | ||
129 | { | ||
130 | int initrd_size = info->initrd_size; | ||
131 | hwaddr base = info->loader_start; | ||
132 | @@ -XXX,XX +XXX,XX @@ static void set_kernel_args(const struct arm_boot_info *info) | ||
133 | int cmdline_size; | ||
134 | |||
135 | cmdline_size = strlen(info->kernel_cmdline); | ||
136 | - cpu_physical_memory_write(p + 8, info->kernel_cmdline, | ||
137 | - cmdline_size + 1); | ||
138 | + address_space_write(as, p + 8, MEMTXATTRS_UNSPECIFIED, | ||
139 | + (const uint8_t *)info->kernel_cmdline, | ||
140 | + cmdline_size + 1); | ||
141 | cmdline_size = (cmdline_size >> 2) + 1; | ||
142 | WRITE_WORD(p, cmdline_size + 2); | ||
143 | WRITE_WORD(p, 0x54410009); | ||
144 | @@ -XXX,XX +XXX,XX @@ static void set_kernel_args(const struct arm_boot_info *info) | ||
145 | atag_board_len = (info->atag_board(info, atag_board_buf) + 3) & ~3; | ||
146 | WRITE_WORD(p, (atag_board_len + 8) >> 2); | ||
147 | WRITE_WORD(p, 0x414f4d50); | ||
148 | - cpu_physical_memory_write(p, atag_board_buf, atag_board_len); | ||
149 | + address_space_write(as, p, MEMTXATTRS_UNSPECIFIED, | ||
150 | + atag_board_buf, atag_board_len); | ||
151 | p += atag_board_len; | ||
152 | } | ||
153 | /* ATAG_END */ | ||
154 | @@ -XXX,XX +XXX,XX @@ static void set_kernel_args(const struct arm_boot_info *info) | ||
155 | WRITE_WORD(p, 0); | ||
156 | } | ||
157 | |||
158 | -static void set_kernel_args_old(const struct arm_boot_info *info) | ||
159 | +static void set_kernel_args_old(const struct arm_boot_info *info, | ||
160 | + AddressSpace *as) | ||
161 | { | ||
162 | hwaddr p; | ||
163 | const char *s; | ||
164 | @@ -XXX,XX +XXX,XX @@ static void set_kernel_args_old(const struct arm_boot_info *info) | ||
165 | } | ||
166 | s = info->kernel_cmdline; | ||
167 | if (s) { | ||
168 | - cpu_physical_memory_write(p, s, strlen(s) + 1); | ||
169 | + address_space_write(as, p, MEMTXATTRS_UNSPECIFIED, | ||
170 | + (const uint8_t *)s, strlen(s) + 1); | ||
171 | } else { | ||
172 | WRITE_WORD(p, 0); | ||
173 | } | ||
174 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_psci_node(void *fdt) | ||
175 | * @addr: the address to load the image at | ||
176 | * @binfo: struct describing the boot environment | ||
177 | * @addr_limit: upper limit of the available memory area at @addr | ||
178 | + * @as: address space to load image to | ||
179 | * | ||
180 | * Load a device tree supplied by the machine or by the user with the | ||
181 | * '-dtb' command line option, and put it at offset @addr in target | ||
182 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_psci_node(void *fdt) | ||
183 | * Note: Must not be called unless have_dtb(binfo) is true. | ||
184 | */ | ||
185 | static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo, | ||
186 | - hwaddr addr_limit) | ||
187 | + hwaddr addr_limit, AddressSpace *as) | ||
188 | { | ||
189 | void *fdt = NULL; | ||
190 | int size, rc; | ||
191 | @@ -XXX,XX +XXX,XX @@ static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo, | ||
192 | /* Put the DTB into the memory map as a ROM image: this will ensure | ||
193 | * the DTB is copied again upon reset, even if addr points into RAM. | ||
194 | */ | ||
195 | - rom_add_blob_fixed("dtb", fdt, size, addr); | ||
196 | + rom_add_blob_fixed_as("dtb", fdt, size, addr, as); | ||
197 | |||
198 | g_free(fdt); | ||
199 | |||
200 | @@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque) | ||
201 | } | ||
202 | |||
203 | if (cs == first_cpu) { | ||
204 | + AddressSpace *as = arm_boot_address_space(cpu, info); | ||
205 | + | ||
206 | cpu_set_pc(cs, info->loader_start); | ||
207 | |||
208 | if (!have_dtb(info)) { | ||
209 | if (old_param) { | ||
210 | - set_kernel_args_old(info); | ||
211 | + set_kernel_args_old(info, as); | ||
212 | } else { | ||
213 | - set_kernel_args(info); | ||
214 | + set_kernel_args(info, as); | ||
215 | } | ||
216 | } | ||
217 | } else { | ||
218 | @@ -XXX,XX +XXX,XX @@ static int do_arm_linux_init(Object *obj, void *opaque) | ||
219 | |||
220 | static uint64_t arm_load_elf(struct arm_boot_info *info, uint64_t *pentry, | ||
221 | uint64_t *lowaddr, uint64_t *highaddr, | ||
222 | - int elf_machine) | ||
223 | + int elf_machine, AddressSpace *as) | ||
224 | { | ||
225 | bool elf_is64; | ||
226 | union { | ||
227 | @@ -XXX,XX +XXX,XX @@ static uint64_t arm_load_elf(struct arm_boot_info *info, uint64_t *pentry, | ||
228 | } | ||
229 | } | ||
230 | |||
231 | - ret = load_elf(info->kernel_filename, NULL, NULL, | ||
232 | - pentry, lowaddr, highaddr, big_endian, elf_machine, | ||
233 | - 1, data_swab); | ||
234 | + ret = load_elf_as(info->kernel_filename, NULL, NULL, | ||
235 | + pentry, lowaddr, highaddr, big_endian, elf_machine, | ||
236 | + 1, data_swab, as); | ||
237 | if (ret <= 0) { | ||
238 | /* The header loaded but the image didn't */ | ||
239 | exit(1); | ||
240 | @@ -XXX,XX +XXX,XX @@ static uint64_t arm_load_elf(struct arm_boot_info *info, uint64_t *pentry, | ||
241 | } | ||
242 | |||
243 | static uint64_t load_aarch64_image(const char *filename, hwaddr mem_base, | ||
244 | - hwaddr *entry) | ||
245 | + hwaddr *entry, AddressSpace *as) | ||
246 | { | ||
247 | hwaddr kernel_load_offset = KERNEL64_LOAD_ADDR; | ||
248 | uint8_t *buffer; | ||
249 | @@ -XXX,XX +XXX,XX @@ static uint64_t load_aarch64_image(const char *filename, hwaddr mem_base, | ||
250 | } | ||
251 | |||
252 | *entry = mem_base + kernel_load_offset; | ||
253 | - rom_add_blob_fixed(filename, buffer, size, *entry); | ||
254 | + rom_add_blob_fixed_as(filename, buffer, size, *entry, as); | ||
255 | |||
256 | g_free(buffer); | ||
257 | |||
258 | @@ -XXX,XX +XXX,XX @@ static void arm_load_kernel_notify(Notifier *notifier, void *data) | ||
259 | ARMCPU *cpu = n->cpu; | ||
260 | struct arm_boot_info *info = | ||
261 | container_of(n, struct arm_boot_info, load_kernel_notifier); | ||
262 | + AddressSpace *as = arm_boot_address_space(cpu, info); | ||
263 | |||
264 | /* The board code is not supposed to set secure_board_setup unless | ||
265 | * running its code in secure mode is actually possible, and KVM | ||
266 | @@ -XXX,XX +XXX,XX @@ static void arm_load_kernel_notify(Notifier *notifier, void *data) | ||
267 | * the kernel is supposed to be loaded by the bootloader), copy the | ||
268 | * DTB to the base of RAM for the bootloader to pick up. | ||
269 | */ | ||
270 | - if (load_dtb(info->loader_start, info, 0) < 0) { | ||
271 | + if (load_dtb(info->loader_start, info, 0, as) < 0) { | ||
272 | exit(1); | ||
273 | } | ||
274 | } | ||
275 | @@ -XXX,XX +XXX,XX @@ static void arm_load_kernel_notify(Notifier *notifier, void *data) | ||
276 | |||
277 | /* Assume that raw images are linux kernels, and ELF images are not. */ | ||
278 | kernel_size = arm_load_elf(info, &elf_entry, &elf_low_addr, | ||
279 | - &elf_high_addr, elf_machine); | ||
280 | + &elf_high_addr, elf_machine, as); | ||
281 | if (kernel_size > 0 && have_dtb(info)) { | ||
282 | /* If there is still some room left at the base of RAM, try and put | ||
283 | * the DTB there like we do for images loaded with -bios or -pflash. | ||
284 | @@ -XXX,XX +XXX,XX @@ static void arm_load_kernel_notify(Notifier *notifier, void *data) | ||
285 | if (elf_low_addr < info->loader_start) { | ||
286 | elf_low_addr = 0; | ||
287 | } | ||
288 | - if (load_dtb(info->loader_start, info, elf_low_addr) < 0) { | ||
289 | + if (load_dtb(info->loader_start, info, elf_low_addr, as) < 0) { | ||
290 | exit(1); | ||
291 | } | ||
292 | } | ||
293 | } | ||
294 | entry = elf_entry; | ||
295 | if (kernel_size < 0) { | ||
296 | - kernel_size = load_uimage(info->kernel_filename, &entry, NULL, | ||
297 | - &is_linux, NULL, NULL); | ||
298 | + kernel_size = load_uimage_as(info->kernel_filename, &entry, NULL, | ||
299 | + &is_linux, NULL, NULL, as); | ||
300 | } | ||
301 | if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64) && kernel_size < 0) { | ||
302 | kernel_size = load_aarch64_image(info->kernel_filename, | ||
303 | - info->loader_start, &entry); | ||
304 | + info->loader_start, &entry, as); | ||
305 | is_linux = 1; | ||
306 | } else if (kernel_size < 0) { | ||
307 | /* 32-bit ARM */ | ||
308 | entry = info->loader_start + KERNEL_LOAD_ADDR; | ||
309 | - kernel_size = load_image_targphys(info->kernel_filename, entry, | ||
310 | - info->ram_size - KERNEL_LOAD_ADDR); | ||
311 | + kernel_size = load_image_targphys_as(info->kernel_filename, entry, | ||
312 | + info->ram_size - KERNEL_LOAD_ADDR, | ||
313 | + as); | ||
314 | is_linux = 1; | ||
315 | } | ||
316 | if (kernel_size < 0) { | ||
317 | @@ -XXX,XX +XXX,XX @@ static void arm_load_kernel_notify(Notifier *notifier, void *data) | ||
318 | uint32_t fixupcontext[FIXUP_MAX]; | ||
319 | |||
320 | if (info->initrd_filename) { | ||
321 | - initrd_size = load_ramdisk(info->initrd_filename, | ||
322 | - info->initrd_start, | ||
323 | - info->ram_size - | ||
324 | - info->initrd_start); | ||
325 | + initrd_size = load_ramdisk_as(info->initrd_filename, | ||
326 | + info->initrd_start, | ||
327 | + info->ram_size - info->initrd_start, | ||
328 | + as); | ||
329 | if (initrd_size < 0) { | ||
330 | - initrd_size = load_image_targphys(info->initrd_filename, | ||
331 | - info->initrd_start, | ||
332 | - info->ram_size - | ||
333 | - info->initrd_start); | ||
334 | + initrd_size = load_image_targphys_as(info->initrd_filename, | ||
335 | + info->initrd_start, | ||
336 | + info->ram_size - | ||
337 | + info->initrd_start, | ||
338 | + as); | ||
339 | } | ||
340 | if (initrd_size < 0) { | ||
341 | error_report("could not load initrd '%s'", | ||
342 | @@ -XXX,XX +XXX,XX @@ static void arm_load_kernel_notify(Notifier *notifier, void *data) | ||
343 | |||
344 | /* Place the DTB after the initrd in memory with alignment. */ | ||
345 | dtb_start = QEMU_ALIGN_UP(info->initrd_start + initrd_size, align); | ||
346 | - if (load_dtb(dtb_start, info, 0) < 0) { | ||
347 | + if (load_dtb(dtb_start, info, 0, as) < 0) { | ||
348 | exit(1); | ||
349 | } | ||
350 | fixupcontext[FIXUP_ARGPTR] = dtb_start; | ||
351 | @@ -XXX,XX +XXX,XX @@ static void arm_load_kernel_notify(Notifier *notifier, void *data) | ||
352 | fixupcontext[FIXUP_ENTRYPOINT] = entry; | ||
353 | |||
354 | write_bootloader("bootloader", info->loader_start, | ||
355 | - primary_loader, fixupcontext); | ||
356 | + primary_loader, fixupcontext, as); | ||
357 | |||
358 | if (info->nb_cpus > 1) { | ||
359 | info->write_secondary_boot(cpu, info); | ||
360 | -- | 116 | -- |
361 | 2.16.2 | 117 | 2.34.1 |
362 | 118 | ||
363 | 119 | diff view generated by jsdifflib |
1 | The or-irq.h header file is missing the customary guard against | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | multiple inclusion, which means compilation fails if it gets | ||
3 | included twice. Fix the omission. | ||
4 | 2 | ||
3 | IEC binary prefixes ease code review: the unit is explicit. | ||
4 | |||
5 | Add the FLASH_SECTOR_SIZE definition. | ||
6 | |||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20230109115316.2235-12-philmd@linaro.org | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20180220180325.29818-11-peter.maydell@linaro.org | ||
9 | --- | 11 | --- |
10 | include/hw/or-irq.h | 5 +++++ | 12 | hw/arm/z2.c | 6 ++++-- |
11 | 1 file changed, 5 insertions(+) | 13 | 1 file changed, 4 insertions(+), 2 deletions(-) |
12 | 14 | ||
13 | diff --git a/include/hw/or-irq.h b/include/hw/or-irq.h | 15 | diff --git a/hw/arm/z2.c b/hw/arm/z2.c |
14 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/include/hw/or-irq.h | 17 | --- a/hw/arm/z2.c |
16 | +++ b/include/hw/or-irq.h | 18 | +++ b/hw/arm/z2.c |
17 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ |
18 | * THE SOFTWARE. | ||
19 | */ | 20 | */ |
20 | 21 | ||
21 | +#ifndef HW_OR_IRQ_H | 22 | #include "qemu/osdep.h" |
22 | +#define HW_OR_IRQ_H | 23 | +#include "qemu/units.h" |
24 | #include "hw/arm/pxa.h" | ||
25 | #include "hw/arm/boot.h" | ||
26 | #include "hw/i2c/i2c.h" | ||
27 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo aer915_info = { | ||
28 | .class_init = aer915_class_init, | ||
29 | }; | ||
30 | |||
31 | +#define FLASH_SECTOR_SIZE (64 * KiB) | ||
23 | + | 32 | + |
24 | #include "hw/irq.h" | 33 | static void z2_init(MachineState *machine) |
25 | #include "hw/sysbus.h" | 34 | { |
26 | #include "qom/object.h" | 35 | - uint32_t sector_len = 0x10000; |
27 | @@ -XXX,XX +XXX,XX @@ struct OrIRQState { | 36 | PXA2xxState *mpu; |
28 | bool levels[MAX_OR_LINES]; | 37 | DriveInfo *dinfo; |
29 | uint16_t num_lines; | 38 | void *z2_lcd; |
30 | }; | 39 | @@ -XXX,XX +XXX,XX @@ static void z2_init(MachineState *machine) |
31 | + | 40 | dinfo = drive_get(IF_PFLASH, 0, 0); |
32 | +#endif | 41 | if (!pflash_cfi01_register(Z2_FLASH_BASE, "z2.flash0", Z2_FLASH_SIZE, |
42 | dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, | ||
43 | - sector_len, 4, 0, 0, 0, 0, 0)) { | ||
44 | + FLASH_SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) { | ||
45 | error_report("Error registering flash memory"); | ||
46 | exit(1); | ||
47 | } | ||
33 | -- | 48 | -- |
34 | 2.16.2 | 49 | 2.34.1 |
35 | 50 | ||
36 | 51 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The integer size check was already outside of the opcode switch; | 3 | Upon introduction in commit b8433303fb ("Set proper device-width |
4 | move the floating-point size check outside as well. Unify the | 4 | for vexpress flash"), ve_pflash_cfi01_register() was calling |
5 | size vs index adjustment between fp and integer paths. | 5 | qdev_init_nofail() which can not fail. This call was later |
6 | converted with a script to use &error_fatal, still unable to | ||
7 | fail. Remove the unreachable code. | ||
6 | 8 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20180228193125.20577-4-richard.henderson@linaro.org | 11 | Message-id: 20230109115316.2235-13-philmd@linaro.org |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 13 | --- |
12 | target/arm/translate-a64.c | 65 +++++++++++++++++++++++----------------------- | 14 | hw/arm/vexpress.c | 10 +--------- |
13 | 1 file changed, 32 insertions(+), 33 deletions(-) | 15 | 1 file changed, 1 insertion(+), 9 deletions(-) |
14 | 16 | ||
15 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 17 | diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c |
16 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate-a64.c | 19 | --- a/hw/arm/vexpress.c |
18 | +++ b/target/arm/translate-a64.c | 20 | +++ b/hw/arm/vexpress.c |
19 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | 21 | @@ -XXX,XX +XXX,XX @@ static void vexpress_common_init(MachineState *machine) |
20 | case 0x05: /* FMLS */ | 22 | dinfo = drive_get(IF_PFLASH, 0, 0); |
21 | case 0x09: /* FMUL */ | 23 | pflash0 = ve_pflash_cfi01_register(map[VE_NORFLASH0], "vexpress.flash0", |
22 | case 0x19: /* FMULX */ | 24 | dinfo); |
23 | - if (size == 1) { | 25 | - if (!pflash0) { |
24 | - unallocated_encoding(s); | 26 | - error_report("vexpress: error registering flash 0"); |
25 | - return; | 27 | - exit(1); |
26 | - } | 28 | - } |
27 | is_fp = true; | 29 | |
28 | break; | 30 | if (map[VE_NORFLASHALIAS] != -1) { |
29 | default: | 31 | /* Map flash 0 as an alias into low memory */ |
30 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | 32 | @@ -XXX,XX +XXX,XX @@ static void vexpress_common_init(MachineState *machine) |
31 | if (is_fp) { | ||
32 | /* convert insn encoded size to TCGMemOp size */ | ||
33 | switch (size) { | ||
34 | - case 2: /* single precision */ | ||
35 | - size = MO_32; | ||
36 | - index = h << 1 | l; | ||
37 | - rm |= (m << 4); | ||
38 | - break; | ||
39 | - case 3: /* double precision */ | ||
40 | - size = MO_64; | ||
41 | - if (l || !is_q) { | ||
42 | + case 0: /* half-precision */ | ||
43 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
44 | unallocated_encoding(s); | ||
45 | return; | ||
46 | } | ||
47 | - index = h; | ||
48 | - rm |= (m << 4); | ||
49 | - break; | ||
50 | - case 0: /* half precision */ | ||
51 | size = MO_16; | ||
52 | - index = h << 2 | l << 1 | m; | ||
53 | - is_fp16 = true; | ||
54 | - if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
55 | - break; | ||
56 | - } | ||
57 | - /* fallthru */ | ||
58 | - default: /* unallocated */ | ||
59 | - unallocated_encoding(s); | ||
60 | - return; | ||
61 | - } | ||
62 | - } else { | ||
63 | - switch (size) { | ||
64 | - case 1: | ||
65 | - index = h << 2 | l << 1 | m; | ||
66 | break; | ||
67 | - case 2: | ||
68 | - index = h << 1 | l; | ||
69 | - rm |= (m << 4); | ||
70 | + case MO_32: /* single precision */ | ||
71 | + case MO_64: /* double precision */ | ||
72 | break; | ||
73 | default: | ||
74 | unallocated_encoding(s); | ||
75 | return; | ||
76 | } | ||
77 | + } else { | ||
78 | + switch (size) { | ||
79 | + case MO_8: | ||
80 | + case MO_64: | ||
81 | + unallocated_encoding(s); | ||
82 | + return; | ||
83 | + } | ||
84 | + } | ||
85 | + | ||
86 | + /* Given TCGMemOp size, adjust register and indexing. */ | ||
87 | + switch (size) { | ||
88 | + case MO_16: | ||
89 | + index = h << 2 | l << 1 | m; | ||
90 | + break; | ||
91 | + case MO_32: | ||
92 | + index = h << 1 | l; | ||
93 | + rm |= m << 4; | ||
94 | + break; | ||
95 | + case MO_64: | ||
96 | + if (l || !is_q) { | ||
97 | + unallocated_encoding(s); | ||
98 | + return; | ||
99 | + } | ||
100 | + index = h; | ||
101 | + rm |= m << 4; | ||
102 | + break; | ||
103 | + default: | ||
104 | + g_assert_not_reached(); | ||
105 | } | 33 | } |
106 | 34 | ||
107 | if (!fp_access_check(s)) { | 35 | dinfo = drive_get(IF_PFLASH, 0, 1); |
36 | - if (!ve_pflash_cfi01_register(map[VE_NORFLASH1], "vexpress.flash1", | ||
37 | - dinfo)) { | ||
38 | - error_report("vexpress: error registering flash 1"); | ||
39 | - exit(1); | ||
40 | - } | ||
41 | + ve_pflash_cfi01_register(map[VE_NORFLASH1], "vexpress.flash1", dinfo); | ||
42 | |||
43 | sram_size = 0x2000000; | ||
44 | memory_region_init_ram(sram, NULL, "vexpress.sram", sram_size, | ||
108 | -- | 45 | -- |
109 | 2.16.2 | 46 | 2.34.1 |
110 | 47 | ||
111 | 48 | diff view generated by jsdifflib |
1 | Add remaining easy registers to iotkit-secctl: | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | * NSCCFG just routes its two bits out to external GPIO lines | ||
3 | * BRGINSTAT/BRGINTCLR/BRGINTEN can be dummies, because QEMU's | ||
4 | bus fabric can never report errors | ||
5 | 2 | ||
3 | Since its QOM'ification in commit 368a354f02 ("pflash_cfi0x: | ||
4 | QOMified") the pflash_cfi01_register() function does not fail. | ||
5 | |||
6 | This call was later converted with a script to use &error_fatal, | ||
7 | still unable to fail. Remove the unreachable code. | ||
8 | |||
9 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20230109115316.2235-14-philmd@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Message-id: 20180220180325.29818-18-peter.maydell@linaro.org | ||
8 | --- | 13 | --- |
9 | include/hw/misc/iotkit-secctl.h | 4 ++++ | 14 | hw/arm/gumstix.c | 18 ++++++------------ |
10 | hw/misc/iotkit-secctl.c | 32 ++++++++++++++++++++++++++------ | 15 | hw/arm/mainstone.c | 13 +++++-------- |
11 | 2 files changed, 30 insertions(+), 6 deletions(-) | 16 | hw/arm/omap_sx1.c | 22 ++++++++-------------- |
17 | hw/arm/versatilepb.c | 6 ++---- | ||
18 | hw/arm/z2.c | 9 +++------ | ||
19 | 5 files changed, 24 insertions(+), 44 deletions(-) | ||
12 | 20 | ||
13 | diff --git a/include/hw/misc/iotkit-secctl.h b/include/hw/misc/iotkit-secctl.h | 21 | diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c |
14 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/include/hw/misc/iotkit-secctl.h | 23 | --- a/hw/arm/gumstix.c |
16 | +++ b/include/hw/misc/iotkit-secctl.h | 24 | +++ b/hw/arm/gumstix.c |
17 | @@ -XXX,XX +XXX,XX @@ | 25 | @@ -XXX,XX +XXX,XX @@ static void connex_init(MachineState *machine) |
18 | * + sysbus MMIO region 1 is the "non-secure privilege control block" registers | 26 | } |
19 | * + named GPIO output "sec_resp_cfg" indicating whether blocked accesses | 27 | |
20 | * should RAZ/WI or bus error | 28 | /* Numonyx RC28F128J3F75 */ |
21 | + * + named GPIO output "nsc_cfg" whose value tracks the NSCCFG register value | 29 | - if (!pflash_cfi01_register(0x00000000, "connext.rom", CONNEX_FLASH_SIZE, |
22 | * Controlling the 2 APB PPCs in the IoTKit: | 30 | - dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, |
23 | * + named GPIO outputs apb_ppc0_nonsec[0..2] and apb_ppc1_nonsec | 31 | - FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0)) { |
24 | * + named GPIO outputs apb_ppc0_ap[0..2] and apb_ppc1_ap | 32 | - error_report("Error registering flash memory"); |
25 | @@ -XXX,XX +XXX,XX @@ struct IoTKitSecCtl { | 33 | - exit(1); |
26 | 34 | - } | |
27 | /*< public >*/ | 35 | + pflash_cfi01_register(0x00000000, "connext.rom", CONNEX_FLASH_SIZE, |
28 | qemu_irq sec_resp_cfg; | 36 | + dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, |
29 | + qemu_irq nsc_cfg_irq; | 37 | + FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0); |
30 | 38 | ||
31 | MemoryRegion s_regs; | 39 | /* Interrupt line of NIC is connected to GPIO line 36 */ |
32 | MemoryRegion ns_regs; | 40 | smc91c111_init(&nd_table[0], 0x04000300, |
33 | @@ -XXX,XX +XXX,XX @@ struct IoTKitSecCtl { | 41 | @@ -XXX,XX +XXX,XX @@ static void verdex_init(MachineState *machine) |
34 | uint32_t secppcintstat; | 42 | } |
35 | uint32_t secppcinten; | 43 | |
36 | uint32_t secrespcfg; | 44 | /* Micron RC28F256P30TFA */ |
37 | + uint32_t nsccfg; | 45 | - if (!pflash_cfi01_register(0x00000000, "verdex.rom", VERDEX_FLASH_SIZE, |
38 | + uint32_t brginten; | 46 | - dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, |
39 | 47 | - FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0)) { | |
40 | IoTKitSecCtlPPC apb[IOTS_NUM_APB_PPC]; | 48 | - error_report("Error registering flash memory"); |
41 | IoTKitSecCtlPPC apbexp[IOTS_NUM_APB_EXP_PPC]; | 49 | - exit(1); |
42 | diff --git a/hw/misc/iotkit-secctl.c b/hw/misc/iotkit-secctl.c | 50 | - } |
51 | + pflash_cfi01_register(0x00000000, "verdex.rom", VERDEX_FLASH_SIZE, | ||
52 | + dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, | ||
53 | + FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0); | ||
54 | |||
55 | /* Interrupt line of NIC is connected to GPIO line 99 */ | ||
56 | smc91c111_init(&nd_table[0], 0x04000300, | ||
57 | diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | 58 | index XXXXXXX..XXXXXXX 100644 |
44 | --- a/hw/misc/iotkit-secctl.c | 59 | --- a/hw/arm/mainstone.c |
45 | +++ b/hw/misc/iotkit-secctl.c | 60 | +++ b/hw/arm/mainstone.c |
46 | @@ -XXX,XX +XXX,XX @@ static MemTxResult iotkit_secctl_s_read(void *opaque, hwaddr addr, | 61 | @@ -XXX,XX +XXX,XX @@ static void mainstone_common_init(MachineState *machine, |
47 | case A_SECRESPCFG: | 62 | /* There are two 32MiB flash devices on the board */ |
48 | r = s->secrespcfg; | 63 | for (i = 0; i < 2; i ++) { |
49 | break; | 64 | dinfo = drive_get(IF_PFLASH, 0, i); |
50 | + case A_NSCCFG: | 65 | - if (!pflash_cfi01_register(mainstone_flash_base[i], |
51 | + r = s->nsccfg; | 66 | - i ? "mainstone.flash1" : "mainstone.flash0", |
52 | + break; | 67 | - MAINSTONE_FLASH_SIZE, |
53 | case A_SECPPCINTSTAT: | 68 | - dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, |
54 | r = s->secppcintstat; | 69 | - FLASH_SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) { |
55 | break; | 70 | - error_report("Error registering flash memory"); |
56 | case A_SECPPCINTEN: | 71 | - exit(1); |
57 | r = s->secppcinten; | 72 | - } |
58 | break; | 73 | + pflash_cfi01_register(mainstone_flash_base[i], |
59 | + case A_BRGINTSTAT: | 74 | + i ? "mainstone.flash1" : "mainstone.flash0", |
60 | + /* QEMU's bus fabric can never report errors as it doesn't buffer | 75 | + MAINSTONE_FLASH_SIZE, |
61 | + * writes, so we never report bridge interrupts. | 76 | + dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, |
62 | + */ | 77 | + FLASH_SECTOR_SIZE, 4, 0, 0, 0, 0, 0); |
63 | + r = 0; | ||
64 | + break; | ||
65 | + case A_BRGINTEN: | ||
66 | + r = s->brginten; | ||
67 | + break; | ||
68 | case A_AHBNSPPCEXP0: | ||
69 | case A_AHBNSPPCEXP1: | ||
70 | case A_AHBNSPPCEXP2: | ||
71 | @@ -XXX,XX +XXX,XX @@ static MemTxResult iotkit_secctl_s_read(void *opaque, hwaddr addr, | ||
72 | case A_APBSPPPCEXP3: | ||
73 | r = s->apbexp[offset_to_ppc_idx(offset)].sp; | ||
74 | break; | ||
75 | - case A_NSCCFG: | ||
76 | case A_SECMPCINTSTATUS: | ||
77 | case A_SECMSCINTSTAT: | ||
78 | case A_SECMSCINTEN: | ||
79 | - case A_BRGINTSTAT: | ||
80 | - case A_BRGINTEN: | ||
81 | case A_NSMSCEXP: | ||
82 | qemu_log_mask(LOG_UNIMP, | ||
83 | "IoTKit SecCtl S block read: " | ||
84 | @@ -XXX,XX +XXX,XX @@ static MemTxResult iotkit_secctl_s_write(void *opaque, hwaddr addr, | ||
85 | } | 78 | } |
86 | 79 | ||
87 | switch (offset) { | 80 | mst_irq = sysbus_create_simple("mainstone-fpga", MST_FPGA_PHYS, |
88 | + case A_NSCCFG: | 81 | diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c |
89 | + s->nsccfg = value & 3; | 82 | index XXXXXXX..XXXXXXX 100644 |
90 | + qemu_set_irq(s->nsc_cfg_irq, s->nsccfg); | 83 | --- a/hw/arm/omap_sx1.c |
91 | + break; | 84 | +++ b/hw/arm/omap_sx1.c |
92 | case A_SECRESPCFG: | 85 | @@ -XXX,XX +XXX,XX @@ static void sx1_init(MachineState *machine, const int version) |
93 | value &= 1; | 86 | |
94 | s->secrespcfg = value; | 87 | fl_idx = 0; |
95 | @@ -XXX,XX +XXX,XX @@ static MemTxResult iotkit_secctl_s_write(void *opaque, hwaddr addr, | 88 | if ((dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) { |
96 | s->secppcinten = value & 0x00f000f3; | 89 | - if (!pflash_cfi01_register(OMAP_CS0_BASE, |
97 | foreach_ppc(s, iotkit_secctl_ppc_update_irq_enable); | 90 | - "omap_sx1.flash0-1", flash_size, |
98 | break; | 91 | - blk_by_legacy_dinfo(dinfo), |
99 | + case A_BRGINTCLR: | 92 | - SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) { |
100 | + break; | 93 | - fprintf(stderr, "qemu: Error registering flash memory %d.\n", |
101 | + case A_BRGINTEN: | 94 | - fl_idx); |
102 | + s->brginten = value & 0xffff0000; | 95 | - } |
103 | + break; | 96 | + pflash_cfi01_register(OMAP_CS0_BASE, |
104 | case A_AHBNSPPCEXP0: | 97 | + "omap_sx1.flash0-1", flash_size, |
105 | case A_AHBNSPPCEXP1: | 98 | + blk_by_legacy_dinfo(dinfo), |
106 | case A_AHBNSPPCEXP2: | 99 | + SECTOR_SIZE, 4, 0, 0, 0, 0, 0); |
107 | @@ -XXX,XX +XXX,XX @@ static MemTxResult iotkit_secctl_s_write(void *opaque, hwaddr addr, | 100 | fl_idx++; |
108 | ppc = &s->apbexp[offset_to_ppc_idx(offset)]; | ||
109 | iotkit_secctl_ppc_sp_write(ppc, value); | ||
110 | break; | ||
111 | - case A_NSCCFG: | ||
112 | case A_SECMSCINTCLR: | ||
113 | case A_SECMSCINTEN: | ||
114 | - case A_BRGINTCLR: | ||
115 | - case A_BRGINTEN: | ||
116 | qemu_log_mask(LOG_UNIMP, | ||
117 | "IoTKit SecCtl S block write: " | ||
118 | "unimplemented offset 0x%x\n", offset); | ||
119 | @@ -XXX,XX +XXX,XX @@ static void iotkit_secctl_reset(DeviceState *dev) | ||
120 | s->secppcintstat = 0; | ||
121 | s->secppcinten = 0; | ||
122 | s->secrespcfg = 0; | ||
123 | + s->nsccfg = 0; | ||
124 | + s->brginten = 0; | ||
125 | |||
126 | foreach_ppc(s, iotkit_secctl_reset_ppc); | ||
127 | } | ||
128 | @@ -XXX,XX +XXX,XX @@ static void iotkit_secctl_init(Object *obj) | ||
129 | } | 101 | } |
130 | 102 | ||
131 | qdev_init_gpio_out_named(dev, &s->sec_resp_cfg, "sec_resp_cfg", 1); | 103 | @@ -XXX,XX +XXX,XX @@ static void sx1_init(MachineState *machine, const int version) |
132 | + qdev_init_gpio_out_named(dev, &s->nsc_cfg_irq, "nsc_cfg", 1); | 104 | memory_region_add_subregion(address_space, |
133 | 105 | OMAP_CS1_BASE + FLASH1_SIZE, &cs[1]); | |
134 | memory_region_init_io(&s->s_regs, obj, &iotkit_secctl_s_ops, | 106 | |
135 | s, "iotkit-secctl-s-regs", 0x1000); | 107 | - if (!pflash_cfi01_register(OMAP_CS1_BASE, |
136 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription iotkit_secctl_vmstate = { | 108 | - "omap_sx1.flash1-1", FLASH1_SIZE, |
137 | VMSTATE_UINT32(secppcintstat, IoTKitSecCtl), | 109 | - blk_by_legacy_dinfo(dinfo), |
138 | VMSTATE_UINT32(secppcinten, IoTKitSecCtl), | 110 | - SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) { |
139 | VMSTATE_UINT32(secrespcfg, IoTKitSecCtl), | 111 | - fprintf(stderr, "qemu: Error registering flash memory %d.\n", |
140 | + VMSTATE_UINT32(nsccfg, IoTKitSecCtl), | 112 | - fl_idx); |
141 | + VMSTATE_UINT32(brginten, IoTKitSecCtl), | 113 | - } |
142 | VMSTATE_STRUCT_ARRAY(apb, IoTKitSecCtl, IOTS_NUM_APB_PPC, 1, | 114 | + pflash_cfi01_register(OMAP_CS1_BASE, |
143 | iotkit_secctl_ppc_vmstate, IoTKitSecCtlPPC), | 115 | + "omap_sx1.flash1-1", FLASH1_SIZE, |
144 | VMSTATE_STRUCT_ARRAY(apbexp, IoTKitSecCtl, IOTS_NUM_APB_EXP_PPC, 1, | 116 | + blk_by_legacy_dinfo(dinfo), |
117 | + SECTOR_SIZE, 4, 0, 0, 0, 0, 0); | ||
118 | fl_idx++; | ||
119 | } else { | ||
120 | memory_region_init_io(&cs[1], NULL, &static_ops, &cs1val, | ||
121 | diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c | ||
122 | index XXXXXXX..XXXXXXX 100644 | ||
123 | --- a/hw/arm/versatilepb.c | ||
124 | +++ b/hw/arm/versatilepb.c | ||
125 | @@ -XXX,XX +XXX,XX @@ static void versatile_init(MachineState *machine, int board_id) | ||
126 | /* 0x34000000 NOR Flash */ | ||
127 | |||
128 | dinfo = drive_get(IF_PFLASH, 0, 0); | ||
129 | - if (!pflash_cfi01_register(VERSATILE_FLASH_ADDR, "versatile.flash", | ||
130 | + pflash_cfi01_register(VERSATILE_FLASH_ADDR, "versatile.flash", | ||
131 | VERSATILE_FLASH_SIZE, | ||
132 | dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, | ||
133 | VERSATILE_FLASH_SECT_SIZE, | ||
134 | - 4, 0x0089, 0x0018, 0x0000, 0x0, 0)) { | ||
135 | - fprintf(stderr, "qemu: Error registering flash memory.\n"); | ||
136 | - } | ||
137 | + 4, 0x0089, 0x0018, 0x0000, 0x0, 0); | ||
138 | |||
139 | versatile_binfo.ram_size = machine->ram_size; | ||
140 | versatile_binfo.board_id = board_id; | ||
141 | diff --git a/hw/arm/z2.c b/hw/arm/z2.c | ||
142 | index XXXXXXX..XXXXXXX 100644 | ||
143 | --- a/hw/arm/z2.c | ||
144 | +++ b/hw/arm/z2.c | ||
145 | @@ -XXX,XX +XXX,XX @@ static void z2_init(MachineState *machine) | ||
146 | mpu = pxa270_init(z2_binfo.ram_size, machine->cpu_type); | ||
147 | |||
148 | dinfo = drive_get(IF_PFLASH, 0, 0); | ||
149 | - if (!pflash_cfi01_register(Z2_FLASH_BASE, "z2.flash0", Z2_FLASH_SIZE, | ||
150 | - dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, | ||
151 | - FLASH_SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) { | ||
152 | - error_report("Error registering flash memory"); | ||
153 | - exit(1); | ||
154 | - } | ||
155 | + pflash_cfi01_register(Z2_FLASH_BASE, "z2.flash0", Z2_FLASH_SIZE, | ||
156 | + dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, | ||
157 | + FLASH_SECTOR_SIZE, 4, 0, 0, 0, 0, 0); | ||
158 | |||
159 | /* setup keypad */ | ||
160 | pxa27x_register_keypad(mpu->kp, map, 0x100); | ||
145 | -- | 161 | -- |
146 | 2.16.2 | 162 | 2.34.1 |
147 | 163 | ||
148 | 164 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Enable it for the "any" CPU used by *-linux-user. | 3 | To avoid forward-declaring PXA2xxI2CState, declare |
4 | PXA2XX_I2C before its use in pxa2xx_i2c_init() prototype. | ||
4 | 5 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20180228193125.20577-10-richard.henderson@linaro.org | 8 | Message-id: 20230109140306.23161-2-philmd@linaro.org |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 10 | --- |
10 | target/arm/cpu.c | 1 + | 11 | include/hw/arm/pxa.h | 6 +++--- |
11 | target/arm/cpu64.c | 1 + | 12 | 1 file changed, 3 insertions(+), 3 deletions(-) |
12 | 2 files changed, 2 insertions(+) | ||
13 | 13 | ||
14 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 14 | diff --git a/include/hw/arm/pxa.h b/include/hw/arm/pxa.h |
15 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/cpu.c | 16 | --- a/include/hw/arm/pxa.h |
17 | +++ b/target/arm/cpu.c | 17 | +++ b/include/hw/arm/pxa.h |
18 | @@ -XXX,XX +XXX,XX @@ static void arm_any_initfn(Object *obj) | 18 | @@ -XXX,XX +XXX,XX @@ void pxa27x_register_keypad(PXA2xxKeyPadState *kp, |
19 | set_feature(&cpu->env, ARM_FEATURE_V8_SHA256); | 19 | const struct keymap *map, int size); |
20 | set_feature(&cpu->env, ARM_FEATURE_V8_PMULL); | 20 | |
21 | set_feature(&cpu->env, ARM_FEATURE_CRC); | 21 | /* pxa2xx.c */ |
22 | + set_feature(&cpu->env, ARM_FEATURE_V8_RDM); | 22 | -typedef struct PXA2xxI2CState PXA2xxI2CState; |
23 | cpu->midr = 0xffffffff; | 23 | +#define TYPE_PXA2XX_I2C "pxa2xx_i2c" |
24 | } | 24 | +OBJECT_DECLARE_SIMPLE_TYPE(PXA2xxI2CState, PXA2XX_I2C) |
25 | #endif | 25 | + |
26 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 26 | PXA2xxI2CState *pxa2xx_i2c_init(hwaddr base, |
27 | index XXXXXXX..XXXXXXX 100644 | 27 | qemu_irq irq, uint32_t page_size); |
28 | --- a/target/arm/cpu64.c | 28 | I2CBus *pxa2xx_i2c_bus(PXA2xxI2CState *s); |
29 | +++ b/target/arm/cpu64.c | 29 | |
30 | @@ -XXX,XX +XXX,XX @@ static void aarch64_any_initfn(Object *obj) | 30 | -#define TYPE_PXA2XX_I2C "pxa2xx_i2c" |
31 | set_feature(&cpu->env, ARM_FEATURE_V8_SM4); | 31 | typedef struct PXA2xxI2SState PXA2xxI2SState; |
32 | set_feature(&cpu->env, ARM_FEATURE_V8_PMULL); | 32 | -OBJECT_DECLARE_SIMPLE_TYPE(PXA2xxI2CState, PXA2XX_I2C) |
33 | set_feature(&cpu->env, ARM_FEATURE_CRC); | 33 | |
34 | + set_feature(&cpu->env, ARM_FEATURE_V8_RDM); | 34 | #define TYPE_PXA2XX_FIR "pxa2xx-fir" |
35 | set_feature(&cpu->env, ARM_FEATURE_V8_FP16); | 35 | OBJECT_DECLARE_SIMPLE_TYPE(PXA2xxFIrState, PXA2XX_FIR) |
36 | cpu->ctr = 0x80038003; /* 32 byte I and D cacheline size, VIPT icache */ | ||
37 | cpu->dcz_blocksize = 7; /* 512 bytes */ | ||
38 | -- | 36 | -- |
39 | 2.16.2 | 37 | 2.34.1 |
40 | 38 | ||
41 | 39 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | Add a local 'struct omap_gpif_s *' variable to improve readability. |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | (This also eases next commit conversion). |
5 | Message-id: 20180228193125.20577-9-richard.henderson@linaro.org | 5 | |
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20230109140306.23161-3-philmd@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 10 | --- |
8 | target/arm/translate.c | 46 ++++++++++++++++++++++++++++++++++++++++++---- | 11 | hw/gpio/omap_gpio.c | 3 ++- |
9 | 1 file changed, 42 insertions(+), 4 deletions(-) | 12 | 1 file changed, 2 insertions(+), 1 deletion(-) |
10 | 13 | ||
11 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 14 | diff --git a/hw/gpio/omap_gpio.c b/hw/gpio/omap_gpio.c |
12 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate.c | 16 | --- a/hw/gpio/omap_gpio.c |
14 | +++ b/target/arm/translate.c | 17 | +++ b/hw/gpio/omap_gpio.c |
15 | @@ -XXX,XX +XXX,XX @@ static const char *regnames[] = | 18 | @@ -XXX,XX +XXX,XX @@ struct omap_gpif_s { |
16 | { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", | 19 | /* General-Purpose I/O of OMAP1 */ |
17 | "r8", "r9", "r10", "r11", "r12", "r13", "r14", "pc" }; | 20 | static void omap_gpio_set(void *opaque, int line, int level) |
18 | |||
19 | +/* Function prototypes for gen_ functions calling Neon helpers. */ | ||
20 | +typedef void NeonGenThreeOpEnvFn(TCGv_i32, TCGv_env, TCGv_i32, | ||
21 | + TCGv_i32, TCGv_i32); | ||
22 | + | ||
23 | /* initialize TCG globals. */ | ||
24 | void arm_translate_init(void) | ||
25 | { | 21 | { |
26 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 22 | - struct omap_gpio_s *s = &((struct omap_gpif_s *) opaque)->omap1; |
27 | } | 23 | + struct omap_gpif_s *p = opaque; |
28 | neon_store_reg64(cpu_V0, rd + pass); | 24 | + struct omap_gpio_s *s = &p->omap1; |
29 | } | 25 | uint16_t prev = s->inputs; |
30 | - | 26 | |
31 | - | 27 | if (level) |
32 | break; | ||
33 | - default: /* 14 and 15 are RESERVED */ | ||
34 | - return 1; | ||
35 | + case 14: /* VQRDMLAH scalar */ | ||
36 | + case 15: /* VQRDMLSH scalar */ | ||
37 | + { | ||
38 | + NeonGenThreeOpEnvFn *fn; | ||
39 | + | ||
40 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_RDM)) { | ||
41 | + return 1; | ||
42 | + } | ||
43 | + if (u && ((rd | rn) & 1)) { | ||
44 | + return 1; | ||
45 | + } | ||
46 | + if (op == 14) { | ||
47 | + if (size == 1) { | ||
48 | + fn = gen_helper_neon_qrdmlah_s16; | ||
49 | + } else { | ||
50 | + fn = gen_helper_neon_qrdmlah_s32; | ||
51 | + } | ||
52 | + } else { | ||
53 | + if (size == 1) { | ||
54 | + fn = gen_helper_neon_qrdmlsh_s16; | ||
55 | + } else { | ||
56 | + fn = gen_helper_neon_qrdmlsh_s32; | ||
57 | + } | ||
58 | + } | ||
59 | + | ||
60 | + tmp2 = neon_get_scalar(size, rm); | ||
61 | + for (pass = 0; pass < (u ? 4 : 2); pass++) { | ||
62 | + tmp = neon_load_reg(rn, pass); | ||
63 | + tmp3 = neon_load_reg(rd, pass); | ||
64 | + fn(tmp, cpu_env, tmp, tmp2, tmp3); | ||
65 | + tcg_temp_free_i32(tmp3); | ||
66 | + neon_store_reg(rd, pass, tmp); | ||
67 | + } | ||
68 | + tcg_temp_free_i32(tmp2); | ||
69 | + } | ||
70 | + break; | ||
71 | + default: | ||
72 | + g_assert_not_reached(); | ||
73 | } | ||
74 | } | ||
75 | } else { /* size == 3 */ | ||
76 | -- | 28 | -- |
77 | 2.16.2 | 29 | 2.34.1 |
78 | 30 | ||
79 | 31 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Not enabled anywhere yet. | 3 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
4 | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | |
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 5 | Message-id: 20230109140306.23161-4-philmd@linaro.org |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20180228193125.20577-2-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 7 | --- |
11 | target/arm/cpu.h | 1 + | 8 | hw/arm/omap1.c | 115 ++++++++++++++++++-------------------- |
12 | linux-user/elfload.c | 1 + | 9 | hw/arm/omap2.c | 40 ++++++------- |
13 | 2 files changed, 2 insertions(+) | 10 | hw/arm/omap_sx1.c | 2 +- |
11 | hw/arm/palm.c | 2 +- | ||
12 | hw/char/omap_uart.c | 7 +-- | ||
13 | hw/display/omap_dss.c | 15 +++-- | ||
14 | hw/display/omap_lcdc.c | 9 ++- | ||
15 | hw/dma/omap_dma.c | 15 +++-- | ||
16 | hw/gpio/omap_gpio.c | 15 +++-- | ||
17 | hw/intc/omap_intc.c | 12 ++-- | ||
18 | hw/misc/omap_gpmc.c | 12 ++-- | ||
19 | hw/misc/omap_l4.c | 7 +-- | ||
20 | hw/misc/omap_sdrc.c | 7 +-- | ||
21 | hw/misc/omap_tap.c | 5 +- | ||
22 | hw/sd/omap_mmc.c | 9 ++- | ||
23 | hw/ssi/omap_spi.c | 7 +-- | ||
24 | hw/timer/omap_gptimer.c | 22 ++++---- | ||
25 | hw/timer/omap_synctimer.c | 4 +- | ||
26 | 18 files changed, 142 insertions(+), 163 deletions(-) | ||
14 | 27 | ||
15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 28 | diff --git a/hw/arm/omap1.c b/hw/arm/omap1.c |
16 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/cpu.h | 30 | --- a/hw/arm/omap1.c |
18 | +++ b/target/arm/cpu.h | 31 | +++ b/hw/arm/omap1.c |
19 | @@ -XXX,XX +XXX,XX @@ enum arm_features { | 32 | @@ -XXX,XX +XXX,XX @@ static void omap_timer_fire(void *opaque) |
20 | ARM_FEATURE_V8_SHA3, /* implements SHA3 part of v8 Crypto Extensions */ | 33 | |
21 | ARM_FEATURE_V8_SM3, /* implements SM3 part of v8 Crypto Extensions */ | 34 | static void omap_timer_tick(void *opaque) |
22 | ARM_FEATURE_V8_SM4, /* implements SM4 part of v8 Crypto Extensions */ | 35 | { |
23 | + ARM_FEATURE_V8_RDM, /* implements v8.1 simd round multiply */ | 36 | - struct omap_mpu_timer_s *timer = (struct omap_mpu_timer_s *) opaque; |
24 | ARM_FEATURE_V8_FP16, /* implements v8.2 half-precision float */ | 37 | + struct omap_mpu_timer_s *timer = opaque; |
38 | |||
39 | omap_timer_sync(timer); | ||
40 | omap_timer_fire(timer); | ||
41 | @@ -XXX,XX +XXX,XX @@ static void omap_timer_tick(void *opaque) | ||
42 | |||
43 | static void omap_timer_clk_update(void *opaque, int line, int on) | ||
44 | { | ||
45 | - struct omap_mpu_timer_s *timer = (struct omap_mpu_timer_s *) opaque; | ||
46 | + struct omap_mpu_timer_s *timer = opaque; | ||
47 | |||
48 | omap_timer_sync(timer); | ||
49 | timer->rate = on ? omap_clk_getrate(timer->clk) : 0; | ||
50 | @@ -XXX,XX +XXX,XX @@ static void omap_timer_clk_setup(struct omap_mpu_timer_s *timer) | ||
51 | static uint64_t omap_mpu_timer_read(void *opaque, hwaddr addr, | ||
52 | unsigned size) | ||
53 | { | ||
54 | - struct omap_mpu_timer_s *s = (struct omap_mpu_timer_s *) opaque; | ||
55 | + struct omap_mpu_timer_s *s = opaque; | ||
56 | |||
57 | if (size != 4) { | ||
58 | return omap_badwidth_read32(opaque, addr); | ||
59 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_mpu_timer_read(void *opaque, hwaddr addr, | ||
60 | static void omap_mpu_timer_write(void *opaque, hwaddr addr, | ||
61 | uint64_t value, unsigned size) | ||
62 | { | ||
63 | - struct omap_mpu_timer_s *s = (struct omap_mpu_timer_s *) opaque; | ||
64 | + struct omap_mpu_timer_s *s = opaque; | ||
65 | |||
66 | if (size != 4) { | ||
67 | omap_badwidth_write32(opaque, addr, value); | ||
68 | @@ -XXX,XX +XXX,XX @@ struct omap_watchdog_timer_s { | ||
69 | static uint64_t omap_wd_timer_read(void *opaque, hwaddr addr, | ||
70 | unsigned size) | ||
71 | { | ||
72 | - struct omap_watchdog_timer_s *s = (struct omap_watchdog_timer_s *) opaque; | ||
73 | + struct omap_watchdog_timer_s *s = opaque; | ||
74 | |||
75 | if (size != 2) { | ||
76 | return omap_badwidth_read16(opaque, addr); | ||
77 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_wd_timer_read(void *opaque, hwaddr addr, | ||
78 | static void omap_wd_timer_write(void *opaque, hwaddr addr, | ||
79 | uint64_t value, unsigned size) | ||
80 | { | ||
81 | - struct omap_watchdog_timer_s *s = (struct omap_watchdog_timer_s *) opaque; | ||
82 | + struct omap_watchdog_timer_s *s = opaque; | ||
83 | |||
84 | if (size != 2) { | ||
85 | omap_badwidth_write16(opaque, addr, value); | ||
86 | @@ -XXX,XX +XXX,XX @@ struct omap_32khz_timer_s { | ||
87 | static uint64_t omap_os_timer_read(void *opaque, hwaddr addr, | ||
88 | unsigned size) | ||
89 | { | ||
90 | - struct omap_32khz_timer_s *s = (struct omap_32khz_timer_s *) opaque; | ||
91 | + struct omap_32khz_timer_s *s = opaque; | ||
92 | int offset = addr & OMAP_MPUI_REG_MASK; | ||
93 | |||
94 | if (size != 4) { | ||
95 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_os_timer_read(void *opaque, hwaddr addr, | ||
96 | static void omap_os_timer_write(void *opaque, hwaddr addr, | ||
97 | uint64_t value, unsigned size) | ||
98 | { | ||
99 | - struct omap_32khz_timer_s *s = (struct omap_32khz_timer_s *) opaque; | ||
100 | + struct omap_32khz_timer_s *s = opaque; | ||
101 | int offset = addr & OMAP_MPUI_REG_MASK; | ||
102 | |||
103 | if (size != 4) { | ||
104 | @@ -XXX,XX +XXX,XX @@ static struct omap_32khz_timer_s *omap_os_timer_init(MemoryRegion *memory, | ||
105 | static uint64_t omap_ulpd_pm_read(void *opaque, hwaddr addr, | ||
106 | unsigned size) | ||
107 | { | ||
108 | - struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; | ||
109 | + struct omap_mpu_state_s *s = opaque; | ||
110 | uint16_t ret; | ||
111 | |||
112 | if (size != 2) { | ||
113 | @@ -XXX,XX +XXX,XX @@ static inline void omap_ulpd_req_update(struct omap_mpu_state_s *s, | ||
114 | static void omap_ulpd_pm_write(void *opaque, hwaddr addr, | ||
115 | uint64_t value, unsigned size) | ||
116 | { | ||
117 | - struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; | ||
118 | + struct omap_mpu_state_s *s = opaque; | ||
119 | int64_t now, ticks; | ||
120 | int div, mult; | ||
121 | static const int bypass_div[4] = { 1, 2, 4, 4 }; | ||
122 | @@ -XXX,XX +XXX,XX @@ static void omap_ulpd_pm_init(MemoryRegion *system_memory, | ||
123 | static uint64_t omap_pin_cfg_read(void *opaque, hwaddr addr, | ||
124 | unsigned size) | ||
125 | { | ||
126 | - struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; | ||
127 | + struct omap_mpu_state_s *s = opaque; | ||
128 | |||
129 | if (size != 4) { | ||
130 | return omap_badwidth_read32(opaque, addr); | ||
131 | @@ -XXX,XX +XXX,XX @@ static inline void omap_pin_modconf1_update(struct omap_mpu_state_s *s, | ||
132 | static void omap_pin_cfg_write(void *opaque, hwaddr addr, | ||
133 | uint64_t value, unsigned size) | ||
134 | { | ||
135 | - struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; | ||
136 | + struct omap_mpu_state_s *s = opaque; | ||
137 | uint32_t diff; | ||
138 | |||
139 | if (size != 4) { | ||
140 | @@ -XXX,XX +XXX,XX @@ static void omap_pin_cfg_init(MemoryRegion *system_memory, | ||
141 | static uint64_t omap_id_read(void *opaque, hwaddr addr, | ||
142 | unsigned size) | ||
143 | { | ||
144 | - struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; | ||
145 | + struct omap_mpu_state_s *s = opaque; | ||
146 | |||
147 | if (size != 4) { | ||
148 | return omap_badwidth_read32(opaque, addr); | ||
149 | @@ -XXX,XX +XXX,XX @@ static void omap_id_init(MemoryRegion *memory, struct omap_mpu_state_s *mpu) | ||
150 | static uint64_t omap_mpui_read(void *opaque, hwaddr addr, | ||
151 | unsigned size) | ||
152 | { | ||
153 | - struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; | ||
154 | + struct omap_mpu_state_s *s = opaque; | ||
155 | |||
156 | if (size != 4) { | ||
157 | return omap_badwidth_read32(opaque, addr); | ||
158 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_mpui_read(void *opaque, hwaddr addr, | ||
159 | static void omap_mpui_write(void *opaque, hwaddr addr, | ||
160 | uint64_t value, unsigned size) | ||
161 | { | ||
162 | - struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; | ||
163 | + struct omap_mpu_state_s *s = opaque; | ||
164 | |||
165 | if (size != 4) { | ||
166 | omap_badwidth_write32(opaque, addr, value); | ||
167 | @@ -XXX,XX +XXX,XX @@ struct omap_tipb_bridge_s { | ||
168 | static uint64_t omap_tipb_bridge_read(void *opaque, hwaddr addr, | ||
169 | unsigned size) | ||
170 | { | ||
171 | - struct omap_tipb_bridge_s *s = (struct omap_tipb_bridge_s *) opaque; | ||
172 | + struct omap_tipb_bridge_s *s = opaque; | ||
173 | |||
174 | if (size < 2) { | ||
175 | return omap_badwidth_read16(opaque, addr); | ||
176 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_tipb_bridge_read(void *opaque, hwaddr addr, | ||
177 | static void omap_tipb_bridge_write(void *opaque, hwaddr addr, | ||
178 | uint64_t value, unsigned size) | ||
179 | { | ||
180 | - struct omap_tipb_bridge_s *s = (struct omap_tipb_bridge_s *) opaque; | ||
181 | + struct omap_tipb_bridge_s *s = opaque; | ||
182 | |||
183 | if (size < 2) { | ||
184 | omap_badwidth_write16(opaque, addr, value); | ||
185 | @@ -XXX,XX +XXX,XX @@ static struct omap_tipb_bridge_s *omap_tipb_bridge_init( | ||
186 | static uint64_t omap_tcmi_read(void *opaque, hwaddr addr, | ||
187 | unsigned size) | ||
188 | { | ||
189 | - struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; | ||
190 | + struct omap_mpu_state_s *s = opaque; | ||
191 | uint32_t ret; | ||
192 | |||
193 | if (size != 4) { | ||
194 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_tcmi_read(void *opaque, hwaddr addr, | ||
195 | static void omap_tcmi_write(void *opaque, hwaddr addr, | ||
196 | uint64_t value, unsigned size) | ||
197 | { | ||
198 | - struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; | ||
199 | + struct omap_mpu_state_s *s = opaque; | ||
200 | |||
201 | if (size != 4) { | ||
202 | omap_badwidth_write32(opaque, addr, value); | ||
203 | @@ -XXX,XX +XXX,XX @@ struct dpll_ctl_s { | ||
204 | static uint64_t omap_dpll_read(void *opaque, hwaddr addr, | ||
205 | unsigned size) | ||
206 | { | ||
207 | - struct dpll_ctl_s *s = (struct dpll_ctl_s *) opaque; | ||
208 | + struct dpll_ctl_s *s = opaque; | ||
209 | |||
210 | if (size != 2) { | ||
211 | return omap_badwidth_read16(opaque, addr); | ||
212 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_dpll_read(void *opaque, hwaddr addr, | ||
213 | static void omap_dpll_write(void *opaque, hwaddr addr, | ||
214 | uint64_t value, unsigned size) | ||
215 | { | ||
216 | - struct dpll_ctl_s *s = (struct dpll_ctl_s *) opaque; | ||
217 | + struct dpll_ctl_s *s = opaque; | ||
218 | uint16_t diff; | ||
219 | static const int bypass_div[4] = { 1, 2, 4, 4 }; | ||
220 | int div, mult; | ||
221 | @@ -XXX,XX +XXX,XX @@ static struct dpll_ctl_s *omap_dpll_init(MemoryRegion *memory, | ||
222 | static uint64_t omap_clkm_read(void *opaque, hwaddr addr, | ||
223 | unsigned size) | ||
224 | { | ||
225 | - struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; | ||
226 | + struct omap_mpu_state_s *s = opaque; | ||
227 | |||
228 | if (size != 2) { | ||
229 | return omap_badwidth_read16(opaque, addr); | ||
230 | @@ -XXX,XX +XXX,XX @@ static inline void omap_clkm_ckout1_update(struct omap_mpu_state_s *s, | ||
231 | static void omap_clkm_write(void *opaque, hwaddr addr, | ||
232 | uint64_t value, unsigned size) | ||
233 | { | ||
234 | - struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; | ||
235 | + struct omap_mpu_state_s *s = opaque; | ||
236 | uint16_t diff; | ||
237 | omap_clk clk; | ||
238 | static const char *clkschemename[8] = { | ||
239 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap_clkm_ops = { | ||
240 | static uint64_t omap_clkdsp_read(void *opaque, hwaddr addr, | ||
241 | unsigned size) | ||
242 | { | ||
243 | - struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; | ||
244 | + struct omap_mpu_state_s *s = opaque; | ||
245 | CPUState *cpu = CPU(s->cpu); | ||
246 | |||
247 | if (size != 2) { | ||
248 | @@ -XXX,XX +XXX,XX @@ static inline void omap_clkdsp_idlect2_update(struct omap_mpu_state_s *s, | ||
249 | static void omap_clkdsp_write(void *opaque, hwaddr addr, | ||
250 | uint64_t value, unsigned size) | ||
251 | { | ||
252 | - struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; | ||
253 | + struct omap_mpu_state_s *s = opaque; | ||
254 | uint16_t diff; | ||
255 | |||
256 | if (size != 2) { | ||
257 | @@ -XXX,XX +XXX,XX @@ struct omap_mpuio_s { | ||
258 | |||
259 | static void omap_mpuio_set(void *opaque, int line, int level) | ||
260 | { | ||
261 | - struct omap_mpuio_s *s = (struct omap_mpuio_s *) opaque; | ||
262 | + struct omap_mpuio_s *s = opaque; | ||
263 | uint16_t prev = s->inputs; | ||
264 | |||
265 | if (level) | ||
266 | @@ -XXX,XX +XXX,XX @@ static void omap_mpuio_kbd_update(struct omap_mpuio_s *s) | ||
267 | static uint64_t omap_mpuio_read(void *opaque, hwaddr addr, | ||
268 | unsigned size) | ||
269 | { | ||
270 | - struct omap_mpuio_s *s = (struct omap_mpuio_s *) opaque; | ||
271 | + struct omap_mpuio_s *s = opaque; | ||
272 | int offset = addr & OMAP_MPUI_REG_MASK; | ||
273 | uint16_t ret; | ||
274 | |||
275 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_mpuio_read(void *opaque, hwaddr addr, | ||
276 | static void omap_mpuio_write(void *opaque, hwaddr addr, | ||
277 | uint64_t value, unsigned size) | ||
278 | { | ||
279 | - struct omap_mpuio_s *s = (struct omap_mpuio_s *) opaque; | ||
280 | + struct omap_mpuio_s *s = opaque; | ||
281 | int offset = addr & OMAP_MPUI_REG_MASK; | ||
282 | uint16_t diff; | ||
283 | int ln; | ||
284 | @@ -XXX,XX +XXX,XX @@ static void omap_mpuio_reset(struct omap_mpuio_s *s) | ||
285 | |||
286 | static void omap_mpuio_onoff(void *opaque, int line, int on) | ||
287 | { | ||
288 | - struct omap_mpuio_s *s = (struct omap_mpuio_s *) opaque; | ||
289 | + struct omap_mpuio_s *s = opaque; | ||
290 | |||
291 | s->clk = on; | ||
292 | if (on) | ||
293 | @@ -XXX,XX +XXX,XX @@ static void omap_uwire_transfer_start(struct omap_uwire_s *s) | ||
294 | } | ||
295 | } | ||
296 | |||
297 | -static uint64_t omap_uwire_read(void *opaque, hwaddr addr, | ||
298 | - unsigned size) | ||
299 | +static uint64_t omap_uwire_read(void *opaque, hwaddr addr, unsigned size) | ||
300 | { | ||
301 | - struct omap_uwire_s *s = (struct omap_uwire_s *) opaque; | ||
302 | + struct omap_uwire_s *s = opaque; | ||
303 | int offset = addr & OMAP_MPUI_REG_MASK; | ||
304 | |||
305 | if (size != 2) { | ||
306 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_uwire_read(void *opaque, hwaddr addr, | ||
307 | static void omap_uwire_write(void *opaque, hwaddr addr, | ||
308 | uint64_t value, unsigned size) | ||
309 | { | ||
310 | - struct omap_uwire_s *s = (struct omap_uwire_s *) opaque; | ||
311 | + struct omap_uwire_s *s = opaque; | ||
312 | int offset = addr & OMAP_MPUI_REG_MASK; | ||
313 | |||
314 | if (size != 2) { | ||
315 | @@ -XXX,XX +XXX,XX @@ static void omap_pwl_update(struct omap_pwl_s *s) | ||
316 | } | ||
317 | } | ||
318 | |||
319 | -static uint64_t omap_pwl_read(void *opaque, hwaddr addr, | ||
320 | - unsigned size) | ||
321 | +static uint64_t omap_pwl_read(void *opaque, hwaddr addr, unsigned size) | ||
322 | { | ||
323 | - struct omap_pwl_s *s = (struct omap_pwl_s *) opaque; | ||
324 | + struct omap_pwl_s *s = opaque; | ||
325 | int offset = addr & OMAP_MPUI_REG_MASK; | ||
326 | |||
327 | if (size != 1) { | ||
328 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_pwl_read(void *opaque, hwaddr addr, | ||
329 | static void omap_pwl_write(void *opaque, hwaddr addr, | ||
330 | uint64_t value, unsigned size) | ||
331 | { | ||
332 | - struct omap_pwl_s *s = (struct omap_pwl_s *) opaque; | ||
333 | + struct omap_pwl_s *s = opaque; | ||
334 | int offset = addr & OMAP_MPUI_REG_MASK; | ||
335 | |||
336 | if (size != 1) { | ||
337 | @@ -XXX,XX +XXX,XX @@ static void omap_pwl_reset(struct omap_pwl_s *s) | ||
338 | |||
339 | static void omap_pwl_clk_update(void *opaque, int line, int on) | ||
340 | { | ||
341 | - struct omap_pwl_s *s = (struct omap_pwl_s *) opaque; | ||
342 | + struct omap_pwl_s *s = opaque; | ||
343 | |||
344 | s->clk = on; | ||
345 | omap_pwl_update(s); | ||
346 | @@ -XXX,XX +XXX,XX @@ struct omap_pwt_s { | ||
347 | omap_clk clk; | ||
25 | }; | 348 | }; |
26 | 349 | ||
27 | diff --git a/linux-user/elfload.c b/linux-user/elfload.c | 350 | -static uint64_t omap_pwt_read(void *opaque, hwaddr addr, |
28 | index XXXXXXX..XXXXXXX 100644 | 351 | - unsigned size) |
29 | --- a/linux-user/elfload.c | 352 | +static uint64_t omap_pwt_read(void *opaque, hwaddr addr, unsigned size) |
30 | +++ b/linux-user/elfload.c | 353 | { |
31 | @@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap(void) | 354 | - struct omap_pwt_s *s = (struct omap_pwt_s *) opaque; |
32 | GET_FEATURE(ARM_FEATURE_V8_SHA512, ARM_HWCAP_A64_SHA512); | 355 | + struct omap_pwt_s *s = opaque; |
33 | GET_FEATURE(ARM_FEATURE_V8_FP16, | 356 | int offset = addr & OMAP_MPUI_REG_MASK; |
34 | ARM_HWCAP_A64_FPHP | ARM_HWCAP_A64_ASIMDHP); | 357 | |
35 | + GET_FEATURE(ARM_FEATURE_V8_RDM, ARM_HWCAP_A64_ASIMDRDM); | 358 | if (size != 1) { |
36 | #undef GET_FEATURE | 359 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_pwt_read(void *opaque, hwaddr addr, |
37 | 360 | static void omap_pwt_write(void *opaque, hwaddr addr, | |
38 | return hwcaps; | 361 | uint64_t value, unsigned size) |
362 | { | ||
363 | - struct omap_pwt_s *s = (struct omap_pwt_s *) opaque; | ||
364 | + struct omap_pwt_s *s = opaque; | ||
365 | int offset = addr & OMAP_MPUI_REG_MASK; | ||
366 | |||
367 | if (size != 1) { | ||
368 | @@ -XXX,XX +XXX,XX @@ static void omap_rtc_alarm_update(struct omap_rtc_s *s) | ||
369 | printf("%s: conversion failed\n", __func__); | ||
370 | } | ||
371 | |||
372 | -static uint64_t omap_rtc_read(void *opaque, hwaddr addr, | ||
373 | - unsigned size) | ||
374 | +static uint64_t omap_rtc_read(void *opaque, hwaddr addr, unsigned size) | ||
375 | { | ||
376 | - struct omap_rtc_s *s = (struct omap_rtc_s *) opaque; | ||
377 | + struct omap_rtc_s *s = opaque; | ||
378 | int offset = addr & OMAP_MPUI_REG_MASK; | ||
379 | uint8_t i; | ||
380 | |||
381 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_rtc_read(void *opaque, hwaddr addr, | ||
382 | static void omap_rtc_write(void *opaque, hwaddr addr, | ||
383 | uint64_t value, unsigned size) | ||
384 | { | ||
385 | - struct omap_rtc_s *s = (struct omap_rtc_s *) opaque; | ||
386 | + struct omap_rtc_s *s = opaque; | ||
387 | int offset = addr & OMAP_MPUI_REG_MASK; | ||
388 | struct tm new_tm; | ||
389 | time_t ti[2]; | ||
390 | @@ -XXX,XX +XXX,XX @@ static void omap_mcbsp_rx_newdata(struct omap_mcbsp_s *s) | ||
391 | |||
392 | static void omap_mcbsp_source_tick(void *opaque) | ||
393 | { | ||
394 | - struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque; | ||
395 | + struct omap_mcbsp_s *s = opaque; | ||
396 | static const int bps[8] = { 0, 1, 1, 2, 2, 2, -255, -255 }; | ||
397 | |||
398 | if (!s->rx_rate) | ||
399 | @@ -XXX,XX +XXX,XX @@ static void omap_mcbsp_tx_newdata(struct omap_mcbsp_s *s) | ||
400 | |||
401 | static void omap_mcbsp_sink_tick(void *opaque) | ||
402 | { | ||
403 | - struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque; | ||
404 | + struct omap_mcbsp_s *s = opaque; | ||
405 | static const int bps[8] = { 0, 1, 1, 2, 2, 2, -255, -255 }; | ||
406 | |||
407 | if (!s->tx_rate) | ||
408 | @@ -XXX,XX +XXX,XX @@ static void omap_mcbsp_req_update(struct omap_mcbsp_s *s) | ||
409 | static uint64_t omap_mcbsp_read(void *opaque, hwaddr addr, | ||
410 | unsigned size) | ||
411 | { | ||
412 | - struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque; | ||
413 | + struct omap_mcbsp_s *s = opaque; | ||
414 | int offset = addr & OMAP_MPUI_REG_MASK; | ||
415 | uint16_t ret; | ||
416 | |||
417 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_mcbsp_read(void *opaque, hwaddr addr, | ||
418 | static void omap_mcbsp_writeh(void *opaque, hwaddr addr, | ||
419 | uint32_t value) | ||
420 | { | ||
421 | - struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque; | ||
422 | + struct omap_mcbsp_s *s = opaque; | ||
423 | int offset = addr & OMAP_MPUI_REG_MASK; | ||
424 | |||
425 | switch (offset) { | ||
426 | @@ -XXX,XX +XXX,XX @@ static void omap_mcbsp_writeh(void *opaque, hwaddr addr, | ||
427 | static void omap_mcbsp_writew(void *opaque, hwaddr addr, | ||
428 | uint32_t value) | ||
429 | { | ||
430 | - struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque; | ||
431 | + struct omap_mcbsp_s *s = opaque; | ||
432 | int offset = addr & OMAP_MPUI_REG_MASK; | ||
433 | |||
434 | if (offset == 0x04) { /* DXR */ | ||
435 | @@ -XXX,XX +XXX,XX @@ static struct omap_mcbsp_s *omap_mcbsp_init(MemoryRegion *system_memory, | ||
436 | |||
437 | static void omap_mcbsp_i2s_swallow(void *opaque, int line, int level) | ||
438 | { | ||
439 | - struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque; | ||
440 | + struct omap_mcbsp_s *s = opaque; | ||
441 | |||
442 | if (s->rx_rate) { | ||
443 | s->rx_req = s->codec->in.len; | ||
444 | @@ -XXX,XX +XXX,XX @@ static void omap_mcbsp_i2s_swallow(void *opaque, int line, int level) | ||
445 | |||
446 | static void omap_mcbsp_i2s_start(void *opaque, int line, int level) | ||
447 | { | ||
448 | - struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque; | ||
449 | + struct omap_mcbsp_s *s = opaque; | ||
450 | |||
451 | if (s->tx_rate) { | ||
452 | s->tx_req = s->codec->out.size; | ||
453 | @@ -XXX,XX +XXX,XX @@ static void omap_lpg_reset(struct omap_lpg_s *s) | ||
454 | omap_lpg_update(s); | ||
455 | } | ||
456 | |||
457 | -static uint64_t omap_lpg_read(void *opaque, hwaddr addr, | ||
458 | - unsigned size) | ||
459 | +static uint64_t omap_lpg_read(void *opaque, hwaddr addr, unsigned size) | ||
460 | { | ||
461 | - struct omap_lpg_s *s = (struct omap_lpg_s *) opaque; | ||
462 | + struct omap_lpg_s *s = opaque; | ||
463 | int offset = addr & OMAP_MPUI_REG_MASK; | ||
464 | |||
465 | if (size != 1) { | ||
466 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_lpg_read(void *opaque, hwaddr addr, | ||
467 | static void omap_lpg_write(void *opaque, hwaddr addr, | ||
468 | uint64_t value, unsigned size) | ||
469 | { | ||
470 | - struct omap_lpg_s *s = (struct omap_lpg_s *) opaque; | ||
471 | + struct omap_lpg_s *s = opaque; | ||
472 | int offset = addr & OMAP_MPUI_REG_MASK; | ||
473 | |||
474 | if (size != 1) { | ||
475 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap_lpg_ops = { | ||
476 | |||
477 | static void omap_lpg_clk_update(void *opaque, int line, int on) | ||
478 | { | ||
479 | - struct omap_lpg_s *s = (struct omap_lpg_s *) opaque; | ||
480 | + struct omap_lpg_s *s = opaque; | ||
481 | |||
482 | s->clk = on; | ||
483 | omap_lpg_update(s); | ||
484 | @@ -XXX,XX +XXX,XX @@ static void omap_setup_mpui_io(MemoryRegion *system_memory, | ||
485 | /* General chip reset */ | ||
486 | static void omap1_mpu_reset(void *opaque) | ||
487 | { | ||
488 | - struct omap_mpu_state_s *mpu = (struct omap_mpu_state_s *) opaque; | ||
489 | + struct omap_mpu_state_s *mpu = opaque; | ||
490 | |||
491 | omap_dma_reset(mpu->dma); | ||
492 | omap_mpu_timer_reset(mpu->timer[0]); | ||
493 | @@ -XXX,XX +XXX,XX @@ static void omap_setup_dsp_mapping(MemoryRegion *system_memory, | ||
494 | |||
495 | void omap_mpu_wakeup(void *opaque, int irq, int req) | ||
496 | { | ||
497 | - struct omap_mpu_state_s *mpu = (struct omap_mpu_state_s *) opaque; | ||
498 | + struct omap_mpu_state_s *mpu = opaque; | ||
499 | CPUState *cpu = CPU(mpu->cpu); | ||
500 | |||
501 | if (cpu->halted) { | ||
502 | diff --git a/hw/arm/omap2.c b/hw/arm/omap2.c | ||
503 | index XXXXXXX..XXXXXXX 100644 | ||
504 | --- a/hw/arm/omap2.c | ||
505 | +++ b/hw/arm/omap2.c | ||
506 | @@ -XXX,XX +XXX,XX @@ static inline void omap_eac_out_empty(struct omap_eac_s *s) | ||
507 | |||
508 | static void omap_eac_in_cb(void *opaque, int avail_b) | ||
509 | { | ||
510 | - struct omap_eac_s *s = (struct omap_eac_s *) opaque; | ||
511 | + struct omap_eac_s *s = opaque; | ||
512 | |||
513 | s->codec.rxavail = avail_b >> 2; | ||
514 | omap_eac_in_refill(s); | ||
515 | @@ -XXX,XX +XXX,XX @@ static void omap_eac_in_cb(void *opaque, int avail_b) | ||
516 | |||
517 | static void omap_eac_out_cb(void *opaque, int free_b) | ||
518 | { | ||
519 | - struct omap_eac_s *s = (struct omap_eac_s *) opaque; | ||
520 | + struct omap_eac_s *s = opaque; | ||
521 | |||
522 | s->codec.txavail = free_b >> 2; | ||
523 | if (s->codec.txlen) | ||
524 | @@ -XXX,XX +XXX,XX @@ static void omap_eac_reset(struct omap_eac_s *s) | ||
525 | omap_eac_interrupt_update(s); | ||
526 | } | ||
527 | |||
528 | -static uint64_t omap_eac_read(void *opaque, hwaddr addr, | ||
529 | - unsigned size) | ||
530 | +static uint64_t omap_eac_read(void *opaque, hwaddr addr, unsigned size) | ||
531 | { | ||
532 | - struct omap_eac_s *s = (struct omap_eac_s *) opaque; | ||
533 | + struct omap_eac_s *s = opaque; | ||
534 | uint32_t ret; | ||
535 | |||
536 | if (size != 2) { | ||
537 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_eac_read(void *opaque, hwaddr addr, | ||
538 | static void omap_eac_write(void *opaque, hwaddr addr, | ||
539 | uint64_t value, unsigned size) | ||
540 | { | ||
541 | - struct omap_eac_s *s = (struct omap_eac_s *) opaque; | ||
542 | + struct omap_eac_s *s = opaque; | ||
543 | |||
544 | if (size != 2) { | ||
545 | omap_badwidth_write16(opaque, addr, value); | ||
546 | @@ -XXX,XX +XXX,XX @@ static void omap_sti_reset(struct omap_sti_s *s) | ||
547 | static uint64_t omap_sti_read(void *opaque, hwaddr addr, | ||
548 | unsigned size) | ||
549 | { | ||
550 | - struct omap_sti_s *s = (struct omap_sti_s *) opaque; | ||
551 | + struct omap_sti_s *s = opaque; | ||
552 | |||
553 | if (size != 4) { | ||
554 | return omap_badwidth_read32(opaque, addr); | ||
555 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_sti_read(void *opaque, hwaddr addr, | ||
556 | static void omap_sti_write(void *opaque, hwaddr addr, | ||
557 | uint64_t value, unsigned size) | ||
558 | { | ||
559 | - struct omap_sti_s *s = (struct omap_sti_s *) opaque; | ||
560 | + struct omap_sti_s *s = opaque; | ||
561 | |||
562 | if (size != 4) { | ||
563 | omap_badwidth_write32(opaque, addr, value); | ||
564 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap_sti_ops = { | ||
565 | .endianness = DEVICE_NATIVE_ENDIAN, | ||
566 | }; | ||
567 | |||
568 | -static uint64_t omap_sti_fifo_read(void *opaque, hwaddr addr, | ||
569 | - unsigned size) | ||
570 | +static uint64_t omap_sti_fifo_read(void *opaque, hwaddr addr, unsigned size) | ||
571 | { | ||
572 | OMAP_BAD_REG(addr); | ||
573 | return 0; | ||
574 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_sti_fifo_read(void *opaque, hwaddr addr, | ||
575 | static void omap_sti_fifo_write(void *opaque, hwaddr addr, | ||
576 | uint64_t value, unsigned size) | ||
577 | { | ||
578 | - struct omap_sti_s *s = (struct omap_sti_s *) opaque; | ||
579 | + struct omap_sti_s *s = opaque; | ||
580 | int ch = addr >> 6; | ||
581 | uint8_t byte = value; | ||
582 | |||
583 | @@ -XXX,XX +XXX,XX @@ static void omap_prcm_int_update(struct omap_prcm_s *s, int dom) | ||
584 | static uint64_t omap_prcm_read(void *opaque, hwaddr addr, | ||
585 | unsigned size) | ||
586 | { | ||
587 | - struct omap_prcm_s *s = (struct omap_prcm_s *) opaque; | ||
588 | + struct omap_prcm_s *s = opaque; | ||
589 | uint32_t ret; | ||
590 | |||
591 | if (size != 4) { | ||
592 | @@ -XXX,XX +XXX,XX @@ static void omap_prcm_dpll_update(struct omap_prcm_s *s) | ||
593 | static void omap_prcm_write(void *opaque, hwaddr addr, | ||
594 | uint64_t value, unsigned size) | ||
595 | { | ||
596 | - struct omap_prcm_s *s = (struct omap_prcm_s *) opaque; | ||
597 | + struct omap_prcm_s *s = opaque; | ||
598 | |||
599 | if (size != 4) { | ||
600 | omap_badwidth_write32(opaque, addr, value); | ||
601 | @@ -XXX,XX +XXX,XX @@ struct omap_sysctl_s { | ||
602 | static uint32_t omap_sysctl_read8(void *opaque, hwaddr addr) | ||
603 | { | ||
604 | |||
605 | - struct omap_sysctl_s *s = (struct omap_sysctl_s *) opaque; | ||
606 | + struct omap_sysctl_s *s = opaque; | ||
607 | int pad_offset, byte_offset; | ||
608 | int value; | ||
609 | |||
610 | @@ -XXX,XX +XXX,XX @@ static uint32_t omap_sysctl_read8(void *opaque, hwaddr addr) | ||
611 | |||
612 | static uint32_t omap_sysctl_read(void *opaque, hwaddr addr) | ||
613 | { | ||
614 | - struct omap_sysctl_s *s = (struct omap_sysctl_s *) opaque; | ||
615 | + struct omap_sysctl_s *s = opaque; | ||
616 | |||
617 | switch (addr) { | ||
618 | case 0x000: /* CONTROL_REVISION */ | ||
619 | @@ -XXX,XX +XXX,XX @@ static uint32_t omap_sysctl_read(void *opaque, hwaddr addr) | ||
620 | return 0; | ||
621 | } | ||
622 | |||
623 | -static void omap_sysctl_write8(void *opaque, hwaddr addr, | ||
624 | - uint32_t value) | ||
625 | +static void omap_sysctl_write8(void *opaque, hwaddr addr, uint32_t value) | ||
626 | { | ||
627 | - struct omap_sysctl_s *s = (struct omap_sysctl_s *) opaque; | ||
628 | + struct omap_sysctl_s *s = opaque; | ||
629 | int pad_offset, byte_offset; | ||
630 | int prev_value; | ||
631 | |||
632 | @@ -XXX,XX +XXX,XX @@ static void omap_sysctl_write8(void *opaque, hwaddr addr, | ||
633 | } | ||
634 | } | ||
635 | |||
636 | -static void omap_sysctl_write(void *opaque, hwaddr addr, | ||
637 | - uint32_t value) | ||
638 | +static void omap_sysctl_write(void *opaque, hwaddr addr, uint32_t value) | ||
639 | { | ||
640 | - struct omap_sysctl_s *s = (struct omap_sysctl_s *) opaque; | ||
641 | + struct omap_sysctl_s *s = opaque; | ||
642 | |||
643 | switch (addr) { | ||
644 | case 0x000: /* CONTROL_REVISION */ | ||
645 | @@ -XXX,XX +XXX,XX @@ static struct omap_sysctl_s *omap_sysctl_init(struct omap_target_agent_s *ta, | ||
646 | /* General chip reset */ | ||
647 | static void omap2_mpu_reset(void *opaque) | ||
648 | { | ||
649 | - struct omap_mpu_state_s *mpu = (struct omap_mpu_state_s *) opaque; | ||
650 | + struct omap_mpu_state_s *mpu = opaque; | ||
651 | |||
652 | omap_dma_reset(mpu->dma); | ||
653 | omap_prcm_reset(mpu->prcm); | ||
654 | diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c | ||
655 | index XXXXXXX..XXXXXXX 100644 | ||
656 | --- a/hw/arm/omap_sx1.c | ||
657 | +++ b/hw/arm/omap_sx1.c | ||
658 | @@ -XXX,XX +XXX,XX @@ | ||
659 | static uint64_t static_read(void *opaque, hwaddr offset, | ||
660 | unsigned size) | ||
661 | { | ||
662 | - uint32_t *val = (uint32_t *) opaque; | ||
663 | + uint32_t *val = opaque; | ||
664 | uint32_t mask = (4 / size) - 1; | ||
665 | |||
666 | return *val >> ((offset & mask) << 3); | ||
667 | diff --git a/hw/arm/palm.c b/hw/arm/palm.c | ||
668 | index XXXXXXX..XXXXXXX 100644 | ||
669 | --- a/hw/arm/palm.c | ||
670 | +++ b/hw/arm/palm.c | ||
671 | @@ -XXX,XX +XXX,XX @@ static struct { | ||
672 | |||
673 | static void palmte_button_event(void *opaque, int keycode) | ||
674 | { | ||
675 | - struct omap_mpu_state_s *cpu = (struct omap_mpu_state_s *) opaque; | ||
676 | + struct omap_mpu_state_s *cpu = opaque; | ||
677 | |||
678 | if (palmte_keymap[keycode & 0x7f].row != -1) | ||
679 | omap_mpuio_key(cpu->mpuio, | ||
680 | diff --git a/hw/char/omap_uart.c b/hw/char/omap_uart.c | ||
681 | index XXXXXXX..XXXXXXX 100644 | ||
682 | --- a/hw/char/omap_uart.c | ||
683 | +++ b/hw/char/omap_uart.c | ||
684 | @@ -XXX,XX +XXX,XX @@ struct omap_uart_s *omap_uart_init(hwaddr base, | ||
685 | return s; | ||
686 | } | ||
687 | |||
688 | -static uint64_t omap_uart_read(void *opaque, hwaddr addr, | ||
689 | - unsigned size) | ||
690 | +static uint64_t omap_uart_read(void *opaque, hwaddr addr, unsigned size) | ||
691 | { | ||
692 | - struct omap_uart_s *s = (struct omap_uart_s *) opaque; | ||
693 | + struct omap_uart_s *s = opaque; | ||
694 | |||
695 | if (size == 4) { | ||
696 | return omap_badwidth_read8(opaque, addr); | ||
697 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_uart_read(void *opaque, hwaddr addr, | ||
698 | static void omap_uart_write(void *opaque, hwaddr addr, | ||
699 | uint64_t value, unsigned size) | ||
700 | { | ||
701 | - struct omap_uart_s *s = (struct omap_uart_s *) opaque; | ||
702 | + struct omap_uart_s *s = opaque; | ||
703 | |||
704 | if (size == 4) { | ||
705 | omap_badwidth_write8(opaque, addr, value); | ||
706 | diff --git a/hw/display/omap_dss.c b/hw/display/omap_dss.c | ||
707 | index XXXXXXX..XXXXXXX 100644 | ||
708 | --- a/hw/display/omap_dss.c | ||
709 | +++ b/hw/display/omap_dss.c | ||
710 | @@ -XXX,XX +XXX,XX @@ void omap_dss_reset(struct omap_dss_s *s) | ||
711 | static uint64_t omap_diss_read(void *opaque, hwaddr addr, | ||
712 | unsigned size) | ||
713 | { | ||
714 | - struct omap_dss_s *s = (struct omap_dss_s *) opaque; | ||
715 | + struct omap_dss_s *s = opaque; | ||
716 | |||
717 | if (size != 4) { | ||
718 | return omap_badwidth_read32(opaque, addr); | ||
719 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_diss_read(void *opaque, hwaddr addr, | ||
720 | static void omap_diss_write(void *opaque, hwaddr addr, | ||
721 | uint64_t value, unsigned size) | ||
722 | { | ||
723 | - struct omap_dss_s *s = (struct omap_dss_s *) opaque; | ||
724 | + struct omap_dss_s *s = opaque; | ||
725 | |||
726 | if (size != 4) { | ||
727 | omap_badwidth_write32(opaque, addr, value); | ||
728 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap_diss_ops = { | ||
729 | static uint64_t omap_disc_read(void *opaque, hwaddr addr, | ||
730 | unsigned size) | ||
731 | { | ||
732 | - struct omap_dss_s *s = (struct omap_dss_s *) opaque; | ||
733 | + struct omap_dss_s *s = opaque; | ||
734 | |||
735 | if (size != 4) { | ||
736 | return omap_badwidth_read32(opaque, addr); | ||
737 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_disc_read(void *opaque, hwaddr addr, | ||
738 | static void omap_disc_write(void *opaque, hwaddr addr, | ||
739 | uint64_t value, unsigned size) | ||
740 | { | ||
741 | - struct omap_dss_s *s = (struct omap_dss_s *) opaque; | ||
742 | + struct omap_dss_s *s = opaque; | ||
743 | |||
744 | if (size != 4) { | ||
745 | omap_badwidth_write32(opaque, addr, value); | ||
746 | @@ -XXX,XX +XXX,XX @@ static void omap_rfbi_transfer_start(struct omap_dss_s *s) | ||
747 | omap_dispc_interrupt_update(s); | ||
748 | } | ||
749 | |||
750 | -static uint64_t omap_rfbi_read(void *opaque, hwaddr addr, | ||
751 | - unsigned size) | ||
752 | +static uint64_t omap_rfbi_read(void *opaque, hwaddr addr, unsigned size) | ||
753 | { | ||
754 | - struct omap_dss_s *s = (struct omap_dss_s *) opaque; | ||
755 | + struct omap_dss_s *s = opaque; | ||
756 | |||
757 | if (size != 4) { | ||
758 | return omap_badwidth_read32(opaque, addr); | ||
759 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_rfbi_read(void *opaque, hwaddr addr, | ||
760 | static void omap_rfbi_write(void *opaque, hwaddr addr, | ||
761 | uint64_t value, unsigned size) | ||
762 | { | ||
763 | - struct omap_dss_s *s = (struct omap_dss_s *) opaque; | ||
764 | + struct omap_dss_s *s = opaque; | ||
765 | |||
766 | if (size != 4) { | ||
767 | omap_badwidth_write32(opaque, addr, value); | ||
768 | diff --git a/hw/display/omap_lcdc.c b/hw/display/omap_lcdc.c | ||
769 | index XXXXXXX..XXXXXXX 100644 | ||
770 | --- a/hw/display/omap_lcdc.c | ||
771 | +++ b/hw/display/omap_lcdc.c | ||
772 | @@ -XXX,XX +XXX,XX @@ static void draw_line16_32(void *opaque, uint8_t *d, const uint8_t *s, | ||
773 | |||
774 | static void omap_update_display(void *opaque) | ||
775 | { | ||
776 | - struct omap_lcd_panel_s *omap_lcd = (struct omap_lcd_panel_s *) opaque; | ||
777 | + struct omap_lcd_panel_s *omap_lcd = opaque; | ||
778 | DisplaySurface *surface; | ||
779 | drawfn draw_line; | ||
780 | int size, height, first, last; | ||
781 | @@ -XXX,XX +XXX,XX @@ static void omap_lcd_update(struct omap_lcd_panel_s *s) { | ||
782 | } | ||
783 | } | ||
784 | |||
785 | -static uint64_t omap_lcdc_read(void *opaque, hwaddr addr, | ||
786 | - unsigned size) | ||
787 | +static uint64_t omap_lcdc_read(void *opaque, hwaddr addr, unsigned size) | ||
788 | { | ||
789 | - struct omap_lcd_panel_s *s = (struct omap_lcd_panel_s *) opaque; | ||
790 | + struct omap_lcd_panel_s *s = opaque; | ||
791 | |||
792 | switch (addr) { | ||
793 | case 0x00: /* LCD_CONTROL */ | ||
794 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_lcdc_read(void *opaque, hwaddr addr, | ||
795 | static void omap_lcdc_write(void *opaque, hwaddr addr, | ||
796 | uint64_t value, unsigned size) | ||
797 | { | ||
798 | - struct omap_lcd_panel_s *s = (struct omap_lcd_panel_s *) opaque; | ||
799 | + struct omap_lcd_panel_s *s = opaque; | ||
800 | |||
801 | switch (addr) { | ||
802 | case 0x00: /* LCD_CONTROL */ | ||
803 | diff --git a/hw/dma/omap_dma.c b/hw/dma/omap_dma.c | ||
804 | index XXXXXXX..XXXXXXX 100644 | ||
805 | --- a/hw/dma/omap_dma.c | ||
806 | +++ b/hw/dma/omap_dma.c | ||
807 | @@ -XXX,XX +XXX,XX @@ static int omap_dma_sys_read(struct omap_dma_s *s, int offset, | ||
808 | return 0; | ||
809 | } | ||
810 | |||
811 | -static uint64_t omap_dma_read(void *opaque, hwaddr addr, | ||
812 | - unsigned size) | ||
813 | +static uint64_t omap_dma_read(void *opaque, hwaddr addr, unsigned size) | ||
814 | { | ||
815 | - struct omap_dma_s *s = (struct omap_dma_s *) opaque; | ||
816 | + struct omap_dma_s *s = opaque; | ||
817 | int reg, ch; | ||
818 | uint16_t ret; | ||
819 | |||
820 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_dma_read(void *opaque, hwaddr addr, | ||
821 | static void omap_dma_write(void *opaque, hwaddr addr, | ||
822 | uint64_t value, unsigned size) | ||
823 | { | ||
824 | - struct omap_dma_s *s = (struct omap_dma_s *) opaque; | ||
825 | + struct omap_dma_s *s = opaque; | ||
826 | int reg, ch; | ||
827 | |||
828 | if (size != 2) { | ||
829 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap_dma_ops = { | ||
830 | |||
831 | static void omap_dma_request(void *opaque, int drq, int req) | ||
832 | { | ||
833 | - struct omap_dma_s *s = (struct omap_dma_s *) opaque; | ||
834 | + struct omap_dma_s *s = opaque; | ||
835 | /* The request pins are level triggered in QEMU. */ | ||
836 | if (req) { | ||
837 | if (~s->dma->drqbmp & (1ULL << drq)) { | ||
838 | @@ -XXX,XX +XXX,XX @@ static void omap_dma_request(void *opaque, int drq, int req) | ||
839 | /* XXX: this won't be needed once soc_dma knows about clocks. */ | ||
840 | static void omap_dma_clk_update(void *opaque, int line, int on) | ||
841 | { | ||
842 | - struct omap_dma_s *s = (struct omap_dma_s *) opaque; | ||
843 | + struct omap_dma_s *s = opaque; | ||
844 | int i; | ||
845 | |||
846 | s->dma->freq = omap_clk_getrate(s->clk); | ||
847 | @@ -XXX,XX +XXX,XX @@ static void omap_dma_interrupts_4_update(struct omap_dma_s *s) | ||
848 | static uint64_t omap_dma4_read(void *opaque, hwaddr addr, | ||
849 | unsigned size) | ||
850 | { | ||
851 | - struct omap_dma_s *s = (struct omap_dma_s *) opaque; | ||
852 | + struct omap_dma_s *s = opaque; | ||
853 | int irqn = 0, chnum; | ||
854 | struct omap_dma_channel_s *ch; | ||
855 | |||
856 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_dma4_read(void *opaque, hwaddr addr, | ||
857 | static void omap_dma4_write(void *opaque, hwaddr addr, | ||
858 | uint64_t value, unsigned size) | ||
859 | { | ||
860 | - struct omap_dma_s *s = (struct omap_dma_s *) opaque; | ||
861 | + struct omap_dma_s *s = opaque; | ||
862 | int chnum, irqn = 0; | ||
863 | struct omap_dma_channel_s *ch; | ||
864 | |||
865 | diff --git a/hw/gpio/omap_gpio.c b/hw/gpio/omap_gpio.c | ||
866 | index XXXXXXX..XXXXXXX 100644 | ||
867 | --- a/hw/gpio/omap_gpio.c | ||
868 | +++ b/hw/gpio/omap_gpio.c | ||
869 | @@ -XXX,XX +XXX,XX @@ static void omap_gpio_set(void *opaque, int line, int level) | ||
870 | static uint64_t omap_gpio_read(void *opaque, hwaddr addr, | ||
871 | unsigned size) | ||
872 | { | ||
873 | - struct omap_gpio_s *s = (struct omap_gpio_s *) opaque; | ||
874 | + struct omap_gpio_s *s = opaque; | ||
875 | int offset = addr & OMAP_MPUI_REG_MASK; | ||
876 | |||
877 | if (size != 2) { | ||
878 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_gpio_read(void *opaque, hwaddr addr, | ||
879 | static void omap_gpio_write(void *opaque, hwaddr addr, | ||
880 | uint64_t value, unsigned size) | ||
881 | { | ||
882 | - struct omap_gpio_s *s = (struct omap_gpio_s *) opaque; | ||
883 | + struct omap_gpio_s *s = opaque; | ||
884 | int offset = addr & OMAP_MPUI_REG_MASK; | ||
885 | uint16_t diff; | ||
886 | int ln; | ||
887 | @@ -XXX,XX +XXX,XX @@ static void omap2_gpio_module_reset(struct omap2_gpio_s *s) | ||
888 | |||
889 | static uint32_t omap2_gpio_module_read(void *opaque, hwaddr addr) | ||
890 | { | ||
891 | - struct omap2_gpio_s *s = (struct omap2_gpio_s *) opaque; | ||
892 | + struct omap2_gpio_s *s = opaque; | ||
893 | |||
894 | switch (addr) { | ||
895 | case 0x00: /* GPIO_REVISION */ | ||
896 | @@ -XXX,XX +XXX,XX @@ static uint32_t omap2_gpio_module_read(void *opaque, hwaddr addr) | ||
897 | static void omap2_gpio_module_write(void *opaque, hwaddr addr, | ||
898 | uint32_t value) | ||
899 | { | ||
900 | - struct omap2_gpio_s *s = (struct omap2_gpio_s *) opaque; | ||
901 | + struct omap2_gpio_s *s = opaque; | ||
902 | uint32_t diff; | ||
903 | int ln; | ||
904 | |||
905 | @@ -XXX,XX +XXX,XX @@ static void omap2_gpif_reset(DeviceState *dev) | ||
906 | s->gpo = 0; | ||
907 | } | ||
908 | |||
909 | -static uint64_t omap2_gpif_top_read(void *opaque, hwaddr addr, | ||
910 | - unsigned size) | ||
911 | +static uint64_t omap2_gpif_top_read(void *opaque, hwaddr addr, unsigned size) | ||
912 | { | ||
913 | - struct omap2_gpif_s *s = (struct omap2_gpif_s *) opaque; | ||
914 | + struct omap2_gpif_s *s = opaque; | ||
915 | |||
916 | switch (addr) { | ||
917 | case 0x00: /* IPGENERICOCPSPL_REVISION */ | ||
918 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap2_gpif_top_read(void *opaque, hwaddr addr, | ||
919 | static void omap2_gpif_top_write(void *opaque, hwaddr addr, | ||
920 | uint64_t value, unsigned size) | ||
921 | { | ||
922 | - struct omap2_gpif_s *s = (struct omap2_gpif_s *) opaque; | ||
923 | + struct omap2_gpif_s *s = opaque; | ||
924 | |||
925 | switch (addr) { | ||
926 | case 0x00: /* IPGENERICOCPSPL_REVISION */ | ||
927 | diff --git a/hw/intc/omap_intc.c b/hw/intc/omap_intc.c | ||
928 | index XXXXXXX..XXXXXXX 100644 | ||
929 | --- a/hw/intc/omap_intc.c | ||
930 | +++ b/hw/intc/omap_intc.c | ||
931 | @@ -XXX,XX +XXX,XX @@ static inline void omap_inth_update(struct omap_intr_handler_s *s, int is_fiq) | ||
932 | |||
933 | static void omap_set_intr(void *opaque, int irq, int req) | ||
934 | { | ||
935 | - struct omap_intr_handler_s *ih = (struct omap_intr_handler_s *) opaque; | ||
936 | + struct omap_intr_handler_s *ih = opaque; | ||
937 | uint32_t rise; | ||
938 | |||
939 | struct omap_intr_handler_bank_s *bank = &ih->bank[irq >> 5]; | ||
940 | @@ -XXX,XX +XXX,XX @@ static void omap_set_intr(void *opaque, int irq, int req) | ||
941 | /* Simplified version with no edge detection */ | ||
942 | static void omap_set_intr_noedge(void *opaque, int irq, int req) | ||
943 | { | ||
944 | - struct omap_intr_handler_s *ih = (struct omap_intr_handler_s *) opaque; | ||
945 | + struct omap_intr_handler_s *ih = opaque; | ||
946 | uint32_t rise; | ||
947 | |||
948 | struct omap_intr_handler_bank_s *bank = &ih->bank[irq >> 5]; | ||
949 | @@ -XXX,XX +XXX,XX @@ static void omap_set_intr_noedge(void *opaque, int irq, int req) | ||
950 | static uint64_t omap_inth_read(void *opaque, hwaddr addr, | ||
951 | unsigned size) | ||
952 | { | ||
953 | - struct omap_intr_handler_s *s = (struct omap_intr_handler_s *) opaque; | ||
954 | + struct omap_intr_handler_s *s = opaque; | ||
955 | int i, offset = addr; | ||
956 | int bank_no = offset >> 8; | ||
957 | int line_no; | ||
958 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_inth_read(void *opaque, hwaddr addr, | ||
959 | static void omap_inth_write(void *opaque, hwaddr addr, | ||
960 | uint64_t value, unsigned size) | ||
961 | { | ||
962 | - struct omap_intr_handler_s *s = (struct omap_intr_handler_s *) opaque; | ||
963 | + struct omap_intr_handler_s *s = opaque; | ||
964 | int i, offset = addr; | ||
965 | int bank_no = offset >> 8; | ||
966 | struct omap_intr_handler_bank_s *bank = &s->bank[bank_no]; | ||
967 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo omap_intc_info = { | ||
968 | static uint64_t omap2_inth_read(void *opaque, hwaddr addr, | ||
969 | unsigned size) | ||
970 | { | ||
971 | - struct omap_intr_handler_s *s = (struct omap_intr_handler_s *) opaque; | ||
972 | + struct omap_intr_handler_s *s = opaque; | ||
973 | int offset = addr; | ||
974 | int bank_no, line_no; | ||
975 | struct omap_intr_handler_bank_s *bank = NULL; | ||
976 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap2_inth_read(void *opaque, hwaddr addr, | ||
977 | static void omap2_inth_write(void *opaque, hwaddr addr, | ||
978 | uint64_t value, unsigned size) | ||
979 | { | ||
980 | - struct omap_intr_handler_s *s = (struct omap_intr_handler_s *) opaque; | ||
981 | + struct omap_intr_handler_s *s = opaque; | ||
982 | int offset = addr; | ||
983 | int bank_no, line_no; | ||
984 | struct omap_intr_handler_bank_s *bank = NULL; | ||
985 | diff --git a/hw/misc/omap_gpmc.c b/hw/misc/omap_gpmc.c | ||
986 | index XXXXXXX..XXXXXXX 100644 | ||
987 | --- a/hw/misc/omap_gpmc.c | ||
988 | +++ b/hw/misc/omap_gpmc.c | ||
989 | @@ -XXX,XX +XXX,XX @@ static void omap_gpmc_dma_update(struct omap_gpmc_s *s, int value) | ||
990 | static uint64_t omap_nand_read(void *opaque, hwaddr addr, | ||
991 | unsigned size) | ||
992 | { | ||
993 | - struct omap_gpmc_cs_file_s *f = (struct omap_gpmc_cs_file_s *)opaque; | ||
994 | + struct omap_gpmc_cs_file_s *f = opaque; | ||
995 | uint64_t v; | ||
996 | nand_setpins(f->dev, 0, 0, 0, 1, 0); | ||
997 | switch (omap_gpmc_devsize(f)) { | ||
998 | @@ -XXX,XX +XXX,XX @@ static void omap_nand_setio(DeviceState *dev, uint64_t value, | ||
999 | static void omap_nand_write(void *opaque, hwaddr addr, | ||
1000 | uint64_t value, unsigned size) | ||
1001 | { | ||
1002 | - struct omap_gpmc_cs_file_s *f = (struct omap_gpmc_cs_file_s *)opaque; | ||
1003 | + struct omap_gpmc_cs_file_s *f = opaque; | ||
1004 | nand_setpins(f->dev, 0, 0, 0, 1, 0); | ||
1005 | omap_nand_setio(f->dev, value, omap_gpmc_devsize(f), size); | ||
1006 | } | ||
1007 | @@ -XXX,XX +XXX,XX @@ static void fill_prefetch_fifo(struct omap_gpmc_s *s) | ||
1008 | static uint64_t omap_gpmc_prefetch_read(void *opaque, hwaddr addr, | ||
1009 | unsigned size) | ||
1010 | { | ||
1011 | - struct omap_gpmc_s *s = (struct omap_gpmc_s *) opaque; | ||
1012 | + struct omap_gpmc_s *s = opaque; | ||
1013 | uint32_t data; | ||
1014 | if (s->prefetch.config1 & 1) { | ||
1015 | /* The TRM doesn't define the behaviour if you read from the | ||
1016 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_gpmc_prefetch_read(void *opaque, hwaddr addr, | ||
1017 | static void omap_gpmc_prefetch_write(void *opaque, hwaddr addr, | ||
1018 | uint64_t value, unsigned size) | ||
1019 | { | ||
1020 | - struct omap_gpmc_s *s = (struct omap_gpmc_s *) opaque; | ||
1021 | + struct omap_gpmc_s *s = opaque; | ||
1022 | int cs = prefetch_cs(s->prefetch.config1); | ||
1023 | if ((s->prefetch.config1 & 1) == 0) { | ||
1024 | /* The TRM doesn't define the behaviour of writing to the | ||
1025 | @@ -XXX,XX +XXX,XX @@ static int gpmc_wordaccess_only(hwaddr addr) | ||
1026 | static uint64_t omap_gpmc_read(void *opaque, hwaddr addr, | ||
1027 | unsigned size) | ||
1028 | { | ||
1029 | - struct omap_gpmc_s *s = (struct omap_gpmc_s *) opaque; | ||
1030 | + struct omap_gpmc_s *s = opaque; | ||
1031 | int cs; | ||
1032 | struct omap_gpmc_cs_file_s *f; | ||
1033 | |||
1034 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_gpmc_read(void *opaque, hwaddr addr, | ||
1035 | static void omap_gpmc_write(void *opaque, hwaddr addr, | ||
1036 | uint64_t value, unsigned size) | ||
1037 | { | ||
1038 | - struct omap_gpmc_s *s = (struct omap_gpmc_s *) opaque; | ||
1039 | + struct omap_gpmc_s *s = opaque; | ||
1040 | int cs; | ||
1041 | struct omap_gpmc_cs_file_s *f; | ||
1042 | |||
1043 | diff --git a/hw/misc/omap_l4.c b/hw/misc/omap_l4.c | ||
1044 | index XXXXXXX..XXXXXXX 100644 | ||
1045 | --- a/hw/misc/omap_l4.c | ||
1046 | +++ b/hw/misc/omap_l4.c | ||
1047 | @@ -XXX,XX +XXX,XX @@ hwaddr omap_l4_region_size(struct omap_target_agent_s *ta, | ||
1048 | return ta->start[region].size; | ||
1049 | } | ||
1050 | |||
1051 | -static uint64_t omap_l4ta_read(void *opaque, hwaddr addr, | ||
1052 | - unsigned size) | ||
1053 | +static uint64_t omap_l4ta_read(void *opaque, hwaddr addr, unsigned size) | ||
1054 | { | ||
1055 | - struct omap_target_agent_s *s = (struct omap_target_agent_s *) opaque; | ||
1056 | + struct omap_target_agent_s *s = opaque; | ||
1057 | |||
1058 | if (size != 2) { | ||
1059 | return omap_badwidth_read16(opaque, addr); | ||
1060 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_l4ta_read(void *opaque, hwaddr addr, | ||
1061 | static void omap_l4ta_write(void *opaque, hwaddr addr, | ||
1062 | uint64_t value, unsigned size) | ||
1063 | { | ||
1064 | - struct omap_target_agent_s *s = (struct omap_target_agent_s *) opaque; | ||
1065 | + struct omap_target_agent_s *s = opaque; | ||
1066 | |||
1067 | if (size != 4) { | ||
1068 | omap_badwidth_write32(opaque, addr, value); | ||
1069 | diff --git a/hw/misc/omap_sdrc.c b/hw/misc/omap_sdrc.c | ||
1070 | index XXXXXXX..XXXXXXX 100644 | ||
1071 | --- a/hw/misc/omap_sdrc.c | ||
1072 | +++ b/hw/misc/omap_sdrc.c | ||
1073 | @@ -XXX,XX +XXX,XX @@ void omap_sdrc_reset(struct omap_sdrc_s *s) | ||
1074 | s->config = 0x10; | ||
1075 | } | ||
1076 | |||
1077 | -static uint64_t omap_sdrc_read(void *opaque, hwaddr addr, | ||
1078 | - unsigned size) | ||
1079 | +static uint64_t omap_sdrc_read(void *opaque, hwaddr addr, unsigned size) | ||
1080 | { | ||
1081 | - struct omap_sdrc_s *s = (struct omap_sdrc_s *) opaque; | ||
1082 | + struct omap_sdrc_s *s = opaque; | ||
1083 | |||
1084 | if (size != 4) { | ||
1085 | return omap_badwidth_read32(opaque, addr); | ||
1086 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_sdrc_read(void *opaque, hwaddr addr, | ||
1087 | static void omap_sdrc_write(void *opaque, hwaddr addr, | ||
1088 | uint64_t value, unsigned size) | ||
1089 | { | ||
1090 | - struct omap_sdrc_s *s = (struct omap_sdrc_s *) opaque; | ||
1091 | + struct omap_sdrc_s *s = opaque; | ||
1092 | |||
1093 | if (size != 4) { | ||
1094 | omap_badwidth_write32(opaque, addr, value); | ||
1095 | diff --git a/hw/misc/omap_tap.c b/hw/misc/omap_tap.c | ||
1096 | index XXXXXXX..XXXXXXX 100644 | ||
1097 | --- a/hw/misc/omap_tap.c | ||
1098 | +++ b/hw/misc/omap_tap.c | ||
1099 | @@ -XXX,XX +XXX,XX @@ | ||
1100 | #include "hw/arm/omap.h" | ||
1101 | |||
1102 | /* TEST-Chip-level TAP */ | ||
1103 | -static uint64_t omap_tap_read(void *opaque, hwaddr addr, | ||
1104 | - unsigned size) | ||
1105 | +static uint64_t omap_tap_read(void *opaque, hwaddr addr, unsigned size) | ||
1106 | { | ||
1107 | - struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque; | ||
1108 | + struct omap_mpu_state_s *s = opaque; | ||
1109 | |||
1110 | if (size != 4) { | ||
1111 | return omap_badwidth_read32(opaque, addr); | ||
1112 | diff --git a/hw/sd/omap_mmc.c b/hw/sd/omap_mmc.c | ||
1113 | index XXXXXXX..XXXXXXX 100644 | ||
1114 | --- a/hw/sd/omap_mmc.c | ||
1115 | +++ b/hw/sd/omap_mmc.c | ||
1116 | @@ -XXX,XX +XXX,XX @@ void omap_mmc_reset(struct omap_mmc_s *host) | ||
1117 | device_cold_reset(DEVICE(host->card)); | ||
1118 | } | ||
1119 | |||
1120 | -static uint64_t omap_mmc_read(void *opaque, hwaddr offset, | ||
1121 | - unsigned size) | ||
1122 | +static uint64_t omap_mmc_read(void *opaque, hwaddr offset, unsigned size) | ||
1123 | { | ||
1124 | uint16_t i; | ||
1125 | - struct omap_mmc_s *s = (struct omap_mmc_s *) opaque; | ||
1126 | + struct omap_mmc_s *s = opaque; | ||
1127 | |||
1128 | if (size != 2) { | ||
1129 | return omap_badwidth_read16(opaque, offset); | ||
1130 | @@ -XXX,XX +XXX,XX @@ static void omap_mmc_write(void *opaque, hwaddr offset, | ||
1131 | uint64_t value, unsigned size) | ||
1132 | { | ||
1133 | int i; | ||
1134 | - struct omap_mmc_s *s = (struct omap_mmc_s *) opaque; | ||
1135 | + struct omap_mmc_s *s = opaque; | ||
1136 | |||
1137 | if (size != 2) { | ||
1138 | omap_badwidth_write16(opaque, offset, value); | ||
1139 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap_mmc_ops = { | ||
1140 | |||
1141 | static void omap_mmc_cover_cb(void *opaque, int line, int level) | ||
1142 | { | ||
1143 | - struct omap_mmc_s *host = (struct omap_mmc_s *) opaque; | ||
1144 | + struct omap_mmc_s *host = opaque; | ||
1145 | |||
1146 | if (!host->cdet_state && level) { | ||
1147 | host->status |= 0x0002; | ||
1148 | diff --git a/hw/ssi/omap_spi.c b/hw/ssi/omap_spi.c | ||
1149 | index XXXXXXX..XXXXXXX 100644 | ||
1150 | --- a/hw/ssi/omap_spi.c | ||
1151 | +++ b/hw/ssi/omap_spi.c | ||
1152 | @@ -XXX,XX +XXX,XX @@ void omap_mcspi_reset(struct omap_mcspi_s *s) | ||
1153 | omap_mcspi_interrupt_update(s); | ||
1154 | } | ||
1155 | |||
1156 | -static uint64_t omap_mcspi_read(void *opaque, hwaddr addr, | ||
1157 | - unsigned size) | ||
1158 | +static uint64_t omap_mcspi_read(void *opaque, hwaddr addr, unsigned size) | ||
1159 | { | ||
1160 | - struct omap_mcspi_s *s = (struct omap_mcspi_s *) opaque; | ||
1161 | + struct omap_mcspi_s *s = opaque; | ||
1162 | int ch = 0; | ||
1163 | uint32_t ret; | ||
1164 | |||
1165 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_mcspi_read(void *opaque, hwaddr addr, | ||
1166 | static void omap_mcspi_write(void *opaque, hwaddr addr, | ||
1167 | uint64_t value, unsigned size) | ||
1168 | { | ||
1169 | - struct omap_mcspi_s *s = (struct omap_mcspi_s *) opaque; | ||
1170 | + struct omap_mcspi_s *s = opaque; | ||
1171 | int ch = 0; | ||
1172 | |||
1173 | if (size != 4) { | ||
1174 | diff --git a/hw/timer/omap_gptimer.c b/hw/timer/omap_gptimer.c | ||
1175 | index XXXXXXX..XXXXXXX 100644 | ||
1176 | --- a/hw/timer/omap_gptimer.c | ||
1177 | +++ b/hw/timer/omap_gptimer.c | ||
1178 | @@ -XXX,XX +XXX,XX @@ static inline void omap_gp_timer_trigger(struct omap_gp_timer_s *timer) | ||
1179 | |||
1180 | static void omap_gp_timer_tick(void *opaque) | ||
1181 | { | ||
1182 | - struct omap_gp_timer_s *timer = (struct omap_gp_timer_s *) opaque; | ||
1183 | + struct omap_gp_timer_s *timer = opaque; | ||
1184 | |||
1185 | if (!timer->ar) { | ||
1186 | timer->st = 0; | ||
1187 | @@ -XXX,XX +XXX,XX @@ static void omap_gp_timer_tick(void *opaque) | ||
1188 | |||
1189 | static void omap_gp_timer_match(void *opaque) | ||
1190 | { | ||
1191 | - struct omap_gp_timer_s *timer = (struct omap_gp_timer_s *) opaque; | ||
1192 | + struct omap_gp_timer_s *timer = opaque; | ||
1193 | |||
1194 | if (timer->trigger == gpt_trigger_both) | ||
1195 | omap_gp_timer_trigger(timer); | ||
1196 | @@ -XXX,XX +XXX,XX @@ static void omap_gp_timer_match(void *opaque) | ||
1197 | |||
1198 | static void omap_gp_timer_input(void *opaque, int line, int on) | ||
1199 | { | ||
1200 | - struct omap_gp_timer_s *s = (struct omap_gp_timer_s *) opaque; | ||
1201 | + struct omap_gp_timer_s *s = opaque; | ||
1202 | int trigger; | ||
1203 | |||
1204 | switch (s->capture) { | ||
1205 | @@ -XXX,XX +XXX,XX @@ static void omap_gp_timer_input(void *opaque, int line, int on) | ||
1206 | |||
1207 | static void omap_gp_timer_clk_update(void *opaque, int line, int on) | ||
1208 | { | ||
1209 | - struct omap_gp_timer_s *timer = (struct omap_gp_timer_s *) opaque; | ||
1210 | + struct omap_gp_timer_s *timer = opaque; | ||
1211 | |||
1212 | omap_gp_timer_sync(timer); | ||
1213 | timer->rate = on ? omap_clk_getrate(timer->clk) : 0; | ||
1214 | @@ -XXX,XX +XXX,XX @@ void omap_gp_timer_reset(struct omap_gp_timer_s *s) | ||
1215 | |||
1216 | static uint32_t omap_gp_timer_readw(void *opaque, hwaddr addr) | ||
1217 | { | ||
1218 | - struct omap_gp_timer_s *s = (struct omap_gp_timer_s *) opaque; | ||
1219 | + struct omap_gp_timer_s *s = opaque; | ||
1220 | |||
1221 | switch (addr) { | ||
1222 | case 0x00: /* TIDR */ | ||
1223 | @@ -XXX,XX +XXX,XX @@ static uint32_t omap_gp_timer_readw(void *opaque, hwaddr addr) | ||
1224 | |||
1225 | static uint32_t omap_gp_timer_readh(void *opaque, hwaddr addr) | ||
1226 | { | ||
1227 | - struct omap_gp_timer_s *s = (struct omap_gp_timer_s *) opaque; | ||
1228 | + struct omap_gp_timer_s *s = opaque; | ||
1229 | uint32_t ret; | ||
1230 | |||
1231 | if (addr & 2) | ||
1232 | @@ -XXX,XX +XXX,XX @@ static uint32_t omap_gp_timer_readh(void *opaque, hwaddr addr) | ||
1233 | } | ||
1234 | } | ||
1235 | |||
1236 | -static void omap_gp_timer_write(void *opaque, hwaddr addr, | ||
1237 | - uint32_t value) | ||
1238 | +static void omap_gp_timer_write(void *opaque, hwaddr addr, uint32_t value) | ||
1239 | { | ||
1240 | - struct omap_gp_timer_s *s = (struct omap_gp_timer_s *) opaque; | ||
1241 | + struct omap_gp_timer_s *s = opaque; | ||
1242 | |||
1243 | switch (addr) { | ||
1244 | case 0x00: /* TIDR */ | ||
1245 | @@ -XXX,XX +XXX,XX @@ static void omap_gp_timer_write(void *opaque, hwaddr addr, | ||
1246 | } | ||
1247 | } | ||
1248 | |||
1249 | -static void omap_gp_timer_writeh(void *opaque, hwaddr addr, | ||
1250 | - uint32_t value) | ||
1251 | +static void omap_gp_timer_writeh(void *opaque, hwaddr addr, uint32_t value) | ||
1252 | { | ||
1253 | - struct omap_gp_timer_s *s = (struct omap_gp_timer_s *) opaque; | ||
1254 | + struct omap_gp_timer_s *s = opaque; | ||
1255 | |||
1256 | if (addr & 2) | ||
1257 | omap_gp_timer_write(opaque, addr, (value << 16) | s->writeh); | ||
1258 | diff --git a/hw/timer/omap_synctimer.c b/hw/timer/omap_synctimer.c | ||
1259 | index XXXXXXX..XXXXXXX 100644 | ||
1260 | --- a/hw/timer/omap_synctimer.c | ||
1261 | +++ b/hw/timer/omap_synctimer.c | ||
1262 | @@ -XXX,XX +XXX,XX @@ void omap_synctimer_reset(struct omap_synctimer_s *s) | ||
1263 | |||
1264 | static uint32_t omap_synctimer_readw(void *opaque, hwaddr addr) | ||
1265 | { | ||
1266 | - struct omap_synctimer_s *s = (struct omap_synctimer_s *) opaque; | ||
1267 | + struct omap_synctimer_s *s = opaque; | ||
1268 | |||
1269 | switch (addr) { | ||
1270 | case 0x00: /* 32KSYNCNT_REV */ | ||
1271 | @@ -XXX,XX +XXX,XX @@ static uint32_t omap_synctimer_readw(void *opaque, hwaddr addr) | ||
1272 | |||
1273 | static uint32_t omap_synctimer_readh(void *opaque, hwaddr addr) | ||
1274 | { | ||
1275 | - struct omap_synctimer_s *s = (struct omap_synctimer_s *) opaque; | ||
1276 | + struct omap_synctimer_s *s = opaque; | ||
1277 | uint32_t ret; | ||
1278 | |||
1279 | if (addr & 2) | ||
39 | -- | 1280 | -- |
40 | 2.16.2 | 1281 | 2.34.1 |
41 | 1282 | ||
42 | 1283 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Following docs/devel/style.rst guidelines, rename omap_gpif_s -> |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | Omap1GpioState. This also remove a use of 'struct' in the |
5 | Message-id: 20180228193125.20577-6-richard.henderson@linaro.org | 5 | DECLARE_INSTANCE_CHECKER() macro call. |
6 | |||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20230109140306.23161-5-philmd@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 11 | --- |
8 | target/arm/helper.h | 9 +++++ | 12 | include/hw/arm/omap.h | 6 +++--- |
9 | target/arm/translate-a64.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++ | 13 | hw/gpio/omap_gpio.c | 16 ++++++++-------- |
10 | target/arm/vec_helper.c | 74 +++++++++++++++++++++++++++++++++++++++++ | 14 | 2 files changed, 11 insertions(+), 11 deletions(-) |
11 | 3 files changed, 166 insertions(+) | ||
12 | 15 | ||
13 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 16 | diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h |
14 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/helper.h | 18 | --- a/include/hw/arm/omap.h |
16 | +++ b/target/arm/helper.h | 19 | +++ b/include/hw/arm/omap.h |
17 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(dc_zva, void, env, i64) | 20 | @@ -XXX,XX +XXX,XX @@ void omap_i2c_set_fclk(OMAPI2CState *i2c, omap_clk clk); |
18 | DEF_HELPER_FLAGS_2(neon_pmull_64_lo, TCG_CALL_NO_RWG_SE, i64, i64, i64) | 21 | |
19 | DEF_HELPER_FLAGS_2(neon_pmull_64_hi, TCG_CALL_NO_RWG_SE, i64, i64, i64) | 22 | /* omap_gpio.c */ |
20 | 23 | #define TYPE_OMAP1_GPIO "omap-gpio" | |
21 | +DEF_HELPER_FLAGS_5(gvec_qrdmlah_s16, TCG_CALL_NO_RWG, | 24 | -DECLARE_INSTANCE_CHECKER(struct omap_gpif_s, OMAP1_GPIO, |
22 | + void, ptr, ptr, ptr, ptr, i32) | 25 | +typedef struct Omap1GpioState Omap1GpioState; |
23 | +DEF_HELPER_FLAGS_5(gvec_qrdmlsh_s16, TCG_CALL_NO_RWG, | 26 | +DECLARE_INSTANCE_CHECKER(Omap1GpioState, OMAP1_GPIO, |
24 | + void, ptr, ptr, ptr, ptr, i32) | 27 | TYPE_OMAP1_GPIO) |
25 | +DEF_HELPER_FLAGS_5(gvec_qrdmlah_s32, TCG_CALL_NO_RWG, | 28 | |
26 | + void, ptr, ptr, ptr, ptr, i32) | 29 | #define TYPE_OMAP2_GPIO "omap2-gpio" |
27 | +DEF_HELPER_FLAGS_5(gvec_qrdmlsh_s32, TCG_CALL_NO_RWG, | 30 | DECLARE_INSTANCE_CHECKER(struct omap2_gpif_s, OMAP2_GPIO, |
28 | + void, ptr, ptr, ptr, ptr, i32) | 31 | TYPE_OMAP2_GPIO) |
29 | + | 32 | |
30 | #ifdef TARGET_AARCH64 | 33 | -typedef struct omap_gpif_s omap_gpif; |
31 | #include "helper-a64.h" | 34 | typedef struct omap2_gpif_s omap2_gpif; |
32 | #endif | 35 | |
33 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 36 | /* TODO: clock framework (see above) */ |
37 | -void omap_gpio_set_clk(omap_gpif *gpio, omap_clk clk); | ||
38 | +void omap_gpio_set_clk(Omap1GpioState *gpio, omap_clk clk); | ||
39 | |||
40 | void omap2_gpio_set_iclk(omap2_gpif *gpio, omap_clk clk); | ||
41 | void omap2_gpio_set_fclk(omap2_gpif *gpio, uint8_t i, omap_clk clk); | ||
42 | diff --git a/hw/gpio/omap_gpio.c b/hw/gpio/omap_gpio.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | 43 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/target/arm/translate-a64.c | 44 | --- a/hw/gpio/omap_gpio.c |
36 | +++ b/target/arm/translate-a64.c | 45 | +++ b/hw/gpio/omap_gpio.c |
37 | @@ -XXX,XX +XXX,XX @@ static void gen_gvec_op3(DisasContext *s, bool is_q, int rd, | 46 | @@ -XXX,XX +XXX,XX @@ struct omap_gpio_s { |
38 | vec_full_reg_size(s), gvec_op); | 47 | uint16_t pins; |
48 | }; | ||
49 | |||
50 | -struct omap_gpif_s { | ||
51 | +struct Omap1GpioState { | ||
52 | SysBusDevice parent_obj; | ||
53 | |||
54 | MemoryRegion iomem; | ||
55 | @@ -XXX,XX +XXX,XX @@ struct omap_gpif_s { | ||
56 | /* General-Purpose I/O of OMAP1 */ | ||
57 | static void omap_gpio_set(void *opaque, int line, int level) | ||
58 | { | ||
59 | - struct omap_gpif_s *p = opaque; | ||
60 | + Omap1GpioState *p = opaque; | ||
61 | struct omap_gpio_s *s = &p->omap1; | ||
62 | uint16_t prev = s->inputs; | ||
63 | |||
64 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap2_gpio_module_ops = { | ||
65 | |||
66 | static void omap_gpif_reset(DeviceState *dev) | ||
67 | { | ||
68 | - struct omap_gpif_s *s = OMAP1_GPIO(dev); | ||
69 | + Omap1GpioState *s = OMAP1_GPIO(dev); | ||
70 | |||
71 | omap_gpio_reset(&s->omap1); | ||
39 | } | 72 | } |
40 | 73 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap2_gpif_top_ops = { | |
41 | +/* Expand a 3-operand + env pointer operation using | 74 | static void omap_gpio_init(Object *obj) |
42 | + * an out-of-line helper. | 75 | { |
43 | + */ | 76 | DeviceState *dev = DEVICE(obj); |
44 | +static void gen_gvec_op3_env(DisasContext *s, bool is_q, int rd, | 77 | - struct omap_gpif_s *s = OMAP1_GPIO(obj); |
45 | + int rn, int rm, gen_helper_gvec_3_ptr *fn) | 78 | + Omap1GpioState *s = OMAP1_GPIO(obj); |
46 | +{ | 79 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); |
47 | + tcg_gen_gvec_3_ptr(vec_full_reg_offset(s, rd), | 80 | |
48 | + vec_full_reg_offset(s, rn), | 81 | qdev_init_gpio_in(dev, omap_gpio_set, 16); |
49 | + vec_full_reg_offset(s, rm), cpu_env, | 82 | @@ -XXX,XX +XXX,XX @@ static void omap_gpio_init(Object *obj) |
50 | + is_q ? 16 : 8, vec_full_reg_size(s), 0, fn); | 83 | |
51 | +} | 84 | static void omap_gpio_realize(DeviceState *dev, Error **errp) |
52 | + | 85 | { |
53 | /* Set ZF and NF based on a 64 bit result. This is alas fiddlier | 86 | - struct omap_gpif_s *s = OMAP1_GPIO(dev); |
54 | * than the 32 bit equivalent. | 87 | + Omap1GpioState *s = OMAP1_GPIO(dev); |
55 | */ | 88 | |
56 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn) | 89 | if (!s->clk) { |
57 | clear_vec_high(s, is_q, rd); | 90 | error_setg(errp, "omap-gpio: clk not connected"); |
91 | @@ -XXX,XX +XXX,XX @@ static void omap2_gpio_realize(DeviceState *dev, Error **errp) | ||
92 | } | ||
58 | } | 93 | } |
59 | 94 | ||
60 | +/* AdvSIMD three same extra | 95 | -void omap_gpio_set_clk(omap_gpif *gpio, omap_clk clk) |
61 | + * 31 30 29 28 24 23 22 21 20 16 15 14 11 10 9 5 4 0 | 96 | +void omap_gpio_set_clk(Omap1GpioState *gpio, omap_clk clk) |
62 | + * +---+---+---+-----------+------+---+------+---+--------+---+----+----+ | ||
63 | + * | 0 | Q | U | 0 1 1 1 0 | size | 0 | Rm | 1 | opcode | 1 | Rn | Rd | | ||
64 | + * +---+---+---+-----------+------+---+------+---+--------+---+----+----+ | ||
65 | + */ | ||
66 | +static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) | ||
67 | +{ | ||
68 | + int rd = extract32(insn, 0, 5); | ||
69 | + int rn = extract32(insn, 5, 5); | ||
70 | + int opcode = extract32(insn, 11, 4); | ||
71 | + int rm = extract32(insn, 16, 5); | ||
72 | + int size = extract32(insn, 22, 2); | ||
73 | + bool u = extract32(insn, 29, 1); | ||
74 | + bool is_q = extract32(insn, 30, 1); | ||
75 | + int feature; | ||
76 | + | ||
77 | + switch (u * 16 + opcode) { | ||
78 | + case 0x10: /* SQRDMLAH (vector) */ | ||
79 | + case 0x11: /* SQRDMLSH (vector) */ | ||
80 | + if (size != 1 && size != 2) { | ||
81 | + unallocated_encoding(s); | ||
82 | + return; | ||
83 | + } | ||
84 | + feature = ARM_FEATURE_V8_RDM; | ||
85 | + break; | ||
86 | + default: | ||
87 | + unallocated_encoding(s); | ||
88 | + return; | ||
89 | + } | ||
90 | + if (!arm_dc_feature(s, feature)) { | ||
91 | + unallocated_encoding(s); | ||
92 | + return; | ||
93 | + } | ||
94 | + if (!fp_access_check(s)) { | ||
95 | + return; | ||
96 | + } | ||
97 | + | ||
98 | + switch (opcode) { | ||
99 | + case 0x0: /* SQRDMLAH (vector) */ | ||
100 | + switch (size) { | ||
101 | + case 1: | ||
102 | + gen_gvec_op3_env(s, is_q, rd, rn, rm, gen_helper_gvec_qrdmlah_s16); | ||
103 | + break; | ||
104 | + case 2: | ||
105 | + gen_gvec_op3_env(s, is_q, rd, rn, rm, gen_helper_gvec_qrdmlah_s32); | ||
106 | + break; | ||
107 | + default: | ||
108 | + g_assert_not_reached(); | ||
109 | + } | ||
110 | + return; | ||
111 | + | ||
112 | + case 0x1: /* SQRDMLSH (vector) */ | ||
113 | + switch (size) { | ||
114 | + case 1: | ||
115 | + gen_gvec_op3_env(s, is_q, rd, rn, rm, gen_helper_gvec_qrdmlsh_s16); | ||
116 | + break; | ||
117 | + case 2: | ||
118 | + gen_gvec_op3_env(s, is_q, rd, rn, rm, gen_helper_gvec_qrdmlsh_s32); | ||
119 | + break; | ||
120 | + default: | ||
121 | + g_assert_not_reached(); | ||
122 | + } | ||
123 | + return; | ||
124 | + | ||
125 | + default: | ||
126 | + g_assert_not_reached(); | ||
127 | + } | ||
128 | +} | ||
129 | + | ||
130 | static void handle_2misc_widening(DisasContext *s, int opcode, bool is_q, | ||
131 | int size, int rn, int rd) | ||
132 | { | 97 | { |
133 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_imm2(DisasContext *s, uint32_t insn) | 98 | gpio->clk = clk; |
134 | static const AArch64DecodeTable data_proc_simd[] = { | ||
135 | /* pattern , mask , fn */ | ||
136 | { 0x0e200400, 0x9f200400, disas_simd_three_reg_same }, | ||
137 | + { 0x0e008400, 0x9f208400, disas_simd_three_reg_same_extra }, | ||
138 | { 0x0e200000, 0x9f200c00, disas_simd_three_reg_diff }, | ||
139 | { 0x0e200800, 0x9f3e0c00, disas_simd_two_reg_misc }, | ||
140 | { 0x0e300800, 0x9f3e0c00, disas_simd_across_lanes }, | ||
141 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | ||
142 | index XXXXXXX..XXXXXXX 100644 | ||
143 | --- a/target/arm/vec_helper.c | ||
144 | +++ b/target/arm/vec_helper.c | ||
145 | @@ -XXX,XX +XXX,XX @@ | ||
146 | |||
147 | #define SET_QC() env->vfp.xregs[ARM_VFP_FPSCR] |= CPSR_Q | ||
148 | |||
149 | +static void clear_tail(void *vd, uintptr_t opr_sz, uintptr_t max_sz) | ||
150 | +{ | ||
151 | + uint64_t *d = vd + opr_sz; | ||
152 | + uintptr_t i; | ||
153 | + | ||
154 | + for (i = opr_sz; i < max_sz; i += 8) { | ||
155 | + *d++ = 0; | ||
156 | + } | ||
157 | +} | ||
158 | + | ||
159 | /* Signed saturating rounding doubling multiply-accumulate high half, 16-bit */ | ||
160 | static uint16_t inl_qrdmlah_s16(CPUARMState *env, int16_t src1, | ||
161 | int16_t src2, int16_t src3) | ||
162 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(neon_qrdmlah_s16)(CPUARMState *env, uint32_t src1, | ||
163 | return deposit32(e1, 16, 16, e2); | ||
164 | } | 99 | } |
165 | 100 | ||
166 | +void HELPER(gvec_qrdmlah_s16)(void *vd, void *vn, void *vm, | 101 | static Property omap_gpio_properties[] = { |
167 | + void *ve, uint32_t desc) | 102 | - DEFINE_PROP_INT32("mpu_model", struct omap_gpif_s, mpu_model, 0), |
168 | +{ | 103 | + DEFINE_PROP_INT32("mpu_model", Omap1GpioState, mpu_model, 0), |
169 | + uintptr_t opr_sz = simd_oprsz(desc); | 104 | DEFINE_PROP_END_OF_LIST(), |
170 | + int16_t *d = vd; | 105 | }; |
171 | + int16_t *n = vn; | 106 | |
172 | + int16_t *m = vm; | 107 | @@ -XXX,XX +XXX,XX @@ static void omap_gpio_class_init(ObjectClass *klass, void *data) |
173 | + CPUARMState *env = ve; | 108 | static const TypeInfo omap_gpio_info = { |
174 | + uintptr_t i; | 109 | .name = TYPE_OMAP1_GPIO, |
175 | + | 110 | .parent = TYPE_SYS_BUS_DEVICE, |
176 | + for (i = 0; i < opr_sz / 2; ++i) { | 111 | - .instance_size = sizeof(struct omap_gpif_s), |
177 | + d[i] = inl_qrdmlah_s16(env, n[i], m[i], d[i]); | 112 | + .instance_size = sizeof(Omap1GpioState), |
178 | + } | 113 | .instance_init = omap_gpio_init, |
179 | + clear_tail(d, opr_sz, simd_maxsz(desc)); | 114 | .class_init = omap_gpio_class_init, |
180 | +} | 115 | }; |
181 | + | ||
182 | /* Signed saturating rounding doubling multiply-subtract high half, 16-bit */ | ||
183 | static uint16_t inl_qrdmlsh_s16(CPUARMState *env, int16_t src1, | ||
184 | int16_t src2, int16_t src3) | ||
185 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(neon_qrdmlsh_s16)(CPUARMState *env, uint32_t src1, | ||
186 | return deposit32(e1, 16, 16, e2); | ||
187 | } | ||
188 | |||
189 | +void HELPER(gvec_qrdmlsh_s16)(void *vd, void *vn, void *vm, | ||
190 | + void *ve, uint32_t desc) | ||
191 | +{ | ||
192 | + uintptr_t opr_sz = simd_oprsz(desc); | ||
193 | + int16_t *d = vd; | ||
194 | + int16_t *n = vn; | ||
195 | + int16_t *m = vm; | ||
196 | + CPUARMState *env = ve; | ||
197 | + uintptr_t i; | ||
198 | + | ||
199 | + for (i = 0; i < opr_sz / 2; ++i) { | ||
200 | + d[i] = inl_qrdmlsh_s16(env, n[i], m[i], d[i]); | ||
201 | + } | ||
202 | + clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
203 | +} | ||
204 | + | ||
205 | /* Signed saturating rounding doubling multiply-accumulate high half, 32-bit */ | ||
206 | uint32_t HELPER(neon_qrdmlah_s32)(CPUARMState *env, int32_t src1, | ||
207 | int32_t src2, int32_t src3) | ||
208 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(neon_qrdmlah_s32)(CPUARMState *env, int32_t src1, | ||
209 | return ret; | ||
210 | } | ||
211 | |||
212 | +void HELPER(gvec_qrdmlah_s32)(void *vd, void *vn, void *vm, | ||
213 | + void *ve, uint32_t desc) | ||
214 | +{ | ||
215 | + uintptr_t opr_sz = simd_oprsz(desc); | ||
216 | + int32_t *d = vd; | ||
217 | + int32_t *n = vn; | ||
218 | + int32_t *m = vm; | ||
219 | + CPUARMState *env = ve; | ||
220 | + uintptr_t i; | ||
221 | + | ||
222 | + for (i = 0; i < opr_sz / 4; ++i) { | ||
223 | + d[i] = helper_neon_qrdmlah_s32(env, n[i], m[i], d[i]); | ||
224 | + } | ||
225 | + clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
226 | +} | ||
227 | + | ||
228 | /* Signed saturating rounding doubling multiply-subtract high half, 32-bit */ | ||
229 | uint32_t HELPER(neon_qrdmlsh_s32)(CPUARMState *env, int32_t src1, | ||
230 | int32_t src2, int32_t src3) | ||
231 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(neon_qrdmlsh_s32)(CPUARMState *env, int32_t src1, | ||
232 | } | ||
233 | return ret; | ||
234 | } | ||
235 | + | ||
236 | +void HELPER(gvec_qrdmlsh_s32)(void *vd, void *vn, void *vm, | ||
237 | + void *ve, uint32_t desc) | ||
238 | +{ | ||
239 | + uintptr_t opr_sz = simd_oprsz(desc); | ||
240 | + int32_t *d = vd; | ||
241 | + int32_t *n = vn; | ||
242 | + int32_t *m = vm; | ||
243 | + CPUARMState *env = ve; | ||
244 | + uintptr_t i; | ||
245 | + | ||
246 | + for (i = 0; i < opr_sz / 4; ++i) { | ||
247 | + d[i] = helper_neon_qrdmlsh_s32(env, n[i], m[i], d[i]); | ||
248 | + } | ||
249 | + clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
250 | +} | ||
251 | -- | 116 | -- |
252 | 2.16.2 | 117 | 2.34.1 |
253 | 118 | ||
254 | 119 | diff view generated by jsdifflib |
1 | Add a function load_ramdisk_as() which behaves like the existing | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | load_ramdisk() but allows the caller to specify the AddressSpace | ||
3 | to use. This matches the pattern we have already for various | ||
4 | other loader functions. | ||
5 | 2 | ||
3 | Following docs/devel/style.rst guidelines, rename omap2_gpif_s -> | ||
4 | Omap2GpioState. This also remove a use of 'struct' in the | ||
5 | DECLARE_INSTANCE_CHECKER() macro call. | ||
6 | |||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20230109140306.23161-6-philmd@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20180220180325.29818-2-peter.maydell@linaro.org | ||
10 | --- | 11 | --- |
11 | include/hw/loader.h | 12 +++++++++++- | 12 | include/hw/arm/omap.h | 9 ++++----- |
12 | hw/core/loader.c | 8 +++++++- | 13 | hw/gpio/omap_gpio.c | 20 ++++++++++---------- |
13 | 2 files changed, 18 insertions(+), 2 deletions(-) | 14 | 2 files changed, 14 insertions(+), 15 deletions(-) |
14 | 15 | ||
15 | diff --git a/include/hw/loader.h b/include/hw/loader.h | 16 | diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h |
16 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/include/hw/loader.h | 18 | --- a/include/hw/arm/omap.h |
18 | +++ b/include/hw/loader.h | 19 | +++ b/include/hw/arm/omap.h |
19 | @@ -XXX,XX +XXX,XX @@ int load_uimage(const char *filename, hwaddr *ep, | 20 | @@ -XXX,XX +XXX,XX @@ DECLARE_INSTANCE_CHECKER(Omap1GpioState, OMAP1_GPIO, |
20 | void *translate_opaque); | 21 | TYPE_OMAP1_GPIO) |
21 | 22 | ||
22 | /** | 23 | #define TYPE_OMAP2_GPIO "omap2-gpio" |
23 | - * load_ramdisk: | 24 | -DECLARE_INSTANCE_CHECKER(struct omap2_gpif_s, OMAP2_GPIO, |
24 | + * load_ramdisk_as: | 25 | +typedef struct Omap2GpioState Omap2GpioState; |
25 | * @filename: Path to the ramdisk image | 26 | +DECLARE_INSTANCE_CHECKER(Omap2GpioState, OMAP2_GPIO, |
26 | * @addr: Memory address to load the ramdisk to | 27 | TYPE_OMAP2_GPIO) |
27 | * @max_sz: Maximum allowed ramdisk size (for non-u-boot ramdisks) | 28 | |
28 | + * @as: The AddressSpace to load the ELF to. The value of address_space_memory | 29 | -typedef struct omap2_gpif_s omap2_gpif; |
29 | + * is used if nothing is supplied here. | 30 | - |
30 | * | 31 | /* TODO: clock framework (see above) */ |
31 | * Load a ramdisk image with U-Boot header to the specified memory | 32 | void omap_gpio_set_clk(Omap1GpioState *gpio, omap_clk clk); |
32 | * address. | 33 | |
33 | * | 34 | -void omap2_gpio_set_iclk(omap2_gpif *gpio, omap_clk clk); |
34 | * Returns the size of the loaded image on success, -1 otherwise. | 35 | -void omap2_gpio_set_fclk(omap2_gpif *gpio, uint8_t i, omap_clk clk); |
35 | */ | 36 | +void omap2_gpio_set_iclk(Omap2GpioState *gpio, omap_clk clk); |
36 | +int load_ramdisk_as(const char *filename, hwaddr addr, uint64_t max_sz, | 37 | +void omap2_gpio_set_fclk(Omap2GpioState *gpio, uint8_t i, omap_clk clk); |
37 | + AddressSpace *as); | 38 | |
38 | + | 39 | /* OMAP2 l4 Interconnect */ |
39 | +/** | 40 | struct omap_l4_s; |
40 | + * load_ramdisk: | 41 | diff --git a/hw/gpio/omap_gpio.c b/hw/gpio/omap_gpio.c |
41 | + * Same as load_ramdisk_as(), but doesn't allow the caller to specify | ||
42 | + * an AddressSpace. | ||
43 | + */ | ||
44 | int load_ramdisk(const char *filename, hwaddr addr, uint64_t max_sz); | ||
45 | |||
46 | ssize_t gunzip(void *dst, size_t dstlen, uint8_t *src, size_t srclen); | ||
47 | diff --git a/hw/core/loader.c b/hw/core/loader.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | 42 | index XXXXXXX..XXXXXXX 100644 |
49 | --- a/hw/core/loader.c | 43 | --- a/hw/gpio/omap_gpio.c |
50 | +++ b/hw/core/loader.c | 44 | +++ b/hw/gpio/omap_gpio.c |
51 | @@ -XXX,XX +XXX,XX @@ int load_uimage_as(const char *filename, hwaddr *ep, hwaddr *loadaddr, | 45 | @@ -XXX,XX +XXX,XX @@ struct omap2_gpio_s { |
52 | 46 | uint8_t delay; | |
53 | /* Load a ramdisk. */ | 47 | }; |
54 | int load_ramdisk(const char *filename, hwaddr addr, uint64_t max_sz) | 48 | |
55 | +{ | 49 | -struct omap2_gpif_s { |
56 | + return load_ramdisk_as(filename, addr, max_sz, NULL); | 50 | +struct Omap2GpioState { |
57 | +} | 51 | SysBusDevice parent_obj; |
58 | + | 52 | |
59 | +int load_ramdisk_as(const char *filename, hwaddr addr, uint64_t max_sz, | 53 | MemoryRegion iomem; |
60 | + AddressSpace *as) | 54 | @@ -XXX,XX +XXX,XX @@ static inline void omap2_gpio_module_int(struct omap2_gpio_s *s, int line) |
55 | |||
56 | static void omap2_gpio_set(void *opaque, int line, int level) | ||
61 | { | 57 | { |
62 | return load_uboot_image(filename, NULL, &addr, NULL, IH_TYPE_RAMDISK, | 58 | - struct omap2_gpif_s *p = opaque; |
63 | - NULL, NULL, NULL); | 59 | + Omap2GpioState *p = opaque; |
64 | + NULL, NULL, as); | 60 | struct omap2_gpio_s *s = &p->modules[line >> 5]; |
61 | |||
62 | line &= 31; | ||
63 | @@ -XXX,XX +XXX,XX @@ static void omap_gpif_reset(DeviceState *dev) | ||
64 | |||
65 | static void omap2_gpif_reset(DeviceState *dev) | ||
66 | { | ||
67 | - struct omap2_gpif_s *s = OMAP2_GPIO(dev); | ||
68 | + Omap2GpioState *s = OMAP2_GPIO(dev); | ||
69 | int i; | ||
70 | |||
71 | for (i = 0; i < s->modulecount; i++) { | ||
72 | @@ -XXX,XX +XXX,XX @@ static void omap2_gpif_reset(DeviceState *dev) | ||
73 | |||
74 | static uint64_t omap2_gpif_top_read(void *opaque, hwaddr addr, unsigned size) | ||
75 | { | ||
76 | - struct omap2_gpif_s *s = opaque; | ||
77 | + Omap2GpioState *s = opaque; | ||
78 | |||
79 | switch (addr) { | ||
80 | case 0x00: /* IPGENERICOCPSPL_REVISION */ | ||
81 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap2_gpif_top_read(void *opaque, hwaddr addr, unsigned size) | ||
82 | static void omap2_gpif_top_write(void *opaque, hwaddr addr, | ||
83 | uint64_t value, unsigned size) | ||
84 | { | ||
85 | - struct omap2_gpif_s *s = opaque; | ||
86 | + Omap2GpioState *s = opaque; | ||
87 | |||
88 | switch (addr) { | ||
89 | case 0x00: /* IPGENERICOCPSPL_REVISION */ | ||
90 | @@ -XXX,XX +XXX,XX @@ static void omap_gpio_realize(DeviceState *dev, Error **errp) | ||
91 | |||
92 | static void omap2_gpio_realize(DeviceState *dev, Error **errp) | ||
93 | { | ||
94 | - struct omap2_gpif_s *s = OMAP2_GPIO(dev); | ||
95 | + Omap2GpioState *s = OMAP2_GPIO(dev); | ||
96 | SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
97 | int i; | ||
98 | |||
99 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo omap_gpio_info = { | ||
100 | .class_init = omap_gpio_class_init, | ||
101 | }; | ||
102 | |||
103 | -void omap2_gpio_set_iclk(omap2_gpif *gpio, omap_clk clk) | ||
104 | +void omap2_gpio_set_iclk(Omap2GpioState *gpio, omap_clk clk) | ||
105 | { | ||
106 | gpio->iclk = clk; | ||
65 | } | 107 | } |
66 | 108 | ||
67 | /* Load a gzip-compressed kernel to a dynamically allocated buffer. */ | 109 | -void omap2_gpio_set_fclk(omap2_gpif *gpio, uint8_t i, omap_clk clk) |
110 | +void omap2_gpio_set_fclk(Omap2GpioState *gpio, uint8_t i, omap_clk clk) | ||
111 | { | ||
112 | assert(i <= 5); | ||
113 | gpio->fclk[i] = clk; | ||
114 | } | ||
115 | |||
116 | static Property omap2_gpio_properties[] = { | ||
117 | - DEFINE_PROP_INT32("mpu_model", struct omap2_gpif_s, mpu_model, 0), | ||
118 | + DEFINE_PROP_INT32("mpu_model", Omap2GpioState, mpu_model, 0), | ||
119 | DEFINE_PROP_END_OF_LIST(), | ||
120 | }; | ||
121 | |||
122 | @@ -XXX,XX +XXX,XX @@ static void omap2_gpio_class_init(ObjectClass *klass, void *data) | ||
123 | static const TypeInfo omap2_gpio_info = { | ||
124 | .name = TYPE_OMAP2_GPIO, | ||
125 | .parent = TYPE_SYS_BUS_DEVICE, | ||
126 | - .instance_size = sizeof(struct omap2_gpif_s), | ||
127 | + .instance_size = sizeof(Omap2GpioState), | ||
128 | .class_init = omap2_gpio_class_init, | ||
129 | }; | ||
130 | |||
68 | -- | 131 | -- |
69 | 2.16.2 | 132 | 2.34.1 |
70 | 133 | ||
71 | 134 | diff view generated by jsdifflib |
1 | The function qdev_init_gpio_in_named() passes the DeviceState pointer | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | as the opaque data pointor for the irq handler function. Usually | 2 | |
3 | this is what you want, but in some cases it would be helpful to use | 3 | Following docs/devel/style.rst guidelines, rename |
4 | some other data pointer. | 4 | omap_intr_handler_s -> OMAPIntcState. This also remove a |
5 | 5 | use of 'struct' in the DECLARE_INSTANCE_CHECKER() macro call. | |
6 | Add a new function qdev_init_gpio_in_named_with_opaque() which allows | 6 | |
7 | the caller to specify the data pointer they want. | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | |
9 | Message-id: 20230109140306.23161-7-philmd@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20180220180325.29818-12-peter.maydell@linaro.org | ||
13 | --- | 11 | --- |
14 | include/hw/qdev-core.h | 30 ++++++++++++++++++++++++++++-- | 12 | include/hw/arm/omap.h | 9 ++++----- |
15 | hw/core/qdev.c | 8 +++++--- | 13 | hw/intc/omap_intc.c | 38 +++++++++++++++++++------------------- |
16 | 2 files changed, 33 insertions(+), 5 deletions(-) | 14 | 2 files changed, 23 insertions(+), 24 deletions(-) |
17 | 15 | ||
18 | diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h | 16 | diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h |
19 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/include/hw/qdev-core.h | 18 | --- a/include/hw/arm/omap.h |
21 | +++ b/include/hw/qdev-core.h | 19 | +++ b/include/hw/arm/omap.h |
22 | @@ -XXX,XX +XXX,XX @@ BusState *qdev_get_child_bus(DeviceState *dev, const char *name); | 20 | @@ -XXX,XX +XXX,XX @@ void omap_clk_reparent(omap_clk clk, omap_clk parent); |
23 | /* GPIO inputs also double as IRQ sinks. */ | 21 | |
24 | void qdev_init_gpio_in(DeviceState *dev, qemu_irq_handler handler, int n); | 22 | /* omap_intc.c */ |
25 | void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n); | 23 | #define TYPE_OMAP_INTC "common-omap-intc" |
26 | -void qdev_init_gpio_in_named(DeviceState *dev, qemu_irq_handler handler, | 24 | -typedef struct omap_intr_handler_s omap_intr_handler; |
27 | - const char *name, int n); | 25 | -DECLARE_INSTANCE_CHECKER(omap_intr_handler, OMAP_INTC, |
28 | void qdev_init_gpio_out_named(DeviceState *dev, qemu_irq *pins, | 26 | - TYPE_OMAP_INTC) |
29 | const char *name, int n); | 27 | +typedef struct OMAPIntcState OMAPIntcState; |
30 | +/** | 28 | +DECLARE_INSTANCE_CHECKER(OMAPIntcState, OMAP_INTC, TYPE_OMAP_INTC) |
31 | + * qdev_init_gpio_in_named_with_opaque: create an array of input GPIO lines | 29 | |
32 | + * for the specified device | 30 | |
33 | + * | 31 | /* |
34 | + * @dev: Device to create input GPIOs for | 32 | @@ -XXX,XX +XXX,XX @@ DECLARE_INSTANCE_CHECKER(omap_intr_handler, OMAP_INTC, |
35 | + * @handler: Function to call when GPIO line value is set | 33 | * (ie the struct omap_mpu_state_s*) to do the clockname to pointer |
36 | + * @opaque: Opaque data pointer to pass to @handler | 34 | * translation.) |
37 | + * @name: Name of the GPIO input (must be unique for this device) | 35 | */ |
38 | + * @n: Number of GPIO lines in this input set | 36 | -void omap_intc_set_iclk(omap_intr_handler *intc, omap_clk clk); |
39 | + */ | 37 | -void omap_intc_set_fclk(omap_intr_handler *intc, omap_clk clk); |
40 | +void qdev_init_gpio_in_named_with_opaque(DeviceState *dev, | 38 | +void omap_intc_set_iclk(OMAPIntcState *intc, omap_clk clk); |
41 | + qemu_irq_handler handler, | 39 | +void omap_intc_set_fclk(OMAPIntcState *intc, omap_clk clk); |
42 | + void *opaque, | 40 | |
43 | + const char *name, int n); | 41 | /* omap_i2c.c */ |
44 | + | 42 | #define TYPE_OMAP_I2C "omap_i2c" |
45 | +/** | 43 | diff --git a/hw/intc/omap_intc.c b/hw/intc/omap_intc.c |
46 | + * qdev_init_gpio_in_named: create an array of input GPIO lines | ||
47 | + * for the specified device | ||
48 | + * | ||
49 | + * Like qdev_init_gpio_in_named_with_opaque(), but the opaque pointer | ||
50 | + * passed to the handler is @dev (which is the most commonly desired behaviour). | ||
51 | + */ | ||
52 | +static inline void qdev_init_gpio_in_named(DeviceState *dev, | ||
53 | + qemu_irq_handler handler, | ||
54 | + const char *name, int n) | ||
55 | +{ | ||
56 | + qdev_init_gpio_in_named_with_opaque(dev, handler, dev, name, n); | ||
57 | +} | ||
58 | |||
59 | void qdev_pass_gpios(DeviceState *dev, DeviceState *container, | ||
60 | const char *name); | ||
61 | diff --git a/hw/core/qdev.c b/hw/core/qdev.c | ||
62 | index XXXXXXX..XXXXXXX 100644 | 44 | index XXXXXXX..XXXXXXX 100644 |
63 | --- a/hw/core/qdev.c | 45 | --- a/hw/intc/omap_intc.c |
64 | +++ b/hw/core/qdev.c | 46 | +++ b/hw/intc/omap_intc.c |
65 | @@ -XXX,XX +XXX,XX @@ static NamedGPIOList *qdev_get_named_gpio_list(DeviceState *dev, | 47 | @@ -XXX,XX +XXX,XX @@ struct omap_intr_handler_bank_s { |
66 | return ngl; | 48 | unsigned char priority[32]; |
67 | } | 49 | }; |
68 | 50 | ||
69 | -void qdev_init_gpio_in_named(DeviceState *dev, qemu_irq_handler handler, | 51 | -struct omap_intr_handler_s { |
70 | - const char *name, int n) | 52 | +struct OMAPIntcState { |
71 | +void qdev_init_gpio_in_named_with_opaque(DeviceState *dev, | 53 | SysBusDevice parent_obj; |
72 | + qemu_irq_handler handler, | 54 | |
73 | + void *opaque, | 55 | qemu_irq *pins; |
74 | + const char *name, int n) | 56 | @@ -XXX,XX +XXX,XX @@ struct omap_intr_handler_s { |
57 | struct omap_intr_handler_bank_s bank[3]; | ||
58 | }; | ||
59 | |||
60 | -static void omap_inth_sir_update(struct omap_intr_handler_s *s, int is_fiq) | ||
61 | +static void omap_inth_sir_update(OMAPIntcState *s, int is_fiq) | ||
62 | { | ||
63 | int i, j, sir_intr, p_intr, p; | ||
64 | uint32_t level; | ||
65 | @@ -XXX,XX +XXX,XX @@ static void omap_inth_sir_update(struct omap_intr_handler_s *s, int is_fiq) | ||
66 | s->sir_intr[is_fiq] = sir_intr; | ||
67 | } | ||
68 | |||
69 | -static inline void omap_inth_update(struct omap_intr_handler_s *s, int is_fiq) | ||
70 | +static inline void omap_inth_update(OMAPIntcState *s, int is_fiq) | ||
75 | { | 71 | { |
76 | int i; | 72 | int i; |
77 | NamedGPIOList *gpio_list = qdev_get_named_gpio_list(dev, name); | 73 | uint32_t has_intr = 0; |
78 | 74 | @@ -XXX,XX +XXX,XX @@ static inline void omap_inth_update(struct omap_intr_handler_s *s, int is_fiq) | |
79 | assert(gpio_list->num_out == 0 || !name); | 75 | |
80 | gpio_list->in = qemu_extend_irqs(gpio_list->in, gpio_list->num_in, handler, | 76 | static void omap_set_intr(void *opaque, int irq, int req) |
81 | - dev, n); | 77 | { |
82 | + opaque, n); | 78 | - struct omap_intr_handler_s *ih = opaque; |
83 | 79 | + OMAPIntcState *ih = opaque; | |
84 | if (!name) { | 80 | uint32_t rise; |
85 | name = "unnamed-gpio-in"; | 81 | |
82 | struct omap_intr_handler_bank_s *bank = &ih->bank[irq >> 5]; | ||
83 | @@ -XXX,XX +XXX,XX @@ static void omap_set_intr(void *opaque, int irq, int req) | ||
84 | /* Simplified version with no edge detection */ | ||
85 | static void omap_set_intr_noedge(void *opaque, int irq, int req) | ||
86 | { | ||
87 | - struct omap_intr_handler_s *ih = opaque; | ||
88 | + OMAPIntcState *ih = opaque; | ||
89 | uint32_t rise; | ||
90 | |||
91 | struct omap_intr_handler_bank_s *bank = &ih->bank[irq >> 5]; | ||
92 | @@ -XXX,XX +XXX,XX @@ static void omap_set_intr_noedge(void *opaque, int irq, int req) | ||
93 | static uint64_t omap_inth_read(void *opaque, hwaddr addr, | ||
94 | unsigned size) | ||
95 | { | ||
96 | - struct omap_intr_handler_s *s = opaque; | ||
97 | + OMAPIntcState *s = opaque; | ||
98 | int i, offset = addr; | ||
99 | int bank_no = offset >> 8; | ||
100 | int line_no; | ||
101 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap_inth_read(void *opaque, hwaddr addr, | ||
102 | static void omap_inth_write(void *opaque, hwaddr addr, | ||
103 | uint64_t value, unsigned size) | ||
104 | { | ||
105 | - struct omap_intr_handler_s *s = opaque; | ||
106 | + OMAPIntcState *s = opaque; | ||
107 | int i, offset = addr; | ||
108 | int bank_no = offset >> 8; | ||
109 | struct omap_intr_handler_bank_s *bank = &s->bank[bank_no]; | ||
110 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap_inth_mem_ops = { | ||
111 | |||
112 | static void omap_inth_reset(DeviceState *dev) | ||
113 | { | ||
114 | - struct omap_intr_handler_s *s = OMAP_INTC(dev); | ||
115 | + OMAPIntcState *s = OMAP_INTC(dev); | ||
116 | int i; | ||
117 | |||
118 | for (i = 0; i < s->nbanks; ++i){ | ||
119 | @@ -XXX,XX +XXX,XX @@ static void omap_inth_reset(DeviceState *dev) | ||
120 | static void omap_intc_init(Object *obj) | ||
121 | { | ||
122 | DeviceState *dev = DEVICE(obj); | ||
123 | - struct omap_intr_handler_s *s = OMAP_INTC(obj); | ||
124 | + OMAPIntcState *s = OMAP_INTC(obj); | ||
125 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
126 | |||
127 | s->nbanks = 1; | ||
128 | @@ -XXX,XX +XXX,XX @@ static void omap_intc_init(Object *obj) | ||
129 | |||
130 | static void omap_intc_realize(DeviceState *dev, Error **errp) | ||
131 | { | ||
132 | - struct omap_intr_handler_s *s = OMAP_INTC(dev); | ||
133 | + OMAPIntcState *s = OMAP_INTC(dev); | ||
134 | |||
135 | if (!s->iclk) { | ||
136 | error_setg(errp, "omap-intc: clk not connected"); | ||
137 | } | ||
138 | } | ||
139 | |||
140 | -void omap_intc_set_iclk(omap_intr_handler *intc, omap_clk clk) | ||
141 | +void omap_intc_set_iclk(OMAPIntcState *intc, omap_clk clk) | ||
142 | { | ||
143 | intc->iclk = clk; | ||
144 | } | ||
145 | |||
146 | -void omap_intc_set_fclk(omap_intr_handler *intc, omap_clk clk) | ||
147 | +void omap_intc_set_fclk(OMAPIntcState *intc, omap_clk clk) | ||
148 | { | ||
149 | intc->fclk = clk; | ||
150 | } | ||
151 | |||
152 | static Property omap_intc_properties[] = { | ||
153 | - DEFINE_PROP_UINT32("size", struct omap_intr_handler_s, size, 0x100), | ||
154 | + DEFINE_PROP_UINT32("size", OMAPIntcState, size, 0x100), | ||
155 | DEFINE_PROP_END_OF_LIST(), | ||
156 | }; | ||
157 | |||
158 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo omap_intc_info = { | ||
159 | static uint64_t omap2_inth_read(void *opaque, hwaddr addr, | ||
160 | unsigned size) | ||
161 | { | ||
162 | - struct omap_intr_handler_s *s = opaque; | ||
163 | + OMAPIntcState *s = opaque; | ||
164 | int offset = addr; | ||
165 | int bank_no, line_no; | ||
166 | struct omap_intr_handler_bank_s *bank = NULL; | ||
167 | @@ -XXX,XX +XXX,XX @@ static uint64_t omap2_inth_read(void *opaque, hwaddr addr, | ||
168 | static void omap2_inth_write(void *opaque, hwaddr addr, | ||
169 | uint64_t value, unsigned size) | ||
170 | { | ||
171 | - struct omap_intr_handler_s *s = opaque; | ||
172 | + OMAPIntcState *s = opaque; | ||
173 | int offset = addr; | ||
174 | int bank_no, line_no; | ||
175 | struct omap_intr_handler_bank_s *bank = NULL; | ||
176 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap2_inth_mem_ops = { | ||
177 | static void omap2_intc_init(Object *obj) | ||
178 | { | ||
179 | DeviceState *dev = DEVICE(obj); | ||
180 | - struct omap_intr_handler_s *s = OMAP_INTC(obj); | ||
181 | + OMAPIntcState *s = OMAP_INTC(obj); | ||
182 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
183 | |||
184 | s->level_only = 1; | ||
185 | @@ -XXX,XX +XXX,XX @@ static void omap2_intc_init(Object *obj) | ||
186 | |||
187 | static void omap2_intc_realize(DeviceState *dev, Error **errp) | ||
188 | { | ||
189 | - struct omap_intr_handler_s *s = OMAP_INTC(dev); | ||
190 | + OMAPIntcState *s = OMAP_INTC(dev); | ||
191 | |||
192 | if (!s->iclk) { | ||
193 | error_setg(errp, "omap2-intc: iclk not connected"); | ||
194 | @@ -XXX,XX +XXX,XX @@ static void omap2_intc_realize(DeviceState *dev, Error **errp) | ||
195 | } | ||
196 | |||
197 | static Property omap2_intc_properties[] = { | ||
198 | - DEFINE_PROP_UINT8("revision", struct omap_intr_handler_s, | ||
199 | + DEFINE_PROP_UINT8("revision", OMAPIntcState, | ||
200 | revision, 0x21), | ||
201 | DEFINE_PROP_END_OF_LIST(), | ||
202 | }; | ||
203 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo omap2_intc_info = { | ||
204 | static const TypeInfo omap_intc_type_info = { | ||
205 | .name = TYPE_OMAP_INTC, | ||
206 | .parent = TYPE_SYS_BUS_DEVICE, | ||
207 | - .instance_size = sizeof(omap_intr_handler), | ||
208 | + .instance_size = sizeof(OMAPIntcState), | ||
209 | .abstract = true, | ||
210 | }; | ||
211 | |||
86 | -- | 212 | -- |
87 | 2.16.2 | 213 | 2.34.1 |
88 | 214 | ||
89 | 215 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 3 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Message-id: 20180228193125.20577-7-richard.henderson@linaro.org | 5 | Message-id: 20230109140306.23161-8-philmd@linaro.org |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 7 | --- |
8 | target/arm/translate-a64.c | 29 +++++++++++++++++++++++++++++ | 8 | hw/arm/stellaris.c | 6 +++--- |
9 | 1 file changed, 29 insertions(+) | 9 | 1 file changed, 3 insertions(+), 3 deletions(-) |
10 | 10 | ||
11 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 11 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c |
12 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate-a64.c | 13 | --- a/hw/arm/stellaris.c |
14 | +++ b/target/arm/translate-a64.c | 14 | +++ b/hw/arm/stellaris.c |
15 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | 15 | @@ -XXX,XX +XXX,XX @@ static void stellaris_adc_update(stellaris_adc_state *s) |
16 | case 0x19: /* FMULX */ | 16 | |
17 | is_fp = true; | 17 | static void stellaris_adc_trigger(void *opaque, int irq, int level) |
18 | break; | 18 | { |
19 | + case 0x1d: /* SQRDMLAH */ | 19 | - stellaris_adc_state *s = (stellaris_adc_state *)opaque; |
20 | + case 0x1f: /* SQRDMLSH */ | 20 | + stellaris_adc_state *s = opaque; |
21 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_RDM)) { | 21 | int n; |
22 | + unallocated_encoding(s); | 22 | |
23 | + return; | 23 | for (n = 0; n < 4; n++) { |
24 | + } | 24 | @@ -XXX,XX +XXX,XX @@ static void stellaris_adc_reset(stellaris_adc_state *s) |
25 | + break; | 25 | static uint64_t stellaris_adc_read(void *opaque, hwaddr offset, |
26 | default: | 26 | unsigned size) |
27 | unallocated_encoding(s); | 27 | { |
28 | return; | 28 | - stellaris_adc_state *s = (stellaris_adc_state *)opaque; |
29 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | 29 | + stellaris_adc_state *s = opaque; |
30 | tcg_op, tcg_idx); | 30 | |
31 | } | 31 | /* TODO: Implement this. */ |
32 | break; | 32 | if (offset >= 0x40 && offset < 0xc0) { |
33 | + case 0x1d: /* SQRDMLAH */ | 33 | @@ -XXX,XX +XXX,XX @@ static uint64_t stellaris_adc_read(void *opaque, hwaddr offset, |
34 | + read_vec_element_i32(s, tcg_res, rd, pass, | 34 | static void stellaris_adc_write(void *opaque, hwaddr offset, |
35 | + is_scalar ? size : MO_32); | 35 | uint64_t value, unsigned size) |
36 | + if (size == 1) { | 36 | { |
37 | + gen_helper_neon_qrdmlah_s16(tcg_res, cpu_env, | 37 | - stellaris_adc_state *s = (stellaris_adc_state *)opaque; |
38 | + tcg_op, tcg_idx, tcg_res); | 38 | + stellaris_adc_state *s = opaque; |
39 | + } else { | 39 | |
40 | + gen_helper_neon_qrdmlah_s32(tcg_res, cpu_env, | 40 | /* TODO: Implement this. */ |
41 | + tcg_op, tcg_idx, tcg_res); | 41 | if (offset >= 0x40 && offset < 0xc0) { |
42 | + } | ||
43 | + break; | ||
44 | + case 0x1f: /* SQRDMLSH */ | ||
45 | + read_vec_element_i32(s, tcg_res, rd, pass, | ||
46 | + is_scalar ? size : MO_32); | ||
47 | + if (size == 1) { | ||
48 | + gen_helper_neon_qrdmlsh_s16(tcg_res, cpu_env, | ||
49 | + tcg_op, tcg_idx, tcg_res); | ||
50 | + } else { | ||
51 | + gen_helper_neon_qrdmlsh_s32(tcg_res, cpu_env, | ||
52 | + tcg_op, tcg_idx, tcg_res); | ||
53 | + } | ||
54 | + break; | ||
55 | default: | ||
56 | g_assert_not_reached(); | ||
57 | } | ||
58 | -- | 42 | -- |
59 | 2.16.2 | 43 | 2.34.1 |
60 | 44 | ||
61 | 45 | diff view generated by jsdifflib |
1 | From: Alistair Francis <alistair.francis@xilinx.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Allow the guest to determine the time set from the QEMU command line. | 3 | Following docs/devel/style.rst guidelines, rename |
4 | stellaris_adc_state -> StellarisADCState. This also remove a | ||
5 | use of 'struct' in the DECLARE_INSTANCE_CHECKER() macro call. | ||
4 | 6 | ||
5 | This includes adding a trace event to debug the new time. | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
6 | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | |
7 | Signed-off-by: Alistair Francis <alistair.francis@xilinx.com> | 9 | Message-id: 20230109140306.23161-9-philmd@linaro.org |
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 11 | --- |
12 | include/hw/timer/xlnx-zynqmp-rtc.h | 2 ++ | 12 | hw/arm/stellaris.c | 73 +++++++++++++++++++++++----------------------- |
13 | hw/timer/xlnx-zynqmp-rtc.c | 58 ++++++++++++++++++++++++++++++++++++++ | 13 | 1 file changed, 36 insertions(+), 37 deletions(-) |
14 | hw/timer/trace-events | 3 ++ | ||
15 | 3 files changed, 63 insertions(+) | ||
16 | 14 | ||
17 | diff --git a/include/hw/timer/xlnx-zynqmp-rtc.h b/include/hw/timer/xlnx-zynqmp-rtc.h | 15 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c |
18 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/hw/timer/xlnx-zynqmp-rtc.h | 17 | --- a/hw/arm/stellaris.c |
20 | +++ b/include/hw/timer/xlnx-zynqmp-rtc.h | 18 | +++ b/hw/arm/stellaris.c |
21 | @@ -XXX,XX +XXX,XX @@ typedef struct XlnxZynqMPRTC { | 19 | @@ -XXX,XX +XXX,XX @@ static void stellaris_i2c_init(Object *obj) |
22 | qemu_irq irq_rtc_int; | 20 | #define STELLARIS_ADC_FIFO_FULL 0x1000 |
23 | qemu_irq irq_addr_error_int; | 21 | |
24 | 22 | #define TYPE_STELLARIS_ADC "stellaris-adc" | |
25 | + uint32_t tick_offset; | 23 | -typedef struct StellarisADCState stellaris_adc_state; |
26 | + | 24 | -DECLARE_INSTANCE_CHECKER(stellaris_adc_state, STELLARIS_ADC, |
27 | uint32_t regs[XLNX_ZYNQMP_RTC_R_MAX]; | 25 | - TYPE_STELLARIS_ADC) |
28 | RegisterInfo regs_info[XLNX_ZYNQMP_RTC_R_MAX]; | 26 | +typedef struct StellarisADCState StellarisADCState; |
29 | } XlnxZynqMPRTC; | 27 | +DECLARE_INSTANCE_CHECKER(StellarisADCState, STELLARIS_ADC, TYPE_STELLARIS_ADC) |
30 | diff --git a/hw/timer/xlnx-zynqmp-rtc.c b/hw/timer/xlnx-zynqmp-rtc.c | 28 | |
31 | index XXXXXXX..XXXXXXX 100644 | 29 | struct StellarisADCState { |
32 | --- a/hw/timer/xlnx-zynqmp-rtc.c | 30 | SysBusDevice parent_obj; |
33 | +++ b/hw/timer/xlnx-zynqmp-rtc.c | 31 | @@ -XXX,XX +XXX,XX @@ struct StellarisADCState { |
34 | @@ -XXX,XX +XXX,XX @@ | 32 | qemu_irq irq[4]; |
35 | #include "hw/register.h" | 33 | }; |
36 | #include "qemu/bitops.h" | 34 | |
37 | #include "qemu/log.h" | 35 | -static uint32_t stellaris_adc_fifo_read(stellaris_adc_state *s, int n) |
38 | +#include "hw/ptimer.h" | 36 | +static uint32_t stellaris_adc_fifo_read(StellarisADCState *s, int n) |
39 | +#include "qemu/cutils.h" | 37 | { |
40 | +#include "sysemu/sysemu.h" | 38 | int tail; |
41 | +#include "trace.h" | 39 | |
42 | #include "hw/timer/xlnx-zynqmp-rtc.h" | 40 | @@ -XXX,XX +XXX,XX @@ static uint32_t stellaris_adc_fifo_read(stellaris_adc_state *s, int n) |
43 | 41 | return s->fifo[n].data[tail]; | |
44 | #ifndef XLNX_ZYNQMP_RTC_ERR_DEBUG | ||
45 | @@ -XXX,XX +XXX,XX @@ static void addr_error_int_update_irq(XlnxZynqMPRTC *s) | ||
46 | qemu_set_irq(s->irq_addr_error_int, pending); | ||
47 | } | 42 | } |
48 | 43 | ||
49 | +static uint32_t rtc_get_count(XlnxZynqMPRTC *s) | 44 | -static void stellaris_adc_fifo_write(stellaris_adc_state *s, int n, |
50 | +{ | 45 | +static void stellaris_adc_fifo_write(StellarisADCState *s, int n, |
51 | + int64_t now = qemu_clock_get_ns(rtc_clock); | 46 | uint32_t value) |
52 | + return s->tick_offset + now / NANOSECONDS_PER_SECOND; | ||
53 | +} | ||
54 | + | ||
55 | +static uint64_t current_time_postr(RegisterInfo *reg, uint64_t val64) | ||
56 | +{ | ||
57 | + XlnxZynqMPRTC *s = XLNX_ZYNQMP_RTC(reg->opaque); | ||
58 | + | ||
59 | + return rtc_get_count(s); | ||
60 | +} | ||
61 | + | ||
62 | static void rtc_int_status_postw(RegisterInfo *reg, uint64_t val64) | ||
63 | { | 47 | { |
64 | XlnxZynqMPRTC *s = XLNX_ZYNQMP_RTC(reg->opaque); | 48 | int head; |
65 | @@ -XXX,XX +XXX,XX @@ static uint64_t addr_error_int_dis_prew(RegisterInfo *reg, uint64_t val64) | 49 | @@ -XXX,XX +XXX,XX @@ static void stellaris_adc_fifo_write(stellaris_adc_state *s, int n, |
66 | 50 | s->fifo[n].state |= STELLARIS_ADC_FIFO_FULL; | |
67 | static const RegisterAccessInfo rtc_regs_info[] = { | ||
68 | { .name = "SET_TIME_WRITE", .addr = A_SET_TIME_WRITE, | ||
69 | + .unimp = MAKE_64BIT_MASK(0, 32), | ||
70 | },{ .name = "SET_TIME_READ", .addr = A_SET_TIME_READ, | ||
71 | .ro = 0xffffffff, | ||
72 | + .post_read = current_time_postr, | ||
73 | },{ .name = "CALIB_WRITE", .addr = A_CALIB_WRITE, | ||
74 | + .unimp = MAKE_64BIT_MASK(0, 32), | ||
75 | },{ .name = "CALIB_READ", .addr = A_CALIB_READ, | ||
76 | .ro = 0x1fffff, | ||
77 | },{ .name = "CURRENT_TIME", .addr = A_CURRENT_TIME, | ||
78 | .ro = 0xffffffff, | ||
79 | + .post_read = current_time_postr, | ||
80 | },{ .name = "CURRENT_TICK", .addr = A_CURRENT_TICK, | ||
81 | .ro = 0xffff, | ||
82 | },{ .name = "ALARM", .addr = A_ALARM, | ||
83 | @@ -XXX,XX +XXX,XX @@ static void rtc_init(Object *obj) | ||
84 | XlnxZynqMPRTC *s = XLNX_ZYNQMP_RTC(obj); | ||
85 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
86 | RegisterInfoArray *reg_array; | ||
87 | + struct tm current_tm; | ||
88 | |||
89 | memory_region_init(&s->iomem, obj, TYPE_XLNX_ZYNQMP_RTC, | ||
90 | XLNX_ZYNQMP_RTC_R_MAX * 4); | ||
91 | @@ -XXX,XX +XXX,XX @@ static void rtc_init(Object *obj) | ||
92 | sysbus_init_mmio(sbd, &s->iomem); | ||
93 | sysbus_init_irq(sbd, &s->irq_rtc_int); | ||
94 | sysbus_init_irq(sbd, &s->irq_addr_error_int); | ||
95 | + | ||
96 | + qemu_get_timedate(¤t_tm, 0); | ||
97 | + s->tick_offset = mktimegm(¤t_tm) - | ||
98 | + qemu_clock_get_ns(rtc_clock) / NANOSECONDS_PER_SECOND; | ||
99 | + | ||
100 | + trace_xlnx_zynqmp_rtc_gettime(current_tm.tm_year, current_tm.tm_mon, | ||
101 | + current_tm.tm_mday, current_tm.tm_hour, | ||
102 | + current_tm.tm_min, current_tm.tm_sec); | ||
103 | +} | ||
104 | + | ||
105 | +static int rtc_pre_save(void *opaque) | ||
106 | +{ | ||
107 | + XlnxZynqMPRTC *s = opaque; | ||
108 | + int64_t now = qemu_clock_get_ns(rtc_clock) / NANOSECONDS_PER_SECOND; | ||
109 | + | ||
110 | + /* Add the time at migration */ | ||
111 | + s->tick_offset = s->tick_offset + now; | ||
112 | + | ||
113 | + return 0; | ||
114 | +} | ||
115 | + | ||
116 | +static int rtc_post_load(void *opaque, int version_id) | ||
117 | +{ | ||
118 | + XlnxZynqMPRTC *s = opaque; | ||
119 | + int64_t now = qemu_clock_get_ns(rtc_clock) / NANOSECONDS_PER_SECOND; | ||
120 | + | ||
121 | + /* Subtract the time after migration. This combined with the pre_save | ||
122 | + * action results in us having subtracted the time that the guest was | ||
123 | + * stopped to the offset. | ||
124 | + */ | ||
125 | + s->tick_offset = s->tick_offset - now; | ||
126 | + | ||
127 | + return 0; | ||
128 | } | 51 | } |
129 | 52 | ||
130 | static const VMStateDescription vmstate_rtc = { | 53 | -static void stellaris_adc_update(stellaris_adc_state *s) |
131 | .name = TYPE_XLNX_ZYNQMP_RTC, | 54 | +static void stellaris_adc_update(StellarisADCState *s) |
55 | { | ||
56 | int level; | ||
57 | int n; | ||
58 | @@ -XXX,XX +XXX,XX @@ static void stellaris_adc_update(stellaris_adc_state *s) | ||
59 | |||
60 | static void stellaris_adc_trigger(void *opaque, int irq, int level) | ||
61 | { | ||
62 | - stellaris_adc_state *s = opaque; | ||
63 | + StellarisADCState *s = opaque; | ||
64 | int n; | ||
65 | |||
66 | for (n = 0; n < 4; n++) { | ||
67 | @@ -XXX,XX +XXX,XX @@ static void stellaris_adc_trigger(void *opaque, int irq, int level) | ||
68 | } | ||
69 | } | ||
70 | |||
71 | -static void stellaris_adc_reset(stellaris_adc_state *s) | ||
72 | +static void stellaris_adc_reset(StellarisADCState *s) | ||
73 | { | ||
74 | int n; | ||
75 | |||
76 | @@ -XXX,XX +XXX,XX @@ static void stellaris_adc_reset(stellaris_adc_state *s) | ||
77 | static uint64_t stellaris_adc_read(void *opaque, hwaddr offset, | ||
78 | unsigned size) | ||
79 | { | ||
80 | - stellaris_adc_state *s = opaque; | ||
81 | + StellarisADCState *s = opaque; | ||
82 | |||
83 | /* TODO: Implement this. */ | ||
84 | if (offset >= 0x40 && offset < 0xc0) { | ||
85 | @@ -XXX,XX +XXX,XX @@ static uint64_t stellaris_adc_read(void *opaque, hwaddr offset, | ||
86 | static void stellaris_adc_write(void *opaque, hwaddr offset, | ||
87 | uint64_t value, unsigned size) | ||
88 | { | ||
89 | - stellaris_adc_state *s = opaque; | ||
90 | + StellarisADCState *s = opaque; | ||
91 | |||
92 | /* TODO: Implement this. */ | ||
93 | if (offset >= 0x40 && offset < 0xc0) { | ||
94 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_stellaris_adc = { | ||
132 | .version_id = 1, | 95 | .version_id = 1, |
133 | .minimum_version_id = 1, | 96 | .minimum_version_id = 1, |
134 | + .pre_save = rtc_pre_save, | ||
135 | + .post_load = rtc_post_load, | ||
136 | .fields = (VMStateField[]) { | 97 | .fields = (VMStateField[]) { |
137 | VMSTATE_UINT32_ARRAY(regs, XlnxZynqMPRTC, XLNX_ZYNQMP_RTC_R_MAX), | 98 | - VMSTATE_UINT32(actss, stellaris_adc_state), |
138 | + VMSTATE_UINT32(tick_offset, XlnxZynqMPRTC), | 99 | - VMSTATE_UINT32(ris, stellaris_adc_state), |
139 | VMSTATE_END_OF_LIST(), | 100 | - VMSTATE_UINT32(im, stellaris_adc_state), |
101 | - VMSTATE_UINT32(emux, stellaris_adc_state), | ||
102 | - VMSTATE_UINT32(ostat, stellaris_adc_state), | ||
103 | - VMSTATE_UINT32(ustat, stellaris_adc_state), | ||
104 | - VMSTATE_UINT32(sspri, stellaris_adc_state), | ||
105 | - VMSTATE_UINT32(sac, stellaris_adc_state), | ||
106 | - VMSTATE_UINT32(fifo[0].state, stellaris_adc_state), | ||
107 | - VMSTATE_UINT32_ARRAY(fifo[0].data, stellaris_adc_state, 16), | ||
108 | - VMSTATE_UINT32(ssmux[0], stellaris_adc_state), | ||
109 | - VMSTATE_UINT32(ssctl[0], stellaris_adc_state), | ||
110 | - VMSTATE_UINT32(fifo[1].state, stellaris_adc_state), | ||
111 | - VMSTATE_UINT32_ARRAY(fifo[1].data, stellaris_adc_state, 16), | ||
112 | - VMSTATE_UINT32(ssmux[1], stellaris_adc_state), | ||
113 | - VMSTATE_UINT32(ssctl[1], stellaris_adc_state), | ||
114 | - VMSTATE_UINT32(fifo[2].state, stellaris_adc_state), | ||
115 | - VMSTATE_UINT32_ARRAY(fifo[2].data, stellaris_adc_state, 16), | ||
116 | - VMSTATE_UINT32(ssmux[2], stellaris_adc_state), | ||
117 | - VMSTATE_UINT32(ssctl[2], stellaris_adc_state), | ||
118 | - VMSTATE_UINT32(fifo[3].state, stellaris_adc_state), | ||
119 | - VMSTATE_UINT32_ARRAY(fifo[3].data, stellaris_adc_state, 16), | ||
120 | - VMSTATE_UINT32(ssmux[3], stellaris_adc_state), | ||
121 | - VMSTATE_UINT32(ssctl[3], stellaris_adc_state), | ||
122 | - VMSTATE_UINT32(noise, stellaris_adc_state), | ||
123 | + VMSTATE_UINT32(actss, StellarisADCState), | ||
124 | + VMSTATE_UINT32(ris, StellarisADCState), | ||
125 | + VMSTATE_UINT32(im, StellarisADCState), | ||
126 | + VMSTATE_UINT32(emux, StellarisADCState), | ||
127 | + VMSTATE_UINT32(ostat, StellarisADCState), | ||
128 | + VMSTATE_UINT32(ustat, StellarisADCState), | ||
129 | + VMSTATE_UINT32(sspri, StellarisADCState), | ||
130 | + VMSTATE_UINT32(sac, StellarisADCState), | ||
131 | + VMSTATE_UINT32(fifo[0].state, StellarisADCState), | ||
132 | + VMSTATE_UINT32_ARRAY(fifo[0].data, StellarisADCState, 16), | ||
133 | + VMSTATE_UINT32(ssmux[0], StellarisADCState), | ||
134 | + VMSTATE_UINT32(ssctl[0], StellarisADCState), | ||
135 | + VMSTATE_UINT32(fifo[1].state, StellarisADCState), | ||
136 | + VMSTATE_UINT32_ARRAY(fifo[1].data, StellarisADCState, 16), | ||
137 | + VMSTATE_UINT32(ssmux[1], StellarisADCState), | ||
138 | + VMSTATE_UINT32(ssctl[1], StellarisADCState), | ||
139 | + VMSTATE_UINT32(fifo[2].state, StellarisADCState), | ||
140 | + VMSTATE_UINT32_ARRAY(fifo[2].data, StellarisADCState, 16), | ||
141 | + VMSTATE_UINT32(ssmux[2], StellarisADCState), | ||
142 | + VMSTATE_UINT32(ssctl[2], StellarisADCState), | ||
143 | + VMSTATE_UINT32(fifo[3].state, StellarisADCState), | ||
144 | + VMSTATE_UINT32_ARRAY(fifo[3].data, StellarisADCState, 16), | ||
145 | + VMSTATE_UINT32(ssmux[3], StellarisADCState), | ||
146 | + VMSTATE_UINT32(ssctl[3], StellarisADCState), | ||
147 | + VMSTATE_UINT32(noise, StellarisADCState), | ||
148 | VMSTATE_END_OF_LIST() | ||
140 | } | 149 | } |
141 | }; | 150 | }; |
142 | diff --git a/hw/timer/trace-events b/hw/timer/trace-events | 151 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_stellaris_adc = { |
143 | index XXXXXXX..XXXXXXX 100644 | 152 | static void stellaris_adc_init(Object *obj) |
144 | --- a/hw/timer/trace-events | 153 | { |
145 | +++ b/hw/timer/trace-events | 154 | DeviceState *dev = DEVICE(obj); |
146 | @@ -XXX,XX +XXX,XX @@ systick_write(uint64_t addr, uint32_t value, unsigned size) "systick write addr | 155 | - stellaris_adc_state *s = STELLARIS_ADC(obj); |
147 | cmsdk_apb_timer_read(uint64_t offset, uint64_t data, unsigned size) "CMSDK APB timer read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" | 156 | + StellarisADCState *s = STELLARIS_ADC(obj); |
148 | cmsdk_apb_timer_write(uint64_t offset, uint64_t data, unsigned size) "CMSDK APB timer write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" | 157 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); |
149 | cmsdk_apb_timer_reset(void) "CMSDK APB timer: reset" | 158 | int n; |
150 | + | 159 | |
151 | +# hw/timer/xlnx-zynqmp-rtc.c | 160 | @@ -XXX,XX +XXX,XX @@ static void stellaris_adc_class_init(ObjectClass *klass, void *data) |
152 | +xlnx_zynqmp_rtc_gettime(int year, int month, int day, int hour, int min, int sec) "Get time from host: %d-%d-%d %2d:%02d:%02d" | 161 | static const TypeInfo stellaris_adc_info = { |
162 | .name = TYPE_STELLARIS_ADC, | ||
163 | .parent = TYPE_SYS_BUS_DEVICE, | ||
164 | - .instance_size = sizeof(stellaris_adc_state), | ||
165 | + .instance_size = sizeof(StellarisADCState), | ||
166 | .instance_init = stellaris_adc_init, | ||
167 | .class_init = stellaris_adc_class_init, | ||
168 | }; | ||
153 | -- | 169 | -- |
154 | 2.16.2 | 170 | 2.34.1 |
155 | 171 | ||
156 | 172 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Include the U bit in the switches rather than testing separately. | 3 | The typedef and definitions are generated by the OBJECT_DECLARE_TYPE |
4 | macro in "hw/arm/bcm2836.h": | ||
4 | 5 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | 20 #define TYPE_BCM283X "bcm283x" |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | 21 OBJECT_DECLARE_TYPE(BCM283XState, BCM283XClass, BCM283X) |
7 | Message-id: 20180228193125.20577-3-richard.henderson@linaro.org | 8 | |
9 | The script ran in commit a489d1951c ("Use OBJECT_DECLARE_TYPE when | ||
10 | possible") missed them because they are declared in a different | ||
11 | file unit. Remove them. | ||
12 | |||
13 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Message-id: 20230109140306.23161-10-philmd@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 17 | --- |
10 | target/arm/translate-a64.c | 129 +++++++++++++++++++++------------------------ | 18 | hw/arm/bcm2836.c | 9 ++------- |
11 | 1 file changed, 61 insertions(+), 68 deletions(-) | 19 | 1 file changed, 2 insertions(+), 7 deletions(-) |
12 | 20 | ||
13 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 21 | diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c |
14 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate-a64.c | 23 | --- a/hw/arm/bcm2836.c |
16 | +++ b/target/arm/translate-a64.c | 24 | +++ b/hw/arm/bcm2836.c |
17 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | 25 | @@ -XXX,XX +XXX,XX @@ |
18 | int index; | 26 | #include "hw/arm/raspi_platform.h" |
19 | TCGv_ptr fpst; | 27 | #include "hw/sysbus.h" |
20 | 28 | ||
21 | - switch (opcode) { | 29 | -typedef struct BCM283XClass { |
22 | - case 0x0: /* MLA */ | 30 | +struct BCM283XClass { |
23 | - case 0x4: /* MLS */ | 31 | /*< private >*/ |
24 | - if (!u || is_scalar) { | 32 | DeviceClass parent_class; |
25 | + switch (16 * u + opcode) { | 33 | /*< public >*/ |
26 | + case 0x08: /* MUL */ | 34 | @@ -XXX,XX +XXX,XX @@ typedef struct BCM283XClass { |
27 | + case 0x10: /* MLA */ | 35 | hwaddr peri_base; /* Peripheral base address seen by the CPU */ |
28 | + case 0x14: /* MLS */ | 36 | hwaddr ctrl_base; /* Interrupt controller and mailboxes etc. */ |
29 | + if (is_scalar) { | 37 | int clusterid; |
30 | unallocated_encoding(s); | 38 | -} BCM283XClass; |
31 | return; | 39 | - |
32 | } | 40 | -#define BCM283X_CLASS(klass) \ |
33 | break; | 41 | - OBJECT_CLASS_CHECK(BCM283XClass, (klass), TYPE_BCM283X) |
34 | - case 0x2: /* SMLAL, SMLAL2, UMLAL, UMLAL2 */ | 42 | -#define BCM283X_GET_CLASS(obj) \ |
35 | - case 0x6: /* SMLSL, SMLSL2, UMLSL, UMLSL2 */ | 43 | - OBJECT_GET_CLASS(BCM283XClass, (obj), TYPE_BCM283X) |
36 | - case 0xa: /* SMULL, SMULL2, UMULL, UMULL2 */ | 44 | +}; |
37 | + case 0x02: /* SMLAL, SMLAL2 */ | 45 | |
38 | + case 0x12: /* UMLAL, UMLAL2 */ | 46 | static Property bcm2836_enabled_cores_property = |
39 | + case 0x06: /* SMLSL, SMLSL2 */ | 47 | DEFINE_PROP_UINT32("enabled-cpus", BCM283XState, enabled_cpus, 0); |
40 | + case 0x16: /* UMLSL, UMLSL2 */ | ||
41 | + case 0x0a: /* SMULL, SMULL2 */ | ||
42 | + case 0x1a: /* UMULL, UMULL2 */ | ||
43 | if (is_scalar) { | ||
44 | unallocated_encoding(s); | ||
45 | return; | ||
46 | } | ||
47 | is_long = true; | ||
48 | break; | ||
49 | - case 0x3: /* SQDMLAL, SQDMLAL2 */ | ||
50 | - case 0x7: /* SQDMLSL, SQDMLSL2 */ | ||
51 | - case 0xb: /* SQDMULL, SQDMULL2 */ | ||
52 | + case 0x03: /* SQDMLAL, SQDMLAL2 */ | ||
53 | + case 0x07: /* SQDMLSL, SQDMLSL2 */ | ||
54 | + case 0x0b: /* SQDMULL, SQDMULL2 */ | ||
55 | is_long = true; | ||
56 | - /* fall through */ | ||
57 | - case 0xc: /* SQDMULH */ | ||
58 | - case 0xd: /* SQRDMULH */ | ||
59 | - if (u) { | ||
60 | - unallocated_encoding(s); | ||
61 | - return; | ||
62 | - } | ||
63 | break; | ||
64 | - case 0x8: /* MUL */ | ||
65 | - if (u || is_scalar) { | ||
66 | - unallocated_encoding(s); | ||
67 | - return; | ||
68 | - } | ||
69 | + case 0x0c: /* SQDMULH */ | ||
70 | + case 0x0d: /* SQRDMULH */ | ||
71 | break; | ||
72 | - case 0x1: /* FMLA */ | ||
73 | - case 0x5: /* FMLS */ | ||
74 | - if (u) { | ||
75 | - unallocated_encoding(s); | ||
76 | - return; | ||
77 | - } | ||
78 | - /* fall through */ | ||
79 | - case 0x9: /* FMUL, FMULX */ | ||
80 | + case 0x01: /* FMLA */ | ||
81 | + case 0x05: /* FMLS */ | ||
82 | + case 0x09: /* FMUL */ | ||
83 | + case 0x19: /* FMULX */ | ||
84 | if (size == 1) { | ||
85 | unallocated_encoding(s); | ||
86 | return; | ||
87 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | ||
88 | |||
89 | read_vec_element(s, tcg_op, rn, pass, MO_64); | ||
90 | |||
91 | - switch (opcode) { | ||
92 | - case 0x5: /* FMLS */ | ||
93 | + switch (16 * u + opcode) { | ||
94 | + case 0x05: /* FMLS */ | ||
95 | /* As usual for ARM, separate negation for fused multiply-add */ | ||
96 | gen_helper_vfp_negd(tcg_op, tcg_op); | ||
97 | /* fall through */ | ||
98 | - case 0x1: /* FMLA */ | ||
99 | + case 0x01: /* FMLA */ | ||
100 | read_vec_element(s, tcg_res, rd, pass, MO_64); | ||
101 | gen_helper_vfp_muladdd(tcg_res, tcg_op, tcg_idx, tcg_res, fpst); | ||
102 | break; | ||
103 | - case 0x9: /* FMUL, FMULX */ | ||
104 | - if (u) { | ||
105 | - gen_helper_vfp_mulxd(tcg_res, tcg_op, tcg_idx, fpst); | ||
106 | - } else { | ||
107 | - gen_helper_vfp_muld(tcg_res, tcg_op, tcg_idx, fpst); | ||
108 | - } | ||
109 | + case 0x09: /* FMUL */ | ||
110 | + gen_helper_vfp_muld(tcg_res, tcg_op, tcg_idx, fpst); | ||
111 | + break; | ||
112 | + case 0x19: /* FMULX */ | ||
113 | + gen_helper_vfp_mulxd(tcg_res, tcg_op, tcg_idx, fpst); | ||
114 | break; | ||
115 | default: | ||
116 | g_assert_not_reached(); | ||
117 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | ||
118 | |||
119 | read_vec_element_i32(s, tcg_op, rn, pass, is_scalar ? size : MO_32); | ||
120 | |||
121 | - switch (opcode) { | ||
122 | - case 0x0: /* MLA */ | ||
123 | - case 0x4: /* MLS */ | ||
124 | - case 0x8: /* MUL */ | ||
125 | + switch (16 * u + opcode) { | ||
126 | + case 0x08: /* MUL */ | ||
127 | + case 0x10: /* MLA */ | ||
128 | + case 0x14: /* MLS */ | ||
129 | { | ||
130 | static NeonGenTwoOpFn * const fns[2][2] = { | ||
131 | { gen_helper_neon_add_u16, gen_helper_neon_sub_u16 }, | ||
132 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | ||
133 | genfn(tcg_res, tcg_op, tcg_res); | ||
134 | break; | ||
135 | } | ||
136 | - case 0x5: /* FMLS */ | ||
137 | - case 0x1: /* FMLA */ | ||
138 | + case 0x05: /* FMLS */ | ||
139 | + case 0x01: /* FMLA */ | ||
140 | read_vec_element_i32(s, tcg_res, rd, pass, | ||
141 | is_scalar ? size : MO_32); | ||
142 | switch (size) { | ||
143 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | ||
144 | g_assert_not_reached(); | ||
145 | } | ||
146 | break; | ||
147 | - case 0x9: /* FMUL, FMULX */ | ||
148 | + case 0x09: /* FMUL */ | ||
149 | switch (size) { | ||
150 | case 1: | ||
151 | - if (u) { | ||
152 | - if (is_scalar) { | ||
153 | - gen_helper_advsimd_mulxh(tcg_res, tcg_op, | ||
154 | - tcg_idx, fpst); | ||
155 | - } else { | ||
156 | - gen_helper_advsimd_mulx2h(tcg_res, tcg_op, | ||
157 | - tcg_idx, fpst); | ||
158 | - } | ||
159 | + if (is_scalar) { | ||
160 | + gen_helper_advsimd_mulh(tcg_res, tcg_op, | ||
161 | + tcg_idx, fpst); | ||
162 | } else { | ||
163 | - if (is_scalar) { | ||
164 | - gen_helper_advsimd_mulh(tcg_res, tcg_op, | ||
165 | - tcg_idx, fpst); | ||
166 | - } else { | ||
167 | - gen_helper_advsimd_mul2h(tcg_res, tcg_op, | ||
168 | - tcg_idx, fpst); | ||
169 | - } | ||
170 | + gen_helper_advsimd_mul2h(tcg_res, tcg_op, | ||
171 | + tcg_idx, fpst); | ||
172 | } | ||
173 | break; | ||
174 | case 2: | ||
175 | - if (u) { | ||
176 | - gen_helper_vfp_mulxs(tcg_res, tcg_op, tcg_idx, fpst); | ||
177 | - } else { | ||
178 | - gen_helper_vfp_muls(tcg_res, tcg_op, tcg_idx, fpst); | ||
179 | - } | ||
180 | + gen_helper_vfp_muls(tcg_res, tcg_op, tcg_idx, fpst); | ||
181 | break; | ||
182 | default: | ||
183 | g_assert_not_reached(); | ||
184 | } | ||
185 | break; | ||
186 | - case 0xc: /* SQDMULH */ | ||
187 | + case 0x19: /* FMULX */ | ||
188 | + switch (size) { | ||
189 | + case 1: | ||
190 | + if (is_scalar) { | ||
191 | + gen_helper_advsimd_mulxh(tcg_res, tcg_op, | ||
192 | + tcg_idx, fpst); | ||
193 | + } else { | ||
194 | + gen_helper_advsimd_mulx2h(tcg_res, tcg_op, | ||
195 | + tcg_idx, fpst); | ||
196 | + } | ||
197 | + break; | ||
198 | + case 2: | ||
199 | + gen_helper_vfp_mulxs(tcg_res, tcg_op, tcg_idx, fpst); | ||
200 | + break; | ||
201 | + default: | ||
202 | + g_assert_not_reached(); | ||
203 | + } | ||
204 | + break; | ||
205 | + case 0x0c: /* SQDMULH */ | ||
206 | if (size == 1) { | ||
207 | gen_helper_neon_qdmulh_s16(tcg_res, cpu_env, | ||
208 | tcg_op, tcg_idx); | ||
209 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | ||
210 | tcg_op, tcg_idx); | ||
211 | } | ||
212 | break; | ||
213 | - case 0xd: /* SQRDMULH */ | ||
214 | + case 0x0d: /* SQRDMULH */ | ||
215 | if (size == 1) { | ||
216 | gen_helper_neon_qrdmulh_s16(tcg_res, cpu_env, | ||
217 | tcg_op, tcg_idx); | ||
218 | -- | 48 | -- |
219 | 2.16.2 | 49 | 2.34.1 |
220 | 50 | ||
221 | 51 | diff view generated by jsdifflib |
1 | Create an "idau" property on the armv7m container object which | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | we can forward to the CPU object. Annoyingly, we can't use | 2 | |
3 | object_property_add_alias() because the CPU object we want to | 3 | NPCM7XX models have been commited after the conversion from |
4 | forward to doesn't exist until the armv7m container is realized. | 4 | commit 8063396bf3 ("Use OBJECT_DECLARE_SIMPLE_TYPE when possible"). |
5 | 5 | Manually convert them. | |
6 | |||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20230109140306.23161-11-philmd@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20180220180325.29818-6-peter.maydell@linaro.org | ||
9 | --- | 11 | --- |
10 | include/hw/arm/armv7m.h | 3 +++ | 12 | include/hw/adc/npcm7xx_adc.h | 7 +++---- |
11 | hw/arm/armv7m.c | 9 +++++++++ | 13 | include/hw/arm/npcm7xx.h | 18 ++++++------------ |
12 | 2 files changed, 12 insertions(+) | 14 | include/hw/i2c/npcm7xx_smbus.h | 7 +++---- |
13 | 15 | include/hw/misc/npcm7xx_clk.h | 2 +- | |
14 | diff --git a/include/hw/arm/armv7m.h b/include/hw/arm/armv7m.h | 16 | include/hw/misc/npcm7xx_gcr.h | 6 +++--- |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | include/hw/misc/npcm7xx_mft.h | 7 +++---- |
16 | --- a/include/hw/arm/armv7m.h | 18 | include/hw/misc/npcm7xx_pwm.h | 3 +-- |
17 | +++ b/include/hw/arm/armv7m.h | 19 | include/hw/misc/npcm7xx_rng.h | 6 +++--- |
18 | @@ -XXX,XX +XXX,XX @@ | 20 | include/hw/net/npcm7xx_emc.h | 5 +---- |
21 | include/hw/sd/npcm7xx_sdhci.h | 4 ++-- | ||
22 | 10 files changed, 26 insertions(+), 39 deletions(-) | ||
23 | |||
24 | diff --git a/include/hw/adc/npcm7xx_adc.h b/include/hw/adc/npcm7xx_adc.h | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/include/hw/adc/npcm7xx_adc.h | ||
27 | +++ b/include/hw/adc/npcm7xx_adc.h | ||
28 | @@ -XXX,XX +XXX,XX @@ | ||
29 | * @iref: The internal reference voltage, initialized at launch time. | ||
30 | * @rv: The calibrated output values of 0.5V and 1.5V for the ADC. | ||
31 | */ | ||
32 | -typedef struct { | ||
33 | +struct NPCM7xxADCState { | ||
34 | SysBusDevice parent; | ||
35 | |||
36 | MemoryRegion iomem; | ||
37 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
38 | uint32_t iref; | ||
39 | |||
40 | uint16_t calibration_r_values[NPCM7XX_ADC_NUM_CALIB]; | ||
41 | -} NPCM7xxADCState; | ||
42 | +}; | ||
43 | |||
44 | #define TYPE_NPCM7XX_ADC "npcm7xx-adc" | ||
45 | -#define NPCM7XX_ADC(obj) \ | ||
46 | - OBJECT_CHECK(NPCM7xxADCState, (obj), TYPE_NPCM7XX_ADC) | ||
47 | +OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxADCState, NPCM7XX_ADC) | ||
48 | |||
49 | #endif /* NPCM7XX_ADC_H */ | ||
50 | diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/include/hw/arm/npcm7xx.h | ||
53 | +++ b/include/hw/arm/npcm7xx.h | ||
54 | @@ -XXX,XX +XXX,XX @@ | ||
55 | |||
56 | #define NPCM7XX_NR_PWM_MODULES 2 | ||
57 | |||
58 | -typedef struct NPCM7xxMachine { | ||
59 | +struct NPCM7xxMachine { | ||
60 | MachineState parent; | ||
61 | /* | ||
62 | * PWM fan splitter. each splitter connects to one PWM output and | ||
63 | @@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxMachine { | ||
64 | */ | ||
65 | SplitIRQ fan_splitter[NPCM7XX_NR_PWM_MODULES * | ||
66 | NPCM7XX_PWM_PER_MODULE]; | ||
67 | -} NPCM7xxMachine; | ||
68 | +}; | ||
69 | |||
70 | #define TYPE_NPCM7XX_MACHINE MACHINE_TYPE_NAME("npcm7xx") | ||
71 | -#define NPCM7XX_MACHINE(obj) \ | ||
72 | - OBJECT_CHECK(NPCM7xxMachine, (obj), TYPE_NPCM7XX_MACHINE) | ||
73 | +OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxMachine, NPCM7XX_MACHINE) | ||
74 | |||
75 | typedef struct NPCM7xxMachineClass { | ||
76 | MachineClass parent; | ||
77 | @@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxMachineClass { | ||
78 | #define NPCM7XX_MACHINE_GET_CLASS(obj) \ | ||
79 | OBJECT_GET_CLASS(NPCM7xxMachineClass, (obj), TYPE_NPCM7XX_MACHINE) | ||
80 | |||
81 | -typedef struct NPCM7xxState { | ||
82 | +struct NPCM7xxState { | ||
83 | DeviceState parent; | ||
84 | |||
85 | ARMCPU cpu[NPCM7XX_MAX_NUM_CPUS]; | ||
86 | @@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxState { | ||
87 | NPCM7xxFIUState fiu[2]; | ||
88 | NPCM7xxEMCState emc[2]; | ||
89 | NPCM7xxSDHCIState mmc; | ||
90 | -} NPCM7xxState; | ||
91 | +}; | ||
92 | |||
93 | #define TYPE_NPCM7XX "npcm7xx" | ||
94 | -#define NPCM7XX(obj) OBJECT_CHECK(NPCM7xxState, (obj), TYPE_NPCM7XX) | ||
95 | +OBJECT_DECLARE_TYPE(NPCM7xxState, NPCM7xxClass, NPCM7XX) | ||
96 | |||
97 | #define TYPE_NPCM730 "npcm730" | ||
98 | #define TYPE_NPCM750 "npcm750" | ||
99 | @@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxClass { | ||
100 | uint32_t num_cpus; | ||
101 | } NPCM7xxClass; | ||
102 | |||
103 | -#define NPCM7XX_CLASS(klass) \ | ||
104 | - OBJECT_CLASS_CHECK(NPCM7xxClass, (klass), TYPE_NPCM7XX) | ||
105 | -#define NPCM7XX_GET_CLASS(obj) \ | ||
106 | - OBJECT_GET_CLASS(NPCM7xxClass, (obj), TYPE_NPCM7XX) | ||
107 | - | ||
108 | /** | ||
109 | * npcm7xx_load_kernel - Loads memory with everything needed to boot | ||
110 | * @machine - The machine containing the SoC to be booted. | ||
111 | diff --git a/include/hw/i2c/npcm7xx_smbus.h b/include/hw/i2c/npcm7xx_smbus.h | ||
112 | index XXXXXXX..XXXXXXX 100644 | ||
113 | --- a/include/hw/i2c/npcm7xx_smbus.h | ||
114 | +++ b/include/hw/i2c/npcm7xx_smbus.h | ||
115 | @@ -XXX,XX +XXX,XX @@ typedef enum NPCM7xxSMBusStatus { | ||
116 | * @rx_cur: The current position of rx_fifo. | ||
117 | * @status: The current status of the SMBus. | ||
118 | */ | ||
119 | -typedef struct NPCM7xxSMBusState { | ||
120 | +struct NPCM7xxSMBusState { | ||
121 | SysBusDevice parent; | ||
122 | |||
123 | MemoryRegion iomem; | ||
124 | @@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxSMBusState { | ||
125 | uint8_t rx_cur; | ||
126 | |||
127 | NPCM7xxSMBusStatus status; | ||
128 | -} NPCM7xxSMBusState; | ||
129 | +}; | ||
130 | |||
131 | #define TYPE_NPCM7XX_SMBUS "npcm7xx-smbus" | ||
132 | -#define NPCM7XX_SMBUS(obj) OBJECT_CHECK(NPCM7xxSMBusState, (obj), \ | ||
133 | - TYPE_NPCM7XX_SMBUS) | ||
134 | +OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxSMBusState, NPCM7XX_SMBUS) | ||
135 | |||
136 | #endif /* NPCM7XX_SMBUS_H */ | ||
137 | diff --git a/include/hw/misc/npcm7xx_clk.h b/include/hw/misc/npcm7xx_clk.h | ||
138 | index XXXXXXX..XXXXXXX 100644 | ||
139 | --- a/include/hw/misc/npcm7xx_clk.h | ||
140 | +++ b/include/hw/misc/npcm7xx_clk.h | ||
141 | @@ -XXX,XX +XXX,XX @@ struct NPCM7xxCLKState { | ||
142 | }; | ||
143 | |||
144 | #define TYPE_NPCM7XX_CLK "npcm7xx-clk" | ||
145 | -#define NPCM7XX_CLK(obj) OBJECT_CHECK(NPCM7xxCLKState, (obj), TYPE_NPCM7XX_CLK) | ||
146 | +OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxCLKState, NPCM7XX_CLK) | ||
147 | |||
148 | #endif /* NPCM7XX_CLK_H */ | ||
149 | diff --git a/include/hw/misc/npcm7xx_gcr.h b/include/hw/misc/npcm7xx_gcr.h | ||
150 | index XXXXXXX..XXXXXXX 100644 | ||
151 | --- a/include/hw/misc/npcm7xx_gcr.h | ||
152 | +++ b/include/hw/misc/npcm7xx_gcr.h | ||
153 | @@ -XXX,XX +XXX,XX @@ | ||
154 | */ | ||
155 | #define NPCM7XX_GCR_NR_REGS (0x148 / sizeof(uint32_t)) | ||
156 | |||
157 | -typedef struct NPCM7xxGCRState { | ||
158 | +struct NPCM7xxGCRState { | ||
159 | SysBusDevice parent; | ||
160 | |||
161 | MemoryRegion iomem; | ||
162 | @@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxGCRState { | ||
163 | uint32_t reset_pwron; | ||
164 | uint32_t reset_mdlr; | ||
165 | uint32_t reset_intcr3; | ||
166 | -} NPCM7xxGCRState; | ||
167 | +}; | ||
168 | |||
169 | #define TYPE_NPCM7XX_GCR "npcm7xx-gcr" | ||
170 | -#define NPCM7XX_GCR(obj) OBJECT_CHECK(NPCM7xxGCRState, (obj), TYPE_NPCM7XX_GCR) | ||
171 | +OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxGCRState, NPCM7XX_GCR) | ||
172 | |||
173 | #endif /* NPCM7XX_GCR_H */ | ||
174 | diff --git a/include/hw/misc/npcm7xx_mft.h b/include/hw/misc/npcm7xx_mft.h | ||
175 | index XXXXXXX..XXXXXXX 100644 | ||
176 | --- a/include/hw/misc/npcm7xx_mft.h | ||
177 | +++ b/include/hw/misc/npcm7xx_mft.h | ||
178 | @@ -XXX,XX +XXX,XX @@ | ||
179 | * @max_rpm: The maximum rpm for fans. Order: A0, B0, A1, B1. | ||
180 | * @duty: The duty cycles for fans, relative to NPCM7XX_PWM_MAX_DUTY. | ||
181 | */ | ||
182 | -typedef struct NPCM7xxMFTState { | ||
183 | +struct NPCM7xxMFTState { | ||
184 | SysBusDevice parent; | ||
185 | |||
186 | MemoryRegion iomem; | ||
187 | @@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxMFTState { | ||
188 | |||
189 | uint32_t max_rpm[NPCM7XX_MFT_FANIN_COUNT]; | ||
190 | uint32_t duty[NPCM7XX_MFT_FANIN_COUNT]; | ||
191 | -} NPCM7xxMFTState; | ||
192 | +}; | ||
193 | |||
194 | #define TYPE_NPCM7XX_MFT "npcm7xx-mft" | ||
195 | -#define NPCM7XX_MFT(obj) \ | ||
196 | - OBJECT_CHECK(NPCM7xxMFTState, (obj), TYPE_NPCM7XX_MFT) | ||
197 | +OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxMFTState, NPCM7XX_MFT) | ||
198 | |||
199 | #endif /* NPCM7XX_MFT_H */ | ||
200 | diff --git a/include/hw/misc/npcm7xx_pwm.h b/include/hw/misc/npcm7xx_pwm.h | ||
201 | index XXXXXXX..XXXXXXX 100644 | ||
202 | --- a/include/hw/misc/npcm7xx_pwm.h | ||
203 | +++ b/include/hw/misc/npcm7xx_pwm.h | ||
204 | @@ -XXX,XX +XXX,XX @@ struct NPCM7xxPWMState { | ||
205 | }; | ||
206 | |||
207 | #define TYPE_NPCM7XX_PWM "npcm7xx-pwm" | ||
208 | -#define NPCM7XX_PWM(obj) \ | ||
209 | - OBJECT_CHECK(NPCM7xxPWMState, (obj), TYPE_NPCM7XX_PWM) | ||
210 | +OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxPWMState, NPCM7XX_PWM) | ||
211 | |||
212 | #endif /* NPCM7XX_PWM_H */ | ||
213 | diff --git a/include/hw/misc/npcm7xx_rng.h b/include/hw/misc/npcm7xx_rng.h | ||
214 | index XXXXXXX..XXXXXXX 100644 | ||
215 | --- a/include/hw/misc/npcm7xx_rng.h | ||
216 | +++ b/include/hw/misc/npcm7xx_rng.h | ||
217 | @@ -XXX,XX +XXX,XX @@ | ||
19 | 218 | ||
20 | #include "hw/sysbus.h" | 219 | #include "hw/sysbus.h" |
21 | #include "hw/intc/armv7m_nvic.h" | 220 | |
22 | +#include "target/arm/idau.h" | 221 | -typedef struct NPCM7xxRNGState { |
23 | 222 | +struct NPCM7xxRNGState { | |
24 | #define TYPE_BITBAND "ARM,bitband-memory" | 223 | SysBusDevice parent; |
25 | #define BITBAND(obj) OBJECT_CHECK(BitBandState, (obj), TYPE_BITBAND) | 224 | |
26 | @@ -XXX,XX +XXX,XX @@ typedef struct { | 225 | MemoryRegion iomem; |
27 | * + Property "memory": MemoryRegion defining the physical address space | 226 | @@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxRNGState { |
28 | * that CPU accesses see. (The NVIC, bitbanding and other CPU-internal | 227 | uint8_t rngcs; |
29 | * devices will be automatically layered on top of this view.) | 228 | uint8_t rngd; |
30 | + * + Property "idau": IDAU interface (forwarded to CPU object) | 229 | uint8_t rngmode; |
31 | */ | 230 | -} NPCM7xxRNGState; |
32 | typedef struct ARMv7MState { | 231 | +}; |
33 | /*< private >*/ | 232 | |
34 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMv7MState { | 233 | #define TYPE_NPCM7XX_RNG "npcm7xx-rng" |
35 | char *cpu_type; | 234 | -#define NPCM7XX_RNG(obj) OBJECT_CHECK(NPCM7xxRNGState, (obj), TYPE_NPCM7XX_RNG) |
36 | /* MemoryRegion the board provides to us (with its devices, RAM, etc) */ | 235 | +OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxRNGState, NPCM7XX_RNG) |
37 | MemoryRegion *board_memory; | 236 | |
38 | + Object *idau; | 237 | #endif /* NPCM7XX_RNG_H */ |
39 | } ARMv7MState; | 238 | diff --git a/include/hw/net/npcm7xx_emc.h b/include/hw/net/npcm7xx_emc.h |
40 | 239 | index XXXXXXX..XXXXXXX 100644 | |
41 | #endif | 240 | --- a/include/hw/net/npcm7xx_emc.h |
42 | diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c | 241 | +++ b/include/hw/net/npcm7xx_emc.h |
43 | index XXXXXXX..XXXXXXX 100644 | 242 | @@ -XXX,XX +XXX,XX @@ struct NPCM7xxEMCState { |
44 | --- a/hw/arm/armv7m.c | 243 | bool rx_active; |
45 | +++ b/hw/arm/armv7m.c | ||
46 | @@ -XXX,XX +XXX,XX @@ | ||
47 | #include "sysemu/qtest.h" | ||
48 | #include "qemu/error-report.h" | ||
49 | #include "exec/address-spaces.h" | ||
50 | +#include "target/arm/idau.h" | ||
51 | |||
52 | /* Bitbanded IO. Each word corresponds to a single bit. */ | ||
53 | |||
54 | @@ -XXX,XX +XXX,XX @@ static void armv7m_realize(DeviceState *dev, Error **errp) | ||
55 | |||
56 | object_property_set_link(OBJECT(s->cpu), OBJECT(&s->container), "memory", | ||
57 | &error_abort); | ||
58 | + if (object_property_find(OBJECT(s->cpu), "idau", NULL)) { | ||
59 | + object_property_set_link(OBJECT(s->cpu), s->idau, "idau", &err); | ||
60 | + if (err != NULL) { | ||
61 | + error_propagate(errp, err); | ||
62 | + return; | ||
63 | + } | ||
64 | + } | ||
65 | object_property_set_bool(OBJECT(s->cpu), true, "realized", &err); | ||
66 | if (err != NULL) { | ||
67 | error_propagate(errp, err); | ||
68 | @@ -XXX,XX +XXX,XX @@ static Property armv7m_properties[] = { | ||
69 | DEFINE_PROP_STRING("cpu-type", ARMv7MState, cpu_type), | ||
70 | DEFINE_PROP_LINK("memory", ARMv7MState, board_memory, TYPE_MEMORY_REGION, | ||
71 | MemoryRegion *), | ||
72 | + DEFINE_PROP_LINK("idau", ARMv7MState, idau, TYPE_IDAU_INTERFACE, Object *), | ||
73 | DEFINE_PROP_END_OF_LIST(), | ||
74 | }; | 244 | }; |
75 | 245 | ||
246 | -typedef struct NPCM7xxEMCState NPCM7xxEMCState; | ||
247 | - | ||
248 | #define TYPE_NPCM7XX_EMC "npcm7xx-emc" | ||
249 | -#define NPCM7XX_EMC(obj) \ | ||
250 | - OBJECT_CHECK(NPCM7xxEMCState, (obj), TYPE_NPCM7XX_EMC) | ||
251 | +OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxEMCState, NPCM7XX_EMC) | ||
252 | |||
253 | #endif /* NPCM7XX_EMC_H */ | ||
254 | diff --git a/include/hw/sd/npcm7xx_sdhci.h b/include/hw/sd/npcm7xx_sdhci.h | ||
255 | index XXXXXXX..XXXXXXX 100644 | ||
256 | --- a/include/hw/sd/npcm7xx_sdhci.h | ||
257 | +++ b/include/hw/sd/npcm7xx_sdhci.h | ||
258 | @@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxRegs { | ||
259 | uint32_t boottoctrl; | ||
260 | } NPCM7xxRegisters; | ||
261 | |||
262 | -typedef struct NPCM7xxSDHCIState { | ||
263 | +struct NPCM7xxSDHCIState { | ||
264 | SysBusDevice parent; | ||
265 | |||
266 | MemoryRegion container; | ||
267 | @@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxSDHCIState { | ||
268 | NPCM7xxRegisters regs; | ||
269 | |||
270 | SDHCIState sdhci; | ||
271 | -} NPCM7xxSDHCIState; | ||
272 | +}; | ||
273 | |||
274 | #endif /* NPCM7XX_SDHCI_H */ | ||
76 | -- | 275 | -- |
77 | 2.16.2 | 276 | 2.34.1 |
78 | 277 | ||
79 | 278 | diff view generated by jsdifflib |
1 | From: Alistair Francis <alistair.francis@xilinx.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Alistair Francis <alistair.francis@xilinx.com> | 3 | The structure is named SECUREECState. Rename the type accordingly. |
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | |
5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20230109140306.23161-12-philmd@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 9 | --- |
8 | include/hw/arm/xlnx-zynqmp.h | 2 ++ | 10 | hw/misc/sbsa_ec.c | 13 +++++++------ |
9 | hw/arm/xlnx-zynqmp.c | 14 ++++++++++++++ | 11 | 1 file changed, 7 insertions(+), 6 deletions(-) |
10 | 2 files changed, 16 insertions(+) | ||
11 | 12 | ||
12 | diff --git a/include/hw/arm/xlnx-zynqmp.h b/include/hw/arm/xlnx-zynqmp.h | 13 | diff --git a/hw/misc/sbsa_ec.c b/hw/misc/sbsa_ec.c |
13 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/include/hw/arm/xlnx-zynqmp.h | 15 | --- a/hw/misc/sbsa_ec.c |
15 | +++ b/include/hw/arm/xlnx-zynqmp.h | 16 | +++ b/hw/misc/sbsa_ec.c |
16 | @@ -XXX,XX +XXX,XX @@ | 17 | @@ -XXX,XX +XXX,XX @@ |
17 | #include "hw/dma/xlnx_dpdma.h" | 18 | #include "hw/sysbus.h" |
18 | #include "hw/display/xlnx_dp.h" | 19 | #include "sysemu/runstate.h" |
19 | #include "hw/intc/xlnx-zynqmp-ipi.h" | 20 | |
20 | +#include "hw/timer/xlnx-zynqmp-rtc.h" | 21 | -typedef struct { |
21 | 22 | +typedef struct SECUREECState { | |
22 | #define TYPE_XLNX_ZYNQMP "xlnx,zynqmp" | 23 | SysBusDevice parent_obj; |
23 | #define XLNX_ZYNQMP(obj) OBJECT_CHECK(XlnxZynqMPState, (obj), \ | 24 | MemoryRegion iomem; |
24 | @@ -XXX,XX +XXX,XX @@ typedef struct XlnxZynqMPState { | 25 | } SECUREECState; |
25 | XlnxDPState dp; | 26 | |
26 | XlnxDPDMAState dpdma; | 27 | -#define TYPE_SBSA_EC "sbsa-ec" |
27 | XlnxZynqMPIPI ipi; | 28 | -#define SECURE_EC(obj) OBJECT_CHECK(SECUREECState, (obj), TYPE_SBSA_EC) |
28 | + XlnxZynqMPRTC rtc; | 29 | +#define TYPE_SBSA_SECURE_EC "sbsa-ec" |
29 | 30 | +#define SBSA_SECURE_EC(obj) \ | |
30 | char *boot_cpu; | 31 | + OBJECT_CHECK(SECUREECState, (obj), TYPE_SBSA_SECURE_EC) |
31 | ARMCPU *boot_cpu_ptr; | 32 | |
32 | diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c | 33 | enum sbsa_ec_powerstates { |
33 | index XXXXXXX..XXXXXXX 100644 | 34 | SBSA_EC_CMD_POWEROFF = 0x01, |
34 | --- a/hw/arm/xlnx-zynqmp.c | 35 | @@ -XXX,XX +XXX,XX @@ static uint64_t sbsa_ec_read(void *opaque, hwaddr offset, unsigned size) |
35 | +++ b/hw/arm/xlnx-zynqmp.c | ||
36 | @@ -XXX,XX +XXX,XX @@ | ||
37 | #define IPI_ADDR 0xFF300000 | ||
38 | #define IPI_IRQ 64 | ||
39 | |||
40 | +#define RTC_ADDR 0xffa60000 | ||
41 | +#define RTC_IRQ 26 | ||
42 | + | ||
43 | #define SDHCI_CAPABILITIES 0x280737ec6481 /* Datasheet: UG1085 (v1.7) */ | ||
44 | |||
45 | static const uint64_t gem_addr[XLNX_ZYNQMP_NUM_GEMS] = { | ||
46 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_init(Object *obj) | ||
47 | |||
48 | object_initialize(&s->ipi, sizeof(s->ipi), TYPE_XLNX_ZYNQMP_IPI); | ||
49 | qdev_set_parent_bus(DEVICE(&s->ipi), sysbus_get_default()); | ||
50 | + | ||
51 | + object_initialize(&s->rtc, sizeof(s->rtc), TYPE_XLNX_ZYNQMP_RTC); | ||
52 | + qdev_set_parent_bus(DEVICE(&s->rtc), sysbus_get_default()); | ||
53 | } | 36 | } |
54 | 37 | ||
55 | static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) | 38 | static void sbsa_ec_write(void *opaque, hwaddr offset, |
56 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) | 39 | - uint64_t value, unsigned size) |
57 | } | 40 | + uint64_t value, unsigned size) |
58 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->ipi), 0, IPI_ADDR); | 41 | { |
59 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->ipi), 0, gic_spi[IPI_IRQ]); | 42 | if (offset == 0) { /* PSCI machine power command register */ |
60 | + | 43 | switch (value) { |
61 | + object_property_set_bool(OBJECT(&s->rtc), true, "realized", &err); | 44 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps sbsa_ec_ops = { |
62 | + if (err) { | 45 | |
63 | + error_propagate(errp, err); | 46 | static void sbsa_ec_init(Object *obj) |
64 | + return; | 47 | { |
65 | + } | 48 | - SECUREECState *s = SECURE_EC(obj); |
66 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->rtc), 0, RTC_ADDR); | 49 | + SECUREECState *s = SBSA_SECURE_EC(obj); |
67 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->rtc), 0, gic_spi[RTC_IRQ]); | 50 | SysBusDevice *dev = SYS_BUS_DEVICE(obj); |
51 | |||
52 | memory_region_init_io(&s->iomem, obj, &sbsa_ec_ops, s, "sbsa-ec", | ||
53 | @@ -XXX,XX +XXX,XX @@ static void sbsa_ec_class_init(ObjectClass *klass, void *data) | ||
68 | } | 54 | } |
69 | 55 | ||
70 | static Property xlnx_zynqmp_props[] = { | 56 | static const TypeInfo sbsa_ec_info = { |
57 | - .name = TYPE_SBSA_EC, | ||
58 | + .name = TYPE_SBSA_SECURE_EC, | ||
59 | .parent = TYPE_SYS_BUS_DEVICE, | ||
60 | .instance_size = sizeof(SECUREECState), | ||
61 | .instance_init = sbsa_ec_init, | ||
71 | -- | 62 | -- |
72 | 2.16.2 | 63 | 2.34.1 |
73 | 64 | ||
74 | 65 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The Cortex-M33 allows the system to specify the reset value of the | ||
2 | secure Vector Table Offset Register (VTOR) by asserting config | ||
3 | signals. In particular, guest images for the MPS2 AN505 board rely | ||
4 | on the MPS2's initial VTOR being correct for that board. | ||
5 | Implement a QEMU property so board and SoC code can set the reset | ||
6 | value to the correct value. | ||
7 | 1 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20180220180325.29818-7-peter.maydell@linaro.org | ||
11 | --- | ||
12 | target/arm/cpu.h | 3 +++ | ||
13 | target/arm/cpu.c | 18 ++++++++++++++---- | ||
14 | 2 files changed, 17 insertions(+), 4 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/cpu.h | ||
19 | +++ b/target/arm/cpu.h | ||
20 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | ||
21 | */ | ||
22 | uint32_t psci_conduit; | ||
23 | |||
24 | + /* For v8M, initial value of the Secure VTOR */ | ||
25 | + uint32_t init_svtor; | ||
26 | + | ||
27 | /* [QEMU_]KVM_ARM_TARGET_* constant for this CPU, or | ||
28 | * QEMU_KVM_ARM_TARGET_NONE if the kernel doesn't support this CPU type. | ||
29 | */ | ||
30 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/cpu.c | ||
33 | +++ b/target/arm/cpu.c | ||
34 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(CPUState *s) | ||
35 | uint32_t initial_msp; /* Loaded from 0x0 */ | ||
36 | uint32_t initial_pc; /* Loaded from 0x4 */ | ||
37 | uint8_t *rom; | ||
38 | + uint32_t vecbase; | ||
39 | |||
40 | if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
41 | env->v7m.secure = true; | ||
42 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(CPUState *s) | ||
43 | /* Unlike A/R profile, M profile defines the reset LR value */ | ||
44 | env->regs[14] = 0xffffffff; | ||
45 | |||
46 | - /* Load the initial SP and PC from the vector table at address 0 */ | ||
47 | - rom = rom_ptr(0); | ||
48 | + env->v7m.vecbase[M_REG_S] = cpu->init_svtor & 0xffffff80; | ||
49 | + | ||
50 | + /* Load the initial SP and PC from offset 0 and 4 in the vector table */ | ||
51 | + vecbase = env->v7m.vecbase[env->v7m.secure]; | ||
52 | + rom = rom_ptr(vecbase); | ||
53 | if (rom) { | ||
54 | /* Address zero is covered by ROM which hasn't yet been | ||
55 | * copied into physical memory. | ||
56 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(CPUState *s) | ||
57 | * it got copied into memory. In the latter case, rom_ptr | ||
58 | * will return a NULL pointer and we should use ldl_phys instead. | ||
59 | */ | ||
60 | - initial_msp = ldl_phys(s->as, 0); | ||
61 | - initial_pc = ldl_phys(s->as, 4); | ||
62 | + initial_msp = ldl_phys(s->as, vecbase); | ||
63 | + initial_pc = ldl_phys(s->as, vecbase + 4); | ||
64 | } | ||
65 | |||
66 | env->regs[13] = initial_msp & 0xFFFFFFFC; | ||
67 | @@ -XXX,XX +XXX,XX @@ static Property arm_cpu_pmsav7_dregion_property = | ||
68 | pmsav7_dregion, | ||
69 | qdev_prop_uint32, uint32_t); | ||
70 | |||
71 | +/* M profile: initial value of the Secure VTOR */ | ||
72 | +static Property arm_cpu_initsvtor_property = | ||
73 | + DEFINE_PROP_UINT32("init-svtor", ARMCPU, init_svtor, 0); | ||
74 | + | ||
75 | static void arm_cpu_post_init(Object *obj) | ||
76 | { | ||
77 | ARMCPU *cpu = ARM_CPU(obj); | ||
78 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_post_init(Object *obj) | ||
79 | qdev_prop_allow_set_link_before_realize, | ||
80 | OBJ_PROP_LINK_UNREF_ON_RELEASE, | ||
81 | &error_abort); | ||
82 | + qdev_property_add_static(DEVICE(obj), &arm_cpu_initsvtor_property, | ||
83 | + &error_abort); | ||
84 | } | ||
85 | |||
86 | qdev_property_add_static(DEVICE(obj), &arm_cpu_cfgend_property, | ||
87 | -- | ||
88 | 2.16.2 | ||
89 | |||
90 | diff view generated by jsdifflib |
1 | Move the definition of the struct for the unimplemented-device | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | from unimp.c to unimp.h, so that users can embed the struct | ||
3 | in their own device structs if they prefer. | ||
4 | 2 | ||
3 | This model was merged few days before the QOM cleanup from | ||
4 | commit 8063396bf3 ("Use OBJECT_DECLARE_SIMPLE_TYPE when possible") | ||
5 | was pulled and merged. Manually adapt. | ||
6 | |||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20230109140306.23161-13-philmd@linaro.org | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20180220180325.29818-10-peter.maydell@linaro.org | ||
9 | --- | 11 | --- |
10 | include/hw/misc/unimp.h | 10 ++++++++++ | 12 | hw/misc/sbsa_ec.c | 3 +-- |
11 | hw/misc/unimp.c | 10 ---------- | 13 | 1 file changed, 1 insertion(+), 2 deletions(-) |
12 | 2 files changed, 10 insertions(+), 10 deletions(-) | ||
13 | 14 | ||
14 | diff --git a/include/hw/misc/unimp.h b/include/hw/misc/unimp.h | 15 | diff --git a/hw/misc/sbsa_ec.c b/hw/misc/sbsa_ec.c |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/include/hw/misc/unimp.h | 17 | --- a/hw/misc/sbsa_ec.c |
17 | +++ b/include/hw/misc/unimp.h | 18 | +++ b/hw/misc/sbsa_ec.c |
18 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ typedef struct SECUREECState { |
19 | 20 | } SECUREECState; | |
20 | #define TYPE_UNIMPLEMENTED_DEVICE "unimplemented-device" | 21 | |
21 | 22 | #define TYPE_SBSA_SECURE_EC "sbsa-ec" | |
22 | +#define UNIMPLEMENTED_DEVICE(obj) \ | 23 | -#define SBSA_SECURE_EC(obj) \ |
23 | + OBJECT_CHECK(UnimplementedDeviceState, (obj), TYPE_UNIMPLEMENTED_DEVICE) | 24 | - OBJECT_CHECK(SECUREECState, (obj), TYPE_SBSA_SECURE_EC) |
24 | + | 25 | +OBJECT_DECLARE_SIMPLE_TYPE(SECUREECState, SBSA_SECURE_EC) |
25 | +typedef struct { | 26 | |
26 | + SysBusDevice parent_obj; | 27 | enum sbsa_ec_powerstates { |
27 | + MemoryRegion iomem; | 28 | SBSA_EC_CMD_POWEROFF = 0x01, |
28 | + char *name; | ||
29 | + uint64_t size; | ||
30 | +} UnimplementedDeviceState; | ||
31 | + | ||
32 | /** | ||
33 | * create_unimplemented_device: create and map a dummy device | ||
34 | * @name: name of the device for debug logging | ||
35 | diff --git a/hw/misc/unimp.c b/hw/misc/unimp.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/hw/misc/unimp.c | ||
38 | +++ b/hw/misc/unimp.c | ||
39 | @@ -XXX,XX +XXX,XX @@ | ||
40 | #include "qemu/log.h" | ||
41 | #include "qapi/error.h" | ||
42 | |||
43 | -#define UNIMPLEMENTED_DEVICE(obj) \ | ||
44 | - OBJECT_CHECK(UnimplementedDeviceState, (obj), TYPE_UNIMPLEMENTED_DEVICE) | ||
45 | - | ||
46 | -typedef struct { | ||
47 | - SysBusDevice parent_obj; | ||
48 | - MemoryRegion iomem; | ||
49 | - char *name; | ||
50 | - uint64_t size; | ||
51 | -} UnimplementedDeviceState; | ||
52 | - | ||
53 | static uint64_t unimp_read(void *opaque, hwaddr offset, unsigned size) | ||
54 | { | ||
55 | UnimplementedDeviceState *s = UNIMPLEMENTED_DEVICE(opaque); | ||
56 | -- | 29 | -- |
57 | 2.16.2 | 30 | 2.34.1 |
58 | 31 | ||
59 | 32 | diff view generated by jsdifflib |
1 | The IoTKit Security Controller includes various registers | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | that expose to software the controls for the Peripheral | ||
3 | Protection Controllers in the system. Implement these. | ||
4 | 2 | ||
3 | This remove a use of 'struct' in the DECLARE_INSTANCE_CHECKER() | ||
4 | macro call, to avoid after a QOM refactor: | ||
5 | |||
6 | hw/intc/xilinx_intc.c:45:1: error: declaration of anonymous struct must be a definition | ||
7 | DECLARE_INSTANCE_CHECKER(struct xlx_pic, XILINX_INTC, | ||
8 | ^ | ||
9 | |||
10 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Reviewed-by: Edgar E. Iglesias <edgar@zeroasic.com> | ||
13 | Message-id: 20230109140306.23161-14-philmd@linaro.org | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20180220180325.29818-17-peter.maydell@linaro.org | ||
8 | --- | 15 | --- |
9 | include/hw/misc/iotkit-secctl.h | 64 +++++++++- | 16 | hw/intc/xilinx_intc.c | 28 +++++++++++++--------------- |
10 | hw/misc/iotkit-secctl.c | 270 +++++++++++++++++++++++++++++++++++++--- | 17 | 1 file changed, 13 insertions(+), 15 deletions(-) |
11 | 2 files changed, 315 insertions(+), 19 deletions(-) | ||
12 | 18 | ||
13 | diff --git a/include/hw/misc/iotkit-secctl.h b/include/hw/misc/iotkit-secctl.h | 19 | diff --git a/hw/intc/xilinx_intc.c b/hw/intc/xilinx_intc.c |
14 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/include/hw/misc/iotkit-secctl.h | 21 | --- a/hw/intc/xilinx_intc.c |
16 | +++ b/include/hw/misc/iotkit-secctl.h | 22 | +++ b/hw/intc/xilinx_intc.c |
17 | @@ -XXX,XX +XXX,XX @@ | 23 | @@ -XXX,XX +XXX,XX @@ |
18 | * QEMU interface: | 24 | #define R_MAX 8 |
19 | * + sysbus MMIO region 0 is the "secure privilege control block" registers | 25 | |
20 | * + sysbus MMIO region 1 is the "non-secure privilege control block" registers | 26 | #define TYPE_XILINX_INTC "xlnx.xps-intc" |
21 | + * + named GPIO output "sec_resp_cfg" indicating whether blocked accesses | 27 | -DECLARE_INSTANCE_CHECKER(struct xlx_pic, XILINX_INTC, |
22 | + * should RAZ/WI or bus error | 28 | - TYPE_XILINX_INTC) |
23 | + * Controlling the 2 APB PPCs in the IoTKit: | 29 | +typedef struct XpsIntc XpsIntc; |
24 | + * + named GPIO outputs apb_ppc0_nonsec[0..2] and apb_ppc1_nonsec | 30 | +DECLARE_INSTANCE_CHECKER(XpsIntc, XILINX_INTC, TYPE_XILINX_INTC) |
25 | + * + named GPIO outputs apb_ppc0_ap[0..2] and apb_ppc1_ap | 31 | |
26 | + * + named GPIO outputs apb_ppc{0,1}_irq_enable | 32 | -struct xlx_pic |
27 | + * + named GPIO outputs apb_ppc{0,1}_irq_clear | 33 | +struct XpsIntc |
28 | + * + named GPIO inputs apb_ppc{0,1}_irq_status | 34 | { |
29 | + * Controlling each of the 4 expansion APB PPCs which a system using the IoTKit | ||
30 | + * might provide: | ||
31 | + * + named GPIO outputs apb_ppcexp{0,1,2,3}_nonsec[0..15] | ||
32 | + * + named GPIO outputs apb_ppcexp{0,1,2,3}_ap[0..15] | ||
33 | + * + named GPIO outputs apb_ppcexp{0,1,2,3}_irq_enable | ||
34 | + * + named GPIO outputs apb_ppcexp{0,1,2,3}_irq_clear | ||
35 | + * + named GPIO inputs apb_ppcexp{0,1,2,3}_irq_status | ||
36 | + * Controlling each of the 4 expansion AHB PPCs which a system using the IoTKit | ||
37 | + * might provide: | ||
38 | + * + named GPIO outputs ahb_ppcexp{0,1,2,3}_nonsec[0..15] | ||
39 | + * + named GPIO outputs ahb_ppcexp{0,1,2,3}_ap[0..15] | ||
40 | + * + named GPIO outputs ahb_ppcexp{0,1,2,3}_irq_enable | ||
41 | + * + named GPIO outputs ahb_ppcexp{0,1,2,3}_irq_clear | ||
42 | + * + named GPIO inputs ahb_ppcexp{0,1,2,3}_irq_status | ||
43 | */ | ||
44 | |||
45 | #ifndef IOTKIT_SECCTL_H | ||
46 | @@ -XXX,XX +XXX,XX @@ | ||
47 | #define TYPE_IOTKIT_SECCTL "iotkit-secctl" | ||
48 | #define IOTKIT_SECCTL(obj) OBJECT_CHECK(IoTKitSecCtl, (obj), TYPE_IOTKIT_SECCTL) | ||
49 | |||
50 | -typedef struct IoTKitSecCtl { | ||
51 | +#define IOTS_APB_PPC0_NUM_PORTS 3 | ||
52 | +#define IOTS_APB_PPC1_NUM_PORTS 1 | ||
53 | +#define IOTS_PPC_NUM_PORTS 16 | ||
54 | +#define IOTS_NUM_APB_PPC 2 | ||
55 | +#define IOTS_NUM_APB_EXP_PPC 4 | ||
56 | +#define IOTS_NUM_AHB_EXP_PPC 4 | ||
57 | + | ||
58 | +typedef struct IoTKitSecCtl IoTKitSecCtl; | ||
59 | + | ||
60 | +/* State and IRQ lines relating to a PPC. For the | ||
61 | + * PPCs in the IoTKit not all the IRQ lines are used. | ||
62 | + */ | ||
63 | +typedef struct IoTKitSecCtlPPC { | ||
64 | + qemu_irq nonsec[IOTS_PPC_NUM_PORTS]; | ||
65 | + qemu_irq ap[IOTS_PPC_NUM_PORTS]; | ||
66 | + qemu_irq irq_enable; | ||
67 | + qemu_irq irq_clear; | ||
68 | + | ||
69 | + uint32_t ns; | ||
70 | + uint32_t sp; | ||
71 | + uint32_t nsp; | ||
72 | + | ||
73 | + /* Number of ports actually present */ | ||
74 | + int numports; | ||
75 | + /* Offset of this PPC's interrupt bits in SECPPCINTSTAT */ | ||
76 | + int irq_bit_offset; | ||
77 | + IoTKitSecCtl *parent; | ||
78 | +} IoTKitSecCtlPPC; | ||
79 | + | ||
80 | +struct IoTKitSecCtl { | ||
81 | /*< private >*/ | ||
82 | SysBusDevice parent_obj; | 35 | SysBusDevice parent_obj; |
83 | 36 | ||
84 | /*< public >*/ | 37 | @@ -XXX,XX +XXX,XX @@ struct xlx_pic |
85 | + qemu_irq sec_resp_cfg; | 38 | uint32_t irq_pin_state; |
86 | |||
87 | MemoryRegion s_regs; | ||
88 | MemoryRegion ns_regs; | ||
89 | -} IoTKitSecCtl; | ||
90 | + | ||
91 | + uint32_t secppcintstat; | ||
92 | + uint32_t secppcinten; | ||
93 | + uint32_t secrespcfg; | ||
94 | + | ||
95 | + IoTKitSecCtlPPC apb[IOTS_NUM_APB_PPC]; | ||
96 | + IoTKitSecCtlPPC apbexp[IOTS_NUM_APB_EXP_PPC]; | ||
97 | + IoTKitSecCtlPPC ahbexp[IOTS_NUM_APB_EXP_PPC]; | ||
98 | +}; | ||
99 | |||
100 | #endif | ||
101 | diff --git a/hw/misc/iotkit-secctl.c b/hw/misc/iotkit-secctl.c | ||
102 | index XXXXXXX..XXXXXXX 100644 | ||
103 | --- a/hw/misc/iotkit-secctl.c | ||
104 | +++ b/hw/misc/iotkit-secctl.c | ||
105 | @@ -XXX,XX +XXX,XX @@ static const uint8_t iotkit_secctl_ns_idregs[] = { | ||
106 | 0x0d, 0xf0, 0x05, 0xb1, | ||
107 | }; | 39 | }; |
108 | 40 | ||
109 | +/* The register sets for the various PPCs (AHB internal, APB internal, | 41 | -static void update_irq(struct xlx_pic *p) |
110 | + * AHB expansion, APB expansion) are all set up so that they are | 42 | +static void update_irq(XpsIntc *p) |
111 | + * in 16-aligned blocks so offsets 0xN0, 0xN4, 0xN8, 0xNC are PPCs | ||
112 | + * 0, 1, 2, 3 of that type, so we can convert a register address offset | ||
113 | + * into an an index into a PPC array easily. | ||
114 | + */ | ||
115 | +static inline int offset_to_ppc_idx(uint32_t offset) | ||
116 | +{ | ||
117 | + return extract32(offset, 2, 2); | ||
118 | +} | ||
119 | + | ||
120 | +typedef void PerPPCFunction(IoTKitSecCtlPPC *ppc); | ||
121 | + | ||
122 | +static void foreach_ppc(IoTKitSecCtl *s, PerPPCFunction *fn) | ||
123 | +{ | ||
124 | + int i; | ||
125 | + | ||
126 | + for (i = 0; i < IOTS_NUM_APB_PPC; i++) { | ||
127 | + fn(&s->apb[i]); | ||
128 | + } | ||
129 | + for (i = 0; i < IOTS_NUM_APB_EXP_PPC; i++) { | ||
130 | + fn(&s->apbexp[i]); | ||
131 | + } | ||
132 | + for (i = 0; i < IOTS_NUM_AHB_EXP_PPC; i++) { | ||
133 | + fn(&s->ahbexp[i]); | ||
134 | + } | ||
135 | +} | ||
136 | + | ||
137 | static MemTxResult iotkit_secctl_s_read(void *opaque, hwaddr addr, | ||
138 | uint64_t *pdata, | ||
139 | unsigned size, MemTxAttrs attrs) | ||
140 | { | 43 | { |
141 | uint64_t r; | 44 | uint32_t i; |
142 | uint32_t offset = addr & ~0x3; | 45 | |
143 | + IoTKitSecCtl *s = IOTKIT_SECCTL(opaque); | 46 | @@ -XXX,XX +XXX,XX @@ static void update_irq(struct xlx_pic *p) |
144 | 47 | qemu_set_irq(p->parent_irq, (p->regs[R_MER] & 1) && p->regs[R_IPR]); | |
145 | switch (offset) { | ||
146 | case A_AHBNSPPC0: | ||
147 | @@ -XXX,XX +XXX,XX @@ static MemTxResult iotkit_secctl_s_read(void *opaque, hwaddr addr, | ||
148 | r = 0; | ||
149 | break; | ||
150 | case A_SECRESPCFG: | ||
151 | - case A_NSCCFG: | ||
152 | - case A_SECMPCINTSTATUS: | ||
153 | + r = s->secrespcfg; | ||
154 | + break; | ||
155 | case A_SECPPCINTSTAT: | ||
156 | + r = s->secppcintstat; | ||
157 | + break; | ||
158 | case A_SECPPCINTEN: | ||
159 | - case A_SECMSCINTSTAT: | ||
160 | - case A_SECMSCINTEN: | ||
161 | - case A_BRGINTSTAT: | ||
162 | - case A_BRGINTEN: | ||
163 | + r = s->secppcinten; | ||
164 | + break; | ||
165 | case A_AHBNSPPCEXP0: | ||
166 | case A_AHBNSPPCEXP1: | ||
167 | case A_AHBNSPPCEXP2: | ||
168 | case A_AHBNSPPCEXP3: | ||
169 | + r = s->ahbexp[offset_to_ppc_idx(offset)].ns; | ||
170 | + break; | ||
171 | case A_APBNSPPC0: | ||
172 | case A_APBNSPPC1: | ||
173 | + r = s->apb[offset_to_ppc_idx(offset)].ns; | ||
174 | + break; | ||
175 | case A_APBNSPPCEXP0: | ||
176 | case A_APBNSPPCEXP1: | ||
177 | case A_APBNSPPCEXP2: | ||
178 | case A_APBNSPPCEXP3: | ||
179 | + r = s->apbexp[offset_to_ppc_idx(offset)].ns; | ||
180 | + break; | ||
181 | case A_AHBSPPPCEXP0: | ||
182 | case A_AHBSPPPCEXP1: | ||
183 | case A_AHBSPPPCEXP2: | ||
184 | case A_AHBSPPPCEXP3: | ||
185 | + r = s->apbexp[offset_to_ppc_idx(offset)].sp; | ||
186 | + break; | ||
187 | case A_APBSPPPC0: | ||
188 | case A_APBSPPPC1: | ||
189 | + r = s->apb[offset_to_ppc_idx(offset)].sp; | ||
190 | + break; | ||
191 | case A_APBSPPPCEXP0: | ||
192 | case A_APBSPPPCEXP1: | ||
193 | case A_APBSPPPCEXP2: | ||
194 | case A_APBSPPPCEXP3: | ||
195 | + r = s->apbexp[offset_to_ppc_idx(offset)].sp; | ||
196 | + break; | ||
197 | + case A_NSCCFG: | ||
198 | + case A_SECMPCINTSTATUS: | ||
199 | + case A_SECMSCINTSTAT: | ||
200 | + case A_SECMSCINTEN: | ||
201 | + case A_BRGINTSTAT: | ||
202 | + case A_BRGINTEN: | ||
203 | case A_NSMSCEXP: | ||
204 | qemu_log_mask(LOG_UNIMP, | ||
205 | "IoTKit SecCtl S block read: " | ||
206 | @@ -XXX,XX +XXX,XX @@ static MemTxResult iotkit_secctl_s_read(void *opaque, hwaddr addr, | ||
207 | return MEMTX_OK; | ||
208 | } | 48 | } |
209 | 49 | ||
210 | +static void iotkit_secctl_update_ppc_ap(IoTKitSecCtlPPC *ppc) | 50 | -static uint64_t |
211 | +{ | 51 | -pic_read(void *opaque, hwaddr addr, unsigned int size) |
212 | + int i; | 52 | +static uint64_t pic_read(void *opaque, hwaddr addr, unsigned int size) |
213 | + | ||
214 | + for (i = 0; i < ppc->numports; i++) { | ||
215 | + bool v; | ||
216 | + | ||
217 | + if (extract32(ppc->ns, i, 1)) { | ||
218 | + v = extract32(ppc->nsp, i, 1); | ||
219 | + } else { | ||
220 | + v = extract32(ppc->sp, i, 1); | ||
221 | + } | ||
222 | + qemu_set_irq(ppc->ap[i], v); | ||
223 | + } | ||
224 | +} | ||
225 | + | ||
226 | +static void iotkit_secctl_ppc_ns_write(IoTKitSecCtlPPC *ppc, uint32_t value) | ||
227 | +{ | ||
228 | + int i; | ||
229 | + | ||
230 | + ppc->ns = value & MAKE_64BIT_MASK(0, ppc->numports); | ||
231 | + for (i = 0; i < ppc->numports; i++) { | ||
232 | + qemu_set_irq(ppc->nonsec[i], extract32(ppc->ns, i, 1)); | ||
233 | + } | ||
234 | + iotkit_secctl_update_ppc_ap(ppc); | ||
235 | +} | ||
236 | + | ||
237 | +static void iotkit_secctl_ppc_sp_write(IoTKitSecCtlPPC *ppc, uint32_t value) | ||
238 | +{ | ||
239 | + ppc->sp = value & MAKE_64BIT_MASK(0, ppc->numports); | ||
240 | + iotkit_secctl_update_ppc_ap(ppc); | ||
241 | +} | ||
242 | + | ||
243 | +static void iotkit_secctl_ppc_nsp_write(IoTKitSecCtlPPC *ppc, uint32_t value) | ||
244 | +{ | ||
245 | + ppc->nsp = value & MAKE_64BIT_MASK(0, ppc->numports); | ||
246 | + iotkit_secctl_update_ppc_ap(ppc); | ||
247 | +} | ||
248 | + | ||
249 | +static void iotkit_secctl_ppc_update_irq_clear(IoTKitSecCtlPPC *ppc) | ||
250 | +{ | ||
251 | + uint32_t value = ppc->parent->secppcintstat; | ||
252 | + | ||
253 | + qemu_set_irq(ppc->irq_clear, extract32(value, ppc->irq_bit_offset, 1)); | ||
254 | +} | ||
255 | + | ||
256 | +static void iotkit_secctl_ppc_update_irq_enable(IoTKitSecCtlPPC *ppc) | ||
257 | +{ | ||
258 | + uint32_t value = ppc->parent->secppcinten; | ||
259 | + | ||
260 | + qemu_set_irq(ppc->irq_enable, extract32(value, ppc->irq_bit_offset, 1)); | ||
261 | +} | ||
262 | + | ||
263 | static MemTxResult iotkit_secctl_s_write(void *opaque, hwaddr addr, | ||
264 | uint64_t value, | ||
265 | unsigned size, MemTxAttrs attrs) | ||
266 | { | 53 | { |
267 | + IoTKitSecCtl *s = IOTKIT_SECCTL(opaque); | 54 | - struct xlx_pic *p = opaque; |
268 | uint32_t offset = addr; | 55 | + XpsIntc *p = opaque; |
269 | + IoTKitSecCtlPPC *ppc; | 56 | uint32_t r = 0; |
270 | 57 | ||
271 | trace_iotkit_secctl_s_write(offset, value, size); | 58 | addr >>= 2; |
272 | 59 | @@ -XXX,XX +XXX,XX @@ pic_read(void *opaque, hwaddr addr, unsigned int size) | |
273 | @@ -XXX,XX +XXX,XX @@ static MemTxResult iotkit_secctl_s_write(void *opaque, hwaddr addr, | 60 | return r; |
274 | 61 | } | |
275 | switch (offset) { | 62 | |
276 | case A_SECRESPCFG: | 63 | -static void |
277 | - case A_NSCCFG: | 64 | -pic_write(void *opaque, hwaddr addr, |
278 | + value &= 1; | 65 | - uint64_t val64, unsigned int size) |
279 | + s->secrespcfg = value; | 66 | +static void pic_write(void *opaque, hwaddr addr, |
280 | + qemu_set_irq(s->sec_resp_cfg, s->secrespcfg); | 67 | + uint64_t val64, unsigned int size) |
281 | + break; | ||
282 | case A_SECPPCINTCLR: | ||
283 | + value &= 0x00f000f3; | ||
284 | + foreach_ppc(s, iotkit_secctl_ppc_update_irq_clear); | ||
285 | + break; | ||
286 | case A_SECPPCINTEN: | ||
287 | - case A_SECMSCINTCLR: | ||
288 | - case A_SECMSCINTEN: | ||
289 | - case A_BRGINTCLR: | ||
290 | - case A_BRGINTEN: | ||
291 | + s->secppcinten = value & 0x00f000f3; | ||
292 | + foreach_ppc(s, iotkit_secctl_ppc_update_irq_enable); | ||
293 | + break; | ||
294 | case A_AHBNSPPCEXP0: | ||
295 | case A_AHBNSPPCEXP1: | ||
296 | case A_AHBNSPPCEXP2: | ||
297 | case A_AHBNSPPCEXP3: | ||
298 | + ppc = &s->ahbexp[offset_to_ppc_idx(offset)]; | ||
299 | + iotkit_secctl_ppc_ns_write(ppc, value); | ||
300 | + break; | ||
301 | case A_APBNSPPC0: | ||
302 | case A_APBNSPPC1: | ||
303 | + ppc = &s->apb[offset_to_ppc_idx(offset)]; | ||
304 | + iotkit_secctl_ppc_ns_write(ppc, value); | ||
305 | + break; | ||
306 | case A_APBNSPPCEXP0: | ||
307 | case A_APBNSPPCEXP1: | ||
308 | case A_APBNSPPCEXP2: | ||
309 | case A_APBNSPPCEXP3: | ||
310 | + ppc = &s->apbexp[offset_to_ppc_idx(offset)]; | ||
311 | + iotkit_secctl_ppc_ns_write(ppc, value); | ||
312 | + break; | ||
313 | case A_AHBSPPPCEXP0: | ||
314 | case A_AHBSPPPCEXP1: | ||
315 | case A_AHBSPPPCEXP2: | ||
316 | case A_AHBSPPPCEXP3: | ||
317 | + ppc = &s->ahbexp[offset_to_ppc_idx(offset)]; | ||
318 | + iotkit_secctl_ppc_sp_write(ppc, value); | ||
319 | + break; | ||
320 | case A_APBSPPPC0: | ||
321 | case A_APBSPPPC1: | ||
322 | + ppc = &s->apb[offset_to_ppc_idx(offset)]; | ||
323 | + iotkit_secctl_ppc_sp_write(ppc, value); | ||
324 | + break; | ||
325 | case A_APBSPPPCEXP0: | ||
326 | case A_APBSPPPCEXP1: | ||
327 | case A_APBSPPPCEXP2: | ||
328 | case A_APBSPPPCEXP3: | ||
329 | + ppc = &s->apbexp[offset_to_ppc_idx(offset)]; | ||
330 | + iotkit_secctl_ppc_sp_write(ppc, value); | ||
331 | + break; | ||
332 | + case A_NSCCFG: | ||
333 | + case A_SECMSCINTCLR: | ||
334 | + case A_SECMSCINTEN: | ||
335 | + case A_BRGINTCLR: | ||
336 | + case A_BRGINTEN: | ||
337 | qemu_log_mask(LOG_UNIMP, | ||
338 | "IoTKit SecCtl S block write: " | ||
339 | "unimplemented offset 0x%x\n", offset); | ||
340 | @@ -XXX,XX +XXX,XX @@ static MemTxResult iotkit_secctl_ns_read(void *opaque, hwaddr addr, | ||
341 | uint64_t *pdata, | ||
342 | unsigned size, MemTxAttrs attrs) | ||
343 | { | 68 | { |
344 | + IoTKitSecCtl *s = IOTKIT_SECCTL(opaque); | 69 | - struct xlx_pic *p = opaque; |
345 | uint64_t r; | 70 | + XpsIntc *p = opaque; |
346 | uint32_t offset = addr & ~0x3; | 71 | uint32_t value = val64; |
347 | 72 | ||
348 | @@ -XXX,XX +XXX,XX @@ static MemTxResult iotkit_secctl_ns_read(void *opaque, hwaddr addr, | 73 | addr >>= 2; |
349 | case A_AHBNSPPPCEXP1: | 74 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps pic_ops = { |
350 | case A_AHBNSPPPCEXP2: | 75 | |
351 | case A_AHBNSPPPCEXP3: | 76 | static void irq_handler(void *opaque, int irq, int level) |
352 | + r = s->ahbexp[offset_to_ppc_idx(offset)].nsp; | ||
353 | + break; | ||
354 | case A_APBNSPPPC0: | ||
355 | case A_APBNSPPPC1: | ||
356 | + r = s->apb[offset_to_ppc_idx(offset)].nsp; | ||
357 | + break; | ||
358 | case A_APBNSPPPCEXP0: | ||
359 | case A_APBNSPPPCEXP1: | ||
360 | case A_APBNSPPPCEXP2: | ||
361 | case A_APBNSPPPCEXP3: | ||
362 | - qemu_log_mask(LOG_UNIMP, | ||
363 | - "IoTKit SecCtl NS block read: " | ||
364 | - "unimplemented offset 0x%x\n", offset); | ||
365 | + r = s->apbexp[offset_to_ppc_idx(offset)].nsp; | ||
366 | break; | ||
367 | case A_PID4: | ||
368 | case A_PID5: | ||
369 | @@ -XXX,XX +XXX,XX @@ static MemTxResult iotkit_secctl_ns_write(void *opaque, hwaddr addr, | ||
370 | uint64_t value, | ||
371 | unsigned size, MemTxAttrs attrs) | ||
372 | { | 77 | { |
373 | + IoTKitSecCtl *s = IOTKIT_SECCTL(opaque); | 78 | - struct xlx_pic *p = opaque; |
374 | uint32_t offset = addr; | 79 | + XpsIntc *p = opaque; |
375 | + IoTKitSecCtlPPC *ppc; | 80 | |
376 | 81 | /* edge triggered interrupt */ | |
377 | trace_iotkit_secctl_ns_write(offset, value, size); | 82 | if (p->c_kind_of_intr & (1 << irq) && p->regs[R_MER] & 2) { |
378 | 83 | @@ -XXX,XX +XXX,XX @@ static void irq_handler(void *opaque, int irq, int level) | |
379 | @@ -XXX,XX +XXX,XX @@ static MemTxResult iotkit_secctl_ns_write(void *opaque, hwaddr addr, | 84 | |
380 | case A_AHBNSPPPCEXP1: | 85 | static void xilinx_intc_init(Object *obj) |
381 | case A_AHBNSPPPCEXP2: | 86 | { |
382 | case A_AHBNSPPPCEXP3: | 87 | - struct xlx_pic *p = XILINX_INTC(obj); |
383 | + ppc = &s->ahbexp[offset_to_ppc_idx(offset)]; | 88 | + XpsIntc *p = XILINX_INTC(obj); |
384 | + iotkit_secctl_ppc_nsp_write(ppc, value); | 89 | |
385 | + break; | 90 | qdev_init_gpio_in(DEVICE(obj), irq_handler, 32); |
386 | case A_APBNSPPPC0: | 91 | sysbus_init_irq(SYS_BUS_DEVICE(obj), &p->parent_irq); |
387 | case A_APBNSPPPC1: | 92 | @@ -XXX,XX +XXX,XX @@ static void xilinx_intc_init(Object *obj) |
388 | + ppc = &s->apb[offset_to_ppc_idx(offset)]; | 93 | } |
389 | + iotkit_secctl_ppc_nsp_write(ppc, value); | 94 | |
390 | + break; | 95 | static Property xilinx_intc_properties[] = { |
391 | case A_APBNSPPPCEXP0: | 96 | - DEFINE_PROP_UINT32("kind-of-intr", struct xlx_pic, c_kind_of_intr, 0), |
392 | case A_APBNSPPPCEXP1: | 97 | + DEFINE_PROP_UINT32("kind-of-intr", XpsIntc, c_kind_of_intr, 0), |
393 | case A_APBNSPPPCEXP2: | 98 | DEFINE_PROP_END_OF_LIST(), |
394 | case A_APBNSPPPCEXP3: | ||
395 | - qemu_log_mask(LOG_UNIMP, | ||
396 | - "IoTKit SecCtl NS block write: " | ||
397 | - "unimplemented offset 0x%x\n", offset); | ||
398 | + ppc = &s->apbexp[offset_to_ppc_idx(offset)]; | ||
399 | + iotkit_secctl_ppc_nsp_write(ppc, value); | ||
400 | break; | ||
401 | case A_AHBNSPPPC0: | ||
402 | case A_PID4: | ||
403 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps iotkit_secctl_ns_ops = { | ||
404 | .impl.max_access_size = 4, | ||
405 | }; | 99 | }; |
406 | 100 | ||
407 | +static void iotkit_secctl_reset_ppc(IoTKitSecCtlPPC *ppc) | 101 | @@ -XXX,XX +XXX,XX @@ static void xilinx_intc_class_init(ObjectClass *klass, void *data) |
408 | +{ | 102 | static const TypeInfo xilinx_intc_info = { |
409 | + ppc->ns = 0; | 103 | .name = TYPE_XILINX_INTC, |
410 | + ppc->sp = 0; | 104 | .parent = TYPE_SYS_BUS_DEVICE, |
411 | + ppc->nsp = 0; | 105 | - .instance_size = sizeof(struct xlx_pic), |
412 | +} | 106 | + .instance_size = sizeof(XpsIntc), |
413 | + | 107 | .instance_init = xilinx_intc_init, |
414 | static void iotkit_secctl_reset(DeviceState *dev) | 108 | .class_init = xilinx_intc_class_init, |
415 | { | ||
416 | + IoTKitSecCtl *s = IOTKIT_SECCTL(dev); | ||
417 | |||
418 | + s->secppcintstat = 0; | ||
419 | + s->secppcinten = 0; | ||
420 | + s->secrespcfg = 0; | ||
421 | + | ||
422 | + foreach_ppc(s, iotkit_secctl_reset_ppc); | ||
423 | +} | ||
424 | + | ||
425 | +static void iotkit_secctl_ppc_irqstatus(void *opaque, int n, int level) | ||
426 | +{ | ||
427 | + IoTKitSecCtlPPC *ppc = opaque; | ||
428 | + IoTKitSecCtl *s = IOTKIT_SECCTL(ppc->parent); | ||
429 | + int irqbit = ppc->irq_bit_offset + n; | ||
430 | + | ||
431 | + s->secppcintstat = deposit32(s->secppcintstat, irqbit, 1, level); | ||
432 | +} | ||
433 | + | ||
434 | +static void iotkit_secctl_init_ppc(IoTKitSecCtl *s, | ||
435 | + IoTKitSecCtlPPC *ppc, | ||
436 | + const char *name, | ||
437 | + int numports, | ||
438 | + int irq_bit_offset) | ||
439 | +{ | ||
440 | + char *gpioname; | ||
441 | + DeviceState *dev = DEVICE(s); | ||
442 | + | ||
443 | + ppc->numports = numports; | ||
444 | + ppc->irq_bit_offset = irq_bit_offset; | ||
445 | + ppc->parent = s; | ||
446 | + | ||
447 | + gpioname = g_strdup_printf("%s_nonsec", name); | ||
448 | + qdev_init_gpio_out_named(dev, ppc->nonsec, gpioname, numports); | ||
449 | + g_free(gpioname); | ||
450 | + gpioname = g_strdup_printf("%s_ap", name); | ||
451 | + qdev_init_gpio_out_named(dev, ppc->ap, gpioname, numports); | ||
452 | + g_free(gpioname); | ||
453 | + gpioname = g_strdup_printf("%s_irq_enable", name); | ||
454 | + qdev_init_gpio_out_named(dev, &ppc->irq_enable, gpioname, 1); | ||
455 | + g_free(gpioname); | ||
456 | + gpioname = g_strdup_printf("%s_irq_clear", name); | ||
457 | + qdev_init_gpio_out_named(dev, &ppc->irq_clear, gpioname, 1); | ||
458 | + g_free(gpioname); | ||
459 | + gpioname = g_strdup_printf("%s_irq_status", name); | ||
460 | + qdev_init_gpio_in_named_with_opaque(dev, iotkit_secctl_ppc_irqstatus, | ||
461 | + ppc, gpioname, 1); | ||
462 | + g_free(gpioname); | ||
463 | } | ||
464 | |||
465 | static void iotkit_secctl_init(Object *obj) | ||
466 | { | ||
467 | IoTKitSecCtl *s = IOTKIT_SECCTL(obj); | ||
468 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
469 | + DeviceState *dev = DEVICE(obj); | ||
470 | + int i; | ||
471 | + | ||
472 | + iotkit_secctl_init_ppc(s, &s->apb[0], "apb_ppc0", | ||
473 | + IOTS_APB_PPC0_NUM_PORTS, 0); | ||
474 | + iotkit_secctl_init_ppc(s, &s->apb[1], "apb_ppc1", | ||
475 | + IOTS_APB_PPC1_NUM_PORTS, 1); | ||
476 | + | ||
477 | + for (i = 0; i < IOTS_NUM_APB_EXP_PPC; i++) { | ||
478 | + IoTKitSecCtlPPC *ppc = &s->apbexp[i]; | ||
479 | + char *ppcname = g_strdup_printf("apb_ppcexp%d", i); | ||
480 | + iotkit_secctl_init_ppc(s, ppc, ppcname, IOTS_PPC_NUM_PORTS, 4 + i); | ||
481 | + g_free(ppcname); | ||
482 | + } | ||
483 | + for (i = 0; i < IOTS_NUM_AHB_EXP_PPC; i++) { | ||
484 | + IoTKitSecCtlPPC *ppc = &s->ahbexp[i]; | ||
485 | + char *ppcname = g_strdup_printf("ahb_ppcexp%d", i); | ||
486 | + iotkit_secctl_init_ppc(s, ppc, ppcname, IOTS_PPC_NUM_PORTS, 20 + i); | ||
487 | + g_free(ppcname); | ||
488 | + } | ||
489 | + | ||
490 | + qdev_init_gpio_out_named(dev, &s->sec_resp_cfg, "sec_resp_cfg", 1); | ||
491 | |||
492 | memory_region_init_io(&s->s_regs, obj, &iotkit_secctl_s_ops, | ||
493 | s, "iotkit-secctl-s-regs", 0x1000); | ||
494 | @@ -XXX,XX +XXX,XX @@ static void iotkit_secctl_init(Object *obj) | ||
495 | sysbus_init_mmio(sbd, &s->ns_regs); | ||
496 | } | ||
497 | |||
498 | +static const VMStateDescription iotkit_secctl_ppc_vmstate = { | ||
499 | + .name = "iotkit-secctl-ppc", | ||
500 | + .version_id = 1, | ||
501 | + .minimum_version_id = 1, | ||
502 | + .fields = (VMStateField[]) { | ||
503 | + VMSTATE_UINT32(ns, IoTKitSecCtlPPC), | ||
504 | + VMSTATE_UINT32(sp, IoTKitSecCtlPPC), | ||
505 | + VMSTATE_UINT32(nsp, IoTKitSecCtlPPC), | ||
506 | + VMSTATE_END_OF_LIST() | ||
507 | + } | ||
508 | +}; | ||
509 | + | ||
510 | static const VMStateDescription iotkit_secctl_vmstate = { | ||
511 | .name = "iotkit-secctl", | ||
512 | .version_id = 1, | ||
513 | .minimum_version_id = 1, | ||
514 | .fields = (VMStateField[]) { | ||
515 | + VMSTATE_UINT32(secppcintstat, IoTKitSecCtl), | ||
516 | + VMSTATE_UINT32(secppcinten, IoTKitSecCtl), | ||
517 | + VMSTATE_UINT32(secrespcfg, IoTKitSecCtl), | ||
518 | + VMSTATE_STRUCT_ARRAY(apb, IoTKitSecCtl, IOTS_NUM_APB_PPC, 1, | ||
519 | + iotkit_secctl_ppc_vmstate, IoTKitSecCtlPPC), | ||
520 | + VMSTATE_STRUCT_ARRAY(apbexp, IoTKitSecCtl, IOTS_NUM_APB_EXP_PPC, 1, | ||
521 | + iotkit_secctl_ppc_vmstate, IoTKitSecCtlPPC), | ||
522 | + VMSTATE_STRUCT_ARRAY(ahbexp, IoTKitSecCtl, IOTS_NUM_AHB_EXP_PPC, 1, | ||
523 | + iotkit_secctl_ppc_vmstate, IoTKitSecCtlPPC), | ||
524 | VMSTATE_END_OF_LIST() | ||
525 | } | ||
526 | }; | 109 | }; |
527 | -- | 110 | -- |
528 | 2.16.2 | 111 | 2.34.1 |
529 | 112 | ||
530 | 113 | diff view generated by jsdifflib |
1 | Create an "init-svtor" property on the armv7m container | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | object which we can forward to the CPU object. | ||
3 | 2 | ||
3 | This remove a use of 'struct' in the DECLARE_INSTANCE_CHECKER() | ||
4 | macro call, to avoid after a QOM refactor: | ||
5 | |||
6 | hw/timer/xilinx_timer.c:65:1: error: declaration of anonymous struct must be a definition | ||
7 | DECLARE_INSTANCE_CHECKER(struct timerblock, XILINX_TIMER, | ||
8 | ^ | ||
9 | |||
10 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Reviewed-by: Edgar E. Iglesias <edgar@zeroasic.com> | ||
13 | Message-id: 20230109140306.23161-15-philmd@linaro.org | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20180220180325.29818-8-peter.maydell@linaro.org | ||
7 | --- | 15 | --- |
8 | include/hw/arm/armv7m.h | 2 ++ | 16 | hw/timer/xilinx_timer.c | 27 +++++++++++++-------------- |
9 | hw/arm/armv7m.c | 9 +++++++++ | 17 | 1 file changed, 13 insertions(+), 14 deletions(-) |
10 | 2 files changed, 11 insertions(+) | ||
11 | 18 | ||
12 | diff --git a/include/hw/arm/armv7m.h b/include/hw/arm/armv7m.h | 19 | diff --git a/hw/timer/xilinx_timer.c b/hw/timer/xilinx_timer.c |
13 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/include/hw/arm/armv7m.h | 21 | --- a/hw/timer/xilinx_timer.c |
15 | +++ b/include/hw/arm/armv7m.h | 22 | +++ b/hw/timer/xilinx_timer.c |
16 | @@ -XXX,XX +XXX,XX @@ typedef struct { | 23 | @@ -XXX,XX +XXX,XX @@ struct xlx_timer |
17 | * that CPU accesses see. (The NVIC, bitbanding and other CPU-internal | 24 | }; |
18 | * devices will be automatically layered on top of this view.) | 25 | |
19 | * + Property "idau": IDAU interface (forwarded to CPU object) | 26 | #define TYPE_XILINX_TIMER "xlnx.xps-timer" |
20 | + * + Property "init-svtor": secure VTOR reset value (forwarded to CPU object) | 27 | -DECLARE_INSTANCE_CHECKER(struct timerblock, XILINX_TIMER, |
21 | */ | 28 | - TYPE_XILINX_TIMER) |
22 | typedef struct ARMv7MState { | 29 | +typedef struct XpsTimerState XpsTimerState; |
23 | /*< private >*/ | 30 | +DECLARE_INSTANCE_CHECKER(XpsTimerState, XILINX_TIMER, TYPE_XILINX_TIMER) |
24 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMv7MState { | 31 | |
25 | /* MemoryRegion the board provides to us (with its devices, RAM, etc) */ | 32 | -struct timerblock |
26 | MemoryRegion *board_memory; | 33 | +struct XpsTimerState |
27 | Object *idau; | 34 | { |
28 | + uint32_t init_svtor; | 35 | SysBusDevice parent_obj; |
29 | } ARMv7MState; | 36 | |
30 | 37 | @@ -XXX,XX +XXX,XX @@ struct timerblock | |
31 | #endif | 38 | struct xlx_timer *timers; |
32 | diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c | 39 | }; |
33 | index XXXXXXX..XXXXXXX 100644 | 40 | |
34 | --- a/hw/arm/armv7m.c | 41 | -static inline unsigned int num_timers(struct timerblock *t) |
35 | +++ b/hw/arm/armv7m.c | 42 | +static inline unsigned int num_timers(XpsTimerState *t) |
36 | @@ -XXX,XX +XXX,XX @@ static void armv7m_realize(DeviceState *dev, Error **errp) | 43 | { |
37 | return; | 44 | return 2 - t->one_timer_only; |
38 | } | 45 | } |
39 | } | 46 | @@ -XXX,XX +XXX,XX @@ static inline unsigned int timer_from_addr(hwaddr addr) |
40 | + if (object_property_find(OBJECT(s->cpu), "init-svtor", NULL)) { | 47 | return addr >> 2; |
41 | + object_property_set_uint(OBJECT(s->cpu), s->init_svtor, | 48 | } |
42 | + "init-svtor", &err); | 49 | |
43 | + if (err != NULL) { | 50 | -static void timer_update_irq(struct timerblock *t) |
44 | + error_propagate(errp, err); | 51 | +static void timer_update_irq(XpsTimerState *t) |
45 | + return; | 52 | { |
46 | + } | 53 | unsigned int i, irq = 0; |
47 | + } | 54 | uint32_t csr; |
48 | object_property_set_bool(OBJECT(s->cpu), true, "realized", &err); | 55 | @@ -XXX,XX +XXX,XX @@ static void timer_update_irq(struct timerblock *t) |
49 | if (err != NULL) { | 56 | static uint64_t |
50 | error_propagate(errp, err); | 57 | timer_read(void *opaque, hwaddr addr, unsigned int size) |
51 | @@ -XXX,XX +XXX,XX @@ static Property armv7m_properties[] = { | 58 | { |
52 | DEFINE_PROP_LINK("memory", ARMv7MState, board_memory, TYPE_MEMORY_REGION, | 59 | - struct timerblock *t = opaque; |
53 | MemoryRegion *), | 60 | + XpsTimerState *t = opaque; |
54 | DEFINE_PROP_LINK("idau", ARMv7MState, idau, TYPE_IDAU_INTERFACE, Object *), | 61 | struct xlx_timer *xt; |
55 | + DEFINE_PROP_UINT32("init-svtor", ARMv7MState, init_svtor, 0), | 62 | uint32_t r = 0; |
63 | unsigned int timer; | ||
64 | @@ -XXX,XX +XXX,XX @@ static void | ||
65 | timer_write(void *opaque, hwaddr addr, | ||
66 | uint64_t val64, unsigned int size) | ||
67 | { | ||
68 | - struct timerblock *t = opaque; | ||
69 | + XpsTimerState *t = opaque; | ||
70 | struct xlx_timer *xt; | ||
71 | unsigned int timer; | ||
72 | uint32_t value = val64; | ||
73 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps timer_ops = { | ||
74 | static void timer_hit(void *opaque) | ||
75 | { | ||
76 | struct xlx_timer *xt = opaque; | ||
77 | - struct timerblock *t = xt->parent; | ||
78 | + XpsTimerState *t = xt->parent; | ||
79 | D(fprintf(stderr, "%s %d\n", __func__, xt->nr)); | ||
80 | xt->regs[R_TCSR] |= TCSR_TINT; | ||
81 | |||
82 | @@ -XXX,XX +XXX,XX @@ static void timer_hit(void *opaque) | ||
83 | |||
84 | static void xilinx_timer_realize(DeviceState *dev, Error **errp) | ||
85 | { | ||
86 | - struct timerblock *t = XILINX_TIMER(dev); | ||
87 | + XpsTimerState *t = XILINX_TIMER(dev); | ||
88 | unsigned int i; | ||
89 | |||
90 | /* Init all the ptimers. */ | ||
91 | @@ -XXX,XX +XXX,XX @@ static void xilinx_timer_realize(DeviceState *dev, Error **errp) | ||
92 | |||
93 | static void xilinx_timer_init(Object *obj) | ||
94 | { | ||
95 | - struct timerblock *t = XILINX_TIMER(obj); | ||
96 | + XpsTimerState *t = XILINX_TIMER(obj); | ||
97 | |||
98 | /* All timers share a single irq line. */ | ||
99 | sysbus_init_irq(SYS_BUS_DEVICE(obj), &t->irq); | ||
100 | } | ||
101 | |||
102 | static Property xilinx_timer_properties[] = { | ||
103 | - DEFINE_PROP_UINT32("clock-frequency", struct timerblock, freq_hz, | ||
104 | - 62 * 1000000), | ||
105 | - DEFINE_PROP_UINT8("one-timer-only", struct timerblock, one_timer_only, 0), | ||
106 | + DEFINE_PROP_UINT32("clock-frequency", XpsTimerState, freq_hz, 62 * 1000000), | ||
107 | + DEFINE_PROP_UINT8("one-timer-only", XpsTimerState, one_timer_only, 0), | ||
56 | DEFINE_PROP_END_OF_LIST(), | 108 | DEFINE_PROP_END_OF_LIST(), |
57 | }; | 109 | }; |
58 | 110 | ||
111 | @@ -XXX,XX +XXX,XX @@ static void xilinx_timer_class_init(ObjectClass *klass, void *data) | ||
112 | static const TypeInfo xilinx_timer_info = { | ||
113 | .name = TYPE_XILINX_TIMER, | ||
114 | .parent = TYPE_SYS_BUS_DEVICE, | ||
115 | - .instance_size = sizeof(struct timerblock), | ||
116 | + .instance_size = sizeof(XpsTimerState), | ||
117 | .instance_init = xilinx_timer_init, | ||
118 | .class_init = xilinx_timer_class_init, | ||
119 | }; | ||
59 | -- | 120 | -- |
60 | 2.16.2 | 121 | 2.34.1 |
61 | 122 | ||
62 | 123 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Evgeny Iakovlev <eiakovlev@linux.microsoft.com> |
---|---|---|---|
2 | 2 | ||
3 | Happily, the bits are in the same places compared to a32. | 3 | ARM trusted firmware, when built with FEAT_HCX support, sets SCR_EL3.HXEn bit |
4 | to allow EL2 to modify HCRX_EL2 register without trapping it in EL3. Qemu | ||
5 | uses a valid mask to clear unsupported SCR_EL3 bits when emulating SCR_EL3 | ||
6 | write, and that mask doesn't include SCR_EL3.HXEn bit even if FEAT_HCX is | ||
7 | enabled and exposed to the guest. As a result EL3 writes of that bit are | ||
8 | ignored. | ||
4 | 9 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Cc: qemu-stable@nongnu.org |
6 | Message-id: 20180228193125.20577-16-richard.henderson@linaro.org | 11 | Signed-off-by: Evgeny Iakovlev <eiakovlev@linux.microsoft.com> |
12 | Message-id: 20230105221251.17896-4-eiakovlev@linux.microsoft.com | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 15 | --- |
10 | target/arm/translate.c | 14 +++++++++++++- | 16 | target/arm/helper.c | 3 +++ |
11 | 1 file changed, 13 insertions(+), 1 deletion(-) | 17 | 1 file changed, 3 insertions(+) |
12 | 18 | ||
13 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 19 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
14 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate.c | 21 | --- a/target/arm/helper.c |
16 | +++ b/target/arm/translate.c | 22 | +++ b/target/arm/helper.c |
17 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 23 | @@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) |
18 | default_exception_el(s)); | 24 | if (cpu_isar_feature(aa64_sme, cpu)) { |
19 | break; | 25 | valid_mask |= SCR_ENTP2; |
20 | } | 26 | } |
21 | - if (((insn >> 24) & 3) == 3) { | 27 | + if (cpu_isar_feature(aa64_hcx, cpu)) { |
22 | + if ((insn & 0xfe000a00) == 0xfc000800 | 28 | + valid_mask |= SCR_HXEN; |
23 | + && arm_dc_feature(s, ARM_FEATURE_V8)) { | 29 | + } |
24 | + /* The Thumb2 and ARM encodings are identical. */ | 30 | } else { |
25 | + if (disas_neon_insn_3same_ext(s, insn)) { | 31 | valid_mask &= ~(SCR_RW | SCR_ST); |
26 | + goto illegal_op; | 32 | if (cpu_isar_feature(aa32_ras, cpu)) { |
27 | + } | ||
28 | + } else if ((insn & 0xff000a00) == 0xfe000800 | ||
29 | + && arm_dc_feature(s, ARM_FEATURE_V8)) { | ||
30 | + /* The Thumb2 and ARM encodings are identical. */ | ||
31 | + if (disas_neon_insn_2reg_scalar_ext(s, insn)) { | ||
32 | + goto illegal_op; | ||
33 | + } | ||
34 | + } else if (((insn >> 24) & 3) == 3) { | ||
35 | /* Translate into the equivalent ARM encoding. */ | ||
36 | insn = (insn & 0xe2ffffff) | ((insn & (1 << 28)) >> 4) | (1 << 28); | ||
37 | if (disas_neon_data_insn(s, insn)) { | ||
38 | -- | 33 | -- |
39 | 2.16.2 | 34 | 2.34.1 |
40 | |||
41 | diff view generated by jsdifflib |