1 | Most of this is the Neon decodetree patches, followed by Edgar's versal cleanups. | 1 | First arm pullreq of the 5.1 cycle; mostly bugfixes and some |
---|---|---|---|
2 | cleanup patches. The new clock modelling framework is the big | ||
3 | thing here. | ||
2 | 4 | ||
3 | thanks | ||
4 | -- PMM | 5 | -- PMM |
5 | 6 | ||
7 | The following changes since commit 648db19685b7030aa558a4ddbd3a8e53d8c9a062: | ||
6 | 8 | ||
7 | The following changes since commit 2ef486e76d64436be90f7359a3071fb2a56ce835: | 9 | Merge remote-tracking branch 'remotes/armbru/tags/pull-misc-2020-04-29' into staging (2020-04-29 15:07:33 +0100) |
8 | |||
9 | Merge remote-tracking branch 'remotes/marcel/tags/rdma-pull-request' into staging (2020-05-03 14:12:56 +0100) | ||
10 | 10 | ||
11 | are available in the Git repository at: | 11 | are available in the Git repository at: |
12 | 12 | ||
13 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200504 | 13 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200430 |
14 | 14 | ||
15 | for you to fetch changes up to 9aefc6cf9b73f66062d2f914a0136756e7a28211: | 15 | for you to fetch changes up to 1267437e593e85498f9105b3bdab796630d2e83f: |
16 | 16 | ||
17 | target/arm: Move gen_ function typedefs to translate.h (2020-05-04 12:59:26 +0100) | 17 | hw/arm: xlnx-zcu102: Disable unsupported FDT firmware nodes (2020-04-30 11:52:29 +0100) |
18 | 18 | ||
19 | ---------------------------------------------------------------- | 19 | ---------------------------------------------------------------- |
20 | target-arm queue: | 20 | target-arm queue: |
21 | * Start of conversion of Neon insns to decodetree | 21 | * xlnx-zdma: Fix endianness handling of descriptor loading |
22 | * versal board: support SD and RTC | 22 | * nrf51: Fix last GPIO CNF address |
23 | * Implement ARMv8.2-TTS2UXN | 23 | * gicv3: Use gicr_typer in arm_gicv3_icc_reset |
24 | * Make VQDMULL undefined when U=1 | 24 | * msf2: Add EMAC block to SmartFusion2 SoC |
25 | * Some minor code cleanups | 25 | * New clock modelling framework |
26 | * hw/arm: versal: Setup the ADMA with 128bit bus-width | ||
27 | * Cadence: gem: fix wraparound in 64bit descriptors | ||
28 | * cadence_gem: clear RX control descriptor | ||
29 | * target/arm: Vectorize integer comparison vs zero | ||
30 | * hw/arm/virt: dt: add kaslr-seed property | ||
31 | * hw/arm: xlnx-zcu102: Disable unsupported FDT firmware nodes | ||
26 | 32 | ||
27 | ---------------------------------------------------------------- | 33 | ---------------------------------------------------------------- |
28 | Edgar E. Iglesias (11): | 34 | Cameron Esfahani (1): |
29 | hw/arm: versal: Remove inclusion of arm_gicv3_common.h | 35 | nrf51: Fix last GPIO CNF address |
30 | hw/arm: versal: Move misplaced comment | ||
31 | hw/arm: versal-virt: Fix typo xlnx-ve -> xlnx-versal | ||
32 | hw/arm: versal: Embed the UARTs into the SoC type | ||
33 | hw/arm: versal: Embed the GEMs into the SoC type | ||
34 | hw/arm: versal: Embed the ADMAs into the SoC type | ||
35 | hw/arm: versal: Embed the APUs into the SoC type | ||
36 | hw/arm: versal: Add support for SD | ||
37 | hw/arm: versal: Add support for the RTC | ||
38 | hw/arm: versal-virt: Add support for SD | ||
39 | hw/arm: versal-virt: Add support for the RTC | ||
40 | 36 | ||
41 | Fredrik Strupe (1): | 37 | Damien Hedde (7): |
42 | target/arm: Make VQDMULL undefined when U=1 | 38 | hw/core/clock-vmstate: define a vmstate entry for clock state |
39 | qdev: add clock input&output support to devices. | ||
40 | qdev-clock: introduce an init array to ease the device construction | ||
41 | hw/misc/zynq_slcr: add clock generation for uarts | ||
42 | hw/char/cadence_uart: add clock support | ||
43 | hw/arm/xilinx_zynq: connect uart clocks to slcr | ||
44 | qdev-monitor: print the device's clock with info qtree | ||
43 | 45 | ||
44 | Peter Maydell (25): | 46 | Edgar E. Iglesias (7): |
45 | target/arm: Don't use a TLB for ARMMMUIdx_Stage2 | 47 | dma/xlnx-zdma: Fix descriptor loading (MEM) wrt endianness |
46 | target/arm: Use enum constant in get_phys_addr_lpae() call | 48 | dma/xlnx-zdma: Fix descriptor loading (REG) wrt endianness |
47 | target/arm: Add new 's1_is_el0' argument to get_phys_addr_lpae() | 49 | hw/arm: versal: Setup the ADMA with 128bit bus-width |
48 | target/arm: Implement ARMv8.2-TTS2UXN | 50 | device_tree: Allow name wildcards in qemu_fdt_node_path() |
49 | target/arm: Use correct variable for setting 'max' cpu's ID_AA64DFR0 | 51 | device_tree: Constify compat in qemu_fdt_node_path() |
50 | target/arm/translate-vfp.inc.c: Remove duplicate simd_r32 check | 52 | hw/arm: xlnx-zcu102: Move arm_boot_info into XlnxZCU102 |
51 | target/arm: Don't allow Thumb Neon insns without FEATURE_NEON | 53 | hw/arm: xlnx-zcu102: Disable unsupported FDT firmware nodes |
52 | target/arm: Add stubs for AArch32 Neon decodetree | ||
53 | target/arm: Convert VCMLA (vector) to decodetree | ||
54 | target/arm: Convert VCADD (vector) to decodetree | ||
55 | target/arm: Convert V[US]DOT (vector) to decodetree | ||
56 | target/arm: Convert VFM[AS]L (vector) to decodetree | ||
57 | target/arm: Convert VCMLA (scalar) to decodetree | ||
58 | target/arm: Convert V[US]DOT (scalar) to decodetree | ||
59 | target/arm: Convert VFM[AS]L (scalar) to decodetree | ||
60 | target/arm: Convert Neon load/store multiple structures to decodetree | ||
61 | target/arm: Convert Neon 'load single structure to all lanes' to decodetree | ||
62 | target/arm: Convert Neon 'load/store single structure' to decodetree | ||
63 | target/arm: Convert Neon 3-reg-same VADD/VSUB to decodetree | ||
64 | target/arm: Convert Neon 3-reg-same logic ops to decodetree | ||
65 | target/arm: Convert Neon 3-reg-same VMAX/VMIN to decodetree | ||
66 | target/arm: Convert Neon 3-reg-same comparisons to decodetree | ||
67 | target/arm: Convert Neon 3-reg-same VQADD/VQSUB to decodetree | ||
68 | target/arm: Convert Neon 3-reg-same VMUL, VMLA, VMLS, VSHL to decodetree | ||
69 | target/arm: Move gen_ function typedefs to translate.h | ||
70 | 54 | ||
71 | Philippe Mathieu-Daudé (2): | 55 | Jerome Forissier (2): |
72 | hw/arm/mps2-tz: Use TYPE_IOTKIT instead of hardcoded string | 56 | hw/arm/virt: dt: move creation of /secure-chosen to create_fdt() |
73 | target/arm: Use uint64_t for midr field in CPU state struct | 57 | hw/arm/virt: dt: add kaslr-seed property |
74 | 58 | ||
75 | include/hw/arm/xlnx-versal.h | 31 +- | 59 | Keqian Zhu (2): |
76 | target/arm/cpu-param.h | 2 +- | 60 | bugfix: Use gicr_typer in arm_gicv3_icc_reset |
77 | target/arm/cpu.h | 38 ++- | 61 | Typo: Correct the name of CPU hotplug memory region |
78 | target/arm/translate-a64.h | 9 - | ||
79 | target/arm/translate.h | 26 ++ | ||
80 | target/arm/neon-dp.decode | 86 +++++ | ||
81 | target/arm/neon-ls.decode | 52 +++ | ||
82 | target/arm/neon-shared.decode | 66 ++++ | ||
83 | hw/arm/mps2-tz.c | 2 +- | ||
84 | hw/arm/xlnx-versal-virt.c | 74 ++++- | ||
85 | hw/arm/xlnx-versal.c | 115 +++++-- | ||
86 | target/arm/cpu.c | 3 +- | ||
87 | target/arm/cpu64.c | 8 +- | ||
88 | target/arm/helper.c | 183 ++++------ | ||
89 | target/arm/translate-a64.c | 17 - | ||
90 | target/arm/translate-neon.inc.c | 714 +++++++++++++++++++++++++++++++++++++++ | ||
91 | target/arm/translate-vfp.inc.c | 6 - | ||
92 | target/arm/translate.c | 716 +++------------------------------------- | ||
93 | target/arm/Makefile.objs | 18 + | ||
94 | 19 files changed, 1302 insertions(+), 864 deletions(-) | ||
95 | create mode 100644 target/arm/neon-dp.decode | ||
96 | create mode 100644 target/arm/neon-ls.decode | ||
97 | create mode 100644 target/arm/neon-shared.decode | ||
98 | create mode 100644 target/arm/translate-neon.inc.c | ||
99 | 62 | ||
63 | Peter Maydell (2): | ||
64 | hw/core/clock: introduce clock object | ||
65 | docs/clocks: add device's clock documentation | ||
66 | |||
67 | Philippe Mathieu-Daudé (3): | ||
68 | target/arm: Restrict the Address Translate write operation to TCG accel | ||
69 | target/arm/cpu: Use ARRAY_SIZE() to iterate over ARMCPUInfo[] | ||
70 | target/arm/cpu: Update coding style to make checkpatch.pl happy | ||
71 | |||
72 | Ramon Fried (2): | ||
73 | Cadence: gem: fix wraparound in 64bit descriptors | ||
74 | net: cadence_gem: clear RX control descriptor | ||
75 | |||
76 | Richard Henderson (1): | ||
77 | target/arm: Vectorize integer comparison vs zero | ||
78 | |||
79 | Subbaraya Sundeep (3): | ||
80 | hw/net: Add Smartfusion2 emac block | ||
81 | msf2: Add EMAC block to SmartFusion2 SoC | ||
82 | tests/boot_linux_console: Add ethernet test to SmartFusion2 | ||
83 | |||
84 | Thomas Huth (1): | ||
85 | target/arm: Make cpu_register() available for other files | ||
86 | |||
87 | hw/core/Makefile.objs | 2 + | ||
88 | hw/net/Makefile.objs | 1 + | ||
89 | tests/Makefile.include | 1 + | ||
90 | include/hw/arm/msf2-soc.h | 2 + | ||
91 | include/hw/char/cadence_uart.h | 1 + | ||
92 | include/hw/clock.h | 225 +++++++++++++ | ||
93 | include/hw/gpio/nrf51_gpio.h | 2 +- | ||
94 | include/hw/net/msf2-emac.h | 53 +++ | ||
95 | include/hw/qdev-clock.h | 159 +++++++++ | ||
96 | include/hw/qdev-core.h | 12 + | ||
97 | include/sysemu/device_tree.h | 5 +- | ||
98 | target/arm/cpu-qom.h | 9 +- | ||
99 | target/arm/helper.h | 27 +- | ||
100 | target/arm/translate.h | 5 + | ||
101 | device_tree.c | 4 +- | ||
102 | hw/acpi/cpu.c | 2 +- | ||
103 | hw/arm/msf2-soc.c | 26 +- | ||
104 | hw/arm/virt.c | 20 +- | ||
105 | hw/arm/xilinx_zynq.c | 57 +++- | ||
106 | hw/arm/xlnx-versal.c | 2 + | ||
107 | hw/arm/xlnx-zcu102.c | 39 ++- | ||
108 | hw/char/cadence_uart.c | 73 +++- | ||
109 | hw/core/clock-vmstate.c | 25 ++ | ||
110 | hw/core/clock.c | 130 ++++++++ | ||
111 | hw/core/qdev-clock.c | 185 +++++++++++ | ||
112 | hw/core/qdev.c | 12 + | ||
113 | hw/dma/xlnx-zdma.c | 25 +- | ||
114 | hw/intc/arm_gicv3_kvm.c | 4 +- | ||
115 | hw/misc/zynq_slcr.c | 172 +++++++++- | ||
116 | hw/net/cadence_gem.c | 16 +- | ||
117 | hw/net/msf2-emac.c | 589 +++++++++++++++++++++++++++++++++ | ||
118 | qdev-monitor.c | 9 + | ||
119 | target/arm/cpu.c | 25 +- | ||
120 | target/arm/cpu64.c | 16 +- | ||
121 | target/arm/helper.c | 17 + | ||
122 | target/arm/neon_helper.c | 24 -- | ||
123 | target/arm/translate-a64.c | 64 +--- | ||
124 | target/arm/translate.c | 256 ++++++++++++-- | ||
125 | target/arm/vec_helper.c | 25 ++ | ||
126 | MAINTAINERS | 2 + | ||
127 | docs/devel/clocks.rst | 391 ++++++++++++++++++++++ | ||
128 | docs/devel/index.rst | 1 + | ||
129 | hw/char/trace-events | 3 + | ||
130 | hw/core/trace-events | 7 + | ||
131 | tests/acceptance/boot_linux_console.py | 15 +- | ||
132 | 45 files changed, 2538 insertions(+), 202 deletions(-) | ||
133 | create mode 100644 include/hw/clock.h | ||
134 | create mode 100644 include/hw/net/msf2-emac.h | ||
135 | create mode 100644 include/hw/qdev-clock.h | ||
136 | create mode 100644 hw/core/clock-vmstate.c | ||
137 | create mode 100644 hw/core/clock.c | ||
138 | create mode 100644 hw/core/qdev-clock.c | ||
139 | create mode 100644 hw/net/msf2-emac.c | ||
140 | create mode 100644 docs/devel/clocks.rst | ||
141 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> |
---|---|---|---|
2 | 2 | ||
3 | Fix typo xlnx-ve -> xlnx-versal. | 3 | Fix descriptor loading from memory wrt host endianness. |
4 | 4 | ||
5 | Reported-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 6 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> |
6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 7 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> |
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
8 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | 9 | Message-id: 20200404122718.25111-2-edgar.iglesias@gmail.com |
9 | Message-id: 20200427181649.26851-4-edgar.iglesias@gmail.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 11 | --- |
12 | hw/arm/xlnx-versal-virt.c | 2 +- | 12 | hw/dma/xlnx-zdma.c | 11 +++++++---- |
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | 13 | 1 file changed, 7 insertions(+), 4 deletions(-) |
14 | 14 | ||
15 | diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c | 15 | diff --git a/hw/dma/xlnx-zdma.c b/hw/dma/xlnx-zdma.c |
16 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/xlnx-versal-virt.c | 17 | --- a/hw/dma/xlnx-zdma.c |
18 | +++ b/hw/arm/xlnx-versal-virt.c | 18 | +++ b/hw/dma/xlnx-zdma.c |
19 | @@ -XXX,XX +XXX,XX @@ static void versal_virt_init(MachineState *machine) | 19 | @@ -XXX,XX +XXX,XX @@ static void zdma_put_regaddr64(XlnxZDMA *s, unsigned int basereg, uint64_t addr) |
20 | psci_conduit = QEMU_PSCI_CONDUIT_SMC; | 20 | s->regs[basereg + 1] = addr >> 32; |
21 | } | ||
22 | |||
23 | -static bool zdma_load_descriptor(XlnxZDMA *s, uint64_t addr, void *buf) | ||
24 | +static bool zdma_load_descriptor(XlnxZDMA *s, uint64_t addr, | ||
25 | + XlnxZDMADescr *descr) | ||
26 | { | ||
27 | /* ZDMA descriptors must be aligned to their own size. */ | ||
28 | if (addr % sizeof(XlnxZDMADescr)) { | ||
29 | qemu_log_mask(LOG_GUEST_ERROR, | ||
30 | "zdma: unaligned descriptor at %" PRIx64, | ||
31 | addr); | ||
32 | - memset(buf, 0x0, sizeof(XlnxZDMADescr)); | ||
33 | + memset(descr, 0x0, sizeof(XlnxZDMADescr)); | ||
34 | s->error = true; | ||
35 | return false; | ||
21 | } | 36 | } |
22 | 37 | ||
23 | - sysbus_init_child_obj(OBJECT(machine), "xlnx-ve", &s->soc, | 38 | - address_space_read(s->dma_as, addr, s->attr, buf, sizeof(XlnxZDMADescr)); |
24 | + sysbus_init_child_obj(OBJECT(machine), "xlnx-versal", &s->soc, | 39 | + descr->addr = address_space_ldq_le(s->dma_as, addr, s->attr, NULL); |
25 | sizeof(s->soc), TYPE_XLNX_VERSAL); | 40 | + descr->size = address_space_ldl_le(s->dma_as, addr + 8, s->attr, NULL); |
26 | object_property_set_link(OBJECT(&s->soc), OBJECT(machine->ram), | 41 | + descr->attr = address_space_ldl_le(s->dma_as, addr + 12, s->attr, NULL); |
27 | "ddr", &error_abort); | 42 | return true; |
43 | } | ||
44 | |||
45 | @@ -XXX,XX +XXX,XX @@ static void zdma_update_descr_addr(XlnxZDMA *s, bool type, | ||
46 | } else { | ||
47 | addr = zdma_get_regaddr64(s, basereg); | ||
48 | addr += sizeof(s->dsc_dst); | ||
49 | - address_space_read(s->dma_as, addr, s->attr, (void *) &next, 8); | ||
50 | + next = address_space_ldq_le(s->dma_as, addr, s->attr, NULL); | ||
51 | } | ||
52 | |||
53 | zdma_put_regaddr64(s, basereg, next); | ||
28 | -- | 54 | -- |
29 | 2.20.1 | 55 | 2.20.1 |
30 | 56 | ||
31 | 57 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> |
---|---|---|---|
2 | 2 | ||
3 | hw/arm: versal: Add support for the RTC. | 3 | Fix descriptor loading from registers wrt host endianness. |
4 | 4 | ||
5 | Reported-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 6 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> |
7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 8 | Message-id: 20200404122718.25111-3-edgar.iglesias@gmail.com |
8 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | ||
9 | Message-id: 20200427181649.26851-10-edgar.iglesias@gmail.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 10 | --- |
12 | include/hw/arm/xlnx-versal.h | 8 ++++++++ | 11 | hw/dma/xlnx-zdma.c | 14 ++++++++++---- |
13 | hw/arm/xlnx-versal.c | 21 +++++++++++++++++++++ | 12 | 1 file changed, 10 insertions(+), 4 deletions(-) |
14 | 2 files changed, 29 insertions(+) | ||
15 | 13 | ||
16 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h | 14 | diff --git a/hw/dma/xlnx-zdma.c b/hw/dma/xlnx-zdma.c |
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/include/hw/arm/xlnx-versal.h | 16 | --- a/hw/dma/xlnx-zdma.c |
19 | +++ b/include/hw/arm/xlnx-versal.h | 17 | +++ b/hw/dma/xlnx-zdma.c |
20 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ static void zdma_put_regaddr64(XlnxZDMA *s, unsigned int basereg, uint64_t addr) |
21 | #include "hw/char/pl011.h" | 19 | s->regs[basereg + 1] = addr >> 32; |
22 | #include "hw/dma/xlnx-zdma.h" | ||
23 | #include "hw/net/cadence_gem.h" | ||
24 | +#include "hw/rtc/xlnx-zynqmp-rtc.h" | ||
25 | |||
26 | #define TYPE_XLNX_VERSAL "xlnx-versal" | ||
27 | #define XLNX_VERSAL(obj) OBJECT_CHECK(Versal, (obj), TYPE_XLNX_VERSAL) | ||
28 | @@ -XXX,XX +XXX,XX @@ typedef struct Versal { | ||
29 | struct { | ||
30 | SDHCIState sd[XLNX_VERSAL_NR_SDS]; | ||
31 | } iou; | ||
32 | + | ||
33 | + XlnxZynqMPRTC rtc; | ||
34 | } pmc; | ||
35 | |||
36 | struct { | ||
37 | @@ -XXX,XX +XXX,XX @@ typedef struct Versal { | ||
38 | #define VERSAL_GEM1_IRQ_0 58 | ||
39 | #define VERSAL_GEM1_WAKE_IRQ_0 59 | ||
40 | #define VERSAL_ADMA_IRQ_0 60 | ||
41 | +#define VERSAL_RTC_APB_ERR_IRQ 121 | ||
42 | #define VERSAL_SD0_IRQ_0 126 | ||
43 | +#define VERSAL_RTC_ALARM_IRQ 142 | ||
44 | +#define VERSAL_RTC_SECONDS_IRQ 143 | ||
45 | |||
46 | /* Architecturally reserved IRQs suitable for virtualization. */ | ||
47 | #define VERSAL_RSVD_IRQ_FIRST 111 | ||
48 | @@ -XXX,XX +XXX,XX @@ typedef struct Versal { | ||
49 | #define MM_PMC_SD0_SIZE 0x10000 | ||
50 | #define MM_PMC_CRP 0xf1260000U | ||
51 | #define MM_PMC_CRP_SIZE 0x10000 | ||
52 | +#define MM_PMC_RTC 0xf12a0000 | ||
53 | +#define MM_PMC_RTC_SIZE 0x10000 | ||
54 | #endif | ||
55 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/hw/arm/xlnx-versal.c | ||
58 | +++ b/hw/arm/xlnx-versal.c | ||
59 | @@ -XXX,XX +XXX,XX @@ static void versal_create_sds(Versal *s, qemu_irq *pic) | ||
60 | } | ||
61 | } | 20 | } |
62 | 21 | ||
63 | +static void versal_create_rtc(Versal *s, qemu_irq *pic) | 22 | +static void zdma_load_descriptor_reg(XlnxZDMA *s, unsigned int reg, |
23 | + XlnxZDMADescr *descr) | ||
64 | +{ | 24 | +{ |
65 | + SysBusDevice *sbd; | 25 | + descr->addr = zdma_get_regaddr64(s, reg); |
66 | + MemoryRegion *mr; | 26 | + descr->size = s->regs[reg + 2]; |
67 | + | 27 | + descr->attr = s->regs[reg + 3]; |
68 | + sysbus_init_child_obj(OBJECT(s), "rtc", &s->pmc.rtc, sizeof(s->pmc.rtc), | ||
69 | + TYPE_XLNX_ZYNQMP_RTC); | ||
70 | + sbd = SYS_BUS_DEVICE(&s->pmc.rtc); | ||
71 | + qdev_init_nofail(DEVICE(sbd)); | ||
72 | + | ||
73 | + mr = sysbus_mmio_get_region(sbd, 0); | ||
74 | + memory_region_add_subregion(&s->mr_ps, MM_PMC_RTC, mr); | ||
75 | + | ||
76 | + /* | ||
77 | + * TODO: Connect the ALARM and SECONDS interrupts once our RTC model | ||
78 | + * supports them. | ||
79 | + */ | ||
80 | + sysbus_connect_irq(sbd, 1, pic[VERSAL_RTC_APB_ERR_IRQ]); | ||
81 | +} | 28 | +} |
82 | + | 29 | + |
83 | /* This takes the board allocated linear DDR memory and creates aliases | 30 | static bool zdma_load_descriptor(XlnxZDMA *s, uint64_t addr, |
84 | * for each split DDR range/aperture on the Versal address map. | 31 | XlnxZDMADescr *descr) |
85 | */ | 32 | { |
86 | @@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp) | 33 | @@ -XXX,XX +XXX,XX @@ static void zdma_load_src_descriptor(XlnxZDMA *s) |
87 | versal_create_gems(s, pic); | 34 | unsigned int ptype = ARRAY_FIELD_EX32(s->regs, ZDMA_CH_CTRL0, POINT_TYPE); |
88 | versal_create_admas(s, pic); | 35 | |
89 | versal_create_sds(s, pic); | 36 | if (ptype == PT_REG) { |
90 | + versal_create_rtc(s, pic); | 37 | - memcpy(&s->dsc_src, &s->regs[R_ZDMA_CH_SRC_DSCR_WORD0], |
91 | versal_map_ddr(s); | 38 | - sizeof(s->dsc_src)); |
92 | versal_unimp(s); | 39 | + zdma_load_descriptor_reg(s, R_ZDMA_CH_SRC_DSCR_WORD0, &s->dsc_src); |
40 | return; | ||
41 | } | ||
42 | |||
43 | @@ -XXX,XX +XXX,XX @@ static void zdma_load_dst_descriptor(XlnxZDMA *s) | ||
44 | bool dst_type; | ||
45 | |||
46 | if (ptype == PT_REG) { | ||
47 | - memcpy(&s->dsc_dst, &s->regs[R_ZDMA_CH_DST_DSCR_WORD0], | ||
48 | - sizeof(s->dsc_dst)); | ||
49 | + zdma_load_descriptor_reg(s, R_ZDMA_CH_DST_DSCR_WORD0, &s->dsc_dst); | ||
50 | return; | ||
51 | } | ||
93 | 52 | ||
94 | -- | 53 | -- |
95 | 2.20.1 | 54 | 2.20.1 |
96 | 55 | ||
97 | 56 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Cameron Esfahani <dirty@apple.com> |
---|---|---|---|
2 | 2 | ||
3 | By using the TYPE_* definitions for devices, we can: | 3 | NRF51_GPIO_REG_CNF_END doesn't actually refer to the start of the last |
4 | - quickly find where devices are used with 'git-grep' | 4 | valid CNF register: it's referring to the last byte of the last valid |
5 | - easily rename a device (one-line change). | 5 | CNF register. |
6 | 6 | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | This hasn't been a problem up to now, as current implementation in |
8 | Message-id: 20200428154650.21991-1-f4bug@amsat.org | 8 | memory.c turns an unaligned 4-byte read from 0x77f to a single byte read |
9 | and the qtest only looks at the least-significant byte of the register. | ||
10 | |||
11 | But when running with patches which fix unaligned accesses in memory.c, | ||
12 | the qtest breaks. | ||
13 | |||
14 | Considering NRF51 doesn't support unaligned accesses, the simplest fix | ||
15 | is to actually set NRF51_GPIO_REG_CNF_END to the start of the last valid | ||
16 | CNF register: 0x77c. | ||
17 | |||
18 | Now, qtests work with or without the unaligned access patches. | ||
19 | |||
20 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
21 | Tested-by: Cédric Le Goater <clg@kaod.org> | ||
22 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
23 | Signed-off-by: Cameron Esfahani <dirty@apple.com> | ||
24 | Message-id: 51b427f06838622da783d38ba56e3630d6d85c60.1586925392.git.dirty@apple.com | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 25 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 26 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 27 | --- |
12 | hw/arm/mps2-tz.c | 2 +- | 28 | include/hw/gpio/nrf51_gpio.h | 2 +- |
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | 29 | 1 file changed, 1 insertion(+), 1 deletion(-) |
14 | 30 | ||
15 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | 31 | diff --git a/include/hw/gpio/nrf51_gpio.h b/include/hw/gpio/nrf51_gpio.h |
16 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/mps2-tz.c | 33 | --- a/include/hw/gpio/nrf51_gpio.h |
18 | +++ b/hw/arm/mps2-tz.c | 34 | +++ b/include/hw/gpio/nrf51_gpio.h |
19 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | 35 | @@ -XXX,XX +XXX,XX @@ |
20 | exit(EXIT_FAILURE); | 36 | #define NRF51_GPIO_REG_DIRSET 0x518 |
21 | } | 37 | #define NRF51_GPIO_REG_DIRCLR 0x51C |
22 | 38 | #define NRF51_GPIO_REG_CNF_START 0x700 | |
23 | - sysbus_init_child_obj(OBJECT(machine), "iotkit", &mms->iotkit, | 39 | -#define NRF51_GPIO_REG_CNF_END 0x77F |
24 | + sysbus_init_child_obj(OBJECT(machine), TYPE_IOTKIT, &mms->iotkit, | 40 | +#define NRF51_GPIO_REG_CNF_END 0x77C |
25 | sizeof(mms->iotkit), mmc->armsse_type); | 41 | |
26 | iotkitdev = DEVICE(&mms->iotkit); | 42 | #define NRF51_GPIO_PULLDOWN 1 |
27 | object_property_set_link(OBJECT(&mms->iotkit), OBJECT(system_memory), | 43 | #define NRF51_GPIO_PULLUP 3 |
28 | -- | 44 | -- |
29 | 2.20.1 | 45 | 2.20.1 |
30 | 46 | ||
31 | 47 | diff view generated by jsdifflib |
1 | We're going to want at least some of the NeonGen* typedefs | 1 | From: Keqian Zhu <zhukeqian1@huawei.com> |
---|---|---|---|
2 | for the refactored 32-bit Neon decoder, so move them all | ||
3 | to translate.h since it makes more sense to keep them in | ||
4 | one group. | ||
5 | 2 | ||
3 | The KVM_VGIC_ATTR macro expect the second parameter as gicr_typer, | ||
4 | of which high 32bit is constructed by mp_affinity. For most case, | ||
5 | the high 32bit of mp_affinity is zero, so it will always access the | ||
6 | ICC_CTLR_EL1 of CPU0. | ||
7 | |||
8 | Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com> | ||
9 | Message-id: 20200413091552.62748-2-zhukeqian1@huawei.com | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20200430181003.21682-23-peter.maydell@linaro.org | ||
9 | --- | 12 | --- |
10 | target/arm/translate.h | 17 +++++++++++++++++ | 13 | hw/intc/arm_gicv3_kvm.c | 4 +--- |
11 | target/arm/translate-a64.c | 17 ----------------- | 14 | 1 file changed, 1 insertion(+), 3 deletions(-) |
12 | 2 files changed, 17 insertions(+), 17 deletions(-) | ||
13 | 15 | ||
14 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 16 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.h | 18 | --- a/hw/intc/arm_gicv3_kvm.c |
17 | +++ b/target/arm/translate.h | 19 | +++ b/hw/intc/arm_gicv3_kvm.c |
18 | @@ -XXX,XX +XXX,XX @@ typedef void GVecGen3Fn(unsigned, uint32_t, uint32_t, | 20 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_get(GICv3State *s) |
19 | typedef void GVecGen4Fn(unsigned, uint32_t, uint32_t, uint32_t, | 21 | |
20 | uint32_t, uint32_t, uint32_t); | 22 | static void arm_gicv3_icc_reset(CPUARMState *env, const ARMCPRegInfo *ri) |
21 | |||
22 | +/* Function prototype for gen_ functions for calling Neon helpers */ | ||
23 | +typedef void NeonGenOneOpEnvFn(TCGv_i32, TCGv_ptr, TCGv_i32); | ||
24 | +typedef void NeonGenTwoOpFn(TCGv_i32, TCGv_i32, TCGv_i32); | ||
25 | +typedef void NeonGenTwoOpEnvFn(TCGv_i32, TCGv_ptr, TCGv_i32, TCGv_i32); | ||
26 | +typedef void NeonGenTwo64OpFn(TCGv_i64, TCGv_i64, TCGv_i64); | ||
27 | +typedef void NeonGenTwo64OpEnvFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i64); | ||
28 | +typedef void NeonGenNarrowFn(TCGv_i32, TCGv_i64); | ||
29 | +typedef void NeonGenNarrowEnvFn(TCGv_i32, TCGv_ptr, TCGv_i64); | ||
30 | +typedef void NeonGenWidenFn(TCGv_i64, TCGv_i32); | ||
31 | +typedef void NeonGenTwoSingleOPFn(TCGv_i32, TCGv_i32, TCGv_i32, TCGv_ptr); | ||
32 | +typedef void NeonGenTwoDoubleOPFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGv_ptr); | ||
33 | +typedef void NeonGenOneOpFn(TCGv_i64, TCGv_i64); | ||
34 | +typedef void CryptoTwoOpFn(TCGv_ptr, TCGv_ptr); | ||
35 | +typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
36 | +typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
37 | +typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); | ||
38 | + | ||
39 | #endif /* TARGET_ARM_TRANSLATE_H */ | ||
40 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/arm/translate-a64.c | ||
43 | +++ b/target/arm/translate-a64.c | ||
44 | @@ -XXX,XX +XXX,XX @@ typedef struct AArch64DecodeTable { | ||
45 | AArch64DecodeFn *disas_fn; | ||
46 | } AArch64DecodeTable; | ||
47 | |||
48 | -/* Function prototype for gen_ functions for calling Neon helpers */ | ||
49 | -typedef void NeonGenOneOpEnvFn(TCGv_i32, TCGv_ptr, TCGv_i32); | ||
50 | -typedef void NeonGenTwoOpFn(TCGv_i32, TCGv_i32, TCGv_i32); | ||
51 | -typedef void NeonGenTwoOpEnvFn(TCGv_i32, TCGv_ptr, TCGv_i32, TCGv_i32); | ||
52 | -typedef void NeonGenTwo64OpFn(TCGv_i64, TCGv_i64, TCGv_i64); | ||
53 | -typedef void NeonGenTwo64OpEnvFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i64); | ||
54 | -typedef void NeonGenNarrowFn(TCGv_i32, TCGv_i64); | ||
55 | -typedef void NeonGenNarrowEnvFn(TCGv_i32, TCGv_ptr, TCGv_i64); | ||
56 | -typedef void NeonGenWidenFn(TCGv_i64, TCGv_i32); | ||
57 | -typedef void NeonGenTwoSingleOPFn(TCGv_i32, TCGv_i32, TCGv_i32, TCGv_ptr); | ||
58 | -typedef void NeonGenTwoDoubleOPFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGv_ptr); | ||
59 | -typedef void NeonGenOneOpFn(TCGv_i64, TCGv_i64); | ||
60 | -typedef void CryptoTwoOpFn(TCGv_ptr, TCGv_ptr); | ||
61 | -typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
62 | -typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
63 | -typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); | ||
64 | - | ||
65 | /* initialize TCG globals. */ | ||
66 | void a64_translate_init(void) | ||
67 | { | 23 | { |
24 | - ARMCPU *cpu; | ||
25 | GICv3State *s; | ||
26 | GICv3CPUState *c; | ||
27 | |||
28 | c = (GICv3CPUState *)env->gicv3state; | ||
29 | s = c->gic; | ||
30 | - cpu = ARM_CPU(c->cpu); | ||
31 | |||
32 | c->icc_pmr_el1 = 0; | ||
33 | c->icc_bpr[GICV3_G0] = GIC_MIN_BPR; | ||
34 | @@ -XXX,XX +XXX,XX @@ static void arm_gicv3_icc_reset(CPUARMState *env, const ARMCPRegInfo *ri) | ||
35 | |||
36 | /* Initialize to actual HW supported configuration */ | ||
37 | kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS, | ||
38 | - KVM_VGIC_ATTR(ICC_CTLR_EL1, cpu->mp_affinity), | ||
39 | + KVM_VGIC_ATTR(ICC_CTLR_EL1, c->gicr_typer), | ||
40 | &c->icc_ctlr_el1[GICV3_NS], false, &error_abort); | ||
41 | |||
42 | c->icc_ctlr_el1[GICV3_S] = c->icc_ctlr_el1[GICV3_NS]; | ||
68 | -- | 43 | -- |
69 | 2.20.1 | 44 | 2.20.1 |
70 | 45 | ||
71 | 46 | diff view generated by jsdifflib |
1 | From: Fredrik Strupe <fredrik@strupe.net> | 1 | From: Keqian Zhu <zhukeqian1@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | According to Arm ARM, VQDMULL is only valid when U=0, while having | 3 | Replace "acpi-mem-hotplug" with "acpi-cpu-hotplug" |
4 | U=1 is unallocated. | ||
5 | 4 | ||
6 | Signed-off-by: Fredrik Strupe <fredrik@strupe.net> | 5 | Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com> |
7 | Fixes: 695272dcb976 ("target-arm: Handle UNDEF cases for Neon 3-regs-different-widths") | 6 | Message-id: 20200413091552.62748-4-zhukeqian1@huawei.com |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 9 | --- |
11 | target/arm/translate.c | 2 +- | 10 | hw/acpi/cpu.c | 2 +- |
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
13 | 12 | ||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 13 | diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c |
15 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 15 | --- a/hw/acpi/cpu.c |
17 | +++ b/target/arm/translate.c | 16 | +++ b/hw/acpi/cpu.c |
18 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 17 | @@ -XXX,XX +XXX,XX @@ void cpu_hotplug_hw_init(MemoryRegion *as, Object *owner, |
19 | {0, 0, 0, 0}, /* VMLSL */ | 18 | state->devs[i].arch_id = id_list->cpus[i].arch_id; |
20 | {0, 0, 0, 9}, /* VQDMLSL */ | 19 | } |
21 | {0, 0, 0, 0}, /* Integer VMULL */ | 20 | memory_region_init_io(&state->ctrl_reg, owner, &cpu_hotplug_ops, state, |
22 | - {0, 0, 0, 1}, /* VQDMULL */ | 21 | - "acpi-mem-hotplug", ACPI_CPU_HOTPLUG_REG_LEN); |
23 | + {0, 0, 0, 9}, /* VQDMULL */ | 22 | + "acpi-cpu-hotplug", ACPI_CPU_HOTPLUG_REG_LEN); |
24 | {0, 0, 0, 0xa}, /* Polynomial VMULL */ | 23 | memory_region_add_subregion(as, base_addr, &state->ctrl_reg); |
25 | {0, 0, 0, 7}, /* Reserved: always UNDEF */ | 24 | } |
26 | }; | 25 | |
27 | -- | 26 | -- |
28 | 2.20.1 | 27 | 2.20.1 |
29 | 28 | ||
30 | 29 | diff view generated by jsdifflib |
1 | Convert the Neon VQADD/VQSUB insns in the 3-reg-same grouping | 1 | From: Subbaraya Sundeep <sundeep.lkml@gmail.com> |
---|---|---|---|
2 | to decodetree. | ||
3 | 2 | ||
3 | Modelled Ethernet MAC of Smartfusion2 SoC. | ||
4 | Micrel KSZ8051 PHY is present on Emcraft's | ||
5 | SOM kit hence same PHY is emulated. | ||
6 | |||
7 | Signed-off-by: Subbaraya Sundeep <sundeep.lkml@gmail.com> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
10 | Message-id: 1587048891-30493-2-git-send-email-sundeep.lkml@gmail.com | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20200430181003.21682-19-peter.maydell@linaro.org | ||
7 | --- | 12 | --- |
8 | target/arm/neon-dp.decode | 6 ++++++ | 13 | hw/net/Makefile.objs | 1 + |
9 | target/arm/translate-neon.inc.c | 15 +++++++++++++++ | 14 | include/hw/net/msf2-emac.h | 53 ++++ |
10 | target/arm/translate.c | 14 ++------------ | 15 | hw/net/msf2-emac.c | 589 +++++++++++++++++++++++++++++++++++++ |
11 | 3 files changed, 23 insertions(+), 12 deletions(-) | 16 | MAINTAINERS | 2 + |
17 | 4 files changed, 645 insertions(+) | ||
18 | create mode 100644 include/hw/net/msf2-emac.h | ||
19 | create mode 100644 hw/net/msf2-emac.c | ||
12 | 20 | ||
13 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 21 | diff --git a/hw/net/Makefile.objs b/hw/net/Makefile.objs |
14 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/neon-dp.decode | 23 | --- a/hw/net/Makefile.objs |
16 | +++ b/target/arm/neon-dp.decode | 24 | +++ b/hw/net/Makefile.objs |
25 | @@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_ROCKER) += rocker/rocker.o rocker/rocker_fp.o \ | ||
26 | obj-$(call lnot,$(CONFIG_ROCKER)) += rocker/qmp-norocker.o | ||
27 | |||
28 | common-obj-$(CONFIG_CAN_BUS) += can/ | ||
29 | +common-obj-$(CONFIG_MSF2) += msf2-emac.o | ||
30 | diff --git a/include/hw/net/msf2-emac.h b/include/hw/net/msf2-emac.h | ||
31 | new file mode 100644 | ||
32 | index XXXXXXX..XXXXXXX | ||
33 | --- /dev/null | ||
34 | +++ b/include/hw/net/msf2-emac.h | ||
17 | @@ -XXX,XX +XXX,XX @@ | 35 | @@ -XXX,XX +XXX,XX @@ |
18 | @3same .... ... . . . size:2 .... .... .... . q:1 . . .... \ | 36 | +/* |
19 | &3same vm=%vm_dp vn=%vn_dp vd=%vd_dp | 37 | + * QEMU model of the Smartfusion2 Ethernet MAC. |
20 | 38 | + * | |
21 | +VQADD_S_3s 1111 001 0 0 . .. .... .... 0000 . . . 1 .... @3same | 39 | + * Copyright (c) 2020 Subbaraya Sundeep <sundeep.lkml@gmail.com>. |
22 | +VQADD_U_3s 1111 001 1 0 . .. .... .... 0000 . . . 1 .... @3same | 40 | + * |
23 | + | 41 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
24 | @3same_logic .... ... . . . .. .... .... .... . q:1 .. .... \ | 42 | + * of this software and associated documentation files (the "Software"), to deal |
25 | &3same vm=%vm_dp vn=%vn_dp vd=%vd_dp size=0 | 43 | + * in the Software without restriction, including without limitation the rights |
26 | 44 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
27 | @@ -XXX,XX +XXX,XX @@ VBSL_3s 1111 001 1 0 . 01 .... .... 0001 ... 1 .... @3same_logic | 45 | + * copies of the Software, and to permit persons to whom the Software is |
28 | VBIT_3s 1111 001 1 0 . 10 .... .... 0001 ... 1 .... @3same_logic | 46 | + * furnished to do so, subject to the following conditions: |
29 | VBIF_3s 1111 001 1 0 . 11 .... .... 0001 ... 1 .... @3same_logic | 47 | + * |
30 | 48 | + * The above copyright notice and this permission notice shall be included in | |
31 | +VQSUB_S_3s 1111 001 0 0 . .. .... .... 0010 . . . 1 .... @3same | 49 | + * all copies or substantial portions of the Software. |
32 | +VQSUB_U_3s 1111 001 1 0 . .. .... .... 0010 . . . 1 .... @3same | 50 | + * |
33 | + | 51 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
34 | VCGT_S_3s 1111 001 0 0 . .. .... .... 0011 . . . 0 .... @3same | 52 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
35 | VCGT_U_3s 1111 001 1 0 . .. .... .... 0011 . . . 0 .... @3same | 53 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
36 | VCGE_S_3s 1111 001 0 0 . .. .... .... 0011 . . . 1 .... @3same | 54 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
37 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | 55 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
56 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
57 | + * THE SOFTWARE. | ||
58 | + */ | ||
59 | + | ||
60 | +#include "hw/sysbus.h" | ||
61 | +#include "exec/memory.h" | ||
62 | +#include "net/net.h" | ||
63 | +#include "net/eth.h" | ||
64 | + | ||
65 | +#define TYPE_MSS_EMAC "msf2-emac" | ||
66 | +#define MSS_EMAC(obj) \ | ||
67 | + OBJECT_CHECK(MSF2EmacState, (obj), TYPE_MSS_EMAC) | ||
68 | + | ||
69 | +#define R_MAX (0x1a0 / 4) | ||
70 | +#define PHY_MAX_REGS 32 | ||
71 | + | ||
72 | +typedef struct MSF2EmacState { | ||
73 | + SysBusDevice parent; | ||
74 | + | ||
75 | + MemoryRegion mmio; | ||
76 | + MemoryRegion *dma_mr; | ||
77 | + AddressSpace dma_as; | ||
78 | + | ||
79 | + qemu_irq irq; | ||
80 | + NICState *nic; | ||
81 | + NICConf conf; | ||
82 | + | ||
83 | + uint8_t mac_addr[ETH_ALEN]; | ||
84 | + uint32_t rx_desc; | ||
85 | + uint16_t phy_regs[PHY_MAX_REGS]; | ||
86 | + | ||
87 | + uint32_t regs[R_MAX]; | ||
88 | +} MSF2EmacState; | ||
89 | diff --git a/hw/net/msf2-emac.c b/hw/net/msf2-emac.c | ||
90 | new file mode 100644 | ||
91 | index XXXXXXX..XXXXXXX | ||
92 | --- /dev/null | ||
93 | +++ b/hw/net/msf2-emac.c | ||
94 | @@ -XXX,XX +XXX,XX @@ | ||
95 | +/* | ||
96 | + * QEMU model of the Smartfusion2 Ethernet MAC. | ||
97 | + * | ||
98 | + * Copyright (c) 2020 Subbaraya Sundeep <sundeep.lkml@gmail.com>. | ||
99 | + * | ||
100 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
101 | + * of this software and associated documentation files (the "Software"), to deal | ||
102 | + * in the Software without restriction, including without limitation the rights | ||
103 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
104 | + * copies of the Software, and to permit persons to whom the Software is | ||
105 | + * furnished to do so, subject to the following conditions: | ||
106 | + * | ||
107 | + * The above copyright notice and this permission notice shall be included in | ||
108 | + * all copies or substantial portions of the Software. | ||
109 | + * | ||
110 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
111 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
112 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
113 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
114 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
115 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
116 | + * THE SOFTWARE. | ||
117 | + * | ||
118 | + * Refer to section Ethernet MAC in the document: | ||
119 | + * UG0331: SmartFusion2 Microcontroller Subsystem User Guide | ||
120 | + * Datasheet URL: | ||
121 | + * https://www.microsemi.com/document-portal/cat_view/56661-internal-documents/ | ||
122 | + * 56758-soc?lang=en&limit=20&limitstart=220 | ||
123 | + */ | ||
124 | + | ||
125 | +#include "qemu/osdep.h" | ||
126 | +#include "qemu-common.h" | ||
127 | +#include "qemu/log.h" | ||
128 | +#include "qapi/error.h" | ||
129 | +#include "exec/address-spaces.h" | ||
130 | +#include "hw/registerfields.h" | ||
131 | +#include "hw/net/msf2-emac.h" | ||
132 | +#include "hw/net/mii.h" | ||
133 | +#include "hw/irq.h" | ||
134 | +#include "hw/qdev-properties.h" | ||
135 | +#include "migration/vmstate.h" | ||
136 | + | ||
137 | +REG32(CFG1, 0x0) | ||
138 | + FIELD(CFG1, RESET, 31, 1) | ||
139 | + FIELD(CFG1, RX_EN, 2, 1) | ||
140 | + FIELD(CFG1, TX_EN, 0, 1) | ||
141 | + FIELD(CFG1, LB_EN, 8, 1) | ||
142 | +REG32(CFG2, 0x4) | ||
143 | +REG32(IFG, 0x8) | ||
144 | +REG32(HALF_DUPLEX, 0xc) | ||
145 | +REG32(MAX_FRAME_LENGTH, 0x10) | ||
146 | +REG32(MII_CMD, 0x24) | ||
147 | + FIELD(MII_CMD, READ, 0, 1) | ||
148 | +REG32(MII_ADDR, 0x28) | ||
149 | + FIELD(MII_ADDR, REGADDR, 0, 5) | ||
150 | + FIELD(MII_ADDR, PHYADDR, 8, 5) | ||
151 | +REG32(MII_CTL, 0x2c) | ||
152 | +REG32(MII_STS, 0x30) | ||
153 | +REG32(STA1, 0x40) | ||
154 | +REG32(STA2, 0x44) | ||
155 | +REG32(FIFO_CFG0, 0x48) | ||
156 | +REG32(FIFO_CFG4, 0x58) | ||
157 | + FIELD(FIFO_CFG4, BCAST, 9, 1) | ||
158 | + FIELD(FIFO_CFG4, MCAST, 8, 1) | ||
159 | +REG32(FIFO_CFG5, 0x5C) | ||
160 | + FIELD(FIFO_CFG5, BCAST, 9, 1) | ||
161 | + FIELD(FIFO_CFG5, MCAST, 8, 1) | ||
162 | +REG32(DMA_TX_CTL, 0x180) | ||
163 | + FIELD(DMA_TX_CTL, EN, 0, 1) | ||
164 | +REG32(DMA_TX_DESC, 0x184) | ||
165 | +REG32(DMA_TX_STATUS, 0x188) | ||
166 | + FIELD(DMA_TX_STATUS, PKTCNT, 16, 8) | ||
167 | + FIELD(DMA_TX_STATUS, UNDERRUN, 1, 1) | ||
168 | + FIELD(DMA_TX_STATUS, PKT_SENT, 0, 1) | ||
169 | +REG32(DMA_RX_CTL, 0x18c) | ||
170 | + FIELD(DMA_RX_CTL, EN, 0, 1) | ||
171 | +REG32(DMA_RX_DESC, 0x190) | ||
172 | +REG32(DMA_RX_STATUS, 0x194) | ||
173 | + FIELD(DMA_RX_STATUS, PKTCNT, 16, 8) | ||
174 | + FIELD(DMA_RX_STATUS, OVERFLOW, 2, 1) | ||
175 | + FIELD(DMA_RX_STATUS, PKT_RCVD, 0, 1) | ||
176 | +REG32(DMA_IRQ_MASK, 0x198) | ||
177 | +REG32(DMA_IRQ, 0x19c) | ||
178 | + | ||
179 | +#define EMPTY_MASK (1 << 31) | ||
180 | +#define PKT_SIZE 0x7FF | ||
181 | +#define PHYADDR 0x1 | ||
182 | +#define MAX_PKT_SIZE 2048 | ||
183 | + | ||
184 | +typedef struct { | ||
185 | + uint32_t pktaddr; | ||
186 | + uint32_t pktsize; | ||
187 | + uint32_t next; | ||
188 | +} EmacDesc; | ||
189 | + | ||
190 | +static uint32_t emac_get_isr(MSF2EmacState *s) | ||
191 | +{ | ||
192 | + uint32_t ier = s->regs[R_DMA_IRQ_MASK]; | ||
193 | + uint32_t tx = s->regs[R_DMA_TX_STATUS] & 0xF; | ||
194 | + uint32_t rx = s->regs[R_DMA_RX_STATUS] & 0xF; | ||
195 | + uint32_t isr = (rx << 4) | tx; | ||
196 | + | ||
197 | + s->regs[R_DMA_IRQ] = ier & isr; | ||
198 | + return s->regs[R_DMA_IRQ]; | ||
199 | +} | ||
200 | + | ||
201 | +static void emac_update_irq(MSF2EmacState *s) | ||
202 | +{ | ||
203 | + bool intr = emac_get_isr(s); | ||
204 | + | ||
205 | + qemu_set_irq(s->irq, intr); | ||
206 | +} | ||
207 | + | ||
208 | +static void emac_load_desc(MSF2EmacState *s, EmacDesc *d, hwaddr desc) | ||
209 | +{ | ||
210 | + address_space_read(&s->dma_as, desc, MEMTXATTRS_UNSPECIFIED, d, sizeof *d); | ||
211 | + /* Convert from LE into host endianness. */ | ||
212 | + d->pktaddr = le32_to_cpu(d->pktaddr); | ||
213 | + d->pktsize = le32_to_cpu(d->pktsize); | ||
214 | + d->next = le32_to_cpu(d->next); | ||
215 | +} | ||
216 | + | ||
217 | +static void emac_store_desc(MSF2EmacState *s, EmacDesc *d, hwaddr desc) | ||
218 | +{ | ||
219 | + /* Convert from host endianness into LE. */ | ||
220 | + d->pktaddr = cpu_to_le32(d->pktaddr); | ||
221 | + d->pktsize = cpu_to_le32(d->pktsize); | ||
222 | + d->next = cpu_to_le32(d->next); | ||
223 | + | ||
224 | + address_space_write(&s->dma_as, desc, MEMTXATTRS_UNSPECIFIED, d, sizeof *d); | ||
225 | +} | ||
226 | + | ||
227 | +static void msf2_dma_tx(MSF2EmacState *s) | ||
228 | +{ | ||
229 | + NetClientState *nc = qemu_get_queue(s->nic); | ||
230 | + hwaddr desc = s->regs[R_DMA_TX_DESC]; | ||
231 | + uint8_t buf[MAX_PKT_SIZE]; | ||
232 | + EmacDesc d; | ||
233 | + int size; | ||
234 | + uint8_t pktcnt; | ||
235 | + uint32_t status; | ||
236 | + | ||
237 | + if (!(s->regs[R_CFG1] & R_CFG1_TX_EN_MASK)) { | ||
238 | + return; | ||
239 | + } | ||
240 | + | ||
241 | + while (1) { | ||
242 | + emac_load_desc(s, &d, desc); | ||
243 | + if (d.pktsize & EMPTY_MASK) { | ||
244 | + break; | ||
245 | + } | ||
246 | + size = d.pktsize & PKT_SIZE; | ||
247 | + address_space_read(&s->dma_as, d.pktaddr, MEMTXATTRS_UNSPECIFIED, | ||
248 | + buf, size); | ||
249 | + /* | ||
250 | + * This is very basic way to send packets. Ideally there should be | ||
251 | + * a FIFO and packets should be sent out from FIFO only when | ||
252 | + * R_CFG1 bit 0 is set. | ||
253 | + */ | ||
254 | + if (s->regs[R_CFG1] & R_CFG1_LB_EN_MASK) { | ||
255 | + nc->info->receive(nc, buf, size); | ||
256 | + } else { | ||
257 | + qemu_send_packet(nc, buf, size); | ||
258 | + } | ||
259 | + d.pktsize |= EMPTY_MASK; | ||
260 | + emac_store_desc(s, &d, desc); | ||
261 | + /* update sent packets count */ | ||
262 | + status = s->regs[R_DMA_TX_STATUS]; | ||
263 | + pktcnt = FIELD_EX32(status, DMA_TX_STATUS, PKTCNT); | ||
264 | + pktcnt++; | ||
265 | + s->regs[R_DMA_TX_STATUS] = FIELD_DP32(status, DMA_TX_STATUS, | ||
266 | + PKTCNT, pktcnt); | ||
267 | + s->regs[R_DMA_TX_STATUS] |= R_DMA_TX_STATUS_PKT_SENT_MASK; | ||
268 | + desc = d.next; | ||
269 | + } | ||
270 | + s->regs[R_DMA_TX_STATUS] |= R_DMA_TX_STATUS_UNDERRUN_MASK; | ||
271 | + s->regs[R_DMA_TX_CTL] &= ~R_DMA_TX_CTL_EN_MASK; | ||
272 | +} | ||
273 | + | ||
274 | +static void msf2_phy_update_link(MSF2EmacState *s) | ||
275 | +{ | ||
276 | + /* Autonegotiation status mirrors link status. */ | ||
277 | + if (qemu_get_queue(s->nic)->link_down) { | ||
278 | + s->phy_regs[MII_BMSR] &= ~(MII_BMSR_AN_COMP | | ||
279 | + MII_BMSR_LINK_ST); | ||
280 | + } else { | ||
281 | + s->phy_regs[MII_BMSR] |= (MII_BMSR_AN_COMP | | ||
282 | + MII_BMSR_LINK_ST); | ||
283 | + } | ||
284 | +} | ||
285 | + | ||
286 | +static void msf2_phy_reset(MSF2EmacState *s) | ||
287 | +{ | ||
288 | + memset(&s->phy_regs[0], 0, sizeof(s->phy_regs)); | ||
289 | + s->phy_regs[MII_BMCR] = 0x1140; | ||
290 | + s->phy_regs[MII_BMSR] = 0x7968; | ||
291 | + s->phy_regs[MII_PHYID1] = 0x0022; | ||
292 | + s->phy_regs[MII_PHYID2] = 0x1550; | ||
293 | + s->phy_regs[MII_ANAR] = 0x01E1; | ||
294 | + s->phy_regs[MII_ANLPAR] = 0xCDE1; | ||
295 | + | ||
296 | + msf2_phy_update_link(s); | ||
297 | +} | ||
298 | + | ||
299 | +static void write_to_phy(MSF2EmacState *s) | ||
300 | +{ | ||
301 | + uint8_t reg_addr = s->regs[R_MII_ADDR] & R_MII_ADDR_REGADDR_MASK; | ||
302 | + uint8_t phy_addr = (s->regs[R_MII_ADDR] >> R_MII_ADDR_PHYADDR_SHIFT) & | ||
303 | + R_MII_ADDR_REGADDR_MASK; | ||
304 | + uint16_t data = s->regs[R_MII_CTL] & 0xFFFF; | ||
305 | + | ||
306 | + if (phy_addr != PHYADDR) { | ||
307 | + return; | ||
308 | + } | ||
309 | + | ||
310 | + switch (reg_addr) { | ||
311 | + case MII_BMCR: | ||
312 | + if (data & MII_BMCR_RESET) { | ||
313 | + /* Phy reset */ | ||
314 | + msf2_phy_reset(s); | ||
315 | + data &= ~MII_BMCR_RESET; | ||
316 | + } | ||
317 | + if (data & MII_BMCR_AUTOEN) { | ||
318 | + /* Complete autonegotiation immediately */ | ||
319 | + data &= ~MII_BMCR_AUTOEN; | ||
320 | + s->phy_regs[MII_BMSR] |= MII_BMSR_AN_COMP; | ||
321 | + } | ||
322 | + break; | ||
323 | + } | ||
324 | + | ||
325 | + s->phy_regs[reg_addr] = data; | ||
326 | +} | ||
327 | + | ||
328 | +static uint16_t read_from_phy(MSF2EmacState *s) | ||
329 | +{ | ||
330 | + uint8_t reg_addr = s->regs[R_MII_ADDR] & R_MII_ADDR_REGADDR_MASK; | ||
331 | + uint8_t phy_addr = (s->regs[R_MII_ADDR] >> R_MII_ADDR_PHYADDR_SHIFT) & | ||
332 | + R_MII_ADDR_REGADDR_MASK; | ||
333 | + | ||
334 | + if (phy_addr == PHYADDR) { | ||
335 | + return s->phy_regs[reg_addr]; | ||
336 | + } else { | ||
337 | + return 0xFFFF; | ||
338 | + } | ||
339 | +} | ||
340 | + | ||
341 | +static void msf2_emac_do_reset(MSF2EmacState *s) | ||
342 | +{ | ||
343 | + memset(&s->regs[0], 0, sizeof(s->regs)); | ||
344 | + s->regs[R_CFG1] = 0x80000000; | ||
345 | + s->regs[R_CFG2] = 0x00007000; | ||
346 | + s->regs[R_IFG] = 0x40605060; | ||
347 | + s->regs[R_HALF_DUPLEX] = 0x00A1F037; | ||
348 | + s->regs[R_MAX_FRAME_LENGTH] = 0x00000600; | ||
349 | + s->regs[R_FIFO_CFG5] = 0X3FFFF; | ||
350 | + | ||
351 | + msf2_phy_reset(s); | ||
352 | +} | ||
353 | + | ||
354 | +static uint64_t emac_read(void *opaque, hwaddr addr, unsigned int size) | ||
355 | +{ | ||
356 | + MSF2EmacState *s = opaque; | ||
357 | + uint32_t r = 0; | ||
358 | + | ||
359 | + addr >>= 2; | ||
360 | + | ||
361 | + switch (addr) { | ||
362 | + case R_DMA_IRQ: | ||
363 | + r = emac_get_isr(s); | ||
364 | + break; | ||
365 | + default: | ||
366 | + if (addr >= ARRAY_SIZE(s->regs)) { | ||
367 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
368 | + "%s: Bad offset 0x%" HWADDR_PRIx "\n", __func__, | ||
369 | + addr * 4); | ||
370 | + return r; | ||
371 | + } | ||
372 | + r = s->regs[addr]; | ||
373 | + break; | ||
374 | + } | ||
375 | + return r; | ||
376 | +} | ||
377 | + | ||
378 | +static void emac_write(void *opaque, hwaddr addr, uint64_t val64, | ||
379 | + unsigned int size) | ||
380 | +{ | ||
381 | + MSF2EmacState *s = opaque; | ||
382 | + uint32_t value = val64; | ||
383 | + uint32_t enreqbits; | ||
384 | + uint8_t pktcnt; | ||
385 | + | ||
386 | + addr >>= 2; | ||
387 | + switch (addr) { | ||
388 | + case R_DMA_TX_CTL: | ||
389 | + s->regs[addr] = value; | ||
390 | + if (value & R_DMA_TX_CTL_EN_MASK) { | ||
391 | + msf2_dma_tx(s); | ||
392 | + } | ||
393 | + break; | ||
394 | + case R_DMA_RX_CTL: | ||
395 | + s->regs[addr] = value; | ||
396 | + if (value & R_DMA_RX_CTL_EN_MASK) { | ||
397 | + s->rx_desc = s->regs[R_DMA_RX_DESC]; | ||
398 | + qemu_flush_queued_packets(qemu_get_queue(s->nic)); | ||
399 | + } | ||
400 | + break; | ||
401 | + case R_CFG1: | ||
402 | + s->regs[addr] = value; | ||
403 | + if (value & R_CFG1_RESET_MASK) { | ||
404 | + msf2_emac_do_reset(s); | ||
405 | + } | ||
406 | + break; | ||
407 | + case R_FIFO_CFG0: | ||
408 | + /* | ||
409 | + * For our implementation, turning on modules is instantaneous, | ||
410 | + * so the states requested via the *ENREQ bits appear in the | ||
411 | + * *ENRPLY bits immediately. Also the reset bits to reset PE-MCXMAC | ||
412 | + * module are not emulated here since it deals with start of frames, | ||
413 | + * inter-packet gap and control frames. | ||
414 | + */ | ||
415 | + enreqbits = extract32(value, 8, 5); | ||
416 | + s->regs[addr] = deposit32(value, 16, 5, enreqbits); | ||
417 | + break; | ||
418 | + case R_DMA_TX_DESC: | ||
419 | + if (value & 0x3) { | ||
420 | + qemu_log_mask(LOG_GUEST_ERROR, "Tx Descriptor address should be" | ||
421 | + " 32 bit aligned\n"); | ||
422 | + } | ||
423 | + /* Ignore [1:0] bits */ | ||
424 | + s->regs[addr] = value & ~3; | ||
425 | + break; | ||
426 | + case R_DMA_RX_DESC: | ||
427 | + if (value & 0x3) { | ||
428 | + qemu_log_mask(LOG_GUEST_ERROR, "Rx Descriptor address should be" | ||
429 | + " 32 bit aligned\n"); | ||
430 | + } | ||
431 | + /* Ignore [1:0] bits */ | ||
432 | + s->regs[addr] = value & ~3; | ||
433 | + break; | ||
434 | + case R_DMA_TX_STATUS: | ||
435 | + if (value & R_DMA_TX_STATUS_UNDERRUN_MASK) { | ||
436 | + s->regs[addr] &= ~R_DMA_TX_STATUS_UNDERRUN_MASK; | ||
437 | + } | ||
438 | + if (value & R_DMA_TX_STATUS_PKT_SENT_MASK) { | ||
439 | + pktcnt = FIELD_EX32(s->regs[addr], DMA_TX_STATUS, PKTCNT); | ||
440 | + pktcnt--; | ||
441 | + s->regs[addr] = FIELD_DP32(s->regs[addr], DMA_TX_STATUS, | ||
442 | + PKTCNT, pktcnt); | ||
443 | + if (pktcnt == 0) { | ||
444 | + s->regs[addr] &= ~R_DMA_TX_STATUS_PKT_SENT_MASK; | ||
445 | + } | ||
446 | + } | ||
447 | + break; | ||
448 | + case R_DMA_RX_STATUS: | ||
449 | + if (value & R_DMA_RX_STATUS_OVERFLOW_MASK) { | ||
450 | + s->regs[addr] &= ~R_DMA_RX_STATUS_OVERFLOW_MASK; | ||
451 | + } | ||
452 | + if (value & R_DMA_RX_STATUS_PKT_RCVD_MASK) { | ||
453 | + pktcnt = FIELD_EX32(s->regs[addr], DMA_RX_STATUS, PKTCNT); | ||
454 | + pktcnt--; | ||
455 | + s->regs[addr] = FIELD_DP32(s->regs[addr], DMA_RX_STATUS, | ||
456 | + PKTCNT, pktcnt); | ||
457 | + if (pktcnt == 0) { | ||
458 | + s->regs[addr] &= ~R_DMA_RX_STATUS_PKT_RCVD_MASK; | ||
459 | + } | ||
460 | + } | ||
461 | + break; | ||
462 | + case R_DMA_IRQ: | ||
463 | + break; | ||
464 | + case R_MII_CMD: | ||
465 | + if (value & R_MII_CMD_READ_MASK) { | ||
466 | + s->regs[R_MII_STS] = read_from_phy(s); | ||
467 | + } | ||
468 | + break; | ||
469 | + case R_MII_CTL: | ||
470 | + s->regs[addr] = value; | ||
471 | + write_to_phy(s); | ||
472 | + break; | ||
473 | + case R_STA1: | ||
474 | + s->regs[addr] = value; | ||
475 | + /* | ||
476 | + * R_STA1 [31:24] : octet 1 of mac address | ||
477 | + * R_STA1 [23:16] : octet 2 of mac address | ||
478 | + * R_STA1 [15:8] : octet 3 of mac address | ||
479 | + * R_STA1 [7:0] : octet 4 of mac address | ||
480 | + */ | ||
481 | + stl_be_p(s->mac_addr, value); | ||
482 | + break; | ||
483 | + case R_STA2: | ||
484 | + s->regs[addr] = value; | ||
485 | + /* | ||
486 | + * R_STA2 [31:24] : octet 5 of mac address | ||
487 | + * R_STA2 [23:16] : octet 6 of mac address | ||
488 | + */ | ||
489 | + stw_be_p(s->mac_addr + 4, value >> 16); | ||
490 | + break; | ||
491 | + default: | ||
492 | + if (addr >= ARRAY_SIZE(s->regs)) { | ||
493 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
494 | + "%s: Bad offset 0x%" HWADDR_PRIx "\n", __func__, | ||
495 | + addr * 4); | ||
496 | + return; | ||
497 | + } | ||
498 | + s->regs[addr] = value; | ||
499 | + break; | ||
500 | + } | ||
501 | + emac_update_irq(s); | ||
502 | +} | ||
503 | + | ||
504 | +static const MemoryRegionOps emac_ops = { | ||
505 | + .read = emac_read, | ||
506 | + .write = emac_write, | ||
507 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
508 | + .impl = { | ||
509 | + .min_access_size = 4, | ||
510 | + .max_access_size = 4 | ||
511 | + } | ||
512 | +}; | ||
513 | + | ||
514 | +static bool emac_can_rx(NetClientState *nc) | ||
515 | +{ | ||
516 | + MSF2EmacState *s = qemu_get_nic_opaque(nc); | ||
517 | + | ||
518 | + return (s->regs[R_CFG1] & R_CFG1_RX_EN_MASK) && | ||
519 | + (s->regs[R_DMA_RX_CTL] & R_DMA_RX_CTL_EN_MASK); | ||
520 | +} | ||
521 | + | ||
522 | +static bool addr_filter_ok(MSF2EmacState *s, const uint8_t *buf) | ||
523 | +{ | ||
524 | + /* The broadcast MAC address: FF:FF:FF:FF:FF:FF */ | ||
525 | + const uint8_t broadcast_addr[] = { 0xFF, 0xFF, 0xFF, 0xFF, | ||
526 | + 0xFF, 0xFF }; | ||
527 | + bool bcast_en = true; | ||
528 | + bool mcast_en = true; | ||
529 | + | ||
530 | + if (s->regs[R_FIFO_CFG5] & R_FIFO_CFG5_BCAST_MASK) { | ||
531 | + bcast_en = true; /* Broadcast dont care for drop circuitry */ | ||
532 | + } else if (s->regs[R_FIFO_CFG4] & R_FIFO_CFG4_BCAST_MASK) { | ||
533 | + bcast_en = false; | ||
534 | + } | ||
535 | + | ||
536 | + if (s->regs[R_FIFO_CFG5] & R_FIFO_CFG5_MCAST_MASK) { | ||
537 | + mcast_en = true; /* Multicast dont care for drop circuitry */ | ||
538 | + } else if (s->regs[R_FIFO_CFG4] & R_FIFO_CFG4_MCAST_MASK) { | ||
539 | + mcast_en = false; | ||
540 | + } | ||
541 | + | ||
542 | + if (!memcmp(buf, broadcast_addr, sizeof(broadcast_addr))) { | ||
543 | + return bcast_en; | ||
544 | + } | ||
545 | + | ||
546 | + if (buf[0] & 1) { | ||
547 | + return mcast_en; | ||
548 | + } | ||
549 | + | ||
550 | + return !memcmp(buf, s->mac_addr, sizeof(s->mac_addr)); | ||
551 | +} | ||
552 | + | ||
553 | +static ssize_t emac_rx(NetClientState *nc, const uint8_t *buf, size_t size) | ||
554 | +{ | ||
555 | + MSF2EmacState *s = qemu_get_nic_opaque(nc); | ||
556 | + EmacDesc d; | ||
557 | + uint8_t pktcnt; | ||
558 | + uint32_t status; | ||
559 | + | ||
560 | + if (size > (s->regs[R_MAX_FRAME_LENGTH] & 0xFFFF)) { | ||
561 | + return size; | ||
562 | + } | ||
563 | + if (!addr_filter_ok(s, buf)) { | ||
564 | + return size; | ||
565 | + } | ||
566 | + | ||
567 | + emac_load_desc(s, &d, s->rx_desc); | ||
568 | + | ||
569 | + if (d.pktsize & EMPTY_MASK) { | ||
570 | + address_space_write(&s->dma_as, d.pktaddr, MEMTXATTRS_UNSPECIFIED, | ||
571 | + buf, size & PKT_SIZE); | ||
572 | + d.pktsize = size & PKT_SIZE; | ||
573 | + emac_store_desc(s, &d, s->rx_desc); | ||
574 | + /* update received packets count */ | ||
575 | + status = s->regs[R_DMA_RX_STATUS]; | ||
576 | + pktcnt = FIELD_EX32(status, DMA_RX_STATUS, PKTCNT); | ||
577 | + pktcnt++; | ||
578 | + s->regs[R_DMA_RX_STATUS] = FIELD_DP32(status, DMA_RX_STATUS, | ||
579 | + PKTCNT, pktcnt); | ||
580 | + s->regs[R_DMA_RX_STATUS] |= R_DMA_RX_STATUS_PKT_RCVD_MASK; | ||
581 | + s->rx_desc = d.next; | ||
582 | + } else { | ||
583 | + s->regs[R_DMA_RX_CTL] &= ~R_DMA_RX_CTL_EN_MASK; | ||
584 | + s->regs[R_DMA_RX_STATUS] |= R_DMA_RX_STATUS_OVERFLOW_MASK; | ||
585 | + } | ||
586 | + emac_update_irq(s); | ||
587 | + return size; | ||
588 | +} | ||
589 | + | ||
590 | +static void msf2_emac_reset(DeviceState *dev) | ||
591 | +{ | ||
592 | + MSF2EmacState *s = MSS_EMAC(dev); | ||
593 | + | ||
594 | + msf2_emac_do_reset(s); | ||
595 | +} | ||
596 | + | ||
597 | +static void emac_set_link(NetClientState *nc) | ||
598 | +{ | ||
599 | + MSF2EmacState *s = qemu_get_nic_opaque(nc); | ||
600 | + | ||
601 | + msf2_phy_update_link(s); | ||
602 | +} | ||
603 | + | ||
604 | +static NetClientInfo net_msf2_emac_info = { | ||
605 | + .type = NET_CLIENT_DRIVER_NIC, | ||
606 | + .size = sizeof(NICState), | ||
607 | + .can_receive = emac_can_rx, | ||
608 | + .receive = emac_rx, | ||
609 | + .link_status_changed = emac_set_link, | ||
610 | +}; | ||
611 | + | ||
612 | +static void msf2_emac_realize(DeviceState *dev, Error **errp) | ||
613 | +{ | ||
614 | + MSF2EmacState *s = MSS_EMAC(dev); | ||
615 | + | ||
616 | + if (!s->dma_mr) { | ||
617 | + error_setg(errp, "MSS_EMAC 'ahb-bus' link not set"); | ||
618 | + return; | ||
619 | + } | ||
620 | + | ||
621 | + address_space_init(&s->dma_as, s->dma_mr, "emac-ahb"); | ||
622 | + | ||
623 | + qemu_macaddr_default_if_unset(&s->conf.macaddr); | ||
624 | + s->nic = qemu_new_nic(&net_msf2_emac_info, &s->conf, | ||
625 | + object_get_typename(OBJECT(dev)), dev->id, s); | ||
626 | + qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); | ||
627 | +} | ||
628 | + | ||
629 | +static void msf2_emac_init(Object *obj) | ||
630 | +{ | ||
631 | + MSF2EmacState *s = MSS_EMAC(obj); | ||
632 | + | ||
633 | + sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->irq); | ||
634 | + | ||
635 | + memory_region_init_io(&s->mmio, obj, &emac_ops, s, | ||
636 | + "msf2-emac", R_MAX * 4); | ||
637 | + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); | ||
638 | +} | ||
639 | + | ||
640 | +static Property msf2_emac_properties[] = { | ||
641 | + DEFINE_PROP_LINK("ahb-bus", MSF2EmacState, dma_mr, | ||
642 | + TYPE_MEMORY_REGION, MemoryRegion *), | ||
643 | + DEFINE_NIC_PROPERTIES(MSF2EmacState, conf), | ||
644 | + DEFINE_PROP_END_OF_LIST(), | ||
645 | +}; | ||
646 | + | ||
647 | +static const VMStateDescription vmstate_msf2_emac = { | ||
648 | + .name = TYPE_MSS_EMAC, | ||
649 | + .version_id = 1, | ||
650 | + .minimum_version_id = 1, | ||
651 | + .fields = (VMStateField[]) { | ||
652 | + VMSTATE_UINT8_ARRAY(mac_addr, MSF2EmacState, ETH_ALEN), | ||
653 | + VMSTATE_UINT32(rx_desc, MSF2EmacState), | ||
654 | + VMSTATE_UINT16_ARRAY(phy_regs, MSF2EmacState, PHY_MAX_REGS), | ||
655 | + VMSTATE_UINT32_ARRAY(regs, MSF2EmacState, R_MAX), | ||
656 | + VMSTATE_END_OF_LIST() | ||
657 | + } | ||
658 | +}; | ||
659 | + | ||
660 | +static void msf2_emac_class_init(ObjectClass *klass, void *data) | ||
661 | +{ | ||
662 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
663 | + | ||
664 | + dc->realize = msf2_emac_realize; | ||
665 | + dc->reset = msf2_emac_reset; | ||
666 | + dc->vmsd = &vmstate_msf2_emac; | ||
667 | + device_class_set_props(dc, msf2_emac_properties); | ||
668 | +} | ||
669 | + | ||
670 | +static const TypeInfo msf2_emac_info = { | ||
671 | + .name = TYPE_MSS_EMAC, | ||
672 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
673 | + .instance_size = sizeof(MSF2EmacState), | ||
674 | + .instance_init = msf2_emac_init, | ||
675 | + .class_init = msf2_emac_class_init, | ||
676 | +}; | ||
677 | + | ||
678 | +static void msf2_emac_register_types(void) | ||
679 | +{ | ||
680 | + type_register_static(&msf2_emac_info); | ||
681 | +} | ||
682 | + | ||
683 | +type_init(msf2_emac_register_types) | ||
684 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
38 | index XXXXXXX..XXXXXXX 100644 | 685 | index XXXXXXX..XXXXXXX 100644 |
39 | --- a/target/arm/translate-neon.inc.c | 686 | --- a/MAINTAINERS |
40 | +++ b/target/arm/translate-neon.inc.c | 687 | +++ b/MAINTAINERS |
41 | @@ -XXX,XX +XXX,XX @@ static void gen_VTST_3s(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, | 688 | @@ -XXX,XX +XXX,XX @@ F: include/hw/arm/msf2-soc.h |
42 | tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, oprsz, maxsz, &cmtst_op[vece]); | 689 | F: include/hw/misc/msf2-sysreg.h |
43 | } | 690 | F: include/hw/timer/mss-timer.h |
44 | DO_3SAME_NO_SZ_3(VTST, gen_VTST_3s) | 691 | F: include/hw/ssi/mss-spi.h |
45 | + | 692 | +F: hw/net/msf2-emac.c |
46 | +#define DO_3SAME_GVEC4(INSN, OPARRAY) \ | 693 | +F: include/hw/net/msf2-emac.h |
47 | + static void gen_##INSN##_3s(unsigned vece, uint32_t rd_ofs, \ | 694 | |
48 | + uint32_t rn_ofs, uint32_t rm_ofs, \ | 695 | Emcraft M2S-FG484 |
49 | + uint32_t oprsz, uint32_t maxsz) \ | 696 | M: Subbaraya Sundeep <sundeep.lkml@gmail.com> |
50 | + { \ | ||
51 | + tcg_gen_gvec_4(rd_ofs, offsetof(CPUARMState, vfp.qc), \ | ||
52 | + rn_ofs, rm_ofs, oprsz, maxsz, &OPARRAY[vece]); \ | ||
53 | + } \ | ||
54 | + DO_3SAME(INSN, gen_##INSN##_3s) | ||
55 | + | ||
56 | +DO_3SAME_GVEC4(VQADD_S, sqadd_op) | ||
57 | +DO_3SAME_GVEC4(VQADD_U, uqadd_op) | ||
58 | +DO_3SAME_GVEC4(VQSUB_S, sqsub_op) | ||
59 | +DO_3SAME_GVEC4(VQSUB_U, uqsub_op) | ||
60 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/target/arm/translate.c | ||
63 | +++ b/target/arm/translate.c | ||
64 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
65 | } | ||
66 | return 1; | ||
67 | |||
68 | - case NEON_3R_VQADD: | ||
69 | - tcg_gen_gvec_4(rd_ofs, offsetof(CPUARMState, vfp.qc), | ||
70 | - rn_ofs, rm_ofs, vec_size, vec_size, | ||
71 | - (u ? uqadd_op : sqadd_op) + size); | ||
72 | - return 0; | ||
73 | - | ||
74 | - case NEON_3R_VQSUB: | ||
75 | - tcg_gen_gvec_4(rd_ofs, offsetof(CPUARMState, vfp.qc), | ||
76 | - rn_ofs, rm_ofs, vec_size, vec_size, | ||
77 | - (u ? uqsub_op : sqsub_op) + size); | ||
78 | - return 0; | ||
79 | - | ||
80 | case NEON_3R_VMUL: /* VMUL */ | ||
81 | if (u) { | ||
82 | /* Polynomial case allows only P8. */ | ||
83 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
84 | case NEON_3R_VTST_VCEQ: | ||
85 | case NEON_3R_VCGT: | ||
86 | case NEON_3R_VCGE: | ||
87 | + case NEON_3R_VQADD: | ||
88 | + case NEON_3R_VQSUB: | ||
89 | /* Already handled by decodetree */ | ||
90 | return 1; | ||
91 | } | ||
92 | -- | 697 | -- |
93 | 2.20.1 | 698 | 2.20.1 |
94 | 699 | ||
95 | 700 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: Subbaraya Sundeep <sundeep.lkml@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | Embed the APUs into the SoC type. | 3 | With SmartFusion2 Ethernet MAC model in |
4 | place this patch adds the same to SoC. | ||
4 | 5 | ||
5 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Subbaraya Sundeep <sundeep.lkml@gmail.com> |
6 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
9 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | 8 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
10 | Message-id: 20200427181649.26851-8-edgar.iglesias@gmail.com | 9 | Message-id: 1587048891-30493-3-git-send-email-sundeep.lkml@gmail.com |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 11 | --- |
13 | include/hw/arm/xlnx-versal.h | 2 +- | 12 | include/hw/arm/msf2-soc.h | 2 ++ |
14 | hw/arm/xlnx-versal-virt.c | 4 ++-- | 13 | hw/arm/msf2-soc.c | 26 ++++++++++++++++++++++++-- |
15 | hw/arm/xlnx-versal.c | 19 +++++-------------- | 14 | 2 files changed, 26 insertions(+), 2 deletions(-) |
16 | 3 files changed, 8 insertions(+), 17 deletions(-) | ||
17 | 15 | ||
18 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h | 16 | diff --git a/include/hw/arm/msf2-soc.h b/include/hw/arm/msf2-soc.h |
19 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/include/hw/arm/xlnx-versal.h | 18 | --- a/include/hw/arm/msf2-soc.h |
21 | +++ b/include/hw/arm/xlnx-versal.h | 19 | +++ b/include/hw/arm/msf2-soc.h |
22 | @@ -XXX,XX +XXX,XX @@ typedef struct Versal { | 20 | @@ -XXX,XX +XXX,XX @@ |
23 | struct { | 21 | #include "hw/timer/mss-timer.h" |
24 | struct { | 22 | #include "hw/misc/msf2-sysreg.h" |
25 | MemoryRegion mr; | 23 | #include "hw/ssi/mss-spi.h" |
26 | - ARMCPU *cpu[XLNX_VERSAL_NR_ACPUS]; | 24 | +#include "hw/net/msf2-emac.h" |
27 | + ARMCPU cpu[XLNX_VERSAL_NR_ACPUS]; | 25 | |
28 | GICv3State gic; | 26 | #define TYPE_MSF2_SOC "msf2-soc" |
29 | } apu; | 27 | #define MSF2_SOC(obj) OBJECT_CHECK(MSF2State, (obj), TYPE_MSF2_SOC) |
30 | } fpd; | 28 | @@ -XXX,XX +XXX,XX @@ typedef struct MSF2State { |
31 | diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c | 29 | MSF2SysregState sysreg; |
30 | MSSTimerState timer; | ||
31 | MSSSpiState spi[MSF2_NUM_SPIS]; | ||
32 | + MSF2EmacState emac; | ||
33 | } MSF2State; | ||
34 | |||
35 | #endif | ||
36 | diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | 37 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/hw/arm/xlnx-versal-virt.c | 38 | --- a/hw/arm/msf2-soc.c |
34 | +++ b/hw/arm/xlnx-versal-virt.c | 39 | +++ b/hw/arm/msf2-soc.c |
35 | @@ -XXX,XX +XXX,XX @@ static void versal_virt_init(MachineState *machine) | 40 | @@ -XXX,XX +XXX,XX @@ |
36 | s->binfo.get_dtb = versal_virt_get_dtb; | 41 | /* |
37 | s->binfo.modify_dtb = versal_virt_modify_dtb; | 42 | * SmartFusion2 SoC emulation. |
38 | if (machine->kernel_filename) { | 43 | * |
39 | - arm_load_kernel(s->soc.fpd.apu.cpu[0], machine, &s->binfo); | 44 | - * Copyright (c) 2017 Subbaraya Sundeep <sundeep.lkml@gmail.com> |
40 | + arm_load_kernel(&s->soc.fpd.apu.cpu[0], machine, &s->binfo); | 45 | + * Copyright (c) 2017-2020 Subbaraya Sundeep <sundeep.lkml@gmail.com> |
41 | } else { | 46 | * |
42 | - AddressSpace *as = arm_boot_address_space(s->soc.fpd.apu.cpu[0], | 47 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
43 | + AddressSpace *as = arm_boot_address_space(&s->soc.fpd.apu.cpu[0], | 48 | * of this software and associated documentation files (the "Software"), to deal |
44 | &s->binfo); | 49 | @@ -XXX,XX +XXX,XX @@ |
45 | /* Some boot-loaders (e.g u-boot) don't like blobs at address 0 (NULL). | 50 | |
46 | * Offset things by 4K. */ | 51 | #define MSF2_TIMER_BASE 0x40004000 |
47 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c | 52 | #define MSF2_SYSREG_BASE 0x40038000 |
48 | index XXXXXXX..XXXXXXX 100644 | 53 | +#define MSF2_EMAC_BASE 0x40041000 |
49 | --- a/hw/arm/xlnx-versal.c | 54 | |
50 | +++ b/hw/arm/xlnx-versal.c | 55 | #define ENVM_BASE_ADDRESS 0x60000000 |
51 | @@ -XXX,XX +XXX,XX @@ static void versal_create_apu_cpus(Versal *s) | 56 | |
52 | 57 | #define SRAM_BASE_ADDRESS 0x20000000 | |
53 | for (i = 0; i < ARRAY_SIZE(s->fpd.apu.cpu); i++) { | 58 | |
54 | Object *obj; | 59 | +#define MSF2_EMAC_IRQ 12 |
55 | - char *name; | 60 | + |
56 | - | 61 | #define MSF2_ENVM_MAX_SIZE (512 * KiB) |
57 | - obj = object_new(XLNX_VERSAL_ACPU_TYPE); | 62 | |
58 | - if (!obj) { | 63 | /* |
59 | - error_report("Unable to create apu.cpu[%d] of type %s", | 64 | @@ -XXX,XX +XXX,XX @@ static void m2sxxx_soc_initfn(Object *obj) |
60 | - i, XLNX_VERSAL_ACPU_TYPE); | 65 | sysbus_init_child_obj(obj, "spi[*]", &s->spi[i], sizeof(s->spi[i]), |
61 | - exit(EXIT_FAILURE); | 66 | TYPE_MSS_SPI); |
62 | - } | ||
63 | - | ||
64 | - name = g_strdup_printf("apu-cpu[%d]", i); | ||
65 | - object_property_add_child(OBJECT(s), name, obj, &error_fatal); | ||
66 | - g_free(name); | ||
67 | |||
68 | + object_initialize_child(OBJECT(s), "apu-cpu[*]", | ||
69 | + &s->fpd.apu.cpu[i], sizeof(s->fpd.apu.cpu[i]), | ||
70 | + XLNX_VERSAL_ACPU_TYPE, &error_abort, NULL); | ||
71 | + obj = OBJECT(&s->fpd.apu.cpu[i]); | ||
72 | object_property_set_int(obj, s->cfg.psci_conduit, | ||
73 | "psci-conduit", &error_abort); | ||
74 | if (i) { | ||
75 | @@ -XXX,XX +XXX,XX @@ static void versal_create_apu_cpus(Versal *s) | ||
76 | object_property_set_link(obj, OBJECT(&s->fpd.apu.mr), "memory", | ||
77 | &error_abort); | ||
78 | object_property_set_bool(obj, true, "realized", &error_fatal); | ||
79 | - s->fpd.apu.cpu[i] = ARM_CPU(obj); | ||
80 | } | 67 | } |
68 | + | ||
69 | + sysbus_init_child_obj(obj, "emac", &s->emac, sizeof(s->emac), | ||
70 | + TYPE_MSS_EMAC); | ||
71 | + if (nd_table[0].used) { | ||
72 | + qemu_check_nic_model(&nd_table[0], TYPE_MSS_EMAC); | ||
73 | + qdev_set_nic_properties(DEVICE(&s->emac), &nd_table[0]); | ||
74 | + } | ||
81 | } | 75 | } |
82 | 76 | ||
83 | @@ -XXX,XX +XXX,XX @@ static void versal_create_apu_gic(Versal *s, qemu_irq *pic) | 77 | static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp) |
78 | @@ -XXX,XX +XXX,XX @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp) | ||
79 | g_free(bus_name); | ||
84 | } | 80 | } |
85 | 81 | ||
86 | for (i = 0; i < nr_apu_cpus; i++) { | 82 | + dev = DEVICE(&s->emac); |
87 | - DeviceState *cpudev = DEVICE(s->fpd.apu.cpu[i]); | 83 | + object_property_set_link(OBJECT(&s->emac), OBJECT(get_system_memory()), |
88 | + DeviceState *cpudev = DEVICE(&s->fpd.apu.cpu[i]); | 84 | + "ahb-bus", &error_abort); |
89 | int ppibase = XLNX_VERSAL_NR_IRQS + i * GIC_INTERNAL + GIC_NR_SGIS; | 85 | + object_property_set_bool(OBJECT(&s->emac), true, "realized", &err); |
90 | qemu_irq maint_irq; | 86 | + if (err != NULL) { |
91 | int ti; | 87 | + error_propagate(errp, err); |
88 | + return; | ||
89 | + } | ||
90 | + busdev = SYS_BUS_DEVICE(dev); | ||
91 | + sysbus_mmio_map(busdev, 0, MSF2_EMAC_BASE); | ||
92 | + sysbus_connect_irq(busdev, 0, | ||
93 | + qdev_get_gpio_in(armv7m, MSF2_EMAC_IRQ)); | ||
94 | + | ||
95 | /* Below devices are not modelled yet. */ | ||
96 | create_unimplemented_device("i2c_0", 0x40002000, 0x1000); | ||
97 | create_unimplemented_device("dma", 0x40003000, 0x1000); | ||
98 | @@ -XXX,XX +XXX,XX @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp) | ||
99 | create_unimplemented_device("can", 0x40015000, 0x1000); | ||
100 | create_unimplemented_device("rtc", 0x40017000, 0x1000); | ||
101 | create_unimplemented_device("apb_config", 0x40020000, 0x10000); | ||
102 | - create_unimplemented_device("emac", 0x40041000, 0x1000); | ||
103 | create_unimplemented_device("usb", 0x40043000, 0x1000); | ||
104 | } | ||
105 | |||
92 | -- | 106 | -- |
93 | 2.20.1 | 107 | 2.20.1 |
94 | 108 | ||
95 | 109 | diff view generated by jsdifflib |
1 | Convert the Neon comparison ops in the 3-reg-same grouping | 1 | From: Subbaraya Sundeep <sundeep.lkml@gmail.com> |
---|---|---|---|
2 | to decodetree. | ||
3 | 2 | ||
3 | In addition to simple serial test this patch uses ping | ||
4 | to test the ethernet block modelled in SmartFusion2 SoC. | ||
5 | |||
6 | Signed-off-by: Subbaraya Sundeep <sundeep.lkml@gmail.com> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Message-id: 1587048891-30493-4-git-send-email-sundeep.lkml@gmail.com | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20200430181003.21682-18-peter.maydell@linaro.org | ||
7 | --- | 11 | --- |
8 | target/arm/neon-dp.decode | 8 ++++++++ | 12 | tests/acceptance/boot_linux_console.py | 15 ++++++++++----- |
9 | target/arm/translate-neon.inc.c | 22 ++++++++++++++++++++++ | 13 | 1 file changed, 10 insertions(+), 5 deletions(-) |
10 | target/arm/translate.c | 23 +++-------------------- | ||
11 | 3 files changed, 33 insertions(+), 20 deletions(-) | ||
12 | 14 | ||
13 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 15 | diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py |
14 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/neon-dp.decode | 17 | --- a/tests/acceptance/boot_linux_console.py |
16 | +++ b/target/arm/neon-dp.decode | 18 | +++ b/tests/acceptance/boot_linux_console.py |
17 | @@ -XXX,XX +XXX,XX @@ VBSL_3s 1111 001 1 0 . 01 .... .... 0001 ... 1 .... @3same_logic | 19 | @@ -XXX,XX +XXX,XX @@ class BootLinuxConsole(Test): |
18 | VBIT_3s 1111 001 1 0 . 10 .... .... 0001 ... 1 .... @3same_logic | 20 | """ |
19 | VBIF_3s 1111 001 1 0 . 11 .... .... 0001 ... 1 .... @3same_logic | 21 | uboot_url = ('https://raw.githubusercontent.com/' |
20 | 22 | 'Subbaraya-Sundeep/qemu-test-binaries/' | |
21 | +VCGT_S_3s 1111 001 0 0 . .. .... .... 0011 . . . 0 .... @3same | 23 | - 'fa030bd77a014a0b8e360d3b7011df89283a2f0b/u-boot') |
22 | +VCGT_U_3s 1111 001 1 0 . .. .... .... 0011 . . . 0 .... @3same | 24 | - uboot_hash = 'abba5d9c24cdd2d49cdc2a8aa92976cf20737eff' |
23 | +VCGE_S_3s 1111 001 0 0 . .. .... .... 0011 . . . 1 .... @3same | 25 | + 'fe371d32e50ca682391e1e70ab98c2942aeffb01/u-boot') |
24 | +VCGE_U_3s 1111 001 1 0 . .. .... .... 0011 . . . 1 .... @3same | 26 | + uboot_hash = 'cbb8cbab970f594bf6523b9855be209c08374ae2' |
27 | uboot_path = self.fetch_asset(uboot_url, asset_hash=uboot_hash) | ||
28 | spi_url = ('https://raw.githubusercontent.com/' | ||
29 | 'Subbaraya-Sundeep/qemu-test-binaries/' | ||
30 | - 'fa030bd77a014a0b8e360d3b7011df89283a2f0b/spi.bin') | ||
31 | - spi_hash = '85f698329d38de63aea6e884a86fbde70890a78a' | ||
32 | + 'fe371d32e50ca682391e1e70ab98c2942aeffb01/spi.bin') | ||
33 | + spi_hash = '65523a1835949b6f4553be96dec1b6a38fb05501' | ||
34 | spi_path = self.fetch_asset(spi_url, asset_hash=spi_hash) | ||
35 | |||
36 | self.vm.set_console() | ||
37 | @@ -XXX,XX +XXX,XX @@ class BootLinuxConsole(Test): | ||
38 | '-drive', 'file=' + spi_path + ',if=mtd,format=raw', | ||
39 | '-no-reboot') | ||
40 | self.vm.launch() | ||
41 | - self.wait_for_console_pattern('init started: BusyBox') | ||
42 | + self.wait_for_console_pattern('Enter \'help\' for a list') | ||
25 | + | 43 | + |
26 | VMAX_S_3s 1111 001 0 0 . .. .... .... 0110 . . . 0 .... @3same | 44 | + exec_command_and_wait_for_pattern(self, 'ifconfig eth0 10.0.2.15', |
27 | VMAX_U_3s 1111 001 1 0 . .. .... .... 0110 . . . 0 .... @3same | 45 | + 'eth0: link becomes ready') |
28 | VMIN_S_3s 1111 001 0 0 . .. .... .... 0110 . . . 1 .... @3same | 46 | + exec_command_and_wait_for_pattern(self, 'ping -c 3 10.0.2.2', |
29 | @@ -XXX,XX +XXX,XX @@ VMIN_U_3s 1111 001 1 0 . .. .... .... 0110 . . . 1 .... @3same | 47 | + '3 packets transmitted, 3 packets received, 0% packet loss') |
30 | 48 | ||
31 | VADD_3s 1111 001 0 0 . .. .... .... 1000 . . . 0 .... @3same | 49 | def do_test_arm_raspi2(self, uart_id): |
32 | VSUB_3s 1111 001 1 0 . .. .... .... 1000 . . . 0 .... @3same | 50 | """ |
33 | + | ||
34 | +VTST_3s 1111 001 0 0 . .. .... .... 1000 . . . 1 .... @3same | ||
35 | +VCEQ_3s 1111 001 1 0 . .. .... .... 1000 . . . 1 .... @3same | ||
36 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/target/arm/translate-neon.inc.c | ||
39 | +++ b/target/arm/translate-neon.inc.c | ||
40 | @@ -XXX,XX +XXX,XX @@ DO_3SAME_NO_SZ_3(VMAX_S, tcg_gen_gvec_smax) | ||
41 | DO_3SAME_NO_SZ_3(VMAX_U, tcg_gen_gvec_umax) | ||
42 | DO_3SAME_NO_SZ_3(VMIN_S, tcg_gen_gvec_smin) | ||
43 | DO_3SAME_NO_SZ_3(VMIN_U, tcg_gen_gvec_umin) | ||
44 | + | ||
45 | +#define DO_3SAME_CMP(INSN, COND) \ | ||
46 | + static void gen_##INSN##_3s(unsigned vece, uint32_t rd_ofs, \ | ||
47 | + uint32_t rn_ofs, uint32_t rm_ofs, \ | ||
48 | + uint32_t oprsz, uint32_t maxsz) \ | ||
49 | + { \ | ||
50 | + tcg_gen_gvec_cmp(COND, vece, rd_ofs, rn_ofs, rm_ofs, oprsz, maxsz); \ | ||
51 | + } \ | ||
52 | + DO_3SAME_NO_SZ_3(INSN, gen_##INSN##_3s) | ||
53 | + | ||
54 | +DO_3SAME_CMP(VCGT_S, TCG_COND_GT) | ||
55 | +DO_3SAME_CMP(VCGT_U, TCG_COND_GTU) | ||
56 | +DO_3SAME_CMP(VCGE_S, TCG_COND_GE) | ||
57 | +DO_3SAME_CMP(VCGE_U, TCG_COND_GEU) | ||
58 | +DO_3SAME_CMP(VCEQ, TCG_COND_EQ) | ||
59 | + | ||
60 | +static void gen_VTST_3s(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, | ||
61 | + uint32_t rm_ofs, uint32_t oprsz, uint32_t maxsz) | ||
62 | +{ | ||
63 | + tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, oprsz, maxsz, &cmtst_op[vece]); | ||
64 | +} | ||
65 | +DO_3SAME_NO_SZ_3(VTST, gen_VTST_3s) | ||
66 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/target/arm/translate.c | ||
69 | +++ b/target/arm/translate.c | ||
70 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
71 | u ? &mls_op[size] : &mla_op[size]); | ||
72 | return 0; | ||
73 | |||
74 | - case NEON_3R_VTST_VCEQ: | ||
75 | - if (u) { /* VCEQ */ | ||
76 | - tcg_gen_gvec_cmp(TCG_COND_EQ, size, rd_ofs, rn_ofs, rm_ofs, | ||
77 | - vec_size, vec_size); | ||
78 | - } else { /* VTST */ | ||
79 | - tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, | ||
80 | - vec_size, vec_size, &cmtst_op[size]); | ||
81 | - } | ||
82 | - return 0; | ||
83 | - | ||
84 | - case NEON_3R_VCGT: | ||
85 | - tcg_gen_gvec_cmp(u ? TCG_COND_GTU : TCG_COND_GT, size, | ||
86 | - rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size); | ||
87 | - return 0; | ||
88 | - | ||
89 | - case NEON_3R_VCGE: | ||
90 | - tcg_gen_gvec_cmp(u ? TCG_COND_GEU : TCG_COND_GE, size, | ||
91 | - rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size); | ||
92 | - return 0; | ||
93 | - | ||
94 | case NEON_3R_VSHL: | ||
95 | /* Note the operation is vshl vd,vm,vn */ | ||
96 | tcg_gen_gvec_3(rd_ofs, rm_ofs, rn_ofs, vec_size, vec_size, | ||
97 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
98 | case NEON_3R_LOGIC: | ||
99 | case NEON_3R_VMAX: | ||
100 | case NEON_3R_VMIN: | ||
101 | + case NEON_3R_VTST_VCEQ: | ||
102 | + case NEON_3R_VCGT: | ||
103 | + case NEON_3R_VCGE: | ||
104 | /* Already handled by decodetree */ | ||
105 | return 1; | ||
106 | } | ||
107 | -- | 51 | -- |
108 | 2.20.1 | 52 | 2.20.1 |
109 | 53 | ||
110 | 54 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | This object may be used to represent a clock inside a clock tree. |
---|---|---|---|
2 | 2 | ||
3 | Add support for SD. | 3 | A clock may be connected to another clock so that it receives update, |
4 | 4 | through a callback, whenever the source/parent clock is updated. | |
5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 5 | |
6 | Although only the root clock of a clock tree controls the values | ||
7 | (represented as periods) of all clocks in tree, each clock holds | ||
8 | a local state containing the current value so that it can be fetched | ||
9 | independently. It will allows us to fullfill migration requirements | ||
10 | by migrating each clock independently of others. | ||
11 | |||
12 | This is based on the original work of Frederic Konrad. | ||
13 | |||
14 | Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> | ||
6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 15 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
7 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | 16 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> |
8 | Message-id: 20200427181649.26851-11-edgar.iglesias@gmail.com | 17 | Message-id: 20200406135251.157596-2-damien.hedde@greensocs.com |
18 | [PMM: Use uint64_t rather than unsigned long long in trace events; | ||
19 | the dtrace backend can't handle the latter] | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 21 | --- |
11 | hw/arm/xlnx-versal-virt.c | 46 +++++++++++++++++++++++++++++++++++++++ | 22 | hw/core/Makefile.objs | 1 + |
12 | 1 file changed, 46 insertions(+) | 23 | include/hw/clock.h | 216 ++++++++++++++++++++++++++++++++++++++++++ |
13 | 24 | hw/core/clock.c | 130 +++++++++++++++++++++++++ | |
14 | diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c | 25 | hw/core/trace-events | 7 ++ |
26 | 4 files changed, 354 insertions(+) | ||
27 | create mode 100644 include/hw/clock.h | ||
28 | create mode 100644 hw/core/clock.c | ||
29 | |||
30 | diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs | ||
15 | index XXXXXXX..XXXXXXX 100644 | 31 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/arm/xlnx-versal-virt.c | 32 | --- a/hw/core/Makefile.objs |
17 | +++ b/hw/arm/xlnx-versal-virt.c | 33 | +++ b/hw/core/Makefile.objs |
34 | @@ -XXX,XX +XXX,XX @@ common-obj-y += hotplug.o | ||
35 | common-obj-y += vmstate-if.o | ||
36 | # irq.o needed for qdev GPIO handling: | ||
37 | common-obj-y += irq.o | ||
38 | +common-obj-y += clock.o | ||
39 | |||
40 | common-obj-$(CONFIG_SOFTMMU) += reset.o | ||
41 | common-obj-$(CONFIG_SOFTMMU) += qdev-fw.o | ||
42 | diff --git a/include/hw/clock.h b/include/hw/clock.h | ||
43 | new file mode 100644 | ||
44 | index XXXXXXX..XXXXXXX | ||
45 | --- /dev/null | ||
46 | +++ b/include/hw/clock.h | ||
18 | @@ -XXX,XX +XXX,XX @@ | 47 | @@ -XXX,XX +XXX,XX @@ |
19 | #include "hw/arm/sysbus-fdt.h" | 48 | +/* |
20 | #include "hw/arm/fdt.h" | 49 | + * Hardware Clocks |
21 | #include "cpu.h" | 50 | + * |
22 | +#include "hw/qdev-properties.h" | 51 | + * Copyright GreenSocs 2016-2020 |
23 | #include "hw/arm/xlnx-versal.h" | 52 | + * |
24 | 53 | + * Authors: | |
25 | #define TYPE_XLNX_VERSAL_VIRT_MACHINE MACHINE_TYPE_NAME("xlnx-versal-virt") | 54 | + * Frederic Konrad |
26 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_zdma_nodes(VersalVirt *s) | 55 | + * Damien Hedde |
27 | } | 56 | + * |
28 | } | 57 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. |
29 | 58 | + * See the COPYING file in the top-level directory. | |
30 | +static void fdt_add_sd_nodes(VersalVirt *s) | 59 | + */ |
31 | +{ | 60 | + |
32 | + const char clocknames[] = "clk_xin\0clk_ahb"; | 61 | +#ifndef QEMU_HW_CLOCK_H |
33 | + const char compat[] = "arasan,sdhci-8.9a"; | 62 | +#define QEMU_HW_CLOCK_H |
34 | + int i; | 63 | + |
35 | + | 64 | +#include "qom/object.h" |
36 | + for (i = ARRAY_SIZE(s->soc.pmc.iou.sd) - 1; i >= 0; i--) { | 65 | +#include "qemu/queue.h" |
37 | + uint64_t addr = MM_PMC_SD0 + MM_PMC_SD0_SIZE * i; | 66 | + |
38 | + char *name = g_strdup_printf("/sdhci@%" PRIx64, addr); | 67 | +#define TYPE_CLOCK "clock" |
39 | + | 68 | +#define CLOCK(obj) OBJECT_CHECK(Clock, (obj), TYPE_CLOCK) |
40 | + qemu_fdt_add_subnode(s->fdt, name); | 69 | + |
41 | + | 70 | +typedef void ClockCallback(void *opaque); |
42 | + qemu_fdt_setprop_cells(s->fdt, name, "clocks", | 71 | + |
43 | + s->phandle.clk_25Mhz, s->phandle.clk_25Mhz); | 72 | +/* |
44 | + qemu_fdt_setprop(s->fdt, name, "clock-names", | 73 | + * clock store a value representing the clock's period in 2^-32ns unit. |
45 | + clocknames, sizeof(clocknames)); | 74 | + * It can represent: |
46 | + qemu_fdt_setprop_cells(s->fdt, name, "interrupts", | 75 | + * + periods from 2^-32ns up to 4seconds |
47 | + GIC_FDT_IRQ_TYPE_SPI, VERSAL_SD0_IRQ_0 + i * 2, | 76 | + * + frequency from ~0.25Hz 2e10Ghz |
48 | + GIC_FDT_IRQ_FLAGS_LEVEL_HI); | 77 | + * Resolution of frequency representation decreases with frequency: |
49 | + qemu_fdt_setprop_sized_cells(s->fdt, name, "reg", | 78 | + * + at 100MHz, resolution is ~2mHz |
50 | + 2, addr, 2, MM_PMC_SD0_SIZE); | 79 | + * + at 1Ghz, resolution is ~0.2Hz |
51 | + qemu_fdt_setprop(s->fdt, name, "compatible", compat, sizeof(compat)); | 80 | + * + at 10Ghz, resolution is ~20Hz |
52 | + g_free(name); | 81 | + */ |
82 | +#define CLOCK_SECOND (1000000000llu << 32) | ||
83 | + | ||
84 | +/* | ||
85 | + * macro helpers to convert to hertz / nanosecond | ||
86 | + */ | ||
87 | +#define CLOCK_PERIOD_FROM_NS(ns) ((ns) * (CLOCK_SECOND / 1000000000llu)) | ||
88 | +#define CLOCK_PERIOD_TO_NS(per) ((per) / (CLOCK_SECOND / 1000000000llu)) | ||
89 | +#define CLOCK_PERIOD_FROM_HZ(hz) (((hz) != 0) ? CLOCK_SECOND / (hz) : 0u) | ||
90 | +#define CLOCK_PERIOD_TO_HZ(per) (((per) != 0) ? CLOCK_SECOND / (per) : 0u) | ||
91 | + | ||
92 | +/** | ||
93 | + * Clock: | ||
94 | + * @parent_obj: parent class | ||
95 | + * @period: unsigned integer representing the period of the clock | ||
96 | + * @canonical_path: clock path string cache (used for trace purpose) | ||
97 | + * @callback: called when clock changes | ||
98 | + * @callback_opaque: argument for @callback | ||
99 | + * @source: source (or parent in clock tree) of the clock | ||
100 | + * @children: list of clocks connected to this one (it is their source) | ||
101 | + * @sibling: structure used to form a clock list | ||
102 | + */ | ||
103 | + | ||
104 | +typedef struct Clock Clock; | ||
105 | + | ||
106 | +struct Clock { | ||
107 | + /*< private >*/ | ||
108 | + Object parent_obj; | ||
109 | + | ||
110 | + /* all fields are private and should not be modified directly */ | ||
111 | + | ||
112 | + /* fields */ | ||
113 | + uint64_t period; | ||
114 | + char *canonical_path; | ||
115 | + ClockCallback *callback; | ||
116 | + void *callback_opaque; | ||
117 | + | ||
118 | + /* Clocks are organized in a clock tree */ | ||
119 | + Clock *source; | ||
120 | + QLIST_HEAD(, Clock) children; | ||
121 | + QLIST_ENTRY(Clock) sibling; | ||
122 | +}; | ||
123 | + | ||
124 | +/** | ||
125 | + * clock_setup_canonical_path: | ||
126 | + * @clk: clock | ||
127 | + * | ||
128 | + * compute the canonical path of the clock (used by log messages) | ||
129 | + */ | ||
130 | +void clock_setup_canonical_path(Clock *clk); | ||
131 | + | ||
132 | +/** | ||
133 | + * clock_set_callback: | ||
134 | + * @clk: the clock to register the callback into | ||
135 | + * @cb: the callback function | ||
136 | + * @opaque: the argument to the callback | ||
137 | + * | ||
138 | + * Register a callback called on every clock update. | ||
139 | + */ | ||
140 | +void clock_set_callback(Clock *clk, ClockCallback *cb, void *opaque); | ||
141 | + | ||
142 | +/** | ||
143 | + * clock_clear_callback: | ||
144 | + * @clk: the clock to delete the callback from | ||
145 | + * | ||
146 | + * Unregister the callback registered with clock_set_callback. | ||
147 | + */ | ||
148 | +void clock_clear_callback(Clock *clk); | ||
149 | + | ||
150 | +/** | ||
151 | + * clock_set_source: | ||
152 | + * @clk: the clock. | ||
153 | + * @src: the source clock | ||
154 | + * | ||
155 | + * Setup @src as the clock source of @clk. The current @src period | ||
156 | + * value is also copied to @clk and its subtree but no callback is | ||
157 | + * called. | ||
158 | + * Further @src update will be propagated to @clk and its subtree. | ||
159 | + */ | ||
160 | +void clock_set_source(Clock *clk, Clock *src); | ||
161 | + | ||
162 | +/** | ||
163 | + * clock_set: | ||
164 | + * @clk: the clock to initialize. | ||
165 | + * @value: the clock's value, 0 means unclocked | ||
166 | + * | ||
167 | + * Set the local cached period value of @clk to @value. | ||
168 | + */ | ||
169 | +void clock_set(Clock *clk, uint64_t value); | ||
170 | + | ||
171 | +static inline void clock_set_hz(Clock *clk, unsigned hz) | ||
172 | +{ | ||
173 | + clock_set(clk, CLOCK_PERIOD_FROM_HZ(hz)); | ||
174 | +} | ||
175 | + | ||
176 | +static inline void clock_set_ns(Clock *clk, unsigned ns) | ||
177 | +{ | ||
178 | + clock_set(clk, CLOCK_PERIOD_FROM_NS(ns)); | ||
179 | +} | ||
180 | + | ||
181 | +/** | ||
182 | + * clock_propagate: | ||
183 | + * @clk: the clock | ||
184 | + * | ||
185 | + * Propagate the clock period that has been previously configured using | ||
186 | + * @clock_set(). This will update recursively all connected clocks. | ||
187 | + * It is an error to call this function on a clock which has a source. | ||
188 | + * Note: this function must not be called during device inititialization | ||
189 | + * or migration. | ||
190 | + */ | ||
191 | +void clock_propagate(Clock *clk); | ||
192 | + | ||
193 | +/** | ||
194 | + * clock_update: | ||
195 | + * @clk: the clock to update. | ||
196 | + * @value: the new clock's value, 0 means unclocked | ||
197 | + * | ||
198 | + * Update the @clk to the new @value. All connected clocks will be informed | ||
199 | + * of this update. This is equivalent to call @clock_set() then | ||
200 | + * @clock_propagate(). | ||
201 | + */ | ||
202 | +static inline void clock_update(Clock *clk, uint64_t value) | ||
203 | +{ | ||
204 | + clock_set(clk, value); | ||
205 | + clock_propagate(clk); | ||
206 | +} | ||
207 | + | ||
208 | +static inline void clock_update_hz(Clock *clk, unsigned hz) | ||
209 | +{ | ||
210 | + clock_update(clk, CLOCK_PERIOD_FROM_HZ(hz)); | ||
211 | +} | ||
212 | + | ||
213 | +static inline void clock_update_ns(Clock *clk, unsigned ns) | ||
214 | +{ | ||
215 | + clock_update(clk, CLOCK_PERIOD_FROM_NS(ns)); | ||
216 | +} | ||
217 | + | ||
218 | +/** | ||
219 | + * clock_get: | ||
220 | + * @clk: the clk to fetch the clock | ||
221 | + * | ||
222 | + * @return: the current period. | ||
223 | + */ | ||
224 | +static inline uint64_t clock_get(const Clock *clk) | ||
225 | +{ | ||
226 | + return clk->period; | ||
227 | +} | ||
228 | + | ||
229 | +static inline unsigned clock_get_hz(Clock *clk) | ||
230 | +{ | ||
231 | + return CLOCK_PERIOD_TO_HZ(clock_get(clk)); | ||
232 | +} | ||
233 | + | ||
234 | +static inline unsigned clock_get_ns(Clock *clk) | ||
235 | +{ | ||
236 | + return CLOCK_PERIOD_TO_NS(clock_get(clk)); | ||
237 | +} | ||
238 | + | ||
239 | +/** | ||
240 | + * clock_is_enabled: | ||
241 | + * @clk: a clock | ||
242 | + * | ||
243 | + * @return: true if the clock is running. | ||
244 | + */ | ||
245 | +static inline bool clock_is_enabled(const Clock *clk) | ||
246 | +{ | ||
247 | + return clock_get(clk) != 0; | ||
248 | +} | ||
249 | + | ||
250 | +static inline void clock_init(Clock *clk, uint64_t value) | ||
251 | +{ | ||
252 | + clock_set(clk, value); | ||
253 | +} | ||
254 | +static inline void clock_init_hz(Clock *clk, uint64_t value) | ||
255 | +{ | ||
256 | + clock_set_hz(clk, value); | ||
257 | +} | ||
258 | +static inline void clock_init_ns(Clock *clk, uint64_t value) | ||
259 | +{ | ||
260 | + clock_set_ns(clk, value); | ||
261 | +} | ||
262 | + | ||
263 | +#endif /* QEMU_HW_CLOCK_H */ | ||
264 | diff --git a/hw/core/clock.c b/hw/core/clock.c | ||
265 | new file mode 100644 | ||
266 | index XXXXXXX..XXXXXXX | ||
267 | --- /dev/null | ||
268 | +++ b/hw/core/clock.c | ||
269 | @@ -XXX,XX +XXX,XX @@ | ||
270 | +/* | ||
271 | + * Hardware Clocks | ||
272 | + * | ||
273 | + * Copyright GreenSocs 2016-2020 | ||
274 | + * | ||
275 | + * Authors: | ||
276 | + * Frederic Konrad | ||
277 | + * Damien Hedde | ||
278 | + * | ||
279 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
280 | + * See the COPYING file in the top-level directory. | ||
281 | + */ | ||
282 | + | ||
283 | +#include "qemu/osdep.h" | ||
284 | +#include "hw/clock.h" | ||
285 | +#include "trace.h" | ||
286 | + | ||
287 | +#define CLOCK_PATH(_clk) (_clk->canonical_path) | ||
288 | + | ||
289 | +void clock_setup_canonical_path(Clock *clk) | ||
290 | +{ | ||
291 | + g_free(clk->canonical_path); | ||
292 | + clk->canonical_path = object_get_canonical_path(OBJECT(clk)); | ||
293 | +} | ||
294 | + | ||
295 | +void clock_set_callback(Clock *clk, ClockCallback *cb, void *opaque) | ||
296 | +{ | ||
297 | + clk->callback = cb; | ||
298 | + clk->callback_opaque = opaque; | ||
299 | +} | ||
300 | + | ||
301 | +void clock_clear_callback(Clock *clk) | ||
302 | +{ | ||
303 | + clock_set_callback(clk, NULL, NULL); | ||
304 | +} | ||
305 | + | ||
306 | +void clock_set(Clock *clk, uint64_t period) | ||
307 | +{ | ||
308 | + trace_clock_set(CLOCK_PATH(clk), CLOCK_PERIOD_TO_NS(clk->period), | ||
309 | + CLOCK_PERIOD_TO_NS(period)); | ||
310 | + clk->period = period; | ||
311 | +} | ||
312 | + | ||
313 | +static void clock_propagate_period(Clock *clk, bool call_callbacks) | ||
314 | +{ | ||
315 | + Clock *child; | ||
316 | + | ||
317 | + QLIST_FOREACH(child, &clk->children, sibling) { | ||
318 | + if (child->period != clk->period) { | ||
319 | + child->period = clk->period; | ||
320 | + trace_clock_update(CLOCK_PATH(child), CLOCK_PATH(clk), | ||
321 | + CLOCK_PERIOD_TO_NS(clk->period), | ||
322 | + call_callbacks); | ||
323 | + if (call_callbacks && child->callback) { | ||
324 | + child->callback(child->callback_opaque); | ||
325 | + } | ||
326 | + clock_propagate_period(child, call_callbacks); | ||
327 | + } | ||
53 | + } | 328 | + } |
54 | +} | 329 | +} |
55 | + | 330 | + |
56 | static void fdt_nop_memory_nodes(void *fdt, Error **errp) | 331 | +void clock_propagate(Clock *clk) |
57 | { | 332 | +{ |
58 | Error *err = NULL; | 333 | + assert(clk->source == NULL); |
59 | @@ -XXX,XX +XXX,XX @@ static void create_virtio_regions(VersalVirt *s) | 334 | + trace_clock_propagate(CLOCK_PATH(clk)); |
60 | } | 335 | + clock_propagate_period(clk, true); |
61 | } | 336 | +} |
62 | 337 | + | |
63 | +static void sd_plugin_card(SDHCIState *sd, DriveInfo *di) | 338 | +void clock_set_source(Clock *clk, Clock *src) |
64 | +{ | 339 | +{ |
65 | + BlockBackend *blk = di ? blk_by_legacy_dinfo(di) : NULL; | 340 | + /* changing clock source is not supported */ |
66 | + DeviceState *card; | 341 | + assert(!clk->source); |
67 | + | 342 | + |
68 | + card = qdev_create(qdev_get_child_bus(DEVICE(sd), "sd-bus"), TYPE_SD_CARD); | 343 | + trace_clock_set_source(CLOCK_PATH(clk), CLOCK_PATH(src)); |
69 | + object_property_add_child(OBJECT(sd), "card[*]", OBJECT(card), | 344 | + |
70 | + &error_fatal); | 345 | + clk->period = src->period; |
71 | + qdev_prop_set_drive(card, "drive", blk, &error_fatal); | 346 | + QLIST_INSERT_HEAD(&src->children, clk, sibling); |
72 | + object_property_set_bool(OBJECT(card), true, "realized", &error_fatal); | 347 | + clk->source = src; |
73 | +} | 348 | + clock_propagate_period(clk, false); |
74 | + | 349 | +} |
75 | static void versal_virt_init(MachineState *machine) | 350 | + |
76 | { | 351 | +static void clock_disconnect(Clock *clk) |
77 | VersalVirt *s = XLNX_VERSAL_VIRT_MACHINE(machine); | 352 | +{ |
78 | int psci_conduit = QEMU_PSCI_CONDUIT_DISABLED; | 353 | + if (clk->source == NULL) { |
79 | + int i; | 354 | + return; |
80 | |||
81 | /* | ||
82 | * If the user provides an Operating System to be loaded, we expect them | ||
83 | @@ -XXX,XX +XXX,XX @@ static void versal_virt_init(MachineState *machine) | ||
84 | fdt_add_gic_nodes(s); | ||
85 | fdt_add_timer_nodes(s); | ||
86 | fdt_add_zdma_nodes(s); | ||
87 | + fdt_add_sd_nodes(s); | ||
88 | fdt_add_cpu_nodes(s, psci_conduit); | ||
89 | fdt_add_clk_node(s, "/clk125", 125000000, s->phandle.clk_125Mhz); | ||
90 | fdt_add_clk_node(s, "/clk25", 25000000, s->phandle.clk_25Mhz); | ||
91 | @@ -XXX,XX +XXX,XX @@ static void versal_virt_init(MachineState *machine) | ||
92 | memory_region_add_subregion_overlap(get_system_memory(), | ||
93 | 0, &s->soc.fpd.apu.mr, 0); | ||
94 | |||
95 | + /* Plugin SD cards. */ | ||
96 | + for (i = 0; i < ARRAY_SIZE(s->soc.pmc.iou.sd); i++) { | ||
97 | + sd_plugin_card(&s->soc.pmc.iou.sd[i], drive_get_next(IF_SD)); | ||
98 | + } | 355 | + } |
99 | + | 356 | + |
100 | s->binfo.ram_size = machine->ram_size; | 357 | + trace_clock_disconnect(CLOCK_PATH(clk)); |
101 | s->binfo.loader_start = 0x0; | 358 | + |
102 | s->binfo.get_dtb = versal_virt_get_dtb; | 359 | + clk->source = NULL; |
360 | + QLIST_REMOVE(clk, sibling); | ||
361 | +} | ||
362 | + | ||
363 | +static void clock_initfn(Object *obj) | ||
364 | +{ | ||
365 | + Clock *clk = CLOCK(obj); | ||
366 | + | ||
367 | + QLIST_INIT(&clk->children); | ||
368 | +} | ||
369 | + | ||
370 | +static void clock_finalizefn(Object *obj) | ||
371 | +{ | ||
372 | + Clock *clk = CLOCK(obj); | ||
373 | + Clock *child, *next; | ||
374 | + | ||
375 | + /* clear our list of children */ | ||
376 | + QLIST_FOREACH_SAFE(child, &clk->children, sibling, next) { | ||
377 | + clock_disconnect(child); | ||
378 | + } | ||
379 | + | ||
380 | + /* remove us from source's children list */ | ||
381 | + clock_disconnect(clk); | ||
382 | + | ||
383 | + g_free(clk->canonical_path); | ||
384 | +} | ||
385 | + | ||
386 | +static const TypeInfo clock_info = { | ||
387 | + .name = TYPE_CLOCK, | ||
388 | + .parent = TYPE_OBJECT, | ||
389 | + .instance_size = sizeof(Clock), | ||
390 | + .instance_init = clock_initfn, | ||
391 | + .instance_finalize = clock_finalizefn, | ||
392 | +}; | ||
393 | + | ||
394 | +static void clock_register_types(void) | ||
395 | +{ | ||
396 | + type_register_static(&clock_info); | ||
397 | +} | ||
398 | + | ||
399 | +type_init(clock_register_types) | ||
400 | diff --git a/hw/core/trace-events b/hw/core/trace-events | ||
401 | index XXXXXXX..XXXXXXX 100644 | ||
402 | --- a/hw/core/trace-events | ||
403 | +++ b/hw/core/trace-events | ||
404 | @@ -XXX,XX +XXX,XX @@ resettable_phase_exit_begin(void *obj, const char *objtype, unsigned count, int | ||
405 | resettable_phase_exit_exec(void *obj, const char *objtype, int has_method) "obj=%p(%s) method=%d" | ||
406 | resettable_phase_exit_end(void *obj, const char *objtype, unsigned count) "obj=%p(%s) count=%d" | ||
407 | resettable_transitional_function(void *obj, const char *objtype) "obj=%p(%s)" | ||
408 | + | ||
409 | +# clock.c | ||
410 | +clock_set_source(const char *clk, const char *src) "'%s', src='%s'" | ||
411 | +clock_disconnect(const char *clk) "'%s'" | ||
412 | +clock_set(const char *clk, uint64_t old, uint64_t new) "'%s', ns=%"PRIu64"->%"PRIu64 | ||
413 | +clock_propagate(const char *clk) "'%s'" | ||
414 | +clock_update(const char *clk, const char *src, uint64_t val, int cb) "'%s', src='%s', ns=%"PRIu64", cb=%d" | ||
103 | -- | 415 | -- |
104 | 2.20.1 | 416 | 2.20.1 |
105 | 417 | ||
106 | 418 | diff view generated by jsdifflib |
1 | Convert the Neon 3-reg-same VMAX and VMIN insns to decodetree. | 1 | From: Damien Hedde <damien.hedde@greensocs.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
7 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
8 | Message-id: 20200406135251.157596-3-damien.hedde@greensocs.com | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20200430181003.21682-17-peter.maydell@linaro.org | ||
6 | --- | 10 | --- |
7 | target/arm/neon-dp.decode | 5 +++++ | 11 | hw/core/Makefile.objs | 1 + |
8 | target/arm/translate-neon.inc.c | 14 ++++++++++++++ | 12 | include/hw/clock.h | 9 +++++++++ |
9 | target/arm/translate.c | 21 ++------------------- | 13 | hw/core/clock-vmstate.c | 25 +++++++++++++++++++++++++ |
10 | 3 files changed, 21 insertions(+), 19 deletions(-) | 14 | 3 files changed, 35 insertions(+) |
15 | create mode 100644 hw/core/clock-vmstate.c | ||
11 | 16 | ||
12 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 17 | diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs |
13 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/neon-dp.decode | 19 | --- a/hw/core/Makefile.objs |
15 | +++ b/target/arm/neon-dp.decode | 20 | +++ b/hw/core/Makefile.objs |
16 | @@ -XXX,XX +XXX,XX @@ VBSL_3s 1111 001 1 0 . 01 .... .... 0001 ... 1 .... @3same_logic | 21 | @@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_SOFTMMU) += null-machine.o |
17 | VBIT_3s 1111 001 1 0 . 10 .... .... 0001 ... 1 .... @3same_logic | 22 | common-obj-$(CONFIG_SOFTMMU) += loader.o |
18 | VBIF_3s 1111 001 1 0 . 11 .... .... 0001 ... 1 .... @3same_logic | 23 | common-obj-$(CONFIG_SOFTMMU) += machine-hmp-cmds.o |
19 | 24 | common-obj-$(CONFIG_SOFTMMU) += numa.o | |
20 | +VMAX_S_3s 1111 001 0 0 . .. .... .... 0110 . . . 0 .... @3same | 25 | +common-obj-$(CONFIG_SOFTMMU) += clock-vmstate.o |
21 | +VMAX_U_3s 1111 001 1 0 . .. .... .... 0110 . . . 0 .... @3same | 26 | obj-$(CONFIG_SOFTMMU) += machine-qmp-cmds.o |
22 | +VMIN_S_3s 1111 001 0 0 . .. .... .... 0110 . . . 1 .... @3same | 27 | |
23 | +VMIN_U_3s 1111 001 1 0 . .. .... .... 0110 . . . 1 .... @3same | 28 | common-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o |
29 | diff --git a/include/hw/clock.h b/include/hw/clock.h | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/include/hw/clock.h | ||
32 | +++ b/include/hw/clock.h | ||
33 | @@ -XXX,XX +XXX,XX @@ struct Clock { | ||
34 | QLIST_ENTRY(Clock) sibling; | ||
35 | }; | ||
36 | |||
37 | +/* | ||
38 | + * vmstate description entry to be added in device vmsd. | ||
39 | + */ | ||
40 | +extern const VMStateDescription vmstate_clock; | ||
41 | +#define VMSTATE_CLOCK(field, state) \ | ||
42 | + VMSTATE_CLOCK_V(field, state, 0) | ||
43 | +#define VMSTATE_CLOCK_V(field, state, version) \ | ||
44 | + VMSTATE_STRUCT_POINTER_V(field, state, version, vmstate_clock, Clock) | ||
24 | + | 45 | + |
25 | VADD_3s 1111 001 0 0 . .. .... .... 1000 . . . 0 .... @3same | 46 | /** |
26 | VSUB_3s 1111 001 1 0 . .. .... .... 1000 . . . 0 .... @3same | 47 | * clock_setup_canonical_path: |
27 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | 48 | * @clk: clock |
28 | index XXXXXXX..XXXXXXX 100644 | 49 | diff --git a/hw/core/clock-vmstate.c b/hw/core/clock-vmstate.c |
29 | --- a/target/arm/translate-neon.inc.c | 50 | new file mode 100644 |
30 | +++ b/target/arm/translate-neon.inc.c | 51 | index XXXXXXX..XXXXXXX |
31 | @@ -XXX,XX +XXX,XX @@ DO_3SAME(VEOR, tcg_gen_gvec_xor) | 52 | --- /dev/null |
32 | DO_3SAME_BITSEL(VBSL, rd_ofs, rn_ofs, rm_ofs) | 53 | +++ b/hw/core/clock-vmstate.c |
33 | DO_3SAME_BITSEL(VBIT, rm_ofs, rn_ofs, rd_ofs) | 54 | @@ -XXX,XX +XXX,XX @@ |
34 | DO_3SAME_BITSEL(VBIF, rm_ofs, rd_ofs, rn_ofs) | 55 | +/* |
56 | + * Clock migration structure | ||
57 | + * | ||
58 | + * Copyright GreenSocs 2019-2020 | ||
59 | + * | ||
60 | + * Authors: | ||
61 | + * Damien Hedde | ||
62 | + * | ||
63 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
64 | + * See the COPYING file in the top-level directory. | ||
65 | + */ | ||
35 | + | 66 | + |
36 | +#define DO_3SAME_NO_SZ_3(INSN, FUNC) \ | 67 | +#include "qemu/osdep.h" |
37 | + static bool trans_##INSN##_3s(DisasContext *s, arg_3same *a) \ | 68 | +#include "migration/vmstate.h" |
38 | + { \ | 69 | +#include "hw/clock.h" |
39 | + if (a->size == 3) { \ | 70 | + |
40 | + return false; \ | 71 | +const VMStateDescription vmstate_clock = { |
41 | + } \ | 72 | + .name = "clock", |
42 | + return do_3same(s, a, FUNC); \ | 73 | + .version_id = 0, |
74 | + .minimum_version_id = 0, | ||
75 | + .fields = (VMStateField[]) { | ||
76 | + VMSTATE_UINT64(period, Clock), | ||
77 | + VMSTATE_END_OF_LIST() | ||
43 | + } | 78 | + } |
44 | + | 79 | +}; |
45 | +DO_3SAME_NO_SZ_3(VMAX_S, tcg_gen_gvec_smax) | ||
46 | +DO_3SAME_NO_SZ_3(VMAX_U, tcg_gen_gvec_umax) | ||
47 | +DO_3SAME_NO_SZ_3(VMIN_S, tcg_gen_gvec_smin) | ||
48 | +DO_3SAME_NO_SZ_3(VMIN_U, tcg_gen_gvec_umin) | ||
49 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/target/arm/translate.c | ||
52 | +++ b/target/arm/translate.c | ||
53 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
54 | rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size); | ||
55 | return 0; | ||
56 | |||
57 | - case NEON_3R_VMAX: | ||
58 | - if (u) { | ||
59 | - tcg_gen_gvec_umax(size, rd_ofs, rn_ofs, rm_ofs, | ||
60 | - vec_size, vec_size); | ||
61 | - } else { | ||
62 | - tcg_gen_gvec_smax(size, rd_ofs, rn_ofs, rm_ofs, | ||
63 | - vec_size, vec_size); | ||
64 | - } | ||
65 | - return 0; | ||
66 | - case NEON_3R_VMIN: | ||
67 | - if (u) { | ||
68 | - tcg_gen_gvec_umin(size, rd_ofs, rn_ofs, rm_ofs, | ||
69 | - vec_size, vec_size); | ||
70 | - } else { | ||
71 | - tcg_gen_gvec_smin(size, rd_ofs, rn_ofs, rm_ofs, | ||
72 | - vec_size, vec_size); | ||
73 | - } | ||
74 | - return 0; | ||
75 | - | ||
76 | case NEON_3R_VSHL: | ||
77 | /* Note the operation is vshl vd,vm,vn */ | ||
78 | tcg_gen_gvec_3(rd_ofs, rm_ofs, rn_ofs, vec_size, vec_size, | ||
79 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
80 | |||
81 | case NEON_3R_VADD_VSUB: | ||
82 | case NEON_3R_LOGIC: | ||
83 | + case NEON_3R_VMAX: | ||
84 | + case NEON_3R_VMIN: | ||
85 | /* Already handled by decodetree */ | ||
86 | return 1; | ||
87 | } | ||
88 | -- | 80 | -- |
89 | 2.20.1 | 81 | 2.20.1 |
90 | 82 | ||
91 | 83 | diff view generated by jsdifflib |
1 | Add the infrastructure for building and invoking a decodetree decoder | 1 | From: Damien Hedde <damien.hedde@greensocs.com> |
---|---|---|---|
2 | for the AArch32 Neon encodings. At the moment the new decoder covers | 2 | |
3 | nothing, so we always fall back to the existing hand-written decode. | 3 | Add functions to easily handle clocks with devices. |
4 | 4 | Clock inputs and outputs should be used to handle clock propagation | |
5 | We follow the same pattern we did for the VFP decodetree conversion | 5 | between devices. |
6 | (commit 78e138bc1f672c145ef6ace74617d and following): code that deals | 6 | The API is very similar the GPIO API. |
7 | with Neon will be moving gradually out to translate-neon.vfp.inc, | 7 | |
8 | which we #include into translate.c. | 8 | This is based on the original work of Frederic Konrad. |
9 | 9 | ||
10 | In order to share the decode files between A32 and T32, we | 10 | Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> |
11 | split Neon into 3 parts: | 11 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> |
12 | * data-processing | 12 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
13 | * load-store | 13 | Message-id: 20200406135251.157596-4-damien.hedde@greensocs.com |
14 | * 'shared' encodings | ||
15 | |||
16 | The first two groups of instructions have similar but not identical | ||
17 | A32 and T32 encodings, so we need to manually transform the T32 | ||
18 | encoding into the A32 one before calling the decoder; the third group | ||
19 | covers the Neon instructions which are identical in A32 and T32. | ||
20 | |||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
22 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
23 | Message-id: 20200430181003.21682-4-peter.maydell@linaro.org | ||
24 | --- | 15 | --- |
25 | target/arm/neon-dp.decode | 29 ++++++++++++++++++++++++++ | 16 | hw/core/Makefile.objs | 2 +- |
26 | target/arm/neon-ls.decode | 29 ++++++++++++++++++++++++++ | 17 | tests/Makefile.include | 1 + |
27 | target/arm/neon-shared.decode | 27 +++++++++++++++++++++++++ | 18 | include/hw/qdev-clock.h | 104 +++++++++++++++++++++++++ |
28 | target/arm/translate-neon.inc.c | 32 +++++++++++++++++++++++++++++ | 19 | include/hw/qdev-core.h | 12 +++ |
29 | target/arm/translate.c | 36 +++++++++++++++++++++++++++++++-- | 20 | hw/core/qdev-clock.c | 168 ++++++++++++++++++++++++++++++++++++++++ |
30 | target/arm/Makefile.objs | 18 +++++++++++++++++ | 21 | hw/core/qdev.c | 12 +++ |
31 | 6 files changed, 169 insertions(+), 2 deletions(-) | 22 | 6 files changed, 298 insertions(+), 1 deletion(-) |
32 | create mode 100644 target/arm/neon-dp.decode | 23 | create mode 100644 include/hw/qdev-clock.h |
33 | create mode 100644 target/arm/neon-ls.decode | 24 | create mode 100644 hw/core/qdev-clock.c |
34 | create mode 100644 target/arm/neon-shared.decode | 25 | |
35 | create mode 100644 target/arm/translate-neon.inc.c | 26 | diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs |
36 | 27 | index XXXXXXX..XXXXXXX 100644 | |
37 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 28 | --- a/hw/core/Makefile.objs |
29 | +++ b/hw/core/Makefile.objs | ||
30 | @@ -XXX,XX +XXX,XX @@ common-obj-y += hotplug.o | ||
31 | common-obj-y += vmstate-if.o | ||
32 | # irq.o needed for qdev GPIO handling: | ||
33 | common-obj-y += irq.o | ||
34 | -common-obj-y += clock.o | ||
35 | +common-obj-y += clock.o qdev-clock.o | ||
36 | |||
37 | common-obj-$(CONFIG_SOFTMMU) += reset.o | ||
38 | common-obj-$(CONFIG_SOFTMMU) += qdev-fw.o | ||
39 | diff --git a/tests/Makefile.include b/tests/Makefile.include | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/tests/Makefile.include | ||
42 | +++ b/tests/Makefile.include | ||
43 | @@ -XXX,XX +XXX,XX @@ tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \ | ||
44 | hw/core/fw-path-provider.o \ | ||
45 | hw/core/reset.o \ | ||
46 | hw/core/vmstate-if.o \ | ||
47 | + hw/core/clock.o hw/core/qdev-clock.o \ | ||
48 | $(test-qapi-obj-y) | ||
49 | tests/test-vmstate$(EXESUF): tests/test-vmstate.o \ | ||
50 | migration/vmstate.o migration/vmstate-types.o migration/qemu-file.o \ | ||
51 | diff --git a/include/hw/qdev-clock.h b/include/hw/qdev-clock.h | ||
38 | new file mode 100644 | 52 | new file mode 100644 |
39 | index XXXXXXX..XXXXXXX | 53 | index XXXXXXX..XXXXXXX |
40 | --- /dev/null | 54 | --- /dev/null |
41 | +++ b/target/arm/neon-dp.decode | 55 | +++ b/include/hw/qdev-clock.h |
42 | @@ -XXX,XX +XXX,XX @@ | 56 | @@ -XXX,XX +XXX,XX @@ |
43 | +# AArch32 Neon data-processing instruction descriptions | 57 | +/* |
44 | +# | 58 | + * Device's clock input and output |
45 | +# Copyright (c) 2020 Linaro, Ltd | 59 | + * |
46 | +# | 60 | + * Copyright GreenSocs 2016-2020 |
47 | +# This library is free software; you can redistribute it and/or | 61 | + * |
48 | +# modify it under the terms of the GNU Lesser General Public | 62 | + * Authors: |
49 | +# License as published by the Free Software Foundation; either | 63 | + * Frederic Konrad |
50 | +# version 2 of the License, or (at your option) any later version. | 64 | + * Damien Hedde |
51 | +# | 65 | + * |
52 | +# This library is distributed in the hope that it will be useful, | 66 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. |
53 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | 67 | + * See the COPYING file in the top-level directory. |
54 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 68 | + */ |
55 | +# Lesser General Public License for more details. | 69 | + |
56 | +# | 70 | +#ifndef QDEV_CLOCK_H |
57 | +# You should have received a copy of the GNU Lesser General Public | 71 | +#define QDEV_CLOCK_H |
58 | +# License along with this library; if not, see <http://www.gnu.org/licenses/>. | 72 | + |
59 | + | 73 | +#include "hw/clock.h" |
60 | +# | 74 | + |
61 | +# This file is processed by scripts/decodetree.py | 75 | +/** |
62 | +# | 76 | + * qdev_init_clock_in: |
63 | + | 77 | + * @dev: the device to add an input clock to |
64 | +# Encodings for Neon data processing instructions where the T32 encoding | 78 | + * @name: the name of the clock (can't be NULL). |
65 | +# is a simple transformation of the A32 encoding. | 79 | + * @callback: optional callback to be called on update or NULL. |
66 | +# More specifically, this file covers instructions where the A32 encoding is | 80 | + * @opaque: argument for the callback |
67 | +# 0b1111_001p_qqqq_qqqq_qqqq_qqqq_qqqq_qqqq | 81 | + * @returns: a pointer to the newly added clock |
68 | +# and the T32 encoding is | 82 | + * |
69 | +# 0b111p_1111_qqqq_qqqq_qqqq_qqqq_qqqq_qqqq | 83 | + * Add an input clock to device @dev as a clock named @name. |
70 | +# This file works on the A32 encoding only; calling code for T32 has to | 84 | + * This adds a child<> property. |
71 | +# transform the insn into the A32 version first. | 85 | + * The callback will be called with @opaque as opaque parameter. |
72 | diff --git a/target/arm/neon-ls.decode b/target/arm/neon-ls.decode | 86 | + */ |
87 | +Clock *qdev_init_clock_in(DeviceState *dev, const char *name, | ||
88 | + ClockCallback *callback, void *opaque); | ||
89 | + | ||
90 | +/** | ||
91 | + * qdev_init_clock_out: | ||
92 | + * @dev: the device to add an output clock to | ||
93 | + * @name: the name of the clock (can't be NULL). | ||
94 | + * @returns: a pointer to the newly added clock | ||
95 | + * | ||
96 | + * Add an output clock to device @dev as a clock named @name. | ||
97 | + * This adds a child<> property. | ||
98 | + */ | ||
99 | +Clock *qdev_init_clock_out(DeviceState *dev, const char *name); | ||
100 | + | ||
101 | +/** | ||
102 | + * qdev_get_clock_in: | ||
103 | + * @dev: the device which has the clock | ||
104 | + * @name: the name of the clock (can't be NULL). | ||
105 | + * @returns: a pointer to the clock | ||
106 | + * | ||
107 | + * Get the input clock @name from @dev or NULL if does not exist. | ||
108 | + */ | ||
109 | +Clock *qdev_get_clock_in(DeviceState *dev, const char *name); | ||
110 | + | ||
111 | +/** | ||
112 | + * qdev_get_clock_out: | ||
113 | + * @dev: the device which has the clock | ||
114 | + * @name: the name of the clock (can't be NULL). | ||
115 | + * @returns: a pointer to the clock | ||
116 | + * | ||
117 | + * Get the output clock @name from @dev or NULL if does not exist. | ||
118 | + */ | ||
119 | +Clock *qdev_get_clock_out(DeviceState *dev, const char *name); | ||
120 | + | ||
121 | +/** | ||
122 | + * qdev_connect_clock_in: | ||
123 | + * @dev: a device | ||
124 | + * @name: the name of an input clock in @dev | ||
125 | + * @source: the source clock (an output clock of another device for example) | ||
126 | + * | ||
127 | + * Set the source clock of input clock @name of device @dev to @source. | ||
128 | + * @source period update will be propagated to @name clock. | ||
129 | + */ | ||
130 | +static inline void qdev_connect_clock_in(DeviceState *dev, const char *name, | ||
131 | + Clock *source) | ||
132 | +{ | ||
133 | + clock_set_source(qdev_get_clock_in(dev, name), source); | ||
134 | +} | ||
135 | + | ||
136 | +/** | ||
137 | + * qdev_alias_clock: | ||
138 | + * @dev: the device which has the clock | ||
139 | + * @name: the name of the clock in @dev (can't be NULL) | ||
140 | + * @alias_dev: the device to add the clock | ||
141 | + * @alias_name: the name of the clock in @container | ||
142 | + * @returns: a pointer to the clock | ||
143 | + * | ||
144 | + * Add a clock @alias_name in @alias_dev which is an alias of the clock @name | ||
145 | + * in @dev. The direction _in_ or _out_ will the same as the original. | ||
146 | + * An alias clock must not be modified or used by @alias_dev and should | ||
147 | + * typically be only only for device composition purpose. | ||
148 | + */ | ||
149 | +Clock *qdev_alias_clock(DeviceState *dev, const char *name, | ||
150 | + DeviceState *alias_dev, const char *alias_name); | ||
151 | + | ||
152 | +/** | ||
153 | + * qdev_finalize_clocklist: | ||
154 | + * @dev: the device being finalized | ||
155 | + * | ||
156 | + * Clear the clocklist from @dev. Only used internally in qdev. | ||
157 | + */ | ||
158 | +void qdev_finalize_clocklist(DeviceState *dev); | ||
159 | + | ||
160 | +#endif /* QDEV_CLOCK_H */ | ||
161 | diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h | ||
162 | index XXXXXXX..XXXXXXX 100644 | ||
163 | --- a/include/hw/qdev-core.h | ||
164 | +++ b/include/hw/qdev-core.h | ||
165 | @@ -XXX,XX +XXX,XX @@ struct NamedGPIOList { | ||
166 | QLIST_ENTRY(NamedGPIOList) node; | ||
167 | }; | ||
168 | |||
169 | +typedef struct Clock Clock; | ||
170 | +typedef struct NamedClockList NamedClockList; | ||
171 | + | ||
172 | +struct NamedClockList { | ||
173 | + char *name; | ||
174 | + Clock *clock; | ||
175 | + bool output; | ||
176 | + bool alias; | ||
177 | + QLIST_ENTRY(NamedClockList) node; | ||
178 | +}; | ||
179 | + | ||
180 | /** | ||
181 | * DeviceState: | ||
182 | * @realized: Indicates whether the device has been fully constructed. | ||
183 | @@ -XXX,XX +XXX,XX @@ struct DeviceState { | ||
184 | bool allow_unplug_during_migration; | ||
185 | BusState *parent_bus; | ||
186 | QLIST_HEAD(, NamedGPIOList) gpios; | ||
187 | + QLIST_HEAD(, NamedClockList) clocks; | ||
188 | QLIST_HEAD(, BusState) child_bus; | ||
189 | int num_child_bus; | ||
190 | int instance_id_alias; | ||
191 | diff --git a/hw/core/qdev-clock.c b/hw/core/qdev-clock.c | ||
73 | new file mode 100644 | 192 | new file mode 100644 |
74 | index XXXXXXX..XXXXXXX | 193 | index XXXXXXX..XXXXXXX |
75 | --- /dev/null | 194 | --- /dev/null |
76 | +++ b/target/arm/neon-ls.decode | 195 | +++ b/hw/core/qdev-clock.c |
77 | @@ -XXX,XX +XXX,XX @@ | ||
78 | +# AArch32 Neon load/store instruction descriptions | ||
79 | +# | ||
80 | +# Copyright (c) 2020 Linaro, Ltd | ||
81 | +# | ||
82 | +# This library is free software; you can redistribute it and/or | ||
83 | +# modify it under the terms of the GNU Lesser General Public | ||
84 | +# License as published by the Free Software Foundation; either | ||
85 | +# version 2 of the License, or (at your option) any later version. | ||
86 | +# | ||
87 | +# This library is distributed in the hope that it will be useful, | ||
88 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
89 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
90 | +# Lesser General Public License for more details. | ||
91 | +# | ||
92 | +# You should have received a copy of the GNU Lesser General Public | ||
93 | +# License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
94 | + | ||
95 | +# | ||
96 | +# This file is processed by scripts/decodetree.py | ||
97 | +# | ||
98 | + | ||
99 | +# Encodings for Neon load/store instructions where the T32 encoding | ||
100 | +# is a simple transformation of the A32 encoding. | ||
101 | +# More specifically, this file covers instructions where the A32 encoding is | ||
102 | +# 0b1111_0100_xxx0_xxxx_xxxx_xxxx_xxxx_xxxx | ||
103 | +# and the T32 encoding is | ||
104 | +# 0b1111_1001_xxx0_xxxx_xxxx_xxxx_xxxx_xxxx | ||
105 | +# This file works on the A32 encoding only; calling code for T32 has to | ||
106 | +# transform the insn into the A32 version first. | ||
107 | diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode | ||
108 | new file mode 100644 | ||
109 | index XXXXXXX..XXXXXXX | ||
110 | --- /dev/null | ||
111 | +++ b/target/arm/neon-shared.decode | ||
112 | @@ -XXX,XX +XXX,XX @@ | ||
113 | +# AArch32 Neon instruction descriptions | ||
114 | +# | ||
115 | +# Copyright (c) 2020 Linaro, Ltd | ||
116 | +# | ||
117 | +# This library is free software; you can redistribute it and/or | ||
118 | +# modify it under the terms of the GNU Lesser General Public | ||
119 | +# License as published by the Free Software Foundation; either | ||
120 | +# version 2 of the License, or (at your option) any later version. | ||
121 | +# | ||
122 | +# This library is distributed in the hope that it will be useful, | ||
123 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
124 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
125 | +# Lesser General Public License for more details. | ||
126 | +# | ||
127 | +# You should have received a copy of the GNU Lesser General Public | ||
128 | +# License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
129 | + | ||
130 | +# | ||
131 | +# This file is processed by scripts/decodetree.py | ||
132 | +# | ||
133 | + | ||
134 | +# Encodings for Neon instructions whose encoding is the same for | ||
135 | +# both A32 and T32. | ||
136 | + | ||
137 | +# More specifically, this covers: | ||
138 | +# 2reg scalar ext: 0b1111_1110_xxxx_xxxx_xxxx_1x0x_xxxx_xxxx | ||
139 | +# 3same ext: 0b1111_110x_xxxx_xxxx_xxxx_1x0x_xxxx_xxxx | ||
140 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
141 | new file mode 100644 | ||
142 | index XXXXXXX..XXXXXXX | ||
143 | --- /dev/null | ||
144 | +++ b/target/arm/translate-neon.inc.c | ||
145 | @@ -XXX,XX +XXX,XX @@ | 196 | @@ -XXX,XX +XXX,XX @@ |
146 | +/* | 197 | +/* |
147 | + * ARM translation: AArch32 Neon instructions | 198 | + * Device's clock input and output |
148 | + * | 199 | + * |
149 | + * Copyright (c) 2003 Fabrice Bellard | 200 | + * Copyright GreenSocs 2016-2020 |
150 | + * Copyright (c) 2005-2007 CodeSourcery | 201 | + * |
151 | + * Copyright (c) 2007 OpenedHand, Ltd. | 202 | + * Authors: |
152 | + * Copyright (c) 2020 Linaro, Ltd. | 203 | + * Frederic Konrad |
153 | + * | 204 | + * Damien Hedde |
154 | + * This library is free software; you can redistribute it and/or | 205 | + * |
155 | + * modify it under the terms of the GNU Lesser General Public | 206 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. |
156 | + * License as published by the Free Software Foundation; either | 207 | + * See the COPYING file in the top-level directory. |
157 | + * version 2 of the License, or (at your option) any later version. | 208 | + */ |
158 | + * | 209 | + |
159 | + * This library is distributed in the hope that it will be useful, | 210 | +#include "qemu/osdep.h" |
160 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | 211 | +#include "hw/qdev-clock.h" |
161 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 212 | +#include "hw/qdev-core.h" |
162 | + * Lesser General Public License for more details. | 213 | +#include "qapi/error.h" |
163 | + * | ||
164 | + * You should have received a copy of the GNU Lesser General Public | ||
165 | + * License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
166 | + */ | ||
167 | + | 214 | + |
168 | +/* | 215 | +/* |
169 | + * This file is intended to be included from translate.c; it uses | 216 | + * qdev_init_clocklist: |
170 | + * some macros and definitions provided by that file. | 217 | + * Add a new clock in a device |
171 | + * It might be possible to convert it to a standalone .c file eventually. | 218 | + */ |
172 | + */ | 219 | +static NamedClockList *qdev_init_clocklist(DeviceState *dev, const char *name, |
173 | + | 220 | + bool output, Clock *clk) |
174 | +/* Include the generated Neon decoder */ | 221 | +{ |
175 | +#include "decode-neon-dp.inc.c" | 222 | + NamedClockList *ncl; |
176 | +#include "decode-neon-ls.inc.c" | 223 | + |
177 | +#include "decode-neon-shared.inc.c" | 224 | + /* |
178 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 225 | + * Clock must be added before realize() so that we can compute the |
179 | index XXXXXXX..XXXXXXX 100644 | 226 | + * clock's canonical path during device_realize(). |
180 | --- a/target/arm/translate.c | 227 | + */ |
181 | +++ b/target/arm/translate.c | 228 | + assert(!dev->realized); |
182 | @@ -XXX,XX +XXX,XX @@ static TCGv_ptr vfp_reg_ptr(bool dp, int reg) | 229 | + |
183 | 230 | + /* | |
184 | #define ARM_CP_RW_BIT (1 << 20) | 231 | + * The ncl structure is freed by qdev_finalize_clocklist() which will |
185 | 232 | + * be called during @dev's device_finalize(). | |
186 | -/* Include the VFP decoder */ | 233 | + */ |
187 | +/* Include the VFP and Neon decoders */ | 234 | + ncl = g_new0(NamedClockList, 1); |
188 | #include "translate-vfp.inc.c" | 235 | + ncl->name = g_strdup(name); |
189 | +#include "translate-neon.inc.c" | 236 | + ncl->output = output; |
190 | 237 | + ncl->alias = (clk != NULL); | |
191 | static inline void iwmmxt_load_reg(TCGv_i64 var, int reg) | 238 | + |
192 | { | 239 | + /* |
193 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 240 | + * Trying to create a clock whose name clashes with some other |
194 | /* Unconditional instructions. */ | 241 | + * clock or property is a bug in the caller and we will abort(). |
195 | /* TODO: Perhaps merge these into one decodetree output file. */ | 242 | + */ |
196 | if (disas_a32_uncond(s, insn) || | 243 | + if (clk == NULL) { |
197 | - disas_vfp_uncond(s, insn)) { | 244 | + clk = CLOCK(object_new(TYPE_CLOCK)); |
198 | + disas_vfp_uncond(s, insn) || | 245 | + object_property_add_child(OBJECT(dev), name, OBJECT(clk), &error_abort); |
199 | + disas_neon_dp(s, insn) || | 246 | + if (output) { |
200 | + disas_neon_ls(s, insn) || | 247 | + /* |
201 | + disas_neon_shared(s, insn)) { | 248 | + * Remove object_new()'s initial reference. |
202 | return; | 249 | + * Note that for inputs, the reference created by object_new() |
203 | } | 250 | + * will be deleted in qdev_finalize_clocklist(). |
204 | /* fall back to legacy decoder */ | 251 | + */ |
205 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 252 | + object_unref(OBJECT(clk)); |
206 | ARCH(6T2); | 253 | + } |
207 | } | 254 | + } else { |
208 | 255 | + object_property_add_link(OBJECT(dev), name, | |
209 | + if ((insn & 0xef000000) == 0xef000000) { | 256 | + object_get_typename(OBJECT(clk)), |
210 | + /* | 257 | + (Object **) &ncl->clock, |
211 | + * T32 encodings 0b111p_1111_qqqq_qqqq_qqqq_qqqq_qqqq_qqqq | 258 | + NULL, OBJ_PROP_LINK_STRONG, &error_abort); |
212 | + * transform into | 259 | + } |
213 | + * A32 encodings 0b1111_001p_qqqq_qqqq_qqqq_qqqq_qqqq_qqqq | 260 | + |
214 | + */ | 261 | + ncl->clock = clk; |
215 | + uint32_t a32_insn = (insn & 0xe2ffffff) | | 262 | + |
216 | + ((insn & (1 << 28)) >> 4) | (1 << 28); | 263 | + QLIST_INSERT_HEAD(&dev->clocks, ncl, node); |
217 | + | 264 | + return ncl; |
218 | + if (disas_neon_dp(s, a32_insn)) { | 265 | +} |
219 | + return; | 266 | + |
267 | +void qdev_finalize_clocklist(DeviceState *dev) | ||
268 | +{ | ||
269 | + /* called by @dev's device_finalize() */ | ||
270 | + NamedClockList *ncl, *ncl_next; | ||
271 | + | ||
272 | + QLIST_FOREACH_SAFE(ncl, &dev->clocks, node, ncl_next) { | ||
273 | + QLIST_REMOVE(ncl, node); | ||
274 | + if (!ncl->output && !ncl->alias) { | ||
275 | + /* | ||
276 | + * We kept a reference on the input clock to ensure it lives up to | ||
277 | + * this point so we can safely remove the callback. | ||
278 | + * It avoids having a callback to a deleted object if ncl->clock | ||
279 | + * is still referenced somewhere else (eg: by a clock output). | ||
280 | + */ | ||
281 | + clock_clear_callback(ncl->clock); | ||
282 | + object_unref(OBJECT(ncl->clock)); | ||
283 | + } | ||
284 | + g_free(ncl->name); | ||
285 | + g_free(ncl); | ||
286 | + } | ||
287 | +} | ||
288 | + | ||
289 | +Clock *qdev_init_clock_out(DeviceState *dev, const char *name) | ||
290 | +{ | ||
291 | + NamedClockList *ncl; | ||
292 | + | ||
293 | + assert(name); | ||
294 | + | ||
295 | + ncl = qdev_init_clocklist(dev, name, true, NULL); | ||
296 | + | ||
297 | + return ncl->clock; | ||
298 | +} | ||
299 | + | ||
300 | +Clock *qdev_init_clock_in(DeviceState *dev, const char *name, | ||
301 | + ClockCallback *callback, void *opaque) | ||
302 | +{ | ||
303 | + NamedClockList *ncl; | ||
304 | + | ||
305 | + assert(name); | ||
306 | + | ||
307 | + ncl = qdev_init_clocklist(dev, name, false, NULL); | ||
308 | + | ||
309 | + if (callback) { | ||
310 | + clock_set_callback(ncl->clock, callback, opaque); | ||
311 | + } | ||
312 | + return ncl->clock; | ||
313 | +} | ||
314 | + | ||
315 | +static NamedClockList *qdev_get_clocklist(DeviceState *dev, const char *name) | ||
316 | +{ | ||
317 | + NamedClockList *ncl; | ||
318 | + | ||
319 | + QLIST_FOREACH(ncl, &dev->clocks, node) { | ||
320 | + if (strcmp(name, ncl->name) == 0) { | ||
321 | + return ncl; | ||
220 | + } | 322 | + } |
221 | + } | 323 | + } |
222 | + | 324 | + |
223 | + if ((insn & 0xff100000) == 0xf9000000) { | 325 | + return NULL; |
224 | + /* | 326 | +} |
225 | + * T32 encodings 0b1111_1001_ppp0_qqqq_qqqq_qqqq_qqqq_qqqq | 327 | + |
226 | + * transform into | 328 | +Clock *qdev_get_clock_in(DeviceState *dev, const char *name) |
227 | + * A32 encodings 0b1111_0100_ppp0_qqqq_qqqq_qqqq_qqqq_qqqq | 329 | +{ |
228 | + */ | 330 | + NamedClockList *ncl; |
229 | + uint32_t a32_insn = (insn & 0x00ffffff) | 0xf4000000; | 331 | + |
230 | + | 332 | + assert(name); |
231 | + if (disas_neon_ls(s, a32_insn)) { | 333 | + |
232 | + return; | 334 | + ncl = qdev_get_clocklist(dev, name); |
335 | + assert(!ncl->output); | ||
336 | + | ||
337 | + return ncl->clock; | ||
338 | +} | ||
339 | + | ||
340 | +Clock *qdev_get_clock_out(DeviceState *dev, const char *name) | ||
341 | +{ | ||
342 | + NamedClockList *ncl; | ||
343 | + | ||
344 | + assert(name); | ||
345 | + | ||
346 | + ncl = qdev_get_clocklist(dev, name); | ||
347 | + assert(ncl->output); | ||
348 | + | ||
349 | + return ncl->clock; | ||
350 | +} | ||
351 | + | ||
352 | +Clock *qdev_alias_clock(DeviceState *dev, const char *name, | ||
353 | + DeviceState *alias_dev, const char *alias_name) | ||
354 | +{ | ||
355 | + NamedClockList *ncl; | ||
356 | + | ||
357 | + assert(name && alias_name); | ||
358 | + | ||
359 | + ncl = qdev_get_clocklist(dev, name); | ||
360 | + | ||
361 | + qdev_init_clocklist(alias_dev, alias_name, ncl->output, ncl->clock); | ||
362 | + | ||
363 | + return ncl->clock; | ||
364 | +} | ||
365 | diff --git a/hw/core/qdev.c b/hw/core/qdev.c | ||
366 | index XXXXXXX..XXXXXXX 100644 | ||
367 | --- a/hw/core/qdev.c | ||
368 | +++ b/hw/core/qdev.c | ||
369 | @@ -XXX,XX +XXX,XX @@ | ||
370 | #include "hw/qdev-properties.h" | ||
371 | #include "hw/boards.h" | ||
372 | #include "hw/sysbus.h" | ||
373 | +#include "hw/qdev-clock.h" | ||
374 | #include "migration/vmstate.h" | ||
375 | #include "trace.h" | ||
376 | |||
377 | @@ -XXX,XX +XXX,XX @@ static void device_set_realized(Object *obj, bool value, Error **errp) | ||
378 | DeviceClass *dc = DEVICE_GET_CLASS(dev); | ||
379 | HotplugHandler *hotplug_ctrl; | ||
380 | BusState *bus; | ||
381 | + NamedClockList *ncl; | ||
382 | Error *local_err = NULL; | ||
383 | bool unattached_parent = false; | ||
384 | static int unattached_count; | ||
385 | @@ -XXX,XX +XXX,XX @@ static void device_set_realized(Object *obj, bool value, Error **errp) | ||
386 | */ | ||
387 | g_free(dev->canonical_path); | ||
388 | dev->canonical_path = object_get_canonical_path(OBJECT(dev)); | ||
389 | + QLIST_FOREACH(ncl, &dev->clocks, node) { | ||
390 | + if (ncl->alias) { | ||
391 | + continue; | ||
392 | + } else { | ||
393 | + clock_setup_canonical_path(ncl->clock); | ||
394 | + } | ||
233 | + } | 395 | + } |
234 | + } | 396 | |
235 | + | 397 | if (qdev_get_vmsd(dev)) { |
236 | /* | 398 | if (vmstate_register_with_alias_id(VMSTATE_IF(dev), |
237 | * TODO: Perhaps merge these into one decodetree output file. | 399 | @@ -XXX,XX +XXX,XX @@ static void device_initfn(Object *obj) |
238 | * Note disas_vfp is written for a32 with cond field in the | 400 | dev->allow_unplug_during_migration = false; |
239 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 401 | |
240 | */ | 402 | QLIST_INIT(&dev->gpios); |
241 | if (disas_t32(s, insn) || | 403 | + QLIST_INIT(&dev->clocks); |
242 | disas_vfp_uncond(s, insn) || | 404 | } |
243 | + disas_neon_shared(s, insn) || | 405 | |
244 | ((insn >> 28) == 0xe && disas_vfp(s, insn))) { | 406 | static void device_post_init(Object *obj) |
245 | return; | 407 | @@ -XXX,XX +XXX,XX @@ static void device_finalize(Object *obj) |
408 | */ | ||
246 | } | 409 | } |
247 | diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs | 410 | |
248 | index XXXXXXX..XXXXXXX 100644 | 411 | + qdev_finalize_clocklist(dev); |
249 | --- a/target/arm/Makefile.objs | 412 | + |
250 | +++ b/target/arm/Makefile.objs | 413 | /* Only send event if the device had been completely realized */ |
251 | @@ -XXX,XX +XXX,XX @@ target/arm/decode-sve.inc.c: $(SRC_PATH)/target/arm/sve.decode $(DECODETREE) | 414 | if (dev->pending_deleted_event) { |
252 | $(PYTHON) $(DECODETREE) --decode disas_sve -o $@ $<,\ | 415 | g_assert(dev->canonical_path); |
253 | "GEN", $(TARGET_DIR)$@) | ||
254 | |||
255 | +target/arm/decode-neon-shared.inc.c: $(SRC_PATH)/target/arm/neon-shared.decode $(DECODETREE) | ||
256 | + $(call quiet-command,\ | ||
257 | + $(PYTHON) $(DECODETREE) --static-decode disas_neon_shared -o $@ $<,\ | ||
258 | + "GEN", $(TARGET_DIR)$@) | ||
259 | + | ||
260 | +target/arm/decode-neon-dp.inc.c: $(SRC_PATH)/target/arm/neon-dp.decode $(DECODETREE) | ||
261 | + $(call quiet-command,\ | ||
262 | + $(PYTHON) $(DECODETREE) --static-decode disas_neon_dp -o $@ $<,\ | ||
263 | + "GEN", $(TARGET_DIR)$@) | ||
264 | + | ||
265 | +target/arm/decode-neon-ls.inc.c: $(SRC_PATH)/target/arm/neon-ls.decode $(DECODETREE) | ||
266 | + $(call quiet-command,\ | ||
267 | + $(PYTHON) $(DECODETREE) --static-decode disas_neon_ls -o $@ $<,\ | ||
268 | + "GEN", $(TARGET_DIR)$@) | ||
269 | + | ||
270 | target/arm/decode-vfp.inc.c: $(SRC_PATH)/target/arm/vfp.decode $(DECODETREE) | ||
271 | $(call quiet-command,\ | ||
272 | $(PYTHON) $(DECODETREE) --static-decode disas_vfp -o $@ $<,\ | ||
273 | @@ -XXX,XX +XXX,XX @@ target/arm/decode-t16.inc.c: $(SRC_PATH)/target/arm/t16.decode $(DECODETREE) | ||
274 | "GEN", $(TARGET_DIR)$@) | ||
275 | |||
276 | target/arm/translate-sve.o: target/arm/decode-sve.inc.c | ||
277 | +target/arm/translate.o: target/arm/decode-neon-shared.inc.c | ||
278 | +target/arm/translate.o: target/arm/decode-neon-dp.inc.c | ||
279 | +target/arm/translate.o: target/arm/decode-neon-ls.inc.c | ||
280 | target/arm/translate.o: target/arm/decode-vfp.inc.c | ||
281 | target/arm/translate.o: target/arm/decode-vfp-uncond.inc.c | ||
282 | target/arm/translate.o: target/arm/decode-a32.inc.c | ||
283 | -- | 416 | -- |
284 | 2.20.1 | 417 | 2.20.1 |
285 | 418 | ||
286 | 419 | diff view generated by jsdifflib |
1 | Convert the Neon "load/store multiple structures" insns to decodetree. | 1 | From: Damien Hedde <damien.hedde@greensocs.com> |
---|---|---|---|
2 | 2 | ||
3 | Introduce a function and macro helpers to setup several clocks | ||
4 | in a device from a static array description. | ||
5 | |||
6 | An element of the array describes the clock (name and direction) as | ||
7 | well as the related callback and an optional offset to store the | ||
8 | created object pointer in the device state structure. | ||
9 | |||
10 | The array must be terminated by a special element QDEV_CLOCK_END. | ||
11 | |||
12 | This is based on the original work of Frederic Konrad. | ||
13 | |||
14 | Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> | ||
15 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
16 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
17 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
18 | Message-id: 20200406135251.157596-5-damien.hedde@greensocs.com | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20200430181003.21682-12-peter.maydell@linaro.org | ||
6 | --- | 20 | --- |
7 | target/arm/neon-ls.decode | 7 ++ | 21 | include/hw/qdev-clock.h | 55 +++++++++++++++++++++++++++++++++++++++++ |
8 | target/arm/translate-neon.inc.c | 124 ++++++++++++++++++++++++++++++++ | 22 | hw/core/qdev-clock.c | 17 +++++++++++++ |
9 | target/arm/translate.c | 91 +---------------------- | 23 | 2 files changed, 72 insertions(+) |
10 | 3 files changed, 133 insertions(+), 89 deletions(-) | ||
11 | 24 | ||
12 | diff --git a/target/arm/neon-ls.decode b/target/arm/neon-ls.decode | 25 | diff --git a/include/hw/qdev-clock.h b/include/hw/qdev-clock.h |
13 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/neon-ls.decode | 27 | --- a/include/hw/qdev-clock.h |
15 | +++ b/target/arm/neon-ls.decode | 28 | +++ b/include/hw/qdev-clock.h |
16 | @@ -XXX,XX +XXX,XX @@ | 29 | @@ -XXX,XX +XXX,XX @@ Clock *qdev_alias_clock(DeviceState *dev, const char *name, |
17 | # 0b1111_1001_xxx0_xxxx_xxxx_xxxx_xxxx_xxxx | 30 | */ |
18 | # This file works on the A32 encoding only; calling code for T32 has to | 31 | void qdev_finalize_clocklist(DeviceState *dev); |
19 | # transform the insn into the A32 version first. | 32 | |
20 | + | 33 | +/** |
21 | +%vd_dp 22:1 12:4 | 34 | + * ClockPortInitElem: |
22 | + | 35 | + * @name: name of the clock (can't be NULL) |
23 | +# Neon load/store multiple structures | 36 | + * @output: indicates whether the clock is input or output |
24 | + | 37 | + * @callback: for inputs, optional callback to be called on clock's update |
25 | +VLDST_multiple 1111 0100 0 . l:1 0 rn:4 .... itype:4 size:2 align:2 rm:4 \ | 38 | + * with device as opaque |
26 | + vd=%vd_dp | 39 | + * @offset: optional offset to store the ClockIn or ClockOut pointer in device |
27 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | 40 | + * state structure (0 means unused) |
28 | index XXXXXXX..XXXXXXX 100644 | 41 | + */ |
29 | --- a/target/arm/translate-neon.inc.c | 42 | +struct ClockPortInitElem { |
30 | +++ b/target/arm/translate-neon.inc.c | 43 | + const char *name; |
31 | @@ -XXX,XX +XXX,XX @@ static bool trans_VFML_scalar(DisasContext *s, arg_VFML_scalar *a) | 44 | + bool is_output; |
32 | gen_helper_gvec_fmlal_idx_a32); | 45 | + ClockCallback *callback; |
33 | return true; | 46 | + size_t offset; |
34 | } | ||
35 | + | ||
36 | +static struct { | ||
37 | + int nregs; | ||
38 | + int interleave; | ||
39 | + int spacing; | ||
40 | +} const neon_ls_element_type[11] = { | ||
41 | + {1, 4, 1}, | ||
42 | + {1, 4, 2}, | ||
43 | + {4, 1, 1}, | ||
44 | + {2, 2, 2}, | ||
45 | + {1, 3, 1}, | ||
46 | + {1, 3, 2}, | ||
47 | + {3, 1, 1}, | ||
48 | + {1, 1, 1}, | ||
49 | + {1, 2, 1}, | ||
50 | + {1, 2, 2}, | ||
51 | + {2, 1, 1} | ||
52 | +}; | 47 | +}; |
53 | + | 48 | + |
54 | +static void gen_neon_ldst_base_update(DisasContext *s, int rm, int rn, | 49 | +#define clock_offset_value(devstate, field) \ |
55 | + int stride) | 50 | + (offsetof(devstate, field) + \ |
51 | + type_check(Clock *, typeof_field(devstate, field))) | ||
52 | + | ||
53 | +#define QDEV_CLOCK(out_not_in, devstate, field, cb) { \ | ||
54 | + .name = (stringify(field)), \ | ||
55 | + .is_output = out_not_in, \ | ||
56 | + .callback = cb, \ | ||
57 | + .offset = clock_offset_value(devstate, field), \ | ||
58 | +} | ||
59 | + | ||
60 | +/** | ||
61 | + * QDEV_CLOCK_(IN|OUT): | ||
62 | + * @devstate: structure type. @dev argument of qdev_init_clocks below must be | ||
63 | + * a pointer to that same type. | ||
64 | + * @field: a field in @_devstate (must be Clock*) | ||
65 | + * @callback: (for input only) callback (or NULL) to be called with the device | ||
66 | + * state as argument | ||
67 | + * | ||
68 | + * The name of the clock will be derived from @field | ||
69 | + */ | ||
70 | +#define QDEV_CLOCK_IN(devstate, field, callback) \ | ||
71 | + QDEV_CLOCK(false, devstate, field, callback) | ||
72 | + | ||
73 | +#define QDEV_CLOCK_OUT(devstate, field) \ | ||
74 | + QDEV_CLOCK(true, devstate, field, NULL) | ||
75 | + | ||
76 | +#define QDEV_CLOCK_END { .name = NULL } | ||
77 | + | ||
78 | +typedef struct ClockPortInitElem ClockPortInitArray[]; | ||
79 | + | ||
80 | +/** | ||
81 | + * qdev_init_clocks: | ||
82 | + * @dev: the device to add clocks to | ||
83 | + * @clocks: a QDEV_CLOCK_END-terminated array which contains the | ||
84 | + * clocks information. | ||
85 | + */ | ||
86 | +void qdev_init_clocks(DeviceState *dev, const ClockPortInitArray clocks); | ||
87 | + | ||
88 | #endif /* QDEV_CLOCK_H */ | ||
89 | diff --git a/hw/core/qdev-clock.c b/hw/core/qdev-clock.c | ||
90 | index XXXXXXX..XXXXXXX 100644 | ||
91 | --- a/hw/core/qdev-clock.c | ||
92 | +++ b/hw/core/qdev-clock.c | ||
93 | @@ -XXX,XX +XXX,XX @@ Clock *qdev_init_clock_in(DeviceState *dev, const char *name, | ||
94 | return ncl->clock; | ||
95 | } | ||
96 | |||
97 | +void qdev_init_clocks(DeviceState *dev, const ClockPortInitArray clocks) | ||
56 | +{ | 98 | +{ |
57 | + if (rm != 15) { | 99 | + const struct ClockPortInitElem *elem; |
58 | + TCGv_i32 base; | ||
59 | + | 100 | + |
60 | + base = load_reg(s, rn); | 101 | + for (elem = &clocks[0]; elem->name != NULL; elem++) { |
61 | + if (rm == 13) { | 102 | + Clock **clkp; |
62 | + tcg_gen_addi_i32(base, base, stride); | 103 | + /* offset cannot be inside the DeviceState part */ |
104 | + assert(elem->offset > sizeof(DeviceState)); | ||
105 | + clkp = (Clock **)(((void *) dev) + elem->offset); | ||
106 | + if (elem->is_output) { | ||
107 | + *clkp = qdev_init_clock_out(dev, elem->name); | ||
63 | + } else { | 108 | + } else { |
64 | + TCGv_i32 index; | 109 | + *clkp = qdev_init_clock_in(dev, elem->name, elem->callback, dev); |
65 | + index = load_reg(s, rm); | ||
66 | + tcg_gen_add_i32(base, base, index); | ||
67 | + tcg_temp_free_i32(index); | ||
68 | + } | 110 | + } |
69 | + store_reg(s, rn, base); | ||
70 | + } | 111 | + } |
71 | +} | 112 | +} |
72 | + | 113 | + |
73 | +static bool trans_VLDST_multiple(DisasContext *s, arg_VLDST_multiple *a) | 114 | static NamedClockList *qdev_get_clocklist(DeviceState *dev, const char *name) |
74 | +{ | ||
75 | + /* Neon load/store multiple structures */ | ||
76 | + int nregs, interleave, spacing, reg, n; | ||
77 | + MemOp endian = s->be_data; | ||
78 | + int mmu_idx = get_mem_index(s); | ||
79 | + int size = a->size; | ||
80 | + TCGv_i64 tmp64; | ||
81 | + TCGv_i32 addr, tmp; | ||
82 | + | ||
83 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
84 | + return false; | ||
85 | + } | ||
86 | + | ||
87 | + /* UNDEF accesses to D16-D31 if they don't exist */ | ||
88 | + if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) { | ||
89 | + return false; | ||
90 | + } | ||
91 | + if (a->itype > 10) { | ||
92 | + return false; | ||
93 | + } | ||
94 | + /* Catch UNDEF cases for bad values of align field */ | ||
95 | + switch (a->itype & 0xc) { | ||
96 | + case 4: | ||
97 | + if (a->align >= 2) { | ||
98 | + return false; | ||
99 | + } | ||
100 | + break; | ||
101 | + case 8: | ||
102 | + if (a->align == 3) { | ||
103 | + return false; | ||
104 | + } | ||
105 | + break; | ||
106 | + default: | ||
107 | + break; | ||
108 | + } | ||
109 | + nregs = neon_ls_element_type[a->itype].nregs; | ||
110 | + interleave = neon_ls_element_type[a->itype].interleave; | ||
111 | + spacing = neon_ls_element_type[a->itype].spacing; | ||
112 | + if (size == 3 && (interleave | spacing) != 1) { | ||
113 | + return false; | ||
114 | + } | ||
115 | + | ||
116 | + if (!vfp_access_check(s)) { | ||
117 | + return true; | ||
118 | + } | ||
119 | + | ||
120 | + /* For our purposes, bytes are always little-endian. */ | ||
121 | + if (size == 0) { | ||
122 | + endian = MO_LE; | ||
123 | + } | ||
124 | + /* | ||
125 | + * Consecutive little-endian elements from a single register | ||
126 | + * can be promoted to a larger little-endian operation. | ||
127 | + */ | ||
128 | + if (interleave == 1 && endian == MO_LE) { | ||
129 | + size = 3; | ||
130 | + } | ||
131 | + tmp64 = tcg_temp_new_i64(); | ||
132 | + addr = tcg_temp_new_i32(); | ||
133 | + tmp = tcg_const_i32(1 << size); | ||
134 | + load_reg_var(s, addr, a->rn); | ||
135 | + for (reg = 0; reg < nregs; reg++) { | ||
136 | + for (n = 0; n < 8 >> size; n++) { | ||
137 | + int xs; | ||
138 | + for (xs = 0; xs < interleave; xs++) { | ||
139 | + int tt = a->vd + reg + spacing * xs; | ||
140 | + | ||
141 | + if (a->l) { | ||
142 | + gen_aa32_ld_i64(s, tmp64, addr, mmu_idx, endian | size); | ||
143 | + neon_store_element64(tt, n, size, tmp64); | ||
144 | + } else { | ||
145 | + neon_load_element64(tmp64, tt, n, size); | ||
146 | + gen_aa32_st_i64(s, tmp64, addr, mmu_idx, endian | size); | ||
147 | + } | ||
148 | + tcg_gen_add_i32(addr, addr, tmp); | ||
149 | + } | ||
150 | + } | ||
151 | + } | ||
152 | + tcg_temp_free_i32(addr); | ||
153 | + tcg_temp_free_i32(tmp); | ||
154 | + tcg_temp_free_i64(tmp64); | ||
155 | + | ||
156 | + gen_neon_ldst_base_update(s, a->rm, a->rn, nregs * interleave * 8); | ||
157 | + return true; | ||
158 | +} | ||
159 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
160 | index XXXXXXX..XXXXXXX 100644 | ||
161 | --- a/target/arm/translate.c | ||
162 | +++ b/target/arm/translate.c | ||
163 | @@ -XXX,XX +XXX,XX @@ static void gen_neon_trn_u16(TCGv_i32 t0, TCGv_i32 t1) | ||
164 | } | ||
165 | |||
166 | |||
167 | -static struct { | ||
168 | - int nregs; | ||
169 | - int interleave; | ||
170 | - int spacing; | ||
171 | -} const neon_ls_element_type[11] = { | ||
172 | - {1, 4, 1}, | ||
173 | - {1, 4, 2}, | ||
174 | - {4, 1, 1}, | ||
175 | - {2, 2, 2}, | ||
176 | - {1, 3, 1}, | ||
177 | - {1, 3, 2}, | ||
178 | - {3, 1, 1}, | ||
179 | - {1, 1, 1}, | ||
180 | - {1, 2, 1}, | ||
181 | - {1, 2, 2}, | ||
182 | - {2, 1, 1} | ||
183 | -}; | ||
184 | - | ||
185 | /* Translate a NEON load/store element instruction. Return nonzero if the | ||
186 | instruction is invalid. */ | ||
187 | static int disas_neon_ls_insn(DisasContext *s, uint32_t insn) | ||
188 | { | 115 | { |
189 | int rd, rn, rm; | 116 | NamedClockList *ncl; |
190 | - int op; | ||
191 | int nregs; | ||
192 | - int interleave; | ||
193 | - int spacing; | ||
194 | int stride; | ||
195 | int size; | ||
196 | int reg; | ||
197 | int load; | ||
198 | - int n; | ||
199 | int vec_size; | ||
200 | - int mmu_idx; | ||
201 | - MemOp endian; | ||
202 | TCGv_i32 addr; | ||
203 | TCGv_i32 tmp; | ||
204 | - TCGv_i32 tmp2; | ||
205 | - TCGv_i64 tmp64; | ||
206 | |||
207 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
208 | return 1; | ||
209 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn) | ||
210 | rn = (insn >> 16) & 0xf; | ||
211 | rm = insn & 0xf; | ||
212 | load = (insn & (1 << 21)) != 0; | ||
213 | - endian = s->be_data; | ||
214 | - mmu_idx = get_mem_index(s); | ||
215 | if ((insn & (1 << 23)) == 0) { | ||
216 | - /* Load store all elements. */ | ||
217 | - op = (insn >> 8) & 0xf; | ||
218 | - size = (insn >> 6) & 3; | ||
219 | - if (op > 10) | ||
220 | - return 1; | ||
221 | - /* Catch UNDEF cases for bad values of align field */ | ||
222 | - switch (op & 0xc) { | ||
223 | - case 4: | ||
224 | - if (((insn >> 5) & 1) == 1) { | ||
225 | - return 1; | ||
226 | - } | ||
227 | - break; | ||
228 | - case 8: | ||
229 | - if (((insn >> 4) & 3) == 3) { | ||
230 | - return 1; | ||
231 | - } | ||
232 | - break; | ||
233 | - default: | ||
234 | - break; | ||
235 | - } | ||
236 | - nregs = neon_ls_element_type[op].nregs; | ||
237 | - interleave = neon_ls_element_type[op].interleave; | ||
238 | - spacing = neon_ls_element_type[op].spacing; | ||
239 | - if (size == 3 && (interleave | spacing) != 1) { | ||
240 | - return 1; | ||
241 | - } | ||
242 | - /* For our purposes, bytes are always little-endian. */ | ||
243 | - if (size == 0) { | ||
244 | - endian = MO_LE; | ||
245 | - } | ||
246 | - /* Consecutive little-endian elements from a single register | ||
247 | - * can be promoted to a larger little-endian operation. | ||
248 | - */ | ||
249 | - if (interleave == 1 && endian == MO_LE) { | ||
250 | - size = 3; | ||
251 | - } | ||
252 | - tmp64 = tcg_temp_new_i64(); | ||
253 | - addr = tcg_temp_new_i32(); | ||
254 | - tmp2 = tcg_const_i32(1 << size); | ||
255 | - load_reg_var(s, addr, rn); | ||
256 | - for (reg = 0; reg < nregs; reg++) { | ||
257 | - for (n = 0; n < 8 >> size; n++) { | ||
258 | - int xs; | ||
259 | - for (xs = 0; xs < interleave; xs++) { | ||
260 | - int tt = rd + reg + spacing * xs; | ||
261 | - | ||
262 | - if (load) { | ||
263 | - gen_aa32_ld_i64(s, tmp64, addr, mmu_idx, endian | size); | ||
264 | - neon_store_element64(tt, n, size, tmp64); | ||
265 | - } else { | ||
266 | - neon_load_element64(tmp64, tt, n, size); | ||
267 | - gen_aa32_st_i64(s, tmp64, addr, mmu_idx, endian | size); | ||
268 | - } | ||
269 | - tcg_gen_add_i32(addr, addr, tmp2); | ||
270 | - } | ||
271 | - } | ||
272 | - } | ||
273 | - tcg_temp_free_i32(addr); | ||
274 | - tcg_temp_free_i32(tmp2); | ||
275 | - tcg_temp_free_i64(tmp64); | ||
276 | - stride = nregs * interleave * 8; | ||
277 | + /* Load store all elements -- handled already by decodetree */ | ||
278 | + return 1; | ||
279 | } else { | ||
280 | size = (insn >> 10) & 3; | ||
281 | if (size == 3) { | ||
282 | -- | 117 | -- |
283 | 2.20.1 | 118 | 2.20.1 |
284 | 119 | ||
285 | 120 | diff view generated by jsdifflib |
1 | Convert the Neon logic ops in the 3-reg-same grouping to decodetree. | 1 | Add the documentation about the clock inputs and outputs in devices. |
---|---|---|---|
2 | Note that for the logic ops the 'size' field forms part of their | ||
3 | decode and the actual operations are always bitwise. | ||
4 | 2 | ||
3 | This is based on the original work of Frederic Konrad. | ||
4 | |||
5 | Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> | ||
6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
7 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
8 | Message-id: 20200406135251.157596-6-damien.hedde@greensocs.com | ||
9 | [PMM: Editing pass for minor grammar, style and Sphinx | ||
10 | formatting fixes] | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20200430181003.21682-16-peter.maydell@linaro.org | ||
8 | --- | 13 | --- |
9 | target/arm/neon-dp.decode | 12 +++++++++++ | 14 | docs/devel/clocks.rst | 391 ++++++++++++++++++++++++++++++++++++++++++ |
10 | target/arm/translate-neon.inc.c | 19 +++++++++++++++++ | 15 | docs/devel/index.rst | 1 + |
11 | target/arm/translate.c | 38 +-------------------------------- | 16 | 2 files changed, 392 insertions(+) |
12 | 3 files changed, 32 insertions(+), 37 deletions(-) | 17 | create mode 100644 docs/devel/clocks.rst |
13 | 18 | ||
14 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 19 | diff --git a/docs/devel/clocks.rst b/docs/devel/clocks.rst |
20 | new file mode 100644 | ||
21 | index XXXXXXX..XXXXXXX | ||
22 | --- /dev/null | ||
23 | +++ b/docs/devel/clocks.rst | ||
24 | @@ -XXX,XX +XXX,XX @@ | ||
25 | +Modelling a clock tree in QEMU | ||
26 | +============================== | ||
27 | + | ||
28 | +What are clocks? | ||
29 | +---------------- | ||
30 | + | ||
31 | +Clocks are QOM objects developed for the purpose of modelling the | ||
32 | +distribution of clocks in QEMU. | ||
33 | + | ||
34 | +They allow us to model the clock distribution of a platform and detect | ||
35 | +configuration errors in the clock tree such as badly configured PLL, clock | ||
36 | +source selection or disabled clock. | ||
37 | + | ||
38 | +The object is *Clock* and its QOM name is ``clock`` (in C code, the macro | ||
39 | +``TYPE_CLOCK``). | ||
40 | + | ||
41 | +Clocks are typically used with devices where they are used to model inputs | ||
42 | +and outputs. They are created in a similar way to GPIOs. Inputs and outputs | ||
43 | +of different devices can be connected together. | ||
44 | + | ||
45 | +In these cases a Clock object is a child of a Device object, but this | ||
46 | +is not a requirement. Clocks can be independent of devices. For | ||
47 | +example it is possible to create a clock outside of any device to | ||
48 | +model the main clock source of a machine. | ||
49 | + | ||
50 | +Here is an example of clocks:: | ||
51 | + | ||
52 | + +---------+ +----------------------+ +--------------+ | ||
53 | + | Clock 1 | | Device B | | Device C | | ||
54 | + | | | +-------+ +-------+ | | +-------+ | | ||
55 | + | |>>-+-->>|Clock 2| |Clock 3|>>--->>|Clock 6| | | ||
56 | + +---------+ | | | (in) | | (out) | | | | (in) | | | ||
57 | + | | +-------+ +-------+ | | +-------+ | | ||
58 | + | | +-------+ | +--------------+ | ||
59 | + | | |Clock 4|>> | ||
60 | + | | | (out) | | +--------------+ | ||
61 | + | | +-------+ | | Device D | | ||
62 | + | | +-------+ | | +-------+ | | ||
63 | + | | |Clock 5|>>--->>|Clock 7| | | ||
64 | + | | | (out) | | | | (in) | | | ||
65 | + | | +-------+ | | +-------+ | | ||
66 | + | +----------------------+ | | | ||
67 | + | | +-------+ | | ||
68 | + +----------------------------->>|Clock 8| | | ||
69 | + | | (in) | | | ||
70 | + | +-------+ | | ||
71 | + +--------------+ | ||
72 | + | ||
73 | +Clocks are defined in the ``include/hw/clock.h`` header and device | ||
74 | +related functions are defined in the ``include/hw/qdev-clock.h`` | ||
75 | +header. | ||
76 | + | ||
77 | +The clock state | ||
78 | +--------------- | ||
79 | + | ||
80 | +The state of a clock is its period; it is stored as an integer | ||
81 | +representing it in units of 2 :sup:`-32` ns. The special value of 0 is used to | ||
82 | +represent the clock being inactive or gated. The clocks do not model | ||
83 | +the signal itself (pin toggling) or other properties such as the duty | ||
84 | +cycle. | ||
85 | + | ||
86 | +All clocks contain this state: outputs as well as inputs. This allows | ||
87 | +the current period of a clock to be fetched at any time. When a clock | ||
88 | +is updated, the value is immediately propagated to all connected | ||
89 | +clocks in the tree. | ||
90 | + | ||
91 | +To ease interaction with clocks, helpers with a unit suffix are defined for | ||
92 | +every clock state setter or getter. The suffixes are: | ||
93 | + | ||
94 | +- ``_ns`` for handling periods in nanoseconds | ||
95 | +- ``_hz`` for handling frequencies in hertz | ||
96 | + | ||
97 | +The 0 period value is converted to 0 in hertz and vice versa. 0 always means | ||
98 | +that the clock is disabled. | ||
99 | + | ||
100 | +Adding a new clock | ||
101 | +------------------ | ||
102 | + | ||
103 | +Adding clocks to a device must be done during the init method of the Device | ||
104 | +instance. | ||
105 | + | ||
106 | +To add an input clock to a device, the function ``qdev_init_clock_in()`` | ||
107 | +must be used. It takes the name, a callback and an opaque parameter | ||
108 | +for the callback (this will be explained in a following section). | ||
109 | +Output is simpler; only the name is required. Typically:: | ||
110 | + | ||
111 | + qdev_init_clock_in(DEVICE(dev), "clk_in", clk_in_callback, dev); | ||
112 | + qdev_init_clock_out(DEVICE(dev), "clk_out"); | ||
113 | + | ||
114 | +Both functions return the created Clock pointer, which should be saved in the | ||
115 | +device's state structure for further use. | ||
116 | + | ||
117 | +These objects will be automatically deleted by the QOM reference mechanism. | ||
118 | + | ||
119 | +Note that it is possible to create a static array describing clock inputs and | ||
120 | +outputs. The function ``qdev_init_clocks()`` must be called with the array as | ||
121 | +parameter to initialize the clocks: it has the same behaviour as calling the | ||
122 | +``qdev_init_clock_in/out()`` for each clock in the array. To ease the array | ||
123 | +construction, some macros are defined in ``include/hw/qdev-clock.h``. | ||
124 | +As an example, the following creates 2 clocks to a device: one input and one | ||
125 | +output. | ||
126 | + | ||
127 | +.. code-block:: c | ||
128 | + | ||
129 | + /* device structure containing pointers to the clock objects */ | ||
130 | + typedef struct MyDeviceState { | ||
131 | + DeviceState parent_obj; | ||
132 | + Clock *clk_in; | ||
133 | + Clock *clk_out; | ||
134 | + } MyDeviceState; | ||
135 | + | ||
136 | + /* | ||
137 | + * callback for the input clock (see "Callback on input clock | ||
138 | + * change" section below for more information). | ||
139 | + */ | ||
140 | + static void clk_in_callback(void *opaque); | ||
141 | + | ||
142 | + /* | ||
143 | + * static array describing clocks: | ||
144 | + * + a clock input named "clk_in", whose pointer is stored in | ||
145 | + * the clk_in field of a MyDeviceState structure with callback | ||
146 | + * clk_in_callback. | ||
147 | + * + a clock output named "clk_out" whose pointer is stored in | ||
148 | + * the clk_out field of a MyDeviceState structure. | ||
149 | + */ | ||
150 | + static const ClockPortInitArray mydev_clocks = { | ||
151 | + QDEV_CLOCK_IN(MyDeviceState, clk_in, clk_in_callback), | ||
152 | + QDEV_CLOCK_OUT(MyDeviceState, clk_out), | ||
153 | + QDEV_CLOCK_END | ||
154 | + }; | ||
155 | + | ||
156 | + /* device initialization function */ | ||
157 | + static void mydev_init(Object *obj) | ||
158 | + { | ||
159 | + /* cast to MyDeviceState */ | ||
160 | + MyDeviceState *mydev = MYDEVICE(obj); | ||
161 | + /* create and fill the pointer fields in the MyDeviceState */ | ||
162 | + qdev_init_clocks(mydev, mydev_clocks); | ||
163 | + [...] | ||
164 | + } | ||
165 | + | ||
166 | +An alternative way to create a clock is to simply call | ||
167 | +``object_new(TYPE_CLOCK)``. In that case the clock will neither be an | ||
168 | +input nor an output of a device. After the whole QOM hierarchy of the | ||
169 | +clock has been set ``clock_setup_canonical_path()`` should be called. | ||
170 | + | ||
171 | +At creation, the period of the clock is 0: the clock is disabled. You can | ||
172 | +change it using ``clock_set_ns()`` or ``clock_set_hz()``. | ||
173 | + | ||
174 | +Note that if you are creating a clock with a fixed period which will never | ||
175 | +change (for example the main clock source of a board), then you'll have | ||
176 | +nothing else to do. This value will be propagated to other clocks when | ||
177 | +connecting the clocks together and devices will fetch the right value during | ||
178 | +the first reset. | ||
179 | + | ||
180 | +Retrieving clocks from a device | ||
181 | +------------------------------- | ||
182 | + | ||
183 | +``qdev_get_clock_in()`` and ``dev_get_clock_out()`` are available to | ||
184 | +get the clock inputs or outputs of a device. For example: | ||
185 | + | ||
186 | +.. code-block:: c | ||
187 | + | ||
188 | + Clock *clk = qdev_get_clock_in(DEVICE(mydev), "clk_in"); | ||
189 | + | ||
190 | +or: | ||
191 | + | ||
192 | +.. code-block:: c | ||
193 | + | ||
194 | + Clock *clk = qdev_get_clock_out(DEVICE(mydev), "clk_out"); | ||
195 | + | ||
196 | +Connecting two clocks together | ||
197 | +------------------------------ | ||
198 | + | ||
199 | +To connect two clocks together, use the ``clock_set_source()`` function. | ||
200 | +Given two clocks ``clk1``, and ``clk2``, ``clock_set_source(clk2, clk1);`` | ||
201 | +configures ``clk2`` to follow the ``clk1`` period changes. Every time ``clk1`` | ||
202 | +is updated, ``clk2`` will be updated too. | ||
203 | + | ||
204 | +When connecting clock between devices, prefer using the | ||
205 | +``qdev_connect_clock_in()`` function to set the source of an input | ||
206 | +device clock. For example, to connect the input clock ``clk2`` of | ||
207 | +``devB`` to the output clock ``clk1`` of ``devA``, do: | ||
208 | + | ||
209 | +.. code-block:: c | ||
210 | + | ||
211 | + qdev_connect_clock_in(devB, "clk2", qdev_get_clock_out(devA, "clk1")) | ||
212 | + | ||
213 | +We used ``qdev_get_clock_out()`` above, but any clock can drive an | ||
214 | +input clock, even another input clock. The following diagram shows | ||
215 | +some examples of connections. Note also that a clock can drive several | ||
216 | +other clocks. | ||
217 | + | ||
218 | +:: | ||
219 | + | ||
220 | + +------------+ +--------------------------------------------------+ | ||
221 | + | Device A | | Device B | | ||
222 | + | | | +---------------------+ | | ||
223 | + | | | | Device C | | | ||
224 | + | +-------+ | | +-------+ | +-------+ +-------+ | +-------+ | | ||
225 | + | |Clock 1|>>-->>|Clock 2|>>+-->>|Clock 3| |Clock 5|>>>>|Clock 6|>> | ||
226 | + | | (out) | | | | (in) | | | | (in) | | (out) | | | (out) | | | ||
227 | + | +-------+ | | +-------+ | | +-------+ +-------+ | +-------+ | | ||
228 | + +------------+ | | +---------------------+ | | ||
229 | + | | | | ||
230 | + | | +--------------+ | | ||
231 | + | | | Device D | | | ||
232 | + | | | +-------+ | | | ||
233 | + | +-->>|Clock 4| | | | ||
234 | + | | | (in) | | | | ||
235 | + | | +-------+ | | | ||
236 | + | +--------------+ | | ||
237 | + +--------------------------------------------------+ | ||
238 | + | ||
239 | +In the above example, when *Clock 1* is updated by *Device A*, three | ||
240 | +clocks get the new clock period value: *Clock 2*, *Clock 3* and *Clock 4*. | ||
241 | + | ||
242 | +It is not possible to disconnect a clock or to change the clock connection | ||
243 | +after it is connected. | ||
244 | + | ||
245 | +Unconnected input clocks | ||
246 | +------------------------ | ||
247 | + | ||
248 | +A newly created input clock is disabled (period of 0). This means the | ||
249 | +clock will be considered as disabled until the period is updated. If | ||
250 | +the clock remains unconnected it will always keep its initial value | ||
251 | +of 0. If this is not the desired behaviour, ``clock_set()``, | ||
252 | +``clock_set_ns()`` or ``clock_set_hz()`` should be called on the Clock | ||
253 | +object during device instance init. For example: | ||
254 | + | ||
255 | +.. code-block:: c | ||
256 | + | ||
257 | + clk = qdev_init_clock_in(DEVICE(dev), "clk-in", clk_in_callback, | ||
258 | + dev); | ||
259 | + /* set initial value to 10ns / 100MHz */ | ||
260 | + clock_set_ns(clk, 10); | ||
261 | + | ||
262 | +Fetching clock frequency/period | ||
263 | +------------------------------- | ||
264 | + | ||
265 | +To get the current state of a clock, use the functions ``clock_get()``, | ||
266 | +``clock_get_ns()`` or ``clock_get_hz()``. | ||
267 | + | ||
268 | +It is also possible to register a callback on clock frequency changes. | ||
269 | +Here is an example: | ||
270 | + | ||
271 | +.. code-block:: c | ||
272 | + | ||
273 | + void clock_callback(void *opaque) { | ||
274 | + MyDeviceState *s = (MyDeviceState *) opaque; | ||
275 | + /* | ||
276 | + * 'opaque' is the argument passed to qdev_init_clock_in(); | ||
277 | + * usually this will be the device state pointer. | ||
278 | + */ | ||
279 | + | ||
280 | + /* do something with the new period */ | ||
281 | + fprintf(stdout, "device new period is %" PRIu64 "ns\n", | ||
282 | + clock_get_ns(dev->my_clk_input)); | ||
283 | + } | ||
284 | + | ||
285 | +Changing a clock period | ||
286 | +----------------------- | ||
287 | + | ||
288 | +A device can change its outputs using the ``clock_update()``, | ||
289 | +``clock_update_ns()`` or ``clock_update_hz()`` function. It will trigger | ||
290 | +updates on every connected input. | ||
291 | + | ||
292 | +For example, let's say that we have an output clock *clkout* and we | ||
293 | +have a pointer to it in the device state because we did the following | ||
294 | +in init phase: | ||
295 | + | ||
296 | +.. code-block:: c | ||
297 | + | ||
298 | + dev->clkout = qdev_init_clock_out(DEVICE(dev), "clkout"); | ||
299 | + | ||
300 | +Then at any time (apart from the cases listed below), it is possible to | ||
301 | +change the clock value by doing: | ||
302 | + | ||
303 | +.. code-block:: c | ||
304 | + | ||
305 | + clock_update_hz(dev->clkout, 1000 * 1000 * 1000); /* 1GHz */ | ||
306 | + | ||
307 | +Because updating a clock may trigger any side effects through | ||
308 | +connected clocks and their callbacks, this operation must be done | ||
309 | +while holding the qemu io lock. | ||
310 | + | ||
311 | +For the same reason, one can update clocks only when it is allowed to have | ||
312 | +side effects on other objects. In consequence, it is forbidden: | ||
313 | + | ||
314 | +* during migration, | ||
315 | +* and in the enter phase of reset. | ||
316 | + | ||
317 | +Note that calling ``clock_update[_ns|_hz]()`` is equivalent to calling | ||
318 | +``clock_set[_ns|_hz]()`` (with the same arguments) then | ||
319 | +``clock_propagate()`` on the clock. Thus, setting the clock value can | ||
320 | +be separated from triggering the side-effects. This is often required | ||
321 | +to factorize code to handle reset and migration in devices. | ||
322 | + | ||
323 | +Aliasing clocks | ||
324 | +--------------- | ||
325 | + | ||
326 | +Sometimes, one needs to forward, or inherit, a clock from another | ||
327 | +device. Typically, when doing device composition, a device might | ||
328 | +expose a sub-device's clock without interfering with it. The function | ||
329 | +``qdev_alias_clock()`` can be used to achieve this behaviour. Note | ||
330 | +that it is possible to expose the clock under a different name. | ||
331 | +``qdev_alias_clock()`` works for both input and output clocks. | ||
332 | + | ||
333 | +For example, if device B is a child of device A, | ||
334 | +``device_a_instance_init()`` may do something like this: | ||
335 | + | ||
336 | +.. code-block:: c | ||
337 | + | ||
338 | + void device_a_instance_init(Object *obj) | ||
339 | + { | ||
340 | + AState *A = DEVICE_A(obj); | ||
341 | + BState *B; | ||
342 | + /* create object B as child of A */ | ||
343 | + [...] | ||
344 | + qdev_alias_clock(B, "clk", A, "b_clk"); | ||
345 | + /* | ||
346 | + * Now A has a clock "b_clk" which is an alias to | ||
347 | + * the clock "clk" of its child B. | ||
348 | + */ | ||
349 | + } | ||
350 | + | ||
351 | +This function does not return any clock object. The new clock has the | ||
352 | +same direction (input or output) as the original one. This function | ||
353 | +only adds a link to the existing clock. In the above example, object B | ||
354 | +remains the only object allowed to use the clock and device A must not | ||
355 | +try to change the clock period or set a callback to the clock. This | ||
356 | +diagram describes the example with an input clock:: | ||
357 | + | ||
358 | + +--------------------------+ | ||
359 | + | Device A | | ||
360 | + | +--------------+ | | ||
361 | + | | Device B | | | ||
362 | + | | +-------+ | | | ||
363 | + >>"b_clk">>>| "clk" | | | | ||
364 | + | (in) | | (in) | | | | ||
365 | + | | +-------+ | | | ||
366 | + | +--------------+ | | ||
367 | + +--------------------------+ | ||
368 | + | ||
369 | +Migration | ||
370 | +--------- | ||
371 | + | ||
372 | +Clock state is not migrated automatically. Every device must handle its | ||
373 | +clock migration. Alias clocks must not be migrated. | ||
374 | + | ||
375 | +To ensure clock states are restored correctly during migration, there | ||
376 | +are two solutions. | ||
377 | + | ||
378 | +Clock states can be migrated by adding an entry into the device | ||
379 | +vmstate description. You should use the ``VMSTATE_CLOCK`` macro for this. | ||
380 | +This is typically used to migrate an input clock state. For example: | ||
381 | + | ||
382 | +.. code-block:: c | ||
383 | + | ||
384 | + MyDeviceState { | ||
385 | + DeviceState parent_obj; | ||
386 | + [...] /* some fields */ | ||
387 | + Clock *clk; | ||
388 | + }; | ||
389 | + | ||
390 | + VMStateDescription my_device_vmstate = { | ||
391 | + .name = "my_device", | ||
392 | + .fields = (VMStateField[]) { | ||
393 | + [...], /* other migrated fields */ | ||
394 | + VMSTATE_CLOCK(clk, MyDeviceState), | ||
395 | + VMSTATE_END_OF_LIST() | ||
396 | + } | ||
397 | + }; | ||
398 | + | ||
399 | +The second solution is to restore the clock state using information already | ||
400 | +at our disposal. This can be used to restore output clock states using the | ||
401 | +device state. The functions ``clock_set[_ns|_hz]()`` can be used during the | ||
402 | +``post_load()`` migration callback. | ||
403 | + | ||
404 | +When adding clock support to an existing device, if you care about | ||
405 | +migration compatibility you will need to be careful, as simply adding | ||
406 | +a ``VMSTATE_CLOCK()`` line will break compatibility. Instead, you can | ||
407 | +put the ``VMSTATE_CLOCK()`` line into a vmstate subsection with a | ||
408 | +suitable ``needed`` function, and use ``clock_set()`` in a | ||
409 | +``pre_load()`` function to set the default value that will be used if | ||
410 | +the source virtual machine in the migration does not send the clock | ||
411 | +state. | ||
412 | + | ||
413 | +Care should be taken not to use ``clock_update[_ns|_hz]()`` or | ||
414 | +``clock_propagate()`` during the whole migration procedure because it | ||
415 | +will trigger side effects to other devices in an unknown state. | ||
416 | diff --git a/docs/devel/index.rst b/docs/devel/index.rst | ||
15 | index XXXXXXX..XXXXXXX 100644 | 417 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/neon-dp.decode | 418 | --- a/docs/devel/index.rst |
17 | +++ b/target/arm/neon-dp.decode | 419 | +++ b/docs/devel/index.rst |
18 | @@ -XXX,XX +XXX,XX @@ | 420 | @@ -XXX,XX +XXX,XX @@ Contents: |
19 | @3same .... ... . . . size:2 .... .... .... . q:1 . . .... \ | 421 | bitops |
20 | &3same vm=%vm_dp vn=%vn_dp vd=%vd_dp | 422 | reset |
21 | 423 | s390-dasd-ipl | |
22 | +@3same_logic .... ... . . . .. .... .... .... . q:1 .. .... \ | 424 | + clocks |
23 | + &3same vm=%vm_dp vn=%vn_dp vd=%vd_dp size=0 | ||
24 | + | ||
25 | +VAND_3s 1111 001 0 0 . 00 .... .... 0001 ... 1 .... @3same_logic | ||
26 | +VBIC_3s 1111 001 0 0 . 01 .... .... 0001 ... 1 .... @3same_logic | ||
27 | +VORR_3s 1111 001 0 0 . 10 .... .... 0001 ... 1 .... @3same_logic | ||
28 | +VORN_3s 1111 001 0 0 . 11 .... .... 0001 ... 1 .... @3same_logic | ||
29 | +VEOR_3s 1111 001 1 0 . 00 .... .... 0001 ... 1 .... @3same_logic | ||
30 | +VBSL_3s 1111 001 1 0 . 01 .... .... 0001 ... 1 .... @3same_logic | ||
31 | +VBIT_3s 1111 001 1 0 . 10 .... .... 0001 ... 1 .... @3same_logic | ||
32 | +VBIF_3s 1111 001 1 0 . 11 .... .... 0001 ... 1 .... @3same_logic | ||
33 | + | ||
34 | VADD_3s 1111 001 0 0 . .. .... .... 1000 . . . 0 .... @3same | ||
35 | VSUB_3s 1111 001 1 0 . .. .... .... 1000 . . . 0 .... @3same | ||
36 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/target/arm/translate-neon.inc.c | ||
39 | +++ b/target/arm/translate-neon.inc.c | ||
40 | @@ -XXX,XX +XXX,XX @@ static bool do_3same(DisasContext *s, arg_3same *a, GVecGen3Fn fn) | ||
41 | |||
42 | DO_3SAME(VADD, tcg_gen_gvec_add) | ||
43 | DO_3SAME(VSUB, tcg_gen_gvec_sub) | ||
44 | +DO_3SAME(VAND, tcg_gen_gvec_and) | ||
45 | +DO_3SAME(VBIC, tcg_gen_gvec_andc) | ||
46 | +DO_3SAME(VORR, tcg_gen_gvec_or) | ||
47 | +DO_3SAME(VORN, tcg_gen_gvec_orc) | ||
48 | +DO_3SAME(VEOR, tcg_gen_gvec_xor) | ||
49 | + | ||
50 | +/* These insns are all gvec_bitsel but with the inputs in various orders. */ | ||
51 | +#define DO_3SAME_BITSEL(INSN, O1, O2, O3) \ | ||
52 | + static void gen_##INSN##_3s(unsigned vece, uint32_t rd_ofs, \ | ||
53 | + uint32_t rn_ofs, uint32_t rm_ofs, \ | ||
54 | + uint32_t oprsz, uint32_t maxsz) \ | ||
55 | + { \ | ||
56 | + tcg_gen_gvec_bitsel(vece, rd_ofs, O1, O2, O3, oprsz, maxsz); \ | ||
57 | + } \ | ||
58 | + DO_3SAME(INSN, gen_##INSN##_3s) | ||
59 | + | ||
60 | +DO_3SAME_BITSEL(VBSL, rd_ofs, rn_ofs, rm_ofs) | ||
61 | +DO_3SAME_BITSEL(VBIT, rm_ofs, rn_ofs, rd_ofs) | ||
62 | +DO_3SAME_BITSEL(VBIF, rm_ofs, rd_ofs, rn_ofs) | ||
63 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/target/arm/translate.c | ||
66 | +++ b/target/arm/translate.c | ||
67 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
68 | } | ||
69 | return 1; | ||
70 | |||
71 | - case NEON_3R_LOGIC: /* Logic ops. */ | ||
72 | - switch ((u << 2) | size) { | ||
73 | - case 0: /* VAND */ | ||
74 | - tcg_gen_gvec_and(0, rd_ofs, rn_ofs, rm_ofs, | ||
75 | - vec_size, vec_size); | ||
76 | - break; | ||
77 | - case 1: /* VBIC */ | ||
78 | - tcg_gen_gvec_andc(0, rd_ofs, rn_ofs, rm_ofs, | ||
79 | - vec_size, vec_size); | ||
80 | - break; | ||
81 | - case 2: /* VORR */ | ||
82 | - tcg_gen_gvec_or(0, rd_ofs, rn_ofs, rm_ofs, | ||
83 | - vec_size, vec_size); | ||
84 | - break; | ||
85 | - case 3: /* VORN */ | ||
86 | - tcg_gen_gvec_orc(0, rd_ofs, rn_ofs, rm_ofs, | ||
87 | - vec_size, vec_size); | ||
88 | - break; | ||
89 | - case 4: /* VEOR */ | ||
90 | - tcg_gen_gvec_xor(0, rd_ofs, rn_ofs, rm_ofs, | ||
91 | - vec_size, vec_size); | ||
92 | - break; | ||
93 | - case 5: /* VBSL */ | ||
94 | - tcg_gen_gvec_bitsel(MO_8, rd_ofs, rd_ofs, rn_ofs, rm_ofs, | ||
95 | - vec_size, vec_size); | ||
96 | - break; | ||
97 | - case 6: /* VBIT */ | ||
98 | - tcg_gen_gvec_bitsel(MO_8, rd_ofs, rm_ofs, rn_ofs, rd_ofs, | ||
99 | - vec_size, vec_size); | ||
100 | - break; | ||
101 | - case 7: /* VBIF */ | ||
102 | - tcg_gen_gvec_bitsel(MO_8, rd_ofs, rm_ofs, rd_ofs, rn_ofs, | ||
103 | - vec_size, vec_size); | ||
104 | - break; | ||
105 | - } | ||
106 | - return 0; | ||
107 | - | ||
108 | case NEON_3R_VQADD: | ||
109 | tcg_gen_gvec_4(rd_ofs, offsetof(CPUARMState, vfp.qc), | ||
110 | rn_ofs, rm_ofs, vec_size, vec_size, | ||
111 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
112 | return 0; | ||
113 | |||
114 | case NEON_3R_VADD_VSUB: | ||
115 | + case NEON_3R_LOGIC: | ||
116 | /* Already handled by decodetree */ | ||
117 | return 1; | ||
118 | } | ||
119 | -- | 425 | -- |
120 | 2.20.1 | 426 | 2.20.1 |
121 | 427 | ||
122 | 428 | diff view generated by jsdifflib |
1 | Convert the Neon "load single structure to all lanes" insns to | 1 | From: Damien Hedde <damien.hedde@greensocs.com> |
---|---|---|---|
2 | decodetree. | 2 | |
3 | 3 | Add some clocks to zynq_slcr | |
4 | + the main input clock (ps_clk) | ||
5 | + the reference clock outputs for each uart (uart0 & 1) | ||
6 | |||
7 | This commit also transitional the slcr to multi-phase reset as it is | ||
8 | required to initialize the clocks correctly. | ||
9 | |||
10 | The clock frequencies are computed using the internal pll & uart configuration | ||
11 | registers and the input ps_clk frequency. | ||
12 | |||
13 | Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> | ||
14 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
15 | Acked-by: Alistair Francis <alistair.francis@wdc.com> | ||
16 | Message-id: 20200406135251.157596-7-damien.hedde@greensocs.com | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20200430181003.21682-13-peter.maydell@linaro.org | ||
7 | --- | 18 | --- |
8 | target/arm/neon-ls.decode | 5 +++ | 19 | hw/misc/zynq_slcr.c | 172 ++++++++++++++++++++++++++++++++++++++++++-- |
9 | target/arm/translate-neon.inc.c | 73 +++++++++++++++++++++++++++++++++ | 20 | 1 file changed, 168 insertions(+), 4 deletions(-) |
10 | target/arm/translate.c | 55 +------------------------ | 21 | |
11 | 3 files changed, 80 insertions(+), 53 deletions(-) | 22 | diff --git a/hw/misc/zynq_slcr.c b/hw/misc/zynq_slcr.c |
12 | |||
13 | diff --git a/target/arm/neon-ls.decode b/target/arm/neon-ls.decode | ||
14 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/neon-ls.decode | 24 | --- a/hw/misc/zynq_slcr.c |
16 | +++ b/target/arm/neon-ls.decode | 25 | +++ b/hw/misc/zynq_slcr.c |
17 | @@ -XXX,XX +XXX,XX @@ | 26 | @@ -XXX,XX +XXX,XX @@ |
18 | 27 | #include "qemu/log.h" | |
19 | VLDST_multiple 1111 0100 0 . l:1 0 rn:4 .... itype:4 size:2 align:2 rm:4 \ | 28 | #include "qemu/module.h" |
20 | vd=%vd_dp | 29 | #include "hw/registerfields.h" |
21 | + | 30 | +#include "hw/qdev-clock.h" |
22 | +# Neon load single element to all lanes | 31 | |
23 | + | 32 | #ifndef ZYNQ_SLCR_ERR_DEBUG |
24 | +VLD_all_lanes 1111 0100 1 . 1 0 rn:4 .... 11 n:2 size:2 t:1 a:1 rm:4 \ | 33 | #define ZYNQ_SLCR_ERR_DEBUG 0 |
25 | + vd=%vd_dp | 34 | @@ -XXX,XX +XXX,XX @@ REG32(LOCKSTA, 0x00c) |
26 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | 35 | REG32(ARM_PLL_CTRL, 0x100) |
27 | index XXXXXXX..XXXXXXX 100644 | 36 | REG32(DDR_PLL_CTRL, 0x104) |
28 | --- a/target/arm/translate-neon.inc.c | 37 | REG32(IO_PLL_CTRL, 0x108) |
29 | +++ b/target/arm/translate-neon.inc.c | 38 | +/* fields for [ARM|DDR|IO]_PLL_CTRL registers */ |
30 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_multiple(DisasContext *s, arg_VLDST_multiple *a) | 39 | + FIELD(xxx_PLL_CTRL, PLL_RESET, 0, 1) |
31 | gen_neon_ldst_base_update(s, a->rm, a->rn, nregs * interleave * 8); | 40 | + FIELD(xxx_PLL_CTRL, PLL_PWRDWN, 1, 1) |
32 | return true; | 41 | + FIELD(xxx_PLL_CTRL, PLL_BYPASS_QUAL, 3, 1) |
33 | } | 42 | + FIELD(xxx_PLL_CTRL, PLL_BYPASS_FORCE, 4, 1) |
34 | + | 43 | + FIELD(xxx_PLL_CTRL, PLL_FPDIV, 12, 7) |
35 | +static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a) | 44 | REG32(PLL_STATUS, 0x10c) |
36 | +{ | 45 | REG32(ARM_PLL_CFG, 0x110) |
37 | + /* Neon load single structure to all lanes */ | 46 | REG32(DDR_PLL_CFG, 0x114) |
38 | + int reg, stride, vec_size; | 47 | @@ -XXX,XX +XXX,XX @@ REG32(SMC_CLK_CTRL, 0x148) |
39 | + int vd = a->vd; | 48 | REG32(LQSPI_CLK_CTRL, 0x14c) |
40 | + int size = a->size; | 49 | REG32(SDIO_CLK_CTRL, 0x150) |
41 | + int nregs = a->n + 1; | 50 | REG32(UART_CLK_CTRL, 0x154) |
42 | + TCGv_i32 addr, tmp; | 51 | + FIELD(UART_CLK_CTRL, CLKACT0, 0, 1) |
43 | + | 52 | + FIELD(UART_CLK_CTRL, CLKACT1, 1, 1) |
44 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | 53 | + FIELD(UART_CLK_CTRL, SRCSEL, 4, 2) |
45 | + return false; | 54 | + FIELD(UART_CLK_CTRL, DIVISOR, 8, 6) |
46 | + } | 55 | REG32(SPI_CLK_CTRL, 0x158) |
47 | + | 56 | REG32(CAN_CLK_CTRL, 0x15c) |
48 | + /* UNDEF accesses to D16-D31 if they don't exist */ | 57 | REG32(CAN_MIOCLK_CTRL, 0x160) |
49 | + if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) { | 58 | @@ -XXX,XX +XXX,XX @@ typedef struct ZynqSLCRState { |
50 | + return false; | 59 | MemoryRegion iomem; |
51 | + } | 60 | |
52 | + | 61 | uint32_t regs[ZYNQ_SLCR_NUM_REGS]; |
53 | + if (size == 3) { | 62 | + |
54 | + if (nregs != 4 || a->a == 0) { | 63 | + Clock *ps_clk; |
55 | + return false; | 64 | + Clock *uart0_ref_clk; |
56 | + } | 65 | + Clock *uart1_ref_clk; |
57 | + /* For VLD4 size == 3 a == 1 means 32 bits at 16 byte alignment */ | 66 | } ZynqSLCRState; |
58 | + size = 2; | 67 | |
59 | + } | 68 | -static void zynq_slcr_reset(DeviceState *d) |
60 | + if (nregs == 1 && a->a == 1 && size == 0) { | 69 | +/* |
61 | + return false; | 70 | + * return the output frequency of ARM/DDR/IO pll |
62 | + } | 71 | + * using input frequency and PLL_CTRL register |
63 | + if (nregs == 3 && a->a == 1) { | 72 | + */ |
64 | + return false; | 73 | +static uint64_t zynq_slcr_compute_pll(uint64_t input, uint32_t ctrl_reg) |
65 | + } | 74 | { |
66 | + | 75 | - ZynqSLCRState *s = ZYNQ_SLCR(d); |
67 | + if (!vfp_access_check(s)) { | 76 | + uint32_t mult = ((ctrl_reg & R_xxx_PLL_CTRL_PLL_FPDIV_MASK) >> |
68 | + return true; | 77 | + R_xxx_PLL_CTRL_PLL_FPDIV_SHIFT); |
78 | + | ||
79 | + /* first, check if pll is bypassed */ | ||
80 | + if (ctrl_reg & R_xxx_PLL_CTRL_PLL_BYPASS_FORCE_MASK) { | ||
81 | + return input; | ||
82 | + } | ||
83 | + | ||
84 | + /* is pll disabled ? */ | ||
85 | + if (ctrl_reg & (R_xxx_PLL_CTRL_PLL_RESET_MASK | | ||
86 | + R_xxx_PLL_CTRL_PLL_PWRDWN_MASK)) { | ||
87 | + return 0; | ||
88 | + } | ||
89 | + | ||
90 | + /* frequency multiplier -> period division */ | ||
91 | + return input / mult; | ||
92 | +} | ||
93 | + | ||
94 | +/* | ||
95 | + * return the output period of a clock given: | ||
96 | + * + the periods in an array corresponding to input mux selector | ||
97 | + * + the register xxx_CLK_CTRL value | ||
98 | + * + enable bit index in ctrl register | ||
99 | + * | ||
100 | + * This function makes the assumption that the ctrl_reg value is organized as | ||
101 | + * follows: | ||
102 | + * + bits[13:8] clock frequency divisor | ||
103 | + * + bits[5:4] clock mux selector (index in array) | ||
104 | + * + bits[index] clock enable | ||
105 | + */ | ||
106 | +static uint64_t zynq_slcr_compute_clock(const uint64_t periods[], | ||
107 | + uint32_t ctrl_reg, | ||
108 | + unsigned index) | ||
109 | +{ | ||
110 | + uint32_t srcsel = extract32(ctrl_reg, 4, 2); /* bits [5:4] */ | ||
111 | + uint32_t divisor = extract32(ctrl_reg, 8, 6); /* bits [13:8] */ | ||
112 | + | ||
113 | + /* first, check if clock is disabled */ | ||
114 | + if (((ctrl_reg >> index) & 1u) == 0) { | ||
115 | + return 0; | ||
69 | + } | 116 | + } |
70 | + | 117 | + |
71 | + /* | 118 | + /* |
72 | + * VLD1 to all lanes: T bit indicates how many Dregs to write. | 119 | + * according to the Zynq technical ref. manual UG585 v1.12.2 in |
73 | + * VLD2/3/4 to all lanes: T bit indicates register stride. | 120 | + * Clocks chapter, section 25.10.1 page 705: |
121 | + * "The 6-bit divider provides a divide range of 1 to 63" | ||
122 | + * We follow here what is implemented in linux kernel and consider | ||
123 | + * the 0 value as a bypass (no division). | ||
74 | + */ | 124 | + */ |
75 | + stride = a->t ? 2 : 1; | 125 | + /* frequency divisor -> period multiplication */ |
76 | + vec_size = nregs == 1 ? stride * 8 : 8; | 126 | + return periods[srcsel] * (divisor ? divisor : 1u); |
77 | + | 127 | +} |
78 | + tmp = tcg_temp_new_i32(); | 128 | + |
79 | + addr = tcg_temp_new_i32(); | 129 | +/* |
80 | + load_reg_var(s, addr, a->rn); | 130 | + * macro helper around zynq_slcr_compute_clock to avoid repeating |
81 | + for (reg = 0; reg < nregs; reg++) { | 131 | + * the register name. |
82 | + gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), | 132 | + */ |
83 | + s->be_data | size); | 133 | +#define ZYNQ_COMPUTE_CLK(state, plls, reg, enable_field) \ |
84 | + if ((vd & 1) && vec_size == 16) { | 134 | + zynq_slcr_compute_clock((plls), (state)->regs[reg], \ |
85 | + /* | 135 | + reg ## _ ## enable_field ## _SHIFT) |
86 | + * We cannot write 16 bytes at once because the | 136 | + |
87 | + * destination is unaligned. | 137 | +/** |
88 | + */ | 138 | + * Compute and set the ouputs clocks periods. |
89 | + tcg_gen_gvec_dup_i32(size, neon_reg_offset(vd, 0), | 139 | + * But do not propagate them further. Connected clocks |
90 | + 8, 8, tmp); | 140 | + * will not receive any updates (See zynq_slcr_compute_clocks()) |
91 | + tcg_gen_gvec_mov(0, neon_reg_offset(vd + 1, 0), | 141 | + */ |
92 | + neon_reg_offset(vd, 0), 8, 8); | 142 | +static void zynq_slcr_compute_clocks(ZynqSLCRState *s) |
93 | + } else { | 143 | +{ |
94 | + tcg_gen_gvec_dup_i32(size, neon_reg_offset(vd, 0), | 144 | + uint64_t ps_clk = clock_get(s->ps_clk); |
95 | + vec_size, vec_size, tmp); | 145 | + |
96 | + } | 146 | + /* consider outputs clocks are disabled while in reset */ |
97 | + tcg_gen_addi_i32(addr, addr, 1 << size); | 147 | + if (device_is_in_reset(DEVICE(s))) { |
98 | + vd += stride; | 148 | + ps_clk = 0; |
99 | + } | 149 | + } |
100 | + tcg_temp_free_i32(tmp); | 150 | + |
101 | + tcg_temp_free_i32(addr); | 151 | + uint64_t io_pll = zynq_slcr_compute_pll(ps_clk, s->regs[R_IO_PLL_CTRL]); |
102 | + | 152 | + uint64_t arm_pll = zynq_slcr_compute_pll(ps_clk, s->regs[R_ARM_PLL_CTRL]); |
103 | + gen_neon_ldst_base_update(s, a->rm, a->rn, (1 << size) * nregs); | 153 | + uint64_t ddr_pll = zynq_slcr_compute_pll(ps_clk, s->regs[R_DDR_PLL_CTRL]); |
104 | + | 154 | + |
105 | + return true; | 155 | + uint64_t uart_mux[4] = {io_pll, io_pll, arm_pll, ddr_pll}; |
106 | +} | 156 | + |
107 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 157 | + /* compute uartX reference clocks */ |
108 | index XXXXXXX..XXXXXXX 100644 | 158 | + clock_set(s->uart0_ref_clk, |
109 | --- a/target/arm/translate.c | 159 | + ZYNQ_COMPUTE_CLK(s, uart_mux, R_UART_CLK_CTRL, CLKACT0)); |
110 | +++ b/target/arm/translate.c | 160 | + clock_set(s->uart1_ref_clk, |
111 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn) | 161 | + ZYNQ_COMPUTE_CLK(s, uart_mux, R_UART_CLK_CTRL, CLKACT1)); |
112 | int size; | 162 | +} |
113 | int reg; | 163 | + |
114 | int load; | 164 | +/** |
115 | - int vec_size; | 165 | + * Propagate the outputs clocks. |
116 | TCGv_i32 addr; | 166 | + * zynq_slcr_compute_clocks() should have been called before |
117 | TCGv_i32 tmp; | 167 | + * to configure them. |
118 | 168 | + */ | |
119 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn) | 169 | +static void zynq_slcr_propagate_clocks(ZynqSLCRState *s) |
120 | } else { | 170 | +{ |
121 | size = (insn >> 10) & 3; | 171 | + clock_propagate(s->uart0_ref_clk); |
122 | if (size == 3) { | 172 | + clock_propagate(s->uart1_ref_clk); |
123 | - /* Load single element to all lanes. */ | 173 | +} |
124 | - int a = (insn >> 4) & 1; | 174 | + |
125 | - if (!load) { | 175 | +static void zynq_slcr_ps_clk_callback(void *opaque) |
126 | - return 1; | 176 | +{ |
127 | - } | 177 | + ZynqSLCRState *s = (ZynqSLCRState *) opaque; |
128 | - size = (insn >> 6) & 3; | 178 | + zynq_slcr_compute_clocks(s); |
129 | - nregs = ((insn >> 8) & 3) + 1; | 179 | + zynq_slcr_propagate_clocks(s); |
130 | - | 180 | +} |
131 | - if (size == 3) { | 181 | + |
132 | - if (nregs != 4 || a == 0) { | 182 | +static void zynq_slcr_reset_init(Object *obj, ResetType type) |
133 | - return 1; | 183 | +{ |
134 | - } | 184 | + ZynqSLCRState *s = ZYNQ_SLCR(obj); |
135 | - /* For VLD4 size==3 a == 1 means 32 bits at 16 byte alignment */ | 185 | int i; |
136 | - size = 2; | 186 | |
137 | - } | 187 | DB_PRINT("RESET\n"); |
138 | - if (nregs == 1 && a == 1 && size == 0) { | 188 | @@ -XXX,XX +XXX,XX @@ static void zynq_slcr_reset(DeviceState *d) |
139 | - return 1; | 189 | s->regs[R_DDRIOB + 12] = 0x00000021; |
140 | - } | 190 | } |
141 | - if (nregs == 3 && a == 1) { | 191 | |
142 | - return 1; | 192 | +static void zynq_slcr_reset_hold(Object *obj) |
143 | - } | 193 | +{ |
144 | - addr = tcg_temp_new_i32(); | 194 | + ZynqSLCRState *s = ZYNQ_SLCR(obj); |
145 | - load_reg_var(s, addr, rn); | 195 | + |
146 | - | 196 | + /* will disable all output clocks */ |
147 | - /* VLD1 to all lanes: bit 5 indicates how many Dregs to write. | 197 | + zynq_slcr_compute_clocks(s); |
148 | - * VLD2/3/4 to all lanes: bit 5 indicates register stride. | 198 | + zynq_slcr_propagate_clocks(s); |
149 | - */ | 199 | +} |
150 | - stride = (insn & (1 << 5)) ? 2 : 1; | 200 | + |
151 | - vec_size = nregs == 1 ? stride * 8 : 8; | 201 | +static void zynq_slcr_reset_exit(Object *obj) |
152 | - | 202 | +{ |
153 | - tmp = tcg_temp_new_i32(); | 203 | + ZynqSLCRState *s = ZYNQ_SLCR(obj); |
154 | - for (reg = 0; reg < nregs; reg++) { | 204 | + |
155 | - gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), | 205 | + /* will compute output clocks according to ps_clk and registers */ |
156 | - s->be_data | size); | 206 | + zynq_slcr_compute_clocks(s); |
157 | - if ((rd & 1) && vec_size == 16) { | 207 | + zynq_slcr_propagate_clocks(s); |
158 | - /* We cannot write 16 bytes at once because the | 208 | +} |
159 | - * destination is unaligned. | 209 | |
160 | - */ | 210 | static bool zynq_slcr_check_offset(hwaddr offset, bool rnw) |
161 | - tcg_gen_gvec_dup_i32(size, neon_reg_offset(rd, 0), | 211 | { |
162 | - 8, 8, tmp); | 212 | @@ -XXX,XX +XXX,XX @@ static void zynq_slcr_write(void *opaque, hwaddr offset, |
163 | - tcg_gen_gvec_mov(0, neon_reg_offset(rd + 1, 0), | 213 | qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); |
164 | - neon_reg_offset(rd, 0), 8, 8); | 214 | } |
165 | - } else { | 215 | break; |
166 | - tcg_gen_gvec_dup_i32(size, neon_reg_offset(rd, 0), | 216 | + case R_IO_PLL_CTRL: |
167 | - vec_size, vec_size, tmp); | 217 | + case R_ARM_PLL_CTRL: |
168 | - } | 218 | + case R_DDR_PLL_CTRL: |
169 | - tcg_gen_addi_i32(addr, addr, 1 << size); | 219 | + case R_UART_CLK_CTRL: |
170 | - rd += stride; | 220 | + zynq_slcr_compute_clocks(s); |
171 | - } | 221 | + zynq_slcr_propagate_clocks(s); |
172 | - tcg_temp_free_i32(tmp); | 222 | + break; |
173 | - tcg_temp_free_i32(addr); | 223 | } |
174 | - stride = (1 << size) * nregs; | 224 | } |
175 | + /* Load single element to all lanes -- handled by decodetree */ | 225 | |
176 | + return 1; | 226 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps slcr_ops = { |
177 | } else { | 227 | .endianness = DEVICE_NATIVE_ENDIAN, |
178 | /* Single element. */ | 228 | }; |
179 | int idx = (insn >> 4) & 0xf; | 229 | |
230 | +static const ClockPortInitArray zynq_slcr_clocks = { | ||
231 | + QDEV_CLOCK_IN(ZynqSLCRState, ps_clk, zynq_slcr_ps_clk_callback), | ||
232 | + QDEV_CLOCK_OUT(ZynqSLCRState, uart0_ref_clk), | ||
233 | + QDEV_CLOCK_OUT(ZynqSLCRState, uart1_ref_clk), | ||
234 | + QDEV_CLOCK_END | ||
235 | +}; | ||
236 | + | ||
237 | static void zynq_slcr_init(Object *obj) | ||
238 | { | ||
239 | ZynqSLCRState *s = ZYNQ_SLCR(obj); | ||
240 | @@ -XXX,XX +XXX,XX @@ static void zynq_slcr_init(Object *obj) | ||
241 | memory_region_init_io(&s->iomem, obj, &slcr_ops, s, "slcr", | ||
242 | ZYNQ_SLCR_MMIO_SIZE); | ||
243 | sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem); | ||
244 | + | ||
245 | + qdev_init_clocks(DEVICE(obj), zynq_slcr_clocks); | ||
246 | } | ||
247 | |||
248 | static const VMStateDescription vmstate_zynq_slcr = { | ||
249 | .name = "zynq_slcr", | ||
250 | - .version_id = 2, | ||
251 | + .version_id = 3, | ||
252 | .minimum_version_id = 2, | ||
253 | .fields = (VMStateField[]) { | ||
254 | VMSTATE_UINT32_ARRAY(regs, ZynqSLCRState, ZYNQ_SLCR_NUM_REGS), | ||
255 | + VMSTATE_CLOCK_V(ps_clk, ZynqSLCRState, 3), | ||
256 | VMSTATE_END_OF_LIST() | ||
257 | } | ||
258 | }; | ||
259 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_zynq_slcr = { | ||
260 | static void zynq_slcr_class_init(ObjectClass *klass, void *data) | ||
261 | { | ||
262 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
263 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
264 | |||
265 | dc->vmsd = &vmstate_zynq_slcr; | ||
266 | - dc->reset = zynq_slcr_reset; | ||
267 | + rc->phases.enter = zynq_slcr_reset_init; | ||
268 | + rc->phases.hold = zynq_slcr_reset_hold; | ||
269 | + rc->phases.exit = zynq_slcr_reset_exit; | ||
270 | } | ||
271 | |||
272 | static const TypeInfo zynq_slcr_info = { | ||
180 | -- | 273 | -- |
181 | 2.20.1 | 274 | 2.20.1 |
182 | 275 | ||
183 | 276 | diff view generated by jsdifflib |
1 | Convert the Neon VMUL, VMLA, VMLS and VSHL insns in the | 1 | From: Damien Hedde <damien.hedde@greensocs.com> |
---|---|---|---|
2 | 3-reg-same grouping to decodetree. | 2 | |
3 | 3 | Switch the cadence uart to multi-phase reset and add the | |
4 | reference clock input. | ||
5 | |||
6 | The input clock frequency is added to the migration structure. | ||
7 | |||
8 | The reference clock controls the baudrate generation. If it disabled, | ||
9 | any input characters and events are ignored. | ||
10 | |||
11 | If this clock remains unconnected, the uart behaves as before | ||
12 | (it default to a 50MHz ref clock). | ||
13 | |||
14 | Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> | ||
15 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
16 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
17 | Message-id: 20200406135251.157596-8-damien.hedde@greensocs.com | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20200430181003.21682-20-peter.maydell@linaro.org | ||
7 | --- | 19 | --- |
8 | target/arm/neon-dp.decode | 9 +++++++ | 20 | include/hw/char/cadence_uart.h | 1 + |
9 | target/arm/translate-neon.inc.c | 44 +++++++++++++++++++++++++++++++++ | 21 | hw/char/cadence_uart.c | 73 +++++++++++++++++++++++++++++----- |
10 | target/arm/translate.c | 28 +++------------------ | 22 | hw/char/trace-events | 3 ++ |
11 | 3 files changed, 56 insertions(+), 25 deletions(-) | 23 | 3 files changed, 67 insertions(+), 10 deletions(-) |
12 | 24 | ||
13 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 25 | diff --git a/include/hw/char/cadence_uart.h b/include/hw/char/cadence_uart.h |
14 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/neon-dp.decode | 27 | --- a/include/hw/char/cadence_uart.h |
16 | +++ b/target/arm/neon-dp.decode | 28 | +++ b/include/hw/char/cadence_uart.h |
17 | @@ -XXX,XX +XXX,XX @@ VCGT_U_3s 1111 001 1 0 . .. .... .... 0011 . . . 0 .... @3same | 29 | @@ -XXX,XX +XXX,XX @@ typedef struct { |
18 | VCGE_S_3s 1111 001 0 0 . .. .... .... 0011 . . . 1 .... @3same | 30 | CharBackend chr; |
19 | VCGE_U_3s 1111 001 1 0 . .. .... .... 0011 . . . 1 .... @3same | 31 | qemu_irq irq; |
20 | 32 | QEMUTimer *fifo_trigger_handle; | |
21 | +VSHL_S_3s 1111 001 0 0 . .. .... .... 0100 . . . 0 .... @3same | 33 | + Clock *refclk; |
22 | +VSHL_U_3s 1111 001 1 0 . .. .... .... 0100 . . . 0 .... @3same | 34 | } CadenceUARTState; |
23 | + | 35 | |
24 | VMAX_S_3s 1111 001 0 0 . .. .... .... 0110 . . . 0 .... @3same | 36 | static inline DeviceState *cadence_uart_create(hwaddr addr, |
25 | VMAX_U_3s 1111 001 1 0 . .. .... .... 0110 . . . 0 .... @3same | 37 | diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c |
26 | VMIN_S_3s 1111 001 0 0 . .. .... .... 0110 . . . 1 .... @3same | ||
27 | @@ -XXX,XX +XXX,XX @@ VSUB_3s 1111 001 1 0 . .. .... .... 1000 . . . 0 .... @3same | ||
28 | |||
29 | VTST_3s 1111 001 0 0 . .. .... .... 1000 . . . 1 .... @3same | ||
30 | VCEQ_3s 1111 001 1 0 . .. .... .... 1000 . . . 1 .... @3same | ||
31 | + | ||
32 | +VMLA_3s 1111 001 0 0 . .. .... .... 1001 . . . 0 .... @3same | ||
33 | +VMLS_3s 1111 001 1 0 . .. .... .... 1001 . . . 0 .... @3same | ||
34 | + | ||
35 | +VMUL_3s 1111 001 0 0 . .. .... .... 1001 . . . 1 .... @3same | ||
36 | +VMUL_p_3s 1111 001 1 0 . .. .... .... 1001 . . . 1 .... @3same | ||
37 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | 38 | index XXXXXXX..XXXXXXX 100644 |
39 | --- a/target/arm/translate-neon.inc.c | 39 | --- a/hw/char/cadence_uart.c |
40 | +++ b/target/arm/translate-neon.inc.c | 40 | +++ b/hw/char/cadence_uart.c |
41 | @@ -XXX,XX +XXX,XX @@ DO_3SAME_NO_SZ_3(VMAX_S, tcg_gen_gvec_smax) | 41 | @@ -XXX,XX +XXX,XX @@ |
42 | DO_3SAME_NO_SZ_3(VMAX_U, tcg_gen_gvec_umax) | 42 | #include "qemu/module.h" |
43 | DO_3SAME_NO_SZ_3(VMIN_S, tcg_gen_gvec_smin) | 43 | #include "hw/char/cadence_uart.h" |
44 | DO_3SAME_NO_SZ_3(VMIN_U, tcg_gen_gvec_umin) | 44 | #include "hw/irq.h" |
45 | +DO_3SAME_NO_SZ_3(VMUL, tcg_gen_gvec_mul) | 45 | +#include "hw/qdev-clock.h" |
46 | 46 | +#include "trace.h" | |
47 | #define DO_3SAME_CMP(INSN, COND) \ | 47 | |
48 | static void gen_##INSN##_3s(unsigned vece, uint32_t rd_ofs, \ | 48 | #ifdef CADENCE_UART_ERR_DEBUG |
49 | @@ -XXX,XX +XXX,XX @@ DO_3SAME_GVEC4(VQADD_S, sqadd_op) | 49 | #define DB_PRINT(...) do { \ |
50 | DO_3SAME_GVEC4(VQADD_U, uqadd_op) | 50 | @@ -XXX,XX +XXX,XX @@ |
51 | DO_3SAME_GVEC4(VQSUB_S, sqsub_op) | 51 | #define LOCAL_LOOPBACK (0x2 << UART_MR_CHMODE_SH) |
52 | DO_3SAME_GVEC4(VQSUB_U, uqsub_op) | 52 | #define REMOTE_LOOPBACK (0x3 << UART_MR_CHMODE_SH) |
53 | + | 53 | |
54 | +static void gen_VMUL_p_3s(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, | 54 | -#define UART_INPUT_CLK 50000000 |
55 | + uint32_t rm_ofs, uint32_t oprsz, uint32_t maxsz) | 55 | +#define UART_DEFAULT_REF_CLK (50 * 1000 * 1000) |
56 | |||
57 | #define R_CR (0x00/4) | ||
58 | #define R_MR (0x04/4) | ||
59 | @@ -XXX,XX +XXX,XX @@ static void uart_send_breaks(CadenceUARTState *s) | ||
60 | static void uart_parameters_setup(CadenceUARTState *s) | ||
61 | { | ||
62 | QEMUSerialSetParams ssp; | ||
63 | - unsigned int baud_rate, packet_size; | ||
64 | + unsigned int baud_rate, packet_size, input_clk; | ||
65 | + input_clk = clock_get_hz(s->refclk); | ||
66 | |||
67 | - baud_rate = (s->r[R_MR] & UART_MR_CLKS) ? | ||
68 | - UART_INPUT_CLK / 8 : UART_INPUT_CLK; | ||
69 | + baud_rate = (s->r[R_MR] & UART_MR_CLKS) ? input_clk / 8 : input_clk; | ||
70 | + baud_rate /= (s->r[R_BRGR] * (s->r[R_BDIV] + 1)); | ||
71 | + trace_cadence_uart_baudrate(baud_rate); | ||
72 | + | ||
73 | + ssp.speed = baud_rate; | ||
74 | |||
75 | - ssp.speed = baud_rate / (s->r[R_BRGR] * (s->r[R_BDIV] + 1)); | ||
76 | packet_size = 1; | ||
77 | |||
78 | switch (s->r[R_MR] & UART_MR_PAR) { | ||
79 | @@ -XXX,XX +XXX,XX @@ static void uart_parameters_setup(CadenceUARTState *s) | ||
80 | } | ||
81 | |||
82 | packet_size += ssp.data_bits + ssp.stop_bits; | ||
83 | + if (ssp.speed == 0) { | ||
84 | + /* | ||
85 | + * Avoid division-by-zero below. | ||
86 | + * TODO: find something better | ||
87 | + */ | ||
88 | + ssp.speed = 1; | ||
89 | + } | ||
90 | s->char_tx_time = (NANOSECONDS_PER_SECOND / ssp.speed) * packet_size; | ||
91 | qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_SERIAL_SET_PARAMS, &ssp); | ||
92 | } | ||
93 | @@ -XXX,XX +XXX,XX @@ static void uart_receive(void *opaque, const uint8_t *buf, int size) | ||
94 | CadenceUARTState *s = opaque; | ||
95 | uint32_t ch_mode = s->r[R_MR] & UART_MR_CHMODE; | ||
96 | |||
97 | + /* ignore characters when unclocked or in reset */ | ||
98 | + if (!clock_is_enabled(s->refclk) || device_is_in_reset(DEVICE(s))) { | ||
99 | + return; | ||
100 | + } | ||
101 | + | ||
102 | if (ch_mode == NORMAL_MODE || ch_mode == ECHO_MODE) { | ||
103 | uart_write_rx_fifo(opaque, buf, size); | ||
104 | } | ||
105 | @@ -XXX,XX +XXX,XX @@ static void uart_event(void *opaque, QEMUChrEvent event) | ||
106 | CadenceUARTState *s = opaque; | ||
107 | uint8_t buf = '\0'; | ||
108 | |||
109 | + /* ignore characters when unclocked or in reset */ | ||
110 | + if (!clock_is_enabled(s->refclk) || device_is_in_reset(DEVICE(s))) { | ||
111 | + return; | ||
112 | + } | ||
113 | + | ||
114 | if (event == CHR_EVENT_BREAK) { | ||
115 | uart_write_rx_fifo(opaque, &buf, 1); | ||
116 | } | ||
117 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps uart_ops = { | ||
118 | .endianness = DEVICE_NATIVE_ENDIAN, | ||
119 | }; | ||
120 | |||
121 | -static void cadence_uart_reset(DeviceState *dev) | ||
122 | +static void cadence_uart_reset_init(Object *obj, ResetType type) | ||
123 | { | ||
124 | - CadenceUARTState *s = CADENCE_UART(dev); | ||
125 | + CadenceUARTState *s = CADENCE_UART(obj); | ||
126 | |||
127 | s->r[R_CR] = 0x00000128; | ||
128 | s->r[R_IMR] = 0; | ||
129 | @@ -XXX,XX +XXX,XX @@ static void cadence_uart_reset(DeviceState *dev) | ||
130 | s->r[R_BRGR] = 0x0000028B; | ||
131 | s->r[R_BDIV] = 0x0000000F; | ||
132 | s->r[R_TTRIG] = 0x00000020; | ||
133 | +} | ||
134 | + | ||
135 | +static void cadence_uart_reset_hold(Object *obj) | ||
56 | +{ | 136 | +{ |
57 | + tcg_gen_gvec_3_ool(rd_ofs, rn_ofs, rm_ofs, oprsz, maxsz, | 137 | + CadenceUARTState *s = CADENCE_UART(obj); |
58 | + 0, gen_helper_gvec_pmul_b); | 138 | |
139 | uart_rx_reset(s); | ||
140 | uart_tx_reset(s); | ||
141 | @@ -XXX,XX +XXX,XX @@ static void cadence_uart_realize(DeviceState *dev, Error **errp) | ||
142 | uart_event, NULL, s, NULL, true); | ||
143 | } | ||
144 | |||
145 | +static void cadence_uart_refclk_update(void *opaque) | ||
146 | +{ | ||
147 | + CadenceUARTState *s = opaque; | ||
148 | + | ||
149 | + /* recompute uart's speed on clock change */ | ||
150 | + uart_parameters_setup(s); | ||
59 | +} | 151 | +} |
60 | + | 152 | + |
61 | +static bool trans_VMUL_p_3s(DisasContext *s, arg_3same *a) | 153 | static void cadence_uart_init(Object *obj) |
154 | { | ||
155 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
156 | @@ -XXX,XX +XXX,XX @@ static void cadence_uart_init(Object *obj) | ||
157 | sysbus_init_mmio(sbd, &s->iomem); | ||
158 | sysbus_init_irq(sbd, &s->irq); | ||
159 | |||
160 | + s->refclk = qdev_init_clock_in(DEVICE(obj), "refclk", | ||
161 | + cadence_uart_refclk_update, s); | ||
162 | + /* initialize the frequency in case the clock remains unconnected */ | ||
163 | + clock_set_hz(s->refclk, UART_DEFAULT_REF_CLK); | ||
164 | + | ||
165 | s->char_tx_time = (NANOSECONDS_PER_SECOND / 9600) * 10; | ||
166 | } | ||
167 | |||
168 | +static int cadence_uart_pre_load(void *opaque) | ||
62 | +{ | 169 | +{ |
63 | + if (a->size != 0) { | 170 | + CadenceUARTState *s = opaque; |
64 | + return false; | 171 | + |
65 | + } | 172 | + /* the frequency will be overriden if the refclk field is present */ |
66 | + return do_3same(s, a, gen_VMUL_p_3s); | 173 | + clock_set_hz(s->refclk, UART_DEFAULT_REF_CLK); |
174 | + return 0; | ||
67 | +} | 175 | +} |
68 | + | 176 | + |
69 | +#define DO_3SAME_GVEC3_NO_SZ_3(INSN, OPARRAY) \ | 177 | static int cadence_uart_post_load(void *opaque, int version_id) |
70 | + static void gen_##INSN##_3s(unsigned vece, uint32_t rd_ofs, \ | 178 | { |
71 | + uint32_t rn_ofs, uint32_t rm_ofs, \ | 179 | CadenceUARTState *s = opaque; |
72 | + uint32_t oprsz, uint32_t maxsz) \ | 180 | @@ -XXX,XX +XXX,XX @@ static int cadence_uart_post_load(void *opaque, int version_id) |
73 | + { \ | 181 | |
74 | + tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, \ | 182 | static const VMStateDescription vmstate_cadence_uart = { |
75 | + oprsz, maxsz, &OPARRAY[vece]); \ | 183 | .name = "cadence_uart", |
76 | + } \ | 184 | - .version_id = 2, |
77 | + DO_3SAME_NO_SZ_3(INSN, gen_##INSN##_3s) | 185 | + .version_id = 3, |
78 | + | 186 | .minimum_version_id = 2, |
79 | + | 187 | + .pre_load = cadence_uart_pre_load, |
80 | +DO_3SAME_GVEC3_NO_SZ_3(VMLA, mla_op) | 188 | .post_load = cadence_uart_post_load, |
81 | +DO_3SAME_GVEC3_NO_SZ_3(VMLS, mls_op) | 189 | .fields = (VMStateField[]) { |
82 | + | 190 | VMSTATE_UINT32_ARRAY(r, CadenceUARTState, CADENCE_UART_R_MAX), |
83 | +#define DO_3SAME_GVEC3_SHIFT(INSN, OPARRAY) \ | 191 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_cadence_uart = { |
84 | + static void gen_##INSN##_3s(unsigned vece, uint32_t rd_ofs, \ | 192 | VMSTATE_UINT32(tx_count, CadenceUARTState), |
85 | + uint32_t rn_ofs, uint32_t rm_ofs, \ | 193 | VMSTATE_UINT32(rx_wpos, CadenceUARTState), |
86 | + uint32_t oprsz, uint32_t maxsz) \ | 194 | VMSTATE_TIMER_PTR(fifo_trigger_handle, CadenceUARTState), |
87 | + { \ | 195 | + VMSTATE_CLOCK_V(refclk, CadenceUARTState, 3), |
88 | + /* Note the operation is vshl vd,vm,vn */ \ | 196 | VMSTATE_END_OF_LIST() |
89 | + tcg_gen_gvec_3(rd_ofs, rm_ofs, rn_ofs, \ | 197 | - } |
90 | + oprsz, maxsz, &OPARRAY[vece]); \ | 198 | + }, |
91 | + } \ | 199 | }; |
92 | + DO_3SAME(INSN, gen_##INSN##_3s) | 200 | |
93 | + | 201 | static Property cadence_uart_properties[] = { |
94 | +DO_3SAME_GVEC3_SHIFT(VSHL_S, sshl_op) | 202 | @@ -XXX,XX +XXX,XX @@ static Property cadence_uart_properties[] = { |
95 | +DO_3SAME_GVEC3_SHIFT(VSHL_U, ushl_op) | 203 | static void cadence_uart_class_init(ObjectClass *klass, void *data) |
96 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 204 | { |
205 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
206 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
207 | |||
208 | dc->realize = cadence_uart_realize; | ||
209 | dc->vmsd = &vmstate_cadence_uart; | ||
210 | - dc->reset = cadence_uart_reset; | ||
211 | + rc->phases.enter = cadence_uart_reset_init; | ||
212 | + rc->phases.hold = cadence_uart_reset_hold; | ||
213 | device_class_set_props(dc, cadence_uart_properties); | ||
214 | } | ||
215 | |||
216 | diff --git a/hw/char/trace-events b/hw/char/trace-events | ||
97 | index XXXXXXX..XXXXXXX 100644 | 217 | index XXXXXXX..XXXXXXX 100644 |
98 | --- a/target/arm/translate.c | 218 | --- a/hw/char/trace-events |
99 | +++ b/target/arm/translate.c | 219 | +++ b/hw/char/trace-events |
100 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 220 | @@ -XXX,XX +XXX,XX @@ exynos_uart_wo_read(uint32_t channel, const char *name, uint32_t reg) "UART%d: T |
101 | } | 221 | exynos_uart_rxsize(uint32_t channel, uint32_t size) "UART%d: Rx FIFO size: %d" |
102 | return 1; | 222 | exynos_uart_channel_error(uint32_t channel) "Wrong UART channel number: %d" |
103 | 223 | exynos_uart_rx_timeout(uint32_t channel, uint32_t stat, uint32_t intsp) "UART%d: Rx timeout stat=0x%x intsp=0x%x" | |
104 | - case NEON_3R_VMUL: /* VMUL */ | 224 | + |
105 | - if (u) { | 225 | +# hw/char/cadence_uart.c |
106 | - /* Polynomial case allows only P8. */ | 226 | +cadence_uart_baudrate(unsigned baudrate) "baudrate %u" |
107 | - if (size != 0) { | ||
108 | - return 1; | ||
109 | - } | ||
110 | - tcg_gen_gvec_3_ool(rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size, | ||
111 | - 0, gen_helper_gvec_pmul_b); | ||
112 | - } else { | ||
113 | - tcg_gen_gvec_mul(size, rd_ofs, rn_ofs, rm_ofs, | ||
114 | - vec_size, vec_size); | ||
115 | - } | ||
116 | - return 0; | ||
117 | - | ||
118 | - case NEON_3R_VML: /* VMLA, VMLS */ | ||
119 | - tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size, | ||
120 | - u ? &mls_op[size] : &mla_op[size]); | ||
121 | - return 0; | ||
122 | - | ||
123 | - case NEON_3R_VSHL: | ||
124 | - /* Note the operation is vshl vd,vm,vn */ | ||
125 | - tcg_gen_gvec_3(rd_ofs, rm_ofs, rn_ofs, vec_size, vec_size, | ||
126 | - u ? &ushl_op[size] : &sshl_op[size]); | ||
127 | - return 0; | ||
128 | - | ||
129 | case NEON_3R_VADD_VSUB: | ||
130 | case NEON_3R_LOGIC: | ||
131 | case NEON_3R_VMAX: | ||
132 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
133 | case NEON_3R_VCGE: | ||
134 | case NEON_3R_VQADD: | ||
135 | case NEON_3R_VQSUB: | ||
136 | + case NEON_3R_VMUL: | ||
137 | + case NEON_3R_VML: | ||
138 | + case NEON_3R_VSHL: | ||
139 | /* Already handled by decodetree */ | ||
140 | return 1; | ||
141 | } | ||
142 | -- | 227 | -- |
143 | 2.20.1 | 228 | 2.20.1 |
144 | 229 | ||
145 | 230 | diff view generated by jsdifflib |
1 | We define ARMMMUIdx_Stage2 as being an MMU index which uses a QEMU | 1 | From: Damien Hedde <damien.hedde@greensocs.com> |
---|---|---|---|
2 | TLB. However we never actually use the TLB -- all stage 2 lookups | ||
3 | are done by direct calls to get_phys_addr_lpae() followed by a | ||
4 | physical address load via address_space_ld*(). | ||
5 | 2 | ||
6 | Remove Stage2 from the list of ARM MMU indexes which correspond to | 3 | Add the connection between the slcr's output clocks and the uarts inputs. |
7 | real core MMU indexes, and instead put it in the set of "NOTLB" ARM | ||
8 | MMU indexes. | ||
9 | 4 | ||
10 | This allows us to drop NB_MMU_MODES to 11. It also means we can | 5 | Also add the main board clock 'ps_clk', which is hard-coded to 33.33MHz |
11 | safely add support for the ARMv8.3-TTS2UXN extension, which adds | 6 | (the default frequency). This clock is used to feed the slcr's input |
12 | permission bits to the stage 2 descriptors which define execute | 7 | clock. |
13 | permission separatel for EL0 and EL1; supporting that while keeping | ||
14 | Stage2 in a QEMU TLB would require us to use separate TLBs for | ||
15 | "Stage2 for an EL0 access" and "Stage2 for an EL1 access", which is a | ||
16 | lot of extra complication given we aren't even using the QEMU TLB. | ||
17 | 8 | ||
18 | In the process of updating the comment on our MMU index use, | 9 | Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> |
19 | fix a couple of other minor errors: | 10 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
20 | * NS EL2 EL2&0 was missing from the list in the comment | 11 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> |
21 | * some text hadn't been updated from when we bumped NB_MMU_MODES | 12 | Message-id: 20200406135251.157596-9-damien.hedde@greensocs.com |
22 | above 8 | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | ||
15 | hw/arm/xilinx_zynq.c | 57 +++++++++++++++++++++++++++++++++++++------- | ||
16 | 1 file changed, 49 insertions(+), 8 deletions(-) | ||
23 | 17 | ||
24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c |
25 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
26 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
27 | Message-id: 20200330210400.11724-2-peter.maydell@linaro.org | ||
28 | --- | ||
29 | target/arm/cpu-param.h | 2 +- | ||
30 | target/arm/cpu.h | 21 +++++--- | ||
31 | target/arm/helper.c | 112 ++++------------------------------------- | ||
32 | 3 files changed, 27 insertions(+), 108 deletions(-) | ||
33 | |||
34 | diff --git a/target/arm/cpu-param.h b/target/arm/cpu-param.h | ||
35 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
36 | --- a/target/arm/cpu-param.h | 20 | --- a/hw/arm/xilinx_zynq.c |
37 | +++ b/target/arm/cpu-param.h | 21 | +++ b/hw/arm/xilinx_zynq.c |
38 | @@ -XXX,XX +XXX,XX @@ | 22 | @@ -XXX,XX +XXX,XX @@ |
39 | # define TARGET_PAGE_BITS_MIN 10 | 23 | #include "hw/char/cadence_uart.h" |
40 | #endif | 24 | #include "hw/net/cadence_gem.h" |
41 | 25 | #include "hw/cpu/a9mpcore.h" | |
42 | -#define NB_MMU_MODES 12 | 26 | +#include "hw/qdev-clock.h" |
43 | +#define NB_MMU_MODES 11 | 27 | +#include "sysemu/reset.h" |
44 | 28 | + | |
45 | #endif | 29 | +#define TYPE_ZYNQ_MACHINE MACHINE_TYPE_NAME("xilinx-zynq-a9") |
46 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 30 | +#define ZYNQ_MACHINE(obj) \ |
47 | index XXXXXXX..XXXXXXX 100644 | 31 | + OBJECT_CHECK(ZynqMachineState, (obj), TYPE_ZYNQ_MACHINE) |
48 | --- a/target/arm/cpu.h | 32 | + |
49 | +++ b/target/arm/cpu.h | 33 | +/* board base frequency: 33.333333 MHz */ |
50 | @@ -XXX,XX +XXX,XX @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync); | 34 | +#define PS_CLK_FREQUENCY (100 * 1000 * 1000 / 3) |
51 | * handling via the TLB. The only way to do a stage 1 translation without | 35 | |
52 | * the immediate stage 2 translation is via the ATS or AT system insns, | 36 | #define NUM_SPI_FLASHES 4 |
53 | * which can be slow-pathed and always do a page table walk. | 37 | #define NUM_QSPI_FLASHES 2 |
54 | + * The only use of stage 2 translations is either as part of an s1+2 | 38 | @@ -XXX,XX +XXX,XX @@ static const int dma_irqs[8] = { |
55 | + * lookup or when loading the descriptors during a stage 1 page table walk, | 39 | 0xe3401000 + ARMV7_IMM16(extract32((val), 16, 16)), /* movt r1 ... */ \ |
56 | + * and in both those cases we don't use the TLB. | 40 | 0xe5801000 + (addr) |
57 | * 4. we can also safely fold together the "32 bit EL3" and "64 bit EL3" | 41 | |
58 | * translation regimes, because they map reasonably well to each other | 42 | +typedef struct ZynqMachineState { |
59 | * and they can't both be active at the same time. | 43 | + MachineState parent; |
60 | @@ -XXX,XX +XXX,XX @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync); | 44 | + Clock *ps_clk; |
61 | * NS EL1 EL1&0 stage 1+2 (aka NS PL1) | 45 | +} ZynqMachineState; |
62 | * NS EL1 EL1&0 stage 1+2 +PAN | 46 | + |
63 | * NS EL0 EL2&0 | 47 | static void zynq_write_board_setup(ARMCPU *cpu, |
64 | + * NS EL2 EL2&0 | 48 | const struct arm_boot_info *info) |
65 | * NS EL2 EL2&0 +PAN | 49 | { |
66 | * NS EL2 (aka NS PL2) | 50 | @@ -XXX,XX +XXX,XX @@ static inline void zynq_init_spi_flashes(uint32_t base_addr, qemu_irq irq, |
67 | * S EL0 EL1&0 (aka S PL0) | 51 | |
68 | * S EL1 EL1&0 (not used if EL3 is 32 bit) | 52 | static void zynq_init(MachineState *machine) |
69 | * S EL1 EL1&0 +PAN | 53 | { |
70 | * S EL3 (aka S PL1) | 54 | + ZynqMachineState *zynq_machine = ZYNQ_MACHINE(machine); |
71 | - * NS EL1&0 stage 2 | 55 | ARMCPU *cpu; |
72 | * | 56 | MemoryRegion *address_space_mem = get_system_memory(); |
73 | - * for a total of 12 different mmu_idx. | 57 | MemoryRegion *ocm_ram = g_new(MemoryRegion, 1); |
74 | + * for a total of 11 different mmu_idx. | 58 | - DeviceState *dev; |
75 | * | 59 | + DeviceState *dev, *slcr; |
76 | * R profile CPUs have an MPU, but can use the same set of MMU indexes | 60 | SysBusDevice *busdev; |
77 | * as A profile. They only need to distinguish NS EL0 and NS EL1 (and | 61 | qemu_irq pic[64]; |
78 | @@ -XXX,XX +XXX,XX @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync); | 62 | int n; |
79 | * are not quite the same -- different CPU types (most notably M profile | 63 | @@ -XXX,XX +XXX,XX @@ static void zynq_init(MachineState *machine) |
80 | * vs A/R profile) would like to use MMU indexes with different semantics, | 64 | 1, 0x0066, 0x0022, 0x0000, 0x0000, 0x0555, 0x2aa, |
81 | * but since we don't ever need to use all of those in a single CPU we | 65 | 0); |
82 | - * can avoid setting NB_MMU_MODES to more than 8. The lower bits of | 66 | |
83 | + * can avoid having to set NB_MMU_MODES to "total number of A profile MMU | 67 | - dev = qdev_create(NULL, "xilinx,zynq_slcr"); |
84 | + * modes + total number of M profile MMU modes". The lower bits of | 68 | - qdev_init_nofail(dev); |
85 | * ARMMMUIdx are the core TLB mmu index, and the higher bits are always | 69 | - sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xF8000000); |
86 | * the same for any particular CPU. | 70 | + /* Create slcr, keep a pointer to connect clocks */ |
87 | * Variables of type ARMMUIdx are always full values, and the core | 71 | + slcr = qdev_create(NULL, "xilinx,zynq_slcr"); |
88 | @@ -XXX,XX +XXX,XX @@ typedef enum ARMMMUIdx { | 72 | + qdev_init_nofail(slcr); |
89 | ARMMMUIdx_SE10_1_PAN = 9 | ARM_MMU_IDX_A, | 73 | + sysbus_mmio_map(SYS_BUS_DEVICE(slcr), 0, 0xF8000000); |
90 | ARMMMUIdx_SE3 = 10 | ARM_MMU_IDX_A, | 74 | + |
91 | 75 | + /* Create the main clock source, and feed slcr with it */ | |
92 | - ARMMMUIdx_Stage2 = 11 | ARM_MMU_IDX_A, | 76 | + zynq_machine->ps_clk = CLOCK(object_new(TYPE_CLOCK)); |
93 | - | 77 | + object_property_add_child(OBJECT(zynq_machine), "ps_clk", |
94 | /* | 78 | + OBJECT(zynq_machine->ps_clk), &error_abort); |
95 | * These are not allocated TLBs and are used only for AT system | 79 | + object_unref(OBJECT(zynq_machine->ps_clk)); |
96 | * instructions or for the first stage of an S12 page table walk. | 80 | + clock_set_hz(zynq_machine->ps_clk, PS_CLK_FREQUENCY); |
97 | @@ -XXX,XX +XXX,XX @@ typedef enum ARMMMUIdx { | 81 | + qdev_connect_clock_in(slcr, "ps_clk", zynq_machine->ps_clk); |
98 | ARMMMUIdx_Stage1_E0 = 0 | ARM_MMU_IDX_NOTLB, | 82 | |
99 | ARMMMUIdx_Stage1_E1 = 1 | ARM_MMU_IDX_NOTLB, | 83 | dev = qdev_create(NULL, TYPE_A9MPCORE_PRIV); |
100 | ARMMMUIdx_Stage1_E1_PAN = 2 | ARM_MMU_IDX_NOTLB, | 84 | qdev_prop_set_uint32(dev, "num-cpu", 1); |
101 | + /* | 85 | @@ -XXX,XX +XXX,XX @@ static void zynq_init(MachineState *machine) |
102 | + * Not allocated a TLB: used only for second stage of an S12 page | 86 | sysbus_create_simple(TYPE_CHIPIDEA, 0xE0002000, pic[53 - IRQ_OFFSET]); |
103 | + * table walk, or for descriptor loads during first stage of an S1 | 87 | sysbus_create_simple(TYPE_CHIPIDEA, 0xE0003000, pic[76 - IRQ_OFFSET]); |
104 | + * page table walk. Note that if we ever want to have a TLB for this | 88 | |
105 | + * then various TLB flush insns which currently are no-ops or flush | 89 | - cadence_uart_create(0xE0000000, pic[59 - IRQ_OFFSET], serial_hd(0)); |
106 | + * only stage 1 MMU indexes will need to change to flush stage 2. | 90 | - cadence_uart_create(0xE0001000, pic[82 - IRQ_OFFSET], serial_hd(1)); |
107 | + */ | 91 | + dev = cadence_uart_create(0xE0000000, pic[59 - IRQ_OFFSET], serial_hd(0)); |
108 | + ARMMMUIdx_Stage2 = 3 | ARM_MMU_IDX_NOTLB, | 92 | + qdev_connect_clock_in(dev, "refclk", |
109 | 93 | + qdev_get_clock_out(slcr, "uart0_ref_clk")); | |
110 | /* | 94 | + dev = cadence_uart_create(0xE0001000, pic[82 - IRQ_OFFSET], serial_hd(1)); |
111 | * M-profile. | 95 | + qdev_connect_clock_in(dev, "refclk", |
112 | @@ -XXX,XX +XXX,XX @@ typedef enum ARMMMUIdxBit { | 96 | + qdev_get_clock_out(slcr, "uart1_ref_clk")); |
113 | TO_CORE_BIT(SE10_1), | 97 | |
114 | TO_CORE_BIT(SE10_1_PAN), | 98 | sysbus_create_varargs("cadence_ttc", 0xF8001000, |
115 | TO_CORE_BIT(SE3), | 99 | pic[42-IRQ_OFFSET], pic[43-IRQ_OFFSET], pic[44-IRQ_OFFSET], NULL); |
116 | - TO_CORE_BIT(Stage2), | 100 | @@ -XXX,XX +XXX,XX @@ static void zynq_init(MachineState *machine) |
117 | 101 | arm_load_kernel(ARM_CPU(first_cpu), machine, &zynq_binfo); | |
118 | TO_CORE_BIT(MUser), | ||
119 | TO_CORE_BIT(MPriv), | ||
120 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
121 | index XXXXXXX..XXXXXXX 100644 | ||
122 | --- a/target/arm/helper.c | ||
123 | +++ b/target/arm/helper.c | ||
124 | @@ -XXX,XX +XXX,XX @@ static void tlbiall_nsnh_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
125 | tlb_flush_by_mmuidx(cs, | ||
126 | ARMMMUIdxBit_E10_1 | | ||
127 | ARMMMUIdxBit_E10_1_PAN | | ||
128 | - ARMMMUIdxBit_E10_0 | | ||
129 | - ARMMMUIdxBit_Stage2); | ||
130 | + ARMMMUIdxBit_E10_0); | ||
131 | } | 102 | } |
132 | 103 | ||
133 | static void tlbiall_nsnh_is_write(CPUARMState *env, const ARMCPRegInfo *ri, | 104 | -static void zynq_machine_init(MachineClass *mc) |
134 | @@ -XXX,XX +XXX,XX @@ static void tlbiall_nsnh_is_write(CPUARMState *env, const ARMCPRegInfo *ri, | 105 | +static void zynq_machine_class_init(ObjectClass *oc, void *data) |
135 | tlb_flush_by_mmuidx_all_cpus_synced(cs, | 106 | { |
136 | ARMMMUIdxBit_E10_1 | | 107 | + MachineClass *mc = MACHINE_CLASS(oc); |
137 | ARMMMUIdxBit_E10_1_PAN | | 108 | mc->desc = "Xilinx Zynq Platform Baseboard for Cortex-A9"; |
138 | - ARMMMUIdxBit_E10_0 | | 109 | mc->init = zynq_init; |
139 | - ARMMMUIdxBit_Stage2); | 110 | mc->max_cpus = 1; |
140 | + ARMMMUIdxBit_E10_0); | 111 | @@ -XXX,XX +XXX,XX @@ static void zynq_machine_init(MachineClass *mc) |
112 | mc->default_ram_id = "zynq.ext_ram"; | ||
141 | } | 113 | } |
142 | 114 | ||
143 | -static void tlbiipas2_write(CPUARMState *env, const ARMCPRegInfo *ri, | 115 | -DEFINE_MACHINE("xilinx-zynq-a9", zynq_machine_init) |
144 | - uint64_t value) | 116 | +static const TypeInfo zynq_machine_type = { |
145 | -{ | 117 | + .name = TYPE_ZYNQ_MACHINE, |
146 | - /* Invalidate by IPA. This has to invalidate any structures that | 118 | + .parent = TYPE_MACHINE, |
147 | - * contain only stage 2 translation information, but does not need | 119 | + .class_init = zynq_machine_class_init, |
148 | - * to apply to structures that contain combined stage 1 and stage 2 | 120 | + .instance_size = sizeof(ZynqMachineState), |
149 | - * translation information. | 121 | +}; |
150 | - * This must NOP if EL2 isn't implemented or SCR_EL3.NS is zero. | 122 | + |
151 | - */ | 123 | +static void zynq_machine_register_types(void) |
152 | - CPUState *cs = env_cpu(env); | 124 | +{ |
153 | - uint64_t pageaddr; | 125 | + type_register_static(&zynq_machine_type); |
154 | - | 126 | +} |
155 | - if (!arm_feature(env, ARM_FEATURE_EL2) || !(env->cp15.scr_el3 & SCR_NS)) { | 127 | + |
156 | - return; | 128 | +type_init(zynq_machine_register_types) |
157 | - } | ||
158 | - | ||
159 | - pageaddr = sextract64(value << 12, 0, 40); | ||
160 | - | ||
161 | - tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_Stage2); | ||
162 | -} | ||
163 | - | ||
164 | -static void tlbiipas2_is_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
165 | - uint64_t value) | ||
166 | -{ | ||
167 | - CPUState *cs = env_cpu(env); | ||
168 | - uint64_t pageaddr; | ||
169 | - | ||
170 | - if (!arm_feature(env, ARM_FEATURE_EL2) || !(env->cp15.scr_el3 & SCR_NS)) { | ||
171 | - return; | ||
172 | - } | ||
173 | - | ||
174 | - pageaddr = sextract64(value << 12, 0, 40); | ||
175 | - | ||
176 | - tlb_flush_page_by_mmuidx_all_cpus_synced(cs, pageaddr, | ||
177 | - ARMMMUIdxBit_Stage2); | ||
178 | -} | ||
179 | |||
180 | static void tlbiall_hyp_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
181 | uint64_t value) | ||
182 | @@ -XXX,XX +XXX,XX @@ static void vttbr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
183 | tlb_flush_by_mmuidx(cs, | ||
184 | ARMMMUIdxBit_E10_1 | | ||
185 | ARMMMUIdxBit_E10_1_PAN | | ||
186 | - ARMMMUIdxBit_E10_0 | | ||
187 | - ARMMMUIdxBit_Stage2); | ||
188 | + ARMMMUIdxBit_E10_0); | ||
189 | raw_write(env, ri, value); | ||
190 | } | ||
191 | } | ||
192 | @@ -XXX,XX +XXX,XX @@ static int alle1_tlbmask(CPUARMState *env) | ||
193 | return ARMMMUIdxBit_SE10_1 | | ||
194 | ARMMMUIdxBit_SE10_1_PAN | | ||
195 | ARMMMUIdxBit_SE10_0; | ||
196 | - } else if (arm_feature(env, ARM_FEATURE_EL2)) { | ||
197 | - return ARMMMUIdxBit_E10_1 | | ||
198 | - ARMMMUIdxBit_E10_1_PAN | | ||
199 | - ARMMMUIdxBit_E10_0 | | ||
200 | - ARMMMUIdxBit_Stage2; | ||
201 | } else { | ||
202 | return ARMMMUIdxBit_E10_1 | | ||
203 | ARMMMUIdxBit_E10_1_PAN | | ||
204 | @@ -XXX,XX +XXX,XX @@ static void tlbi_aa64_vae3is_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
205 | ARMMMUIdxBit_SE3); | ||
206 | } | ||
207 | |||
208 | -static void tlbi_aa64_ipas2e1_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
209 | - uint64_t value) | ||
210 | -{ | ||
211 | - /* Invalidate by IPA. This has to invalidate any structures that | ||
212 | - * contain only stage 2 translation information, but does not need | ||
213 | - * to apply to structures that contain combined stage 1 and stage 2 | ||
214 | - * translation information. | ||
215 | - * This must NOP if EL2 isn't implemented or SCR_EL3.NS is zero. | ||
216 | - */ | ||
217 | - ARMCPU *cpu = env_archcpu(env); | ||
218 | - CPUState *cs = CPU(cpu); | ||
219 | - uint64_t pageaddr; | ||
220 | - | ||
221 | - if (!arm_feature(env, ARM_FEATURE_EL2) || !(env->cp15.scr_el3 & SCR_NS)) { | ||
222 | - return; | ||
223 | - } | ||
224 | - | ||
225 | - pageaddr = sextract64(value << 12, 0, 48); | ||
226 | - | ||
227 | - tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_Stage2); | ||
228 | -} | ||
229 | - | ||
230 | -static void tlbi_aa64_ipas2e1is_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
231 | - uint64_t value) | ||
232 | -{ | ||
233 | - CPUState *cs = env_cpu(env); | ||
234 | - uint64_t pageaddr; | ||
235 | - | ||
236 | - if (!arm_feature(env, ARM_FEATURE_EL2) || !(env->cp15.scr_el3 & SCR_NS)) { | ||
237 | - return; | ||
238 | - } | ||
239 | - | ||
240 | - pageaddr = sextract64(value << 12, 0, 48); | ||
241 | - | ||
242 | - tlb_flush_page_by_mmuidx_all_cpus_synced(cs, pageaddr, | ||
243 | - ARMMMUIdxBit_Stage2); | ||
244 | -} | ||
245 | - | ||
246 | static CPAccessResult aa64_zva_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
247 | bool isread) | ||
248 | { | ||
249 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
250 | .writefn = tlbi_aa64_vae1_write }, | ||
251 | { .name = "TLBI_IPAS2E1IS", .state = ARM_CP_STATE_AA64, | ||
252 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 0, .opc2 = 1, | ||
253 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
254 | - .writefn = tlbi_aa64_ipas2e1is_write }, | ||
255 | + .access = PL2_W, .type = ARM_CP_NOP }, | ||
256 | { .name = "TLBI_IPAS2LE1IS", .state = ARM_CP_STATE_AA64, | ||
257 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 0, .opc2 = 5, | ||
258 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
259 | - .writefn = tlbi_aa64_ipas2e1is_write }, | ||
260 | + .access = PL2_W, .type = ARM_CP_NOP }, | ||
261 | { .name = "TLBI_ALLE1IS", .state = ARM_CP_STATE_AA64, | ||
262 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 3, .opc2 = 4, | ||
263 | .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
264 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
265 | .writefn = tlbi_aa64_alle1is_write }, | ||
266 | { .name = "TLBI_IPAS2E1", .state = ARM_CP_STATE_AA64, | ||
267 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 4, .opc2 = 1, | ||
268 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
269 | - .writefn = tlbi_aa64_ipas2e1_write }, | ||
270 | + .access = PL2_W, .type = ARM_CP_NOP }, | ||
271 | { .name = "TLBI_IPAS2LE1", .state = ARM_CP_STATE_AA64, | ||
272 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 4, .opc2 = 5, | ||
273 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
274 | - .writefn = tlbi_aa64_ipas2e1_write }, | ||
275 | + .access = PL2_W, .type = ARM_CP_NOP }, | ||
276 | { .name = "TLBI_ALLE1", .state = ARM_CP_STATE_AA64, | ||
277 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 7, .opc2 = 4, | ||
278 | .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
279 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
280 | .writefn = tlbimva_hyp_is_write }, | ||
281 | { .name = "TLBIIPAS2", | ||
282 | .cp = 15, .opc1 = 4, .crn = 8, .crm = 4, .opc2 = 1, | ||
283 | - .type = ARM_CP_NO_RAW, .access = PL2_W, | ||
284 | - .writefn = tlbiipas2_write }, | ||
285 | + .type = ARM_CP_NOP, .access = PL2_W }, | ||
286 | { .name = "TLBIIPAS2IS", | ||
287 | .cp = 15, .opc1 = 4, .crn = 8, .crm = 0, .opc2 = 1, | ||
288 | - .type = ARM_CP_NO_RAW, .access = PL2_W, | ||
289 | - .writefn = tlbiipas2_is_write }, | ||
290 | + .type = ARM_CP_NOP, .access = PL2_W }, | ||
291 | { .name = "TLBIIPAS2L", | ||
292 | .cp = 15, .opc1 = 4, .crn = 8, .crm = 4, .opc2 = 5, | ||
293 | - .type = ARM_CP_NO_RAW, .access = PL2_W, | ||
294 | - .writefn = tlbiipas2_write }, | ||
295 | + .type = ARM_CP_NOP, .access = PL2_W }, | ||
296 | { .name = "TLBIIPAS2LIS", | ||
297 | .cp = 15, .opc1 = 4, .crn = 8, .crm = 0, .opc2 = 5, | ||
298 | - .type = ARM_CP_NO_RAW, .access = PL2_W, | ||
299 | - .writefn = tlbiipas2_is_write }, | ||
300 | + .type = ARM_CP_NOP, .access = PL2_W }, | ||
301 | /* 32 bit cache operations */ | ||
302 | { .name = "ICIALLUIS", .cp = 15, .opc1 = 0, .crn = 7, .crm = 1, .opc2 = 0, | ||
303 | .type = ARM_CP_NOP, .access = PL1_W, .accessfn = aa64_cacheop_pou_access }, | ||
304 | -- | 129 | -- |
305 | 2.20.1 | 130 | 2.20.1 |
306 | 131 | ||
307 | 132 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The access_type argument to get_phys_addr_lpae() is an MMUAccessType; | ||
2 | use the enum constant MMU_DATA_LOAD rather than a literal 0 when we | ||
3 | call it in S1_ptw_translate(). | ||
4 | 1 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20200330210400.11724-3-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/helper.c | 5 +++-- | ||
11 | 1 file changed, 3 insertions(+), 2 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/helper.c | ||
16 | +++ b/target/arm/helper.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
18 | pcacheattrs = &cacheattrs; | ||
19 | } | ||
20 | |||
21 | - ret = get_phys_addr_lpae(env, addr, 0, ARMMMUIdx_Stage2, &s2pa, | ||
22 | - &txattrs, &s2prot, &s2size, fi, pcacheattrs); | ||
23 | + ret = get_phys_addr_lpae(env, addr, MMU_DATA_LOAD, ARMMMUIdx_Stage2, | ||
24 | + &s2pa, &txattrs, &s2prot, &s2size, fi, | ||
25 | + pcacheattrs); | ||
26 | if (ret) { | ||
27 | assert(fi->type != ARMFault_None); | ||
28 | fi->s2addr = addr; | ||
29 | -- | ||
30 | 2.20.1 | ||
31 | |||
32 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: Damien Hedde <damien.hedde@greensocs.com> |
---|---|---|---|
2 | 2 | ||
3 | Embed the ADMAs into the SoC type. | 3 | This prints the clocks attached to a DeviceState when using |
4 | "info qtree" monitor command. For every clock, it displays the | ||
5 | direction, the name and if the clock is forwarded. For input clock, | ||
6 | it displays also the frequency. | ||
4 | 7 | ||
5 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> | 8 | This is based on the original work of Frederic Konrad. |
6 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 9 | |
10 | Here follows a sample of `info qtree` output on xilinx_zynq machine | ||
11 | after linux boot with only one uart clocked: | ||
12 | > bus: main-system-bus | ||
13 | > type System | ||
14 | > [...] | ||
15 | > dev: cadence_uart, id "" | ||
16 | > gpio-out "sysbus-irq" 1 | ||
17 | > clock-in "refclk" freq_hz=0.000000e+00 | ||
18 | > chardev = "" | ||
19 | > mmio 00000000e0001000/0000000000001000 | ||
20 | > dev: cadence_uart, id "" | ||
21 | > gpio-out "sysbus-irq" 1 | ||
22 | > clock-in "refclk" freq_hz=1.375661e+07 | ||
23 | > chardev = "serial0" | ||
24 | > mmio 00000000e0000000/0000000000001000 | ||
25 | > [...] | ||
26 | > dev: xilinx,zynq_slcr, id "" | ||
27 | > clock-out "uart1_ref_clk" freq_hz=0.000000e+00 | ||
28 | > clock-out "uart0_ref_clk" freq_hz=1.375661e+07 | ||
29 | > clock-in "ps_clk" freq_hz=3.333333e+07 | ||
30 | > mmio 00000000f8000000/0000000000001000 | ||
31 | |||
32 | Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> | ||
33 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
34 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 35 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 36 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> |
9 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | 37 | Message-id: 20200406135251.157596-10-damien.hedde@greensocs.com |
10 | Message-id: 20200427181649.26851-7-edgar.iglesias@gmail.com | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 38 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 39 | --- |
13 | include/hw/arm/xlnx-versal.h | 3 ++- | 40 | qdev-monitor.c | 9 +++++++++ |
14 | hw/arm/xlnx-versal.c | 14 +++++++------- | 41 | 1 file changed, 9 insertions(+) |
15 | 2 files changed, 9 insertions(+), 8 deletions(-) | ||
16 | 42 | ||
17 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h | 43 | diff --git a/qdev-monitor.c b/qdev-monitor.c |
18 | index XXXXXXX..XXXXXXX 100644 | 44 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/hw/arm/xlnx-versal.h | 45 | --- a/qdev-monitor.c |
20 | +++ b/include/hw/arm/xlnx-versal.h | 46 | +++ b/qdev-monitor.c |
21 | @@ -XXX,XX +XXX,XX @@ | 47 | @@ -XXX,XX +XXX,XX @@ |
22 | #include "hw/arm/boot.h" | 48 | #include "migration/misc.h" |
23 | #include "hw/intc/arm_gicv3.h" | 49 | #include "migration/migration.h" |
24 | #include "hw/char/pl011.h" | 50 | #include "qemu/cutils.h" |
25 | +#include "hw/dma/xlnx-zdma.h" | 51 | +#include "hw/clock.h" |
26 | #include "hw/net/cadence_gem.h" | 52 | |
27 | 53 | /* | |
28 | #define TYPE_XLNX_VERSAL "xlnx-versal" | 54 | * Aliases were a bad idea from the start. Let's keep them |
29 | @@ -XXX,XX +XXX,XX @@ typedef struct Versal { | 55 | @@ -XXX,XX +XXX,XX @@ static void qdev_print(Monitor *mon, DeviceState *dev, int indent) |
30 | struct { | 56 | ObjectClass *class; |
31 | PL011State uart[XLNX_VERSAL_NR_UARTS]; | 57 | BusState *child; |
32 | CadenceGEMState gem[XLNX_VERSAL_NR_GEMS]; | 58 | NamedGPIOList *ngl; |
33 | - SysBusDevice *adma[XLNX_VERSAL_NR_ADMAS]; | 59 | + NamedClockList *ncl; |
34 | + XlnxZDMA adma[XLNX_VERSAL_NR_ADMAS]; | 60 | |
35 | } iou; | 61 | qdev_printf("dev: %s, id \"%s\"\n", object_get_typename(OBJECT(dev)), |
36 | } lpd; | 62 | dev->id ? dev->id : ""); |
37 | 63 | @@ -XXX,XX +XXX,XX @@ static void qdev_print(Monitor *mon, DeviceState *dev, int indent) | |
38 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c | 64 | ngl->num_out); |
39 | index XXXXXXX..XXXXXXX 100644 | 65 | } |
40 | --- a/hw/arm/xlnx-versal.c | ||
41 | +++ b/hw/arm/xlnx-versal.c | ||
42 | @@ -XXX,XX +XXX,XX @@ static void versal_create_admas(Versal *s, qemu_irq *pic) | ||
43 | DeviceState *dev; | ||
44 | MemoryRegion *mr; | ||
45 | |||
46 | - dev = qdev_create(NULL, "xlnx.zdma"); | ||
47 | - s->lpd.iou.adma[i] = SYS_BUS_DEVICE(dev); | ||
48 | - object_property_set_int(OBJECT(s->lpd.iou.adma[i]), 128, "bus-width", | ||
49 | - &error_abort); | ||
50 | - object_property_add_child(OBJECT(s), name, OBJECT(dev), &error_fatal); | ||
51 | + sysbus_init_child_obj(OBJECT(s), name, | ||
52 | + &s->lpd.iou.adma[i], sizeof(s->lpd.iou.adma[i]), | ||
53 | + TYPE_XLNX_ZDMA); | ||
54 | + dev = DEVICE(&s->lpd.iou.adma[i]); | ||
55 | + object_property_set_int(OBJECT(dev), 128, "bus-width", &error_abort); | ||
56 | qdev_init_nofail(dev); | ||
57 | |||
58 | - mr = sysbus_mmio_get_region(s->lpd.iou.adma[i], 0); | ||
59 | + mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0); | ||
60 | memory_region_add_subregion(&s->mr_ps, | ||
61 | MM_ADMA_CH0 + i * MM_ADMA_CH0_SIZE, mr); | ||
62 | |||
63 | - sysbus_connect_irq(s->lpd.iou.adma[i], 0, pic[VERSAL_ADMA_IRQ_0 + i]); | ||
64 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[VERSAL_ADMA_IRQ_0 + i]); | ||
65 | g_free(name); | ||
66 | } | 66 | } |
67 | } | 67 | + QLIST_FOREACH(ncl, &dev->clocks, node) { |
68 | + qdev_printf("clock-%s%s \"%s\" freq_hz=%e\n", | ||
69 | + ncl->output ? "out" : "in", | ||
70 | + ncl->alias ? " (alias)" : "", | ||
71 | + ncl->name, | ||
72 | + CLOCK_PERIOD_TO_HZ(1.0 * clock_get(ncl->clock))); | ||
73 | + } | ||
74 | class = object_get_class(OBJECT(dev)); | ||
75 | do { | ||
76 | qdev_print_props(mon, dev, DEVICE_CLASS(class)->props_, indent); | ||
68 | -- | 77 | -- |
69 | 2.20.1 | 78 | 2.20.1 |
70 | 79 | ||
71 | 80 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> |
---|---|---|---|
2 | 2 | ||
3 | Remove inclusion of arm_gicv3_common.h, this already gets | 3 | Setup the ADMA with 128bit bus-width. This matters when |
4 | included via xlnx-versal.h. | 4 | FIXED BURST mode is used. |
5 | 5 | ||
6 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 6 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> |
7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
8 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | 8 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> |
9 | Message-id: 20200427181649.26851-2-edgar.iglesias@gmail.com | 9 | Message-id: 20200417153800.27399-2-edgar.iglesias@gmail.com |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 11 | --- |
12 | hw/arm/xlnx-versal.c | 1 - | 12 | hw/arm/xlnx-versal.c | 2 ++ |
13 | 1 file changed, 1 deletion(-) | 13 | 1 file changed, 2 insertions(+) |
14 | 14 | ||
15 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c | 15 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c |
16 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/xlnx-versal.c | 17 | --- a/hw/arm/xlnx-versal.c |
18 | +++ b/hw/arm/xlnx-versal.c | 18 | +++ b/hw/arm/xlnx-versal.c |
19 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ static void versal_create_admas(Versal *s, qemu_irq *pic) |
20 | #include "hw/arm/boot.h" | 20 | |
21 | #include "kvm_arm.h" | 21 | dev = qdev_create(NULL, "xlnx.zdma"); |
22 | #include "hw/misc/unimp.h" | 22 | s->lpd.iou.adma[i] = SYS_BUS_DEVICE(dev); |
23 | -#include "hw/intc/arm_gicv3_common.h" | 23 | + object_property_set_int(OBJECT(s->lpd.iou.adma[i]), 128, "bus-width", |
24 | #include "hw/arm/xlnx-versal.h" | 24 | + &error_abort); |
25 | #include "hw/char/pl011.h" | 25 | object_property_add_child(OBJECT(s), name, OBJECT(dev), &error_fatal); |
26 | qdev_init_nofail(dev); | ||
26 | 27 | ||
27 | -- | 28 | -- |
28 | 2.20.1 | 29 | 2.20.1 |
29 | 30 | ||
30 | 31 | diff view generated by jsdifflib |
1 | Convert the VFM[AS]L (vector) insns to decodetree. This is the last | 1 | From: Ramon Fried <rfried.dev@gmail.com> |
---|---|---|---|
2 | insn in the legacy decoder for the 3same_ext group, so we can | ||
3 | delete the legacy decoder function for the group entirely. | ||
4 | 2 | ||
5 | Note that in disas_thumb2_insn() the parts of this encoding space | 3 | Wraparound of TX descriptor cyclic buffer only updated |
6 | where the decodetree decoder returns false will correctly be directed | 4 | the low 32 bits of the descriptor. |
7 | to illegal_op by the "(insn & (1 << 28))" check so they won't fall | 5 | Fix that by checking if we're working with 64bit descriptors. |
8 | into disas_coproc_insn() by mistake. | ||
9 | 6 | ||
7 | Signed-off-by: Ramon Fried <rfried.dev@gmail.com> | ||
8 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
9 | Message-id: 20200417171736.441607-1-rfried.dev@gmail.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20200430181003.21682-8-peter.maydell@linaro.org | ||
13 | --- | 11 | --- |
14 | target/arm/neon-shared.decode | 6 +++ | 12 | hw/net/cadence_gem.c | 9 ++++++++- |
15 | target/arm/translate-neon.inc.c | 31 +++++++++++ | 13 | 1 file changed, 8 insertions(+), 1 deletion(-) |
16 | target/arm/translate.c | 92 +-------------------------------- | ||
17 | 3 files changed, 38 insertions(+), 91 deletions(-) | ||
18 | 14 | ||
19 | diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode | 15 | diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c |
20 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/neon-shared.decode | 17 | --- a/hw/net/cadence_gem.c |
22 | +++ b/target/arm/neon-shared.decode | 18 | +++ b/hw/net/cadence_gem.c |
23 | @@ -XXX,XX +XXX,XX @@ VCADD 1111 110 rot:1 1 . 0 size:1 .... .... 1000 . q:1 . 0 .... \ | 19 | @@ -XXX,XX +XXX,XX @@ static void gem_transmit(CadenceGEMState *s) |
24 | # VUDOT and VSDOT | 20 | /* read next descriptor */ |
25 | VDOT 1111 110 00 . 10 .... .... 1101 . q:1 . u:1 .... \ | 21 | if (tx_desc_get_wrap(desc)) { |
26 | vm=%vm_dp vn=%vn_dp vd=%vd_dp | 22 | tx_desc_set_last(desc); |
23 | - packet_desc_addr = s->regs[GEM_TXQBASE]; | ||
27 | + | 24 | + |
28 | +# VFM[AS]L | 25 | + if (s->regs[GEM_DMACFG] & GEM_DMACFG_ADDR_64B) { |
29 | +VFML 1111 110 0 s:1 . 10 .... .... 1000 . 0 . 1 .... \ | 26 | + packet_desc_addr = s->regs[GEM_TBQPH]; |
30 | + vm=%vm_sp vn=%vn_sp vd=%vd_dp q=0 | 27 | + packet_desc_addr <<= 32; |
31 | +VFML 1111 110 0 s:1 . 10 .... .... 1000 . 1 . 1 .... \ | 28 | + } else { |
32 | + vm=%vm_dp vn=%vn_dp vd=%vd_dp q=1 | 29 | + packet_desc_addr = 0; |
33 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | 30 | + } |
34 | index XXXXXXX..XXXXXXX 100644 | 31 | + packet_desc_addr |= s->regs[GEM_TXQBASE]; |
35 | --- a/target/arm/translate-neon.inc.c | 32 | } else { |
36 | +++ b/target/arm/translate-neon.inc.c | 33 | packet_desc_addr += 4 * gem_get_desc_len(s, false); |
37 | @@ -XXX,XX +XXX,XX @@ static bool trans_VDOT(DisasContext *s, arg_VDOT *a) | ||
38 | opr_sz, opr_sz, 0, fn_gvec); | ||
39 | return true; | ||
40 | } | ||
41 | + | ||
42 | +static bool trans_VFML(DisasContext *s, arg_VFML *a) | ||
43 | +{ | ||
44 | + int opr_sz; | ||
45 | + | ||
46 | + if (!dc_isar_feature(aa32_fhm, s)) { | ||
47 | + return false; | ||
48 | + } | ||
49 | + | ||
50 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
51 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
52 | + (a->vd & 0x10)) { | ||
53 | + return false; | ||
54 | + } | ||
55 | + | ||
56 | + if (a->vd & a->q) { | ||
57 | + return false; | ||
58 | + } | ||
59 | + | ||
60 | + if (!vfp_access_check(s)) { | ||
61 | + return true; | ||
62 | + } | ||
63 | + | ||
64 | + opr_sz = (1 + a->q) * 8; | ||
65 | + tcg_gen_gvec_3_ptr(vfp_reg_offset(1, a->vd), | ||
66 | + vfp_reg_offset(a->q, a->vn), | ||
67 | + vfp_reg_offset(a->q, a->vm), | ||
68 | + cpu_env, opr_sz, opr_sz, a->s, /* is_2 == 0 */ | ||
69 | + gen_helper_gvec_fmlal_a32); | ||
70 | + return true; | ||
71 | +} | ||
72 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
73 | index XXXXXXX..XXXXXXX 100644 | ||
74 | --- a/target/arm/translate.c | ||
75 | +++ b/target/arm/translate.c | ||
76 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
77 | return 0; | ||
78 | } | ||
79 | |||
80 | -/* Advanced SIMD three registers of the same length extension. | ||
81 | - * 31 25 23 22 20 16 12 11 10 9 8 3 0 | ||
82 | - * +---------------+-----+---+-----+----+----+---+----+---+----+---------+----+ | ||
83 | - * | 1 1 1 1 1 1 0 | op1 | D | op2 | Vn | Vd | 1 | o3 | 0 | o4 | N Q M U | Vm | | ||
84 | - * +---------------+-----+---+-----+----+----+---+----+---+----+---------+----+ | ||
85 | - */ | ||
86 | -static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn) | ||
87 | -{ | ||
88 | - gen_helper_gvec_3 *fn_gvec = NULL; | ||
89 | - gen_helper_gvec_3_ptr *fn_gvec_ptr = NULL; | ||
90 | - int rd, rn, rm, opr_sz; | ||
91 | - int data = 0; | ||
92 | - int off_rn, off_rm; | ||
93 | - bool is_long = false, q = extract32(insn, 6, 1); | ||
94 | - bool ptr_is_env = false; | ||
95 | - | ||
96 | - if ((insn & 0xff300f10) == 0xfc200810) { | ||
97 | - /* VFM[AS]L -- 1111 1100 S.10 .... .... 1000 .Q.1 .... */ | ||
98 | - int is_s = extract32(insn, 23, 1); | ||
99 | - if (!dc_isar_feature(aa32_fhm, s)) { | ||
100 | - return 1; | ||
101 | - } | ||
102 | - is_long = true; | ||
103 | - data = is_s; /* is_2 == 0 */ | ||
104 | - fn_gvec_ptr = gen_helper_gvec_fmlal_a32; | ||
105 | - ptr_is_env = true; | ||
106 | - } else { | ||
107 | - return 1; | ||
108 | - } | ||
109 | - | ||
110 | - VFP_DREG_D(rd, insn); | ||
111 | - if (rd & q) { | ||
112 | - return 1; | ||
113 | - } | ||
114 | - if (q || !is_long) { | ||
115 | - VFP_DREG_N(rn, insn); | ||
116 | - VFP_DREG_M(rm, insn); | ||
117 | - if ((rn | rm) & q & !is_long) { | ||
118 | - return 1; | ||
119 | - } | ||
120 | - off_rn = vfp_reg_offset(1, rn); | ||
121 | - off_rm = vfp_reg_offset(1, rm); | ||
122 | - } else { | ||
123 | - rn = VFP_SREG_N(insn); | ||
124 | - rm = VFP_SREG_M(insn); | ||
125 | - off_rn = vfp_reg_offset(0, rn); | ||
126 | - off_rm = vfp_reg_offset(0, rm); | ||
127 | - } | ||
128 | - | ||
129 | - if (s->fp_excp_el) { | ||
130 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
131 | - syn_simd_access_trap(1, 0xe, false), s->fp_excp_el); | ||
132 | - return 0; | ||
133 | - } | ||
134 | - if (!s->vfp_enabled) { | ||
135 | - return 1; | ||
136 | - } | ||
137 | - | ||
138 | - opr_sz = (1 + q) * 8; | ||
139 | - if (fn_gvec_ptr) { | ||
140 | - TCGv_ptr ptr; | ||
141 | - if (ptr_is_env) { | ||
142 | - ptr = cpu_env; | ||
143 | - } else { | ||
144 | - ptr = get_fpstatus_ptr(1); | ||
145 | - } | ||
146 | - tcg_gen_gvec_3_ptr(vfp_reg_offset(1, rd), off_rn, off_rm, ptr, | ||
147 | - opr_sz, opr_sz, data, fn_gvec_ptr); | ||
148 | - if (!ptr_is_env) { | ||
149 | - tcg_temp_free_ptr(ptr); | ||
150 | - } | ||
151 | - } else { | ||
152 | - tcg_gen_gvec_3_ool(vfp_reg_offset(1, rd), off_rn, off_rm, | ||
153 | - opr_sz, opr_sz, data, fn_gvec); | ||
154 | - } | ||
155 | - return 0; | ||
156 | -} | ||
157 | - | ||
158 | /* Advanced SIMD two registers and a scalar extension. | ||
159 | * 31 24 23 22 20 16 12 11 10 9 8 3 0 | ||
160 | * +-----------------+----+---+----+----+----+---+----+---+----+---------+----+ | ||
161 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
162 | } | ||
163 | } | ||
164 | } | ||
165 | - } else if ((insn & 0x0e000a00) == 0x0c000800 | ||
166 | - && arm_dc_feature(s, ARM_FEATURE_V8)) { | ||
167 | - if (disas_neon_insn_3same_ext(s, insn)) { | ||
168 | - goto illegal_op; | ||
169 | - } | ||
170 | - return; | ||
171 | } else if ((insn & 0x0f000a00) == 0x0e000800 | ||
172 | && arm_dc_feature(s, ARM_FEATURE_V8)) { | ||
173 | if (disas_neon_insn_2reg_scalar_ext(s, insn)) { | ||
174 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
175 | } | ||
176 | break; | ||
177 | } | ||
178 | - if ((insn & 0xfe000a00) == 0xfc000800 | ||
179 | + if ((insn & 0xff000a00) == 0xfe000800 | ||
180 | && arm_dc_feature(s, ARM_FEATURE_V8)) { | ||
181 | /* The Thumb2 and ARM encodings are identical. */ | ||
182 | - if (disas_neon_insn_3same_ext(s, insn)) { | ||
183 | - goto illegal_op; | ||
184 | - } | ||
185 | - } else if ((insn & 0xff000a00) == 0xfe000800 | ||
186 | - && arm_dc_feature(s, ARM_FEATURE_V8)) { | ||
187 | - /* The Thumb2 and ARM encodings are identical. */ | ||
188 | if (disas_neon_insn_2reg_scalar_ext(s, insn)) { | ||
189 | goto illegal_op; | ||
190 | } | 34 | } |
191 | -- | 35 | -- |
192 | 2.20.1 | 36 | 2.20.1 |
193 | 37 | ||
194 | 38 | diff view generated by jsdifflib |
1 | Convert the Neon "load/store single structure to one lane" insns to | 1 | From: Ramon Fried <rfried.dev@gmail.com> |
---|---|---|---|
2 | decodetree. | ||
3 | 2 | ||
4 | As this is the last set of insns in the neon load/store group, | 3 | The RX ring descriptors control field is used for setting |
5 | we can remove the whole disas_neon_ls_insn() function. | 4 | SOF and EOF (start of frame and end of frame). |
5 | The SOF and EOF weren't cleared from the previous descriptors, | ||
6 | causing inconsistencies in ring buffer. | ||
7 | Fix that by clearing the control field of every descriptors we're | ||
8 | processing. | ||
6 | 9 | ||
10 | Signed-off-by: Ramon Fried <rfried.dev@gmail.com> | ||
11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
13 | Message-id: 20200418085145.489726-1-rfried.dev@gmail.com | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20200430181003.21682-14-peter.maydell@linaro.org | ||
10 | --- | 15 | --- |
11 | target/arm/neon-ls.decode | 11 +++ | 16 | hw/net/cadence_gem.c | 7 +++++++ |
12 | target/arm/translate-neon.inc.c | 89 +++++++++++++++++++ | 17 | 1 file changed, 7 insertions(+) |
13 | target/arm/translate.c | 147 -------------------------------- | ||
14 | 3 files changed, 100 insertions(+), 147 deletions(-) | ||
15 | 18 | ||
16 | diff --git a/target/arm/neon-ls.decode b/target/arm/neon-ls.decode | 19 | diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c |
17 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/neon-ls.decode | 21 | --- a/hw/net/cadence_gem.c |
19 | +++ b/target/arm/neon-ls.decode | 22 | +++ b/hw/net/cadence_gem.c |
20 | @@ -XXX,XX +XXX,XX @@ VLDST_multiple 1111 0100 0 . l:1 0 rn:4 .... itype:4 size:2 align:2 rm:4 \ | 23 | @@ -XXX,XX +XXX,XX @@ static inline void rx_desc_set_sof(uint32_t *desc) |
21 | 24 | desc[1] |= DESC_1_RX_SOF; | |
22 | VLD_all_lanes 1111 0100 1 . 1 0 rn:4 .... 11 n:2 size:2 t:1 a:1 rm:4 \ | 25 | } |
23 | vd=%vd_dp | 26 | |
24 | + | 27 | +static inline void rx_desc_clear_control(uint32_t *desc) |
25 | +# Neon load/store single structure to one lane | ||
26 | +%imm1_5_p1 5:1 !function=plus1 | ||
27 | +%imm1_6_p1 6:1 !function=plus1 | ||
28 | + | ||
29 | +VLDST_single 1111 0100 1 . l:1 0 rn:4 .... 00 n:2 reg_idx:3 align:1 rm:4 \ | ||
30 | + vd=%vd_dp size=0 stride=1 | ||
31 | +VLDST_single 1111 0100 1 . l:1 0 rn:4 .... 01 n:2 reg_idx:2 align:2 rm:4 \ | ||
32 | + vd=%vd_dp size=1 stride=%imm1_5_p1 | ||
33 | +VLDST_single 1111 0100 1 . l:1 0 rn:4 .... 10 n:2 reg_idx:1 align:3 rm:4 \ | ||
34 | + vd=%vd_dp size=2 stride=%imm1_6_p1 | ||
35 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/target/arm/translate-neon.inc.c | ||
38 | +++ b/target/arm/translate-neon.inc.c | ||
39 | @@ -XXX,XX +XXX,XX @@ | ||
40 | * It might be possible to convert it to a standalone .c file eventually. | ||
41 | */ | ||
42 | |||
43 | +static inline int plus1(DisasContext *s, int x) | ||
44 | +{ | 28 | +{ |
45 | + return x + 1; | 29 | + desc[1] = 0; |
46 | +} | 30 | +} |
47 | + | 31 | + |
48 | /* Include the generated Neon decoder */ | 32 | static inline void rx_desc_set_eof(uint32_t *desc) |
49 | #include "decode-neon-dp.inc.c" | 33 | { |
50 | #include "decode-neon-ls.inc.c" | 34 | desc[1] |= DESC_1_RX_EOF; |
51 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a) | 35 | @@ -XXX,XX +XXX,XX @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) |
52 | 36 | rxbuf_ptr += MIN(bytes_to_copy, rxbufsize); | |
53 | return true; | 37 | bytes_to_copy -= MIN(bytes_to_copy, rxbufsize); |
54 | } | 38 | |
39 | + rx_desc_clear_control(s->rx_desc[q]); | ||
55 | + | 40 | + |
56 | +static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a) | 41 | /* Update the descriptor. */ |
57 | +{ | 42 | if (first_desc) { |
58 | + /* Neon load/store single structure to one lane */ | 43 | rx_desc_set_sof(s->rx_desc[q]); |
59 | + int reg; | ||
60 | + int nregs = a->n + 1; | ||
61 | + int vd = a->vd; | ||
62 | + TCGv_i32 addr, tmp; | ||
63 | + | ||
64 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
65 | + return false; | ||
66 | + } | ||
67 | + | ||
68 | + /* UNDEF accesses to D16-D31 if they don't exist */ | ||
69 | + if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) { | ||
70 | + return false; | ||
71 | + } | ||
72 | + | ||
73 | + /* Catch the UNDEF cases. This is unavoidably a bit messy. */ | ||
74 | + switch (nregs) { | ||
75 | + case 1: | ||
76 | + if (((a->align & (1 << a->size)) != 0) || | ||
77 | + (a->size == 2 && ((a->align & 3) == 1 || (a->align & 3) == 2))) { | ||
78 | + return false; | ||
79 | + } | ||
80 | + break; | ||
81 | + case 3: | ||
82 | + if ((a->align & 1) != 0) { | ||
83 | + return false; | ||
84 | + } | ||
85 | + /* fall through */ | ||
86 | + case 2: | ||
87 | + if (a->size == 2 && (a->align & 2) != 0) { | ||
88 | + return false; | ||
89 | + } | ||
90 | + break; | ||
91 | + case 4: | ||
92 | + if ((a->size == 2) && ((a->align & 3) == 3)) { | ||
93 | + return false; | ||
94 | + } | ||
95 | + break; | ||
96 | + default: | ||
97 | + abort(); | ||
98 | + } | ||
99 | + if ((vd + a->stride * (nregs - 1)) > 31) { | ||
100 | + /* | ||
101 | + * Attempts to write off the end of the register file are | ||
102 | + * UNPREDICTABLE; we choose to UNDEF because otherwise we would | ||
103 | + * access off the end of the array that holds the register data. | ||
104 | + */ | ||
105 | + return false; | ||
106 | + } | ||
107 | + | ||
108 | + if (!vfp_access_check(s)) { | ||
109 | + return true; | ||
110 | + } | ||
111 | + | ||
112 | + tmp = tcg_temp_new_i32(); | ||
113 | + addr = tcg_temp_new_i32(); | ||
114 | + load_reg_var(s, addr, a->rn); | ||
115 | + /* | ||
116 | + * TODO: if we implemented alignment exceptions, we should check | ||
117 | + * addr against the alignment encoded in a->align here. | ||
118 | + */ | ||
119 | + for (reg = 0; reg < nregs; reg++) { | ||
120 | + if (a->l) { | ||
121 | + gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), | ||
122 | + s->be_data | a->size); | ||
123 | + neon_store_element(vd, a->reg_idx, a->size, tmp); | ||
124 | + } else { /* Store */ | ||
125 | + neon_load_element(tmp, vd, a->reg_idx, a->size); | ||
126 | + gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), | ||
127 | + s->be_data | a->size); | ||
128 | + } | ||
129 | + vd += a->stride; | ||
130 | + tcg_gen_addi_i32(addr, addr, 1 << a->size); | ||
131 | + } | ||
132 | + tcg_temp_free_i32(addr); | ||
133 | + tcg_temp_free_i32(tmp); | ||
134 | + | ||
135 | + gen_neon_ldst_base_update(s, a->rm, a->rn, (1 << a->size) * nregs); | ||
136 | + | ||
137 | + return true; | ||
138 | +} | ||
139 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
140 | index XXXXXXX..XXXXXXX 100644 | ||
141 | --- a/target/arm/translate.c | ||
142 | +++ b/target/arm/translate.c | ||
143 | @@ -XXX,XX +XXX,XX @@ static void gen_neon_trn_u16(TCGv_i32 t0, TCGv_i32 t1) | ||
144 | tcg_temp_free_i32(rd); | ||
145 | } | ||
146 | |||
147 | - | ||
148 | -/* Translate a NEON load/store element instruction. Return nonzero if the | ||
149 | - instruction is invalid. */ | ||
150 | -static int disas_neon_ls_insn(DisasContext *s, uint32_t insn) | ||
151 | -{ | ||
152 | - int rd, rn, rm; | ||
153 | - int nregs; | ||
154 | - int stride; | ||
155 | - int size; | ||
156 | - int reg; | ||
157 | - int load; | ||
158 | - TCGv_i32 addr; | ||
159 | - TCGv_i32 tmp; | ||
160 | - | ||
161 | - if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
162 | - return 1; | ||
163 | - } | ||
164 | - | ||
165 | - /* FIXME: this access check should not take precedence over UNDEF | ||
166 | - * for invalid encodings; we will generate incorrect syndrome information | ||
167 | - * for attempts to execute invalid vfp/neon encodings with FP disabled. | ||
168 | - */ | ||
169 | - if (s->fp_excp_el) { | ||
170 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
171 | - syn_simd_access_trap(1, 0xe, false), s->fp_excp_el); | ||
172 | - return 0; | ||
173 | - } | ||
174 | - | ||
175 | - if (!s->vfp_enabled) | ||
176 | - return 1; | ||
177 | - VFP_DREG_D(rd, insn); | ||
178 | - rn = (insn >> 16) & 0xf; | ||
179 | - rm = insn & 0xf; | ||
180 | - load = (insn & (1 << 21)) != 0; | ||
181 | - if ((insn & (1 << 23)) == 0) { | ||
182 | - /* Load store all elements -- handled already by decodetree */ | ||
183 | - return 1; | ||
184 | - } else { | ||
185 | - size = (insn >> 10) & 3; | ||
186 | - if (size == 3) { | ||
187 | - /* Load single element to all lanes -- handled by decodetree */ | ||
188 | - return 1; | ||
189 | - } else { | ||
190 | - /* Single element. */ | ||
191 | - int idx = (insn >> 4) & 0xf; | ||
192 | - int reg_idx; | ||
193 | - switch (size) { | ||
194 | - case 0: | ||
195 | - reg_idx = (insn >> 5) & 7; | ||
196 | - stride = 1; | ||
197 | - break; | ||
198 | - case 1: | ||
199 | - reg_idx = (insn >> 6) & 3; | ||
200 | - stride = (insn & (1 << 5)) ? 2 : 1; | ||
201 | - break; | ||
202 | - case 2: | ||
203 | - reg_idx = (insn >> 7) & 1; | ||
204 | - stride = (insn & (1 << 6)) ? 2 : 1; | ||
205 | - break; | ||
206 | - default: | ||
207 | - abort(); | ||
208 | - } | ||
209 | - nregs = ((insn >> 8) & 3) + 1; | ||
210 | - /* Catch the UNDEF cases. This is unavoidably a bit messy. */ | ||
211 | - switch (nregs) { | ||
212 | - case 1: | ||
213 | - if (((idx & (1 << size)) != 0) || | ||
214 | - (size == 2 && ((idx & 3) == 1 || (idx & 3) == 2))) { | ||
215 | - return 1; | ||
216 | - } | ||
217 | - break; | ||
218 | - case 3: | ||
219 | - if ((idx & 1) != 0) { | ||
220 | - return 1; | ||
221 | - } | ||
222 | - /* fall through */ | ||
223 | - case 2: | ||
224 | - if (size == 2 && (idx & 2) != 0) { | ||
225 | - return 1; | ||
226 | - } | ||
227 | - break; | ||
228 | - case 4: | ||
229 | - if ((size == 2) && ((idx & 3) == 3)) { | ||
230 | - return 1; | ||
231 | - } | ||
232 | - break; | ||
233 | - default: | ||
234 | - abort(); | ||
235 | - } | ||
236 | - if ((rd + stride * (nregs - 1)) > 31) { | ||
237 | - /* Attempts to write off the end of the register file | ||
238 | - * are UNPREDICTABLE; we choose to UNDEF because otherwise | ||
239 | - * the neon_load_reg() would write off the end of the array. | ||
240 | - */ | ||
241 | - return 1; | ||
242 | - } | ||
243 | - tmp = tcg_temp_new_i32(); | ||
244 | - addr = tcg_temp_new_i32(); | ||
245 | - load_reg_var(s, addr, rn); | ||
246 | - for (reg = 0; reg < nregs; reg++) { | ||
247 | - if (load) { | ||
248 | - gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s), | ||
249 | - s->be_data | size); | ||
250 | - neon_store_element(rd, reg_idx, size, tmp); | ||
251 | - } else { /* Store */ | ||
252 | - neon_load_element(tmp, rd, reg_idx, size); | ||
253 | - gen_aa32_st_i32(s, tmp, addr, get_mem_index(s), | ||
254 | - s->be_data | size); | ||
255 | - } | ||
256 | - rd += stride; | ||
257 | - tcg_gen_addi_i32(addr, addr, 1 << size); | ||
258 | - } | ||
259 | - tcg_temp_free_i32(addr); | ||
260 | - tcg_temp_free_i32(tmp); | ||
261 | - stride = nregs * (1 << size); | ||
262 | - } | ||
263 | - } | ||
264 | - if (rm != 15) { | ||
265 | - TCGv_i32 base; | ||
266 | - | ||
267 | - base = load_reg(s, rn); | ||
268 | - if (rm == 13) { | ||
269 | - tcg_gen_addi_i32(base, base, stride); | ||
270 | - } else { | ||
271 | - TCGv_i32 index; | ||
272 | - index = load_reg(s, rm); | ||
273 | - tcg_gen_add_i32(base, base, index); | ||
274 | - tcg_temp_free_i32(index); | ||
275 | - } | ||
276 | - store_reg(s, rn, base); | ||
277 | - } | ||
278 | - return 0; | ||
279 | -} | ||
280 | - | ||
281 | static inline void gen_neon_narrow(int size, TCGv_i32 dest, TCGv_i64 src) | ||
282 | { | ||
283 | switch (size) { | ||
284 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
285 | } | ||
286 | return; | ||
287 | } | ||
288 | - if ((insn & 0x0f100000) == 0x04000000) { | ||
289 | - /* NEON load/store. */ | ||
290 | - if (disas_neon_ls_insn(s, insn)) { | ||
291 | - goto illegal_op; | ||
292 | - } | ||
293 | - return; | ||
294 | - } | ||
295 | if ((insn & 0x0e000f00) == 0x0c000100) { | ||
296 | if (arm_dc_feature(s, ARM_FEATURE_IWMMXT)) { | ||
297 | /* iWMMXt register transfer. */ | ||
298 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
299 | } | ||
300 | break; | ||
301 | case 12: | ||
302 | - if ((insn & 0x01100000) == 0x01000000) { | ||
303 | - if (disas_neon_ls_insn(s, insn)) { | ||
304 | - goto illegal_op; | ||
305 | - } | ||
306 | - break; | ||
307 | - } | ||
308 | goto illegal_op; | ||
309 | default: | ||
310 | illegal_op: | ||
311 | -- | 44 | -- |
312 | 2.20.1 | 45 | 2.20.1 |
313 | 46 | ||
314 | 47 | diff view generated by jsdifflib |
1 | Convert the Neon 3-reg-same VADD and VSUB insns to decodetree. | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Note that we don't need the neon_3r_sizes[op] check here because all | 3 | These instructions are often used in glibc's string routines. |
4 | size values are OK for VADD and VSUB; we'll add this when we convert | 4 | They were the final uses of the 32-bit at a time neon helpers. |
5 | the first insn that has size restrictions. | ||
6 | 5 | ||
7 | For this we need one of the GVecGen*Fn typedefs currently in | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | translate-a64.h; move them all to translate.h as a block so they | 7 | Message-id: 20200418162808.4680-1-richard.henderson@linaro.org |
9 | are visible to the 32-bit decoder. | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/helper.h | 27 ++-- | ||
12 | target/arm/translate.h | 5 + | ||
13 | target/arm/neon_helper.c | 24 ---- | ||
14 | target/arm/translate-a64.c | 64 +++------- | ||
15 | target/arm/translate.c | 256 +++++++++++++++++++++++++++++++------ | ||
16 | target/arm/vec_helper.c | 25 ++++ | ||
17 | 6 files changed, 278 insertions(+), 123 deletions(-) | ||
10 | 18 | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | diff --git a/target/arm/helper.h b/target/arm/helper.h |
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20200430181003.21682-15-peter.maydell@linaro.org | ||
14 | --- | ||
15 | target/arm/translate-a64.h | 9 -------- | ||
16 | target/arm/translate.h | 9 ++++++++ | ||
17 | target/arm/neon-dp.decode | 17 +++++++++++++++ | ||
18 | target/arm/translate-neon.inc.c | 38 +++++++++++++++++++++++++++++++++ | ||
19 | target/arm/translate.c | 14 ++++-------- | ||
20 | 5 files changed, 68 insertions(+), 19 deletions(-) | ||
21 | |||
22 | diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h | ||
23 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/arm/translate-a64.h | 21 | --- a/target/arm/helper.h |
25 | +++ b/target/arm/translate-a64.h | 22 | +++ b/target/arm/helper.h |
26 | @@ -XXX,XX +XXX,XX @@ static inline int vec_full_reg_size(DisasContext *s) | 23 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(neon_hsub_u16, i32, i32, i32) |
27 | 24 | DEF_HELPER_2(neon_hsub_s32, s32, s32, s32) | |
28 | bool disas_sve(DisasContext *, uint32_t); | 25 | DEF_HELPER_2(neon_hsub_u32, i32, i32, i32) |
29 | 26 | ||
30 | -/* Note that the gvec expanders operate on offsets + sizes. */ | 27 | -DEF_HELPER_2(neon_cgt_u8, i32, i32, i32) |
31 | -typedef void GVecGen2Fn(unsigned, uint32_t, uint32_t, uint32_t, uint32_t); | 28 | -DEF_HELPER_2(neon_cgt_s8, i32, i32, i32) |
32 | -typedef void GVecGen2iFn(unsigned, uint32_t, uint32_t, int64_t, | 29 | -DEF_HELPER_2(neon_cgt_u16, i32, i32, i32) |
33 | - uint32_t, uint32_t); | 30 | -DEF_HELPER_2(neon_cgt_s16, i32, i32, i32) |
34 | -typedef void GVecGen3Fn(unsigned, uint32_t, uint32_t, | 31 | -DEF_HELPER_2(neon_cgt_u32, i32, i32, i32) |
35 | - uint32_t, uint32_t, uint32_t); | 32 | -DEF_HELPER_2(neon_cgt_s32, i32, i32, i32) |
36 | -typedef void GVecGen4Fn(unsigned, uint32_t, uint32_t, uint32_t, | 33 | -DEF_HELPER_2(neon_cge_u8, i32, i32, i32) |
37 | - uint32_t, uint32_t, uint32_t); | 34 | -DEF_HELPER_2(neon_cge_s8, i32, i32, i32) |
35 | -DEF_HELPER_2(neon_cge_u16, i32, i32, i32) | ||
36 | -DEF_HELPER_2(neon_cge_s16, i32, i32, i32) | ||
37 | -DEF_HELPER_2(neon_cge_u32, i32, i32, i32) | ||
38 | -DEF_HELPER_2(neon_cge_s32, i32, i32, i32) | ||
38 | - | 39 | - |
39 | #endif /* TARGET_ARM_TRANSLATE_A64_H */ | 40 | DEF_HELPER_2(neon_pmin_u8, i32, i32, i32) |
41 | DEF_HELPER_2(neon_pmin_s8, i32, i32, i32) | ||
42 | DEF_HELPER_2(neon_pmin_u16, i32, i32, i32) | ||
43 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(neon_mul_u16, i32, i32, i32) | ||
44 | DEF_HELPER_2(neon_tst_u8, i32, i32, i32) | ||
45 | DEF_HELPER_2(neon_tst_u16, i32, i32, i32) | ||
46 | DEF_HELPER_2(neon_tst_u32, i32, i32, i32) | ||
47 | -DEF_HELPER_2(neon_ceq_u8, i32, i32, i32) | ||
48 | -DEF_HELPER_2(neon_ceq_u16, i32, i32, i32) | ||
49 | -DEF_HELPER_2(neon_ceq_u32, i32, i32, i32) | ||
50 | |||
51 | DEF_HELPER_1(neon_clz_u8, i32, i32) | ||
52 | DEF_HELPER_1(neon_clz_u16, i32, i32) | ||
53 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_2(frint64_s, TCG_CALL_NO_RWG, f32, f32, ptr) | ||
54 | DEF_HELPER_FLAGS_2(frint32_d, TCG_CALL_NO_RWG, f64, f64, ptr) | ||
55 | DEF_HELPER_FLAGS_2(frint64_d, TCG_CALL_NO_RWG, f64, f64, ptr) | ||
56 | |||
57 | +DEF_HELPER_FLAGS_3(gvec_ceq0_b, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
58 | +DEF_HELPER_FLAGS_3(gvec_ceq0_h, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
59 | +DEF_HELPER_FLAGS_3(gvec_clt0_b, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
60 | +DEF_HELPER_FLAGS_3(gvec_clt0_h, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
61 | +DEF_HELPER_FLAGS_3(gvec_cle0_b, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
62 | +DEF_HELPER_FLAGS_3(gvec_cle0_h, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
63 | +DEF_HELPER_FLAGS_3(gvec_cgt0_b, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
64 | +DEF_HELPER_FLAGS_3(gvec_cgt0_h, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
65 | +DEF_HELPER_FLAGS_3(gvec_cge0_b, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
66 | +DEF_HELPER_FLAGS_3(gvec_cge0_h, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
67 | + | ||
68 | DEF_HELPER_FLAGS_4(gvec_sshl_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
69 | DEF_HELPER_FLAGS_4(gvec_sshl_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
70 | DEF_HELPER_FLAGS_4(gvec_ushl_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
40 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 71 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
41 | index XXXXXXX..XXXXXXX 100644 | 72 | index XXXXXXX..XXXXXXX 100644 |
42 | --- a/target/arm/translate.h | 73 | --- a/target/arm/translate.h |
43 | +++ b/target/arm/translate.h | 74 | +++ b/target/arm/translate.h |
44 | @@ -XXX,XX +XXX,XX @@ void gen_sshl_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b); | 75 | @@ -XXX,XX +XXX,XX @@ static inline void gen_swstep_exception(DisasContext *s, int isv, int ex) |
45 | #define dc_isar_feature(name, ctx) \ | 76 | uint64_t vfp_expand_imm(int size, uint8_t imm8); |
46 | ({ DisasContext *ctx_ = (ctx); isar_feature_##name(ctx_->isar); }) | 77 | |
47 | 78 | /* Vector operations shared between ARM and AArch64. */ | |
48 | +/* Note that the gvec expanders operate on offsets + sizes. */ | 79 | +extern const GVecGen2 ceq0_op[4]; |
49 | +typedef void GVecGen2Fn(unsigned, uint32_t, uint32_t, uint32_t, uint32_t); | 80 | +extern const GVecGen2 clt0_op[4]; |
50 | +typedef void GVecGen2iFn(unsigned, uint32_t, uint32_t, int64_t, | 81 | +extern const GVecGen2 cgt0_op[4]; |
51 | + uint32_t, uint32_t); | 82 | +extern const GVecGen2 cle0_op[4]; |
52 | +typedef void GVecGen3Fn(unsigned, uint32_t, uint32_t, | 83 | +extern const GVecGen2 cge0_op[4]; |
53 | + uint32_t, uint32_t, uint32_t); | 84 | extern const GVecGen3 mla_op[4]; |
54 | +typedef void GVecGen4Fn(unsigned, uint32_t, uint32_t, uint32_t, | 85 | extern const GVecGen3 mls_op[4]; |
55 | + uint32_t, uint32_t, uint32_t); | 86 | extern const GVecGen3 cmtst_op[4]; |
56 | + | 87 | diff --git a/target/arm/neon_helper.c b/target/arm/neon_helper.c |
57 | #endif /* TARGET_ARM_TRANSLATE_H */ | ||
58 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | ||
59 | index XXXXXXX..XXXXXXX 100644 | 88 | index XXXXXXX..XXXXXXX 100644 |
60 | --- a/target/arm/neon-dp.decode | 89 | --- a/target/arm/neon_helper.c |
61 | +++ b/target/arm/neon-dp.decode | 90 | +++ b/target/arm/neon_helper.c |
62 | @@ -XXX,XX +XXX,XX @@ | 91 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(neon_hsub_u32)(uint32_t src1, uint32_t src2) |
63 | # | 92 | return dest; |
64 | # This file is processed by scripts/decodetree.py | 93 | } |
65 | # | 94 | |
66 | +# VFP/Neon register fields; same as vfp.decode | 95 | -#define NEON_FN(dest, src1, src2) dest = (src1 > src2) ? ~0 : 0 |
67 | +%vm_dp 5:1 0:4 | 96 | -NEON_VOP(cgt_s8, neon_s8, 4) |
68 | +%vn_dp 7:1 16:4 | 97 | -NEON_VOP(cgt_u8, neon_u8, 4) |
69 | +%vd_dp 22:1 12:4 | 98 | -NEON_VOP(cgt_s16, neon_s16, 2) |
70 | 99 | -NEON_VOP(cgt_u16, neon_u16, 2) | |
71 | # Encodings for Neon data processing instructions where the T32 encoding | 100 | -NEON_VOP(cgt_s32, neon_s32, 1) |
72 | # is a simple transformation of the A32 encoding. | 101 | -NEON_VOP(cgt_u32, neon_u32, 1) |
73 | @@ -XXX,XX +XXX,XX @@ | 102 | -#undef NEON_FN |
74 | # 0b111p_1111_qqqq_qqqq_qqqq_qqqq_qqqq_qqqq | 103 | - |
75 | # This file works on the A32 encoding only; calling code for T32 has to | 104 | -#define NEON_FN(dest, src1, src2) dest = (src1 >= src2) ? ~0 : 0 |
76 | # transform the insn into the A32 version first. | 105 | -NEON_VOP(cge_s8, neon_s8, 4) |
77 | + | 106 | -NEON_VOP(cge_u8, neon_u8, 4) |
78 | +###################################################################### | 107 | -NEON_VOP(cge_s16, neon_s16, 2) |
79 | +# 3-reg-same grouping: | 108 | -NEON_VOP(cge_u16, neon_u16, 2) |
80 | +# 1111 001 U 0 D sz:2 Vn:4 Vd:4 opc:4 N Q M op Vm:4 | 109 | -NEON_VOP(cge_s32, neon_s32, 1) |
81 | +###################################################################### | 110 | -NEON_VOP(cge_u32, neon_u32, 1) |
82 | + | 111 | -#undef NEON_FN |
83 | +&3same vm vn vd q size | 112 | - |
84 | + | 113 | #define NEON_FN(dest, src1, src2) dest = (src1 < src2) ? src1 : src2 |
85 | +@3same .... ... . . . size:2 .... .... .... . q:1 . . .... \ | 114 | NEON_POP(pmin_s8, neon_s8, 4) |
86 | + &3same vm=%vm_dp vn=%vn_dp vd=%vd_dp | 115 | NEON_POP(pmin_u8, neon_u8, 4) |
87 | + | 116 | @@ -XXX,XX +XXX,XX @@ NEON_VOP(tst_u16, neon_u16, 2) |
88 | +VADD_3s 1111 001 0 0 . .. .... .... 1000 . . . 0 .... @3same | 117 | NEON_VOP(tst_u32, neon_u32, 1) |
89 | +VSUB_3s 1111 001 1 0 . .. .... .... 1000 . . . 0 .... @3same | 118 | #undef NEON_FN |
90 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | 119 | |
120 | -#define NEON_FN(dest, src1, src2) dest = (src1 == src2) ? -1 : 0 | ||
121 | -NEON_VOP(ceq_u8, neon_u8, 4) | ||
122 | -NEON_VOP(ceq_u16, neon_u16, 2) | ||
123 | -NEON_VOP(ceq_u32, neon_u32, 1) | ||
124 | -#undef NEON_FN | ||
125 | - | ||
126 | /* Count Leading Sign/Zero Bits. */ | ||
127 | static inline int do_clz8(uint8_t x) | ||
128 | { | ||
129 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
91 | index XXXXXXX..XXXXXXX 100644 | 130 | index XXXXXXX..XXXXXXX 100644 |
92 | --- a/target/arm/translate-neon.inc.c | 131 | --- a/target/arm/translate-a64.c |
93 | +++ b/target/arm/translate-neon.inc.c | 132 | +++ b/target/arm/translate-a64.c |
94 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a) | 133 | @@ -XXX,XX +XXX,XX @@ static void gen_gvec_fn4(DisasContext *s, bool is_q, int rd, int rn, int rm, |
95 | 134 | is_q ? 16 : 8, vec_full_reg_size(s)); | |
96 | return true; | ||
97 | } | 135 | } |
98 | + | 136 | |
99 | +static bool do_3same(DisasContext *s, arg_3same *a, GVecGen3Fn fn) | 137 | +/* Expand a 2-operand AdvSIMD vector operation using an op descriptor. */ |
100 | +{ | 138 | +static void gen_gvec_op2(DisasContext *s, bool is_q, int rd, |
101 | + int vec_size = a->q ? 16 : 8; | 139 | + int rn, const GVecGen2 *gvec_op) |
102 | + int rd_ofs = neon_reg_offset(a->vd, 0); | 140 | +{ |
103 | + int rn_ofs = neon_reg_offset(a->vn, 0); | 141 | + tcg_gen_gvec_2(vec_full_reg_offset(s, rd), vec_full_reg_offset(s, rn), |
104 | + int rm_ofs = neon_reg_offset(a->vm, 0); | 142 | + is_q ? 16 : 8, vec_full_reg_size(s), gvec_op); |
105 | + | 143 | +} |
106 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | 144 | + |
107 | + return false; | 145 | /* Expand a 2-operand + immediate AdvSIMD vector operation using |
108 | + } | 146 | * an op descriptor. |
109 | + | 147 | */ |
110 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | 148 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn) |
111 | + if (!dc_isar_feature(aa32_simd_r32, s) && | 149 | return; |
112 | + ((a->vd | a->vn | a->vm) & 0x10)) { | 150 | } |
113 | + return false; | 151 | break; |
114 | + } | 152 | + case 0x8: /* CMGT, CMGE */ |
115 | + | 153 | + gen_gvec_op2(s, is_q, rd, rn, u ? &cge0_op[size] : &cgt0_op[size]); |
116 | + if ((a->vn | a->vm | a->vd) & a->q) { | 154 | + return; |
117 | + return false; | 155 | + case 0x9: /* CMEQ, CMLE */ |
118 | + } | 156 | + gen_gvec_op2(s, is_q, rd, rn, u ? &cle0_op[size] : &ceq0_op[size]); |
119 | + | 157 | + return; |
120 | + if (!vfp_access_check(s)) { | 158 | + case 0xa: /* CMLT */ |
121 | + return true; | 159 | + gen_gvec_op2(s, is_q, rd, rn, &clt0_op[size]); |
122 | + } | 160 | + return; |
123 | + | 161 | case 0xb: |
124 | + fn(a->size, rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size); | 162 | if (u) { /* ABS, NEG */ |
125 | + return true; | 163 | gen_gvec_fn2(s, is_q, rd, rn, tcg_gen_gvec_neg, size); |
126 | +} | 164 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn) |
127 | + | 165 | for (pass = 0; pass < (is_q ? 4 : 2); pass++) { |
128 | +#define DO_3SAME(INSN, FUNC) \ | 166 | TCGv_i32 tcg_op = tcg_temp_new_i32(); |
129 | + static bool trans_##INSN##_3s(DisasContext *s, arg_3same *a) \ | 167 | TCGv_i32 tcg_res = tcg_temp_new_i32(); |
130 | + { \ | 168 | - TCGCond cond; |
131 | + return do_3same(s, a, FUNC); \ | 169 | |
132 | + } | 170 | read_vec_element_i32(s, tcg_op, rn, pass, MO_32); |
133 | + | 171 | |
134 | +DO_3SAME(VADD, tcg_gen_gvec_add) | 172 | if (size == 2) { |
135 | +DO_3SAME(VSUB, tcg_gen_gvec_sub) | 173 | /* Special cases for 32 bit elements */ |
174 | switch (opcode) { | ||
175 | - case 0xa: /* CMLT */ | ||
176 | - /* 32 bit integer comparison against zero, result is | ||
177 | - * test ? (2^32 - 1) : 0. We implement via setcond(test) | ||
178 | - * and inverting. | ||
179 | - */ | ||
180 | - cond = TCG_COND_LT; | ||
181 | - do_cmop: | ||
182 | - tcg_gen_setcondi_i32(cond, tcg_res, tcg_op, 0); | ||
183 | - tcg_gen_neg_i32(tcg_res, tcg_res); | ||
184 | - break; | ||
185 | - case 0x8: /* CMGT, CMGE */ | ||
186 | - cond = u ? TCG_COND_GE : TCG_COND_GT; | ||
187 | - goto do_cmop; | ||
188 | - case 0x9: /* CMEQ, CMLE */ | ||
189 | - cond = u ? TCG_COND_LE : TCG_COND_EQ; | ||
190 | - goto do_cmop; | ||
191 | case 0x4: /* CLS */ | ||
192 | if (u) { | ||
193 | tcg_gen_clzi_i32(tcg_res, tcg_op, 32); | ||
194 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn) | ||
195 | genfn(tcg_res, cpu_env, tcg_op); | ||
196 | break; | ||
197 | } | ||
198 | - case 0x8: /* CMGT, CMGE */ | ||
199 | - case 0x9: /* CMEQ, CMLE */ | ||
200 | - case 0xa: /* CMLT */ | ||
201 | - { | ||
202 | - static NeonGenTwoOpFn * const fns[3][2] = { | ||
203 | - { gen_helper_neon_cgt_s8, gen_helper_neon_cgt_s16 }, | ||
204 | - { gen_helper_neon_cge_s8, gen_helper_neon_cge_s16 }, | ||
205 | - { gen_helper_neon_ceq_u8, gen_helper_neon_ceq_u16 }, | ||
206 | - }; | ||
207 | - NeonGenTwoOpFn *genfn; | ||
208 | - int comp; | ||
209 | - bool reverse; | ||
210 | - TCGv_i32 tcg_zero = tcg_const_i32(0); | ||
211 | - | ||
212 | - /* comp = index into [CMGT, CMGE, CMEQ, CMLE, CMLT] */ | ||
213 | - comp = (opcode - 0x8) * 2 + u; | ||
214 | - /* ...but LE, LT are implemented as reverse GE, GT */ | ||
215 | - reverse = (comp > 2); | ||
216 | - if (reverse) { | ||
217 | - comp = 4 - comp; | ||
218 | - } | ||
219 | - genfn = fns[comp][size]; | ||
220 | - if (reverse) { | ||
221 | - genfn(tcg_res, tcg_zero, tcg_op); | ||
222 | - } else { | ||
223 | - genfn(tcg_res, tcg_op, tcg_zero); | ||
224 | - } | ||
225 | - tcg_temp_free_i32(tcg_zero); | ||
226 | - break; | ||
227 | - } | ||
228 | case 0x4: /* CLS, CLZ */ | ||
229 | if (u) { | ||
230 | if (size == 0) { | ||
136 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 231 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
137 | index XXXXXXX..XXXXXXX 100644 | 232 | index XXXXXXX..XXXXXXX 100644 |
138 | --- a/target/arm/translate.c | 233 | --- a/target/arm/translate.c |
139 | +++ b/target/arm/translate.c | 234 | +++ b/target/arm/translate.c |
235 | @@ -XXX,XX +XXX,XX @@ static int do_v81_helper(DisasContext *s, gen_helper_gvec_3_ptr *fn, | ||
236 | return 1; | ||
237 | } | ||
238 | |||
239 | +static void gen_ceq0_i32(TCGv_i32 d, TCGv_i32 a) | ||
240 | +{ | ||
241 | + tcg_gen_setcondi_i32(TCG_COND_EQ, d, a, 0); | ||
242 | + tcg_gen_neg_i32(d, d); | ||
243 | +} | ||
244 | + | ||
245 | +static void gen_ceq0_i64(TCGv_i64 d, TCGv_i64 a) | ||
246 | +{ | ||
247 | + tcg_gen_setcondi_i64(TCG_COND_EQ, d, a, 0); | ||
248 | + tcg_gen_neg_i64(d, d); | ||
249 | +} | ||
250 | + | ||
251 | +static void gen_ceq0_vec(unsigned vece, TCGv_vec d, TCGv_vec a) | ||
252 | +{ | ||
253 | + TCGv_vec zero = tcg_const_zeros_vec_matching(d); | ||
254 | + tcg_gen_cmp_vec(TCG_COND_EQ, vece, d, a, zero); | ||
255 | + tcg_temp_free_vec(zero); | ||
256 | +} | ||
257 | + | ||
258 | +static const TCGOpcode vecop_list_cmp[] = { | ||
259 | + INDEX_op_cmp_vec, 0 | ||
260 | +}; | ||
261 | + | ||
262 | +const GVecGen2 ceq0_op[4] = { | ||
263 | + { .fno = gen_helper_gvec_ceq0_b, | ||
264 | + .fniv = gen_ceq0_vec, | ||
265 | + .opt_opc = vecop_list_cmp, | ||
266 | + .vece = MO_8 }, | ||
267 | + { .fno = gen_helper_gvec_ceq0_h, | ||
268 | + .fniv = gen_ceq0_vec, | ||
269 | + .opt_opc = vecop_list_cmp, | ||
270 | + .vece = MO_16 }, | ||
271 | + { .fni4 = gen_ceq0_i32, | ||
272 | + .fniv = gen_ceq0_vec, | ||
273 | + .opt_opc = vecop_list_cmp, | ||
274 | + .vece = MO_32 }, | ||
275 | + { .fni8 = gen_ceq0_i64, | ||
276 | + .fniv = gen_ceq0_vec, | ||
277 | + .opt_opc = vecop_list_cmp, | ||
278 | + .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
279 | + .vece = MO_64 }, | ||
280 | +}; | ||
281 | + | ||
282 | +static void gen_cle0_i32(TCGv_i32 d, TCGv_i32 a) | ||
283 | +{ | ||
284 | + tcg_gen_setcondi_i32(TCG_COND_LE, d, a, 0); | ||
285 | + tcg_gen_neg_i32(d, d); | ||
286 | +} | ||
287 | + | ||
288 | +static void gen_cle0_i64(TCGv_i64 d, TCGv_i64 a) | ||
289 | +{ | ||
290 | + tcg_gen_setcondi_i64(TCG_COND_LE, d, a, 0); | ||
291 | + tcg_gen_neg_i64(d, d); | ||
292 | +} | ||
293 | + | ||
294 | +static void gen_cle0_vec(unsigned vece, TCGv_vec d, TCGv_vec a) | ||
295 | +{ | ||
296 | + TCGv_vec zero = tcg_const_zeros_vec_matching(d); | ||
297 | + tcg_gen_cmp_vec(TCG_COND_LE, vece, d, a, zero); | ||
298 | + tcg_temp_free_vec(zero); | ||
299 | +} | ||
300 | + | ||
301 | +const GVecGen2 cle0_op[4] = { | ||
302 | + { .fno = gen_helper_gvec_cle0_b, | ||
303 | + .fniv = gen_cle0_vec, | ||
304 | + .opt_opc = vecop_list_cmp, | ||
305 | + .vece = MO_8 }, | ||
306 | + { .fno = gen_helper_gvec_cle0_h, | ||
307 | + .fniv = gen_cle0_vec, | ||
308 | + .opt_opc = vecop_list_cmp, | ||
309 | + .vece = MO_16 }, | ||
310 | + { .fni4 = gen_cle0_i32, | ||
311 | + .fniv = gen_cle0_vec, | ||
312 | + .opt_opc = vecop_list_cmp, | ||
313 | + .vece = MO_32 }, | ||
314 | + { .fni8 = gen_cle0_i64, | ||
315 | + .fniv = gen_cle0_vec, | ||
316 | + .opt_opc = vecop_list_cmp, | ||
317 | + .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
318 | + .vece = MO_64 }, | ||
319 | +}; | ||
320 | + | ||
321 | +static void gen_cge0_i32(TCGv_i32 d, TCGv_i32 a) | ||
322 | +{ | ||
323 | + tcg_gen_setcondi_i32(TCG_COND_GE, d, a, 0); | ||
324 | + tcg_gen_neg_i32(d, d); | ||
325 | +} | ||
326 | + | ||
327 | +static void gen_cge0_i64(TCGv_i64 d, TCGv_i64 a) | ||
328 | +{ | ||
329 | + tcg_gen_setcondi_i64(TCG_COND_GE, d, a, 0); | ||
330 | + tcg_gen_neg_i64(d, d); | ||
331 | +} | ||
332 | + | ||
333 | +static void gen_cge0_vec(unsigned vece, TCGv_vec d, TCGv_vec a) | ||
334 | +{ | ||
335 | + TCGv_vec zero = tcg_const_zeros_vec_matching(d); | ||
336 | + tcg_gen_cmp_vec(TCG_COND_GE, vece, d, a, zero); | ||
337 | + tcg_temp_free_vec(zero); | ||
338 | +} | ||
339 | + | ||
340 | +const GVecGen2 cge0_op[4] = { | ||
341 | + { .fno = gen_helper_gvec_cge0_b, | ||
342 | + .fniv = gen_cge0_vec, | ||
343 | + .opt_opc = vecop_list_cmp, | ||
344 | + .vece = MO_8 }, | ||
345 | + { .fno = gen_helper_gvec_cge0_h, | ||
346 | + .fniv = gen_cge0_vec, | ||
347 | + .opt_opc = vecop_list_cmp, | ||
348 | + .vece = MO_16 }, | ||
349 | + { .fni4 = gen_cge0_i32, | ||
350 | + .fniv = gen_cge0_vec, | ||
351 | + .opt_opc = vecop_list_cmp, | ||
352 | + .vece = MO_32 }, | ||
353 | + { .fni8 = gen_cge0_i64, | ||
354 | + .fniv = gen_cge0_vec, | ||
355 | + .opt_opc = vecop_list_cmp, | ||
356 | + .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
357 | + .vece = MO_64 }, | ||
358 | +}; | ||
359 | + | ||
360 | +static void gen_clt0_i32(TCGv_i32 d, TCGv_i32 a) | ||
361 | +{ | ||
362 | + tcg_gen_setcondi_i32(TCG_COND_LT, d, a, 0); | ||
363 | + tcg_gen_neg_i32(d, d); | ||
364 | +} | ||
365 | + | ||
366 | +static void gen_clt0_i64(TCGv_i64 d, TCGv_i64 a) | ||
367 | +{ | ||
368 | + tcg_gen_setcondi_i64(TCG_COND_LT, d, a, 0); | ||
369 | + tcg_gen_neg_i64(d, d); | ||
370 | +} | ||
371 | + | ||
372 | +static void gen_clt0_vec(unsigned vece, TCGv_vec d, TCGv_vec a) | ||
373 | +{ | ||
374 | + TCGv_vec zero = tcg_const_zeros_vec_matching(d); | ||
375 | + tcg_gen_cmp_vec(TCG_COND_LT, vece, d, a, zero); | ||
376 | + tcg_temp_free_vec(zero); | ||
377 | +} | ||
378 | + | ||
379 | +const GVecGen2 clt0_op[4] = { | ||
380 | + { .fno = gen_helper_gvec_clt0_b, | ||
381 | + .fniv = gen_clt0_vec, | ||
382 | + .opt_opc = vecop_list_cmp, | ||
383 | + .vece = MO_8 }, | ||
384 | + { .fno = gen_helper_gvec_clt0_h, | ||
385 | + .fniv = gen_clt0_vec, | ||
386 | + .opt_opc = vecop_list_cmp, | ||
387 | + .vece = MO_16 }, | ||
388 | + { .fni4 = gen_clt0_i32, | ||
389 | + .fniv = gen_clt0_vec, | ||
390 | + .opt_opc = vecop_list_cmp, | ||
391 | + .vece = MO_32 }, | ||
392 | + { .fni8 = gen_clt0_i64, | ||
393 | + .fniv = gen_clt0_vec, | ||
394 | + .opt_opc = vecop_list_cmp, | ||
395 | + .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
396 | + .vece = MO_64 }, | ||
397 | +}; | ||
398 | + | ||
399 | +static void gen_cgt0_i32(TCGv_i32 d, TCGv_i32 a) | ||
400 | +{ | ||
401 | + tcg_gen_setcondi_i32(TCG_COND_GT, d, a, 0); | ||
402 | + tcg_gen_neg_i32(d, d); | ||
403 | +} | ||
404 | + | ||
405 | +static void gen_cgt0_i64(TCGv_i64 d, TCGv_i64 a) | ||
406 | +{ | ||
407 | + tcg_gen_setcondi_i64(TCG_COND_GT, d, a, 0); | ||
408 | + tcg_gen_neg_i64(d, d); | ||
409 | +} | ||
410 | + | ||
411 | +static void gen_cgt0_vec(unsigned vece, TCGv_vec d, TCGv_vec a) | ||
412 | +{ | ||
413 | + TCGv_vec zero = tcg_const_zeros_vec_matching(d); | ||
414 | + tcg_gen_cmp_vec(TCG_COND_GT, vece, d, a, zero); | ||
415 | + tcg_temp_free_vec(zero); | ||
416 | +} | ||
417 | + | ||
418 | +const GVecGen2 cgt0_op[4] = { | ||
419 | + { .fno = gen_helper_gvec_cgt0_b, | ||
420 | + .fniv = gen_cgt0_vec, | ||
421 | + .opt_opc = vecop_list_cmp, | ||
422 | + .vece = MO_8 }, | ||
423 | + { .fno = gen_helper_gvec_cgt0_h, | ||
424 | + .fniv = gen_cgt0_vec, | ||
425 | + .opt_opc = vecop_list_cmp, | ||
426 | + .vece = MO_16 }, | ||
427 | + { .fni4 = gen_cgt0_i32, | ||
428 | + .fniv = gen_cgt0_vec, | ||
429 | + .opt_opc = vecop_list_cmp, | ||
430 | + .vece = MO_32 }, | ||
431 | + { .fni8 = gen_cgt0_i64, | ||
432 | + .fniv = gen_cgt0_vec, | ||
433 | + .opt_opc = vecop_list_cmp, | ||
434 | + .prefer_i64 = TCG_TARGET_REG_BITS == 64, | ||
435 | + .vece = MO_64 }, | ||
436 | +}; | ||
437 | + | ||
438 | static void gen_ssra8_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | ||
439 | { | ||
440 | tcg_gen_vec_sar8i_i64(a, a, shift); | ||
140 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 441 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) |
141 | } | 442 | tcg_gen_gvec_abs(size, rd_ofs, rm_ofs, vec_size, vec_size); |
142 | return 0; | 443 | break; |
143 | 444 | ||
144 | - case NEON_3R_VADD_VSUB: | 445 | + case NEON_2RM_VCEQ0: |
145 | - if (u) { | 446 | + tcg_gen_gvec_2(rd_ofs, rm_ofs, vec_size, |
146 | - tcg_gen_gvec_sub(size, rd_ofs, rn_ofs, rm_ofs, | 447 | + vec_size, &ceq0_op[size]); |
147 | - vec_size, vec_size); | 448 | + break; |
148 | - } else { | 449 | + case NEON_2RM_VCGT0: |
149 | - tcg_gen_gvec_add(size, rd_ofs, rn_ofs, rm_ofs, | 450 | + tcg_gen_gvec_2(rd_ofs, rm_ofs, vec_size, |
150 | - vec_size, vec_size); | 451 | + vec_size, &cgt0_op[size]); |
151 | - } | 452 | + break; |
152 | - return 0; | 453 | + case NEON_2RM_VCLE0: |
153 | - | 454 | + tcg_gen_gvec_2(rd_ofs, rm_ofs, vec_size, |
154 | case NEON_3R_VQADD: | 455 | + vec_size, &cle0_op[size]); |
155 | tcg_gen_gvec_4(rd_ofs, offsetof(CPUARMState, vfp.qc), | 456 | + break; |
156 | rn_ofs, rm_ofs, vec_size, vec_size, | 457 | + case NEON_2RM_VCGE0: |
458 | + tcg_gen_gvec_2(rd_ofs, rm_ofs, vec_size, | ||
459 | + vec_size, &cge0_op[size]); | ||
460 | + break; | ||
461 | + case NEON_2RM_VCLT0: | ||
462 | + tcg_gen_gvec_2(rd_ofs, rm_ofs, vec_size, | ||
463 | + vec_size, &clt0_op[size]); | ||
464 | + break; | ||
465 | + | ||
466 | default: | ||
467 | elementwise: | ||
468 | for (pass = 0; pass < (q ? 4 : 2); pass++) { | ||
157 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 469 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) |
158 | tcg_gen_gvec_3(rd_ofs, rm_ofs, rn_ofs, vec_size, vec_size, | 470 | default: abort(); |
159 | u ? &ushl_op[size] : &sshl_op[size]); | 471 | } |
160 | return 0; | 472 | break; |
161 | + | 473 | - case NEON_2RM_VCGT0: case NEON_2RM_VCLE0: |
162 | + case NEON_3R_VADD_VSUB: | 474 | - tmp2 = tcg_const_i32(0); |
163 | + /* Already handled by decodetree */ | 475 | - switch(size) { |
164 | + return 1; | 476 | - case 0: gen_helper_neon_cgt_s8(tmp, tmp, tmp2); break; |
165 | } | 477 | - case 1: gen_helper_neon_cgt_s16(tmp, tmp, tmp2); break; |
166 | 478 | - case 2: gen_helper_neon_cgt_s32(tmp, tmp, tmp2); break; | |
167 | if (size == 3) { | 479 | - default: abort(); |
480 | - } | ||
481 | - tcg_temp_free_i32(tmp2); | ||
482 | - if (op == NEON_2RM_VCLE0) { | ||
483 | - tcg_gen_not_i32(tmp, tmp); | ||
484 | - } | ||
485 | - break; | ||
486 | - case NEON_2RM_VCGE0: case NEON_2RM_VCLT0: | ||
487 | - tmp2 = tcg_const_i32(0); | ||
488 | - switch(size) { | ||
489 | - case 0: gen_helper_neon_cge_s8(tmp, tmp, tmp2); break; | ||
490 | - case 1: gen_helper_neon_cge_s16(tmp, tmp, tmp2); break; | ||
491 | - case 2: gen_helper_neon_cge_s32(tmp, tmp, tmp2); break; | ||
492 | - default: abort(); | ||
493 | - } | ||
494 | - tcg_temp_free_i32(tmp2); | ||
495 | - if (op == NEON_2RM_VCLT0) { | ||
496 | - tcg_gen_not_i32(tmp, tmp); | ||
497 | - } | ||
498 | - break; | ||
499 | - case NEON_2RM_VCEQ0: | ||
500 | - tmp2 = tcg_const_i32(0); | ||
501 | - switch(size) { | ||
502 | - case 0: gen_helper_neon_ceq_u8(tmp, tmp, tmp2); break; | ||
503 | - case 1: gen_helper_neon_ceq_u16(tmp, tmp, tmp2); break; | ||
504 | - case 2: gen_helper_neon_ceq_u32(tmp, tmp, tmp2); break; | ||
505 | - default: abort(); | ||
506 | - } | ||
507 | - tcg_temp_free_i32(tmp2); | ||
508 | - break; | ||
509 | case NEON_2RM_VCGT0_F: | ||
510 | { | ||
511 | TCGv_ptr fpstatus = get_fpstatus_ptr(1); | ||
512 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | ||
513 | index XXXXXXX..XXXXXXX 100644 | ||
514 | --- a/target/arm/vec_helper.c | ||
515 | +++ b/target/arm/vec_helper.c | ||
516 | @@ -XXX,XX +XXX,XX @@ void HELPER(sve2_pmull_h)(void *vd, void *vn, void *vm, uint32_t desc) | ||
517 | } | ||
518 | } | ||
519 | #endif | ||
520 | + | ||
521 | +#define DO_CMP0(NAME, TYPE, OP) \ | ||
522 | +void HELPER(NAME)(void *vd, void *vn, uint32_t desc) \ | ||
523 | +{ \ | ||
524 | + intptr_t i, opr_sz = simd_oprsz(desc); \ | ||
525 | + for (i = 0; i < opr_sz; i += sizeof(TYPE)) { \ | ||
526 | + TYPE nn = *(TYPE *)(vn + i); \ | ||
527 | + *(TYPE *)(vd + i) = -(nn OP 0); \ | ||
528 | + } \ | ||
529 | + clear_tail(vd, opr_sz, simd_maxsz(desc)); \ | ||
530 | +} | ||
531 | + | ||
532 | +DO_CMP0(gvec_ceq0_b, int8_t, ==) | ||
533 | +DO_CMP0(gvec_clt0_b, int8_t, <) | ||
534 | +DO_CMP0(gvec_cle0_b, int8_t, <=) | ||
535 | +DO_CMP0(gvec_cgt0_b, int8_t, >) | ||
536 | +DO_CMP0(gvec_cge0_b, int8_t, >=) | ||
537 | + | ||
538 | +DO_CMP0(gvec_ceq0_h, int16_t, ==) | ||
539 | +DO_CMP0(gvec_clt0_h, int16_t, <) | ||
540 | +DO_CMP0(gvec_cle0_h, int16_t, <=) | ||
541 | +DO_CMP0(gvec_cgt0_h, int16_t, >) | ||
542 | +DO_CMP0(gvec_cge0_h, int16_t, >=) | ||
543 | + | ||
544 | +#undef DO_CMP0 | ||
168 | -- | 545 | -- |
169 | 2.20.1 | 546 | 2.20.1 |
170 | 547 | ||
171 | 548 | diff view generated by jsdifflib |
1 | Convert VCMLA (scalar) in the 2reg-scalar-ext group to decodetree. | 1 | From: Jerome Forissier <jerome@forissier.org> |
---|---|---|---|
2 | 2 | ||
3 | The /secure-chosen node is currently used only by create_uart(), but | ||
4 | this will change. Therefore move the creation of this node to | ||
5 | create_fdt(). | ||
6 | |||
7 | Signed-off-by: Jerome Forissier <jerome@forissier.org> | ||
8 | Message-id: 20200420121807.8204-2-jerome@forissier.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20200430181003.21682-9-peter.maydell@linaro.org | ||
6 | --- | 11 | --- |
7 | target/arm/neon-shared.decode | 5 +++++ | 12 | hw/arm/virt.c | 5 ++++- |
8 | target/arm/translate-neon.inc.c | 40 +++++++++++++++++++++++++++++++++ | 13 | 1 file changed, 4 insertions(+), 1 deletion(-) |
9 | target/arm/translate.c | 26 +-------------------- | ||
10 | 3 files changed, 46 insertions(+), 25 deletions(-) | ||
11 | 14 | ||
12 | diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode | 15 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
13 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/neon-shared.decode | 17 | --- a/hw/arm/virt.c |
15 | +++ b/target/arm/neon-shared.decode | 18 | +++ b/hw/arm/virt.c |
16 | @@ -XXX,XX +XXX,XX @@ VFML 1111 110 0 s:1 . 10 .... .... 1000 . 0 . 1 .... \ | 19 | @@ -XXX,XX +XXX,XX @@ static void create_fdt(VirtMachineState *vms) |
17 | vm=%vm_sp vn=%vn_sp vd=%vd_dp q=0 | 20 | /* /chosen must exist for load_dtb to fill in necessary properties later */ |
18 | VFML 1111 110 0 s:1 . 10 .... .... 1000 . 1 . 1 .... \ | 21 | qemu_fdt_add_subnode(fdt, "/chosen"); |
19 | vm=%vm_dp vn=%vn_dp vd=%vd_dp q=1 | 22 | |
20 | + | 23 | + if (vms->secure) { |
21 | +VCMLA_scalar 1111 1110 0 . rot:2 .... .... 1000 . q:1 index:1 0 vm:4 \ | 24 | + qemu_fdt_add_subnode(fdt, "/secure-chosen"); |
22 | + vn=%vn_dp vd=%vd_dp size=0 | ||
23 | +VCMLA_scalar 1111 1110 1 . rot:2 .... .... 1000 . q:1 . 0 .... \ | ||
24 | + vm=%vm_dp vn=%vn_dp vd=%vd_dp size=1 index=0 | ||
25 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/target/arm/translate-neon.inc.c | ||
28 | +++ b/target/arm/translate-neon.inc.c | ||
29 | @@ -XXX,XX +XXX,XX @@ static bool trans_VFML(DisasContext *s, arg_VFML *a) | ||
30 | gen_helper_gvec_fmlal_a32); | ||
31 | return true; | ||
32 | } | ||
33 | + | ||
34 | +static bool trans_VCMLA_scalar(DisasContext *s, arg_VCMLA_scalar *a) | ||
35 | +{ | ||
36 | + gen_helper_gvec_3_ptr *fn_gvec_ptr; | ||
37 | + int opr_sz; | ||
38 | + TCGv_ptr fpst; | ||
39 | + | ||
40 | + if (!dc_isar_feature(aa32_vcma, s)) { | ||
41 | + return false; | ||
42 | + } | ||
43 | + if (a->size == 0 && !dc_isar_feature(aa32_fp16_arith, s)) { | ||
44 | + return false; | ||
45 | + } | 25 | + } |
46 | + | 26 | + |
47 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | 27 | /* Clock node, for the benefit of the UART. The kernel device tree |
48 | + if (!dc_isar_feature(aa32_simd_r32, s) && | 28 | * binding documentation claims the PL011 node clock properties are |
49 | + ((a->vd | a->vn | a->vm) & 0x10)) { | 29 | * optional but in practice if you omit them the kernel refuses to |
50 | + return false; | 30 | @@ -XXX,XX +XXX,XX @@ static void create_uart(const VirtMachineState *vms, int uart, |
51 | + } | 31 | qemu_fdt_setprop_string(vms->fdt, nodename, "status", "disabled"); |
52 | + | 32 | qemu_fdt_setprop_string(vms->fdt, nodename, "secure-status", "okay"); |
53 | + if ((a->vd | a->vn) & a->q) { | 33 | |
54 | + return false; | 34 | - qemu_fdt_add_subnode(vms->fdt, "/secure-chosen"); |
55 | + } | 35 | qemu_fdt_setprop_string(vms->fdt, "/secure-chosen", "stdout-path", |
56 | + | 36 | nodename); |
57 | + if (!vfp_access_check(s)) { | 37 | } |
58 | + return true; | ||
59 | + } | ||
60 | + | ||
61 | + fn_gvec_ptr = (a->size ? gen_helper_gvec_fcmlas_idx | ||
62 | + : gen_helper_gvec_fcmlah_idx); | ||
63 | + opr_sz = (1 + a->q) * 8; | ||
64 | + fpst = get_fpstatus_ptr(1); | ||
65 | + tcg_gen_gvec_3_ptr(vfp_reg_offset(1, a->vd), | ||
66 | + vfp_reg_offset(1, a->vn), | ||
67 | + vfp_reg_offset(1, a->vm), | ||
68 | + fpst, opr_sz, opr_sz, | ||
69 | + (a->index << 2) | a->rot, fn_gvec_ptr); | ||
70 | + tcg_temp_free_ptr(fpst); | ||
71 | + return true; | ||
72 | +} | ||
73 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
74 | index XXXXXXX..XXXXXXX 100644 | ||
75 | --- a/target/arm/translate.c | ||
76 | +++ b/target/arm/translate.c | ||
77 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_2reg_scalar_ext(DisasContext *s, uint32_t insn) | ||
78 | bool is_long = false, q = extract32(insn, 6, 1); | ||
79 | bool ptr_is_env = false; | ||
80 | |||
81 | - if ((insn & 0xff000f10) == 0xfe000800) { | ||
82 | - /* VCMLA (indexed) -- 1111 1110 S.RR .... .... 1000 ...0 .... */ | ||
83 | - int rot = extract32(insn, 20, 2); | ||
84 | - int size = extract32(insn, 23, 1); | ||
85 | - int index; | ||
86 | - | ||
87 | - if (!dc_isar_feature(aa32_vcma, s)) { | ||
88 | - return 1; | ||
89 | - } | ||
90 | - if (size == 0) { | ||
91 | - if (!dc_isar_feature(aa32_fp16_arith, s)) { | ||
92 | - return 1; | ||
93 | - } | ||
94 | - /* For fp16, rm is just Vm, and index is M. */ | ||
95 | - rm = extract32(insn, 0, 4); | ||
96 | - index = extract32(insn, 5, 1); | ||
97 | - } else { | ||
98 | - /* For fp32, rm is the usual M:Vm, and index is 0. */ | ||
99 | - VFP_DREG_M(rm, insn); | ||
100 | - index = 0; | ||
101 | - } | ||
102 | - data = (index << 2) | rot; | ||
103 | - fn_gvec_ptr = (size ? gen_helper_gvec_fcmlas_idx | ||
104 | - : gen_helper_gvec_fcmlah_idx); | ||
105 | - } else if ((insn & 0xffb00f00) == 0xfe200d00) { | ||
106 | + if ((insn & 0xffb00f00) == 0xfe200d00) { | ||
107 | /* V[US]DOT -- 1111 1110 0.10 .... .... 1101 .Q.U .... */ | ||
108 | int u = extract32(insn, 4, 1); | ||
109 | |||
110 | -- | 38 | -- |
111 | 2.20.1 | 39 | 2.20.1 |
112 | 40 | ||
113 | 41 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: Jerome Forissier <jerome@forissier.org> |
---|---|---|---|
2 | 2 | ||
3 | Add support for the RTC. | 3 | Generate random seeds to be used by the non-secure and/or secure OSes |
4 | for ASLR. The seeds are 64-bit random values exported via the DT | ||
5 | properties /chosen/kaslr-seed [1] and /secure-chosen/kaslr-seed, the | ||
6 | latter being used by OP-TEE [2]. | ||
4 | 7 | ||
5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 8 | [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e5bc0c37c97e1 |
6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 9 | [2] https://github.com/OP-TEE/optee_os/commit/ef262691fe0e |
7 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | 10 | |
8 | Message-id: 20200427181649.26851-12-edgar.iglesias@gmail.com | 11 | Signed-off-by: Jerome Forissier <jerome@forissier.org> |
12 | Message-id: 20200420121807.8204-3-jerome@forissier.org | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 15 | --- |
11 | hw/arm/xlnx-versal-virt.c | 22 ++++++++++++++++++++++ | 16 | hw/arm/virt.c | 15 +++++++++++++++ |
12 | 1 file changed, 22 insertions(+) | 17 | 1 file changed, 15 insertions(+) |
13 | 18 | ||
14 | diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c | 19 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
15 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/arm/xlnx-versal-virt.c | 21 | --- a/hw/arm/virt.c |
17 | +++ b/hw/arm/xlnx-versal-virt.c | 22 | +++ b/hw/arm/virt.c |
18 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_sd_nodes(VersalVirt *s) | 23 | @@ -XXX,XX +XXX,XX @@ |
19 | } | 24 | #include "hw/acpi/generic_event_device.h" |
25 | #include "hw/virtio/virtio-iommu.h" | ||
26 | #include "hw/char/pl011.h" | ||
27 | +#include "qemu/guest-random.h" | ||
28 | |||
29 | #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \ | ||
30 | static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ | ||
31 | @@ -XXX,XX +XXX,XX @@ static bool cpu_type_valid(const char *cpu) | ||
32 | return false; | ||
20 | } | 33 | } |
21 | 34 | ||
22 | +static void fdt_add_rtc_node(VersalVirt *s) | 35 | +static void create_kaslr_seed(VirtMachineState *vms, const char *node) |
23 | +{ | 36 | +{ |
24 | + const char compat[] = "xlnx,zynqmp-rtc"; | 37 | + Error *err = NULL; |
25 | + const char interrupt_names[] = "alarm\0sec"; | 38 | + uint64_t seed; |
26 | + char *name = g_strdup_printf("/rtc@%x", MM_PMC_RTC); | ||
27 | + | 39 | + |
28 | + qemu_fdt_add_subnode(s->fdt, name); | 40 | + if (qemu_guest_getrandom(&seed, sizeof(seed), &err)) { |
29 | + | 41 | + error_free(err); |
30 | + qemu_fdt_setprop_cells(s->fdt, name, "interrupts", | 42 | + return; |
31 | + GIC_FDT_IRQ_TYPE_SPI, VERSAL_RTC_ALARM_IRQ, | 43 | + } |
32 | + GIC_FDT_IRQ_FLAGS_LEVEL_HI, | 44 | + qemu_fdt_setprop_u64(vms->fdt, node, "kaslr-seed", seed); |
33 | + GIC_FDT_IRQ_TYPE_SPI, VERSAL_RTC_SECONDS_IRQ, | ||
34 | + GIC_FDT_IRQ_FLAGS_LEVEL_HI); | ||
35 | + qemu_fdt_setprop(s->fdt, name, "interrupt-names", | ||
36 | + interrupt_names, sizeof(interrupt_names)); | ||
37 | + qemu_fdt_setprop_sized_cells(s->fdt, name, "reg", | ||
38 | + 2, MM_PMC_RTC, 2, MM_PMC_RTC_SIZE); | ||
39 | + qemu_fdt_setprop(s->fdt, name, "compatible", compat, sizeof(compat)); | ||
40 | + g_free(name); | ||
41 | +} | 45 | +} |
42 | + | 46 | + |
43 | static void fdt_nop_memory_nodes(void *fdt, Error **errp) | 47 | static void create_fdt(VirtMachineState *vms) |
44 | { | 48 | { |
45 | Error *err = NULL; | 49 | MachineState *ms = MACHINE(vms); |
46 | @@ -XXX,XX +XXX,XX @@ static void versal_virt_init(MachineState *machine) | 50 | @@ -XXX,XX +XXX,XX @@ static void create_fdt(VirtMachineState *vms) |
47 | fdt_add_timer_nodes(s); | 51 | |
48 | fdt_add_zdma_nodes(s); | 52 | /* /chosen must exist for load_dtb to fill in necessary properties later */ |
49 | fdt_add_sd_nodes(s); | 53 | qemu_fdt_add_subnode(fdt, "/chosen"); |
50 | + fdt_add_rtc_node(s); | 54 | + create_kaslr_seed(vms, "/chosen"); |
51 | fdt_add_cpu_nodes(s, psci_conduit); | 55 | |
52 | fdt_add_clk_node(s, "/clk125", 125000000, s->phandle.clk_125Mhz); | 56 | if (vms->secure) { |
53 | fdt_add_clk_node(s, "/clk25", 25000000, s->phandle.clk_25Mhz); | 57 | qemu_fdt_add_subnode(fdt, "/secure-chosen"); |
58 | + create_kaslr_seed(vms, "/secure-chosen"); | ||
59 | } | ||
60 | |||
61 | /* Clock node, for the benefit of the UART. The kernel device tree | ||
54 | -- | 62 | -- |
55 | 2.20.1 | 63 | 2.20.1 |
56 | 64 | ||
57 | 65 | diff view generated by jsdifflib |
1 | For ARMv8.2-TTS2UXN, the stage 2 page table walk wants to know | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | whether the stage 1 access is for EL0 or not, because whether | ||
3 | exec permission is given can depend on whether this is an EL0 | ||
4 | or EL1 access. Add a new argument to get_phys_addr_lpae() so | ||
5 | the call sites can pass this information in. | ||
6 | 2 | ||
7 | Since get_phys_addr_lpae() doesn't already have a doc comment, | 3 | Under KVM these registers are written by the hardware. |
8 | add one so we have a place to put the documentation of the | 4 | Restrict the writefn handlers to TCG to avoid when building |
9 | semantics of the new s1_is_el0 argument. | 5 | without TCG: |
10 | 6 | ||
7 | LINK aarch64-softmmu/qemu-system-aarch64 | ||
8 | target/arm/helper.o: In function `do_ats_write': | ||
9 | target/arm/helper.c:3524: undefined reference to `raise_exception' | ||
10 | |||
11 | Suggested-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
14 | Message-id: 20200423073358.27155-2-philmd@redhat.com | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20200330210400.11724-4-peter.maydell@linaro.org | ||
15 | --- | 16 | --- |
16 | target/arm/helper.c | 29 ++++++++++++++++++++++++++++- | 17 | target/arm/helper.c | 17 +++++++++++++++++ |
17 | 1 file changed, 28 insertions(+), 1 deletion(-) | 18 | 1 file changed, 17 insertions(+) |
18 | 19 | ||
19 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 20 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
20 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/helper.c | 22 | --- a/target/arm/helper.c |
22 | +++ b/target/arm/helper.c | 23 | +++ b/target/arm/helper.c |
23 | @@ -XXX,XX +XXX,XX @@ | 24 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult ats_access(CPUARMState *env, const ARMCPRegInfo *ri, |
24 | 25 | return CP_ACCESS_OK; | |
25 | static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, | ||
26 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
27 | + bool s1_is_el0, | ||
28 | hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot, | ||
29 | target_ulong *page_size_ptr, | ||
30 | ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs); | ||
31 | @@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, | ||
32 | } | ||
33 | |||
34 | ret = get_phys_addr_lpae(env, addr, MMU_DATA_LOAD, ARMMMUIdx_Stage2, | ||
35 | + false, | ||
36 | &s2pa, &txattrs, &s2prot, &s2size, fi, | ||
37 | pcacheattrs); | ||
38 | if (ret) { | ||
39 | @@ -XXX,XX +XXX,XX @@ static ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, | ||
40 | }; | ||
41 | } | 26 | } |
42 | 27 | ||
43 | +/** | 28 | +#ifdef CONFIG_TCG |
44 | + * get_phys_addr_lpae: perform one stage of page table walk, LPAE format | 29 | static uint64_t do_ats_write(CPUARMState *env, uint64_t value, |
45 | + * | 30 | MMUAccessType access_type, ARMMMUIdx mmu_idx) |
46 | + * Returns false if the translation was successful. Otherwise, phys_ptr, attrs, | 31 | { |
47 | + * prot and page_size may not be filled in, and the populated fsr value provides | 32 | @@ -XXX,XX +XXX,XX @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value, |
48 | + * information on why the translation aborted, in the format of a long-format | ||
49 | + * DFSR/IFSR fault register, with the following caveats: | ||
50 | + * * the WnR bit is never set (the caller must do this). | ||
51 | + * | ||
52 | + * @env: CPUARMState | ||
53 | + * @address: virtual address to get physical address for | ||
54 | + * @access_type: MMU_DATA_LOAD, MMU_DATA_STORE or MMU_INST_FETCH | ||
55 | + * @mmu_idx: MMU index indicating required translation regime | ||
56 | + * @s1_is_el0: if @mmu_idx is ARMMMUIdx_Stage2 (so this is a stage 2 page table | ||
57 | + * walk), must be true if this is stage 2 of a stage 1+2 walk for an | ||
58 | + * EL0 access). If @mmu_idx is anything else, @s1_is_el0 is ignored. | ||
59 | + * @phys_ptr: set to the physical address corresponding to the virtual address | ||
60 | + * @attrs: set to the memory transaction attributes to use | ||
61 | + * @prot: set to the permissions for the page containing phys_ptr | ||
62 | + * @page_size_ptr: set to the size of the page containing phys_ptr | ||
63 | + * @fi: set to fault info if the translation fails | ||
64 | + * @cacheattrs: (if non-NULL) set to the cacheability/shareability attributes | ||
65 | + */ | ||
66 | static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, | ||
67 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
68 | + bool s1_is_el0, | ||
69 | hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot, | ||
70 | target_ulong *page_size_ptr, | ||
71 | ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) | ||
72 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
73 | |||
74 | /* S1 is done. Now do S2 translation. */ | ||
75 | ret = get_phys_addr_lpae(env, ipa, access_type, ARMMMUIdx_Stage2, | ||
76 | + mmu_idx == ARMMMUIdx_E10_0, | ||
77 | phys_ptr, attrs, &s2_prot, | ||
78 | page_size, fi, | ||
79 | cacheattrs != NULL ? &cacheattrs2 : NULL); | ||
80 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
81 | } | 33 | } |
82 | 34 | return par64; | |
83 | if (regime_using_lpae_format(env, mmu_idx)) { | 35 | } |
84 | - return get_phys_addr_lpae(env, address, access_type, mmu_idx, | 36 | +#endif /* CONFIG_TCG */ |
85 | + return get_phys_addr_lpae(env, address, access_type, mmu_idx, false, | 37 | |
86 | phys_ptr, attrs, prot, page_size, | 38 | static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) |
87 | fi, cacheattrs); | 39 | { |
88 | } else if (regime_sctlr(env, mmu_idx) & SCTLR_XP) { | 40 | +#ifdef CONFIG_TCG |
41 | MMUAccessType access_type = ri->opc2 & 1 ? MMU_DATA_STORE : MMU_DATA_LOAD; | ||
42 | uint64_t par64; | ||
43 | ARMMMUIdx mmu_idx; | ||
44 | @@ -XXX,XX +XXX,XX @@ static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
45 | par64 = do_ats_write(env, value, access_type, mmu_idx); | ||
46 | |||
47 | A32_BANKED_CURRENT_REG_SET(env, par, par64); | ||
48 | +#else | ||
49 | + /* Handled by hardware accelerator. */ | ||
50 | + g_assert_not_reached(); | ||
51 | +#endif /* CONFIG_TCG */ | ||
52 | } | ||
53 | |||
54 | static void ats1h_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
55 | uint64_t value) | ||
56 | { | ||
57 | +#ifdef CONFIG_TCG | ||
58 | MMUAccessType access_type = ri->opc2 & 1 ? MMU_DATA_STORE : MMU_DATA_LOAD; | ||
59 | uint64_t par64; | ||
60 | |||
61 | par64 = do_ats_write(env, value, access_type, ARMMMUIdx_E2); | ||
62 | |||
63 | A32_BANKED_CURRENT_REG_SET(env, par, par64); | ||
64 | +#else | ||
65 | + /* Handled by hardware accelerator. */ | ||
66 | + g_assert_not_reached(); | ||
67 | +#endif /* CONFIG_TCG */ | ||
68 | } | ||
69 | |||
70 | static CPAccessResult at_s1e2_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
71 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult at_s1e2_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
72 | static void ats_write64(CPUARMState *env, const ARMCPRegInfo *ri, | ||
73 | uint64_t value) | ||
74 | { | ||
75 | +#ifdef CONFIG_TCG | ||
76 | MMUAccessType access_type = ri->opc2 & 1 ? MMU_DATA_STORE : MMU_DATA_LOAD; | ||
77 | ARMMMUIdx mmu_idx; | ||
78 | int secure = arm_is_secure_below_el3(env); | ||
79 | @@ -XXX,XX +XXX,XX @@ static void ats_write64(CPUARMState *env, const ARMCPRegInfo *ri, | ||
80 | } | ||
81 | |||
82 | env->cp15.par_el[1] = do_ats_write(env, value, access_type, mmu_idx); | ||
83 | +#else | ||
84 | + /* Handled by hardware accelerator. */ | ||
85 | + g_assert_not_reached(); | ||
86 | +#endif /* CONFIG_TCG */ | ||
87 | } | ||
88 | #endif | ||
89 | |||
89 | -- | 90 | -- |
90 | 2.20.1 | 91 | 2.20.1 |
91 | 92 | ||
92 | 93 | diff view generated by jsdifflib |
1 | The ARMv8.2-TTS2UXN feature extends the XN field in stage 2 | 1 | From: Thomas Huth <thuth@redhat.com> |
---|---|---|---|
2 | translation table descriptors from just bit [54] to bits [54:53], | ||
3 | allowing stage 2 to control execution permissions separately for EL0 | ||
4 | and EL1. Implement the new semantics of the XN field and enable | ||
5 | the feature for our 'max' CPU. | ||
6 | 2 | ||
3 | Make cpu_register() (renamed to arm_cpu_register()) available | ||
4 | from internals.h so we can register CPUs also from other files | ||
5 | in the future. | ||
6 | |||
7 | Signed-off-by: Thomas Huth <thuth@redhat.com> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
10 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
11 | Message-id: 20200423073358.27155-3-philmd@redhat.com | ||
12 | Message-ID: <20190921150420.30743-2-thuth@redhat.com> | ||
13 | [PMD: Only take cpu_register() from Thomas's patch] | ||
14 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20200330210400.11724-5-peter.maydell@linaro.org | ||
11 | --- | 16 | --- |
12 | target/arm/cpu.h | 15 +++++++++++++++ | 17 | target/arm/cpu-qom.h | 9 ++++++++- |
13 | target/arm/cpu.c | 1 + | 18 | target/arm/cpu.c | 10 ++-------- |
14 | target/arm/cpu64.c | 2 ++ | 19 | target/arm/cpu64.c | 8 +------- |
15 | target/arm/helper.c | 37 +++++++++++++++++++++++++++++++------ | 20 | 3 files changed, 11 insertions(+), 16 deletions(-) |
16 | 4 files changed, 49 insertions(+), 6 deletions(-) | ||
17 | 21 | ||
18 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 22 | diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h |
19 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/cpu.h | 24 | --- a/target/arm/cpu-qom.h |
21 | +++ b/target/arm/cpu.h | 25 | +++ b/target/arm/cpu-qom.h |
22 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_ccidx(const ARMISARegisters *id) | 26 | @@ -XXX,XX +XXX,XX @@ struct arm_boot_info; |
23 | return FIELD_EX32(id->id_mmfr4, ID_MMFR4, CCIDX) != 0; | 27 | |
24 | } | 28 | #define TYPE_ARM_MAX_CPU "max-" TYPE_ARM_CPU |
25 | 29 | ||
26 | +static inline bool isar_feature_aa32_tts2uxn(const ARMISARegisters *id) | 30 | -typedef struct ARMCPUInfo ARMCPUInfo; |
27 | +{ | 31 | +typedef struct ARMCPUInfo { |
28 | + return FIELD_EX32(id->id_mmfr4, ID_MMFR4, XNX) != 0; | 32 | + const char *name; |
29 | +} | 33 | + void (*initfn)(Object *obj); |
34 | + void (*class_init)(ObjectClass *oc, void *data); | ||
35 | +} ARMCPUInfo; | ||
30 | + | 36 | + |
31 | /* | 37 | +void arm_cpu_register(const ARMCPUInfo *info); |
32 | * 64-bit feature tests via id registers. | 38 | +void aarch64_cpu_register(const ARMCPUInfo *info); |
33 | */ | 39 | |
34 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_ccidx(const ARMISARegisters *id) | 40 | /** |
35 | return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, CCIDX) != 0; | 41 | * ARMCPUClass: |
36 | } | ||
37 | |||
38 | +static inline bool isar_feature_aa64_tts2uxn(const ARMISARegisters *id) | ||
39 | +{ | ||
40 | + return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, XNX) != 0; | ||
41 | +} | ||
42 | + | ||
43 | /* | ||
44 | * Feature tests for "does this exist in either 32-bit or 64-bit?" | ||
45 | */ | ||
46 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_any_ccidx(const ARMISARegisters *id) | ||
47 | return isar_feature_aa64_ccidx(id) || isar_feature_aa32_ccidx(id); | ||
48 | } | ||
49 | |||
50 | +static inline bool isar_feature_any_tts2uxn(const ARMISARegisters *id) | ||
51 | +{ | ||
52 | + return isar_feature_aa64_tts2uxn(id) || isar_feature_aa32_tts2uxn(id); | ||
53 | +} | ||
54 | + | ||
55 | /* | ||
56 | * Forward to the above feature tests given an ARMCPU pointer. | ||
57 | */ | ||
58 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 42 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
59 | index XXXXXXX..XXXXXXX 100644 | 43 | index XXXXXXX..XXXXXXX 100644 |
60 | --- a/target/arm/cpu.c | 44 | --- a/target/arm/cpu.c |
61 | +++ b/target/arm/cpu.c | 45 | +++ b/target/arm/cpu.c |
62 | @@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj) | 46 | @@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj) |
63 | t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */ | 47 | |
64 | t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ | 48 | #endif /* !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) */ |
65 | t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* TTCNP */ | 49 | |
66 | + t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* TTS2UXN */ | 50 | -struct ARMCPUInfo { |
67 | cpu->isar.id_mmfr4 = t; | 51 | - const char *name; |
68 | } | 52 | - void (*initfn)(Object *obj); |
69 | #endif | 53 | - void (*class_init)(ObjectClass *oc, void *data); |
54 | -}; | ||
55 | - | ||
56 | static const ARMCPUInfo arm_cpus[] = { | ||
57 | #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) | ||
58 | { .name = "arm926", .initfn = arm926_initfn }, | ||
59 | @@ -XXX,XX +XXX,XX @@ static void cpu_register_class_init(ObjectClass *oc, void *data) | ||
60 | acc->info = data; | ||
61 | } | ||
62 | |||
63 | -static void cpu_register(const ARMCPUInfo *info) | ||
64 | +void arm_cpu_register(const ARMCPUInfo *info) | ||
65 | { | ||
66 | TypeInfo type_info = { | ||
67 | .parent = TYPE_ARM_CPU, | ||
68 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_register_types(void) | ||
69 | type_register_static(&idau_interface_type_info); | ||
70 | |||
71 | while (info->name) { | ||
72 | - cpu_register(info); | ||
73 | + arm_cpu_register(info); | ||
74 | info++; | ||
75 | } | ||
76 | |||
70 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 77 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
71 | index XXXXXXX..XXXXXXX 100644 | 78 | index XXXXXXX..XXXXXXX 100644 |
72 | --- a/target/arm/cpu64.c | 79 | --- a/target/arm/cpu64.c |
73 | +++ b/target/arm/cpu64.c | 80 | +++ b/target/arm/cpu64.c |
74 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 81 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
75 | t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1); | 82 | cpu_max_set_sve_max_vq, NULL, NULL, &error_fatal); |
76 | t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 2); /* ATS1E1 */ | 83 | } |
77 | t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* VMID16 */ | 84 | |
78 | + t = FIELD_DP64(t, ID_AA64MMFR1, XNX, 1); /* TTS2UXN */ | 85 | -struct ARMCPUInfo { |
79 | cpu->isar.id_aa64mmfr1 = t; | 86 | - const char *name; |
80 | 87 | - void (*initfn)(Object *obj); | |
81 | t = cpu->isar.id_aa64mmfr2; | 88 | - void (*class_init)(ObjectClass *oc, void *data); |
82 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 89 | -}; |
83 | u = FIELD_DP32(u, ID_MMFR4, HPDS, 1); /* AA32HPD */ | 90 | - |
84 | u = FIELD_DP32(u, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ | 91 | static const ARMCPUInfo aarch64_cpus[] = { |
85 | u = FIELD_DP32(u, ID_MMFR4, CNP, 1); /* TTCNP */ | 92 | { .name = "cortex-a57", .initfn = aarch64_a57_initfn }, |
86 | + u = FIELD_DP32(u, ID_MMFR4, XNX, 1); /* TTS2UXN */ | 93 | { .name = "cortex-a53", .initfn = aarch64_a53_initfn }, |
87 | cpu->isar.id_mmfr4 = u; | 94 | @@ -XXX,XX +XXX,XX @@ static void cpu_register_class_init(ObjectClass *oc, void *data) |
88 | 95 | acc->info = data; | |
89 | u = cpu->isar.id_aa64dfr0; | 96 | } |
90 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 97 | |
91 | index XXXXXXX..XXXXXXX 100644 | 98 | -static void aarch64_cpu_register(const ARMCPUInfo *info) |
92 | --- a/target/arm/helper.c | 99 | +void aarch64_cpu_register(const ARMCPUInfo *info) |
93 | +++ b/target/arm/helper.c | ||
94 | @@ -XXX,XX +XXX,XX @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap) | ||
95 | * | ||
96 | * @env: CPUARMState | ||
97 | * @s2ap: The 2-bit stage2 access permissions (S2AP) | ||
98 | - * @xn: XN (execute-never) bit | ||
99 | + * @xn: XN (execute-never) bits | ||
100 | + * @s1_is_el0: true if this is S2 of an S1+2 walk for EL0 | ||
101 | */ | ||
102 | -static int get_S2prot(CPUARMState *env, int s2ap, int xn) | ||
103 | +static int get_S2prot(CPUARMState *env, int s2ap, int xn, bool s1_is_el0) | ||
104 | { | 100 | { |
105 | int prot = 0; | 101 | TypeInfo type_info = { |
106 | 102 | .parent = TYPE_AARCH64_CPU, | |
107 | @@ -XXX,XX +XXX,XX @@ static int get_S2prot(CPUARMState *env, int s2ap, int xn) | ||
108 | if (s2ap & 2) { | ||
109 | prot |= PAGE_WRITE; | ||
110 | } | ||
111 | - if (!xn) { | ||
112 | - if (arm_el_is_aa64(env, 2) || prot & PAGE_READ) { | ||
113 | + | ||
114 | + if (cpu_isar_feature(any_tts2uxn, env_archcpu(env))) { | ||
115 | + switch (xn) { | ||
116 | + case 0: | ||
117 | prot |= PAGE_EXEC; | ||
118 | + break; | ||
119 | + case 1: | ||
120 | + if (s1_is_el0) { | ||
121 | + prot |= PAGE_EXEC; | ||
122 | + } | ||
123 | + break; | ||
124 | + case 2: | ||
125 | + break; | ||
126 | + case 3: | ||
127 | + if (!s1_is_el0) { | ||
128 | + prot |= PAGE_EXEC; | ||
129 | + } | ||
130 | + break; | ||
131 | + default: | ||
132 | + g_assert_not_reached(); | ||
133 | + } | ||
134 | + } else { | ||
135 | + if (!extract32(xn, 1, 1)) { | ||
136 | + if (arm_el_is_aa64(env, 2) || prot & PAGE_READ) { | ||
137 | + prot |= PAGE_EXEC; | ||
138 | + } | ||
139 | } | ||
140 | } | ||
141 | return prot; | ||
142 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, | ||
143 | } | ||
144 | |||
145 | ap = extract32(attrs, 4, 2); | ||
146 | - xn = extract32(attrs, 12, 1); | ||
147 | |||
148 | if (mmu_idx == ARMMMUIdx_Stage2) { | ||
149 | ns = true; | ||
150 | - *prot = get_S2prot(env, ap, xn); | ||
151 | + xn = extract32(attrs, 11, 2); | ||
152 | + *prot = get_S2prot(env, ap, xn, s1_is_el0); | ||
153 | } else { | ||
154 | ns = extract32(attrs, 3, 1); | ||
155 | + xn = extract32(attrs, 12, 1); | ||
156 | pxn = extract32(attrs, 11, 1); | ||
157 | *prot = get_S1prot(env, mmu_idx, aarch64, ap, ns, xn, pxn); | ||
158 | } | ||
159 | -- | 103 | -- |
160 | 2.20.1 | 104 | 2.20.1 |
161 | 105 | ||
162 | 106 | diff view generated by jsdifflib |
1 | In aarch64_max_initfn() we update both 32-bit and 64-bit ID | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | registers. The intended pattern is that for 64-bit ID registers we | ||
3 | use FIELD_DP64 and the uint64_t 't' register, while 32-bit ID | ||
4 | registers use FIELD_DP32 and the uint32_t 'u' register. For | ||
5 | ID_AA64DFR0 we accidentally used 'u', meaning that the top 32 bits of | ||
6 | this 64-bit ID register would end up always zero. Luckily at the | ||
7 | moment that's what they should be anyway, so this bug has no visible | ||
8 | effects. | ||
9 | 2 | ||
10 | Use the right-sized variable. | 3 | Suggested-by: Richard Henderson <richard.henderson@linaro.org> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
6 | Message-id: 20200423073358.27155-4-philmd@redhat.com | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | --- | ||
9 | target/arm/cpu.c | 8 +++----- | ||
10 | target/arm/cpu64.c | 8 +++----- | ||
11 | 2 files changed, 6 insertions(+), 10 deletions(-) | ||
11 | 12 | ||
12 | Fixes: 3bec78447a958d481991 | 13 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | index XXXXXXX..XXXXXXX 100644 |
14 | Reviewed-by: Laurent Desnogues <laurent.desnogues@gmail.com> | 15 | --- a/target/arm/cpu.c |
15 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 16 | +++ b/target/arm/cpu.c |
16 | Message-id: 20200423110915.10527-1-peter.maydell@linaro.org | 17 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_cpus[] = { |
17 | --- | 18 | { .name = "any", .initfn = arm_max_initfn }, |
18 | target/arm/cpu64.c | 6 +++--- | 19 | #endif |
19 | 1 file changed, 3 insertions(+), 3 deletions(-) | 20 | #endif |
20 | 21 | - { .name = NULL } | |
22 | }; | ||
23 | |||
24 | static Property arm_cpu_properties[] = { | ||
25 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo idau_interface_type_info = { | ||
26 | |||
27 | static void arm_cpu_register_types(void) | ||
28 | { | ||
29 | - const ARMCPUInfo *info = arm_cpus; | ||
30 | + size_t i; | ||
31 | |||
32 | type_register_static(&arm_cpu_type_info); | ||
33 | type_register_static(&idau_interface_type_info); | ||
34 | |||
35 | - while (info->name) { | ||
36 | - arm_cpu_register(info); | ||
37 | - info++; | ||
38 | + for (i = 0; i < ARRAY_SIZE(arm_cpus); ++i) { | ||
39 | + arm_cpu_register(&arm_cpus[i]); | ||
40 | } | ||
41 | |||
42 | #ifdef CONFIG_KVM | ||
21 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 43 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
22 | index XXXXXXX..XXXXXXX 100644 | 44 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/target/arm/cpu64.c | 45 | --- a/target/arm/cpu64.c |
24 | +++ b/target/arm/cpu64.c | 46 | +++ b/target/arm/cpu64.c |
25 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 47 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo aarch64_cpus[] = { |
26 | u = FIELD_DP32(u, ID_MMFR4, XNX, 1); /* TTS2UXN */ | 48 | { .name = "cortex-a53", .initfn = aarch64_a53_initfn }, |
27 | cpu->isar.id_mmfr4 = u; | 49 | { .name = "cortex-a72", .initfn = aarch64_a72_initfn }, |
28 | 50 | { .name = "max", .initfn = aarch64_max_initfn }, | |
29 | - u = cpu->isar.id_aa64dfr0; | 51 | - { .name = NULL } |
30 | - u = FIELD_DP64(u, ID_AA64DFR0, PMUVER, 5); /* v8.4-PMU */ | 52 | }; |
31 | - cpu->isar.id_aa64dfr0 = u; | 53 | |
32 | + t = cpu->isar.id_aa64dfr0; | 54 | static bool aarch64_cpu_get_aarch64(Object *obj, Error **errp) |
33 | + t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 5); /* v8.4-PMU */ | 55 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo aarch64_cpu_type_info = { |
34 | + cpu->isar.id_aa64dfr0 = t; | 56 | |
35 | 57 | static void aarch64_cpu_register_types(void) | |
36 | u = cpu->isar.id_dfr0; | 58 | { |
37 | u = FIELD_DP32(u, ID_DFR0, PERFMON, 5); /* v8.4-PMU */ | 59 | - const ARMCPUInfo *info = aarch64_cpus; |
60 | + size_t i; | ||
61 | |||
62 | type_register_static(&aarch64_cpu_type_info); | ||
63 | |||
64 | - while (info->name) { | ||
65 | - aarch64_cpu_register(info); | ||
66 | - info++; | ||
67 | + for (i = 0; i < ARRAY_SIZE(aarch64_cpus); ++i) { | ||
68 | + aarch64_cpu_register(&aarch64_cpus[i]); | ||
69 | } | ||
70 | } | ||
71 | |||
38 | -- | 72 | -- |
39 | 2.20.1 | 73 | 2.20.1 |
40 | 74 | ||
41 | 75 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | MIDR_EL1 is a 64-bit system register with the top 32-bit being RES0. | 3 | We will move this code in the next commit. Clean it up |
4 | Represent it in QEMU's ARMCPU struct with a uint64_t, not a | 4 | first to avoid checkpatch.pl errors. |
5 | uint32_t. | ||
6 | 5 | ||
7 | This fixes an error when compiling with -Werror=conversion | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | because we were manipulating the register value using a | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
9 | local uint64_t variable: | 8 | Message-id: 20200423073358.27155-5-philmd@redhat.com |
10 | |||
11 | target/arm/cpu64.c: In function ‘aarch64_max_initfn’: | ||
12 | target/arm/cpu64.c:628:21: error: conversion from ‘uint64_t’ {aka ‘long unsigned int’} to ‘uint32_t’ {aka ‘unsigned int’} may change value [-Werror=conversion] | ||
13 | 628 | cpu->midr = t; | ||
14 | | ^ | ||
15 | |||
16 | and future-proofs us against a possible future architecture | ||
17 | change using some of the top 32 bits. | ||
18 | |||
19 | Suggested-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
20 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> | ||
21 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
22 | Reviewed-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
23 | Message-id: 20200428172634.29707-1-f4bug@amsat.org | ||
24 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
25 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
26 | --- | 10 | --- |
27 | target/arm/cpu.h | 2 +- | 11 | target/arm/cpu.c | 9 ++++++--- |
28 | target/arm/cpu.c | 2 +- | 12 | 1 file changed, 6 insertions(+), 3 deletions(-) |
29 | 2 files changed, 2 insertions(+), 2 deletions(-) | ||
30 | 13 | ||
31 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/target/arm/cpu.h | ||
34 | +++ b/target/arm/cpu.h | ||
35 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | ||
36 | uint64_t id_aa64dfr0; | ||
37 | uint64_t id_aa64dfr1; | ||
38 | } isar; | ||
39 | - uint32_t midr; | ||
40 | + uint64_t midr; | ||
41 | uint32_t revidr; | ||
42 | uint32_t reset_fpsid; | ||
43 | uint32_t ctr; | ||
44 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 14 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
45 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
46 | --- a/target/arm/cpu.c | 16 | --- a/target/arm/cpu.c |
47 | +++ b/target/arm/cpu.c | 17 | +++ b/target/arm/cpu.c |
18 | @@ -XXX,XX +XXX,XX @@ static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request) | ||
19 | CPUARMState *env = &cpu->env; | ||
20 | bool ret = false; | ||
21 | |||
22 | - /* ARMv7-M interrupt masking works differently than -A or -R. | ||
23 | + /* | ||
24 | + * ARMv7-M interrupt masking works differently than -A or -R. | ||
25 | * There is no FIQ/IRQ distinction. Instead of I and F bits | ||
26 | * masking FIQ and IRQ interrupts, an exception is taken only | ||
27 | * if it is higher priority than the current execution priority | ||
28 | @@ -XXX,XX +XXX,XX @@ static void arm1026_initfn(Object *obj) | ||
29 | static void arm1136_r2_initfn(Object *obj) | ||
30 | { | ||
31 | ARMCPU *cpu = ARM_CPU(obj); | ||
32 | - /* What qemu calls "arm1136_r2" is actually the 1136 r0p2, ie an | ||
33 | + /* | ||
34 | + * What qemu calls "arm1136_r2" is actually the 1136 r0p2, ie an | ||
35 | * older core than plain "arm1136". In particular this does not | ||
36 | * have the v6K features. | ||
37 | * These ID register values are correct for 1136 but may be wrong | ||
48 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_cpus[] = { | 38 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_cpus[] = { |
49 | static Property arm_cpu_properties[] = { | 39 | { .name = "arm926", .initfn = arm926_initfn }, |
50 | DEFINE_PROP_BOOL("start-powered-off", ARMCPU, start_powered_off, false), | 40 | { .name = "arm946", .initfn = arm946_initfn }, |
51 | DEFINE_PROP_UINT32("psci-conduit", ARMCPU, psci_conduit, 0), | 41 | { .name = "arm1026", .initfn = arm1026_initfn }, |
52 | - DEFINE_PROP_UINT32("midr", ARMCPU, midr, 0), | 42 | - /* What QEMU calls "arm1136-r2" is actually the 1136 r0p2, i.e. an |
53 | + DEFINE_PROP_UINT64("midr", ARMCPU, midr, 0), | 43 | + /* |
54 | DEFINE_PROP_UINT64("mp-affinity", ARMCPU, | 44 | + * What QEMU calls "arm1136-r2" is actually the 1136 r0p2, i.e. an |
55 | mp_affinity, ARM64_AFFINITY_INVALID), | 45 | * older core than plain "arm1136". In particular this does not |
56 | DEFINE_PROP_INT32("node-id", ARMCPU, node_id, CPU_UNSET_NUMA_NODE_ID), | 46 | * have the v6K features. |
47 | */ | ||
57 | -- | 48 | -- |
58 | 2.20.1 | 49 | 2.20.1 |
59 | 50 | ||
60 | 51 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> |
---|---|---|---|
2 | 2 | ||
3 | Embed the GEMs into the SoC type. | 3 | Allow name wildcards in qemu_fdt_node_path(). This is useful |
4 | to find all nodes with a given compatibility string. | ||
4 | 5 | ||
5 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
6 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 7 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> |
7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 8 | Message-id: 20200423121114.4274-2-edgar.iglesias@gmail.com |
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | ||
10 | Message-id: 20200427181649.26851-6-edgar.iglesias@gmail.com | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 10 | --- |
13 | include/hw/arm/xlnx-versal.h | 3 ++- | 11 | include/sysemu/device_tree.h | 3 +++ |
14 | hw/arm/xlnx-versal.c | 15 ++++++++------- | 12 | device_tree.c | 2 +- |
15 | 2 files changed, 10 insertions(+), 8 deletions(-) | 13 | 2 files changed, 4 insertions(+), 1 deletion(-) |
16 | 14 | ||
17 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h | 15 | diff --git a/include/sysemu/device_tree.h b/include/sysemu/device_tree.h |
18 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/hw/arm/xlnx-versal.h | 17 | --- a/include/sysemu/device_tree.h |
20 | +++ b/include/hw/arm/xlnx-versal.h | 18 | +++ b/include/sysemu/device_tree.h |
21 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ void *load_device_tree_from_sysfs(void); |
22 | #include "hw/arm/boot.h" | 20 | * NULL. If there is no error but no matching node was found, the |
23 | #include "hw/intc/arm_gicv3.h" | 21 | * returned array contains a single element equal to NULL. If an error |
24 | #include "hw/char/pl011.h" | 22 | * was encountered when parsing the blob, the function returns NULL |
25 | +#include "hw/net/cadence_gem.h" | 23 | + * |
26 | 24 | + * @name may be NULL to wildcard names and only match compatibility | |
27 | #define TYPE_XLNX_VERSAL "xlnx-versal" | 25 | + * strings. |
28 | #define XLNX_VERSAL(obj) OBJECT_CHECK(Versal, (obj), TYPE_XLNX_VERSAL) | 26 | */ |
29 | @@ -XXX,XX +XXX,XX @@ typedef struct Versal { | 27 | char **qemu_fdt_node_path(void *fdt, const char *name, char *compat, |
30 | 28 | Error **errp); | |
31 | struct { | 29 | diff --git a/device_tree.c b/device_tree.c |
32 | PL011State uart[XLNX_VERSAL_NR_UARTS]; | ||
33 | - SysBusDevice *gem[XLNX_VERSAL_NR_GEMS]; | ||
34 | + CadenceGEMState gem[XLNX_VERSAL_NR_GEMS]; | ||
35 | SysBusDevice *adma[XLNX_VERSAL_NR_ADMAS]; | ||
36 | } iou; | ||
37 | } lpd; | ||
38 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
40 | --- a/hw/arm/xlnx-versal.c | 31 | --- a/device_tree.c |
41 | +++ b/hw/arm/xlnx-versal.c | 32 | +++ b/device_tree.c |
42 | @@ -XXX,XX +XXX,XX @@ static void versal_create_gems(Versal *s, qemu_irq *pic) | 33 | @@ -XXX,XX +XXX,XX @@ char **qemu_fdt_node_path(void *fdt, const char *name, char *compat, |
43 | DeviceState *dev; | 34 | offset = len; |
44 | MemoryRegion *mr; | 35 | break; |
45 | |||
46 | - dev = qdev_create(NULL, "cadence_gem"); | ||
47 | - s->lpd.iou.gem[i] = SYS_BUS_DEVICE(dev); | ||
48 | - object_property_add_child(OBJECT(s), name, OBJECT(dev), &error_fatal); | ||
49 | + sysbus_init_child_obj(OBJECT(s), name, | ||
50 | + &s->lpd.iou.gem[i], sizeof(s->lpd.iou.gem[i]), | ||
51 | + TYPE_CADENCE_GEM); | ||
52 | + dev = DEVICE(&s->lpd.iou.gem[i]); | ||
53 | if (nd->used) { | ||
54 | qemu_check_nic_model(nd, "cadence_gem"); | ||
55 | qdev_set_nic_properties(dev, nd); | ||
56 | } | 36 | } |
57 | - object_property_set_int(OBJECT(s->lpd.iou.gem[i]), | 37 | - if (!strcmp(iter_name, name)) { |
58 | + object_property_set_int(OBJECT(dev), | 38 | + if (!name || !strcmp(iter_name, name)) { |
59 | 2, "num-priority-queues", | 39 | char *path; |
60 | &error_abort); | 40 | |
61 | - object_property_set_link(OBJECT(s->lpd.iou.gem[i]), | 41 | path = g_malloc(path_len); |
62 | + object_property_set_link(OBJECT(dev), | ||
63 | OBJECT(&s->mr_ps), "dma", | ||
64 | &error_abort); | ||
65 | qdev_init_nofail(dev); | ||
66 | |||
67 | - mr = sysbus_mmio_get_region(s->lpd.iou.gem[i], 0); | ||
68 | + mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0); | ||
69 | memory_region_add_subregion(&s->mr_ps, addrs[i], mr); | ||
70 | |||
71 | - sysbus_connect_irq(s->lpd.iou.gem[i], 0, pic[irqs[i]]); | ||
72 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[irqs[i]]); | ||
73 | g_free(name); | ||
74 | } | ||
75 | } | ||
76 | -- | 42 | -- |
77 | 2.20.1 | 43 | 2.20.1 |
78 | 44 | ||
79 | 45 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> |
---|---|---|---|
2 | 2 | ||
3 | Move misplaced comment. | 3 | Make compat in qemu_fdt_node_path() const char *. |
4 | 4 | ||
5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> |
6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 6 | Message-id: 20200423121114.4274-3-edgar.iglesias@gmail.com |
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | ||
9 | Message-id: 20200427181649.26851-3-edgar.iglesias@gmail.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 9 | --- |
12 | hw/arm/xlnx-versal.c | 2 +- | 10 | include/sysemu/device_tree.h | 2 +- |
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | 11 | device_tree.c | 2 +- |
12 | 2 files changed, 2 insertions(+), 2 deletions(-) | ||
14 | 13 | ||
15 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c | 14 | diff --git a/include/sysemu/device_tree.h b/include/sysemu/device_tree.h |
16 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/xlnx-versal.c | 16 | --- a/include/sysemu/device_tree.h |
18 | +++ b/hw/arm/xlnx-versal.c | 17 | +++ b/include/sysemu/device_tree.h |
19 | @@ -XXX,XX +XXX,XX @@ static void versal_create_apu_cpus(Versal *s) | 18 | @@ -XXX,XX +XXX,XX @@ void *load_device_tree_from_sysfs(void); |
20 | 19 | * @name may be NULL to wildcard names and only match compatibility | |
21 | obj = object_new(XLNX_VERSAL_ACPU_TYPE); | 20 | * strings. |
22 | if (!obj) { | 21 | */ |
23 | - /* Secondary CPUs start in PSCI powered-down state */ | 22 | -char **qemu_fdt_node_path(void *fdt, const char *name, char *compat, |
24 | error_report("Unable to create apu.cpu[%d] of type %s", | 23 | +char **qemu_fdt_node_path(void *fdt, const char *name, const char *compat, |
25 | i, XLNX_VERSAL_ACPU_TYPE); | 24 | Error **errp); |
26 | exit(EXIT_FAILURE); | 25 | |
27 | @@ -XXX,XX +XXX,XX @@ static void versal_create_apu_cpus(Versal *s) | 26 | /** |
28 | object_property_set_int(obj, s->cfg.psci_conduit, | 27 | diff --git a/device_tree.c b/device_tree.c |
29 | "psci-conduit", &error_abort); | 28 | index XXXXXXX..XXXXXXX 100644 |
30 | if (i) { | 29 | --- a/device_tree.c |
31 | + /* Secondary CPUs start in PSCI powered-down state */ | 30 | +++ b/device_tree.c |
32 | object_property_set_bool(obj, true, | 31 | @@ -XXX,XX +XXX,XX @@ char **qemu_fdt_node_unit_path(void *fdt, const char *name, Error **errp) |
33 | "start-powered-off", &error_abort); | 32 | return path_array; |
34 | } | 33 | } |
34 | |||
35 | -char **qemu_fdt_node_path(void *fdt, const char *name, char *compat, | ||
36 | +char **qemu_fdt_node_path(void *fdt, const char *name, const char *compat, | ||
37 | Error **errp) | ||
38 | { | ||
39 | int offset, len, ret; | ||
35 | -- | 40 | -- |
36 | 2.20.1 | 41 | 2.20.1 |
37 | 42 | ||
38 | 43 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> |
---|---|---|---|
2 | 2 | ||
3 | Embed the UARTs into the SoC type. | 3 | Move arm_boot_info into XlnxZCU102. |
4 | 4 | ||
5 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
6 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 6 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> |
7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 7 | Message-id: 20200423121114.4274-4-edgar.iglesias@gmail.com |
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | ||
10 | Message-id: 20200427181649.26851-5-edgar.iglesias@gmail.com | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 9 | --- |
13 | include/hw/arm/xlnx-versal.h | 3 ++- | 10 | hw/arm/xlnx-zcu102.c | 9 +++++---- |
14 | hw/arm/xlnx-versal.c | 12 ++++++------ | 11 | 1 file changed, 5 insertions(+), 4 deletions(-) |
15 | 2 files changed, 8 insertions(+), 7 deletions(-) | ||
16 | 12 | ||
17 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h | 13 | diff --git a/hw/arm/xlnx-zcu102.c b/hw/arm/xlnx-zcu102.c |
18 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/hw/arm/xlnx-versal.h | 15 | --- a/hw/arm/xlnx-zcu102.c |
20 | +++ b/include/hw/arm/xlnx-versal.h | 16 | +++ b/hw/arm/xlnx-zcu102.c |
21 | @@ -XXX,XX +XXX,XX @@ | 17 | @@ -XXX,XX +XXX,XX @@ typedef struct XlnxZCU102 { |
22 | #include "hw/sysbus.h" | 18 | |
23 | #include "hw/arm/boot.h" | 19 | bool secure; |
24 | #include "hw/intc/arm_gicv3.h" | 20 | bool virt; |
25 | +#include "hw/char/pl011.h" | 21 | + |
26 | 22 | + struct arm_boot_info binfo; | |
27 | #define TYPE_XLNX_VERSAL "xlnx-versal" | 23 | } XlnxZCU102; |
28 | #define XLNX_VERSAL(obj) OBJECT_CHECK(Versal, (obj), TYPE_XLNX_VERSAL) | 24 | |
29 | @@ -XXX,XX +XXX,XX @@ typedef struct Versal { | 25 | #define TYPE_ZCU102_MACHINE MACHINE_TYPE_NAME("xlnx-zcu102") |
30 | MemoryRegion mr_ocm; | 26 | #define ZCU102_MACHINE(obj) \ |
31 | 27 | OBJECT_CHECK(XlnxZCU102, (obj), TYPE_ZCU102_MACHINE) | |
32 | struct { | 28 | |
33 | - SysBusDevice *uart[XLNX_VERSAL_NR_UARTS]; | 29 | -static struct arm_boot_info xlnx_zcu102_binfo; |
34 | + PL011State uart[XLNX_VERSAL_NR_UARTS]; | 30 | |
35 | SysBusDevice *gem[XLNX_VERSAL_NR_GEMS]; | 31 | static bool zcu102_get_secure(Object *obj, Error **errp) |
36 | SysBusDevice *adma[XLNX_VERSAL_NR_ADMAS]; | 32 | { |
37 | } iou; | 33 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zcu102_init(MachineState *machine) |
38 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c | 34 | |
39 | index XXXXXXX..XXXXXXX 100644 | 35 | /* TODO create and connect IDE devices for ide_drive_get() */ |
40 | --- a/hw/arm/xlnx-versal.c | 36 | |
41 | +++ b/hw/arm/xlnx-versal.c | 37 | - xlnx_zcu102_binfo.ram_size = ram_size; |
42 | @@ -XXX,XX +XXX,XX @@ | 38 | - xlnx_zcu102_binfo.loader_start = 0; |
43 | #include "kvm_arm.h" | 39 | - arm_load_kernel(s->soc.boot_cpu_ptr, machine, &xlnx_zcu102_binfo); |
44 | #include "hw/misc/unimp.h" | 40 | + s->binfo.ram_size = ram_size; |
45 | #include "hw/arm/xlnx-versal.h" | 41 | + s->binfo.loader_start = 0; |
46 | -#include "hw/char/pl011.h" | 42 | + arm_load_kernel(s->soc.boot_cpu_ptr, machine, &s->binfo); |
47 | |||
48 | #define XLNX_VERSAL_ACPU_TYPE ARM_CPU_TYPE_NAME("cortex-a72") | ||
49 | #define GEM_REVISION 0x40070106 | ||
50 | @@ -XXX,XX +XXX,XX @@ static void versal_create_uarts(Versal *s, qemu_irq *pic) | ||
51 | DeviceState *dev; | ||
52 | MemoryRegion *mr; | ||
53 | |||
54 | - dev = qdev_create(NULL, TYPE_PL011); | ||
55 | - s->lpd.iou.uart[i] = SYS_BUS_DEVICE(dev); | ||
56 | + sysbus_init_child_obj(OBJECT(s), name, | ||
57 | + &s->lpd.iou.uart[i], sizeof(s->lpd.iou.uart[i]), | ||
58 | + TYPE_PL011); | ||
59 | + dev = DEVICE(&s->lpd.iou.uart[i]); | ||
60 | qdev_prop_set_chr(dev, "chardev", serial_hd(i)); | ||
61 | - object_property_add_child(OBJECT(s), name, OBJECT(dev), &error_fatal); | ||
62 | qdev_init_nofail(dev); | ||
63 | |||
64 | - mr = sysbus_mmio_get_region(s->lpd.iou.uart[i], 0); | ||
65 | + mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0); | ||
66 | memory_region_add_subregion(&s->mr_ps, addrs[i], mr); | ||
67 | |||
68 | - sysbus_connect_irq(s->lpd.iou.uart[i], 0, pic[irqs[i]]); | ||
69 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[irqs[i]]); | ||
70 | g_free(name); | ||
71 | } | ||
72 | } | 43 | } |
44 | |||
45 | static void xlnx_zcu102_machine_instance_init(Object *obj) | ||
73 | -- | 46 | -- |
74 | 2.20.1 | 47 | 2.20.1 |
75 | 48 | ||
76 | 49 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> |
---|---|---|---|
2 | 2 | ||
3 | Add support for SD. | 3 | Disable unsupported FDT firmware nodes if a user passes us |
4 | a DTB with nodes enabled that the machine cannot support | ||
5 | due to lack of EL3 or EL2 support. | ||
4 | 6 | ||
7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 8 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> |
6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 9 | Message-id: 20200423121114.4274-5-edgar.iglesias@gmail.com |
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | ||
9 | Message-id: 20200427181649.26851-9-edgar.iglesias@gmail.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 11 | --- |
12 | include/hw/arm/xlnx-versal.h | 12 ++++++++++++ | 12 | hw/arm/xlnx-zcu102.c | 30 ++++++++++++++++++++++++++++++ |
13 | hw/arm/xlnx-versal.c | 31 +++++++++++++++++++++++++++++++ | 13 | 1 file changed, 30 insertions(+) |
14 | 2 files changed, 43 insertions(+) | ||
15 | 14 | ||
16 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h | 15 | diff --git a/hw/arm/xlnx-zcu102.c b/hw/arm/xlnx-zcu102.c |
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/include/hw/arm/xlnx-versal.h | 17 | --- a/hw/arm/xlnx-zcu102.c |
19 | +++ b/include/hw/arm/xlnx-versal.h | 18 | +++ b/hw/arm/xlnx-zcu102.c |
20 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ |
21 | 20 | #include "qemu/error-report.h" | |
22 | #include "hw/sysbus.h" | 21 | #include "qemu/log.h" |
23 | #include "hw/arm/boot.h" | 22 | #include "sysemu/qtest.h" |
24 | +#include "hw/sd/sdhci.h" | 23 | +#include "sysemu/device_tree.h" |
25 | #include "hw/intc/arm_gicv3.h" | 24 | |
26 | #include "hw/char/pl011.h" | 25 | typedef struct XlnxZCU102 { |
27 | #include "hw/dma/xlnx-zdma.h" | 26 | MachineState parent_obj; |
28 | @@ -XXX,XX +XXX,XX @@ | 27 | @@ -XXX,XX +XXX,XX @@ static void zcu102_set_virt(Object *obj, bool value, Error **errp) |
29 | #define XLNX_VERSAL_NR_UARTS 2 | 28 | s->virt = value; |
30 | #define XLNX_VERSAL_NR_GEMS 2 | ||
31 | #define XLNX_VERSAL_NR_ADMAS 8 | ||
32 | +#define XLNX_VERSAL_NR_SDS 2 | ||
33 | #define XLNX_VERSAL_NR_IRQS 192 | ||
34 | |||
35 | typedef struct Versal { | ||
36 | @@ -XXX,XX +XXX,XX @@ typedef struct Versal { | ||
37 | } iou; | ||
38 | } lpd; | ||
39 | |||
40 | + /* The Platform Management Controller subsystem. */ | ||
41 | + struct { | ||
42 | + struct { | ||
43 | + SDHCIState sd[XLNX_VERSAL_NR_SDS]; | ||
44 | + } iou; | ||
45 | + } pmc; | ||
46 | + | ||
47 | struct { | ||
48 | MemoryRegion *mr_ddr; | ||
49 | uint32_t psci_conduit; | ||
50 | @@ -XXX,XX +XXX,XX @@ typedef struct Versal { | ||
51 | #define VERSAL_GEM1_IRQ_0 58 | ||
52 | #define VERSAL_GEM1_WAKE_IRQ_0 59 | ||
53 | #define VERSAL_ADMA_IRQ_0 60 | ||
54 | +#define VERSAL_SD0_IRQ_0 126 | ||
55 | |||
56 | /* Architecturally reserved IRQs suitable for virtualization. */ | ||
57 | #define VERSAL_RSVD_IRQ_FIRST 111 | ||
58 | @@ -XXX,XX +XXX,XX @@ typedef struct Versal { | ||
59 | #define MM_FPD_CRF 0xfd1a0000U | ||
60 | #define MM_FPD_CRF_SIZE 0x140000 | ||
61 | |||
62 | +#define MM_PMC_SD0 0xf1040000U | ||
63 | +#define MM_PMC_SD0_SIZE 0x10000 | ||
64 | #define MM_PMC_CRP 0xf1260000U | ||
65 | #define MM_PMC_CRP_SIZE 0x10000 | ||
66 | #endif | ||
67 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c | ||
68 | index XXXXXXX..XXXXXXX 100644 | ||
69 | --- a/hw/arm/xlnx-versal.c | ||
70 | +++ b/hw/arm/xlnx-versal.c | ||
71 | @@ -XXX,XX +XXX,XX @@ static void versal_create_admas(Versal *s, qemu_irq *pic) | ||
72 | } | ||
73 | } | 29 | } |
74 | 30 | ||
75 | +#define SDHCI_CAPABILITIES 0x280737ec6481 /* Same as on ZynqMP. */ | 31 | +static void zcu102_modify_dtb(const struct arm_boot_info *binfo, void *fdt) |
76 | +static void versal_create_sds(Versal *s, qemu_irq *pic) | ||
77 | +{ | 32 | +{ |
33 | + XlnxZCU102 *s = container_of(binfo, XlnxZCU102, binfo); | ||
34 | + bool method_is_hvc; | ||
35 | + char **node_path; | ||
36 | + const char *r; | ||
37 | + int prop_len; | ||
78 | + int i; | 38 | + int i; |
79 | + | 39 | + |
80 | + for (i = 0; i < ARRAY_SIZE(s->pmc.iou.sd); i++) { | 40 | + /* If EL3 is enabled, we keep all firmware nodes active. */ |
81 | + DeviceState *dev; | 41 | + if (!s->secure) { |
82 | + MemoryRegion *mr; | 42 | + node_path = qemu_fdt_node_path(fdt, NULL, "xlnx,zynqmp-firmware", |
43 | + &error_fatal); | ||
83 | + | 44 | + |
84 | + sysbus_init_child_obj(OBJECT(s), "sd[*]", | 45 | + for (i = 0; node_path && node_path[i]; i++) { |
85 | + &s->pmc.iou.sd[i], sizeof(s->pmc.iou.sd[i]), | 46 | + r = qemu_fdt_getprop(fdt, node_path[i], "method", &prop_len, NULL); |
86 | + TYPE_SYSBUS_SDHCI); | 47 | + method_is_hvc = r && !strcmp("hvc", r); |
87 | + dev = DEVICE(&s->pmc.iou.sd[i]); | ||
88 | + | 48 | + |
89 | + object_property_set_uint(OBJECT(dev), | 49 | + /* Allow HVC based firmware if EL2 is enabled. */ |
90 | + 3, "sd-spec-version", &error_fatal); | 50 | + if (method_is_hvc && s->virt) { |
91 | + object_property_set_uint(OBJECT(dev), SDHCI_CAPABILITIES, "capareg", | 51 | + continue; |
92 | + &error_fatal); | 52 | + } |
93 | + object_property_set_uint(OBJECT(dev), UHS_I, "uhs", &error_fatal); | 53 | + qemu_fdt_setprop_string(fdt, node_path[i], "status", "disabled"); |
94 | + qdev_init_nofail(dev); | 54 | + } |
95 | + | 55 | + g_strfreev(node_path); |
96 | + mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0); | ||
97 | + memory_region_add_subregion(&s->mr_ps, | ||
98 | + MM_PMC_SD0 + i * MM_PMC_SD0_SIZE, mr); | ||
99 | + | ||
100 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, | ||
101 | + pic[VERSAL_SD0_IRQ_0 + i * 2]); | ||
102 | + } | 56 | + } |
103 | +} | 57 | +} |
104 | + | 58 | + |
105 | /* This takes the board allocated linear DDR memory and creates aliases | 59 | static void xlnx_zcu102_init(MachineState *machine) |
106 | * for each split DDR range/aperture on the Versal address map. | 60 | { |
107 | */ | 61 | XlnxZCU102 *s = ZCU102_MACHINE(machine); |
108 | @@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp) | 62 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zcu102_init(MachineState *machine) |
109 | versal_create_uarts(s, pic); | 63 | |
110 | versal_create_gems(s, pic); | 64 | s->binfo.ram_size = ram_size; |
111 | versal_create_admas(s, pic); | 65 | s->binfo.loader_start = 0; |
112 | + versal_create_sds(s, pic); | 66 | + s->binfo.modify_dtb = zcu102_modify_dtb; |
113 | versal_map_ddr(s); | 67 | arm_load_kernel(s->soc.boot_cpu_ptr, machine, &s->binfo); |
114 | versal_unimp(s); | 68 | } |
115 | 69 | ||
116 | -- | 70 | -- |
117 | 2.20.1 | 71 | 2.20.1 |
118 | 72 | ||
119 | 73 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Somewhere along theline we accidentally added a duplicate | ||
2 | "using D16-D31 when they don't exist" check to do_vfm_dp() | ||
3 | (probably an artifact of a patchseries rebase). Remove it. | ||
4 | 1 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Message-id: 20200430181003.21682-2-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/translate-vfp.inc.c | 6 ------ | ||
11 | 1 file changed, 6 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/translate-vfp.inc.c | ||
16 | +++ b/target/arm/translate-vfp.inc.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static bool do_vfm_dp(DisasContext *s, arg_VFMA_dp *a, bool neg_n, bool neg_d) | ||
18 | return false; | ||
19 | } | ||
20 | |||
21 | - /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
22 | - if (!dc_isar_feature(aa32_simd_r32, s) && | ||
23 | - ((a->vd | a->vn | a->vm) & 0x10)) { | ||
24 | - return false; | ||
25 | - } | ||
26 | - | ||
27 | if (!vfp_access_check(s)) { | ||
28 | return true; | ||
29 | } | ||
30 | -- | ||
31 | 2.20.1 | ||
32 | |||
33 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | We were accidentally permitting decode of Thumb Neon insns even if | ||
2 | the CPU didn't have the FEATURE_NEON bit set, because the feature | ||
3 | check was being done before the call to disas_neon_data_insn() and | ||
4 | disas_neon_ls_insn() in the Arm decoder but was omitted from the | ||
5 | Thumb decoder. Push the feature bit check down into the called | ||
6 | functions so it is done for both Arm and Thumb encodings. | ||
7 | 1 | ||
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: 20200430181003.21682-3-peter.maydell@linaro.org | ||
12 | --- | ||
13 | target/arm/translate.c | 16 ++++++++-------- | ||
14 | 1 file changed, 8 insertions(+), 8 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/translate.c | ||
19 | +++ b/target/arm/translate.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn) | ||
21 | TCGv_i32 tmp2; | ||
22 | TCGv_i64 tmp64; | ||
23 | |||
24 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
25 | + return 1; | ||
26 | + } | ||
27 | + | ||
28 | /* FIXME: this access check should not take precedence over UNDEF | ||
29 | * for invalid encodings; we will generate incorrect syndrome information | ||
30 | * for attempts to execute invalid vfp/neon encodings with FP disabled. | ||
31 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
32 | TCGv_ptr ptr1, ptr2, ptr3; | ||
33 | TCGv_i64 tmp64; | ||
34 | |||
35 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
36 | + return 1; | ||
37 | + } | ||
38 | + | ||
39 | /* FIXME: this access check should not take precedence over UNDEF | ||
40 | * for invalid encodings; we will generate incorrect syndrome information | ||
41 | * for attempts to execute invalid vfp/neon encodings with FP disabled. | ||
42 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
43 | |||
44 | if (((insn >> 25) & 7) == 1) { | ||
45 | /* NEON Data processing. */ | ||
46 | - if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
47 | - goto illegal_op; | ||
48 | - } | ||
49 | - | ||
50 | if (disas_neon_data_insn(s, insn)) { | ||
51 | goto illegal_op; | ||
52 | } | ||
53 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
54 | } | ||
55 | if ((insn & 0x0f100000) == 0x04000000) { | ||
56 | /* NEON load/store. */ | ||
57 | - if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
58 | - goto illegal_op; | ||
59 | - } | ||
60 | - | ||
61 | if (disas_neon_ls_insn(s, insn)) { | ||
62 | goto illegal_op; | ||
63 | } | ||
64 | -- | ||
65 | 2.20.1 | ||
66 | |||
67 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Convert the VCMLA (vector) insns in the 3same extension group to | ||
2 | decodetree. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20200430181003.21682-5-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/neon-shared.decode | 11 ++++++++++ | ||
9 | target/arm/translate-neon.inc.c | 37 +++++++++++++++++++++++++++++++++ | ||
10 | target/arm/translate.c | 11 +--------- | ||
11 | 3 files changed, 49 insertions(+), 10 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/neon-shared.decode | ||
16 | +++ b/target/arm/neon-shared.decode | ||
17 | @@ -XXX,XX +XXX,XX @@ | ||
18 | # More specifically, this covers: | ||
19 | # 2reg scalar ext: 0b1111_1110_xxxx_xxxx_xxxx_1x0x_xxxx_xxxx | ||
20 | # 3same ext: 0b1111_110x_xxxx_xxxx_xxxx_1x0x_xxxx_xxxx | ||
21 | + | ||
22 | +# VFP/Neon register fields; same as vfp.decode | ||
23 | +%vm_dp 5:1 0:4 | ||
24 | +%vm_sp 0:4 5:1 | ||
25 | +%vn_dp 7:1 16:4 | ||
26 | +%vn_sp 16:4 7:1 | ||
27 | +%vd_dp 22:1 12:4 | ||
28 | +%vd_sp 12:4 22:1 | ||
29 | + | ||
30 | +VCMLA 1111 110 rot:2 . 1 size:1 .... .... 1000 . q:1 . 0 .... \ | ||
31 | + vm=%vm_dp vn=%vn_dp vd=%vd_dp | ||
32 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/target/arm/translate-neon.inc.c | ||
35 | +++ b/target/arm/translate-neon.inc.c | ||
36 | @@ -XXX,XX +XXX,XX @@ | ||
37 | #include "decode-neon-dp.inc.c" | ||
38 | #include "decode-neon-ls.inc.c" | ||
39 | #include "decode-neon-shared.inc.c" | ||
40 | + | ||
41 | +static bool trans_VCMLA(DisasContext *s, arg_VCMLA *a) | ||
42 | +{ | ||
43 | + int opr_sz; | ||
44 | + TCGv_ptr fpst; | ||
45 | + gen_helper_gvec_3_ptr *fn_gvec_ptr; | ||
46 | + | ||
47 | + if (!dc_isar_feature(aa32_vcma, s) | ||
48 | + || (!a->size && !dc_isar_feature(aa32_fp16_arith, s))) { | ||
49 | + return false; | ||
50 | + } | ||
51 | + | ||
52 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
53 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
54 | + ((a->vd | a->vn | a->vm) & 0x10)) { | ||
55 | + return false; | ||
56 | + } | ||
57 | + | ||
58 | + if ((a->vn | a->vm | a->vd) & a->q) { | ||
59 | + return false; | ||
60 | + } | ||
61 | + | ||
62 | + if (!vfp_access_check(s)) { | ||
63 | + return true; | ||
64 | + } | ||
65 | + | ||
66 | + opr_sz = (1 + a->q) * 8; | ||
67 | + fpst = get_fpstatus_ptr(1); | ||
68 | + fn_gvec_ptr = a->size ? gen_helper_gvec_fcmlas : gen_helper_gvec_fcmlah; | ||
69 | + tcg_gen_gvec_3_ptr(vfp_reg_offset(1, a->vd), | ||
70 | + vfp_reg_offset(1, a->vn), | ||
71 | + vfp_reg_offset(1, a->vm), | ||
72 | + fpst, opr_sz, opr_sz, a->rot, | ||
73 | + fn_gvec_ptr); | ||
74 | + tcg_temp_free_ptr(fpst); | ||
75 | + return true; | ||
76 | +} | ||
77 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | --- a/target/arm/translate.c | ||
80 | +++ b/target/arm/translate.c | ||
81 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn) | ||
82 | bool is_long = false, q = extract32(insn, 6, 1); | ||
83 | bool ptr_is_env = false; | ||
84 | |||
85 | - if ((insn & 0xfe200f10) == 0xfc200800) { | ||
86 | - /* VCMLA -- 1111 110R R.1S .... .... 1000 ...0 .... */ | ||
87 | - int size = extract32(insn, 20, 1); | ||
88 | - data = extract32(insn, 23, 2); /* rot */ | ||
89 | - if (!dc_isar_feature(aa32_vcma, s) | ||
90 | - || (!size && !dc_isar_feature(aa32_fp16_arith, s))) { | ||
91 | - return 1; | ||
92 | - } | ||
93 | - fn_gvec_ptr = size ? gen_helper_gvec_fcmlas : gen_helper_gvec_fcmlah; | ||
94 | - } else if ((insn & 0xfea00f10) == 0xfc800800) { | ||
95 | + if ((insn & 0xfea00f10) == 0xfc800800) { | ||
96 | /* VCADD -- 1111 110R 1.0S .... .... 1000 ...0 .... */ | ||
97 | int size = extract32(insn, 20, 1); | ||
98 | data = extract32(insn, 24, 1); /* rot */ | ||
99 | -- | ||
100 | 2.20.1 | ||
101 | |||
102 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Convert the VCADD (vector) insns to decodetree. | ||
2 | 1 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20200430181003.21682-6-peter.maydell@linaro.org | ||
6 | --- | ||
7 | target/arm/neon-shared.decode | 3 +++ | ||
8 | target/arm/translate-neon.inc.c | 37 +++++++++++++++++++++++++++++++++ | ||
9 | target/arm/translate.c | 11 +--------- | ||
10 | 3 files changed, 41 insertions(+), 10 deletions(-) | ||
11 | |||
12 | diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/neon-shared.decode | ||
15 | +++ b/target/arm/neon-shared.decode | ||
16 | @@ -XXX,XX +XXX,XX @@ | ||
17 | |||
18 | VCMLA 1111 110 rot:2 . 1 size:1 .... .... 1000 . q:1 . 0 .... \ | ||
19 | vm=%vm_dp vn=%vn_dp vd=%vd_dp | ||
20 | + | ||
21 | +VCADD 1111 110 rot:1 1 . 0 size:1 .... .... 1000 . q:1 . 0 .... \ | ||
22 | + vm=%vm_dp vn=%vn_dp vd=%vd_dp | ||
23 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/target/arm/translate-neon.inc.c | ||
26 | +++ b/target/arm/translate-neon.inc.c | ||
27 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCMLA(DisasContext *s, arg_VCMLA *a) | ||
28 | tcg_temp_free_ptr(fpst); | ||
29 | return true; | ||
30 | } | ||
31 | + | ||
32 | +static bool trans_VCADD(DisasContext *s, arg_VCADD *a) | ||
33 | +{ | ||
34 | + int opr_sz; | ||
35 | + TCGv_ptr fpst; | ||
36 | + gen_helper_gvec_3_ptr *fn_gvec_ptr; | ||
37 | + | ||
38 | + if (!dc_isar_feature(aa32_vcma, s) | ||
39 | + || (!a->size && !dc_isar_feature(aa32_fp16_arith, s))) { | ||
40 | + return false; | ||
41 | + } | ||
42 | + | ||
43 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
44 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
45 | + ((a->vd | a->vn | a->vm) & 0x10)) { | ||
46 | + return false; | ||
47 | + } | ||
48 | + | ||
49 | + if ((a->vn | a->vm | a->vd) & a->q) { | ||
50 | + return false; | ||
51 | + } | ||
52 | + | ||
53 | + if (!vfp_access_check(s)) { | ||
54 | + return true; | ||
55 | + } | ||
56 | + | ||
57 | + opr_sz = (1 + a->q) * 8; | ||
58 | + fpst = get_fpstatus_ptr(1); | ||
59 | + fn_gvec_ptr = a->size ? gen_helper_gvec_fcadds : gen_helper_gvec_fcaddh; | ||
60 | + tcg_gen_gvec_3_ptr(vfp_reg_offset(1, a->vd), | ||
61 | + vfp_reg_offset(1, a->vn), | ||
62 | + vfp_reg_offset(1, a->vm), | ||
63 | + fpst, opr_sz, opr_sz, a->rot, | ||
64 | + fn_gvec_ptr); | ||
65 | + tcg_temp_free_ptr(fpst); | ||
66 | + return true; | ||
67 | +} | ||
68 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/target/arm/translate.c | ||
71 | +++ b/target/arm/translate.c | ||
72 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn) | ||
73 | bool is_long = false, q = extract32(insn, 6, 1); | ||
74 | bool ptr_is_env = false; | ||
75 | |||
76 | - if ((insn & 0xfea00f10) == 0xfc800800) { | ||
77 | - /* VCADD -- 1111 110R 1.0S .... .... 1000 ...0 .... */ | ||
78 | - int size = extract32(insn, 20, 1); | ||
79 | - data = extract32(insn, 24, 1); /* rot */ | ||
80 | - if (!dc_isar_feature(aa32_vcma, s) | ||
81 | - || (!size && !dc_isar_feature(aa32_fp16_arith, s))) { | ||
82 | - return 1; | ||
83 | - } | ||
84 | - fn_gvec_ptr = size ? gen_helper_gvec_fcadds : gen_helper_gvec_fcaddh; | ||
85 | - } else if ((insn & 0xfeb00f00) == 0xfc200d00) { | ||
86 | + if ((insn & 0xfeb00f00) == 0xfc200d00) { | ||
87 | /* V[US]DOT -- 1111 1100 0.10 .... .... 1101 .Q.U .... */ | ||
88 | bool u = extract32(insn, 4, 1); | ||
89 | if (!dc_isar_feature(aa32_dp, s)) { | ||
90 | -- | ||
91 | 2.20.1 | ||
92 | |||
93 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Convert the V[US]DOT (vector) insns to decodetree. | ||
2 | 1 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20200430181003.21682-7-peter.maydell@linaro.org | ||
6 | --- | ||
7 | target/arm/neon-shared.decode | 4 ++++ | ||
8 | target/arm/translate-neon.inc.c | 32 ++++++++++++++++++++++++++++++++ | ||
9 | target/arm/translate.c | 9 +-------- | ||
10 | 3 files changed, 37 insertions(+), 8 deletions(-) | ||
11 | |||
12 | diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/neon-shared.decode | ||
15 | +++ b/target/arm/neon-shared.decode | ||
16 | @@ -XXX,XX +XXX,XX @@ VCMLA 1111 110 rot:2 . 1 size:1 .... .... 1000 . q:1 . 0 .... \ | ||
17 | |||
18 | VCADD 1111 110 rot:1 1 . 0 size:1 .... .... 1000 . q:1 . 0 .... \ | ||
19 | vm=%vm_dp vn=%vn_dp vd=%vd_dp | ||
20 | + | ||
21 | +# VUDOT and VSDOT | ||
22 | +VDOT 1111 110 00 . 10 .... .... 1101 . q:1 . u:1 .... \ | ||
23 | + vm=%vm_dp vn=%vn_dp vd=%vd_dp | ||
24 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/arm/translate-neon.inc.c | ||
27 | +++ b/target/arm/translate-neon.inc.c | ||
28 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCADD(DisasContext *s, arg_VCADD *a) | ||
29 | tcg_temp_free_ptr(fpst); | ||
30 | return true; | ||
31 | } | ||
32 | + | ||
33 | +static bool trans_VDOT(DisasContext *s, arg_VDOT *a) | ||
34 | +{ | ||
35 | + int opr_sz; | ||
36 | + gen_helper_gvec_3 *fn_gvec; | ||
37 | + | ||
38 | + if (!dc_isar_feature(aa32_dp, s)) { | ||
39 | + return false; | ||
40 | + } | ||
41 | + | ||
42 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
43 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
44 | + ((a->vd | a->vn | a->vm) & 0x10)) { | ||
45 | + return false; | ||
46 | + } | ||
47 | + | ||
48 | + if ((a->vn | a->vm | a->vd) & a->q) { | ||
49 | + return false; | ||
50 | + } | ||
51 | + | ||
52 | + if (!vfp_access_check(s)) { | ||
53 | + return true; | ||
54 | + } | ||
55 | + | ||
56 | + opr_sz = (1 + a->q) * 8; | ||
57 | + fn_gvec = a->u ? gen_helper_gvec_udot_b : gen_helper_gvec_sdot_b; | ||
58 | + tcg_gen_gvec_3_ool(vfp_reg_offset(1, a->vd), | ||
59 | + vfp_reg_offset(1, a->vn), | ||
60 | + vfp_reg_offset(1, a->vm), | ||
61 | + opr_sz, opr_sz, 0, fn_gvec); | ||
62 | + return true; | ||
63 | +} | ||
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 @@ static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn) | ||
69 | bool is_long = false, q = extract32(insn, 6, 1); | ||
70 | bool ptr_is_env = false; | ||
71 | |||
72 | - if ((insn & 0xfeb00f00) == 0xfc200d00) { | ||
73 | - /* V[US]DOT -- 1111 1100 0.10 .... .... 1101 .Q.U .... */ | ||
74 | - bool u = extract32(insn, 4, 1); | ||
75 | - if (!dc_isar_feature(aa32_dp, s)) { | ||
76 | - return 1; | ||
77 | - } | ||
78 | - fn_gvec = u ? gen_helper_gvec_udot_b : gen_helper_gvec_sdot_b; | ||
79 | - } else if ((insn & 0xff300f10) == 0xfc200810) { | ||
80 | + if ((insn & 0xff300f10) == 0xfc200810) { | ||
81 | /* VFM[AS]L -- 1111 1100 S.10 .... .... 1000 .Q.1 .... */ | ||
82 | int is_s = extract32(insn, 23, 1); | ||
83 | if (!dc_isar_feature(aa32_fhm, s)) { | ||
84 | -- | ||
85 | 2.20.1 | ||
86 | |||
87 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Convert the V[US]DOT (scalar) insns in the 2reg-scalar-ext group | ||
2 | to decodetree. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20200430181003.21682-10-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/neon-shared.decode | 3 +++ | ||
9 | target/arm/translate-neon.inc.c | 35 +++++++++++++++++++++++++++++++++ | ||
10 | target/arm/translate.c | 13 +----------- | ||
11 | 3 files changed, 39 insertions(+), 12 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/neon-shared.decode | ||
16 | +++ b/target/arm/neon-shared.decode | ||
17 | @@ -XXX,XX +XXX,XX @@ VCMLA_scalar 1111 1110 0 . rot:2 .... .... 1000 . q:1 index:1 0 vm:4 \ | ||
18 | vn=%vn_dp vd=%vd_dp size=0 | ||
19 | VCMLA_scalar 1111 1110 1 . rot:2 .... .... 1000 . q:1 . 0 .... \ | ||
20 | vm=%vm_dp vn=%vn_dp vd=%vd_dp size=1 index=0 | ||
21 | + | ||
22 | +VDOT_scalar 1111 1110 0 . 10 .... .... 1101 . q:1 index:1 u:1 rm:4 \ | ||
23 | + vm=%vm_dp vn=%vn_dp vd=%vd_dp | ||
24 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/arm/translate-neon.inc.c | ||
27 | +++ b/target/arm/translate-neon.inc.c | ||
28 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCMLA_scalar(DisasContext *s, arg_VCMLA_scalar *a) | ||
29 | tcg_temp_free_ptr(fpst); | ||
30 | return true; | ||
31 | } | ||
32 | + | ||
33 | +static bool trans_VDOT_scalar(DisasContext *s, arg_VDOT_scalar *a) | ||
34 | +{ | ||
35 | + gen_helper_gvec_3 *fn_gvec; | ||
36 | + int opr_sz; | ||
37 | + TCGv_ptr fpst; | ||
38 | + | ||
39 | + if (!dc_isar_feature(aa32_dp, s)) { | ||
40 | + return false; | ||
41 | + } | ||
42 | + | ||
43 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
44 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
45 | + ((a->vd | a->vn) & 0x10)) { | ||
46 | + return false; | ||
47 | + } | ||
48 | + | ||
49 | + if ((a->vd | a->vn) & a->q) { | ||
50 | + return false; | ||
51 | + } | ||
52 | + | ||
53 | + if (!vfp_access_check(s)) { | ||
54 | + return true; | ||
55 | + } | ||
56 | + | ||
57 | + fn_gvec = a->u ? gen_helper_gvec_udot_idx_b : gen_helper_gvec_sdot_idx_b; | ||
58 | + opr_sz = (1 + a->q) * 8; | ||
59 | + fpst = get_fpstatus_ptr(1); | ||
60 | + tcg_gen_gvec_3_ool(vfp_reg_offset(1, a->vd), | ||
61 | + vfp_reg_offset(1, a->vn), | ||
62 | + vfp_reg_offset(1, a->rm), | ||
63 | + opr_sz, opr_sz, a->index, fn_gvec); | ||
64 | + tcg_temp_free_ptr(fpst); | ||
65 | + return true; | ||
66 | +} | ||
67 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
68 | index XXXXXXX..XXXXXXX 100644 | ||
69 | --- a/target/arm/translate.c | ||
70 | +++ b/target/arm/translate.c | ||
71 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_2reg_scalar_ext(DisasContext *s, uint32_t insn) | ||
72 | bool is_long = false, q = extract32(insn, 6, 1); | ||
73 | bool ptr_is_env = false; | ||
74 | |||
75 | - if ((insn & 0xffb00f00) == 0xfe200d00) { | ||
76 | - /* V[US]DOT -- 1111 1110 0.10 .... .... 1101 .Q.U .... */ | ||
77 | - int u = extract32(insn, 4, 1); | ||
78 | - | ||
79 | - if (!dc_isar_feature(aa32_dp, s)) { | ||
80 | - return 1; | ||
81 | - } | ||
82 | - fn_gvec = u ? gen_helper_gvec_udot_idx_b : gen_helper_gvec_sdot_idx_b; | ||
83 | - /* rm is just Vm, and index is M. */ | ||
84 | - data = extract32(insn, 5, 1); /* index */ | ||
85 | - rm = extract32(insn, 0, 4); | ||
86 | - } else if ((insn & 0xffa00f10) == 0xfe000810) { | ||
87 | + if ((insn & 0xffa00f10) == 0xfe000810) { | ||
88 | /* VFM[AS]L -- 1111 1110 0.0S .... .... 1000 .Q.1 .... */ | ||
89 | int is_s = extract32(insn, 20, 1); | ||
90 | int vm20 = extract32(insn, 0, 3); | ||
91 | -- | ||
92 | 2.20.1 | ||
93 | |||
94 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Convert the VFM[AS]L (scalar) insns in the 2reg-scalar-ext group | ||
2 | to decodetree. These are the last ones in the group so we can remove | ||
3 | all the legacy decode for the group. | ||
4 | 1 | ||
5 | Note that in disas_thumb2_insn() the parts of this encoding space | ||
6 | where the decodetree decoder returns false will correctly be directed | ||
7 | to illegal_op by the "(insn & (1 << 28))" check so they won't fall | ||
8 | into disas_coproc_insn() by mistake. | ||
9 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20200430181003.21682-11-peter.maydell@linaro.org | ||
13 | --- | ||
14 | target/arm/neon-shared.decode | 7 +++ | ||
15 | target/arm/translate-neon.inc.c | 32 ++++++++++ | ||
16 | target/arm/translate.c | 107 +------------------------------- | ||
17 | 3 files changed, 40 insertions(+), 106 deletions(-) | ||
18 | |||
19 | diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/target/arm/neon-shared.decode | ||
22 | +++ b/target/arm/neon-shared.decode | ||
23 | @@ -XXX,XX +XXX,XX @@ VCMLA_scalar 1111 1110 1 . rot:2 .... .... 1000 . q:1 . 0 .... \ | ||
24 | |||
25 | VDOT_scalar 1111 1110 0 . 10 .... .... 1101 . q:1 index:1 u:1 rm:4 \ | ||
26 | vm=%vm_dp vn=%vn_dp vd=%vd_dp | ||
27 | + | ||
28 | +%vfml_scalar_q0_rm 0:3 5:1 | ||
29 | +%vfml_scalar_q1_index 5:1 3:1 | ||
30 | +VFML_scalar 1111 1110 0 . 0 s:1 .... .... 1000 . 0 . 1 index:1 ... \ | ||
31 | + rm=%vfml_scalar_q0_rm vn=%vn_sp vd=%vd_dp q=0 | ||
32 | +VFML_scalar 1111 1110 0 . 0 s:1 .... .... 1000 . 1 . 1 . rm:3 \ | ||
33 | + index=%vfml_scalar_q1_index vn=%vn_dp vd=%vd_dp q=1 | ||
34 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/target/arm/translate-neon.inc.c | ||
37 | +++ b/target/arm/translate-neon.inc.c | ||
38 | @@ -XXX,XX +XXX,XX @@ static bool trans_VDOT_scalar(DisasContext *s, arg_VDOT_scalar *a) | ||
39 | tcg_temp_free_ptr(fpst); | ||
40 | return true; | ||
41 | } | ||
42 | + | ||
43 | +static bool trans_VFML_scalar(DisasContext *s, arg_VFML_scalar *a) | ||
44 | +{ | ||
45 | + int opr_sz; | ||
46 | + | ||
47 | + if (!dc_isar_feature(aa32_fhm, s)) { | ||
48 | + return false; | ||
49 | + } | ||
50 | + | ||
51 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
52 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
53 | + ((a->vd & 0x10) || (a->q && (a->vn & 0x10)))) { | ||
54 | + return false; | ||
55 | + } | ||
56 | + | ||
57 | + if (a->vd & a->q) { | ||
58 | + return false; | ||
59 | + } | ||
60 | + | ||
61 | + if (!vfp_access_check(s)) { | ||
62 | + return true; | ||
63 | + } | ||
64 | + | ||
65 | + opr_sz = (1 + a->q) * 8; | ||
66 | + tcg_gen_gvec_3_ptr(vfp_reg_offset(1, a->vd), | ||
67 | + vfp_reg_offset(a->q, a->vn), | ||
68 | + vfp_reg_offset(a->q, a->rm), | ||
69 | + cpu_env, opr_sz, opr_sz, | ||
70 | + (a->index << 2) | a->s, /* is_2 == 0 */ | ||
71 | + gen_helper_gvec_fmlal_idx_a32); | ||
72 | + return true; | ||
73 | +} | ||
74 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
75 | index XXXXXXX..XXXXXXX 100644 | ||
76 | --- a/target/arm/translate.c | ||
77 | +++ b/target/arm/translate.c | ||
78 | @@ -XXX,XX +XXX,XX @@ static int disas_dsp_insn(DisasContext *s, uint32_t insn) | ||
79 | } | ||
80 | |||
81 | #define VFP_REG_SHR(x, n) (((n) > 0) ? (x) >> (n) : (x) << -(n)) | ||
82 | -#define VFP_SREG(insn, bigbit, smallbit) \ | ||
83 | - ((VFP_REG_SHR(insn, bigbit - 1) & 0x1e) | (((insn) >> (smallbit)) & 1)) | ||
84 | #define VFP_DREG(reg, insn, bigbit, smallbit) do { \ | ||
85 | if (dc_isar_feature(aa32_simd_r32, s)) { \ | ||
86 | reg = (((insn) >> (bigbit)) & 0x0f) \ | ||
87 | @@ -XXX,XX +XXX,XX @@ static int disas_dsp_insn(DisasContext *s, uint32_t insn) | ||
88 | reg = ((insn) >> (bigbit)) & 0x0f; \ | ||
89 | }} while (0) | ||
90 | |||
91 | -#define VFP_SREG_D(insn) VFP_SREG(insn, 12, 22) | ||
92 | #define VFP_DREG_D(reg, insn) VFP_DREG(reg, insn, 12, 22) | ||
93 | -#define VFP_SREG_N(insn) VFP_SREG(insn, 16, 7) | ||
94 | #define VFP_DREG_N(reg, insn) VFP_DREG(reg, insn, 16, 7) | ||
95 | -#define VFP_SREG_M(insn) VFP_SREG(insn, 0, 5) | ||
96 | #define VFP_DREG_M(reg, insn) VFP_DREG(reg, insn, 0, 5) | ||
97 | |||
98 | static void gen_neon_dup_low16(TCGv_i32 var) | ||
99 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
100 | return 0; | ||
101 | } | ||
102 | |||
103 | -/* Advanced SIMD two registers and a scalar extension. | ||
104 | - * 31 24 23 22 20 16 12 11 10 9 8 3 0 | ||
105 | - * +-----------------+----+---+----+----+----+---+----+---+----+---------+----+ | ||
106 | - * | 1 1 1 1 1 1 1 0 | o1 | D | o2 | Vn | Vd | 1 | o3 | 0 | o4 | N Q M U | Vm | | ||
107 | - * +-----------------+----+---+----+----+----+---+----+---+----+---------+----+ | ||
108 | - * | ||
109 | - */ | ||
110 | - | ||
111 | -static int disas_neon_insn_2reg_scalar_ext(DisasContext *s, uint32_t insn) | ||
112 | -{ | ||
113 | - gen_helper_gvec_3 *fn_gvec = NULL; | ||
114 | - gen_helper_gvec_3_ptr *fn_gvec_ptr = NULL; | ||
115 | - int rd, rn, rm, opr_sz, data; | ||
116 | - int off_rn, off_rm; | ||
117 | - bool is_long = false, q = extract32(insn, 6, 1); | ||
118 | - bool ptr_is_env = false; | ||
119 | - | ||
120 | - if ((insn & 0xffa00f10) == 0xfe000810) { | ||
121 | - /* VFM[AS]L -- 1111 1110 0.0S .... .... 1000 .Q.1 .... */ | ||
122 | - int is_s = extract32(insn, 20, 1); | ||
123 | - int vm20 = extract32(insn, 0, 3); | ||
124 | - int vm3 = extract32(insn, 3, 1); | ||
125 | - int m = extract32(insn, 5, 1); | ||
126 | - int index; | ||
127 | - | ||
128 | - if (!dc_isar_feature(aa32_fhm, s)) { | ||
129 | - return 1; | ||
130 | - } | ||
131 | - if (q) { | ||
132 | - rm = vm20; | ||
133 | - index = m * 2 + vm3; | ||
134 | - } else { | ||
135 | - rm = vm20 * 2 + m; | ||
136 | - index = vm3; | ||
137 | - } | ||
138 | - is_long = true; | ||
139 | - data = (index << 2) | is_s; /* is_2 == 0 */ | ||
140 | - fn_gvec_ptr = gen_helper_gvec_fmlal_idx_a32; | ||
141 | - ptr_is_env = true; | ||
142 | - } else { | ||
143 | - return 1; | ||
144 | - } | ||
145 | - | ||
146 | - VFP_DREG_D(rd, insn); | ||
147 | - if (rd & q) { | ||
148 | - return 1; | ||
149 | - } | ||
150 | - if (q || !is_long) { | ||
151 | - VFP_DREG_N(rn, insn); | ||
152 | - if (rn & q & !is_long) { | ||
153 | - return 1; | ||
154 | - } | ||
155 | - off_rn = vfp_reg_offset(1, rn); | ||
156 | - off_rm = vfp_reg_offset(1, rm); | ||
157 | - } else { | ||
158 | - rn = VFP_SREG_N(insn); | ||
159 | - off_rn = vfp_reg_offset(0, rn); | ||
160 | - off_rm = vfp_reg_offset(0, rm); | ||
161 | - } | ||
162 | - if (s->fp_excp_el) { | ||
163 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
164 | - syn_simd_access_trap(1, 0xe, false), s->fp_excp_el); | ||
165 | - return 0; | ||
166 | - } | ||
167 | - if (!s->vfp_enabled) { | ||
168 | - return 1; | ||
169 | - } | ||
170 | - | ||
171 | - opr_sz = (1 + q) * 8; | ||
172 | - if (fn_gvec_ptr) { | ||
173 | - TCGv_ptr ptr; | ||
174 | - if (ptr_is_env) { | ||
175 | - ptr = cpu_env; | ||
176 | - } else { | ||
177 | - ptr = get_fpstatus_ptr(1); | ||
178 | - } | ||
179 | - tcg_gen_gvec_3_ptr(vfp_reg_offset(1, rd), off_rn, off_rm, ptr, | ||
180 | - opr_sz, opr_sz, data, fn_gvec_ptr); | ||
181 | - if (!ptr_is_env) { | ||
182 | - tcg_temp_free_ptr(ptr); | ||
183 | - } | ||
184 | - } else { | ||
185 | - tcg_gen_gvec_3_ool(vfp_reg_offset(1, rd), off_rn, off_rm, | ||
186 | - opr_sz, opr_sz, data, fn_gvec); | ||
187 | - } | ||
188 | - return 0; | ||
189 | -} | ||
190 | - | ||
191 | static int disas_coproc_insn(DisasContext *s, uint32_t insn) | ||
192 | { | ||
193 | int cpnum, is64, crn, crm, opc1, opc2, isread, rt, rt2; | ||
194 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
195 | } | ||
196 | } | ||
197 | } | ||
198 | - } else if ((insn & 0x0f000a00) == 0x0e000800 | ||
199 | - && arm_dc_feature(s, ARM_FEATURE_V8)) { | ||
200 | - if (disas_neon_insn_2reg_scalar_ext(s, insn)) { | ||
201 | - goto illegal_op; | ||
202 | - } | ||
203 | - return; | ||
204 | } | ||
205 | goto illegal_op; | ||
206 | } | ||
207 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
208 | } | ||
209 | break; | ||
210 | } | ||
211 | - if ((insn & 0xff000a00) == 0xfe000800 | ||
212 | - && arm_dc_feature(s, ARM_FEATURE_V8)) { | ||
213 | - /* The Thumb2 and ARM encodings are identical. */ | ||
214 | - if (disas_neon_insn_2reg_scalar_ext(s, insn)) { | ||
215 | - goto illegal_op; | ||
216 | - } | ||
217 | - } else if (((insn >> 24) & 3) == 3) { | ||
218 | + if (((insn >> 24) & 3) == 3) { | ||
219 | /* Translate into the equivalent ARM encoding. */ | ||
220 | insn = (insn & 0xe2ffffff) | ((insn & (1 << 28)) >> 4) | (1 << 28); | ||
221 | if (disas_neon_data_insn(s, insn)) { | ||
222 | -- | ||
223 | 2.20.1 | ||
224 | |||
225 | diff view generated by jsdifflib |