1 | Arm queue; some of the simpler stuff, things other have reviewed (thanks!), etc. | 1 | First arm pullreq of the cycle; this is mostly my softfloat NaN |
---|---|---|---|
2 | handling series. (Lots more in my to-review queue, but I don't | ||
3 | like pullreqs growing too close to a hundred patches at a time :-)) | ||
2 | 4 | ||
5 | thanks | ||
3 | -- PMM | 6 | -- PMM |
4 | 7 | ||
5 | The following changes since commit 5d2f557b47dfbf8f23277a5bdd8473d4607c681a: | 8 | The following changes since commit 97f2796a3736ed37a1b85dc1c76a6c45b829dd17: |
6 | 9 | ||
7 | Merge remote-tracking branch 'remotes/kraxel/tags/vga-20200605-pull-request' into staging (2020-06-05 13:53:05 +0100) | 10 | Open 10.0 development tree (2024-12-10 17:41:17 +0000) |
8 | 11 | ||
9 | are available in the Git repository at: | 12 | are available in the Git repository at: |
10 | 13 | ||
11 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200605 | 14 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20241211 |
12 | 15 | ||
13 | for you to fetch changes up to 2c35a39eda0b16c2ed85c94cec204bf5efb97812: | 16 | for you to fetch changes up to 1abe28d519239eea5cf9620bb13149423e5665f8: |
14 | 17 | ||
15 | target/arm: Convert Neon one-register-and-immediate insns to decodetree (2020-06-05 17:23:10 +0100) | 18 | MAINTAINERS: Add correct email address for Vikram Garhwal (2024-12-11 15:31:09 +0000) |
16 | 19 | ||
17 | ---------------------------------------------------------------- | 20 | ---------------------------------------------------------------- |
18 | target-arm queue: | 21 | target-arm queue: |
19 | hw/ssi/imx_spi: Handle tx burst lengths other than 8 correctly | 22 | * hw/net/lan9118: Extract PHY model, reuse with imx_fec, fix bugs |
20 | hw/input/pxa2xx_keypad: Replace hw_error() by qemu_log_mask() | 23 | * fpu: Make muladd NaN handling runtime-selected, not compile-time |
21 | hw/arm/pxa2xx: Replace printf() call by qemu_log_mask() | 24 | * fpu: Make default NaN pattern runtime-selected, not compile-time |
22 | target/arm: Convert crypto insns to gvec | 25 | * fpu: Minor NaN-related cleanups |
23 | hw/adc/stm32f2xx_adc: Correct memory region size and access size | 26 | * MAINTAINERS: email address updates |
24 | tests/acceptance: Add a boot test for the xlnx-versal-virt machine | ||
25 | docs/system: Document Aspeed boards | ||
26 | raspi: Add model of the USB controller | ||
27 | target/arm: Convert 2-reg-and-shift and 1-reg-imm Neon insns to decodetree | ||
28 | 27 | ||
29 | ---------------------------------------------------------------- | 28 | ---------------------------------------------------------------- |
30 | Cédric Le Goater (1): | 29 | Bernhard Beschow (5): |
31 | docs/system: Document Aspeed boards | 30 | hw/net/lan9118: Extract lan9118_phy |
31 | hw/net/lan9118_phy: Reuse in imx_fec and consolidate implementations | ||
32 | hw/net/lan9118_phy: Fix off-by-one error in MII_ANLPAR register | ||
33 | hw/net/lan9118_phy: Reuse MII constants | ||
34 | hw/net/lan9118_phy: Add missing 100 mbps full duplex advertisement | ||
32 | 35 | ||
33 | Eden Mikitas (2): | 36 | Leif Lindholm (1): |
34 | hw/ssi/imx_spi: changed while statement to prevent underflow | 37 | MAINTAINERS: update email address for Leif Lindholm |
35 | hw/ssi/imx_spi: Removed unnecessary cast of rx data received from slave | ||
36 | 38 | ||
37 | Paul Zimmerman (7): | 39 | Peter Maydell (54): |
38 | raspi: add BCM2835 SOC MPHI emulation | 40 | fpu: handle raising Invalid for infzero in pick_nan_muladd |
39 | dwc-hsotg (dwc2) USB host controller register definitions | 41 | fpu: Check for default_nan_mode before calling pickNaNMulAdd |
40 | dwc-hsotg (dwc2) USB host controller state definitions | 42 | softfloat: Allow runtime choice of inf * 0 + NaN result |
41 | dwc-hsotg (dwc2) USB host controller emulation | 43 | tests/fp: Explicitly set inf-zero-nan rule |
42 | usb: add short-packet handling to usb-storage driver | 44 | target/arm: Set FloatInfZeroNaNRule explicitly |
43 | wire in the dwc-hsotg (dwc2) USB host controller emulation | 45 | target/s390: Set FloatInfZeroNaNRule explicitly |
44 | raspi2 acceptance test: add test for dwc-hsotg (dwc2) USB host | 46 | target/ppc: Set FloatInfZeroNaNRule explicitly |
47 | target/mips: Set FloatInfZeroNaNRule explicitly | ||
48 | target/sparc: Set FloatInfZeroNaNRule explicitly | ||
49 | target/xtensa: Set FloatInfZeroNaNRule explicitly | ||
50 | target/x86: Set FloatInfZeroNaNRule explicitly | ||
51 | target/loongarch: Set FloatInfZeroNaNRule explicitly | ||
52 | target/hppa: Set FloatInfZeroNaNRule explicitly | ||
53 | softfloat: Pass have_snan to pickNaNMulAdd | ||
54 | softfloat: Allow runtime choice of NaN propagation for muladd | ||
55 | tests/fp: Explicitly set 3-NaN propagation rule | ||
56 | target/arm: Set Float3NaNPropRule explicitly | ||
57 | target/loongarch: Set Float3NaNPropRule explicitly | ||
58 | target/ppc: Set Float3NaNPropRule explicitly | ||
59 | target/s390x: Set Float3NaNPropRule explicitly | ||
60 | target/sparc: Set Float3NaNPropRule explicitly | ||
61 | target/mips: Set Float3NaNPropRule explicitly | ||
62 | target/xtensa: Set Float3NaNPropRule explicitly | ||
63 | target/i386: Set Float3NaNPropRule explicitly | ||
64 | target/hppa: Set Float3NaNPropRule explicitly | ||
65 | fpu: Remove use_first_nan field from float_status | ||
66 | target/m68k: Don't pass NULL float_status to floatx80_default_nan() | ||
67 | softfloat: Create floatx80 default NaN from parts64_default_nan | ||
68 | target/loongarch: Use normal float_status in fclass_s and fclass_d helpers | ||
69 | target/m68k: In frem helper, initialize local float_status from env->fp_status | ||
70 | target/m68k: Init local float_status from env fp_status in gdb get/set reg | ||
71 | target/sparc: Initialize local scratch float_status from env->fp_status | ||
72 | target/ppc: Use env->fp_status in helper_compute_fprf functions | ||
73 | fpu: Allow runtime choice of default NaN value | ||
74 | tests/fp: Set default NaN pattern explicitly | ||
75 | target/microblaze: Set default NaN pattern explicitly | ||
76 | target/i386: Set default NaN pattern explicitly | ||
77 | target/hppa: Set default NaN pattern explicitly | ||
78 | target/alpha: Set default NaN pattern explicitly | ||
79 | target/arm: Set default NaN pattern explicitly | ||
80 | target/loongarch: Set default NaN pattern explicitly | ||
81 | target/m68k: Set default NaN pattern explicitly | ||
82 | target/mips: Set default NaN pattern explicitly | ||
83 | target/openrisc: Set default NaN pattern explicitly | ||
84 | target/ppc: Set default NaN pattern explicitly | ||
85 | target/sh4: Set default NaN pattern explicitly | ||
86 | target/rx: Set default NaN pattern explicitly | ||
87 | target/s390x: Set default NaN pattern explicitly | ||
88 | target/sparc: Set default NaN pattern explicitly | ||
89 | target/xtensa: Set default NaN pattern explicitly | ||
90 | target/hexagon: Set default NaN pattern explicitly | ||
91 | target/riscv: Set default NaN pattern explicitly | ||
92 | target/tricore: Set default NaN pattern explicitly | ||
93 | fpu: Remove default handling for dnan_pattern | ||
45 | 94 | ||
46 | Peter Maydell (9): | 95 | Richard Henderson (11): |
47 | target/arm: Convert Neon VSHL and VSLI 2-reg-shift insn to decodetree | 96 | target/arm: Copy entire float_status in is_ebf |
48 | target/arm: Convert Neon VSHR 2-reg-shift insns to decodetree | 97 | softfloat: Inline pickNaNMulAdd |
49 | target/arm: Convert Neon VSRA, VSRI, VRSHR, VRSRA 2-reg-shift insns to decodetree | 98 | softfloat: Use goto for default nan case in pick_nan_muladd |
50 | target/arm: Convert VQSHLU, VQSHL 2-reg-shift insns to decodetree | 99 | softfloat: Remove which from parts_pick_nan_muladd |
51 | target/arm: Convert Neon narrowing shifts with op==8 to decodetree | 100 | softfloat: Pad array size in pick_nan_muladd |
52 | target/arm: Convert Neon narrowing shifts with op==9 to decodetree | 101 | softfloat: Move propagateFloatx80NaN to softfloat.c |
53 | target/arm: Convert Neon VSHLL, VMOVL to decodetree | 102 | softfloat: Use parts_pick_nan in propagateFloatx80NaN |
54 | target/arm: Convert VCVT fixed-point ops to decodetree | 103 | softfloat: Inline pickNaN |
55 | target/arm: Convert Neon one-register-and-immediate insns to decodetree | 104 | softfloat: Share code between parts_pick_nan cases |
105 | softfloat: Sink frac_cmp in parts_pick_nan until needed | ||
106 | softfloat: Replace WHICH with RET in parts_pick_nan | ||
56 | 107 | ||
57 | Philippe Mathieu-Daudé (3): | 108 | Vikram Garhwal (1): |
58 | hw/input/pxa2xx_keypad: Replace hw_error() by qemu_log_mask() | 109 | MAINTAINERS: Add correct email address for Vikram Garhwal |
59 | hw/arm/pxa2xx: Replace printf() call by qemu_log_mask() | ||
60 | hw/adc/stm32f2xx_adc: Correct memory region size and access size | ||
61 | 110 | ||
62 | Richard Henderson (6): | 111 | MAINTAINERS | 4 +- |
63 | target/arm: Convert aes and sm4 to gvec helpers | 112 | include/fpu/softfloat-helpers.h | 38 +++- |
64 | target/arm: Convert rax1 to gvec helpers | 113 | include/fpu/softfloat-types.h | 89 +++++++- |
65 | target/arm: Convert sha512 and sm3 to gvec helpers | 114 | include/hw/net/imx_fec.h | 9 +- |
66 | target/arm: Convert sha1 and sha256 to gvec helpers | 115 | include/hw/net/lan9118_phy.h | 37 ++++ |
67 | target/arm: Split helper_crypto_sha1_3reg | 116 | include/hw/net/mii.h | 6 + |
68 | target/arm: Split helper_crypto_sm3tt | 117 | target/mips/fpu_helper.h | 20 ++ |
69 | 118 | target/sparc/helper.h | 4 +- | |
70 | Thomas Huth (1): | 119 | fpu/softfloat.c | 19 ++ |
71 | tests/acceptance: Add a boot test for the xlnx-versal-virt machine | 120 | hw/net/imx_fec.c | 146 ++------------ |
72 | 121 | hw/net/lan9118.c | 137 ++----------- | |
73 | docs/system/arm/aspeed.rst | 85 ++ | 122 | hw/net/lan9118_phy.c | 222 ++++++++++++++++++++ |
74 | docs/system/target-arm.rst | 1 + | 123 | linux-user/arm/nwfpe/fpa11.c | 5 + |
75 | hw/usb/hcd-dwc2.h | 190 +++++ | 124 | target/alpha/cpu.c | 2 + |
76 | include/hw/arm/bcm2835_peripherals.h | 5 +- | 125 | target/arm/cpu.c | 10 + |
77 | include/hw/misc/bcm2835_mphi.h | 44 + | 126 | target/arm/tcg/vec_helper.c | 20 +- |
78 | include/hw/usb/dwc2-regs.h | 899 ++++++++++++++++++++ | 127 | target/hexagon/cpu.c | 2 + |
79 | target/arm/helper.h | 45 +- | 128 | target/hppa/fpu_helper.c | 12 ++ |
80 | target/arm/translate-a64.h | 3 + | 129 | target/i386/tcg/fpu_helper.c | 12 ++ |
81 | target/arm/vec_internal.h | 33 + | 130 | target/loongarch/tcg/fpu_helper.c | 14 +- |
82 | target/arm/neon-dp.decode | 214 ++++- | 131 | target/m68k/cpu.c | 14 +- |
83 | hw/adc/stm32f2xx_adc.c | 4 +- | 132 | target/m68k/fpu_helper.c | 6 +- |
84 | hw/arm/bcm2835_peripherals.c | 38 +- | 133 | target/m68k/helper.c | 6 +- |
85 | hw/arm/pxa2xx.c | 66 +- | 134 | target/microblaze/cpu.c | 2 + |
86 | hw/input/pxa2xx_keypad.c | 10 +- | 135 | target/mips/msa.c | 10 + |
87 | hw/misc/bcm2835_mphi.c | 191 +++++ | 136 | target/openrisc/cpu.c | 2 + |
88 | hw/ssi/imx_spi.c | 4 +- | 137 | target/ppc/cpu_init.c | 19 ++ |
89 | hw/usb/dev-storage.c | 15 +- | 138 | target/ppc/fpu_helper.c | 3 +- |
90 | hw/usb/hcd-dwc2.c | 1417 ++++++++++++++++++++++++++++++++ | 139 | target/riscv/cpu.c | 2 + |
91 | target/arm/crypto_helper.c | 267 ++++-- | 140 | target/rx/cpu.c | 2 + |
92 | target/arm/translate-a64.c | 198 ++--- | 141 | target/s390x/cpu.c | 5 + |
93 | target/arm/translate-neon.inc.c | 796 ++++++++++++++---- | 142 | target/sh4/cpu.c | 2 + |
94 | target/arm/translate.c | 539 +----------- | 143 | target/sparc/cpu.c | 6 + |
95 | target/arm/vec_helper.c | 12 +- | 144 | target/sparc/fop_helper.c | 8 +- |
96 | hw/misc/Makefile.objs | 1 + | 145 | target/sparc/translate.c | 4 +- |
97 | hw/usb/Kconfig | 5 + | 146 | target/tricore/helper.c | 2 + |
98 | hw/usb/Makefile.objs | 1 + | 147 | target/xtensa/cpu.c | 4 + |
99 | hw/usb/trace-events | 50 ++ | 148 | target/xtensa/fpu_helper.c | 3 +- |
100 | tests/acceptance/boot_linux_console.py | 35 +- | 149 | tests/fp/fp-bench.c | 7 + |
101 | 28 files changed, 4258 insertions(+), 910 deletions(-) | 150 | tests/fp/fp-test-log2.c | 1 + |
102 | create mode 100644 docs/system/arm/aspeed.rst | 151 | tests/fp/fp-test.c | 7 + |
103 | create mode 100644 hw/usb/hcd-dwc2.h | 152 | fpu/softfloat-parts.c.inc | 152 +++++++++++--- |
104 | create mode 100644 include/hw/misc/bcm2835_mphi.h | 153 | fpu/softfloat-specialize.c.inc | 412 ++------------------------------------ |
105 | create mode 100644 include/hw/usb/dwc2-regs.h | 154 | .mailmap | 5 +- |
106 | create mode 100644 target/arm/vec_internal.h | 155 | hw/net/Kconfig | 5 + |
107 | create mode 100644 hw/misc/bcm2835_mphi.c | 156 | hw/net/meson.build | 1 + |
108 | create mode 100644 hw/usb/hcd-dwc2.c | 157 | hw/net/trace-events | 10 +- |
109 | 158 | 47 files changed, 778 insertions(+), 730 deletions(-) | |
159 | create mode 100644 include/hw/net/lan9118_phy.h | ||
160 | create mode 100644 hw/net/lan9118_phy.c | diff view generated by jsdifflib |
1 | From: Paul Zimmerman <pauldzim@gmail.com> | 1 | From: Bernhard Beschow <shentey@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | Add BCM2835 SOC MPHI (Message-based Parallel Host Interface) | 3 | A very similar implementation of the same device exists in imx_fec. Prepare for |
4 | emulation. It is very basic, only providing the FIQ interrupt | 4 | a common implementation by extracting a device model into its own files. |
5 | needed to allow the dwc-otg USB host controller driver in the | ||
6 | Raspbian kernel to function. | ||
7 | 5 | ||
8 | Signed-off-by: Paul Zimmerman <pauldzim@gmail.com> | 6 | Some migration state has been moved into the new device model which breaks |
9 | Acked-by: Philippe Mathieu-Daude <f4bug@amsat.org> | 7 | migration compatibility for the following machines: |
8 | * smdkc210 | ||
9 | * realview-* | ||
10 | * vexpress-* | ||
11 | * kzm | ||
12 | * mps2-* | ||
13 | |||
14 | While breaking migration ABI, fix the size of the MII registers to be 16 bit, | ||
15 | as defined by IEEE 802.3u. | ||
16 | |||
17 | Signed-off-by: Bernhard Beschow <shentey@gmail.com> | ||
18 | Tested-by: Guenter Roeck <linux@roeck-us.net> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Message-id: 20200520235349.21215-2-pauldzim@gmail.com | 20 | Message-id: 20241102125724.532843-2-shentey@gmail.com |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 22 | --- |
14 | include/hw/arm/bcm2835_peripherals.h | 2 + | 23 | include/hw/net/lan9118_phy.h | 37 ++++++++ |
15 | include/hw/misc/bcm2835_mphi.h | 44 ++++++ | 24 | hw/net/lan9118.c | 137 +++++----------------------- |
16 | hw/arm/bcm2835_peripherals.c | 17 +++ | 25 | hw/net/lan9118_phy.c | 169 +++++++++++++++++++++++++++++++++++ |
17 | hw/misc/bcm2835_mphi.c | 191 +++++++++++++++++++++++++++ | 26 | hw/net/Kconfig | 4 + |
18 | hw/misc/Makefile.objs | 1 + | 27 | hw/net/meson.build | 1 + |
19 | 5 files changed, 255 insertions(+) | 28 | 5 files changed, 233 insertions(+), 115 deletions(-) |
20 | create mode 100644 include/hw/misc/bcm2835_mphi.h | 29 | create mode 100644 include/hw/net/lan9118_phy.h |
21 | create mode 100644 hw/misc/bcm2835_mphi.c | 30 | create mode 100644 hw/net/lan9118_phy.c |
22 | 31 | ||
23 | diff --git a/include/hw/arm/bcm2835_peripherals.h b/include/hw/arm/bcm2835_peripherals.h | 32 | diff --git a/include/hw/net/lan9118_phy.h b/include/hw/net/lan9118_phy.h |
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/include/hw/arm/bcm2835_peripherals.h | ||
26 | +++ b/include/hw/arm/bcm2835_peripherals.h | ||
27 | @@ -XXX,XX +XXX,XX @@ | ||
28 | #include "hw/misc/bcm2835_property.h" | ||
29 | #include "hw/misc/bcm2835_rng.h" | ||
30 | #include "hw/misc/bcm2835_mbox.h" | ||
31 | +#include "hw/misc/bcm2835_mphi.h" | ||
32 | #include "hw/misc/bcm2835_thermal.h" | ||
33 | #include "hw/sd/sdhci.h" | ||
34 | #include "hw/sd/bcm2835_sdhost.h" | ||
35 | @@ -XXX,XX +XXX,XX @@ typedef struct BCM2835PeripheralState { | ||
36 | qemu_irq irq, fiq; | ||
37 | |||
38 | BCM2835SystemTimerState systmr; | ||
39 | + BCM2835MphiState mphi; | ||
40 | UnimplementedDeviceState armtmr; | ||
41 | UnimplementedDeviceState cprman; | ||
42 | UnimplementedDeviceState a2w; | ||
43 | diff --git a/include/hw/misc/bcm2835_mphi.h b/include/hw/misc/bcm2835_mphi.h | ||
44 | new file mode 100644 | 33 | new file mode 100644 |
45 | index XXXXXXX..XXXXXXX | 34 | index XXXXXXX..XXXXXXX |
46 | --- /dev/null | 35 | --- /dev/null |
47 | +++ b/include/hw/misc/bcm2835_mphi.h | 36 | +++ b/include/hw/net/lan9118_phy.h |
48 | @@ -XXX,XX +XXX,XX @@ | 37 | @@ -XXX,XX +XXX,XX @@ |
49 | +/* | 38 | +/* |
50 | + * BCM2835 SOC MPHI state definitions | 39 | + * SMSC LAN9118 PHY emulation |
51 | + * | 40 | + * |
52 | + * Copyright (c) 2020 Paul Zimmerman <pauldzim@gmail.com> | 41 | + * Copyright (c) 2009 CodeSourcery, LLC. |
42 | + * Written by Paul Brook | ||
53 | + * | 43 | + * |
54 | + * This program is free software; you can redistribute it and/or modify | 44 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. |
55 | + * it under the terms of the GNU General Public License as published by | 45 | + * See the COPYING file in the top-level directory. |
56 | + * the Free Software Foundation; either version 2 of the License, or | ||
57 | + * (at your option) any later version. | ||
58 | + * | ||
59 | + * This program is distributed in the hope that it will be useful, | ||
60 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
61 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
62 | + * GNU General Public License for more details. | ||
63 | + */ | 46 | + */ |
64 | + | 47 | + |
65 | +#ifndef HW_MISC_BCM2835_MPHI_H | 48 | +#ifndef HW_NET_LAN9118_PHY_H |
66 | +#define HW_MISC_BCM2835_MPHI_H | 49 | +#define HW_NET_LAN9118_PHY_H |
67 | + | 50 | + |
68 | +#include "hw/irq.h" | 51 | +#include "qom/object.h" |
69 | +#include "hw/sysbus.h" | 52 | +#include "hw/sysbus.h" |
70 | + | 53 | + |
71 | +#define MPHI_MMIO_SIZE 0x1000 | 54 | +#define TYPE_LAN9118_PHY "lan9118-phy" |
72 | + | 55 | +OBJECT_DECLARE_SIMPLE_TYPE(Lan9118PhyState, LAN9118_PHY) |
73 | +typedef struct BCM2835MphiState BCM2835MphiState; | 56 | + |
74 | + | 57 | +typedef struct Lan9118PhyState { |
75 | +struct BCM2835MphiState { | ||
76 | + SysBusDevice parent_obj; | 58 | + SysBusDevice parent_obj; |
59 | + | ||
60 | + uint16_t status; | ||
61 | + uint16_t control; | ||
62 | + uint16_t advertise; | ||
63 | + uint16_t ints; | ||
64 | + uint16_t int_mask; | ||
77 | + qemu_irq irq; | 65 | + qemu_irq irq; |
78 | + MemoryRegion iomem; | 66 | + bool link_down; |
79 | + | 67 | +} Lan9118PhyState; |
80 | + uint32_t outdda; | 68 | + |
81 | + uint32_t outddb; | 69 | +void lan9118_phy_update_link(Lan9118PhyState *s, bool link_down); |
82 | + uint32_t ctrl; | 70 | +void lan9118_phy_reset(Lan9118PhyState *s); |
83 | + uint32_t intstat; | 71 | +uint16_t lan9118_phy_read(Lan9118PhyState *s, int reg); |
84 | + uint32_t swirq; | 72 | +void lan9118_phy_write(Lan9118PhyState *s, int reg, uint16_t val); |
85 | +}; | ||
86 | + | ||
87 | +#define TYPE_BCM2835_MPHI "bcm2835-mphi" | ||
88 | + | ||
89 | +#define BCM2835_MPHI(obj) \ | ||
90 | + OBJECT_CHECK(BCM2835MphiState, (obj), TYPE_BCM2835_MPHI) | ||
91 | + | 73 | + |
92 | +#endif | 74 | +#endif |
93 | diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c | 75 | diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c |
94 | index XXXXXXX..XXXXXXX 100644 | 76 | index XXXXXXX..XXXXXXX 100644 |
95 | --- a/hw/arm/bcm2835_peripherals.c | 77 | --- a/hw/net/lan9118.c |
96 | +++ b/hw/arm/bcm2835_peripherals.c | 78 | +++ b/hw/net/lan9118.c |
97 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_init(Object *obj) | 79 | @@ -XXX,XX +XXX,XX @@ |
98 | OBJECT(&s->sdhci.sdbus)); | 80 | #include "net/net.h" |
99 | object_property_add_const_link(OBJECT(&s->gpio), "sdbus-sdhost", | 81 | #include "net/eth.h" |
100 | OBJECT(&s->sdhost.sdbus)); | 82 | #include "hw/irq.h" |
101 | + | 83 | +#include "hw/net/lan9118_phy.h" |
102 | + /* Mphi */ | 84 | #include "hw/net/lan9118.h" |
103 | + sysbus_init_child_obj(obj, "mphi", &s->mphi, sizeof(s->mphi), | 85 | #include "hw/ptimer.h" |
104 | + TYPE_BCM2835_MPHI); | 86 | #include "hw/qdev-properties.h" |
87 | @@ -XXX,XX +XXX,XX @@ do { printf("lan9118: " fmt , ## __VA_ARGS__); } while (0) | ||
88 | #define MAC_CR_RXEN 0x00000004 | ||
89 | #define MAC_CR_RESERVED 0x7f404213 | ||
90 | |||
91 | -#define PHY_INT_ENERGYON 0x80 | ||
92 | -#define PHY_INT_AUTONEG_COMPLETE 0x40 | ||
93 | -#define PHY_INT_FAULT 0x20 | ||
94 | -#define PHY_INT_DOWN 0x10 | ||
95 | -#define PHY_INT_AUTONEG_LP 0x08 | ||
96 | -#define PHY_INT_PARFAULT 0x04 | ||
97 | -#define PHY_INT_AUTONEG_PAGE 0x02 | ||
98 | - | ||
99 | #define GPT_TIMER_EN 0x20000000 | ||
100 | |||
101 | /* | ||
102 | @@ -XXX,XX +XXX,XX @@ struct lan9118_state { | ||
103 | uint32_t mac_mii_data; | ||
104 | uint32_t mac_flow; | ||
105 | |||
106 | - uint32_t phy_status; | ||
107 | - uint32_t phy_control; | ||
108 | - uint32_t phy_advertise; | ||
109 | - uint32_t phy_int; | ||
110 | - uint32_t phy_int_mask; | ||
111 | + Lan9118PhyState mii; | ||
112 | + IRQState mii_irq; | ||
113 | |||
114 | int32_t eeprom_writable; | ||
115 | uint8_t eeprom[128]; | ||
116 | @@ -XXX,XX +XXX,XX @@ struct lan9118_state { | ||
117 | |||
118 | static const VMStateDescription vmstate_lan9118 = { | ||
119 | .name = "lan9118", | ||
120 | - .version_id = 2, | ||
121 | - .minimum_version_id = 1, | ||
122 | + .version_id = 3, | ||
123 | + .minimum_version_id = 3, | ||
124 | .fields = (const VMStateField[]) { | ||
125 | VMSTATE_PTIMER(timer, lan9118_state), | ||
126 | VMSTATE_UINT32(irq_cfg, lan9118_state), | ||
127 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_lan9118 = { | ||
128 | VMSTATE_UINT32(mac_mii_acc, lan9118_state), | ||
129 | VMSTATE_UINT32(mac_mii_data, lan9118_state), | ||
130 | VMSTATE_UINT32(mac_flow, lan9118_state), | ||
131 | - VMSTATE_UINT32(phy_status, lan9118_state), | ||
132 | - VMSTATE_UINT32(phy_control, lan9118_state), | ||
133 | - VMSTATE_UINT32(phy_advertise, lan9118_state), | ||
134 | - VMSTATE_UINT32(phy_int, lan9118_state), | ||
135 | - VMSTATE_UINT32(phy_int_mask, lan9118_state), | ||
136 | VMSTATE_INT32(eeprom_writable, lan9118_state), | ||
137 | VMSTATE_UINT8_ARRAY(eeprom, lan9118_state, 128), | ||
138 | VMSTATE_INT32(tx_fifo_size, lan9118_state), | ||
139 | @@ -XXX,XX +XXX,XX @@ static void lan9118_reload_eeprom(lan9118_state *s) | ||
140 | lan9118_mac_changed(s); | ||
105 | } | 141 | } |
106 | 142 | ||
107 | static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | 143 | -static void phy_update_irq(lan9118_state *s) |
108 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | 144 | +static void lan9118_update_irq(void *opaque, int n, int level) |
109 | 145 | { | |
110 | object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(&s->gpio), "sd-bus"); | 146 | - if (s->phy_int & s->phy_int_mask) { |
111 | 147 | + lan9118_state *s = opaque; | |
112 | + /* Mphi */ | 148 | + |
113 | + object_property_set_bool(OBJECT(&s->mphi), true, "realized", &err); | 149 | + if (level) { |
114 | + if (err) { | 150 | s->int_sts |= PHY_INT; |
115 | + error_propagate(errp, err); | 151 | } else { |
152 | s->int_sts &= ~PHY_INT; | ||
153 | @@ -XXX,XX +XXX,XX @@ static void phy_update_irq(lan9118_state *s) | ||
154 | lan9118_update(s); | ||
155 | } | ||
156 | |||
157 | -static void phy_update_link(lan9118_state *s) | ||
158 | -{ | ||
159 | - /* Autonegotiation status mirrors link status. */ | ||
160 | - if (qemu_get_queue(s->nic)->link_down) { | ||
161 | - s->phy_status &= ~0x0024; | ||
162 | - s->phy_int |= PHY_INT_DOWN; | ||
163 | - } else { | ||
164 | - s->phy_status |= 0x0024; | ||
165 | - s->phy_int |= PHY_INT_ENERGYON; | ||
166 | - s->phy_int |= PHY_INT_AUTONEG_COMPLETE; | ||
167 | - } | ||
168 | - phy_update_irq(s); | ||
169 | -} | ||
170 | - | ||
171 | static void lan9118_set_link(NetClientState *nc) | ||
172 | { | ||
173 | - phy_update_link(qemu_get_nic_opaque(nc)); | ||
174 | -} | ||
175 | - | ||
176 | -static void phy_reset(lan9118_state *s) | ||
177 | -{ | ||
178 | - s->phy_status = 0x7809; | ||
179 | - s->phy_control = 0x3000; | ||
180 | - s->phy_advertise = 0x01e1; | ||
181 | - s->phy_int_mask = 0; | ||
182 | - s->phy_int = 0; | ||
183 | - phy_update_link(s); | ||
184 | + lan9118_phy_update_link(&LAN9118(qemu_get_nic_opaque(nc))->mii, | ||
185 | + nc->link_down); | ||
186 | } | ||
187 | |||
188 | static void lan9118_reset(DeviceState *d) | ||
189 | @@ -XXX,XX +XXX,XX @@ static void lan9118_reset(DeviceState *d) | ||
190 | s->read_word_n = 0; | ||
191 | s->write_word_n = 0; | ||
192 | |||
193 | - phy_reset(s); | ||
194 | - | ||
195 | s->eeprom_writable = 0; | ||
196 | lan9118_reload_eeprom(s); | ||
197 | } | ||
198 | @@ -XXX,XX +XXX,XX @@ static void do_tx_packet(lan9118_state *s) | ||
199 | uint32_t status; | ||
200 | |||
201 | /* FIXME: Honor TX disable, and allow queueing of packets. */ | ||
202 | - if (s->phy_control & 0x4000) { | ||
203 | + if (s->mii.control & 0x4000) { | ||
204 | /* This assumes the receive routine doesn't touch the VLANClient. */ | ||
205 | qemu_receive_packet(qemu_get_queue(s->nic), s->txp->data, s->txp->len); | ||
206 | } else { | ||
207 | @@ -XXX,XX +XXX,XX @@ static void tx_fifo_push(lan9118_state *s, uint32_t val) | ||
208 | } | ||
209 | } | ||
210 | |||
211 | -static uint32_t do_phy_read(lan9118_state *s, int reg) | ||
212 | -{ | ||
213 | - uint32_t val; | ||
214 | - | ||
215 | - switch (reg) { | ||
216 | - case 0: /* Basic Control */ | ||
217 | - return s->phy_control; | ||
218 | - case 1: /* Basic Status */ | ||
219 | - return s->phy_status; | ||
220 | - case 2: /* ID1 */ | ||
221 | - return 0x0007; | ||
222 | - case 3: /* ID2 */ | ||
223 | - return 0xc0d1; | ||
224 | - case 4: /* Auto-neg advertisement */ | ||
225 | - return s->phy_advertise; | ||
226 | - case 5: /* Auto-neg Link Partner Ability */ | ||
227 | - return 0x0f71; | ||
228 | - case 6: /* Auto-neg Expansion */ | ||
229 | - return 1; | ||
230 | - /* TODO 17, 18, 27, 29, 30, 31 */ | ||
231 | - case 29: /* Interrupt source. */ | ||
232 | - val = s->phy_int; | ||
233 | - s->phy_int = 0; | ||
234 | - phy_update_irq(s); | ||
235 | - return val; | ||
236 | - case 30: /* Interrupt mask */ | ||
237 | - return s->phy_int_mask; | ||
238 | - default: | ||
239 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
240 | - "do_phy_read: PHY read reg %d\n", reg); | ||
241 | - return 0; | ||
242 | - } | ||
243 | -} | ||
244 | - | ||
245 | -static void do_phy_write(lan9118_state *s, int reg, uint32_t val) | ||
246 | -{ | ||
247 | - switch (reg) { | ||
248 | - case 0: /* Basic Control */ | ||
249 | - if (val & 0x8000) { | ||
250 | - phy_reset(s); | ||
251 | - break; | ||
252 | - } | ||
253 | - s->phy_control = val & 0x7980; | ||
254 | - /* Complete autonegotiation immediately. */ | ||
255 | - if (val & 0x1000) { | ||
256 | - s->phy_status |= 0x0020; | ||
257 | - } | ||
258 | - break; | ||
259 | - case 4: /* Auto-neg advertisement */ | ||
260 | - s->phy_advertise = (val & 0x2d7f) | 0x80; | ||
261 | - break; | ||
262 | - /* TODO 17, 18, 27, 31 */ | ||
263 | - case 30: /* Interrupt mask */ | ||
264 | - s->phy_int_mask = val & 0xff; | ||
265 | - phy_update_irq(s); | ||
266 | - break; | ||
267 | - default: | ||
268 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
269 | - "do_phy_write: PHY write reg %d = 0x%04x\n", reg, val); | ||
270 | - } | ||
271 | -} | ||
272 | - | ||
273 | static void do_mac_write(lan9118_state *s, int reg, uint32_t val) | ||
274 | { | ||
275 | switch (reg) { | ||
276 | @@ -XXX,XX +XXX,XX @@ static void do_mac_write(lan9118_state *s, int reg, uint32_t val) | ||
277 | if (val & 2) { | ||
278 | DPRINTF("PHY write %d = 0x%04x\n", | ||
279 | (val >> 6) & 0x1f, s->mac_mii_data); | ||
280 | - do_phy_write(s, (val >> 6) & 0x1f, s->mac_mii_data); | ||
281 | + lan9118_phy_write(&s->mii, (val >> 6) & 0x1f, s->mac_mii_data); | ||
282 | } else { | ||
283 | - s->mac_mii_data = do_phy_read(s, (val >> 6) & 0x1f); | ||
284 | + s->mac_mii_data = lan9118_phy_read(&s->mii, (val >> 6) & 0x1f); | ||
285 | DPRINTF("PHY read %d = 0x%04x\n", | ||
286 | (val >> 6) & 0x1f, s->mac_mii_data); | ||
287 | } | ||
288 | @@ -XXX,XX +XXX,XX @@ static void lan9118_writel(void *opaque, hwaddr offset, | ||
289 | break; | ||
290 | case CSR_PMT_CTRL: | ||
291 | if (val & 0x400) { | ||
292 | - phy_reset(s); | ||
293 | + lan9118_phy_reset(&s->mii); | ||
294 | } | ||
295 | s->pmt_ctrl &= ~0x34e; | ||
296 | s->pmt_ctrl |= (val & 0x34e); | ||
297 | @@ -XXX,XX +XXX,XX @@ static void lan9118_realize(DeviceState *dev, Error **errp) | ||
298 | const MemoryRegionOps *mem_ops = | ||
299 | s->mode_16bit ? &lan9118_16bit_mem_ops : &lan9118_mem_ops; | ||
300 | |||
301 | + qemu_init_irq(&s->mii_irq, lan9118_update_irq, s, 0); | ||
302 | + object_initialize_child(OBJECT(s), "mii", &s->mii, TYPE_LAN9118_PHY); | ||
303 | + if (!sysbus_realize_and_unref(SYS_BUS_DEVICE(&s->mii), errp)) { | ||
116 | + return; | 304 | + return; |
117 | + } | 305 | + } |
118 | + | 306 | + qdev_connect_gpio_out(DEVICE(&s->mii), 0, &s->mii_irq); |
119 | + memory_region_add_subregion(&s->peri_mr, MPHI_OFFSET, | 307 | + |
120 | + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->mphi), 0)); | 308 | memory_region_init_io(&s->mmio, OBJECT(dev), mem_ops, s, |
121 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->mphi), 0, | 309 | "lan9118-mmio", 0x100); |
122 | + qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, | 310 | sysbus_init_mmio(sbd, &s->mmio); |
123 | + INTERRUPT_HOSTPORT)); | 311 | diff --git a/hw/net/lan9118_phy.c b/hw/net/lan9118_phy.c |
124 | + | ||
125 | create_unimp(s, &s->armtmr, "bcm2835-sp804", ARMCTRL_TIMER0_1_OFFSET, 0x40); | ||
126 | create_unimp(s, &s->cprman, "bcm2835-cprman", CPRMAN_OFFSET, 0x1000); | ||
127 | create_unimp(s, &s->a2w, "bcm2835-a2w", A2W_OFFSET, 0x1000); | ||
128 | diff --git a/hw/misc/bcm2835_mphi.c b/hw/misc/bcm2835_mphi.c | ||
129 | new file mode 100644 | 312 | new file mode 100644 |
130 | index XXXXXXX..XXXXXXX | 313 | index XXXXXXX..XXXXXXX |
131 | --- /dev/null | 314 | --- /dev/null |
132 | +++ b/hw/misc/bcm2835_mphi.c | 315 | +++ b/hw/net/lan9118_phy.c |
133 | @@ -XXX,XX +XXX,XX @@ | 316 | @@ -XXX,XX +XXX,XX @@ |
134 | +/* | 317 | +/* |
135 | + * BCM2835 SOC MPHI emulation | 318 | + * SMSC LAN9118 PHY emulation |
136 | + * | 319 | + * |
137 | + * Very basic emulation, only providing the FIQ interrupt needed to | 320 | + * Copyright (c) 2009 CodeSourcery, LLC. |
138 | + * allow the dwc-otg USB host controller driver in the Raspbian kernel | 321 | + * Written by Paul Brook |
139 | + * to function. | ||
140 | + * | 322 | + * |
141 | + * Copyright (c) 2020 Paul Zimmerman <pauldzim@gmail.com> | 323 | + * This code is licensed under the GNU GPL v2 |
142 | + * | 324 | + * |
143 | + * This program is free software; you can redistribute it and/or modify | 325 | + * Contributions after 2012-01-13 are licensed under the terms of the |
144 | + * it under the terms of the GNU General Public License as published by | 326 | + * GNU GPL, version 2 or (at your option) any later version. |
145 | + * the Free Software Foundation; either version 2 of the License, or | ||
146 | + * (at your option) any later version. | ||
147 | + * | ||
148 | + * This program is distributed in the hope that it will be useful, | ||
149 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
150 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
151 | + * GNU General Public License for more details. | ||
152 | + */ | 327 | + */ |
153 | + | 328 | + |
154 | +#include "qemu/osdep.h" | 329 | +#include "qemu/osdep.h" |
155 | +#include "qapi/error.h" | 330 | +#include "hw/net/lan9118_phy.h" |
156 | +#include "hw/misc/bcm2835_mphi.h" | 331 | +#include "hw/irq.h" |
332 | +#include "hw/resettable.h" | ||
157 | +#include "migration/vmstate.h" | 333 | +#include "migration/vmstate.h" |
158 | +#include "qemu/error-report.h" | ||
159 | +#include "qemu/log.h" | 334 | +#include "qemu/log.h" |
160 | +#include "qemu/main-loop.h" | 335 | + |
161 | + | 336 | +#define PHY_INT_ENERGYON (1 << 7) |
162 | +static inline void mphi_raise_irq(BCM2835MphiState *s) | 337 | +#define PHY_INT_AUTONEG_COMPLETE (1 << 6) |
163 | +{ | 338 | +#define PHY_INT_FAULT (1 << 5) |
164 | + qemu_set_irq(s->irq, 1); | 339 | +#define PHY_INT_DOWN (1 << 4) |
165 | +} | 340 | +#define PHY_INT_AUTONEG_LP (1 << 3) |
166 | + | 341 | +#define PHY_INT_PARFAULT (1 << 2) |
167 | +static inline void mphi_lower_irq(BCM2835MphiState *s) | 342 | +#define PHY_INT_AUTONEG_PAGE (1 << 1) |
168 | +{ | 343 | + |
169 | + qemu_set_irq(s->irq, 0); | 344 | +static void lan9118_phy_update_irq(Lan9118PhyState *s) |
170 | +} | 345 | +{ |
171 | + | 346 | + qemu_set_irq(s->irq, !!(s->ints & s->int_mask)); |
172 | +static uint64_t mphi_reg_read(void *ptr, hwaddr addr, unsigned size) | 347 | +} |
173 | +{ | 348 | + |
174 | + BCM2835MphiState *s = ptr; | 349 | +uint16_t lan9118_phy_read(Lan9118PhyState *s, int reg) |
175 | + uint32_t val = 0; | 350 | +{ |
176 | + | 351 | + uint16_t val; |
177 | + switch (addr) { | 352 | + |
178 | + case 0x28: /* outdda */ | 353 | + switch (reg) { |
179 | + val = s->outdda; | 354 | + case 0: /* Basic Control */ |
355 | + return s->control; | ||
356 | + case 1: /* Basic Status */ | ||
357 | + return s->status; | ||
358 | + case 2: /* ID1 */ | ||
359 | + return 0x0007; | ||
360 | + case 3: /* ID2 */ | ||
361 | + return 0xc0d1; | ||
362 | + case 4: /* Auto-neg advertisement */ | ||
363 | + return s->advertise; | ||
364 | + case 5: /* Auto-neg Link Partner Ability */ | ||
365 | + return 0x0f71; | ||
366 | + case 6: /* Auto-neg Expansion */ | ||
367 | + return 1; | ||
368 | + /* TODO 17, 18, 27, 29, 30, 31 */ | ||
369 | + case 29: /* Interrupt source. */ | ||
370 | + val = s->ints; | ||
371 | + s->ints = 0; | ||
372 | + lan9118_phy_update_irq(s); | ||
373 | + return val; | ||
374 | + case 30: /* Interrupt mask */ | ||
375 | + return s->int_mask; | ||
376 | + default: | ||
377 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
378 | + "lan9118_phy_read: PHY read reg %d\n", reg); | ||
379 | + return 0; | ||
380 | + } | ||
381 | +} | ||
382 | + | ||
383 | +void lan9118_phy_write(Lan9118PhyState *s, int reg, uint16_t val) | ||
384 | +{ | ||
385 | + switch (reg) { | ||
386 | + case 0: /* Basic Control */ | ||
387 | + if (val & 0x8000) { | ||
388 | + lan9118_phy_reset(s); | ||
389 | + break; | ||
390 | + } | ||
391 | + s->control = val & 0x7980; | ||
392 | + /* Complete autonegotiation immediately. */ | ||
393 | + if (val & 0x1000) { | ||
394 | + s->status |= 0x0020; | ||
395 | + } | ||
180 | + break; | 396 | + break; |
181 | + case 0x2c: /* outddb */ | 397 | + case 4: /* Auto-neg advertisement */ |
182 | + val = s->outddb; | 398 | + s->advertise = (val & 0x2d7f) | 0x80; |
183 | + break; | 399 | + break; |
184 | + case 0x4c: /* ctrl */ | 400 | + /* TODO 17, 18, 27, 31 */ |
185 | + val = s->ctrl; | 401 | + case 30: /* Interrupt mask */ |
186 | + val |= 1 << 17; | 402 | + s->int_mask = val & 0xff; |
187 | + break; | 403 | + lan9118_phy_update_irq(s); |
188 | + case 0x50: /* intstat */ | ||
189 | + val = s->intstat; | ||
190 | + break; | ||
191 | + case 0x1f0: /* swirq_set */ | ||
192 | + val = s->swirq; | ||
193 | + break; | ||
194 | + case 0x1f4: /* swirq_clr */ | ||
195 | + val = s->swirq; | ||
196 | + break; | 404 | + break; |
197 | + default: | 405 | + default: |
198 | + qemu_log_mask(LOG_UNIMP, "read from unknown register"); | 406 | + qemu_log_mask(LOG_GUEST_ERROR, |
199 | + break; | 407 | + "lan9118_phy_write: PHY write reg %d = 0x%04x\n", reg, val); |
200 | + } | 408 | + } |
201 | + | 409 | +} |
202 | + return val; | 410 | + |
203 | +} | 411 | +void lan9118_phy_update_link(Lan9118PhyState *s, bool link_down) |
204 | + | 412 | +{ |
205 | +static void mphi_reg_write(void *ptr, hwaddr addr, uint64_t val, unsigned size) | 413 | + s->link_down = link_down; |
206 | +{ | 414 | + |
207 | + BCM2835MphiState *s = ptr; | 415 | + /* Autonegotiation status mirrors link status. */ |
208 | + int do_irq = 0; | 416 | + if (link_down) { |
209 | + | 417 | + s->status &= ~0x0024; |
210 | + switch (addr) { | 418 | + s->ints |= PHY_INT_DOWN; |
211 | + case 0x28: /* outdda */ | 419 | + } else { |
212 | + s->outdda = val; | 420 | + s->status |= 0x0024; |
213 | + break; | 421 | + s->ints |= PHY_INT_ENERGYON; |
214 | + case 0x2c: /* outddb */ | 422 | + s->ints |= PHY_INT_AUTONEG_COMPLETE; |
215 | + s->outddb = val; | ||
216 | + if (val & (1 << 29)) { | ||
217 | + do_irq = 1; | ||
218 | + } | ||
219 | + break; | ||
220 | + case 0x4c: /* ctrl */ | ||
221 | + s->ctrl = val; | ||
222 | + if (val & (1 << 16)) { | ||
223 | + do_irq = -1; | ||
224 | + } | ||
225 | + break; | ||
226 | + case 0x50: /* intstat */ | ||
227 | + s->intstat = val; | ||
228 | + if (val & ((1 << 16) | (1 << 29))) { | ||
229 | + do_irq = -1; | ||
230 | + } | ||
231 | + break; | ||
232 | + case 0x1f0: /* swirq_set */ | ||
233 | + s->swirq |= val; | ||
234 | + do_irq = 1; | ||
235 | + break; | ||
236 | + case 0x1f4: /* swirq_clr */ | ||
237 | + s->swirq &= ~val; | ||
238 | + do_irq = -1; | ||
239 | + break; | ||
240 | + default: | ||
241 | + qemu_log_mask(LOG_UNIMP, "write to unknown register"); | ||
242 | + return; | ||
243 | + } | 423 | + } |
244 | + | 424 | + lan9118_phy_update_irq(s); |
245 | + if (do_irq > 0) { | 425 | +} |
246 | + mphi_raise_irq(s); | 426 | + |
247 | + } else if (do_irq < 0) { | 427 | +void lan9118_phy_reset(Lan9118PhyState *s) |
248 | + mphi_lower_irq(s); | 428 | +{ |
249 | + } | 429 | + s->control = 0x3000; |
250 | +} | 430 | + s->status = 0x7809; |
251 | + | 431 | + s->advertise = 0x01e1; |
252 | +static const MemoryRegionOps mphi_mmio_ops = { | 432 | + s->int_mask = 0; |
253 | + .read = mphi_reg_read, | 433 | + s->ints = 0; |
254 | + .write = mphi_reg_write, | 434 | + lan9118_phy_update_link(s, s->link_down); |
255 | + .impl.min_access_size = 4, | 435 | +} |
256 | + .impl.max_access_size = 4, | 436 | + |
257 | + .endianness = DEVICE_LITTLE_ENDIAN, | 437 | +static void lan9118_phy_reset_hold(Object *obj, ResetType type) |
258 | +}; | 438 | +{ |
259 | + | 439 | + Lan9118PhyState *s = LAN9118_PHY(obj); |
260 | +static void mphi_reset(DeviceState *dev) | 440 | + |
261 | +{ | 441 | + lan9118_phy_reset(s); |
262 | + BCM2835MphiState *s = BCM2835_MPHI(dev); | 442 | +} |
263 | + | 443 | + |
264 | + s->outdda = 0; | 444 | +static void lan9118_phy_init(Object *obj) |
265 | + s->outddb = 0; | 445 | +{ |
266 | + s->ctrl = 0; | 446 | + Lan9118PhyState *s = LAN9118_PHY(obj); |
267 | + s->intstat = 0; | 447 | + |
268 | + s->swirq = 0; | 448 | + qdev_init_gpio_out(DEVICE(s), &s->irq, 1); |
269 | +} | 449 | +} |
270 | + | 450 | + |
271 | +static void mphi_realize(DeviceState *dev, Error **errp) | 451 | +static const VMStateDescription vmstate_lan9118_phy = { |
272 | +{ | 452 | + .name = "lan9118-phy", |
273 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
274 | + BCM2835MphiState *s = BCM2835_MPHI(dev); | ||
275 | + | ||
276 | + sysbus_init_irq(sbd, &s->irq); | ||
277 | +} | ||
278 | + | ||
279 | +static void mphi_init(Object *obj) | ||
280 | +{ | ||
281 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
282 | + BCM2835MphiState *s = BCM2835_MPHI(obj); | ||
283 | + | ||
284 | + memory_region_init_io(&s->iomem, obj, &mphi_mmio_ops, s, "mphi", MPHI_MMIO_SIZE); | ||
285 | + sysbus_init_mmio(sbd, &s->iomem); | ||
286 | +} | ||
287 | + | ||
288 | +const VMStateDescription vmstate_mphi_state = { | ||
289 | + .name = "mphi", | ||
290 | + .version_id = 1, | 453 | + .version_id = 1, |
291 | + .minimum_version_id = 1, | 454 | + .minimum_version_id = 1, |
292 | + .fields = (VMStateField[]) { | 455 | + .fields = (const VMStateField[]) { |
293 | + VMSTATE_UINT32(outdda, BCM2835MphiState), | 456 | + VMSTATE_UINT16(control, Lan9118PhyState), |
294 | + VMSTATE_UINT32(outddb, BCM2835MphiState), | 457 | + VMSTATE_UINT16(status, Lan9118PhyState), |
295 | + VMSTATE_UINT32(ctrl, BCM2835MphiState), | 458 | + VMSTATE_UINT16(advertise, Lan9118PhyState), |
296 | + VMSTATE_UINT32(intstat, BCM2835MphiState), | 459 | + VMSTATE_UINT16(ints, Lan9118PhyState), |
297 | + VMSTATE_UINT32(swirq, BCM2835MphiState), | 460 | + VMSTATE_UINT16(int_mask, Lan9118PhyState), |
461 | + VMSTATE_BOOL(link_down, Lan9118PhyState), | ||
298 | + VMSTATE_END_OF_LIST() | 462 | + VMSTATE_END_OF_LIST() |
299 | + } | 463 | + } |
300 | +}; | 464 | +}; |
301 | + | 465 | + |
302 | +static void mphi_class_init(ObjectClass *klass, void *data) | 466 | +static void lan9118_phy_class_init(ObjectClass *klass, void *data) |
303 | +{ | 467 | +{ |
468 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
304 | + DeviceClass *dc = DEVICE_CLASS(klass); | 469 | + DeviceClass *dc = DEVICE_CLASS(klass); |
305 | + | 470 | + |
306 | + dc->realize = mphi_realize; | 471 | + rc->phases.hold = lan9118_phy_reset_hold; |
307 | + dc->reset = mphi_reset; | 472 | + dc->vmsd = &vmstate_lan9118_phy; |
308 | + dc->vmsd = &vmstate_mphi_state; | 473 | +} |
309 | +} | 474 | + |
310 | + | 475 | +static const TypeInfo types[] = { |
311 | +static const TypeInfo bcm2835_mphi_type_info = { | 476 | + { |
312 | + .name = TYPE_BCM2835_MPHI, | 477 | + .name = TYPE_LAN9118_PHY, |
313 | + .parent = TYPE_SYS_BUS_DEVICE, | 478 | + .parent = TYPE_SYS_BUS_DEVICE, |
314 | + .instance_size = sizeof(BCM2835MphiState), | 479 | + .instance_size = sizeof(Lan9118PhyState), |
315 | + .instance_init = mphi_init, | 480 | + .instance_init = lan9118_phy_init, |
316 | + .class_init = mphi_class_init, | 481 | + .class_init = lan9118_phy_class_init, |
482 | + } | ||
317 | +}; | 483 | +}; |
318 | + | 484 | + |
319 | +static void bcm2835_mphi_register_types(void) | 485 | +DEFINE_TYPES(types) |
320 | +{ | 486 | diff --git a/hw/net/Kconfig b/hw/net/Kconfig |
321 | + type_register_static(&bcm2835_mphi_type_info); | ||
322 | +} | ||
323 | + | ||
324 | +type_init(bcm2835_mphi_register_types) | ||
325 | diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs | ||
326 | index XXXXXXX..XXXXXXX 100644 | 487 | index XXXXXXX..XXXXXXX 100644 |
327 | --- a/hw/misc/Makefile.objs | 488 | --- a/hw/net/Kconfig |
328 | +++ b/hw/misc/Makefile.objs | 489 | +++ b/hw/net/Kconfig |
329 | @@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_OMAP) += omap_l4.o | 490 | @@ -XXX,XX +XXX,XX @@ config VMXNET3_PCI |
330 | common-obj-$(CONFIG_OMAP) += omap_sdrc.o | 491 | config SMC91C111 |
331 | common-obj-$(CONFIG_OMAP) += omap_tap.o | 492 | bool |
332 | common-obj-$(CONFIG_RASPI) += bcm2835_mbox.o | 493 | |
333 | +common-obj-$(CONFIG_RASPI) += bcm2835_mphi.o | 494 | +config LAN9118_PHY |
334 | common-obj-$(CONFIG_RASPI) += bcm2835_property.o | 495 | + bool |
335 | common-obj-$(CONFIG_RASPI) += bcm2835_rng.o | 496 | + |
336 | common-obj-$(CONFIG_RASPI) += bcm2835_thermal.o | 497 | config LAN9118 |
498 | bool | ||
499 | + select LAN9118_PHY | ||
500 | select PTIMER | ||
501 | |||
502 | config NE2000_ISA | ||
503 | diff --git a/hw/net/meson.build b/hw/net/meson.build | ||
504 | index XXXXXXX..XXXXXXX 100644 | ||
505 | --- a/hw/net/meson.build | ||
506 | +++ b/hw/net/meson.build | ||
507 | @@ -XXX,XX +XXX,XX @@ system_ss.add(when: 'CONFIG_VMXNET3_PCI', if_true: files('vmxnet3.c')) | ||
508 | |||
509 | system_ss.add(when: 'CONFIG_SMC91C111', if_true: files('smc91c111.c')) | ||
510 | system_ss.add(when: 'CONFIG_LAN9118', if_true: files('lan9118.c')) | ||
511 | +system_ss.add(when: 'CONFIG_LAN9118_PHY', if_true: files('lan9118_phy.c')) | ||
512 | system_ss.add(when: 'CONFIG_NE2000_ISA', if_true: files('ne2000-isa.c')) | ||
513 | system_ss.add(when: 'CONFIG_OPENCORES_ETH', if_true: files('opencores_eth.c')) | ||
514 | system_ss.add(when: 'CONFIG_XGMAC', if_true: files('xgmac.c')) | ||
337 | -- | 515 | -- |
338 | 2.20.1 | 516 | 2.34.1 |
339 | |||
340 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Bernhard Beschow <shentey@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | Replace printf() calls by qemu_log_mask(), which is disabled | 3 | imx_fec models the same PHY as lan9118_phy. The code is almost the same with |
4 | by default. This avoid flooding the terminal when fuzzing the | 4 | imx_fec having more logging and tracing. Merge these improvements into |
5 | device. | 5 | lan9118_phy and reuse in imx_fec to fix the code duplication. |
6 | 6 | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | Some migration state how resides in the new device model which breaks migration |
8 | Message-id: 20200525114123.21317-3-f4bug@amsat.org | 8 | compatibility for the following machines: |
9 | * imx25-pdk | ||
10 | * sabrelite | ||
11 | * mcimx7d-sabre | ||
12 | * mcimx6ul-evk | ||
13 | |||
14 | Signed-off-by: Bernhard Beschow <shentey@gmail.com> | ||
15 | Tested-by: Guenter Roeck <linux@roeck-us.net> | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
17 | Message-id: 20241102125724.532843-3-shentey@gmail.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 19 | --- |
12 | hw/arm/pxa2xx.c | 66 ++++++++++++++++++++++++++++++++++++------------- | 20 | include/hw/net/imx_fec.h | 9 ++- |
13 | 1 file changed, 49 insertions(+), 17 deletions(-) | 21 | hw/net/imx_fec.c | 146 ++++----------------------------------- |
22 | hw/net/lan9118_phy.c | 82 ++++++++++++++++------ | ||
23 | hw/net/Kconfig | 1 + | ||
24 | hw/net/trace-events | 10 +-- | ||
25 | 5 files changed, 85 insertions(+), 163 deletions(-) | ||
14 | 26 | ||
15 | diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c | 27 | diff --git a/include/hw/net/imx_fec.h b/include/hw/net/imx_fec.h |
16 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/pxa2xx.c | 29 | --- a/include/hw/net/imx_fec.h |
18 | +++ b/hw/arm/pxa2xx.c | 30 | +++ b/include/hw/net/imx_fec.h |
31 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(IMXFECState, IMX_FEC) | ||
32 | #define TYPE_IMX_ENET "imx.enet" | ||
33 | |||
34 | #include "hw/sysbus.h" | ||
35 | +#include "hw/net/lan9118_phy.h" | ||
36 | +#include "hw/irq.h" | ||
37 | #include "net/net.h" | ||
38 | |||
39 | #define ENET_EIR 1 | ||
40 | @@ -XXX,XX +XXX,XX @@ struct IMXFECState { | ||
41 | uint32_t tx_descriptor[ENET_TX_RING_NUM]; | ||
42 | uint32_t tx_ring_num; | ||
43 | |||
44 | - uint32_t phy_status; | ||
45 | - uint32_t phy_control; | ||
46 | - uint32_t phy_advertise; | ||
47 | - uint32_t phy_int; | ||
48 | - uint32_t phy_int_mask; | ||
49 | + Lan9118PhyState mii; | ||
50 | + IRQState mii_irq; | ||
51 | uint32_t phy_num; | ||
52 | bool phy_connected; | ||
53 | struct IMXFECState *phy_consumer; | ||
54 | diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/hw/net/imx_fec.c | ||
57 | +++ b/hw/net/imx_fec.c | ||
58 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_imx_eth_txdescs = { | ||
59 | |||
60 | static const VMStateDescription vmstate_imx_eth = { | ||
61 | .name = TYPE_IMX_FEC, | ||
62 | - .version_id = 2, | ||
63 | - .minimum_version_id = 2, | ||
64 | + .version_id = 3, | ||
65 | + .minimum_version_id = 3, | ||
66 | .fields = (const VMStateField[]) { | ||
67 | VMSTATE_UINT32_ARRAY(regs, IMXFECState, ENET_MAX), | ||
68 | VMSTATE_UINT32(rx_descriptor, IMXFECState), | ||
69 | VMSTATE_UINT32(tx_descriptor[0], IMXFECState), | ||
70 | - VMSTATE_UINT32(phy_status, IMXFECState), | ||
71 | - VMSTATE_UINT32(phy_control, IMXFECState), | ||
72 | - VMSTATE_UINT32(phy_advertise, IMXFECState), | ||
73 | - VMSTATE_UINT32(phy_int, IMXFECState), | ||
74 | - VMSTATE_UINT32(phy_int_mask, IMXFECState), | ||
75 | VMSTATE_END_OF_LIST() | ||
76 | }, | ||
77 | .subsections = (const VMStateDescription * const []) { | ||
78 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_imx_eth = { | ||
79 | }, | ||
80 | }; | ||
81 | |||
82 | -#define PHY_INT_ENERGYON (1 << 7) | ||
83 | -#define PHY_INT_AUTONEG_COMPLETE (1 << 6) | ||
84 | -#define PHY_INT_FAULT (1 << 5) | ||
85 | -#define PHY_INT_DOWN (1 << 4) | ||
86 | -#define PHY_INT_AUTONEG_LP (1 << 3) | ||
87 | -#define PHY_INT_PARFAULT (1 << 2) | ||
88 | -#define PHY_INT_AUTONEG_PAGE (1 << 1) | ||
89 | - | ||
90 | static void imx_eth_update(IMXFECState *s); | ||
91 | |||
92 | /* | ||
93 | @@ -XXX,XX +XXX,XX @@ static void imx_eth_update(IMXFECState *s); | ||
94 | * For now we don't handle any GPIO/interrupt line, so the OS will | ||
95 | * have to poll for the PHY status. | ||
96 | */ | ||
97 | -static void imx_phy_update_irq(IMXFECState *s) | ||
98 | +static void imx_phy_update_irq(void *opaque, int n, int level) | ||
99 | { | ||
100 | - imx_eth_update(s); | ||
101 | -} | ||
102 | - | ||
103 | -static void imx_phy_update_link(IMXFECState *s) | ||
104 | -{ | ||
105 | - /* Autonegotiation status mirrors link status. */ | ||
106 | - if (qemu_get_queue(s->nic)->link_down) { | ||
107 | - trace_imx_phy_update_link("down"); | ||
108 | - s->phy_status &= ~0x0024; | ||
109 | - s->phy_int |= PHY_INT_DOWN; | ||
110 | - } else { | ||
111 | - trace_imx_phy_update_link("up"); | ||
112 | - s->phy_status |= 0x0024; | ||
113 | - s->phy_int |= PHY_INT_ENERGYON; | ||
114 | - s->phy_int |= PHY_INT_AUTONEG_COMPLETE; | ||
115 | - } | ||
116 | - imx_phy_update_irq(s); | ||
117 | + imx_eth_update(opaque); | ||
118 | } | ||
119 | |||
120 | static void imx_eth_set_link(NetClientState *nc) | ||
121 | { | ||
122 | - imx_phy_update_link(IMX_FEC(qemu_get_nic_opaque(nc))); | ||
123 | -} | ||
124 | - | ||
125 | -static void imx_phy_reset(IMXFECState *s) | ||
126 | -{ | ||
127 | - trace_imx_phy_reset(); | ||
128 | - | ||
129 | - s->phy_status = 0x7809; | ||
130 | - s->phy_control = 0x3000; | ||
131 | - s->phy_advertise = 0x01e1; | ||
132 | - s->phy_int_mask = 0; | ||
133 | - s->phy_int = 0; | ||
134 | - imx_phy_update_link(s); | ||
135 | + lan9118_phy_update_link(&IMX_FEC(qemu_get_nic_opaque(nc))->mii, | ||
136 | + nc->link_down); | ||
137 | } | ||
138 | |||
139 | static uint32_t imx_phy_read(IMXFECState *s, int reg) | ||
140 | { | ||
141 | - uint32_t val; | ||
142 | uint32_t phy = reg / 32; | ||
143 | |||
144 | if (!s->phy_connected) { | ||
145 | @@ -XXX,XX +XXX,XX @@ static uint32_t imx_phy_read(IMXFECState *s, int reg) | ||
146 | |||
147 | reg %= 32; | ||
148 | |||
149 | - switch (reg) { | ||
150 | - case 0: /* Basic Control */ | ||
151 | - val = s->phy_control; | ||
152 | - break; | ||
153 | - case 1: /* Basic Status */ | ||
154 | - val = s->phy_status; | ||
155 | - break; | ||
156 | - case 2: /* ID1 */ | ||
157 | - val = 0x0007; | ||
158 | - break; | ||
159 | - case 3: /* ID2 */ | ||
160 | - val = 0xc0d1; | ||
161 | - break; | ||
162 | - case 4: /* Auto-neg advertisement */ | ||
163 | - val = s->phy_advertise; | ||
164 | - break; | ||
165 | - case 5: /* Auto-neg Link Partner Ability */ | ||
166 | - val = 0x0f71; | ||
167 | - break; | ||
168 | - case 6: /* Auto-neg Expansion */ | ||
169 | - val = 1; | ||
170 | - break; | ||
171 | - case 29: /* Interrupt source. */ | ||
172 | - val = s->phy_int; | ||
173 | - s->phy_int = 0; | ||
174 | - imx_phy_update_irq(s); | ||
175 | - break; | ||
176 | - case 30: /* Interrupt mask */ | ||
177 | - val = s->phy_int_mask; | ||
178 | - break; | ||
179 | - case 17: | ||
180 | - case 18: | ||
181 | - case 27: | ||
182 | - case 31: | ||
183 | - qemu_log_mask(LOG_UNIMP, "[%s.phy]%s: reg %d not implemented\n", | ||
184 | - TYPE_IMX_FEC, __func__, reg); | ||
185 | - val = 0; | ||
186 | - break; | ||
187 | - default: | ||
188 | - qemu_log_mask(LOG_GUEST_ERROR, "[%s.phy]%s: Bad address at offset %d\n", | ||
189 | - TYPE_IMX_FEC, __func__, reg); | ||
190 | - val = 0; | ||
191 | - break; | ||
192 | - } | ||
193 | - | ||
194 | - trace_imx_phy_read(val, phy, reg); | ||
195 | - | ||
196 | - return val; | ||
197 | + return lan9118_phy_read(&s->mii, reg); | ||
198 | } | ||
199 | |||
200 | static void imx_phy_write(IMXFECState *s, int reg, uint32_t val) | ||
201 | @@ -XXX,XX +XXX,XX @@ static void imx_phy_write(IMXFECState *s, int reg, uint32_t val) | ||
202 | |||
203 | reg %= 32; | ||
204 | |||
205 | - trace_imx_phy_write(val, phy, reg); | ||
206 | - | ||
207 | - switch (reg) { | ||
208 | - case 0: /* Basic Control */ | ||
209 | - if (val & 0x8000) { | ||
210 | - imx_phy_reset(s); | ||
211 | - } else { | ||
212 | - s->phy_control = val & 0x7980; | ||
213 | - /* Complete autonegotiation immediately. */ | ||
214 | - if (val & 0x1000) { | ||
215 | - s->phy_status |= 0x0020; | ||
216 | - } | ||
217 | - } | ||
218 | - break; | ||
219 | - case 4: /* Auto-neg advertisement */ | ||
220 | - s->phy_advertise = (val & 0x2d7f) | 0x80; | ||
221 | - break; | ||
222 | - case 30: /* Interrupt mask */ | ||
223 | - s->phy_int_mask = val & 0xff; | ||
224 | - imx_phy_update_irq(s); | ||
225 | - break; | ||
226 | - case 17: | ||
227 | - case 18: | ||
228 | - case 27: | ||
229 | - case 31: | ||
230 | - qemu_log_mask(LOG_UNIMP, "[%s.phy)%s: reg %d not implemented\n", | ||
231 | - TYPE_IMX_FEC, __func__, reg); | ||
232 | - break; | ||
233 | - default: | ||
234 | - qemu_log_mask(LOG_GUEST_ERROR, "[%s.phy]%s: Bad address at offset %d\n", | ||
235 | - TYPE_IMX_FEC, __func__, reg); | ||
236 | - break; | ||
237 | - } | ||
238 | + lan9118_phy_write(&s->mii, reg, val); | ||
239 | } | ||
240 | |||
241 | static void imx_fec_read_bd(IMXFECBufDesc *bd, dma_addr_t addr) | ||
242 | @@ -XXX,XX +XXX,XX @@ static void imx_eth_reset(DeviceState *d) | ||
243 | |||
244 | s->rx_descriptor = 0; | ||
245 | memset(s->tx_descriptor, 0, sizeof(s->tx_descriptor)); | ||
246 | - | ||
247 | - /* We also reset the PHY */ | ||
248 | - imx_phy_reset(s); | ||
249 | } | ||
250 | |||
251 | static uint32_t imx_default_read(IMXFECState *s, uint32_t index) | ||
252 | @@ -XXX,XX +XXX,XX @@ static void imx_eth_realize(DeviceState *dev, Error **errp) | ||
253 | sysbus_init_irq(sbd, &s->irq[0]); | ||
254 | sysbus_init_irq(sbd, &s->irq[1]); | ||
255 | |||
256 | + qemu_init_irq(&s->mii_irq, imx_phy_update_irq, s, 0); | ||
257 | + object_initialize_child(OBJECT(s), "mii", &s->mii, TYPE_LAN9118_PHY); | ||
258 | + if (!sysbus_realize_and_unref(SYS_BUS_DEVICE(&s->mii), errp)) { | ||
259 | + return; | ||
260 | + } | ||
261 | + qdev_connect_gpio_out(DEVICE(&s->mii), 0, &s->mii_irq); | ||
262 | + | ||
263 | qemu_macaddr_default_if_unset(&s->conf.macaddr); | ||
264 | |||
265 | s->nic = qemu_new_nic(&imx_eth_net_info, &s->conf, | ||
266 | diff --git a/hw/net/lan9118_phy.c b/hw/net/lan9118_phy.c | ||
267 | index XXXXXXX..XXXXXXX 100644 | ||
268 | --- a/hw/net/lan9118_phy.c | ||
269 | +++ b/hw/net/lan9118_phy.c | ||
19 | @@ -XXX,XX +XXX,XX @@ | 270 | @@ -XXX,XX +XXX,XX @@ |
20 | #include "sysemu/blockdev.h" | 271 | * Copyright (c) 2009 CodeSourcery, LLC. |
21 | #include "sysemu/qtest.h" | 272 | * Written by Paul Brook |
22 | #include "qemu/cutils.h" | 273 | * |
23 | +#include "qemu/log.h" | 274 | + * Copyright (c) 2013 Jean-Christophe Dubois. <jcd@tribudubois.net> |
24 | 275 | + * | |
25 | static struct { | 276 | * This code is licensed under the GNU GPL v2 |
26 | hwaddr io_base; | 277 | * |
27 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_pm_read(void *opaque, hwaddr addr, | 278 | * Contributions after 2012-01-13 are licensed under the terms of the |
28 | return s->pm_regs[addr >> 2]; | 279 | @@ -XXX,XX +XXX,XX @@ |
280 | #include "hw/resettable.h" | ||
281 | #include "migration/vmstate.h" | ||
282 | #include "qemu/log.h" | ||
283 | +#include "trace.h" | ||
284 | |||
285 | #define PHY_INT_ENERGYON (1 << 7) | ||
286 | #define PHY_INT_AUTONEG_COMPLETE (1 << 6) | ||
287 | @@ -XXX,XX +XXX,XX @@ uint16_t lan9118_phy_read(Lan9118PhyState *s, int reg) | ||
288 | |||
289 | switch (reg) { | ||
290 | case 0: /* Basic Control */ | ||
291 | - return s->control; | ||
292 | + val = s->control; | ||
293 | + break; | ||
294 | case 1: /* Basic Status */ | ||
295 | - return s->status; | ||
296 | + val = s->status; | ||
297 | + break; | ||
298 | case 2: /* ID1 */ | ||
299 | - return 0x0007; | ||
300 | + val = 0x0007; | ||
301 | + break; | ||
302 | case 3: /* ID2 */ | ||
303 | - return 0xc0d1; | ||
304 | + val = 0xc0d1; | ||
305 | + break; | ||
306 | case 4: /* Auto-neg advertisement */ | ||
307 | - return s->advertise; | ||
308 | + val = s->advertise; | ||
309 | + break; | ||
310 | case 5: /* Auto-neg Link Partner Ability */ | ||
311 | - return 0x0f71; | ||
312 | + val = 0x0f71; | ||
313 | + break; | ||
314 | case 6: /* Auto-neg Expansion */ | ||
315 | - return 1; | ||
316 | - /* TODO 17, 18, 27, 29, 30, 31 */ | ||
317 | + val = 1; | ||
318 | + break; | ||
319 | case 29: /* Interrupt source. */ | ||
320 | val = s->ints; | ||
321 | s->ints = 0; | ||
322 | lan9118_phy_update_irq(s); | ||
323 | - return val; | ||
324 | + break; | ||
325 | case 30: /* Interrupt mask */ | ||
326 | - return s->int_mask; | ||
327 | + val = s->int_mask; | ||
328 | + break; | ||
329 | + case 17: | ||
330 | + case 18: | ||
331 | + case 27: | ||
332 | + case 31: | ||
333 | + qemu_log_mask(LOG_UNIMP, "%s: reg %d not implemented\n", | ||
334 | + __func__, reg); | ||
335 | + val = 0; | ||
336 | + break; | ||
29 | default: | 337 | default: |
30 | fail: | 338 | - qemu_log_mask(LOG_GUEST_ERROR, |
31 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | 339 | - "lan9118_phy_read: PHY read reg %d\n", reg); |
32 | + qemu_log_mask(LOG_GUEST_ERROR, | 340 | - return 0; |
33 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | 341 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad address at offset %d\n", |
34 | + __func__, addr); | 342 | + __func__, reg); |
35 | break; | 343 | + val = 0; |
344 | + break; | ||
36 | } | 345 | } |
37 | return 0; | 346 | + |
38 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_pm_write(void *opaque, hwaddr addr, | 347 | + trace_lan9118_phy_read(val, reg); |
39 | s->pm_regs[addr >> 2] = value; | 348 | + |
40 | break; | 349 | + return val; |
41 | } | 350 | } |
42 | - | 351 | |
43 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | 352 | void lan9118_phy_write(Lan9118PhyState *s, int reg, uint16_t val) |
44 | + qemu_log_mask(LOG_GUEST_ERROR, | 353 | { |
45 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | 354 | + trace_lan9118_phy_write(val, reg); |
46 | + __func__, addr); | 355 | + |
47 | break; | 356 | switch (reg) { |
48 | } | 357 | case 0: /* Basic Control */ |
49 | } | 358 | if (val & 0x8000) { |
50 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_cm_read(void *opaque, hwaddr addr, | 359 | lan9118_phy_reset(s); |
51 | return s->cm_regs[CCCR >> 2] | (3 << 28); | 360 | - break; |
52 | 361 | - } | |
53 | default: | 362 | - s->control = val & 0x7980; |
54 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | 363 | - /* Complete autonegotiation immediately. */ |
55 | + qemu_log_mask(LOG_GUEST_ERROR, | 364 | - if (val & 0x1000) { |
56 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | 365 | - s->status |= 0x0020; |
57 | + __func__, addr); | 366 | + } else { |
58 | break; | 367 | + s->control = val & 0x7980; |
59 | } | 368 | + /* Complete autonegotiation immediately. */ |
60 | return 0; | 369 | + if (val & 0x1000) { |
61 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_cm_write(void *opaque, hwaddr addr, | 370 | + s->status |= 0x0020; |
62 | break; | 371 | + } |
63 | |||
64 | default: | ||
65 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
66 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
67 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | ||
68 | + __func__, addr); | ||
69 | break; | ||
70 | } | ||
71 | } | ||
72 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_mm_read(void *opaque, hwaddr addr, | ||
73 | return s->mm_regs[addr >> 2]; | ||
74 | /* fall through */ | ||
75 | default: | ||
76 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
77 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
78 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | ||
79 | + __func__, addr); | ||
80 | break; | ||
81 | } | ||
82 | return 0; | ||
83 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_mm_write(void *opaque, hwaddr addr, | ||
84 | } | ||
85 | |||
86 | default: | ||
87 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
88 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
89 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | ||
90 | + __func__, addr); | ||
91 | break; | ||
92 | } | ||
93 | } | ||
94 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_ssp_read(void *opaque, hwaddr addr, | ||
95 | case SSACD: | ||
96 | return s->ssacd; | ||
97 | default: | ||
98 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
99 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
100 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | ||
101 | + __func__, addr); | ||
102 | break; | ||
103 | } | ||
104 | return 0; | ||
105 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_ssp_write(void *opaque, hwaddr addr, | ||
106 | break; | ||
107 | |||
108 | default: | ||
109 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
110 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
111 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | ||
112 | + __func__, addr); | ||
113 | break; | ||
114 | } | ||
115 | } | ||
116 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_rtc_read(void *opaque, hwaddr addr, | ||
117 | else | ||
118 | return s->last_swcr; | ||
119 | default: | ||
120 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
121 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
122 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | ||
123 | + __func__, addr); | ||
124 | break; | ||
125 | } | ||
126 | return 0; | ||
127 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_rtc_write(void *opaque, hwaddr addr, | ||
128 | break; | ||
129 | |||
130 | default: | ||
131 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
132 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
133 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | ||
134 | + __func__, addr); | ||
135 | } | ||
136 | } | ||
137 | |||
138 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_i2c_read(void *opaque, hwaddr addr, | ||
139 | s->ibmr = 0; | ||
140 | return s->ibmr; | ||
141 | default: | ||
142 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
143 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
144 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | ||
145 | + __func__, addr); | ||
146 | break; | ||
147 | } | ||
148 | return 0; | ||
149 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_i2c_write(void *opaque, hwaddr addr, | ||
150 | break; | ||
151 | |||
152 | default: | ||
153 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
154 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
155 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | ||
156 | + __func__, addr); | ||
157 | } | ||
158 | } | ||
159 | |||
160 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_i2s_read(void *opaque, hwaddr addr, | ||
161 | } | ||
162 | return 0; | ||
163 | default: | ||
164 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | ||
165 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
166 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | ||
167 | + __func__, addr); | ||
168 | break; | ||
169 | } | ||
170 | return 0; | ||
171 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_i2s_write(void *opaque, hwaddr addr, | ||
172 | } | 372 | } |
173 | break; | 373 | break; |
374 | case 4: /* Auto-neg advertisement */ | ||
375 | s->advertise = (val & 0x2d7f) | 0x80; | ||
376 | break; | ||
377 | - /* TODO 17, 18, 27, 31 */ | ||
378 | case 30: /* Interrupt mask */ | ||
379 | s->int_mask = val & 0xff; | ||
380 | lan9118_phy_update_irq(s); | ||
381 | break; | ||
382 | + case 17: | ||
383 | + case 18: | ||
384 | + case 27: | ||
385 | + case 31: | ||
386 | + qemu_log_mask(LOG_UNIMP, "%s: reg %d not implemented\n", | ||
387 | + __func__, reg); | ||
388 | + break; | ||
174 | default: | 389 | default: |
175 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | 390 | - qemu_log_mask(LOG_GUEST_ERROR, |
176 | + qemu_log_mask(LOG_GUEST_ERROR, | 391 | - "lan9118_phy_write: PHY write reg %d = 0x%04x\n", reg, val); |
177 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | 392 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad address at offset %d\n", |
178 | + __func__, addr); | 393 | + __func__, reg); |
394 | + break; | ||
179 | } | 395 | } |
180 | } | 396 | } |
181 | 397 | ||
182 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_fir_read(void *opaque, hwaddr addr, | 398 | @@ -XXX,XX +XXX,XX @@ void lan9118_phy_update_link(Lan9118PhyState *s, bool link_down) |
183 | case ICFOR: | 399 | |
184 | return s->rx_len; | 400 | /* Autonegotiation status mirrors link status. */ |
185 | default: | 401 | if (link_down) { |
186 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | 402 | + trace_lan9118_phy_update_link("down"); |
187 | + qemu_log_mask(LOG_GUEST_ERROR, | 403 | s->status &= ~0x0024; |
188 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | 404 | s->ints |= PHY_INT_DOWN; |
189 | + __func__, addr); | 405 | } else { |
190 | break; | 406 | + trace_lan9118_phy_update_link("up"); |
191 | } | 407 | s->status |= 0x0024; |
192 | return 0; | 408 | s->ints |= PHY_INT_ENERGYON; |
193 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_fir_write(void *opaque, hwaddr addr, | 409 | s->ints |= PHY_INT_AUTONEG_COMPLETE; |
194 | case ICFOR: | 410 | @@ -XXX,XX +XXX,XX @@ void lan9118_phy_update_link(Lan9118PhyState *s, bool link_down) |
195 | break; | 411 | |
196 | default: | 412 | void lan9118_phy_reset(Lan9118PhyState *s) |
197 | - printf("%s: Bad register " REG_FMT "\n", __func__, addr); | 413 | { |
198 | + qemu_log_mask(LOG_GUEST_ERROR, | 414 | + trace_lan9118_phy_reset(); |
199 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | 415 | + |
200 | + __func__, addr); | 416 | s->control = 0x3000; |
201 | } | 417 | s->status = 0x7809; |
202 | } | 418 | s->advertise = 0x01e1; |
203 | 419 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_lan9118_phy = { | |
420 | .version_id = 1, | ||
421 | .minimum_version_id = 1, | ||
422 | .fields = (const VMStateField[]) { | ||
423 | - VMSTATE_UINT16(control, Lan9118PhyState), | ||
424 | VMSTATE_UINT16(status, Lan9118PhyState), | ||
425 | + VMSTATE_UINT16(control, Lan9118PhyState), | ||
426 | VMSTATE_UINT16(advertise, Lan9118PhyState), | ||
427 | VMSTATE_UINT16(ints, Lan9118PhyState), | ||
428 | VMSTATE_UINT16(int_mask, Lan9118PhyState), | ||
429 | diff --git a/hw/net/Kconfig b/hw/net/Kconfig | ||
430 | index XXXXXXX..XXXXXXX 100644 | ||
431 | --- a/hw/net/Kconfig | ||
432 | +++ b/hw/net/Kconfig | ||
433 | @@ -XXX,XX +XXX,XX @@ config ALLWINNER_SUN8I_EMAC | ||
434 | |||
435 | config IMX_FEC | ||
436 | bool | ||
437 | + select LAN9118_PHY | ||
438 | |||
439 | config CADENCE | ||
440 | bool | ||
441 | diff --git a/hw/net/trace-events b/hw/net/trace-events | ||
442 | index XXXXXXX..XXXXXXX 100644 | ||
443 | --- a/hw/net/trace-events | ||
444 | +++ b/hw/net/trace-events | ||
445 | @@ -XXX,XX +XXX,XX @@ allwinner_sun8i_emac_set_link(bool active) "Set link: active=%u" | ||
446 | allwinner_sun8i_emac_read(uint64_t offset, uint64_t val) "MMIO read: offset=0x%" PRIx64 " value=0x%" PRIx64 | ||
447 | allwinner_sun8i_emac_write(uint64_t offset, uint64_t val) "MMIO write: offset=0x%" PRIx64 " value=0x%" PRIx64 | ||
448 | |||
449 | +# lan9118_phy.c | ||
450 | +lan9118_phy_read(uint16_t val, int reg) "[0x%02x] -> 0x%04" PRIx16 | ||
451 | +lan9118_phy_write(uint16_t val, int reg) "[0x%02x] <- 0x%04" PRIx16 | ||
452 | +lan9118_phy_update_link(const char *s) "%s" | ||
453 | +lan9118_phy_reset(void) "" | ||
454 | + | ||
455 | # lance.c | ||
456 | lance_mem_readw(uint64_t addr, uint32_t ret) "addr=0x%"PRIx64"val=0x%04x" | ||
457 | lance_mem_writew(uint64_t addr, uint32_t val) "addr=0x%"PRIx64"val=0x%04x" | ||
458 | @@ -XXX,XX +XXX,XX @@ i82596_set_multicast(uint16_t count) "Added %d multicast entries" | ||
459 | i82596_channel_attention(void *s) "%p: Received CHANNEL ATTENTION" | ||
460 | |||
461 | # imx_fec.c | ||
462 | -imx_phy_read(uint32_t val, int phy, int reg) "0x%04"PRIx32" <= phy[%d].reg[%d]" | ||
463 | imx_phy_read_num(int phy, int configured) "read request from unconfigured phy %d (configured %d)" | ||
464 | -imx_phy_write(uint32_t val, int phy, int reg) "0x%04"PRIx32" => phy[%d].reg[%d]" | ||
465 | imx_phy_write_num(int phy, int configured) "write request to unconfigured phy %d (configured %d)" | ||
466 | -imx_phy_update_link(const char *s) "%s" | ||
467 | -imx_phy_reset(void) "" | ||
468 | imx_fec_read_bd(uint64_t addr, int flags, int len, int data) "tx_bd 0x%"PRIx64" flags 0x%04x len %d data 0x%08x" | ||
469 | imx_enet_read_bd(uint64_t addr, int flags, int len, int data, int options, int status) "tx_bd 0x%"PRIx64" flags 0x%04x len %d data 0x%08x option 0x%04x status 0x%04x" | ||
470 | imx_eth_tx_bd_busy(void) "tx_bd ran out of descriptors to transmit" | ||
204 | -- | 471 | -- |
205 | 2.20.1 | 472 | 2.34.1 |
206 | |||
207 | diff view generated by jsdifflib |
1 | From: Eden Mikitas <e.mikitas@gmail.com> | 1 | From: Bernhard Beschow <shentey@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | When inserting the value retrieved (rx) from the spi slave, rx is pushed to | 3 | Turns 0x70 into 0xe0 (== 0x70 << 1) which adds the missing MII_ANLPAR_TX and |
4 | rx_fifo after being cast to uint8_t. rx_fifo is a fifo32, and the rx | 4 | fixes the MSB of selector field to be zero, as specified in the datasheet. |
5 | register the driver uses is also 32 bit. This zeroes the 24 most | ||
6 | significant bits of rx. This proved problematic with devices that expect to | ||
7 | use the whole 32 bits of the rx register. | ||
8 | 5 | ||
9 | Signed-off-by: Eden Mikitas <e.mikitas@gmail.com> | 6 | Fixes: 2a424990170b "LAN9118 emulation" |
10 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 7 | Signed-off-by: Bernhard Beschow <shentey@gmail.com> |
8 | Tested-by: Guenter Roeck <linux@roeck-us.net> | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Message-id: 20241102125724.532843-4-shentey@gmail.com | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 12 | --- |
13 | hw/ssi/imx_spi.c | 2 +- | 13 | hw/net/lan9118_phy.c | 2 +- |
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | 14 | 1 file changed, 1 insertion(+), 1 deletion(-) |
15 | 15 | ||
16 | diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c | 16 | diff --git a/hw/net/lan9118_phy.c b/hw/net/lan9118_phy.c |
17 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/ssi/imx_spi.c | 18 | --- a/hw/net/lan9118_phy.c |
19 | +++ b/hw/ssi/imx_spi.c | 19 | +++ b/hw/net/lan9118_phy.c |
20 | @@ -XXX,XX +XXX,XX @@ static void imx_spi_flush_txfifo(IMXSPIState *s) | 20 | @@ -XXX,XX +XXX,XX @@ uint16_t lan9118_phy_read(Lan9118PhyState *s, int reg) |
21 | if (fifo32_is_full(&s->rx_fifo)) { | 21 | val = s->advertise; |
22 | s->regs[ECSPI_STATREG] |= ECSPI_STATREG_RO; | 22 | break; |
23 | } else { | 23 | case 5: /* Auto-neg Link Partner Ability */ |
24 | - fifo32_push(&s->rx_fifo, (uint8_t)rx); | 24 | - val = 0x0f71; |
25 | + fifo32_push(&s->rx_fifo, rx); | 25 | + val = 0x0fe1; |
26 | } | 26 | break; |
27 | 27 | case 6: /* Auto-neg Expansion */ | |
28 | if (s->burst_length <= 0) { | 28 | val = 1; |
29 | -- | 29 | -- |
30 | 2.20.1 | 30 | 2.34.1 |
31 | |||
32 | diff view generated by jsdifflib |
1 | From: Paul Zimmerman <pauldzim@gmail.com> | 1 | From: Bernhard Beschow <shentey@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | The dwc-hsotg (dwc2) USB host depends on a short packet to | 3 | Prefer named constants over magic values for better readability. |
4 | indicate the end of an IN transfer. The usb-storage driver | ||
5 | currently doesn't provide this, so fix it. | ||
6 | 4 | ||
7 | I have tested this change rather extensively using a PC | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | emulation with xhci, ehci, and uhci controllers, and have | 6 | Signed-off-by: Bernhard Beschow <shentey@gmail.com> |
9 | not observed any regressions. | 7 | Tested-by: Guenter Roeck <linux@roeck-us.net> |
10 | 8 | Message-id: 20241102125724.532843-5-shentey@gmail.com | |
11 | Signed-off-by: Paul Zimmerman <pauldzim@gmail.com> | ||
12 | Message-id: 20200520235349.21215-6-pauldzim@gmail.com | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 10 | --- |
15 | hw/usb/dev-storage.c | 15 ++++++++++++++- | 11 | include/hw/net/mii.h | 6 +++++ |
16 | 1 file changed, 14 insertions(+), 1 deletion(-) | 12 | hw/net/lan9118_phy.c | 63 ++++++++++++++++++++++++++++---------------- |
13 | 2 files changed, 46 insertions(+), 23 deletions(-) | ||
17 | 14 | ||
18 | diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c | 15 | diff --git a/include/hw/net/mii.h b/include/hw/net/mii.h |
19 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/usb/dev-storage.c | 17 | --- a/include/hw/net/mii.h |
21 | +++ b/hw/usb/dev-storage.c | 18 | +++ b/include/hw/net/mii.h |
22 | @@ -XXX,XX +XXX,XX @@ static void usb_msd_copy_data(MSDState *s, USBPacket *p) | 19 | @@ -XXX,XX +XXX,XX @@ |
23 | usb_packet_copy(p, scsi_req_get_buf(s->req) + s->scsi_off, len); | 20 | #define MII_BMSR_JABBER (1 << 1) /* Jabber detected */ |
24 | s->scsi_len -= len; | 21 | #define MII_BMSR_EXTCAP (1 << 0) /* Ext-reg capability */ |
25 | s->scsi_off += len; | 22 | |
26 | + if (len > s->data_len) { | 23 | +#define MII_ANAR_RFAULT (1 << 13) /* Say we can detect faults */ |
27 | + len = s->data_len; | 24 | #define MII_ANAR_PAUSE_ASYM (1 << 11) /* Try for asymmetric pause */ |
28 | + } | 25 | #define MII_ANAR_PAUSE (1 << 10) /* Try for pause */ |
29 | s->data_len -= len; | 26 | #define MII_ANAR_TXFD (1 << 8) |
30 | if (s->scsi_len == 0 || s->data_len == 0) { | 27 | @@ -XXX,XX +XXX,XX @@ |
31 | scsi_req_continue(s->req); | 28 | #define MII_ANAR_10FD (1 << 6) |
32 | @@ -XXX,XX +XXX,XX @@ static void usb_msd_command_complete(SCSIRequest *req, uint32_t status, size_t r | 29 | #define MII_ANAR_10 (1 << 5) |
33 | if (s->data_len) { | 30 | #define MII_ANAR_CSMACD (1 << 0) |
34 | int len = (p->iov.size - p->actual_length); | 31 | +#define MII_ANAR_SELECT (0x001f) /* Selector bits */ |
35 | usb_packet_skip(p, len); | 32 | |
36 | + if (len > s->data_len) { | 33 | #define MII_ANLPAR_ACK (1 << 14) |
37 | + len = s->data_len; | 34 | #define MII_ANLPAR_PAUSEASY (1 << 11) /* can pause asymmetrically */ |
38 | + } | 35 | @@ -XXX,XX +XXX,XX @@ |
39 | s->data_len -= len; | 36 | #define RTL8201CP_PHYID1 0x0000 |
37 | #define RTL8201CP_PHYID2 0x8201 | ||
38 | |||
39 | +/* SMSC LAN9118 */ | ||
40 | +#define SMSCLAN9118_PHYID1 0x0007 | ||
41 | +#define SMSCLAN9118_PHYID2 0xc0d1 | ||
42 | + | ||
43 | /* RealTek 8211E */ | ||
44 | #define RTL8211E_PHYID1 0x001c | ||
45 | #define RTL8211E_PHYID2 0xc915 | ||
46 | diff --git a/hw/net/lan9118_phy.c b/hw/net/lan9118_phy.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/hw/net/lan9118_phy.c | ||
49 | +++ b/hw/net/lan9118_phy.c | ||
50 | @@ -XXX,XX +XXX,XX @@ | ||
51 | |||
52 | #include "qemu/osdep.h" | ||
53 | #include "hw/net/lan9118_phy.h" | ||
54 | +#include "hw/net/mii.h" | ||
55 | #include "hw/irq.h" | ||
56 | #include "hw/resettable.h" | ||
57 | #include "migration/vmstate.h" | ||
58 | @@ -XXX,XX +XXX,XX @@ uint16_t lan9118_phy_read(Lan9118PhyState *s, int reg) | ||
59 | uint16_t val; | ||
60 | |||
61 | switch (reg) { | ||
62 | - case 0: /* Basic Control */ | ||
63 | + case MII_BMCR: | ||
64 | val = s->control; | ||
65 | break; | ||
66 | - case 1: /* Basic Status */ | ||
67 | + case MII_BMSR: | ||
68 | val = s->status; | ||
69 | break; | ||
70 | - case 2: /* ID1 */ | ||
71 | - val = 0x0007; | ||
72 | + case MII_PHYID1: | ||
73 | + val = SMSCLAN9118_PHYID1; | ||
74 | break; | ||
75 | - case 3: /* ID2 */ | ||
76 | - val = 0xc0d1; | ||
77 | + case MII_PHYID2: | ||
78 | + val = SMSCLAN9118_PHYID2; | ||
79 | break; | ||
80 | - case 4: /* Auto-neg advertisement */ | ||
81 | + case MII_ANAR: | ||
82 | val = s->advertise; | ||
83 | break; | ||
84 | - case 5: /* Auto-neg Link Partner Ability */ | ||
85 | - val = 0x0fe1; | ||
86 | + case MII_ANLPAR: | ||
87 | + val = MII_ANLPAR_PAUSEASY | MII_ANLPAR_PAUSE | MII_ANLPAR_T4 | | ||
88 | + MII_ANLPAR_TXFD | MII_ANLPAR_TX | MII_ANLPAR_10FD | | ||
89 | + MII_ANLPAR_10 | MII_ANLPAR_CSMACD; | ||
90 | break; | ||
91 | - case 6: /* Auto-neg Expansion */ | ||
92 | - val = 1; | ||
93 | + case MII_ANER: | ||
94 | + val = MII_ANER_NWAY; | ||
95 | break; | ||
96 | case 29: /* Interrupt source. */ | ||
97 | val = s->ints; | ||
98 | @@ -XXX,XX +XXX,XX @@ void lan9118_phy_write(Lan9118PhyState *s, int reg, uint16_t val) | ||
99 | trace_lan9118_phy_write(val, reg); | ||
100 | |||
101 | switch (reg) { | ||
102 | - case 0: /* Basic Control */ | ||
103 | - if (val & 0x8000) { | ||
104 | + case MII_BMCR: | ||
105 | + if (val & MII_BMCR_RESET) { | ||
106 | lan9118_phy_reset(s); | ||
107 | } else { | ||
108 | - s->control = val & 0x7980; | ||
109 | + s->control = val & (MII_BMCR_LOOPBACK | MII_BMCR_SPEED100 | | ||
110 | + MII_BMCR_AUTOEN | MII_BMCR_PDOWN | MII_BMCR_FD | | ||
111 | + MII_BMCR_CTST); | ||
112 | /* Complete autonegotiation immediately. */ | ||
113 | - if (val & 0x1000) { | ||
114 | - s->status |= 0x0020; | ||
115 | + if (val & MII_BMCR_AUTOEN) { | ||
116 | + s->status |= MII_BMSR_AN_COMP; | ||
40 | } | 117 | } |
41 | if (s->data_len == 0) { | 118 | } |
42 | @@ -XXX,XX +XXX,XX @@ static void usb_msd_handle_data(USBDevice *dev, USBPacket *p) | 119 | break; |
43 | int len = p->iov.size - p->actual_length; | 120 | - case 4: /* Auto-neg advertisement */ |
44 | if (len) { | 121 | - s->advertise = (val & 0x2d7f) | 0x80; |
45 | usb_packet_skip(p, len); | 122 | + case MII_ANAR: |
46 | + if (len > s->data_len) { | 123 | + s->advertise = (val & (MII_ANAR_RFAULT | MII_ANAR_PAUSE_ASYM | |
47 | + len = s->data_len; | 124 | + MII_ANAR_PAUSE | MII_ANAR_10FD | MII_ANAR_10 | |
48 | + } | 125 | + MII_ANAR_SELECT)) |
49 | s->data_len -= len; | 126 | + | MII_ANAR_TX; |
50 | if (s->data_len == 0) { | 127 | break; |
51 | s->mode = USB_MSDM_CSW; | 128 | case 30: /* Interrupt mask */ |
52 | @@ -XXX,XX +XXX,XX @@ static void usb_msd_handle_data(USBDevice *dev, USBPacket *p) | 129 | s->int_mask = val & 0xff; |
53 | int len = p->iov.size - p->actual_length; | 130 | @@ -XXX,XX +XXX,XX @@ void lan9118_phy_update_link(Lan9118PhyState *s, bool link_down) |
54 | if (len) { | 131 | /* Autonegotiation status mirrors link status. */ |
55 | usb_packet_skip(p, len); | 132 | if (link_down) { |
56 | + if (len > s->data_len) { | 133 | trace_lan9118_phy_update_link("down"); |
57 | + len = s->data_len; | 134 | - s->status &= ~0x0024; |
58 | + } | 135 | + s->status &= ~(MII_BMSR_AN_COMP | MII_BMSR_LINK_ST); |
59 | s->data_len -= len; | 136 | s->ints |= PHY_INT_DOWN; |
60 | if (s->data_len == 0) { | 137 | } else { |
61 | s->mode = USB_MSDM_CSW; | 138 | trace_lan9118_phy_update_link("up"); |
62 | } | 139 | - s->status |= 0x0024; |
63 | } | 140 | + s->status |= MII_BMSR_AN_COMP | MII_BMSR_LINK_ST; |
64 | } | 141 | s->ints |= PHY_INT_ENERGYON; |
65 | - if (p->actual_length < p->iov.size) { | 142 | s->ints |= PHY_INT_AUTONEG_COMPLETE; |
66 | + if (p->actual_length < p->iov.size && (p->short_not_ok || | 143 | } |
67 | + s->scsi_len >= p->ep->max_packet_size)) { | 144 | @@ -XXX,XX +XXX,XX @@ void lan9118_phy_reset(Lan9118PhyState *s) |
68 | DPRINTF("Deferring packet %p [wait data-in]\n", p); | 145 | { |
69 | s->packet = p; | 146 | trace_lan9118_phy_reset(); |
70 | p->status = USB_RET_ASYNC; | 147 | |
148 | - s->control = 0x3000; | ||
149 | - s->status = 0x7809; | ||
150 | - s->advertise = 0x01e1; | ||
151 | + s->control = MII_BMCR_AUTOEN | MII_BMCR_SPEED100; | ||
152 | + s->status = MII_BMSR_100TX_FD | ||
153 | + | MII_BMSR_100TX_HD | ||
154 | + | MII_BMSR_10T_FD | ||
155 | + | MII_BMSR_10T_HD | ||
156 | + | MII_BMSR_AUTONEG | ||
157 | + | MII_BMSR_EXTCAP; | ||
158 | + s->advertise = MII_ANAR_TXFD | ||
159 | + | MII_ANAR_TX | ||
160 | + | MII_ANAR_10FD | ||
161 | + | MII_ANAR_10 | ||
162 | + | MII_ANAR_CSMACD; | ||
163 | s->int_mask = 0; | ||
164 | s->ints = 0; | ||
165 | lan9118_phy_update_link(s, s->link_down); | ||
71 | -- | 166 | -- |
72 | 2.20.1 | 167 | 2.34.1 |
73 | |||
74 | diff view generated by jsdifflib |
1 | From: Paul Zimmerman <pauldzim@gmail.com> | 1 | From: Bernhard Beschow <shentey@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | Add a check for functional dwc-hsotg (dwc2) USB host emulation to | 3 | The real device advertises this mode and the device model already advertises |
4 | the Raspi 2 acceptance test | 4 | 100 mbps half duplex and 10 mbps full+half duplex. So advertise this mode to |
5 | make the model more realistic. | ||
5 | 6 | ||
6 | Signed-off-by: Paul Zimmerman <pauldzim@gmail.com> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Philippe Mathieu-Daude <f4bug@amsat.org> | 8 | Signed-off-by: Bernhard Beschow <shentey@gmail.com> |
8 | Message-id: 20200520235349.21215-8-pauldzim@gmail.com | 9 | Tested-by: Guenter Roeck <linux@roeck-us.net> |
10 | Message-id: 20241102125724.532843-6-shentey@gmail.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 12 | --- |
11 | tests/acceptance/boot_linux_console.py | 9 +++++++-- | 13 | hw/net/lan9118_phy.c | 4 ++-- |
12 | 1 file changed, 7 insertions(+), 2 deletions(-) | 14 | 1 file changed, 2 insertions(+), 2 deletions(-) |
13 | 15 | ||
14 | diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py | 16 | diff --git a/hw/net/lan9118_phy.c b/hw/net/lan9118_phy.c |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/tests/acceptance/boot_linux_console.py | 18 | --- a/hw/net/lan9118_phy.c |
17 | +++ b/tests/acceptance/boot_linux_console.py | 19 | +++ b/hw/net/lan9118_phy.c |
18 | @@ -XXX,XX +XXX,XX @@ class BootLinuxConsole(LinuxKernelTest): | 20 | @@ -XXX,XX +XXX,XX @@ void lan9118_phy_write(Lan9118PhyState *s, int reg, uint16_t val) |
19 | 21 | break; | |
20 | self.vm.set_console() | 22 | case MII_ANAR: |
21 | kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + | 23 | s->advertise = (val & (MII_ANAR_RFAULT | MII_ANAR_PAUSE_ASYM | |
22 | - serial_kernel_cmdline[uart_id]) | 24 | - MII_ANAR_PAUSE | MII_ANAR_10FD | MII_ANAR_10 | |
23 | + serial_kernel_cmdline[uart_id] + | 25 | - MII_ANAR_SELECT)) |
24 | + ' root=/dev/mmcblk0p2 rootwait ' + | 26 | + MII_ANAR_PAUSE | MII_ANAR_TXFD | MII_ANAR_10FD | |
25 | + 'dwc_otg.fiq_fsm_enable=0') | 27 | + MII_ANAR_10 | MII_ANAR_SELECT)) |
26 | self.vm.add_args('-kernel', kernel_path, | 28 | | MII_ANAR_TX; |
27 | '-dtb', dtb_path, | 29 | break; |
28 | - '-append', kernel_command_line) | 30 | case 30: /* Interrupt mask */ |
29 | + '-append', kernel_command_line, | ||
30 | + '-device', 'usb-kbd') | ||
31 | self.vm.launch() | ||
32 | console_pattern = 'Kernel command line: %s' % kernel_command_line | ||
33 | self.wait_for_console_pattern(console_pattern) | ||
34 | + console_pattern = 'Product: QEMU USB Keyboard' | ||
35 | + self.wait_for_console_pattern(console_pattern) | ||
36 | |||
37 | def test_arm_raspi2_uart0(self): | ||
38 | """ | ||
39 | -- | 31 | -- |
40 | 2.20.1 | 32 | 2.34.1 |
41 | |||
42 | diff view generated by jsdifflib |
1 | Convert the VSHLL and VMOVL insns from the 2-reg-shift group | 1 | For IEEE fused multiply-add, the (0 * inf) + NaN case should raise |
---|---|---|---|
2 | to decodetree. Since the loop always has two passes, we unroll | 2 | Invalid for the multiplication of 0 by infinity. Currently we handle |
3 | it to avoid the awkward reassignment of one TCGv to another. | 3 | this in the per-architecture ifdef ladder in pickNaNMulAdd(). |
4 | However, since this isn't really architecture specific we can hoist | ||
5 | it up to the generic code. | ||
6 | |||
7 | For the cases where the infzero test in pickNaNMulAdd was | ||
8 | returning 2, we can delete the check entirely and allow the | ||
9 | code to fall into the normal pick-a-NaN handling, because this | ||
10 | will return 2 anyway (input 'c' being the only NaN in this case). | ||
11 | For the cases where infzero was returning 3 to indicate "return | ||
12 | the default NaN", we must retain that "return 3". | ||
13 | |||
14 | For Arm, this looks like it might be a behaviour change because we | ||
15 | used to set float_flag_invalid | float_flag_invalid_imz only if C is | ||
16 | a quiet NaN. However, it is not, because Arm target code never looks | ||
17 | at float_flag_invalid_imz, and for the (0 * inf) + SNaN case we | ||
18 | already raised float_flag_invalid via the "abc_mask & | ||
19 | float_cmask_snan" check in pick_nan_muladd. | ||
20 | |||
21 | For any target architecture using the "default implementation" at the | ||
22 | bottom of the ifdef, this is a behaviour change but will be fixing a | ||
23 | bug (where we failed to raise the Invalid exception for (0 * inf + | ||
24 | QNaN). The architectures using the default case are: | ||
25 | * hppa | ||
26 | * i386 | ||
27 | * sh4 | ||
28 | * tricore | ||
29 | |||
30 | The x86, Tricore and SH4 CPU architecture manuals are clear that this | ||
31 | should have raised Invalid; HPPA is a bit vaguer but still seems | ||
32 | clear enough. | ||
4 | 33 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 34 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 35 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20200522145520.6778-8-peter.maydell@linaro.org | 36 | Message-id: 20241202131347.498124-2-peter.maydell@linaro.org |
8 | --- | 37 | --- |
9 | target/arm/neon-dp.decode | 16 +++++++ | 38 | fpu/softfloat-parts.c.inc | 13 +++++++------ |
10 | target/arm/translate-neon.inc.c | 81 +++++++++++++++++++++++++++++++++ | 39 | fpu/softfloat-specialize.c.inc | 29 +---------------------------- |
11 | target/arm/translate.c | 46 +------------------ | 40 | 2 files changed, 8 insertions(+), 34 deletions(-) |
12 | 3 files changed, 99 insertions(+), 44 deletions(-) | ||
13 | 41 | ||
14 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 42 | diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc |
15 | index XXXXXXX..XXXXXXX 100644 | 43 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/neon-dp.decode | 44 | --- a/fpu/softfloat-parts.c.inc |
17 | +++ b/target/arm/neon-dp.decode | 45 | +++ b/fpu/softfloat-parts.c.inc |
18 | @@ -XXX,XX +XXX,XX @@ VMINNM_fp_3s 1111 001 1 0 . 1 . .... .... 1111 ... 1 .... @3same_fp | 46 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, |
19 | &2reg_shift vm=%vm_dp vd=%vd_dp size=1 q=0 \ | 47 | int ab_mask, int abc_mask) |
20 | shift=%neon_rshift_i3 | 48 | { |
21 | 49 | int which; | |
22 | +# Long left shifts: again Q is part of opcode decode | 50 | + bool infzero = (ab_mask == float_cmask_infzero); |
23 | +@2reg_shll_s .... ... . . . 1 shift:5 .... .... 0 . . . .... \ | 51 | |
24 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=2 q=0 | 52 | if (unlikely(abc_mask & float_cmask_snan)) { |
25 | +@2reg_shll_h .... ... . . . 01 shift:4 .... .... 0 . . . .... \ | 53 | float_raise(float_flag_invalid | float_flag_invalid_snan, s); |
26 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=1 q=0 | 54 | } |
27 | +@2reg_shll_b .... ... . . . 001 shift:3 .... .... 0 . . . .... \ | 55 | |
28 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=0 q=0 | 56 | - which = pickNaNMulAdd(a->cls, b->cls, c->cls, |
29 | + | 57 | - ab_mask == float_cmask_infzero, s); |
30 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_d | 58 | + if (infzero) { |
31 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_s | 59 | + /* This is (0 * inf) + NaN or (inf * 0) + NaN */ |
32 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_h | 60 | + float_raise(float_flag_invalid | float_flag_invalid_imz, s); |
33 | @@ -XXX,XX +XXX,XX @@ VQSHRN_U16_2sh 1111 001 1 1 . ...... .... 1001 . 0 . 1 .... @2reg_shrn_h | ||
34 | VQRSHRN_U64_2sh 1111 001 1 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_d | ||
35 | VQRSHRN_U32_2sh 1111 001 1 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_s | ||
36 | VQRSHRN_U16_2sh 1111 001 1 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_h | ||
37 | + | ||
38 | +VSHLL_S_2sh 1111 001 0 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_s | ||
39 | +VSHLL_S_2sh 1111 001 0 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_h | ||
40 | +VSHLL_S_2sh 1111 001 0 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_b | ||
41 | + | ||
42 | +VSHLL_U_2sh 1111 001 1 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_s | ||
43 | +VSHLL_U_2sh 1111 001 1 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_h | ||
44 | +VSHLL_U_2sh 1111 001 1 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_b | ||
45 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/arm/translate-neon.inc.c | ||
48 | +++ b/target/arm/translate-neon.inc.c | ||
49 | @@ -XXX,XX +XXX,XX @@ DO_2SN_32(VQSHRN_U16, gen_helper_neon_shl_u16, gen_helper_neon_narrow_sat_u8) | ||
50 | DO_2SN_64(VQRSHRN_U64, gen_helper_neon_rshl_u64, gen_helper_neon_narrow_sat_u32) | ||
51 | DO_2SN_32(VQRSHRN_U32, gen_helper_neon_rshl_u32, gen_helper_neon_narrow_sat_u16) | ||
52 | DO_2SN_32(VQRSHRN_U16, gen_helper_neon_rshl_u16, gen_helper_neon_narrow_sat_u8) | ||
53 | + | ||
54 | +static bool do_vshll_2sh(DisasContext *s, arg_2reg_shift *a, | ||
55 | + NeonGenWidenFn *widenfn, bool u) | ||
56 | +{ | ||
57 | + TCGv_i64 tmp; | ||
58 | + TCGv_i32 rm0, rm1; | ||
59 | + uint64_t widen_mask = 0; | ||
60 | + | ||
61 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
62 | + return false; | ||
63 | + } | 61 | + } |
64 | + | 62 | + |
65 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | 63 | + which = pickNaNMulAdd(a->cls, b->cls, c->cls, infzero, s); |
66 | + if (!dc_isar_feature(aa32_simd_r32, s) && | 64 | |
67 | + ((a->vd | a->vm) & 0x10)) { | 65 | if (s->default_nan_mode || which == 3) { |
68 | + return false; | 66 | - /* |
69 | + } | 67 | - * Note that this check is after pickNaNMulAdd so that function |
68 | - * has an opportunity to set the Invalid flag for infzero. | ||
69 | - */ | ||
70 | parts_default_nan(a, s); | ||
71 | return a; | ||
72 | } | ||
73 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
74 | index XXXXXXX..XXXXXXX 100644 | ||
75 | --- a/fpu/softfloat-specialize.c.inc | ||
76 | +++ b/fpu/softfloat-specialize.c.inc | ||
77 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
78 | * the default NaN | ||
79 | */ | ||
80 | if (infzero && is_qnan(c_cls)) { | ||
81 | - float_raise(float_flag_invalid | float_flag_invalid_imz, status); | ||
82 | return 3; | ||
83 | } | ||
84 | |||
85 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
86 | * case sets InvalidOp and returns the default NaN | ||
87 | */ | ||
88 | if (infzero) { | ||
89 | - float_raise(float_flag_invalid | float_flag_invalid_imz, status); | ||
90 | return 3; | ||
91 | } | ||
92 | /* Prefer sNaN over qNaN, in the a, b, c order. */ | ||
93 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
94 | * For MIPS systems that conform to IEEE754-2008, the (inf,zero,nan) | ||
95 | * case sets InvalidOp and returns the input value 'c' | ||
96 | */ | ||
97 | - if (infzero) { | ||
98 | - float_raise(float_flag_invalid | float_flag_invalid_imz, status); | ||
99 | - return 2; | ||
100 | - } | ||
101 | /* Prefer sNaN over qNaN, in the c, a, b order. */ | ||
102 | if (is_snan(c_cls)) { | ||
103 | return 2; | ||
104 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
105 | * For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan) | ||
106 | * case sets InvalidOp and returns the input value 'c' | ||
107 | */ | ||
108 | - if (infzero) { | ||
109 | - float_raise(float_flag_invalid | float_flag_invalid_imz, status); | ||
110 | - return 2; | ||
111 | - } | ||
70 | + | 112 | + |
71 | + if (a->vd & 1) { | 113 | /* Prefer sNaN over qNaN, in the c, a, b order. */ |
72 | + return false; | 114 | if (is_snan(c_cls)) { |
73 | + } | 115 | return 2; |
74 | + | 116 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, |
75 | + if (!vfp_access_check(s)) { | 117 | * to return an input NaN if we have one (ie c) rather than generating |
76 | + return true; | 118 | * a default NaN |
77 | + } | 119 | */ |
78 | + | 120 | - if (infzero) { |
79 | + /* | 121 | - float_raise(float_flag_invalid | float_flag_invalid_imz, status); |
80 | + * This is a widen-and-shift operation. The shift is always less | 122 | - return 2; |
81 | + * than the width of the source type, so after widening the input | 123 | - } |
82 | + * vector we can simply shift the whole 64-bit widened register, | 124 | |
83 | + * and then clear the potential overflow bits resulting from left | 125 | /* If fRA is a NaN return it; otherwise if fRB is a NaN return it; |
84 | + * bits of the narrow input appearing as right bits of the left | 126 | * otherwise return fRC. Note that muladd on PPC is (fRA * fRC) + frB |
85 | + * neighbour narrow input. Calculate a mask of bits to clear. | 127 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, |
86 | + */ | 128 | return 1; |
87 | + if ((a->shift != 0) && (a->size < 2 || u)) { | 129 | } |
88 | + int esize = 8 << a->size; | 130 | #elif defined(TARGET_RISCV) |
89 | + widen_mask = MAKE_64BIT_MASK(0, esize); | 131 | - /* For RISC-V, InvalidOp is set when multiplicands are Inf and zero */ |
90 | + widen_mask >>= esize - a->shift; | 132 | - if (infzero) { |
91 | + widen_mask = dup_const(a->size + 1, widen_mask); | 133 | - float_raise(float_flag_invalid | float_flag_invalid_imz, status); |
92 | + } | 134 | - } |
93 | + | 135 | return 3; /* default NaN */ |
94 | + rm0 = neon_load_reg(a->vm, 0); | 136 | #elif defined(TARGET_S390X) |
95 | + rm1 = neon_load_reg(a->vm, 1); | 137 | if (infzero) { |
96 | + tmp = tcg_temp_new_i64(); | 138 | - float_raise(float_flag_invalid | float_flag_invalid_imz, status); |
97 | + | 139 | return 3; |
98 | + widenfn(tmp, rm0); | 140 | } |
99 | + if (a->shift != 0) { | 141 | |
100 | + tcg_gen_shli_i64(tmp, tmp, a->shift); | 142 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, |
101 | + tcg_gen_andi_i64(tmp, tmp, ~widen_mask); | 143 | return 2; |
102 | + } | 144 | } |
103 | + neon_store_reg64(tmp, a->vd); | 145 | #elif defined(TARGET_SPARC) |
104 | + | 146 | - /* For (inf,0,nan) return c. */ |
105 | + widenfn(tmp, rm1); | 147 | - if (infzero) { |
106 | + if (a->shift != 0) { | 148 | - float_raise(float_flag_invalid | float_flag_invalid_imz, status); |
107 | + tcg_gen_shli_i64(tmp, tmp, a->shift); | 149 | - return 2; |
108 | + tcg_gen_andi_i64(tmp, tmp, ~widen_mask); | 150 | - } |
109 | + } | 151 | /* Prefer SNaN over QNaN, order C, B, A. */ |
110 | + neon_store_reg64(tmp, a->vd + 1); | 152 | if (is_snan(c_cls)) { |
111 | + tcg_temp_free_i64(tmp); | 153 | return 2; |
112 | + return true; | 154 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, |
113 | +} | 155 | * For Xtensa, the (inf,zero,nan) case sets InvalidOp and returns |
114 | + | 156 | * an input NaN if we have one (ie c). |
115 | +static bool trans_VSHLL_S_2sh(DisasContext *s, arg_2reg_shift *a) | 157 | */ |
116 | +{ | 158 | - if (infzero) { |
117 | + NeonGenWidenFn *widenfn[] = { | 159 | - float_raise(float_flag_invalid | float_flag_invalid_imz, status); |
118 | + gen_helper_neon_widen_s8, | 160 | - return 2; |
119 | + gen_helper_neon_widen_s16, | 161 | - } |
120 | + tcg_gen_ext_i32_i64, | 162 | if (status->use_first_nan) { |
121 | + }; | 163 | if (is_nan(a_cls)) { |
122 | + return do_vshll_2sh(s, a, widenfn[a->size], false); | 164 | return 0; |
123 | +} | ||
124 | + | ||
125 | +static bool trans_VSHLL_U_2sh(DisasContext *s, arg_2reg_shift *a) | ||
126 | +{ | ||
127 | + NeonGenWidenFn *widenfn[] = { | ||
128 | + gen_helper_neon_widen_u8, | ||
129 | + gen_helper_neon_widen_u16, | ||
130 | + tcg_gen_extu_i32_i64, | ||
131 | + }; | ||
132 | + return do_vshll_2sh(s, a, widenfn[a->size], true); | ||
133 | +} | ||
134 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
135 | index XXXXXXX..XXXXXXX 100644 | ||
136 | --- a/target/arm/translate.c | ||
137 | +++ b/target/arm/translate.c | ||
138 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
139 | case 7: /* VQSHL */ | ||
140 | case 8: /* VSHRN, VRSHRN, VQSHRUN, VQRSHRUN */ | ||
141 | case 9: /* VQSHRN, VQRSHRN */ | ||
142 | + case 10: /* VSHLL, including VMOVL */ | ||
143 | return 1; /* handled by decodetree */ | ||
144 | default: | ||
145 | break; | ||
146 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
147 | size--; | ||
148 | } | ||
149 | shift = (insn >> 16) & ((1 << (3 + size)) - 1); | ||
150 | - if (op == 10) { | ||
151 | - /* VSHLL, VMOVL */ | ||
152 | - if (q || (rd & 1)) { | ||
153 | - return 1; | ||
154 | - } | ||
155 | - tmp = neon_load_reg(rm, 0); | ||
156 | - tmp2 = neon_load_reg(rm, 1); | ||
157 | - for (pass = 0; pass < 2; pass++) { | ||
158 | - if (pass == 1) | ||
159 | - tmp = tmp2; | ||
160 | - | ||
161 | - gen_neon_widen(cpu_V0, tmp, size, u); | ||
162 | - | ||
163 | - if (shift != 0) { | ||
164 | - /* The shift is less than the width of the source | ||
165 | - type, so we can just shift the whole register. */ | ||
166 | - tcg_gen_shli_i64(cpu_V0, cpu_V0, shift); | ||
167 | - /* Widen the result of shift: we need to clear | ||
168 | - * the potential overflow bits resulting from | ||
169 | - * left bits of the narrow input appearing as | ||
170 | - * right bits of left the neighbour narrow | ||
171 | - * input. */ | ||
172 | - if (size < 2 || !u) { | ||
173 | - uint64_t imm64; | ||
174 | - if (size == 0) { | ||
175 | - imm = (0xffu >> (8 - shift)); | ||
176 | - imm |= imm << 16; | ||
177 | - } else if (size == 1) { | ||
178 | - imm = 0xffff >> (16 - shift); | ||
179 | - } else { | ||
180 | - /* size == 2 */ | ||
181 | - imm = 0xffffffff >> (32 - shift); | ||
182 | - } | ||
183 | - if (size < 2) { | ||
184 | - imm64 = imm | (((uint64_t)imm) << 32); | ||
185 | - } else { | ||
186 | - imm64 = imm; | ||
187 | - } | ||
188 | - tcg_gen_andi_i64(cpu_V0, cpu_V0, ~imm64); | ||
189 | - } | ||
190 | - } | ||
191 | - neon_store_reg64(cpu_V0, rd + pass); | ||
192 | - } | ||
193 | - } else if (op >= 14) { | ||
194 | + if (op >= 14) { | ||
195 | /* VCVT fixed-point. */ | ||
196 | TCGv_ptr fpst; | ||
197 | TCGv_i32 shiftv; | ||
198 | -- | 165 | -- |
199 | 2.20.1 | 166 | 2.34.1 |
200 | |||
201 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | If the target sets default_nan_mode then we're always going to return | ||
2 | the default NaN, and pickNaNMulAdd() no longer has any side effects. | ||
3 | For consistency with pickNaN(), check for default_nan_mode before | ||
4 | calling pickNaNMulAdd(). | ||
1 | 5 | ||
6 | When we convert pickNaNMulAdd() to allow runtime selection of the NaN | ||
7 | propagation rule, this means we won't have to make the targets which | ||
8 | use default_nan_mode also set a propagation rule. | ||
9 | |||
10 | Since RiscV always uses default_nan_mode, this allows us to remove | ||
11 | its ifdef case from pickNaNMulAdd(). | ||
12 | |||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Message-id: 20241202131347.498124-3-peter.maydell@linaro.org | ||
16 | --- | ||
17 | fpu/softfloat-parts.c.inc | 8 ++++++-- | ||
18 | fpu/softfloat-specialize.c.inc | 9 +++++++-- | ||
19 | 2 files changed, 13 insertions(+), 4 deletions(-) | ||
20 | |||
21 | diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/fpu/softfloat-parts.c.inc | ||
24 | +++ b/fpu/softfloat-parts.c.inc | ||
25 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, | ||
26 | float_raise(float_flag_invalid | float_flag_invalid_imz, s); | ||
27 | } | ||
28 | |||
29 | - which = pickNaNMulAdd(a->cls, b->cls, c->cls, infzero, s); | ||
30 | + if (s->default_nan_mode) { | ||
31 | + which = 3; | ||
32 | + } else { | ||
33 | + which = pickNaNMulAdd(a->cls, b->cls, c->cls, infzero, s); | ||
34 | + } | ||
35 | |||
36 | - if (s->default_nan_mode || which == 3) { | ||
37 | + if (which == 3) { | ||
38 | parts_default_nan(a, s); | ||
39 | return a; | ||
40 | } | ||
41 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/fpu/softfloat-specialize.c.inc | ||
44 | +++ b/fpu/softfloat-specialize.c.inc | ||
45 | @@ -XXX,XX +XXX,XX @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls, | ||
46 | static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
47 | bool infzero, float_status *status) | ||
48 | { | ||
49 | + /* | ||
50 | + * We guarantee not to require the target to tell us how to | ||
51 | + * pick a NaN if we're always returning the default NaN. | ||
52 | + * But if we're not in default-NaN mode then the target must | ||
53 | + * specify. | ||
54 | + */ | ||
55 | + assert(!status->default_nan_mode); | ||
56 | #if defined(TARGET_ARM) | ||
57 | /* For ARM, the (inf,zero,qnan) case sets InvalidOp and returns | ||
58 | * the default NaN | ||
59 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
60 | } else { | ||
61 | return 1; | ||
62 | } | ||
63 | -#elif defined(TARGET_RISCV) | ||
64 | - return 3; /* default NaN */ | ||
65 | #elif defined(TARGET_S390X) | ||
66 | if (infzero) { | ||
67 | return 3; | ||
68 | -- | ||
69 | 2.34.1 | diff view generated by jsdifflib |
1 | Convert the Neon narrowing shifts where op==8 to decodetree: | 1 | IEEE 758 does not define a fixed rule for what NaN to return in |
---|---|---|---|
2 | * VSHRN | 2 | the case of a fused multiply-add of inf * 0 + NaN. Different |
3 | * VRSHRN | 3 | architectures thus do different things: |
4 | * VQSHRUN | 4 | * some return the default NaN |
5 | * VQRSHRUN | 5 | * some return the input NaN |
6 | * Arm returns the default NaN if the input NaN is quiet, | ||
7 | and the input NaN if it is signalling | ||
8 | |||
9 | We want to make this logic be runtime selected rather than | ||
10 | hardcoded into the binary, because: | ||
11 | * this will let us have multiple targets in one QEMU binary | ||
12 | * the Arm FEAT_AFP architectural feature includes letting | ||
13 | the guest select a NaN propagation rule at runtime | ||
14 | |||
15 | In this commit we add an enum for the propagation rule, the field in | ||
16 | float_status, and the corresponding getters and setters. We change | ||
17 | pickNaNMulAdd to honour this, but because all targets still leave | ||
18 | this field at its default 0 value, the fallback logic will pick the | ||
19 | rule type with the old ifdef ladder. | ||
20 | |||
21 | Note that four architectures both use the muladd softfloat functions | ||
22 | and did not have a branch of the ifdef ladder to specify their | ||
23 | behaviour (and so were ending up with the "default" case, probably | ||
24 | wrongly): i386, HPPA, SH4 and Tricore. SH4 and Tricore both set | ||
25 | default_nan_mode, and so will never get into pickNaNMulAdd(). For | ||
26 | HPPA and i386 we retain the same behaviour as the old default-case, | ||
27 | which is to not ever return the default NaN. This might not be | ||
28 | correct but it is not a behaviour change. | ||
6 | 29 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 30 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 31 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20200522145520.6778-6-peter.maydell@linaro.org | 32 | Message-id: 20241202131347.498124-4-peter.maydell@linaro.org |
10 | --- | 33 | --- |
11 | target/arm/neon-dp.decode | 27 ++++++ | 34 | include/fpu/softfloat-helpers.h | 11 ++++ |
12 | target/arm/translate-neon.inc.c | 167 ++++++++++++++++++++++++++++++++ | 35 | include/fpu/softfloat-types.h | 23 +++++++++ |
13 | target/arm/translate.c | 1 + | 36 | fpu/softfloat-specialize.c.inc | 91 ++++++++++++++++++++++----------- |
14 | 3 files changed, 195 insertions(+) | 37 | 3 files changed, 95 insertions(+), 30 deletions(-) |
15 | 38 | ||
16 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 39 | diff --git a/include/fpu/softfloat-helpers.h b/include/fpu/softfloat-helpers.h |
17 | index XXXXXXX..XXXXXXX 100644 | 40 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/neon-dp.decode | 41 | --- a/include/fpu/softfloat-helpers.h |
19 | +++ b/target/arm/neon-dp.decode | 42 | +++ b/include/fpu/softfloat-helpers.h |
20 | @@ -XXX,XX +XXX,XX @@ VMINNM_fp_3s 1111 001 1 0 . 1 . .... .... 1111 ... 1 .... @3same_fp | 43 | @@ -XXX,XX +XXX,XX @@ static inline void set_float_2nan_prop_rule(Float2NaNPropRule rule, |
21 | @2reg_shl_b .... ... . . . 001 shift:3 .... .... 0 q:1 . . .... \ | 44 | status->float_2nan_prop_rule = rule; |
22 | &2reg_shift vm=%vm_dp vd=%vd_dp size=0 | 45 | } |
23 | 46 | ||
24 | +# Narrowing right shifts: here the Q bit is part of the opcode decode | 47 | +static inline void set_float_infzeronan_rule(FloatInfZeroNaNRule rule, |
25 | +@2reg_shrn_d .... ... . . . 1 ..... .... .... 0 . . . .... \ | 48 | + float_status *status) |
26 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=3 q=0 \ | 49 | +{ |
27 | + shift=%neon_rshift_i5 | 50 | + status->float_infzeronan_rule = rule; |
28 | +@2reg_shrn_s .... ... . . . 01 .... .... .... 0 . . . .... \ | 51 | +} |
29 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=2 q=0 \ | 52 | + |
30 | + shift=%neon_rshift_i4 | 53 | static inline void set_flush_to_zero(bool val, float_status *status) |
31 | +@2reg_shrn_h .... ... . . . 001 ... .... .... 0 . . . .... \ | 54 | { |
32 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=1 q=0 \ | 55 | status->flush_to_zero = val; |
33 | + shift=%neon_rshift_i3 | 56 | @@ -XXX,XX +XXX,XX @@ static inline Float2NaNPropRule get_float_2nan_prop_rule(float_status *status) |
34 | + | 57 | return status->float_2nan_prop_rule; |
35 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_d | 58 | } |
36 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_s | 59 | |
37 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_h | 60 | +static inline FloatInfZeroNaNRule get_float_infzeronan_rule(float_status *status) |
38 | @@ -XXX,XX +XXX,XX @@ VQSHL_U_64_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_d | 61 | +{ |
39 | VQSHL_U_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_s | 62 | + return status->float_infzeronan_rule; |
40 | VQSHL_U_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_h | 63 | +} |
41 | VQSHL_U_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_b | 64 | + |
42 | + | 65 | static inline bool get_flush_to_zero(float_status *status) |
43 | +VSHRN_64_2sh 1111 001 0 1 . ...... .... 1000 . 0 . 1 .... @2reg_shrn_d | 66 | { |
44 | +VSHRN_32_2sh 1111 001 0 1 . ...... .... 1000 . 0 . 1 .... @2reg_shrn_s | 67 | return status->flush_to_zero; |
45 | +VSHRN_16_2sh 1111 001 0 1 . ...... .... 1000 . 0 . 1 .... @2reg_shrn_h | 68 | diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h |
46 | + | ||
47 | +VRSHRN_64_2sh 1111 001 0 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_d | ||
48 | +VRSHRN_32_2sh 1111 001 0 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_s | ||
49 | +VRSHRN_16_2sh 1111 001 0 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_h | ||
50 | + | ||
51 | +VQSHRUN_64_2sh 1111 001 1 1 . ...... .... 1000 . 0 . 1 .... @2reg_shrn_d | ||
52 | +VQSHRUN_32_2sh 1111 001 1 1 . ...... .... 1000 . 0 . 1 .... @2reg_shrn_s | ||
53 | +VQSHRUN_16_2sh 1111 001 1 1 . ...... .... 1000 . 0 . 1 .... @2reg_shrn_h | ||
54 | + | ||
55 | +VQRSHRUN_64_2sh 1111 001 1 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_d | ||
56 | +VQRSHRUN_32_2sh 1111 001 1 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_s | ||
57 | +VQRSHRUN_16_2sh 1111 001 1 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_h | ||
58 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
59 | index XXXXXXX..XXXXXXX 100644 | 69 | index XXXXXXX..XXXXXXX 100644 |
60 | --- a/target/arm/translate-neon.inc.c | 70 | --- a/include/fpu/softfloat-types.h |
61 | +++ b/target/arm/translate-neon.inc.c | 71 | +++ b/include/fpu/softfloat-types.h |
62 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_env_32(DisasContext *s, arg_2reg_shift *a, | 72 | @@ -XXX,XX +XXX,XX @@ typedef enum __attribute__((__packed__)) { |
63 | DO_2SHIFT_ENV(VQSHLU, qshlu_s) | 73 | float_2nan_prop_x87, |
64 | DO_2SHIFT_ENV(VQSHL_U, qshl_u) | 74 | } Float2NaNPropRule; |
65 | DO_2SHIFT_ENV(VQSHL_S, qshl_s) | 75 | |
66 | + | 76 | +/* |
67 | +static bool do_2shift_narrow_64(DisasContext *s, arg_2reg_shift *a, | 77 | + * Rule for result of fused multiply-add 0 * Inf + NaN. |
68 | + NeonGenTwo64OpFn *shiftfn, | 78 | + * This must be a NaN, but implementations differ on whether this |
69 | + NeonGenNarrowEnvFn *narrowfn) | 79 | + * is the input NaN or the default NaN. |
70 | +{ | 80 | + * |
71 | + /* 2-reg-and-shift narrowing-shift operations, size == 3 case */ | 81 | + * You don't need to set this if default_nan_mode is enabled. |
72 | + TCGv_i64 constimm, rm1, rm2; | 82 | + * When not in default-NaN mode, it is an error for the target |
73 | + TCGv_i32 rd; | 83 | + * not to set the rule in float_status if it uses muladd, and we |
74 | + | 84 | + * will assert if we need to handle an input NaN and no rule was |
75 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | 85 | + * selected. |
76 | + return false; | 86 | + */ |
87 | +typedef enum __attribute__((__packed__)) { | ||
88 | + /* No propagation rule specified */ | ||
89 | + float_infzeronan_none = 0, | ||
90 | + /* Result is never the default NaN (so always the input NaN) */ | ||
91 | + float_infzeronan_dnan_never, | ||
92 | + /* Result is always the default NaN */ | ||
93 | + float_infzeronan_dnan_always, | ||
94 | + /* Result is the default NaN if the input NaN is quiet */ | ||
95 | + float_infzeronan_dnan_if_qnan, | ||
96 | +} FloatInfZeroNaNRule; | ||
97 | + | ||
98 | /* | ||
99 | * Floating Point Status. Individual architectures may maintain | ||
100 | * several versions of float_status for different functions. The | ||
101 | @@ -XXX,XX +XXX,XX @@ typedef struct float_status { | ||
102 | FloatRoundMode float_rounding_mode; | ||
103 | FloatX80RoundPrec floatx80_rounding_precision; | ||
104 | Float2NaNPropRule float_2nan_prop_rule; | ||
105 | + FloatInfZeroNaNRule float_infzeronan_rule; | ||
106 | bool tininess_before_rounding; | ||
107 | /* should denormalised results go to zero and set the inexact flag? */ | ||
108 | bool flush_to_zero; | ||
109 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
110 | index XXXXXXX..XXXXXXX 100644 | ||
111 | --- a/fpu/softfloat-specialize.c.inc | ||
112 | +++ b/fpu/softfloat-specialize.c.inc | ||
113 | @@ -XXX,XX +XXX,XX @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls, | ||
114 | static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
115 | bool infzero, float_status *status) | ||
116 | { | ||
117 | + FloatInfZeroNaNRule rule = status->float_infzeronan_rule; | ||
118 | + | ||
119 | /* | ||
120 | * We guarantee not to require the target to tell us how to | ||
121 | * pick a NaN if we're always returning the default NaN. | ||
122 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
123 | * specify. | ||
124 | */ | ||
125 | assert(!status->default_nan_mode); | ||
126 | + | ||
127 | + if (rule == float_infzeronan_none) { | ||
128 | + /* | ||
129 | + * Temporarily fall back to ifdef ladder | ||
130 | + */ | ||
131 | #if defined(TARGET_ARM) | ||
132 | - /* For ARM, the (inf,zero,qnan) case sets InvalidOp and returns | ||
133 | - * the default NaN | ||
134 | - */ | ||
135 | - if (infzero && is_qnan(c_cls)) { | ||
136 | - return 3; | ||
137 | + /* | ||
138 | + * For ARM, the (inf,zero,qnan) case returns the default NaN, | ||
139 | + * but (inf,zero,snan) returns the input NaN. | ||
140 | + */ | ||
141 | + rule = float_infzeronan_dnan_if_qnan; | ||
142 | +#elif defined(TARGET_MIPS) | ||
143 | + if (snan_bit_is_one(status)) { | ||
144 | + /* | ||
145 | + * For MIPS systems that conform to IEEE754-1985, the (inf,zero,nan) | ||
146 | + * case sets InvalidOp and returns the default NaN | ||
147 | + */ | ||
148 | + rule = float_infzeronan_dnan_always; | ||
149 | + } else { | ||
150 | + /* | ||
151 | + * For MIPS systems that conform to IEEE754-2008, the (inf,zero,nan) | ||
152 | + * case sets InvalidOp and returns the input value 'c' | ||
153 | + */ | ||
154 | + rule = float_infzeronan_dnan_never; | ||
155 | + } | ||
156 | +#elif defined(TARGET_PPC) || defined(TARGET_SPARC) || \ | ||
157 | + defined(TARGET_XTENSA) || defined(TARGET_HPPA) || \ | ||
158 | + defined(TARGET_I386) || defined(TARGET_LOONGARCH) | ||
159 | + /* | ||
160 | + * For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan) | ||
161 | + * case sets InvalidOp and returns the input value 'c' | ||
162 | + */ | ||
163 | + /* | ||
164 | + * For PPC, the (inf,zero,qnan) case sets InvalidOp, but we prefer | ||
165 | + * to return an input NaN if we have one (ie c) rather than generating | ||
166 | + * a default NaN | ||
167 | + */ | ||
168 | + rule = float_infzeronan_dnan_never; | ||
169 | +#elif defined(TARGET_S390X) | ||
170 | + rule = float_infzeronan_dnan_always; | ||
171 | +#endif | ||
172 | } | ||
173 | |||
174 | + if (infzero) { | ||
175 | + /* | ||
176 | + * Inf * 0 + NaN -- some implementations return the default NaN here, | ||
177 | + * and some return the input NaN. | ||
178 | + */ | ||
179 | + switch (rule) { | ||
180 | + case float_infzeronan_dnan_never: | ||
181 | + return 2; | ||
182 | + case float_infzeronan_dnan_always: | ||
183 | + return 3; | ||
184 | + case float_infzeronan_dnan_if_qnan: | ||
185 | + return is_qnan(c_cls) ? 3 : 2; | ||
186 | + default: | ||
187 | + g_assert_not_reached(); | ||
188 | + } | ||
77 | + } | 189 | + } |
78 | + | 190 | + |
79 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | 191 | +#if defined(TARGET_ARM) |
80 | + if (!dc_isar_feature(aa32_simd_r32, s) && | 192 | + |
81 | + ((a->vd | a->vm) & 0x10)) { | 193 | /* This looks different from the ARM ARM pseudocode, because the ARM ARM |
82 | + return false; | 194 | * puts the operands to a fused mac operation (a*b)+c in the order c,a,b. |
83 | + } | 195 | */ |
84 | + | 196 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, |
85 | + if (a->vm & 1) { | 197 | } |
86 | + return false; | 198 | #elif defined(TARGET_MIPS) |
87 | + } | 199 | if (snan_bit_is_one(status)) { |
88 | + | 200 | - /* |
89 | + if (!vfp_access_check(s)) { | 201 | - * For MIPS systems that conform to IEEE754-1985, the (inf,zero,nan) |
90 | + return true; | 202 | - * case sets InvalidOp and returns the default NaN |
91 | + } | 203 | - */ |
92 | + | 204 | - if (infzero) { |
93 | + /* | 205 | - return 3; |
94 | + * This is always a right shift, and the shiftfn is always a | 206 | - } |
95 | + * left-shift helper, which thus needs the negated shift count. | 207 | /* Prefer sNaN over qNaN, in the a, b, c order. */ |
96 | + */ | 208 | if (is_snan(a_cls)) { |
97 | + constimm = tcg_const_i64(-a->shift); | 209 | return 0; |
98 | + rm1 = tcg_temp_new_i64(); | 210 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, |
99 | + rm2 = tcg_temp_new_i64(); | 211 | return 2; |
100 | + | 212 | } |
101 | + /* Load both inputs first to avoid potential overwrite if rm == rd */ | 213 | } else { |
102 | + neon_load_reg64(rm1, a->vm); | 214 | - /* |
103 | + neon_load_reg64(rm2, a->vm + 1); | 215 | - * For MIPS systems that conform to IEEE754-2008, the (inf,zero,nan) |
104 | + | 216 | - * case sets InvalidOp and returns the input value 'c' |
105 | + shiftfn(rm1, rm1, constimm); | 217 | - */ |
106 | + rd = tcg_temp_new_i32(); | 218 | /* Prefer sNaN over qNaN, in the c, a, b order. */ |
107 | + narrowfn(rd, cpu_env, rm1); | 219 | if (is_snan(c_cls)) { |
108 | + neon_store_reg(a->vd, 0, rd); | 220 | return 2; |
109 | + | 221 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, |
110 | + shiftfn(rm2, rm2, constimm); | 222 | } |
111 | + rd = tcg_temp_new_i32(); | 223 | } |
112 | + narrowfn(rd, cpu_env, rm2); | 224 | #elif defined(TARGET_LOONGARCH64) |
113 | + neon_store_reg(a->vd, 1, rd); | 225 | - /* |
114 | + | 226 | - * For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan) |
115 | + tcg_temp_free_i64(rm1); | 227 | - * case sets InvalidOp and returns the input value 'c' |
116 | + tcg_temp_free_i64(rm2); | 228 | - */ |
117 | + tcg_temp_free_i64(constimm); | 229 | - |
118 | + | 230 | /* Prefer sNaN over qNaN, in the c, a, b order. */ |
119 | + return true; | 231 | if (is_snan(c_cls)) { |
120 | +} | 232 | return 2; |
121 | + | 233 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, |
122 | +static bool do_2shift_narrow_32(DisasContext *s, arg_2reg_shift *a, | 234 | return 1; |
123 | + NeonGenTwoOpFn *shiftfn, | 235 | } |
124 | + NeonGenNarrowEnvFn *narrowfn) | 236 | #elif defined(TARGET_PPC) |
125 | +{ | 237 | - /* For PPC, the (inf,zero,qnan) case sets InvalidOp, but we prefer |
126 | + /* 2-reg-and-shift narrowing-shift operations, size < 3 case */ | 238 | - * to return an input NaN if we have one (ie c) rather than generating |
127 | + TCGv_i32 constimm, rm1, rm2, rm3, rm4; | 239 | - * a default NaN |
128 | + TCGv_i64 rtmp; | 240 | - */ |
129 | + uint32_t imm; | 241 | - |
130 | + | 242 | /* If fRA is a NaN return it; otherwise if fRB is a NaN return it; |
131 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | 243 | * otherwise return fRC. Note that muladd on PPC is (fRA * fRC) + frB |
132 | + return false; | 244 | */ |
133 | + } | 245 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, |
134 | + | 246 | return 1; |
135 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | 247 | } |
136 | + if (!dc_isar_feature(aa32_simd_r32, s) && | 248 | #elif defined(TARGET_S390X) |
137 | + ((a->vd | a->vm) & 0x10)) { | 249 | - if (infzero) { |
138 | + return false; | 250 | - return 3; |
139 | + } | 251 | - } |
140 | + | 252 | - |
141 | + if (a->vm & 1) { | 253 | if (is_snan(a_cls)) { |
142 | + return false; | 254 | return 0; |
143 | + } | 255 | } else if (is_snan(b_cls)) { |
144 | + | ||
145 | + if (!vfp_access_check(s)) { | ||
146 | + return true; | ||
147 | + } | ||
148 | + | ||
149 | + /* | ||
150 | + * This is always a right shift, and the shiftfn is always a | ||
151 | + * left-shift helper, which thus needs the negated shift count | ||
152 | + * duplicated into each lane of the immediate value. | ||
153 | + */ | ||
154 | + if (a->size == 1) { | ||
155 | + imm = (uint16_t)(-a->shift); | ||
156 | + imm |= imm << 16; | ||
157 | + } else { | ||
158 | + /* size == 2 */ | ||
159 | + imm = -a->shift; | ||
160 | + } | ||
161 | + constimm = tcg_const_i32(imm); | ||
162 | + | ||
163 | + /* Load all inputs first to avoid potential overwrite */ | ||
164 | + rm1 = neon_load_reg(a->vm, 0); | ||
165 | + rm2 = neon_load_reg(a->vm, 1); | ||
166 | + rm3 = neon_load_reg(a->vm + 1, 0); | ||
167 | + rm4 = neon_load_reg(a->vm + 1, 1); | ||
168 | + rtmp = tcg_temp_new_i64(); | ||
169 | + | ||
170 | + shiftfn(rm1, rm1, constimm); | ||
171 | + shiftfn(rm2, rm2, constimm); | ||
172 | + | ||
173 | + tcg_gen_concat_i32_i64(rtmp, rm1, rm2); | ||
174 | + tcg_temp_free_i32(rm2); | ||
175 | + | ||
176 | + narrowfn(rm1, cpu_env, rtmp); | ||
177 | + neon_store_reg(a->vd, 0, rm1); | ||
178 | + | ||
179 | + shiftfn(rm3, rm3, constimm); | ||
180 | + shiftfn(rm4, rm4, constimm); | ||
181 | + tcg_temp_free_i32(constimm); | ||
182 | + | ||
183 | + tcg_gen_concat_i32_i64(rtmp, rm3, rm4); | ||
184 | + tcg_temp_free_i32(rm4); | ||
185 | + | ||
186 | + narrowfn(rm3, cpu_env, rtmp); | ||
187 | + tcg_temp_free_i64(rtmp); | ||
188 | + neon_store_reg(a->vd, 1, rm3); | ||
189 | + return true; | ||
190 | +} | ||
191 | + | ||
192 | +#define DO_2SN_64(INSN, FUNC, NARROWFUNC) \ | ||
193 | + static bool trans_##INSN##_2sh(DisasContext *s, arg_2reg_shift *a) \ | ||
194 | + { \ | ||
195 | + return do_2shift_narrow_64(s, a, FUNC, NARROWFUNC); \ | ||
196 | + } | ||
197 | +#define DO_2SN_32(INSN, FUNC, NARROWFUNC) \ | ||
198 | + static bool trans_##INSN##_2sh(DisasContext *s, arg_2reg_shift *a) \ | ||
199 | + { \ | ||
200 | + return do_2shift_narrow_32(s, a, FUNC, NARROWFUNC); \ | ||
201 | + } | ||
202 | + | ||
203 | +static void gen_neon_narrow_u32(TCGv_i32 dest, TCGv_ptr env, TCGv_i64 src) | ||
204 | +{ | ||
205 | + tcg_gen_extrl_i64_i32(dest, src); | ||
206 | +} | ||
207 | + | ||
208 | +static void gen_neon_narrow_u16(TCGv_i32 dest, TCGv_ptr env, TCGv_i64 src) | ||
209 | +{ | ||
210 | + gen_helper_neon_narrow_u16(dest, src); | ||
211 | +} | ||
212 | + | ||
213 | +static void gen_neon_narrow_u8(TCGv_i32 dest, TCGv_ptr env, TCGv_i64 src) | ||
214 | +{ | ||
215 | + gen_helper_neon_narrow_u8(dest, src); | ||
216 | +} | ||
217 | + | ||
218 | +DO_2SN_64(VSHRN_64, gen_ushl_i64, gen_neon_narrow_u32) | ||
219 | +DO_2SN_32(VSHRN_32, gen_ushl_i32, gen_neon_narrow_u16) | ||
220 | +DO_2SN_32(VSHRN_16, gen_helper_neon_shl_u16, gen_neon_narrow_u8) | ||
221 | + | ||
222 | +DO_2SN_64(VRSHRN_64, gen_helper_neon_rshl_u64, gen_neon_narrow_u32) | ||
223 | +DO_2SN_32(VRSHRN_32, gen_helper_neon_rshl_u32, gen_neon_narrow_u16) | ||
224 | +DO_2SN_32(VRSHRN_16, gen_helper_neon_rshl_u16, gen_neon_narrow_u8) | ||
225 | + | ||
226 | +DO_2SN_64(VQSHRUN_64, gen_sshl_i64, gen_helper_neon_unarrow_sat32) | ||
227 | +DO_2SN_32(VQSHRUN_32, gen_sshl_i32, gen_helper_neon_unarrow_sat16) | ||
228 | +DO_2SN_32(VQSHRUN_16, gen_helper_neon_shl_s16, gen_helper_neon_unarrow_sat8) | ||
229 | + | ||
230 | +DO_2SN_64(VQRSHRUN_64, gen_helper_neon_rshl_s64, gen_helper_neon_unarrow_sat32) | ||
231 | +DO_2SN_32(VQRSHRUN_32, gen_helper_neon_rshl_s32, gen_helper_neon_unarrow_sat16) | ||
232 | +DO_2SN_32(VQRSHRUN_16, gen_helper_neon_rshl_s16, gen_helper_neon_unarrow_sat8) | ||
233 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
234 | index XXXXXXX..XXXXXXX 100644 | ||
235 | --- a/target/arm/translate.c | ||
236 | +++ b/target/arm/translate.c | ||
237 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
238 | case 5: /* VSHL, VSLI */ | ||
239 | case 6: /* VQSHLU */ | ||
240 | case 7: /* VQSHL */ | ||
241 | + case 8: /* VSHRN, VRSHRN, VQSHRUN, VQRSHRUN */ | ||
242 | return 1; /* handled by decodetree */ | ||
243 | default: | ||
244 | break; | ||
245 | -- | 256 | -- |
246 | 2.20.1 | 257 | 2.34.1 |
247 | |||
248 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Explicitly set a rule in the softfloat tests for the inf-zero-nan | ||
2 | muladd special case. In meson.build we put -DTARGET_ARM in fpcflags, | ||
3 | and so we should select here the Arm rule of | ||
4 | float_infzeronan_dnan_if_qnan. | ||
1 | 5 | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Message-id: 20241202131347.498124-5-peter.maydell@linaro.org | ||
9 | --- | ||
10 | tests/fp/fp-bench.c | 5 +++++ | ||
11 | tests/fp/fp-test.c | 5 +++++ | ||
12 | 2 files changed, 10 insertions(+) | ||
13 | |||
14 | diff --git a/tests/fp/fp-bench.c b/tests/fp/fp-bench.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/tests/fp/fp-bench.c | ||
17 | +++ b/tests/fp/fp-bench.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void run_bench(void) | ||
19 | { | ||
20 | bench_func_t f; | ||
21 | |||
22 | + /* | ||
23 | + * These implementation-defined choices for various things IEEE | ||
24 | + * doesn't specify match those used by the Arm architecture. | ||
25 | + */ | ||
26 | set_float_2nan_prop_rule(float_2nan_prop_s_ab, &soft_status); | ||
27 | + set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, &soft_status); | ||
28 | |||
29 | f = bench_funcs[operation][precision]; | ||
30 | g_assert(f); | ||
31 | diff --git a/tests/fp/fp-test.c b/tests/fp/fp-test.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/tests/fp/fp-test.c | ||
34 | +++ b/tests/fp/fp-test.c | ||
35 | @@ -XXX,XX +XXX,XX @@ void run_test(void) | ||
36 | { | ||
37 | unsigned int i; | ||
38 | |||
39 | + /* | ||
40 | + * These implementation-defined choices for various things IEEE | ||
41 | + * doesn't specify match those used by the Arm architecture. | ||
42 | + */ | ||
43 | set_float_2nan_prop_rule(float_2nan_prop_s_ab, &qsf); | ||
44 | + set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, &qsf); | ||
45 | |||
46 | genCases_setLevel(test_level); | ||
47 | verCases_maxErrorCount = n_max_errors; | ||
48 | -- | ||
49 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the FloatInfZeroNaNRule explicitly for the Arm target, | ||
2 | so we can remove the ifdef from pickNaNMulAdd(). | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20241202131347.498124-6-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/cpu.c | 3 +++ | ||
9 | fpu/softfloat-specialize.c.inc | 8 +------- | ||
10 | 2 files changed, 4 insertions(+), 7 deletions(-) | ||
11 | |||
12 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/cpu.c | ||
15 | +++ b/target/arm/cpu.c | ||
16 | @@ -XXX,XX +XXX,XX @@ void arm_register_el_change_hook(ARMCPU *cpu, ARMELChangeHookFn *hook, | ||
17 | * * tininess-before-rounding | ||
18 | * * 2-input NaN propagation prefers SNaN over QNaN, and then | ||
19 | * operand A over operand B (see FPProcessNaNs() pseudocode) | ||
20 | + * * 0 * Inf + NaN returns the default NaN if the input NaN is quiet, | ||
21 | + * and the input NaN if it is signalling | ||
22 | */ | ||
23 | static void arm_set_default_fp_behaviours(float_status *s) | ||
24 | { | ||
25 | set_float_detect_tininess(float_tininess_before_rounding, s); | ||
26 | set_float_2nan_prop_rule(float_2nan_prop_s_ab, s); | ||
27 | + set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, s); | ||
28 | } | ||
29 | |||
30 | static void cp_reg_reset(gpointer key, gpointer value, gpointer opaque) | ||
31 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/fpu/softfloat-specialize.c.inc | ||
34 | +++ b/fpu/softfloat-specialize.c.inc | ||
35 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
36 | /* | ||
37 | * Temporarily fall back to ifdef ladder | ||
38 | */ | ||
39 | -#if defined(TARGET_ARM) | ||
40 | - /* | ||
41 | - * For ARM, the (inf,zero,qnan) case returns the default NaN, | ||
42 | - * but (inf,zero,snan) returns the input NaN. | ||
43 | - */ | ||
44 | - rule = float_infzeronan_dnan_if_qnan; | ||
45 | -#elif defined(TARGET_MIPS) | ||
46 | +#if defined(TARGET_MIPS) | ||
47 | if (snan_bit_is_one(status)) { | ||
48 | /* | ||
49 | * For MIPS systems that conform to IEEE754-1985, the (inf,zero,nan) | ||
50 | -- | ||
51 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the FloatInfZeroNaNRule explicitly for s390, so we | ||
2 | can remove the ifdef from pickNaNMulAdd(). | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20241202131347.498124-7-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/s390x/cpu.c | 2 ++ | ||
9 | fpu/softfloat-specialize.c.inc | 2 -- | ||
10 | 2 files changed, 2 insertions(+), 2 deletions(-) | ||
11 | |||
12 | diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/s390x/cpu.c | ||
15 | +++ b/target/s390x/cpu.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static void s390_cpu_reset_hold(Object *obj, ResetType type) | ||
17 | set_float_detect_tininess(float_tininess_before_rounding, | ||
18 | &env->fpu_status); | ||
19 | set_float_2nan_prop_rule(float_2nan_prop_s_ab, &env->fpu_status); | ||
20 | + set_float_infzeronan_rule(float_infzeronan_dnan_always, | ||
21 | + &env->fpu_status); | ||
22 | /* fall through */ | ||
23 | case RESET_TYPE_S390_CPU_NORMAL: | ||
24 | env->psw.mask &= ~PSW_MASK_RI; | ||
25 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/fpu/softfloat-specialize.c.inc | ||
28 | +++ b/fpu/softfloat-specialize.c.inc | ||
29 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
30 | * a default NaN | ||
31 | */ | ||
32 | rule = float_infzeronan_dnan_never; | ||
33 | -#elif defined(TARGET_S390X) | ||
34 | - rule = float_infzeronan_dnan_always; | ||
35 | #endif | ||
36 | } | ||
37 | |||
38 | -- | ||
39 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the FloatInfZeroNaNRule explicitly for the PPC target, | ||
2 | so we can remove the ifdef from pickNaNMulAdd(). | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20241202131347.498124-8-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/ppc/cpu_init.c | 7 +++++++ | ||
9 | fpu/softfloat-specialize.c.inc | 7 +------ | ||
10 | 2 files changed, 8 insertions(+), 6 deletions(-) | ||
11 | |||
12 | diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/ppc/cpu_init.c | ||
15 | +++ b/target/ppc/cpu_init.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static void ppc_cpu_reset_hold(Object *obj, ResetType type) | ||
17 | */ | ||
18 | set_float_2nan_prop_rule(float_2nan_prop_ab, &env->fp_status); | ||
19 | set_float_2nan_prop_rule(float_2nan_prop_ab, &env->vec_status); | ||
20 | + /* | ||
21 | + * For PPC, the (inf,zero,qnan) case sets InvalidOp, but we prefer | ||
22 | + * to return an input NaN if we have one (ie c) rather than generating | ||
23 | + * a default NaN | ||
24 | + */ | ||
25 | + set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status); | ||
26 | + set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->vec_status); | ||
27 | |||
28 | for (i = 0; i < ARRAY_SIZE(env->spr_cb); i++) { | ||
29 | ppc_spr_t *spr = &env->spr_cb[i]; | ||
30 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/fpu/softfloat-specialize.c.inc | ||
33 | +++ b/fpu/softfloat-specialize.c.inc | ||
34 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
35 | */ | ||
36 | rule = float_infzeronan_dnan_never; | ||
37 | } | ||
38 | -#elif defined(TARGET_PPC) || defined(TARGET_SPARC) || \ | ||
39 | +#elif defined(TARGET_SPARC) || \ | ||
40 | defined(TARGET_XTENSA) || defined(TARGET_HPPA) || \ | ||
41 | defined(TARGET_I386) || defined(TARGET_LOONGARCH) | ||
42 | /* | ||
43 | * For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan) | ||
44 | * case sets InvalidOp and returns the input value 'c' | ||
45 | */ | ||
46 | - /* | ||
47 | - * For PPC, the (inf,zero,qnan) case sets InvalidOp, but we prefer | ||
48 | - * to return an input NaN if we have one (ie c) rather than generating | ||
49 | - * a default NaN | ||
50 | - */ | ||
51 | rule = float_infzeronan_dnan_never; | ||
52 | #endif | ||
53 | } | ||
54 | -- | ||
55 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the FloatInfZeroNaNRule explicitly for the MIPS target, | ||
2 | so we can remove the ifdef from pickNaNMulAdd(). | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20241202131347.498124-9-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/mips/fpu_helper.h | 9 +++++++++ | ||
9 | target/mips/msa.c | 4 ++++ | ||
10 | fpu/softfloat-specialize.c.inc | 16 +--------------- | ||
11 | 3 files changed, 14 insertions(+), 15 deletions(-) | ||
12 | |||
13 | diff --git a/target/mips/fpu_helper.h b/target/mips/fpu_helper.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/mips/fpu_helper.h | ||
16 | +++ b/target/mips/fpu_helper.h | ||
17 | @@ -XXX,XX +XXX,XX @@ static inline void restore_flush_mode(CPUMIPSState *env) | ||
18 | static inline void restore_snan_bit_mode(CPUMIPSState *env) | ||
19 | { | ||
20 | bool nan2008 = env->active_fpu.fcr31 & (1 << FCR31_NAN2008); | ||
21 | + FloatInfZeroNaNRule izn_rule; | ||
22 | |||
23 | /* | ||
24 | * With nan2008, SNaNs are silenced in the usual way. | ||
25 | @@ -XXX,XX +XXX,XX @@ static inline void restore_snan_bit_mode(CPUMIPSState *env) | ||
26 | */ | ||
27 | set_snan_bit_is_one(!nan2008, &env->active_fpu.fp_status); | ||
28 | set_default_nan_mode(!nan2008, &env->active_fpu.fp_status); | ||
29 | + /* | ||
30 | + * For MIPS systems that conform to IEEE754-1985, the (inf,zero,nan) | ||
31 | + * case sets InvalidOp and returns the default NaN. | ||
32 | + * For MIPS systems that conform to IEEE754-2008, the (inf,zero,nan) | ||
33 | + * case sets InvalidOp and returns the input value 'c'. | ||
34 | + */ | ||
35 | + izn_rule = nan2008 ? float_infzeronan_dnan_never : float_infzeronan_dnan_always; | ||
36 | + set_float_infzeronan_rule(izn_rule, &env->active_fpu.fp_status); | ||
37 | } | ||
38 | |||
39 | static inline void restore_fp_status(CPUMIPSState *env) | ||
40 | diff --git a/target/mips/msa.c b/target/mips/msa.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/mips/msa.c | ||
43 | +++ b/target/mips/msa.c | ||
44 | @@ -XXX,XX +XXX,XX @@ void msa_reset(CPUMIPSState *env) | ||
45 | |||
46 | /* set proper signanling bit meaning ("1" means "quiet") */ | ||
47 | set_snan_bit_is_one(0, &env->active_tc.msa_fp_status); | ||
48 | + | ||
49 | + /* Inf * 0 + NaN returns the input NaN */ | ||
50 | + set_float_infzeronan_rule(float_infzeronan_dnan_never, | ||
51 | + &env->active_tc.msa_fp_status); | ||
52 | } | ||
53 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/fpu/softfloat-specialize.c.inc | ||
56 | +++ b/fpu/softfloat-specialize.c.inc | ||
57 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
58 | /* | ||
59 | * Temporarily fall back to ifdef ladder | ||
60 | */ | ||
61 | -#if defined(TARGET_MIPS) | ||
62 | - if (snan_bit_is_one(status)) { | ||
63 | - /* | ||
64 | - * For MIPS systems that conform to IEEE754-1985, the (inf,zero,nan) | ||
65 | - * case sets InvalidOp and returns the default NaN | ||
66 | - */ | ||
67 | - rule = float_infzeronan_dnan_always; | ||
68 | - } else { | ||
69 | - /* | ||
70 | - * For MIPS systems that conform to IEEE754-2008, the (inf,zero,nan) | ||
71 | - * case sets InvalidOp and returns the input value 'c' | ||
72 | - */ | ||
73 | - rule = float_infzeronan_dnan_never; | ||
74 | - } | ||
75 | -#elif defined(TARGET_SPARC) || \ | ||
76 | +#if defined(TARGET_SPARC) || \ | ||
77 | defined(TARGET_XTENSA) || defined(TARGET_HPPA) || \ | ||
78 | defined(TARGET_I386) || defined(TARGET_LOONGARCH) | ||
79 | /* | ||
80 | -- | ||
81 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the FloatInfZeroNaNRule explicitly for the SPARC target, | ||
2 | so we can remove the ifdef from pickNaNMulAdd(). | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20241202131347.498124-10-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/sparc/cpu.c | 2 ++ | ||
9 | fpu/softfloat-specialize.c.inc | 3 +-- | ||
10 | 2 files changed, 3 insertions(+), 2 deletions(-) | ||
11 | |||
12 | diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/sparc/cpu.c | ||
15 | +++ b/target/sparc/cpu.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static void sparc_cpu_realizefn(DeviceState *dev, Error **errp) | ||
17 | * the CPU state struct so it won't get zeroed on reset. | ||
18 | */ | ||
19 | set_float_2nan_prop_rule(float_2nan_prop_s_ba, &env->fp_status); | ||
20 | + /* For inf * 0 + NaN, return the input NaN */ | ||
21 | + set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status); | ||
22 | |||
23 | cpu_exec_realizefn(cs, &local_err); | ||
24 | if (local_err != NULL) { | ||
25 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/fpu/softfloat-specialize.c.inc | ||
28 | +++ b/fpu/softfloat-specialize.c.inc | ||
29 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
30 | /* | ||
31 | * Temporarily fall back to ifdef ladder | ||
32 | */ | ||
33 | -#if defined(TARGET_SPARC) || \ | ||
34 | - defined(TARGET_XTENSA) || defined(TARGET_HPPA) || \ | ||
35 | +#if defined(TARGET_XTENSA) || defined(TARGET_HPPA) || \ | ||
36 | defined(TARGET_I386) || defined(TARGET_LOONGARCH) | ||
37 | /* | ||
38 | * For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan) | ||
39 | -- | ||
40 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the FloatInfZeroNaNRule explicitly for the xtensa target, | ||
2 | so we can remove the ifdef from pickNaNMulAdd(). | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20241202131347.498124-11-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/xtensa/cpu.c | 2 ++ | ||
9 | fpu/softfloat-specialize.c.inc | 2 +- | ||
10 | 2 files changed, 3 insertions(+), 1 deletion(-) | ||
11 | |||
12 | diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/xtensa/cpu.c | ||
15 | +++ b/target/xtensa/cpu.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static void xtensa_cpu_reset_hold(Object *obj, ResetType type) | ||
17 | reset_mmu(env); | ||
18 | cs->halted = env->runstall; | ||
19 | #endif | ||
20 | + /* For inf * 0 + NaN, return the input NaN */ | ||
21 | + set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status); | ||
22 | set_no_signaling_nans(!dfpu, &env->fp_status); | ||
23 | xtensa_use_first_nan(env, !dfpu); | ||
24 | } | ||
25 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/fpu/softfloat-specialize.c.inc | ||
28 | +++ b/fpu/softfloat-specialize.c.inc | ||
29 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
30 | /* | ||
31 | * Temporarily fall back to ifdef ladder | ||
32 | */ | ||
33 | -#if defined(TARGET_XTENSA) || defined(TARGET_HPPA) || \ | ||
34 | +#if defined(TARGET_HPPA) || \ | ||
35 | defined(TARGET_I386) || defined(TARGET_LOONGARCH) | ||
36 | /* | ||
37 | * For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan) | ||
38 | -- | ||
39 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the FloatInfZeroNaNRule explicitly for the x86 target. | ||
1 | 2 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20241202131347.498124-12-peter.maydell@linaro.org | ||
6 | --- | ||
7 | target/i386/tcg/fpu_helper.c | 7 +++++++ | ||
8 | fpu/softfloat-specialize.c.inc | 2 +- | ||
9 | 2 files changed, 8 insertions(+), 1 deletion(-) | ||
10 | |||
11 | diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/i386/tcg/fpu_helper.c | ||
14 | +++ b/target/i386/tcg/fpu_helper.c | ||
15 | @@ -XXX,XX +XXX,XX @@ void cpu_init_fp_statuses(CPUX86State *env) | ||
16 | */ | ||
17 | set_float_2nan_prop_rule(float_2nan_prop_x87, &env->mmx_status); | ||
18 | set_float_2nan_prop_rule(float_2nan_prop_x87, &env->sse_status); | ||
19 | + /* | ||
20 | + * Only SSE has multiply-add instructions. In the SDM Section 14.5.2 | ||
21 | + * "Fused-Multiply-ADD (FMA) Numeric Behavior" the NaN handling is | ||
22 | + * specified -- for 0 * inf + NaN the input NaN is selected, and if | ||
23 | + * there are multiple input NaNs they are selected in the order a, b, c. | ||
24 | + */ | ||
25 | + set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->sse_status); | ||
26 | } | ||
27 | |||
28 | static inline uint8_t save_exception_flags(CPUX86State *env) | ||
29 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/fpu/softfloat-specialize.c.inc | ||
32 | +++ b/fpu/softfloat-specialize.c.inc | ||
33 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
34 | * Temporarily fall back to ifdef ladder | ||
35 | */ | ||
36 | #if defined(TARGET_HPPA) || \ | ||
37 | - defined(TARGET_I386) || defined(TARGET_LOONGARCH) | ||
38 | + defined(TARGET_LOONGARCH) | ||
39 | /* | ||
40 | * For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan) | ||
41 | * case sets InvalidOp and returns the input value 'c' | ||
42 | -- | ||
43 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the FloatInfZeroNaNRule explicitly for the loongarch target. | ||
1 | 2 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20241202131347.498124-13-peter.maydell@linaro.org | ||
6 | --- | ||
7 | target/loongarch/tcg/fpu_helper.c | 5 +++++ | ||
8 | fpu/softfloat-specialize.c.inc | 7 +------ | ||
9 | 2 files changed, 6 insertions(+), 6 deletions(-) | ||
10 | |||
11 | diff --git a/target/loongarch/tcg/fpu_helper.c b/target/loongarch/tcg/fpu_helper.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/loongarch/tcg/fpu_helper.c | ||
14 | +++ b/target/loongarch/tcg/fpu_helper.c | ||
15 | @@ -XXX,XX +XXX,XX @@ void restore_fp_status(CPULoongArchState *env) | ||
16 | &env->fp_status); | ||
17 | set_flush_to_zero(0, &env->fp_status); | ||
18 | set_float_2nan_prop_rule(float_2nan_prop_s_ab, &env->fp_status); | ||
19 | + /* | ||
20 | + * For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan) | ||
21 | + * case sets InvalidOp and returns the input value 'c' | ||
22 | + */ | ||
23 | + set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status); | ||
24 | } | ||
25 | |||
26 | int ieee_ex_to_loongarch(int xcpt) | ||
27 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/fpu/softfloat-specialize.c.inc | ||
30 | +++ b/fpu/softfloat-specialize.c.inc | ||
31 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
32 | /* | ||
33 | * Temporarily fall back to ifdef ladder | ||
34 | */ | ||
35 | -#if defined(TARGET_HPPA) || \ | ||
36 | - defined(TARGET_LOONGARCH) | ||
37 | - /* | ||
38 | - * For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan) | ||
39 | - * case sets InvalidOp and returns the input value 'c' | ||
40 | - */ | ||
41 | +#if defined(TARGET_HPPA) | ||
42 | rule = float_infzeronan_dnan_never; | ||
43 | #endif | ||
44 | } | ||
45 | -- | ||
46 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the FloatInfZeroNaNRule explicitly for the HPPA target, | ||
2 | so we can remove the ifdef from pickNaNMulAdd(). | ||
1 | 3 | ||
4 | As this is the last target to be converted to explicitly setting | ||
5 | the rule, we can remove the fallback code in pickNaNMulAdd() | ||
6 | entirely. | ||
7 | |||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20241202131347.498124-14-peter.maydell@linaro.org | ||
11 | --- | ||
12 | target/hppa/fpu_helper.c | 2 ++ | ||
13 | fpu/softfloat-specialize.c.inc | 13 +------------ | ||
14 | 2 files changed, 3 insertions(+), 12 deletions(-) | ||
15 | |||
16 | diff --git a/target/hppa/fpu_helper.c b/target/hppa/fpu_helper.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/hppa/fpu_helper.c | ||
19 | +++ b/target/hppa/fpu_helper.c | ||
20 | @@ -XXX,XX +XXX,XX @@ void HELPER(loaded_fr0)(CPUHPPAState *env) | ||
21 | * HPPA does note implement a CPU reset method at all... | ||
22 | */ | ||
23 | set_float_2nan_prop_rule(float_2nan_prop_s_ab, &env->fp_status); | ||
24 | + /* For inf * 0 + NaN, return the input NaN */ | ||
25 | + set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status); | ||
26 | } | ||
27 | |||
28 | void cpu_hppa_loaded_fr0(CPUHPPAState *env) | ||
29 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/fpu/softfloat-specialize.c.inc | ||
32 | +++ b/fpu/softfloat-specialize.c.inc | ||
33 | @@ -XXX,XX +XXX,XX @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls, | ||
34 | static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
35 | bool infzero, float_status *status) | ||
36 | { | ||
37 | - FloatInfZeroNaNRule rule = status->float_infzeronan_rule; | ||
38 | - | ||
39 | /* | ||
40 | * We guarantee not to require the target to tell us how to | ||
41 | * pick a NaN if we're always returning the default NaN. | ||
42 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
43 | */ | ||
44 | assert(!status->default_nan_mode); | ||
45 | |||
46 | - if (rule == float_infzeronan_none) { | ||
47 | - /* | ||
48 | - * Temporarily fall back to ifdef ladder | ||
49 | - */ | ||
50 | -#if defined(TARGET_HPPA) | ||
51 | - rule = float_infzeronan_dnan_never; | ||
52 | -#endif | ||
53 | - } | ||
54 | - | ||
55 | if (infzero) { | ||
56 | /* | ||
57 | * Inf * 0 + NaN -- some implementations return the default NaN here, | ||
58 | * and some return the input NaN. | ||
59 | */ | ||
60 | - switch (rule) { | ||
61 | + switch (status->float_infzeronan_rule) { | ||
62 | case float_infzeronan_dnan_never: | ||
63 | return 2; | ||
64 | case float_infzeronan_dnan_always: | ||
65 | -- | ||
66 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The new implementation of pickNaNMulAdd() will find it convenient | ||
2 | to know whether at least one of the three arguments to the muladd | ||
3 | was a signaling NaN. We already calculate that in the caller, | ||
4 | so pass it in as a new bool have_snan. | ||
1 | 5 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20241202131347.498124-15-peter.maydell@linaro.org | ||
9 | --- | ||
10 | fpu/softfloat-parts.c.inc | 5 +++-- | ||
11 | fpu/softfloat-specialize.c.inc | 2 +- | ||
12 | 2 files changed, 4 insertions(+), 3 deletions(-) | ||
13 | |||
14 | diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/fpu/softfloat-parts.c.inc | ||
17 | +++ b/fpu/softfloat-parts.c.inc | ||
18 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, | ||
19 | { | ||
20 | int which; | ||
21 | bool infzero = (ab_mask == float_cmask_infzero); | ||
22 | + bool have_snan = (abc_mask & float_cmask_snan); | ||
23 | |||
24 | - if (unlikely(abc_mask & float_cmask_snan)) { | ||
25 | + if (unlikely(have_snan)) { | ||
26 | float_raise(float_flag_invalid | float_flag_invalid_snan, s); | ||
27 | } | ||
28 | |||
29 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, | ||
30 | if (s->default_nan_mode) { | ||
31 | which = 3; | ||
32 | } else { | ||
33 | - which = pickNaNMulAdd(a->cls, b->cls, c->cls, infzero, s); | ||
34 | + which = pickNaNMulAdd(a->cls, b->cls, c->cls, infzero, have_snan, s); | ||
35 | } | ||
36 | |||
37 | if (which == 3) { | ||
38 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/fpu/softfloat-specialize.c.inc | ||
41 | +++ b/fpu/softfloat-specialize.c.inc | ||
42 | @@ -XXX,XX +XXX,XX @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls, | ||
43 | | Return values : 0 : a; 1 : b; 2 : c; 3 : default-NaN | ||
44 | *----------------------------------------------------------------------------*/ | ||
45 | static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
46 | - bool infzero, float_status *status) | ||
47 | + bool infzero, bool have_snan, float_status *status) | ||
48 | { | ||
49 | /* | ||
50 | * We guarantee not to require the target to tell us how to | ||
51 | -- | ||
52 | 2.34.1 | diff view generated by jsdifflib |
1 | Convert the VSHL and VSLI insns from the Neon 2-registers-and-a-shift | 1 | IEEE 758 does not define a fixed rule for which NaN to pick as the |
---|---|---|---|
2 | group to decodetree. | 2 | result if both operands of a 3-operand fused multiply-add operation |
3 | are NaNs. As a result different architectures have ended up with | ||
4 | different rules for propagating NaNs. | ||
5 | |||
6 | QEMU currently hardcodes the NaN propagation logic into the binary | ||
7 | because pickNaNMulAdd() has an ifdef ladder for different targets. | ||
8 | We want to make the propagation rule instead be selectable at | ||
9 | runtime, because: | ||
10 | * this will let us have multiple targets in one QEMU binary | ||
11 | * the Arm FEAT_AFP architectural feature includes letting | ||
12 | the guest select a NaN propagation rule at runtime | ||
13 | |||
14 | In this commit we add an enum for the propagation rule, the field in | ||
15 | float_status, and the corresponding getters and setters. We change | ||
16 | pickNaNMulAdd to honour this, but because all targets still leave | ||
17 | this field at its default 0 value, the fallback logic will pick the | ||
18 | rule type with the old ifdef ladder. | ||
19 | |||
20 | It's valid not to set a propagation rule if default_nan_mode is | ||
21 | enabled, because in that case there's no need to pick a NaN; all the | ||
22 | callers of pickNaNMulAdd() catch this case and skip calling it. | ||
3 | 23 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 25 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20200522145520.6778-2-peter.maydell@linaro.org | 26 | Message-id: 20241202131347.498124-16-peter.maydell@linaro.org |
7 | --- | 27 | --- |
8 | target/arm/neon-dp.decode | 25 ++++++++++++++++++++++ | 28 | include/fpu/softfloat-helpers.h | 11 +++ |
9 | target/arm/translate-neon.inc.c | 38 +++++++++++++++++++++++++++++++++ | 29 | include/fpu/softfloat-types.h | 55 +++++++++++ |
10 | target/arm/translate.c | 18 +++++++--------- | 30 | fpu/softfloat-specialize.c.inc | 167 ++++++++------------------------ |
11 | 3 files changed, 71 insertions(+), 10 deletions(-) | 31 | 3 files changed, 107 insertions(+), 126 deletions(-) |
12 | 32 | ||
13 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 33 | diff --git a/include/fpu/softfloat-helpers.h b/include/fpu/softfloat-helpers.h |
14 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/neon-dp.decode | 35 | --- a/include/fpu/softfloat-helpers.h |
16 | +++ b/target/arm/neon-dp.decode | 36 | +++ b/include/fpu/softfloat-helpers.h |
17 | @@ -XXX,XX +XXX,XX @@ VRECPS_fp_3s 1111 001 0 0 . 0 . .... .... 1111 ... 1 .... @3same_fp | 37 | @@ -XXX,XX +XXX,XX @@ static inline void set_float_2nan_prop_rule(Float2NaNPropRule rule, |
18 | VRSQRTS_fp_3s 1111 001 0 0 . 1 . .... .... 1111 ... 1 .... @3same_fp | 38 | status->float_2nan_prop_rule = rule; |
19 | VMAXNM_fp_3s 1111 001 1 0 . 0 . .... .... 1111 ... 1 .... @3same_fp | 39 | } |
20 | VMINNM_fp_3s 1111 001 1 0 . 1 . .... .... 1111 ... 1 .... @3same_fp | 40 | |
21 | + | 41 | +static inline void set_float_3nan_prop_rule(Float3NaNPropRule rule, |
22 | +###################################################################### | 42 | + float_status *status) |
23 | +# 2-reg-and-shift grouping: | 43 | +{ |
24 | +# 1111 001 U 1 D immH:3 immL:3 Vd:4 opc:4 L Q M 1 Vm:4 | 44 | + status->float_3nan_prop_rule = rule; |
25 | +###################################################################### | 45 | +} |
26 | +&2reg_shift vm vd q shift size | 46 | + |
27 | + | 47 | static inline void set_float_infzeronan_rule(FloatInfZeroNaNRule rule, |
28 | +@2reg_shl_d .... ... . . . shift:6 .... .... 1 q:1 . . .... \ | 48 | float_status *status) |
29 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=3 | 49 | { |
30 | +@2reg_shl_s .... ... . . . 1 shift:5 .... .... 0 q:1 . . .... \ | 50 | @@ -XXX,XX +XXX,XX @@ static inline Float2NaNPropRule get_float_2nan_prop_rule(float_status *status) |
31 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=2 | 51 | return status->float_2nan_prop_rule; |
32 | +@2reg_shl_h .... ... . . . 01 shift:4 .... .... 0 q:1 . . .... \ | 52 | } |
33 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=1 | 53 | |
34 | +@2reg_shl_b .... ... . . . 001 shift:3 .... .... 0 q:1 . . .... \ | 54 | +static inline Float3NaNPropRule get_float_3nan_prop_rule(float_status *status) |
35 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=0 | 55 | +{ |
36 | + | 56 | + return status->float_3nan_prop_rule; |
37 | +VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_d | 57 | +} |
38 | +VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_s | 58 | + |
39 | +VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_h | 59 | static inline FloatInfZeroNaNRule get_float_infzeronan_rule(float_status *status) |
40 | +VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_b | 60 | { |
41 | + | 61 | return status->float_infzeronan_rule; |
42 | +VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_d | 62 | diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h |
43 | +VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_s | ||
44 | +VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_h | ||
45 | +VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_b | ||
46 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | 63 | index XXXXXXX..XXXXXXX 100644 |
48 | --- a/target/arm/translate-neon.inc.c | 64 | --- a/include/fpu/softfloat-types.h |
49 | +++ b/target/arm/translate-neon.inc.c | 65 | +++ b/include/fpu/softfloat-types.h |
50 | @@ -XXX,XX +XXX,XX @@ static bool do_3same_fp_pair(DisasContext *s, arg_3same *a, VFPGen3OpSPFn *fn) | 66 | @@ -XXX,XX +XXX,XX @@ this code that are retained. |
51 | DO_3S_FP_PAIR(VPADD, gen_helper_vfp_adds) | 67 | #ifndef SOFTFLOAT_TYPES_H |
52 | DO_3S_FP_PAIR(VPMAX, gen_helper_vfp_maxs) | 68 | #define SOFTFLOAT_TYPES_H |
53 | DO_3S_FP_PAIR(VPMIN, gen_helper_vfp_mins) | 69 | |
54 | + | 70 | +#include "hw/registerfields.h" |
55 | +static bool do_vector_2sh(DisasContext *s, arg_2reg_shift *a, GVecGen2iFn *fn) | 71 | + |
56 | +{ | 72 | /* |
57 | + /* Handle a 2-reg-shift insn which can be vectorized. */ | 73 | * Software IEC/IEEE floating-point types. |
58 | + int vec_size = a->q ? 16 : 8; | 74 | */ |
59 | + int rd_ofs = neon_reg_offset(a->vd, 0); | 75 | @@ -XXX,XX +XXX,XX @@ typedef enum __attribute__((__packed__)) { |
60 | + int rm_ofs = neon_reg_offset(a->vm, 0); | 76 | float_2nan_prop_x87, |
61 | + | 77 | } Float2NaNPropRule; |
62 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | 78 | |
63 | + return false; | 79 | +/* |
80 | + * 3-input NaN propagation rule, for fused multiply-add. Individual | ||
81 | + * architectures have different rules for which input NaN is | ||
82 | + * propagated to the output when there is more than one NaN on the | ||
83 | + * input. | ||
84 | + * | ||
85 | + * If default_nan_mode is enabled then it is valid not to set a NaN | ||
86 | + * propagation rule, because the softfloat code guarantees not to try | ||
87 | + * to pick a NaN to propagate in default NaN mode. When not in | ||
88 | + * default-NaN mode, it is an error for the target not to set the rule | ||
89 | + * in float_status if it uses a muladd, and we will assert if we need | ||
90 | + * to handle an input NaN and no rule was selected. | ||
91 | + * | ||
92 | + * The naming scheme for Float3NaNPropRule values is: | ||
93 | + * float_3nan_prop_s_abc: | ||
94 | + * = "Prefer SNaN over QNaN, then operand A over B over C" | ||
95 | + * float_3nan_prop_abc: | ||
96 | + * = "Prefer A over B over C regardless of SNaN vs QNAN" | ||
97 | + * | ||
98 | + * For QEMU, the multiply-add operation is A * B + C. | ||
99 | + */ | ||
100 | + | ||
101 | +/* | ||
102 | + * We set the Float3NaNPropRule enum values up so we can select the | ||
103 | + * right value in pickNaNMulAdd in a data driven way. | ||
104 | + */ | ||
105 | +FIELD(3NAN, 1ST, 0, 2) /* which operand is most preferred ? */ | ||
106 | +FIELD(3NAN, 2ND, 2, 2) /* which operand is next most preferred ? */ | ||
107 | +FIELD(3NAN, 3RD, 4, 2) /* which operand is least preferred ? */ | ||
108 | +FIELD(3NAN, SNAN, 6, 1) /* do we prefer SNaN over QNaN ? */ | ||
109 | + | ||
110 | +#define PROPRULE(X, Y, Z) \ | ||
111 | + ((X << R_3NAN_1ST_SHIFT) | (Y << R_3NAN_2ND_SHIFT) | (Z << R_3NAN_3RD_SHIFT)) | ||
112 | + | ||
113 | +typedef enum __attribute__((__packed__)) { | ||
114 | + float_3nan_prop_none = 0, /* No propagation rule specified */ | ||
115 | + float_3nan_prop_abc = PROPRULE(0, 1, 2), | ||
116 | + float_3nan_prop_acb = PROPRULE(0, 2, 1), | ||
117 | + float_3nan_prop_bac = PROPRULE(1, 0, 2), | ||
118 | + float_3nan_prop_bca = PROPRULE(1, 2, 0), | ||
119 | + float_3nan_prop_cab = PROPRULE(2, 0, 1), | ||
120 | + float_3nan_prop_cba = PROPRULE(2, 1, 0), | ||
121 | + float_3nan_prop_s_abc = float_3nan_prop_abc | R_3NAN_SNAN_MASK, | ||
122 | + float_3nan_prop_s_acb = float_3nan_prop_acb | R_3NAN_SNAN_MASK, | ||
123 | + float_3nan_prop_s_bac = float_3nan_prop_bac | R_3NAN_SNAN_MASK, | ||
124 | + float_3nan_prop_s_bca = float_3nan_prop_bca | R_3NAN_SNAN_MASK, | ||
125 | + float_3nan_prop_s_cab = float_3nan_prop_cab | R_3NAN_SNAN_MASK, | ||
126 | + float_3nan_prop_s_cba = float_3nan_prop_cba | R_3NAN_SNAN_MASK, | ||
127 | +} Float3NaNPropRule; | ||
128 | + | ||
129 | +#undef PROPRULE | ||
130 | + | ||
131 | /* | ||
132 | * Rule for result of fused multiply-add 0 * Inf + NaN. | ||
133 | * This must be a NaN, but implementations differ on whether this | ||
134 | @@ -XXX,XX +XXX,XX @@ typedef struct float_status { | ||
135 | FloatRoundMode float_rounding_mode; | ||
136 | FloatX80RoundPrec floatx80_rounding_precision; | ||
137 | Float2NaNPropRule float_2nan_prop_rule; | ||
138 | + Float3NaNPropRule float_3nan_prop_rule; | ||
139 | FloatInfZeroNaNRule float_infzeronan_rule; | ||
140 | bool tininess_before_rounding; | ||
141 | /* should denormalised results go to zero and set the inexact flag? */ | ||
142 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
143 | index XXXXXXX..XXXXXXX 100644 | ||
144 | --- a/fpu/softfloat-specialize.c.inc | ||
145 | +++ b/fpu/softfloat-specialize.c.inc | ||
146 | @@ -XXX,XX +XXX,XX @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls, | ||
147 | static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
148 | bool infzero, bool have_snan, float_status *status) | ||
149 | { | ||
150 | + FloatClass cls[3] = { a_cls, b_cls, c_cls }; | ||
151 | + Float3NaNPropRule rule = status->float_3nan_prop_rule; | ||
152 | + int which; | ||
153 | + | ||
154 | /* | ||
155 | * We guarantee not to require the target to tell us how to | ||
156 | * pick a NaN if we're always returning the default NaN. | ||
157 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
158 | } | ||
159 | } | ||
160 | |||
161 | + if (rule == float_3nan_prop_none) { | ||
162 | #if defined(TARGET_ARM) | ||
163 | - | ||
164 | - /* This looks different from the ARM ARM pseudocode, because the ARM ARM | ||
165 | - * puts the operands to a fused mac operation (a*b)+c in the order c,a,b. | ||
166 | - */ | ||
167 | - if (is_snan(c_cls)) { | ||
168 | - return 2; | ||
169 | - } else if (is_snan(a_cls)) { | ||
170 | - return 0; | ||
171 | - } else if (is_snan(b_cls)) { | ||
172 | - return 1; | ||
173 | - } else if (is_qnan(c_cls)) { | ||
174 | - return 2; | ||
175 | - } else if (is_qnan(a_cls)) { | ||
176 | - return 0; | ||
177 | - } else { | ||
178 | - return 1; | ||
179 | - } | ||
180 | + /* | ||
181 | + * This looks different from the ARM ARM pseudocode, because the ARM ARM | ||
182 | + * puts the operands to a fused mac operation (a*b)+c in the order c,a,b | ||
183 | + */ | ||
184 | + rule = float_3nan_prop_s_cab; | ||
185 | #elif defined(TARGET_MIPS) | ||
186 | - if (snan_bit_is_one(status)) { | ||
187 | - /* Prefer sNaN over qNaN, in the a, b, c order. */ | ||
188 | - if (is_snan(a_cls)) { | ||
189 | - return 0; | ||
190 | - } else if (is_snan(b_cls)) { | ||
191 | - return 1; | ||
192 | - } else if (is_snan(c_cls)) { | ||
193 | - return 2; | ||
194 | - } else if (is_qnan(a_cls)) { | ||
195 | - return 0; | ||
196 | - } else if (is_qnan(b_cls)) { | ||
197 | - return 1; | ||
198 | + if (snan_bit_is_one(status)) { | ||
199 | + rule = float_3nan_prop_s_abc; | ||
200 | } else { | ||
201 | - return 2; | ||
202 | + rule = float_3nan_prop_s_cab; | ||
203 | } | ||
204 | - } else { | ||
205 | - /* Prefer sNaN over qNaN, in the c, a, b order. */ | ||
206 | - if (is_snan(c_cls)) { | ||
207 | - return 2; | ||
208 | - } else if (is_snan(a_cls)) { | ||
209 | - return 0; | ||
210 | - } else if (is_snan(b_cls)) { | ||
211 | - return 1; | ||
212 | - } else if (is_qnan(c_cls)) { | ||
213 | - return 2; | ||
214 | - } else if (is_qnan(a_cls)) { | ||
215 | - return 0; | ||
216 | - } else { | ||
217 | - return 1; | ||
218 | - } | ||
219 | - } | ||
220 | #elif defined(TARGET_LOONGARCH64) | ||
221 | - /* Prefer sNaN over qNaN, in the c, a, b order. */ | ||
222 | - if (is_snan(c_cls)) { | ||
223 | - return 2; | ||
224 | - } else if (is_snan(a_cls)) { | ||
225 | - return 0; | ||
226 | - } else if (is_snan(b_cls)) { | ||
227 | - return 1; | ||
228 | - } else if (is_qnan(c_cls)) { | ||
229 | - return 2; | ||
230 | - } else if (is_qnan(a_cls)) { | ||
231 | - return 0; | ||
232 | - } else { | ||
233 | - return 1; | ||
234 | - } | ||
235 | + rule = float_3nan_prop_s_cab; | ||
236 | #elif defined(TARGET_PPC) | ||
237 | - /* If fRA is a NaN return it; otherwise if fRB is a NaN return it; | ||
238 | - * otherwise return fRC. Note that muladd on PPC is (fRA * fRC) + frB | ||
239 | - */ | ||
240 | - if (is_nan(a_cls)) { | ||
241 | - return 0; | ||
242 | - } else if (is_nan(c_cls)) { | ||
243 | - return 2; | ||
244 | - } else { | ||
245 | - return 1; | ||
246 | - } | ||
247 | + /* | ||
248 | + * If fRA is a NaN return it; otherwise if fRB is a NaN return it; | ||
249 | + * otherwise return fRC. Note that muladd on PPC is (fRA * fRC) + frB | ||
250 | + */ | ||
251 | + rule = float_3nan_prop_acb; | ||
252 | #elif defined(TARGET_S390X) | ||
253 | - if (is_snan(a_cls)) { | ||
254 | - return 0; | ||
255 | - } else if (is_snan(b_cls)) { | ||
256 | - return 1; | ||
257 | - } else if (is_snan(c_cls)) { | ||
258 | - return 2; | ||
259 | - } else if (is_qnan(a_cls)) { | ||
260 | - return 0; | ||
261 | - } else if (is_qnan(b_cls)) { | ||
262 | - return 1; | ||
263 | - } else { | ||
264 | - return 2; | ||
265 | - } | ||
266 | + rule = float_3nan_prop_s_abc; | ||
267 | #elif defined(TARGET_SPARC) | ||
268 | - /* Prefer SNaN over QNaN, order C, B, A. */ | ||
269 | - if (is_snan(c_cls)) { | ||
270 | - return 2; | ||
271 | - } else if (is_snan(b_cls)) { | ||
272 | - return 1; | ||
273 | - } else if (is_snan(a_cls)) { | ||
274 | - return 0; | ||
275 | - } else if (is_qnan(c_cls)) { | ||
276 | - return 2; | ||
277 | - } else if (is_qnan(b_cls)) { | ||
278 | - return 1; | ||
279 | - } else { | ||
280 | - return 0; | ||
281 | - } | ||
282 | + rule = float_3nan_prop_s_cba; | ||
283 | #elif defined(TARGET_XTENSA) | ||
284 | - /* | ||
285 | - * For Xtensa, the (inf,zero,nan) case sets InvalidOp and returns | ||
286 | - * an input NaN if we have one (ie c). | ||
287 | - */ | ||
288 | - if (status->use_first_nan) { | ||
289 | - if (is_nan(a_cls)) { | ||
290 | - return 0; | ||
291 | - } else if (is_nan(b_cls)) { | ||
292 | - return 1; | ||
293 | + if (status->use_first_nan) { | ||
294 | + rule = float_3nan_prop_abc; | ||
295 | } else { | ||
296 | - return 2; | ||
297 | + rule = float_3nan_prop_cba; | ||
298 | } | ||
299 | - } else { | ||
300 | - if (is_nan(c_cls)) { | ||
301 | - return 2; | ||
302 | - } else if (is_nan(b_cls)) { | ||
303 | - return 1; | ||
304 | - } else { | ||
305 | - return 0; | ||
306 | - } | ||
307 | - } | ||
308 | #else | ||
309 | - /* A default implementation: prefer a to b to c. | ||
310 | - * This is unlikely to actually match any real implementation. | ||
311 | - */ | ||
312 | - if (is_nan(a_cls)) { | ||
313 | - return 0; | ||
314 | - } else if (is_nan(b_cls)) { | ||
315 | - return 1; | ||
316 | - } else { | ||
317 | - return 2; | ||
318 | - } | ||
319 | + rule = float_3nan_prop_abc; | ||
320 | #endif | ||
64 | + } | 321 | + } |
65 | + | 322 | + |
66 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | 323 | + assert(rule != float_3nan_prop_none); |
67 | + if (!dc_isar_feature(aa32_simd_r32, s) && | 324 | + if (have_snan && (rule & R_3NAN_SNAN_MASK)) { |
68 | + ((a->vd | a->vm) & 0x10)) { | 325 | + /* We have at least one SNaN input and should prefer it */ |
69 | + return false; | 326 | + do { |
327 | + which = rule & R_3NAN_1ST_MASK; | ||
328 | + rule >>= R_3NAN_1ST_LENGTH; | ||
329 | + } while (!is_snan(cls[which])); | ||
330 | + } else { | ||
331 | + do { | ||
332 | + which = rule & R_3NAN_1ST_MASK; | ||
333 | + rule >>= R_3NAN_1ST_LENGTH; | ||
334 | + } while (!is_nan(cls[which])); | ||
70 | + } | 335 | + } |
71 | + | 336 | + return which; |
72 | + if ((a->vm | a->vd) & a->q) { | 337 | } |
73 | + return false; | 338 | |
74 | + } | 339 | /*---------------------------------------------------------------------------- |
75 | + | ||
76 | + if (!vfp_access_check(s)) { | ||
77 | + return true; | ||
78 | + } | ||
79 | + | ||
80 | + fn(a->size, rd_ofs, rm_ofs, a->shift, vec_size, vec_size); | ||
81 | + return true; | ||
82 | +} | ||
83 | + | ||
84 | +#define DO_2SH(INSN, FUNC) \ | ||
85 | + static bool trans_##INSN##_2sh(DisasContext *s, arg_2reg_shift *a) \ | ||
86 | + { \ | ||
87 | + return do_vector_2sh(s, a, FUNC); \ | ||
88 | + } \ | ||
89 | + | ||
90 | +DO_2SH(VSHL, tcg_gen_gvec_shli) | ||
91 | +DO_2SH(VSLI, gen_gvec_sli) | ||
92 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
93 | index XXXXXXX..XXXXXXX 100644 | ||
94 | --- a/target/arm/translate.c | ||
95 | +++ b/target/arm/translate.c | ||
96 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
97 | if ((insn & 0x00380080) != 0) { | ||
98 | /* Two registers and shift. */ | ||
99 | op = (insn >> 8) & 0xf; | ||
100 | + | ||
101 | + switch (op) { | ||
102 | + case 5: /* VSHL, VSLI */ | ||
103 | + return 1; /* handled by decodetree */ | ||
104 | + default: | ||
105 | + break; | ||
106 | + } | ||
107 | + | ||
108 | if (insn & (1 << 7)) { | ||
109 | /* 64-bit shift. */ | ||
110 | if (op > 7) { | ||
111 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
112 | gen_gvec_sri(size, rd_ofs, rm_ofs, shift, | ||
113 | vec_size, vec_size); | ||
114 | return 0; | ||
115 | - | ||
116 | - case 5: /* VSHL, VSLI */ | ||
117 | - if (u) { /* VSLI */ | ||
118 | - gen_gvec_sli(size, rd_ofs, rm_ofs, shift, | ||
119 | - vec_size, vec_size); | ||
120 | - } else { /* VSHL */ | ||
121 | - tcg_gen_gvec_shli(size, rd_ofs, rm_ofs, shift, | ||
122 | - vec_size, vec_size); | ||
123 | - } | ||
124 | - return 0; | ||
125 | } | ||
126 | |||
127 | if (size == 3) { | ||
128 | -- | 340 | -- |
129 | 2.20.1 | 341 | 2.34.1 |
130 | |||
131 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Explicitly set a rule in the softfloat tests for propagating NaNs in | ||
2 | the muladd case. In meson.build we put -DTARGET_ARM in fpcflags, and | ||
3 | so we should select here the Arm rule of float_3nan_prop_s_cab. | ||
1 | 4 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20241202131347.498124-17-peter.maydell@linaro.org | ||
8 | --- | ||
9 | tests/fp/fp-bench.c | 1 + | ||
10 | tests/fp/fp-test.c | 1 + | ||
11 | 2 files changed, 2 insertions(+) | ||
12 | |||
13 | diff --git a/tests/fp/fp-bench.c b/tests/fp/fp-bench.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/tests/fp/fp-bench.c | ||
16 | +++ b/tests/fp/fp-bench.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static void run_bench(void) | ||
18 | * doesn't specify match those used by the Arm architecture. | ||
19 | */ | ||
20 | set_float_2nan_prop_rule(float_2nan_prop_s_ab, &soft_status); | ||
21 | + set_float_3nan_prop_rule(float_3nan_prop_s_cab, &soft_status); | ||
22 | set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, &soft_status); | ||
23 | |||
24 | f = bench_funcs[operation][precision]; | ||
25 | diff --git a/tests/fp/fp-test.c b/tests/fp/fp-test.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/tests/fp/fp-test.c | ||
28 | +++ b/tests/fp/fp-test.c | ||
29 | @@ -XXX,XX +XXX,XX @@ void run_test(void) | ||
30 | * doesn't specify match those used by the Arm architecture. | ||
31 | */ | ||
32 | set_float_2nan_prop_rule(float_2nan_prop_s_ab, &qsf); | ||
33 | + set_float_3nan_prop_rule(float_3nan_prop_s_cab, &qsf); | ||
34 | set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, &qsf); | ||
35 | |||
36 | genCases_setLevel(test_level); | ||
37 | -- | ||
38 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the Float3NaNPropRule explicitly for Arm, and remove the | ||
2 | ifdef from pickNaNMulAdd(). | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20241202131347.498124-18-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/cpu.c | 5 +++++ | ||
9 | fpu/softfloat-specialize.c.inc | 8 +------- | ||
10 | 2 files changed, 6 insertions(+), 7 deletions(-) | ||
11 | |||
12 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/cpu.c | ||
15 | +++ b/target/arm/cpu.c | ||
16 | @@ -XXX,XX +XXX,XX @@ void arm_register_el_change_hook(ARMCPU *cpu, ARMELChangeHookFn *hook, | ||
17 | * * tininess-before-rounding | ||
18 | * * 2-input NaN propagation prefers SNaN over QNaN, and then | ||
19 | * operand A over operand B (see FPProcessNaNs() pseudocode) | ||
20 | + * * 3-input NaN propagation prefers SNaN over QNaN, and then | ||
21 | + * operand C over A over B (see FPProcessNaNs3() pseudocode, | ||
22 | + * but note that for QEMU muladd is a * b + c, whereas for | ||
23 | + * the pseudocode function the arguments are in the order c, a, b. | ||
24 | * * 0 * Inf + NaN returns the default NaN if the input NaN is quiet, | ||
25 | * and the input NaN if it is signalling | ||
26 | */ | ||
27 | @@ -XXX,XX +XXX,XX @@ static void arm_set_default_fp_behaviours(float_status *s) | ||
28 | { | ||
29 | set_float_detect_tininess(float_tininess_before_rounding, s); | ||
30 | set_float_2nan_prop_rule(float_2nan_prop_s_ab, s); | ||
31 | + set_float_3nan_prop_rule(float_3nan_prop_s_cab, s); | ||
32 | set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, s); | ||
33 | } | ||
34 | |||
35 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/fpu/softfloat-specialize.c.inc | ||
38 | +++ b/fpu/softfloat-specialize.c.inc | ||
39 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
40 | } | ||
41 | |||
42 | if (rule == float_3nan_prop_none) { | ||
43 | -#if defined(TARGET_ARM) | ||
44 | - /* | ||
45 | - * This looks different from the ARM ARM pseudocode, because the ARM ARM | ||
46 | - * puts the operands to a fused mac operation (a*b)+c in the order c,a,b | ||
47 | - */ | ||
48 | - rule = float_3nan_prop_s_cab; | ||
49 | -#elif defined(TARGET_MIPS) | ||
50 | +#if defined(TARGET_MIPS) | ||
51 | if (snan_bit_is_one(status)) { | ||
52 | rule = float_3nan_prop_s_abc; | ||
53 | } else { | ||
54 | -- | ||
55 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the Float3NaNPropRule explicitly for loongarch, and remove the | ||
2 | ifdef from pickNaNMulAdd(). | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20241202131347.498124-19-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/loongarch/tcg/fpu_helper.c | 1 + | ||
9 | fpu/softfloat-specialize.c.inc | 2 -- | ||
10 | 2 files changed, 1 insertion(+), 2 deletions(-) | ||
11 | |||
12 | diff --git a/target/loongarch/tcg/fpu_helper.c b/target/loongarch/tcg/fpu_helper.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/loongarch/tcg/fpu_helper.c | ||
15 | +++ b/target/loongarch/tcg/fpu_helper.c | ||
16 | @@ -XXX,XX +XXX,XX @@ void restore_fp_status(CPULoongArchState *env) | ||
17 | * case sets InvalidOp and returns the input value 'c' | ||
18 | */ | ||
19 | set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status); | ||
20 | + set_float_3nan_prop_rule(float_3nan_prop_s_cab, &env->fp_status); | ||
21 | } | ||
22 | |||
23 | int ieee_ex_to_loongarch(int xcpt) | ||
24 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/fpu/softfloat-specialize.c.inc | ||
27 | +++ b/fpu/softfloat-specialize.c.inc | ||
28 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
29 | } else { | ||
30 | rule = float_3nan_prop_s_cab; | ||
31 | } | ||
32 | -#elif defined(TARGET_LOONGARCH64) | ||
33 | - rule = float_3nan_prop_s_cab; | ||
34 | #elif defined(TARGET_PPC) | ||
35 | /* | ||
36 | * If fRA is a NaN return it; otherwise if fRB is a NaN return it; | ||
37 | -- | ||
38 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the Float3NaNPropRule explicitly for PPC, and remove the | ||
2 | ifdef from pickNaNMulAdd(). | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20241202131347.498124-20-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/ppc/cpu_init.c | 8 ++++++++ | ||
9 | fpu/softfloat-specialize.c.inc | 6 ------ | ||
10 | 2 files changed, 8 insertions(+), 6 deletions(-) | ||
11 | |||
12 | diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/ppc/cpu_init.c | ||
15 | +++ b/target/ppc/cpu_init.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static void ppc_cpu_reset_hold(Object *obj, ResetType type) | ||
17 | */ | ||
18 | set_float_2nan_prop_rule(float_2nan_prop_ab, &env->fp_status); | ||
19 | set_float_2nan_prop_rule(float_2nan_prop_ab, &env->vec_status); | ||
20 | + /* | ||
21 | + * NaN propagation for fused multiply-add: | ||
22 | + * if fRA is a NaN return it; otherwise if fRB is a NaN return it; | ||
23 | + * otherwise return fRC. Note that muladd on PPC is (fRA * fRC) + frB | ||
24 | + * whereas QEMU labels the operands as (a * b) + c. | ||
25 | + */ | ||
26 | + set_float_3nan_prop_rule(float_3nan_prop_acb, &env->fp_status); | ||
27 | + set_float_3nan_prop_rule(float_3nan_prop_acb, &env->vec_status); | ||
28 | /* | ||
29 | * For PPC, the (inf,zero,qnan) case sets InvalidOp, but we prefer | ||
30 | * to return an input NaN if we have one (ie c) rather than generating | ||
31 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/fpu/softfloat-specialize.c.inc | ||
34 | +++ b/fpu/softfloat-specialize.c.inc | ||
35 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
36 | } else { | ||
37 | rule = float_3nan_prop_s_cab; | ||
38 | } | ||
39 | -#elif defined(TARGET_PPC) | ||
40 | - /* | ||
41 | - * If fRA is a NaN return it; otherwise if fRB is a NaN return it; | ||
42 | - * otherwise return fRC. Note that muladd on PPC is (fRA * fRC) + frB | ||
43 | - */ | ||
44 | - rule = float_3nan_prop_acb; | ||
45 | #elif defined(TARGET_S390X) | ||
46 | rule = float_3nan_prop_s_abc; | ||
47 | #elif defined(TARGET_SPARC) | ||
48 | -- | ||
49 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the Float3NaNPropRule explicitly for s390x, and remove the | ||
2 | ifdef from pickNaNMulAdd(). | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20241202131347.498124-21-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/s390x/cpu.c | 1 + | ||
9 | fpu/softfloat-specialize.c.inc | 2 -- | ||
10 | 2 files changed, 1 insertion(+), 2 deletions(-) | ||
11 | |||
12 | diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/s390x/cpu.c | ||
15 | +++ b/target/s390x/cpu.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static void s390_cpu_reset_hold(Object *obj, ResetType type) | ||
17 | set_float_detect_tininess(float_tininess_before_rounding, | ||
18 | &env->fpu_status); | ||
19 | set_float_2nan_prop_rule(float_2nan_prop_s_ab, &env->fpu_status); | ||
20 | + set_float_3nan_prop_rule(float_3nan_prop_s_abc, &env->fpu_status); | ||
21 | set_float_infzeronan_rule(float_infzeronan_dnan_always, | ||
22 | &env->fpu_status); | ||
23 | /* fall through */ | ||
24 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/fpu/softfloat-specialize.c.inc | ||
27 | +++ b/fpu/softfloat-specialize.c.inc | ||
28 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
29 | } else { | ||
30 | rule = float_3nan_prop_s_cab; | ||
31 | } | ||
32 | -#elif defined(TARGET_S390X) | ||
33 | - rule = float_3nan_prop_s_abc; | ||
34 | #elif defined(TARGET_SPARC) | ||
35 | rule = float_3nan_prop_s_cba; | ||
36 | #elif defined(TARGET_XTENSA) | ||
37 | -- | ||
38 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the Float3NaNPropRule explicitly for SPARC, and remove the | ||
2 | ifdef from pickNaNMulAdd(). | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20241202131347.498124-22-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/sparc/cpu.c | 2 ++ | ||
9 | fpu/softfloat-specialize.c.inc | 2 -- | ||
10 | 2 files changed, 2 insertions(+), 2 deletions(-) | ||
11 | |||
12 | diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/sparc/cpu.c | ||
15 | +++ b/target/sparc/cpu.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static void sparc_cpu_realizefn(DeviceState *dev, Error **errp) | ||
17 | * the CPU state struct so it won't get zeroed on reset. | ||
18 | */ | ||
19 | set_float_2nan_prop_rule(float_2nan_prop_s_ba, &env->fp_status); | ||
20 | + /* For fused-multiply add, prefer SNaN over QNaN, then C->B->A */ | ||
21 | + set_float_3nan_prop_rule(float_3nan_prop_s_cba, &env->fp_status); | ||
22 | /* For inf * 0 + NaN, return the input NaN */ | ||
23 | set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status); | ||
24 | |||
25 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/fpu/softfloat-specialize.c.inc | ||
28 | +++ b/fpu/softfloat-specialize.c.inc | ||
29 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
30 | } else { | ||
31 | rule = float_3nan_prop_s_cab; | ||
32 | } | ||
33 | -#elif defined(TARGET_SPARC) | ||
34 | - rule = float_3nan_prop_s_cba; | ||
35 | #elif defined(TARGET_XTENSA) | ||
36 | if (status->use_first_nan) { | ||
37 | rule = float_3nan_prop_abc; | ||
38 | -- | ||
39 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the Float3NaNPropRule explicitly for Arm, and remove the | ||
2 | ifdef from pickNaNMulAdd(). | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20241202131347.498124-23-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/mips/fpu_helper.h | 4 ++++ | ||
9 | target/mips/msa.c | 3 +++ | ||
10 | fpu/softfloat-specialize.c.inc | 8 +------- | ||
11 | 3 files changed, 8 insertions(+), 7 deletions(-) | ||
12 | |||
13 | diff --git a/target/mips/fpu_helper.h b/target/mips/fpu_helper.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/mips/fpu_helper.h | ||
16 | +++ b/target/mips/fpu_helper.h | ||
17 | @@ -XXX,XX +XXX,XX @@ static inline void restore_snan_bit_mode(CPUMIPSState *env) | ||
18 | { | ||
19 | bool nan2008 = env->active_fpu.fcr31 & (1 << FCR31_NAN2008); | ||
20 | FloatInfZeroNaNRule izn_rule; | ||
21 | + Float3NaNPropRule nan3_rule; | ||
22 | |||
23 | /* | ||
24 | * With nan2008, SNaNs are silenced in the usual way. | ||
25 | @@ -XXX,XX +XXX,XX @@ static inline void restore_snan_bit_mode(CPUMIPSState *env) | ||
26 | */ | ||
27 | izn_rule = nan2008 ? float_infzeronan_dnan_never : float_infzeronan_dnan_always; | ||
28 | set_float_infzeronan_rule(izn_rule, &env->active_fpu.fp_status); | ||
29 | + nan3_rule = nan2008 ? float_3nan_prop_s_cab : float_3nan_prop_s_abc; | ||
30 | + set_float_3nan_prop_rule(nan3_rule, &env->active_fpu.fp_status); | ||
31 | + | ||
32 | } | ||
33 | |||
34 | static inline void restore_fp_status(CPUMIPSState *env) | ||
35 | diff --git a/target/mips/msa.c b/target/mips/msa.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/target/mips/msa.c | ||
38 | +++ b/target/mips/msa.c | ||
39 | @@ -XXX,XX +XXX,XX @@ void msa_reset(CPUMIPSState *env) | ||
40 | set_float_2nan_prop_rule(float_2nan_prop_s_ab, | ||
41 | &env->active_tc.msa_fp_status); | ||
42 | |||
43 | + set_float_3nan_prop_rule(float_3nan_prop_s_cab, | ||
44 | + &env->active_tc.msa_fp_status); | ||
45 | + | ||
46 | /* clear float_status exception flags */ | ||
47 | set_float_exception_flags(0, &env->active_tc.msa_fp_status); | ||
48 | |||
49 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/fpu/softfloat-specialize.c.inc | ||
52 | +++ b/fpu/softfloat-specialize.c.inc | ||
53 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
54 | } | ||
55 | |||
56 | if (rule == float_3nan_prop_none) { | ||
57 | -#if defined(TARGET_MIPS) | ||
58 | - if (snan_bit_is_one(status)) { | ||
59 | - rule = float_3nan_prop_s_abc; | ||
60 | - } else { | ||
61 | - rule = float_3nan_prop_s_cab; | ||
62 | - } | ||
63 | -#elif defined(TARGET_XTENSA) | ||
64 | +#if defined(TARGET_XTENSA) | ||
65 | if (status->use_first_nan) { | ||
66 | rule = float_3nan_prop_abc; | ||
67 | } else { | ||
68 | -- | ||
69 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the Float3NaNPropRule explicitly for xtensa, and remove the | ||
2 | ifdef from pickNaNMulAdd(). | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20241202131347.498124-24-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/xtensa/fpu_helper.c | 2 ++ | ||
9 | fpu/softfloat-specialize.c.inc | 8 -------- | ||
10 | 2 files changed, 2 insertions(+), 8 deletions(-) | ||
11 | |||
12 | diff --git a/target/xtensa/fpu_helper.c b/target/xtensa/fpu_helper.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/xtensa/fpu_helper.c | ||
15 | +++ b/target/xtensa/fpu_helper.c | ||
16 | @@ -XXX,XX +XXX,XX @@ void xtensa_use_first_nan(CPUXtensaState *env, bool use_first) | ||
17 | set_use_first_nan(use_first, &env->fp_status); | ||
18 | set_float_2nan_prop_rule(use_first ? float_2nan_prop_ab : float_2nan_prop_ba, | ||
19 | &env->fp_status); | ||
20 | + set_float_3nan_prop_rule(use_first ? float_3nan_prop_abc : float_3nan_prop_cba, | ||
21 | + &env->fp_status); | ||
22 | } | ||
23 | |||
24 | void HELPER(wur_fpu2k_fcr)(CPUXtensaState *env, uint32_t v) | ||
25 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/fpu/softfloat-specialize.c.inc | ||
28 | +++ b/fpu/softfloat-specialize.c.inc | ||
29 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
30 | } | ||
31 | |||
32 | if (rule == float_3nan_prop_none) { | ||
33 | -#if defined(TARGET_XTENSA) | ||
34 | - if (status->use_first_nan) { | ||
35 | - rule = float_3nan_prop_abc; | ||
36 | - } else { | ||
37 | - rule = float_3nan_prop_cba; | ||
38 | - } | ||
39 | -#else | ||
40 | rule = float_3nan_prop_abc; | ||
41 | -#endif | ||
42 | } | ||
43 | |||
44 | assert(rule != float_3nan_prop_none); | ||
45 | -- | ||
46 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the Float3NaNPropRule explicitly for i386. We had no | ||
2 | i386-specific behaviour in the old ifdef ladder, so we were using the | ||
3 | default "prefer a then b then c" fallback; this is actually the | ||
4 | correct per-the-spec handling for i386. | ||
1 | 5 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20241202131347.498124-25-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/i386/tcg/fpu_helper.c | 1 + | ||
11 | 1 file changed, 1 insertion(+) | ||
12 | |||
13 | diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/i386/tcg/fpu_helper.c | ||
16 | +++ b/target/i386/tcg/fpu_helper.c | ||
17 | @@ -XXX,XX +XXX,XX @@ void cpu_init_fp_statuses(CPUX86State *env) | ||
18 | * there are multiple input NaNs they are selected in the order a, b, c. | ||
19 | */ | ||
20 | set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->sse_status); | ||
21 | + set_float_3nan_prop_rule(float_3nan_prop_abc, &env->sse_status); | ||
22 | } | ||
23 | |||
24 | static inline uint8_t save_exception_flags(CPUX86State *env) | ||
25 | -- | ||
26 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the Float3NaNPropRule explicitly for HPPA, and remove the | ||
2 | ifdef from pickNaNMulAdd(). | ||
1 | 3 | ||
4 | HPPA is the only target that was using the default branch of the | ||
5 | ifdef ladder (other targets either do not use muladd or set | ||
6 | default_nan_mode), so we can remove the ifdef fallback entirely now | ||
7 | (allowing the "rule not set" case to fall into the default of the | ||
8 | switch statement and assert). | ||
9 | |||
10 | We add a TODO note that the HPPA rule is probably wrong; this is | ||
11 | not a behavioural change for this refactoring. | ||
12 | |||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Message-id: 20241202131347.498124-26-peter.maydell@linaro.org | ||
16 | --- | ||
17 | target/hppa/fpu_helper.c | 8 ++++++++ | ||
18 | fpu/softfloat-specialize.c.inc | 4 ---- | ||
19 | 2 files changed, 8 insertions(+), 4 deletions(-) | ||
20 | |||
21 | diff --git a/target/hppa/fpu_helper.c b/target/hppa/fpu_helper.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/target/hppa/fpu_helper.c | ||
24 | +++ b/target/hppa/fpu_helper.c | ||
25 | @@ -XXX,XX +XXX,XX @@ void HELPER(loaded_fr0)(CPUHPPAState *env) | ||
26 | * HPPA does note implement a CPU reset method at all... | ||
27 | */ | ||
28 | set_float_2nan_prop_rule(float_2nan_prop_s_ab, &env->fp_status); | ||
29 | + /* | ||
30 | + * TODO: The HPPA architecture reference only documents its NaN | ||
31 | + * propagation rule for 2-operand operations. Testing on real hardware | ||
32 | + * might be necessary to confirm whether this order for muladd is correct. | ||
33 | + * Not preferring the SNaN is almost certainly incorrect as it diverges | ||
34 | + * from the documented rules for 2-operand operations. | ||
35 | + */ | ||
36 | + set_float_3nan_prop_rule(float_3nan_prop_abc, &env->fp_status); | ||
37 | /* For inf * 0 + NaN, return the input NaN */ | ||
38 | set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status); | ||
39 | } | ||
40 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/fpu/softfloat-specialize.c.inc | ||
43 | +++ b/fpu/softfloat-specialize.c.inc | ||
44 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
45 | } | ||
46 | } | ||
47 | |||
48 | - if (rule == float_3nan_prop_none) { | ||
49 | - rule = float_3nan_prop_abc; | ||
50 | - } | ||
51 | - | ||
52 | assert(rule != float_3nan_prop_none); | ||
53 | if (have_snan && (rule & R_3NAN_SNAN_MASK)) { | ||
54 | /* We have at least one SNaN input and should prefer it */ | ||
55 | -- | ||
56 | 2.34.1 | diff view generated by jsdifflib |
1 | Convert the remaining Neon narrowing shifts to decodetree: | 1 | The use_first_nan field in float_status was an xtensa-specific way to |
---|---|---|---|
2 | * VQSHRN | 2 | select at runtime from two different NaN propagation rules. Now that |
3 | * VQRSHRN | 3 | xtensa is using the target-agnostic NaN propagation rule selection |
4 | that we've just added, we can remove use_first_nan, because there is | ||
5 | no longer any code that reads it. | ||
4 | 6 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20200522145520.6778-7-peter.maydell@linaro.org | 9 | Message-id: 20241202131347.498124-27-peter.maydell@linaro.org |
8 | --- | 10 | --- |
9 | target/arm/neon-dp.decode | 20 ++++++ | 11 | include/fpu/softfloat-helpers.h | 5 ----- |
10 | target/arm/translate-neon.inc.c | 15 +++++ | 12 | include/fpu/softfloat-types.h | 1 - |
11 | target/arm/translate.c | 110 +------------------------------- | 13 | target/xtensa/fpu_helper.c | 1 - |
12 | 3 files changed, 37 insertions(+), 108 deletions(-) | 14 | 3 files changed, 7 deletions(-) |
13 | 15 | ||
14 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 16 | diff --git a/include/fpu/softfloat-helpers.h b/include/fpu/softfloat-helpers.h |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/neon-dp.decode | 18 | --- a/include/fpu/softfloat-helpers.h |
17 | +++ b/target/arm/neon-dp.decode | 19 | +++ b/include/fpu/softfloat-helpers.h |
18 | @@ -XXX,XX +XXX,XX @@ VQSHRUN_16_2sh 1111 001 1 1 . ...... .... 1000 . 0 . 1 .... @2reg_shrn_h | 20 | @@ -XXX,XX +XXX,XX @@ static inline void set_snan_bit_is_one(bool val, float_status *status) |
19 | VQRSHRUN_64_2sh 1111 001 1 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_d | 21 | status->snan_bit_is_one = val; |
20 | VQRSHRUN_32_2sh 1111 001 1 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_s | ||
21 | VQRSHRUN_16_2sh 1111 001 1 1 . ...... .... 1000 . 1 . 1 .... @2reg_shrn_h | ||
22 | + | ||
23 | +# VQSHRN with signed input | ||
24 | +VQSHRN_S64_2sh 1111 001 0 1 . ...... .... 1001 . 0 . 1 .... @2reg_shrn_d | ||
25 | +VQSHRN_S32_2sh 1111 001 0 1 . ...... .... 1001 . 0 . 1 .... @2reg_shrn_s | ||
26 | +VQSHRN_S16_2sh 1111 001 0 1 . ...... .... 1001 . 0 . 1 .... @2reg_shrn_h | ||
27 | + | ||
28 | +# VQRSHRN with signed input | ||
29 | +VQRSHRN_S64_2sh 1111 001 0 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_d | ||
30 | +VQRSHRN_S32_2sh 1111 001 0 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_s | ||
31 | +VQRSHRN_S16_2sh 1111 001 0 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_h | ||
32 | + | ||
33 | +# VQSHRN with unsigned input | ||
34 | +VQSHRN_U64_2sh 1111 001 1 1 . ...... .... 1001 . 0 . 1 .... @2reg_shrn_d | ||
35 | +VQSHRN_U32_2sh 1111 001 1 1 . ...... .... 1001 . 0 . 1 .... @2reg_shrn_s | ||
36 | +VQSHRN_U16_2sh 1111 001 1 1 . ...... .... 1001 . 0 . 1 .... @2reg_shrn_h | ||
37 | + | ||
38 | +# VQRSHRN with unsigned input | ||
39 | +VQRSHRN_U64_2sh 1111 001 1 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_d | ||
40 | +VQRSHRN_U32_2sh 1111 001 1 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_s | ||
41 | +VQRSHRN_U16_2sh 1111 001 1 1 . ...... .... 1001 . 1 . 1 .... @2reg_shrn_h | ||
42 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/target/arm/translate-neon.inc.c | ||
45 | +++ b/target/arm/translate-neon.inc.c | ||
46 | @@ -XXX,XX +XXX,XX @@ DO_2SN_32(VQSHRUN_16, gen_helper_neon_shl_s16, gen_helper_neon_unarrow_sat8) | ||
47 | DO_2SN_64(VQRSHRUN_64, gen_helper_neon_rshl_s64, gen_helper_neon_unarrow_sat32) | ||
48 | DO_2SN_32(VQRSHRUN_32, gen_helper_neon_rshl_s32, gen_helper_neon_unarrow_sat16) | ||
49 | DO_2SN_32(VQRSHRUN_16, gen_helper_neon_rshl_s16, gen_helper_neon_unarrow_sat8) | ||
50 | +DO_2SN_64(VQSHRN_S64, gen_sshl_i64, gen_helper_neon_narrow_sat_s32) | ||
51 | +DO_2SN_32(VQSHRN_S32, gen_sshl_i32, gen_helper_neon_narrow_sat_s16) | ||
52 | +DO_2SN_32(VQSHRN_S16, gen_helper_neon_shl_s16, gen_helper_neon_narrow_sat_s8) | ||
53 | + | ||
54 | +DO_2SN_64(VQRSHRN_S64, gen_helper_neon_rshl_s64, gen_helper_neon_narrow_sat_s32) | ||
55 | +DO_2SN_32(VQRSHRN_S32, gen_helper_neon_rshl_s32, gen_helper_neon_narrow_sat_s16) | ||
56 | +DO_2SN_32(VQRSHRN_S16, gen_helper_neon_rshl_s16, gen_helper_neon_narrow_sat_s8) | ||
57 | + | ||
58 | +DO_2SN_64(VQSHRN_U64, gen_ushl_i64, gen_helper_neon_narrow_sat_u32) | ||
59 | +DO_2SN_32(VQSHRN_U32, gen_ushl_i32, gen_helper_neon_narrow_sat_u16) | ||
60 | +DO_2SN_32(VQSHRN_U16, gen_helper_neon_shl_u16, gen_helper_neon_narrow_sat_u8) | ||
61 | + | ||
62 | +DO_2SN_64(VQRSHRN_U64, gen_helper_neon_rshl_u64, gen_helper_neon_narrow_sat_u32) | ||
63 | +DO_2SN_32(VQRSHRN_U32, gen_helper_neon_rshl_u32, gen_helper_neon_narrow_sat_u16) | ||
64 | +DO_2SN_32(VQRSHRN_U16, gen_helper_neon_rshl_u16, gen_helper_neon_narrow_sat_u8) | ||
65 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
66 | index XXXXXXX..XXXXXXX 100644 | ||
67 | --- a/target/arm/translate.c | ||
68 | +++ b/target/arm/translate.c | ||
69 | @@ -XXX,XX +XXX,XX @@ static inline void gen_neon_unarrow_sats(int size, TCGv_i32 dest, TCGv_i64 src) | ||
70 | } | ||
71 | } | 22 | } |
72 | 23 | ||
73 | -static inline void gen_neon_shift_narrow(int size, TCGv_i32 var, TCGv_i32 shift, | 24 | -static inline void set_use_first_nan(bool val, float_status *status) |
74 | - int q, int u) | ||
75 | -{ | 25 | -{ |
76 | - if (q) { | 26 | - status->use_first_nan = val; |
77 | - if (u) { | ||
78 | - switch (size) { | ||
79 | - case 1: gen_helper_neon_rshl_u16(var, var, shift); break; | ||
80 | - case 2: gen_helper_neon_rshl_u32(var, var, shift); break; | ||
81 | - default: abort(); | ||
82 | - } | ||
83 | - } else { | ||
84 | - switch (size) { | ||
85 | - case 1: gen_helper_neon_rshl_s16(var, var, shift); break; | ||
86 | - case 2: gen_helper_neon_rshl_s32(var, var, shift); break; | ||
87 | - default: abort(); | ||
88 | - } | ||
89 | - } | ||
90 | - } else { | ||
91 | - if (u) { | ||
92 | - switch (size) { | ||
93 | - case 1: gen_helper_neon_shl_u16(var, var, shift); break; | ||
94 | - case 2: gen_ushl_i32(var, var, shift); break; | ||
95 | - default: abort(); | ||
96 | - } | ||
97 | - } else { | ||
98 | - switch (size) { | ||
99 | - case 1: gen_helper_neon_shl_s16(var, var, shift); break; | ||
100 | - case 2: gen_sshl_i32(var, var, shift); break; | ||
101 | - default: abort(); | ||
102 | - } | ||
103 | - } | ||
104 | - } | ||
105 | -} | 27 | -} |
106 | - | 28 | - |
107 | static inline void gen_neon_widen(TCGv_i64 dest, TCGv_i32 src, int size, int u) | 29 | static inline void set_no_signaling_nans(bool val, float_status *status) |
108 | { | 30 | { |
109 | if (u) { | 31 | status->no_signaling_nans = val; |
110 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 32 | diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h |
111 | case 6: /* VQSHLU */ | 33 | index XXXXXXX..XXXXXXX 100644 |
112 | case 7: /* VQSHL */ | 34 | --- a/include/fpu/softfloat-types.h |
113 | case 8: /* VSHRN, VRSHRN, VQSHRUN, VQRSHRUN */ | 35 | +++ b/include/fpu/softfloat-types.h |
114 | + case 9: /* VQSHRN, VQRSHRN */ | 36 | @@ -XXX,XX +XXX,XX @@ typedef struct float_status { |
115 | return 1; /* handled by decodetree */ | 37 | * softfloat-specialize.inc.c) |
116 | default: | 38 | */ |
117 | break; | 39 | bool snan_bit_is_one; |
118 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 40 | - bool use_first_nan; |
119 | size--; | 41 | bool no_signaling_nans; |
120 | } | 42 | /* should overflowed results subtract re_bias to its exponent? */ |
121 | shift = (insn >> 16) & ((1 << (3 + size)) - 1); | 43 | bool rebias_overflow; |
122 | - if (op < 10) { | 44 | diff --git a/target/xtensa/fpu_helper.c b/target/xtensa/fpu_helper.c |
123 | - /* Shift by immediate and narrow: | 45 | index XXXXXXX..XXXXXXX 100644 |
124 | - VSHRN, VRSHRN, VQSHRN, VQRSHRN. */ | 46 | --- a/target/xtensa/fpu_helper.c |
125 | - int input_unsigned = (op == 8) ? !u : u; | 47 | +++ b/target/xtensa/fpu_helper.c |
126 | - if (rm & 1) { | 48 | @@ -XXX,XX +XXX,XX @@ static const struct { |
127 | - return 1; | 49 | |
128 | - } | 50 | void xtensa_use_first_nan(CPUXtensaState *env, bool use_first) |
129 | - shift = shift - (1 << (size + 3)); | 51 | { |
130 | - size++; | 52 | - set_use_first_nan(use_first, &env->fp_status); |
131 | - if (size == 3) { | 53 | set_float_2nan_prop_rule(use_first ? float_2nan_prop_ab : float_2nan_prop_ba, |
132 | - tmp64 = tcg_const_i64(shift); | 54 | &env->fp_status); |
133 | - neon_load_reg64(cpu_V0, rm); | 55 | set_float_3nan_prop_rule(use_first ? float_3nan_prop_abc : float_3nan_prop_cba, |
134 | - neon_load_reg64(cpu_V1, rm + 1); | ||
135 | - for (pass = 0; pass < 2; pass++) { | ||
136 | - TCGv_i64 in; | ||
137 | - if (pass == 0) { | ||
138 | - in = cpu_V0; | ||
139 | - } else { | ||
140 | - in = cpu_V1; | ||
141 | - } | ||
142 | - if (q) { | ||
143 | - if (input_unsigned) { | ||
144 | - gen_helper_neon_rshl_u64(cpu_V0, in, tmp64); | ||
145 | - } else { | ||
146 | - gen_helper_neon_rshl_s64(cpu_V0, in, tmp64); | ||
147 | - } | ||
148 | - } else { | ||
149 | - if (input_unsigned) { | ||
150 | - gen_ushl_i64(cpu_V0, in, tmp64); | ||
151 | - } else { | ||
152 | - gen_sshl_i64(cpu_V0, in, tmp64); | ||
153 | - } | ||
154 | - } | ||
155 | - tmp = tcg_temp_new_i32(); | ||
156 | - gen_neon_narrow_op(op == 8, u, size - 1, tmp, cpu_V0); | ||
157 | - neon_store_reg(rd, pass, tmp); | ||
158 | - } /* for pass */ | ||
159 | - tcg_temp_free_i64(tmp64); | ||
160 | - } else { | ||
161 | - if (size == 1) { | ||
162 | - imm = (uint16_t)shift; | ||
163 | - imm |= imm << 16; | ||
164 | - } else { | ||
165 | - /* size == 2 */ | ||
166 | - imm = (uint32_t)shift; | ||
167 | - } | ||
168 | - tmp2 = tcg_const_i32(imm); | ||
169 | - tmp4 = neon_load_reg(rm + 1, 0); | ||
170 | - tmp5 = neon_load_reg(rm + 1, 1); | ||
171 | - for (pass = 0; pass < 2; pass++) { | ||
172 | - if (pass == 0) { | ||
173 | - tmp = neon_load_reg(rm, 0); | ||
174 | - } else { | ||
175 | - tmp = tmp4; | ||
176 | - } | ||
177 | - gen_neon_shift_narrow(size, tmp, tmp2, q, | ||
178 | - input_unsigned); | ||
179 | - if (pass == 0) { | ||
180 | - tmp3 = neon_load_reg(rm, 1); | ||
181 | - } else { | ||
182 | - tmp3 = tmp5; | ||
183 | - } | ||
184 | - gen_neon_shift_narrow(size, tmp3, tmp2, q, | ||
185 | - input_unsigned); | ||
186 | - tcg_gen_concat_i32_i64(cpu_V0, tmp, tmp3); | ||
187 | - tcg_temp_free_i32(tmp); | ||
188 | - tcg_temp_free_i32(tmp3); | ||
189 | - tmp = tcg_temp_new_i32(); | ||
190 | - gen_neon_narrow_op(op == 8, u, size - 1, tmp, cpu_V0); | ||
191 | - neon_store_reg(rd, pass, tmp); | ||
192 | - } /* for pass */ | ||
193 | - tcg_temp_free_i32(tmp2); | ||
194 | - } | ||
195 | - } else if (op == 10) { | ||
196 | + if (op == 10) { | ||
197 | /* VSHLL, VMOVL */ | ||
198 | if (q || (rd & 1)) { | ||
199 | return 1; | ||
200 | -- | 56 | -- |
201 | 2.20.1 | 57 | 2.34.1 |
202 | |||
203 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Currently m68k_cpu_reset_hold() calls floatx80_default_nan(NULL) | ||
2 | to get the NaN bit pattern to reset the FPU registers. This | ||
3 | works because it happens that our implementation of | ||
4 | floatx80_default_nan() doesn't actually look at the float_status | ||
5 | pointer except for TARGET_MIPS. However, this isn't guaranteed, | ||
6 | and to be able to remove the ifdef in floatx80_default_nan() | ||
7 | we're going to need a real float_status here. | ||
1 | 8 | ||
9 | Rearrange m68k_cpu_reset_hold() so that we initialize env->fp_status | ||
10 | earlier, and thus can pass it to floatx80_default_nan(). | ||
11 | |||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20241202131347.498124-28-peter.maydell@linaro.org | ||
15 | --- | ||
16 | target/m68k/cpu.c | 12 +++++++----- | ||
17 | 1 file changed, 7 insertions(+), 5 deletions(-) | ||
18 | |||
19 | diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/target/m68k/cpu.c | ||
22 | +++ b/target/m68k/cpu.c | ||
23 | @@ -XXX,XX +XXX,XX @@ static void m68k_cpu_reset_hold(Object *obj, ResetType type) | ||
24 | CPUState *cs = CPU(obj); | ||
25 | M68kCPUClass *mcc = M68K_CPU_GET_CLASS(obj); | ||
26 | CPUM68KState *env = cpu_env(cs); | ||
27 | - floatx80 nan = floatx80_default_nan(NULL); | ||
28 | + floatx80 nan; | ||
29 | int i; | ||
30 | |||
31 | if (mcc->parent_phases.hold) { | ||
32 | @@ -XXX,XX +XXX,XX @@ static void m68k_cpu_reset_hold(Object *obj, ResetType type) | ||
33 | #else | ||
34 | cpu_m68k_set_sr(env, SR_S | SR_I); | ||
35 | #endif | ||
36 | - for (i = 0; i < 8; i++) { | ||
37 | - env->fregs[i].d = nan; | ||
38 | - } | ||
39 | - cpu_m68k_set_fpcr(env, 0); | ||
40 | /* | ||
41 | * M68000 FAMILY PROGRAMMER'S REFERENCE MANUAL | ||
42 | * 3.4 FLOATING-POINT INSTRUCTION DETAILS | ||
43 | @@ -XXX,XX +XXX,XX @@ static void m68k_cpu_reset_hold(Object *obj, ResetType type) | ||
44 | * preceding paragraph for nonsignaling NaNs. | ||
45 | */ | ||
46 | set_float_2nan_prop_rule(float_2nan_prop_ab, &env->fp_status); | ||
47 | + | ||
48 | + nan = floatx80_default_nan(&env->fp_status); | ||
49 | + for (i = 0; i < 8; i++) { | ||
50 | + env->fregs[i].d = nan; | ||
51 | + } | ||
52 | + cpu_m68k_set_fpcr(env, 0); | ||
53 | env->fpsr = 0; | ||
54 | |||
55 | /* TODO: We should set PC from the interrupt vector. */ | ||
56 | -- | ||
57 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | We create our 128-bit default NaN by calling parts64_default_nan() | ||
2 | and then adjusting the result. We can do the same trick for creating | ||
3 | the floatx80 default NaN, which lets us drop a target ifdef. | ||
1 | 4 | ||
5 | floatx80 is used only by: | ||
6 | i386 | ||
7 | m68k | ||
8 | arm nwfpe old floating-point emulation emulation support | ||
9 | (which is essentially dead, especially the parts involving floatx80) | ||
10 | PPC (only in the xsrqpxp instruction, which just rounds an input | ||
11 | value by converting to floatx80 and back, so will never generate | ||
12 | the default NaN) | ||
13 | |||
14 | The floatx80 default NaN as currently implemented is: | ||
15 | m68k: sign = 0, exp = 1...1, int = 1, frac = 1....1 | ||
16 | i386: sign = 1, exp = 1...1, int = 1, frac = 10...0 | ||
17 | |||
18 | These are the same as the parts64_default_nan for these architectures. | ||
19 | |||
20 | This is technically a possible behaviour change for arm linux-user | ||
21 | nwfpe emulation emulation, because the default NaN will now have the | ||
22 | sign bit clear. But we were already generating a different floatx80 | ||
23 | default NaN from the real kernel emulation we are supposedly | ||
24 | following, which appears to use an all-bits-1 value: | ||
25 | https://elixir.bootlin.com/linux/v6.12/source/arch/arm/nwfpe/softfloat-specialize#L267 | ||
26 | |||
27 | This won't affect the only "real" use of the nwfpe emulation, which | ||
28 | is ancient binaries that used it as part of the old floating point | ||
29 | calling convention; that only uses loads and stores of 32 and 64 bit | ||
30 | floats, not any of the floatx80 behaviour the original hardware had. | ||
31 | We also get the nwfpe float64 default NaN value wrong: | ||
32 | https://elixir.bootlin.com/linux/v6.12/source/arch/arm/nwfpe/softfloat-specialize#L166 | ||
33 | so if we ever cared about this obscure corner the right fix would be | ||
34 | to correct that so nwfpe used its own default-NaN setting rather | ||
35 | than the Arm VFP one. | ||
36 | |||
37 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
38 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
39 | Message-id: 20241202131347.498124-29-peter.maydell@linaro.org | ||
40 | --- | ||
41 | fpu/softfloat-specialize.c.inc | 20 ++++++++++---------- | ||
42 | 1 file changed, 10 insertions(+), 10 deletions(-) | ||
43 | |||
44 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/fpu/softfloat-specialize.c.inc | ||
47 | +++ b/fpu/softfloat-specialize.c.inc | ||
48 | @@ -XXX,XX +XXX,XX @@ static void parts128_silence_nan(FloatParts128 *p, float_status *status) | ||
49 | floatx80 floatx80_default_nan(float_status *status) | ||
50 | { | ||
51 | floatx80 r; | ||
52 | + /* | ||
53 | + * Extrapolate from the choices made by parts64_default_nan to fill | ||
54 | + * in the floatx80 format. We assume that floatx80's explicit | ||
55 | + * integer bit is always set (this is true for i386 and m68k, | ||
56 | + * which are the only real users of this format). | ||
57 | + */ | ||
58 | + FloatParts64 p64; | ||
59 | + parts64_default_nan(&p64, status); | ||
60 | |||
61 | - /* None of the targets that have snan_bit_is_one use floatx80. */ | ||
62 | - assert(!snan_bit_is_one(status)); | ||
63 | -#if defined(TARGET_M68K) | ||
64 | - r.low = UINT64_C(0xFFFFFFFFFFFFFFFF); | ||
65 | - r.high = 0x7FFF; | ||
66 | -#else | ||
67 | - /* X86 */ | ||
68 | - r.low = UINT64_C(0xC000000000000000); | ||
69 | - r.high = 0xFFFF; | ||
70 | -#endif | ||
71 | + r.high = 0x7FFF | (p64.sign << 15); | ||
72 | + r.low = (1ULL << DECOMPOSED_BINARY_POINT) | p64.frac; | ||
73 | return r; | ||
74 | } | ||
75 | |||
76 | -- | ||
77 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | In target/loongarch's helper_fclass_s() and helper_fclass_d() we pass | ||
2 | a zero-initialized float_status struct to float32_is_quiet_nan() and | ||
3 | float64_is_quiet_nan(), with the cryptic comment "for | ||
4 | snan_bit_is_one". | ||
1 | 5 | ||
6 | This pattern appears to have been copied from target/riscv, where it | ||
7 | is used because the functions there do not have ready access to the | ||
8 | CPU state struct. The comment presumably refers to the fact that the | ||
9 | main reason the is_quiet_nan() functions want the float_state is | ||
10 | because they want to know about the snan_bit_is_one config. | ||
11 | |||
12 | In the loongarch helpers, though, we have the CPU state struct | ||
13 | to hand. Use the usual env->fp_status here. This avoids our needing | ||
14 | to track that we need to update the initializer of the local | ||
15 | float_status structs when the core softfloat code adds new | ||
16 | options for targets to configure their behaviour. | ||
17 | |||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
20 | Message-id: 20241202131347.498124-30-peter.maydell@linaro.org | ||
21 | --- | ||
22 | target/loongarch/tcg/fpu_helper.c | 6 ++---- | ||
23 | 1 file changed, 2 insertions(+), 4 deletions(-) | ||
24 | |||
25 | diff --git a/target/loongarch/tcg/fpu_helper.c b/target/loongarch/tcg/fpu_helper.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/target/loongarch/tcg/fpu_helper.c | ||
28 | +++ b/target/loongarch/tcg/fpu_helper.c | ||
29 | @@ -XXX,XX +XXX,XX @@ uint64_t helper_fclass_s(CPULoongArchState *env, uint64_t fj) | ||
30 | } else if (float32_is_zero_or_denormal(f)) { | ||
31 | return sign ? 1 << 4 : 1 << 8; | ||
32 | } else if (float32_is_any_nan(f)) { | ||
33 | - float_status s = { }; /* for snan_bit_is_one */ | ||
34 | - return float32_is_quiet_nan(f, &s) ? 1 << 1 : 1 << 0; | ||
35 | + return float32_is_quiet_nan(f, &env->fp_status) ? 1 << 1 : 1 << 0; | ||
36 | } else { | ||
37 | return sign ? 1 << 3 : 1 << 7; | ||
38 | } | ||
39 | @@ -XXX,XX +XXX,XX @@ uint64_t helper_fclass_d(CPULoongArchState *env, uint64_t fj) | ||
40 | } else if (float64_is_zero_or_denormal(f)) { | ||
41 | return sign ? 1 << 4 : 1 << 8; | ||
42 | } else if (float64_is_any_nan(f)) { | ||
43 | - float_status s = { }; /* for snan_bit_is_one */ | ||
44 | - return float64_is_quiet_nan(f, &s) ? 1 << 1 : 1 << 0; | ||
45 | + return float64_is_quiet_nan(f, &env->fp_status) ? 1 << 1 : 1 << 0; | ||
46 | } else { | ||
47 | return sign ? 1 << 3 : 1 << 7; | ||
48 | } | ||
49 | -- | ||
50 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | In the frem helper, we have a local float_status because we want to | ||
2 | execute the floatx80_div() with a custom rounding mode. Instead of | ||
3 | zero-initializing the local float_status and then having to set it up | ||
4 | with the m68k standard behaviour (including the NaN propagation rule | ||
5 | and copying the rounding precision from env->fp_status), initialize | ||
6 | it as a complete copy of env->fp_status. This will avoid our having | ||
7 | to add new code in this function for every new config knob we add | ||
8 | to fp_status. | ||
1 | 9 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20241202131347.498124-31-peter.maydell@linaro.org | ||
13 | --- | ||
14 | target/m68k/fpu_helper.c | 6 ++---- | ||
15 | 1 file changed, 2 insertions(+), 4 deletions(-) | ||
16 | |||
17 | diff --git a/target/m68k/fpu_helper.c b/target/m68k/fpu_helper.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/m68k/fpu_helper.c | ||
20 | +++ b/target/m68k/fpu_helper.c | ||
21 | @@ -XXX,XX +XXX,XX @@ void HELPER(frem)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1) | ||
22 | |||
23 | fp_rem = floatx80_rem(val1->d, val0->d, &env->fp_status); | ||
24 | if (!floatx80_is_any_nan(fp_rem)) { | ||
25 | - float_status fp_status = { }; | ||
26 | + /* Use local temporary fp_status to set different rounding mode */ | ||
27 | + float_status fp_status = env->fp_status; | ||
28 | uint32_t quotient; | ||
29 | int sign; | ||
30 | |||
31 | /* Calculate quotient directly using round to nearest mode */ | ||
32 | - set_float_2nan_prop_rule(float_2nan_prop_ab, &fp_status); | ||
33 | set_float_rounding_mode(float_round_nearest_even, &fp_status); | ||
34 | - set_floatx80_rounding_precision( | ||
35 | - get_floatx80_rounding_precision(&env->fp_status), &fp_status); | ||
36 | fp_quot.d = floatx80_div(val1->d, val0->d, &fp_status); | ||
37 | |||
38 | sign = extractFloatx80Sign(fp_quot.d); | ||
39 | -- | ||
40 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | In cf_fpu_gdb_get_reg() and cf_fpu_gdb_set_reg() we do the conversion | ||
2 | from float64 to floatx80 using a scratch float_status, because we | ||
3 | don't want the conversion to affect the CPU's floating point exception | ||
4 | status. Currently we use a zero-initialized float_status. This will | ||
5 | get steadily more awkward as we add config knobs to float_status | ||
6 | that the target must initialize. Avoid having to add any of that | ||
7 | configuration here by instead initializing our local float_status | ||
8 | from the env->fp_status. | ||
1 | 9 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20241202131347.498124-32-peter.maydell@linaro.org | ||
13 | --- | ||
14 | target/m68k/helper.c | 6 ++++-- | ||
15 | 1 file changed, 4 insertions(+), 2 deletions(-) | ||
16 | |||
17 | diff --git a/target/m68k/helper.c b/target/m68k/helper.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/m68k/helper.c | ||
20 | +++ b/target/m68k/helper.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static int cf_fpu_gdb_get_reg(CPUState *cs, GByteArray *mem_buf, int n) | ||
22 | CPUM68KState *env = &cpu->env; | ||
23 | |||
24 | if (n < 8) { | ||
25 | - float_status s = {}; | ||
26 | + /* Use scratch float_status so any exceptions don't change CPU state */ | ||
27 | + float_status s = env->fp_status; | ||
28 | return gdb_get_reg64(mem_buf, floatx80_to_float64(env->fregs[n].d, &s)); | ||
29 | } | ||
30 | switch (n) { | ||
31 | @@ -XXX,XX +XXX,XX @@ static int cf_fpu_gdb_set_reg(CPUState *cs, uint8_t *mem_buf, int n) | ||
32 | CPUM68KState *env = &cpu->env; | ||
33 | |||
34 | if (n < 8) { | ||
35 | - float_status s = {}; | ||
36 | + /* Use scratch float_status so any exceptions don't change CPU state */ | ||
37 | + float_status s = env->fp_status; | ||
38 | env->fregs[n].d = float64_to_floatx80(ldq_be_p(mem_buf), &s); | ||
39 | return 8; | ||
40 | } | ||
41 | -- | ||
42 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Paul Zimmerman <pauldzim@gmail.com> | 1 | In the helper functions flcmps and flcmpd we use a scratch float_status |
---|---|---|---|
2 | so that we don't change the CPU state if the comparison raises any | ||
3 | floating point exception flags. Instead of zero-initializing this | ||
4 | scratch float_status, initialize it as a copy of env->fp_status. This | ||
5 | avoids the need to explicitly initialize settings like the NaN | ||
6 | propagation rule or others we might add to softfloat in future. | ||
2 | 7 | ||
3 | Wire the dwc-hsotg (dwc2) emulation into Qemu | 8 | To do this we need to pass the CPU env pointer in to the helper. |
4 | 9 | ||
5 | Signed-off-by: Paul Zimmerman <pauldzim@gmail.com> | ||
6 | Reviewed-by: Philippe Mathieu-Daude <f4bug@amsat.org> | ||
7 | Message-id: 20200520235349.21215-7-pauldzim@gmail.com | ||
8 | 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: 20241202131347.498124-33-peter.maydell@linaro.org | ||
9 | --- | 13 | --- |
10 | include/hw/arm/bcm2835_peripherals.h | 3 ++- | 14 | target/sparc/helper.h | 4 ++-- |
11 | hw/arm/bcm2835_peripherals.c | 21 ++++++++++++++++++++- | 15 | target/sparc/fop_helper.c | 8 ++++---- |
12 | 2 files changed, 22 insertions(+), 2 deletions(-) | 16 | target/sparc/translate.c | 4 ++-- |
17 | 3 files changed, 8 insertions(+), 8 deletions(-) | ||
13 | 18 | ||
14 | diff --git a/include/hw/arm/bcm2835_peripherals.h b/include/hw/arm/bcm2835_peripherals.h | 19 | diff --git a/target/sparc/helper.h b/target/sparc/helper.h |
15 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/include/hw/arm/bcm2835_peripherals.h | 21 | --- a/target/sparc/helper.h |
17 | +++ b/include/hw/arm/bcm2835_peripherals.h | 22 | +++ b/target/sparc/helper.h |
18 | @@ -XXX,XX +XXX,XX @@ | 23 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(fcmpd, TCG_CALL_NO_WG, i32, env, f64, f64) |
19 | #include "hw/sd/bcm2835_sdhost.h" | 24 | DEF_HELPER_FLAGS_3(fcmped, TCG_CALL_NO_WG, i32, env, f64, f64) |
20 | #include "hw/gpio/bcm2835_gpio.h" | 25 | DEF_HELPER_FLAGS_3(fcmpq, TCG_CALL_NO_WG, i32, env, i128, i128) |
21 | #include "hw/timer/bcm2835_systmr.h" | 26 | DEF_HELPER_FLAGS_3(fcmpeq, TCG_CALL_NO_WG, i32, env, i128, i128) |
22 | +#include "hw/usb/hcd-dwc2.h" | 27 | -DEF_HELPER_FLAGS_2(flcmps, TCG_CALL_NO_RWG_SE, i32, f32, f32) |
23 | #include "hw/misc/unimp.h" | 28 | -DEF_HELPER_FLAGS_2(flcmpd, TCG_CALL_NO_RWG_SE, i32, f64, f64) |
24 | 29 | +DEF_HELPER_FLAGS_3(flcmps, TCG_CALL_NO_RWG_SE, i32, env, f32, f32) | |
25 | #define TYPE_BCM2835_PERIPHERALS "bcm2835-peripherals" | 30 | +DEF_HELPER_FLAGS_3(flcmpd, TCG_CALL_NO_RWG_SE, i32, env, f64, f64) |
26 | @@ -XXX,XX +XXX,XX @@ typedef struct BCM2835PeripheralState { | 31 | DEF_HELPER_2(raise_exception, noreturn, env, int) |
27 | UnimplementedDeviceState ave0; | 32 | |
28 | UnimplementedDeviceState bscsl; | 33 | DEF_HELPER_FLAGS_3(faddd, TCG_CALL_NO_WG, f64, env, f64, f64) |
29 | UnimplementedDeviceState smi; | 34 | diff --git a/target/sparc/fop_helper.c b/target/sparc/fop_helper.c |
30 | - UnimplementedDeviceState dwc2; | ||
31 | + DWC2State dwc2; | ||
32 | UnimplementedDeviceState sdramc; | ||
33 | } BCM2835PeripheralState; | ||
34 | |||
35 | diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | 35 | index XXXXXXX..XXXXXXX 100644 |
37 | --- a/hw/arm/bcm2835_peripherals.c | 36 | --- a/target/sparc/fop_helper.c |
38 | +++ b/hw/arm/bcm2835_peripherals.c | 37 | +++ b/target/sparc/fop_helper.c |
39 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_init(Object *obj) | 38 | @@ -XXX,XX +XXX,XX @@ uint32_t helper_fcmpeq(CPUSPARCState *env, Int128 src1, Int128 src2) |
40 | /* Mphi */ | 39 | return finish_fcmp(env, r, GETPC()); |
41 | sysbus_init_child_obj(obj, "mphi", &s->mphi, sizeof(s->mphi), | ||
42 | TYPE_BCM2835_MPHI); | ||
43 | + | ||
44 | + /* DWC2 */ | ||
45 | + sysbus_init_child_obj(obj, "dwc2", &s->dwc2, sizeof(s->dwc2), | ||
46 | + TYPE_DWC2_USB); | ||
47 | + | ||
48 | + object_property_add_const_link(OBJECT(&s->dwc2), "dma-mr", | ||
49 | + OBJECT(&s->gpu_bus_mr)); | ||
50 | } | 40 | } |
51 | 41 | ||
52 | static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | 42 | -uint32_t helper_flcmps(float32 src1, float32 src2) |
53 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | 43 | +uint32_t helper_flcmps(CPUSPARCState *env, float32 src1, float32 src2) |
54 | qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, | 44 | { |
55 | INTERRUPT_HOSTPORT)); | 45 | /* |
56 | 46 | * FLCMP never raises an exception nor modifies any FSR fields. | |
57 | + /* DWC2 */ | 47 | * Perform the comparison with a dummy fp environment. |
58 | + object_property_set_bool(OBJECT(&s->dwc2), true, "realized", &err); | 48 | */ |
59 | + if (err) { | 49 | - float_status discard = { }; |
60 | + error_propagate(errp, err); | 50 | + float_status discard = env->fp_status; |
61 | + return; | 51 | FloatRelation r; |
62 | + } | 52 | |
63 | + | 53 | set_float_2nan_prop_rule(float_2nan_prop_s_ba, &discard); |
64 | + memory_region_add_subregion(&s->peri_mr, USB_OTG_OFFSET, | 54 | @@ -XXX,XX +XXX,XX @@ uint32_t helper_flcmps(float32 src1, float32 src2) |
65 | + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->dwc2), 0)); | 55 | g_assert_not_reached(); |
66 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->dwc2), 0, | ||
67 | + qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, | ||
68 | + INTERRUPT_USB)); | ||
69 | + | ||
70 | create_unimp(s, &s->armtmr, "bcm2835-sp804", ARMCTRL_TIMER0_1_OFFSET, 0x40); | ||
71 | create_unimp(s, &s->cprman, "bcm2835-cprman", CPRMAN_OFFSET, 0x1000); | ||
72 | create_unimp(s, &s->a2w, "bcm2835-a2w", A2W_OFFSET, 0x1000); | ||
73 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | ||
74 | create_unimp(s, &s->otp, "bcm2835-otp", OTP_OFFSET, 0x80); | ||
75 | create_unimp(s, &s->dbus, "bcm2835-dbus", DBUS_OFFSET, 0x8000); | ||
76 | create_unimp(s, &s->ave0, "bcm2835-ave0", AVE0_OFFSET, 0x8000); | ||
77 | - create_unimp(s, &s->dwc2, "dwc-usb2", USB_OTG_OFFSET, 0x1000); | ||
78 | create_unimp(s, &s->sdramc, "bcm2835-sdramc", SDRAMC_OFFSET, 0x100); | ||
79 | } | 56 | } |
80 | 57 | ||
58 | -uint32_t helper_flcmpd(float64 src1, float64 src2) | ||
59 | +uint32_t helper_flcmpd(CPUSPARCState *env, float64 src1, float64 src2) | ||
60 | { | ||
61 | - float_status discard = { }; | ||
62 | + float_status discard = env->fp_status; | ||
63 | FloatRelation r; | ||
64 | |||
65 | set_float_2nan_prop_rule(float_2nan_prop_s_ba, &discard); | ||
66 | diff --git a/target/sparc/translate.c b/target/sparc/translate.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/target/sparc/translate.c | ||
69 | +++ b/target/sparc/translate.c | ||
70 | @@ -XXX,XX +XXX,XX @@ static bool trans_FLCMPs(DisasContext *dc, arg_FLCMPs *a) | ||
71 | |||
72 | src1 = gen_load_fpr_F(dc, a->rs1); | ||
73 | src2 = gen_load_fpr_F(dc, a->rs2); | ||
74 | - gen_helper_flcmps(cpu_fcc[a->cc], src1, src2); | ||
75 | + gen_helper_flcmps(cpu_fcc[a->cc], tcg_env, src1, src2); | ||
76 | return advance_pc(dc); | ||
77 | } | ||
78 | |||
79 | @@ -XXX,XX +XXX,XX @@ static bool trans_FLCMPd(DisasContext *dc, arg_FLCMPd *a) | ||
80 | |||
81 | src1 = gen_load_fpr_D(dc, a->rs1); | ||
82 | src2 = gen_load_fpr_D(dc, a->rs2); | ||
83 | - gen_helper_flcmpd(cpu_fcc[a->cc], src1, src2); | ||
84 | + gen_helper_flcmpd(cpu_fcc[a->cc], tcg_env, src1, src2); | ||
85 | return advance_pc(dc); | ||
86 | } | ||
87 | |||
81 | -- | 88 | -- |
82 | 2.20.1 | 89 | 2.34.1 |
83 | |||
84 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | In the helper_compute_fprf functions, we pass a dummy float_status | ||
2 | in to the is_signaling_nan() function. This is unnecessary, because | ||
3 | we have convenient access to the CPU env pointer here and that | ||
4 | is already set up with the correct values for the snan_bit_is_one | ||
5 | and no_signaling_nans config settings. is_signaling_nan() doesn't | ||
6 | ever update the fp_status with any exception flags, so there is | ||
7 | no reason not to use env->fp_status here. | ||
1 | 8 | ||
9 | Use env->fp_status instead of the dummy fp_status. | ||
10 | |||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20241202131347.498124-34-peter.maydell@linaro.org | ||
14 | --- | ||
15 | target/ppc/fpu_helper.c | 3 +-- | ||
16 | 1 file changed, 1 insertion(+), 2 deletions(-) | ||
17 | |||
18 | diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/ppc/fpu_helper.c | ||
21 | +++ b/target/ppc/fpu_helper.c | ||
22 | @@ -XXX,XX +XXX,XX @@ void helper_compute_fprf_##tp(CPUPPCState *env, tp arg) \ | ||
23 | } else if (tp##_is_infinity(arg)) { \ | ||
24 | fprf = neg ? 0x09 << FPSCR_FPRF : 0x05 << FPSCR_FPRF; \ | ||
25 | } else { \ | ||
26 | - float_status dummy = { }; /* snan_bit_is_one = 0 */ \ | ||
27 | - if (tp##_is_signaling_nan(arg, &dummy)) { \ | ||
28 | + if (tp##_is_signaling_nan(arg, &env->fp_status)) { \ | ||
29 | fprf = 0x00 << FPSCR_FPRF; \ | ||
30 | } else { \ | ||
31 | fprf = 0x11 << FPSCR_FPRF; \ | ||
32 | -- | ||
33 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | With this conversion, we will be able to use the same helpers | 3 | Now that float_status has a bunch of fp parameters, |
4 | with sve. In particular, pass 3 vector parameters for the | 4 | it is easier to copy an existing structure than create |
5 | 3-operand operations; for advsimd the destination register | 5 | one from scratch. Begin by copying the structure that |
6 | is also an input. | 6 | corresponds to the FPSR and make only the adjustments |
7 | 7 | required for BFloat16 semantics. | |
8 | This also fixes a bug in which we failed to clear the high bits | ||
9 | of the SVE register after an AdvSIMD operation. | ||
10 | 8 | ||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
12 | Message-id: 20200514212831.31248-2-richard.henderson@linaro.org | 10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Message-id: 20241203203949.483774-2-richard.henderson@linaro.org | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 14 | --- |
16 | target/arm/helper.h | 6 ++-- | 15 | target/arm/tcg/vec_helper.c | 20 +++++++------------- |
17 | target/arm/vec_internal.h | 33 +++++++++++++++++ | 16 | 1 file changed, 7 insertions(+), 13 deletions(-) |
18 | target/arm/crypto_helper.c | 72 +++++++++++++++++++++++++++----------- | ||
19 | target/arm/translate-a64.c | 55 ++++++++++++++++++----------- | ||
20 | target/arm/translate.c | 27 +++++++------- | ||
21 | target/arm/vec_helper.c | 12 +------ | ||
22 | 6 files changed, 138 insertions(+), 67 deletions(-) | ||
23 | create mode 100644 target/arm/vec_internal.h | ||
24 | 17 | ||
25 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 18 | diff --git a/target/arm/tcg/vec_helper.c b/target/arm/tcg/vec_helper.c |
26 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/target/arm/helper.h | 20 | --- a/target/arm/tcg/vec_helper.c |
28 | +++ b/target/arm/helper.h | 21 | +++ b/target/arm/tcg/vec_helper.c |
29 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_2(neon_qzip8, TCG_CALL_NO_RWG, void, ptr, ptr) | 22 | @@ -XXX,XX +XXX,XX @@ bool is_ebf(CPUARMState *env, float_status *statusp, float_status *oddstatusp) |
30 | DEF_HELPER_FLAGS_2(neon_qzip16, TCG_CALL_NO_RWG, void, ptr, ptr) | 23 | * no effect on AArch32 instructions. |
31 | DEF_HELPER_FLAGS_2(neon_qzip32, TCG_CALL_NO_RWG, void, ptr, ptr) | 24 | */ |
32 | 25 | bool ebf = is_a64(env) && env->vfp.fpcr & FPCR_EBF; | |
33 | -DEF_HELPER_FLAGS_3(crypto_aese, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 26 | - *statusp = (float_status){ |
34 | +DEF_HELPER_FLAGS_4(crypto_aese, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 27 | - .tininess_before_rounding = float_tininess_before_rounding, |
35 | DEF_HELPER_FLAGS_3(crypto_aesmc, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 28 | - .float_rounding_mode = float_round_to_odd_inf, |
36 | 29 | - .flush_to_zero = true, | |
37 | DEF_HELPER_FLAGS_4(crypto_sha1_3reg, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 30 | - .flush_inputs_to_zero = true, |
38 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(crypto_sm3tt, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32, i32) | 31 | - .default_nan_mode = true, |
39 | DEF_HELPER_FLAGS_3(crypto_sm3partw1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 32 | - }; |
40 | DEF_HELPER_FLAGS_3(crypto_sm3partw2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | ||
41 | |||
42 | -DEF_HELPER_FLAGS_2(crypto_sm4e, TCG_CALL_NO_RWG, void, ptr, ptr) | ||
43 | -DEF_HELPER_FLAGS_3(crypto_sm4ekey, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | ||
44 | +DEF_HELPER_FLAGS_4(crypto_sm4e, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
45 | +DEF_HELPER_FLAGS_4(crypto_sm4ekey, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
46 | |||
47 | DEF_HELPER_FLAGS_3(crc32, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) | ||
48 | DEF_HELPER_FLAGS_3(crc32c, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) | ||
49 | diff --git a/target/arm/vec_internal.h b/target/arm/vec_internal.h | ||
50 | new file mode 100644 | ||
51 | index XXXXXXX..XXXXXXX | ||
52 | --- /dev/null | ||
53 | +++ b/target/arm/vec_internal.h | ||
54 | @@ -XXX,XX +XXX,XX @@ | ||
55 | +/* | ||
56 | + * ARM AdvSIMD / SVE Vector Helpers | ||
57 | + * | ||
58 | + * Copyright (c) 2020 Linaro | ||
59 | + * | ||
60 | + * This library is free software; you can redistribute it and/or | ||
61 | + * modify it under the terms of the GNU Lesser General Public | ||
62 | + * License as published by the Free Software Foundation; either | ||
63 | + * version 2 of the License, or (at your option) any later version. | ||
64 | + * | ||
65 | + * This library is distributed in the hope that it will be useful, | ||
66 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
67 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
68 | + * Lesser General Public License for more details. | ||
69 | + * | ||
70 | + * You should have received a copy of the GNU Lesser General Public | ||
71 | + * License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
72 | + */ | ||
73 | + | 33 | + |
74 | +#ifndef TARGET_ARM_VEC_INTERNALS_H | 34 | + *statusp = env->vfp.fp_status; |
75 | +#define TARGET_ARM_VEC_INTERNALS_H | 35 | + set_default_nan_mode(true, statusp); |
76 | + | 36 | |
77 | +static inline void clear_tail(void *vd, uintptr_t opr_sz, uintptr_t max_sz) | 37 | if (ebf) { |
78 | +{ | 38 | - float_status *fpst = &env->vfp.fp_status; |
79 | + uint64_t *d = vd + opr_sz; | 39 | - set_flush_to_zero(get_flush_to_zero(fpst), statusp); |
80 | + uintptr_t i; | 40 | - set_flush_inputs_to_zero(get_flush_inputs_to_zero(fpst), statusp); |
81 | + | 41 | - set_float_rounding_mode(get_float_rounding_mode(fpst), statusp); |
82 | + for (i = opr_sz; i < max_sz; i += 8) { | ||
83 | + *d++ = 0; | ||
84 | + } | ||
85 | +} | ||
86 | + | ||
87 | +#endif /* TARGET_ARM_VEC_INTERNALS_H */ | ||
88 | diff --git a/target/arm/crypto_helper.c b/target/arm/crypto_helper.c | ||
89 | index XXXXXXX..XXXXXXX 100644 | ||
90 | --- a/target/arm/crypto_helper.c | ||
91 | +++ b/target/arm/crypto_helper.c | ||
92 | @@ -XXX,XX +XXX,XX @@ | ||
93 | |||
94 | #include "cpu.h" | ||
95 | #include "exec/helper-proto.h" | ||
96 | +#include "tcg/tcg-gvec-desc.h" | ||
97 | #include "crypto/aes.h" | ||
98 | +#include "vec_internal.h" | ||
99 | |||
100 | union CRYPTO_STATE { | ||
101 | uint8_t bytes[16]; | ||
102 | @@ -XXX,XX +XXX,XX @@ union CRYPTO_STATE { | ||
103 | #define CR_ST_WORD(state, i) (state.words[i]) | ||
104 | #endif | ||
105 | |||
106 | -void HELPER(crypto_aese)(void *vd, void *vm, uint32_t decrypt) | ||
107 | +static void do_crypto_aese(uint64_t *rd, uint64_t *rn, | ||
108 | + uint64_t *rm, bool decrypt) | ||
109 | { | ||
110 | static uint8_t const * const sbox[2] = { AES_sbox, AES_isbox }; | ||
111 | static uint8_t const * const shift[2] = { AES_shifts, AES_ishifts }; | ||
112 | - uint64_t *rd = vd; | ||
113 | - uint64_t *rm = vm; | ||
114 | union CRYPTO_STATE rk = { .l = { rm[0], rm[1] } }; | ||
115 | - union CRYPTO_STATE st = { .l = { rd[0], rd[1] } }; | ||
116 | + union CRYPTO_STATE st = { .l = { rn[0], rn[1] } }; | ||
117 | int i; | ||
118 | |||
119 | - assert(decrypt < 2); | ||
120 | - | 42 | - |
121 | /* xor state vector with round key */ | 43 | /* EBF=1 needs to do a step with round-to-odd semantics */ |
122 | rk.l[0] ^= st.l[0]; | 44 | *oddstatusp = *statusp; |
123 | rk.l[1] ^= st.l[1]; | 45 | set_float_rounding_mode(float_round_to_odd, oddstatusp); |
124 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_aese)(void *vd, void *vm, uint32_t decrypt) | 46 | + } else { |
125 | rd[1] = st.l[1]; | 47 | + set_flush_to_zero(true, statusp); |
126 | } | 48 | + set_flush_inputs_to_zero(true, statusp); |
127 | 49 | + set_float_rounding_mode(float_round_to_odd_inf, statusp); | |
128 | -void HELPER(crypto_aesmc)(void *vd, void *vm, uint32_t decrypt) | ||
129 | +void HELPER(crypto_aese)(void *vd, void *vn, void *vm, uint32_t desc) | ||
130 | +{ | ||
131 | + intptr_t i, opr_sz = simd_oprsz(desc); | ||
132 | + bool decrypt = simd_data(desc); | ||
133 | + | ||
134 | + for (i = 0; i < opr_sz; i += 16) { | ||
135 | + do_crypto_aese(vd + i, vn + i, vm + i, decrypt); | ||
136 | + } | ||
137 | + clear_tail(vd, opr_sz, simd_maxsz(desc)); | ||
138 | +} | ||
139 | + | ||
140 | +static void do_crypto_aesmc(uint64_t *rd, uint64_t *rm, bool decrypt) | ||
141 | { | ||
142 | static uint32_t const mc[][256] = { { | ||
143 | /* MixColumns lookup table */ | ||
144 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_aesmc)(void *vd, void *vm, uint32_t decrypt) | ||
145 | 0xbe805d9f, 0xb58d5491, 0xa89a4f83, 0xa397468d, | ||
146 | } }; | ||
147 | |||
148 | - uint64_t *rd = vd; | ||
149 | - uint64_t *rm = vm; | ||
150 | union CRYPTO_STATE st = { .l = { rm[0], rm[1] } }; | ||
151 | int i; | ||
152 | |||
153 | - assert(decrypt < 2); | ||
154 | - | ||
155 | for (i = 0; i < 16; i += 4) { | ||
156 | CR_ST_WORD(st, i >> 2) = | ||
157 | mc[decrypt][CR_ST_BYTE(st, i)] ^ | ||
158 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_aesmc)(void *vd, void *vm, uint32_t decrypt) | ||
159 | rd[1] = st.l[1]; | ||
160 | } | ||
161 | |||
162 | +void HELPER(crypto_aesmc)(void *vd, void *vm, uint32_t desc) | ||
163 | +{ | ||
164 | + intptr_t i, opr_sz = simd_oprsz(desc); | ||
165 | + bool decrypt = simd_data(desc); | ||
166 | + | ||
167 | + for (i = 0; i < opr_sz; i += 16) { | ||
168 | + do_crypto_aesmc(vd + i, vm + i, decrypt); | ||
169 | + } | ||
170 | + clear_tail(vd, opr_sz, simd_maxsz(desc)); | ||
171 | +} | ||
172 | + | ||
173 | /* | ||
174 | * SHA-1 logical functions | ||
175 | */ | ||
176 | @@ -XXX,XX +XXX,XX @@ static uint8_t const sm4_sbox[] = { | ||
177 | 0x79, 0xee, 0x5f, 0x3e, 0xd7, 0xcb, 0x39, 0x48, | ||
178 | }; | ||
179 | |||
180 | -void HELPER(crypto_sm4e)(void *vd, void *vn) | ||
181 | +static void do_crypto_sm4e(uint64_t *rd, uint64_t *rn, uint64_t *rm) | ||
182 | { | ||
183 | - uint64_t *rd = vd; | ||
184 | - uint64_t *rn = vn; | ||
185 | - union CRYPTO_STATE d = { .l = { rd[0], rd[1] } }; | ||
186 | - union CRYPTO_STATE n = { .l = { rn[0], rn[1] } }; | ||
187 | + union CRYPTO_STATE d = { .l = { rn[0], rn[1] } }; | ||
188 | + union CRYPTO_STATE n = { .l = { rm[0], rm[1] } }; | ||
189 | uint32_t t, i; | ||
190 | |||
191 | for (i = 0; i < 4; i++) { | ||
192 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm4e)(void *vd, void *vn) | ||
193 | rd[1] = d.l[1]; | ||
194 | } | ||
195 | |||
196 | -void HELPER(crypto_sm4ekey)(void *vd, void *vn, void* vm) | ||
197 | +void HELPER(crypto_sm4e)(void *vd, void *vn, void *vm, uint32_t desc) | ||
198 | +{ | ||
199 | + intptr_t i, opr_sz = simd_oprsz(desc); | ||
200 | + | ||
201 | + for (i = 0; i < opr_sz; i += 16) { | ||
202 | + do_crypto_sm4e(vd + i, vn + i, vm + i); | ||
203 | + } | ||
204 | + clear_tail(vd, opr_sz, simd_maxsz(desc)); | ||
205 | +} | ||
206 | + | ||
207 | +static void do_crypto_sm4ekey(uint64_t *rd, uint64_t *rn, uint64_t *rm) | ||
208 | { | ||
209 | - uint64_t *rd = vd; | ||
210 | - uint64_t *rn = vn; | ||
211 | - uint64_t *rm = vm; | ||
212 | union CRYPTO_STATE d; | ||
213 | union CRYPTO_STATE n = { .l = { rn[0], rn[1] } }; | ||
214 | union CRYPTO_STATE m = { .l = { rm[0], rm[1] } }; | ||
215 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm4ekey)(void *vd, void *vn, void* vm) | ||
216 | rd[0] = d.l[0]; | ||
217 | rd[1] = d.l[1]; | ||
218 | } | ||
219 | + | ||
220 | +void HELPER(crypto_sm4ekey)(void *vd, void *vn, void* vm, uint32_t desc) | ||
221 | +{ | ||
222 | + intptr_t i, opr_sz = simd_oprsz(desc); | ||
223 | + | ||
224 | + for (i = 0; i < opr_sz; i += 16) { | ||
225 | + do_crypto_sm4ekey(vd + i, vn + i, vm + i); | ||
226 | + } | ||
227 | + clear_tail(vd, opr_sz, simd_maxsz(desc)); | ||
228 | +} | ||
229 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
230 | index XXXXXXX..XXXXXXX 100644 | ||
231 | --- a/target/arm/translate-a64.c | ||
232 | +++ b/target/arm/translate-a64.c | ||
233 | @@ -XXX,XX +XXX,XX @@ static void gen_gvec_fn4(DisasContext *s, bool is_q, int rd, int rn, int rm, | ||
234 | is_q ? 16 : 8, vec_full_reg_size(s)); | ||
235 | } | ||
236 | |||
237 | +/* Expand a 2-operand operation using an out-of-line helper. */ | ||
238 | +static void gen_gvec_op2_ool(DisasContext *s, bool is_q, int rd, | ||
239 | + int rn, int data, gen_helper_gvec_2 *fn) | ||
240 | +{ | ||
241 | + tcg_gen_gvec_2_ool(vec_full_reg_offset(s, rd), | ||
242 | + vec_full_reg_offset(s, rn), | ||
243 | + is_q ? 16 : 8, vec_full_reg_size(s), data, fn); | ||
244 | +} | ||
245 | + | ||
246 | /* Expand a 3-operand operation using an out-of-line helper. */ | ||
247 | static void gen_gvec_op3_ool(DisasContext *s, bool is_q, int rd, | ||
248 | int rn, int rm, int data, gen_helper_gvec_3 *fn) | ||
249 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_aes(DisasContext *s, uint32_t insn) | ||
250 | int rn = extract32(insn, 5, 5); | ||
251 | int rd = extract32(insn, 0, 5); | ||
252 | int decrypt; | ||
253 | - TCGv_ptr tcg_rd_ptr, tcg_rn_ptr; | ||
254 | - TCGv_i32 tcg_decrypt; | ||
255 | - CryptoThreeOpIntFn *genfn; | ||
256 | + gen_helper_gvec_2 *genfn2 = NULL; | ||
257 | + gen_helper_gvec_3 *genfn3 = NULL; | ||
258 | |||
259 | if (!dc_isar_feature(aa64_aes, s) || size != 0) { | ||
260 | unallocated_encoding(s); | ||
261 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_aes(DisasContext *s, uint32_t insn) | ||
262 | switch (opcode) { | ||
263 | case 0x4: /* AESE */ | ||
264 | decrypt = 0; | ||
265 | - genfn = gen_helper_crypto_aese; | ||
266 | + genfn3 = gen_helper_crypto_aese; | ||
267 | break; | ||
268 | case 0x6: /* AESMC */ | ||
269 | decrypt = 0; | ||
270 | - genfn = gen_helper_crypto_aesmc; | ||
271 | + genfn2 = gen_helper_crypto_aesmc; | ||
272 | break; | ||
273 | case 0x5: /* AESD */ | ||
274 | decrypt = 1; | ||
275 | - genfn = gen_helper_crypto_aese; | ||
276 | + genfn3 = gen_helper_crypto_aese; | ||
277 | break; | ||
278 | case 0x7: /* AESIMC */ | ||
279 | decrypt = 1; | ||
280 | - genfn = gen_helper_crypto_aesmc; | ||
281 | + genfn2 = gen_helper_crypto_aesmc; | ||
282 | break; | ||
283 | default: | ||
284 | unallocated_encoding(s); | ||
285 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_aes(DisasContext *s, uint32_t insn) | ||
286 | if (!fp_access_check(s)) { | ||
287 | return; | ||
288 | } | 50 | } |
289 | - | 51 | - |
290 | - tcg_rd_ptr = vec_full_reg_ptr(s, rd); | 52 | return ebf; |
291 | - tcg_rn_ptr = vec_full_reg_ptr(s, rn); | ||
292 | - tcg_decrypt = tcg_const_i32(decrypt); | ||
293 | - | ||
294 | - genfn(tcg_rd_ptr, tcg_rn_ptr, tcg_decrypt); | ||
295 | - | ||
296 | - tcg_temp_free_ptr(tcg_rd_ptr); | ||
297 | - tcg_temp_free_ptr(tcg_rn_ptr); | ||
298 | - tcg_temp_free_i32(tcg_decrypt); | ||
299 | + if (genfn2) { | ||
300 | + gen_gvec_op2_ool(s, true, rd, rn, decrypt, genfn2); | ||
301 | + } else { | ||
302 | + gen_gvec_op3_ool(s, true, rd, rd, rn, decrypt, genfn3); | ||
303 | + } | ||
304 | } | 53 | } |
305 | 54 | ||
306 | /* Crypto three-reg SHA | ||
307 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
308 | int rn = extract32(insn, 5, 5); | ||
309 | int rd = extract32(insn, 0, 5); | ||
310 | bool feature; | ||
311 | - CryptoThreeOpFn *genfn; | ||
312 | + CryptoThreeOpFn *genfn = NULL; | ||
313 | + gen_helper_gvec_3 *oolfn = NULL; | ||
314 | |||
315 | if (o == 0) { | ||
316 | switch (opcode) { | ||
317 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
318 | break; | ||
319 | case 2: /* SM4EKEY */ | ||
320 | feature = dc_isar_feature(aa64_sm4, s); | ||
321 | - genfn = gen_helper_crypto_sm4ekey; | ||
322 | + oolfn = gen_helper_crypto_sm4ekey; | ||
323 | break; | ||
324 | default: | ||
325 | unallocated_encoding(s); | ||
326 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
327 | return; | ||
328 | } | ||
329 | |||
330 | + if (oolfn) { | ||
331 | + gen_gvec_op3_ool(s, true, rd, rn, rm, 0, oolfn); | ||
332 | + return; | ||
333 | + } | ||
334 | + | ||
335 | if (genfn) { | ||
336 | TCGv_ptr tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr; | ||
337 | |||
338 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha512(DisasContext *s, uint32_t insn) | ||
339 | TCGv_ptr tcg_rd_ptr, tcg_rn_ptr; | ||
340 | bool feature; | ||
341 | CryptoTwoOpFn *genfn; | ||
342 | + gen_helper_gvec_3 *oolfn = NULL; | ||
343 | |||
344 | switch (opcode) { | ||
345 | case 0: /* SHA512SU0 */ | ||
346 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha512(DisasContext *s, uint32_t insn) | ||
347 | break; | ||
348 | case 1: /* SM4E */ | ||
349 | feature = dc_isar_feature(aa64_sm4, s); | ||
350 | - genfn = gen_helper_crypto_sm4e; | ||
351 | + oolfn = gen_helper_crypto_sm4e; | ||
352 | break; | ||
353 | default: | ||
354 | unallocated_encoding(s); | ||
355 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha512(DisasContext *s, uint32_t insn) | ||
356 | return; | ||
357 | } | ||
358 | |||
359 | + if (oolfn) { | ||
360 | + gen_gvec_op3_ool(s, true, rd, rd, rn, 0, oolfn); | ||
361 | + return; | ||
362 | + } | ||
363 | + | ||
364 | tcg_rd_ptr = vec_full_reg_ptr(s, rd); | ||
365 | tcg_rn_ptr = vec_full_reg_ptr(s, rn); | ||
366 | |||
367 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
368 | index XXXXXXX..XXXXXXX 100644 | ||
369 | --- a/target/arm/translate.c | ||
370 | +++ b/target/arm/translate.c | ||
371 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
372 | if (!dc_isar_feature(aa32_aes, s) || ((rm | rd) & 1)) { | ||
373 | return 1; | ||
374 | } | ||
375 | - ptr1 = vfp_reg_ptr(true, rd); | ||
376 | - ptr2 = vfp_reg_ptr(true, rm); | ||
377 | - | ||
378 | - /* Bit 6 is the lowest opcode bit; it distinguishes between | ||
379 | - * encryption (AESE/AESMC) and decryption (AESD/AESIMC) | ||
380 | - */ | ||
381 | - tmp3 = tcg_const_i32(extract32(insn, 6, 1)); | ||
382 | - | ||
383 | + /* | ||
384 | + * Bit 6 is the lowest opcode bit; it distinguishes | ||
385 | + * between encryption (AESE/AESMC) and decryption | ||
386 | + * (AESD/AESIMC). | ||
387 | + */ | ||
388 | if (op == NEON_2RM_AESE) { | ||
389 | - gen_helper_crypto_aese(ptr1, ptr2, tmp3); | ||
390 | + tcg_gen_gvec_3_ool(vfp_reg_offset(true, rd), | ||
391 | + vfp_reg_offset(true, rd), | ||
392 | + vfp_reg_offset(true, rm), | ||
393 | + 16, 16, extract32(insn, 6, 1), | ||
394 | + gen_helper_crypto_aese); | ||
395 | } else { | ||
396 | - gen_helper_crypto_aesmc(ptr1, ptr2, tmp3); | ||
397 | + tcg_gen_gvec_2_ool(vfp_reg_offset(true, rd), | ||
398 | + vfp_reg_offset(true, rm), | ||
399 | + 16, 16, extract32(insn, 6, 1), | ||
400 | + gen_helper_crypto_aesmc); | ||
401 | } | ||
402 | - tcg_temp_free_ptr(ptr1); | ||
403 | - tcg_temp_free_ptr(ptr2); | ||
404 | - tcg_temp_free_i32(tmp3); | ||
405 | break; | ||
406 | case NEON_2RM_SHA1H: | ||
407 | if (!dc_isar_feature(aa32_sha1, s) || ((rm | rd) & 1)) { | ||
408 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | ||
409 | index XXXXXXX..XXXXXXX 100644 | ||
410 | --- a/target/arm/vec_helper.c | ||
411 | +++ b/target/arm/vec_helper.c | ||
412 | @@ -XXX,XX +XXX,XX @@ | ||
413 | #include "exec/helper-proto.h" | ||
414 | #include "tcg/tcg-gvec-desc.h" | ||
415 | #include "fpu/softfloat.h" | ||
416 | - | ||
417 | +#include "vec_internal.h" | ||
418 | |||
419 | /* Note that vector data is stored in host-endian 64-bit chunks, | ||
420 | so addressing units smaller than that needs a host-endian fixup. */ | ||
421 | @@ -XXX,XX +XXX,XX @@ | ||
422 | #define H4(x) (x) | ||
423 | #endif | ||
424 | |||
425 | -static void clear_tail(void *vd, uintptr_t opr_sz, uintptr_t max_sz) | ||
426 | -{ | ||
427 | - uint64_t *d = vd + opr_sz; | ||
428 | - uintptr_t i; | ||
429 | - | ||
430 | - for (i = opr_sz; i < max_sz; i += 8) { | ||
431 | - *d++ = 0; | ||
432 | - } | ||
433 | -} | ||
434 | - | ||
435 | /* Signed saturating rounding doubling multiply-accumulate high half, 16-bit */ | ||
436 | static int16_t inl_qrdmlah_s16(int16_t src1, int16_t src2, | ||
437 | int16_t src3, uint32_t *sat) | ||
438 | -- | 55 | -- |
439 | 2.20.1 | 56 | 2.34.1 |
440 | 57 | ||
441 | 58 | diff view generated by jsdifflib |
1 | Convert the insns in the one-register-and-immediate group to decodetree. | 1 | Currently we hardcode the default NaN value in parts64_default_nan() |
---|---|---|---|
2 | using a compile-time ifdef ladder. This is awkward for two cases: | ||
3 | * for single-QEMU-binary we can't hard-code target-specifics like this | ||
4 | * for Arm FEAT_AFP the default NaN value depends on FPCR.AH | ||
5 | (specifically the sign bit is different) | ||
2 | 6 | ||
3 | In the new decode, our asimd_imm_const() function returns a 64-bit value | 7 | Add a field to float_status to specify the default NaN value; fall |
4 | rather than a 32-bit one, which means we don't need to treat cmode=14 op=1 | 8 | back to the old ifdef behaviour if these are not set. |
5 | as a special case in the decoder (it is the only encoding where the two | 9 | |
6 | halves of the 64-bit value are different). | 10 | The default NaN value is specified by setting a uint8_t to a |
11 | pattern corresponding to the sign and upper fraction parts of | ||
12 | the NaN; the lower bits of the fraction are set from bit 0 of | ||
13 | the pattern. | ||
7 | 14 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20200522145520.6778-10-peter.maydell@linaro.org | 17 | Message-id: 20241202131347.498124-35-peter.maydell@linaro.org |
11 | --- | 18 | --- |
12 | target/arm/neon-dp.decode | 22 ++++++ | 19 | include/fpu/softfloat-helpers.h | 11 +++++++ |
13 | target/arm/translate-neon.inc.c | 118 ++++++++++++++++++++++++++++++++ | 20 | include/fpu/softfloat-types.h | 10 ++++++ |
14 | target/arm/translate.c | 101 +-------------------------- | 21 | fpu/softfloat-specialize.c.inc | 55 ++++++++++++++++++++------------- |
15 | 3 files changed, 142 insertions(+), 99 deletions(-) | 22 | 3 files changed, 54 insertions(+), 22 deletions(-) |
16 | 23 | ||
17 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 24 | diff --git a/include/fpu/softfloat-helpers.h b/include/fpu/softfloat-helpers.h |
18 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/neon-dp.decode | 26 | --- a/include/fpu/softfloat-helpers.h |
20 | +++ b/target/arm/neon-dp.decode | 27 | +++ b/include/fpu/softfloat-helpers.h |
21 | @@ -XXX,XX +XXX,XX @@ VCVT_SF_2sh 1111 001 0 1 . ...... .... 1110 0 . . 1 .... @2reg_vcvt | 28 | @@ -XXX,XX +XXX,XX @@ static inline void set_float_infzeronan_rule(FloatInfZeroNaNRule rule, |
22 | VCVT_UF_2sh 1111 001 1 1 . ...... .... 1110 0 . . 1 .... @2reg_vcvt | 29 | status->float_infzeronan_rule = rule; |
23 | VCVT_FS_2sh 1111 001 0 1 . ...... .... 1111 0 . . 1 .... @2reg_vcvt | 30 | } |
24 | VCVT_FU_2sh 1111 001 1 1 . ...... .... 1111 0 . . 1 .... @2reg_vcvt | 31 | |
25 | + | 32 | +static inline void set_float_default_nan_pattern(uint8_t dnan_pattern, |
26 | +###################################################################### | 33 | + float_status *status) |
27 | +# 1-reg-and-modified-immediate grouping: | ||
28 | +# 1111 001 i 1 D 000 imm:3 Vd:4 cmode:4 0 Q op 1 Vm:4 | ||
29 | +###################################################################### | ||
30 | + | ||
31 | +&1reg_imm vd q imm cmode op | ||
32 | + | ||
33 | +%asimd_imm_value 24:1 16:3 0:4 | ||
34 | + | ||
35 | +@1reg_imm .... ... . . . ... ... .... .... . q:1 . . .... \ | ||
36 | + &1reg_imm imm=%asimd_imm_value vd=%vd_dp | ||
37 | + | ||
38 | +# The cmode/op bits here decode VORR/VBIC/VMOV/VMNV, but | ||
39 | +# not in a way we can conveniently represent in decodetree without | ||
40 | +# a lot of repetition: | ||
41 | +# VORR: op=0, (cmode & 1) && cmode < 12 | ||
42 | +# VBIC: op=1, (cmode & 1) && cmode < 12 | ||
43 | +# VMOV: everything else | ||
44 | +# So we have a single decode line and check the cmode/op in the | ||
45 | +# trans function. | ||
46 | +Vimm_1r 1111 001 . 1 . 000 ... .... cmode:4 0 . op:1 1 .... @1reg_imm | ||
47 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/target/arm/translate-neon.inc.c | ||
50 | +++ b/target/arm/translate-neon.inc.c | ||
51 | @@ -XXX,XX +XXX,XX @@ DO_FP_2SH(VCVT_SF, gen_helper_vfp_sltos) | ||
52 | DO_FP_2SH(VCVT_UF, gen_helper_vfp_ultos) | ||
53 | DO_FP_2SH(VCVT_FS, gen_helper_vfp_tosls_round_to_zero) | ||
54 | DO_FP_2SH(VCVT_FU, gen_helper_vfp_touls_round_to_zero) | ||
55 | + | ||
56 | +static uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) | ||
57 | +{ | 34 | +{ |
58 | + /* | 35 | + status->default_nan_pattern = dnan_pattern; |
59 | + * Expand the encoded constant. | ||
60 | + * Note that cmode = 2,3,4,5,6,7,10,11,12,13 imm=0 is UNPREDICTABLE. | ||
61 | + * We choose to not special-case this and will behave as if a | ||
62 | + * valid constant encoding of 0 had been given. | ||
63 | + * cmode = 15 op = 1 must UNDEF; we assume decode has handled that. | ||
64 | + */ | ||
65 | + switch (cmode) { | ||
66 | + case 0: case 1: | ||
67 | + /* no-op */ | ||
68 | + break; | ||
69 | + case 2: case 3: | ||
70 | + imm <<= 8; | ||
71 | + break; | ||
72 | + case 4: case 5: | ||
73 | + imm <<= 16; | ||
74 | + break; | ||
75 | + case 6: case 7: | ||
76 | + imm <<= 24; | ||
77 | + break; | ||
78 | + case 8: case 9: | ||
79 | + imm |= imm << 16; | ||
80 | + break; | ||
81 | + case 10: case 11: | ||
82 | + imm = (imm << 8) | (imm << 24); | ||
83 | + break; | ||
84 | + case 12: | ||
85 | + imm = (imm << 8) | 0xff; | ||
86 | + break; | ||
87 | + case 13: | ||
88 | + imm = (imm << 16) | 0xffff; | ||
89 | + break; | ||
90 | + case 14: | ||
91 | + if (op) { | ||
92 | + /* | ||
93 | + * This is the only case where the top and bottom 32 bits | ||
94 | + * of the encoded constant differ. | ||
95 | + */ | ||
96 | + uint64_t imm64 = 0; | ||
97 | + int n; | ||
98 | + | ||
99 | + for (n = 0; n < 8; n++) { | ||
100 | + if (imm & (1 << n)) { | ||
101 | + imm64 |= (0xffULL << (n * 8)); | ||
102 | + } | ||
103 | + } | ||
104 | + return imm64; | ||
105 | + } | ||
106 | + imm |= (imm << 8) | (imm << 16) | (imm << 24); | ||
107 | + break; | ||
108 | + case 15: | ||
109 | + imm = ((imm & 0x80) << 24) | ((imm & 0x3f) << 19) | ||
110 | + | ((imm & 0x40) ? (0x1f << 25) : (1 << 30)); | ||
111 | + break; | ||
112 | + } | ||
113 | + if (op) { | ||
114 | + imm = ~imm; | ||
115 | + } | ||
116 | + return dup_const(MO_32, imm); | ||
117 | +} | 36 | +} |
118 | + | 37 | + |
119 | +static bool do_1reg_imm(DisasContext *s, arg_1reg_imm *a, | 38 | static inline void set_flush_to_zero(bool val, float_status *status) |
120 | + GVecGen2iFn *fn) | 39 | { |
40 | status->flush_to_zero = val; | ||
41 | @@ -XXX,XX +XXX,XX @@ static inline FloatInfZeroNaNRule get_float_infzeronan_rule(float_status *status | ||
42 | return status->float_infzeronan_rule; | ||
43 | } | ||
44 | |||
45 | +static inline uint8_t get_float_default_nan_pattern(float_status *status) | ||
121 | +{ | 46 | +{ |
122 | + uint64_t imm; | 47 | + return status->default_nan_pattern; |
123 | + int reg_ofs, vec_size; | ||
124 | + | ||
125 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
126 | + return false; | ||
127 | + } | ||
128 | + | ||
129 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
130 | + if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) { | ||
131 | + return false; | ||
132 | + } | ||
133 | + | ||
134 | + if (a->vd & a->q) { | ||
135 | + return false; | ||
136 | + } | ||
137 | + | ||
138 | + if (!vfp_access_check(s)) { | ||
139 | + return true; | ||
140 | + } | ||
141 | + | ||
142 | + reg_ofs = neon_reg_offset(a->vd, 0); | ||
143 | + vec_size = a->q ? 16 : 8; | ||
144 | + imm = asimd_imm_const(a->imm, a->cmode, a->op); | ||
145 | + | ||
146 | + fn(MO_64, reg_ofs, reg_ofs, imm, vec_size, vec_size); | ||
147 | + return true; | ||
148 | +} | 48 | +} |
149 | + | 49 | + |
150 | +static void gen_VMOV_1r(unsigned vece, uint32_t dofs, uint32_t aofs, | 50 | static inline bool get_flush_to_zero(float_status *status) |
151 | + int64_t c, uint32_t oprsz, uint32_t maxsz) | 51 | { |
152 | +{ | 52 | return status->flush_to_zero; |
153 | + tcg_gen_gvec_dup_imm(MO_64, dofs, oprsz, maxsz, c); | 53 | diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h |
154 | +} | 54 | index XXXXXXX..XXXXXXX 100644 |
55 | --- a/include/fpu/softfloat-types.h | ||
56 | +++ b/include/fpu/softfloat-types.h | ||
57 | @@ -XXX,XX +XXX,XX @@ typedef struct float_status { | ||
58 | /* should denormalised inputs go to zero and set the input_denormal flag? */ | ||
59 | bool flush_inputs_to_zero; | ||
60 | bool default_nan_mode; | ||
61 | + /* | ||
62 | + * The pattern to use for the default NaN. Here the high bit specifies | ||
63 | + * the default NaN's sign bit, and bits 6..0 specify the high bits of the | ||
64 | + * fractional part. The low bits of the fractional part are copies of bit 0. | ||
65 | + * The exponent of the default NaN is (as for any NaN) always all 1s. | ||
66 | + * Note that a value of 0 here is not a valid NaN. The target must set | ||
67 | + * this to the correct non-zero value, or we will assert when trying to | ||
68 | + * create a default NaN. | ||
69 | + */ | ||
70 | + uint8_t default_nan_pattern; | ||
71 | /* | ||
72 | * The flags below are not used on all specializations and may | ||
73 | * constant fold away (see snan_bit_is_one()/no_signalling_nans() in | ||
74 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
75 | index XXXXXXX..XXXXXXX 100644 | ||
76 | --- a/fpu/softfloat-specialize.c.inc | ||
77 | +++ b/fpu/softfloat-specialize.c.inc | ||
78 | @@ -XXX,XX +XXX,XX @@ static void parts64_default_nan(FloatParts64 *p, float_status *status) | ||
79 | { | ||
80 | bool sign = 0; | ||
81 | uint64_t frac; | ||
82 | + uint8_t dnan_pattern = status->default_nan_pattern; | ||
83 | |||
84 | + if (dnan_pattern == 0) { | ||
85 | #if defined(TARGET_SPARC) || defined(TARGET_M68K) | ||
86 | - /* !snan_bit_is_one, set all bits */ | ||
87 | - frac = (1ULL << DECOMPOSED_BINARY_POINT) - 1; | ||
88 | -#elif defined(TARGET_I386) || defined(TARGET_X86_64) \ | ||
89 | + /* Sign bit clear, all frac bits set */ | ||
90 | + dnan_pattern = 0b01111111; | ||
91 | +#elif defined(TARGET_I386) || defined(TARGET_X86_64) \ | ||
92 | || defined(TARGET_MICROBLAZE) | ||
93 | - /* !snan_bit_is_one, set sign and msb */ | ||
94 | - frac = 1ULL << (DECOMPOSED_BINARY_POINT - 1); | ||
95 | - sign = 1; | ||
96 | + /* Sign bit set, most significant frac bit set */ | ||
97 | + dnan_pattern = 0b11000000; | ||
98 | #elif defined(TARGET_HPPA) | ||
99 | - /* snan_bit_is_one, set msb-1. */ | ||
100 | - frac = 1ULL << (DECOMPOSED_BINARY_POINT - 2); | ||
101 | + /* Sign bit clear, msb-1 frac bit set */ | ||
102 | + dnan_pattern = 0b00100000; | ||
103 | #elif defined(TARGET_HEXAGON) | ||
104 | - sign = 1; | ||
105 | - frac = ~0ULL; | ||
106 | + /* Sign bit set, all frac bits set. */ | ||
107 | + dnan_pattern = 0b11111111; | ||
108 | #else | ||
109 | - /* | ||
110 | - * This case is true for Alpha, ARM, MIPS, OpenRISC, PPC, RISC-V, | ||
111 | - * S390, SH4, TriCore, and Xtensa. Our other supported targets | ||
112 | - * do not have floating-point. | ||
113 | - */ | ||
114 | - if (snan_bit_is_one(status)) { | ||
115 | - /* set all bits other than msb */ | ||
116 | - frac = (1ULL << (DECOMPOSED_BINARY_POINT - 1)) - 1; | ||
117 | - } else { | ||
118 | - /* set msb */ | ||
119 | - frac = 1ULL << (DECOMPOSED_BINARY_POINT - 1); | ||
120 | - } | ||
121 | + /* | ||
122 | + * This case is true for Alpha, ARM, MIPS, OpenRISC, PPC, RISC-V, | ||
123 | + * S390, SH4, TriCore, and Xtensa. Our other supported targets | ||
124 | + * do not have floating-point. | ||
125 | + */ | ||
126 | + if (snan_bit_is_one(status)) { | ||
127 | + /* sign bit clear, set all frac bits other than msb */ | ||
128 | + dnan_pattern = 0b00111111; | ||
129 | + } else { | ||
130 | + /* sign bit clear, set frac msb */ | ||
131 | + dnan_pattern = 0b01000000; | ||
132 | + } | ||
133 | #endif | ||
134 | + } | ||
135 | + assert(dnan_pattern != 0); | ||
155 | + | 136 | + |
156 | +static bool trans_Vimm_1r(DisasContext *s, arg_1reg_imm *a) | 137 | + sign = dnan_pattern >> 7; |
157 | +{ | 138 | + /* |
158 | + /* Handle decode of cmode/op here between VORR/VBIC/VMOV */ | 139 | + * Place default_nan_pattern [6:0] into bits [62:56], |
159 | + GVecGen2iFn *fn; | 140 | + * and replecate bit [0] down into [55:0] |
160 | + | 141 | + */ |
161 | + if ((a->cmode & 1) && a->cmode < 12) { | 142 | + frac = deposit64(0, DECOMPOSED_BINARY_POINT - 7, 7, dnan_pattern); |
162 | + /* for op=1, the imm will be inverted, so BIC becomes AND. */ | 143 | + frac = deposit64(frac, 0, DECOMPOSED_BINARY_POINT - 7, -(dnan_pattern & 1)); |
163 | + fn = a->op ? tcg_gen_gvec_andi : tcg_gen_gvec_ori; | 144 | |
164 | + } else { | 145 | *p = (FloatParts64) { |
165 | + /* There is one unallocated cmode/op combination in this space */ | 146 | .cls = float_class_qnan, |
166 | + if (a->cmode == 15 && a->op == 1) { | ||
167 | + return false; | ||
168 | + } | ||
169 | + fn = gen_VMOV_1r; | ||
170 | + } | ||
171 | + return do_1reg_imm(s, a, fn); | ||
172 | +} | ||
173 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
174 | index XXXXXXX..XXXXXXX 100644 | ||
175 | --- a/target/arm/translate.c | ||
176 | +++ b/target/arm/translate.c | ||
177 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
178 | /* Three register same length: handled by decodetree */ | ||
179 | return 1; | ||
180 | } else if (insn & (1 << 4)) { | ||
181 | - if ((insn & 0x00380080) != 0) { | ||
182 | - /* Two registers and shift: handled by decodetree */ | ||
183 | - return 1; | ||
184 | - } else { /* (insn & 0x00380080) == 0 */ | ||
185 | - int invert, reg_ofs, vec_size; | ||
186 | - | ||
187 | - if (q && (rd & 1)) { | ||
188 | - return 1; | ||
189 | - } | ||
190 | - | ||
191 | - op = (insn >> 8) & 0xf; | ||
192 | - /* One register and immediate. */ | ||
193 | - imm = (u << 7) | ((insn >> 12) & 0x70) | (insn & 0xf); | ||
194 | - invert = (insn & (1 << 5)) != 0; | ||
195 | - /* Note that op = 2,3,4,5,6,7,10,11,12,13 imm=0 is UNPREDICTABLE. | ||
196 | - * We choose to not special-case this and will behave as if a | ||
197 | - * valid constant encoding of 0 had been given. | ||
198 | - */ | ||
199 | - switch (op) { | ||
200 | - case 0: case 1: | ||
201 | - /* no-op */ | ||
202 | - break; | ||
203 | - case 2: case 3: | ||
204 | - imm <<= 8; | ||
205 | - break; | ||
206 | - case 4: case 5: | ||
207 | - imm <<= 16; | ||
208 | - break; | ||
209 | - case 6: case 7: | ||
210 | - imm <<= 24; | ||
211 | - break; | ||
212 | - case 8: case 9: | ||
213 | - imm |= imm << 16; | ||
214 | - break; | ||
215 | - case 10: case 11: | ||
216 | - imm = (imm << 8) | (imm << 24); | ||
217 | - break; | ||
218 | - case 12: | ||
219 | - imm = (imm << 8) | 0xff; | ||
220 | - break; | ||
221 | - case 13: | ||
222 | - imm = (imm << 16) | 0xffff; | ||
223 | - break; | ||
224 | - case 14: | ||
225 | - imm |= (imm << 8) | (imm << 16) | (imm << 24); | ||
226 | - if (invert) { | ||
227 | - imm = ~imm; | ||
228 | - } | ||
229 | - break; | ||
230 | - case 15: | ||
231 | - if (invert) { | ||
232 | - return 1; | ||
233 | - } | ||
234 | - imm = ((imm & 0x80) << 24) | ((imm & 0x3f) << 19) | ||
235 | - | ((imm & 0x40) ? (0x1f << 25) : (1 << 30)); | ||
236 | - break; | ||
237 | - } | ||
238 | - if (invert) { | ||
239 | - imm = ~imm; | ||
240 | - } | ||
241 | - | ||
242 | - reg_ofs = neon_reg_offset(rd, 0); | ||
243 | - vec_size = q ? 16 : 8; | ||
244 | - | ||
245 | - if (op & 1 && op < 12) { | ||
246 | - if (invert) { | ||
247 | - /* The immediate value has already been inverted, | ||
248 | - * so BIC becomes AND. | ||
249 | - */ | ||
250 | - tcg_gen_gvec_andi(MO_32, reg_ofs, reg_ofs, imm, | ||
251 | - vec_size, vec_size); | ||
252 | - } else { | ||
253 | - tcg_gen_gvec_ori(MO_32, reg_ofs, reg_ofs, imm, | ||
254 | - vec_size, vec_size); | ||
255 | - } | ||
256 | - } else { | ||
257 | - /* VMOV, VMVN. */ | ||
258 | - if (op == 14 && invert) { | ||
259 | - TCGv_i64 t64 = tcg_temp_new_i64(); | ||
260 | - | ||
261 | - for (pass = 0; pass <= q; ++pass) { | ||
262 | - uint64_t val = 0; | ||
263 | - int n; | ||
264 | - | ||
265 | - for (n = 0; n < 8; n++) { | ||
266 | - if (imm & (1 << (n + pass * 8))) { | ||
267 | - val |= 0xffull << (n * 8); | ||
268 | - } | ||
269 | - } | ||
270 | - tcg_gen_movi_i64(t64, val); | ||
271 | - neon_store_reg64(t64, rd + pass); | ||
272 | - } | ||
273 | - tcg_temp_free_i64(t64); | ||
274 | - } else { | ||
275 | - tcg_gen_gvec_dup_imm(MO_32, reg_ofs, vec_size, | ||
276 | - vec_size, imm); | ||
277 | - } | ||
278 | - } | ||
279 | - } | ||
280 | + /* Two registers and shift or reg and imm: handled by decodetree */ | ||
281 | + return 1; | ||
282 | } else { /* (insn & 0x00800010 == 0x00800000) */ | ||
283 | if (size != 3) { | ||
284 | op = (insn >> 8) & 0xf; | ||
285 | -- | 147 | -- |
286 | 2.20.1 | 148 | 2.34.1 |
287 | |||
288 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the default NaN pattern explicitly for the tests/fp code. | ||
1 | 2 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20241202131347.498124-36-peter.maydell@linaro.org | ||
6 | --- | ||
7 | tests/fp/fp-bench.c | 1 + | ||
8 | tests/fp/fp-test-log2.c | 1 + | ||
9 | tests/fp/fp-test.c | 1 + | ||
10 | 3 files changed, 3 insertions(+) | ||
11 | |||
12 | diff --git a/tests/fp/fp-bench.c b/tests/fp/fp-bench.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/tests/fp/fp-bench.c | ||
15 | +++ b/tests/fp/fp-bench.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static void run_bench(void) | ||
17 | set_float_2nan_prop_rule(float_2nan_prop_s_ab, &soft_status); | ||
18 | set_float_3nan_prop_rule(float_3nan_prop_s_cab, &soft_status); | ||
19 | set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, &soft_status); | ||
20 | + set_float_default_nan_pattern(0b01000000, &soft_status); | ||
21 | |||
22 | f = bench_funcs[operation][precision]; | ||
23 | g_assert(f); | ||
24 | diff --git a/tests/fp/fp-test-log2.c b/tests/fp/fp-test-log2.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/tests/fp/fp-test-log2.c | ||
27 | +++ b/tests/fp/fp-test-log2.c | ||
28 | @@ -XXX,XX +XXX,XX @@ int main(int ac, char **av) | ||
29 | int i; | ||
30 | |||
31 | set_float_2nan_prop_rule(float_2nan_prop_s_ab, &qsf); | ||
32 | + set_float_default_nan_pattern(0b01000000, &qsf); | ||
33 | set_float_rounding_mode(float_round_nearest_even, &qsf); | ||
34 | |||
35 | test.d = 0.0; | ||
36 | diff --git a/tests/fp/fp-test.c b/tests/fp/fp-test.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/tests/fp/fp-test.c | ||
39 | +++ b/tests/fp/fp-test.c | ||
40 | @@ -XXX,XX +XXX,XX @@ void run_test(void) | ||
41 | */ | ||
42 | set_float_2nan_prop_rule(float_2nan_prop_s_ab, &qsf); | ||
43 | set_float_3nan_prop_rule(float_3nan_prop_s_cab, &qsf); | ||
44 | + set_float_default_nan_pattern(0b01000000, &qsf); | ||
45 | set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, &qsf); | ||
46 | |||
47 | genCases_setLevel(test_level); | ||
48 | -- | ||
49 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the default NaN pattern explicitly, and remove the ifdef from | ||
2 | parts64_default_nan(). | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20241202131347.498124-37-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/microblaze/cpu.c | 2 ++ | ||
9 | fpu/softfloat-specialize.c.inc | 3 +-- | ||
10 | 2 files changed, 3 insertions(+), 2 deletions(-) | ||
11 | |||
12 | diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/microblaze/cpu.c | ||
15 | +++ b/target/microblaze/cpu.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static void mb_cpu_reset_hold(Object *obj, ResetType type) | ||
17 | * this architecture. | ||
18 | */ | ||
19 | set_float_2nan_prop_rule(float_2nan_prop_x87, &env->fp_status); | ||
20 | + /* Default NaN: sign bit set, most significant frac bit set */ | ||
21 | + set_float_default_nan_pattern(0b11000000, &env->fp_status); | ||
22 | |||
23 | #if defined(CONFIG_USER_ONLY) | ||
24 | /* start in user mode with interrupts enabled. */ | ||
25 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/fpu/softfloat-specialize.c.inc | ||
28 | +++ b/fpu/softfloat-specialize.c.inc | ||
29 | @@ -XXX,XX +XXX,XX @@ static void parts64_default_nan(FloatParts64 *p, float_status *status) | ||
30 | #if defined(TARGET_SPARC) || defined(TARGET_M68K) | ||
31 | /* Sign bit clear, all frac bits set */ | ||
32 | dnan_pattern = 0b01111111; | ||
33 | -#elif defined(TARGET_I386) || defined(TARGET_X86_64) \ | ||
34 | - || defined(TARGET_MICROBLAZE) | ||
35 | +#elif defined(TARGET_I386) || defined(TARGET_X86_64) | ||
36 | /* Sign bit set, most significant frac bit set */ | ||
37 | dnan_pattern = 0b11000000; | ||
38 | #elif defined(TARGET_HPPA) | ||
39 | -- | ||
40 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the default NaN pattern explicitly, and remove the ifdef from | ||
2 | parts64_default_nan(). | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20241202131347.498124-38-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/i386/tcg/fpu_helper.c | 4 ++++ | ||
9 | fpu/softfloat-specialize.c.inc | 3 --- | ||
10 | 2 files changed, 4 insertions(+), 3 deletions(-) | ||
11 | |||
12 | diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/i386/tcg/fpu_helper.c | ||
15 | +++ b/target/i386/tcg/fpu_helper.c | ||
16 | @@ -XXX,XX +XXX,XX @@ void cpu_init_fp_statuses(CPUX86State *env) | ||
17 | */ | ||
18 | set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->sse_status); | ||
19 | set_float_3nan_prop_rule(float_3nan_prop_abc, &env->sse_status); | ||
20 | + /* Default NaN: sign bit set, most significant frac bit set */ | ||
21 | + set_float_default_nan_pattern(0b11000000, &env->fp_status); | ||
22 | + set_float_default_nan_pattern(0b11000000, &env->mmx_status); | ||
23 | + set_float_default_nan_pattern(0b11000000, &env->sse_status); | ||
24 | } | ||
25 | |||
26 | static inline uint8_t save_exception_flags(CPUX86State *env) | ||
27 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/fpu/softfloat-specialize.c.inc | ||
30 | +++ b/fpu/softfloat-specialize.c.inc | ||
31 | @@ -XXX,XX +XXX,XX @@ static void parts64_default_nan(FloatParts64 *p, float_status *status) | ||
32 | #if defined(TARGET_SPARC) || defined(TARGET_M68K) | ||
33 | /* Sign bit clear, all frac bits set */ | ||
34 | dnan_pattern = 0b01111111; | ||
35 | -#elif defined(TARGET_I386) || defined(TARGET_X86_64) | ||
36 | - /* Sign bit set, most significant frac bit set */ | ||
37 | - dnan_pattern = 0b11000000; | ||
38 | #elif defined(TARGET_HPPA) | ||
39 | /* Sign bit clear, msb-1 frac bit set */ | ||
40 | dnan_pattern = 0b00100000; | ||
41 | -- | ||
42 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the default NaN pattern explicitly, and remove the ifdef from | ||
2 | parts64_default_nan(). | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20241202131347.498124-39-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/hppa/fpu_helper.c | 2 ++ | ||
9 | fpu/softfloat-specialize.c.inc | 3 --- | ||
10 | 2 files changed, 2 insertions(+), 3 deletions(-) | ||
11 | |||
12 | diff --git a/target/hppa/fpu_helper.c b/target/hppa/fpu_helper.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/hppa/fpu_helper.c | ||
15 | +++ b/target/hppa/fpu_helper.c | ||
16 | @@ -XXX,XX +XXX,XX @@ void HELPER(loaded_fr0)(CPUHPPAState *env) | ||
17 | set_float_3nan_prop_rule(float_3nan_prop_abc, &env->fp_status); | ||
18 | /* For inf * 0 + NaN, return the input NaN */ | ||
19 | set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status); | ||
20 | + /* Default NaN: sign bit clear, msb-1 frac bit set */ | ||
21 | + set_float_default_nan_pattern(0b00100000, &env->fp_status); | ||
22 | } | ||
23 | |||
24 | void cpu_hppa_loaded_fr0(CPUHPPAState *env) | ||
25 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/fpu/softfloat-specialize.c.inc | ||
28 | +++ b/fpu/softfloat-specialize.c.inc | ||
29 | @@ -XXX,XX +XXX,XX @@ static void parts64_default_nan(FloatParts64 *p, float_status *status) | ||
30 | #if defined(TARGET_SPARC) || defined(TARGET_M68K) | ||
31 | /* Sign bit clear, all frac bits set */ | ||
32 | dnan_pattern = 0b01111111; | ||
33 | -#elif defined(TARGET_HPPA) | ||
34 | - /* Sign bit clear, msb-1 frac bit set */ | ||
35 | - dnan_pattern = 0b00100000; | ||
36 | #elif defined(TARGET_HEXAGON) | ||
37 | /* Sign bit set, all frac bits set. */ | ||
38 | dnan_pattern = 0b11111111; | ||
39 | -- | ||
40 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the default NaN pattern explicitly for the alpha target. | ||
1 | 2 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20241202131347.498124-40-peter.maydell@linaro.org | ||
6 | --- | ||
7 | target/alpha/cpu.c | 2 ++ | ||
8 | 1 file changed, 2 insertions(+) | ||
9 | |||
10 | diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/target/alpha/cpu.c | ||
13 | +++ b/target/alpha/cpu.c | ||
14 | @@ -XXX,XX +XXX,XX @@ static void alpha_cpu_initfn(Object *obj) | ||
15 | * operand in Fa. That is float_2nan_prop_ba. | ||
16 | */ | ||
17 | set_float_2nan_prop_rule(float_2nan_prop_x87, &env->fp_status); | ||
18 | + /* Default NaN: sign bit clear, msb frac bit set */ | ||
19 | + set_float_default_nan_pattern(0b01000000, &env->fp_status); | ||
20 | #if defined(CONFIG_USER_ONLY) | ||
21 | env->flags = ENV_FLAG_PS_USER | ENV_FLAG_FEN; | ||
22 | cpu_alpha_store_fpcr(env, (uint64_t)(FPCR_INVD | FPCR_DZED | FPCR_OVFD | ||
23 | -- | ||
24 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the default NaN pattern explicitly for the arm target. | ||
2 | This includes setting it for the old linux-user nwfpe emulation. | ||
3 | For nwfpe, our default doesn't match the real kernel, but we | ||
4 | avoid making a behaviour change in this commit. | ||
1 | 5 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20241202131347.498124-41-peter.maydell@linaro.org | ||
9 | --- | ||
10 | linux-user/arm/nwfpe/fpa11.c | 5 +++++ | ||
11 | target/arm/cpu.c | 2 ++ | ||
12 | 2 files changed, 7 insertions(+) | ||
13 | |||
14 | diff --git a/linux-user/arm/nwfpe/fpa11.c b/linux-user/arm/nwfpe/fpa11.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/linux-user/arm/nwfpe/fpa11.c | ||
17 | +++ b/linux-user/arm/nwfpe/fpa11.c | ||
18 | @@ -XXX,XX +XXX,XX @@ void resetFPA11(void) | ||
19 | * this late date. | ||
20 | */ | ||
21 | set_float_2nan_prop_rule(float_2nan_prop_s_ab, &fpa11->fp_status); | ||
22 | + /* | ||
23 | + * Use the same default NaN value as Arm VFP. This doesn't match | ||
24 | + * the Linux kernel's nwfpe emulation, which uses an all-1s value. | ||
25 | + */ | ||
26 | + set_float_default_nan_pattern(0b01000000, &fpa11->fp_status); | ||
27 | } | ||
28 | |||
29 | void SetRoundingMode(const unsigned int opcode) | ||
30 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/cpu.c | ||
33 | +++ b/target/arm/cpu.c | ||
34 | @@ -XXX,XX +XXX,XX @@ void arm_register_el_change_hook(ARMCPU *cpu, ARMELChangeHookFn *hook, | ||
35 | * the pseudocode function the arguments are in the order c, a, b. | ||
36 | * * 0 * Inf + NaN returns the default NaN if the input NaN is quiet, | ||
37 | * and the input NaN if it is signalling | ||
38 | + * * Default NaN has sign bit clear, msb frac bit set | ||
39 | */ | ||
40 | static void arm_set_default_fp_behaviours(float_status *s) | ||
41 | { | ||
42 | @@ -XXX,XX +XXX,XX @@ static void arm_set_default_fp_behaviours(float_status *s) | ||
43 | set_float_2nan_prop_rule(float_2nan_prop_s_ab, s); | ||
44 | set_float_3nan_prop_rule(float_3nan_prop_s_cab, s); | ||
45 | set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, s); | ||
46 | + set_float_default_nan_pattern(0b01000000, s); | ||
47 | } | ||
48 | |||
49 | static void cp_reg_reset(gpointer key, gpointer value, gpointer opaque) | ||
50 | -- | ||
51 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the default NaN pattern explicitly for loongarch. | ||
1 | 2 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20241202131347.498124-42-peter.maydell@linaro.org | ||
6 | --- | ||
7 | target/loongarch/tcg/fpu_helper.c | 2 ++ | ||
8 | 1 file changed, 2 insertions(+) | ||
9 | |||
10 | diff --git a/target/loongarch/tcg/fpu_helper.c b/target/loongarch/tcg/fpu_helper.c | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/target/loongarch/tcg/fpu_helper.c | ||
13 | +++ b/target/loongarch/tcg/fpu_helper.c | ||
14 | @@ -XXX,XX +XXX,XX @@ void restore_fp_status(CPULoongArchState *env) | ||
15 | */ | ||
16 | set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status); | ||
17 | set_float_3nan_prop_rule(float_3nan_prop_s_cab, &env->fp_status); | ||
18 | + /* Default NaN: sign bit clear, msb frac bit set */ | ||
19 | + set_float_default_nan_pattern(0b01000000, &env->fp_status); | ||
20 | } | ||
21 | |||
22 | int ieee_ex_to_loongarch(int xcpt) | ||
23 | -- | ||
24 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the default NaN pattern explicitly for m68k. | ||
1 | 2 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20241202131347.498124-43-peter.maydell@linaro.org | ||
6 | --- | ||
7 | target/m68k/cpu.c | 2 ++ | ||
8 | fpu/softfloat-specialize.c.inc | 2 +- | ||
9 | 2 files changed, 3 insertions(+), 1 deletion(-) | ||
10 | |||
11 | diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/target/m68k/cpu.c | ||
14 | +++ b/target/m68k/cpu.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static void m68k_cpu_reset_hold(Object *obj, ResetType type) | ||
16 | * preceding paragraph for nonsignaling NaNs. | ||
17 | */ | ||
18 | set_float_2nan_prop_rule(float_2nan_prop_ab, &env->fp_status); | ||
19 | + /* Default NaN: sign bit clear, all frac bits set */ | ||
20 | + set_float_default_nan_pattern(0b01111111, &env->fp_status); | ||
21 | |||
22 | nan = floatx80_default_nan(&env->fp_status); | ||
23 | for (i = 0; i < 8; i++) { | ||
24 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/fpu/softfloat-specialize.c.inc | ||
27 | +++ b/fpu/softfloat-specialize.c.inc | ||
28 | @@ -XXX,XX +XXX,XX @@ static void parts64_default_nan(FloatParts64 *p, float_status *status) | ||
29 | uint8_t dnan_pattern = status->default_nan_pattern; | ||
30 | |||
31 | if (dnan_pattern == 0) { | ||
32 | -#if defined(TARGET_SPARC) || defined(TARGET_M68K) | ||
33 | +#if defined(TARGET_SPARC) | ||
34 | /* Sign bit clear, all frac bits set */ | ||
35 | dnan_pattern = 0b01111111; | ||
36 | #elif defined(TARGET_HEXAGON) | ||
37 | -- | ||
38 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the default NaN pattern explicitly for MIPS. Note that this | ||
2 | is our only target which currently changes the default NaN | ||
3 | at runtime (which it was previously doing indirectly when it | ||
4 | changed the snan_bit_is_one setting). | ||
1 | 5 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20241202131347.498124-44-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/mips/fpu_helper.h | 7 +++++++ | ||
11 | target/mips/msa.c | 3 +++ | ||
12 | 2 files changed, 10 insertions(+) | ||
13 | |||
14 | diff --git a/target/mips/fpu_helper.h b/target/mips/fpu_helper.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/mips/fpu_helper.h | ||
17 | +++ b/target/mips/fpu_helper.h | ||
18 | @@ -XXX,XX +XXX,XX @@ static inline void restore_snan_bit_mode(CPUMIPSState *env) | ||
19 | set_float_infzeronan_rule(izn_rule, &env->active_fpu.fp_status); | ||
20 | nan3_rule = nan2008 ? float_3nan_prop_s_cab : float_3nan_prop_s_abc; | ||
21 | set_float_3nan_prop_rule(nan3_rule, &env->active_fpu.fp_status); | ||
22 | + /* | ||
23 | + * With nan2008, the default NaN value has the sign bit clear and the | ||
24 | + * frac msb set; with the older mode, the sign bit is clear, and all | ||
25 | + * frac bits except the msb are set. | ||
26 | + */ | ||
27 | + set_float_default_nan_pattern(nan2008 ? 0b01000000 : 0b00111111, | ||
28 | + &env->active_fpu.fp_status); | ||
29 | |||
30 | } | ||
31 | |||
32 | diff --git a/target/mips/msa.c b/target/mips/msa.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/target/mips/msa.c | ||
35 | +++ b/target/mips/msa.c | ||
36 | @@ -XXX,XX +XXX,XX @@ void msa_reset(CPUMIPSState *env) | ||
37 | /* Inf * 0 + NaN returns the input NaN */ | ||
38 | set_float_infzeronan_rule(float_infzeronan_dnan_never, | ||
39 | &env->active_tc.msa_fp_status); | ||
40 | + /* Default NaN: sign bit clear, frac msb set */ | ||
41 | + set_float_default_nan_pattern(0b01000000, | ||
42 | + &env->active_tc.msa_fp_status); | ||
43 | } | ||
44 | -- | ||
45 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the default NaN pattern explicitly for openrisc. | ||
1 | 2 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20241202131347.498124-45-peter.maydell@linaro.org | ||
6 | --- | ||
7 | target/openrisc/cpu.c | 2 ++ | ||
8 | 1 file changed, 2 insertions(+) | ||
9 | |||
10 | diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/target/openrisc/cpu.c | ||
13 | +++ b/target/openrisc/cpu.c | ||
14 | @@ -XXX,XX +XXX,XX @@ static void openrisc_cpu_reset_hold(Object *obj, ResetType type) | ||
15 | */ | ||
16 | set_float_2nan_prop_rule(float_2nan_prop_x87, &cpu->env.fp_status); | ||
17 | |||
18 | + /* Default NaN: sign bit clear, frac msb set */ | ||
19 | + set_float_default_nan_pattern(0b01000000, &cpu->env.fp_status); | ||
20 | |||
21 | #ifndef CONFIG_USER_ONLY | ||
22 | cpu->env.picmr = 0x00000000; | ||
23 | -- | ||
24 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the default NaN pattern explicitly for ppc. | ||
1 | 2 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20241202131347.498124-46-peter.maydell@linaro.org | ||
6 | --- | ||
7 | target/ppc/cpu_init.c | 4 ++++ | ||
8 | 1 file changed, 4 insertions(+) | ||
9 | |||
10 | diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/target/ppc/cpu_init.c | ||
13 | +++ b/target/ppc/cpu_init.c | ||
14 | @@ -XXX,XX +XXX,XX @@ static void ppc_cpu_reset_hold(Object *obj, ResetType type) | ||
15 | set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status); | ||
16 | set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->vec_status); | ||
17 | |||
18 | + /* Default NaN: sign bit clear, set frac msb */ | ||
19 | + set_float_default_nan_pattern(0b01000000, &env->fp_status); | ||
20 | + set_float_default_nan_pattern(0b01000000, &env->vec_status); | ||
21 | + | ||
22 | for (i = 0; i < ARRAY_SIZE(env->spr_cb); i++) { | ||
23 | ppc_spr_t *spr = &env->spr_cb[i]; | ||
24 | |||
25 | -- | ||
26 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the default NaN pattern explicitly for sh4. Note that sh4 | ||
2 | is one of the only three targets (the others being HPPA and | ||
3 | sometimes MIPS) that has snan_bit_is_one set. | ||
1 | 4 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20241202131347.498124-47-peter.maydell@linaro.org | ||
8 | --- | ||
9 | target/sh4/cpu.c | 2 ++ | ||
10 | 1 file changed, 2 insertions(+) | ||
11 | |||
12 | diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/sh4/cpu.c | ||
15 | +++ b/target/sh4/cpu.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static void superh_cpu_reset_hold(Object *obj, ResetType type) | ||
17 | set_flush_to_zero(1, &env->fp_status); | ||
18 | #endif | ||
19 | set_default_nan_mode(1, &env->fp_status); | ||
20 | + /* sign bit clear, set all frac bits other than msb */ | ||
21 | + set_float_default_nan_pattern(0b00111111, &env->fp_status); | ||
22 | } | ||
23 | |||
24 | static void superh_cpu_disas_set_info(CPUState *cpu, disassemble_info *info) | ||
25 | -- | ||
26 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the default NaN pattern explicitly for rx. | ||
1 | 2 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20241202131347.498124-48-peter.maydell@linaro.org | ||
6 | --- | ||
7 | target/rx/cpu.c | 2 ++ | ||
8 | 1 file changed, 2 insertions(+) | ||
9 | |||
10 | diff --git a/target/rx/cpu.c b/target/rx/cpu.c | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/target/rx/cpu.c | ||
13 | +++ b/target/rx/cpu.c | ||
14 | @@ -XXX,XX +XXX,XX @@ static void rx_cpu_reset_hold(Object *obj, ResetType type) | ||
15 | * then prefer dest over source", which is float_2nan_prop_s_ab. | ||
16 | */ | ||
17 | set_float_2nan_prop_rule(float_2nan_prop_x87, &env->fp_status); | ||
18 | + /* Default NaN value: sign bit clear, set frac msb */ | ||
19 | + set_float_default_nan_pattern(0b01000000, &env->fp_status); | ||
20 | } | ||
21 | |||
22 | static ObjectClass *rx_cpu_class_by_name(const char *cpu_model) | ||
23 | -- | ||
24 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the default NaN pattern explicitly for s390x. | ||
1 | 2 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20241202131347.498124-49-peter.maydell@linaro.org | ||
6 | --- | ||
7 | target/s390x/cpu.c | 2 ++ | ||
8 | 1 file changed, 2 insertions(+) | ||
9 | |||
10 | diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/target/s390x/cpu.c | ||
13 | +++ b/target/s390x/cpu.c | ||
14 | @@ -XXX,XX +XXX,XX @@ static void s390_cpu_reset_hold(Object *obj, ResetType type) | ||
15 | set_float_3nan_prop_rule(float_3nan_prop_s_abc, &env->fpu_status); | ||
16 | set_float_infzeronan_rule(float_infzeronan_dnan_always, | ||
17 | &env->fpu_status); | ||
18 | + /* Default NaN value: sign bit clear, frac msb set */ | ||
19 | + set_float_default_nan_pattern(0b01000000, &env->fpu_status); | ||
20 | /* fall through */ | ||
21 | case RESET_TYPE_S390_CPU_NORMAL: | ||
22 | env->psw.mask &= ~PSW_MASK_RI; | ||
23 | -- | ||
24 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Set the default NaN pattern explicitly for SPARC, and remove | ||
2 | the ifdef from parts64_default_nan. | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20241202131347.498124-50-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/sparc/cpu.c | 2 ++ | ||
9 | fpu/softfloat-specialize.c.inc | 5 +---- | ||
10 | 2 files changed, 3 insertions(+), 4 deletions(-) | ||
11 | |||
12 | diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/sparc/cpu.c | ||
15 | +++ b/target/sparc/cpu.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static void sparc_cpu_realizefn(DeviceState *dev, Error **errp) | ||
17 | set_float_3nan_prop_rule(float_3nan_prop_s_cba, &env->fp_status); | ||
18 | /* For inf * 0 + NaN, return the input NaN */ | ||
19 | set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status); | ||
20 | + /* Default NaN value: sign bit clear, all frac bits set */ | ||
21 | + set_float_default_nan_pattern(0b01111111, &env->fp_status); | ||
22 | |||
23 | cpu_exec_realizefn(cs, &local_err); | ||
24 | if (local_err != NULL) { | ||
25 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/fpu/softfloat-specialize.c.inc | ||
28 | +++ b/fpu/softfloat-specialize.c.inc | ||
29 | @@ -XXX,XX +XXX,XX @@ static void parts64_default_nan(FloatParts64 *p, float_status *status) | ||
30 | uint8_t dnan_pattern = status->default_nan_pattern; | ||
31 | |||
32 | if (dnan_pattern == 0) { | ||
33 | -#if defined(TARGET_SPARC) | ||
34 | - /* Sign bit clear, all frac bits set */ | ||
35 | - dnan_pattern = 0b01111111; | ||
36 | -#elif defined(TARGET_HEXAGON) | ||
37 | +#if defined(TARGET_HEXAGON) | ||
38 | /* Sign bit set, all frac bits set. */ | ||
39 | dnan_pattern = 0b11111111; | ||
40 | #else | ||
41 | -- | ||
42 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | Set the default NaN pattern explicitly for xtensa. |
---|---|---|---|
2 | 2 | ||
3 | The ADC region size is 256B, split as: | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | - [0x00 - 0x4f] defined | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | - [0x50 - 0xff] reserved | 5 | Message-id: 20241202131347.498124-51-peter.maydell@linaro.org |
6 | --- | ||
7 | target/xtensa/cpu.c | 2 ++ | ||
8 | 1 file changed, 2 insertions(+) | ||
6 | 9 | ||
7 | All registers are 32-bit (thus when the datasheet mentions the | 10 | diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c |
8 | last defined register is 0x4c, it means its address range is | ||
9 | 0x4c .. 0x4f. | ||
10 | |||
11 | This model implementation is also 32-bit. Set MemoryRegionOps | ||
12 | 'impl' fields. | ||
13 | |||
14 | See: | ||
15 | 'RM0033 Reference manual Rev 8', Table 10.13.18 "ADC register map". | ||
16 | |||
17 | Reported-by: Seth Kintigh <skintigh@gmail.com> | ||
18 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
19 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
20 | Message-id: 20200603055915.17678-1-f4bug@amsat.org | ||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
22 | --- | ||
23 | hw/adc/stm32f2xx_adc.c | 4 +++- | ||
24 | 1 file changed, 3 insertions(+), 1 deletion(-) | ||
25 | |||
26 | diff --git a/hw/adc/stm32f2xx_adc.c b/hw/adc/stm32f2xx_adc.c | ||
27 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/hw/adc/stm32f2xx_adc.c | 12 | --- a/target/xtensa/cpu.c |
29 | +++ b/hw/adc/stm32f2xx_adc.c | 13 | +++ b/target/xtensa/cpu.c |
30 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps stm32f2xx_adc_ops = { | 14 | @@ -XXX,XX +XXX,XX @@ static void xtensa_cpu_reset_hold(Object *obj, ResetType type) |
31 | .read = stm32f2xx_adc_read, | 15 | /* For inf * 0 + NaN, return the input NaN */ |
32 | .write = stm32f2xx_adc_write, | 16 | set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status); |
33 | .endianness = DEVICE_NATIVE_ENDIAN, | 17 | set_no_signaling_nans(!dfpu, &env->fp_status); |
34 | + .impl.min_access_size = 4, | 18 | + /* Default NaN value: sign bit clear, set frac msb */ |
35 | + .impl.max_access_size = 4, | 19 | + set_float_default_nan_pattern(0b01000000, &env->fp_status); |
36 | }; | 20 | xtensa_use_first_nan(env, !dfpu); |
37 | |||
38 | static const VMStateDescription vmstate_stm32f2xx_adc = { | ||
39 | @@ -XXX,XX +XXX,XX @@ static void stm32f2xx_adc_init(Object *obj) | ||
40 | sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->irq); | ||
41 | |||
42 | memory_region_init_io(&s->mmio, obj, &stm32f2xx_adc_ops, s, | ||
43 | - TYPE_STM32F2XX_ADC, 0xFF); | ||
44 | + TYPE_STM32F2XX_ADC, 0x100); | ||
45 | sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); | ||
46 | } | 21 | } |
47 | 22 | ||
48 | -- | 23 | -- |
49 | 2.20.1 | 24 | 2.34.1 |
50 | |||
51 | diff view generated by jsdifflib |
1 | Convert the VCVT fixed-point conversion operations in the | 1 | Set the default NaN pattern explicitly for hexagon. |
---|---|---|---|
2 | Neon 2-regs-and-shift group to decodetree. | 2 | Remove the ifdef from parts64_default_nan(); the only |
3 | remaining unconverted targets all use the default case. | ||
3 | 4 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20200522145520.6778-9-peter.maydell@linaro.org | 7 | Message-id: 20241202131347.498124-52-peter.maydell@linaro.org |
7 | --- | 8 | --- |
8 | target/arm/neon-dp.decode | 11 +++++ | 9 | target/hexagon/cpu.c | 2 ++ |
9 | target/arm/translate-neon.inc.c | 49 +++++++++++++++++++++ | 10 | fpu/softfloat-specialize.c.inc | 5 ----- |
10 | target/arm/translate.c | 75 +-------------------------------- | 11 | 2 files changed, 2 insertions(+), 5 deletions(-) |
11 | 3 files changed, 62 insertions(+), 73 deletions(-) | ||
12 | 12 | ||
13 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 13 | diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c |
14 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/neon-dp.decode | 15 | --- a/target/hexagon/cpu.c |
16 | +++ b/target/arm/neon-dp.decode | 16 | +++ b/target/hexagon/cpu.c |
17 | @@ -XXX,XX +XXX,XX @@ VMINNM_fp_3s 1111 001 1 0 . 1 . .... .... 1111 ... 1 .... @3same_fp | 17 | @@ -XXX,XX +XXX,XX @@ static void hexagon_cpu_reset_hold(Object *obj, ResetType type) |
18 | @2reg_shll_b .... ... . . . 001 shift:3 .... .... 0 . . . .... \ | 18 | |
19 | &2reg_shift vm=%vm_dp vd=%vd_dp size=0 q=0 | 19 | set_default_nan_mode(1, &env->fp_status); |
20 | 20 | set_float_detect_tininess(float_tininess_before_rounding, &env->fp_status); | |
21 | +# We use size=0 for fp32 and size=1 for fp16 to match the 3-same encodings. | 21 | + /* Default NaN value: sign bit set, all frac bits set */ |
22 | +@2reg_vcvt .... ... . . . 1 ..... .... .... . q:1 . . .... \ | 22 | + set_float_default_nan_pattern(0b11111111, &env->fp_status); |
23 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=0 shift=%neon_rshift_i5 | 23 | } |
24 | + | 24 | |
25 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_d | 25 | static void hexagon_cpu_disas_set_info(CPUState *s, disassemble_info *info) |
26 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_s | 26 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc |
27 | VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_h | ||
28 | @@ -XXX,XX +XXX,XX @@ VSHLL_S_2sh 1111 001 0 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_b | ||
29 | VSHLL_U_2sh 1111 001 1 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_s | ||
30 | VSHLL_U_2sh 1111 001 1 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_h | ||
31 | VSHLL_U_2sh 1111 001 1 1 . ...... .... 1010 . 0 . 1 .... @2reg_shll_b | ||
32 | + | ||
33 | +# VCVT fixed<->float conversions | ||
34 | +# TODO: FP16 fixed<->float conversions are opc==0b1100 and 0b1101 | ||
35 | +VCVT_SF_2sh 1111 001 0 1 . ...... .... 1110 0 . . 1 .... @2reg_vcvt | ||
36 | +VCVT_UF_2sh 1111 001 1 1 . ...... .... 1110 0 . . 1 .... @2reg_vcvt | ||
37 | +VCVT_FS_2sh 1111 001 0 1 . ...... .... 1111 0 . . 1 .... @2reg_vcvt | ||
38 | +VCVT_FU_2sh 1111 001 1 1 . ...... .... 1111 0 . . 1 .... @2reg_vcvt | ||
39 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
41 | --- a/target/arm/translate-neon.inc.c | 28 | --- a/fpu/softfloat-specialize.c.inc |
42 | +++ b/target/arm/translate-neon.inc.c | 29 | +++ b/fpu/softfloat-specialize.c.inc |
43 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSHLL_U_2sh(DisasContext *s, arg_2reg_shift *a) | 30 | @@ -XXX,XX +XXX,XX @@ static void parts64_default_nan(FloatParts64 *p, float_status *status) |
44 | }; | 31 | uint8_t dnan_pattern = status->default_nan_pattern; |
45 | return do_vshll_2sh(s, a, widenfn[a->size], true); | 32 | |
46 | } | 33 | if (dnan_pattern == 0) { |
47 | + | 34 | -#if defined(TARGET_HEXAGON) |
48 | +static bool do_fp_2sh(DisasContext *s, arg_2reg_shift *a, | 35 | - /* Sign bit set, all frac bits set. */ |
49 | + NeonGenTwoSingleOPFn *fn) | 36 | - dnan_pattern = 0b11111111; |
50 | +{ | 37 | -#else |
51 | + /* FP operations in 2-reg-and-shift group */ | 38 | /* |
52 | + TCGv_i32 tmp, shiftv; | 39 | * This case is true for Alpha, ARM, MIPS, OpenRISC, PPC, RISC-V, |
53 | + TCGv_ptr fpstatus; | 40 | * S390, SH4, TriCore, and Xtensa. Our other supported targets |
54 | + int pass; | 41 | @@ -XXX,XX +XXX,XX @@ static void parts64_default_nan(FloatParts64 *p, float_status *status) |
55 | + | 42 | /* sign bit clear, set frac msb */ |
56 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | 43 | dnan_pattern = 0b01000000; |
57 | + return false; | 44 | } |
58 | + } | 45 | -#endif |
59 | + | 46 | } |
60 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | 47 | assert(dnan_pattern != 0); |
61 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
62 | + ((a->vd | a->vm) & 0x10)) { | ||
63 | + return false; | ||
64 | + } | ||
65 | + | ||
66 | + if ((a->vm | a->vd) & a->q) { | ||
67 | + return false; | ||
68 | + } | ||
69 | + | ||
70 | + if (!vfp_access_check(s)) { | ||
71 | + return true; | ||
72 | + } | ||
73 | + | ||
74 | + fpstatus = get_fpstatus_ptr(1); | ||
75 | + shiftv = tcg_const_i32(a->shift); | ||
76 | + for (pass = 0; pass < (a->q ? 4 : 2); pass++) { | ||
77 | + tmp = neon_load_reg(a->vm, pass); | ||
78 | + fn(tmp, tmp, shiftv, fpstatus); | ||
79 | + neon_store_reg(a->vd, pass, tmp); | ||
80 | + } | ||
81 | + tcg_temp_free_ptr(fpstatus); | ||
82 | + tcg_temp_free_i32(shiftv); | ||
83 | + return true; | ||
84 | +} | ||
85 | + | ||
86 | +#define DO_FP_2SH(INSN, FUNC) \ | ||
87 | + static bool trans_##INSN##_2sh(DisasContext *s, arg_2reg_shift *a) \ | ||
88 | + { \ | ||
89 | + return do_fp_2sh(s, a, FUNC); \ | ||
90 | + } | ||
91 | + | ||
92 | +DO_FP_2SH(VCVT_SF, gen_helper_vfp_sltos) | ||
93 | +DO_FP_2SH(VCVT_UF, gen_helper_vfp_ultos) | ||
94 | +DO_FP_2SH(VCVT_FS, gen_helper_vfp_tosls_round_to_zero) | ||
95 | +DO_FP_2SH(VCVT_FU, gen_helper_vfp_touls_round_to_zero) | ||
96 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
97 | index XXXXXXX..XXXXXXX 100644 | ||
98 | --- a/target/arm/translate.c | ||
99 | +++ b/target/arm/translate.c | ||
100 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
101 | int q; | ||
102 | int rd, rn, rm, rd_ofs, rn_ofs, rm_ofs; | ||
103 | int size; | ||
104 | - int shift; | ||
105 | int pass; | ||
106 | int u; | ||
107 | int vec_size; | ||
108 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
109 | return 1; | ||
110 | } else if (insn & (1 << 4)) { | ||
111 | if ((insn & 0x00380080) != 0) { | ||
112 | - /* Two registers and shift. */ | ||
113 | - op = (insn >> 8) & 0xf; | ||
114 | - | ||
115 | - switch (op) { | ||
116 | - case 0: /* VSHR */ | ||
117 | - case 1: /* VSRA */ | ||
118 | - case 2: /* VRSHR */ | ||
119 | - case 3: /* VRSRA */ | ||
120 | - case 4: /* VSRI */ | ||
121 | - case 5: /* VSHL, VSLI */ | ||
122 | - case 6: /* VQSHLU */ | ||
123 | - case 7: /* VQSHL */ | ||
124 | - case 8: /* VSHRN, VRSHRN, VQSHRUN, VQRSHRUN */ | ||
125 | - case 9: /* VQSHRN, VQRSHRN */ | ||
126 | - case 10: /* VSHLL, including VMOVL */ | ||
127 | - return 1; /* handled by decodetree */ | ||
128 | - default: | ||
129 | - break; | ||
130 | - } | ||
131 | - | ||
132 | - if (insn & (1 << 7)) { | ||
133 | - /* 64-bit shift. */ | ||
134 | - if (op > 7) { | ||
135 | - return 1; | ||
136 | - } | ||
137 | - size = 3; | ||
138 | - } else { | ||
139 | - size = 2; | ||
140 | - while ((insn & (1 << (size + 19))) == 0) | ||
141 | - size--; | ||
142 | - } | ||
143 | - shift = (insn >> 16) & ((1 << (3 + size)) - 1); | ||
144 | - if (op >= 14) { | ||
145 | - /* VCVT fixed-point. */ | ||
146 | - TCGv_ptr fpst; | ||
147 | - TCGv_i32 shiftv; | ||
148 | - VFPGenFixPointFn *fn; | ||
149 | - | ||
150 | - if (!(insn & (1 << 21)) || (q && ((rd | rm) & 1))) { | ||
151 | - return 1; | ||
152 | - } | ||
153 | - | ||
154 | - if (!(op & 1)) { | ||
155 | - if (u) { | ||
156 | - fn = gen_helper_vfp_ultos; | ||
157 | - } else { | ||
158 | - fn = gen_helper_vfp_sltos; | ||
159 | - } | ||
160 | - } else { | ||
161 | - if (u) { | ||
162 | - fn = gen_helper_vfp_touls_round_to_zero; | ||
163 | - } else { | ||
164 | - fn = gen_helper_vfp_tosls_round_to_zero; | ||
165 | - } | ||
166 | - } | ||
167 | - | ||
168 | - /* We have already masked out the must-be-1 top bit of imm6, | ||
169 | - * hence this 32-shift where the ARM ARM has 64-imm6. | ||
170 | - */ | ||
171 | - shift = 32 - shift; | ||
172 | - fpst = get_fpstatus_ptr(1); | ||
173 | - shiftv = tcg_const_i32(shift); | ||
174 | - for (pass = 0; pass < (q ? 4 : 2); pass++) { | ||
175 | - TCGv_i32 tmpf = neon_load_reg(rm, pass); | ||
176 | - fn(tmpf, tmpf, shiftv, fpst); | ||
177 | - neon_store_reg(rd, pass, tmpf); | ||
178 | - } | ||
179 | - tcg_temp_free_ptr(fpst); | ||
180 | - tcg_temp_free_i32(shiftv); | ||
181 | - } else { | ||
182 | - return 1; | ||
183 | - } | ||
184 | + /* Two registers and shift: handled by decodetree */ | ||
185 | + return 1; | ||
186 | } else { /* (insn & 0x00380080) == 0 */ | ||
187 | int invert, reg_ofs, vec_size; | ||
188 | 48 | ||
189 | -- | 49 | -- |
190 | 2.20.1 | 50 | 2.34.1 |
191 | |||
192 | diff view generated by jsdifflib |
1 | Convert the VQSHLU and QVSHL 2-reg-shift insns to decodetree. | 1 | Set the default NaN pattern explicitly for riscv. |
---|---|---|---|
2 | These are the last of the simple shift-by-immediate insns. | ||
3 | 2 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20200522145520.6778-5-peter.maydell@linaro.org | 5 | Message-id: 20241202131347.498124-53-peter.maydell@linaro.org |
7 | --- | 6 | --- |
8 | target/arm/neon-dp.decode | 15 +++++ | 7 | target/riscv/cpu.c | 2 ++ |
9 | target/arm/translate-neon.inc.c | 108 +++++++++++++++++++++++++++++++ | 8 | 1 file changed, 2 insertions(+) |
10 | target/arm/translate.c | 110 +------------------------------- | ||
11 | 3 files changed, 126 insertions(+), 107 deletions(-) | ||
12 | 9 | ||
13 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 10 | diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c |
14 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/neon-dp.decode | 12 | --- a/target/riscv/cpu.c |
16 | +++ b/target/arm/neon-dp.decode | 13 | +++ b/target/riscv/cpu.c |
17 | @@ -XXX,XX +XXX,XX @@ VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_d | 14 | @@ -XXX,XX +XXX,XX @@ static void riscv_cpu_reset_hold(Object *obj, ResetType type) |
18 | VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_s | 15 | cs->exception_index = RISCV_EXCP_NONE; |
19 | VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_h | 16 | env->load_res = -1; |
20 | VSLI_2sh 1111 001 1 1 . ...... .... 0101 . . . 1 .... @2reg_shl_b | 17 | set_default_nan_mode(1, &env->fp_status); |
21 | + | 18 | + /* Default NaN value: sign bit clear, frac msb set */ |
22 | +VQSHLU_64_2sh 1111 001 1 1 . ...... .... 0110 . . . 1 .... @2reg_shl_d | 19 | + set_float_default_nan_pattern(0b01000000, &env->fp_status); |
23 | +VQSHLU_2sh 1111 001 1 1 . ...... .... 0110 . . . 1 .... @2reg_shl_s | 20 | env->vill = true; |
24 | +VQSHLU_2sh 1111 001 1 1 . ...... .... 0110 . . . 1 .... @2reg_shl_h | 21 | |
25 | +VQSHLU_2sh 1111 001 1 1 . ...... .... 0110 . . . 1 .... @2reg_shl_b | 22 | #ifndef CONFIG_USER_ONLY |
26 | + | ||
27 | +VQSHL_S_64_2sh 1111 001 0 1 . ...... .... 0111 . . . 1 .... @2reg_shl_d | ||
28 | +VQSHL_S_2sh 1111 001 0 1 . ...... .... 0111 . . . 1 .... @2reg_shl_s | ||
29 | +VQSHL_S_2sh 1111 001 0 1 . ...... .... 0111 . . . 1 .... @2reg_shl_h | ||
30 | +VQSHL_S_2sh 1111 001 0 1 . ...... .... 0111 . . . 1 .... @2reg_shl_b | ||
31 | + | ||
32 | +VQSHL_U_64_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_d | ||
33 | +VQSHL_U_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_s | ||
34 | +VQSHL_U_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_h | ||
35 | +VQSHL_U_2sh 1111 001 1 1 . ...... .... 0111 . . . 1 .... @2reg_shl_b | ||
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 trans_VSHR_U_2sh(DisasContext *s, arg_2reg_shift *a) | ||
41 | return do_vector_2sh(s, a, tcg_gen_gvec_shri); | ||
42 | } | ||
43 | } | ||
44 | + | ||
45 | +static bool do_2shift_env_64(DisasContext *s, arg_2reg_shift *a, | ||
46 | + NeonGenTwo64OpEnvFn *fn) | ||
47 | +{ | ||
48 | + /* | ||
49 | + * 2-reg-and-shift operations, size == 3 case, where the | ||
50 | + * function needs to be passed cpu_env. | ||
51 | + */ | ||
52 | + TCGv_i64 constimm; | ||
53 | + int pass; | ||
54 | + | ||
55 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
56 | + return false; | ||
57 | + } | ||
58 | + | ||
59 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
60 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
61 | + ((a->vd | a->vm) & 0x10)) { | ||
62 | + return false; | ||
63 | + } | ||
64 | + | ||
65 | + if ((a->vm | a->vd) & a->q) { | ||
66 | + return false; | ||
67 | + } | ||
68 | + | ||
69 | + if (!vfp_access_check(s)) { | ||
70 | + return true; | ||
71 | + } | ||
72 | + | ||
73 | + /* | ||
74 | + * To avoid excessive duplication of ops we implement shift | ||
75 | + * by immediate using the variable shift operations. | ||
76 | + */ | ||
77 | + constimm = tcg_const_i64(dup_const(a->size, a->shift)); | ||
78 | + | ||
79 | + for (pass = 0; pass < a->q + 1; pass++) { | ||
80 | + TCGv_i64 tmp = tcg_temp_new_i64(); | ||
81 | + | ||
82 | + neon_load_reg64(tmp, a->vm + pass); | ||
83 | + fn(tmp, cpu_env, tmp, constimm); | ||
84 | + neon_store_reg64(tmp, a->vd + pass); | ||
85 | + } | ||
86 | + tcg_temp_free_i64(constimm); | ||
87 | + return true; | ||
88 | +} | ||
89 | + | ||
90 | +static bool do_2shift_env_32(DisasContext *s, arg_2reg_shift *a, | ||
91 | + NeonGenTwoOpEnvFn *fn) | ||
92 | +{ | ||
93 | + /* | ||
94 | + * 2-reg-and-shift operations, size < 3 case, where the | ||
95 | + * helper needs to be passed cpu_env. | ||
96 | + */ | ||
97 | + TCGv_i32 constimm; | ||
98 | + int pass; | ||
99 | + | ||
100 | + if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
101 | + return false; | ||
102 | + } | ||
103 | + | ||
104 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
105 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
106 | + ((a->vd | a->vm) & 0x10)) { | ||
107 | + return false; | ||
108 | + } | ||
109 | + | ||
110 | + if ((a->vm | a->vd) & a->q) { | ||
111 | + return false; | ||
112 | + } | ||
113 | + | ||
114 | + if (!vfp_access_check(s)) { | ||
115 | + return true; | ||
116 | + } | ||
117 | + | ||
118 | + /* | ||
119 | + * To avoid excessive duplication of ops we implement shift | ||
120 | + * by immediate using the variable shift operations. | ||
121 | + */ | ||
122 | + constimm = tcg_const_i32(dup_const(a->size, a->shift)); | ||
123 | + | ||
124 | + for (pass = 0; pass < (a->q ? 4 : 2); pass++) { | ||
125 | + TCGv_i32 tmp = neon_load_reg(a->vm, pass); | ||
126 | + fn(tmp, cpu_env, tmp, constimm); | ||
127 | + neon_store_reg(a->vd, pass, tmp); | ||
128 | + } | ||
129 | + tcg_temp_free_i32(constimm); | ||
130 | + return true; | ||
131 | +} | ||
132 | + | ||
133 | +#define DO_2SHIFT_ENV(INSN, FUNC) \ | ||
134 | + static bool trans_##INSN##_64_2sh(DisasContext *s, arg_2reg_shift *a) \ | ||
135 | + { \ | ||
136 | + return do_2shift_env_64(s, a, gen_helper_neon_##FUNC##64); \ | ||
137 | + } \ | ||
138 | + static bool trans_##INSN##_2sh(DisasContext *s, arg_2reg_shift *a) \ | ||
139 | + { \ | ||
140 | + static NeonGenTwoOpEnvFn * const fns[] = { \ | ||
141 | + gen_helper_neon_##FUNC##8, \ | ||
142 | + gen_helper_neon_##FUNC##16, \ | ||
143 | + gen_helper_neon_##FUNC##32, \ | ||
144 | + }; \ | ||
145 | + assert(a->size < ARRAY_SIZE(fns)); \ | ||
146 | + return do_2shift_env_32(s, a, fns[a->size]); \ | ||
147 | + } | ||
148 | + | ||
149 | +DO_2SHIFT_ENV(VQSHLU, qshlu_s) | ||
150 | +DO_2SHIFT_ENV(VQSHL_U, qshl_u) | ||
151 | +DO_2SHIFT_ENV(VQSHL_S, qshl_s) | ||
152 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
153 | index XXXXXXX..XXXXXXX 100644 | ||
154 | --- a/target/arm/translate.c | ||
155 | +++ b/target/arm/translate.c | ||
156 | @@ -XXX,XX +XXX,XX @@ static inline void gen_neon_rsb(int size, TCGv_i32 t0, TCGv_i32 t1) | ||
157 | } | ||
158 | } | ||
159 | |||
160 | -#define GEN_NEON_INTEGER_OP_ENV(name) do { \ | ||
161 | - switch ((size << 1) | u) { \ | ||
162 | - case 0: \ | ||
163 | - gen_helper_neon_##name##_s8(tmp, cpu_env, tmp, tmp2); \ | ||
164 | - break; \ | ||
165 | - case 1: \ | ||
166 | - gen_helper_neon_##name##_u8(tmp, cpu_env, tmp, tmp2); \ | ||
167 | - break; \ | ||
168 | - case 2: \ | ||
169 | - gen_helper_neon_##name##_s16(tmp, cpu_env, tmp, tmp2); \ | ||
170 | - break; \ | ||
171 | - case 3: \ | ||
172 | - gen_helper_neon_##name##_u16(tmp, cpu_env, tmp, tmp2); \ | ||
173 | - break; \ | ||
174 | - case 4: \ | ||
175 | - gen_helper_neon_##name##_s32(tmp, cpu_env, tmp, tmp2); \ | ||
176 | - break; \ | ||
177 | - case 5: \ | ||
178 | - gen_helper_neon_##name##_u32(tmp, cpu_env, tmp, tmp2); \ | ||
179 | - break; \ | ||
180 | - default: return 1; \ | ||
181 | - }} while (0) | ||
182 | - | ||
183 | static TCGv_i32 neon_load_scratch(int scratch) | ||
184 | { | ||
185 | TCGv_i32 tmp = tcg_temp_new_i32(); | ||
186 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
187 | int size; | ||
188 | int shift; | ||
189 | int pass; | ||
190 | - int count; | ||
191 | int u; | ||
192 | int vec_size; | ||
193 | uint32_t imm; | ||
194 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
195 | case 3: /* VRSRA */ | ||
196 | case 4: /* VSRI */ | ||
197 | case 5: /* VSHL, VSLI */ | ||
198 | + case 6: /* VQSHLU */ | ||
199 | + case 7: /* VQSHL */ | ||
200 | return 1; /* handled by decodetree */ | ||
201 | default: | ||
202 | break; | ||
203 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
204 | size--; | ||
205 | } | ||
206 | shift = (insn >> 16) & ((1 << (3 + size)) - 1); | ||
207 | - if (op < 8) { | ||
208 | - /* Shift by immediate: | ||
209 | - VSHR, VSRA, VRSHR, VRSRA, VSRI, VSHL, VQSHL, VQSHLU. */ | ||
210 | - if (q && ((rd | rm) & 1)) { | ||
211 | - return 1; | ||
212 | - } | ||
213 | - if (!u && (op == 4 || op == 6)) { | ||
214 | - return 1; | ||
215 | - } | ||
216 | - /* Right shifts are encoded as N - shift, where N is the | ||
217 | - element size in bits. */ | ||
218 | - if (op <= 4) { | ||
219 | - shift = shift - (1 << (size + 3)); | ||
220 | - } | ||
221 | - | ||
222 | - if (size == 3) { | ||
223 | - count = q + 1; | ||
224 | - } else { | ||
225 | - count = q ? 4: 2; | ||
226 | - } | ||
227 | - | ||
228 | - /* To avoid excessive duplication of ops we implement shift | ||
229 | - * by immediate using the variable shift operations. | ||
230 | - */ | ||
231 | - imm = dup_const(size, shift); | ||
232 | - | ||
233 | - for (pass = 0; pass < count; pass++) { | ||
234 | - if (size == 3) { | ||
235 | - neon_load_reg64(cpu_V0, rm + pass); | ||
236 | - tcg_gen_movi_i64(cpu_V1, imm); | ||
237 | - switch (op) { | ||
238 | - case 6: /* VQSHLU */ | ||
239 | - gen_helper_neon_qshlu_s64(cpu_V0, cpu_env, | ||
240 | - cpu_V0, cpu_V1); | ||
241 | - break; | ||
242 | - case 7: /* VQSHL */ | ||
243 | - if (u) { | ||
244 | - gen_helper_neon_qshl_u64(cpu_V0, cpu_env, | ||
245 | - cpu_V0, cpu_V1); | ||
246 | - } else { | ||
247 | - gen_helper_neon_qshl_s64(cpu_V0, cpu_env, | ||
248 | - cpu_V0, cpu_V1); | ||
249 | - } | ||
250 | - break; | ||
251 | - default: | ||
252 | - g_assert_not_reached(); | ||
253 | - } | ||
254 | - neon_store_reg64(cpu_V0, rd + pass); | ||
255 | - } else { /* size < 3 */ | ||
256 | - /* Operands in T0 and T1. */ | ||
257 | - tmp = neon_load_reg(rm, pass); | ||
258 | - tmp2 = tcg_temp_new_i32(); | ||
259 | - tcg_gen_movi_i32(tmp2, imm); | ||
260 | - switch (op) { | ||
261 | - case 6: /* VQSHLU */ | ||
262 | - switch (size) { | ||
263 | - case 0: | ||
264 | - gen_helper_neon_qshlu_s8(tmp, cpu_env, | ||
265 | - tmp, tmp2); | ||
266 | - break; | ||
267 | - case 1: | ||
268 | - gen_helper_neon_qshlu_s16(tmp, cpu_env, | ||
269 | - tmp, tmp2); | ||
270 | - break; | ||
271 | - case 2: | ||
272 | - gen_helper_neon_qshlu_s32(tmp, cpu_env, | ||
273 | - tmp, tmp2); | ||
274 | - break; | ||
275 | - default: | ||
276 | - abort(); | ||
277 | - } | ||
278 | - break; | ||
279 | - case 7: /* VQSHL */ | ||
280 | - GEN_NEON_INTEGER_OP_ENV(qshl); | ||
281 | - break; | ||
282 | - default: | ||
283 | - g_assert_not_reached(); | ||
284 | - } | ||
285 | - tcg_temp_free_i32(tmp2); | ||
286 | - neon_store_reg(rd, pass, tmp); | ||
287 | - } | ||
288 | - } /* for pass */ | ||
289 | - } else if (op < 10) { | ||
290 | + if (op < 10) { | ||
291 | /* Shift by immediate and narrow: | ||
292 | VSHRN, VRSHRN, VQSHRN, VQRSHRN. */ | ||
293 | int input_unsigned = (op == 8) ? !u : u; | ||
294 | -- | 23 | -- |
295 | 2.20.1 | 24 | 2.34.1 |
296 | |||
297 | diff view generated by jsdifflib |
1 | Convert the VSHR 2-reg-shift insns to decodetree. | 1 | Set the default NaN pattern explicitly for tricore. |
---|---|---|---|
2 | |||
3 | Note that unlike the legacy decoder, we present the right shift | ||
4 | amount to the trans_ function as a positive integer. | ||
5 | 2 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20200522145520.6778-3-peter.maydell@linaro.org | 5 | Message-id: 20241202131347.498124-54-peter.maydell@linaro.org |
9 | --- | 6 | --- |
10 | target/arm/neon-dp.decode | 25 ++++++++++++++++++++ | 7 | target/tricore/helper.c | 2 ++ |
11 | target/arm/translate-neon.inc.c | 41 +++++++++++++++++++++++++++++++++ | 8 | 1 file changed, 2 insertions(+) |
12 | target/arm/translate.c | 21 +---------------- | ||
13 | 3 files changed, 67 insertions(+), 20 deletions(-) | ||
14 | 9 | ||
15 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 10 | diff --git a/target/tricore/helper.c b/target/tricore/helper.c |
16 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/neon-dp.decode | 12 | --- a/target/tricore/helper.c |
18 | +++ b/target/arm/neon-dp.decode | 13 | +++ b/target/tricore/helper.c |
19 | @@ -XXX,XX +XXX,XX @@ VMINNM_fp_3s 1111 001 1 0 . 1 . .... .... 1111 ... 1 .... @3same_fp | 14 | @@ -XXX,XX +XXX,XX @@ void fpu_set_state(CPUTriCoreState *env) |
20 | ###################################################################### | 15 | set_flush_to_zero(1, &env->fp_status); |
21 | &2reg_shift vm vd q shift size | 16 | set_float_detect_tininess(float_tininess_before_rounding, &env->fp_status); |
22 | 17 | set_default_nan_mode(1, &env->fp_status); | |
23 | +# Right shifts are encoded as N - shift, where N is the element size in bits. | 18 | + /* Default NaN pattern: sign bit clear, frac msb set */ |
24 | +%neon_rshift_i6 16:6 !function=rsub_64 | 19 | + set_float_default_nan_pattern(0b01000000, &env->fp_status); |
25 | +%neon_rshift_i5 16:5 !function=rsub_32 | ||
26 | +%neon_rshift_i4 16:4 !function=rsub_16 | ||
27 | +%neon_rshift_i3 16:3 !function=rsub_8 | ||
28 | + | ||
29 | +@2reg_shr_d .... ... . . . ...... .... .... 1 q:1 . . .... \ | ||
30 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=3 shift=%neon_rshift_i6 | ||
31 | +@2reg_shr_s .... ... . . . 1 ..... .... .... 0 q:1 . . .... \ | ||
32 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=2 shift=%neon_rshift_i5 | ||
33 | +@2reg_shr_h .... ... . . . 01 .... .... .... 0 q:1 . . .... \ | ||
34 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=1 shift=%neon_rshift_i4 | ||
35 | +@2reg_shr_b .... ... . . . 001 ... .... .... 0 q:1 . . .... \ | ||
36 | + &2reg_shift vm=%vm_dp vd=%vd_dp size=0 shift=%neon_rshift_i3 | ||
37 | + | ||
38 | @2reg_shl_d .... ... . . . shift:6 .... .... 1 q:1 . . .... \ | ||
39 | &2reg_shift vm=%vm_dp vd=%vd_dp size=3 | ||
40 | @2reg_shl_s .... ... . . . 1 shift:5 .... .... 0 q:1 . . .... \ | ||
41 | @@ -XXX,XX +XXX,XX @@ VMINNM_fp_3s 1111 001 1 0 . 1 . .... .... 1111 ... 1 .... @3same_fp | ||
42 | @2reg_shl_b .... ... . . . 001 shift:3 .... .... 0 q:1 . . .... \ | ||
43 | &2reg_shift vm=%vm_dp vd=%vd_dp size=0 | ||
44 | |||
45 | +VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_d | ||
46 | +VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_s | ||
47 | +VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_h | ||
48 | +VSHR_S_2sh 1111 001 0 1 . ...... .... 0000 . . . 1 .... @2reg_shr_b | ||
49 | + | ||
50 | +VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_d | ||
51 | +VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_s | ||
52 | +VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_h | ||
53 | +VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_b | ||
54 | + | ||
55 | VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_d | ||
56 | VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_s | ||
57 | VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_h | ||
58 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
59 | index XXXXXXX..XXXXXXX 100644 | ||
60 | --- a/target/arm/translate-neon.inc.c | ||
61 | +++ b/target/arm/translate-neon.inc.c | ||
62 | @@ -XXX,XX +XXX,XX @@ static inline int plus1(DisasContext *s, int x) | ||
63 | return x + 1; | ||
64 | } | 20 | } |
65 | 21 | ||
66 | +static inline int rsub_64(DisasContext *s, int x) | 22 | uint32_t psw_read(CPUTriCoreState *env) |
67 | +{ | ||
68 | + return 64 - x; | ||
69 | +} | ||
70 | + | ||
71 | +static inline int rsub_32(DisasContext *s, int x) | ||
72 | +{ | ||
73 | + return 32 - x; | ||
74 | +} | ||
75 | +static inline int rsub_16(DisasContext *s, int x) | ||
76 | +{ | ||
77 | + return 16 - x; | ||
78 | +} | ||
79 | +static inline int rsub_8(DisasContext *s, int x) | ||
80 | +{ | ||
81 | + return 8 - x; | ||
82 | +} | ||
83 | + | ||
84 | /* Include the generated Neon decoder */ | ||
85 | #include "decode-neon-dp.inc.c" | ||
86 | #include "decode-neon-ls.inc.c" | ||
87 | @@ -XXX,XX +XXX,XX @@ static bool do_vector_2sh(DisasContext *s, arg_2reg_shift *a, GVecGen2iFn *fn) | ||
88 | |||
89 | DO_2SH(VSHL, tcg_gen_gvec_shli) | ||
90 | DO_2SH(VSLI, gen_gvec_sli) | ||
91 | + | ||
92 | +static bool trans_VSHR_S_2sh(DisasContext *s, arg_2reg_shift *a) | ||
93 | +{ | ||
94 | + /* Signed shift out of range results in all-sign-bits */ | ||
95 | + a->shift = MIN(a->shift, (8 << a->size) - 1); | ||
96 | + return do_vector_2sh(s, a, tcg_gen_gvec_sari); | ||
97 | +} | ||
98 | + | ||
99 | +static void gen_zero_rd_2sh(unsigned vece, uint32_t rd_ofs, uint32_t rm_ofs, | ||
100 | + int64_t shift, uint32_t oprsz, uint32_t maxsz) | ||
101 | +{ | ||
102 | + tcg_gen_gvec_dup_imm(vece, rd_ofs, oprsz, maxsz, 0); | ||
103 | +} | ||
104 | + | ||
105 | +static bool trans_VSHR_U_2sh(DisasContext *s, arg_2reg_shift *a) | ||
106 | +{ | ||
107 | + /* Shift out of range is architecturally valid and results in zero. */ | ||
108 | + if (a->shift >= (8 << a->size)) { | ||
109 | + return do_vector_2sh(s, a, gen_zero_rd_2sh); | ||
110 | + } else { | ||
111 | + return do_vector_2sh(s, a, tcg_gen_gvec_shri); | ||
112 | + } | ||
113 | +} | ||
114 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
115 | index XXXXXXX..XXXXXXX 100644 | ||
116 | --- a/target/arm/translate.c | ||
117 | +++ b/target/arm/translate.c | ||
118 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
119 | op = (insn >> 8) & 0xf; | ||
120 | |||
121 | switch (op) { | ||
122 | + case 0: /* VSHR */ | ||
123 | case 5: /* VSHL, VSLI */ | ||
124 | return 1; /* handled by decodetree */ | ||
125 | default: | ||
126 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
127 | } | ||
128 | |||
129 | switch (op) { | ||
130 | - case 0: /* VSHR */ | ||
131 | - /* Right shift comes here negative. */ | ||
132 | - shift = -shift; | ||
133 | - /* Shifts larger than the element size are architecturally | ||
134 | - * valid. Unsigned results in all zeros; signed results | ||
135 | - * in all sign bits. | ||
136 | - */ | ||
137 | - if (!u) { | ||
138 | - tcg_gen_gvec_sari(size, rd_ofs, rm_ofs, | ||
139 | - MIN(shift, (8 << size) - 1), | ||
140 | - vec_size, vec_size); | ||
141 | - } else if (shift >= 8 << size) { | ||
142 | - tcg_gen_gvec_dup_imm(MO_8, rd_ofs, vec_size, | ||
143 | - vec_size, 0); | ||
144 | - } else { | ||
145 | - tcg_gen_gvec_shri(size, rd_ofs, rm_ofs, shift, | ||
146 | - vec_size, vec_size); | ||
147 | - } | ||
148 | - return 0; | ||
149 | - | ||
150 | case 1: /* VSRA */ | ||
151 | /* Right shift comes here negative. */ | ||
152 | shift = -shift; | ||
153 | -- | 23 | -- |
154 | 2.20.1 | 24 | 2.34.1 |
155 | |||
156 | diff view generated by jsdifflib |
1 | Convert the VSRA, VSRI, VRSHR, VRSRA 2-reg-shift insns to decodetree. | 1 | Now that all our targets have bene converted to explicitly specify |
---|---|---|---|
2 | (These are the last instructions in the group that are vectorized; | 2 | their pattern for the default NaN value we can remove the remaining |
3 | the rest all require looping over each element.) | 3 | fallback code in parts64_default_nan(). |
4 | 4 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20200522145520.6778-4-peter.maydell@linaro.org | 7 | Message-id: 20241202131347.498124-55-peter.maydell@linaro.org |
8 | --- | 8 | --- |
9 | target/arm/neon-dp.decode | 35 ++++++++++++++++++++++ | 9 | fpu/softfloat-specialize.c.inc | 14 -------------- |
10 | target/arm/translate-neon.inc.c | 7 +++++ | 10 | 1 file changed, 14 deletions(-) |
11 | target/arm/translate.c | 52 +++------------------------------ | ||
12 | 3 files changed, 46 insertions(+), 48 deletions(-) | ||
13 | 11 | ||
14 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 12 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc |
15 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/neon-dp.decode | 14 | --- a/fpu/softfloat-specialize.c.inc |
17 | +++ b/target/arm/neon-dp.decode | 15 | +++ b/fpu/softfloat-specialize.c.inc |
18 | @@ -XXX,XX +XXX,XX @@ VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_s | 16 | @@ -XXX,XX +XXX,XX @@ static void parts64_default_nan(FloatParts64 *p, float_status *status) |
19 | VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_h | 17 | uint64_t frac; |
20 | VSHR_U_2sh 1111 001 1 1 . ...... .... 0000 . . . 1 .... @2reg_shr_b | 18 | uint8_t dnan_pattern = status->default_nan_pattern; |
21 | 19 | ||
22 | +VSRA_S_2sh 1111 001 0 1 . ...... .... 0001 . . . 1 .... @2reg_shr_d | 20 | - if (dnan_pattern == 0) { |
23 | +VSRA_S_2sh 1111 001 0 1 . ...... .... 0001 . . . 1 .... @2reg_shr_s | 21 | - /* |
24 | +VSRA_S_2sh 1111 001 0 1 . ...... .... 0001 . . . 1 .... @2reg_shr_h | 22 | - * This case is true for Alpha, ARM, MIPS, OpenRISC, PPC, RISC-V, |
25 | +VSRA_S_2sh 1111 001 0 1 . ...... .... 0001 . . . 1 .... @2reg_shr_b | 23 | - * S390, SH4, TriCore, and Xtensa. Our other supported targets |
26 | + | 24 | - * do not have floating-point. |
27 | +VSRA_U_2sh 1111 001 1 1 . ...... .... 0001 . . . 1 .... @2reg_shr_d | 25 | - */ |
28 | +VSRA_U_2sh 1111 001 1 1 . ...... .... 0001 . . . 1 .... @2reg_shr_s | 26 | - if (snan_bit_is_one(status)) { |
29 | +VSRA_U_2sh 1111 001 1 1 . ...... .... 0001 . . . 1 .... @2reg_shr_h | 27 | - /* sign bit clear, set all frac bits other than msb */ |
30 | +VSRA_U_2sh 1111 001 1 1 . ...... .... 0001 . . . 1 .... @2reg_shr_b | 28 | - dnan_pattern = 0b00111111; |
31 | + | 29 | - } else { |
32 | +VRSHR_S_2sh 1111 001 0 1 . ...... .... 0010 . . . 1 .... @2reg_shr_d | 30 | - /* sign bit clear, set frac msb */ |
33 | +VRSHR_S_2sh 1111 001 0 1 . ...... .... 0010 . . . 1 .... @2reg_shr_s | 31 | - dnan_pattern = 0b01000000; |
34 | +VRSHR_S_2sh 1111 001 0 1 . ...... .... 0010 . . . 1 .... @2reg_shr_h | 32 | - } |
35 | +VRSHR_S_2sh 1111 001 0 1 . ...... .... 0010 . . . 1 .... @2reg_shr_b | 33 | - } |
36 | + | 34 | assert(dnan_pattern != 0); |
37 | +VRSHR_U_2sh 1111 001 1 1 . ...... .... 0010 . . . 1 .... @2reg_shr_d | 35 | |
38 | +VRSHR_U_2sh 1111 001 1 1 . ...... .... 0010 . . . 1 .... @2reg_shr_s | 36 | sign = dnan_pattern >> 7; |
39 | +VRSHR_U_2sh 1111 001 1 1 . ...... .... 0010 . . . 1 .... @2reg_shr_h | ||
40 | +VRSHR_U_2sh 1111 001 1 1 . ...... .... 0010 . . . 1 .... @2reg_shr_b | ||
41 | + | ||
42 | +VRSRA_S_2sh 1111 001 0 1 . ...... .... 0011 . . . 1 .... @2reg_shr_d | ||
43 | +VRSRA_S_2sh 1111 001 0 1 . ...... .... 0011 . . . 1 .... @2reg_shr_s | ||
44 | +VRSRA_S_2sh 1111 001 0 1 . ...... .... 0011 . . . 1 .... @2reg_shr_h | ||
45 | +VRSRA_S_2sh 1111 001 0 1 . ...... .... 0011 . . . 1 .... @2reg_shr_b | ||
46 | + | ||
47 | +VRSRA_U_2sh 1111 001 1 1 . ...... .... 0011 . . . 1 .... @2reg_shr_d | ||
48 | +VRSRA_U_2sh 1111 001 1 1 . ...... .... 0011 . . . 1 .... @2reg_shr_s | ||
49 | +VRSRA_U_2sh 1111 001 1 1 . ...... .... 0011 . . . 1 .... @2reg_shr_h | ||
50 | +VRSRA_U_2sh 1111 001 1 1 . ...... .... 0011 . . . 1 .... @2reg_shr_b | ||
51 | + | ||
52 | +VSRI_2sh 1111 001 1 1 . ...... .... 0100 . . . 1 .... @2reg_shr_d | ||
53 | +VSRI_2sh 1111 001 1 1 . ...... .... 0100 . . . 1 .... @2reg_shr_s | ||
54 | +VSRI_2sh 1111 001 1 1 . ...... .... 0100 . . . 1 .... @2reg_shr_h | ||
55 | +VSRI_2sh 1111 001 1 1 . ...... .... 0100 . . . 1 .... @2reg_shr_b | ||
56 | + | ||
57 | VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_d | ||
58 | VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_s | ||
59 | VSHL_2sh 1111 001 0 1 . ...... .... 0101 . . . 1 .... @2reg_shl_h | ||
60 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/target/arm/translate-neon.inc.c | ||
63 | +++ b/target/arm/translate-neon.inc.c | ||
64 | @@ -XXX,XX +XXX,XX @@ static bool do_vector_2sh(DisasContext *s, arg_2reg_shift *a, GVecGen2iFn *fn) | ||
65 | |||
66 | DO_2SH(VSHL, tcg_gen_gvec_shli) | ||
67 | DO_2SH(VSLI, gen_gvec_sli) | ||
68 | +DO_2SH(VSRI, gen_gvec_sri) | ||
69 | +DO_2SH(VSRA_S, gen_gvec_ssra) | ||
70 | +DO_2SH(VSRA_U, gen_gvec_usra) | ||
71 | +DO_2SH(VRSHR_S, gen_gvec_srshr) | ||
72 | +DO_2SH(VRSHR_U, gen_gvec_urshr) | ||
73 | +DO_2SH(VRSRA_S, gen_gvec_srsra) | ||
74 | +DO_2SH(VRSRA_U, gen_gvec_ursra) | ||
75 | |||
76 | static bool trans_VSHR_S_2sh(DisasContext *s, arg_2reg_shift *a) | ||
77 | { | ||
78 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
79 | index XXXXXXX..XXXXXXX 100644 | ||
80 | --- a/target/arm/translate.c | ||
81 | +++ b/target/arm/translate.c | ||
82 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
83 | |||
84 | switch (op) { | ||
85 | case 0: /* VSHR */ | ||
86 | + case 1: /* VSRA */ | ||
87 | + case 2: /* VRSHR */ | ||
88 | + case 3: /* VRSRA */ | ||
89 | + case 4: /* VSRI */ | ||
90 | case 5: /* VSHL, VSLI */ | ||
91 | return 1; /* handled by decodetree */ | ||
92 | default: | ||
93 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
94 | shift = shift - (1 << (size + 3)); | ||
95 | } | ||
96 | |||
97 | - switch (op) { | ||
98 | - case 1: /* VSRA */ | ||
99 | - /* Right shift comes here negative. */ | ||
100 | - shift = -shift; | ||
101 | - if (u) { | ||
102 | - gen_gvec_usra(size, rd_ofs, rm_ofs, shift, | ||
103 | - vec_size, vec_size); | ||
104 | - } else { | ||
105 | - gen_gvec_ssra(size, rd_ofs, rm_ofs, shift, | ||
106 | - vec_size, vec_size); | ||
107 | - } | ||
108 | - return 0; | ||
109 | - | ||
110 | - case 2: /* VRSHR */ | ||
111 | - /* Right shift comes here negative. */ | ||
112 | - shift = -shift; | ||
113 | - if (u) { | ||
114 | - gen_gvec_urshr(size, rd_ofs, rm_ofs, shift, | ||
115 | - vec_size, vec_size); | ||
116 | - } else { | ||
117 | - gen_gvec_srshr(size, rd_ofs, rm_ofs, shift, | ||
118 | - vec_size, vec_size); | ||
119 | - } | ||
120 | - return 0; | ||
121 | - | ||
122 | - case 3: /* VRSRA */ | ||
123 | - /* Right shift comes here negative. */ | ||
124 | - shift = -shift; | ||
125 | - if (u) { | ||
126 | - gen_gvec_ursra(size, rd_ofs, rm_ofs, shift, | ||
127 | - vec_size, vec_size); | ||
128 | - } else { | ||
129 | - gen_gvec_srsra(size, rd_ofs, rm_ofs, shift, | ||
130 | - vec_size, vec_size); | ||
131 | - } | ||
132 | - return 0; | ||
133 | - | ||
134 | - case 4: /* VSRI */ | ||
135 | - if (!u) { | ||
136 | - return 1; | ||
137 | - } | ||
138 | - /* Right shift comes here negative. */ | ||
139 | - shift = -shift; | ||
140 | - gen_gvec_sri(size, rd_ofs, rm_ofs, shift, | ||
141 | - vec_size, vec_size); | ||
142 | - return 0; | ||
143 | - } | ||
144 | - | ||
145 | if (size == 3) { | ||
146 | count = q + 1; | ||
147 | } else { | ||
148 | -- | 37 | -- |
149 | 2.20.1 | 38 | 2.34.1 |
150 | |||
151 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | hw_error() calls exit(). This a bit overkill when we can log | 3 | Inline pickNaNMulAdd into its only caller. This makes |
4 | the accesses as unimplemented or guest error. | 4 | one assert redundant with the immediately preceding IF. |
5 | 5 | ||
6 | When fuzzing the devices, we don't want the whole process to | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | exit. Replace some hw_error() calls by qemu_log_mask() | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | (missed in commit 5a0001ec7e). | 8 | Message-id: 20241203203949.483774-3-richard.henderson@linaro.org |
9 | 9 | [PMM: keep comment from old code in new location] | |
10 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Message-id: 20200525114123.21317-2-f4bug@amsat.org | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 11 | --- |
15 | hw/input/pxa2xx_keypad.c | 10 +++++++--- | 12 | fpu/softfloat-parts.c.inc | 41 +++++++++++++++++++++++++- |
16 | 1 file changed, 7 insertions(+), 3 deletions(-) | 13 | fpu/softfloat-specialize.c.inc | 54 ---------------------------------- |
14 | 2 files changed, 40 insertions(+), 55 deletions(-) | ||
17 | 15 | ||
18 | diff --git a/hw/input/pxa2xx_keypad.c b/hw/input/pxa2xx_keypad.c | 16 | diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc |
19 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/input/pxa2xx_keypad.c | 18 | --- a/fpu/softfloat-parts.c.inc |
21 | +++ b/hw/input/pxa2xx_keypad.c | 19 | +++ b/fpu/softfloat-parts.c.inc |
22 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, |
23 | */ | ||
24 | |||
25 | #include "qemu/osdep.h" | ||
26 | -#include "hw/hw.h" | ||
27 | +#include "qemu/log.h" | ||
28 | #include "hw/irq.h" | ||
29 | #include "migration/vmstate.h" | ||
30 | #include "hw/arm/pxa.h" | ||
31 | @@ -XXX,XX +XXX,XX @@ static uint64_t pxa2xx_keypad_read(void *opaque, hwaddr offset, | ||
32 | return s->kpkdi; | ||
33 | break; | ||
34 | default: | ||
35 | - hw_error("%s: Bad offset " REG_FMT "\n", __func__, offset); | ||
36 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
37 | + "%s: Bad read offset 0x%"HWADDR_PRIx"\n", | ||
38 | + __func__, offset); | ||
39 | } | 21 | } |
40 | 22 | ||
41 | return 0; | 23 | if (s->default_nan_mode) { |
42 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_keypad_write(void *opaque, hwaddr offset, | 24 | + /* |
43 | break; | 25 | + * We guarantee not to require the target to tell us how to |
44 | 26 | + * pick a NaN if we're always returning the default NaN. | |
45 | default: | 27 | + * But if we're not in default-NaN mode then the target must |
46 | - hw_error("%s: Bad offset " REG_FMT "\n", __func__, offset); | 28 | + * specify. |
47 | + qemu_log_mask(LOG_GUEST_ERROR, | 29 | + */ |
48 | + "%s: Bad write offset 0x%"HWADDR_PRIx"\n", | 30 | which = 3; |
49 | + __func__, offset); | 31 | + } else if (infzero) { |
32 | + /* | ||
33 | + * Inf * 0 + NaN -- some implementations return the | ||
34 | + * default NaN here, and some return the input NaN. | ||
35 | + */ | ||
36 | + switch (s->float_infzeronan_rule) { | ||
37 | + case float_infzeronan_dnan_never: | ||
38 | + which = 2; | ||
39 | + break; | ||
40 | + case float_infzeronan_dnan_always: | ||
41 | + which = 3; | ||
42 | + break; | ||
43 | + case float_infzeronan_dnan_if_qnan: | ||
44 | + which = is_qnan(c->cls) ? 3 : 2; | ||
45 | + break; | ||
46 | + default: | ||
47 | + g_assert_not_reached(); | ||
48 | + } | ||
49 | } else { | ||
50 | - which = pickNaNMulAdd(a->cls, b->cls, c->cls, infzero, have_snan, s); | ||
51 | + FloatClass cls[3] = { a->cls, b->cls, c->cls }; | ||
52 | + Float3NaNPropRule rule = s->float_3nan_prop_rule; | ||
53 | + | ||
54 | + assert(rule != float_3nan_prop_none); | ||
55 | + if (have_snan && (rule & R_3NAN_SNAN_MASK)) { | ||
56 | + /* We have at least one SNaN input and should prefer it */ | ||
57 | + do { | ||
58 | + which = rule & R_3NAN_1ST_MASK; | ||
59 | + rule >>= R_3NAN_1ST_LENGTH; | ||
60 | + } while (!is_snan(cls[which])); | ||
61 | + } else { | ||
62 | + do { | ||
63 | + which = rule & R_3NAN_1ST_MASK; | ||
64 | + rule >>= R_3NAN_1ST_LENGTH; | ||
65 | + } while (!is_nan(cls[which])); | ||
66 | + } | ||
67 | } | ||
68 | |||
69 | if (which == 3) { | ||
70 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
71 | index XXXXXXX..XXXXXXX 100644 | ||
72 | --- a/fpu/softfloat-specialize.c.inc | ||
73 | +++ b/fpu/softfloat-specialize.c.inc | ||
74 | @@ -XXX,XX +XXX,XX @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls, | ||
50 | } | 75 | } |
51 | } | 76 | } |
52 | 77 | ||
78 | -/*---------------------------------------------------------------------------- | ||
79 | -| Select which NaN to propagate for a three-input operation. | ||
80 | -| For the moment we assume that no CPU needs the 'larger significand' | ||
81 | -| information. | ||
82 | -| Return values : 0 : a; 1 : b; 2 : c; 3 : default-NaN | ||
83 | -*----------------------------------------------------------------------------*/ | ||
84 | -static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
85 | - bool infzero, bool have_snan, float_status *status) | ||
86 | -{ | ||
87 | - FloatClass cls[3] = { a_cls, b_cls, c_cls }; | ||
88 | - Float3NaNPropRule rule = status->float_3nan_prop_rule; | ||
89 | - int which; | ||
90 | - | ||
91 | - /* | ||
92 | - * We guarantee not to require the target to tell us how to | ||
93 | - * pick a NaN if we're always returning the default NaN. | ||
94 | - * But if we're not in default-NaN mode then the target must | ||
95 | - * specify. | ||
96 | - */ | ||
97 | - assert(!status->default_nan_mode); | ||
98 | - | ||
99 | - if (infzero) { | ||
100 | - /* | ||
101 | - * Inf * 0 + NaN -- some implementations return the default NaN here, | ||
102 | - * and some return the input NaN. | ||
103 | - */ | ||
104 | - switch (status->float_infzeronan_rule) { | ||
105 | - case float_infzeronan_dnan_never: | ||
106 | - return 2; | ||
107 | - case float_infzeronan_dnan_always: | ||
108 | - return 3; | ||
109 | - case float_infzeronan_dnan_if_qnan: | ||
110 | - return is_qnan(c_cls) ? 3 : 2; | ||
111 | - default: | ||
112 | - g_assert_not_reached(); | ||
113 | - } | ||
114 | - } | ||
115 | - | ||
116 | - assert(rule != float_3nan_prop_none); | ||
117 | - if (have_snan && (rule & R_3NAN_SNAN_MASK)) { | ||
118 | - /* We have at least one SNaN input and should prefer it */ | ||
119 | - do { | ||
120 | - which = rule & R_3NAN_1ST_MASK; | ||
121 | - rule >>= R_3NAN_1ST_LENGTH; | ||
122 | - } while (!is_snan(cls[which])); | ||
123 | - } else { | ||
124 | - do { | ||
125 | - which = rule & R_3NAN_1ST_MASK; | ||
126 | - rule >>= R_3NAN_1ST_LENGTH; | ||
127 | - } while (!is_nan(cls[which])); | ||
128 | - } | ||
129 | - return which; | ||
130 | -} | ||
131 | - | ||
132 | /*---------------------------------------------------------------------------- | ||
133 | | Returns 1 if the double-precision floating-point value `a' is a quiet | ||
134 | | NaN; otherwise returns 0. | ||
53 | -- | 135 | -- |
54 | 2.20.1 | 136 | 2.34.1 |
55 | 137 | ||
56 | 138 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | With this conversion, we will be able to use the same helpers | 3 | Remove "3" as a special case for which and simply |
4 | with sve. This also fixes a bug in which we failed to clear | 4 | branch to return the desired value. |
5 | the high bits of the SVE register after an AdvSIMD operation. | ||
6 | 5 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20200514212831.31248-3-richard.henderson@linaro.org | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Message-id: 20241203203949.483774-4-richard.henderson@linaro.org |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 10 | --- |
12 | target/arm/helper.h | 2 ++ | 11 | fpu/softfloat-parts.c.inc | 20 ++++++++++---------- |
13 | target/arm/translate-a64.h | 3 ++ | 12 | 1 file changed, 10 insertions(+), 10 deletions(-) |
14 | target/arm/crypto_helper.c | 11 +++++++ | ||
15 | target/arm/translate-a64.c | 59 ++++++++++++++++++++------------------ | ||
16 | 4 files changed, 47 insertions(+), 28 deletions(-) | ||
17 | 13 | ||
18 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 14 | diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc |
19 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/helper.h | 16 | --- a/fpu/softfloat-parts.c.inc |
21 | +++ b/target/arm/helper.h | 17 | +++ b/fpu/softfloat-parts.c.inc |
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(crypto_sm3partw2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 18 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, |
23 | DEF_HELPER_FLAGS_4(crypto_sm4e, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 19 | * But if we're not in default-NaN mode then the target must |
24 | DEF_HELPER_FLAGS_4(crypto_sm4ekey, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 20 | * specify. |
25 | 21 | */ | |
26 | +DEF_HELPER_FLAGS_4(crypto_rax1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 22 | - which = 3; |
27 | + | 23 | + goto default_nan; |
28 | DEF_HELPER_FLAGS_3(crc32, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) | 24 | } else if (infzero) { |
29 | DEF_HELPER_FLAGS_3(crc32c, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) | 25 | /* |
30 | 26 | * Inf * 0 + NaN -- some implementations return the | |
31 | diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h | 27 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, |
32 | index XXXXXXX..XXXXXXX 100644 | 28 | */ |
33 | --- a/target/arm/translate-a64.h | 29 | switch (s->float_infzeronan_rule) { |
34 | +++ b/target/arm/translate-a64.h | 30 | case float_infzeronan_dnan_never: |
35 | @@ -XXX,XX +XXX,XX @@ static inline int vec_full_reg_size(DisasContext *s) | 31 | - which = 2; |
36 | |||
37 | bool disas_sve(DisasContext *, uint32_t); | ||
38 | |||
39 | +void gen_gvec_rax1(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, | ||
40 | + uint32_t rm_ofs, uint32_t opr_sz, uint32_t max_sz); | ||
41 | + | ||
42 | #endif /* TARGET_ARM_TRANSLATE_A64_H */ | ||
43 | diff --git a/target/arm/crypto_helper.c b/target/arm/crypto_helper.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/target/arm/crypto_helper.c | ||
46 | +++ b/target/arm/crypto_helper.c | ||
47 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm4ekey)(void *vd, void *vn, void* vm, uint32_t desc) | ||
48 | } | ||
49 | clear_tail(vd, opr_sz, simd_maxsz(desc)); | ||
50 | } | ||
51 | + | ||
52 | +void HELPER(crypto_rax1)(void *vd, void *vn, void *vm, uint32_t desc) | ||
53 | +{ | ||
54 | + intptr_t i, opr_sz = simd_oprsz(desc); | ||
55 | + uint64_t *d = vd, *n = vn, *m = vm; | ||
56 | + | ||
57 | + for (i = 0; i < opr_sz / 8; ++i) { | ||
58 | + d[i] = n[i] ^ rol64(m[i], 1); | ||
59 | + } | ||
60 | + clear_tail(vd, opr_sz, simd_maxsz(desc)); | ||
61 | +} | ||
62 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/target/arm/translate-a64.c | ||
65 | +++ b/target/arm/translate-a64.c | ||
66 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha(DisasContext *s, uint32_t insn) | ||
67 | tcg_temp_free_ptr(tcg_rn_ptr); | ||
68 | } | ||
69 | |||
70 | +static void gen_rax1_i64(TCGv_i64 d, TCGv_i64 n, TCGv_i64 m) | ||
71 | +{ | ||
72 | + tcg_gen_rotli_i64(d, m, 1); | ||
73 | + tcg_gen_xor_i64(d, d, n); | ||
74 | +} | ||
75 | + | ||
76 | +static void gen_rax1_vec(unsigned vece, TCGv_vec d, TCGv_vec n, TCGv_vec m) | ||
77 | +{ | ||
78 | + tcg_gen_rotli_vec(vece, d, m, 1); | ||
79 | + tcg_gen_xor_vec(vece, d, d, n); | ||
80 | +} | ||
81 | + | ||
82 | +void gen_gvec_rax1(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, | ||
83 | + uint32_t rm_ofs, uint32_t opr_sz, uint32_t max_sz) | ||
84 | +{ | ||
85 | + static const TCGOpcode vecop_list[] = { INDEX_op_rotli_vec, 0 }; | ||
86 | + static const GVecGen3 op = { | ||
87 | + .fni8 = gen_rax1_i64, | ||
88 | + .fniv = gen_rax1_vec, | ||
89 | + .opt_opc = vecop_list, | ||
90 | + .fno = gen_helper_crypto_rax1, | ||
91 | + .vece = MO_64, | ||
92 | + }; | ||
93 | + tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, opr_sz, max_sz, &op); | ||
94 | +} | ||
95 | + | ||
96 | /* Crypto three-reg SHA512 | ||
97 | * 31 21 20 16 15 14 13 12 11 10 9 5 4 0 | ||
98 | * +-----------------------+------+---+---+-----+--------+------+------+ | ||
99 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
100 | bool feature; | ||
101 | CryptoThreeOpFn *genfn = NULL; | ||
102 | gen_helper_gvec_3 *oolfn = NULL; | ||
103 | + GVecGen3Fn *gvecfn = NULL; | ||
104 | |||
105 | if (o == 0) { | ||
106 | switch (opcode) { | ||
107 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
108 | break; | 32 | break; |
109 | case 3: /* RAX1 */ | 33 | case float_infzeronan_dnan_always: |
110 | feature = dc_isar_feature(aa64_sha3, s); | 34 | - which = 3; |
111 | - genfn = NULL; | 35 | - break; |
112 | + gvecfn = gen_gvec_rax1; | 36 | + goto default_nan; |
37 | case float_infzeronan_dnan_if_qnan: | ||
38 | - which = is_qnan(c->cls) ? 3 : 2; | ||
39 | + if (is_qnan(c->cls)) { | ||
40 | + goto default_nan; | ||
41 | + } | ||
113 | break; | 42 | break; |
114 | default: | 43 | default: |
115 | g_assert_not_reached(); | 44 | g_assert_not_reached(); |
116 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | 45 | } |
117 | 46 | + which = 2; | |
118 | if (oolfn) { | 47 | } else { |
119 | gen_gvec_op3_ool(s, true, rd, rn, rm, 0, oolfn); | 48 | FloatClass cls[3] = { a->cls, b->cls, c->cls }; |
120 | - return; | 49 | Float3NaNPropRule rule = s->float_3nan_prop_rule; |
50 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, | ||
51 | } | ||
52 | } | ||
53 | |||
54 | - if (which == 3) { | ||
55 | - parts_default_nan(a, s); | ||
56 | - return a; | ||
121 | - } | 57 | - } |
122 | - | 58 | - |
123 | - if (genfn) { | 59 | switch (which) { |
124 | + } else if (gvecfn) { | 60 | case 0: |
125 | + gen_gvec_fn3(s, true, rd, rn, rm, gvecfn, MO_64); | 61 | break; |
126 | + } else { | 62 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, |
127 | TCGv_ptr tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr; | 63 | parts_silence_nan(a, s); |
128 | |||
129 | tcg_rd_ptr = vec_full_reg_ptr(s, rd); | ||
130 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
131 | tcg_temp_free_ptr(tcg_rd_ptr); | ||
132 | tcg_temp_free_ptr(tcg_rn_ptr); | ||
133 | tcg_temp_free_ptr(tcg_rm_ptr); | ||
134 | - } else { | ||
135 | - TCGv_i64 tcg_op1, tcg_op2, tcg_res[2]; | ||
136 | - int pass; | ||
137 | - | ||
138 | - tcg_op1 = tcg_temp_new_i64(); | ||
139 | - tcg_op2 = tcg_temp_new_i64(); | ||
140 | - tcg_res[0] = tcg_temp_new_i64(); | ||
141 | - tcg_res[1] = tcg_temp_new_i64(); | ||
142 | - | ||
143 | - for (pass = 0; pass < 2; pass++) { | ||
144 | - read_vec_element(s, tcg_op1, rn, pass, MO_64); | ||
145 | - read_vec_element(s, tcg_op2, rm, pass, MO_64); | ||
146 | - | ||
147 | - tcg_gen_rotli_i64(tcg_res[pass], tcg_op2, 1); | ||
148 | - tcg_gen_xor_i64(tcg_res[pass], tcg_res[pass], tcg_op1); | ||
149 | - } | ||
150 | - write_vec_element(s, tcg_res[0], rd, 0, MO_64); | ||
151 | - write_vec_element(s, tcg_res[1], rd, 1, MO_64); | ||
152 | - | ||
153 | - tcg_temp_free_i64(tcg_op1); | ||
154 | - tcg_temp_free_i64(tcg_op2); | ||
155 | - tcg_temp_free_i64(tcg_res[0]); | ||
156 | - tcg_temp_free_i64(tcg_res[1]); | ||
157 | } | 64 | } |
65 | return a; | ||
66 | + | ||
67 | + default_nan: | ||
68 | + parts_default_nan(a, s); | ||
69 | + return a; | ||
158 | } | 70 | } |
159 | 71 | ||
72 | /* | ||
160 | -- | 73 | -- |
161 | 2.20.1 | 74 | 2.34.1 |
162 | 75 | ||
163 | 76 | diff view generated by jsdifflib |
1 | From: Paul Zimmerman <pauldzim@gmail.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Add the dwc-hsotg (dwc2) USB host controller state definitions. | 3 | Assign the pointer return value to 'a' directly, |
4 | Mostly based on hw/usb/hcd-ehci.h. | 4 | rather than going through an intermediary index. |
5 | 5 | ||
6 | Signed-off-by: Paul Zimmerman <pauldzim@gmail.com> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20200520235349.21215-4-pauldzim@gmail.com | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Message-id: 20241203203949.483774-5-richard.henderson@linaro.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 10 | --- |
11 | hw/usb/hcd-dwc2.h | 190 ++++++++++++++++++++++++++++++++++++++++++++++ | 11 | fpu/softfloat-parts.c.inc | 32 ++++++++++---------------------- |
12 | 1 file changed, 190 insertions(+) | 12 | 1 file changed, 10 insertions(+), 22 deletions(-) |
13 | create mode 100644 hw/usb/hcd-dwc2.h | ||
14 | 13 | ||
15 | diff --git a/hw/usb/hcd-dwc2.h b/hw/usb/hcd-dwc2.h | 14 | diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc |
16 | new file mode 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
17 | index XXXXXXX..XXXXXXX | 16 | --- a/fpu/softfloat-parts.c.inc |
18 | --- /dev/null | 17 | +++ b/fpu/softfloat-parts.c.inc |
19 | +++ b/hw/usb/hcd-dwc2.h | 18 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, |
20 | @@ -XXX,XX +XXX,XX @@ | 19 | FloatPartsN *c, float_status *s, |
21 | +/* | 20 | int ab_mask, int abc_mask) |
22 | + * dwc-hsotg (dwc2) USB host controller state definitions | 21 | { |
23 | + * | 22 | - int which; |
24 | + * Based on hw/usb/hcd-ehci.h | 23 | bool infzero = (ab_mask == float_cmask_infzero); |
25 | + * | 24 | bool have_snan = (abc_mask & float_cmask_snan); |
26 | + * Copyright (c) 2020 Paul Zimmerman <pauldzim@gmail.com> | 25 | + FloatPartsN *ret; |
27 | + * | 26 | |
28 | + * This program is free software; you can redistribute it and/or modify | 27 | if (unlikely(have_snan)) { |
29 | + * it under the terms of the GNU General Public License as published by | 28 | float_raise(float_flag_invalid | float_flag_invalid_snan, s); |
30 | + * the Free Software Foundation; either version 2 of the License, or | 29 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, |
31 | + * (at your option) any later version. | 30 | default: |
32 | + * | 31 | g_assert_not_reached(); |
33 | + * This program is distributed in the hope that it will be useful, | 32 | } |
34 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | 33 | - which = 2; |
35 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 34 | + ret = c; |
36 | + * GNU General Public License for more details. | 35 | } else { |
37 | + */ | 36 | - FloatClass cls[3] = { a->cls, b->cls, c->cls }; |
38 | + | 37 | + FloatPartsN *val[3] = { a, b, c }; |
39 | +#ifndef HW_USB_DWC2_H | 38 | Float3NaNPropRule rule = s->float_3nan_prop_rule; |
40 | +#define HW_USB_DWC2_H | 39 | |
41 | + | 40 | assert(rule != float_3nan_prop_none); |
42 | +#include "qemu/timer.h" | 41 | if (have_snan && (rule & R_3NAN_SNAN_MASK)) { |
43 | +#include "hw/irq.h" | 42 | /* We have at least one SNaN input and should prefer it */ |
44 | +#include "hw/sysbus.h" | 43 | do { |
45 | +#include "hw/usb.h" | 44 | - which = rule & R_3NAN_1ST_MASK; |
46 | +#include "sysemu/dma.h" | 45 | + ret = val[rule & R_3NAN_1ST_MASK]; |
47 | + | 46 | rule >>= R_3NAN_1ST_LENGTH; |
48 | +#define DWC2_MMIO_SIZE 0x11000 | 47 | - } while (!is_snan(cls[which])); |
49 | + | 48 | + } while (!is_snan(ret->cls)); |
50 | +#define DWC2_NB_CHAN 8 /* Number of host channels */ | 49 | } else { |
51 | +#define DWC2_MAX_XFER_SIZE 65536 /* Max transfer size expected in HCTSIZ */ | 50 | do { |
52 | + | 51 | - which = rule & R_3NAN_1ST_MASK; |
53 | +typedef struct DWC2Packet DWC2Packet; | 52 | + ret = val[rule & R_3NAN_1ST_MASK]; |
54 | +typedef struct DWC2State DWC2State; | 53 | rule >>= R_3NAN_1ST_LENGTH; |
55 | +typedef struct DWC2Class DWC2Class; | 54 | - } while (!is_nan(cls[which])); |
56 | + | 55 | + } while (!is_nan(ret->cls)); |
57 | +enum async_state { | 56 | } |
58 | + DWC2_ASYNC_NONE = 0, | 57 | } |
59 | + DWC2_ASYNC_INITIALIZED, | 58 | |
60 | + DWC2_ASYNC_INFLIGHT, | 59 | - switch (which) { |
61 | + DWC2_ASYNC_FINISHED, | 60 | - case 0: |
62 | +}; | 61 | - break; |
63 | + | 62 | - case 1: |
64 | +struct DWC2Packet { | 63 | - a = b; |
65 | + USBPacket packet; | 64 | - break; |
66 | + uint32_t devadr; | 65 | - case 2: |
67 | + uint32_t epnum; | 66 | - a = c; |
68 | + uint32_t epdir; | 67 | - break; |
69 | + uint32_t mps; | 68 | - default: |
70 | + uint32_t pid; | 69 | - g_assert_not_reached(); |
71 | + uint32_t index; | 70 | + if (is_snan(ret->cls)) { |
72 | + uint32_t pcnt; | 71 | + parts_silence_nan(ret, s); |
73 | + uint32_t len; | 72 | } |
74 | + int32_t async; | 73 | - if (is_snan(a->cls)) { |
75 | + bool small; | 74 | - parts_silence_nan(a, s); |
76 | + bool needs_service; | 75 | - } |
77 | +}; | 76 | - return a; |
78 | + | 77 | + return ret; |
79 | +struct DWC2State { | 78 | |
80 | + /*< private >*/ | 79 | default_nan: |
81 | + SysBusDevice parent_obj; | 80 | parts_default_nan(a, s); |
82 | + | ||
83 | + /*< public >*/ | ||
84 | + USBBus bus; | ||
85 | + qemu_irq irq; | ||
86 | + MemoryRegion *dma_mr; | ||
87 | + AddressSpace dma_as; | ||
88 | + MemoryRegion container; | ||
89 | + MemoryRegion hsotg; | ||
90 | + MemoryRegion fifos; | ||
91 | + | ||
92 | + union { | ||
93 | +#define DWC2_GLBREG_SIZE 0x70 | ||
94 | + uint32_t glbreg[DWC2_GLBREG_SIZE / sizeof(uint32_t)]; | ||
95 | + struct { | ||
96 | + uint32_t gotgctl; /* 00 */ | ||
97 | + uint32_t gotgint; /* 04 */ | ||
98 | + uint32_t gahbcfg; /* 08 */ | ||
99 | + uint32_t gusbcfg; /* 0c */ | ||
100 | + uint32_t grstctl; /* 10 */ | ||
101 | + uint32_t gintsts; /* 14 */ | ||
102 | + uint32_t gintmsk; /* 18 */ | ||
103 | + uint32_t grxstsr; /* 1c */ | ||
104 | + uint32_t grxstsp; /* 20 */ | ||
105 | + uint32_t grxfsiz; /* 24 */ | ||
106 | + uint32_t gnptxfsiz; /* 28 */ | ||
107 | + uint32_t gnptxsts; /* 2c */ | ||
108 | + uint32_t gi2cctl; /* 30 */ | ||
109 | + uint32_t gpvndctl; /* 34 */ | ||
110 | + uint32_t ggpio; /* 38 */ | ||
111 | + uint32_t guid; /* 3c */ | ||
112 | + uint32_t gsnpsid; /* 40 */ | ||
113 | + uint32_t ghwcfg1; /* 44 */ | ||
114 | + uint32_t ghwcfg2; /* 48 */ | ||
115 | + uint32_t ghwcfg3; /* 4c */ | ||
116 | + uint32_t ghwcfg4; /* 50 */ | ||
117 | + uint32_t glpmcfg; /* 54 */ | ||
118 | + uint32_t gpwrdn; /* 58 */ | ||
119 | + uint32_t gdfifocfg; /* 5c */ | ||
120 | + uint32_t gadpctl; /* 60 */ | ||
121 | + uint32_t grefclk; /* 64 */ | ||
122 | + uint32_t gintmsk2; /* 68 */ | ||
123 | + uint32_t gintsts2; /* 6c */ | ||
124 | + }; | ||
125 | + }; | ||
126 | + | ||
127 | + union { | ||
128 | +#define DWC2_FSZREG_SIZE 0x04 | ||
129 | + uint32_t fszreg[DWC2_FSZREG_SIZE / sizeof(uint32_t)]; | ||
130 | + struct { | ||
131 | + uint32_t hptxfsiz; /* 100 */ | ||
132 | + }; | ||
133 | + }; | ||
134 | + | ||
135 | + union { | ||
136 | +#define DWC2_HREG0_SIZE 0x44 | ||
137 | + uint32_t hreg0[DWC2_HREG0_SIZE / sizeof(uint32_t)]; | ||
138 | + struct { | ||
139 | + uint32_t hcfg; /* 400 */ | ||
140 | + uint32_t hfir; /* 404 */ | ||
141 | + uint32_t hfnum; /* 408 */ | ||
142 | + uint32_t rsvd0; /* 40c */ | ||
143 | + uint32_t hptxsts; /* 410 */ | ||
144 | + uint32_t haint; /* 414 */ | ||
145 | + uint32_t haintmsk; /* 418 */ | ||
146 | + uint32_t hflbaddr; /* 41c */ | ||
147 | + uint32_t rsvd1[8]; /* 420-43c */ | ||
148 | + uint32_t hprt0; /* 440 */ | ||
149 | + }; | ||
150 | + }; | ||
151 | + | ||
152 | +#define DWC2_HREG1_SIZE (0x20 * DWC2_NB_CHAN) | ||
153 | + uint32_t hreg1[DWC2_HREG1_SIZE / sizeof(uint32_t)]; | ||
154 | + | ||
155 | +#define hcchar(_ch) hreg1[((_ch) << 3) + 0] /* 500, 520, ... */ | ||
156 | +#define hcsplt(_ch) hreg1[((_ch) << 3) + 1] /* 504, 524, ... */ | ||
157 | +#define hcint(_ch) hreg1[((_ch) << 3) + 2] /* 508, 528, ... */ | ||
158 | +#define hcintmsk(_ch) hreg1[((_ch) << 3) + 3] /* 50c, 52c, ... */ | ||
159 | +#define hctsiz(_ch) hreg1[((_ch) << 3) + 4] /* 510, 530, ... */ | ||
160 | +#define hcdma(_ch) hreg1[((_ch) << 3) + 5] /* 514, 534, ... */ | ||
161 | +#define hcdmab(_ch) hreg1[((_ch) << 3) + 7] /* 51c, 53c, ... */ | ||
162 | + | ||
163 | + union { | ||
164 | +#define DWC2_PCGREG_SIZE 0x08 | ||
165 | + uint32_t pcgreg[DWC2_PCGREG_SIZE / sizeof(uint32_t)]; | ||
166 | + struct { | ||
167 | + uint32_t pcgctl; /* e00 */ | ||
168 | + uint32_t pcgcctl1; /* e04 */ | ||
169 | + }; | ||
170 | + }; | ||
171 | + | ||
172 | + /* TODO - implement FIFO registers for slave mode */ | ||
173 | +#define DWC2_HFIFO_SIZE (0x1000 * DWC2_NB_CHAN) | ||
174 | + | ||
175 | + /* | ||
176 | + * Internal state | ||
177 | + */ | ||
178 | + QEMUTimer *eof_timer; | ||
179 | + QEMUTimer *frame_timer; | ||
180 | + QEMUBH *async_bh; | ||
181 | + int64_t sof_time; | ||
182 | + int64_t usb_frame_time; | ||
183 | + int64_t usb_bit_time; | ||
184 | + uint32_t usb_version; | ||
185 | + uint16_t frame_number; | ||
186 | + uint16_t fi; | ||
187 | + uint16_t next_chan; | ||
188 | + bool working; | ||
189 | + USBPort uport; | ||
190 | + DWC2Packet packet[DWC2_NB_CHAN]; /* one packet per chan */ | ||
191 | + uint8_t usb_buf[DWC2_NB_CHAN][DWC2_MAX_XFER_SIZE]; /* one buffer per chan */ | ||
192 | +}; | ||
193 | + | ||
194 | +struct DWC2Class { | ||
195 | + /*< private >*/ | ||
196 | + SysBusDeviceClass parent_class; | ||
197 | + ResettablePhases parent_phases; | ||
198 | + | ||
199 | + /*< public >*/ | ||
200 | +}; | ||
201 | + | ||
202 | +#define TYPE_DWC2_USB "dwc2-usb" | ||
203 | +#define DWC2_USB(obj) \ | ||
204 | + OBJECT_CHECK(DWC2State, (obj), TYPE_DWC2_USB) | ||
205 | +#define DWC2_CLASS(klass) \ | ||
206 | + OBJECT_CLASS_CHECK(DWC2Class, (klass), TYPE_DWC2_USB) | ||
207 | +#define DWC2_GET_CLASS(obj) \ | ||
208 | + OBJECT_GET_CLASS(DWC2Class, (obj), TYPE_DWC2_USB) | ||
209 | + | ||
210 | +#endif | ||
211 | -- | 81 | -- |
212 | 2.20.1 | 82 | 2.34.1 |
213 | 83 | ||
214 | 84 | diff view generated by jsdifflib |
1 | From: Eden Mikitas <e.mikitas@gmail.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The while statement in question only checked if tx_burst is not 0. | 3 | While all indices into val[] should be in [0-2], the mask |
4 | tx_burst is a signed int, which is assigned the value put by the | 4 | applied is two bits. To help static analysis see there is |
5 | guest driver in ECSPI_CONREG. The burst length can be anywhere | 5 | no possibility of read beyond the end of the array, pad the |
6 | between 1 and 4096, and since tx_burst is always decremented by 8 | 6 | array to 4 entries, with the final being (implicitly) NULL. |
7 | it could possibly underflow, causing an infinite loop. | ||
8 | 7 | ||
9 | Signed-off-by: Eden Mikitas <e.mikitas@gmail.com> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
10 | Message-id: 20241203203949.483774-6-richard.henderson@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 12 | --- |
13 | hw/ssi/imx_spi.c | 2 +- | 13 | fpu/softfloat-parts.c.inc | 2 +- |
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | 14 | 1 file changed, 1 insertion(+), 1 deletion(-) |
15 | 15 | ||
16 | diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c | 16 | diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc |
17 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/ssi/imx_spi.c | 18 | --- a/fpu/softfloat-parts.c.inc |
19 | +++ b/hw/ssi/imx_spi.c | 19 | +++ b/fpu/softfloat-parts.c.inc |
20 | @@ -XXX,XX +XXX,XX @@ static void imx_spi_flush_txfifo(IMXSPIState *s) | 20 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, |
21 | 21 | } | |
22 | rx = 0; | 22 | ret = c; |
23 | 23 | } else { | |
24 | - while (tx_burst) { | 24 | - FloatPartsN *val[3] = { a, b, c }; |
25 | + while (tx_burst > 0) { | 25 | + FloatPartsN *val[R_3NAN_1ST_MASK + 1] = { a, b, c }; |
26 | uint8_t byte = tx & 0xff; | 26 | Float3NaNPropRule rule = s->float_3nan_prop_rule; |
27 | 27 | ||
28 | DPRINTF("writing 0x%02x\n", (uint32_t)byte); | 28 | assert(rule != float_3nan_prop_none); |
29 | -- | 29 | -- |
30 | 2.20.1 | 30 | 2.34.1 |
31 | 31 | ||
32 | 32 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Do not yet convert the helpers to loop over opr_sz, but the | 3 | This function is part of the public interface and |
4 | descriptor allows the vector tail to be cleared. Which fixes | 4 | is not "specialized" to any target in any way. |
5 | an existing bug vs SVE. | ||
6 | 5 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20200514212831.31248-5-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20241203203949.483774-7-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 10 | --- |
12 | target/arm/helper.h | 12 ++-- | 11 | fpu/softfloat.c | 52 ++++++++++++++++++++++++++++++++++ |
13 | target/arm/neon-dp.decode | 12 ++-- | 12 | fpu/softfloat-specialize.c.inc | 52 ---------------------------------- |
14 | target/arm/crypto_helper.c | 24 +++++-- | 13 | 2 files changed, 52 insertions(+), 52 deletions(-) |
15 | target/arm/translate-a64.c | 34 ++++----- | ||
16 | target/arm/translate-neon.inc.c | 124 +++++--------------------------- | ||
17 | target/arm/translate.c | 24 ++----- | ||
18 | 6 files changed, 67 insertions(+), 163 deletions(-) | ||
19 | 14 | ||
20 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 15 | diff --git a/fpu/softfloat.c b/fpu/softfloat.c |
21 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/helper.h | 17 | --- a/fpu/softfloat.c |
23 | +++ b/target/arm/helper.h | 18 | +++ b/fpu/softfloat.c |
24 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(crypto_aese, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 19 | @@ -XXX,XX +XXX,XX @@ void normalizeFloatx80Subnormal(uint64_t aSig, int32_t *zExpPtr, |
25 | DEF_HELPER_FLAGS_3(crypto_aesmc, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 20 | *zExpPtr = 1 - shiftCount; |
26 | 21 | } | |
27 | DEF_HELPER_FLAGS_4(crypto_sha1_3reg, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 22 | |
28 | -DEF_HELPER_FLAGS_2(crypto_sha1h, TCG_CALL_NO_RWG, void, ptr, ptr) | 23 | +/*---------------------------------------------------------------------------- |
29 | -DEF_HELPER_FLAGS_2(crypto_sha1su1, TCG_CALL_NO_RWG, void, ptr, ptr) | 24 | +| Takes two extended double-precision floating-point values `a' and `b', one |
30 | +DEF_HELPER_FLAGS_3(crypto_sha1h, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 25 | +| of which is a NaN, and returns the appropriate NaN result. If either `a' or |
31 | +DEF_HELPER_FLAGS_3(crypto_sha1su1, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 26 | +| `b' is a signaling NaN, the invalid exception is raised. |
32 | 27 | +*----------------------------------------------------------------------------*/ | |
33 | -DEF_HELPER_FLAGS_3(crypto_sha256h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | ||
34 | -DEF_HELPER_FLAGS_3(crypto_sha256h2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | ||
35 | -DEF_HELPER_FLAGS_2(crypto_sha256su0, TCG_CALL_NO_RWG, void, ptr, ptr) | ||
36 | -DEF_HELPER_FLAGS_3(crypto_sha256su1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | ||
37 | +DEF_HELPER_FLAGS_4(crypto_sha256h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
38 | +DEF_HELPER_FLAGS_4(crypto_sha256h2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
39 | +DEF_HELPER_FLAGS_3(crypto_sha256su0, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
40 | +DEF_HELPER_FLAGS_4(crypto_sha256su1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
41 | |||
42 | DEF_HELPER_FLAGS_4(crypto_sha512h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
43 | DEF_HELPER_FLAGS_4(crypto_sha512h2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
44 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/target/arm/neon-dp.decode | ||
47 | +++ b/target/arm/neon-dp.decode | ||
48 | @@ -XXX,XX +XXX,XX @@ VPADD_3s 1111 001 0 0 . .. .... .... 1011 . . . 1 .... @3same_q0 | ||
49 | |||
50 | VQRDMLAH_3s 1111 001 1 0 . .. .... .... 1011 ... 1 .... @3same | ||
51 | |||
52 | +@3same_crypto .... .... .... .... .... .... .... .... \ | ||
53 | + &3same vm=%vm_dp vn=%vn_dp vd=%vd_dp size=0 q=1 | ||
54 | + | 28 | + |
55 | SHA1_3s 1111 001 0 0 . optype:2 .... .... 1100 . 1 . 0 .... \ | 29 | +floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status) |
56 | vm=%vm_dp vn=%vn_dp vd=%vd_dp | 30 | +{ |
57 | -SHA256H_3s 1111 001 1 0 . 00 .... .... 1100 . 1 . 0 .... \ | 31 | + bool aIsLargerSignificand; |
58 | - vm=%vm_dp vn=%vn_dp vd=%vd_dp | 32 | + FloatClass a_cls, b_cls; |
59 | -SHA256H2_3s 1111 001 1 0 . 01 .... .... 1100 . 1 . 0 .... \ | ||
60 | - vm=%vm_dp vn=%vn_dp vd=%vd_dp | ||
61 | -SHA256SU1_3s 1111 001 1 0 . 10 .... .... 1100 . 1 . 0 .... \ | ||
62 | - vm=%vm_dp vn=%vn_dp vd=%vd_dp | ||
63 | +SHA256H_3s 1111 001 1 0 . 00 .... .... 1100 . 1 . 0 .... @3same_crypto | ||
64 | +SHA256H2_3s 1111 001 1 0 . 01 .... .... 1100 . 1 . 0 .... @3same_crypto | ||
65 | +SHA256SU1_3s 1111 001 1 0 . 10 .... .... 1100 . 1 . 0 .... @3same_crypto | ||
66 | |||
67 | VFMA_fp_3s 1111 001 0 0 . 0 . .... .... 1100 ... 1 .... @3same_fp | ||
68 | VFMS_fp_3s 1111 001 0 0 . 1 . .... .... 1100 ... 1 .... @3same_fp | ||
69 | diff --git a/target/arm/crypto_helper.c b/target/arm/crypto_helper.c | ||
70 | index XXXXXXX..XXXXXXX 100644 | ||
71 | --- a/target/arm/crypto_helper.c | ||
72 | +++ b/target/arm/crypto_helper.c | ||
73 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha1_3reg)(void *vd, void *vn, void *vm, uint32_t op) | ||
74 | rd[1] = d.l[1]; | ||
75 | } | ||
76 | |||
77 | -void HELPER(crypto_sha1h)(void *vd, void *vm) | ||
78 | +void HELPER(crypto_sha1h)(void *vd, void *vm, uint32_t desc) | ||
79 | { | ||
80 | uint64_t *rd = vd; | ||
81 | uint64_t *rm = vm; | ||
82 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha1h)(void *vd, void *vm) | ||
83 | |||
84 | rd[0] = m.l[0]; | ||
85 | rd[1] = m.l[1]; | ||
86 | + | 33 | + |
87 | + clear_tail_16(vd, desc); | 34 | + /* This is not complete, but is good enough for pickNaN. */ |
88 | } | 35 | + a_cls = (!floatx80_is_any_nan(a) |
89 | 36 | + ? float_class_normal | |
90 | -void HELPER(crypto_sha1su1)(void *vd, void *vm) | 37 | + : floatx80_is_signaling_nan(a, status) |
91 | +void HELPER(crypto_sha1su1)(void *vd, void *vm, uint32_t desc) | 38 | + ? float_class_snan |
92 | { | 39 | + : float_class_qnan); |
93 | uint64_t *rd = vd; | 40 | + b_cls = (!floatx80_is_any_nan(b) |
94 | uint64_t *rm = vm; | 41 | + ? float_class_normal |
95 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha1su1)(void *vd, void *vm) | 42 | + : floatx80_is_signaling_nan(b, status) |
96 | 43 | + ? float_class_snan | |
97 | rd[0] = d.l[0]; | 44 | + : float_class_qnan); |
98 | rd[1] = d.l[1]; | ||
99 | + | 45 | + |
100 | + clear_tail_16(vd, desc); | 46 | + if (is_snan(a_cls) || is_snan(b_cls)) { |
101 | } | 47 | + float_raise(float_flag_invalid, status); |
102 | |||
103 | /* | ||
104 | @@ -XXX,XX +XXX,XX @@ static uint32_t s1(uint32_t x) | ||
105 | return ror32(x, 17) ^ ror32(x, 19) ^ (x >> 10); | ||
106 | } | ||
107 | |||
108 | -void HELPER(crypto_sha256h)(void *vd, void *vn, void *vm) | ||
109 | +void HELPER(crypto_sha256h)(void *vd, void *vn, void *vm, uint32_t desc) | ||
110 | { | ||
111 | uint64_t *rd = vd; | ||
112 | uint64_t *rn = vn; | ||
113 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha256h)(void *vd, void *vn, void *vm) | ||
114 | |||
115 | rd[0] = d.l[0]; | ||
116 | rd[1] = d.l[1]; | ||
117 | + | ||
118 | + clear_tail_16(vd, desc); | ||
119 | } | ||
120 | |||
121 | -void HELPER(crypto_sha256h2)(void *vd, void *vn, void *vm) | ||
122 | +void HELPER(crypto_sha256h2)(void *vd, void *vn, void *vm, uint32_t desc) | ||
123 | { | ||
124 | uint64_t *rd = vd; | ||
125 | uint64_t *rn = vn; | ||
126 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha256h2)(void *vd, void *vn, void *vm) | ||
127 | |||
128 | rd[0] = d.l[0]; | ||
129 | rd[1] = d.l[1]; | ||
130 | + | ||
131 | + clear_tail_16(vd, desc); | ||
132 | } | ||
133 | |||
134 | -void HELPER(crypto_sha256su0)(void *vd, void *vm) | ||
135 | +void HELPER(crypto_sha256su0)(void *vd, void *vm, uint32_t desc) | ||
136 | { | ||
137 | uint64_t *rd = vd; | ||
138 | uint64_t *rm = vm; | ||
139 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha256su0)(void *vd, void *vm) | ||
140 | |||
141 | rd[0] = d.l[0]; | ||
142 | rd[1] = d.l[1]; | ||
143 | + | ||
144 | + clear_tail_16(vd, desc); | ||
145 | } | ||
146 | |||
147 | -void HELPER(crypto_sha256su1)(void *vd, void *vn, void *vm) | ||
148 | +void HELPER(crypto_sha256su1)(void *vd, void *vn, void *vm, uint32_t desc) | ||
149 | { | ||
150 | uint64_t *rd = vd; | ||
151 | uint64_t *rn = vn; | ||
152 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha256su1)(void *vd, void *vn, void *vm) | ||
153 | |||
154 | rd[0] = d.l[0]; | ||
155 | rd[1] = d.l[1]; | ||
156 | + | ||
157 | + clear_tail_16(vd, desc); | ||
158 | } | ||
159 | |||
160 | /* | ||
161 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
162 | index XXXXXXX..XXXXXXX 100644 | ||
163 | --- a/target/arm/translate-a64.c | ||
164 | +++ b/target/arm/translate-a64.c | ||
165 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha(DisasContext *s, uint32_t insn) | ||
166 | int rm = extract32(insn, 16, 5); | ||
167 | int rn = extract32(insn, 5, 5); | ||
168 | int rd = extract32(insn, 0, 5); | ||
169 | - CryptoThreeOpFn *genfn; | ||
170 | - TCGv_ptr tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr; | ||
171 | + gen_helper_gvec_3 *genfn; | ||
172 | bool feature; | ||
173 | |||
174 | if (size != 0) { | ||
175 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha(DisasContext *s, uint32_t insn) | ||
176 | return; | ||
177 | } | ||
178 | |||
179 | - tcg_rd_ptr = vec_full_reg_ptr(s, rd); | ||
180 | - tcg_rn_ptr = vec_full_reg_ptr(s, rn); | ||
181 | - tcg_rm_ptr = vec_full_reg_ptr(s, rm); | ||
182 | - | ||
183 | if (genfn) { | ||
184 | - genfn(tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr); | ||
185 | + gen_gvec_op3_ool(s, true, rd, rn, rm, 0, genfn); | ||
186 | } else { | ||
187 | TCGv_i32 tcg_opcode = tcg_const_i32(opcode); | ||
188 | + TCGv_ptr tcg_rd_ptr = vec_full_reg_ptr(s, rd); | ||
189 | + TCGv_ptr tcg_rn_ptr = vec_full_reg_ptr(s, rn); | ||
190 | + TCGv_ptr tcg_rm_ptr = vec_full_reg_ptr(s, rm); | ||
191 | |||
192 | gen_helper_crypto_sha1_3reg(tcg_rd_ptr, tcg_rn_ptr, | ||
193 | tcg_rm_ptr, tcg_opcode); | ||
194 | - tcg_temp_free_i32(tcg_opcode); | ||
195 | - } | ||
196 | |||
197 | - tcg_temp_free_ptr(tcg_rd_ptr); | ||
198 | - tcg_temp_free_ptr(tcg_rn_ptr); | ||
199 | - tcg_temp_free_ptr(tcg_rm_ptr); | ||
200 | + tcg_temp_free_i32(tcg_opcode); | ||
201 | + tcg_temp_free_ptr(tcg_rd_ptr); | ||
202 | + tcg_temp_free_ptr(tcg_rn_ptr); | ||
203 | + tcg_temp_free_ptr(tcg_rm_ptr); | ||
204 | + } | ||
205 | } | ||
206 | |||
207 | /* Crypto two-reg SHA | ||
208 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha(DisasContext *s, uint32_t insn) | ||
209 | int opcode = extract32(insn, 12, 5); | ||
210 | int rn = extract32(insn, 5, 5); | ||
211 | int rd = extract32(insn, 0, 5); | ||
212 | - CryptoTwoOpFn *genfn; | ||
213 | + gen_helper_gvec_2 *genfn; | ||
214 | bool feature; | ||
215 | - TCGv_ptr tcg_rd_ptr, tcg_rn_ptr; | ||
216 | |||
217 | if (size != 0) { | ||
218 | unallocated_encoding(s); | ||
219 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha(DisasContext *s, uint32_t insn) | ||
220 | if (!fp_access_check(s)) { | ||
221 | return; | ||
222 | } | ||
223 | - | ||
224 | - tcg_rd_ptr = vec_full_reg_ptr(s, rd); | ||
225 | - tcg_rn_ptr = vec_full_reg_ptr(s, rn); | ||
226 | - | ||
227 | - genfn(tcg_rd_ptr, tcg_rn_ptr); | ||
228 | - | ||
229 | - tcg_temp_free_ptr(tcg_rd_ptr); | ||
230 | - tcg_temp_free_ptr(tcg_rn_ptr); | ||
231 | + gen_gvec_op2_ool(s, true, rd, rn, 0, genfn); | ||
232 | } | ||
233 | |||
234 | static void gen_rax1_i64(TCGv_i64 d, TCGv_i64 n, TCGv_i64 m) | ||
235 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
236 | index XXXXXXX..XXXXXXX 100644 | ||
237 | --- a/target/arm/translate-neon.inc.c | ||
238 | +++ b/target/arm/translate-neon.inc.c | ||
239 | @@ -XXX,XX +XXX,XX @@ DO_3SAME_CMP(VCGE_S, TCG_COND_GE) | ||
240 | DO_3SAME_CMP(VCGE_U, TCG_COND_GEU) | ||
241 | DO_3SAME_CMP(VCEQ, TCG_COND_EQ) | ||
242 | |||
243 | -static void gen_VMUL_p_3s(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, | ||
244 | - uint32_t rm_ofs, uint32_t oprsz, uint32_t maxsz) | ||
245 | -{ | ||
246 | - tcg_gen_gvec_3_ool(rd_ofs, rn_ofs, rm_ofs, oprsz, maxsz, | ||
247 | - 0, gen_helper_gvec_pmul_b); | ||
248 | -} | ||
249 | +#define WRAP_OOL_FN(WRAPNAME, FUNC) \ | ||
250 | + static void WRAPNAME(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, \ | ||
251 | + uint32_t rm_ofs, uint32_t oprsz, uint32_t maxsz) \ | ||
252 | + { \ | ||
253 | + tcg_gen_gvec_3_ool(rd_ofs, rn_ofs, rm_ofs, oprsz, maxsz, 0, FUNC); \ | ||
254 | + } | 48 | + } |
255 | + | 49 | + |
256 | +WRAP_OOL_FN(gen_VMUL_p_3s, gen_helper_gvec_pmul_b) | 50 | + if (status->default_nan_mode) { |
257 | 51 | + return floatx80_default_nan(status); | |
258 | static bool trans_VMUL_p_3s(DisasContext *s, arg_3same *a) | 52 | + } |
259 | { | 53 | + |
260 | @@ -XXX,XX +XXX,XX @@ static bool trans_SHA1_3s(DisasContext *s, arg_SHA1_3s *a) | 54 | + if (a.low < b.low) { |
261 | return true; | 55 | + aIsLargerSignificand = 0; |
56 | + } else if (b.low < a.low) { | ||
57 | + aIsLargerSignificand = 1; | ||
58 | + } else { | ||
59 | + aIsLargerSignificand = (a.high < b.high) ? 1 : 0; | ||
60 | + } | ||
61 | + | ||
62 | + if (pickNaN(a_cls, b_cls, aIsLargerSignificand, status)) { | ||
63 | + if (is_snan(b_cls)) { | ||
64 | + return floatx80_silence_nan(b, status); | ||
65 | + } | ||
66 | + return b; | ||
67 | + } else { | ||
68 | + if (is_snan(a_cls)) { | ||
69 | + return floatx80_silence_nan(a, status); | ||
70 | + } | ||
71 | + return a; | ||
72 | + } | ||
73 | +} | ||
74 | + | ||
75 | /*---------------------------------------------------------------------------- | ||
76 | | Takes an abstract floating-point value having sign `zSign', exponent `zExp', | ||
77 | | and extended significand formed by the concatenation of `zSig0' and `zSig1', | ||
78 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
79 | index XXXXXXX..XXXXXXX 100644 | ||
80 | --- a/fpu/softfloat-specialize.c.inc | ||
81 | +++ b/fpu/softfloat-specialize.c.inc | ||
82 | @@ -XXX,XX +XXX,XX @@ floatx80 floatx80_silence_nan(floatx80 a, float_status *status) | ||
83 | return a; | ||
262 | } | 84 | } |
263 | 85 | ||
264 | -static bool trans_SHA256H_3s(DisasContext *s, arg_SHA256H_3s *a) | 86 | -/*---------------------------------------------------------------------------- |
87 | -| Takes two extended double-precision floating-point values `a' and `b', one | ||
88 | -| of which is a NaN, and returns the appropriate NaN result. If either `a' or | ||
89 | -| `b' is a signaling NaN, the invalid exception is raised. | ||
90 | -*----------------------------------------------------------------------------*/ | ||
91 | - | ||
92 | -floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status) | ||
265 | -{ | 93 | -{ |
266 | - TCGv_ptr ptr1, ptr2, ptr3; | 94 | - bool aIsLargerSignificand; |
95 | - FloatClass a_cls, b_cls; | ||
267 | - | 96 | - |
268 | - if (!arm_dc_feature(s, ARM_FEATURE_NEON) || | 97 | - /* This is not complete, but is good enough for pickNaN. */ |
269 | - !dc_isar_feature(aa32_sha2, s)) { | 98 | - a_cls = (!floatx80_is_any_nan(a) |
270 | - return false; | 99 | - ? float_class_normal |
271 | +#define DO_SHA2(NAME, FUNC) \ | 100 | - : floatx80_is_signaling_nan(a, status) |
272 | + WRAP_OOL_FN(gen_##NAME##_3s, FUNC) \ | 101 | - ? float_class_snan |
273 | + static bool trans_##NAME##_3s(DisasContext *s, arg_3same *a) \ | 102 | - : float_class_qnan); |
274 | + { \ | 103 | - b_cls = (!floatx80_is_any_nan(b) |
275 | + if (!dc_isar_feature(aa32_sha2, s)) { \ | 104 | - ? float_class_normal |
276 | + return false; \ | 105 | - : floatx80_is_signaling_nan(b, status) |
277 | + } \ | 106 | - ? float_class_snan |
278 | + return do_3same(s, a, gen_##NAME##_3s); \ | 107 | - : float_class_qnan); |
279 | } | 108 | - |
280 | 109 | - if (is_snan(a_cls) || is_snan(b_cls)) { | |
281 | - /* UNDEF accesses to D16-D31 if they don't exist. */ | 110 | - float_raise(float_flag_invalid, status); |
282 | - if (!dc_isar_feature(aa32_simd_r32, s) && | ||
283 | - ((a->vd | a->vn | a->vm) & 0x10)) { | ||
284 | - return false; | ||
285 | - } | 111 | - } |
286 | - | 112 | - |
287 | - if ((a->vn | a->vm | a->vd) & 1) { | 113 | - if (status->default_nan_mode) { |
288 | - return false; | 114 | - return floatx80_default_nan(status); |
289 | - } | 115 | - } |
290 | - | 116 | - |
291 | - if (!vfp_access_check(s)) { | 117 | - if (a.low < b.low) { |
292 | - return true; | 118 | - aIsLargerSignificand = 0; |
119 | - } else if (b.low < a.low) { | ||
120 | - aIsLargerSignificand = 1; | ||
121 | - } else { | ||
122 | - aIsLargerSignificand = (a.high < b.high) ? 1 : 0; | ||
293 | - } | 123 | - } |
294 | - | 124 | - |
295 | - ptr1 = vfp_reg_ptr(true, a->vd); | 125 | - if (pickNaN(a_cls, b_cls, aIsLargerSignificand, status)) { |
296 | - ptr2 = vfp_reg_ptr(true, a->vn); | 126 | - if (is_snan(b_cls)) { |
297 | - ptr3 = vfp_reg_ptr(true, a->vm); | 127 | - return floatx80_silence_nan(b, status); |
298 | - gen_helper_crypto_sha256h(ptr1, ptr2, ptr3); | 128 | - } |
299 | - tcg_temp_free_ptr(ptr1); | 129 | - return b; |
300 | - tcg_temp_free_ptr(ptr2); | 130 | - } else { |
301 | - tcg_temp_free_ptr(ptr3); | 131 | - if (is_snan(a_cls)) { |
302 | - | 132 | - return floatx80_silence_nan(a, status); |
303 | - return true; | 133 | - } |
134 | - return a; | ||
135 | - } | ||
304 | -} | 136 | -} |
305 | - | 137 | - |
306 | -static bool trans_SHA256H2_3s(DisasContext *s, arg_SHA256H2_3s *a) | 138 | /*---------------------------------------------------------------------------- |
307 | -{ | 139 | | Returns 1 if the quadruple-precision floating-point value `a' is a quiet |
308 | - TCGv_ptr ptr1, ptr2, ptr3; | 140 | | NaN; otherwise returns 0. |
309 | - | ||
310 | - if (!arm_dc_feature(s, ARM_FEATURE_NEON) || | ||
311 | - !dc_isar_feature(aa32_sha2, s)) { | ||
312 | - return false; | ||
313 | - } | ||
314 | - | ||
315 | - /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
316 | - if (!dc_isar_feature(aa32_simd_r32, s) && | ||
317 | - ((a->vd | a->vn | a->vm) & 0x10)) { | ||
318 | - return false; | ||
319 | - } | ||
320 | - | ||
321 | - if ((a->vn | a->vm | a->vd) & 1) { | ||
322 | - return false; | ||
323 | - } | ||
324 | - | ||
325 | - if (!vfp_access_check(s)) { | ||
326 | - return true; | ||
327 | - } | ||
328 | - | ||
329 | - ptr1 = vfp_reg_ptr(true, a->vd); | ||
330 | - ptr2 = vfp_reg_ptr(true, a->vn); | ||
331 | - ptr3 = vfp_reg_ptr(true, a->vm); | ||
332 | - gen_helper_crypto_sha256h2(ptr1, ptr2, ptr3); | ||
333 | - tcg_temp_free_ptr(ptr1); | ||
334 | - tcg_temp_free_ptr(ptr2); | ||
335 | - tcg_temp_free_ptr(ptr3); | ||
336 | - | ||
337 | - return true; | ||
338 | -} | ||
339 | - | ||
340 | -static bool trans_SHA256SU1_3s(DisasContext *s, arg_SHA256SU1_3s *a) | ||
341 | -{ | ||
342 | - TCGv_ptr ptr1, ptr2, ptr3; | ||
343 | - | ||
344 | - if (!arm_dc_feature(s, ARM_FEATURE_NEON) || | ||
345 | - !dc_isar_feature(aa32_sha2, s)) { | ||
346 | - return false; | ||
347 | - } | ||
348 | - | ||
349 | - /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
350 | - if (!dc_isar_feature(aa32_simd_r32, s) && | ||
351 | - ((a->vd | a->vn | a->vm) & 0x10)) { | ||
352 | - return false; | ||
353 | - } | ||
354 | - | ||
355 | - if ((a->vn | a->vm | a->vd) & 1) { | ||
356 | - return false; | ||
357 | - } | ||
358 | - | ||
359 | - if (!vfp_access_check(s)) { | ||
360 | - return true; | ||
361 | - } | ||
362 | - | ||
363 | - ptr1 = vfp_reg_ptr(true, a->vd); | ||
364 | - ptr2 = vfp_reg_ptr(true, a->vn); | ||
365 | - ptr3 = vfp_reg_ptr(true, a->vm); | ||
366 | - gen_helper_crypto_sha256su1(ptr1, ptr2, ptr3); | ||
367 | - tcg_temp_free_ptr(ptr1); | ||
368 | - tcg_temp_free_ptr(ptr2); | ||
369 | - tcg_temp_free_ptr(ptr3); | ||
370 | - | ||
371 | - return true; | ||
372 | -} | ||
373 | +DO_SHA2(SHA256H, gen_helper_crypto_sha256h) | ||
374 | +DO_SHA2(SHA256H2, gen_helper_crypto_sha256h2) | ||
375 | +DO_SHA2(SHA256SU1, gen_helper_crypto_sha256su1) | ||
376 | |||
377 | #define DO_3SAME_64(INSN, FUNC) \ | ||
378 | static void gen_##INSN##_3s(unsigned vece, uint32_t rd_ofs, \ | ||
379 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
380 | index XXXXXXX..XXXXXXX 100644 | ||
381 | --- a/target/arm/translate.c | ||
382 | +++ b/target/arm/translate.c | ||
383 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
384 | int vec_size; | ||
385 | uint32_t imm; | ||
386 | TCGv_i32 tmp, tmp2, tmp3, tmp4, tmp5; | ||
387 | - TCGv_ptr ptr1, ptr2; | ||
388 | + TCGv_ptr ptr1; | ||
389 | TCGv_i64 tmp64; | ||
390 | |||
391 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
392 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
393 | if (!dc_isar_feature(aa32_sha1, s) || ((rm | rd) & 1)) { | ||
394 | return 1; | ||
395 | } | ||
396 | - ptr1 = vfp_reg_ptr(true, rd); | ||
397 | - ptr2 = vfp_reg_ptr(true, rm); | ||
398 | - | ||
399 | - gen_helper_crypto_sha1h(ptr1, ptr2); | ||
400 | - | ||
401 | - tcg_temp_free_ptr(ptr1); | ||
402 | - tcg_temp_free_ptr(ptr2); | ||
403 | + tcg_gen_gvec_2_ool(rd_ofs, rm_ofs, 16, 16, 0, | ||
404 | + gen_helper_crypto_sha1h); | ||
405 | break; | ||
406 | case NEON_2RM_SHA1SU1: | ||
407 | if ((rm | rd) & 1) { | ||
408 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
409 | } else if (!dc_isar_feature(aa32_sha1, s)) { | ||
410 | return 1; | ||
411 | } | ||
412 | - ptr1 = vfp_reg_ptr(true, rd); | ||
413 | - ptr2 = vfp_reg_ptr(true, rm); | ||
414 | - if (q) { | ||
415 | - gen_helper_crypto_sha256su0(ptr1, ptr2); | ||
416 | - } else { | ||
417 | - gen_helper_crypto_sha1su1(ptr1, ptr2); | ||
418 | - } | ||
419 | - tcg_temp_free_ptr(ptr1); | ||
420 | - tcg_temp_free_ptr(ptr2); | ||
421 | + tcg_gen_gvec_2_ool(rd_ofs, rm_ofs, 16, 16, 0, | ||
422 | + q ? gen_helper_crypto_sha256su0 | ||
423 | + : gen_helper_crypto_sha1su1); | ||
424 | break; | ||
425 | - | ||
426 | case NEON_2RM_VMVN: | ||
427 | tcg_gen_gvec_not(0, rd_ofs, rm_ofs, vec_size, vec_size); | ||
428 | break; | ||
429 | -- | 141 | -- |
430 | 2.20.1 | 142 | 2.34.1 |
431 | |||
432 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Rather than passing an opcode to a helper, fully decode the | 3 | Unpacking and repacking the parts may be slightly more work |
4 | operation at translate time. Use clear_tail_16 to zap the | 4 | than we did before, but we get to reuse more code. For a |
5 | balance of the SVE register with the AdvSIMD write. | 5 | code path handling exceptional values, this is an improvement. |
6 | 6 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20200514212831.31248-6-richard.henderson@linaro.org | 8 | Message-id: 20241203203949.483774-8-richard.henderson@linaro.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | 11 | --- |
12 | target/arm/helper.h | 5 +- | 12 | fpu/softfloat.c | 43 +++++-------------------------------------- |
13 | target/arm/neon-dp.decode | 6 +- | 13 | 1 file changed, 5 insertions(+), 38 deletions(-) |
14 | target/arm/crypto_helper.c | 99 +++++++++++++++++++++------------ | ||
15 | target/arm/translate-a64.c | 29 ++++------ | ||
16 | target/arm/translate-neon.inc.c | 46 ++++----------- | ||
17 | 5 files changed, 93 insertions(+), 92 deletions(-) | ||
18 | 14 | ||
19 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 15 | diff --git a/fpu/softfloat.c b/fpu/softfloat.c |
20 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/helper.h | 17 | --- a/fpu/softfloat.c |
22 | +++ b/target/arm/helper.h | 18 | +++ b/fpu/softfloat.c |
23 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_2(neon_qzip32, TCG_CALL_NO_RWG, void, ptr, ptr) | 19 | @@ -XXX,XX +XXX,XX @@ void normalizeFloatx80Subnormal(uint64_t aSig, int32_t *zExpPtr, |
24 | DEF_HELPER_FLAGS_4(crypto_aese, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | 20 | |
25 | DEF_HELPER_FLAGS_3(crypto_aesmc, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 21 | floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status) |
26 | |||
27 | -DEF_HELPER_FLAGS_4(crypto_sha1_3reg, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_4(crypto_sha1su0, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
29 | +DEF_HELPER_FLAGS_4(crypto_sha1c, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
30 | +DEF_HELPER_FLAGS_4(crypto_sha1p, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_4(crypto_sha1m, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
32 | DEF_HELPER_FLAGS_3(crypto_sha1h, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
33 | DEF_HELPER_FLAGS_3(crypto_sha1su1, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
34 | |||
35 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/target/arm/neon-dp.decode | ||
38 | +++ b/target/arm/neon-dp.decode | ||
39 | @@ -XXX,XX +XXX,XX @@ VQRDMLAH_3s 1111 001 1 0 . .. .... .... 1011 ... 1 .... @3same | ||
40 | @3same_crypto .... .... .... .... .... .... .... .... \ | ||
41 | &3same vm=%vm_dp vn=%vn_dp vd=%vd_dp size=0 q=1 | ||
42 | |||
43 | -SHA1_3s 1111 001 0 0 . optype:2 .... .... 1100 . 1 . 0 .... \ | ||
44 | - vm=%vm_dp vn=%vn_dp vd=%vd_dp | ||
45 | +SHA1C_3s 1111 001 0 0 . 00 .... .... 1100 . 1 . 0 .... @3same_crypto | ||
46 | +SHA1P_3s 1111 001 0 0 . 01 .... .... 1100 . 1 . 0 .... @3same_crypto | ||
47 | +SHA1M_3s 1111 001 0 0 . 10 .... .... 1100 . 1 . 0 .... @3same_crypto | ||
48 | +SHA1SU0_3s 1111 001 0 0 . 11 .... .... 1100 . 1 . 0 .... @3same_crypto | ||
49 | SHA256H_3s 1111 001 1 0 . 00 .... .... 1100 . 1 . 0 .... @3same_crypto | ||
50 | SHA256H2_3s 1111 001 1 0 . 01 .... .... 1100 . 1 . 0 .... @3same_crypto | ||
51 | SHA256SU1_3s 1111 001 1 0 . 10 .... .... 1100 . 1 . 0 .... @3same_crypto | ||
52 | diff --git a/target/arm/crypto_helper.c b/target/arm/crypto_helper.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/target/arm/crypto_helper.c | ||
55 | +++ b/target/arm/crypto_helper.c | ||
56 | @@ -XXX,XX +XXX,XX @@ union CRYPTO_STATE { | ||
57 | }; | ||
58 | |||
59 | #ifdef HOST_WORDS_BIGENDIAN | ||
60 | -#define CR_ST_BYTE(state, i) (state.bytes[(15 - (i)) ^ 8]) | ||
61 | -#define CR_ST_WORD(state, i) (state.words[(3 - (i)) ^ 2]) | ||
62 | +#define CR_ST_BYTE(state, i) ((state).bytes[(15 - (i)) ^ 8]) | ||
63 | +#define CR_ST_WORD(state, i) ((state).words[(3 - (i)) ^ 2]) | ||
64 | #else | ||
65 | -#define CR_ST_BYTE(state, i) (state.bytes[i]) | ||
66 | -#define CR_ST_WORD(state, i) (state.words[i]) | ||
67 | +#define CR_ST_BYTE(state, i) ((state).bytes[i]) | ||
68 | +#define CR_ST_WORD(state, i) ((state).words[i]) | ||
69 | #endif | ||
70 | |||
71 | /* | ||
72 | @@ -XXX,XX +XXX,XX @@ static uint32_t maj(uint32_t x, uint32_t y, uint32_t z) | ||
73 | return (x & y) | ((x | y) & z); | ||
74 | } | ||
75 | |||
76 | -void HELPER(crypto_sha1_3reg)(void *vd, void *vn, void *vm, uint32_t op) | ||
77 | +void HELPER(crypto_sha1su0)(void *vd, void *vn, void *vm, uint32_t desc) | ||
78 | +{ | ||
79 | + uint64_t *d = vd, *n = vn, *m = vm; | ||
80 | + uint64_t d0, d1; | ||
81 | + | ||
82 | + d0 = d[1] ^ d[0] ^ m[0]; | ||
83 | + d1 = n[0] ^ d[1] ^ m[1]; | ||
84 | + d[0] = d0; | ||
85 | + d[1] = d1; | ||
86 | + | ||
87 | + clear_tail_16(vd, desc); | ||
88 | +} | ||
89 | + | ||
90 | +static inline void crypto_sha1_3reg(uint64_t *rd, uint64_t *rn, | ||
91 | + uint64_t *rm, uint32_t desc, | ||
92 | + uint32_t (*fn)(union CRYPTO_STATE *d)) | ||
93 | { | 22 | { |
94 | - uint64_t *rd = vd; | 23 | - bool aIsLargerSignificand; |
95 | - uint64_t *rn = vn; | 24 | - FloatClass a_cls, b_cls; |
96 | - uint64_t *rm = vm; | 25 | + FloatParts128 pa, pb, *pr; |
97 | union CRYPTO_STATE d = { .l = { rd[0], rd[1] } }; | 26 | |
98 | union CRYPTO_STATE n = { .l = { rn[0], rn[1] } }; | 27 | - /* This is not complete, but is good enough for pickNaN. */ |
99 | union CRYPTO_STATE m = { .l = { rm[0], rm[1] } }; | 28 | - a_cls = (!floatx80_is_any_nan(a) |
100 | + int i; | 29 | - ? float_class_normal |
101 | 30 | - : floatx80_is_signaling_nan(a, status) | |
102 | - if (op == 3) { /* sha1su0 */ | 31 | - ? float_class_snan |
103 | - d.l[0] ^= d.l[1] ^ m.l[0]; | 32 | - : float_class_qnan); |
104 | - d.l[1] ^= n.l[0] ^ m.l[1]; | 33 | - b_cls = (!floatx80_is_any_nan(b) |
105 | - } else { | 34 | - ? float_class_normal |
106 | - int i; | 35 | - : floatx80_is_signaling_nan(b, status) |
107 | + for (i = 0; i < 4; i++) { | 36 | - ? float_class_snan |
108 | + uint32_t t = fn(&d); | 37 | - : float_class_qnan); |
109 | |||
110 | - for (i = 0; i < 4; i++) { | ||
111 | - uint32_t t; | ||
112 | + t += rol32(CR_ST_WORD(d, 0), 5) + CR_ST_WORD(n, 0) | ||
113 | + + CR_ST_WORD(m, i); | ||
114 | |||
115 | - switch (op) { | ||
116 | - case 0: /* sha1c */ | ||
117 | - t = cho(CR_ST_WORD(d, 1), CR_ST_WORD(d, 2), CR_ST_WORD(d, 3)); | ||
118 | - break; | ||
119 | - case 1: /* sha1p */ | ||
120 | - t = par(CR_ST_WORD(d, 1), CR_ST_WORD(d, 2), CR_ST_WORD(d, 3)); | ||
121 | - break; | ||
122 | - case 2: /* sha1m */ | ||
123 | - t = maj(CR_ST_WORD(d, 1), CR_ST_WORD(d, 2), CR_ST_WORD(d, 3)); | ||
124 | - break; | ||
125 | - default: | ||
126 | - g_assert_not_reached(); | ||
127 | - } | ||
128 | - t += rol32(CR_ST_WORD(d, 0), 5) + CR_ST_WORD(n, 0) | ||
129 | - + CR_ST_WORD(m, i); | ||
130 | - | 38 | - |
131 | - CR_ST_WORD(n, 0) = CR_ST_WORD(d, 3); | 39 | - if (is_snan(a_cls) || is_snan(b_cls)) { |
132 | - CR_ST_WORD(d, 3) = CR_ST_WORD(d, 2); | 40 | - float_raise(float_flag_invalid, status); |
133 | - CR_ST_WORD(d, 2) = ror32(CR_ST_WORD(d, 1), 2); | ||
134 | - CR_ST_WORD(d, 1) = CR_ST_WORD(d, 0); | ||
135 | - CR_ST_WORD(d, 0) = t; | ||
136 | - } | ||
137 | + CR_ST_WORD(n, 0) = CR_ST_WORD(d, 3); | ||
138 | + CR_ST_WORD(d, 3) = CR_ST_WORD(d, 2); | ||
139 | + CR_ST_WORD(d, 2) = ror32(CR_ST_WORD(d, 1), 2); | ||
140 | + CR_ST_WORD(d, 1) = CR_ST_WORD(d, 0); | ||
141 | + CR_ST_WORD(d, 0) = t; | ||
142 | } | ||
143 | rd[0] = d.l[0]; | ||
144 | rd[1] = d.l[1]; | ||
145 | + | ||
146 | + clear_tail_16(rd, desc); | ||
147 | +} | ||
148 | + | ||
149 | +static uint32_t do_sha1c(union CRYPTO_STATE *d) | ||
150 | +{ | ||
151 | + return cho(CR_ST_WORD(*d, 1), CR_ST_WORD(*d, 2), CR_ST_WORD(*d, 3)); | ||
152 | +} | ||
153 | + | ||
154 | +void HELPER(crypto_sha1c)(void *vd, void *vn, void *vm, uint32_t desc) | ||
155 | +{ | ||
156 | + crypto_sha1_3reg(vd, vn, vm, desc, do_sha1c); | ||
157 | +} | ||
158 | + | ||
159 | +static uint32_t do_sha1p(union CRYPTO_STATE *d) | ||
160 | +{ | ||
161 | + return par(CR_ST_WORD(*d, 1), CR_ST_WORD(*d, 2), CR_ST_WORD(*d, 3)); | ||
162 | +} | ||
163 | + | ||
164 | +void HELPER(crypto_sha1p)(void *vd, void *vn, void *vm, uint32_t desc) | ||
165 | +{ | ||
166 | + crypto_sha1_3reg(vd, vn, vm, desc, do_sha1p); | ||
167 | +} | ||
168 | + | ||
169 | +static uint32_t do_sha1m(union CRYPTO_STATE *d) | ||
170 | +{ | ||
171 | + return maj(CR_ST_WORD(*d, 1), CR_ST_WORD(*d, 2), CR_ST_WORD(*d, 3)); | ||
172 | +} | ||
173 | + | ||
174 | +void HELPER(crypto_sha1m)(void *vd, void *vn, void *vm, uint32_t desc) | ||
175 | +{ | ||
176 | + crypto_sha1_3reg(vd, vn, vm, desc, do_sha1m); | ||
177 | } | ||
178 | |||
179 | void HELPER(crypto_sha1h)(void *vd, void *vm, uint32_t desc) | ||
180 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
181 | index XXXXXXX..XXXXXXX 100644 | ||
182 | --- a/target/arm/translate-a64.c | ||
183 | +++ b/target/arm/translate-a64.c | ||
184 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha(DisasContext *s, uint32_t insn) | ||
185 | |||
186 | switch (opcode) { | ||
187 | case 0: /* SHA1C */ | ||
188 | + genfn = gen_helper_crypto_sha1c; | ||
189 | + feature = dc_isar_feature(aa64_sha1, s); | ||
190 | + break; | ||
191 | case 1: /* SHA1P */ | ||
192 | + genfn = gen_helper_crypto_sha1p; | ||
193 | + feature = dc_isar_feature(aa64_sha1, s); | ||
194 | + break; | ||
195 | case 2: /* SHA1M */ | ||
196 | + genfn = gen_helper_crypto_sha1m; | ||
197 | + feature = dc_isar_feature(aa64_sha1, s); | ||
198 | + break; | ||
199 | case 3: /* SHA1SU0 */ | ||
200 | - genfn = NULL; | ||
201 | + genfn = gen_helper_crypto_sha1su0; | ||
202 | feature = dc_isar_feature(aa64_sha1, s); | ||
203 | break; | ||
204 | case 4: /* SHA256H */ | ||
205 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha(DisasContext *s, uint32_t insn) | ||
206 | if (!fp_access_check(s)) { | ||
207 | return; | ||
208 | } | ||
209 | - | ||
210 | - if (genfn) { | ||
211 | - gen_gvec_op3_ool(s, true, rd, rn, rm, 0, genfn); | ||
212 | - } else { | ||
213 | - TCGv_i32 tcg_opcode = tcg_const_i32(opcode); | ||
214 | - TCGv_ptr tcg_rd_ptr = vec_full_reg_ptr(s, rd); | ||
215 | - TCGv_ptr tcg_rn_ptr = vec_full_reg_ptr(s, rn); | ||
216 | - TCGv_ptr tcg_rm_ptr = vec_full_reg_ptr(s, rm); | ||
217 | - | ||
218 | - gen_helper_crypto_sha1_3reg(tcg_rd_ptr, tcg_rn_ptr, | ||
219 | - tcg_rm_ptr, tcg_opcode); | ||
220 | - | ||
221 | - tcg_temp_free_i32(tcg_opcode); | ||
222 | - tcg_temp_free_ptr(tcg_rd_ptr); | ||
223 | - tcg_temp_free_ptr(tcg_rn_ptr); | ||
224 | - tcg_temp_free_ptr(tcg_rm_ptr); | ||
225 | - } | ||
226 | + gen_gvec_op3_ool(s, true, rd, rn, rm, 0, genfn); | ||
227 | } | ||
228 | |||
229 | /* Crypto two-reg SHA | ||
230 | diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c | ||
231 | index XXXXXXX..XXXXXXX 100644 | ||
232 | --- a/target/arm/translate-neon.inc.c | ||
233 | +++ b/target/arm/translate-neon.inc.c | ||
234 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMUL_p_3s(DisasContext *s, arg_3same *a) | ||
235 | DO_VQRDMLAH(VQRDMLAH, gen_gvec_sqrdmlah_qc) | ||
236 | DO_VQRDMLAH(VQRDMLSH, gen_gvec_sqrdmlsh_qc) | ||
237 | |||
238 | -static bool trans_SHA1_3s(DisasContext *s, arg_SHA1_3s *a) | ||
239 | -{ | ||
240 | - TCGv_ptr ptr1, ptr2, ptr3; | ||
241 | - TCGv_i32 tmp; | ||
242 | - | ||
243 | - if (!arm_dc_feature(s, ARM_FEATURE_NEON) || | ||
244 | - !dc_isar_feature(aa32_sha1, s)) { | ||
245 | - return false; | ||
246 | +#define DO_SHA1(NAME, FUNC) \ | ||
247 | + WRAP_OOL_FN(gen_##NAME##_3s, FUNC) \ | ||
248 | + static bool trans_##NAME##_3s(DisasContext *s, arg_3same *a) \ | ||
249 | + { \ | ||
250 | + if (!dc_isar_feature(aa32_sha1, s)) { \ | ||
251 | + return false; \ | ||
252 | + } \ | ||
253 | + return do_3same(s, a, gen_##NAME##_3s); \ | ||
254 | } | ||
255 | |||
256 | - /* UNDEF accesses to D16-D31 if they don't exist. */ | ||
257 | - if (!dc_isar_feature(aa32_simd_r32, s) && | ||
258 | - ((a->vd | a->vn | a->vm) & 0x10)) { | ||
259 | - return false; | ||
260 | - } | 41 | - } |
261 | - | 42 | - |
262 | - if ((a->vn | a->vm | a->vd) & 1) { | 43 | - if (status->default_nan_mode) { |
263 | - return false; | 44 | + if (!floatx80_unpack_canonical(&pa, a, status) || |
45 | + !floatx80_unpack_canonical(&pb, b, status)) { | ||
46 | return floatx80_default_nan(status); | ||
47 | } | ||
48 | |||
49 | - if (a.low < b.low) { | ||
50 | - aIsLargerSignificand = 0; | ||
51 | - } else if (b.low < a.low) { | ||
52 | - aIsLargerSignificand = 1; | ||
53 | - } else { | ||
54 | - aIsLargerSignificand = (a.high < b.high) ? 1 : 0; | ||
264 | - } | 55 | - } |
265 | - | 56 | - |
266 | - if (!vfp_access_check(s)) { | 57 | - if (pickNaN(a_cls, b_cls, aIsLargerSignificand, status)) { |
267 | - return true; | 58 | - if (is_snan(b_cls)) { |
59 | - return floatx80_silence_nan(b, status); | ||
60 | - } | ||
61 | - return b; | ||
62 | - } else { | ||
63 | - if (is_snan(a_cls)) { | ||
64 | - return floatx80_silence_nan(a, status); | ||
65 | - } | ||
66 | - return a; | ||
268 | - } | 67 | - } |
269 | - | 68 | + pr = parts_pick_nan(&pa, &pb, status); |
270 | - ptr1 = vfp_reg_ptr(true, a->vd); | 69 | + return floatx80_round_pack_canonical(pr, status); |
271 | - ptr2 = vfp_reg_ptr(true, a->vn); | 70 | } |
272 | - ptr3 = vfp_reg_ptr(true, a->vm); | 71 | |
273 | - tmp = tcg_const_i32(a->optype); | 72 | /*---------------------------------------------------------------------------- |
274 | - gen_helper_crypto_sha1_3reg(ptr1, ptr2, ptr3, tmp); | ||
275 | - tcg_temp_free_i32(tmp); | ||
276 | - tcg_temp_free_ptr(ptr1); | ||
277 | - tcg_temp_free_ptr(ptr2); | ||
278 | - tcg_temp_free_ptr(ptr3); | ||
279 | - | ||
280 | - return true; | ||
281 | -} | ||
282 | +DO_SHA1(SHA1C, gen_helper_crypto_sha1c) | ||
283 | +DO_SHA1(SHA1P, gen_helper_crypto_sha1p) | ||
284 | +DO_SHA1(SHA1M, gen_helper_crypto_sha1m) | ||
285 | +DO_SHA1(SHA1SU0, gen_helper_crypto_sha1su0) | ||
286 | |||
287 | #define DO_SHA2(NAME, FUNC) \ | ||
288 | WRAP_OOL_FN(gen_##NAME##_3s, FUNC) \ | ||
289 | -- | 73 | -- |
290 | 2.20.1 | 74 | 2.34.1 |
291 | |||
292 | diff view generated by jsdifflib |
1 | From: Paul Zimmerman <pauldzim@gmail.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Add the dwc-hsotg (dwc2) USB host controller emulation code. | 3 | Inline pickNaN into its only caller. This makes one assert |
4 | Based on hw/usb/hcd-ehci.c and hw/usb/hcd-ohci.c. | 4 | redundant with the immediately preceding IF. |
5 | 5 | ||
6 | Note that to use this with the dwc-otg driver in the Raspbian | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | kernel, you must pass the option "dwc_otg.fiq_fsm_enable=0" on | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | the kernel command line. | 8 | Message-id: 20241203203949.483774-9-richard.henderson@linaro.org |
9 | |||
10 | Emulation of slave mode and of descriptor-DMA mode has not been | ||
11 | implemented yet. These modes are seldom used. | ||
12 | |||
13 | I have used some on-line sources of information while developing | ||
14 | this emulation, including: | ||
15 | |||
16 | http://www.capital-micro.com/PDF/CME-M7_Family_User_Guide_EN.pdf | ||
17 | which has a pretty complete description of the controller starting | ||
18 | on page 370. | ||
19 | |||
20 | https://sourceforge.net/p/wive-ng/wive-ng-mt/ci/master/tree/docs/DataSheets/RT3050_5x_V2.0_081408_0902.pdf | ||
21 | which has a description of the controller registers starting on | ||
22 | page 130. | ||
23 | |||
24 | Thanks to Felippe Mathieu-Daude for providing a cleaner method | ||
25 | of implementing the memory regions for the controller registers. | ||
26 | |||
27 | Signed-off-by: Paul Zimmerman <pauldzim@gmail.com> | ||
28 | Message-id: 20200520235349.21215-5-pauldzim@gmail.com | ||
29 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
30 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
31 | --- | 10 | --- |
32 | hw/usb/hcd-dwc2.c | 1417 ++++++++++++++++++++++++++++++++++++++++++ | 11 | fpu/softfloat-parts.c.inc | 82 +++++++++++++++++++++++++---- |
33 | hw/usb/Kconfig | 5 + | 12 | fpu/softfloat-specialize.c.inc | 96 ---------------------------------- |
34 | hw/usb/Makefile.objs | 1 + | 13 | 2 files changed, 73 insertions(+), 105 deletions(-) |
35 | hw/usb/trace-events | 50 ++ | 14 | |
36 | 4 files changed, 1473 insertions(+) | 15 | diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc |
37 | create mode 100644 hw/usb/hcd-dwc2.c | 16 | index XXXXXXX..XXXXXXX 100644 |
38 | 17 | --- a/fpu/softfloat-parts.c.inc | |
39 | diff --git a/hw/usb/hcd-dwc2.c b/hw/usb/hcd-dwc2.c | 18 | +++ b/fpu/softfloat-parts.c.inc |
40 | new file mode 100644 | 19 | @@ -XXX,XX +XXX,XX @@ static void partsN(return_nan)(FloatPartsN *a, float_status *s) |
41 | index XXXXXXX..XXXXXXX | 20 | static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b, |
42 | --- /dev/null | 21 | float_status *s) |
43 | +++ b/hw/usb/hcd-dwc2.c | 22 | { |
44 | @@ -XXX,XX +XXX,XX @@ | 23 | + int cmp, which; |
45 | +/* | ||
46 | + * dwc-hsotg (dwc2) USB host controller emulation | ||
47 | + * | ||
48 | + * Based on hw/usb/hcd-ehci.c and hw/usb/hcd-ohci.c | ||
49 | + * | ||
50 | + * Note that to use this emulation with the dwc-otg driver in the | ||
51 | + * Raspbian kernel, you must pass the option "dwc_otg.fiq_fsm_enable=0" | ||
52 | + * on the kernel command line. | ||
53 | + * | ||
54 | + * Some useful documentation used to develop this emulation can be | ||
55 | + * found online (as of April 2020) at: | ||
56 | + * | ||
57 | + * http://www.capital-micro.com/PDF/CME-M7_Family_User_Guide_EN.pdf | ||
58 | + * which has a pretty complete description of the controller starting | ||
59 | + * on page 370. | ||
60 | + * | ||
61 | + * https://sourceforge.net/p/wive-ng/wive-ng-mt/ci/master/tree/docs/DataSheets/RT3050_5x_V2.0_081408_0902.pdf | ||
62 | + * which has a description of the controller registers starting on | ||
63 | + * page 130. | ||
64 | + * | ||
65 | + * Copyright (c) 2020 Paul Zimmerman <pauldzim@gmail.com> | ||
66 | + * | ||
67 | + * This program is free software; you can redistribute it and/or modify | ||
68 | + * it under the terms of the GNU General Public License as published by | ||
69 | + * the Free Software Foundation; either version 2 of the License, or | ||
70 | + * (at your option) any later version. | ||
71 | + * | ||
72 | + * This program is distributed in the hope that it will be useful, | ||
73 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
74 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
75 | + * GNU General Public License for more details. | ||
76 | + */ | ||
77 | + | 24 | + |
78 | +#include "qemu/osdep.h" | 25 | if (is_snan(a->cls) || is_snan(b->cls)) { |
79 | +#include "qemu/units.h" | 26 | float_raise(float_flag_invalid | float_flag_invalid_snan, s); |
80 | +#include "qapi/error.h" | 27 | } |
81 | +#include "hw/usb/dwc2-regs.h" | 28 | |
82 | +#include "hw/usb/hcd-dwc2.h" | 29 | if (s->default_nan_mode) { |
83 | +#include "migration/vmstate.h" | 30 | parts_default_nan(a, s); |
84 | +#include "trace.h" | 31 | - } else { |
85 | +#include "qemu/log.h" | 32 | - int cmp = frac_cmp(a, b); |
86 | +#include "qemu/error-report.h" | 33 | - if (cmp == 0) { |
87 | +#include "qemu/main-loop.h" | 34 | - cmp = a->sign < b->sign; |
88 | +#include "hw/qdev-properties.h" | 35 | - } |
36 | + return a; | ||
37 | + } | ||
38 | |||
39 | - if (pickNaN(a->cls, b->cls, cmp > 0, s)) { | ||
40 | - a = b; | ||
41 | - } | ||
42 | + cmp = frac_cmp(a, b); | ||
43 | + if (cmp == 0) { | ||
44 | + cmp = a->sign < b->sign; | ||
45 | + } | ||
89 | + | 46 | + |
90 | +#define USB_HZ_FS 12000000 | 47 | + switch (s->float_2nan_prop_rule) { |
91 | +#define USB_HZ_HS 96000000 | 48 | + case float_2nan_prop_s_ab: |
92 | +#define USB_FRMINTVL 12000 | 49 | if (is_snan(a->cls)) { |
93 | + | 50 | - parts_silence_nan(a, s); |
94 | +/* nifty macros from Arnon's EHCI version */ | 51 | + which = 0; |
95 | +#define get_field(data, field) \ | 52 | + } else if (is_snan(b->cls)) { |
96 | + (((data) & field##_MASK) >> field##_SHIFT) | 53 | + which = 1; |
97 | + | 54 | + } else if (is_qnan(a->cls)) { |
98 | +#define set_field(data, newval, field) do { \ | 55 | + which = 0; |
99 | + uint32_t val = *(data); \ | 56 | + } else { |
100 | + val &= ~field##_MASK; \ | 57 | + which = 1; |
101 | + val |= ((newval) << field##_SHIFT) & field##_MASK; \ | 58 | } |
102 | + *(data) = val; \ | 59 | + break; |
103 | +} while (0) | 60 | + case float_2nan_prop_s_ba: |
104 | + | 61 | + if (is_snan(b->cls)) { |
105 | +#define get_bit(data, bitmask) \ | 62 | + which = 1; |
106 | + (!!((data) & (bitmask))) | 63 | + } else if (is_snan(a->cls)) { |
107 | + | 64 | + which = 0; |
108 | +/* update irq line */ | 65 | + } else if (is_qnan(b->cls)) { |
109 | +static inline void dwc2_update_irq(DWC2State *s) | 66 | + which = 1; |
110 | +{ | 67 | + } else { |
111 | + static int oldlevel; | 68 | + which = 0; |
112 | + int level = 0; | ||
113 | + | ||
114 | + if ((s->gintsts & s->gintmsk) && (s->gahbcfg & GAHBCFG_GLBL_INTR_EN)) { | ||
115 | + level = 1; | ||
116 | + } | ||
117 | + if (level != oldlevel) { | ||
118 | + oldlevel = level; | ||
119 | + trace_usb_dwc2_update_irq(level); | ||
120 | + qemu_set_irq(s->irq, level); | ||
121 | + } | ||
122 | +} | ||
123 | + | ||
124 | +/* flag interrupt condition */ | ||
125 | +static inline void dwc2_raise_global_irq(DWC2State *s, uint32_t intr) | ||
126 | +{ | ||
127 | + if (!(s->gintsts & intr)) { | ||
128 | + s->gintsts |= intr; | ||
129 | + trace_usb_dwc2_raise_global_irq(intr); | ||
130 | + dwc2_update_irq(s); | ||
131 | + } | ||
132 | +} | ||
133 | + | ||
134 | +static inline void dwc2_lower_global_irq(DWC2State *s, uint32_t intr) | ||
135 | +{ | ||
136 | + if (s->gintsts & intr) { | ||
137 | + s->gintsts &= ~intr; | ||
138 | + trace_usb_dwc2_lower_global_irq(intr); | ||
139 | + dwc2_update_irq(s); | ||
140 | + } | ||
141 | +} | ||
142 | + | ||
143 | +static inline void dwc2_raise_host_irq(DWC2State *s, uint32_t host_intr) | ||
144 | +{ | ||
145 | + if (!(s->haint & host_intr)) { | ||
146 | + s->haint |= host_intr; | ||
147 | + s->haint &= 0xffff; | ||
148 | + trace_usb_dwc2_raise_host_irq(host_intr); | ||
149 | + if (s->haint & s->haintmsk) { | ||
150 | + dwc2_raise_global_irq(s, GINTSTS_HCHINT); | ||
151 | + } | 69 | + } |
152 | + } | 70 | + break; |
153 | +} | 71 | + case float_2nan_prop_ab: |
154 | + | 72 | + which = is_nan(a->cls) ? 0 : 1; |
155 | +static inline void dwc2_lower_host_irq(DWC2State *s, uint32_t host_intr) | 73 | + break; |
156 | +{ | 74 | + case float_2nan_prop_ba: |
157 | + if (s->haint & host_intr) { | 75 | + which = is_nan(b->cls) ? 1 : 0; |
158 | + s->haint &= ~host_intr; | 76 | + break; |
159 | + trace_usb_dwc2_lower_host_irq(host_intr); | 77 | + case float_2nan_prop_x87: |
160 | + if (!(s->haint & s->haintmsk)) { | 78 | + /* |
161 | + dwc2_lower_global_irq(s, GINTSTS_HCHINT); | 79 | + * This implements x87 NaN propagation rules: |
80 | + * SNaN + QNaN => return the QNaN | ||
81 | + * two SNaNs => return the one with the larger significand, silenced | ||
82 | + * two QNaNs => return the one with the larger significand | ||
83 | + * SNaN and a non-NaN => return the SNaN, silenced | ||
84 | + * QNaN and a non-NaN => return the QNaN | ||
85 | + * | ||
86 | + * If we get down to comparing significands and they are the same, | ||
87 | + * return the NaN with the positive sign bit (if any). | ||
88 | + */ | ||
89 | + if (is_snan(a->cls)) { | ||
90 | + if (is_snan(b->cls)) { | ||
91 | + which = cmp > 0 ? 0 : 1; | ||
92 | + } else { | ||
93 | + which = is_qnan(b->cls) ? 1 : 0; | ||
94 | + } | ||
95 | + } else if (is_qnan(a->cls)) { | ||
96 | + if (is_snan(b->cls) || !is_qnan(b->cls)) { | ||
97 | + which = 0; | ||
98 | + } else { | ||
99 | + which = cmp > 0 ? 0 : 1; | ||
100 | + } | ||
101 | + } else { | ||
102 | + which = 1; | ||
162 | + } | 103 | + } |
163 | + } | ||
164 | +} | ||
165 | + | ||
166 | +static inline void dwc2_update_hc_irq(DWC2State *s, int index) | ||
167 | +{ | ||
168 | + uint32_t host_intr = 1 << (index >> 3); | ||
169 | + | ||
170 | + if (s->hreg1[index + 2] & s->hreg1[index + 3]) { | ||
171 | + dwc2_raise_host_irq(s, host_intr); | ||
172 | + } else { | ||
173 | + dwc2_lower_host_irq(s, host_intr); | ||
174 | + } | ||
175 | +} | ||
176 | + | ||
177 | +/* set a timer for EOF */ | ||
178 | +static void dwc2_eof_timer(DWC2State *s) | ||
179 | +{ | ||
180 | + timer_mod(s->eof_timer, s->sof_time + s->usb_frame_time); | ||
181 | +} | ||
182 | + | ||
183 | +/* Set a timer for EOF and generate SOF event */ | ||
184 | +static void dwc2_sof(DWC2State *s) | ||
185 | +{ | ||
186 | + s->sof_time += s->usb_frame_time; | ||
187 | + trace_usb_dwc2_sof(s->sof_time); | ||
188 | + dwc2_eof_timer(s); | ||
189 | + dwc2_raise_global_irq(s, GINTSTS_SOF); | ||
190 | +} | ||
191 | + | ||
192 | +/* Do frame processing on frame boundary */ | ||
193 | +static void dwc2_frame_boundary(void *opaque) | ||
194 | +{ | ||
195 | + DWC2State *s = opaque; | ||
196 | + int64_t now; | ||
197 | + uint16_t frcnt; | ||
198 | + | ||
199 | + now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | ||
200 | + | ||
201 | + /* Frame boundary, so do EOF stuff here */ | ||
202 | + | ||
203 | + /* Increment frame number */ | ||
204 | + frcnt = (uint16_t)((now - s->sof_time) / s->fi); | ||
205 | + s->frame_number = (s->frame_number + frcnt) & 0xffff; | ||
206 | + s->hfnum = s->frame_number & HFNUM_MAX_FRNUM; | ||
207 | + | ||
208 | + /* Do SOF stuff here */ | ||
209 | + dwc2_sof(s); | ||
210 | +} | ||
211 | + | ||
212 | +/* Start sending SOF tokens on the USB bus */ | ||
213 | +static void dwc2_bus_start(DWC2State *s) | ||
214 | +{ | ||
215 | + trace_usb_dwc2_bus_start(); | ||
216 | + s->sof_time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | ||
217 | + dwc2_eof_timer(s); | ||
218 | +} | ||
219 | + | ||
220 | +/* Stop sending SOF tokens on the USB bus */ | ||
221 | +static void dwc2_bus_stop(DWC2State *s) | ||
222 | +{ | ||
223 | + trace_usb_dwc2_bus_stop(); | ||
224 | + timer_del(s->eof_timer); | ||
225 | +} | ||
226 | + | ||
227 | +static USBDevice *dwc2_find_device(DWC2State *s, uint8_t addr) | ||
228 | +{ | ||
229 | + USBDevice *dev; | ||
230 | + | ||
231 | + trace_usb_dwc2_find_device(addr); | ||
232 | + | ||
233 | + if (!(s->hprt0 & HPRT0_ENA)) { | ||
234 | + trace_usb_dwc2_port_disabled(0); | ||
235 | + } else { | ||
236 | + dev = usb_find_device(&s->uport, addr); | ||
237 | + if (dev != NULL) { | ||
238 | + trace_usb_dwc2_device_found(0); | ||
239 | + return dev; | ||
240 | + } | ||
241 | + } | ||
242 | + | ||
243 | + trace_usb_dwc2_device_not_found(); | ||
244 | + return NULL; | ||
245 | +} | ||
246 | + | ||
247 | +static const char *pstatus[] = { | ||
248 | + "USB_RET_SUCCESS", "USB_RET_NODEV", "USB_RET_NAK", "USB_RET_STALL", | ||
249 | + "USB_RET_BABBLE", "USB_RET_IOERROR", "USB_RET_ASYNC", | ||
250 | + "USB_RET_ADD_TO_QUEUE", "USB_RET_REMOVE_FROM_QUEUE" | ||
251 | +}; | ||
252 | + | ||
253 | +static uint32_t pintr[] = { | ||
254 | + HCINTMSK_XFERCOMPL, HCINTMSK_XACTERR, HCINTMSK_NAK, HCINTMSK_STALL, | ||
255 | + HCINTMSK_BBLERR, HCINTMSK_XACTERR, HCINTMSK_XACTERR, HCINTMSK_XACTERR, | ||
256 | + HCINTMSK_XACTERR | ||
257 | +}; | ||
258 | + | ||
259 | +static const char *types[] = { | ||
260 | + "Ctrl", "Isoc", "Bulk", "Intr" | ||
261 | +}; | ||
262 | + | ||
263 | +static const char *dirs[] = { | ||
264 | + "Out", "In" | ||
265 | +}; | ||
266 | + | ||
267 | +static void dwc2_handle_packet(DWC2State *s, uint32_t devadr, USBDevice *dev, | ||
268 | + USBEndpoint *ep, uint32_t index, bool send) | ||
269 | +{ | ||
270 | + DWC2Packet *p; | ||
271 | + uint32_t hcchar = s->hreg1[index]; | ||
272 | + uint32_t hctsiz = s->hreg1[index + 4]; | ||
273 | + uint32_t hcdma = s->hreg1[index + 5]; | ||
274 | + uint32_t chan, epnum, epdir, eptype, mps, pid, pcnt, len, tlen, intr = 0; | ||
275 | + uint32_t tpcnt, stsidx, actual = 0; | ||
276 | + bool do_intr = false, done = false; | ||
277 | + | ||
278 | + epnum = get_field(hcchar, HCCHAR_EPNUM); | ||
279 | + epdir = get_bit(hcchar, HCCHAR_EPDIR); | ||
280 | + eptype = get_field(hcchar, HCCHAR_EPTYPE); | ||
281 | + mps = get_field(hcchar, HCCHAR_MPS); | ||
282 | + pid = get_field(hctsiz, TSIZ_SC_MC_PID); | ||
283 | + pcnt = get_field(hctsiz, TSIZ_PKTCNT); | ||
284 | + len = get_field(hctsiz, TSIZ_XFERSIZE); | ||
285 | + assert(len <= DWC2_MAX_XFER_SIZE); | ||
286 | + chan = index >> 3; | ||
287 | + p = &s->packet[chan]; | ||
288 | + | ||
289 | + trace_usb_dwc2_handle_packet(chan, dev, &p->packet, epnum, types[eptype], | ||
290 | + dirs[epdir], mps, len, pcnt); | ||
291 | + | ||
292 | + if (eptype == USB_ENDPOINT_XFER_CONTROL && pid == TSIZ_SC_MC_PID_SETUP) { | ||
293 | + pid = USB_TOKEN_SETUP; | ||
294 | + } else { | ||
295 | + pid = epdir ? USB_TOKEN_IN : USB_TOKEN_OUT; | ||
296 | + } | ||
297 | + | ||
298 | + if (send) { | ||
299 | + tlen = len; | ||
300 | + if (p->small) { | ||
301 | + if (tlen > mps) { | ||
302 | + tlen = mps; | ||
303 | + } | ||
304 | + } | ||
305 | + | ||
306 | + if (pid != USB_TOKEN_IN) { | ||
307 | + trace_usb_dwc2_memory_read(hcdma, tlen); | ||
308 | + if (dma_memory_read(&s->dma_as, hcdma, | ||
309 | + s->usb_buf[chan], tlen) != MEMTX_OK) { | ||
310 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: dma_memory_read failed\n", | ||
311 | + __func__); | ||
312 | + } | ||
313 | + } | ||
314 | + | ||
315 | + usb_packet_init(&p->packet); | ||
316 | + usb_packet_setup(&p->packet, pid, ep, 0, hcdma, | ||
317 | + pid != USB_TOKEN_IN, true); | ||
318 | + usb_packet_addbuf(&p->packet, s->usb_buf[chan], tlen); | ||
319 | + p->async = DWC2_ASYNC_NONE; | ||
320 | + usb_handle_packet(dev, &p->packet); | ||
321 | + } else { | ||
322 | + tlen = p->len; | ||
323 | + } | ||
324 | + | ||
325 | + stsidx = -p->packet.status; | ||
326 | + assert(stsidx < sizeof(pstatus) / sizeof(*pstatus)); | ||
327 | + actual = p->packet.actual_length; | ||
328 | + trace_usb_dwc2_packet_status(pstatus[stsidx], actual); | ||
329 | + | ||
330 | +babble: | ||
331 | + if (p->packet.status != USB_RET_SUCCESS && | ||
332 | + p->packet.status != USB_RET_NAK && | ||
333 | + p->packet.status != USB_RET_STALL && | ||
334 | + p->packet.status != USB_RET_ASYNC) { | ||
335 | + trace_usb_dwc2_packet_error(pstatus[stsidx]); | ||
336 | + } | ||
337 | + | ||
338 | + if (p->packet.status == USB_RET_ASYNC) { | ||
339 | + trace_usb_dwc2_async_packet(&p->packet, chan, dev, epnum, | ||
340 | + dirs[epdir], tlen); | ||
341 | + usb_device_flush_ep_queue(dev, ep); | ||
342 | + assert(p->async != DWC2_ASYNC_INFLIGHT); | ||
343 | + p->devadr = devadr; | ||
344 | + p->epnum = epnum; | ||
345 | + p->epdir = epdir; | ||
346 | + p->mps = mps; | ||
347 | + p->pid = pid; | ||
348 | + p->index = index; | ||
349 | + p->pcnt = pcnt; | ||
350 | + p->len = tlen; | ||
351 | + p->async = DWC2_ASYNC_INFLIGHT; | ||
352 | + p->needs_service = false; | ||
353 | + return; | ||
354 | + } | ||
355 | + | ||
356 | + if (p->packet.status == USB_RET_SUCCESS) { | ||
357 | + if (actual > tlen) { | ||
358 | + p->packet.status = USB_RET_BABBLE; | ||
359 | + goto babble; | ||
360 | + } | ||
361 | + | ||
362 | + if (pid == USB_TOKEN_IN) { | ||
363 | + trace_usb_dwc2_memory_write(hcdma, actual); | ||
364 | + if (dma_memory_write(&s->dma_as, hcdma, s->usb_buf[chan], | ||
365 | + actual) != MEMTX_OK) { | ||
366 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: dma_memory_write failed\n", | ||
367 | + __func__); | ||
368 | + } | ||
369 | + } | ||
370 | + | ||
371 | + tpcnt = actual / mps; | ||
372 | + if (actual % mps) { | ||
373 | + tpcnt++; | ||
374 | + if (pid == USB_TOKEN_IN) { | ||
375 | + done = true; | ||
376 | + } | ||
377 | + } | ||
378 | + | ||
379 | + pcnt -= tpcnt < pcnt ? tpcnt : pcnt; | ||
380 | + set_field(&hctsiz, pcnt, TSIZ_PKTCNT); | ||
381 | + len -= actual < len ? actual : len; | ||
382 | + set_field(&hctsiz, len, TSIZ_XFERSIZE); | ||
383 | + s->hreg1[index + 4] = hctsiz; | ||
384 | + hcdma += actual; | ||
385 | + s->hreg1[index + 5] = hcdma; | ||
386 | + | ||
387 | + if (!pcnt || len == 0 || actual == 0) { | ||
388 | + done = true; | ||
389 | + } | ||
390 | + } else { | ||
391 | + intr |= pintr[stsidx]; | ||
392 | + if (p->packet.status == USB_RET_NAK && | ||
393 | + (eptype == USB_ENDPOINT_XFER_CONTROL || | ||
394 | + eptype == USB_ENDPOINT_XFER_BULK)) { | ||
395 | + /* | ||
396 | + * for ctrl/bulk, automatically retry on NAK, | ||
397 | + * but send the interrupt anyway | ||
398 | + */ | ||
399 | + intr &= ~HCINTMSK_RESERVED14_31; | ||
400 | + s->hreg1[index + 2] |= intr; | ||
401 | + do_intr = true; | ||
402 | + } else { | ||
403 | + intr |= HCINTMSK_CHHLTD; | ||
404 | + done = true; | ||
405 | + } | ||
406 | + } | ||
407 | + | ||
408 | + usb_packet_cleanup(&p->packet); | ||
409 | + | ||
410 | + if (done) { | ||
411 | + hcchar &= ~HCCHAR_CHENA; | ||
412 | + s->hreg1[index] = hcchar; | ||
413 | + if (!(intr & HCINTMSK_CHHLTD)) { | ||
414 | + intr |= HCINTMSK_CHHLTD | HCINTMSK_XFERCOMPL; | ||
415 | + } | ||
416 | + intr &= ~HCINTMSK_RESERVED14_31; | ||
417 | + s->hreg1[index + 2] |= intr; | ||
418 | + p->needs_service = false; | ||
419 | + trace_usb_dwc2_packet_done(pstatus[stsidx], actual, len, pcnt); | ||
420 | + dwc2_update_hc_irq(s, index); | ||
421 | + return; | ||
422 | + } | ||
423 | + | ||
424 | + p->devadr = devadr; | ||
425 | + p->epnum = epnum; | ||
426 | + p->epdir = epdir; | ||
427 | + p->mps = mps; | ||
428 | + p->pid = pid; | ||
429 | + p->index = index; | ||
430 | + p->pcnt = pcnt; | ||
431 | + p->len = len; | ||
432 | + p->needs_service = true; | ||
433 | + trace_usb_dwc2_packet_next(pstatus[stsidx], len, pcnt); | ||
434 | + if (do_intr) { | ||
435 | + dwc2_update_hc_irq(s, index); | ||
436 | + } | ||
437 | +} | ||
438 | + | ||
439 | +/* Attach or detach a device on root hub */ | ||
440 | + | ||
441 | +static const char *speeds[] = { | ||
442 | + "low", "full", "high" | ||
443 | +}; | ||
444 | + | ||
445 | +static void dwc2_attach(USBPort *port) | ||
446 | +{ | ||
447 | + DWC2State *s = port->opaque; | ||
448 | + int hispd = 0; | ||
449 | + | ||
450 | + trace_usb_dwc2_attach(port); | ||
451 | + assert(port->index == 0); | ||
452 | + | ||
453 | + if (!port->dev || !port->dev->attached) { | ||
454 | + return; | ||
455 | + } | ||
456 | + | ||
457 | + assert(port->dev->speed <= USB_SPEED_HIGH); | ||
458 | + trace_usb_dwc2_attach_speed(speeds[port->dev->speed]); | ||
459 | + s->hprt0 &= ~HPRT0_SPD_MASK; | ||
460 | + | ||
461 | + switch (port->dev->speed) { | ||
462 | + case USB_SPEED_LOW: | ||
463 | + s->hprt0 |= HPRT0_SPD_LOW_SPEED << HPRT0_SPD_SHIFT; | ||
464 | + break; | ||
465 | + case USB_SPEED_FULL: | ||
466 | + s->hprt0 |= HPRT0_SPD_FULL_SPEED << HPRT0_SPD_SHIFT; | ||
467 | + break; | ||
468 | + case USB_SPEED_HIGH: | ||
469 | + s->hprt0 |= HPRT0_SPD_HIGH_SPEED << HPRT0_SPD_SHIFT; | ||
470 | + hispd = 1; | ||
471 | + break; | ||
472 | + } | ||
473 | + | ||
474 | + if (hispd) { | ||
475 | + s->usb_frame_time = NANOSECONDS_PER_SECOND / 8000; /* 125000 */ | ||
476 | + if (NANOSECONDS_PER_SECOND >= USB_HZ_HS) { | ||
477 | + s->usb_bit_time = NANOSECONDS_PER_SECOND / USB_HZ_HS; /* 10.4 */ | ||
478 | + } else { | ||
479 | + s->usb_bit_time = 1; | ||
480 | + } | ||
481 | + } else { | ||
482 | + s->usb_frame_time = NANOSECONDS_PER_SECOND / 1000; /* 1000000 */ | ||
483 | + if (NANOSECONDS_PER_SECOND >= USB_HZ_FS) { | ||
484 | + s->usb_bit_time = NANOSECONDS_PER_SECOND / USB_HZ_FS; /* 83.3 */ | ||
485 | + } else { | ||
486 | + s->usb_bit_time = 1; | ||
487 | + } | ||
488 | + } | ||
489 | + | ||
490 | + s->fi = USB_FRMINTVL - 1; | ||
491 | + s->hprt0 |= HPRT0_CONNDET | HPRT0_CONNSTS; | ||
492 | + | ||
493 | + dwc2_bus_start(s); | ||
494 | + dwc2_raise_global_irq(s, GINTSTS_PRTINT); | ||
495 | +} | ||
496 | + | ||
497 | +static void dwc2_detach(USBPort *port) | ||
498 | +{ | ||
499 | + DWC2State *s = port->opaque; | ||
500 | + | ||
501 | + trace_usb_dwc2_detach(port); | ||
502 | + assert(port->index == 0); | ||
503 | + | ||
504 | + dwc2_bus_stop(s); | ||
505 | + | ||
506 | + s->hprt0 &= ~(HPRT0_SPD_MASK | HPRT0_SUSP | HPRT0_ENA | HPRT0_CONNSTS); | ||
507 | + s->hprt0 |= HPRT0_CONNDET | HPRT0_ENACHG; | ||
508 | + | ||
509 | + dwc2_raise_global_irq(s, GINTSTS_PRTINT); | ||
510 | +} | ||
511 | + | ||
512 | +static void dwc2_child_detach(USBPort *port, USBDevice *child) | ||
513 | +{ | ||
514 | + trace_usb_dwc2_child_detach(port, child); | ||
515 | + assert(port->index == 0); | ||
516 | +} | ||
517 | + | ||
518 | +static void dwc2_wakeup(USBPort *port) | ||
519 | +{ | ||
520 | + DWC2State *s = port->opaque; | ||
521 | + | ||
522 | + trace_usb_dwc2_wakeup(port); | ||
523 | + assert(port->index == 0); | ||
524 | + | ||
525 | + if (s->hprt0 & HPRT0_SUSP) { | ||
526 | + s->hprt0 |= HPRT0_RES; | ||
527 | + dwc2_raise_global_irq(s, GINTSTS_PRTINT); | ||
528 | + } | ||
529 | + | ||
530 | + qemu_bh_schedule(s->async_bh); | ||
531 | +} | ||
532 | + | ||
533 | +static void dwc2_async_packet_complete(USBPort *port, USBPacket *packet) | ||
534 | +{ | ||
535 | + DWC2State *s = port->opaque; | ||
536 | + DWC2Packet *p; | ||
537 | + USBDevice *dev; | ||
538 | + USBEndpoint *ep; | ||
539 | + | ||
540 | + assert(port->index == 0); | ||
541 | + p = container_of(packet, DWC2Packet, packet); | ||
542 | + dev = dwc2_find_device(s, p->devadr); | ||
543 | + ep = usb_ep_get(dev, p->pid, p->epnum); | ||
544 | + trace_usb_dwc2_async_packet_complete(port, packet, p->index >> 3, dev, | ||
545 | + p->epnum, dirs[p->epdir], p->len); | ||
546 | + assert(p->async == DWC2_ASYNC_INFLIGHT); | ||
547 | + | ||
548 | + if (packet->status == USB_RET_REMOVE_FROM_QUEUE) { | ||
549 | + usb_cancel_packet(packet); | ||
550 | + usb_packet_cleanup(packet); | ||
551 | + return; | ||
552 | + } | ||
553 | + | ||
554 | + dwc2_handle_packet(s, p->devadr, dev, ep, p->index, false); | ||
555 | + | ||
556 | + p->async = DWC2_ASYNC_FINISHED; | ||
557 | + qemu_bh_schedule(s->async_bh); | ||
558 | +} | ||
559 | + | ||
560 | +static USBPortOps dwc2_port_ops = { | ||
561 | + .attach = dwc2_attach, | ||
562 | + .detach = dwc2_detach, | ||
563 | + .child_detach = dwc2_child_detach, | ||
564 | + .wakeup = dwc2_wakeup, | ||
565 | + .complete = dwc2_async_packet_complete, | ||
566 | +}; | ||
567 | + | ||
568 | +static uint32_t dwc2_get_frame_remaining(DWC2State *s) | ||
569 | +{ | ||
570 | + uint32_t fr = 0; | ||
571 | + int64_t tks; | ||
572 | + | ||
573 | + tks = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - s->sof_time; | ||
574 | + if (tks < 0) { | ||
575 | + tks = 0; | ||
576 | + } | ||
577 | + | ||
578 | + /* avoid muldiv if possible */ | ||
579 | + if (tks >= s->usb_frame_time) { | ||
580 | + goto out; | ||
581 | + } | ||
582 | + if (tks < s->usb_bit_time) { | ||
583 | + fr = s->fi; | ||
584 | + goto out; | ||
585 | + } | ||
586 | + | ||
587 | + /* tks = number of ns since SOF, divided by 83 (fs) or 10 (hs) */ | ||
588 | + tks = tks / s->usb_bit_time; | ||
589 | + if (tks >= (int64_t)s->fi) { | ||
590 | + goto out; | ||
591 | + } | ||
592 | + | ||
593 | + /* remaining = frame interval minus tks */ | ||
594 | + fr = (uint32_t)((int64_t)s->fi - tks); | ||
595 | + | ||
596 | +out: | ||
597 | + return fr; | ||
598 | +} | ||
599 | + | ||
600 | +static void dwc2_work_bh(void *opaque) | ||
601 | +{ | ||
602 | + DWC2State *s = opaque; | ||
603 | + DWC2Packet *p; | ||
604 | + USBDevice *dev; | ||
605 | + USBEndpoint *ep; | ||
606 | + int64_t t_now, expire_time; | ||
607 | + int chan; | ||
608 | + bool found = false; | ||
609 | + | ||
610 | + trace_usb_dwc2_work_bh(); | ||
611 | + if (s->working) { | ||
612 | + return; | ||
613 | + } | ||
614 | + s->working = true; | ||
615 | + | ||
616 | + t_now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | ||
617 | + chan = s->next_chan; | ||
618 | + | ||
619 | + do { | ||
620 | + p = &s->packet[chan]; | ||
621 | + if (p->needs_service) { | ||
622 | + dev = dwc2_find_device(s, p->devadr); | ||
623 | + ep = usb_ep_get(dev, p->pid, p->epnum); | ||
624 | + trace_usb_dwc2_work_bh_service(s->next_chan, chan, dev, p->epnum); | ||
625 | + dwc2_handle_packet(s, p->devadr, dev, ep, p->index, true); | ||
626 | + found = true; | ||
627 | + } | ||
628 | + if (++chan == DWC2_NB_CHAN) { | ||
629 | + chan = 0; | ||
630 | + } | ||
631 | + if (found) { | ||
632 | + s->next_chan = chan; | ||
633 | + trace_usb_dwc2_work_bh_next(chan); | ||
634 | + } | ||
635 | + } while (chan != s->next_chan); | ||
636 | + | ||
637 | + if (found) { | ||
638 | + expire_time = t_now + NANOSECONDS_PER_SECOND / 4000; | ||
639 | + timer_mod(s->frame_timer, expire_time); | ||
640 | + } | ||
641 | + s->working = false; | ||
642 | +} | ||
643 | + | ||
644 | +static void dwc2_enable_chan(DWC2State *s, uint32_t index) | ||
645 | +{ | ||
646 | + USBDevice *dev; | ||
647 | + USBEndpoint *ep; | ||
648 | + uint32_t hcchar; | ||
649 | + uint32_t hctsiz; | ||
650 | + uint32_t devadr, epnum, epdir, eptype, pid, len; | ||
651 | + DWC2Packet *p; | ||
652 | + | ||
653 | + assert((index >> 3) < DWC2_NB_CHAN); | ||
654 | + p = &s->packet[index >> 3]; | ||
655 | + hcchar = s->hreg1[index]; | ||
656 | + hctsiz = s->hreg1[index + 4]; | ||
657 | + devadr = get_field(hcchar, HCCHAR_DEVADDR); | ||
658 | + epnum = get_field(hcchar, HCCHAR_EPNUM); | ||
659 | + epdir = get_bit(hcchar, HCCHAR_EPDIR); | ||
660 | + eptype = get_field(hcchar, HCCHAR_EPTYPE); | ||
661 | + pid = get_field(hctsiz, TSIZ_SC_MC_PID); | ||
662 | + len = get_field(hctsiz, TSIZ_XFERSIZE); | ||
663 | + | ||
664 | + dev = dwc2_find_device(s, devadr); | ||
665 | + | ||
666 | + trace_usb_dwc2_enable_chan(index >> 3, dev, &p->packet, epnum); | ||
667 | + if (dev == NULL) { | ||
668 | + return; | ||
669 | + } | ||
670 | + | ||
671 | + if (eptype == USB_ENDPOINT_XFER_CONTROL && pid == TSIZ_SC_MC_PID_SETUP) { | ||
672 | + pid = USB_TOKEN_SETUP; | ||
673 | + } else { | ||
674 | + pid = epdir ? USB_TOKEN_IN : USB_TOKEN_OUT; | ||
675 | + } | ||
676 | + | ||
677 | + ep = usb_ep_get(dev, pid, epnum); | ||
678 | + | ||
679 | + /* | ||
680 | + * Hack: Networking doesn't like us delivering large transfers, it kind | ||
681 | + * of works but the latency is horrible. So if the transfer is <= the mtu | ||
682 | + * size, we take that as a hint that this might be a network transfer, | ||
683 | + * and do the transfer packet-by-packet. | ||
684 | + */ | ||
685 | + if (len > 1536) { | ||
686 | + p->small = false; | ||
687 | + } else { | ||
688 | + p->small = true; | ||
689 | + } | ||
690 | + | ||
691 | + dwc2_handle_packet(s, devadr, dev, ep, index, true); | ||
692 | + qemu_bh_schedule(s->async_bh); | ||
693 | +} | ||
694 | + | ||
695 | +static const char *glbregnm[] = { | ||
696 | + "GOTGCTL ", "GOTGINT ", "GAHBCFG ", "GUSBCFG ", "GRSTCTL ", | ||
697 | + "GINTSTS ", "GINTMSK ", "GRXSTSR ", "GRXSTSP ", "GRXFSIZ ", | ||
698 | + "GNPTXFSIZ", "GNPTXSTS ", "GI2CCTL ", "GPVNDCTL ", "GGPIO ", | ||
699 | + "GUID ", "GSNPSID ", "GHWCFG1 ", "GHWCFG2 ", "GHWCFG3 ", | ||
700 | + "GHWCFG4 ", "GLPMCFG ", "GPWRDN ", "GDFIFOCFG", "GADPCTL ", | ||
701 | + "GREFCLK ", "GINTMSK2 ", "GINTSTS2 " | ||
702 | +}; | ||
703 | + | ||
704 | +static uint64_t dwc2_glbreg_read(void *ptr, hwaddr addr, int index, | ||
705 | + unsigned size) | ||
706 | +{ | ||
707 | + DWC2State *s = ptr; | ||
708 | + uint32_t val; | ||
709 | + | ||
710 | + assert(addr <= GINTSTS2); | ||
711 | + val = s->glbreg[index]; | ||
712 | + | ||
713 | + switch (addr) { | ||
714 | + case GRSTCTL: | ||
715 | + /* clear any self-clearing bits that were set */ | ||
716 | + val &= ~(GRSTCTL_TXFFLSH | GRSTCTL_RXFFLSH | GRSTCTL_IN_TKNQ_FLSH | | ||
717 | + GRSTCTL_FRMCNTRRST | GRSTCTL_HSFTRST | GRSTCTL_CSFTRST); | ||
718 | + s->glbreg[index] = val; | ||
719 | + break; | ||
720 | + default: | ||
721 | + break; | ||
722 | + } | ||
723 | + | ||
724 | + trace_usb_dwc2_glbreg_read(addr, glbregnm[index], val); | ||
725 | + return val; | ||
726 | +} | ||
727 | + | ||
728 | +static void dwc2_glbreg_write(void *ptr, hwaddr addr, int index, uint64_t val, | ||
729 | + unsigned size) | ||
730 | +{ | ||
731 | + DWC2State *s = ptr; | ||
732 | + uint64_t orig = val; | ||
733 | + uint32_t *mmio; | ||
734 | + uint32_t old; | ||
735 | + int iflg = 0; | ||
736 | + | ||
737 | + assert(addr <= GINTSTS2); | ||
738 | + mmio = &s->glbreg[index]; | ||
739 | + old = *mmio; | ||
740 | + | ||
741 | + switch (addr) { | ||
742 | + case GOTGCTL: | ||
743 | + /* don't allow setting of read-only bits */ | ||
744 | + val &= ~(GOTGCTL_MULT_VALID_BC_MASK | GOTGCTL_BSESVLD | | ||
745 | + GOTGCTL_ASESVLD | GOTGCTL_DBNC_SHORT | GOTGCTL_CONID_B | | ||
746 | + GOTGCTL_HSTNEGSCS | GOTGCTL_SESREQSCS); | ||
747 | + /* don't allow clearing of read-only bits */ | ||
748 | + val |= old & (GOTGCTL_MULT_VALID_BC_MASK | GOTGCTL_BSESVLD | | ||
749 | + GOTGCTL_ASESVLD | GOTGCTL_DBNC_SHORT | GOTGCTL_CONID_B | | ||
750 | + GOTGCTL_HSTNEGSCS | GOTGCTL_SESREQSCS); | ||
751 | + break; | ||
752 | + case GAHBCFG: | ||
753 | + if ((val & GAHBCFG_GLBL_INTR_EN) && !(old & GAHBCFG_GLBL_INTR_EN)) { | ||
754 | + iflg = 1; | ||
755 | + } | ||
756 | + break; | ||
757 | + case GRSTCTL: | ||
758 | + val |= GRSTCTL_AHBIDLE; | ||
759 | + val &= ~GRSTCTL_DMAREQ; | ||
760 | + if (!(old & GRSTCTL_TXFFLSH) && (val & GRSTCTL_TXFFLSH)) { | ||
761 | + /* TODO - TX fifo flush */ | ||
762 | + qemu_log_mask(LOG_UNIMP, "Tx FIFO flush not implemented\n"); | ||
763 | + } | ||
764 | + if (!(old & GRSTCTL_RXFFLSH) && (val & GRSTCTL_RXFFLSH)) { | ||
765 | + /* TODO - RX fifo flush */ | ||
766 | + qemu_log_mask(LOG_UNIMP, "Rx FIFO flush not implemented\n"); | ||
767 | + } | ||
768 | + if (!(old & GRSTCTL_IN_TKNQ_FLSH) && (val & GRSTCTL_IN_TKNQ_FLSH)) { | ||
769 | + /* TODO - device IN token queue flush */ | ||
770 | + qemu_log_mask(LOG_UNIMP, "Token queue flush not implemented\n"); | ||
771 | + } | ||
772 | + if (!(old & GRSTCTL_FRMCNTRRST) && (val & GRSTCTL_FRMCNTRRST)) { | ||
773 | + /* TODO - host frame counter reset */ | ||
774 | + qemu_log_mask(LOG_UNIMP, "Frame counter reset not implemented\n"); | ||
775 | + } | ||
776 | + if (!(old & GRSTCTL_HSFTRST) && (val & GRSTCTL_HSFTRST)) { | ||
777 | + /* TODO - host soft reset */ | ||
778 | + qemu_log_mask(LOG_UNIMP, "Host soft reset not implemented\n"); | ||
779 | + } | ||
780 | + if (!(old & GRSTCTL_CSFTRST) && (val & GRSTCTL_CSFTRST)) { | ||
781 | + /* TODO - core soft reset */ | ||
782 | + qemu_log_mask(LOG_UNIMP, "Core soft reset not implemented\n"); | ||
783 | + } | ||
784 | + /* don't allow clearing of self-clearing bits */ | ||
785 | + val |= old & (GRSTCTL_TXFFLSH | GRSTCTL_RXFFLSH | | ||
786 | + GRSTCTL_IN_TKNQ_FLSH | GRSTCTL_FRMCNTRRST | | ||
787 | + GRSTCTL_HSFTRST | GRSTCTL_CSFTRST); | ||
788 | + break; | ||
789 | + case GINTSTS: | ||
790 | + /* clear the write-1-to-clear bits */ | ||
791 | + val |= ~old; | ||
792 | + val = ~val; | ||
793 | + /* don't allow clearing of read-only bits */ | ||
794 | + val |= old & (GINTSTS_PTXFEMP | GINTSTS_HCHINT | GINTSTS_PRTINT | | ||
795 | + GINTSTS_OEPINT | GINTSTS_IEPINT | GINTSTS_GOUTNAKEFF | | ||
796 | + GINTSTS_GINNAKEFF | GINTSTS_NPTXFEMP | GINTSTS_RXFLVL | | ||
797 | + GINTSTS_OTGINT | GINTSTS_CURMODE_HOST); | ||
798 | + iflg = 1; | ||
799 | + break; | ||
800 | + case GINTMSK: | ||
801 | + iflg = 1; | ||
802 | + break; | ||
803 | + default: | ||
804 | + break; | ||
805 | + } | ||
806 | + | ||
807 | + trace_usb_dwc2_glbreg_write(addr, glbregnm[index], orig, old, val); | ||
808 | + *mmio = val; | ||
809 | + | ||
810 | + if (iflg) { | ||
811 | + dwc2_update_irq(s); | ||
812 | + } | ||
813 | +} | ||
814 | + | ||
815 | +static uint64_t dwc2_fszreg_read(void *ptr, hwaddr addr, int index, | ||
816 | + unsigned size) | ||
817 | +{ | ||
818 | + DWC2State *s = ptr; | ||
819 | + uint32_t val; | ||
820 | + | ||
821 | + assert(addr == HPTXFSIZ); | ||
822 | + val = s->fszreg[index]; | ||
823 | + | ||
824 | + trace_usb_dwc2_fszreg_read(addr, val); | ||
825 | + return val; | ||
826 | +} | ||
827 | + | ||
828 | +static void dwc2_fszreg_write(void *ptr, hwaddr addr, int index, uint64_t val, | ||
829 | + unsigned size) | ||
830 | +{ | ||
831 | + DWC2State *s = ptr; | ||
832 | + uint64_t orig = val; | ||
833 | + uint32_t *mmio; | ||
834 | + uint32_t old; | ||
835 | + | ||
836 | + assert(addr == HPTXFSIZ); | ||
837 | + mmio = &s->fszreg[index]; | ||
838 | + old = *mmio; | ||
839 | + | ||
840 | + trace_usb_dwc2_fszreg_write(addr, orig, old, val); | ||
841 | + *mmio = val; | ||
842 | +} | ||
843 | + | ||
844 | +static const char *hreg0nm[] = { | ||
845 | + "HCFG ", "HFIR ", "HFNUM ", "<rsvd> ", "HPTXSTS ", | ||
846 | + "HAINT ", "HAINTMSK ", "HFLBADDR ", "<rsvd> ", "<rsvd> ", | ||
847 | + "<rsvd> ", "<rsvd> ", "<rsvd> ", "<rsvd> ", "<rsvd> ", | ||
848 | + "<rsvd> ", "HPRT0 " | ||
849 | +}; | ||
850 | + | ||
851 | +static uint64_t dwc2_hreg0_read(void *ptr, hwaddr addr, int index, | ||
852 | + unsigned size) | ||
853 | +{ | ||
854 | + DWC2State *s = ptr; | ||
855 | + uint32_t val; | ||
856 | + | ||
857 | + assert(addr >= HCFG && addr <= HPRT0); | ||
858 | + val = s->hreg0[index]; | ||
859 | + | ||
860 | + switch (addr) { | ||
861 | + case HFNUM: | ||
862 | + val = (dwc2_get_frame_remaining(s) << HFNUM_FRREM_SHIFT) | | ||
863 | + (s->hfnum << HFNUM_FRNUM_SHIFT); | ||
864 | + break; | ||
865 | + default: | ||
866 | + break; | ||
867 | + } | ||
868 | + | ||
869 | + trace_usb_dwc2_hreg0_read(addr, hreg0nm[index], val); | ||
870 | + return val; | ||
871 | +} | ||
872 | + | ||
873 | +static void dwc2_hreg0_write(void *ptr, hwaddr addr, int index, uint64_t val, | ||
874 | + unsigned size) | ||
875 | +{ | ||
876 | + DWC2State *s = ptr; | ||
877 | + USBDevice *dev = s->uport.dev; | ||
878 | + uint64_t orig = val; | ||
879 | + uint32_t *mmio; | ||
880 | + uint32_t tval, told, old; | ||
881 | + int prst = 0; | ||
882 | + int iflg = 0; | ||
883 | + | ||
884 | + assert(addr >= HCFG && addr <= HPRT0); | ||
885 | + mmio = &s->hreg0[index]; | ||
886 | + old = *mmio; | ||
887 | + | ||
888 | + switch (addr) { | ||
889 | + case HFIR: | ||
890 | + break; | ||
891 | + case HFNUM: | ||
892 | + case HPTXSTS: | ||
893 | + case HAINT: | ||
894 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: write to read-only register\n", | ||
895 | + __func__); | ||
896 | + return; | ||
897 | + case HAINTMSK: | ||
898 | + val &= 0xffff; | ||
899 | + break; | ||
900 | + case HPRT0: | ||
901 | + /* don't allow clearing of read-only bits */ | ||
902 | + val |= old & (HPRT0_SPD_MASK | HPRT0_LNSTS_MASK | HPRT0_OVRCURRACT | | ||
903 | + HPRT0_CONNSTS); | ||
904 | + /* don't allow clearing of self-clearing bits */ | ||
905 | + val |= old & (HPRT0_SUSP | HPRT0_RES); | ||
906 | + /* don't allow setting of self-setting bits */ | ||
907 | + if (!(old & HPRT0_ENA) && (val & HPRT0_ENA)) { | ||
908 | + val &= ~HPRT0_ENA; | ||
909 | + } | ||
910 | + /* clear the write-1-to-clear bits */ | ||
911 | + tval = val & (HPRT0_OVRCURRCHG | HPRT0_ENACHG | HPRT0_ENA | | ||
912 | + HPRT0_CONNDET); | ||
913 | + told = old & (HPRT0_OVRCURRCHG | HPRT0_ENACHG | HPRT0_ENA | | ||
914 | + HPRT0_CONNDET); | ||
915 | + tval |= ~told; | ||
916 | + tval = ~tval; | ||
917 | + tval &= (HPRT0_OVRCURRCHG | HPRT0_ENACHG | HPRT0_ENA | | ||
918 | + HPRT0_CONNDET); | ||
919 | + val &= ~(HPRT0_OVRCURRCHG | HPRT0_ENACHG | HPRT0_ENA | | ||
920 | + HPRT0_CONNDET); | ||
921 | + val |= tval; | ||
922 | + if (!(val & HPRT0_RST) && (old & HPRT0_RST)) { | ||
923 | + if (dev && dev->attached) { | ||
924 | + val |= HPRT0_ENA | HPRT0_ENACHG; | ||
925 | + prst = 1; | ||
926 | + } | ||
927 | + } | ||
928 | + if (val & (HPRT0_OVRCURRCHG | HPRT0_ENACHG | HPRT0_CONNDET)) { | ||
929 | + iflg = 1; | ||
930 | + } else { | ||
931 | + iflg = -1; | ||
932 | + } | ||
933 | + break; | ||
934 | + default: | ||
935 | + break; | ||
936 | + } | ||
937 | + | ||
938 | + if (prst) { | ||
939 | + trace_usb_dwc2_hreg0_write(addr, hreg0nm[index], orig, old, | ||
940 | + val & ~HPRT0_CONNDET); | ||
941 | + trace_usb_dwc2_hreg0_action("call usb_port_reset"); | ||
942 | + usb_port_reset(&s->uport); | ||
943 | + val &= ~HPRT0_CONNDET; | ||
944 | + } else { | ||
945 | + trace_usb_dwc2_hreg0_write(addr, hreg0nm[index], orig, old, val); | ||
946 | + } | ||
947 | + | ||
948 | + *mmio = val; | ||
949 | + | ||
950 | + if (iflg > 0) { | ||
951 | + trace_usb_dwc2_hreg0_action("enable PRTINT"); | ||
952 | + dwc2_raise_global_irq(s, GINTSTS_PRTINT); | ||
953 | + } else if (iflg < 0) { | ||
954 | + trace_usb_dwc2_hreg0_action("disable PRTINT"); | ||
955 | + dwc2_lower_global_irq(s, GINTSTS_PRTINT); | ||
956 | + } | ||
957 | +} | ||
958 | + | ||
959 | +static const char *hreg1nm[] = { | ||
960 | + "HCCHAR ", "HCSPLT ", "HCINT ", "HCINTMSK", "HCTSIZ ", "HCDMA ", | ||
961 | + "<rsvd> ", "HCDMAB " | ||
962 | +}; | ||
963 | + | ||
964 | +static uint64_t dwc2_hreg1_read(void *ptr, hwaddr addr, int index, | ||
965 | + unsigned size) | ||
966 | +{ | ||
967 | + DWC2State *s = ptr; | ||
968 | + uint32_t val; | ||
969 | + | ||
970 | + assert(addr >= HCCHAR(0) && addr <= HCDMAB(DWC2_NB_CHAN - 1)); | ||
971 | + val = s->hreg1[index]; | ||
972 | + | ||
973 | + trace_usb_dwc2_hreg1_read(addr, hreg1nm[index & 7], addr >> 5, val); | ||
974 | + return val; | ||
975 | +} | ||
976 | + | ||
977 | +static void dwc2_hreg1_write(void *ptr, hwaddr addr, int index, uint64_t val, | ||
978 | + unsigned size) | ||
979 | +{ | ||
980 | + DWC2State *s = ptr; | ||
981 | + uint64_t orig = val; | ||
982 | + uint32_t *mmio; | ||
983 | + uint32_t old; | ||
984 | + int iflg = 0; | ||
985 | + int enflg = 0; | ||
986 | + int disflg = 0; | ||
987 | + | ||
988 | + assert(addr >= HCCHAR(0) && addr <= HCDMAB(DWC2_NB_CHAN - 1)); | ||
989 | + mmio = &s->hreg1[index]; | ||
990 | + old = *mmio; | ||
991 | + | ||
992 | + switch (HSOTG_REG(0x500) + (addr & 0x1c)) { | ||
993 | + case HCCHAR(0): | ||
994 | + if ((val & HCCHAR_CHDIS) && !(old & HCCHAR_CHDIS)) { | ||
995 | + val &= ~(HCCHAR_CHENA | HCCHAR_CHDIS); | ||
996 | + disflg = 1; | ||
997 | + } else { | ||
998 | + val |= old & HCCHAR_CHDIS; | ||
999 | + if ((val & HCCHAR_CHENA) && !(old & HCCHAR_CHENA)) { | ||
1000 | + val &= ~HCCHAR_CHDIS; | ||
1001 | + enflg = 1; | ||
1002 | + } else { | ||
1003 | + val |= old & HCCHAR_CHENA; | ||
1004 | + } | ||
1005 | + } | ||
1006 | + break; | ||
1007 | + case HCINT(0): | ||
1008 | + /* clear the write-1-to-clear bits */ | ||
1009 | + val |= ~old; | ||
1010 | + val = ~val; | ||
1011 | + val &= ~HCINTMSK_RESERVED14_31; | ||
1012 | + iflg = 1; | ||
1013 | + break; | ||
1014 | + case HCINTMSK(0): | ||
1015 | + val &= ~HCINTMSK_RESERVED14_31; | ||
1016 | + iflg = 1; | ||
1017 | + break; | ||
1018 | + case HCDMAB(0): | ||
1019 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: write to read-only register\n", | ||
1020 | + __func__); | ||
1021 | + return; | ||
1022 | + default: | ||
1023 | + break; | ||
1024 | + } | ||
1025 | + | ||
1026 | + trace_usb_dwc2_hreg1_write(addr, hreg1nm[index & 7], index >> 3, orig, | ||
1027 | + old, val); | ||
1028 | + *mmio = val; | ||
1029 | + | ||
1030 | + if (disflg) { | ||
1031 | + /* set ChHltd in HCINT */ | ||
1032 | + s->hreg1[(index & ~7) + 2] |= HCINTMSK_CHHLTD; | ||
1033 | + iflg = 1; | ||
1034 | + } | ||
1035 | + | ||
1036 | + if (enflg) { | ||
1037 | + dwc2_enable_chan(s, index & ~7); | ||
1038 | + } | ||
1039 | + | ||
1040 | + if (iflg) { | ||
1041 | + dwc2_update_hc_irq(s, index & ~7); | ||
1042 | + } | ||
1043 | +} | ||
1044 | + | ||
1045 | +static const char *pcgregnm[] = { | ||
1046 | + "PCGCTL ", "PCGCCTL1 " | ||
1047 | +}; | ||
1048 | + | ||
1049 | +static uint64_t dwc2_pcgreg_read(void *ptr, hwaddr addr, int index, | ||
1050 | + unsigned size) | ||
1051 | +{ | ||
1052 | + DWC2State *s = ptr; | ||
1053 | + uint32_t val; | ||
1054 | + | ||
1055 | + assert(addr >= PCGCTL && addr <= PCGCCTL1); | ||
1056 | + val = s->pcgreg[index]; | ||
1057 | + | ||
1058 | + trace_usb_dwc2_pcgreg_read(addr, pcgregnm[index], val); | ||
1059 | + return val; | ||
1060 | +} | ||
1061 | + | ||
1062 | +static void dwc2_pcgreg_write(void *ptr, hwaddr addr, int index, | ||
1063 | + uint64_t val, unsigned size) | ||
1064 | +{ | ||
1065 | + DWC2State *s = ptr; | ||
1066 | + uint64_t orig = val; | ||
1067 | + uint32_t *mmio; | ||
1068 | + uint32_t old; | ||
1069 | + | ||
1070 | + assert(addr >= PCGCTL && addr <= PCGCCTL1); | ||
1071 | + mmio = &s->pcgreg[index]; | ||
1072 | + old = *mmio; | ||
1073 | + | ||
1074 | + trace_usb_dwc2_pcgreg_write(addr, pcgregnm[index], orig, old, val); | ||
1075 | + *mmio = val; | ||
1076 | +} | ||
1077 | + | ||
1078 | +static uint64_t dwc2_hsotg_read(void *ptr, hwaddr addr, unsigned size) | ||
1079 | +{ | ||
1080 | + uint64_t val; | ||
1081 | + | ||
1082 | + switch (addr) { | ||
1083 | + case HSOTG_REG(0x000) ... HSOTG_REG(0x0fc): | ||
1084 | + val = dwc2_glbreg_read(ptr, addr, (addr - HSOTG_REG(0x000)) >> 2, size); | ||
1085 | + break; | ||
1086 | + case HSOTG_REG(0x100): | ||
1087 | + val = dwc2_fszreg_read(ptr, addr, (addr - HSOTG_REG(0x100)) >> 2, size); | ||
1088 | + break; | ||
1089 | + case HSOTG_REG(0x104) ... HSOTG_REG(0x3fc): | ||
1090 | + /* Gadget-mode registers, just return 0 for now */ | ||
1091 | + val = 0; | ||
1092 | + break; | ||
1093 | + case HSOTG_REG(0x400) ... HSOTG_REG(0x4fc): | ||
1094 | + val = dwc2_hreg0_read(ptr, addr, (addr - HSOTG_REG(0x400)) >> 2, size); | ||
1095 | + break; | ||
1096 | + case HSOTG_REG(0x500) ... HSOTG_REG(0x7fc): | ||
1097 | + val = dwc2_hreg1_read(ptr, addr, (addr - HSOTG_REG(0x500)) >> 2, size); | ||
1098 | + break; | ||
1099 | + case HSOTG_REG(0x800) ... HSOTG_REG(0xdfc): | ||
1100 | + /* Gadget-mode registers, just return 0 for now */ | ||
1101 | + val = 0; | ||
1102 | + break; | ||
1103 | + case HSOTG_REG(0xe00) ... HSOTG_REG(0xffc): | ||
1104 | + val = dwc2_pcgreg_read(ptr, addr, (addr - HSOTG_REG(0xe00)) >> 2, size); | ||
1105 | + break; | 104 | + break; |
1106 | + default: | 105 | + default: |
1107 | + g_assert_not_reached(); | 106 | + g_assert_not_reached(); |
1108 | + } | 107 | + } |
1109 | + | 108 | + |
1110 | + return val; | 109 | + if (which) { |
1111 | +} | 110 | + a = b; |
1112 | + | 111 | + } |
1113 | +static void dwc2_hsotg_write(void *ptr, hwaddr addr, uint64_t val, | 112 | + if (is_snan(a->cls)) { |
1114 | + unsigned size) | 113 | + parts_silence_nan(a, s); |
1115 | +{ | 114 | } |
1116 | + switch (addr) { | 115 | return a; |
1117 | + case HSOTG_REG(0x000) ... HSOTG_REG(0x0fc): | 116 | } |
1118 | + dwc2_glbreg_write(ptr, addr, (addr - HSOTG_REG(0x000)) >> 2, val, size); | 117 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc |
1119 | + break; | ||
1120 | + case HSOTG_REG(0x100): | ||
1121 | + dwc2_fszreg_write(ptr, addr, (addr - HSOTG_REG(0x100)) >> 2, val, size); | ||
1122 | + break; | ||
1123 | + case HSOTG_REG(0x104) ... HSOTG_REG(0x3fc): | ||
1124 | + /* Gadget-mode registers, do nothing for now */ | ||
1125 | + break; | ||
1126 | + case HSOTG_REG(0x400) ... HSOTG_REG(0x4fc): | ||
1127 | + dwc2_hreg0_write(ptr, addr, (addr - HSOTG_REG(0x400)) >> 2, val, size); | ||
1128 | + break; | ||
1129 | + case HSOTG_REG(0x500) ... HSOTG_REG(0x7fc): | ||
1130 | + dwc2_hreg1_write(ptr, addr, (addr - HSOTG_REG(0x500)) >> 2, val, size); | ||
1131 | + break; | ||
1132 | + case HSOTG_REG(0x800) ... HSOTG_REG(0xdfc): | ||
1133 | + /* Gadget-mode registers, do nothing for now */ | ||
1134 | + break; | ||
1135 | + case HSOTG_REG(0xe00) ... HSOTG_REG(0xffc): | ||
1136 | + dwc2_pcgreg_write(ptr, addr, (addr - HSOTG_REG(0xe00)) >> 2, val, size); | ||
1137 | + break; | ||
1138 | + default: | ||
1139 | + g_assert_not_reached(); | ||
1140 | + } | ||
1141 | +} | ||
1142 | + | ||
1143 | +static const MemoryRegionOps dwc2_mmio_hsotg_ops = { | ||
1144 | + .read = dwc2_hsotg_read, | ||
1145 | + .write = dwc2_hsotg_write, | ||
1146 | + .impl.min_access_size = 4, | ||
1147 | + .impl.max_access_size = 4, | ||
1148 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
1149 | +}; | ||
1150 | + | ||
1151 | +static uint64_t dwc2_hreg2_read(void *ptr, hwaddr addr, unsigned size) | ||
1152 | +{ | ||
1153 | + /* TODO - implement FIFOs to support slave mode */ | ||
1154 | + trace_usb_dwc2_hreg2_read(addr, addr >> 12, 0); | ||
1155 | + qemu_log_mask(LOG_UNIMP, "FIFO read not implemented\n"); | ||
1156 | + return 0; | ||
1157 | +} | ||
1158 | + | ||
1159 | +static void dwc2_hreg2_write(void *ptr, hwaddr addr, uint64_t val, | ||
1160 | + unsigned size) | ||
1161 | +{ | ||
1162 | + uint64_t orig = val; | ||
1163 | + | ||
1164 | + /* TODO - implement FIFOs to support slave mode */ | ||
1165 | + trace_usb_dwc2_hreg2_write(addr, addr >> 12, orig, 0, val); | ||
1166 | + qemu_log_mask(LOG_UNIMP, "FIFO write not implemented\n"); | ||
1167 | +} | ||
1168 | + | ||
1169 | +static const MemoryRegionOps dwc2_mmio_hreg2_ops = { | ||
1170 | + .read = dwc2_hreg2_read, | ||
1171 | + .write = dwc2_hreg2_write, | ||
1172 | + .impl.min_access_size = 4, | ||
1173 | + .impl.max_access_size = 4, | ||
1174 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
1175 | +}; | ||
1176 | + | ||
1177 | +static void dwc2_wakeup_endpoint(USBBus *bus, USBEndpoint *ep, | ||
1178 | + unsigned int stream) | ||
1179 | +{ | ||
1180 | + DWC2State *s = container_of(bus, DWC2State, bus); | ||
1181 | + | ||
1182 | + trace_usb_dwc2_wakeup_endpoint(ep, stream); | ||
1183 | + | ||
1184 | + /* TODO - do something here? */ | ||
1185 | + qemu_bh_schedule(s->async_bh); | ||
1186 | +} | ||
1187 | + | ||
1188 | +static USBBusOps dwc2_bus_ops = { | ||
1189 | + .wakeup_endpoint = dwc2_wakeup_endpoint, | ||
1190 | +}; | ||
1191 | + | ||
1192 | +static void dwc2_work_timer(void *opaque) | ||
1193 | +{ | ||
1194 | + DWC2State *s = opaque; | ||
1195 | + | ||
1196 | + trace_usb_dwc2_work_timer(); | ||
1197 | + qemu_bh_schedule(s->async_bh); | ||
1198 | +} | ||
1199 | + | ||
1200 | +static void dwc2_reset_enter(Object *obj, ResetType type) | ||
1201 | +{ | ||
1202 | + DWC2Class *c = DWC2_GET_CLASS(obj); | ||
1203 | + DWC2State *s = DWC2_USB(obj); | ||
1204 | + int i; | ||
1205 | + | ||
1206 | + trace_usb_dwc2_reset_enter(); | ||
1207 | + | ||
1208 | + if (c->parent_phases.enter) { | ||
1209 | + c->parent_phases.enter(obj, type); | ||
1210 | + } | ||
1211 | + | ||
1212 | + timer_del(s->frame_timer); | ||
1213 | + qemu_bh_cancel(s->async_bh); | ||
1214 | + | ||
1215 | + if (s->uport.dev && s->uport.dev->attached) { | ||
1216 | + usb_detach(&s->uport); | ||
1217 | + } | ||
1218 | + | ||
1219 | + dwc2_bus_stop(s); | ||
1220 | + | ||
1221 | + s->gotgctl = GOTGCTL_BSESVLD | GOTGCTL_ASESVLD | GOTGCTL_CONID_B; | ||
1222 | + s->gotgint = 0; | ||
1223 | + s->gahbcfg = 0; | ||
1224 | + s->gusbcfg = 5 << GUSBCFG_USBTRDTIM_SHIFT; | ||
1225 | + s->grstctl = GRSTCTL_AHBIDLE; | ||
1226 | + s->gintsts = GINTSTS_CONIDSTSCHNG | GINTSTS_PTXFEMP | GINTSTS_NPTXFEMP | | ||
1227 | + GINTSTS_CURMODE_HOST; | ||
1228 | + s->gintmsk = 0; | ||
1229 | + s->grxstsr = 0; | ||
1230 | + s->grxstsp = 0; | ||
1231 | + s->grxfsiz = 1024; | ||
1232 | + s->gnptxfsiz = 1024 << FIFOSIZE_DEPTH_SHIFT; | ||
1233 | + s->gnptxsts = (4 << FIFOSIZE_DEPTH_SHIFT) | 1024; | ||
1234 | + s->gi2cctl = GI2CCTL_I2CDATSE0 | GI2CCTL_ACK; | ||
1235 | + s->gpvndctl = 0; | ||
1236 | + s->ggpio = 0; | ||
1237 | + s->guid = 0; | ||
1238 | + s->gsnpsid = 0x4f54294a; | ||
1239 | + s->ghwcfg1 = 0; | ||
1240 | + s->ghwcfg2 = (8 << GHWCFG2_DEV_TOKEN_Q_DEPTH_SHIFT) | | ||
1241 | + (4 << GHWCFG2_HOST_PERIO_TX_Q_DEPTH_SHIFT) | | ||
1242 | + (4 << GHWCFG2_NONPERIO_TX_Q_DEPTH_SHIFT) | | ||
1243 | + GHWCFG2_DYNAMIC_FIFO | | ||
1244 | + GHWCFG2_PERIO_EP_SUPPORTED | | ||
1245 | + ((DWC2_NB_CHAN - 1) << GHWCFG2_NUM_HOST_CHAN_SHIFT) | | ||
1246 | + (GHWCFG2_INT_DMA_ARCH << GHWCFG2_ARCHITECTURE_SHIFT) | | ||
1247 | + (GHWCFG2_OP_MODE_NO_SRP_CAPABLE_HOST << GHWCFG2_OP_MODE_SHIFT); | ||
1248 | + s->ghwcfg3 = (4096 << GHWCFG3_DFIFO_DEPTH_SHIFT) | | ||
1249 | + (4 << GHWCFG3_PACKET_SIZE_CNTR_WIDTH_SHIFT) | | ||
1250 | + (4 << GHWCFG3_XFER_SIZE_CNTR_WIDTH_SHIFT); | ||
1251 | + s->ghwcfg4 = 0; | ||
1252 | + s->glpmcfg = 0; | ||
1253 | + s->gpwrdn = GPWRDN_PWRDNRSTN; | ||
1254 | + s->gdfifocfg = 0; | ||
1255 | + s->gadpctl = 0; | ||
1256 | + s->grefclk = 0; | ||
1257 | + s->gintmsk2 = 0; | ||
1258 | + s->gintsts2 = 0; | ||
1259 | + | ||
1260 | + s->hptxfsiz = 500 << FIFOSIZE_DEPTH_SHIFT; | ||
1261 | + | ||
1262 | + s->hcfg = 2 << HCFG_RESVALID_SHIFT; | ||
1263 | + s->hfir = 60000; | ||
1264 | + s->hfnum = 0x3fff; | ||
1265 | + s->hptxsts = (16 << TXSTS_QSPCAVAIL_SHIFT) | 32768; | ||
1266 | + s->haint = 0; | ||
1267 | + s->haintmsk = 0; | ||
1268 | + s->hprt0 = 0; | ||
1269 | + | ||
1270 | + memset(s->hreg1, 0, sizeof(s->hreg1)); | ||
1271 | + memset(s->pcgreg, 0, sizeof(s->pcgreg)); | ||
1272 | + | ||
1273 | + s->sof_time = 0; | ||
1274 | + s->frame_number = 0; | ||
1275 | + s->fi = USB_FRMINTVL - 1; | ||
1276 | + s->next_chan = 0; | ||
1277 | + s->working = false; | ||
1278 | + | ||
1279 | + for (i = 0; i < DWC2_NB_CHAN; i++) { | ||
1280 | + s->packet[i].needs_service = false; | ||
1281 | + } | ||
1282 | +} | ||
1283 | + | ||
1284 | +static void dwc2_reset_hold(Object *obj) | ||
1285 | +{ | ||
1286 | + DWC2Class *c = DWC2_GET_CLASS(obj); | ||
1287 | + DWC2State *s = DWC2_USB(obj); | ||
1288 | + | ||
1289 | + trace_usb_dwc2_reset_hold(); | ||
1290 | + | ||
1291 | + if (c->parent_phases.hold) { | ||
1292 | + c->parent_phases.hold(obj); | ||
1293 | + } | ||
1294 | + | ||
1295 | + dwc2_update_irq(s); | ||
1296 | +} | ||
1297 | + | ||
1298 | +static void dwc2_reset_exit(Object *obj) | ||
1299 | +{ | ||
1300 | + DWC2Class *c = DWC2_GET_CLASS(obj); | ||
1301 | + DWC2State *s = DWC2_USB(obj); | ||
1302 | + | ||
1303 | + trace_usb_dwc2_reset_exit(); | ||
1304 | + | ||
1305 | + if (c->parent_phases.exit) { | ||
1306 | + c->parent_phases.exit(obj); | ||
1307 | + } | ||
1308 | + | ||
1309 | + s->hprt0 = HPRT0_PWR; | ||
1310 | + if (s->uport.dev && s->uport.dev->attached) { | ||
1311 | + usb_attach(&s->uport); | ||
1312 | + usb_device_reset(s->uport.dev); | ||
1313 | + } | ||
1314 | +} | ||
1315 | + | ||
1316 | +static void dwc2_realize(DeviceState *dev, Error **errp) | ||
1317 | +{ | ||
1318 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
1319 | + DWC2State *s = DWC2_USB(dev); | ||
1320 | + Object *obj; | ||
1321 | + Error *err = NULL; | ||
1322 | + | ||
1323 | + obj = object_property_get_link(OBJECT(dev), "dma-mr", &err); | ||
1324 | + if (err) { | ||
1325 | + error_setg(errp, "dwc2: required dma-mr link not found: %s", | ||
1326 | + error_get_pretty(err)); | ||
1327 | + return; | ||
1328 | + } | ||
1329 | + assert(obj != NULL); | ||
1330 | + | ||
1331 | + s->dma_mr = MEMORY_REGION(obj); | ||
1332 | + address_space_init(&s->dma_as, s->dma_mr, "dwc2"); | ||
1333 | + | ||
1334 | + usb_bus_new(&s->bus, sizeof(s->bus), &dwc2_bus_ops, dev); | ||
1335 | + usb_register_port(&s->bus, &s->uport, s, 0, &dwc2_port_ops, | ||
1336 | + USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL | | ||
1337 | + (s->usb_version == 2 ? USB_SPEED_MASK_HIGH : 0)); | ||
1338 | + s->uport.dev = 0; | ||
1339 | + | ||
1340 | + s->usb_frame_time = NANOSECONDS_PER_SECOND / 1000; /* 1000000 */ | ||
1341 | + if (NANOSECONDS_PER_SECOND >= USB_HZ_FS) { | ||
1342 | + s->usb_bit_time = NANOSECONDS_PER_SECOND / USB_HZ_FS; /* 83.3 */ | ||
1343 | + } else { | ||
1344 | + s->usb_bit_time = 1; | ||
1345 | + } | ||
1346 | + | ||
1347 | + s->fi = USB_FRMINTVL - 1; | ||
1348 | + s->eof_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, dwc2_frame_boundary, s); | ||
1349 | + s->frame_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, dwc2_work_timer, s); | ||
1350 | + s->async_bh = qemu_bh_new(dwc2_work_bh, s); | ||
1351 | + | ||
1352 | + sysbus_init_irq(sbd, &s->irq); | ||
1353 | +} | ||
1354 | + | ||
1355 | +static void dwc2_init(Object *obj) | ||
1356 | +{ | ||
1357 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
1358 | + DWC2State *s = DWC2_USB(obj); | ||
1359 | + | ||
1360 | + memory_region_init(&s->container, obj, "dwc2", DWC2_MMIO_SIZE); | ||
1361 | + sysbus_init_mmio(sbd, &s->container); | ||
1362 | + | ||
1363 | + memory_region_init_io(&s->hsotg, obj, &dwc2_mmio_hsotg_ops, s, | ||
1364 | + "dwc2-io", 4 * KiB); | ||
1365 | + memory_region_add_subregion(&s->container, 0x0000, &s->hsotg); | ||
1366 | + | ||
1367 | + memory_region_init_io(&s->fifos, obj, &dwc2_mmio_hreg2_ops, s, | ||
1368 | + "dwc2-fifo", 64 * KiB); | ||
1369 | + memory_region_add_subregion(&s->container, 0x1000, &s->fifos); | ||
1370 | +} | ||
1371 | + | ||
1372 | +static const VMStateDescription vmstate_dwc2_state_packet = { | ||
1373 | + .name = "dwc2/packet", | ||
1374 | + .version_id = 1, | ||
1375 | + .minimum_version_id = 1, | ||
1376 | + .fields = (VMStateField[]) { | ||
1377 | + VMSTATE_UINT32(devadr, DWC2Packet), | ||
1378 | + VMSTATE_UINT32(epnum, DWC2Packet), | ||
1379 | + VMSTATE_UINT32(epdir, DWC2Packet), | ||
1380 | + VMSTATE_UINT32(mps, DWC2Packet), | ||
1381 | + VMSTATE_UINT32(pid, DWC2Packet), | ||
1382 | + VMSTATE_UINT32(index, DWC2Packet), | ||
1383 | + VMSTATE_UINT32(pcnt, DWC2Packet), | ||
1384 | + VMSTATE_UINT32(len, DWC2Packet), | ||
1385 | + VMSTATE_INT32(async, DWC2Packet), | ||
1386 | + VMSTATE_BOOL(small, DWC2Packet), | ||
1387 | + VMSTATE_BOOL(needs_service, DWC2Packet), | ||
1388 | + VMSTATE_END_OF_LIST() | ||
1389 | + }, | ||
1390 | +}; | ||
1391 | + | ||
1392 | +const VMStateDescription vmstate_dwc2_state = { | ||
1393 | + .name = "dwc2", | ||
1394 | + .version_id = 1, | ||
1395 | + .minimum_version_id = 1, | ||
1396 | + .fields = (VMStateField[]) { | ||
1397 | + VMSTATE_UINT32_ARRAY(glbreg, DWC2State, | ||
1398 | + DWC2_GLBREG_SIZE / sizeof(uint32_t)), | ||
1399 | + VMSTATE_UINT32_ARRAY(fszreg, DWC2State, | ||
1400 | + DWC2_FSZREG_SIZE / sizeof(uint32_t)), | ||
1401 | + VMSTATE_UINT32_ARRAY(hreg0, DWC2State, | ||
1402 | + DWC2_HREG0_SIZE / sizeof(uint32_t)), | ||
1403 | + VMSTATE_UINT32_ARRAY(hreg1, DWC2State, | ||
1404 | + DWC2_HREG1_SIZE / sizeof(uint32_t)), | ||
1405 | + VMSTATE_UINT32_ARRAY(pcgreg, DWC2State, | ||
1406 | + DWC2_PCGREG_SIZE / sizeof(uint32_t)), | ||
1407 | + | ||
1408 | + VMSTATE_TIMER_PTR(eof_timer, DWC2State), | ||
1409 | + VMSTATE_TIMER_PTR(frame_timer, DWC2State), | ||
1410 | + VMSTATE_INT64(sof_time, DWC2State), | ||
1411 | + VMSTATE_INT64(usb_frame_time, DWC2State), | ||
1412 | + VMSTATE_INT64(usb_bit_time, DWC2State), | ||
1413 | + VMSTATE_UINT32(usb_version, DWC2State), | ||
1414 | + VMSTATE_UINT16(frame_number, DWC2State), | ||
1415 | + VMSTATE_UINT16(fi, DWC2State), | ||
1416 | + VMSTATE_UINT16(next_chan, DWC2State), | ||
1417 | + VMSTATE_BOOL(working, DWC2State), | ||
1418 | + | ||
1419 | + VMSTATE_STRUCT_ARRAY(packet, DWC2State, DWC2_NB_CHAN, 1, | ||
1420 | + vmstate_dwc2_state_packet, DWC2Packet), | ||
1421 | + VMSTATE_UINT8_2DARRAY(usb_buf, DWC2State, DWC2_NB_CHAN, | ||
1422 | + DWC2_MAX_XFER_SIZE), | ||
1423 | + | ||
1424 | + VMSTATE_END_OF_LIST() | ||
1425 | + } | ||
1426 | +}; | ||
1427 | + | ||
1428 | +static Property dwc2_usb_properties[] = { | ||
1429 | + DEFINE_PROP_UINT32("usb_version", DWC2State, usb_version, 2), | ||
1430 | + DEFINE_PROP_END_OF_LIST(), | ||
1431 | +}; | ||
1432 | + | ||
1433 | +static void dwc2_class_init(ObjectClass *klass, void *data) | ||
1434 | +{ | ||
1435 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
1436 | + DWC2Class *c = DWC2_CLASS(klass); | ||
1437 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
1438 | + | ||
1439 | + dc->realize = dwc2_realize; | ||
1440 | + dc->vmsd = &vmstate_dwc2_state; | ||
1441 | + set_bit(DEVICE_CATEGORY_USB, dc->categories); | ||
1442 | + device_class_set_props(dc, dwc2_usb_properties); | ||
1443 | + resettable_class_set_parent_phases(rc, dwc2_reset_enter, dwc2_reset_hold, | ||
1444 | + dwc2_reset_exit, &c->parent_phases); | ||
1445 | +} | ||
1446 | + | ||
1447 | +static const TypeInfo dwc2_usb_type_info = { | ||
1448 | + .name = TYPE_DWC2_USB, | ||
1449 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
1450 | + .instance_size = sizeof(DWC2State), | ||
1451 | + .instance_init = dwc2_init, | ||
1452 | + .class_size = sizeof(DWC2Class), | ||
1453 | + .class_init = dwc2_class_init, | ||
1454 | +}; | ||
1455 | + | ||
1456 | +static void dwc2_usb_register_types(void) | ||
1457 | +{ | ||
1458 | + type_register_static(&dwc2_usb_type_info); | ||
1459 | +} | ||
1460 | + | ||
1461 | +type_init(dwc2_usb_register_types) | ||
1462 | diff --git a/hw/usb/Kconfig b/hw/usb/Kconfig | ||
1463 | index XXXXXXX..XXXXXXX 100644 | 118 | index XXXXXXX..XXXXXXX 100644 |
1464 | --- a/hw/usb/Kconfig | 119 | --- a/fpu/softfloat-specialize.c.inc |
1465 | +++ b/hw/usb/Kconfig | 120 | +++ b/fpu/softfloat-specialize.c.inc |
1466 | @@ -XXX,XX +XXX,XX @@ config USB_MUSB | 121 | @@ -XXX,XX +XXX,XX @@ bool float32_is_signaling_nan(float32 a_, float_status *status) |
1467 | bool | 122 | } |
1468 | select USB | 123 | } |
1469 | 124 | ||
1470 | +config USB_DWC2 | 125 | -/*---------------------------------------------------------------------------- |
1471 | + bool | 126 | -| Select which NaN to propagate for a two-input operation. |
1472 | + default y | 127 | -| IEEE754 doesn't specify all the details of this, so the |
1473 | + select USB | 128 | -| algorithm is target-specific. |
1474 | + | 129 | -| The routine is passed various bits of information about the |
1475 | config TUSB6010 | 130 | -| two NaNs and should return 0 to select NaN a and 1 for NaN b. |
1476 | bool | 131 | -| Note that signalling NaNs are always squashed to quiet NaNs |
1477 | select USB_MUSB | 132 | -| by the caller, by calling floatXX_silence_nan() before |
1478 | diff --git a/hw/usb/Makefile.objs b/hw/usb/Makefile.objs | 133 | -| returning them. |
1479 | index XXXXXXX..XXXXXXX 100644 | 134 | -| |
1480 | --- a/hw/usb/Makefile.objs | 135 | -| aIsLargerSignificand is only valid if both a and b are NaNs |
1481 | +++ b/hw/usb/Makefile.objs | 136 | -| of some kind, and is true if a has the larger significand, |
1482 | @@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_USB_EHCI_SYSBUS) += hcd-ehci-sysbus.o | 137 | -| or if both a and b have the same significand but a is |
1483 | common-obj-$(CONFIG_USB_XHCI) += hcd-xhci.o | 138 | -| positive but b is negative. It is only needed for the x87 |
1484 | common-obj-$(CONFIG_USB_XHCI_NEC) += hcd-xhci-nec.o | 139 | -| tie-break rule. |
1485 | common-obj-$(CONFIG_USB_MUSB) += hcd-musb.o | 140 | -*----------------------------------------------------------------------------*/ |
1486 | +common-obj-$(CONFIG_USB_DWC2) += hcd-dwc2.o | 141 | - |
1487 | 142 | -static int pickNaN(FloatClass a_cls, FloatClass b_cls, | |
1488 | common-obj-$(CONFIG_TUSB6010) += tusb6010.o | 143 | - bool aIsLargerSignificand, float_status *status) |
1489 | common-obj-$(CONFIG_IMX) += chipidea.o | 144 | -{ |
1490 | diff --git a/hw/usb/trace-events b/hw/usb/trace-events | 145 | - /* |
1491 | index XXXXXXX..XXXXXXX 100644 | 146 | - * We guarantee not to require the target to tell us how to |
1492 | --- a/hw/usb/trace-events | 147 | - * pick a NaN if we're always returning the default NaN. |
1493 | +++ b/hw/usb/trace-events | 148 | - * But if we're not in default-NaN mode then the target must |
1494 | @@ -XXX,XX +XXX,XX @@ usb_xhci_xfer_error(void *xfer, uint32_t ret) "%p: ret %d" | 149 | - * specify via set_float_2nan_prop_rule(). |
1495 | usb_xhci_unimplemented(const char *item, int nr) "%s (0x%x)" | 150 | - */ |
1496 | usb_xhci_enforced_limit(const char *item) "%s" | 151 | - assert(!status->default_nan_mode); |
1497 | 152 | - | |
1498 | +# hcd-dwc2.c | 153 | - switch (status->float_2nan_prop_rule) { |
1499 | +usb_dwc2_update_irq(uint32_t level) "level=%d" | 154 | - case float_2nan_prop_s_ab: |
1500 | +usb_dwc2_raise_global_irq(uint32_t intr) "0x%08x" | 155 | - if (is_snan(a_cls)) { |
1501 | +usb_dwc2_lower_global_irq(uint32_t intr) "0x%08x" | 156 | - return 0; |
1502 | +usb_dwc2_raise_host_irq(uint32_t intr) "0x%04x" | 157 | - } else if (is_snan(b_cls)) { |
1503 | +usb_dwc2_lower_host_irq(uint32_t intr) "0x%04x" | 158 | - return 1; |
1504 | +usb_dwc2_sof(int64_t next) "next SOF %" PRId64 | 159 | - } else if (is_qnan(a_cls)) { |
1505 | +usb_dwc2_bus_start(void) "start SOFs" | 160 | - return 0; |
1506 | +usb_dwc2_bus_stop(void) "stop SOFs" | 161 | - } else { |
1507 | +usb_dwc2_find_device(uint8_t addr) "%d" | 162 | - return 1; |
1508 | +usb_dwc2_port_disabled(uint32_t pnum) "port %d disabled" | 163 | - } |
1509 | +usb_dwc2_device_found(uint32_t pnum) "device found on port %d" | 164 | - break; |
1510 | +usb_dwc2_device_not_found(void) "device not found" | 165 | - case float_2nan_prop_s_ba: |
1511 | +usb_dwc2_handle_packet(uint32_t chan, void *dev, void *pkt, uint32_t ep, const char *type, const char *dir, uint32_t mps, uint32_t len, uint32_t pcnt) "ch %d dev %p pkt %p ep %d type %s dir %s mps %d len %d pcnt %d" | 166 | - if (is_snan(b_cls)) { |
1512 | +usb_dwc2_memory_read(uint32_t addr, uint32_t len) "addr %d len %d" | 167 | - return 1; |
1513 | +usb_dwc2_packet_status(const char *status, uint32_t len) "status %s len %d" | 168 | - } else if (is_snan(a_cls)) { |
1514 | +usb_dwc2_packet_error(const char *status) "ERROR %s" | 169 | - return 0; |
1515 | +usb_dwc2_async_packet(void *pkt, uint32_t chan, void *dev, uint32_t ep, const char *dir, uint32_t len) "pkt %p ch %d dev %p ep %d %s len %d" | 170 | - } else if (is_qnan(b_cls)) { |
1516 | +usb_dwc2_memory_write(uint32_t addr, uint32_t len) "addr %d len %d" | 171 | - return 1; |
1517 | +usb_dwc2_packet_done(const char *status, uint32_t actual, uint32_t len, uint32_t pcnt) "status %s actual %d len %d pcnt %d" | 172 | - } else { |
1518 | +usb_dwc2_packet_next(const char *status, uint32_t len, uint32_t pcnt) "status %s len %d pcnt %d" | 173 | - return 0; |
1519 | +usb_dwc2_attach(void *port) "port %p" | 174 | - } |
1520 | +usb_dwc2_attach_speed(const char *speed) "%s-speed device attached" | 175 | - break; |
1521 | +usb_dwc2_detach(void *port) "port %p" | 176 | - case float_2nan_prop_ab: |
1522 | +usb_dwc2_child_detach(void *port, void *child) "port %p child %p" | 177 | - if (is_nan(a_cls)) { |
1523 | +usb_dwc2_wakeup(void *port) "port %p" | 178 | - return 0; |
1524 | +usb_dwc2_async_packet_complete(void *port, void *pkt, uint32_t chan, void *dev, uint32_t ep, const char *dir, uint32_t len) "port %p packet %p ch %d dev %p ep %d %s len %d" | 179 | - } else { |
1525 | +usb_dwc2_work_bh(void) "" | 180 | - return 1; |
1526 | +usb_dwc2_work_bh_service(uint32_t first, uint32_t current, void *dev, uint32_t ep) "first %d servicing %d dev %p ep %d" | 181 | - } |
1527 | +usb_dwc2_work_bh_next(uint32_t chan) "next %d" | 182 | - break; |
1528 | +usb_dwc2_enable_chan(uint32_t chan, void *dev, void *pkt, uint32_t ep) "ch %d dev %p pkt %p ep %d" | 183 | - case float_2nan_prop_ba: |
1529 | +usb_dwc2_glbreg_read(uint64_t addr, const char *reg, uint32_t val) " 0x%04" PRIx64 " %s val 0x%08x" | 184 | - if (is_nan(b_cls)) { |
1530 | +usb_dwc2_glbreg_write(uint64_t addr, const char *reg, uint64_t val, uint32_t old, uint64_t result) "0x%04" PRIx64 " %s val 0x%08" PRIx64 " old 0x%08x result 0x%08" PRIx64 | 185 | - return 1; |
1531 | +usb_dwc2_fszreg_read(uint64_t addr, uint32_t val) " 0x%04" PRIx64 " HPTXFSIZ val 0x%08x" | 186 | - } else { |
1532 | +usb_dwc2_fszreg_write(uint64_t addr, uint64_t val, uint32_t old, uint64_t result) "0x%04" PRIx64 " HPTXFSIZ val 0x%08" PRIx64 " old 0x%08x result 0x%08" PRIx64 | 187 | - return 0; |
1533 | +usb_dwc2_hreg0_read(uint64_t addr, const char *reg, uint32_t val) " 0x%04" PRIx64 " %s val 0x%08x" | 188 | - } |
1534 | +usb_dwc2_hreg0_write(uint64_t addr, const char *reg, uint64_t val, uint32_t old, uint64_t result) " 0x%04" PRIx64 " %s val 0x%08" PRIx64 " old 0x%08x result 0x%08" PRIx64 | 189 | - break; |
1535 | +usb_dwc2_hreg1_read(uint64_t addr, const char *reg, uint64_t chan, uint32_t val) " 0x%04" PRIx64 " %s%" PRId64 " val 0x%08x" | 190 | - case float_2nan_prop_x87: |
1536 | +usb_dwc2_hreg1_write(uint64_t addr, const char *reg, uint64_t chan, uint64_t val, uint32_t old, uint64_t result) " 0x%04" PRIx64 " %s%" PRId64 " val 0x%08" PRIx64 " old 0x%08x result 0x%08" PRIx64 | 191 | - /* |
1537 | +usb_dwc2_pcgreg_read(uint64_t addr, const char *reg, uint32_t val) " 0x%04" PRIx64 " %s val 0x%08x" | 192 | - * This implements x87 NaN propagation rules: |
1538 | +usb_dwc2_pcgreg_write(uint64_t addr, const char *reg, uint64_t val, uint32_t old, uint64_t result) "0x%04" PRIx64 " %s val 0x%08" PRIx64 " old 0x%08x result 0x%08" PRIx64 | 193 | - * SNaN + QNaN => return the QNaN |
1539 | +usb_dwc2_hreg2_read(uint64_t addr, uint64_t fifo, uint32_t val) " 0x%04" PRIx64 " FIFO%" PRId64 " val 0x%08x" | 194 | - * two SNaNs => return the one with the larger significand, silenced |
1540 | +usb_dwc2_hreg2_write(uint64_t addr, uint64_t fifo, uint64_t val, uint32_t old, uint64_t result) " 0x%04" PRIx64 " FIFO%" PRId64 " val 0x%08" PRIx64 " old 0x%08x result 0x%08" PRIx64 | 195 | - * two QNaNs => return the one with the larger significand |
1541 | +usb_dwc2_hreg0_action(const char *s) "%s" | 196 | - * SNaN and a non-NaN => return the SNaN, silenced |
1542 | +usb_dwc2_wakeup_endpoint(void *ep, uint32_t stream) "endp %p stream %d" | 197 | - * QNaN and a non-NaN => return the QNaN |
1543 | +usb_dwc2_work_timer(void) "" | 198 | - * |
1544 | +usb_dwc2_reset_enter(void) "=== RESET enter ===" | 199 | - * If we get down to comparing significands and they are the same, |
1545 | +usb_dwc2_reset_hold(void) "=== RESET hold ===" | 200 | - * return the NaN with the positive sign bit (if any). |
1546 | +usb_dwc2_reset_exit(void) "=== RESET exit ===" | 201 | - */ |
1547 | + | 202 | - if (is_snan(a_cls)) { |
1548 | # desc.c | 203 | - if (is_snan(b_cls)) { |
1549 | usb_desc_device(int addr, int len, int ret) "dev %d query device, len %d, ret %d" | 204 | - return aIsLargerSignificand ? 0 : 1; |
1550 | usb_desc_device_qualifier(int addr, int len, int ret) "dev %d query device qualifier, len %d, ret %d" | 205 | - } |
206 | - return is_qnan(b_cls) ? 1 : 0; | ||
207 | - } else if (is_qnan(a_cls)) { | ||
208 | - if (is_snan(b_cls) || !is_qnan(b_cls)) { | ||
209 | - return 0; | ||
210 | - } else { | ||
211 | - return aIsLargerSignificand ? 0 : 1; | ||
212 | - } | ||
213 | - } else { | ||
214 | - return 1; | ||
215 | - } | ||
216 | - default: | ||
217 | - g_assert_not_reached(); | ||
218 | - } | ||
219 | -} | ||
220 | - | ||
221 | /*---------------------------------------------------------------------------- | ||
222 | | Returns 1 if the double-precision floating-point value `a' is a quiet | ||
223 | | NaN; otherwise returns 0. | ||
1551 | -- | 224 | -- |
1552 | 2.20.1 | 225 | 2.34.1 |
1553 | 226 | ||
1554 | 227 | diff view generated by jsdifflib |
1 | From: Paul Zimmerman <pauldzim@gmail.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Import the dwc-hsotg (dwc2) register definitions file from the | 3 | Remember if there was an SNaN, and use that to simplify |
4 | Linux kernel. This is a copy of drivers/usb/dwc2/hw.h from the | 4 | float_2nan_prop_s_{ab,ba} to only the snan component. |
5 | mainline Linux kernel, the only changes being to the header, and | 5 | Then, fall through to the corresponding |
6 | two instances of 'u32' changed to 'uint32_t' to allow it to | 6 | float_2nan_prop_{ab,ba} case to handle any remaining |
7 | compile. Checkpatch throws a boatload of errors due to the tab | 7 | nans, which must be quiet. |
8 | indentation, but I would rather import it as-is than reformat it. | ||
9 | 8 | ||
10 | Signed-off-by: Paul Zimmerman <pauldzim@gmail.com> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Message-id: 20200520235349.21215-3-pauldzim@gmail.com | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Message-id: 20241203203949.483774-10-richard.henderson@linaro.org | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 13 | --- |
15 | include/hw/usb/dwc2-regs.h | 899 +++++++++++++++++++++++++++++++++++++ | 14 | fpu/softfloat-parts.c.inc | 32 ++++++++++++-------------------- |
16 | 1 file changed, 899 insertions(+) | 15 | 1 file changed, 12 insertions(+), 20 deletions(-) |
17 | create mode 100644 include/hw/usb/dwc2-regs.h | ||
18 | 16 | ||
19 | diff --git a/include/hw/usb/dwc2-regs.h b/include/hw/usb/dwc2-regs.h | 17 | diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc |
20 | new file mode 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
21 | index XXXXXXX..XXXXXXX | 19 | --- a/fpu/softfloat-parts.c.inc |
22 | --- /dev/null | 20 | +++ b/fpu/softfloat-parts.c.inc |
23 | +++ b/include/hw/usb/dwc2-regs.h | 21 | @@ -XXX,XX +XXX,XX @@ static void partsN(return_nan)(FloatPartsN *a, float_status *s) |
24 | @@ -XXX,XX +XXX,XX @@ | 22 | static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b, |
25 | +/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */ | 23 | float_status *s) |
26 | +/* | 24 | { |
27 | + * Imported from the Linux kernel file drivers/usb/dwc2/hw.h, commit | 25 | + bool have_snan = false; |
28 | + * a89bae709b3492b478480a2c9734e7e9393b279c ("usb: dwc2: Move | 26 | int cmp, which; |
29 | + * UTMI_PHY_DATA defines closer") | 27 | |
30 | + * | 28 | if (is_snan(a->cls) || is_snan(b->cls)) { |
31 | + * hw.h - DesignWare HS OTG Controller hardware definitions | 29 | float_raise(float_flag_invalid | float_flag_invalid_snan, s); |
32 | + * | 30 | + have_snan = true; |
33 | + * Copyright 2004-2013 Synopsys, Inc. | 31 | } |
34 | + * | 32 | |
35 | + * Redistribution and use in source and binary forms, with or without | 33 | if (s->default_nan_mode) { |
36 | + * modification, are permitted provided that the following conditions | 34 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b, |
37 | + * are met: | 35 | |
38 | + * 1. Redistributions of source code must retain the above copyright | 36 | switch (s->float_2nan_prop_rule) { |
39 | + * notice, this list of conditions, and the following disclaimer, | 37 | case float_2nan_prop_s_ab: |
40 | + * without modification. | 38 | - if (is_snan(a->cls)) { |
41 | + * 2. Redistributions in binary form must reproduce the above copyright | 39 | - which = 0; |
42 | + * notice, this list of conditions and the following disclaimer in the | 40 | - } else if (is_snan(b->cls)) { |
43 | + * documentation and/or other materials provided with the distribution. | 41 | - which = 1; |
44 | + * 3. The names of the above-listed copyright holders may not be used | 42 | - } else if (is_qnan(a->cls)) { |
45 | + * to endorse or promote products derived from this software without | 43 | - which = 0; |
46 | + * specific prior written permission. | 44 | - } else { |
47 | + * | 45 | - which = 1; |
48 | + * ALTERNATIVELY, this software may be distributed under the terms of the | 46 | + if (have_snan) { |
49 | + * GNU General Public License ("GPL") as published by the Free Software | 47 | + which = is_snan(a->cls) ? 0 : 1; |
50 | + * Foundation; either version 2 of the License, or (at your option) any | 48 | + break; |
51 | + * later version. | 49 | } |
52 | + * | 50 | - break; |
53 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | 51 | - case float_2nan_prop_s_ba: |
54 | + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | 52 | - if (is_snan(b->cls)) { |
55 | + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 53 | - which = 1; |
56 | + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | 54 | - } else if (is_snan(a->cls)) { |
57 | + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 55 | - which = 0; |
58 | + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 56 | - } else if (is_qnan(b->cls)) { |
59 | + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 57 | - which = 1; |
60 | + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 58 | - } else { |
61 | + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 59 | - which = 0; |
62 | + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 60 | - } |
63 | + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 61 | - break; |
64 | + */ | 62 | + /* fall through */ |
65 | + | 63 | case float_2nan_prop_ab: |
66 | +#ifndef __DWC2_HW_H__ | 64 | which = is_nan(a->cls) ? 0 : 1; |
67 | +#define __DWC2_HW_H__ | 65 | break; |
68 | + | 66 | + case float_2nan_prop_s_ba: |
69 | +#define HSOTG_REG(x) (x) | 67 | + if (have_snan) { |
70 | + | 68 | + which = is_snan(b->cls) ? 1 : 0; |
71 | +#define GOTGCTL HSOTG_REG(0x000) | 69 | + break; |
72 | +#define GOTGCTL_CHIRPEN BIT(27) | 70 | + } |
73 | +#define GOTGCTL_MULT_VALID_BC_MASK (0x1f << 22) | 71 | + /* fall through */ |
74 | +#define GOTGCTL_MULT_VALID_BC_SHIFT 22 | 72 | case float_2nan_prop_ba: |
75 | +#define GOTGCTL_OTGVER BIT(20) | 73 | which = is_nan(b->cls) ? 1 : 0; |
76 | +#define GOTGCTL_BSESVLD BIT(19) | 74 | break; |
77 | +#define GOTGCTL_ASESVLD BIT(18) | ||
78 | +#define GOTGCTL_DBNC_SHORT BIT(17) | ||
79 | +#define GOTGCTL_CONID_B BIT(16) | ||
80 | +#define GOTGCTL_DBNCE_FLTR_BYPASS BIT(15) | ||
81 | +#define GOTGCTL_DEVHNPEN BIT(11) | ||
82 | +#define GOTGCTL_HSTSETHNPEN BIT(10) | ||
83 | +#define GOTGCTL_HNPREQ BIT(9) | ||
84 | +#define GOTGCTL_HSTNEGSCS BIT(8) | ||
85 | +#define GOTGCTL_SESREQ BIT(1) | ||
86 | +#define GOTGCTL_SESREQSCS BIT(0) | ||
87 | + | ||
88 | +#define GOTGINT HSOTG_REG(0x004) | ||
89 | +#define GOTGINT_DBNCE_DONE BIT(19) | ||
90 | +#define GOTGINT_A_DEV_TOUT_CHG BIT(18) | ||
91 | +#define GOTGINT_HST_NEG_DET BIT(17) | ||
92 | +#define GOTGINT_HST_NEG_SUC_STS_CHNG BIT(9) | ||
93 | +#define GOTGINT_SES_REQ_SUC_STS_CHNG BIT(8) | ||
94 | +#define GOTGINT_SES_END_DET BIT(2) | ||
95 | + | ||
96 | +#define GAHBCFG HSOTG_REG(0x008) | ||
97 | +#define GAHBCFG_AHB_SINGLE BIT(23) | ||
98 | +#define GAHBCFG_NOTI_ALL_DMA_WRIT BIT(22) | ||
99 | +#define GAHBCFG_REM_MEM_SUPP BIT(21) | ||
100 | +#define GAHBCFG_P_TXF_EMP_LVL BIT(8) | ||
101 | +#define GAHBCFG_NP_TXF_EMP_LVL BIT(7) | ||
102 | +#define GAHBCFG_DMA_EN BIT(5) | ||
103 | +#define GAHBCFG_HBSTLEN_MASK (0xf << 1) | ||
104 | +#define GAHBCFG_HBSTLEN_SHIFT 1 | ||
105 | +#define GAHBCFG_HBSTLEN_SINGLE 0 | ||
106 | +#define GAHBCFG_HBSTLEN_INCR 1 | ||
107 | +#define GAHBCFG_HBSTLEN_INCR4 3 | ||
108 | +#define GAHBCFG_HBSTLEN_INCR8 5 | ||
109 | +#define GAHBCFG_HBSTLEN_INCR16 7 | ||
110 | +#define GAHBCFG_GLBL_INTR_EN BIT(0) | ||
111 | +#define GAHBCFG_CTRL_MASK (GAHBCFG_P_TXF_EMP_LVL | \ | ||
112 | + GAHBCFG_NP_TXF_EMP_LVL | \ | ||
113 | + GAHBCFG_DMA_EN | \ | ||
114 | + GAHBCFG_GLBL_INTR_EN) | ||
115 | + | ||
116 | +#define GUSBCFG HSOTG_REG(0x00C) | ||
117 | +#define GUSBCFG_FORCEDEVMODE BIT(30) | ||
118 | +#define GUSBCFG_FORCEHOSTMODE BIT(29) | ||
119 | +#define GUSBCFG_TXENDDELAY BIT(28) | ||
120 | +#define GUSBCFG_ICTRAFFICPULLREMOVE BIT(27) | ||
121 | +#define GUSBCFG_ICUSBCAP BIT(26) | ||
122 | +#define GUSBCFG_ULPI_INT_PROT_DIS BIT(25) | ||
123 | +#define GUSBCFG_INDICATORPASSTHROUGH BIT(24) | ||
124 | +#define GUSBCFG_INDICATORCOMPLEMENT BIT(23) | ||
125 | +#define GUSBCFG_TERMSELDLPULSE BIT(22) | ||
126 | +#define GUSBCFG_ULPI_INT_VBUS_IND BIT(21) | ||
127 | +#define GUSBCFG_ULPI_EXT_VBUS_DRV BIT(20) | ||
128 | +#define GUSBCFG_ULPI_CLK_SUSP_M BIT(19) | ||
129 | +#define GUSBCFG_ULPI_AUTO_RES BIT(18) | ||
130 | +#define GUSBCFG_ULPI_FS_LS BIT(17) | ||
131 | +#define GUSBCFG_OTG_UTMI_FS_SEL BIT(16) | ||
132 | +#define GUSBCFG_PHY_LP_CLK_SEL BIT(15) | ||
133 | +#define GUSBCFG_USBTRDTIM_MASK (0xf << 10) | ||
134 | +#define GUSBCFG_USBTRDTIM_SHIFT 10 | ||
135 | +#define GUSBCFG_HNPCAP BIT(9) | ||
136 | +#define GUSBCFG_SRPCAP BIT(8) | ||
137 | +#define GUSBCFG_DDRSEL BIT(7) | ||
138 | +#define GUSBCFG_PHYSEL BIT(6) | ||
139 | +#define GUSBCFG_FSINTF BIT(5) | ||
140 | +#define GUSBCFG_ULPI_UTMI_SEL BIT(4) | ||
141 | +#define GUSBCFG_PHYIF16 BIT(3) | ||
142 | +#define GUSBCFG_PHYIF8 (0 << 3) | ||
143 | +#define GUSBCFG_TOUTCAL_MASK (0x7 << 0) | ||
144 | +#define GUSBCFG_TOUTCAL_SHIFT 0 | ||
145 | +#define GUSBCFG_TOUTCAL_LIMIT 0x7 | ||
146 | +#define GUSBCFG_TOUTCAL(_x) ((_x) << 0) | ||
147 | + | ||
148 | +#define GRSTCTL HSOTG_REG(0x010) | ||
149 | +#define GRSTCTL_AHBIDLE BIT(31) | ||
150 | +#define GRSTCTL_DMAREQ BIT(30) | ||
151 | +#define GRSTCTL_TXFNUM_MASK (0x1f << 6) | ||
152 | +#define GRSTCTL_TXFNUM_SHIFT 6 | ||
153 | +#define GRSTCTL_TXFNUM_LIMIT 0x1f | ||
154 | +#define GRSTCTL_TXFNUM(_x) ((_x) << 6) | ||
155 | +#define GRSTCTL_TXFFLSH BIT(5) | ||
156 | +#define GRSTCTL_RXFFLSH BIT(4) | ||
157 | +#define GRSTCTL_IN_TKNQ_FLSH BIT(3) | ||
158 | +#define GRSTCTL_FRMCNTRRST BIT(2) | ||
159 | +#define GRSTCTL_HSFTRST BIT(1) | ||
160 | +#define GRSTCTL_CSFTRST BIT(0) | ||
161 | + | ||
162 | +#define GINTSTS HSOTG_REG(0x014) | ||
163 | +#define GINTMSK HSOTG_REG(0x018) | ||
164 | +#define GINTSTS_WKUPINT BIT(31) | ||
165 | +#define GINTSTS_SESSREQINT BIT(30) | ||
166 | +#define GINTSTS_DISCONNINT BIT(29) | ||
167 | +#define GINTSTS_CONIDSTSCHNG BIT(28) | ||
168 | +#define GINTSTS_LPMTRANRCVD BIT(27) | ||
169 | +#define GINTSTS_PTXFEMP BIT(26) | ||
170 | +#define GINTSTS_HCHINT BIT(25) | ||
171 | +#define GINTSTS_PRTINT BIT(24) | ||
172 | +#define GINTSTS_RESETDET BIT(23) | ||
173 | +#define GINTSTS_FET_SUSP BIT(22) | ||
174 | +#define GINTSTS_INCOMPL_IP BIT(21) | ||
175 | +#define GINTSTS_INCOMPL_SOOUT BIT(21) | ||
176 | +#define GINTSTS_INCOMPL_SOIN BIT(20) | ||
177 | +#define GINTSTS_OEPINT BIT(19) | ||
178 | +#define GINTSTS_IEPINT BIT(18) | ||
179 | +#define GINTSTS_EPMIS BIT(17) | ||
180 | +#define GINTSTS_RESTOREDONE BIT(16) | ||
181 | +#define GINTSTS_EOPF BIT(15) | ||
182 | +#define GINTSTS_ISOUTDROP BIT(14) | ||
183 | +#define GINTSTS_ENUMDONE BIT(13) | ||
184 | +#define GINTSTS_USBRST BIT(12) | ||
185 | +#define GINTSTS_USBSUSP BIT(11) | ||
186 | +#define GINTSTS_ERLYSUSP BIT(10) | ||
187 | +#define GINTSTS_I2CINT BIT(9) | ||
188 | +#define GINTSTS_ULPI_CK_INT BIT(8) | ||
189 | +#define GINTSTS_GOUTNAKEFF BIT(7) | ||
190 | +#define GINTSTS_GINNAKEFF BIT(6) | ||
191 | +#define GINTSTS_NPTXFEMP BIT(5) | ||
192 | +#define GINTSTS_RXFLVL BIT(4) | ||
193 | +#define GINTSTS_SOF BIT(3) | ||
194 | +#define GINTSTS_OTGINT BIT(2) | ||
195 | +#define GINTSTS_MODEMIS BIT(1) | ||
196 | +#define GINTSTS_CURMODE_HOST BIT(0) | ||
197 | + | ||
198 | +#define GRXSTSR HSOTG_REG(0x01C) | ||
199 | +#define GRXSTSP HSOTG_REG(0x020) | ||
200 | +#define GRXSTS_FN_MASK (0x7f << 25) | ||
201 | +#define GRXSTS_FN_SHIFT 25 | ||
202 | +#define GRXSTS_PKTSTS_MASK (0xf << 17) | ||
203 | +#define GRXSTS_PKTSTS_SHIFT 17 | ||
204 | +#define GRXSTS_PKTSTS_GLOBALOUTNAK 1 | ||
205 | +#define GRXSTS_PKTSTS_OUTRX 2 | ||
206 | +#define GRXSTS_PKTSTS_HCHIN 2 | ||
207 | +#define GRXSTS_PKTSTS_OUTDONE 3 | ||
208 | +#define GRXSTS_PKTSTS_HCHIN_XFER_COMP 3 | ||
209 | +#define GRXSTS_PKTSTS_SETUPDONE 4 | ||
210 | +#define GRXSTS_PKTSTS_DATATOGGLEERR 5 | ||
211 | +#define GRXSTS_PKTSTS_SETUPRX 6 | ||
212 | +#define GRXSTS_PKTSTS_HCHHALTED 7 | ||
213 | +#define GRXSTS_HCHNUM_MASK (0xf << 0) | ||
214 | +#define GRXSTS_HCHNUM_SHIFT 0 | ||
215 | +#define GRXSTS_DPID_MASK (0x3 << 15) | ||
216 | +#define GRXSTS_DPID_SHIFT 15 | ||
217 | +#define GRXSTS_BYTECNT_MASK (0x7ff << 4) | ||
218 | +#define GRXSTS_BYTECNT_SHIFT 4 | ||
219 | +#define GRXSTS_EPNUM_MASK (0xf << 0) | ||
220 | +#define GRXSTS_EPNUM_SHIFT 0 | ||
221 | + | ||
222 | +#define GRXFSIZ HSOTG_REG(0x024) | ||
223 | +#define GRXFSIZ_DEPTH_MASK (0xffff << 0) | ||
224 | +#define GRXFSIZ_DEPTH_SHIFT 0 | ||
225 | + | ||
226 | +#define GNPTXFSIZ HSOTG_REG(0x028) | ||
227 | +/* Use FIFOSIZE_* constants to access this register */ | ||
228 | + | ||
229 | +#define GNPTXSTS HSOTG_REG(0x02C) | ||
230 | +#define GNPTXSTS_NP_TXQ_TOP_MASK (0x7f << 24) | ||
231 | +#define GNPTXSTS_NP_TXQ_TOP_SHIFT 24 | ||
232 | +#define GNPTXSTS_NP_TXQ_SPC_AVAIL_MASK (0xff << 16) | ||
233 | +#define GNPTXSTS_NP_TXQ_SPC_AVAIL_SHIFT 16 | ||
234 | +#define GNPTXSTS_NP_TXQ_SPC_AVAIL_GET(_v) (((_v) >> 16) & 0xff) | ||
235 | +#define GNPTXSTS_NP_TXF_SPC_AVAIL_MASK (0xffff << 0) | ||
236 | +#define GNPTXSTS_NP_TXF_SPC_AVAIL_SHIFT 0 | ||
237 | +#define GNPTXSTS_NP_TXF_SPC_AVAIL_GET(_v) (((_v) >> 0) & 0xffff) | ||
238 | + | ||
239 | +#define GI2CCTL HSOTG_REG(0x0030) | ||
240 | +#define GI2CCTL_BSYDNE BIT(31) | ||
241 | +#define GI2CCTL_RW BIT(30) | ||
242 | +#define GI2CCTL_I2CDATSE0 BIT(28) | ||
243 | +#define GI2CCTL_I2CDEVADDR_MASK (0x3 << 26) | ||
244 | +#define GI2CCTL_I2CDEVADDR_SHIFT 26 | ||
245 | +#define GI2CCTL_I2CSUSPCTL BIT(25) | ||
246 | +#define GI2CCTL_ACK BIT(24) | ||
247 | +#define GI2CCTL_I2CEN BIT(23) | ||
248 | +#define GI2CCTL_ADDR_MASK (0x7f << 16) | ||
249 | +#define GI2CCTL_ADDR_SHIFT 16 | ||
250 | +#define GI2CCTL_REGADDR_MASK (0xff << 8) | ||
251 | +#define GI2CCTL_REGADDR_SHIFT 8 | ||
252 | +#define GI2CCTL_RWDATA_MASK (0xff << 0) | ||
253 | +#define GI2CCTL_RWDATA_SHIFT 0 | ||
254 | + | ||
255 | +#define GPVNDCTL HSOTG_REG(0x0034) | ||
256 | +#define GGPIO HSOTG_REG(0x0038) | ||
257 | +#define GGPIO_STM32_OTG_GCCFG_PWRDWN BIT(16) | ||
258 | + | ||
259 | +#define GUID HSOTG_REG(0x003c) | ||
260 | +#define GSNPSID HSOTG_REG(0x0040) | ||
261 | +#define GHWCFG1 HSOTG_REG(0x0044) | ||
262 | +#define GSNPSID_ID_MASK GENMASK(31, 16) | ||
263 | + | ||
264 | +#define GHWCFG2 HSOTG_REG(0x0048) | ||
265 | +#define GHWCFG2_OTG_ENABLE_IC_USB BIT(31) | ||
266 | +#define GHWCFG2_DEV_TOKEN_Q_DEPTH_MASK (0x1f << 26) | ||
267 | +#define GHWCFG2_DEV_TOKEN_Q_DEPTH_SHIFT 26 | ||
268 | +#define GHWCFG2_HOST_PERIO_TX_Q_DEPTH_MASK (0x3 << 24) | ||
269 | +#define GHWCFG2_HOST_PERIO_TX_Q_DEPTH_SHIFT 24 | ||
270 | +#define GHWCFG2_NONPERIO_TX_Q_DEPTH_MASK (0x3 << 22) | ||
271 | +#define GHWCFG2_NONPERIO_TX_Q_DEPTH_SHIFT 22 | ||
272 | +#define GHWCFG2_MULTI_PROC_INT BIT(20) | ||
273 | +#define GHWCFG2_DYNAMIC_FIFO BIT(19) | ||
274 | +#define GHWCFG2_PERIO_EP_SUPPORTED BIT(18) | ||
275 | +#define GHWCFG2_NUM_HOST_CHAN_MASK (0xf << 14) | ||
276 | +#define GHWCFG2_NUM_HOST_CHAN_SHIFT 14 | ||
277 | +#define GHWCFG2_NUM_DEV_EP_MASK (0xf << 10) | ||
278 | +#define GHWCFG2_NUM_DEV_EP_SHIFT 10 | ||
279 | +#define GHWCFG2_FS_PHY_TYPE_MASK (0x3 << 8) | ||
280 | +#define GHWCFG2_FS_PHY_TYPE_SHIFT 8 | ||
281 | +#define GHWCFG2_FS_PHY_TYPE_NOT_SUPPORTED 0 | ||
282 | +#define GHWCFG2_FS_PHY_TYPE_DEDICATED 1 | ||
283 | +#define GHWCFG2_FS_PHY_TYPE_SHARED_UTMI 2 | ||
284 | +#define GHWCFG2_FS_PHY_TYPE_SHARED_ULPI 3 | ||
285 | +#define GHWCFG2_HS_PHY_TYPE_MASK (0x3 << 6) | ||
286 | +#define GHWCFG2_HS_PHY_TYPE_SHIFT 6 | ||
287 | +#define GHWCFG2_HS_PHY_TYPE_NOT_SUPPORTED 0 | ||
288 | +#define GHWCFG2_HS_PHY_TYPE_UTMI 1 | ||
289 | +#define GHWCFG2_HS_PHY_TYPE_ULPI 2 | ||
290 | +#define GHWCFG2_HS_PHY_TYPE_UTMI_ULPI 3 | ||
291 | +#define GHWCFG2_POINT2POINT BIT(5) | ||
292 | +#define GHWCFG2_ARCHITECTURE_MASK (0x3 << 3) | ||
293 | +#define GHWCFG2_ARCHITECTURE_SHIFT 3 | ||
294 | +#define GHWCFG2_SLAVE_ONLY_ARCH 0 | ||
295 | +#define GHWCFG2_EXT_DMA_ARCH 1 | ||
296 | +#define GHWCFG2_INT_DMA_ARCH 2 | ||
297 | +#define GHWCFG2_OP_MODE_MASK (0x7 << 0) | ||
298 | +#define GHWCFG2_OP_MODE_SHIFT 0 | ||
299 | +#define GHWCFG2_OP_MODE_HNP_SRP_CAPABLE 0 | ||
300 | +#define GHWCFG2_OP_MODE_SRP_ONLY_CAPABLE 1 | ||
301 | +#define GHWCFG2_OP_MODE_NO_HNP_SRP_CAPABLE 2 | ||
302 | +#define GHWCFG2_OP_MODE_SRP_CAPABLE_DEVICE 3 | ||
303 | +#define GHWCFG2_OP_MODE_NO_SRP_CAPABLE_DEVICE 4 | ||
304 | +#define GHWCFG2_OP_MODE_SRP_CAPABLE_HOST 5 | ||
305 | +#define GHWCFG2_OP_MODE_NO_SRP_CAPABLE_HOST 6 | ||
306 | +#define GHWCFG2_OP_MODE_UNDEFINED 7 | ||
307 | + | ||
308 | +#define GHWCFG3 HSOTG_REG(0x004c) | ||
309 | +#define GHWCFG3_DFIFO_DEPTH_MASK (0xffff << 16) | ||
310 | +#define GHWCFG3_DFIFO_DEPTH_SHIFT 16 | ||
311 | +#define GHWCFG3_OTG_LPM_EN BIT(15) | ||
312 | +#define GHWCFG3_BC_SUPPORT BIT(14) | ||
313 | +#define GHWCFG3_OTG_ENABLE_HSIC BIT(13) | ||
314 | +#define GHWCFG3_ADP_SUPP BIT(12) | ||
315 | +#define GHWCFG3_SYNCH_RESET_TYPE BIT(11) | ||
316 | +#define GHWCFG3_OPTIONAL_FEATURES BIT(10) | ||
317 | +#define GHWCFG3_VENDOR_CTRL_IF BIT(9) | ||
318 | +#define GHWCFG3_I2C BIT(8) | ||
319 | +#define GHWCFG3_OTG_FUNC BIT(7) | ||
320 | +#define GHWCFG3_PACKET_SIZE_CNTR_WIDTH_MASK (0x7 << 4) | ||
321 | +#define GHWCFG3_PACKET_SIZE_CNTR_WIDTH_SHIFT 4 | ||
322 | +#define GHWCFG3_XFER_SIZE_CNTR_WIDTH_MASK (0xf << 0) | ||
323 | +#define GHWCFG3_XFER_SIZE_CNTR_WIDTH_SHIFT 0 | ||
324 | + | ||
325 | +#define GHWCFG4 HSOTG_REG(0x0050) | ||
326 | +#define GHWCFG4_DESC_DMA_DYN BIT(31) | ||
327 | +#define GHWCFG4_DESC_DMA BIT(30) | ||
328 | +#define GHWCFG4_NUM_IN_EPS_MASK (0xf << 26) | ||
329 | +#define GHWCFG4_NUM_IN_EPS_SHIFT 26 | ||
330 | +#define GHWCFG4_DED_FIFO_EN BIT(25) | ||
331 | +#define GHWCFG4_DED_FIFO_SHIFT 25 | ||
332 | +#define GHWCFG4_SESSION_END_FILT_EN BIT(24) | ||
333 | +#define GHWCFG4_B_VALID_FILT_EN BIT(23) | ||
334 | +#define GHWCFG4_A_VALID_FILT_EN BIT(22) | ||
335 | +#define GHWCFG4_VBUS_VALID_FILT_EN BIT(21) | ||
336 | +#define GHWCFG4_IDDIG_FILT_EN BIT(20) | ||
337 | +#define GHWCFG4_NUM_DEV_MODE_CTRL_EP_MASK (0xf << 16) | ||
338 | +#define GHWCFG4_NUM_DEV_MODE_CTRL_EP_SHIFT 16 | ||
339 | +#define GHWCFG4_UTMI_PHY_DATA_WIDTH_MASK (0x3 << 14) | ||
340 | +#define GHWCFG4_UTMI_PHY_DATA_WIDTH_SHIFT 14 | ||
341 | +#define GHWCFG4_UTMI_PHY_DATA_WIDTH_8 0 | ||
342 | +#define GHWCFG4_UTMI_PHY_DATA_WIDTH_16 1 | ||
343 | +#define GHWCFG4_UTMI_PHY_DATA_WIDTH_8_OR_16 2 | ||
344 | +#define GHWCFG4_ACG_SUPPORTED BIT(12) | ||
345 | +#define GHWCFG4_IPG_ISOC_SUPPORTED BIT(11) | ||
346 | +#define GHWCFG4_SERVICE_INTERVAL_SUPPORTED BIT(10) | ||
347 | +#define GHWCFG4_XHIBER BIT(7) | ||
348 | +#define GHWCFG4_HIBER BIT(6) | ||
349 | +#define GHWCFG4_MIN_AHB_FREQ BIT(5) | ||
350 | +#define GHWCFG4_POWER_OPTIMIZ BIT(4) | ||
351 | +#define GHWCFG4_NUM_DEV_PERIO_IN_EP_MASK (0xf << 0) | ||
352 | +#define GHWCFG4_NUM_DEV_PERIO_IN_EP_SHIFT 0 | ||
353 | + | ||
354 | +#define GLPMCFG HSOTG_REG(0x0054) | ||
355 | +#define GLPMCFG_INVSELHSIC BIT(31) | ||
356 | +#define GLPMCFG_HSICCON BIT(30) | ||
357 | +#define GLPMCFG_RSTRSLPSTS BIT(29) | ||
358 | +#define GLPMCFG_ENBESL BIT(28) | ||
359 | +#define GLPMCFG_LPM_RETRYCNT_STS_MASK (0x7 << 25) | ||
360 | +#define GLPMCFG_LPM_RETRYCNT_STS_SHIFT 25 | ||
361 | +#define GLPMCFG_SNDLPM BIT(24) | ||
362 | +#define GLPMCFG_RETRY_CNT_MASK (0x7 << 21) | ||
363 | +#define GLPMCFG_RETRY_CNT_SHIFT 21 | ||
364 | +#define GLPMCFG_LPM_REJECT_CTRL_CONTROL BIT(21) | ||
365 | +#define GLPMCFG_LPM_ACCEPT_CTRL_ISOC BIT(22) | ||
366 | +#define GLPMCFG_LPM_CHNL_INDX_MASK (0xf << 17) | ||
367 | +#define GLPMCFG_LPM_CHNL_INDX_SHIFT 17 | ||
368 | +#define GLPMCFG_L1RESUMEOK BIT(16) | ||
369 | +#define GLPMCFG_SLPSTS BIT(15) | ||
370 | +#define GLPMCFG_COREL1RES_MASK (0x3 << 13) | ||
371 | +#define GLPMCFG_COREL1RES_SHIFT 13 | ||
372 | +#define GLPMCFG_HIRD_THRES_MASK (0x1f << 8) | ||
373 | +#define GLPMCFG_HIRD_THRES_SHIFT 8 | ||
374 | +#define GLPMCFG_HIRD_THRES_EN (0x10 << 8) | ||
375 | +#define GLPMCFG_ENBLSLPM BIT(7) | ||
376 | +#define GLPMCFG_BREMOTEWAKE BIT(6) | ||
377 | +#define GLPMCFG_HIRD_MASK (0xf << 2) | ||
378 | +#define GLPMCFG_HIRD_SHIFT 2 | ||
379 | +#define GLPMCFG_APPL1RES BIT(1) | ||
380 | +#define GLPMCFG_LPMCAP BIT(0) | ||
381 | + | ||
382 | +#define GPWRDN HSOTG_REG(0x0058) | ||
383 | +#define GPWRDN_MULT_VAL_ID_BC_MASK (0x1f << 24) | ||
384 | +#define GPWRDN_MULT_VAL_ID_BC_SHIFT 24 | ||
385 | +#define GPWRDN_ADP_INT BIT(23) | ||
386 | +#define GPWRDN_BSESSVLD BIT(22) | ||
387 | +#define GPWRDN_IDSTS BIT(21) | ||
388 | +#define GPWRDN_LINESTATE_MASK (0x3 << 19) | ||
389 | +#define GPWRDN_LINESTATE_SHIFT 19 | ||
390 | +#define GPWRDN_STS_CHGINT_MSK BIT(18) | ||
391 | +#define GPWRDN_STS_CHGINT BIT(17) | ||
392 | +#define GPWRDN_SRP_DET_MSK BIT(16) | ||
393 | +#define GPWRDN_SRP_DET BIT(15) | ||
394 | +#define GPWRDN_CONNECT_DET_MSK BIT(14) | ||
395 | +#define GPWRDN_CONNECT_DET BIT(13) | ||
396 | +#define GPWRDN_DISCONN_DET_MSK BIT(12) | ||
397 | +#define GPWRDN_DISCONN_DET BIT(11) | ||
398 | +#define GPWRDN_RST_DET_MSK BIT(10) | ||
399 | +#define GPWRDN_RST_DET BIT(9) | ||
400 | +#define GPWRDN_LNSTSCHG_MSK BIT(8) | ||
401 | +#define GPWRDN_LNSTSCHG BIT(7) | ||
402 | +#define GPWRDN_DIS_VBUS BIT(6) | ||
403 | +#define GPWRDN_PWRDNSWTCH BIT(5) | ||
404 | +#define GPWRDN_PWRDNRSTN BIT(4) | ||
405 | +#define GPWRDN_PWRDNCLMP BIT(3) | ||
406 | +#define GPWRDN_RESTORE BIT(2) | ||
407 | +#define GPWRDN_PMUACTV BIT(1) | ||
408 | +#define GPWRDN_PMUINTSEL BIT(0) | ||
409 | + | ||
410 | +#define GDFIFOCFG HSOTG_REG(0x005c) | ||
411 | +#define GDFIFOCFG_EPINFOBASE_MASK (0xffff << 16) | ||
412 | +#define GDFIFOCFG_EPINFOBASE_SHIFT 16 | ||
413 | +#define GDFIFOCFG_GDFIFOCFG_MASK (0xffff << 0) | ||
414 | +#define GDFIFOCFG_GDFIFOCFG_SHIFT 0 | ||
415 | + | ||
416 | +#define ADPCTL HSOTG_REG(0x0060) | ||
417 | +#define ADPCTL_AR_MASK (0x3 << 27) | ||
418 | +#define ADPCTL_AR_SHIFT 27 | ||
419 | +#define ADPCTL_ADP_TMOUT_INT_MSK BIT(26) | ||
420 | +#define ADPCTL_ADP_SNS_INT_MSK BIT(25) | ||
421 | +#define ADPCTL_ADP_PRB_INT_MSK BIT(24) | ||
422 | +#define ADPCTL_ADP_TMOUT_INT BIT(23) | ||
423 | +#define ADPCTL_ADP_SNS_INT BIT(22) | ||
424 | +#define ADPCTL_ADP_PRB_INT BIT(21) | ||
425 | +#define ADPCTL_ADPENA BIT(20) | ||
426 | +#define ADPCTL_ADPRES BIT(19) | ||
427 | +#define ADPCTL_ENASNS BIT(18) | ||
428 | +#define ADPCTL_ENAPRB BIT(17) | ||
429 | +#define ADPCTL_RTIM_MASK (0x7ff << 6) | ||
430 | +#define ADPCTL_RTIM_SHIFT 6 | ||
431 | +#define ADPCTL_PRB_PER_MASK (0x3 << 4) | ||
432 | +#define ADPCTL_PRB_PER_SHIFT 4 | ||
433 | +#define ADPCTL_PRB_DELTA_MASK (0x3 << 2) | ||
434 | +#define ADPCTL_PRB_DELTA_SHIFT 2 | ||
435 | +#define ADPCTL_PRB_DSCHRG_MASK (0x3 << 0) | ||
436 | +#define ADPCTL_PRB_DSCHRG_SHIFT 0 | ||
437 | + | ||
438 | +#define GREFCLK HSOTG_REG(0x0064) | ||
439 | +#define GREFCLK_REFCLKPER_MASK (0x1ffff << 15) | ||
440 | +#define GREFCLK_REFCLKPER_SHIFT 15 | ||
441 | +#define GREFCLK_REF_CLK_MODE BIT(14) | ||
442 | +#define GREFCLK_SOF_CNT_WKUP_ALERT_MASK (0x3ff) | ||
443 | +#define GREFCLK_SOF_CNT_WKUP_ALERT_SHIFT 0 | ||
444 | + | ||
445 | +#define GINTMSK2 HSOTG_REG(0x0068) | ||
446 | +#define GINTMSK2_WKUP_ALERT_INT_MSK BIT(0) | ||
447 | + | ||
448 | +#define GINTSTS2 HSOTG_REG(0x006c) | ||
449 | +#define GINTSTS2_WKUP_ALERT_INT BIT(0) | ||
450 | + | ||
451 | +#define HPTXFSIZ HSOTG_REG(0x100) | ||
452 | +/* Use FIFOSIZE_* constants to access this register */ | ||
453 | + | ||
454 | +#define DPTXFSIZN(_a) HSOTG_REG(0x104 + (((_a) - 1) * 4)) | ||
455 | +/* Use FIFOSIZE_* constants to access this register */ | ||
456 | + | ||
457 | +/* These apply to the GNPTXFSIZ, HPTXFSIZ and DPTXFSIZN registers */ | ||
458 | +#define FIFOSIZE_DEPTH_MASK (0xffff << 16) | ||
459 | +#define FIFOSIZE_DEPTH_SHIFT 16 | ||
460 | +#define FIFOSIZE_STARTADDR_MASK (0xffff << 0) | ||
461 | +#define FIFOSIZE_STARTADDR_SHIFT 0 | ||
462 | +#define FIFOSIZE_DEPTH_GET(_x) (((_x) >> 16) & 0xffff) | ||
463 | + | ||
464 | +/* Device mode registers */ | ||
465 | + | ||
466 | +#define DCFG HSOTG_REG(0x800) | ||
467 | +#define DCFG_DESCDMA_EN BIT(23) | ||
468 | +#define DCFG_EPMISCNT_MASK (0x1f << 18) | ||
469 | +#define DCFG_EPMISCNT_SHIFT 18 | ||
470 | +#define DCFG_EPMISCNT_LIMIT 0x1f | ||
471 | +#define DCFG_EPMISCNT(_x) ((_x) << 18) | ||
472 | +#define DCFG_IPG_ISOC_SUPPORDED BIT(17) | ||
473 | +#define DCFG_PERFRINT_MASK (0x3 << 11) | ||
474 | +#define DCFG_PERFRINT_SHIFT 11 | ||
475 | +#define DCFG_PERFRINT_LIMIT 0x3 | ||
476 | +#define DCFG_PERFRINT(_x) ((_x) << 11) | ||
477 | +#define DCFG_DEVADDR_MASK (0x7f << 4) | ||
478 | +#define DCFG_DEVADDR_SHIFT 4 | ||
479 | +#define DCFG_DEVADDR_LIMIT 0x7f | ||
480 | +#define DCFG_DEVADDR(_x) ((_x) << 4) | ||
481 | +#define DCFG_NZ_STS_OUT_HSHK BIT(2) | ||
482 | +#define DCFG_DEVSPD_MASK (0x3 << 0) | ||
483 | +#define DCFG_DEVSPD_SHIFT 0 | ||
484 | +#define DCFG_DEVSPD_HS 0 | ||
485 | +#define DCFG_DEVSPD_FS 1 | ||
486 | +#define DCFG_DEVSPD_LS 2 | ||
487 | +#define DCFG_DEVSPD_FS48 3 | ||
488 | + | ||
489 | +#define DCTL HSOTG_REG(0x804) | ||
490 | +#define DCTL_SERVICE_INTERVAL_SUPPORTED BIT(19) | ||
491 | +#define DCTL_PWRONPRGDONE BIT(11) | ||
492 | +#define DCTL_CGOUTNAK BIT(10) | ||
493 | +#define DCTL_SGOUTNAK BIT(9) | ||
494 | +#define DCTL_CGNPINNAK BIT(8) | ||
495 | +#define DCTL_SGNPINNAK BIT(7) | ||
496 | +#define DCTL_TSTCTL_MASK (0x7 << 4) | ||
497 | +#define DCTL_TSTCTL_SHIFT 4 | ||
498 | +#define DCTL_GOUTNAKSTS BIT(3) | ||
499 | +#define DCTL_GNPINNAKSTS BIT(2) | ||
500 | +#define DCTL_SFTDISCON BIT(1) | ||
501 | +#define DCTL_RMTWKUPSIG BIT(0) | ||
502 | + | ||
503 | +#define DSTS HSOTG_REG(0x808) | ||
504 | +#define DSTS_SOFFN_MASK (0x3fff << 8) | ||
505 | +#define DSTS_SOFFN_SHIFT 8 | ||
506 | +#define DSTS_SOFFN_LIMIT 0x3fff | ||
507 | +#define DSTS_SOFFN(_x) ((_x) << 8) | ||
508 | +#define DSTS_ERRATICERR BIT(3) | ||
509 | +#define DSTS_ENUMSPD_MASK (0x3 << 1) | ||
510 | +#define DSTS_ENUMSPD_SHIFT 1 | ||
511 | +#define DSTS_ENUMSPD_HS 0 | ||
512 | +#define DSTS_ENUMSPD_FS 1 | ||
513 | +#define DSTS_ENUMSPD_LS 2 | ||
514 | +#define DSTS_ENUMSPD_FS48 3 | ||
515 | +#define DSTS_SUSPSTS BIT(0) | ||
516 | + | ||
517 | +#define DIEPMSK HSOTG_REG(0x810) | ||
518 | +#define DIEPMSK_NAKMSK BIT(13) | ||
519 | +#define DIEPMSK_BNAININTRMSK BIT(9) | ||
520 | +#define DIEPMSK_TXFIFOUNDRNMSK BIT(8) | ||
521 | +#define DIEPMSK_TXFIFOEMPTY BIT(7) | ||
522 | +#define DIEPMSK_INEPNAKEFFMSK BIT(6) | ||
523 | +#define DIEPMSK_INTKNEPMISMSK BIT(5) | ||
524 | +#define DIEPMSK_INTKNTXFEMPMSK BIT(4) | ||
525 | +#define DIEPMSK_TIMEOUTMSK BIT(3) | ||
526 | +#define DIEPMSK_AHBERRMSK BIT(2) | ||
527 | +#define DIEPMSK_EPDISBLDMSK BIT(1) | ||
528 | +#define DIEPMSK_XFERCOMPLMSK BIT(0) | ||
529 | + | ||
530 | +#define DOEPMSK HSOTG_REG(0x814) | ||
531 | +#define DOEPMSK_BNAMSK BIT(9) | ||
532 | +#define DOEPMSK_BACK2BACKSETUP BIT(6) | ||
533 | +#define DOEPMSK_STSPHSERCVDMSK BIT(5) | ||
534 | +#define DOEPMSK_OUTTKNEPDISMSK BIT(4) | ||
535 | +#define DOEPMSK_SETUPMSK BIT(3) | ||
536 | +#define DOEPMSK_AHBERRMSK BIT(2) | ||
537 | +#define DOEPMSK_EPDISBLDMSK BIT(1) | ||
538 | +#define DOEPMSK_XFERCOMPLMSK BIT(0) | ||
539 | + | ||
540 | +#define DAINT HSOTG_REG(0x818) | ||
541 | +#define DAINTMSK HSOTG_REG(0x81C) | ||
542 | +#define DAINT_OUTEP_SHIFT 16 | ||
543 | +#define DAINT_OUTEP(_x) (1 << ((_x) + 16)) | ||
544 | +#define DAINT_INEP(_x) (1 << (_x)) | ||
545 | + | ||
546 | +#define DTKNQR1 HSOTG_REG(0x820) | ||
547 | +#define DTKNQR2 HSOTG_REG(0x824) | ||
548 | +#define DTKNQR3 HSOTG_REG(0x830) | ||
549 | +#define DTKNQR4 HSOTG_REG(0x834) | ||
550 | +#define DIEPEMPMSK HSOTG_REG(0x834) | ||
551 | + | ||
552 | +#define DVBUSDIS HSOTG_REG(0x828) | ||
553 | +#define DVBUSPULSE HSOTG_REG(0x82C) | ||
554 | + | ||
555 | +#define DIEPCTL0 HSOTG_REG(0x900) | ||
556 | +#define DIEPCTL(_a) HSOTG_REG(0x900 + ((_a) * 0x20)) | ||
557 | + | ||
558 | +#define DOEPCTL0 HSOTG_REG(0xB00) | ||
559 | +#define DOEPCTL(_a) HSOTG_REG(0xB00 + ((_a) * 0x20)) | ||
560 | + | ||
561 | +/* EP0 specialness: | ||
562 | + * bits[29..28] - reserved (no SetD0PID, SetD1PID) | ||
563 | + * bits[25..22] - should always be zero, this isn't a periodic endpoint | ||
564 | + * bits[10..0] - MPS setting different for EP0 | ||
565 | + */ | ||
566 | +#define D0EPCTL_MPS_MASK (0x3 << 0) | ||
567 | +#define D0EPCTL_MPS_SHIFT 0 | ||
568 | +#define D0EPCTL_MPS_64 0 | ||
569 | +#define D0EPCTL_MPS_32 1 | ||
570 | +#define D0EPCTL_MPS_16 2 | ||
571 | +#define D0EPCTL_MPS_8 3 | ||
572 | + | ||
573 | +#define DXEPCTL_EPENA BIT(31) | ||
574 | +#define DXEPCTL_EPDIS BIT(30) | ||
575 | +#define DXEPCTL_SETD1PID BIT(29) | ||
576 | +#define DXEPCTL_SETODDFR BIT(29) | ||
577 | +#define DXEPCTL_SETD0PID BIT(28) | ||
578 | +#define DXEPCTL_SETEVENFR BIT(28) | ||
579 | +#define DXEPCTL_SNAK BIT(27) | ||
580 | +#define DXEPCTL_CNAK BIT(26) | ||
581 | +#define DXEPCTL_TXFNUM_MASK (0xf << 22) | ||
582 | +#define DXEPCTL_TXFNUM_SHIFT 22 | ||
583 | +#define DXEPCTL_TXFNUM_LIMIT 0xf | ||
584 | +#define DXEPCTL_TXFNUM(_x) ((_x) << 22) | ||
585 | +#define DXEPCTL_STALL BIT(21) | ||
586 | +#define DXEPCTL_SNP BIT(20) | ||
587 | +#define DXEPCTL_EPTYPE_MASK (0x3 << 18) | ||
588 | +#define DXEPCTL_EPTYPE_CONTROL (0x0 << 18) | ||
589 | +#define DXEPCTL_EPTYPE_ISO (0x1 << 18) | ||
590 | +#define DXEPCTL_EPTYPE_BULK (0x2 << 18) | ||
591 | +#define DXEPCTL_EPTYPE_INTERRUPT (0x3 << 18) | ||
592 | + | ||
593 | +#define DXEPCTL_NAKSTS BIT(17) | ||
594 | +#define DXEPCTL_DPID BIT(16) | ||
595 | +#define DXEPCTL_EOFRNUM BIT(16) | ||
596 | +#define DXEPCTL_USBACTEP BIT(15) | ||
597 | +#define DXEPCTL_NEXTEP_MASK (0xf << 11) | ||
598 | +#define DXEPCTL_NEXTEP_SHIFT 11 | ||
599 | +#define DXEPCTL_NEXTEP_LIMIT 0xf | ||
600 | +#define DXEPCTL_NEXTEP(_x) ((_x) << 11) | ||
601 | +#define DXEPCTL_MPS_MASK (0x7ff << 0) | ||
602 | +#define DXEPCTL_MPS_SHIFT 0 | ||
603 | +#define DXEPCTL_MPS_LIMIT 0x7ff | ||
604 | +#define DXEPCTL_MPS(_x) ((_x) << 0) | ||
605 | + | ||
606 | +#define DIEPINT(_a) HSOTG_REG(0x908 + ((_a) * 0x20)) | ||
607 | +#define DOEPINT(_a) HSOTG_REG(0xB08 + ((_a) * 0x20)) | ||
608 | +#define DXEPINT_SETUP_RCVD BIT(15) | ||
609 | +#define DXEPINT_NYETINTRPT BIT(14) | ||
610 | +#define DXEPINT_NAKINTRPT BIT(13) | ||
611 | +#define DXEPINT_BBLEERRINTRPT BIT(12) | ||
612 | +#define DXEPINT_PKTDRPSTS BIT(11) | ||
613 | +#define DXEPINT_BNAINTR BIT(9) | ||
614 | +#define DXEPINT_TXFIFOUNDRN BIT(8) | ||
615 | +#define DXEPINT_OUTPKTERR BIT(8) | ||
616 | +#define DXEPINT_TXFEMP BIT(7) | ||
617 | +#define DXEPINT_INEPNAKEFF BIT(6) | ||
618 | +#define DXEPINT_BACK2BACKSETUP BIT(6) | ||
619 | +#define DXEPINT_INTKNEPMIS BIT(5) | ||
620 | +#define DXEPINT_STSPHSERCVD BIT(5) | ||
621 | +#define DXEPINT_INTKNTXFEMP BIT(4) | ||
622 | +#define DXEPINT_OUTTKNEPDIS BIT(4) | ||
623 | +#define DXEPINT_TIMEOUT BIT(3) | ||
624 | +#define DXEPINT_SETUP BIT(3) | ||
625 | +#define DXEPINT_AHBERR BIT(2) | ||
626 | +#define DXEPINT_EPDISBLD BIT(1) | ||
627 | +#define DXEPINT_XFERCOMPL BIT(0) | ||
628 | + | ||
629 | +#define DIEPTSIZ0 HSOTG_REG(0x910) | ||
630 | +#define DIEPTSIZ0_PKTCNT_MASK (0x3 << 19) | ||
631 | +#define DIEPTSIZ0_PKTCNT_SHIFT 19 | ||
632 | +#define DIEPTSIZ0_PKTCNT_LIMIT 0x3 | ||
633 | +#define DIEPTSIZ0_PKTCNT(_x) ((_x) << 19) | ||
634 | +#define DIEPTSIZ0_XFERSIZE_MASK (0x7f << 0) | ||
635 | +#define DIEPTSIZ0_XFERSIZE_SHIFT 0 | ||
636 | +#define DIEPTSIZ0_XFERSIZE_LIMIT 0x7f | ||
637 | +#define DIEPTSIZ0_XFERSIZE(_x) ((_x) << 0) | ||
638 | + | ||
639 | +#define DOEPTSIZ0 HSOTG_REG(0xB10) | ||
640 | +#define DOEPTSIZ0_SUPCNT_MASK (0x3 << 29) | ||
641 | +#define DOEPTSIZ0_SUPCNT_SHIFT 29 | ||
642 | +#define DOEPTSIZ0_SUPCNT_LIMIT 0x3 | ||
643 | +#define DOEPTSIZ0_SUPCNT(_x) ((_x) << 29) | ||
644 | +#define DOEPTSIZ0_PKTCNT BIT(19) | ||
645 | +#define DOEPTSIZ0_XFERSIZE_MASK (0x7f << 0) | ||
646 | +#define DOEPTSIZ0_XFERSIZE_SHIFT 0 | ||
647 | + | ||
648 | +#define DIEPTSIZ(_a) HSOTG_REG(0x910 + ((_a) * 0x20)) | ||
649 | +#define DOEPTSIZ(_a) HSOTG_REG(0xB10 + ((_a) * 0x20)) | ||
650 | +#define DXEPTSIZ_MC_MASK (0x3 << 29) | ||
651 | +#define DXEPTSIZ_MC_SHIFT 29 | ||
652 | +#define DXEPTSIZ_MC_LIMIT 0x3 | ||
653 | +#define DXEPTSIZ_MC(_x) ((_x) << 29) | ||
654 | +#define DXEPTSIZ_PKTCNT_MASK (0x3ff << 19) | ||
655 | +#define DXEPTSIZ_PKTCNT_SHIFT 19 | ||
656 | +#define DXEPTSIZ_PKTCNT_LIMIT 0x3ff | ||
657 | +#define DXEPTSIZ_PKTCNT_GET(_v) (((_v) >> 19) & 0x3ff) | ||
658 | +#define DXEPTSIZ_PKTCNT(_x) ((_x) << 19) | ||
659 | +#define DXEPTSIZ_XFERSIZE_MASK (0x7ffff << 0) | ||
660 | +#define DXEPTSIZ_XFERSIZE_SHIFT 0 | ||
661 | +#define DXEPTSIZ_XFERSIZE_LIMIT 0x7ffff | ||
662 | +#define DXEPTSIZ_XFERSIZE_GET(_v) (((_v) >> 0) & 0x7ffff) | ||
663 | +#define DXEPTSIZ_XFERSIZE(_x) ((_x) << 0) | ||
664 | + | ||
665 | +#define DIEPDMA(_a) HSOTG_REG(0x914 + ((_a) * 0x20)) | ||
666 | +#define DOEPDMA(_a) HSOTG_REG(0xB14 + ((_a) * 0x20)) | ||
667 | + | ||
668 | +#define DTXFSTS(_a) HSOTG_REG(0x918 + ((_a) * 0x20)) | ||
669 | + | ||
670 | +#define PCGCTL HSOTG_REG(0x0e00) | ||
671 | +#define PCGCTL_IF_DEV_MODE BIT(31) | ||
672 | +#define PCGCTL_P2HD_PRT_SPD_MASK (0x3 << 29) | ||
673 | +#define PCGCTL_P2HD_PRT_SPD_SHIFT 29 | ||
674 | +#define PCGCTL_P2HD_DEV_ENUM_SPD_MASK (0x3 << 27) | ||
675 | +#define PCGCTL_P2HD_DEV_ENUM_SPD_SHIFT 27 | ||
676 | +#define PCGCTL_MAC_DEV_ADDR_MASK (0x7f << 20) | ||
677 | +#define PCGCTL_MAC_DEV_ADDR_SHIFT 20 | ||
678 | +#define PCGCTL_MAX_TERMSEL BIT(19) | ||
679 | +#define PCGCTL_MAX_XCVRSELECT_MASK (0x3 << 17) | ||
680 | +#define PCGCTL_MAX_XCVRSELECT_SHIFT 17 | ||
681 | +#define PCGCTL_PORT_POWER BIT(16) | ||
682 | +#define PCGCTL_PRT_CLK_SEL_MASK (0x3 << 14) | ||
683 | +#define PCGCTL_PRT_CLK_SEL_SHIFT 14 | ||
684 | +#define PCGCTL_ESS_REG_RESTORED BIT(13) | ||
685 | +#define PCGCTL_EXTND_HIBER_SWITCH BIT(12) | ||
686 | +#define PCGCTL_EXTND_HIBER_PWRCLMP BIT(11) | ||
687 | +#define PCGCTL_ENBL_EXTND_HIBER BIT(10) | ||
688 | +#define PCGCTL_RESTOREMODE BIT(9) | ||
689 | +#define PCGCTL_RESETAFTSUSP BIT(8) | ||
690 | +#define PCGCTL_DEEP_SLEEP BIT(7) | ||
691 | +#define PCGCTL_PHY_IN_SLEEP BIT(6) | ||
692 | +#define PCGCTL_ENBL_SLEEP_GATING BIT(5) | ||
693 | +#define PCGCTL_RSTPDWNMODULE BIT(3) | ||
694 | +#define PCGCTL_PWRCLMP BIT(2) | ||
695 | +#define PCGCTL_GATEHCLK BIT(1) | ||
696 | +#define PCGCTL_STOPPCLK BIT(0) | ||
697 | + | ||
698 | +#define PCGCCTL1 HSOTG_REG(0xe04) | ||
699 | +#define PCGCCTL1_TIMER (0x3 << 1) | ||
700 | +#define PCGCCTL1_GATEEN BIT(0) | ||
701 | + | ||
702 | +#define EPFIFO(_a) HSOTG_REG(0x1000 + ((_a) * 0x1000)) | ||
703 | + | ||
704 | +/* Host Mode Registers */ | ||
705 | + | ||
706 | +#define HCFG HSOTG_REG(0x0400) | ||
707 | +#define HCFG_MODECHTIMEN BIT(31) | ||
708 | +#define HCFG_PERSCHEDENA BIT(26) | ||
709 | +#define HCFG_FRLISTEN_MASK (0x3 << 24) | ||
710 | +#define HCFG_FRLISTEN_SHIFT 24 | ||
711 | +#define HCFG_FRLISTEN_8 (0 << 24) | ||
712 | +#define FRLISTEN_8_SIZE 8 | ||
713 | +#define HCFG_FRLISTEN_16 BIT(24) | ||
714 | +#define FRLISTEN_16_SIZE 16 | ||
715 | +#define HCFG_FRLISTEN_32 (2 << 24) | ||
716 | +#define FRLISTEN_32_SIZE 32 | ||
717 | +#define HCFG_FRLISTEN_64 (3 << 24) | ||
718 | +#define FRLISTEN_64_SIZE 64 | ||
719 | +#define HCFG_DESCDMA BIT(23) | ||
720 | +#define HCFG_RESVALID_MASK (0xff << 8) | ||
721 | +#define HCFG_RESVALID_SHIFT 8 | ||
722 | +#define HCFG_ENA32KHZ BIT(7) | ||
723 | +#define HCFG_FSLSSUPP BIT(2) | ||
724 | +#define HCFG_FSLSPCLKSEL_MASK (0x3 << 0) | ||
725 | +#define HCFG_FSLSPCLKSEL_SHIFT 0 | ||
726 | +#define HCFG_FSLSPCLKSEL_30_60_MHZ 0 | ||
727 | +#define HCFG_FSLSPCLKSEL_48_MHZ 1 | ||
728 | +#define HCFG_FSLSPCLKSEL_6_MHZ 2 | ||
729 | + | ||
730 | +#define HFIR HSOTG_REG(0x0404) | ||
731 | +#define HFIR_FRINT_MASK (0xffff << 0) | ||
732 | +#define HFIR_FRINT_SHIFT 0 | ||
733 | +#define HFIR_RLDCTRL BIT(16) | ||
734 | + | ||
735 | +#define HFNUM HSOTG_REG(0x0408) | ||
736 | +#define HFNUM_FRREM_MASK (0xffff << 16) | ||
737 | +#define HFNUM_FRREM_SHIFT 16 | ||
738 | +#define HFNUM_FRNUM_MASK (0xffff << 0) | ||
739 | +#define HFNUM_FRNUM_SHIFT 0 | ||
740 | +#define HFNUM_MAX_FRNUM 0x3fff | ||
741 | + | ||
742 | +#define HPTXSTS HSOTG_REG(0x0410) | ||
743 | +#define TXSTS_QTOP_ODD BIT(31) | ||
744 | +#define TXSTS_QTOP_CHNEP_MASK (0xf << 27) | ||
745 | +#define TXSTS_QTOP_CHNEP_SHIFT 27 | ||
746 | +#define TXSTS_QTOP_TOKEN_MASK (0x3 << 25) | ||
747 | +#define TXSTS_QTOP_TOKEN_SHIFT 25 | ||
748 | +#define TXSTS_QTOP_TERMINATE BIT(24) | ||
749 | +#define TXSTS_QSPCAVAIL_MASK (0xff << 16) | ||
750 | +#define TXSTS_QSPCAVAIL_SHIFT 16 | ||
751 | +#define TXSTS_FSPCAVAIL_MASK (0xffff << 0) | ||
752 | +#define TXSTS_FSPCAVAIL_SHIFT 0 | ||
753 | + | ||
754 | +#define HAINT HSOTG_REG(0x0414) | ||
755 | +#define HAINTMSK HSOTG_REG(0x0418) | ||
756 | +#define HFLBADDR HSOTG_REG(0x041c) | ||
757 | + | ||
758 | +#define HPRT0 HSOTG_REG(0x0440) | ||
759 | +#define HPRT0_SPD_MASK (0x3 << 17) | ||
760 | +#define HPRT0_SPD_SHIFT 17 | ||
761 | +#define HPRT0_SPD_HIGH_SPEED 0 | ||
762 | +#define HPRT0_SPD_FULL_SPEED 1 | ||
763 | +#define HPRT0_SPD_LOW_SPEED 2 | ||
764 | +#define HPRT0_TSTCTL_MASK (0xf << 13) | ||
765 | +#define HPRT0_TSTCTL_SHIFT 13 | ||
766 | +#define HPRT0_PWR BIT(12) | ||
767 | +#define HPRT0_LNSTS_MASK (0x3 << 10) | ||
768 | +#define HPRT0_LNSTS_SHIFT 10 | ||
769 | +#define HPRT0_RST BIT(8) | ||
770 | +#define HPRT0_SUSP BIT(7) | ||
771 | +#define HPRT0_RES BIT(6) | ||
772 | +#define HPRT0_OVRCURRCHG BIT(5) | ||
773 | +#define HPRT0_OVRCURRACT BIT(4) | ||
774 | +#define HPRT0_ENACHG BIT(3) | ||
775 | +#define HPRT0_ENA BIT(2) | ||
776 | +#define HPRT0_CONNDET BIT(1) | ||
777 | +#define HPRT0_CONNSTS BIT(0) | ||
778 | + | ||
779 | +#define HCCHAR(_ch) HSOTG_REG(0x0500 + 0x20 * (_ch)) | ||
780 | +#define HCCHAR_CHENA BIT(31) | ||
781 | +#define HCCHAR_CHDIS BIT(30) | ||
782 | +#define HCCHAR_ODDFRM BIT(29) | ||
783 | +#define HCCHAR_DEVADDR_MASK (0x7f << 22) | ||
784 | +#define HCCHAR_DEVADDR_SHIFT 22 | ||
785 | +#define HCCHAR_MULTICNT_MASK (0x3 << 20) | ||
786 | +#define HCCHAR_MULTICNT_SHIFT 20 | ||
787 | +#define HCCHAR_EPTYPE_MASK (0x3 << 18) | ||
788 | +#define HCCHAR_EPTYPE_SHIFT 18 | ||
789 | +#define HCCHAR_LSPDDEV BIT(17) | ||
790 | +#define HCCHAR_EPDIR BIT(15) | ||
791 | +#define HCCHAR_EPNUM_MASK (0xf << 11) | ||
792 | +#define HCCHAR_EPNUM_SHIFT 11 | ||
793 | +#define HCCHAR_MPS_MASK (0x7ff << 0) | ||
794 | +#define HCCHAR_MPS_SHIFT 0 | ||
795 | + | ||
796 | +#define HCSPLT(_ch) HSOTG_REG(0x0504 + 0x20 * (_ch)) | ||
797 | +#define HCSPLT_SPLTENA BIT(31) | ||
798 | +#define HCSPLT_COMPSPLT BIT(16) | ||
799 | +#define HCSPLT_XACTPOS_MASK (0x3 << 14) | ||
800 | +#define HCSPLT_XACTPOS_SHIFT 14 | ||
801 | +#define HCSPLT_XACTPOS_MID 0 | ||
802 | +#define HCSPLT_XACTPOS_END 1 | ||
803 | +#define HCSPLT_XACTPOS_BEGIN 2 | ||
804 | +#define HCSPLT_XACTPOS_ALL 3 | ||
805 | +#define HCSPLT_HUBADDR_MASK (0x7f << 7) | ||
806 | +#define HCSPLT_HUBADDR_SHIFT 7 | ||
807 | +#define HCSPLT_PRTADDR_MASK (0x7f << 0) | ||
808 | +#define HCSPLT_PRTADDR_SHIFT 0 | ||
809 | + | ||
810 | +#define HCINT(_ch) HSOTG_REG(0x0508 + 0x20 * (_ch)) | ||
811 | +#define HCINTMSK(_ch) HSOTG_REG(0x050c + 0x20 * (_ch)) | ||
812 | +#define HCINTMSK_RESERVED14_31 (0x3ffff << 14) | ||
813 | +#define HCINTMSK_FRM_LIST_ROLL BIT(13) | ||
814 | +#define HCINTMSK_XCS_XACT BIT(12) | ||
815 | +#define HCINTMSK_BNA BIT(11) | ||
816 | +#define HCINTMSK_DATATGLERR BIT(10) | ||
817 | +#define HCINTMSK_FRMOVRUN BIT(9) | ||
818 | +#define HCINTMSK_BBLERR BIT(8) | ||
819 | +#define HCINTMSK_XACTERR BIT(7) | ||
820 | +#define HCINTMSK_NYET BIT(6) | ||
821 | +#define HCINTMSK_ACK BIT(5) | ||
822 | +#define HCINTMSK_NAK BIT(4) | ||
823 | +#define HCINTMSK_STALL BIT(3) | ||
824 | +#define HCINTMSK_AHBERR BIT(2) | ||
825 | +#define HCINTMSK_CHHLTD BIT(1) | ||
826 | +#define HCINTMSK_XFERCOMPL BIT(0) | ||
827 | + | ||
828 | +#define HCTSIZ(_ch) HSOTG_REG(0x0510 + 0x20 * (_ch)) | ||
829 | +#define TSIZ_DOPNG BIT(31) | ||
830 | +#define TSIZ_SC_MC_PID_MASK (0x3 << 29) | ||
831 | +#define TSIZ_SC_MC_PID_SHIFT 29 | ||
832 | +#define TSIZ_SC_MC_PID_DATA0 0 | ||
833 | +#define TSIZ_SC_MC_PID_DATA2 1 | ||
834 | +#define TSIZ_SC_MC_PID_DATA1 2 | ||
835 | +#define TSIZ_SC_MC_PID_MDATA 3 | ||
836 | +#define TSIZ_SC_MC_PID_SETUP 3 | ||
837 | +#define TSIZ_PKTCNT_MASK (0x3ff << 19) | ||
838 | +#define TSIZ_PKTCNT_SHIFT 19 | ||
839 | +#define TSIZ_NTD_MASK (0xff << 8) | ||
840 | +#define TSIZ_NTD_SHIFT 8 | ||
841 | +#define TSIZ_SCHINFO_MASK (0xff << 0) | ||
842 | +#define TSIZ_SCHINFO_SHIFT 0 | ||
843 | +#define TSIZ_XFERSIZE_MASK (0x7ffff << 0) | ||
844 | +#define TSIZ_XFERSIZE_SHIFT 0 | ||
845 | + | ||
846 | +#define HCDMA(_ch) HSOTG_REG(0x0514 + 0x20 * (_ch)) | ||
847 | + | ||
848 | +#define HCDMAB(_ch) HSOTG_REG(0x051c + 0x20 * (_ch)) | ||
849 | + | ||
850 | +#define HCFIFO(_ch) HSOTG_REG(0x1000 + 0x1000 * (_ch)) | ||
851 | + | ||
852 | +/** | ||
853 | + * struct dwc2_dma_desc - DMA descriptor structure, | ||
854 | + * used for both host and gadget modes | ||
855 | + * | ||
856 | + * @status: DMA descriptor status quadlet | ||
857 | + * @buf: DMA descriptor data buffer pointer | ||
858 | + * | ||
859 | + * DMA Descriptor structure contains two quadlets: | ||
860 | + * Status quadlet and Data buffer pointer. | ||
861 | + */ | ||
862 | +struct dwc2_dma_desc { | ||
863 | + uint32_t status; | ||
864 | + uint32_t buf; | ||
865 | +} __packed; | ||
866 | + | ||
867 | +/* Host Mode DMA descriptor status quadlet */ | ||
868 | + | ||
869 | +#define HOST_DMA_A BIT(31) | ||
870 | +#define HOST_DMA_STS_MASK (0x3 << 28) | ||
871 | +#define HOST_DMA_STS_SHIFT 28 | ||
872 | +#define HOST_DMA_STS_PKTERR BIT(28) | ||
873 | +#define HOST_DMA_EOL BIT(26) | ||
874 | +#define HOST_DMA_IOC BIT(25) | ||
875 | +#define HOST_DMA_SUP BIT(24) | ||
876 | +#define HOST_DMA_ALT_QTD BIT(23) | ||
877 | +#define HOST_DMA_QTD_OFFSET_MASK (0x3f << 17) | ||
878 | +#define HOST_DMA_QTD_OFFSET_SHIFT 17 | ||
879 | +#define HOST_DMA_ISOC_NBYTES_MASK (0xfff << 0) | ||
880 | +#define HOST_DMA_ISOC_NBYTES_SHIFT 0 | ||
881 | +#define HOST_DMA_NBYTES_MASK (0x1ffff << 0) | ||
882 | +#define HOST_DMA_NBYTES_SHIFT 0 | ||
883 | +#define HOST_DMA_NBYTES_LIMIT 131071 | ||
884 | + | ||
885 | +/* Device Mode DMA descriptor status quadlet */ | ||
886 | + | ||
887 | +#define DEV_DMA_BUFF_STS_MASK (0x3 << 30) | ||
888 | +#define DEV_DMA_BUFF_STS_SHIFT 30 | ||
889 | +#define DEV_DMA_BUFF_STS_HREADY 0 | ||
890 | +#define DEV_DMA_BUFF_STS_DMABUSY 1 | ||
891 | +#define DEV_DMA_BUFF_STS_DMADONE 2 | ||
892 | +#define DEV_DMA_BUFF_STS_HBUSY 3 | ||
893 | +#define DEV_DMA_STS_MASK (0x3 << 28) | ||
894 | +#define DEV_DMA_STS_SHIFT 28 | ||
895 | +#define DEV_DMA_STS_SUCC 0 | ||
896 | +#define DEV_DMA_STS_BUFF_FLUSH 1 | ||
897 | +#define DEV_DMA_STS_BUFF_ERR 3 | ||
898 | +#define DEV_DMA_L BIT(27) | ||
899 | +#define DEV_DMA_SHORT BIT(26) | ||
900 | +#define DEV_DMA_IOC BIT(25) | ||
901 | +#define DEV_DMA_SR BIT(24) | ||
902 | +#define DEV_DMA_MTRF BIT(23) | ||
903 | +#define DEV_DMA_ISOC_PID_MASK (0x3 << 23) | ||
904 | +#define DEV_DMA_ISOC_PID_SHIFT 23 | ||
905 | +#define DEV_DMA_ISOC_PID_DATA0 0 | ||
906 | +#define DEV_DMA_ISOC_PID_DATA2 1 | ||
907 | +#define DEV_DMA_ISOC_PID_DATA1 2 | ||
908 | +#define DEV_DMA_ISOC_PID_MDATA 3 | ||
909 | +#define DEV_DMA_ISOC_FRNUM_MASK (0x7ff << 12) | ||
910 | +#define DEV_DMA_ISOC_FRNUM_SHIFT 12 | ||
911 | +#define DEV_DMA_ISOC_TX_NBYTES_MASK (0xfff << 0) | ||
912 | +#define DEV_DMA_ISOC_TX_NBYTES_LIMIT 0xfff | ||
913 | +#define DEV_DMA_ISOC_RX_NBYTES_MASK (0x7ff << 0) | ||
914 | +#define DEV_DMA_ISOC_RX_NBYTES_LIMIT 0x7ff | ||
915 | +#define DEV_DMA_ISOC_NBYTES_SHIFT 0 | ||
916 | +#define DEV_DMA_NBYTES_MASK (0xffff << 0) | ||
917 | +#define DEV_DMA_NBYTES_SHIFT 0 | ||
918 | +#define DEV_DMA_NBYTES_LIMIT 0xffff | ||
919 | + | ||
920 | +#define MAX_DMA_DESC_NUM_GENERIC 64 | ||
921 | +#define MAX_DMA_DESC_NUM_HS_ISOC 256 | ||
922 | + | ||
923 | +#endif /* __DWC2_HW_H__ */ | ||
924 | -- | 75 | -- |
925 | 2.20.1 | 76 | 2.34.1 |
926 | |||
927 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Rather than passing an opcode to a helper, fully decode the | 3 | Move the fractional comparison to the end of the |
4 | operation at translate time. Use clear_tail_16 to zap the | 4 | float_2nan_prop_x87 case. This is not required for |
5 | balance of the SVE register with the AdvSIMD write. | 5 | any other 2nan propagation rule. Reorganize the |
6 | x87 case itself to break out of the switch when the | ||
7 | fractional comparison is not required. | ||
6 | 8 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20200514212831.31248-7-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Message-id: 20241203203949.483774-11-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 13 | --- |
12 | target/arm/helper.h | 5 ++++- | 14 | fpu/softfloat-parts.c.inc | 19 +++++++++---------- |
13 | target/arm/crypto_helper.c | 24 ++++++++++++++++++------ | 15 | 1 file changed, 9 insertions(+), 10 deletions(-) |
14 | target/arm/translate-a64.c | 21 +++++---------------- | ||
15 | 3 files changed, 27 insertions(+), 23 deletions(-) | ||
16 | 16 | ||
17 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 17 | diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc |
18 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper.h | 19 | --- a/fpu/softfloat-parts.c.inc |
20 | +++ b/target/arm/helper.h | 20 | +++ b/fpu/softfloat-parts.c.inc |
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(crypto_sha512su0, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | 21 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b, |
22 | DEF_HELPER_FLAGS_4(crypto_sha512su1, TCG_CALL_NO_RWG, | 22 | return a; |
23 | void, ptr, ptr, ptr, i32) | ||
24 | |||
25 | -DEF_HELPER_FLAGS_5(crypto_sm3tt, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32, i32) | ||
26 | +DEF_HELPER_FLAGS_4(crypto_sm3tt1a, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_4(crypto_sm3tt1b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_4(crypto_sm3tt2a, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
29 | +DEF_HELPER_FLAGS_4(crypto_sm3tt2b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
30 | DEF_HELPER_FLAGS_4(crypto_sm3partw1, TCG_CALL_NO_RWG, | ||
31 | void, ptr, ptr, ptr, i32) | ||
32 | DEF_HELPER_FLAGS_4(crypto_sm3partw2, TCG_CALL_NO_RWG, | ||
33 | diff --git a/target/arm/crypto_helper.c b/target/arm/crypto_helper.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/crypto_helper.c | ||
36 | +++ b/target/arm/crypto_helper.c | ||
37 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm3partw2)(void *vd, void *vn, void *vm, uint32_t desc) | ||
38 | clear_tail_16(vd, desc); | ||
39 | } | ||
40 | |||
41 | -void HELPER(crypto_sm3tt)(void *vd, void *vn, void *vm, uint32_t imm2, | ||
42 | - uint32_t opcode) | ||
43 | +static inline void QEMU_ALWAYS_INLINE | ||
44 | +crypto_sm3tt(uint64_t *rd, uint64_t *rn, uint64_t *rm, | ||
45 | + uint32_t desc, uint32_t opcode) | ||
46 | { | ||
47 | - uint64_t *rd = vd; | ||
48 | - uint64_t *rn = vn; | ||
49 | - uint64_t *rm = vm; | ||
50 | union CRYPTO_STATE d = { .l = { rd[0], rd[1] } }; | ||
51 | union CRYPTO_STATE n = { .l = { rn[0], rn[1] } }; | ||
52 | union CRYPTO_STATE m = { .l = { rm[0], rm[1] } }; | ||
53 | + uint32_t imm2 = simd_data(desc); | ||
54 | uint32_t t; | ||
55 | |||
56 | assert(imm2 < 4); | ||
57 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm3tt)(void *vd, void *vn, void *vm, uint32_t imm2, | ||
58 | /* SM3TT2B */ | ||
59 | t = cho(CR_ST_WORD(d, 3), CR_ST_WORD(d, 2), CR_ST_WORD(d, 1)); | ||
60 | } else { | ||
61 | - g_assert_not_reached(); | ||
62 | + qemu_build_not_reached(); | ||
63 | } | 23 | } |
64 | 24 | ||
65 | t += CR_ST_WORD(d, 0) + CR_ST_WORD(m, imm2); | 25 | - cmp = frac_cmp(a, b); |
66 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm3tt)(void *vd, void *vn, void *vm, uint32_t imm2, | 26 | - if (cmp == 0) { |
67 | 27 | - cmp = a->sign < b->sign; | |
68 | rd[0] = d.l[0]; | 28 | - } |
69 | rd[1] = d.l[1]; | ||
70 | + | ||
71 | + clear_tail_16(rd, desc); | ||
72 | } | ||
73 | |||
74 | +#define DO_SM3TT(NAME, OPCODE) \ | ||
75 | + void HELPER(NAME)(void *vd, void *vn, void *vm, uint32_t desc) \ | ||
76 | + { crypto_sm3tt(vd, vn, vm, desc, OPCODE); } | ||
77 | + | ||
78 | +DO_SM3TT(crypto_sm3tt1a, 0) | ||
79 | +DO_SM3TT(crypto_sm3tt1b, 1) | ||
80 | +DO_SM3TT(crypto_sm3tt2a, 2) | ||
81 | +DO_SM3TT(crypto_sm3tt2b, 3) | ||
82 | + | ||
83 | +#undef DO_SM3TT | ||
84 | + | ||
85 | static uint8_t const sm4_sbox[] = { | ||
86 | 0xd6, 0x90, 0xe9, 0xfe, 0xcc, 0xe1, 0x3d, 0xb7, | ||
87 | 0x16, 0xb6, 0x14, 0xc2, 0x28, 0xfb, 0x2c, 0x05, | ||
88 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
89 | index XXXXXXX..XXXXXXX 100644 | ||
90 | --- a/target/arm/translate-a64.c | ||
91 | +++ b/target/arm/translate-a64.c | ||
92 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_xar(DisasContext *s, uint32_t insn) | ||
93 | */ | ||
94 | static void disas_crypto_three_reg_imm2(DisasContext *s, uint32_t insn) | ||
95 | { | ||
96 | + static gen_helper_gvec_3 * const fns[4] = { | ||
97 | + gen_helper_crypto_sm3tt1a, gen_helper_crypto_sm3tt1b, | ||
98 | + gen_helper_crypto_sm3tt2a, gen_helper_crypto_sm3tt2b, | ||
99 | + }; | ||
100 | int opcode = extract32(insn, 10, 2); | ||
101 | int imm2 = extract32(insn, 12, 2); | ||
102 | int rm = extract32(insn, 16, 5); | ||
103 | int rn = extract32(insn, 5, 5); | ||
104 | int rd = extract32(insn, 0, 5); | ||
105 | - TCGv_ptr tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr; | ||
106 | - TCGv_i32 tcg_imm2, tcg_opcode; | ||
107 | |||
108 | if (!dc_isar_feature(aa64_sm3, s)) { | ||
109 | unallocated_encoding(s); | ||
110 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_imm2(DisasContext *s, uint32_t insn) | ||
111 | return; | ||
112 | } | ||
113 | |||
114 | - tcg_rd_ptr = vec_full_reg_ptr(s, rd); | ||
115 | - tcg_rn_ptr = vec_full_reg_ptr(s, rn); | ||
116 | - tcg_rm_ptr = vec_full_reg_ptr(s, rm); | ||
117 | - tcg_imm2 = tcg_const_i32(imm2); | ||
118 | - tcg_opcode = tcg_const_i32(opcode); | ||
119 | - | 29 | - |
120 | - gen_helper_crypto_sm3tt(tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr, tcg_imm2, | 30 | switch (s->float_2nan_prop_rule) { |
121 | - tcg_opcode); | 31 | case float_2nan_prop_s_ab: |
122 | - | 32 | if (have_snan) { |
123 | - tcg_temp_free_ptr(tcg_rd_ptr); | 33 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b, |
124 | - tcg_temp_free_ptr(tcg_rn_ptr); | 34 | * return the NaN with the positive sign bit (if any). |
125 | - tcg_temp_free_ptr(tcg_rm_ptr); | 35 | */ |
126 | - tcg_temp_free_i32(tcg_imm2); | 36 | if (is_snan(a->cls)) { |
127 | - tcg_temp_free_i32(tcg_opcode); | 37 | - if (is_snan(b->cls)) { |
128 | + gen_gvec_op3_ool(s, true, rd, rn, rm, imm2, fns[opcode]); | 38 | - which = cmp > 0 ? 0 : 1; |
129 | } | 39 | - } else { |
130 | 40 | + if (!is_snan(b->cls)) { | |
131 | /* C3.6 Data processing - SIMD, inc Crypto | 41 | which = is_qnan(b->cls) ? 1 : 0; |
42 | + break; | ||
43 | } | ||
44 | } else if (is_qnan(a->cls)) { | ||
45 | if (is_snan(b->cls) || !is_qnan(b->cls)) { | ||
46 | which = 0; | ||
47 | - } else { | ||
48 | - which = cmp > 0 ? 0 : 1; | ||
49 | + break; | ||
50 | } | ||
51 | } else { | ||
52 | which = 1; | ||
53 | + break; | ||
54 | } | ||
55 | + cmp = frac_cmp(a, b); | ||
56 | + if (cmp == 0) { | ||
57 | + cmp = a->sign < b->sign; | ||
58 | + } | ||
59 | + which = cmp > 0 ? 0 : 1; | ||
60 | break; | ||
61 | default: | ||
62 | g_assert_not_reached(); | ||
132 | -- | 63 | -- |
133 | 2.20.1 | 64 | 2.34.1 |
134 | |||
135 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Do not yet convert the helpers to loop over opr_sz, but the | 3 | Replace the "index" selecting between A and B with a result variable |
4 | descriptor allows the vector tail to be cleared. Which fixes | 4 | of the proper type. This improves clarity within the function. |
5 | an existing bug vs SVE. | ||
6 | 5 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20200514212831.31248-4-richard.henderson@linaro.org | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Message-id: 20241203203949.483774-12-richard.henderson@linaro.org |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 10 | --- |
12 | target/arm/helper.h | 15 +++++++----- | 11 | fpu/softfloat-parts.c.inc | 28 +++++++++++++--------------- |
13 | target/arm/crypto_helper.c | 37 +++++++++++++++++++++++----- | 12 | 1 file changed, 13 insertions(+), 15 deletions(-) |
14 | target/arm/translate-a64.c | 50 ++++++++++++-------------------------- | ||
15 | 3 files changed, 55 insertions(+), 47 deletions(-) | ||
16 | 13 | ||
17 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 14 | diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc |
18 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper.h | 16 | --- a/fpu/softfloat-parts.c.inc |
20 | +++ b/target/arm/helper.h | 17 | +++ b/fpu/softfloat-parts.c.inc |
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(crypto_sha256h2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 18 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b, |
22 | DEF_HELPER_FLAGS_2(crypto_sha256su0, TCG_CALL_NO_RWG, void, ptr, ptr) | 19 | float_status *s) |
23 | DEF_HELPER_FLAGS_3(crypto_sha256su1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | ||
24 | |||
25 | -DEF_HELPER_FLAGS_3(crypto_sha512h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | ||
26 | -DEF_HELPER_FLAGS_3(crypto_sha512h2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | ||
27 | -DEF_HELPER_FLAGS_2(crypto_sha512su0, TCG_CALL_NO_RWG, void, ptr, ptr) | ||
28 | -DEF_HELPER_FLAGS_3(crypto_sha512su1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | ||
29 | +DEF_HELPER_FLAGS_4(crypto_sha512h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
30 | +DEF_HELPER_FLAGS_4(crypto_sha512h2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_3(crypto_sha512su0, TCG_CALL_NO_RWG, void, ptr, ptr, i32) | ||
32 | +DEF_HELPER_FLAGS_4(crypto_sha512su1, TCG_CALL_NO_RWG, | ||
33 | + void, ptr, ptr, ptr, i32) | ||
34 | |||
35 | DEF_HELPER_FLAGS_5(crypto_sm3tt, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32, i32) | ||
36 | -DEF_HELPER_FLAGS_3(crypto_sm3partw1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | ||
37 | -DEF_HELPER_FLAGS_3(crypto_sm3partw2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | ||
38 | +DEF_HELPER_FLAGS_4(crypto_sm3partw1, TCG_CALL_NO_RWG, | ||
39 | + void, ptr, ptr, ptr, i32) | ||
40 | +DEF_HELPER_FLAGS_4(crypto_sm3partw2, TCG_CALL_NO_RWG, | ||
41 | + void, ptr, ptr, ptr, i32) | ||
42 | |||
43 | DEF_HELPER_FLAGS_4(crypto_sm4e, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
44 | DEF_HELPER_FLAGS_4(crypto_sm4ekey, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32) | ||
45 | diff --git a/target/arm/crypto_helper.c b/target/arm/crypto_helper.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/arm/crypto_helper.c | ||
48 | +++ b/target/arm/crypto_helper.c | ||
49 | @@ -XXX,XX +XXX,XX @@ union CRYPTO_STATE { | ||
50 | #define CR_ST_WORD(state, i) (state.words[i]) | ||
51 | #endif | ||
52 | |||
53 | +/* | ||
54 | + * The caller has not been converted to full gvec, and so only | ||
55 | + * modifies the low 16 bytes of the vector register. | ||
56 | + */ | ||
57 | +static void clear_tail_16(void *vd, uint32_t desc) | ||
58 | +{ | ||
59 | + int opr_sz = simd_oprsz(desc); | ||
60 | + int max_sz = simd_maxsz(desc); | ||
61 | + | ||
62 | + assert(opr_sz == 16); | ||
63 | + clear_tail(vd, opr_sz, max_sz); | ||
64 | +} | ||
65 | + | ||
66 | static void do_crypto_aese(uint64_t *rd, uint64_t *rn, | ||
67 | uint64_t *rm, bool decrypt) | ||
68 | { | 20 | { |
69 | @@ -XXX,XX +XXX,XX @@ static uint64_t s1_512(uint64_t x) | 21 | bool have_snan = false; |
70 | return ror64(x, 19) ^ ror64(x, 61) ^ (x >> 6); | 22 | - int cmp, which; |
71 | } | 23 | + FloatPartsN *ret; |
72 | 24 | + int cmp; | |
73 | -void HELPER(crypto_sha512h)(void *vd, void *vn, void *vm) | 25 | |
74 | +void HELPER(crypto_sha512h)(void *vd, void *vn, void *vm, uint32_t desc) | 26 | if (is_snan(a->cls) || is_snan(b->cls)) { |
75 | { | 27 | float_raise(float_flag_invalid | float_flag_invalid_snan, s); |
76 | uint64_t *rd = vd; | 28 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b, |
77 | uint64_t *rn = vn; | 29 | switch (s->float_2nan_prop_rule) { |
78 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha512h)(void *vd, void *vn, void *vm) | 30 | case float_2nan_prop_s_ab: |
79 | 31 | if (have_snan) { | |
80 | rd[0] = d0; | 32 | - which = is_snan(a->cls) ? 0 : 1; |
81 | rd[1] = d1; | 33 | + ret = is_snan(a->cls) ? a : b; |
82 | + | ||
83 | + clear_tail_16(vd, desc); | ||
84 | } | ||
85 | |||
86 | -void HELPER(crypto_sha512h2)(void *vd, void *vn, void *vm) | ||
87 | +void HELPER(crypto_sha512h2)(void *vd, void *vn, void *vm, uint32_t desc) | ||
88 | { | ||
89 | uint64_t *rd = vd; | ||
90 | uint64_t *rn = vn; | ||
91 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha512h2)(void *vd, void *vn, void *vm) | ||
92 | |||
93 | rd[0] = d0; | ||
94 | rd[1] = d1; | ||
95 | + | ||
96 | + clear_tail_16(vd, desc); | ||
97 | } | ||
98 | |||
99 | -void HELPER(crypto_sha512su0)(void *vd, void *vn) | ||
100 | +void HELPER(crypto_sha512su0)(void *vd, void *vn, uint32_t desc) | ||
101 | { | ||
102 | uint64_t *rd = vd; | ||
103 | uint64_t *rn = vn; | ||
104 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha512su0)(void *vd, void *vn) | ||
105 | |||
106 | rd[0] = d0; | ||
107 | rd[1] = d1; | ||
108 | + | ||
109 | + clear_tail_16(vd, desc); | ||
110 | } | ||
111 | |||
112 | -void HELPER(crypto_sha512su1)(void *vd, void *vn, void *vm) | ||
113 | +void HELPER(crypto_sha512su1)(void *vd, void *vn, void *vm, uint32_t desc) | ||
114 | { | ||
115 | uint64_t *rd = vd; | ||
116 | uint64_t *rn = vn; | ||
117 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sha512su1)(void *vd, void *vn, void *vm) | ||
118 | |||
119 | rd[0] += s1_512(rn[0]) + rm[0]; | ||
120 | rd[1] += s1_512(rn[1]) + rm[1]; | ||
121 | + | ||
122 | + clear_tail_16(vd, desc); | ||
123 | } | ||
124 | |||
125 | -void HELPER(crypto_sm3partw1)(void *vd, void *vn, void *vm) | ||
126 | +void HELPER(crypto_sm3partw1)(void *vd, void *vn, void *vm, uint32_t desc) | ||
127 | { | ||
128 | uint64_t *rd = vd; | ||
129 | uint64_t *rn = vn; | ||
130 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm3partw1)(void *vd, void *vn, void *vm) | ||
131 | |||
132 | rd[0] = d.l[0]; | ||
133 | rd[1] = d.l[1]; | ||
134 | + | ||
135 | + clear_tail_16(vd, desc); | ||
136 | } | ||
137 | |||
138 | -void HELPER(crypto_sm3partw2)(void *vd, void *vn, void *vm) | ||
139 | +void HELPER(crypto_sm3partw2)(void *vd, void *vn, void *vm, uint32_t desc) | ||
140 | { | ||
141 | uint64_t *rd = vd; | ||
142 | uint64_t *rn = vn; | ||
143 | @@ -XXX,XX +XXX,XX @@ void HELPER(crypto_sm3partw2)(void *vd, void *vn, void *vm) | ||
144 | |||
145 | rd[0] = d.l[0]; | ||
146 | rd[1] = d.l[1]; | ||
147 | + | ||
148 | + clear_tail_16(vd, desc); | ||
149 | } | ||
150 | |||
151 | void HELPER(crypto_sm3tt)(void *vd, void *vn, void *vm, uint32_t imm2, | ||
152 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
153 | index XXXXXXX..XXXXXXX 100644 | ||
154 | --- a/target/arm/translate-a64.c | ||
155 | +++ b/target/arm/translate-a64.c | ||
156 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
157 | int rn = extract32(insn, 5, 5); | ||
158 | int rd = extract32(insn, 0, 5); | ||
159 | bool feature; | ||
160 | - CryptoThreeOpFn *genfn = NULL; | ||
161 | gen_helper_gvec_3 *oolfn = NULL; | ||
162 | GVecGen3Fn *gvecfn = NULL; | ||
163 | |||
164 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
165 | switch (opcode) { | ||
166 | case 0: /* SHA512H */ | ||
167 | feature = dc_isar_feature(aa64_sha512, s); | ||
168 | - genfn = gen_helper_crypto_sha512h; | ||
169 | + oolfn = gen_helper_crypto_sha512h; | ||
170 | break; | 34 | break; |
171 | case 1: /* SHA512H2 */ | 35 | } |
172 | feature = dc_isar_feature(aa64_sha512, s); | 36 | /* fall through */ |
173 | - genfn = gen_helper_crypto_sha512h2; | 37 | case float_2nan_prop_ab: |
174 | + oolfn = gen_helper_crypto_sha512h2; | 38 | - which = is_nan(a->cls) ? 0 : 1; |
39 | + ret = is_nan(a->cls) ? a : b; | ||
40 | break; | ||
41 | case float_2nan_prop_s_ba: | ||
42 | if (have_snan) { | ||
43 | - which = is_snan(b->cls) ? 1 : 0; | ||
44 | + ret = is_snan(b->cls) ? b : a; | ||
175 | break; | 45 | break; |
176 | case 2: /* SHA512SU1 */ | 46 | } |
177 | feature = dc_isar_feature(aa64_sha512, s); | 47 | /* fall through */ |
178 | - genfn = gen_helper_crypto_sha512su1; | 48 | case float_2nan_prop_ba: |
179 | + oolfn = gen_helper_crypto_sha512su1; | 49 | - which = is_nan(b->cls) ? 1 : 0; |
50 | + ret = is_nan(b->cls) ? b : a; | ||
51 | break; | ||
52 | case float_2nan_prop_x87: | ||
53 | /* | ||
54 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b, | ||
55 | */ | ||
56 | if (is_snan(a->cls)) { | ||
57 | if (!is_snan(b->cls)) { | ||
58 | - which = is_qnan(b->cls) ? 1 : 0; | ||
59 | + ret = is_qnan(b->cls) ? b : a; | ||
60 | break; | ||
61 | } | ||
62 | } else if (is_qnan(a->cls)) { | ||
63 | if (is_snan(b->cls) || !is_qnan(b->cls)) { | ||
64 | - which = 0; | ||
65 | + ret = a; | ||
66 | break; | ||
67 | } | ||
68 | } else { | ||
69 | - which = 1; | ||
70 | + ret = b; | ||
180 | break; | 71 | break; |
181 | case 3: /* RAX1 */ | 72 | } |
182 | feature = dc_isar_feature(aa64_sha3, s); | 73 | cmp = frac_cmp(a, b); |
183 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | 74 | if (cmp == 0) { |
184 | switch (opcode) { | 75 | cmp = a->sign < b->sign; |
185 | case 0: /* SM3PARTW1 */ | 76 | } |
186 | feature = dc_isar_feature(aa64_sm3, s); | 77 | - which = cmp > 0 ? 0 : 1; |
187 | - genfn = gen_helper_crypto_sm3partw1; | 78 | + ret = cmp > 0 ? a : b; |
188 | + oolfn = gen_helper_crypto_sm3partw1; | ||
189 | break; | ||
190 | case 1: /* SM3PARTW2 */ | ||
191 | feature = dc_isar_feature(aa64_sm3, s); | ||
192 | - genfn = gen_helper_crypto_sm3partw2; | ||
193 | + oolfn = gen_helper_crypto_sm3partw2; | ||
194 | break; | ||
195 | case 2: /* SM4EKEY */ | ||
196 | feature = dc_isar_feature(aa64_sm4, s); | ||
197 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) | ||
198 | |||
199 | if (oolfn) { | ||
200 | gen_gvec_op3_ool(s, true, rd, rn, rm, 0, oolfn); | ||
201 | - } else if (gvecfn) { | ||
202 | - gen_gvec_fn3(s, true, rd, rn, rm, gvecfn, MO_64); | ||
203 | } else { | ||
204 | - TCGv_ptr tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr; | ||
205 | - | ||
206 | - tcg_rd_ptr = vec_full_reg_ptr(s, rd); | ||
207 | - tcg_rn_ptr = vec_full_reg_ptr(s, rn); | ||
208 | - tcg_rm_ptr = vec_full_reg_ptr(s, rm); | ||
209 | - | ||
210 | - genfn(tcg_rd_ptr, tcg_rn_ptr, tcg_rm_ptr); | ||
211 | - | ||
212 | - tcg_temp_free_ptr(tcg_rd_ptr); | ||
213 | - tcg_temp_free_ptr(tcg_rn_ptr); | ||
214 | - tcg_temp_free_ptr(tcg_rm_ptr); | ||
215 | + gen_gvec_fn3(s, true, rd, rn, rm, gvecfn, MO_64); | ||
216 | } | ||
217 | } | ||
218 | |||
219 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha512(DisasContext *s, uint32_t insn) | ||
220 | int opcode = extract32(insn, 10, 2); | ||
221 | int rn = extract32(insn, 5, 5); | ||
222 | int rd = extract32(insn, 0, 5); | ||
223 | - TCGv_ptr tcg_rd_ptr, tcg_rn_ptr; | ||
224 | bool feature; | ||
225 | - CryptoTwoOpFn *genfn; | ||
226 | - gen_helper_gvec_3 *oolfn = NULL; | ||
227 | |||
228 | switch (opcode) { | ||
229 | case 0: /* SHA512SU0 */ | ||
230 | feature = dc_isar_feature(aa64_sha512, s); | ||
231 | - genfn = gen_helper_crypto_sha512su0; | ||
232 | break; | ||
233 | case 1: /* SM4E */ | ||
234 | feature = dc_isar_feature(aa64_sm4, s); | ||
235 | - oolfn = gen_helper_crypto_sm4e; | ||
236 | break; | 79 | break; |
237 | default: | 80 | default: |
238 | unallocated_encoding(s); | 81 | g_assert_not_reached(); |
239 | @@ -XXX,XX +XXX,XX @@ static void disas_crypto_two_reg_sha512(DisasContext *s, uint32_t insn) | ||
240 | return; | ||
241 | } | 82 | } |
242 | 83 | ||
243 | - if (oolfn) { | 84 | - if (which) { |
244 | - gen_gvec_op3_ool(s, true, rd, rd, rn, 0, oolfn); | 85 | - a = b; |
245 | - return; | 86 | + if (is_snan(ret->cls)) { |
246 | + switch (opcode) { | 87 | + parts_silence_nan(ret, s); |
247 | + case 0: /* SHA512SU0 */ | ||
248 | + gen_gvec_op2_ool(s, true, rd, rn, 0, gen_helper_crypto_sha512su0); | ||
249 | + break; | ||
250 | + case 1: /* SM4E */ | ||
251 | + gen_gvec_op3_ool(s, true, rd, rd, rn, 0, gen_helper_crypto_sm4e); | ||
252 | + break; | ||
253 | + default: | ||
254 | + g_assert_not_reached(); | ||
255 | } | 88 | } |
256 | - | 89 | - if (is_snan(a->cls)) { |
257 | - tcg_rd_ptr = vec_full_reg_ptr(s, rd); | 90 | - parts_silence_nan(a, s); |
258 | - tcg_rn_ptr = vec_full_reg_ptr(s, rn); | 91 | - } |
259 | - | 92 | - return a; |
260 | - genfn(tcg_rd_ptr, tcg_rn_ptr); | 93 | + return ret; |
261 | - | ||
262 | - tcg_temp_free_ptr(tcg_rd_ptr); | ||
263 | - tcg_temp_free_ptr(tcg_rn_ptr); | ||
264 | } | 94 | } |
265 | 95 | ||
266 | /* Crypto four-register | 96 | static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, |
267 | -- | 97 | -- |
268 | 2.20.1 | 98 | 2.34.1 |
269 | 99 | ||
270 | 100 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | From: Leif Lindholm <quic_llindhol@quicinc.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 3 | I'm migrating to Qualcomm's new open source email infrastructure, so |
4 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 4 | update my email address, and update the mailmap to match. |
5 | Message-id: 20200602135050.593692-1-clg@kaod.org | 5 | |
6 | Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com> | ||
7 | Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com> | ||
8 | Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com> | ||
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
10 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
11 | Message-id: 20241205114047.1125842-1-leif.lindholm@oss.qualcomm.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 13 | --- |
8 | docs/system/arm/aspeed.rst | 85 ++++++++++++++++++++++++++++++++++++++ | 14 | MAINTAINERS | 2 +- |
9 | docs/system/target-arm.rst | 1 + | 15 | .mailmap | 5 +++-- |
10 | 2 files changed, 86 insertions(+) | 16 | 2 files changed, 4 insertions(+), 3 deletions(-) |
11 | create mode 100644 docs/system/arm/aspeed.rst | ||
12 | 17 | ||
13 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst | 18 | diff --git a/MAINTAINERS b/MAINTAINERS |
14 | new file mode 100644 | ||
15 | index XXXXXXX..XXXXXXX | ||
16 | --- /dev/null | ||
17 | +++ b/docs/system/arm/aspeed.rst | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | +Aspeed family boards (``*-bmc``, ``ast2500-evb``, ``ast2600-evb``) | ||
20 | +================================================================== | ||
21 | + | ||
22 | +The QEMU Aspeed machines model BMCs of various OpenPOWER systems and | ||
23 | +Aspeed evaluation boards. They are based on different releases of the | ||
24 | +Aspeed SoC : the AST2400 integrating an ARM926EJ-S CPU (400MHz), the | ||
25 | +AST2500 with an ARM1176JZS CPU (800MHz) and more recently the AST2600 | ||
26 | +with dual cores ARM Cortex A7 CPUs (1.2GHz). | ||
27 | + | ||
28 | +The SoC comes with RAM, Gigabit ethernet, USB, SD/MMC, USB, SPI, I2C, | ||
29 | +etc. | ||
30 | + | ||
31 | +AST2400 SoC based machines : | ||
32 | + | ||
33 | +- ``palmetto-bmc`` OpenPOWER Palmetto POWER8 BMC | ||
34 | + | ||
35 | +AST2500 SoC based machines : | ||
36 | + | ||
37 | +- ``ast2500-evb`` Aspeed AST2500 Evaluation board | ||
38 | +- ``romulus-bmc`` OpenPOWER Romulus POWER9 BMC | ||
39 | +- ``witherspoon-bmc`` OpenPOWER Witherspoon POWER9 BMC | ||
40 | +- ``sonorapass-bmc`` OCP SonoraPass BMC | ||
41 | +- ``swift-bmc`` OpenPOWER Swift BMC POWER9 | ||
42 | + | ||
43 | +AST2600 SoC based machines : | ||
44 | + | ||
45 | +- ``ast2600-evb`` Aspeed AST2600 Evaluation board (Cortex A7) | ||
46 | +- ``tacoma-bmc`` OpenPOWER Witherspoon POWER9 AST2600 BMC | ||
47 | + | ||
48 | +Supported devices | ||
49 | +----------------- | ||
50 | + | ||
51 | + * SMP (for the AST2600 Cortex-A7) | ||
52 | + * Interrupt Controller (VIC) | ||
53 | + * Timer Controller | ||
54 | + * RTC Controller | ||
55 | + * I2C Controller | ||
56 | + * System Control Unit (SCU) | ||
57 | + * SRAM mapping | ||
58 | + * X-DMA Controller (basic interface) | ||
59 | + * Static Memory Controller (SMC or FMC) - Only SPI Flash support | ||
60 | + * SPI Memory Controller | ||
61 | + * USB 2.0 Controller | ||
62 | + * SD/MMC storage controllers | ||
63 | + * SDRAM controller (dummy interface for basic settings and training) | ||
64 | + * Watchdog Controller | ||
65 | + * GPIO Controller (Master only) | ||
66 | + * UART | ||
67 | + * Ethernet controllers | ||
68 | + | ||
69 | + | ||
70 | +Missing devices | ||
71 | +--------------- | ||
72 | + | ||
73 | + * Coprocessor support | ||
74 | + * ADC (out of tree implementation) | ||
75 | + * PWM and Fan Controller | ||
76 | + * LPC Bus Controller | ||
77 | + * Slave GPIO Controller | ||
78 | + * Super I/O Controller | ||
79 | + * Hash/Crypto Engine | ||
80 | + * PCI-Express 1 Controller | ||
81 | + * Graphic Display Controller | ||
82 | + * PECI Controller | ||
83 | + * MCTP Controller | ||
84 | + * Mailbox Controller | ||
85 | + * Virtual UART | ||
86 | + * eSPI Controller | ||
87 | + * I3C Controller | ||
88 | + | ||
89 | +Boot options | ||
90 | +------------ | ||
91 | + | ||
92 | +The Aspeed machines can be started using the -kernel option to load a | ||
93 | +Linux kernel or from a firmare image which can be downloaded from the | ||
94 | +OpenPOWER jenkins : | ||
95 | + | ||
96 | + https://openpower.xyz/ | ||
97 | + | ||
98 | +The image should be attached as an MTD drive. Run : | ||
99 | + | ||
100 | +.. code-block:: bash | ||
101 | + | ||
102 | + $ qemu-system-arm -M romulus-bmc -nic user \ | ||
103 | + -drive file=flash-romulus,format=raw,if=mtd -nographic | ||
104 | diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst | ||
105 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
106 | --- a/docs/system/target-arm.rst | 20 | --- a/MAINTAINERS |
107 | +++ b/docs/system/target-arm.rst | 21 | +++ b/MAINTAINERS |
108 | @@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running | 22 | @@ -XXX,XX +XXX,XX @@ F: include/hw/ssi/imx_spi.h |
109 | arm/realview | 23 | SBSA-REF |
110 | arm/versatile | 24 | M: Radoslaw Biernacki <rad@semihalf.com> |
111 | arm/vexpress | 25 | M: Peter Maydell <peter.maydell@linaro.org> |
112 | + arm/aspeed | 26 | -R: Leif Lindholm <quic_llindhol@quicinc.com> |
113 | arm/musicpal | 27 | +R: Leif Lindholm <leif.lindholm@oss.qualcomm.com> |
114 | arm/nseries | 28 | R: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
115 | arm/orangepi | 29 | L: qemu-arm@nongnu.org |
30 | S: Maintained | ||
31 | diff --git a/.mailmap b/.mailmap | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/.mailmap | ||
34 | +++ b/.mailmap | ||
35 | @@ -XXX,XX +XXX,XX @@ Huacai Chen <chenhuacai@kernel.org> <chenhc@lemote.com> | ||
36 | Huacai Chen <chenhuacai@kernel.org> <chenhuacai@loongson.cn> | ||
37 | James Hogan <jhogan@kernel.org> <james.hogan@imgtec.com> | ||
38 | Juan Quintela <quintela@trasno.org> <quintela@redhat.com> | ||
39 | -Leif Lindholm <quic_llindhol@quicinc.com> <leif.lindholm@linaro.org> | ||
40 | -Leif Lindholm <quic_llindhol@quicinc.com> <leif@nuviainc.com> | ||
41 | +Leif Lindholm <leif.lindholm@oss.qualcomm.com> <quic_llindhol@quicinc.com> | ||
42 | +Leif Lindholm <leif.lindholm@oss.qualcomm.com> <leif.lindholm@linaro.org> | ||
43 | +Leif Lindholm <leif.lindholm@oss.qualcomm.com> <leif@nuviainc.com> | ||
44 | Luc Michel <luc@lmichel.fr> <luc.michel@git.antfield.fr> | ||
45 | Luc Michel <luc@lmichel.fr> <luc.michel@greensocs.com> | ||
46 | Luc Michel <luc@lmichel.fr> <lmichel@kalray.eu> | ||
116 | -- | 47 | -- |
117 | 2.20.1 | 48 | 2.34.1 |
118 | 49 | ||
119 | 50 | diff view generated by jsdifflib |
1 | From: Thomas Huth <thuth@redhat.com> | 1 | From: Vikram Garhwal <vikram.garhwal@bytedance.com> |
---|---|---|---|
2 | 2 | ||
3 | As described by Edgar here: | 3 | Previously, maintainer role was paused due to inactive email id. Commit id: |
4 | c009d715721861984c4987bcc78b7ee183e86d75. | ||
4 | 5 | ||
5 | https://www.mail-archive.com/qemu-devel@nongnu.org/msg605124.html | 6 | Signed-off-by: Vikram Garhwal <vikram.garhwal@bytedance.com> |
6 | 7 | Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com> | |
7 | we can use the Ubuntu kernel for testing the xlnx-versal-virt machine. | 8 | Message-id: 20241204184205.12952-1-vikram.garhwal@bytedance.com |
8 | So let's add a boot test for this now. | ||
9 | |||
10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
11 | Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Signed-off-by: Thomas Huth <thuth@redhat.com> | ||
13 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
14 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
15 | Message-id: 20200525141237.15243-1-thuth@redhat.com | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | --- | 10 | --- |
18 | tests/acceptance/boot_linux_console.py | 26 ++++++++++++++++++++++++++ | 11 | MAINTAINERS | 2 ++ |
19 | 1 file changed, 26 insertions(+) | 12 | 1 file changed, 2 insertions(+) |
20 | 13 | ||
21 | diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py | 14 | diff --git a/MAINTAINERS b/MAINTAINERS |
22 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/tests/acceptance/boot_linux_console.py | 16 | --- a/MAINTAINERS |
24 | +++ b/tests/acceptance/boot_linux_console.py | 17 | +++ b/MAINTAINERS |
25 | @@ -XXX,XX +XXX,XX @@ class BootLinuxConsole(LinuxKernelTest): | 18 | @@ -XXX,XX +XXX,XX @@ F: tests/qtest/fuzz-sb16-test.c |
26 | console_pattern = 'Kernel command line: %s' % kernel_command_line | 19 | |
27 | self.wait_for_console_pattern(console_pattern) | 20 | Xilinx CAN |
28 | 21 | M: Francisco Iglesias <francisco.iglesias@amd.com> | |
29 | + def test_aarch64_xlnx_versal_virt(self): | 22 | +M: Vikram Garhwal <vikram.garhwal@bytedance.com> |
30 | + """ | 23 | S: Maintained |
31 | + :avocado: tags=arch:aarch64 | 24 | F: hw/net/can/xlnx-* |
32 | + :avocado: tags=machine:xlnx-versal-virt | 25 | F: include/hw/net/xlnx-* |
33 | + :avocado: tags=device:pl011 | 26 | @@ -XXX,XX +XXX,XX @@ F: include/hw/rx/ |
34 | + :avocado: tags=device:arm_gicv3 | 27 | CAN bus subsystem and hardware |
35 | + """ | 28 | M: Pavel Pisa <pisa@cmp.felk.cvut.cz> |
36 | + kernel_url = ('http://ports.ubuntu.com/ubuntu-ports/dists/' | 29 | M: Francisco Iglesias <francisco.iglesias@amd.com> |
37 | + 'bionic-updates/main/installer-arm64/current/images/' | 30 | +M: Vikram Garhwal <vikram.garhwal@bytedance.com> |
38 | + 'netboot/ubuntu-installer/arm64/linux') | 31 | S: Maintained |
39 | + kernel_hash = '5bfc54cf7ed8157d93f6e5b0241e727b6dc22c50' | 32 | W: https://canbus.pages.fel.cvut.cz/ |
40 | + kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) | 33 | F: net/can/* |
41 | + | ||
42 | + initrd_url = ('http://ports.ubuntu.com/ubuntu-ports/dists/' | ||
43 | + 'bionic-updates/main/installer-arm64/current/images/' | ||
44 | + 'netboot/ubuntu-installer/arm64/initrd.gz') | ||
45 | + initrd_hash = 'd385d3e88d53e2004c5d43cbe668b458a094f772' | ||
46 | + initrd_path = self.fetch_asset(initrd_url, asset_hash=initrd_hash) | ||
47 | + | ||
48 | + self.vm.set_console() | ||
49 | + self.vm.add_args('-m', '2G', | ||
50 | + '-kernel', kernel_path, | ||
51 | + '-initrd', initrd_path) | ||
52 | + self.vm.launch() | ||
53 | + self.wait_for_console_pattern('Checked W+X mappings: passed') | ||
54 | + | ||
55 | def test_arm_virt(self): | ||
56 | """ | ||
57 | :avocado: tags=arch:arm | ||
58 | -- | 34 | -- |
59 | 2.20.1 | 35 | 2.34.1 |
60 | |||
61 | diff view generated by jsdifflib |