1 | Less than a day of post-3.0 code review and already enough | 1 | First pullreq for 6.0: mostly my v8.1M work, plus some other |
---|---|---|---|
2 | patches for another pullreq :-) | 2 | bits and pieces. (I still have a lot of stuff in my to-review |
3 | folder, which I may or may not get to before the Christmas break...) | ||
3 | 4 | ||
4 | thanks | 5 | thanks |
5 | -- PMM | 6 | -- PMM |
6 | 7 | ||
7 | The following changes since commit c542a9f9794ec8e0bc3fcf5956d3cc8bce667789: | 8 | The following changes since commit 5e7b204dbfae9a562fc73684986f936b97f63877: |
8 | 9 | ||
9 | Merge remote-tracking branch 'remotes/armbru/tags/pull-tests-2018-08-16' into staging (2018-08-16 09:50:54 +0100) | 10 | Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2020-12-09 20:08:54 +0000) |
10 | 11 | ||
11 | are available in the Git repository at: | 12 | are available in the Git repository at: |
12 | 13 | ||
13 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180816 | 14 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20201210 |
14 | 15 | ||
15 | for you to fetch changes up to fcf13ca556f462b52956059bf8fa622bc8575edb: | 16 | for you to fetch changes up to 71f916be1c7e9ede0e37d9cabc781b5a9e8638ff: |
16 | 17 | ||
17 | hw/arm/mps2-tz: Replace init_sysbus_child() with sysbus_init_child_obj() (2018-08-16 14:29:58 +0100) | 18 | hw/arm/armv7m: Correct typo in QOM object name (2020-12-10 11:44:56 +0000) |
18 | 19 | ||
19 | ---------------------------------------------------------------- | 20 | ---------------------------------------------------------------- |
20 | target-arm queue: | 21 | target-arm queue: |
21 | * Fixes for various bugs in SVE instructions | 22 | * hw/arm/smmuv3: Fix up L1STD_SPAN decoding |
22 | * Add model of Freescale i.MX6 UltraLite 14x14 EVK Board | 23 | * xlnx-zynqmp: Support Xilinx ZynqMP CAN controllers |
23 | * hw/arm: make bitbanded IO optional on ARMv7-M | 24 | * sbsa-ref: allow to use Cortex-A53/57/72 cpus |
24 | * Add model of Cortex-M0 CPU | 25 | * Various minor code cleanups |
25 | * Add support for loading Intel HEX files to the generic loader | 26 | * hw/intc/armv7m_nvic: Make all of system PPB range be RAZWI/BusFault |
26 | * imx_spi: Unset XCH when TX FIFO becomes empty | 27 | * Implement more pieces of ARMv8.1M support |
27 | * aspeed_sdmc: fix various bugs | ||
28 | * Fix bugs in Arm FP16 instruction support | ||
29 | * Fix aa64 FCADD and FCMLA decode | ||
30 | * softfloat: Fix missing inexact for floating-point add | ||
31 | * hw/arm/mps2-tz: Replace init_sysbus_child() with sysbus_init_child_obj() | ||
32 | 28 | ||
33 | ---------------------------------------------------------------- | 29 | ---------------------------------------------------------------- |
34 | Cédric Le Goater (1): | 30 | Alex Chen (4): |
35 | aspeed: add a max_ram_size property to the memory controller | 31 | i.MX25: Fix bad printf format specifiers |
32 | i.MX31: Fix bad printf format specifiers | ||
33 | i.MX6: Fix bad printf format specifiers | ||
34 | i.MX6ul: Fix bad printf format specifiers | ||
36 | 35 | ||
37 | Jean-Christophe Dubois (3): | 36 | Havard Skinnemoen (1): |
38 | i.MX6UL: Add i.MX6UL specific CCM device | 37 | tests/qtest/npcm7xx_rng-test: dump random data on failure |
39 | i.MX6UL: Add i.MX6UL SOC | ||
40 | i.MX6UL: Add Freescale i.MX6 UltraLite 14x14 EVK Board | ||
41 | 38 | ||
42 | Joel Stanley (5): | 39 | Kunkun Jiang (1): |
43 | aspeed_sdmc: Extend number of valid registers | 40 | hw/arm/smmuv3: Fix up L1STD_SPAN decoding |
44 | aspeed_sdmc: Fix saved values | ||
45 | aspeed_sdmc: Set 'cache initial sequence' always true | ||
46 | aspeed_sdmc: Init status always idle | ||
47 | aspeed_sdmc: Handle ECC training | ||
48 | 41 | ||
49 | Richard Henderson (13): | 42 | Marcin Juszkiewicz (1): |
50 | target/arm: Fix typo in helper_sve_ld1hss_r | 43 | sbsa-ref: allow to use Cortex-A53/57/72 cpus |
51 | target/arm: Fix sign-extension in sve do_ldr/do_str | ||
52 | target/arm: Fix offset for LD1R instructions | ||
53 | target/arm: Fix offset scaling for LD_zprr and ST_zprr | ||
54 | target/arm: Reformat integer register dump | ||
55 | target/arm: Dump SVE state if enabled | ||
56 | target/arm: Add sve-max-vq cpu property to -cpu max | ||
57 | target/arm: Adjust FPCR_MASK for FZ16 | ||
58 | target/arm: Ignore float_flag_input_denormal from fp_status_f16 | ||
59 | target/arm: Use fp_status_fp16 for do_fmpa_zpzzz_h | ||
60 | target/arm: Use FZ not FZ16 for SVE FCVT single-half and double-half | ||
61 | target/arm: Fix aa64 FCADD and FCMLA decode | ||
62 | softfloat: Fix missing inexact for floating-point add | ||
63 | 44 | ||
64 | Stefan Hajnoczi (4): | 45 | Peter Maydell (25): |
65 | hw/arm: make bitbanded IO optional on ARMv7-M | 46 | hw/intc/armv7m_nvic: Make all of system PPB range be RAZWI/BusFault |
66 | target/arm: add "cortex-m0" CPU model | 47 | target/arm: Implement v8.1M PXN extension |
67 | loader: extract rom_free() function | 48 | target/arm: Don't clobber ID_PFR1.Security on M-profile cores |
68 | loader: add rom transaction API | 49 | target/arm: Implement VSCCLRM insn |
50 | target/arm: Implement CLRM instruction | ||
51 | target/arm: Enforce M-profile VMRS/VMSR register restrictions | ||
52 | target/arm: Refactor M-profile VMSR/VMRS handling | ||
53 | target/arm: Move general-use constant expanders up in translate.c | ||
54 | target/arm: Implement VLDR/VSTR system register | ||
55 | target/arm: Implement M-profile FPSCR_nzcvqc | ||
56 | target/arm: Use new FPCR_NZCV_MASK constant | ||
57 | target/arm: Factor out preserve-fp-state from full_vfp_access_check() | ||
58 | target/arm: Implement FPCXT_S fp system register | ||
59 | hw/intc/armv7m_nvic: Update FPDSCR masking for v8.1M | ||
60 | target/arm: For v8.1M, always clear R0-R3, R12, APSR, EPSR on exception entry | ||
61 | target/arm: In v8.1M, don't set HFSR.FORCED on vector table fetch failures | ||
62 | target/arm: Implement v8.1M REVIDR register | ||
63 | target/arm: Implement new v8.1M NOCP check for exception return | ||
64 | target/arm: Implement new v8.1M VLLDM and VLSTM encodings | ||
65 | hw/intc/armv7m_nvic: Support v8.1M CCR.TRD bit | ||
66 | target/arm: Implement CCR_S.TRD behaviour for SG insns | ||
67 | hw/intc/armv7m_nvic: Fix "return from inactive handler" check | ||
68 | target/arm: Implement M-profile "minimal RAS implementation" | ||
69 | hw/intc/armv7m_nvic: Implement read/write for RAS register block | ||
70 | hw/arm/armv7m: Correct typo in QOM object name | ||
69 | 71 | ||
70 | Su Hang (2): | 72 | Vikram Garhwal (4): |
71 | loader: Implement .hex file loader | 73 | hw/net/can: Introduce Xilinx ZynqMP CAN controller |
72 | Add QTest testcase for the Intel Hexadecimal | 74 | xlnx-zynqmp: Connect Xilinx ZynqMP CAN controllers |
75 | tests/qtest: Introduce tests for Xilinx ZynqMP CAN controller | ||
76 | MAINTAINERS: Add maintainer entry for Xilinx ZynqMP CAN controller | ||
73 | 77 | ||
74 | Thomas Huth (1): | 78 | meson.build | 1 + |
75 | hw/arm/mps2-tz: Replace init_sysbus_child() with sysbus_init_child_obj() | 79 | hw/arm/smmuv3-internal.h | 2 +- |
80 | hw/net/can/trace.h | 1 + | ||
81 | include/hw/arm/xlnx-zynqmp.h | 8 + | ||
82 | include/hw/intc/armv7m_nvic.h | 2 + | ||
83 | include/hw/net/xlnx-zynqmp-can.h | 78 +++ | ||
84 | target/arm/cpu.h | 46 ++ | ||
85 | target/arm/m-nocp.decode | 10 +- | ||
86 | target/arm/t32.decode | 10 +- | ||
87 | target/arm/vfp.decode | 14 + | ||
88 | hw/arm/armv7m.c | 4 +- | ||
89 | hw/arm/sbsa-ref.c | 23 +- | ||
90 | hw/arm/xlnx-zcu102.c | 20 + | ||
91 | hw/arm/xlnx-zynqmp.c | 34 ++ | ||
92 | hw/intc/armv7m_nvic.c | 246 ++++++-- | ||
93 | hw/misc/imx25_ccm.c | 12 +- | ||
94 | hw/misc/imx31_ccm.c | 14 +- | ||
95 | hw/misc/imx6_ccm.c | 20 +- | ||
96 | hw/misc/imx6_src.c | 2 +- | ||
97 | hw/misc/imx6ul_ccm.c | 4 +- | ||
98 | hw/misc/imx_ccm.c | 4 +- | ||
99 | hw/net/can/xlnx-zynqmp-can.c | 1161 ++++++++++++++++++++++++++++++++++++++ | ||
100 | target/arm/cpu.c | 5 +- | ||
101 | target/arm/helper.c | 7 +- | ||
102 | target/arm/m_helper.c | 130 ++++- | ||
103 | target/arm/translate.c | 105 +++- | ||
104 | tests/qtest/npcm7xx_rng-test.c | 12 + | ||
105 | tests/qtest/xlnx-can-test.c | 360 ++++++++++++ | ||
106 | MAINTAINERS | 8 + | ||
107 | hw/Kconfig | 1 + | ||
108 | hw/net/can/meson.build | 1 + | ||
109 | hw/net/can/trace-events | 9 + | ||
110 | target/arm/translate-vfp.c.inc | 511 ++++++++++++++++- | ||
111 | tests/qtest/meson.build | 1 + | ||
112 | 34 files changed, 2713 insertions(+), 153 deletions(-) | ||
113 | create mode 100644 hw/net/can/trace.h | ||
114 | create mode 100644 include/hw/net/xlnx-zynqmp-can.h | ||
115 | create mode 100644 hw/net/can/xlnx-zynqmp-can.c | ||
116 | create mode 100644 tests/qtest/xlnx-can-test.c | ||
117 | create mode 100644 hw/net/can/trace-events | ||
76 | 118 | ||
77 | Trent Piepho (1): | ||
78 | imx_spi: Unset XCH when TX FIFO becomes empty | ||
79 | |||
80 | configure | 4 + | ||
81 | hw/arm/Makefile.objs | 1 + | ||
82 | hw/misc/Makefile.objs | 1 + | ||
83 | tests/Makefile.include | 2 + | ||
84 | include/hw/arm/armv7m.h | 2 + | ||
85 | include/hw/arm/fsl-imx6ul.h | 339 ++++++++++++++ | ||
86 | include/hw/loader.h | 31 ++ | ||
87 | include/hw/misc/aspeed_sdmc.h | 4 +- | ||
88 | include/hw/misc/imx6ul_ccm.h | 226 +++++++++ | ||
89 | target/arm/cpu.h | 5 +- | ||
90 | fpu/softfloat.c | 2 +- | ||
91 | hw/arm/armv7m.c | 37 +- | ||
92 | hw/arm/aspeed.c | 31 ++ | ||
93 | hw/arm/aspeed_soc.c | 2 + | ||
94 | hw/arm/fsl-imx6ul.c | 617 ++++++++++++++++++++++++ | ||
95 | hw/arm/mcimx6ul-evk.c | 85 ++++ | ||
96 | hw/arm/mps2-tz.c | 32 +- | ||
97 | hw/arm/mps2.c | 1 + | ||
98 | hw/arm/msf2-soc.c | 1 + | ||
99 | hw/arm/stellaris.c | 1 + | ||
100 | hw/arm/stm32f205_soc.c | 1 + | ||
101 | hw/core/generic-loader.c | 4 + | ||
102 | hw/core/loader.c | 302 +++++++++++- | ||
103 | hw/misc/aspeed_sdmc.c | 55 ++- | ||
104 | hw/misc/imx6ul_ccm.c | 886 +++++++++++++++++++++++++++++++++++ | ||
105 | hw/ssi/imx_spi.c | 3 +- | ||
106 | linux-user/syscall.c | 19 +- | ||
107 | target/arm/cpu.c | 17 +- | ||
108 | target/arm/cpu64.c | 29 ++ | ||
109 | target/arm/helper.c | 18 +- | ||
110 | target/arm/sve_helper.c | 4 +- | ||
111 | target/arm/translate-a64.c | 120 ++++- | ||
112 | target/arm/translate-sve.c | 30 +- | ||
113 | tests/hexloader-test.c | 45 ++ | ||
114 | MAINTAINERS | 6 + | ||
115 | default-configs/arm-softmmu.mak | 1 + | ||
116 | hw/misc/trace-events | 7 + | ||
117 | tests/hex-loader-check-data/test.hex | 18 + | ||
118 | 38 files changed, 2863 insertions(+), 126 deletions(-) | ||
119 | create mode 100644 include/hw/arm/fsl-imx6ul.h | ||
120 | create mode 100644 include/hw/misc/imx6ul_ccm.h | ||
121 | create mode 100644 hw/arm/fsl-imx6ul.c | ||
122 | create mode 100644 hw/arm/mcimx6ul-evk.c | ||
123 | create mode 100644 hw/misc/imx6ul_ccm.c | ||
124 | create mode 100644 tests/hexloader-test.c | ||
125 | create mode 100644 tests/hex-loader-check-data/test.hex | ||
126 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Kunkun Jiang <jiangkunkun@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | For 0x1.0000000000003p+0 + 0x1.ffffffep+14 = 0x1.0001fffp+15 | 3 | Accroding to the SMMUv3 spec, the SPAN field of Level1 Stream Table |
4 | we dropped the sticky bit and so failed to raise inexact. | 4 | Descriptor is 5 bits([4:0]). |
5 | 5 | ||
6 | Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com> | 6 | Fixes: 9bde7f0674f(hw/arm/smmuv3: Implement translate callback) |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com> |
8 | Reviewed-by: Laurent Desnogues <laurent.desnogues@gmail.com> | 8 | Message-id: 20201124023711.1184-1-jiangkunkun@huawei.com |
9 | Tested-by: Laurent Desnogues <laurent.desnogues@gmail.com> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Message-id: 20180810193129.1556-7-richard.henderson@linaro.org | 10 | Acked-by: Eric Auger <eric.auger@redhat.com> |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 12 | --- |
13 | fpu/softfloat.c | 2 +- | 13 | hw/arm/smmuv3-internal.h | 2 +- |
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | 14 | 1 file changed, 1 insertion(+), 1 deletion(-) |
15 | 15 | ||
16 | diff --git a/fpu/softfloat.c b/fpu/softfloat.c | 16 | diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h |
17 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/fpu/softfloat.c | 18 | --- a/hw/arm/smmuv3-internal.h |
19 | +++ b/fpu/softfloat.c | 19 | +++ b/hw/arm/smmuv3-internal.h |
20 | @@ -XXX,XX +XXX,XX @@ static FloatParts addsub_floats(FloatParts a, FloatParts b, bool subtract, | 20 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t l1std_l2ptr(STEDesc *desc) |
21 | } | 21 | return hi << 32 | lo; |
22 | a.frac += b.frac; | 22 | } |
23 | if (a.frac & DECOMPOSED_OVERFLOW_BIT) { | 23 | |
24 | - a.frac >>= 1; | 24 | -#define L1STD_SPAN(stm) (extract32((stm)->word[0], 0, 4)) |
25 | + shift64RightJamming(a.frac, 1, &a.frac); | 25 | +#define L1STD_SPAN(stm) (extract32((stm)->word[0], 0, 5)) |
26 | a.exp += 1; | 26 | |
27 | } | 27 | #endif |
28 | return a; | ||
29 | -- | 28 | -- |
30 | 2.18.0 | 29 | 2.20.1 |
31 | 30 | ||
32 | 31 | diff view generated by jsdifflib |
1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> | 1 | From: Vikram Garhwal <fnu.vikram@xilinx.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> | 3 | The Xilinx ZynqMP CAN controller is developed based on SocketCAN, QEMU CAN bus |
4 | Message-id: 34b6704ceb81b49e35ce1ad162bf758e5141ff87.1532984236.git.jcd@tribudubois.net | 4 | implementation. Bus connection and socketCAN connection for each CAN module |
5 | [PMM: fixed some comment typos etc] | 5 | can be set through command lines. |
6 | |||
7 | Example for using single CAN: | ||
8 | -object can-bus,id=canbus0 \ | ||
9 | -machine xlnx-zcu102.canbus0=canbus0 \ | ||
10 | -object can-host-socketcan,id=socketcan0,if=vcan0,canbus=canbus0 | ||
11 | |||
12 | Example for connecting both CAN to same virtual CAN on host machine: | ||
13 | -object can-bus,id=canbus0 -object can-bus,id=canbus1 \ | ||
14 | -machine xlnx-zcu102.canbus0=canbus0 \ | ||
15 | -machine xlnx-zcu102.canbus1=canbus1 \ | ||
16 | -object can-host-socketcan,id=socketcan0,if=vcan0,canbus=canbus0 \ | ||
17 | -object can-host-socketcan,id=socketcan1,if=vcan0,canbus=canbus1 | ||
18 | |||
19 | To create virtual CAN on the host machine, please check the QEMU CAN docs: | ||
20 | https://github.com/qemu/qemu/blob/master/docs/can.txt | ||
21 | |||
22 | Signed-off-by: Vikram Garhwal <fnu.vikram@xilinx.com> | ||
23 | Message-id: 1605728926-352690-2-git-send-email-fnu.vikram@xilinx.com | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 24 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 25 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 26 | --- |
9 | hw/misc/Makefile.objs | 1 + | 27 | meson.build | 1 + |
10 | include/hw/misc/imx6ul_ccm.h | 226 +++++++++ | 28 | hw/net/can/trace.h | 1 + |
11 | hw/misc/imx6ul_ccm.c | 886 +++++++++++++++++++++++++++++++++++ | 29 | include/hw/net/xlnx-zynqmp-can.h | 78 ++ |
12 | hw/misc/trace-events | 7 + | 30 | hw/net/can/xlnx-zynqmp-can.c | 1161 ++++++++++++++++++++++++++++++ |
13 | 4 files changed, 1120 insertions(+) | 31 | hw/Kconfig | 1 + |
14 | create mode 100644 include/hw/misc/imx6ul_ccm.h | 32 | hw/net/can/meson.build | 1 + |
15 | create mode 100644 hw/misc/imx6ul_ccm.c | 33 | hw/net/can/trace-events | 9 + |
34 | 7 files changed, 1252 insertions(+) | ||
35 | create mode 100644 hw/net/can/trace.h | ||
36 | create mode 100644 include/hw/net/xlnx-zynqmp-can.h | ||
37 | create mode 100644 hw/net/can/xlnx-zynqmp-can.c | ||
38 | create mode 100644 hw/net/can/trace-events | ||
16 | 39 | ||
17 | diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs | 40 | diff --git a/meson.build b/meson.build |
18 | index XXXXXXX..XXXXXXX 100644 | 41 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/misc/Makefile.objs | 42 | --- a/meson.build |
20 | +++ b/hw/misc/Makefile.objs | 43 | +++ b/meson.build |
21 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_IMX) += imx_ccm.o | 44 | @@ -XXX,XX +XXX,XX @@ if have_system |
22 | obj-$(CONFIG_IMX) += imx31_ccm.o | 45 | 'hw/misc', |
23 | obj-$(CONFIG_IMX) += imx25_ccm.o | 46 | 'hw/misc/macio', |
24 | obj-$(CONFIG_IMX) += imx6_ccm.o | 47 | 'hw/net', |
25 | +obj-$(CONFIG_IMX) += imx6ul_ccm.o | 48 | + 'hw/net/can', |
26 | obj-$(CONFIG_IMX) += imx6_src.o | 49 | 'hw/nvram', |
27 | obj-$(CONFIG_IMX) += imx7_ccm.o | 50 | 'hw/pci', |
28 | obj-$(CONFIG_IMX) += imx2_wdt.o | 51 | 'hw/pci-host', |
29 | diff --git a/include/hw/misc/imx6ul_ccm.h b/include/hw/misc/imx6ul_ccm.h | 52 | diff --git a/hw/net/can/trace.h b/hw/net/can/trace.h |
30 | new file mode 100644 | 53 | new file mode 100644 |
31 | index XXXXXXX..XXXXXXX | 54 | index XXXXXXX..XXXXXXX |
32 | --- /dev/null | 55 | --- /dev/null |
33 | +++ b/include/hw/misc/imx6ul_ccm.h | 56 | +++ b/hw/net/can/trace.h |
34 | @@ -XXX,XX +XXX,XX @@ | 57 | @@ -0,0 +1 @@ |
35 | +/* | 58 | +#include "trace/trace-hw_net_can.h" |
36 | + * IMX6UL Clock Control Module | 59 | diff --git a/include/hw/net/xlnx-zynqmp-can.h b/include/hw/net/xlnx-zynqmp-can.h |
37 | + * | ||
38 | + * Copyright (C) 2018 by Jean-Christophe Dubois <jcd@tribudubois.net> | ||
39 | + * | ||
40 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
41 | + * See the COPYING file in the top-level directory. | ||
42 | + */ | ||
43 | + | ||
44 | +#ifndef IMX6UL_CCM_H | ||
45 | +#define IMX6UL_CCM_H | ||
46 | + | ||
47 | +#include "hw/misc/imx_ccm.h" | ||
48 | +#include "qemu/bitops.h" | ||
49 | + | ||
50 | +#define CCM_CCR 0 | ||
51 | +#define CCM_CCDR 1 | ||
52 | +#define CCM_CSR 2 | ||
53 | +#define CCM_CCSR 3 | ||
54 | +#define CCM_CACRR 4 | ||
55 | +#define CCM_CBCDR 5 | ||
56 | +#define CCM_CBCMR 6 | ||
57 | +#define CCM_CSCMR1 7 | ||
58 | +#define CCM_CSCMR2 8 | ||
59 | +#define CCM_CSCDR1 9 | ||
60 | +#define CCM_CS1CDR 10 | ||
61 | +#define CCM_CS2CDR 11 | ||
62 | +#define CCM_CDCDR 12 | ||
63 | +#define CCM_CHSCCDR 13 | ||
64 | +#define CCM_CSCDR2 14 | ||
65 | +#define CCM_CSCDR3 15 | ||
66 | +#define CCM_CDHIPR 18 | ||
67 | +#define CCM_CTOR 20 | ||
68 | +#define CCM_CLPCR 21 | ||
69 | +#define CCM_CISR 22 | ||
70 | +#define CCM_CIMR 23 | ||
71 | +#define CCM_CCOSR 24 | ||
72 | +#define CCM_CGPR 25 | ||
73 | +#define CCM_CCGR0 26 | ||
74 | +#define CCM_CCGR1 27 | ||
75 | +#define CCM_CCGR2 28 | ||
76 | +#define CCM_CCGR3 29 | ||
77 | +#define CCM_CCGR4 30 | ||
78 | +#define CCM_CCGR5 31 | ||
79 | +#define CCM_CCGR6 32 | ||
80 | +#define CCM_CMEOR 34 | ||
81 | +#define CCM_MAX 35 | ||
82 | + | ||
83 | +#define CCM_ANALOG_PLL_ARM 0 | ||
84 | +#define CCM_ANALOG_PLL_ARM_SET 1 | ||
85 | +#define CCM_ANALOG_PLL_ARM_CLR 2 | ||
86 | +#define CCM_ANALOG_PLL_ARM_TOG 3 | ||
87 | +#define CCM_ANALOG_PLL_USB1 4 | ||
88 | +#define CCM_ANALOG_PLL_USB1_SET 5 | ||
89 | +#define CCM_ANALOG_PLL_USB1_CLR 6 | ||
90 | +#define CCM_ANALOG_PLL_USB1_TOG 7 | ||
91 | +#define CCM_ANALOG_PLL_USB2 8 | ||
92 | +#define CCM_ANALOG_PLL_USB2_SET 9 | ||
93 | +#define CCM_ANALOG_PLL_USB2_CLR 10 | ||
94 | +#define CCM_ANALOG_PLL_USB2_TOG 11 | ||
95 | +#define CCM_ANALOG_PLL_SYS 12 | ||
96 | +#define CCM_ANALOG_PLL_SYS_SET 13 | ||
97 | +#define CCM_ANALOG_PLL_SYS_CLR 14 | ||
98 | +#define CCM_ANALOG_PLL_SYS_TOG 15 | ||
99 | +#define CCM_ANALOG_PLL_SYS_SS 16 | ||
100 | +#define CCM_ANALOG_PLL_SYS_NUM 20 | ||
101 | +#define CCM_ANALOG_PLL_SYS_DENOM 24 | ||
102 | +#define CCM_ANALOG_PLL_AUDIO 28 | ||
103 | +#define CCM_ANALOG_PLL_AUDIO_SET 29 | ||
104 | +#define CCM_ANALOG_PLL_AUDIO_CLR 30 | ||
105 | +#define CCM_ANALOG_PLL_AUDIO_TOG 31 | ||
106 | +#define CCM_ANALOG_PLL_AUDIO_NUM 32 | ||
107 | +#define CCM_ANALOG_PLL_AUDIO_DENOM 36 | ||
108 | +#define CCM_ANALOG_PLL_VIDEO 40 | ||
109 | +#define CCM_ANALOG_PLL_VIDEO_SET 41 | ||
110 | +#define CCM_ANALOG_PLL_VIDEO_CLR 42 | ||
111 | +#define CCM_ANALOG_PLL_VIDEO_TOG 44 | ||
112 | +#define CCM_ANALOG_PLL_VIDEO_NUM 46 | ||
113 | +#define CCM_ANALOG_PLL_VIDEO_DENOM 48 | ||
114 | +#define CCM_ANALOG_PLL_ENET 56 | ||
115 | +#define CCM_ANALOG_PLL_ENET_SET 57 | ||
116 | +#define CCM_ANALOG_PLL_ENET_CLR 58 | ||
117 | +#define CCM_ANALOG_PLL_ENET_TOG 59 | ||
118 | +#define CCM_ANALOG_PFD_480 60 | ||
119 | +#define CCM_ANALOG_PFD_480_SET 61 | ||
120 | +#define CCM_ANALOG_PFD_480_CLR 62 | ||
121 | +#define CCM_ANALOG_PFD_480_TOG 63 | ||
122 | +#define CCM_ANALOG_PFD_528 64 | ||
123 | +#define CCM_ANALOG_PFD_528_SET 65 | ||
124 | +#define CCM_ANALOG_PFD_528_CLR 66 | ||
125 | +#define CCM_ANALOG_PFD_528_TOG 67 | ||
126 | + | ||
127 | +/* PMU registers */ | ||
128 | +#define PMU_REG_1P1 68 | ||
129 | +#define PMU_REG_3P0 72 | ||
130 | +#define PMU_REG_2P5 76 | ||
131 | +#define PMU_REG_CORE 80 | ||
132 | + | ||
133 | +#define CCM_ANALOG_MISC0 84 | ||
134 | +#define PMU_MISC0 CCM_ANALOG_MISC0 | ||
135 | +#define CCM_ANALOG_MISC0_SET 85 | ||
136 | +#define PMU_MISC0_SET CCM_ANALOG_MISC0_SET | ||
137 | +#define CCM_ANALOG_MISC0_CLR 86 | ||
138 | +#define PMU_MISC0_CLR CCM_ANALOG_MISC0_CLR | ||
139 | +#define CCM_ANALOG_MISC0_TOG 87 | ||
140 | +#define PMU_MISC0_TOG CCM_ANALOG_MISC0_TOG | ||
141 | + | ||
142 | +#define CCM_ANALOG_MISC1 88 | ||
143 | +#define PMU_MISC1 CCM_ANALOG_MISC1 | ||
144 | +#define CCM_ANALOG_MISC1_SET 89 | ||
145 | +#define PMU_MISC1_SET CCM_ANALOG_MISC1_SET | ||
146 | +#define CCM_ANALOG_MISC1_CLR 90 | ||
147 | +#define PMU_MISC1_CLR CCM_ANALOG_MISC1_CLR | ||
148 | +#define CCM_ANALOG_MISC1_TOG 91 | ||
149 | +#define PMU_MISC1_TOG CCM_ANALOG_MISC1_TOG | ||
150 | + | ||
151 | +#define CCM_ANALOG_MISC2 92 | ||
152 | +#define PMU_MISC2 CCM_ANALOG_MISC2 | ||
153 | +#define CCM_ANALOG_MISC2_SET 93 | ||
154 | +#define PMU_MISC2_SET CCM_ANALOG_MISC2_SET | ||
155 | +#define CCM_ANALOG_MISC2_CLR 94 | ||
156 | +#define PMU_MISC2_CLR CCM_ANALOG_MISC2_CLR | ||
157 | +#define CCM_ANALOG_MISC2_TOG 95 | ||
158 | +#define PMU_MISC2_TOG CCM_ANALOG_MISC2_TOG | ||
159 | + | ||
160 | +#define TEMPMON_TEMPSENSE0 96 | ||
161 | +#define TEMPMON_TEMPSENSE0_SET 97 | ||
162 | +#define TEMPMON_TEMPSENSE0_CLR 98 | ||
163 | +#define TEMPMON_TEMPSENSE0_TOG 99 | ||
164 | +#define TEMPMON_TEMPSENSE1 100 | ||
165 | +#define TEMPMON_TEMPSENSE1_SET 101 | ||
166 | +#define TEMPMON_TEMPSENSE1_CLR 102 | ||
167 | +#define TEMPMON_TEMPSENSE1_TOG 103 | ||
168 | +#define TEMPMON_TEMPSENSE2 164 | ||
169 | +#define TEMPMON_TEMPSENSE2_SET 165 | ||
170 | +#define TEMPMON_TEMPSENSE2_CLR 166 | ||
171 | +#define TEMPMON_TEMPSENSE2_TOG 167 | ||
172 | + | ||
173 | +#define PMU_LOWPWR_CTRL 155 | ||
174 | +#define PMU_LOWPWR_CTRL_SET 156 | ||
175 | +#define PMU_LOWPWR_CTRL_CLR 157 | ||
176 | +#define PMU_LOWPWR_CTRL_TOG 158 | ||
177 | + | ||
178 | +#define USB_ANALOG_USB1_VBUS_DETECT 104 | ||
179 | +#define USB_ANALOG_USB1_VBUS_DETECT_SET 105 | ||
180 | +#define USB_ANALOG_USB1_VBUS_DETECT_CLR 106 | ||
181 | +#define USB_ANALOG_USB1_VBUS_DETECT_TOG 107 | ||
182 | +#define USB_ANALOG_USB1_CHRG_DETECT 108 | ||
183 | +#define USB_ANALOG_USB1_CHRG_DETECT_SET 109 | ||
184 | +#define USB_ANALOG_USB1_CHRG_DETECT_CLR 110 | ||
185 | +#define USB_ANALOG_USB1_CHRG_DETECT_TOG 111 | ||
186 | +#define USB_ANALOG_USB1_VBUS_DETECT_STAT 112 | ||
187 | +#define USB_ANALOG_USB1_CHRG_DETECT_STAT 116 | ||
188 | +#define USB_ANALOG_USB1_MISC 124 | ||
189 | +#define USB_ANALOG_USB1_MISC_SET 125 | ||
190 | +#define USB_ANALOG_USB1_MISC_CLR 126 | ||
191 | +#define USB_ANALOG_USB1_MISC_TOG 127 | ||
192 | +#define USB_ANALOG_USB2_VBUS_DETECT 128 | ||
193 | +#define USB_ANALOG_USB2_VBUS_DETECT_SET 129 | ||
194 | +#define USB_ANALOG_USB2_VBUS_DETECT_CLR 130 | ||
195 | +#define USB_ANALOG_USB2_VBUS_DETECT_TOG 131 | ||
196 | +#define USB_ANALOG_USB2_CHRG_DETECT 132 | ||
197 | +#define USB_ANALOG_USB2_CHRG_DETECT_SET 133 | ||
198 | +#define USB_ANALOG_USB2_CHRG_DETECT_CLR 134 | ||
199 | +#define USB_ANALOG_USB2_CHRG_DETECT_TOG 135 | ||
200 | +#define USB_ANALOG_USB2_VBUS_DETECT_STAT 136 | ||
201 | +#define USB_ANALOG_USB2_CHRG_DETECT_STAT 140 | ||
202 | +#define USB_ANALOG_USB2_MISC 148 | ||
203 | +#define USB_ANALOG_USB2_MISC_SET 149 | ||
204 | +#define USB_ANALOG_USB2_MISC_CLR 150 | ||
205 | +#define USB_ANALOG_USB2_MISC_TOG 151 | ||
206 | +#define USB_ANALOG_DIGPROG 152 | ||
207 | +#define CCM_ANALOG_MAX 4096 | ||
208 | + | ||
209 | +/* CCM_CBCMR */ | ||
210 | +#define R_CBCMR_PRE_PERIPH_CLK_SEL_SHIFT (18) | ||
211 | +#define R_CBCMR_PRE_PERIPH_CLK_SEL_LENGTH (2) | ||
212 | +#define R_CBCMR_PERIPH_CLK2_SEL_SHIFT (12) | ||
213 | +#define R_CBCMR_PERIPH_CLK2_SEL_LENGTH (2) | ||
214 | + | ||
215 | +/* CCM_CBCDR */ | ||
216 | +#define R_CBCDR_AHB_PODF_SHIFT (10) | ||
217 | +#define R_CBCDR_AHB_PODF_LENGTH (3) | ||
218 | +#define R_CBCDR_IPG_PODF_SHIFT (8) | ||
219 | +#define R_CBCDR_IPG_PODF_LENGTH (2) | ||
220 | +#define R_CBCDR_PERIPH_CLK_SEL_SHIFT (25) | ||
221 | +#define R_CBCDR_PERIPH_CLK_SEL_LENGTH (1) | ||
222 | +#define R_CBCDR_PERIPH_CLK2_PODF_SHIFT (27) | ||
223 | +#define R_CBCDR_PERIPH_CLK2_PODF_LENGTH (3) | ||
224 | + | ||
225 | +/* CCM_CSCMR1 */ | ||
226 | +#define R_CSCMR1_PERCLK_PODF_SHIFT (0) | ||
227 | +#define R_CSCMR1_PERCLK_PODF_LENGTH (6) | ||
228 | +#define R_CSCMR1_PERCLK_CLK_SEL_SHIFT (6) | ||
229 | +#define R_CSCMR1_PERCLK_CLK_SEL_LENGTH (1) | ||
230 | + | ||
231 | +/* CCM_ANALOG_PFD_528 */ | ||
232 | +#define R_ANALOG_PFD_528_PFD0_FRAC_SHIFT (0) | ||
233 | +#define R_ANALOG_PFD_528_PFD0_FRAC_LENGTH (6) | ||
234 | +#define R_ANALOG_PFD_528_PFD2_FRAC_SHIFT (16) | ||
235 | +#define R_ANALOG_PFD_528_PFD2_FRAC_LENGTH (6) | ||
236 | + | ||
237 | +/* CCM_ANALOG_PLL_SYS */ | ||
238 | +#define R_ANALOG_PLL_SYS_DIV_SELECT_SHIFT (0) | ||
239 | +#define R_ANALOG_PLL_SYS_DIV_SELECT_LENGTH (1) | ||
240 | + | ||
241 | +#define CCM_ANALOG_PLL_LOCK (1 << 31); | ||
242 | + | ||
243 | +#define TYPE_IMX6UL_CCM "imx6ul.ccm" | ||
244 | +#define IMX6UL_CCM(obj) OBJECT_CHECK(IMX6ULCCMState, (obj), TYPE_IMX6UL_CCM) | ||
245 | + | ||
246 | +typedef struct IMX6ULCCMState { | ||
247 | + /* <private> */ | ||
248 | + IMXCCMState parent_obj; | ||
249 | + | ||
250 | + /* <public> */ | ||
251 | + MemoryRegion container; | ||
252 | + MemoryRegion ioccm; | ||
253 | + MemoryRegion ioanalog; | ||
254 | + | ||
255 | + uint32_t ccm[CCM_MAX]; | ||
256 | + uint32_t analog[CCM_ANALOG_MAX]; | ||
257 | + | ||
258 | +} IMX6ULCCMState; | ||
259 | + | ||
260 | +#endif /* IMX6UL_CCM_H */ | ||
261 | diff --git a/hw/misc/imx6ul_ccm.c b/hw/misc/imx6ul_ccm.c | ||
262 | new file mode 100644 | 60 | new file mode 100644 |
263 | index XXXXXXX..XXXXXXX | 61 | index XXXXXXX..XXXXXXX |
264 | --- /dev/null | 62 | --- /dev/null |
265 | +++ b/hw/misc/imx6ul_ccm.c | 63 | +++ b/include/hw/net/xlnx-zynqmp-can.h |
266 | @@ -XXX,XX +XXX,XX @@ | 64 | @@ -XXX,XX +XXX,XX @@ |
267 | +/* | 65 | +/* |
268 | + * IMX6UL Clock Control Module | 66 | + * QEMU model of the Xilinx ZynqMP CAN controller. |
269 | + * | 67 | + * |
270 | + * Copyright (c) 2018 Jean-Christophe Dubois <jcd@tribudubois.net> | 68 | + * Copyright (c) 2020 Xilinx Inc. |
271 | + * | 69 | + * |
272 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | 70 | + * Written-by: Vikram Garhwal<fnu.vikram@xilinx.com> |
273 | + * See the COPYING file in the top-level directory. | ||
274 | + * | 71 | + * |
275 | + * To get the timer frequencies right, we need to emulate at least part of | 72 | + * Based on QEMU CAN Device emulation implemented by Jin Yang, Deniz Eren and |
276 | + * the CCM. | 73 | + * Pavel Pisa. |
74 | + * | ||
75 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
76 | + * of this software and associated documentation files (the "Software"), to deal | ||
77 | + * in the Software without restriction, including without limitation the rights | ||
78 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
79 | + * copies of the Software, and to permit persons to whom the Software is | ||
80 | + * furnished to do so, subject to the following conditions: | ||
81 | + * | ||
82 | + * The above copyright notice and this permission notice shall be included in | ||
83 | + * all copies or substantial portions of the Software. | ||
84 | + * | ||
85 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
86 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
87 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
88 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
89 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
90 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
91 | + * THE SOFTWARE. | ||
277 | + */ | 92 | + */ |
278 | + | 93 | + |
94 | +#ifndef XLNX_ZYNQMP_CAN_H | ||
95 | +#define XLNX_ZYNQMP_CAN_H | ||
96 | + | ||
97 | +#include "hw/register.h" | ||
98 | +#include "net/can_emu.h" | ||
99 | +#include "net/can_host.h" | ||
100 | +#include "qemu/fifo32.h" | ||
101 | +#include "hw/ptimer.h" | ||
102 | +#include "hw/qdev-clock.h" | ||
103 | + | ||
104 | +#define TYPE_XLNX_ZYNQMP_CAN "xlnx.zynqmp-can" | ||
105 | + | ||
106 | +#define XLNX_ZYNQMP_CAN(obj) \ | ||
107 | + OBJECT_CHECK(XlnxZynqMPCANState, (obj), TYPE_XLNX_ZYNQMP_CAN) | ||
108 | + | ||
109 | +#define MAX_CAN_CTRLS 2 | ||
110 | +#define XLNX_ZYNQMP_CAN_R_MAX (0x84 / 4) | ||
111 | +#define MAILBOX_CAPACITY 64 | ||
112 | +#define CAN_TIMER_MAX 0XFFFFUL | ||
113 | +#define CAN_DEFAULT_CLOCK (24 * 1000 * 1000) | ||
114 | + | ||
115 | +/* Each CAN_FRAME will have 4 * 32bit size. */ | ||
116 | +#define CAN_FRAME_SIZE 4 | ||
117 | +#define RXFIFO_SIZE (MAILBOX_CAPACITY * CAN_FRAME_SIZE) | ||
118 | + | ||
119 | +typedef struct XlnxZynqMPCANState { | ||
120 | + SysBusDevice parent_obj; | ||
121 | + MemoryRegion iomem; | ||
122 | + | ||
123 | + qemu_irq irq; | ||
124 | + | ||
125 | + CanBusClientState bus_client; | ||
126 | + CanBusState *canbus; | ||
127 | + | ||
128 | + struct { | ||
129 | + uint32_t ext_clk_freq; | ||
130 | + } cfg; | ||
131 | + | ||
132 | + RegisterInfo reg_info[XLNX_ZYNQMP_CAN_R_MAX]; | ||
133 | + uint32_t regs[XLNX_ZYNQMP_CAN_R_MAX]; | ||
134 | + | ||
135 | + Fifo32 rx_fifo; | ||
136 | + Fifo32 tx_fifo; | ||
137 | + Fifo32 txhpb_fifo; | ||
138 | + | ||
139 | + ptimer_state *can_timer; | ||
140 | +} XlnxZynqMPCANState; | ||
141 | + | ||
142 | +#endif | ||
143 | diff --git a/hw/net/can/xlnx-zynqmp-can.c b/hw/net/can/xlnx-zynqmp-can.c | ||
144 | new file mode 100644 | ||
145 | index XXXXXXX..XXXXXXX | ||
146 | --- /dev/null | ||
147 | +++ b/hw/net/can/xlnx-zynqmp-can.c | ||
148 | @@ -XXX,XX +XXX,XX @@ | ||
149 | +/* | ||
150 | + * QEMU model of the Xilinx ZynqMP CAN controller. | ||
151 | + * This implementation is based on the following datasheet: | ||
152 | + * https://www.xilinx.com/support/documentation/user_guides/ug1085-zynq-ultrascale-trm.pdf | ||
153 | + * | ||
154 | + * Copyright (c) 2020 Xilinx Inc. | ||
155 | + * | ||
156 | + * Written-by: Vikram Garhwal<fnu.vikram@xilinx.com> | ||
157 | + * | ||
158 | + * Based on QEMU CAN Device emulation implemented by Jin Yang, Deniz Eren and | ||
159 | + * Pavel Pisa | ||
160 | + * | ||
161 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
162 | + * of this software and associated documentation files (the "Software"), to deal | ||
163 | + * in the Software without restriction, including without limitation the rights | ||
164 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
165 | + * copies of the Software, and to permit persons to whom the Software is | ||
166 | + * furnished to do so, subject to the following conditions: | ||
167 | + * | ||
168 | + * The above copyright notice and this permission notice shall be included in | ||
169 | + * all copies or substantial portions of the Software. | ||
170 | + * | ||
171 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
172 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
173 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
174 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
175 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
176 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
177 | + * THE SOFTWARE. | ||
178 | + */ | ||
179 | + | ||
279 | +#include "qemu/osdep.h" | 180 | +#include "qemu/osdep.h" |
280 | +#include "hw/registerfields.h" | 181 | +#include "hw/sysbus.h" |
281 | +#include "hw/misc/imx6ul_ccm.h" | 182 | +#include "hw/register.h" |
183 | +#include "hw/irq.h" | ||
184 | +#include "qapi/error.h" | ||
185 | +#include "qemu/bitops.h" | ||
282 | +#include "qemu/log.h" | 186 | +#include "qemu/log.h" |
283 | + | 187 | +#include "qemu/cutils.h" |
188 | +#include "sysemu/sysemu.h" | ||
189 | +#include "migration/vmstate.h" | ||
190 | +#include "hw/qdev-properties.h" | ||
191 | +#include "net/can_emu.h" | ||
192 | +#include "net/can_host.h" | ||
193 | +#include "qemu/event_notifier.h" | ||
194 | +#include "qom/object_interfaces.h" | ||
195 | +#include "hw/net/xlnx-zynqmp-can.h" | ||
284 | +#include "trace.h" | 196 | +#include "trace.h" |
285 | + | 197 | + |
286 | +static const char *imx6ul_ccm_reg_name(uint32_t reg) | 198 | +#ifndef XLNX_ZYNQMP_CAN_ERR_DEBUG |
287 | +{ | 199 | +#define XLNX_ZYNQMP_CAN_ERR_DEBUG 0 |
288 | + static char unknown[20]; | 200 | +#endif |
289 | + | 201 | + |
290 | + switch (reg) { | 202 | +#define MAX_DLC 8 |
291 | + case CCM_CCR: | 203 | +#undef ERROR |
292 | + return "CCR"; | 204 | + |
293 | + case CCM_CCDR: | 205 | +REG32(SOFTWARE_RESET_REGISTER, 0x0) |
294 | + return "CCDR"; | 206 | + FIELD(SOFTWARE_RESET_REGISTER, CEN, 1, 1) |
295 | + case CCM_CSR: | 207 | + FIELD(SOFTWARE_RESET_REGISTER, SRST, 0, 1) |
296 | + return "CSR"; | 208 | +REG32(MODE_SELECT_REGISTER, 0x4) |
297 | + case CCM_CCSR: | 209 | + FIELD(MODE_SELECT_REGISTER, SNOOP, 2, 1) |
298 | + return "CCSR"; | 210 | + FIELD(MODE_SELECT_REGISTER, LBACK, 1, 1) |
299 | + case CCM_CACRR: | 211 | + FIELD(MODE_SELECT_REGISTER, SLEEP, 0, 1) |
300 | + return "CACRR"; | 212 | +REG32(ARBITRATION_PHASE_BAUD_RATE_PRESCALER_REGISTER, 0x8) |
301 | + case CCM_CBCDR: | 213 | + FIELD(ARBITRATION_PHASE_BAUD_RATE_PRESCALER_REGISTER, BRP, 0, 8) |
302 | + return "CBCDR"; | 214 | +REG32(ARBITRATION_PHASE_BIT_TIMING_REGISTER, 0xc) |
303 | + case CCM_CBCMR: | 215 | + FIELD(ARBITRATION_PHASE_BIT_TIMING_REGISTER, SJW, 7, 2) |
304 | + return "CBCMR"; | 216 | + FIELD(ARBITRATION_PHASE_BIT_TIMING_REGISTER, TS2, 4, 3) |
305 | + case CCM_CSCMR1: | 217 | + FIELD(ARBITRATION_PHASE_BIT_TIMING_REGISTER, TS1, 0, 4) |
306 | + return "CSCMR1"; | 218 | +REG32(ERROR_COUNTER_REGISTER, 0x10) |
307 | + case CCM_CSCMR2: | 219 | + FIELD(ERROR_COUNTER_REGISTER, REC, 8, 8) |
308 | + return "CSCMR2"; | 220 | + FIELD(ERROR_COUNTER_REGISTER, TEC, 0, 8) |
309 | + case CCM_CSCDR1: | 221 | +REG32(ERROR_STATUS_REGISTER, 0x14) |
310 | + return "CSCDR1"; | 222 | + FIELD(ERROR_STATUS_REGISTER, ACKER, 4, 1) |
311 | + case CCM_CS1CDR: | 223 | + FIELD(ERROR_STATUS_REGISTER, BERR, 3, 1) |
312 | + return "CS1CDR"; | 224 | + FIELD(ERROR_STATUS_REGISTER, STER, 2, 1) |
313 | + case CCM_CS2CDR: | 225 | + FIELD(ERROR_STATUS_REGISTER, FMER, 1, 1) |
314 | + return "CS2CDR"; | 226 | + FIELD(ERROR_STATUS_REGISTER, CRCER, 0, 1) |
315 | + case CCM_CDCDR: | 227 | +REG32(STATUS_REGISTER, 0x18) |
316 | + return "CDCDR"; | 228 | + FIELD(STATUS_REGISTER, SNOOP, 12, 1) |
317 | + case CCM_CHSCCDR: | 229 | + FIELD(STATUS_REGISTER, ACFBSY, 11, 1) |
318 | + return "CHSCCDR"; | 230 | + FIELD(STATUS_REGISTER, TXFLL, 10, 1) |
319 | + case CCM_CSCDR2: | 231 | + FIELD(STATUS_REGISTER, TXBFLL, 9, 1) |
320 | + return "CSCDR2"; | 232 | + FIELD(STATUS_REGISTER, ESTAT, 7, 2) |
321 | + case CCM_CSCDR3: | 233 | + FIELD(STATUS_REGISTER, ERRWRN, 6, 1) |
322 | + return "CSCDR3"; | 234 | + FIELD(STATUS_REGISTER, BBSY, 5, 1) |
323 | + case CCM_CDHIPR: | 235 | + FIELD(STATUS_REGISTER, BIDLE, 4, 1) |
324 | + return "CDHIPR"; | 236 | + FIELD(STATUS_REGISTER, NORMAL, 3, 1) |
325 | + case CCM_CTOR: | 237 | + FIELD(STATUS_REGISTER, SLEEP, 2, 1) |
326 | + return "CTOR"; | 238 | + FIELD(STATUS_REGISTER, LBACK, 1, 1) |
327 | + case CCM_CLPCR: | 239 | + FIELD(STATUS_REGISTER, CONFIG, 0, 1) |
328 | + return "CLPCR"; | 240 | +REG32(INTERRUPT_STATUS_REGISTER, 0x1c) |
329 | + case CCM_CISR: | 241 | + FIELD(INTERRUPT_STATUS_REGISTER, TXFEMP, 14, 1) |
330 | + return "CISR"; | 242 | + FIELD(INTERRUPT_STATUS_REGISTER, TXFWMEMP, 13, 1) |
331 | + case CCM_CIMR: | 243 | + FIELD(INTERRUPT_STATUS_REGISTER, RXFWMFLL, 12, 1) |
332 | + return "CIMR"; | 244 | + FIELD(INTERRUPT_STATUS_REGISTER, WKUP, 11, 1) |
333 | + case CCM_CCOSR: | 245 | + FIELD(INTERRUPT_STATUS_REGISTER, SLP, 10, 1) |
334 | + return "CCOSR"; | 246 | + FIELD(INTERRUPT_STATUS_REGISTER, BSOFF, 9, 1) |
335 | + case CCM_CGPR: | 247 | + FIELD(INTERRUPT_STATUS_REGISTER, ERROR, 8, 1) |
336 | + return "CGPR"; | 248 | + FIELD(INTERRUPT_STATUS_REGISTER, RXNEMP, 7, 1) |
337 | + case CCM_CCGR0: | 249 | + FIELD(INTERRUPT_STATUS_REGISTER, RXOFLW, 6, 1) |
338 | + return "CCGR0"; | 250 | + FIELD(INTERRUPT_STATUS_REGISTER, RXUFLW, 5, 1) |
339 | + case CCM_CCGR1: | 251 | + FIELD(INTERRUPT_STATUS_REGISTER, RXOK, 4, 1) |
340 | + return "CCGR1"; | 252 | + FIELD(INTERRUPT_STATUS_REGISTER, TXBFLL, 3, 1) |
341 | + case CCM_CCGR2: | 253 | + FIELD(INTERRUPT_STATUS_REGISTER, TXFLL, 2, 1) |
342 | + return "CCGR2"; | 254 | + FIELD(INTERRUPT_STATUS_REGISTER, TXOK, 1, 1) |
343 | + case CCM_CCGR3: | 255 | + FIELD(INTERRUPT_STATUS_REGISTER, ARBLST, 0, 1) |
344 | + return "CCGR3"; | 256 | +REG32(INTERRUPT_ENABLE_REGISTER, 0x20) |
345 | + case CCM_CCGR4: | 257 | + FIELD(INTERRUPT_ENABLE_REGISTER, ETXFEMP, 14, 1) |
346 | + return "CCGR4"; | 258 | + FIELD(INTERRUPT_ENABLE_REGISTER, ETXFWMEMP, 13, 1) |
347 | + case CCM_CCGR5: | 259 | + FIELD(INTERRUPT_ENABLE_REGISTER, ERXFWMFLL, 12, 1) |
348 | + return "CCGR5"; | 260 | + FIELD(INTERRUPT_ENABLE_REGISTER, EWKUP, 11, 1) |
349 | + case CCM_CCGR6: | 261 | + FIELD(INTERRUPT_ENABLE_REGISTER, ESLP, 10, 1) |
350 | + return "CCGR6"; | 262 | + FIELD(INTERRUPT_ENABLE_REGISTER, EBSOFF, 9, 1) |
351 | + case CCM_CMEOR: | 263 | + FIELD(INTERRUPT_ENABLE_REGISTER, EERROR, 8, 1) |
352 | + return "CMEOR"; | 264 | + FIELD(INTERRUPT_ENABLE_REGISTER, ERXNEMP, 7, 1) |
353 | + default: | 265 | + FIELD(INTERRUPT_ENABLE_REGISTER, ERXOFLW, 6, 1) |
354 | + sprintf(unknown, "%d ?", reg); | 266 | + FIELD(INTERRUPT_ENABLE_REGISTER, ERXUFLW, 5, 1) |
355 | + return unknown; | 267 | + FIELD(INTERRUPT_ENABLE_REGISTER, ERXOK, 4, 1) |
356 | + } | 268 | + FIELD(INTERRUPT_ENABLE_REGISTER, ETXBFLL, 3, 1) |
357 | +} | 269 | + FIELD(INTERRUPT_ENABLE_REGISTER, ETXFLL, 2, 1) |
358 | + | 270 | + FIELD(INTERRUPT_ENABLE_REGISTER, ETXOK, 1, 1) |
359 | +static const char *imx6ul_analog_reg_name(uint32_t reg) | 271 | + FIELD(INTERRUPT_ENABLE_REGISTER, EARBLST, 0, 1) |
360 | +{ | 272 | +REG32(INTERRUPT_CLEAR_REGISTER, 0x24) |
361 | + static char unknown[20]; | 273 | + FIELD(INTERRUPT_CLEAR_REGISTER, CTXFEMP, 14, 1) |
362 | + | 274 | + FIELD(INTERRUPT_CLEAR_REGISTER, CTXFWMEMP, 13, 1) |
363 | + switch (reg) { | 275 | + FIELD(INTERRUPT_CLEAR_REGISTER, CRXFWMFLL, 12, 1) |
364 | + case CCM_ANALOG_PLL_ARM: | 276 | + FIELD(INTERRUPT_CLEAR_REGISTER, CWKUP, 11, 1) |
365 | + return "PLL_ARM"; | 277 | + FIELD(INTERRUPT_CLEAR_REGISTER, CSLP, 10, 1) |
366 | + case CCM_ANALOG_PLL_ARM_SET: | 278 | + FIELD(INTERRUPT_CLEAR_REGISTER, CBSOFF, 9, 1) |
367 | + return "PLL_ARM_SET"; | 279 | + FIELD(INTERRUPT_CLEAR_REGISTER, CERROR, 8, 1) |
368 | + case CCM_ANALOG_PLL_ARM_CLR: | 280 | + FIELD(INTERRUPT_CLEAR_REGISTER, CRXNEMP, 7, 1) |
369 | + return "PLL_ARM_CLR"; | 281 | + FIELD(INTERRUPT_CLEAR_REGISTER, CRXOFLW, 6, 1) |
370 | + case CCM_ANALOG_PLL_ARM_TOG: | 282 | + FIELD(INTERRUPT_CLEAR_REGISTER, CRXUFLW, 5, 1) |
371 | + return "PLL_ARM_TOG"; | 283 | + FIELD(INTERRUPT_CLEAR_REGISTER, CRXOK, 4, 1) |
372 | + case CCM_ANALOG_PLL_USB1: | 284 | + FIELD(INTERRUPT_CLEAR_REGISTER, CTXBFLL, 3, 1) |
373 | + return "PLL_USB1"; | 285 | + FIELD(INTERRUPT_CLEAR_REGISTER, CTXFLL, 2, 1) |
374 | + case CCM_ANALOG_PLL_USB1_SET: | 286 | + FIELD(INTERRUPT_CLEAR_REGISTER, CTXOK, 1, 1) |
375 | + return "PLL_USB1_SET"; | 287 | + FIELD(INTERRUPT_CLEAR_REGISTER, CARBLST, 0, 1) |
376 | + case CCM_ANALOG_PLL_USB1_CLR: | 288 | +REG32(TIMESTAMP_REGISTER, 0x28) |
377 | + return "PLL_USB1_CLR"; | 289 | + FIELD(TIMESTAMP_REGISTER, CTS, 0, 1) |
378 | + case CCM_ANALOG_PLL_USB1_TOG: | 290 | +REG32(WIR, 0x2c) |
379 | + return "PLL_USB1_TOG"; | 291 | + FIELD(WIR, EW, 8, 8) |
380 | + case CCM_ANALOG_PLL_USB2: | 292 | + FIELD(WIR, FW, 0, 8) |
381 | + return "PLL_USB2"; | 293 | +REG32(TXFIFO_ID, 0x30) |
382 | + case CCM_ANALOG_PLL_USB2_SET: | 294 | + FIELD(TXFIFO_ID, IDH, 21, 11) |
383 | + return "PLL_USB2_SET"; | 295 | + FIELD(TXFIFO_ID, SRRRTR, 20, 1) |
384 | + case CCM_ANALOG_PLL_USB2_CLR: | 296 | + FIELD(TXFIFO_ID, IDE, 19, 1) |
385 | + return "PLL_USB2_CLR"; | 297 | + FIELD(TXFIFO_ID, IDL, 1, 18) |
386 | + case CCM_ANALOG_PLL_USB2_TOG: | 298 | + FIELD(TXFIFO_ID, RTR, 0, 1) |
387 | + return "PLL_USB2_TOG"; | 299 | +REG32(TXFIFO_DLC, 0x34) |
388 | + case CCM_ANALOG_PLL_SYS: | 300 | + FIELD(TXFIFO_DLC, DLC, 28, 4) |
389 | + return "PLL_SYS"; | 301 | +REG32(TXFIFO_DATA1, 0x38) |
390 | + case CCM_ANALOG_PLL_SYS_SET: | 302 | + FIELD(TXFIFO_DATA1, DB0, 24, 8) |
391 | + return "PLL_SYS_SET"; | 303 | + FIELD(TXFIFO_DATA1, DB1, 16, 8) |
392 | + case CCM_ANALOG_PLL_SYS_CLR: | 304 | + FIELD(TXFIFO_DATA1, DB2, 8, 8) |
393 | + return "PLL_SYS_CLR"; | 305 | + FIELD(TXFIFO_DATA1, DB3, 0, 8) |
394 | + case CCM_ANALOG_PLL_SYS_TOG: | 306 | +REG32(TXFIFO_DATA2, 0x3c) |
395 | + return "PLL_SYS_TOG"; | 307 | + FIELD(TXFIFO_DATA2, DB4, 24, 8) |
396 | + case CCM_ANALOG_PLL_SYS_SS: | 308 | + FIELD(TXFIFO_DATA2, DB5, 16, 8) |
397 | + return "PLL_SYS_SS"; | 309 | + FIELD(TXFIFO_DATA2, DB6, 8, 8) |
398 | + case CCM_ANALOG_PLL_SYS_NUM: | 310 | + FIELD(TXFIFO_DATA2, DB7, 0, 8) |
399 | + return "PLL_SYS_NUM"; | 311 | +REG32(TXHPB_ID, 0x40) |
400 | + case CCM_ANALOG_PLL_SYS_DENOM: | 312 | + FIELD(TXHPB_ID, IDH, 21, 11) |
401 | + return "PLL_SYS_DENOM"; | 313 | + FIELD(TXHPB_ID, SRRRTR, 20, 1) |
402 | + case CCM_ANALOG_PLL_AUDIO: | 314 | + FIELD(TXHPB_ID, IDE, 19, 1) |
403 | + return "PLL_AUDIO"; | 315 | + FIELD(TXHPB_ID, IDL, 1, 18) |
404 | + case CCM_ANALOG_PLL_AUDIO_SET: | 316 | + FIELD(TXHPB_ID, RTR, 0, 1) |
405 | + return "PLL_AUDIO_SET"; | 317 | +REG32(TXHPB_DLC, 0x44) |
406 | + case CCM_ANALOG_PLL_AUDIO_CLR: | 318 | + FIELD(TXHPB_DLC, DLC, 28, 4) |
407 | + return "PLL_AUDIO_CLR"; | 319 | +REG32(TXHPB_DATA1, 0x48) |
408 | + case CCM_ANALOG_PLL_AUDIO_TOG: | 320 | + FIELD(TXHPB_DATA1, DB0, 24, 8) |
409 | + return "PLL_AUDIO_TOG"; | 321 | + FIELD(TXHPB_DATA1, DB1, 16, 8) |
410 | + case CCM_ANALOG_PLL_AUDIO_NUM: | 322 | + FIELD(TXHPB_DATA1, DB2, 8, 8) |
411 | + return "PLL_AUDIO_NUM"; | 323 | + FIELD(TXHPB_DATA1, DB3, 0, 8) |
412 | + case CCM_ANALOG_PLL_AUDIO_DENOM: | 324 | +REG32(TXHPB_DATA2, 0x4c) |
413 | + return "PLL_AUDIO_DENOM"; | 325 | + FIELD(TXHPB_DATA2, DB4, 24, 8) |
414 | + case CCM_ANALOG_PLL_VIDEO: | 326 | + FIELD(TXHPB_DATA2, DB5, 16, 8) |
415 | + return "PLL_VIDEO"; | 327 | + FIELD(TXHPB_DATA2, DB6, 8, 8) |
416 | + case CCM_ANALOG_PLL_VIDEO_SET: | 328 | + FIELD(TXHPB_DATA2, DB7, 0, 8) |
417 | + return "PLL_VIDEO_SET"; | 329 | +REG32(RXFIFO_ID, 0x50) |
418 | + case CCM_ANALOG_PLL_VIDEO_CLR: | 330 | + FIELD(RXFIFO_ID, IDH, 21, 11) |
419 | + return "PLL_VIDEO_CLR"; | 331 | + FIELD(RXFIFO_ID, SRRRTR, 20, 1) |
420 | + case CCM_ANALOG_PLL_VIDEO_TOG: | 332 | + FIELD(RXFIFO_ID, IDE, 19, 1) |
421 | + return "PLL_VIDEO_TOG"; | 333 | + FIELD(RXFIFO_ID, IDL, 1, 18) |
422 | + case CCM_ANALOG_PLL_VIDEO_NUM: | 334 | + FIELD(RXFIFO_ID, RTR, 0, 1) |
423 | + return "PLL_VIDEO_NUM"; | 335 | +REG32(RXFIFO_DLC, 0x54) |
424 | + case CCM_ANALOG_PLL_VIDEO_DENOM: | 336 | + FIELD(RXFIFO_DLC, DLC, 28, 4) |
425 | + return "PLL_VIDEO_DENOM"; | 337 | + FIELD(RXFIFO_DLC, RXT, 0, 16) |
426 | + case CCM_ANALOG_PLL_ENET: | 338 | +REG32(RXFIFO_DATA1, 0x58) |
427 | + return "PLL_ENET"; | 339 | + FIELD(RXFIFO_DATA1, DB0, 24, 8) |
428 | + case CCM_ANALOG_PLL_ENET_SET: | 340 | + FIELD(RXFIFO_DATA1, DB1, 16, 8) |
429 | + return "PLL_ENET_SET"; | 341 | + FIELD(RXFIFO_DATA1, DB2, 8, 8) |
430 | + case CCM_ANALOG_PLL_ENET_CLR: | 342 | + FIELD(RXFIFO_DATA1, DB3, 0, 8) |
431 | + return "PLL_ENET_CLR"; | 343 | +REG32(RXFIFO_DATA2, 0x5c) |
432 | + case CCM_ANALOG_PLL_ENET_TOG: | 344 | + FIELD(RXFIFO_DATA2, DB4, 24, 8) |
433 | + return "PLL_ENET_TOG"; | 345 | + FIELD(RXFIFO_DATA2, DB5, 16, 8) |
434 | + case CCM_ANALOG_PFD_480: | 346 | + FIELD(RXFIFO_DATA2, DB6, 8, 8) |
435 | + return "PFD_480"; | 347 | + FIELD(RXFIFO_DATA2, DB7, 0, 8) |
436 | + case CCM_ANALOG_PFD_480_SET: | 348 | +REG32(AFR, 0x60) |
437 | + return "PFD_480_SET"; | 349 | + FIELD(AFR, UAF4, 3, 1) |
438 | + case CCM_ANALOG_PFD_480_CLR: | 350 | + FIELD(AFR, UAF3, 2, 1) |
439 | + return "PFD_480_CLR"; | 351 | + FIELD(AFR, UAF2, 1, 1) |
440 | + case CCM_ANALOG_PFD_480_TOG: | 352 | + FIELD(AFR, UAF1, 0, 1) |
441 | + return "PFD_480_TOG"; | 353 | +REG32(AFMR1, 0x64) |
442 | + case CCM_ANALOG_PFD_528: | 354 | + FIELD(AFMR1, AMIDH, 21, 11) |
443 | + return "PFD_528"; | 355 | + FIELD(AFMR1, AMSRR, 20, 1) |
444 | + case CCM_ANALOG_PFD_528_SET: | 356 | + FIELD(AFMR1, AMIDE, 19, 1) |
445 | + return "PFD_528_SET"; | 357 | + FIELD(AFMR1, AMIDL, 1, 18) |
446 | + case CCM_ANALOG_PFD_528_CLR: | 358 | + FIELD(AFMR1, AMRTR, 0, 1) |
447 | + return "PFD_528_CLR"; | 359 | +REG32(AFIR1, 0x68) |
448 | + case CCM_ANALOG_PFD_528_TOG: | 360 | + FIELD(AFIR1, AIIDH, 21, 11) |
449 | + return "PFD_528_TOG"; | 361 | + FIELD(AFIR1, AISRR, 20, 1) |
450 | + case CCM_ANALOG_MISC0: | 362 | + FIELD(AFIR1, AIIDE, 19, 1) |
451 | + return "MISC0"; | 363 | + FIELD(AFIR1, AIIDL, 1, 18) |
452 | + case CCM_ANALOG_MISC0_SET: | 364 | + FIELD(AFIR1, AIRTR, 0, 1) |
453 | + return "MISC0_SET"; | 365 | +REG32(AFMR2, 0x6c) |
454 | + case CCM_ANALOG_MISC0_CLR: | 366 | + FIELD(AFMR2, AMIDH, 21, 11) |
455 | + return "MISC0_CLR"; | 367 | + FIELD(AFMR2, AMSRR, 20, 1) |
456 | + case CCM_ANALOG_MISC0_TOG: | 368 | + FIELD(AFMR2, AMIDE, 19, 1) |
457 | + return "MISC0_TOG"; | 369 | + FIELD(AFMR2, AMIDL, 1, 18) |
458 | + case CCM_ANALOG_MISC2: | 370 | + FIELD(AFMR2, AMRTR, 0, 1) |
459 | + return "MISC2"; | 371 | +REG32(AFIR2, 0x70) |
460 | + case CCM_ANALOG_MISC2_SET: | 372 | + FIELD(AFIR2, AIIDH, 21, 11) |
461 | + return "MISC2_SET"; | 373 | + FIELD(AFIR2, AISRR, 20, 1) |
462 | + case CCM_ANALOG_MISC2_CLR: | 374 | + FIELD(AFIR2, AIIDE, 19, 1) |
463 | + return "MISC2_CLR"; | 375 | + FIELD(AFIR2, AIIDL, 1, 18) |
464 | + case CCM_ANALOG_MISC2_TOG: | 376 | + FIELD(AFIR2, AIRTR, 0, 1) |
465 | + return "MISC2_TOG"; | 377 | +REG32(AFMR3, 0x74) |
466 | + case PMU_REG_1P1: | 378 | + FIELD(AFMR3, AMIDH, 21, 11) |
467 | + return "PMU_REG_1P1"; | 379 | + FIELD(AFMR3, AMSRR, 20, 1) |
468 | + case PMU_REG_3P0: | 380 | + FIELD(AFMR3, AMIDE, 19, 1) |
469 | + return "PMU_REG_3P0"; | 381 | + FIELD(AFMR3, AMIDL, 1, 18) |
470 | + case PMU_REG_2P5: | 382 | + FIELD(AFMR3, AMRTR, 0, 1) |
471 | + return "PMU_REG_2P5"; | 383 | +REG32(AFIR3, 0x78) |
472 | + case PMU_REG_CORE: | 384 | + FIELD(AFIR3, AIIDH, 21, 11) |
473 | + return "PMU_REG_CORE"; | 385 | + FIELD(AFIR3, AISRR, 20, 1) |
474 | + case PMU_MISC1: | 386 | + FIELD(AFIR3, AIIDE, 19, 1) |
475 | + return "PMU_MISC1"; | 387 | + FIELD(AFIR3, AIIDL, 1, 18) |
476 | + case PMU_MISC1_SET: | 388 | + FIELD(AFIR3, AIRTR, 0, 1) |
477 | + return "PMU_MISC1_SET"; | 389 | +REG32(AFMR4, 0x7c) |
478 | + case PMU_MISC1_CLR: | 390 | + FIELD(AFMR4, AMIDH, 21, 11) |
479 | + return "PMU_MISC1_CLR"; | 391 | + FIELD(AFMR4, AMSRR, 20, 1) |
480 | + case PMU_MISC1_TOG: | 392 | + FIELD(AFMR4, AMIDE, 19, 1) |
481 | + return "PMU_MISC1_TOG"; | 393 | + FIELD(AFMR4, AMIDL, 1, 18) |
482 | + case USB_ANALOG_DIGPROG: | 394 | + FIELD(AFMR4, AMRTR, 0, 1) |
483 | + return "USB_ANALOG_DIGPROG"; | 395 | +REG32(AFIR4, 0x80) |
484 | + default: | 396 | + FIELD(AFIR4, AIIDH, 21, 11) |
485 | + sprintf(unknown, "%d ?", reg); | 397 | + FIELD(AFIR4, AISRR, 20, 1) |
486 | + return unknown; | 398 | + FIELD(AFIR4, AIIDE, 19, 1) |
487 | + } | 399 | + FIELD(AFIR4, AIIDL, 1, 18) |
488 | +} | 400 | + FIELD(AFIR4, AIRTR, 0, 1) |
489 | + | 401 | + |
490 | +#define CKIH_FREQ 24000000 /* 24MHz crystal input */ | 402 | +static void can_update_irq(XlnxZynqMPCANState *s) |
491 | + | 403 | +{ |
492 | +static const VMStateDescription vmstate_imx6ul_ccm = { | 404 | + uint32_t irq; |
493 | + .name = TYPE_IMX6UL_CCM, | 405 | + |
406 | + /* Watermark register interrupts. */ | ||
407 | + if ((fifo32_num_free(&s->tx_fifo) / CAN_FRAME_SIZE) > | ||
408 | + ARRAY_FIELD_EX32(s->regs, WIR, EW)) { | ||
409 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, TXFWMEMP, 1); | ||
410 | + } | ||
411 | + | ||
412 | + if ((fifo32_num_used(&s->rx_fifo) / CAN_FRAME_SIZE) > | ||
413 | + ARRAY_FIELD_EX32(s->regs, WIR, FW)) { | ||
414 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, RXFWMFLL, 1); | ||
415 | + } | ||
416 | + | ||
417 | + /* RX Interrupts. */ | ||
418 | + if (fifo32_num_used(&s->rx_fifo) >= CAN_FRAME_SIZE) { | ||
419 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, RXNEMP, 1); | ||
420 | + } | ||
421 | + | ||
422 | + /* TX interrupts. */ | ||
423 | + if (fifo32_is_empty(&s->tx_fifo)) { | ||
424 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, TXFEMP, 1); | ||
425 | + } | ||
426 | + | ||
427 | + if (fifo32_is_full(&s->tx_fifo)) { | ||
428 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, TXFLL, 1); | ||
429 | + } | ||
430 | + | ||
431 | + if (fifo32_is_full(&s->txhpb_fifo)) { | ||
432 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, TXBFLL, 1); | ||
433 | + } | ||
434 | + | ||
435 | + irq = s->regs[R_INTERRUPT_STATUS_REGISTER]; | ||
436 | + irq &= s->regs[R_INTERRUPT_ENABLE_REGISTER]; | ||
437 | + | ||
438 | + trace_xlnx_can_update_irq(s->regs[R_INTERRUPT_STATUS_REGISTER], | ||
439 | + s->regs[R_INTERRUPT_ENABLE_REGISTER], irq); | ||
440 | + qemu_set_irq(s->irq, irq); | ||
441 | +} | ||
442 | + | ||
443 | +static void can_ier_post_write(RegisterInfo *reg, uint64_t val) | ||
444 | +{ | ||
445 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(reg->opaque); | ||
446 | + | ||
447 | + can_update_irq(s); | ||
448 | +} | ||
449 | + | ||
450 | +static uint64_t can_icr_pre_write(RegisterInfo *reg, uint64_t val) | ||
451 | +{ | ||
452 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(reg->opaque); | ||
453 | + | ||
454 | + s->regs[R_INTERRUPT_STATUS_REGISTER] &= ~val; | ||
455 | + can_update_irq(s); | ||
456 | + | ||
457 | + return 0; | ||
458 | +} | ||
459 | + | ||
460 | +static void can_config_reset(XlnxZynqMPCANState *s) | ||
461 | +{ | ||
462 | + /* Reset all the configuration registers. */ | ||
463 | + register_reset(&s->reg_info[R_SOFTWARE_RESET_REGISTER]); | ||
464 | + register_reset(&s->reg_info[R_MODE_SELECT_REGISTER]); | ||
465 | + register_reset( | ||
466 | + &s->reg_info[R_ARBITRATION_PHASE_BAUD_RATE_PRESCALER_REGISTER]); | ||
467 | + register_reset(&s->reg_info[R_ARBITRATION_PHASE_BIT_TIMING_REGISTER]); | ||
468 | + register_reset(&s->reg_info[R_STATUS_REGISTER]); | ||
469 | + register_reset(&s->reg_info[R_INTERRUPT_STATUS_REGISTER]); | ||
470 | + register_reset(&s->reg_info[R_INTERRUPT_ENABLE_REGISTER]); | ||
471 | + register_reset(&s->reg_info[R_INTERRUPT_CLEAR_REGISTER]); | ||
472 | + register_reset(&s->reg_info[R_WIR]); | ||
473 | +} | ||
474 | + | ||
475 | +static void can_config_mode(XlnxZynqMPCANState *s) | ||
476 | +{ | ||
477 | + register_reset(&s->reg_info[R_ERROR_COUNTER_REGISTER]); | ||
478 | + register_reset(&s->reg_info[R_ERROR_STATUS_REGISTER]); | ||
479 | + | ||
480 | + /* Put XlnxZynqMPCAN in configuration mode. */ | ||
481 | + ARRAY_FIELD_DP32(s->regs, STATUS_REGISTER, CONFIG, 1); | ||
482 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, WKUP, 0); | ||
483 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, SLP, 0); | ||
484 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, BSOFF, 0); | ||
485 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, ERROR, 0); | ||
486 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, RXOFLW, 0); | ||
487 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, RXOK, 0); | ||
488 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, TXOK, 0); | ||
489 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, ARBLST, 0); | ||
490 | + | ||
491 | + can_update_irq(s); | ||
492 | +} | ||
493 | + | ||
494 | +static void update_status_register_mode_bits(XlnxZynqMPCANState *s) | ||
495 | +{ | ||
496 | + bool sleep_status = ARRAY_FIELD_EX32(s->regs, STATUS_REGISTER, SLEEP); | ||
497 | + bool sleep_mode = ARRAY_FIELD_EX32(s->regs, MODE_SELECT_REGISTER, SLEEP); | ||
498 | + /* Wake up interrupt bit. */ | ||
499 | + bool wakeup_irq_val = sleep_status && (sleep_mode == 0); | ||
500 | + /* Sleep interrupt bit. */ | ||
501 | + bool sleep_irq_val = sleep_mode && (sleep_status == 0); | ||
502 | + | ||
503 | + /* Clear previous core mode status bits. */ | ||
504 | + ARRAY_FIELD_DP32(s->regs, STATUS_REGISTER, LBACK, 0); | ||
505 | + ARRAY_FIELD_DP32(s->regs, STATUS_REGISTER, SLEEP, 0); | ||
506 | + ARRAY_FIELD_DP32(s->regs, STATUS_REGISTER, SNOOP, 0); | ||
507 | + ARRAY_FIELD_DP32(s->regs, STATUS_REGISTER, NORMAL, 0); | ||
508 | + | ||
509 | + /* set current mode bit and generate irqs accordingly. */ | ||
510 | + if (ARRAY_FIELD_EX32(s->regs, MODE_SELECT_REGISTER, LBACK)) { | ||
511 | + ARRAY_FIELD_DP32(s->regs, STATUS_REGISTER, LBACK, 1); | ||
512 | + } else if (ARRAY_FIELD_EX32(s->regs, MODE_SELECT_REGISTER, SLEEP)) { | ||
513 | + ARRAY_FIELD_DP32(s->regs, STATUS_REGISTER, SLEEP, 1); | ||
514 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, SLP, | ||
515 | + sleep_irq_val); | ||
516 | + } else if (ARRAY_FIELD_EX32(s->regs, MODE_SELECT_REGISTER, SNOOP)) { | ||
517 | + ARRAY_FIELD_DP32(s->regs, STATUS_REGISTER, SNOOP, 1); | ||
518 | + } else { | ||
519 | + /* | ||
520 | + * If all bits are zero then XlnxZynqMPCAN is set in normal mode. | ||
521 | + */ | ||
522 | + ARRAY_FIELD_DP32(s->regs, STATUS_REGISTER, NORMAL, 1); | ||
523 | + /* Set wakeup interrupt bit. */ | ||
524 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, WKUP, | ||
525 | + wakeup_irq_val); | ||
526 | + } | ||
527 | + | ||
528 | + can_update_irq(s); | ||
529 | +} | ||
530 | + | ||
531 | +static void can_exit_sleep_mode(XlnxZynqMPCANState *s) | ||
532 | +{ | ||
533 | + ARRAY_FIELD_DP32(s->regs, MODE_SELECT_REGISTER, SLEEP, 0); | ||
534 | + update_status_register_mode_bits(s); | ||
535 | +} | ||
536 | + | ||
537 | +static void generate_frame(qemu_can_frame *frame, uint32_t *data) | ||
538 | +{ | ||
539 | + frame->can_id = data[0]; | ||
540 | + frame->can_dlc = FIELD_EX32(data[1], TXFIFO_DLC, DLC); | ||
541 | + | ||
542 | + frame->data[0] = FIELD_EX32(data[2], TXFIFO_DATA1, DB3); | ||
543 | + frame->data[1] = FIELD_EX32(data[2], TXFIFO_DATA1, DB2); | ||
544 | + frame->data[2] = FIELD_EX32(data[2], TXFIFO_DATA1, DB1); | ||
545 | + frame->data[3] = FIELD_EX32(data[2], TXFIFO_DATA1, DB0); | ||
546 | + | ||
547 | + frame->data[4] = FIELD_EX32(data[3], TXFIFO_DATA2, DB7); | ||
548 | + frame->data[5] = FIELD_EX32(data[3], TXFIFO_DATA2, DB6); | ||
549 | + frame->data[6] = FIELD_EX32(data[3], TXFIFO_DATA2, DB5); | ||
550 | + frame->data[7] = FIELD_EX32(data[3], TXFIFO_DATA2, DB4); | ||
551 | +} | ||
552 | + | ||
553 | +static bool tx_ready_check(XlnxZynqMPCANState *s) | ||
554 | +{ | ||
555 | + if (ARRAY_FIELD_EX32(s->regs, SOFTWARE_RESET_REGISTER, SRST)) { | ||
556 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
557 | + | ||
558 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Attempting to transfer data while" | ||
559 | + " data while controller is in reset mode.\n", | ||
560 | + path); | ||
561 | + return false; | ||
562 | + } | ||
563 | + | ||
564 | + if (ARRAY_FIELD_EX32(s->regs, SOFTWARE_RESET_REGISTER, CEN) == 0) { | ||
565 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
566 | + | ||
567 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Attempting to transfer" | ||
568 | + " data while controller is in configuration mode. Reset" | ||
569 | + " the core so operations can start fresh.\n", | ||
570 | + path); | ||
571 | + return false; | ||
572 | + } | ||
573 | + | ||
574 | + if (ARRAY_FIELD_EX32(s->regs, STATUS_REGISTER, SNOOP)) { | ||
575 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
576 | + | ||
577 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Attempting to transfer" | ||
578 | + " data while controller is in SNOOP MODE.\n", | ||
579 | + path); | ||
580 | + return false; | ||
581 | + } | ||
582 | + | ||
583 | + return true; | ||
584 | +} | ||
585 | + | ||
586 | +static void transfer_fifo(XlnxZynqMPCANState *s, Fifo32 *fifo) | ||
587 | +{ | ||
588 | + qemu_can_frame frame; | ||
589 | + uint32_t data[CAN_FRAME_SIZE]; | ||
590 | + int i; | ||
591 | + bool can_tx = tx_ready_check(s); | ||
592 | + | ||
593 | + if (!can_tx) { | ||
594 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
595 | + | ||
596 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Controller is not enabled for data" | ||
597 | + " transfer.\n", path); | ||
598 | + can_update_irq(s); | ||
599 | + return; | ||
600 | + } | ||
601 | + | ||
602 | + while (!fifo32_is_empty(fifo)) { | ||
603 | + for (i = 0; i < CAN_FRAME_SIZE; i++) { | ||
604 | + data[i] = fifo32_pop(fifo); | ||
605 | + } | ||
606 | + | ||
607 | + if (ARRAY_FIELD_EX32(s->regs, STATUS_REGISTER, LBACK)) { | ||
608 | + /* | ||
609 | + * Controller is in loopback. In Loopback mode, the CAN core | ||
610 | + * transmits a recessive bitstream on to the XlnxZynqMPCAN Bus. | ||
611 | + * Any message transmitted is looped back to the RX line and | ||
612 | + * acknowledged. The XlnxZynqMPCAN core receives any message | ||
613 | + * that it transmits. | ||
614 | + */ | ||
615 | + if (fifo32_is_full(&s->rx_fifo)) { | ||
616 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, RXOFLW, 1); | ||
617 | + } else { | ||
618 | + for (i = 0; i < CAN_FRAME_SIZE; i++) { | ||
619 | + fifo32_push(&s->rx_fifo, data[i]); | ||
620 | + } | ||
621 | + | ||
622 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, RXOK, 1); | ||
623 | + } | ||
624 | + } else { | ||
625 | + /* Normal mode Tx. */ | ||
626 | + generate_frame(&frame, data); | ||
627 | + | ||
628 | + trace_xlnx_can_tx_data(frame.can_id, frame.can_dlc, | ||
629 | + frame.data[0], frame.data[1], | ||
630 | + frame.data[2], frame.data[3], | ||
631 | + frame.data[4], frame.data[5], | ||
632 | + frame.data[6], frame.data[7]); | ||
633 | + can_bus_client_send(&s->bus_client, &frame, 1); | ||
634 | + } | ||
635 | + } | ||
636 | + | ||
637 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, TXOK, 1); | ||
638 | + ARRAY_FIELD_DP32(s->regs, STATUS_REGISTER, TXBFLL, 0); | ||
639 | + | ||
640 | + if (ARRAY_FIELD_EX32(s->regs, STATUS_REGISTER, SLEEP)) { | ||
641 | + can_exit_sleep_mode(s); | ||
642 | + } | ||
643 | + | ||
644 | + can_update_irq(s); | ||
645 | +} | ||
646 | + | ||
647 | +static uint64_t can_srr_pre_write(RegisterInfo *reg, uint64_t val) | ||
648 | +{ | ||
649 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(reg->opaque); | ||
650 | + | ||
651 | + ARRAY_FIELD_DP32(s->regs, SOFTWARE_RESET_REGISTER, CEN, | ||
652 | + FIELD_EX32(val, SOFTWARE_RESET_REGISTER, CEN)); | ||
653 | + | ||
654 | + if (FIELD_EX32(val, SOFTWARE_RESET_REGISTER, SRST)) { | ||
655 | + trace_xlnx_can_reset(val); | ||
656 | + | ||
657 | + /* First, core will do software reset then will enter in config mode. */ | ||
658 | + can_config_reset(s); | ||
659 | + } | ||
660 | + | ||
661 | + if (ARRAY_FIELD_EX32(s->regs, SOFTWARE_RESET_REGISTER, CEN) == 0) { | ||
662 | + can_config_mode(s); | ||
663 | + } else { | ||
664 | + /* | ||
665 | + * Leave config mode. Now XlnxZynqMPCAN core will enter normal, | ||
666 | + * sleep, snoop or loopback mode depending upon LBACK, SLEEP, SNOOP | ||
667 | + * register states. | ||
668 | + */ | ||
669 | + ARRAY_FIELD_DP32(s->regs, STATUS_REGISTER, CONFIG, 0); | ||
670 | + | ||
671 | + ptimer_transaction_begin(s->can_timer); | ||
672 | + ptimer_set_count(s->can_timer, 0); | ||
673 | + ptimer_transaction_commit(s->can_timer); | ||
674 | + | ||
675 | + /* XlnxZynqMPCAN is out of config mode. It will send pending data. */ | ||
676 | + transfer_fifo(s, &s->txhpb_fifo); | ||
677 | + transfer_fifo(s, &s->tx_fifo); | ||
678 | + } | ||
679 | + | ||
680 | + update_status_register_mode_bits(s); | ||
681 | + | ||
682 | + return s->regs[R_SOFTWARE_RESET_REGISTER]; | ||
683 | +} | ||
684 | + | ||
685 | +static uint64_t can_msr_pre_write(RegisterInfo *reg, uint64_t val) | ||
686 | +{ | ||
687 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(reg->opaque); | ||
688 | + uint8_t multi_mode; | ||
689 | + | ||
690 | + /* | ||
691 | + * Multiple mode set check. This is done to make sure user doesn't set | ||
692 | + * multiple modes. | ||
693 | + */ | ||
694 | + multi_mode = FIELD_EX32(val, MODE_SELECT_REGISTER, LBACK) + | ||
695 | + FIELD_EX32(val, MODE_SELECT_REGISTER, SLEEP) + | ||
696 | + FIELD_EX32(val, MODE_SELECT_REGISTER, SNOOP); | ||
697 | + | ||
698 | + if (multi_mode > 1) { | ||
699 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
700 | + | ||
701 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Attempting to config" | ||
702 | + " several modes simultaneously. One mode will be selected" | ||
703 | + " according to their priority: LBACK > SLEEP > SNOOP.\n", | ||
704 | + path); | ||
705 | + } | ||
706 | + | ||
707 | + if (ARRAY_FIELD_EX32(s->regs, SOFTWARE_RESET_REGISTER, CEN) == 0) { | ||
708 | + /* We are in configuration mode, any mode can be selected. */ | ||
709 | + s->regs[R_MODE_SELECT_REGISTER] = val; | ||
710 | + } else { | ||
711 | + bool sleep_mode_bit = FIELD_EX32(val, MODE_SELECT_REGISTER, SLEEP); | ||
712 | + | ||
713 | + ARRAY_FIELD_DP32(s->regs, MODE_SELECT_REGISTER, SLEEP, sleep_mode_bit); | ||
714 | + | ||
715 | + if (FIELD_EX32(val, MODE_SELECT_REGISTER, LBACK)) { | ||
716 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
717 | + | ||
718 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Attempting to set" | ||
719 | + " LBACK mode without setting CEN bit as 0.\n", | ||
720 | + path); | ||
721 | + } else if (FIELD_EX32(val, MODE_SELECT_REGISTER, SNOOP)) { | ||
722 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
723 | + | ||
724 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Attempting to set" | ||
725 | + " SNOOP mode without setting CEN bit as 0.\n", | ||
726 | + path); | ||
727 | + } | ||
728 | + | ||
729 | + update_status_register_mode_bits(s); | ||
730 | + } | ||
731 | + | ||
732 | + return s->regs[R_MODE_SELECT_REGISTER]; | ||
733 | +} | ||
734 | + | ||
735 | +static uint64_t can_brpr_pre_write(RegisterInfo *reg, uint64_t val) | ||
736 | +{ | ||
737 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(reg->opaque); | ||
738 | + | ||
739 | + /* Only allow writes when in config mode. */ | ||
740 | + if (ARRAY_FIELD_EX32(s->regs, SOFTWARE_RESET_REGISTER, CEN)) { | ||
741 | + return s->regs[R_ARBITRATION_PHASE_BAUD_RATE_PRESCALER_REGISTER]; | ||
742 | + } | ||
743 | + | ||
744 | + return val; | ||
745 | +} | ||
746 | + | ||
747 | +static uint64_t can_btr_pre_write(RegisterInfo *reg, uint64_t val) | ||
748 | +{ | ||
749 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(reg->opaque); | ||
750 | + | ||
751 | + /* Only allow writes when in config mode. */ | ||
752 | + if (ARRAY_FIELD_EX32(s->regs, SOFTWARE_RESET_REGISTER, CEN)) { | ||
753 | + return s->regs[R_ARBITRATION_PHASE_BIT_TIMING_REGISTER]; | ||
754 | + } | ||
755 | + | ||
756 | + return val; | ||
757 | +} | ||
758 | + | ||
759 | +static uint64_t can_tcr_pre_write(RegisterInfo *reg, uint64_t val) | ||
760 | +{ | ||
761 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(reg->opaque); | ||
762 | + | ||
763 | + if (FIELD_EX32(val, TIMESTAMP_REGISTER, CTS)) { | ||
764 | + ptimer_transaction_begin(s->can_timer); | ||
765 | + ptimer_set_count(s->can_timer, 0); | ||
766 | + ptimer_transaction_commit(s->can_timer); | ||
767 | + } | ||
768 | + | ||
769 | + return 0; | ||
770 | +} | ||
771 | + | ||
772 | +static void update_rx_fifo(XlnxZynqMPCANState *s, const qemu_can_frame *frame) | ||
773 | +{ | ||
774 | + bool filter_pass = false; | ||
775 | + uint16_t timestamp = 0; | ||
776 | + | ||
777 | + /* If no filter is enabled. Message will be stored in FIFO. */ | ||
778 | + if (!((ARRAY_FIELD_EX32(s->regs, AFR, UAF1)) | | ||
779 | + (ARRAY_FIELD_EX32(s->regs, AFR, UAF2)) | | ||
780 | + (ARRAY_FIELD_EX32(s->regs, AFR, UAF3)) | | ||
781 | + (ARRAY_FIELD_EX32(s->regs, AFR, UAF4)))) { | ||
782 | + filter_pass = true; | ||
783 | + } | ||
784 | + | ||
785 | + /* | ||
786 | + * Messages that pass any of the acceptance filters will be stored in | ||
787 | + * the RX FIFO. | ||
788 | + */ | ||
789 | + if (ARRAY_FIELD_EX32(s->regs, AFR, UAF1)) { | ||
790 | + uint32_t id_masked = s->regs[R_AFMR1] & frame->can_id; | ||
791 | + uint32_t filter_id_masked = s->regs[R_AFMR1] & s->regs[R_AFIR1]; | ||
792 | + | ||
793 | + if (filter_id_masked == id_masked) { | ||
794 | + filter_pass = true; | ||
795 | + } | ||
796 | + } | ||
797 | + | ||
798 | + if (ARRAY_FIELD_EX32(s->regs, AFR, UAF2)) { | ||
799 | + uint32_t id_masked = s->regs[R_AFMR2] & frame->can_id; | ||
800 | + uint32_t filter_id_masked = s->regs[R_AFMR2] & s->regs[R_AFIR2]; | ||
801 | + | ||
802 | + if (filter_id_masked == id_masked) { | ||
803 | + filter_pass = true; | ||
804 | + } | ||
805 | + } | ||
806 | + | ||
807 | + if (ARRAY_FIELD_EX32(s->regs, AFR, UAF3)) { | ||
808 | + uint32_t id_masked = s->regs[R_AFMR3] & frame->can_id; | ||
809 | + uint32_t filter_id_masked = s->regs[R_AFMR3] & s->regs[R_AFIR3]; | ||
810 | + | ||
811 | + if (filter_id_masked == id_masked) { | ||
812 | + filter_pass = true; | ||
813 | + } | ||
814 | + } | ||
815 | + | ||
816 | + if (ARRAY_FIELD_EX32(s->regs, AFR, UAF4)) { | ||
817 | + uint32_t id_masked = s->regs[R_AFMR4] & frame->can_id; | ||
818 | + uint32_t filter_id_masked = s->regs[R_AFMR4] & s->regs[R_AFIR4]; | ||
819 | + | ||
820 | + if (filter_id_masked == id_masked) { | ||
821 | + filter_pass = true; | ||
822 | + } | ||
823 | + } | ||
824 | + | ||
825 | + if (!filter_pass) { | ||
826 | + trace_xlnx_can_rx_fifo_filter_reject(frame->can_id, frame->can_dlc); | ||
827 | + return; | ||
828 | + } | ||
829 | + | ||
830 | + /* Store the message in fifo if it passed through any of the filters. */ | ||
831 | + if (filter_pass && frame->can_dlc <= MAX_DLC) { | ||
832 | + | ||
833 | + if (fifo32_is_full(&s->rx_fifo)) { | ||
834 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, RXOFLW, 1); | ||
835 | + } else { | ||
836 | + timestamp = CAN_TIMER_MAX - ptimer_get_count(s->can_timer); | ||
837 | + | ||
838 | + fifo32_push(&s->rx_fifo, frame->can_id); | ||
839 | + | ||
840 | + fifo32_push(&s->rx_fifo, deposit32(0, R_RXFIFO_DLC_DLC_SHIFT, | ||
841 | + R_RXFIFO_DLC_DLC_LENGTH, | ||
842 | + frame->can_dlc) | | ||
843 | + deposit32(0, R_RXFIFO_DLC_RXT_SHIFT, | ||
844 | + R_RXFIFO_DLC_RXT_LENGTH, | ||
845 | + timestamp)); | ||
846 | + | ||
847 | + /* First 32 bit of the data. */ | ||
848 | + fifo32_push(&s->rx_fifo, deposit32(0, R_TXFIFO_DATA1_DB3_SHIFT, | ||
849 | + R_TXFIFO_DATA1_DB3_LENGTH, | ||
850 | + frame->data[0]) | | ||
851 | + deposit32(0, R_TXFIFO_DATA1_DB2_SHIFT, | ||
852 | + R_TXFIFO_DATA1_DB2_LENGTH, | ||
853 | + frame->data[1]) | | ||
854 | + deposit32(0, R_TXFIFO_DATA1_DB1_SHIFT, | ||
855 | + R_TXFIFO_DATA1_DB1_LENGTH, | ||
856 | + frame->data[2]) | | ||
857 | + deposit32(0, R_TXFIFO_DATA1_DB0_SHIFT, | ||
858 | + R_TXFIFO_DATA1_DB0_LENGTH, | ||
859 | + frame->data[3])); | ||
860 | + /* Last 32 bit of the data. */ | ||
861 | + fifo32_push(&s->rx_fifo, deposit32(0, R_TXFIFO_DATA2_DB7_SHIFT, | ||
862 | + R_TXFIFO_DATA2_DB7_LENGTH, | ||
863 | + frame->data[4]) | | ||
864 | + deposit32(0, R_TXFIFO_DATA2_DB6_SHIFT, | ||
865 | + R_TXFIFO_DATA2_DB6_LENGTH, | ||
866 | + frame->data[5]) | | ||
867 | + deposit32(0, R_TXFIFO_DATA2_DB5_SHIFT, | ||
868 | + R_TXFIFO_DATA2_DB5_LENGTH, | ||
869 | + frame->data[6]) | | ||
870 | + deposit32(0, R_TXFIFO_DATA2_DB4_SHIFT, | ||
871 | + R_TXFIFO_DATA2_DB4_LENGTH, | ||
872 | + frame->data[7])); | ||
873 | + | ||
874 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, RXOK, 1); | ||
875 | + trace_xlnx_can_rx_data(frame->can_id, frame->can_dlc, | ||
876 | + frame->data[0], frame->data[1], | ||
877 | + frame->data[2], frame->data[3], | ||
878 | + frame->data[4], frame->data[5], | ||
879 | + frame->data[6], frame->data[7]); | ||
880 | + } | ||
881 | + | ||
882 | + can_update_irq(s); | ||
883 | + } | ||
884 | +} | ||
885 | + | ||
886 | +static uint64_t can_rxfifo_pre_read(RegisterInfo *reg, uint64_t val) | ||
887 | +{ | ||
888 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(reg->opaque); | ||
889 | + | ||
890 | + if (!fifo32_is_empty(&s->rx_fifo)) { | ||
891 | + val = fifo32_pop(&s->rx_fifo); | ||
892 | + } else { | ||
893 | + ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, RXUFLW, 1); | ||
894 | + } | ||
895 | + | ||
896 | + can_update_irq(s); | ||
897 | + return val; | ||
898 | +} | ||
899 | + | ||
900 | +static void can_filter_enable_post_write(RegisterInfo *reg, uint64_t val) | ||
901 | +{ | ||
902 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(reg->opaque); | ||
903 | + | ||
904 | + if (ARRAY_FIELD_EX32(s->regs, AFR, UAF1) && | ||
905 | + ARRAY_FIELD_EX32(s->regs, AFR, UAF2) && | ||
906 | + ARRAY_FIELD_EX32(s->regs, AFR, UAF3) && | ||
907 | + ARRAY_FIELD_EX32(s->regs, AFR, UAF4)) { | ||
908 | + ARRAY_FIELD_DP32(s->regs, STATUS_REGISTER, ACFBSY, 1); | ||
909 | + } else { | ||
910 | + ARRAY_FIELD_DP32(s->regs, STATUS_REGISTER, ACFBSY, 0); | ||
911 | + } | ||
912 | +} | ||
913 | + | ||
914 | +static uint64_t can_filter_mask_pre_write(RegisterInfo *reg, uint64_t val) | ||
915 | +{ | ||
916 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(reg->opaque); | ||
917 | + uint32_t reg_idx = (reg->access->addr) / 4; | ||
918 | + uint32_t filter_number = (reg_idx - R_AFMR1) / 2; | ||
919 | + | ||
920 | + /* modify an acceptance filter, the corresponding UAF bit should be '0'. */ | ||
921 | + if (!(s->regs[R_AFR] & (1 << filter_number))) { | ||
922 | + s->regs[reg_idx] = val; | ||
923 | + | ||
924 | + trace_xlnx_can_filter_mask_pre_write(filter_number, s->regs[reg_idx]); | ||
925 | + } else { | ||
926 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
927 | + | ||
928 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Acceptance filter %d" | ||
929 | + " mask is not set as corresponding UAF bit is not 0.\n", | ||
930 | + path, filter_number + 1); | ||
931 | + } | ||
932 | + | ||
933 | + return s->regs[reg_idx]; | ||
934 | +} | ||
935 | + | ||
936 | +static uint64_t can_filter_id_pre_write(RegisterInfo *reg, uint64_t val) | ||
937 | +{ | ||
938 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(reg->opaque); | ||
939 | + uint32_t reg_idx = (reg->access->addr) / 4; | ||
940 | + uint32_t filter_number = (reg_idx - R_AFIR1) / 2; | ||
941 | + | ||
942 | + if (!(s->regs[R_AFR] & (1 << filter_number))) { | ||
943 | + s->regs[reg_idx] = val; | ||
944 | + | ||
945 | + trace_xlnx_can_filter_id_pre_write(filter_number, s->regs[reg_idx]); | ||
946 | + } else { | ||
947 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
948 | + | ||
949 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Acceptance filter %d" | ||
950 | + " id is not set as corresponding UAF bit is not 0.\n", | ||
951 | + path, filter_number + 1); | ||
952 | + } | ||
953 | + | ||
954 | + return s->regs[reg_idx]; | ||
955 | +} | ||
956 | + | ||
957 | +static void can_tx_post_write(RegisterInfo *reg, uint64_t val) | ||
958 | +{ | ||
959 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(reg->opaque); | ||
960 | + | ||
961 | + bool is_txhpb = reg->access->addr > A_TXFIFO_DATA2; | ||
962 | + | ||
963 | + bool initiate_transfer = (reg->access->addr == A_TXFIFO_DATA2) || | ||
964 | + (reg->access->addr == A_TXHPB_DATA2); | ||
965 | + | ||
966 | + Fifo32 *f = is_txhpb ? &s->txhpb_fifo : &s->tx_fifo; | ||
967 | + | ||
968 | + if (!fifo32_is_full(f)) { | ||
969 | + fifo32_push(f, val); | ||
970 | + } else { | ||
971 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
972 | + | ||
973 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: TX FIFO is full.\n", path); | ||
974 | + } | ||
975 | + | ||
976 | + /* Initiate the message send if TX register is written. */ | ||
977 | + if (initiate_transfer && | ||
978 | + ARRAY_FIELD_EX32(s->regs, SOFTWARE_RESET_REGISTER, CEN)) { | ||
979 | + transfer_fifo(s, f); | ||
980 | + } | ||
981 | + | ||
982 | + can_update_irq(s); | ||
983 | +} | ||
984 | + | ||
985 | +static const RegisterAccessInfo can_regs_info[] = { | ||
986 | + { .name = "SOFTWARE_RESET_REGISTER", | ||
987 | + .addr = A_SOFTWARE_RESET_REGISTER, | ||
988 | + .rsvd = 0xfffffffc, | ||
989 | + .pre_write = can_srr_pre_write, | ||
990 | + },{ .name = "MODE_SELECT_REGISTER", | ||
991 | + .addr = A_MODE_SELECT_REGISTER, | ||
992 | + .rsvd = 0xfffffff8, | ||
993 | + .pre_write = can_msr_pre_write, | ||
994 | + },{ .name = "ARBITRATION_PHASE_BAUD_RATE_PRESCALER_REGISTER", | ||
995 | + .addr = A_ARBITRATION_PHASE_BAUD_RATE_PRESCALER_REGISTER, | ||
996 | + .rsvd = 0xffffff00, | ||
997 | + .pre_write = can_brpr_pre_write, | ||
998 | + },{ .name = "ARBITRATION_PHASE_BIT_TIMING_REGISTER", | ||
999 | + .addr = A_ARBITRATION_PHASE_BIT_TIMING_REGISTER, | ||
1000 | + .rsvd = 0xfffffe00, | ||
1001 | + .pre_write = can_btr_pre_write, | ||
1002 | + },{ .name = "ERROR_COUNTER_REGISTER", | ||
1003 | + .addr = A_ERROR_COUNTER_REGISTER, | ||
1004 | + .rsvd = 0xffff0000, | ||
1005 | + .ro = 0xffffffff, | ||
1006 | + },{ .name = "ERROR_STATUS_REGISTER", | ||
1007 | + .addr = A_ERROR_STATUS_REGISTER, | ||
1008 | + .rsvd = 0xffffffe0, | ||
1009 | + .w1c = 0x1f, | ||
1010 | + },{ .name = "STATUS_REGISTER", .addr = A_STATUS_REGISTER, | ||
1011 | + .reset = 0x1, | ||
1012 | + .rsvd = 0xffffe000, | ||
1013 | + .ro = 0x1fff, | ||
1014 | + },{ .name = "INTERRUPT_STATUS_REGISTER", | ||
1015 | + .addr = A_INTERRUPT_STATUS_REGISTER, | ||
1016 | + .reset = 0x6000, | ||
1017 | + .rsvd = 0xffff8000, | ||
1018 | + .ro = 0x7fff, | ||
1019 | + },{ .name = "INTERRUPT_ENABLE_REGISTER", | ||
1020 | + .addr = A_INTERRUPT_ENABLE_REGISTER, | ||
1021 | + .rsvd = 0xffff8000, | ||
1022 | + .post_write = can_ier_post_write, | ||
1023 | + },{ .name = "INTERRUPT_CLEAR_REGISTER", | ||
1024 | + .addr = A_INTERRUPT_CLEAR_REGISTER, | ||
1025 | + .rsvd = 0xffff8000, | ||
1026 | + .pre_write = can_icr_pre_write, | ||
1027 | + },{ .name = "TIMESTAMP_REGISTER", | ||
1028 | + .addr = A_TIMESTAMP_REGISTER, | ||
1029 | + .rsvd = 0xfffffffe, | ||
1030 | + .pre_write = can_tcr_pre_write, | ||
1031 | + },{ .name = "WIR", .addr = A_WIR, | ||
1032 | + .reset = 0x3f3f, | ||
1033 | + .rsvd = 0xffff0000, | ||
1034 | + },{ .name = "TXFIFO_ID", .addr = A_TXFIFO_ID, | ||
1035 | + .post_write = can_tx_post_write, | ||
1036 | + },{ .name = "TXFIFO_DLC", .addr = A_TXFIFO_DLC, | ||
1037 | + .rsvd = 0xfffffff, | ||
1038 | + .post_write = can_tx_post_write, | ||
1039 | + },{ .name = "TXFIFO_DATA1", .addr = A_TXFIFO_DATA1, | ||
1040 | + .post_write = can_tx_post_write, | ||
1041 | + },{ .name = "TXFIFO_DATA2", .addr = A_TXFIFO_DATA2, | ||
1042 | + .post_write = can_tx_post_write, | ||
1043 | + },{ .name = "TXHPB_ID", .addr = A_TXHPB_ID, | ||
1044 | + .post_write = can_tx_post_write, | ||
1045 | + },{ .name = "TXHPB_DLC", .addr = A_TXHPB_DLC, | ||
1046 | + .rsvd = 0xfffffff, | ||
1047 | + .post_write = can_tx_post_write, | ||
1048 | + },{ .name = "TXHPB_DATA1", .addr = A_TXHPB_DATA1, | ||
1049 | + .post_write = can_tx_post_write, | ||
1050 | + },{ .name = "TXHPB_DATA2", .addr = A_TXHPB_DATA2, | ||
1051 | + .post_write = can_tx_post_write, | ||
1052 | + },{ .name = "RXFIFO_ID", .addr = A_RXFIFO_ID, | ||
1053 | + .ro = 0xffffffff, | ||
1054 | + .post_read = can_rxfifo_pre_read, | ||
1055 | + },{ .name = "RXFIFO_DLC", .addr = A_RXFIFO_DLC, | ||
1056 | + .rsvd = 0xfff0000, | ||
1057 | + .post_read = can_rxfifo_pre_read, | ||
1058 | + },{ .name = "RXFIFO_DATA1", .addr = A_RXFIFO_DATA1, | ||
1059 | + .post_read = can_rxfifo_pre_read, | ||
1060 | + },{ .name = "RXFIFO_DATA2", .addr = A_RXFIFO_DATA2, | ||
1061 | + .post_read = can_rxfifo_pre_read, | ||
1062 | + },{ .name = "AFR", .addr = A_AFR, | ||
1063 | + .rsvd = 0xfffffff0, | ||
1064 | + .post_write = can_filter_enable_post_write, | ||
1065 | + },{ .name = "AFMR1", .addr = A_AFMR1, | ||
1066 | + .pre_write = can_filter_mask_pre_write, | ||
1067 | + },{ .name = "AFIR1", .addr = A_AFIR1, | ||
1068 | + .pre_write = can_filter_id_pre_write, | ||
1069 | + },{ .name = "AFMR2", .addr = A_AFMR2, | ||
1070 | + .pre_write = can_filter_mask_pre_write, | ||
1071 | + },{ .name = "AFIR2", .addr = A_AFIR2, | ||
1072 | + .pre_write = can_filter_id_pre_write, | ||
1073 | + },{ .name = "AFMR3", .addr = A_AFMR3, | ||
1074 | + .pre_write = can_filter_mask_pre_write, | ||
1075 | + },{ .name = "AFIR3", .addr = A_AFIR3, | ||
1076 | + .pre_write = can_filter_id_pre_write, | ||
1077 | + },{ .name = "AFMR4", .addr = A_AFMR4, | ||
1078 | + .pre_write = can_filter_mask_pre_write, | ||
1079 | + },{ .name = "AFIR4", .addr = A_AFIR4, | ||
1080 | + .pre_write = can_filter_id_pre_write, | ||
1081 | + } | ||
1082 | +}; | ||
1083 | + | ||
1084 | +static void xlnx_zynqmp_can_ptimer_cb(void *opaque) | ||
1085 | +{ | ||
1086 | + /* No action required on the timer rollover. */ | ||
1087 | +} | ||
1088 | + | ||
1089 | +static const MemoryRegionOps can_ops = { | ||
1090 | + .read = register_read_memory, | ||
1091 | + .write = register_write_memory, | ||
1092 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
1093 | + .valid = { | ||
1094 | + .min_access_size = 4, | ||
1095 | + .max_access_size = 4, | ||
1096 | + }, | ||
1097 | +}; | ||
1098 | + | ||
1099 | +static void xlnx_zynqmp_can_reset_init(Object *obj, ResetType type) | ||
1100 | +{ | ||
1101 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(obj); | ||
1102 | + unsigned int i; | ||
1103 | + | ||
1104 | + for (i = R_RXFIFO_ID; i < ARRAY_SIZE(s->reg_info); ++i) { | ||
1105 | + register_reset(&s->reg_info[i]); | ||
1106 | + } | ||
1107 | + | ||
1108 | + ptimer_transaction_begin(s->can_timer); | ||
1109 | + ptimer_set_count(s->can_timer, 0); | ||
1110 | + ptimer_transaction_commit(s->can_timer); | ||
1111 | +} | ||
1112 | + | ||
1113 | +static void xlnx_zynqmp_can_reset_hold(Object *obj) | ||
1114 | +{ | ||
1115 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(obj); | ||
1116 | + unsigned int i; | ||
1117 | + | ||
1118 | + for (i = 0; i < R_RXFIFO_ID; ++i) { | ||
1119 | + register_reset(&s->reg_info[i]); | ||
1120 | + } | ||
1121 | + | ||
1122 | + /* | ||
1123 | + * Reset FIFOs when CAN model is reset. This will clear the fifo writes | ||
1124 | + * done by post_write which gets called from register_reset function, | ||
1125 | + * post_write handle will not be able to trigger tx because CAN will be | ||
1126 | + * disabled when software_reset_register is cleared first. | ||
1127 | + */ | ||
1128 | + fifo32_reset(&s->rx_fifo); | ||
1129 | + fifo32_reset(&s->tx_fifo); | ||
1130 | + fifo32_reset(&s->txhpb_fifo); | ||
1131 | +} | ||
1132 | + | ||
1133 | +static bool xlnx_zynqmp_can_can_receive(CanBusClientState *client) | ||
1134 | +{ | ||
1135 | + XlnxZynqMPCANState *s = container_of(client, XlnxZynqMPCANState, | ||
1136 | + bus_client); | ||
1137 | + | ||
1138 | + if (ARRAY_FIELD_EX32(s->regs, SOFTWARE_RESET_REGISTER, SRST)) { | ||
1139 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
1140 | + | ||
1141 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Controller is in reset state.\n", | ||
1142 | + path); | ||
1143 | + return false; | ||
1144 | + } | ||
1145 | + | ||
1146 | + if ((ARRAY_FIELD_EX32(s->regs, SOFTWARE_RESET_REGISTER, CEN)) == 0) { | ||
1147 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
1148 | + | ||
1149 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Controller is disabled. Incoming" | ||
1150 | + " messages will be discarded.\n", path); | ||
1151 | + return false; | ||
1152 | + } | ||
1153 | + | ||
1154 | + return true; | ||
1155 | +} | ||
1156 | + | ||
1157 | +static ssize_t xlnx_zynqmp_can_receive(CanBusClientState *client, | ||
1158 | + const qemu_can_frame *buf, size_t buf_size) { | ||
1159 | + XlnxZynqMPCANState *s = container_of(client, XlnxZynqMPCANState, | ||
1160 | + bus_client); | ||
1161 | + const qemu_can_frame *frame = buf; | ||
1162 | + | ||
1163 | + if (buf_size <= 0) { | ||
1164 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
1165 | + | ||
1166 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Error in the data received.\n", | ||
1167 | + path); | ||
1168 | + return 0; | ||
1169 | + } | ||
1170 | + | ||
1171 | + if (ARRAY_FIELD_EX32(s->regs, STATUS_REGISTER, SNOOP)) { | ||
1172 | + /* Snoop Mode: Just keep the data. no response back. */ | ||
1173 | + update_rx_fifo(s, frame); | ||
1174 | + } else if ((ARRAY_FIELD_EX32(s->regs, STATUS_REGISTER, SLEEP))) { | ||
1175 | + /* | ||
1176 | + * XlnxZynqMPCAN is in sleep mode. Any data on bus will bring it to wake | ||
1177 | + * up state. | ||
1178 | + */ | ||
1179 | + can_exit_sleep_mode(s); | ||
1180 | + update_rx_fifo(s, frame); | ||
1181 | + } else if ((ARRAY_FIELD_EX32(s->regs, STATUS_REGISTER, SLEEP)) == 0) { | ||
1182 | + update_rx_fifo(s, frame); | ||
1183 | + } else { | ||
1184 | + /* | ||
1185 | + * XlnxZynqMPCAN will not participate in normal bus communication | ||
1186 | + * and will not receive any messages transmitted by other CAN nodes. | ||
1187 | + */ | ||
1188 | + trace_xlnx_can_rx_discard(s->regs[R_STATUS_REGISTER]); | ||
1189 | + } | ||
1190 | + | ||
1191 | + return 1; | ||
1192 | +} | ||
1193 | + | ||
1194 | +static CanBusClientInfo can_xilinx_bus_client_info = { | ||
1195 | + .can_receive = xlnx_zynqmp_can_can_receive, | ||
1196 | + .receive = xlnx_zynqmp_can_receive, | ||
1197 | +}; | ||
1198 | + | ||
1199 | +static int xlnx_zynqmp_can_connect_to_bus(XlnxZynqMPCANState *s, | ||
1200 | + CanBusState *bus) | ||
1201 | +{ | ||
1202 | + s->bus_client.info = &can_xilinx_bus_client_info; | ||
1203 | + | ||
1204 | + if (can_bus_insert_client(bus, &s->bus_client) < 0) { | ||
1205 | + return -1; | ||
1206 | + } | ||
1207 | + return 0; | ||
1208 | +} | ||
1209 | + | ||
1210 | +static void xlnx_zynqmp_can_realize(DeviceState *dev, Error **errp) | ||
1211 | +{ | ||
1212 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(dev); | ||
1213 | + | ||
1214 | + if (s->canbus) { | ||
1215 | + if (xlnx_zynqmp_can_connect_to_bus(s, s->canbus) < 0) { | ||
1216 | + g_autofree char *path = object_get_canonical_path(OBJECT(s)); | ||
1217 | + | ||
1218 | + error_setg(errp, "%s: xlnx_zynqmp_can_connect_to_bus" | ||
1219 | + " failed.", path); | ||
1220 | + return; | ||
1221 | + } | ||
1222 | + } | ||
1223 | + | ||
1224 | + /* Create RX FIFO, TXFIFO, TXHPB storage. */ | ||
1225 | + fifo32_create(&s->rx_fifo, RXFIFO_SIZE); | ||
1226 | + fifo32_create(&s->tx_fifo, RXFIFO_SIZE); | ||
1227 | + fifo32_create(&s->txhpb_fifo, CAN_FRAME_SIZE); | ||
1228 | + | ||
1229 | + /* Allocate a new timer. */ | ||
1230 | + s->can_timer = ptimer_init(xlnx_zynqmp_can_ptimer_cb, s, | ||
1231 | + PTIMER_POLICY_DEFAULT); | ||
1232 | + | ||
1233 | + ptimer_transaction_begin(s->can_timer); | ||
1234 | + | ||
1235 | + ptimer_set_freq(s->can_timer, s->cfg.ext_clk_freq); | ||
1236 | + ptimer_set_limit(s->can_timer, CAN_TIMER_MAX, 1); | ||
1237 | + ptimer_run(s->can_timer, 0); | ||
1238 | + ptimer_transaction_commit(s->can_timer); | ||
1239 | +} | ||
1240 | + | ||
1241 | +static void xlnx_zynqmp_can_init(Object *obj) | ||
1242 | +{ | ||
1243 | + XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(obj); | ||
1244 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
1245 | + | ||
1246 | + RegisterInfoArray *reg_array; | ||
1247 | + | ||
1248 | + memory_region_init(&s->iomem, obj, TYPE_XLNX_ZYNQMP_CAN, | ||
1249 | + XLNX_ZYNQMP_CAN_R_MAX * 4); | ||
1250 | + reg_array = register_init_block32(DEVICE(obj), can_regs_info, | ||
1251 | + ARRAY_SIZE(can_regs_info), | ||
1252 | + s->reg_info, s->regs, | ||
1253 | + &can_ops, | ||
1254 | + XLNX_ZYNQMP_CAN_ERR_DEBUG, | ||
1255 | + XLNX_ZYNQMP_CAN_R_MAX * 4); | ||
1256 | + | ||
1257 | + memory_region_add_subregion(&s->iomem, 0x00, ®_array->mem); | ||
1258 | + sysbus_init_mmio(sbd, &s->iomem); | ||
1259 | + sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->irq); | ||
1260 | +} | ||
1261 | + | ||
1262 | +static const VMStateDescription vmstate_can = { | ||
1263 | + .name = TYPE_XLNX_ZYNQMP_CAN, | ||
494 | + .version_id = 1, | 1264 | + .version_id = 1, |
495 | + .minimum_version_id = 1, | 1265 | + .minimum_version_id = 1, |
496 | + .fields = (VMStateField[]) { | 1266 | + .fields = (VMStateField[]) { |
497 | + VMSTATE_UINT32_ARRAY(ccm, IMX6ULCCMState, CCM_MAX), | 1267 | + VMSTATE_FIFO32(rx_fifo, XlnxZynqMPCANState), |
498 | + VMSTATE_UINT32_ARRAY(analog, IMX6ULCCMState, CCM_ANALOG_MAX), | 1268 | + VMSTATE_FIFO32(tx_fifo, XlnxZynqMPCANState), |
499 | + VMSTATE_END_OF_LIST() | 1269 | + VMSTATE_FIFO32(txhpb_fifo, XlnxZynqMPCANState), |
500 | + }, | 1270 | + VMSTATE_UINT32_ARRAY(regs, XlnxZynqMPCANState, XLNX_ZYNQMP_CAN_R_MAX), |
1271 | + VMSTATE_PTIMER(can_timer, XlnxZynqMPCANState), | ||
1272 | + VMSTATE_END_OF_LIST(), | ||
1273 | + } | ||
501 | +}; | 1274 | +}; |
502 | + | 1275 | + |
503 | +static uint64_t imx6ul_analog_get_osc_clk(IMX6ULCCMState *dev) | 1276 | +static Property xlnx_zynqmp_can_properties[] = { |
504 | +{ | 1277 | + DEFINE_PROP_UINT32("ext_clk_freq", XlnxZynqMPCANState, cfg.ext_clk_freq, |
505 | + uint64_t freq = CKIH_FREQ; | 1278 | + CAN_DEFAULT_CLOCK), |
506 | + | 1279 | + DEFINE_PROP_LINK("canbus", XlnxZynqMPCANState, canbus, TYPE_CAN_BUS, |
507 | + trace_ccm_freq((uint32_t)freq); | 1280 | + CanBusState *), |
508 | + | 1281 | + DEFINE_PROP_END_OF_LIST(), |
509 | + return freq; | ||
510 | +} | ||
511 | + | ||
512 | +static uint64_t imx6ul_analog_get_pll2_clk(IMX6ULCCMState *dev) | ||
513 | +{ | ||
514 | + uint64_t freq = imx6ul_analog_get_osc_clk(dev); | ||
515 | + | ||
516 | + if (FIELD_EX32(dev->analog[CCM_ANALOG_PLL_SYS], | ||
517 | + ANALOG_PLL_SYS, DIV_SELECT)) { | ||
518 | + freq *= 22; | ||
519 | + } else { | ||
520 | + freq *= 20; | ||
521 | + } | ||
522 | + | ||
523 | + trace_ccm_freq((uint32_t)freq); | ||
524 | + | ||
525 | + return freq; | ||
526 | +} | ||
527 | + | ||
528 | +static uint64_t imx6ul_analog_get_pll3_clk(IMX6ULCCMState *dev) | ||
529 | +{ | ||
530 | + uint64_t freq = imx6ul_analog_get_osc_clk(dev) * 20; | ||
531 | + | ||
532 | + trace_ccm_freq((uint32_t)freq); | ||
533 | + | ||
534 | + return freq; | ||
535 | +} | ||
536 | + | ||
537 | +static uint64_t imx6ul_analog_get_pll2_pfd0_clk(IMX6ULCCMState *dev) | ||
538 | +{ | ||
539 | + uint64_t freq = 0; | ||
540 | + | ||
541 | + freq = imx6ul_analog_get_pll2_clk(dev) * 18 | ||
542 | + / FIELD_EX32(dev->analog[CCM_ANALOG_PFD_528], | ||
543 | + ANALOG_PFD_528, PFD0_FRAC); | ||
544 | + | ||
545 | + trace_ccm_freq((uint32_t)freq); | ||
546 | + | ||
547 | + return freq; | ||
548 | +} | ||
549 | + | ||
550 | +static uint64_t imx6ul_analog_get_pll2_pfd2_clk(IMX6ULCCMState *dev) | ||
551 | +{ | ||
552 | + uint64_t freq = 0; | ||
553 | + | ||
554 | + freq = imx6ul_analog_get_pll2_clk(dev) * 18 | ||
555 | + / FIELD_EX32(dev->analog[CCM_ANALOG_PFD_528], | ||
556 | + ANALOG_PFD_528, PFD2_FRAC); | ||
557 | + | ||
558 | + trace_ccm_freq((uint32_t)freq); | ||
559 | + | ||
560 | + return freq; | ||
561 | +} | ||
562 | + | ||
563 | +static uint64_t imx6ul_analog_pll2_bypass_clk(IMX6ULCCMState *dev) | ||
564 | +{ | ||
565 | + uint64_t freq = 0; | ||
566 | + | ||
567 | + trace_ccm_freq((uint32_t)freq); | ||
568 | + | ||
569 | + return freq; | ||
570 | +} | ||
571 | + | ||
572 | +static uint64_t imx6ul_ccm_get_periph_clk2_sel_clk(IMX6ULCCMState *dev) | ||
573 | +{ | ||
574 | + uint64_t freq = 0; | ||
575 | + | ||
576 | + switch (FIELD_EX32(dev->ccm[CCM_CBCMR], CBCMR, PERIPH_CLK2_SEL)) { | ||
577 | + case 0: | ||
578 | + freq = imx6ul_analog_get_pll3_clk(dev); | ||
579 | + break; | ||
580 | + case 1: | ||
581 | + freq = imx6ul_analog_get_osc_clk(dev); | ||
582 | + break; | ||
583 | + case 2: | ||
584 | + freq = imx6ul_analog_pll2_bypass_clk(dev); | ||
585 | + break; | ||
586 | + case 3: | ||
587 | + /* We should never get there as 3 is a reserved value */ | ||
588 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
589 | + "[%s]%s: unsupported PERIPH_CLK2_SEL value 3\n", | ||
590 | + TYPE_IMX6UL_CCM, __func__); | ||
591 | + /* freq is set to 0 as we don't know what it should be */ | ||
592 | + break; | ||
593 | + default: | ||
594 | + g_assert_not_reached(); | ||
595 | + } | ||
596 | + | ||
597 | + trace_ccm_freq((uint32_t)freq); | ||
598 | + | ||
599 | + return freq; | ||
600 | +} | ||
601 | + | ||
602 | +static uint64_t imx6ul_ccm_get_periph_clk_sel_clk(IMX6ULCCMState *dev) | ||
603 | +{ | ||
604 | + uint64_t freq = 0; | ||
605 | + | ||
606 | + switch (FIELD_EX32(dev->ccm[CCM_CBCMR], CBCMR, PRE_PERIPH_CLK_SEL)) { | ||
607 | + case 0: | ||
608 | + freq = imx6ul_analog_get_pll2_clk(dev); | ||
609 | + break; | ||
610 | + case 1: | ||
611 | + freq = imx6ul_analog_get_pll2_pfd2_clk(dev); | ||
612 | + break; | ||
613 | + case 2: | ||
614 | + freq = imx6ul_analog_get_pll2_pfd0_clk(dev); | ||
615 | + break; | ||
616 | + case 3: | ||
617 | + freq = imx6ul_analog_get_pll2_pfd2_clk(dev) / 2; | ||
618 | + break; | ||
619 | + default: | ||
620 | + g_assert_not_reached(); | ||
621 | + } | ||
622 | + | ||
623 | + trace_ccm_freq((uint32_t)freq); | ||
624 | + | ||
625 | + return freq; | ||
626 | +} | ||
627 | + | ||
628 | +static uint64_t imx6ul_ccm_get_periph_clk2_clk(IMX6ULCCMState *dev) | ||
629 | +{ | ||
630 | + uint64_t freq = 0; | ||
631 | + | ||
632 | + freq = imx6ul_ccm_get_periph_clk2_sel_clk(dev) | ||
633 | + / (1 + FIELD_EX32(dev->ccm[CCM_CBCDR], CBCDR, PERIPH_CLK2_PODF)); | ||
634 | + | ||
635 | + trace_ccm_freq((uint32_t)freq); | ||
636 | + | ||
637 | + return freq; | ||
638 | +} | ||
639 | + | ||
640 | +static uint64_t imx6ul_ccm_get_periph_sel_clk(IMX6ULCCMState *dev) | ||
641 | +{ | ||
642 | + uint64_t freq = 0; | ||
643 | + | ||
644 | + switch (FIELD_EX32(dev->ccm[CCM_CBCDR], CBCDR, PERIPH_CLK_SEL)) { | ||
645 | + case 0: | ||
646 | + freq = imx6ul_ccm_get_periph_clk_sel_clk(dev); | ||
647 | + break; | ||
648 | + case 1: | ||
649 | + freq = imx6ul_ccm_get_periph_clk2_clk(dev); | ||
650 | + break; | ||
651 | + default: | ||
652 | + g_assert_not_reached(); | ||
653 | + } | ||
654 | + | ||
655 | + trace_ccm_freq((uint32_t)freq); | ||
656 | + | ||
657 | + return freq; | ||
658 | +} | ||
659 | + | ||
660 | +static uint64_t imx6ul_ccm_get_ahb_clk(IMX6ULCCMState *dev) | ||
661 | +{ | ||
662 | + uint64_t freq = 0; | ||
663 | + | ||
664 | + freq = imx6ul_ccm_get_periph_sel_clk(dev) | ||
665 | + / (1 + FIELD_EX32(dev->ccm[CCM_CBCDR], CBCDR, AHB_PODF)); | ||
666 | + | ||
667 | + trace_ccm_freq((uint32_t)freq); | ||
668 | + | ||
669 | + return freq; | ||
670 | +} | ||
671 | + | ||
672 | +static uint64_t imx6ul_ccm_get_ipg_clk(IMX6ULCCMState *dev) | ||
673 | +{ | ||
674 | + uint64_t freq = 0; | ||
675 | + | ||
676 | + freq = imx6ul_ccm_get_ahb_clk(dev) | ||
677 | + / (1 + FIELD_EX32(dev->ccm[CCM_CBCDR], CBCDR, IPG_PODF)); | ||
678 | + | ||
679 | + trace_ccm_freq((uint32_t)freq); | ||
680 | + | ||
681 | + return freq; | ||
682 | +} | ||
683 | + | ||
684 | +static uint64_t imx6ul_ccm_get_per_sel_clk(IMX6ULCCMState *dev) | ||
685 | +{ | ||
686 | + uint64_t freq = 0; | ||
687 | + | ||
688 | + switch (FIELD_EX32(dev->ccm[CCM_CSCMR1], CSCMR1, PERCLK_CLK_SEL)) { | ||
689 | + case 0: | ||
690 | + freq = imx6ul_ccm_get_ipg_clk(dev); | ||
691 | + break; | ||
692 | + case 1: | ||
693 | + freq = imx6ul_analog_get_osc_clk(dev); | ||
694 | + break; | ||
695 | + default: | ||
696 | + g_assert_not_reached(); | ||
697 | + } | ||
698 | + | ||
699 | + trace_ccm_freq((uint32_t)freq); | ||
700 | + | ||
701 | + return freq; | ||
702 | +} | ||
703 | + | ||
704 | +static uint64_t imx6ul_ccm_get_per_clk(IMX6ULCCMState *dev) | ||
705 | +{ | ||
706 | + uint64_t freq = 0; | ||
707 | + | ||
708 | + freq = imx6ul_ccm_get_per_sel_clk(dev) | ||
709 | + / (1 + FIELD_EX32(dev->ccm[CCM_CSCMR1], CSCMR1, PERCLK_PODF)); | ||
710 | + | ||
711 | + trace_ccm_freq((uint32_t)freq); | ||
712 | + | ||
713 | + return freq; | ||
714 | +} | ||
715 | + | ||
716 | +static uint32_t imx6ul_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock) | ||
717 | +{ | ||
718 | + uint32_t freq = 0; | ||
719 | + IMX6ULCCMState *s = IMX6UL_CCM(dev); | ||
720 | + | ||
721 | + switch (clock) { | ||
722 | + case CLK_NONE: | ||
723 | + break; | ||
724 | + case CLK_IPG: | ||
725 | + freq = imx6ul_ccm_get_ipg_clk(s); | ||
726 | + break; | ||
727 | + case CLK_IPG_HIGH: | ||
728 | + freq = imx6ul_ccm_get_per_clk(s); | ||
729 | + break; | ||
730 | + case CLK_32k: | ||
731 | + freq = CKIL_FREQ; | ||
732 | + break; | ||
733 | + case CLK_HIGH: | ||
734 | + freq = CKIH_FREQ; | ||
735 | + break; | ||
736 | + case CLK_HIGH_DIV: | ||
737 | + freq = CKIH_FREQ / 8; | ||
738 | + break; | ||
739 | + default: | ||
740 | + qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: unsupported clock %d\n", | ||
741 | + TYPE_IMX6UL_CCM, __func__, clock); | ||
742 | + break; | ||
743 | + } | ||
744 | + | ||
745 | + trace_ccm_clock_freq(clock, freq); | ||
746 | + | ||
747 | + return freq; | ||
748 | +} | ||
749 | + | ||
750 | +static void imx6ul_ccm_reset(DeviceState *dev) | ||
751 | +{ | ||
752 | + IMX6ULCCMState *s = IMX6UL_CCM(dev); | ||
753 | + | ||
754 | + trace_ccm_entry(); | ||
755 | + | ||
756 | + s->ccm[CCM_CCR] = 0x0401167F; | ||
757 | + s->ccm[CCM_CCDR] = 0x00000000; | ||
758 | + s->ccm[CCM_CSR] = 0x00000010; | ||
759 | + s->ccm[CCM_CCSR] = 0x00000100; | ||
760 | + s->ccm[CCM_CACRR] = 0x00000000; | ||
761 | + s->ccm[CCM_CBCDR] = 0x00018D00; | ||
762 | + s->ccm[CCM_CBCMR] = 0x24860324; | ||
763 | + s->ccm[CCM_CSCMR1] = 0x04900080; | ||
764 | + s->ccm[CCM_CSCMR2] = 0x03192F06; | ||
765 | + s->ccm[CCM_CSCDR1] = 0x00490B00; | ||
766 | + s->ccm[CCM_CS1CDR] = 0x0EC102C1; | ||
767 | + s->ccm[CCM_CS2CDR] = 0x000336C1; | ||
768 | + s->ccm[CCM_CDCDR] = 0x33F71F92; | ||
769 | + s->ccm[CCM_CHSCCDR] = 0x000248A4; | ||
770 | + s->ccm[CCM_CSCDR2] = 0x00029B48; | ||
771 | + s->ccm[CCM_CSCDR3] = 0x00014841; | ||
772 | + s->ccm[CCM_CDHIPR] = 0x00000000; | ||
773 | + s->ccm[CCM_CTOR] = 0x00000000; | ||
774 | + s->ccm[CCM_CLPCR] = 0x00000079; | ||
775 | + s->ccm[CCM_CISR] = 0x00000000; | ||
776 | + s->ccm[CCM_CIMR] = 0xFFFFFFFF; | ||
777 | + s->ccm[CCM_CCOSR] = 0x000A0001; | ||
778 | + s->ccm[CCM_CGPR] = 0x0000FE62; | ||
779 | + s->ccm[CCM_CCGR0] = 0xFFFFFFFF; | ||
780 | + s->ccm[CCM_CCGR1] = 0xFFFFFFFF; | ||
781 | + s->ccm[CCM_CCGR2] = 0xFC3FFFFF; | ||
782 | + s->ccm[CCM_CCGR3] = 0xFFFFFFFF; | ||
783 | + s->ccm[CCM_CCGR4] = 0xFFFFFFFF; | ||
784 | + s->ccm[CCM_CCGR5] = 0xFFFFFFFF; | ||
785 | + s->ccm[CCM_CCGR6] = 0xFFFFFFFF; | ||
786 | + s->ccm[CCM_CMEOR] = 0xFFFFFFFF; | ||
787 | + | ||
788 | + s->analog[CCM_ANALOG_PLL_ARM] = 0x00013063; | ||
789 | + s->analog[CCM_ANALOG_PLL_USB1] = 0x00012000; | ||
790 | + s->analog[CCM_ANALOG_PLL_USB2] = 0x00012000; | ||
791 | + s->analog[CCM_ANALOG_PLL_SYS] = 0x00013001; | ||
792 | + s->analog[CCM_ANALOG_PLL_SYS_SS] = 0x00000000; | ||
793 | + s->analog[CCM_ANALOG_PLL_SYS_NUM] = 0x00000000; | ||
794 | + s->analog[CCM_ANALOG_PLL_SYS_DENOM] = 0x00000012; | ||
795 | + s->analog[CCM_ANALOG_PLL_AUDIO] = 0x00011006; | ||
796 | + s->analog[CCM_ANALOG_PLL_AUDIO_NUM] = 0x05F5E100; | ||
797 | + s->analog[CCM_ANALOG_PLL_AUDIO_DENOM] = 0x2964619C; | ||
798 | + s->analog[CCM_ANALOG_PLL_VIDEO] = 0x0001100C; | ||
799 | + s->analog[CCM_ANALOG_PLL_VIDEO_NUM] = 0x05F5E100; | ||
800 | + s->analog[CCM_ANALOG_PLL_VIDEO_DENOM] = 0x10A24447; | ||
801 | + s->analog[CCM_ANALOG_PLL_ENET] = 0x00011001; | ||
802 | + s->analog[CCM_ANALOG_PFD_480] = 0x1311100C; | ||
803 | + s->analog[CCM_ANALOG_PFD_528] = 0x1018101B; | ||
804 | + | ||
805 | + s->analog[PMU_REG_1P1] = 0x00001073; | ||
806 | + s->analog[PMU_REG_3P0] = 0x00000F74; | ||
807 | + s->analog[PMU_REG_2P5] = 0x00001073; | ||
808 | + s->analog[PMU_REG_CORE] = 0x00482012; | ||
809 | + s->analog[PMU_MISC0] = 0x04000000; | ||
810 | + s->analog[PMU_MISC1] = 0x00000000; | ||
811 | + s->analog[PMU_MISC2] = 0x00272727; | ||
812 | + s->analog[PMU_LOWPWR_CTRL] = 0x00004009; | ||
813 | + | ||
814 | + s->analog[USB_ANALOG_USB1_VBUS_DETECT] = 0x01000004; | ||
815 | + s->analog[USB_ANALOG_USB1_CHRG_DETECT] = 0x00000000; | ||
816 | + s->analog[USB_ANALOG_USB1_VBUS_DETECT_STAT] = 0x00000000; | ||
817 | + s->analog[USB_ANALOG_USB1_CHRG_DETECT_STAT] = 0x00000000; | ||
818 | + s->analog[USB_ANALOG_USB1_MISC] = 0x00000002; | ||
819 | + s->analog[USB_ANALOG_USB2_VBUS_DETECT] = 0x01000004; | ||
820 | + s->analog[USB_ANALOG_USB2_CHRG_DETECT] = 0x00000000; | ||
821 | + s->analog[USB_ANALOG_USB2_MISC] = 0x00000002; | ||
822 | + s->analog[USB_ANALOG_DIGPROG] = 0x00640000; | ||
823 | + | ||
824 | + /* all PLLs need to be locked */ | ||
825 | + s->analog[CCM_ANALOG_PLL_ARM] |= CCM_ANALOG_PLL_LOCK; | ||
826 | + s->analog[CCM_ANALOG_PLL_USB1] |= CCM_ANALOG_PLL_LOCK; | ||
827 | + s->analog[CCM_ANALOG_PLL_USB2] |= CCM_ANALOG_PLL_LOCK; | ||
828 | + s->analog[CCM_ANALOG_PLL_SYS] |= CCM_ANALOG_PLL_LOCK; | ||
829 | + s->analog[CCM_ANALOG_PLL_AUDIO] |= CCM_ANALOG_PLL_LOCK; | ||
830 | + s->analog[CCM_ANALOG_PLL_VIDEO] |= CCM_ANALOG_PLL_LOCK; | ||
831 | + s->analog[CCM_ANALOG_PLL_ENET] |= CCM_ANALOG_PLL_LOCK; | ||
832 | + | ||
833 | + s->analog[TEMPMON_TEMPSENSE0] = 0x00000001; | ||
834 | + s->analog[TEMPMON_TEMPSENSE1] = 0x00000001; | ||
835 | + s->analog[TEMPMON_TEMPSENSE2] = 0x00000000; | ||
836 | +} | ||
837 | + | ||
838 | +static uint64_t imx6ul_ccm_read(void *opaque, hwaddr offset, unsigned size) | ||
839 | +{ | ||
840 | + uint32_t value = 0; | ||
841 | + uint32_t index = offset >> 2; | ||
842 | + IMX6ULCCMState *s = (IMX6ULCCMState *)opaque; | ||
843 | + | ||
844 | + assert(index < CCM_MAX); | ||
845 | + | ||
846 | + value = s->ccm[index]; | ||
847 | + | ||
848 | + trace_ccm_read_reg(imx6ul_ccm_reg_name(index), (uint32_t)value); | ||
849 | + | ||
850 | + return (uint64_t)value; | ||
851 | +} | ||
852 | + | ||
853 | +static void imx6ul_ccm_write(void *opaque, hwaddr offset, uint64_t value, | ||
854 | + unsigned size) | ||
855 | +{ | ||
856 | + uint32_t index = offset >> 2; | ||
857 | + IMX6ULCCMState *s = (IMX6ULCCMState *)opaque; | ||
858 | + | ||
859 | + assert(index < CCM_MAX); | ||
860 | + | ||
861 | + trace_ccm_write_reg(imx6ul_ccm_reg_name(index), (uint32_t)value); | ||
862 | + | ||
863 | + /* | ||
864 | + * We will do a better implementation later. In particular some bits | ||
865 | + * cannot be written to. | ||
866 | + */ | ||
867 | + s->ccm[index] = (uint32_t)value; | ||
868 | +} | ||
869 | + | ||
870 | +static uint64_t imx6ul_analog_read(void *opaque, hwaddr offset, unsigned size) | ||
871 | +{ | ||
872 | + uint32_t value; | ||
873 | + uint32_t index = offset >> 2; | ||
874 | + IMX6ULCCMState *s = (IMX6ULCCMState *)opaque; | ||
875 | + | ||
876 | + assert(index < CCM_ANALOG_MAX); | ||
877 | + | ||
878 | + switch (index) { | ||
879 | + case CCM_ANALOG_PLL_ARM_SET: | ||
880 | + case CCM_ANALOG_PLL_USB1_SET: | ||
881 | + case CCM_ANALOG_PLL_USB2_SET: | ||
882 | + case CCM_ANALOG_PLL_SYS_SET: | ||
883 | + case CCM_ANALOG_PLL_AUDIO_SET: | ||
884 | + case CCM_ANALOG_PLL_VIDEO_SET: | ||
885 | + case CCM_ANALOG_PLL_ENET_SET: | ||
886 | + case CCM_ANALOG_PFD_480_SET: | ||
887 | + case CCM_ANALOG_PFD_528_SET: | ||
888 | + case CCM_ANALOG_MISC0_SET: | ||
889 | + case PMU_MISC1_SET: | ||
890 | + case CCM_ANALOG_MISC2_SET: | ||
891 | + case USB_ANALOG_USB1_VBUS_DETECT_SET: | ||
892 | + case USB_ANALOG_USB1_CHRG_DETECT_SET: | ||
893 | + case USB_ANALOG_USB1_MISC_SET: | ||
894 | + case USB_ANALOG_USB2_VBUS_DETECT_SET: | ||
895 | + case USB_ANALOG_USB2_CHRG_DETECT_SET: | ||
896 | + case USB_ANALOG_USB2_MISC_SET: | ||
897 | + case TEMPMON_TEMPSENSE0_SET: | ||
898 | + case TEMPMON_TEMPSENSE1_SET: | ||
899 | + case TEMPMON_TEMPSENSE2_SET: | ||
900 | + /* | ||
901 | + * All REG_NAME_SET register access are in fact targeting | ||
902 | + * the REG_NAME register. | ||
903 | + */ | ||
904 | + value = s->analog[index - 1]; | ||
905 | + break; | ||
906 | + case CCM_ANALOG_PLL_ARM_CLR: | ||
907 | + case CCM_ANALOG_PLL_USB1_CLR: | ||
908 | + case CCM_ANALOG_PLL_USB2_CLR: | ||
909 | + case CCM_ANALOG_PLL_SYS_CLR: | ||
910 | + case CCM_ANALOG_PLL_AUDIO_CLR: | ||
911 | + case CCM_ANALOG_PLL_VIDEO_CLR: | ||
912 | + case CCM_ANALOG_PLL_ENET_CLR: | ||
913 | + case CCM_ANALOG_PFD_480_CLR: | ||
914 | + case CCM_ANALOG_PFD_528_CLR: | ||
915 | + case CCM_ANALOG_MISC0_CLR: | ||
916 | + case PMU_MISC1_CLR: | ||
917 | + case CCM_ANALOG_MISC2_CLR: | ||
918 | + case USB_ANALOG_USB1_VBUS_DETECT_CLR: | ||
919 | + case USB_ANALOG_USB1_CHRG_DETECT_CLR: | ||
920 | + case USB_ANALOG_USB1_MISC_CLR: | ||
921 | + case USB_ANALOG_USB2_VBUS_DETECT_CLR: | ||
922 | + case USB_ANALOG_USB2_CHRG_DETECT_CLR: | ||
923 | + case USB_ANALOG_USB2_MISC_CLR: | ||
924 | + case TEMPMON_TEMPSENSE0_CLR: | ||
925 | + case TEMPMON_TEMPSENSE1_CLR: | ||
926 | + case TEMPMON_TEMPSENSE2_CLR: | ||
927 | + /* | ||
928 | + * All REG_NAME_CLR register access are in fact targeting | ||
929 | + * the REG_NAME register. | ||
930 | + */ | ||
931 | + value = s->analog[index - 2]; | ||
932 | + break; | ||
933 | + case CCM_ANALOG_PLL_ARM_TOG: | ||
934 | + case CCM_ANALOG_PLL_USB1_TOG: | ||
935 | + case CCM_ANALOG_PLL_USB2_TOG: | ||
936 | + case CCM_ANALOG_PLL_SYS_TOG: | ||
937 | + case CCM_ANALOG_PLL_AUDIO_TOG: | ||
938 | + case CCM_ANALOG_PLL_VIDEO_TOG: | ||
939 | + case CCM_ANALOG_PLL_ENET_TOG: | ||
940 | + case CCM_ANALOG_PFD_480_TOG: | ||
941 | + case CCM_ANALOG_PFD_528_TOG: | ||
942 | + case CCM_ANALOG_MISC0_TOG: | ||
943 | + case PMU_MISC1_TOG: | ||
944 | + case CCM_ANALOG_MISC2_TOG: | ||
945 | + case USB_ANALOG_USB1_VBUS_DETECT_TOG: | ||
946 | + case USB_ANALOG_USB1_CHRG_DETECT_TOG: | ||
947 | + case USB_ANALOG_USB1_MISC_TOG: | ||
948 | + case USB_ANALOG_USB2_VBUS_DETECT_TOG: | ||
949 | + case USB_ANALOG_USB2_CHRG_DETECT_TOG: | ||
950 | + case USB_ANALOG_USB2_MISC_TOG: | ||
951 | + case TEMPMON_TEMPSENSE0_TOG: | ||
952 | + case TEMPMON_TEMPSENSE1_TOG: | ||
953 | + case TEMPMON_TEMPSENSE2_TOG: | ||
954 | + /* | ||
955 | + * All REG_NAME_TOG register access are in fact targeting | ||
956 | + * the REG_NAME register. | ||
957 | + */ | ||
958 | + value = s->analog[index - 3]; | ||
959 | + break; | ||
960 | + default: | ||
961 | + value = s->analog[index]; | ||
962 | + break; | ||
963 | + } | ||
964 | + | ||
965 | + trace_ccm_read_reg(imx6ul_analog_reg_name(index), (uint32_t)value); | ||
966 | + | ||
967 | + return (uint64_t)value; | ||
968 | +} | ||
969 | + | ||
970 | +static void imx6ul_analog_write(void *opaque, hwaddr offset, uint64_t value, | ||
971 | + unsigned size) | ||
972 | +{ | ||
973 | + uint32_t index = offset >> 2; | ||
974 | + IMX6ULCCMState *s = (IMX6ULCCMState *)opaque; | ||
975 | + | ||
976 | + assert(index < CCM_ANALOG_MAX); | ||
977 | + | ||
978 | + trace_ccm_write_reg(imx6ul_analog_reg_name(index), (uint32_t)value); | ||
979 | + | ||
980 | + switch (index) { | ||
981 | + case CCM_ANALOG_PLL_ARM_SET: | ||
982 | + case CCM_ANALOG_PLL_USB1_SET: | ||
983 | + case CCM_ANALOG_PLL_USB2_SET: | ||
984 | + case CCM_ANALOG_PLL_SYS_SET: | ||
985 | + case CCM_ANALOG_PLL_AUDIO_SET: | ||
986 | + case CCM_ANALOG_PLL_VIDEO_SET: | ||
987 | + case CCM_ANALOG_PLL_ENET_SET: | ||
988 | + case CCM_ANALOG_PFD_480_SET: | ||
989 | + case CCM_ANALOG_PFD_528_SET: | ||
990 | + case CCM_ANALOG_MISC0_SET: | ||
991 | + case PMU_MISC1_SET: | ||
992 | + case CCM_ANALOG_MISC2_SET: | ||
993 | + case USB_ANALOG_USB1_VBUS_DETECT_SET: | ||
994 | + case USB_ANALOG_USB1_CHRG_DETECT_SET: | ||
995 | + case USB_ANALOG_USB1_MISC_SET: | ||
996 | + case USB_ANALOG_USB2_VBUS_DETECT_SET: | ||
997 | + case USB_ANALOG_USB2_CHRG_DETECT_SET: | ||
998 | + case USB_ANALOG_USB2_MISC_SET: | ||
999 | + /* | ||
1000 | + * All REG_NAME_SET register access are in fact targeting | ||
1001 | + * the REG_NAME register. So we change the value of the | ||
1002 | + * REG_NAME register, setting bits passed in the value. | ||
1003 | + */ | ||
1004 | + s->analog[index - 1] |= value; | ||
1005 | + break; | ||
1006 | + case CCM_ANALOG_PLL_ARM_CLR: | ||
1007 | + case CCM_ANALOG_PLL_USB1_CLR: | ||
1008 | + case CCM_ANALOG_PLL_USB2_CLR: | ||
1009 | + case CCM_ANALOG_PLL_SYS_CLR: | ||
1010 | + case CCM_ANALOG_PLL_AUDIO_CLR: | ||
1011 | + case CCM_ANALOG_PLL_VIDEO_CLR: | ||
1012 | + case CCM_ANALOG_PLL_ENET_CLR: | ||
1013 | + case CCM_ANALOG_PFD_480_CLR: | ||
1014 | + case CCM_ANALOG_PFD_528_CLR: | ||
1015 | + case CCM_ANALOG_MISC0_CLR: | ||
1016 | + case PMU_MISC1_CLR: | ||
1017 | + case CCM_ANALOG_MISC2_CLR: | ||
1018 | + case USB_ANALOG_USB1_VBUS_DETECT_CLR: | ||
1019 | + case USB_ANALOG_USB1_CHRG_DETECT_CLR: | ||
1020 | + case USB_ANALOG_USB1_MISC_CLR: | ||
1021 | + case USB_ANALOG_USB2_VBUS_DETECT_CLR: | ||
1022 | + case USB_ANALOG_USB2_CHRG_DETECT_CLR: | ||
1023 | + case USB_ANALOG_USB2_MISC_CLR: | ||
1024 | + /* | ||
1025 | + * All REG_NAME_CLR register access are in fact targeting | ||
1026 | + * the REG_NAME register. So we change the value of the | ||
1027 | + * REG_NAME register, unsetting bits passed in the value. | ||
1028 | + */ | ||
1029 | + s->analog[index - 2] &= ~value; | ||
1030 | + break; | ||
1031 | + case CCM_ANALOG_PLL_ARM_TOG: | ||
1032 | + case CCM_ANALOG_PLL_USB1_TOG: | ||
1033 | + case CCM_ANALOG_PLL_USB2_TOG: | ||
1034 | + case CCM_ANALOG_PLL_SYS_TOG: | ||
1035 | + case CCM_ANALOG_PLL_AUDIO_TOG: | ||
1036 | + case CCM_ANALOG_PLL_VIDEO_TOG: | ||
1037 | + case CCM_ANALOG_PLL_ENET_TOG: | ||
1038 | + case CCM_ANALOG_PFD_480_TOG: | ||
1039 | + case CCM_ANALOG_PFD_528_TOG: | ||
1040 | + case CCM_ANALOG_MISC0_TOG: | ||
1041 | + case PMU_MISC1_TOG: | ||
1042 | + case CCM_ANALOG_MISC2_TOG: | ||
1043 | + case USB_ANALOG_USB1_VBUS_DETECT_TOG: | ||
1044 | + case USB_ANALOG_USB1_CHRG_DETECT_TOG: | ||
1045 | + case USB_ANALOG_USB1_MISC_TOG: | ||
1046 | + case USB_ANALOG_USB2_VBUS_DETECT_TOG: | ||
1047 | + case USB_ANALOG_USB2_CHRG_DETECT_TOG: | ||
1048 | + case USB_ANALOG_USB2_MISC_TOG: | ||
1049 | + /* | ||
1050 | + * All REG_NAME_TOG register access are in fact targeting | ||
1051 | + * the REG_NAME register. So we change the value of the | ||
1052 | + * REG_NAME register, toggling bits passed in the value. | ||
1053 | + */ | ||
1054 | + s->analog[index - 3] ^= value; | ||
1055 | + break; | ||
1056 | + default: | ||
1057 | + /* | ||
1058 | + * We will do a better implementation later. In particular some bits | ||
1059 | + * cannot be written to. | ||
1060 | + */ | ||
1061 | + s->analog[index] = value; | ||
1062 | + break; | ||
1063 | + } | ||
1064 | +} | ||
1065 | + | ||
1066 | +static const struct MemoryRegionOps imx6ul_ccm_ops = { | ||
1067 | + .read = imx6ul_ccm_read, | ||
1068 | + .write = imx6ul_ccm_write, | ||
1069 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
1070 | + .valid = { | ||
1071 | + /* | ||
1072 | + * Our device would not work correctly if the guest was doing | ||
1073 | + * unaligned access. This might not be a limitation on the real | ||
1074 | + * device but in practice there is no reason for a guest to access | ||
1075 | + * this device unaligned. | ||
1076 | + */ | ||
1077 | + .min_access_size = 4, | ||
1078 | + .max_access_size = 4, | ||
1079 | + .unaligned = false, | ||
1080 | + }, | ||
1081 | +}; | 1282 | +}; |
1082 | + | 1283 | + |
1083 | +static const struct MemoryRegionOps imx6ul_analog_ops = { | 1284 | +static void xlnx_zynqmp_can_class_init(ObjectClass *klass, void *data) |
1084 | + .read = imx6ul_analog_read, | 1285 | +{ |
1085 | + .write = imx6ul_analog_write, | 1286 | + DeviceClass *dc = DEVICE_CLASS(klass); |
1086 | + .endianness = DEVICE_NATIVE_ENDIAN, | 1287 | + ResettableClass *rc = RESETTABLE_CLASS(klass); |
1087 | + .valid = { | 1288 | + |
1088 | + /* | 1289 | + rc->phases.enter = xlnx_zynqmp_can_reset_init; |
1089 | + * Our device would not work correctly if the guest was doing | 1290 | + rc->phases.hold = xlnx_zynqmp_can_reset_hold; |
1090 | + * unaligned access. This might not be a limitation on the real | 1291 | + dc->realize = xlnx_zynqmp_can_realize; |
1091 | + * device but in practice there is no reason for a guest to access | 1292 | + device_class_set_props(dc, xlnx_zynqmp_can_properties); |
1092 | + * this device unaligned. | 1293 | + dc->vmsd = &vmstate_can; |
1093 | + */ | 1294 | +} |
1094 | + .min_access_size = 4, | 1295 | + |
1095 | + .max_access_size = 4, | 1296 | +static const TypeInfo can_info = { |
1096 | + .unaligned = false, | 1297 | + .name = TYPE_XLNX_ZYNQMP_CAN, |
1097 | + }, | 1298 | + .parent = TYPE_SYS_BUS_DEVICE, |
1299 | + .instance_size = sizeof(XlnxZynqMPCANState), | ||
1300 | + .class_init = xlnx_zynqmp_can_class_init, | ||
1301 | + .instance_init = xlnx_zynqmp_can_init, | ||
1098 | +}; | 1302 | +}; |
1099 | + | 1303 | + |
1100 | +static void imx6ul_ccm_init(Object *obj) | 1304 | +static void can_register_types(void) |
1101 | +{ | 1305 | +{ |
1102 | + DeviceState *dev = DEVICE(obj); | 1306 | + type_register_static(&can_info); |
1103 | + SysBusDevice *sd = SYS_BUS_DEVICE(obj); | 1307 | +} |
1104 | + IMX6ULCCMState *s = IMX6UL_CCM(obj); | 1308 | + |
1105 | + | 1309 | +type_init(can_register_types) |
1106 | + /* initialize a container for the all memory range */ | 1310 | diff --git a/hw/Kconfig b/hw/Kconfig |
1107 | + memory_region_init(&s->container, OBJECT(dev), TYPE_IMX6UL_CCM, 0x8000); | ||
1108 | + | ||
1109 | + /* We initialize an IO memory region for the CCM part */ | ||
1110 | + memory_region_init_io(&s->ioccm, OBJECT(dev), &imx6ul_ccm_ops, s, | ||
1111 | + TYPE_IMX6UL_CCM ".ccm", CCM_MAX * sizeof(uint32_t)); | ||
1112 | + | ||
1113 | + /* Add the CCM as a subregion at offset 0 */ | ||
1114 | + memory_region_add_subregion(&s->container, 0, &s->ioccm); | ||
1115 | + | ||
1116 | + /* We initialize an IO memory region for the ANALOG part */ | ||
1117 | + memory_region_init_io(&s->ioanalog, OBJECT(dev), &imx6ul_analog_ops, s, | ||
1118 | + TYPE_IMX6UL_CCM ".analog", | ||
1119 | + CCM_ANALOG_MAX * sizeof(uint32_t)); | ||
1120 | + | ||
1121 | + /* Add the ANALOG as a subregion at offset 0x4000 */ | ||
1122 | + memory_region_add_subregion(&s->container, 0x4000, &s->ioanalog); | ||
1123 | + | ||
1124 | + sysbus_init_mmio(sd, &s->container); | ||
1125 | +} | ||
1126 | + | ||
1127 | +static void imx6ul_ccm_class_init(ObjectClass *klass, void *data) | ||
1128 | +{ | ||
1129 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
1130 | + IMXCCMClass *ccm = IMX_CCM_CLASS(klass); | ||
1131 | + | ||
1132 | + dc->reset = imx6ul_ccm_reset; | ||
1133 | + dc->vmsd = &vmstate_imx6ul_ccm; | ||
1134 | + dc->desc = "i.MX6UL Clock Control Module"; | ||
1135 | + | ||
1136 | + ccm->get_clock_frequency = imx6ul_ccm_get_clock_frequency; | ||
1137 | +} | ||
1138 | + | ||
1139 | +static const TypeInfo imx6ul_ccm_info = { | ||
1140 | + .name = TYPE_IMX6UL_CCM, | ||
1141 | + .parent = TYPE_IMX_CCM, | ||
1142 | + .instance_size = sizeof(IMX6ULCCMState), | ||
1143 | + .instance_init = imx6ul_ccm_init, | ||
1144 | + .class_init = imx6ul_ccm_class_init, | ||
1145 | +}; | ||
1146 | + | ||
1147 | +static void imx6ul_ccm_register_types(void) | ||
1148 | +{ | ||
1149 | + type_register_static(&imx6ul_ccm_info); | ||
1150 | +} | ||
1151 | + | ||
1152 | +type_init(imx6ul_ccm_register_types) | ||
1153 | diff --git a/hw/misc/trace-events b/hw/misc/trace-events | ||
1154 | index XXXXXXX..XXXXXXX 100644 | 1311 | index XXXXXXX..XXXXXXX 100644 |
1155 | --- a/hw/misc/trace-events | 1312 | --- a/hw/Kconfig |
1156 | +++ b/hw/misc/trace-events | 1313 | +++ b/hw/Kconfig |
1157 | @@ -XXX,XX +XXX,XX @@ iotkit_secctl_s_write(uint32_t offset, uint64_t data, unsigned size) "IoTKit Sec | 1314 | @@ -XXX,XX +XXX,XX @@ config XILINX_AXI |
1158 | 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" | 1315 | config XLNX_ZYNQMP |
1159 | 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" | 1316 | bool |
1160 | iotkit_secctl_reset(void) "IoTKit SecCtl: reset" | 1317 | select REGISTER |
1161 | + | 1318 | + select CAN_BUS |
1162 | +# hw/misc/imx6ul_ccm.c | 1319 | diff --git a/hw/net/can/meson.build b/hw/net/can/meson.build |
1163 | +ccm_entry(void) "\n" | 1320 | index XXXXXXX..XXXXXXX 100644 |
1164 | +ccm_freq(uint32_t freq) "freq = %d\n" | 1321 | --- a/hw/net/can/meson.build |
1165 | +ccm_clock_freq(uint32_t clock, uint32_t freq) "(Clock = %d) = %d\n" | 1322 | +++ b/hw/net/can/meson.build |
1166 | +ccm_read_reg(const char *reg_name, uint32_t value) "reg[%s] <= 0x%" PRIx32 "\n" | 1323 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_CAN_PCI', if_true: files('can_pcm3680_pci.c')) |
1167 | +ccm_write_reg(const char *reg_name, uint32_t value) "reg[%s] => 0x%" PRIx32 "\n" | 1324 | softmmu_ss.add(when: 'CONFIG_CAN_PCI', if_true: files('can_mioe3680_pci.c')) |
1325 | softmmu_ss.add(when: 'CONFIG_CAN_CTUCANFD', if_true: files('ctucan_core.c')) | ||
1326 | softmmu_ss.add(when: 'CONFIG_CAN_CTUCANFD_PCI', if_true: files('ctucan_pci.c')) | ||
1327 | +softmmu_ss.add(when: 'CONFIG_XLNX_ZYNQMP', if_true: files('xlnx-zynqmp-can.c')) | ||
1328 | diff --git a/hw/net/can/trace-events b/hw/net/can/trace-events | ||
1329 | new file mode 100644 | ||
1330 | index XXXXXXX..XXXXXXX | ||
1331 | --- /dev/null | ||
1332 | +++ b/hw/net/can/trace-events | ||
1333 | @@ -XXX,XX +XXX,XX @@ | ||
1334 | +# xlnx-zynqmp-can.c | ||
1335 | +xlnx_can_update_irq(uint32_t isr, uint32_t ier, uint32_t irq) "ISR: 0x%08x IER: 0x%08x IRQ: 0x%08x" | ||
1336 | +xlnx_can_reset(uint32_t val) "Resetting controller with value = 0x%08x" | ||
1337 | +xlnx_can_rx_fifo_filter_reject(uint32_t id, uint8_t dlc) "Frame: ID: 0x%08x DLC: 0x%02x" | ||
1338 | +xlnx_can_filter_id_pre_write(uint8_t filter_num, uint32_t value) "Filter%d ID: 0x%08x" | ||
1339 | +xlnx_can_filter_mask_pre_write(uint8_t filter_num, uint32_t value) "Filter%d MASK: 0x%08x" | ||
1340 | +xlnx_can_tx_data(uint32_t id, uint8_t dlc, uint8_t db0, uint8_t db1, uint8_t db2, uint8_t db3, uint8_t db4, uint8_t db5, uint8_t db6, uint8_t db7) "Frame: ID: 0x%08x DLC: 0x%02x DATA: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x" | ||
1341 | +xlnx_can_rx_data(uint32_t id, uint32_t dlc, uint8_t db0, uint8_t db1, uint8_t db2, uint8_t db3, uint8_t db4, uint8_t db5, uint8_t db6, uint8_t db7) "Frame: ID: 0x%08x DLC: 0x%02x DATA: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x" | ||
1342 | +xlnx_can_rx_discard(uint32_t status) "Controller is not enabled for bus communication. Status Register: 0x%08x" | ||
1168 | -- | 1343 | -- |
1169 | 2.18.0 | 1344 | 2.20.1 |
1170 | 1345 | ||
1171 | 1346 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Vikram Garhwal <fnu.vikram@xilinx.com> |
---|---|---|---|
2 | 2 | ||
3 | The expression (int) imm + (uint32_t) len_align turns into uint32_t | 3 | Connect CAN0 and CAN1 on the ZynqMP. |
4 | and thus with negative imm produces a memory operation at the wrong | ||
5 | offset. None of the numbers involved are particularly large, so | ||
6 | change everything to use int. | ||
7 | 4 | ||
8 | Cc: qemu-stable@nongnu.org (3.0.1) | 5 | Reviewed-by: Francisco Iglesias <francisco.iglesias@xilinx.com> |
9 | Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com> | 6 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> |
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Vikram Garhwal <fnu.vikram@xilinx.com> |
11 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 8 | Message-id: 1605728926-352690-3-git-send-email-fnu.vikram@xilinx.com |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 10 | --- |
14 | target/arm/translate-sve.c | 18 ++++++++---------- | 11 | include/hw/arm/xlnx-zynqmp.h | 8 ++++++++ |
15 | 1 file changed, 8 insertions(+), 10 deletions(-) | 12 | hw/arm/xlnx-zcu102.c | 20 ++++++++++++++++++++ |
13 | hw/arm/xlnx-zynqmp.c | 34 ++++++++++++++++++++++++++++++++++ | ||
14 | 3 files changed, 62 insertions(+) | ||
16 | 15 | ||
17 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | 16 | diff --git a/include/hw/arm/xlnx-zynqmp.h b/include/hw/arm/xlnx-zynqmp.h |
18 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/translate-sve.c | 18 | --- a/include/hw/arm/xlnx-zynqmp.h |
20 | +++ b/target/arm/translate-sve.c | 19 | +++ b/include/hw/arm/xlnx-zynqmp.h |
21 | @@ -XXX,XX +XXX,XX @@ static bool trans_UCVTF_dd(DisasContext *s, arg_rpr_esz *a, uint32_t insn) | 20 | @@ -XXX,XX +XXX,XX @@ |
22 | * The load should begin at the address Rn + IMM. | 21 | #include "hw/intc/arm_gic.h" |
23 | */ | 22 | #include "hw/net/cadence_gem.h" |
24 | 23 | #include "hw/char/cadence_uart.h" | |
25 | -static void do_ldr(DisasContext *s, uint32_t vofs, uint32_t len, | 24 | +#include "hw/net/xlnx-zynqmp-can.h" |
26 | - int rn, int imm) | 25 | #include "hw/ide/ahci.h" |
27 | +static void do_ldr(DisasContext *s, uint32_t vofs, int len, int rn, int imm) | 26 | #include "hw/sd/sdhci.h" |
28 | { | 27 | #include "hw/ssi/xilinx_spips.h" |
29 | - uint32_t len_align = QEMU_ALIGN_DOWN(len, 8); | 28 | @@ -XXX,XX +XXX,XX @@ |
30 | - uint32_t len_remain = len % 8; | 29 | #include "hw/cpu/cluster.h" |
31 | - uint32_t nparts = len / 8 + ctpop8(len_remain); | 30 | #include "target/arm/cpu.h" |
32 | + int len_align = QEMU_ALIGN_DOWN(len, 8); | 31 | #include "qom/object.h" |
33 | + int len_remain = len % 8; | 32 | +#include "net/can_emu.h" |
34 | + int nparts = len / 8 + ctpop8(len_remain); | 33 | |
35 | int midx = get_mem_index(s); | 34 | #define TYPE_XLNX_ZYNQMP "xlnx,zynqmp" |
36 | TCGv_i64 addr, t0, t1; | 35 | OBJECT_DECLARE_SIMPLE_TYPE(XlnxZynqMPState, XLNX_ZYNQMP) |
37 | 36 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(XlnxZynqMPState, XLNX_ZYNQMP) | |
38 | @@ -XXX,XX +XXX,XX @@ static void do_ldr(DisasContext *s, uint32_t vofs, uint32_t len, | 37 | #define XLNX_ZYNQMP_NUM_RPU_CPUS 2 |
38 | #define XLNX_ZYNQMP_NUM_GEMS 4 | ||
39 | #define XLNX_ZYNQMP_NUM_UARTS 2 | ||
40 | +#define XLNX_ZYNQMP_NUM_CAN 2 | ||
41 | +#define XLNX_ZYNQMP_CAN_REF_CLK (24 * 1000 * 1000) | ||
42 | #define XLNX_ZYNQMP_NUM_SDHCI 2 | ||
43 | #define XLNX_ZYNQMP_NUM_SPIS 2 | ||
44 | #define XLNX_ZYNQMP_NUM_GDMA_CH 8 | ||
45 | @@ -XXX,XX +XXX,XX @@ struct XlnxZynqMPState { | ||
46 | |||
47 | CadenceGEMState gem[XLNX_ZYNQMP_NUM_GEMS]; | ||
48 | CadenceUARTState uart[XLNX_ZYNQMP_NUM_UARTS]; | ||
49 | + XlnxZynqMPCANState can[XLNX_ZYNQMP_NUM_CAN]; | ||
50 | SysbusAHCIState sata; | ||
51 | SDHCIState sdhci[XLNX_ZYNQMP_NUM_SDHCI]; | ||
52 | XilinxSPIPS spi[XLNX_ZYNQMP_NUM_SPIS]; | ||
53 | @@ -XXX,XX +XXX,XX @@ struct XlnxZynqMPState { | ||
54 | bool virt; | ||
55 | /* Has the RPU subsystem? */ | ||
56 | bool has_rpu; | ||
57 | + | ||
58 | + /* CAN bus. */ | ||
59 | + CanBusState *canbus[XLNX_ZYNQMP_NUM_CAN]; | ||
60 | }; | ||
61 | |||
62 | #endif | ||
63 | diff --git a/hw/arm/xlnx-zcu102.c b/hw/arm/xlnx-zcu102.c | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/hw/arm/xlnx-zcu102.c | ||
66 | +++ b/hw/arm/xlnx-zcu102.c | ||
67 | @@ -XXX,XX +XXX,XX @@ | ||
68 | #include "sysemu/qtest.h" | ||
69 | #include "sysemu/device_tree.h" | ||
70 | #include "qom/object.h" | ||
71 | +#include "net/can_emu.h" | ||
72 | |||
73 | struct XlnxZCU102 { | ||
74 | MachineState parent_obj; | ||
75 | @@ -XXX,XX +XXX,XX @@ struct XlnxZCU102 { | ||
76 | bool secure; | ||
77 | bool virt; | ||
78 | |||
79 | + CanBusState *canbus[XLNX_ZYNQMP_NUM_CAN]; | ||
80 | + | ||
81 | struct arm_boot_info binfo; | ||
82 | }; | ||
83 | |||
84 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zcu102_init(MachineState *machine) | ||
85 | object_property_set_bool(OBJECT(&s->soc), "virtualization", s->virt, | ||
86 | &error_fatal); | ||
87 | |||
88 | + for (i = 0; i < XLNX_ZYNQMP_NUM_CAN; i++) { | ||
89 | + gchar *bus_name = g_strdup_printf("canbus%d", i); | ||
90 | + | ||
91 | + object_property_set_link(OBJECT(&s->soc), bus_name, | ||
92 | + OBJECT(s->canbus[i]), &error_fatal); | ||
93 | + g_free(bus_name); | ||
94 | + } | ||
95 | + | ||
96 | qdev_realize(DEVICE(&s->soc), NULL, &error_fatal); | ||
97 | |||
98 | /* Create and plug in the SD cards */ | ||
99 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zcu102_machine_instance_init(Object *obj) | ||
100 | s->secure = false; | ||
101 | /* Default to virt (EL2) being disabled */ | ||
102 | s->virt = false; | ||
103 | + object_property_add_link(obj, "xlnx-zcu102.canbus0", TYPE_CAN_BUS, | ||
104 | + (Object **)&s->canbus[0], | ||
105 | + object_property_allow_set_link, | ||
106 | + 0); | ||
107 | + | ||
108 | + object_property_add_link(obj, "xlnx-zcu102.canbus1", TYPE_CAN_BUS, | ||
109 | + (Object **)&s->canbus[1], | ||
110 | + object_property_allow_set_link, | ||
111 | + 0); | ||
39 | } | 112 | } |
40 | 113 | ||
41 | /* Similarly for stores. */ | 114 | static void xlnx_zcu102_machine_class_init(ObjectClass *oc, void *data) |
42 | -static void do_str(DisasContext *s, uint32_t vofs, uint32_t len, | 115 | diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c |
43 | - int rn, int imm) | 116 | index XXXXXXX..XXXXXXX 100644 |
44 | +static void do_str(DisasContext *s, uint32_t vofs, int len, int rn, int imm) | 117 | --- a/hw/arm/xlnx-zynqmp.c |
45 | { | 118 | +++ b/hw/arm/xlnx-zynqmp.c |
46 | - uint32_t len_align = QEMU_ALIGN_DOWN(len, 8); | 119 | @@ -XXX,XX +XXX,XX @@ static const int uart_intr[XLNX_ZYNQMP_NUM_UARTS] = { |
47 | - uint32_t len_remain = len % 8; | 120 | 21, 22, |
48 | - uint32_t nparts = len / 8 + ctpop8(len_remain); | 121 | }; |
49 | + int len_align = QEMU_ALIGN_DOWN(len, 8); | 122 | |
50 | + int len_remain = len % 8; | 123 | +static const uint64_t can_addr[XLNX_ZYNQMP_NUM_CAN] = { |
51 | + int nparts = len / 8 + ctpop8(len_remain); | 124 | + 0xFF060000, 0xFF070000, |
52 | int midx = get_mem_index(s); | 125 | +}; |
53 | TCGv_i64 addr, t0; | 126 | + |
127 | +static const int can_intr[XLNX_ZYNQMP_NUM_CAN] = { | ||
128 | + 23, 24, | ||
129 | +}; | ||
130 | + | ||
131 | static const uint64_t sdhci_addr[XLNX_ZYNQMP_NUM_SDHCI] = { | ||
132 | 0xFF160000, 0xFF170000, | ||
133 | }; | ||
134 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_init(Object *obj) | ||
135 | TYPE_CADENCE_UART); | ||
136 | } | ||
137 | |||
138 | + for (i = 0; i < XLNX_ZYNQMP_NUM_CAN; i++) { | ||
139 | + object_initialize_child(obj, "can[*]", &s->can[i], | ||
140 | + TYPE_XLNX_ZYNQMP_CAN); | ||
141 | + } | ||
142 | + | ||
143 | object_initialize_child(obj, "sata", &s->sata, TYPE_SYSBUS_AHCI); | ||
144 | |||
145 | for (i = 0; i < XLNX_ZYNQMP_NUM_SDHCI; i++) { | ||
146 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) | ||
147 | gic_spi[uart_intr[i]]); | ||
148 | } | ||
149 | |||
150 | + for (i = 0; i < XLNX_ZYNQMP_NUM_CAN; i++) { | ||
151 | + object_property_set_int(OBJECT(&s->can[i]), "ext_clk_freq", | ||
152 | + XLNX_ZYNQMP_CAN_REF_CLK, &error_abort); | ||
153 | + | ||
154 | + object_property_set_link(OBJECT(&s->can[i]), "canbus", | ||
155 | + OBJECT(s->canbus[i]), &error_fatal); | ||
156 | + | ||
157 | + sysbus_realize(SYS_BUS_DEVICE(&s->can[i]), &err); | ||
158 | + if (err) { | ||
159 | + error_propagate(errp, err); | ||
160 | + return; | ||
161 | + } | ||
162 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->can[i]), 0, can_addr[i]); | ||
163 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->can[i]), 0, | ||
164 | + gic_spi[can_intr[i]]); | ||
165 | + } | ||
166 | + | ||
167 | object_property_set_int(OBJECT(&s->sata), "num-ports", SATA_NUM_PORTS, | ||
168 | &error_abort); | ||
169 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->sata), errp)) { | ||
170 | @@ -XXX,XX +XXX,XX @@ static Property xlnx_zynqmp_props[] = { | ||
171 | DEFINE_PROP_BOOL("has_rpu", XlnxZynqMPState, has_rpu, false), | ||
172 | DEFINE_PROP_LINK("ddr-ram", XlnxZynqMPState, ddr_ram, TYPE_MEMORY_REGION, | ||
173 | MemoryRegion *), | ||
174 | + DEFINE_PROP_LINK("canbus0", XlnxZynqMPState, canbus[0], TYPE_CAN_BUS, | ||
175 | + CanBusState *), | ||
176 | + DEFINE_PROP_LINK("canbus1", XlnxZynqMPState, canbus[1], TYPE_CAN_BUS, | ||
177 | + CanBusState *), | ||
178 | DEFINE_PROP_END_OF_LIST() | ||
179 | }; | ||
54 | 180 | ||
55 | -- | 181 | -- |
56 | 2.18.0 | 182 | 2.20.1 |
57 | 183 | ||
58 | 184 | diff view generated by jsdifflib |
1 | From: Su Hang <suhang16@mails.ucas.ac.cn> | 1 | From: Vikram Garhwal <fnu.vikram@xilinx.com> |
---|---|---|---|
2 | 2 | ||
3 | 'test.hex' file is a memory test pattern stored in Hexadecimal Object | 3 | The QTests perform five tests on the Xilinx ZynqMP CAN controller: |
4 | Format. It loads at 0x10000 in RAM and contains values from 0 through | 4 | Tests the CAN controller in loopback, sleep and snoop mode. |
5 | 255. | 5 | Tests filtering of incoming CAN messages. |
6 | 6 | ||
7 | The test case verifies that the expected memory test pattern was loaded. | ||
8 | |||
9 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
10 | Suggested-by: Steffen Gortz <qemu.ml@steffen-goertz.de> | ||
11 | Suggested-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
12 | Signed-off-by: Su Hang <suhang16@mails.ucas.ac.cn> | ||
13 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
15 | [PMM: changed qtest_startf() to qtest_initf() to work with | 8 | Reviewed-by: Francisco Iglesias <francisco.iglesias@xilinx.com> |
16 | current master after the refactoring in commit 88b988c895e3c2] | 9 | Signed-off-by: Vikram Garhwal <fnu.vikram@xilinx.com> |
10 | Message-id: 1605728926-352690-4-git-send-email-fnu.vikram@xilinx.com | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | --- | 12 | --- |
19 | configure | 4 +++ | 13 | tests/qtest/xlnx-can-test.c | 360 ++++++++++++++++++++++++++++++++++++ |
20 | tests/Makefile.include | 2 ++ | 14 | tests/qtest/meson.build | 1 + |
21 | tests/hexloader-test.c | 45 ++++++++++++++++++++++++++++ | 15 | 2 files changed, 361 insertions(+) |
22 | MAINTAINERS | 6 ++++ | 16 | create mode 100644 tests/qtest/xlnx-can-test.c |
23 | tests/hex-loader-check-data/test.hex | 18 +++++++++++ | 17 | |
24 | 5 files changed, 75 insertions(+) | 18 | diff --git a/tests/qtest/xlnx-can-test.c b/tests/qtest/xlnx-can-test.c |
25 | create mode 100644 tests/hexloader-test.c | ||
26 | create mode 100644 tests/hex-loader-check-data/test.hex | ||
27 | |||
28 | diff --git a/configure b/configure | ||
29 | index XXXXXXX..XXXXXXX 100755 | ||
30 | --- a/configure | ||
31 | +++ b/configure | ||
32 | @@ -XXX,XX +XXX,XX @@ for test_file in $(find $source_path/tests/acpi-test-data -type f) | ||
33 | do | ||
34 | FILES="$FILES tests/acpi-test-data$(echo $test_file | sed -e 's/.*acpi-test-data//')" | ||
35 | done | ||
36 | +for test_file in $(find $source_path/tests/hex-loader-check-data -type f) | ||
37 | +do | ||
38 | + FILES="$FILES tests/hex-loader-check-data$(echo $test_file | sed -e 's/.*hex-loader-check-data//')" | ||
39 | +done | ||
40 | mkdir -p $DIRS | ||
41 | for f in $FILES ; do | ||
42 | if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then | ||
43 | diff --git a/tests/Makefile.include b/tests/Makefile.include | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/tests/Makefile.include | ||
46 | +++ b/tests/Makefile.include | ||
47 | @@ -XXX,XX +XXX,XX @@ check-qtest-arm-y += tests/test-arm-mptimer$(EXESUF) | ||
48 | gcov-files-arm-y += hw/timer/arm_mptimer.c | ||
49 | check-qtest-arm-y += tests/boot-serial-test$(EXESUF) | ||
50 | check-qtest-arm-y += tests/sdhci-test$(EXESUF) | ||
51 | +check-qtest-arm-y += tests/hexloader-test$(EXESUF) | ||
52 | |||
53 | check-qtest-aarch64-y = tests/numa-test$(EXESUF) | ||
54 | check-qtest-aarch64-y += tests/sdhci-test$(EXESUF) | ||
55 | @@ -XXX,XX +XXX,XX @@ tests/qmp-test$(EXESUF): tests/qmp-test.o | ||
56 | tests/device-introspect-test$(EXESUF): tests/device-introspect-test.o | ||
57 | tests/rtc-test$(EXESUF): tests/rtc-test.o | ||
58 | tests/m48t59-test$(EXESUF): tests/m48t59-test.o | ||
59 | +tests/hexloader-test$(EXESUF): tests/hexloader-test.o | ||
60 | tests/endianness-test$(EXESUF): tests/endianness-test.o | ||
61 | tests/spapr-phb-test$(EXESUF): tests/spapr-phb-test.o $(libqos-obj-y) | ||
62 | tests/prom-env-test$(EXESUF): tests/prom-env-test.o $(libqos-obj-y) | ||
63 | diff --git a/tests/hexloader-test.c b/tests/hexloader-test.c | ||
64 | new file mode 100644 | 19 | new file mode 100644 |
65 | index XXXXXXX..XXXXXXX | 20 | index XXXXXXX..XXXXXXX |
66 | --- /dev/null | 21 | --- /dev/null |
67 | +++ b/tests/hexloader-test.c | 22 | +++ b/tests/qtest/xlnx-can-test.c |
68 | @@ -XXX,XX +XXX,XX @@ | 23 | @@ -XXX,XX +XXX,XX @@ |
69 | +/* | 24 | +/* |
70 | + * QTest testcase for the Intel Hexadecimal Object File Loader | 25 | + * QTests for the Xilinx ZynqMP CAN controller. |
71 | + * | 26 | + * |
72 | + * Authors: | 27 | + * Copyright (c) 2020 Xilinx Inc. |
73 | + * Su Hang <suhang16@mails.ucas.ac.cn> 2018 | 28 | + * |
74 | + * | 29 | + * Written-by: Vikram Garhwal<fnu.vikram@xilinx.com> |
75 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | 30 | + * |
76 | + * See the COPYING file in the top-level directory. | 31 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
77 | + * | 32 | + * of this software and associated documentation files (the "Software"), to deal |
33 | + * in the Software without restriction, including without limitation the rights | ||
34 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
35 | + * copies of the Software, and to permit persons to whom the Software is | ||
36 | + * furnished to do so, subject to the following conditions: | ||
37 | + * | ||
38 | + * The above copyright notice and this permission notice shall be included in | ||
39 | + * all copies or substantial portions of the Software. | ||
40 | + * | ||
41 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
42 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
43 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
44 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
45 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
46 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
47 | + * THE SOFTWARE. | ||
78 | + */ | 48 | + */ |
79 | + | 49 | + |
80 | +#include "qemu/osdep.h" | 50 | +#include "qemu/osdep.h" |
81 | +#include "libqtest.h" | 51 | +#include "libqos/libqtest.h" |
82 | + | 52 | + |
83 | +/* Load 'test.hex' and verify that the in-memory contents are as expected. | 53 | +/* Base address. */ |
84 | + * 'test.hex' is a memory test pattern stored in Hexadecimal Object | 54 | +#define CAN0_BASE_ADDR 0xFF060000 |
85 | + * format. It loads at 0x10000 in RAM and contains values from 0 through | 55 | +#define CAN1_BASE_ADDR 0xFF070000 |
86 | + * 255. | 56 | + |
57 | +/* Register addresses. */ | ||
58 | +#define R_SRR_OFFSET 0x00 | ||
59 | +#define R_MSR_OFFSET 0x04 | ||
60 | +#define R_SR_OFFSET 0x18 | ||
61 | +#define R_ISR_OFFSET 0x1C | ||
62 | +#define R_ICR_OFFSET 0x24 | ||
63 | +#define R_TXID_OFFSET 0x30 | ||
64 | +#define R_TXDLC_OFFSET 0x34 | ||
65 | +#define R_TXDATA1_OFFSET 0x38 | ||
66 | +#define R_TXDATA2_OFFSET 0x3C | ||
67 | +#define R_RXID_OFFSET 0x50 | ||
68 | +#define R_RXDLC_OFFSET 0x54 | ||
69 | +#define R_RXDATA1_OFFSET 0x58 | ||
70 | +#define R_RXDATA2_OFFSET 0x5C | ||
71 | +#define R_AFR 0x60 | ||
72 | +#define R_AFMR1 0x64 | ||
73 | +#define R_AFIR1 0x68 | ||
74 | +#define R_AFMR2 0x6C | ||
75 | +#define R_AFIR2 0x70 | ||
76 | +#define R_AFMR3 0x74 | ||
77 | +#define R_AFIR3 0x78 | ||
78 | +#define R_AFMR4 0x7C | ||
79 | +#define R_AFIR4 0x80 | ||
80 | + | ||
81 | +/* CAN modes. */ | ||
82 | +#define CONFIG_MODE 0x00 | ||
83 | +#define NORMAL_MODE 0x00 | ||
84 | +#define LOOPBACK_MODE 0x02 | ||
85 | +#define SNOOP_MODE 0x04 | ||
86 | +#define SLEEP_MODE 0x01 | ||
87 | +#define ENABLE_CAN (1 << 1) | ||
88 | +#define STATUS_NORMAL_MODE (1 << 3) | ||
89 | +#define STATUS_LOOPBACK_MODE (1 << 1) | ||
90 | +#define STATUS_SNOOP_MODE (1 << 12) | ||
91 | +#define STATUS_SLEEP_MODE (1 << 2) | ||
92 | +#define ISR_TXOK (1 << 1) | ||
93 | +#define ISR_RXOK (1 << 4) | ||
94 | + | ||
95 | +static void match_rx_tx_data(const uint32_t *buf_tx, const uint32_t *buf_rx, | ||
96 | + uint8_t can_timestamp) | ||
97 | +{ | ||
98 | + uint16_t size = 0; | ||
99 | + uint8_t len = 4; | ||
100 | + | ||
101 | + while (size < len) { | ||
102 | + if (R_RXID_OFFSET + 4 * size == R_RXDLC_OFFSET) { | ||
103 | + g_assert_cmpint(buf_rx[size], ==, buf_tx[size] + can_timestamp); | ||
104 | + } else { | ||
105 | + g_assert_cmpint(buf_rx[size], ==, buf_tx[size]); | ||
106 | + } | ||
107 | + | ||
108 | + size++; | ||
109 | + } | ||
110 | +} | ||
111 | + | ||
112 | +static void read_data(QTestState *qts, uint64_t can_base_addr, uint32_t *buf_rx) | ||
113 | +{ | ||
114 | + uint32_t int_status; | ||
115 | + | ||
116 | + /* Read the interrupt on CAN rx. */ | ||
117 | + int_status = qtest_readl(qts, can_base_addr + R_ISR_OFFSET) & ISR_RXOK; | ||
118 | + | ||
119 | + g_assert_cmpint(int_status, ==, ISR_RXOK); | ||
120 | + | ||
121 | + /* Read the RX register data for CAN. */ | ||
122 | + buf_rx[0] = qtest_readl(qts, can_base_addr + R_RXID_OFFSET); | ||
123 | + buf_rx[1] = qtest_readl(qts, can_base_addr + R_RXDLC_OFFSET); | ||
124 | + buf_rx[2] = qtest_readl(qts, can_base_addr + R_RXDATA1_OFFSET); | ||
125 | + buf_rx[3] = qtest_readl(qts, can_base_addr + R_RXDATA2_OFFSET); | ||
126 | + | ||
127 | + /* Clear the RX interrupt. */ | ||
128 | + qtest_writel(qts, CAN1_BASE_ADDR + R_ICR_OFFSET, ISR_RXOK); | ||
129 | +} | ||
130 | + | ||
131 | +static void send_data(QTestState *qts, uint64_t can_base_addr, | ||
132 | + const uint32_t *buf_tx) | ||
133 | +{ | ||
134 | + uint32_t int_status; | ||
135 | + | ||
136 | + /* Write the TX register data for CAN. */ | ||
137 | + qtest_writel(qts, can_base_addr + R_TXID_OFFSET, buf_tx[0]); | ||
138 | + qtest_writel(qts, can_base_addr + R_TXDLC_OFFSET, buf_tx[1]); | ||
139 | + qtest_writel(qts, can_base_addr + R_TXDATA1_OFFSET, buf_tx[2]); | ||
140 | + qtest_writel(qts, can_base_addr + R_TXDATA2_OFFSET, buf_tx[3]); | ||
141 | + | ||
142 | + /* Read the interrupt on CAN for tx. */ | ||
143 | + int_status = qtest_readl(qts, can_base_addr + R_ISR_OFFSET) & ISR_TXOK; | ||
144 | + | ||
145 | + g_assert_cmpint(int_status, ==, ISR_TXOK); | ||
146 | + | ||
147 | + /* Clear the interrupt for tx. */ | ||
148 | + qtest_writel(qts, CAN0_BASE_ADDR + R_ICR_OFFSET, ISR_TXOK); | ||
149 | +} | ||
150 | + | ||
151 | +/* | ||
152 | + * This test will be transferring data from CAN0 and CAN1 through canbus. CAN0 | ||
153 | + * initiate the data transfer to can-bus, CAN1 receives the data. Test compares | ||
154 | + * the data sent from CAN0 with received on CAN1. | ||
87 | + */ | 155 | + */ |
88 | +static void hex_loader_test(void) | 156 | +static void test_can_bus(void) |
89 | +{ | 157 | +{ |
90 | + unsigned int i; | 158 | + const uint32_t buf_tx[4] = { 0xFF, 0x80000000, 0x12345678, 0x87654321 }; |
91 | + const unsigned int base_addr = 0x00010000; | 159 | + uint32_t buf_rx[4] = { 0x00, 0x00, 0x00, 0x00 }; |
92 | + | 160 | + uint32_t status = 0; |
93 | + QTestState *s = qtest_initf( | 161 | + uint8_t can_timestamp = 1; |
94 | + "-M vexpress-a9 -nographic -device loader,file=tests/hex-loader-check-data/test.hex"); | 162 | + |
95 | + | 163 | + QTestState *qts = qtest_init("-machine xlnx-zcu102" |
96 | + for (i = 0; i < 256; ++i) { | 164 | + " -object can-bus,id=canbus0" |
97 | + uint8_t val = qtest_readb(s, base_addr + i); | 165 | + " -machine xlnx-zcu102.canbus0=canbus0" |
98 | + g_assert_cmpuint(i, ==, val); | 166 | + " -machine xlnx-zcu102.canbus1=canbus0" |
99 | + } | 167 | + ); |
100 | + qtest_quit(s); | 168 | + |
169 | + /* Configure the CAN0 and CAN1. */ | ||
170 | + qtest_writel(qts, CAN0_BASE_ADDR + R_SRR_OFFSET, ENABLE_CAN); | ||
171 | + qtest_writel(qts, CAN0_BASE_ADDR + R_MSR_OFFSET, NORMAL_MODE); | ||
172 | + qtest_writel(qts, CAN1_BASE_ADDR + R_SRR_OFFSET, ENABLE_CAN); | ||
173 | + qtest_writel(qts, CAN1_BASE_ADDR + R_MSR_OFFSET, NORMAL_MODE); | ||
174 | + | ||
175 | + /* Check here if CAN0 and CAN1 are in normal mode. */ | ||
176 | + status = qtest_readl(qts, CAN0_BASE_ADDR + R_SR_OFFSET); | ||
177 | + g_assert_cmpint(status, ==, STATUS_NORMAL_MODE); | ||
178 | + | ||
179 | + status = qtest_readl(qts, CAN1_BASE_ADDR + R_SR_OFFSET); | ||
180 | + g_assert_cmpint(status, ==, STATUS_NORMAL_MODE); | ||
181 | + | ||
182 | + send_data(qts, CAN0_BASE_ADDR, buf_tx); | ||
183 | + | ||
184 | + read_data(qts, CAN1_BASE_ADDR, buf_rx); | ||
185 | + match_rx_tx_data(buf_tx, buf_rx, can_timestamp); | ||
186 | + | ||
187 | + qtest_quit(qts); | ||
188 | +} | ||
189 | + | ||
190 | +/* | ||
191 | + * This test is performing loopback mode on CAN0 and CAN1. Data sent from TX of | ||
192 | + * each CAN0 and CAN1 are compared with RX register data for respective CAN. | ||
193 | + */ | ||
194 | +static void test_can_loopback(void) | ||
195 | +{ | ||
196 | + uint32_t buf_tx[4] = { 0xFF, 0x80000000, 0x12345678, 0x87654321 }; | ||
197 | + uint32_t buf_rx[4] = { 0x00, 0x00, 0x00, 0x00 }; | ||
198 | + uint32_t status = 0; | ||
199 | + | ||
200 | + QTestState *qts = qtest_init("-machine xlnx-zcu102" | ||
201 | + " -object can-bus,id=canbus0" | ||
202 | + " -machine xlnx-zcu102.canbus0=canbus0" | ||
203 | + " -machine xlnx-zcu102.canbus1=canbus0" | ||
204 | + ); | ||
205 | + | ||
206 | + /* Configure the CAN0 in loopback mode. */ | ||
207 | + qtest_writel(qts, CAN0_BASE_ADDR + R_SRR_OFFSET, CONFIG_MODE); | ||
208 | + qtest_writel(qts, CAN0_BASE_ADDR + R_MSR_OFFSET, LOOPBACK_MODE); | ||
209 | + qtest_writel(qts, CAN0_BASE_ADDR + R_SRR_OFFSET, ENABLE_CAN); | ||
210 | + | ||
211 | + /* Check here if CAN0 is set in loopback mode. */ | ||
212 | + status = qtest_readl(qts, CAN0_BASE_ADDR + R_SR_OFFSET); | ||
213 | + | ||
214 | + g_assert_cmpint(status, ==, STATUS_LOOPBACK_MODE); | ||
215 | + | ||
216 | + send_data(qts, CAN0_BASE_ADDR, buf_tx); | ||
217 | + read_data(qts, CAN0_BASE_ADDR, buf_rx); | ||
218 | + match_rx_tx_data(buf_tx, buf_rx, 0); | ||
219 | + | ||
220 | + /* Configure the CAN1 in loopback mode. */ | ||
221 | + qtest_writel(qts, CAN1_BASE_ADDR + R_SRR_OFFSET, CONFIG_MODE); | ||
222 | + qtest_writel(qts, CAN1_BASE_ADDR + R_MSR_OFFSET, LOOPBACK_MODE); | ||
223 | + qtest_writel(qts, CAN1_BASE_ADDR + R_SRR_OFFSET, ENABLE_CAN); | ||
224 | + | ||
225 | + /* Check here if CAN1 is set in loopback mode. */ | ||
226 | + status = qtest_readl(qts, CAN1_BASE_ADDR + R_SR_OFFSET); | ||
227 | + | ||
228 | + g_assert_cmpint(status, ==, STATUS_LOOPBACK_MODE); | ||
229 | + | ||
230 | + send_data(qts, CAN1_BASE_ADDR, buf_tx); | ||
231 | + read_data(qts, CAN1_BASE_ADDR, buf_rx); | ||
232 | + match_rx_tx_data(buf_tx, buf_rx, 0); | ||
233 | + | ||
234 | + qtest_quit(qts); | ||
235 | +} | ||
236 | + | ||
237 | +/* | ||
238 | + * Enable filters for CAN1. This will filter incoming messages with ID. In this | ||
239 | + * test message will pass through filter 2. | ||
240 | + */ | ||
241 | +static void test_can_filter(void) | ||
242 | +{ | ||
243 | + uint32_t buf_tx[4] = { 0x14, 0x80000000, 0x12345678, 0x87654321 }; | ||
244 | + uint32_t buf_rx[4] = { 0x00, 0x00, 0x00, 0x00 }; | ||
245 | + uint32_t status = 0; | ||
246 | + uint8_t can_timestamp = 1; | ||
247 | + | ||
248 | + QTestState *qts = qtest_init("-machine xlnx-zcu102" | ||
249 | + " -object can-bus,id=canbus0" | ||
250 | + " -machine xlnx-zcu102.canbus0=canbus0" | ||
251 | + " -machine xlnx-zcu102.canbus1=canbus0" | ||
252 | + ); | ||
253 | + | ||
254 | + /* Configure the CAN0 and CAN1. */ | ||
255 | + qtest_writel(qts, CAN0_BASE_ADDR + R_SRR_OFFSET, ENABLE_CAN); | ||
256 | + qtest_writel(qts, CAN0_BASE_ADDR + R_MSR_OFFSET, NORMAL_MODE); | ||
257 | + qtest_writel(qts, CAN1_BASE_ADDR + R_SRR_OFFSET, ENABLE_CAN); | ||
258 | + qtest_writel(qts, CAN1_BASE_ADDR + R_MSR_OFFSET, NORMAL_MODE); | ||
259 | + | ||
260 | + /* Check here if CAN0 and CAN1 are in normal mode. */ | ||
261 | + status = qtest_readl(qts, CAN0_BASE_ADDR + R_SR_OFFSET); | ||
262 | + g_assert_cmpint(status, ==, STATUS_NORMAL_MODE); | ||
263 | + | ||
264 | + status = qtest_readl(qts, CAN1_BASE_ADDR + R_SR_OFFSET); | ||
265 | + g_assert_cmpint(status, ==, STATUS_NORMAL_MODE); | ||
266 | + | ||
267 | + /* Set filter for CAN1 for incoming messages. */ | ||
268 | + qtest_writel(qts, CAN1_BASE_ADDR + R_AFR, 0x0); | ||
269 | + qtest_writel(qts, CAN1_BASE_ADDR + R_AFMR1, 0xF7); | ||
270 | + qtest_writel(qts, CAN1_BASE_ADDR + R_AFIR1, 0x121F); | ||
271 | + qtest_writel(qts, CAN1_BASE_ADDR + R_AFMR2, 0x5431); | ||
272 | + qtest_writel(qts, CAN1_BASE_ADDR + R_AFIR2, 0x14); | ||
273 | + qtest_writel(qts, CAN1_BASE_ADDR + R_AFMR3, 0x1234); | ||
274 | + qtest_writel(qts, CAN1_BASE_ADDR + R_AFIR3, 0x5431); | ||
275 | + qtest_writel(qts, CAN1_BASE_ADDR + R_AFMR4, 0xFFF); | ||
276 | + qtest_writel(qts, CAN1_BASE_ADDR + R_AFIR4, 0x1234); | ||
277 | + | ||
278 | + qtest_writel(qts, CAN1_BASE_ADDR + R_AFR, 0xF); | ||
279 | + | ||
280 | + send_data(qts, CAN0_BASE_ADDR, buf_tx); | ||
281 | + | ||
282 | + read_data(qts, CAN1_BASE_ADDR, buf_rx); | ||
283 | + match_rx_tx_data(buf_tx, buf_rx, can_timestamp); | ||
284 | + | ||
285 | + qtest_quit(qts); | ||
286 | +} | ||
287 | + | ||
288 | +/* Testing sleep mode on CAN0 while CAN1 is in normal mode. */ | ||
289 | +static void test_can_sleepmode(void) | ||
290 | +{ | ||
291 | + uint32_t buf_tx[4] = { 0x14, 0x80000000, 0x12345678, 0x87654321 }; | ||
292 | + uint32_t buf_rx[4] = { 0x00, 0x00, 0x00, 0x00 }; | ||
293 | + uint32_t status = 0; | ||
294 | + uint8_t can_timestamp = 1; | ||
295 | + | ||
296 | + QTestState *qts = qtest_init("-machine xlnx-zcu102" | ||
297 | + " -object can-bus,id=canbus0" | ||
298 | + " -machine xlnx-zcu102.canbus0=canbus0" | ||
299 | + " -machine xlnx-zcu102.canbus1=canbus0" | ||
300 | + ); | ||
301 | + | ||
302 | + /* Configure the CAN0. */ | ||
303 | + qtest_writel(qts, CAN0_BASE_ADDR + R_SRR_OFFSET, CONFIG_MODE); | ||
304 | + qtest_writel(qts, CAN0_BASE_ADDR + R_MSR_OFFSET, SLEEP_MODE); | ||
305 | + qtest_writel(qts, CAN0_BASE_ADDR + R_SRR_OFFSET, ENABLE_CAN); | ||
306 | + | ||
307 | + qtest_writel(qts, CAN1_BASE_ADDR + R_SRR_OFFSET, ENABLE_CAN); | ||
308 | + qtest_writel(qts, CAN1_BASE_ADDR + R_MSR_OFFSET, NORMAL_MODE); | ||
309 | + | ||
310 | + /* Check here if CAN0 is in SLEEP mode and CAN1 in normal mode. */ | ||
311 | + status = qtest_readl(qts, CAN0_BASE_ADDR + R_SR_OFFSET); | ||
312 | + g_assert_cmpint(status, ==, STATUS_SLEEP_MODE); | ||
313 | + | ||
314 | + status = qtest_readl(qts, CAN1_BASE_ADDR + R_SR_OFFSET); | ||
315 | + g_assert_cmpint(status, ==, STATUS_NORMAL_MODE); | ||
316 | + | ||
317 | + send_data(qts, CAN1_BASE_ADDR, buf_tx); | ||
318 | + | ||
319 | + /* | ||
320 | + * Once CAN1 sends data on can-bus. CAN0 should exit sleep mode. | ||
321 | + * Check the CAN0 status now. It should exit the sleep mode and receive the | ||
322 | + * incoming data. | ||
323 | + */ | ||
324 | + status = qtest_readl(qts, CAN0_BASE_ADDR + R_SR_OFFSET); | ||
325 | + g_assert_cmpint(status, ==, STATUS_NORMAL_MODE); | ||
326 | + | ||
327 | + read_data(qts, CAN0_BASE_ADDR, buf_rx); | ||
328 | + | ||
329 | + match_rx_tx_data(buf_tx, buf_rx, can_timestamp); | ||
330 | + | ||
331 | + qtest_quit(qts); | ||
332 | +} | ||
333 | + | ||
334 | +/* Testing Snoop mode on CAN0 while CAN1 is in normal mode. */ | ||
335 | +static void test_can_snoopmode(void) | ||
336 | +{ | ||
337 | + uint32_t buf_tx[4] = { 0x14, 0x80000000, 0x12345678, 0x87654321 }; | ||
338 | + uint32_t buf_rx[4] = { 0x00, 0x00, 0x00, 0x00 }; | ||
339 | + uint32_t status = 0; | ||
340 | + uint8_t can_timestamp = 1; | ||
341 | + | ||
342 | + QTestState *qts = qtest_init("-machine xlnx-zcu102" | ||
343 | + " -object can-bus,id=canbus0" | ||
344 | + " -machine xlnx-zcu102.canbus0=canbus0" | ||
345 | + " -machine xlnx-zcu102.canbus1=canbus0" | ||
346 | + ); | ||
347 | + | ||
348 | + /* Configure the CAN0. */ | ||
349 | + qtest_writel(qts, CAN0_BASE_ADDR + R_SRR_OFFSET, CONFIG_MODE); | ||
350 | + qtest_writel(qts, CAN0_BASE_ADDR + R_MSR_OFFSET, SNOOP_MODE); | ||
351 | + qtest_writel(qts, CAN0_BASE_ADDR + R_SRR_OFFSET, ENABLE_CAN); | ||
352 | + | ||
353 | + qtest_writel(qts, CAN1_BASE_ADDR + R_SRR_OFFSET, ENABLE_CAN); | ||
354 | + qtest_writel(qts, CAN1_BASE_ADDR + R_MSR_OFFSET, NORMAL_MODE); | ||
355 | + | ||
356 | + /* Check here if CAN0 is in SNOOP mode and CAN1 in normal mode. */ | ||
357 | + status = qtest_readl(qts, CAN0_BASE_ADDR + R_SR_OFFSET); | ||
358 | + g_assert_cmpint(status, ==, STATUS_SNOOP_MODE); | ||
359 | + | ||
360 | + status = qtest_readl(qts, CAN1_BASE_ADDR + R_SR_OFFSET); | ||
361 | + g_assert_cmpint(status, ==, STATUS_NORMAL_MODE); | ||
362 | + | ||
363 | + send_data(qts, CAN1_BASE_ADDR, buf_tx); | ||
364 | + | ||
365 | + read_data(qts, CAN0_BASE_ADDR, buf_rx); | ||
366 | + | ||
367 | + match_rx_tx_data(buf_tx, buf_rx, can_timestamp); | ||
368 | + | ||
369 | + qtest_quit(qts); | ||
101 | +} | 370 | +} |
102 | + | 371 | + |
103 | +int main(int argc, char **argv) | 372 | +int main(int argc, char **argv) |
104 | +{ | 373 | +{ |
105 | + int ret; | ||
106 | + | ||
107 | + g_test_init(&argc, &argv, NULL); | 374 | + g_test_init(&argc, &argv, NULL); |
108 | + | 375 | + |
109 | + qtest_add_func("/tmp/hex_loader", hex_loader_test); | 376 | + qtest_add_func("/net/can/can_bus", test_can_bus); |
110 | + ret = g_test_run(); | 377 | + qtest_add_func("/net/can/can_loopback", test_can_loopback); |
111 | + | 378 | + qtest_add_func("/net/can/can_filter", test_can_filter); |
112 | + return ret; | 379 | + qtest_add_func("/net/can/can_test_snoopmode", test_can_snoopmode); |
113 | +} | 380 | + qtest_add_func("/net/can/can_test_sleepmode", test_can_sleepmode); |
114 | diff --git a/MAINTAINERS b/MAINTAINERS | 381 | + |
382 | + return g_test_run(); | ||
383 | +} | ||
384 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build | ||
115 | index XXXXXXX..XXXXXXX 100644 | 385 | index XXXXXXX..XXXXXXX 100644 |
116 | --- a/MAINTAINERS | 386 | --- a/tests/qtest/meson.build |
117 | +++ b/MAINTAINERS | 387 | +++ b/tests/qtest/meson.build |
118 | @@ -XXX,XX +XXX,XX @@ F: hw/core/generic-loader.c | 388 | @@ -XXX,XX +XXX,XX @@ qtests_aarch64 = \ |
119 | F: include/hw/core/generic-loader.h | 389 | ['arm-cpu-features', |
120 | F: docs/generic-loader.txt | 390 | 'numa-test', |
121 | 391 | 'boot-serial-test', | |
122 | +Intel Hexadecimal Object File Loader | 392 | + 'xlnx-can-test', |
123 | +M: Su Hang <suhang16@mails.ucas.ac.cn> | 393 | 'migration-test'] |
124 | +S: Maintained | 394 | |
125 | +F: tests/hexloader-test.c | 395 | qtests_s390x = \ |
126 | +F: tests/hex-loader-check-data/test.hex | ||
127 | + | ||
128 | CHRP NVRAM | ||
129 | M: Thomas Huth <thuth@redhat.com> | ||
130 | S: Maintained | ||
131 | diff --git a/tests/hex-loader-check-data/test.hex b/tests/hex-loader-check-data/test.hex | ||
132 | new file mode 100644 | ||
133 | index XXXXXXX..XXXXXXX | ||
134 | --- /dev/null | ||
135 | +++ b/tests/hex-loader-check-data/test.hex | ||
136 | @@ -XXX,XX +XXX,XX @@ | ||
137 | +:020000040001F9 | ||
138 | +:10000000000102030405060708090a0b0c0d0e0f78 | ||
139 | +:10001000101112131415161718191a1b1c1d1e1f68 | ||
140 | +:10002000202122232425262728292a2b2c2d2e2f58 | ||
141 | +:10003000303132333435363738393a3b3c3d3e3f48 | ||
142 | +:10004000404142434445464748494a4b4c4d4e4f38 | ||
143 | +:10005000505152535455565758595a5b5c5d5e5f28 | ||
144 | +:10006000606162636465666768696a6b6c6d6e6f18 | ||
145 | +:10007000707172737475767778797a7b7c7d7e7f08 | ||
146 | +:10008000808182838485868788898a8b8c8d8e8ff8 | ||
147 | +:10009000909192939495969798999a9b9c9d9e9fe8 | ||
148 | +:1000a000a0a1a2a3a4a5a6a7a8a9aaabacadaeafd8 | ||
149 | +:1000b000b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc8 | ||
150 | +:1000c000c0c1c2c3c4c5c6c7c8c9cacbcccdcecfb8 | ||
151 | +:1000d000d0d1d2d3d4d5d6d7d8d9dadbdcdddedfa8 | ||
152 | +:1000e000e0e1e2e3e4e5e6e7e8e9eaebecedeeef98 | ||
153 | +:1000f000f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff88 | ||
154 | +:00000001FF | ||
155 | -- | 396 | -- |
156 | 2.18.0 | 397 | 2.20.1 |
157 | 398 | ||
158 | 399 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Vikram Garhwal <fnu.vikram@xilinx.com> |
---|---|---|---|
2 | 2 | ||
3 | This makes float16_muladd correctly use FZ16 not FZ. | 3 | Reviewed-by: Francisco Iglesias <francisco.iglesias@xilinx.com> |
4 | 4 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | |
5 | Fixes: 6ceabaad110 | 5 | Signed-off-by: Vikram Garhwal <fnu.vikram@xilinx.com> |
6 | Cc: qemu-stable@nongnu.org (3.0.1) | 6 | Message-id: 1605728926-352690-5-git-send-email-fnu.vikram@xilinx.com |
7 | Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Reviewed-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
10 | Tested-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
11 | Message-id: 20180810193129.1556-4-richard.henderson@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 8 | --- |
14 | target/arm/sve_helper.c | 2 +- | 9 | MAINTAINERS | 8 ++++++++ |
15 | 1 file changed, 1 insertion(+), 1 deletion(-) | 10 | 1 file changed, 8 insertions(+) |
16 | 11 | ||
17 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | 12 | diff --git a/MAINTAINERS b/MAINTAINERS |
18 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/sve_helper.c | 14 | --- a/MAINTAINERS |
20 | +++ b/target/arm/sve_helper.c | 15 | +++ b/MAINTAINERS |
21 | @@ -XXX,XX +XXX,XX @@ static void do_fmla_zpzzz_h(CPUARMState *env, void *vg, uint32_t desc, | 16 | @@ -XXX,XX +XXX,XX @@ F: hw/net/opencores_eth.c |
22 | e1 = *(uint16_t *)(vn + H1_2(i)) ^ neg1; | 17 | |
23 | e2 = *(uint16_t *)(vm + H1_2(i)); | 18 | Devices |
24 | e3 = *(uint16_t *)(va + H1_2(i)) ^ neg3; | 19 | ------- |
25 | - r = float16_muladd(e1, e2, e3, 0, &env->vfp.fp_status); | 20 | +Xilinx CAN |
26 | + r = float16_muladd(e1, e2, e3, 0, &env->vfp.fp_status_f16); | 21 | +M: Vikram Garhwal <fnu.vikram@xilinx.com> |
27 | *(uint16_t *)(vd + H1_2(i)) = r; | 22 | +M: Francisco Iglesias <francisco.iglesias@xilinx.com> |
28 | } | 23 | +S: Maintained |
29 | } while (i & 63); | 24 | +F: hw/net/can/xlnx-* |
25 | +F: include/hw/net/xlnx-* | ||
26 | +F: tests/qtest/xlnx-can-test* | ||
27 | + | ||
28 | EDU | ||
29 | M: Jiri Slaby <jslaby@suse.cz> | ||
30 | S: Maintained | ||
30 | -- | 31 | -- |
31 | 2.18.0 | 32 | 2.20.1 |
32 | 33 | ||
33 | 34 | diff view generated by jsdifflib |
1 | From: Trent Piepho <tpiepho@impinj.com> | 1 | From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The current emulation will clear the XCH bit when a burst finishes. | 3 | Trusted Firmware now supports A72 on sbsa-ref by default [1] so enable |
4 | This is not quite correct. According to the i.MX7d referemce manual, | 4 | it for QEMU as well. A53 was already enabled there. |
5 | Rev 0.1, §10.1.7.3: | ||
6 | 5 | ||
7 | This bit [XCH] is cleared automatically when all data in the TXFIFO | 6 | 1. https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/7117 |
8 | and the shift register has been shifted out. | ||
9 | 7 | ||
10 | So XCH should be cleared when the FIFO empties, not on completion of a | 8 | Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
11 | burst. The FIFO is 64 x 32 bits = 2048 bits, while the max burst size | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
12 | is larger at 4096 bits. So it's possible that the burst is not finished | 10 | Message-id: 20201120141705.246690-1-marcin.juszkiewicz@linaro.org |
13 | after the TXFIFO empties. | ||
14 | |||
15 | Sending a large block (> 2048 bits) with the Linux driver will use a | ||
16 | burst that is larger than the TXFIFO. After the TXFIFO has emptied XCH | ||
17 | does not become unset, as the burst is not yet finished. | ||
18 | |||
19 | What should happen after the TXFIFO empties is the driver will refill it | ||
20 | and set XCH. The rising edge of XCH will trigger another transfer to | ||
21 | begin. However, since the emulation does not set XCH to 0, there is no | ||
22 | rising edge and the next trasfer never begins. | ||
23 | |||
24 | Signed-off-by: Trent Piepho <tpiepho@impinj.com> | ||
25 | Message-id: 20180731201056.29257-1-tpiepho@impinj.com | ||
26 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
28 | --- | 13 | --- |
29 | hw/ssi/imx_spi.c | 3 +-- | 14 | hw/arm/sbsa-ref.c | 23 ++++++++++++++++++++--- |
30 | 1 file changed, 1 insertion(+), 2 deletions(-) | 15 | 1 file changed, 20 insertions(+), 3 deletions(-) |
31 | 16 | ||
32 | diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c | 17 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
33 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/hw/ssi/imx_spi.c | 19 | --- a/hw/arm/sbsa-ref.c |
35 | +++ b/hw/ssi/imx_spi.c | 20 | +++ b/hw/arm/sbsa-ref.c |
36 | @@ -XXX,XX +XXX,XX @@ static void imx_spi_flush_txfifo(IMXSPIState *s) | 21 | @@ -XXX,XX +XXX,XX @@ static const int sbsa_ref_irqmap[] = { |
37 | } | 22 | [SBSA_GWDT] = 16, |
38 | 23 | }; | |
39 | if (s->burst_length <= 0) { | 24 | |
40 | - s->regs[ECSPI_CONREG] &= ~ECSPI_CONREG_XCH; | 25 | +static const char * const valid_cpus[] = { |
41 | - | 26 | + ARM_CPU_TYPE_NAME("cortex-a53"), |
42 | if (!imx_spi_is_multiple_master_burst(s)) { | 27 | + ARM_CPU_TYPE_NAME("cortex-a57"), |
43 | s->regs[ECSPI_STATREG] |= ECSPI_STATREG_TC; | 28 | + ARM_CPU_TYPE_NAME("cortex-a72"), |
44 | break; | 29 | +}; |
45 | @@ -XXX,XX +XXX,XX @@ static void imx_spi_flush_txfifo(IMXSPIState *s) | 30 | + |
46 | 31 | +static bool cpu_type_valid(const char *cpu) | |
47 | if (fifo32_is_empty(&s->tx_fifo)) { | 32 | +{ |
48 | s->regs[ECSPI_STATREG] |= ECSPI_STATREG_TC; | 33 | + int i; |
49 | + s->regs[ECSPI_CONREG] &= ~ECSPI_CONREG_XCH; | 34 | + |
35 | + for (i = 0; i < ARRAY_SIZE(valid_cpus); i++) { | ||
36 | + if (strcmp(cpu, valid_cpus[i]) == 0) { | ||
37 | + return true; | ||
38 | + } | ||
39 | + } | ||
40 | + return false; | ||
41 | +} | ||
42 | + | ||
43 | static uint64_t sbsa_ref_cpu_mp_affinity(SBSAMachineState *sms, int idx) | ||
44 | { | ||
45 | uint8_t clustersz = ARM_DEFAULT_CPUS_PER_CLUSTER; | ||
46 | @@ -XXX,XX +XXX,XX @@ static void sbsa_ref_init(MachineState *machine) | ||
47 | const CPUArchIdList *possible_cpus; | ||
48 | int n, sbsa_max_cpus; | ||
49 | |||
50 | - if (strcmp(machine->cpu_type, ARM_CPU_TYPE_NAME("cortex-a57"))) { | ||
51 | - error_report("sbsa-ref: CPU type other than the built-in " | ||
52 | - "cortex-a57 not supported"); | ||
53 | + if (!cpu_type_valid(machine->cpu_type)) { | ||
54 | + error_report("mach-virt: CPU type %s not supported", machine->cpu_type); | ||
55 | exit(1); | ||
50 | } | 56 | } |
51 | 57 | ||
52 | /* TODO: We should also use TDR and RDR bits */ | ||
53 | -- | 58 | -- |
54 | 2.18.0 | 59 | 2.20.1 |
55 | 60 | ||
56 | 61 | diff view generated by jsdifflib |
1 | From: Stefan Hajnoczi <stefanha@redhat.com> | 1 | From: Havard Skinnemoen <hskinnemoen@google.com> |
---|---|---|---|
2 | 2 | ||
3 | The next patch will need to free a rom. There is already code to do | 3 | Dump the collected random data after a randomness test failure. |
4 | this in rom_add_file(). | ||
5 | 4 | ||
6 | Note that rom_add_file() uses: | 5 | Note that this relies on the test having called |
6 | g_test_set_nonfatal_assertions() so we don't abort immediately on the | ||
7 | assertion failure. | ||
7 | 8 | ||
8 | rom = g_malloc0(sizeof(*rom)); | 9 | Signed-off-by: Havard Skinnemoen <hskinnemoen@google.com> |
9 | ... | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | if (rom->fw_dir) { | 11 | [PMM: minor commit message tweak] |
11 | g_free(rom->fw_dir); | ||
12 | g_free(rom->fw_file); | ||
13 | } | ||
14 | |||
15 | The conditional is unnecessary since g_free(NULL) is a no-op. | ||
16 | |||
17 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
18 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
19 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
20 | Message-id: 20180814162739.11814-4-stefanha@redhat.com | ||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
22 | --- | 13 | --- |
23 | hw/core/loader.c | 21 ++++++++++++--------- | 14 | tests/qtest/npcm7xx_rng-test.c | 12 ++++++++++++ |
24 | 1 file changed, 12 insertions(+), 9 deletions(-) | 15 | 1 file changed, 12 insertions(+) |
25 | 16 | ||
26 | diff --git a/hw/core/loader.c b/hw/core/loader.c | 17 | diff --git a/tests/qtest/npcm7xx_rng-test.c b/tests/qtest/npcm7xx_rng-test.c |
27 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/hw/core/loader.c | 19 | --- a/tests/qtest/npcm7xx_rng-test.c |
29 | +++ b/hw/core/loader.c | 20 | +++ b/tests/qtest/npcm7xx_rng-test.c |
30 | @@ -XXX,XX +XXX,XX @@ struct Rom { | 21 | @@ -XXX,XX +XXX,XX @@ |
31 | static FWCfgState *fw_cfg; | 22 | |
32 | static QTAILQ_HEAD(, Rom) roms = QTAILQ_HEAD_INITIALIZER(roms); | 23 | #include "libqtest-single.h" |
33 | 24 | #include "qemu/bitops.h" | |
34 | +/* rom->data must be heap-allocated (do not use with rom_add_elf_program()) */ | 25 | +#include "qemu-common.h" |
35 | +static void rom_free(Rom *rom) | 26 | |
27 | #define RNG_BASE_ADDR 0xf000b000 | ||
28 | |||
29 | @@ -XXX,XX +XXX,XX @@ | ||
30 | /* Number of bits to collect for randomness tests. */ | ||
31 | #define TEST_INPUT_BITS (128) | ||
32 | |||
33 | +static void dump_buf_if_failed(const uint8_t *buf, size_t size) | ||
36 | +{ | 34 | +{ |
37 | + g_free(rom->data); | 35 | + if (g_test_failed()) { |
38 | + g_free(rom->path); | 36 | + qemu_hexdump(stderr, "", buf, size); |
39 | + g_free(rom->name); | 37 | + } |
40 | + g_free(rom->fw_dir); | ||
41 | + g_free(rom->fw_file); | ||
42 | + g_free(rom); | ||
43 | +} | 38 | +} |
44 | + | 39 | + |
45 | static inline bool rom_order_compare(Rom *rom, Rom *item) | 40 | static void rng_writeb(unsigned int offset, uint8_t value) |
46 | { | 41 | { |
47 | return ((uintptr_t)(void *)rom->as > (uintptr_t)(void *)item->as) || | 42 | writeb(RNG_BASE_ADDR + offset, value); |
48 | @@ -XXX,XX +XXX,XX @@ err: | 43 | @@ -XXX,XX +XXX,XX @@ static void test_continuous_monobit(void) |
49 | if (fd != -1) | 44 | } |
50 | close(fd); | 45 | |
51 | 46 | g_assert_cmpfloat(calc_monobit_p(buf, sizeof(buf)), >, 0.01); | |
52 | - g_free(rom->data); | 47 | + dump_buf_if_failed(buf, sizeof(buf)); |
53 | - g_free(rom->path); | ||
54 | - g_free(rom->name); | ||
55 | - if (fw_dir) { | ||
56 | - g_free(rom->fw_dir); | ||
57 | - g_free(rom->fw_file); | ||
58 | - } | ||
59 | - g_free(rom); | ||
60 | - | ||
61 | + rom_free(rom); | ||
62 | return -1; | ||
63 | } | 48 | } |
64 | 49 | ||
50 | /* | ||
51 | @@ -XXX,XX +XXX,XX @@ static void test_continuous_runs(void) | ||
52 | } | ||
53 | |||
54 | g_assert_cmpfloat(calc_runs_p(buf.l, sizeof(buf) * BITS_PER_BYTE), >, 0.01); | ||
55 | + dump_buf_if_failed(buf.c, sizeof(buf)); | ||
56 | } | ||
57 | |||
58 | /* | ||
59 | @@ -XXX,XX +XXX,XX @@ static void test_first_byte_monobit(void) | ||
60 | } | ||
61 | |||
62 | g_assert_cmpfloat(calc_monobit_p(buf, sizeof(buf)), >, 0.01); | ||
63 | + dump_buf_if_failed(buf, sizeof(buf)); | ||
64 | } | ||
65 | |||
66 | /* | ||
67 | @@ -XXX,XX +XXX,XX @@ static void test_first_byte_runs(void) | ||
68 | } | ||
69 | |||
70 | g_assert_cmpfloat(calc_runs_p(buf.l, sizeof(buf) * BITS_PER_BYTE), >, 0.01); | ||
71 | + dump_buf_if_failed(buf.c, sizeof(buf)); | ||
72 | } | ||
73 | |||
74 | int main(int argc, char **argv) | ||
65 | -- | 75 | -- |
66 | 2.18.0 | 76 | 2.20.1 |
67 | 77 | ||
68 | 78 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Alex Chen <alex.chen@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | These insns require u=1; failed to include that in the switch | 3 | We should use printf format specifier "%u" instead of "%d" for |
4 | cases. This probably happened during one of the rebases just | 4 | argument of type "unsigned int". |
5 | before final commit. | ||
6 | 5 | ||
7 | Fixes: d17b7cdcf4e | 6 | Reported-by: Euler Robot <euler.robot@huawei.com> |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Alex Chen <alex.chen@huawei.com> |
9 | Reviewed-by: Laurent Desnogues <laurent.desnogues@gmail.com> | 8 | Message-id: 20201126111109.112238-2-alex.chen@huawei.com |
10 | Message-id: 20180810193129.1556-6-richard.henderson@linaro.org | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 11 | --- |
13 | target/arm/translate-a64.c | 12 ++++++------ | 12 | hw/misc/imx25_ccm.c | 12 ++++++------ |
14 | 1 file changed, 6 insertions(+), 6 deletions(-) | 13 | 1 file changed, 6 insertions(+), 6 deletions(-) |
15 | 14 | ||
16 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 15 | diff --git a/hw/misc/imx25_ccm.c b/hw/misc/imx25_ccm.c |
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/translate-a64.c | 17 | --- a/hw/misc/imx25_ccm.c |
19 | +++ b/target/arm/translate-a64.c | 18 | +++ b/hw/misc/imx25_ccm.c |
20 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) | 19 | @@ -XXX,XX +XXX,XX @@ static const char *imx25_ccm_reg_name(uint32_t reg) |
21 | } | 20 | case IMX25_CCM_LPIMR1_REG: |
22 | feature = ARM_FEATURE_V8_DOTPROD; | 21 | return "lpimr1"; |
22 | default: | ||
23 | - sprintf(unknown, "[%d ?]", reg); | ||
24 | + sprintf(unknown, "[%u ?]", reg); | ||
25 | return unknown; | ||
26 | } | ||
27 | } | ||
28 | @@ -XXX,XX +XXX,XX @@ static uint32_t imx25_ccm_get_mpll_clk(IMXCCMState *dev) | ||
29 | freq = imx_ccm_calc_pll(s->reg[IMX25_CCM_MPCTL_REG], CKIH_FREQ); | ||
30 | } | ||
31 | |||
32 | - DPRINTF("freq = %d\n", freq); | ||
33 | + DPRINTF("freq = %u\n", freq); | ||
34 | |||
35 | return freq; | ||
36 | } | ||
37 | @@ -XXX,XX +XXX,XX @@ static uint32_t imx25_ccm_get_mcu_clk(IMXCCMState *dev) | ||
38 | |||
39 | freq = freq / (1 + EXTRACT(s->reg[IMX25_CCM_CCTL_REG], ARM_CLK_DIV)); | ||
40 | |||
41 | - DPRINTF("freq = %d\n", freq); | ||
42 | + DPRINTF("freq = %u\n", freq); | ||
43 | |||
44 | return freq; | ||
45 | } | ||
46 | @@ -XXX,XX +XXX,XX @@ static uint32_t imx25_ccm_get_ahb_clk(IMXCCMState *dev) | ||
47 | freq = imx25_ccm_get_mcu_clk(dev) | ||
48 | / (1 + EXTRACT(s->reg[IMX25_CCM_CCTL_REG], AHB_CLK_DIV)); | ||
49 | |||
50 | - DPRINTF("freq = %d\n", freq); | ||
51 | + DPRINTF("freq = %u\n", freq); | ||
52 | |||
53 | return freq; | ||
54 | } | ||
55 | @@ -XXX,XX +XXX,XX @@ static uint32_t imx25_ccm_get_ipg_clk(IMXCCMState *dev) | ||
56 | |||
57 | freq = imx25_ccm_get_ahb_clk(dev) / 2; | ||
58 | |||
59 | - DPRINTF("freq = %d\n", freq); | ||
60 | + DPRINTF("freq = %u\n", freq); | ||
61 | |||
62 | return freq; | ||
63 | } | ||
64 | @@ -XXX,XX +XXX,XX @@ static uint32_t imx25_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock) | ||
23 | break; | 65 | break; |
24 | - case 0x8: /* FCMLA, #0 */ | 66 | } |
25 | - case 0x9: /* FCMLA, #90 */ | 67 | |
26 | - case 0xa: /* FCMLA, #180 */ | 68 | - DPRINTF("Clock = %d) = %d\n", clock, freq); |
27 | - case 0xb: /* FCMLA, #270 */ | 69 | + DPRINTF("Clock = %d) = %u\n", clock, freq); |
28 | - case 0xc: /* FCADD, #90 */ | 70 | |
29 | - case 0xe: /* FCADD, #270 */ | 71 | return freq; |
30 | + case 0x18: /* FCMLA, #0 */ | 72 | } |
31 | + case 0x19: /* FCMLA, #90 */ | ||
32 | + case 0x1a: /* FCMLA, #180 */ | ||
33 | + case 0x1b: /* FCMLA, #270 */ | ||
34 | + case 0x1c: /* FCADD, #90 */ | ||
35 | + case 0x1e: /* FCADD, #270 */ | ||
36 | if (size == 0 | ||
37 | || (size == 1 && !arm_dc_feature(s, ARM_FEATURE_V8_FP16)) | ||
38 | || (size == 3 && !is_q)) { | ||
39 | -- | 73 | -- |
40 | 2.18.0 | 74 | 2.20.1 |
41 | 75 | ||
42 | 76 | diff view generated by jsdifflib |
1 | From: Thomas Huth <thuth@redhat.com> | 1 | From: Alex Chen <alex.chen@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | Now that we've got the common sysbus_init_child_obj() function, we do | 3 | We should use printf format specifier "%u" instead of "%d" for |
4 | not need the local init_sysbus_child() anymore. | 4 | argument of type "unsigned int". |
5 | 5 | ||
6 | Signed-off-by: Thomas Huth <thuth@redhat.com> | 6 | Reported-by: Euler Robot <euler.robot@huawei.com> |
7 | Message-id: 1534420566-15799-1-git-send-email-thuth@redhat.com | 7 | Signed-off-by: Alex Chen <alex.chen@huawei.com> |
8 | Message-id: 20201126111109.112238-3-alex.chen@huawei.com | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 11 | --- |
11 | hw/arm/mps2-tz.c | 32 +++++++++++--------------------- | 12 | hw/misc/imx31_ccm.c | 14 +++++++------- |
12 | 1 file changed, 11 insertions(+), 21 deletions(-) | 13 | hw/misc/imx_ccm.c | 4 ++-- |
14 | 2 files changed, 9 insertions(+), 9 deletions(-) | ||
13 | 15 | ||
14 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | 16 | diff --git a/hw/misc/imx31_ccm.c b/hw/misc/imx31_ccm.c |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/arm/mps2-tz.c | 18 | --- a/hw/misc/imx31_ccm.c |
17 | +++ b/hw/arm/mps2-tz.c | 19 | +++ b/hw/misc/imx31_ccm.c |
18 | @@ -XXX,XX +XXX,XX @@ static void make_ram_alias(MemoryRegion *mr, const char *name, | 20 | @@ -XXX,XX +XXX,XX @@ static const char *imx31_ccm_reg_name(uint32_t reg) |
19 | memory_region_add_subregion(get_system_memory(), base, mr); | 21 | case IMX31_CCM_PDR2_REG: |
22 | return "PDR2"; | ||
23 | default: | ||
24 | - sprintf(unknown, "[%d ?]", reg); | ||
25 | + sprintf(unknown, "[%u ?]", reg); | ||
26 | return unknown; | ||
27 | } | ||
20 | } | 28 | } |
21 | 29 | @@ -XXX,XX +XXX,XX @@ static uint32_t imx31_ccm_get_pll_ref_clk(IMXCCMState *dev) | |
22 | -static void init_sysbus_child(Object *parent, const char *childname, | 30 | freq = CKIH_FREQ; |
23 | - void *child, size_t childsize, | ||
24 | - const char *childtype) | ||
25 | -{ | ||
26 | - object_initialize(child, childsize, childtype); | ||
27 | - object_property_add_child(parent, childname, OBJECT(child), &error_abort); | ||
28 | - qdev_set_parent_bus(DEVICE(child), sysbus_get_default()); | ||
29 | - | ||
30 | -} | ||
31 | - | ||
32 | /* Most of the devices in the AN505 FPGA image sit behind | ||
33 | * Peripheral Protection Controllers. These data structures | ||
34 | * define the layout of which devices sit behind which PPCs. | ||
35 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_unimp_dev(MPS2TZMachineState *mms, | ||
36 | */ | ||
37 | UnimplementedDeviceState *uds = opaque; | ||
38 | |||
39 | - init_sysbus_child(OBJECT(mms), name, uds, | ||
40 | - sizeof(UnimplementedDeviceState), | ||
41 | - TYPE_UNIMPLEMENTED_DEVICE); | ||
42 | + sysbus_init_child_obj(OBJECT(mms), name, uds, | ||
43 | + sizeof(UnimplementedDeviceState), | ||
44 | + TYPE_UNIMPLEMENTED_DEVICE); | ||
45 | qdev_prop_set_string(DEVICE(uds), "name", name); | ||
46 | qdev_prop_set_uint64(DEVICE(uds), "size", size); | ||
47 | object_property_set_bool(OBJECT(uds), true, "realized", &error_fatal); | ||
48 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_uart(MPS2TZMachineState *mms, void *opaque, | ||
49 | DeviceState *iotkitdev = DEVICE(&mms->iotkit); | ||
50 | DeviceState *orgate_dev = DEVICE(&mms->uart_irq_orgate); | ||
51 | |||
52 | - init_sysbus_child(OBJECT(mms), name, uart, | ||
53 | - sizeof(mms->uart[0]), TYPE_CMSDK_APB_UART); | ||
54 | + sysbus_init_child_obj(OBJECT(mms), name, uart, sizeof(mms->uart[0]), | ||
55 | + TYPE_CMSDK_APB_UART); | ||
56 | qdev_prop_set_chr(DEVICE(uart), "chardev", serial_hd(i)); | ||
57 | qdev_prop_set_uint32(DEVICE(uart), "pclk-frq", SYSCLK_FRQ); | ||
58 | object_property_set_bool(OBJECT(uart), true, "realized", &error_fatal); | ||
59 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_mpc(MPS2TZMachineState *mms, void *opaque, | ||
60 | |||
61 | memory_region_init_ram(ssram, NULL, name, ramsize[i], &error_fatal); | ||
62 | |||
63 | - init_sysbus_child(OBJECT(mms), mpcname, mpc, | ||
64 | - sizeof(mms->ssram_mpc[0]), TYPE_TZ_MPC); | ||
65 | + sysbus_init_child_obj(OBJECT(mms), mpcname, mpc, sizeof(mms->ssram_mpc[0]), | ||
66 | + TYPE_TZ_MPC); | ||
67 | object_property_set_link(OBJECT(mpc), OBJECT(ssram), | ||
68 | "downstream", &error_fatal); | ||
69 | object_property_set_bool(OBJECT(mpc), true, "realized", &error_fatal); | ||
70 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | ||
71 | exit(1); | ||
72 | } | 31 | } |
73 | 32 | ||
74 | - init_sysbus_child(OBJECT(machine), "iotkit", &mms->iotkit, | 33 | - DPRINTF("freq = %d\n", freq); |
75 | - sizeof(mms->iotkit), TYPE_IOTKIT); | 34 | + DPRINTF("freq = %u\n", freq); |
76 | + sysbus_init_child_obj(OBJECT(machine), "iotkit", &mms->iotkit, | 35 | |
77 | + sizeof(mms->iotkit), TYPE_IOTKIT); | 36 | return freq; |
78 | iotkitdev = DEVICE(&mms->iotkit); | 37 | } |
79 | object_property_set_link(OBJECT(&mms->iotkit), OBJECT(system_memory), | 38 | @@ -XXX,XX +XXX,XX @@ static uint32_t imx31_ccm_get_mpll_clk(IMXCCMState *dev) |
80 | "memory", &error_abort); | 39 | freq = imx_ccm_calc_pll(s->reg[IMX31_CCM_MPCTL_REG], |
81 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | 40 | imx31_ccm_get_pll_ref_clk(dev)); |
82 | int port; | 41 | |
83 | char *gpioname; | 42 | - DPRINTF("freq = %d\n", freq); |
84 | 43 | + DPRINTF("freq = %u\n", freq); | |
85 | - init_sysbus_child(OBJECT(machine), ppcinfo->name, ppc, | 44 | |
86 | - sizeof(TZPPC), TYPE_TZ_PPC); | 45 | return freq; |
87 | + sysbus_init_child_obj(OBJECT(machine), ppcinfo->name, ppc, | 46 | } |
88 | + sizeof(TZPPC), TYPE_TZ_PPC); | 47 | @@ -XXX,XX +XXX,XX @@ static uint32_t imx31_ccm_get_mcu_main_clk(IMXCCMState *dev) |
89 | ppcdev = DEVICE(ppc); | 48 | freq = imx31_ccm_get_mpll_clk(dev); |
90 | 49 | } | |
91 | for (port = 0; port < TZ_NUM_PORTS; port++) { | 50 | |
51 | - DPRINTF("freq = %d\n", freq); | ||
52 | + DPRINTF("freq = %u\n", freq); | ||
53 | |||
54 | return freq; | ||
55 | } | ||
56 | @@ -XXX,XX +XXX,XX @@ static uint32_t imx31_ccm_get_hclk_clk(IMXCCMState *dev) | ||
57 | freq = imx31_ccm_get_mcu_main_clk(dev) | ||
58 | / (1 + EXTRACT(s->reg[IMX31_CCM_PDR0_REG], MAX)); | ||
59 | |||
60 | - DPRINTF("freq = %d\n", freq); | ||
61 | + DPRINTF("freq = %u\n", freq); | ||
62 | |||
63 | return freq; | ||
64 | } | ||
65 | @@ -XXX,XX +XXX,XX @@ static uint32_t imx31_ccm_get_ipg_clk(IMXCCMState *dev) | ||
66 | freq = imx31_ccm_get_hclk_clk(dev) | ||
67 | / (1 + EXTRACT(s->reg[IMX31_CCM_PDR0_REG], IPG)); | ||
68 | |||
69 | - DPRINTF("freq = %d\n", freq); | ||
70 | + DPRINTF("freq = %u\n", freq); | ||
71 | |||
72 | return freq; | ||
73 | } | ||
74 | @@ -XXX,XX +XXX,XX @@ static uint32_t imx31_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock) | ||
75 | break; | ||
76 | } | ||
77 | |||
78 | - DPRINTF("Clock = %d) = %d\n", clock, freq); | ||
79 | + DPRINTF("Clock = %d) = %u\n", clock, freq); | ||
80 | |||
81 | return freq; | ||
82 | } | ||
83 | diff --git a/hw/misc/imx_ccm.c b/hw/misc/imx_ccm.c | ||
84 | index XXXXXXX..XXXXXXX 100644 | ||
85 | --- a/hw/misc/imx_ccm.c | ||
86 | +++ b/hw/misc/imx_ccm.c | ||
87 | @@ -XXX,XX +XXX,XX @@ uint32_t imx_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock) | ||
88 | freq = klass->get_clock_frequency(dev, clock); | ||
89 | } | ||
90 | |||
91 | - DPRINTF("(clock = %d) = %d\n", clock, freq); | ||
92 | + DPRINTF("(clock = %d) = %u\n", clock, freq); | ||
93 | |||
94 | return freq; | ||
95 | } | ||
96 | @@ -XXX,XX +XXX,XX @@ uint32_t imx_ccm_calc_pll(uint32_t pllreg, uint32_t base_freq) | ||
97 | freq = ((2 * (base_freq >> 10) * (mfi * mfd + mfn)) / | ||
98 | (mfd * pd)) << 10; | ||
99 | |||
100 | - DPRINTF("(pllreg = 0x%08x, base_freq = %d) = %d\n", pllreg, base_freq, | ||
101 | + DPRINTF("(pllreg = 0x%08x, base_freq = %u) = %d\n", pllreg, base_freq, | ||
102 | freq); | ||
103 | |||
104 | return freq; | ||
92 | -- | 105 | -- |
93 | 2.18.0 | 106 | 2.20.1 |
94 | 107 | ||
95 | 108 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | From: Alex Chen <alex.chen@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | The SDMC on the ast2500 has 170 registers. | 3 | We should use printf format specifier "%u" instead of "%d" for |
4 | argument of type "unsigned int". | ||
4 | 5 | ||
5 | Signed-off-by: Joel Stanley <joel@jms.id.au> | 6 | Reported-by: Euler Robot <euler.robot@huawei.com> |
6 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 7 | Signed-off-by: Alex Chen <alex.chen@huawei.com> |
7 | Tested-by: Cédric Le Goater <clg@kaod.org> | 8 | Message-id: 20201126111109.112238-4-alex.chen@huawei.com |
8 | Message-id: 20180807075757.7242-2-joel@jms.id.au | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 11 | --- |
11 | include/hw/misc/aspeed_sdmc.h | 2 +- | 12 | hw/misc/imx6_ccm.c | 20 ++++++++++---------- |
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | 13 | hw/misc/imx6_src.c | 2 +- |
14 | 2 files changed, 11 insertions(+), 11 deletions(-) | ||
13 | 15 | ||
14 | diff --git a/include/hw/misc/aspeed_sdmc.h b/include/hw/misc/aspeed_sdmc.h | 16 | diff --git a/hw/misc/imx6_ccm.c b/hw/misc/imx6_ccm.c |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/include/hw/misc/aspeed_sdmc.h | 18 | --- a/hw/misc/imx6_ccm.c |
17 | +++ b/include/hw/misc/aspeed_sdmc.h | 19 | +++ b/hw/misc/imx6_ccm.c |
18 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ static const char *imx6_ccm_reg_name(uint32_t reg) |
19 | #define TYPE_ASPEED_SDMC "aspeed.sdmc" | 21 | case CCM_CMEOR: |
20 | #define ASPEED_SDMC(obj) OBJECT_CHECK(AspeedSDMCState, (obj), TYPE_ASPEED_SDMC) | 22 | return "CMEOR"; |
21 | 23 | default: | |
22 | -#define ASPEED_SDMC_NR_REGS (0x8 >> 2) | 24 | - sprintf(unknown, "%d ?", reg); |
23 | +#define ASPEED_SDMC_NR_REGS (0x174 >> 2) | 25 | + sprintf(unknown, "%u ?", reg); |
24 | 26 | return unknown; | |
25 | typedef struct AspeedSDMCState { | 27 | } |
26 | /*< private >*/ | 28 | } |
29 | @@ -XXX,XX +XXX,XX @@ static const char *imx6_analog_reg_name(uint32_t reg) | ||
30 | case USB_ANALOG_DIGPROG: | ||
31 | return "USB_ANALOG_DIGPROG"; | ||
32 | default: | ||
33 | - sprintf(unknown, "%d ?", reg); | ||
34 | + sprintf(unknown, "%u ?", reg); | ||
35 | return unknown; | ||
36 | } | ||
37 | } | ||
38 | @@ -XXX,XX +XXX,XX @@ static uint64_t imx6_analog_get_pll2_clk(IMX6CCMState *dev) | ||
39 | freq *= 20; | ||
40 | } | ||
41 | |||
42 | - DPRINTF("freq = %d\n", (uint32_t)freq); | ||
43 | + DPRINTF("freq = %u\n", (uint32_t)freq); | ||
44 | |||
45 | return freq; | ||
46 | } | ||
47 | @@ -XXX,XX +XXX,XX @@ static uint64_t imx6_analog_get_pll2_pfd0_clk(IMX6CCMState *dev) | ||
48 | freq = imx6_analog_get_pll2_clk(dev) * 18 | ||
49 | / EXTRACT(dev->analog[CCM_ANALOG_PFD_528], PFD0_FRAC); | ||
50 | |||
51 | - DPRINTF("freq = %d\n", (uint32_t)freq); | ||
52 | + DPRINTF("freq = %u\n", (uint32_t)freq); | ||
53 | |||
54 | return freq; | ||
55 | } | ||
56 | @@ -XXX,XX +XXX,XX @@ static uint64_t imx6_analog_get_pll2_pfd2_clk(IMX6CCMState *dev) | ||
57 | freq = imx6_analog_get_pll2_clk(dev) * 18 | ||
58 | / EXTRACT(dev->analog[CCM_ANALOG_PFD_528], PFD2_FRAC); | ||
59 | |||
60 | - DPRINTF("freq = %d\n", (uint32_t)freq); | ||
61 | + DPRINTF("freq = %u\n", (uint32_t)freq); | ||
62 | |||
63 | return freq; | ||
64 | } | ||
65 | @@ -XXX,XX +XXX,XX @@ static uint64_t imx6_analog_get_periph_clk(IMX6CCMState *dev) | ||
66 | break; | ||
67 | } | ||
68 | |||
69 | - DPRINTF("freq = %d\n", (uint32_t)freq); | ||
70 | + DPRINTF("freq = %u\n", (uint32_t)freq); | ||
71 | |||
72 | return freq; | ||
73 | } | ||
74 | @@ -XXX,XX +XXX,XX @@ static uint64_t imx6_ccm_get_ahb_clk(IMX6CCMState *dev) | ||
75 | freq = imx6_analog_get_periph_clk(dev) | ||
76 | / (1 + EXTRACT(dev->ccm[CCM_CBCDR], AHB_PODF)); | ||
77 | |||
78 | - DPRINTF("freq = %d\n", (uint32_t)freq); | ||
79 | + DPRINTF("freq = %u\n", (uint32_t)freq); | ||
80 | |||
81 | return freq; | ||
82 | } | ||
83 | @@ -XXX,XX +XXX,XX @@ static uint64_t imx6_ccm_get_ipg_clk(IMX6CCMState *dev) | ||
84 | freq = imx6_ccm_get_ahb_clk(dev) | ||
85 | / (1 + EXTRACT(dev->ccm[CCM_CBCDR], IPG_PODF)); | ||
86 | |||
87 | - DPRINTF("freq = %d\n", (uint32_t)freq); | ||
88 | + DPRINTF("freq = %u\n", (uint32_t)freq); | ||
89 | |||
90 | return freq; | ||
91 | } | ||
92 | @@ -XXX,XX +XXX,XX @@ static uint64_t imx6_ccm_get_per_clk(IMX6CCMState *dev) | ||
93 | freq = imx6_ccm_get_ipg_clk(dev) | ||
94 | / (1 + EXTRACT(dev->ccm[CCM_CSCMR1], PERCLK_PODF)); | ||
95 | |||
96 | - DPRINTF("freq = %d\n", (uint32_t)freq); | ||
97 | + DPRINTF("freq = %u\n", (uint32_t)freq); | ||
98 | |||
99 | return freq; | ||
100 | } | ||
101 | @@ -XXX,XX +XXX,XX @@ static uint32_t imx6_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock) | ||
102 | break; | ||
103 | } | ||
104 | |||
105 | - DPRINTF("Clock = %d) = %d\n", clock, freq); | ||
106 | + DPRINTF("Clock = %d) = %u\n", clock, freq); | ||
107 | |||
108 | return freq; | ||
109 | } | ||
110 | diff --git a/hw/misc/imx6_src.c b/hw/misc/imx6_src.c | ||
111 | index XXXXXXX..XXXXXXX 100644 | ||
112 | --- a/hw/misc/imx6_src.c | ||
113 | +++ b/hw/misc/imx6_src.c | ||
114 | @@ -XXX,XX +XXX,XX @@ static const char *imx6_src_reg_name(uint32_t reg) | ||
115 | case SRC_GPR10: | ||
116 | return "SRC_GPR10"; | ||
117 | default: | ||
118 | - sprintf(unknown, "%d ?", reg); | ||
119 | + sprintf(unknown, "%u ?", reg); | ||
120 | return unknown; | ||
121 | } | ||
122 | } | ||
27 | -- | 123 | -- |
28 | 2.18.0 | 124 | 2.20.1 |
29 | 125 | ||
30 | 126 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Alex Chen <alex.chen@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | We were using the wrong flush-to-zero bit for the non-half input. | 3 | We should use printf format specifier "%u" instead of "%d" for |
4 | argument of type "unsigned int". | ||
4 | 5 | ||
5 | Fixes: 46d33d1e3c9 | 6 | Reported-by: Euler Robot <euler.robot@huawei.com> |
6 | Cc: qemu-stable@nongnu.org (3.0.1) | 7 | Signed-off-by: Alex Chen <alex.chen@huawei.com> |
7 | Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com> | 8 | Message-id: 20201126111109.112238-5-alex.chen@huawei.com |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
10 | Tested-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
11 | Message-id: 20180810193129.1556-5-richard.henderson@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 11 | --- |
14 | target/arm/translate-sve.c | 4 ++-- | 12 | hw/misc/imx6ul_ccm.c | 4 ++-- |
15 | 1 file changed, 2 insertions(+), 2 deletions(-) | 13 | 1 file changed, 2 insertions(+), 2 deletions(-) |
16 | 14 | ||
17 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | 15 | diff --git a/hw/misc/imx6ul_ccm.c b/hw/misc/imx6ul_ccm.c |
18 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/translate-sve.c | 17 | --- a/hw/misc/imx6ul_ccm.c |
20 | +++ b/target/arm/translate-sve.c | 18 | +++ b/hw/misc/imx6ul_ccm.c |
21 | @@ -XXX,XX +XXX,XX @@ static bool do_zpz_ptr(DisasContext *s, int rd, int rn, int pg, | 19 | @@ -XXX,XX +XXX,XX @@ static const char *imx6ul_ccm_reg_name(uint32_t reg) |
22 | 20 | case CCM_CMEOR: | |
23 | static bool trans_FCVT_sh(DisasContext *s, arg_rpr_esz *a, uint32_t insn) | 21 | return "CMEOR"; |
24 | { | 22 | default: |
25 | - return do_zpz_ptr(s, a->rd, a->rn, a->pg, true, gen_helper_sve_fcvt_sh); | 23 | - sprintf(unknown, "%d ?", reg); |
26 | + return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_fcvt_sh); | 24 | + sprintf(unknown, "%u ?", reg); |
25 | return unknown; | ||
26 | } | ||
27 | } | 27 | } |
28 | 28 | @@ -XXX,XX +XXX,XX @@ static const char *imx6ul_analog_reg_name(uint32_t reg) | |
29 | static bool trans_FCVT_hs(DisasContext *s, arg_rpr_esz *a, uint32_t insn) | 29 | case USB_ANALOG_DIGPROG: |
30 | @@ -XXX,XX +XXX,XX @@ static bool trans_FCVT_hs(DisasContext *s, arg_rpr_esz *a, uint32_t insn) | 30 | return "USB_ANALOG_DIGPROG"; |
31 | 31 | default: | |
32 | static bool trans_FCVT_dh(DisasContext *s, arg_rpr_esz *a, uint32_t insn) | 32 | - sprintf(unknown, "%d ?", reg); |
33 | { | 33 | + sprintf(unknown, "%u ?", reg); |
34 | - return do_zpz_ptr(s, a->rd, a->rn, a->pg, true, gen_helper_sve_fcvt_dh); | 34 | return unknown; |
35 | + return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_fcvt_dh); | 35 | } |
36 | } | 36 | } |
37 | |||
38 | static bool trans_FCVT_hd(DisasContext *s, arg_rpr_esz *a, uint32_t insn) | ||
39 | -- | 37 | -- |
40 | 2.18.0 | 38 | 2.20.1 |
41 | 39 | ||
42 | 40 | diff view generated by jsdifflib |
1 | From: Stefan Hajnoczi <stefanha@redhat.com> | 1 | For M-profile CPUs, the range from 0xe0000000 to 0xe00fffff is the |
---|---|---|---|
2 | Private Peripheral Bus range, which includes all of the memory mapped | ||
3 | devices and registers that are part of the CPU itself, including the | ||
4 | NVIC, systick timer, and debug and trace components like the Data | ||
5 | Watchpoint and Trace unit (DWT). Within this large region, the range | ||
6 | 0xe000e000 to 0xe000efff is the System Control Space (NVIC, system | ||
7 | registers, systick) and 0xe002e000 to 0exe002efff is its Non-secure | ||
8 | alias. | ||
2 | 9 | ||
3 | Some ARM CPUs have bitbanded IO, a memory region that allows convenient | 10 | The architecture is clear that within the SCS unimplemented registers |
4 | bit access via 32-bit memory loads/stores. This eliminates the need for | 11 | should be RES0 for privileged accesses and generate BusFault for |
5 | read-modify-update instruction sequences. | 12 | unprivileged accesses, and we currently implement this. |
6 | 13 | ||
7 | This patch makes this optional feature an ARMv7MState qdev property, | 14 | It is less clear about how to handle accesses to unimplemented |
8 | allowing boards to choose whether they want bitbanding or not. | 15 | regions of the wider PPB. Unprivileged accesses should definitely |
16 | cause BusFaults (R_DQQS), but the behaviour of privileged accesses is | ||
17 | not given as a general rule. However, the register definitions of | ||
18 | individual registers for components like the DWT all state that they | ||
19 | are RES0 if the relevant component is not implemented, so the | ||
20 | simplest way to provide that is to provide RAZ/WI for the whole range | ||
21 | for privileged accesses. (The v7M Arm ARM does say that reserved | ||
22 | registers should be UNK/SBZP.) | ||
9 | 23 | ||
10 | Status of boards: | 24 | Expand the container MemoryRegion that the NVIC exposes so that |
11 | * iotkit (Cortex M33), no bitband | 25 | it covers the whole PPB space. This means: |
12 | * mps2 (Cortex M3), bitband | 26 | * moving the address that the ARMV7M device maps it to down by |
13 | * msf2 (Cortex M3), bitband | 27 | 0xe000 bytes |
14 | * stellaris (Cortex M3), bitband | 28 | * moving the off and the offsets within the container of all the |
15 | * stm32f205 (Cortex M3), bitband | 29 | subregions forward by 0xe000 bytes |
30 | * adding a new default MemoryRegion that covers the whole container | ||
31 | at a lower priority than anything else and which provides the | ||
32 | RAZWI/BusFault behaviour | ||
16 | 33 | ||
17 | As a side-effect of this patch, Peter Maydell noted that the Ethernet | 34 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | controller on mps2 board is now accessible. Previously they were hidden | 35 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
19 | by the bitband region (which does not exist on the real board). | 36 | Message-id: 20201119215617.29887-2-peter.maydell@linaro.org |
37 | --- | ||
38 | include/hw/intc/armv7m_nvic.h | 1 + | ||
39 | hw/arm/armv7m.c | 2 +- | ||
40 | hw/intc/armv7m_nvic.c | 78 ++++++++++++++++++++++++++++++----- | ||
41 | 3 files changed, 69 insertions(+), 12 deletions(-) | ||
20 | 42 | ||
21 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 43 | diff --git a/include/hw/intc/armv7m_nvic.h b/include/hw/intc/armv7m_nvic.h |
22 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
23 | Message-id: 20180814162739.11814-2-stefanha@redhat.com | ||
24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
25 | --- | ||
26 | include/hw/arm/armv7m.h | 2 ++ | ||
27 | hw/arm/armv7m.c | 37 ++++++++++++++++++++----------------- | ||
28 | hw/arm/mps2.c | 1 + | ||
29 | hw/arm/msf2-soc.c | 1 + | ||
30 | hw/arm/stellaris.c | 1 + | ||
31 | hw/arm/stm32f205_soc.c | 1 + | ||
32 | 6 files changed, 26 insertions(+), 17 deletions(-) | ||
33 | |||
34 | diff --git a/include/hw/arm/armv7m.h b/include/hw/arm/armv7m.h | ||
35 | index XXXXXXX..XXXXXXX 100644 | 44 | index XXXXXXX..XXXXXXX 100644 |
36 | --- a/include/hw/arm/armv7m.h | 45 | --- a/include/hw/intc/armv7m_nvic.h |
37 | +++ b/include/hw/arm/armv7m.h | 46 | +++ b/include/hw/intc/armv7m_nvic.h |
38 | @@ -XXX,XX +XXX,XX @@ typedef struct { | 47 | @@ -XXX,XX +XXX,XX @@ struct NVICState { |
39 | * devices will be automatically layered on top of this view.) | 48 | MemoryRegion systickmem; |
40 | * + Property "idau": IDAU interface (forwarded to CPU object) | 49 | MemoryRegion systick_ns_mem; |
41 | * + Property "init-svtor": secure VTOR reset value (forwarded to CPU object) | 50 | MemoryRegion container; |
42 | + * + Property "enable-bitband": expose bitbanded IO | 51 | + MemoryRegion defaultmem; |
43 | */ | 52 | |
44 | typedef struct ARMv7MState { | 53 | uint32_t num_irq; |
45 | /*< private >*/ | 54 | qemu_irq excpout; |
46 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMv7MState { | ||
47 | MemoryRegion *board_memory; | ||
48 | Object *idau; | ||
49 | uint32_t init_svtor; | ||
50 | + bool enable_bitband; | ||
51 | } ARMv7MState; | ||
52 | |||
53 | #endif | ||
54 | diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c | 55 | diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c |
55 | index XXXXXXX..XXXXXXX 100644 | 56 | index XXXXXXX..XXXXXXX 100644 |
56 | --- a/hw/arm/armv7m.c | 57 | --- a/hw/arm/armv7m.c |
57 | +++ b/hw/arm/armv7m.c | 58 | +++ b/hw/arm/armv7m.c |
58 | @@ -XXX,XX +XXX,XX @@ static void armv7m_realize(DeviceState *dev, Error **errp) | 59 | @@ -XXX,XX +XXX,XX @@ static void armv7m_realize(DeviceState *dev, Error **errp) |
59 | memory_region_add_subregion(&s->container, 0xe000e000, | 60 | sysbus_connect_irq(sbd, 0, |
61 | qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_IRQ)); | ||
62 | |||
63 | - memory_region_add_subregion(&s->container, 0xe000e000, | ||
64 | + memory_region_add_subregion(&s->container, 0xe0000000, | ||
60 | sysbus_mmio_get_region(sbd, 0)); | 65 | sysbus_mmio_get_region(sbd, 0)); |
61 | 66 | ||
62 | - for (i = 0; i < ARRAY_SIZE(s->bitband); i++) { | 67 | for (i = 0; i < ARRAY_SIZE(s->bitband); i++) { |
63 | - Object *obj = OBJECT(&s->bitband[i]); | 68 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c |
64 | - SysBusDevice *sbd = SYS_BUS_DEVICE(&s->bitband[i]); | 69 | index XXXXXXX..XXXXXXX 100644 |
65 | + if (s->enable_bitband) { | 70 | --- a/hw/intc/armv7m_nvic.c |
66 | + for (i = 0; i < ARRAY_SIZE(s->bitband); i++) { | 71 | +++ b/hw/intc/armv7m_nvic.c |
67 | + Object *obj = OBJECT(&s->bitband[i]); | 72 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps nvic_systick_ops = { |
68 | + SysBusDevice *sbd = SYS_BUS_DEVICE(&s->bitband[i]); | 73 | .endianness = DEVICE_NATIVE_ENDIAN, |
69 | 74 | }; | |
70 | - object_property_set_int(obj, bitband_input_addr[i], "base", &err); | 75 | |
71 | - if (err != NULL) { | 76 | +/* |
72 | - error_propagate(errp, err); | 77 | + * Unassigned portions of the PPB space are RAZ/WI for privileged |
73 | - return; | 78 | + * accesses, and fault for non-privileged accesses. |
74 | - } | 79 | + */ |
75 | - object_property_set_link(obj, OBJECT(s->board_memory), | 80 | +static MemTxResult ppb_default_read(void *opaque, hwaddr addr, |
76 | - "source-memory", &error_abort); | 81 | + uint64_t *data, unsigned size, |
77 | - object_property_set_bool(obj, true, "realized", &err); | 82 | + MemTxAttrs attrs) |
78 | - if (err != NULL) { | 83 | +{ |
79 | - error_propagate(errp, err); | 84 | + qemu_log_mask(LOG_UNIMP, "Read of unassigned area of PPB: offset 0x%x\n", |
80 | - return; | 85 | + (uint32_t)addr); |
81 | - } | 86 | + if (attrs.user) { |
82 | + object_property_set_int(obj, bitband_input_addr[i], "base", &err); | 87 | + return MEMTX_ERROR; |
83 | + if (err != NULL) { | 88 | + } |
84 | + error_propagate(errp, err); | 89 | + *data = 0; |
85 | + return; | 90 | + return MEMTX_OK; |
86 | + } | 91 | +} |
87 | + object_property_set_link(obj, OBJECT(s->board_memory), | 92 | + |
88 | + "source-memory", &error_abort); | 93 | +static MemTxResult ppb_default_write(void *opaque, hwaddr addr, |
89 | + object_property_set_bool(obj, true, "realized", &err); | 94 | + uint64_t value, unsigned size, |
90 | + if (err != NULL) { | 95 | + MemTxAttrs attrs) |
91 | + error_propagate(errp, err); | 96 | +{ |
92 | + return; | 97 | + qemu_log_mask(LOG_UNIMP, "Write of unassigned area of PPB: offset 0x%x\n", |
93 | + } | 98 | + (uint32_t)addr); |
94 | 99 | + if (attrs.user) { | |
95 | - memory_region_add_subregion(&s->container, bitband_output_addr[i], | 100 | + return MEMTX_ERROR; |
96 | - sysbus_mmio_get_region(sbd, 0)); | 101 | + } |
97 | + memory_region_add_subregion(&s->container, bitband_output_addr[i], | 102 | + return MEMTX_OK; |
98 | + sysbus_mmio_get_region(sbd, 0)); | 103 | +} |
99 | + } | 104 | + |
105 | +static const MemoryRegionOps ppb_default_ops = { | ||
106 | + .read_with_attrs = ppb_default_read, | ||
107 | + .write_with_attrs = ppb_default_write, | ||
108 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
109 | + .valid.min_access_size = 1, | ||
110 | + .valid.max_access_size = 8, | ||
111 | +}; | ||
112 | + | ||
113 | static int nvic_post_load(void *opaque, int version_id) | ||
114 | { | ||
115 | NVICState *s = opaque; | ||
116 | @@ -XXX,XX +XXX,XX @@ static void nvic_systick_trigger(void *opaque, int n, int level) | ||
117 | static void armv7m_nvic_realize(DeviceState *dev, Error **errp) | ||
118 | { | ||
119 | NVICState *s = NVIC(dev); | ||
120 | - int regionlen; | ||
121 | |||
122 | /* The armv7m container object will have set our CPU pointer */ | ||
123 | if (!s->cpu || !arm_feature(&s->cpu->env, ARM_FEATURE_M)) { | ||
124 | @@ -XXX,XX +XXX,XX @@ static void armv7m_nvic_realize(DeviceState *dev, Error **errp) | ||
125 | M_REG_S)); | ||
100 | } | 126 | } |
101 | } | 127 | |
102 | 128 | - /* The NVIC and System Control Space (SCS) starts at 0xe000e000 | |
103 | @@ -XXX,XX +XXX,XX @@ static Property armv7m_properties[] = { | 129 | + /* |
104 | MemoryRegion *), | 130 | + * This device provides a single sysbus memory region which |
105 | DEFINE_PROP_LINK("idau", ARMv7MState, idau, TYPE_IDAU_INTERFACE, Object *), | 131 | + * represents the whole of the "System PPB" space. This is the |
106 | DEFINE_PROP_UINT32("init-svtor", ARMv7MState, init_svtor, 0), | 132 | + * range from 0xe0000000 to 0xe00fffff and includes the NVIC, |
107 | + DEFINE_PROP_BOOL("enable-bitband", ARMv7MState, enable_bitband, false), | 133 | + * the System Control Space (system registers), the systick timer, |
108 | DEFINE_PROP_END_OF_LIST(), | 134 | + * and for CPUs with the Security extension an NS banked version |
109 | }; | 135 | + * of all of these. |
110 | 136 | + * | |
111 | diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c | 137 | + * The default behaviour for unimplemented registers/ranges |
112 | index XXXXXXX..XXXXXXX 100644 | 138 | + * (for instance the Data Watchpoint and Trace unit at 0xe0001000) |
113 | --- a/hw/arm/mps2.c | 139 | + * is to RAZ/WI for privileged access and BusFault for non-privileged |
114 | +++ b/hw/arm/mps2.c | 140 | + * access. |
115 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) | 141 | + * |
116 | g_assert_not_reached(); | 142 | + * The NVIC and System Control Space (SCS) starts at 0xe000e000 |
143 | * and looks like this: | ||
144 | * 0x004 - ICTR | ||
145 | * 0x010 - 0xff - systick | ||
146 | @@ -XXX,XX +XXX,XX @@ static void armv7m_nvic_realize(DeviceState *dev, Error **errp) | ||
147 | * generally code determining which banked register to use should | ||
148 | * use attrs.secure; code determining actual behaviour of the system | ||
149 | * should use env->v7m.secure. | ||
150 | + * | ||
151 | + * The container covers the whole PPB space. Within it the priority | ||
152 | + * of overlapping regions is: | ||
153 | + * - default region (for RAZ/WI and BusFault) : -1 | ||
154 | + * - system register regions : 0 | ||
155 | + * - systick : 1 | ||
156 | + * This is because the systick device is a small block of registers | ||
157 | + * in the middle of the other system control registers. | ||
158 | */ | ||
159 | - regionlen = arm_feature(&s->cpu->env, ARM_FEATURE_V8) ? 0x21000 : 0x1000; | ||
160 | - memory_region_init(&s->container, OBJECT(s), "nvic", regionlen); | ||
161 | - /* The system register region goes at the bottom of the priority | ||
162 | - * stack as it covers the whole page. | ||
163 | - */ | ||
164 | + memory_region_init(&s->container, OBJECT(s), "nvic", 0x100000); | ||
165 | + memory_region_init_io(&s->defaultmem, OBJECT(s), &ppb_default_ops, s, | ||
166 | + "nvic-default", 0x100000); | ||
167 | + memory_region_add_subregion_overlap(&s->container, 0, &s->defaultmem, -1); | ||
168 | memory_region_init_io(&s->sysregmem, OBJECT(s), &nvic_sysreg_ops, s, | ||
169 | "nvic_sysregs", 0x1000); | ||
170 | - memory_region_add_subregion(&s->container, 0, &s->sysregmem); | ||
171 | + memory_region_add_subregion(&s->container, 0xe000, &s->sysregmem); | ||
172 | |||
173 | memory_region_init_io(&s->systickmem, OBJECT(s), | ||
174 | &nvic_systick_ops, s, | ||
175 | "nvic_systick", 0xe0); | ||
176 | |||
177 | - memory_region_add_subregion_overlap(&s->container, 0x10, | ||
178 | + memory_region_add_subregion_overlap(&s->container, 0xe010, | ||
179 | &s->systickmem, 1); | ||
180 | |||
181 | if (arm_feature(&s->cpu->env, ARM_FEATURE_V8)) { | ||
182 | memory_region_init_io(&s->sysreg_ns_mem, OBJECT(s), | ||
183 | &nvic_sysreg_ns_ops, &s->sysregmem, | ||
184 | "nvic_sysregs_ns", 0x1000); | ||
185 | - memory_region_add_subregion(&s->container, 0x20000, &s->sysreg_ns_mem); | ||
186 | + memory_region_add_subregion(&s->container, 0x2e000, &s->sysreg_ns_mem); | ||
187 | memory_region_init_io(&s->systick_ns_mem, OBJECT(s), | ||
188 | &nvic_sysreg_ns_ops, &s->systickmem, | ||
189 | "nvic_systick_ns", 0xe0); | ||
190 | - memory_region_add_subregion_overlap(&s->container, 0x20010, | ||
191 | + memory_region_add_subregion_overlap(&s->container, 0x2e010, | ||
192 | &s->systick_ns_mem, 1); | ||
117 | } | 193 | } |
118 | qdev_prop_set_string(armv7m, "cpu-type", machine->cpu_type); | 194 | |
119 | + qdev_prop_set_bit(armv7m, "enable-bitband", true); | ||
120 | object_property_set_link(OBJECT(&mms->armv7m), OBJECT(system_memory), | ||
121 | "memory", &error_abort); | ||
122 | object_property_set_bool(OBJECT(&mms->armv7m), true, "realized", | ||
123 | diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c | ||
124 | index XXXXXXX..XXXXXXX 100644 | ||
125 | --- a/hw/arm/msf2-soc.c | ||
126 | +++ b/hw/arm/msf2-soc.c | ||
127 | @@ -XXX,XX +XXX,XX @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp) | ||
128 | armv7m = DEVICE(&s->armv7m); | ||
129 | qdev_prop_set_uint32(armv7m, "num-irq", 81); | ||
130 | qdev_prop_set_string(armv7m, "cpu-type", s->cpu_type); | ||
131 | + qdev_prop_set_bit(armv7m, "enable-bitband", true); | ||
132 | object_property_set_link(OBJECT(&s->armv7m), OBJECT(get_system_memory()), | ||
133 | "memory", &error_abort); | ||
134 | object_property_set_bool(OBJECT(&s->armv7m), true, "realized", &err); | ||
135 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | ||
136 | index XXXXXXX..XXXXXXX 100644 | ||
137 | --- a/hw/arm/stellaris.c | ||
138 | +++ b/hw/arm/stellaris.c | ||
139 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
140 | nvic = qdev_create(NULL, TYPE_ARMV7M); | ||
141 | qdev_prop_set_uint32(nvic, "num-irq", NUM_IRQ_LINES); | ||
142 | qdev_prop_set_string(nvic, "cpu-type", ms->cpu_type); | ||
143 | + qdev_prop_set_bit(nvic, "enable-bitband", true); | ||
144 | object_property_set_link(OBJECT(nvic), OBJECT(get_system_memory()), | ||
145 | "memory", &error_abort); | ||
146 | /* This will exit with an error if the user passed us a bad cpu_type */ | ||
147 | diff --git a/hw/arm/stm32f205_soc.c b/hw/arm/stm32f205_soc.c | ||
148 | index XXXXXXX..XXXXXXX 100644 | ||
149 | --- a/hw/arm/stm32f205_soc.c | ||
150 | +++ b/hw/arm/stm32f205_soc.c | ||
151 | @@ -XXX,XX +XXX,XX @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp) | ||
152 | armv7m = DEVICE(&s->armv7m); | ||
153 | qdev_prop_set_uint32(armv7m, "num-irq", 96); | ||
154 | qdev_prop_set_string(armv7m, "cpu-type", s->cpu_type); | ||
155 | + qdev_prop_set_bit(armv7m, "enable-bitband", true); | ||
156 | object_property_set_link(OBJECT(&s->armv7m), OBJECT(get_system_memory()), | ||
157 | "memory", &error_abort); | ||
158 | object_property_set_bool(OBJECT(&s->armv7m), true, "realized", &err); | ||
159 | -- | 195 | -- |
160 | 2.18.0 | 196 | 2.20.1 |
161 | 197 | ||
162 | 198 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | In v8.1M the PXN architecture extension adds a new PXN bit to the |
---|---|---|---|
2 | MPU_RLAR registers, which forbids execution of code in the region | ||
3 | from a privileged mode. | ||
2 | 4 | ||
3 | When FZ is set, input_denormal exceptions are recognized, but this does | 5 | This is another feature which is just in the generic "in v8.1M" set |
4 | not happen with FZ16. The softfloat code has no way to distinguish | 6 | and has no ID register field indicating its presence. |
5 | these bits and will raise such exceptions into fp_status_f16.flags, | ||
6 | so ignore them when computing the accumulated flags. | ||
7 | 7 | ||
8 | Cc: qemu-stable@nongnu.org (3.0.1) | ||
9 | Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Reviewed-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
12 | Tested-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
13 | Message-id: 20180810193129.1556-3-richard.henderson@linaro.org | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20201119215617.29887-3-peter.maydell@linaro.org | ||
15 | --- | 11 | --- |
16 | target/arm/helper.c | 6 +++++- | 12 | target/arm/helper.c | 7 ++++++- |
17 | 1 file changed, 5 insertions(+), 1 deletion(-) | 13 | 1 file changed, 6 insertions(+), 1 deletion(-) |
18 | 14 | ||
19 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 15 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
20 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/helper.c | 17 | --- a/target/arm/helper.c |
22 | +++ b/target/arm/helper.c | 18 | +++ b/target/arm/helper.c |
23 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env) | 19 | @@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, |
24 | fpscr = (env->vfp.xregs[ARM_VFP_FPSCR] & 0xffc8ffff) | 20 | } else { |
25 | | (env->vfp.vec_len << 16) | 21 | uint32_t ap = extract32(env->pmsav8.rbar[secure][matchregion], 1, 2); |
26 | | (env->vfp.vec_stride << 20); | 22 | uint32_t xn = extract32(env->pmsav8.rbar[secure][matchregion], 0, 1); |
23 | + bool pxn = false; | ||
27 | + | 24 | + |
28 | i = get_float_exception_flags(&env->vfp.fp_status); | 25 | + if (arm_feature(env, ARM_FEATURE_V8_1M)) { |
29 | i |= get_float_exception_flags(&env->vfp.standard_fp_status); | 26 | + pxn = extract32(env->pmsav8.rlar[secure][matchregion], 4, 1); |
30 | - i |= get_float_exception_flags(&env->vfp.fp_status_f16); | 27 | + } |
31 | + /* FZ16 does not generate an input denormal exception. */ | 28 | |
32 | + i |= (get_float_exception_flags(&env->vfp.fp_status_f16) | 29 | if (m_is_system_region(env, address)) { |
33 | + & ~float_flag_input_denormal); | 30 | /* System space is always execute never */ |
34 | + | 31 | @@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, |
35 | fpscr |= vfp_exceptbits_from_host(i); | 32 | } |
36 | return fpscr; | 33 | |
37 | } | 34 | *prot = simple_ap_to_rw_prot(env, mmu_idx, ap); |
35 | - if (*prot && !xn) { | ||
36 | + if (*prot && !xn && !(pxn && !is_user)) { | ||
37 | *prot |= PAGE_EXEC; | ||
38 | } | ||
39 | /* We don't need to look the attribute up in the MAIR0/MAIR1 | ||
38 | -- | 40 | -- |
39 | 2.18.0 | 41 | 2.20.1 |
40 | 42 | ||
41 | 43 | diff view generated by jsdifflib |
1 | From: Stefan Hajnoczi <stefanha@redhat.com> | 1 | In arm_cpu_realizefn() we check whether the board code disabled EL3 |
---|---|---|---|
2 | via the has_el3 CPU object property, which we create if the CPU | ||
3 | starts with the ARM_FEATURE_EL3 feature bit. If it is disabled, then | ||
4 | we turn off ARM_FEATURE_EL3 and also zero out the relevant fields in | ||
5 | the ID_PFR1 and ID_AA64PFR0 registers. | ||
2 | 6 | ||
3 | Define a "cortex-m0" ARMv6-M CPU model. | 7 | This codepath was incorrectly being taken for M-profile CPUs, which |
8 | do not have an EL3 and don't set ARM_FEATURE_EL3, but which may have | ||
9 | the M-profile Security extension and so should have non-zero values | ||
10 | in the ID_PFR1.Security field. | ||
4 | 11 | ||
5 | Most of the register reset values set by other CPU models are not | 12 | Restrict the handling of the feature flag to A/R-profile cores. |
6 | relevant for the cut-down ARMv6-M architecture. | ||
7 | 13 | ||
8 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Message-id: 20180814162739.11814-3-stefanha@redhat.com | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | Message-id: 20201119215617.29887-4-peter.maydell@linaro.org | ||
13 | --- | 17 | --- |
14 | target/arm/cpu.c | 11 +++++++++++ | 18 | target/arm/cpu.c | 2 +- |
15 | 1 file changed, 11 insertions(+) | 19 | 1 file changed, 1 insertion(+), 1 deletion(-) |
16 | 20 | ||
17 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 21 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
18 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/cpu.c | 23 | --- a/target/arm/cpu.c |
20 | +++ b/target/arm/cpu.c | 24 | +++ b/target/arm/cpu.c |
21 | @@ -XXX,XX +XXX,XX @@ static void arm11mpcore_initfn(Object *obj) | 25 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
22 | cpu->reset_auxcr = 1; | 26 | } |
23 | } | 27 | } |
24 | 28 | ||
25 | +static void cortex_m0_initfn(Object *obj) | 29 | - if (!cpu->has_el3) { |
26 | +{ | 30 | + if (!arm_feature(env, ARM_FEATURE_M) && !cpu->has_el3) { |
27 | + ARMCPU *cpu = ARM_CPU(obj); | 31 | /* If the has_el3 CPU property is disabled then we need to disable the |
28 | + set_feature(&cpu->env, ARM_FEATURE_V6); | 32 | * feature. |
29 | + set_feature(&cpu->env, ARM_FEATURE_M); | 33 | */ |
30 | + | ||
31 | + cpu->midr = 0x410cc200; | ||
32 | +} | ||
33 | + | ||
34 | static void cortex_m3_initfn(Object *obj) | ||
35 | { | ||
36 | ARMCPU *cpu = ARM_CPU(obj); | ||
37 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_cpus[] = { | ||
38 | { .name = "arm1136", .initfn = arm1136_initfn }, | ||
39 | { .name = "arm1176", .initfn = arm1176_initfn }, | ||
40 | { .name = "arm11mpcore", .initfn = arm11mpcore_initfn }, | ||
41 | + { .name = "cortex-m0", .initfn = cortex_m0_initfn, | ||
42 | + .class_init = arm_v7m_class_init }, | ||
43 | { .name = "cortex-m3", .initfn = cortex_m3_initfn, | ||
44 | .class_init = arm_v7m_class_init }, | ||
45 | { .name = "cortex-m4", .initfn = cortex_m4_initfn, | ||
46 | -- | 34 | -- |
47 | 2.18.0 | 35 | 2.20.1 |
48 | 36 | ||
49 | 37 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | Implement the v8.1M VSCCLRM insn, which zeros floating point | |
2 | registers if there is an active floating point context. | ||
3 | This requires support in write_neon_element32() for the MO_32 | ||
4 | element size, so add it. | ||
5 | |||
6 | Because we want to use arm_gen_condlabel(), we need to move | ||
7 | the definition of that function up in translate.c so it is | ||
8 | before the #include of translate-vfp.c.inc. | ||
9 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20201119215617.29887-5-peter.maydell@linaro.org | ||
13 | --- | ||
14 | target/arm/cpu.h | 9 ++++ | ||
15 | target/arm/m-nocp.decode | 8 +++- | ||
16 | target/arm/translate.c | 21 +++++---- | ||
17 | target/arm/translate-vfp.c.inc | 84 ++++++++++++++++++++++++++++++++++ | ||
18 | 4 files changed, 111 insertions(+), 11 deletions(-) | ||
19 | |||
20 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/target/arm/cpu.h | ||
23 | +++ b/target/arm/cpu.h | ||
24 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_mprofile(const ARMISARegisters *id) | ||
25 | return FIELD_EX32(id->id_pfr1, ID_PFR1, MPROGMOD) != 0; | ||
26 | } | ||
27 | |||
28 | +static inline bool isar_feature_aa32_m_sec_state(const ARMISARegisters *id) | ||
29 | +{ | ||
30 | + /* | ||
31 | + * Return true if M-profile state handling insns | ||
32 | + * (VSCCLRM, CLRM, FPCTX access insns) are implemented | ||
33 | + */ | ||
34 | + return FIELD_EX32(id->id_pfr1, ID_PFR1, SECURITY) >= 3; | ||
35 | +} | ||
36 | + | ||
37 | static inline bool isar_feature_aa32_fp16_arith(const ARMISARegisters *id) | ||
38 | { | ||
39 | /* Sadly this is encoded differently for A-profile and M-profile */ | ||
40 | diff --git a/target/arm/m-nocp.decode b/target/arm/m-nocp.decode | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/arm/m-nocp.decode | ||
43 | +++ b/target/arm/m-nocp.decode | ||
44 | @@ -XXX,XX +XXX,XX @@ | ||
45 | # If the coprocessor is not present or disabled then we will generate | ||
46 | # the NOCP exception; otherwise we let the insn through to the main decode. | ||
47 | |||
48 | +%vd_dp 22:1 12:4 | ||
49 | +%vd_sp 12:4 22:1 | ||
50 | + | ||
51 | &nocp cp | ||
52 | |||
53 | { | ||
54 | # Special cases which do not take an early NOCP: VLLDM and VLSTM | ||
55 | VLLDM_VLSTM 1110 1100 001 l:1 rn:4 0000 1010 0000 0000 | ||
56 | - # TODO: VSCCLRM (new in v8.1M) is similar: | ||
57 | - #VSCCLRM 1110 1100 1-01 1111 ---- 1011 ---- ---0 | ||
58 | + # VSCCLRM (new in v8.1M) is similar: | ||
59 | + VSCCLRM 1110 1100 1.01 1111 .... 1011 imm:7 0 vd=%vd_dp size=3 | ||
60 | + VSCCLRM 1110 1100 1.01 1111 .... 1010 imm:8 vd=%vd_sp size=2 | ||
61 | |||
62 | NOCP 111- 1110 ---- ---- ---- cp:4 ---- ---- &nocp | ||
63 | NOCP 111- 110- ---- ---- ---- cp:4 ---- ---- &nocp | ||
64 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
65 | index XXXXXXX..XXXXXXX 100644 | ||
66 | --- a/target/arm/translate.c | ||
67 | +++ b/target/arm/translate.c | ||
68 | @@ -XXX,XX +XXX,XX @@ void arm_translate_init(void) | ||
69 | a64_translate_init(); | ||
70 | } | ||
71 | |||
72 | +/* Generate a label used for skipping this instruction */ | ||
73 | +static void arm_gen_condlabel(DisasContext *s) | ||
74 | +{ | ||
75 | + if (!s->condjmp) { | ||
76 | + s->condlabel = gen_new_label(); | ||
77 | + s->condjmp = 1; | ||
78 | + } | ||
79 | +} | ||
80 | + | ||
81 | /* Flags for the disas_set_da_iss info argument: | ||
82 | * lower bits hold the Rt register number, higher bits are flags. | ||
83 | */ | ||
84 | @@ -XXX,XX +XXX,XX @@ static void write_neon_element64(TCGv_i64 src, int reg, int ele, MemOp memop) | ||
85 | long off = neon_element_offset(reg, ele, memop); | ||
86 | |||
87 | switch (memop) { | ||
88 | + case MO_32: | ||
89 | + tcg_gen_st32_i64(src, cpu_env, off); | ||
90 | + break; | ||
91 | case MO_64: | ||
92 | tcg_gen_st_i64(src, cpu_env, off); | ||
93 | break; | ||
94 | @@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s, | ||
95 | s->base.is_jmp = DISAS_UPDATE_EXIT; | ||
96 | } | ||
97 | |||
98 | -/* Generate a label used for skipping this instruction */ | ||
99 | -static void arm_gen_condlabel(DisasContext *s) | ||
100 | -{ | ||
101 | - if (!s->condjmp) { | ||
102 | - s->condlabel = gen_new_label(); | ||
103 | - s->condjmp = 1; | ||
104 | - } | ||
105 | -} | ||
106 | - | ||
107 | /* Skip this instruction if the ARM condition is false */ | ||
108 | static void arm_skip_unless(DisasContext *s, uint32_t cond) | ||
109 | { | ||
110 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc | ||
111 | index XXXXXXX..XXXXXXX 100644 | ||
112 | --- a/target/arm/translate-vfp.c.inc | ||
113 | +++ b/target/arm/translate-vfp.c.inc | ||
114 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLLDM_VLSTM(DisasContext *s, arg_VLLDM_VLSTM *a) | ||
115 | return true; | ||
116 | } | ||
117 | |||
118 | +static bool trans_VSCCLRM(DisasContext *s, arg_VSCCLRM *a) | ||
119 | +{ | ||
120 | + int btmreg, topreg; | ||
121 | + TCGv_i64 zero; | ||
122 | + TCGv_i32 aspen, sfpa; | ||
123 | + | ||
124 | + if (!dc_isar_feature(aa32_m_sec_state, s)) { | ||
125 | + /* Before v8.1M, fall through in decode to NOCP check */ | ||
126 | + return false; | ||
127 | + } | ||
128 | + | ||
129 | + /* Explicitly UNDEF because this takes precedence over NOCP */ | ||
130 | + if (!arm_dc_feature(s, ARM_FEATURE_M_MAIN) || !s->v8m_secure) { | ||
131 | + unallocated_encoding(s); | ||
132 | + return true; | ||
133 | + } | ||
134 | + | ||
135 | + if (!dc_isar_feature(aa32_vfp_simd, s)) { | ||
136 | + /* NOP if we have neither FP nor MVE */ | ||
137 | + return true; | ||
138 | + } | ||
139 | + | ||
140 | + /* | ||
141 | + * If FPCCR.ASPEN != 0 && CONTROL_S.SFPA == 0 then there is no | ||
142 | + * active floating point context so we must NOP (without doing | ||
143 | + * any lazy state preservation or the NOCP check). | ||
144 | + */ | ||
145 | + aspen = load_cpu_field(v7m.fpccr[M_REG_S]); | ||
146 | + sfpa = load_cpu_field(v7m.control[M_REG_S]); | ||
147 | + tcg_gen_andi_i32(aspen, aspen, R_V7M_FPCCR_ASPEN_MASK); | ||
148 | + tcg_gen_xori_i32(aspen, aspen, R_V7M_FPCCR_ASPEN_MASK); | ||
149 | + tcg_gen_andi_i32(sfpa, sfpa, R_V7M_CONTROL_SFPA_MASK); | ||
150 | + tcg_gen_or_i32(sfpa, sfpa, aspen); | ||
151 | + arm_gen_condlabel(s); | ||
152 | + tcg_gen_brcondi_i32(TCG_COND_EQ, sfpa, 0, s->condlabel); | ||
153 | + | ||
154 | + if (s->fp_excp_el != 0) { | ||
155 | + gen_exception_insn(s, s->pc_curr, EXCP_NOCP, | ||
156 | + syn_uncategorized(), s->fp_excp_el); | ||
157 | + return true; | ||
158 | + } | ||
159 | + | ||
160 | + topreg = a->vd + a->imm - 1; | ||
161 | + btmreg = a->vd; | ||
162 | + | ||
163 | + /* Convert to Sreg numbers if the insn specified in Dregs */ | ||
164 | + if (a->size == 3) { | ||
165 | + topreg = topreg * 2 + 1; | ||
166 | + btmreg *= 2; | ||
167 | + } | ||
168 | + | ||
169 | + if (topreg > 63 || (topreg > 31 && !(topreg & 1))) { | ||
170 | + /* UNPREDICTABLE: we choose to undef */ | ||
171 | + unallocated_encoding(s); | ||
172 | + return true; | ||
173 | + } | ||
174 | + | ||
175 | + /* Silently ignore requests to clear D16-D31 if they don't exist */ | ||
176 | + if (topreg > 31 && !dc_isar_feature(aa32_simd_r32, s)) { | ||
177 | + topreg = 31; | ||
178 | + } | ||
179 | + | ||
180 | + if (!vfp_access_check(s)) { | ||
181 | + return true; | ||
182 | + } | ||
183 | + | ||
184 | + /* Zero the Sregs from btmreg to topreg inclusive. */ | ||
185 | + zero = tcg_const_i64(0); | ||
186 | + if (btmreg & 1) { | ||
187 | + write_neon_element64(zero, btmreg >> 1, 1, MO_32); | ||
188 | + btmreg++; | ||
189 | + } | ||
190 | + for (; btmreg + 1 <= topreg; btmreg += 2) { | ||
191 | + write_neon_element64(zero, btmreg >> 1, 0, MO_64); | ||
192 | + } | ||
193 | + if (btmreg == topreg) { | ||
194 | + write_neon_element64(zero, btmreg >> 1, 0, MO_32); | ||
195 | + btmreg++; | ||
196 | + } | ||
197 | + assert(btmreg == topreg + 1); | ||
198 | + /* TODO: when MVE is implemented, zero VPR here */ | ||
199 | + return true; | ||
200 | +} | ||
201 | + | ||
202 | static bool trans_NOCP(DisasContext *s, arg_nocp *a) | ||
203 | { | ||
204 | /* | ||
205 | -- | ||
206 | 2.20.1 | ||
207 | |||
208 | diff view generated by jsdifflib |
1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> | 1 | In v8.1M the new CLRM instruction allows zeroing an arbitrary set of |
---|---|---|---|
2 | the general-purpose registers and APSR. Implement this. | ||
2 | 3 | ||
3 | Tested by booting linux 4.18 (built using imx_v6_v7_defconfig) on the | 4 | The encoding is a subset of the LDMIA T2 encoding, using what would |
4 | emulated board. | 5 | be Rn=0b1111 (which UNDEFs for LDMIA). |
5 | 6 | ||
6 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> | ||
7 | Message-id: 3f8eb4300206634dc01e04b12f65b73c0ad2f955.1532984236.git.jcd@tribudubois.net | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20201119215617.29887-6-peter.maydell@linaro.org | ||
10 | --- | 10 | --- |
11 | hw/arm/Makefile.objs | 2 +- | 11 | target/arm/t32.decode | 6 +++++- |
12 | hw/arm/mcimx6ul-evk.c | 85 +++++++++++++++++++++++++++++++++++++++++++ | 12 | target/arm/translate.c | 38 ++++++++++++++++++++++++++++++++++++++ |
13 | 2 files changed, 86 insertions(+), 1 deletion(-) | 13 | 2 files changed, 43 insertions(+), 1 deletion(-) |
14 | create mode 100644 hw/arm/mcimx6ul-evk.c | ||
15 | 14 | ||
16 | diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs | 15 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode |
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/arm/Makefile.objs | 17 | --- a/target/arm/t32.decode |
19 | +++ b/hw/arm/Makefile.objs | 18 | +++ b/target/arm/t32.decode |
20 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_MSF2) += msf2-soc.o msf2-som.o | 19 | @@ -XXX,XX +XXX,XX @@ UXTAB 1111 1010 0101 .... 1111 .... 10.. .... @rrr_rot |
21 | obj-$(CONFIG_IOTKIT) += iotkit.o | 20 | |
22 | obj-$(CONFIG_FSL_IMX7) += fsl-imx7.o mcimx7d-sabre.o | 21 | STM_t32 1110 1000 10.0 .... ................ @ldstm i=1 b=0 |
23 | obj-$(CONFIG_ARM_SMMUV3) += smmu-common.o smmuv3.o | 22 | STM_t32 1110 1001 00.0 .... ................ @ldstm i=0 b=1 |
24 | -obj-$(CONFIG_FSL_IMX6UL) += fsl-imx6ul.o | 23 | -LDM_t32 1110 1000 10.1 .... ................ @ldstm i=1 b=0 |
25 | +obj-$(CONFIG_FSL_IMX6UL) += fsl-imx6ul.o mcimx6ul-evk.o | 24 | +{ |
26 | diff --git a/hw/arm/mcimx6ul-evk.c b/hw/arm/mcimx6ul-evk.c | 25 | + # Rn=15 UNDEFs for LDM; M-profile CLRM uses that encoding |
27 | new file mode 100644 | 26 | + CLRM 1110 1000 1001 1111 list:16 |
28 | index XXXXXXX..XXXXXXX | 27 | + LDM_t32 1110 1000 10.1 .... ................ @ldstm i=1 b=0 |
29 | --- /dev/null | 28 | +} |
30 | +++ b/hw/arm/mcimx6ul-evk.c | 29 | LDM_t32 1110 1001 00.1 .... ................ @ldstm i=0 b=1 |
31 | @@ -XXX,XX +XXX,XX @@ | 30 | |
32 | +/* | 31 | &rfe !extern rn w pu |
33 | + * Copyright (c) 2018 Jean-Christophe Dubois <jcd@tribudubois.net> | 32 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
34 | + * | 33 | index XXXXXXX..XXXXXXX 100644 |
35 | + * MCIMX6UL_EVK Board System emulation. | 34 | --- a/target/arm/translate.c |
36 | + * | 35 | +++ b/target/arm/translate.c |
37 | + * This code is licensed under the GPL, version 2 or later. | 36 | @@ -XXX,XX +XXX,XX @@ static bool trans_LDM_t16(DisasContext *s, arg_ldst_block *a) |
38 | + * See the file `COPYING' in the top level directory. | 37 | return do_ldm(s, a, 1); |
39 | + * | 38 | } |
40 | + * It (partially) emulates a mcimx6ul_evk board, with a Freescale | 39 | |
41 | + * i.MX6ul SoC | 40 | +static bool trans_CLRM(DisasContext *s, arg_CLRM *a) |
42 | + */ | 41 | +{ |
42 | + int i; | ||
43 | + TCGv_i32 zero; | ||
43 | + | 44 | + |
44 | +#include "qemu/osdep.h" | 45 | + if (!dc_isar_feature(aa32_m_sec_state, s)) { |
45 | +#include "qapi/error.h" | 46 | + return false; |
46 | +#include "qemu-common.h" | ||
47 | +#include "hw/arm/fsl-imx6ul.h" | ||
48 | +#include "hw/boards.h" | ||
49 | +#include "sysemu/sysemu.h" | ||
50 | +#include "qemu/error-report.h" | ||
51 | +#include "sysemu/qtest.h" | ||
52 | + | ||
53 | +typedef struct { | ||
54 | + FslIMX6ULState soc; | ||
55 | + MemoryRegion ram; | ||
56 | +} MCIMX6ULEVK; | ||
57 | + | ||
58 | +static void mcimx6ul_evk_init(MachineState *machine) | ||
59 | +{ | ||
60 | + static struct arm_boot_info boot_info; | ||
61 | + MCIMX6ULEVK *s = g_new0(MCIMX6ULEVK, 1); | ||
62 | + int i; | ||
63 | + | ||
64 | + if (machine->ram_size > FSL_IMX6UL_MMDC_SIZE) { | ||
65 | + error_report("RAM size " RAM_ADDR_FMT " above max supported (%08x)", | ||
66 | + machine->ram_size, FSL_IMX6UL_MMDC_SIZE); | ||
67 | + exit(1); | ||
68 | + } | 47 | + } |
69 | + | 48 | + |
70 | + boot_info = (struct arm_boot_info) { | 49 | + if (extract32(a->list, 13, 1)) { |
71 | + .loader_start = FSL_IMX6UL_MMDC_ADDR, | 50 | + return false; |
72 | + .board_id = -1, | ||
73 | + .ram_size = machine->ram_size, | ||
74 | + .kernel_filename = machine->kernel_filename, | ||
75 | + .kernel_cmdline = machine->kernel_cmdline, | ||
76 | + .initrd_filename = machine->initrd_filename, | ||
77 | + .nb_cpus = smp_cpus, | ||
78 | + }; | ||
79 | + | ||
80 | + object_initialize_child(OBJECT(machine), "soc", &s->soc, sizeof(s->soc), | ||
81 | + TYPE_FSL_IMX6UL, &error_fatal, NULL); | ||
82 | + | ||
83 | + object_property_set_bool(OBJECT(&s->soc), true, "realized", &error_fatal); | ||
84 | + | ||
85 | + memory_region_allocate_system_memory(&s->ram, NULL, "mcimx6ul-evk.ram", | ||
86 | + machine->ram_size); | ||
87 | + memory_region_add_subregion(get_system_memory(), | ||
88 | + FSL_IMX6UL_MMDC_ADDR, &s->ram); | ||
89 | + | ||
90 | + for (i = 0; i < FSL_IMX6UL_NUM_USDHCS; i++) { | ||
91 | + BusState *bus; | ||
92 | + DeviceState *carddev; | ||
93 | + DriveInfo *di; | ||
94 | + BlockBackend *blk; | ||
95 | + | ||
96 | + di = drive_get_next(IF_SD); | ||
97 | + blk = di ? blk_by_legacy_dinfo(di) : NULL; | ||
98 | + bus = qdev_get_child_bus(DEVICE(&s->soc.usdhc[i]), "sd-bus"); | ||
99 | + carddev = qdev_create(bus, TYPE_SD_CARD); | ||
100 | + qdev_prop_set_drive(carddev, "drive", blk, &error_fatal); | ||
101 | + object_property_set_bool(OBJECT(carddev), true, | ||
102 | + "realized", &error_fatal); | ||
103 | + } | 51 | + } |
104 | + | 52 | + |
105 | + if (!qtest_enabled()) { | 53 | + if (!a->list) { |
106 | + arm_load_kernel(&s->soc.cpu[0], &boot_info); | 54 | + /* UNPREDICTABLE; we choose to UNDEF */ |
55 | + return false; | ||
107 | + } | 56 | + } |
57 | + | ||
58 | + zero = tcg_const_i32(0); | ||
59 | + for (i = 0; i < 15; i++) { | ||
60 | + if (extract32(a->list, i, 1)) { | ||
61 | + /* Clear R[i] */ | ||
62 | + tcg_gen_mov_i32(cpu_R[i], zero); | ||
63 | + } | ||
64 | + } | ||
65 | + if (extract32(a->list, 15, 1)) { | ||
66 | + /* | ||
67 | + * Clear APSR (by calling the MSR helper with the same argument | ||
68 | + * as for "MSR APSR_nzcvqg, Rn": mask = 0b1100, SYSM=0) | ||
69 | + */ | ||
70 | + TCGv_i32 maskreg = tcg_const_i32(0xc << 8); | ||
71 | + gen_helper_v7m_msr(cpu_env, maskreg, zero); | ||
72 | + tcg_temp_free_i32(maskreg); | ||
73 | + } | ||
74 | + tcg_temp_free_i32(zero); | ||
75 | + return true; | ||
108 | +} | 76 | +} |
109 | + | 77 | + |
110 | +static void mcimx6ul_evk_machine_init(MachineClass *mc) | 78 | /* |
111 | +{ | 79 | * Branch, branch with link |
112 | + mc->desc = "Freescale i.MX6UL Evaluation Kit (Cortex A7)"; | 80 | */ |
113 | + mc->init = mcimx6ul_evk_init; | ||
114 | + mc->max_cpus = FSL_IMX6UL_NUM_CPUS; | ||
115 | +} | ||
116 | +DEFINE_MACHINE("mcimx6ul-evk", mcimx6ul_evk_machine_init) | ||
117 | -- | 81 | -- |
118 | 2.18.0 | 82 | 2.20.1 |
119 | 83 | ||
120 | 84 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | For M-profile before v8.1M, the only valid register for VMSR/VMRS is |
---|---|---|---|
2 | the FPSCR. We have a comment that states this, but the actual logic | ||
3 | to forbid accesses for any other register value is missing, so we | ||
4 | would end up with A-profile style behaviour. Add the missing check. | ||
2 | 5 | ||
3 | The scaling should be solely on the memory operation size; the number | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | of registers being loaded does not come in to the initial computation. | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20201119215617.29887-7-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/translate-vfp.c.inc | 5 ++++- | ||
11 | 1 file changed, 4 insertions(+), 1 deletion(-) | ||
5 | 12 | ||
6 | Cc: qemu-stable@nongnu.org (3.0.1) | 13 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc |
7 | Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Tested-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
10 | Reviewed-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | target/arm/translate-sve.c | 5 ++--- | ||
14 | 1 file changed, 2 insertions(+), 3 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/translate-sve.c | 15 | --- a/target/arm/translate-vfp.c.inc |
19 | +++ b/target/arm/translate-sve.c | 16 | +++ b/target/arm/translate-vfp.c.inc |
20 | @@ -XXX,XX +XXX,XX @@ static bool trans_LD_zprr(DisasContext *s, arg_rprr_load *a, uint32_t insn) | 17 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMSR_VMRS(DisasContext *s, arg_VMSR_VMRS *a) |
21 | } | 18 | * Accesses to R15 are UNPREDICTABLE; we choose to undef. |
22 | if (sve_access_check(s)) { | 19 | * (FPSCR -> r15 is a special case which writes to the PSR flags.) |
23 | TCGv_i64 addr = new_tmp_a64(s); | 20 | */ |
24 | - tcg_gen_muli_i64(addr, cpu_reg(s, a->rm), | 21 | - if (a->rt == 15 && (!a->l || a->reg != ARM_VFP_FPSCR)) { |
25 | - (a->nreg + 1) << dtype_msz(a->dtype)); | 22 | + if (a->reg != ARM_VFP_FPSCR) { |
26 | + tcg_gen_shli_i64(addr, cpu_reg(s, a->rm), dtype_msz(a->dtype)); | 23 | + return false; |
27 | tcg_gen_add_i64(addr, addr, cpu_reg_sp(s, a->rn)); | 24 | + } |
28 | do_ld_zpa(s, a->rd, a->pg, addr, a->dtype, a->nreg); | 25 | + if (a->rt == 15 && !a->l) { |
29 | } | 26 | return false; |
30 | @@ -XXX,XX +XXX,XX @@ static bool trans_ST_zprr(DisasContext *s, arg_rprr_store *a, uint32_t insn) | 27 | } |
31 | } | ||
32 | if (sve_access_check(s)) { | ||
33 | TCGv_i64 addr = new_tmp_a64(s); | ||
34 | - tcg_gen_muli_i64(addr, cpu_reg(s, a->rm), (a->nreg + 1) << a->msz); | ||
35 | + tcg_gen_shli_i64(addr, cpu_reg(s, a->rm), a->msz); | ||
36 | tcg_gen_add_i64(addr, addr, cpu_reg_sp(s, a->rn)); | ||
37 | do_st_zpa(s, a->rd, a->pg, addr, a->msz, a->esz, a->nreg); | ||
38 | } | 28 | } |
39 | -- | 29 | -- |
40 | 2.18.0 | 30 | 2.20.1 |
41 | 31 | ||
42 | 32 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | Currently M-profile borrows the A-profile code for VMSR and VMRS | |
2 | (access to the FP system registers), because all it needs to support | ||
3 | is the FPSCR. In v8.1M things become significantly more complicated | ||
4 | in two ways: | ||
5 | |||
6 | * there are several new FP system registers; some have side effects | ||
7 | on read, and one (FPCXT_NS) needs to avoid the usual | ||
8 | vfp_access_check() and the "only if FPU implemented" check | ||
9 | |||
10 | * all sysregs are now accessible both by VMRS/VMSR (which | ||
11 | reads/writes a general purpose register) and also by VLDR/VSTR | ||
12 | (which reads/writes them directly to memory) | ||
13 | |||
14 | Refactor the structure of how we handle VMSR/VMRS to cope with this: | ||
15 | |||
16 | * keep the M-profile code entirely separate from the A-profile code | ||
17 | |||
18 | * abstract out the "read or write the general purpose register" part | ||
19 | of the code into a loadfn or storefn function pointer, so we can | ||
20 | reuse it for VLDR/VSTR. | ||
21 | |||
22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
23 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
24 | Message-id: 20201119215617.29887-8-peter.maydell@linaro.org | ||
25 | --- | ||
26 | target/arm/cpu.h | 3 + | ||
27 | target/arm/translate-vfp.c.inc | 182 ++++++++++++++++++++++++++++++--- | ||
28 | 2 files changed, 171 insertions(+), 14 deletions(-) | ||
29 | |||
30 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/cpu.h | ||
33 | +++ b/target/arm/cpu.h | ||
34 | @@ -XXX,XX +XXX,XX @@ enum arm_cpu_mode { | ||
35 | #define ARM_VFP_FPINST 9 | ||
36 | #define ARM_VFP_FPINST2 10 | ||
37 | |||
38 | +/* QEMU-internal value meaning "FPSCR, but we care only about NZCV" */ | ||
39 | +#define QEMU_VFP_FPSCR_NZCV 0xffff | ||
40 | + | ||
41 | /* iwMMXt coprocessor control registers. */ | ||
42 | #define ARM_IWMMXT_wCID 0 | ||
43 | #define ARM_IWMMXT_wCon 1 | ||
44 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/target/arm/translate-vfp.c.inc | ||
47 | +++ b/target/arm/translate-vfp.c.inc | ||
48 | @@ -XXX,XX +XXX,XX @@ static bool trans_VDUP(DisasContext *s, arg_VDUP *a) | ||
49 | return true; | ||
50 | } | ||
51 | |||
52 | +/* | ||
53 | + * M-profile provides two different sets of instructions that can | ||
54 | + * access floating point system registers: VMSR/VMRS (which move | ||
55 | + * to/from a general purpose register) and VLDR/VSTR sysreg (which | ||
56 | + * move directly to/from memory). In some cases there are also side | ||
57 | + * effects which must happen after any write to memory (which could | ||
58 | + * cause an exception). So we implement the common logic for the | ||
59 | + * sysreg access in gen_M_fp_sysreg_write() and gen_M_fp_sysreg_read(), | ||
60 | + * which take pointers to callback functions which will perform the | ||
61 | + * actual "read/write general purpose register" and "read/write | ||
62 | + * memory" operations. | ||
63 | + */ | ||
64 | + | ||
65 | +/* | ||
66 | + * Emit code to store the sysreg to its final destination; frees the | ||
67 | + * TCG temp 'value' it is passed. | ||
68 | + */ | ||
69 | +typedef void fp_sysreg_storefn(DisasContext *s, void *opaque, TCGv_i32 value); | ||
70 | +/* | ||
71 | + * Emit code to load the value to be copied to the sysreg; returns | ||
72 | + * a new TCG temporary | ||
73 | + */ | ||
74 | +typedef TCGv_i32 fp_sysreg_loadfn(DisasContext *s, void *opaque); | ||
75 | + | ||
76 | +/* Common decode/access checks for fp sysreg read/write */ | ||
77 | +typedef enum FPSysRegCheckResult { | ||
78 | + FPSysRegCheckFailed, /* caller should return false */ | ||
79 | + FPSysRegCheckDone, /* caller should return true */ | ||
80 | + FPSysRegCheckContinue, /* caller should continue generating code */ | ||
81 | +} FPSysRegCheckResult; | ||
82 | + | ||
83 | +static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno) | ||
84 | +{ | ||
85 | + if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
86 | + return FPSysRegCheckFailed; | ||
87 | + } | ||
88 | + | ||
89 | + switch (regno) { | ||
90 | + case ARM_VFP_FPSCR: | ||
91 | + case QEMU_VFP_FPSCR_NZCV: | ||
92 | + break; | ||
93 | + default: | ||
94 | + return FPSysRegCheckFailed; | ||
95 | + } | ||
96 | + | ||
97 | + if (!vfp_access_check(s)) { | ||
98 | + return FPSysRegCheckDone; | ||
99 | + } | ||
100 | + | ||
101 | + return FPSysRegCheckContinue; | ||
102 | +} | ||
103 | + | ||
104 | +static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | ||
105 | + | ||
106 | + fp_sysreg_loadfn *loadfn, | ||
107 | + void *opaque) | ||
108 | +{ | ||
109 | + /* Do a write to an M-profile floating point system register */ | ||
110 | + TCGv_i32 tmp; | ||
111 | + | ||
112 | + switch (fp_sysreg_checks(s, regno)) { | ||
113 | + case FPSysRegCheckFailed: | ||
114 | + return false; | ||
115 | + case FPSysRegCheckDone: | ||
116 | + return true; | ||
117 | + case FPSysRegCheckContinue: | ||
118 | + break; | ||
119 | + } | ||
120 | + | ||
121 | + switch (regno) { | ||
122 | + case ARM_VFP_FPSCR: | ||
123 | + tmp = loadfn(s, opaque); | ||
124 | + gen_helper_vfp_set_fpscr(cpu_env, tmp); | ||
125 | + tcg_temp_free_i32(tmp); | ||
126 | + gen_lookup_tb(s); | ||
127 | + break; | ||
128 | + default: | ||
129 | + g_assert_not_reached(); | ||
130 | + } | ||
131 | + return true; | ||
132 | +} | ||
133 | + | ||
134 | +static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, | ||
135 | + fp_sysreg_storefn *storefn, | ||
136 | + void *opaque) | ||
137 | +{ | ||
138 | + /* Do a read from an M-profile floating point system register */ | ||
139 | + TCGv_i32 tmp; | ||
140 | + | ||
141 | + switch (fp_sysreg_checks(s, regno)) { | ||
142 | + case FPSysRegCheckFailed: | ||
143 | + return false; | ||
144 | + case FPSysRegCheckDone: | ||
145 | + return true; | ||
146 | + case FPSysRegCheckContinue: | ||
147 | + break; | ||
148 | + } | ||
149 | + | ||
150 | + switch (regno) { | ||
151 | + case ARM_VFP_FPSCR: | ||
152 | + tmp = tcg_temp_new_i32(); | ||
153 | + gen_helper_vfp_get_fpscr(tmp, cpu_env); | ||
154 | + storefn(s, opaque, tmp); | ||
155 | + break; | ||
156 | + case QEMU_VFP_FPSCR_NZCV: | ||
157 | + /* | ||
158 | + * Read just NZCV; this is a special case to avoid the | ||
159 | + * helper call for the "VMRS to CPSR.NZCV" insn. | ||
160 | + */ | ||
161 | + tmp = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]); | ||
162 | + tcg_gen_andi_i32(tmp, tmp, 0xf0000000); | ||
163 | + storefn(s, opaque, tmp); | ||
164 | + break; | ||
165 | + default: | ||
166 | + g_assert_not_reached(); | ||
167 | + } | ||
168 | + return true; | ||
169 | +} | ||
170 | + | ||
171 | +static void fp_sysreg_to_gpr(DisasContext *s, void *opaque, TCGv_i32 value) | ||
172 | +{ | ||
173 | + arg_VMSR_VMRS *a = opaque; | ||
174 | + | ||
175 | + if (a->rt == 15) { | ||
176 | + /* Set the 4 flag bits in the CPSR */ | ||
177 | + gen_set_nzcv(value); | ||
178 | + tcg_temp_free_i32(value); | ||
179 | + } else { | ||
180 | + store_reg(s, a->rt, value); | ||
181 | + } | ||
182 | +} | ||
183 | + | ||
184 | +static TCGv_i32 gpr_to_fp_sysreg(DisasContext *s, void *opaque) | ||
185 | +{ | ||
186 | + arg_VMSR_VMRS *a = opaque; | ||
187 | + | ||
188 | + return load_reg(s, a->rt); | ||
189 | +} | ||
190 | + | ||
191 | +static bool gen_M_VMSR_VMRS(DisasContext *s, arg_VMSR_VMRS *a) | ||
192 | +{ | ||
193 | + /* | ||
194 | + * Accesses to R15 are UNPREDICTABLE; we choose to undef. | ||
195 | + * FPSCR -> r15 is a special case which writes to the PSR flags; | ||
196 | + * set a->reg to a special value to tell gen_M_fp_sysreg_read() | ||
197 | + * we only care about the top 4 bits of FPSCR there. | ||
198 | + */ | ||
199 | + if (a->rt == 15) { | ||
200 | + if (a->l && a->reg == ARM_VFP_FPSCR) { | ||
201 | + a->reg = QEMU_VFP_FPSCR_NZCV; | ||
202 | + } else { | ||
203 | + return false; | ||
204 | + } | ||
205 | + } | ||
206 | + | ||
207 | + if (a->l) { | ||
208 | + /* VMRS, move FP system register to gp register */ | ||
209 | + return gen_M_fp_sysreg_read(s, a->reg, fp_sysreg_to_gpr, a); | ||
210 | + } else { | ||
211 | + /* VMSR, move gp register to FP system register */ | ||
212 | + return gen_M_fp_sysreg_write(s, a->reg, gpr_to_fp_sysreg, a); | ||
213 | + } | ||
214 | +} | ||
215 | + | ||
216 | static bool trans_VMSR_VMRS(DisasContext *s, arg_VMSR_VMRS *a) | ||
217 | { | ||
218 | TCGv_i32 tmp; | ||
219 | bool ignore_vfp_enabled = false; | ||
220 | |||
221 | - if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
222 | - return false; | ||
223 | + if (arm_dc_feature(s, ARM_FEATURE_M)) { | ||
224 | + return gen_M_VMSR_VMRS(s, a); | ||
225 | } | ||
226 | |||
227 | - if (arm_dc_feature(s, ARM_FEATURE_M)) { | ||
228 | - /* | ||
229 | - * The only M-profile VFP vmrs/vmsr sysreg is FPSCR. | ||
230 | - * Accesses to R15 are UNPREDICTABLE; we choose to undef. | ||
231 | - * (FPSCR -> r15 is a special case which writes to the PSR flags.) | ||
232 | - */ | ||
233 | - if (a->reg != ARM_VFP_FPSCR) { | ||
234 | - return false; | ||
235 | - } | ||
236 | - if (a->rt == 15 && !a->l) { | ||
237 | - return false; | ||
238 | - } | ||
239 | + if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
240 | + return false; | ||
241 | } | ||
242 | |||
243 | switch (a->reg) { | ||
244 | -- | ||
245 | 2.20.1 | ||
246 | |||
247 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | The constant-expander functions like negate, plus_2, etc, are |
---|---|---|---|
2 | generally useful; move them up in translate.c so we can use them in | ||
3 | the VFP/Neon decoders as well as in the A32/T32/T16 decoders. | ||
2 | 4 | ||
3 | Also fold the FPCR/FPSR state onto the same line as PSTATE, | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | and mention but do not dump disabled FPU state. | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20201119215617.29887-9-peter.maydell@linaro.org | ||
8 | --- | ||
9 | target/arm/translate.c | 46 +++++++++++++++++++++++------------------- | ||
10 | 1 file changed, 25 insertions(+), 21 deletions(-) | ||
5 | 11 | ||
6 | Cc: qemu-stable@nongnu.org (3.0.1) | 12 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
9 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/translate-a64.c | 95 +++++++++++++++++++++++++++++++++----- | ||
13 | 1 file changed, 83 insertions(+), 12 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate-a64.c | 14 | --- a/target/arm/translate.c |
18 | +++ b/target/arm/translate-a64.c | 15 | +++ b/target/arm/translate.c |
19 | @@ -XXX,XX +XXX,XX @@ void aarch64_cpu_dump_state(CPUState *cs, FILE *f, | 16 | @@ -XXX,XX +XXX,XX @@ static void arm_gen_condlabel(DisasContext *s) |
20 | } else { | ||
21 | ns_status = ""; | ||
22 | } | ||
23 | - | ||
24 | - cpu_fprintf(f, "\nPSTATE=%08x %c%c%c%c %sEL%d%c\n", | ||
25 | + cpu_fprintf(f, "PSTATE=%08x %c%c%c%c %sEL%d%c", | ||
26 | psr, | ||
27 | psr & PSTATE_N ? 'N' : '-', | ||
28 | psr & PSTATE_Z ? 'Z' : '-', | ||
29 | @@ -XXX,XX +XXX,XX @@ void aarch64_cpu_dump_state(CPUState *cs, FILE *f, | ||
30 | el, | ||
31 | psr & PSTATE_SP ? 'h' : 't'); | ||
32 | |||
33 | - if (flags & CPU_DUMP_FPU) { | ||
34 | - int numvfpregs = 32; | ||
35 | - for (i = 0; i < numvfpregs; i++) { | ||
36 | - uint64_t *q = aa64_vfp_qreg(env, i); | ||
37 | - uint64_t vlo = q[0]; | ||
38 | - uint64_t vhi = q[1]; | ||
39 | - cpu_fprintf(f, "q%02d=%016" PRIx64 ":%016" PRIx64 "%c", | ||
40 | - i, vhi, vlo, (i & 1 ? '\n' : ' ')); | ||
41 | + if (!(flags & CPU_DUMP_FPU)) { | ||
42 | + cpu_fprintf(f, "\n"); | ||
43 | + return; | ||
44 | + } | ||
45 | + cpu_fprintf(f, " FPCR=%08x FPSR=%08x\n", | ||
46 | + vfp_get_fpcr(env), vfp_get_fpsr(env)); | ||
47 | + | ||
48 | + if (arm_feature(env, ARM_FEATURE_SVE)) { | ||
49 | + int j, zcr_len = env->vfp.zcr_el[1] & 0xf; /* fix for system mode */ | ||
50 | + | ||
51 | + for (i = 0; i <= FFR_PRED_NUM; i++) { | ||
52 | + bool eol; | ||
53 | + if (i == FFR_PRED_NUM) { | ||
54 | + cpu_fprintf(f, "FFR="); | ||
55 | + /* It's last, so end the line. */ | ||
56 | + eol = true; | ||
57 | + } else { | ||
58 | + cpu_fprintf(f, "P%02d=", i); | ||
59 | + switch (zcr_len) { | ||
60 | + case 0: | ||
61 | + eol = i % 8 == 7; | ||
62 | + break; | ||
63 | + case 1: | ||
64 | + eol = i % 6 == 5; | ||
65 | + break; | ||
66 | + case 2: | ||
67 | + case 3: | ||
68 | + eol = i % 3 == 2; | ||
69 | + break; | ||
70 | + default: | ||
71 | + /* More than one quadword per predicate. */ | ||
72 | + eol = true; | ||
73 | + break; | ||
74 | + } | ||
75 | + } | ||
76 | + for (j = zcr_len / 4; j >= 0; j--) { | ||
77 | + int digits; | ||
78 | + if (j * 4 + 4 <= zcr_len + 1) { | ||
79 | + digits = 16; | ||
80 | + } else { | ||
81 | + digits = (zcr_len % 4 + 1) * 4; | ||
82 | + } | ||
83 | + cpu_fprintf(f, "%0*" PRIx64 "%s", digits, | ||
84 | + env->vfp.pregs[i].p[j], | ||
85 | + j ? ":" : eol ? "\n" : " "); | ||
86 | + } | ||
87 | + } | ||
88 | + | ||
89 | + for (i = 0; i < 32; i++) { | ||
90 | + if (zcr_len == 0) { | ||
91 | + cpu_fprintf(f, "Z%02d=%016" PRIx64 ":%016" PRIx64 "%s", | ||
92 | + i, env->vfp.zregs[i].d[1], | ||
93 | + env->vfp.zregs[i].d[0], i & 1 ? "\n" : " "); | ||
94 | + } else if (zcr_len == 1) { | ||
95 | + cpu_fprintf(f, "Z%02d=%016" PRIx64 ":%016" PRIx64 | ||
96 | + ":%016" PRIx64 ":%016" PRIx64 "\n", | ||
97 | + i, env->vfp.zregs[i].d[3], env->vfp.zregs[i].d[2], | ||
98 | + env->vfp.zregs[i].d[1], env->vfp.zregs[i].d[0]); | ||
99 | + } else { | ||
100 | + for (j = zcr_len; j >= 0; j--) { | ||
101 | + bool odd = (zcr_len - j) % 2 != 0; | ||
102 | + if (j == zcr_len) { | ||
103 | + cpu_fprintf(f, "Z%02d[%x-%x]=", i, j, j - 1); | ||
104 | + } else if (!odd) { | ||
105 | + if (j > 0) { | ||
106 | + cpu_fprintf(f, " [%x-%x]=", j, j - 1); | ||
107 | + } else { | ||
108 | + cpu_fprintf(f, " [%x]=", j); | ||
109 | + } | ||
110 | + } | ||
111 | + cpu_fprintf(f, "%016" PRIx64 ":%016" PRIx64 "%s", | ||
112 | + env->vfp.zregs[i].d[j * 2 + 1], | ||
113 | + env->vfp.zregs[i].d[j * 2], | ||
114 | + odd || j == 0 ? "\n" : ":"); | ||
115 | + } | ||
116 | + } | ||
117 | + } | ||
118 | + } else { | ||
119 | + for (i = 0; i < 32; i++) { | ||
120 | + uint64_t *q = aa64_vfp_qreg(env, i); | ||
121 | + cpu_fprintf(f, "Q%02d=%016" PRIx64 ":%016" PRIx64 "%s", | ||
122 | + i, q[1], q[0], (i & 1 ? "\n" : " ")); | ||
123 | } | ||
124 | - cpu_fprintf(f, "FPCR: %08x FPSR: %08x\n", | ||
125 | - vfp_get_fpcr(env), vfp_get_fpsr(env)); | ||
126 | } | 17 | } |
127 | } | 18 | } |
128 | 19 | ||
20 | +/* | ||
21 | + * Constant expanders for the decoders. | ||
22 | + */ | ||
23 | + | ||
24 | +static int negate(DisasContext *s, int x) | ||
25 | +{ | ||
26 | + return -x; | ||
27 | +} | ||
28 | + | ||
29 | +static int plus_2(DisasContext *s, int x) | ||
30 | +{ | ||
31 | + return x + 2; | ||
32 | +} | ||
33 | + | ||
34 | +static int times_2(DisasContext *s, int x) | ||
35 | +{ | ||
36 | + return x * 2; | ||
37 | +} | ||
38 | + | ||
39 | +static int times_4(DisasContext *s, int x) | ||
40 | +{ | ||
41 | + return x * 4; | ||
42 | +} | ||
43 | + | ||
44 | /* Flags for the disas_set_da_iss info argument: | ||
45 | * lower bits hold the Rt register number, higher bits are flags. | ||
46 | */ | ||
47 | @@ -XXX,XX +XXX,XX @@ static void arm_skip_unless(DisasContext *s, uint32_t cond) | ||
48 | |||
49 | |||
50 | /* | ||
51 | - * Constant expanders for the decoders. | ||
52 | + * Constant expanders used by T16/T32 decode | ||
53 | */ | ||
54 | |||
55 | -static int negate(DisasContext *s, int x) | ||
56 | -{ | ||
57 | - return -x; | ||
58 | -} | ||
59 | - | ||
60 | -static int plus_2(DisasContext *s, int x) | ||
61 | -{ | ||
62 | - return x + 2; | ||
63 | -} | ||
64 | - | ||
65 | -static int times_2(DisasContext *s, int x) | ||
66 | -{ | ||
67 | - return x * 2; | ||
68 | -} | ||
69 | - | ||
70 | -static int times_4(DisasContext *s, int x) | ||
71 | -{ | ||
72 | - return x * 4; | ||
73 | -} | ||
74 | - | ||
75 | /* Return only the rotation part of T32ExpandImm. */ | ||
76 | static int t32_expandimm_rot(DisasContext *s, int x) | ||
77 | { | ||
129 | -- | 78 | -- |
130 | 2.18.0 | 79 | 2.20.1 |
131 | 80 | ||
132 | 81 | diff view generated by jsdifflib |
1 | From: Jean-Christophe Dubois <jcd@tribudubois.net> | 1 | Implement the new-in-v8.1M VLDR/VSTR variants which directly |
---|---|---|---|
2 | read or write FP system registers to memory. | ||
2 | 3 | ||
3 | Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net> | ||
4 | Message-id: 3853ec555d68e7e25d726170833b775796151a07.1532984236.git.jcd@tribudubois.net | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20201119215617.29887-10-peter.maydell@linaro.org | ||
7 | --- | 7 | --- |
8 | hw/arm/Makefile.objs | 1 + | 8 | target/arm/vfp.decode | 14 ++++++ |
9 | include/hw/arm/fsl-imx6ul.h | 339 ++++++++++++++++++ | 9 | target/arm/translate-vfp.c.inc | 91 ++++++++++++++++++++++++++++++++++ |
10 | hw/arm/fsl-imx6ul.c | 617 ++++++++++++++++++++++++++++++++ | 10 | 2 files changed, 105 insertions(+) |
11 | default-configs/arm-softmmu.mak | 1 + | ||
12 | 4 files changed, 958 insertions(+) | ||
13 | create mode 100644 include/hw/arm/fsl-imx6ul.h | ||
14 | create mode 100644 hw/arm/fsl-imx6ul.c | ||
15 | 11 | ||
16 | diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs | 12 | diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode |
17 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/arm/Makefile.objs | 14 | --- a/target/arm/vfp.decode |
19 | +++ b/hw/arm/Makefile.objs | 15 | +++ b/target/arm/vfp.decode |
20 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_MSF2) += msf2-soc.o msf2-som.o | 16 | @@ -XXX,XX +XXX,XX @@ VLDR_VSTR_hp ---- 1101 u:1 .0 l:1 rn:4 .... 1001 imm:8 vd=%vd_sp |
21 | obj-$(CONFIG_IOTKIT) += iotkit.o | 17 | VLDR_VSTR_sp ---- 1101 u:1 .0 l:1 rn:4 .... 1010 imm:8 vd=%vd_sp |
22 | obj-$(CONFIG_FSL_IMX7) += fsl-imx7.o mcimx7d-sabre.o | 18 | VLDR_VSTR_dp ---- 1101 u:1 .0 l:1 rn:4 .... 1011 imm:8 vd=%vd_dp |
23 | obj-$(CONFIG_ARM_SMMUV3) += smmu-common.o smmuv3.o | 19 | |
24 | +obj-$(CONFIG_FSL_IMX6UL) += fsl-imx6ul.o | 20 | +# M-profile VLDR/VSTR to sysreg |
25 | diff --git a/include/hw/arm/fsl-imx6ul.h b/include/hw/arm/fsl-imx6ul.h | 21 | +%vldr_sysreg 22:1 13:3 |
26 | new file mode 100644 | 22 | +%imm7_0x4 0:7 !function=times_4 |
27 | index XXXXXXX..XXXXXXX | ||
28 | --- /dev/null | ||
29 | +++ b/include/hw/arm/fsl-imx6ul.h | ||
30 | @@ -XXX,XX +XXX,XX @@ | ||
31 | +/* | ||
32 | + * Copyright (c) 2018 Jean-Christophe Dubois <jcd@tribudubois.net> | ||
33 | + * | ||
34 | + * i.MX6ul SoC definitions | ||
35 | + * | ||
36 | + * This program is free software; you can redistribute it and/or modify | ||
37 | + * it under the terms of the GNU General Public License as published by | ||
38 | + * the Free Software Foundation; either version 2 of the License, or | ||
39 | + * (at your option) any later version. | ||
40 | + * | ||
41 | + * This program is distributed in the hope that it will be useful, | ||
42 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
43 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
44 | + * GNU General Public License for more details. | ||
45 | + */ | ||
46 | + | 23 | + |
47 | +#ifndef FSL_IMX6UL_H | 24 | +&vldr_sysreg rn reg imm a w p |
48 | +#define FSL_IMX6UL_H | 25 | +@vldr_sysreg .... ... . a:1 . . . rn:4 ... . ... .. ....... \ |
26 | + reg=%vldr_sysreg imm=%imm7_0x4 &vldr_sysreg | ||
49 | + | 27 | + |
50 | +#include "hw/arm/arm.h" | 28 | +# P=0 W=0 is SEE "Related encodings", so split into two patterns |
51 | +#include "hw/cpu/a15mpcore.h" | 29 | +VLDR_sysreg ---- 110 1 . . w:1 1 .... ... 0 111 11 ....... @vldr_sysreg p=1 |
52 | +#include "hw/misc/imx6ul_ccm.h" | 30 | +VLDR_sysreg ---- 110 0 . . 1 1 .... ... 0 111 11 ....... @vldr_sysreg p=0 w=1 |
53 | +#include "hw/misc/imx6_src.h" | 31 | +VSTR_sysreg ---- 110 1 . . w:1 0 .... ... 0 111 11 ....... @vldr_sysreg p=1 |
54 | +#include "hw/misc/imx7_snvs.h" | 32 | +VSTR_sysreg ---- 110 0 . . 1 0 .... ... 0 111 11 ....... @vldr_sysreg p=0 w=1 |
55 | +#include "hw/misc/imx7_gpr.h" | ||
56 | +#include "hw/intc/imx_gpcv2.h" | ||
57 | +#include "hw/misc/imx2_wdt.h" | ||
58 | +#include "hw/gpio/imx_gpio.h" | ||
59 | +#include "hw/char/imx_serial.h" | ||
60 | +#include "hw/timer/imx_gpt.h" | ||
61 | +#include "hw/timer/imx_epit.h" | ||
62 | +#include "hw/i2c/imx_i2c.h" | ||
63 | +#include "hw/gpio/imx_gpio.h" | ||
64 | +#include "hw/sd/sdhci.h" | ||
65 | +#include "hw/ssi/imx_spi.h" | ||
66 | +#include "hw/net/imx_fec.h" | ||
67 | +#include "exec/memory.h" | ||
68 | +#include "cpu.h" | ||
69 | + | 33 | + |
70 | +#define TYPE_FSL_IMX6UL "fsl,imx6ul" | 34 | # We split the load/store multiple up into two patterns to avoid |
71 | +#define FSL_IMX6UL(obj) OBJECT_CHECK(FslIMX6ULState, (obj), TYPE_FSL_IMX6UL) | 35 | # overlap with other insns in the "Advanced SIMD load/store and 64-bit move" |
36 | # grouping: | ||
37 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/target/arm/translate-vfp.c.inc | ||
40 | +++ b/target/arm/translate-vfp.c.inc | ||
41 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMSR_VMRS(DisasContext *s, arg_VMSR_VMRS *a) | ||
42 | return true; | ||
43 | } | ||
44 | |||
45 | +static void fp_sysreg_to_memory(DisasContext *s, void *opaque, TCGv_i32 value) | ||
46 | +{ | ||
47 | + arg_vldr_sysreg *a = opaque; | ||
48 | + uint32_t offset = a->imm; | ||
49 | + TCGv_i32 addr; | ||
72 | + | 50 | + |
73 | +enum FslIMX6ULConfiguration { | 51 | + if (!a->a) { |
74 | + FSL_IMX6UL_NUM_CPUS = 1, | 52 | + offset = - offset; |
75 | + FSL_IMX6UL_NUM_UARTS = 8, | ||
76 | + FSL_IMX6UL_NUM_ETHS = 2, | ||
77 | + FSL_IMX6UL_ETH_NUM_TX_RINGS = 2, | ||
78 | + FSL_IMX6UL_NUM_USDHCS = 2, | ||
79 | + FSL_IMX6UL_NUM_WDTS = 3, | ||
80 | + FSL_IMX6UL_NUM_GPTS = 2, | ||
81 | + FSL_IMX6UL_NUM_EPITS = 2, | ||
82 | + FSL_IMX6UL_NUM_IOMUXCS = 2, | ||
83 | + FSL_IMX6UL_NUM_GPIOS = 5, | ||
84 | + FSL_IMX6UL_NUM_I2CS = 4, | ||
85 | + FSL_IMX6UL_NUM_ECSPIS = 4, | ||
86 | + FSL_IMX6UL_NUM_ADCS = 2, | ||
87 | +}; | ||
88 | + | ||
89 | +typedef struct FslIMX6ULState { | ||
90 | + /*< private >*/ | ||
91 | + DeviceState parent_obj; | ||
92 | + | ||
93 | + /*< public >*/ | ||
94 | + ARMCPU cpu[FSL_IMX6UL_NUM_CPUS]; | ||
95 | + A15MPPrivState a7mpcore; | ||
96 | + IMXGPTState gpt[FSL_IMX6UL_NUM_GPTS]; | ||
97 | + IMXEPITState epit[FSL_IMX6UL_NUM_EPITS]; | ||
98 | + IMXGPIOState gpio[FSL_IMX6UL_NUM_GPIOS]; | ||
99 | + IMX6ULCCMState ccm; | ||
100 | + IMX6SRCState src; | ||
101 | + IMX7SNVSState snvs; | ||
102 | + IMXGPCv2State gpcv2; | ||
103 | + IMX7GPRState gpr; | ||
104 | + IMXSPIState spi[FSL_IMX6UL_NUM_ECSPIS]; | ||
105 | + IMXI2CState i2c[FSL_IMX6UL_NUM_I2CS]; | ||
106 | + IMXSerialState uart[FSL_IMX6UL_NUM_UARTS]; | ||
107 | + IMXFECState eth[FSL_IMX6UL_NUM_ETHS]; | ||
108 | + SDHCIState usdhc[FSL_IMX6UL_NUM_USDHCS]; | ||
109 | + IMX2WdtState wdt[FSL_IMX6UL_NUM_WDTS]; | ||
110 | + MemoryRegion rom; | ||
111 | + MemoryRegion caam; | ||
112 | + MemoryRegion ocram; | ||
113 | + MemoryRegion ocram_alias; | ||
114 | +} FslIMX6ULState; | ||
115 | + | ||
116 | +enum FslIMX6ULMemoryMap { | ||
117 | + FSL_IMX6UL_MMDC_ADDR = 0x80000000, | ||
118 | + FSL_IMX6UL_MMDC_SIZE = 2 * 1024 * 1024 * 1024UL, | ||
119 | + | ||
120 | + FSL_IMX6UL_QSPI1_MEM_ADDR = 0x60000000, | ||
121 | + FSL_IMX6UL_EIM_ALIAS_ADDR = 0x58000000, | ||
122 | + FSL_IMX6UL_EIM_CS_ADDR = 0x50000000, | ||
123 | + FSL_IMX6UL_AES_ENCRYPT_ADDR = 0x10000000, | ||
124 | + FSL_IMX6UL_QSPI1_RX_ADDR = 0x0C000000, | ||
125 | + | ||
126 | + /* AIPS-2 */ | ||
127 | + FSL_IMX6UL_UART6_ADDR = 0x021FC000, | ||
128 | + FSL_IMX6UL_I2C4_ADDR = 0x021F8000, | ||
129 | + FSL_IMX6UL_UART5_ADDR = 0x021F4000, | ||
130 | + FSL_IMX6UL_UART4_ADDR = 0x021F0000, | ||
131 | + FSL_IMX6UL_UART3_ADDR = 0x021EC000, | ||
132 | + FSL_IMX6UL_UART2_ADDR = 0x021E8000, | ||
133 | + FSL_IMX6UL_WDOG3_ADDR = 0x021E4000, | ||
134 | + FSL_IMX6UL_QSPI_ADDR = 0x021E0000, | ||
135 | + FSL_IMX6UL_SYS_CNT_CTRL_ADDR = 0x021DC000, | ||
136 | + FSL_IMX6UL_SYS_CNT_CMP_ADDR = 0x021D8000, | ||
137 | + FSL_IMX6UL_SYS_CNT_RD_ADDR = 0x021D4000, | ||
138 | + FSL_IMX6UL_TZASC_ADDR = 0x021D0000, | ||
139 | + FSL_IMX6UL_PXP_ADDR = 0x021CC000, | ||
140 | + FSL_IMX6UL_LCDIF_ADDR = 0x021C8000, | ||
141 | + FSL_IMX6UL_CSI_ADDR = 0x021C4000, | ||
142 | + FSL_IMX6UL_CSU_ADDR = 0x021C0000, | ||
143 | + FSL_IMX6UL_OCOTP_CTRL_ADDR = 0x021BC000, | ||
144 | + FSL_IMX6UL_EIM_ADDR = 0x021B8000, | ||
145 | + FSL_IMX6UL_SIM2_ADDR = 0x021B4000, | ||
146 | + FSL_IMX6UL_MMDC_CFG_ADDR = 0x021B0000, | ||
147 | + FSL_IMX6UL_ROMCP_ADDR = 0x021AC000, | ||
148 | + FSL_IMX6UL_I2C3_ADDR = 0x021A8000, | ||
149 | + FSL_IMX6UL_I2C2_ADDR = 0x021A4000, | ||
150 | + FSL_IMX6UL_I2C1_ADDR = 0x021A0000, | ||
151 | + FSL_IMX6UL_ADC2_ADDR = 0x0219C000, | ||
152 | + FSL_IMX6UL_ADC1_ADDR = 0x02198000, | ||
153 | + FSL_IMX6UL_USDHC2_ADDR = 0x02194000, | ||
154 | + FSL_IMX6UL_USDHC1_ADDR = 0x02190000, | ||
155 | + FSL_IMX6UL_SIM1_ADDR = 0x0218C000, | ||
156 | + FSL_IMX6UL_ENET1_ADDR = 0x02188000, | ||
157 | + FSL_IMX6UL_USBO2_USBMISC_ADDR = 0x02184800, | ||
158 | + FSL_IMX6UL_USBO2_USB_ADDR = 0x02184000, | ||
159 | + FSL_IMX6UL_USBO2_PL301_ADDR = 0x02180000, | ||
160 | + FSL_IMX6UL_AIPS2_CFG_ADDR = 0x0217C000, | ||
161 | + FSL_IMX6UL_CAAM_ADDR = 0x02140000, | ||
162 | + FSL_IMX6UL_A7MPCORE_DAP_ADDR = 0x02100000, | ||
163 | + | ||
164 | + /* AIPS-1 */ | ||
165 | + FSL_IMX6UL_PWM8_ADDR = 0x020FC000, | ||
166 | + FSL_IMX6UL_PWM7_ADDR = 0x020F8000, | ||
167 | + FSL_IMX6UL_PWM6_ADDR = 0x020F4000, | ||
168 | + FSL_IMX6UL_PWM5_ADDR = 0x020F0000, | ||
169 | + FSL_IMX6UL_SDMA_ADDR = 0x020EC000, | ||
170 | + FSL_IMX6UL_GPT2_ADDR = 0x020E8000, | ||
171 | + FSL_IMX6UL_IOMUXC_GPR_ADDR = 0x020E4000, | ||
172 | + FSL_IMX6UL_IOMUXC_ADDR = 0x020E0000, | ||
173 | + FSL_IMX6UL_GPC_ADDR = 0x020DC000, | ||
174 | + FSL_IMX6UL_SRC_ADDR = 0x020D8000, | ||
175 | + FSL_IMX6UL_EPIT2_ADDR = 0x020D4000, | ||
176 | + FSL_IMX6UL_EPIT1_ADDR = 0x020D0000, | ||
177 | + FSL_IMX6UL_SNVS_HP_ADDR = 0x020CC000, | ||
178 | + FSL_IMX6UL_ANALOG_ADDR = 0x020C8000, | ||
179 | + FSL_IMX6UL_CCM_ADDR = 0x020C4000, | ||
180 | + FSL_IMX6UL_WDOG2_ADDR = 0x020C0000, | ||
181 | + FSL_IMX6UL_WDOG1_ADDR = 0x020BC000, | ||
182 | + FSL_IMX6UL_KPP_ADDR = 0x020B8000, | ||
183 | + FSL_IMX6UL_ENET2_ADDR = 0x020B4000, | ||
184 | + FSL_IMX6UL_SNVS_LP_ADDR = 0x020B0000, | ||
185 | + FSL_IMX6UL_GPIO5_ADDR = 0x020AC000, | ||
186 | + FSL_IMX6UL_GPIO4_ADDR = 0x020A8000, | ||
187 | + FSL_IMX6UL_GPIO3_ADDR = 0x020A4000, | ||
188 | + FSL_IMX6UL_GPIO2_ADDR = 0x020A0000, | ||
189 | + FSL_IMX6UL_GPIO1_ADDR = 0x0209C000, | ||
190 | + FSL_IMX6UL_GPT1_ADDR = 0x02098000, | ||
191 | + FSL_IMX6UL_CAN2_ADDR = 0x02094000, | ||
192 | + FSL_IMX6UL_CAN1_ADDR = 0x02090000, | ||
193 | + FSL_IMX6UL_PWM4_ADDR = 0x0208C000, | ||
194 | + FSL_IMX6UL_PWM3_ADDR = 0x02088000, | ||
195 | + FSL_IMX6UL_PWM2_ADDR = 0x02084000, | ||
196 | + FSL_IMX6UL_PWM1_ADDR = 0x02080000, | ||
197 | + FSL_IMX6UL_AIPS1_CFG_ADDR = 0x0207C000, | ||
198 | + FSL_IMX6UL_BEE_ADDR = 0x02044000, | ||
199 | + FSL_IMX6UL_TOUCH_CTRL_ADDR = 0x02040000, | ||
200 | + FSL_IMX6UL_SPBA_ADDR = 0x0203C000, | ||
201 | + FSL_IMX6UL_ASRC_ADDR = 0x02034000, | ||
202 | + FSL_IMX6UL_SAI3_ADDR = 0x02030000, | ||
203 | + FSL_IMX6UL_SAI2_ADDR = 0x0202C000, | ||
204 | + FSL_IMX6UL_SAI1_ADDR = 0x02028000, | ||
205 | + FSL_IMX6UL_UART8_ADDR = 0x02024000, | ||
206 | + FSL_IMX6UL_UART1_ADDR = 0x02020000, | ||
207 | + FSL_IMX6UL_UART7_ADDR = 0x02018000, | ||
208 | + FSL_IMX6UL_ECSPI4_ADDR = 0x02014000, | ||
209 | + FSL_IMX6UL_ECSPI3_ADDR = 0x02010000, | ||
210 | + FSL_IMX6UL_ECSPI2_ADDR = 0x0200C000, | ||
211 | + FSL_IMX6UL_ECSPI1_ADDR = 0x02008000, | ||
212 | + FSL_IMX6UL_SPDIF_ADDR = 0x02004000, | ||
213 | + | ||
214 | + FSL_IMX6UL_APBH_DMA_ADDR = 0x01804000, | ||
215 | + FSL_IMX6UL_APBH_DMA_SIZE = (32 * 1024), | ||
216 | + | ||
217 | + FSL_IMX6UL_A7MPCORE_ADDR = 0x00A00000, | ||
218 | + | ||
219 | + FSL_IMX6UL_OCRAM_ALIAS_ADDR = 0x00920000, | ||
220 | + FSL_IMX6UL_OCRAM_ALIAS_SIZE = 0x00060000, | ||
221 | + FSL_IMX6UL_OCRAM_MEM_ADDR = 0x00900000, | ||
222 | + FSL_IMX6UL_OCRAM_MEM_SIZE = 0x00020000, | ||
223 | + FSL_IMX6UL_CAAM_MEM_ADDR = 0x00100000, | ||
224 | + FSL_IMX6UL_CAAM_MEM_SIZE = 0x00008000, | ||
225 | + FSL_IMX6UL_ROM_ADDR = 0x00000000, | ||
226 | + FSL_IMX6UL_ROM_SIZE = 0x00018000, | ||
227 | +}; | ||
228 | + | ||
229 | +enum FslIMX6ULIRQs { | ||
230 | + FSL_IMX6UL_IOMUXC_IRQ = 0, | ||
231 | + FSL_IMX6UL_DAP_IRQ = 1, | ||
232 | + FSL_IMX6UL_SDMA_IRQ = 2, | ||
233 | + FSL_IMX6UL_TSC_IRQ = 3, | ||
234 | + FSL_IMX6UL_SNVS_IRQ = 4, | ||
235 | + FSL_IMX6UL_LCDIF_IRQ = 5, | ||
236 | + FSL_IMX6UL_BEE_IRQ = 6, | ||
237 | + FSL_IMX6UL_CSI_IRQ = 7, | ||
238 | + FSL_IMX6UL_PXP_IRQ = 8, | ||
239 | + FSL_IMX6UL_SCTR1_IRQ = 9, | ||
240 | + FSL_IMX6UL_SCTR2_IRQ = 10, | ||
241 | + FSL_IMX6UL_WDOG3_IRQ = 11, | ||
242 | + FSL_IMX6UL_APBH_DMA_IRQ = 13, | ||
243 | + FSL_IMX6UL_WEIM_IRQ = 14, | ||
244 | + FSL_IMX6UL_RAWNAND1_IRQ = 15, | ||
245 | + FSL_IMX6UL_RAWNAND2_IRQ = 16, | ||
246 | + FSL_IMX6UL_UART6_IRQ = 17, | ||
247 | + FSL_IMX6UL_SRTC_IRQ = 19, | ||
248 | + FSL_IMX6UL_SRTC_SEC_IRQ = 20, | ||
249 | + FSL_IMX6UL_CSU_IRQ = 21, | ||
250 | + FSL_IMX6UL_USDHC1_IRQ = 22, | ||
251 | + FSL_IMX6UL_USDHC2_IRQ = 23, | ||
252 | + FSL_IMX6UL_SAI3_IRQ = 24, | ||
253 | + FSL_IMX6UL_SAI32_IRQ = 25, | ||
254 | + | ||
255 | + FSL_IMX6UL_UART1_IRQ = 26, | ||
256 | + FSL_IMX6UL_UART2_IRQ = 27, | ||
257 | + FSL_IMX6UL_UART3_IRQ = 28, | ||
258 | + FSL_IMX6UL_UART4_IRQ = 29, | ||
259 | + FSL_IMX6UL_UART5_IRQ = 30, | ||
260 | + | ||
261 | + FSL_IMX6UL_ECSPI1_IRQ = 31, | ||
262 | + FSL_IMX6UL_ECSPI2_IRQ = 32, | ||
263 | + FSL_IMX6UL_ECSPI3_IRQ = 33, | ||
264 | + FSL_IMX6UL_ECSPI4_IRQ = 34, | ||
265 | + | ||
266 | + FSL_IMX6UL_I2C4_IRQ = 35, | ||
267 | + FSL_IMX6UL_I2C1_IRQ = 36, | ||
268 | + FSL_IMX6UL_I2C2_IRQ = 37, | ||
269 | + FSL_IMX6UL_I2C3_IRQ = 38, | ||
270 | + | ||
271 | + FSL_IMX6UL_UART7_IRQ = 39, | ||
272 | + FSL_IMX6UL_UART8_IRQ = 40, | ||
273 | + | ||
274 | + FSL_IMX6UL_USB1_IRQ = 42, | ||
275 | + FSL_IMX6UL_USB2_IRQ = 43, | ||
276 | + FSL_IMX6UL_USB_PHY1_IRQ = 44, | ||
277 | + FSL_IMX6UL_USB_PHY2_IRQ = 44, | ||
278 | + | ||
279 | + FSL_IMX6UL_CAAM_JQ2_IRQ = 46, | ||
280 | + FSL_IMX6UL_CAAM_ERR_IRQ = 47, | ||
281 | + FSL_IMX6UL_CAAM_RTIC_IRQ = 48, | ||
282 | + FSL_IMX6UL_TEMP_IRQ = 49, | ||
283 | + FSL_IMX6UL_ASRC_IRQ = 50, | ||
284 | + FSL_IMX6UL_SPDIF_IRQ = 52, | ||
285 | + FSL_IMX6UL_PMU_REG_IRQ = 54, | ||
286 | + FSL_IMX6UL_GPT1_IRQ = 55, | ||
287 | + | ||
288 | + FSL_IMX6UL_EPIT1_IRQ = 56, | ||
289 | + FSL_IMX6UL_EPIT2_IRQ = 57, | ||
290 | + | ||
291 | + FSL_IMX6UL_GPIO1_INT7_IRQ = 58, | ||
292 | + FSL_IMX6UL_GPIO1_INT6_IRQ = 59, | ||
293 | + FSL_IMX6UL_GPIO1_INT5_IRQ = 60, | ||
294 | + FSL_IMX6UL_GPIO1_INT4_IRQ = 61, | ||
295 | + FSL_IMX6UL_GPIO1_INT3_IRQ = 62, | ||
296 | + FSL_IMX6UL_GPIO1_INT2_IRQ = 63, | ||
297 | + FSL_IMX6UL_GPIO1_INT1_IRQ = 64, | ||
298 | + FSL_IMX6UL_GPIO1_INT0_IRQ = 65, | ||
299 | + FSL_IMX6UL_GPIO1_LOW_IRQ = 66, | ||
300 | + FSL_IMX6UL_GPIO1_HIGH_IRQ = 67, | ||
301 | + FSL_IMX6UL_GPIO2_LOW_IRQ = 68, | ||
302 | + FSL_IMX6UL_GPIO2_HIGH_IRQ = 69, | ||
303 | + FSL_IMX6UL_GPIO3_LOW_IRQ = 70, | ||
304 | + FSL_IMX6UL_GPIO3_HIGH_IRQ = 71, | ||
305 | + FSL_IMX6UL_GPIO4_LOW_IRQ = 72, | ||
306 | + FSL_IMX6UL_GPIO4_HIGH_IRQ = 73, | ||
307 | + FSL_IMX6UL_GPIO5_LOW_IRQ = 74, | ||
308 | + FSL_IMX6UL_GPIO5_HIGH_IRQ = 75, | ||
309 | + | ||
310 | + FSL_IMX6UL_WDOG1_IRQ = 80, | ||
311 | + FSL_IMX6UL_WDOG2_IRQ = 81, | ||
312 | + | ||
313 | + FSL_IMX6UL_KPP_IRQ = 82, | ||
314 | + | ||
315 | + FSL_IMX6UL_PWM1_IRQ = 83, | ||
316 | + FSL_IMX6UL_PWM2_IRQ = 84, | ||
317 | + FSL_IMX6UL_PWM3_IRQ = 85, | ||
318 | + FSL_IMX6UL_PWM4_IRQ = 86, | ||
319 | + | ||
320 | + FSL_IMX6UL_CCM1_IRQ = 87, | ||
321 | + FSL_IMX6UL_CCM2_IRQ = 88, | ||
322 | + | ||
323 | + FSL_IMX6UL_GPC_IRQ = 89, | ||
324 | + | ||
325 | + FSL_IMX6UL_SRC_IRQ = 91, | ||
326 | + | ||
327 | + FSL_IMX6UL_CPU_PERF_IRQ = 94, | ||
328 | + FSL_IMX6UL_CPU_CTI_IRQ = 95, | ||
329 | + | ||
330 | + FSL_IMX6UL_SRC_WDOG_IRQ = 96, | ||
331 | + | ||
332 | + FSL_IMX6UL_SAI1_IRQ = 97, | ||
333 | + FSL_IMX6UL_SAI2_IRQ = 98, | ||
334 | + | ||
335 | + FSL_IMX6UL_ADC1_IRQ = 100, | ||
336 | + FSL_IMX6UL_ADC2_IRQ = 101, | ||
337 | + | ||
338 | + FSL_IMX6UL_SJC_IRQ = 104, | ||
339 | + | ||
340 | + FSL_IMX6UL_CAAM_RING0_IRQ = 105, | ||
341 | + FSL_IMX6UL_CAAM_RING1_IRQ = 106, | ||
342 | + | ||
343 | + FSL_IMX6UL_QSPI_IRQ = 107, | ||
344 | + | ||
345 | + FSL_IMX6UL_TZASC_IRQ = 108, | ||
346 | + | ||
347 | + FSL_IMX6UL_GPT2_IRQ = 109, | ||
348 | + | ||
349 | + FSL_IMX6UL_CAN1_IRQ = 110, | ||
350 | + FSL_IMX6UL_CAN2_IRQ = 111, | ||
351 | + | ||
352 | + FSL_IMX6UL_SIM1_IRQ = 112, | ||
353 | + FSL_IMX6UL_SIM2_IRQ = 113, | ||
354 | + | ||
355 | + FSL_IMX6UL_PWM5_IRQ = 114, | ||
356 | + FSL_IMX6UL_PWM6_IRQ = 115, | ||
357 | + FSL_IMX6UL_PWM7_IRQ = 116, | ||
358 | + FSL_IMX6UL_PWM8_IRQ = 117, | ||
359 | + | ||
360 | + FSL_IMX6UL_ENET1_IRQ = 118, | ||
361 | + FSL_IMX6UL_ENET1_TIMER_IRQ = 119, | ||
362 | + FSL_IMX6UL_ENET2_IRQ = 120, | ||
363 | + FSL_IMX6UL_ENET2_TIMER_IRQ = 121, | ||
364 | + | ||
365 | + FSL_IMX6UL_PMU_CORE_IRQ = 127, | ||
366 | + FSL_IMX6UL_MAX_IRQ = 128, | ||
367 | +}; | ||
368 | + | ||
369 | +#endif /* FSL_IMX6UL_H */ | ||
370 | diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c | ||
371 | new file mode 100644 | ||
372 | index XXXXXXX..XXXXXXX | ||
373 | --- /dev/null | ||
374 | +++ b/hw/arm/fsl-imx6ul.c | ||
375 | @@ -XXX,XX +XXX,XX @@ | ||
376 | +/* | ||
377 | + * Copyright (c) 2018 Jean-Christophe Dubois <jcd@tribudubois.net> | ||
378 | + * | ||
379 | + * i.MX6UL SOC emulation. | ||
380 | + * | ||
381 | + * Based on hw/arm/fsl-imx7.c | ||
382 | + * | ||
383 | + * This program is free software; you can redistribute it and/or modify | ||
384 | + * it under the terms of the GNU General Public License as published by | ||
385 | + * the Free Software Foundation; either version 2 of the License, or | ||
386 | + * (at your option) any later version. | ||
387 | + * | ||
388 | + * This program is distributed in the hope that it will be useful, | ||
389 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
390 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
391 | + * GNU General Public License for more details. | ||
392 | + */ | ||
393 | + | ||
394 | +#include "qemu/osdep.h" | ||
395 | +#include "qapi/error.h" | ||
396 | +#include "qemu-common.h" | ||
397 | +#include "hw/arm/fsl-imx6ul.h" | ||
398 | +#include "hw/misc/unimp.h" | ||
399 | +#include "sysemu/sysemu.h" | ||
400 | +#include "qemu/error-report.h" | ||
401 | + | ||
402 | +#define NAME_SIZE 20 | ||
403 | + | ||
404 | +static void fsl_imx6ul_init(Object *obj) | ||
405 | +{ | ||
406 | + FslIMX6ULState *s = FSL_IMX6UL(obj); | ||
407 | + char name[NAME_SIZE]; | ||
408 | + int i; | ||
409 | + | ||
410 | + for (i = 0; i < MIN(smp_cpus, FSL_IMX6UL_NUM_CPUS); i++) { | ||
411 | + snprintf(name, NAME_SIZE, "cpu%d", i); | ||
412 | + object_initialize_child(obj, name, &s->cpu[i], sizeof(s->cpu[i]), | ||
413 | + "cortex-a7-" TYPE_ARM_CPU, &error_abort, NULL); | ||
414 | + } | 53 | + } |
415 | + | 54 | + |
416 | + /* | 55 | + addr = load_reg(s, a->rn); |
417 | + * A7MPCORE | 56 | + if (a->p) { |
418 | + */ | 57 | + tcg_gen_addi_i32(addr, addr, offset); |
419 | + sysbus_init_child_obj(obj, "a7mpcore", &s->a7mpcore, sizeof(s->a7mpcore), | ||
420 | + TYPE_A15MPCORE_PRIV); | ||
421 | + | ||
422 | + /* | ||
423 | + * CCM | ||
424 | + */ | ||
425 | + sysbus_init_child_obj(obj, "ccm", &s->ccm, sizeof(s->ccm), TYPE_IMX6UL_CCM); | ||
426 | + | ||
427 | + /* | ||
428 | + * SRC | ||
429 | + */ | ||
430 | + sysbus_init_child_obj(obj, "src", &s->src, sizeof(s->src), TYPE_IMX6_SRC); | ||
431 | + | ||
432 | + /* | ||
433 | + * GPCv2 | ||
434 | + */ | ||
435 | + sysbus_init_child_obj(obj, "gpcv2", &s->gpcv2, sizeof(s->gpcv2), | ||
436 | + TYPE_IMX_GPCV2); | ||
437 | + | ||
438 | + /* | ||
439 | + * SNVS | ||
440 | + */ | ||
441 | + sysbus_init_child_obj(obj, "snvs", &s->snvs, sizeof(s->snvs), | ||
442 | + TYPE_IMX7_SNVS); | ||
443 | + | ||
444 | + /* | ||
445 | + * GPR | ||
446 | + */ | ||
447 | + sysbus_init_child_obj(obj, "gpr", &s->gpr, sizeof(s->gpr), | ||
448 | + TYPE_IMX7_GPR); | ||
449 | + | ||
450 | + /* | ||
451 | + * GPIOs 1 to 5 | ||
452 | + */ | ||
453 | + for (i = 0; i < FSL_IMX6UL_NUM_GPIOS; i++) { | ||
454 | + snprintf(name, NAME_SIZE, "gpio%d", i); | ||
455 | + sysbus_init_child_obj(obj, name, &s->gpio[i], sizeof(s->gpio[i]), | ||
456 | + TYPE_IMX_GPIO); | ||
457 | + } | 58 | + } |
458 | + | 59 | + |
459 | + /* | 60 | + if (s->v8m_stackcheck && a->rn == 13 && a->w) { |
460 | + * GPT 1, 2 | 61 | + gen_helper_v8m_stackcheck(cpu_env, addr); |
461 | + */ | ||
462 | + for (i = 0; i < FSL_IMX6UL_NUM_GPTS; i++) { | ||
463 | + snprintf(name, NAME_SIZE, "gpt%d", i); | ||
464 | + sysbus_init_child_obj(obj, name, &s->gpt[i], sizeof(s->gpt[i]), | ||
465 | + TYPE_IMX7_GPT); | ||
466 | + } | 62 | + } |
467 | + | 63 | + |
468 | + /* | 64 | + gen_aa32_st_i32(s, value, addr, get_mem_index(s), |
469 | + * EPIT 1, 2 | 65 | + MO_UL | MO_ALIGN | s->be_data); |
470 | + */ | 66 | + tcg_temp_free_i32(value); |
471 | + for (i = 0; i < FSL_IMX6UL_NUM_EPITS; i++) { | ||
472 | + snprintf(name, NAME_SIZE, "epit%d", i + 1); | ||
473 | + sysbus_init_child_obj(obj, name, &s->epit[i], sizeof(s->epit[i]), | ||
474 | + TYPE_IMX_EPIT); | ||
475 | + } | ||
476 | + | 67 | + |
477 | + /* | 68 | + if (a->w) { |
478 | + * eCSPI | 69 | + /* writeback */ |
479 | + */ | 70 | + if (!a->p) { |
480 | + for (i = 0; i < FSL_IMX6UL_NUM_ECSPIS; i++) { | 71 | + tcg_gen_addi_i32(addr, addr, offset); |
481 | + snprintf(name, NAME_SIZE, "spi%d", i + 1); | 72 | + } |
482 | + sysbus_init_child_obj(obj, name, &s->spi[i], sizeof(s->spi[i]), | 73 | + store_reg(s, a->rn, addr); |
483 | + TYPE_IMX_SPI); | 74 | + } else { |
484 | + } | 75 | + tcg_temp_free_i32(addr); |
485 | + | ||
486 | + /* | ||
487 | + * I2C | ||
488 | + */ | ||
489 | + for (i = 0; i < FSL_IMX6UL_NUM_I2CS; i++) { | ||
490 | + snprintf(name, NAME_SIZE, "i2c%d", i + 1); | ||
491 | + sysbus_init_child_obj(obj, name, &s->i2c[i], sizeof(s->i2c[i]), | ||
492 | + TYPE_IMX_I2C); | ||
493 | + } | ||
494 | + | ||
495 | + /* | ||
496 | + * UART | ||
497 | + */ | ||
498 | + for (i = 0; i < FSL_IMX6UL_NUM_UARTS; i++) { | ||
499 | + snprintf(name, NAME_SIZE, "uart%d", i); | ||
500 | + sysbus_init_child_obj(obj, name, &s->uart[i], sizeof(s->uart[i]), | ||
501 | + TYPE_IMX_SERIAL); | ||
502 | + } | ||
503 | + | ||
504 | + /* | ||
505 | + * Ethernet | ||
506 | + */ | ||
507 | + for (i = 0; i < FSL_IMX6UL_NUM_ETHS; i++) { | ||
508 | + snprintf(name, NAME_SIZE, "eth%d", i); | ||
509 | + sysbus_init_child_obj(obj, name, &s->eth[i], sizeof(s->eth[i]), | ||
510 | + TYPE_IMX_ENET); | ||
511 | + } | ||
512 | + | ||
513 | + /* | ||
514 | + * SDHCI | ||
515 | + */ | ||
516 | + for (i = 0; i < FSL_IMX6UL_NUM_USDHCS; i++) { | ||
517 | + snprintf(name, NAME_SIZE, "usdhc%d", i); | ||
518 | + sysbus_init_child_obj(obj, name, &s->usdhc[i], sizeof(s->usdhc[i]), | ||
519 | + TYPE_IMX_USDHC); | ||
520 | + } | ||
521 | + | ||
522 | + /* | ||
523 | + * Watchdog | ||
524 | + */ | ||
525 | + for (i = 0; i < FSL_IMX6UL_NUM_WDTS; i++) { | ||
526 | + snprintf(name, NAME_SIZE, "wdt%d", i); | ||
527 | + sysbus_init_child_obj(obj, name, &s->wdt[i], sizeof(s->wdt[i]), | ||
528 | + TYPE_IMX2_WDT); | ||
529 | + } | 76 | + } |
530 | +} | 77 | +} |
531 | + | 78 | + |
532 | +static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | 79 | +static TCGv_i32 memory_to_fp_sysreg(DisasContext *s, void *opaque) |
533 | +{ | 80 | +{ |
534 | + FslIMX6ULState *s = FSL_IMX6UL(dev); | 81 | + arg_vldr_sysreg *a = opaque; |
535 | + int i; | 82 | + uint32_t offset = a->imm; |
536 | + qemu_irq irq; | 83 | + TCGv_i32 addr; |
537 | + char name[NAME_SIZE]; | 84 | + TCGv_i32 value = tcg_temp_new_i32(); |
538 | + | 85 | + |
539 | + if (smp_cpus > FSL_IMX6UL_NUM_CPUS) { | 86 | + if (!a->a) { |
540 | + error_setg(errp, "%s: Only %d CPUs are supported (%d requested)", | 87 | + offset = - offset; |
541 | + TYPE_FSL_IMX6UL, FSL_IMX6UL_NUM_CPUS, smp_cpus); | ||
542 | + return; | ||
543 | + } | 88 | + } |
544 | + | 89 | + |
545 | + for (i = 0; i < smp_cpus; i++) { | 90 | + addr = load_reg(s, a->rn); |
546 | + Object *o = OBJECT(&s->cpu[i]); | 91 | + if (a->p) { |
547 | + | 92 | + tcg_gen_addi_i32(addr, addr, offset); |
548 | + object_property_set_int(o, QEMU_PSCI_CONDUIT_SMC, | ||
549 | + "psci-conduit", &error_abort); | ||
550 | + | ||
551 | + /* On uniprocessor, the CBAR is set to 0 */ | ||
552 | + if (smp_cpus > 1) { | ||
553 | + object_property_set_int(o, FSL_IMX6UL_A7MPCORE_ADDR, | ||
554 | + "reset-cbar", &error_abort); | ||
555 | + } | ||
556 | + | ||
557 | + if (i) { | ||
558 | + /* Secondary CPUs start in PSCI powered-down state */ | ||
559 | + object_property_set_bool(o, true, | ||
560 | + "start-powered-off", &error_abort); | ||
561 | + } | ||
562 | + | ||
563 | + object_property_set_bool(o, true, "realized", &error_abort); | ||
564 | + } | 93 | + } |
565 | + | 94 | + |
566 | + /* | 95 | + if (s->v8m_stackcheck && a->rn == 13 && a->w) { |
567 | + * A7MPCORE | 96 | + gen_helper_v8m_stackcheck(cpu_env, addr); |
568 | + */ | ||
569 | + object_property_set_int(OBJECT(&s->a7mpcore), smp_cpus, "num-cpu", | ||
570 | + &error_abort); | ||
571 | + object_property_set_int(OBJECT(&s->a7mpcore), | ||
572 | + FSL_IMX6UL_MAX_IRQ + GIC_INTERNAL, | ||
573 | + "num-irq", &error_abort); | ||
574 | + object_property_set_bool(OBJECT(&s->a7mpcore), true, "realized", | ||
575 | + &error_abort); | ||
576 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->a7mpcore), 0, FSL_IMX6UL_A7MPCORE_ADDR); | ||
577 | + | ||
578 | + for (i = 0; i < smp_cpus; i++) { | ||
579 | + SysBusDevice *sbd = SYS_BUS_DEVICE(&s->a7mpcore); | ||
580 | + DeviceState *d = DEVICE(qemu_get_cpu(i)); | ||
581 | + | ||
582 | + irq = qdev_get_gpio_in(d, ARM_CPU_IRQ); | ||
583 | + sysbus_connect_irq(sbd, i, irq); | ||
584 | + sysbus_connect_irq(sbd, i + smp_cpus, qdev_get_gpio_in(d, ARM_CPU_FIQ)); | ||
585 | + } | 97 | + } |
586 | + | 98 | + |
587 | + /* | 99 | + gen_aa32_ld_i32(s, value, addr, get_mem_index(s), |
588 | + * A7MPCORE DAP | 100 | + MO_UL | MO_ALIGN | s->be_data); |
589 | + */ | ||
590 | + create_unimplemented_device("a7mpcore-dap", FSL_IMX6UL_A7MPCORE_DAP_ADDR, | ||
591 | + 0x100000); | ||
592 | + | 101 | + |
593 | + /* | 102 | + if (a->w) { |
594 | + * GPT 1, 2 | 103 | + /* writeback */ |
595 | + */ | 104 | + if (!a->p) { |
596 | + for (i = 0; i < FSL_IMX6UL_NUM_GPTS; i++) { | 105 | + tcg_gen_addi_i32(addr, addr, offset); |
597 | + static const hwaddr FSL_IMX6UL_GPTn_ADDR[FSL_IMX6UL_NUM_GPTS] = { | 106 | + } |
598 | + FSL_IMX6UL_GPT1_ADDR, | 107 | + store_reg(s, a->rn, addr); |
599 | + FSL_IMX6UL_GPT2_ADDR, | 108 | + } else { |
600 | + }; | 109 | + tcg_temp_free_i32(addr); |
601 | + | ||
602 | + static const int FSL_IMX6UL_GPTn_IRQ[FSL_IMX6UL_NUM_GPTS] = { | ||
603 | + FSL_IMX6UL_GPT1_IRQ, | ||
604 | + FSL_IMX6UL_GPT2_IRQ, | ||
605 | + }; | ||
606 | + | ||
607 | + s->gpt[i].ccm = IMX_CCM(&s->ccm); | ||
608 | + object_property_set_bool(OBJECT(&s->gpt[i]), true, "realized", | ||
609 | + &error_abort); | ||
610 | + | ||
611 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpt[i]), 0, | ||
612 | + FSL_IMX6UL_GPTn_ADDR[i]); | ||
613 | + | ||
614 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpt[i]), 0, | ||
615 | + qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
616 | + FSL_IMX6UL_GPTn_IRQ[i])); | ||
617 | + } | 110 | + } |
618 | + | 111 | + return value; |
619 | + /* | ||
620 | + * EPIT 1, 2 | ||
621 | + */ | ||
622 | + for (i = 0; i < FSL_IMX6UL_NUM_EPITS; i++) { | ||
623 | + static const hwaddr FSL_IMX6UL_EPITn_ADDR[FSL_IMX6UL_NUM_EPITS] = { | ||
624 | + FSL_IMX6UL_EPIT1_ADDR, | ||
625 | + FSL_IMX6UL_EPIT2_ADDR, | ||
626 | + }; | ||
627 | + | ||
628 | + static const int FSL_IMX6UL_EPITn_IRQ[FSL_IMX6UL_NUM_EPITS] = { | ||
629 | + FSL_IMX6UL_EPIT1_IRQ, | ||
630 | + FSL_IMX6UL_EPIT2_IRQ, | ||
631 | + }; | ||
632 | + | ||
633 | + s->epit[i].ccm = IMX_CCM(&s->ccm); | ||
634 | + object_property_set_bool(OBJECT(&s->epit[i]), true, "realized", | ||
635 | + &error_abort); | ||
636 | + | ||
637 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->epit[i]), 0, | ||
638 | + FSL_IMX6UL_EPITn_ADDR[i]); | ||
639 | + | ||
640 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->epit[i]), 0, | ||
641 | + qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
642 | + FSL_IMX6UL_EPITn_IRQ[i])); | ||
643 | + } | ||
644 | + | ||
645 | + /* | ||
646 | + * GPIO | ||
647 | + */ | ||
648 | + for (i = 0; i < FSL_IMX6UL_NUM_GPIOS; i++) { | ||
649 | + static const hwaddr FSL_IMX6UL_GPIOn_ADDR[FSL_IMX6UL_NUM_GPIOS] = { | ||
650 | + FSL_IMX6UL_GPIO1_ADDR, | ||
651 | + FSL_IMX6UL_GPIO2_ADDR, | ||
652 | + FSL_IMX6UL_GPIO3_ADDR, | ||
653 | + FSL_IMX6UL_GPIO4_ADDR, | ||
654 | + FSL_IMX6UL_GPIO5_ADDR, | ||
655 | + }; | ||
656 | + | ||
657 | + static const int FSL_IMX6UL_GPIOn_LOW_IRQ[FSL_IMX6UL_NUM_GPIOS] = { | ||
658 | + FSL_IMX6UL_GPIO1_LOW_IRQ, | ||
659 | + FSL_IMX6UL_GPIO2_LOW_IRQ, | ||
660 | + FSL_IMX6UL_GPIO3_LOW_IRQ, | ||
661 | + FSL_IMX6UL_GPIO4_LOW_IRQ, | ||
662 | + FSL_IMX6UL_GPIO5_LOW_IRQ, | ||
663 | + }; | ||
664 | + | ||
665 | + static const int FSL_IMX6UL_GPIOn_HIGH_IRQ[FSL_IMX6UL_NUM_GPIOS] = { | ||
666 | + FSL_IMX6UL_GPIO1_HIGH_IRQ, | ||
667 | + FSL_IMX6UL_GPIO2_HIGH_IRQ, | ||
668 | + FSL_IMX6UL_GPIO3_HIGH_IRQ, | ||
669 | + FSL_IMX6UL_GPIO4_HIGH_IRQ, | ||
670 | + FSL_IMX6UL_GPIO5_HIGH_IRQ, | ||
671 | + }; | ||
672 | + | ||
673 | + object_property_set_bool(OBJECT(&s->gpio[i]), true, "realized", | ||
674 | + &error_abort); | ||
675 | + | ||
676 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0, | ||
677 | + FSL_IMX6UL_GPIOn_ADDR[i]); | ||
678 | + | ||
679 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 0, | ||
680 | + qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
681 | + FSL_IMX6UL_GPIOn_LOW_IRQ[i])); | ||
682 | + | ||
683 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 1, | ||
684 | + qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
685 | + FSL_IMX6UL_GPIOn_HIGH_IRQ[i])); | ||
686 | + } | ||
687 | + | ||
688 | + /* | ||
689 | + * IOMUXC and IOMUXC_GPR | ||
690 | + */ | ||
691 | + for (i = 0; i < 1; i++) { | ||
692 | + static const hwaddr FSL_IMX6UL_IOMUXCn_ADDR[FSL_IMX6UL_NUM_IOMUXCS] = { | ||
693 | + FSL_IMX6UL_IOMUXC_ADDR, | ||
694 | + FSL_IMX6UL_IOMUXC_GPR_ADDR, | ||
695 | + }; | ||
696 | + | ||
697 | + snprintf(name, NAME_SIZE, "iomuxc%d", i); | ||
698 | + create_unimplemented_device(name, FSL_IMX6UL_IOMUXCn_ADDR[i], 0x4000); | ||
699 | + } | ||
700 | + | ||
701 | + /* | ||
702 | + * CCM | ||
703 | + */ | ||
704 | + object_property_set_bool(OBJECT(&s->ccm), true, "realized", &error_abort); | ||
705 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->ccm), 0, FSL_IMX6UL_CCM_ADDR); | ||
706 | + | ||
707 | + /* | ||
708 | + * SRC | ||
709 | + */ | ||
710 | + object_property_set_bool(OBJECT(&s->src), true, "realized", &error_abort); | ||
711 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->src), 0, FSL_IMX6UL_SRC_ADDR); | ||
712 | + | ||
713 | + /* | ||
714 | + * GPCv2 | ||
715 | + */ | ||
716 | + object_property_set_bool(OBJECT(&s->gpcv2), true, | ||
717 | + "realized", &error_abort); | ||
718 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpcv2), 0, FSL_IMX6UL_GPC_ADDR); | ||
719 | + | ||
720 | + /* Initialize all ECSPI */ | ||
721 | + for (i = 0; i < FSL_IMX6UL_NUM_ECSPIS; i++) { | ||
722 | + static const hwaddr FSL_IMX6UL_SPIn_ADDR[FSL_IMX6UL_NUM_ECSPIS] = { | ||
723 | + FSL_IMX6UL_ECSPI1_ADDR, | ||
724 | + FSL_IMX6UL_ECSPI2_ADDR, | ||
725 | + FSL_IMX6UL_ECSPI3_ADDR, | ||
726 | + FSL_IMX6UL_ECSPI4_ADDR, | ||
727 | + }; | ||
728 | + | ||
729 | + static const int FSL_IMX6UL_SPIn_IRQ[FSL_IMX6UL_NUM_ECSPIS] = { | ||
730 | + FSL_IMX6UL_ECSPI1_IRQ, | ||
731 | + FSL_IMX6UL_ECSPI2_IRQ, | ||
732 | + FSL_IMX6UL_ECSPI3_IRQ, | ||
733 | + FSL_IMX6UL_ECSPI4_IRQ, | ||
734 | + }; | ||
735 | + | ||
736 | + /* Initialize the SPI */ | ||
737 | + object_property_set_bool(OBJECT(&s->spi[i]), true, "realized", | ||
738 | + &error_abort); | ||
739 | + | ||
740 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, | ||
741 | + FSL_IMX6UL_SPIn_ADDR[i]); | ||
742 | + | ||
743 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0, | ||
744 | + qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
745 | + FSL_IMX6UL_SPIn_IRQ[i])); | ||
746 | + } | ||
747 | + | ||
748 | + /* | ||
749 | + * I2C | ||
750 | + */ | ||
751 | + for (i = 0; i < FSL_IMX6UL_NUM_I2CS; i++) { | ||
752 | + static const hwaddr FSL_IMX6UL_I2Cn_ADDR[FSL_IMX6UL_NUM_I2CS] = { | ||
753 | + FSL_IMX6UL_I2C1_ADDR, | ||
754 | + FSL_IMX6UL_I2C2_ADDR, | ||
755 | + FSL_IMX6UL_I2C3_ADDR, | ||
756 | + FSL_IMX6UL_I2C4_ADDR, | ||
757 | + }; | ||
758 | + | ||
759 | + static const int FSL_IMX6UL_I2Cn_IRQ[FSL_IMX6UL_NUM_I2CS] = { | ||
760 | + FSL_IMX6UL_I2C1_IRQ, | ||
761 | + FSL_IMX6UL_I2C2_IRQ, | ||
762 | + FSL_IMX6UL_I2C3_IRQ, | ||
763 | + FSL_IMX6UL_I2C4_IRQ, | ||
764 | + }; | ||
765 | + | ||
766 | + object_property_set_bool(OBJECT(&s->i2c[i]), true, "realized", | ||
767 | + &error_abort); | ||
768 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c[i]), 0, FSL_IMX6UL_I2Cn_ADDR[i]); | ||
769 | + | ||
770 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c[i]), 0, | ||
771 | + qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
772 | + FSL_IMX6UL_I2Cn_IRQ[i])); | ||
773 | + } | ||
774 | + | ||
775 | + /* | ||
776 | + * UART | ||
777 | + */ | ||
778 | + for (i = 0; i < FSL_IMX6UL_NUM_UARTS; i++) { | ||
779 | + static const hwaddr FSL_IMX6UL_UARTn_ADDR[FSL_IMX6UL_NUM_UARTS] = { | ||
780 | + FSL_IMX6UL_UART1_ADDR, | ||
781 | + FSL_IMX6UL_UART2_ADDR, | ||
782 | + FSL_IMX6UL_UART3_ADDR, | ||
783 | + FSL_IMX6UL_UART4_ADDR, | ||
784 | + FSL_IMX6UL_UART5_ADDR, | ||
785 | + FSL_IMX6UL_UART6_ADDR, | ||
786 | + FSL_IMX6UL_UART7_ADDR, | ||
787 | + FSL_IMX6UL_UART8_ADDR, | ||
788 | + }; | ||
789 | + | ||
790 | + static const int FSL_IMX6UL_UARTn_IRQ[FSL_IMX6UL_NUM_UARTS] = { | ||
791 | + FSL_IMX6UL_UART1_IRQ, | ||
792 | + FSL_IMX6UL_UART2_IRQ, | ||
793 | + FSL_IMX6UL_UART3_IRQ, | ||
794 | + FSL_IMX6UL_UART4_IRQ, | ||
795 | + FSL_IMX6UL_UART5_IRQ, | ||
796 | + FSL_IMX6UL_UART6_IRQ, | ||
797 | + FSL_IMX6UL_UART7_IRQ, | ||
798 | + FSL_IMX6UL_UART8_IRQ, | ||
799 | + }; | ||
800 | + | ||
801 | + qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", serial_hd(i)); | ||
802 | + | ||
803 | + object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", | ||
804 | + &error_abort); | ||
805 | + | ||
806 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0, | ||
807 | + FSL_IMX6UL_UARTn_ADDR[i]); | ||
808 | + | ||
809 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart[i]), 0, | ||
810 | + qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
811 | + FSL_IMX6UL_UARTn_IRQ[i])); | ||
812 | + } | ||
813 | + | ||
814 | + /* | ||
815 | + * Ethernet | ||
816 | + */ | ||
817 | + for (i = 0; i < FSL_IMX6UL_NUM_ETHS; i++) { | ||
818 | + static const hwaddr FSL_IMX6UL_ENETn_ADDR[FSL_IMX6UL_NUM_ETHS] = { | ||
819 | + FSL_IMX6UL_ENET1_ADDR, | ||
820 | + FSL_IMX6UL_ENET2_ADDR, | ||
821 | + }; | ||
822 | + | ||
823 | + static const int FSL_IMX6UL_ENETn_IRQ[FSL_IMX6UL_NUM_ETHS] = { | ||
824 | + FSL_IMX6UL_ENET1_IRQ, | ||
825 | + FSL_IMX6UL_ENET2_IRQ, | ||
826 | + }; | ||
827 | + | ||
828 | + static const int FSL_IMX6UL_ENETn_TIMER_IRQ[FSL_IMX6UL_NUM_ETHS] = { | ||
829 | + FSL_IMX6UL_ENET1_TIMER_IRQ, | ||
830 | + FSL_IMX6UL_ENET2_TIMER_IRQ, | ||
831 | + }; | ||
832 | + | ||
833 | + object_property_set_uint(OBJECT(&s->eth[i]), | ||
834 | + FSL_IMX6UL_ETH_NUM_TX_RINGS, | ||
835 | + "tx-ring-num", &error_abort); | ||
836 | + qdev_set_nic_properties(DEVICE(&s->eth[i]), &nd_table[i]); | ||
837 | + object_property_set_bool(OBJECT(&s->eth[i]), true, "realized", | ||
838 | + &error_abort); | ||
839 | + | ||
840 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->eth[i]), 0, | ||
841 | + FSL_IMX6UL_ENETn_ADDR[i]); | ||
842 | + | ||
843 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->eth[i]), 0, | ||
844 | + qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
845 | + FSL_IMX6UL_ENETn_IRQ[i])); | ||
846 | + | ||
847 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->eth[i]), 1, | ||
848 | + qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
849 | + FSL_IMX6UL_ENETn_TIMER_IRQ[i])); | ||
850 | + } | ||
851 | + | ||
852 | + /* | ||
853 | + * USDHC | ||
854 | + */ | ||
855 | + for (i = 0; i < FSL_IMX6UL_NUM_USDHCS; i++) { | ||
856 | + static const hwaddr FSL_IMX6UL_USDHCn_ADDR[FSL_IMX6UL_NUM_USDHCS] = { | ||
857 | + FSL_IMX6UL_USDHC1_ADDR, | ||
858 | + FSL_IMX6UL_USDHC2_ADDR, | ||
859 | + }; | ||
860 | + | ||
861 | + static const int FSL_IMX6UL_USDHCn_IRQ[FSL_IMX6UL_NUM_USDHCS] = { | ||
862 | + FSL_IMX6UL_USDHC1_IRQ, | ||
863 | + FSL_IMX6UL_USDHC2_IRQ, | ||
864 | + }; | ||
865 | + | ||
866 | + object_property_set_bool(OBJECT(&s->usdhc[i]), true, "realized", | ||
867 | + &error_abort); | ||
868 | + | ||
869 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->usdhc[i]), 0, | ||
870 | + FSL_IMX6UL_USDHCn_ADDR[i]); | ||
871 | + | ||
872 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->usdhc[i]), 0, | ||
873 | + qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
874 | + FSL_IMX6UL_USDHCn_IRQ[i])); | ||
875 | + } | ||
876 | + | ||
877 | + /* | ||
878 | + * SNVS | ||
879 | + */ | ||
880 | + object_property_set_bool(OBJECT(&s->snvs), true, "realized", &error_abort); | ||
881 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->snvs), 0, FSL_IMX6UL_SNVS_HP_ADDR); | ||
882 | + | ||
883 | + /* | ||
884 | + * Watchdog | ||
885 | + */ | ||
886 | + for (i = 0; i < FSL_IMX6UL_NUM_WDTS; i++) { | ||
887 | + static const hwaddr FSL_IMX6UL_WDOGn_ADDR[FSL_IMX6UL_NUM_WDTS] = { | ||
888 | + FSL_IMX6UL_WDOG1_ADDR, | ||
889 | + FSL_IMX6UL_WDOG2_ADDR, | ||
890 | + FSL_IMX6UL_WDOG3_ADDR, | ||
891 | + }; | ||
892 | + | ||
893 | + object_property_set_bool(OBJECT(&s->wdt[i]), true, "realized", | ||
894 | + &error_abort); | ||
895 | + | ||
896 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt[i]), 0, | ||
897 | + FSL_IMX6UL_WDOGn_ADDR[i]); | ||
898 | + } | ||
899 | + | ||
900 | + /* | ||
901 | + * GPR | ||
902 | + */ | ||
903 | + object_property_set_bool(OBJECT(&s->gpr), true, "realized", | ||
904 | + &error_abort); | ||
905 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpr), 0, FSL_IMX6UL_IOMUXC_GPR_ADDR); | ||
906 | + | ||
907 | + /* | ||
908 | + * SDMA | ||
909 | + */ | ||
910 | + create_unimplemented_device("sdma", FSL_IMX6UL_SDMA_ADDR, 0x4000); | ||
911 | + | ||
912 | + /* | ||
913 | + * APHB_DMA | ||
914 | + */ | ||
915 | + create_unimplemented_device("aphb_dma", FSL_IMX6UL_APBH_DMA_ADDR, | ||
916 | + FSL_IMX6UL_APBH_DMA_SIZE); | ||
917 | + | ||
918 | + /* | ||
919 | + * ADCs | ||
920 | + */ | ||
921 | + for (i = 0; i < FSL_IMX6UL_NUM_ADCS; i++) { | ||
922 | + static const hwaddr FSL_IMX6UL_ADCn_ADDR[FSL_IMX6UL_NUM_ADCS] = { | ||
923 | + FSL_IMX6UL_ADC1_ADDR, | ||
924 | + FSL_IMX6UL_ADC2_ADDR, | ||
925 | + }; | ||
926 | + | ||
927 | + snprintf(name, NAME_SIZE, "adc%d", i); | ||
928 | + create_unimplemented_device(name, FSL_IMX6UL_ADCn_ADDR[i], 0x4000); | ||
929 | + } | ||
930 | + | ||
931 | + /* | ||
932 | + * LCD | ||
933 | + */ | ||
934 | + create_unimplemented_device("lcdif", FSL_IMX6UL_LCDIF_ADDR, 0x4000); | ||
935 | + | ||
936 | + /* | ||
937 | + * ROM memory | ||
938 | + */ | ||
939 | + memory_region_init_rom(&s->rom, NULL, "imx6ul.rom", | ||
940 | + FSL_IMX6UL_ROM_SIZE, &error_abort); | ||
941 | + memory_region_add_subregion(get_system_memory(), FSL_IMX6UL_ROM_ADDR, | ||
942 | + &s->rom); | ||
943 | + | ||
944 | + /* | ||
945 | + * CAAM memory | ||
946 | + */ | ||
947 | + memory_region_init_rom(&s->caam, NULL, "imx6ul.caam", | ||
948 | + FSL_IMX6UL_CAAM_MEM_SIZE, &error_abort); | ||
949 | + memory_region_add_subregion(get_system_memory(), FSL_IMX6UL_CAAM_MEM_ADDR, | ||
950 | + &s->caam); | ||
951 | + | ||
952 | + /* | ||
953 | + * OCRAM memory | ||
954 | + */ | ||
955 | + memory_region_init_ram(&s->ocram, NULL, "imx6ul.ocram", | ||
956 | + FSL_IMX6UL_OCRAM_MEM_SIZE, | ||
957 | + &error_abort); | ||
958 | + memory_region_add_subregion(get_system_memory(), FSL_IMX6UL_OCRAM_MEM_ADDR, | ||
959 | + &s->ocram); | ||
960 | + | ||
961 | + /* | ||
962 | + * internal OCRAM (128 KB) is aliased over 512 KB | ||
963 | + */ | ||
964 | + memory_region_init_alias(&s->ocram_alias, NULL, "imx6ul.ocram_alias", | ||
965 | + &s->ocram, 0, FSL_IMX6UL_OCRAM_ALIAS_SIZE); | ||
966 | + memory_region_add_subregion(get_system_memory(), | ||
967 | + FSL_IMX6UL_OCRAM_ALIAS_ADDR, &s->ocram_alias); | ||
968 | +} | 112 | +} |
969 | + | 113 | + |
970 | +static void fsl_imx6ul_class_init(ObjectClass *oc, void *data) | 114 | +static bool trans_VLDR_sysreg(DisasContext *s, arg_vldr_sysreg *a) |
971 | +{ | 115 | +{ |
972 | + DeviceClass *dc = DEVICE_CLASS(oc); | 116 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { |
973 | + | 117 | + return false; |
974 | + dc->realize = fsl_imx6ul_realize; | 118 | + } |
975 | + dc->desc = "i.MX6UL SOC"; | 119 | + if (a->rn == 15) { |
976 | + /* Reason: Uses serial_hds and nd_table in realize() directly */ | 120 | + return false; |
977 | + dc->user_creatable = false; | 121 | + } |
122 | + return gen_M_fp_sysreg_write(s, a->reg, memory_to_fp_sysreg, a); | ||
978 | +} | 123 | +} |
979 | + | 124 | + |
980 | +static const TypeInfo fsl_imx6ul_type_info = { | 125 | +static bool trans_VSTR_sysreg(DisasContext *s, arg_vldr_sysreg *a) |
981 | + .name = TYPE_FSL_IMX6UL, | 126 | +{ |
982 | + .parent = TYPE_DEVICE, | 127 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { |
983 | + .instance_size = sizeof(FslIMX6ULState), | 128 | + return false; |
984 | + .instance_init = fsl_imx6ul_init, | 129 | + } |
985 | + .class_init = fsl_imx6ul_class_init, | 130 | + if (a->rn == 15) { |
986 | +}; | 131 | + return false; |
132 | + } | ||
133 | + return gen_M_fp_sysreg_read(s, a->reg, fp_sysreg_to_memory, a); | ||
134 | +} | ||
987 | + | 135 | + |
988 | +static void fsl_imx6ul_register_types(void) | 136 | static bool trans_VMOV_half(DisasContext *s, arg_VMOV_single *a) |
989 | +{ | 137 | { |
990 | + type_register_static(&fsl_imx6ul_type_info); | 138 | TCGv_i32 tmp; |
991 | +} | ||
992 | +type_init(fsl_imx6ul_register_types) | ||
993 | diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak | ||
994 | index XXXXXXX..XXXXXXX 100644 | ||
995 | --- a/default-configs/arm-softmmu.mak | ||
996 | +++ b/default-configs/arm-softmmu.mak | ||
997 | @@ -XXX,XX +XXX,XX @@ CONFIG_FSL_IMX6=y | ||
998 | CONFIG_FSL_IMX31=y | ||
999 | CONFIG_FSL_IMX25=y | ||
1000 | CONFIG_FSL_IMX7=y | ||
1001 | +CONFIG_FSL_IMX6UL=y | ||
1002 | |||
1003 | CONFIG_IMX_I2C=y | ||
1004 | |||
1005 | -- | 139 | -- |
1006 | 2.18.0 | 140 | 2.20.1 |
1007 | 141 | ||
1008 | 142 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | v8.1M defines a new FP system register FPSCR_nzcvqc; this behaves |
---|---|---|---|
2 | like the existing FPSCR, except that it reads and writes only bits | ||
3 | [31:27] of the FPSCR (the N, Z, C, V and QC flag bits). (Unlike the | ||
4 | FPSCR, the special case for Rt=15 of writing the CPSR.NZCV is not | ||
5 | permitted.) | ||
2 | 6 | ||
3 | When support for FZ16 was added, we failed to include the bit | 7 | Implement the register. Since we don't yet implement MVE, we handle |
4 | within FPCR_MASK, which means that it could never be set. | 8 | the QC bit as RES0, with todo comments for where we will need to add |
5 | Continue to zero FZ16 when ARMv8.2-FP16 is not enabled. | 9 | support later. |
6 | 10 | ||
7 | Fixes: d81ce0ef2c4 | ||
8 | Cc: qemu-stable@nongnu.org (3.0.1) | ||
9 | Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Reviewed-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
12 | Tested-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
13 | Message-id: 20180810193129.1556-2-richard.henderson@linaro.org | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20201119215617.29887-11-peter.maydell@linaro.org | ||
15 | --- | 14 | --- |
16 | target/arm/cpu.h | 2 +- | 15 | target/arm/cpu.h | 13 +++++++++++++ |
17 | target/arm/helper.c | 5 +++++ | 16 | target/arm/translate-vfp.c.inc | 27 +++++++++++++++++++++++++++ |
18 | 2 files changed, 6 insertions(+), 1 deletion(-) | 17 | 2 files changed, 40 insertions(+) |
19 | 18 | ||
20 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 19 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
21 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/cpu.h | 21 | --- a/target/arm/cpu.h |
23 | +++ b/target/arm/cpu.h | 22 | +++ b/target/arm/cpu.h |
24 | @@ -XXX,XX +XXX,XX @@ void vfp_set_fpscr(CPUARMState *env, uint32_t val); | 23 | @@ -XXX,XX +XXX,XX @@ void vfp_set_fpscr(CPUARMState *env, uint32_t val); |
25 | * we store the underlying state in fpscr and just mask on read/write. | ||
26 | */ | ||
27 | #define FPSR_MASK 0xf800009f | ||
28 | -#define FPCR_MASK 0x07f79f00 | ||
29 | +#define FPCR_MASK 0x07ff9f00 | ||
30 | |||
31 | #define FPCR_FZ16 (1 << 19) /* ARMv8.2+, FP16 flush-to-zero */ | ||
32 | #define FPCR_FZ (1 << 24) /* Flush-to-zero enable bit */ | 24 | #define FPCR_FZ (1 << 24) /* Flush-to-zero enable bit */ |
33 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 25 | #define FPCR_DN (1 << 25) /* Default NaN enable bit */ |
26 | #define FPCR_QC (1 << 27) /* Cumulative saturation bit */ | ||
27 | +#define FPCR_V (1 << 28) /* FP overflow flag */ | ||
28 | +#define FPCR_C (1 << 29) /* FP carry flag */ | ||
29 | +#define FPCR_Z (1 << 30) /* FP zero flag */ | ||
30 | +#define FPCR_N (1 << 31) /* FP negative flag */ | ||
31 | + | ||
32 | +#define FPCR_NZCV_MASK (FPCR_N | FPCR_Z | FPCR_C | FPCR_V) | ||
33 | +#define FPCR_NZCVQC_MASK (FPCR_NZCV_MASK | FPCR_QC) | ||
34 | |||
35 | static inline uint32_t vfp_get_fpsr(CPUARMState *env) | ||
36 | { | ||
37 | @@ -XXX,XX +XXX,XX @@ enum arm_cpu_mode { | ||
38 | #define ARM_VFP_FPEXC 8 | ||
39 | #define ARM_VFP_FPINST 9 | ||
40 | #define ARM_VFP_FPINST2 10 | ||
41 | +/* These ones are M-profile only */ | ||
42 | +#define ARM_VFP_FPSCR_NZCVQC 2 | ||
43 | +#define ARM_VFP_VPR 12 | ||
44 | +#define ARM_VFP_P0 13 | ||
45 | +#define ARM_VFP_FPCXT_NS 14 | ||
46 | +#define ARM_VFP_FPCXT_S 15 | ||
47 | |||
48 | /* QEMU-internal value meaning "FPSCR, but we care only about NZCV" */ | ||
49 | #define QEMU_VFP_FPSCR_NZCV 0xffff | ||
50 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc | ||
34 | index XXXXXXX..XXXXXXX 100644 | 51 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/target/arm/helper.c | 52 | --- a/target/arm/translate-vfp.c.inc |
36 | +++ b/target/arm/helper.c | 53 | +++ b/target/arm/translate-vfp.c.inc |
37 | @@ -XXX,XX +XXX,XX @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) | 54 | @@ -XXX,XX +XXX,XX @@ static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno) |
38 | int i; | 55 | case ARM_VFP_FPSCR: |
39 | uint32_t changed; | 56 | case QEMU_VFP_FPSCR_NZCV: |
40 | 57 | break; | |
41 | + /* When ARMv8.2-FP16 is not supported, FZ16 is RES0. */ | 58 | + case ARM_VFP_FPSCR_NZCVQC: |
42 | + if (!arm_feature(env, ARM_FEATURE_V8_FP16)) { | 59 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { |
43 | + val &= ~FPCR_FZ16; | 60 | + return false; |
61 | + } | ||
62 | + break; | ||
63 | default: | ||
64 | return FPSysRegCheckFailed; | ||
65 | } | ||
66 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | ||
67 | tcg_temp_free_i32(tmp); | ||
68 | gen_lookup_tb(s); | ||
69 | break; | ||
70 | + case ARM_VFP_FPSCR_NZCVQC: | ||
71 | + { | ||
72 | + TCGv_i32 fpscr; | ||
73 | + tmp = loadfn(s, opaque); | ||
74 | + /* | ||
75 | + * TODO: when we implement MVE, write the QC bit. | ||
76 | + * For non-MVE, QC is RES0. | ||
77 | + */ | ||
78 | + tcg_gen_andi_i32(tmp, tmp, FPCR_NZCV_MASK); | ||
79 | + fpscr = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]); | ||
80 | + tcg_gen_andi_i32(fpscr, fpscr, ~FPCR_NZCV_MASK); | ||
81 | + tcg_gen_or_i32(fpscr, fpscr, tmp); | ||
82 | + store_cpu_field(fpscr, vfp.xregs[ARM_VFP_FPSCR]); | ||
83 | + tcg_temp_free_i32(tmp); | ||
84 | + break; | ||
44 | + } | 85 | + } |
45 | + | 86 | default: |
46 | changed = env->vfp.xregs[ARM_VFP_FPSCR]; | 87 | g_assert_not_reached(); |
47 | env->vfp.xregs[ARM_VFP_FPSCR] = (val & 0xffc8ffff); | 88 | } |
48 | env->vfp.vec_len = (val >> 16) & 7; | 89 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, |
90 | gen_helper_vfp_get_fpscr(tmp, cpu_env); | ||
91 | storefn(s, opaque, tmp); | ||
92 | break; | ||
93 | + case ARM_VFP_FPSCR_NZCVQC: | ||
94 | + /* | ||
95 | + * TODO: MVE has a QC bit, which we probably won't store | ||
96 | + * in the xregs[] field. For non-MVE, where QC is RES0, | ||
97 | + * we can just fall through to the FPSCR_NZCV case. | ||
98 | + */ | ||
99 | case QEMU_VFP_FPSCR_NZCV: | ||
100 | /* | ||
101 | * Read just NZCV; this is a special case to avoid the | ||
49 | -- | 102 | -- |
50 | 2.18.0 | 103 | 2.20.1 |
51 | 104 | ||
52 | 105 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | We defined a constant name for the mask of NZCV bits in the FPCR/FPSCR |
---|---|---|---|
2 | in the previous commit; use it in a couple of places in existing code, | ||
3 | where we're masking out everything except NZCV for the "load to Rt=15 | ||
4 | sets CPSR.NZCV" special case. | ||
2 | 5 | ||
3 | The SDRAM training routine sets the 'Enable cache initial' bit, and then | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | waits for the 'cache initial sequence' to be done. | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20201119215617.29887-12-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/translate-vfp.c.inc | 4 ++-- | ||
11 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
5 | 12 | ||
6 | Have it always return done, as there is no other side effects that the | 13 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc |
7 | model needs to implement. This allows the upstream u-boot training to | ||
8 | proceed on the ast2500-evb board. | ||
9 | |||
10 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
11 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
12 | Tested-by: Cédric Le Goater <clg@kaod.org> | ||
13 | Message-id: 20180807075757.7242-4-joel@jms.id.au | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | hw/misc/aspeed_sdmc.c | 1 + | ||
17 | 1 file changed, 1 insertion(+) | ||
18 | |||
19 | diff --git a/hw/misc/aspeed_sdmc.c b/hw/misc/aspeed_sdmc.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/misc/aspeed_sdmc.c | 15 | --- a/target/arm/translate-vfp.c.inc |
22 | +++ b/hw/misc/aspeed_sdmc.c | 16 | +++ b/target/arm/translate-vfp.c.inc |
23 | @@ -XXX,XX +XXX,XX @@ static void aspeed_sdmc_realize(DeviceState *dev, Error **errp) | 17 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, |
24 | s->ram_bits = ast2500_rambits(s); | 18 | * helper call for the "VMRS to CPSR.NZCV" insn. |
25 | s->fixed_conf = ASPEED_SDMC_HW_VERSION(1) | | 19 | */ |
26 | ASPEED_SDMC_VGA_APERTURE(ASPEED_SDMC_VGA_64MB) | | 20 | tmp = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]); |
27 | + ASPEED_SDMC_CACHE_INITIAL_DONE | | 21 | - tcg_gen_andi_i32(tmp, tmp, 0xf0000000); |
28 | ASPEED_SDMC_DRAM_SIZE(s->ram_bits); | 22 | + tcg_gen_andi_i32(tmp, tmp, FPCR_NZCV_MASK); |
23 | storefn(s, opaque, tmp); | ||
29 | break; | 24 | break; |
30 | default: | 25 | default: |
26 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMSR_VMRS(DisasContext *s, arg_VMSR_VMRS *a) | ||
27 | case ARM_VFP_FPSCR: | ||
28 | if (a->rt == 15) { | ||
29 | tmp = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]); | ||
30 | - tcg_gen_andi_i32(tmp, tmp, 0xf0000000); | ||
31 | + tcg_gen_andi_i32(tmp, tmp, FPCR_NZCV_MASK); | ||
32 | } else { | ||
33 | tmp = tcg_temp_new_i32(); | ||
34 | gen_helper_vfp_get_fpscr(tmp, cpu_env); | ||
31 | -- | 35 | -- |
32 | 2.18.0 | 36 | 2.20.1 |
33 | 37 | ||
34 | 38 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | Factor out the code which handles M-profile lazy FP state preservation |
---|---|---|---|
2 | from full_vfp_access_check(); accesses to the FPCXT_NS register are | ||
3 | a special case which need to do just this part (corresponding in the | ||
4 | pseudocode to the PreserveFPState() function), and not the full | ||
5 | set of actions matching the pseudocode ExecuteFPCheck() which | ||
6 | normal FP instructions need to do. | ||
2 | 7 | ||
3 | This is required to ensure u-boot SDRAM training completes. | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Message-id: 20201119215617.29887-13-peter.maydell@linaro.org | ||
12 | --- | ||
13 | target/arm/translate-vfp.c.inc | 45 ++++++++++++++++++++-------------- | ||
14 | 1 file changed, 27 insertions(+), 18 deletions(-) | ||
4 | 15 | ||
5 | Signed-off-by: Joel Stanley <joel@jms.id.au> | 16 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc |
6 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
7 | Tested-by: Cédric Le Goater <clg@kaod.org> | ||
8 | Message-id: 20180807075757.7242-6-joel@jms.id.au | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/misc/aspeed_sdmc.c | 9 +++++++++ | ||
12 | 1 file changed, 9 insertions(+) | ||
13 | |||
14 | diff --git a/hw/misc/aspeed_sdmc.c b/hw/misc/aspeed_sdmc.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/misc/aspeed_sdmc.c | 18 | --- a/target/arm/translate-vfp.c.inc |
17 | +++ b/hw/misc/aspeed_sdmc.c | 19 | +++ b/target/arm/translate-vfp.c.inc |
18 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ static inline long vfp_f16_offset(unsigned reg, bool top) |
19 | #define R_STATUS1 (0x60 / 4) | 21 | return offs; |
20 | #define PHY_BUSY_STATE BIT(0) | 22 | } |
21 | 23 | ||
22 | +#define R_ECC_TEST_CTRL (0x70 / 4) | 24 | +/* |
23 | +#define ECC_TEST_FINISHED BIT(12) | 25 | + * Generate code for M-profile lazy FP state preservation if needed; |
24 | +#define ECC_TEST_FAIL BIT(13) | 26 | + * this corresponds to the pseudocode PreserveFPState() function. |
27 | + */ | ||
28 | +static void gen_preserve_fp_state(DisasContext *s) | ||
29 | +{ | ||
30 | + if (s->v7m_lspact) { | ||
31 | + /* | ||
32 | + * Lazy state saving affects external memory and also the NVIC, | ||
33 | + * so we must mark it as an IO operation for icount (and cause | ||
34 | + * this to be the last insn in the TB). | ||
35 | + */ | ||
36 | + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { | ||
37 | + s->base.is_jmp = DISAS_UPDATE_EXIT; | ||
38 | + gen_io_start(); | ||
39 | + } | ||
40 | + gen_helper_v7m_preserve_fp_state(cpu_env); | ||
41 | + /* | ||
42 | + * If the preserve_fp_state helper doesn't throw an exception | ||
43 | + * then it will clear LSPACT; we don't need to repeat this for | ||
44 | + * any further FP insns in this TB. | ||
45 | + */ | ||
46 | + s->v7m_lspact = false; | ||
47 | + } | ||
48 | +} | ||
25 | + | 49 | + |
26 | /* | 50 | /* |
27 | * Configuration register Ox4 (for Aspeed AST2400 SOC) | 51 | * Check that VFP access is enabled. If it is, do the necessary |
28 | * | 52 | * M-profile lazy-FP handling and then return true. |
29 | @@ -XXX,XX +XXX,XX @@ static void aspeed_sdmc_write(void *opaque, hwaddr addr, uint64_t data, | 53 | @@ -XXX,XX +XXX,XX @@ static bool full_vfp_access_check(DisasContext *s, bool ignore_vfp_enabled) |
30 | /* Will never return 'busy' */ | 54 | /* Handle M-profile lazy FP state mechanics */ |
31 | data &= ~PHY_BUSY_STATE; | 55 | |
32 | break; | 56 | /* Trigger lazy-state preservation if necessary */ |
33 | + case R_ECC_TEST_CTRL: | 57 | - if (s->v7m_lspact) { |
34 | + /* Always done, always happy */ | 58 | - /* |
35 | + data |= ECC_TEST_FINISHED; | 59 | - * Lazy state saving affects external memory and also the NVIC, |
36 | + data &= ~ECC_TEST_FAIL; | 60 | - * so we must mark it as an IO operation for icount (and cause |
37 | + break; | 61 | - * this to be the last insn in the TB). |
38 | default: | 62 | - */ |
39 | break; | 63 | - if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { |
40 | } | 64 | - s->base.is_jmp = DISAS_UPDATE_EXIT; |
65 | - gen_io_start(); | ||
66 | - } | ||
67 | - gen_helper_v7m_preserve_fp_state(cpu_env); | ||
68 | - /* | ||
69 | - * If the preserve_fp_state helper doesn't throw an exception | ||
70 | - * then it will clear LSPACT; we don't need to repeat this for | ||
71 | - * any further FP insns in this TB. | ||
72 | - */ | ||
73 | - s->v7m_lspact = false; | ||
74 | - } | ||
75 | + gen_preserve_fp_state(s); | ||
76 | |||
77 | /* Update ownership of FP context: set FPCCR.S to match current state */ | ||
78 | if (s->v8m_fpccr_s_wrong) { | ||
41 | -- | 79 | -- |
42 | 2.18.0 | 80 | 2.20.1 |
43 | 81 | ||
44 | 82 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | Implement the new-in-v8.1M FPCXT_S floating point system register. |
---|---|---|---|
2 | This is for saving and restoring the secure floating point context, | ||
3 | and it reads and writes bits [27:0] from the FPSCR and the | ||
4 | CONTROL.SFPA bit in bit [31]. | ||
2 | 5 | ||
3 | This fixes the intended protection of read-only values in the | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | configuration register. They were being always set to zero by mistake. | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20201119215617.29887-14-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/translate-vfp.c.inc | 58 ++++++++++++++++++++++++++++++++++ | ||
11 | 1 file changed, 58 insertions(+) | ||
5 | 12 | ||
6 | The read-only fields depend on the configured memory size of the system, | 13 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc |
7 | so they cannot be fixed at compile time. The most straight forward | ||
8 | option was to store them in the state structure. | ||
9 | |||
10 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
11 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
12 | Tested-by: Cédric Le Goater <clg@kaod.org> | ||
13 | Message-id: 20180807075757.7242-3-joel@jms.id.au | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | include/hw/misc/aspeed_sdmc.h | 1 + | ||
17 | hw/misc/aspeed_sdmc.c | 27 ++++++++------------------- | ||
18 | 2 files changed, 9 insertions(+), 19 deletions(-) | ||
19 | |||
20 | diff --git a/include/hw/misc/aspeed_sdmc.h b/include/hw/misc/aspeed_sdmc.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/hw/misc/aspeed_sdmc.h | 15 | --- a/target/arm/translate-vfp.c.inc |
23 | +++ b/include/hw/misc/aspeed_sdmc.h | 16 | +++ b/target/arm/translate-vfp.c.inc |
24 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSDMCState { | 17 | @@ -XXX,XX +XXX,XX @@ static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno) |
25 | uint32_t silicon_rev; | 18 | return false; |
26 | uint32_t ram_bits; | 19 | } |
27 | uint64_t ram_size; | ||
28 | + uint32_t fixed_conf; | ||
29 | |||
30 | } AspeedSDMCState; | ||
31 | |||
32 | diff --git a/hw/misc/aspeed_sdmc.c b/hw/misc/aspeed_sdmc.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/hw/misc/aspeed_sdmc.c | ||
35 | +++ b/hw/misc/aspeed_sdmc.c | ||
36 | @@ -XXX,XX +XXX,XX @@ static void aspeed_sdmc_write(void *opaque, hwaddr addr, uint64_t data, | ||
37 | case AST2400_A0_SILICON_REV: | ||
38 | case AST2400_A1_SILICON_REV: | ||
39 | data &= ~ASPEED_SDMC_READONLY_MASK; | ||
40 | + data |= s->fixed_conf; | ||
41 | break; | ||
42 | case AST2500_A0_SILICON_REV: | ||
43 | case AST2500_A1_SILICON_REV: | ||
44 | data &= ~ASPEED_SDMC_AST2500_READONLY_MASK; | ||
45 | + data |= s->fixed_conf; | ||
46 | break; | ||
47 | default: | ||
48 | g_assert_not_reached(); | ||
49 | @@ -XXX,XX +XXX,XX @@ static void aspeed_sdmc_reset(DeviceState *dev) | ||
50 | memset(s->regs, 0, sizeof(s->regs)); | ||
51 | |||
52 | /* Set ram size bit and defaults values */ | ||
53 | - switch (s->silicon_rev) { | ||
54 | - case AST2400_A0_SILICON_REV: | ||
55 | - case AST2400_A1_SILICON_REV: | ||
56 | - s->regs[R_CONF] |= | ||
57 | - ASPEED_SDMC_VGA_COMPAT | | ||
58 | - ASPEED_SDMC_DRAM_SIZE(s->ram_bits); | ||
59 | - break; | ||
60 | - | ||
61 | - case AST2500_A0_SILICON_REV: | ||
62 | - case AST2500_A1_SILICON_REV: | ||
63 | - s->regs[R_CONF] |= | ||
64 | - ASPEED_SDMC_HW_VERSION(1) | | ||
65 | - ASPEED_SDMC_VGA_APERTURE(ASPEED_SDMC_VGA_64MB) | | ||
66 | - ASPEED_SDMC_DRAM_SIZE(s->ram_bits); | ||
67 | - break; | ||
68 | - | ||
69 | - default: | ||
70 | - g_assert_not_reached(); | ||
71 | - } | ||
72 | + s->regs[R_CONF] = s->fixed_conf; | ||
73 | } | ||
74 | |||
75 | static void aspeed_sdmc_realize(DeviceState *dev, Error **errp) | ||
76 | @@ -XXX,XX +XXX,XX @@ static void aspeed_sdmc_realize(DeviceState *dev, Error **errp) | ||
77 | case AST2400_A0_SILICON_REV: | ||
78 | case AST2400_A1_SILICON_REV: | ||
79 | s->ram_bits = ast2400_rambits(s); | ||
80 | + s->fixed_conf = ASPEED_SDMC_VGA_COMPAT | | ||
81 | + ASPEED_SDMC_DRAM_SIZE(s->ram_bits); | ||
82 | break; | 20 | break; |
83 | case AST2500_A0_SILICON_REV: | 21 | + case ARM_VFP_FPCXT_S: |
84 | case AST2500_A1_SILICON_REV: | 22 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { |
85 | s->ram_bits = ast2500_rambits(s); | 23 | + return false; |
86 | + s->fixed_conf = ASPEED_SDMC_HW_VERSION(1) | | 24 | + } |
87 | + ASPEED_SDMC_VGA_APERTURE(ASPEED_SDMC_VGA_64MB) | | 25 | + if (!s->v8m_secure) { |
88 | + ASPEED_SDMC_DRAM_SIZE(s->ram_bits); | 26 | + return false; |
27 | + } | ||
28 | + break; | ||
29 | default: | ||
30 | return FPSysRegCheckFailed; | ||
31 | } | ||
32 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | ||
33 | tcg_temp_free_i32(tmp); | ||
89 | break; | 34 | break; |
35 | } | ||
36 | + case ARM_VFP_FPCXT_S: | ||
37 | + { | ||
38 | + TCGv_i32 sfpa, control, fpscr; | ||
39 | + /* Set FPSCR[27:0] and CONTROL.SFPA from value */ | ||
40 | + tmp = loadfn(s, opaque); | ||
41 | + sfpa = tcg_temp_new_i32(); | ||
42 | + tcg_gen_shri_i32(sfpa, tmp, 31); | ||
43 | + control = load_cpu_field(v7m.control[M_REG_S]); | ||
44 | + tcg_gen_deposit_i32(control, control, sfpa, | ||
45 | + R_V7M_CONTROL_SFPA_SHIFT, 1); | ||
46 | + store_cpu_field(control, v7m.control[M_REG_S]); | ||
47 | + fpscr = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]); | ||
48 | + tcg_gen_andi_i32(fpscr, fpscr, FPCR_NZCV_MASK); | ||
49 | + tcg_gen_andi_i32(tmp, tmp, ~FPCR_NZCV_MASK); | ||
50 | + tcg_gen_or_i32(fpscr, fpscr, tmp); | ||
51 | + store_cpu_field(fpscr, vfp.xregs[ARM_VFP_FPSCR]); | ||
52 | + tcg_temp_free_i32(tmp); | ||
53 | + tcg_temp_free_i32(sfpa); | ||
54 | + break; | ||
55 | + } | ||
90 | default: | 56 | default: |
91 | g_assert_not_reached(); | 57 | g_assert_not_reached(); |
58 | } | ||
59 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, | ||
60 | tcg_gen_andi_i32(tmp, tmp, FPCR_NZCV_MASK); | ||
61 | storefn(s, opaque, tmp); | ||
62 | break; | ||
63 | + case ARM_VFP_FPCXT_S: | ||
64 | + { | ||
65 | + TCGv_i32 control, sfpa, fpscr; | ||
66 | + /* Bits [27:0] from FPSCR, bit [31] from CONTROL.SFPA */ | ||
67 | + tmp = tcg_temp_new_i32(); | ||
68 | + sfpa = tcg_temp_new_i32(); | ||
69 | + gen_helper_vfp_get_fpscr(tmp, cpu_env); | ||
70 | + tcg_gen_andi_i32(tmp, tmp, ~FPCR_NZCV_MASK); | ||
71 | + control = load_cpu_field(v7m.control[M_REG_S]); | ||
72 | + tcg_gen_andi_i32(sfpa, control, R_V7M_CONTROL_SFPA_MASK); | ||
73 | + tcg_gen_shli_i32(sfpa, sfpa, 31 - R_V7M_CONTROL_SFPA_SHIFT); | ||
74 | + tcg_gen_or_i32(tmp, tmp, sfpa); | ||
75 | + tcg_temp_free_i32(sfpa); | ||
76 | + /* | ||
77 | + * Store result before updating FPSCR etc, in case | ||
78 | + * it is a memory write which causes an exception. | ||
79 | + */ | ||
80 | + storefn(s, opaque, tmp); | ||
81 | + /* | ||
82 | + * Now we must reset FPSCR from FPDSCR_NS, and clear | ||
83 | + * CONTROL.SFPA; so we'll end the TB here. | ||
84 | + */ | ||
85 | + tcg_gen_andi_i32(control, control, ~R_V7M_CONTROL_SFPA_MASK); | ||
86 | + store_cpu_field(control, v7m.control[M_REG_S]); | ||
87 | + fpscr = load_cpu_field(v7m.fpdscr[M_REG_NS]); | ||
88 | + gen_helper_vfp_set_fpscr(cpu_env, fpscr); | ||
89 | + tcg_temp_free_i32(fpscr); | ||
90 | + gen_lookup_tb(s); | ||
91 | + break; | ||
92 | + } | ||
93 | default: | ||
94 | g_assert_not_reached(); | ||
95 | } | ||
92 | -- | 96 | -- |
93 | 2.18.0 | 97 | 2.20.1 |
94 | 98 | ||
95 | 99 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | The FPDSCR register has a similar layout to the FPSCR. In v8.1M it |
---|---|---|---|
2 | gains new fields FZ16 (if half-precision floating point is supported) | ||
3 | and LTPSIZE (always reads as 4). Update the reset value and the code | ||
4 | that handles writes to this register accordingly. | ||
2 | 5 | ||
3 | This allows the default (and maximum) vector length to be set | ||
4 | from the command-line. Which is extraordinarily helpful in | ||
5 | debugging problems depending on vector length without having to | ||
6 | bake knowledge of PR_SET_SVE_VL into every guest binary. | ||
7 | |||
8 | Cc: qemu-stable@nongnu.org (3.0.1) | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
11 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20201119215617.29887-16-peter.maydell@linaro.org | ||
13 | --- | 9 | --- |
14 | target/arm/cpu.h | 3 +++ | 10 | target/arm/cpu.h | 5 +++++ |
15 | linux-user/syscall.c | 19 +++++++++++++------ | 11 | hw/intc/armv7m_nvic.c | 9 ++++++++- |
16 | target/arm/cpu.c | 6 +++--- | 12 | target/arm/cpu.c | 3 +++ |
17 | target/arm/cpu64.c | 29 +++++++++++++++++++++++++++++ | 13 | 3 files changed, 16 insertions(+), 1 deletion(-) |
18 | target/arm/helper.c | 7 +++++-- | ||
19 | 5 files changed, 53 insertions(+), 11 deletions(-) | ||
20 | 14 | ||
21 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
22 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/target/arm/cpu.h | 17 | --- a/target/arm/cpu.h |
24 | +++ b/target/arm/cpu.h | 18 | +++ b/target/arm/cpu.h |
25 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | 19 | @@ -XXX,XX +XXX,XX @@ void vfp_set_fpscr(CPUARMState *env, uint32_t val); |
26 | 20 | #define FPCR_IXE (1 << 12) /* Inexact exception trap enable */ | |
27 | /* Used to synchronize KVM and QEMU in-kernel device levels */ | 21 | #define FPCR_IDE (1 << 15) /* Input Denormal exception trap enable */ |
28 | uint8_t device_irq_level; | 22 | #define FPCR_FZ16 (1 << 19) /* ARMv8.2+, FP16 flush-to-zero */ |
23 | +#define FPCR_RMODE_MASK (3 << 22) /* Rounding mode */ | ||
24 | #define FPCR_FZ (1 << 24) /* Flush-to-zero enable bit */ | ||
25 | #define FPCR_DN (1 << 25) /* Default NaN enable bit */ | ||
26 | +#define FPCR_AHP (1 << 26) /* Alternative half-precision */ | ||
27 | #define FPCR_QC (1 << 27) /* Cumulative saturation bit */ | ||
28 | #define FPCR_V (1 << 28) /* FP overflow flag */ | ||
29 | #define FPCR_C (1 << 29) /* FP carry flag */ | ||
30 | #define FPCR_Z (1 << 30) /* FP zero flag */ | ||
31 | #define FPCR_N (1 << 31) /* FP negative flag */ | ||
32 | |||
33 | +#define FPCR_LTPSIZE_SHIFT 16 /* LTPSIZE, M-profile only */ | ||
34 | +#define FPCR_LTPSIZE_MASK (7 << FPCR_LTPSIZE_SHIFT) | ||
29 | + | 35 | + |
30 | + /* Used to set the maximum vector length the cpu will support. */ | 36 | #define FPCR_NZCV_MASK (FPCR_N | FPCR_Z | FPCR_C | FPCR_V) |
31 | + uint32_t sve_max_vq; | 37 | #define FPCR_NZCVQC_MASK (FPCR_NZCV_MASK | FPCR_QC) |
32 | }; | 38 | |
33 | 39 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | |
34 | static inline ARMCPU *arm_env_get_cpu(CPUARMState *env) | ||
35 | diff --git a/linux-user/syscall.c b/linux-user/syscall.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | 40 | index XXXXXXX..XXXXXXX 100644 |
37 | --- a/linux-user/syscall.c | 41 | --- a/hw/intc/armv7m_nvic.c |
38 | +++ b/linux-user/syscall.c | 42 | +++ b/hw/intc/armv7m_nvic.c |
39 | @@ -XXX,XX +XXX,XX @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, | 43 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, |
40 | #endif | 44 | break; |
41 | #ifdef TARGET_AARCH64 | 45 | case 0xf3c: /* FPDSCR */ |
42 | case TARGET_PR_SVE_SET_VL: | 46 | if (cpu_isar_feature(aa32_vfp_simd, cpu)) { |
43 | - /* We cannot support either PR_SVE_SET_VL_ONEXEC | 47 | - value &= 0x07c00000; |
44 | - or PR_SVE_VL_INHERIT. Therefore, anything above | 48 | + uint32_t mask = FPCR_AHP | FPCR_DN | FPCR_FZ | FPCR_RMODE_MASK; |
45 | - ARM_MAX_VQ results in EINVAL. */ | 49 | + if (cpu_isar_feature(any_fp16, cpu)) { |
46 | + /* | 50 | + mask |= FPCR_FZ16; |
47 | + * We cannot support either PR_SVE_SET_VL_ONEXEC or | 51 | + } |
48 | + * PR_SVE_VL_INHERIT. Note the kernel definition | 52 | + value &= mask; |
49 | + * of sve_vl_valid allows for VQ=512, i.e. VL=8192, | 53 | + if (cpu_isar_feature(aa32_lob, cpu)) { |
50 | + * even though the current architectural maximum is VQ=16. | 54 | + value |= 4 << FPCR_LTPSIZE_SHIFT; |
51 | + */ | 55 | + } |
52 | ret = -TARGET_EINVAL; | 56 | cpu->env.v7m.fpdscr[attrs.secure] = value; |
53 | if (arm_feature(cpu_env, ARM_FEATURE_SVE) | 57 | } |
54 | - && arg2 >= 0 && arg2 <= ARM_MAX_VQ * 16 && !(arg2 & 15)) { | 58 | break; |
55 | + && arg2 >= 0 && arg2 <= 512 * 16 && !(arg2 & 15)) { | ||
56 | CPUARMState *env = cpu_env; | ||
57 | - int old_vq = (env->vfp.zcr_el[1] & 0xf) + 1; | ||
58 | - int vq = MAX(arg2 / 16, 1); | ||
59 | + ARMCPU *cpu = arm_env_get_cpu(env); | ||
60 | + uint32_t vq, old_vq; | ||
61 | + | ||
62 | + old_vq = (env->vfp.zcr_el[1] & 0xf) + 1; | ||
63 | + vq = MAX(arg2 / 16, 1); | ||
64 | + vq = MIN(vq, cpu->sve_max_vq); | ||
65 | |||
66 | if (vq < old_vq) { | ||
67 | aarch64_sve_narrow_vq(env, vq); | ||
68 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 59 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
69 | index XXXXXXX..XXXXXXX 100644 | 60 | index XXXXXXX..XXXXXXX 100644 |
70 | --- a/target/arm/cpu.c | 61 | --- a/target/arm/cpu.c |
71 | +++ b/target/arm/cpu.c | 62 | +++ b/target/arm/cpu.c |
72 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(CPUState *s) | 63 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev) |
73 | env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 16, 2, 3); | 64 | * always reset to 4. |
74 | env->cp15.cptr_el[3] |= CPTR_EZ; | 65 | */ |
75 | /* with maximum vector length */ | 66 | env->v7m.ltpsize = 4; |
76 | - env->vfp.zcr_el[1] = ARM_MAX_VQ - 1; | 67 | + /* The LTPSIZE field in FPDSCR is constant and reads as 4. */ |
77 | - env->vfp.zcr_el[2] = ARM_MAX_VQ - 1; | 68 | + env->v7m.fpdscr[M_REG_NS] = 4 << FPCR_LTPSIZE_SHIFT; |
78 | - env->vfp.zcr_el[3] = ARM_MAX_VQ - 1; | 69 | + env->v7m.fpdscr[M_REG_S] = 4 << FPCR_LTPSIZE_SHIFT; |
79 | + env->vfp.zcr_el[1] = cpu->sve_max_vq - 1; | 70 | } |
80 | + env->vfp.zcr_el[2] = env->vfp.zcr_el[1]; | 71 | |
81 | + env->vfp.zcr_el[3] = env->vfp.zcr_el[1]; | 72 | if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { |
82 | #else | ||
83 | /* Reset into the highest available EL */ | ||
84 | if (arm_feature(env, ARM_FEATURE_EL3)) { | ||
85 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
86 | index XXXXXXX..XXXXXXX 100644 | ||
87 | --- a/target/arm/cpu64.c | ||
88 | +++ b/target/arm/cpu64.c | ||
89 | @@ -XXX,XX +XXX,XX @@ | ||
90 | #include "sysemu/sysemu.h" | ||
91 | #include "sysemu/kvm.h" | ||
92 | #include "kvm_arm.h" | ||
93 | +#include "qapi/visitor.h" | ||
94 | |||
95 | static inline void set_feature(CPUARMState *env, int feature) | ||
96 | { | ||
97 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a53_initfn(Object *obj) | ||
98 | define_arm_cp_regs(cpu, cortex_a57_a53_cp_reginfo); | ||
99 | } | ||
100 | |||
101 | +static void cpu_max_get_sve_vq(Object *obj, Visitor *v, const char *name, | ||
102 | + void *opaque, Error **errp) | ||
103 | +{ | ||
104 | + ARMCPU *cpu = ARM_CPU(obj); | ||
105 | + visit_type_uint32(v, name, &cpu->sve_max_vq, errp); | ||
106 | +} | ||
107 | + | ||
108 | +static void cpu_max_set_sve_vq(Object *obj, Visitor *v, const char *name, | ||
109 | + void *opaque, Error **errp) | ||
110 | +{ | ||
111 | + ARMCPU *cpu = ARM_CPU(obj); | ||
112 | + Error *err = NULL; | ||
113 | + | ||
114 | + visit_type_uint32(v, name, &cpu->sve_max_vq, &err); | ||
115 | + | ||
116 | + if (!err && (cpu->sve_max_vq == 0 || cpu->sve_max_vq > ARM_MAX_VQ)) { | ||
117 | + error_setg(&err, "unsupported SVE vector length"); | ||
118 | + error_append_hint(&err, "Valid sve-max-vq in range [1-%d]\n", | ||
119 | + ARM_MAX_VQ); | ||
120 | + } | ||
121 | + error_propagate(errp, err); | ||
122 | +} | ||
123 | + | ||
124 | /* -cpu max: if KVM is enabled, like -cpu host (best possible with this host); | ||
125 | * otherwise, a CPU with as many features enabled as our emulation supports. | ||
126 | * The version of '-cpu max' for qemu-system-arm is defined in cpu.c; | ||
127 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
128 | cpu->ctr = 0x80038003; /* 32 byte I and D cacheline size, VIPT icache */ | ||
129 | cpu->dcz_blocksize = 7; /* 512 bytes */ | ||
130 | #endif | ||
131 | + | ||
132 | + cpu->sve_max_vq = ARM_MAX_VQ; | ||
133 | + object_property_add(obj, "sve-max-vq", "uint32", cpu_max_get_sve_vq, | ||
134 | + cpu_max_set_sve_vq, NULL, NULL, &error_fatal); | ||
135 | } | ||
136 | } | ||
137 | |||
138 | @@ -XXX,XX +XXX,XX @@ void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq) | ||
139 | uint64_t pmask; | ||
140 | |||
141 | assert(vq >= 1 && vq <= ARM_MAX_VQ); | ||
142 | + assert(vq <= arm_env_get_cpu(env)->sve_max_vq); | ||
143 | |||
144 | /* Zap the high bits of the zregs. */ | ||
145 | for (i = 0; i < 32; i++) { | ||
146 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
147 | index XXXXXXX..XXXXXXX 100644 | ||
148 | --- a/target/arm/helper.c | ||
149 | +++ b/target/arm/helper.c | ||
150 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
151 | zcr_len = 0; | ||
152 | } else { | ||
153 | int current_el = arm_current_el(env); | ||
154 | + ARMCPU *cpu = arm_env_get_cpu(env); | ||
155 | |||
156 | - zcr_len = env->vfp.zcr_el[current_el <= 1 ? 1 : current_el]; | ||
157 | - zcr_len &= 0xf; | ||
158 | + zcr_len = cpu->sve_max_vq - 1; | ||
159 | + if (current_el <= 1) { | ||
160 | + zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[1]); | ||
161 | + } | ||
162 | if (current_el < 2 && arm_feature(env, ARM_FEATURE_EL2)) { | ||
163 | zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[2]); | ||
164 | } | ||
165 | -- | 73 | -- |
166 | 2.18.0 | 74 | 2.20.1 |
167 | 75 | ||
168 | 76 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | In v8.0M, on exception entry the registers R0-R3, R12, APSR and EPSR | ||
2 | are zeroed for an exception taken to Non-secure state; for an | ||
3 | exception taken to Secure state they become UNKNOWN, and we chose to | ||
4 | leave them at their previous values. | ||
1 | 5 | ||
6 | In v8.1M the behaviour is specified more tightly and these registers | ||
7 | are always zeroed regardless of the security state that the exception | ||
8 | targets (see rule R_KPZV). Implement this. | ||
9 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20201119215617.29887-17-peter.maydell@linaro.org | ||
13 | --- | ||
14 | target/arm/m_helper.c | 16 ++++++++++++---- | ||
15 | 1 file changed, 12 insertions(+), 4 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/m_helper.c | ||
20 | +++ b/target/arm/m_helper.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
22 | * Clear registers if necessary to prevent non-secure exception | ||
23 | * code being able to see register values from secure code. | ||
24 | * Where register values become architecturally UNKNOWN we leave | ||
25 | - * them with their previous values. | ||
26 | + * them with their previous values. v8.1M is tighter than v8.0M | ||
27 | + * here and always zeroes the caller-saved registers regardless | ||
28 | + * of the security state the exception is targeting. | ||
29 | */ | ||
30 | if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
31 | - if (!targets_secure) { | ||
32 | + if (!targets_secure || arm_feature(env, ARM_FEATURE_V8_1M)) { | ||
33 | /* | ||
34 | * Always clear the caller-saved registers (they have been | ||
35 | * pushed to the stack earlier in v7m_push_stack()). | ||
36 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
37 | * v7m_push_callee_stack()). | ||
38 | */ | ||
39 | int i; | ||
40 | + /* | ||
41 | + * r4..r11 are callee-saves, zero only if background | ||
42 | + * state was Secure (EXCRET.S == 1) and exception | ||
43 | + * targets Non-secure state | ||
44 | + */ | ||
45 | + bool zero_callee_saves = !targets_secure && | ||
46 | + (lr & R_V7M_EXCRET_S_MASK); | ||
47 | |||
48 | for (i = 0; i < 13; i++) { | ||
49 | - /* r4..r11 are callee-saves, zero only if EXCRET.S == 1 */ | ||
50 | - if (i < 4 || i > 11 || (lr & R_V7M_EXCRET_S_MASK)) { | ||
51 | + if (i < 4 || i > 11 || zero_callee_saves) { | ||
52 | env->regs[i] = 0; | ||
53 | } | ||
54 | } | ||
55 | -- | ||
56 | 2.20.1 | ||
57 | |||
58 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | In v8.1M, vector table fetch failures don't set HFSR.FORCED (see rule | ||
2 | R_LLRP). (In previous versions of the architecture this was either | ||
3 | required or IMPDEF.) | ||
1 | 4 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20201119215617.29887-18-peter.maydell@linaro.org | ||
8 | --- | ||
9 | target/arm/m_helper.c | 6 +++++- | ||
10 | 1 file changed, 5 insertions(+), 1 deletion(-) | ||
11 | |||
12 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/m_helper.c | ||
15 | +++ b/target/arm/m_helper.c | ||
16 | @@ -XXX,XX +XXX,XX @@ load_fail: | ||
17 | * The HardFault is Secure if BFHFNMINS is 0 (meaning that all HFs are | ||
18 | * secure); otherwise it targets the same security state as the | ||
19 | * underlying exception. | ||
20 | + * In v8.1M HardFaults from vector table fetch fails don't set FORCED. | ||
21 | */ | ||
22 | if (!(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) { | ||
23 | exc_secure = true; | ||
24 | } | ||
25 | - env->v7m.hfsr |= R_V7M_HFSR_VECTTBL_MASK | R_V7M_HFSR_FORCED_MASK; | ||
26 | + env->v7m.hfsr |= R_V7M_HFSR_VECTTBL_MASK; | ||
27 | + if (!arm_feature(env, ARM_FEATURE_V8_1M)) { | ||
28 | + env->v7m.hfsr |= R_V7M_HFSR_FORCED_MASK; | ||
29 | + } | ||
30 | armv7m_nvic_set_pending_derived(env->nvic, ARMV7M_EXCP_HARD, exc_secure); | ||
31 | return false; | ||
32 | } | ||
33 | -- | ||
34 | 2.20.1 | ||
35 | |||
36 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | In v8.1M a REVIDR register is defined, which is at address 0xe00ecfc | ||
2 | and is a read-only IMPDEF register providing implementation specific | ||
3 | minor revision information, like the v8A REVIDR_EL1. Implement this. | ||
1 | 4 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20201119215617.29887-19-peter.maydell@linaro.org | ||
8 | --- | ||
9 | hw/intc/armv7m_nvic.c | 5 +++++ | ||
10 | 1 file changed, 5 insertions(+) | ||
11 | |||
12 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/hw/intc/armv7m_nvic.c | ||
15 | +++ b/hw/intc/armv7m_nvic.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | ||
17 | } | ||
18 | return val; | ||
19 | } | ||
20 | + case 0xcfc: | ||
21 | + if (!arm_feature(&cpu->env, ARM_FEATURE_V8_1M)) { | ||
22 | + goto bad_offset; | ||
23 | + } | ||
24 | + return cpu->revidr; | ||
25 | case 0xd00: /* CPUID Base. */ | ||
26 | return cpu->midr; | ||
27 | case 0xd04: /* Interrupt Control State (ICSR) */ | ||
28 | -- | ||
29 | 2.20.1 | ||
30 | |||
31 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | In v8.1M a new exception return check is added which may cause a NOCP | ||
2 | UsageFault (see rule R_XLTP): before we clear s0..s15 and the FPSCR | ||
3 | we must check whether access to CP10 from the Security state of the | ||
4 | returning exception is disabled; if it is then we must take a fault. | ||
1 | 5 | ||
6 | (Note that for our implementation CPPWR is always RAZ/WI and so can | ||
7 | never cause CP10 accesses to fail.) | ||
8 | |||
9 | The other v8.1M change to this register-clearing code is that if MVE | ||
10 | is implemented VPR must also be cleared, so add a TODO comment to | ||
11 | that effect. | ||
12 | |||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Message-id: 20201119215617.29887-20-peter.maydell@linaro.org | ||
16 | --- | ||
17 | target/arm/m_helper.c | 22 +++++++++++++++++++++- | ||
18 | 1 file changed, 21 insertions(+), 1 deletion(-) | ||
19 | |||
20 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/target/arm/m_helper.c | ||
23 | +++ b/target/arm/m_helper.c | ||
24 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
25 | v7m_exception_taken(cpu, excret, true, false); | ||
26 | return; | ||
27 | } else { | ||
28 | - /* Clear s0..s15 and FPSCR */ | ||
29 | + if (arm_feature(env, ARM_FEATURE_V8_1M)) { | ||
30 | + /* v8.1M adds this NOCP check */ | ||
31 | + bool nsacr_pass = exc_secure || | ||
32 | + extract32(env->v7m.nsacr, 10, 1); | ||
33 | + bool cpacr_pass = v7m_cpacr_pass(env, exc_secure, true); | ||
34 | + if (!nsacr_pass) { | ||
35 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, true); | ||
36 | + env->v7m.cfsr[M_REG_S] |= R_V7M_CFSR_NOCP_MASK; | ||
37 | + qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing " | ||
38 | + "stackframe: NSACR prevents clearing FPU registers\n"); | ||
39 | + v7m_exception_taken(cpu, excret, true, false); | ||
40 | + } else if (!cpacr_pass) { | ||
41 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, | ||
42 | + exc_secure); | ||
43 | + env->v7m.cfsr[exc_secure] |= R_V7M_CFSR_NOCP_MASK; | ||
44 | + qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing " | ||
45 | + "stackframe: CPACR prevents clearing FPU registers\n"); | ||
46 | + v7m_exception_taken(cpu, excret, true, false); | ||
47 | + } | ||
48 | + } | ||
49 | + /* Clear s0..s15 and FPSCR; TODO also VPR when MVE is implemented */ | ||
50 | int i; | ||
51 | |||
52 | for (i = 0; i < 16; i += 2) { | ||
53 | -- | ||
54 | 2.20.1 | ||
55 | |||
56 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | v8.1M adds new encodings of VLLDM and VLSTM (where bit 7 is set). |
---|---|---|---|
2 | The only difference is that: | ||
3 | * the old T1 encodings UNDEF if the implementation implements 32 | ||
4 | Dregs (this is currently architecturally impossible for M-profile) | ||
5 | * the new T2 encodings have the implementation-defined option to | ||
6 | read from memory (discarding the data) or write UNKNOWN values to | ||
7 | memory for the stack slots that would be D16-D31 | ||
2 | 8 | ||
3 | The ast2500 SDRAM training routine busy waits on the 'init cycle busy | 9 | We choose not to make those accesses, so for us the two |
4 | state' bit in DDR PHY Control/Status register #1 (MCR60). | 10 | instructions behave identically assuming they don't UNDEF. |
5 | 11 | ||
6 | This ensures the bit always reads zero, and allows training to | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | complete with upstream u-boot on the ast2500-evb. | 13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
14 | Message-id: 20201119215617.29887-21-peter.maydell@linaro.org | ||
15 | --- | ||
16 | target/arm/m-nocp.decode | 2 +- | ||
17 | target/arm/translate-vfp.c.inc | 25 +++++++++++++++++++++++++ | ||
18 | 2 files changed, 26 insertions(+), 1 deletion(-) | ||
8 | 19 | ||
9 | Signed-off-by: Joel Stanley <joel@jms.id.au> | 20 | diff --git a/target/arm/m-nocp.decode b/target/arm/m-nocp.decode |
10 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
11 | Tested-by: Cédric Le Goater <clg@kaod.org> | ||
12 | Message-id: 20180807075757.7242-5-joel@jms.id.au | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | hw/misc/aspeed_sdmc.c | 15 +++++++++++++++ | ||
16 | 1 file changed, 15 insertions(+) | ||
17 | |||
18 | diff --git a/hw/misc/aspeed_sdmc.c b/hw/misc/aspeed_sdmc.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/misc/aspeed_sdmc.c | 22 | --- a/target/arm/m-nocp.decode |
21 | +++ b/hw/misc/aspeed_sdmc.c | 23 | +++ b/target/arm/m-nocp.decode |
22 | @@ -XXX,XX +XXX,XX @@ | 24 | @@ -XXX,XX +XXX,XX @@ |
23 | /* Configuration Register */ | 25 | |
24 | #define R_CONF (0x04 / 4) | 26 | { |
25 | 27 | # Special cases which do not take an early NOCP: VLLDM and VLSTM | |
26 | +/* Control/Status Register #1 (ast2500) */ | 28 | - VLLDM_VLSTM 1110 1100 001 l:1 rn:4 0000 1010 0000 0000 |
27 | +#define R_STATUS1 (0x60 / 4) | 29 | + VLLDM_VLSTM 1110 1100 001 l:1 rn:4 0000 1010 op:1 000 0000 |
28 | +#define PHY_BUSY_STATE BIT(0) | 30 | # VSCCLRM (new in v8.1M) is similar: |
31 | VSCCLRM 1110 1100 1.01 1111 .... 1011 imm:7 0 vd=%vd_dp size=3 | ||
32 | VSCCLRM 1110 1100 1.01 1111 .... 1010 imm:8 vd=%vd_sp size=2 | ||
33 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/translate-vfp.c.inc | ||
36 | +++ b/target/arm/translate-vfp.c.inc | ||
37 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLLDM_VLSTM(DisasContext *s, arg_VLLDM_VLSTM *a) | ||
38 | !arm_dc_feature(s, ARM_FEATURE_V8)) { | ||
39 | return false; | ||
40 | } | ||
29 | + | 41 | + |
30 | /* | 42 | + if (a->op) { |
31 | * Configuration register Ox4 (for Aspeed AST2400 SOC) | 43 | + /* |
32 | * | 44 | + * T2 encoding ({D0-D31} reglist): v8.1M and up. We choose not |
33 | @@ -XXX,XX +XXX,XX @@ static void aspeed_sdmc_write(void *opaque, hwaddr addr, uint64_t data, | 45 | + * to take the IMPDEF option to make memory accesses to the stack |
34 | g_assert_not_reached(); | 46 | + * slots that correspond to the D16-D31 registers (discarding |
35 | } | 47 | + * read data and writing UNKNOWN values), so for us the T2 |
36 | } | 48 | + * encoding behaves identically to the T1 encoding. |
37 | + if (s->silicon_rev == AST2500_A0_SILICON_REV || | 49 | + */ |
38 | + s->silicon_rev == AST2500_A1_SILICON_REV) { | 50 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { |
39 | + switch (addr) { | 51 | + return false; |
40 | + case R_STATUS1: | 52 | + } |
41 | + /* Will never return 'busy' */ | 53 | + } else { |
42 | + data &= ~PHY_BUSY_STATE; | 54 | + /* |
43 | + break; | 55 | + * T1 encoding ({D0-D15} reglist); undef if we have 32 Dregs. |
44 | + default: | 56 | + * This is currently architecturally impossible, but we add the |
45 | + break; | 57 | + * check to stay in line with the pseudocode. Note that we must |
58 | + * emit code for the UNDEF so it takes precedence over the NOCP. | ||
59 | + */ | ||
60 | + if (dc_isar_feature(aa32_simd_r32, s)) { | ||
61 | + unallocated_encoding(s); | ||
62 | + return true; | ||
46 | + } | 63 | + } |
47 | + } | 64 | + } |
48 | 65 | + | |
49 | s->regs[addr] = data; | 66 | /* |
50 | } | 67 | * If not secure, UNDEF. We must emit code for this |
68 | * rather than returning false so that this takes | ||
51 | -- | 69 | -- |
52 | 2.18.0 | 70 | 2.20.1 |
53 | 71 | ||
54 | 72 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | v8.1M introduces a new TRD flag in the CCR register, which enables |
---|---|---|---|
2 | checking for stack frame integrity signatures on SG instructions. | ||
3 | This bit is not banked, and is always RAZ/WI to Non-secure code. | ||
4 | Adjust the code for handling CCR reads and writes to handle this. | ||
2 | 5 | ||
3 | The immediate should be scaled by the size of the memory reference, | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | not the size of the elements into which it is loaded. | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20201119215617.29887-23-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/cpu.h | 2 ++ | ||
11 | hw/intc/armv7m_nvic.c | 26 ++++++++++++++++++-------- | ||
12 | 2 files changed, 20 insertions(+), 8 deletions(-) | ||
5 | 13 | ||
6 | Cc: qemu-stable@nongnu.org (3.0.1) | 14 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
7 | Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Tested-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
10 | Reviewed-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | target/arm/translate-sve.c | 3 ++- | ||
14 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/translate-sve.c | 16 | --- a/target/arm/cpu.h |
19 | +++ b/target/arm/translate-sve.c | 17 | +++ b/target/arm/cpu.h |
20 | @@ -XXX,XX +XXX,XX @@ static bool trans_LD1R_zpri(DisasContext *s, arg_rpri_load *a, uint32_t insn) | 18 | @@ -XXX,XX +XXX,XX @@ FIELD(V7M_CCR, STKOFHFNMIGN, 10, 1) |
21 | unsigned vsz = vec_full_reg_size(s); | 19 | FIELD(V7M_CCR, DC, 16, 1) |
22 | unsigned psz = pred_full_reg_size(s); | 20 | FIELD(V7M_CCR, IC, 17, 1) |
23 | unsigned esz = dtype_esz[a->dtype]; | 21 | FIELD(V7M_CCR, BP, 18, 1) |
24 | + unsigned msz = dtype_msz(a->dtype); | 22 | +FIELD(V7M_CCR, LOB, 19, 1) |
25 | TCGLabel *over = gen_new_label(); | 23 | +FIELD(V7M_CCR, TRD, 20, 1) |
26 | TCGv_i64 temp; | 24 | |
27 | 25 | /* V7M SCR bits */ | |
28 | @@ -XXX,XX +XXX,XX @@ static bool trans_LD1R_zpri(DisasContext *s, arg_rpri_load *a, uint32_t insn) | 26 | FIELD(V7M_SCR, SLEEPONEXIT, 1, 1) |
29 | 27 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | |
30 | /* Load the data. */ | 28 | index XXXXXXX..XXXXXXX 100644 |
31 | temp = tcg_temp_new_i64(); | 29 | --- a/hw/intc/armv7m_nvic.c |
32 | - tcg_gen_addi_i64(temp, cpu_reg_sp(s, a->rn), a->imm << esz); | 30 | +++ b/hw/intc/armv7m_nvic.c |
33 | + tcg_gen_addi_i64(temp, cpu_reg_sp(s, a->rn), a->imm << msz); | 31 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) |
34 | tcg_gen_qemu_ld_i64(temp, temp, get_mem_index(s), | 32 | } |
35 | s->be_data | dtype_mop[a->dtype]); | 33 | return cpu->env.v7m.scr[attrs.secure]; |
36 | 34 | case 0xd14: /* Configuration Control. */ | |
35 | - /* The BFHFNMIGN bit is the only non-banked bit; we | ||
36 | - * keep it in the non-secure copy of the register. | ||
37 | + /* | ||
38 | + * Non-banked bits: BFHFNMIGN (stored in the NS copy of the register) | ||
39 | + * and TRD (stored in the S copy of the register) | ||
40 | */ | ||
41 | val = cpu->env.v7m.ccr[attrs.secure]; | ||
42 | val |= cpu->env.v7m.ccr[M_REG_NS] & R_V7M_CCR_BFHFNMIGN_MASK; | ||
43 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | ||
44 | cpu->env.v7m.scr[attrs.secure] = value; | ||
45 | break; | ||
46 | case 0xd14: /* Configuration Control. */ | ||
47 | + { | ||
48 | + uint32_t mask; | ||
49 | + | ||
50 | if (!arm_feature(&cpu->env, ARM_FEATURE_M_MAIN)) { | ||
51 | goto bad_offset; | ||
52 | } | ||
53 | |||
54 | /* Enforce RAZ/WI on reserved and must-RAZ/WI bits */ | ||
55 | - value &= (R_V7M_CCR_STKALIGN_MASK | | ||
56 | - R_V7M_CCR_BFHFNMIGN_MASK | | ||
57 | - R_V7M_CCR_DIV_0_TRP_MASK | | ||
58 | - R_V7M_CCR_UNALIGN_TRP_MASK | | ||
59 | - R_V7M_CCR_USERSETMPEND_MASK | | ||
60 | - R_V7M_CCR_NONBASETHRDENA_MASK); | ||
61 | + mask = R_V7M_CCR_STKALIGN_MASK | | ||
62 | + R_V7M_CCR_BFHFNMIGN_MASK | | ||
63 | + R_V7M_CCR_DIV_0_TRP_MASK | | ||
64 | + R_V7M_CCR_UNALIGN_TRP_MASK | | ||
65 | + R_V7M_CCR_USERSETMPEND_MASK | | ||
66 | + R_V7M_CCR_NONBASETHRDENA_MASK; | ||
67 | + if (arm_feature(&cpu->env, ARM_FEATURE_V8_1M) && attrs.secure) { | ||
68 | + /* TRD is always RAZ/WI from NS */ | ||
69 | + mask |= R_V7M_CCR_TRD_MASK; | ||
70 | + } | ||
71 | + value &= mask; | ||
72 | |||
73 | if (arm_feature(&cpu->env, ARM_FEATURE_V8)) { | ||
74 | /* v8M makes NONBASETHRDENA and STKALIGN be RES1 */ | ||
75 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | ||
76 | |||
77 | cpu->env.v7m.ccr[attrs.secure] = value; | ||
78 | break; | ||
79 | + } | ||
80 | case 0xd24: /* System Handler Control and State (SHCSR) */ | ||
81 | if (!arm_feature(&cpu->env, ARM_FEATURE_V7)) { | ||
82 | goto bad_offset; | ||
37 | -- | 83 | -- |
38 | 2.18.0 | 84 | 2.20.1 |
39 | 85 | ||
40 | 86 | diff view generated by jsdifflib |
1 | From: Su Hang <suhang16@mails.ucas.ac.cn> | 1 | v8.1M introduces a new TRD flag in the CCR register, which enables |
---|---|---|---|
2 | checking for stack frame integrity signatures on SG instructions. | ||
3 | Add the code in the SG insn implementation for the new behaviour. | ||
2 | 4 | ||
3 | This patch adds Intel Hexadecimal Object File format support to the | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | generic loader device. The file format specification is available here: | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | http://www.piclist.com/techref/fileext/hex/intel.htm | 7 | Message-id: 20201119215617.29887-24-peter.maydell@linaro.org |
8 | --- | ||
9 | target/arm/m_helper.c | 86 +++++++++++++++++++++++++++++++++++++++++++ | ||
10 | 1 file changed, 86 insertions(+) | ||
6 | 11 | ||
7 | This file format is often used with microcontrollers such as the | 12 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c |
8 | micro:bit, Arduino, STM32, etc. Users expect to be able to run .hex | ||
9 | files directly with without first converting them to ELF. Most | ||
10 | micro:bit code is developed in web-based IDEs without direct user access | ||
11 | to binutils so it is important for QEMU to handle this file format | ||
12 | natively. | ||
13 | |||
14 | Signed-off-by: Su Hang <suhang16@mails.ucas.ac.cn> | ||
15 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
16 | Acked-by: Alistair Francis <alistair.francis@wdc.com> | ||
17 | Message-id: 20180814162739.11814-6-stefanha@redhat.com | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | --- | ||
20 | include/hw/loader.h | 12 ++ | ||
21 | hw/core/generic-loader.c | 4 + | ||
22 | hw/core/loader.c | 249 +++++++++++++++++++++++++++++++++++++++ | ||
23 | 3 files changed, 265 insertions(+) | ||
24 | |||
25 | diff --git a/include/hw/loader.h b/include/hw/loader.h | ||
26 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/include/hw/loader.h | 14 | --- a/target/arm/m_helper.c |
28 | +++ b/include/hw/loader.h | 15 | +++ b/target/arm/m_helper.c |
29 | @@ -XXX,XX +XXX,XX @@ ssize_t load_image_size(const char *filename, void *addr, size_t size); | 16 | @@ -XXX,XX +XXX,XX @@ static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx, |
30 | int load_image_targphys_as(const char *filename, | 17 | return true; |
31 | hwaddr addr, uint64_t max_sz, AddressSpace *as); | 18 | } |
32 | 19 | ||
33 | +/**load_targphys_hex_as: | 20 | +static bool v7m_read_sg_stack_word(ARMCPU *cpu, ARMMMUIdx mmu_idx, |
34 | + * @filename: Path to the .hex file | 21 | + uint32_t addr, uint32_t *spdata) |
35 | + * @entry: Store the entry point given by the .hex file | 22 | +{ |
36 | + * @as: The AddressSpace to load the .hex file to. The value of | 23 | + /* |
37 | + * address_space_memory is used if nothing is supplied here. | 24 | + * Read a word of data from the stack for the SG instruction, |
38 | + * | 25 | + * writing the value into *spdata. If the load succeeds, return |
39 | + * Load a fixed .hex file into memory. | 26 | + * true; otherwise pend an appropriate exception and return false. |
40 | + * | 27 | + * (We can't use data load helpers here that throw an exception |
41 | + * Returns the size of the loaded .hex file on success, -1 otherwise. | 28 | + * because of the context we're called in, which is halfway through |
42 | + */ | 29 | + * arm_v7m_cpu_do_interrupt().) |
43 | +int load_targphys_hex_as(const char *filename, hwaddr *entry, AddressSpace *as); | 30 | + */ |
31 | + CPUState *cs = CPU(cpu); | ||
32 | + CPUARMState *env = &cpu->env; | ||
33 | + MemTxAttrs attrs = {}; | ||
34 | + MemTxResult txres; | ||
35 | + target_ulong page_size; | ||
36 | + hwaddr physaddr; | ||
37 | + int prot; | ||
38 | + ARMMMUFaultInfo fi = {}; | ||
39 | + ARMCacheAttrs cacheattrs = {}; | ||
40 | + uint32_t value; | ||
44 | + | 41 | + |
45 | /** load_image_targphys: | 42 | + if (get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &physaddr, |
46 | * Same as load_image_targphys_as(), but doesn't allow the caller to specify | 43 | + &attrs, &prot, &page_size, &fi, &cacheattrs)) { |
47 | * an AddressSpace. | 44 | + /* MPU/SAU lookup failed */ |
48 | diff --git a/hw/core/generic-loader.c b/hw/core/generic-loader.c | 45 | + if (fi.type == ARMFault_QEMU_SFault) { |
49 | index XXXXXXX..XXXXXXX 100644 | 46 | + qemu_log_mask(CPU_LOG_INT, |
50 | --- a/hw/core/generic-loader.c | 47 | + "...SecureFault during stack word read\n"); |
51 | +++ b/hw/core/generic-loader.c | 48 | + env->v7m.sfsr |= R_V7M_SFSR_AUVIOL_MASK | R_V7M_SFSR_SFARVALID_MASK; |
52 | @@ -XXX,XX +XXX,XX @@ static void generic_loader_realize(DeviceState *dev, Error **errp) | 49 | + env->v7m.sfar = addr; |
53 | size = load_uimage_as(s->file, &entry, NULL, NULL, NULL, NULL, | 50 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false); |
54 | as); | 51 | + } else { |
55 | } | 52 | + qemu_log_mask(CPU_LOG_INT, |
56 | + | 53 | + "...MemManageFault during stack word read\n"); |
57 | + if (size < 0) { | 54 | + env->v7m.cfsr[M_REG_S] |= R_V7M_CFSR_DACCVIOL_MASK | |
58 | + size = load_targphys_hex_as(s->file, &entry, as); | 55 | + R_V7M_CFSR_MMARVALID_MASK; |
59 | + } | 56 | + env->v7m.mmfar[M_REG_S] = addr; |
60 | } | 57 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_MEM, false); |
61 | 58 | + } | |
62 | if (size < 0 || s->force_raw) { | ||
63 | diff --git a/hw/core/loader.c b/hw/core/loader.c | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/hw/core/loader.c | ||
66 | +++ b/hw/core/loader.c | ||
67 | @@ -XXX,XX +XXX,XX @@ void hmp_info_roms(Monitor *mon, const QDict *qdict) | ||
68 | } | ||
69 | } | ||
70 | } | ||
71 | + | ||
72 | +typedef enum HexRecord HexRecord; | ||
73 | +enum HexRecord { | ||
74 | + DATA_RECORD = 0, | ||
75 | + EOF_RECORD, | ||
76 | + EXT_SEG_ADDR_RECORD, | ||
77 | + START_SEG_ADDR_RECORD, | ||
78 | + EXT_LINEAR_ADDR_RECORD, | ||
79 | + START_LINEAR_ADDR_RECORD, | ||
80 | +}; | ||
81 | + | ||
82 | +/* Each record contains a 16-bit address which is combined with the upper 16 | ||
83 | + * bits of the implicit "next address" to form a 32-bit address. | ||
84 | + */ | ||
85 | +#define NEXT_ADDR_MASK 0xffff0000 | ||
86 | + | ||
87 | +#define DATA_FIELD_MAX_LEN 0xff | ||
88 | +#define LEN_EXCEPT_DATA 0x5 | ||
89 | +/* 0x5 = sizeof(byte_count) + sizeof(address) + sizeof(record_type) + | ||
90 | + * sizeof(checksum) */ | ||
91 | +typedef struct { | ||
92 | + uint8_t byte_count; | ||
93 | + uint16_t address; | ||
94 | + uint8_t record_type; | ||
95 | + uint8_t data[DATA_FIELD_MAX_LEN]; | ||
96 | + uint8_t checksum; | ||
97 | +} HexLine; | ||
98 | + | ||
99 | +/* return 0 or -1 if error */ | ||
100 | +static bool parse_record(HexLine *line, uint8_t *our_checksum, const uint8_t c, | ||
101 | + uint32_t *index, const bool in_process) | ||
102 | +{ | ||
103 | + /* +-------+---------------+-------+---------------------+--------+ | ||
104 | + * | byte | |record | | | | ||
105 | + * | count | address | type | data |checksum| | ||
106 | + * +-------+---------------+-------+---------------------+--------+ | ||
107 | + * ^ ^ ^ ^ ^ ^ | ||
108 | + * |1 byte | 2 bytes |1 byte | 0-255 bytes | 1 byte | | ||
109 | + */ | ||
110 | + uint8_t value = 0; | ||
111 | + uint32_t idx = *index; | ||
112 | + /* ignore space */ | ||
113 | + if (g_ascii_isspace(c)) { | ||
114 | + return true; | ||
115 | + } | ||
116 | + if (!g_ascii_isxdigit(c) || !in_process) { | ||
117 | + return false; | 59 | + return false; |
118 | + } | 60 | + } |
119 | + value = g_ascii_xdigit_value(c); | 61 | + value = address_space_ldl(arm_addressspace(cs, attrs), physaddr, |
120 | + value = (idx & 0x1) ? (value & 0xf) : (value << 4); | 62 | + attrs, &txres); |
121 | + if (idx < 2) { | 63 | + if (txres != MEMTX_OK) { |
122 | + line->byte_count |= value; | 64 | + /* BusFault trying to read the data */ |
123 | + } else if (2 <= idx && idx < 6) { | 65 | + qemu_log_mask(CPU_LOG_INT, |
124 | + line->address <<= 4; | 66 | + "...BusFault during stack word read\n"); |
125 | + line->address += g_ascii_xdigit_value(c); | 67 | + env->v7m.cfsr[M_REG_NS] |= |
126 | + } else if (6 <= idx && idx < 8) { | 68 | + (R_V7M_CFSR_PRECISERR_MASK | R_V7M_CFSR_BFARVALID_MASK); |
127 | + line->record_type |= value; | 69 | + env->v7m.bfar = addr; |
128 | + } else if (8 <= idx && idx < 8 + 2 * line->byte_count) { | 70 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_BUS, false); |
129 | + line->data[(idx - 8) >> 1] |= value; | ||
130 | + } else if (8 + 2 * line->byte_count <= idx && | ||
131 | + idx < 10 + 2 * line->byte_count) { | ||
132 | + line->checksum |= value; | ||
133 | + } else { | ||
134 | + return false; | 71 | + return false; |
135 | + } | 72 | + } |
136 | + *our_checksum += value; | 73 | + |
137 | + ++(*index); | 74 | + *spdata = value; |
138 | + return true; | 75 | + return true; |
139 | +} | 76 | +} |
140 | + | 77 | + |
141 | +typedef struct { | 78 | static bool v7m_handle_execute_nsc(ARMCPU *cpu) |
142 | + const char *filename; | 79 | { |
143 | + HexLine line; | 80 | /* |
144 | + uint8_t *bin_buf; | 81 | @@ -XXX,XX +XXX,XX @@ static bool v7m_handle_execute_nsc(ARMCPU *cpu) |
145 | + hwaddr *start_addr; | 82 | */ |
146 | + int total_size; | 83 | qemu_log_mask(CPU_LOG_INT, "...really an SG instruction at 0x%08" PRIx32 |
147 | + uint32_t next_address_to_write; | 84 | ", executing it\n", env->regs[15]); |
148 | + uint32_t current_address; | ||
149 | + uint32_t current_rom_index; | ||
150 | + uint32_t rom_start_address; | ||
151 | + AddressSpace *as; | ||
152 | +} HexParser; | ||
153 | + | 85 | + |
154 | +/* return size or -1 if error */ | 86 | + if (cpu_isar_feature(aa32_m_sec_state, cpu) && |
155 | +static int handle_record_type(HexParser *parser) | 87 | + !arm_v7m_is_handler_mode(env)) { |
156 | +{ | 88 | + /* |
157 | + HexLine *line = &(parser->line); | 89 | + * v8.1M exception stack frame integrity check. Note that we |
158 | + switch (line->record_type) { | 90 | + * must perform the memory access even if CCR_S.TRD is zero |
159 | + case DATA_RECORD: | 91 | + * and we aren't going to check what the data loaded is. |
160 | + parser->current_address = | 92 | + */ |
161 | + (parser->next_address_to_write & NEXT_ADDR_MASK) | line->address; | 93 | + uint32_t spdata, sp; |
162 | + /* verify this is a contiguous block of memory */ | 94 | + |
163 | + if (parser->current_address != parser->next_address_to_write) { | 95 | + /* |
164 | + if (parser->current_rom_index != 0) { | 96 | + * We know we are currently NS, so the S stack pointers must be |
165 | + rom_add_blob_fixed_as(parser->filename, parser->bin_buf, | 97 | + * in other_ss_{psp,msp}, not in regs[13]/other_sp. |
166 | + parser->current_rom_index, | 98 | + */ |
167 | + parser->rom_start_address, parser->as); | 99 | + sp = v7m_using_psp(env) ? env->v7m.other_ss_psp : env->v7m.other_ss_msp; |
168 | + } | 100 | + if (!v7m_read_sg_stack_word(cpu, mmu_idx, sp, &spdata)) { |
169 | + parser->rom_start_address = parser->current_address; | 101 | + /* Stack access failed and an exception has been pended */ |
170 | + parser->current_rom_index = 0; | 102 | + return false; |
171 | + } | 103 | + } |
172 | + | 104 | + |
173 | + /* copy from line buffer to output bin_buf */ | 105 | + if (env->v7m.ccr[M_REG_S] & R_V7M_CCR_TRD_MASK) { |
174 | + memcpy(parser->bin_buf + parser->current_rom_index, line->data, | 106 | + if (((spdata & ~1) == 0xfefa125a) || |
175 | + line->byte_count); | 107 | + !(env->v7m.control[M_REG_S] & 1)) { |
176 | + parser->current_rom_index += line->byte_count; | 108 | + goto gen_invep; |
177 | + parser->total_size += line->byte_count; | ||
178 | + /* save next address to write */ | ||
179 | + parser->next_address_to_write = | ||
180 | + parser->current_address + line->byte_count; | ||
181 | + break; | ||
182 | + | ||
183 | + case EOF_RECORD: | ||
184 | + if (parser->current_rom_index != 0) { | ||
185 | + rom_add_blob_fixed_as(parser->filename, parser->bin_buf, | ||
186 | + parser->current_rom_index, | ||
187 | + parser->rom_start_address, parser->as); | ||
188 | + } | ||
189 | + return parser->total_size; | ||
190 | + case EXT_SEG_ADDR_RECORD: | ||
191 | + case EXT_LINEAR_ADDR_RECORD: | ||
192 | + if (line->byte_count != 2 && line->address != 0) { | ||
193 | + return -1; | ||
194 | + } | ||
195 | + | ||
196 | + if (parser->current_rom_index != 0) { | ||
197 | + rom_add_blob_fixed_as(parser->filename, parser->bin_buf, | ||
198 | + parser->current_rom_index, | ||
199 | + parser->rom_start_address, parser->as); | ||
200 | + } | ||
201 | + | ||
202 | + /* save next address to write, | ||
203 | + * in case of non-contiguous block of memory */ | ||
204 | + parser->next_address_to_write = (line->data[0] << 12) | | ||
205 | + (line->data[1] << 4); | ||
206 | + if (line->record_type == EXT_LINEAR_ADDR_RECORD) { | ||
207 | + parser->next_address_to_write <<= 12; | ||
208 | + } | ||
209 | + | ||
210 | + parser->rom_start_address = parser->next_address_to_write; | ||
211 | + parser->current_rom_index = 0; | ||
212 | + break; | ||
213 | + | ||
214 | + case START_SEG_ADDR_RECORD: | ||
215 | + if (line->byte_count != 4 && line->address != 0) { | ||
216 | + return -1; | ||
217 | + } | ||
218 | + | ||
219 | + /* x86 16-bit CS:IP segmented addressing */ | ||
220 | + *(parser->start_addr) = (((line->data[0] << 8) | line->data[1]) << 4) + | ||
221 | + ((line->data[2] << 8) | line->data[3]); | ||
222 | + break; | ||
223 | + | ||
224 | + case START_LINEAR_ADDR_RECORD: | ||
225 | + if (line->byte_count != 4 && line->address != 0) { | ||
226 | + return -1; | ||
227 | + } | ||
228 | + | ||
229 | + *(parser->start_addr) = ldl_be_p(line->data); | ||
230 | + break; | ||
231 | + | ||
232 | + default: | ||
233 | + return -1; | ||
234 | + } | ||
235 | + | ||
236 | + return parser->total_size; | ||
237 | +} | ||
238 | + | ||
239 | +/* return size or -1 if error */ | ||
240 | +static int parse_hex_blob(const char *filename, hwaddr *addr, uint8_t *hex_blob, | ||
241 | + size_t hex_blob_size, AddressSpace *as) | ||
242 | +{ | ||
243 | + bool in_process = false; /* avoid re-enter and | ||
244 | + * check whether record begin with ':' */ | ||
245 | + uint8_t *end = hex_blob + hex_blob_size; | ||
246 | + uint8_t our_checksum = 0; | ||
247 | + uint32_t record_index = 0; | ||
248 | + HexParser parser = { | ||
249 | + .filename = filename, | ||
250 | + .bin_buf = g_malloc(hex_blob_size), | ||
251 | + .start_addr = addr, | ||
252 | + .as = as, | ||
253 | + }; | ||
254 | + | ||
255 | + rom_transaction_begin(); | ||
256 | + | ||
257 | + for (; hex_blob < end; ++hex_blob) { | ||
258 | + switch (*hex_blob) { | ||
259 | + case '\r': | ||
260 | + case '\n': | ||
261 | + if (!in_process) { | ||
262 | + break; | ||
263 | + } | 109 | + } |
264 | + | ||
265 | + in_process = false; | ||
266 | + if ((LEN_EXCEPT_DATA + parser.line.byte_count) * 2 != | ||
267 | + record_index || | ||
268 | + our_checksum != 0) { | ||
269 | + parser.total_size = -1; | ||
270 | + goto out; | ||
271 | + } | ||
272 | + | ||
273 | + if (handle_record_type(&parser) == -1) { | ||
274 | + parser.total_size = -1; | ||
275 | + goto out; | ||
276 | + } | ||
277 | + break; | ||
278 | + | ||
279 | + /* start of a new record. */ | ||
280 | + case ':': | ||
281 | + memset(&parser.line, 0, sizeof(HexLine)); | ||
282 | + in_process = true; | ||
283 | + record_index = 0; | ||
284 | + break; | ||
285 | + | ||
286 | + /* decoding lines */ | ||
287 | + default: | ||
288 | + if (!parse_record(&parser.line, &our_checksum, *hex_blob, | ||
289 | + &record_index, in_process)) { | ||
290 | + parser.total_size = -1; | ||
291 | + goto out; | ||
292 | + } | ||
293 | + break; | ||
294 | + } | 110 | + } |
295 | + } | 111 | + } |
296 | + | 112 | + |
297 | +out: | 113 | env->regs[14] &= ~1; |
298 | + g_free(parser.bin_buf); | 114 | env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK; |
299 | + rom_transaction_end(parser.total_size != -1); | 115 | switch_v7m_security_state(env, true); |
300 | + return parser.total_size; | ||
301 | +} | ||
302 | + | ||
303 | +/* return size or -1 if error */ | ||
304 | +int load_targphys_hex_as(const char *filename, hwaddr *entry, AddressSpace *as) | ||
305 | +{ | ||
306 | + gsize hex_blob_size; | ||
307 | + gchar *hex_blob; | ||
308 | + int total_size = 0; | ||
309 | + | ||
310 | + if (!g_file_get_contents(filename, &hex_blob, &hex_blob_size, NULL)) { | ||
311 | + return -1; | ||
312 | + } | ||
313 | + | ||
314 | + total_size = parse_hex_blob(filename, entry, (uint8_t *)hex_blob, | ||
315 | + hex_blob_size, as); | ||
316 | + | ||
317 | + g_free(hex_blob); | ||
318 | + return total_size; | ||
319 | +} | ||
320 | -- | 116 | -- |
321 | 2.18.0 | 117 | 2.20.1 |
322 | 118 | ||
323 | 119 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | In commit 077d7449100d824a4 we added code to handle the v8M |
---|---|---|---|
2 | requirement that returns from NMI or HardFault forcibly deactivate | ||
3 | those exceptions regardless of what interrupt the guest is trying to | ||
4 | deactivate. Unfortunately this broke the handling of the "illegal | ||
5 | exception return because the returning exception number is not | ||
6 | active" check for those cases. In the pseudocode this test is done | ||
7 | on the exception the guest asks to return from, but because our | ||
8 | implementation was doing this in armv7m_nvic_complete_irq() after the | ||
9 | new "deactivate NMI/HardFault regardless" code we ended up doing the | ||
10 | test on the VecInfo for that exception instead, which usually meant | ||
11 | failing to raise the illegal exception return fault. | ||
2 | 12 | ||
3 | With PC, there are 33 registers. Three per line lines up nicely | 13 | In the case for "configurable exception targeting the opposite |
4 | without overflowing 80 columns. | 14 | security state" we detected the illegal-return case but went ahead |
15 | and deactivated the VecInfo anyway, which is wrong because that is | ||
16 | the VecInfo for the other security state. | ||
5 | 17 | ||
6 | Cc: qemu-stable@nongnu.org (3.0.1) | 18 | Rearrange the code so that we first identify the illegal return |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 19 | cases, then see if we really need to deactivate NMI or HardFault |
8 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 20 | instead, and finally do the deactivation. |
21 | |||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
23 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
24 | Message-id: 20201119215617.29887-25-peter.maydell@linaro.org | ||
10 | --- | 25 | --- |
11 | target/arm/translate-a64.c | 13 ++++++------- | 26 | hw/intc/armv7m_nvic.c | 59 +++++++++++++++++++++++-------------------- |
12 | 1 file changed, 6 insertions(+), 7 deletions(-) | 27 | 1 file changed, 32 insertions(+), 27 deletions(-) |
13 | 28 | ||
14 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 29 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c |
15 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate-a64.c | 31 | --- a/hw/intc/armv7m_nvic.c |
17 | +++ b/target/arm/translate-a64.c | 32 | +++ b/hw/intc/armv7m_nvic.c |
18 | @@ -XXX,XX +XXX,XX @@ void aarch64_cpu_dump_state(CPUState *cs, FILE *f, | 33 | @@ -XXX,XX +XXX,XX @@ int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure) |
19 | int el = arm_current_el(env); | 34 | { |
20 | const char *ns_status; | 35 | NVICState *s = (NVICState *)opaque; |
21 | 36 | VecInfo *vec = NULL; | |
22 | - cpu_fprintf(f, "PC=%016"PRIx64" SP=%016"PRIx64"\n", | 37 | - int ret; |
23 | - env->pc, env->xregs[31]); | 38 | + int ret = 0; |
24 | - for (i = 0; i < 31; i++) { | 39 | |
25 | - cpu_fprintf(f, "X%02d=%016"PRIx64, i, env->xregs[i]); | 40 | assert(irq > ARMV7M_EXCP_RESET && irq < s->num_irq); |
26 | - if ((i % 4) == 3) { | 41 | |
27 | - cpu_fprintf(f, "\n"); | 42 | + trace_nvic_complete_irq(irq, secure); |
28 | + cpu_fprintf(f, " PC=%016" PRIx64 " ", env->pc); | 43 | + |
29 | + for (i = 0; i < 32; i++) { | 44 | + if (secure && exc_is_banked(irq)) { |
30 | + if (i == 31) { | 45 | + vec = &s->sec_vectors[irq]; |
31 | + cpu_fprintf(f, " SP=%016" PRIx64 "\n", env->xregs[i]); | 46 | + } else { |
32 | } else { | 47 | + vec = &s->vectors[irq]; |
33 | - cpu_fprintf(f, " "); | 48 | + } |
34 | + cpu_fprintf(f, "X%02d=%016" PRIx64 "%s", i, env->xregs[i], | 49 | + |
35 | + (i + 2) % 3 ? " " : "\n"); | 50 | + /* |
36 | } | 51 | + * Identify illegal exception return cases. We can't immediately |
52 | + * return at this point because we still need to deactivate | ||
53 | + * (either this exception or NMI/HardFault) first. | ||
54 | + */ | ||
55 | + if (!exc_is_banked(irq) && exc_targets_secure(s, irq) != secure) { | ||
56 | + /* | ||
57 | + * Return from a configurable exception targeting the opposite | ||
58 | + * security state from the one we're trying to complete it for. | ||
59 | + * Clear vec because it's not really the VecInfo for this | ||
60 | + * (irq, secstate) so we mustn't deactivate it. | ||
61 | + */ | ||
62 | + ret = -1; | ||
63 | + vec = NULL; | ||
64 | + } else if (!vec->active) { | ||
65 | + /* Return from an inactive interrupt */ | ||
66 | + ret = -1; | ||
67 | + } else { | ||
68 | + /* Legal return, we will return the RETTOBASE bit value to the caller */ | ||
69 | + ret = nvic_rettobase(s); | ||
70 | + } | ||
71 | + | ||
72 | /* | ||
73 | * For negative priorities, v8M will forcibly deactivate the appropriate | ||
74 | * NMI or HardFault regardless of what interrupt we're being asked to | ||
75 | @@ -XXX,XX +XXX,XX @@ int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure) | ||
37 | } | 76 | } |
38 | 77 | ||
78 | if (!vec) { | ||
79 | - if (secure && exc_is_banked(irq)) { | ||
80 | - vec = &s->sec_vectors[irq]; | ||
81 | - } else { | ||
82 | - vec = &s->vectors[irq]; | ||
83 | - } | ||
84 | - } | ||
85 | - | ||
86 | - trace_nvic_complete_irq(irq, secure); | ||
87 | - | ||
88 | - if (!vec->active) { | ||
89 | - /* Tell the caller this was an illegal exception return */ | ||
90 | - return -1; | ||
91 | - } | ||
92 | - | ||
93 | - /* | ||
94 | - * If this is a configurable exception and it is currently | ||
95 | - * targeting the opposite security state from the one we're trying | ||
96 | - * to complete it for, this counts as an illegal exception return. | ||
97 | - * We still need to deactivate whatever vector the logic above has | ||
98 | - * selected, though, as it might not be the same as the one for the | ||
99 | - * requested exception number. | ||
100 | - */ | ||
101 | - if (!exc_is_banked(irq) && exc_targets_secure(s, irq) != secure) { | ||
102 | - ret = -1; | ||
103 | - } else { | ||
104 | - ret = nvic_rettobase(s); | ||
105 | + return ret; | ||
106 | } | ||
107 | |||
108 | vec->active = 0; | ||
39 | -- | 109 | -- |
40 | 2.18.0 | 110 | 2.20.1 |
41 | 111 | ||
42 | 112 | diff view generated by jsdifflib |
1 | From: Stefan Hajnoczi <stefanha@redhat.com> | 1 | For v8.1M the architecture mandates that CPUs must provide at |
---|---|---|---|
2 | least the "minimal RAS implementation" from the Reliability, | ||
3 | Availability and Serviceability extension. This consists of: | ||
4 | * an ESB instruction which is a NOP | ||
5 | -- since it is in the HINT space we need only add a comment | ||
6 | * an RFSR register which will RAZ/WI | ||
7 | * a RAZ/WI AIRCR.IESB bit | ||
8 | -- the code which handles writes to AIRCR does not allow setting | ||
9 | of RES0 bits, so we already treat this as RAZ/WI; add a comment | ||
10 | noting that this is deliberate | ||
11 | * minimal implementation of the RAS register block at 0xe0005000 | ||
12 | -- this will be in a subsequent commit | ||
13 | * setting the ID_PFR0.RAS field to 0b0010 | ||
14 | -- we will do this when we add the Cortex-M55 CPU model | ||
2 | 15 | ||
3 | Image file loaders may add a series of roms. If an error occurs partway | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | through loading there is no easy way to drop previously added roms. | 17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
18 | Message-id: 20201119215617.29887-26-peter.maydell@linaro.org | ||
19 | --- | ||
20 | target/arm/cpu.h | 14 ++++++++++++++ | ||
21 | target/arm/t32.decode | 4 ++++ | ||
22 | hw/intc/armv7m_nvic.c | 13 +++++++++++++ | ||
23 | 3 files changed, 31 insertions(+) | ||
5 | 24 | ||
6 | This patch adds a transaction mechanism that works like this: | 25 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
7 | |||
8 | rom_transaction_begin(); | ||
9 | ...call rom_add_*()... | ||
10 | rom_transaction_end(ok); | ||
11 | |||
12 | If ok is false then roms added in this transaction are dropped. | ||
13 | |||
14 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
15 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
16 | Message-id: 20180814162739.11814-5-stefanha@redhat.com | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | --- | ||
19 | include/hw/loader.h | 19 +++++++++++++++++++ | ||
20 | hw/core/loader.c | 32 ++++++++++++++++++++++++++++++++ | ||
21 | 2 files changed, 51 insertions(+) | ||
22 | |||
23 | diff --git a/include/hw/loader.h b/include/hw/loader.h | ||
24 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/include/hw/loader.h | 27 | --- a/target/arm/cpu.h |
26 | +++ b/include/hw/loader.h | 28 | +++ b/target/arm/cpu.h |
27 | @@ -XXX,XX +XXX,XX @@ int rom_check_and_register_reset(void); | 29 | @@ -XXX,XX +XXX,XX @@ FIELD(ID_MMFR4, LSM, 20, 4) |
28 | void rom_set_fw(FWCfgState *f); | 30 | FIELD(ID_MMFR4, CCIDX, 24, 4) |
29 | void rom_set_order_override(int order); | 31 | FIELD(ID_MMFR4, EVT, 28, 4) |
30 | void rom_reset_order_override(void); | 32 | |
33 | +FIELD(ID_PFR0, STATE0, 0, 4) | ||
34 | +FIELD(ID_PFR0, STATE1, 4, 4) | ||
35 | +FIELD(ID_PFR0, STATE2, 8, 4) | ||
36 | +FIELD(ID_PFR0, STATE3, 12, 4) | ||
37 | +FIELD(ID_PFR0, CSV2, 16, 4) | ||
38 | +FIELD(ID_PFR0, AMU, 20, 4) | ||
39 | +FIELD(ID_PFR0, DIT, 24, 4) | ||
40 | +FIELD(ID_PFR0, RAS, 28, 4) | ||
31 | + | 41 | + |
32 | +/** | 42 | FIELD(ID_PFR1, PROGMOD, 0, 4) |
33 | + * rom_transaction_begin: | 43 | FIELD(ID_PFR1, SECURITY, 4, 4) |
34 | + * | 44 | FIELD(ID_PFR1, MPROGMOD, 8, 4) |
35 | + * Call this before of a series of rom_add_*() calls. Call | 45 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_predinv(const ARMISARegisters *id) |
36 | + * rom_transaction_end() afterwards to commit or abort. These functions are | 46 | return FIELD_EX32(id->id_isar6, ID_ISAR6, SPECRES) != 0; |
37 | + * useful for undoing a series of rom_add_*() calls if image file loading fails | ||
38 | + * partway through. | ||
39 | + */ | ||
40 | +void rom_transaction_begin(void); | ||
41 | + | ||
42 | +/** | ||
43 | + * rom_transaction_end: | ||
44 | + * @commit: true to commit added roms, false to drop added roms | ||
45 | + * | ||
46 | + * Call this after a series of rom_add_*() calls. See rom_transaction_begin(). | ||
47 | + */ | ||
48 | +void rom_transaction_end(bool commit); | ||
49 | + | ||
50 | int rom_copy(uint8_t *dest, hwaddr addr, size_t size); | ||
51 | void *rom_ptr(hwaddr addr, size_t size); | ||
52 | void hmp_info_roms(Monitor *mon, const QDict *qdict); | ||
53 | diff --git a/hw/core/loader.c b/hw/core/loader.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/hw/core/loader.c | ||
56 | +++ b/hw/core/loader.c | ||
57 | @@ -XXX,XX +XXX,XX @@ struct Rom { | ||
58 | char *fw_dir; | ||
59 | char *fw_file; | ||
60 | |||
61 | + bool committed; | ||
62 | + | ||
63 | hwaddr addr; | ||
64 | QTAILQ_ENTRY(Rom) next; | ||
65 | }; | ||
66 | @@ -XXX,XX +XXX,XX @@ static void rom_insert(Rom *rom) | ||
67 | rom->as = &address_space_memory; | ||
68 | } | ||
69 | |||
70 | + rom->committed = false; | ||
71 | + | ||
72 | /* List is ordered by load address in the same address space */ | ||
73 | QTAILQ_FOREACH(item, &roms, next) { | ||
74 | if (rom_order_compare(rom, item)) { | ||
75 | @@ -XXX,XX +XXX,XX @@ void rom_reset_order_override(void) | ||
76 | fw_cfg_reset_order_override(fw_cfg); | ||
77 | } | 47 | } |
78 | 48 | ||
79 | +void rom_transaction_begin(void) | 49 | +static inline bool isar_feature_aa32_ras(const ARMISARegisters *id) |
80 | +{ | 50 | +{ |
81 | + Rom *rom; | 51 | + return FIELD_EX32(id->id_pfr0, ID_PFR0, RAS) != 0; |
82 | + | ||
83 | + /* Ignore ROMs added without the transaction API */ | ||
84 | + QTAILQ_FOREACH(rom, &roms, next) { | ||
85 | + rom->committed = true; | ||
86 | + } | ||
87 | +} | 52 | +} |
88 | + | 53 | + |
89 | +void rom_transaction_end(bool commit) | 54 | static inline bool isar_feature_aa32_mprofile(const ARMISARegisters *id) |
90 | +{ | 55 | { |
91 | + Rom *rom; | 56 | return FIELD_EX32(id->id_pfr1, ID_PFR1, MPROGMOD) != 0; |
92 | + Rom *tmp; | 57 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode |
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/target/arm/t32.decode | ||
60 | +++ b/target/arm/t32.decode | ||
61 | @@ -XXX,XX +XXX,XX @@ CLZ 1111 1010 1011 ---- 1111 .... 1000 .... @rdm | ||
62 | # SEV 1111 0011 1010 1111 1000 0000 0000 0100 | ||
63 | # SEVL 1111 0011 1010 1111 1000 0000 0000 0101 | ||
64 | |||
65 | + # For M-profile minimal-RAS ESB can be a NOP, which is the | ||
66 | + # default behaviour since it is in the hint space. | ||
67 | + # ESB 1111 0011 1010 1111 1000 0000 0001 0000 | ||
93 | + | 68 | + |
94 | + QTAILQ_FOREACH_SAFE(rom, &roms, next, tmp) { | 69 | # The canonical nop ends in 0000 0000, but the whole rest |
95 | + if (rom->committed) { | 70 | # of the space is "reserved hint, behaves as nop". |
96 | + continue; | 71 | NOP 1111 0011 1010 1111 1000 0000 ---- ---- |
72 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
73 | index XXXXXXX..XXXXXXX 100644 | ||
74 | --- a/hw/intc/armv7m_nvic.c | ||
75 | +++ b/hw/intc/armv7m_nvic.c | ||
76 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | ||
77 | return 0; | ||
78 | } | ||
79 | return cpu->env.v7m.sfar; | ||
80 | + case 0xf04: /* RFSR */ | ||
81 | + if (!cpu_isar_feature(aa32_ras, cpu)) { | ||
82 | + goto bad_offset; | ||
97 | + } | 83 | + } |
98 | + if (commit) { | 84 | + /* We provide minimal-RAS only: RFSR is RAZ/WI */ |
99 | + rom->committed = true; | 85 | + return 0; |
100 | + } else { | 86 | case 0xf34: /* FPCCR */ |
101 | + QTAILQ_REMOVE(&roms, rom, next); | 87 | if (!cpu_isar_feature(aa32_vfp_simd, cpu)) { |
102 | + rom_free(rom); | 88 | return 0; |
89 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | ||
90 | R_V7M_AIRCR_PRIGROUP_SHIFT, | ||
91 | R_V7M_AIRCR_PRIGROUP_LENGTH); | ||
92 | } | ||
93 | + /* AIRCR.IESB is RAZ/WI because we implement only minimal RAS */ | ||
94 | if (attrs.secure) { | ||
95 | /* These bits are only writable by secure */ | ||
96 | cpu->env.v7m.aircr = value & | ||
97 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | ||
98 | } | ||
99 | break; | ||
100 | } | ||
101 | + case 0xf04: /* RFSR */ | ||
102 | + if (!cpu_isar_feature(aa32_ras, cpu)) { | ||
103 | + goto bad_offset; | ||
103 | + } | 104 | + } |
104 | + } | 105 | + /* We provide minimal-RAS only: RFSR is RAZ/WI */ |
105 | +} | 106 | + break; |
106 | + | 107 | case 0xf34: /* FPCCR */ |
107 | static Rom *find_rom(hwaddr addr, size_t size) | 108 | if (cpu_isar_feature(aa32_vfp_simd, cpu)) { |
108 | { | 109 | /* Not all bits here are banked. */ |
109 | Rom *rom; | ||
110 | -- | 110 | -- |
111 | 2.18.0 | 111 | 2.20.1 |
112 | 112 | ||
113 | 113 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | The RAS feature has a block of memory-mapped registers at offset |
---|---|---|---|
2 | 0x5000 within the PPB. For a "minimal RAS" implementation we provide | ||
3 | no error records and so the only registers that exist in the block | ||
4 | are ERRIIDR and ERRDEVID. | ||
2 | 5 | ||
3 | This will be used to construct a memory region beyond the RAM region | 6 | The "RAZ/WI for privileged, BusFault for nonprivileged" behaviour |
4 | to let firmwares scan the address space with load/store to guess how | 7 | of the "nvic-default" region is actually valid for minimal-RAS, |
5 | much RAM the SoC has. | 8 | so the main benefit of providing an explicit implementation of |
9 | the register block is more accurate LOG_UNIMP messages, and a | ||
10 | framework for where we could add a real RAS implementation later | ||
11 | if necessary. | ||
6 | 12 | ||
7 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
8 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
9 | Tested-by: Cédric Le Goater <clg@kaod.org> | ||
10 | Message-id: 20180807075757.7242-7-joel@jms.id.au | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Message-id: 20201119215617.29887-27-peter.maydell@linaro.org | ||
13 | --- | 16 | --- |
14 | include/hw/misc/aspeed_sdmc.h | 1 + | 17 | include/hw/intc/armv7m_nvic.h | 1 + |
15 | hw/arm/aspeed.c | 31 +++++++++++++++++++++++++++++++ | 18 | hw/intc/armv7m_nvic.c | 56 +++++++++++++++++++++++++++++++++++ |
16 | hw/arm/aspeed_soc.c | 2 ++ | 19 | 2 files changed, 57 insertions(+) |
17 | hw/misc/aspeed_sdmc.c | 3 +++ | ||
18 | 4 files changed, 37 insertions(+) | ||
19 | 20 | ||
20 | diff --git a/include/hw/misc/aspeed_sdmc.h b/include/hw/misc/aspeed_sdmc.h | 21 | diff --git a/include/hw/intc/armv7m_nvic.h b/include/hw/intc/armv7m_nvic.h |
21 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/hw/misc/aspeed_sdmc.h | 23 | --- a/include/hw/intc/armv7m_nvic.h |
23 | +++ b/include/hw/misc/aspeed_sdmc.h | 24 | +++ b/include/hw/intc/armv7m_nvic.h |
24 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSDMCState { | 25 | @@ -XXX,XX +XXX,XX @@ struct NVICState { |
25 | uint32_t silicon_rev; | 26 | MemoryRegion sysreg_ns_mem; |
26 | uint32_t ram_bits; | 27 | MemoryRegion systickmem; |
27 | uint64_t ram_size; | 28 | MemoryRegion systick_ns_mem; |
28 | + uint64_t max_ram_size; | 29 | + MemoryRegion ras_mem; |
29 | uint32_t fixed_conf; | 30 | MemoryRegion container; |
30 | 31 | MemoryRegion defaultmem; | |
31 | } AspeedSDMCState; | 32 | |
32 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | 33 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c |
33 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/hw/arm/aspeed.c | 35 | --- a/hw/intc/armv7m_nvic.c |
35 | +++ b/hw/arm/aspeed.c | 36 | +++ b/hw/intc/armv7m_nvic.c |
36 | @@ -XXX,XX +XXX,XX @@ static struct arm_boot_info aspeed_board_binfo = { | 37 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps nvic_systick_ops = { |
37 | typedef struct AspeedBoardState { | 38 | .endianness = DEVICE_NATIVE_ENDIAN, |
38 | AspeedSoCState soc; | ||
39 | MemoryRegion ram; | ||
40 | + MemoryRegion max_ram; | ||
41 | } AspeedBoardState; | ||
42 | |||
43 | typedef struct AspeedBoardConfig { | ||
44 | @@ -XXX,XX +XXX,XX @@ static const AspeedBoardConfig aspeed_boards[] = { | ||
45 | }, | ||
46 | }; | 39 | }; |
47 | 40 | ||
48 | +/* | 41 | + |
49 | + * The max ram region is for firmwares that scan the address space | 42 | +static MemTxResult ras_read(void *opaque, hwaddr addr, |
50 | + * with load/store to guess how much RAM the SoC has. | 43 | + uint64_t *data, unsigned size, |
51 | + */ | 44 | + MemTxAttrs attrs) |
52 | +static uint64_t max_ram_read(void *opaque, hwaddr offset, unsigned size) | ||
53 | +{ | 45 | +{ |
54 | + return 0; | 46 | + if (attrs.user) { |
47 | + return MEMTX_ERROR; | ||
48 | + } | ||
49 | + | ||
50 | + switch (addr) { | ||
51 | + case 0xe10: /* ERRIIDR */ | ||
52 | + /* architect field = Arm; product/variant/revision 0 */ | ||
53 | + *data = 0x43b; | ||
54 | + break; | ||
55 | + case 0xfc8: /* ERRDEVID */ | ||
56 | + /* Minimal RAS: we implement 0 error record indexes */ | ||
57 | + *data = 0; | ||
58 | + break; | ||
59 | + default: | ||
60 | + qemu_log_mask(LOG_UNIMP, "Read RAS register offset 0x%x\n", | ||
61 | + (uint32_t)addr); | ||
62 | + *data = 0; | ||
63 | + break; | ||
64 | + } | ||
65 | + return MEMTX_OK; | ||
55 | +} | 66 | +} |
56 | + | 67 | + |
57 | +static void max_ram_write(void *opaque, hwaddr offset, uint64_t value, | 68 | +static MemTxResult ras_write(void *opaque, hwaddr addr, |
58 | + unsigned size) | 69 | + uint64_t value, unsigned size, |
70 | + MemTxAttrs attrs) | ||
59 | +{ | 71 | +{ |
60 | + /* Discard writes */ | 72 | + if (attrs.user) { |
73 | + return MEMTX_ERROR; | ||
74 | + } | ||
75 | + | ||
76 | + switch (addr) { | ||
77 | + default: | ||
78 | + qemu_log_mask(LOG_UNIMP, "Write to RAS register offset 0x%x\n", | ||
79 | + (uint32_t)addr); | ||
80 | + break; | ||
81 | + } | ||
82 | + return MEMTX_OK; | ||
61 | +} | 83 | +} |
62 | + | 84 | + |
63 | +static const MemoryRegionOps max_ram_ops = { | 85 | +static const MemoryRegionOps ras_ops = { |
64 | + .read = max_ram_read, | 86 | + .read_with_attrs = ras_read, |
65 | + .write = max_ram_write, | 87 | + .write_with_attrs = ras_write, |
66 | + .endianness = DEVICE_NATIVE_ENDIAN, | 88 | + .endianness = DEVICE_NATIVE_ENDIAN, |
67 | +}; | 89 | +}; |
68 | + | 90 | + |
69 | #define FIRMWARE_ADDR 0x0 | 91 | /* |
70 | 92 | * Unassigned portions of the PPB space are RAZ/WI for privileged | |
71 | static void write_boot_rom(DriveInfo *dinfo, hwaddr addr, size_t rom_size, | 93 | * accesses, and fault for non-privileged accesses. |
72 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | 94 | @@ -XXX,XX +XXX,XX @@ static void armv7m_nvic_realize(DeviceState *dev, Error **errp) |
73 | AspeedBoardState *bmc; | 95 | &s->systick_ns_mem, 1); |
74 | AspeedSoCClass *sc; | 96 | } |
75 | DriveInfo *drive0 = drive_get(IF_MTD, 0, 0); | 97 | |
76 | + ram_addr_t max_ram_size; | 98 | + if (cpu_isar_feature(aa32_ras, s->cpu)) { |
77 | 99 | + memory_region_init_io(&s->ras_mem, OBJECT(s), | |
78 | bmc = g_new0(AspeedBoardState, 1); | 100 | + &ras_ops, s, "nvic_ras", 0x1000); |
79 | object_initialize(&bmc->soc, (sizeof(bmc->soc)), cfg->soc_name); | 101 | + memory_region_add_subregion(&s->container, 0x5000, &s->ras_mem); |
80 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | 102 | + } |
81 | object_property_add_const_link(OBJECT(&bmc->soc), "ram", OBJECT(&bmc->ram), | ||
82 | &error_abort); | ||
83 | |||
84 | + max_ram_size = object_property_get_uint(OBJECT(&bmc->soc), "max-ram-size", | ||
85 | + &error_abort); | ||
86 | + memory_region_init_io(&bmc->max_ram, NULL, &max_ram_ops, NULL, | ||
87 | + "max_ram", max_ram_size - ram_size); | ||
88 | + memory_region_add_subregion(get_system_memory(), | ||
89 | + sc->info->sdram_base + ram_size, | ||
90 | + &bmc->max_ram); | ||
91 | + | 103 | + |
92 | aspeed_board_init_flashes(&bmc->soc.fmc, cfg->fmc_model, &error_abort); | 104 | sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->container); |
93 | aspeed_board_init_flashes(&bmc->soc.spi[0], cfg->spi_model, &error_abort); | 105 | } |
94 | |||
95 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
96 | index XXXXXXX..XXXXXXX 100644 | ||
97 | --- a/hw/arm/aspeed_soc.c | ||
98 | +++ b/hw/arm/aspeed_soc.c | ||
99 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | ||
100 | sc->info->silicon_rev); | ||
101 | object_property_add_alias(obj, "ram-size", OBJECT(&s->sdmc), | ||
102 | "ram-size", &error_abort); | ||
103 | + object_property_add_alias(obj, "max-ram-size", OBJECT(&s->sdmc), | ||
104 | + "max-ram-size", &error_abort); | ||
105 | |||
106 | for (i = 0; i < sc->info->wdts_num; i++) { | ||
107 | object_initialize(&s->wdt[i], sizeof(s->wdt[i]), TYPE_ASPEED_WDT); | ||
108 | diff --git a/hw/misc/aspeed_sdmc.c b/hw/misc/aspeed_sdmc.c | ||
109 | index XXXXXXX..XXXXXXX 100644 | ||
110 | --- a/hw/misc/aspeed_sdmc.c | ||
111 | +++ b/hw/misc/aspeed_sdmc.c | ||
112 | @@ -XXX,XX +XXX,XX @@ static void aspeed_sdmc_realize(DeviceState *dev, Error **errp) | ||
113 | case AST2400_A0_SILICON_REV: | ||
114 | case AST2400_A1_SILICON_REV: | ||
115 | s->ram_bits = ast2400_rambits(s); | ||
116 | + s->max_ram_size = 512 << 20; | ||
117 | s->fixed_conf = ASPEED_SDMC_VGA_COMPAT | | ||
118 | ASPEED_SDMC_DRAM_SIZE(s->ram_bits); | ||
119 | break; | ||
120 | case AST2500_A0_SILICON_REV: | ||
121 | case AST2500_A1_SILICON_REV: | ||
122 | s->ram_bits = ast2500_rambits(s); | ||
123 | + s->max_ram_size = 1024 << 20; | ||
124 | s->fixed_conf = ASPEED_SDMC_HW_VERSION(1) | | ||
125 | ASPEED_SDMC_VGA_APERTURE(ASPEED_SDMC_VGA_64MB) | | ||
126 | ASPEED_SDMC_CACHE_INITIAL_DONE | | ||
127 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_aspeed_sdmc = { | ||
128 | static Property aspeed_sdmc_properties[] = { | ||
129 | DEFINE_PROP_UINT32("silicon-rev", AspeedSDMCState, silicon_rev, 0), | ||
130 | DEFINE_PROP_UINT64("ram-size", AspeedSDMCState, ram_size, 0), | ||
131 | + DEFINE_PROP_UINT64("max-ram-size", AspeedSDMCState, max_ram_size, 0), | ||
132 | DEFINE_PROP_END_OF_LIST(), | ||
133 | }; | ||
134 | 106 | ||
135 | -- | 107 | -- |
136 | 2.18.0 | 108 | 2.20.1 |
137 | 109 | ||
138 | 110 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Correct a typo in the name we give the NVIC object. |
---|---|---|---|
2 | 2 | ||
3 | Cc: qemu-stable@nongnu.org (3.0.1) | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20201119215617.29887-28-peter.maydell@linaro.org | ||
7 | --- | 7 | --- |
8 | target/arm/sve_helper.c | 2 +- | 8 | hw/arm/armv7m.c | 2 +- |
9 | 1 file changed, 1 insertion(+), 1 deletion(-) | 9 | 1 file changed, 1 insertion(+), 1 deletion(-) |
10 | 10 | ||
11 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | 11 | diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c |
12 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/sve_helper.c | 13 | --- a/hw/arm/armv7m.c |
14 | +++ b/target/arm/sve_helper.c | 14 | +++ b/hw/arm/armv7m.c |
15 | @@ -XXX,XX +XXX,XX @@ DO_LD1(sve_ld1bdu_r, cpu_ldub_data_ra, uint64_t, uint8_t, ) | 15 | @@ -XXX,XX +XXX,XX @@ static void armv7m_instance_init(Object *obj) |
16 | DO_LD1(sve_ld1bds_r, cpu_ldsb_data_ra, uint64_t, int8_t, ) | 16 | |
17 | 17 | memory_region_init(&s->container, obj, "armv7m-container", UINT64_MAX); | |
18 | DO_LD1(sve_ld1hsu_r, cpu_lduw_data_ra, uint32_t, uint16_t, H1_4) | 18 | |
19 | -DO_LD1(sve_ld1hss_r, cpu_ldsw_data_ra, uint32_t, int8_t, H1_4) | 19 | - object_initialize_child(obj, "nvnic", &s->nvic, TYPE_NVIC); |
20 | +DO_LD1(sve_ld1hss_r, cpu_ldsw_data_ra, uint32_t, int16_t, H1_4) | 20 | + object_initialize_child(obj, "nvic", &s->nvic, TYPE_NVIC); |
21 | DO_LD1(sve_ld1hdu_r, cpu_lduw_data_ra, uint64_t, uint16_t, ) | 21 | object_property_add_alias(obj, "num-irq", |
22 | DO_LD1(sve_ld1hds_r, cpu_ldsw_data_ra, uint64_t, int16_t, ) | 22 | OBJECT(&s->nvic), "num-irq"); |
23 | 23 | ||
24 | -- | 24 | -- |
25 | 2.18.0 | 25 | 2.20.1 |
26 | 26 | ||
27 | 27 | diff view generated by jsdifflib |