1
target-arm queue: this clears out a bunch of patches I'd sent over
1
Nothing earth-shaking in here, just a lot of refactoring and cleanup
2
the last coupled of weeks that have now got reviewed. Mostly
2
and a few bugfixes. I suspect I'll have another pullreq to come in
3
this is MPS2 device support improvements, put there is also
3
the early part of next week...
4
more of the incremental work towards supporting AArch32 Hyp mode,
5
a floating point bugfix, and the raspi framebuffer viewport support.
6
4
7
thanks
5
The following changes since commit 19591e9e0938ea5066984553c256a043bd5d822f:
8
-- PMM
9
6
10
The following changes since commit 5ccac548faf041ff5229a8e8342e3be14a34c8af:
7
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2020-08-27 16:59:02 +0100)
11
12
Merge remote-tracking branch 'remotes/cody/tags/block-pull-request' into staging (2018-08-23 17:35:48 +0100)
13
8
14
are available in the Git repository at:
9
are available in the Git repository at:
15
10
16
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180824
11
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200828
17
12
18
for you to fetch changes up to 30a719e3cb5c5367f3651eba8fa935634bfee286:
13
for you to fetch changes up to ed78849d9711805bda37ee026018d6ee7a606d0e:
19
14
20
hw/arm/mps2: Fix ID register errors on AN511 and AN385 (2018-08-24 10:22:44 +0100)
15
target/arm: Convert sq{, r}dmulh to gvec for aa64 advsimd (2020-08-28 10:02:50 +0100)
21
16
22
----------------------------------------------------------------
17
----------------------------------------------------------------
23
target-arm queue:
18
target-arm queue:
24
* Fix rounding errors in scaling float-to-int and int-to-float operations
19
* target/arm: Cleanup and refactoring preparatory to SVE2
25
* Connect virtualization-related IRQs and memory regions of GICv2
20
* armsse: Define ARMSSEClass correctly
26
in boards that use Cortex-A7 or Cortex-A15
21
* hw/misc/unimp: Improve information provided in log messages
27
* Support taking exceptions to AArch32 Hyp mode
22
* hw/qdev-clock: Avoid calling qdev_connect_clock_in after DeviceRealize
28
* Clear CPSR.IL and CPSR.J on 32-bit exception entry
23
* hw/arm/xilinx_zynq: Call qdev_connect_clock_in() before DeviceRealize
29
(a minor bug fix that won't affect non-buggy guest code)
24
* hw/net/allwinner-sun8i-emac: Use AddressSpace for DMA transfers
30
* mps2-an505: Implement various missing devices:
25
* hw/sd/allwinner-sdhost: Use AddressSpace for DMA transfers
31
dual timer, watchdogs, counters in the FPGAIO registers,
26
* target/arm: Fill in the WnR syndrome bit in mte_check_fail
32
some missing ID/control registers, TrustZone Master Security
27
* target/arm: Clarify HCR_EL2 ARMCPRegInfo type
33
Controllers, PL081 DMA controllers, PL022 SPI controllers
28
* hw/arm/musicpal: Use AddressSpace for DMA transfers
34
* correct ID register values for mps2-an385, -an511, -an505
29
* hw/clock: Minor cleanups
35
* fix some hardcoded tabs in untouched backwaters of the
30
* hw/arm/sbsa-ref: fix typo breaking PCIe IRQs
36
target/arm codebase
37
* raspi: Refactor framebuffer property handling code and implement
38
support for the virtual framebuffer/viewport
39
31
40
----------------------------------------------------------------
32
----------------------------------------------------------------
41
Peter Maydell (48):
33
Eduardo Habkost (1):
42
hw/intc/arm_gic: Make per-cpu GICH memory regions 0x200 bytes large
34
armsse: Define ARMSSEClass correctly
43
hw/arm/vexpress: Connect VIRQ and VFIQ
44
hw/arm/highbank: Connect VIRQ and VFIQ
45
hw/arm/fsl-imx6ul: Connect VIRQ and VFIQ
46
hw/arm/fsl-imx6ul: Connect VIRQ and VFIQ
47
hw/cpu/a15mpcore: If CPU has EL2, enable it on the GIC and wire it up
48
hw/arm/vexpress: Don't set info->secure_boot if CPU doesn't have EL3
49
hw/arm/vexpress: Add "virtualization" property controlling presence of EL2
50
target/arm: Implement RAZ/WI HACTLR2
51
target/arm: Implement AArch32 HCR and HCR2
52
target/arm: Factor out code for taking an AArch32 exception
53
target/arm: Implement support for taking exceptions to Hyp mode
54
target/arm: Clear CPSR.IL and CPSR.J on 32-bit exception entry
55
hw/arm/boot: AArch32 kernels should be started in Hyp mode if available
56
hw/misc/mps2-fpgaio: Implement 1Hz and 100Hz counters
57
hw/misc/mps2-fpgaio: Implement PSCNTR and COUNTER
58
hw/timer/cmsdk-apb-dualtimer: Implement CMSDK dual timer module
59
hw/arm/iotkit: Wire up the dualtimer
60
hw/arm/mps2: Wire up dual-timer in mps2-an385 and mps2-an511
61
hw/arm/iotkit: Wire up the watchdogs
62
hw/arm/iotkit: Wire up the S32KTIMER
63
hw/misc/iotkit-sysctl: Implement IoTKit system control element
64
hw/misc/iotkit-sysinfo: Implement IoTKit system information block
65
hw/misc/iotkit: Wire up the sysctl and sysinfo register blocks
66
hw/misc/tz-msc: Model TrustZone Master Security Controller
67
hw/misc/iotkit-secctl: Wire up registers for controlling MSCs
68
hw/arm/iotkit: Wire up the lines for MSCs
69
hw/arm/mps2-tz: Create PL081s and MSCs
70
hw/ssi/pl022: Allow use as embedded-struct device
71
hw/ssi/pl022: Set up reset function in class init
72
hw/ssi/pl022: Don't directly call vmstate_register()
73
hw/ssi/pl022: Use DeviceState::realize rather than SysBusDevice::init
74
hw/ssi/pl022: Correct wrong value for PL022_INT_RT
75
hw/ssi/pl022: Correct wrong DMACR and ICR handling
76
hw/arm/mps2-tz: Instantiate SPI controllers
77
hw/arm/mps2-tz: Fix MPS2 SCC config register values
78
target/arm: Untabify translate.c
79
target/arm: Untabify iwmmxt_helper.c
80
target/arm: Remove a handful of stray tabs
81
hw/misc/bcm2835_fb: Move config fields to their own struct
82
hw/misc/bcm2835_property: Track fb settings using BCM2835FBConfig
83
hw/display/bcm2835_fb: Drop unused size and pitch fields
84
hw/display/bcm2835_fb: Reset resolution, etc correctly
85
hw/display/bcm2835_fb: Abstract out calculation of pitch, size
86
hw/display/bcm2835_fb: Fix handling of virtual framebuffer
87
hw/display/bcm2835_fb: Validate config settings
88
hw/display/bcm2835_fb: Validate bcm2835_fb_mbox_push() config
89
hw/arm/mps2: Fix ID register errors on AN511 and AN385
90
35
91
Richard Henderson (4):
36
Graeme Gregory (1):
92
softfloat: Add scaling int-to-float routines
37
hw/arm/sbsa-ref: fix typo breaking PCIe IRQs
93
softfloat: Add scaling float-to-int routines
94
target/arm: Use the int-to-float-scale softfloat routines
95
target/arm: Use the float-to-int-scale softfloat routines
96
38
97
hw/misc/Makefile.objs | 3 +
39
Philippe Mathieu-Daudé (14):
98
hw/timer/Makefile.objs | 1 +
40
hw/clock: Remove unused clock_init*() functions
99
include/fpu/softfloat.h | 169 +++++++---
41
hw/clock: Let clock_set() return boolean value
100
include/hw/arm/iotkit.h | 25 +-
42
hw/clock: Only propagate clock changes if the clock is changed
101
include/hw/display/bcm2835_fb.h | 59 +++-
43
hw/arm/musicpal: Use AddressSpace for DMA transfers
102
include/hw/misc/iotkit-secctl.h | 14 +
44
target/arm: Clarify HCR_EL2 ARMCPRegInfo type
103
include/hw/misc/iotkit-sysctl.h | 49 +++
45
hw/sd/allwinner-sdhost: Use AddressSpace for DMA transfers
104
include/hw/misc/iotkit-sysinfo.h | 37 +++
46
hw/net/allwinner-sun8i-emac: Use AddressSpace for DMA transfers
105
include/hw/misc/mps2-fpgaio.h | 10 +
47
hw/arm/xilinx_zynq: Uninline cadence_uart_create()
106
include/hw/misc/tz-msc.h | 79 +++++
48
hw/arm/xilinx_zynq: Call qdev_connect_clock_in() before DeviceRealize
107
include/hw/ssi/pl022.h | 51 +++
49
hw/qdev-clock: Uninline qdev_connect_clock_in()
108
include/hw/timer/cmsdk-apb-dualtimer.h | 72 ++++
50
hw/qdev-clock: Avoid calling qdev_connect_clock_in after DeviceRealize
109
target/arm/cpu.h | 16 +-
51
hw/misc/unimp: Display value after offset
110
fpu/softfloat.c | 579 ++++++++++++++++++++++++++-------
52
hw/misc/unimp: Display the value with width of the access size
111
hw/arm/boot.c | 11 +
53
hw/misc/unimp: Display the offset with width of the region size
112
hw/arm/fsl-imx6ul.c | 4 +
113
hw/arm/fsl-imx7.c | 4 +
114
hw/arm/highbank.c | 6 +
115
hw/arm/iotkit.c | 114 ++++++-
116
hw/arm/mps2-tz.c | 142 +++++++-
117
hw/arm/mps2.c | 17 +-
118
hw/arm/vexpress.c | 64 +++-
119
hw/cpu/a15mpcore.c | 31 +-
120
hw/display/bcm2835_fb.c | 218 ++++++++-----
121
hw/intc/arm_gic.c | 2 +-
122
hw/misc/bcm2835_property.c | 123 ++++---
123
hw/misc/iotkit-secctl.c | 73 ++++-
124
hw/misc/iotkit-sysctl.c | 261 +++++++++++++++
125
hw/misc/iotkit-sysinfo.c | 128 ++++++++
126
hw/misc/mps2-fpgaio.c | 146 ++++++++-
127
hw/misc/tz-msc.c | 308 ++++++++++++++++++
128
hw/ssi/pl022.c | 57 ++--
129
hw/timer/cmsdk-apb-dualtimer.c | 515 +++++++++++++++++++++++++++++
130
target/arm/arm-semi.c | 2 +-
131
target/arm/helper.c | 342 +++++++++++++------
132
target/arm/iwmmxt_helper.c | 234 ++++++-------
133
target/arm/translate.c | 122 +++----
134
MAINTAINERS | 10 +
135
default-configs/arm-softmmu.mak | 4 +
136
hw/misc/trace-events | 16 +
137
hw/timer/trace-events | 5 +
138
41 files changed, 3405 insertions(+), 718 deletions(-)
139
create mode 100644 include/hw/misc/iotkit-sysctl.h
140
create mode 100644 include/hw/misc/iotkit-sysinfo.h
141
create mode 100644 include/hw/misc/tz-msc.h
142
create mode 100644 include/hw/ssi/pl022.h
143
create mode 100644 include/hw/timer/cmsdk-apb-dualtimer.h
144
create mode 100644 hw/misc/iotkit-sysctl.c
145
create mode 100644 hw/misc/iotkit-sysinfo.c
146
create mode 100644 hw/misc/tz-msc.c
147
create mode 100644 hw/timer/cmsdk-apb-dualtimer.c
148
54
55
Richard Henderson (19):
56
target/arm: Pass the entire mte descriptor to mte_check_fail
57
target/arm: Fill in the WnR syndrome bit in mte_check_fail
58
qemu/int128: Add int128_lshift
59
target/arm: Split out gen_gvec_fn_zz
60
target/arm: Split out gen_gvec_fn_zzz, do_zzz_fn
61
target/arm: Rearrange {sve,fp}_check_access assert
62
target/arm: Merge do_vector2_p into do_mov_p
63
target/arm: Clean up 4-operand predicate expansion
64
target/arm: Use tcg_gen_gvec_bitsel for trans_SEL_pppp
65
target/arm: Split out gen_gvec_ool_zzzp
66
target/arm: Merge helper_sve_clr_* and helper_sve_movz_*
67
target/arm: Split out gen_gvec_ool_zzp
68
target/arm: Split out gen_gvec_ool_zzz
69
target/arm: Split out gen_gvec_ool_zz
70
target/arm: Tidy SVE tszimm shift formats
71
target/arm: Generalize inl_qrdmlah_* helper functions
72
target/arm: Convert integer multiply (indexed) to gvec for aa64 advsimd
73
target/arm: Convert integer multiply-add (indexed) to gvec for aa64 advsimd
74
target/arm: Convert sq{, r}dmulh to gvec for aa64 advsimd
75
76
include/hw/arm/armsse.h | 2 +-
77
include/hw/char/cadence_uart.h | 17 --
78
include/hw/clock.h | 30 +--
79
include/hw/misc/unimp.h | 1 +
80
include/hw/net/allwinner-sun8i-emac.h | 6 +
81
include/hw/qdev-clock.h | 8 +-
82
include/hw/sd/allwinner-sdhost.h | 6 +
83
include/qemu/int128.h | 16 ++
84
target/arm/helper-sve.h | 5 -
85
target/arm/helper.h | 28 +++
86
target/arm/translate.h | 1 +
87
target/arm/sve.decode | 35 ++-
88
hw/arm/allwinner-a10.c | 2 +
89
hw/arm/allwinner-h3.c | 4 +
90
hw/arm/armsse.c | 1 +
91
hw/arm/musicpal.c | 45 ++--
92
hw/arm/sbsa-ref.c | 2 +-
93
hw/arm/xilinx_zynq.c | 24 +-
94
hw/core/clock.c | 7 +-
95
hw/core/qdev-clock.c | 6 +
96
hw/misc/unimp.c | 14 +-
97
hw/net/allwinner-sun8i-emac.c | 46 ++--
98
hw/sd/allwinner-sdhost.c | 37 +++-
99
target/arm/helper.c | 1 -
100
target/arm/mte_helper.c | 19 +-
101
target/arm/sve_helper.c | 70 ++----
102
target/arm/translate-a64.c | 110 ++++++++--
103
target/arm/translate-sve.c | 399 ++++++++++++++--------------------
104
target/arm/vec_helper.c | 182 +++++++++++-----
105
29 files changed, 629 insertions(+), 495 deletions(-)
106
diff view generated by jsdifflib
1
The PL022 interrupt registers have bits allocated as:
1
From: Graeme Gregory <graeme@nuviainc.com>
2
0: ROR (receive overrun)
3
1: RT (receive timeout)
4
2: RX (receive FIFO half full or less)
5
3: TX (transmit FIFO half full or less)
6
2
7
A cut and paste error meant we had the wrong value for
3
Fixing a typo in a previous patch that translated an "i" to a 1
8
the PL022_INT_RT constant. This bug doesn't affect device
4
and therefore breaking the allocation of PCIe interrupts. This was
9
behaviour, because we don't implement the receive timeout
5
discovered when virtio-net-pci devices ceased to function correctly.
10
feature and so never set that interrupt bit.
11
6
7
Cc: qemu-stable@nongnu.org
8
Fixes: 48ba18e6d3f3 ("hw/arm/sbsa-ref: Simplify by moving the gic in the machine state")
9
Signed-off-by: Graeme Gregory <graeme@nuviainc.com>
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Message-id: 20200821083853.356490-1-graeme@nuviainc.com
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Message-id: 20180820141116.9118-20-peter.maydell@linaro.org
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
---
13
---
16
hw/ssi/pl022.c | 2 +-
14
hw/arm/sbsa-ref.c | 2 +-
17
1 file changed, 1 insertion(+), 1 deletion(-)
15
1 file changed, 1 insertion(+), 1 deletion(-)
18
16
19
diff --git a/hw/ssi/pl022.c b/hw/ssi/pl022.c
17
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
20
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/ssi/pl022.c
19
--- a/hw/arm/sbsa-ref.c
22
+++ b/hw/ssi/pl022.c
20
+++ b/hw/arm/sbsa-ref.c
23
@@ -XXX,XX +XXX,XX @@ do { fprintf(stderr, "pl022: error: " fmt , ## __VA_ARGS__);} while (0)
21
@@ -XXX,XX +XXX,XX @@ static void create_pcie(SBSAMachineState *sms)
24
#define PL022_SR_BSY 0x10
22
25
23
for (i = 0; i < GPEX_NUM_IRQS; i++) {
26
#define PL022_INT_ROR 0x01
24
sysbus_connect_irq(SYS_BUS_DEVICE(dev), i,
27
-#define PL022_INT_RT 0x04
25
- qdev_get_gpio_in(sms->gic, irq + 1));
28
+#define PL022_INT_RT 0x02
26
+ qdev_get_gpio_in(sms->gic, irq + i));
29
#define PL022_INT_RX 0x04
27
gpex_set_irq_num(GPEX_HOST(dev), i, irq + i);
30
#define PL022_INT_TX 0x08
28
}
31
29
32
--
30
--
33
2.18.0
31
2.20.1
34
32
35
33
diff view generated by jsdifflib
1
Fix MPS2 SCC config register values for the mps2-an511
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
and mps2-an385 boards:
3
* the SCC_AID bits [23:20] specify the FPGA build target board revision,
4
and the SCC_CFG4 register specifies the actual board revision, so
5
these should have matching values. Claim to be board revision C,
6
consistently -- we had the revision in the wrong part of SCC_AID.
7
* SCC_ID bits [15:4] should be the board number in hex, not decimal
8
2
3
clock_init*() inlined funtions are simple wrappers around
4
clock_set*() and are not used. Remove them in favor of clock_set*().
5
6
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20200806123858.30058-2-f4bug@amsat.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20180823175225.22612-1-peter.maydell@linaro.org
12
---
10
---
13
hw/arm/mps2.c | 6 +++---
11
include/hw/clock.h | 13 -------------
14
1 file changed, 3 insertions(+), 3 deletions(-)
12
1 file changed, 13 deletions(-)
15
13
16
diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
14
diff --git a/include/hw/clock.h b/include/hw/clock.h
17
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/arm/mps2.c
16
--- a/include/hw/clock.h
19
+++ b/hw/arm/mps2.c
17
+++ b/include/hw/clock.h
20
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
18
@@ -XXX,XX +XXX,XX @@ static inline bool clock_is_enabled(const Clock *clk)
21
sccdev = DEVICE(&mms->scc);
19
return clock_get(clk) != 0;
22
qdev_set_parent_bus(sccdev, sysbus_get_default());
23
qdev_prop_set_uint32(sccdev, "scc-cfg4", 0x2);
24
- qdev_prop_set_uint32(sccdev, "scc-aid", 0x02000008);
25
+ qdev_prop_set_uint32(sccdev, "scc-aid", 0x00200008);
26
qdev_prop_set_uint32(sccdev, "scc-id", mmc->scc_id);
27
object_property_set_bool(OBJECT(&mms->scc), true, "realized",
28
&error_fatal);
29
@@ -XXX,XX +XXX,XX @@ static void mps2_an385_class_init(ObjectClass *oc, void *data)
30
mc->desc = "ARM MPS2 with AN385 FPGA image for Cortex-M3";
31
mmc->fpga_type = FPGA_AN385;
32
mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m3");
33
- mmc->scc_id = 0x41040000 | (385 << 4);
34
+ mmc->scc_id = 0x41043850;
35
}
20
}
36
21
37
static void mps2_an511_class_init(ObjectClass *oc, void *data)
22
-static inline void clock_init(Clock *clk, uint64_t value)
38
@@ -XXX,XX +XXX,XX @@ static void mps2_an511_class_init(ObjectClass *oc, void *data)
23
-{
39
mc->desc = "ARM MPS2 with AN511 DesignStart FPGA image for Cortex-M3";
24
- clock_set(clk, value);
40
mmc->fpga_type = FPGA_AN511;
25
-}
41
mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m3");
26
-static inline void clock_init_hz(Clock *clk, uint64_t value)
42
- mmc->scc_id = 0x4104000 | (511 << 4);
27
-{
43
+ mmc->scc_id = 0x41045110;
28
- clock_set_hz(clk, value);
44
}
29
-}
45
30
-static inline void clock_init_ns(Clock *clk, uint64_t value)
46
static const TypeInfo mps2_info = {
31
-{
32
- clock_set_ns(clk, value);
33
-}
34
-
35
#endif /* QEMU_HW_CLOCK_H */
47
--
36
--
48
2.18.0
37
2.20.1
49
38
50
39
diff view generated by jsdifflib
1
Validate the config settings that the guest tries to set.
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
The wiki page documentation is not really accurate here:
3
Let clock_set() return a boolean value whether the clock
4
generally rather than failing requests to set bad parameters,
4
has been updated or not.
5
the hardware will just clip them to something sensible.
6
5
7
Validate the most important parameters: sizes and
6
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
the viewport offsets. This prevents the framebuffer
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
code from trying to read out-of-range memory.
8
Message-id: 20200806123858.30058-3-f4bug@amsat.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
include/hw/clock.h | 12 +++++++-----
12
hw/core/clock.c | 7 ++++++-
13
2 files changed, 13 insertions(+), 6 deletions(-)
10
14
11
In the property handling code, we validate the new parameters every
15
diff --git a/include/hw/clock.h b/include/hw/clock.h
12
time we encounter a tag that sets them. This means we validate the
13
config multiple times if the request includes multiple config-setting
14
tags, but the code would require significant restructuring to do a
15
validation only once but still return the clipped settings for
16
get-parameter tags and the buffer allocation tag.
17
18
Validation of settings made via the older bcm2835_fb_mbox_push()
19
function will be done in the next commit.
20
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
23
Message-id: 20180814144436.679-8-peter.maydell@linaro.org
24
---
25
include/hw/display/bcm2835_fb.h | 8 +++++
26
hw/display/bcm2835_fb.c | 48 +++++++++++++++++++++++++++--
27
hw/misc/bcm2835_property.c | 54 ++++++++++++++++-----------------
28
3 files changed, 81 insertions(+), 29 deletions(-)
29
30
diff --git a/include/hw/display/bcm2835_fb.h b/include/hw/display/bcm2835_fb.h
31
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
32
--- a/include/hw/display/bcm2835_fb.h
17
--- a/include/hw/clock.h
33
+++ b/include/hw/display/bcm2835_fb.h
18
+++ b/include/hw/clock.h
34
@@ -XXX,XX +XXX,XX @@ static inline uint32_t bcm2835_fb_get_size(BCM2835FBConfig *config)
19
@@ -XXX,XX +XXX,XX @@ void clock_set_source(Clock *clk, Clock *src);
35
return yres * bcm2835_fb_get_pitch(config);
20
* @value: the clock's value, 0 means unclocked
21
*
22
* Set the local cached period value of @clk to @value.
23
+ *
24
+ * @return: true if the clock is changed.
25
*/
26
-void clock_set(Clock *clk, uint64_t value);
27
+bool clock_set(Clock *clk, uint64_t value);
28
29
-static inline void clock_set_hz(Clock *clk, unsigned hz)
30
+static inline bool clock_set_hz(Clock *clk, unsigned hz)
31
{
32
- clock_set(clk, CLOCK_PERIOD_FROM_HZ(hz));
33
+ return clock_set(clk, CLOCK_PERIOD_FROM_HZ(hz));
36
}
34
}
37
35
38
+/**
36
-static inline void clock_set_ns(Clock *clk, unsigned ns)
39
+ * bcm2835_fb_validate_config: check provided config
37
+static inline bool clock_set_ns(Clock *clk, unsigned ns)
40
+ *
38
{
41
+ * Validates the configuration information provided by the guest and
39
- clock_set(clk, CLOCK_PERIOD_FROM_NS(ns));
42
+ * adjusts it if necessary.
40
+ return clock_set(clk, CLOCK_PERIOD_FROM_NS(ns));
43
+ */
41
}
44
+void bcm2835_fb_validate_config(BCM2835FBConfig *config);
42
43
/**
44
diff --git a/hw/core/clock.c b/hw/core/clock.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/hw/core/clock.c
47
+++ b/hw/core/clock.c
48
@@ -XXX,XX +XXX,XX @@ void clock_clear_callback(Clock *clk)
49
clock_set_callback(clk, NULL, NULL);
50
}
51
52
-void clock_set(Clock *clk, uint64_t period)
53
+bool clock_set(Clock *clk, uint64_t period)
54
{
55
+ if (clk->period == period) {
56
+ return false;
57
+ }
58
trace_clock_set(CLOCK_PATH(clk), CLOCK_PERIOD_TO_NS(clk->period),
59
CLOCK_PERIOD_TO_NS(period));
60
clk->period = period;
45
+
61
+
46
#endif
62
+ return true;
47
diff --git a/hw/display/bcm2835_fb.c b/hw/display/bcm2835_fb.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/hw/display/bcm2835_fb.c
50
+++ b/hw/display/bcm2835_fb.c
51
@@ -XXX,XX +XXX,XX @@
52
#define DEFAULT_VCRAM_SIZE 0x4000000
53
#define BCM2835_FB_OFFSET 0x00100000
54
55
+/* Maximum permitted framebuffer size; experimentally determined on an rpi2 */
56
+#define XRES_MAX 3840
57
+#define YRES_MAX 2560
58
+/* Framebuffer size used if guest requests zero size */
59
+#define XRES_SMALL 592
60
+#define YRES_SMALL 488
61
+
62
static void fb_invalidate_display(void *opaque)
63
{
64
BCM2835FBState *s = BCM2835_FB(opaque);
65
@@ -XXX,XX +XXX,XX @@ static void fb_update_display(void *opaque)
66
s->invalidate = false;
67
}
63
}
68
64
69
+void bcm2835_fb_validate_config(BCM2835FBConfig *config)
65
static void clock_propagate_period(Clock *clk, bool call_callbacks)
70
+{
71
+ /*
72
+ * Validate the config, and clip any bogus values into range,
73
+ * as the hardware does. Note that fb_update_display() relies on
74
+ * this happening to prevent it from performing out-of-range
75
+ * accesses on redraw.
76
+ */
77
+ config->xres = MIN(config->xres, XRES_MAX);
78
+ config->xres_virtual = MIN(config->xres_virtual, XRES_MAX);
79
+ config->yres = MIN(config->yres, YRES_MAX);
80
+ config->yres_virtual = MIN(config->yres_virtual, YRES_MAX);
81
+
82
+ /*
83
+ * These are not minima: a 40x40 framebuffer will be accepted.
84
+ * They're only used as defaults if the guest asks for zero size.
85
+ */
86
+ if (config->xres == 0) {
87
+ config->xres = XRES_SMALL;
88
+ }
89
+ if (config->yres == 0) {
90
+ config->yres = YRES_SMALL;
91
+ }
92
+ if (config->xres_virtual == 0) {
93
+ config->xres_virtual = config->xres;
94
+ }
95
+ if (config->yres_virtual == 0) {
96
+ config->yres_virtual = config->yres;
97
+ }
98
+
99
+ if (fb_use_offsets(config)) {
100
+ /* Clip the offsets so the viewport is within the physical screen */
101
+ config->xoffset = MIN(config->xoffset,
102
+ config->xres_virtual - config->xres);
103
+ config->yoffset = MIN(config->yoffset,
104
+ config->yres_virtual - config->yres);
105
+ }
106
+}
107
+
108
static void bcm2835_fb_mbox_push(BCM2835FBState *s, uint32_t value)
109
{
110
uint32_t pitch;
111
@@ -XXX,XX +XXX,XX @@ void bcm2835_fb_reconfigure(BCM2835FBState *s, BCM2835FBConfig *newconfig)
112
{
113
s->lock = true;
114
115
- /* TODO: input validation! */
116
-
117
s->config = *newconfig;
118
119
s->invalidate = true;
120
diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c
121
index XXXXXXX..XXXXXXX 100644
122
--- a/hw/misc/bcm2835_property.c
123
+++ b/hw/misc/bcm2835_property.c
124
@@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value)
125
case 0x00040002: /* Blank screen */
126
resplen = 4;
127
break;
128
- case 0x00040003: /* Get physical display width/height */
129
- stl_le_phys(&s->dma_as, value + 12, fbconfig.xres);
130
- stl_le_phys(&s->dma_as, value + 16, fbconfig.yres);
131
- resplen = 8;
132
- break;
133
- case 0x00040004: /* Get virtual display width/height */
134
- stl_le_phys(&s->dma_as, value + 12, fbconfig.xres_virtual);
135
- stl_le_phys(&s->dma_as, value + 16, fbconfig.yres_virtual);
136
- resplen = 8;
137
- break;
138
case 0x00044003: /* Test physical display width/height */
139
case 0x00044004: /* Test virtual display width/height */
140
resplen = 8;
141
@@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value)
142
case 0x00048003: /* Set physical display width/height */
143
fbconfig.xres = ldl_le_phys(&s->dma_as, value + 12);
144
fbconfig.yres = ldl_le_phys(&s->dma_as, value + 16);
145
+ bcm2835_fb_validate_config(&fbconfig);
146
fbconfig_updated = true;
147
+ /* fall through */
148
+ case 0x00040003: /* Get physical display width/height */
149
+ stl_le_phys(&s->dma_as, value + 12, fbconfig.xres);
150
+ stl_le_phys(&s->dma_as, value + 16, fbconfig.yres);
151
resplen = 8;
152
break;
153
case 0x00048004: /* Set virtual display width/height */
154
fbconfig.xres_virtual = ldl_le_phys(&s->dma_as, value + 12);
155
fbconfig.yres_virtual = ldl_le_phys(&s->dma_as, value + 16);
156
+ bcm2835_fb_validate_config(&fbconfig);
157
fbconfig_updated = true;
158
+ /* fall through */
159
+ case 0x00040004: /* Get virtual display width/height */
160
+ stl_le_phys(&s->dma_as, value + 12, fbconfig.xres_virtual);
161
+ stl_le_phys(&s->dma_as, value + 16, fbconfig.yres_virtual);
162
resplen = 8;
163
break;
164
- case 0x00040005: /* Get depth */
165
- stl_le_phys(&s->dma_as, value + 12, fbconfig.bpp);
166
- resplen = 4;
167
- break;
168
case 0x00044005: /* Test depth */
169
resplen = 4;
170
break;
171
case 0x00048005: /* Set depth */
172
fbconfig.bpp = ldl_le_phys(&s->dma_as, value + 12);
173
+ bcm2835_fb_validate_config(&fbconfig);
174
fbconfig_updated = true;
175
- resplen = 4;
176
- break;
177
- case 0x00040006: /* Get pixel order */
178
- stl_le_phys(&s->dma_as, value + 12, fbconfig.pixo);
179
+ /* fall through */
180
+ case 0x00040005: /* Get depth */
181
+ stl_le_phys(&s->dma_as, value + 12, fbconfig.bpp);
182
resplen = 4;
183
break;
184
case 0x00044006: /* Test pixel order */
185
@@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value)
186
break;
187
case 0x00048006: /* Set pixel order */
188
fbconfig.pixo = ldl_le_phys(&s->dma_as, value + 12);
189
+ bcm2835_fb_validate_config(&fbconfig);
190
fbconfig_updated = true;
191
- resplen = 4;
192
- break;
193
- case 0x00040007: /* Get alpha */
194
- stl_le_phys(&s->dma_as, value + 12, fbconfig.alpha);
195
+ /* fall through */
196
+ case 0x00040006: /* Get pixel order */
197
+ stl_le_phys(&s->dma_as, value + 12, fbconfig.pixo);
198
resplen = 4;
199
break;
200
case 0x00044007: /* Test pixel alpha */
201
@@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value)
202
break;
203
case 0x00048007: /* Set alpha */
204
fbconfig.alpha = ldl_le_phys(&s->dma_as, value + 12);
205
+ bcm2835_fb_validate_config(&fbconfig);
206
fbconfig_updated = true;
207
+ /* fall through */
208
+ case 0x00040007: /* Get alpha */
209
+ stl_le_phys(&s->dma_as, value + 12, fbconfig.alpha);
210
resplen = 4;
211
break;
212
case 0x00040008: /* Get pitch */
213
@@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value)
214
bcm2835_fb_get_pitch(&fbconfig));
215
resplen = 4;
216
break;
217
- case 0x00040009: /* Get virtual offset */
218
- stl_le_phys(&s->dma_as, value + 12, fbconfig.xoffset);
219
- stl_le_phys(&s->dma_as, value + 16, fbconfig.yoffset);
220
- resplen = 8;
221
- break;
222
case 0x00044009: /* Test virtual offset */
223
resplen = 8;
224
break;
225
case 0x00048009: /* Set virtual offset */
226
fbconfig.xoffset = ldl_le_phys(&s->dma_as, value + 12);
227
fbconfig.yoffset = ldl_le_phys(&s->dma_as, value + 16);
228
+ bcm2835_fb_validate_config(&fbconfig);
229
fbconfig_updated = true;
230
+ /* fall through */
231
+ case 0x00040009: /* Get virtual offset */
232
+ stl_le_phys(&s->dma_as, value + 12, fbconfig.xoffset);
233
+ stl_le_phys(&s->dma_as, value + 16, fbconfig.yoffset);
234
resplen = 8;
235
break;
236
case 0x0004000a: /* Get/Test/Set overscan */
237
--
66
--
238
2.18.0
67
2.20.1
239
68
240
69
diff view generated by jsdifflib
1
For the A15MPCore internal peripheral object, we handle GIC
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
security extensions support by checking whether the CPUs
3
have EL3 enabled; if so then we enable it also on the GIC.
4
Handle the virtualization extensions in the same way: if the
5
CPU has EL2 then enable it on the GIC and wire up the
6
virtualization-specific memory regions and the maintenance
7
interrupt.
8
2
3
Avoid propagating the clock change when the clock does not change.
4
5
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20200806123858.30058-4-f4bug@amsat.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
11
Message-id: 20180821132811.17675-8-peter.maydell@linaro.org
12
---
9
---
13
hw/cpu/a15mpcore.c | 31 ++++++++++++++++++++++++++++---
10
include/hw/clock.h | 5 +++--
14
1 file changed, 28 insertions(+), 3 deletions(-)
11
1 file changed, 3 insertions(+), 2 deletions(-)
15
12
16
diff --git a/hw/cpu/a15mpcore.c b/hw/cpu/a15mpcore.c
13
diff --git a/include/hw/clock.h b/include/hw/clock.h
17
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/cpu/a15mpcore.c
15
--- a/include/hw/clock.h
19
+++ b/hw/cpu/a15mpcore.c
16
+++ b/include/hw/clock.h
20
@@ -XXX,XX +XXX,XX @@ static void a15mp_priv_realize(DeviceState *dev, Error **errp)
17
@@ -XXX,XX +XXX,XX @@ void clock_propagate(Clock *clk);
21
int i;
18
*/
22
Error *err = NULL;
19
static inline void clock_update(Clock *clk, uint64_t value)
23
bool has_el3;
20
{
24
+ bool has_el2;
21
- clock_set(clk, value);
25
Object *cpuobj;
22
- clock_propagate(clk);
26
23
+ if (clock_set(clk, value)) {
27
gicdev = DEVICE(&s->gic);
24
+ clock_propagate(clk);
28
@@ -XXX,XX +XXX,XX @@ static void a15mp_priv_realize(DeviceState *dev, Error **errp)
29
has_el3 = object_property_find(cpuobj, "has_el3", NULL) &&
30
object_property_get_bool(cpuobj, "has_el3", &error_abort);
31
qdev_prop_set_bit(gicdev, "has-security-extensions", has_el3);
32
+ /* Similarly for virtualization support */
33
+ has_el2 = object_property_find(cpuobj, "has_el2", NULL) &&
34
+ object_property_get_bool(cpuobj, "has_el2", &error_abort);
35
+ qdev_prop_set_bit(gicdev, "has-virtualization-extensions", has_el2);
36
}
37
38
object_property_set_bool(OBJECT(&s->gic), true, "realized", &err);
39
@@ -XXX,XX +XXX,XX @@ static void a15mp_priv_realize(DeviceState *dev, Error **errp)
40
qdev_get_gpio_in(gicdev,
41
ppibase + timer_irq[irq]));
42
}
43
+ if (has_el2) {
44
+ /* Connect the GIC maintenance interrupt to PPI ID 25 */
45
+ sysbus_connect_irq(SYS_BUS_DEVICE(gicdev), i + 4 * s->num_cpu,
46
+ qdev_get_gpio_in(gicdev, ppibase + 25));
47
+ }
48
}
49
50
/* Memory map (addresses are offsets from PERIPHBASE):
51
* 0x0000-0x0fff -- reserved
52
* 0x1000-0x1fff -- GIC Distributor
53
* 0x2000-0x3fff -- GIC CPU interface
54
- * 0x4000-0x4fff -- GIC virtual interface control (not modelled)
55
- * 0x5000-0x5fff -- GIC virtual interface control (not modelled)
56
- * 0x6000-0x7fff -- GIC virtual CPU interface (not modelled)
57
+ * 0x4000-0x4fff -- GIC virtual interface control for this CPU
58
+ * 0x5000-0x51ff -- GIC virtual interface control for CPU 0
59
+ * 0x5200-0x53ff -- GIC virtual interface control for CPU 1
60
+ * 0x5400-0x55ff -- GIC virtual interface control for CPU 2
61
+ * 0x5600-0x57ff -- GIC virtual interface control for CPU 3
62
+ * 0x6000-0x7fff -- GIC virtual CPU interface
63
*/
64
memory_region_add_subregion(&s->container, 0x1000,
65
sysbus_mmio_get_region(busdev, 0));
66
memory_region_add_subregion(&s->container, 0x2000,
67
sysbus_mmio_get_region(busdev, 1));
68
+ if (has_el2) {
69
+ memory_region_add_subregion(&s->container, 0x4000,
70
+ sysbus_mmio_get_region(busdev, 2));
71
+ memory_region_add_subregion(&s->container, 0x6000,
72
+ sysbus_mmio_get_region(busdev, 3));
73
+ for (i = 0; i < s->num_cpu; i++) {
74
+ hwaddr base = 0x5000 + i * 0x200;
75
+ MemoryRegion *mr = sysbus_mmio_get_region(busdev,
76
+ 4 + s->num_cpu + i);
77
+ memory_region_add_subregion(&s->container, base, mr);
78
+ }
79
+ }
25
+ }
80
}
26
}
81
27
82
static Property a15mp_priv_properties[] = {
28
static inline void clock_update_hz(Clock *clk, unsigned hz)
83
--
29
--
84
2.18.0
30
2.20.1
85
31
86
32
diff view generated by jsdifflib
1
Implement the necessary support code for taking exceptions
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
to Hyp mode in AArch32.
3
2
3
Allow the device to execute the DMA transfers in a different
4
AddressSpace.
5
6
We keep using the system_memory address space, but via the
7
proper dma_memory_access() API.
8
9
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20200814125533.4047-1-f4bug@amsat.org
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
7
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
8
Message-id: 20180820153020.21478-5-peter.maydell@linaro.org
9
---
13
---
10
target/arm/helper.c | 82 +++++++++++++++++++++++++++++++++++++++++++++
14
hw/arm/musicpal.c | 45 +++++++++++++++++++++++++++++++--------------
11
1 file changed, 82 insertions(+)
15
1 file changed, 31 insertions(+), 14 deletions(-)
12
16
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
17
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
14
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
19
--- a/hw/arm/musicpal.c
16
+++ b/target/arm/helper.c
20
+++ b/hw/arm/musicpal.c
17
@@ -XXX,XX +XXX,XX @@ static void take_aarch32_exception(CPUARMState *env, int new_mode,
21
@@ -XXX,XX +XXX,XX @@
18
env->regs[15] = newpc;
22
#include "hw/audio/wm8750.h"
23
#include "sysemu/block-backend.h"
24
#include "sysemu/runstate.h"
25
+#include "sysemu/dma.h"
26
#include "exec/address-spaces.h"
27
#include "ui/pixel_ops.h"
28
#include "qemu/cutils.h"
29
@@ -XXX,XX +XXX,XX @@ typedef struct mv88w8618_eth_state {
30
31
MemoryRegion iomem;
32
qemu_irq irq;
33
+ MemoryRegion *dma_mr;
34
+ AddressSpace dma_as;
35
uint32_t smir;
36
uint32_t icr;
37
uint32_t imr;
38
@@ -XXX,XX +XXX,XX @@ typedef struct mv88w8618_eth_state {
39
NICConf conf;
40
} mv88w8618_eth_state;
41
42
-static void eth_rx_desc_put(uint32_t addr, mv88w8618_rx_desc *desc)
43
+static void eth_rx_desc_put(AddressSpace *dma_as, uint32_t addr,
44
+ mv88w8618_rx_desc *desc)
45
{
46
cpu_to_le32s(&desc->cmdstat);
47
cpu_to_le16s(&desc->bytes);
48
cpu_to_le16s(&desc->buffer_size);
49
cpu_to_le32s(&desc->buffer);
50
cpu_to_le32s(&desc->next);
51
- cpu_physical_memory_write(addr, desc, sizeof(*desc));
52
+ dma_memory_write(dma_as, addr, desc, sizeof(*desc));
19
}
53
}
20
54
21
+static void arm_cpu_do_interrupt_aarch32_hyp(CPUState *cs)
55
-static void eth_rx_desc_get(uint32_t addr, mv88w8618_rx_desc *desc)
22
+{
56
+static void eth_rx_desc_get(AddressSpace *dma_as, uint32_t addr,
23
+ /*
57
+ mv88w8618_rx_desc *desc)
24
+ * Handle exception entry to Hyp mode; this is sufficiently
25
+ * different to entry to other AArch32 modes that we handle it
26
+ * separately here.
27
+ *
28
+ * The vector table entry used is always the 0x14 Hyp mode entry point,
29
+ * unless this is an UNDEF/HVC/abort taken from Hyp to Hyp.
30
+ * The offset applied to the preferred return address is always zero
31
+ * (see DDI0487C.a section G1.12.3).
32
+ * PSTATE A/I/F masks are set based only on the SCR.EA/IRQ/FIQ values.
33
+ */
34
+ uint32_t addr, mask;
35
+ ARMCPU *cpu = ARM_CPU(cs);
36
+ CPUARMState *env = &cpu->env;
37
+
38
+ switch (cs->exception_index) {
39
+ case EXCP_UDEF:
40
+ addr = 0x04;
41
+ break;
42
+ case EXCP_SWI:
43
+ addr = 0x14;
44
+ break;
45
+ case EXCP_BKPT:
46
+ /* Fall through to prefetch abort. */
47
+ case EXCP_PREFETCH_ABORT:
48
+ env->cp15.ifar_s = env->exception.vaddress;
49
+ qemu_log_mask(CPU_LOG_INT, "...with HIFAR 0x%x\n",
50
+ (uint32_t)env->exception.vaddress);
51
+ addr = 0x0c;
52
+ break;
53
+ case EXCP_DATA_ABORT:
54
+ env->cp15.dfar_s = env->exception.vaddress;
55
+ qemu_log_mask(CPU_LOG_INT, "...with HDFAR 0x%x\n",
56
+ (uint32_t)env->exception.vaddress);
57
+ addr = 0x10;
58
+ break;
59
+ case EXCP_IRQ:
60
+ addr = 0x18;
61
+ break;
62
+ case EXCP_FIQ:
63
+ addr = 0x1c;
64
+ break;
65
+ case EXCP_HVC:
66
+ addr = 0x08;
67
+ break;
68
+ case EXCP_HYP_TRAP:
69
+ addr = 0x14;
70
+ default:
71
+ cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index);
72
+ }
73
+
74
+ if (cs->exception_index != EXCP_IRQ && cs->exception_index != EXCP_FIQ) {
75
+ env->cp15.esr_el[2] = env->exception.syndrome;
76
+ }
77
+
78
+ if (arm_current_el(env) != 2 && addr < 0x14) {
79
+ addr = 0x14;
80
+ }
81
+
82
+ mask = 0;
83
+ if (!(env->cp15.scr_el3 & SCR_EA)) {
84
+ mask |= CPSR_A;
85
+ }
86
+ if (!(env->cp15.scr_el3 & SCR_IRQ)) {
87
+ mask |= CPSR_I;
88
+ }
89
+ if (!(env->cp15.scr_el3 & SCR_FIQ)) {
90
+ mask |= CPSR_F;
91
+ }
92
+
93
+ addr += env->cp15.hvbar;
94
+
95
+ take_aarch32_exception(env, ARM_CPU_MODE_HYP, mask, 0, addr);
96
+}
97
+
98
static void arm_cpu_do_interrupt_aarch32(CPUState *cs)
99
{
58
{
100
ARMCPU *cpu = ARM_CPU(cs);
59
- cpu_physical_memory_read(addr, desc, sizeof(*desc));
101
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch32(CPUState *cs)
60
+ dma_memory_read(dma_as, addr, desc, sizeof(*desc));
102
env->cp15.mdscr_el1 = deposit64(env->cp15.mdscr_el1, 2, 4, moe);
61
le32_to_cpus(&desc->cmdstat);
103
}
62
le16_to_cpus(&desc->bytes);
104
63
le16_to_cpus(&desc->buffer_size);
105
+ if (env->exception.target_el == 2) {
64
@@ -XXX,XX +XXX,XX @@ static ssize_t eth_receive(NetClientState *nc, const uint8_t *buf, size_t size)
106
+ arm_cpu_do_interrupt_aarch32_hyp(cs);
65
continue;
66
}
67
do {
68
- eth_rx_desc_get(desc_addr, &desc);
69
+ eth_rx_desc_get(&s->dma_as, desc_addr, &desc);
70
if ((desc.cmdstat & MP_ETH_RX_OWN) && desc.buffer_size >= size) {
71
- cpu_physical_memory_write(desc.buffer + s->vlan_header,
72
+ dma_memory_write(&s->dma_as, desc.buffer + s->vlan_header,
73
buf, size);
74
desc.bytes = size + s->vlan_header;
75
desc.cmdstat &= ~MP_ETH_RX_OWN;
76
@@ -XXX,XX +XXX,XX @@ static ssize_t eth_receive(NetClientState *nc, const uint8_t *buf, size_t size)
77
if (s->icr & s->imr) {
78
qemu_irq_raise(s->irq);
79
}
80
- eth_rx_desc_put(desc_addr, &desc);
81
+ eth_rx_desc_put(&s->dma_as, desc_addr, &desc);
82
return size;
83
}
84
desc_addr = desc.next;
85
@@ -XXX,XX +XXX,XX @@ static ssize_t eth_receive(NetClientState *nc, const uint8_t *buf, size_t size)
86
return size;
87
}
88
89
-static void eth_tx_desc_put(uint32_t addr, mv88w8618_tx_desc *desc)
90
+static void eth_tx_desc_put(AddressSpace *dma_as, uint32_t addr,
91
+ mv88w8618_tx_desc *desc)
92
{
93
cpu_to_le32s(&desc->cmdstat);
94
cpu_to_le16s(&desc->res);
95
cpu_to_le16s(&desc->bytes);
96
cpu_to_le32s(&desc->buffer);
97
cpu_to_le32s(&desc->next);
98
- cpu_physical_memory_write(addr, desc, sizeof(*desc));
99
+ dma_memory_write(dma_as, addr, desc, sizeof(*desc));
100
}
101
102
-static void eth_tx_desc_get(uint32_t addr, mv88w8618_tx_desc *desc)
103
+static void eth_tx_desc_get(AddressSpace *dma_as, uint32_t addr,
104
+ mv88w8618_tx_desc *desc)
105
{
106
- cpu_physical_memory_read(addr, desc, sizeof(*desc));
107
+ dma_memory_read(dma_as, addr, desc, sizeof(*desc));
108
le32_to_cpus(&desc->cmdstat);
109
le16_to_cpus(&desc->res);
110
le16_to_cpus(&desc->bytes);
111
@@ -XXX,XX +XXX,XX @@ static void eth_send(mv88w8618_eth_state *s, int queue_index)
112
int len;
113
114
do {
115
- eth_tx_desc_get(desc_addr, &desc);
116
+ eth_tx_desc_get(&s->dma_as, desc_addr, &desc);
117
next_desc = desc.next;
118
if (desc.cmdstat & MP_ETH_TX_OWN) {
119
len = desc.bytes;
120
if (len < 2048) {
121
- cpu_physical_memory_read(desc.buffer, buf, len);
122
+ dma_memory_read(&s->dma_as, desc.buffer, buf, len);
123
qemu_send_packet(qemu_get_queue(s->nic), buf, len);
124
}
125
desc.cmdstat &= ~MP_ETH_TX_OWN;
126
s->icr |= 1 << (MP_ETH_IRQ_TXLO_BIT - queue_index);
127
- eth_tx_desc_put(desc_addr, &desc);
128
+ eth_tx_desc_put(&s->dma_as, desc_addr, &desc);
129
}
130
desc_addr = next_desc;
131
} while (desc_addr != s->tx_queue[queue_index]);
132
@@ -XXX,XX +XXX,XX @@ static void mv88w8618_eth_realize(DeviceState *dev, Error **errp)
133
{
134
mv88w8618_eth_state *s = MV88W8618_ETH(dev);
135
136
+ if (!s->dma_mr) {
137
+ error_setg(errp, TYPE_MV88W8618_ETH " 'dma-memory' link not set");
107
+ return;
138
+ return;
108
+ }
139
+ }
109
+
140
+
110
/* TODO: Vectored interrupt controller. */
141
+ address_space_init(&s->dma_as, s->dma_mr, "emac-dma");
111
switch (cs->exception_index) {
142
s->nic = qemu_new_nic(&net_mv88w8618_info, &s->conf,
112
case EXCP_UDEF:
143
object_get_typename(OBJECT(dev)), dev->id, s);
144
}
145
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription mv88w8618_eth_vmsd = {
146
147
static Property mv88w8618_eth_properties[] = {
148
DEFINE_NIC_PROPERTIES(mv88w8618_eth_state, conf),
149
+ DEFINE_PROP_LINK("dma-memory", mv88w8618_eth_state, dma_mr,
150
+ TYPE_MEMORY_REGION, MemoryRegion *),
151
DEFINE_PROP_END_OF_LIST(),
152
};
153
154
@@ -XXX,XX +XXX,XX @@ static void musicpal_init(MachineState *machine)
155
qemu_check_nic_model(&nd_table[0], "mv88w8618");
156
dev = qdev_new(TYPE_MV88W8618_ETH);
157
qdev_set_nic_properties(dev, &nd_table[0]);
158
+ object_property_set_link(OBJECT(dev), "dma-memory",
159
+ OBJECT(get_system_memory()), &error_fatal);
160
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
161
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, MP_ETH_BASE);
162
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[MP_ETH_IRQ]);
113
--
163
--
114
2.18.0
164
2.20.1
115
165
116
166
diff view generated by jsdifflib
1
The AArch32 HCR and HCR2 registers alias HCR_EL2
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
bits [31:0] and [63:32]; implement them.
3
2
4
Since HCR2 exists in ARMv8 but not ARMv7, we need new
3
In commit ce4afed839 ("target/arm: Implement AArch32 HCR and HCR2")
5
regdef arrays for "we have EL3, not EL2, we're ARMv8"
4
the HCR_EL2 register has been changed from type NO_RAW (no underlying
6
and "we have EL2, we're ARMv8" to hold the definitions.
5
state and does not support raw access for state saving/loading) to
6
type CONST (TCG can assume the value to be constant), removing the
7
read/write accessors.
8
We forgot to remove the previous type ARM_CP_NO_RAW. This is not
9
really a problem since the field is overwritten. However it makes
10
code review confuse, so remove it.
7
11
12
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20200812111223.7787-1-f4bug@amsat.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
11
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
12
Message-id: 20180820153020.21478-3-peter.maydell@linaro.org
13
---
17
---
14
target/arm/helper.c | 54 +++++++++++++++++++++++++++++++++++++++++----
18
target/arm/helper.c | 1 -
15
1 file changed, 50 insertions(+), 4 deletions(-)
19
1 file changed, 1 deletion(-)
16
20
17
diff --git a/target/arm/helper.c b/target/arm/helper.c
21
diff --git a/target/arm/helper.c b/target/arm/helper.c
18
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/helper.c
23
--- a/target/arm/helper.c
20
+++ b/target/arm/helper.c
24
+++ b/target/arm/helper.c
21
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_no_el2_cp_reginfo[] = {
25
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_no_el2_cp_reginfo[] = {
22
.opc0 = 3, .opc1 = 4, .crn = 12, .crm = 0, .opc2 = 0,
23
.access = PL2_RW,
26
.access = PL2_RW,
24
.readfn = arm_cp_read_zero, .writefn = arm_cp_write_ignore },
27
.readfn = arm_cp_read_zero, .writefn = arm_cp_write_ignore },
25
- { .name = "HCR_EL2", .state = ARM_CP_STATE_AA64,
28
{ .name = "HCR_EL2", .state = ARM_CP_STATE_BOTH,
26
+ { .name = "HCR_EL2", .state = ARM_CP_STATE_BOTH,
29
- .type = ARM_CP_NO_RAW,
27
.type = ARM_CP_NO_RAW,
28
.opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0,
30
.opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0,
29
.access = PL2_RW,
31
.access = PL2_RW,
30
- .readfn = arm_cp_read_zero, .writefn = arm_cp_write_ignore },
32
.type = ARM_CP_CONST, .resetvalue = 0 },
31
+ .type = ARM_CP_CONST, .resetvalue = 0 },
32
{ .name = "ESR_EL2", .state = ARM_CP_STATE_BOTH,
33
.opc0 = 3, .opc1 = 4, .crn = 5, .crm = 2, .opc2 = 0,
34
.access = PL2_RW,
35
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_no_el2_cp_reginfo[] = {
36
REGINFO_SENTINEL
37
};
38
39
+/* Ditto, but for registers which exist in ARMv8 but not v7 */
40
+static const ARMCPRegInfo el3_no_el2_v8_cp_reginfo[] = {
41
+ { .name = "HCR2", .state = ARM_CP_STATE_AA32,
42
+ .cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 4,
43
+ .access = PL2_RW,
44
+ .type = ARM_CP_CONST, .resetvalue = 0 },
45
+ REGINFO_SENTINEL
46
+};
47
+
48
static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
49
{
50
ARMCPU *cpu = arm_env_get_cpu(env);
51
@@ -XXX,XX +XXX,XX @@ static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
52
* HCR_PTW forbids certain page-table setups
53
* HCR_DC Disables stage1 and enables stage2 translation
54
*/
55
- if ((raw_read(env, ri) ^ value) & (HCR_VM | HCR_PTW | HCR_DC)) {
56
+ if ((env->cp15.hcr_el2 ^ value) & (HCR_VM | HCR_PTW | HCR_DC)) {
57
tlb_flush(CPU(cpu));
58
}
59
- raw_write(env, ri, value);
60
+ env->cp15.hcr_el2 = value;
61
+}
62
+
63
+static void hcr_writehigh(CPUARMState *env, const ARMCPRegInfo *ri,
64
+ uint64_t value)
65
+{
66
+ /* Handle HCR2 write, i.e. write to high half of HCR_EL2 */
67
+ value = deposit64(env->cp15.hcr_el2, 32, 32, value);
68
+ hcr_write(env, NULL, value);
69
+}
70
+
71
+static void hcr_writelow(CPUARMState *env, const ARMCPRegInfo *ri,
72
+ uint64_t value)
73
+{
74
+ /* Handle HCR write, i.e. write to low half of HCR_EL2 */
75
+ value = deposit64(env->cp15.hcr_el2, 0, 32, value);
76
+ hcr_write(env, NULL, value);
77
}
78
79
static const ARMCPRegInfo el2_cp_reginfo[] = {
80
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = {
81
.opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0,
82
.access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.hcr_el2),
83
.writefn = hcr_write },
84
+ { .name = "HCR", .state = ARM_CP_STATE_AA32,
85
+ .type = ARM_CP_ALIAS,
86
+ .cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0,
87
+ .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.hcr_el2),
88
+ .writefn = hcr_writelow },
89
{ .name = "ELR_EL2", .state = ARM_CP_STATE_AA64,
90
.type = ARM_CP_ALIAS,
91
.opc0 = 3, .opc1 = 4, .crn = 4, .crm = 0, .opc2 = 1,
92
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = {
93
REGINFO_SENTINEL
94
};
95
96
+static const ARMCPRegInfo el2_v8_cp_reginfo[] = {
97
+ { .name = "HCR2", .state = ARM_CP_STATE_AA32,
98
+ .type = ARM_CP_ALIAS,
99
+ .cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 4,
100
+ .access = PL2_RW,
101
+ .fieldoffset = offsetofhigh32(CPUARMState, cp15.hcr_el2),
102
+ .writefn = hcr_writehigh },
103
+ REGINFO_SENTINEL
104
+};
105
+
106
static CPAccessResult nsacr_access(CPUARMState *env, const ARMCPRegInfo *ri,
107
bool isread)
108
{
109
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
110
};
111
define_arm_cp_regs(cpu, vpidr_regs);
112
define_arm_cp_regs(cpu, el2_cp_reginfo);
113
+ if (arm_feature(env, ARM_FEATURE_V8)) {
114
+ define_arm_cp_regs(cpu, el2_v8_cp_reginfo);
115
+ }
116
/* RVBAR_EL2 is only implemented if EL2 is the highest EL */
117
if (!arm_feature(env, ARM_FEATURE_EL3)) {
118
ARMCPRegInfo rvbar = {
119
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
120
};
121
define_arm_cp_regs(cpu, vpidr_regs);
122
define_arm_cp_regs(cpu, el3_no_el2_cp_reginfo);
123
+ if (arm_feature(env, ARM_FEATURE_V8)) {
124
+ define_arm_cp_regs(cpu, el3_no_el2_v8_cp_reginfo);
125
+ }
126
}
127
}
128
if (arm_feature(env, ARM_FEATURE_EL3)) {
129
--
33
--
130
2.18.0
34
2.20.1
131
35
132
36
diff view generated by jsdifflib
1
Refactor the fb property setting code so that rather than
1
From: Richard Henderson <richard.henderson@linaro.org>
2
using a set of pointers to local variables to track
3
whether a config value has been updated in the current
4
mbox and if so what its new value is, we just copy
5
all the current settings of the fb at the start, and
6
then update that copy as we go along, before asking
7
the fb to switch to it at the end.
8
2
3
We need more information than just the mmu_idx in order
4
to create the proper exception syndrome. Only change the
5
function signature so far.
6
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20200813200816.3037186-2-richard.henderson@linaro.org
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20180814144436.679-3-peter.maydell@linaro.org
12
---
11
---
13
include/hw/display/bcm2835_fb.h | 4 +-
12
target/arm/mte_helper.c | 10 +++++-----
14
hw/display/bcm2835_fb.c | 27 ++---------
13
1 file changed, 5 insertions(+), 5 deletions(-)
15
hw/misc/bcm2835_property.c | 80 ++++++++++++++-------------------
16
3 files changed, 37 insertions(+), 74 deletions(-)
17
14
18
diff --git a/include/hw/display/bcm2835_fb.h b/include/hw/display/bcm2835_fb.h
15
diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c
19
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
20
--- a/include/hw/display/bcm2835_fb.h
17
--- a/target/arm/mte_helper.c
21
+++ b/include/hw/display/bcm2835_fb.h
18
+++ b/target/arm/mte_helper.c
22
@@ -XXX,XX +XXX,XX @@ typedef struct {
19
@@ -XXX,XX +XXX,XX @@ void HELPER(stzgm_tags)(CPUARMState *env, uint64_t ptr, uint64_t val)
23
uint32_t pitch;
24
} BCM2835FBState;
25
26
-void bcm2835_fb_reconfigure(BCM2835FBState *s, uint32_t *xres, uint32_t *yres,
27
- uint32_t *xoffset, uint32_t *yoffset, uint32_t *bpp,
28
- uint32_t *pixo, uint32_t *alpha);
29
+void bcm2835_fb_reconfigure(BCM2835FBState *s, BCM2835FBConfig *newconfig);
30
31
#endif
32
diff --git a/hw/display/bcm2835_fb.c b/hw/display/bcm2835_fb.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/display/bcm2835_fb.c
35
+++ b/hw/display/bcm2835_fb.c
36
@@ -XXX,XX +XXX,XX @@ static void bcm2835_fb_mbox_push(BCM2835FBState *s, uint32_t value)
37
s->lock = false;
38
}
20
}
39
21
40
-void bcm2835_fb_reconfigure(BCM2835FBState *s, uint32_t *xres, uint32_t *yres,
22
/* Record a tag check failure. */
41
- uint32_t *xoffset, uint32_t *yoffset, uint32_t *bpp,
23
-static void mte_check_fail(CPUARMState *env, int mmu_idx,
42
- uint32_t *pixo, uint32_t *alpha)
24
+static void mte_check_fail(CPUARMState *env, uint32_t desc,
43
+void bcm2835_fb_reconfigure(BCM2835FBState *s, BCM2835FBConfig *newconfig)
25
uint64_t dirty_ptr, uintptr_t ra)
44
{
26
{
45
s->lock = true;
27
+ int mmu_idx = FIELD_EX32(desc, MTEDESC, MIDX);
46
28
ARMMMUIdx arm_mmu_idx = core_to_aa64_mmu_idx(mmu_idx);
47
/* TODO: input validation! */
29
int el, reg_el, tcf, select;
48
- if (xres) {
30
uint64_t sctlr;
49
- s->config.xres = *xres;
31
@@ -XXX,XX +XXX,XX @@ uint64_t mte_check1(CPUARMState *env, uint32_t desc,
50
- }
51
- if (yres) {
52
- s->config.yres = *yres;
53
- }
54
- if (xoffset) {
55
- s->config.xoffset = *xoffset;
56
- }
57
- if (yoffset) {
58
- s->config.yoffset = *yoffset;
59
- }
60
- if (bpp) {
61
- s->config.bpp = *bpp;
62
- }
63
- if (pixo) {
64
- s->config.pixo = *pixo;
65
- }
66
- if (alpha) {
67
- s->config.alpha = *alpha;
68
- }
69
+
70
+ s->config = *newconfig;
71
72
/* TODO - Manage properly virtual resolution */
73
74
diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c
75
index XXXXXXX..XXXXXXX 100644
76
--- a/hw/misc/bcm2835_property.c
77
+++ b/hw/misc/bcm2835_property.c
78
@@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value)
79
uint32_t tmp;
80
int n;
81
uint32_t offset, length, color;
82
- uint32_t xres, yres, xoffset, yoffset, bpp, pixo, alpha;
83
- uint32_t tmp_xres, tmp_yres, tmp_xoffset, tmp_yoffset;
84
- uint32_t tmp_bpp, tmp_pixo, tmp_alpha;
85
- uint32_t *newxres = NULL, *newyres = NULL, *newxoffset = NULL,
86
- *newyoffset = NULL, *newbpp = NULL, *newpixo = NULL, *newalpha = NULL;
87
+
88
+ /*
89
+ * Copy the current state of the framebuffer config; we will update
90
+ * this copy as we process tags and then ask the framebuffer to use
91
+ * it at the end.
92
+ */
93
+ BCM2835FBConfig fbconfig = s->fbdev->config;
94
+ bool fbconfig_updated = false;
95
96
value &= ~0xf;
97
98
@@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value)
99
/* Frame buffer */
100
101
case 0x00040001: /* Allocate buffer */
102
- stl_le_phys(&s->dma_as, value + 12, s->fbdev->config.base);
103
- tmp_xres = newxres != NULL ? *newxres : s->fbdev->config.xres;
104
- tmp_yres = newyres != NULL ? *newyres : s->fbdev->config.yres;
105
- tmp_bpp = newbpp != NULL ? *newbpp : s->fbdev->config.bpp;
106
+ stl_le_phys(&s->dma_as, value + 12, fbconfig.base);
107
stl_le_phys(&s->dma_as, value + 16,
108
- tmp_xres * tmp_yres * tmp_bpp / 8);
109
+ fbconfig.xres * fbconfig.yres * fbconfig.bpp / 8);
110
resplen = 8;
111
break;
112
case 0x00048001: /* Release buffer */
113
@@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value)
114
break;
115
case 0x00040003: /* Get display width/height */
116
case 0x00040004:
117
- tmp_xres = newxres != NULL ? *newxres : s->fbdev->config.xres;
118
- tmp_yres = newyres != NULL ? *newyres : s->fbdev->config.yres;
119
- stl_le_phys(&s->dma_as, value + 12, tmp_xres);
120
- stl_le_phys(&s->dma_as, value + 16, tmp_yres);
121
+ stl_le_phys(&s->dma_as, value + 12, fbconfig.xres);
122
+ stl_le_phys(&s->dma_as, value + 16, fbconfig.yres);
123
resplen = 8;
124
break;
125
case 0x00044003: /* Test display width/height */
126
@@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value)
127
break;
128
case 0x00048003: /* Set display width/height */
129
case 0x00048004:
130
- xres = ldl_le_phys(&s->dma_as, value + 12);
131
- newxres = &xres;
132
- yres = ldl_le_phys(&s->dma_as, value + 16);
133
- newyres = &yres;
134
+ fbconfig.xres = ldl_le_phys(&s->dma_as, value + 12);
135
+ fbconfig.yres = ldl_le_phys(&s->dma_as, value + 16);
136
+ fbconfig_updated = true;
137
resplen = 8;
138
break;
139
case 0x00040005: /* Get depth */
140
- tmp_bpp = newbpp != NULL ? *newbpp : s->fbdev->config.bpp;
141
- stl_le_phys(&s->dma_as, value + 12, tmp_bpp);
142
+ stl_le_phys(&s->dma_as, value + 12, fbconfig.bpp);
143
resplen = 4;
144
break;
145
case 0x00044005: /* Test depth */
146
resplen = 4;
147
break;
148
case 0x00048005: /* Set depth */
149
- bpp = ldl_le_phys(&s->dma_as, value + 12);
150
- newbpp = &bpp;
151
+ fbconfig.bpp = ldl_le_phys(&s->dma_as, value + 12);
152
+ fbconfig_updated = true;
153
resplen = 4;
154
break;
155
case 0x00040006: /* Get pixel order */
156
- tmp_pixo = newpixo != NULL ? *newpixo : s->fbdev->config.pixo;
157
- stl_le_phys(&s->dma_as, value + 12, tmp_pixo);
158
+ stl_le_phys(&s->dma_as, value + 12, fbconfig.pixo);
159
resplen = 4;
160
break;
161
case 0x00044006: /* Test pixel order */
162
resplen = 4;
163
break;
164
case 0x00048006: /* Set pixel order */
165
- pixo = ldl_le_phys(&s->dma_as, value + 12);
166
- newpixo = &pixo;
167
+ fbconfig.pixo = ldl_le_phys(&s->dma_as, value + 12);
168
+ fbconfig_updated = true;
169
resplen = 4;
170
break;
171
case 0x00040007: /* Get alpha */
172
- tmp_alpha = newalpha != NULL ? *newalpha : s->fbdev->config.alpha;
173
- stl_le_phys(&s->dma_as, value + 12, tmp_alpha);
174
+ stl_le_phys(&s->dma_as, value + 12, fbconfig.alpha);
175
resplen = 4;
176
break;
177
case 0x00044007: /* Test pixel alpha */
178
resplen = 4;
179
break;
180
case 0x00048007: /* Set alpha */
181
- alpha = ldl_le_phys(&s->dma_as, value + 12);
182
- newalpha = &alpha;
183
+ fbconfig.alpha = ldl_le_phys(&s->dma_as, value + 12);
184
+ fbconfig_updated = true;
185
resplen = 4;
186
break;
187
case 0x00040008: /* Get pitch */
188
- tmp_xres = newxres != NULL ? *newxres : s->fbdev->config.xres;
189
- tmp_bpp = newbpp != NULL ? *newbpp : s->fbdev->config.bpp;
190
- stl_le_phys(&s->dma_as, value + 12, tmp_xres * tmp_bpp / 8);
191
+ stl_le_phys(&s->dma_as, value + 12,
192
+ fbconfig.xres * fbconfig.bpp / 8);
193
resplen = 4;
194
break;
195
case 0x00040009: /* Get virtual offset */
196
- tmp_xoffset = newxoffset != NULL ?
197
- *newxoffset : s->fbdev->config.xoffset;
198
- tmp_yoffset = newyoffset != NULL ?
199
- *newyoffset : s->fbdev->config.yoffset;
200
- stl_le_phys(&s->dma_as, value + 12, tmp_xoffset);
201
- stl_le_phys(&s->dma_as, value + 16, tmp_yoffset);
202
+ stl_le_phys(&s->dma_as, value + 12, fbconfig.xoffset);
203
+ stl_le_phys(&s->dma_as, value + 16, fbconfig.yoffset);
204
resplen = 8;
205
break;
206
case 0x00044009: /* Test virtual offset */
207
resplen = 8;
208
break;
209
case 0x00048009: /* Set virtual offset */
210
- xoffset = ldl_le_phys(&s->dma_as, value + 12);
211
- newxoffset = &xoffset;
212
- yoffset = ldl_le_phys(&s->dma_as, value + 16);
213
- newyoffset = &yoffset;
214
+ fbconfig.xoffset = ldl_le_phys(&s->dma_as, value + 12);
215
+ fbconfig.yoffset = ldl_le_phys(&s->dma_as, value + 16);
216
+ fbconfig_updated = true;
217
resplen = 8;
218
break;
219
case 0x0004000a: /* Get/Test/Set overscan */
220
@@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value)
221
}
32
}
222
33
223
/* Reconfigure framebuffer if required */
34
if (unlikely(!mte_probe1_int(env, desc, ptr, ra, bit55))) {
224
- if (newxres || newyres || newxoffset || newyoffset || newbpp || newpixo
35
- int mmu_idx = FIELD_EX32(desc, MTEDESC, MIDX);
225
- || newalpha) {
36
- mte_check_fail(env, mmu_idx, ptr, ra);
226
- bcm2835_fb_reconfigure(s->fbdev, newxres, newyres, newxoffset,
37
+ mte_check_fail(env, desc, ptr, ra);
227
- newyoffset, newbpp, newpixo, newalpha);
228
+ if (fbconfig_updated) {
229
+ bcm2835_fb_reconfigure(s->fbdev, &fbconfig);
230
}
38
}
231
39
232
/* Buffer response code */
40
return useronly_clean_ptr(ptr);
41
@@ -XXX,XX +XXX,XX @@ uint64_t mte_checkN(CPUARMState *env, uint32_t desc,
42
43
fail_ofs = tag_first + n * TAG_GRANULE - ptr;
44
fail_ofs = ROUND_UP(fail_ofs, esize);
45
- mte_check_fail(env, mmu_idx, ptr + fail_ofs, ra);
46
+ mte_check_fail(env, desc, ptr + fail_ofs, ra);
47
}
48
49
done:
50
@@ -XXX,XX +XXX,XX @@ uint64_t HELPER(mte_check_zva)(CPUARMState *env, uint32_t desc, uint64_t ptr)
51
fail:
52
/* Locate the first nibble that differs. */
53
i = ctz64(mem_tag ^ ptr_tag) >> 4;
54
- mte_check_fail(env, mmu_idx, align_ptr + i * TAG_GRANULE, ra);
55
+ mte_check_fail(env, desc, align_ptr + i * TAG_GRANULE, ra);
56
57
done:
58
return useronly_clean_ptr(ptr);
233
--
59
--
234
2.18.0
60
2.20.1
235
61
236
62
diff view generated by jsdifflib
1
Abstract out the calculation of the pitch and size of the
1
From: Richard Henderson <richard.henderson@linaro.org>
2
framebuffer into functions that operate on the BCM2835FBConfig
3
struct -- these are about to get a little more complicated
4
when we add support for virtual and physical sizes differing.
5
2
3
According to AArch64.TagCheckFault, none of the other ISS values are
4
provided, so we do not need to go so far as merge_syn_data_abort.
5
But we were missing the WnR bit.
6
7
Tested-by: Andrey Konovalov <andreyknvl@google.com>
8
Reported-by: Andrey Konovalov <andreyknvl@google.com>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20200813200816.3037186-3-richard.henderson@linaro.org
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20180814144436.679-6-peter.maydell@linaro.org
9
---
13
---
10
include/hw/display/bcm2835_fb.h | 22 ++++++++++++++++++++++
14
target/arm/mte_helper.c | 9 +++++----
11
hw/display/bcm2835_fb.c | 6 +++---
15
1 file changed, 5 insertions(+), 4 deletions(-)
12
hw/misc/bcm2835_property.c | 4 ++--
13
3 files changed, 27 insertions(+), 5 deletions(-)
14
16
15
diff --git a/include/hw/display/bcm2835_fb.h b/include/hw/display/bcm2835_fb.h
17
diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c
16
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/display/bcm2835_fb.h
19
--- a/target/arm/mte_helper.c
18
+++ b/include/hw/display/bcm2835_fb.h
20
+++ b/target/arm/mte_helper.c
19
@@ -XXX,XX +XXX,XX @@ typedef struct {
21
@@ -XXX,XX +XXX,XX @@ static void mte_check_fail(CPUARMState *env, uint32_t desc,
20
22
{
21
void bcm2835_fb_reconfigure(BCM2835FBState *s, BCM2835FBConfig *newconfig);
23
int mmu_idx = FIELD_EX32(desc, MTEDESC, MIDX);
22
24
ARMMMUIdx arm_mmu_idx = core_to_aa64_mmu_idx(mmu_idx);
23
+/**
25
- int el, reg_el, tcf, select;
24
+ * bcm2835_fb_get_pitch: return number of bytes per line of the framebuffer
26
+ int el, reg_el, tcf, select, is_write, syn;
25
+ * @config: configuration info for the framebuffer
27
uint64_t sctlr;
26
+ *
28
27
+ * Return the number of bytes per line of the framebuffer, ie the number
29
reg_el = regime_el(env, arm_mmu_idx);
28
+ * that must be added to a pixel address to get the address of the pixel
30
@@ -XXX,XX +XXX,XX @@ static void mte_check_fail(CPUARMState *env, uint32_t desc,
29
+ * directly below it on screen.
31
*/
30
+ */
32
cpu_restore_state(env_cpu(env), ra, true);
31
+static inline uint32_t bcm2835_fb_get_pitch(BCM2835FBConfig *config)
33
env->exception.vaddress = dirty_ptr;
32
+{
34
- raise_exception(env, EXCP_DATA_ABORT,
33
+ return config->xres * (config->bpp >> 3);
35
- syn_data_abort_no_iss(el != 0, 0, 0, 0, 0, 0, 0x11),
34
+}
36
- exception_target_el(env));
35
+
37
+
36
+/**
38
+ is_write = FIELD_EX32(desc, MTEDESC, WRITE);
37
+ * bcm2835_fb_get_size: return total size of framebuffer in bytes
39
+ syn = syn_data_abort_no_iss(el != 0, 0, 0, 0, 0, is_write, 0x11);
38
+ * @config: configuration info for the framebuffer
40
+ raise_exception(env, EXCP_DATA_ABORT, syn, exception_target_el(env));
39
+ */
41
/* noreturn, but fall through to the assert anyway */
40
+static inline uint32_t bcm2835_fb_get_size(BCM2835FBConfig *config)
42
41
+{
43
case 0:
42
+ return config->yres * bcm2835_fb_get_pitch(config);
43
+}
44
+
45
#endif
46
diff --git a/hw/display/bcm2835_fb.c b/hw/display/bcm2835_fb.c
47
index XXXXXXX..XXXXXXX 100644
48
--- a/hw/display/bcm2835_fb.c
49
+++ b/hw/display/bcm2835_fb.c
50
@@ -XXX,XX +XXX,XX @@ static void fb_update_display(void *opaque)
51
return;
52
}
53
54
- src_width = s->config.xres * (s->config.bpp >> 3);
55
+ src_width = bcm2835_fb_get_pitch(&s->config);
56
dest_width = s->config.xres;
57
58
switch (surface_bits_per_pixel(surface)) {
59
@@ -XXX,XX +XXX,XX @@ static void bcm2835_fb_mbox_push(BCM2835FBState *s, uint32_t value)
60
61
/* TODO - Manage properly virtual resolution */
62
63
- pitch = s->config.xres * (s->config.bpp >> 3);
64
- size = s->config.yres * pitch;
65
+ pitch = bcm2835_fb_get_pitch(&s->config);
66
+ size = bcm2835_fb_get_size(&s->config);
67
68
stl_le_phys(&s->dma_as, value + 16, pitch);
69
stl_le_phys(&s->dma_as, value + 32, s->config.base);
70
diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c
71
index XXXXXXX..XXXXXXX 100644
72
--- a/hw/misc/bcm2835_property.c
73
+++ b/hw/misc/bcm2835_property.c
74
@@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value)
75
case 0x00040001: /* Allocate buffer */
76
stl_le_phys(&s->dma_as, value + 12, fbconfig.base);
77
stl_le_phys(&s->dma_as, value + 16,
78
- fbconfig.xres * fbconfig.yres * fbconfig.bpp / 8);
79
+ bcm2835_fb_get_size(&fbconfig));
80
resplen = 8;
81
break;
82
case 0x00048001: /* Release buffer */
83
@@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value)
84
break;
85
case 0x00040008: /* Get pitch */
86
stl_le_phys(&s->dma_as, value + 12,
87
- fbconfig.xres * fbconfig.bpp / 8);
88
+ bcm2835_fb_get_pitch(&fbconfig));
89
resplen = 4;
90
break;
91
case 0x00040009: /* Get virtual offset */
92
--
44
--
93
2.18.0
45
2.20.1
94
46
95
47
diff view generated by jsdifflib
1
Move from the legacy SysBusDevice::init method to using
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
DeviceState::realize.
3
2
3
Allow the device to execute the DMA transfers in a different
4
AddressSpace.
5
6
The A10 and H3 SoC keep using the system_memory address space,
7
but via the proper dma_memory_access() API.
8
9
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com>
11
Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>
12
Message-id: 20200814110057.307-1-f4bug@amsat.org
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Message-id: 20180820141116.9118-19-peter.maydell@linaro.org
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
---
14
---
9
hw/ssi/pl022.c | 8 +++-----
15
include/hw/sd/allwinner-sdhost.h | 6 ++++++
10
1 file changed, 3 insertions(+), 5 deletions(-)
16
hw/arm/allwinner-a10.c | 2 ++
17
hw/arm/allwinner-h3.c | 2 ++
18
hw/sd/allwinner-sdhost.c | 37 ++++++++++++++++++++++++++------
19
4 files changed, 41 insertions(+), 6 deletions(-)
11
20
12
diff --git a/hw/ssi/pl022.c b/hw/ssi/pl022.c
21
diff --git a/include/hw/sd/allwinner-sdhost.h b/include/hw/sd/allwinner-sdhost.h
13
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/ssi/pl022.c
23
--- a/include/hw/sd/allwinner-sdhost.h
15
+++ b/hw/ssi/pl022.c
24
+++ b/include/hw/sd/allwinner-sdhost.h
16
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_pl022 = {
25
@@ -XXX,XX +XXX,XX @@ typedef struct AwSdHostState {
26
/** Interrupt output signal to notify CPU */
27
qemu_irq irq;
28
29
+ /** Memory region where DMA transfers are done */
30
+ MemoryRegion *dma_mr;
31
+
32
+ /** Address space used internally for DMA transfers */
33
+ AddressSpace dma_as;
34
+
35
/** Number of bytes left in current DMA transfer */
36
uint32_t transfer_cnt;
37
38
diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
39
index XXXXXXX..XXXXXXX 100644
40
--- a/hw/arm/allwinner-a10.c
41
+++ b/hw/arm/allwinner-a10.c
42
@@ -XXX,XX +XXX,XX @@ static void aw_a10_realize(DeviceState *dev, Error **errp)
43
}
44
45
/* SD/MMC */
46
+ object_property_set_link(OBJECT(&s->mmc0), "dma-memory",
47
+ OBJECT(get_system_memory()), &error_fatal);
48
sysbus_realize(SYS_BUS_DEVICE(&s->mmc0), &error_fatal);
49
sysbus_mmio_map(SYS_BUS_DEVICE(&s->mmc0), 0, AW_A10_MMC0_BASE);
50
sysbus_connect_irq(SYS_BUS_DEVICE(&s->mmc0), 0, qdev_get_gpio_in(dev, 32));
51
diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
52
index XXXXXXX..XXXXXXX 100644
53
--- a/hw/arm/allwinner-h3.c
54
+++ b/hw/arm/allwinner-h3.c
55
@@ -XXX,XX +XXX,XX @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp)
56
sysbus_mmio_map(SYS_BUS_DEVICE(&s->sid), 0, s->memmap[AW_H3_SID]);
57
58
/* SD/MMC */
59
+ object_property_set_link(OBJECT(&s->mmc0), "dma-memory",
60
+ OBJECT(get_system_memory()), &error_fatal);
61
sysbus_realize(SYS_BUS_DEVICE(&s->mmc0), &error_fatal);
62
sysbus_mmio_map(SYS_BUS_DEVICE(&s->mmc0), 0, s->memmap[AW_H3_MMC0]);
63
sysbus_connect_irq(SYS_BUS_DEVICE(&s->mmc0), 0,
64
diff --git a/hw/sd/allwinner-sdhost.c b/hw/sd/allwinner-sdhost.c
65
index XXXXXXX..XXXXXXX 100644
66
--- a/hw/sd/allwinner-sdhost.c
67
+++ b/hw/sd/allwinner-sdhost.c
68
@@ -XXX,XX +XXX,XX @@
69
#include "qemu/log.h"
70
#include "qemu/module.h"
71
#include "qemu/units.h"
72
+#include "qapi/error.h"
73
#include "sysemu/blockdev.h"
74
+#include "sysemu/dma.h"
75
+#include "hw/qdev-properties.h"
76
#include "hw/irq.h"
77
#include "hw/sd/allwinner-sdhost.h"
78
#include "migration/vmstate.h"
79
@@ -XXX,XX +XXX,XX @@ static uint32_t allwinner_sdhost_process_desc(AwSdHostState *s,
80
uint8_t buf[1024];
81
82
/* Read descriptor */
83
- cpu_physical_memory_read(desc_addr, desc, sizeof(*desc));
84
+ dma_memory_read(&s->dma_as, desc_addr, desc, sizeof(*desc));
85
if (desc->size == 0) {
86
desc->size = klass->max_desc_size;
87
} else if (desc->size > klass->max_desc_size) {
88
@@ -XXX,XX +XXX,XX @@ static uint32_t allwinner_sdhost_process_desc(AwSdHostState *s,
89
90
/* Write to SD bus */
91
if (is_write) {
92
- cpu_physical_memory_read((desc->addr & DESC_SIZE_MASK) + num_done,
93
- buf, buf_bytes);
94
+ dma_memory_read(&s->dma_as,
95
+ (desc->addr & DESC_SIZE_MASK) + num_done,
96
+ buf, buf_bytes);
97
sdbus_write_data(&s->sdbus, buf, buf_bytes);
98
99
/* Read from SD bus */
100
} else {
101
sdbus_read_data(&s->sdbus, buf, buf_bytes);
102
- cpu_physical_memory_write((desc->addr & DESC_SIZE_MASK) + num_done,
103
- buf, buf_bytes);
104
+ dma_memory_write(&s->dma_as,
105
+ (desc->addr & DESC_SIZE_MASK) + num_done,
106
+ buf, buf_bytes);
107
}
108
num_done += buf_bytes;
109
}
110
111
/* Clear hold flag and flush descriptor */
112
desc->status &= ~DESC_STATUS_HOLD;
113
- cpu_physical_memory_write(desc_addr, desc, sizeof(*desc));
114
+ dma_memory_write(&s->dma_as, desc_addr, desc, sizeof(*desc));
115
116
return num_done;
117
}
118
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_allwinner_sdhost = {
17
}
119
}
18
};
120
};
19
121
20
-static int pl022_init(SysBusDevice *sbd)
122
+static Property allwinner_sdhost_properties[] = {
21
+static void pl022_realize(DeviceState *dev, Error **errp)
123
+ DEFINE_PROP_LINK("dma-memory", AwSdHostState, dma_mr,
124
+ TYPE_MEMORY_REGION, MemoryRegion *),
125
+ DEFINE_PROP_END_OF_LIST(),
126
+};
127
+
128
static void allwinner_sdhost_init(Object *obj)
22
{
129
{
23
- DeviceState *dev = DEVICE(sbd);
130
AwSdHostState *s = AW_SDHOST(obj);
24
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
131
@@ -XXX,XX +XXX,XX @@ static void allwinner_sdhost_init(Object *obj)
25
PL022State *s = PL022(dev);
132
sysbus_init_irq(SYS_BUS_DEVICE(s), &s->irq);
26
27
memory_region_init_io(&s->iomem, OBJECT(s), &pl022_ops, s, "pl022", 0x1000);
28
sysbus_init_mmio(sbd, &s->iomem);
29
sysbus_init_irq(sbd, &s->irq);
30
s->ssi = ssi_create_bus(dev, "ssi");
31
- return 0;
32
}
133
}
33
134
34
static void pl022_class_init(ObjectClass *klass, void *data)
135
+static void allwinner_sdhost_realize(DeviceState *dev, Error **errp)
136
+{
137
+ AwSdHostState *s = AW_SDHOST(dev);
138
+
139
+ if (!s->dma_mr) {
140
+ error_setg(errp, TYPE_AW_SDHOST " 'dma-memory' link not set");
141
+ return;
142
+ }
143
+
144
+ address_space_init(&s->dma_as, s->dma_mr, "sdhost-dma");
145
+}
146
+
147
static void allwinner_sdhost_reset(DeviceState *dev)
35
{
148
{
36
- SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
149
AwSdHostState *s = AW_SDHOST(dev);
37
DeviceClass *dc = DEVICE_CLASS(klass);
150
@@ -XXX,XX +XXX,XX @@ static void allwinner_sdhost_class_init(ObjectClass *klass, void *data)
38
151
39
- sdc->init = pl022_init;
152
dc->reset = allwinner_sdhost_reset;
40
dc->reset = pl022_reset;
153
dc->vmsd = &vmstate_allwinner_sdhost;
41
dc->vmsd = &vmstate_pl022;
154
+ dc->realize = allwinner_sdhost_realize;
42
+ dc->realize = pl022_realize;
155
+ device_class_set_props(dc, allwinner_sdhost_properties);
43
}
156
}
44
157
45
static const TypeInfo pl022_info = {
158
static void allwinner_sdhost_sun4i_class_init(ObjectClass *klass, void *data)
46
--
159
--
47
2.18.0
160
2.20.1
48
161
49
162
diff view generated by jsdifflib
1
The handling of framebuffer properties in the bcm2835_property code
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
is a bit clumsy, because for each of the many fb related properties
2
3
we try to track the value we're about to set and whether we're going
3
Allow the device to execute the DMA transfers in a different
4
to be setting a value, and then we hand all the new values off
4
AddressSpace.
5
to the framebuffer via a function which takes them all as separate
5
6
arguments. It would be simpler if the property code could easily
6
The H3 SoC keeps using the system_memory address space,
7
copy all the framebuffer's current settings, update them with
7
but via the proper dma_memory_access() API.
8
the new specified values and then ask the framebuffer to switch
8
9
to the new set.
9
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
As the first part of this refactoring, pull all the fb config
11
Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>
12
settings fields in BCM2835FBState out into their own struct.
12
Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com>
13
13
Message-id: 20200814122907.27732-1-f4bug@amsat.org
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
16
Message-id: 20180814144436.679-2-peter.maydell@linaro.org
17
---
15
---
18
include/hw/display/bcm2835_fb.h | 26 ++++++--
16
include/hw/net/allwinner-sun8i-emac.h | 6 ++++
19
hw/display/bcm2835_fb.c | 114 +++++++++++++++++---------------
17
hw/arm/allwinner-h3.c | 2 ++
20
hw/misc/bcm2835_property.c | 28 ++++----
18
hw/net/allwinner-sun8i-emac.c | 46 +++++++++++++++++----------
21
3 files changed, 94 insertions(+), 74 deletions(-)
19
3 files changed, 38 insertions(+), 16 deletions(-)
22
20
23
diff --git a/include/hw/display/bcm2835_fb.h b/include/hw/display/bcm2835_fb.h
21
diff --git a/include/hw/net/allwinner-sun8i-emac.h b/include/hw/net/allwinner-sun8i-emac.h
24
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
25
--- a/include/hw/display/bcm2835_fb.h
23
--- a/include/hw/net/allwinner-sun8i-emac.h
26
+++ b/include/hw/display/bcm2835_fb.h
24
+++ b/include/hw/net/allwinner-sun8i-emac.h
25
@@ -XXX,XX +XXX,XX @@ typedef struct AwSun8iEmacState {
26
/** Interrupt output signal to notify CPU */
27
qemu_irq irq;
28
29
+ /** Memory region where DMA transfers are done */
30
+ MemoryRegion *dma_mr;
31
+
32
+ /** Address space used internally for DMA transfers */
33
+ AddressSpace dma_as;
34
+
35
/** Generic Network Interface Controller (NIC) for networking API */
36
NICState *nic;
37
38
diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
39
index XXXXXXX..XXXXXXX 100644
40
--- a/hw/arm/allwinner-h3.c
41
+++ b/hw/arm/allwinner-h3.c
42
@@ -XXX,XX +XXX,XX @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp)
43
qemu_check_nic_model(&nd_table[0], TYPE_AW_SUN8I_EMAC);
44
qdev_set_nic_properties(DEVICE(&s->emac), &nd_table[0]);
45
}
46
+ object_property_set_link(OBJECT(&s->emac), "dma-memory",
47
+ OBJECT(get_system_memory()), &error_fatal);
48
sysbus_realize(SYS_BUS_DEVICE(&s->emac), &error_fatal);
49
sysbus_mmio_map(SYS_BUS_DEVICE(&s->emac), 0, s->memmap[AW_H3_EMAC]);
50
sysbus_connect_irq(SYS_BUS_DEVICE(&s->emac), 0,
51
diff --git a/hw/net/allwinner-sun8i-emac.c b/hw/net/allwinner-sun8i-emac.c
52
index XXXXXXX..XXXXXXX 100644
53
--- a/hw/net/allwinner-sun8i-emac.c
54
+++ b/hw/net/allwinner-sun8i-emac.c
27
@@ -XXX,XX +XXX,XX @@
55
@@ -XXX,XX +XXX,XX @@
28
#define TYPE_BCM2835_FB "bcm2835-fb"
56
29
#define BCM2835_FB(obj) OBJECT_CHECK(BCM2835FBState, (obj), TYPE_BCM2835_FB)
57
#include "qemu/osdep.h"
30
58
#include "qemu/units.h"
31
+/*
59
+#include "qapi/error.h"
32
+ * Configuration information about the fb which the guest can program
60
#include "hw/sysbus.h"
33
+ * via the mailbox property interface.
61
#include "migration/vmstate.h"
34
+ */
62
#include "net/net.h"
35
+typedef struct {
63
@@ -XXX,XX +XXX,XX @@
36
+ uint32_t xres, yres;
64
#include "net/checksum.h"
37
+ uint32_t xres_virtual, yres_virtual;
65
#include "qemu/module.h"
38
+ uint32_t xoffset, yoffset;
66
#include "exec/cpu-common.h"
39
+ uint32_t bpp;
67
+#include "sysemu/dma.h"
40
+ uint32_t base;
68
#include "hw/net/allwinner-sun8i-emac.h"
41
+ uint32_t pixo;
69
42
+ uint32_t alpha;
70
/* EMAC register offsets */
43
+} BCM2835FBConfig;
71
@@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_update_irq(AwSun8iEmacState *s)
44
+
72
qemu_set_irq(s->irq, (s->int_sta & s->int_en) != 0);
45
typedef struct {
73
}
46
/*< private >*/
74
47
SysBusDevice busdev;
75
-static uint32_t allwinner_sun8i_emac_next_desc(FrameDescriptor *desc,
48
@@ -XXX,XX +XXX,XX @@ typedef struct {
76
+static uint32_t allwinner_sun8i_emac_next_desc(AwSun8iEmacState *s,
49
qemu_irq mbox_irq;
77
+ FrameDescriptor *desc,
50
78
size_t min_size)
51
bool lock, invalidate, pending;
79
{
52
- uint32_t xres, yres;
80
uint32_t paddr = desc->next;
53
- uint32_t xres_virtual, yres_virtual;
81
54
- uint32_t xoffset, yoffset;
82
- cpu_physical_memory_read(paddr, desc, sizeof(*desc));
55
- uint32_t bpp;
83
+ dma_memory_read(&s->dma_as, paddr, desc, sizeof(*desc));
56
- uint32_t base, pitch, size;
84
57
- uint32_t pixo, alpha;
85
if ((desc->status & DESC_STATUS_CTL) &&
58
+
86
(desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_size) {
59
+ BCM2835FBConfig config;
87
@@ -XXX,XX +XXX,XX @@ static uint32_t allwinner_sun8i_emac_next_desc(FrameDescriptor *desc,
60
+
88
}
61
+ /* These are just cached values calculated from the config settings */
89
}
62
+ uint32_t size;
90
63
+ uint32_t pitch;
91
-static uint32_t allwinner_sun8i_emac_get_desc(FrameDescriptor *desc,
64
} BCM2835FBState;
92
+static uint32_t allwinner_sun8i_emac_get_desc(AwSun8iEmacState *s,
65
93
+ FrameDescriptor *desc,
66
void bcm2835_fb_reconfigure(BCM2835FBState *s, uint32_t *xres, uint32_t *yres,
94
uint32_t start_addr,
67
diff --git a/hw/display/bcm2835_fb.c b/hw/display/bcm2835_fb.c
95
size_t min_size)
68
index XXXXXXX..XXXXXXX 100644
96
{
69
--- a/hw/display/bcm2835_fb.c
97
@@ -XXX,XX +XXX,XX @@ static uint32_t allwinner_sun8i_emac_get_desc(FrameDescriptor *desc,
70
+++ b/hw/display/bcm2835_fb.c
98
71
@@ -XXX,XX +XXX,XX @@ static void draw_line_src16(void *opaque, uint8_t *dst, const uint8_t *src,
99
/* Note that the list is a cycle. Last entry points back to the head. */
72
int bpp = surface_bits_per_pixel(surface);
100
while (desc_addr != 0) {
73
101
- cpu_physical_memory_read(desc_addr, desc, sizeof(*desc));
74
while (width--) {
102
+ dma_memory_read(&s->dma_as, desc_addr, desc, sizeof(*desc));
75
- switch (s->bpp) {
103
76
+ switch (s->config.bpp) {
104
if ((desc->status & DESC_STATUS_CTL) &&
77
case 8:
105
(desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_size) {
78
/* lookup palette starting at video ram base
106
@@ -XXX,XX +XXX,XX @@ static uint32_t allwinner_sun8i_emac_rx_desc(AwSun8iEmacState *s,
79
* TODO: cache translation, rather than doing this each time!
107
FrameDescriptor *desc,
80
@@ -XXX,XX +XXX,XX @@ static void draw_line_src16(void *opaque, uint8_t *dst, const uint8_t *src,
108
size_t min_size)
109
{
110
- return allwinner_sun8i_emac_get_desc(desc, s->rx_desc_curr, min_size);
111
+ return allwinner_sun8i_emac_get_desc(s, desc, s->rx_desc_curr, min_size);
112
}
113
114
static uint32_t allwinner_sun8i_emac_tx_desc(AwSun8iEmacState *s,
115
FrameDescriptor *desc,
116
size_t min_size)
117
{
118
- return allwinner_sun8i_emac_get_desc(desc, s->tx_desc_head, min_size);
119
+ return allwinner_sun8i_emac_get_desc(s, desc, s->tx_desc_head, min_size);
120
}
121
122
-static void allwinner_sun8i_emac_flush_desc(FrameDescriptor *desc,
123
+static void allwinner_sun8i_emac_flush_desc(AwSun8iEmacState *s,
124
+ FrameDescriptor *desc,
125
uint32_t phys_addr)
126
{
127
- cpu_physical_memory_write(phys_addr, desc, sizeof(*desc));
128
+ dma_memory_write(&s->dma_as, phys_addr, desc, sizeof(*desc));
129
}
130
131
static bool allwinner_sun8i_emac_can_receive(NetClientState *nc)
132
@@ -XXX,XX +XXX,XX @@ static ssize_t allwinner_sun8i_emac_receive(NetClientState *nc,
133
<< RX_DESC_STATUS_FRM_LEN_SHIFT;
134
}
135
136
- cpu_physical_memory_write(desc.addr, buf, desc_bytes);
137
- allwinner_sun8i_emac_flush_desc(&desc, s->rx_desc_curr);
138
+ dma_memory_write(&s->dma_as, desc.addr, buf, desc_bytes);
139
+ allwinner_sun8i_emac_flush_desc(s, &desc, s->rx_desc_curr);
140
trace_allwinner_sun8i_emac_receive(s->rx_desc_curr, desc.addr,
141
desc_bytes);
142
143
@@ -XXX,XX +XXX,XX @@ static ssize_t allwinner_sun8i_emac_receive(NetClientState *nc,
144
bytes_left -= desc_bytes;
145
146
/* Move to the next descriptor */
147
- s->rx_desc_curr = allwinner_sun8i_emac_next_desc(&desc, 64);
148
+ s->rx_desc_curr = allwinner_sun8i_emac_next_desc(s, &desc, 64);
149
if (!s->rx_desc_curr) {
150
/* Not enough buffer space available */
151
s->int_sta |= INT_STA_RX_BUF_UA;
152
@@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_transmit(AwSun8iEmacState *s)
153
desc.status |= TX_DESC_STATUS_LENGTH_ERR;
81
break;
154
break;
82
}
155
}
83
156
- cpu_physical_memory_read(desc.addr, packet_buf + packet_bytes, bytes);
84
- if (s->pixo == 0) {
157
+ dma_memory_read(&s->dma_as, desc.addr, packet_buf + packet_bytes, bytes);
85
+ if (s->config.pixo == 0) {
158
packet_bytes += bytes;
86
/* swap to BGR pixel format */
159
desc.status &= ~DESC_STATUS_CTL;
87
uint8_t tmp = r;
160
- allwinner_sun8i_emac_flush_desc(&desc, s->tx_desc_curr);
88
r = b;
161
+ allwinner_sun8i_emac_flush_desc(s, &desc, s->tx_desc_curr);
89
@@ -XXX,XX +XXX,XX @@ static void fb_update_display(void *opaque)
162
90
int src_width = 0;
163
/* After the last descriptor, send the packet */
91
int dest_width = 0;
164
if (desc.status2 & TX_DESC_STATUS2_LAST_DESC) {
92
165
@@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_transmit(AwSun8iEmacState *s)
93
- if (s->lock || !s->xres) {
166
packet_bytes = 0;
94
+ if (s->lock || !s->config.xres) {
167
transmitted++;
95
return;
168
}
169
- s->tx_desc_curr = allwinner_sun8i_emac_next_desc(&desc, 0);
170
+ s->tx_desc_curr = allwinner_sun8i_emac_next_desc(s, &desc, 0);
96
}
171
}
97
172
98
- src_width = s->xres * (s->bpp >> 3);
173
/* Raise transmit completed interrupt */
99
- dest_width = s->xres;
174
@@ -XXX,XX +XXX,XX @@ static uint64_t allwinner_sun8i_emac_read(void *opaque, hwaddr offset,
100
+ src_width = s->config.xres * (s->config.bpp >> 3);
175
break;
101
+ dest_width = s->config.xres;
176
case REG_TX_CUR_BUF: /* Transmit Current Buffer */
102
177
if (s->tx_desc_curr != 0) {
103
switch (surface_bits_per_pixel(surface)) {
178
- cpu_physical_memory_read(s->tx_desc_curr, &desc, sizeof(desc));
104
case 0:
179
+ dma_memory_read(&s->dma_as, s->tx_desc_curr, &desc, sizeof(desc));
105
@@ -XXX,XX +XXX,XX @@ static void fb_update_display(void *opaque)
180
value = desc.addr;
106
}
181
} else {
107
182
value = 0;
108
if (s->invalidate) {
183
@@ -XXX,XX +XXX,XX @@ static uint64_t allwinner_sun8i_emac_read(void *opaque, hwaddr offset,
109
- framebuffer_update_memory_section(&s->fbsection, s->dma_mr, s->base,
184
break;
110
- s->yres, src_width);
185
case REG_RX_CUR_BUF: /* Receive Current Buffer */
111
+ framebuffer_update_memory_section(&s->fbsection, s->dma_mr,
186
if (s->rx_desc_curr != 0) {
112
+ s->config.base,
187
- cpu_physical_memory_read(s->rx_desc_curr, &desc, sizeof(desc));
113
+ s->config.yres, src_width);
188
+ dma_memory_read(&s->dma_as, s->rx_desc_curr, &desc, sizeof(desc));
114
}
189
value = desc.addr;
115
190
} else {
116
- framebuffer_update_display(surface, &s->fbsection, s->xres, s->yres,
191
value = 0;
117
+ framebuffer_update_display(surface, &s->fbsection,
192
@@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_realize(DeviceState *dev, Error **errp)
118
+ s->config.xres, s->config.yres,
193
{
119
src_width, dest_width, 0, s->invalidate,
194
AwSun8iEmacState *s = AW_SUN8I_EMAC(dev);
120
draw_line_src16, s, &first, &last);
195
121
196
+ if (!s->dma_mr) {
122
if (first >= 0) {
197
+ error_setg(errp, TYPE_AW_SUN8I_EMAC " 'dma-memory' link not set");
123
- dpy_gfx_update(s->con, 0, first, s->xres, last - first + 1);
198
+ return;
124
+ dpy_gfx_update(s->con, 0, first, s->config.xres, last - first + 1);
199
+ }
125
}
200
+
126
201
+ address_space_init(&s->dma_as, s->dma_mr, "emac-dma");
127
s->invalidate = false;
202
+
128
@@ -XXX,XX +XXX,XX @@ static void bcm2835_fb_mbox_push(BCM2835FBState *s, uint32_t value)
203
qemu_macaddr_default_if_unset(&s->conf.macaddr);
129
204
s->nic = qemu_new_nic(&net_allwinner_sun8i_emac_info, &s->conf,
130
s->lock = true;
205
object_get_typename(OBJECT(dev)), dev->id, s);
131
206
@@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_realize(DeviceState *dev, Error **errp)
132
- s->xres = ldl_le_phys(&s->dma_as, value);
207
static Property allwinner_sun8i_emac_properties[] = {
133
- s->yres = ldl_le_phys(&s->dma_as, value + 4);
208
DEFINE_NIC_PROPERTIES(AwSun8iEmacState, conf),
134
- s->xres_virtual = ldl_le_phys(&s->dma_as, value + 8);
209
DEFINE_PROP_UINT8("phy-addr", AwSun8iEmacState, mii_phy_addr, 0),
135
- s->yres_virtual = ldl_le_phys(&s->dma_as, value + 12);
210
+ DEFINE_PROP_LINK("dma-memory", AwSun8iEmacState, dma_mr,
136
- s->bpp = ldl_le_phys(&s->dma_as, value + 20);
211
+ TYPE_MEMORY_REGION, MemoryRegion *),
137
- s->xoffset = ldl_le_phys(&s->dma_as, value + 24);
212
DEFINE_PROP_END_OF_LIST(),
138
- s->yoffset = ldl_le_phys(&s->dma_as, value + 28);
139
+ s->config.xres = ldl_le_phys(&s->dma_as, value);
140
+ s->config.yres = ldl_le_phys(&s->dma_as, value + 4);
141
+ s->config.xres_virtual = ldl_le_phys(&s->dma_as, value + 8);
142
+ s->config.yres_virtual = ldl_le_phys(&s->dma_as, value + 12);
143
+ s->config.bpp = ldl_le_phys(&s->dma_as, value + 20);
144
+ s->config.xoffset = ldl_le_phys(&s->dma_as, value + 24);
145
+ s->config.yoffset = ldl_le_phys(&s->dma_as, value + 28);
146
147
- s->base = s->vcram_base | (value & 0xc0000000);
148
- s->base += BCM2835_FB_OFFSET;
149
+ s->config.base = s->vcram_base | (value & 0xc0000000);
150
+ s->config.base += BCM2835_FB_OFFSET;
151
152
/* TODO - Manage properly virtual resolution */
153
154
- s->pitch = s->xres * (s->bpp >> 3);
155
- s->size = s->yres * s->pitch;
156
+ s->pitch = s->config.xres * (s->config.bpp >> 3);
157
+ s->size = s->config.yres * s->pitch;
158
159
stl_le_phys(&s->dma_as, value + 16, s->pitch);
160
- stl_le_phys(&s->dma_as, value + 32, s->base);
161
+ stl_le_phys(&s->dma_as, value + 32, s->config.base);
162
stl_le_phys(&s->dma_as, value + 36, s->size);
163
164
s->invalidate = true;
165
- qemu_console_resize(s->con, s->xres, s->yres);
166
+ qemu_console_resize(s->con, s->config.xres, s->config.yres);
167
s->lock = false;
168
}
169
170
@@ -XXX,XX +XXX,XX @@ void bcm2835_fb_reconfigure(BCM2835FBState *s, uint32_t *xres, uint32_t *yres,
171
172
/* TODO: input validation! */
173
if (xres) {
174
- s->xres = *xres;
175
+ s->config.xres = *xres;
176
}
177
if (yres) {
178
- s->yres = *yres;
179
+ s->config.yres = *yres;
180
}
181
if (xoffset) {
182
- s->xoffset = *xoffset;
183
+ s->config.xoffset = *xoffset;
184
}
185
if (yoffset) {
186
- s->yoffset = *yoffset;
187
+ s->config.yoffset = *yoffset;
188
}
189
if (bpp) {
190
- s->bpp = *bpp;
191
+ s->config.bpp = *bpp;
192
}
193
if (pixo) {
194
- s->pixo = *pixo;
195
+ s->config.pixo = *pixo;
196
}
197
if (alpha) {
198
- s->alpha = *alpha;
199
+ s->config.alpha = *alpha;
200
}
201
202
/* TODO - Manage properly virtual resolution */
203
204
- s->pitch = s->xres * (s->bpp >> 3);
205
- s->size = s->yres * s->pitch;
206
+ s->pitch = s->config.xres * (s->config.bpp >> 3);
207
+ s->size = s->config.yres * s->pitch;
208
209
s->invalidate = true;
210
- qemu_console_resize(s->con, s->xres, s->yres);
211
+ qemu_console_resize(s->con, s->config.xres, s->config.yres);
212
s->lock = false;
213
}
214
215
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_bcm2835_fb = {
216
VMSTATE_BOOL(lock, BCM2835FBState),
217
VMSTATE_BOOL(invalidate, BCM2835FBState),
218
VMSTATE_BOOL(pending, BCM2835FBState),
219
- VMSTATE_UINT32(xres, BCM2835FBState),
220
- VMSTATE_UINT32(yres, BCM2835FBState),
221
- VMSTATE_UINT32(xres_virtual, BCM2835FBState),
222
- VMSTATE_UINT32(yres_virtual, BCM2835FBState),
223
- VMSTATE_UINT32(xoffset, BCM2835FBState),
224
- VMSTATE_UINT32(yoffset, BCM2835FBState),
225
- VMSTATE_UINT32(bpp, BCM2835FBState),
226
- VMSTATE_UINT32(base, BCM2835FBState),
227
+ VMSTATE_UINT32(config.xres, BCM2835FBState),
228
+ VMSTATE_UINT32(config.yres, BCM2835FBState),
229
+ VMSTATE_UINT32(config.xres_virtual, BCM2835FBState),
230
+ VMSTATE_UINT32(config.yres_virtual, BCM2835FBState),
231
+ VMSTATE_UINT32(config.xoffset, BCM2835FBState),
232
+ VMSTATE_UINT32(config.yoffset, BCM2835FBState),
233
+ VMSTATE_UINT32(config.bpp, BCM2835FBState),
234
+ VMSTATE_UINT32(config.base, BCM2835FBState),
235
VMSTATE_UINT32(pitch, BCM2835FBState),
236
VMSTATE_UINT32(size, BCM2835FBState),
237
- VMSTATE_UINT32(pixo, BCM2835FBState),
238
- VMSTATE_UINT32(alpha, BCM2835FBState),
239
+ VMSTATE_UINT32(config.pixo, BCM2835FBState),
240
+ VMSTATE_UINT32(config.alpha, BCM2835FBState),
241
VMSTATE_END_OF_LIST()
242
}
243
};
213
};
244
@@ -XXX,XX +XXX,XX @@ static void bcm2835_fb_reset(DeviceState *dev)
214
245
246
s->pending = false;
247
248
- s->xres_virtual = s->xres;
249
- s->yres_virtual = s->yres;
250
- s->xoffset = 0;
251
- s->yoffset = 0;
252
- s->base = s->vcram_base + BCM2835_FB_OFFSET;
253
- s->pitch = s->xres * (s->bpp >> 3);
254
- s->size = s->yres * s->pitch;
255
+ s->config.xres_virtual = s->config.xres;
256
+ s->config.yres_virtual = s->config.yres;
257
+ s->config.xoffset = 0;
258
+ s->config.yoffset = 0;
259
+ s->config.base = s->vcram_base + BCM2835_FB_OFFSET;
260
+ s->pitch = s->config.xres * (s->config.bpp >> 3);
261
+ s->size = s->config.yres * s->pitch;
262
263
s->invalidate = true;
264
s->lock = false;
265
@@ -XXX,XX +XXX,XX @@ static void bcm2835_fb_realize(DeviceState *dev, Error **errp)
266
bcm2835_fb_reset(dev);
267
268
s->con = graphic_console_init(dev, 0, &vgafb_ops, s);
269
- qemu_console_resize(s->con, s->xres, s->yres);
270
+ qemu_console_resize(s->con, s->config.xres, s->config.yres);
271
}
272
273
static Property bcm2835_fb_props[] = {
274
DEFINE_PROP_UINT32("vcram-base", BCM2835FBState, vcram_base, 0),/*required*/
275
DEFINE_PROP_UINT32("vcram-size", BCM2835FBState, vcram_size,
276
DEFAULT_VCRAM_SIZE),
277
- DEFINE_PROP_UINT32("xres", BCM2835FBState, xres, 640),
278
- DEFINE_PROP_UINT32("yres", BCM2835FBState, yres, 480),
279
- DEFINE_PROP_UINT32("bpp", BCM2835FBState, bpp, 16),
280
- DEFINE_PROP_UINT32("pixo", BCM2835FBState, pixo, 1), /* 1=RGB, 0=BGR */
281
- DEFINE_PROP_UINT32("alpha", BCM2835FBState, alpha, 2), /* alpha ignored */
282
+ DEFINE_PROP_UINT32("xres", BCM2835FBState, config.xres, 640),
283
+ DEFINE_PROP_UINT32("yres", BCM2835FBState, config.yres, 480),
284
+ DEFINE_PROP_UINT32("bpp", BCM2835FBState, config.bpp, 16),
285
+ DEFINE_PROP_UINT32("pixo",
286
+ BCM2835FBState, config.pixo, 1), /* 1=RGB, 0=BGR */
287
+ DEFINE_PROP_UINT32("alpha",
288
+ BCM2835FBState, config.alpha, 2), /* alpha ignored */
289
DEFINE_PROP_END_OF_LIST()
290
};
291
292
diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c
293
index XXXXXXX..XXXXXXX 100644
294
--- a/hw/misc/bcm2835_property.c
295
+++ b/hw/misc/bcm2835_property.c
296
@@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value)
297
/* Frame buffer */
298
299
case 0x00040001: /* Allocate buffer */
300
- stl_le_phys(&s->dma_as, value + 12, s->fbdev->base);
301
- tmp_xres = newxres != NULL ? *newxres : s->fbdev->xres;
302
- tmp_yres = newyres != NULL ? *newyres : s->fbdev->yres;
303
- tmp_bpp = newbpp != NULL ? *newbpp : s->fbdev->bpp;
304
+ stl_le_phys(&s->dma_as, value + 12, s->fbdev->config.base);
305
+ tmp_xres = newxres != NULL ? *newxres : s->fbdev->config.xres;
306
+ tmp_yres = newyres != NULL ? *newyres : s->fbdev->config.yres;
307
+ tmp_bpp = newbpp != NULL ? *newbpp : s->fbdev->config.bpp;
308
stl_le_phys(&s->dma_as, value + 16,
309
tmp_xres * tmp_yres * tmp_bpp / 8);
310
resplen = 8;
311
@@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value)
312
break;
313
case 0x00040003: /* Get display width/height */
314
case 0x00040004:
315
- tmp_xres = newxres != NULL ? *newxres : s->fbdev->xres;
316
- tmp_yres = newyres != NULL ? *newyres : s->fbdev->yres;
317
+ tmp_xres = newxres != NULL ? *newxres : s->fbdev->config.xres;
318
+ tmp_yres = newyres != NULL ? *newyres : s->fbdev->config.yres;
319
stl_le_phys(&s->dma_as, value + 12, tmp_xres);
320
stl_le_phys(&s->dma_as, value + 16, tmp_yres);
321
resplen = 8;
322
@@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value)
323
resplen = 8;
324
break;
325
case 0x00040005: /* Get depth */
326
- tmp_bpp = newbpp != NULL ? *newbpp : s->fbdev->bpp;
327
+ tmp_bpp = newbpp != NULL ? *newbpp : s->fbdev->config.bpp;
328
stl_le_phys(&s->dma_as, value + 12, tmp_bpp);
329
resplen = 4;
330
break;
331
@@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value)
332
resplen = 4;
333
break;
334
case 0x00040006: /* Get pixel order */
335
- tmp_pixo = newpixo != NULL ? *newpixo : s->fbdev->pixo;
336
+ tmp_pixo = newpixo != NULL ? *newpixo : s->fbdev->config.pixo;
337
stl_le_phys(&s->dma_as, value + 12, tmp_pixo);
338
resplen = 4;
339
break;
340
@@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value)
341
resplen = 4;
342
break;
343
case 0x00040007: /* Get alpha */
344
- tmp_alpha = newalpha != NULL ? *newalpha : s->fbdev->alpha;
345
+ tmp_alpha = newalpha != NULL ? *newalpha : s->fbdev->config.alpha;
346
stl_le_phys(&s->dma_as, value + 12, tmp_alpha);
347
resplen = 4;
348
break;
349
@@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value)
350
resplen = 4;
351
break;
352
case 0x00040008: /* Get pitch */
353
- tmp_xres = newxres != NULL ? *newxres : s->fbdev->xres;
354
- tmp_bpp = newbpp != NULL ? *newbpp : s->fbdev->bpp;
355
+ tmp_xres = newxres != NULL ? *newxres : s->fbdev->config.xres;
356
+ tmp_bpp = newbpp != NULL ? *newbpp : s->fbdev->config.bpp;
357
stl_le_phys(&s->dma_as, value + 12, tmp_xres * tmp_bpp / 8);
358
resplen = 4;
359
break;
360
case 0x00040009: /* Get virtual offset */
361
- tmp_xoffset = newxoffset != NULL ? *newxoffset : s->fbdev->xoffset;
362
- tmp_yoffset = newyoffset != NULL ? *newyoffset : s->fbdev->yoffset;
363
+ tmp_xoffset = newxoffset != NULL ?
364
+ *newxoffset : s->fbdev->config.xoffset;
365
+ tmp_yoffset = newyoffset != NULL ?
366
+ *newyoffset : s->fbdev->config.yoffset;
367
stl_le_phys(&s->dma_as, value + 12, tmp_xoffset);
368
stl_le_phys(&s->dma_as, value + 16, tmp_yoffset);
369
resplen = 8;
370
--
215
--
371
2.18.0
216
2.20.1
372
217
373
218
diff view generated by jsdifflib
1
The bcm2835_fb's initial resolution and other parameters are set
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
via QOM properties. We should reset to those initial values on
3
device reset, which means we need to save the QOM property
4
values somewhere that they are not overwritten by guest
5
changes to the framebuffer configuration.
6
2
3
As we want to call qdev_connect_clock_in() before the device
4
is realized, we need to uninline cadence_uart_create() first.
5
6
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Message-id: 20200803105647.22223-2-f4bug@amsat.org
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20180814144436.679-5-peter.maydell@linaro.org
10
---
10
---
11
include/hw/display/bcm2835_fb.h | 1 +
11
include/hw/char/cadence_uart.h | 17 -----------------
12
hw/display/bcm2835_fb.c | 27 +++++++++++++++------------
12
hw/arm/xilinx_zynq.c | 14 ++++++++++++--
13
2 files changed, 16 insertions(+), 12 deletions(-)
13
2 files changed, 12 insertions(+), 19 deletions(-)
14
14
15
diff --git a/include/hw/display/bcm2835_fb.h b/include/hw/display/bcm2835_fb.h
15
diff --git a/include/hw/char/cadence_uart.h b/include/hw/char/cadence_uart.h
16
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/display/bcm2835_fb.h
17
--- a/include/hw/char/cadence_uart.h
18
+++ b/include/hw/display/bcm2835_fb.h
18
+++ b/include/hw/char/cadence_uart.h
19
@@ -XXX,XX +XXX,XX @@ typedef struct {
19
@@ -XXX,XX +XXX,XX @@ typedef struct {
20
bool lock, invalidate, pending;
20
Clock *refclk;
21
21
} CadenceUARTState;
22
BCM2835FBConfig config;
22
23
+ BCM2835FBConfig initial_config;
23
-static inline DeviceState *cadence_uart_create(hwaddr addr,
24
} BCM2835FBState;
24
- qemu_irq irq,
25
25
- Chardev *chr)
26
void bcm2835_fb_reconfigure(BCM2835FBState *s, BCM2835FBConfig *newconfig);
26
-{
27
diff --git a/hw/display/bcm2835_fb.c b/hw/display/bcm2835_fb.c
27
- DeviceState *dev;
28
- SysBusDevice *s;
29
-
30
- dev = qdev_new(TYPE_CADENCE_UART);
31
- s = SYS_BUS_DEVICE(dev);
32
- qdev_prop_set_chr(dev, "chardev", chr);
33
- sysbus_realize_and_unref(s, &error_fatal);
34
- sysbus_mmio_map(s, 0, addr);
35
- sysbus_connect_irq(s, 0, irq);
36
-
37
- return dev;
38
-}
39
-
40
#endif
41
diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
28
index XXXXXXX..XXXXXXX 100644
42
index XXXXXXX..XXXXXXX 100644
29
--- a/hw/display/bcm2835_fb.c
43
--- a/hw/arm/xilinx_zynq.c
30
+++ b/hw/display/bcm2835_fb.c
44
+++ b/hw/arm/xilinx_zynq.c
31
@@ -XXX,XX +XXX,XX @@ static void bcm2835_fb_reset(DeviceState *dev)
45
@@ -XXX,XX +XXX,XX @@ static void zynq_init(MachineState *machine)
32
46
sysbus_create_simple(TYPE_CHIPIDEA, 0xE0002000, pic[53 - IRQ_OFFSET]);
33
s->pending = false;
47
sysbus_create_simple(TYPE_CHIPIDEA, 0xE0003000, pic[76 - IRQ_OFFSET]);
34
48
35
- s->config.xres_virtual = s->config.xres;
49
- dev = cadence_uart_create(0xE0000000, pic[59 - IRQ_OFFSET], serial_hd(0));
36
- s->config.yres_virtual = s->config.yres;
50
+ dev = qdev_new(TYPE_CADENCE_UART);
37
- s->config.xoffset = 0;
51
+ busdev = SYS_BUS_DEVICE(dev);
38
- s->config.yoffset = 0;
52
+ qdev_prop_set_chr(dev, "chardev", serial_hd(0));
39
- s->config.base = s->vcram_base + BCM2835_FB_OFFSET;
53
+ sysbus_realize_and_unref(busdev, &error_fatal);
40
+ s->config = s->initial_config;
54
+ sysbus_mmio_map(busdev, 0, 0xE0000000);
41
55
+ sysbus_connect_irq(busdev, 0, pic[59 - IRQ_OFFSET]);
42
s->invalidate = true;
56
qdev_connect_clock_in(dev, "refclk",
43
s->lock = false;
57
qdev_get_clock_out(slcr, "uart0_ref_clk"));
44
@@ -XXX,XX +XXX,XX @@ static void bcm2835_fb_realize(DeviceState *dev, Error **errp)
58
- dev = cadence_uart_create(0xE0001000, pic[82 - IRQ_OFFSET], serial_hd(1));
45
return;
59
+ dev = qdev_new(TYPE_CADENCE_UART);
46
}
60
+ busdev = SYS_BUS_DEVICE(dev);
47
61
+ qdev_prop_set_chr(dev, "chardev", serial_hd(1));
48
+ /* Fill in the parts of initial_config that are not set by QOM properties */
62
+ sysbus_realize_and_unref(busdev, &error_fatal);
49
+ s->initial_config.xres_virtual = s->initial_config.xres;
63
+ sysbus_mmio_map(busdev, 0, 0xE0001000);
50
+ s->initial_config.yres_virtual = s->initial_config.yres;
64
+ sysbus_connect_irq(busdev, 0, pic[82 - IRQ_OFFSET]);
51
+ s->initial_config.xoffset = 0;
65
qdev_connect_clock_in(dev, "refclk",
52
+ s->initial_config.yoffset = 0;
66
qdev_get_clock_out(slcr, "uart1_ref_clk"));
53
+ s->initial_config.base = s->vcram_base + BCM2835_FB_OFFSET;
54
+
55
s->dma_mr = MEMORY_REGION(obj);
56
address_space_init(&s->dma_as, s->dma_mr, NULL);
57
58
@@ -XXX,XX +XXX,XX @@ static Property bcm2835_fb_props[] = {
59
DEFINE_PROP_UINT32("vcram-base", BCM2835FBState, vcram_base, 0),/*required*/
60
DEFINE_PROP_UINT32("vcram-size", BCM2835FBState, vcram_size,
61
DEFAULT_VCRAM_SIZE),
62
- DEFINE_PROP_UINT32("xres", BCM2835FBState, config.xres, 640),
63
- DEFINE_PROP_UINT32("yres", BCM2835FBState, config.yres, 480),
64
- DEFINE_PROP_UINT32("bpp", BCM2835FBState, config.bpp, 16),
65
- DEFINE_PROP_UINT32("pixo",
66
- BCM2835FBState, config.pixo, 1), /* 1=RGB, 0=BGR */
67
- DEFINE_PROP_UINT32("alpha",
68
- BCM2835FBState, config.alpha, 2), /* alpha ignored */
69
+ DEFINE_PROP_UINT32("xres", BCM2835FBState, initial_config.xres, 640),
70
+ DEFINE_PROP_UINT32("yres", BCM2835FBState, initial_config.yres, 480),
71
+ DEFINE_PROP_UINT32("bpp", BCM2835FBState, initial_config.bpp, 16),
72
+ DEFINE_PROP_UINT32("pixo", BCM2835FBState,
73
+ initial_config.pixo, 1), /* 1=RGB, 0=BGR */
74
+ DEFINE_PROP_UINT32("alpha", BCM2835FBState,
75
+ initial_config.alpha, 2), /* alpha ignored */
76
DEFINE_PROP_END_OF_LIST()
77
};
78
67
79
--
68
--
80
2.18.0
69
2.20.1
81
70
82
71
diff view generated by jsdifflib
1
The BCM2835FBState struct has a 'pitch' field which is a
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
cached copy of xres * (bpp >> 3), and a 'size' field which is
3
a cached copy of pitch * yres. However we don't actually do
4
anything with these fields; delete them. We retain the
5
now-unused slots in the VMState struct for migration
6
compatibility.
7
2
3
Clock canonical name is set in device_set_realized (see the block
4
added to hw/core/qdev.c in commit 0e6934f264).
5
If we connect a clock after the device is realized, this code is
6
not executed. This is currently not a problem as this name is only
7
used for trace events, however this disrupt tracing.
8
9
Fix by calling qdev_connect_clock_in() before realizing.
10
11
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
12
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
13
Message-id: 20200803105647.22223-3-f4bug@amsat.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20180814144436.679-4-peter.maydell@linaro.org
11
---
15
---
12
include/hw/display/bcm2835_fb.h | 4 ----
16
hw/arm/xilinx_zynq.c | 18 +++++++++---------
13
hw/display/bcm2835_fb.c | 19 ++++++++-----------
17
1 file changed, 9 insertions(+), 9 deletions(-)
14
2 files changed, 8 insertions(+), 15 deletions(-)
15
18
16
diff --git a/include/hw/display/bcm2835_fb.h b/include/hw/display/bcm2835_fb.h
19
diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
17
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/display/bcm2835_fb.h
21
--- a/hw/arm/xilinx_zynq.c
19
+++ b/include/hw/display/bcm2835_fb.h
22
+++ b/hw/arm/xilinx_zynq.c
20
@@ -XXX,XX +XXX,XX @@ typedef struct {
23
@@ -XXX,XX +XXX,XX @@ static void zynq_init(MachineState *machine)
21
bool lock, invalidate, pending;
24
1, 0x0066, 0x0022, 0x0000, 0x0000, 0x0555, 0x2aa,
22
25
0);
23
BCM2835FBConfig config;
26
27
- /* Create slcr, keep a pointer to connect clocks */
28
- slcr = qdev_new("xilinx,zynq_slcr");
29
- sysbus_realize_and_unref(SYS_BUS_DEVICE(slcr), &error_fatal);
30
- sysbus_mmio_map(SYS_BUS_DEVICE(slcr), 0, 0xF8000000);
24
-
31
-
25
- /* These are just cached values calculated from the config settings */
32
/* Create the main clock source, and feed slcr with it */
26
- uint32_t size;
33
zynq_machine->ps_clk = CLOCK(object_new(TYPE_CLOCK));
27
- uint32_t pitch;
34
object_property_add_child(OBJECT(zynq_machine), "ps_clk",
28
} BCM2835FBState;
35
OBJECT(zynq_machine->ps_clk));
29
36
object_unref(OBJECT(zynq_machine->ps_clk));
30
void bcm2835_fb_reconfigure(BCM2835FBState *s, BCM2835FBConfig *newconfig);
37
clock_set_hz(zynq_machine->ps_clk, PS_CLK_FREQUENCY);
31
diff --git a/hw/display/bcm2835_fb.c b/hw/display/bcm2835_fb.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/hw/display/bcm2835_fb.c
34
+++ b/hw/display/bcm2835_fb.c
35
@@ -XXX,XX +XXX,XX @@ static void fb_update_display(void *opaque)
36
37
static void bcm2835_fb_mbox_push(BCM2835FBState *s, uint32_t value)
38
{
39
+ uint32_t pitch;
40
+ uint32_t size;
41
+
38
+
42
value &= ~0xf;
39
+ /* Create slcr, keep a pointer to connect clocks */
43
40
+ slcr = qdev_new("xilinx,zynq_slcr");
44
s->lock = true;
41
qdev_connect_clock_in(slcr, "ps_clk", zynq_machine->ps_clk);
45
@@ -XXX,XX +XXX,XX @@ static void bcm2835_fb_mbox_push(BCM2835FBState *s, uint32_t value)
42
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(slcr), &error_fatal);
46
43
+ sysbus_mmio_map(SYS_BUS_DEVICE(slcr), 0, 0xF8000000);
47
/* TODO - Manage properly virtual resolution */
44
48
45
dev = qdev_new(TYPE_A9MPCORE_PRIV);
49
- s->pitch = s->config.xres * (s->config.bpp >> 3);
46
qdev_prop_set_uint32(dev, "num-cpu", 1);
50
- s->size = s->config.yres * s->pitch;
47
@@ -XXX,XX +XXX,XX @@ static void zynq_init(MachineState *machine)
51
+ pitch = s->config.xres * (s->config.bpp >> 3);
48
dev = qdev_new(TYPE_CADENCE_UART);
52
+ size = s->config.yres * pitch;
49
busdev = SYS_BUS_DEVICE(dev);
53
50
qdev_prop_set_chr(dev, "chardev", serial_hd(0));
54
- stl_le_phys(&s->dma_as, value + 16, s->pitch);
51
+ qdev_connect_clock_in(dev, "refclk",
55
+ stl_le_phys(&s->dma_as, value + 16, pitch);
52
+ qdev_get_clock_out(slcr, "uart0_ref_clk"));
56
stl_le_phys(&s->dma_as, value + 32, s->config.base);
53
sysbus_realize_and_unref(busdev, &error_fatal);
57
- stl_le_phys(&s->dma_as, value + 36, s->size);
54
sysbus_mmio_map(busdev, 0, 0xE0000000);
58
+ stl_le_phys(&s->dma_as, value + 36, size);
55
sysbus_connect_irq(busdev, 0, pic[59 - IRQ_OFFSET]);
59
56
- qdev_connect_clock_in(dev, "refclk",
60
s->invalidate = true;
57
- qdev_get_clock_out(slcr, "uart0_ref_clk"));
61
qemu_console_resize(s->con, s->config.xres, s->config.yres);
58
dev = qdev_new(TYPE_CADENCE_UART);
62
@@ -XXX,XX +XXX,XX @@ void bcm2835_fb_reconfigure(BCM2835FBState *s, BCM2835FBConfig *newconfig)
59
busdev = SYS_BUS_DEVICE(dev);
63
60
qdev_prop_set_chr(dev, "chardev", serial_hd(1));
64
/* TODO - Manage properly virtual resolution */
61
+ qdev_connect_clock_in(dev, "refclk",
65
62
+ qdev_get_clock_out(slcr, "uart1_ref_clk"));
66
- s->pitch = s->config.xres * (s->config.bpp >> 3);
63
sysbus_realize_and_unref(busdev, &error_fatal);
67
- s->size = s->config.yres * s->pitch;
64
sysbus_mmio_map(busdev, 0, 0xE0001000);
68
-
65
sysbus_connect_irq(busdev, 0, pic[82 - IRQ_OFFSET]);
69
s->invalidate = true;
66
- qdev_connect_clock_in(dev, "refclk",
70
qemu_console_resize(s->con, s->config.xres, s->config.yres);
67
- qdev_get_clock_out(slcr, "uart1_ref_clk"));
71
s->lock = false;
68
72
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_bcm2835_fb = {
69
sysbus_create_varargs("cadence_ttc", 0xF8001000,
73
VMSTATE_UINT32(config.yoffset, BCM2835FBState),
70
pic[42-IRQ_OFFSET], pic[43-IRQ_OFFSET], pic[44-IRQ_OFFSET], NULL);
74
VMSTATE_UINT32(config.bpp, BCM2835FBState),
75
VMSTATE_UINT32(config.base, BCM2835FBState),
76
- VMSTATE_UINT32(pitch, BCM2835FBState),
77
- VMSTATE_UINT32(size, BCM2835FBState),
78
+ VMSTATE_UNUSED(8), /* Was pitch and size */
79
VMSTATE_UINT32(config.pixo, BCM2835FBState),
80
VMSTATE_UINT32(config.alpha, BCM2835FBState),
81
VMSTATE_END_OF_LIST()
82
@@ -XXX,XX +XXX,XX @@ static void bcm2835_fb_reset(DeviceState *dev)
83
s->config.xoffset = 0;
84
s->config.yoffset = 0;
85
s->config.base = s->vcram_base + BCM2835_FB_OFFSET;
86
- s->pitch = s->config.xres * (s->config.bpp >> 3);
87
- s->size = s->config.yres * s->pitch;
88
89
s->invalidate = true;
90
s->lock = false;
91
--
71
--
92
2.18.0
72
2.20.1
93
73
94
74
diff view generated by jsdifflib
1
The IoTKit has a CMSDK timer device that runs on the S32KCLK.
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
Create this and wire it up.
3
2
3
We want to assert the device is not realized. To avoid overloading
4
this header including "hw/qdev-core.h", uninline the function first.
5
6
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Message-id: 20200803105647.22223-4-f4bug@amsat.org
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20180820141116.9118-8-peter.maydell@linaro.org
8
---
10
---
9
include/hw/arm/iotkit.h | 2 +-
11
include/hw/qdev-clock.h | 6 +-----
10
hw/arm/iotkit.c | 9 +++++----
12
hw/core/qdev-clock.c | 5 +++++
11
2 files changed, 6 insertions(+), 5 deletions(-)
13
2 files changed, 6 insertions(+), 5 deletions(-)
12
14
13
diff --git a/include/hw/arm/iotkit.h b/include/hw/arm/iotkit.h
15
diff --git a/include/hw/qdev-clock.h b/include/hw/qdev-clock.h
14
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
15
--- a/include/hw/arm/iotkit.h
17
--- a/include/hw/qdev-clock.h
16
+++ b/include/hw/arm/iotkit.h
18
+++ b/include/hw/qdev-clock.h
17
@@ -XXX,XX +XXX,XX @@ typedef struct IoTKit {
19
@@ -XXX,XX +XXX,XX @@ Clock *qdev_get_clock_out(DeviceState *dev, const char *name);
18
TZMPC mpc;
20
* Set the source clock of input clock @name of device @dev to @source.
19
CMSDKAPBTIMER timer0;
21
* @source period update will be propagated to @name clock.
20
CMSDKAPBTIMER timer1;
22
*/
21
+ CMSDKAPBTIMER s32ktimer;
23
-static inline void qdev_connect_clock_in(DeviceState *dev, const char *name,
22
qemu_or_irq ppc_irq_orgate;
24
- Clock *source)
23
SplitIRQ sec_resp_splitter;
25
-{
24
SplitIRQ ppc_irq_splitter[NUM_PPCS];
26
- clock_set_source(qdev_get_clock_in(dev, name), source);
25
@@ -XXX,XX +XXX,XX @@ typedef struct IoTKit {
27
-}
26
qemu_or_irq nmi_orgate;
28
+void qdev_connect_clock_in(DeviceState *dev, const char *name, Clock *source);
27
29
28
CMSDKAPBDualTimer dualtimer;
30
/**
29
- UnimplementedDeviceState s32ktimer;
31
* qdev_alias_clock:
30
32
diff --git a/hw/core/qdev-clock.c b/hw/core/qdev-clock.c
31
CMSDKAPBWatchdog s32kwatchdog;
32
CMSDKAPBWatchdog nswatchdog;
33
diff --git a/hw/arm/iotkit.c b/hw/arm/iotkit.c
34
index XXXXXXX..XXXXXXX 100644
33
index XXXXXXX..XXXXXXX 100644
35
--- a/hw/arm/iotkit.c
34
--- a/hw/core/qdev-clock.c
36
+++ b/hw/arm/iotkit.c
35
+++ b/hw/core/qdev-clock.c
37
@@ -XXX,XX +XXX,XX @@ static void iotkit_init(Object *obj)
36
@@ -XXX,XX +XXX,XX @@ Clock *qdev_alias_clock(DeviceState *dev, const char *name,
38
TYPE_CMSDK_APB_TIMER);
37
39
sysbus_init_child_obj(obj, "timer1", &s->timer1, sizeof(s->timer1),
38
return ncl->clock;
40
TYPE_CMSDK_APB_TIMER);
41
+ sysbus_init_child_obj(obj, "s32ktimer", &s->s32ktimer, sizeof(s->s32ktimer),
42
+ TYPE_CMSDK_APB_TIMER);
43
sysbus_init_child_obj(obj, "dualtimer", &s->dualtimer, sizeof(s->dualtimer),
44
TYPE_CMSDK_APB_DUALTIMER);
45
sysbus_init_child_obj(obj, "s32kwatchdog", &s->s32kwatchdog,
46
@@ -XXX,XX +XXX,XX @@ static void iotkit_init(Object *obj)
47
TYPE_SPLIT_IRQ, &error_abort, NULL);
48
g_free(name);
49
}
50
- sysbus_init_child_obj(obj, "s32ktimer", &s->s32ktimer, sizeof(s->s32ktimer),
51
- TYPE_UNIMPLEMENTED_DEVICE);
52
}
39
}
53
40
+
54
static void iotkit_exp_irq(void *opaque, int n, int level)
41
+void qdev_connect_clock_in(DeviceState *dev, const char *name, Clock *source)
55
@@ -XXX,XX +XXX,XX @@ static void iotkit_realize(DeviceState *dev, Error **errp)
42
+{
56
/* Devices behind APB PPC1:
43
+ clock_set_source(qdev_get_clock_in(dev, name), source);
57
* 0x4002f000: S32K timer
44
+}
58
*/
59
- qdev_prop_set_string(DEVICE(&s->s32ktimer), "name", "S32KTIMER");
60
- qdev_prop_set_uint64(DEVICE(&s->s32ktimer), "size", 0x1000);
61
+ qdev_prop_set_uint32(DEVICE(&s->s32ktimer), "pclk-frq", S32KCLK);
62
object_property_set_bool(OBJECT(&s->s32ktimer), true, "realized", &err);
63
if (err) {
64
error_propagate(errp, err);
65
return;
66
}
67
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->s32ktimer), 0,
68
+ qdev_get_gpio_in(DEVICE(&s->armv7m), 2));
69
mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->s32ktimer), 0);
70
object_property_set_link(OBJECT(&s->apb_ppc1), OBJECT(mr), "port[0]", &err);
71
if (err) {
72
--
45
--
73
2.18.0
46
2.20.1
74
47
75
48
diff view generated by jsdifflib
1
Following the bulk conversion of the iwMMXt code, there are
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
just a handful of hard coded tabs in target/arm; fix them.
3
This is a whitespace-only patch.
4
2
3
Clock canonical name is set in device_set_realized (see the block
4
added to hw/core/qdev.c in commit 0e6934f264).
5
If we connect a clock after the device is realized, this code is
6
not executed. This is currently not a problem as this name is only
7
used for trace events, however this disrupt tracing.
8
9
Add a comment to document qdev_connect_clock_in() must be called
10
before the device is realized, and assert this condition.
11
12
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
14
Message-id: 20200803105647.22223-5-f4bug@amsat.org
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Message-id: 20180821165215.29069-4-peter.maydell@linaro.org
7
---
16
---
8
target/arm/cpu.h | 16 ++++++++--------
17
include/hw/qdev-clock.h | 2 ++
9
target/arm/arm-semi.c | 2 +-
18
hw/core/qdev-clock.c | 1 +
10
2 files changed, 9 insertions(+), 9 deletions(-)
19
2 files changed, 3 insertions(+)
11
20
12
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
21
diff --git a/include/hw/qdev-clock.h b/include/hw/qdev-clock.h
13
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/cpu.h
23
--- a/include/hw/qdev-clock.h
15
+++ b/target/arm/cpu.h
24
+++ b/include/hw/qdev-clock.h
16
@@ -XXX,XX +XXX,XX @@ enum arm_cpu_mode {
25
@@ -XXX,XX +XXX,XX @@ Clock *qdev_get_clock_out(DeviceState *dev, const char *name);
17
#define ARM_VFP_FPINST2 10
26
*
18
27
* Set the source clock of input clock @name of device @dev to @source.
19
/* iwMMXt coprocessor control registers. */
28
* @source period update will be propagated to @name clock.
20
-#define ARM_IWMMXT_wCID        0
29
+ *
21
-#define ARM_IWMMXT_wCon        1
30
+ * Must be called before @dev is realized.
22
-#define ARM_IWMMXT_wCSSF    2
31
*/
23
-#define ARM_IWMMXT_wCASF    3
32
void qdev_connect_clock_in(DeviceState *dev, const char *name, Clock *source);
24
-#define ARM_IWMMXT_wCGR0    8
33
25
-#define ARM_IWMMXT_wCGR1    9
34
diff --git a/hw/core/qdev-clock.c b/hw/core/qdev-clock.c
26
-#define ARM_IWMMXT_wCGR2    10
27
-#define ARM_IWMMXT_wCGR3    11
28
+#define ARM_IWMMXT_wCID 0
29
+#define ARM_IWMMXT_wCon 1
30
+#define ARM_IWMMXT_wCSSF 2
31
+#define ARM_IWMMXT_wCASF 3
32
+#define ARM_IWMMXT_wCGR0 8
33
+#define ARM_IWMMXT_wCGR1 9
34
+#define ARM_IWMMXT_wCGR2 10
35
+#define ARM_IWMMXT_wCGR3 11
36
37
/* V7M CCR bits */
38
FIELD(V7M_CCR, NONBASETHRDENA, 0, 1)
39
diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c
40
index XXXXXXX..XXXXXXX 100644
35
index XXXXXXX..XXXXXXX 100644
41
--- a/target/arm/arm-semi.c
36
--- a/hw/core/qdev-clock.c
42
+++ b/target/arm/arm-semi.c
37
+++ b/hw/core/qdev-clock.c
43
@@ -XXX,XX +XXX,XX @@ static void arm_semi_cb(CPUState *cs, target_ulong ret, target_ulong err)
38
@@ -XXX,XX +XXX,XX @@ Clock *qdev_alias_clock(DeviceState *dev, const char *name,
44
#ifdef CONFIG_USER_ONLY
39
45
ts->swi_errno = err;
40
void qdev_connect_clock_in(DeviceState *dev, const char *name, Clock *source)
46
#else
41
{
47
-    syscall_err = err;
42
+ assert(!dev->realized);
48
+ syscall_err = err;
43
clock_set_source(qdev_get_clock_in(dev, name), source);
49
#endif
44
}
50
reg0 = ret;
51
} else {
52
--
45
--
53
2.18.0
46
2.20.1
54
47
55
48
diff view generated by jsdifflib
1
Untabify the arm translate.c. This affects only some lines,
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
mostly comments, in the iwMMXt code. We've never touched
3
that code in years, so it's not going to get fixed up
4
by our "change when touched" process, and a bulk change
5
is not going to be too disruptive.
6
2
7
This commit was produced using Emacs "untabify"; it is
3
To better align the read/write accesses, display the value after
8
a whitespace-only change.
4
the offset (read accesses only display the offset).
9
5
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20200812190206.31595-2-f4bug@amsat.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Message-id: 20180821165215.29069-2-peter.maydell@linaro.org
12
---
10
---
13
target/arm/translate.c | 122 ++++++++++++++++++++---------------------
11
hw/misc/unimp.c | 8 ++++----
14
1 file changed, 61 insertions(+), 61 deletions(-)
12
1 file changed, 4 insertions(+), 4 deletions(-)
15
13
16
diff --git a/target/arm/translate.c b/target/arm/translate.c
14
diff --git a/hw/misc/unimp.c b/hw/misc/unimp.c
17
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/translate.c
16
--- a/hw/misc/unimp.c
19
+++ b/target/arm/translate.c
17
+++ b/hw/misc/unimp.c
20
@@ -XXX,XX +XXX,XX @@ static inline void gen_mov_vreg_F0(int dp, int reg)
18
@@ -XXX,XX +XXX,XX @@ static uint64_t unimp_read(void *opaque, hwaddr offset, unsigned size)
21
tcg_gen_st_f32(cpu_F0s, cpu_env, vfp_reg_offset(dp, reg));
19
{
20
UnimplementedDeviceState *s = UNIMPLEMENTED_DEVICE(opaque);
21
22
- qemu_log_mask(LOG_UNIMP, "%s: unimplemented device read "
23
+ qemu_log_mask(LOG_UNIMP, "%s: unimplemented device read "
24
"(size %d, offset 0x%" HWADDR_PRIx ")\n",
25
s->name, size, offset);
26
return 0;
27
@@ -XXX,XX +XXX,XX @@ static void unimp_write(void *opaque, hwaddr offset,
28
UnimplementedDeviceState *s = UNIMPLEMENTED_DEVICE(opaque);
29
30
qemu_log_mask(LOG_UNIMP, "%s: unimplemented device write "
31
- "(size %d, value 0x%" PRIx64
32
- ", offset 0x%" HWADDR_PRIx ")\n",
33
- s->name, size, value, offset);
34
+ "(size %d, offset 0x%" HWADDR_PRIx
35
+ ", value 0x%" PRIx64 ")\n",
36
+ s->name, size, offset, value);
22
}
37
}
23
38
24
-#define ARM_CP_RW_BIT    (1 << 20)
39
static const MemoryRegionOps unimp_ops = {
25
+#define ARM_CP_RW_BIT (1 << 20)
26
27
static inline void iwmmxt_load_reg(TCGv_i64 var, int reg)
28
{
29
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
30
wrd = insn & 0xf;
31
rdlo = (insn >> 12) & 0xf;
32
rdhi = (insn >> 16) & 0xf;
33
- if (insn & ARM_CP_RW_BIT) {            /* TMRRC */
34
+ if (insn & ARM_CP_RW_BIT) { /* TMRRC */
35
iwmmxt_load_reg(cpu_V0, wrd);
36
tcg_gen_extrl_i64_i32(cpu_R[rdlo], cpu_V0);
37
tcg_gen_shri_i64(cpu_V0, cpu_V0, 32);
38
tcg_gen_extrl_i64_i32(cpu_R[rdhi], cpu_V0);
39
- } else {                    /* TMCRR */
40
+ } else { /* TMCRR */
41
tcg_gen_concat_i32_i64(cpu_V0, cpu_R[rdlo], cpu_R[rdhi]);
42
iwmmxt_store_reg(cpu_V0, wrd);
43
gen_op_iwmmxt_set_mup();
44
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
45
return 1;
46
}
47
if (insn & ARM_CP_RW_BIT) {
48
- if ((insn >> 28) == 0xf) {            /* WLDRW wCx */
49
+ if ((insn >> 28) == 0xf) { /* WLDRW wCx */
50
tmp = tcg_temp_new_i32();
51
gen_aa32_ld32u(s, tmp, addr, get_mem_index(s));
52
iwmmxt_store_creg(wrd, tmp);
53
} else {
54
i = 1;
55
if (insn & (1 << 8)) {
56
- if (insn & (1 << 22)) {        /* WLDRD */
57
+ if (insn & (1 << 22)) { /* WLDRD */
58
gen_aa32_ld64(s, cpu_M0, addr, get_mem_index(s));
59
i = 0;
60
- } else {                /* WLDRW wRd */
61
+ } else { /* WLDRW wRd */
62
tmp = tcg_temp_new_i32();
63
gen_aa32_ld32u(s, tmp, addr, get_mem_index(s));
64
}
65
} else {
66
tmp = tcg_temp_new_i32();
67
- if (insn & (1 << 22)) {        /* WLDRH */
68
+ if (insn & (1 << 22)) { /* WLDRH */
69
gen_aa32_ld16u(s, tmp, addr, get_mem_index(s));
70
- } else {                /* WLDRB */
71
+ } else { /* WLDRB */
72
gen_aa32_ld8u(s, tmp, addr, get_mem_index(s));
73
}
74
}
75
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
76
gen_op_iwmmxt_movq_wRn_M0(wrd);
77
}
78
} else {
79
- if ((insn >> 28) == 0xf) {            /* WSTRW wCx */
80
+ if ((insn >> 28) == 0xf) { /* WSTRW wCx */
81
tmp = iwmmxt_load_creg(wrd);
82
gen_aa32_st32(s, tmp, addr, get_mem_index(s));
83
} else {
84
gen_op_iwmmxt_movq_M0_wRn(wrd);
85
tmp = tcg_temp_new_i32();
86
if (insn & (1 << 8)) {
87
- if (insn & (1 << 22)) {        /* WSTRD */
88
+ if (insn & (1 << 22)) { /* WSTRD */
89
gen_aa32_st64(s, cpu_M0, addr, get_mem_index(s));
90
- } else {                /* WSTRW wRd */
91
+ } else { /* WSTRW wRd */
92
tcg_gen_extrl_i64_i32(tmp, cpu_M0);
93
gen_aa32_st32(s, tmp, addr, get_mem_index(s));
94
}
95
} else {
96
- if (insn & (1 << 22)) {        /* WSTRH */
97
+ if (insn & (1 << 22)) { /* WSTRH */
98
tcg_gen_extrl_i64_i32(tmp, cpu_M0);
99
gen_aa32_st16(s, tmp, addr, get_mem_index(s));
100
- } else {                /* WSTRB */
101
+ } else { /* WSTRB */
102
tcg_gen_extrl_i64_i32(tmp, cpu_M0);
103
gen_aa32_st8(s, tmp, addr, get_mem_index(s));
104
}
105
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
106
return 1;
107
108
switch (((insn >> 12) & 0xf00) | ((insn >> 4) & 0xff)) {
109
- case 0x000:                        /* WOR */
110
+ case 0x000: /* WOR */
111
wrd = (insn >> 12) & 0xf;
112
rd0 = (insn >> 0) & 0xf;
113
rd1 = (insn >> 16) & 0xf;
114
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
115
gen_op_iwmmxt_set_mup();
116
gen_op_iwmmxt_set_cup();
117
break;
118
- case 0x011:                        /* TMCR */
119
+ case 0x011: /* TMCR */
120
if (insn & 0xf)
121
return 1;
122
rd = (insn >> 12) & 0xf;
123
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
124
return 1;
125
}
126
break;
127
- case 0x100:                        /* WXOR */
128
+ case 0x100: /* WXOR */
129
wrd = (insn >> 12) & 0xf;
130
rd0 = (insn >> 0) & 0xf;
131
rd1 = (insn >> 16) & 0xf;
132
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
133
gen_op_iwmmxt_set_mup();
134
gen_op_iwmmxt_set_cup();
135
break;
136
- case 0x111:                        /* TMRC */
137
+ case 0x111: /* TMRC */
138
if (insn & 0xf)
139
return 1;
140
rd = (insn >> 12) & 0xf;
141
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
142
tmp = iwmmxt_load_creg(wrd);
143
store_reg(s, rd, tmp);
144
break;
145
- case 0x300:                        /* WANDN */
146
+ case 0x300: /* WANDN */
147
wrd = (insn >> 12) & 0xf;
148
rd0 = (insn >> 0) & 0xf;
149
rd1 = (insn >> 16) & 0xf;
150
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
151
gen_op_iwmmxt_set_mup();
152
gen_op_iwmmxt_set_cup();
153
break;
154
- case 0x200:                        /* WAND */
155
+ case 0x200: /* WAND */
156
wrd = (insn >> 12) & 0xf;
157
rd0 = (insn >> 0) & 0xf;
158
rd1 = (insn >> 16) & 0xf;
159
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
160
gen_op_iwmmxt_set_mup();
161
gen_op_iwmmxt_set_cup();
162
break;
163
- case 0x810: case 0xa10:                /* WMADD */
164
+ case 0x810: case 0xa10: /* WMADD */
165
wrd = (insn >> 12) & 0xf;
166
rd0 = (insn >> 0) & 0xf;
167
rd1 = (insn >> 16) & 0xf;
168
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
169
gen_op_iwmmxt_movq_wRn_M0(wrd);
170
gen_op_iwmmxt_set_mup();
171
break;
172
- case 0x10e: case 0x50e: case 0x90e: case 0xd0e:    /* WUNPCKIL */
173
+ case 0x10e: case 0x50e: case 0x90e: case 0xd0e: /* WUNPCKIL */
174
wrd = (insn >> 12) & 0xf;
175
rd0 = (insn >> 16) & 0xf;
176
rd1 = (insn >> 0) & 0xf;
177
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
178
gen_op_iwmmxt_set_mup();
179
gen_op_iwmmxt_set_cup();
180
break;
181
- case 0x10c: case 0x50c: case 0x90c: case 0xd0c:    /* WUNPCKIH */
182
+ case 0x10c: case 0x50c: case 0x90c: case 0xd0c: /* WUNPCKIH */
183
wrd = (insn >> 12) & 0xf;
184
rd0 = (insn >> 16) & 0xf;
185
rd1 = (insn >> 0) & 0xf;
186
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
187
gen_op_iwmmxt_set_mup();
188
gen_op_iwmmxt_set_cup();
189
break;
190
- case 0x012: case 0x112: case 0x412: case 0x512:    /* WSAD */
191
+ case 0x012: case 0x112: case 0x412: case 0x512: /* WSAD */
192
wrd = (insn >> 12) & 0xf;
193
rd0 = (insn >> 16) & 0xf;
194
rd1 = (insn >> 0) & 0xf;
195
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
196
gen_op_iwmmxt_movq_wRn_M0(wrd);
197
gen_op_iwmmxt_set_mup();
198
break;
199
- case 0x010: case 0x110: case 0x210: case 0x310:    /* WMUL */
200
+ case 0x010: case 0x110: case 0x210: case 0x310: /* WMUL */
201
wrd = (insn >> 12) & 0xf;
202
rd0 = (insn >> 16) & 0xf;
203
rd1 = (insn >> 0) & 0xf;
204
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
205
gen_op_iwmmxt_movq_wRn_M0(wrd);
206
gen_op_iwmmxt_set_mup();
207
break;
208
- case 0x410: case 0x510: case 0x610: case 0x710:    /* WMAC */
209
+ case 0x410: case 0x510: case 0x610: case 0x710: /* WMAC */
210
wrd = (insn >> 12) & 0xf;
211
rd0 = (insn >> 16) & 0xf;
212
rd1 = (insn >> 0) & 0xf;
213
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
214
gen_op_iwmmxt_movq_wRn_M0(wrd);
215
gen_op_iwmmxt_set_mup();
216
break;
217
- case 0x006: case 0x406: case 0x806: case 0xc06:    /* WCMPEQ */
218
+ case 0x006: case 0x406: case 0x806: case 0xc06: /* WCMPEQ */
219
wrd = (insn >> 12) & 0xf;
220
rd0 = (insn >> 16) & 0xf;
221
rd1 = (insn >> 0) & 0xf;
222
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
223
gen_op_iwmmxt_set_mup();
224
gen_op_iwmmxt_set_cup();
225
break;
226
- case 0x800: case 0x900: case 0xc00: case 0xd00:    /* WAVG2 */
227
+ case 0x800: case 0x900: case 0xc00: case 0xd00: /* WAVG2 */
228
wrd = (insn >> 12) & 0xf;
229
rd0 = (insn >> 16) & 0xf;
230
rd1 = (insn >> 0) & 0xf;
231
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
232
gen_op_iwmmxt_set_mup();
233
gen_op_iwmmxt_set_cup();
234
break;
235
- case 0x802: case 0x902: case 0xa02: case 0xb02:    /* WALIGNR */
236
+ case 0x802: case 0x902: case 0xa02: case 0xb02: /* WALIGNR */
237
wrd = (insn >> 12) & 0xf;
238
rd0 = (insn >> 16) & 0xf;
239
rd1 = (insn >> 0) & 0xf;
240
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
241
gen_op_iwmmxt_movq_wRn_M0(wrd);
242
gen_op_iwmmxt_set_mup();
243
break;
244
- case 0x601: case 0x605: case 0x609: case 0x60d:    /* TINSR */
245
+ case 0x601: case 0x605: case 0x609: case 0x60d: /* TINSR */
246
if (((insn >> 6) & 3) == 3)
247
return 1;
248
rd = (insn >> 12) & 0xf;
249
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
250
gen_op_iwmmxt_movq_wRn_M0(wrd);
251
gen_op_iwmmxt_set_mup();
252
break;
253
- case 0x107: case 0x507: case 0x907: case 0xd07:    /* TEXTRM */
254
+ case 0x107: case 0x507: case 0x907: case 0xd07: /* TEXTRM */
255
rd = (insn >> 12) & 0xf;
256
wrd = (insn >> 16) & 0xf;
257
if (rd == 15 || ((insn >> 22) & 3) == 3)
258
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
259
}
260
store_reg(s, rd, tmp);
261
break;
262
- case 0x117: case 0x517: case 0x917: case 0xd17:    /* TEXTRC */
263
+ case 0x117: case 0x517: case 0x917: case 0xd17: /* TEXTRC */
264
if ((insn & 0x000ff008) != 0x0003f000 || ((insn >> 22) & 3) == 3)
265
return 1;
266
tmp = iwmmxt_load_creg(ARM_IWMMXT_wCASF);
267
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
268
gen_set_nzcv(tmp);
269
tcg_temp_free_i32(tmp);
270
break;
271
- case 0x401: case 0x405: case 0x409: case 0x40d:    /* TBCST */
272
+ case 0x401: case 0x405: case 0x409: case 0x40d: /* TBCST */
273
if (((insn >> 6) & 3) == 3)
274
return 1;
275
rd = (insn >> 12) & 0xf;
276
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
277
gen_op_iwmmxt_movq_wRn_M0(wrd);
278
gen_op_iwmmxt_set_mup();
279
break;
280
- case 0x113: case 0x513: case 0x913: case 0xd13:    /* TANDC */
281
+ case 0x113: case 0x513: case 0x913: case 0xd13: /* TANDC */
282
if ((insn & 0x000ff00f) != 0x0003f000 || ((insn >> 22) & 3) == 3)
283
return 1;
284
tmp = iwmmxt_load_creg(ARM_IWMMXT_wCASF);
285
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
286
tcg_temp_free_i32(tmp2);
287
tcg_temp_free_i32(tmp);
288
break;
289
- case 0x01c: case 0x41c: case 0x81c: case 0xc1c:    /* WACC */
290
+ case 0x01c: case 0x41c: case 0x81c: case 0xc1c: /* WACC */
291
wrd = (insn >> 12) & 0xf;
292
rd0 = (insn >> 16) & 0xf;
293
gen_op_iwmmxt_movq_M0_wRn(rd0);
294
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
295
gen_op_iwmmxt_movq_wRn_M0(wrd);
296
gen_op_iwmmxt_set_mup();
297
break;
298
- case 0x115: case 0x515: case 0x915: case 0xd15:    /* TORC */
299
+ case 0x115: case 0x515: case 0x915: case 0xd15: /* TORC */
300
if ((insn & 0x000ff00f) != 0x0003f000 || ((insn >> 22) & 3) == 3)
301
return 1;
302
tmp = iwmmxt_load_creg(ARM_IWMMXT_wCASF);
303
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
304
tcg_temp_free_i32(tmp2);
305
tcg_temp_free_i32(tmp);
306
break;
307
- case 0x103: case 0x503: case 0x903: case 0xd03:    /* TMOVMSK */
308
+ case 0x103: case 0x503: case 0x903: case 0xd03: /* TMOVMSK */
309
rd = (insn >> 12) & 0xf;
310
rd0 = (insn >> 16) & 0xf;
311
if ((insn & 0xf) != 0 || ((insn >> 22) & 3) == 3)
312
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
313
}
314
store_reg(s, rd, tmp);
315
break;
316
- case 0x106: case 0x306: case 0x506: case 0x706:    /* WCMPGT */
317
+ case 0x106: case 0x306: case 0x506: case 0x706: /* WCMPGT */
318
case 0x906: case 0xb06: case 0xd06: case 0xf06:
319
wrd = (insn >> 12) & 0xf;
320
rd0 = (insn >> 16) & 0xf;
321
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
322
gen_op_iwmmxt_set_mup();
323
gen_op_iwmmxt_set_cup();
324
break;
325
- case 0x00e: case 0x20e: case 0x40e: case 0x60e:    /* WUNPCKEL */
326
+ case 0x00e: case 0x20e: case 0x40e: case 0x60e: /* WUNPCKEL */
327
case 0x80e: case 0xa0e: case 0xc0e: case 0xe0e:
328
wrd = (insn >> 12) & 0xf;
329
rd0 = (insn >> 16) & 0xf;
330
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
331
gen_op_iwmmxt_set_mup();
332
gen_op_iwmmxt_set_cup();
333
break;
334
- case 0x00c: case 0x20c: case 0x40c: case 0x60c:    /* WUNPCKEH */
335
+ case 0x00c: case 0x20c: case 0x40c: case 0x60c: /* WUNPCKEH */
336
case 0x80c: case 0xa0c: case 0xc0c: case 0xe0c:
337
wrd = (insn >> 12) & 0xf;
338
rd0 = (insn >> 16) & 0xf;
339
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
340
gen_op_iwmmxt_set_mup();
341
gen_op_iwmmxt_set_cup();
342
break;
343
- case 0x204: case 0x604: case 0xa04: case 0xe04:    /* WSRL */
344
+ case 0x204: case 0x604: case 0xa04: case 0xe04: /* WSRL */
345
case 0x214: case 0x614: case 0xa14: case 0xe14:
346
if (((insn >> 22) & 3) == 0)
347
return 1;
348
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
349
gen_op_iwmmxt_set_mup();
350
gen_op_iwmmxt_set_cup();
351
break;
352
- case 0x004: case 0x404: case 0x804: case 0xc04:    /* WSRA */
353
+ case 0x004: case 0x404: case 0x804: case 0xc04: /* WSRA */
354
case 0x014: case 0x414: case 0x814: case 0xc14:
355
if (((insn >> 22) & 3) == 0)
356
return 1;
357
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
358
gen_op_iwmmxt_set_mup();
359
gen_op_iwmmxt_set_cup();
360
break;
361
- case 0x104: case 0x504: case 0x904: case 0xd04:    /* WSLL */
362
+ case 0x104: case 0x504: case 0x904: case 0xd04: /* WSLL */
363
case 0x114: case 0x514: case 0x914: case 0xd14:
364
if (((insn >> 22) & 3) == 0)
365
return 1;
366
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
367
gen_op_iwmmxt_set_mup();
368
gen_op_iwmmxt_set_cup();
369
break;
370
- case 0x304: case 0x704: case 0xb04: case 0xf04:    /* WROR */
371
+ case 0x304: case 0x704: case 0xb04: case 0xf04: /* WROR */
372
case 0x314: case 0x714: case 0xb14: case 0xf14:
373
if (((insn >> 22) & 3) == 0)
374
return 1;
375
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
376
gen_op_iwmmxt_set_mup();
377
gen_op_iwmmxt_set_cup();
378
break;
379
- case 0x116: case 0x316: case 0x516: case 0x716:    /* WMIN */
380
+ case 0x116: case 0x316: case 0x516: case 0x716: /* WMIN */
381
case 0x916: case 0xb16: case 0xd16: case 0xf16:
382
wrd = (insn >> 12) & 0xf;
383
rd0 = (insn >> 16) & 0xf;
384
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
385
gen_op_iwmmxt_movq_wRn_M0(wrd);
386
gen_op_iwmmxt_set_mup();
387
break;
388
- case 0x016: case 0x216: case 0x416: case 0x616:    /* WMAX */
389
+ case 0x016: case 0x216: case 0x416: case 0x616: /* WMAX */
390
case 0x816: case 0xa16: case 0xc16: case 0xe16:
391
wrd = (insn >> 12) & 0xf;
392
rd0 = (insn >> 16) & 0xf;
393
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
394
gen_op_iwmmxt_movq_wRn_M0(wrd);
395
gen_op_iwmmxt_set_mup();
396
break;
397
- case 0x002: case 0x102: case 0x202: case 0x302:    /* WALIGNI */
398
+ case 0x002: case 0x102: case 0x202: case 0x302: /* WALIGNI */
399
case 0x402: case 0x502: case 0x602: case 0x702:
400
wrd = (insn >> 12) & 0xf;
401
rd0 = (insn >> 16) & 0xf;
402
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
403
gen_op_iwmmxt_movq_wRn_M0(wrd);
404
gen_op_iwmmxt_set_mup();
405
break;
406
- case 0x01a: case 0x11a: case 0x21a: case 0x31a:    /* WSUB */
407
+ case 0x01a: case 0x11a: case 0x21a: case 0x31a: /* WSUB */
408
case 0x41a: case 0x51a: case 0x61a: case 0x71a:
409
case 0x81a: case 0x91a: case 0xa1a: case 0xb1a:
410
case 0xc1a: case 0xd1a: case 0xe1a: case 0xf1a:
411
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
412
gen_op_iwmmxt_set_mup();
413
gen_op_iwmmxt_set_cup();
414
break;
415
- case 0x01e: case 0x11e: case 0x21e: case 0x31e:    /* WSHUFH */
416
+ case 0x01e: case 0x11e: case 0x21e: case 0x31e: /* WSHUFH */
417
case 0x41e: case 0x51e: case 0x61e: case 0x71e:
418
case 0x81e: case 0x91e: case 0xa1e: case 0xb1e:
419
case 0xc1e: case 0xd1e: case 0xe1e: case 0xf1e:
420
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
421
gen_op_iwmmxt_set_mup();
422
gen_op_iwmmxt_set_cup();
423
break;
424
- case 0x018: case 0x118: case 0x218: case 0x318:    /* WADD */
425
+ case 0x018: case 0x118: case 0x218: case 0x318: /* WADD */
426
case 0x418: case 0x518: case 0x618: case 0x718:
427
case 0x818: case 0x918: case 0xa18: case 0xb18:
428
case 0xc18: case 0xd18: case 0xe18: case 0xf18:
429
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
430
gen_op_iwmmxt_set_mup();
431
gen_op_iwmmxt_set_cup();
432
break;
433
- case 0x008: case 0x108: case 0x208: case 0x308:    /* WPACK */
434
+ case 0x008: case 0x108: case 0x208: case 0x308: /* WPACK */
435
case 0x408: case 0x508: case 0x608: case 0x708:
436
case 0x808: case 0x908: case 0xa08: case 0xb08:
437
case 0xc08: case 0xd08: case 0xe08: case 0xf08:
438
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
439
tmp = load_reg(s, rd0);
440
tmp2 = load_reg(s, rd1);
441
switch ((insn >> 16) & 0xf) {
442
- case 0x0:                    /* TMIA */
443
+ case 0x0: /* TMIA */
444
gen_helper_iwmmxt_muladdsl(cpu_M0, cpu_M0, tmp, tmp2);
445
break;
446
- case 0x8:                    /* TMIAPH */
447
+ case 0x8: /* TMIAPH */
448
gen_helper_iwmmxt_muladdsw(cpu_M0, cpu_M0, tmp, tmp2);
449
break;
450
- case 0xc: case 0xd: case 0xe: case 0xf:        /* TMIAxy */
451
+ case 0xc: case 0xd: case 0xe: case 0xf: /* TMIAxy */
452
if (insn & (1 << 16))
453
tcg_gen_shri_i32(tmp, tmp, 16);
454
if (insn & (1 << 17))
455
@@ -XXX,XX +XXX,XX @@ static int disas_dsp_insn(DisasContext *s, uint32_t insn)
456
tmp = load_reg(s, rd0);
457
tmp2 = load_reg(s, rd1);
458
switch ((insn >> 16) & 0xf) {
459
- case 0x0:                    /* MIA */
460
+ case 0x0: /* MIA */
461
gen_helper_iwmmxt_muladdsl(cpu_M0, cpu_M0, tmp, tmp2);
462
break;
463
- case 0x8:                    /* MIAPH */
464
+ case 0x8: /* MIAPH */
465
gen_helper_iwmmxt_muladdsw(cpu_M0, cpu_M0, tmp, tmp2);
466
break;
467
- case 0xc:                    /* MIABB */
468
- case 0xd:                    /* MIABT */
469
- case 0xe:                    /* MIATB */
470
- case 0xf:                    /* MIATT */
471
+ case 0xc: /* MIABB */
472
+ case 0xd: /* MIABT */
473
+ case 0xe: /* MIATB */
474
+ case 0xf: /* MIATT */
475
if (insn & (1 << 16))
476
tcg_gen_shri_i32(tmp, tmp, 16);
477
if (insn & (1 << 17))
478
@@ -XXX,XX +XXX,XX @@ static int disas_dsp_insn(DisasContext *s, uint32_t insn)
479
if (acc != 0)
480
return 1;
481
482
- if (insn & ARM_CP_RW_BIT) {            /* MRA */
483
+ if (insn & ARM_CP_RW_BIT) { /* MRA */
484
iwmmxt_load_reg(cpu_V0, acc);
485
tcg_gen_extrl_i64_i32(cpu_R[rdlo], cpu_V0);
486
tcg_gen_shri_i64(cpu_V0, cpu_V0, 32);
487
tcg_gen_extrl_i64_i32(cpu_R[rdhi], cpu_V0);
488
tcg_gen_andi_i32(cpu_R[rdhi], cpu_R[rdhi], (1 << (40 - 32)) - 1);
489
- } else {                    /* MAR */
490
+ } else { /* MAR */
491
tcg_gen_concat_i32_i64(cpu_V0, cpu_R[rdlo], cpu_R[rdhi]);
492
iwmmxt_store_reg(cpu_V0, acc);
493
}
494
--
40
--
495
2.18.0
41
2.20.1
496
42
497
43
diff view generated by jsdifflib
1
Some of the config register values we were setting for the MPS2 SCC
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
weren't correct:
3
* the SCC_AID bits [23:20] specify the FPGA build target board revision,
4
and the SCC_CFG4 register specifies the actual board revision, so
5
these should have matching values. Claim to be board revision C,
6
consistently -- we had the revision in the wrong part of SCC_AID.
7
* SCC_ID bits [15:4] should be 0x505, not decimal 505
8
2
3
To quickly notice the access size, display the value with the
4
width of the access (i.e. 16-bit access is displayed 0x0000,
5
while 8-bit access 0x00).
6
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-id: 20200812190206.31595-3-f4bug@amsat.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 20180820141116.9118-23-peter.maydell@linaro.org
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
---
11
---
13
hw/arm/mps2-tz.c | 4 ++--
12
hw/misc/unimp.c | 4 ++--
14
1 file changed, 2 insertions(+), 2 deletions(-)
13
1 file changed, 2 insertions(+), 2 deletions(-)
15
14
16
diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c
15
diff --git a/hw/misc/unimp.c b/hw/misc/unimp.c
17
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/arm/mps2-tz.c
17
--- a/hw/misc/unimp.c
19
+++ b/hw/arm/mps2-tz.c
18
+++ b/hw/misc/unimp.c
20
@@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_scc(MPS2TZMachineState *mms, void *opaque,
19
@@ -XXX,XX +XXX,XX @@ static void unimp_write(void *opaque, hwaddr offset,
21
sccdev = DEVICE(scc);
20
22
qdev_set_parent_bus(sccdev, sysbus_get_default());
21
qemu_log_mask(LOG_UNIMP, "%s: unimplemented device write "
23
qdev_prop_set_uint32(sccdev, "scc-cfg4", 0x2);
22
"(size %d, offset 0x%" HWADDR_PRIx
24
- qdev_prop_set_uint32(sccdev, "scc-aid", 0x02000008);
23
- ", value 0x%" PRIx64 ")\n",
25
+ qdev_prop_set_uint32(sccdev, "scc-aid", 0x00200008);
24
- s->name, size, offset, value);
26
qdev_prop_set_uint32(sccdev, "scc-id", mmc->scc_id);
25
+ ", value 0x%0*" PRIx64 ")\n",
27
object_property_set_bool(OBJECT(scc), true, "realized", &error_fatal);
26
+ s->name, size, offset, size << 1, value);
28
return sysbus_mmio_get_region(SYS_BUS_DEVICE(sccdev), 0);
29
@@ -XXX,XX +XXX,XX @@ static void mps2tz_an505_class_init(ObjectClass *oc, void *data)
30
mc->desc = "ARM MPS2 with AN505 FPGA image for Cortex-M33";
31
mmc->fpga_type = FPGA_AN505;
32
mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m33");
33
- mmc->scc_id = 0x41040000 | (505 << 4);
34
+ mmc->scc_id = 0x41045050;
35
}
27
}
36
28
37
static const TypeInfo mps2tz_info = {
29
static const MemoryRegionOps unimp_ops = {
38
--
30
--
39
2.18.0
31
2.20.1
40
32
41
33
diff view generated by jsdifflib
1
The raspi framebuffir in bcm2835_fb supports the definition
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
of a virtual "viewport", which is smaller than the full
3
physical framebuffer size and at an adjustable offset within
4
it. Only the viewport area is sent to the screen. This allows
5
the guest to do things like double buffering, or scrolling
6
by adjusting the viewport origin. Currently QEMU doesn't
7
implement this at all.
8
2
9
Add support for this feature:
3
To have a better idea of how big is the region where the offset
10
* the property mailbox code needs to distinguish the
4
belongs, display the value with the width of the region size
11
virtual width/height from the physical width/height
5
(i.e. a region of 0x1000 bytes uses 0x000 format).
12
* the framebuffer code needs to do something with the
13
virtual width/height/origin information
14
6
15
Note that the wiki documentation on the semantics of the
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
16
virtual and physical height and width has it the wrong way
8
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
17
around -- the virtual size is the size of the allocated
9
Message-id: 20200812190206.31595-4-f4bug@amsat.org
18
buffer, and the physical size is the size of the display,
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
so the virtual size is always the same as or larger than
11
---
20
the physical.
12
include/hw/misc/unimp.h | 1 +
13
hw/misc/unimp.c | 10 ++++++----
14
2 files changed, 7 insertions(+), 4 deletions(-)
21
15
22
If the viewport size is set smaller than the physical
16
diff --git a/include/hw/misc/unimp.h b/include/hw/misc/unimp.h
23
screen size, we ignore the viewport settings completely
24
and just display the physical screen area.
25
26
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
27
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
28
Message-id: 20180814144436.679-7-peter.maydell@linaro.org
29
---
30
include/hw/display/bcm2835_fb.h | 6 ++++--
31
hw/display/bcm2835_fb.c | 28 ++++++++++++++++++++++------
32
hw/misc/bcm2835_property.c | 21 +++++++++++++++------
33
3 files changed, 41 insertions(+), 14 deletions(-)
34
35
diff --git a/include/hw/display/bcm2835_fb.h b/include/hw/display/bcm2835_fb.h
36
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
37
--- a/include/hw/display/bcm2835_fb.h
18
--- a/include/hw/misc/unimp.h
38
+++ b/include/hw/display/bcm2835_fb.h
19
+++ b/include/hw/misc/unimp.h
39
@@ -XXX,XX +XXX,XX @@ void bcm2835_fb_reconfigure(BCM2835FBState *s, BCM2835FBConfig *newconfig);
20
@@ -XXX,XX +XXX,XX @@
40
*/
21
typedef struct {
41
static inline uint32_t bcm2835_fb_get_pitch(BCM2835FBConfig *config)
22
SysBusDevice parent_obj;
42
{
23
MemoryRegion iomem;
43
- return config->xres * (config->bpp >> 3);
24
+ unsigned offset_fmt_width;
44
+ uint32_t xres = MAX(config->xres, config->xres_virtual);
25
char *name;
45
+ return xres * (config->bpp >> 3);
26
uint64_t size;
27
} UnimplementedDeviceState;
28
diff --git a/hw/misc/unimp.c b/hw/misc/unimp.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/hw/misc/unimp.c
31
+++ b/hw/misc/unimp.c
32
@@ -XXX,XX +XXX,XX @@ static uint64_t unimp_read(void *opaque, hwaddr offset, unsigned size)
33
UnimplementedDeviceState *s = UNIMPLEMENTED_DEVICE(opaque);
34
35
qemu_log_mask(LOG_UNIMP, "%s: unimplemented device read "
36
- "(size %d, offset 0x%" HWADDR_PRIx ")\n",
37
- s->name, size, offset);
38
+ "(size %d, offset 0x%0*" HWADDR_PRIx ")\n",
39
+ s->name, size, s->offset_fmt_width, offset);
40
return 0;
46
}
41
}
47
42
48
/**
43
@@ -XXX,XX +XXX,XX @@ static void unimp_write(void *opaque, hwaddr offset,
49
@@ -XXX,XX +XXX,XX @@ static inline uint32_t bcm2835_fb_get_pitch(BCM2835FBConfig *config)
44
UnimplementedDeviceState *s = UNIMPLEMENTED_DEVICE(opaque);
50
*/
45
51
static inline uint32_t bcm2835_fb_get_size(BCM2835FBConfig *config)
46
qemu_log_mask(LOG_UNIMP, "%s: unimplemented device write "
52
{
47
- "(size %d, offset 0x%" HWADDR_PRIx
53
- return config->yres * bcm2835_fb_get_pitch(config);
48
+ "(size %d, offset 0x%0*" HWADDR_PRIx
54
+ uint32_t yres = MAX(config->yres, config->yres_virtual);
49
", value 0x%0*" PRIx64 ")\n",
55
+ return yres * bcm2835_fb_get_pitch(config);
50
- s->name, size, offset, size << 1, value);
51
+ s->name, size, s->offset_fmt_width, offset, size << 1, value);
56
}
52
}
57
53
58
#endif
54
static const MemoryRegionOps unimp_ops = {
59
diff --git a/hw/display/bcm2835_fb.c b/hw/display/bcm2835_fb.c
55
@@ -XXX,XX +XXX,XX @@ static void unimp_realize(DeviceState *dev, Error **errp)
60
index XXXXXXX..XXXXXXX 100644
61
--- a/hw/display/bcm2835_fb.c
62
+++ b/hw/display/bcm2835_fb.c
63
@@ -XXX,XX +XXX,XX @@ static void draw_line_src16(void *opaque, uint8_t *dst, const uint8_t *src,
64
}
65
}
66
67
+static bool fb_use_offsets(BCM2835FBConfig *config)
68
+{
69
+ /*
70
+ * Return true if we should use the viewport offsets.
71
+ * Experimentally, the hardware seems to do this only if the
72
+ * viewport size is larger than the physical screen. (It doesn't
73
+ * prevent the guest setting this silly viewport setting, though...)
74
+ */
75
+ return config->xres_virtual > config->xres &&
76
+ config->yres_virtual > config->yres;
77
+}
78
+
79
static void fb_update_display(void *opaque)
80
{
81
BCM2835FBState *s = opaque;
82
@@ -XXX,XX +XXX,XX @@ static void fb_update_display(void *opaque)
83
int last = 0;
84
int src_width = 0;
85
int dest_width = 0;
86
+ uint32_t xoff = 0, yoff = 0;
87
88
if (s->lock || !s->config.xres) {
89
return;
56
return;
90
}
57
}
91
58
92
src_width = bcm2835_fb_get_pitch(&s->config);
59
+ s->offset_fmt_width = DIV_ROUND_UP(64 - clz64(s->size - 1), 4);
93
+ if (fb_use_offsets(&s->config)) {
94
+ xoff = s->config.xoffset;
95
+ yoff = s->config.yoffset;
96
+ }
97
+
60
+
98
dest_width = s->config.xres;
61
memory_region_init_io(&s->iomem, OBJECT(s), &unimp_ops, s,
99
62
s->name, s->size);
100
switch (surface_bits_per_pixel(surface)) {
63
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem);
101
@@ -XXX,XX +XXX,XX @@ static void fb_update_display(void *opaque)
102
}
103
104
if (s->invalidate) {
105
+ hwaddr base = s->config.base + xoff + yoff * src_width;
106
framebuffer_update_memory_section(&s->fbsection, s->dma_mr,
107
- s->config.base,
108
+ base,
109
s->config.yres, src_width);
110
}
111
112
@@ -XXX,XX +XXX,XX @@ static void fb_update_display(void *opaque)
113
draw_line_src16, s, &first, &last);
114
115
if (first >= 0) {
116
- dpy_gfx_update(s->con, 0, first, s->config.xres, last - first + 1);
117
+ dpy_gfx_update(s->con, 0, first, s->config.xres,
118
+ last - first + 1);
119
}
120
121
s->invalidate = false;
122
@@ -XXX,XX +XXX,XX @@ static void bcm2835_fb_mbox_push(BCM2835FBState *s, uint32_t value)
123
s->config.base = s->vcram_base | (value & 0xc0000000);
124
s->config.base += BCM2835_FB_OFFSET;
125
126
- /* TODO - Manage properly virtual resolution */
127
-
128
pitch = bcm2835_fb_get_pitch(&s->config);
129
size = bcm2835_fb_get_size(&s->config);
130
131
@@ -XXX,XX +XXX,XX @@ void bcm2835_fb_reconfigure(BCM2835FBState *s, BCM2835FBConfig *newconfig)
132
133
s->config = *newconfig;
134
135
- /* TODO - Manage properly virtual resolution */
136
-
137
s->invalidate = true;
138
qemu_console_resize(s->con, s->config.xres, s->config.yres);
139
s->lock = false;
140
diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c
141
index XXXXXXX..XXXXXXX 100644
142
--- a/hw/misc/bcm2835_property.c
143
+++ b/hw/misc/bcm2835_property.c
144
@@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value)
145
case 0x00040002: /* Blank screen */
146
resplen = 4;
147
break;
148
- case 0x00040003: /* Get display width/height */
149
- case 0x00040004:
150
+ case 0x00040003: /* Get physical display width/height */
151
stl_le_phys(&s->dma_as, value + 12, fbconfig.xres);
152
stl_le_phys(&s->dma_as, value + 16, fbconfig.yres);
153
resplen = 8;
154
break;
155
- case 0x00044003: /* Test display width/height */
156
- case 0x00044004:
157
+ case 0x00040004: /* Get virtual display width/height */
158
+ stl_le_phys(&s->dma_as, value + 12, fbconfig.xres_virtual);
159
+ stl_le_phys(&s->dma_as, value + 16, fbconfig.yres_virtual);
160
resplen = 8;
161
break;
162
- case 0x00048003: /* Set display width/height */
163
- case 0x00048004:
164
+ case 0x00044003: /* Test physical display width/height */
165
+ case 0x00044004: /* Test virtual display width/height */
166
+ resplen = 8;
167
+ break;
168
+ case 0x00048003: /* Set physical display width/height */
169
fbconfig.xres = ldl_le_phys(&s->dma_as, value + 12);
170
fbconfig.yres = ldl_le_phys(&s->dma_as, value + 16);
171
fbconfig_updated = true;
172
resplen = 8;
173
break;
174
+ case 0x00048004: /* Set virtual display width/height */
175
+ fbconfig.xres_virtual = ldl_le_phys(&s->dma_as, value + 12);
176
+ fbconfig.yres_virtual = ldl_le_phys(&s->dma_as, value + 16);
177
+ fbconfig_updated = true;
178
+ resplen = 8;
179
+ break;
180
case 0x00040005: /* Get depth */
181
stl_le_phys(&s->dma_as, value + 12, fbconfig.bpp);
182
resplen = 4;
183
--
64
--
184
2.18.0
65
2.20.1
185
66
186
67
diff view generated by jsdifflib
1
Untabify the arm iwmmxt_helper.c. This affects only the iwMMXt code.
1
From: Eduardo Habkost <ehabkost@redhat.com>
2
We've never touched that code in years, so it's not going to get
3
fixed up by our "change when touched" process, and a bulk change is
4
not going to be too disruptive.
5
2
6
This commit was produced using Emacs "untabify" (plus one
3
TYPE_ARM_SSE is a TYPE_SYS_BUS_DEVICE subclass, but
7
by-hand removal of a space to fix a checkpatch nit); it is
4
ARMSSEClass::parent_class is declared as DeviceClass.
8
a whitespace-only change.
9
5
6
It never caused any problems by pure luck:
7
8
We were not setting class_size for TYPE_ARM_SSE, so class_size of
9
TYPE_SYS_BUS_DEVICE was being used (sizeof(SysBusDeviceClass)).
10
This made the system allocate enough memory for TYPE_ARM_SSE
11
devices even though ARMSSEClass was too small for a sysbus
12
device.
13
14
Additionally, the ARMSSEClass::info field ended up at the same
15
offset as SysBusDeviceClass::explicit_ofw_unit_address. This
16
would make sysbus_get_fw_dev_path() crash for the device.
17
Luckily, sysbus_get_fw_dev_path() never gets called for
18
TYPE_ARM_SSE devices, because qdev_get_fw_dev_path() is only used
19
by the boot device code, and TYPE_ARM_SSE devices don't appear at
20
the fw_boot_order list.
21
22
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
23
Message-id: 20200826181006.4097163-1-ehabkost@redhat.com
24
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
25
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Message-id: 20180821165215.29069-3-peter.maydell@linaro.org
12
---
26
---
13
target/arm/iwmmxt_helper.c | 234 ++++++++++++++++++-------------------
27
include/hw/arm/armsse.h | 2 +-
14
1 file changed, 117 insertions(+), 117 deletions(-)
28
hw/arm/armsse.c | 1 +
29
2 files changed, 2 insertions(+), 1 deletion(-)
15
30
16
diff --git a/target/arm/iwmmxt_helper.c b/target/arm/iwmmxt_helper.c
31
diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h
17
index XXXXXXX..XXXXXXX 100644
32
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/iwmmxt_helper.c
33
--- a/include/hw/arm/armsse.h
19
+++ b/target/arm/iwmmxt_helper.c
34
+++ b/include/hw/arm/armsse.h
20
@@ -XXX,XX +XXX,XX @@
35
@@ -XXX,XX +XXX,XX @@ typedef struct ARMSSE {
21
/* iwMMXt macros extracted from GNU gdb. */
36
typedef struct ARMSSEInfo ARMSSEInfo;
22
37
23
/* Set the SIMD wCASF flags for 8, 16, 32 or 64-bit operations. */
38
typedef struct ARMSSEClass {
24
-#define SIMD8_SET( v, n, b)    ((v != 0) << ((((b) + 1) * 4) + (n)))
39
- DeviceClass parent_class;
25
-#define SIMD16_SET(v, n, h)    ((v != 0) << ((((h) + 1) * 8) + (n)))
40
+ SysBusDeviceClass parent_class;
26
-#define SIMD32_SET(v, n, w)    ((v != 0) << ((((w) + 1) * 16) + (n)))
41
const ARMSSEInfo *info;
27
-#define SIMD64_SET(v, n)    ((v != 0) << (32 + (n)))
42
} ARMSSEClass;
28
+#define SIMD8_SET(v, n, b) ((v != 0) << ((((b) + 1) * 4) + (n)))
43
29
+#define SIMD16_SET(v, n, h) ((v != 0) << ((((h) + 1) * 8) + (n)))
44
diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c
30
+#define SIMD32_SET(v, n, w) ((v != 0) << ((((w) + 1) * 16) + (n)))
45
index XXXXXXX..XXXXXXX 100644
31
+#define SIMD64_SET(v, n) ((v != 0) << (32 + (n)))
46
--- a/hw/arm/armsse.c
32
/* Flags to pass as "n" above. */
47
+++ b/hw/arm/armsse.c
33
-#define SIMD_NBIT    -1
48
@@ -XXX,XX +XXX,XX @@ static const TypeInfo armsse_info = {
34
-#define SIMD_ZBIT    -2
49
.name = TYPE_ARMSSE,
35
-#define SIMD_CBIT    -3
50
.parent = TYPE_SYS_BUS_DEVICE,
36
-#define SIMD_VBIT    -4
51
.instance_size = sizeof(ARMSSE),
37
+#define SIMD_NBIT -1
52
+ .class_size = sizeof(ARMSSEClass),
38
+#define SIMD_ZBIT -2
53
.instance_init = armsse_init,
39
+#define SIMD_CBIT -3
54
.abstract = true,
40
+#define SIMD_VBIT -4
55
.interfaces = (InterfaceInfo[]) {
41
/* Various status bit macros. */
42
-#define NBIT8(x)    ((x) & 0x80)
43
-#define NBIT16(x)    ((x) & 0x8000)
44
-#define NBIT32(x)    ((x) & 0x80000000)
45
-#define NBIT64(x)    ((x) & 0x8000000000000000ULL)
46
-#define ZBIT8(x)    (((x) & 0xff) == 0)
47
-#define ZBIT16(x)    (((x) & 0xffff) == 0)
48
-#define ZBIT32(x)    (((x) & 0xffffffff) == 0)
49
-#define ZBIT64(x)    (x == 0)
50
+#define NBIT8(x) ((x) & 0x80)
51
+#define NBIT16(x) ((x) & 0x8000)
52
+#define NBIT32(x) ((x) & 0x80000000)
53
+#define NBIT64(x) ((x) & 0x8000000000000000ULL)
54
+#define ZBIT8(x) (((x) & 0xff) == 0)
55
+#define ZBIT16(x) (((x) & 0xffff) == 0)
56
+#define ZBIT32(x) (((x) & 0xffffffff) == 0)
57
+#define ZBIT64(x) (x == 0)
58
/* Sign extension macros. */
59
-#define EXTEND8H(a)    ((uint16_t) (int8_t) (a))
60
-#define EXTEND8(a)    ((uint32_t) (int8_t) (a))
61
-#define EXTEND16(a)    ((uint32_t) (int16_t) (a))
62
-#define EXTEND16S(a)    ((int32_t) (int16_t) (a))
63
-#define EXTEND32(a)    ((uint64_t) (int32_t) (a))
64
+#define EXTEND8H(a) ((uint16_t) (int8_t) (a))
65
+#define EXTEND8(a) ((uint32_t) (int8_t) (a))
66
+#define EXTEND16(a) ((uint32_t) (int16_t) (a))
67
+#define EXTEND16S(a) ((int32_t) (int16_t) (a))
68
+#define EXTEND32(a) ((uint64_t) (int32_t) (a))
69
70
uint64_t HELPER(iwmmxt_maddsq)(uint64_t a, uint64_t b)
71
{
72
@@ -XXX,XX +XXX,XX @@ uint64_t HELPER(iwmmxt_macuw)(uint64_t a, uint64_t b)
73
#define NZBIT64(x) \
74
SIMD64_SET(NBIT64(x), SIMD_NBIT) | \
75
SIMD64_SET(ZBIT64(x), SIMD_ZBIT)
76
-#define IWMMXT_OP_UNPACK(S, SH0, SH1, SH2, SH3)            \
77
+#define IWMMXT_OP_UNPACK(S, SH0, SH1, SH2, SH3) \
78
uint64_t HELPER(glue(iwmmxt_unpack, glue(S, b)))(CPUARMState *env, \
79
uint64_t a, uint64_t b) \
80
-{                                \
81
- a =                             \
82
- (((a >> SH0) & 0xff) << 0) | (((b >> SH0) & 0xff) << 8) |    \
83
- (((a >> SH1) & 0xff) << 16) | (((b >> SH1) & 0xff) << 24) |    \
84
- (((a >> SH2) & 0xff) << 32) | (((b >> SH2) & 0xff) << 40) |    \
85
- (((a >> SH3) & 0xff) << 48) | (((b >> SH3) & 0xff) << 56);    \
86
- env->iwmmxt.cregs[ARM_IWMMXT_wCASF] =            \
87
- NZBIT8(a >> 0, 0) | NZBIT8(a >> 8, 1) |         \
88
- NZBIT8(a >> 16, 2) | NZBIT8(a >> 24, 3) |        \
89
- NZBIT8(a >> 32, 4) | NZBIT8(a >> 40, 5) |        \
90
- NZBIT8(a >> 48, 6) | NZBIT8(a >> 56, 7);        \
91
+{ \
92
+ a = \
93
+ (((a >> SH0) & 0xff) << 0) | (((b >> SH0) & 0xff) << 8) | \
94
+ (((a >> SH1) & 0xff) << 16) | (((b >> SH1) & 0xff) << 24) | \
95
+ (((a >> SH2) & 0xff) << 32) | (((b >> SH2) & 0xff) << 40) | \
96
+ (((a >> SH3) & 0xff) << 48) | (((b >> SH3) & 0xff) << 56); \
97
+ env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \
98
+ NZBIT8(a >> 0, 0) | NZBIT8(a >> 8, 1) | \
99
+ NZBIT8(a >> 16, 2) | NZBIT8(a >> 24, 3) | \
100
+ NZBIT8(a >> 32, 4) | NZBIT8(a >> 40, 5) | \
101
+ NZBIT8(a >> 48, 6) | NZBIT8(a >> 56, 7); \
102
return a; \
103
-}                                \
104
+} \
105
uint64_t HELPER(glue(iwmmxt_unpack, glue(S, w)))(CPUARMState *env, \
106
uint64_t a, uint64_t b) \
107
-{                                \
108
- a =                             \
109
- (((a >> SH0) & 0xffff) << 0) |                \
110
- (((b >> SH0) & 0xffff) << 16) |             \
111
- (((a >> SH2) & 0xffff) << 32) |             \
112
- (((b >> SH2) & 0xffff) << 48);                \
113
- env->iwmmxt.cregs[ARM_IWMMXT_wCASF] =            \
114
- NZBIT8(a >> 0, 0) | NZBIT8(a >> 16, 1) |        \
115
- NZBIT8(a >> 32, 2) | NZBIT8(a >> 48, 3);        \
116
+{ \
117
+ a = \
118
+ (((a >> SH0) & 0xffff) << 0) | \
119
+ (((b >> SH0) & 0xffff) << 16) | \
120
+ (((a >> SH2) & 0xffff) << 32) | \
121
+ (((b >> SH2) & 0xffff) << 48); \
122
+ env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \
123
+ NZBIT8(a >> 0, 0) | NZBIT8(a >> 16, 1) | \
124
+ NZBIT8(a >> 32, 2) | NZBIT8(a >> 48, 3); \
125
return a; \
126
-}                                \
127
+} \
128
uint64_t HELPER(glue(iwmmxt_unpack, glue(S, l)))(CPUARMState *env, \
129
uint64_t a, uint64_t b) \
130
-{                                \
131
- a =                             \
132
- (((a >> SH0) & 0xffffffff) << 0) |            \
133
- (((b >> SH0) & 0xffffffff) << 32);            \
134
- env->iwmmxt.cregs[ARM_IWMMXT_wCASF] =            \
135
- NZBIT32(a >> 0, 0) | NZBIT32(a >> 32, 1);        \
136
+{ \
137
+ a = \
138
+ (((a >> SH0) & 0xffffffff) << 0) | \
139
+ (((b >> SH0) & 0xffffffff) << 32); \
140
+ env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \
141
+ NZBIT32(a >> 0, 0) | NZBIT32(a >> 32, 1); \
142
return a; \
143
-}                                \
144
+} \
145
uint64_t HELPER(glue(iwmmxt_unpack, glue(S, ub)))(CPUARMState *env, \
146
uint64_t x) \
147
-{                                \
148
- x =                             \
149
- (((x >> SH0) & 0xff) << 0) |                \
150
- (((x >> SH1) & 0xff) << 16) |                \
151
- (((x >> SH2) & 0xff) << 32) |                \
152
- (((x >> SH3) & 0xff) << 48);                \
153
- env->iwmmxt.cregs[ARM_IWMMXT_wCASF] =            \
154
- NZBIT16(x >> 0, 0) | NZBIT16(x >> 16, 1) |        \
155
- NZBIT16(x >> 32, 2) | NZBIT16(x >> 48, 3);        \
156
+{ \
157
+ x = \
158
+ (((x >> SH0) & 0xff) << 0) | \
159
+ (((x >> SH1) & 0xff) << 16) | \
160
+ (((x >> SH2) & 0xff) << 32) | \
161
+ (((x >> SH3) & 0xff) << 48); \
162
+ env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \
163
+ NZBIT16(x >> 0, 0) | NZBIT16(x >> 16, 1) | \
164
+ NZBIT16(x >> 32, 2) | NZBIT16(x >> 48, 3); \
165
return x; \
166
-}                                \
167
+} \
168
uint64_t HELPER(glue(iwmmxt_unpack, glue(S, uw)))(CPUARMState *env, \
169
uint64_t x) \
170
-{                                \
171
- x =                             \
172
- (((x >> SH0) & 0xffff) << 0) |                \
173
- (((x >> SH2) & 0xffff) << 32);                \
174
- env->iwmmxt.cregs[ARM_IWMMXT_wCASF] =            \
175
- NZBIT32(x >> 0, 0) | NZBIT32(x >> 32, 1);        \
176
+{ \
177
+ x = \
178
+ (((x >> SH0) & 0xffff) << 0) | \
179
+ (((x >> SH2) & 0xffff) << 32); \
180
+ env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \
181
+ NZBIT32(x >> 0, 0) | NZBIT32(x >> 32, 1); \
182
return x; \
183
-}                                \
184
+} \
185
uint64_t HELPER(glue(iwmmxt_unpack, glue(S, ul)))(CPUARMState *env, \
186
uint64_t x) \
187
-{                                \
188
- x = (((x >> SH0) & 0xffffffff) << 0);            \
189
- env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = NZBIT64(x >> 0);    \
190
+{ \
191
+ x = (((x >> SH0) & 0xffffffff) << 0); \
192
+ env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = NZBIT64(x >> 0); \
193
return x; \
194
-}                                \
195
+} \
196
uint64_t HELPER(glue(iwmmxt_unpack, glue(S, sb)))(CPUARMState *env, \
197
uint64_t x) \
198
-{                                \
199
- x =                             \
200
- ((uint64_t) EXTEND8H((x >> SH0) & 0xff) << 0) |     \
201
- ((uint64_t) EXTEND8H((x >> SH1) & 0xff) << 16) |    \
202
- ((uint64_t) EXTEND8H((x >> SH2) & 0xff) << 32) |    \
203
- ((uint64_t) EXTEND8H((x >> SH3) & 0xff) << 48);     \
204
- env->iwmmxt.cregs[ARM_IWMMXT_wCASF] =            \
205
- NZBIT16(x >> 0, 0) | NZBIT16(x >> 16, 1) |        \
206
- NZBIT16(x >> 32, 2) | NZBIT16(x >> 48, 3);        \
207
+{ \
208
+ x = \
209
+ ((uint64_t) EXTEND8H((x >> SH0) & 0xff) << 0) | \
210
+ ((uint64_t) EXTEND8H((x >> SH1) & 0xff) << 16) | \
211
+ ((uint64_t) EXTEND8H((x >> SH2) & 0xff) << 32) | \
212
+ ((uint64_t) EXTEND8H((x >> SH3) & 0xff) << 48); \
213
+ env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \
214
+ NZBIT16(x >> 0, 0) | NZBIT16(x >> 16, 1) | \
215
+ NZBIT16(x >> 32, 2) | NZBIT16(x >> 48, 3); \
216
return x; \
217
-}                                \
218
+} \
219
uint64_t HELPER(glue(iwmmxt_unpack, glue(S, sw)))(CPUARMState *env, \
220
uint64_t x) \
221
-{                                \
222
- x =                             \
223
- ((uint64_t) EXTEND16((x >> SH0) & 0xffff) << 0) |    \
224
- ((uint64_t) EXTEND16((x >> SH2) & 0xffff) << 32);    \
225
- env->iwmmxt.cregs[ARM_IWMMXT_wCASF] =            \
226
- NZBIT32(x >> 0, 0) | NZBIT32(x >> 32, 1);        \
227
+{ \
228
+ x = \
229
+ ((uint64_t) EXTEND16((x >> SH0) & 0xffff) << 0) | \
230
+ ((uint64_t) EXTEND16((x >> SH2) & 0xffff) << 32); \
231
+ env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \
232
+ NZBIT32(x >> 0, 0) | NZBIT32(x >> 32, 1); \
233
return x; \
234
-}                                \
235
+} \
236
uint64_t HELPER(glue(iwmmxt_unpack, glue(S, sl)))(CPUARMState *env, \
237
uint64_t x) \
238
-{                                \
239
- x = EXTEND32((x >> SH0) & 0xffffffff);            \
240
- env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = NZBIT64(x >> 0);    \
241
+{ \
242
+ x = EXTEND32((x >> SH0) & 0xffffffff); \
243
+ env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = NZBIT64(x >> 0); \
244
return x; \
245
}
246
IWMMXT_OP_UNPACK(l, 0, 8, 16, 24)
247
IWMMXT_OP_UNPACK(h, 32, 40, 48, 56)
248
249
-#define IWMMXT_OP_CMP(SUFF, Tb, Tw, Tl, O)            \
250
+#define IWMMXT_OP_CMP(SUFF, Tb, Tw, Tl, O) \
251
uint64_t HELPER(glue(iwmmxt_, glue(SUFF, b)))(CPUARMState *env, \
252
uint64_t a, uint64_t b) \
253
-{                                \
254
- a =                             \
255
- CMP(0, Tb, O, 0xff) | CMP(8, Tb, O, 0xff) |        \
256
- CMP(16, Tb, O, 0xff) | CMP(24, Tb, O, 0xff) |        \
257
- CMP(32, Tb, O, 0xff) | CMP(40, Tb, O, 0xff) |        \
258
- CMP(48, Tb, O, 0xff) | CMP(56, Tb, O, 0xff);        \
259
- env->iwmmxt.cregs[ARM_IWMMXT_wCASF] =            \
260
- NZBIT8(a >> 0, 0) | NZBIT8(a >> 8, 1) |         \
261
- NZBIT8(a >> 16, 2) | NZBIT8(a >> 24, 3) |        \
262
- NZBIT8(a >> 32, 4) | NZBIT8(a >> 40, 5) |        \
263
- NZBIT8(a >> 48, 6) | NZBIT8(a >> 56, 7);        \
264
+{ \
265
+ a = \
266
+ CMP(0, Tb, O, 0xff) | CMP(8, Tb, O, 0xff) | \
267
+ CMP(16, Tb, O, 0xff) | CMP(24, Tb, O, 0xff) | \
268
+ CMP(32, Tb, O, 0xff) | CMP(40, Tb, O, 0xff) | \
269
+ CMP(48, Tb, O, 0xff) | CMP(56, Tb, O, 0xff); \
270
+ env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \
271
+ NZBIT8(a >> 0, 0) | NZBIT8(a >> 8, 1) | \
272
+ NZBIT8(a >> 16, 2) | NZBIT8(a >> 24, 3) | \
273
+ NZBIT8(a >> 32, 4) | NZBIT8(a >> 40, 5) | \
274
+ NZBIT8(a >> 48, 6) | NZBIT8(a >> 56, 7); \
275
return a; \
276
-}                                \
277
+} \
278
uint64_t HELPER(glue(iwmmxt_, glue(SUFF, w)))(CPUARMState *env, \
279
uint64_t a, uint64_t b) \
280
-{                                \
281
- a = CMP(0, Tw, O, 0xffff) | CMP(16, Tw, O, 0xffff) |    \
282
- CMP(32, Tw, O, 0xffff) | CMP(48, Tw, O, 0xffff);    \
283
- env->iwmmxt.cregs[ARM_IWMMXT_wCASF] =            \
284
- NZBIT16(a >> 0, 0) | NZBIT16(a >> 16, 1) |        \
285
- NZBIT16(a >> 32, 2) | NZBIT16(a >> 48, 3);        \
286
+{ \
287
+ a = CMP(0, Tw, O, 0xffff) | CMP(16, Tw, O, 0xffff) | \
288
+ CMP(32, Tw, O, 0xffff) | CMP(48, Tw, O, 0xffff); \
289
+ env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \
290
+ NZBIT16(a >> 0, 0) | NZBIT16(a >> 16, 1) | \
291
+ NZBIT16(a >> 32, 2) | NZBIT16(a >> 48, 3); \
292
return a; \
293
-}                                \
294
+} \
295
uint64_t HELPER(glue(iwmmxt_, glue(SUFF, l)))(CPUARMState *env, \
296
uint64_t a, uint64_t b) \
297
-{                                \
298
- a = CMP(0, Tl, O, 0xffffffff) |                \
299
- CMP(32, Tl, O, 0xffffffff);                \
300
- env->iwmmxt.cregs[ARM_IWMMXT_wCASF] =            \
301
- NZBIT32(a >> 0, 0) | NZBIT32(a >> 32, 1);        \
302
+{ \
303
+ a = CMP(0, Tl, O, 0xffffffff) | \
304
+ CMP(32, Tl, O, 0xffffffff); \
305
+ env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \
306
+ NZBIT32(a >> 0, 0) | NZBIT32(a >> 32, 1); \
307
return a; \
308
}
309
#define CMP(SHR, TYPE, OPER, MASK) ((((TYPE) ((a >> SHR) & MASK) OPER \
310
--
56
--
311
2.18.0
57
2.20.1
312
58
313
59
diff view generated by jsdifflib
1
The AN505 FPGA image includes four PL081 DMA controllers, each
1
From: Richard Henderson <richard.henderson@linaro.org>
2
of which is gated by a Master Security Controller that allows
3
the guest to prevent a non-secure DMA controller from accessing
4
memory that is used by secure guest code. Create and wire
5
up these devices.
6
2
3
Add left-shift to match the existing right-shift.
4
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Message-id: 20200815013145.539409-2-richard.henderson@linaro.org
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-id: 20180820141116.9118-15-peter.maydell@linaro.org
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
---
9
---
12
hw/arm/mps2-tz.c | 100 +++++++++++++++++++++++++++++++++++++++++++----
10
include/qemu/int128.h | 16 ++++++++++++++++
13
1 file changed, 93 insertions(+), 7 deletions(-)
11
1 file changed, 16 insertions(+)
14
12
15
diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c
13
diff --git a/include/qemu/int128.h b/include/qemu/int128.h
16
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/mps2-tz.c
15
--- a/include/qemu/int128.h
18
+++ b/hw/arm/mps2-tz.c
16
+++ b/include/qemu/int128.h
19
@@ -XXX,XX +XXX,XX @@
17
@@ -XXX,XX +XXX,XX @@ static inline Int128 int128_rshift(Int128 a, int n)
20
#include "hw/misc/mps2-scc.h"
18
return a >> n;
21
#include "hw/misc/mps2-fpgaio.h"
22
#include "hw/misc/tz-mpc.h"
23
+#include "hw/misc/tz-msc.h"
24
#include "hw/arm/iotkit.h"
25
+#include "hw/dma/pl080.h"
26
#include "hw/devices.h"
27
#include "net/net.h"
28
#include "hw/core/split-irq.h"
29
@@ -XXX,XX +XXX,XX @@ typedef struct {
30
UnimplementedDeviceState i2c[4];
31
UnimplementedDeviceState i2s_audio;
32
UnimplementedDeviceState gpio[4];
33
- UnimplementedDeviceState dma[4];
34
UnimplementedDeviceState gfx;
35
+ PL080State dma[4];
36
+ TZMSC msc[4];
37
CMSDKAPBUART uart[5];
38
SplitIRQ sec_resp_splitter;
39
qemu_or_irq uart_irq_orgate;
40
@@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_mpc(MPS2TZMachineState *mms, void *opaque,
41
return sysbus_mmio_get_region(SYS_BUS_DEVICE(mpc), 0);
42
}
19
}
43
20
44
+static MemoryRegion *make_dma(MPS2TZMachineState *mms, void *opaque,
21
+static inline Int128 int128_lshift(Int128 a, int n)
45
+ const char *name, hwaddr size)
46
+{
22
+{
47
+ PL080State *dma = opaque;
23
+ return a << n;
48
+ int i = dma - &mms->dma[0];
49
+ SysBusDevice *s;
50
+ char *mscname = g_strdup_printf("%s-msc", name);
51
+ TZMSC *msc = &mms->msc[i];
52
+ DeviceState *iotkitdev = DEVICE(&mms->iotkit);
53
+ MemoryRegion *msc_upstream;
54
+ MemoryRegion *msc_downstream;
55
+
56
+ /*
57
+ * Each DMA device is a PL081 whose transaction master interface
58
+ * is guarded by a Master Security Controller. The downstream end of
59
+ * the MSC connects to the IoTKit AHB Slave Expansion port, so the
60
+ * DMA devices can see all devices and memory that the CPU does.
61
+ */
62
+ sysbus_init_child_obj(OBJECT(mms), mscname, msc, sizeof(*msc), TYPE_TZ_MSC);
63
+ msc_downstream = sysbus_mmio_get_region(SYS_BUS_DEVICE(&mms->iotkit), 0);
64
+ object_property_set_link(OBJECT(msc), OBJECT(msc_downstream),
65
+ "downstream", &error_fatal);
66
+ object_property_set_link(OBJECT(msc), OBJECT(mms),
67
+ "idau", &error_fatal);
68
+ object_property_set_bool(OBJECT(msc), true, "realized", &error_fatal);
69
+
70
+ qdev_connect_gpio_out_named(DEVICE(msc), "irq", 0,
71
+ qdev_get_gpio_in_named(iotkitdev,
72
+ "mscexp_status", i));
73
+ qdev_connect_gpio_out_named(iotkitdev, "mscexp_clear", i,
74
+ qdev_get_gpio_in_named(DEVICE(msc),
75
+ "irq_clear", 0));
76
+ qdev_connect_gpio_out_named(iotkitdev, "mscexp_ns", i,
77
+ qdev_get_gpio_in_named(DEVICE(msc),
78
+ "cfg_nonsec", 0));
79
+ qdev_connect_gpio_out(DEVICE(&mms->sec_resp_splitter),
80
+ ARRAY_SIZE(mms->ppc) + i,
81
+ qdev_get_gpio_in_named(DEVICE(msc),
82
+ "cfg_sec_resp", 0));
83
+ msc_upstream = sysbus_mmio_get_region(SYS_BUS_DEVICE(msc), 0);
84
+
85
+ sysbus_init_child_obj(OBJECT(mms), name, dma, sizeof(*dma), TYPE_PL081);
86
+ object_property_set_link(OBJECT(dma), OBJECT(msc_upstream),
87
+ "downstream", &error_fatal);
88
+ object_property_set_bool(OBJECT(dma), true, "realized", &error_fatal);
89
+
90
+ s = SYS_BUS_DEVICE(dma);
91
+ /* Wire up DMACINTR, DMACINTERR, DMACINTTC */
92
+ sysbus_connect_irq(s, 0, qdev_get_gpio_in_named(iotkitdev,
93
+ "EXP_IRQ", 58 + i * 3));
94
+ sysbus_connect_irq(s, 1, qdev_get_gpio_in_named(iotkitdev,
95
+ "EXP_IRQ", 56 + i * 3));
96
+ sysbus_connect_irq(s, 2, qdev_get_gpio_in_named(iotkitdev,
97
+ "EXP_IRQ", 57 + i * 3));
98
+
99
+ return sysbus_mmio_get_region(s, 0);
100
+}
24
+}
101
+
25
+
102
static void mps2tz_common_init(MachineState *machine)
26
static inline Int128 int128_add(Int128 a, Int128 b)
103
{
27
{
104
MPS2TZMachineState *mms = MPS2TZ_MACHINE(machine);
28
return a + b;
105
@@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine)
29
@@ -XXX,XX +XXX,XX @@ static inline Int128 int128_rshift(Int128 a, int n)
106
&error_fatal);
30
}
107
108
/* The sec_resp_cfg output from the IoTKit must be split into multiple
109
- * lines, one for each of the PPCs we create here.
110
+ * lines, one for each of the PPCs we create here, plus one per MSC.
111
*/
112
object_initialize(&mms->sec_resp_splitter, sizeof(mms->sec_resp_splitter),
113
TYPE_SPLIT_IRQ);
114
object_property_add_child(OBJECT(machine), "sec-resp-splitter",
115
OBJECT(&mms->sec_resp_splitter), &error_abort);
116
- object_property_set_int(OBJECT(&mms->sec_resp_splitter), 5,
117
+ object_property_set_int(OBJECT(&mms->sec_resp_splitter),
118
+ ARRAY_SIZE(mms->ppc) + ARRAY_SIZE(mms->msc),
119
"num-lines", &error_fatal);
120
object_property_set_bool(OBJECT(&mms->sec_resp_splitter), true,
121
"realized", &error_fatal);
122
@@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine)
123
}, {
124
.name = "ahb_ppcexp1",
125
.ports = {
126
- { "dma0", make_unimp_dev, &mms->dma[0], 0x40110000, 0x1000 },
127
- { "dma1", make_unimp_dev, &mms->dma[1], 0x40111000, 0x1000 },
128
- { "dma2", make_unimp_dev, &mms->dma[2], 0x40112000, 0x1000 },
129
- { "dma3", make_unimp_dev, &mms->dma[3], 0x40113000, 0x1000 },
130
+ { "dma0", make_dma, &mms->dma[0], 0x40110000, 0x1000 },
131
+ { "dma1", make_dma, &mms->dma[1], 0x40111000, 0x1000 },
132
+ { "dma2", make_dma, &mms->dma[2], 0x40112000, 0x1000 },
133
+ { "dma3", make_dma, &mms->dma[3], 0x40113000, 0x1000 },
134
},
135
},
136
};
137
@@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine)
138
armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, 0x400000);
139
}
31
}
140
32
141
+static void mps2_tz_idau_check(IDAUInterface *ii, uint32_t address,
33
+static inline Int128 int128_lshift(Int128 a, int n)
142
+ int *iregion, bool *exempt, bool *ns, bool *nsc)
143
+{
34
+{
144
+ /*
35
+ uint64_t l = a.lo << (n & 63);
145
+ * The MPS2 TZ FPGA images have IDAUs in them which are connected to
36
+ if (n >= 64) {
146
+ * the Master Security Controllers. Thes have the same logic as
37
+ return int128_make128(0, l);
147
+ * is used by the IoTKit for the IDAU connected to the CPU, except
38
+ } else if (n > 0) {
148
+ * that MSCs don't care about the NSC attribute.
39
+ return int128_make128(l, (a.hi << n) | (a.lo >> (64 - n)));
149
+ */
40
+ }
150
+ int region = extract32(address, 28, 4);
41
+ return a;
151
+
152
+ *ns = !(region & 1);
153
+ *nsc = false;
154
+ /* 0xe0000000..0xe00fffff and 0xf0000000..0xf00fffff are exempt */
155
+ *exempt = (address & 0xeff00000) == 0xe0000000;
156
+ *iregion = region;
157
+}
42
+}
158
+
43
+
159
static void mps2tz_class_init(ObjectClass *oc, void *data)
44
static inline Int128 int128_add(Int128 a, Int128 b)
160
{
45
{
161
MachineClass *mc = MACHINE_CLASS(oc);
46
uint64_t lo = a.lo + b.lo;
162
+ IDAUInterfaceClass *iic = IDAU_INTERFACE_CLASS(oc);
163
164
mc->init = mps2tz_common_init;
165
mc->max_cpus = 1;
166
+ iic->check = mps2_tz_idau_check;
167
}
168
169
static void mps2tz_an505_class_init(ObjectClass *oc, void *data)
170
@@ -XXX,XX +XXX,XX @@ static const TypeInfo mps2tz_info = {
171
.instance_size = sizeof(MPS2TZMachineState),
172
.class_size = sizeof(MPS2TZMachineClass),
173
.class_init = mps2tz_class_init,
174
+ .interfaces = (InterfaceInfo[]) {
175
+ { TYPE_IDAU_INTERFACE },
176
+ { }
177
+ },
178
};
179
180
static const TypeInfo mps2tz_an505_info = {
181
--
47
--
182
2.18.0
48
2.20.1
183
49
184
50
diff view generated by jsdifflib
1
Use the DeviceState vmsd pointer rather than calling vmstate_register()
1
From: Richard Henderson <richard.henderson@linaro.org>
2
directly.
3
2
3
Model the new function on gen_gvec_fn2 in translate-a64.c, but
4
indicating which kind of register and in which order. Since there
5
is only one user of do_vector2_z, fold it into do_mov_z.
6
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20200815013145.539409-3-richard.henderson@linaro.org
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Message-id: 20180820141116.9118-18-peter.maydell@linaro.org
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
---
11
---
8
hw/ssi/pl022.c | 2 +-
12
target/arm/translate-sve.c | 19 ++++++++++---------
9
1 file changed, 1 insertion(+), 1 deletion(-)
13
1 file changed, 10 insertions(+), 9 deletions(-)
10
14
11
diff --git a/hw/ssi/pl022.c b/hw/ssi/pl022.c
15
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
12
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/ssi/pl022.c
17
--- a/target/arm/translate-sve.c
14
+++ b/hw/ssi/pl022.c
18
+++ b/target/arm/translate-sve.c
15
@@ -XXX,XX +XXX,XX @@ static int pl022_init(SysBusDevice *sbd)
19
@@ -XXX,XX +XXX,XX @@ static int pred_gvec_reg_size(DisasContext *s)
16
sysbus_init_mmio(sbd, &s->iomem);
17
sysbus_init_irq(sbd, &s->irq);
18
s->ssi = ssi_create_bus(dev, "ssi");
19
- vmstate_register(dev, -1, &vmstate_pl022, s);
20
return 0;
21
}
20
}
22
21
23
@@ -XXX,XX +XXX,XX @@ static void pl022_class_init(ObjectClass *klass, void *data)
22
/* Invoke a vector expander on two Zregs. */
24
23
-static bool do_vector2_z(DisasContext *s, GVecGen2Fn *gvec_fn,
25
sdc->init = pl022_init;
24
- int esz, int rd, int rn)
26
dc->reset = pl022_reset;
25
+
27
+ dc->vmsd = &vmstate_pl022;
26
+static void gen_gvec_fn_zz(DisasContext *s, GVecGen2Fn *gvec_fn,
27
+ int esz, int rd, int rn)
28
{
29
- if (sve_access_check(s)) {
30
- unsigned vsz = vec_full_reg_size(s);
31
- gvec_fn(esz, vec_full_reg_offset(s, rd),
32
- vec_full_reg_offset(s, rn), vsz, vsz);
33
- }
34
- return true;
35
+ unsigned vsz = vec_full_reg_size(s);
36
+ gvec_fn(esz, vec_full_reg_offset(s, rd),
37
+ vec_full_reg_offset(s, rn), vsz, vsz);
28
}
38
}
29
39
30
static const TypeInfo pl022_info = {
40
/* Invoke a vector expander on three Zregs. */
41
@@ -XXX,XX +XXX,XX @@ static bool do_vector3_z(DisasContext *s, GVecGen3Fn *gvec_fn,
42
/* Invoke a vector move on two Zregs. */
43
static bool do_mov_z(DisasContext *s, int rd, int rn)
44
{
45
- return do_vector2_z(s, tcg_gen_gvec_mov, 0, rd, rn);
46
+ if (sve_access_check(s)) {
47
+ gen_gvec_fn_zz(s, tcg_gen_gvec_mov, MO_8, rd, rn);
48
+ }
49
+ return true;
50
}
51
52
/* Initialize a Zreg with replications of a 64-bit immediate. */
31
--
53
--
32
2.18.0
54
2.20.1
33
55
34
56
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Model gen_gvec_fn_zzz on gen_gvec_fn3 in translate-a64.c, but
4
indicating which kind of register and in which order.
5
6
Model do_zzz_fn on the other do_foo functions that take an
7
argument set and verify sve enabled.
8
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Message-id: 20180814002653.12828-2-richard.henderson@linaro.org
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Message-id: 20200815013145.539409-4-richard.henderson@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
13
---
8
include/fpu/softfloat.h | 56 ++++++++----
14
target/arm/translate-sve.c | 43 +++++++++++++++++++++-----------------
9
fpu/softfloat.c | 188 +++++++++++++++++++++++++++++-----------
15
1 file changed, 24 insertions(+), 19 deletions(-)
10
2 files changed, 179 insertions(+), 65 deletions(-)
11
16
12
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
17
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
13
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
14
--- a/include/fpu/softfloat.h
19
--- a/target/arm/translate-sve.c
15
+++ b/include/fpu/softfloat.h
20
+++ b/target/arm/translate-sve.c
16
@@ -XXX,XX +XXX,XX @@ enum {
21
@@ -XXX,XX +XXX,XX @@ static void gen_gvec_fn_zz(DisasContext *s, GVecGen2Fn *gvec_fn,
17
/*----------------------------------------------------------------------------
22
}
18
| Software IEC/IEEE integer-to-floating-point conversion routines.
23
19
*----------------------------------------------------------------------------*/
24
/* Invoke a vector expander on three Zregs. */
20
+
25
-static bool do_vector3_z(DisasContext *s, GVecGen3Fn *gvec_fn,
21
+float16 int16_to_float16_scalbn(int16_t a, int, float_status *status);
26
- int esz, int rd, int rn, int rm)
22
+float16 int32_to_float16_scalbn(int32_t a, int, float_status *status);
27
+static void gen_gvec_fn_zzz(DisasContext *s, GVecGen3Fn *gvec_fn,
23
+float16 int64_to_float16_scalbn(int64_t a, int, float_status *status);
28
+ int esz, int rd, int rn, int rm)
24
+float16 uint16_to_float16_scalbn(uint16_t a, int, float_status *status);
29
{
25
+float16 uint32_to_float16_scalbn(uint32_t a, int, float_status *status);
30
- if (sve_access_check(s)) {
26
+float16 uint64_to_float16_scalbn(uint64_t a, int, float_status *status);
31
- unsigned vsz = vec_full_reg_size(s);
27
+
32
- gvec_fn(esz, vec_full_reg_offset(s, rd),
28
+float16 int16_to_float16(int16_t a, float_status *status);
33
- vec_full_reg_offset(s, rn),
29
+float16 int32_to_float16(int32_t a, float_status *status);
34
- vec_full_reg_offset(s, rm), vsz, vsz);
30
+float16 int64_to_float16(int64_t a, float_status *status);
35
- }
31
+float16 uint16_to_float16(uint16_t a, float_status *status);
36
- return true;
32
+float16 uint32_to_float16(uint32_t a, float_status *status);
37
+ unsigned vsz = vec_full_reg_size(s);
33
+float16 uint64_to_float16(uint64_t a, float_status *status);
38
+ gvec_fn(esz, vec_full_reg_offset(s, rd),
34
+
39
+ vec_full_reg_offset(s, rn),
35
+float32 int16_to_float32_scalbn(int16_t, int, float_status *status);
40
+ vec_full_reg_offset(s, rm), vsz, vsz);
36
+float32 int32_to_float32_scalbn(int32_t, int, float_status *status);
41
}
37
+float32 int64_to_float32_scalbn(int64_t, int, float_status *status);
42
38
+float32 uint16_to_float32_scalbn(uint16_t, int, float_status *status);
43
/* Invoke a vector move on two Zregs. */
39
+float32 uint32_to_float32_scalbn(uint32_t, int, float_status *status);
44
@@ -XXX,XX +XXX,XX @@ const uint64_t pred_esz_masks[4] = {
40
+float32 uint64_to_float32_scalbn(uint64_t, int, float_status *status);
45
*** SVE Logical - Unpredicated Group
41
+
42
float32 int16_to_float32(int16_t, float_status *status);
43
float32 int32_to_float32(int32_t, float_status *status);
44
-float64 int16_to_float64(int16_t, float_status *status);
45
-float64 int32_to_float64(int32_t, float_status *status);
46
+float32 int64_to_float32(int64_t, float_status *status);
47
float32 uint16_to_float32(uint16_t, float_status *status);
48
float32 uint32_to_float32(uint32_t, float_status *status);
49
+float32 uint64_to_float32(uint64_t, float_status *status);
50
+
51
+float64 int16_to_float64_scalbn(int16_t, int, float_status *status);
52
+float64 int32_to_float64_scalbn(int32_t, int, float_status *status);
53
+float64 int64_to_float64_scalbn(int64_t, int, float_status *status);
54
+float64 uint16_to_float64_scalbn(uint16_t, int, float_status *status);
55
+float64 uint32_to_float64_scalbn(uint32_t, int, float_status *status);
56
+float64 uint64_to_float64_scalbn(uint64_t, int, float_status *status);
57
+
58
+float64 int16_to_float64(int16_t, float_status *status);
59
+float64 int32_to_float64(int32_t, float_status *status);
60
+float64 int64_to_float64(int64_t, float_status *status);
61
float64 uint16_to_float64(uint16_t, float_status *status);
62
float64 uint32_to_float64(uint32_t, float_status *status);
63
-floatx80 int32_to_floatx80(int32_t, float_status *status);
64
-float128 int32_to_float128(int32_t, float_status *status);
65
-float32 int64_to_float32(int64_t, float_status *status);
66
-float64 int64_to_float64(int64_t, float_status *status);
67
-floatx80 int64_to_floatx80(int64_t, float_status *status);
68
-float128 int64_to_float128(int64_t, float_status *status);
69
-float32 uint64_to_float32(uint64_t, float_status *status);
70
float64 uint64_to_float64(uint64_t, float_status *status);
71
+
72
+floatx80 int32_to_floatx80(int32_t, float_status *status);
73
+floatx80 int64_to_floatx80(int64_t, float_status *status);
74
+
75
+float128 int32_to_float128(int32_t, float_status *status);
76
+float128 int64_to_float128(int64_t, float_status *status);
77
float128 uint64_to_float128(uint64_t, float_status *status);
78
79
/*----------------------------------------------------------------------------
80
@@ -XXX,XX +XXX,XX @@ int64_t float16_to_int64(float16, float_status *status);
81
uint64_t float16_to_uint64(float16 a, float_status *status);
82
int64_t float16_to_int64_round_to_zero(float16, float_status *status);
83
uint64_t float16_to_uint64_round_to_zero(float16 a, float_status *status);
84
-float16 int16_to_float16(int16_t a, float_status *status);
85
-float16 int32_to_float16(int32_t a, float_status *status);
86
-float16 int64_to_float16(int64_t a, float_status *status);
87
-float16 uint16_to_float16(uint16_t a, float_status *status);
88
-float16 uint32_to_float16(uint32_t a, float_status *status);
89
-float16 uint64_to_float16(uint64_t a, float_status *status);
90
91
/*----------------------------------------------------------------------------
92
| Software half-precision operations.
93
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
94
index XXXXXXX..XXXXXXX 100644
95
--- a/fpu/softfloat.c
96
+++ b/fpu/softfloat.c
97
@@ -XXX,XX +XXX,XX @@ FLOAT_TO_UINT(64, 64)
98
* to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
99
*/
46
*/
100
47
101
-static FloatParts int_to_float(int64_t a, float_status *status)
48
+static bool do_zzz_fn(DisasContext *s, arg_rrr_esz *a, GVecGen3Fn *gvec_fn)
102
+static FloatParts int_to_float(int64_t a, int scale, float_status *status)
103
{
104
- FloatParts r = {};
105
+ FloatParts r = { .sign = false };
106
+
107
if (a == 0) {
108
r.cls = float_class_zero;
109
- r.sign = false;
110
- } else if (a == (1ULL << 63)) {
111
- r.cls = float_class_normal;
112
- r.sign = true;
113
- r.frac = DECOMPOSED_IMPLICIT_BIT;
114
- r.exp = 63;
115
} else {
116
- uint64_t f;
117
- if (a < 0) {
118
- f = -a;
119
- r.sign = true;
120
- } else {
121
- f = a;
122
- r.sign = false;
123
- }
124
- int shift = clz64(f) - 1;
125
+ uint64_t f = a;
126
+ int shift;
127
+
128
r.cls = float_class_normal;
129
- r.exp = (DECOMPOSED_BINARY_POINT - shift);
130
- r.frac = f << shift;
131
+ if (a < 0) {
132
+ f = -f;
133
+ r.sign = true;
134
+ }
135
+ shift = clz64(f) - 1;
136
+ scale = MIN(MAX(scale, -0x10000), 0x10000);
137
+
138
+ r.exp = DECOMPOSED_BINARY_POINT - shift + scale;
139
+ r.frac = (shift < 0 ? DECOMPOSED_IMPLICIT_BIT : f << shift);
140
}
141
142
return r;
143
}
144
145
+float16 int64_to_float16_scalbn(int64_t a, int scale, float_status *status)
146
+{
49
+{
147
+ FloatParts pa = int_to_float(a, scale, status);
50
+ if (sve_access_check(s)) {
148
+ return float16_round_pack_canonical(pa, status);
51
+ gen_gvec_fn_zzz(s, gvec_fn, a->esz, a->rd, a->rn, a->rm);
52
+ }
53
+ return true;
149
+}
54
+}
150
+
55
+
151
+float16 int32_to_float16_scalbn(int32_t a, int scale, float_status *status)
56
static bool trans_AND_zzz(DisasContext *s, arg_rrr_esz *a)
152
+{
153
+ return int64_to_float16_scalbn(a, scale, status);
154
+}
155
+
156
+float16 int16_to_float16_scalbn(int16_t a, int scale, float_status *status)
157
+{
158
+ return int64_to_float16_scalbn(a, scale, status);
159
+}
160
+
161
float16 int64_to_float16(int64_t a, float_status *status)
162
{
57
{
163
- FloatParts pa = int_to_float(a, status);
58
- return do_vector3_z(s, tcg_gen_gvec_and, 0, a->rd, a->rn, a->rm);
164
- return float16_round_pack_canonical(pa, status);
59
+ return do_zzz_fn(s, a, tcg_gen_gvec_and);
165
+ return int64_to_float16_scalbn(a, 0, status);
166
}
60
}
167
61
168
float16 int32_to_float16(int32_t a, float_status *status)
62
static bool trans_ORR_zzz(DisasContext *s, arg_rrr_esz *a)
169
{
63
{
170
- return int64_to_float16(a, status);
64
- return do_vector3_z(s, tcg_gen_gvec_or, 0, a->rd, a->rn, a->rm);
171
+ return int64_to_float16_scalbn(a, 0, status);
65
+ return do_zzz_fn(s, a, tcg_gen_gvec_or);
172
}
66
}
173
67
174
float16 int16_to_float16(int16_t a, float_status *status)
68
static bool trans_EOR_zzz(DisasContext *s, arg_rrr_esz *a)
175
{
69
{
176
- return int64_to_float16(a, status);
70
- return do_vector3_z(s, tcg_gen_gvec_xor, 0, a->rd, a->rn, a->rm);
177
+ return int64_to_float16_scalbn(a, 0, status);
71
+ return do_zzz_fn(s, a, tcg_gen_gvec_xor);
178
+}
179
+
180
+float32 int64_to_float32_scalbn(int64_t a, int scale, float_status *status)
181
+{
182
+ FloatParts pa = int_to_float(a, scale, status);
183
+ return float32_round_pack_canonical(pa, status);
184
+}
185
+
186
+float32 int32_to_float32_scalbn(int32_t a, int scale, float_status *status)
187
+{
188
+ return int64_to_float32_scalbn(a, scale, status);
189
+}
190
+
191
+float32 int16_to_float32_scalbn(int16_t a, int scale, float_status *status)
192
+{
193
+ return int64_to_float32_scalbn(a, scale, status);
194
}
72
}
195
73
196
float32 int64_to_float32(int64_t a, float_status *status)
74
static bool trans_BIC_zzz(DisasContext *s, arg_rrr_esz *a)
197
{
75
{
198
- FloatParts pa = int_to_float(a, status);
76
- return do_vector3_z(s, tcg_gen_gvec_andc, 0, a->rd, a->rn, a->rm);
199
- return float32_round_pack_canonical(pa, status);
77
+ return do_zzz_fn(s, a, tcg_gen_gvec_andc);
200
+ return int64_to_float32_scalbn(a, 0, status);
201
}
78
}
202
79
203
float32 int32_to_float32(int32_t a, float_status *status)
80
/*
81
@@ -XXX,XX +XXX,XX @@ static bool trans_BIC_zzz(DisasContext *s, arg_rrr_esz *a)
82
83
static bool trans_ADD_zzz(DisasContext *s, arg_rrr_esz *a)
204
{
84
{
205
- return int64_to_float32(a, status);
85
- return do_vector3_z(s, tcg_gen_gvec_add, a->esz, a->rd, a->rn, a->rm);
206
+ return int64_to_float32_scalbn(a, 0, status);
86
+ return do_zzz_fn(s, a, tcg_gen_gvec_add);
207
}
87
}
208
88
209
float32 int16_to_float32(int16_t a, float_status *status)
89
static bool trans_SUB_zzz(DisasContext *s, arg_rrr_esz *a)
210
{
90
{
211
- return int64_to_float32(a, status);
91
- return do_vector3_z(s, tcg_gen_gvec_sub, a->esz, a->rd, a->rn, a->rm);
212
+ return int64_to_float32_scalbn(a, 0, status);
92
+ return do_zzz_fn(s, a, tcg_gen_gvec_sub);
213
+}
214
+
215
+float64 int64_to_float64_scalbn(int64_t a, int scale, float_status *status)
216
+{
217
+ FloatParts pa = int_to_float(a, scale, status);
218
+ return float64_round_pack_canonical(pa, status);
219
+}
220
+
221
+float64 int32_to_float64_scalbn(int32_t a, int scale, float_status *status)
222
+{
223
+ return int64_to_float64_scalbn(a, scale, status);
224
+}
225
+
226
+float64 int16_to_float64_scalbn(int16_t a, int scale, float_status *status)
227
+{
228
+ return int64_to_float64_scalbn(a, scale, status);
229
}
93
}
230
94
231
float64 int64_to_float64(int64_t a, float_status *status)
95
static bool trans_SQADD_zzz(DisasContext *s, arg_rrr_esz *a)
232
{
96
{
233
- FloatParts pa = int_to_float(a, status);
97
- return do_vector3_z(s, tcg_gen_gvec_ssadd, a->esz, a->rd, a->rn, a->rm);
234
- return float64_round_pack_canonical(pa, status);
98
+ return do_zzz_fn(s, a, tcg_gen_gvec_ssadd);
235
+ return int64_to_float64_scalbn(a, 0, status);
236
}
99
}
237
100
238
float64 int32_to_float64(int32_t a, float_status *status)
101
static bool trans_SQSUB_zzz(DisasContext *s, arg_rrr_esz *a)
239
{
102
{
240
- return int64_to_float64(a, status);
103
- return do_vector3_z(s, tcg_gen_gvec_sssub, a->esz, a->rd, a->rn, a->rm);
241
+ return int64_to_float64_scalbn(a, 0, status);
104
+ return do_zzz_fn(s, a, tcg_gen_gvec_sssub);
242
}
105
}
243
106
244
float64 int16_to_float64(int16_t a, float_status *status)
107
static bool trans_UQADD_zzz(DisasContext *s, arg_rrr_esz *a)
245
{
108
{
246
- return int64_to_float64(a, status);
109
- return do_vector3_z(s, tcg_gen_gvec_usadd, a->esz, a->rd, a->rn, a->rm);
247
+ return int64_to_float64_scalbn(a, 0, status);
110
+ return do_zzz_fn(s, a, tcg_gen_gvec_usadd);
248
}
111
}
249
112
250
113
static bool trans_UQSUB_zzz(DisasContext *s, arg_rrr_esz *a)
251
@@ -XXX,XX +XXX,XX @@ float64 int16_to_float64(int16_t a, float_status *status)
252
* IEC/IEEE Standard for Binary Floating-Point Arithmetic.
253
*/
254
255
-static FloatParts uint_to_float(uint64_t a, float_status *status)
256
+static FloatParts uint_to_float(uint64_t a, int scale, float_status *status)
257
{
114
{
258
- FloatParts r = { .sign = false};
115
- return do_vector3_z(s, tcg_gen_gvec_ussub, a->esz, a->rd, a->rn, a->rm);
259
+ FloatParts r = { .sign = false };
116
+ return do_zzz_fn(s, a, tcg_gen_gvec_ussub);
260
261
if (a == 0) {
262
r.cls = float_class_zero;
263
} else {
264
- int spare_bits = clz64(a) - 1;
265
+ scale = MIN(MAX(scale, -0x10000), 0x10000);
266
r.cls = float_class_normal;
267
- r.exp = DECOMPOSED_BINARY_POINT - spare_bits;
268
- if (spare_bits < 0) {
269
- shift64RightJamming(a, -spare_bits, &a);
270
+ if ((int64_t)a < 0) {
271
+ r.exp = DECOMPOSED_BINARY_POINT + 1 + scale;
272
+ shift64RightJamming(a, 1, &a);
273
r.frac = a;
274
} else {
275
- r.frac = a << spare_bits;
276
+ int shift = clz64(a) - 1;
277
+ r.exp = DECOMPOSED_BINARY_POINT - shift + scale;
278
+ r.frac = a << shift;
279
}
280
}
281
282
return r;
283
}
117
}
284
118
285
+float16 uint64_to_float16_scalbn(uint64_t a, int scale, float_status *status)
119
/*
286
+{
287
+ FloatParts pa = uint_to_float(a, scale, status);
288
+ return float16_round_pack_canonical(pa, status);
289
+}
290
+
291
+float16 uint32_to_float16_scalbn(uint32_t a, int scale, float_status *status)
292
+{
293
+ return uint64_to_float16_scalbn(a, scale, status);
294
+}
295
+
296
+float16 uint16_to_float16_scalbn(uint16_t a, int scale, float_status *status)
297
+{
298
+ return uint64_to_float16_scalbn(a, scale, status);
299
+}
300
+
301
float16 uint64_to_float16(uint64_t a, float_status *status)
302
{
303
- FloatParts pa = uint_to_float(a, status);
304
- return float16_round_pack_canonical(pa, status);
305
+ return uint64_to_float16_scalbn(a, 0, status);
306
}
307
308
float16 uint32_to_float16(uint32_t a, float_status *status)
309
{
310
- return uint64_to_float16(a, status);
311
+ return uint64_to_float16_scalbn(a, 0, status);
312
}
313
314
float16 uint16_to_float16(uint16_t a, float_status *status)
315
{
316
- return uint64_to_float16(a, status);
317
+ return uint64_to_float16_scalbn(a, 0, status);
318
+}
319
+
320
+float32 uint64_to_float32_scalbn(uint64_t a, int scale, float_status *status)
321
+{
322
+ FloatParts pa = uint_to_float(a, scale, status);
323
+ return float32_round_pack_canonical(pa, status);
324
+}
325
+
326
+float32 uint32_to_float32_scalbn(uint32_t a, int scale, float_status *status)
327
+{
328
+ return uint64_to_float32_scalbn(a, scale, status);
329
+}
330
+
331
+float32 uint16_to_float32_scalbn(uint16_t a, int scale, float_status *status)
332
+{
333
+ return uint64_to_float32_scalbn(a, scale, status);
334
}
335
336
float32 uint64_to_float32(uint64_t a, float_status *status)
337
{
338
- FloatParts pa = uint_to_float(a, status);
339
- return float32_round_pack_canonical(pa, status);
340
+ return uint64_to_float32_scalbn(a, 0, status);
341
}
342
343
float32 uint32_to_float32(uint32_t a, float_status *status)
344
{
345
- return uint64_to_float32(a, status);
346
+ return uint64_to_float32_scalbn(a, 0, status);
347
}
348
349
float32 uint16_to_float32(uint16_t a, float_status *status)
350
{
351
- return uint64_to_float32(a, status);
352
+ return uint64_to_float32_scalbn(a, 0, status);
353
+}
354
+
355
+float64 uint64_to_float64_scalbn(uint64_t a, int scale, float_status *status)
356
+{
357
+ FloatParts pa = uint_to_float(a, scale, status);
358
+ return float64_round_pack_canonical(pa, status);
359
+}
360
+
361
+float64 uint32_to_float64_scalbn(uint32_t a, int scale, float_status *status)
362
+{
363
+ return uint64_to_float64_scalbn(a, scale, status);
364
+}
365
+
366
+float64 uint16_to_float64_scalbn(uint16_t a, int scale, float_status *status)
367
+{
368
+ return uint64_to_float64_scalbn(a, scale, status);
369
}
370
371
float64 uint64_to_float64(uint64_t a, float_status *status)
372
{
373
- FloatParts pa = uint_to_float(a, status);
374
- return float64_round_pack_canonical(pa, status);
375
+ return uint64_to_float64_scalbn(a, 0, status);
376
}
377
378
float64 uint32_to_float64(uint32_t a, float_status *status)
379
{
380
- return uint64_to_float64(a, status);
381
+ return uint64_to_float64_scalbn(a, 0, status);
382
}
383
384
float64 uint16_to_float64(uint16_t a, float_status *status)
385
{
386
- return uint64_to_float64(a, status);
387
+ return uint64_to_float64_scalbn(a, 0, status);
388
}
389
390
/* Float Min/Max */
391
--
120
--
392
2.18.0
121
2.20.1
393
122
394
123
diff view generated by jsdifflib
1
Factor out the code which changes the CPU state so as to
1
From: Richard Henderson <richard.henderson@linaro.org>
2
actually take an exception to AArch32. We're going to want
3
to use this for handling exception entry to Hyp mode.
4
2
3
We want to ensure that access is checked by the time we ask
4
for a specific fp/vector register. We want to ensure that
5
we do not emit two lots of code to raise an exception.
6
7
But sometimes it's difficult to cleanly organize the code
8
such that we never pass through sve_check_access exactly once.
9
Allow multiple calls so long as the result is true, that is,
10
no exception to be raised.
11
12
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
14
Message-id: 20200815013145.539409-5-richard.henderson@linaro.org
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
8
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
9
Message-id: 20180820153020.21478-4-peter.maydell@linaro.org
10
---
16
---
11
target/arm/helper.c | 64 +++++++++++++++++++++++++++++----------------
17
target/arm/translate.h | 1 +
12
1 file changed, 41 insertions(+), 23 deletions(-)
18
target/arm/translate-a64.c | 27 ++++++++++++++++-----------
19
2 files changed, 17 insertions(+), 11 deletions(-)
13
20
14
diff --git a/target/arm/helper.c b/target/arm/helper.c
21
diff --git a/target/arm/translate.h b/target/arm/translate.h
15
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/helper.c
23
--- a/target/arm/translate.h
17
+++ b/target/arm/helper.c
24
+++ b/target/arm/translate.h
18
@@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env)
25
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
19
env->regs[15] = env->pc;
26
* that it is set at the point where we actually touch the FP regs.
27
*/
28
bool fp_access_checked;
29
+ bool sve_access_checked;
30
/* ARMv8 single-step state (this is distinct from the QEMU gdbstub
31
* single-step support).
32
*/
33
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
34
index XXXXXXX..XXXXXXX 100644
35
--- a/target/arm/translate-a64.c
36
+++ b/target/arm/translate-a64.c
37
@@ -XXX,XX +XXX,XX @@ static void do_vec_ld(DisasContext *s, int destidx, int element,
38
* unallocated-encoding checks (otherwise the syndrome information
39
* for the resulting exception will be incorrect).
40
*/
41
-static inline bool fp_access_check(DisasContext *s)
42
+static bool fp_access_check(DisasContext *s)
43
{
44
- assert(!s->fp_access_checked);
45
- s->fp_access_checked = true;
46
+ if (s->fp_excp_el) {
47
+ assert(!s->fp_access_checked);
48
+ s->fp_access_checked = true;
49
50
- if (!s->fp_excp_el) {
51
- return true;
52
+ gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
53
+ syn_fp_access_trap(1, 0xe, false), s->fp_excp_el);
54
+ return false;
55
}
56
-
57
- gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
58
- syn_fp_access_trap(1, 0xe, false), s->fp_excp_el);
59
- return false;
60
+ s->fp_access_checked = true;
61
+ return true;
20
}
62
}
21
63
22
+static void take_aarch32_exception(CPUARMState *env, int new_mode,
64
/* Check that SVE access is enabled. If it is, return true.
23
+ uint32_t mask, uint32_t offset,
65
@@ -XXX,XX +XXX,XX @@ static inline bool fp_access_check(DisasContext *s)
24
+ uint32_t newpc)
66
bool sve_access_check(DisasContext *s)
25
+{
67
{
26
+ /* Change the CPU state so as to actually take the exception. */
68
if (s->sve_excp_el) {
27
+ switch_mode(env, new_mode);
69
- gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_sve_access_trap(),
28
+ /*
70
- s->sve_excp_el);
29
+ * For exceptions taken to AArch32 we must clear the SS bit in both
71
+ assert(!s->sve_access_checked);
30
+ * PSTATE and in the old-state value we save to SPSR_<mode>, so zero it now.
72
+ s->sve_access_checked = true;
31
+ */
32
+ env->uncached_cpsr &= ~PSTATE_SS;
33
+ env->spsr = cpsr_read(env);
34
+ /* Clear IT bits. */
35
+ env->condexec_bits = 0;
36
+ /* Switch to the new mode, and to the correct instruction set. */
37
+ env->uncached_cpsr = (env->uncached_cpsr & ~CPSR_M) | new_mode;
38
+ /* Set new mode endianness */
39
+ env->uncached_cpsr &= ~CPSR_E;
40
+ if (env->cp15.sctlr_el[arm_current_el(env)] & SCTLR_EE) {
41
+ env->uncached_cpsr |= CPSR_E;
42
+ }
43
+ env->daif |= mask;
44
+
73
+
45
+ if (new_mode == ARM_CPU_MODE_HYP) {
74
+ gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
46
+ env->thumb = (env->cp15.sctlr_el[2] & SCTLR_TE) != 0;
75
+ syn_sve_access_trap(), s->sve_excp_el);
47
+ env->elr_el[2] = env->regs[15];
76
return false;
48
+ } else {
49
+ /*
50
+ * this is a lie, as there was no c1_sys on V4T/V5, but who cares
51
+ * and we should just guard the thumb mode on V4
52
+ */
53
+ if (arm_feature(env, ARM_FEATURE_V4T)) {
54
+ env->thumb =
55
+ (A32_BANKED_CURRENT_REG_GET(env, sctlr) & SCTLR_TE) != 0;
56
+ }
57
+ env->regs[14] = env->regs[15] + offset;
58
+ }
59
+ env->regs[15] = newpc;
60
+}
61
+
62
static void arm_cpu_do_interrupt_aarch32(CPUState *cs)
63
{
64
ARMCPU *cpu = ARM_CPU(cs);
65
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch32(CPUState *cs)
66
env->cp15.scr_el3 &= ~SCR_NS;
67
}
77
}
68
78
+ s->sve_access_checked = true;
69
- switch_mode (env, new_mode);
79
return fp_access_check(s);
70
- /* For exceptions taken to AArch32 we must clear the SS bit in both
71
- * PSTATE and in the old-state value we save to SPSR_<mode>, so zero it now.
72
- */
73
- env->uncached_cpsr &= ~PSTATE_SS;
74
- env->spsr = cpsr_read(env);
75
- /* Clear IT bits. */
76
- env->condexec_bits = 0;
77
- /* Switch to the new mode, and to the correct instruction set. */
78
- env->uncached_cpsr = (env->uncached_cpsr & ~CPSR_M) | new_mode;
79
- /* Set new mode endianness */
80
- env->uncached_cpsr &= ~CPSR_E;
81
- if (env->cp15.sctlr_el[arm_current_el(env)] & SCTLR_EE) {
82
- env->uncached_cpsr |= CPSR_E;
83
- }
84
- env->daif |= mask;
85
- /* this is a lie, as the was no c1_sys on V4T/V5, but who cares
86
- * and we should just guard the thumb mode on V4 */
87
- if (arm_feature(env, ARM_FEATURE_V4T)) {
88
- env->thumb = (A32_BANKED_CURRENT_REG_GET(env, sctlr) & SCTLR_TE) != 0;
89
- }
90
- env->regs[14] = env->regs[15] + offset;
91
- env->regs[15] = addr;
92
+ take_aarch32_exception(env, new_mode, mask, offset, addr);
93
}
80
}
94
81
95
/* Handle exception entry to a target EL which is using AArch64 */
82
@@ -XXX,XX +XXX,XX @@ static void disas_a64_insn(CPUARMState *env, DisasContext *s)
83
s->base.pc_next += 4;
84
85
s->fp_access_checked = false;
86
+ s->sve_access_checked = false;
87
88
if (dc_isar_feature(aa64_bti, s)) {
89
if (s->base.num_insns == 1) {
96
--
90
--
97
2.18.0
91
2.20.1
98
92
99
93
diff view generated by jsdifflib
1
Refactor bcm2835_fb_mbox_push() to work by calling
1
From: Richard Henderson <richard.henderson@linaro.org>
2
bcm2835_fb_validate_config() and bcm2835_fb_reconfigure(),
3
so that config set this way is also validated.
4
2
3
This is the only user of the function.
4
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Message-id: 20200815013145.539409-6-richard.henderson@linaro.org
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20180814144436.679-9-peter.maydell@linaro.org
8
---
9
---
9
hw/display/bcm2835_fb.c | 63 ++++++++++++++++++++---------------------
10
target/arm/translate-sve.c | 19 ++++++-------------
10
1 file changed, 31 insertions(+), 32 deletions(-)
11
1 file changed, 6 insertions(+), 13 deletions(-)
11
12
12
diff --git a/hw/display/bcm2835_fb.c b/hw/display/bcm2835_fb.c
13
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
13
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/display/bcm2835_fb.c
15
--- a/target/arm/translate-sve.c
15
+++ b/hw/display/bcm2835_fb.c
16
+++ b/target/arm/translate-sve.c
16
@@ -XXX,XX +XXX,XX @@ void bcm2835_fb_validate_config(BCM2835FBConfig *config)
17
@@ -XXX,XX +XXX,XX @@ static void do_dupi_z(DisasContext *s, int rd, uint64_t word)
17
}
18
tcg_gen_gvec_dup_imm(MO_64, vec_full_reg_offset(s, rd), vsz, vsz, word);
18
}
19
}
19
20
20
-static void bcm2835_fb_mbox_push(BCM2835FBState *s, uint32_t value)
21
-/* Invoke a vector expander on two Pregs. */
22
-static bool do_vector2_p(DisasContext *s, GVecGen2Fn *gvec_fn,
23
- int esz, int rd, int rn)
21
-{
24
-{
22
- uint32_t pitch;
25
- if (sve_access_check(s)) {
23
- uint32_t size;
26
- unsigned psz = pred_gvec_reg_size(s);
24
-
27
- gvec_fn(esz, pred_full_reg_offset(s, rd),
25
- value &= ~0xf;
28
- pred_full_reg_offset(s, rn), psz, psz);
26
-
29
- }
27
- s->lock = true;
30
- return true;
28
-
29
- s->config.xres = ldl_le_phys(&s->dma_as, value);
30
- s->config.yres = ldl_le_phys(&s->dma_as, value + 4);
31
- s->config.xres_virtual = ldl_le_phys(&s->dma_as, value + 8);
32
- s->config.yres_virtual = ldl_le_phys(&s->dma_as, value + 12);
33
- s->config.bpp = ldl_le_phys(&s->dma_as, value + 20);
34
- s->config.xoffset = ldl_le_phys(&s->dma_as, value + 24);
35
- s->config.yoffset = ldl_le_phys(&s->dma_as, value + 28);
36
-
37
- s->config.base = s->vcram_base | (value & 0xc0000000);
38
- s->config.base += BCM2835_FB_OFFSET;
39
-
40
- pitch = bcm2835_fb_get_pitch(&s->config);
41
- size = bcm2835_fb_get_size(&s->config);
42
-
43
- stl_le_phys(&s->dma_as, value + 16, pitch);
44
- stl_le_phys(&s->dma_as, value + 32, s->config.base);
45
- stl_le_phys(&s->dma_as, value + 36, size);
46
-
47
- s->invalidate = true;
48
- qemu_console_resize(s->con, s->config.xres, s->config.yres);
49
- s->lock = false;
50
-}
31
-}
51
-
32
-
52
void bcm2835_fb_reconfigure(BCM2835FBState *s, BCM2835FBConfig *newconfig)
33
/* Invoke a vector expander on three Pregs. */
34
static bool do_vector3_p(DisasContext *s, GVecGen3Fn *gvec_fn,
35
int esz, int rd, int rn, int rm)
36
@@ -XXX,XX +XXX,XX @@ static bool do_vecop4_p(DisasContext *s, const GVecGen4 *gvec_op,
37
/* Invoke a vector move on two Pregs. */
38
static bool do_mov_p(DisasContext *s, int rd, int rn)
53
{
39
{
54
s->lock = true;
40
- return do_vector2_p(s, tcg_gen_gvec_mov, 0, rd, rn);
55
@@ -XXX,XX +XXX,XX @@ void bcm2835_fb_reconfigure(BCM2835FBState *s, BCM2835FBConfig *newconfig)
41
+ if (sve_access_check(s)) {
56
s->lock = false;
42
+ unsigned psz = pred_gvec_reg_size(s);
43
+ tcg_gen_gvec_mov(MO_8, pred_full_reg_offset(s, rd),
44
+ pred_full_reg_offset(s, rn), psz, psz);
45
+ }
46
+ return true;
57
}
47
}
58
48
59
+static void bcm2835_fb_mbox_push(BCM2835FBState *s, uint32_t value)
49
/* Set the cpu flags as per a return from an SVE helper. */
60
+{
61
+ uint32_t pitch;
62
+ uint32_t size;
63
+ BCM2835FBConfig newconf;
64
+
65
+ value &= ~0xf;
66
+
67
+ newconf.xres = ldl_le_phys(&s->dma_as, value);
68
+ newconf.yres = ldl_le_phys(&s->dma_as, value + 4);
69
+ newconf.xres_virtual = ldl_le_phys(&s->dma_as, value + 8);
70
+ newconf.yres_virtual = ldl_le_phys(&s->dma_as, value + 12);
71
+ newconf.bpp = ldl_le_phys(&s->dma_as, value + 20);
72
+ newconf.xoffset = ldl_le_phys(&s->dma_as, value + 24);
73
+ newconf.yoffset = ldl_le_phys(&s->dma_as, value + 28);
74
+
75
+ newconf.base = s->vcram_base | (value & 0xc0000000);
76
+ newconf.base += BCM2835_FB_OFFSET;
77
+
78
+ bcm2835_fb_validate_config(&newconf);
79
+
80
+ pitch = bcm2835_fb_get_pitch(&newconf);
81
+ size = bcm2835_fb_get_size(&newconf);
82
+
83
+ stl_le_phys(&s->dma_as, value + 16, pitch);
84
+ stl_le_phys(&s->dma_as, value + 32, newconf.base);
85
+ stl_le_phys(&s->dma_as, value + 36, size);
86
+
87
+ bcm2835_fb_reconfigure(s, &newconf);
88
+}
89
+
90
static uint64_t bcm2835_fb_read(void *opaque, hwaddr offset, unsigned size)
91
{
92
BCM2835FBState *s = opaque;
93
--
50
--
94
2.18.0
51
2.20.1
95
52
96
53
diff view generated by jsdifflib
1
The Arm Cortex-M System Design Kit includes a "dual-input timer module"
1
From: Richard Henderson <richard.henderson@linaro.org>
2
which combines two programmable down-counters. Implement a model
2
3
of this device.
3
Move the check for !S into do_pppp_flags, which allows to merge in
4
4
do_vecop4_p. Split out gen_gvec_fn_ppp without sve_access_check,
5
to mirror gen_gvec_fn_zzz.
6
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20200815013145.539409-7-richard.henderson@linaro.org
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20180820141116.9118-4-peter.maydell@linaro.org
8
---
11
---
9
hw/timer/Makefile.objs | 1 +
12
target/arm/translate-sve.c | 111 ++++++++++++++-----------------------
10
include/hw/timer/cmsdk-apb-dualtimer.h | 72 ++++
13
1 file changed, 43 insertions(+), 68 deletions(-)
11
hw/timer/cmsdk-apb-dualtimer.c | 515 +++++++++++++++++++++++++
14
12
MAINTAINERS | 2 +
15
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
13
default-configs/arm-softmmu.mak | 1 +
14
hw/timer/trace-events | 5 +
15
6 files changed, 596 insertions(+)
16
create mode 100644 include/hw/timer/cmsdk-apb-dualtimer.h
17
create mode 100644 hw/timer/cmsdk-apb-dualtimer.c
18
19
diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
20
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/timer/Makefile.objs
17
--- a/target/arm/translate-sve.c
22
+++ b/hw/timer/Makefile.objs
18
+++ b/target/arm/translate-sve.c
23
@@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o
19
@@ -XXX,XX +XXX,XX @@ static void do_dupi_z(DisasContext *s, int rd, uint64_t word)
24
20
}
25
common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o
21
26
common-obj-$(CONFIG_CMSDK_APB_TIMER) += cmsdk-apb-timer.o
22
/* Invoke a vector expander on three Pregs. */
27
+common-obj-$(CONFIG_CMSDK_APB_DUALTIMER) += cmsdk-apb-dualtimer.o
23
-static bool do_vector3_p(DisasContext *s, GVecGen3Fn *gvec_fn,
28
common-obj-$(CONFIG_MSF2) += mss-timer.o
24
- int esz, int rd, int rn, int rm)
29
diff --git a/include/hw/timer/cmsdk-apb-dualtimer.h b/include/hw/timer/cmsdk-apb-dualtimer.h
25
+static void gen_gvec_fn_ppp(DisasContext *s, GVecGen3Fn *gvec_fn,
30
new file mode 100644
26
+ int rd, int rn, int rm)
31
index XXXXXXX..XXXXXXX
27
{
32
--- /dev/null
28
- if (sve_access_check(s)) {
33
+++ b/include/hw/timer/cmsdk-apb-dualtimer.h
29
- unsigned psz = pred_gvec_reg_size(s);
34
@@ -XXX,XX +XXX,XX @@
30
- gvec_fn(esz, pred_full_reg_offset(s, rd),
35
+/*
31
- pred_full_reg_offset(s, rn),
36
+ * ARM CMSDK APB dual-timer emulation
32
- pred_full_reg_offset(s, rm), psz, psz);
37
+ *
33
- }
38
+ * Copyright (c) 2018 Linaro Limited
34
- return true;
39
+ * Written by Peter Maydell
35
-}
40
+ *
36
-
41
+ * This program is free software; you can redistribute it and/or modify
37
-/* Invoke a vector operation on four Pregs. */
42
+ * it under the terms of the GNU General Public License version 2 or
38
-static bool do_vecop4_p(DisasContext *s, const GVecGen4 *gvec_op,
43
+ * (at your option) any later version.
39
- int rd, int rn, int rm, int rg)
44
+ */
40
-{
45
+
41
- if (sve_access_check(s)) {
46
+/*
42
- unsigned psz = pred_gvec_reg_size(s);
47
+ * This is a model of the "APB dual-input timer" which is part of the Cortex-M
43
- tcg_gen_gvec_4(pred_full_reg_offset(s, rd),
48
+ * System Design Kit (CMSDK) and documented in the Cortex-M System
44
- pred_full_reg_offset(s, rn),
49
+ * Design Kit Technical Reference Manual (ARM DDI0479C):
45
- pred_full_reg_offset(s, rm),
50
+ * https://developer.arm.com/products/system-design/system-design-kits/cortex-m-system-design-kit
46
- pred_full_reg_offset(s, rg),
51
+ *
47
- psz, psz, gvec_op);
52
+ * QEMU interface:
48
- }
53
+ * + QOM property "pclk-frq": frequency at which the timer is clocked
49
- return true;
54
+ * + sysbus MMIO region 0: the register bank
50
+ unsigned psz = pred_gvec_reg_size(s);
55
+ * + sysbus IRQ 0: combined timer interrupt TIMINTC
51
+ gvec_fn(MO_64, pred_full_reg_offset(s, rd),
56
+ * + sysbus IRO 1: timer block 1 interrupt TIMINT1
52
+ pred_full_reg_offset(s, rn),
57
+ * + sysbus IRQ 2: timer block 2 interrupt TIMINT2
53
+ pred_full_reg_offset(s, rm), psz, psz);
58
+ */
54
}
59
+
55
60
+#ifndef CMSDK_APB_DUALTIMER_H
56
/* Invoke a vector move on two Pregs. */
61
+#define CMSDK_APB_DUALTIMER_H
57
@@ -XXX,XX +XXX,XX @@ static bool do_pppp_flags(DisasContext *s, arg_rprr_s *a,
62
+
58
int mofs = pred_full_reg_offset(s, a->rm);
63
+#include "hw/sysbus.h"
59
int gofs = pred_full_reg_offset(s, a->pg);
64
+#include "hw/ptimer.h"
60
65
+
61
+ if (!a->s) {
66
+#define TYPE_CMSDK_APB_DUALTIMER "cmsdk-apb-dualtimer"
62
+ tcg_gen_gvec_4(dofs, nofs, mofs, gofs, psz, psz, gvec_op);
67
+#define CMSDK_APB_DUALTIMER(obj) OBJECT_CHECK(CMSDKAPBDualTimer, (obj), \
63
+ return true;
68
+ TYPE_CMSDK_APB_DUALTIMER)
69
+
70
+typedef struct CMSDKAPBDualTimer CMSDKAPBDualTimer;
71
+
72
+/* One of the two identical timer modules in the dual-timer module */
73
+typedef struct CMSDKAPBDualTimerModule {
74
+ CMSDKAPBDualTimer *parent;
75
+ struct ptimer_state *timer;
76
+ qemu_irq timerint;
77
+ /*
78
+ * We must track the guest LOAD and VALUE register state by hand
79
+ * rather than leaving this state only in the ptimer limit/count,
80
+ * because if CONTROL.SIZE is 0 then only the low 16 bits of the
81
+ * counter actually counts, but the high half is still guest
82
+ * accessible.
83
+ */
84
+ uint32_t load;
85
+ uint32_t value;
86
+ uint32_t control;
87
+ uint32_t intstatus;
88
+} CMSDKAPBDualTimerModule;
89
+
90
+#define CMSDK_APB_DUALTIMER_NUM_MODULES 2
91
+
92
+struct CMSDKAPBDualTimer {
93
+ /*< private >*/
94
+ SysBusDevice parent_obj;
95
+
96
+ /*< public >*/
97
+ MemoryRegion iomem;
98
+ qemu_irq timerintc;
99
+ uint32_t pclk_frq;
100
+
101
+ CMSDKAPBDualTimerModule timermod[CMSDK_APB_DUALTIMER_NUM_MODULES];
102
+ uint32_t timeritcr;
103
+ uint32_t timeritop;
104
+};
105
+
106
+#endif
107
diff --git a/hw/timer/cmsdk-apb-dualtimer.c b/hw/timer/cmsdk-apb-dualtimer.c
108
new file mode 100644
109
index XXXXXXX..XXXXXXX
110
--- /dev/null
111
+++ b/hw/timer/cmsdk-apb-dualtimer.c
112
@@ -XXX,XX +XXX,XX @@
113
+/*
114
+ * ARM CMSDK APB dual-timer emulation
115
+ *
116
+ * Copyright (c) 2018 Linaro Limited
117
+ * Written by Peter Maydell
118
+ *
119
+ * This program is free software; you can redistribute it and/or modify
120
+ * it under the terms of the GNU General Public License version 2 or
121
+ * (at your option) any later version.
122
+ */
123
+
124
+/*
125
+ * This is a model of the "APB dual-input timer" which is part of the Cortex-M
126
+ * System Design Kit (CMSDK) and documented in the Cortex-M System
127
+ * Design Kit Technical Reference Manual (ARM DDI0479C):
128
+ * https://developer.arm.com/products/system-design/system-design-kits/cortex-m-system-design-kit
129
+ */
130
+
131
+#include "qemu/osdep.h"
132
+#include "qemu/log.h"
133
+#include "trace.h"
134
+#include "qapi/error.h"
135
+#include "qemu/main-loop.h"
136
+#include "hw/sysbus.h"
137
+#include "hw/registerfields.h"
138
+#include "hw/timer/cmsdk-apb-dualtimer.h"
139
+
140
+REG32(TIMER1LOAD, 0x0)
141
+REG32(TIMER1VALUE, 0x4)
142
+REG32(TIMER1CONTROL, 0x8)
143
+ FIELD(CONTROL, ONESHOT, 0, 1)
144
+ FIELD(CONTROL, SIZE, 1, 1)
145
+ FIELD(CONTROL, PRESCALE, 2, 2)
146
+ FIELD(CONTROL, INTEN, 5, 1)
147
+ FIELD(CONTROL, MODE, 6, 1)
148
+ FIELD(CONTROL, ENABLE, 7, 1)
149
+#define R_CONTROL_VALID_MASK (R_CONTROL_ONESHOT_MASK | R_CONTROL_SIZE_MASK | \
150
+ R_CONTROL_PRESCALE_MASK | R_CONTROL_INTEN_MASK | \
151
+ R_CONTROL_MODE_MASK | R_CONTROL_ENABLE_MASK)
152
+REG32(TIMER1INTCLR, 0xc)
153
+REG32(TIMER1RIS, 0x10)
154
+REG32(TIMER1MIS, 0x14)
155
+REG32(TIMER1BGLOAD, 0x18)
156
+REG32(TIMER2LOAD, 0x20)
157
+REG32(TIMER2VALUE, 0x24)
158
+REG32(TIMER2CONTROL, 0x28)
159
+REG32(TIMER2INTCLR, 0x2c)
160
+REG32(TIMER2RIS, 0x30)
161
+REG32(TIMER2MIS, 0x34)
162
+REG32(TIMER2BGLOAD, 0x38)
163
+REG32(TIMERITCR, 0xf00)
164
+ FIELD(TIMERITCR, ENABLE, 0, 1)
165
+#define R_TIMERITCR_VALID_MASK R_TIMERITCR_ENABLE_MASK
166
+REG32(TIMERITOP, 0xf04)
167
+ FIELD(TIMERITOP, TIMINT1, 0, 1)
168
+ FIELD(TIMERITOP, TIMINT2, 1, 1)
169
+#define R_TIMERITOP_VALID_MASK (R_TIMERITOP_TIMINT1_MASK | \
170
+ R_TIMERITOP_TIMINT2_MASK)
171
+REG32(PID4, 0xfd0)
172
+REG32(PID5, 0xfd4)
173
+REG32(PID6, 0xfd8)
174
+REG32(PID7, 0xfdc)
175
+REG32(PID0, 0xfe0)
176
+REG32(PID1, 0xfe4)
177
+REG32(PID2, 0xfe8)
178
+REG32(PID3, 0xfec)
179
+REG32(CID0, 0xff0)
180
+REG32(CID1, 0xff4)
181
+REG32(CID2, 0xff8)
182
+REG32(CID3, 0xffc)
183
+
184
+/* PID/CID values */
185
+static const int timer_id[] = {
186
+ 0x04, 0x00, 0x00, 0x00, /* PID4..PID7 */
187
+ 0x23, 0xb8, 0x1b, 0x00, /* PID0..PID3 */
188
+ 0x0d, 0xf0, 0x05, 0xb1, /* CID0..CID3 */
189
+};
190
+
191
+static bool cmsdk_dualtimermod_intstatus(CMSDKAPBDualTimerModule *m)
192
+{
193
+ /* Return masked interrupt status for the timer module */
194
+ return m->intstatus && (m->control & R_CONTROL_INTEN_MASK);
195
+}
196
+
197
+static void cmsdk_apb_dualtimer_update(CMSDKAPBDualTimer *s)
198
+{
199
+ bool timint1, timint2, timintc;
200
+
201
+ if (s->timeritcr) {
202
+ /* Integration test mode: outputs driven directly from TIMERITOP bits */
203
+ timint1 = s->timeritop & R_TIMERITOP_TIMINT1_MASK;
204
+ timint2 = s->timeritop & R_TIMERITOP_TIMINT2_MASK;
205
+ } else {
206
+ timint1 = cmsdk_dualtimermod_intstatus(&s->timermod[0]);
207
+ timint2 = cmsdk_dualtimermod_intstatus(&s->timermod[1]);
208
+ }
64
+ }
209
+
65
+
210
+ timintc = timint1 || timint2;
66
if (psz == 8) {
211
+
67
/* Do the operation and the flags generation in temps. */
212
+ qemu_set_irq(s->timermod[0].timerint, timint1);
68
TCGv_i64 pd = tcg_temp_new_i64();
213
+ qemu_set_irq(s->timermod[1].timerint, timint2);
69
@@ -XXX,XX +XXX,XX @@ static bool trans_AND_pppp(DisasContext *s, arg_rprr_s *a)
214
+ qemu_set_irq(s->timerintc, timintc);
70
.fno = gen_helper_sve_and_pppp,
215
+}
71
.prefer_i64 = TCG_TARGET_REG_BITS == 64,
216
+
72
};
217
+static void cmsdk_dualtimermod_write_control(CMSDKAPBDualTimerModule *m,
73
- if (a->s) {
218
+ uint32_t newctrl)
74
- return do_pppp_flags(s, a, &op);
219
+{
75
- } else if (a->rn == a->rm) {
220
+ /* Handle a write to the CONTROL register */
76
- if (a->pg == a->rn) {
221
+ uint32_t changed;
77
- return do_mov_p(s, a->rd, a->rn);
222
+
78
- } else {
223
+ newctrl &= R_CONTROL_VALID_MASK;
79
- return do_vector3_p(s, tcg_gen_gvec_and, 0, a->rd, a->rn, a->pg);
224
+
80
+
225
+ changed = m->control ^ newctrl;
81
+ if (!a->s) {
226
+
82
+ if (!sve_access_check(s)) {
227
+ if (changed & ~newctrl & R_CONTROL_ENABLE_MASK) {
83
+ return true;
228
+ /* ENABLE cleared, stop timer before any further changes */
229
+ ptimer_stop(m->timer);
230
+ }
231
+
232
+ if (changed & R_CONTROL_PRESCALE_MASK) {
233
+ int divisor;
234
+
235
+ switch (FIELD_EX32(newctrl, CONTROL, PRESCALE)) {
236
+ case 0:
237
+ divisor = 1;
238
+ break;
239
+ case 1:
240
+ divisor = 16;
241
+ break;
242
+ case 2:
243
+ divisor = 256;
244
+ break;
245
+ case 3:
246
+ /* UNDEFINED; complain, and arbitrarily treat like 2 */
247
+ qemu_log_mask(LOG_GUEST_ERROR,
248
+ "CMSDK APB dual-timer: CONTROL.PRESCALE==0b11"
249
+ " is undefined behaviour\n");
250
+ divisor = 256;
251
+ break;
252
+ default:
253
+ g_assert_not_reached();
254
+ }
84
+ }
255
+ ptimer_set_freq(m->timer, m->parent->pclk_frq / divisor);
85
+ if (a->rn == a->rm) {
256
+ }
86
+ if (a->pg == a->rn) {
257
+
87
+ do_mov_p(s, a->rd, a->rn);
258
+ if (changed & R_CONTROL_MODE_MASK) {
88
+ } else {
259
+ uint32_t load;
89
+ gen_gvec_fn_ppp(s, tcg_gen_gvec_and, a->rd, a->rn, a->pg);
260
+ if (newctrl & R_CONTROL_MODE_MASK) {
261
+ /* Periodic: the limit is the LOAD register value */
262
+ load = m->load;
263
+ } else {
264
+ /* Free-running: counter wraps around */
265
+ load = ptimer_get_limit(m->timer);
266
+ if (!(m->control & R_CONTROL_SIZE_MASK)) {
267
+ load = deposit32(m->load, 0, 16, load);
268
+ }
90
+ }
269
+ m->load = load;
91
+ return true;
270
+ load = 0xffffffff;
92
+ } else if (a->pg == a->rn || a->pg == a->rm) {
93
+ gen_gvec_fn_ppp(s, tcg_gen_gvec_and, a->rd, a->rn, a->rm);
94
+ return true;
95
}
96
- } else if (a->pg == a->rn || a->pg == a->rm) {
97
- return do_vector3_p(s, tcg_gen_gvec_and, 0, a->rd, a->rn, a->rm);
98
- } else {
99
- return do_vecop4_p(s, &op, a->rd, a->rn, a->rm, a->pg);
100
}
101
+ return do_pppp_flags(s, a, &op);
102
}
103
104
static void gen_bic_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg)
105
@@ -XXX,XX +XXX,XX @@ static bool trans_BIC_pppp(DisasContext *s, arg_rprr_s *a)
106
.fno = gen_helper_sve_bic_pppp,
107
.prefer_i64 = TCG_TARGET_REG_BITS == 64,
108
};
109
- if (a->s) {
110
- return do_pppp_flags(s, a, &op);
111
- } else if (a->pg == a->rn) {
112
- return do_vector3_p(s, tcg_gen_gvec_andc, 0, a->rd, a->rn, a->rm);
113
- } else {
114
- return do_vecop4_p(s, &op, a->rd, a->rn, a->rm, a->pg);
115
+
116
+ if (!a->s && a->pg == a->rn) {
117
+ if (sve_access_check(s)) {
118
+ gen_gvec_fn_ppp(s, tcg_gen_gvec_andc, a->rd, a->rn, a->rm);
271
+ }
119
+ }
272
+ if (!(m->control & R_CONTROL_SIZE_MASK)) {
120
+ return true;
273
+ load &= 0xffff;
121
}
274
+ }
122
+ return do_pppp_flags(s, a, &op);
275
+ ptimer_set_limit(m->timer, load, 0);
123
}
276
+ }
124
277
+
125
static void gen_eor_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg)
278
+ if (changed & R_CONTROL_SIZE_MASK) {
126
@@ -XXX,XX +XXX,XX @@ static bool trans_EOR_pppp(DisasContext *s, arg_rprr_s *a)
279
+ /* Timer switched between 16 and 32 bit count */
127
.fno = gen_helper_sve_eor_pppp,
280
+ uint32_t value, load;
128
.prefer_i64 = TCG_TARGET_REG_BITS == 64,
281
+
129
};
282
+ value = ptimer_get_count(m->timer);
130
- if (a->s) {
283
+ load = ptimer_get_limit(m->timer);
131
- return do_pppp_flags(s, a, &op);
284
+ if (newctrl & R_CONTROL_SIZE_MASK) {
132
- } else {
285
+ /* 16 -> 32, top half of VALUE is in struct field */
133
- return do_vecop4_p(s, &op, a->rd, a->rn, a->rm, a->pg);
286
+ value = deposit32(m->value, 0, 16, value);
134
- }
287
+ } else {
135
+ return do_pppp_flags(s, a, &op);
288
+ /* 32 -> 16: save top half to struct field and truncate */
136
}
289
+ m->value = value;
137
290
+ value &= 0xffff;
138
static void gen_sel_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg)
291
+ }
139
@@ -XXX,XX +XXX,XX @@ static bool trans_SEL_pppp(DisasContext *s, arg_rprr_s *a)
292
+
140
.fno = gen_helper_sve_sel_pppp,
293
+ if (newctrl & R_CONTROL_MODE_MASK) {
141
.prefer_i64 = TCG_TARGET_REG_BITS == 64,
294
+ /* Periodic, timer limit has LOAD value */
142
};
295
+ if (newctrl & R_CONTROL_SIZE_MASK) {
143
+
296
+ load = deposit32(m->load, 0, 16, load);
144
if (a->s) {
297
+ } else {
145
return false;
298
+ m->load = load;
146
- } else {
299
+ load &= 0xffff;
147
- return do_vecop4_p(s, &op, a->rd, a->rn, a->rm, a->pg);
300
+ }
148
}
301
+ } else {
149
+ return do_pppp_flags(s, a, &op);
302
+ /* Free-running, timer limit is set to give wraparound */
150
}
303
+ if (newctrl & R_CONTROL_SIZE_MASK) {
151
304
+ load = 0xffffffff;
152
static void gen_orr_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg)
305
+ } else {
153
@@ -XXX,XX +XXX,XX @@ static bool trans_ORR_pppp(DisasContext *s, arg_rprr_s *a)
306
+ load = 0xffff;
154
.fno = gen_helper_sve_orr_pppp,
307
+ }
155
.prefer_i64 = TCG_TARGET_REG_BITS == 64,
308
+ }
156
};
309
+ ptimer_set_count(m->timer, value);
157
- if (a->s) {
310
+ ptimer_set_limit(m->timer, load, 0);
158
- return do_pppp_flags(s, a, &op);
311
+ }
159
- } else if (a->pg == a->rn && a->rn == a->rm) {
312
+
160
+
313
+ if (newctrl & R_CONTROL_ENABLE_MASK) {
161
+ if (!a->s && a->pg == a->rn && a->rn == a->rm) {
314
+ /*
162
return do_mov_p(s, a->rd, a->rn);
315
+ * ENABLE is set; start the timer after all other changes.
163
- } else {
316
+ * We start it even if the ENABLE bit didn't actually change,
164
- return do_vecop4_p(s, &op, a->rd, a->rn, a->rm, a->pg);
317
+ * in case the timer was an expired one-shot timer that has
165
}
318
+ * now been changed into a free-running or periodic timer.
166
+ return do_pppp_flags(s, a, &op);
319
+ */
167
}
320
+ ptimer_run(m->timer, !!(newctrl & R_CONTROL_ONESHOT_MASK));
168
321
+ }
169
static void gen_orn_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg)
322
+
170
@@ -XXX,XX +XXX,XX @@ static bool trans_ORN_pppp(DisasContext *s, arg_rprr_s *a)
323
+ m->control = newctrl;
171
.fno = gen_helper_sve_orn_pppp,
324
+}
172
.prefer_i64 = TCG_TARGET_REG_BITS == 64,
325
+
173
};
326
+static uint64_t cmsdk_apb_dualtimer_read(void *opaque, hwaddr offset,
174
- if (a->s) {
327
+ unsigned size)
175
- return do_pppp_flags(s, a, &op);
328
+{
176
- } else {
329
+ CMSDKAPBDualTimer *s = CMSDK_APB_DUALTIMER(opaque);
177
- return do_vecop4_p(s, &op, a->rd, a->rn, a->rm, a->pg);
330
+ uint64_t r;
178
- }
331
+
179
+ return do_pppp_flags(s, a, &op);
332
+ if (offset >= A_TIMERITCR) {
180
}
333
+ switch (offset) {
181
334
+ case A_TIMERITCR:
182
static void gen_nor_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg)
335
+ r = s->timeritcr;
183
@@ -XXX,XX +XXX,XX @@ static bool trans_NOR_pppp(DisasContext *s, arg_rprr_s *a)
336
+ break;
184
.fno = gen_helper_sve_nor_pppp,
337
+ case A_PID4 ... A_CID3:
185
.prefer_i64 = TCG_TARGET_REG_BITS == 64,
338
+ r = timer_id[(offset - A_PID4) / 4];
186
};
339
+ break;
187
- if (a->s) {
340
+ default:
188
- return do_pppp_flags(s, a, &op);
341
+ bad_offset:
189
- } else {
342
+ qemu_log_mask(LOG_GUEST_ERROR,
190
- return do_vecop4_p(s, &op, a->rd, a->rn, a->rm, a->pg);
343
+ "CMSDK APB dual-timer read: bad offset %x\n",
191
- }
344
+ (int) offset);
192
+ return do_pppp_flags(s, a, &op);
345
+ r = 0;
193
}
346
+ break;
194
347
+ }
195
static void gen_nand_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg)
348
+ } else {
196
@@ -XXX,XX +XXX,XX @@ static bool trans_NAND_pppp(DisasContext *s, arg_rprr_s *a)
349
+ int timer = offset >> 5;
197
.fno = gen_helper_sve_nand_pppp,
350
+ CMSDKAPBDualTimerModule *m;
198
.prefer_i64 = TCG_TARGET_REG_BITS == 64,
351
+
199
};
352
+ if (timer >= ARRAY_SIZE(s->timermod)) {
200
- if (a->s) {
353
+ goto bad_offset;
201
- return do_pppp_flags(s, a, &op);
354
+ }
202
- } else {
355
+
203
- return do_vecop4_p(s, &op, a->rd, a->rn, a->rm, a->pg);
356
+ m = &s->timermod[timer];
204
- }
357
+
205
+ return do_pppp_flags(s, a, &op);
358
+ switch (offset & 0x1F) {
206
}
359
+ case A_TIMER1LOAD:
207
360
+ case A_TIMER1BGLOAD:
208
/*
361
+ if (m->control & R_CONTROL_MODE_MASK) {
362
+ /*
363
+ * Periodic: the ptimer limit is the LOAD register value, (or
364
+ * just the low 16 bits of it if the timer is in 16-bit mode)
365
+ */
366
+ r = ptimer_get_limit(m->timer);
367
+ if (!(m->control & R_CONTROL_SIZE_MASK)) {
368
+ r = deposit32(m->load, 0, 16, r);
369
+ }
370
+ } else {
371
+ /* Free-running: LOAD register value is just in m->load */
372
+ r = m->load;
373
+ }
374
+ break;
375
+ case A_TIMER1VALUE:
376
+ r = ptimer_get_count(m->timer);
377
+ if (!(m->control & R_CONTROL_SIZE_MASK)) {
378
+ r = deposit32(m->value, 0, 16, r);
379
+ }
380
+ break;
381
+ case A_TIMER1CONTROL:
382
+ r = m->control;
383
+ break;
384
+ case A_TIMER1RIS:
385
+ r = m->intstatus;
386
+ break;
387
+ case A_TIMER1MIS:
388
+ r = cmsdk_dualtimermod_intstatus(m);
389
+ break;
390
+ default:
391
+ goto bad_offset;
392
+ }
393
+ }
394
+
395
+ trace_cmsdk_apb_dualtimer_read(offset, r, size);
396
+ return r;
397
+}
398
+
399
+static void cmsdk_apb_dualtimer_write(void *opaque, hwaddr offset,
400
+ uint64_t value, unsigned size)
401
+{
402
+ CMSDKAPBDualTimer *s = CMSDK_APB_DUALTIMER(opaque);
403
+
404
+ trace_cmsdk_apb_dualtimer_write(offset, value, size);
405
+
406
+ if (offset >= A_TIMERITCR) {
407
+ switch (offset) {
408
+ case A_TIMERITCR:
409
+ s->timeritcr = value & R_TIMERITCR_VALID_MASK;
410
+ cmsdk_apb_dualtimer_update(s);
411
+ case A_TIMERITOP:
412
+ s->timeritop = value & R_TIMERITOP_VALID_MASK;
413
+ cmsdk_apb_dualtimer_update(s);
414
+ default:
415
+ bad_offset:
416
+ qemu_log_mask(LOG_GUEST_ERROR,
417
+ "CMSDK APB dual-timer write: bad offset %x\n",
418
+ (int) offset);
419
+ break;
420
+ }
421
+ } else {
422
+ int timer = offset >> 5;
423
+ CMSDKAPBDualTimerModule *m;
424
+
425
+ if (timer >= ARRAY_SIZE(s->timermod)) {
426
+ goto bad_offset;
427
+ }
428
+
429
+ m = &s->timermod[timer];
430
+
431
+ switch (offset & 0x1F) {
432
+ case A_TIMER1LOAD:
433
+ /* Set the limit, and immediately reload the count from it */
434
+ m->load = value;
435
+ m->value = value;
436
+ if (!(m->control & R_CONTROL_SIZE_MASK)) {
437
+ value &= 0xffff;
438
+ }
439
+ if (!(m->control & R_CONTROL_MODE_MASK)) {
440
+ /*
441
+ * In free-running mode this won't set the limit but will
442
+ * still change the current count value.
443
+ */
444
+ ptimer_set_count(m->timer, value);
445
+ } else {
446
+ if (!value) {
447
+ ptimer_stop(m->timer);
448
+ }
449
+ ptimer_set_limit(m->timer, value, 1);
450
+ if (value && (m->control & R_CONTROL_ENABLE_MASK)) {
451
+ /* Force possibly-expired oneshot timer to restart */
452
+ ptimer_run(m->timer, 1);
453
+ }
454
+ }
455
+ break;
456
+ case A_TIMER1BGLOAD:
457
+ /* Set the limit, but not the current count */
458
+ m->load = value;
459
+ if (!(m->control & R_CONTROL_MODE_MASK)) {
460
+ /* In free-running mode there is no limit */
461
+ break;
462
+ }
463
+ if (!(m->control & R_CONTROL_SIZE_MASK)) {
464
+ value &= 0xffff;
465
+ }
466
+ ptimer_set_limit(m->timer, value, 0);
467
+ break;
468
+ case A_TIMER1CONTROL:
469
+ cmsdk_dualtimermod_write_control(m, value);
470
+ cmsdk_apb_dualtimer_update(s);
471
+ break;
472
+ case A_TIMER1INTCLR:
473
+ m->intstatus = 0;
474
+ cmsdk_apb_dualtimer_update(s);
475
+ break;
476
+ default:
477
+ goto bad_offset;
478
+ }
479
+ }
480
+}
481
+
482
+static const MemoryRegionOps cmsdk_apb_dualtimer_ops = {
483
+ .read = cmsdk_apb_dualtimer_read,
484
+ .write = cmsdk_apb_dualtimer_write,
485
+ .endianness = DEVICE_LITTLE_ENDIAN,
486
+ /* byte/halfword accesses are just zero-padded on reads and writes */
487
+ .impl.min_access_size = 4,
488
+ .impl.max_access_size = 4,
489
+ .valid.min_access_size = 1,
490
+ .valid.max_access_size = 4,
491
+};
492
+
493
+static void cmsdk_dualtimermod_tick(void *opaque)
494
+{
495
+ CMSDKAPBDualTimerModule *m = opaque;
496
+
497
+ m->intstatus = 1;
498
+ cmsdk_apb_dualtimer_update(m->parent);
499
+}
500
+
501
+static void cmsdk_dualtimermod_reset(CMSDKAPBDualTimerModule *m)
502
+{
503
+ m->control = R_CONTROL_INTEN_MASK;
504
+ m->intstatus = 0;
505
+ m->load = 0;
506
+ m->value = 0xffffffff;
507
+ ptimer_stop(m->timer);
508
+ /*
509
+ * We start in free-running mode, with VALUE at 0xffffffff, and
510
+ * in 16-bit counter mode. This means that the ptimer count and
511
+ * limit must both be set to 0xffff, so we wrap at 16 bits.
512
+ */
513
+ ptimer_set_limit(m->timer, 0xffff, 1);
514
+ ptimer_set_freq(m->timer, m->parent->pclk_frq);
515
+}
516
+
517
+static void cmsdk_apb_dualtimer_reset(DeviceState *dev)
518
+{
519
+ CMSDKAPBDualTimer *s = CMSDK_APB_DUALTIMER(dev);
520
+ int i;
521
+
522
+ trace_cmsdk_apb_dualtimer_reset();
523
+
524
+ for (i = 0; i < ARRAY_SIZE(s->timermod); i++) {
525
+ cmsdk_dualtimermod_reset(&s->timermod[i]);
526
+ }
527
+ s->timeritcr = 0;
528
+ s->timeritop = 0;
529
+}
530
+
531
+static void cmsdk_apb_dualtimer_init(Object *obj)
532
+{
533
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
534
+ CMSDKAPBDualTimer *s = CMSDK_APB_DUALTIMER(obj);
535
+ int i;
536
+
537
+ memory_region_init_io(&s->iomem, obj, &cmsdk_apb_dualtimer_ops,
538
+ s, "cmsdk-apb-dualtimer", 0x1000);
539
+ sysbus_init_mmio(sbd, &s->iomem);
540
+ sysbus_init_irq(sbd, &s->timerintc);
541
+
542
+ for (i = 0; i < ARRAY_SIZE(s->timermod); i++) {
543
+ sysbus_init_irq(sbd, &s->timermod[i].timerint);
544
+ }
545
+}
546
+
547
+static void cmsdk_apb_dualtimer_realize(DeviceState *dev, Error **errp)
548
+{
549
+ CMSDKAPBDualTimer *s = CMSDK_APB_DUALTIMER(dev);
550
+ int i;
551
+
552
+ if (s->pclk_frq == 0) {
553
+ error_setg(errp, "CMSDK APB timer: pclk-frq property must be set");
554
+ return;
555
+ }
556
+
557
+ for (i = 0; i < ARRAY_SIZE(s->timermod); i++) {
558
+ CMSDKAPBDualTimerModule *m = &s->timermod[i];
559
+ QEMUBH *bh = qemu_bh_new(cmsdk_dualtimermod_tick, m);
560
+
561
+ m->parent = s;
562
+ m->timer = ptimer_init(bh,
563
+ PTIMER_POLICY_WRAP_AFTER_ONE_PERIOD |
564
+ PTIMER_POLICY_TRIGGER_ONLY_ON_DECREMENT |
565
+ PTIMER_POLICY_NO_IMMEDIATE_RELOAD |
566
+ PTIMER_POLICY_NO_COUNTER_ROUND_DOWN);
567
+ }
568
+}
569
+
570
+static const VMStateDescription cmsdk_dualtimermod_vmstate = {
571
+ .name = "cmsdk-apb-dualtimer-module",
572
+ .version_id = 1,
573
+ .minimum_version_id = 1,
574
+ .fields = (VMStateField[]) {
575
+ VMSTATE_PTIMER(timer, CMSDKAPBDualTimerModule),
576
+ VMSTATE_UINT32(load, CMSDKAPBDualTimerModule),
577
+ VMSTATE_UINT32(value, CMSDKAPBDualTimerModule),
578
+ VMSTATE_UINT32(control, CMSDKAPBDualTimerModule),
579
+ VMSTATE_UINT32(intstatus, CMSDKAPBDualTimerModule),
580
+ VMSTATE_END_OF_LIST()
581
+ }
582
+};
583
+
584
+static const VMStateDescription cmsdk_apb_dualtimer_vmstate = {
585
+ .name = "cmsdk-apb-dualtimer",
586
+ .version_id = 1,
587
+ .minimum_version_id = 1,
588
+ .fields = (VMStateField[]) {
589
+ VMSTATE_STRUCT_ARRAY(timermod, CMSDKAPBDualTimer,
590
+ CMSDK_APB_DUALTIMER_NUM_MODULES,
591
+ 1, cmsdk_dualtimermod_vmstate,
592
+ CMSDKAPBDualTimerModule),
593
+ VMSTATE_UINT32(timeritcr, CMSDKAPBDualTimer),
594
+ VMSTATE_UINT32(timeritop, CMSDKAPBDualTimer),
595
+ VMSTATE_END_OF_LIST()
596
+ }
597
+};
598
+
599
+static Property cmsdk_apb_dualtimer_properties[] = {
600
+ DEFINE_PROP_UINT32("pclk-frq", CMSDKAPBDualTimer, pclk_frq, 0),
601
+ DEFINE_PROP_END_OF_LIST(),
602
+};
603
+
604
+static void cmsdk_apb_dualtimer_class_init(ObjectClass *klass, void *data)
605
+{
606
+ DeviceClass *dc = DEVICE_CLASS(klass);
607
+
608
+ dc->realize = cmsdk_apb_dualtimer_realize;
609
+ dc->vmsd = &cmsdk_apb_dualtimer_vmstate;
610
+ dc->reset = cmsdk_apb_dualtimer_reset;
611
+ dc->props = cmsdk_apb_dualtimer_properties;
612
+}
613
+
614
+static const TypeInfo cmsdk_apb_dualtimer_info = {
615
+ .name = TYPE_CMSDK_APB_DUALTIMER,
616
+ .parent = TYPE_SYS_BUS_DEVICE,
617
+ .instance_size = sizeof(CMSDKAPBDualTimer),
618
+ .instance_init = cmsdk_apb_dualtimer_init,
619
+ .class_init = cmsdk_apb_dualtimer_class_init,
620
+};
621
+
622
+static void cmsdk_apb_dualtimer_register_types(void)
623
+{
624
+ type_register_static(&cmsdk_apb_dualtimer_info);
625
+}
626
+
627
+type_init(cmsdk_apb_dualtimer_register_types);
628
diff --git a/MAINTAINERS b/MAINTAINERS
629
index XXXXXXX..XXXXXXX 100644
630
--- a/MAINTAINERS
631
+++ b/MAINTAINERS
632
@@ -XXX,XX +XXX,XX @@ F: hw/timer/pl031.c
633
F: include/hw/arm/primecell.h
634
F: hw/timer/cmsdk-apb-timer.c
635
F: include/hw/timer/cmsdk-apb-timer.h
636
+F: hw/timer/cmsdk-apb-dualtimer.c
637
+F: include/hw/timer/cmsdk-apb-dualtimer.h
638
F: hw/char/cmsdk-apb-uart.c
639
F: include/hw/char/cmsdk-apb-uart.h
640
F: hw/watchdog/cmsdk-apb-watchdog.c
641
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
642
index XXXXXXX..XXXXXXX 100644
643
--- a/default-configs/arm-softmmu.mak
644
+++ b/default-configs/arm-softmmu.mak
645
@@ -XXX,XX +XXX,XX @@ CONFIG_STM32F2XX_SPI=y
646
CONFIG_STM32F205_SOC=y
647
648
CONFIG_CMSDK_APB_TIMER=y
649
+CONFIG_CMSDK_APB_DUALTIMER=y
650
CONFIG_CMSDK_APB_UART=y
651
CONFIG_CMSDK_APB_WATCHDOG=y
652
653
diff --git a/hw/timer/trace-events b/hw/timer/trace-events
654
index XXXXXXX..XXXXXXX 100644
655
--- a/hw/timer/trace-events
656
+++ b/hw/timer/trace-events
657
@@ -XXX,XX +XXX,XX @@ cmsdk_apb_timer_read(uint64_t offset, uint64_t data, unsigned size) "CMSDK APB t
658
cmsdk_apb_timer_write(uint64_t offset, uint64_t data, unsigned size) "CMSDK APB timer write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
659
cmsdk_apb_timer_reset(void) "CMSDK APB timer: reset"
660
661
+# hw/timer/cmsdk_apb_dualtimer.c
662
+cmsdk_apb_dualtimer_read(uint64_t offset, uint64_t data, unsigned size) "CMSDK APB dualtimer read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
663
+cmsdk_apb_dualtimer_write(uint64_t offset, uint64_t data, unsigned size) "CMSDK APB dualtimer write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
664
+cmsdk_apb_dualtimer_reset(void) "CMSDK APB dualtimer: reset"
665
+
666
# hw/timer/xlnx-zynqmp-rtc.c
667
xlnx_zynqmp_rtc_gettime(int year, int month, int day, int hour, int min, int sec) "Get time from host: %d-%d-%d %2d:%02d:%02d"
668
--
209
--
669
2.18.0
210
2.20.1
670
211
671
212
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
The gvec operation was added after the initial implementation
4
of the SEL instruction and was missed in the conversion.
5
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Message-id: 20180814002653.12828-5-richard.henderson@linaro.org
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20200815013145.539409-8-richard.henderson@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/helper.c | 101 ++++++++++++++++++++++----------------------
11
target/arm/translate-sve.c | 31 ++++++++-----------------------
9
1 file changed, 51 insertions(+), 50 deletions(-)
12
1 file changed, 8 insertions(+), 23 deletions(-)
10
13
11
diff --git a/target/arm/helper.c b/target/arm/helper.c
14
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
12
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/helper.c
16
--- a/target/arm/translate-sve.c
14
+++ b/target/arm/helper.c
17
+++ b/target/arm/translate-sve.c
15
@@ -XXX,XX +XXX,XX @@ float##fsz HELPER(vfp_##name##to##p)(uint##isz##_t x, uint32_t shift, \
18
@@ -XXX,XX +XXX,XX @@ static bool trans_EOR_pppp(DisasContext *s, arg_rprr_s *a)
16
void *fpstp) \
19
return do_pppp_flags(s, a, &op);
17
{ return itype##_to_##float##fsz##_scalbn(x, -shift, fpstp); }
18
19
-/* Notice that we want only input-denormal exception flags from the
20
- * scalbn operation: the other possible flags (overflow+inexact if
21
- * we overflow to infinity, output-denormal) aren't correct for the
22
- * complete scale-and-convert operation.
23
- */
24
-#define VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, round) \
25
-uint##isz##_t HELPER(vfp_to##name##p##round)(float##fsz x, \
26
- uint32_t shift, \
27
- void *fpstp) \
28
-{ \
29
- float_status *fpst = fpstp; \
30
- int old_exc_flags = get_float_exception_flags(fpst); \
31
- float##fsz tmp; \
32
- if (float##fsz##_is_any_nan(x)) { \
33
- float_raise(float_flag_invalid, fpst); \
34
- return 0; \
35
- } \
36
- tmp = float##fsz##_scalbn(x, shift, fpst); \
37
- old_exc_flags |= get_float_exception_flags(fpst) \
38
- & float_flag_input_denormal; \
39
- set_float_exception_flags(old_exc_flags, fpst); \
40
- return float##fsz##_to_##itype##round(tmp, fpst); \
41
+#define VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, ROUND, suff) \
42
+uint##isz##_t HELPER(vfp_to##name##p##suff)(float##fsz x, uint32_t shift, \
43
+ void *fpst) \
44
+{ \
45
+ if (unlikely(float##fsz##_is_any_nan(x))) { \
46
+ float_raise(float_flag_invalid, fpst); \
47
+ return 0; \
48
+ } \
49
+ return float##fsz##_to_##itype##_scalbn(x, ROUND, shift, fpst); \
50
}
20
}
51
21
52
#define VFP_CONV_FIX(name, p, fsz, isz, itype) \
22
-static void gen_sel_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg)
53
VFP_CONV_FIX_FLOAT(name, p, fsz, isz, itype) \
54
-VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, _round_to_zero) \
55
-VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, )
56
+VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, \
57
+ float_round_to_zero, _round_to_zero) \
58
+VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, \
59
+ get_float_rounding_mode(fpst), )
60
61
#define VFP_CONV_FIX_A64(name, p, fsz, isz, itype) \
62
VFP_CONV_FIX_FLOAT(name, p, fsz, isz, itype) \
63
-VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, )
64
+VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, \
65
+ get_float_rounding_mode(fpst), )
66
67
VFP_CONV_FIX(sh, d, 64, 64, int16)
68
VFP_CONV_FIX(sl, d, 64, 64, int32)
69
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(vfp_uqtoh)(uint64_t x, uint32_t shift, void *fpst)
70
return uint64_to_float16_scalbn(x, -shift, fpst);
71
}
72
73
-static float64 do_prescale_fp16(float16 f, int shift, float_status *fpst)
74
-{
23
-{
75
- if (unlikely(float16_is_any_nan(f))) {
24
- tcg_gen_and_i64(pn, pn, pg);
76
- float_raise(float_flag_invalid, fpst);
25
- tcg_gen_andc_i64(pm, pm, pg);
77
- return 0;
26
- tcg_gen_or_i64(pd, pn, pm);
78
- } else {
79
- int old_exc_flags = get_float_exception_flags(fpst);
80
- float64 ret;
81
-
82
- ret = float16_to_float64(f, true, fpst);
83
- ret = float64_scalbn(ret, shift, fpst);
84
- old_exc_flags |= get_float_exception_flags(fpst)
85
- & float_flag_input_denormal;
86
- set_float_exception_flags(old_exc_flags, fpst);
87
-
88
- return ret;
89
- }
90
-}
27
-}
91
-
28
-
92
uint32_t HELPER(vfp_toshh)(uint32_t x, uint32_t shift, void *fpst)
29
-static void gen_sel_pg_vec(unsigned vece, TCGv_vec pd, TCGv_vec pn,
30
- TCGv_vec pm, TCGv_vec pg)
31
-{
32
- tcg_gen_and_vec(vece, pn, pn, pg);
33
- tcg_gen_andc_vec(vece, pm, pm, pg);
34
- tcg_gen_or_vec(vece, pd, pn, pm);
35
-}
36
-
37
static bool trans_SEL_pppp(DisasContext *s, arg_rprr_s *a)
93
{
38
{
94
- return float64_to_int16(do_prescale_fp16(x, shift, fpst), fpst);
39
- static const GVecGen4 op = {
95
+ if (unlikely(float16_is_any_nan(x))) {
40
- .fni8 = gen_sel_pg_i64,
96
+ float_raise(float_flag_invalid, fpst);
41
- .fniv = gen_sel_pg_vec,
97
+ return 0;
42
- .fno = gen_helper_sve_sel_pppp,
43
- .prefer_i64 = TCG_TARGET_REG_BITS == 64,
44
- };
45
-
46
if (a->s) {
47
return false;
48
}
49
- return do_pppp_flags(s, a, &op);
50
+ if (sve_access_check(s)) {
51
+ unsigned psz = pred_gvec_reg_size(s);
52
+ tcg_gen_gvec_bitsel(MO_8, pred_full_reg_offset(s, a->rd),
53
+ pred_full_reg_offset(s, a->pg),
54
+ pred_full_reg_offset(s, a->rn),
55
+ pred_full_reg_offset(s, a->rm), psz, psz);
98
+ }
56
+ }
99
+ return float16_to_int16_scalbn(x, get_float_rounding_mode(fpst),
57
+ return true;
100
+ shift, fpst);
101
}
58
}
102
59
103
uint32_t HELPER(vfp_touhh)(uint32_t x, uint32_t shift, void *fpst)
60
static void gen_orr_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg)
104
{
105
- return float64_to_uint16(do_prescale_fp16(x, shift, fpst), fpst);
106
+ if (unlikely(float16_is_any_nan(x))) {
107
+ float_raise(float_flag_invalid, fpst);
108
+ return 0;
109
+ }
110
+ return float16_to_uint16_scalbn(x, get_float_rounding_mode(fpst),
111
+ shift, fpst);
112
}
113
114
uint32_t HELPER(vfp_toslh)(uint32_t x, uint32_t shift, void *fpst)
115
{
116
- return float64_to_int32(do_prescale_fp16(x, shift, fpst), fpst);
117
+ if (unlikely(float16_is_any_nan(x))) {
118
+ float_raise(float_flag_invalid, fpst);
119
+ return 0;
120
+ }
121
+ return float16_to_int32_scalbn(x, get_float_rounding_mode(fpst),
122
+ shift, fpst);
123
}
124
125
uint32_t HELPER(vfp_toulh)(uint32_t x, uint32_t shift, void *fpst)
126
{
127
- return float64_to_uint32(do_prescale_fp16(x, shift, fpst), fpst);
128
+ if (unlikely(float16_is_any_nan(x))) {
129
+ float_raise(float_flag_invalid, fpst);
130
+ return 0;
131
+ }
132
+ return float16_to_uint32_scalbn(x, get_float_rounding_mode(fpst),
133
+ shift, fpst);
134
}
135
136
uint64_t HELPER(vfp_tosqh)(uint32_t x, uint32_t shift, void *fpst)
137
{
138
- return float64_to_int64(do_prescale_fp16(x, shift, fpst), fpst);
139
+ if (unlikely(float16_is_any_nan(x))) {
140
+ float_raise(float_flag_invalid, fpst);
141
+ return 0;
142
+ }
143
+ return float16_to_int64_scalbn(x, get_float_rounding_mode(fpst),
144
+ shift, fpst);
145
}
146
147
uint64_t HELPER(vfp_touqh)(uint32_t x, uint32_t shift, void *fpst)
148
{
149
- return float64_to_uint64(do_prescale_fp16(x, shift, fpst), fpst);
150
+ if (unlikely(float16_is_any_nan(x))) {
151
+ float_raise(float_flag_invalid, fpst);
152
+ return 0;
153
+ }
154
+ return float16_to_uint64_scalbn(x, get_float_rounding_mode(fpst),
155
+ shift, fpst);
156
}
157
158
/* Set the current fp rounding mode and return the old one.
159
--
61
--
160
2.18.0
62
2.20.1
161
63
162
64
diff view generated by jsdifflib
1
The SPI controllers in the MPS2 AN505 board are PL022s.
1
From: Richard Henderson <richard.henderson@linaro.org>
2
We have a model of the PL022, so create these devices.
3
2
4
We don't currently model the LCD controller that sits behind
3
Model after gen_gvec_fn_zzz et al.
5
one of the PL022s; the others are intended to control devices
6
that sit on the FPGA's general purpose SPI connector or
7
"shield" expansion connectors.
8
4
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Message-id: 20200815013145.539409-9-richard.henderson@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 20180820141116.9118-22-peter.maydell@linaro.org
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
---
9
---
13
hw/arm/mps2-tz.c | 38 ++++++++++++++++++++++++++++++++------
10
target/arm/translate-sve.c | 35 ++++++++++++++++-------------------
14
1 file changed, 32 insertions(+), 6 deletions(-)
11
1 file changed, 16 insertions(+), 19 deletions(-)
15
12
16
diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c
13
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
17
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/arm/mps2-tz.c
15
--- a/target/arm/translate-sve.c
19
+++ b/hw/arm/mps2-tz.c
16
+++ b/target/arm/translate-sve.c
20
@@ -XXX,XX +XXX,XX @@
17
@@ -XXX,XX +XXX,XX @@ static int pred_gvec_reg_size(DisasContext *s)
21
#include "hw/misc/tz-msc.h"
18
return size_for_gvec(pred_full_reg_size(s));
22
#include "hw/arm/iotkit.h"
23
#include "hw/dma/pl080.h"
24
+#include "hw/ssi/pl022.h"
25
#include "hw/devices.h"
26
#include "net/net.h"
27
#include "hw/core/split-irq.h"
28
@@ -XXX,XX +XXX,XX @@ typedef struct {
29
MPS2FPGAIO fpgaio;
30
TZPPC ppc[5];
31
TZMPC ssram_mpc[3];
32
- UnimplementedDeviceState spi[5];
33
+ PL022State spi[5];
34
UnimplementedDeviceState i2c[4];
35
UnimplementedDeviceState i2s_audio;
36
UnimplementedDeviceState gpio[4];
37
@@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_dma(MPS2TZMachineState *mms, void *opaque,
38
return sysbus_mmio_get_region(s, 0);
39
}
19
}
40
20
41
+static MemoryRegion *make_spi(MPS2TZMachineState *mms, void *opaque,
21
-/* Invoke a vector expander on two Zregs. */
42
+ const char *name, hwaddr size)
22
+/* Invoke an out-of-line helper on 3 Zregs and a predicate. */
23
+static void gen_gvec_ool_zzzp(DisasContext *s, gen_helper_gvec_4 *fn,
24
+ int rd, int rn, int rm, int pg, int data)
43
+{
25
+{
44
+ /*
26
+ unsigned vsz = vec_full_reg_size(s);
45
+ * The AN505 has five PL022 SPI controllers.
27
+ tcg_gen_gvec_4_ool(vec_full_reg_offset(s, rd),
46
+ * One of these should have the LCD controller behind it; the others
28
+ vec_full_reg_offset(s, rn),
47
+ * are connected only to the FPGA's "general purpose SPI connector"
29
+ vec_full_reg_offset(s, rm),
48
+ * or "shield" expansion connectors.
30
+ pred_full_reg_offset(s, pg),
49
+ * Note that if we do implement devices behind SPI, the chip select
31
+ vsz, vsz, data, fn);
50
+ * lines are set via the "MISC" register in the MPS2 FPGAIO device.
51
+ */
52
+ PL022State *spi = opaque;
53
+ int i = spi - &mms->spi[0];
54
+ DeviceState *iotkitdev = DEVICE(&mms->iotkit);
55
+ SysBusDevice *s;
56
+
57
+ sysbus_init_child_obj(OBJECT(mms), name, spi, sizeof(mms->spi[0]),
58
+ TYPE_PL022);
59
+ object_property_set_bool(OBJECT(spi), true, "realized", &error_fatal);
60
+ s = SYS_BUS_DEVICE(spi);
61
+ sysbus_connect_irq(s, 0,
62
+ qdev_get_gpio_in_named(iotkitdev, "EXP_IRQ", 51 + i));
63
+ return sysbus_mmio_get_region(s, 0);
64
+}
32
+}
65
+
33
66
static void mps2tz_common_init(MachineState *machine)
34
+/* Invoke a vector expander on two Zregs. */
35
static void gen_gvec_fn_zz(DisasContext *s, GVecGen2Fn *gvec_fn,
36
int esz, int rd, int rn)
67
{
37
{
68
MPS2TZMachineState *mms = MPS2TZ_MACHINE(machine);
38
@@ -XXX,XX +XXX,XX @@ static bool trans_UQSUB_zzz(DisasContext *s, arg_rrr_esz *a)
69
@@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine)
39
70
}, {
40
static bool do_zpzz_ool(DisasContext *s, arg_rprr_esz *a, gen_helper_gvec_4 *fn)
71
.name = "apb_ppcexp1",
41
{
72
.ports = {
42
- unsigned vsz = vec_full_reg_size(s);
73
- { "spi0", make_unimp_dev, &mms->spi[0], 0x40205000, 0x1000 },
43
if (fn == NULL) {
74
- { "spi1", make_unimp_dev, &mms->spi[1], 0x40206000, 0x1000 },
44
return false;
75
- { "spi2", make_unimp_dev, &mms->spi[2], 0x40209000, 0x1000 },
45
}
76
- { "spi3", make_unimp_dev, &mms->spi[3], 0x4020a000, 0x1000 },
46
if (sve_access_check(s)) {
77
- { "spi4", make_unimp_dev, &mms->spi[4], 0x4020b000, 0x1000 },
47
- tcg_gen_gvec_4_ool(vec_full_reg_offset(s, a->rd),
78
+ { "spi0", make_spi, &mms->spi[0], 0x40205000, 0x1000 },
48
- vec_full_reg_offset(s, a->rn),
79
+ { "spi1", make_spi, &mms->spi[1], 0x40206000, 0x1000 },
49
- vec_full_reg_offset(s, a->rm),
80
+ { "spi2", make_spi, &mms->spi[2], 0x40209000, 0x1000 },
50
- pred_full_reg_offset(s, a->pg),
81
+ { "spi3", make_spi, &mms->spi[3], 0x4020a000, 0x1000 },
51
- vsz, vsz, 0, fn);
82
+ { "spi4", make_spi, &mms->spi[4], 0x4020b000, 0x1000 },
52
+ gen_gvec_ool_zzzp(s, fn, a->rd, a->rn, a->rm, a->pg, 0);
83
{ "uart0", make_uart, &mms->uart[0], 0x40200000, 0x1000 },
53
}
84
{ "uart1", make_uart, &mms->uart[1], 0x40201000, 0x1000 },
54
return true;
85
{ "uart2", make_uart, &mms->uart[2], 0x40202000, 0x1000 },
55
}
56
@@ -XXX,XX +XXX,XX @@ static void do_sel_z(DisasContext *s, int rd, int rn, int rm, int pg, int esz)
57
gen_helper_sve_sel_zpzz_b, gen_helper_sve_sel_zpzz_h,
58
gen_helper_sve_sel_zpzz_s, gen_helper_sve_sel_zpzz_d
59
};
60
- unsigned vsz = vec_full_reg_size(s);
61
- tcg_gen_gvec_4_ool(vec_full_reg_offset(s, rd),
62
- vec_full_reg_offset(s, rn),
63
- vec_full_reg_offset(s, rm),
64
- pred_full_reg_offset(s, pg),
65
- vsz, vsz, 0, fns[esz]);
66
+ gen_gvec_ool_zzzp(s, fns[esz], rd, rn, rm, pg, 0);
67
}
68
69
#define DO_ZPZZ(NAME, name) \
70
@@ -XXX,XX +XXX,XX @@ static bool trans_RBIT(DisasContext *s, arg_rpr_esz *a)
71
static bool trans_SPLICE(DisasContext *s, arg_rprr_esz *a)
72
{
73
if (sve_access_check(s)) {
74
- unsigned vsz = vec_full_reg_size(s);
75
- tcg_gen_gvec_4_ool(vec_full_reg_offset(s, a->rd),
76
- vec_full_reg_offset(s, a->rn),
77
- vec_full_reg_offset(s, a->rm),
78
- pred_full_reg_offset(s, a->pg),
79
- vsz, vsz, a->esz, gen_helper_sve_splice);
80
+ gen_gvec_ool_zzzp(s, gen_helper_sve_splice,
81
+ a->rd, a->rn, a->rm, a->pg, 0);
82
}
83
return true;
84
}
86
--
85
--
87
2.18.0
86
2.20.1
88
87
89
88
diff view generated by jsdifflib
1
Implement a model of the TrustZone Master Securtiy Controller,
1
From: Richard Henderson <richard.henderson@linaro.org>
2
as documented in the Arm CoreLink SIE-200 System IP for
2
3
Embedded TRM (DDI0571G):
3
The existing clr functions have only one vector argument, and so
4
https://developer.arm.com/products/architecture/m-profile/docs/ddi0571/g
4
can only clear in place. The existing movz functions have two
5
5
vector arguments, and so can clear while moving. Merge them, with
6
The MSC is intended to sit in front of a device which can
6
a flag that controls the sense of active vs inactive elements
7
be a bus master (eg a DMA controller) and programmably gate
7
being cleared.
8
its transactions. This allows a bus-mastering device to be
8
9
controlled by non-secure code but still restricted from
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
making accesses to addresses which are secure-only.
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
11
Message-id: 20200815013145.539409-10-richard.henderson@linaro.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Message-id: 20180820141116.9118-12-peter.maydell@linaro.org
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
---
13
---
16
hw/misc/Makefile.objs | 1 +
14
target/arm/helper-sve.h | 5 ---
17
include/hw/misc/tz-msc.h | 79 ++++++++
15
target/arm/sve_helper.c | 70 ++++++++------------------------------
18
hw/misc/tz-msc.c | 308 ++++++++++++++++++++++++++++++++
16
target/arm/translate-sve.c | 53 +++++++++++------------------
19
MAINTAINERS | 2 +
17
3 files changed, 34 insertions(+), 94 deletions(-)
20
default-configs/arm-softmmu.mak | 1 +
18
21
hw/misc/trace-events | 9 +
19
diff --git a/target/arm/helper-sve.h b/target/arm/helper-sve.h
22
6 files changed, 400 insertions(+)
23
create mode 100644 include/hw/misc/tz-msc.h
24
create mode 100644 hw/misc/tz-msc.c
25
26
diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs
27
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
28
--- a/hw/misc/Makefile.objs
21
--- a/target/arm/helper-sve.h
29
+++ b/hw/misc/Makefile.objs
22
+++ b/target/arm/helper-sve.h
30
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_MPS2_FPGAIO) += mps2-fpgaio.o
23
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(sve_uminv_h, TCG_CALL_NO_RWG, i64, ptr, ptr, i32)
31
obj-$(CONFIG_MPS2_SCC) += mps2-scc.o
24
DEF_HELPER_FLAGS_3(sve_uminv_s, TCG_CALL_NO_RWG, i64, ptr, ptr, i32)
32
25
DEF_HELPER_FLAGS_3(sve_uminv_d, TCG_CALL_NO_RWG, i64, ptr, ptr, i32)
33
obj-$(CONFIG_TZ_MPC) += tz-mpc.o
26
34
+obj-$(CONFIG_TZ_MSC) += tz-msc.o
27
-DEF_HELPER_FLAGS_3(sve_clr_b, TCG_CALL_NO_RWG, void, ptr, ptr, i32)
35
obj-$(CONFIG_TZ_PPC) += tz-ppc.o
28
-DEF_HELPER_FLAGS_3(sve_clr_h, TCG_CALL_NO_RWG, void, ptr, ptr, i32)
36
obj-$(CONFIG_IOTKIT_SECCTL) += iotkit-secctl.o
29
-DEF_HELPER_FLAGS_3(sve_clr_s, TCG_CALL_NO_RWG, void, ptr, ptr, i32)
37
obj-$(CONFIG_IOTKIT_SYSCTL) += iotkit-sysctl.o
30
-DEF_HELPER_FLAGS_3(sve_clr_d, TCG_CALL_NO_RWG, void, ptr, ptr, i32)
38
diff --git a/include/hw/misc/tz-msc.h b/include/hw/misc/tz-msc.h
31
-
39
new file mode 100644
32
DEF_HELPER_FLAGS_4(sve_movz_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
40
index XXXXXXX..XXXXXXX
33
DEF_HELPER_FLAGS_4(sve_movz_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
41
--- /dev/null
34
DEF_HELPER_FLAGS_4(sve_movz_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
42
+++ b/include/hw/misc/tz-msc.h
35
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
43
@@ -XXX,XX +XXX,XX @@
36
index XXXXXXX..XXXXXXX 100644
37
--- a/target/arm/sve_helper.c
38
+++ b/target/arm/sve_helper.c
39
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sve_pnext)(void *vd, void *vg, uint32_t pred_desc)
40
return flags;
41
}
42
43
-/* Store zero into every active element of Zd. We will use this for two
44
- * and three-operand predicated instructions for which logic dictates a
45
- * zero result. In particular, logical shift by element size, which is
46
- * otherwise undefined on the host.
47
- *
48
- * For element sizes smaller than uint64_t, we use tables to expand
49
- * the N bits of the controlling predicate to a byte mask, and clear
50
- * those bytes.
44
+/*
51
+/*
45
+ * ARM TrustZone master security controller emulation
52
+ * Copy Zn into Zd, and store zero into inactive elements.
46
+ *
53
+ * If inv, store zeros into the active elements.
47
+ * Copyright (c) 2018 Linaro Limited
54
*/
48
+ * Written by Peter Maydell
55
-void HELPER(sve_clr_b)(void *vd, void *vg, uint32_t desc)
49
+ *
56
-{
50
+ * This program is free software; you can redistribute it and/or modify
57
- intptr_t i, opr_sz = simd_oprsz(desc) / 8;
51
+ * it under the terms of the GNU General Public License version 2 or
58
- uint64_t *d = vd;
52
+ * (at your option) any later version.
59
- uint8_t *pg = vg;
53
+ */
60
- for (i = 0; i < opr_sz; i += 1) {
54
+
61
- d[i] &= ~expand_pred_b(pg[H1(i)]);
62
- }
63
-}
64
-
65
-void HELPER(sve_clr_h)(void *vd, void *vg, uint32_t desc)
66
-{
67
- intptr_t i, opr_sz = simd_oprsz(desc) / 8;
68
- uint64_t *d = vd;
69
- uint8_t *pg = vg;
70
- for (i = 0; i < opr_sz; i += 1) {
71
- d[i] &= ~expand_pred_h(pg[H1(i)]);
72
- }
73
-}
74
-
75
-void HELPER(sve_clr_s)(void *vd, void *vg, uint32_t desc)
76
-{
77
- intptr_t i, opr_sz = simd_oprsz(desc) / 8;
78
- uint64_t *d = vd;
79
- uint8_t *pg = vg;
80
- for (i = 0; i < opr_sz; i += 1) {
81
- d[i] &= ~expand_pred_s(pg[H1(i)]);
82
- }
83
-}
84
-
85
-void HELPER(sve_clr_d)(void *vd, void *vg, uint32_t desc)
86
-{
87
- intptr_t i, opr_sz = simd_oprsz(desc) / 8;
88
- uint64_t *d = vd;
89
- uint8_t *pg = vg;
90
- for (i = 0; i < opr_sz; i += 1) {
91
- if (pg[H1(i)] & 1) {
92
- d[i] = 0;
93
- }
94
- }
95
-}
96
-
97
-/* Copy Zn into Zd, and store zero into inactive elements. */
98
void HELPER(sve_movz_b)(void *vd, void *vn, void *vg, uint32_t desc)
99
{
100
intptr_t i, opr_sz = simd_oprsz(desc) / 8;
101
+ uint64_t inv = -(uint64_t)(simd_data(desc) & 1);
102
uint64_t *d = vd, *n = vn;
103
uint8_t *pg = vg;
104
+
105
for (i = 0; i < opr_sz; i += 1) {
106
- d[i] = n[i] & expand_pred_b(pg[H1(i)]);
107
+ d[i] = n[i] & (expand_pred_b(pg[H1(i)]) ^ inv);
108
}
109
}
110
111
void HELPER(sve_movz_h)(void *vd, void *vn, void *vg, uint32_t desc)
112
{
113
intptr_t i, opr_sz = simd_oprsz(desc) / 8;
114
+ uint64_t inv = -(uint64_t)(simd_data(desc) & 1);
115
uint64_t *d = vd, *n = vn;
116
uint8_t *pg = vg;
117
+
118
for (i = 0; i < opr_sz; i += 1) {
119
- d[i] = n[i] & expand_pred_h(pg[H1(i)]);
120
+ d[i] = n[i] & (expand_pred_h(pg[H1(i)]) ^ inv);
121
}
122
}
123
124
void HELPER(sve_movz_s)(void *vd, void *vn, void *vg, uint32_t desc)
125
{
126
intptr_t i, opr_sz = simd_oprsz(desc) / 8;
127
+ uint64_t inv = -(uint64_t)(simd_data(desc) & 1);
128
uint64_t *d = vd, *n = vn;
129
uint8_t *pg = vg;
130
+
131
for (i = 0; i < opr_sz; i += 1) {
132
- d[i] = n[i] & expand_pred_s(pg[H1(i)]);
133
+ d[i] = n[i] & (expand_pred_s(pg[H1(i)]) ^ inv);
134
}
135
}
136
137
@@ -XXX,XX +XXX,XX @@ void HELPER(sve_movz_d)(void *vd, void *vn, void *vg, uint32_t desc)
138
intptr_t i, opr_sz = simd_oprsz(desc) / 8;
139
uint64_t *d = vd, *n = vn;
140
uint8_t *pg = vg;
141
+ uint8_t inv = simd_data(desc);
142
+
143
for (i = 0; i < opr_sz; i += 1) {
144
- d[i] = n[i] & -(uint64_t)(pg[H1(i)] & 1);
145
+ d[i] = n[i] & -(uint64_t)((pg[H1(i)] ^ inv) & 1);
146
}
147
}
148
149
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
150
index XXXXXXX..XXXXXXX 100644
151
--- a/target/arm/translate-sve.c
152
+++ b/target/arm/translate-sve.c
153
@@ -XXX,XX +XXX,XX @@ static bool trans_SADDV(DisasContext *s, arg_rpr_esz *a)
154
*** SVE Shift by Immediate - Predicated Group
155
*/
156
157
-/* Store zero into every active element of Zd. We will use this for two
158
- * and three-operand predicated instructions for which logic dictates a
159
- * zero result.
55
+/*
160
+/*
56
+ * This is a model of the TrustZone master security controller (MSC).
161
+ * Copy Zn into Zd, storing zeros into inactive elements.
57
+ * It is documented in the ARM CoreLink SIE-200 System IP for Embedded TRM
162
+ * If invert, store zeros into the active elements.
58
+ * (DDI 0571G):
163
*/
59
+ * https://developer.arm.com/products/architecture/m-profile/docs/ddi0571/g
164
-static bool do_clr_zp(DisasContext *s, int rd, int pg, int esz)
60
+ *
165
-{
61
+ * The MSC sits in front of a device which can be a bus master (such as
166
- static gen_helper_gvec_2 * const fns[4] = {
62
+ * a DMA controller) and allows secure software to configure it to either
167
- gen_helper_sve_clr_b, gen_helper_sve_clr_h,
63
+ * pass through or reject transactions made by that bus master.
168
- gen_helper_sve_clr_s, gen_helper_sve_clr_d,
64
+ * Rejected transactions may be configured to either be aborted, or to
169
- };
65
+ * behave as RAZ/WI. An interrupt can be signalled for a rejected transaction.
170
- if (sve_access_check(s)) {
66
+ *
171
- unsigned vsz = vec_full_reg_size(s);
67
+ * The MSC has no register interface -- it is configured purely by a
172
- tcg_gen_gvec_2_ool(vec_full_reg_offset(s, rd),
68
+ * collection of input signals from other hardware in the system. Typically
173
- pred_full_reg_offset(s, pg),
69
+ * they are either hardwired or exposed in an ad-hoc register interface by
174
- vsz, vsz, 0, fns[esz]);
70
+ * the SoC that uses the MSC.
175
- }
71
+ *
176
- return true;
72
+ * We don't currently implement the irq_enable GPIO input, because on
177
-}
73
+ * the MPS2 FPGA images it is always tied high, which is awkward to
178
-
74
+ * implement in QEMU.
179
-/* Copy Zn into Zd, storing zeros into inactive elements. */
75
+ *
180
-static void do_movz_zpz(DisasContext *s, int rd, int rn, int pg, int esz)
76
+ * QEMU interface:
181
+static bool do_movz_zpz(DisasContext *s, int rd, int rn, int pg,
77
+ * + Named GPIO input "cfg_nonsec": set to 1 if the bus master should be
182
+ int esz, bool invert)
78
+ * treated as nonsecure, or 0 for secure
183
{
79
+ * + Named GPIO input "cfg_sec_resp": set to 1 if a rejected transaction should
184
static gen_helper_gvec_3 * const fns[4] = {
80
+ * result in a transaction error, or 0 for the transaction to RAZ/WI
185
gen_helper_sve_movz_b, gen_helper_sve_movz_h,
81
+ * + Named GPIO input "irq_clear": set to 1 to clear a pending interrupt
186
gen_helper_sve_movz_s, gen_helper_sve_movz_d,
82
+ * + Named GPIO output "irq": set for a transaction-failed interrupt
187
};
83
+ * + Property "downstream": MemoryRegion defining where bus master transactions
188
- unsigned vsz = vec_full_reg_size(s);
84
+ * are made if they are not blocked
189
- tcg_gen_gvec_3_ool(vec_full_reg_offset(s, rd),
85
+ * + Property "idau": an object implementing IDAUInterface, which defines which
190
- vec_full_reg_offset(s, rn),
86
+ * addresses should be treated as secure and which as non-secure.
191
- pred_full_reg_offset(s, pg),
87
+ * This need not be the same IDAU as the one used by the CPU.
192
- vsz, vsz, 0, fns[esz]);
88
+ * + sysbus MMIO region 0: MemoryRegion defining the upstream end of the MSC;
193
+
89
+ * this should be passed to the bus master device as the region it should
194
+ if (sve_access_check(s)) {
90
+ * make memory transactions to
195
+ unsigned vsz = vec_full_reg_size(s);
91
+ */
196
+ tcg_gen_gvec_3_ool(vec_full_reg_offset(s, rd),
92
+
197
+ vec_full_reg_offset(s, rn),
93
+#ifndef TZ_MSC_H
198
+ pred_full_reg_offset(s, pg),
94
+#define TZ_MSC_H
199
+ vsz, vsz, invert, fns[esz]);
95
+
96
+#include "hw/sysbus.h"
97
+#include "target/arm/idau.h"
98
+
99
+#define TYPE_TZ_MSC "tz-msc"
100
+#define TZ_MSC(obj) OBJECT_CHECK(TZMSC, (obj), TYPE_TZ_MSC)
101
+
102
+typedef struct TZMSC {
103
+ /*< private >*/
104
+ SysBusDevice parent_obj;
105
+
106
+ /*< public >*/
107
+
108
+ /* State: these just track the values of our input signals */
109
+ bool cfg_nonsec;
110
+ bool cfg_sec_resp;
111
+ bool irq_clear;
112
+ /* State: are we asserting irq ? */
113
+ bool irq_status;
114
+
115
+ qemu_irq irq;
116
+ MemoryRegion *downstream;
117
+ AddressSpace downstream_as;
118
+ MemoryRegion upstream;
119
+ IDAUInterface *idau;
120
+} TZMSC;
121
+
122
+#endif
123
diff --git a/hw/misc/tz-msc.c b/hw/misc/tz-msc.c
124
new file mode 100644
125
index XXXXXXX..XXXXXXX
126
--- /dev/null
127
+++ b/hw/misc/tz-msc.c
128
@@ -XXX,XX +XXX,XX @@
129
+/*
130
+ * ARM TrustZone master security controller emulation
131
+ *
132
+ * Copyright (c) 2018 Linaro Limited
133
+ * Written by Peter Maydell
134
+ *
135
+ * This program is free software; you can redistribute it and/or modify
136
+ * it under the terms of the GNU General Public License version 2 or
137
+ * (at your option) any later version.
138
+ */
139
+
140
+#include "qemu/osdep.h"
141
+#include "qemu/log.h"
142
+#include "qapi/error.h"
143
+#include "trace.h"
144
+#include "hw/sysbus.h"
145
+#include "hw/registerfields.h"
146
+#include "hw/misc/tz-msc.h"
147
+
148
+static void tz_msc_update_irq(TZMSC *s)
149
+{
150
+ bool level = s->irq_status;
151
+
152
+ trace_tz_msc_update_irq(level);
153
+ qemu_set_irq(s->irq, level);
154
+}
155
+
156
+static void tz_msc_cfg_nonsec(void *opaque, int n, int level)
157
+{
158
+ TZMSC *s = TZ_MSC(opaque);
159
+
160
+ trace_tz_msc_cfg_nonsec(level);
161
+ s->cfg_nonsec = level;
162
+}
163
+
164
+static void tz_msc_cfg_sec_resp(void *opaque, int n, int level)
165
+{
166
+ TZMSC *s = TZ_MSC(opaque);
167
+
168
+ trace_tz_msc_cfg_sec_resp(level);
169
+ s->cfg_sec_resp = level;
170
+}
171
+
172
+static void tz_msc_irq_clear(void *opaque, int n, int level)
173
+{
174
+ TZMSC *s = TZ_MSC(opaque);
175
+
176
+ trace_tz_msc_irq_clear(level);
177
+
178
+ s->irq_clear = level;
179
+ if (level) {
180
+ s->irq_status = false;
181
+ tz_msc_update_irq(s);
182
+ }
200
+ }
183
+}
201
+ return true;
184
+
202
}
185
+/* The MSC may either block a transaction by aborting it, block a
203
186
+ * transaction by making it RAZ/WI, allow it through with
204
static bool do_zpzi_ool(DisasContext *s, arg_rpri_esz *a,
187
+ * MemTxAttrs indicating a secure transaction, or allow it with
205
@@ -XXX,XX +XXX,XX @@ static bool trans_LSR_zpzi(DisasContext *s, arg_rpri_esz *a)
188
+ * MemTxAttrs indicating a non-secure transaction.
206
/* Shift by element size is architecturally valid.
189
+ */
207
For logical shifts, it is a zeroing operation. */
190
+typedef enum MSCAction {
208
if (a->imm >= (8 << a->esz)) {
191
+ MSCBlockAbort,
209
- return do_clr_zp(s, a->rd, a->pg, a->esz);
192
+ MSCBlockRAZWI,
210
+ return do_movz_zpz(s, a->rd, a->rd, a->pg, a->esz, true);
193
+ MSCAllowSecure,
211
} else {
194
+ MSCAllowNonSecure,
212
return do_zpzi_ool(s, a, fns[a->esz]);
195
+} MSCAction;
213
}
196
+
214
@@ -XXX,XX +XXX,XX @@ static bool trans_LSL_zpzi(DisasContext *s, arg_rpri_esz *a)
197
+static MSCAction tz_msc_check(TZMSC *s, hwaddr addr)
215
/* Shift by element size is architecturally valid.
198
+{
216
For logical shifts, it is a zeroing operation. */
199
+ /*
217
if (a->imm >= (8 << a->esz)) {
200
+ * Check whether to allow an access from the bus master, returning
218
- return do_clr_zp(s, a->rd, a->pg, a->esz);
201
+ * an MSCAction indicating the required behaviour. If the transaction
219
+ return do_movz_zpz(s, a->rd, a->rd, a->pg, a->esz, true);
202
+ * is blocked, the caller must check cfg_sec_resp to determine
220
} else {
203
+ * whether to abort or RAZ/WI the transaction.
221
return do_zpzi_ool(s, a, fns[a->esz]);
204
+ */
222
}
205
+ IDAUInterfaceClass *iic = IDAU_INTERFACE_GET_CLASS(s->idau);
223
@@ -XXX,XX +XXX,XX @@ static bool trans_ASRD(DisasContext *s, arg_rpri_esz *a)
206
+ IDAUInterface *ii = IDAU_INTERFACE(s->idau);
224
/* Shift by element size is architecturally valid. For arithmetic
207
+ bool idau_exempt = false, idau_ns = true, idau_nsc = true;
225
right shift for division, it is a zeroing operation. */
208
+ int idau_region = IREGION_NOTVALID;
226
if (a->imm >= (8 << a->esz)) {
209
+
227
- return do_clr_zp(s, a->rd, a->pg, a->esz);
210
+ iic->check(ii, addr, &idau_region, &idau_exempt, &idau_ns, &idau_nsc);
228
+ return do_movz_zpz(s, a->rd, a->rd, a->pg, a->esz, true);
211
+
229
} else {
212
+ if (idau_exempt) {
230
return do_zpzi_ool(s, a, fns[a->esz]);
213
+ /*
231
}
214
+ * Uncheck region -- OK, transaction type depends on
232
@@ -XXX,XX +XXX,XX @@ static bool trans_LD1R_zpri(DisasContext *s, arg_rpri_load *a)
215
+ * whether bus master is configured as Secure or NonSecure
233
216
+ */
234
/* Zero the inactive elements. */
217
+ return s->cfg_nonsec ? MSCAllowNonSecure : MSCAllowSecure;
235
gen_set_label(over);
218
+ }
236
- do_movz_zpz(s, a->rd, a->rd, a->pg, esz);
219
+
237
- return true;
220
+ if (idau_ns) {
238
+ return do_movz_zpz(s, a->rd, a->rd, a->pg, esz, false);
221
+ /* NonSecure region -- always forward as NS transaction */
239
}
222
+ return MSCAllowNonSecure;
240
223
+ }
241
static void do_st_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr,
224
+
242
@@ -XXX,XX +XXX,XX @@ static bool trans_MOVPRFX_m(DisasContext *s, arg_rpr_esz *a)
225
+ if (!s->cfg_nonsec) {
243
226
+ /* Access to Secure region by Secure bus master: OK */
244
static bool trans_MOVPRFX_z(DisasContext *s, arg_rpr_esz *a)
227
+ return MSCAllowSecure;
245
{
228
+ }
246
- if (sve_access_check(s)) {
229
+
247
- do_movz_zpz(s, a->rd, a->rn, a->pg, a->esz);
230
+ /* Attempted access to Secure region by NS bus master: block */
248
- }
231
+ trace_tz_msc_access_blocked(addr);
249
- return true;
232
+ if (!s->cfg_sec_resp) {
250
+ return do_movz_zpz(s, a->rd, a->rn, a->pg, a->esz, false);
233
+ return MSCBlockRAZWI;
251
}
234
+ }
235
+
236
+ /*
237
+ * The TRM isn't clear on behaviour if irq_clear is high when a
238
+ * transaction is blocked. We assume that the MSC behaves like the
239
+ * PPC, where holding irq_clear high suppresses the interrupt.
240
+ */
241
+ if (!s->irq_clear) {
242
+ s->irq_status = true;
243
+ tz_msc_update_irq(s);
244
+ }
245
+ return MSCBlockAbort;
246
+}
247
+
248
+static MemTxResult tz_msc_read(void *opaque, hwaddr addr, uint64_t *pdata,
249
+ unsigned size, MemTxAttrs attrs)
250
+{
251
+ TZMSC *s = opaque;
252
+ AddressSpace *as = &s->downstream_as;
253
+ uint64_t data;
254
+ MemTxResult res;
255
+
256
+ switch (tz_msc_check(s, addr)) {
257
+ case MSCBlockAbort:
258
+ return MEMTX_ERROR;
259
+ case MSCBlockRAZWI:
260
+ *pdata = 0;
261
+ return MEMTX_OK;
262
+ case MSCAllowSecure:
263
+ attrs.secure = 1;
264
+ attrs.unspecified = 0;
265
+ break;
266
+ case MSCAllowNonSecure:
267
+ attrs.secure = 0;
268
+ attrs.unspecified = 0;
269
+ break;
270
+ }
271
+
272
+ switch (size) {
273
+ case 1:
274
+ data = address_space_ldub(as, addr, attrs, &res);
275
+ break;
276
+ case 2:
277
+ data = address_space_lduw_le(as, addr, attrs, &res);
278
+ break;
279
+ case 4:
280
+ data = address_space_ldl_le(as, addr, attrs, &res);
281
+ break;
282
+ case 8:
283
+ data = address_space_ldq_le(as, addr, attrs, &res);
284
+ break;
285
+ default:
286
+ g_assert_not_reached();
287
+ }
288
+ *pdata = data;
289
+ return res;
290
+}
291
+
292
+static MemTxResult tz_msc_write(void *opaque, hwaddr addr, uint64_t val,
293
+ unsigned size, MemTxAttrs attrs)
294
+{
295
+ TZMSC *s = opaque;
296
+ AddressSpace *as = &s->downstream_as;
297
+ MemTxResult res;
298
+
299
+ switch (tz_msc_check(s, addr)) {
300
+ case MSCBlockAbort:
301
+ return MEMTX_ERROR;
302
+ case MSCBlockRAZWI:
303
+ return MEMTX_OK;
304
+ case MSCAllowSecure:
305
+ attrs.secure = 1;
306
+ attrs.unspecified = 0;
307
+ break;
308
+ case MSCAllowNonSecure:
309
+ attrs.secure = 0;
310
+ attrs.unspecified = 0;
311
+ break;
312
+ }
313
+
314
+ switch (size) {
315
+ case 1:
316
+ address_space_stb(as, addr, val, attrs, &res);
317
+ break;
318
+ case 2:
319
+ address_space_stw_le(as, addr, val, attrs, &res);
320
+ break;
321
+ case 4:
322
+ address_space_stl_le(as, addr, val, attrs, &res);
323
+ break;
324
+ case 8:
325
+ address_space_stq_le(as, addr, val, attrs, &res);
326
+ break;
327
+ default:
328
+ g_assert_not_reached();
329
+ }
330
+ return res;
331
+}
332
+
333
+static const MemoryRegionOps tz_msc_ops = {
334
+ .read_with_attrs = tz_msc_read,
335
+ .write_with_attrs = tz_msc_write,
336
+ .endianness = DEVICE_LITTLE_ENDIAN,
337
+};
338
+
339
+static void tz_msc_reset(DeviceState *dev)
340
+{
341
+ TZMSC *s = TZ_MSC(dev);
342
+
343
+ trace_tz_msc_reset();
344
+ s->cfg_sec_resp = false;
345
+ s->cfg_nonsec = false;
346
+ s->irq_clear = 0;
347
+ s->irq_status = 0;
348
+}
349
+
350
+static void tz_msc_init(Object *obj)
351
+{
352
+ DeviceState *dev = DEVICE(obj);
353
+ TZMSC *s = TZ_MSC(obj);
354
+
355
+ qdev_init_gpio_in_named(dev, tz_msc_cfg_nonsec, "cfg_nonsec", 1);
356
+ qdev_init_gpio_in_named(dev, tz_msc_cfg_sec_resp, "cfg_sec_resp", 1);
357
+ qdev_init_gpio_in_named(dev, tz_msc_irq_clear, "irq_clear", 1);
358
+ qdev_init_gpio_out_named(dev, &s->irq, "irq", 1);
359
+}
360
+
361
+static void tz_msc_realize(DeviceState *dev, Error **errp)
362
+{
363
+ Object *obj = OBJECT(dev);
364
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
365
+ TZMSC *s = TZ_MSC(dev);
366
+ const char *name = "tz-msc-downstream";
367
+ uint64_t size;
368
+
369
+ /*
370
+ * We can't create the upstream end of the port until realize,
371
+ * as we don't know the size of the MR used as the downstream until then.
372
+ * We insist on having a downstream, to avoid complicating the
373
+ * code with handling the "don't know how big this is" case. It's easy
374
+ * enough for the user to create an unimplemented_device as downstream
375
+ * if they have nothing else to plug into this.
376
+ */
377
+ if (!s->downstream) {
378
+ error_setg(errp, "MSC 'downstream' link not set");
379
+ return;
380
+ }
381
+ if (!s->idau) {
382
+ error_setg(errp, "MSC 'idau' link not set");
383
+ return;
384
+ }
385
+
386
+ size = memory_region_size(s->downstream);
387
+ address_space_init(&s->downstream_as, s->downstream, name);
388
+ memory_region_init_io(&s->upstream, obj, &tz_msc_ops, s, name, size);
389
+ sysbus_init_mmio(sbd, &s->upstream);
390
+}
391
+
392
+static const VMStateDescription tz_msc_vmstate = {
393
+ .name = "tz-msc",
394
+ .version_id = 1,
395
+ .minimum_version_id = 1,
396
+ .fields = (VMStateField[]) {
397
+ VMSTATE_BOOL(cfg_nonsec, TZMSC),
398
+ VMSTATE_BOOL(cfg_sec_resp, TZMSC),
399
+ VMSTATE_BOOL(irq_clear, TZMSC),
400
+ VMSTATE_BOOL(irq_status, TZMSC),
401
+ VMSTATE_END_OF_LIST()
402
+ }
403
+};
404
+
405
+static Property tz_msc_properties[] = {
406
+ DEFINE_PROP_LINK("downstream", TZMSC, downstream,
407
+ TYPE_MEMORY_REGION, MemoryRegion *),
408
+ DEFINE_PROP_LINK("idau", TZMSC, idau,
409
+ TYPE_IDAU_INTERFACE, IDAUInterface *),
410
+ DEFINE_PROP_END_OF_LIST(),
411
+};
412
+
413
+static void tz_msc_class_init(ObjectClass *klass, void *data)
414
+{
415
+ DeviceClass *dc = DEVICE_CLASS(klass);
416
+
417
+ dc->realize = tz_msc_realize;
418
+ dc->vmsd = &tz_msc_vmstate;
419
+ dc->reset = tz_msc_reset;
420
+ dc->props = tz_msc_properties;
421
+}
422
+
423
+static const TypeInfo tz_msc_info = {
424
+ .name = TYPE_TZ_MSC,
425
+ .parent = TYPE_SYS_BUS_DEVICE,
426
+ .instance_size = sizeof(TZMSC),
427
+ .instance_init = tz_msc_init,
428
+ .class_init = tz_msc_class_init,
429
+};
430
+
431
+static void tz_msc_register_types(void)
432
+{
433
+ type_register_static(&tz_msc_info);
434
+}
435
+
436
+type_init(tz_msc_register_types);
437
diff --git a/MAINTAINERS b/MAINTAINERS
438
index XXXXXXX..XXXXXXX 100644
439
--- a/MAINTAINERS
440
+++ b/MAINTAINERS
441
@@ -XXX,XX +XXX,XX @@ F: hw/misc/tz-ppc.c
442
F: include/hw/misc/tz-ppc.h
443
F: hw/misc/tz-mpc.c
444
F: include/hw/misc/tz-mpc.h
445
+F: hw/misc/tz-msc.c
446
+F: include/hw/misc/tz-msc.h
447
448
ARM cores
449
M: Peter Maydell <peter.maydell@linaro.org>
450
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
451
index XXXXXXX..XXXXXXX 100644
452
--- a/default-configs/arm-softmmu.mak
453
+++ b/default-configs/arm-softmmu.mak
454
@@ -XXX,XX +XXX,XX @@ CONFIG_MPS2_FPGAIO=y
455
CONFIG_MPS2_SCC=y
456
457
CONFIG_TZ_MPC=y
458
+CONFIG_TZ_MSC=y
459
CONFIG_TZ_PPC=y
460
CONFIG_IOTKIT=y
461
CONFIG_IOTKIT_SECCTL=y
462
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
463
index XXXXXXX..XXXXXXX 100644
464
--- a/hw/misc/trace-events
465
+++ b/hw/misc/trace-events
466
@@ -XXX,XX +XXX,XX @@ tz_mpc_mem_blocked_write(uint64_t addr, uint64_t data, unsigned size, bool secur
467
tz_mpc_translate(uint64_t addr, int flags, const char *idx, const char *res) "TZ MPC translate: addr 0x%" PRIx64 " flags 0x%x iommu_idx %s: %s"
468
tz_mpc_iommu_notify(uint64_t addr) "TZ MPC iommu: notifying UNMAP/MAP for 0x%" PRIx64
469
470
+# hw/misc/tz-msc.c
471
+tz_msc_reset(void) "TZ MSC: reset"
472
+tz_msc_cfg_nonsec(int level) "TZ MSC: cfg_nonsec = %d"
473
+tz_msc_cfg_sec_resp(int level) "TZ MSC: cfg_sec_resp = %d"
474
+tz_msc_irq_enable(int level) "TZ MSC: int_enable = %d"
475
+tz_msc_irq_clear(int level) "TZ MSC: int_clear = %d"
476
+tz_msc_update_irq(int level) "TZ MSC: setting irq line to %d"
477
+tz_msc_access_blocked(uint64_t offset) "TZ MSC: offset 0x%" PRIx64 " access blocked"
478
+
479
# hw/misc/tz-ppc.c
480
tz_ppc_reset(void) "TZ PPC: reset"
481
tz_ppc_cfg_nonsec(int n, int level) "TZ PPC: cfg_nonsec[%d] = %d"
482
--
252
--
483
2.18.0
253
2.20.1
484
254
485
255
diff view generated by jsdifflib
1
The IoTKit does not have any Master Security Contollers itself,
1
From: Richard Henderson <richard.henderson@linaro.org>
2
but it does provide registers in the secure privilege control
3
block which allow control of MSCs in the external system.
4
Add support for these registers.
5
2
3
Model after gen_gvec_fn_zzz et al.
4
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Message-id: 20200815013145.539409-11-richard.henderson@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20180820141116.9118-13-peter.maydell@linaro.org
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
---
9
---
11
include/hw/misc/iotkit-secctl.h | 14 +++++++
10
target/arm/translate-sve.c | 29 ++++++++++++++---------------
12
hw/misc/iotkit-secctl.c | 73 +++++++++++++++++++++++++++++----
11
1 file changed, 14 insertions(+), 15 deletions(-)
13
2 files changed, 79 insertions(+), 8 deletions(-)
14
12
15
diff --git a/include/hw/misc/iotkit-secctl.h b/include/hw/misc/iotkit-secctl.h
13
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
16
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/misc/iotkit-secctl.h
15
--- a/target/arm/translate-sve.c
18
+++ b/include/hw/misc/iotkit-secctl.h
16
+++ b/target/arm/translate-sve.c
19
@@ -XXX,XX +XXX,XX @@
17
@@ -XXX,XX +XXX,XX @@ static int pred_gvec_reg_size(DisasContext *s)
20
* + named GPIO output "sec_resp_cfg" indicating whether blocked accesses
18
return size_for_gvec(pred_full_reg_size(s));
21
* should RAZ/WI or bus error
22
* + named GPIO output "nsc_cfg" whose value tracks the NSCCFG register value
23
+ * + named GPIO output "msc_irq" for the combined IRQ line from the MSCs
24
* Controlling the 2 APB PPCs in the IoTKit:
25
* + named GPIO outputs apb_ppc0_nonsec[0..2] and apb_ppc1_nonsec
26
* + named GPIO outputs apb_ppc0_ap[0..2] and apb_ppc1_ap
27
@@ -XXX,XX +XXX,XX @@
28
* Controlling each of the 16 expansion MPCs which a system using the IoTKit
29
* might provide:
30
* + named GPIO inputs mpcexp_status[0..15]
31
+ * Controlling each of the 16 expansion MSCs which a system using the IoTKit
32
+ * might provide:
33
+ * + named GPIO inputs mscexp_status[0..15]
34
+ * + named GPIO outputs mscexp_clear[0..15]
35
+ * + named GPIO outputs mscexp_ns[0..15]
36
*/
37
38
#ifndef IOTKIT_SECCTL_H
39
@@ -XXX,XX +XXX,XX @@
40
#define IOTS_NUM_AHB_EXP_PPC 4
41
#define IOTS_NUM_EXP_MPC 16
42
#define IOTS_NUM_MPC 1
43
+#define IOTS_NUM_EXP_MSC 16
44
45
typedef struct IoTKitSecCtl IoTKitSecCtl;
46
47
@@ -XXX,XX +XXX,XX @@ struct IoTKitSecCtl {
48
uint32_t brginten;
49
uint32_t mpcintstatus;
50
51
+ uint32_t secmscintstat;
52
+ uint32_t secmscinten;
53
+ uint32_t nsmscexp;
54
+ qemu_irq mscexp_clear[IOTS_NUM_EXP_MSC];
55
+ qemu_irq mscexp_ns[IOTS_NUM_EXP_MSC];
56
+ qemu_irq msc_irq;
57
+
58
IoTKitSecCtlPPC apb[IOTS_NUM_APB_PPC];
59
IoTKitSecCtlPPC apbexp[IOTS_NUM_APB_EXP_PPC];
60
IoTKitSecCtlPPC ahbexp[IOTS_NUM_APB_EXP_PPC];
61
diff --git a/hw/misc/iotkit-secctl.c b/hw/misc/iotkit-secctl.c
62
index XXXXXXX..XXXXXXX 100644
63
--- a/hw/misc/iotkit-secctl.c
64
+++ b/hw/misc/iotkit-secctl.c
65
@@ -XXX,XX +XXX,XX @@ static MemTxResult iotkit_secctl_s_read(void *opaque, hwaddr addr,
66
r = s->apbexp[offset_to_ppc_idx(offset)].sp;
67
break;
68
case A_SECMSCINTSTAT:
69
+ r = s->secmscintstat;
70
+ break;
71
case A_SECMSCINTEN:
72
+ r = s->secmscinten;
73
+ break;
74
case A_NSMSCEXP:
75
- qemu_log_mask(LOG_UNIMP,
76
- "IoTKit SecCtl S block read: "
77
- "unimplemented offset 0x%x\n", offset);
78
- r = 0;
79
+ r = s->nsmscexp;
80
break;
81
case A_PID4:
82
case A_PID5:
83
@@ -XXX,XX +XXX,XX @@ static void iotkit_secctl_ppc_update_irq_enable(IoTKitSecCtlPPC *ppc)
84
qemu_set_irq(ppc->irq_enable, extract32(value, ppc->irq_bit_offset, 1));
85
}
19
}
86
20
87
+static void iotkit_secctl_update_mscexp_irqs(qemu_irq *msc_irqs, uint32_t value)
21
+/* Invoke an out-of-line helper on 2 Zregs and a predicate. */
22
+static void gen_gvec_ool_zzp(DisasContext *s, gen_helper_gvec_3 *fn,
23
+ int rd, int rn, int pg, int data)
88
+{
24
+{
89
+ int i;
25
+ unsigned vsz = vec_full_reg_size(s);
90
+
26
+ tcg_gen_gvec_3_ool(vec_full_reg_offset(s, rd),
91
+ for (i = 0; i < IOTS_NUM_EXP_MSC; i++) {
27
+ vec_full_reg_offset(s, rn),
92
+ qemu_set_irq(msc_irqs[i], extract32(value, i + 16, 1));
28
+ pred_full_reg_offset(s, pg),
93
+ }
29
+ vsz, vsz, data, fn);
94
+}
30
+}
95
+
31
+
96
+static void iotkit_secctl_update_msc_irq(IoTKitSecCtl *s)
32
/* Invoke an out-of-line helper on 3 Zregs and a predicate. */
97
+{
33
static void gen_gvec_ool_zzzp(DisasContext *s, gen_helper_gvec_4 *fn,
98
+ /* Update the combined MSC IRQ, based on S_MSCEXP_STATUS and S_MSCEXP_EN */
34
int rd, int rn, int rm, int pg, int data)
99
+ bool level = s->secmscintstat & s->secmscinten;
35
@@ -XXX,XX +XXX,XX @@ static bool do_zpz_ool(DisasContext *s, arg_rpr_esz *a, gen_helper_gvec_3 *fn)
100
+
36
return false;
101
+ qemu_set_irq(s->msc_irq, level);
37
}
102
+}
38
if (sve_access_check(s)) {
103
+
39
- unsigned vsz = vec_full_reg_size(s);
104
static MemTxResult iotkit_secctl_s_write(void *opaque, hwaddr addr,
40
- tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd),
105
uint64_t value,
41
- vec_full_reg_offset(s, a->rn),
106
unsigned size, MemTxAttrs attrs)
42
- pred_full_reg_offset(s, a->pg),
107
@@ -XXX,XX +XXX,XX @@ static MemTxResult iotkit_secctl_s_write(void *opaque, hwaddr addr,
43
- vsz, vsz, 0, fn);
108
iotkit_secctl_ppc_sp_write(ppc, value);
44
+ gen_gvec_ool_zzp(s, fn, a->rd, a->rn, a->pg, 0);
109
break;
45
}
110
case A_SECMSCINTCLR:
46
return true;
111
+ iotkit_secctl_update_mscexp_irqs(s->mscexp_clear, value);
112
+ break;
113
case A_SECMSCINTEN:
114
- qemu_log_mask(LOG_UNIMP,
115
- "IoTKit SecCtl S block write: "
116
- "unimplemented offset 0x%x\n", offset);
117
+ s->secmscinten = value;
118
+ iotkit_secctl_update_msc_irq(s);
119
+ break;
120
+ case A_NSMSCEXP:
121
+ s->nsmscexp = value;
122
+ iotkit_secctl_update_mscexp_irqs(s->mscexp_ns, value);
123
break;
124
case A_SECMPCINTSTATUS:
125
case A_SECPPCINTSTAT:
126
@@ -XXX,XX +XXX,XX @@ static MemTxResult iotkit_secctl_s_write(void *opaque, hwaddr addr,
127
case A_BRGINTSTAT:
128
case A_AHBNSPPC0:
129
case A_AHBSPPPC0:
130
- case A_NSMSCEXP:
131
case A_PID4:
132
case A_PID5:
133
case A_PID6:
134
@@ -XXX,XX +XXX,XX @@ static void iotkit_secctl_mpcexp_status(void *opaque, int n, int level)
135
s->mpcintstatus = deposit32(s->mpcintstatus, n + 16, 1, !!level);
136
}
47
}
137
48
@@ -XXX,XX +XXX,XX @@ static bool do_movz_zpz(DisasContext *s, int rd, int rn, int pg,
138
+static void iotkit_secctl_mscexp_status(void *opaque, int n, int level)
49
};
139
+{
50
140
+ IoTKitSecCtl *s = IOTKIT_SECCTL(opaque);
51
if (sve_access_check(s)) {
141
+
52
- unsigned vsz = vec_full_reg_size(s);
142
+ s->secmscintstat = deposit32(s->secmscintstat, n + 16, 1, !!level);
53
- tcg_gen_gvec_3_ool(vec_full_reg_offset(s, rd),
143
+ iotkit_secctl_update_msc_irq(s);
54
- vec_full_reg_offset(s, rn),
144
+}
55
- pred_full_reg_offset(s, pg),
145
+
56
- vsz, vsz, invert, fns[esz]);
146
static void iotkit_secctl_ppc_irqstatus(void *opaque, int n, int level)
57
+ gen_gvec_ool_zzp(s, fns[esz], rd, rn, pg, invert);
58
}
59
return true;
60
}
61
@@ -XXX,XX +XXX,XX @@ static bool do_zpzi_ool(DisasContext *s, arg_rpri_esz *a,
62
gen_helper_gvec_3 *fn)
147
{
63
{
148
IoTKitSecCtlPPC *ppc = opaque;
64
if (sve_access_check(s)) {
149
@@ -XXX,XX +XXX,XX @@ static void iotkit_secctl_init(Object *obj)
65
- unsigned vsz = vec_full_reg_size(s);
150
qdev_init_gpio_in_named(dev, iotkit_secctl_mpcexp_status,
66
- tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd),
151
"mpcexp_status", IOTS_NUM_EXP_MPC);
67
- vec_full_reg_offset(s, a->rn),
152
68
- pred_full_reg_offset(s, a->pg),
153
+ qdev_init_gpio_in_named(dev, iotkit_secctl_mscexp_status,
69
- vsz, vsz, a->imm, fn);
154
+ "mscexp_status", IOTS_NUM_EXP_MSC);
70
+ gen_gvec_ool_zzp(s, fn, a->rd, a->rn, a->pg, a->imm);
155
+ qdev_init_gpio_out_named(dev, s->mscexp_clear, "mscexp_clear",
156
+ IOTS_NUM_EXP_MSC);
157
+ qdev_init_gpio_out_named(dev, s->mscexp_ns, "mscexp_ns",
158
+ IOTS_NUM_EXP_MSC);
159
+ qdev_init_gpio_out_named(dev, &s->msc_irq, "msc_irq", 1);
160
+
161
memory_region_init_io(&s->s_regs, obj, &iotkit_secctl_s_ops,
162
s, "iotkit-secctl-s-regs", 0x1000);
163
memory_region_init_io(&s->ns_regs, obj, &iotkit_secctl_ns_ops,
164
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription iotkit_secctl_mpcintstatus_vmstate = {
165
}
71
}
166
};
72
return true;
167
73
}
168
+static bool needed_always(void *opaque)
169
+{
170
+ return true;
171
+}
172
+
173
+static const VMStateDescription iotkit_secctl_msc_vmstate = {
174
+ .name = "iotkit-secctl/msc",
175
+ .version_id = 1,
176
+ .minimum_version_id = 1,
177
+ .needed = needed_always,
178
+ .fields = (VMStateField[]) {
179
+ VMSTATE_UINT32(secmscintstat, IoTKitSecCtl),
180
+ VMSTATE_UINT32(secmscinten, IoTKitSecCtl),
181
+ VMSTATE_UINT32(nsmscexp, IoTKitSecCtl),
182
+ VMSTATE_END_OF_LIST()
183
+ }
184
+};
185
+
186
static const VMStateDescription iotkit_secctl_vmstate = {
187
.name = "iotkit-secctl",
188
.version_id = 1,
189
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription iotkit_secctl_vmstate = {
190
},
191
.subsections = (const VMStateDescription*[]) {
192
&iotkit_secctl_mpcintstatus_vmstate,
193
+ &iotkit_secctl_msc_vmstate,
194
NULL
195
},
196
};
197
--
74
--
198
2.18.0
75
2.20.1
199
76
200
77
diff view generated by jsdifflib
1
In the MPS2 FPGAIO, PSCNTR is a free-running downcounter with
1
From: Richard Henderson <richard.henderson@linaro.org>
2
a reload value configured via the PRESCALE register, and
3
COUNTER counts up by 1 every time PSCNTR reaches zero.
4
Implement these counters.
5
2
6
We can just increment the counters migration subsection's
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
version ID because we only added it in the previous commit,
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
so no released QEMU versions will be using it.
5
Message-id: 20200815013145.539409-12-richard.henderson@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
target/arm/translate-sve.c | 53 +++++++++++++-------------------------
9
1 file changed, 18 insertions(+), 35 deletions(-)
9
10
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
11
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Message-id: 20180820141116.9118-3-peter.maydell@linaro.org
14
---
15
include/hw/misc/mps2-fpgaio.h | 6 +++
16
hw/misc/mps2-fpgaio.c | 97 +++++++++++++++++++++++++++++++++--
17
2 files changed, 99 insertions(+), 4 deletions(-)
18
19
diff --git a/include/hw/misc/mps2-fpgaio.h b/include/hw/misc/mps2-fpgaio.h
20
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
21
--- a/include/hw/misc/mps2-fpgaio.h
13
--- a/target/arm/translate-sve.c
22
+++ b/include/hw/misc/mps2-fpgaio.h
14
+++ b/target/arm/translate-sve.c
23
@@ -XXX,XX +XXX,XX @@ typedef struct {
15
@@ -XXX,XX +XXX,XX @@ static int pred_gvec_reg_size(DisasContext *s)
24
uint32_t prescale;
16
return size_for_gvec(pred_full_reg_size(s));
25
uint32_t misc;
26
27
+ /* QEMU_CLOCK_VIRTUAL time at which counter and pscntr were last synced */
28
+ int64_t pscntr_sync_ticks;
29
+ /* Values of COUNTER and PSCNTR at time pscntr_sync_ticks */
30
+ uint32_t counter;
31
+ uint32_t pscntr;
32
+
33
uint32_t prescale_clk;
34
35
/* These hold the CLOCK_VIRTUAL ns tick when the CLK1HZ/CLK100HZ was zero */
36
diff --git a/hw/misc/mps2-fpgaio.c b/hw/misc/mps2-fpgaio.c
37
index XXXXXXX..XXXXXXX 100644
38
--- a/hw/misc/mps2-fpgaio.c
39
+++ b/hw/misc/mps2-fpgaio.c
40
@@ -XXX,XX +XXX,XX @@ static int64_t tickoff_from_counter(int64_t now, uint32_t count, int frq)
41
return now - muldiv64(count, NANOSECONDS_PER_SECOND, frq);
42
}
17
}
43
18
44
+static void resync_counter(MPS2FPGAIO *s)
19
+/* Invoke an out-of-line helper on 3 Zregs. */
20
+static void gen_gvec_ool_zzz(DisasContext *s, gen_helper_gvec_3 *fn,
21
+ int rd, int rn, int rm, int data)
45
+{
22
+{
46
+ /*
23
+ unsigned vsz = vec_full_reg_size(s);
47
+ * Update s->counter and s->pscntr to their true current values
24
+ tcg_gen_gvec_3_ool(vec_full_reg_offset(s, rd),
48
+ * by calculating how many times PSCNTR has ticked since the
25
+ vec_full_reg_offset(s, rn),
49
+ * last time we did a resync.
26
+ vec_full_reg_offset(s, rm),
50
+ */
27
+ vsz, vsz, data, fn);
51
+ int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
52
+ int64_t elapsed = now - s->pscntr_sync_ticks;
53
+
54
+ /*
55
+ * Round elapsed down to a whole number of PSCNTR ticks, so we don't
56
+ * lose time if we do multiple resyncs in a single tick.
57
+ */
58
+ uint64_t ticks = muldiv64(elapsed, s->prescale_clk, NANOSECONDS_PER_SECOND);
59
+
60
+ /*
61
+ * Work out what PSCNTR and COUNTER have moved to. We assume that
62
+ * PSCNTR reloads from PRESCALE one tick-period after it hits zero,
63
+ * and that COUNTER increments at the same moment.
64
+ */
65
+ if (ticks == 0) {
66
+ /* We haven't ticked since the last time we were asked */
67
+ return;
68
+ } else if (ticks < s->pscntr) {
69
+ /* We haven't yet reached zero, just reduce the PSCNTR */
70
+ s->pscntr -= ticks;
71
+ } else {
72
+ if (s->prescale == 0) {
73
+ /*
74
+ * If the reload value is zero then the PSCNTR will stick
75
+ * at zero once it reaches it, and so we will increment
76
+ * COUNTER every tick after that.
77
+ */
78
+ s->counter += ticks - s->pscntr;
79
+ s->pscntr = 0;
80
+ } else {
81
+ /*
82
+ * This is the complicated bit. This ASCII art diagram gives an
83
+ * example with PRESCALE==5 PSCNTR==7:
84
+ *
85
+ * ticks 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
86
+ * PSCNTR 7 6 5 4 3 2 1 0 5 4 3 2 1 0 5
87
+ * cinc 1 2
88
+ * y 0 1 2 3 4 5 6 7 8 9 10 11 12
89
+ * x 0 1 2 3 4 5 0 1 2 3 4 5 0
90
+ *
91
+ * where x = y % (s->prescale + 1)
92
+ * and so PSCNTR = s->prescale - x
93
+ * and COUNTER is incremented by y / (s->prescale + 1)
94
+ *
95
+ * The case where PSCNTR < PRESCALE works out the same,
96
+ * though we must be careful to calculate y as 64-bit unsigned
97
+ * for all parts of the expression.
98
+ * y < 0 is not possible because that implies ticks < s->pscntr.
99
+ */
100
+ uint64_t y = ticks - s->pscntr + s->prescale;
101
+ s->pscntr = s->prescale - (y % (s->prescale + 1));
102
+ s->counter += y / (s->prescale + 1);
103
+ }
104
+ }
105
+
106
+ /*
107
+ * Only advance the sync time to the timestamp of the last PSCNTR tick,
108
+ * not all the way to 'now', so we don't lose time if we do multiple
109
+ * resyncs in a single tick.
110
+ */
111
+ s->pscntr_sync_ticks += muldiv64(ticks, NANOSECONDS_PER_SECOND,
112
+ s->prescale_clk);
113
+}
28
+}
114
+
29
+
115
static uint64_t mps2_fpgaio_read(void *opaque, hwaddr offset, unsigned size)
30
/* Invoke an out-of-line helper on 2 Zregs and a predicate. */
31
static void gen_gvec_ool_zzp(DisasContext *s, gen_helper_gvec_3 *fn,
32
int rd, int rn, int pg, int data)
33
@@ -XXX,XX +XXX,XX @@ static bool do_zzw_ool(DisasContext *s, arg_rrr_esz *a, gen_helper_gvec_3 *fn)
34
return false;
35
}
36
if (sve_access_check(s)) {
37
- unsigned vsz = vec_full_reg_size(s);
38
- tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd),
39
- vec_full_reg_offset(s, a->rn),
40
- vec_full_reg_offset(s, a->rm),
41
- vsz, vsz, 0, fn);
42
+ gen_gvec_ool_zzz(s, fn, a->rd, a->rn, a->rm, 0);
43
}
44
return true;
45
}
46
@@ -XXX,XX +XXX,XX @@ static bool trans_RDVL(DisasContext *s, arg_RDVL *a)
47
static bool do_adr(DisasContext *s, arg_rrri *a, gen_helper_gvec_3 *fn)
116
{
48
{
117
MPS2FPGAIO *s = MPS2_FPGAIO(opaque);
49
if (sve_access_check(s)) {
118
@@ -XXX,XX +XXX,XX @@ static uint64_t mps2_fpgaio_read(void *opaque, hwaddr offset, unsigned size)
50
- unsigned vsz = vec_full_reg_size(s);
119
r = counter_from_tickoff(now, s->clk100hz_tick_offset, 100);
51
- tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd),
120
break;
52
- vec_full_reg_offset(s, a->rn),
121
case A_COUNTER:
53
- vec_full_reg_offset(s, a->rm),
122
+ resync_counter(s);
54
- vsz, vsz, a->imm, fn);
123
+ r = s->counter;
55
+ gen_gvec_ool_zzz(s, fn, a->rd, a->rn, a->rm, a->imm);
124
+ break;
56
}
125
case A_PSCNTR:
57
return true;
126
- qemu_log_mask(LOG_UNIMP, "MPS2 FPGAIO: counters unimplemented\n");
127
- r = 0;
128
+ resync_counter(s);
129
+ r = s->pscntr;
130
break;
131
default:
132
qemu_log_mask(LOG_GUEST_ERROR,
133
@@ -XXX,XX +XXX,XX @@ static void mps2_fpgaio_write(void *opaque, hwaddr offset, uint64_t value,
134
s->led0 = value & 0x3;
135
break;
136
case A_PRESCALE:
137
+ resync_counter(s);
138
s->prescale = value;
139
break;
140
case A_MISC:
141
@@ -XXX,XX +XXX,XX @@ static void mps2_fpgaio_write(void *opaque, hwaddr offset, uint64_t value,
142
now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
143
s->clk100hz_tick_offset = tickoff_from_counter(now, value, 100);
144
break;
145
+ case A_COUNTER:
146
+ resync_counter(s);
147
+ s->counter = value;
148
+ break;
149
+ case A_PSCNTR:
150
+ resync_counter(s);
151
+ s->pscntr = value;
152
+ break;
153
default:
154
qemu_log_mask(LOG_GUEST_ERROR,
155
"MPS2 FPGAIO write: bad offset 0x%x\n", (int) offset);
156
@@ -XXX,XX +XXX,XX @@ static void mps2_fpgaio_reset(DeviceState *dev)
157
s->misc = 0;
158
s->clk1hz_tick_offset = tickoff_from_counter(now, 0, 1);
159
s->clk100hz_tick_offset = tickoff_from_counter(now, 0, 100);
160
+ s->counter = 0;
161
+ s->pscntr = 0;
162
+ s->pscntr_sync_ticks = now;
163
}
58
}
164
59
@@ -XXX,XX +XXX,XX @@ static bool trans_FTSSEL(DisasContext *s, arg_rrr_esz *a)
165
static void mps2_fpgaio_init(Object *obj)
60
return false;
166
@@ -XXX,XX +XXX,XX @@ static bool mps2_fpgaio_counters_needed(void *opaque)
167
168
static const VMStateDescription mps2_fpgaio_counters_vmstate = {
169
.name = "mps2-fpgaio/counters",
170
- .version_id = 1,
171
- .minimum_version_id = 1,
172
+ .version_id = 2,
173
+ .minimum_version_id = 2,
174
.needed = mps2_fpgaio_counters_needed,
175
.fields = (VMStateField[]) {
176
VMSTATE_INT64(clk1hz_tick_offset, MPS2FPGAIO),
177
VMSTATE_INT64(clk100hz_tick_offset, MPS2FPGAIO),
178
+ VMSTATE_UINT32(counter, MPS2FPGAIO),
179
+ VMSTATE_UINT32(pscntr, MPS2FPGAIO),
180
+ VMSTATE_INT64(pscntr_sync_ticks, MPS2FPGAIO),
181
VMSTATE_END_OF_LIST()
182
}
61
}
183
};
62
if (sve_access_check(s)) {
63
- unsigned vsz = vec_full_reg_size(s);
64
- tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd),
65
- vec_full_reg_offset(s, a->rn),
66
- vec_full_reg_offset(s, a->rm),
67
- vsz, vsz, 0, fns[a->esz]);
68
+ gen_gvec_ool_zzz(s, fns[a->esz], a->rd, a->rn, a->rm, 0);
69
}
70
return true;
71
}
72
@@ -XXX,XX +XXX,XX @@ static bool trans_TBL(DisasContext *s, arg_rrr_esz *a)
73
};
74
75
if (sve_access_check(s)) {
76
- unsigned vsz = vec_full_reg_size(s);
77
- tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd),
78
- vec_full_reg_offset(s, a->rn),
79
- vec_full_reg_offset(s, a->rm),
80
- vsz, vsz, 0, fns[a->esz]);
81
+ gen_gvec_ool_zzz(s, fns[a->esz], a->rd, a->rn, a->rm, 0);
82
}
83
return true;
84
}
85
@@ -XXX,XX +XXX,XX @@ static bool do_zzz_data_ool(DisasContext *s, arg_rrr_esz *a, int data,
86
gen_helper_gvec_3 *fn)
87
{
88
if (sve_access_check(s)) {
89
- unsigned vsz = vec_full_reg_size(s);
90
- tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd),
91
- vec_full_reg_offset(s, a->rn),
92
- vec_full_reg_offset(s, a->rm),
93
- vsz, vsz, data, fn);
94
+ gen_gvec_ool_zzz(s, fn, a->rd, a->rn, a->rm, data);
95
}
96
return true;
97
}
98
@@ -XXX,XX +XXX,XX @@ static bool trans_DOT_zzz(DisasContext *s, arg_DOT_zzz *a)
99
};
100
101
if (sve_access_check(s)) {
102
- unsigned vsz = vec_full_reg_size(s);
103
- tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd),
104
- vec_full_reg_offset(s, a->rn),
105
- vec_full_reg_offset(s, a->rm),
106
- vsz, vsz, 0, fns[a->u][a->sz]);
107
+ gen_gvec_ool_zzz(s, fns[a->u][a->sz], a->rd, a->rn, a->rm, 0);
108
}
109
return true;
110
}
111
@@ -XXX,XX +XXX,XX @@ static bool trans_DOT_zzx(DisasContext *s, arg_DOT_zzx *a)
112
};
113
114
if (sve_access_check(s)) {
115
- unsigned vsz = vec_full_reg_size(s);
116
- tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd),
117
- vec_full_reg_offset(s, a->rn),
118
- vec_full_reg_offset(s, a->rm),
119
- vsz, vsz, a->index, fns[a->u][a->sz]);
120
+ gen_gvec_ool_zzz(s, fns[a->u][a->sz], a->rd, a->rn, a->rm, a->index);
121
}
122
return true;
123
}
184
--
124
--
185
2.18.0
125
2.20.1
186
126
187
127
diff view generated by jsdifflib
1
Add a "virtualization" property to the vexpress-a15 board,
1
From: Richard Henderson <richard.henderson@linaro.org>
2
controlling presence of EL2. As with EL3, we default to
3
enabling it, but the user can disable it if they have an
4
older guest which can't cope with it being present.
5
2
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Message-id: 20200815013145.539409-13-richard.henderson@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
8
Message-id: 20180821132811.17675-10-peter.maydell@linaro.org
9
---
7
---
10
hw/arm/vexpress.c | 56 ++++++++++++++++++++++++++++++++++++++++++++---
8
target/arm/translate-sve.c | 20 ++++++++++++--------
11
1 file changed, 53 insertions(+), 3 deletions(-)
9
1 file changed, 12 insertions(+), 8 deletions(-)
12
10
13
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
11
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
14
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/arm/vexpress.c
13
--- a/target/arm/translate-sve.c
16
+++ b/hw/arm/vexpress.c
14
+++ b/target/arm/translate-sve.c
17
@@ -XXX,XX +XXX,XX @@ typedef struct {
15
@@ -XXX,XX +XXX,XX @@ static int pred_gvec_reg_size(DisasContext *s)
18
typedef struct {
16
return size_for_gvec(pred_full_reg_size(s));
19
MachineState parent;
20
bool secure;
21
+ bool virt;
22
} VexpressMachineState;
23
24
#define TYPE_VEXPRESS_MACHINE "vexpress"
25
@@ -XXX,XX +XXX,XX @@ struct VEDBoardInfo {
26
};
27
28
static void init_cpus(const char *cpu_type, const char *privdev,
29
- hwaddr periphbase, qemu_irq *pic, bool secure)
30
+ hwaddr periphbase, qemu_irq *pic, bool secure, bool virt)
31
{
32
DeviceState *dev;
33
SysBusDevice *busdev;
34
@@ -XXX,XX +XXX,XX @@ static void init_cpus(const char *cpu_type, const char *privdev,
35
if (!secure) {
36
object_property_set_bool(cpuobj, false, "has_el3", NULL);
37
}
38
+ if (!virt) {
39
+ if (object_property_find(cpuobj, "has_el2", NULL)) {
40
+ object_property_set_bool(cpuobj, false, "has_el2", NULL);
41
+ }
42
+ }
43
44
if (object_property_find(cpuobj, "reset-cbar", NULL)) {
45
object_property_set_int(cpuobj, periphbase,
46
@@ -XXX,XX +XXX,XX @@ static void a9_daughterboard_init(const VexpressMachineState *vms,
47
memory_region_add_subregion(sysmem, 0x60000000, ram);
48
49
/* 0x1e000000 A9MPCore (SCU) private memory region */
50
- init_cpus(cpu_type, TYPE_A9MPCORE_PRIV, 0x1e000000, pic, vms->secure);
51
+ init_cpus(cpu_type, TYPE_A9MPCORE_PRIV, 0x1e000000, pic,
52
+ vms->secure, vms->virt);
53
54
/* Daughterboard peripherals : 0x10020000 .. 0x20000000 */
55
56
@@ -XXX,XX +XXX,XX @@ static void a15_daughterboard_init(const VexpressMachineState *vms,
57
memory_region_add_subregion(sysmem, 0x80000000, ram);
58
59
/* 0x2c000000 A15MPCore private memory region (GIC) */
60
- init_cpus(cpu_type, TYPE_A15MPCORE_PRIV, 0x2c000000, pic, vms->secure);
61
+ init_cpus(cpu_type, TYPE_A15MPCORE_PRIV, 0x2c000000, pic, vms->secure,
62
+ vms->virt);
63
64
/* A15 daughterboard peripherals: */
65
66
@@ -XXX,XX +XXX,XX @@ static void vexpress_set_secure(Object *obj, bool value, Error **errp)
67
vms->secure = value;
68
}
17
}
69
18
70
+static bool vexpress_get_virt(Object *obj, Error **errp)
19
+/* Invoke an out-of-line helper on 2 Zregs. */
20
+static void gen_gvec_ool_zz(DisasContext *s, gen_helper_gvec_2 *fn,
21
+ int rd, int rn, int data)
71
+{
22
+{
72
+ VexpressMachineState *vms = VEXPRESS_MACHINE(obj);
23
+ unsigned vsz = vec_full_reg_size(s);
73
+
24
+ tcg_gen_gvec_2_ool(vec_full_reg_offset(s, rd),
74
+ return vms->virt;
25
+ vec_full_reg_offset(s, rn),
26
+ vsz, vsz, data, fn);
75
+}
27
+}
76
+
28
+
77
+static void vexpress_set_virt(Object *obj, bool value, Error **errp)
29
/* Invoke an out-of-line helper on 3 Zregs. */
78
+{
30
static void gen_gvec_ool_zzz(DisasContext *s, gen_helper_gvec_3 *fn,
79
+ VexpressMachineState *vms = VEXPRESS_MACHINE(obj);
31
int rd, int rn, int rm, int data)
80
+
32
@@ -XXX,XX +XXX,XX @@ static bool trans_FEXPA(DisasContext *s, arg_rr_esz *a)
81
+ vms->virt = value;
33
return false;
82
+}
34
}
83
+
35
if (sve_access_check(s)) {
84
static void vexpress_instance_init(Object *obj)
36
- unsigned vsz = vec_full_reg_size(s);
85
{
37
- tcg_gen_gvec_2_ool(vec_full_reg_offset(s, a->rd),
86
VexpressMachineState *vms = VEXPRESS_MACHINE(obj);
38
- vec_full_reg_offset(s, a->rn),
87
@@ -XXX,XX +XXX,XX @@ static void vexpress_instance_init(Object *obj)
39
- vsz, vsz, 0, fns[a->esz]);
88
NULL);
40
+ gen_gvec_ool_zz(s, fns[a->esz], a->rd, a->rn, 0);
41
}
42
return true;
89
}
43
}
90
44
@@ -XXX,XX +XXX,XX @@ static bool trans_REV_v(DisasContext *s, arg_rr_esz *a)
91
+static void vexpress_a15_instance_init(Object *obj)
45
};
92
+{
46
93
+ VexpressMachineState *vms = VEXPRESS_MACHINE(obj);
47
if (sve_access_check(s)) {
94
+
48
- unsigned vsz = vec_full_reg_size(s);
95
+ /*
49
- tcg_gen_gvec_2_ool(vec_full_reg_offset(s, a->rd),
96
+ * For the vexpress-a15, EL2 is by default enabled if EL3 is,
50
- vec_full_reg_offset(s, a->rn),
97
+ * but can also be specifically set to on or off.
51
- vsz, vsz, 0, fns[a->esz]);
98
+ */
52
+ gen_gvec_ool_zz(s, fns[a->esz], a->rd, a->rn, 0);
99
+ vms->virt = true;
53
}
100
+ object_property_add_bool(obj, "virtualization", vexpress_get_virt,
54
return true;
101
+ vexpress_set_virt, NULL);
55
}
102
+ object_property_set_description(obj, "virtualization",
103
+ "Set on/off to enable/disable the ARM "
104
+ "Virtualization Extensions "
105
+ "(defaults to same as 'secure')",
106
+ NULL);
107
+}
108
+
109
+static void vexpress_a9_instance_init(Object *obj)
110
+{
111
+ VexpressMachineState *vms = VEXPRESS_MACHINE(obj);
112
+
113
+ /* The A9 doesn't have the virt extensions */
114
+ vms->virt = false;
115
+}
116
+
117
static void vexpress_class_init(ObjectClass *oc, void *data)
118
{
119
MachineClass *mc = MACHINE_CLASS(oc);
120
@@ -XXX,XX +XXX,XX @@ static const TypeInfo vexpress_a9_info = {
121
.name = TYPE_VEXPRESS_A9_MACHINE,
122
.parent = TYPE_VEXPRESS_MACHINE,
123
.class_init = vexpress_a9_class_init,
124
+ .instance_init = vexpress_a9_instance_init,
125
};
126
127
static const TypeInfo vexpress_a15_info = {
128
.name = TYPE_VEXPRESS_A15_MACHINE,
129
.parent = TYPE_VEXPRESS_MACHINE,
130
.class_init = vexpress_a15_class_init,
131
+ .instance_init = vexpress_a15_instance_init,
132
};
133
134
static void vexpress_machine_init(void)
135
--
56
--
136
2.18.0
57
2.20.1
137
58
138
59
diff view generated by jsdifflib
1
In the PL022, register offset 0x20 is the ICR, a write-only
1
From: Richard Henderson <richard.henderson@linaro.org>
2
interrupt-clear register. Register offset 0x24 is DMACR, the DMA
3
control register. We were incorrectly implementing (a stub version
4
of) DMACR at 0x20, and not implementing anything at 0x24. Fix this
5
bug.
6
2
3
Rather than require the user to fill in the immediate (shl or shr),
4
create full formats that include the immediate.
5
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20200815013145.539409-14-richard.henderson@linaro.org
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20180820141116.9118-21-peter.maydell@linaro.org
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
---
10
---
11
hw/ssi/pl022.c | 12 ++++++++++--
11
target/arm/sve.decode | 35 ++++++++++++++++-------------------
12
1 file changed, 10 insertions(+), 2 deletions(-)
12
1 file changed, 16 insertions(+), 19 deletions(-)
13
13
14
diff --git a/hw/ssi/pl022.c b/hw/ssi/pl022.c
14
diff --git a/target/arm/sve.decode b/target/arm/sve.decode
15
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/ssi/pl022.c
16
--- a/target/arm/sve.decode
17
+++ b/hw/ssi/pl022.c
17
+++ b/target/arm/sve.decode
18
@@ -XXX,XX +XXX,XX @@ static uint64_t pl022_read(void *opaque, hwaddr offset,
18
@@ -XXX,XX +XXX,XX @@
19
return s->is;
19
@rd_rn_i6 ........ ... rn:5 ..... imm:s6 rd:5 &rri
20
case 0x1c: /* MIS */
20
21
return s->im & s->is;
21
# Two register operand, one immediate operand, with predicate,
22
- case 0x20: /* DMACR */
22
-# element size encoded as TSZHL. User must fill in imm.
23
+ case 0x24: /* DMACR */
23
-@rdn_pg_tszimm ........ .. ... ... ... pg:3 ..... rd:5 \
24
/* Not implemented. */
24
- &rpri_esz rn=%reg_movprfx esz=%tszimm_esz
25
return 0;
25
+# element size encoded as TSZHL.
26
default:
26
+@rdn_pg_tszimm_shl ........ .. ... ... ... pg:3 ..... rd:5 \
27
@@ -XXX,XX +XXX,XX @@ static void pl022_write(void *opaque, hwaddr offset,
27
+ &rpri_esz rn=%reg_movprfx esz=%tszimm_esz imm=%tszimm_shl
28
s->im = value;
28
+@rdn_pg_tszimm_shr ........ .. ... ... ... pg:3 ..... rd:5 \
29
pl022_update(s);
29
+ &rpri_esz rn=%reg_movprfx esz=%tszimm_esz imm=%tszimm_shr
30
break;
30
31
- case 0x20: /* DMACR */
31
# Similarly without predicate.
32
+ case 0x20: /* ICR */
32
-@rd_rn_tszimm ........ .. ... ... ...... rn:5 rd:5 \
33
+ /*
33
- &rri_esz esz=%tszimm16_esz
34
+ * write-1-to-clear: bit 0 clears ROR, bit 1 clears RT;
34
+@rd_rn_tszimm_shl ........ .. ... ... ...... rn:5 rd:5 \
35
+ * RX and TX interrupts cannot be cleared this way.
35
+ &rri_esz esz=%tszimm16_esz imm=%tszimm16_shl
36
+ */
36
+@rd_rn_tszimm_shr ........ .. ... ... ...... rn:5 rd:5 \
37
+ value &= PL022_INT_ROR | PL022_INT_RT;
37
+ &rri_esz esz=%tszimm16_esz imm=%tszimm16_shr
38
+ s->is &= ~value;
38
39
+ break;
39
# Two register operand, one immediate operand, with 4-bit predicate.
40
+ case 0x24: /* DMACR */
40
# User must fill in imm.
41
if (value) {
41
@@ -XXX,XX +XXX,XX @@ UMINV 00000100 .. 001 011 001 ... ..... ..... @rd_pg_rn
42
qemu_log_mask(LOG_UNIMP, "pl022: DMA not implemented\n");
42
### SVE Shift by Immediate - Predicated Group
43
}
43
44
# SVE bitwise shift by immediate (predicated)
45
-ASR_zpzi 00000100 .. 000 000 100 ... .. ... ..... \
46
- @rdn_pg_tszimm imm=%tszimm_shr
47
-LSR_zpzi 00000100 .. 000 001 100 ... .. ... ..... \
48
- @rdn_pg_tszimm imm=%tszimm_shr
49
-LSL_zpzi 00000100 .. 000 011 100 ... .. ... ..... \
50
- @rdn_pg_tszimm imm=%tszimm_shl
51
-ASRD 00000100 .. 000 100 100 ... .. ... ..... \
52
- @rdn_pg_tszimm imm=%tszimm_shr
53
+ASR_zpzi 00000100 .. 000 000 100 ... .. ... ..... @rdn_pg_tszimm_shr
54
+LSR_zpzi 00000100 .. 000 001 100 ... .. ... ..... @rdn_pg_tszimm_shr
55
+LSL_zpzi 00000100 .. 000 011 100 ... .. ... ..... @rdn_pg_tszimm_shl
56
+ASRD 00000100 .. 000 100 100 ... .. ... ..... @rdn_pg_tszimm_shr
57
58
# SVE bitwise shift by vector (predicated)
59
ASR_zpzz 00000100 .. 010 000 100 ... ..... ..... @rdn_pg_rm
60
@@ -XXX,XX +XXX,XX @@ RDVL 00000100 101 11111 01010 imm:s6 rd:5
61
### SVE Bitwise Shift - Unpredicated Group
62
63
# SVE bitwise shift by immediate (unpredicated)
64
-ASR_zzi 00000100 .. 1 ..... 1001 00 ..... ..... \
65
- @rd_rn_tszimm imm=%tszimm16_shr
66
-LSR_zzi 00000100 .. 1 ..... 1001 01 ..... ..... \
67
- @rd_rn_tszimm imm=%tszimm16_shr
68
-LSL_zzi 00000100 .. 1 ..... 1001 11 ..... ..... \
69
- @rd_rn_tszimm imm=%tszimm16_shl
70
+ASR_zzi 00000100 .. 1 ..... 1001 00 ..... ..... @rd_rn_tszimm_shr
71
+LSR_zzi 00000100 .. 1 ..... 1001 01 ..... ..... @rd_rn_tszimm_shr
72
+LSL_zzi 00000100 .. 1 ..... 1001 11 ..... ..... @rd_rn_tszimm_shl
73
74
# SVE bitwise shift by wide elements (unpredicated)
75
# Note esz != 3
44
--
76
--
45
2.18.0
77
2.20.1
46
78
47
79
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Unify add/sub helpers and add a parameter for rounding.
4
This will allow saturating non-rounding to reuse this code.
5
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Message-id: 20180814002653.12828-4-richard.henderson@linaro.org
7
[PMM: fixed accidental use of '=' rather than '+=' in do_sqrdmlah_s]
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20200815013145.539409-15-richard.henderson@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
11
---
8
target/arm/helper.c | 29 +++++------------------------
12
target/arm/vec_helper.c | 80 +++++++++++++++--------------------------
9
1 file changed, 5 insertions(+), 24 deletions(-)
13
1 file changed, 29 insertions(+), 51 deletions(-)
10
14
11
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c
12
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/helper.c
17
--- a/target/arm/vec_helper.c
14
+++ b/target/arm/helper.c
18
+++ b/target/arm/vec_helper.c
15
@@ -XXX,XX +XXX,XX @@ float32 VFP_HELPER(fcvts, d)(float64 x, CPUARMState *env)
19
@@ -XXX,XX +XXX,XX @@
16
#define VFP_CONV_FIX_FLOAT(name, p, fsz, isz, itype) \
20
#endif
17
float##fsz HELPER(vfp_##name##to##p)(uint##isz##_t x, uint32_t shift, \
21
18
void *fpstp) \
22
/* Signed saturating rounding doubling multiply-accumulate high half, 16-bit */
19
-{ \
23
-static int16_t inl_qrdmlah_s16(int16_t src1, int16_t src2,
20
- float_status *fpst = fpstp; \
24
- int16_t src3, uint32_t *sat)
21
- float##fsz tmp; \
25
+static int16_t do_sqrdmlah_h(int16_t src1, int16_t src2, int16_t src3,
22
- tmp = itype##_to_##float##fsz(x, fpst); \
26
+ bool neg, bool round, uint32_t *sat)
23
- return float##fsz##_scalbn(tmp, -(int)shift, fpst); \
27
{
24
-}
28
- /* Simplify:
25
+{ return itype##_to_##float##fsz##_scalbn(x, -shift, fpstp); }
29
+ /*
26
30
+ * Simplify:
27
/* Notice that we want only input-denormal exception flags from the
31
* = ((a3 << 16) + ((e1 * e2) << 1) + (1 << 15)) >> 16
28
* scalbn operation: the other possible flags (overflow+inexact if
32
* = ((a3 << 15) + (e1 * e2) + (1 << 14)) >> 15
29
@@ -XXX,XX +XXX,XX @@ VFP_CONV_FIX_A64(uq, s, 32, 64, uint64)
33
*/
30
#undef VFP_CONV_FLOAT_FIX_ROUND
34
int32_t ret = (int32_t)src1 * src2;
31
#undef VFP_CONV_FIX_A64
35
- ret = ((int32_t)src3 << 15) + ret + (1 << 14);
32
36
+ if (neg) {
33
-/* Conversion to/from f16 can overflow to infinity before/after scaling.
37
+ ret = -ret;
34
- * Therefore we convert to f64, scale, and then convert f64 to f16; or
38
+ }
35
- * vice versa for conversion to integer.
39
+ ret += ((int32_t)src3 << 15) + (round << 14);
36
- *
40
ret >>= 15;
37
- * For 16- and 32-bit integers, the conversion to f64 never rounds.
41
+
38
- * For 64-bit integers, any integer that would cause rounding will also
42
if (ret != (int16_t)ret) {
39
- * overflow to f16 infinity, so there is no double rounding problem.
43
*sat = 1;
40
- */
44
- ret = (ret < 0 ? -0x8000 : 0x7fff);
41
-
45
+ ret = (ret < 0 ? INT16_MIN : INT16_MAX);
42
-static float16 do_postscale_fp16(float64 f, int shift, float_status *fpst)
46
}
47
return ret;
48
}
49
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(neon_qrdmlah_s16)(CPUARMState *env, uint32_t src1,
50
uint32_t src2, uint32_t src3)
51
{
52
uint32_t *sat = &env->vfp.qc[0];
53
- uint16_t e1 = inl_qrdmlah_s16(src1, src2, src3, sat);
54
- uint16_t e2 = inl_qrdmlah_s16(src1 >> 16, src2 >> 16, src3 >> 16, sat);
55
+ uint16_t e1 = do_sqrdmlah_h(src1, src2, src3, false, true, sat);
56
+ uint16_t e2 = do_sqrdmlah_h(src1 >> 16, src2 >> 16, src3 >> 16,
57
+ false, true, sat);
58
return deposit32(e1, 16, 16, e2);
59
}
60
61
@@ -XXX,XX +XXX,XX @@ void HELPER(gvec_qrdmlah_s16)(void *vd, void *vn, void *vm,
62
uintptr_t i;
63
64
for (i = 0; i < opr_sz / 2; ++i) {
65
- d[i] = inl_qrdmlah_s16(n[i], m[i], d[i], vq);
66
+ d[i] = do_sqrdmlah_h(n[i], m[i], d[i], false, true, vq);
67
}
68
clear_tail(d, opr_sz, simd_maxsz(desc));
69
}
70
71
-/* Signed saturating rounding doubling multiply-subtract high half, 16-bit */
72
-static int16_t inl_qrdmlsh_s16(int16_t src1, int16_t src2,
73
- int16_t src3, uint32_t *sat)
43
-{
74
-{
44
- return float64_to_float16(float64_scalbn(f, -shift, fpst), true, fpst);
75
- /* Similarly, using subtraction:
76
- * = ((a3 << 16) - ((e1 * e2) << 1) + (1 << 15)) >> 16
77
- * = ((a3 << 15) - (e1 * e2) + (1 << 14)) >> 15
78
- */
79
- int32_t ret = (int32_t)src1 * src2;
80
- ret = ((int32_t)src3 << 15) - ret + (1 << 14);
81
- ret >>= 15;
82
- if (ret != (int16_t)ret) {
83
- *sat = 1;
84
- ret = (ret < 0 ? -0x8000 : 0x7fff);
85
- }
86
- return ret;
45
-}
87
-}
46
-
88
-
47
uint32_t HELPER(vfp_sltoh)(uint32_t x, uint32_t shift, void *fpst)
89
uint32_t HELPER(neon_qrdmlsh_s16)(CPUARMState *env, uint32_t src1,
90
uint32_t src2, uint32_t src3)
48
{
91
{
49
- return do_postscale_fp16(int32_to_float64(x, fpst), shift, fpst);
92
uint32_t *sat = &env->vfp.qc[0];
50
+ return int32_to_float16_scalbn(x, -shift, fpst);
93
- uint16_t e1 = inl_qrdmlsh_s16(src1, src2, src3, sat);
94
- uint16_t e2 = inl_qrdmlsh_s16(src1 >> 16, src2 >> 16, src3 >> 16, sat);
95
+ uint16_t e1 = do_sqrdmlah_h(src1, src2, src3, true, true, sat);
96
+ uint16_t e2 = do_sqrdmlah_h(src1 >> 16, src2 >> 16, src3 >> 16,
97
+ true, true, sat);
98
return deposit32(e1, 16, 16, e2);
51
}
99
}
52
100
53
uint32_t HELPER(vfp_ultoh)(uint32_t x, uint32_t shift, void *fpst)
101
@@ -XXX,XX +XXX,XX @@ void HELPER(gvec_qrdmlsh_s16)(void *vd, void *vn, void *vm,
102
uintptr_t i;
103
104
for (i = 0; i < opr_sz / 2; ++i) {
105
- d[i] = inl_qrdmlsh_s16(n[i], m[i], d[i], vq);
106
+ d[i] = do_sqrdmlah_h(n[i], m[i], d[i], true, true, vq);
107
}
108
clear_tail(d, opr_sz, simd_maxsz(desc));
109
}
110
111
/* Signed saturating rounding doubling multiply-accumulate high half, 32-bit */
112
-static int32_t inl_qrdmlah_s32(int32_t src1, int32_t src2,
113
- int32_t src3, uint32_t *sat)
114
+static int32_t do_sqrdmlah_s(int32_t src1, int32_t src2, int32_t src3,
115
+ bool neg, bool round, uint32_t *sat)
54
{
116
{
55
- return do_postscale_fp16(uint32_to_float64(x, fpst), shift, fpst);
117
/* Simplify similarly to int_qrdmlah_s16 above. */
56
+ return uint32_to_float16_scalbn(x, -shift, fpst);
118
int64_t ret = (int64_t)src1 * src2;
119
- ret = ((int64_t)src3 << 31) + ret + (1 << 30);
120
+ if (neg) {
121
+ ret = -ret;
122
+ }
123
+ ret += ((int64_t)src3 << 31) + (round << 30);
124
ret >>= 31;
125
+
126
if (ret != (int32_t)ret) {
127
*sat = 1;
128
ret = (ret < 0 ? INT32_MIN : INT32_MAX);
129
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(neon_qrdmlah_s32)(CPUARMState *env, int32_t src1,
130
int32_t src2, int32_t src3)
131
{
132
uint32_t *sat = &env->vfp.qc[0];
133
- return inl_qrdmlah_s32(src1, src2, src3, sat);
134
+ return do_sqrdmlah_s(src1, src2, src3, false, true, sat);
57
}
135
}
58
136
59
uint32_t HELPER(vfp_sqtoh)(uint64_t x, uint32_t shift, void *fpst)
137
void HELPER(gvec_qrdmlah_s32)(void *vd, void *vn, void *vm,
138
@@ -XXX,XX +XXX,XX @@ void HELPER(gvec_qrdmlah_s32)(void *vd, void *vn, void *vm,
139
uintptr_t i;
140
141
for (i = 0; i < opr_sz / 4; ++i) {
142
- d[i] = inl_qrdmlah_s32(n[i], m[i], d[i], vq);
143
+ d[i] = do_sqrdmlah_s(n[i], m[i], d[i], false, true, vq);
144
}
145
clear_tail(d, opr_sz, simd_maxsz(desc));
146
}
147
148
-/* Signed saturating rounding doubling multiply-subtract high half, 32-bit */
149
-static int32_t inl_qrdmlsh_s32(int32_t src1, int32_t src2,
150
- int32_t src3, uint32_t *sat)
151
-{
152
- /* Simplify similarly to int_qrdmlsh_s16 above. */
153
- int64_t ret = (int64_t)src1 * src2;
154
- ret = ((int64_t)src3 << 31) - ret + (1 << 30);
155
- ret >>= 31;
156
- if (ret != (int32_t)ret) {
157
- *sat = 1;
158
- ret = (ret < 0 ? INT32_MIN : INT32_MAX);
159
- }
160
- return ret;
161
-}
162
-
163
uint32_t HELPER(neon_qrdmlsh_s32)(CPUARMState *env, int32_t src1,
164
int32_t src2, int32_t src3)
60
{
165
{
61
- return do_postscale_fp16(int64_to_float64(x, fpst), shift, fpst);
166
uint32_t *sat = &env->vfp.qc[0];
62
+ return int64_to_float16_scalbn(x, -shift, fpst);
167
- return inl_qrdmlsh_s32(src1, src2, src3, sat);
168
+ return do_sqrdmlah_s(src1, src2, src3, true, true, sat);
63
}
169
}
64
170
65
uint32_t HELPER(vfp_uqtoh)(uint64_t x, uint32_t shift, void *fpst)
171
void HELPER(gvec_qrdmlsh_s32)(void *vd, void *vn, void *vm,
66
{
172
@@ -XXX,XX +XXX,XX @@ void HELPER(gvec_qrdmlsh_s32)(void *vd, void *vn, void *vm,
67
- return do_postscale_fp16(uint64_to_float64(x, fpst), shift, fpst);
173
uintptr_t i;
68
+ return uint64_to_float16_scalbn(x, -shift, fpst);
174
175
for (i = 0; i < opr_sz / 4; ++i) {
176
- d[i] = inl_qrdmlsh_s32(n[i], m[i], d[i], vq);
177
+ d[i] = do_sqrdmlah_s(n[i], m[i], d[i], true, true, vq);
178
}
179
clear_tail(d, opr_sz, simd_maxsz(desc));
69
}
180
}
70
71
static float64 do_prescale_fp16(float16 f, int shift, float_status *fpst)
72
--
181
--
73
2.18.0
182
2.20.1
74
183
75
184
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Message-id: 20180814002653.12828-3-richard.henderson@linaro.org
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Message-id: 20200815013145.539409-19-richard.henderson@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
7
---
8
include/fpu/softfloat.h | 85 ++++++---
8
target/arm/helper.h | 4 ++++
9
fpu/softfloat.c | 391 ++++++++++++++++++++++++++++++++--------
9
target/arm/translate-a64.c | 16 ++++++++++++++++
10
2 files changed, 379 insertions(+), 97 deletions(-)
10
target/arm/vec_helper.c | 29 +++++++++++++++++++++++++----
11
3 files changed, 45 insertions(+), 4 deletions(-)
11
12
12
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
13
diff --git a/target/arm/helper.h b/target/arm/helper.h
13
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
14
--- a/include/fpu/softfloat.h
15
--- a/target/arm/helper.h
15
+++ b/include/fpu/softfloat.h
16
+++ b/target/arm/helper.h
16
@@ -XXX,XX +XXX,XX @@ float128 uint64_to_float128(uint64_t, float_status *status);
17
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(gvec_uaba_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
17
/*----------------------------------------------------------------------------
18
DEF_HELPER_FLAGS_4(gvec_uaba_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
18
| Software half-precision conversion routines.
19
DEF_HELPER_FLAGS_4(gvec_uaba_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
19
*----------------------------------------------------------------------------*/
20
21
+DEF_HELPER_FLAGS_4(gvec_mul_idx_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
22
+DEF_HELPER_FLAGS_4(gvec_mul_idx_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
23
+DEF_HELPER_FLAGS_4(gvec_mul_idx_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
20
+
24
+
21
float16 float32_to_float16(float32, bool ieee, float_status *status);
25
#ifdef TARGET_AARCH64
22
float32 float16_to_float32(float16, bool ieee, float_status *status);
26
#include "helper-a64.h"
23
float16 float64_to_float16(float64 a, bool ieee, float_status *status);
27
#include "helper-sve.h"
24
float64 float16_to_float64(float16 a, bool ieee, float_status *status);
28
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/target/arm/translate-a64.c
31
+++ b/target/arm/translate-a64.c
32
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
33
data, gen_helper_gvec_fmlal_idx_a64);
34
}
35
return;
25
+
36
+
26
+int16_t float16_to_int16_scalbn(float16, int, int, float_status *status);
37
+ case 0x08: /* MUL */
27
+int32_t float16_to_int32_scalbn(float16, int, int, float_status *status);
38
+ if (!is_long && !is_scalar) {
28
+int64_t float16_to_int64_scalbn(float16, int, int, float_status *status);
39
+ static gen_helper_gvec_3 * const fns[3] = {
29
+
40
+ gen_helper_gvec_mul_idx_h,
30
int16_t float16_to_int16(float16, float_status *status);
41
+ gen_helper_gvec_mul_idx_s,
31
-uint16_t float16_to_uint16(float16 a, float_status *status);
42
+ gen_helper_gvec_mul_idx_d,
32
-int16_t float16_to_int16_round_to_zero(float16, float_status *status);
43
+ };
33
-uint16_t float16_to_uint16_round_to_zero(float16 a, float_status *status);
44
+ tcg_gen_gvec_3_ool(vec_full_reg_offset(s, rd),
34
int32_t float16_to_int32(float16, float_status *status);
45
+ vec_full_reg_offset(s, rn),
35
-uint32_t float16_to_uint32(float16 a, float_status *status);
46
+ vec_full_reg_offset(s, rm),
36
-int32_t float16_to_int32_round_to_zero(float16, float_status *status);
47
+ is_q ? 16 : 8, vec_full_reg_size(s),
37
-uint32_t float16_to_uint32_round_to_zero(float16 a, float_status *status);
48
+ index, fns[size - 1]);
38
int64_t float16_to_int64(float16, float_status *status);
49
+ return;
39
-uint64_t float16_to_uint64(float16 a, float_status *status);
50
+ }
40
+
51
+ break;
41
+int16_t float16_to_int16_round_to_zero(float16, float_status *status);
52
}
42
+int32_t float16_to_int32_round_to_zero(float16, float_status *status);
53
43
int64_t float16_to_int64_round_to_zero(float16, float_status *status);
54
if (size == 3) {
44
+
55
diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c
45
+uint16_t float16_to_uint16_scalbn(float16 a, int, int, float_status *status);
46
+uint32_t float16_to_uint32_scalbn(float16 a, int, int, float_status *status);
47
+uint64_t float16_to_uint64_scalbn(float16 a, int, int, float_status *status);
48
+
49
+uint16_t float16_to_uint16(float16 a, float_status *status);
50
+uint32_t float16_to_uint32(float16 a, float_status *status);
51
+uint64_t float16_to_uint64(float16 a, float_status *status);
52
+
53
+uint16_t float16_to_uint16_round_to_zero(float16 a, float_status *status);
54
+uint32_t float16_to_uint32_round_to_zero(float16 a, float_status *status);
55
uint64_t float16_to_uint64_round_to_zero(float16 a, float_status *status);
56
57
/*----------------------------------------------------------------------------
58
@@ -XXX,XX +XXX,XX @@ float16 float16_default_nan(float_status *status);
59
/*----------------------------------------------------------------------------
60
| Software IEC/IEEE single-precision conversion routines.
61
*----------------------------------------------------------------------------*/
62
+
63
+int16_t float32_to_int16_scalbn(float32, int, int, float_status *status);
64
+int32_t float32_to_int32_scalbn(float32, int, int, float_status *status);
65
+int64_t float32_to_int64_scalbn(float32, int, int, float_status *status);
66
+
67
int16_t float32_to_int16(float32, float_status *status);
68
-uint16_t float32_to_uint16(float32, float_status *status);
69
-int16_t float32_to_int16_round_to_zero(float32, float_status *status);
70
-uint16_t float32_to_uint16_round_to_zero(float32, float_status *status);
71
int32_t float32_to_int32(float32, float_status *status);
72
-int32_t float32_to_int32_round_to_zero(float32, float_status *status);
73
-uint32_t float32_to_uint32(float32, float_status *status);
74
-uint32_t float32_to_uint32_round_to_zero(float32, float_status *status);
75
int64_t float32_to_int64(float32, float_status *status);
76
-uint64_t float32_to_uint64(float32, float_status *status);
77
-uint64_t float32_to_uint64_round_to_zero(float32, float_status *status);
78
+
79
+int16_t float32_to_int16_round_to_zero(float32, float_status *status);
80
+int32_t float32_to_int32_round_to_zero(float32, float_status *status);
81
int64_t float32_to_int64_round_to_zero(float32, float_status *status);
82
+
83
+uint16_t float32_to_uint16_scalbn(float32, int, int, float_status *status);
84
+uint32_t float32_to_uint32_scalbn(float32, int, int, float_status *status);
85
+uint64_t float32_to_uint64_scalbn(float32, int, int, float_status *status);
86
+
87
+uint16_t float32_to_uint16(float32, float_status *status);
88
+uint32_t float32_to_uint32(float32, float_status *status);
89
+uint64_t float32_to_uint64(float32, float_status *status);
90
+
91
+uint16_t float32_to_uint16_round_to_zero(float32, float_status *status);
92
+uint32_t float32_to_uint32_round_to_zero(float32, float_status *status);
93
+uint64_t float32_to_uint64_round_to_zero(float32, float_status *status);
94
+
95
float64 float32_to_float64(float32, float_status *status);
96
floatx80 float32_to_floatx80(float32, float_status *status);
97
float128 float32_to_float128(float32, float_status *status);
98
@@ -XXX,XX +XXX,XX @@ float32 float32_default_nan(float_status *status);
99
/*----------------------------------------------------------------------------
100
| Software IEC/IEEE double-precision conversion routines.
101
*----------------------------------------------------------------------------*/
102
+
103
+int16_t float64_to_int16_scalbn(float64, int, int, float_status *status);
104
+int32_t float64_to_int32_scalbn(float64, int, int, float_status *status);
105
+int64_t float64_to_int64_scalbn(float64, int, int, float_status *status);
106
+
107
int16_t float64_to_int16(float64, float_status *status);
108
-uint16_t float64_to_uint16(float64, float_status *status);
109
-int16_t float64_to_int16_round_to_zero(float64, float_status *status);
110
-uint16_t float64_to_uint16_round_to_zero(float64, float_status *status);
111
int32_t float64_to_int32(float64, float_status *status);
112
-int32_t float64_to_int32_round_to_zero(float64, float_status *status);
113
-uint32_t float64_to_uint32(float64, float_status *status);
114
-uint32_t float64_to_uint32_round_to_zero(float64, float_status *status);
115
int64_t float64_to_int64(float64, float_status *status);
116
+
117
+int16_t float64_to_int16_round_to_zero(float64, float_status *status);
118
+int32_t float64_to_int32_round_to_zero(float64, float_status *status);
119
int64_t float64_to_int64_round_to_zero(float64, float_status *status);
120
-uint64_t float64_to_uint64(float64 a, float_status *status);
121
-uint64_t float64_to_uint64_round_to_zero(float64 a, float_status *status);
122
+
123
+uint16_t float64_to_uint16_scalbn(float64, int, int, float_status *status);
124
+uint32_t float64_to_uint32_scalbn(float64, int, int, float_status *status);
125
+uint64_t float64_to_uint64_scalbn(float64, int, int, float_status *status);
126
+
127
+uint16_t float64_to_uint16(float64, float_status *status);
128
+uint32_t float64_to_uint32(float64, float_status *status);
129
+uint64_t float64_to_uint64(float64, float_status *status);
130
+
131
+uint16_t float64_to_uint16_round_to_zero(float64, float_status *status);
132
+uint32_t float64_to_uint32_round_to_zero(float64, float_status *status);
133
+uint64_t float64_to_uint64_round_to_zero(float64, float_status *status);
134
+
135
float32 float64_to_float32(float64, float_status *status);
136
floatx80 float64_to_floatx80(float64, float_status *status);
137
float128 float64_to_float128(float64, float_status *status);
138
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
139
index XXXXXXX..XXXXXXX 100644
56
index XXXXXXX..XXXXXXX 100644
140
--- a/fpu/softfloat.c
57
--- a/target/arm/vec_helper.c
141
+++ b/fpu/softfloat.c
58
+++ b/target/arm/vec_helper.c
142
@@ -XXX,XX +XXX,XX @@ float32 float64_to_float32(float64 a, float_status *s)
59
@@ -XXX,XX +XXX,XX @@ DO_3OP(gvec_rsqrts_d, helper_rsqrtsf_f64, float64)
143
* Arithmetic.
144
*/
60
*/
145
61
146
-static FloatParts round_to_int(FloatParts a, int rounding_mode, float_status *s)
62
#define DO_MUL_IDX(NAME, TYPE, H) \
147
+static FloatParts round_to_int(FloatParts a, int rmode,
63
+void HELPER(NAME)(void *vd, void *vn, void *vm, uint32_t desc) \
148
+ int scale, float_status *s)
64
+{ \
149
{
65
+ intptr_t i, j, oprsz = simd_oprsz(desc), segment = 16 / sizeof(TYPE); \
150
- if (is_nan(a.cls)) {
66
+ intptr_t idx = simd_data(desc); \
151
- return return_nan(a, s);
67
+ TYPE *d = vd, *n = vn, *m = vm; \
152
- }
68
+ for (i = 0; i < oprsz / sizeof(TYPE); i += segment) { \
153
-
69
+ TYPE mm = m[H(i + idx)]; \
154
switch (a.cls) {
70
+ for (j = 0; j < segment; j++) { \
155
+ case float_class_qnan:
71
+ d[i + j] = n[i + j] * mm; \
156
+ case float_class_snan:
72
+ } \
157
+ return return_nan(a, s);
73
+ } \
158
+
74
+ clear_tail(d, oprsz, simd_maxsz(desc)); \
159
case float_class_zero:
160
case float_class_inf:
161
- case float_class_qnan:
162
/* already "integral" */
163
break;
164
+
165
case float_class_normal:
166
+ scale = MIN(MAX(scale, -0x10000), 0x10000);
167
+ a.exp += scale;
168
+
169
if (a.exp >= DECOMPOSED_BINARY_POINT) {
170
/* already integral */
171
break;
172
@@ -XXX,XX +XXX,XX @@ static FloatParts round_to_int(FloatParts a, int rounding_mode, float_status *s)
173
bool one;
174
/* all fractional */
175
s->float_exception_flags |= float_flag_inexact;
176
- switch (rounding_mode) {
177
+ switch (rmode) {
178
case float_round_nearest_even:
179
one = a.exp == -1 && a.frac > DECOMPOSED_IMPLICIT_BIT;
180
break;
181
@@ -XXX,XX +XXX,XX @@ static FloatParts round_to_int(FloatParts a, int rounding_mode, float_status *s)
182
uint64_t rnd_mask = rnd_even_mask >> 1;
183
uint64_t inc;
184
185
- switch (rounding_mode) {
186
+ switch (rmode) {
187
case float_round_nearest_even:
188
inc = ((a.frac & rnd_even_mask) != frac_lsbm1 ? frac_lsbm1 : 0);
189
break;
190
@@ -XXX,XX +XXX,XX @@ static FloatParts round_to_int(FloatParts a, int rounding_mode, float_status *s)
191
float16 float16_round_to_int(float16 a, float_status *s)
192
{
193
FloatParts pa = float16_unpack_canonical(a, s);
194
- FloatParts pr = round_to_int(pa, s->float_rounding_mode, s);
195
+ FloatParts pr = round_to_int(pa, s->float_rounding_mode, 0, s);
196
return float16_round_pack_canonical(pr, s);
197
}
198
199
float32 float32_round_to_int(float32 a, float_status *s)
200
{
201
FloatParts pa = float32_unpack_canonical(a, s);
202
- FloatParts pr = round_to_int(pa, s->float_rounding_mode, s);
203
+ FloatParts pr = round_to_int(pa, s->float_rounding_mode, 0, s);
204
return float32_round_pack_canonical(pr, s);
205
}
206
207
float64 float64_round_to_int(float64 a, float_status *s)
208
{
209
FloatParts pa = float64_unpack_canonical(a, s);
210
- FloatParts pr = round_to_int(pa, s->float_rounding_mode, s);
211
+ FloatParts pr = round_to_int(pa, s->float_rounding_mode, 0, s);
212
return float64_round_pack_canonical(pr, s);
213
}
214
215
float64 float64_trunc_to_int(float64 a, float_status *s)
216
{
217
FloatParts pa = float64_unpack_canonical(a, s);
218
- FloatParts pr = round_to_int(pa, float_round_to_zero, s);
219
+ FloatParts pr = round_to_int(pa, float_round_to_zero, 0, s);
220
return float64_round_pack_canonical(pr, s);
221
}
222
223
@@ -XXX,XX +XXX,XX @@ float64 float64_trunc_to_int(float64 a, float_status *s)
224
* is returned.
225
*/
226
227
-static int64_t round_to_int_and_pack(FloatParts in, int rmode,
228
+static int64_t round_to_int_and_pack(FloatParts in, int rmode, int scale,
229
int64_t min, int64_t max,
230
float_status *s)
231
{
232
uint64_t r;
233
int orig_flags = get_float_exception_flags(s);
234
- FloatParts p = round_to_int(in, rmode, s);
235
+ FloatParts p = round_to_int(in, rmode, scale, s);
236
237
switch (p.cls) {
238
case float_class_snan:
239
@@ -XXX,XX +XXX,XX @@ static int64_t round_to_int_and_pack(FloatParts in, int rmode,
240
}
241
}
242
243
-#define FLOAT_TO_INT(fsz, isz) \
244
-int ## isz ## _t float ## fsz ## _to_int ## isz(float ## fsz a, \
245
- float_status *s) \
246
-{ \
247
- FloatParts p = float ## fsz ## _unpack_canonical(a, s); \
248
- return round_to_int_and_pack(p, s->float_rounding_mode, \
249
- INT ## isz ## _MIN, INT ## isz ## _MAX,\
250
- s); \
251
-} \
252
- \
253
-int ## isz ## _t float ## fsz ## _to_int ## isz ## _round_to_zero \
254
- (float ## fsz a, float_status *s) \
255
-{ \
256
- FloatParts p = float ## fsz ## _unpack_canonical(a, s); \
257
- return round_to_int_and_pack(p, float_round_to_zero, \
258
- INT ## isz ## _MIN, INT ## isz ## _MAX,\
259
- s); \
260
+int16_t float16_to_int16_scalbn(float16 a, int rmode, int scale,
261
+ float_status *s)
262
+{
263
+ return round_to_int_and_pack(float16_unpack_canonical(a, s),
264
+ rmode, scale, INT16_MIN, INT16_MAX, s);
265
}
266
267
-FLOAT_TO_INT(16, 16)
268
-FLOAT_TO_INT(16, 32)
269
-FLOAT_TO_INT(16, 64)
270
+int32_t float16_to_int32_scalbn(float16 a, int rmode, int scale,
271
+ float_status *s)
272
+{
273
+ return round_to_int_and_pack(float16_unpack_canonical(a, s),
274
+ rmode, scale, INT32_MIN, INT32_MAX, s);
275
+}
276
277
-FLOAT_TO_INT(32, 16)
278
-FLOAT_TO_INT(32, 32)
279
-FLOAT_TO_INT(32, 64)
280
+int64_t float16_to_int64_scalbn(float16 a, int rmode, int scale,
281
+ float_status *s)
282
+{
283
+ return round_to_int_and_pack(float16_unpack_canonical(a, s),
284
+ rmode, scale, INT64_MIN, INT64_MAX, s);
285
+}
286
287
-FLOAT_TO_INT(64, 16)
288
-FLOAT_TO_INT(64, 32)
289
-FLOAT_TO_INT(64, 64)
290
+int16_t float32_to_int16_scalbn(float32 a, int rmode, int scale,
291
+ float_status *s)
292
+{
293
+ return round_to_int_and_pack(float32_unpack_canonical(a, s),
294
+ rmode, scale, INT16_MIN, INT16_MAX, s);
295
+}
296
297
-#undef FLOAT_TO_INT
298
+int32_t float32_to_int32_scalbn(float32 a, int rmode, int scale,
299
+ float_status *s)
300
+{
301
+ return round_to_int_and_pack(float32_unpack_canonical(a, s),
302
+ rmode, scale, INT32_MIN, INT32_MAX, s);
303
+}
75
+}
304
+
76
+
305
+int64_t float32_to_int64_scalbn(float32 a, int rmode, int scale,
77
+DO_MUL_IDX(gvec_mul_idx_h, uint16_t, H2)
306
+ float_status *s)
78
+DO_MUL_IDX(gvec_mul_idx_s, uint32_t, H4)
307
+{
79
+DO_MUL_IDX(gvec_mul_idx_d, uint64_t, )
308
+ return round_to_int_and_pack(float32_unpack_canonical(a, s),
309
+ rmode, scale, INT64_MIN, INT64_MAX, s);
310
+}
311
+
80
+
312
+int16_t float64_to_int16_scalbn(float64 a, int rmode, int scale,
81
+#undef DO_MUL_IDX
313
+ float_status *s)
314
+{
315
+ return round_to_int_and_pack(float64_unpack_canonical(a, s),
316
+ rmode, scale, INT16_MIN, INT16_MAX, s);
317
+}
318
+
82
+
319
+int32_t float64_to_int32_scalbn(float64 a, int rmode, int scale,
83
+#define DO_FMUL_IDX(NAME, TYPE, H) \
320
+ float_status *s)
84
void HELPER(NAME)(void *vd, void *vn, void *vm, void *stat, uint32_t desc) \
321
+{
85
{ \
322
+ return round_to_int_and_pack(float64_unpack_canonical(a, s),
86
intptr_t i, j, oprsz = simd_oprsz(desc), segment = 16 / sizeof(TYPE); \
323
+ rmode, scale, INT32_MIN, INT32_MAX, s);
87
@@ -XXX,XX +XXX,XX @@ void HELPER(NAME)(void *vd, void *vn, void *vm, void *stat, uint32_t desc) \
324
+}
88
clear_tail(d, oprsz, simd_maxsz(desc)); \
325
+
326
+int64_t float64_to_int64_scalbn(float64 a, int rmode, int scale,
327
+ float_status *s)
328
+{
329
+ return round_to_int_and_pack(float64_unpack_canonical(a, s),
330
+ rmode, scale, INT64_MIN, INT64_MAX, s);
331
+}
332
+
333
+int16_t float16_to_int16(float16 a, float_status *s)
334
+{
335
+ return float16_to_int16_scalbn(a, s->float_rounding_mode, 0, s);
336
+}
337
+
338
+int32_t float16_to_int32(float16 a, float_status *s)
339
+{
340
+ return float16_to_int32_scalbn(a, s->float_rounding_mode, 0, s);
341
+}
342
+
343
+int64_t float16_to_int64(float16 a, float_status *s)
344
+{
345
+ return float16_to_int64_scalbn(a, s->float_rounding_mode, 0, s);
346
+}
347
+
348
+int16_t float32_to_int16(float32 a, float_status *s)
349
+{
350
+ return float32_to_int16_scalbn(a, s->float_rounding_mode, 0, s);
351
+}
352
+
353
+int32_t float32_to_int32(float32 a, float_status *s)
354
+{
355
+ return float32_to_int32_scalbn(a, s->float_rounding_mode, 0, s);
356
+}
357
+
358
+int64_t float32_to_int64(float32 a, float_status *s)
359
+{
360
+ return float32_to_int64_scalbn(a, s->float_rounding_mode, 0, s);
361
+}
362
+
363
+int16_t float64_to_int16(float64 a, float_status *s)
364
+{
365
+ return float64_to_int16_scalbn(a, s->float_rounding_mode, 0, s);
366
+}
367
+
368
+int32_t float64_to_int32(float64 a, float_status *s)
369
+{
370
+ return float64_to_int32_scalbn(a, s->float_rounding_mode, 0, s);
371
+}
372
+
373
+int64_t float64_to_int64(float64 a, float_status *s)
374
+{
375
+ return float64_to_int64_scalbn(a, s->float_rounding_mode, 0, s);
376
+}
377
+
378
+int16_t float16_to_int16_round_to_zero(float16 a, float_status *s)
379
+{
380
+ return float16_to_int16_scalbn(a, float_round_to_zero, 0, s);
381
+}
382
+
383
+int32_t float16_to_int32_round_to_zero(float16 a, float_status *s)
384
+{
385
+ return float16_to_int32_scalbn(a, float_round_to_zero, 0, s);
386
+}
387
+
388
+int64_t float16_to_int64_round_to_zero(float16 a, float_status *s)
389
+{
390
+ return float16_to_int64_scalbn(a, float_round_to_zero, 0, s);
391
+}
392
+
393
+int16_t float32_to_int16_round_to_zero(float32 a, float_status *s)
394
+{
395
+ return float32_to_int16_scalbn(a, float_round_to_zero, 0, s);
396
+}
397
+
398
+int32_t float32_to_int32_round_to_zero(float32 a, float_status *s)
399
+{
400
+ return float32_to_int32_scalbn(a, float_round_to_zero, 0, s);
401
+}
402
+
403
+int64_t float32_to_int64_round_to_zero(float32 a, float_status *s)
404
+{
405
+ return float32_to_int64_scalbn(a, float_round_to_zero, 0, s);
406
+}
407
+
408
+int16_t float64_to_int16_round_to_zero(float64 a, float_status *s)
409
+{
410
+ return float64_to_int16_scalbn(a, float_round_to_zero, 0, s);
411
+}
412
+
413
+int32_t float64_to_int32_round_to_zero(float64 a, float_status *s)
414
+{
415
+ return float64_to_int32_scalbn(a, float_round_to_zero, 0, s);
416
+}
417
+
418
+int64_t float64_to_int64_round_to_zero(float64 a, float_status *s)
419
+{
420
+ return float64_to_int64_scalbn(a, float_round_to_zero, 0, s);
421
+}
422
423
/*
424
* Returns the result of converting the floating-point value `a' to
425
@@ -XXX,XX +XXX,XX @@ FLOAT_TO_INT(64, 64)
426
* flag.
427
*/
428
429
-static uint64_t round_to_uint_and_pack(FloatParts in, int rmode, uint64_t max,
430
- float_status *s)
431
+static uint64_t round_to_uint_and_pack(FloatParts in, int rmode, int scale,
432
+ uint64_t max, float_status *s)
433
{
434
int orig_flags = get_float_exception_flags(s);
435
- FloatParts p = round_to_int(in, rmode, s);
436
+ FloatParts p = round_to_int(in, rmode, scale, s);
437
+ uint64_t r;
438
439
switch (p.cls) {
440
case float_class_snan:
441
@@ -XXX,XX +XXX,XX @@ static uint64_t round_to_uint_and_pack(FloatParts in, int rmode, uint64_t max,
442
case float_class_zero:
443
return 0;
444
case float_class_normal:
445
- {
446
- uint64_t r;
447
if (p.sign) {
448
s->float_exception_flags = orig_flags | float_flag_invalid;
449
return 0;
450
@@ -XXX,XX +XXX,XX @@ static uint64_t round_to_uint_and_pack(FloatParts in, int rmode, uint64_t max,
451
if (r > max) {
452
s->float_exception_flags = orig_flags | float_flag_invalid;
453
return max;
454
- } else {
455
- return r;
456
}
457
- }
458
+ return r;
459
default:
460
g_assert_not_reached();
461
}
462
}
89
}
463
90
464
-#define FLOAT_TO_UINT(fsz, isz) \
91
-DO_MUL_IDX(gvec_fmul_idx_h, float16, H2)
465
-uint ## isz ## _t float ## fsz ## _to_uint ## isz(float ## fsz a, \
92
-DO_MUL_IDX(gvec_fmul_idx_s, float32, H4)
466
- float_status *s) \
93
-DO_MUL_IDX(gvec_fmul_idx_d, float64, )
467
-{ \
94
+DO_FMUL_IDX(gvec_fmul_idx_h, float16, H2)
468
- FloatParts p = float ## fsz ## _unpack_canonical(a, s); \
95
+DO_FMUL_IDX(gvec_fmul_idx_s, float32, H4)
469
- return round_to_uint_and_pack(p, s->float_rounding_mode, \
96
+DO_FMUL_IDX(gvec_fmul_idx_d, float64, )
470
- UINT ## isz ## _MAX, s); \
97
471
-} \
98
-#undef DO_MUL_IDX
472
- \
99
+#undef DO_FMUL_IDX
473
-uint ## isz ## _t float ## fsz ## _to_uint ## isz ## _round_to_zero \
100
474
- (float ## fsz a, float_status *s) \
101
#define DO_FMLA_IDX(NAME, TYPE, H) \
475
-{ \
102
void HELPER(NAME)(void *vd, void *vn, void *vm, void *va, \
476
- FloatParts p = float ## fsz ## _unpack_canonical(a, s); \
477
- return round_to_uint_and_pack(p, float_round_to_zero, \
478
- UINT ## isz ## _MAX, s); \
479
+uint16_t float16_to_uint16_scalbn(float16 a, int rmode, int scale,
480
+ float_status *s)
481
+{
482
+ return round_to_uint_and_pack(float16_unpack_canonical(a, s),
483
+ rmode, scale, UINT16_MAX, s);
484
}
485
486
-FLOAT_TO_UINT(16, 16)
487
-FLOAT_TO_UINT(16, 32)
488
-FLOAT_TO_UINT(16, 64)
489
+uint32_t float16_to_uint32_scalbn(float16 a, int rmode, int scale,
490
+ float_status *s)
491
+{
492
+ return round_to_uint_and_pack(float16_unpack_canonical(a, s),
493
+ rmode, scale, UINT32_MAX, s);
494
+}
495
496
-FLOAT_TO_UINT(32, 16)
497
-FLOAT_TO_UINT(32, 32)
498
-FLOAT_TO_UINT(32, 64)
499
+uint64_t float16_to_uint64_scalbn(float16 a, int rmode, int scale,
500
+ float_status *s)
501
+{
502
+ return round_to_uint_and_pack(float16_unpack_canonical(a, s),
503
+ rmode, scale, UINT64_MAX, s);
504
+}
505
506
-FLOAT_TO_UINT(64, 16)
507
-FLOAT_TO_UINT(64, 32)
508
-FLOAT_TO_UINT(64, 64)
509
+uint16_t float32_to_uint16_scalbn(float32 a, int rmode, int scale,
510
+ float_status *s)
511
+{
512
+ return round_to_uint_and_pack(float32_unpack_canonical(a, s),
513
+ rmode, scale, UINT16_MAX, s);
514
+}
515
516
-#undef FLOAT_TO_UINT
517
+uint32_t float32_to_uint32_scalbn(float32 a, int rmode, int scale,
518
+ float_status *s)
519
+{
520
+ return round_to_uint_and_pack(float32_unpack_canonical(a, s),
521
+ rmode, scale, UINT32_MAX, s);
522
+}
523
+
524
+uint64_t float32_to_uint64_scalbn(float32 a, int rmode, int scale,
525
+ float_status *s)
526
+{
527
+ return round_to_uint_and_pack(float32_unpack_canonical(a, s),
528
+ rmode, scale, UINT64_MAX, s);
529
+}
530
+
531
+uint16_t float64_to_uint16_scalbn(float64 a, int rmode, int scale,
532
+ float_status *s)
533
+{
534
+ return round_to_uint_and_pack(float64_unpack_canonical(a, s),
535
+ rmode, scale, UINT16_MAX, s);
536
+}
537
+
538
+uint32_t float64_to_uint32_scalbn(float64 a, int rmode, int scale,
539
+ float_status *s)
540
+{
541
+ return round_to_uint_and_pack(float64_unpack_canonical(a, s),
542
+ rmode, scale, UINT32_MAX, s);
543
+}
544
+
545
+uint64_t float64_to_uint64_scalbn(float64 a, int rmode, int scale,
546
+ float_status *s)
547
+{
548
+ return round_to_uint_and_pack(float64_unpack_canonical(a, s),
549
+ rmode, scale, UINT64_MAX, s);
550
+}
551
+
552
+uint16_t float16_to_uint16(float16 a, float_status *s)
553
+{
554
+ return float16_to_uint16_scalbn(a, s->float_rounding_mode, 0, s);
555
+}
556
+
557
+uint32_t float16_to_uint32(float16 a, float_status *s)
558
+{
559
+ return float16_to_uint32_scalbn(a, s->float_rounding_mode, 0, s);
560
+}
561
+
562
+uint64_t float16_to_uint64(float16 a, float_status *s)
563
+{
564
+ return float16_to_uint64_scalbn(a, s->float_rounding_mode, 0, s);
565
+}
566
+
567
+uint16_t float32_to_uint16(float32 a, float_status *s)
568
+{
569
+ return float32_to_uint16_scalbn(a, s->float_rounding_mode, 0, s);
570
+}
571
+
572
+uint32_t float32_to_uint32(float32 a, float_status *s)
573
+{
574
+ return float32_to_uint32_scalbn(a, s->float_rounding_mode, 0, s);
575
+}
576
+
577
+uint64_t float32_to_uint64(float32 a, float_status *s)
578
+{
579
+ return float32_to_uint64_scalbn(a, s->float_rounding_mode, 0, s);
580
+}
581
+
582
+uint16_t float64_to_uint16(float64 a, float_status *s)
583
+{
584
+ return float64_to_uint16_scalbn(a, s->float_rounding_mode, 0, s);
585
+}
586
+
587
+uint32_t float64_to_uint32(float64 a, float_status *s)
588
+{
589
+ return float64_to_uint32_scalbn(a, s->float_rounding_mode, 0, s);
590
+}
591
+
592
+uint64_t float64_to_uint64(float64 a, float_status *s)
593
+{
594
+ return float64_to_uint64_scalbn(a, s->float_rounding_mode, 0, s);
595
+}
596
+
597
+uint16_t float16_to_uint16_round_to_zero(float16 a, float_status *s)
598
+{
599
+ return float16_to_uint16_scalbn(a, float_round_to_zero, 0, s);
600
+}
601
+
602
+uint32_t float16_to_uint32_round_to_zero(float16 a, float_status *s)
603
+{
604
+ return float16_to_uint32_scalbn(a, float_round_to_zero, 0, s);
605
+}
606
+
607
+uint64_t float16_to_uint64_round_to_zero(float16 a, float_status *s)
608
+{
609
+ return float16_to_uint64_scalbn(a, float_round_to_zero, 0, s);
610
+}
611
+
612
+uint16_t float32_to_uint16_round_to_zero(float32 a, float_status *s)
613
+{
614
+ return float32_to_uint16_scalbn(a, float_round_to_zero, 0, s);
615
+}
616
+
617
+uint32_t float32_to_uint32_round_to_zero(float32 a, float_status *s)
618
+{
619
+ return float32_to_uint32_scalbn(a, float_round_to_zero, 0, s);
620
+}
621
+
622
+uint64_t float32_to_uint64_round_to_zero(float32 a, float_status *s)
623
+{
624
+ return float32_to_uint64_scalbn(a, float_round_to_zero, 0, s);
625
+}
626
+
627
+uint16_t float64_to_uint16_round_to_zero(float64 a, float_status *s)
628
+{
629
+ return float64_to_uint16_scalbn(a, float_round_to_zero, 0, s);
630
+}
631
+
632
+uint32_t float64_to_uint32_round_to_zero(float64 a, float_status *s)
633
+{
634
+ return float64_to_uint32_scalbn(a, float_round_to_zero, 0, s);
635
+}
636
+
637
+uint64_t float64_to_uint64_round_to_zero(float64 a, float_status *s)
638
+{
639
+ return float64_to_uint64_scalbn(a, float_round_to_zero, 0, s);
640
+}
641
642
/*
643
* Integer to float conversions
644
--
103
--
645
2.18.0
104
2.20.1
646
105
647
106
diff view generated by jsdifflib
Deleted patch
1
Reduce the size of the per-cpu GICH memory regions from 0x1000
2
to 0x200. The registers only cover 0x200 bytes, and the Cortex-A15
3
wants to map them at a spacing of 0x200 bytes apart. Having the
4
region be too large interferes with mapping them like that, so
5
reduce it.
6
1
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
9
Message-id: 20180821132811.17675-3-peter.maydell@linaro.org
10
---
11
hw/intc/arm_gic.c | 2 +-
12
1 file changed, 1 insertion(+), 1 deletion(-)
13
14
diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/intc/arm_gic.c
17
+++ b/hw/intc/arm_gic.c
18
@@ -XXX,XX +XXX,XX @@ static void arm_gic_realize(DeviceState *dev, Error **errp)
19
for (i = 0; i < s->num_cpu; i++) {
20
memory_region_init_io(&s->vifaceiomem[i + 1], OBJECT(s),
21
&gic_viface_ops, &s->backref[i],
22
- "gic_viface", 0x1000);
23
+ "gic_viface", 0x200);
24
sysbus_init_mmio(sbd, &s->vifaceiomem[i + 1]);
25
}
26
}
27
--
28
2.18.0
29
30
diff view generated by jsdifflib
Deleted patch
1
Connect the VIRQ and VFIQ lines from the GIC to the CPU;
2
these exist always for both CPU and GIC whether the
3
virtualization extensions are enabled or not, so we
4
can just unconditionally connect them.
5
1
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
8
Message-id: 20180821132811.17675-4-peter.maydell@linaro.org
9
---
10
hw/arm/vexpress.c | 4 ++++
11
1 file changed, 4 insertions(+)
12
13
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/arm/vexpress.c
16
+++ b/hw/arm/vexpress.c
17
@@ -XXX,XX +XXX,XX @@ static void init_cpus(const char *cpu_type, const char *privdev,
18
sysbus_connect_irq(busdev, n, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ));
19
sysbus_connect_irq(busdev, n + smp_cpus,
20
qdev_get_gpio_in(cpudev, ARM_CPU_FIQ));
21
+ sysbus_connect_irq(busdev, n + 2 * smp_cpus,
22
+ qdev_get_gpio_in(cpudev, ARM_CPU_VIRQ));
23
+ sysbus_connect_irq(busdev, n + 3 * smp_cpus,
24
+ qdev_get_gpio_in(cpudev, ARM_CPU_VFIQ));
25
}
26
}
27
28
--
29
2.18.0
30
31
diff view generated by jsdifflib
Deleted patch
1
Connect the VIRQ and VFIQ lines from the GIC to the CPU;
2
these exist always for both CPU and GIC whether the
3
virtualization extensions are enabled or not, so we
4
can just unconditionally connect them.
5
1
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
8
Message-id: 20180821132811.17675-5-peter.maydell@linaro.org
9
---
10
hw/arm/highbank.c | 6 ++++++
11
1 file changed, 6 insertions(+)
12
13
diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/arm/highbank.c
16
+++ b/hw/arm/highbank.c
17
@@ -XXX,XX +XXX,XX @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id)
18
int n;
19
qemu_irq cpu_irq[4];
20
qemu_irq cpu_fiq[4];
21
+ qemu_irq cpu_virq[4];
22
+ qemu_irq cpu_vfiq[4];
23
MemoryRegion *sysram;
24
MemoryRegion *dram;
25
MemoryRegion *sysmem;
26
@@ -XXX,XX +XXX,XX @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id)
27
object_property_set_bool(cpuobj, true, "realized", &error_fatal);
28
cpu_irq[n] = qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ);
29
cpu_fiq[n] = qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_FIQ);
30
+ cpu_virq[n] = qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_VIRQ);
31
+ cpu_vfiq[n] = qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_VFIQ);
32
}
33
34
sysmem = get_system_memory();
35
@@ -XXX,XX +XXX,XX @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id)
36
for (n = 0; n < smp_cpus; n++) {
37
sysbus_connect_irq(busdev, n, cpu_irq[n]);
38
sysbus_connect_irq(busdev, n + smp_cpus, cpu_fiq[n]);
39
+ sysbus_connect_irq(busdev, n + 2 * smp_cpus, cpu_virq[n]);
40
+ sysbus_connect_irq(busdev, n + 3 * smp_cpus, cpu_vfiq[n]);
41
}
42
43
for (n = 0; n < 128; n++) {
44
--
45
2.18.0
46
47
diff view generated by jsdifflib
Deleted patch
1
Connect the VIRQ and VFIQ lines from the GIC to the CPU;
2
these exist always for both CPU and GIC whether the
3
virtualization extensions are enabled or not, so we
4
can just unconditionally connect them.
5
1
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
8
Message-id: 20180821132811.17675-6-peter.maydell@linaro.org
9
---
10
hw/arm/fsl-imx6ul.c | 4 ++++
11
1 file changed, 4 insertions(+)
12
13
diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/arm/fsl-imx6ul.c
16
+++ b/hw/arm/fsl-imx6ul.c
17
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
18
irq = qdev_get_gpio_in(d, ARM_CPU_IRQ);
19
sysbus_connect_irq(sbd, i, irq);
20
sysbus_connect_irq(sbd, i + smp_cpus, qdev_get_gpio_in(d, ARM_CPU_FIQ));
21
+ sysbus_connect_irq(sbd, i + 2 * smp_cpus,
22
+ qdev_get_gpio_in(d, ARM_CPU_VIRQ));
23
+ sysbus_connect_irq(sbd, i + 3 * smp_cpus,
24
+ qdev_get_gpio_in(d, ARM_CPU_VFIQ));
25
}
26
27
/*
28
--
29
2.18.0
30
31
diff view generated by jsdifflib
Deleted patch
1
Connect the VIRQ and VFIQ lines from the GIC to the CPU;
2
these exist always for both CPU and GIC whether the
3
virtualization extensions are enabled or not, so we
4
can just unconditionally connect them.
5
1
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
8
Message-id: 20180821132811.17675-7-peter.maydell@linaro.org
9
---
10
hw/arm/fsl-imx7.c | 4 ++++
11
1 file changed, 4 insertions(+)
12
13
diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/arm/fsl-imx7.c
16
+++ b/hw/arm/fsl-imx7.c
17
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
18
sysbus_connect_irq(sbd, i, irq);
19
irq = qdev_get_gpio_in(d, ARM_CPU_FIQ);
20
sysbus_connect_irq(sbd, i + smp_cpus, irq);
21
+ irq = qdev_get_gpio_in(d, ARM_CPU_VIRQ);
22
+ sysbus_connect_irq(sbd, i + 2 * smp_cpus, irq);
23
+ irq = qdev_get_gpio_in(d, ARM_CPU_VFIQ);
24
+ sysbus_connect_irq(sbd, i + 3 * smp_cpus, irq);
25
}
26
27
/*
28
--
29
2.18.0
30
31
diff view generated by jsdifflib
Deleted patch
1
Don't request that the arm_load_kernel() code should boot in secure
2
state if the CPU doesn't have a secure state. Currently this
3
doesn't make a difference because the boot.c code only examines
4
the secure_boot flag in code guarded by an ARM_FEATURE_EL3 check,
5
but upcoming changes for supporting booting into Hyp mode will
6
change that.
7
1
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
10
Message-id: 20180821132811.17675-9-peter.maydell@linaro.org
11
---
12
hw/arm/vexpress.c | 4 ++--
13
1 file changed, 2 insertions(+), 2 deletions(-)
14
15
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/vexpress.c
18
+++ b/hw/arm/vexpress.c
19
@@ -XXX,XX +XXX,XX @@ static void vexpress_common_init(MachineState *machine)
20
daughterboard->bootinfo.smp_bootreg_addr = map[VE_SYSREGS] + 0x30;
21
daughterboard->bootinfo.gic_cpu_if_addr = daughterboard->gic_cpu_if_addr;
22
daughterboard->bootinfo.modify_dtb = vexpress_modify_dtb;
23
- /* Indicate that when booting Linux we should be in secure state */
24
- daughterboard->bootinfo.secure_boot = true;
25
+ /* When booting Linux we should be in secure state if the CPU has one. */
26
+ daughterboard->bootinfo.secure_boot = vms->secure;
27
arm_load_kernel(ARM_CPU(first_cpu), &daughterboard->bootinfo);
28
}
29
30
--
31
2.18.0
32
33
diff view generated by jsdifflib
Deleted patch
1
The v8 AArch32 HACTLR2 register maps to bits [63:32] of ACTLR_EL2.
2
We implement ACTLR_EL2 as RAZ/WI, so make HACTLR2 also RAZ/WI.
3
(We put the regdef next to ACTLR_EL2 as a reminder in case we
4
ever make ACTLR_EL2 something other than RAZ/WI).
5
1
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
9
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
10
Message-id: 20180820153020.21478-2-peter.maydell@linaro.org
11
---
12
target/arm/helper.c | 10 ++++++++++
13
1 file changed, 10 insertions(+)
14
15
diff --git a/target/arm/helper.c b/target/arm/helper.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/helper.c
18
+++ b/target/arm/helper.c
19
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
20
REGINFO_SENTINEL
21
};
22
define_arm_cp_regs(cpu, auxcr_reginfo);
23
+ if (arm_feature(env, ARM_FEATURE_V8)) {
24
+ /* HACTLR2 maps to ACTLR_EL2[63:32] and is not in ARMv7 */
25
+ ARMCPRegInfo hactlr2_reginfo = {
26
+ .name = "HACTLR2", .state = ARM_CP_STATE_AA32,
27
+ .cp = 15, .opc1 = 4, .crn = 1, .crm = 0, .opc2 = 3,
28
+ .access = PL2_RW, .type = ARM_CP_CONST,
29
+ .resetvalue = 0
30
+ };
31
+ define_one_arm_cp_reg(cpu, &hactlr2_reginfo);
32
+ }
33
}
34
35
if (arm_feature(env, ARM_FEATURE_CBAR)) {
36
--
37
2.18.0
38
39
diff view generated by jsdifflib
Deleted patch
1
On 32-bit exception entry, CPSR.J must always be set to 0
2
(see v7A Arm ARM DDI0406C.c B1.8.5). CPSR.IL must also
3
be cleared on 32-bit exception entry (see v8A Arm ARM
4
DDI0487C.a G1.10).
5
1
6
Clear these bits. (This fixes a bug which will never be noticed
7
by non-buggy guests.)
8
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
12
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
13
Message-id: 20180820153020.21478-6-peter.maydell@linaro.org
14
---
15
target/arm/helper.c | 2 ++
16
1 file changed, 2 insertions(+)
17
18
diff --git a/target/arm/helper.c b/target/arm/helper.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/helper.c
21
+++ b/target/arm/helper.c
22
@@ -XXX,XX +XXX,XX @@ static void take_aarch32_exception(CPUARMState *env, int new_mode,
23
if (env->cp15.sctlr_el[arm_current_el(env)] & SCTLR_EE) {
24
env->uncached_cpsr |= CPSR_E;
25
}
26
+ /* J and IL must always be cleared for exception entry */
27
+ env->uncached_cpsr &= ~(CPSR_IL | CPSR_J);
28
env->daif |= mask;
29
30
if (new_mode == ARM_CPU_MODE_HYP) {
31
--
32
2.18.0
33
34
diff view generated by jsdifflib
Deleted patch
1
The kernel booting specification for an AArch32 kernel requires that
2
it is booted in Hyp mode if available; otherwise the kernel can't
3
enable KVM. We were incorrectly leaving the kernel in SVC mode.
4
If we're booting an AArch32 kernel in the Nonsecure state and Hyp
5
mode is available, start in it.
6
1
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
10
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
11
Message-id: 20180820153020.21478-7-peter.maydell@linaro.org
12
---
13
hw/arm/boot.c | 11 +++++++++++
14
1 file changed, 11 insertions(+)
15
16
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/arm/boot.c
19
+++ b/hw/arm/boot.c
20
@@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque)
21
}
22
}
23
24
+ if (!env->aarch64 && !info->secure_boot &&
25
+ arm_feature(env, ARM_FEATURE_EL2)) {
26
+ /*
27
+ * This is an AArch32 boot not to Secure state, and
28
+ * we have Hyp mode available, so boot the kernel into
29
+ * Hyp mode. This is not how the CPU comes out of reset,
30
+ * so we need to manually put it there.
31
+ */
32
+ cpsr_write(env, ARM_CPU_MODE_HYP, CPSR_M, CPSRWriteRaw);
33
+ }
34
+
35
if (cs == first_cpu) {
36
AddressSpace *as = arm_boot_address_space(cpu, info);
37
38
--
39
2.18.0
40
41
diff view generated by jsdifflib
Deleted patch
1
The MPS2 FPGAIO block includes some simple free-running counters.
2
Implement these.
3
1
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20180820141116.9118-2-peter.maydell@linaro.org
7
---
8
include/hw/misc/mps2-fpgaio.h | 4 +++
9
hw/misc/mps2-fpgaio.c | 53 ++++++++++++++++++++++++++++++++++-
10
2 files changed, 56 insertions(+), 1 deletion(-)
11
12
diff --git a/include/hw/misc/mps2-fpgaio.h b/include/hw/misc/mps2-fpgaio.h
13
index XXXXXXX..XXXXXXX 100644
14
--- a/include/hw/misc/mps2-fpgaio.h
15
+++ b/include/hw/misc/mps2-fpgaio.h
16
@@ -XXX,XX +XXX,XX @@ typedef struct {
17
uint32_t misc;
18
19
uint32_t prescale_clk;
20
+
21
+ /* These hold the CLOCK_VIRTUAL ns tick when the CLK1HZ/CLK100HZ was zero */
22
+ int64_t clk1hz_tick_offset;
23
+ int64_t clk100hz_tick_offset;
24
} MPS2FPGAIO;
25
26
#endif
27
diff --git a/hw/misc/mps2-fpgaio.c b/hw/misc/mps2-fpgaio.c
28
index XXXXXXX..XXXXXXX 100644
29
--- a/hw/misc/mps2-fpgaio.c
30
+++ b/hw/misc/mps2-fpgaio.c
31
@@ -XXX,XX +XXX,XX @@
32
#include "hw/sysbus.h"
33
#include "hw/registerfields.h"
34
#include "hw/misc/mps2-fpgaio.h"
35
+#include "qemu/timer.h"
36
37
REG32(LED0, 0)
38
REG32(BUTTON, 8)
39
@@ -XXX,XX +XXX,XX @@ REG32(PRESCALE, 0x1c)
40
REG32(PSCNTR, 0x20)
41
REG32(MISC, 0x4c)
42
43
+static uint32_t counter_from_tickoff(int64_t now, int64_t tick_offset, int frq)
44
+{
45
+ return muldiv64(now - tick_offset, frq, NANOSECONDS_PER_SECOND);
46
+}
47
+
48
+static int64_t tickoff_from_counter(int64_t now, uint32_t count, int frq)
49
+{
50
+ return now - muldiv64(count, NANOSECONDS_PER_SECOND, frq);
51
+}
52
+
53
static uint64_t mps2_fpgaio_read(void *opaque, hwaddr offset, unsigned size)
54
{
55
MPS2FPGAIO *s = MPS2_FPGAIO(opaque);
56
uint64_t r;
57
+ int64_t now;
58
59
switch (offset) {
60
case A_LED0:
61
@@ -XXX,XX +XXX,XX @@ static uint64_t mps2_fpgaio_read(void *opaque, hwaddr offset, unsigned size)
62
r = s->misc;
63
break;
64
case A_CLK1HZ:
65
+ now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
66
+ r = counter_from_tickoff(now, s->clk1hz_tick_offset, 1);
67
+ break;
68
case A_CLK100HZ:
69
+ now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
70
+ r = counter_from_tickoff(now, s->clk100hz_tick_offset, 100);
71
+ break;
72
case A_COUNTER:
73
case A_PSCNTR:
74
- /* These are all upcounters of various frequencies. */
75
qemu_log_mask(LOG_UNIMP, "MPS2 FPGAIO: counters unimplemented\n");
76
r = 0;
77
break;
78
@@ -XXX,XX +XXX,XX @@ static void mps2_fpgaio_write(void *opaque, hwaddr offset, uint64_t value,
79
unsigned size)
80
{
81
MPS2FPGAIO *s = MPS2_FPGAIO(opaque);
82
+ int64_t now;
83
84
trace_mps2_fpgaio_write(offset, value, size);
85
86
@@ -XXX,XX +XXX,XX @@ static void mps2_fpgaio_write(void *opaque, hwaddr offset, uint64_t value,
87
"MPS2 FPGAIO: MISC control bits unimplemented\n");
88
s->misc = value;
89
break;
90
+ case A_CLK1HZ:
91
+ now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
92
+ s->clk1hz_tick_offset = tickoff_from_counter(now, value, 1);
93
+ break;
94
+ case A_CLK100HZ:
95
+ now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
96
+ s->clk100hz_tick_offset = tickoff_from_counter(now, value, 100);
97
+ break;
98
default:
99
qemu_log_mask(LOG_GUEST_ERROR,
100
"MPS2 FPGAIO write: bad offset 0x%x\n", (int) offset);
101
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps mps2_fpgaio_ops = {
102
static void mps2_fpgaio_reset(DeviceState *dev)
103
{
104
MPS2FPGAIO *s = MPS2_FPGAIO(dev);
105
+ int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
106
107
trace_mps2_fpgaio_reset();
108
s->led0 = 0;
109
s->prescale = 0;
110
s->misc = 0;
111
+ s->clk1hz_tick_offset = tickoff_from_counter(now, 0, 1);
112
+ s->clk100hz_tick_offset = tickoff_from_counter(now, 0, 100);
113
}
114
115
static void mps2_fpgaio_init(Object *obj)
116
@@ -XXX,XX +XXX,XX @@ static void mps2_fpgaio_init(Object *obj)
117
sysbus_init_mmio(sbd, &s->iomem);
118
}
119
120
+static bool mps2_fpgaio_counters_needed(void *opaque)
121
+{
122
+ /* Currently vmstate.c insists all subsections have a 'needed' function */
123
+ return true;
124
+}
125
+
126
+static const VMStateDescription mps2_fpgaio_counters_vmstate = {
127
+ .name = "mps2-fpgaio/counters",
128
+ .version_id = 1,
129
+ .minimum_version_id = 1,
130
+ .needed = mps2_fpgaio_counters_needed,
131
+ .fields = (VMStateField[]) {
132
+ VMSTATE_INT64(clk1hz_tick_offset, MPS2FPGAIO),
133
+ VMSTATE_INT64(clk100hz_tick_offset, MPS2FPGAIO),
134
+ VMSTATE_END_OF_LIST()
135
+ }
136
+};
137
+
138
static const VMStateDescription mps2_fpgaio_vmstate = {
139
.name = "mps2-fpgaio",
140
.version_id = 1,
141
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription mps2_fpgaio_vmstate = {
142
VMSTATE_UINT32(prescale, MPS2FPGAIO),
143
VMSTATE_UINT32(misc, MPS2FPGAIO),
144
VMSTATE_END_OF_LIST()
145
+ },
146
+ .subsections = (const VMStateDescription*[]) {
147
+ &mps2_fpgaio_counters_vmstate,
148
+ NULL
149
}
150
};
151
152
--
153
2.18.0
154
155
diff view generated by jsdifflib
Deleted patch
1
Now we have a model of the CMSDK dual timer, we can wire it
2
up in the IoTKit.
3
1
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20180820141116.9118-5-peter.maydell@linaro.org
8
---
9
include/hw/arm/iotkit.h | 3 ++-
10
hw/arm/iotkit.c | 8 +++++---
11
2 files changed, 7 insertions(+), 4 deletions(-)
12
13
diff --git a/include/hw/arm/iotkit.h b/include/hw/arm/iotkit.h
14
index XXXXXXX..XXXXXXX 100644
15
--- a/include/hw/arm/iotkit.h
16
+++ b/include/hw/arm/iotkit.h
17
@@ -XXX,XX +XXX,XX @@
18
#include "hw/misc/tz-ppc.h"
19
#include "hw/misc/tz-mpc.h"
20
#include "hw/timer/cmsdk-apb-timer.h"
21
+#include "hw/timer/cmsdk-apb-dualtimer.h"
22
#include "hw/misc/unimp.h"
23
#include "hw/or-irq.h"
24
#include "hw/core/split-irq.h"
25
@@ -XXX,XX +XXX,XX @@ typedef struct IoTKit {
26
SplitIRQ mpc_irq_splitter[IOTS_NUM_EXP_MPC + IOTS_NUM_MPC];
27
qemu_or_irq mpc_irq_orgate;
28
29
- UnimplementedDeviceState dualtimer;
30
+ CMSDKAPBDualTimer dualtimer;
31
UnimplementedDeviceState s32ktimer;
32
33
MemoryRegion container;
34
diff --git a/hw/arm/iotkit.c b/hw/arm/iotkit.c
35
index XXXXXXX..XXXXXXX 100644
36
--- a/hw/arm/iotkit.c
37
+++ b/hw/arm/iotkit.c
38
@@ -XXX,XX +XXX,XX @@ static void iotkit_init(Object *obj)
39
sysbus_init_child_obj(obj, "timer1", &s->timer1, sizeof(s->timer1),
40
TYPE_CMSDK_APB_TIMER);
41
sysbus_init_child_obj(obj, "dualtimer", &s->dualtimer, sizeof(s->dualtimer),
42
- TYPE_UNIMPLEMENTED_DEVICE);
43
+ TYPE_CMSDK_APB_DUALTIMER);
44
object_initialize_child(obj, "ppc-irq-orgate", &s->ppc_irq_orgate,
45
sizeof(s->ppc_irq_orgate), TYPE_OR_IRQ,
46
&error_abort, NULL);
47
@@ -XXX,XX +XXX,XX @@ static void iotkit_realize(DeviceState *dev, Error **errp)
48
return;
49
}
50
51
- qdev_prop_set_string(DEVICE(&s->dualtimer), "name", "Dual timer");
52
- qdev_prop_set_uint64(DEVICE(&s->dualtimer), "size", 0x1000);
53
+
54
+ qdev_prop_set_uint32(DEVICE(&s->dualtimer), "pclk-frq", s->mainclk_frq);
55
object_property_set_bool(OBJECT(&s->dualtimer), true, "realized", &err);
56
if (err) {
57
error_propagate(errp, err);
58
return;
59
}
60
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->dualtimer), 0,
61
+ qdev_get_gpio_in(DEVICE(&s->armv7m), 5));
62
mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->dualtimer), 0);
63
object_property_set_link(OBJECT(&s->apb_ppc0), OBJECT(mr), "port[2]", &err);
64
if (err) {
65
--
66
2.18.0
67
68
diff view generated by jsdifflib
Deleted patch
1
The MPS2 FPGA images for the Cortex-M3 (mps2-an385 and mps2-511)
2
both include a CMSDK dual-timer module. Wire this up.
3
1
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20180820141116.9118-6-peter.maydell@linaro.org
8
---
9
hw/arm/mps2.c | 11 +++++++++++
10
1 file changed, 11 insertions(+)
11
12
diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/arm/mps2.c
15
+++ b/hw/arm/mps2.c
16
@@ -XXX,XX +XXX,XX @@
17
#include "hw/misc/unimp.h"
18
#include "hw/char/cmsdk-apb-uart.h"
19
#include "hw/timer/cmsdk-apb-timer.h"
20
+#include "hw/timer/cmsdk-apb-dualtimer.h"
21
#include "hw/misc/mps2-scc.h"
22
#include "hw/devices.h"
23
#include "net/net.h"
24
@@ -XXX,XX +XXX,XX @@ typedef struct {
25
MemoryRegion blockram_m3;
26
MemoryRegion sram;
27
MPS2SCC scc;
28
+ CMSDKAPBDualTimer dualtimer;
29
} MPS2MachineState;
30
31
#define TYPE_MPS2_MACHINE "mps2"
32
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
33
cmsdk_apb_timer_create(0x40000000, qdev_get_gpio_in(armv7m, 8), SYSCLK_FRQ);
34
cmsdk_apb_timer_create(0x40001000, qdev_get_gpio_in(armv7m, 9), SYSCLK_FRQ);
35
36
+ sysbus_init_child_obj(OBJECT(mms), "dualtimer", &mms->dualtimer,
37
+ sizeof(mms->dualtimer), TYPE_CMSDK_APB_DUALTIMER);
38
+ qdev_prop_set_uint32(DEVICE(&mms->dualtimer), "pclk-frq", SYSCLK_FRQ);
39
+ object_property_set_bool(OBJECT(&mms->dualtimer), true, "realized",
40
+ &error_fatal);
41
+ sysbus_connect_irq(SYS_BUS_DEVICE(&mms->dualtimer), 0,
42
+ qdev_get_gpio_in(armv7m, 10));
43
+ sysbus_mmio_map(SYS_BUS_DEVICE(&mms->dualtimer), 0, 0x40002000);
44
+
45
object_initialize(&mms->scc, sizeof(mms->scc), TYPE_MPS2_SCC);
46
sccdev = DEVICE(&mms->scc);
47
qdev_set_parent_bus(sccdev, sysbus_get_default());
48
--
49
2.18.0
50
51
diff view generated by jsdifflib
Deleted patch
1
The IoTKit includes three different instances of the
2
CMSDK APB watchdog; create and wire them up.
3
1
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20180820141116.9118-7-peter.maydell@linaro.org
8
---
9
include/hw/arm/iotkit.h | 6 +++++
10
hw/arm/iotkit.c | 58 ++++++++++++++++++++++++++++++++++++++---
11
2 files changed, 61 insertions(+), 3 deletions(-)
12
13
diff --git a/include/hw/arm/iotkit.h b/include/hw/arm/iotkit.h
14
index XXXXXXX..XXXXXXX 100644
15
--- a/include/hw/arm/iotkit.h
16
+++ b/include/hw/arm/iotkit.h
17
@@ -XXX,XX +XXX,XX @@
18
#include "hw/misc/tz-mpc.h"
19
#include "hw/timer/cmsdk-apb-timer.h"
20
#include "hw/timer/cmsdk-apb-dualtimer.h"
21
+#include "hw/watchdog/cmsdk-apb-watchdog.h"
22
#include "hw/misc/unimp.h"
23
#include "hw/or-irq.h"
24
#include "hw/core/split-irq.h"
25
@@ -XXX,XX +XXX,XX @@ typedef struct IoTKit {
26
SplitIRQ ppc_irq_splitter[NUM_PPCS];
27
SplitIRQ mpc_irq_splitter[IOTS_NUM_EXP_MPC + IOTS_NUM_MPC];
28
qemu_or_irq mpc_irq_orgate;
29
+ qemu_or_irq nmi_orgate;
30
31
CMSDKAPBDualTimer dualtimer;
32
UnimplementedDeviceState s32ktimer;
33
34
+ CMSDKAPBWatchdog s32kwatchdog;
35
+ CMSDKAPBWatchdog nswatchdog;
36
+ CMSDKAPBWatchdog swatchdog;
37
+
38
MemoryRegion container;
39
MemoryRegion alias1;
40
MemoryRegion alias2;
41
diff --git a/hw/arm/iotkit.c b/hw/arm/iotkit.c
42
index XXXXXXX..XXXXXXX 100644
43
--- a/hw/arm/iotkit.c
44
+++ b/hw/arm/iotkit.c
45
@@ -XXX,XX +XXX,XX @@
46
#include "hw/misc/unimp.h"
47
#include "hw/arm/arm.h"
48
49
+/* Clock frequency in HZ of the 32KHz "slow clock" */
50
+#define S32KCLK (32 * 1000)
51
+
52
/* Create an alias region of @size bytes starting at @base
53
* which mirrors the memory starting at @orig.
54
*/
55
@@ -XXX,XX +XXX,XX @@ static void iotkit_init(Object *obj)
56
TYPE_CMSDK_APB_TIMER);
57
sysbus_init_child_obj(obj, "dualtimer", &s->dualtimer, sizeof(s->dualtimer),
58
TYPE_CMSDK_APB_DUALTIMER);
59
+ sysbus_init_child_obj(obj, "s32kwatchdog", &s->s32kwatchdog,
60
+ sizeof(s->s32kwatchdog), TYPE_CMSDK_APB_WATCHDOG);
61
+ sysbus_init_child_obj(obj, "nswatchdog", &s->nswatchdog,
62
+ sizeof(s->nswatchdog), TYPE_CMSDK_APB_WATCHDOG);
63
+ sysbus_init_child_obj(obj, "swatchdog", &s->swatchdog,
64
+ sizeof(s->swatchdog), TYPE_CMSDK_APB_WATCHDOG);
65
+ object_initialize_child(obj, "nmi-orgate", &s->nmi_orgate,
66
+ sizeof(s->nmi_orgate), TYPE_OR_IRQ,
67
+ &error_abort, NULL);
68
object_initialize_child(obj, "ppc-irq-orgate", &s->ppc_irq_orgate,
69
sizeof(s->ppc_irq_orgate), TYPE_OR_IRQ,
70
&error_abort, NULL);
71
@@ -XXX,XX +XXX,XX @@ static void iotkit_realize(DeviceState *dev, Error **errp)
72
create_unimplemented_device("SYSINFO", 0x40020000, 0x1000);
73
74
create_unimplemented_device("SYSCONTROL", 0x50021000, 0x1000);
75
- create_unimplemented_device("S32KWATCHDOG", 0x5002e000, 0x1000);
76
+
77
+ /* This OR gate wires together outputs from the secure watchdogs to NMI */
78
+ object_property_set_int(OBJECT(&s->nmi_orgate), 2, "num-lines", &err);
79
+ if (err) {
80
+ error_propagate(errp, err);
81
+ return;
82
+ }
83
+ object_property_set_bool(OBJECT(&s->nmi_orgate), true, "realized", &err);
84
+ if (err) {
85
+ error_propagate(errp, err);
86
+ return;
87
+ }
88
+ qdev_connect_gpio_out(DEVICE(&s->nmi_orgate), 0,
89
+ qdev_get_gpio_in_named(DEVICE(&s->armv7m), "NMI", 0));
90
+
91
+ qdev_prop_set_uint32(DEVICE(&s->s32kwatchdog), "wdogclk-frq", S32KCLK);
92
+ object_property_set_bool(OBJECT(&s->s32kwatchdog), true, "realized", &err);
93
+ if (err) {
94
+ error_propagate(errp, err);
95
+ return;
96
+ }
97
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->s32kwatchdog), 0,
98
+ qdev_get_gpio_in(DEVICE(&s->nmi_orgate), 0));
99
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->s32kwatchdog), 0, 0x5002e000);
100
101
/* 0x40080000 .. 0x4008ffff : IoTKit second Base peripheral region */
102
103
- create_unimplemented_device("NS watchdog", 0x40081000, 0x1000);
104
- create_unimplemented_device("S watchdog", 0x50081000, 0x1000);
105
+ qdev_prop_set_uint32(DEVICE(&s->nswatchdog), "wdogclk-frq", s->mainclk_frq);
106
+ object_property_set_bool(OBJECT(&s->nswatchdog), true, "realized", &err);
107
+ if (err) {
108
+ error_propagate(errp, err);
109
+ return;
110
+ }
111
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->nswatchdog), 0,
112
+ qdev_get_gpio_in(DEVICE(&s->armv7m), 1));
113
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->nswatchdog), 0, 0x40081000);
114
+
115
+ qdev_prop_set_uint32(DEVICE(&s->swatchdog), "wdogclk-frq", s->mainclk_frq);
116
+ object_property_set_bool(OBJECT(&s->swatchdog), true, "realized", &err);
117
+ if (err) {
118
+ error_propagate(errp, err);
119
+ return;
120
+ }
121
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->swatchdog), 0,
122
+ qdev_get_gpio_in(DEVICE(&s->nmi_orgate), 1));
123
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->swatchdog), 0, 0x50081000);
124
125
for (i = 0; i < ARRAY_SIZE(s->ppc_irq_splitter); i++) {
126
Object *splitter = OBJECT(&s->ppc_irq_splitter[i]);
127
--
128
2.18.0
129
130
diff view generated by jsdifflib
1
Implement the IoTKit system control element's system information
1
From: Richard Henderson <richard.henderson@linaro.org>
2
block; this is just a pair of read-only version/config registers,
3
plus the usual PID/CID ID registers.
4
2
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Message-id: 20200815013145.539409-20-richard.henderson@linaro.org
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20180820141116.9118-10-peter.maydell@linaro.org
9
---
7
---
10
hw/misc/Makefile.objs | 1 +
8
target/arm/helper.h | 14 ++++++++++++++
11
include/hw/misc/iotkit-sysinfo.h | 37 +++++++++
9
target/arm/translate-a64.c | 34 ++++++++++++++++++++++++++++++++++
12
hw/misc/iotkit-sysinfo.c | 128 +++++++++++++++++++++++++++++++
10
target/arm/vec_helper.c | 25 +++++++++++++++++++++++++
13
MAINTAINERS | 2 +
11
3 files changed, 73 insertions(+)
14
default-configs/arm-softmmu.mak | 1 +
15
5 files changed, 169 insertions(+)
16
create mode 100644 include/hw/misc/iotkit-sysinfo.h
17
create mode 100644 hw/misc/iotkit-sysinfo.c
18
12
19
diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs
13
diff --git a/target/arm/helper.h b/target/arm/helper.h
20
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/misc/Makefile.objs
15
--- a/target/arm/helper.h
22
+++ b/hw/misc/Makefile.objs
16
+++ b/target/arm/helper.h
23
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_TZ_MPC) += tz-mpc.o
17
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(gvec_mul_idx_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
24
obj-$(CONFIG_TZ_PPC) += tz-ppc.o
18
DEF_HELPER_FLAGS_4(gvec_mul_idx_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
25
obj-$(CONFIG_IOTKIT_SECCTL) += iotkit-secctl.o
19
DEF_HELPER_FLAGS_4(gvec_mul_idx_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
26
obj-$(CONFIG_IOTKIT_SYSCTL) += iotkit-sysctl.o
20
27
+obj-$(CONFIG_IOTKIT_SYSINFO) += iotkit-sysinfo.o
21
+DEF_HELPER_FLAGS_5(gvec_mla_idx_h, TCG_CALL_NO_RWG,
28
22
+ void, ptr, ptr, ptr, ptr, i32)
29
obj-$(CONFIG_PVPANIC) += pvpanic.o
23
+DEF_HELPER_FLAGS_5(gvec_mla_idx_s, TCG_CALL_NO_RWG,
30
obj-$(CONFIG_HYPERV_TESTDEV) += hyperv_testdev.o
24
+ void, ptr, ptr, ptr, ptr, i32)
31
diff --git a/include/hw/misc/iotkit-sysinfo.h b/include/hw/misc/iotkit-sysinfo.h
25
+DEF_HELPER_FLAGS_5(gvec_mla_idx_d, TCG_CALL_NO_RWG,
32
new file mode 100644
26
+ void, ptr, ptr, ptr, ptr, i32)
33
index XXXXXXX..XXXXXXX
34
--- /dev/null
35
+++ b/include/hw/misc/iotkit-sysinfo.h
36
@@ -XXX,XX +XXX,XX @@
37
+/*
38
+ * ARM IoTKit system information block
39
+ *
40
+ * Copyright (c) 2018 Linaro Limited
41
+ * Written by Peter Maydell
42
+ *
43
+ * This program is free software; you can redistribute it and/or modify
44
+ * it under the terms of the GNU General Public License version 2 or
45
+ * (at your option) any later version.
46
+ */
47
+
27
+
48
+/*
28
+DEF_HELPER_FLAGS_5(gvec_mls_idx_h, TCG_CALL_NO_RWG,
49
+ * This is a model of the "system information block" which is part of the
29
+ void, ptr, ptr, ptr, ptr, i32)
50
+ * Arm IoTKit and documented in
30
+DEF_HELPER_FLAGS_5(gvec_mls_idx_s, TCG_CALL_NO_RWG,
51
+ * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ecm0601256/index.html
31
+ void, ptr, ptr, ptr, ptr, i32)
52
+ * QEMU interface:
32
+DEF_HELPER_FLAGS_5(gvec_mls_idx_d, TCG_CALL_NO_RWG,
53
+ * + sysbus MMIO region 0: the system information register bank
33
+ void, ptr, ptr, ptr, ptr, i32)
54
+ */
55
+
34
+
56
+#ifndef HW_MISC_IOTKIT_SYSINFO_H
35
#ifdef TARGET_AARCH64
57
+#define HW_MISC_IOTKIT_SYSINFO_H
36
#include "helper-a64.h"
37
#include "helper-sve.h"
38
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
39
index XXXXXXX..XXXXXXX 100644
40
--- a/target/arm/translate-a64.c
41
+++ b/target/arm/translate-a64.c
42
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
43
return;
44
}
45
break;
58
+
46
+
59
+#include "hw/sysbus.h"
47
+ case 0x10: /* MLA */
60
+
48
+ if (!is_long && !is_scalar) {
61
+#define TYPE_IOTKIT_SYSINFO "iotkit-sysinfo"
49
+ static gen_helper_gvec_4 * const fns[3] = {
62
+#define IOTKIT_SYSINFO(obj) OBJECT_CHECK(IoTKitSysInfo, (obj), \
50
+ gen_helper_gvec_mla_idx_h,
63
+ TYPE_IOTKIT_SYSINFO)
51
+ gen_helper_gvec_mla_idx_s,
64
+
52
+ gen_helper_gvec_mla_idx_d,
65
+typedef struct IoTKitSysInfo {
53
+ };
66
+ /*< private >*/
54
+ tcg_gen_gvec_4_ool(vec_full_reg_offset(s, rd),
67
+ SysBusDevice parent_obj;
55
+ vec_full_reg_offset(s, rn),
68
+
56
+ vec_full_reg_offset(s, rm),
69
+ /*< public >*/
57
+ vec_full_reg_offset(s, rd),
70
+ MemoryRegion iomem;
58
+ is_q ? 16 : 8, vec_full_reg_size(s),
71
+} IoTKitSysInfo;
59
+ index, fns[size - 1]);
72
+
60
+ return;
73
+#endif
61
+ }
74
diff --git a/hw/misc/iotkit-sysinfo.c b/hw/misc/iotkit-sysinfo.c
75
new file mode 100644
76
index XXXXXXX..XXXXXXX
77
--- /dev/null
78
+++ b/hw/misc/iotkit-sysinfo.c
79
@@ -XXX,XX +XXX,XX @@
80
+/*
81
+ * ARM IoTKit system information block
82
+ *
83
+ * Copyright (c) 2018 Linaro Limited
84
+ * Written by Peter Maydell
85
+ *
86
+ * This program is free software; you can redistribute it and/or modify
87
+ * it under the terms of the GNU General Public License version 2 or
88
+ * (at your option) any later version.
89
+ */
90
+
91
+/*
92
+ * This is a model of the "system information block" which is part of the
93
+ * Arm IoTKit and documented in
94
+ * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ecm0601256/index.html
95
+ * It consists of 2 read-only version/config registers, plus the
96
+ * usual ID registers.
97
+ */
98
+
99
+#include "qemu/osdep.h"
100
+#include "qemu/log.h"
101
+#include "trace.h"
102
+#include "qapi/error.h"
103
+#include "sysemu/sysemu.h"
104
+#include "hw/sysbus.h"
105
+#include "hw/registerfields.h"
106
+#include "hw/misc/iotkit-sysinfo.h"
107
+
108
+REG32(SYS_VERSION, 0x0)
109
+REG32(SYS_CONFIG, 0x4)
110
+REG32(PID4, 0xfd0)
111
+REG32(PID5, 0xfd4)
112
+REG32(PID6, 0xfd8)
113
+REG32(PID7, 0xfdc)
114
+REG32(PID0, 0xfe0)
115
+REG32(PID1, 0xfe4)
116
+REG32(PID2, 0xfe8)
117
+REG32(PID3, 0xfec)
118
+REG32(CID0, 0xff0)
119
+REG32(CID1, 0xff4)
120
+REG32(CID2, 0xff8)
121
+REG32(CID3, 0xffc)
122
+
123
+/* PID/CID values */
124
+static const int sysinfo_id[] = {
125
+ 0x04, 0x00, 0x00, 0x00, /* PID4..PID7 */
126
+ 0x58, 0xb8, 0x0b, 0x00, /* PID0..PID3 */
127
+ 0x0d, 0xf0, 0x05, 0xb1, /* CID0..CID3 */
128
+};
129
+
130
+static uint64_t iotkit_sysinfo_read(void *opaque, hwaddr offset,
131
+ unsigned size)
132
+{
133
+ uint64_t r;
134
+
135
+ switch (offset) {
136
+ case A_SYS_VERSION:
137
+ r = 0x41743;
138
+ break;
62
+ break;
139
+
63
+
140
+ case A_SYS_CONFIG:
64
+ case 0x14: /* MLS */
141
+ r = 0x31;
65
+ if (!is_long && !is_scalar) {
66
+ static gen_helper_gvec_4 * const fns[3] = {
67
+ gen_helper_gvec_mls_idx_h,
68
+ gen_helper_gvec_mls_idx_s,
69
+ gen_helper_gvec_mls_idx_d,
70
+ };
71
+ tcg_gen_gvec_4_ool(vec_full_reg_offset(s, rd),
72
+ vec_full_reg_offset(s, rn),
73
+ vec_full_reg_offset(s, rm),
74
+ vec_full_reg_offset(s, rd),
75
+ is_q ? 16 : 8, vec_full_reg_size(s),
76
+ index, fns[size - 1]);
77
+ return;
78
+ }
142
+ break;
79
+ break;
143
+ case A_PID4 ... A_CID3:
80
}
144
+ r = sysinfo_id[(offset - A_PID4) / 4];
81
145
+ break;
82
if (size == 3) {
146
+ default:
83
diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c
147
+ qemu_log_mask(LOG_GUEST_ERROR,
84
index XXXXXXX..XXXXXXX 100644
148
+ "IoTKit SysInfo read: bad offset %x\n", (int)offset);
85
--- a/target/arm/vec_helper.c
149
+ r = 0;
86
+++ b/target/arm/vec_helper.c
150
+ break;
87
@@ -XXX,XX +XXX,XX @@ DO_MUL_IDX(gvec_mul_idx_d, uint64_t, )
151
+ }
88
152
+ trace_iotkit_sysinfo_read(offset, r, size);
89
#undef DO_MUL_IDX
153
+ return r;
90
91
+#define DO_MLA_IDX(NAME, TYPE, OP, H) \
92
+void HELPER(NAME)(void *vd, void *vn, void *vm, void *va, uint32_t desc) \
93
+{ \
94
+ intptr_t i, j, oprsz = simd_oprsz(desc), segment = 16 / sizeof(TYPE); \
95
+ intptr_t idx = simd_data(desc); \
96
+ TYPE *d = vd, *n = vn, *m = vm, *a = va; \
97
+ for (i = 0; i < oprsz / sizeof(TYPE); i += segment) { \
98
+ TYPE mm = m[H(i + idx)]; \
99
+ for (j = 0; j < segment; j++) { \
100
+ d[i + j] = a[i + j] OP n[i + j] * mm; \
101
+ } \
102
+ } \
103
+ clear_tail(d, oprsz, simd_maxsz(desc)); \
154
+}
104
+}
155
+
105
+
156
+static void iotkit_sysinfo_write(void *opaque, hwaddr offset,
106
+DO_MLA_IDX(gvec_mla_idx_h, uint16_t, +, H2)
157
+ uint64_t value, unsigned size)
107
+DO_MLA_IDX(gvec_mla_idx_s, uint32_t, +, H4)
158
+{
108
+DO_MLA_IDX(gvec_mla_idx_d, uint64_t, +, )
159
+ trace_iotkit_sysinfo_write(offset, value, size);
160
+
109
+
161
+ qemu_log_mask(LOG_GUEST_ERROR,
110
+DO_MLA_IDX(gvec_mls_idx_h, uint16_t, -, H2)
162
+ "IoTKit SysInfo: write to RO offset 0x%x\n", (int)offset);
111
+DO_MLA_IDX(gvec_mls_idx_s, uint32_t, -, H4)
163
+}
112
+DO_MLA_IDX(gvec_mls_idx_d, uint64_t, -, )
164
+
113
+
165
+static const MemoryRegionOps iotkit_sysinfo_ops = {
114
+#undef DO_MLA_IDX
166
+ .read = iotkit_sysinfo_read,
167
+ .write = iotkit_sysinfo_write,
168
+ .endianness = DEVICE_LITTLE_ENDIAN,
169
+ /* byte/halfword accesses are just zero-padded on reads and writes */
170
+ .impl.min_access_size = 4,
171
+ .impl.max_access_size = 4,
172
+ .valid.min_access_size = 1,
173
+ .valid.max_access_size = 4,
174
+};
175
+
115
+
176
+static void iotkit_sysinfo_init(Object *obj)
116
#define DO_FMUL_IDX(NAME, TYPE, H) \
177
+{
117
void HELPER(NAME)(void *vd, void *vn, void *vm, void *stat, uint32_t desc) \
178
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
118
{ \
179
+ IoTKitSysInfo *s = IOTKIT_SYSINFO(obj);
180
+
181
+ memory_region_init_io(&s->iomem, obj, &iotkit_sysinfo_ops,
182
+ s, "iotkit-sysinfo", 0x1000);
183
+ sysbus_init_mmio(sbd, &s->iomem);
184
+}
185
+
186
+static void iotkit_sysinfo_class_init(ObjectClass *klass, void *data)
187
+{
188
+ /*
189
+ * This device has no guest-modifiable state and so it
190
+ * does not need a reset function or VMState.
191
+ */
192
+}
193
+
194
+static const TypeInfo iotkit_sysinfo_info = {
195
+ .name = TYPE_IOTKIT_SYSINFO,
196
+ .parent = TYPE_SYS_BUS_DEVICE,
197
+ .instance_size = sizeof(IoTKitSysInfo),
198
+ .instance_init = iotkit_sysinfo_init,
199
+ .class_init = iotkit_sysinfo_class_init,
200
+};
201
+
202
+static void iotkit_sysinfo_register_types(void)
203
+{
204
+ type_register_static(&iotkit_sysinfo_info);
205
+}
206
+
207
+type_init(iotkit_sysinfo_register_types);
208
diff --git a/MAINTAINERS b/MAINTAINERS
209
index XXXXXXX..XXXXXXX 100644
210
--- a/MAINTAINERS
211
+++ b/MAINTAINERS
212
@@ -XXX,XX +XXX,XX @@ F: hw/arm/iotkit.c
213
F: include/hw/arm/iotkit.h
214
F: hw/misc/iotkit-sysctl.c
215
F: include/hw/misc/iotkit-sysctl.h
216
+F: hw/misc/iotkit-sysinfo.c
217
+F: include/hw/misc/iotkit-sysinfo.h
218
219
Musicpal
220
M: Jan Kiszka <jan.kiszka@web.de>
221
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
222
index XXXXXXX..XXXXXXX 100644
223
--- a/default-configs/arm-softmmu.mak
224
+++ b/default-configs/arm-softmmu.mak
225
@@ -XXX,XX +XXX,XX @@ CONFIG_TZ_PPC=y
226
CONFIG_IOTKIT=y
227
CONFIG_IOTKIT_SECCTL=y
228
CONFIG_IOTKIT_SYSCTL=y
229
+CONFIG_IOTKIT_SYSINFO=y
230
231
CONFIG_VERSATILE=y
232
CONFIG_VERSATILE_PCI=y
233
--
119
--
234
2.18.0
120
2.20.1
235
121
236
122
diff view generated by jsdifflib
1
The Arm IoTKit includes a system control element which
1
From: Richard Henderson <richard.henderson@linaro.org>
2
provides a block of read-only ID registers and a block
3
of read-write control registers. Implement a minimal
4
version of this.
5
2
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Message-id: 20200815013145.539409-21-richard.henderson@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20180820141116.9118-9-peter.maydell@linaro.org
9
---
7
---
10
hw/misc/Makefile.objs | 1 +
8
target/arm/helper.h | 10 ++++++++
11
include/hw/misc/iotkit-sysctl.h | 49 ++++++
9
target/arm/translate-a64.c | 33 ++++++++++++++++++--------
12
hw/misc/iotkit-sysctl.c | 261 ++++++++++++++++++++++++++++++++
10
target/arm/vec_helper.c | 48 ++++++++++++++++++++++++++++++++++++++
13
MAINTAINERS | 2 +
11
3 files changed, 81 insertions(+), 10 deletions(-)
14
default-configs/arm-softmmu.mak | 1 +
15
hw/misc/trace-events | 7 +
16
6 files changed, 321 insertions(+)
17
create mode 100644 include/hw/misc/iotkit-sysctl.h
18
create mode 100644 hw/misc/iotkit-sysctl.c
19
12
20
diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs
13
diff --git a/target/arm/helper.h b/target/arm/helper.h
21
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/misc/Makefile.objs
15
--- a/target/arm/helper.h
23
+++ b/hw/misc/Makefile.objs
16
+++ b/target/arm/helper.h
24
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_MPS2_SCC) += mps2-scc.o
17
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(gvec_mls_idx_s, TCG_CALL_NO_RWG,
25
obj-$(CONFIG_TZ_MPC) += tz-mpc.o
18
DEF_HELPER_FLAGS_5(gvec_mls_idx_d, TCG_CALL_NO_RWG,
26
obj-$(CONFIG_TZ_PPC) += tz-ppc.o
19
void, ptr, ptr, ptr, ptr, i32)
27
obj-$(CONFIG_IOTKIT_SECCTL) += iotkit-secctl.o
20
28
+obj-$(CONFIG_IOTKIT_SYSCTL) += iotkit-sysctl.o
21
+DEF_HELPER_FLAGS_5(neon_sqdmulh_h, TCG_CALL_NO_RWG,
29
22
+ void, ptr, ptr, ptr, ptr, i32)
30
obj-$(CONFIG_PVPANIC) += pvpanic.o
23
+DEF_HELPER_FLAGS_5(neon_sqdmulh_s, TCG_CALL_NO_RWG,
31
obj-$(CONFIG_HYPERV_TESTDEV) += hyperv_testdev.o
24
+ void, ptr, ptr, ptr, ptr, i32)
32
diff --git a/include/hw/misc/iotkit-sysctl.h b/include/hw/misc/iotkit-sysctl.h
33
new file mode 100644
34
index XXXXXXX..XXXXXXX
35
--- /dev/null
36
+++ b/include/hw/misc/iotkit-sysctl.h
37
@@ -XXX,XX +XXX,XX @@
38
+/*
39
+ * ARM IoTKit system control element
40
+ *
41
+ * Copyright (c) 2018 Linaro Limited
42
+ * Written by Peter Maydell
43
+ *
44
+ * This program is free software; you can redistribute it and/or modify
45
+ * it under the terms of the GNU General Public License version 2 or
46
+ * (at your option) any later version.
47
+ */
48
+
25
+
49
+/*
26
+DEF_HELPER_FLAGS_5(neon_sqrdmulh_h, TCG_CALL_NO_RWG,
50
+ * This is a model of the "system control element" which is part of the
27
+ void, ptr, ptr, ptr, ptr, i32)
51
+ * Arm IoTKit and documented in
28
+DEF_HELPER_FLAGS_5(neon_sqrdmulh_s, TCG_CALL_NO_RWG,
52
+ * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ecm0601256/index.html
29
+ void, ptr, ptr, ptr, ptr, i32)
53
+ * Specifically, it implements the "system information block" and
54
+ * "system control register" blocks.
55
+ *
56
+ * QEMU interface:
57
+ * + sysbus MMIO region 0: the system information register bank
58
+ * + sysbus MMIO region 1: the system control register bank
59
+ */
60
+
30
+
61
+#ifndef HW_MISC_IOTKIT_SYSCTL_H
31
#ifdef TARGET_AARCH64
62
+#define HW_MISC_IOTKIT_SYSCTL_H
32
#include "helper-a64.h"
33
#include "helper-sve.h"
34
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
35
index XXXXXXX..XXXXXXX 100644
36
--- a/target/arm/translate-a64.c
37
+++ b/target/arm/translate-a64.c
38
@@ -XXX,XX +XXX,XX @@ static void gen_gvec_op3_fpst(DisasContext *s, bool is_q, int rd, int rn,
39
tcg_temp_free_ptr(fpst);
40
}
41
42
+/* Expand a 3-operand + qc + operation using an out-of-line helper. */
43
+static void gen_gvec_op3_qc(DisasContext *s, bool is_q, int rd, int rn,
44
+ int rm, gen_helper_gvec_3_ptr *fn)
45
+{
46
+ TCGv_ptr qc_ptr = tcg_temp_new_ptr();
63
+
47
+
64
+#include "hw/sysbus.h"
48
+ tcg_gen_addi_ptr(qc_ptr, cpu_env, offsetof(CPUARMState, vfp.qc));
65
+
49
+ tcg_gen_gvec_3_ptr(vec_full_reg_offset(s, rd),
66
+#define TYPE_IOTKIT_SYSCTL "iotkit-sysctl"
50
+ vec_full_reg_offset(s, rn),
67
+#define IOTKIT_SYSCTL(obj) OBJECT_CHECK(IoTKitSysCtl, (obj), \
51
+ vec_full_reg_offset(s, rm), qc_ptr,
68
+ TYPE_IOTKIT_SYSCTL)
52
+ is_q ? 16 : 8, vec_full_reg_size(s), 0, fn);
69
+
53
+ tcg_temp_free_ptr(qc_ptr);
70
+typedef struct IoTKitSysCtl {
71
+ /*< private >*/
72
+ SysBusDevice parent_obj;
73
+
74
+ /*< public >*/
75
+ MemoryRegion iomem;
76
+
77
+ uint32_t secure_debug;
78
+ uint32_t reset_syndrome;
79
+ uint32_t reset_mask;
80
+ uint32_t gretreg;
81
+ uint32_t initsvrtor0;
82
+ uint32_t cpuwait;
83
+ uint32_t wicctrl;
84
+} IoTKitSysCtl;
85
+
86
+#endif
87
diff --git a/hw/misc/iotkit-sysctl.c b/hw/misc/iotkit-sysctl.c
88
new file mode 100644
89
index XXXXXXX..XXXXXXX
90
--- /dev/null
91
+++ b/hw/misc/iotkit-sysctl.c
92
@@ -XXX,XX +XXX,XX @@
93
+/*
94
+ * ARM IoTKit system control element
95
+ *
96
+ * Copyright (c) 2018 Linaro Limited
97
+ * Written by Peter Maydell
98
+ *
99
+ * This program is free software; you can redistribute it and/or modify
100
+ * it under the terms of the GNU General Public License version 2 or
101
+ * (at your option) any later version.
102
+ */
103
+
104
+/*
105
+ * This is a model of the "system control element" which is part of the
106
+ * Arm IoTKit and documented in
107
+ * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ecm0601256/index.html
108
+ * Specifically, it implements the "system control register" blocks.
109
+ */
110
+
111
+#include "qemu/osdep.h"
112
+#include "qemu/log.h"
113
+#include "trace.h"
114
+#include "qapi/error.h"
115
+#include "sysemu/sysemu.h"
116
+#include "hw/sysbus.h"
117
+#include "hw/registerfields.h"
118
+#include "hw/misc/iotkit-sysctl.h"
119
+
120
+REG32(SECDBGSTAT, 0x0)
121
+REG32(SECDBGSET, 0x4)
122
+REG32(SECDBGCLR, 0x8)
123
+REG32(RESET_SYNDROME, 0x100)
124
+REG32(RESET_MASK, 0x104)
125
+REG32(SWRESET, 0x108)
126
+ FIELD(SWRESET, SWRESETREQ, 9, 1)
127
+REG32(GRETREG, 0x10c)
128
+REG32(INITSVRTOR0, 0x110)
129
+REG32(CPUWAIT, 0x118)
130
+REG32(BUSWAIT, 0x11c)
131
+REG32(WICCTRL, 0x120)
132
+REG32(PID4, 0xfd0)
133
+REG32(PID5, 0xfd4)
134
+REG32(PID6, 0xfd8)
135
+REG32(PID7, 0xfdc)
136
+REG32(PID0, 0xfe0)
137
+REG32(PID1, 0xfe4)
138
+REG32(PID2, 0xfe8)
139
+REG32(PID3, 0xfec)
140
+REG32(CID0, 0xff0)
141
+REG32(CID1, 0xff4)
142
+REG32(CID2, 0xff8)
143
+REG32(CID3, 0xffc)
144
+
145
+/* PID/CID values */
146
+static const int sysctl_id[] = {
147
+ 0x04, 0x00, 0x00, 0x00, /* PID4..PID7 */
148
+ 0x54, 0xb8, 0x0b, 0x00, /* PID0..PID3 */
149
+ 0x0d, 0xf0, 0x05, 0xb1, /* CID0..CID3 */
150
+};
151
+
152
+static uint64_t iotkit_sysctl_read(void *opaque, hwaddr offset,
153
+ unsigned size)
154
+{
155
+ IoTKitSysCtl *s = IOTKIT_SYSCTL(opaque);
156
+ uint64_t r;
157
+
158
+ switch (offset) {
159
+ case A_SECDBGSTAT:
160
+ r = s->secure_debug;
161
+ break;
162
+ case A_RESET_SYNDROME:
163
+ r = s->reset_syndrome;
164
+ break;
165
+ case A_RESET_MASK:
166
+ r = s->reset_mask;
167
+ break;
168
+ case A_GRETREG:
169
+ r = s->gretreg;
170
+ break;
171
+ case A_INITSVRTOR0:
172
+ r = s->initsvrtor0;
173
+ break;
174
+ case A_CPUWAIT:
175
+ r = s->cpuwait;
176
+ break;
177
+ case A_BUSWAIT:
178
+ /* In IoTKit BUSWAIT is reserved, R/O, zero */
179
+ r = 0;
180
+ break;
181
+ case A_WICCTRL:
182
+ r = s->wicctrl;
183
+ break;
184
+ case A_PID4 ... A_CID3:
185
+ r = sysctl_id[(offset - A_PID4) / 4];
186
+ break;
187
+ case A_SECDBGSET:
188
+ case A_SECDBGCLR:
189
+ case A_SWRESET:
190
+ qemu_log_mask(LOG_GUEST_ERROR,
191
+ "IoTKit SysCtl read: read of WO offset %x\n",
192
+ (int)offset);
193
+ r = 0;
194
+ break;
195
+ default:
196
+ qemu_log_mask(LOG_GUEST_ERROR,
197
+ "IoTKit SysCtl read: bad offset %x\n", (int)offset);
198
+ r = 0;
199
+ break;
200
+ }
201
+ trace_iotkit_sysctl_read(offset, r, size);
202
+ return r;
203
+}
54
+}
204
+
55
+
205
+static void iotkit_sysctl_write(void *opaque, hwaddr offset,
56
/* Set ZF and NF based on a 64 bit result. This is alas fiddlier
206
+ uint64_t value, unsigned size)
57
* than the 32 bit equivalent.
58
*/
59
@@ -XXX,XX +XXX,XX @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn)
60
gen_gvec_fn3(s, is_q, rd, rn, rm, gen_gvec_mla, size);
61
}
62
return;
63
+ case 0x16: /* SQDMULH, SQRDMULH */
64
+ {
65
+ static gen_helper_gvec_3_ptr * const fns[2][2] = {
66
+ { gen_helper_neon_sqdmulh_h, gen_helper_neon_sqrdmulh_h },
67
+ { gen_helper_neon_sqdmulh_s, gen_helper_neon_sqrdmulh_s },
68
+ };
69
+ gen_gvec_op3_qc(s, is_q, rd, rn, rm, fns[size - 1][u]);
70
+ }
71
+ return;
72
case 0x11:
73
if (!u) { /* CMTST */
74
gen_gvec_fn3(s, is_q, rd, rn, rm, gen_gvec_cmtst, size);
75
@@ -XXX,XX +XXX,XX @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn)
76
genenvfn = fns[size][u];
77
break;
78
}
79
- case 0x16: /* SQDMULH, SQRDMULH */
80
- {
81
- static NeonGenTwoOpEnvFn * const fns[2][2] = {
82
- { gen_helper_neon_qdmulh_s16, gen_helper_neon_qrdmulh_s16 },
83
- { gen_helper_neon_qdmulh_s32, gen_helper_neon_qrdmulh_s32 },
84
- };
85
- assert(size == 1 || size == 2);
86
- genenvfn = fns[size - 1][u];
87
- break;
88
- }
89
default:
90
g_assert_not_reached();
91
}
92
diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c
93
index XXXXXXX..XXXXXXX 100644
94
--- a/target/arm/vec_helper.c
95
+++ b/target/arm/vec_helper.c
96
@@ -XXX,XX +XXX,XX @@ void HELPER(gvec_qrdmlsh_s16)(void *vd, void *vn, void *vm,
97
clear_tail(d, opr_sz, simd_maxsz(desc));
98
}
99
100
+void HELPER(neon_sqdmulh_h)(void *vd, void *vn, void *vm,
101
+ void *vq, uint32_t desc)
207
+{
102
+{
208
+ IoTKitSysCtl *s = IOTKIT_SYSCTL(opaque);
103
+ intptr_t i, opr_sz = simd_oprsz(desc);
104
+ int16_t *d = vd, *n = vn, *m = vm;
209
+
105
+
210
+ trace_iotkit_sysctl_write(offset, value, size);
106
+ for (i = 0; i < opr_sz / 2; ++i) {
211
+
107
+ d[i] = do_sqrdmlah_h(n[i], m[i], 0, false, false, vq);
212
+ /*
213
+ * Most of the state here has to do with control of reset and
214
+ * similar kinds of power up -- for instance the guest can ask
215
+ * what the reason for the last reset was, or forbid reset for
216
+ * some causes (like the non-secure watchdog). Most of this is
217
+ * not relevant to QEMU, which doesn't really model anything other
218
+ * than a full power-on reset.
219
+ * We just model the registers as reads-as-written.
220
+ */
221
+
222
+ switch (offset) {
223
+ case A_RESET_SYNDROME:
224
+ qemu_log_mask(LOG_UNIMP,
225
+ "IoTKit SysCtl RESET_SYNDROME unimplemented\n");
226
+ s->reset_syndrome = value;
227
+ break;
228
+ case A_RESET_MASK:
229
+ qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl RESET_MASK unimplemented\n");
230
+ s->reset_mask = value;
231
+ break;
232
+ case A_GRETREG:
233
+ /*
234
+ * General retention register, which is only reset by a power-on
235
+ * reset. Technically this implementation is complete, since
236
+ * QEMU only supports power-on resets...
237
+ */
238
+ s->gretreg = value;
239
+ break;
240
+ case A_INITSVRTOR0:
241
+ qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl INITSVRTOR0 unimplemented\n");
242
+ s->initsvrtor0 = value;
243
+ break;
244
+ case A_CPUWAIT:
245
+ qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl CPUWAIT unimplemented\n");
246
+ s->cpuwait = value;
247
+ break;
248
+ case A_WICCTRL:
249
+ qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl WICCTRL unimplemented\n");
250
+ s->wicctrl = value;
251
+ break;
252
+ case A_SECDBGSET:
253
+ /* write-1-to-set */
254
+ qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl SECDBGSET unimplemented\n");
255
+ s->secure_debug |= value;
256
+ break;
257
+ case A_SECDBGCLR:
258
+ /* write-1-to-clear */
259
+ s->secure_debug &= ~value;
260
+ break;
261
+ case A_SWRESET:
262
+ /* One w/o bit to request a reset; all other bits reserved */
263
+ if (value & R_SWRESET_SWRESETREQ_MASK) {
264
+ qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
265
+ }
266
+ break;
267
+ case A_BUSWAIT: /* In IoTKit BUSWAIT is reserved, R/O, zero */
268
+ case A_SECDBGSTAT:
269
+ case A_PID4 ... A_CID3:
270
+ qemu_log_mask(LOG_GUEST_ERROR,
271
+ "IoTKit SysCtl write: write of RO offset %x\n",
272
+ (int)offset);
273
+ break;
274
+ default:
275
+ qemu_log_mask(LOG_GUEST_ERROR,
276
+ "IoTKit SysCtl write: bad offset %x\n", (int)offset);
277
+ break;
278
+ }
108
+ }
109
+ clear_tail(d, opr_sz, simd_maxsz(desc));
279
+}
110
+}
280
+
111
+
281
+static const MemoryRegionOps iotkit_sysctl_ops = {
112
+void HELPER(neon_sqrdmulh_h)(void *vd, void *vn, void *vm,
282
+ .read = iotkit_sysctl_read,
113
+ void *vq, uint32_t desc)
283
+ .write = iotkit_sysctl_write,
114
+{
284
+ .endianness = DEVICE_LITTLE_ENDIAN,
115
+ intptr_t i, opr_sz = simd_oprsz(desc);
285
+ /* byte/halfword accesses are just zero-padded on reads and writes */
116
+ int16_t *d = vd, *n = vn, *m = vm;
286
+ .impl.min_access_size = 4,
287
+ .impl.max_access_size = 4,
288
+ .valid.min_access_size = 1,
289
+ .valid.max_access_size = 4,
290
+};
291
+
117
+
292
+static void iotkit_sysctl_reset(DeviceState *dev)
118
+ for (i = 0; i < opr_sz / 2; ++i) {
293
+{
119
+ d[i] = do_sqrdmlah_h(n[i], m[i], 0, false, true, vq);
294
+ IoTKitSysCtl *s = IOTKIT_SYSCTL(dev);
120
+ }
295
+
121
+ clear_tail(d, opr_sz, simd_maxsz(desc));
296
+ trace_iotkit_sysctl_reset();
297
+ s->secure_debug = 0;
298
+ s->reset_syndrome = 1;
299
+ s->reset_mask = 0;
300
+ s->gretreg = 0;
301
+ s->initsvrtor0 = 0x10000000;
302
+ s->cpuwait = 0;
303
+ s->wicctrl = 0;
304
+}
122
+}
305
+
123
+
306
+static void iotkit_sysctl_init(Object *obj)
124
/* Signed saturating rounding doubling multiply-accumulate high half, 32-bit */
125
static int32_t do_sqrdmlah_s(int32_t src1, int32_t src2, int32_t src3,
126
bool neg, bool round, uint32_t *sat)
127
@@ -XXX,XX +XXX,XX @@ void HELPER(gvec_qrdmlsh_s32)(void *vd, void *vn, void *vm,
128
clear_tail(d, opr_sz, simd_maxsz(desc));
129
}
130
131
+void HELPER(neon_sqdmulh_s)(void *vd, void *vn, void *vm,
132
+ void *vq, uint32_t desc)
307
+{
133
+{
308
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
134
+ intptr_t i, opr_sz = simd_oprsz(desc);
309
+ IoTKitSysCtl *s = IOTKIT_SYSCTL(obj);
135
+ int32_t *d = vd, *n = vn, *m = vm;
310
+
136
+
311
+ memory_region_init_io(&s->iomem, obj, &iotkit_sysctl_ops,
137
+ for (i = 0; i < opr_sz / 4; ++i) {
312
+ s, "iotkit-sysctl", 0x1000);
138
+ d[i] = do_sqrdmlah_s(n[i], m[i], 0, false, false, vq);
313
+ sysbus_init_mmio(sbd, &s->iomem);
139
+ }
140
+ clear_tail(d, opr_sz, simd_maxsz(desc));
314
+}
141
+}
315
+
142
+
316
+static const VMStateDescription iotkit_sysctl_vmstate = {
143
+void HELPER(neon_sqrdmulh_s)(void *vd, void *vn, void *vm,
317
+ .name = "iotkit-sysctl",
144
+ void *vq, uint32_t desc)
318
+ .version_id = 1,
145
+{
319
+ .minimum_version_id = 1,
146
+ intptr_t i, opr_sz = simd_oprsz(desc);
320
+ .fields = (VMStateField[]) {
147
+ int32_t *d = vd, *n = vn, *m = vm;
321
+ VMSTATE_UINT32(secure_debug, IoTKitSysCtl),
148
+
322
+ VMSTATE_UINT32(reset_syndrome, IoTKitSysCtl),
149
+ for (i = 0; i < opr_sz / 4; ++i) {
323
+ VMSTATE_UINT32(reset_mask, IoTKitSysCtl),
150
+ d[i] = do_sqrdmlah_s(n[i], m[i], 0, false, true, vq);
324
+ VMSTATE_UINT32(gretreg, IoTKitSysCtl),
325
+ VMSTATE_UINT32(initsvrtor0, IoTKitSysCtl),
326
+ VMSTATE_UINT32(cpuwait, IoTKitSysCtl),
327
+ VMSTATE_UINT32(wicctrl, IoTKitSysCtl),
328
+ VMSTATE_END_OF_LIST()
329
+ }
151
+ }
330
+};
152
+ clear_tail(d, opr_sz, simd_maxsz(desc));
331
+
332
+static void iotkit_sysctl_class_init(ObjectClass *klass, void *data)
333
+{
334
+ DeviceClass *dc = DEVICE_CLASS(klass);
335
+
336
+ dc->vmsd = &iotkit_sysctl_vmstate;
337
+ dc->reset = iotkit_sysctl_reset;
338
+}
153
+}
339
+
154
+
340
+static const TypeInfo iotkit_sysctl_info = {
155
/* Integer 8 and 16-bit dot-product.
341
+ .name = TYPE_IOTKIT_SYSCTL,
156
*
342
+ .parent = TYPE_SYS_BUS_DEVICE,
157
* Note that for the loops herein, host endianness does not matter
343
+ .instance_size = sizeof(IoTKitSysCtl),
344
+ .instance_init = iotkit_sysctl_init,
345
+ .class_init = iotkit_sysctl_class_init,
346
+};
347
+
348
+static void iotkit_sysctl_register_types(void)
349
+{
350
+ type_register_static(&iotkit_sysctl_info);
351
+}
352
+
353
+type_init(iotkit_sysctl_register_types);
354
diff --git a/MAINTAINERS b/MAINTAINERS
355
index XXXXXXX..XXXXXXX 100644
356
--- a/MAINTAINERS
357
+++ b/MAINTAINERS
358
@@ -XXX,XX +XXX,XX @@ F: hw/misc/mps2-*.c
359
F: include/hw/misc/mps2-*.h
360
F: hw/arm/iotkit.c
361
F: include/hw/arm/iotkit.h
362
+F: hw/misc/iotkit-sysctl.c
363
+F: include/hw/misc/iotkit-sysctl.h
364
365
Musicpal
366
M: Jan Kiszka <jan.kiszka@web.de>
367
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
368
index XXXXXXX..XXXXXXX 100644
369
--- a/default-configs/arm-softmmu.mak
370
+++ b/default-configs/arm-softmmu.mak
371
@@ -XXX,XX +XXX,XX @@ CONFIG_TZ_MPC=y
372
CONFIG_TZ_PPC=y
373
CONFIG_IOTKIT=y
374
CONFIG_IOTKIT_SECCTL=y
375
+CONFIG_IOTKIT_SYSCTL=y
376
377
CONFIG_VERSATILE=y
378
CONFIG_VERSATILE_PCI=y
379
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
380
index XXXXXXX..XXXXXXX 100644
381
--- a/hw/misc/trace-events
382
+++ b/hw/misc/trace-events
383
@@ -XXX,XX +XXX,XX @@ ccm_freq(uint32_t freq) "freq = %d\n"
384
ccm_clock_freq(uint32_t clock, uint32_t freq) "(Clock = %d) = %d\n"
385
ccm_read_reg(const char *reg_name, uint32_t value) "reg[%s] <= 0x%" PRIx32 "\n"
386
ccm_write_reg(const char *reg_name, uint32_t value) "reg[%s] => 0x%" PRIx32 "\n"
387
+
388
+# hw/misc/iotkit-sysctl.c
389
+iotkit_sysinfo_read(uint64_t offset, uint64_t data, unsigned size) "IoTKit SysInfo read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
390
+iotkit_sysinfo_write(uint64_t offset, uint64_t data, unsigned size) "IoTKit SysInfo write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
391
+iotkit_sysctl_read(uint64_t offset, uint64_t data, unsigned size) "IoTKit SysCtl read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
392
+iotkit_sysctl_write(uint64_t offset, uint64_t data, unsigned size) "IoTKit SysCtl write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
393
+iotkit_sysctl_reset(void) "IoTKit SysCtl: reset"
394
--
158
--
395
2.18.0
159
2.20.1
396
160
397
161
diff view generated by jsdifflib
Deleted patch
1
Wire up the system control element's register banks
2
(sysctl and sysinfo).
3
1
4
This is the last of the previously completely unimplemented
5
components in the IoTKit.
6
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20180820141116.9118-11-peter.maydell@linaro.org
11
---
12
include/hw/arm/iotkit.h | 6 +++++-
13
hw/arm/iotkit.c | 26 ++++++++++++++++++--------
14
2 files changed, 23 insertions(+), 9 deletions(-)
15
16
diff --git a/include/hw/arm/iotkit.h b/include/hw/arm/iotkit.h
17
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/arm/iotkit.h
19
+++ b/include/hw/arm/iotkit.h
20
@@ -XXX,XX +XXX,XX @@
21
#include "hw/timer/cmsdk-apb-timer.h"
22
#include "hw/timer/cmsdk-apb-dualtimer.h"
23
#include "hw/watchdog/cmsdk-apb-watchdog.h"
24
-#include "hw/misc/unimp.h"
25
+#include "hw/misc/iotkit-sysctl.h"
26
+#include "hw/misc/iotkit-sysinfo.h"
27
#include "hw/or-irq.h"
28
#include "hw/core/split-irq.h"
29
30
@@ -XXX,XX +XXX,XX @@ typedef struct IoTKit {
31
CMSDKAPBWatchdog nswatchdog;
32
CMSDKAPBWatchdog swatchdog;
33
34
+ IoTKitSysCtl sysctl;
35
+ IoTKitSysCtl sysinfo;
36
+
37
MemoryRegion container;
38
MemoryRegion alias1;
39
MemoryRegion alias2;
40
diff --git a/hw/arm/iotkit.c b/hw/arm/iotkit.c
41
index XXXXXXX..XXXXXXX 100644
42
--- a/hw/arm/iotkit.c
43
+++ b/hw/arm/iotkit.c
44
@@ -XXX,XX +XXX,XX @@
45
#include "hw/sysbus.h"
46
#include "hw/registerfields.h"
47
#include "hw/arm/iotkit.h"
48
-#include "hw/misc/unimp.h"
49
#include "hw/arm/arm.h"
50
51
/* Clock frequency in HZ of the 32KHz "slow clock" */
52
@@ -XXX,XX +XXX,XX @@ static void iotkit_init(Object *obj)
53
sizeof(s->nswatchdog), TYPE_CMSDK_APB_WATCHDOG);
54
sysbus_init_child_obj(obj, "swatchdog", &s->swatchdog,
55
sizeof(s->swatchdog), TYPE_CMSDK_APB_WATCHDOG);
56
+ sysbus_init_child_obj(obj, "iotkit-sysctl", &s->sysctl,
57
+ sizeof(s->sysctl), TYPE_IOTKIT_SYSCTL);
58
+ sysbus_init_child_obj(obj, "iotkit-sysinfo", &s->sysinfo,
59
+ sizeof(s->sysinfo), TYPE_IOTKIT_SYSINFO);
60
object_initialize_child(obj, "nmi-orgate", &s->nmi_orgate,
61
sizeof(s->nmi_orgate), TYPE_OR_IRQ,
62
&error_abort, NULL);
63
@@ -XXX,XX +XXX,XX @@ static void iotkit_realize(DeviceState *dev, Error **errp)
64
qdev_get_gpio_in_named(dev_apb_ppc1,
65
"cfg_sec_resp", 0));
66
67
- /* Using create_unimplemented_device() maps the stub into the
68
- * system address space rather than into our container, but the
69
- * overall effect to the guest is the same.
70
- */
71
- create_unimplemented_device("SYSINFO", 0x40020000, 0x1000);
72
-
73
- create_unimplemented_device("SYSCONTROL", 0x50021000, 0x1000);
74
+ object_property_set_bool(OBJECT(&s->sysinfo), true, "realized", &err);
75
+ if (err) {
76
+ error_propagate(errp, err);
77
+ return;
78
+ }
79
+ /* System information registers */
80
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->sysinfo), 0, 0x40020000);
81
+ /* System control registers */
82
+ object_property_set_bool(OBJECT(&s->sysctl), true, "realized", &err);
83
+ if (err) {
84
+ error_propagate(errp, err);
85
+ return;
86
+ }
87
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->sysctl), 0, 0x50021000);
88
89
/* This OR gate wires together outputs from the secure watchdogs to NMI */
90
object_property_set_int(OBJECT(&s->nmi_orgate), 2, "num-lines", &err);
91
--
92
2.18.0
93
94
diff view generated by jsdifflib
Deleted patch
1
The IoTKit doesn't have any MSCs itself but it does need
2
some wiring to connect the external signals from MSCs
3
in the outer board model up to the registers and the
4
NVIC IRQ line.
5
1
6
We also need to expose a MemoryRegion corresponding to
7
the AHB bus, so that MSCs in the outer board model can
8
use that as their downstream port. (In the FPGA this is
9
the "AHB Slave Expansion" ports shown in the block
10
diagram in the AN505 documentation.)
11
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
14
Message-id: 20180820141116.9118-14-peter.maydell@linaro.org
15
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
16
---
17
include/hw/arm/iotkit.h | 8 ++++++++
18
hw/arm/iotkit.c | 15 +++++++++++++++
19
2 files changed, 23 insertions(+)
20
21
diff --git a/include/hw/arm/iotkit.h b/include/hw/arm/iotkit.h
22
index XXXXXXX..XXXXXXX 100644
23
--- a/include/hw/arm/iotkit.h
24
+++ b/include/hw/arm/iotkit.h
25
@@ -XXX,XX +XXX,XX @@
26
* + QOM property "EXP_NUMIRQ" sets the number of expansion interrupts
27
* + Named GPIO inputs "EXP_IRQ" 0..n are the expansion interrupts, which
28
* are wired to the NVIC lines 32 .. n+32
29
+ * + sysbus MMIO region 0 is the "AHB Slave Expansion" which allows
30
+ * bus master devices in the board model to make transactions into
31
+ * all the devices and memory areas in the IoTKit
32
* Controlling up to 4 AHB expansion PPBs which a system using the IoTKit
33
* might provide:
34
* + named GPIO outputs apb_ppcexp{0,1,2,3}_nonsec[0..15]
35
@@ -XXX,XX +XXX,XX @@
36
* Controlling each of the 16 expansion MPCs which a system using the IoTKit
37
* might provide:
38
* + named GPIO inputs mpcexp_status[0..15]
39
+ * Controlling each of the 16 expansion MSCs which a system using the IoTKit
40
+ * might provide:
41
+ * + named GPIO inputs mscexp_status[0..15]
42
+ * + named GPIO outputs mscexp_clear[0..15]
43
+ * + named GPIO outputs mscexp_ns[0..15]
44
*/
45
46
#ifndef IOTKIT_H
47
diff --git a/hw/arm/iotkit.c b/hw/arm/iotkit.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/hw/arm/iotkit.c
50
+++ b/hw/arm/iotkit.c
51
@@ -XXX,XX +XXX,XX @@ static void iotkit_realize(DeviceState *dev, Error **errp)
52
53
iotkit_forward_sec_resp_cfg(s);
54
55
+ /* Forward the MSC related signals */
56
+ qdev_pass_gpios(dev_secctl, dev, "mscexp_status");
57
+ qdev_pass_gpios(dev_secctl, dev, "mscexp_clear");
58
+ qdev_pass_gpios(dev_secctl, dev, "mscexp_ns");
59
+ qdev_connect_gpio_out_named(dev_secctl, "msc_irq", 0,
60
+ qdev_get_gpio_in(DEVICE(&s->armv7m), 11));
61
+
62
+ /*
63
+ * Expose our container region to the board model; this corresponds
64
+ * to the AHB Slave Expansion ports which allow bus master devices
65
+ * (eg DMA controllers) in the board model to make transactions into
66
+ * devices in the IoTKit.
67
+ */
68
+ sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->container);
69
+
70
system_clock_scale = NANOSECONDS_PER_SECOND / s->mainclk_frq;
71
}
72
73
--
74
2.18.0
75
76
diff view generated by jsdifflib
Deleted patch
1
Create a new include file for the pl022's device struct,
2
type macros, etc, so that it can be instantiated using
3
the "embedded struct" coding style.
4
1
5
While we're adding the new file to MAINTAINERS, add
6
also the .c file, which was missing an entry.
7
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Message-id: 20180820141116.9118-16-peter.maydell@linaro.org
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
---
13
include/hw/ssi/pl022.h | 51 ++++++++++++++++++++++++++++++++++++++++++
14
hw/ssi/pl022.c | 26 +--------------------
15
MAINTAINERS | 2 ++
16
3 files changed, 54 insertions(+), 25 deletions(-)
17
create mode 100644 include/hw/ssi/pl022.h
18
19
diff --git a/include/hw/ssi/pl022.h b/include/hw/ssi/pl022.h
20
new file mode 100644
21
index XXXXXXX..XXXXXXX
22
--- /dev/null
23
+++ b/include/hw/ssi/pl022.h
24
@@ -XXX,XX +XXX,XX @@
25
+/*
26
+ * ARM PrimeCell PL022 Synchronous Serial Port
27
+ *
28
+ * Copyright (c) 2007 CodeSourcery.
29
+ * Written by Paul Brook
30
+ *
31
+ * This program is free software; you can redistribute it and/or modify
32
+ * it under the terms of the GNU General Public License version 2 or
33
+ * (at your option) any later version.
34
+ */
35
+
36
+/* This is a model of the Arm PrimeCell PL022 synchronous serial port.
37
+ * The PL022 TRM is:
38
+ * http://infocenter.arm.com/help/topic/com.arm.doc.ddi0194h/DDI0194H_ssp_pl022_trm.pdf
39
+ *
40
+ * QEMU interface:
41
+ * + sysbus IRQ: SSPINTR combined interrupt line
42
+ * + sysbus MMIO region 0: MemoryRegion for the device's registers
43
+ */
44
+
45
+#ifndef HW_SSI_PL022_H
46
+#define HW_SSI_PL022_H
47
+
48
+#include "hw/sysbus.h"
49
+
50
+#define TYPE_PL022 "pl022"
51
+#define PL022(obj) OBJECT_CHECK(PL022State, (obj), TYPE_PL022)
52
+
53
+typedef struct PL022State {
54
+ SysBusDevice parent_obj;
55
+
56
+ MemoryRegion iomem;
57
+ uint32_t cr0;
58
+ uint32_t cr1;
59
+ uint32_t bitmask;
60
+ uint32_t sr;
61
+ uint32_t cpsr;
62
+ uint32_t is;
63
+ uint32_t im;
64
+ /* The FIFO head points to the next empty entry. */
65
+ int tx_fifo_head;
66
+ int rx_fifo_head;
67
+ int tx_fifo_len;
68
+ int rx_fifo_len;
69
+ uint16_t tx_fifo[8];
70
+ uint16_t rx_fifo[8];
71
+ qemu_irq irq;
72
+ SSIBus *ssi;
73
+} PL022State;
74
+
75
+#endif
76
diff --git a/hw/ssi/pl022.c b/hw/ssi/pl022.c
77
index XXXXXXX..XXXXXXX 100644
78
--- a/hw/ssi/pl022.c
79
+++ b/hw/ssi/pl022.c
80
@@ -XXX,XX +XXX,XX @@
81
82
#include "qemu/osdep.h"
83
#include "hw/sysbus.h"
84
+#include "hw/ssi/pl022.h"
85
#include "hw/ssi/ssi.h"
86
#include "qemu/log.h"
87
88
@@ -XXX,XX +XXX,XX @@ do { fprintf(stderr, "pl022: error: " fmt , ## __VA_ARGS__);} while (0)
89
#define PL022_INT_RX 0x04
90
#define PL022_INT_TX 0x08
91
92
-#define TYPE_PL022 "pl022"
93
-#define PL022(obj) OBJECT_CHECK(PL022State, (obj), TYPE_PL022)
94
-
95
-typedef struct PL022State {
96
- SysBusDevice parent_obj;
97
-
98
- MemoryRegion iomem;
99
- uint32_t cr0;
100
- uint32_t cr1;
101
- uint32_t bitmask;
102
- uint32_t sr;
103
- uint32_t cpsr;
104
- uint32_t is;
105
- uint32_t im;
106
- /* The FIFO head points to the next empty entry. */
107
- int tx_fifo_head;
108
- int rx_fifo_head;
109
- int tx_fifo_len;
110
- int rx_fifo_len;
111
- uint16_t tx_fifo[8];
112
- uint16_t rx_fifo[8];
113
- qemu_irq irq;
114
- SSIBus *ssi;
115
-} PL022State;
116
-
117
static const unsigned char pl022_id[8] =
118
{ 0x22, 0x10, 0x04, 0x00, 0x0d, 0xf0, 0x05, 0xb1 };
119
120
diff --git a/MAINTAINERS b/MAINTAINERS
121
index XXXXXXX..XXXXXXX 100644
122
--- a/MAINTAINERS
123
+++ b/MAINTAINERS
124
@@ -XXX,XX +XXX,XX @@ F: hw/gpio/pl061.c
125
F: hw/input/pl050.c
126
F: hw/intc/pl190.c
127
F: hw/sd/pl181.c
128
+F: hw/ssi/pl022.c
129
+F: include/hw/ssi/pl022.h
130
F: hw/timer/pl031.c
131
F: include/hw/arm/primecell.h
132
F: hw/timer/cmsdk-apb-timer.c
133
--
134
2.18.0
135
136
diff view generated by jsdifflib
Deleted patch
1
Currently the PL022 calls pl022_reset() from its class init
2
function. Make it register a DeviceState reset method instead,
3
so that we reset the device on system reset.
4
1
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Message-id: 20180820141116.9118-17-peter.maydell@linaro.org
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
---
10
hw/ssi/pl022.c | 7 +++++--
11
1 file changed, 5 insertions(+), 2 deletions(-)
12
13
diff --git a/hw/ssi/pl022.c b/hw/ssi/pl022.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/ssi/pl022.c
16
+++ b/hw/ssi/pl022.c
17
@@ -XXX,XX +XXX,XX @@ static void pl022_write(void *opaque, hwaddr offset,
18
}
19
}
20
21
-static void pl022_reset(PL022State *s)
22
+static void pl022_reset(DeviceState *dev)
23
{
24
+ PL022State *s = PL022(dev);
25
+
26
s->rx_fifo_len = 0;
27
s->tx_fifo_len = 0;
28
s->im = 0;
29
@@ -XXX,XX +XXX,XX @@ static int pl022_init(SysBusDevice *sbd)
30
sysbus_init_mmio(sbd, &s->iomem);
31
sysbus_init_irq(sbd, &s->irq);
32
s->ssi = ssi_create_bus(dev, "ssi");
33
- pl022_reset(s);
34
vmstate_register(dev, -1, &vmstate_pl022, s);
35
return 0;
36
}
37
@@ -XXX,XX +XXX,XX @@ static int pl022_init(SysBusDevice *sbd)
38
static void pl022_class_init(ObjectClass *klass, void *data)
39
{
40
SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
41
+ DeviceClass *dc = DEVICE_CLASS(klass);
42
43
sdc->init = pl022_init;
44
+ dc->reset = pl022_reset;
45
}
46
47
static const TypeInfo pl022_info = {
48
--
49
2.18.0
50
51
diff view generated by jsdifflib