1
Arm queue -- I have more stuff pending but I prefer to push
1
The following changes since commit 7e7eb9f852a46b51a71ae9d82590b2e4d28827ee:
2
this first lot out and keep the pull below 50 patches.
3
Most of this is Alex's FP16 support work.
4
2
5
-- PMM
3
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2021-01-28' into staging (2021-01-28 22:43:18 +0000)
6
7
8
The following changes since commit 6697439794f72b3501ee16bb95d16854f9981421:
9
10
Merge remote-tracking branch 'remotes/kraxel/tags/usb-20180227-pull-request' into staging (2018-02-27 17:50:46 +0000)
11
4
12
are available in the Git repository at:
5
are available in the Git repository at:
13
6
14
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180301
7
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210129
15
8
16
for you to fetch changes up to c22e580c2ad1cccef582e1490e732f254d4ac064:
9
for you to fetch changes up to 11749122e1a86866591306d43603d2795a3dea1a:
17
10
18
MAINTAINERS: Update my email address (2018-03-01 11:13:59 +0000)
11
hw/arm/stellaris: Remove board-creation reset of STELLARIS_SYS (2021-01-29 10:47:29 +0000)
19
12
20
----------------------------------------------------------------
13
----------------------------------------------------------------
21
target-arm queue:
14
target-arm queue:
22
* update MAINTAINERS for Alistair's new email address
15
* Implement ID_PFR2
23
* add Arm v8.2 FP16 arithmetic extension for linux-user
16
* Conditionalize DBGDIDR
24
* implement display connector emulation for vexpress board
17
* rename xlnx-zcu102.canbusN properties
25
* xilinx_spips: Enable only two slaves when reading/writing with stripe
18
* provide powerdown/reset mechanism for secure firmware on 'virt' board
26
* xilinx_spips: Use 8 dummy cycles with the QIOR/QIOR4 commands
19
* hw/misc: Fix arith overflow in NPCM7XX PWM module
27
* hw: register: Run post_write hook on reset
20
* target/arm: Replace magic value by MMU_DATA_LOAD definition
21
* configure: fix preadv errors on Catalina macOS with new XCode
22
* Various configure and other cleanups in preparation for iOS support
23
* hvf: Add hypervisor entitlement to output binaries (needed for Big Sur)
24
* Implement pvpanic-pci device
25
* Convert the CMSDK timer devices to the Clock framework
28
26
29
----------------------------------------------------------------
27
----------------------------------------------------------------
30
Alex Bennée (31):
28
Alexander Graf (1):
31
include/exec/helper-head.h: support f16 in helper calls
29
hvf: Add hypervisor entitlement to output binaries
32
target/arm/cpu64: introduce ARM_V8_FP16 feature bit
33
target/arm/cpu.h: update comment for half-precision values
34
target/arm/cpu.h: add additional float_status flags
35
target/arm/helper: pass explicit fpst to set_rmode
36
arm/translate-a64: implement half-precision F(MIN|MAX)(V|NMV)
37
arm/translate-a64: handle_3same_64 comment fix
38
arm/translate-a64: initial decode for simd_three_reg_same_fp16
39
arm/translate-a64: add FP16 FADD/FABD/FSUB/FMUL/FDIV to simd_three_reg_same_fp16
40
arm/translate-a64: add FP16 F[A]C[EQ/GE/GT] to simd_three_reg_same_fp16
41
arm/translate-a64: add FP16 FMULA/X/S to simd_three_reg_same_fp16
42
arm/translate-a64: add FP16 FR[ECP/SQRT]S to simd_three_reg_same_fp16
43
arm/translate-a64: add FP16 pairwise ops simd_three_reg_same_fp16
44
arm/translate-a64: add FP16 FMULX/MLS/FMLA to simd_indexed
45
arm/translate-a64: add FP16 x2 ops for simd_indexed
46
arm/translate-a64: initial decode for simd_two_reg_misc_fp16
47
arm/translate-a64: add FP16 FPRINTx to simd_two_reg_misc_fp16
48
arm/translate-a64: add FCVTxx to simd_two_reg_misc_fp16
49
arm/translate-a64: add FP16 FCMxx (zero) to simd_two_reg_misc_fp16
50
arm/translate-a64: add FP16 SCVTF/UCVFT to simd_two_reg_misc_fp16
51
arm/translate-a64: add FP16 FNEG/FABS to simd_two_reg_misc_fp16
52
arm/helper.c: re-factor recpe and add recepe_f16
53
arm/translate-a64: add FP16 FRECPE
54
arm/translate-a64: add FP16 FRCPX to simd_two_reg_misc_fp16
55
arm/translate-a64: add FP16 FSQRT to simd_two_reg_misc_fp16
56
arm/helper.c: re-factor rsqrte and add rsqrte_f16
57
arm/translate-a64: add FP16 FRSQRTE to simd_two_reg_misc_fp16
58
arm/translate-a64: add FP16 FMOV to simd_mod_imm
59
arm/translate-a64: add all FP16 ops in simd_scalar_pairwise
60
arm/translate-a64: implement simd_scalar_three_reg_same_fp16
61
arm/translate-a64: add all single op FP16 to handle_fp_1src_half
62
30
63
Alistair Francis (2):
31
Hao Wu (1):
64
hw: register: Run post_write hook on reset
32
hw/misc: Fix arith overflow in NPCM7XX PWM module
65
MAINTAINERS: Update my email address
66
33
67
Corey Minyard (2):
34
Joelle van Dyne (7):
68
i2c: Fix some brace style issues
35
configure: cross-compiling with empty cross_prefix
69
i2c: Move the bus class to i2c.h
36
osdep: build with non-working system() function
37
darwin: remove redundant dependency declaration
38
darwin: fix cross-compiling for Darwin
39
configure: cross compile should use x86_64 cpu_family
40
darwin: detect CoreAudio for build
41
darwin: remove 64-bit build detection on 32-bit OS
70
42
71
Francisco Iglesias (2):
43
Maxim Uvarov (3):
72
xilinx_spips: Enable only two slaves when reading/writing with stripe
44
hw: gpio: implement gpio-pwr driver for qemu reset/poweroff
73
xilinx_spips: Use 8 dummy cycles with the QIOR/QIOR4 commands
45
arm-virt: refactor gpios creation
46
arm-virt: add secure pl061 for reset/power down
74
47
75
Linus Walleij (3):
48
Mihai Carabas (4):
76
hw/i2c-ddc: Do not fail writes
49
hw/misc/pvpanic: split-out generic and bus dependent code
77
hw/sii9022: Add support for Silicon Image SII9022
50
hw/misc/pvpanic: add PCI interface support
78
arm/vexpress: Add proper display connector emulation
51
pvpanic : update pvpanic spec document
52
tests/qtest: add a test case for pvpanic-pci
79
53
80
Peter Maydell (2):
54
Paolo Bonzini (1):
81
target/arm: Enable ARM_V8_FP16 feature bit for the AArch64 "any" CPU
55
arm: rename xlnx-zcu102.canbusN properties
82
linux-user: Report AArch64 FP16 support via hwcap bits
83
56
84
hw/display/Makefile.objs | 1 +
57
Peter Maydell (26):
85
include/exec/helper-head.h | 3 +
58
configure: Move preadv check to meson.build
86
include/fpu/softfloat.h | 18 +-
59
ptimer: Add new ptimer_set_period_from_clock() function
87
include/hw/i2c/i2c.h | 23 +-
60
clock: Add new clock_has_source() function
88
include/hw/register.h | 6 +-
61
tests: Add a simple test of the CMSDK APB timer
89
target/arm/cpu.h | 34 +-
62
tests: Add a simple test of the CMSDK APB watchdog
90
target/arm/helper-a64.h | 33 +
63
tests: Add a simple test of the CMSDK APB dual timer
91
target/arm/helper.h | 14 +-
64
hw/timer/cmsdk-apb-timer: Rename CMSDKAPBTIMER struct to CMSDKAPBTimer
92
hw/arm/vexpress.c | 6 +-
65
hw/timer/cmsdk-apb-timer: Add Clock input
93
hw/core/register.c | 8 +
66
hw/timer/cmsdk-apb-dualtimer: Add Clock input
94
hw/display/sii9022.c | 191 ++++++
67
hw/watchdog/cmsdk-apb-watchdog: Add Clock input
95
hw/i2c/core.c | 18 -
68
hw/arm/armsse: Rename "MAINCLK" property to "MAINCLK_FRQ"
96
hw/i2c/i2c-ddc.c | 4 +-
69
hw/arm/armsse: Wire up clocks
97
hw/ssi/xilinx_spips.c | 43 +-
70
hw/arm/mps2: Inline CMSDK_APB_TIMER creation
98
linux-user/elfload.c | 2 +
71
hw/arm/mps2: Create and connect SYSCLK Clock
99
target/arm/cpu64.c | 1 +
72
hw/arm/mps2-tz: Create and connect ARMSSE Clocks
100
target/arm/helper-a64.c | 269 +++++++++
73
hw/arm/musca: Create and connect ARMSSE Clocks
101
target/arm/helper.c | 481 ++++++++-------
74
hw/arm/stellaris: Convert SSYS to QOM device
102
target/arm/translate-a64.c | 1266 +++++++++++++++++++++++++++++++++------
75
hw/arm/stellaris: Create Clock input for watchdog
103
target/arm/translate.c | 12 +-
76
hw/timer/cmsdk-apb-timer: Convert to use Clock input
104
MAINTAINERS | 12 +-
77
hw/timer/cmsdk-apb-dualtimer: Convert to use Clock input
105
default-configs/arm-softmmu.mak | 2 +
78
hw/watchdog/cmsdk-apb-watchdog: Convert to use Clock input
106
hw/display/trace-events | 5 +
79
tests/qtest/cmsdk-apb-watchdog-test: Test clock changes
107
23 files changed, 1981 insertions(+), 471 deletions(-)
80
hw/arm/armsse: Use Clock to set system_clock_scale
108
create mode 100644 hw/display/sii9022.c
81
arm: Don't set freq properties on CMSDK timer, dualtimer, watchdog, ARMSSE
82
arm: Remove frq properties on CMSDK timer, dualtimer, watchdog, ARMSSE
83
hw/arm/stellaris: Remove board-creation reset of STELLARIS_SYS
109
84
85
Philippe Mathieu-Daudé (1):
86
target/arm: Replace magic value by MMU_DATA_LOAD definition
87
88
Richard Henderson (2):
89
target/arm: Implement ID_PFR2
90
target/arm: Conditionalize DBGDIDR
91
92
docs/devel/clocks.rst | 16 +++
93
docs/specs/pci-ids.txt | 1 +
94
docs/specs/pvpanic.txt | 13 ++-
95
docs/system/arm/virt.rst | 2 +
96
configure | 78 ++++++++------
97
meson.build | 34 ++++++-
98
include/hw/arm/armsse.h | 14 ++-
99
include/hw/arm/virt.h | 2 +
100
include/hw/clock.h | 15 +++
101
include/hw/misc/pvpanic.h | 24 ++++-
102
include/hw/pci/pci.h | 1 +
103
include/hw/ptimer.h | 22 ++++
104
include/hw/timer/cmsdk-apb-dualtimer.h | 5 +-
105
include/hw/timer/cmsdk-apb-timer.h | 34 ++-----
106
include/hw/watchdog/cmsdk-apb-watchdog.h | 5 +-
107
include/qemu/osdep.h | 12 +++
108
include/qemu/typedefs.h | 1 +
109
target/arm/cpu.h | 1 +
110
hw/arm/armsse.c | 48 ++++++---
111
hw/arm/mps2-tz.c | 14 ++-
112
hw/arm/mps2.c | 28 ++++-
113
hw/arm/musca.c | 13 ++-
114
hw/arm/stellaris.c | 170 +++++++++++++++++++++++--------
115
hw/arm/virt.c | 111 ++++++++++++++++----
116
hw/arm/xlnx-zcu102.c | 4 +-
117
hw/core/ptimer.c | 34 +++++++
118
hw/gpio/gpio_pwr.c | 70 +++++++++++++
119
hw/misc/npcm7xx_pwm.c | 23 ++++-
120
hw/misc/pvpanic-isa.c | 94 +++++++++++++++++
121
hw/misc/pvpanic-pci.c | 94 +++++++++++++++++
122
hw/misc/pvpanic.c | 85 ++--------------
123
hw/timer/cmsdk-apb-dualtimer.c | 53 +++++++---
124
hw/timer/cmsdk-apb-timer.c | 55 +++++-----
125
hw/watchdog/cmsdk-apb-watchdog.c | 29 ++++--
126
target/arm/helper.c | 27 +++--
127
target/arm/kvm64.c | 2 +
128
tests/qtest/cmsdk-apb-dualtimer-test.c | 130 +++++++++++++++++++++++
129
tests/qtest/cmsdk-apb-timer-test.c | 75 ++++++++++++++
130
tests/qtest/cmsdk-apb-watchdog-test.c | 131 ++++++++++++++++++++++++
131
tests/qtest/npcm7xx_pwm-test.c | 4 +-
132
tests/qtest/pvpanic-pci-test.c | 94 +++++++++++++++++
133
tests/qtest/xlnx-can-test.c | 30 +++---
134
MAINTAINERS | 3 +
135
accel/hvf/entitlements.plist | 8 ++
136
hw/arm/Kconfig | 1 +
137
hw/gpio/Kconfig | 3 +
138
hw/gpio/meson.build | 1 +
139
hw/i386/Kconfig | 2 +-
140
hw/misc/Kconfig | 12 ++-
141
hw/misc/meson.build | 4 +-
142
scripts/entitlement.sh | 13 +++
143
tests/qtest/meson.build | 6 +-
144
52 files changed, 1432 insertions(+), 319 deletions(-)
145
create mode 100644 hw/gpio/gpio_pwr.c
146
create mode 100644 hw/misc/pvpanic-isa.c
147
create mode 100644 hw/misc/pvpanic-pci.c
148
create mode 100644 tests/qtest/cmsdk-apb-dualtimer-test.c
149
create mode 100644 tests/qtest/cmsdk-apb-timer-test.c
150
create mode 100644 tests/qtest/cmsdk-apb-watchdog-test.c
151
create mode 100644 tests/qtest/pvpanic-pci-test.c
152
create mode 100644 accel/hvf/entitlements.plist
153
create mode 100755 scripts/entitlement.sh
154
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Half-precision flush to zero behaviour is controlled by a separate
3
This was defined at some point before ARMv8.4, and will
4
FZ16 bit in the FPCR. To handle this we pass a pointer to
4
shortly be used by new processor descriptions.
5
fp_status_fp16 when working on half-precision operations. The value of
6
the presented FPCR is calculated from an amalgam of the two when read.
7
5
8
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20180227143852.11175-5-alex.bennee@linaro.org
8
Message-id: 20210120204400.1056582-1-richard.henderson@linaro.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
10
---
13
target/arm/cpu.h | 32 ++++++++++++++++++++++------
11
target/arm/cpu.h | 1 +
14
target/arm/helper.c | 26 ++++++++++++++++++-----
12
target/arm/helper.c | 4 ++--
15
target/arm/translate-a64.c | 53 +++++++++++++++++++++++++---------------------
13
target/arm/kvm64.c | 2 ++
16
3 files changed, 75 insertions(+), 36 deletions(-)
14
3 files changed, 5 insertions(+), 2 deletions(-)
17
15
18
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
16
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
19
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/cpu.h
18
--- a/target/arm/cpu.h
21
+++ b/target/arm/cpu.h
19
+++ b/target/arm/cpu.h
22
@@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState {
20
@@ -XXX,XX +XXX,XX @@ struct ARMCPU {
23
/* scratch space when Tn are not sufficient. */
21
uint32_t id_mmfr4;
24
uint32_t scratch[8];
22
uint32_t id_pfr0;
25
23
uint32_t id_pfr1;
26
- /* fp_status is the "normal" fp status. standard_fp_status retains
24
+ uint32_t id_pfr2;
27
- * values corresponding to the ARM "Standard FPSCR Value", ie
25
uint32_t mvfr0;
28
- * default-NaN, flush-to-zero, round-to-nearest and is used by
26
uint32_t mvfr1;
29
- * any operations (generally Neon) which the architecture defines
27
uint32_t mvfr2;
30
- * as controlled by the standard FPSCR value rather than the FPSCR.
31
+ /* There are a number of distinct float control structures:
32
+ *
33
+ * fp_status: is the "normal" fp status.
34
+ * fp_status_fp16: used for half-precision calculations
35
+ * standard_fp_status : the ARM "Standard FPSCR Value"
36
+ *
37
+ * Half-precision operations are governed by a separate
38
+ * flush-to-zero control bit in FPSCR:FZ16. We pass a separate
39
+ * status structure to control this.
40
+ *
41
+ * The "Standard FPSCR", ie default-NaN, flush-to-zero,
42
+ * round-to-nearest and is used by any operations (generally
43
+ * Neon) which the architecture defines as controlled by the
44
+ * standard FPSCR value rather than the FPSCR.
45
*
46
* To avoid having to transfer exception bits around, we simply
47
* say that the FPSCR cumulative exception flags are the logical
48
- * OR of the flags in the two fp statuses. This relies on the
49
+ * OR of the flags in the three fp statuses. This relies on the
50
* only thing which needs to read the exception flags being
51
* an explicit FPSCR read.
52
*/
53
float_status fp_status;
54
+ float_status fp_status_f16;
55
float_status standard_fp_status;
56
57
/* ZCR_EL[1-3] */
58
@@ -XXX,XX +XXX,XX @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask)
59
uint32_t vfp_get_fpscr(CPUARMState *env);
60
void vfp_set_fpscr(CPUARMState *env, uint32_t val);
61
62
-/* For A64 the FPSCR is split into two logically distinct registers,
63
+/* FPCR, Floating Point Control Register
64
+ * FPSR, Floating Poiht Status Register
65
+ *
66
+ * For A64 the FPSCR is split into two logically distinct registers,
67
* FPCR and FPSR. However since they still use non-overlapping bits
68
* we store the underlying state in fpscr and just mask on read/write.
69
*/
70
#define FPSR_MASK 0xf800009f
71
#define FPCR_MASK 0x07f79f00
72
+
73
+#define FPCR_FZ16 (1 << 19) /* ARMv8.2+, FP16 flush-to-zero */
74
+#define FPCR_FZ (1 << 24) /* Flush-to-zero enable bit */
75
+#define FPCR_DN (1 << 25) /* Default NaN enable bit */
76
+
77
static inline uint32_t vfp_get_fpsr(CPUARMState *env)
78
{
79
return vfp_get_fpscr(env) & FPSR_MASK;
80
diff --git a/target/arm/helper.c b/target/arm/helper.c
28
diff --git a/target/arm/helper.c b/target/arm/helper.c
81
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
82
--- a/target/arm/helper.c
30
--- a/target/arm/helper.c
83
+++ b/target/arm/helper.c
31
+++ b/target/arm/helper.c
84
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env)
32
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
85
| (env->vfp.vec_stride << 20);
33
.access = PL1_R, .type = ARM_CP_CONST,
86
i = get_float_exception_flags(&env->vfp.fp_status);
34
.accessfn = access_aa64_tid3,
87
i |= get_float_exception_flags(&env->vfp.standard_fp_status);
35
.resetvalue = 0 },
88
+ i |= get_float_exception_flags(&env->vfp.fp_status_f16);
36
- { .name = "MVFR4_EL1_RESERVED", .state = ARM_CP_STATE_AA64,
89
fpscr |= vfp_exceptbits_from_host(i);
37
+ { .name = "ID_PFR2", .state = ARM_CP_STATE_BOTH,
90
return fpscr;
38
.opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 4,
91
}
39
.access = PL1_R, .type = ARM_CP_CONST,
92
@@ -XXX,XX +XXX,XX @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val)
40
.accessfn = access_aa64_tid3,
93
break;
41
- .resetvalue = 0 },
94
}
42
+ .resetvalue = cpu->isar.id_pfr2 },
95
set_float_rounding_mode(i, &env->vfp.fp_status);
43
{ .name = "MVFR5_EL1_RESERVED", .state = ARM_CP_STATE_AA64,
96
+ set_float_rounding_mode(i, &env->vfp.fp_status_f16);
44
.opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 5,
97
}
45
.access = PL1_R, .type = ARM_CP_CONST,
98
- if (changed & (1 << 24)) {
46
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
99
- set_flush_to_zero((val & (1 << 24)) != 0, &env->vfp.fp_status);
100
- set_flush_inputs_to_zero((val & (1 << 24)) != 0, &env->vfp.fp_status);
101
+ if (changed & FPCR_FZ16) {
102
+ bool ftz_enabled = val & FPCR_FZ16;
103
+ set_flush_to_zero(ftz_enabled, &env->vfp.fp_status_f16);
104
+ set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status_f16);
105
+ }
106
+ if (changed & FPCR_FZ) {
107
+ bool ftz_enabled = val & FPCR_FZ;
108
+ set_flush_to_zero(ftz_enabled, &env->vfp.fp_status);
109
+ set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status);
110
+ }
111
+ if (changed & FPCR_DN) {
112
+ bool dnan_enabled = val & FPCR_DN;
113
+ set_default_nan_mode(dnan_enabled, &env->vfp.fp_status);
114
+ set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_f16);
115
}
116
- if (changed & (1 << 25))
117
- set_default_nan_mode((val & (1 << 25)) != 0, &env->vfp.fp_status);
118
119
+ /* The exception flags are ORed together when we read fpscr so we
120
+ * only need to preserve the current state in one of our
121
+ * float_status values.
122
+ */
123
i = vfp_exceptbits_to_host(val);
124
set_float_exception_flags(i, &env->vfp.fp_status);
125
+ set_float_exception_flags(0, &env->vfp.fp_status_f16);
126
set_float_exception_flags(0, &env->vfp.standard_fp_status);
127
}
128
129
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
130
index XXXXXXX..XXXXXXX 100644
47
index XXXXXXX..XXXXXXX 100644
131
--- a/target/arm/translate-a64.c
48
--- a/target/arm/kvm64.c
132
+++ b/target/arm/translate-a64.c
49
+++ b/target/arm/kvm64.c
133
@@ -XXX,XX +XXX,XX @@ static void write_fp_sreg(DisasContext *s, int reg, TCGv_i32 v)
50
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
134
tcg_temp_free_i64(tmp);
51
ARM64_SYS_REG(3, 0, 0, 1, 0));
135
}
52
err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr1,
136
53
ARM64_SYS_REG(3, 0, 0, 1, 1));
137
-static TCGv_ptr get_fpstatus_ptr(void)
54
+ err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr2,
138
+static TCGv_ptr get_fpstatus_ptr(bool is_f16)
55
+ ARM64_SYS_REG(3, 0, 0, 3, 4));
139
{
56
err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_dfr0,
140
TCGv_ptr statusptr = tcg_temp_new_ptr();
57
ARM64_SYS_REG(3, 0, 0, 1, 2));
141
int offset;
58
err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr0,
142
143
- /* In A64 all instructions (both FP and Neon) use the FPCR;
144
- * there is no equivalent of the A32 Neon "standard FPSCR value"
145
- * and all operations use vfp.fp_status.
146
+ /* In A64 all instructions (both FP and Neon) use the FPCR; there
147
+ * is no equivalent of the A32 Neon "standard FPSCR value".
148
+ * However half-precision operations operate under a different
149
+ * FZ16 flag and use vfp.fp_status_f16 instead of vfp.fp_status.
150
*/
151
- offset = offsetof(CPUARMState, vfp.fp_status);
152
+ if (is_f16) {
153
+ offset = offsetof(CPUARMState, vfp.fp_status_f16);
154
+ } else {
155
+ offset = offsetof(CPUARMState, vfp.fp_status);
156
+ }
157
tcg_gen_addi_ptr(statusptr, cpu_env, offset);
158
return statusptr;
159
}
160
@@ -XXX,XX +XXX,XX @@ static void handle_fp_compare(DisasContext *s, bool is_double,
161
bool cmp_with_zero, bool signal_all_nans)
162
{
163
TCGv_i64 tcg_flags = tcg_temp_new_i64();
164
- TCGv_ptr fpst = get_fpstatus_ptr();
165
+ TCGv_ptr fpst = get_fpstatus_ptr(false);
166
167
if (is_double) {
168
TCGv_i64 tcg_vn, tcg_vm;
169
@@ -XXX,XX +XXX,XX @@ static void handle_fp_1src_single(DisasContext *s, int opcode, int rd, int rn)
170
TCGv_i32 tcg_op;
171
TCGv_i32 tcg_res;
172
173
- fpst = get_fpstatus_ptr();
174
+ fpst = get_fpstatus_ptr(false);
175
tcg_op = read_fp_sreg(s, rn);
176
tcg_res = tcg_temp_new_i32();
177
178
@@ -XXX,XX +XXX,XX @@ static void handle_fp_1src_double(DisasContext *s, int opcode, int rd, int rn)
179
return;
180
}
181
182
- fpst = get_fpstatus_ptr();
183
+ fpst = get_fpstatus_ptr(false);
184
tcg_op = read_fp_dreg(s, rn);
185
tcg_res = tcg_temp_new_i64();
186
187
@@ -XXX,XX +XXX,XX @@ static void handle_fp_2src_single(DisasContext *s, int opcode,
188
TCGv_ptr fpst;
189
190
tcg_res = tcg_temp_new_i32();
191
- fpst = get_fpstatus_ptr();
192
+ fpst = get_fpstatus_ptr(false);
193
tcg_op1 = read_fp_sreg(s, rn);
194
tcg_op2 = read_fp_sreg(s, rm);
195
196
@@ -XXX,XX +XXX,XX @@ static void handle_fp_2src_double(DisasContext *s, int opcode,
197
TCGv_ptr fpst;
198
199
tcg_res = tcg_temp_new_i64();
200
- fpst = get_fpstatus_ptr();
201
+ fpst = get_fpstatus_ptr(false);
202
tcg_op1 = read_fp_dreg(s, rn);
203
tcg_op2 = read_fp_dreg(s, rm);
204
205
@@ -XXX,XX +XXX,XX @@ static void handle_fp_3src_single(DisasContext *s, bool o0, bool o1,
206
{
207
TCGv_i32 tcg_op1, tcg_op2, tcg_op3;
208
TCGv_i32 tcg_res = tcg_temp_new_i32();
209
- TCGv_ptr fpst = get_fpstatus_ptr();
210
+ TCGv_ptr fpst = get_fpstatus_ptr(false);
211
212
tcg_op1 = read_fp_sreg(s, rn);
213
tcg_op2 = read_fp_sreg(s, rm);
214
@@ -XXX,XX +XXX,XX @@ static void handle_fp_3src_double(DisasContext *s, bool o0, bool o1,
215
{
216
TCGv_i64 tcg_op1, tcg_op2, tcg_op3;
217
TCGv_i64 tcg_res = tcg_temp_new_i64();
218
- TCGv_ptr fpst = get_fpstatus_ptr();
219
+ TCGv_ptr fpst = get_fpstatus_ptr(false);
220
221
tcg_op1 = read_fp_dreg(s, rn);
222
tcg_op2 = read_fp_dreg(s, rm);
223
@@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode,
224
TCGv_ptr tcg_fpstatus;
225
TCGv_i32 tcg_shift;
226
227
- tcg_fpstatus = get_fpstatus_ptr();
228
+ tcg_fpstatus = get_fpstatus_ptr(false);
229
230
tcg_shift = tcg_const_i32(64 - scale);
231
232
@@ -XXX,XX +XXX,XX @@ static void disas_simd_across_lanes(DisasContext *s, uint32_t insn)
233
TCGv_i32 tcg_elt1 = tcg_temp_new_i32();
234
TCGv_i32 tcg_elt2 = tcg_temp_new_i32();
235
TCGv_i32 tcg_elt3 = tcg_temp_new_i32();
236
- TCGv_ptr fpst = get_fpstatus_ptr();
237
+ TCGv_ptr fpst = get_fpstatus_ptr(false);
238
239
assert(esize == 32);
240
assert(elements == 4);
241
@@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_pairwise(DisasContext *s, uint32_t insn)
242
}
243
244
size = extract32(size, 0, 1) ? 3 : 2;
245
- fpst = get_fpstatus_ptr();
246
+ fpst = get_fpstatus_ptr(false);
247
break;
248
default:
249
unallocated_encoding(s);
250
@@ -XXX,XX +XXX,XX @@ static void handle_simd_intfp_conv(DisasContext *s, int rd, int rn,
251
int fracbits, int size)
252
{
253
bool is_double = size == 3 ? true : false;
254
- TCGv_ptr tcg_fpst = get_fpstatus_ptr();
255
+ TCGv_ptr tcg_fpst = get_fpstatus_ptr(false);
256
TCGv_i32 tcg_shift = tcg_const_i32(fracbits);
257
TCGv_i64 tcg_int = tcg_temp_new_i64();
258
TCGMemOp mop = size | (is_signed ? MO_SIGN : 0);
259
@@ -XXX,XX +XXX,XX @@ static void handle_simd_shift_fpint_conv(DisasContext *s, bool is_scalar,
260
261
tcg_rmode = tcg_const_i32(arm_rmode_to_sf(FPROUNDING_ZERO));
262
gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
263
- tcg_fpstatus = get_fpstatus_ptr();
264
+ tcg_fpstatus = get_fpstatus_ptr(false);
265
tcg_shift = tcg_const_i32(fracbits);
266
267
if (is_double) {
268
@@ -XXX,XX +XXX,XX @@ static void handle_3same_float(DisasContext *s, int size, int elements,
269
int fpopcode, int rd, int rn, int rm)
270
{
271
int pass;
272
- TCGv_ptr fpst = get_fpstatus_ptr();
273
+ TCGv_ptr fpst = get_fpstatus_ptr(false);
274
275
for (pass = 0; pass < elements; pass++) {
276
if (size) {
277
@@ -XXX,XX +XXX,XX @@ static void handle_2misc_fcmp_zero(DisasContext *s, int opcode,
278
return;
279
}
280
281
- fpst = get_fpstatus_ptr();
282
+ fpst = get_fpstatus_ptr(false);
283
284
if (is_double) {
285
TCGv_i64 tcg_op = tcg_temp_new_i64();
286
@@ -XXX,XX +XXX,XX @@ static void handle_2misc_reciprocal(DisasContext *s, int opcode,
287
int size, int rn, int rd)
288
{
289
bool is_double = (size == 3);
290
- TCGv_ptr fpst = get_fpstatus_ptr();
291
+ TCGv_ptr fpst = get_fpstatus_ptr(false);
292
293
if (is_double) {
294
TCGv_i64 tcg_op = tcg_temp_new_i64();
295
@@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_two_reg_misc(DisasContext *s, uint32_t insn)
296
if (is_fcvt) {
297
tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rmode));
298
gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
299
- tcg_fpstatus = get_fpstatus_ptr();
300
+ tcg_fpstatus = get_fpstatus_ptr(false);
301
} else {
302
tcg_rmode = NULL;
303
tcg_fpstatus = NULL;
304
@@ -XXX,XX +XXX,XX @@ static void handle_simd_3same_pair(DisasContext *s, int is_q, int u, int opcode,
305
306
/* Floating point operations need fpst */
307
if (opcode >= 0x58) {
308
- fpst = get_fpstatus_ptr();
309
+ fpst = get_fpstatus_ptr(false);
310
} else {
311
fpst = NULL;
312
}
313
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn)
314
}
315
316
if (need_fpstatus) {
317
- tcg_fpstatus = get_fpstatus_ptr();
318
+ tcg_fpstatus = get_fpstatus_ptr(false);
319
} else {
320
tcg_fpstatus = NULL;
321
}
322
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
323
}
324
325
if (is_fp) {
326
- fpst = get_fpstatus_ptr();
327
+ fpst = get_fpstatus_ptr(false);
328
} else {
329
fpst = NULL;
330
}
331
--
59
--
332
2.16.2
60
2.20.1
333
61
334
62
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
I've re-factored the handle_simd_intfp_conv helper to properly handle
3
Only define the register if it exists for the cpu.
4
half-precision as well as call plain conversion helpers when we are
5
not doing fixed point conversion.
6
4
7
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20210120031656.737646-1-richard.henderson@linaro.org
9
Message-id: 20180227143852.11175-21-alex.bennee@linaro.org
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
9
---
12
target/arm/helper.h | 10 ++++
10
target/arm/helper.c | 21 +++++++++++++++------
13
target/arm/helper.c | 4 ++
11
1 file changed, 15 insertions(+), 6 deletions(-)
14
target/arm/translate-a64.c | 122 ++++++++++++++++++++++++++++++++++-----------
15
3 files changed, 108 insertions(+), 28 deletions(-)
16
12
17
diff --git a/target/arm/helper.h b/target/arm/helper.h
18
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/helper.h
20
+++ b/target/arm/helper.h
21
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(vfp_cmped, void, f64, f64, env)
22
DEF_HELPER_2(vfp_fcvtds, f64, f32, env)
23
DEF_HELPER_2(vfp_fcvtsd, f32, f64, env)
24
25
+DEF_HELPER_2(vfp_uitoh, f16, i32, ptr)
26
DEF_HELPER_2(vfp_uitos, f32, i32, ptr)
27
DEF_HELPER_2(vfp_uitod, f64, i32, ptr)
28
+DEF_HELPER_2(vfp_sitoh, f16, i32, ptr)
29
DEF_HELPER_2(vfp_sitos, f32, i32, ptr)
30
DEF_HELPER_2(vfp_sitod, f64, i32, ptr)
31
32
+DEF_HELPER_2(vfp_touih, i32, f16, ptr)
33
DEF_HELPER_2(vfp_touis, i32, f32, ptr)
34
DEF_HELPER_2(vfp_touid, i32, f64, ptr)
35
+DEF_HELPER_2(vfp_touizh, i32, f16, ptr)
36
DEF_HELPER_2(vfp_touizs, i32, f32, ptr)
37
DEF_HELPER_2(vfp_touizd, i32, f64, ptr)
38
+DEF_HELPER_2(vfp_tosih, i32, f16, ptr)
39
DEF_HELPER_2(vfp_tosis, i32, f32, ptr)
40
DEF_HELPER_2(vfp_tosid, i32, f64, ptr)
41
+DEF_HELPER_2(vfp_tosizh, i32, f16, ptr)
42
DEF_HELPER_2(vfp_tosizs, i32, f32, ptr)
43
DEF_HELPER_2(vfp_tosizd, i32, f64, ptr)
44
45
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(vfp_toshd_round_to_zero, i64, f64, i32, ptr)
46
DEF_HELPER_3(vfp_tosld_round_to_zero, i64, f64, i32, ptr)
47
DEF_HELPER_3(vfp_touhd_round_to_zero, i64, f64, i32, ptr)
48
DEF_HELPER_3(vfp_tould_round_to_zero, i64, f64, i32, ptr)
49
+DEF_HELPER_3(vfp_toulh, i32, f16, i32, ptr)
50
+DEF_HELPER_3(vfp_toslh, i32, f16, i32, ptr)
51
DEF_HELPER_3(vfp_toshs, i32, f32, i32, ptr)
52
DEF_HELPER_3(vfp_tosls, i32, f32, i32, ptr)
53
DEF_HELPER_3(vfp_tosqs, i64, f32, i32, ptr)
54
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(vfp_sqtod, f64, i64, i32, ptr)
55
DEF_HELPER_3(vfp_uhtod, f64, i64, i32, ptr)
56
DEF_HELPER_3(vfp_ultod, f64, i64, i32, ptr)
57
DEF_HELPER_3(vfp_uqtod, f64, i64, i32, ptr)
58
+DEF_HELPER_3(vfp_sltoh, f16, i32, i32, ptr)
59
+DEF_HELPER_3(vfp_ultoh, f16, i32, i32, ptr)
60
61
DEF_HELPER_FLAGS_2(set_rmode, TCG_CALL_NO_RWG, i32, i32, ptr)
62
DEF_HELPER_FLAGS_2(set_neon_rmode, TCG_CALL_NO_RWG, i32, i32, env)
63
diff --git a/target/arm/helper.c b/target/arm/helper.c
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
64
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
65
--- a/target/arm/helper.c
15
--- a/target/arm/helper.c
66
+++ b/target/arm/helper.c
16
+++ b/target/arm/helper.c
67
@@ -XXX,XX +XXX,XX @@ CONV_ITOF(vfp_##name##to##p, fsz, sign) \
17
@@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu)
68
CONV_FTOI(vfp_to##name##p, fsz, sign, ) \
18
*/
69
CONV_FTOI(vfp_to##name##z##p, fsz, sign, _round_to_zero)
19
int i;
70
20
int wrps, brps, ctx_cmps;
71
+FLOAT_CONVS(si, h, 16, )
21
- ARMCPRegInfo dbgdidr = {
72
FLOAT_CONVS(si, s, 32, )
22
- .name = "DBGDIDR", .cp = 14, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 0,
73
FLOAT_CONVS(si, d, 64, )
23
- .access = PL0_R, .accessfn = access_tda,
74
+FLOAT_CONVS(ui, h, 16, u)
24
- .type = ARM_CP_CONST, .resetvalue = cpu->isar.dbgdidr,
75
FLOAT_CONVS(ui, s, 32, u)
25
- };
76
FLOAT_CONVS(ui, d, 64, u)
77
78
@@ -XXX,XX +XXX,XX @@ VFP_CONV_FIX_A64(sq, s, 32, 64, int64)
79
VFP_CONV_FIX(uh, s, 32, 32, uint16)
80
VFP_CONV_FIX(ul, s, 32, 32, uint32)
81
VFP_CONV_FIX_A64(uq, s, 32, 64, uint64)
82
+VFP_CONV_FIX_A64(sl, h, 16, 32, int32)
83
+VFP_CONV_FIX_A64(ul, h, 16, 32, uint32)
84
#undef VFP_CONV_FIX
85
#undef VFP_CONV_FIX_FLOAT
86
#undef VFP_CONV_FLOAT_FIX_ROUND
87
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
88
index XXXXXXX..XXXXXXX 100644
89
--- a/target/arm/translate-a64.c
90
+++ b/target/arm/translate-a64.c
91
@@ -XXX,XX +XXX,XX @@ static void handle_simd_intfp_conv(DisasContext *s, int rd, int rn,
92
int elements, int is_signed,
93
int fracbits, int size)
94
{
95
- bool is_double = size == 3 ? true : false;
96
- TCGv_ptr tcg_fpst = get_fpstatus_ptr(false);
97
- TCGv_i32 tcg_shift = tcg_const_i32(fracbits);
98
- TCGv_i64 tcg_int = tcg_temp_new_i64();
99
+ TCGv_ptr tcg_fpst = get_fpstatus_ptr(size == MO_16);
100
+ TCGv_i32 tcg_shift = NULL;
101
+
26
+
102
TCGMemOp mop = size | (is_signed ? MO_SIGN : 0);
27
+ /*
103
int pass;
28
+ * The Arm ARM says DBGDIDR is optional and deprecated if EL1 cannot
104
29
+ * use AArch32. Given that bit 15 is RES1, if the value is 0 then
105
- for (pass = 0; pass < elements; pass++) {
30
+ * the register must not exist for this cpu.
106
- read_vec_element(s, tcg_int, rn, pass, mop);
31
+ */
107
+ if (fracbits || size == MO_64) {
32
+ if (cpu->isar.dbgdidr != 0) {
108
+ tcg_shift = tcg_const_i32(fracbits);
33
+ ARMCPRegInfo dbgdidr = {
34
+ .name = "DBGDIDR", .cp = 14, .crn = 0, .crm = 0,
35
+ .opc1 = 0, .opc2 = 0,
36
+ .access = PL0_R, .accessfn = access_tda,
37
+ .type = ARM_CP_CONST, .resetvalue = cpu->isar.dbgdidr,
38
+ };
39
+ define_one_arm_cp_reg(cpu, &dbgdidr);
109
+ }
40
+ }
110
+
41
111
+ if (size == MO_64) {
42
/* Note that all these register fields hold "number of Xs minus 1". */
112
+ TCGv_i64 tcg_int64 = tcg_temp_new_i64();
43
brps = arm_num_brps(cpu);
113
+ TCGv_i64 tcg_double = tcg_temp_new_i64();
44
@@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu)
114
+
45
115
+ for (pass = 0; pass < elements; pass++) {
46
assert(ctx_cmps <= brps);
116
+ read_vec_element(s, tcg_int64, rn, pass, mop);
47
117
48
- define_one_arm_cp_reg(cpu, &dbgdidr);
118
- if (is_double) {
49
define_arm_cp_regs(cpu, debug_cp_reginfo);
119
- TCGv_i64 tcg_double = tcg_temp_new_i64();
50
120
if (is_signed) {
51
if (arm_feature(&cpu->env, ARM_FEATURE_LPAE)) {
121
- gen_helper_vfp_sqtod(tcg_double, tcg_int,
122
+ gen_helper_vfp_sqtod(tcg_double, tcg_int64,
123
tcg_shift, tcg_fpst);
124
} else {
125
- gen_helper_vfp_uqtod(tcg_double, tcg_int,
126
+ gen_helper_vfp_uqtod(tcg_double, tcg_int64,
127
tcg_shift, tcg_fpst);
128
}
129
if (elements == 1) {
130
@@ -XXX,XX +XXX,XX @@ static void handle_simd_intfp_conv(DisasContext *s, int rd, int rn,
131
} else {
132
write_vec_element(s, tcg_double, rd, pass, MO_64);
133
}
134
- tcg_temp_free_i64(tcg_double);
135
- } else {
136
- TCGv_i32 tcg_single = tcg_temp_new_i32();
137
- if (is_signed) {
138
- gen_helper_vfp_sqtos(tcg_single, tcg_int,
139
- tcg_shift, tcg_fpst);
140
- } else {
141
- gen_helper_vfp_uqtos(tcg_single, tcg_int,
142
- tcg_shift, tcg_fpst);
143
- }
144
- if (elements == 1) {
145
- write_fp_sreg(s, rd, tcg_single);
146
- } else {
147
- write_vec_element_i32(s, tcg_single, rd, pass, MO_32);
148
- }
149
- tcg_temp_free_i32(tcg_single);
150
}
151
+
152
+ tcg_temp_free_i64(tcg_int64);
153
+ tcg_temp_free_i64(tcg_double);
154
+
155
+ } else {
156
+ TCGv_i32 tcg_int32 = tcg_temp_new_i32();
157
+ TCGv_i32 tcg_float = tcg_temp_new_i32();
158
+
159
+ for (pass = 0; pass < elements; pass++) {
160
+ read_vec_element_i32(s, tcg_int32, rn, pass, mop);
161
+
162
+ switch (size) {
163
+ case MO_32:
164
+ if (fracbits) {
165
+ if (is_signed) {
166
+ gen_helper_vfp_sltos(tcg_float, tcg_int32,
167
+ tcg_shift, tcg_fpst);
168
+ } else {
169
+ gen_helper_vfp_ultos(tcg_float, tcg_int32,
170
+ tcg_shift, tcg_fpst);
171
+ }
172
+ } else {
173
+ if (is_signed) {
174
+ gen_helper_vfp_sitos(tcg_float, tcg_int32, tcg_fpst);
175
+ } else {
176
+ gen_helper_vfp_uitos(tcg_float, tcg_int32, tcg_fpst);
177
+ }
178
+ }
179
+ break;
180
+ case MO_16:
181
+ if (fracbits) {
182
+ if (is_signed) {
183
+ gen_helper_vfp_sltoh(tcg_float, tcg_int32,
184
+ tcg_shift, tcg_fpst);
185
+ } else {
186
+ gen_helper_vfp_ultoh(tcg_float, tcg_int32,
187
+ tcg_shift, tcg_fpst);
188
+ }
189
+ } else {
190
+ if (is_signed) {
191
+ gen_helper_vfp_sitoh(tcg_float, tcg_int32, tcg_fpst);
192
+ } else {
193
+ gen_helper_vfp_uitoh(tcg_float, tcg_int32, tcg_fpst);
194
+ }
195
+ }
196
+ break;
197
+ default:
198
+ g_assert_not_reached();
199
+ }
200
+
201
+ if (elements == 1) {
202
+ write_fp_sreg(s, rd, tcg_float);
203
+ } else {
204
+ write_vec_element_i32(s, tcg_float, rd, pass, size);
205
+ }
206
+ }
207
+
208
+ tcg_temp_free_i32(tcg_int32);
209
+ tcg_temp_free_i32(tcg_float);
210
}
211
212
- tcg_temp_free_i64(tcg_int);
213
tcg_temp_free_ptr(tcg_fpst);
214
- tcg_temp_free_i32(tcg_shift);
215
+ if (tcg_shift) {
216
+ tcg_temp_free_i32(tcg_shift);
217
+ }
218
219
clear_vec_high(s, elements << size == 16, rd);
220
}
221
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
222
rn = extract32(insn, 5, 5);
223
224
switch (fpop) {
225
+ case 0x1d: /* SCVTF */
226
+ case 0x5d: /* UCVTF */
227
+ {
228
+ int elements;
229
+
230
+ if (is_scalar) {
231
+ elements = 1;
232
+ } else {
233
+ elements = (is_q ? 8 : 4);
234
+ }
235
+
236
+ if (!fp_access_check(s)) {
237
+ return;
238
+ }
239
+ handle_simd_intfp_conv(s, rd, rn, elements, !u, 0, MO_16);
240
+ return;
241
+ }
242
break;
243
case 0x2c: /* FCMGT (zero) */
244
case 0x2d: /* FCMEQ (zero) */
245
--
52
--
246
2.16.2
53
2.20.1
247
54
248
55
diff view generated by jsdifflib
1
From: Francisco Iglesias <frasse.iglesias@gmail.com>
1
From: Paolo Bonzini <pbonzini@redhat.com>
2
2
3
Use 8 dummy cycles (4 dummy bytes) with the QIOR/QIOR4 commands in legacy mode
3
The properties to attach a CANBUS object to the xlnx-zcu102 machine have
4
for matching what is expected by Micron (Numonyx) flashes (the default target
4
a period in them. We want to use periods in properties for compound QAPI types,
5
flash type of the QSPI).
5
and besides the "xlnx-zcu102." prefix is both unnecessary and different
6
from any other machine property name. Remove it.
6
7
7
Signed-off-by: Francisco Iglesias <frasse.iglesias@gmail.com>
8
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8
Tested-by: Alistair Francis <alistair.francis@xilinx.com>
9
Message-id: 20210118162537.779542-1-pbonzini@redhat.com
9
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
10
Reviewed-by: Vikram Garhwal <fnu.vikram@xilinx.com>
10
Message-id: 20180223232233.31482-3-frasse.iglesias@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/xilinx_spips.c | 2 +-
13
hw/arm/xlnx-zcu102.c | 4 ++--
14
1 file changed, 1 insertion(+), 1 deletion(-)
14
tests/qtest/xlnx-can-test.c | 30 +++++++++++++++---------------
15
2 files changed, 17 insertions(+), 17 deletions(-)
15
16
16
diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c
17
diff --git a/hw/arm/xlnx-zcu102.c b/hw/arm/xlnx-zcu102.c
17
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/ssi/xilinx_spips.c
19
--- a/hw/arm/xlnx-zcu102.c
19
+++ b/hw/ssi/xilinx_spips.c
20
+++ b/hw/arm/xlnx-zcu102.c
20
@@ -XXX,XX +XXX,XX @@ static int xilinx_spips_num_dummies(XilinxQSPIPS *qs, uint8_t command)
21
@@ -XXX,XX +XXX,XX @@ static void xlnx_zcu102_machine_instance_init(Object *obj)
21
return 2;
22
s->secure = false;
22
case QIOR:
23
/* Default to virt (EL2) being disabled */
23
case QIOR_4:
24
s->virt = false;
24
- return 5;
25
- object_property_add_link(obj, "xlnx-zcu102.canbus0", TYPE_CAN_BUS,
25
+ return 4;
26
+ object_property_add_link(obj, "canbus0", TYPE_CAN_BUS,
26
default:
27
(Object **)&s->canbus[0],
27
return -1;
28
object_property_allow_set_link,
28
}
29
0);
30
31
- object_property_add_link(obj, "xlnx-zcu102.canbus1", TYPE_CAN_BUS,
32
+ object_property_add_link(obj, "canbus1", TYPE_CAN_BUS,
33
(Object **)&s->canbus[1],
34
object_property_allow_set_link,
35
0);
36
diff --git a/tests/qtest/xlnx-can-test.c b/tests/qtest/xlnx-can-test.c
37
index XXXXXXX..XXXXXXX 100644
38
--- a/tests/qtest/xlnx-can-test.c
39
+++ b/tests/qtest/xlnx-can-test.c
40
@@ -XXX,XX +XXX,XX @@ static void test_can_bus(void)
41
uint8_t can_timestamp = 1;
42
43
QTestState *qts = qtest_init("-machine xlnx-zcu102"
44
- " -object can-bus,id=canbus0"
45
- " -machine xlnx-zcu102.canbus0=canbus0"
46
- " -machine xlnx-zcu102.canbus1=canbus0"
47
+ " -object can-bus,id=canbus"
48
+ " -machine canbus0=canbus"
49
+ " -machine canbus1=canbus"
50
);
51
52
/* Configure the CAN0 and CAN1. */
53
@@ -XXX,XX +XXX,XX @@ static void test_can_loopback(void)
54
uint32_t status = 0;
55
56
QTestState *qts = qtest_init("-machine xlnx-zcu102"
57
- " -object can-bus,id=canbus0"
58
- " -machine xlnx-zcu102.canbus0=canbus0"
59
- " -machine xlnx-zcu102.canbus1=canbus0"
60
+ " -object can-bus,id=canbus"
61
+ " -machine canbus0=canbus"
62
+ " -machine canbus1=canbus"
63
);
64
65
/* Configure the CAN0 in loopback mode. */
66
@@ -XXX,XX +XXX,XX @@ static void test_can_filter(void)
67
uint8_t can_timestamp = 1;
68
69
QTestState *qts = qtest_init("-machine xlnx-zcu102"
70
- " -object can-bus,id=canbus0"
71
- " -machine xlnx-zcu102.canbus0=canbus0"
72
- " -machine xlnx-zcu102.canbus1=canbus0"
73
+ " -object can-bus,id=canbus"
74
+ " -machine canbus0=canbus"
75
+ " -machine canbus1=canbus"
76
);
77
78
/* Configure the CAN0 and CAN1. */
79
@@ -XXX,XX +XXX,XX @@ static void test_can_sleepmode(void)
80
uint8_t can_timestamp = 1;
81
82
QTestState *qts = qtest_init("-machine xlnx-zcu102"
83
- " -object can-bus,id=canbus0"
84
- " -machine xlnx-zcu102.canbus0=canbus0"
85
- " -machine xlnx-zcu102.canbus1=canbus0"
86
+ " -object can-bus,id=canbus"
87
+ " -machine canbus0=canbus"
88
+ " -machine canbus1=canbus"
89
);
90
91
/* Configure the CAN0. */
92
@@ -XXX,XX +XXX,XX @@ static void test_can_snoopmode(void)
93
uint8_t can_timestamp = 1;
94
95
QTestState *qts = qtest_init("-machine xlnx-zcu102"
96
- " -object can-bus,id=canbus0"
97
- " -machine xlnx-zcu102.canbus0=canbus0"
98
- " -machine xlnx-zcu102.canbus1=canbus0"
99
+ " -object can-bus,id=canbus"
100
+ " -machine canbus0=canbus"
101
+ " -machine canbus1=canbus"
102
);
103
104
/* Configure the CAN0. */
29
--
105
--
30
2.16.2
106
2.20.1
31
107
32
108
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Maxim Uvarov <maxim.uvarov@linaro.org>
2
2
3
These use the generic float16_compare functionality which in turn uses
3
Implement gpio-pwr driver to allow reboot and poweroff machine.
4
the common float_compare code from the softfloat re-factor.
4
This is simple driver with just 2 gpios lines. Current use case
5
is to reboot and poweroff virt machine in secure mode. Secure
6
pl066 gpio chip is needed for that.
5
7
6
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
8
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Hao Wu <wuhaotsh@google.com>
8
Message-id: 20180227143852.11175-11-alex.bennee@linaro.org
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
12
---
11
target/arm/helper-a64.h | 5 +++++
13
hw/gpio/gpio_pwr.c | 70 +++++++++++++++++++++++++++++++++++++++++++++
12
target/arm/helper-a64.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++
14
hw/gpio/Kconfig | 3 ++
13
target/arm/translate-a64.c | 15 ++++++++++++++
15
hw/gpio/meson.build | 1 +
14
3 files changed, 69 insertions(+)
16
3 files changed, 74 insertions(+)
17
create mode 100644 hw/gpio/gpio_pwr.c
15
18
16
diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h
19
diff --git a/hw/gpio/gpio_pwr.c b/hw/gpio/gpio_pwr.c
17
index XXXXXXX..XXXXXXX 100644
20
new file mode 100644
18
--- a/target/arm/helper-a64.h
21
index XXXXXXX..XXXXXXX
19
+++ b/target/arm/helper-a64.h
22
--- /dev/null
20
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(advsimd_addh, f16, f16, f16, ptr)
23
+++ b/hw/gpio/gpio_pwr.c
21
DEF_HELPER_3(advsimd_subh, f16, f16, f16, ptr)
24
@@ -XXX,XX +XXX,XX @@
22
DEF_HELPER_3(advsimd_mulh, f16, f16, f16, ptr)
25
+/*
23
DEF_HELPER_3(advsimd_divh, f16, f16, f16, ptr)
26
+ * GPIO qemu power controller
24
+DEF_HELPER_3(advsimd_ceq_f16, i32, f16, f16, ptr)
27
+ *
25
+DEF_HELPER_3(advsimd_cge_f16, i32, f16, f16, ptr)
28
+ * Copyright (c) 2020 Linaro Limited
26
+DEF_HELPER_3(advsimd_cgt_f16, i32, f16, f16, ptr)
29
+ *
27
+DEF_HELPER_3(advsimd_acge_f16, i32, f16, f16, ptr)
30
+ * Author: Maxim Uvarov <maxim.uvarov@linaro.org>
28
+DEF_HELPER_3(advsimd_acgt_f16, i32, f16, f16, ptr)
31
+ *
29
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
32
+ * Virtual gpio driver which can be used on top of pl061
30
index XXXXXXX..XXXXXXX 100644
33
+ * to reboot and shutdown qemu virtual machine. One of use
31
--- a/target/arm/helper-a64.c
34
+ * case is gpio driver for secure world application (ARM
32
+++ b/target/arm/helper-a64.c
35
+ * Trusted Firmware.).
33
@@ -XXX,XX +XXX,XX @@ ADVSIMD_HALFOP(min)
36
+ *
34
ADVSIMD_HALFOP(max)
37
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
35
ADVSIMD_HALFOP(minnum)
38
+ * See the COPYING file in the top-level directory.
36
ADVSIMD_HALFOP(maxnum)
39
+ * SPDX-License-Identifier: GPL-2.0-or-later
40
+ */
37
+
41
+
38
+/*
42
+/*
39
+ * Floating point comparisons produce an integer result. Softfloat
43
+ * QEMU interface:
40
+ * routines return float_relation types which we convert to the 0/-1
44
+ * two named input GPIO lines:
41
+ * Neon requires.
45
+ * 'reset' : when asserted, trigger system reset
46
+ * 'shutdown' : when asserted, trigger system shutdown
42
+ */
47
+ */
43
+
48
+
44
+#define ADVSIMD_CMPRES(test) (test) ? 0xffff : 0
49
+#include "qemu/osdep.h"
50
+#include "hw/sysbus.h"
51
+#include "sysemu/runstate.h"
45
+
52
+
46
+uint32_t HELPER(advsimd_ceq_f16)(float16 a, float16 b, void *fpstp)
53
+#define TYPE_GPIOPWR "gpio-pwr"
54
+OBJECT_DECLARE_SIMPLE_TYPE(GPIO_PWR_State, GPIOPWR)
55
+
56
+struct GPIO_PWR_State {
57
+ SysBusDevice parent_obj;
58
+};
59
+
60
+static void gpio_pwr_reset(void *opaque, int n, int level)
47
+{
61
+{
48
+ float_status *fpst = fpstp;
62
+ if (level) {
49
+ int compare = float16_compare_quiet(a, b, fpst);
63
+ qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
50
+ return ADVSIMD_CMPRES(compare == float_relation_equal);
64
+ }
51
+}
65
+}
52
+
66
+
53
+uint32_t HELPER(advsimd_cge_f16)(float16 a, float16 b, void *fpstp)
67
+static void gpio_pwr_shutdown(void *opaque, int n, int level)
54
+{
68
+{
55
+ float_status *fpst = fpstp;
69
+ if (level) {
56
+ int compare = float16_compare(a, b, fpst);
70
+ qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
57
+ return ADVSIMD_CMPRES(compare == float_relation_greater ||
71
+ }
58
+ compare == float_relation_equal);
59
+}
72
+}
60
+
73
+
61
+uint32_t HELPER(advsimd_cgt_f16)(float16 a, float16 b, void *fpstp)
74
+static void gpio_pwr_init(Object *obj)
62
+{
75
+{
63
+ float_status *fpst = fpstp;
76
+ DeviceState *dev = DEVICE(obj);
64
+ int compare = float16_compare(a, b, fpst);
77
+
65
+ return ADVSIMD_CMPRES(compare == float_relation_greater);
78
+ qdev_init_gpio_in_named(dev, gpio_pwr_reset, "reset", 1);
79
+ qdev_init_gpio_in_named(dev, gpio_pwr_shutdown, "shutdown", 1);
66
+}
80
+}
67
+
81
+
68
+uint32_t HELPER(advsimd_acge_f16)(float16 a, float16 b, void *fpstp)
82
+static const TypeInfo gpio_pwr_info = {
83
+ .name = TYPE_GPIOPWR,
84
+ .parent = TYPE_SYS_BUS_DEVICE,
85
+ .instance_size = sizeof(GPIO_PWR_State),
86
+ .instance_init = gpio_pwr_init,
87
+};
88
+
89
+static void gpio_pwr_register_types(void)
69
+{
90
+{
70
+ float_status *fpst = fpstp;
91
+ type_register_static(&gpio_pwr_info);
71
+ float16 f0 = float16_abs(a);
72
+ float16 f1 = float16_abs(b);
73
+ int compare = float16_compare(f0, f1, fpst);
74
+ return ADVSIMD_CMPRES(compare == float_relation_greater ||
75
+ compare == float_relation_equal);
76
+}
92
+}
77
+
93
+
78
+uint32_t HELPER(advsimd_acgt_f16)(float16 a, float16 b, void *fpstp)
94
+type_init(gpio_pwr_register_types)
79
+{
95
diff --git a/hw/gpio/Kconfig b/hw/gpio/Kconfig
80
+ float_status *fpst = fpstp;
81
+ float16 f0 = float16_abs(a);
82
+ float16 f1 = float16_abs(b);
83
+ int compare = float16_compare(f0, f1, fpst);
84
+ return ADVSIMD_CMPRES(compare == float_relation_greater);
85
+}
86
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
87
index XXXXXXX..XXXXXXX 100644
96
index XXXXXXX..XXXXXXX 100644
88
--- a/target/arm/translate-a64.c
97
--- a/hw/gpio/Kconfig
89
+++ b/target/arm/translate-a64.c
98
+++ b/hw/gpio/Kconfig
90
@@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn)
99
@@ -XXX,XX +XXX,XX @@ config PL061
91
case 0x2: /* FADD */
100
config GPIO_KEY
92
gen_helper_advsimd_addh(tcg_res, tcg_op1, tcg_op2, fpst);
101
bool
93
break;
102
94
+ case 0x4: /* FCMEQ */
103
+config GPIO_PWR
95
+ gen_helper_advsimd_ceq_f16(tcg_res, tcg_op1, tcg_op2, fpst);
104
+ bool
96
+ break;
105
+
97
case 0x6: /* FMAX */
106
config SIFIVE_GPIO
98
gen_helper_advsimd_maxh(tcg_res, tcg_op1, tcg_op2, fpst);
107
bool
99
break;
108
diff --git a/hw/gpio/meson.build b/hw/gpio/meson.build
100
@@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn)
109
index XXXXXXX..XXXXXXX 100644
101
case 0x13: /* FMUL */
110
--- a/hw/gpio/meson.build
102
gen_helper_advsimd_mulh(tcg_res, tcg_op1, tcg_op2, fpst);
111
+++ b/hw/gpio/meson.build
103
break;
112
@@ -XXX,XX +XXX,XX @@
104
+ case 0x14: /* FCMGE */
113
softmmu_ss.add(when: 'CONFIG_E500', if_true: files('mpc8xxx.c'))
105
+ gen_helper_advsimd_cge_f16(tcg_res, tcg_op1, tcg_op2, fpst);
114
softmmu_ss.add(when: 'CONFIG_GPIO_KEY', if_true: files('gpio_key.c'))
106
+ break;
115
+softmmu_ss.add(when: 'CONFIG_GPIO_PWR', if_true: files('gpio_pwr.c'))
107
+ case 0x15: /* FACGE */
116
softmmu_ss.add(when: 'CONFIG_MAX7310', if_true: files('max7310.c'))
108
+ gen_helper_advsimd_acge_f16(tcg_res, tcg_op1, tcg_op2, fpst);
117
softmmu_ss.add(when: 'CONFIG_PL061', if_true: files('pl061.c'))
109
+ break;
118
softmmu_ss.add(when: 'CONFIG_PUV3', if_true: files('puv3_gpio.c'))
110
case 0x17: /* FDIV */
111
gen_helper_advsimd_divh(tcg_res, tcg_op1, tcg_op2, fpst);
112
break;
113
@@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn)
114
gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst);
115
tcg_gen_andi_i32(tcg_res, tcg_res, 0x7fff);
116
break;
117
+ case 0x1c: /* FCMGT */
118
+ gen_helper_advsimd_cgt_f16(tcg_res, tcg_op1, tcg_op2, fpst);
119
+ break;
120
+ case 0x1d: /* FACGT */
121
+ gen_helper_advsimd_acgt_f16(tcg_res, tcg_op1, tcg_op2, fpst);
122
+ break;
123
default:
124
fprintf(stderr, "%s: insn %#04x, fpop %#2x @ %#" PRIx64 "\n",
125
__func__, insn, fpopcode, s->pc);
126
--
119
--
127
2.16.2
120
2.20.1
128
121
129
122
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Maxim Uvarov <maxim.uvarov@linaro.org>
2
2
3
This actually covers two different sections of the encoding table:
3
No functional change. Just refactor code to better
4
support secure and normal world gpios.
4
5
5
Advanced SIMD scalar two-register miscellaneous FP16
6
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
6
Advanced SIMD two-register miscellaneous (FP16)
7
Reviewed-by: Andrew Jones <drjones@redhat.com>
7
8
The difference between the two is covered by a combination of Q (bit
9
30) and S (bit 28). Notably the FRINTx instructions are only
10
available in the vector form.
11
12
This is just the decode skeleton which will be filled out by later
13
patches.
14
15
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
17
Message-id: 20180227143852.11175-17-alex.bennee@linaro.org
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
---
9
---
20
target/arm/translate-a64.c | 40 ++++++++++++++++++++++++++++++++++++++++
10
hw/arm/virt.c | 57 ++++++++++++++++++++++++++++++++-------------------
21
1 file changed, 40 insertions(+)
11
1 file changed, 36 insertions(+), 21 deletions(-)
22
12
23
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
13
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
24
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
25
--- a/target/arm/translate-a64.c
15
--- a/hw/arm/virt.c
26
+++ b/target/arm/translate-a64.c
16
+++ b/hw/arm/virt.c
27
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn)
17
@@ -XXX,XX +XXX,XX @@ static void virt_powerdown_req(Notifier *n, void *opaque)
28
}
18
}
29
}
19
}
30
20
31
+/* AdvSIMD [scalar] two register miscellaneous (FP16)
21
-static void create_gpio(const VirtMachineState *vms)
32
+ *
22
+static void create_gpio_keys(const VirtMachineState *vms,
33
+ * 31 30 29 28 27 24 23 22 21 17 16 12 11 10 9 5 4 0
23
+ DeviceState *pl061_dev,
34
+ * +---+---+---+---+---------+---+-------------+--------+-----+------+------+
24
+ uint32_t phandle)
35
+ * | 0 | Q | U | S | 1 1 1 0 | a | 1 1 1 1 0 0 | opcode | 1 0 | Rn | Rd |
36
+ * +---+---+---+---+---------+---+-------------+--------+-----+------+------+
37
+ * mask: 1000 1111 0111 1110 0000 1100 0000 0000 0x8f7e 0c00
38
+ * val: 0000 1110 0111 1000 0000 1000 0000 0000 0x0e78 0800
39
+ *
40
+ * This actually covers two groups where scalar access is governed by
41
+ * bit 28. A bunch of the instructions (float to integral) only exist
42
+ * in the vector form and are un-allocated for the scalar decode. Also
43
+ * in the scalar decode Q is always 1.
44
+ */
45
+static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
46
+{
25
+{
47
+ int fpop, opcode, a;
26
+ gpio_key_dev = sysbus_create_simple("gpio-key", -1,
27
+ qdev_get_gpio_in(pl061_dev, 3));
48
+
28
+
49
+ if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
29
+ qemu_fdt_add_subnode(vms->fdt, "/gpio-keys");
50
+ unallocated_encoding(s);
30
+ qemu_fdt_setprop_string(vms->fdt, "/gpio-keys", "compatible", "gpio-keys");
51
+ return;
31
+ qemu_fdt_setprop_cell(vms->fdt, "/gpio-keys", "#size-cells", 0);
52
+ }
32
+ qemu_fdt_setprop_cell(vms->fdt, "/gpio-keys", "#address-cells", 1);
53
+
33
+
54
+ if (!fp_access_check(s)) {
34
+ qemu_fdt_add_subnode(vms->fdt, "/gpio-keys/poweroff");
55
+ return;
35
+ qemu_fdt_setprop_string(vms->fdt, "/gpio-keys/poweroff",
56
+ }
36
+ "label", "GPIO Key Poweroff");
57
+
37
+ qemu_fdt_setprop_cell(vms->fdt, "/gpio-keys/poweroff", "linux,code",
58
+ opcode = extract32(insn, 12, 4);
38
+ KEY_POWER);
59
+ a = extract32(insn, 23, 1);
39
+ qemu_fdt_setprop_cells(vms->fdt, "/gpio-keys/poweroff",
60
+ fpop = deposit32(opcode, 5, 1, a);
40
+ "gpios", phandle, 3, 0);
61
+
62
+ switch (fpop) {
63
+ default:
64
+ fprintf(stderr, "%s: insn %#04x fpop %#2x\n", __func__, insn, fpop);
65
+ g_assert_not_reached();
66
+ }
67
+
68
+}
41
+}
69
+
42
+
70
/* AdvSIMD scalar x indexed element
43
+static void create_gpio_devices(const VirtMachineState *vms, int gpio,
71
* 31 30 29 28 24 23 22 21 20 19 16 15 12 11 10 9 5 4 0
44
+ MemoryRegion *mem)
72
* +-----+---+-----------+------+---+---+------+-----+---+---+------+------+
45
{
73
@@ -XXX,XX +XXX,XX @@ static const AArch64DecodeTable data_proc_simd[] = {
46
char *nodename;
74
{ 0xce800000, 0xffe00000, disas_crypto_xar },
47
DeviceState *pl061_dev;
75
{ 0xce408000, 0xffe0c000, disas_crypto_three_reg_imm2 },
48
- hwaddr base = vms->memmap[VIRT_GPIO].base;
76
{ 0x0e400400, 0x9f60c400, disas_simd_three_reg_same_fp16 },
49
- hwaddr size = vms->memmap[VIRT_GPIO].size;
77
+ { 0x0e780800, 0x8f7e0c00, disas_simd_two_reg_misc_fp16 },
50
- int irq = vms->irqmap[VIRT_GPIO];
78
{ 0x00000000, 0x00000000, NULL }
51
+ hwaddr base = vms->memmap[gpio].base;
79
};
52
+ hwaddr size = vms->memmap[gpio].size;
80
53
+ int irq = vms->irqmap[gpio];
54
const char compat[] = "arm,pl061\0arm,primecell";
55
+ SysBusDevice *s;
56
57
- pl061_dev = sysbus_create_simple("pl061", base,
58
- qdev_get_gpio_in(vms->gic, irq));
59
+ pl061_dev = qdev_new("pl061");
60
+ s = SYS_BUS_DEVICE(pl061_dev);
61
+ sysbus_realize_and_unref(s, &error_fatal);
62
+ memory_region_add_subregion(mem, base, sysbus_mmio_get_region(s, 0));
63
+ sysbus_connect_irq(s, 0, qdev_get_gpio_in(vms->gic, irq));
64
65
uint32_t phandle = qemu_fdt_alloc_phandle(vms->fdt);
66
nodename = g_strdup_printf("/pl061@%" PRIx64, base);
67
@@ -XXX,XX +XXX,XX @@ static void create_gpio(const VirtMachineState *vms)
68
qemu_fdt_setprop_string(vms->fdt, nodename, "clock-names", "apb_pclk");
69
qemu_fdt_setprop_cell(vms->fdt, nodename, "phandle", phandle);
70
71
- gpio_key_dev = sysbus_create_simple("gpio-key", -1,
72
- qdev_get_gpio_in(pl061_dev, 3));
73
- qemu_fdt_add_subnode(vms->fdt, "/gpio-keys");
74
- qemu_fdt_setprop_string(vms->fdt, "/gpio-keys", "compatible", "gpio-keys");
75
- qemu_fdt_setprop_cell(vms->fdt, "/gpio-keys", "#size-cells", 0);
76
- qemu_fdt_setprop_cell(vms->fdt, "/gpio-keys", "#address-cells", 1);
77
-
78
- qemu_fdt_add_subnode(vms->fdt, "/gpio-keys/poweroff");
79
- qemu_fdt_setprop_string(vms->fdt, "/gpio-keys/poweroff",
80
- "label", "GPIO Key Poweroff");
81
- qemu_fdt_setprop_cell(vms->fdt, "/gpio-keys/poweroff", "linux,code",
82
- KEY_POWER);
83
- qemu_fdt_setprop_cells(vms->fdt, "/gpio-keys/poweroff",
84
- "gpios", phandle, 3, 0);
85
g_free(nodename);
86
+
87
+ /* Child gpio devices */
88
+ create_gpio_keys(vms, pl061_dev, phandle);
89
}
90
91
static void create_virtio_devices(const VirtMachineState *vms)
92
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
93
if (has_ged && aarch64 && firmware_loaded && virt_is_acpi_enabled(vms)) {
94
vms->acpi_dev = create_acpi_ged(vms);
95
} else {
96
- create_gpio(vms);
97
+ create_gpio_devices(vms, VIRT_GPIO, sysmem);
98
}
99
100
/* connect powerdown request */
81
--
101
--
82
2.16.2
102
2.20.1
83
103
84
104
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Maxim Uvarov <maxim.uvarov@linaro.org>
2
2
3
As some of the constants here will also be needed
3
Add secure pl061 for reset/power down machine from
4
elsewhere (specifically for the upcoming SVE support) we move them out
4
the secure world (Arm Trusted Firmware). Connect it
5
to softfloat.h.
5
with gpio-pwr driver.
6
6
7
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Andrew Jones <drjones@redhat.com>
9
Message-id: 20180227143852.11175-13-alex.bennee@linaro.org
9
[PMM: Added mention of the new device to the documentation]
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
11
---
12
include/fpu/softfloat.h | 18 +++++++++++++-----
12
docs/system/arm/virt.rst | 2 ++
13
target/arm/helper-a64.h | 2 ++
13
include/hw/arm/virt.h | 2 ++
14
target/arm/helper-a64.c | 34 ++++++++++++++++++++++++++++++++++
14
hw/arm/virt.c | 56 +++++++++++++++++++++++++++++++++++++++-
15
target/arm/translate-a64.c | 6 ++++++
15
hw/arm/Kconfig | 1 +
16
4 files changed, 55 insertions(+), 5 deletions(-)
16
4 files changed, 60 insertions(+), 1 deletion(-)
17
17
18
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
18
diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst
19
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
20
--- a/include/fpu/softfloat.h
20
--- a/docs/system/arm/virt.rst
21
+++ b/include/fpu/softfloat.h
21
+++ b/docs/system/arm/virt.rst
22
@@ -XXX,XX +XXX,XX @@ static inline float16 float16_set_sign(float16 a, int sign)
22
@@ -XXX,XX +XXX,XX @@ The virt board supports:
23
- Secure-World-only devices if the CPU has TrustZone:
24
25
- A second PL011 UART
26
+ - A second PL061 GPIO controller, with GPIO lines for triggering
27
+ a system reset or system poweroff
28
- A secure flash memory
29
- 16MB of secure RAM
30
31
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
32
index XXXXXXX..XXXXXXX 100644
33
--- a/include/hw/arm/virt.h
34
+++ b/include/hw/arm/virt.h
35
@@ -XXX,XX +XXX,XX @@ enum {
36
VIRT_GPIO,
37
VIRT_SECURE_UART,
38
VIRT_SECURE_MEM,
39
+ VIRT_SECURE_GPIO,
40
VIRT_PCDIMM_ACPI,
41
VIRT_ACPI_GED,
42
VIRT_NVDIMM_ACPI,
43
@@ -XXX,XX +XXX,XX @@ struct VirtMachineClass {
44
bool kvm_no_adjvtime;
45
bool no_kvm_steal_time;
46
bool acpi_expose_flash;
47
+ bool no_secure_gpio;
48
};
49
50
struct VirtMachineState {
51
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
52
index XXXXXXX..XXXXXXX 100644
53
--- a/hw/arm/virt.c
54
+++ b/hw/arm/virt.c
55
@@ -XXX,XX +XXX,XX @@ static const MemMapEntry base_memmap[] = {
56
[VIRT_ACPI_GED] = { 0x09080000, ACPI_GED_EVT_SEL_LEN },
57
[VIRT_NVDIMM_ACPI] = { 0x09090000, NVDIMM_ACPI_IO_LEN},
58
[VIRT_PVTIME] = { 0x090a0000, 0x00010000 },
59
+ [VIRT_SECURE_GPIO] = { 0x090b0000, 0x00001000 },
60
[VIRT_MMIO] = { 0x0a000000, 0x00000200 },
61
/* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */
62
[VIRT_PLATFORM_BUS] = { 0x0c000000, 0x02000000 },
63
@@ -XXX,XX +XXX,XX @@ static void create_gpio_keys(const VirtMachineState *vms,
64
"gpios", phandle, 3, 0);
23
}
65
}
24
66
25
#define float16_zero make_float16(0)
67
+#define SECURE_GPIO_POWEROFF 0
26
-#define float16_one make_float16(0x3c00)
68
+#define SECURE_GPIO_RESET 1
27
#define float16_half make_float16(0x3800)
28
+#define float16_one make_float16(0x3c00)
29
+#define float16_one_point_five make_float16(0x3e00)
30
+#define float16_two make_float16(0x4000)
31
+#define float16_three make_float16(0x4200)
32
#define float16_infinity make_float16(0x7c00)
33
34
/*----------------------------------------------------------------------------
35
@@ -XXX,XX +XXX,XX @@ static inline float32 float32_set_sign(float32 a, int sign)
36
}
37
38
#define float32_zero make_float32(0)
39
-#define float32_one make_float32(0x3f800000)
40
#define float32_half make_float32(0x3f000000)
41
+#define float32_one make_float32(0x3f800000)
42
+#define float32_one_point_five make_float32(0x3fc00000)
43
+#define float32_two make_float32(0x40000000)
44
+#define float32_three make_float32(0x40400000)
45
#define float32_infinity make_float32(0x7f800000)
46
47
-
48
/*----------------------------------------------------------------------------
49
| The pattern for a default generated single-precision NaN.
50
*----------------------------------------------------------------------------*/
51
@@ -XXX,XX +XXX,XX @@ static inline float64 float64_set_sign(float64 a, int sign)
52
}
53
54
#define float64_zero make_float64(0)
55
-#define float64_one make_float64(0x3ff0000000000000LL)
56
-#define float64_ln2 make_float64(0x3fe62e42fefa39efLL)
57
#define float64_half make_float64(0x3fe0000000000000LL)
58
+#define float64_one make_float64(0x3ff0000000000000LL)
59
+#define float64_one_point_five make_float64(0x3FF8000000000000ULL)
60
+#define float64_two make_float64(0x4000000000000000ULL)
61
+#define float64_three make_float64(0x4008000000000000ULL)
62
+#define float64_ln2 make_float64(0x3fe62e42fefa39efLL)
63
#define float64_infinity make_float64(0x7ff0000000000000LL)
64
65
/*----------------------------------------------------------------------------
66
diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h
67
index XXXXXXX..XXXXXXX 100644
68
--- a/target/arm/helper-a64.h
69
+++ b/target/arm/helper-a64.h
70
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(vfp_mulxd, TCG_CALL_NO_RWG, f64, f64, f64, ptr)
71
DEF_HELPER_FLAGS_3(neon_ceq_f64, TCG_CALL_NO_RWG, i64, i64, i64, ptr)
72
DEF_HELPER_FLAGS_3(neon_cge_f64, TCG_CALL_NO_RWG, i64, i64, i64, ptr)
73
DEF_HELPER_FLAGS_3(neon_cgt_f64, TCG_CALL_NO_RWG, i64, i64, i64, ptr)
74
+DEF_HELPER_FLAGS_3(recpsf_f16, TCG_CALL_NO_RWG, f16, f16, f16, ptr)
75
DEF_HELPER_FLAGS_3(recpsf_f32, TCG_CALL_NO_RWG, f32, f32, f32, ptr)
76
DEF_HELPER_FLAGS_3(recpsf_f64, TCG_CALL_NO_RWG, f64, f64, f64, ptr)
77
+DEF_HELPER_FLAGS_3(rsqrtsf_f16, TCG_CALL_NO_RWG, f16, f16, f16, ptr)
78
DEF_HELPER_FLAGS_3(rsqrtsf_f32, TCG_CALL_NO_RWG, f32, f32, f32, ptr)
79
DEF_HELPER_FLAGS_3(rsqrtsf_f64, TCG_CALL_NO_RWG, f64, f64, f64, ptr)
80
DEF_HELPER_FLAGS_1(neon_addlp_s8, TCG_CALL_NO_RWG_SE, i64, i64)
81
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
82
index XXXXXXX..XXXXXXX 100644
83
--- a/target/arm/helper-a64.c
84
+++ b/target/arm/helper-a64.c
85
@@ -XXX,XX +XXX,XX @@ uint64_t HELPER(neon_cgt_f64)(float64 a, float64 b, void *fpstp)
86
* versions, these do a fully fused multiply-add or
87
* multiply-add-and-halve.
88
*/
89
+#define float16_two make_float16(0x4000)
90
+#define float16_three make_float16(0x4200)
91
+#define float16_one_point_five make_float16(0x3e00)
92
+
69
+
93
#define float32_two make_float32(0x40000000)
70
+static void create_secure_gpio_pwr(const VirtMachineState *vms,
94
#define float32_three make_float32(0x40400000)
71
+ DeviceState *pl061_dev,
95
#define float32_one_point_five make_float32(0x3fc00000)
72
+ uint32_t phandle)
96
@@ -XXX,XX +XXX,XX @@ uint64_t HELPER(neon_cgt_f64)(float64 a, float64 b, void *fpstp)
97
#define float64_three make_float64(0x4008000000000000ULL)
98
#define float64_one_point_five make_float64(0x3FF8000000000000ULL)
99
100
+float16 HELPER(recpsf_f16)(float16 a, float16 b, void *fpstp)
101
+{
73
+{
102
+ float_status *fpst = fpstp;
74
+ DeviceState *gpio_pwr_dev;
103
+
75
+
104
+ a = float16_squash_input_denormal(a, fpst);
76
+ /* gpio-pwr */
105
+ b = float16_squash_input_denormal(b, fpst);
77
+ gpio_pwr_dev = sysbus_create_simple("gpio-pwr", -1, NULL);
106
+
78
+
107
+ a = float16_chs(a);
79
+ /* connect secure pl061 to gpio-pwr */
108
+ if ((float16_is_infinity(a) && float16_is_zero(b)) ||
80
+ qdev_connect_gpio_out(pl061_dev, SECURE_GPIO_RESET,
109
+ (float16_is_infinity(b) && float16_is_zero(a))) {
81
+ qdev_get_gpio_in_named(gpio_pwr_dev, "reset", 0));
110
+ return float16_two;
82
+ qdev_connect_gpio_out(pl061_dev, SECURE_GPIO_POWEROFF,
111
+ }
83
+ qdev_get_gpio_in_named(gpio_pwr_dev, "shutdown", 0));
112
+ return float16_muladd(a, b, float16_two, 0, fpst);
84
+
85
+ qemu_fdt_add_subnode(vms->fdt, "/gpio-poweroff");
86
+ qemu_fdt_setprop_string(vms->fdt, "/gpio-poweroff", "compatible",
87
+ "gpio-poweroff");
88
+ qemu_fdt_setprop_cells(vms->fdt, "/gpio-poweroff",
89
+ "gpios", phandle, SECURE_GPIO_POWEROFF, 0);
90
+ qemu_fdt_setprop_string(vms->fdt, "/gpio-poweroff", "status", "disabled");
91
+ qemu_fdt_setprop_string(vms->fdt, "/gpio-poweroff", "secure-status",
92
+ "okay");
93
+
94
+ qemu_fdt_add_subnode(vms->fdt, "/gpio-restart");
95
+ qemu_fdt_setprop_string(vms->fdt, "/gpio-restart", "compatible",
96
+ "gpio-restart");
97
+ qemu_fdt_setprop_cells(vms->fdt, "/gpio-restart",
98
+ "gpios", phandle, SECURE_GPIO_RESET, 0);
99
+ qemu_fdt_setprop_string(vms->fdt, "/gpio-restart", "status", "disabled");
100
+ qemu_fdt_setprop_string(vms->fdt, "/gpio-restart", "secure-status",
101
+ "okay");
113
+}
102
+}
114
+
103
+
115
float32 HELPER(recpsf_f32)(float32 a, float32 b, void *fpstp)
104
static void create_gpio_devices(const VirtMachineState *vms, int gpio,
105
MemoryRegion *mem)
116
{
106
{
117
float_status *fpst = fpstp;
107
@@ -XXX,XX +XXX,XX @@ static void create_gpio_devices(const VirtMachineState *vms, int gpio,
118
@@ -XXX,XX +XXX,XX @@ float64 HELPER(recpsf_f64)(float64 a, float64 b, void *fpstp)
108
qemu_fdt_setprop_string(vms->fdt, nodename, "clock-names", "apb_pclk");
119
return float64_muladd(a, b, float64_two, 0, fpst);
109
qemu_fdt_setprop_cell(vms->fdt, nodename, "phandle", phandle);
110
111
+ if (gpio != VIRT_GPIO) {
112
+ /* Mark as not usable by the normal world */
113
+ qemu_fdt_setprop_string(vms->fdt, nodename, "status", "disabled");
114
+ qemu_fdt_setprop_string(vms->fdt, nodename, "secure-status", "okay");
115
+ }
116
g_free(nodename);
117
118
/* Child gpio devices */
119
- create_gpio_keys(vms, pl061_dev, phandle);
120
+ if (gpio == VIRT_GPIO) {
121
+ create_gpio_keys(vms, pl061_dev, phandle);
122
+ } else {
123
+ create_secure_gpio_pwr(vms, pl061_dev, phandle);
124
+ }
120
}
125
}
121
126
122
+float16 HELPER(rsqrtsf_f16)(float16 a, float16 b, void *fpstp)
127
static void create_virtio_devices(const VirtMachineState *vms)
123
+{
128
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
124
+ float_status *fpst = fpstp;
129
create_gpio_devices(vms, VIRT_GPIO, sysmem);
130
}
131
132
+ if (vms->secure && !vmc->no_secure_gpio) {
133
+ create_gpio_devices(vms, VIRT_SECURE_GPIO, secure_sysmem);
134
+ }
125
+
135
+
126
+ a = float16_squash_input_denormal(a, fpst);
136
/* connect powerdown request */
127
+ b = float16_squash_input_denormal(b, fpst);
137
vms->powerdown_notifier.notify = virt_powerdown_req;
138
qemu_register_powerdown_notifier(&vms->powerdown_notifier);
139
@@ -XXX,XX +XXX,XX @@ DEFINE_VIRT_MACHINE_AS_LATEST(6, 0)
140
141
static void virt_machine_5_2_options(MachineClass *mc)
142
{
143
+ VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
128
+
144
+
129
+ a = float16_chs(a);
145
virt_machine_6_0_options(mc);
130
+ if ((float16_is_infinity(a) && float16_is_zero(b)) ||
146
compat_props_add(mc->compat_props, hw_compat_5_2, hw_compat_5_2_len);
131
+ (float16_is_infinity(b) && float16_is_zero(a))) {
147
+ vmc->no_secure_gpio = true;
132
+ return float16_one_point_five;
148
}
133
+ }
149
DEFINE_VIRT_MACHINE(5, 2)
134
+ return float16_muladd(a, b, float16_three, float_muladd_halve_result, fpst);
150
135
+}
151
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
136
+
137
float32 HELPER(rsqrtsf_f32)(float32 a, float32 b, void *fpstp)
138
{
139
float_status *fpst = fpstp;
140
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
141
index XXXXXXX..XXXXXXX 100644
152
index XXXXXXX..XXXXXXX 100644
142
--- a/target/arm/translate-a64.c
153
--- a/hw/arm/Kconfig
143
+++ b/target/arm/translate-a64.c
154
+++ b/hw/arm/Kconfig
144
@@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn)
155
@@ -XXX,XX +XXX,XX @@ config ARM_VIRT
145
case 0x6: /* FMAX */
156
select PL011 # UART
146
gen_helper_advsimd_maxh(tcg_res, tcg_op1, tcg_op2, fpst);
157
select PL031 # RTC
147
break;
158
select PL061 # GPIO
148
+ case 0x7: /* FRECPS */
159
+ select GPIO_PWR
149
+ gen_helper_recpsf_f16(tcg_res, tcg_op1, tcg_op2, fpst);
160
select PLATFORM_BUS
150
+ break;
161
select SMBIOS
151
case 0x8: /* FMINNM */
162
select VIRTIO_MMIO
152
gen_helper_advsimd_minnumh(tcg_res, tcg_op1, tcg_op2, fpst);
153
break;
154
@@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn)
155
case 0xe: /* FMIN */
156
gen_helper_advsimd_minh(tcg_res, tcg_op1, tcg_op2, fpst);
157
break;
158
+ case 0xf: /* FRSQRTS */
159
+ gen_helper_rsqrtsf_f16(tcg_res, tcg_op1, tcg_op2, fpst);
160
+ break;
161
case 0x13: /* FMUL */
162
gen_helper_advsimd_mulh(tcg_res, tcg_op1, tcg_op2, fpst);
163
break;
164
--
163
--
165
2.16.2
164
2.20.1
166
165
167
166
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Hao Wu <wuhaotsh@google.com>
2
2
3
I only needed to do a little light re-factoring to support the
3
Fix potential overflow problem when calculating pwm_duty.
4
half-precision helpers.
4
1. Ensure p->cmr and p->cnr to be from [0,65535], according to the
5
hardware specification.
6
2. Changed duty to uint32_t. However, since MAX_DUTY * (p->cmr+1)
7
can excceed UINT32_MAX, we convert them to uint64_t in computation
8
and converted them back to uint32_t.
9
(duty is guaranteed to be <= MAX_DUTY so it won't overflow.)
5
10
6
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
11
Fixes: CID 1442342
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20180227143852.11175-30-alex.bennee@linaro.org
13
Reviewed-by: Doug Evans <dje@google.com>
14
Signed-off-by: Hao Wu <wuhaotsh@google.com>
15
Message-id: 20210127011142.2122790-1-wuhaotsh@google.com
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
18
---
11
target/arm/translate-a64.c | 80 +++++++++++++++++++++++++++++++---------------
19
hw/misc/npcm7xx_pwm.c | 23 +++++++++++++++++++----
12
1 file changed, 54 insertions(+), 26 deletions(-)
20
tests/qtest/npcm7xx_pwm-test.c | 4 ++--
21
2 files changed, 21 insertions(+), 6 deletions(-)
13
22
14
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
23
diff --git a/hw/misc/npcm7xx_pwm.c b/hw/misc/npcm7xx_pwm.c
15
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/translate-a64.c
25
--- a/hw/misc/npcm7xx_pwm.c
17
+++ b/target/arm/translate-a64.c
26
+++ b/hw/misc/npcm7xx_pwm.c
18
@@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_pairwise(DisasContext *s, uint32_t insn)
27
@@ -XXX,XX +XXX,XX @@ REG32(NPCM7XX_PWM_PWDR3, 0x50);
19
case 0xf: /* FMAXP */
28
#define NPCM7XX_CH_INV BIT(2)
20
case 0x2c: /* FMINNMP */
29
#define NPCM7XX_CH_MOD BIT(3)
21
case 0x2f: /* FMINP */
30
22
- /* FP op, size[0] is 32 or 64 bit */
31
+#define NPCM7XX_MAX_CMR 65535
23
+ /* FP op, size[0] is 32 or 64 bit*/
32
+#define NPCM7XX_MAX_CNR 65535
24
if (!u) {
33
+
25
- unallocated_encoding(s);
34
/* Offset of each PWM channel's prescaler in the PPR register. */
26
- return;
35
static const int npcm7xx_ppr_base[] = { 0, 0, 8, 8 };
27
+ if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
36
/* Offset of each PWM channel's clock selector in the CSR register. */
28
+ unallocated_encoding(s);
37
@@ -XXX,XX +XXX,XX @@ static uint32_t npcm7xx_pwm_calculate_freq(NPCM7xxPWM *p)
29
+ return;
38
30
+ } else {
39
static uint32_t npcm7xx_pwm_calculate_duty(NPCM7xxPWM *p)
31
+ size = MO_16;
40
{
32
+ }
41
- uint64_t duty;
42
+ uint32_t duty;
43
44
if (p->running) {
45
if (p->cnr == 0) {
46
@@ -XXX,XX +XXX,XX @@ static uint32_t npcm7xx_pwm_calculate_duty(NPCM7xxPWM *p)
47
} else if (p->cmr >= p->cnr) {
48
duty = NPCM7XX_PWM_MAX_DUTY;
49
} else {
50
- duty = NPCM7XX_PWM_MAX_DUTY * (p->cmr + 1) / (p->cnr + 1);
51
+ duty = (uint64_t)NPCM7XX_PWM_MAX_DUTY * (p->cmr + 1) / (p->cnr + 1);
52
}
53
} else {
54
duty = 0;
55
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_pwm_write(void *opaque, hwaddr offset,
56
case A_NPCM7XX_PWM_CNR2:
57
case A_NPCM7XX_PWM_CNR3:
58
p = &s->pwm[npcm7xx_cnr_index(offset)];
59
- p->cnr = value;
60
+ if (value > NPCM7XX_MAX_CNR) {
61
+ qemu_log_mask(LOG_GUEST_ERROR,
62
+ "%s: invalid cnr value: %u", __func__, value);
63
+ p->cnr = NPCM7XX_MAX_CNR;
33
+ } else {
64
+ } else {
34
+ size = extract32(size, 0, 1) ? MO_64 : MO_32;
65
+ p->cnr = value;
35
}
66
+ }
36
+
67
npcm7xx_pwm_update_output(p);
37
if (!fp_access_check(s)) {
38
return;
39
}
40
41
- size = extract32(size, 0, 1) ? 3 : 2;
42
- fpst = get_fpstatus_ptr(false);
43
+ fpst = get_fpstatus_ptr(size == MO_16);
44
break;
68
break;
45
default:
69
46
unallocated_encoding(s);
70
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_pwm_write(void *opaque, hwaddr offset,
47
return;
71
case A_NPCM7XX_PWM_CMR2:
72
case A_NPCM7XX_PWM_CMR3:
73
p = &s->pwm[npcm7xx_cmr_index(offset)];
74
- p->cmr = value;
75
+ if (value > NPCM7XX_MAX_CMR) {
76
+ qemu_log_mask(LOG_GUEST_ERROR,
77
+ "%s: invalid cmr value: %u", __func__, value);
78
+ p->cmr = NPCM7XX_MAX_CMR;
79
+ } else {
80
+ p->cmr = value;
81
+ }
82
npcm7xx_pwm_update_output(p);
83
break;
84
85
diff --git a/tests/qtest/npcm7xx_pwm-test.c b/tests/qtest/npcm7xx_pwm-test.c
86
index XXXXXXX..XXXXXXX 100644
87
--- a/tests/qtest/npcm7xx_pwm-test.c
88
+++ b/tests/qtest/npcm7xx_pwm-test.c
89
@@ -XXX,XX +XXX,XX @@ static uint64_t pwm_compute_freq(QTestState *qts, uint32_t ppr, uint32_t csr,
90
91
static uint64_t pwm_compute_duty(uint32_t cnr, uint32_t cmr, bool inverted)
92
{
93
- uint64_t duty;
94
+ uint32_t duty;
95
96
if (cnr == 0) {
97
/* PWM is stopped. */
98
@@ -XXX,XX +XXX,XX @@ static uint64_t pwm_compute_duty(uint32_t cnr, uint32_t cmr, bool inverted)
99
} else if (cmr >= cnr) {
100
duty = MAX_DUTY;
101
} else {
102
- duty = MAX_DUTY * (cmr + 1) / (cnr + 1);
103
+ duty = (uint64_t)MAX_DUTY * (cmr + 1) / (cnr + 1);
48
}
104
}
49
105
50
- if (size == 3) {
106
if (inverted) {
51
+ if (size == MO_64) {
52
TCGv_i64 tcg_op1 = tcg_temp_new_i64();
53
TCGv_i64 tcg_op2 = tcg_temp_new_i64();
54
TCGv_i64 tcg_res = tcg_temp_new_i64();
55
@@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_pairwise(DisasContext *s, uint32_t insn)
56
TCGv_i32 tcg_op2 = tcg_temp_new_i32();
57
TCGv_i32 tcg_res = tcg_temp_new_i32();
58
59
- read_vec_element_i32(s, tcg_op1, rn, 0, MO_32);
60
- read_vec_element_i32(s, tcg_op2, rn, 1, MO_32);
61
+ read_vec_element_i32(s, tcg_op1, rn, 0, size);
62
+ read_vec_element_i32(s, tcg_op2, rn, 1, size);
63
64
- switch (opcode) {
65
- case 0xc: /* FMAXNMP */
66
- gen_helper_vfp_maxnums(tcg_res, tcg_op1, tcg_op2, fpst);
67
- break;
68
- case 0xd: /* FADDP */
69
- gen_helper_vfp_adds(tcg_res, tcg_op1, tcg_op2, fpst);
70
- break;
71
- case 0xf: /* FMAXP */
72
- gen_helper_vfp_maxs(tcg_res, tcg_op1, tcg_op2, fpst);
73
- break;
74
- case 0x2c: /* FMINNMP */
75
- gen_helper_vfp_minnums(tcg_res, tcg_op1, tcg_op2, fpst);
76
- break;
77
- case 0x2f: /* FMINP */
78
- gen_helper_vfp_mins(tcg_res, tcg_op1, tcg_op2, fpst);
79
- break;
80
- default:
81
- g_assert_not_reached();
82
+ if (size == MO_16) {
83
+ switch (opcode) {
84
+ case 0xc: /* FMAXNMP */
85
+ gen_helper_advsimd_maxnumh(tcg_res, tcg_op1, tcg_op2, fpst);
86
+ break;
87
+ case 0xd: /* FADDP */
88
+ gen_helper_advsimd_addh(tcg_res, tcg_op1, tcg_op2, fpst);
89
+ break;
90
+ case 0xf: /* FMAXP */
91
+ gen_helper_advsimd_maxh(tcg_res, tcg_op1, tcg_op2, fpst);
92
+ break;
93
+ case 0x2c: /* FMINNMP */
94
+ gen_helper_advsimd_minnumh(tcg_res, tcg_op1, tcg_op2, fpst);
95
+ break;
96
+ case 0x2f: /* FMINP */
97
+ gen_helper_advsimd_minh(tcg_res, tcg_op1, tcg_op2, fpst);
98
+ break;
99
+ default:
100
+ g_assert_not_reached();
101
+ }
102
+ } else {
103
+ switch (opcode) {
104
+ case 0xc: /* FMAXNMP */
105
+ gen_helper_vfp_maxnums(tcg_res, tcg_op1, tcg_op2, fpst);
106
+ break;
107
+ case 0xd: /* FADDP */
108
+ gen_helper_vfp_adds(tcg_res, tcg_op1, tcg_op2, fpst);
109
+ break;
110
+ case 0xf: /* FMAXP */
111
+ gen_helper_vfp_maxs(tcg_res, tcg_op1, tcg_op2, fpst);
112
+ break;
113
+ case 0x2c: /* FMINNMP */
114
+ gen_helper_vfp_minnums(tcg_res, tcg_op1, tcg_op2, fpst);
115
+ break;
116
+ case 0x2f: /* FMINP */
117
+ gen_helper_vfp_mins(tcg_res, tcg_op1, tcg_op2, fpst);
118
+ break;
119
+ default:
120
+ g_assert_not_reached();
121
+ }
122
}
123
124
write_fp_sreg(s, rd, tcg_res);
125
--
107
--
126
2.16.2
108
2.20.1
127
109
128
110
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
As the rounding mode is now split between FP16 and the rest of
3
cpu_get_phys_page_debug() uses 'DATA LOAD' MMU access type.
4
floating point we need to be explicit when tweaking it. Instead of
5
passing the CPU env we now pass the appropriate fpst pointer directly.
6
4
7
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
5
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20210127232822.3530782-1-f4bug@amsat.org
9
Message-id: 20180227143852.11175-6-alex.bennee@linaro.org
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
9
---
12
target/arm/helper.h | 2 +-
10
target/arm/helper.c | 2 +-
13
target/arm/helper.c | 4 ++--
11
1 file changed, 1 insertion(+), 1 deletion(-)
14
target/arm/translate-a64.c | 26 +++++++++++++-------------
15
target/arm/translate.c | 12 ++++++------
16
4 files changed, 22 insertions(+), 22 deletions(-)
17
12
18
diff --git a/target/arm/helper.h b/target/arm/helper.h
19
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/helper.h
21
+++ b/target/arm/helper.h
22
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(vfp_uhtod, f64, i64, i32, ptr)
23
DEF_HELPER_3(vfp_ultod, f64, i64, i32, ptr)
24
DEF_HELPER_3(vfp_uqtod, f64, i64, i32, ptr)
25
26
-DEF_HELPER_FLAGS_2(set_rmode, TCG_CALL_NO_RWG, i32, i32, env)
27
+DEF_HELPER_FLAGS_2(set_rmode, TCG_CALL_NO_RWG, i32, i32, ptr)
28
DEF_HELPER_FLAGS_2(set_neon_rmode, TCG_CALL_NO_RWG, i32, i32, env)
29
30
DEF_HELPER_2(vfp_fcvt_f16_to_f32, f32, i32, env)
31
diff --git a/target/arm/helper.c b/target/arm/helper.c
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
32
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
33
--- a/target/arm/helper.c
15
--- a/target/arm/helper.c
34
+++ b/target/arm/helper.c
16
+++ b/target/arm/helper.c
35
@@ -XXX,XX +XXX,XX @@ VFP_CONV_FIX_A64(uq, s, 32, 64, uint64)
17
@@ -XXX,XX +XXX,XX @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr,
36
/* Set the current fp rounding mode and return the old one.
18
37
* The argument is a softfloat float_round_ value.
19
*attrs = (MemTxAttrs) {};
38
*/
20
39
-uint32_t HELPER(set_rmode)(uint32_t rmode, CPUARMState *env)
21
- ret = get_phys_addr(env, addr, 0, mmu_idx, &phys_addr,
40
+uint32_t HELPER(set_rmode)(uint32_t rmode, void *fpstp)
22
+ ret = get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &phys_addr,
41
{
23
attrs, &prot, &page_size, &fi, &cacheattrs);
42
- float_status *fp_status = &env->vfp.fp_status;
24
43
+ float_status *fp_status = fpstp;
25
if (ret) {
44
45
uint32_t prev_rmode = get_float_rounding_mode(fp_status);
46
set_float_rounding_mode(rmode, fp_status);
47
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/target/arm/translate-a64.c
50
+++ b/target/arm/translate-a64.c
51
@@ -XXX,XX +XXX,XX @@ static void handle_fp_1src_single(DisasContext *s, int opcode, int rd, int rn)
52
{
53
TCGv_i32 tcg_rmode = tcg_const_i32(arm_rmode_to_sf(opcode & 7));
54
55
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
56
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
57
gen_helper_rints(tcg_res, tcg_op, fpst);
58
59
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
60
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
61
tcg_temp_free_i32(tcg_rmode);
62
break;
63
}
64
@@ -XXX,XX +XXX,XX @@ static void handle_fp_1src_double(DisasContext *s, int opcode, int rd, int rn)
65
{
66
TCGv_i32 tcg_rmode = tcg_const_i32(arm_rmode_to_sf(opcode & 7));
67
68
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
69
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
70
gen_helper_rintd(tcg_res, tcg_op, fpst);
71
72
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
73
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
74
tcg_temp_free_i32(tcg_rmode);
75
break;
76
}
77
@@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode,
78
79
tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rmode));
80
81
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
82
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus);
83
84
if (is_double) {
85
TCGv_i64 tcg_double = read_fp_dreg(s, rn);
86
@@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode,
87
tcg_temp_free_i32(tcg_single);
88
}
89
90
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
91
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus);
92
tcg_temp_free_i32(tcg_rmode);
93
94
if (!sf) {
95
@@ -XXX,XX +XXX,XX @@ static void handle_simd_shift_fpint_conv(DisasContext *s, bool is_scalar,
96
assert(!(is_scalar && is_q));
97
98
tcg_rmode = tcg_const_i32(arm_rmode_to_sf(FPROUNDING_ZERO));
99
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
100
tcg_fpstatus = get_fpstatus_ptr(false);
101
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus);
102
tcg_shift = tcg_const_i32(fracbits);
103
104
if (is_double) {
105
@@ -XXX,XX +XXX,XX @@ static void handle_simd_shift_fpint_conv(DisasContext *s, bool is_scalar,
106
107
tcg_temp_free_ptr(tcg_fpstatus);
108
tcg_temp_free_i32(tcg_shift);
109
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
110
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus);
111
tcg_temp_free_i32(tcg_rmode);
112
}
113
114
@@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_two_reg_misc(DisasContext *s, uint32_t insn)
115
116
if (is_fcvt) {
117
tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rmode));
118
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
119
tcg_fpstatus = get_fpstatus_ptr(false);
120
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus);
121
} else {
122
tcg_rmode = NULL;
123
tcg_fpstatus = NULL;
124
@@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_two_reg_misc(DisasContext *s, uint32_t insn)
125
}
126
127
if (is_fcvt) {
128
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
129
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus);
130
tcg_temp_free_i32(tcg_rmode);
131
tcg_temp_free_ptr(tcg_fpstatus);
132
}
133
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn)
134
return;
135
}
136
137
- if (need_fpstatus) {
138
+ if (need_fpstatus || need_rmode) {
139
tcg_fpstatus = get_fpstatus_ptr(false);
140
} else {
141
tcg_fpstatus = NULL;
142
}
143
if (need_rmode) {
144
tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rmode));
145
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
146
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus);
147
} else {
148
tcg_rmode = NULL;
149
}
150
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn)
151
clear_vec_high(s, is_q, rd);
152
153
if (need_rmode) {
154
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
155
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus);
156
tcg_temp_free_i32(tcg_rmode);
157
}
158
if (need_fpstatus) {
159
diff --git a/target/arm/translate.c b/target/arm/translate.c
160
index XXXXXXX..XXXXXXX 100644
161
--- a/target/arm/translate.c
162
+++ b/target/arm/translate.c
163
@@ -XXX,XX +XXX,XX @@ static int handle_vrint(uint32_t insn, uint32_t rd, uint32_t rm, uint32_t dp,
164
TCGv_i32 tcg_rmode;
165
166
tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rounding));
167
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
168
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
169
170
if (dp) {
171
TCGv_i64 tcg_op;
172
@@ -XXX,XX +XXX,XX @@ static int handle_vrint(uint32_t insn, uint32_t rd, uint32_t rm, uint32_t dp,
173
tcg_temp_free_i32(tcg_res);
174
}
175
176
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
177
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
178
tcg_temp_free_i32(tcg_rmode);
179
180
tcg_temp_free_ptr(fpst);
181
@@ -XXX,XX +XXX,XX @@ static int handle_vcvt(uint32_t insn, uint32_t rd, uint32_t rm, uint32_t dp,
182
tcg_shift = tcg_const_i32(0);
183
184
tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rounding));
185
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
186
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
187
188
if (dp) {
189
TCGv_i64 tcg_double, tcg_res;
190
@@ -XXX,XX +XXX,XX @@ static int handle_vcvt(uint32_t insn, uint32_t rd, uint32_t rm, uint32_t dp,
191
tcg_temp_free_i32(tcg_single);
192
}
193
194
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
195
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
196
tcg_temp_free_i32(tcg_rmode);
197
198
tcg_temp_free_i32(tcg_shift);
199
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
200
TCGv_ptr fpst = get_fpstatus_ptr(0);
201
TCGv_i32 tcg_rmode;
202
tcg_rmode = tcg_const_i32(float_round_to_zero);
203
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
204
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
205
if (dp) {
206
gen_helper_rintd(cpu_F0d, cpu_F0d, fpst);
207
} else {
208
gen_helper_rints(cpu_F0s, cpu_F0s, fpst);
209
}
210
- gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
211
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
212
tcg_temp_free_i32(tcg_rmode);
213
tcg_temp_free_ptr(fpst);
214
break;
215
--
26
--
216
2.16.2
27
2.20.1
217
28
218
29
diff view generated by jsdifflib
New patch
1
Move the preadv availability check to meson.build. This is what we
2
want to be doing for host-OS-feature-checks anyway, but it also fixes
3
a problem with building for macOS with the most recent XCode SDK on a
4
Catalina host.
1
5
6
On that configuration, 'preadv()' is provided as a weak symbol, so
7
that programs can be built with optional support for it and make a
8
runtime availability check to see whether the preadv() they have is a
9
working one or one which they must not call because it will
10
runtime-assert. QEMU's configure test passes (unless you're building
11
with --enable-werror) because the test program using preadv()
12
compiles, but then QEMU crashes at runtime when preadv() is called,
13
with errors like:
14
15
dyld: lazy symbol binding failed: Symbol not found: _preadv
16
Referenced from: /Users/pm215/src/qemu/./build/x86/tests/test-replication
17
Expected in: /usr/lib/libSystem.B.dylib
18
19
dyld: Symbol not found: _preadv
20
Referenced from: /Users/pm215/src/qemu/./build/x86/tests/test-replication
21
Expected in: /usr/lib/libSystem.B.dylib
22
23
Meson's own function availability check has a special case for macOS
24
which adds '-Wl,-no_weak_imports' to the compiler flags, which forces
25
the test to require the real function, not the macOS-version-too-old
26
stub.
27
28
So this commit fixes the bug where macOS builds on Catalina currently
29
require --disable-werror.
30
31
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
32
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
33
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
34
Message-id: 20210126155846.17109-1-peter.maydell@linaro.org
35
---
36
configure | 16 ----------------
37
meson.build | 4 +++-
38
2 files changed, 3 insertions(+), 17 deletions(-)
39
40
diff --git a/configure b/configure
41
index XXXXXXX..XXXXXXX 100755
42
--- a/configure
43
+++ b/configure
44
@@ -XXX,XX +XXX,XX @@ if compile_prog "" "" ; then
45
iovec=yes
46
fi
47
48
-##########################################
49
-# preadv probe
50
-cat > $TMPC <<EOF
51
-#include <sys/types.h>
52
-#include <sys/uio.h>
53
-#include <unistd.h>
54
-int main(void) { return preadv(0, 0, 0, 0); }
55
-EOF
56
-preadv=no
57
-if compile_prog "" "" ; then
58
- preadv=yes
59
-fi
60
-
61
##########################################
62
# fdt probe
63
64
@@ -XXX,XX +XXX,XX @@ fi
65
if test "$iovec" = "yes" ; then
66
echo "CONFIG_IOVEC=y" >> $config_host_mak
67
fi
68
-if test "$preadv" = "yes" ; then
69
- echo "CONFIG_PREADV=y" >> $config_host_mak
70
-fi
71
if test "$membarrier" = "yes" ; then
72
echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
73
fi
74
diff --git a/meson.build b/meson.build
75
index XXXXXXX..XXXXXXX 100644
76
--- a/meson.build
77
+++ b/meson.build
78
@@ -XXX,XX +XXX,XX @@ config_host_data.set('HAVE_PTY_H', cc.has_header('pty.h'))
79
config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h'))
80
config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h'))
81
82
+config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include <sys/uio.h>'))
83
+
84
ignored = ['CONFIG_QEMU_INTERP_PREFIX'] # actually per-target
85
arrays = ['CONFIG_AUDIO_DRIVERS', 'CONFIG_BDRV_RW_WHITELIST', 'CONFIG_BDRV_RO_WHITELIST']
86
strings = ['HOST_DSOSUF', 'CONFIG_IASL']
87
@@ -XXX,XX +XXX,XX @@ summary_info += {'PIE': get_option('b_pie')}
88
summary_info += {'static build': config_host.has_key('CONFIG_STATIC')}
89
summary_info += {'malloc trim support': has_malloc_trim}
90
summary_info += {'membarrier': config_host.has_key('CONFIG_MEMBARRIER')}
91
-summary_info += {'preadv support': config_host.has_key('CONFIG_PREADV')}
92
+summary_info += {'preadv support': config_host_data.get('CONFIG_PREADV')}
93
summary_info += {'fdatasync': config_host.has_key('CONFIG_FDATASYNC')}
94
summary_info += {'madvise': config_host.has_key('CONFIG_MADVISE')}
95
summary_info += {'posix_madvise': config_host.has_key('CONFIG_POSIX_MADVISE')}
96
--
97
2.20.1
98
99
diff view generated by jsdifflib
1
Now we have implemented FP16 we can enable it for the "any" CPU.
1
From: Joelle van Dyne <j@getutm.app>
2
2
3
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
3
The iOS toolchain does not use the host prefix naming convention. So we
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
4
need to enable cross-compile options while allowing the PREFIX to be
5
[PMM: split out from an earlier patch in the series]
5
blank.
6
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Signed-off-by: Joelle van Dyne <j@getutm.app>
9
Message-id: 20210126012457.39046-3-j@getutm.app
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
11
---
8
target/arm/cpu64.c | 1 +
12
configure | 6 ++++--
9
1 file changed, 1 insertion(+)
13
1 file changed, 4 insertions(+), 2 deletions(-)
10
14
11
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
15
diff --git a/configure b/configure
12
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100755
13
--- a/target/arm/cpu64.c
17
--- a/configure
14
+++ b/target/arm/cpu64.c
18
+++ b/configure
15
@@ -XXX,XX +XXX,XX @@ static void aarch64_any_initfn(Object *obj)
19
@@ -XXX,XX +XXX,XX @@ cpu=""
16
set_feature(&cpu->env, ARM_FEATURE_V8_SM4);
20
iasl="iasl"
17
set_feature(&cpu->env, ARM_FEATURE_V8_PMULL);
21
interp_prefix="/usr/gnemul/qemu-%M"
18
set_feature(&cpu->env, ARM_FEATURE_CRC);
22
static="no"
19
+ set_feature(&cpu->env, ARM_FEATURE_V8_FP16);
23
+cross_compile="no"
20
cpu->ctr = 0x80038003; /* 32 byte I and D cacheline size, VIPT icache */
24
cross_prefix=""
21
cpu->dcz_blocksize = 7; /* 512 bytes */
25
audio_drv_list=""
22
}
26
block_drv_rw_whitelist=""
27
@@ -XXX,XX +XXX,XX @@ for opt do
28
optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
29
case "$opt" in
30
--cross-prefix=*) cross_prefix="$optarg"
31
+ cross_compile="yes"
32
;;
33
--cc=*) CC="$optarg"
34
;;
35
@@ -XXX,XX +XXX,XX @@ $(echo Deprecated targets: $deprecated_targets_list | \
36
--target-list-exclude=LIST exclude a set of targets from the default target-list
37
38
Advanced options (experts only):
39
- --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
40
+ --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
41
--cc=CC use C compiler CC [$cc]
42
--iasl=IASL use ACPI compiler IASL [$iasl]
43
--host-cc=CC use C compiler CC [$host_cc] for code run at
44
@@ -XXX,XX +XXX,XX @@ if has $sdl2_config; then
45
fi
46
echo "strip = [$(meson_quote $strip)]" >> $cross
47
echo "windres = [$(meson_quote $windres)]" >> $cross
48
-if test -n "$cross_prefix"; then
49
+if test "$cross_compile" = "yes"; then
50
cross_arg="--cross-file config-meson.cross"
51
echo "[host_machine]" >> $cross
52
if test "$mingw32" = "yes" ; then
23
--
53
--
24
2.16.2
54
2.20.1
25
55
26
56
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Joelle van Dyne <j@getutm.app>
2
2
3
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
3
Build without error on hosts without a working system(). If system()
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
4
is called, return -1 with ENOSYS.
5
Message-id: 20180227143852.11175-28-alex.bennee@linaro.org
5
6
Signed-off-by: Joelle van Dyne <j@getutm.app>
7
Message-id: 20210126012457.39046-6-j@getutm.app
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
10
---
8
target/arm/translate-a64.c | 7 +++++++
11
meson.build | 1 +
9
1 file changed, 7 insertions(+)
12
include/qemu/osdep.h | 12 ++++++++++++
13
2 files changed, 13 insertions(+)
10
14
11
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
15
diff --git a/meson.build b/meson.build
12
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/translate-a64.c
17
--- a/meson.build
14
+++ b/target/arm/translate-a64.c
18
+++ b/meson.build
15
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
19
@@ -XXX,XX +XXX,XX @@ config_host_data.set('HAVE_DRM_H', cc.has_header('libdrm/drm.h'))
16
case 0x6f: /* FNEG */
20
config_host_data.set('HAVE_PTY_H', cc.has_header('pty.h'))
17
need_fpst = false;
21
config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h'))
18
break;
22
config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h'))
19
+ case 0x7d: /* FRSQRTE */
23
+config_host_data.set('HAVE_SYSTEM_FUNCTION', cc.has_function('system', prefix: '#include <stdlib.h>'))
20
case 0x7f: /* FSQRT (vector) */
24
21
break;
25
config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include <sys/uio.h>'))
22
default:
26
23
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
27
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
24
case 0x6f: /* FNEG */
28
index XXXXXXX..XXXXXXX 100644
25
tcg_gen_xori_i32(tcg_res, tcg_op, 0x8000);
29
--- a/include/qemu/osdep.h
26
break;
30
+++ b/include/qemu/osdep.h
27
+ case 0x7d: /* FRSQRTE */
31
@@ -XXX,XX +XXX,XX @@ static inline void qemu_thread_jit_write(void) {}
28
+ gen_helper_rsqrte_f16(tcg_res, tcg_op, tcg_fpstatus);
32
static inline void qemu_thread_jit_execute(void) {}
29
+ break;
33
#endif
30
default:
34
31
g_assert_not_reached();
35
+/**
32
}
36
+ * Platforms which do not support system() return ENOSYS
33
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
37
+ */
34
case 0x6f: /* FNEG */
38
+#ifndef HAVE_SYSTEM_FUNCTION
35
tcg_gen_xori_i32(tcg_res, tcg_op, 0x8000);
39
+#define system platform_does_not_support_system
36
break;
40
+static inline int platform_does_not_support_system(const char *command)
37
+ case 0x7d: /* FRSQRTE */
41
+{
38
+ gen_helper_rsqrte_f16(tcg_res, tcg_op, tcg_fpstatus);
42
+ errno = ENOSYS;
39
+ break;
43
+ return -1;
40
case 0x7f: /* FSQRT */
44
+}
41
gen_helper_sqrt_f16(tcg_res, tcg_op, tcg_fpstatus);
45
+#endif /* !HAVE_SYSTEM_FUNCTION */
42
break;
46
+
47
#endif
43
--
48
--
44
2.16.2
49
2.20.1
45
50
46
51
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Joelle van Dyne <j@getutm.app>
2
2
3
Now we have added f16 during the re-factoring we can simply call the
3
Meson will find CoreFoundation, IOKit, and Cocoa as needed.
4
helper.
5
4
6
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Joelle van Dyne <j@getutm.app>
8
Message-id: 20180227143852.11175-24-alex.bennee@linaro.org
7
Message-id: 20210126012457.39046-7-j@getutm.app
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
9
---
11
target/arm/translate-a64.c | 8 ++++++++
10
configure | 1 -
12
1 file changed, 8 insertions(+)
11
1 file changed, 1 deletion(-)
13
12
14
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
13
diff --git a/configure b/configure
15
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100755
16
--- a/target/arm/translate-a64.c
15
--- a/configure
17
+++ b/target/arm/translate-a64.c
16
+++ b/configure
18
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
17
@@ -XXX,XX +XXX,XX @@ Darwin)
19
case 0x6d: /* FCMLE (zero) */
18
fi
20
handle_2misc_fcmp_zero(s, fpop, is_scalar, 0, is_q, MO_16, rn, rd);
19
audio_drv_list="coreaudio try-sdl"
21
return;
20
audio_possible_drivers="coreaudio sdl"
22
+ case 0x3d: /* FRECPE */
21
- QEMU_LDFLAGS="-framework CoreFoundation -framework IOKit $QEMU_LDFLAGS"
23
+ break;
22
# Disable attempts to use ObjectiveC features in os/object.h since they
24
case 0x18: /* FRINTN */
23
# won't work when we're compiling with gcc as a C compiler.
25
need_rmode = true;
24
QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
26
only_in_vector = true;
27
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
28
case 0x3b: /* FCVTZS */
29
gen_helper_advsimd_f16tosinth(tcg_res, tcg_op, tcg_fpstatus);
30
break;
31
+ case 0x3d: /* FRECPE */
32
+ gen_helper_recpe_f16(tcg_res, tcg_op, tcg_fpstatus);
33
+ break;
34
case 0x5a: /* FCVTNU */
35
case 0x5b: /* FCVTMU */
36
case 0x5c: /* FCVTAU */
37
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
38
case 0x3b: /* FCVTZS */
39
gen_helper_advsimd_f16tosinth(tcg_res, tcg_op, tcg_fpstatus);
40
break;
41
+ case 0x3d: /* FRECPE */
42
+ gen_helper_recpe_f16(tcg_res, tcg_op, tcg_fpstatus);
43
+ break;
44
case 0x5a: /* FCVTNU */
45
case 0x5b: /* FCVTMU */
46
case 0x5c: /* FCVTAU */
47
--
25
--
48
2.16.2
26
2.20.1
49
27
50
28
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Joelle van Dyne <j@getutm.app>
2
2
3
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
3
Add objc to the Meson cross file as well as detection of Darwin.
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
4
5
Message-id: 20180227143852.11175-4-alex.bennee@linaro.org
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Joelle van Dyne <j@getutm.app>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20210126012457.39046-8-j@getutm.app
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
10
---
8
target/arm/cpu.h | 1 +
11
configure | 4 ++++
9
1 file changed, 1 insertion(+)
12
1 file changed, 4 insertions(+)
10
13
11
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
14
diff --git a/configure b/configure
12
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100755
13
--- a/target/arm/cpu.h
16
--- a/configure
14
+++ b/target/arm/cpu.h
17
+++ b/configure
15
@@ -XXX,XX +XXX,XX @@ typedef struct {
18
@@ -XXX,XX +XXX,XX @@ echo "cpp_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
16
* Qn = regs[n].d[1]:regs[n].d[0]
19
echo "[binaries]" >> $cross
17
* Dn = regs[n].d[0]
20
echo "c = [$(meson_quote $cc)]" >> $cross
18
* Sn = regs[n].d[0] bits 31..0
21
test -n "$cxx" && echo "cpp = [$(meson_quote $cxx)]" >> $cross
19
+ * Hn = regs[n].d[0] bits 15..0
22
+test -n "$objcc" && echo "objc = [$(meson_quote $objcc)]" >> $cross
20
*
23
echo "ar = [$(meson_quote $ar)]" >> $cross
21
* This corresponds to the architecturally defined mapping between
24
echo "nm = [$(meson_quote $nm)]" >> $cross
22
* the two execution states, and means we do not need to explicitly
25
echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
26
@@ -XXX,XX +XXX,XX @@ if test "$cross_compile" = "yes"; then
27
if test "$linux" = "yes" ; then
28
echo "system = 'linux'" >> $cross
29
fi
30
+ if test "$darwin" = "yes" ; then
31
+ echo "system = 'darwin'" >> $cross
32
+ fi
33
case "$ARCH" in
34
i386|x86_64)
35
echo "cpu_family = 'x86'" >> $cross
23
--
36
--
24
2.16.2
37
2.20.1
25
38
26
39
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Joelle van Dyne <j@getutm.app>
2
2
3
This allows us to explicitly pass float16 to helpers rather than
3
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
assuming uint32_t and dealing with the result. Of course they will be
4
Signed-off-by: Joelle van Dyne <j@getutm.app>
5
passed in i32 sized registers by default.
5
Message-id: 20210126012457.39046-9-j@getutm.app
6
7
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20180227143852.11175-2-alex.bennee@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
7
---
12
include/exec/helper-head.h | 3 +++
8
configure | 5 ++++-
13
1 file changed, 3 insertions(+)
9
1 file changed, 4 insertions(+), 1 deletion(-)
14
10
15
diff --git a/include/exec/helper-head.h b/include/exec/helper-head.h
11
diff --git a/configure b/configure
16
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100755
17
--- a/include/exec/helper-head.h
13
--- a/configure
18
+++ b/include/exec/helper-head.h
14
+++ b/configure
19
@@ -XXX,XX +XXX,XX @@
15
@@ -XXX,XX +XXX,XX @@ if test "$cross_compile" = "yes"; then
20
#define dh_alias_int i32
16
echo "system = 'darwin'" >> $cross
21
#define dh_alias_i64 i64
17
fi
22
#define dh_alias_s64 i64
18
case "$ARCH" in
23
+#define dh_alias_f16 i32
19
- i386|x86_64)
24
#define dh_alias_f32 i32
20
+ i386)
25
#define dh_alias_f64 i64
21
echo "cpu_family = 'x86'" >> $cross
26
#define dh_alias_ptr ptr
22
;;
27
@@ -XXX,XX +XXX,XX @@
23
+ x86_64)
28
#define dh_ctype_int int
24
+ echo "cpu_family = 'x86_64'" >> $cross
29
#define dh_ctype_i64 uint64_t
25
+ ;;
30
#define dh_ctype_s64 int64_t
26
ppc64le)
31
+#define dh_ctype_f16 float16
27
echo "cpu_family = 'ppc64'" >> $cross
32
#define dh_ctype_f32 float32
28
;;
33
#define dh_ctype_f64 float64
34
#define dh_ctype_ptr void *
35
@@ -XXX,XX +XXX,XX @@
36
#define dh_is_signed_s32 1
37
#define dh_is_signed_i64 0
38
#define dh_is_signed_s64 1
39
+#define dh_is_signed_f16 0
40
#define dh_is_signed_f32 0
41
#define dh_is_signed_f64 0
42
#define dh_is_signed_tl 0
43
--
29
--
44
2.16.2
30
2.20.1
45
31
46
32
diff view generated by jsdifflib
1
From: Linus Walleij <linus.walleij@linaro.org>
1
From: Joelle van Dyne <j@getutm.app>
2
2
3
This adds the SiI9022 (and implicitly EDID I2C) device to the ARM
3
On iOS there is no CoreAudio, so we should not assume Darwin always
4
Versatile Express machine, and selects the two I2C devices necessary
4
has it.
5
in the arm-softmmu.mak configuration so everything will build
6
smoothly.
7
5
8
I am implementing proper handling of the graphics in the Linux
6
Signed-off-by: Joelle van Dyne <j@getutm.app>
9
kernel and adding proper emulation of SiI9022 and EDID makes the
10
driver probe as nicely as before, retrieving the resolutions
11
supported by the "QEMU monitor" and overall just working nice.
12
13
Cc: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
15
Message-id: 20180227104903.21353-6-linus.walleij@linaro.org
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
17
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20210126012457.39046-11-j@getutm.app
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
---
10
---
20
hw/arm/vexpress.c | 6 +++++-
11
configure | 35 +++++++++++++++++++++++++++++++++--
21
default-configs/arm-softmmu.mak | 2 ++
12
1 file changed, 33 insertions(+), 2 deletions(-)
22
2 files changed, 7 insertions(+), 1 deletion(-)
23
13
24
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
14
diff --git a/configure b/configure
25
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100755
26
--- a/hw/arm/vexpress.c
16
--- a/configure
27
+++ b/hw/arm/vexpress.c
17
+++ b/configure
28
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@ fdt="auto"
29
#include "hw/arm/arm.h"
19
netmap="no"
30
#include "hw/arm/primecell.h"
20
sdl="auto"
31
#include "hw/devices.h"
21
sdl_image="auto"
32
+#include "hw/i2c/i2c.h"
22
+coreaudio="auto"
33
#include "net/net.h"
23
virtiofsd="auto"
34
#include "sysemu/sysemu.h"
24
virtfs="auto"
35
#include "hw/boards.h"
25
libudev="auto"
36
@@ -XXX,XX +XXX,XX @@ static void vexpress_common_init(MachineState *machine)
26
@@ -XXX,XX +XXX,XX @@ Darwin)
37
uint32_t sys_id;
27
QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
38
DriveInfo *dinfo;
28
QEMU_LDFLAGS="-arch x86_64 $QEMU_LDFLAGS"
39
pflash_t *pflash0;
29
fi
40
+ I2CBus *i2c;
30
- audio_drv_list="coreaudio try-sdl"
41
ram_addr_t vram_size, sram_size;
31
+ audio_drv_list="try-coreaudio try-sdl"
42
MemoryRegion *sysmem = get_system_memory();
32
audio_possible_drivers="coreaudio sdl"
43
MemoryRegion *vram = g_new(MemoryRegion, 1);
33
# Disable attempts to use ObjectiveC features in os/object.h since they
44
@@ -XXX,XX +XXX,XX @@ static void vexpress_common_init(MachineState *machine)
34
# won't work when we're compiling with gcc as a C compiler.
45
sysbus_create_simple("sp804", map[VE_TIMER01], pic[2]);
35
@@ -XXX,XX +XXX,XX @@ EOF
46
sysbus_create_simple("sp804", map[VE_TIMER23], pic[3]);
36
fi
47
37
fi
48
- /* VE_SERIALDVI: not modelled */
38
49
+ dev = sysbus_create_simple("versatile_i2c", map[VE_SERIALDVI], NULL);
39
+##########################################
50
+ i2c = (I2CBus *)qdev_get_child_bus(dev, "i2c");
40
+# detect CoreAudio
51
+ i2c_create_slave(i2c, "sii9022", 0x39);
41
+if test "$coreaudio" != "no" ; then
52
42
+ coreaudio_libs="-framework CoreAudio"
53
sysbus_create_simple("pl031", map[VE_RTC], pic[4]); /* RTC */
43
+ cat > $TMPC << EOF
54
44
+#include <CoreAudio/CoreAudio.h>
55
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
45
+int main(void)
56
index XXXXXXX..XXXXXXX 100644
46
+{
57
--- a/default-configs/arm-softmmu.mak
47
+ return (int)AudioGetCurrentHostTime();
58
+++ b/default-configs/arm-softmmu.mak
48
+}
59
@@ -XXX,XX +XXX,XX @@ CONFIG_STELLARIS_INPUT=y
49
+EOF
60
CONFIG_STELLARIS_ENET=y
50
+ if compile_prog "" "$coreaudio_libs" ; then
61
CONFIG_SSD0303=y
51
+ coreaudio=yes
62
CONFIG_SSD0323=y
52
+ else
63
+CONFIG_DDC=y
53
+ coreaudio=no
64
+CONFIG_SII9022=y
54
+ fi
65
CONFIG_ADS7846=y
55
+fi
66
CONFIG_MAX111X=y
56
+
67
CONFIG_SSI=y
57
##########################################
58
# Sound support libraries probe
59
60
@@ -XXX,XX +XXX,XX @@ for drv in $audio_drv_list; do
61
fi
62
;;
63
64
- coreaudio)
65
+ coreaudio | try-coreaudio)
66
+ if test "$coreaudio" = "no"; then
67
+ if test "$drv" = "try-coreaudio"; then
68
+ audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-coreaudio//')
69
+ else
70
+ error_exit "$drv check failed" \
71
+ "Make sure to have the $drv is available."
72
+ fi
73
+ else
74
coreaudio_libs="-framework CoreAudio"
75
+ if test "$drv" = "try-coreaudio"; then
76
+ audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-coreaudio/coreaudio/')
77
+ fi
78
+ fi
79
;;
80
81
dsound)
68
--
82
--
69
2.16.2
83
2.20.1
70
84
71
85
diff view generated by jsdifflib
1
From: Linus Walleij <linus.walleij@linaro.org>
1
From: Joelle van Dyne <j@getutm.app>
2
2
3
The tx function of the DDC I2C slave emulation was returning 1
3
A workaround added in early days of 64-bit OSX forced x86_64 if the
4
on all writes resulting in NACK in the I2C bus. Changing it to
4
host machine had 64-bit support. This creates issues when cross-
5
0 makes the DDC I2C work fine with bit-banged I2C such as the
5
compiling for ARM64. Additionally, the user can always use --cpu=* to
6
versatile I2C.
6
manually set the host CPU and therefore this workaround should be
7
7
removed.
8
I guess it was not affecting whatever I2C controller this was
9
used with until now, but with the Versatile I2C it surely
10
does not work.
11
8
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
10
Signed-off-by: Joelle van Dyne <j@getutm.app>
14
Message-id: 20180227104903.21353-4-linus.walleij@linaro.org
11
Message-id: 20210126012457.39046-12-j@getutm.app
15
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
13
---
18
hw/i2c/i2c-ddc.c | 4 ++--
14
configure | 11 -----------
19
1 file changed, 2 insertions(+), 2 deletions(-)
15
1 file changed, 11 deletions(-)
20
16
21
diff --git a/hw/i2c/i2c-ddc.c b/hw/i2c/i2c-ddc.c
17
diff --git a/configure b/configure
22
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100755
23
--- a/hw/i2c/i2c-ddc.c
19
--- a/configure
24
+++ b/hw/i2c/i2c-ddc.c
20
+++ b/configure
25
@@ -XXX,XX +XXX,XX @@ static int i2c_ddc_tx(I2CSlave *i2c, uint8_t data)
21
@@ -XXX,XX +XXX,XX @@ fi
26
s->reg = data;
22
# the correct CPU with the --cpu option.
27
s->firstbyte = false;
23
case $targetos in
28
DPRINTF("[EDID] Written new pointer: %u\n", data);
24
Darwin)
29
- return 1;
25
- # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
30
+ return 0;
26
- # run 64-bit userspace code.
31
}
27
- # If the user didn't specify a CPU explicitly and the kernel says this is
32
28
- # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
33
/* Ignore all writes */
29
- if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
34
s->reg++;
30
- cpu="x86_64"
35
- return 1;
31
- fi
36
+ return 0;
32
HOST_DSOSUF=".dylib"
37
}
33
;;
38
34
SunOS)
39
static void i2c_ddc_init(Object *obj)
35
@@ -XXX,XX +XXX,XX @@ OpenBSD)
36
Darwin)
37
bsd="yes"
38
darwin="yes"
39
- if [ "$cpu" = "x86_64" ] ; then
40
- QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
41
- QEMU_LDFLAGS="-arch x86_64 $QEMU_LDFLAGS"
42
- fi
43
audio_drv_list="try-coreaudio try-sdl"
44
audio_possible_drivers="coreaudio sdl"
45
# Disable attempts to use ObjectiveC features in os/object.h since they
40
--
46
--
41
2.16.2
47
2.20.1
42
48
43
49
diff view generated by jsdifflib
1
From: Corey Minyard <cminyard@mvista.com>
1
From: Alexander Graf <agraf@csgraf.de>
2
2
3
Signed-off-by: Corey Minyard <cminyard@mvista.com>
3
In macOS 11, QEMU only gets access to Hypervisor.framework if it has the
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
4
respective entitlement. Add an entitlement template and automatically self
5
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
5
sign and apply the entitlement in the build.
6
Message-id: 20180227104903.21353-2-linus.walleij@linaro.org
6
7
Signed-off-by: Alexander Graf <agraf@csgraf.de>
8
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
9
Tested-by: Roman Bolshakov <r.bolshakov@yadro.com>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
11
---
9
include/hw/i2c/i2c.h | 6 ++----
12
meson.build | 29 +++++++++++++++++++++++++----
10
hw/i2c/core.c | 3 +--
13
accel/hvf/entitlements.plist | 8 ++++++++
11
2 files changed, 3 insertions(+), 6 deletions(-)
14
scripts/entitlement.sh | 13 +++++++++++++
15
3 files changed, 46 insertions(+), 4 deletions(-)
16
create mode 100644 accel/hvf/entitlements.plist
17
create mode 100755 scripts/entitlement.sh
12
18
13
diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h
19
diff --git a/meson.build b/meson.build
14
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
15
--- a/include/hw/i2c/i2c.h
21
--- a/meson.build
16
+++ b/include/hw/i2c/i2c.h
22
+++ b/meson.build
17
@@ -XXX,XX +XXX,XX @@ typedef struct I2CSlave I2CSlave;
23
@@ -XXX,XX +XXX,XX @@ foreach target : target_dirs
18
#define I2C_SLAVE_GET_CLASS(obj) \
24
}]
19
OBJECT_GET_CLASS(I2CSlaveClass, (obj), TYPE_I2C_SLAVE)
25
endif
20
26
foreach exe: execs
21
-typedef struct I2CSlaveClass
27
- emulators += {exe['name']:
22
-{
28
- executable(exe['name'], exe['sources'],
23
+typedef struct I2CSlaveClass {
29
- install: true,
24
DeviceClass parent_class;
30
+ exe_name = exe['name']
25
31
+ exe_sign = 'CONFIG_HVF' in config_target
26
/* Callbacks provided by the device. */
32
+ if exe_sign
27
@@ -XXX,XX +XXX,XX @@ typedef struct I2CSlaveClass
33
+ exe_name += '-unsigned'
28
int (*event)(I2CSlave *s, enum i2c_event event);
34
+ endif
29
} I2CSlaveClass;
35
+
30
36
+ emulator = executable(exe_name, exe['sources'],
31
-struct I2CSlave
37
+ install: not exe_sign,
32
-{
38
c_args: c_args,
33
+struct I2CSlave {
39
dependencies: arch_deps + deps + exe['dependencies'],
34
DeviceState qdev;
40
objects: lib.extract_all_objects(recursive: true),
35
41
@@ -XXX,XX +XXX,XX @@ foreach target : target_dirs
36
/* Remaining fields for internal use by the I2C code. */
42
link_depends: [block_syms, qemu_syms] + exe.get('link_depends', []),
37
diff --git a/hw/i2c/core.c b/hw/i2c/core.c
43
link_args: link_args,
38
index XXXXXXX..XXXXXXX 100644
44
gui_app: exe['gui'])
39
--- a/hw/i2c/core.c
45
- }
40
+++ b/hw/i2c/core.c
46
+
41
@@ -XXX,XX +XXX,XX @@ struct I2CNode {
47
+ if exe_sign
42
48
+ emulators += {exe['name'] : custom_target(exe['name'],
43
#define I2C_BROADCAST 0x00
49
+ install: true,
44
50
+ install_dir: get_option('bindir'),
45
-struct I2CBus
51
+ depends: emulator,
46
-{
52
+ output: exe['name'],
47
+struct I2CBus {
53
+ command: [
48
BusState qbus;
54
+ meson.current_source_dir() / 'scripts/entitlement.sh',
49
QLIST_HEAD(, I2CNode) current_devs;
55
+ meson.current_build_dir() / exe_name,
50
uint8_t saved_address;
56
+ meson.current_build_dir() / exe['name'],
57
+ meson.current_source_dir() / 'accel/hvf/entitlements.plist'
58
+ ])
59
+ }
60
+ else
61
+ emulators += {exe['name']: emulator}
62
+ endif
63
64
if 'CONFIG_TRACE_SYSTEMTAP' in config_host
65
foreach stp: [
66
diff --git a/accel/hvf/entitlements.plist b/accel/hvf/entitlements.plist
67
new file mode 100644
68
index XXXXXXX..XXXXXXX
69
--- /dev/null
70
+++ b/accel/hvf/entitlements.plist
71
@@ -XXX,XX +XXX,XX @@
72
+<?xml version="1.0" encoding="UTF-8"?>
73
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
74
+<plist version="1.0">
75
+<dict>
76
+ <key>com.apple.security.hypervisor</key>
77
+ <true/>
78
+</dict>
79
+</plist>
80
diff --git a/scripts/entitlement.sh b/scripts/entitlement.sh
81
new file mode 100755
82
index XXXXXXX..XXXXXXX
83
--- /dev/null
84
+++ b/scripts/entitlement.sh
85
@@ -XXX,XX +XXX,XX @@
86
+#!/bin/sh -e
87
+#
88
+# Helper script for the build process to apply entitlements
89
+
90
+SRC="$1"
91
+DST="$2"
92
+ENTITLEMENT="$3"
93
+
94
+trap 'rm "$DST.tmp"' exit
95
+cp -af "$SRC" "$DST.tmp"
96
+codesign --entitlements "$ENTITLEMENT" --force -s - "$DST.tmp"
97
+mv "$DST.tmp" "$DST"
98
+trap '' exit
51
--
99
--
52
2.16.2
100
2.20.1
53
101
54
102
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Mihai Carabas <mihai.carabas@oracle.com>
2
2
3
This implements the half-precision variants of the across vector
3
To ease the PCI device addition in next patches, split the code as follows:
4
reduction operations. This involves a re-factor of the reduction code
4
- generic code (read/write/setup) is being kept in pvpanic.c
5
which more closely matches the ARM ARM order (and handles 8 element
5
- ISA dependent code moved to pvpanic-isa.c
6
reductions).
6
7
7
Also, rename:
8
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
8
- ISA_PVPANIC_DEVICE -> PVPANIC_ISA_DEVICE.
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
- TYPE_PVPANIC -> TYPE_PVPANIC_ISA.
10
Message-id: 20180227143852.11175-7-alex.bennee@linaro.org
10
- MemoryRegion io -> mr.
11
- pvpanic_ioport_* in pvpanic_*.
12
13
Update the build system with the new files and config structure.
14
15
Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
18
---
13
target/arm/helper-a64.h | 4 ++
19
include/hw/misc/pvpanic.h | 23 +++++++++-
14
target/arm/helper-a64.c | 18 ++++++
20
hw/misc/pvpanic-isa.c | 94 +++++++++++++++++++++++++++++++++++++++
15
target/arm/translate-a64.c | 140 ++++++++++++++++++++++++++++-----------------
21
hw/misc/pvpanic.c | 85 +++--------------------------------
16
3 files changed, 109 insertions(+), 53 deletions(-)
22
hw/i386/Kconfig | 2 +-
17
23
hw/misc/Kconfig | 6 ++-
18
diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h
24
hw/misc/meson.build | 3 +-
19
index XXXXXXX..XXXXXXX 100644
25
tests/qtest/meson.build | 2 +-
20
--- a/target/arm/helper-a64.h
26
7 files changed, 130 insertions(+), 85 deletions(-)
21
+++ b/target/arm/helper-a64.h
27
create mode 100644 hw/misc/pvpanic-isa.c
22
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(paired_cmpxchg64_le_parallel, TCG_CALL_NO_WG,
28
23
DEF_HELPER_FLAGS_4(paired_cmpxchg64_be, TCG_CALL_NO_WG, i64, env, i64, i64, i64)
29
diff --git a/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.h
24
DEF_HELPER_FLAGS_4(paired_cmpxchg64_be_parallel, TCG_CALL_NO_WG,
30
index XXXXXXX..XXXXXXX 100644
25
i64, env, i64, i64, i64)
31
--- a/include/hw/misc/pvpanic.h
26
+DEF_HELPER_FLAGS_3(advsimd_maxh, TCG_CALL_NO_RWG, f16, f16, f16, ptr)
32
+++ b/include/hw/misc/pvpanic.h
27
+DEF_HELPER_FLAGS_3(advsimd_minh, TCG_CALL_NO_RWG, f16, f16, f16, ptr)
33
@@ -XXX,XX +XXX,XX @@
28
+DEF_HELPER_FLAGS_3(advsimd_maxnumh, TCG_CALL_NO_RWG, f16, f16, f16, ptr)
34
29
+DEF_HELPER_FLAGS_3(advsimd_minnumh, TCG_CALL_NO_RWG, f16, f16, f16, ptr)
35
#include "qom/object.h"
30
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
36
31
index XXXXXXX..XXXXXXX 100644
37
-#define TYPE_PVPANIC "pvpanic"
32
--- a/target/arm/helper-a64.c
38
+#define TYPE_PVPANIC_ISA_DEVICE "pvpanic"
33
+++ b/target/arm/helper-a64.c
39
34
@@ -XXX,XX +XXX,XX @@ uint64_t HELPER(paired_cmpxchg64_be_parallel)(CPUARMState *env, uint64_t addr,
40
#define PVPANIC_IOPORT_PROP "ioport"
35
{
41
36
return do_paired_cmpxchg64_be(env, addr, new_lo, new_hi, true, GETPC());
42
+/* The bit of supported pv event, TODO: include uapi header and remove this */
37
}
43
+#define PVPANIC_F_PANICKED 0
44
+#define PVPANIC_F_CRASHLOADED 1
45
+
46
+/* The pv event value */
47
+#define PVPANIC_PANICKED (1 << PVPANIC_F_PANICKED)
48
+#define PVPANIC_CRASHLOADED (1 << PVPANIC_F_CRASHLOADED)
38
+
49
+
39
+/*
50
+/*
40
+ * AdvSIMD half-precision
51
+ * PVPanicState for any device type
41
+ */
52
+ */
42
+
53
+typedef struct PVPanicState PVPanicState;
43
+#define ADVSIMD_HELPER(name, suffix) HELPER(glue(glue(advsimd_, name), suffix))
54
+struct PVPanicState {
44
+
55
+ MemoryRegion mr;
45
+#define ADVSIMD_HALFOP(name) \
56
+ uint8_t events;
46
+float16 ADVSIMD_HELPER(name, h)(float16 a, float16 b, void *fpstp) \
57
+};
47
+{ \
58
+
48
+ float_status *fpst = fpstp; \
59
+void pvpanic_setup_io(PVPanicState *s, DeviceState *dev, unsigned size);
49
+ return float16_ ## name(a, b, fpst); \
60
+
61
static inline uint16_t pvpanic_port(void)
62
{
63
- Object *o = object_resolve_path_type("", TYPE_PVPANIC, NULL);
64
+ Object *o = object_resolve_path_type("", TYPE_PVPANIC_ISA_DEVICE, NULL);
65
if (!o) {
66
return 0;
67
}
68
diff --git a/hw/misc/pvpanic-isa.c b/hw/misc/pvpanic-isa.c
69
new file mode 100644
70
index XXXXXXX..XXXXXXX
71
--- /dev/null
72
+++ b/hw/misc/pvpanic-isa.c
73
@@ -XXX,XX +XXX,XX @@
74
+/*
75
+ * QEMU simulated pvpanic device.
76
+ *
77
+ * Copyright Fujitsu, Corp. 2013
78
+ *
79
+ * Authors:
80
+ * Wen Congyang <wency@cn.fujitsu.com>
81
+ * Hu Tao <hutao@cn.fujitsu.com>
82
+ *
83
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
84
+ * See the COPYING file in the top-level directory.
85
+ *
86
+ */
87
+
88
+#include "qemu/osdep.h"
89
+#include "qemu/log.h"
90
+#include "qemu/module.h"
91
+#include "sysemu/runstate.h"
92
+
93
+#include "hw/nvram/fw_cfg.h"
94
+#include "hw/qdev-properties.h"
95
+#include "hw/misc/pvpanic.h"
96
+#include "qom/object.h"
97
+#include "hw/isa/isa.h"
98
+
99
+OBJECT_DECLARE_SIMPLE_TYPE(PVPanicISAState, PVPANIC_ISA_DEVICE)
100
+
101
+/*
102
+ * PVPanicISAState for ISA device and
103
+ * use ioport.
104
+ */
105
+struct PVPanicISAState {
106
+ ISADevice parent_obj;
107
+
108
+ uint16_t ioport;
109
+ PVPanicState pvpanic;
110
+};
111
+
112
+static void pvpanic_isa_initfn(Object *obj)
113
+{
114
+ PVPanicISAState *s = PVPANIC_ISA_DEVICE(obj);
115
+
116
+ pvpanic_setup_io(&s->pvpanic, DEVICE(s), 1);
50
+}
117
+}
51
+
118
+
52
+ADVSIMD_HALFOP(min)
119
+static void pvpanic_isa_realizefn(DeviceState *dev, Error **errp)
53
+ADVSIMD_HALFOP(max)
120
+{
54
+ADVSIMD_HALFOP(minnum)
121
+ ISADevice *d = ISA_DEVICE(dev);
55
+ADVSIMD_HALFOP(maxnum)
122
+ PVPanicISAState *s = PVPANIC_ISA_DEVICE(dev);
56
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
123
+ PVPanicState *ps = &s->pvpanic;
57
index XXXXXXX..XXXXXXX 100644
124
+ FWCfgState *fw_cfg = fw_cfg_find();
58
--- a/target/arm/translate-a64.c
125
+ uint16_t *pvpanic_port;
59
+++ b/target/arm/translate-a64.c
126
+
60
@@ -XXX,XX +XXX,XX @@ static void disas_simd_zip_trn(DisasContext *s, uint32_t insn)
127
+ if (!fw_cfg) {
61
tcg_temp_free_i64(tcg_resh);
128
+ return;
62
}
129
+ }
63
130
+
64
-static void do_minmaxop(DisasContext *s, TCGv_i32 tcg_elt1, TCGv_i32 tcg_elt2,
131
+ pvpanic_port = g_malloc(sizeof(*pvpanic_port));
65
- int opc, bool is_min, TCGv_ptr fpst)
132
+ *pvpanic_port = cpu_to_le16(s->ioport);
66
+/*
133
+ fw_cfg_add_file(fw_cfg, "etc/pvpanic-port", pvpanic_port,
67
+ * do_reduction_op helper
134
+ sizeof(*pvpanic_port));
68
+ *
135
+
69
+ * This mirrors the Reduce() pseudocode in the ARM ARM. It is
136
+ isa_register_ioport(d, &ps->mr, s->ioport);
70
+ * important for correct NaN propagation that we do these
137
+}
71
+ * operations in exactly the order specified by the pseudocode.
138
+
72
+ *
139
+static Property pvpanic_isa_properties[] = {
73
+ * This is a recursive function, TCG temps should be freed by the
140
+ DEFINE_PROP_UINT16(PVPANIC_IOPORT_PROP, PVPanicISAState, ioport, 0x505),
74
+ * calling function once it is done with the values.
141
+ DEFINE_PROP_UINT8("events", PVPanicISAState, pvpanic.events, PVPANIC_PANICKED | PVPANIC_CRASHLOADED),
75
+ */
142
+ DEFINE_PROP_END_OF_LIST(),
76
+static TCGv_i32 do_reduction_op(DisasContext *s, int fpopcode, int rn,
143
+};
77
+ int esize, int size, int vmap, TCGv_ptr fpst)
144
+
78
{
145
+static void pvpanic_isa_class_init(ObjectClass *klass, void *data)
79
- /* Helper function for disas_simd_across_lanes: do a single precision
146
+{
80
- * min/max operation on the specified two inputs,
147
+ DeviceClass *dc = DEVICE_CLASS(klass);
81
- * and return the result in tcg_elt1.
148
+
82
- */
149
+ dc->realize = pvpanic_isa_realizefn;
83
- if (opc == 0xc) {
150
+ device_class_set_props(dc, pvpanic_isa_properties);
84
- if (is_min) {
151
+ set_bit(DEVICE_CATEGORY_MISC, dc->categories);
85
- gen_helper_vfp_minnums(tcg_elt1, tcg_elt1, tcg_elt2, fpst);
152
+}
86
- } else {
153
+
87
- gen_helper_vfp_maxnums(tcg_elt1, tcg_elt1, tcg_elt2, fpst);
154
+static TypeInfo pvpanic_isa_info = {
88
- }
155
+ .name = TYPE_PVPANIC_ISA_DEVICE,
89
+ if (esize == size) {
156
+ .parent = TYPE_ISA_DEVICE,
90
+ int element;
157
+ .instance_size = sizeof(PVPanicISAState),
91
+ TCGMemOp msize = esize == 16 ? MO_16 : MO_32;
158
+ .instance_init = pvpanic_isa_initfn,
92
+ TCGv_i32 tcg_elem;
159
+ .class_init = pvpanic_isa_class_init,
93
+
160
+};
94
+ /* We should have one register left here */
161
+
95
+ assert(ctpop8(vmap) == 1);
162
+static void pvpanic_register_types(void)
96
+ element = ctz32(vmap);
163
+{
97
+ assert(element < 8);
164
+ type_register_static(&pvpanic_isa_info);
98
+
165
+}
99
+ tcg_elem = tcg_temp_new_i32();
166
+
100
+ read_vec_element_i32(s, tcg_elem, rn, element, msize);
167
+type_init(pvpanic_register_types)
101
+ return tcg_elem;
168
diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c
102
} else {
169
index XXXXXXX..XXXXXXX 100644
103
- assert(opc == 0xf);
170
--- a/hw/misc/pvpanic.c
104
- if (is_min) {
171
+++ b/hw/misc/pvpanic.c
105
- gen_helper_vfp_mins(tcg_elt1, tcg_elt1, tcg_elt2, fpst);
172
@@ -XXX,XX +XXX,XX @@
106
- } else {
173
#include "hw/misc/pvpanic.h"
107
- gen_helper_vfp_maxs(tcg_elt1, tcg_elt1, tcg_elt2, fpst);
174
#include "qom/object.h"
108
+ int bits = size / 2;
175
109
+ int shift = ctpop8(vmap) / 2;
176
-/* The bit of supported pv event, TODO: include uapi header and remove this */
110
+ int vmap_lo = (vmap >> shift) & vmap;
177
-#define PVPANIC_F_PANICKED 0
111
+ int vmap_hi = (vmap & ~vmap_lo);
178
-#define PVPANIC_F_CRASHLOADED 1
112
+ TCGv_i32 tcg_hi, tcg_lo, tcg_res;
179
-
113
+
180
-/* The pv event value */
114
+ tcg_hi = do_reduction_op(s, fpopcode, rn, esize, bits, vmap_hi, fpst);
181
-#define PVPANIC_PANICKED (1 << PVPANIC_F_PANICKED)
115
+ tcg_lo = do_reduction_op(s, fpopcode, rn, esize, bits, vmap_lo, fpst);
182
-#define PVPANIC_CRASHLOADED (1 << PVPANIC_F_CRASHLOADED)
116
+ tcg_res = tcg_temp_new_i32();
183
-
117
+
184
-typedef struct PVPanicState PVPanicState;
118
+ switch (fpopcode) {
185
-DECLARE_INSTANCE_CHECKER(PVPanicState, ISA_PVPANIC_DEVICE,
119
+ case 0x0c: /* fmaxnmv half-precision */
186
- TYPE_PVPANIC)
120
+ gen_helper_advsimd_maxnumh(tcg_res, tcg_lo, tcg_hi, fpst);
187
-
121
+ break;
188
static void handle_event(int event)
122
+ case 0x0f: /* fmaxv half-precision */
189
{
123
+ gen_helper_advsimd_maxh(tcg_res, tcg_lo, tcg_hi, fpst);
190
static bool logged;
124
+ break;
191
@@ -XXX,XX +XXX,XX @@ static void handle_event(int event)
125
+ case 0x1c: /* fminnmv half-precision */
126
+ gen_helper_advsimd_minnumh(tcg_res, tcg_lo, tcg_hi, fpst);
127
+ break;
128
+ case 0x1f: /* fminv half-precision */
129
+ gen_helper_advsimd_minh(tcg_res, tcg_lo, tcg_hi, fpst);
130
+ break;
131
+ case 0x2c: /* fmaxnmv */
132
+ gen_helper_vfp_maxnums(tcg_res, tcg_lo, tcg_hi, fpst);
133
+ break;
134
+ case 0x2f: /* fmaxv */
135
+ gen_helper_vfp_maxs(tcg_res, tcg_lo, tcg_hi, fpst);
136
+ break;
137
+ case 0x3c: /* fminnmv */
138
+ gen_helper_vfp_minnums(tcg_res, tcg_lo, tcg_hi, fpst);
139
+ break;
140
+ case 0x3f: /* fminv */
141
+ gen_helper_vfp_mins(tcg_res, tcg_lo, tcg_hi, fpst);
142
+ break;
143
+ default:
144
+ g_assert_not_reached();
145
}
146
+
147
+ tcg_temp_free_i32(tcg_hi);
148
+ tcg_temp_free_i32(tcg_lo);
149
+ return tcg_res;
150
}
192
}
151
}
193
}
152
194
153
@@ -XXX,XX +XXX,XX @@ static void disas_simd_across_lanes(DisasContext *s, uint32_t insn)
195
-#include "hw/isa/isa.h"
154
break;
196
-
155
case 0xc: /* FMAXNMV, FMINNMV */
197
-struct PVPanicState {
156
case 0xf: /* FMAXV, FMINV */
198
- ISADevice parent_obj;
157
- if (!is_u || !is_q || extract32(size, 0, 1)) {
199
-
158
- unallocated_encoding(s);
200
- MemoryRegion io;
159
- return;
201
- uint16_t ioport;
160
- }
202
- uint8_t events;
161
- /* Bit 1 of size field encodes min vs max, and actual size is always
203
-};
162
- * 32 bits: adjust the size variable so following code can rely on it
204
-
163
+ /* Bit 1 of size field encodes min vs max and the actual size
205
/* return supported events on read */
164
+ * depends on the encoding of the U bit. If not set (and FP16
206
-static uint64_t pvpanic_ioport_read(void *opaque, hwaddr addr, unsigned size)
165
+ * enabled) then we do half-precision float instead of single
207
+static uint64_t pvpanic_read(void *opaque, hwaddr addr, unsigned size)
166
+ * precision.
208
{
167
*/
209
PVPanicState *pvp = opaque;
168
is_min = extract32(size, 1, 1);
210
return pvp->events;
169
is_fp = true;
211
}
170
- size = 2;
212
171
+ if (!is_u && arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
213
-static void pvpanic_ioport_write(void *opaque, hwaddr addr, uint64_t val,
172
+ size = 1;
214
+static void pvpanic_write(void *opaque, hwaddr addr, uint64_t val,
173
+ } else if (!is_u || !is_q || extract32(size, 0, 1)) {
215
unsigned size)
174
+ unallocated_encoding(s);
216
{
175
+ return;
217
handle_event(val);
176
+ } else {
218
}
177
+ size = 2;
219
178
+ }
220
static const MemoryRegionOps pvpanic_ops = {
179
break;
221
- .read = pvpanic_ioport_read,
180
default:
222
- .write = pvpanic_ioport_write,
181
unallocated_encoding(s);
223
+ .read = pvpanic_read,
182
@@ -XXX,XX +XXX,XX @@ static void disas_simd_across_lanes(DisasContext *s, uint32_t insn)
224
+ .write = pvpanic_write,
183
225
.impl = {
184
}
226
.min_access_size = 1,
185
} else {
227
.max_access_size = 1,
186
- /* Floating point ops which work on 32 bit (single) intermediates.
228
},
187
+ /* Floating point vector reduction ops which work across 32
229
};
188
+ * bit (single) or 16 bit (half-precision) intermediates.
230
189
* Note that correct NaN propagation requires that we do these
231
-static void pvpanic_isa_initfn(Object *obj)
190
* operations in exactly the order specified by the pseudocode.
232
+void pvpanic_setup_io(PVPanicState *s, DeviceState *dev, unsigned size)
191
*/
233
{
192
- TCGv_i32 tcg_elt1 = tcg_temp_new_i32();
234
- PVPanicState *s = ISA_PVPANIC_DEVICE(obj);
193
- TCGv_i32 tcg_elt2 = tcg_temp_new_i32();
235
-
194
- TCGv_i32 tcg_elt3 = tcg_temp_new_i32();
236
- memory_region_init_io(&s->io, OBJECT(s), &pvpanic_ops, s, "pvpanic", 1);
195
- TCGv_ptr fpst = get_fpstatus_ptr(false);
237
+ memory_region_init_io(&s->mr, OBJECT(dev), &pvpanic_ops, s, "pvpanic", size);
196
-
238
}
197
- assert(esize == 32);
239
-
198
- assert(elements == 4);
240
-static void pvpanic_isa_realizefn(DeviceState *dev, Error **errp)
199
-
241
-{
200
- read_vec_element(s, tcg_elt, rn, 0, MO_32);
242
- ISADevice *d = ISA_DEVICE(dev);
201
- tcg_gen_extrl_i64_i32(tcg_elt1, tcg_elt);
243
- PVPanicState *s = ISA_PVPANIC_DEVICE(dev);
202
- read_vec_element(s, tcg_elt, rn, 1, MO_32);
244
- FWCfgState *fw_cfg = fw_cfg_find();
203
- tcg_gen_extrl_i64_i32(tcg_elt2, tcg_elt);
245
- uint16_t *pvpanic_port;
204
-
246
-
205
- do_minmaxop(s, tcg_elt1, tcg_elt2, opcode, is_min, fpst);
247
- if (!fw_cfg) {
206
-
248
- return;
207
- read_vec_element(s, tcg_elt, rn, 2, MO_32);
249
- }
208
- tcg_gen_extrl_i64_i32(tcg_elt2, tcg_elt);
250
-
209
- read_vec_element(s, tcg_elt, rn, 3, MO_32);
251
- pvpanic_port = g_malloc(sizeof(*pvpanic_port));
210
- tcg_gen_extrl_i64_i32(tcg_elt3, tcg_elt);
252
- *pvpanic_port = cpu_to_le16(s->ioport);
211
-
253
- fw_cfg_add_file(fw_cfg, "etc/pvpanic-port", pvpanic_port,
212
- do_minmaxop(s, tcg_elt2, tcg_elt3, opcode, is_min, fpst);
254
- sizeof(*pvpanic_port));
213
-
255
-
214
- do_minmaxop(s, tcg_elt1, tcg_elt2, opcode, is_min, fpst);
256
- isa_register_ioport(d, &s->io, s->ioport);
215
-
257
-}
216
- tcg_gen_extu_i32_i64(tcg_res, tcg_elt1);
258
-
217
- tcg_temp_free_i32(tcg_elt1);
259
-static Property pvpanic_isa_properties[] = {
218
- tcg_temp_free_i32(tcg_elt2);
260
- DEFINE_PROP_UINT16(PVPANIC_IOPORT_PROP, PVPanicState, ioport, 0x505),
219
- tcg_temp_free_i32(tcg_elt3);
261
- DEFINE_PROP_UINT8("events", PVPanicState, events, PVPANIC_PANICKED | PVPANIC_CRASHLOADED),
220
+ TCGv_ptr fpst = get_fpstatus_ptr(size == MO_16);
262
- DEFINE_PROP_END_OF_LIST(),
221
+ int fpopcode = opcode | is_min << 4 | is_u << 5;
263
-};
222
+ int vmap = (1 << elements) - 1;
264
-
223
+ TCGv_i32 tcg_res32 = do_reduction_op(s, fpopcode, rn, esize,
265
-static void pvpanic_isa_class_init(ObjectClass *klass, void *data)
224
+ (is_q ? 128 : 64), vmap, fpst);
266
-{
225
+ tcg_gen_extu_i32_i64(tcg_res, tcg_res32);
267
- DeviceClass *dc = DEVICE_CLASS(klass);
226
+ tcg_temp_free_i32(tcg_res32);
268
-
227
tcg_temp_free_ptr(fpst);
269
- dc->realize = pvpanic_isa_realizefn;
228
}
270
- device_class_set_props(dc, pvpanic_isa_properties);
229
271
- set_bit(DEVICE_CATEGORY_MISC, dc->categories);
272
-}
273
-
274
-static TypeInfo pvpanic_isa_info = {
275
- .name = TYPE_PVPANIC,
276
- .parent = TYPE_ISA_DEVICE,
277
- .instance_size = sizeof(PVPanicState),
278
- .instance_init = pvpanic_isa_initfn,
279
- .class_init = pvpanic_isa_class_init,
280
-};
281
-
282
-static void pvpanic_register_types(void)
283
-{
284
- type_register_static(&pvpanic_isa_info);
285
-}
286
-
287
-type_init(pvpanic_register_types)
288
diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig
289
index XXXXXXX..XXXXXXX 100644
290
--- a/hw/i386/Kconfig
291
+++ b/hw/i386/Kconfig
292
@@ -XXX,XX +XXX,XX @@ config PC
293
imply ISA_DEBUG
294
imply PARALLEL
295
imply PCI_DEVICES
296
- imply PVPANIC
297
+ imply PVPANIC_ISA
298
imply QXL
299
imply SEV
300
imply SGA
301
diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
302
index XXXXXXX..XXXXXXX 100644
303
--- a/hw/misc/Kconfig
304
+++ b/hw/misc/Kconfig
305
@@ -XXX,XX +XXX,XX @@ config IOTKIT_SYSCTL
306
config IOTKIT_SYSINFO
307
bool
308
309
-config PVPANIC
310
+config PVPANIC_COMMON
311
+ bool
312
+
313
+config PVPANIC_ISA
314
bool
315
depends on ISA_BUS
316
+ select PVPANIC_COMMON
317
318
config AUX
319
bool
320
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
321
index XXXXXXX..XXXXXXX 100644
322
--- a/hw/misc/meson.build
323
+++ b/hw/misc/meson.build
324
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_EMC141X', if_true: files('emc141x.c'))
325
softmmu_ss.add(when: 'CONFIG_UNIMP', if_true: files('unimp.c'))
326
softmmu_ss.add(when: 'CONFIG_EMPTY_SLOT', if_true: files('empty_slot.c'))
327
softmmu_ss.add(when: 'CONFIG_LED', if_true: files('led.c'))
328
+softmmu_ss.add(when: 'CONFIG_PVPANIC_COMMON', if_true: files('pvpanic.c'))
329
330
# ARM devices
331
softmmu_ss.add(when: 'CONFIG_PL310', if_true: files('arm_l2x0.c'))
332
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_IOTKIT_SYSINFO', if_true: files('iotkit-sysinfo.c')
333
softmmu_ss.add(when: 'CONFIG_ARMSSE_CPUID', if_true: files('armsse-cpuid.c'))
334
softmmu_ss.add(when: 'CONFIG_ARMSSE_MHU', if_true: files('armsse-mhu.c'))
335
336
-softmmu_ss.add(when: 'CONFIG_PVPANIC', if_true: files('pvpanic.c'))
337
+softmmu_ss.add(when: 'CONFIG_PVPANIC_ISA', if_true: files('pvpanic-isa.c'))
338
softmmu_ss.add(when: 'CONFIG_AUX', if_true: files('auxbus.c'))
339
softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_scu.c', 'aspeed_sdmc.c', 'aspeed_xdma.c'))
340
softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('msf2-sysreg.c'))
341
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
342
index XXXXXXX..XXXXXXX 100644
343
--- a/tests/qtest/meson.build
344
+++ b/tests/qtest/meson.build
345
@@ -XXX,XX +XXX,XX @@ qtests_i386 = \
346
(config_host.has_key('CONFIG_LINUX') and \
347
config_all_devices.has_key('CONFIG_ISA_IPMI_BT') ? ['ipmi-bt-test'] : []) + \
348
(config_all_devices.has_key('CONFIG_WDT_IB700') ? ['wdt_ib700-test'] : []) + \
349
- (config_all_devices.has_key('CONFIG_PVPANIC') ? ['pvpanic-test'] : []) + \
350
+ (config_all_devices.has_key('CONFIG_PVPANIC_ISA') ? ['pvpanic-test'] : []) + \
351
(config_all_devices.has_key('CONFIG_HDA') ? ['intel-hda-test'] : []) + \
352
(config_all_devices.has_key('CONFIG_I82801B11') ? ['i82801b11-test'] : []) + \
353
(config_all_devices.has_key('CONFIG_IOH3420') ? ['ioh3420-test'] : []) + \
230
--
354
--
231
2.16.2
355
2.20.1
232
356
233
357
diff view generated by jsdifflib
1
From: Linus Walleij <linus.walleij@linaro.org>
1
From: Mihai Carabas <mihai.carabas@oracle.com>
2
2
3
This adds support for emulating the Silicon Image SII9022 DVI/HDMI
3
Add PCI interface support for PVPANIC device. Create a new file pvpanic-pci.c
4
bridge. It's not very clever right now, it just acknowledges
4
where the PCI specific routines reside and update the build system with the new
5
the switch into DDC I2C mode and back. Combining this with the
5
files and config structure.
6
existing DDC I2C emulation gives the right behavior on the Versatile
7
Express emulation passing through the QEMU EDID to the emulated
8
platform.
9
6
10
Cc: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
11
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
8
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
12
Message-id: 20180227104903.21353-5-linus.walleij@linaro.org
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
14
[PMM: explictly reset ddc_req/ddc_skip_finish/ddc]
10
Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
---
12
---
17
hw/display/Makefile.objs | 1 +
13
docs/specs/pci-ids.txt | 1 +
18
hw/display/sii9022.c | 191 +++++++++++++++++++++++++++++++++++++++++++++++
14
include/hw/misc/pvpanic.h | 1 +
19
hw/display/trace-events | 5 ++
15
include/hw/pci/pci.h | 1 +
20
3 files changed, 197 insertions(+)
16
hw/misc/pvpanic-pci.c | 94 +++++++++++++++++++++++++++++++++++++++
21
create mode 100644 hw/display/sii9022.c
17
hw/misc/Kconfig | 6 +++
18
hw/misc/meson.build | 1 +
19
6 files changed, 104 insertions(+)
20
create mode 100644 hw/misc/pvpanic-pci.c
22
21
23
diff --git a/hw/display/Makefile.objs b/hw/display/Makefile.objs
22
diff --git a/docs/specs/pci-ids.txt b/docs/specs/pci-ids.txt
24
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
25
--- a/hw/display/Makefile.objs
24
--- a/docs/specs/pci-ids.txt
26
+++ b/hw/display/Makefile.objs
25
+++ b/docs/specs/pci-ids.txt
27
@@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_VGA_CIRRUS) += cirrus_vga.o
26
@@ -XXX,XX +XXX,XX @@ PCI devices (other than virtio):
28
common-obj-$(CONFIG_G364FB) += g364fb.o
27
1b36:000d PCI xhci usb host adapter
29
common-obj-$(CONFIG_JAZZ_LED) += jazz_led.o
28
1b36:000f mdpy (mdev sample device), linux/samples/vfio-mdev/mdpy.c
30
common-obj-$(CONFIG_PL110) += pl110.o
29
1b36:0010 PCIe NVMe device (-device nvme)
31
+common-obj-$(CONFIG_SII9022) += sii9022.o
30
+1b36:0011 PCI PVPanic device (-device pvpanic-pci)
32
common-obj-$(CONFIG_SSD0303) += ssd0303.o
31
33
common-obj-$(CONFIG_SSD0323) += ssd0323.o
32
All these devices are documented in docs/specs.
34
common-obj-$(CONFIG_XEN) += xenfb.o
33
35
diff --git a/hw/display/sii9022.c b/hw/display/sii9022.c
34
diff --git a/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.h
35
index XXXXXXX..XXXXXXX 100644
36
--- a/include/hw/misc/pvpanic.h
37
+++ b/include/hw/misc/pvpanic.h
38
@@ -XXX,XX +XXX,XX @@
39
#include "qom/object.h"
40
41
#define TYPE_PVPANIC_ISA_DEVICE "pvpanic"
42
+#define TYPE_PVPANIC_PCI_DEVICE "pvpanic-pci"
43
44
#define PVPANIC_IOPORT_PROP "ioport"
45
46
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
47
index XXXXXXX..XXXXXXX 100644
48
--- a/include/hw/pci/pci.h
49
+++ b/include/hw/pci/pci.h
50
@@ -XXX,XX +XXX,XX @@ extern bool pci_available;
51
#define PCI_DEVICE_ID_REDHAT_PCIE_BRIDGE 0x000e
52
#define PCI_DEVICE_ID_REDHAT_MDPY 0x000f
53
#define PCI_DEVICE_ID_REDHAT_NVME 0x0010
54
+#define PCI_DEVICE_ID_REDHAT_PVPANIC 0x0011
55
#define PCI_DEVICE_ID_REDHAT_QXL 0x0100
56
57
#define FMT_PCIBUS PRIx64
58
diff --git a/hw/misc/pvpanic-pci.c b/hw/misc/pvpanic-pci.c
36
new file mode 100644
59
new file mode 100644
37
index XXXXXXX..XXXXXXX
60
index XXXXXXX..XXXXXXX
38
--- /dev/null
61
--- /dev/null
39
+++ b/hw/display/sii9022.c
62
+++ b/hw/misc/pvpanic-pci.c
40
@@ -XXX,XX +XXX,XX @@
63
@@ -XXX,XX +XXX,XX @@
41
+/*
64
+/*
42
+ * Silicon Image SiI9022
65
+ * QEMU simulated PCI pvpanic device.
43
+ *
66
+ *
44
+ * This is a pretty hollow emulation: all we do is acknowledge that we
67
+ * Copyright (C) 2020 Oracle
45
+ * exist (chip ID) and confirm that we get switched over into DDC mode
46
+ * so the emulated host can proceed to read out EDID data. All subsequent
47
+ * set-up of connectors etc will be acknowledged and ignored.
48
+ *
68
+ *
49
+ * Copyright (C) 2018 Linus Walleij
69
+ * Authors:
70
+ * Mihai Carabas <mihai.carabas@oracle.com>
50
+ *
71
+ *
51
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
72
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
52
+ * See the COPYING file in the top-level directory.
73
+ * See the COPYING file in the top-level directory.
53
+ * SPDX-License-Identifier: GPL-2.0-or-later
74
+ *
54
+ */
75
+ */
55
+
76
+
56
+#include "qemu/osdep.h"
77
+#include "qemu/osdep.h"
57
+#include "qemu-common.h"
78
+#include "qemu/log.h"
58
+#include "hw/i2c/i2c.h"
79
+#include "qemu/module.h"
59
+#include "hw/i2c/i2c-ddc.h"
80
+#include "sysemu/runstate.h"
60
+#include "trace.h"
61
+
81
+
62
+#define SII9022_SYS_CTRL_DATA 0x1a
82
+#include "hw/nvram/fw_cfg.h"
63
+#define SII9022_SYS_CTRL_PWR_DWN 0x10
83
+#include "hw/qdev-properties.h"
64
+#define SII9022_SYS_CTRL_AV_MUTE 0x08
84
+#include "migration/vmstate.h"
65
+#define SII9022_SYS_CTRL_DDC_BUS_REQ 0x04
85
+#include "hw/misc/pvpanic.h"
66
+#define SII9022_SYS_CTRL_DDC_BUS_GRTD 0x02
86
+#include "qom/object.h"
67
+#define SII9022_SYS_CTRL_OUTPUT_MODE 0x01
87
+#include "hw/pci/pci.h"
68
+#define SII9022_SYS_CTRL_OUTPUT_HDMI 1
69
+#define SII9022_SYS_CTRL_OUTPUT_DVI 0
70
+#define SII9022_REG_CHIPID 0x1b
71
+#define SII9022_INT_ENABLE 0x3c
72
+#define SII9022_INT_STATUS 0x3d
73
+#define SII9022_INT_STATUS_HOTPLUG 0x01;
74
+#define SII9022_INT_STATUS_PLUGGED 0x04;
75
+
88
+
76
+#define TYPE_SII9022 "sii9022"
89
+OBJECT_DECLARE_SIMPLE_TYPE(PVPanicPCIState, PVPANIC_PCI_DEVICE)
77
+#define SII9022(obj) OBJECT_CHECK(sii9022_state, (obj), TYPE_SII9022)
78
+
90
+
79
+typedef struct sii9022_state {
91
+/*
80
+ I2CSlave parent_obj;
92
+ * PVPanicPCIState for PCI device
81
+ uint8_t ptr;
93
+ */
82
+ bool addr_byte;
94
+typedef struct PVPanicPCIState {
83
+ bool ddc_req;
95
+ PCIDevice dev;
84
+ bool ddc_skip_finish;
96
+ PVPanicState pvpanic;
85
+ bool ddc;
97
+} PVPanicPCIState;
86
+} sii9022_state;
87
+
98
+
88
+static const VMStateDescription vmstate_sii9022 = {
99
+static const VMStateDescription vmstate_pvpanic_pci = {
89
+ .name = "sii9022",
100
+ .name = "pvpanic-pci",
90
+ .version_id = 1,
101
+ .version_id = 1,
91
+ .minimum_version_id = 1,
102
+ .minimum_version_id = 1,
92
+ .fields = (VMStateField[]) {
103
+ .fields = (VMStateField[]) {
93
+ VMSTATE_I2C_SLAVE(parent_obj, sii9022_state),
104
+ VMSTATE_PCI_DEVICE(dev, PVPanicPCIState),
94
+ VMSTATE_UINT8(ptr, sii9022_state),
95
+ VMSTATE_BOOL(addr_byte, sii9022_state),
96
+ VMSTATE_BOOL(ddc_req, sii9022_state),
97
+ VMSTATE_BOOL(ddc_skip_finish, sii9022_state),
98
+ VMSTATE_BOOL(ddc, sii9022_state),
99
+ VMSTATE_END_OF_LIST()
105
+ VMSTATE_END_OF_LIST()
100
+ }
106
+ }
101
+};
107
+};
102
+
108
+
103
+static int sii9022_event(I2CSlave *i2c, enum i2c_event event)
109
+static void pvpanic_pci_realizefn(PCIDevice *dev, Error **errp)
104
+{
110
+{
105
+ sii9022_state *s = SII9022(i2c);
111
+ PVPanicPCIState *s = PVPANIC_PCI_DEVICE(dev);
112
+ PVPanicState *ps = &s->pvpanic;
106
+
113
+
107
+ switch (event) {
114
+ pvpanic_setup_io(&s->pvpanic, DEVICE(s), 2);
108
+ case I2C_START_SEND:
109
+ s->addr_byte = true;
110
+ break;
111
+ case I2C_START_RECV:
112
+ break;
113
+ case I2C_FINISH:
114
+ break;
115
+ case I2C_NACK:
116
+ break;
117
+ }
118
+
115
+
119
+ return 0;
116
+ pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &ps->mr);
120
+}
117
+}
121
+
118
+
122
+static int sii9022_rx(I2CSlave *i2c)
119
+static Property pvpanic_pci_properties[] = {
120
+ DEFINE_PROP_UINT8("events", PVPanicPCIState, pvpanic.events, PVPANIC_PANICKED | PVPANIC_CRASHLOADED),
121
+ DEFINE_PROP_END_OF_LIST(),
122
+};
123
+
124
+static void pvpanic_pci_class_init(ObjectClass *klass, void *data)
123
+{
125
+{
124
+ sii9022_state *s = SII9022(i2c);
126
+ DeviceClass *dc = DEVICE_CLASS(klass);
125
+ uint8_t res = 0x00;
127
+ PCIDeviceClass *pc = PCI_DEVICE_CLASS(klass);
126
+
128
+
127
+ switch (s->ptr) {
129
+ device_class_set_props(dc, pvpanic_pci_properties);
128
+ case SII9022_SYS_CTRL_DATA:
129
+ if (s->ddc_req) {
130
+ /* Acknowledge DDC bus request */
131
+ res = SII9022_SYS_CTRL_DDC_BUS_GRTD | SII9022_SYS_CTRL_DDC_BUS_REQ;
132
+ }
133
+ break;
134
+ case SII9022_REG_CHIPID:
135
+ res = 0xb0;
136
+ break;
137
+ case SII9022_INT_STATUS:
138
+ /* Something is cold-plugged in, no interrupts */
139
+ res = SII9022_INT_STATUS_PLUGGED;
140
+ break;
141
+ default:
142
+ break;
143
+ }
144
+
130
+
145
+ trace_sii9022_read_reg(s->ptr, res);
131
+ pc->realize = pvpanic_pci_realizefn;
146
+ s->ptr++;
132
+ pc->vendor_id = PCI_VENDOR_ID_REDHAT;
133
+ pc->device_id = PCI_DEVICE_ID_REDHAT_PVPANIC;
134
+ pc->revision = 1;
135
+ pc->class_id = PCI_CLASS_SYSTEM_OTHER;
136
+ dc->vmsd = &vmstate_pvpanic_pci;
147
+
137
+
148
+ return res;
138
+ set_bit(DEVICE_CATEGORY_MISC, dc->categories);
149
+}
139
+}
150
+
140
+
151
+static int sii9022_tx(I2CSlave *i2c, uint8_t data)
141
+static TypeInfo pvpanic_pci_info = {
142
+ .name = TYPE_PVPANIC_PCI_DEVICE,
143
+ .parent = TYPE_PCI_DEVICE,
144
+ .instance_size = sizeof(PVPanicPCIState),
145
+ .class_init = pvpanic_pci_class_init,
146
+ .interfaces = (InterfaceInfo[]) {
147
+ { INTERFACE_CONVENTIONAL_PCI_DEVICE },
148
+ { }
149
+ }
150
+};
151
+
152
+static void pvpanic_register_types(void)
152
+{
153
+{
153
+ sii9022_state *s = SII9022(i2c);
154
+ type_register_static(&pvpanic_pci_info);
154
+
155
+ if (s->addr_byte) {
156
+ s->ptr = data;
157
+ s->addr_byte = false;
158
+ return 0;
159
+ }
160
+
161
+ switch (s->ptr) {
162
+ case SII9022_SYS_CTRL_DATA:
163
+ if (data & SII9022_SYS_CTRL_DDC_BUS_REQ) {
164
+ s->ddc_req = true;
165
+ if (data & SII9022_SYS_CTRL_DDC_BUS_GRTD) {
166
+ s->ddc = true;
167
+ /* Skip this finish since we just switched to DDC */
168
+ s->ddc_skip_finish = true;
169
+ trace_sii9022_switch_mode("DDC");
170
+ }
171
+ } else {
172
+ s->ddc_req = false;
173
+ s->ddc = false;
174
+ trace_sii9022_switch_mode("normal");
175
+ }
176
+ break;
177
+ default:
178
+ break;
179
+ }
180
+
181
+ trace_sii9022_write_reg(s->ptr, data);
182
+ s->ptr++;
183
+
184
+ return 0;
185
+}
155
+}
186
+
156
+
187
+static void sii9022_reset(DeviceState *dev)
157
+type_init(pvpanic_register_types);
188
+{
158
diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
189
+ sii9022_state *s = SII9022(dev);
159
index XXXXXXX..XXXXXXX 100644
160
--- a/hw/misc/Kconfig
161
+++ b/hw/misc/Kconfig
162
@@ -XXX,XX +XXX,XX @@ config IOTKIT_SYSINFO
163
config PVPANIC_COMMON
164
bool
165
166
+config PVPANIC_PCI
167
+ bool
168
+ default y if PCI_DEVICES
169
+ depends on PCI
170
+ select PVPANIC_COMMON
190
+
171
+
191
+ s->ptr = 0;
172
config PVPANIC_ISA
192
+ s->addr_byte = false;
173
bool
193
+ s->ddc_req = false;
174
depends on ISA_BUS
194
+ s->ddc_skip_finish = false;
175
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
195
+ s->ddc = false;
196
+}
197
+
198
+static void sii9022_realize(DeviceState *dev, Error **errp)
199
+{
200
+ I2CBus *bus;
201
+
202
+ bus = I2C_BUS(qdev_get_parent_bus(dev));
203
+ i2c_create_slave(bus, TYPE_I2CDDC, 0x50);
204
+}
205
+
206
+static void sii9022_class_init(ObjectClass *klass, void *data)
207
+{
208
+ DeviceClass *dc = DEVICE_CLASS(klass);
209
+ I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
210
+
211
+ k->event = sii9022_event;
212
+ k->recv = sii9022_rx;
213
+ k->send = sii9022_tx;
214
+ dc->reset = sii9022_reset;
215
+ dc->realize = sii9022_realize;
216
+ dc->vmsd = &vmstate_sii9022;
217
+}
218
+
219
+static const TypeInfo sii9022_info = {
220
+ .name = TYPE_SII9022,
221
+ .parent = TYPE_I2C_SLAVE,
222
+ .instance_size = sizeof(sii9022_state),
223
+ .class_init = sii9022_class_init,
224
+};
225
+
226
+static void sii9022_register_types(void)
227
+{
228
+ type_register_static(&sii9022_info);
229
+}
230
+
231
+type_init(sii9022_register_types)
232
diff --git a/hw/display/trace-events b/hw/display/trace-events
233
index XXXXXXX..XXXXXXX 100644
176
index XXXXXXX..XXXXXXX 100644
234
--- a/hw/display/trace-events
177
--- a/hw/misc/meson.build
235
+++ b/hw/display/trace-events
178
+++ b/hw/misc/meson.build
236
@@ -XXX,XX +XXX,XX @@ vga_cirrus_read_io(uint32_t addr, uint32_t val) "addr 0x%x, val 0x%x"
179
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_ARMSSE_CPUID', if_true: files('armsse-cpuid.c'))
237
vga_cirrus_write_io(uint32_t addr, uint32_t val) "addr 0x%x, val 0x%x"
180
softmmu_ss.add(when: 'CONFIG_ARMSSE_MHU', if_true: files('armsse-mhu.c'))
238
vga_cirrus_read_blt(uint32_t offset, uint32_t val) "offset 0x%x, val 0x%x"
181
239
vga_cirrus_write_blt(uint32_t offset, uint32_t val) "offset 0x%x, val 0x%x"
182
softmmu_ss.add(when: 'CONFIG_PVPANIC_ISA', if_true: files('pvpanic-isa.c'))
240
+
183
+softmmu_ss.add(when: 'CONFIG_PVPANIC_PCI', if_true: files('pvpanic-pci.c'))
241
+# hw/display/sii9022.c
184
softmmu_ss.add(when: 'CONFIG_AUX', if_true: files('auxbus.c'))
242
+sii9022_read_reg(uint8_t addr, uint8_t val) "addr 0x%02x, val 0x%02x"
185
softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_scu.c', 'aspeed_sdmc.c', 'aspeed_xdma.c'))
243
+sii9022_write_reg(uint8_t addr, uint8_t val) "addr 0x%02x, val 0x%02x"
186
softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('msf2-sysreg.c'))
244
+sii9022_switch_mode(const char *mode) "mode: %s"
245
--
187
--
246
2.16.2
188
2.20.1
247
189
248
190
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Mihai Carabas <mihai.carabas@oracle.com>
2
2
3
We do implement all the opcodes.
3
Add pvpanic PCI device support details in docs/specs/pvpanic.txt.
4
4
5
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
5
Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Message-id: 20180227143852.11175-8-alex.bennee@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
8
---
10
target/arm/translate-a64.c | 3 +--
9
docs/specs/pvpanic.txt | 13 ++++++++++++-
11
1 file changed, 1 insertion(+), 2 deletions(-)
10
1 file changed, 12 insertions(+), 1 deletion(-)
12
11
13
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
12
diff --git a/docs/specs/pvpanic.txt b/docs/specs/pvpanic.txt
14
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/translate-a64.c
14
--- a/docs/specs/pvpanic.txt
16
+++ b/target/arm/translate-a64.c
15
+++ b/docs/specs/pvpanic.txt
17
@@ -XXX,XX +XXX,XX @@ static void handle_3same_64(DisasContext *s, int opcode, bool u,
16
@@ -XXX,XX +XXX,XX @@
18
/* Handle 64x64->64 opcodes which are shared between the scalar
17
PVPANIC DEVICE
19
* and vector 3-same groups. We cover every opcode where size == 3
18
==============
20
* is valid in either the three-reg-same (integer, not pairwise)
19
21
- * or scalar-three-reg-same groups. (Some opcodes are not yet
20
-pvpanic device is a simulated ISA device, through which a guest panic
22
- * implemented.)
21
+pvpanic device is a simulated device, through which a guest panic
23
+ * or scalar-three-reg-same groups.
22
event is sent to qemu, and a QMP event is generated. This allows
24
*/
23
management apps (e.g. libvirt) to be notified and respond to the event.
25
TCGCond cond;
24
25
@@ -XXX,XX +XXX,XX @@ The management app has the option of waiting for GUEST_PANICKED events,
26
and/or polling for guest-panicked RunState, to learn when the pvpanic
27
device has fired a panic event.
28
29
+The pvpanic device can be implemented as an ISA device (using IOPORT) or as a
30
+PCI device.
31
+
32
ISA Interface
33
-------------
34
35
@@ -XXX,XX +XXX,XX @@ bit 1: a guest panic has happened and will be handled by the guest;
36
the host should record it or report it, but should not affect
37
the execution of the guest.
38
39
+PCI Interface
40
+-------------
41
+
42
+The PCI interface is similar to the ISA interface except that it uses an MMIO
43
+address space provided by its BAR0, 1 byte long. Any machine with a PCI bus
44
+can enable a pvpanic device by adding '-device pvpanic-pci' to the command
45
+line.
46
+
47
ACPI Interface
48
--------------
26
49
27
--
50
--
28
2.16.2
51
2.20.1
29
52
30
53
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Mihai Carabas <mihai.carabas@oracle.com>
2
2
3
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
3
Add a test case for pvpanic-pci device. The scenario is the same as pvpanic
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
4
ISA device, but is using the PCI bus.
5
Message-id: 20180227143852.11175-26-alex.bennee@linaro.org
5
6
Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
7
Acked-by: Thomas Huth <thuth@redhat.com>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
11
---
8
target/arm/helper-a64.h | 1 +
12
tests/qtest/pvpanic-pci-test.c | 94 ++++++++++++++++++++++++++++++++++
9
target/arm/helper-a64.c | 13 +++++++++++++
13
tests/qtest/meson.build | 1 +
10
target/arm/translate-a64.c | 5 +++++
14
2 files changed, 95 insertions(+)
11
3 files changed, 19 insertions(+)
15
create mode 100644 tests/qtest/pvpanic-pci-test.c
12
16
13
diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h
17
diff --git a/tests/qtest/pvpanic-pci-test.c b/tests/qtest/pvpanic-pci-test.c
14
index XXXXXXX..XXXXXXX 100644
18
new file mode 100644
15
--- a/target/arm/helper-a64.h
19
index XXXXXXX..XXXXXXX
16
+++ b/target/arm/helper-a64.h
20
--- /dev/null
17
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(advsimd_rinth_exact, f16, f16, ptr)
21
+++ b/tests/qtest/pvpanic-pci-test.c
18
DEF_HELPER_2(advsimd_rinth, f16, f16, ptr)
22
@@ -XXX,XX +XXX,XX @@
19
DEF_HELPER_2(advsimd_f16tosinth, i32, f16, ptr)
20
DEF_HELPER_2(advsimd_f16touinth, i32, f16, ptr)
21
+DEF_HELPER_2(sqrt_f16, f16, f16, ptr)
22
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
23
index XXXXXXX..XXXXXXX 100644
24
--- a/target/arm/helper-a64.c
25
+++ b/target/arm/helper-a64.c
26
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_f16touinth)(float16 a, void *fpstp)
27
}
28
return float16_to_uint16(a, fpst);
29
}
30
+
31
+/*
23
+/*
32
+ * Square Root and Reciprocal square root
24
+ * QTest testcase for PV Panic PCI device
25
+ *
26
+ * Copyright (C) 2020 Oracle
27
+ *
28
+ * Authors:
29
+ * Mihai Carabas <mihai.carabas@oracle.com>
30
+ *
31
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
32
+ * See the COPYING file in the top-level directory.
33
+ *
33
+ */
34
+ */
34
+
35
+
35
+float16 HELPER(sqrt_f16)(float16 a, void *fpstp)
36
+#include "qemu/osdep.h"
37
+#include "libqos/libqtest.h"
38
+#include "qapi/qmp/qdict.h"
39
+#include "libqos/pci.h"
40
+#include "libqos/pci-pc.h"
41
+#include "hw/pci/pci_regs.h"
42
+
43
+static void test_panic_nopause(void)
36
+{
44
+{
37
+ float_status *s = fpstp;
45
+ uint8_t val;
46
+ QDict *response, *data;
47
+ QTestState *qts;
48
+ QPCIBus *pcibus;
49
+ QPCIDevice *dev;
50
+ QPCIBar bar;
38
+
51
+
39
+ return float16_sqrt(a, s);
52
+ qts = qtest_init("-device pvpanic-pci,addr=04.0 -action panic=none");
53
+ pcibus = qpci_new_pc(qts, NULL);
54
+ dev = qpci_device_find(pcibus, QPCI_DEVFN(0x4, 0x0));
55
+ qpci_device_enable(dev);
56
+ bar = qpci_iomap(dev, 0, NULL);
57
+
58
+ qpci_memread(dev, bar, 0, &val, sizeof(val));
59
+ g_assert_cmpuint(val, ==, 3);
60
+
61
+ val = 1;
62
+ qpci_memwrite(dev, bar, 0, &val, sizeof(val));
63
+
64
+ response = qtest_qmp_eventwait_ref(qts, "GUEST_PANICKED");
65
+ g_assert(qdict_haskey(response, "data"));
66
+ data = qdict_get_qdict(response, "data");
67
+ g_assert(qdict_haskey(data, "action"));
68
+ g_assert_cmpstr(qdict_get_str(data, "action"), ==, "run");
69
+ qobject_unref(response);
70
+
71
+ qtest_quit(qts);
40
+}
72
+}
41
+
73
+
74
+static void test_panic(void)
75
+{
76
+ uint8_t val;
77
+ QDict *response, *data;
78
+ QTestState *qts;
79
+ QPCIBus *pcibus;
80
+ QPCIDevice *dev;
81
+ QPCIBar bar;
42
+
82
+
43
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
83
+ qts = qtest_init("-device pvpanic-pci,addr=04.0 -action panic=pause");
84
+ pcibus = qpci_new_pc(qts, NULL);
85
+ dev = qpci_device_find(pcibus, QPCI_DEVFN(0x4, 0x0));
86
+ qpci_device_enable(dev);
87
+ bar = qpci_iomap(dev, 0, NULL);
88
+
89
+ qpci_memread(dev, bar, 0, &val, sizeof(val));
90
+ g_assert_cmpuint(val, ==, 3);
91
+
92
+ val = 1;
93
+ qpci_memwrite(dev, bar, 0, &val, sizeof(val));
94
+
95
+ response = qtest_qmp_eventwait_ref(qts, "GUEST_PANICKED");
96
+ g_assert(qdict_haskey(response, "data"));
97
+ data = qdict_get_qdict(response, "data");
98
+ g_assert(qdict_haskey(data, "action"));
99
+ g_assert_cmpstr(qdict_get_str(data, "action"), ==, "pause");
100
+ qobject_unref(response);
101
+
102
+ qtest_quit(qts);
103
+}
104
+
105
+int main(int argc, char **argv)
106
+{
107
+ int ret;
108
+
109
+ g_test_init(&argc, &argv, NULL);
110
+ qtest_add_func("/pvpanic-pci/panic", test_panic);
111
+ qtest_add_func("/pvpanic-pci/panic-nopause", test_panic_nopause);
112
+
113
+ ret = g_test_run();
114
+
115
+ return ret;
116
+}
117
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
44
index XXXXXXX..XXXXXXX 100644
118
index XXXXXXX..XXXXXXX 100644
45
--- a/target/arm/translate-a64.c
119
--- a/tests/qtest/meson.build
46
+++ b/target/arm/translate-a64.c
120
+++ b/tests/qtest/meson.build
47
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
121
@@ -XXX,XX +XXX,XX @@ qtests_i386 = \
48
case 0x6f: /* FNEG */
122
config_all_devices.has_key('CONFIG_ISA_IPMI_BT') ? ['ipmi-bt-test'] : []) + \
49
need_fpst = false;
123
(config_all_devices.has_key('CONFIG_WDT_IB700') ? ['wdt_ib700-test'] : []) + \
50
break;
124
(config_all_devices.has_key('CONFIG_PVPANIC_ISA') ? ['pvpanic-test'] : []) + \
51
+ case 0x7f: /* FSQRT (vector) */
125
+ (config_all_devices.has_key('CONFIG_PVPANIC_PCI') ? ['pvpanic-pci-test'] : []) + \
52
+ break;
126
(config_all_devices.has_key('CONFIG_HDA') ? ['intel-hda-test'] : []) + \
53
default:
127
(config_all_devices.has_key('CONFIG_I82801B11') ? ['i82801b11-test'] : []) + \
54
fprintf(stderr, "%s: insn %#04x fpop %#2x\n", __func__, insn, fpop);
128
(config_all_devices.has_key('CONFIG_IOH3420') ? ['ioh3420-test'] : []) + \
55
g_assert_not_reached();
56
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
57
case 0x6f: /* FNEG */
58
tcg_gen_xori_i32(tcg_res, tcg_op, 0x8000);
59
break;
60
+ case 0x7f: /* FSQRT */
61
+ gen_helper_sqrt_f16(tcg_res, tcg_op, tcg_fpstatus);
62
+ break;
63
default:
64
g_assert_not_reached();
65
}
66
--
129
--
67
2.16.2
130
2.20.1
68
131
69
132
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
The ptimer API currently provides two methods for setting the period:
2
ptimer_set_period(), which takes a period in nanoseconds, and
3
ptimer_set_freq(), which takes a frequency in Hz. Neither of these
4
lines up nicely with the Clock API, because although both the Clock
5
and the ptimer track the frequency using a representation of whole
6
and fractional nanoseconds, conversion via either period-in-ns or
7
frequency-in-Hz will introduce a rounding error.
2
8
3
We go with the localised helper.
9
Add a new function ptimer_set_period_from_clock() which takes the
10
Clock object directly to avoid the rounding issues. This includes a
11
facility for the user to specify that there is a frequency divider
12
between the Clock proper and the timer, as some timer devices like
13
the CMSDK APB dualtimer need this.
4
14
5
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
15
To avoid having to drag in clock.h from ptimer.h we add the Clock
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
16
type to typedefs.h.
7
Message-id: 20180227143852.11175-25-alex.bennee@linaro.org
17
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Reviewed-by: Luc Michel <luc@lmichel.fr>
20
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
21
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
22
Message-id: 20210128114145.20536-2-peter.maydell@linaro.org
23
Message-id: 20210121190622.22000-2-peter.maydell@linaro.org
9
---
24
---
10
target/arm/helper-a64.h | 1 +
25
include/hw/ptimer.h | 22 ++++++++++++++++++++++
11
target/arm/helper-a64.c | 29 +++++++++++++++++++++++++++++
26
include/qemu/typedefs.h | 1 +
12
target/arm/translate-a64.c | 4 ++++
27
hw/core/ptimer.c | 34 ++++++++++++++++++++++++++++++++++
13
3 files changed, 34 insertions(+)
28
3 files changed, 57 insertions(+)
14
29
15
diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h
30
diff --git a/include/hw/ptimer.h b/include/hw/ptimer.h
16
index XXXXXXX..XXXXXXX 100644
31
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/helper-a64.h
32
--- a/include/hw/ptimer.h
18
+++ b/target/arm/helper-a64.h
33
+++ b/include/hw/ptimer.h
19
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_1(neon_addlp_s16, TCG_CALL_NO_RWG_SE, i64, i64)
34
@@ -XXX,XX +XXX,XX @@ void ptimer_transaction_commit(ptimer_state *s);
20
DEF_HELPER_FLAGS_1(neon_addlp_u16, TCG_CALL_NO_RWG_SE, i64, i64)
35
*/
21
DEF_HELPER_FLAGS_2(frecpx_f64, TCG_CALL_NO_RWG, f64, f64, ptr)
36
void ptimer_set_period(ptimer_state *s, int64_t period);
22
DEF_HELPER_FLAGS_2(frecpx_f32, TCG_CALL_NO_RWG, f32, f32, ptr)
37
23
+DEF_HELPER_FLAGS_2(frecpx_f16, TCG_CALL_NO_RWG, f16, f16, ptr)
38
+/**
24
DEF_HELPER_FLAGS_2(fcvtx_f64_to_f32, TCG_CALL_NO_RWG, f32, f64, env)
39
+ * ptimer_set_period_from_clock - Set counter increment from a Clock
25
DEF_HELPER_FLAGS_3(crc32_64, TCG_CALL_NO_RWG_SE, i64, i64, i64, i32)
40
+ * @s: ptimer to configure
26
DEF_HELPER_FLAGS_3(crc32c_64, TCG_CALL_NO_RWG_SE, i64, i64, i64, i32)
41
+ * @clk: pointer to Clock object to take period from
27
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
42
+ * @divisor: value to scale the clock frequency down by
43
+ *
44
+ * If the ptimer is being driven from a Clock, this is the preferred
45
+ * way to tell the ptimer about the period, because it avoids any
46
+ * possible rounding errors that might happen if the internal
47
+ * representation of the Clock period was converted to either a period
48
+ * in ns or a frequency in Hz.
49
+ *
50
+ * If the ptimer should run at the same frequency as the clock,
51
+ * pass 1 as the @divisor; if the ptimer should run at half the
52
+ * frequency, pass 2, and so on.
53
+ *
54
+ * This function will assert if it is called outside a
55
+ * ptimer_transaction_begin/commit block.
56
+ */
57
+void ptimer_set_period_from_clock(ptimer_state *s, const Clock *clock,
58
+ unsigned int divisor);
59
+
60
/**
61
* ptimer_set_freq - Set counter frequency in Hz
62
* @s: ptimer to configure
63
diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
28
index XXXXXXX..XXXXXXX 100644
64
index XXXXXXX..XXXXXXX 100644
29
--- a/target/arm/helper-a64.c
65
--- a/include/qemu/typedefs.h
30
+++ b/target/arm/helper-a64.c
66
+++ b/include/qemu/typedefs.h
31
@@ -XXX,XX +XXX,XX @@ uint64_t HELPER(neon_addlp_u16)(uint64_t a)
67
@@ -XXX,XX +XXX,XX @@ typedef struct BlockDriverState BlockDriverState;
68
typedef struct BusClass BusClass;
69
typedef struct BusState BusState;
70
typedef struct Chardev Chardev;
71
+typedef struct Clock Clock;
72
typedef struct CompatProperty CompatProperty;
73
typedef struct CoMutex CoMutex;
74
typedef struct CPUAddressSpace CPUAddressSpace;
75
diff --git a/hw/core/ptimer.c b/hw/core/ptimer.c
76
index XXXXXXX..XXXXXXX 100644
77
--- a/hw/core/ptimer.c
78
+++ b/hw/core/ptimer.c
79
@@ -XXX,XX +XXX,XX @@
80
#include "sysemu/qtest.h"
81
#include "block/aio.h"
82
#include "sysemu/cpus.h"
83
+#include "hw/clock.h"
84
85
#define DELTA_ADJUST 1
86
#define DELTA_NO_ADJUST -1
87
@@ -XXX,XX +XXX,XX @@ void ptimer_set_period(ptimer_state *s, int64_t period)
88
}
32
}
89
}
33
90
34
/* Floating-point reciprocal exponent - see FPRecpX in ARM ARM */
91
+/* Set counter increment interval from a Clock */
35
+float16 HELPER(frecpx_f16)(float16 a, void *fpstp)
92
+void ptimer_set_period_from_clock(ptimer_state *s, const Clock *clk,
93
+ unsigned int divisor)
36
+{
94
+{
37
+ float_status *fpst = fpstp;
95
+ /*
38
+ uint16_t val16, sbit;
96
+ * The raw clock period is a 64-bit value in units of 2^-32 ns;
39
+ int16_t exp;
97
+ * put another way it's a 32.32 fixed-point ns value. Our internal
98
+ * representation of the period is 64.32 fixed point ns, so
99
+ * the conversion is simple.
100
+ */
101
+ uint64_t raw_period = clock_get(clk);
102
+ uint64_t period_frac;
40
+
103
+
41
+ if (float16_is_any_nan(a)) {
104
+ assert(s->in_transaction);
42
+ float16 nan = a;
105
+ s->delta = ptimer_get_count(s);
43
+ if (float16_is_signaling_nan(a, fpst)) {
106
+ s->period = extract64(raw_period, 32, 32);
44
+ float_raise(float_flag_invalid, fpst);
107
+ period_frac = extract64(raw_period, 0, 32);
45
+ nan = float16_maybe_silence_nan(a, fpst);
108
+ /*
46
+ }
109
+ * divisor specifies a possible frequency divisor between the
47
+ if (fpst->default_nan_mode) {
110
+ * clock and the timer, so it is a multiplier on the period.
48
+ nan = float16_default_nan(fpst);
111
+ * We do the multiply after splitting the raw period out into
49
+ }
112
+ * period and frac to avoid having to do a 32*64->96 multiply.
50
+ return nan;
113
+ */
51
+ }
114
+ s->period *= divisor;
115
+ period_frac *= divisor;
116
+ s->period += extract64(period_frac, 32, 32);
117
+ s->period_frac = (uint32_t)period_frac;
52
+
118
+
53
+ val16 = float16_val(a);
119
+ if (s->enabled) {
54
+ sbit = 0x8000 & val16;
120
+ s->need_reload = true;
55
+ exp = extract32(val16, 10, 5);
56
+
57
+ if (exp == 0) {
58
+ return make_float16(deposit32(sbit, 10, 5, 0x1e));
59
+ } else {
60
+ return make_float16(deposit32(sbit, 10, 5, ~exp));
61
+ }
121
+ }
62
+}
122
+}
63
+
123
+
64
float32 HELPER(frecpx_f32)(float32 a, void *fpstp)
124
/* Set counter frequency in Hz. */
125
void ptimer_set_freq(ptimer_state *s, uint32_t freq)
65
{
126
{
66
float_status *fpst = fpstp;
67
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
68
index XXXXXXX..XXXXXXX 100644
69
--- a/target/arm/translate-a64.c
70
+++ b/target/arm/translate-a64.c
71
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
72
handle_2misc_fcmp_zero(s, fpop, is_scalar, 0, is_q, MO_16, rn, rd);
73
return;
74
case 0x3d: /* FRECPE */
75
+ case 0x3f: /* FRECPX */
76
break;
77
case 0x18: /* FRINTN */
78
need_rmode = true;
79
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
80
case 0x3d: /* FRECPE */
81
gen_helper_recpe_f16(tcg_res, tcg_op, tcg_fpstatus);
82
break;
83
+ case 0x3f: /* FRECPX */
84
+ gen_helper_frecpx_f16(tcg_res, tcg_op, tcg_fpstatus);
85
+ break;
86
case 0x5a: /* FCVTNU */
87
case 0x5b: /* FCVTMU */
88
case 0x5c: /* FCVTAU */
89
--
127
--
90
2.16.2
128
2.20.1
91
129
92
130
diff view generated by jsdifflib
New patch
1
Add a function for checking whether a clock has a source. This is
2
useful for devices which have input clocks that must be wired up by
3
the board as it allows them to fail in realize rather than ploughing
4
on with a zero-period clock.
1
5
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Luc Michel <luc@lmichel.fr>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Message-id: 20210128114145.20536-3-peter.maydell@linaro.org
11
Message-id: 20210121190622.22000-3-peter.maydell@linaro.org
12
---
13
docs/devel/clocks.rst | 16 ++++++++++++++++
14
include/hw/clock.h | 15 +++++++++++++++
15
2 files changed, 31 insertions(+)
16
17
diff --git a/docs/devel/clocks.rst b/docs/devel/clocks.rst
18
index XXXXXXX..XXXXXXX 100644
19
--- a/docs/devel/clocks.rst
20
+++ b/docs/devel/clocks.rst
21
@@ -XXX,XX +XXX,XX @@ object during device instance init. For example:
22
/* set initial value to 10ns / 100MHz */
23
clock_set_ns(clk, 10);
24
25
+To enforce that the clock is wired up by the board code, you can
26
+call ``clock_has_source()`` in your device's realize method:
27
+
28
+.. code-block:: c
29
+
30
+ if (!clock_has_source(s->clk)) {
31
+ error_setg(errp, "MyDevice: clk input must be connected");
32
+ return;
33
+ }
34
+
35
+Note that this only checks that the clock has been wired up; it is
36
+still possible that the output clock connected to it is disabled
37
+or has not yet been configured, in which case the period will be
38
+zero. You should use the clock callback to find out when the clock
39
+period changes.
40
+
41
Fetching clock frequency/period
42
-------------------------------
43
44
diff --git a/include/hw/clock.h b/include/hw/clock.h
45
index XXXXXXX..XXXXXXX 100644
46
--- a/include/hw/clock.h
47
+++ b/include/hw/clock.h
48
@@ -XXX,XX +XXX,XX @@ void clock_clear_callback(Clock *clk);
49
*/
50
void clock_set_source(Clock *clk, Clock *src);
51
52
+/**
53
+ * clock_has_source:
54
+ * @clk: the clock
55
+ *
56
+ * Returns true if the clock has a source clock connected to it.
57
+ * This is useful for devices which have input clocks which must
58
+ * be connected by the board/SoC code which creates them. The
59
+ * device code can use this to check in its realize method that
60
+ * the clock has been connected.
61
+ */
62
+static inline bool clock_has_source(const Clock *clk)
63
+{
64
+ return clk->source != NULL;
65
+}
66
+
67
/**
68
* clock_set:
69
* @clk: the clock to initialize.
70
--
71
2.20.1
72
73
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
Add a simple test of the CMSDK APB timer, since we're about to do
2
some refactoring of how it is clocked.
2
3
3
This covers all the floating point convert operations.
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Reviewed-by: Luc Michel <luc@lmichel.fr>
7
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20210128114145.20536-4-peter.maydell@linaro.org
9
Message-id: 20210121190622.22000-4-peter.maydell@linaro.org
10
---
11
tests/qtest/cmsdk-apb-timer-test.c | 75 ++++++++++++++++++++++++++++++
12
MAINTAINERS | 1 +
13
tests/qtest/meson.build | 1 +
14
3 files changed, 77 insertions(+)
15
create mode 100644 tests/qtest/cmsdk-apb-timer-test.c
4
16
5
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
17
diff --git a/tests/qtest/cmsdk-apb-timer-test.c b/tests/qtest/cmsdk-apb-timer-test.c
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
18
new file mode 100644
7
Message-id: 20180227143852.11175-19-alex.bennee@linaro.org
19
index XXXXXXX..XXXXXXX
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
--- /dev/null
9
---
21
+++ b/tests/qtest/cmsdk-apb-timer-test.c
10
target/arm/helper-a64.h | 2 ++
22
@@ -XXX,XX +XXX,XX @@
11
target/arm/helper-a64.c | 32 +++++++++++++++++
12
target/arm/translate-a64.c | 85 +++++++++++++++++++++++++++++++++++++++++++++-
13
3 files changed, 118 insertions(+), 1 deletion(-)
14
15
diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/helper-a64.h
18
+++ b/target/arm/helper-a64.h
19
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(advsimd_mulx2h, i32, i32, i32, ptr)
20
DEF_HELPER_4(advsimd_muladd2h, i32, i32, i32, i32, ptr)
21
DEF_HELPER_2(advsimd_rinth_exact, f16, f16, ptr)
22
DEF_HELPER_2(advsimd_rinth, f16, f16, ptr)
23
+DEF_HELPER_2(advsimd_f16tosinth, i32, f16, ptr)
24
+DEF_HELPER_2(advsimd_f16touinth, i32, f16, ptr)
25
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
26
index XXXXXXX..XXXXXXX 100644
27
--- a/target/arm/helper-a64.c
28
+++ b/target/arm/helper-a64.c
29
@@ -XXX,XX +XXX,XX @@ float16 HELPER(advsimd_rinth)(float16 x, void *fp_status)
30
31
return ret;
32
}
33
+
34
+/*
23
+/*
35
+ * Half-precision floating point conversion functions
24
+ * QTest testcase for the CMSDK APB timer device
36
+ *
25
+ *
37
+ * There are a multitude of conversion functions with various
26
+ * Copyright (c) 2021 Linaro Limited
38
+ * different rounding modes. This is dealt with by the calling code
27
+ *
39
+ * setting the mode appropriately before calling the helper.
28
+ * This program is free software; you can redistribute it and/or modify it
29
+ * under the terms of the GNU General Public License as published by the
30
+ * Free Software Foundation; either version 2 of the License, or
31
+ * (at your option) any later version.
32
+ *
33
+ * This program is distributed in the hope that it will be useful, but WITHOUT
34
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
35
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
36
+ * for more details.
40
+ */
37
+ */
41
+
38
+
42
+uint32_t HELPER(advsimd_f16tosinth)(float16 a, void *fpstp)
39
+#include "qemu/osdep.h"
40
+#include "libqtest-single.h"
41
+
42
+/* IoTKit/ARMSSE-200 timer0; driven at 25MHz in mps2-an385, so 40ns per tick */
43
+#define TIMER_BASE 0x40000000
44
+
45
+#define CTRL 0
46
+#define VALUE 4
47
+#define RELOAD 8
48
+#define INTSTATUS 0xc
49
+
50
+static void test_timer(void)
43
+{
51
+{
44
+ float_status *fpst = fpstp;
52
+ g_assert_true(readl(TIMER_BASE + INTSTATUS) == 0);
45
+
53
+
46
+ /* Invalid if we are passed a NaN */
54
+ /* Start timer: will fire after 40 * 1000 == 40000 ns */
47
+ if (float16_is_any_nan(a)) {
55
+ writel(TIMER_BASE + RELOAD, 1000);
48
+ float_raise(float_flag_invalid, fpst);
56
+ writel(TIMER_BASE + CTRL, 9);
49
+ return 0;
57
+
50
+ }
58
+ /* Step to just past the 500th tick and check VALUE */
51
+ return float16_to_int16(a, fpst);
59
+ clock_step(40 * 500 + 1);
60
+ g_assert_cmpuint(readl(TIMER_BASE + INTSTATUS), ==, 0);
61
+ g_assert_cmpuint(readl(TIMER_BASE + VALUE), ==, 500);
62
+
63
+ /* Just past the 1000th tick: timer should have fired */
64
+ clock_step(40 * 500);
65
+ g_assert_cmpuint(readl(TIMER_BASE + INTSTATUS), ==, 1);
66
+ g_assert_cmpuint(readl(TIMER_BASE + VALUE), ==, 0);
67
+
68
+ /* VALUE reloads at the following tick */
69
+ clock_step(40);
70
+ g_assert_cmpuint(readl(TIMER_BASE + VALUE), ==, 1000);
71
+
72
+ /* Check write-1-to-clear behaviour of INTSTATUS */
73
+ writel(TIMER_BASE + INTSTATUS, 0);
74
+ g_assert_cmpuint(readl(TIMER_BASE + INTSTATUS), ==, 1);
75
+ writel(TIMER_BASE + INTSTATUS, 1);
76
+ g_assert_cmpuint(readl(TIMER_BASE + INTSTATUS), ==, 0);
77
+
78
+ /* Turn off the timer */
79
+ writel(TIMER_BASE + CTRL, 0);
52
+}
80
+}
53
+
81
+
54
+uint32_t HELPER(advsimd_f16touinth)(float16 a, void *fpstp)
82
+int main(int argc, char **argv)
55
+{
83
+{
56
+ float_status *fpst = fpstp;
84
+ int r;
57
+
85
+
58
+ /* Invalid if we are passed a NaN */
86
+ g_test_init(&argc, &argv, NULL);
59
+ if (float16_is_any_nan(a)) {
87
+
60
+ float_raise(float_flag_invalid, fpst);
88
+ qtest_start("-machine mps2-an385");
61
+ return 0;
89
+
62
+ }
90
+ qtest_add_func("/cmsdk-apb-timer/timer", test_timer);
63
+ return float16_to_uint16(a, fpst);
91
+
92
+ r = g_test_run();
93
+
94
+ qtest_end();
95
+
96
+ return r;
64
+}
97
+}
65
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
98
diff --git a/MAINTAINERS b/MAINTAINERS
66
index XXXXXXX..XXXXXXX 100644
99
index XXXXXXX..XXXXXXX 100644
67
--- a/target/arm/translate-a64.c
100
--- a/MAINTAINERS
68
+++ b/target/arm/translate-a64.c
101
+++ b/MAINTAINERS
69
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
102
@@ -XXX,XX +XXX,XX @@ F: include/hw/rtc/pl031.h
70
only_in_vector = true;
103
F: include/hw/arm/primecell.h
71
/* current rounding mode */
104
F: hw/timer/cmsdk-apb-timer.c
72
break;
105
F: include/hw/timer/cmsdk-apb-timer.h
73
+ case 0x1a: /* FCVTNS */
106
+F: tests/qtest/cmsdk-apb-timer-test.c
74
+ need_rmode = true;
107
F: hw/timer/cmsdk-apb-dualtimer.c
75
+ rmode = FPROUNDING_TIEEVEN;
108
F: include/hw/timer/cmsdk-apb-dualtimer.h
76
+ break;
109
F: hw/char/cmsdk-apb-uart.c
77
+ case 0x1b: /* FCVTMS */
110
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
78
+ need_rmode = true;
111
index XXXXXXX..XXXXXXX 100644
79
+ rmode = FPROUNDING_NEGINF;
112
--- a/tests/qtest/meson.build
80
+ break;
113
+++ b/tests/qtest/meson.build
81
+ case 0x1c: /* FCVTAS */
114
@@ -XXX,XX +XXX,XX @@ qtests_npcm7xx = \
82
+ need_rmode = true;
115
'npcm7xx_timer-test',
83
+ rmode = FPROUNDING_TIEAWAY;
116
'npcm7xx_watchdog_timer-test']
84
+ break;
117
qtests_arm = \
85
+ case 0x3a: /* FCVTPS */
118
+ (config_all_devices.has_key('CONFIG_CMSDK_APB_TIMER') ? ['cmsdk-apb-timer-test'] : []) + \
86
+ need_rmode = true;
119
(config_all_devices.has_key('CONFIG_PFLASH_CFI02') ? ['pflash-cfi02-test'] : []) + \
87
+ rmode = FPROUNDING_POSINF;
120
(config_all_devices.has_key('CONFIG_NPCM7XX') ? qtests_npcm7xx : []) + \
88
+ break;
121
['arm-cpu-features',
89
+ case 0x3b: /* FCVTZS */
90
+ need_rmode = true;
91
+ rmode = FPROUNDING_ZERO;
92
+ break;
93
+ case 0x5a: /* FCVTNU */
94
+ need_rmode = true;
95
+ rmode = FPROUNDING_TIEEVEN;
96
+ break;
97
+ case 0x5b: /* FCVTMU */
98
+ need_rmode = true;
99
+ rmode = FPROUNDING_NEGINF;
100
+ break;
101
+ case 0x5c: /* FCVTAU */
102
+ need_rmode = true;
103
+ rmode = FPROUNDING_TIEAWAY;
104
+ break;
105
+ case 0x7a: /* FCVTPU */
106
+ need_rmode = true;
107
+ rmode = FPROUNDING_POSINF;
108
+ break;
109
+ case 0x7b: /* FCVTZU */
110
+ need_rmode = true;
111
+ rmode = FPROUNDING_ZERO;
112
+ break;
113
default:
114
fprintf(stderr, "%s: insn %#04x fpop %#2x\n", __func__, insn, fpop);
115
g_assert_not_reached();
116
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
117
}
118
119
if (is_scalar) {
120
- /* no operations yet */
121
+ TCGv_i32 tcg_op = tcg_temp_new_i32();
122
+ TCGv_i32 tcg_res = tcg_temp_new_i32();
123
+
124
+ read_vec_element_i32(s, tcg_op, rn, 0, MO_16);
125
+
126
+ switch (fpop) {
127
+ case 0x1a: /* FCVTNS */
128
+ case 0x1b: /* FCVTMS */
129
+ case 0x1c: /* FCVTAS */
130
+ case 0x3a: /* FCVTPS */
131
+ case 0x3b: /* FCVTZS */
132
+ gen_helper_advsimd_f16tosinth(tcg_res, tcg_op, tcg_fpstatus);
133
+ break;
134
+ case 0x5a: /* FCVTNU */
135
+ case 0x5b: /* FCVTMU */
136
+ case 0x5c: /* FCVTAU */
137
+ case 0x7a: /* FCVTPU */
138
+ case 0x7b: /* FCVTZU */
139
+ gen_helper_advsimd_f16touinth(tcg_res, tcg_op, tcg_fpstatus);
140
+ break;
141
+ default:
142
+ g_assert_not_reached();
143
+ }
144
+
145
+ /* limit any sign extension going on */
146
+ tcg_gen_andi_i32(tcg_res, tcg_res, 0xffff);
147
+ write_fp_sreg(s, rd, tcg_res);
148
+
149
+ tcg_temp_free_i32(tcg_res);
150
+ tcg_temp_free_i32(tcg_op);
151
} else {
152
for (pass = 0; pass < (is_q ? 8 : 4); pass++) {
153
TCGv_i32 tcg_op = tcg_temp_new_i32();
154
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
155
read_vec_element_i32(s, tcg_op, rn, pass, MO_16);
156
157
switch (fpop) {
158
+ case 0x1a: /* FCVTNS */
159
+ case 0x1b: /* FCVTMS */
160
+ case 0x1c: /* FCVTAS */
161
+ case 0x3a: /* FCVTPS */
162
+ case 0x3b: /* FCVTZS */
163
+ gen_helper_advsimd_f16tosinth(tcg_res, tcg_op, tcg_fpstatus);
164
+ break;
165
+ case 0x5a: /* FCVTNU */
166
+ case 0x5b: /* FCVTMU */
167
+ case 0x5c: /* FCVTAU */
168
+ case 0x7a: /* FCVTPU */
169
+ case 0x7b: /* FCVTZU */
170
+ gen_helper_advsimd_f16touinth(tcg_res, tcg_op, tcg_fpstatus);
171
+ break;
172
case 0x18: /* FRINTN */
173
case 0x19: /* FRINTM */
174
case 0x38: /* FRINTP */
175
--
122
--
176
2.16.2
123
2.20.1
177
124
178
125
diff view generated by jsdifflib
1
From: Alistair Francis <alistair.francis@xilinx.com>
1
Add a simple test of the CMSDK watchdog, since we're about to do some
2
refactoring of how it is clocked.
2
3
3
I am leaving Xilinx, so to avoid having an email address that bounces
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
update my maintainer address to point to my personal email address.
5
Reviewed-by: Luc Michel <luc@lmichel.fr>
6
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20210128114145.20536-5-peter.maydell@linaro.org
9
Message-id: 20210121190622.22000-5-peter.maydell@linaro.org
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
---
12
tests/qtest/cmsdk-apb-watchdog-test.c | 79 +++++++++++++++++++++++++++
13
MAINTAINERS | 1 +
14
tests/qtest/meson.build | 1 +
15
3 files changed, 81 insertions(+)
16
create mode 100644 tests/qtest/cmsdk-apb-watchdog-test.c
5
17
6
Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
18
diff --git a/tests/qtest/cmsdk-apb-watchdog-test.c b/tests/qtest/cmsdk-apb-watchdog-test.c
7
Signed-off-by: Alistair Francis <alistair@alistair23.me>
19
new file mode 100644
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
20
index XXXXXXX..XXXXXXX
9
Message-id: 7bb690382e3370aa1c1e047a84e36603c787ec0e.1519749987.git.alistair.francis@xilinx.com
21
--- /dev/null
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
+++ b/tests/qtest/cmsdk-apb-watchdog-test.c
11
---
23
@@ -XXX,XX +XXX,XX @@
12
MAINTAINERS | 12 ++++++------
24
+/*
13
1 file changed, 6 insertions(+), 6 deletions(-)
25
+ * QTest testcase for the CMSDK APB watchdog device
14
26
+ *
27
+ * Copyright (c) 2021 Linaro Limited
28
+ *
29
+ * This program is free software; you can redistribute it and/or modify it
30
+ * under the terms of the GNU General Public License as published by the
31
+ * Free Software Foundation; either version 2 of the License, or
32
+ * (at your option) any later version.
33
+ *
34
+ * This program is distributed in the hope that it will be useful, but WITHOUT
35
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
36
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
37
+ * for more details.
38
+ */
39
+
40
+#include "qemu/osdep.h"
41
+#include "libqtest-single.h"
42
+
43
+/*
44
+ * lm3s811evb watchdog; at board startup this runs at 200MHz / 16 == 12.5MHz,
45
+ * which is 80ns per tick.
46
+ */
47
+#define WDOG_BASE 0x40000000
48
+
49
+#define WDOGLOAD 0
50
+#define WDOGVALUE 4
51
+#define WDOGCONTROL 8
52
+#define WDOGINTCLR 0xc
53
+#define WDOGRIS 0x10
54
+#define WDOGMIS 0x14
55
+#define WDOGLOCK 0xc00
56
+
57
+static void test_watchdog(void)
58
+{
59
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0);
60
+
61
+ writel(WDOG_BASE + WDOGCONTROL, 1);
62
+ writel(WDOG_BASE + WDOGLOAD, 1000);
63
+
64
+ /* Step to just past the 500th tick */
65
+ clock_step(500 * 80 + 1);
66
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0);
67
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 500);
68
+
69
+ /* Just past the 1000th tick: timer should have fired */
70
+ clock_step(500 * 80);
71
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 1);
72
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 0);
73
+
74
+ /* VALUE reloads at following tick */
75
+ clock_step(80);
76
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 1000);
77
+
78
+ /* Writing any value to WDOGINTCLR clears the interrupt and reloads */
79
+ clock_step(500 * 80);
80
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 500);
81
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 1);
82
+ writel(WDOG_BASE + WDOGINTCLR, 0);
83
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 1000);
84
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0);
85
+}
86
+
87
+int main(int argc, char **argv)
88
+{
89
+ int r;
90
+
91
+ g_test_init(&argc, &argv, NULL);
92
+
93
+ qtest_start("-machine lm3s811evb");
94
+
95
+ qtest_add_func("/cmsdk-apb-watchdog/watchdog", test_watchdog);
96
+
97
+ r = g_test_run();
98
+
99
+ qtest_end();
100
+
101
+ return r;
102
+}
15
diff --git a/MAINTAINERS b/MAINTAINERS
103
diff --git a/MAINTAINERS b/MAINTAINERS
16
index XXXXXXX..XXXXXXX 100644
104
index XXXXXXX..XXXXXXX 100644
17
--- a/MAINTAINERS
105
--- a/MAINTAINERS
18
+++ b/MAINTAINERS
106
+++ b/MAINTAINERS
19
@@ -XXX,XX +XXX,XX @@ F: hw/misc/arm_sysctl.c
107
@@ -XXX,XX +XXX,XX @@ F: hw/char/cmsdk-apb-uart.c
20
108
F: include/hw/char/cmsdk-apb-uart.h
21
Xilinx Zynq
109
F: hw/watchdog/cmsdk-apb-watchdog.c
22
M: Edgar E. Iglesias <edgar.iglesias@gmail.com>
110
F: include/hw/watchdog/cmsdk-apb-watchdog.h
23
-M: Alistair Francis <alistair.francis@xilinx.com>
111
+F: tests/qtest/cmsdk-apb-watchdog-test.c
24
+M: Alistair Francis <alistair@alistair23.me>
112
F: hw/misc/tz-ppc.c
25
L: qemu-arm@nongnu.org
113
F: include/hw/misc/tz-ppc.h
26
S: Maintained
114
F: hw/misc/tz-mpc.c
27
F: hw/*/xilinx_*
115
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
28
@@ -XXX,XX +XXX,XX @@ F: include/hw/misc/zynq*
116
index XXXXXXX..XXXXXXX 100644
29
X: hw/ssi/xilinx_*
117
--- a/tests/qtest/meson.build
30
118
+++ b/tests/qtest/meson.build
31
Xilinx ZynqMP
119
@@ -XXX,XX +XXX,XX @@ qtests_npcm7xx = \
32
-M: Alistair Francis <alistair.francis@xilinx.com>
120
'npcm7xx_watchdog_timer-test']
33
+M: Alistair Francis <alistair@alistair23.me>
121
qtests_arm = \
34
M: Edgar E. Iglesias <edgar.iglesias@gmail.com>
122
(config_all_devices.has_key('CONFIG_CMSDK_APB_TIMER') ? ['cmsdk-apb-timer-test'] : []) + \
35
L: qemu-arm@nongnu.org
123
+ (config_all_devices.has_key('CONFIG_CMSDK_APB_WATCHDOG') ? ['cmsdk-apb-watchdog-test'] : []) + \
36
S: Maintained
124
(config_all_devices.has_key('CONFIG_PFLASH_CFI02') ? ['pflash-cfi02-test'] : []) + \
37
@@ -XXX,XX +XXX,XX @@ T: git git://github.com/bonzini/qemu.git scsi-next
125
(config_all_devices.has_key('CONFIG_NPCM7XX') ? qtests_npcm7xx : []) + \
38
126
['arm-cpu-features',
39
SSI
40
M: Peter Crosthwaite <crosthwaite.peter@gmail.com>
41
-M: Alistair Francis <alistair.francis@xilinx.com>
42
+M: Alistair Francis <alistair@alistair23.me>
43
S: Maintained
44
F: hw/ssi/*
45
F: hw/block/m25p80.c
46
@@ -XXX,XX +XXX,XX @@ X: hw/ssi/xilinx_*
47
F: tests/m25p80-test.c
48
49
Xilinx SPI
50
-M: Alistair Francis <alistair.francis@xilinx.com>
51
+M: Alistair Francis <alistair@alistair23.me>
52
M: Peter Crosthwaite <crosthwaite.peter@gmail.com>
53
S: Maintained
54
F: hw/ssi/xilinx_*
55
@@ -XXX,XX +XXX,XX @@ S: Maintained
56
F: hw/net/eepro100.c
57
58
Generic Loader
59
-M: Alistair Francis <alistair.francis@xilinx.com>
60
+M: Alistair Francis <alistair@alistair23.me>
61
S: Maintained
62
F: hw/core/generic-loader.c
63
F: include/hw/core/generic-loader.h
64
@@ -XXX,XX +XXX,XX @@ F: tests/qmp-test.c
65
T: git git://repo.or.cz/qemu/armbru.git qapi-next
66
67
Register API
68
-M: Alistair Francis <alistair.francis@xilinx.com>
69
+M: Alistair Francis <alistair@alistair23.me>
70
S: Maintained
71
F: hw/core/register.c
72
F: include/hw/register.h
73
--
127
--
74
2.16.2
128
2.20.1
75
129
76
130
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
Add a simple test of the CMSDK dual timer, since we're about to do
2
some refactoring of how it is clocked.
2
3
3
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20180227143852.11175-12-alex.bennee@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Luc Michel <luc@lmichel.fr>
8
Message-id: 20210128114145.20536-6-peter.maydell@linaro.org
9
Message-id: 20210121190622.22000-6-peter.maydell@linaro.org
7
---
10
---
8
target/arm/helper-a64.h | 2 ++
11
tests/qtest/cmsdk-apb-dualtimer-test.c | 130 +++++++++++++++++++++++++
9
target/arm/helper-a64.c | 24 ++++++++++++++++++++++++
12
MAINTAINERS | 1 +
10
target/arm/translate-a64.c | 15 +++++++++++++++
13
tests/qtest/meson.build | 1 +
11
3 files changed, 41 insertions(+)
14
3 files changed, 132 insertions(+)
15
create mode 100644 tests/qtest/cmsdk-apb-dualtimer-test.c
12
16
13
diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h
17
diff --git a/tests/qtest/cmsdk-apb-dualtimer-test.c b/tests/qtest/cmsdk-apb-dualtimer-test.c
14
index XXXXXXX..XXXXXXX 100644
18
new file mode 100644
15
--- a/target/arm/helper-a64.h
19
index XXXXXXX..XXXXXXX
16
+++ b/target/arm/helper-a64.h
20
--- /dev/null
17
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(advsimd_cge_f16, i32, f16, f16, ptr)
21
+++ b/tests/qtest/cmsdk-apb-dualtimer-test.c
18
DEF_HELPER_3(advsimd_cgt_f16, i32, f16, f16, ptr)
22
@@ -XXX,XX +XXX,XX @@
19
DEF_HELPER_3(advsimd_acge_f16, i32, f16, f16, ptr)
23
+/*
20
DEF_HELPER_3(advsimd_acgt_f16, i32, f16, f16, ptr)
24
+ * QTest testcase for the CMSDK APB dualtimer device
21
+DEF_HELPER_3(advsimd_mulxh, f16, f16, f16, ptr)
25
+ *
22
+DEF_HELPER_4(advsimd_muladdh, f16, f16, f16, f16, ptr)
26
+ * Copyright (c) 2021 Linaro Limited
23
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
27
+ *
24
index XXXXXXX..XXXXXXX 100644
28
+ * This program is free software; you can redistribute it and/or modify it
25
--- a/target/arm/helper-a64.c
29
+ * under the terms of the GNU General Public License as published by the
26
+++ b/target/arm/helper-a64.c
30
+ * Free Software Foundation; either version 2 of the License, or
27
@@ -XXX,XX +XXX,XX @@ ADVSIMD_HALFOP(max)
31
+ * (at your option) any later version.
28
ADVSIMD_HALFOP(minnum)
32
+ *
29
ADVSIMD_HALFOP(maxnum)
33
+ * This program is distributed in the hope that it will be useful, but WITHOUT
30
34
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
31
+/* Data processing - scalar floating-point and advanced SIMD */
35
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
32
+float16 HELPER(advsimd_mulxh)(float16 a, float16 b, void *fpstp)
36
+ * for more details.
37
+ */
38
+
39
+#include "qemu/osdep.h"
40
+#include "libqtest-single.h"
41
+
42
+/* IoTKit/ARMSSE dualtimer; driven at 25MHz in mps2-an385, so 40ns per tick */
43
+#define TIMER_BASE 0x40002000
44
+
45
+#define TIMER1LOAD 0
46
+#define TIMER1VALUE 4
47
+#define TIMER1CONTROL 8
48
+#define TIMER1INTCLR 0xc
49
+#define TIMER1RIS 0x10
50
+#define TIMER1MIS 0x14
51
+#define TIMER1BGLOAD 0x18
52
+
53
+#define TIMER2LOAD 0x20
54
+#define TIMER2VALUE 0x24
55
+#define TIMER2CONTROL 0x28
56
+#define TIMER2INTCLR 0x2c
57
+#define TIMER2RIS 0x30
58
+#define TIMER2MIS 0x34
59
+#define TIMER2BGLOAD 0x38
60
+
61
+#define CTRL_ENABLE (1 << 7)
62
+#define CTRL_PERIODIC (1 << 6)
63
+#define CTRL_INTEN (1 << 5)
64
+#define CTRL_PRESCALE_1 (0 << 2)
65
+#define CTRL_PRESCALE_16 (1 << 2)
66
+#define CTRL_PRESCALE_256 (2 << 2)
67
+#define CTRL_32BIT (1 << 1)
68
+#define CTRL_ONESHOT (1 << 0)
69
+
70
+static void test_dualtimer(void)
33
+{
71
+{
34
+ float_status *fpst = fpstp;
72
+ g_assert_true(readl(TIMER_BASE + TIMER1RIS) == 0);
35
+
73
+
36
+ a = float16_squash_input_denormal(a, fpst);
74
+ /* Start timer: will fire after 40000 ns */
37
+ b = float16_squash_input_denormal(b, fpst);
75
+ writel(TIMER_BASE + TIMER1LOAD, 1000);
76
+ /* enable in free-running, wrapping, interrupt mode */
77
+ writel(TIMER_BASE + TIMER1CONTROL, CTRL_ENABLE | CTRL_INTEN);
38
+
78
+
39
+ if ((float16_is_zero(a) && float16_is_infinity(b)) ||
79
+ /* Step to just past the 500th tick and check VALUE */
40
+ (float16_is_infinity(a) && float16_is_zero(b))) {
80
+ clock_step(500 * 40 + 1);
41
+ /* 2.0 with the sign bit set to sign(A) XOR sign(B) */
81
+ g_assert_cmpuint(readl(TIMER_BASE + TIMER1RIS), ==, 0);
42
+ return make_float16((1U << 14) |
82
+ g_assert_cmpuint(readl(TIMER_BASE + TIMER1VALUE), ==, 500);
43
+ ((float16_val(a) ^ float16_val(b)) & (1U << 15)));
83
+
44
+ }
84
+ /* Just past the 1000th tick: timer should have fired */
45
+ return float16_mul(a, b, fpst);
85
+ clock_step(500 * 40);
86
+ g_assert_cmpuint(readl(TIMER_BASE + TIMER1RIS), ==, 1);
87
+ g_assert_cmpuint(readl(TIMER_BASE + TIMER1VALUE), ==, 0);
88
+
89
+ /*
90
+ * We are in free-running wrapping 16-bit mode, so on the following
91
+ * tick VALUE should have wrapped round to 0xffff.
92
+ */
93
+ clock_step(40);
94
+ g_assert_cmpuint(readl(TIMER_BASE + TIMER1VALUE), ==, 0xffff);
95
+
96
+ /* Check that any write to INTCLR clears interrupt */
97
+ writel(TIMER_BASE + TIMER1INTCLR, 1);
98
+ g_assert_cmpuint(readl(TIMER_BASE + TIMER1RIS), ==, 0);
99
+
100
+ /* Turn off the timer */
101
+ writel(TIMER_BASE + TIMER1CONTROL, 0);
46
+}
102
+}
47
+
103
+
48
+/* fused multiply-accumulate */
104
+static void test_prescale(void)
49
+float16 HELPER(advsimd_muladdh)(float16 a, float16 b, float16 c, void *fpstp)
50
+{
105
+{
51
+ float_status *fpst = fpstp;
106
+ g_assert_true(readl(TIMER_BASE + TIMER2RIS) == 0);
52
+ return float16_muladd(a, b, c, 0, fpst);
107
+
108
+ /* Start timer: will fire after 40 * 256 * 1000 == 1024000 ns */
109
+ writel(TIMER_BASE + TIMER2LOAD, 1000);
110
+ /* enable in periodic, wrapping, interrupt mode, prescale 256 */
111
+ writel(TIMER_BASE + TIMER2CONTROL,
112
+ CTRL_ENABLE | CTRL_INTEN | CTRL_PERIODIC | CTRL_PRESCALE_256);
113
+
114
+ /* Step to just past the 500th tick and check VALUE */
115
+ clock_step(40 * 256 * 501);
116
+ g_assert_cmpuint(readl(TIMER_BASE + TIMER2RIS), ==, 0);
117
+ g_assert_cmpuint(readl(TIMER_BASE + TIMER2VALUE), ==, 500);
118
+
119
+ /* Just past the 1000th tick: timer should have fired */
120
+ clock_step(40 * 256 * 500);
121
+ g_assert_cmpuint(readl(TIMER_BASE + TIMER2RIS), ==, 1);
122
+ g_assert_cmpuint(readl(TIMER_BASE + TIMER2VALUE), ==, 0);
123
+
124
+ /* In periodic mode the tick VALUE now reloads */
125
+ clock_step(40 * 256);
126
+ g_assert_cmpuint(readl(TIMER_BASE + TIMER2VALUE), ==, 1000);
127
+
128
+ /* Check that any write to INTCLR clears interrupt */
129
+ writel(TIMER_BASE + TIMER2INTCLR, 1);
130
+ g_assert_cmpuint(readl(TIMER_BASE + TIMER2RIS), ==, 0);
131
+
132
+ /* Turn off the timer */
133
+ writel(TIMER_BASE + TIMER2CONTROL, 0);
53
+}
134
+}
54
+
135
+
55
/*
136
+int main(int argc, char **argv)
56
* Floating point comparisons produce an integer result. Softfloat
137
+{
57
* routines return float_relation types which we convert to the 0/-1
138
+ int r;
58
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
139
+
140
+ g_test_init(&argc, &argv, NULL);
141
+
142
+ qtest_start("-machine mps2-an385");
143
+
144
+ qtest_add_func("/cmsdk-apb-dualtimer/dualtimer", test_dualtimer);
145
+ qtest_add_func("/cmsdk-apb-dualtimer/prescale", test_prescale);
146
+
147
+ r = g_test_run();
148
+
149
+ qtest_end();
150
+
151
+ return r;
152
+}
153
diff --git a/MAINTAINERS b/MAINTAINERS
59
index XXXXXXX..XXXXXXX 100644
154
index XXXXXXX..XXXXXXX 100644
60
--- a/target/arm/translate-a64.c
155
--- a/MAINTAINERS
61
+++ b/target/arm/translate-a64.c
156
+++ b/MAINTAINERS
62
@@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn)
157
@@ -XXX,XX +XXX,XX @@ F: include/hw/timer/cmsdk-apb-timer.h
63
case 0x0: /* FMAXNM */
158
F: tests/qtest/cmsdk-apb-timer-test.c
64
gen_helper_advsimd_maxnumh(tcg_res, tcg_op1, tcg_op2, fpst);
159
F: hw/timer/cmsdk-apb-dualtimer.c
65
break;
160
F: include/hw/timer/cmsdk-apb-dualtimer.h
66
+ case 0x1: /* FMLA */
161
+F: tests/qtest/cmsdk-apb-dualtimer-test.c
67
+ read_vec_element_i32(s, tcg_res, rd, pass, MO_16);
162
F: hw/char/cmsdk-apb-uart.c
68
+ gen_helper_advsimd_muladdh(tcg_res, tcg_op1, tcg_op2, tcg_res,
163
F: include/hw/char/cmsdk-apb-uart.h
69
+ fpst);
164
F: hw/watchdog/cmsdk-apb-watchdog.c
70
+ break;
165
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
71
case 0x2: /* FADD */
166
index XXXXXXX..XXXXXXX 100644
72
gen_helper_advsimd_addh(tcg_res, tcg_op1, tcg_op2, fpst);
167
--- a/tests/qtest/meson.build
73
break;
168
+++ b/tests/qtest/meson.build
74
+ case 0x3: /* FMULX */
169
@@ -XXX,XX +XXX,XX @@ qtests_npcm7xx = \
75
+ gen_helper_advsimd_mulxh(tcg_res, tcg_op1, tcg_op2, fpst);
170
'npcm7xx_timer-test',
76
+ break;
171
'npcm7xx_watchdog_timer-test']
77
case 0x4: /* FCMEQ */
172
qtests_arm = \
78
gen_helper_advsimd_ceq_f16(tcg_res, tcg_op1, tcg_op2, fpst);
173
+ (config_all_devices.has_key('CONFIG_CMSDK_APB_DUALTIMER') ? ['cmsdk-apb-dualtimer-test'] : []) + \
79
break;
174
(config_all_devices.has_key('CONFIG_CMSDK_APB_TIMER') ? ['cmsdk-apb-timer-test'] : []) + \
80
@@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn)
175
(config_all_devices.has_key('CONFIG_CMSDK_APB_WATCHDOG') ? ['cmsdk-apb-watchdog-test'] : []) + \
81
case 0x8: /* FMINNM */
176
(config_all_devices.has_key('CONFIG_PFLASH_CFI02') ? ['pflash-cfi02-test'] : []) + \
82
gen_helper_advsimd_minnumh(tcg_res, tcg_op1, tcg_op2, fpst);
83
break;
84
+ case 0x9: /* FMLS */
85
+ /* As usual for ARM, separate negation for fused multiply-add */
86
+ tcg_gen_xori_i32(tcg_op1, tcg_op1, 0x8000);
87
+ read_vec_element_i32(s, tcg_res, rd, pass, MO_16);
88
+ gen_helper_advsimd_muladdh(tcg_res, tcg_op1, tcg_op2, tcg_res,
89
+ fpst);
90
+ break;
91
case 0xa: /* FSUB */
92
gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst);
93
break;
94
--
177
--
95
2.16.2
178
2.20.1
96
179
97
180
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
The state struct for the CMSDK APB timer device doesn't follow our
2
usual naming convention of camelcase -- "CMSDK" and "APB" are both
3
acronyms, but "TIMER" is not so should not be all-uppercase.
4
Globally rename the struct to "CMSDKAPBTimer" (bringing it into line
5
with CMSDKAPBWatchdog and CMSDKAPBDualTimer; CMSDKAPBUART remains
6
as-is because "UART" is an acronym).
2
7
3
This covers the encoding group:
8
Commit created with:
9
perl -p -i -e 's/CMSDKAPBTIMER/CMSDKAPBTimer/g' hw/timer/cmsdk-apb-timer.c include/hw/arm/armsse.h include/hw/timer/cmsdk-apb-timer.h
4
10
5
Advanced SIMD scalar three same FP16
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
Reviewed-by: Luc Michel <luc@lmichel.fr>
14
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
Message-id: 20210128114145.20536-7-peter.maydell@linaro.org
16
Message-id: 20210121190622.22000-7-peter.maydell@linaro.org
17
---
18
include/hw/arm/armsse.h | 6 +++---
19
include/hw/timer/cmsdk-apb-timer.h | 4 ++--
20
hw/timer/cmsdk-apb-timer.c | 28 ++++++++++++++--------------
21
3 files changed, 19 insertions(+), 19 deletions(-)
6
22
7
As all the helpers are already there it is simply a case of calling the
23
diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h
8
existing helpers in the scalar context.
9
10
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20180227143852.11175-31-alex.bennee@linaro.org
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
15
target/arm/translate-a64.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++
16
1 file changed, 99 insertions(+)
17
18
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
19
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/translate-a64.c
25
--- a/include/hw/arm/armsse.h
21
+++ b/target/arm/translate-a64.c
26
+++ b/include/hw/arm/armsse.h
22
@@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_three_reg_same(DisasContext *s, uint32_t insn)
27
@@ -XXX,XX +XXX,XX @@ struct ARMSSE {
23
tcg_temp_free_i64(tcg_rd);
28
TZPPC apb_ppc0;
29
TZPPC apb_ppc1;
30
TZMPC mpc[IOTS_NUM_MPC];
31
- CMSDKAPBTIMER timer0;
32
- CMSDKAPBTIMER timer1;
33
- CMSDKAPBTIMER s32ktimer;
34
+ CMSDKAPBTimer timer0;
35
+ CMSDKAPBTimer timer1;
36
+ CMSDKAPBTimer s32ktimer;
37
qemu_or_irq ppc_irq_orgate;
38
SplitIRQ sec_resp_splitter;
39
SplitIRQ ppc_irq_splitter[NUM_PPCS];
40
diff --git a/include/hw/timer/cmsdk-apb-timer.h b/include/hw/timer/cmsdk-apb-timer.h
41
index XXXXXXX..XXXXXXX 100644
42
--- a/include/hw/timer/cmsdk-apb-timer.h
43
+++ b/include/hw/timer/cmsdk-apb-timer.h
44
@@ -XXX,XX +XXX,XX @@
45
#include "qom/object.h"
46
47
#define TYPE_CMSDK_APB_TIMER "cmsdk-apb-timer"
48
-OBJECT_DECLARE_SIMPLE_TYPE(CMSDKAPBTIMER, CMSDK_APB_TIMER)
49
+OBJECT_DECLARE_SIMPLE_TYPE(CMSDKAPBTimer, CMSDK_APB_TIMER)
50
51
-struct CMSDKAPBTIMER {
52
+struct CMSDKAPBTimer {
53
/*< private >*/
54
SysBusDevice parent_obj;
55
56
diff --git a/hw/timer/cmsdk-apb-timer.c b/hw/timer/cmsdk-apb-timer.c
57
index XXXXXXX..XXXXXXX 100644
58
--- a/hw/timer/cmsdk-apb-timer.c
59
+++ b/hw/timer/cmsdk-apb-timer.c
60
@@ -XXX,XX +XXX,XX @@ static const int timer_id[] = {
61
0x0d, 0xf0, 0x05, 0xb1, /* CID0..CID3 */
62
};
63
64
-static void cmsdk_apb_timer_update(CMSDKAPBTIMER *s)
65
+static void cmsdk_apb_timer_update(CMSDKAPBTimer *s)
66
{
67
qemu_set_irq(s->timerint, !!(s->intstatus & R_INTSTATUS_IRQ_MASK));
24
}
68
}
25
69
26
+/* AdvSIMD scalar three same FP16
70
static uint64_t cmsdk_apb_timer_read(void *opaque, hwaddr offset, unsigned size)
27
+ * 31 30 29 28 24 23 22 21 20 16 15 14 13 11 10 9 5 4 0
71
{
28
+ * +-----+---+-----------+---+-----+------+-----+--------+---+----+----+
72
- CMSDKAPBTIMER *s = CMSDK_APB_TIMER(opaque);
29
+ * | 0 1 | U | 1 1 1 1 0 | a | 1 0 | Rm | 0 0 | opcode | 1 | Rn | Rd |
73
+ CMSDKAPBTimer *s = CMSDK_APB_TIMER(opaque);
30
+ * +-----+---+-----------+---+-----+------+-----+--------+---+----+----+
74
uint64_t r;
31
+ * v: 0101 1110 0100 0000 0000 0100 0000 0000 => 5e400400
75
32
+ * m: 1101 1111 0110 0000 1100 0100 0000 0000 => df60c400
76
switch (offset) {
33
+ */
77
@@ -XXX,XX +XXX,XX @@ static uint64_t cmsdk_apb_timer_read(void *opaque, hwaddr offset, unsigned size)
34
+static void disas_simd_scalar_three_reg_same_fp16(DisasContext *s,
78
static void cmsdk_apb_timer_write(void *opaque, hwaddr offset, uint64_t value,
35
+ uint32_t insn)
79
unsigned size)
36
+{
80
{
37
+ int rd = extract32(insn, 0, 5);
81
- CMSDKAPBTIMER *s = CMSDK_APB_TIMER(opaque);
38
+ int rn = extract32(insn, 5, 5);
82
+ CMSDKAPBTimer *s = CMSDK_APB_TIMER(opaque);
39
+ int opcode = extract32(insn, 11, 3);
83
40
+ int rm = extract32(insn, 16, 5);
84
trace_cmsdk_apb_timer_write(offset, value, size);
41
+ bool u = extract32(insn, 29, 1);
85
42
+ bool a = extract32(insn, 23, 1);
86
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps cmsdk_apb_timer_ops = {
43
+ int fpopcode = opcode | (a << 3) | (u << 4);
87
44
+ TCGv_ptr fpst;
88
static void cmsdk_apb_timer_tick(void *opaque)
45
+ TCGv_i32 tcg_op1;
89
{
46
+ TCGv_i32 tcg_op2;
90
- CMSDKAPBTIMER *s = CMSDK_APB_TIMER(opaque);
47
+ TCGv_i32 tcg_res;
91
+ CMSDKAPBTimer *s = CMSDK_APB_TIMER(opaque);
48
+
92
49
+ switch (fpopcode) {
93
if (s->ctrl & R_CTRL_IRQEN_MASK) {
50
+ case 0x03: /* FMULX */
94
s->intstatus |= R_INTSTATUS_IRQ_MASK;
51
+ case 0x04: /* FCMEQ (reg) */
95
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_tick(void *opaque)
52
+ case 0x07: /* FRECPS */
96
53
+ case 0x0f: /* FRSQRTS */
97
static void cmsdk_apb_timer_reset(DeviceState *dev)
54
+ case 0x14: /* FCMGE (reg) */
98
{
55
+ case 0x15: /* FACGE */
99
- CMSDKAPBTIMER *s = CMSDK_APB_TIMER(dev);
56
+ case 0x1a: /* FABD */
100
+ CMSDKAPBTimer *s = CMSDK_APB_TIMER(dev);
57
+ case 0x1c: /* FCMGT (reg) */
101
58
+ case 0x1d: /* FACGT */
102
trace_cmsdk_apb_timer_reset();
59
+ break;
103
s->ctrl = 0;
60
+ default:
104
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_reset(DeviceState *dev)
61
+ unallocated_encoding(s);
105
static void cmsdk_apb_timer_init(Object *obj)
62
+ return;
106
{
63
+ }
107
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
64
+
108
- CMSDKAPBTIMER *s = CMSDK_APB_TIMER(obj);
65
+ if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
109
+ CMSDKAPBTimer *s = CMSDK_APB_TIMER(obj);
66
+ unallocated_encoding(s);
110
67
+ }
111
memory_region_init_io(&s->iomem, obj, &cmsdk_apb_timer_ops,
68
+
112
s, "cmsdk-apb-timer", 0x1000);
69
+ if (!fp_access_check(s)) {
113
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_init(Object *obj)
70
+ return;
114
71
+ }
115
static void cmsdk_apb_timer_realize(DeviceState *dev, Error **errp)
72
+
116
{
73
+ fpst = get_fpstatus_ptr(true);
117
- CMSDKAPBTIMER *s = CMSDK_APB_TIMER(dev);
74
+
118
+ CMSDKAPBTimer *s = CMSDK_APB_TIMER(dev);
75
+ tcg_op1 = tcg_temp_new_i32();
119
76
+ tcg_op2 = tcg_temp_new_i32();
120
if (s->pclk_frq == 0) {
77
+ tcg_res = tcg_temp_new_i32();
121
error_setg(errp, "CMSDK APB timer: pclk-frq property must be set");
78
+
122
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription cmsdk_apb_timer_vmstate = {
79
+ read_vec_element_i32(s, tcg_op1, rn, 0, MO_16);
123
.version_id = 1,
80
+ read_vec_element_i32(s, tcg_op2, rm, 0, MO_16);
124
.minimum_version_id = 1,
81
+
125
.fields = (VMStateField[]) {
82
+ switch (fpopcode) {
126
- VMSTATE_PTIMER(timer, CMSDKAPBTIMER),
83
+ case 0x03: /* FMULX */
127
- VMSTATE_UINT32(ctrl, CMSDKAPBTIMER),
84
+ gen_helper_advsimd_mulxh(tcg_res, tcg_op1, tcg_op2, fpst);
128
- VMSTATE_UINT32(value, CMSDKAPBTIMER),
85
+ break;
129
- VMSTATE_UINT32(reload, CMSDKAPBTIMER),
86
+ case 0x04: /* FCMEQ (reg) */
130
- VMSTATE_UINT32(intstatus, CMSDKAPBTIMER),
87
+ gen_helper_advsimd_ceq_f16(tcg_res, tcg_op1, tcg_op2, fpst);
131
+ VMSTATE_PTIMER(timer, CMSDKAPBTimer),
88
+ break;
132
+ VMSTATE_UINT32(ctrl, CMSDKAPBTimer),
89
+ case 0x07: /* FRECPS */
133
+ VMSTATE_UINT32(value, CMSDKAPBTimer),
90
+ gen_helper_recpsf_f16(tcg_res, tcg_op1, tcg_op2, fpst);
134
+ VMSTATE_UINT32(reload, CMSDKAPBTimer),
91
+ break;
135
+ VMSTATE_UINT32(intstatus, CMSDKAPBTimer),
92
+ case 0x0f: /* FRSQRTS */
136
VMSTATE_END_OF_LIST()
93
+ gen_helper_rsqrtsf_f16(tcg_res, tcg_op1, tcg_op2, fpst);
137
}
94
+ break;
95
+ case 0x14: /* FCMGE (reg) */
96
+ gen_helper_advsimd_cge_f16(tcg_res, tcg_op1, tcg_op2, fpst);
97
+ break;
98
+ case 0x15: /* FACGE */
99
+ gen_helper_advsimd_acge_f16(tcg_res, tcg_op1, tcg_op2, fpst);
100
+ break;
101
+ case 0x1a: /* FABD */
102
+ gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst);
103
+ tcg_gen_andi_i32(tcg_res, tcg_res, 0x7fff);
104
+ break;
105
+ case 0x1c: /* FCMGT (reg) */
106
+ gen_helper_advsimd_cgt_f16(tcg_res, tcg_op1, tcg_op2, fpst);
107
+ break;
108
+ case 0x1d: /* FACGT */
109
+ gen_helper_advsimd_acgt_f16(tcg_res, tcg_op1, tcg_op2, fpst);
110
+ break;
111
+ default:
112
+ g_assert_not_reached();
113
+ }
114
+
115
+ write_fp_sreg(s, rd, tcg_res);
116
+
117
+
118
+ tcg_temp_free_i32(tcg_res);
119
+ tcg_temp_free_i32(tcg_op1);
120
+ tcg_temp_free_i32(tcg_op2);
121
+ tcg_temp_free_ptr(fpst);
122
+}
123
+
124
static void handle_2misc_64(DisasContext *s, int opcode, bool u,
125
TCGv_i64 tcg_rd, TCGv_i64 tcg_rn,
126
TCGv_i32 tcg_rmode, TCGv_ptr tcg_fpstatus)
127
@@ -XXX,XX +XXX,XX @@ static const AArch64DecodeTable data_proc_simd[] = {
128
{ 0xce408000, 0xffe0c000, disas_crypto_three_reg_imm2 },
129
{ 0x0e400400, 0x9f60c400, disas_simd_three_reg_same_fp16 },
130
{ 0x0e780800, 0x8f7e0c00, disas_simd_two_reg_misc_fp16 },
131
+ { 0x5e400400, 0xdf60c400, disas_simd_scalar_three_reg_same_fp16 },
132
{ 0x00000000, 0x00000000, NULL }
133
};
138
};
134
139
140
static Property cmsdk_apb_timer_properties[] = {
141
- DEFINE_PROP_UINT32("pclk-frq", CMSDKAPBTIMER, pclk_frq, 0),
142
+ DEFINE_PROP_UINT32("pclk-frq", CMSDKAPBTimer, pclk_frq, 0),
143
DEFINE_PROP_END_OF_LIST(),
144
};
145
146
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_class_init(ObjectClass *klass, void *data)
147
static const TypeInfo cmsdk_apb_timer_info = {
148
.name = TYPE_CMSDK_APB_TIMER,
149
.parent = TYPE_SYS_BUS_DEVICE,
150
- .instance_size = sizeof(CMSDKAPBTIMER),
151
+ .instance_size = sizeof(CMSDKAPBTimer),
152
.instance_init = cmsdk_apb_timer_init,
153
.class_init = cmsdk_apb_timer_class_init,
154
};
135
--
155
--
136
2.16.2
156
2.20.1
137
157
138
158
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
As the first step in converting the CMSDK_APB_TIMER device to the
2
Clock framework, add a Clock input. For the moment we do nothing
3
with this clock; we will change the behaviour from using the pclk-frq
4
property to using the Clock once all the users of this device have
5
been converted to wire up the Clock.
2
6
3
This includes FMOV, FABS, FNEG, FSQRT and FRINT[NPMZAXI]. We re-use
7
Since the device doesn't already have a doc comment for its "QEMU
4
existing helpers to achieve this.
8
interface", we add one including the new Clock.
5
9
6
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
10
This is a migration compatibility break for machines mps2-an505,
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
mps2-an521, musca-a, musca-b1.
8
Message-id: 20180227143852.11175-32-alex.bennee@linaro.org
12
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
Reviewed-by: Luc Michel <luc@lmichel.fr>
16
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
17
Message-id: 20210128114145.20536-8-peter.maydell@linaro.org
18
Message-id: 20210121190622.22000-8-peter.maydell@linaro.org
10
---
19
---
11
target/arm/translate-a64.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++
20
include/hw/timer/cmsdk-apb-timer.h | 9 +++++++++
12
1 file changed, 71 insertions(+)
21
hw/timer/cmsdk-apb-timer.c | 7 +++++--
22
2 files changed, 14 insertions(+), 2 deletions(-)
13
23
14
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
24
diff --git a/include/hw/timer/cmsdk-apb-timer.h b/include/hw/timer/cmsdk-apb-timer.h
15
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/translate-a64.c
26
--- a/include/hw/timer/cmsdk-apb-timer.h
17
+++ b/target/arm/translate-a64.c
27
+++ b/include/hw/timer/cmsdk-apb-timer.h
18
@@ -XXX,XX +XXX,XX @@ static void disas_fp_csel(DisasContext *s, uint32_t insn)
28
@@ -XXX,XX +XXX,XX @@
19
tcg_temp_free_i64(t_true);
29
#include "hw/qdev-properties.h"
30
#include "hw/sysbus.h"
31
#include "hw/ptimer.h"
32
+#include "hw/clock.h"
33
#include "qom/object.h"
34
35
#define TYPE_CMSDK_APB_TIMER "cmsdk-apb-timer"
36
OBJECT_DECLARE_SIMPLE_TYPE(CMSDKAPBTimer, CMSDK_APB_TIMER)
37
38
+/*
39
+ * QEMU interface:
40
+ * + QOM property "pclk-frq": frequency at which the timer is clocked
41
+ * + Clock input "pclk": clock for the timer
42
+ * + sysbus MMIO region 0: the register bank
43
+ * + sysbus IRQ 0: timer interrupt TIMERINT
44
+ */
45
struct CMSDKAPBTimer {
46
/*< private >*/
47
SysBusDevice parent_obj;
48
@@ -XXX,XX +XXX,XX @@ struct CMSDKAPBTimer {
49
qemu_irq timerint;
50
uint32_t pclk_frq;
51
struct ptimer_state *timer;
52
+ Clock *pclk;
53
54
uint32_t ctrl;
55
uint32_t value;
56
diff --git a/hw/timer/cmsdk-apb-timer.c b/hw/timer/cmsdk-apb-timer.c
57
index XXXXXXX..XXXXXXX 100644
58
--- a/hw/timer/cmsdk-apb-timer.c
59
+++ b/hw/timer/cmsdk-apb-timer.c
60
@@ -XXX,XX +XXX,XX @@
61
#include "hw/sysbus.h"
62
#include "hw/irq.h"
63
#include "hw/registerfields.h"
64
+#include "hw/qdev-clock.h"
65
#include "hw/timer/cmsdk-apb-timer.h"
66
#include "migration/vmstate.h"
67
68
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_init(Object *obj)
69
s, "cmsdk-apb-timer", 0x1000);
70
sysbus_init_mmio(sbd, &s->iomem);
71
sysbus_init_irq(sbd, &s->timerint);
72
+ s->pclk = qdev_init_clock_in(DEVICE(s), "pclk", NULL, NULL);
20
}
73
}
21
74
22
+/* Floating-point data-processing (1 source) - half precision */
75
static void cmsdk_apb_timer_realize(DeviceState *dev, Error **errp)
23
+static void handle_fp_1src_half(DisasContext *s, int opcode, int rd, int rn)
76
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_realize(DeviceState *dev, Error **errp)
24
+{
77
25
+ TCGv_ptr fpst = NULL;
78
static const VMStateDescription cmsdk_apb_timer_vmstate = {
26
+ TCGv_i32 tcg_op = tcg_temp_new_i32();
79
.name = "cmsdk-apb-timer",
27
+ TCGv_i32 tcg_res = tcg_temp_new_i32();
80
- .version_id = 1,
28
+
81
- .minimum_version_id = 1,
29
+ read_vec_element_i32(s, tcg_op, rn, 0, MO_16);
82
+ .version_id = 2,
30
+
83
+ .minimum_version_id = 2,
31
+ switch (opcode) {
84
.fields = (VMStateField[]) {
32
+ case 0x0: /* FMOV */
85
VMSTATE_PTIMER(timer, CMSDKAPBTimer),
33
+ tcg_gen_mov_i32(tcg_res, tcg_op);
86
+ VMSTATE_CLOCK(pclk, CMSDKAPBTimer),
34
+ break;
87
VMSTATE_UINT32(ctrl, CMSDKAPBTimer),
35
+ case 0x1: /* FABS */
88
VMSTATE_UINT32(value, CMSDKAPBTimer),
36
+ tcg_gen_andi_i32(tcg_res, tcg_op, 0x7fff);
89
VMSTATE_UINT32(reload, CMSDKAPBTimer),
37
+ break;
38
+ case 0x2: /* FNEG */
39
+ tcg_gen_xori_i32(tcg_res, tcg_op, 0x8000);
40
+ break;
41
+ case 0x3: /* FSQRT */
42
+ gen_helper_sqrt_f16(tcg_res, tcg_op, cpu_env);
43
+ break;
44
+ case 0x8: /* FRINTN */
45
+ case 0x9: /* FRINTP */
46
+ case 0xa: /* FRINTM */
47
+ case 0xb: /* FRINTZ */
48
+ case 0xc: /* FRINTA */
49
+ {
50
+ TCGv_i32 tcg_rmode = tcg_const_i32(arm_rmode_to_sf(opcode & 7));
51
+ fpst = get_fpstatus_ptr(true);
52
+
53
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
54
+ gen_helper_advsimd_rinth(tcg_res, tcg_op, fpst);
55
+
56
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst);
57
+ tcg_temp_free_i32(tcg_rmode);
58
+ break;
59
+ }
60
+ case 0xe: /* FRINTX */
61
+ fpst = get_fpstatus_ptr(true);
62
+ gen_helper_advsimd_rinth_exact(tcg_res, tcg_op, fpst);
63
+ break;
64
+ case 0xf: /* FRINTI */
65
+ fpst = get_fpstatus_ptr(true);
66
+ gen_helper_advsimd_rinth(tcg_res, tcg_op, fpst);
67
+ break;
68
+ default:
69
+ abort();
70
+ }
71
+
72
+ write_fp_sreg(s, rd, tcg_res);
73
+
74
+ if (fpst) {
75
+ tcg_temp_free_ptr(fpst);
76
+ }
77
+ tcg_temp_free_i32(tcg_op);
78
+ tcg_temp_free_i32(tcg_res);
79
+}
80
+
81
/* Floating-point data-processing (1 source) - single precision */
82
static void handle_fp_1src_single(DisasContext *s, int opcode, int rd, int rn)
83
{
84
@@ -XXX,XX +XXX,XX @@ static void disas_fp_1src(DisasContext *s, uint32_t insn)
85
86
handle_fp_1src_double(s, opcode, rd, rn);
87
break;
88
+ case 3:
89
+ if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
90
+ unallocated_encoding(s);
91
+ return;
92
+ }
93
+
94
+ if (!fp_access_check(s)) {
95
+ return;
96
+ }
97
+
98
+ handle_fp_1src_half(s, opcode, rd, rn);
99
+ break;
100
default:
101
unallocated_encoding(s);
102
}
103
--
90
--
104
2.16.2
91
2.20.1
105
92
106
93
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
As the first step in converting the CMSDK_APB_DUALTIMER device to the
2
Clock framework, add a Clock input. For the moment we do nothing
3
with this clock; we will change the behaviour from using the pclk-frq
4
property to using the Clock once all the users of this device have
5
been converted to wire up the Clock.
2
6
3
The fprintf is only there for debugging as the skeleton is added to,
7
We take the opportunity to correct the name of the clock input to
4
it will be removed once the skeleton is complete.
8
match the hardware -- the dual timer names the clock which drives the
9
timers TIMCLK. (It does also have a 'pclk' input, which is used only
10
for the register and APB bus logic; on the SSE-200 these clocks are
11
both connected together.)
5
12
6
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
13
This is a migration compatibility break for machines mps2-an385,
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
mps2-an386, mps2-an500, mps2-an511, mps2-an505, mps2-an521, musca-a,
8
Message-id: 20180227143852.11175-10-alex.bennee@linaro.org
15
musca-b1.
16
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
19
Reviewed-by: Luc Michel <luc@lmichel.fr>
20
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
21
Message-id: 20210128114145.20536-9-peter.maydell@linaro.org
22
Message-id: 20210121190622.22000-9-peter.maydell@linaro.org
10
---
23
---
11
target/arm/helper-a64.h | 4 ++++
24
include/hw/timer/cmsdk-apb-dualtimer.h | 3 +++
12
target/arm/helper-a64.c | 4 ++++
25
hw/timer/cmsdk-apb-dualtimer.c | 7 +++++--
13
target/arm/translate-a64.c | 28 ++++++++++++++++++++++++++++
26
2 files changed, 8 insertions(+), 2 deletions(-)
14
3 files changed, 36 insertions(+)
15
27
16
diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h
28
diff --git a/include/hw/timer/cmsdk-apb-dualtimer.h b/include/hw/timer/cmsdk-apb-dualtimer.h
17
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/helper-a64.h
30
--- a/include/hw/timer/cmsdk-apb-dualtimer.h
19
+++ b/target/arm/helper-a64.h
31
+++ b/include/hw/timer/cmsdk-apb-dualtimer.h
20
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(advsimd_maxh, TCG_CALL_NO_RWG, f16, f16, f16, ptr)
32
@@ -XXX,XX +XXX,XX @@
21
DEF_HELPER_FLAGS_3(advsimd_minh, TCG_CALL_NO_RWG, f16, f16, f16, ptr)
33
*
22
DEF_HELPER_FLAGS_3(advsimd_maxnumh, TCG_CALL_NO_RWG, f16, f16, f16, ptr)
34
* QEMU interface:
23
DEF_HELPER_FLAGS_3(advsimd_minnumh, TCG_CALL_NO_RWG, f16, f16, f16, ptr)
35
* + QOM property "pclk-frq": frequency at which the timer is clocked
24
+DEF_HELPER_3(advsimd_addh, f16, f16, f16, ptr)
36
+ * + Clock input "TIMCLK": clock (for both timers)
25
+DEF_HELPER_3(advsimd_subh, f16, f16, f16, ptr)
37
* + sysbus MMIO region 0: the register bank
26
+DEF_HELPER_3(advsimd_mulh, f16, f16, f16, ptr)
38
* + sysbus IRQ 0: combined timer interrupt TIMINTC
27
+DEF_HELPER_3(advsimd_divh, f16, f16, f16, ptr)
39
* + sysbus IRO 1: timer block 1 interrupt TIMINT1
28
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
40
@@ -XXX,XX +XXX,XX @@
41
42
#include "hw/sysbus.h"
43
#include "hw/ptimer.h"
44
+#include "hw/clock.h"
45
#include "qom/object.h"
46
47
#define TYPE_CMSDK_APB_DUALTIMER "cmsdk-apb-dualtimer"
48
@@ -XXX,XX +XXX,XX @@ struct CMSDKAPBDualTimer {
49
MemoryRegion iomem;
50
qemu_irq timerintc;
51
uint32_t pclk_frq;
52
+ Clock *timclk;
53
54
CMSDKAPBDualTimerModule timermod[CMSDK_APB_DUALTIMER_NUM_MODULES];
55
uint32_t timeritcr;
56
diff --git a/hw/timer/cmsdk-apb-dualtimer.c b/hw/timer/cmsdk-apb-dualtimer.c
29
index XXXXXXX..XXXXXXX 100644
57
index XXXXXXX..XXXXXXX 100644
30
--- a/target/arm/helper-a64.c
58
--- a/hw/timer/cmsdk-apb-dualtimer.c
31
+++ b/target/arm/helper-a64.c
59
+++ b/hw/timer/cmsdk-apb-dualtimer.c
32
@@ -XXX,XX +XXX,XX @@ float16 ADVSIMD_HELPER(name, h)(float16 a, float16 b, void *fpstp) \
60
@@ -XXX,XX +XXX,XX @@
33
return float16_ ## name(a, b, fpst); \
61
#include "hw/irq.h"
62
#include "hw/qdev-properties.h"
63
#include "hw/registerfields.h"
64
+#include "hw/qdev-clock.h"
65
#include "hw/timer/cmsdk-apb-dualtimer.h"
66
#include "migration/vmstate.h"
67
68
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_dualtimer_init(Object *obj)
69
for (i = 0; i < ARRAY_SIZE(s->timermod); i++) {
70
sysbus_init_irq(sbd, &s->timermod[i].timerint);
71
}
72
+ s->timclk = qdev_init_clock_in(DEVICE(s), "TIMCLK", NULL, NULL);
34
}
73
}
35
74
36
+ADVSIMD_HALFOP(add)
75
static void cmsdk_apb_dualtimer_realize(DeviceState *dev, Error **errp)
37
+ADVSIMD_HALFOP(sub)
76
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription cmsdk_dualtimermod_vmstate = {
38
+ADVSIMD_HALFOP(mul)
77
39
+ADVSIMD_HALFOP(div)
78
static const VMStateDescription cmsdk_apb_dualtimer_vmstate = {
40
ADVSIMD_HALFOP(min)
79
.name = "cmsdk-apb-dualtimer",
41
ADVSIMD_HALFOP(max)
80
- .version_id = 1,
42
ADVSIMD_HALFOP(minnum)
81
- .minimum_version_id = 1,
43
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
82
+ .version_id = 2,
44
index XXXXXXX..XXXXXXX 100644
83
+ .minimum_version_id = 2,
45
--- a/target/arm/translate-a64.c
84
.fields = (VMStateField[]) {
46
+++ b/target/arm/translate-a64.c
85
+ VMSTATE_CLOCK(timclk, CMSDKAPBDualTimer),
47
@@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn)
86
VMSTATE_STRUCT_ARRAY(timermod, CMSDKAPBDualTimer,
48
read_vec_element_i32(s, tcg_op2, rm, pass, MO_16);
87
CMSDK_APB_DUALTIMER_NUM_MODULES,
49
88
1, cmsdk_dualtimermod_vmstate,
50
switch (fpopcode) {
51
+ case 0x0: /* FMAXNM */
52
+ gen_helper_advsimd_maxnumh(tcg_res, tcg_op1, tcg_op2, fpst);
53
+ break;
54
+ case 0x2: /* FADD */
55
+ gen_helper_advsimd_addh(tcg_res, tcg_op1, tcg_op2, fpst);
56
+ break;
57
+ case 0x6: /* FMAX */
58
+ gen_helper_advsimd_maxh(tcg_res, tcg_op1, tcg_op2, fpst);
59
+ break;
60
+ case 0x8: /* FMINNM */
61
+ gen_helper_advsimd_minnumh(tcg_res, tcg_op1, tcg_op2, fpst);
62
+ break;
63
+ case 0xa: /* FSUB */
64
+ gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst);
65
+ break;
66
+ case 0xe: /* FMIN */
67
+ gen_helper_advsimd_minh(tcg_res, tcg_op1, tcg_op2, fpst);
68
+ break;
69
+ case 0x13: /* FMUL */
70
+ gen_helper_advsimd_mulh(tcg_res, tcg_op1, tcg_op2, fpst);
71
+ break;
72
+ case 0x17: /* FDIV */
73
+ gen_helper_advsimd_divh(tcg_res, tcg_op1, tcg_op2, fpst);
74
+ break;
75
+ case 0x1a: /* FABD */
76
+ gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst);
77
+ tcg_gen_andi_i32(tcg_res, tcg_res, 0x7fff);
78
+ break;
79
default:
80
fprintf(stderr, "%s: insn %#04x, fpop %#2x @ %#" PRIx64 "\n",
81
__func__, insn, fpopcode, s->pc);
82
--
89
--
83
2.16.2
90
2.20.1
84
91
85
92
diff view generated by jsdifflib
New patch
1
As the first step in converting the CMSDK_APB_TIMER device to the
2
Clock framework, add a Clock input. For the moment we do nothing
3
with this clock; we will change the behaviour from using the
4
wdogclk-frq property to using the Clock once all the users of this
5
device have been converted to wire up the Clock.
1
6
7
This is a migration compatibility break for machines mps2-an385,
8
mps2-an386, mps2-an500, mps2-an511, mps2-an505, mps2-an521, musca-a,
9
musca-b1, lm3s811evb, lm3s6965evb.
10
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
Reviewed-by: Luc Michel <luc@lmichel.fr>
14
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
Message-id: 20210128114145.20536-10-peter.maydell@linaro.org
16
Message-id: 20210121190622.22000-10-peter.maydell@linaro.org
17
---
18
include/hw/watchdog/cmsdk-apb-watchdog.h | 3 +++
19
hw/watchdog/cmsdk-apb-watchdog.c | 7 +++++--
20
2 files changed, 8 insertions(+), 2 deletions(-)
21
22
diff --git a/include/hw/watchdog/cmsdk-apb-watchdog.h b/include/hw/watchdog/cmsdk-apb-watchdog.h
23
index XXXXXXX..XXXXXXX 100644
24
--- a/include/hw/watchdog/cmsdk-apb-watchdog.h
25
+++ b/include/hw/watchdog/cmsdk-apb-watchdog.h
26
@@ -XXX,XX +XXX,XX @@
27
*
28
* QEMU interface:
29
* + QOM property "wdogclk-frq": frequency at which the watchdog is clocked
30
+ * + Clock input "WDOGCLK": clock for the watchdog's timer
31
* + sysbus MMIO region 0: the register bank
32
* + sysbus IRQ 0: watchdog interrupt
33
*
34
@@ -XXX,XX +XXX,XX @@
35
36
#include "hw/sysbus.h"
37
#include "hw/ptimer.h"
38
+#include "hw/clock.h"
39
#include "qom/object.h"
40
41
#define TYPE_CMSDK_APB_WATCHDOG "cmsdk-apb-watchdog"
42
@@ -XXX,XX +XXX,XX @@ struct CMSDKAPBWatchdog {
43
uint32_t wdogclk_frq;
44
bool is_luminary;
45
struct ptimer_state *timer;
46
+ Clock *wdogclk;
47
48
uint32_t control;
49
uint32_t intstatus;
50
diff --git a/hw/watchdog/cmsdk-apb-watchdog.c b/hw/watchdog/cmsdk-apb-watchdog.c
51
index XXXXXXX..XXXXXXX 100644
52
--- a/hw/watchdog/cmsdk-apb-watchdog.c
53
+++ b/hw/watchdog/cmsdk-apb-watchdog.c
54
@@ -XXX,XX +XXX,XX @@
55
#include "hw/irq.h"
56
#include "hw/qdev-properties.h"
57
#include "hw/registerfields.h"
58
+#include "hw/qdev-clock.h"
59
#include "hw/watchdog/cmsdk-apb-watchdog.h"
60
#include "migration/vmstate.h"
61
62
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_init(Object *obj)
63
s, "cmsdk-apb-watchdog", 0x1000);
64
sysbus_init_mmio(sbd, &s->iomem);
65
sysbus_init_irq(sbd, &s->wdogint);
66
+ s->wdogclk = qdev_init_clock_in(DEVICE(s), "WDOGCLK", NULL, NULL);
67
68
s->is_luminary = false;
69
s->id = cmsdk_apb_watchdog_id;
70
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_realize(DeviceState *dev, Error **errp)
71
72
static const VMStateDescription cmsdk_apb_watchdog_vmstate = {
73
.name = "cmsdk-apb-watchdog",
74
- .version_id = 1,
75
- .minimum_version_id = 1,
76
+ .version_id = 2,
77
+ .minimum_version_id = 2,
78
.fields = (VMStateField[]) {
79
+ VMSTATE_CLOCK(wdogclk, CMSDKAPBWatchdog),
80
VMSTATE_PTIMER(timer, CMSDKAPBWatchdog),
81
VMSTATE_UINT32(control, CMSDKAPBWatchdog),
82
VMSTATE_UINT32(intstatus, CMSDKAPBWatchdog),
83
--
84
2.20.1
85
86
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
While we transition the ARMSSE code from integer properties
2
specifying clock frequencies to Clock objects, we want to have the
3
device provide both at once. We want the final name of the main
4
input Clock to be "MAINCLK", following the hardware name.
5
Unfortunately creating an input Clock with a name X creates an
6
under-the-hood QOM property X; for "MAINCLK" this clashes with the
7
existing UINT32 property of that name.
2
8
3
Only one half-precision instruction has been added to this group.
9
Rename the UINT32 property to MAINCLK_FRQ so it can coexist with the
10
MAINCLK Clock; once the transition is complete MAINCLK_FRQ will be
11
deleted.
4
12
5
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
13
Commit created with:
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
perl -p -i -e 's/MAINCLK/MAINCLK_FRQ/g' hw/arm/{armsse,mps2-tz,musca}.c include/hw/arm/armsse.h
7
Message-id: 20180227143852.11175-29-alex.bennee@linaro.org
15
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
18
Reviewed-by: Luc Michel <luc@lmichel.fr>
19
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
20
Message-id: 20210128114145.20536-11-peter.maydell@linaro.org
21
Message-id: 20210121190622.22000-11-peter.maydell@linaro.org
9
---
22
---
10
target/arm/translate-a64.c | 35 +++++++++++++++++++++++++----------
23
include/hw/arm/armsse.h | 2 +-
11
1 file changed, 25 insertions(+), 10 deletions(-)
24
hw/arm/armsse.c | 6 +++---
25
hw/arm/mps2-tz.c | 2 +-
26
hw/arm/musca.c | 2 +-
27
4 files changed, 6 insertions(+), 6 deletions(-)
12
28
13
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
29
diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h
14
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/translate-a64.c
31
--- a/include/hw/arm/armsse.h
16
+++ b/target/arm/translate-a64.c
32
+++ b/include/hw/arm/armsse.h
17
@@ -XXX,XX +XXX,XX @@ static void disas_simd_copy(DisasContext *s, uint32_t insn)
33
@@ -XXX,XX +XXX,XX @@
18
* MVNI - move inverted (shifted) imm into register
34
* QEMU interface:
19
* ORR - bitwise OR of (shifted) imm with register
35
* + QOM property "memory" is a MemoryRegion containing the devices provided
20
* BIC - bitwise clear of (shifted) imm with register
36
* by the board model.
21
+ * With ARMv8.2 we also have:
37
- * + QOM property "MAINCLK" is the frequency of the main system clock
22
+ * FMOV half-precision
38
+ * + QOM property "MAINCLK_FRQ" is the frequency of the main system clock
23
*/
39
* + QOM property "EXP_NUMIRQ" sets the number of expansion interrupts.
24
static void disas_simd_mod_imm(DisasContext *s, uint32_t insn)
40
* (In hardware, the SSE-200 permits the number of expansion interrupts
25
{
41
* for the two CPUs to be configured separately, but we restrict it to
26
@@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn)
42
diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c
27
uint64_t imm = 0;
43
index XXXXXXX..XXXXXXX 100644
28
44
--- a/hw/arm/armsse.c
29
if (o2 != 0 || ((cmode == 0xf) && is_neg && !is_q)) {
45
+++ b/hw/arm/armsse.c
30
- unallocated_encoding(s);
46
@@ -XXX,XX +XXX,XX @@ static Property iotkit_properties[] = {
31
- return;
47
DEFINE_PROP_LINK("memory", ARMSSE, board_memory, TYPE_MEMORY_REGION,
32
+ /* Check for FMOV (vector, immediate) - half-precision */
48
MemoryRegion *),
33
+ if (!(arm_dc_feature(s, ARM_FEATURE_V8_FP16) && o2 && cmode == 0xf)) {
49
DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64),
34
+ unallocated_encoding(s);
50
- DEFINE_PROP_UINT32("MAINCLK", ARMSSE, mainclk_frq, 0),
35
+ return;
51
+ DEFINE_PROP_UINT32("MAINCLK_FRQ", ARMSSE, mainclk_frq, 0),
36
+ }
52
DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 15),
53
DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000),
54
DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], true),
55
@@ -XXX,XX +XXX,XX @@ static Property armsse_properties[] = {
56
DEFINE_PROP_LINK("memory", ARMSSE, board_memory, TYPE_MEMORY_REGION,
57
MemoryRegion *),
58
DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64),
59
- DEFINE_PROP_UINT32("MAINCLK", ARMSSE, mainclk_frq, 0),
60
+ DEFINE_PROP_UINT32("MAINCLK_FRQ", ARMSSE, mainclk_frq, 0),
61
DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 15),
62
DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000),
63
DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], false),
64
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
37
}
65
}
38
66
39
if (!fp_access_check(s)) {
67
if (!s->mainclk_frq) {
40
@@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn)
68
- error_setg(errp, "MAINCLK property was not set");
41
imm |= 0x4000000000000000ULL;
69
+ error_setg(errp, "MAINCLK_FRQ property was not set");
42
}
70
return;
43
} else {
44
- imm = (abcdefgh & 0x3f) << 19;
45
- if (abcdefgh & 0x80) {
46
- imm |= 0x80000000;
47
- }
48
- if (abcdefgh & 0x40) {
49
- imm |= 0x3e000000;
50
+ if (o2) {
51
+ /* FMOV (vector, immediate) - half-precision */
52
+ imm = vfp_expand_imm(MO_16, abcdefgh);
53
+ /* now duplicate across the lanes */
54
+ imm = bitfield_replicate(imm, 16);
55
} else {
56
- imm |= 0x40000000;
57
+ imm = (abcdefgh & 0x3f) << 19;
58
+ if (abcdefgh & 0x80) {
59
+ imm |= 0x80000000;
60
+ }
61
+ if (abcdefgh & 0x40) {
62
+ imm |= 0x3e000000;
63
+ } else {
64
+ imm |= 0x40000000;
65
+ }
66
+ imm |= (imm << 32);
67
}
68
- imm |= (imm << 32);
69
}
70
}
71
break;
72
+ default:
73
+ fprintf(stderr, "%s: cmode_3_1: %x\n", __func__, cmode_3_1);
74
+ g_assert_not_reached();
75
}
71
}
76
72
77
if (cmode_3_1 != 7 && is_neg) {
73
diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c
74
index XXXXXXX..XXXXXXX 100644
75
--- a/hw/arm/mps2-tz.c
76
+++ b/hw/arm/mps2-tz.c
77
@@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine)
78
object_property_set_link(OBJECT(&mms->iotkit), "memory",
79
OBJECT(system_memory), &error_abort);
80
qdev_prop_set_uint32(iotkitdev, "EXP_NUMIRQ", MPS2TZ_NUMIRQ);
81
- qdev_prop_set_uint32(iotkitdev, "MAINCLK", SYSCLK_FRQ);
82
+ qdev_prop_set_uint32(iotkitdev, "MAINCLK_FRQ", SYSCLK_FRQ);
83
sysbus_realize(SYS_BUS_DEVICE(&mms->iotkit), &error_fatal);
84
85
/*
86
diff --git a/hw/arm/musca.c b/hw/arm/musca.c
87
index XXXXXXX..XXXXXXX 100644
88
--- a/hw/arm/musca.c
89
+++ b/hw/arm/musca.c
90
@@ -XXX,XX +XXX,XX @@ static void musca_init(MachineState *machine)
91
qdev_prop_set_uint32(ssedev, "EXP_NUMIRQ", mmc->num_irqs);
92
qdev_prop_set_uint32(ssedev, "init-svtor", mmc->init_svtor);
93
qdev_prop_set_uint32(ssedev, "SRAM_ADDR_WIDTH", mmc->sram_addr_width);
94
- qdev_prop_set_uint32(ssedev, "MAINCLK", SYSCLK_FRQ);
95
+ qdev_prop_set_uint32(ssedev, "MAINCLK_FRQ", SYSCLK_FRQ);
96
/*
97
* Musca-A takes the default SSE-200 FPU/DSP settings (ie no for
98
* CPU0 and yes for CPU1); Musca-B1 explicitly enables them for CPU0.
78
--
99
--
79
2.16.2
100
2.20.1
80
101
81
102
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
Create two input clocks on the ARMSSE devices, one for the normal
2
MAINCLK, and one for the 32KHz S32KCLK, and wire these up to the
3
appropriate devices. The old property-based clock frequency setting
4
will remain in place until conversion is complete.
2
5
3
Neither of these operations alter the floating point status registers
6
This is a migration compatibility break for machines mps2-an505,
4
so we can do a pure bitwise operation, either squashing any sign
7
mps2-an521, musca-a, musca-b1.
5
bit (ABS) or inverting it (NEG).
6
8
7
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20180227143852.11175-22-alex.bennee@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Reviewed-by: Luc Michel <luc@lmichel.fr>
12
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
Message-id: 20210128114145.20536-12-peter.maydell@linaro.org
14
Message-id: 20210121190622.22000-12-peter.maydell@linaro.org
11
---
15
---
12
target/arm/translate-a64.c | 16 +++++++++++++++-
16
include/hw/arm/armsse.h | 6 ++++++
13
1 file changed, 15 insertions(+), 1 deletion(-)
17
hw/arm/armsse.c | 17 +++++++++++++++--
18
2 files changed, 21 insertions(+), 2 deletions(-)
14
19
15
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
20
diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h
16
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/translate-a64.c
22
--- a/include/hw/arm/armsse.h
18
+++ b/target/arm/translate-a64.c
23
+++ b/include/hw/arm/armsse.h
19
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
24
@@ -XXX,XX +XXX,XX @@
20
TCGv_i32 tcg_rmode = NULL;
25
* per-CPU identity and control register blocks
21
TCGv_ptr tcg_fpstatus = NULL;
26
*
22
bool need_rmode = false;
27
* QEMU interface:
23
+ bool need_fpst = true;
28
+ * + Clock input "MAINCLK": clock for CPUs and most peripherals
24
int rmode;
29
+ * + Clock input "S32KCLK": slow 32KHz clock used for a few peripherals
25
30
* + QOM property "memory" is a MemoryRegion containing the devices provided
26
if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
31
* by the board model.
27
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
32
* + QOM property "MAINCLK_FRQ" is the frequency of the main system clock
28
need_rmode = true;
33
@@ -XXX,XX +XXX,XX @@
29
rmode = FPROUNDING_ZERO;
34
#include "hw/misc/armsse-mhu.h"
30
break;
35
#include "hw/misc/unimp.h"
31
+ case 0x2f: /* FABS */
36
#include "hw/or-irq.h"
32
+ case 0x6f: /* FNEG */
37
+#include "hw/clock.h"
33
+ need_fpst = false;
38
#include "hw/core/split-irq.h"
34
+ break;
39
#include "hw/cpu/cluster.h"
35
default:
40
#include "qom/object.h"
36
fprintf(stderr, "%s: insn %#04x fpop %#2x\n", __func__, insn, fpop);
41
@@ -XXX,XX +XXX,XX @@ struct ARMSSE {
37
g_assert_not_reached();
42
38
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
43
uint32_t nsccfg;
44
45
+ Clock *mainclk;
46
+ Clock *s32kclk;
47
+
48
/* Properties */
49
MemoryRegion *board_memory;
50
uint32_t exp_numirq;
51
diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c
52
index XXXXXXX..XXXXXXX 100644
53
--- a/hw/arm/armsse.c
54
+++ b/hw/arm/armsse.c
55
@@ -XXX,XX +XXX,XX @@
56
#include "hw/arm/armsse.h"
57
#include "hw/arm/boot.h"
58
#include "hw/irq.h"
59
+#include "hw/qdev-clock.h"
60
61
/* Format of the System Information block SYS_CONFIG register */
62
typedef enum SysConfigFormat {
63
@@ -XXX,XX +XXX,XX @@ static void armsse_init(Object *obj)
64
assert(info->sram_banks <= MAX_SRAM_BANKS);
65
assert(info->num_cpus <= SSE_MAX_CPUS);
66
67
+ s->mainclk = qdev_init_clock_in(DEVICE(s), "MAINCLK", NULL, NULL);
68
+ s->s32kclk = qdev_init_clock_in(DEVICE(s), "S32KCLK", NULL, NULL);
69
+
70
memory_region_init(&s->container, obj, "armsse-container", UINT64_MAX);
71
72
for (i = 0; i < info->num_cpus; i++) {
73
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
74
* map its upstream ends to the right place in the container.
75
*/
76
qdev_prop_set_uint32(DEVICE(&s->timer0), "pclk-frq", s->mainclk_frq);
77
+ qdev_connect_clock_in(DEVICE(&s->timer0), "pclk", s->mainclk);
78
if (!sysbus_realize(SYS_BUS_DEVICE(&s->timer0), errp)) {
39
return;
79
return;
40
}
80
}
41
81
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
42
- if (need_rmode) {
82
&error_abort);
43
+ if (need_rmode || need_fpst) {
83
44
tcg_fpstatus = get_fpstatus_ptr(true);
84
qdev_prop_set_uint32(DEVICE(&s->timer1), "pclk-frq", s->mainclk_frq);
85
+ qdev_connect_clock_in(DEVICE(&s->timer1), "pclk", s->mainclk);
86
if (!sysbus_realize(SYS_BUS_DEVICE(&s->timer1), errp)) {
87
return;
45
}
88
}
46
89
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
47
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
90
&error_abort);
48
case 0x7b: /* FCVTZU */
91
49
gen_helper_advsimd_f16touinth(tcg_res, tcg_op, tcg_fpstatus);
92
qdev_prop_set_uint32(DEVICE(&s->dualtimer), "pclk-frq", s->mainclk_frq);
50
break;
93
+ qdev_connect_clock_in(DEVICE(&s->dualtimer), "TIMCLK", s->mainclk);
51
+ case 0x6f: /* FNEG */
94
if (!sysbus_realize(SYS_BUS_DEVICE(&s->dualtimer), errp)) {
52
+ tcg_gen_xori_i32(tcg_res, tcg_op, 0x8000);
95
return;
53
+ break;
96
}
54
default:
97
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
55
g_assert_not_reached();
98
* 0x4002f000: S32K timer
56
}
99
*/
57
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
100
qdev_prop_set_uint32(DEVICE(&s->s32ktimer), "pclk-frq", S32KCLK);
58
case 0x59: /* FRINTX */
101
+ qdev_connect_clock_in(DEVICE(&s->s32ktimer), "pclk", s->s32kclk);
59
gen_helper_advsimd_rinth_exact(tcg_res, tcg_op, tcg_fpstatus);
102
if (!sysbus_realize(SYS_BUS_DEVICE(&s->s32ktimer), errp)) {
60
break;
103
return;
61
+ case 0x2f: /* FABS */
104
}
62
+ tcg_gen_andi_i32(tcg_res, tcg_op, 0x7fff);
105
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
63
+ break;
106
qdev_get_gpio_in_named(DEVICE(&s->armv7m), "NMI", 0));
64
+ case 0x6f: /* FNEG */
107
65
+ tcg_gen_xori_i32(tcg_res, tcg_op, 0x8000);
108
qdev_prop_set_uint32(DEVICE(&s->s32kwatchdog), "wdogclk-frq", S32KCLK);
66
+ break;
109
+ qdev_connect_clock_in(DEVICE(&s->s32kwatchdog), "WDOGCLK", s->s32kclk);
67
default:
110
if (!sysbus_realize(SYS_BUS_DEVICE(&s->s32kwatchdog), errp)) {
68
g_assert_not_reached();
111
return;
69
}
112
}
113
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
114
/* 0x40080000 .. 0x4008ffff : ARMSSE second Base peripheral region */
115
116
qdev_prop_set_uint32(DEVICE(&s->nswatchdog), "wdogclk-frq", s->mainclk_frq);
117
+ qdev_connect_clock_in(DEVICE(&s->nswatchdog), "WDOGCLK", s->mainclk);
118
if (!sysbus_realize(SYS_BUS_DEVICE(&s->nswatchdog), errp)) {
119
return;
120
}
121
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
122
sysbus_mmio_map(SYS_BUS_DEVICE(&s->nswatchdog), 0, 0x40081000);
123
124
qdev_prop_set_uint32(DEVICE(&s->swatchdog), "wdogclk-frq", s->mainclk_frq);
125
+ qdev_connect_clock_in(DEVICE(&s->swatchdog), "WDOGCLK", s->mainclk);
126
if (!sysbus_realize(SYS_BUS_DEVICE(&s->swatchdog), errp)) {
127
return;
128
}
129
@@ -XXX,XX +XXX,XX @@ static void armsse_idau_check(IDAUInterface *ii, uint32_t address,
130
131
static const VMStateDescription armsse_vmstate = {
132
.name = "iotkit",
133
- .version_id = 1,
134
- .minimum_version_id = 1,
135
+ .version_id = 2,
136
+ .minimum_version_id = 2,
137
.fields = (VMStateField[]) {
138
+ VMSTATE_CLOCK(mainclk, ARMSSE),
139
+ VMSTATE_CLOCK(s32kclk, ARMSSE),
140
VMSTATE_UINT32(nsccfg, ARMSSE),
141
VMSTATE_END_OF_LIST()
142
}
70
--
143
--
71
2.16.2
144
2.20.1
72
145
73
146
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
The old-style convenience function cmsdk_apb_timer_create() for
2
creating CMSDK_APB_TIMER objects is used in only two places in
3
mps2.c. Most of the rest of the code in that file uses the new
4
"initialize in place" coding style.
2
5
3
This includes FMAXNMP, FADDP, FMAXP, FMINNMP, FMINP.
6
We want to connect up a Clock object which should be done between the
7
object creation and realization; rather than adding a Clock* argument
8
to the convenience function, convert the timer creation code in
9
mps2.c to the same style as is used already for the watchdog,
10
dualtimer and other devices, and delete the now-unused convenience
11
function.
4
12
5
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20180227143852.11175-14-alex.bennee@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
Reviewed-by: Luc Michel <luc@lmichel.fr>
16
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
17
Message-id: 20210128114145.20536-13-peter.maydell@linaro.org
18
Message-id: 20210121190622.22000-13-peter.maydell@linaro.org
9
---
19
---
10
target/arm/translate-a64.c | 208 +++++++++++++++++++++++++++++----------------
20
include/hw/timer/cmsdk-apb-timer.h | 21 ---------------------
11
1 file changed, 133 insertions(+), 75 deletions(-)
21
hw/arm/mps2.c | 18 ++++++++++++++++--
22
2 files changed, 16 insertions(+), 23 deletions(-)
12
23
13
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
24
diff --git a/include/hw/timer/cmsdk-apb-timer.h b/include/hw/timer/cmsdk-apb-timer.h
14
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/translate-a64.c
26
--- a/include/hw/timer/cmsdk-apb-timer.h
16
+++ b/target/arm/translate-a64.c
27
+++ b/include/hw/timer/cmsdk-apb-timer.h
17
@@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn)
28
@@ -XXX,XX +XXX,XX @@ struct CMSDKAPBTimer {
18
int datasize, elements;
29
uint32_t intstatus;
19
int pass;
30
};
20
TCGv_ptr fpst;
31
21
+ bool pairwise = false;
32
-/**
22
33
- * cmsdk_apb_timer_create - convenience function to create TYPE_CMSDK_APB_TIMER
23
if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
34
- * @addr: location in system memory to map registers
24
unallocated_encoding(s);
35
- * @pclk_frq: frequency in Hz of the PCLK clock (used for calculating baud rate)
25
@@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn)
36
- */
26
datasize = is_q ? 128 : 64;
37
-static inline DeviceState *cmsdk_apb_timer_create(hwaddr addr,
27
elements = datasize / 16;
38
- qemu_irq timerint,
28
39
- uint32_t pclk_frq)
29
+ switch (fpopcode) {
40
-{
30
+ case 0x10: /* FMAXNMP */
41
- DeviceState *dev;
31
+ case 0x12: /* FADDP */
42
- SysBusDevice *s;
32
+ case 0x16: /* FMAXP */
43
-
33
+ case 0x18: /* FMINNMP */
44
- dev = qdev_new(TYPE_CMSDK_APB_TIMER);
34
+ case 0x1e: /* FMINP */
45
- s = SYS_BUS_DEVICE(dev);
35
+ pairwise = true;
46
- qdev_prop_set_uint32(dev, "pclk-frq", pclk_frq);
36
+ break;
47
- sysbus_realize_and_unref(s, &error_fatal);
48
- sysbus_mmio_map(s, 0, addr);
49
- sysbus_connect_irq(s, 0, timerint);
50
- return dev;
51
-}
52
-
53
#endif
54
diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
55
index XXXXXXX..XXXXXXX 100644
56
--- a/hw/arm/mps2.c
57
+++ b/hw/arm/mps2.c
58
@@ -XXX,XX +XXX,XX @@ struct MPS2MachineState {
59
/* CMSDK APB subsystem */
60
CMSDKAPBDualTimer dualtimer;
61
CMSDKAPBWatchdog watchdog;
62
+ CMSDKAPBTimer timer[2];
63
};
64
65
#define TYPE_MPS2_MACHINE "mps2"
66
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
67
}
68
69
/* CMSDK APB subsystem */
70
- cmsdk_apb_timer_create(0x40000000, qdev_get_gpio_in(armv7m, 8), SYSCLK_FRQ);
71
- cmsdk_apb_timer_create(0x40001000, qdev_get_gpio_in(armv7m, 9), SYSCLK_FRQ);
72
+ for (i = 0; i < ARRAY_SIZE(mms->timer); i++) {
73
+ g_autofree char *name = g_strdup_printf("timer%d", i);
74
+ hwaddr base = 0x40000000 + i * 0x1000;
75
+ int irqno = 8 + i;
76
+ SysBusDevice *sbd;
77
+
78
+ object_initialize_child(OBJECT(mms), name, &mms->timer[i],
79
+ TYPE_CMSDK_APB_TIMER);
80
+ sbd = SYS_BUS_DEVICE(&mms->timer[i]);
81
+ qdev_prop_set_uint32(DEVICE(&mms->timer[i]), "pclk-frq", SYSCLK_FRQ);
82
+ sysbus_realize_and_unref(sbd, &error_fatal);
83
+ sysbus_mmio_map(sbd, 0, base);
84
+ sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(armv7m, irqno));
37
+ }
85
+ }
38
+
86
+
39
fpst = get_fpstatus_ptr(true);
87
object_initialize_child(OBJECT(mms), "dualtimer", &mms->dualtimer,
40
88
TYPE_CMSDK_APB_DUALTIMER);
41
- for (pass = 0; pass < elements; pass++) {
89
qdev_prop_set_uint32(DEVICE(&mms->dualtimer), "pclk-frq", SYSCLK_FRQ);
42
+ if (pairwise) {
43
+ int maxpass = is_q ? 8 : 4;
44
TCGv_i32 tcg_op1 = tcg_temp_new_i32();
45
TCGv_i32 tcg_op2 = tcg_temp_new_i32();
46
- TCGv_i32 tcg_res = tcg_temp_new_i32();
47
+ TCGv_i32 tcg_res[8];
48
49
- read_vec_element_i32(s, tcg_op1, rn, pass, MO_16);
50
- read_vec_element_i32(s, tcg_op2, rm, pass, MO_16);
51
+ for (pass = 0; pass < maxpass; pass++) {
52
+ int passreg = pass < (maxpass / 2) ? rn : rm;
53
+ int passelt = (pass << 1) & (maxpass - 1);
54
55
- switch (fpopcode) {
56
- case 0x0: /* FMAXNM */
57
- gen_helper_advsimd_maxnumh(tcg_res, tcg_op1, tcg_op2, fpst);
58
- break;
59
- case 0x1: /* FMLA */
60
- read_vec_element_i32(s, tcg_res, rd, pass, MO_16);
61
- gen_helper_advsimd_muladdh(tcg_res, tcg_op1, tcg_op2, tcg_res,
62
- fpst);
63
- break;
64
- case 0x2: /* FADD */
65
- gen_helper_advsimd_addh(tcg_res, tcg_op1, tcg_op2, fpst);
66
- break;
67
- case 0x3: /* FMULX */
68
- gen_helper_advsimd_mulxh(tcg_res, tcg_op1, tcg_op2, fpst);
69
- break;
70
- case 0x4: /* FCMEQ */
71
- gen_helper_advsimd_ceq_f16(tcg_res, tcg_op1, tcg_op2, fpst);
72
- break;
73
- case 0x6: /* FMAX */
74
- gen_helper_advsimd_maxh(tcg_res, tcg_op1, tcg_op2, fpst);
75
- break;
76
- case 0x7: /* FRECPS */
77
- gen_helper_recpsf_f16(tcg_res, tcg_op1, tcg_op2, fpst);
78
- break;
79
- case 0x8: /* FMINNM */
80
- gen_helper_advsimd_minnumh(tcg_res, tcg_op1, tcg_op2, fpst);
81
- break;
82
- case 0x9: /* FMLS */
83
- /* As usual for ARM, separate negation for fused multiply-add */
84
- tcg_gen_xori_i32(tcg_op1, tcg_op1, 0x8000);
85
- read_vec_element_i32(s, tcg_res, rd, pass, MO_16);
86
- gen_helper_advsimd_muladdh(tcg_res, tcg_op1, tcg_op2, tcg_res,
87
- fpst);
88
- break;
89
- case 0xa: /* FSUB */
90
- gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst);
91
- break;
92
- case 0xe: /* FMIN */
93
- gen_helper_advsimd_minh(tcg_res, tcg_op1, tcg_op2, fpst);
94
- break;
95
- case 0xf: /* FRSQRTS */
96
- gen_helper_rsqrtsf_f16(tcg_res, tcg_op1, tcg_op2, fpst);
97
- break;
98
- case 0x13: /* FMUL */
99
- gen_helper_advsimd_mulh(tcg_res, tcg_op1, tcg_op2, fpst);
100
- break;
101
- case 0x14: /* FCMGE */
102
- gen_helper_advsimd_cge_f16(tcg_res, tcg_op1, tcg_op2, fpst);
103
- break;
104
- case 0x15: /* FACGE */
105
- gen_helper_advsimd_acge_f16(tcg_res, tcg_op1, tcg_op2, fpst);
106
- break;
107
- case 0x17: /* FDIV */
108
- gen_helper_advsimd_divh(tcg_res, tcg_op1, tcg_op2, fpst);
109
- break;
110
- case 0x1a: /* FABD */
111
- gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst);
112
- tcg_gen_andi_i32(tcg_res, tcg_res, 0x7fff);
113
- break;
114
- case 0x1c: /* FCMGT */
115
- gen_helper_advsimd_cgt_f16(tcg_res, tcg_op1, tcg_op2, fpst);
116
- break;
117
- case 0x1d: /* FACGT */
118
- gen_helper_advsimd_acgt_f16(tcg_res, tcg_op1, tcg_op2, fpst);
119
- break;
120
- default:
121
- fprintf(stderr, "%s: insn %#04x, fpop %#2x @ %#" PRIx64 "\n",
122
- __func__, insn, fpopcode, s->pc);
123
- g_assert_not_reached();
124
+ read_vec_element_i32(s, tcg_op1, passreg, passelt, MO_16);
125
+ read_vec_element_i32(s, tcg_op2, passreg, passelt + 1, MO_16);
126
+ tcg_res[pass] = tcg_temp_new_i32();
127
+
128
+ switch (fpopcode) {
129
+ case 0x10: /* FMAXNMP */
130
+ gen_helper_advsimd_maxnumh(tcg_res[pass], tcg_op1, tcg_op2,
131
+ fpst);
132
+ break;
133
+ case 0x12: /* FADDP */
134
+ gen_helper_advsimd_addh(tcg_res[pass], tcg_op1, tcg_op2, fpst);
135
+ break;
136
+ case 0x16: /* FMAXP */
137
+ gen_helper_advsimd_maxh(tcg_res[pass], tcg_op1, tcg_op2, fpst);
138
+ break;
139
+ case 0x18: /* FMINNMP */
140
+ gen_helper_advsimd_minnumh(tcg_res[pass], tcg_op1, tcg_op2,
141
+ fpst);
142
+ break;
143
+ case 0x1e: /* FMINP */
144
+ gen_helper_advsimd_minh(tcg_res[pass], tcg_op1, tcg_op2, fpst);
145
+ break;
146
+ default:
147
+ g_assert_not_reached();
148
+ }
149
+ }
150
+
151
+ for (pass = 0; pass < maxpass; pass++) {
152
+ write_vec_element_i32(s, tcg_res[pass], rd, pass, MO_16);
153
+ tcg_temp_free_i32(tcg_res[pass]);
154
}
155
156
- write_vec_element_i32(s, tcg_res, rd, pass, MO_16);
157
- tcg_temp_free_i32(tcg_res);
158
tcg_temp_free_i32(tcg_op1);
159
tcg_temp_free_i32(tcg_op2);
160
+
161
+ } else {
162
+ for (pass = 0; pass < elements; pass++) {
163
+ TCGv_i32 tcg_op1 = tcg_temp_new_i32();
164
+ TCGv_i32 tcg_op2 = tcg_temp_new_i32();
165
+ TCGv_i32 tcg_res = tcg_temp_new_i32();
166
+
167
+ read_vec_element_i32(s, tcg_op1, rn, pass, MO_16);
168
+ read_vec_element_i32(s, tcg_op2, rm, pass, MO_16);
169
+
170
+ switch (fpopcode) {
171
+ case 0x0: /* FMAXNM */
172
+ gen_helper_advsimd_maxnumh(tcg_res, tcg_op1, tcg_op2, fpst);
173
+ break;
174
+ case 0x1: /* FMLA */
175
+ read_vec_element_i32(s, tcg_res, rd, pass, MO_16);
176
+ gen_helper_advsimd_muladdh(tcg_res, tcg_op1, tcg_op2, tcg_res,
177
+ fpst);
178
+ break;
179
+ case 0x2: /* FADD */
180
+ gen_helper_advsimd_addh(tcg_res, tcg_op1, tcg_op2, fpst);
181
+ break;
182
+ case 0x3: /* FMULX */
183
+ gen_helper_advsimd_mulxh(tcg_res, tcg_op1, tcg_op2, fpst);
184
+ break;
185
+ case 0x4: /* FCMEQ */
186
+ gen_helper_advsimd_ceq_f16(tcg_res, tcg_op1, tcg_op2, fpst);
187
+ break;
188
+ case 0x6: /* FMAX */
189
+ gen_helper_advsimd_maxh(tcg_res, tcg_op1, tcg_op2, fpst);
190
+ break;
191
+ case 0x7: /* FRECPS */
192
+ gen_helper_recpsf_f16(tcg_res, tcg_op1, tcg_op2, fpst);
193
+ break;
194
+ case 0x8: /* FMINNM */
195
+ gen_helper_advsimd_minnumh(tcg_res, tcg_op1, tcg_op2, fpst);
196
+ break;
197
+ case 0x9: /* FMLS */
198
+ /* As usual for ARM, separate negation for fused multiply-add */
199
+ tcg_gen_xori_i32(tcg_op1, tcg_op1, 0x8000);
200
+ read_vec_element_i32(s, tcg_res, rd, pass, MO_16);
201
+ gen_helper_advsimd_muladdh(tcg_res, tcg_op1, tcg_op2, tcg_res,
202
+ fpst);
203
+ break;
204
+ case 0xa: /* FSUB */
205
+ gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst);
206
+ break;
207
+ case 0xe: /* FMIN */
208
+ gen_helper_advsimd_minh(tcg_res, tcg_op1, tcg_op2, fpst);
209
+ break;
210
+ case 0xf: /* FRSQRTS */
211
+ gen_helper_rsqrtsf_f16(tcg_res, tcg_op1, tcg_op2, fpst);
212
+ break;
213
+ case 0x13: /* FMUL */
214
+ gen_helper_advsimd_mulh(tcg_res, tcg_op1, tcg_op2, fpst);
215
+ break;
216
+ case 0x14: /* FCMGE */
217
+ gen_helper_advsimd_cge_f16(tcg_res, tcg_op1, tcg_op2, fpst);
218
+ break;
219
+ case 0x15: /* FACGE */
220
+ gen_helper_advsimd_acge_f16(tcg_res, tcg_op1, tcg_op2, fpst);
221
+ break;
222
+ case 0x17: /* FDIV */
223
+ gen_helper_advsimd_divh(tcg_res, tcg_op1, tcg_op2, fpst);
224
+ break;
225
+ case 0x1a: /* FABD */
226
+ gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst);
227
+ tcg_gen_andi_i32(tcg_res, tcg_res, 0x7fff);
228
+ break;
229
+ case 0x1c: /* FCMGT */
230
+ gen_helper_advsimd_cgt_f16(tcg_res, tcg_op1, tcg_op2, fpst);
231
+ break;
232
+ case 0x1d: /* FACGT */
233
+ gen_helper_advsimd_acgt_f16(tcg_res, tcg_op1, tcg_op2, fpst);
234
+ break;
235
+ default:
236
+ fprintf(stderr, "%s: insn %#04x, fpop %#2x @ %#" PRIx64 "\n",
237
+ __func__, insn, fpopcode, s->pc);
238
+ g_assert_not_reached();
239
+ }
240
+
241
+ write_vec_element_i32(s, tcg_res, rd, pass, MO_16);
242
+ tcg_temp_free_i32(tcg_res);
243
+ tcg_temp_free_i32(tcg_op1);
244
+ tcg_temp_free_i32(tcg_op2);
245
+ }
246
}
247
248
tcg_temp_free_ptr(fpst);
249
--
90
--
250
2.16.2
91
2.20.1
251
92
252
93
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
Create a fixed-frequency Clock object to be the SYSCLK, and wire it
2
up to the devices that require it.
2
3
3
I re-use the existing handle_2misc_fcmp_zero handler and tweak it
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
slightly to deal with the half-precision case.
5
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Reviewed-by: Luc Michel <luc@lmichel.fr>
7
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20210128114145.20536-14-peter.maydell@linaro.org
9
Message-id: 20210121190622.22000-14-peter.maydell@linaro.org
10
---
11
hw/arm/mps2.c | 9 +++++++++
12
1 file changed, 9 insertions(+)
5
13
6
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
14
diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20180227143852.11175-20-alex.bennee@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/translate-a64.c | 80 +++++++++++++++++++++++++++++++++-------------
12
1 file changed, 57 insertions(+), 23 deletions(-)
13
14
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
15
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/translate-a64.c
16
--- a/hw/arm/mps2.c
17
+++ b/target/arm/translate-a64.c
17
+++ b/hw/arm/mps2.c
18
@@ -XXX,XX +XXX,XX @@ static void handle_2misc_fcmp_zero(DisasContext *s, int opcode,
18
@@ -XXX,XX +XXX,XX @@
19
bool is_scalar, bool is_u, bool is_q,
19
#include "hw/net/lan9118.h"
20
int size, int rn, int rd)
20
#include "net/net.h"
21
{
21
#include "hw/watchdog/cmsdk-apb-watchdog.h"
22
- bool is_double = (size == 3);
22
+#include "hw/qdev-clock.h"
23
+ bool is_double = (size == MO_64);
23
#include "qom/object.h"
24
TCGv_ptr fpst;
24
25
25
typedef enum MPS2FPGAType {
26
if (!fp_access_check(s)) {
26
@@ -XXX,XX +XXX,XX @@ struct MPS2MachineState {
27
return;
27
CMSDKAPBDualTimer dualtimer;
28
CMSDKAPBWatchdog watchdog;
29
CMSDKAPBTimer timer[2];
30
+ Clock *sysclk;
31
};
32
33
#define TYPE_MPS2_MACHINE "mps2"
34
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
35
exit(EXIT_FAILURE);
28
}
36
}
29
37
30
- fpst = get_fpstatus_ptr(false);
38
+ /* This clock doesn't need migration because it is fixed-frequency */
31
+ fpst = get_fpstatus_ptr(size == MO_16);
39
+ mms->sysclk = clock_new(OBJECT(machine), "SYSCLK");
32
40
+ clock_set_hz(mms->sysclk, SYSCLK_FRQ);
33
if (is_double) {
34
TCGv_i64 tcg_op = tcg_temp_new_i64();
35
@@ -XXX,XX +XXX,XX @@ static void handle_2misc_fcmp_zero(DisasContext *s, int opcode,
36
bool swap = false;
37
int pass, maxpasses;
38
39
- switch (opcode) {
40
- case 0x2e: /* FCMLT (zero) */
41
- swap = true;
42
- /* fall through */
43
- case 0x2c: /* FCMGT (zero) */
44
- genfn = gen_helper_neon_cgt_f32;
45
- break;
46
- case 0x2d: /* FCMEQ (zero) */
47
- genfn = gen_helper_neon_ceq_f32;
48
- break;
49
- case 0x6d: /* FCMLE (zero) */
50
- swap = true;
51
- /* fall through */
52
- case 0x6c: /* FCMGE (zero) */
53
- genfn = gen_helper_neon_cge_f32;
54
- break;
55
- default:
56
- g_assert_not_reached();
57
+ if (size == MO_16) {
58
+ switch (opcode) {
59
+ case 0x2e: /* FCMLT (zero) */
60
+ swap = true;
61
+ /* fall through */
62
+ case 0x2c: /* FCMGT (zero) */
63
+ genfn = gen_helper_advsimd_cgt_f16;
64
+ break;
65
+ case 0x2d: /* FCMEQ (zero) */
66
+ genfn = gen_helper_advsimd_ceq_f16;
67
+ break;
68
+ case 0x6d: /* FCMLE (zero) */
69
+ swap = true;
70
+ /* fall through */
71
+ case 0x6c: /* FCMGE (zero) */
72
+ genfn = gen_helper_advsimd_cge_f16;
73
+ break;
74
+ default:
75
+ g_assert_not_reached();
76
+ }
77
+ } else {
78
+ switch (opcode) {
79
+ case 0x2e: /* FCMLT (zero) */
80
+ swap = true;
81
+ /* fall through */
82
+ case 0x2c: /* FCMGT (zero) */
83
+ genfn = gen_helper_neon_cgt_f32;
84
+ break;
85
+ case 0x2d: /* FCMEQ (zero) */
86
+ genfn = gen_helper_neon_ceq_f32;
87
+ break;
88
+ case 0x6d: /* FCMLE (zero) */
89
+ swap = true;
90
+ /* fall through */
91
+ case 0x6c: /* FCMGE (zero) */
92
+ genfn = gen_helper_neon_cge_f32;
93
+ break;
94
+ default:
95
+ g_assert_not_reached();
96
+ }
97
}
98
99
if (is_scalar) {
100
maxpasses = 1;
101
} else {
102
- maxpasses = is_q ? 4 : 2;
103
+ int vector_size = 8 << is_q;
104
+ maxpasses = vector_size >> size;
105
}
106
107
for (pass = 0; pass < maxpasses; pass++) {
108
- read_vec_element_i32(s, tcg_op, rn, pass, MO_32);
109
+ read_vec_element_i32(s, tcg_op, rn, pass, size);
110
if (swap) {
111
genfn(tcg_res, tcg_zero, tcg_op, fpst);
112
} else {
113
@@ -XXX,XX +XXX,XX @@ static void handle_2misc_fcmp_zero(DisasContext *s, int opcode,
114
if (is_scalar) {
115
write_fp_sreg(s, rd, tcg_res);
116
} else {
117
- write_vec_element_i32(s, tcg_res, rd, pass, MO_32);
118
+ write_vec_element_i32(s, tcg_res, rd, pass, size);
119
}
120
}
121
tcg_temp_free_i32(tcg_res);
122
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
123
fpop = deposit32(opcode, 5, 1, a);
124
fpop = deposit32(fpop, 6, 1, u);
125
126
+ rd = extract32(insn, 0, 5);
127
+ rn = extract32(insn, 5, 5);
128
+
41
+
129
switch (fpop) {
42
/* The FPGA images have an odd combination of different RAMs,
130
+ break;
43
* because in hardware they are different implementations and
131
+ case 0x2c: /* FCMGT (zero) */
44
* connected to different buses, giving varying performance/size
132
+ case 0x2d: /* FCMEQ (zero) */
45
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
133
+ case 0x2e: /* FCMLT (zero) */
46
TYPE_CMSDK_APB_TIMER);
134
+ case 0x6c: /* FCMGE (zero) */
47
sbd = SYS_BUS_DEVICE(&mms->timer[i]);
135
+ case 0x6d: /* FCMLE (zero) */
48
qdev_prop_set_uint32(DEVICE(&mms->timer[i]), "pclk-frq", SYSCLK_FRQ);
136
+ handle_2misc_fcmp_zero(s, fpop, is_scalar, 0, is_q, MO_16, rn, rd);
49
+ qdev_connect_clock_in(DEVICE(&mms->timer[i]), "pclk", mms->sysclk);
137
+ return;
50
sysbus_realize_and_unref(sbd, &error_fatal);
138
case 0x18: /* FRINTN */
51
sysbus_mmio_map(sbd, 0, base);
139
need_rmode = true;
52
sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(armv7m, irqno));
140
only_in_vector = true;
53
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
54
object_initialize_child(OBJECT(mms), "dualtimer", &mms->dualtimer,
55
TYPE_CMSDK_APB_DUALTIMER);
56
qdev_prop_set_uint32(DEVICE(&mms->dualtimer), "pclk-frq", SYSCLK_FRQ);
57
+ qdev_connect_clock_in(DEVICE(&mms->dualtimer), "TIMCLK", mms->sysclk);
58
sysbus_realize(SYS_BUS_DEVICE(&mms->dualtimer), &error_fatal);
59
sysbus_connect_irq(SYS_BUS_DEVICE(&mms->dualtimer), 0,
60
qdev_get_gpio_in(armv7m, 10));
61
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
62
object_initialize_child(OBJECT(mms), "watchdog", &mms->watchdog,
63
TYPE_CMSDK_APB_WATCHDOG);
64
qdev_prop_set_uint32(DEVICE(&mms->watchdog), "wdogclk-frq", SYSCLK_FRQ);
65
+ qdev_connect_clock_in(DEVICE(&mms->watchdog), "WDOGCLK", mms->sysclk);
66
sysbus_realize(SYS_BUS_DEVICE(&mms->watchdog), &error_fatal);
67
sysbus_connect_irq(SYS_BUS_DEVICE(&mms->watchdog), 0,
68
qdev_get_gpio_in_named(armv7m, "NMI", 0));
141
--
69
--
142
2.16.2
70
2.20.1
143
71
144
72
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
Create and connect the two clocks needed by the ARMSSE.
2
2
3
The helpers use the new re-factored muladd support in SoftFloat for
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
the float16 work.
4
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
5
Reviewed-by: Luc Michel <luc@lmichel.fr>
6
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Message-id: 20210128114145.20536-15-peter.maydell@linaro.org
8
Message-id: 20210121190622.22000-15-peter.maydell@linaro.org
9
---
10
hw/arm/mps2-tz.c | 13 +++++++++++++
11
1 file changed, 13 insertions(+)
5
12
6
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
13
diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c
7
Message-id: 20180227143852.11175-15-alex.bennee@linaro.org
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/translate-a64.c | 82 +++++++++++++++++++++++++++++++++++++---------
12
1 file changed, 66 insertions(+), 16 deletions(-)
13
14
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
15
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/translate-a64.c
15
--- a/hw/arm/mps2-tz.c
17
+++ b/target/arm/translate-a64.c
16
+++ b/hw/arm/mps2-tz.c
18
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
17
@@ -XXX,XX +XXX,XX @@
19
int rd = extract32(insn, 0, 5);
18
#include "hw/net/lan9118.h"
20
bool is_long = false;
19
#include "net/net.h"
21
bool is_fp = false;
20
#include "hw/core/split-irq.h"
22
+ bool is_fp16 = false;
21
+#include "hw/qdev-clock.h"
23
int index;
22
#include "qom/object.h"
24
TCGv_ptr fpst;
23
25
24
#define MPS2TZ_NUMIRQ 92
26
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
25
@@ -XXX,XX +XXX,XX @@ struct MPS2TZMachineState {
27
}
26
qemu_or_irq uart_irq_orgate;
28
/* fall through */
27
DeviceState *lan9118;
29
case 0x9: /* FMUL, FMULX */
28
SplitIRQ cpu_irq_splitter[MPS2TZ_NUMIRQ];
30
- if (!extract32(size, 1, 1)) {
29
+ Clock *sysclk;
31
+ if (size == 1) {
30
+ Clock *s32kclk;
32
unallocated_encoding(s);
31
};
33
return;
32
34
}
33
#define TYPE_MPS2TZ_MACHINE "mps2tz"
35
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
34
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_TYPE(MPS2TZMachineState, MPS2TZMachineClass, MPS2TZ_MACHINE)
35
36
/* Main SYSCLK frequency in Hz */
37
#define SYSCLK_FRQ 20000000
38
+/* Slow 32Khz S32KCLK frequency in Hz */
39
+#define S32KCLK_FRQ (32 * 1000)
40
41
/* Create an alias of an entire original MemoryRegion @orig
42
* located at @base in the memory map.
43
@@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine)
44
exit(EXIT_FAILURE);
36
}
45
}
37
46
38
if (is_fp) {
47
+ /* These clocks don't need migration because they are fixed-frequency */
39
- /* low bit of size indicates single/double */
48
+ mms->sysclk = clock_new(OBJECT(machine), "SYSCLK");
40
- size = extract32(size, 0, 1) ? 3 : 2;
49
+ clock_set_hz(mms->sysclk, SYSCLK_FRQ);
41
- if (size == 2) {
50
+ mms->s32kclk = clock_new(OBJECT(machine), "S32KCLK");
42
+ /* convert insn encoded size to TCGMemOp size */
51
+ clock_set_hz(mms->s32kclk, S32KCLK_FRQ);
43
+ switch (size) {
52
+
44
+ case 2: /* single precision */
53
object_initialize_child(OBJECT(machine), TYPE_IOTKIT, &mms->iotkit,
45
+ size = MO_32;
54
mmc->armsse_type);
46
index = h << 1 | l;
55
iotkitdev = DEVICE(&mms->iotkit);
47
- } else {
56
@@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine)
48
+ rm |= (m << 4);
57
OBJECT(system_memory), &error_abort);
49
+ break;
58
qdev_prop_set_uint32(iotkitdev, "EXP_NUMIRQ", MPS2TZ_NUMIRQ);
50
+ case 3: /* double precision */
59
qdev_prop_set_uint32(iotkitdev, "MAINCLK_FRQ", SYSCLK_FRQ);
51
+ size = MO_64;
60
+ qdev_connect_clock_in(iotkitdev, "MAINCLK", mms->sysclk);
52
if (l || !is_q) {
61
+ qdev_connect_clock_in(iotkitdev, "S32KCLK", mms->s32kclk);
53
unallocated_encoding(s);
62
sysbus_realize(SYS_BUS_DEVICE(&mms->iotkit), &error_fatal);
54
return;
63
55
}
64
/*
56
index = h;
57
+ rm |= (m << 4);
58
+ break;
59
+ case 0: /* half precision */
60
+ size = MO_16;
61
+ index = h << 2 | l << 1 | m;
62
+ is_fp16 = true;
63
+ if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
64
+ break;
65
+ }
66
+ /* fallthru */
67
+ default: /* unallocated */
68
+ unallocated_encoding(s);
69
+ return;
70
}
71
- rm |= (m << 4);
72
} else {
73
switch (size) {
74
case 1:
75
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
76
}
77
78
if (is_fp) {
79
- fpst = get_fpstatus_ptr(false);
80
+ fpst = get_fpstatus_ptr(is_fp16);
81
} else {
82
fpst = NULL;
83
}
84
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
85
break;
86
}
87
case 0x5: /* FMLS */
88
- /* As usual for ARM, separate negation for fused multiply-add */
89
- gen_helper_vfp_negs(tcg_op, tcg_op);
90
- /* fall through */
91
case 0x1: /* FMLA */
92
- read_vec_element_i32(s, tcg_res, rd, pass, MO_32);
93
- gen_helper_vfp_muladds(tcg_res, tcg_op, tcg_idx, tcg_res, fpst);
94
+ read_vec_element_i32(s, tcg_res, rd, pass,
95
+ is_scalar ? size : MO_32);
96
+ switch (size) {
97
+ case 1:
98
+ if (opcode == 0x5) {
99
+ /* As usual for ARM, separate negation for fused
100
+ * multiply-add */
101
+ tcg_gen_xori_i32(tcg_op, tcg_op, 0x80008000);
102
+ }
103
+ gen_helper_advsimd_muladdh(tcg_res, tcg_op, tcg_idx,
104
+ tcg_res, fpst);
105
+ break;
106
+ case 2:
107
+ if (opcode == 0x5) {
108
+ /* As usual for ARM, separate negation for
109
+ * fused multiply-add */
110
+ tcg_gen_xori_i32(tcg_op, tcg_op, 0x80000000);
111
+ }
112
+ gen_helper_vfp_muladds(tcg_res, tcg_op, tcg_idx,
113
+ tcg_res, fpst);
114
+ break;
115
+ default:
116
+ g_assert_not_reached();
117
+ }
118
break;
119
case 0x9: /* FMUL, FMULX */
120
- if (u) {
121
- gen_helper_vfp_mulxs(tcg_res, tcg_op, tcg_idx, fpst);
122
- } else {
123
- gen_helper_vfp_muls(tcg_res, tcg_op, tcg_idx, fpst);
124
+ switch (size) {
125
+ case 1:
126
+ if (u) {
127
+ gen_helper_advsimd_mulxh(tcg_res, tcg_op, tcg_idx,
128
+ fpst);
129
+ } else {
130
+ g_assert_not_reached();
131
+ }
132
+ break;
133
+ case 2:
134
+ if (u) {
135
+ gen_helper_vfp_mulxs(tcg_res, tcg_op, tcg_idx, fpst);
136
+ } else {
137
+ gen_helper_vfp_muls(tcg_res, tcg_op, tcg_idx, fpst);
138
+ }
139
+ break;
140
+ default:
141
+ g_assert_not_reached();
142
}
143
break;
144
case 0xc: /* SQDMULH */
145
--
65
--
146
2.16.2
66
2.20.1
147
67
148
68
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
Create and connect the two clocks needed by the ARMSSE.
2
2
3
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20180227143852.11175-3-alex.bennee@linaro.org
6
[PMM: postpone actually enabling feature until end of the
7
patch series]
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
5
Reviewed-by: Luc Michel <luc@lmichel.fr>
6
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Message-id: 20210128114145.20536-16-peter.maydell@linaro.org
8
Message-id: 20210121190622.22000-16-peter.maydell@linaro.org
9
---
9
---
10
target/arm/cpu.h | 1 +
10
hw/arm/musca.c | 12 ++++++++++++
11
1 file changed, 1 insertion(+)
11
1 file changed, 12 insertions(+)
12
12
13
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
13
diff --git a/hw/arm/musca.c b/hw/arm/musca.c
14
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/cpu.h
15
--- a/hw/arm/musca.c
16
+++ b/target/arm/cpu.h
16
+++ b/hw/arm/musca.c
17
@@ -XXX,XX +XXX,XX @@ enum arm_features {
17
@@ -XXX,XX +XXX,XX @@
18
ARM_FEATURE_V8_SHA3, /* implements SHA3 part of v8 Crypto Extensions */
18
#include "hw/misc/tz-ppc.h"
19
ARM_FEATURE_V8_SM3, /* implements SM3 part of v8 Crypto Extensions */
19
#include "hw/misc/unimp.h"
20
ARM_FEATURE_V8_SM4, /* implements SM4 part of v8 Crypto Extensions */
20
#include "hw/rtc/pl031.h"
21
+ ARM_FEATURE_V8_FP16, /* implements v8.2 half-precision float */
21
+#include "hw/qdev-clock.h"
22
#include "qom/object.h"
23
24
#define MUSCA_NUMIRQ_MAX 96
25
@@ -XXX,XX +XXX,XX @@ struct MuscaMachineState {
26
UnimplementedDeviceState sdio;
27
UnimplementedDeviceState gpio;
28
UnimplementedDeviceState cryptoisland;
29
+ Clock *sysclk;
30
+ Clock *s32kclk;
22
};
31
};
23
32
24
static inline int arm_feature(CPUARMState *env, int feature)
33
#define TYPE_MUSCA_MACHINE "musca"
34
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_TYPE(MuscaMachineState, MuscaMachineClass, MUSCA_MACHINE)
35
* don't model that in our SSE-200 model yet.
36
*/
37
#define SYSCLK_FRQ 40000000
38
+/* Slow 32Khz S32KCLK frequency in Hz */
39
+#define S32KCLK_FRQ (32 * 1000)
40
41
static qemu_irq get_sse_irq_in(MuscaMachineState *mms, int irqno)
42
{
43
@@ -XXX,XX +XXX,XX @@ static void musca_init(MachineState *machine)
44
exit(1);
45
}
46
47
+ mms->sysclk = clock_new(OBJECT(machine), "SYSCLK");
48
+ clock_set_hz(mms->sysclk, SYSCLK_FRQ);
49
+ mms->s32kclk = clock_new(OBJECT(machine), "S32KCLK");
50
+ clock_set_hz(mms->s32kclk, S32KCLK_FRQ);
51
+
52
object_initialize_child(OBJECT(machine), "sse-200", &mms->sse,
53
TYPE_SSE200);
54
ssedev = DEVICE(&mms->sse);
55
@@ -XXX,XX +XXX,XX @@ static void musca_init(MachineState *machine)
56
qdev_prop_set_uint32(ssedev, "init-svtor", mmc->init_svtor);
57
qdev_prop_set_uint32(ssedev, "SRAM_ADDR_WIDTH", mmc->sram_addr_width);
58
qdev_prop_set_uint32(ssedev, "MAINCLK_FRQ", SYSCLK_FRQ);
59
+ qdev_connect_clock_in(ssedev, "MAINCLK", mms->sysclk);
60
+ qdev_connect_clock_in(ssedev, "S32KCLK", mms->s32kclk);
61
/*
62
* Musca-A takes the default SSE-200 FPU/DSP settings (ie no for
63
* CPU0 and yes for CPU1); Musca-B1 explicitly enables them for CPU0.
25
--
64
--
26
2.16.2
65
2.20.1
27
66
28
67
diff view generated by jsdifflib
New patch
1
1
Convert the SSYS code in the Stellaris boards (which encapsulates the
2
system registers) to a proper QOM device. This will provide us with
3
somewhere to put the output Clock whose frequency depends on the
4
setting of the PLL configuration registers.
5
6
This is a migration compatibility break for lm3s811evb, lm3s6965evb.
7
8
We use 3-phase reset here because the Clock will need to propagate
9
its value in the hold phase.
10
11
For the moment we reset the device during the board creation so that
12
the system_clock_scale global gets set; this will be removed in a
13
subsequent commit.
14
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Luc Michel <luc@lmichel.fr>
17
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
18
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
19
Message-id: 20210128114145.20536-17-peter.maydell@linaro.org
20
Message-id: 20210121190622.22000-17-peter.maydell@linaro.org
21
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
22
---
23
hw/arm/stellaris.c | 132 ++++++++++++++++++++++++++++++++++++---------
24
1 file changed, 107 insertions(+), 25 deletions(-)
25
26
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
27
index XXXXXXX..XXXXXXX 100644
28
--- a/hw/arm/stellaris.c
29
+++ b/hw/arm/stellaris.c
30
@@ -XXX,XX +XXX,XX @@ static void stellaris_gptm_realize(DeviceState *dev, Error **errp)
31
32
/* System controller. */
33
34
-typedef struct {
35
+#define TYPE_STELLARIS_SYS "stellaris-sys"
36
+OBJECT_DECLARE_SIMPLE_TYPE(ssys_state, STELLARIS_SYS)
37
+
38
+struct ssys_state {
39
+ SysBusDevice parent_obj;
40
+
41
MemoryRegion iomem;
42
uint32_t pborctl;
43
uint32_t ldopctl;
44
@@ -XXX,XX +XXX,XX @@ typedef struct {
45
uint32_t dcgc[3];
46
uint32_t clkvclr;
47
uint32_t ldoarst;
48
+ qemu_irq irq;
49
+ /* Properties (all read-only registers) */
50
uint32_t user0;
51
uint32_t user1;
52
- qemu_irq irq;
53
- stellaris_board_info *board;
54
-} ssys_state;
55
+ uint32_t did0;
56
+ uint32_t did1;
57
+ uint32_t dc0;
58
+ uint32_t dc1;
59
+ uint32_t dc2;
60
+ uint32_t dc3;
61
+ uint32_t dc4;
62
+};
63
64
static void ssys_update(ssys_state *s)
65
{
66
@@ -XXX,XX +XXX,XX @@ static uint32_t pllcfg_fury[16] = {
67
68
static int ssys_board_class(const ssys_state *s)
69
{
70
- uint32_t did0 = s->board->did0;
71
+ uint32_t did0 = s->did0;
72
switch (did0 & DID0_VER_MASK) {
73
case DID0_VER_0:
74
return DID0_CLASS_SANDSTORM;
75
@@ -XXX,XX +XXX,XX @@ static uint64_t ssys_read(void *opaque, hwaddr offset,
76
77
switch (offset) {
78
case 0x000: /* DID0 */
79
- return s->board->did0;
80
+ return s->did0;
81
case 0x004: /* DID1 */
82
- return s->board->did1;
83
+ return s->did1;
84
case 0x008: /* DC0 */
85
- return s->board->dc0;
86
+ return s->dc0;
87
case 0x010: /* DC1 */
88
- return s->board->dc1;
89
+ return s->dc1;
90
case 0x014: /* DC2 */
91
- return s->board->dc2;
92
+ return s->dc2;
93
case 0x018: /* DC3 */
94
- return s->board->dc3;
95
+ return s->dc3;
96
case 0x01c: /* DC4 */
97
- return s->board->dc4;
98
+ return s->dc4;
99
case 0x030: /* PBORCTL */
100
return s->pborctl;
101
case 0x034: /* LDOPCTL */
102
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps ssys_ops = {
103
.endianness = DEVICE_NATIVE_ENDIAN,
104
};
105
106
-static void ssys_reset(void *opaque)
107
+static void stellaris_sys_reset_enter(Object *obj, ResetType type)
108
{
109
- ssys_state *s = (ssys_state *)opaque;
110
+ ssys_state *s = STELLARIS_SYS(obj);
111
112
s->pborctl = 0x7ffd;
113
s->rcc = 0x078e3ac0;
114
@@ -XXX,XX +XXX,XX @@ static void ssys_reset(void *opaque)
115
s->rcgc[0] = 1;
116
s->scgc[0] = 1;
117
s->dcgc[0] = 1;
118
+}
119
+
120
+static void stellaris_sys_reset_hold(Object *obj)
121
+{
122
+ ssys_state *s = STELLARIS_SYS(obj);
123
+
124
ssys_calculate_system_clock(s);
125
}
126
127
+static void stellaris_sys_reset_exit(Object *obj)
128
+{
129
+}
130
+
131
static int stellaris_sys_post_load(void *opaque, int version_id)
132
{
133
ssys_state *s = opaque;
134
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_stellaris_sys = {
135
}
136
};
137
138
+static Property stellaris_sys_properties[] = {
139
+ DEFINE_PROP_UINT32("user0", ssys_state, user0, 0),
140
+ DEFINE_PROP_UINT32("user1", ssys_state, user1, 0),
141
+ DEFINE_PROP_UINT32("did0", ssys_state, did0, 0),
142
+ DEFINE_PROP_UINT32("did1", ssys_state, did1, 0),
143
+ DEFINE_PROP_UINT32("dc0", ssys_state, dc0, 0),
144
+ DEFINE_PROP_UINT32("dc1", ssys_state, dc1, 0),
145
+ DEFINE_PROP_UINT32("dc2", ssys_state, dc2, 0),
146
+ DEFINE_PROP_UINT32("dc3", ssys_state, dc3, 0),
147
+ DEFINE_PROP_UINT32("dc4", ssys_state, dc4, 0),
148
+ DEFINE_PROP_END_OF_LIST()
149
+};
150
+
151
+static void stellaris_sys_instance_init(Object *obj)
152
+{
153
+ ssys_state *s = STELLARIS_SYS(obj);
154
+ SysBusDevice *sbd = SYS_BUS_DEVICE(s);
155
+
156
+ memory_region_init_io(&s->iomem, obj, &ssys_ops, s, "ssys", 0x00001000);
157
+ sysbus_init_mmio(sbd, &s->iomem);
158
+ sysbus_init_irq(sbd, &s->irq);
159
+}
160
+
161
static int stellaris_sys_init(uint32_t base, qemu_irq irq,
162
stellaris_board_info * board,
163
uint8_t *macaddr)
164
{
165
- ssys_state *s;
166
+ DeviceState *dev = qdev_new(TYPE_STELLARIS_SYS);
167
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
168
169
- s = g_new0(ssys_state, 1);
170
- s->irq = irq;
171
- s->board = board;
172
/* Most devices come preprogrammed with a MAC address in the user data. */
173
- s->user0 = macaddr[0] | (macaddr[1] << 8) | (macaddr[2] << 16);
174
- s->user1 = macaddr[3] | (macaddr[4] << 8) | (macaddr[5] << 16);
175
+ qdev_prop_set_uint32(dev, "user0",
176
+ macaddr[0] | (macaddr[1] << 8) | (macaddr[2] << 16));
177
+ qdev_prop_set_uint32(dev, "user1",
178
+ macaddr[3] | (macaddr[4] << 8) | (macaddr[5] << 16));
179
+ qdev_prop_set_uint32(dev, "did0", board->did0);
180
+ qdev_prop_set_uint32(dev, "did1", board->did1);
181
+ qdev_prop_set_uint32(dev, "dc0", board->dc0);
182
+ qdev_prop_set_uint32(dev, "dc1", board->dc1);
183
+ qdev_prop_set_uint32(dev, "dc2", board->dc2);
184
+ qdev_prop_set_uint32(dev, "dc3", board->dc3);
185
+ qdev_prop_set_uint32(dev, "dc4", board->dc4);
186
+
187
+ sysbus_realize_and_unref(sbd, &error_fatal);
188
+ sysbus_mmio_map(sbd, 0, base);
189
+ sysbus_connect_irq(sbd, 0, irq);
190
+
191
+ /*
192
+ * Normally we should not be resetting devices like this during
193
+ * board creation. For the moment we need to do so, because
194
+ * system_clock_scale will only get set when the STELLARIS_SYS
195
+ * device is reset, and we need its initial value to pass to
196
+ * the watchdog device. This hack can be removed once the
197
+ * watchdog has been converted to use a Clock input instead.
198
+ */
199
+ device_cold_reset(dev);
200
201
- memory_region_init_io(&s->iomem, NULL, &ssys_ops, s, "ssys", 0x00001000);
202
- memory_region_add_subregion(get_system_memory(), base, &s->iomem);
203
- ssys_reset(s);
204
- vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY, &vmstate_stellaris_sys, s);
205
return 0;
206
}
207
208
-
209
/* I2C controller. */
210
211
#define TYPE_STELLARIS_I2C "stellaris-i2c"
212
@@ -XXX,XX +XXX,XX @@ static const TypeInfo stellaris_adc_info = {
213
.class_init = stellaris_adc_class_init,
214
};
215
216
+static void stellaris_sys_class_init(ObjectClass *klass, void *data)
217
+{
218
+ DeviceClass *dc = DEVICE_CLASS(klass);
219
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
220
+
221
+ dc->vmsd = &vmstate_stellaris_sys;
222
+ rc->phases.enter = stellaris_sys_reset_enter;
223
+ rc->phases.hold = stellaris_sys_reset_hold;
224
+ rc->phases.exit = stellaris_sys_reset_exit;
225
+ device_class_set_props(dc, stellaris_sys_properties);
226
+}
227
+
228
+static const TypeInfo stellaris_sys_info = {
229
+ .name = TYPE_STELLARIS_SYS,
230
+ .parent = TYPE_SYS_BUS_DEVICE,
231
+ .instance_size = sizeof(ssys_state),
232
+ .instance_init = stellaris_sys_instance_init,
233
+ .class_init = stellaris_sys_class_init,
234
+};
235
+
236
static void stellaris_register_types(void)
237
{
238
type_register_static(&stellaris_i2c_info);
239
type_register_static(&stellaris_gptm_info);
240
type_register_static(&stellaris_adc_info);
241
+ type_register_static(&stellaris_sys_info);
242
}
243
244
type_init(stellaris_register_types)
245
--
246
2.20.1
247
248
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
Create and connect the Clock input for the watchdog device on the
2
Stellaris boards. Because the Stellaris boards model the ability to
3
change the clock rate by programming PLL registers, we have to create
4
an output Clock on the ssys_state device and wire it up to the
5
watchdog.
2
6
3
Much like recpe the ARM ARM has simplified the pseudo code for the
7
Note that the old comment on ssys_calculate_system_clock() got the
4
calculation which is done on a fixed point 9 bit integer maths. So
8
units wrong -- system_clock_scale is in nanoseconds, not
5
while adding f16 we can also clean this up to be a little less heavy
9
milliseconds. Improve the commentary to clarify how we are
6
on the floating point and just return the fractional part and leave
10
calculating the period.
7
the calle's to do the final packing of the result.
8
11
9
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20180227143852.11175-27-alex.bennee@linaro.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Luc Michel <luc@lmichel.fr>
14
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
16
Message-id: 20210128114145.20536-18-peter.maydell@linaro.org
17
Message-id: 20210121190622.22000-18-peter.maydell@linaro.org
18
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
---
19
---
14
target/arm/helper.h | 1 +
20
hw/arm/stellaris.c | 43 +++++++++++++++++++++++++++++++------------
15
target/arm/helper.c | 221 ++++++++++++++++++++++++----------------------------
21
1 file changed, 31 insertions(+), 12 deletions(-)
16
2 files changed, 104 insertions(+), 118 deletions(-)
17
22
18
diff --git a/target/arm/helper.h b/target/arm/helper.h
23
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
19
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/helper.h
25
--- a/hw/arm/stellaris.c
21
+++ b/target/arm/helper.h
26
+++ b/hw/arm/stellaris.c
22
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(rsqrts_f32, f32, f32, f32, env)
27
@@ -XXX,XX +XXX,XX @@
23
DEF_HELPER_FLAGS_2(recpe_f16, TCG_CALL_NO_RWG, f16, f16, ptr)
28
#include "hw/watchdog/cmsdk-apb-watchdog.h"
24
DEF_HELPER_FLAGS_2(recpe_f32, TCG_CALL_NO_RWG, f32, f32, ptr)
29
#include "migration/vmstate.h"
25
DEF_HELPER_FLAGS_2(recpe_f64, TCG_CALL_NO_RWG, f64, f64, ptr)
30
#include "hw/misc/unimp.h"
26
+DEF_HELPER_FLAGS_2(rsqrte_f16, TCG_CALL_NO_RWG, f16, f16, ptr)
31
+#include "hw/qdev-clock.h"
27
DEF_HELPER_FLAGS_2(rsqrte_f32, TCG_CALL_NO_RWG, f32, f32, ptr)
32
#include "cpu.h"
28
DEF_HELPER_FLAGS_2(rsqrte_f64, TCG_CALL_NO_RWG, f64, f64, ptr)
33
#include "qom/object.h"
29
DEF_HELPER_2(recpe_u32, i32, i32, ptr)
34
30
diff --git a/target/arm/helper.c b/target/arm/helper.c
35
@@ -XXX,XX +XXX,XX @@ struct ssys_state {
31
index XXXXXXX..XXXXXXX 100644
36
uint32_t clkvclr;
32
--- a/target/arm/helper.c
37
uint32_t ldoarst;
33
+++ b/target/arm/helper.c
38
qemu_irq irq;
34
@@ -XXX,XX +XXX,XX @@ float64 HELPER(recpe_f64)(float64 input, void *fpstp)
39
+ Clock *sysclk;
35
/* The algorithm that must be used to calculate the estimate
40
/* Properties (all read-only registers) */
36
* is specified by the ARM ARM.
41
uint32_t user0;
42
uint32_t user1;
43
@@ -XXX,XX +XXX,XX @@ static bool ssys_use_rcc2(ssys_state *s)
44
}
45
46
/*
47
- * Caculate the sys. clock period in ms.
48
+ * Calculate the system clock period. We only want to propagate
49
+ * this change to the rest of the system if we're not being called
50
+ * from migration post-load.
37
*/
51
*/
38
-static float64 recip_sqrt_estimate(float64 a, float_status *real_fp_status)
52
-static void ssys_calculate_system_clock(ssys_state *s)
39
+
53
+static void ssys_calculate_system_clock(ssys_state *s, bool propagate_clock)
40
+static int do_recip_sqrt_estimate(int a)
41
{
54
{
42
- /* These calculations mustn't set any fp exception flags,
55
+ /*
43
- * so we use a local copy of the fp_status.
56
+ * SYSDIV field specifies divisor: 0 == /1, 1 == /2, etc. Input
44
- */
57
+ * clock is 200MHz, which is a period of 5 ns. Dividing the clock
45
- float_status dummy_status = *real_fp_status;
58
+ * frequency by X is the same as multiplying the period by X.
46
- float_status *s = &dummy_status;
59
+ */
47
- float64 q;
60
if (ssys_use_rcc2(s)) {
48
- int64_t q_int;
61
system_clock_scale = 5 * (((s->rcc2 >> 23) & 0x3f) + 1);
49
+ int b, estimate;
50
51
- if (float64_lt(a, float64_half, s)) {
52
- /* range 0.25 <= a < 0.5 */
53
-
54
- /* a in units of 1/512 rounded down */
55
- /* q0 = (int)(a * 512.0); */
56
- q = float64_mul(float64_512, a, s);
57
- q_int = float64_to_int64_round_to_zero(q, s);
58
-
59
- /* reciprocal root r */
60
- /* r = 1.0 / sqrt(((double)q0 + 0.5) / 512.0); */
61
- q = int64_to_float64(q_int, s);
62
- q = float64_add(q, float64_half, s);
63
- q = float64_div(q, float64_512, s);
64
- q = float64_sqrt(q, s);
65
- q = float64_div(float64_one, q, s);
66
+ assert(128 <= a && a < 512);
67
+ if (a < 256) {
68
+ a = a * 2 + 1;
69
} else {
62
} else {
70
- /* range 0.5 <= a < 1.0 */
63
system_clock_scale = 5 * (((s->rcc >> 23) & 0xf) + 1);
71
-
72
- /* a in units of 1/256 rounded down */
73
- /* q1 = (int)(a * 256.0); */
74
- q = float64_mul(float64_256, a, s);
75
- int64_t q_int = float64_to_int64_round_to_zero(q, s);
76
-
77
- /* reciprocal root r */
78
- /* r = 1.0 /sqrt(((double)q1 + 0.5) / 256); */
79
- q = int64_to_float64(q_int, s);
80
- q = float64_add(q, float64_half, s);
81
- q = float64_div(q, float64_256, s);
82
- q = float64_sqrt(q, s);
83
- q = float64_div(float64_one, q, s);
84
+ a = (a >> 1) << 1;
85
+ a = (a + 1) * 2;
86
}
64
}
87
- /* r in units of 1/256 rounded to nearest */
65
+ clock_set_ns(s->sysclk, system_clock_scale);
88
- /* s = (int)(256.0 * r + 0.5); */
66
+ if (propagate_clock) {
89
+ b = 512;
67
+ clock_propagate(s->sysclk);
90
+ while (a * (b + 1) * (b + 1) < (1 << 28)) {
91
+ b += 1;
92
+ }
68
+ }
93
+ estimate = (b + 1) / 2;
94
+ assert(256 <= estimate && estimate < 512);
95
96
- q = float64_mul(q, float64_256,s );
97
- q = float64_add(q, float64_half, s);
98
- q_int = float64_to_int64_round_to_zero(q, s);
99
+ return estimate;
100
+}
101
102
- /* return (double)s / 256.0;*/
103
- return float64_div(int64_to_float64(q_int, s), float64_256, s);
104
+
105
+static uint64_t recip_sqrt_estimate(int *exp , int exp_off, uint64_t frac)
106
+{
107
+ int estimate;
108
+ uint32_t scaled;
109
+
110
+ if (*exp == 0) {
111
+ while (extract64(frac, 51, 1) == 0) {
112
+ frac = frac << 1;
113
+ *exp -= 1;
114
+ }
115
+ frac = extract64(frac, 0, 51) << 1;
116
+ }
117
+
118
+ if (*exp & 1) {
119
+ /* scaled = UInt('01':fraction<51:45>) */
120
+ scaled = deposit32(1 << 7, 0, 7, extract64(frac, 45, 7));
121
+ } else {
122
+ /* scaled = UInt('1':fraction<51:44>) */
123
+ scaled = deposit32(1 << 8, 0, 8, extract64(frac, 44, 8));
124
+ }
125
+ estimate = do_recip_sqrt_estimate(scaled);
126
+
127
+ *exp = (exp_off - *exp) / 2;
128
+ return extract64(estimate, 0, 8) << 44;
129
+}
130
+
131
+float16 HELPER(rsqrte_f16)(float16 input, void *fpstp)
132
+{
133
+ float_status *s = fpstp;
134
+ float16 f16 = float16_squash_input_denormal(input, s);
135
+ uint16_t val = float16_val(f16);
136
+ bool f16_sign = float16_is_neg(f16);
137
+ int f16_exp = extract32(val, 10, 5);
138
+ uint16_t f16_frac = extract32(val, 0, 10);
139
+ uint64_t f64_frac;
140
+
141
+ if (float16_is_any_nan(f16)) {
142
+ float16 nan = f16;
143
+ if (float16_is_signaling_nan(f16, s)) {
144
+ float_raise(float_flag_invalid, s);
145
+ nan = float16_maybe_silence_nan(f16, s);
146
+ }
147
+ if (s->default_nan_mode) {
148
+ nan = float16_default_nan(s);
149
+ }
150
+ return nan;
151
+ } else if (float16_is_zero(f16)) {
152
+ float_raise(float_flag_divbyzero, s);
153
+ return float16_set_sign(float16_infinity, f16_sign);
154
+ } else if (f16_sign) {
155
+ float_raise(float_flag_invalid, s);
156
+ return float16_default_nan(s);
157
+ } else if (float16_is_infinity(f16)) {
158
+ return float16_zero;
159
+ }
160
+
161
+ /* Scale and normalize to a double-precision value between 0.25 and 1.0,
162
+ * preserving the parity of the exponent. */
163
+
164
+ f64_frac = ((uint64_t) f16_frac) << (52 - 10);
165
+
166
+ f64_frac = recip_sqrt_estimate(&f16_exp, 44, f64_frac);
167
+
168
+ /* result = sign : result_exp<4:0> : estimate<7:0> : Zeros(2) */
169
+ val = deposit32(0, 15, 1, f16_sign);
170
+ val = deposit32(val, 10, 5, f16_exp);
171
+ val = deposit32(val, 2, 8, extract64(f64_frac, 52 - 8, 8));
172
+ return make_float16(val);
173
}
69
}
174
70
175
float32 HELPER(rsqrte_f32)(float32 input, void *fpstp)
71
static void ssys_write(void *opaque, hwaddr offset,
176
@@ -XXX,XX +XXX,XX @@ float32 HELPER(rsqrte_f32)(float32 input, void *fpstp)
72
@@ -XXX,XX +XXX,XX @@ static void ssys_write(void *opaque, hwaddr offset,
177
float_status *s = fpstp;
73
s->int_status |= (1 << 6);
178
float32 f32 = float32_squash_input_denormal(input, s);
74
}
179
uint32_t val = float32_val(f32);
75
s->rcc = value;
180
- uint32_t f32_sbit = 0x80000000 & val;
76
- ssys_calculate_system_clock(s);
181
- int32_t f32_exp = extract32(val, 23, 8);
77
+ ssys_calculate_system_clock(s, true);
182
+ uint32_t f32_sign = float32_is_neg(f32);
78
break;
183
+ int f32_exp = extract32(val, 23, 8);
79
case 0x070: /* RCC2 */
184
uint32_t f32_frac = extract32(val, 0, 23);
80
if (ssys_board_class(s) == DID0_CLASS_SANDSTORM) {
185
uint64_t f64_frac;
81
@@ -XXX,XX +XXX,XX @@ static void ssys_write(void *opaque, hwaddr offset,
186
- uint64_t val64;
82
s->int_status |= (1 << 6);
187
- int result_exp;
83
}
188
- float64 f64;
84
s->rcc2 = value;
189
85
- ssys_calculate_system_clock(s);
190
if (float32_is_any_nan(f32)) {
86
+ ssys_calculate_system_clock(s, true);
191
float32 nan = f32;
87
break;
192
@@ -XXX,XX +XXX,XX @@ float32 HELPER(rsqrte_f32)(float32 input, void *fpstp)
88
case 0x100: /* RCGC0 */
193
* preserving the parity of the exponent. */
89
s->rcgc[0] = value;
194
90
@@ -XXX,XX +XXX,XX @@ static void stellaris_sys_reset_hold(Object *obj)
195
f64_frac = ((uint64_t) f32_frac) << 29;
91
{
196
- if (f32_exp == 0) {
92
ssys_state *s = STELLARIS_SYS(obj);
197
- while (extract64(f64_frac, 51, 1) == 0) {
93
198
- f64_frac = f64_frac << 1;
94
- ssys_calculate_system_clock(s);
199
- f32_exp = f32_exp-1;
95
+ /* OK to propagate clocks from the hold phase */
200
- }
96
+ ssys_calculate_system_clock(s, true);
201
- f64_frac = extract64(f64_frac, 0, 51) << 1;
202
- }
203
204
- if (extract64(f32_exp, 0, 1) == 0) {
205
- f64 = make_float64(((uint64_t) f32_sbit) << 32
206
- | (0x3feULL << 52)
207
- | f64_frac);
208
- } else {
209
- f64 = make_float64(((uint64_t) f32_sbit) << 32
210
- | (0x3fdULL << 52)
211
- | f64_frac);
212
- }
213
+ f64_frac = recip_sqrt_estimate(&f32_exp, 380, f64_frac);
214
215
- result_exp = (380 - f32_exp) / 2;
216
-
217
- f64 = recip_sqrt_estimate(f64, s);
218
-
219
- val64 = float64_val(f64);
220
-
221
- val = ((result_exp & 0xff) << 23)
222
- | ((val64 >> 29) & 0x7fffff);
223
+ /* result = sign : result_exp<4:0> : estimate<7:0> : Zeros(15) */
224
+ val = deposit32(0, 31, 1, f32_sign);
225
+ val = deposit32(val, 23, 8, f32_exp);
226
+ val = deposit32(val, 15, 8, extract64(f64_frac, 52 - 8, 8));
227
return make_float32(val);
228
}
97
}
229
98
230
@@ -XXX,XX +XXX,XX @@ float64 HELPER(rsqrte_f64)(float64 input, void *fpstp)
99
static void stellaris_sys_reset_exit(Object *obj)
231
float_status *s = fpstp;
100
@@ -XXX,XX +XXX,XX @@ static int stellaris_sys_post_load(void *opaque, int version_id)
232
float64 f64 = float64_squash_input_denormal(input, s);
101
{
233
uint64_t val = float64_val(f64);
102
ssys_state *s = opaque;
234
- uint64_t f64_sbit = 0x8000000000000000ULL & val;
103
235
- int64_t f64_exp = extract64(val, 52, 11);
104
- ssys_calculate_system_clock(s);
236
+ bool f64_sign = float64_is_neg(f64);
105
+ ssys_calculate_system_clock(s, false);
237
+ int f64_exp = extract64(val, 52, 11);
106
238
uint64_t f64_frac = extract64(val, 0, 52);
107
return 0;
239
- int64_t result_exp;
108
}
240
- uint64_t result_frac;
109
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_stellaris_sys = {
241
110
VMSTATE_UINT32_ARRAY(dcgc, ssys_state, 3),
242
if (float64_is_any_nan(f64)) {
111
VMSTATE_UINT32(clkvclr, ssys_state),
243
float64 nan = f64;
112
VMSTATE_UINT32(ldoarst, ssys_state),
244
@@ -XXX,XX +XXX,XX @@ float64 HELPER(rsqrte_f64)(float64 input, void *fpstp)
113
+ /* No field for sysclk -- handled in post-load instead */
245
return float64_zero;
114
VMSTATE_END_OF_LIST()
246
}
115
}
247
116
};
248
- /* Scale and normalize to a double-precision value between 0.25 and 1.0,
117
@@ -XXX,XX +XXX,XX @@ static void stellaris_sys_instance_init(Object *obj)
249
- * preserving the parity of the exponent. */
118
memory_region_init_io(&s->iomem, obj, &ssys_ops, s, "ssys", 0x00001000);
250
+ f64_frac = recip_sqrt_estimate(&f64_exp, 3068, f64_frac);
119
sysbus_init_mmio(sbd, &s->iomem);
251
120
sysbus_init_irq(sbd, &s->irq);
252
- if (f64_exp == 0) {
121
+ s->sysclk = qdev_init_clock_out(DEVICE(s), "SYSCLK");
253
- while (extract64(f64_frac, 51, 1) == 0) {
254
- f64_frac = f64_frac << 1;
255
- f64_exp = f64_exp - 1;
256
- }
257
- f64_frac = extract64(f64_frac, 0, 51) << 1;
258
- }
259
-
260
- if (extract64(f64_exp, 0, 1) == 0) {
261
- f64 = make_float64(f64_sbit
262
- | (0x3feULL << 52)
263
- | f64_frac);
264
- } else {
265
- f64 = make_float64(f64_sbit
266
- | (0x3fdULL << 52)
267
- | f64_frac);
268
- }
269
-
270
- result_exp = (3068 - f64_exp) / 2;
271
-
272
- f64 = recip_sqrt_estimate(f64, s);
273
-
274
- result_frac = extract64(float64_val(f64), 0, 52);
275
-
276
- return make_float64(f64_sbit |
277
- ((result_exp & 0x7ff) << 52) |
278
- result_frac);
279
+ /* result = sign : result_exp<4:0> : estimate<7:0> : Zeros(44) */
280
+ val = deposit64(0, 61, 1, f64_sign);
281
+ val = deposit64(val, 52, 11, f64_exp);
282
+ val = deposit64(val, 44, 8, extract64(f64_frac, 52 - 8, 8));
283
+ return make_float64(val);
284
}
122
}
285
123
286
uint32_t HELPER(recpe_u32)(uint32_t a, void *fpstp)
124
-static int stellaris_sys_init(uint32_t base, qemu_irq irq,
287
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(recpe_u32)(uint32_t a, void *fpstp)
125
- stellaris_board_info * board,
288
126
- uint8_t *macaddr)
289
uint32_t HELPER(rsqrte_u32)(uint32_t a, void *fpstp)
127
+static DeviceState *stellaris_sys_init(uint32_t base, qemu_irq irq,
128
+ stellaris_board_info *board,
129
+ uint8_t *macaddr)
290
{
130
{
291
- float_status *fpst = fpstp;
131
DeviceState *dev = qdev_new(TYPE_STELLARIS_SYS);
292
- float64 f64;
132
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
293
+ int estimate;
133
@@ -XXX,XX +XXX,XX @@ static int stellaris_sys_init(uint32_t base, qemu_irq irq,
294
134
*/
295
if ((a & 0xc0000000) == 0) {
135
device_cold_reset(dev);
296
return 0xffffffff;
136
137
- return 0;
138
+ return dev;
139
}
140
141
/* I2C controller. */
142
@@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
143
int flash_size;
144
I2CBus *i2c;
145
DeviceState *dev;
146
+ DeviceState *ssys_dev;
147
int i;
148
int j;
149
150
@@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
151
}
297
}
152
}
298
153
299
- if (a & 0x80000000) {
154
- stellaris_sys_init(0x400fe000, qdev_get_gpio_in(nvic, 28),
300
- f64 = make_float64((0x3feULL << 52)
155
- board, nd_table[0].macaddr.a);
301
- | ((uint64_t)(a & 0x7fffffff) << 21));
156
+ ssys_dev = stellaris_sys_init(0x400fe000, qdev_get_gpio_in(nvic, 28),
302
- } else { /* bits 31-30 == '01' */
157
+ board, nd_table[0].macaddr.a);
303
- f64 = make_float64((0x3fdULL << 52)
158
304
- | ((uint64_t)(a & 0x3fffffff) << 22));
159
305
- }
160
if (board->dc1 & (1 << 3)) { /* watchdog present */
306
+ estimate = do_recip_sqrt_estimate(extract32(a, 23, 9));
161
@@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
307
162
/* system_clock_scale is valid now */
308
- f64 = recip_sqrt_estimate(f64, fpst);
163
uint32_t mainclk = NANOSECONDS_PER_SECOND / system_clock_scale;
309
-
164
qdev_prop_set_uint32(dev, "wdogclk-frq", mainclk);
310
- return 0x80000000 | ((float64_val(f64) >> 21) & 0x7fffffff);
165
+ qdev_connect_clock_in(dev, "WDOGCLK",
311
+ return deposit32(0, 23, 9, estimate);
166
+ qdev_get_clock_out(ssys_dev, "SYSCLK"));
312
}
167
313
168
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
314
/* VFPv4 fused multiply-accumulate */
169
sysbus_mmio_map(SYS_BUS_DEVICE(dev),
315
--
170
--
316
2.16.2
171
2.20.1
317
172
318
173
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
Switch the CMSDK APB timer device over to using its Clock input; the
2
pclk-frq property is now ignored.
2
3
3
A bunch of the vectorised bitwise operations just operate on larger
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
chunks at a time. We can do the same for the new half-precision
5
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
5
operations by introducing some TWOHALFOP helpers which work on each
6
Reviewed-by: Luc Michel <luc@lmichel.fr>
6
half of a pair of half-precision operations at once.
7
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20210128114145.20536-19-peter.maydell@linaro.org
9
Message-id: 20210121190622.22000-19-peter.maydell@linaro.org
10
---
11
hw/timer/cmsdk-apb-timer.c | 18 ++++++++++++++----
12
1 file changed, 14 insertions(+), 4 deletions(-)
7
13
8
Hopefully all this hoop jumping will get simpler once we have
14
diff --git a/hw/timer/cmsdk-apb-timer.c b/hw/timer/cmsdk-apb-timer.c
9
generically vectorised helpers here.
10
11
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Message-id: 20180227143852.11175-16-alex.bennee@linaro.org
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
16
target/arm/helper-a64.h | 10 ++++++++++
17
target/arm/helper-a64.c | 46 +++++++++++++++++++++++++++++++++++++++++++++-
18
target/arm/translate-a64.c | 26 +++++++++++++++++++++-----
19
3 files changed, 76 insertions(+), 6 deletions(-)
20
21
diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h
22
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
23
--- a/target/arm/helper-a64.h
16
--- a/hw/timer/cmsdk-apb-timer.c
24
+++ b/target/arm/helper-a64.h
17
+++ b/hw/timer/cmsdk-apb-timer.c
25
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(advsimd_acge_f16, i32, f16, f16, ptr)
18
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_reset(DeviceState *dev)
26
DEF_HELPER_3(advsimd_acgt_f16, i32, f16, f16, ptr)
19
ptimer_transaction_commit(s->timer);
27
DEF_HELPER_3(advsimd_mulxh, f16, f16, f16, ptr)
20
}
28
DEF_HELPER_4(advsimd_muladdh, f16, f16, f16, f16, ptr)
21
29
+DEF_HELPER_3(advsimd_add2h, i32, i32, i32, ptr)
22
+static void cmsdk_apb_timer_clk_update(void *opaque)
30
+DEF_HELPER_3(advsimd_sub2h, i32, i32, i32, ptr)
23
+{
31
+DEF_HELPER_3(advsimd_mul2h, i32, i32, i32, ptr)
24
+ CMSDKAPBTimer *s = CMSDK_APB_TIMER(opaque);
32
+DEF_HELPER_3(advsimd_div2h, i32, i32, i32, ptr)
25
+
33
+DEF_HELPER_3(advsimd_max2h, i32, i32, i32, ptr)
26
+ ptimer_transaction_begin(s->timer);
34
+DEF_HELPER_3(advsimd_min2h, i32, i32, i32, ptr)
27
+ ptimer_set_period_from_clock(s->timer, s->pclk, 1);
35
+DEF_HELPER_3(advsimd_maxnum2h, i32, i32, i32, ptr)
28
+ ptimer_transaction_commit(s->timer);
36
+DEF_HELPER_3(advsimd_minnum2h, i32, i32, i32, ptr)
37
+DEF_HELPER_3(advsimd_mulx2h, i32, i32, i32, ptr)
38
+DEF_HELPER_4(advsimd_muladd2h, i32, i32, i32, i32, ptr)
39
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
40
index XXXXXXX..XXXXXXX 100644
41
--- a/target/arm/helper-a64.c
42
+++ b/target/arm/helper-a64.c
43
@@ -XXX,XX +XXX,XX @@ ADVSIMD_HALFOP(max)
44
ADVSIMD_HALFOP(minnum)
45
ADVSIMD_HALFOP(maxnum)
46
47
+#define ADVSIMD_TWOHALFOP(name) \
48
+uint32_t ADVSIMD_HELPER(name, 2h)(uint32_t two_a, uint32_t two_b, void *fpstp) \
49
+{ \
50
+ float16 a1, a2, b1, b2; \
51
+ uint32_t r1, r2; \
52
+ float_status *fpst = fpstp; \
53
+ a1 = extract32(two_a, 0, 16); \
54
+ a2 = extract32(two_a, 16, 16); \
55
+ b1 = extract32(two_b, 0, 16); \
56
+ b2 = extract32(two_b, 16, 16); \
57
+ r1 = float16_ ## name(a1, b1, fpst); \
58
+ r2 = float16_ ## name(a2, b2, fpst); \
59
+ return deposit32(r1, 16, 16, r2); \
60
+}
29
+}
61
+
30
+
62
+ADVSIMD_TWOHALFOP(add)
31
static void cmsdk_apb_timer_init(Object *obj)
63
+ADVSIMD_TWOHALFOP(sub)
64
+ADVSIMD_TWOHALFOP(mul)
65
+ADVSIMD_TWOHALFOP(div)
66
+ADVSIMD_TWOHALFOP(min)
67
+ADVSIMD_TWOHALFOP(max)
68
+ADVSIMD_TWOHALFOP(minnum)
69
+ADVSIMD_TWOHALFOP(maxnum)
70
+
71
/* Data processing - scalar floating-point and advanced SIMD */
72
-float16 HELPER(advsimd_mulxh)(float16 a, float16 b, void *fpstp)
73
+static float16 float16_mulx(float16 a, float16 b, void *fpstp)
74
{
32
{
75
float_status *fpst = fpstp;
33
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
76
34
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_init(Object *obj)
77
@@ -XXX,XX +XXX,XX @@ float16 HELPER(advsimd_mulxh)(float16 a, float16 b, void *fpstp)
35
s, "cmsdk-apb-timer", 0x1000);
78
return float16_mul(a, b, fpst);
36
sysbus_init_mmio(sbd, &s->iomem);
37
sysbus_init_irq(sbd, &s->timerint);
38
- s->pclk = qdev_init_clock_in(DEVICE(s), "pclk", NULL, NULL);
39
+ s->pclk = qdev_init_clock_in(DEVICE(s), "pclk",
40
+ cmsdk_apb_timer_clk_update, s);
79
}
41
}
80
42
81
+ADVSIMD_HALFOP(mulx)
43
static void cmsdk_apb_timer_realize(DeviceState *dev, Error **errp)
82
+ADVSIMD_TWOHALFOP(mulx)
83
+
84
/* fused multiply-accumulate */
85
float16 HELPER(advsimd_muladdh)(float16 a, float16 b, float16 c, void *fpstp)
86
{
44
{
87
@@ -XXX,XX +XXX,XX @@ float16 HELPER(advsimd_muladdh)(float16 a, float16 b, float16 c, void *fpstp)
45
CMSDKAPBTimer *s = CMSDK_APB_TIMER(dev);
88
return float16_muladd(a, b, c, 0, fpst);
46
47
- if (s->pclk_frq == 0) {
48
- error_setg(errp, "CMSDK APB timer: pclk-frq property must be set");
49
+ if (!clock_has_source(s->pclk)) {
50
+ error_setg(errp, "CMSDK APB timer: pclk clock must be connected");
51
return;
52
}
53
54
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_realize(DeviceState *dev, Error **errp)
55
PTIMER_POLICY_NO_COUNTER_ROUND_DOWN);
56
57
ptimer_transaction_begin(s->timer);
58
- ptimer_set_freq(s->timer, s->pclk_frq);
59
+ ptimer_set_period_from_clock(s->timer, s->pclk, 1);
60
ptimer_transaction_commit(s->timer);
89
}
61
}
90
62
91
+uint32_t HELPER(advsimd_muladd2h)(uint32_t two_a, uint32_t two_b,
92
+ uint32_t two_c, void *fpstp)
93
+{
94
+ float_status *fpst = fpstp;
95
+ float16 a1, a2, b1, b2, c1, c2;
96
+ uint32_t r1, r2;
97
+ a1 = extract32(two_a, 0, 16);
98
+ a2 = extract32(two_a, 16, 16);
99
+ b1 = extract32(two_b, 0, 16);
100
+ b2 = extract32(two_b, 16, 16);
101
+ c1 = extract32(two_c, 0, 16);
102
+ c2 = extract32(two_c, 16, 16);
103
+ r1 = float16_muladd(a1, b1, c1, 0, fpst);
104
+ r2 = float16_muladd(a2, b2, c2, 0, fpst);
105
+ return deposit32(r1, 16, 16, r2);
106
+}
107
+
108
/*
109
* Floating point comparisons produce an integer result. Softfloat
110
* routines return float_relation types which we convert to the 0/-1
111
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
112
index XXXXXXX..XXXXXXX 100644
113
--- a/target/arm/translate-a64.c
114
+++ b/target/arm/translate-a64.c
115
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
116
* multiply-add */
117
tcg_gen_xori_i32(tcg_op, tcg_op, 0x80008000);
118
}
119
- gen_helper_advsimd_muladdh(tcg_res, tcg_op, tcg_idx,
120
- tcg_res, fpst);
121
+ if (is_scalar) {
122
+ gen_helper_advsimd_muladdh(tcg_res, tcg_op, tcg_idx,
123
+ tcg_res, fpst);
124
+ } else {
125
+ gen_helper_advsimd_muladd2h(tcg_res, tcg_op, tcg_idx,
126
+ tcg_res, fpst);
127
+ }
128
break;
129
case 2:
130
if (opcode == 0x5) {
131
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
132
switch (size) {
133
case 1:
134
if (u) {
135
- gen_helper_advsimd_mulxh(tcg_res, tcg_op, tcg_idx,
136
- fpst);
137
+ if (is_scalar) {
138
+ gen_helper_advsimd_mulxh(tcg_res, tcg_op,
139
+ tcg_idx, fpst);
140
+ } else {
141
+ gen_helper_advsimd_mulx2h(tcg_res, tcg_op,
142
+ tcg_idx, fpst);
143
+ }
144
} else {
145
- g_assert_not_reached();
146
+ if (is_scalar) {
147
+ gen_helper_advsimd_mulh(tcg_res, tcg_op,
148
+ tcg_idx, fpst);
149
+ } else {
150
+ gen_helper_advsimd_mul2h(tcg_res, tcg_op,
151
+ tcg_idx, fpst);
152
+ }
153
}
154
break;
155
case 2:
156
--
63
--
157
2.16.2
64
2.20.1
158
65
159
66
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
Switch the CMSDK APB dualtimer device over to using its Clock input;
2
the pclk-frq property is now ignored.
2
3
3
It looks like the ARM ARM has simplified the pseudo code for the
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
calculation which is done on a fixed point 9 bit integer maths. So
5
Reviewed-by: Luc Michel <luc@lmichel.fr>
5
while adding f16 we can also clean this up to be a little less heavy
6
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
on the floating point and just return the fractional part and leave
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
the calle's to do the final packing of the result.
8
Message-id: 20210128114145.20536-20-peter.maydell@linaro.org
9
Message-id: 20210121190622.22000-20-peter.maydell@linaro.org
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
---
12
hw/timer/cmsdk-apb-dualtimer.c | 42 ++++++++++++++++++++++++++++++----
13
1 file changed, 37 insertions(+), 5 deletions(-)
8
14
9
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
15
diff --git a/hw/timer/cmsdk-apb-dualtimer.c b/hw/timer/cmsdk-apb-dualtimer.c
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20180227143852.11175-23-alex.bennee@linaro.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
target/arm/helper.h | 1 +
15
target/arm/helper.c | 226 +++++++++++++++++++++++++++++-----------------------
16
2 files changed, 129 insertions(+), 98 deletions(-)
17
18
diff --git a/target/arm/helper.h b/target/arm/helper.h
19
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/helper.h
17
--- a/hw/timer/cmsdk-apb-dualtimer.c
21
+++ b/target/arm/helper.h
18
+++ b/hw/timer/cmsdk-apb-dualtimer.c
22
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_4(vfp_muladds, f32, f32, f32, f32, ptr)
19
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_dualtimer_update(CMSDKAPBDualTimer *s)
23
20
qemu_set_irq(s->timerintc, timintc);
24
DEF_HELPER_3(recps_f32, f32, f32, f32, env)
25
DEF_HELPER_3(rsqrts_f32, f32, f32, f32, env)
26
+DEF_HELPER_FLAGS_2(recpe_f16, TCG_CALL_NO_RWG, f16, f16, ptr)
27
DEF_HELPER_FLAGS_2(recpe_f32, TCG_CALL_NO_RWG, f32, f32, ptr)
28
DEF_HELPER_FLAGS_2(recpe_f64, TCG_CALL_NO_RWG, f64, f64, ptr)
29
DEF_HELPER_FLAGS_2(rsqrte_f32, TCG_CALL_NO_RWG, f32, f32, ptr)
30
diff --git a/target/arm/helper.c b/target/arm/helper.c
31
index XXXXXXX..XXXXXXX 100644
32
--- a/target/arm/helper.c
33
+++ b/target/arm/helper.c
34
@@ -XXX,XX +XXX,XX @@ float32 HELPER(rsqrts_f32)(float32 a, float32 b, CPUARMState *env)
35
* int->float conversions at run-time. */
36
#define float64_256 make_float64(0x4070000000000000LL)
37
#define float64_512 make_float64(0x4080000000000000LL)
38
+#define float16_maxnorm make_float16(0x7bff)
39
#define float32_maxnorm make_float32(0x7f7fffff)
40
#define float64_maxnorm make_float64(0x7fefffffffffffffLL)
41
42
/* Reciprocal functions
43
*
44
* The algorithm that must be used to calculate the estimate
45
- * is specified by the ARM ARM, see FPRecipEstimate()
46
+ * is specified by the ARM ARM, see FPRecipEstimate()/RecipEstimate
47
*/
48
49
-static float64 recip_estimate(float64 a, float_status *real_fp_status)
50
+/* See RecipEstimate()
51
+ *
52
+ * input is a 9 bit fixed point number
53
+ * input range 256 .. 511 for a number from 0.5 <= x < 1.0.
54
+ * result range 256 .. 511 for a number from 1.0 to 511/256.
55
+ */
56
+
57
+static int recip_estimate(int input)
58
{
59
- /* These calculations mustn't set any fp exception flags,
60
- * so we use a local copy of the fp_status.
61
- */
62
- float_status dummy_status = *real_fp_status;
63
- float_status *s = &dummy_status;
64
- /* q = (int)(a * 512.0) */
65
- float64 q = float64_mul(float64_512, a, s);
66
- int64_t q_int = float64_to_int64_round_to_zero(q, s);
67
-
68
- /* r = 1.0 / (((double)q + 0.5) / 512.0) */
69
- q = int64_to_float64(q_int, s);
70
- q = float64_add(q, float64_half, s);
71
- q = float64_div(q, float64_512, s);
72
- q = float64_div(float64_one, q, s);
73
-
74
- /* s = (int)(256.0 * r + 0.5) */
75
- q = float64_mul(q, float64_256, s);
76
- q = float64_add(q, float64_half, s);
77
- q_int = float64_to_int64_round_to_zero(q, s);
78
-
79
- /* return (double)s / 256.0 */
80
- return float64_div(int64_to_float64(q_int, s), float64_256, s);
81
+ int a, b, r;
82
+ assert(256 <= input && input < 512);
83
+ a = (input * 2) + 1;
84
+ b = (1 << 19) / a;
85
+ r = (b + 1) >> 1;
86
+ assert(256 <= r && r < 512);
87
+ return r;
88
}
21
}
89
22
90
-/* Common wrapper to call recip_estimate */
23
+static int cmsdk_dualtimermod_divisor(CMSDKAPBDualTimerModule *m)
91
-static float64 call_recip_estimate(float64 num, int off, float_status *fpst)
92
-{
93
- uint64_t val64 = float64_val(num);
94
- uint64_t frac = extract64(val64, 0, 52);
95
- int64_t exp = extract64(val64, 52, 11);
96
- uint64_t sbit;
97
- float64 scaled, estimate;
98
+/*
99
+ * Common wrapper to call recip_estimate
100
+ *
101
+ * The parameters are exponent and 64 bit fraction (without implicit
102
+ * bit) where the binary point is nominally at bit 52. Returns a
103
+ * float64 which can then be rounded to the appropriate size by the
104
+ * callee.
105
+ */
106
107
- /* Generate the scaled number for the estimate function */
108
- if (exp == 0) {
109
+static uint64_t call_recip_estimate(int *exp, int exp_off, uint64_t frac)
110
+{
24
+{
111
+ uint32_t scaled, estimate;
25
+ /* Return the divisor set by the current CONTROL.PRESCALE value */
112
+ uint64_t result_frac;
26
+ switch (FIELD_EX32(m->control, CONTROL, PRESCALE)) {
113
+ int result_exp;
27
+ case 0:
114
+
28
+ return 1;
115
+ /* Handle sub-normals */
29
+ case 1:
116
+ if (*exp == 0) {
30
+ return 16;
117
if (extract64(frac, 51, 1) == 0) {
31
+ case 2:
118
- exp = -1;
32
+ case 3: /* UNDEFINED, we treat like 2 (and complained when it was set) */
119
- frac = extract64(frac, 0, 50) << 2;
33
+ return 256;
120
+ *exp = -1;
34
+ default:
121
+ frac <<= 2;
35
+ g_assert_not_reached();
122
} else {
123
- frac = extract64(frac, 0, 51) << 1;
124
+ frac <<= 1;
125
}
126
}
127
128
- /* scaled = '0' : '01111111110' : fraction<51:44> : Zeros(44); */
129
- scaled = make_float64((0x3feULL << 52)
130
- | extract64(frac, 44, 8) << 44);
131
+ /* scaled = UInt('1':fraction<51:44>) */
132
+ scaled = deposit32(1 << 8, 0, 8, extract64(frac, 44, 8));
133
+ estimate = recip_estimate(scaled);
134
135
- estimate = recip_estimate(scaled, fpst);
136
-
137
- /* Build new result */
138
- val64 = float64_val(estimate);
139
- sbit = 0x8000000000000000ULL & val64;
140
- exp = off - exp;
141
- frac = extract64(val64, 0, 52);
142
-
143
- if (exp == 0) {
144
- frac = 1ULL << 51 | extract64(frac, 1, 51);
145
- } else if (exp == -1) {
146
- frac = 1ULL << 50 | extract64(frac, 2, 50);
147
- exp = 0;
148
+ result_exp = exp_off - *exp;
149
+ result_frac = deposit64(0, 44, 8, estimate);
150
+ if (result_exp == 0) {
151
+ result_frac = deposit64(result_frac >> 1, 51, 1, 1);
152
+ } else if (result_exp == -1) {
153
+ result_frac = deposit64(result_frac >> 2, 50, 2, 1);
154
+ result_exp = 0;
155
}
156
157
- return make_float64(sbit | (exp << 52) | frac);
158
+ *exp = result_exp;
159
+
160
+ return result_frac;
161
}
162
163
static bool round_to_inf(float_status *fpst, bool sign_bit)
164
@@ -XXX,XX +XXX,XX @@ static bool round_to_inf(float_status *fpst, bool sign_bit)
165
g_assert_not_reached();
166
}
167
168
+float16 HELPER(recpe_f16)(float16 input, void *fpstp)
169
+{
170
+ float_status *fpst = fpstp;
171
+ float16 f16 = float16_squash_input_denormal(input, fpst);
172
+ uint32_t f16_val = float16_val(f16);
173
+ uint32_t f16_sign = float16_is_neg(f16);
174
+ int f16_exp = extract32(f16_val, 10, 5);
175
+ uint32_t f16_frac = extract32(f16_val, 0, 10);
176
+ uint64_t f64_frac;
177
+
178
+ if (float16_is_any_nan(f16)) {
179
+ float16 nan = f16;
180
+ if (float16_is_signaling_nan(f16, fpst)) {
181
+ float_raise(float_flag_invalid, fpst);
182
+ nan = float16_maybe_silence_nan(f16, fpst);
183
+ }
184
+ if (fpst->default_nan_mode) {
185
+ nan = float16_default_nan(fpst);
186
+ }
187
+ return nan;
188
+ } else if (float16_is_infinity(f16)) {
189
+ return float16_set_sign(float16_zero, float16_is_neg(f16));
190
+ } else if (float16_is_zero(f16)) {
191
+ float_raise(float_flag_divbyzero, fpst);
192
+ return float16_set_sign(float16_infinity, float16_is_neg(f16));
193
+ } else if (float16_abs(f16) < (1 << 8)) {
194
+ /* Abs(value) < 2.0^-16 */
195
+ float_raise(float_flag_overflow | float_flag_inexact, fpst);
196
+ if (round_to_inf(fpst, f16_sign)) {
197
+ return float16_set_sign(float16_infinity, f16_sign);
198
+ } else {
199
+ return float16_set_sign(float16_maxnorm, f16_sign);
200
+ }
201
+ } else if (f16_exp >= 29 && fpst->flush_to_zero) {
202
+ float_raise(float_flag_underflow, fpst);
203
+ return float16_set_sign(float16_zero, float16_is_neg(f16));
204
+ }
36
+ }
205
+
206
+ f64_frac = call_recip_estimate(&f16_exp, 29,
207
+ ((uint64_t) f16_frac) << (52 - 10));
208
+
209
+ /* result = sign : result_exp<4:0> : fraction<51:42> */
210
+ f16_val = deposit32(0, 15, 1, f16_sign);
211
+ f16_val = deposit32(f16_val, 10, 5, f16_exp);
212
+ f16_val = deposit32(f16_val, 0, 10, extract64(f64_frac, 52 - 10, 10));
213
+ return make_float16(f16_val);
214
+}
37
+}
215
+
38
+
216
float32 HELPER(recpe_f32)(float32 input, void *fpstp)
39
static void cmsdk_dualtimermod_write_control(CMSDKAPBDualTimerModule *m,
40
uint32_t newctrl)
217
{
41
{
218
float_status *fpst = fpstp;
42
@@ -XXX,XX +XXX,XX @@ static void cmsdk_dualtimermod_write_control(CMSDKAPBDualTimerModule *m,
219
float32 f32 = float32_squash_input_denormal(input, fpst);
43
default:
220
uint32_t f32_val = float32_val(f32);
44
g_assert_not_reached();
221
- uint32_t f32_sbit = 0x80000000ULL & f32_val;
222
- int32_t f32_exp = extract32(f32_val, 23, 8);
223
+ bool f32_sign = float32_is_neg(f32);
224
+ int f32_exp = extract32(f32_val, 23, 8);
225
uint32_t f32_frac = extract32(f32_val, 0, 23);
226
- float64 f64, r64;
227
- uint64_t r64_val;
228
- int64_t r64_exp;
229
- uint64_t r64_frac;
230
+ uint64_t f64_frac;
231
232
if (float32_is_any_nan(f32)) {
233
float32 nan = f32;
234
@@ -XXX,XX +XXX,XX @@ float32 HELPER(recpe_f32)(float32 input, void *fpstp)
235
} else if (float32_is_zero(f32)) {
236
float_raise(float_flag_divbyzero, fpst);
237
return float32_set_sign(float32_infinity, float32_is_neg(f32));
238
- } else if ((f32_val & ~(1ULL << 31)) < (1ULL << 21)) {
239
+ } else if (float32_abs(f32) < (1ULL << 21)) {
240
/* Abs(value) < 2.0^-128 */
241
float_raise(float_flag_overflow | float_flag_inexact, fpst);
242
- if (round_to_inf(fpst, f32_sbit)) {
243
- return float32_set_sign(float32_infinity, float32_is_neg(f32));
244
+ if (round_to_inf(fpst, f32_sign)) {
245
+ return float32_set_sign(float32_infinity, f32_sign);
246
} else {
247
- return float32_set_sign(float32_maxnorm, float32_is_neg(f32));
248
+ return float32_set_sign(float32_maxnorm, f32_sign);
249
}
45
}
250
} else if (f32_exp >= 253 && fpst->flush_to_zero) {
46
- ptimer_set_freq(m->timer, m->parent->pclk_frq / divisor);
251
float_raise(float_flag_underflow, fpst);
47
+ ptimer_set_period_from_clock(m->timer, m->parent->timclk, divisor);
252
return float32_set_sign(float32_zero, float32_is_neg(f32));
253
}
48
}
254
49
255
+ f64_frac = call_recip_estimate(&f32_exp, 253,
50
if (changed & R_CONTROL_MODE_MASK) {
256
+ ((uint64_t) f32_frac) << (52 - 23));
51
@@ -XXX,XX +XXX,XX @@ static void cmsdk_dualtimermod_reset(CMSDKAPBDualTimerModule *m)
257
52
* limit must both be set to 0xffff, so we wrap at 16 bits.
258
- f64 = make_float64(((int64_t)(f32_exp) << 52) | (int64_t)(f32_frac) << 29);
53
*/
259
- r64 = call_recip_estimate(f64, 253, fpst);
54
ptimer_set_limit(m->timer, 0xffff, 1);
260
- r64_val = float64_val(r64);
55
- ptimer_set_freq(m->timer, m->parent->pclk_frq);
261
- r64_exp = extract64(r64_val, 52, 11);
56
+ ptimer_set_period_from_clock(m->timer, m->parent->timclk,
262
- r64_frac = extract64(r64_val, 0, 52);
57
+ cmsdk_dualtimermod_divisor(m));
263
-
58
ptimer_transaction_commit(m->timer);
264
- /* result = sign : result_exp<7:0> : fraction<51:29>; */
265
- return make_float32(f32_sbit |
266
- (r64_exp & 0xff) << 23 |
267
- extract64(r64_frac, 29, 24));
268
+ /* result = sign : result_exp<7:0> : fraction<51:29> */
269
+ f32_val = deposit32(0, 31, 1, f32_sign);
270
+ f32_val = deposit32(f32_val, 23, 8, f32_exp);
271
+ f32_val = deposit32(f32_val, 0, 23, extract64(f64_frac, 52 - 23, 23));
272
+ return make_float32(f32_val);
273
}
59
}
274
60
275
float64 HELPER(recpe_f64)(float64 input, void *fpstp)
61
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_dualtimer_reset(DeviceState *dev)
276
@@ -XXX,XX +XXX,XX @@ float64 HELPER(recpe_f64)(float64 input, void *fpstp)
62
s->timeritop = 0;
277
float_status *fpst = fpstp;
63
}
278
float64 f64 = float64_squash_input_denormal(input, fpst);
64
279
uint64_t f64_val = float64_val(f64);
65
+static void cmsdk_apb_dualtimer_clk_update(void *opaque)
280
- uint64_t f64_sbit = 0x8000000000000000ULL & f64_val;
66
+{
281
- int64_t f64_exp = extract64(f64_val, 52, 11);
67
+ CMSDKAPBDualTimer *s = CMSDK_APB_DUALTIMER(opaque);
282
- float64 r64;
68
+ int i;
283
- uint64_t r64_val;
69
+
284
- int64_t r64_exp;
70
+ for (i = 0; i < ARRAY_SIZE(s->timermod); i++) {
285
- uint64_t r64_frac;
71
+ CMSDKAPBDualTimerModule *m = &s->timermod[i];
286
+ bool f64_sign = float64_is_neg(f64);
72
+ ptimer_transaction_begin(m->timer);
287
+ int f64_exp = extract64(f64_val, 52, 11);
73
+ ptimer_set_period_from_clock(m->timer, m->parent->timclk,
288
+ uint64_t f64_frac = extract64(f64_val, 0, 52);
74
+ cmsdk_dualtimermod_divisor(m));
289
75
+ ptimer_transaction_commit(m->timer);
290
/* Deal with any special cases */
76
+ }
291
if (float64_is_any_nan(f64)) {
77
+}
292
@@ -XXX,XX +XXX,XX @@ float64 HELPER(recpe_f64)(float64 input, void *fpstp)
78
+
293
} else if ((f64_val & ~(1ULL << 63)) < (1ULL << 50)) {
79
static void cmsdk_apb_dualtimer_init(Object *obj)
294
/* Abs(value) < 2.0^-1024 */
80
{
295
float_raise(float_flag_overflow | float_flag_inexact, fpst);
81
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
296
- if (round_to_inf(fpst, f64_sbit)) {
82
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_dualtimer_init(Object *obj)
297
- return float64_set_sign(float64_infinity, float64_is_neg(f64));
83
for (i = 0; i < ARRAY_SIZE(s->timermod); i++) {
298
+ if (round_to_inf(fpst, f64_sign)) {
84
sysbus_init_irq(sbd, &s->timermod[i].timerint);
299
+ return float64_set_sign(float64_infinity, f64_sign);
300
} else {
301
- return float64_set_sign(float64_maxnorm, float64_is_neg(f64));
302
+ return float64_set_sign(float64_maxnorm, f64_sign);
303
}
304
} else if (f64_exp >= 2045 && fpst->flush_to_zero) {
305
float_raise(float_flag_underflow, fpst);
306
return float64_set_sign(float64_zero, float64_is_neg(f64));
307
}
85
}
308
86
- s->timclk = qdev_init_clock_in(DEVICE(s), "TIMCLK", NULL, NULL);
309
- r64 = call_recip_estimate(f64, 2045, fpst);
87
+ s->timclk = qdev_init_clock_in(DEVICE(s), "TIMCLK",
310
- r64_val = float64_val(r64);
88
+ cmsdk_apb_dualtimer_clk_update, s);
311
- r64_exp = extract64(r64_val, 52, 11);
312
- r64_frac = extract64(r64_val, 0, 52);
313
+ f64_frac = call_recip_estimate(&f64_exp, 2045, f64_frac);
314
315
- /* result = sign : result_exp<10:0> : fraction<51:0> */
316
- return make_float64(f64_sbit |
317
- ((r64_exp & 0x7ff) << 52) |
318
- r64_frac);
319
+ /* result = sign : result_exp<10:0> : fraction<51:0>; */
320
+ f64_val = deposit64(0, 63, 1, f64_sign);
321
+ f64_val = deposit64(f64_val, 52, 11, f64_exp);
322
+ f64_val = deposit64(f64_val, 0, 52, f64_frac);
323
+ return make_float64(f64_val);
324
}
89
}
325
90
326
/* The algorithm that must be used to calculate the estimate
91
static void cmsdk_apb_dualtimer_realize(DeviceState *dev, Error **errp)
327
@@ -XXX,XX +XXX,XX @@ float64 HELPER(rsqrte_f64)(float64 input, void *fpstp)
92
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_dualtimer_realize(DeviceState *dev, Error **errp)
328
93
CMSDKAPBDualTimer *s = CMSDK_APB_DUALTIMER(dev);
329
uint32_t HELPER(recpe_u32)(uint32_t a, void *fpstp)
94
int i;
330
{
95
331
- float_status *s = fpstp;
96
- if (s->pclk_frq == 0) {
332
- float64 f64;
97
- error_setg(errp, "CMSDK APB timer: pclk-frq property must be set");
333
+ /* float_status *s = fpstp; */
98
+ if (!clock_has_source(s->timclk)) {
334
+ int input, estimate;
99
+ error_setg(errp, "CMSDK APB dualtimer: TIMCLK clock must be connected");
335
100
return;
336
if ((a & 0x80000000) == 0) {
337
return 0xffffffff;
338
}
101
}
339
102
340
- f64 = make_float64((0x3feULL << 52)
341
- | ((int64_t)(a & 0x7fffffff) << 21));
342
+ input = extract32(a, 23, 9);
343
+ estimate = recip_estimate(input);
344
345
- f64 = recip_estimate(f64, s);
346
-
347
- return 0x80000000 | ((float64_val(f64) >> 21) & 0x7fffffff);
348
+ return deposit32(0, (32 - 9), 9, estimate);
349
}
350
351
uint32_t HELPER(rsqrte_u32)(uint32_t a, void *fpstp)
352
--
103
--
353
2.16.2
104
2.20.1
354
105
355
106
diff view generated by jsdifflib
1
From: Alistair Francis <alistair.francis@xilinx.com>
1
Switch the CMSDK APB watchdog device over to using its Clock input;
2
the wdogclk_frq property is now ignored.
2
3
3
Ensure that the post write hook is called during reset. This allows us
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
to rely on the post write functions instead of having to call them from
5
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
5
the reset() function.
6
Reviewed-by: Luc Michel <luc@lmichel.fr>
7
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20210128114145.20536-21-peter.maydell@linaro.org
9
Message-id: 20210121190622.22000-21-peter.maydell@linaro.org
10
---
11
hw/watchdog/cmsdk-apb-watchdog.c | 18 ++++++++++++++----
12
1 file changed, 14 insertions(+), 4 deletions(-)
6
13
7
Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
14
diff --git a/hw/watchdog/cmsdk-apb-watchdog.c b/hw/watchdog/cmsdk-apb-watchdog.c
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-id: d131e24b911653a945e46ca2d8f90f572469e1dd.1517856214.git.alistair.francis@xilinx.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
include/hw/register.h | 6 +++---
13
hw/core/register.c | 8 ++++++++
14
2 files changed, 11 insertions(+), 3 deletions(-)
15
16
diff --git a/include/hw/register.h b/include/hw/register.h
17
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/register.h
16
--- a/hw/watchdog/cmsdk-apb-watchdog.c
19
+++ b/include/hw/register.h
17
+++ b/hw/watchdog/cmsdk-apb-watchdog.c
20
@@ -XXX,XX +XXX,XX @@ typedef struct RegisterInfoArray RegisterInfoArray;
18
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_reset(DeviceState *dev)
21
* immediately before the actual write. The returned value is what is written,
19
ptimer_transaction_commit(s->timer);
22
* giving the handler a chance to modify the written value.
20
}
23
* @post_write: Post write callback. Passed the written value. Most write side
21
24
- * effects should be implemented here.
22
+static void cmsdk_apb_watchdog_clk_update(void *opaque)
25
+ * effects should be implemented here. This is called during device reset.
23
+{
26
*
24
+ CMSDKAPBWatchdog *s = CMSDK_APB_WATCHDOG(opaque);
27
* @post_read: Post read callback. Passes the value that is about to be returned
25
+
28
* for a read. The return value from this function is what is ultimately read,
26
+ ptimer_transaction_begin(s->timer);
29
@@ -XXX,XX +XXX,XX @@ uint64_t register_read(RegisterInfo *reg, uint64_t re, const char* prefix,
27
+ ptimer_set_period_from_clock(s->timer, s->wdogclk, 1);
30
bool debug);
28
+ ptimer_transaction_commit(s->timer);
31
29
+}
32
/**
30
+
33
- * reset a register
31
static void cmsdk_apb_watchdog_init(Object *obj)
34
- * @reg: register to reset
35
+ * Resets a register. This will also call the post_write hook if it exists.
36
+ * @reg: The register to reset.
37
*/
38
39
void register_reset(RegisterInfo *reg);
40
diff --git a/hw/core/register.c b/hw/core/register.c
41
index XXXXXXX..XXXXXXX 100644
42
--- a/hw/core/register.c
43
+++ b/hw/core/register.c
44
@@ -XXX,XX +XXX,XX @@ uint64_t register_read(RegisterInfo *reg, uint64_t re, const char* prefix,
45
46
void register_reset(RegisterInfo *reg)
47
{
32
{
48
+ const RegisterAccessInfo *ac;
33
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
49
+
34
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_init(Object *obj)
50
g_assert(reg);
35
s, "cmsdk-apb-watchdog", 0x1000);
51
36
sysbus_init_mmio(sbd, &s->iomem);
52
if (!reg->data || !reg->access) {
37
sysbus_init_irq(sbd, &s->wdogint);
38
- s->wdogclk = qdev_init_clock_in(DEVICE(s), "WDOGCLK", NULL, NULL);
39
+ s->wdogclk = qdev_init_clock_in(DEVICE(s), "WDOGCLK",
40
+ cmsdk_apb_watchdog_clk_update, s);
41
42
s->is_luminary = false;
43
s->id = cmsdk_apb_watchdog_id;
44
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_realize(DeviceState *dev, Error **errp)
45
{
46
CMSDKAPBWatchdog *s = CMSDK_APB_WATCHDOG(dev);
47
48
- if (s->wdogclk_frq == 0) {
49
+ if (!clock_has_source(s->wdogclk)) {
50
error_setg(errp,
51
- "CMSDK APB watchdog: wdogclk-frq property must be set");
52
+ "CMSDK APB watchdog: WDOGCLK clock must be connected");
53
return;
53
return;
54
}
54
}
55
55
56
+ ac = reg->access;
56
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_realize(DeviceState *dev, Error **errp)
57
+
57
PTIMER_POLICY_NO_COUNTER_ROUND_DOWN);
58
register_write_val(reg, reg->access->reset);
58
59
+
59
ptimer_transaction_begin(s->timer);
60
+ if (ac->post_write) {
60
- ptimer_set_freq(s->timer, s->wdogclk_frq);
61
+ ac->post_write(reg, reg->access->reset);
61
+ ptimer_set_period_from_clock(s->timer, s->wdogclk, 1);
62
+ }
62
ptimer_transaction_commit(s->timer);
63
}
63
}
64
64
65
void register_init(RegisterInfo *reg)
66
--
65
--
67
2.16.2
66
2.20.1
68
67
69
68
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
Now that the CMSDK APB watchdog uses its Clock input, it will
2
correctly respond when the system clock frequency is changed using
3
the RCC register on in the Stellaris board system registers. Test
4
that when the RCC register is written it causes the watchdog timer to
5
change speed.
2
6
3
This is the initial decode skeleton for the Advanced SIMD three same
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
instruction group.
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Reviewed-by: Luc Michel <luc@lmichel.fr>
10
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Message-id: 20210128114145.20536-22-peter.maydell@linaro.org
12
Message-id: 20210121190622.22000-22-peter.maydell@linaro.org
13
---
14
tests/qtest/cmsdk-apb-watchdog-test.c | 52 +++++++++++++++++++++++++++
15
1 file changed, 52 insertions(+)
5
16
6
The fprintf is purely to aid debugging as the additional instructions
17
diff --git a/tests/qtest/cmsdk-apb-watchdog-test.c b/tests/qtest/cmsdk-apb-watchdog-test.c
7
are added. It will be removed once the group is complete.
8
9
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20180227143852.11175-9-alex.bennee@linaro.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
target/arm/translate-a64.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++
15
1 file changed, 73 insertions(+)
16
17
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
18
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/translate-a64.c
19
--- a/tests/qtest/cmsdk-apb-watchdog-test.c
20
+++ b/target/arm/translate-a64.c
20
+++ b/tests/qtest/cmsdk-apb-watchdog-test.c
21
@@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same(DisasContext *s, uint32_t insn)
21
@@ -XXX,XX +XXX,XX @@
22
}
22
*/
23
24
#include "qemu/osdep.h"
25
+#include "qemu/bitops.h"
26
#include "libqtest-single.h"
27
28
/*
29
@@ -XXX,XX +XXX,XX @@
30
#define WDOGMIS 0x14
31
#define WDOGLOCK 0xc00
32
33
+#define SSYS_BASE 0x400fe000
34
+#define RCC 0x60
35
+#define SYSDIV_SHIFT 23
36
+#define SYSDIV_LENGTH 4
37
+
38
static void test_watchdog(void)
39
{
40
g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0);
41
@@ -XXX,XX +XXX,XX @@ static void test_watchdog(void)
42
g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0);
23
}
43
}
24
44
25
+/*
45
+static void test_clock_change(void)
26
+ * Advanced SIMD three same (ARMv8.2 FP16 variants)
27
+ *
28
+ * 31 30 29 28 24 23 22 21 20 16 15 14 13 11 10 9 5 4 0
29
+ * +---+---+---+-----------+---------+------+-----+--------+---+------+------+
30
+ * | 0 | Q | U | 0 1 1 1 0 | a | 1 0 | Rm | 0 0 | opcode | 1 | Rn | Rd |
31
+ * +---+---+---+-----------+---------+------+-----+--------+---+------+------+
32
+ *
33
+ * This includes FMULX, FCMEQ (register), FRECPS, FRSQRTS, FCMGE
34
+ * (register), FACGE, FABD, FCMGT (register) and FACGT.
35
+ *
36
+ */
37
+static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn)
38
+{
46
+{
39
+ int opcode, fpopcode;
47
+ uint32_t rcc;
40
+ int is_q, u, a, rm, rn, rd;
41
+ int datasize, elements;
42
+ int pass;
43
+ TCGv_ptr fpst;
44
+
48
+
45
+ if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
49
+ /*
46
+ unallocated_encoding(s);
50
+ * Test that writing to the stellaris board's RCC register to
47
+ return;
51
+ * change the system clock frequency causes the watchdog
48
+ }
52
+ * to change the speed it counts at.
53
+ */
54
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0);
49
+
55
+
50
+ if (!fp_access_check(s)) {
56
+ writel(WDOG_BASE + WDOGCONTROL, 1);
51
+ return;
57
+ writel(WDOG_BASE + WDOGLOAD, 1000);
52
+ }
53
+
58
+
54
+ /* For these floating point ops, the U, a and opcode bits
59
+ /* Step to just past the 500th tick */
55
+ * together indicate the operation.
60
+ clock_step(80 * 500 + 1);
56
+ */
61
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0);
57
+ opcode = extract32(insn, 11, 3);
62
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 500);
58
+ u = extract32(insn, 29, 1);
59
+ a = extract32(insn, 23, 1);
60
+ is_q = extract32(insn, 30, 1);
61
+ rm = extract32(insn, 16, 5);
62
+ rn = extract32(insn, 5, 5);
63
+ rd = extract32(insn, 0, 5);
64
+
63
+
65
+ fpopcode = opcode | (a << 3) | (u << 4);
64
+ /* Rewrite RCC.SYSDIV from 16 to 8, so the clock is now 40ns per tick */
66
+ datasize = is_q ? 128 : 64;
65
+ rcc = readl(SSYS_BASE + RCC);
67
+ elements = datasize / 16;
66
+ g_assert_cmpuint(extract32(rcc, SYSDIV_SHIFT, SYSDIV_LENGTH), ==, 0xf);
67
+ rcc = deposit32(rcc, SYSDIV_SHIFT, SYSDIV_LENGTH, 7);
68
+ writel(SSYS_BASE + RCC, rcc);
68
+
69
+
69
+ fpst = get_fpstatus_ptr(true);
70
+ /* Just past the 1000th tick: timer should have fired */
71
+ clock_step(40 * 500);
72
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 1);
70
+
73
+
71
+ for (pass = 0; pass < elements; pass++) {
74
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 0);
72
+ TCGv_i32 tcg_op1 = tcg_temp_new_i32();
73
+ TCGv_i32 tcg_op2 = tcg_temp_new_i32();
74
+ TCGv_i32 tcg_res = tcg_temp_new_i32();
75
+
75
+
76
+ read_vec_element_i32(s, tcg_op1, rn, pass, MO_16);
76
+ /* VALUE reloads at following tick */
77
+ read_vec_element_i32(s, tcg_op2, rm, pass, MO_16);
77
+ clock_step(41);
78
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 1000);
78
+
79
+
79
+ switch (fpopcode) {
80
+ /* Writing any value to WDOGINTCLR clears the interrupt and reloads */
80
+ default:
81
+ clock_step(40 * 500);
81
+ fprintf(stderr, "%s: insn %#04x, fpop %#2x @ %#" PRIx64 "\n",
82
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 500);
82
+ __func__, insn, fpopcode, s->pc);
83
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 1);
83
+ g_assert_not_reached();
84
+ writel(WDOG_BASE + WDOGINTCLR, 0);
84
+ }
85
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 1000);
85
+
86
+ g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0);
86
+ write_vec_element_i32(s, tcg_res, rd, pass, MO_16);
87
+ tcg_temp_free_i32(tcg_res);
88
+ tcg_temp_free_i32(tcg_op1);
89
+ tcg_temp_free_i32(tcg_op2);
90
+ }
91
+
92
+ tcg_temp_free_ptr(fpst);
93
+
94
+ clear_vec_high(s, is_q, rd);
95
+}
87
+}
96
+
88
+
97
static void handle_2misc_widening(DisasContext *s, int opcode, bool is_q,
89
int main(int argc, char **argv)
98
int size, int rn, int rd)
99
{
90
{
100
@@ -XXX,XX +XXX,XX @@ static const AArch64DecodeTable data_proc_simd[] = {
91
int r;
101
{ 0xce000000, 0xff808000, disas_crypto_four_reg },
92
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv)
102
{ 0xce800000, 0xffe00000, disas_crypto_xar },
93
qtest_start("-machine lm3s811evb");
103
{ 0xce408000, 0xffe0c000, disas_crypto_three_reg_imm2 },
94
104
+ { 0x0e400400, 0x9f60c400, disas_simd_three_reg_same_fp16 },
95
qtest_add_func("/cmsdk-apb-watchdog/watchdog", test_watchdog);
105
{ 0x00000000, 0x00000000, NULL }
96
+ qtest_add_func("/cmsdk-apb-watchdog/watchdog_clock_change",
106
};
97
+ test_clock_change);
98
99
r = g_test_run();
107
100
108
--
101
--
109
2.16.2
102
2.20.1
110
103
111
104
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
Use the MAINCLK Clock input to set the system_clock_scale variable
2
rather than using the mainclk_frq property.
2
3
3
This adds the full range of half-precision floating point to integral
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
instructions.
5
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Luc Michel <luc@lmichel.fr>
8
Message-id: 20210128114145.20536-23-peter.maydell@linaro.org
9
Message-id: 20210121190622.22000-23-peter.maydell@linaro.org
10
---
11
hw/arm/armsse.c | 24 +++++++++++++++++++-----
12
1 file changed, 19 insertions(+), 5 deletions(-)
5
13
6
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
14
diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20180227143852.11175-18-alex.bennee@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/helper-a64.h | 2 +
12
target/arm/helper-a64.c | 22 ++++++++
13
target/arm/translate-a64.c | 123 +++++++++++++++++++++++++++++++++++++++++++--
14
3 files changed, 142 insertions(+), 5 deletions(-)
15
16
diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h
17
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/helper-a64.h
16
--- a/hw/arm/armsse.c
19
+++ b/target/arm/helper-a64.h
17
+++ b/hw/arm/armsse.c
20
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(advsimd_maxnum2h, i32, i32, i32, ptr)
18
@@ -XXX,XX +XXX,XX @@ static void armsse_forward_sec_resp_cfg(ARMSSE *s)
21
DEF_HELPER_3(advsimd_minnum2h, i32, i32, i32, ptr)
19
qdev_connect_gpio_out(dev_splitter, 2, s->sec_resp_cfg_in);
22
DEF_HELPER_3(advsimd_mulx2h, i32, i32, i32, ptr)
23
DEF_HELPER_4(advsimd_muladd2h, i32, i32, i32, i32, ptr)
24
+DEF_HELPER_2(advsimd_rinth_exact, f16, f16, ptr)
25
+DEF_HELPER_2(advsimd_rinth, f16, f16, ptr)
26
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
27
index XXXXXXX..XXXXXXX 100644
28
--- a/target/arm/helper-a64.c
29
+++ b/target/arm/helper-a64.c
30
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(advsimd_acgt_f16)(float16 a, float16 b, void *fpstp)
31
int compare = float16_compare(f0, f1, fpst);
32
return ADVSIMD_CMPRES(compare == float_relation_greater);
33
}
20
}
34
+
21
35
+/* round to integral */
22
+static void armsse_mainclk_update(void *opaque)
36
+float16 HELPER(advsimd_rinth_exact)(float16 x, void *fp_status)
37
+{
23
+{
38
+ return float16_round_to_int(x, fp_status);
24
+ ARMSSE *s = ARM_SSE(opaque);
25
+ /*
26
+ * Set system_clock_scale from our Clock input; this is what
27
+ * controls the tick rate of the CPU SysTick timer.
28
+ */
29
+ system_clock_scale = clock_ticks_to_ns(s->mainclk, 1);
39
+}
30
+}
40
+
31
+
41
+float16 HELPER(advsimd_rinth)(float16 x, void *fp_status)
32
static void armsse_init(Object *obj)
42
+{
43
+ int old_flags = get_float_exception_flags(fp_status), new_flags;
44
+ float16 ret;
45
+
46
+ ret = float16_round_to_int(x, fp_status);
47
+
48
+ /* Suppress any inexact exceptions the conversion produced */
49
+ if (!(old_flags & float_flag_inexact)) {
50
+ new_flags = get_float_exception_flags(fp_status);
51
+ set_float_exception_flags(new_flags & ~float_flag_inexact, fp_status);
52
+ }
53
+
54
+ return ret;
55
+}
56
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
57
index XXXXXXX..XXXXXXX 100644
58
--- a/target/arm/translate-a64.c
59
+++ b/target/arm/translate-a64.c
60
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn)
61
*/
62
static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn)
63
{
33
{
64
- int fpop, opcode, a;
34
ARMSSE *s = ARM_SSE(obj);
65
+ int fpop, opcode, a, u;
35
@@ -XXX,XX +XXX,XX @@ static void armsse_init(Object *obj)
66
+ int rn, rd;
36
assert(info->sram_banks <= MAX_SRAM_BANKS);
67
+ bool is_q;
37
assert(info->num_cpus <= SSE_MAX_CPUS);
68
+ bool is_scalar;
38
69
+ bool only_in_vector = false;
39
- s->mainclk = qdev_init_clock_in(DEVICE(s), "MAINCLK", NULL, NULL);
70
+
40
+ s->mainclk = qdev_init_clock_in(DEVICE(s), "MAINCLK",
71
+ int pass;
41
+ armsse_mainclk_update, s);
72
+ TCGv_i32 tcg_rmode = NULL;
42
s->s32kclk = qdev_init_clock_in(DEVICE(s), "S32KCLK", NULL, NULL);
73
+ TCGv_ptr tcg_fpstatus = NULL;
43
74
+ bool need_rmode = false;
44
memory_region_init(&s->container, obj, "armsse-container", UINT64_MAX);
75
+ int rmode;
45
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
76
77
if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) {
78
unallocated_encoding(s);
79
return;
46
return;
80
}
47
}
81
48
82
- if (!fp_access_check(s)) {
49
- if (!s->mainclk_frq) {
50
- error_setg(errp, "MAINCLK_FRQ property was not set");
83
- return;
51
- return;
84
- }
52
+ if (!clock_has_source(s->mainclk)) {
85
+ rd = extract32(insn, 0, 5);
53
+ error_setg(errp, "MAINCLK clock was not connected");
86
+ rn = extract32(insn, 5, 5);
54
+ }
87
55
+ if (!clock_has_source(s->s32kclk)) {
88
- opcode = extract32(insn, 12, 4);
56
+ error_setg(errp, "S32KCLK clock was not connected");
89
a = extract32(insn, 23, 1);
90
+ u = extract32(insn, 29, 1);
91
+ is_scalar = extract32(insn, 28, 1);
92
+ is_q = extract32(insn, 30, 1);
93
+
94
+ opcode = extract32(insn, 12, 5);
95
fpop = deposit32(opcode, 5, 1, a);
96
+ fpop = deposit32(fpop, 6, 1, u);
97
98
switch (fpop) {
99
+ case 0x18: /* FRINTN */
100
+ need_rmode = true;
101
+ only_in_vector = true;
102
+ rmode = FPROUNDING_TIEEVEN;
103
+ break;
104
+ case 0x19: /* FRINTM */
105
+ need_rmode = true;
106
+ only_in_vector = true;
107
+ rmode = FPROUNDING_NEGINF;
108
+ break;
109
+ case 0x38: /* FRINTP */
110
+ need_rmode = true;
111
+ only_in_vector = true;
112
+ rmode = FPROUNDING_POSINF;
113
+ break;
114
+ case 0x39: /* FRINTZ */
115
+ need_rmode = true;
116
+ only_in_vector = true;
117
+ rmode = FPROUNDING_ZERO;
118
+ break;
119
+ case 0x58: /* FRINTA */
120
+ need_rmode = true;
121
+ only_in_vector = true;
122
+ rmode = FPROUNDING_TIEAWAY;
123
+ break;
124
+ case 0x59: /* FRINTX */
125
+ case 0x79: /* FRINTI */
126
+ only_in_vector = true;
127
+ /* current rounding mode */
128
+ break;
129
default:
130
fprintf(stderr, "%s: insn %#04x fpop %#2x\n", __func__, insn, fpop);
131
g_assert_not_reached();
132
}
57
}
133
58
134
+
59
assert(info->num_cpus <= SSE_MAX_CPUS);
135
+ /* Check additional constraints for the scalar encoding */
60
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
136
+ if (is_scalar) {
61
*/
137
+ if (!is_q) {
62
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->container);
138
+ unallocated_encoding(s);
63
139
+ return;
64
- system_clock_scale = NANOSECONDS_PER_SECOND / s->mainclk_frq;
140
+ }
65
+ /* Set initial system_clock_scale from MAINCLK */
141
+ /* FRINTxx is only in the vector form */
66
+ armsse_mainclk_update(s);
142
+ if (only_in_vector) {
143
+ unallocated_encoding(s);
144
+ return;
145
+ }
146
+ }
147
+
148
+ if (!fp_access_check(s)) {
149
+ return;
150
+ }
151
+
152
+ if (need_rmode) {
153
+ tcg_fpstatus = get_fpstatus_ptr(true);
154
+ }
155
+
156
+ if (need_rmode) {
157
+ tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rmode));
158
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus);
159
+ }
160
+
161
+ if (is_scalar) {
162
+ /* no operations yet */
163
+ } else {
164
+ for (pass = 0; pass < (is_q ? 8 : 4); pass++) {
165
+ TCGv_i32 tcg_op = tcg_temp_new_i32();
166
+ TCGv_i32 tcg_res = tcg_temp_new_i32();
167
+
168
+ read_vec_element_i32(s, tcg_op, rn, pass, MO_16);
169
+
170
+ switch (fpop) {
171
+ case 0x18: /* FRINTN */
172
+ case 0x19: /* FRINTM */
173
+ case 0x38: /* FRINTP */
174
+ case 0x39: /* FRINTZ */
175
+ case 0x58: /* FRINTA */
176
+ case 0x79: /* FRINTI */
177
+ gen_helper_advsimd_rinth(tcg_res, tcg_op, tcg_fpstatus);
178
+ break;
179
+ case 0x59: /* FRINTX */
180
+ gen_helper_advsimd_rinth_exact(tcg_res, tcg_op, tcg_fpstatus);
181
+ break;
182
+ default:
183
+ g_assert_not_reached();
184
+ }
185
+
186
+ write_vec_element_i32(s, tcg_res, rd, pass, MO_16);
187
+
188
+ tcg_temp_free_i32(tcg_res);
189
+ tcg_temp_free_i32(tcg_op);
190
+ }
191
+
192
+ clear_vec_high(s, is_q, rd);
193
+ }
194
+
195
+ if (tcg_rmode) {
196
+ gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus);
197
+ tcg_temp_free_i32(tcg_rmode);
198
+ }
199
+
200
+ if (tcg_fpstatus) {
201
+ tcg_temp_free_ptr(tcg_fpstatus);
202
+ }
203
}
67
}
204
68
205
/* AdvSIMD scalar x indexed element
69
static void armsse_idau_check(IDAUInterface *ii, uint32_t address,
206
--
70
--
207
2.16.2
71
2.20.1
208
72
209
73
diff view generated by jsdifflib
1
Set the appropriate Linux hwcap bits to tell the guest binary if we
1
Remove all the code that sets frequency properties on the CMSDK
2
have implemented half-precision floating point support.
2
timer, dualtimer and watchdog devices and on the ARMSSE SoC device:
3
these properties are unused now that the devices rely on their Clock
4
inputs instead.
3
5
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Reviewed-by: Luc Michel <luc@lmichel.fr>
9
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Message-id: 20210128114145.20536-24-peter.maydell@linaro.org
11
Message-id: 20210121190622.22000-24-peter.maydell@linaro.org
6
---
12
---
7
linux-user/elfload.c | 2 ++
13
hw/arm/armsse.c | 7 -------
8
1 file changed, 2 insertions(+)
14
hw/arm/mps2-tz.c | 1 -
15
hw/arm/mps2.c | 3 ---
16
hw/arm/musca.c | 1 -
17
hw/arm/stellaris.c | 3 ---
18
5 files changed, 15 deletions(-)
9
19
10
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
20
diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c
11
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
12
--- a/linux-user/elfload.c
22
--- a/hw/arm/armsse.c
13
+++ b/linux-user/elfload.c
23
+++ b/hw/arm/armsse.c
14
@@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap(void)
24
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
15
GET_FEATURE(ARM_FEATURE_V8_SM3, ARM_HWCAP_A64_SM3);
25
* it to the appropriate PPC port; then we can realize the PPC and
16
GET_FEATURE(ARM_FEATURE_V8_SM4, ARM_HWCAP_A64_SM4);
26
* map its upstream ends to the right place in the container.
17
GET_FEATURE(ARM_FEATURE_V8_SHA512, ARM_HWCAP_A64_SHA512);
27
*/
18
+ GET_FEATURE(ARM_FEATURE_V8_FP16,
28
- qdev_prop_set_uint32(DEVICE(&s->timer0), "pclk-frq", s->mainclk_frq);
19
+ ARM_HWCAP_A64_FPHP | ARM_HWCAP_A64_ASIMDHP);
29
qdev_connect_clock_in(DEVICE(&s->timer0), "pclk", s->mainclk);
20
#undef GET_FEATURE
30
if (!sysbus_realize(SYS_BUS_DEVICE(&s->timer0), errp)) {
21
31
return;
22
return hwcaps;
32
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
33
object_property_set_link(OBJECT(&s->apb_ppc0), "port[0]", OBJECT(mr),
34
&error_abort);
35
36
- qdev_prop_set_uint32(DEVICE(&s->timer1), "pclk-frq", s->mainclk_frq);
37
qdev_connect_clock_in(DEVICE(&s->timer1), "pclk", s->mainclk);
38
if (!sysbus_realize(SYS_BUS_DEVICE(&s->timer1), errp)) {
39
return;
40
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
41
object_property_set_link(OBJECT(&s->apb_ppc0), "port[1]", OBJECT(mr),
42
&error_abort);
43
44
- qdev_prop_set_uint32(DEVICE(&s->dualtimer), "pclk-frq", s->mainclk_frq);
45
qdev_connect_clock_in(DEVICE(&s->dualtimer), "TIMCLK", s->mainclk);
46
if (!sysbus_realize(SYS_BUS_DEVICE(&s->dualtimer), errp)) {
47
return;
48
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
49
/* Devices behind APB PPC1:
50
* 0x4002f000: S32K timer
51
*/
52
- qdev_prop_set_uint32(DEVICE(&s->s32ktimer), "pclk-frq", S32KCLK);
53
qdev_connect_clock_in(DEVICE(&s->s32ktimer), "pclk", s->s32kclk);
54
if (!sysbus_realize(SYS_BUS_DEVICE(&s->s32ktimer), errp)) {
55
return;
56
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
57
qdev_connect_gpio_out(DEVICE(&s->nmi_orgate), 0,
58
qdev_get_gpio_in_named(DEVICE(&s->armv7m), "NMI", 0));
59
60
- qdev_prop_set_uint32(DEVICE(&s->s32kwatchdog), "wdogclk-frq", S32KCLK);
61
qdev_connect_clock_in(DEVICE(&s->s32kwatchdog), "WDOGCLK", s->s32kclk);
62
if (!sysbus_realize(SYS_BUS_DEVICE(&s->s32kwatchdog), errp)) {
63
return;
64
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
65
66
/* 0x40080000 .. 0x4008ffff : ARMSSE second Base peripheral region */
67
68
- qdev_prop_set_uint32(DEVICE(&s->nswatchdog), "wdogclk-frq", s->mainclk_frq);
69
qdev_connect_clock_in(DEVICE(&s->nswatchdog), "WDOGCLK", s->mainclk);
70
if (!sysbus_realize(SYS_BUS_DEVICE(&s->nswatchdog), errp)) {
71
return;
72
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
73
armsse_get_common_irq_in(s, 1));
74
sysbus_mmio_map(SYS_BUS_DEVICE(&s->nswatchdog), 0, 0x40081000);
75
76
- qdev_prop_set_uint32(DEVICE(&s->swatchdog), "wdogclk-frq", s->mainclk_frq);
77
qdev_connect_clock_in(DEVICE(&s->swatchdog), "WDOGCLK", s->mainclk);
78
if (!sysbus_realize(SYS_BUS_DEVICE(&s->swatchdog), errp)) {
79
return;
80
diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c
81
index XXXXXXX..XXXXXXX 100644
82
--- a/hw/arm/mps2-tz.c
83
+++ b/hw/arm/mps2-tz.c
84
@@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine)
85
object_property_set_link(OBJECT(&mms->iotkit), "memory",
86
OBJECT(system_memory), &error_abort);
87
qdev_prop_set_uint32(iotkitdev, "EXP_NUMIRQ", MPS2TZ_NUMIRQ);
88
- qdev_prop_set_uint32(iotkitdev, "MAINCLK_FRQ", SYSCLK_FRQ);
89
qdev_connect_clock_in(iotkitdev, "MAINCLK", mms->sysclk);
90
qdev_connect_clock_in(iotkitdev, "S32KCLK", mms->s32kclk);
91
sysbus_realize(SYS_BUS_DEVICE(&mms->iotkit), &error_fatal);
92
diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
93
index XXXXXXX..XXXXXXX 100644
94
--- a/hw/arm/mps2.c
95
+++ b/hw/arm/mps2.c
96
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
97
object_initialize_child(OBJECT(mms), name, &mms->timer[i],
98
TYPE_CMSDK_APB_TIMER);
99
sbd = SYS_BUS_DEVICE(&mms->timer[i]);
100
- qdev_prop_set_uint32(DEVICE(&mms->timer[i]), "pclk-frq", SYSCLK_FRQ);
101
qdev_connect_clock_in(DEVICE(&mms->timer[i]), "pclk", mms->sysclk);
102
sysbus_realize_and_unref(sbd, &error_fatal);
103
sysbus_mmio_map(sbd, 0, base);
104
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
105
106
object_initialize_child(OBJECT(mms), "dualtimer", &mms->dualtimer,
107
TYPE_CMSDK_APB_DUALTIMER);
108
- qdev_prop_set_uint32(DEVICE(&mms->dualtimer), "pclk-frq", SYSCLK_FRQ);
109
qdev_connect_clock_in(DEVICE(&mms->dualtimer), "TIMCLK", mms->sysclk);
110
sysbus_realize(SYS_BUS_DEVICE(&mms->dualtimer), &error_fatal);
111
sysbus_connect_irq(SYS_BUS_DEVICE(&mms->dualtimer), 0,
112
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
113
sysbus_mmio_map(SYS_BUS_DEVICE(&mms->dualtimer), 0, 0x40002000);
114
object_initialize_child(OBJECT(mms), "watchdog", &mms->watchdog,
115
TYPE_CMSDK_APB_WATCHDOG);
116
- qdev_prop_set_uint32(DEVICE(&mms->watchdog), "wdogclk-frq", SYSCLK_FRQ);
117
qdev_connect_clock_in(DEVICE(&mms->watchdog), "WDOGCLK", mms->sysclk);
118
sysbus_realize(SYS_BUS_DEVICE(&mms->watchdog), &error_fatal);
119
sysbus_connect_irq(SYS_BUS_DEVICE(&mms->watchdog), 0,
120
diff --git a/hw/arm/musca.c b/hw/arm/musca.c
121
index XXXXXXX..XXXXXXX 100644
122
--- a/hw/arm/musca.c
123
+++ b/hw/arm/musca.c
124
@@ -XXX,XX +XXX,XX @@ static void musca_init(MachineState *machine)
125
qdev_prop_set_uint32(ssedev, "EXP_NUMIRQ", mmc->num_irqs);
126
qdev_prop_set_uint32(ssedev, "init-svtor", mmc->init_svtor);
127
qdev_prop_set_uint32(ssedev, "SRAM_ADDR_WIDTH", mmc->sram_addr_width);
128
- qdev_prop_set_uint32(ssedev, "MAINCLK_FRQ", SYSCLK_FRQ);
129
qdev_connect_clock_in(ssedev, "MAINCLK", mms->sysclk);
130
qdev_connect_clock_in(ssedev, "S32KCLK", mms->s32kclk);
131
/*
132
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
133
index XXXXXXX..XXXXXXX 100644
134
--- a/hw/arm/stellaris.c
135
+++ b/hw/arm/stellaris.c
136
@@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
137
if (board->dc1 & (1 << 3)) { /* watchdog present */
138
dev = qdev_new(TYPE_LUMINARY_WATCHDOG);
139
140
- /* system_clock_scale is valid now */
141
- uint32_t mainclk = NANOSECONDS_PER_SECOND / system_clock_scale;
142
- qdev_prop_set_uint32(dev, "wdogclk-frq", mainclk);
143
qdev_connect_clock_in(dev, "WDOGCLK",
144
qdev_get_clock_out(ssys_dev, "SYSCLK"));
145
23
--
146
--
24
2.16.2
147
2.20.1
25
148
26
149
diff view generated by jsdifflib
1
From: Corey Minyard <cminyard@mvista.com>
1
Now no users are setting the frq properties on the CMSDK timer,
2
dualtimer, watchdog or ARMSSE SoC devices, we can remove the
3
properties and the struct fields that back them.
2
4
3
Some devices need access to it.
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Luc Michel <luc@lmichel.fr>
8
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-id: 20210128114145.20536-25-peter.maydell@linaro.org
10
Message-id: 20210121190622.22000-25-peter.maydell@linaro.org
11
---
12
include/hw/arm/armsse.h | 2 --
13
include/hw/timer/cmsdk-apb-dualtimer.h | 2 --
14
include/hw/timer/cmsdk-apb-timer.h | 2 --
15
include/hw/watchdog/cmsdk-apb-watchdog.h | 2 --
16
hw/arm/armsse.c | 2 --
17
hw/timer/cmsdk-apb-dualtimer.c | 6 ------
18
hw/timer/cmsdk-apb-timer.c | 6 ------
19
hw/watchdog/cmsdk-apb-watchdog.c | 6 ------
20
8 files changed, 28 deletions(-)
4
21
5
Signed-off-by: Corey Minyard <cminyard@mvista.com>
22
diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
8
Message-id: 20180227104903.21353-3-linus.walleij@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
include/hw/i2c/i2c.h | 17 +++++++++++++++++
12
hw/i2c/core.c | 17 -----------------
13
2 files changed, 17 insertions(+), 17 deletions(-)
14
15
diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h
16
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/i2c/i2c.h
24
--- a/include/hw/arm/armsse.h
18
+++ b/include/hw/i2c/i2c.h
25
+++ b/include/hw/arm/armsse.h
19
@@ -XXX,XX +XXX,XX @@ struct I2CSlave {
26
@@ -XXX,XX +XXX,XX @@
20
uint8_t address;
27
* + Clock input "S32KCLK": slow 32KHz clock used for a few peripherals
28
* + QOM property "memory" is a MemoryRegion containing the devices provided
29
* by the board model.
30
- * + QOM property "MAINCLK_FRQ" is the frequency of the main system clock
31
* + QOM property "EXP_NUMIRQ" sets the number of expansion interrupts.
32
* (In hardware, the SSE-200 permits the number of expansion interrupts
33
* for the two CPUs to be configured separately, but we restrict it to
34
@@ -XXX,XX +XXX,XX @@ struct ARMSSE {
35
/* Properties */
36
MemoryRegion *board_memory;
37
uint32_t exp_numirq;
38
- uint32_t mainclk_frq;
39
uint32_t sram_addr_width;
40
uint32_t init_svtor;
41
bool cpu_fpu[SSE_MAX_CPUS];
42
diff --git a/include/hw/timer/cmsdk-apb-dualtimer.h b/include/hw/timer/cmsdk-apb-dualtimer.h
43
index XXXXXXX..XXXXXXX 100644
44
--- a/include/hw/timer/cmsdk-apb-dualtimer.h
45
+++ b/include/hw/timer/cmsdk-apb-dualtimer.h
46
@@ -XXX,XX +XXX,XX @@
47
* https://developer.arm.com/products/system-design/system-design-kits/cortex-m-system-design-kit
48
*
49
* QEMU interface:
50
- * + QOM property "pclk-frq": frequency at which the timer is clocked
51
* + Clock input "TIMCLK": clock (for both timers)
52
* + sysbus MMIO region 0: the register bank
53
* + sysbus IRQ 0: combined timer interrupt TIMINTC
54
@@ -XXX,XX +XXX,XX @@ struct CMSDKAPBDualTimer {
55
/*< public >*/
56
MemoryRegion iomem;
57
qemu_irq timerintc;
58
- uint32_t pclk_frq;
59
Clock *timclk;
60
61
CMSDKAPBDualTimerModule timermod[CMSDK_APB_DUALTIMER_NUM_MODULES];
62
diff --git a/include/hw/timer/cmsdk-apb-timer.h b/include/hw/timer/cmsdk-apb-timer.h
63
index XXXXXXX..XXXXXXX 100644
64
--- a/include/hw/timer/cmsdk-apb-timer.h
65
+++ b/include/hw/timer/cmsdk-apb-timer.h
66
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(CMSDKAPBTimer, CMSDK_APB_TIMER)
67
68
/*
69
* QEMU interface:
70
- * + QOM property "pclk-frq": frequency at which the timer is clocked
71
* + Clock input "pclk": clock for the timer
72
* + sysbus MMIO region 0: the register bank
73
* + sysbus IRQ 0: timer interrupt TIMERINT
74
@@ -XXX,XX +XXX,XX @@ struct CMSDKAPBTimer {
75
/*< public >*/
76
MemoryRegion iomem;
77
qemu_irq timerint;
78
- uint32_t pclk_frq;
79
struct ptimer_state *timer;
80
Clock *pclk;
81
82
diff --git a/include/hw/watchdog/cmsdk-apb-watchdog.h b/include/hw/watchdog/cmsdk-apb-watchdog.h
83
index XXXXXXX..XXXXXXX 100644
84
--- a/include/hw/watchdog/cmsdk-apb-watchdog.h
85
+++ b/include/hw/watchdog/cmsdk-apb-watchdog.h
86
@@ -XXX,XX +XXX,XX @@
87
* https://developer.arm.com/products/system-design/system-design-kits/cortex-m-system-design-kit
88
*
89
* QEMU interface:
90
- * + QOM property "wdogclk-frq": frequency at which the watchdog is clocked
91
* + Clock input "WDOGCLK": clock for the watchdog's timer
92
* + sysbus MMIO region 0: the register bank
93
* + sysbus IRQ 0: watchdog interrupt
94
@@ -XXX,XX +XXX,XX @@ struct CMSDKAPBWatchdog {
95
/*< public >*/
96
MemoryRegion iomem;
97
qemu_irq wdogint;
98
- uint32_t wdogclk_frq;
99
bool is_luminary;
100
struct ptimer_state *timer;
101
Clock *wdogclk;
102
diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c
103
index XXXXXXX..XXXXXXX 100644
104
--- a/hw/arm/armsse.c
105
+++ b/hw/arm/armsse.c
106
@@ -XXX,XX +XXX,XX @@ static Property iotkit_properties[] = {
107
DEFINE_PROP_LINK("memory", ARMSSE, board_memory, TYPE_MEMORY_REGION,
108
MemoryRegion *),
109
DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64),
110
- DEFINE_PROP_UINT32("MAINCLK_FRQ", ARMSSE, mainclk_frq, 0),
111
DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 15),
112
DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000),
113
DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], true),
114
@@ -XXX,XX +XXX,XX @@ static Property armsse_properties[] = {
115
DEFINE_PROP_LINK("memory", ARMSSE, board_memory, TYPE_MEMORY_REGION,
116
MemoryRegion *),
117
DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64),
118
- DEFINE_PROP_UINT32("MAINCLK_FRQ", ARMSSE, mainclk_frq, 0),
119
DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 15),
120
DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000),
121
DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], false),
122
diff --git a/hw/timer/cmsdk-apb-dualtimer.c b/hw/timer/cmsdk-apb-dualtimer.c
123
index XXXXXXX..XXXXXXX 100644
124
--- a/hw/timer/cmsdk-apb-dualtimer.c
125
+++ b/hw/timer/cmsdk-apb-dualtimer.c
126
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription cmsdk_apb_dualtimer_vmstate = {
127
}
21
};
128
};
22
129
23
+#define TYPE_I2C_BUS "i2c-bus"
130
-static Property cmsdk_apb_dualtimer_properties[] = {
24
+#define I2C_BUS(obj) OBJECT_CHECK(I2CBus, (obj), TYPE_I2C_BUS)
131
- DEFINE_PROP_UINT32("pclk-frq", CMSDKAPBDualTimer, pclk_frq, 0),
25
+
132
- DEFINE_PROP_END_OF_LIST(),
26
+typedef struct I2CNode I2CNode;
27
+
28
+struct I2CNode {
29
+ I2CSlave *elt;
30
+ QLIST_ENTRY(I2CNode) next;
31
+};
32
+
33
+struct I2CBus {
34
+ BusState qbus;
35
+ QLIST_HEAD(, I2CNode) current_devs;
36
+ uint8_t saved_address;
37
+ bool broadcast;
38
+};
39
+
40
I2CBus *i2c_init_bus(DeviceState *parent, const char *name);
41
void i2c_set_slave_address(I2CSlave *dev, uint8_t address);
42
int i2c_bus_busy(I2CBus *bus);
43
diff --git a/hw/i2c/core.c b/hw/i2c/core.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/hw/i2c/core.c
46
+++ b/hw/i2c/core.c
47
@@ -XXX,XX +XXX,XX @@
48
#include "qemu/osdep.h"
49
#include "hw/i2c/i2c.h"
50
51
-typedef struct I2CNode I2CNode;
52
-
53
-struct I2CNode {
54
- I2CSlave *elt;
55
- QLIST_ENTRY(I2CNode) next;
56
-};
133
-};
57
-
134
-
58
#define I2C_BROADCAST 0x00
135
static void cmsdk_apb_dualtimer_class_init(ObjectClass *klass, void *data)
59
136
{
60
-struct I2CBus {
137
DeviceClass *dc = DEVICE_CLASS(klass);
61
- BusState qbus;
138
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_dualtimer_class_init(ObjectClass *klass, void *data)
62
- QLIST_HEAD(, I2CNode) current_devs;
139
dc->realize = cmsdk_apb_dualtimer_realize;
63
- uint8_t saved_address;
140
dc->vmsd = &cmsdk_apb_dualtimer_vmstate;
64
- bool broadcast;
141
dc->reset = cmsdk_apb_dualtimer_reset;
142
- device_class_set_props(dc, cmsdk_apb_dualtimer_properties);
143
}
144
145
static const TypeInfo cmsdk_apb_dualtimer_info = {
146
diff --git a/hw/timer/cmsdk-apb-timer.c b/hw/timer/cmsdk-apb-timer.c
147
index XXXXXXX..XXXXXXX 100644
148
--- a/hw/timer/cmsdk-apb-timer.c
149
+++ b/hw/timer/cmsdk-apb-timer.c
150
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription cmsdk_apb_timer_vmstate = {
151
}
152
};
153
154
-static Property cmsdk_apb_timer_properties[] = {
155
- DEFINE_PROP_UINT32("pclk-frq", CMSDKAPBTimer, pclk_frq, 0),
156
- DEFINE_PROP_END_OF_LIST(),
65
-};
157
-};
66
-
158
-
67
static Property i2c_props[] = {
159
static void cmsdk_apb_timer_class_init(ObjectClass *klass, void *data)
68
DEFINE_PROP_UINT8("address", struct I2CSlave, address, 0),
160
{
69
DEFINE_PROP_END_OF_LIST(),
161
DeviceClass *dc = DEVICE_CLASS(klass);
162
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_class_init(ObjectClass *klass, void *data)
163
dc->realize = cmsdk_apb_timer_realize;
164
dc->vmsd = &cmsdk_apb_timer_vmstate;
165
dc->reset = cmsdk_apb_timer_reset;
166
- device_class_set_props(dc, cmsdk_apb_timer_properties);
167
}
168
169
static const TypeInfo cmsdk_apb_timer_info = {
170
diff --git a/hw/watchdog/cmsdk-apb-watchdog.c b/hw/watchdog/cmsdk-apb-watchdog.c
171
index XXXXXXX..XXXXXXX 100644
172
--- a/hw/watchdog/cmsdk-apb-watchdog.c
173
+++ b/hw/watchdog/cmsdk-apb-watchdog.c
174
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription cmsdk_apb_watchdog_vmstate = {
175
}
70
};
176
};
71
177
72
-#define TYPE_I2C_BUS "i2c-bus"
178
-static Property cmsdk_apb_watchdog_properties[] = {
73
-#define I2C_BUS(obj) OBJECT_CHECK(I2CBus, (obj), TYPE_I2C_BUS)
179
- DEFINE_PROP_UINT32("wdogclk-frq", CMSDKAPBWatchdog, wdogclk_frq, 0),
180
- DEFINE_PROP_END_OF_LIST(),
181
-};
74
-
182
-
75
static const TypeInfo i2c_bus_info = {
183
static void cmsdk_apb_watchdog_class_init(ObjectClass *klass, void *data)
76
.name = TYPE_I2C_BUS,
184
{
77
.parent = TYPE_BUS,
185
DeviceClass *dc = DEVICE_CLASS(klass);
186
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_class_init(ObjectClass *klass, void *data)
187
dc->realize = cmsdk_apb_watchdog_realize;
188
dc->vmsd = &cmsdk_apb_watchdog_vmstate;
189
dc->reset = cmsdk_apb_watchdog_reset;
190
- device_class_set_props(dc, cmsdk_apb_watchdog_properties);
191
}
192
193
static const TypeInfo cmsdk_apb_watchdog_info = {
78
--
194
--
79
2.16.2
195
2.20.1
80
196
81
197
diff view generated by jsdifflib
1
From: Francisco Iglesias <frasse.iglesias@gmail.com>
1
Now that the watchdog device uses its Clock input rather than being
2
passed the value of system_clock_scale at creation time, we can
3
remove the hack where we reset the STELLARIS_SYS at board creation
4
time to force it to set system_clock_scale. Instead it will be reset
5
at the usual point in startup and will inform the watchdog of the
6
clock frequency at that point.
2
7
3
Assert only the lower cs on bus 0 and upper cs on bus 1 when both buses and
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
chip selects are enabled (e.g reading/writing with stripe).
9
Reviewed-by: Luc Michel <luc@lmichel.fr>
10
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
12
Message-id: 20210128114145.20536-26-peter.maydell@linaro.org
13
Message-id: 20210121190622.22000-26-peter.maydell@linaro.org
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
---
16
hw/arm/stellaris.c | 10 ----------
17
1 file changed, 10 deletions(-)
5
18
6
Signed-off-by: Francisco Iglesias <frasse.iglesias@gmail.com>
19
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
7
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
8
Tested-by: Alistair Francis <alistair.francis@xilinx.com>
9
Message-id: 20180223232233.31482-2-frasse.iglesias@gmail.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
hw/ssi/xilinx_spips.c | 41 +++++++++++++++++++++++++++++++++++++----
13
1 file changed, 37 insertions(+), 4 deletions(-)
14
15
diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c
16
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/ssi/xilinx_spips.c
21
--- a/hw/arm/stellaris.c
18
+++ b/hw/ssi/xilinx_spips.c
22
+++ b/hw/arm/stellaris.c
19
@@ -XXX,XX +XXX,XX @@ static void xilinx_spips_update_cs(XilinxSPIPS *s, int field)
23
@@ -XXX,XX +XXX,XX @@ static DeviceState *stellaris_sys_init(uint32_t base, qemu_irq irq,
20
{
24
sysbus_mmio_map(sbd, 0, base);
21
int i;
25
sysbus_connect_irq(sbd, 0, irq);
22
26
23
- for (i = 0; i < s->num_cs; i++) {
27
- /*
24
+ for (i = 0; i < s->num_cs * s->num_busses; i++) {
28
- * Normally we should not be resetting devices like this during
25
bool old_state = s->cs_lines_state[i];
29
- * board creation. For the moment we need to do so, because
26
bool new_state = field & (1 << i);
30
- * system_clock_scale will only get set when the STELLARIS_SYS
27
31
- * device is reset, and we need its initial value to pass to
28
@@ -XXX,XX +XXX,XX @@ static void xilinx_spips_update_cs(XilinxSPIPS *s, int field)
32
- * the watchdog device. This hack can be removed once the
29
}
33
- * watchdog has been converted to use a Clock input instead.
30
qemu_set_irq(s->cs_lines[i], !new_state);
34
- */
31
}
35
- device_cold_reset(dev);
32
- if (!(field & ((1 << s->num_cs) - 1))) {
36
-
33
+ if (!(field & ((1 << (s->num_cs * s->num_busses)) - 1))) {
37
return dev;
34
s->snoop_state = SNOOP_CHECKING;
35
s->cmd_dummies = 0;
36
s->link_state = 1;
37
@@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_qspips_update_cs_lines(XlnxZynqMPQSPIPS *s)
38
{
39
if (s->regs[R_GQSPI_GF_SNAPSHOT]) {
40
int field = ARRAY_FIELD_EX32(s->regs, GQSPI_GF_SNAPSHOT, CHIP_SELECT);
41
- xilinx_spips_update_cs(XILINX_SPIPS(s), field);
42
+ bool upper_cs_sel = field & (1 << 1);
43
+ bool lower_cs_sel = field & 1;
44
+ bool bus0_enabled;
45
+ bool bus1_enabled;
46
+ uint8_t buses;
47
+ int cs = 0;
48
+
49
+ buses = ARRAY_FIELD_EX32(s->regs, GQSPI_GF_SNAPSHOT, DATA_BUS_SELECT);
50
+ bus0_enabled = buses & 1;
51
+ bus1_enabled = buses & (1 << 1);
52
+
53
+ if (bus0_enabled && bus1_enabled) {
54
+ if (lower_cs_sel) {
55
+ cs |= 1;
56
+ }
57
+ if (upper_cs_sel) {
58
+ cs |= 1 << 3;
59
+ }
60
+ } else if (bus0_enabled) {
61
+ if (lower_cs_sel) {
62
+ cs |= 1;
63
+ }
64
+ if (upper_cs_sel) {
65
+ cs |= 1 << 1;
66
+ }
67
+ } else if (bus1_enabled) {
68
+ if (lower_cs_sel) {
69
+ cs |= 1 << 2;
70
+ }
71
+ if (upper_cs_sel) {
72
+ cs |= 1 << 3;
73
+ }
74
+ }
75
+ xilinx_spips_update_cs(XILINX_SPIPS(s), cs);
76
}
77
}
38
}
78
39
79
@@ -XXX,XX +XXX,XX @@ static void xilinx_spips_update_cs_lines(XilinxSPIPS *s)
80
if (num_effective_busses(s) == 2) {
81
/* Single bit chip-select for qspi */
82
field &= 0x1;
83
- field |= field << 1;
84
+ field |= field << 3;
85
/* Dual stack U-Page */
86
} else if (s->regs[R_LQSPI_CFG] & LQSPI_CFG_TWO_MEM &&
87
s->regs[R_LQSPI_STS] & LQSPI_CFG_U_PAGE) {
88
--
40
--
89
2.16.2
41
2.20.1
90
42
91
43
diff view generated by jsdifflib