1
target-arm queue: this clears out a bunch of patches I'd sent over
1
The following changes since commit 3db29dcac23da85486704ef9e7a8e7217f7829cd:
2
the last coupled of weeks that have now got reviewed. Mostly
3
this is MPS2 device support improvements, put there is also
4
more of the incremental work towards supporting AArch32 Hyp mode,
5
a floating point bugfix, and the raspi framebuffer viewport support.
6
2
7
thanks
3
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2023-01-12 13:51:36 +0000)
8
-- PMM
9
10
The following changes since commit 5ccac548faf041ff5229a8e8342e3be14a34c8af:
11
12
Merge remote-tracking branch 'remotes/cody/tags/block-pull-request' into staging (2018-08-23 17:35:48 +0100)
13
4
14
are available in the Git repository at:
5
are available in the Git repository at:
15
6
16
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180824
7
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230113
17
8
18
for you to fetch changes up to 30a719e3cb5c5367f3651eba8fa935634bfee286:
9
for you to fetch changes up to 08899b5c68a55a3780d707e2464073c8f2670d31:
19
10
20
hw/arm/mps2: Fix ID register errors on AN511 and AN385 (2018-08-24 10:22:44 +0100)
11
target/arm: allow writes to SCR_EL3.HXEn bit when FEAT_HCX is enabled (2023-01-13 13:19:36 +0000)
21
12
22
----------------------------------------------------------------
13
----------------------------------------------------------------
23
target-arm queue:
14
target-arm queue:
24
* Fix rounding errors in scaling float-to-int and int-to-float operations
15
hw/arm/stm32f405: correctly describe the memory layout
25
* Connect virtualization-related IRQs and memory regions of GICv2
16
hw/arm: Add Olimex H405 board
26
in boards that use Cortex-A7 or Cortex-A15
17
cubieboard: Support booting from an SD card image with u-boot on it
27
* Support taking exceptions to AArch32 Hyp mode
18
target/arm: Fix sve_probe_page
28
* Clear CPSR.IL and CPSR.J on 32-bit exception entry
19
target/arm: allow writes to SCR_EL3.HXEn bit when FEAT_HCX is enabled
29
(a minor bug fix that won't affect non-buggy guest code)
20
various code cleanups
30
* mps2-an505: Implement various missing devices:
31
dual timer, watchdogs, counters in the FPGAIO registers,
32
some missing ID/control registers, TrustZone Master Security
33
Controllers, PL081 DMA controllers, PL022 SPI controllers
34
* correct ID register values for mps2-an385, -an511, -an505
35
* fix some hardcoded tabs in untouched backwaters of the
36
target/arm codebase
37
* raspi: Refactor framebuffer property handling code and implement
38
support for the virtual framebuffer/viewport
39
21
40
----------------------------------------------------------------
22
----------------------------------------------------------------
41
Peter Maydell (48):
23
Evgeny Iakovlev (1):
42
hw/intc/arm_gic: Make per-cpu GICH memory regions 0x200 bytes large
24
target/arm: allow writes to SCR_EL3.HXEn bit when FEAT_HCX is enabled
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
25
91
Richard Henderson (4):
26
Felipe Balbi (2):
92
softfloat: Add scaling int-to-float routines
27
hw/arm/stm32f405: correctly describe the memory layout
93
softfloat: Add scaling float-to-int routines
28
hw/arm: Add Olimex H405
94
target/arm: Use the int-to-float-scale softfloat routines
95
target/arm: Use the float-to-int-scale softfloat routines
96
29
97
hw/misc/Makefile.objs | 3 +
30
Philippe Mathieu-Daudé (27):
98
hw/timer/Makefile.objs | 1 +
31
hw/arm/pxa2xx: Simplify pxa255_init()
99
include/fpu/softfloat.h | 169 +++++++---
32
hw/arm/pxa2xx: Simplify pxa270_init()
100
include/hw/arm/iotkit.h | 25 +-
33
hw/arm/collie: Use the IEC binary prefix definitions
101
include/hw/display/bcm2835_fb.h | 59 +++-
34
hw/arm/collie: Simplify flash creation using for() loop
102
include/hw/misc/iotkit-secctl.h | 14 +
35
hw/arm/gumstix: Improve documentation
103
include/hw/misc/iotkit-sysctl.h | 49 +++
36
hw/arm/gumstix: Use the IEC binary prefix definitions
104
include/hw/misc/iotkit-sysinfo.h | 37 +++
37
hw/arm/mainstone: Use the IEC binary prefix definitions
105
include/hw/misc/mps2-fpgaio.h | 10 +
38
hw/arm/musicpal: Use the IEC binary prefix definitions
106
include/hw/misc/tz-msc.h | 79 +++++
39
hw/arm/omap_sx1: Remove unused 'total_ram' definitions
107
include/hw/ssi/pl022.h | 51 +++
40
hw/arm/omap_sx1: Use the IEC binary prefix definitions
108
include/hw/timer/cmsdk-apb-dualtimer.h | 72 ++++
41
hw/arm/z2: Use the IEC binary prefix definitions
109
target/arm/cpu.h | 16 +-
42
hw/arm/vexpress: Remove dead code in vexpress_common_init()
110
fpu/softfloat.c | 579 ++++++++++++++++++++++++++-------
43
hw/arm: Remove unreachable code calling pflash_cfi01_register()
111
hw/arm/boot.c | 11 +
44
hw/arm/pxa: Avoid forward-declaring PXA2xxI2CState
112
hw/arm/fsl-imx6ul.c | 4 +
45
hw/gpio/omap_gpio: Add local variable to avoid embedded cast
113
hw/arm/fsl-imx7.c | 4 +
46
hw/arm/omap: Drop useless casts from void * to pointer
114
hw/arm/highbank.c | 6 +
47
hw/gpio/omap_gpio: Use CamelCase for TYPE_OMAP1_GPIO type name
115
hw/arm/iotkit.c | 114 ++++++-
48
hw/gpio/omap_gpio: Use CamelCase for TYPE_OMAP2_GPIO type name
116
hw/arm/mps2-tz.c | 142 +++++++-
49
hw/intc/omap_intc: Use CamelCase for TYPE_OMAP_INTC type name
117
hw/arm/mps2.c | 17 +-
50
hw/arm/stellaris: Drop useless casts from void * to pointer
118
hw/arm/vexpress.c | 64 +++-
51
hw/arm/stellaris: Use CamelCase for STELLARIS_ADC type name
119
hw/cpu/a15mpcore.c | 31 +-
52
hw/arm/bcm2836: Remove definitions generated by OBJECT_DECLARE_TYPE()
120
hw/display/bcm2835_fb.c | 218 ++++++++-----
53
hw/arm/npcm7xx: Declare QOM macros using OBJECT_DECLARE_SIMPLE_TYPE()
121
hw/intc/arm_gic.c | 2 +-
54
hw/misc/sbsa_ec: Rename TYPE_SBSA_EC -> TYPE_SBSA_SECURE_EC
122
hw/misc/bcm2835_property.c | 123 ++++---
55
hw/misc/sbsa_ec: Declare QOM macros using OBJECT_DECLARE_SIMPLE_TYPE()
123
hw/misc/iotkit-secctl.c | 73 ++++-
56
hw/intc/xilinx_intc: Use 'XpsIntc' typedef instead of 'struct xlx_pic'
124
hw/misc/iotkit-sysctl.c | 261 +++++++++++++++
57
hw/timer/xilinx_timer: Use XpsTimerState instead of 'struct timerblock'
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
58
59
Richard Henderson (1):
60
target/arm: Fix sve_probe_page
61
62
Strahinja Jankovic (7):
63
hw/misc: Allwinner-A10 Clock Controller Module Emulation
64
hw/misc: Allwinner A10 DRAM Controller Emulation
65
{hw/i2c,docs/system/arm}: Allwinner TWI/I2C Emulation
66
hw/misc: AXP209 PMU Emulation
67
hw/arm: Add AXP209 to Cubieboard
68
hw/arm: Allwinner A10 enable SPL load from MMC
69
tests/avocado: Add SD boot test to Cubieboard
70
71
docs/system/arm/cubieboard.rst | 1 +
72
docs/system/arm/orangepi.rst | 1 +
73
docs/system/arm/stm32.rst | 1 +
74
configs/devices/arm-softmmu/default.mak | 1 +
75
include/hw/adc/npcm7xx_adc.h | 7 +-
76
include/hw/arm/allwinner-a10.h | 27 ++
77
include/hw/arm/allwinner-h3.h | 3 +
78
include/hw/arm/npcm7xx.h | 18 +-
79
include/hw/arm/omap.h | 24 +-
80
include/hw/arm/pxa.h | 11 +-
81
include/hw/arm/stm32f405_soc.h | 5 +-
82
include/hw/i2c/allwinner-i2c.h | 55 ++++
83
include/hw/i2c/npcm7xx_smbus.h | 7 +-
84
include/hw/misc/allwinner-a10-ccm.h | 67 +++++
85
include/hw/misc/allwinner-a10-dramc.h | 68 +++++
86
include/hw/misc/npcm7xx_clk.h | 2 +-
87
include/hw/misc/npcm7xx_gcr.h | 6 +-
88
include/hw/misc/npcm7xx_mft.h | 7 +-
89
include/hw/misc/npcm7xx_pwm.h | 3 +-
90
include/hw/misc/npcm7xx_rng.h | 6 +-
91
include/hw/net/npcm7xx_emc.h | 5 +-
92
include/hw/sd/npcm7xx_sdhci.h | 4 +-
93
hw/arm/allwinner-a10.c | 40 +++
94
hw/arm/allwinner-h3.c | 11 +-
95
hw/arm/bcm2836.c | 9 +-
96
hw/arm/collie.c | 25 +-
97
hw/arm/cubieboard.c | 11 +
98
hw/arm/gumstix.c | 45 ++--
99
hw/arm/mainstone.c | 37 ++-
100
hw/arm/musicpal.c | 9 +-
101
hw/arm/olimex-stm32-h405.c | 69 +++++
102
hw/arm/omap1.c | 115 ++++----
103
hw/arm/omap2.c | 40 ++-
104
hw/arm/omap_sx1.c | 53 ++--
105
hw/arm/palm.c | 2 +-
106
hw/arm/pxa2xx.c | 8 +-
107
hw/arm/spitz.c | 6 +-
108
hw/arm/stellaris.c | 73 +++--
109
hw/arm/stm32f405_soc.c | 8 +
110
hw/arm/tosa.c | 2 +-
111
hw/arm/versatilepb.c | 6 +-
112
hw/arm/vexpress.c | 10 +-
113
hw/arm/z2.c | 16 +-
114
hw/char/omap_uart.c | 7 +-
115
hw/display/omap_dss.c | 15 +-
116
hw/display/omap_lcdc.c | 9 +-
117
hw/dma/omap_dma.c | 15 +-
118
hw/gpio/omap_gpio.c | 48 ++--
119
hw/i2c/allwinner-i2c.c | 459 ++++++++++++++++++++++++++++++++
120
hw/intc/omap_intc.c | 38 +--
121
hw/intc/xilinx_intc.c | 28 +-
122
hw/misc/allwinner-a10-ccm.c | 224 ++++++++++++++++
123
hw/misc/allwinner-a10-dramc.c | 179 +++++++++++++
124
hw/misc/axp209.c | 238 +++++++++++++++++
125
hw/misc/omap_gpmc.c | 12 +-
126
hw/misc/omap_l4.c | 7 +-
127
hw/misc/omap_sdrc.c | 7 +-
128
hw/misc/omap_tap.c | 5 +-
129
hw/misc/sbsa_ec.c | 12 +-
130
hw/sd/omap_mmc.c | 9 +-
131
hw/ssi/omap_spi.c | 7 +-
132
hw/timer/omap_gptimer.c | 22 +-
133
hw/timer/omap_synctimer.c | 4 +-
134
hw/timer/xilinx_timer.c | 27 +-
135
target/arm/helper.c | 3 +
136
target/arm/sve_helper.c | 14 +-
137
MAINTAINERS | 8 +
138
hw/arm/Kconfig | 9 +
139
hw/arm/meson.build | 1 +
140
hw/i2c/Kconfig | 4 +
141
hw/i2c/meson.build | 1 +
142
hw/i2c/trace-events | 5 +
143
hw/misc/Kconfig | 10 +
144
hw/misc/meson.build | 3 +
145
hw/misc/trace-events | 5 +
146
tests/avocado/boot_linux_console.py | 47 ++++
147
76 files changed, 1951 insertions(+), 455 deletions(-)
148
create mode 100644 include/hw/i2c/allwinner-i2c.h
149
create mode 100644 include/hw/misc/allwinner-a10-ccm.h
150
create mode 100644 include/hw/misc/allwinner-a10-dramc.h
151
create mode 100644 hw/arm/olimex-stm32-h405.c
152
create mode 100644 hw/i2c/allwinner-i2c.c
153
create mode 100644 hw/misc/allwinner-a10-ccm.c
154
create mode 100644 hw/misc/allwinner-a10-dramc.c
155
create mode 100644 hw/misc/axp209.c
156
diff view generated by jsdifflib
1
Wire up the system control element's register banks
1
From: Felipe Balbi <balbi@kernel.org>
2
(sysctl and sysinfo).
3
2
4
This is the last of the previously completely unimplemented
3
STM32F405 has 128K of SRAM and another 64K of CCM (Core-coupled
5
components in the IoTKit.
4
Memory) at a different base address. Correctly describe the memory
5
layout to give existing FW images a chance to run unmodified.
6
6
7
Reviewed-by: Alistair Francis <alistair@alistair23.me>
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Signed-off-by: Felipe Balbi <balbi@kernel.org>
10
Message-id: 20221230145733.200496-2-balbi@kernel.org
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
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
---
12
include/hw/arm/iotkit.h | 6 +++++-
13
include/hw/arm/stm32f405_soc.h | 5 ++++-
13
hw/arm/iotkit.c | 26 ++++++++++++++++++--------
14
hw/arm/stm32f405_soc.c | 8 ++++++++
14
2 files changed, 23 insertions(+), 9 deletions(-)
15
2 files changed, 12 insertions(+), 1 deletion(-)
15
16
16
diff --git a/include/hw/arm/iotkit.h b/include/hw/arm/iotkit.h
17
diff --git a/include/hw/arm/stm32f405_soc.h b/include/hw/arm/stm32f405_soc.h
17
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/arm/iotkit.h
19
--- a/include/hw/arm/stm32f405_soc.h
19
+++ b/include/hw/arm/iotkit.h
20
+++ b/include/hw/arm/stm32f405_soc.h
20
@@ -XXX,XX +XXX,XX @@
21
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(STM32F405State, STM32F405_SOC)
21
#include "hw/timer/cmsdk-apb-timer.h"
22
#define FLASH_BASE_ADDRESS 0x08000000
22
#include "hw/timer/cmsdk-apb-dualtimer.h"
23
#define FLASH_SIZE (1024 * 1024)
23
#include "hw/watchdog/cmsdk-apb-watchdog.h"
24
#define SRAM_BASE_ADDRESS 0x20000000
24
-#include "hw/misc/unimp.h"
25
-#define SRAM_SIZE (192 * 1024)
25
+#include "hw/misc/iotkit-sysctl.h"
26
+#define SRAM_SIZE (128 * 1024)
26
+#include "hw/misc/iotkit-sysinfo.h"
27
+#define CCM_BASE_ADDRESS 0x10000000
27
#include "hw/or-irq.h"
28
+#define CCM_SIZE (64 * 1024)
28
#include "hw/core/split-irq.h"
29
29
30
struct STM32F405State {
30
@@ -XXX,XX +XXX,XX @@ typedef struct IoTKit {
31
/*< private >*/
31
CMSDKAPBWatchdog nswatchdog;
32
@@ -XXX,XX +XXX,XX @@ struct STM32F405State {
32
CMSDKAPBWatchdog swatchdog;
33
STM32F2XXADCState adc[STM_NUM_ADCS];
33
34
STM32F2XXSPIState spi[STM_NUM_SPIS];
34
+ IoTKitSysCtl sysctl;
35
35
+ IoTKitSysCtl sysinfo;
36
+ MemoryRegion ccm;
36
+
37
MemoryRegion sram;
37
MemoryRegion container;
38
MemoryRegion flash;
38
MemoryRegion alias1;
39
MemoryRegion flash_alias;
39
MemoryRegion alias2;
40
diff --git a/hw/arm/stm32f405_soc.c b/hw/arm/stm32f405_soc.c
40
diff --git a/hw/arm/iotkit.c b/hw/arm/iotkit.c
41
index XXXXXXX..XXXXXXX 100644
41
index XXXXXXX..XXXXXXX 100644
42
--- a/hw/arm/iotkit.c
42
--- a/hw/arm/stm32f405_soc.c
43
+++ b/hw/arm/iotkit.c
43
+++ b/hw/arm/stm32f405_soc.c
44
@@ -XXX,XX +XXX,XX @@
44
@@ -XXX,XX +XXX,XX @@ static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp)
45
#include "hw/sysbus.h"
45
}
46
#include "hw/registerfields.h"
46
memory_region_add_subregion(system_memory, SRAM_BASE_ADDRESS, &s->sram);
47
#include "hw/arm/iotkit.h"
47
48
-#include "hw/misc/unimp.h"
48
+ memory_region_init_ram(&s->ccm, NULL, "STM32F405.ccm", CCM_SIZE,
49
#include "hw/arm/arm.h"
49
+ &err);
50
50
+ if (err != NULL) {
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);
51
+ error_propagate(errp, err);
77
+ return;
52
+ return;
78
+ }
53
+ }
79
+ /* System information registers */
54
+ memory_region_add_subregion(system_memory, CCM_BASE_ADDRESS, &s->ccm);
80
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->sysinfo), 0, 0x40020000);
55
+
81
+ /* System control registers */
56
armv7m = DEVICE(&s->armv7m);
82
+ object_property_set_bool(OBJECT(&s->sysctl), true, "realized", &err);
57
qdev_prop_set_uint32(armv7m, "num-irq", 96);
83
+ if (err) {
58
qdev_prop_set_string(armv7m, "cpu-type", s->cpu_type);
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
--
59
--
92
2.18.0
60
2.34.1
93
61
94
62
diff view generated by jsdifflib
1
Create a new include file for the pl022's device struct,
1
From: Felipe Balbi <balbi@kernel.org>
2
type macros, etc, so that it can be instantiated using
3
the "embedded struct" coding style.
4
2
5
While we're adding the new file to MAINTAINERS, add
3
Olimex makes a series of low-cost STM32 boards. This commit introduces
6
also the .c file, which was missing an entry.
4
the minimum setup to support SMT32-H405. See [1] for details
7
5
6
[1] https://www.olimex.com/Products/ARM/ST/STM32-H405/
7
8
Signed-off-by: Felipe Balbi <balbi@kernel.org>
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
11
Message-id: 20221230145733.200496-3-balbi@kernel.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
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
---
13
include/hw/ssi/pl022.h | 51 ++++++++++++++++++++++++++++++++++++++++++
14
docs/system/arm/stm32.rst | 1 +
14
hw/ssi/pl022.c | 26 +--------------------
15
configs/devices/arm-softmmu/default.mak | 1 +
15
MAINTAINERS | 2 ++
16
hw/arm/olimex-stm32-h405.c | 69 +++++++++++++++++++++++++
16
3 files changed, 54 insertions(+), 25 deletions(-)
17
MAINTAINERS | 6 +++
17
create mode 100644 include/hw/ssi/pl022.h
18
hw/arm/Kconfig | 4 ++
19
hw/arm/meson.build | 1 +
20
6 files changed, 82 insertions(+)
21
create mode 100644 hw/arm/olimex-stm32-h405.c
18
22
19
diff --git a/include/hw/ssi/pl022.h b/include/hw/ssi/pl022.h
23
diff --git a/docs/system/arm/stm32.rst b/docs/system/arm/stm32.rst
24
index XXXXXXX..XXXXXXX 100644
25
--- a/docs/system/arm/stm32.rst
26
+++ b/docs/system/arm/stm32.rst
27
@@ -XXX,XX +XXX,XX @@ The STM32F4 series is based on ARM Cortex-M4F core. This series is pin-to-pin
28
compatible with STM32F2 series. The following machines are based on this chip :
29
30
- ``netduinoplus2`` Netduino Plus 2 board with STM32F405RGT6 microcontroller
31
+- ``olimex-stm32-h405`` Olimex STM32 H405 board with STM32F405RGT6 microcontroller
32
33
There are many other STM32 series that are currently not supported by QEMU.
34
35
diff --git a/configs/devices/arm-softmmu/default.mak b/configs/devices/arm-softmmu/default.mak
36
index XXXXXXX..XXXXXXX 100644
37
--- a/configs/devices/arm-softmmu/default.mak
38
+++ b/configs/devices/arm-softmmu/default.mak
39
@@ -XXX,XX +XXX,XX @@ CONFIG_COLLIE=y
40
CONFIG_ASPEED_SOC=y
41
CONFIG_NETDUINO2=y
42
CONFIG_NETDUINOPLUS2=y
43
+CONFIG_OLIMEX_STM32_H405=y
44
CONFIG_MPS2=y
45
CONFIG_RASPI=y
46
CONFIG_DIGIC=y
47
diff --git a/hw/arm/olimex-stm32-h405.c b/hw/arm/olimex-stm32-h405.c
20
new file mode 100644
48
new file mode 100644
21
index XXXXXXX..XXXXXXX
49
index XXXXXXX..XXXXXXX
22
--- /dev/null
50
--- /dev/null
23
+++ b/include/hw/ssi/pl022.h
51
+++ b/hw/arm/olimex-stm32-h405.c
24
@@ -XXX,XX +XXX,XX @@
52
@@ -XXX,XX +XXX,XX @@
25
+/*
53
+/*
26
+ * ARM PrimeCell PL022 Synchronous Serial Port
54
+ * ST STM32VLDISCOVERY machine
55
+ * Olimex STM32-H405 machine
27
+ *
56
+ *
28
+ * Copyright (c) 2007 CodeSourcery.
57
+ * Copyright (c) 2022 Felipe Balbi <balbi@kernel.org>
29
+ * Written by Paul Brook
30
+ *
58
+ *
31
+ * This program is free software; you can redistribute it and/or modify
59
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
32
+ * it under the terms of the GNU General Public License version 2 or
60
+ * of this software and associated documentation files (the "Software"), to deal
33
+ * (at your option) any later version.
61
+ * in the Software without restriction, including without limitation the rights
62
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
63
+ * copies of the Software, and to permit persons to whom the Software is
64
+ * furnished to do so, subject to the following conditions:
65
+ *
66
+ * The above copyright notice and this permission notice shall be included in
67
+ * all copies or substantial portions of the Software.
68
+ *
69
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
70
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
71
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
72
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
73
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
74
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
75
+ * THE SOFTWARE.
34
+ */
76
+ */
35
+
77
+
36
+/* This is a model of the Arm PrimeCell PL022 synchronous serial port.
78
+#include "qemu/osdep.h"
37
+ * The PL022 TRM is:
79
+#include "qapi/error.h"
38
+ * http://infocenter.arm.com/help/topic/com.arm.doc.ddi0194h/DDI0194H_ssp_pl022_trm.pdf
80
+#include "hw/boards.h"
39
+ *
81
+#include "hw/qdev-properties.h"
40
+ * QEMU interface:
82
+#include "hw/qdev-clock.h"
41
+ * + sysbus IRQ: SSPINTR combined interrupt line
83
+#include "qemu/error-report.h"
42
+ * + sysbus MMIO region 0: MemoryRegion for the device's registers
84
+#include "hw/arm/stm32f405_soc.h"
43
+ */
85
+#include "hw/arm/boot.h"
44
+
86
+
45
+#ifndef HW_SSI_PL022_H
87
+/* olimex-stm32-h405 implementation is derived from netduinoplus2 */
46
+#define HW_SSI_PL022_H
47
+
88
+
48
+#include "hw/sysbus.h"
89
+/* Main SYSCLK frequency in Hz (168MHz) */
90
+#define SYSCLK_FRQ 168000000ULL
49
+
91
+
50
+#define TYPE_PL022 "pl022"
92
+static void olimex_stm32_h405_init(MachineState *machine)
51
+#define PL022(obj) OBJECT_CHECK(PL022State, (obj), TYPE_PL022)
93
+{
94
+ DeviceState *dev;
95
+ Clock *sysclk;
52
+
96
+
53
+typedef struct PL022State {
97
+ /* This clock doesn't need migration because it is fixed-frequency */
54
+ SysBusDevice parent_obj;
98
+ sysclk = clock_new(OBJECT(machine), "SYSCLK");
99
+ clock_set_hz(sysclk, SYSCLK_FRQ);
55
+
100
+
56
+ MemoryRegion iomem;
101
+ dev = qdev_new(TYPE_STM32F405_SOC);
57
+ uint32_t cr0;
102
+ qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m4"));
58
+ uint32_t cr1;
103
+ qdev_connect_clock_in(dev, "sysclk", sysclk);
59
+ uint32_t bitmask;
104
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
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
+
105
+
75
+#endif
106
+ armv7m_load_kernel(ARM_CPU(first_cpu),
76
diff --git a/hw/ssi/pl022.c b/hw/ssi/pl022.c
107
+ machine->kernel_filename,
77
index XXXXXXX..XXXXXXX 100644
108
+ 0, FLASH_SIZE);
78
--- a/hw/ssi/pl022.c
109
+}
79
+++ b/hw/ssi/pl022.c
110
+
80
@@ -XXX,XX +XXX,XX @@
111
+static void olimex_stm32_h405_machine_init(MachineClass *mc)
81
112
+{
82
#include "qemu/osdep.h"
113
+ mc->desc = "Olimex STM32-H405 (Cortex-M4)";
83
#include "hw/sysbus.h"
114
+ mc->init = olimex_stm32_h405_init;
84
+#include "hw/ssi/pl022.h"
115
+ mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m4");
85
#include "hw/ssi/ssi.h"
116
+
86
#include "qemu/log.h"
117
+ /* SRAM pre-allocated as part of the SoC instantiation */
87
118
+ mc->default_ram_size = 0;
88
@@ -XXX,XX +XXX,XX @@ do { fprintf(stderr, "pl022: error: " fmt , ## __VA_ARGS__);} while (0)
119
+}
89
#define PL022_INT_RX 0x04
120
+
90
#define PL022_INT_TX 0x08
121
+DEFINE_MACHINE("olimex-stm32-h405", olimex_stm32_h405_machine_init)
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
122
diff --git a/MAINTAINERS b/MAINTAINERS
121
index XXXXXXX..XXXXXXX 100644
123
index XXXXXXX..XXXXXXX 100644
122
--- a/MAINTAINERS
124
--- a/MAINTAINERS
123
+++ b/MAINTAINERS
125
+++ b/MAINTAINERS
124
@@ -XXX,XX +XXX,XX @@ F: hw/gpio/pl061.c
126
@@ -XXX,XX +XXX,XX @@ L: qemu-arm@nongnu.org
125
F: hw/input/pl050.c
127
S: Maintained
126
F: hw/intc/pl190.c
128
F: hw/arm/netduinoplus2.c
127
F: hw/sd/pl181.c
129
128
+F: hw/ssi/pl022.c
130
+Olimex STM32 H405
129
+F: include/hw/ssi/pl022.h
131
+M: Felipe Balbi <balbi@kernel.org>
130
F: hw/timer/pl031.c
132
+L: qemu-arm@nongnu.org
131
F: include/hw/arm/primecell.h
133
+S: Maintained
132
F: hw/timer/cmsdk-apb-timer.c
134
+F: hw/arm/olimex-stm32-h405.c
135
+
136
SmartFusion2
137
M: Subbaraya Sundeep <sundeep.lkml@gmail.com>
138
M: Peter Maydell <peter.maydell@linaro.org>
139
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
140
index XXXXXXX..XXXXXXX 100644
141
--- a/hw/arm/Kconfig
142
+++ b/hw/arm/Kconfig
143
@@ -XXX,XX +XXX,XX @@ config NETDUINOPLUS2
144
bool
145
select STM32F405_SOC
146
147
+config OLIMEX_STM32_H405
148
+ bool
149
+ select STM32F405_SOC
150
+
151
config NSERIES
152
bool
153
select OMAP
154
diff --git a/hw/arm/meson.build b/hw/arm/meson.build
155
index XXXXXXX..XXXXXXX 100644
156
--- a/hw/arm/meson.build
157
+++ b/hw/arm/meson.build
158
@@ -XXX,XX +XXX,XX @@ arm_ss.add(when: 'CONFIG_MICROBIT', if_true: files('microbit.c'))
159
arm_ss.add(when: 'CONFIG_MUSICPAL', if_true: files('musicpal.c'))
160
arm_ss.add(when: 'CONFIG_NETDUINO2', if_true: files('netduino2.c'))
161
arm_ss.add(when: 'CONFIG_NETDUINOPLUS2', if_true: files('netduinoplus2.c'))
162
+arm_ss.add(when: 'CONFIG_OLIMEX_STM32_H405', if_true: files('olimex-stm32-h405.c'))
163
arm_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx.c', 'npcm7xx_boards.c'))
164
arm_ss.add(when: 'CONFIG_NSERIES', if_true: files('nseries.c'))
165
arm_ss.add(when: 'CONFIG_SX1', if_true: files('omap_sx1.c'))
133
--
166
--
134
2.18.0
167
2.34.1
135
168
136
169
diff view generated by jsdifflib
1
Implement the IoTKit system control element's system information
1
From: Strahinja Jankovic <strahinjapjankovic@gmail.com>
2
block; this is just a pair of read-only version/config registers,
3
plus the usual PID/CID ID registers.
4
2
3
During SPL boot several Clock Controller Module (CCM) registers are
4
read, most important are PLL and Tuning, as well as divisor registers.
5
6
This patch adds these registers and initializes reset values from user's
7
guide.
8
9
Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
10
11
Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>
12
Message-id: 20221226220303.14420-2-strahinja.p.jankovic@gmail.com
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
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
---
14
---
10
hw/misc/Makefile.objs | 1 +
15
include/hw/arm/allwinner-a10.h | 2 +
11
include/hw/misc/iotkit-sysinfo.h | 37 +++++++++
16
include/hw/misc/allwinner-a10-ccm.h | 67 +++++++++
12
hw/misc/iotkit-sysinfo.c | 128 +++++++++++++++++++++++++++++++
17
hw/arm/allwinner-a10.c | 7 +
13
MAINTAINERS | 2 +
18
hw/misc/allwinner-a10-ccm.c | 224 ++++++++++++++++++++++++++++
14
default-configs/arm-softmmu.mak | 1 +
19
hw/arm/Kconfig | 1 +
15
5 files changed, 169 insertions(+)
20
hw/misc/Kconfig | 3 +
16
create mode 100644 include/hw/misc/iotkit-sysinfo.h
21
hw/misc/meson.build | 1 +
17
create mode 100644 hw/misc/iotkit-sysinfo.c
22
7 files changed, 305 insertions(+)
23
create mode 100644 include/hw/misc/allwinner-a10-ccm.h
24
create mode 100644 hw/misc/allwinner-a10-ccm.c
18
25
19
diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs
26
diff --git a/include/hw/arm/allwinner-a10.h b/include/hw/arm/allwinner-a10.h
20
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/misc/Makefile.objs
28
--- a/include/hw/arm/allwinner-a10.h
22
+++ b/hw/misc/Makefile.objs
29
+++ b/include/hw/arm/allwinner-a10.h
23
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_TZ_MPC) += tz-mpc.o
30
@@ -XXX,XX +XXX,XX @@
24
obj-$(CONFIG_TZ_PPC) += tz-ppc.o
31
#include "hw/usb/hcd-ohci.h"
25
obj-$(CONFIG_IOTKIT_SECCTL) += iotkit-secctl.o
32
#include "hw/usb/hcd-ehci.h"
26
obj-$(CONFIG_IOTKIT_SYSCTL) += iotkit-sysctl.o
33
#include "hw/rtc/allwinner-rtc.h"
27
+obj-$(CONFIG_IOTKIT_SYSINFO) += iotkit-sysinfo.o
34
+#include "hw/misc/allwinner-a10-ccm.h"
28
35
29
obj-$(CONFIG_PVPANIC) += pvpanic.o
36
#include "target/arm/cpu.h"
30
obj-$(CONFIG_HYPERV_TESTDEV) += hyperv_testdev.o
37
#include "qom/object.h"
31
diff --git a/include/hw/misc/iotkit-sysinfo.h b/include/hw/misc/iotkit-sysinfo.h
38
@@ -XXX,XX +XXX,XX @@ struct AwA10State {
39
/*< public >*/
40
41
ARMCPU cpu;
42
+ AwA10ClockCtlState ccm;
43
AwA10PITState timer;
44
AwA10PICState intc;
45
AwEmacState emac;
46
diff --git a/include/hw/misc/allwinner-a10-ccm.h b/include/hw/misc/allwinner-a10-ccm.h
32
new file mode 100644
47
new file mode 100644
33
index XXXXXXX..XXXXXXX
48
index XXXXXXX..XXXXXXX
34
--- /dev/null
49
--- /dev/null
35
+++ b/include/hw/misc/iotkit-sysinfo.h
50
+++ b/include/hw/misc/allwinner-a10-ccm.h
36
@@ -XXX,XX +XXX,XX @@
51
@@ -XXX,XX +XXX,XX @@
37
+/*
52
+/*
38
+ * ARM IoTKit system information block
53
+ * Allwinner A10 Clock Control Module emulation
39
+ *
54
+ *
40
+ * Copyright (c) 2018 Linaro Limited
55
+ * Copyright (C) 2022 Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
41
+ * Written by Peter Maydell
56
+ *
42
+ *
57
+ * This file is derived from Allwinner H3 CCU,
43
+ * This program is free software; you can redistribute it and/or modify
58
+ * by Niek Linnenbank.
44
+ * it under the terms of the GNU General Public License version 2 or
59
+ *
45
+ * (at your option) any later version.
60
+ * This program is free software: you can redistribute it and/or modify
61
+ * it under the terms of the GNU General Public License as published by
62
+ * the Free Software Foundation, either version 2 of the License, or
63
+ * (at your option) any later version.
64
+ *
65
+ * This program is distributed in the hope that it will be useful,
66
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
67
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
68
+ * GNU General Public License for more details.
69
+ *
70
+ * You should have received a copy of the GNU General Public License
71
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
46
+ */
72
+ */
47
+
73
+
48
+/*
74
+#ifndef HW_MISC_ALLWINNER_A10_CCM_H
49
+ * This is a model of the "system information block" which is part of the
75
+#define HW_MISC_ALLWINNER_A10_CCM_H
50
+ * Arm IoTKit and documented in
76
+
51
+ * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ecm0601256/index.html
77
+#include "qom/object.h"
52
+ * QEMU interface:
78
+#include "hw/sysbus.h"
53
+ * + sysbus MMIO region 0: the system information register bank
79
+
80
+/**
81
+ * @name Constants
82
+ * @{
54
+ */
83
+ */
55
+
84
+
56
+#ifndef HW_MISC_IOTKIT_SYSINFO_H
85
+/** Size of register I/O address space used by CCM device */
57
+#define HW_MISC_IOTKIT_SYSINFO_H
86
+#define AW_A10_CCM_IOSIZE (0x400)
58
+
87
+
59
+#include "hw/sysbus.h"
88
+/** Total number of known registers */
60
+
89
+#define AW_A10_CCM_REGS_NUM (AW_A10_CCM_IOSIZE / sizeof(uint32_t))
61
+#define TYPE_IOTKIT_SYSINFO "iotkit-sysinfo"
90
+
62
+#define IOTKIT_SYSINFO(obj) OBJECT_CHECK(IoTKitSysInfo, (obj), \
91
+/** @} */
63
+ TYPE_IOTKIT_SYSINFO)
92
+
64
+
93
+/**
65
+typedef struct IoTKitSysInfo {
94
+ * @name Object model
95
+ * @{
96
+ */
97
+
98
+#define TYPE_AW_A10_CCM "allwinner-a10-ccm"
99
+OBJECT_DECLARE_SIMPLE_TYPE(AwA10ClockCtlState, AW_A10_CCM)
100
+
101
+/** @} */
102
+
103
+/**
104
+ * Allwinner A10 CCM object instance state.
105
+ */
106
+struct AwA10ClockCtlState {
66
+ /*< private >*/
107
+ /*< private >*/
67
+ SysBusDevice parent_obj;
108
+ SysBusDevice parent_obj;
68
+
69
+ /*< public >*/
109
+ /*< public >*/
110
+
111
+ /** Maps I/O registers in physical memory */
70
+ MemoryRegion iomem;
112
+ MemoryRegion iomem;
71
+} IoTKitSysInfo;
113
+
72
+
114
+ /** Array of hardware registers */
73
+#endif
115
+ uint32_t regs[AW_A10_CCM_REGS_NUM];
74
diff --git a/hw/misc/iotkit-sysinfo.c b/hw/misc/iotkit-sysinfo.c
116
+};
117
+
118
+#endif /* HW_MISC_ALLWINNER_H3_CCU_H */
119
diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
120
index XXXXXXX..XXXXXXX 100644
121
--- a/hw/arm/allwinner-a10.c
122
+++ b/hw/arm/allwinner-a10.c
123
@@ -XXX,XX +XXX,XX @@
124
#include "hw/usb/hcd-ohci.h"
125
126
#define AW_A10_MMC0_BASE 0x01c0f000
127
+#define AW_A10_CCM_BASE 0x01c20000
128
#define AW_A10_PIC_REG_BASE 0x01c20400
129
#define AW_A10_PIT_REG_BASE 0x01c20c00
130
#define AW_A10_UART0_REG_BASE 0x01c28000
131
@@ -XXX,XX +XXX,XX @@ static void aw_a10_init(Object *obj)
132
133
object_initialize_child(obj, "timer", &s->timer, TYPE_AW_A10_PIT);
134
135
+ object_initialize_child(obj, "ccm", &s->ccm, TYPE_AW_A10_CCM);
136
+
137
object_initialize_child(obj, "emac", &s->emac, TYPE_AW_EMAC);
138
139
object_initialize_child(obj, "sata", &s->sata, TYPE_ALLWINNER_AHCI);
140
@@ -XXX,XX +XXX,XX @@ static void aw_a10_realize(DeviceState *dev, Error **errp)
141
memory_region_add_subregion(get_system_memory(), 0x00000000, &s->sram_a);
142
create_unimplemented_device("a10-sram-ctrl", 0x01c00000, 4 * KiB);
143
144
+ /* Clock Control Module */
145
+ sysbus_realize(SYS_BUS_DEVICE(&s->ccm), &error_fatal);
146
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->ccm), 0, AW_A10_CCM_BASE);
147
+
148
/* FIXME use qdev NIC properties instead of nd_table[] */
149
if (nd_table[0].used) {
150
qemu_check_nic_model(&nd_table[0], TYPE_AW_EMAC);
151
diff --git a/hw/misc/allwinner-a10-ccm.c b/hw/misc/allwinner-a10-ccm.c
75
new file mode 100644
152
new file mode 100644
76
index XXXXXXX..XXXXXXX
153
index XXXXXXX..XXXXXXX
77
--- /dev/null
154
--- /dev/null
78
+++ b/hw/misc/iotkit-sysinfo.c
155
+++ b/hw/misc/allwinner-a10-ccm.c
79
@@ -XXX,XX +XXX,XX @@
156
@@ -XXX,XX +XXX,XX @@
80
+/*
157
+/*
81
+ * ARM IoTKit system information block
158
+ * Allwinner A10 Clock Control Module emulation
82
+ *
159
+ *
83
+ * Copyright (c) 2018 Linaro Limited
160
+ * Copyright (C) 2022 Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
84
+ * Written by Peter Maydell
161
+ *
85
+ *
162
+ * This file is derived from Allwinner H3 CCU,
86
+ * This program is free software; you can redistribute it and/or modify
163
+ * by Niek Linnenbank.
87
+ * it under the terms of the GNU General Public License version 2 or
164
+ *
88
+ * (at your option) any later version.
165
+ * This program is free software: you can redistribute it and/or modify
166
+ * it under the terms of the GNU General Public License as published by
167
+ * the Free Software Foundation, either version 2 of the License, or
168
+ * (at your option) any later version.
169
+ *
170
+ * This program is distributed in the hope that it will be useful,
171
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
172
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
173
+ * GNU General Public License for more details.
174
+ *
175
+ * You should have received a copy of the GNU General Public License
176
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
89
+ */
177
+ */
90
+
178
+
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"
179
+#include "qemu/osdep.h"
180
+#include "qemu/units.h"
181
+#include "hw/sysbus.h"
182
+#include "migration/vmstate.h"
100
+#include "qemu/log.h"
183
+#include "qemu/log.h"
101
+#include "trace.h"
184
+#include "qemu/module.h"
102
+#include "qapi/error.h"
185
+#include "hw/misc/allwinner-a10-ccm.h"
103
+#include "sysemu/sysemu.h"
186
+
104
+#include "hw/sysbus.h"
187
+/* CCM register offsets */
105
+#include "hw/registerfields.h"
188
+enum {
106
+#include "hw/misc/iotkit-sysinfo.h"
189
+ REG_PLL1_CFG = 0x0000, /* PLL1 Control */
107
+
190
+ REG_PLL1_TUN = 0x0004, /* PLL1 Tuning */
108
+REG32(SYS_VERSION, 0x0)
191
+ REG_PLL2_CFG = 0x0008, /* PLL2 Control */
109
+REG32(SYS_CONFIG, 0x4)
192
+ REG_PLL2_TUN = 0x000C, /* PLL2 Tuning */
110
+REG32(PID4, 0xfd0)
193
+ REG_PLL3_CFG = 0x0010, /* PLL3 Control */
111
+REG32(PID5, 0xfd4)
194
+ REG_PLL4_CFG = 0x0018, /* PLL4 Control */
112
+REG32(PID6, 0xfd8)
195
+ REG_PLL5_CFG = 0x0020, /* PLL5 Control */
113
+REG32(PID7, 0xfdc)
196
+ REG_PLL5_TUN = 0x0024, /* PLL5 Tuning */
114
+REG32(PID0, 0xfe0)
197
+ REG_PLL6_CFG = 0x0028, /* PLL6 Control */
115
+REG32(PID1, 0xfe4)
198
+ REG_PLL6_TUN = 0x002C, /* PLL6 Tuning */
116
+REG32(PID2, 0xfe8)
199
+ REG_PLL7_CFG = 0x0030, /* PLL7 Control */
117
+REG32(PID3, 0xfec)
200
+ REG_PLL1_TUN2 = 0x0038, /* PLL1 Tuning2 */
118
+REG32(CID0, 0xff0)
201
+ REG_PLL5_TUN2 = 0x003C, /* PLL5 Tuning2 */
119
+REG32(CID1, 0xff4)
202
+ REG_PLL8_CFG = 0x0040, /* PLL8 Control */
120
+REG32(CID2, 0xff8)
203
+ REG_OSC24M_CFG = 0x0050, /* OSC24M Control */
121
+REG32(CID3, 0xffc)
204
+ REG_CPU_AHB_APB0_CFG = 0x0054, /* CPU, AHB and APB0 Divide Ratio */
122
+
205
+};
123
+/* PID/CID values */
206
+
124
+static const int sysinfo_id[] = {
207
+#define REG_INDEX(offset) (offset / sizeof(uint32_t))
125
+ 0x04, 0x00, 0x00, 0x00, /* PID4..PID7 */
208
+
126
+ 0x58, 0xb8, 0x0b, 0x00, /* PID0..PID3 */
209
+/* CCM register reset values */
127
+ 0x0d, 0xf0, 0x05, 0xb1, /* CID0..CID3 */
210
+enum {
128
+};
211
+ REG_PLL1_CFG_RST = 0x21005000,
129
+
212
+ REG_PLL1_TUN_RST = 0x0A101000,
130
+static uint64_t iotkit_sysinfo_read(void *opaque, hwaddr offset,
213
+ REG_PLL2_CFG_RST = 0x08100010,
131
+ unsigned size)
214
+ REG_PLL2_TUN_RST = 0x00000000,
132
+{
215
+ REG_PLL3_CFG_RST = 0x0010D063,
133
+ uint64_t r;
216
+ REG_PLL4_CFG_RST = 0x21009911,
217
+ REG_PLL5_CFG_RST = 0x11049280,
218
+ REG_PLL5_TUN_RST = 0x14888000,
219
+ REG_PLL6_CFG_RST = 0x21009911,
220
+ REG_PLL6_TUN_RST = 0x00000000,
221
+ REG_PLL7_CFG_RST = 0x0010D063,
222
+ REG_PLL1_TUN2_RST = 0x00000000,
223
+ REG_PLL5_TUN2_RST = 0x00000000,
224
+ REG_PLL8_CFG_RST = 0x21009911,
225
+ REG_OSC24M_CFG_RST = 0x00138013,
226
+ REG_CPU_AHB_APB0_CFG_RST = 0x00010010,
227
+};
228
+
229
+static uint64_t allwinner_a10_ccm_read(void *opaque, hwaddr offset,
230
+ unsigned size)
231
+{
232
+ const AwA10ClockCtlState *s = AW_A10_CCM(opaque);
233
+ const uint32_t idx = REG_INDEX(offset);
134
+
234
+
135
+ switch (offset) {
235
+ switch (offset) {
136
+ case A_SYS_VERSION:
236
+ case REG_PLL1_CFG:
137
+ r = 0x41743;
237
+ case REG_PLL1_TUN:
238
+ case REG_PLL2_CFG:
239
+ case REG_PLL2_TUN:
240
+ case REG_PLL3_CFG:
241
+ case REG_PLL4_CFG:
242
+ case REG_PLL5_CFG:
243
+ case REG_PLL5_TUN:
244
+ case REG_PLL6_CFG:
245
+ case REG_PLL6_TUN:
246
+ case REG_PLL7_CFG:
247
+ case REG_PLL1_TUN2:
248
+ case REG_PLL5_TUN2:
249
+ case REG_PLL8_CFG:
250
+ case REG_OSC24M_CFG:
251
+ case REG_CPU_AHB_APB0_CFG:
138
+ break;
252
+ break;
139
+
253
+ case 0x158 ... AW_A10_CCM_IOSIZE:
140
+ case A_SYS_CONFIG:
254
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: out-of-bounds offset 0x%04x\n",
141
+ r = 0x31;
255
+ __func__, (uint32_t)offset);
256
+ return 0;
257
+ default:
258
+ qemu_log_mask(LOG_UNIMP, "%s: unimplemented read offset 0x%04x\n",
259
+ __func__, (uint32_t)offset);
260
+ return 0;
261
+ }
262
+
263
+ return s->regs[idx];
264
+}
265
+
266
+static void allwinner_a10_ccm_write(void *opaque, hwaddr offset,
267
+ uint64_t val, unsigned size)
268
+{
269
+ AwA10ClockCtlState *s = AW_A10_CCM(opaque);
270
+ const uint32_t idx = REG_INDEX(offset);
271
+
272
+ switch (offset) {
273
+ case REG_PLL1_CFG:
274
+ case REG_PLL1_TUN:
275
+ case REG_PLL2_CFG:
276
+ case REG_PLL2_TUN:
277
+ case REG_PLL3_CFG:
278
+ case REG_PLL4_CFG:
279
+ case REG_PLL5_CFG:
280
+ case REG_PLL5_TUN:
281
+ case REG_PLL6_CFG:
282
+ case REG_PLL6_TUN:
283
+ case REG_PLL7_CFG:
284
+ case REG_PLL1_TUN2:
285
+ case REG_PLL5_TUN2:
286
+ case REG_PLL8_CFG:
287
+ case REG_OSC24M_CFG:
288
+ case REG_CPU_AHB_APB0_CFG:
142
+ break;
289
+ break;
143
+ case A_PID4 ... A_CID3:
290
+ case 0x158 ... AW_A10_CCM_IOSIZE:
144
+ r = sysinfo_id[(offset - A_PID4) / 4];
291
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: out-of-bounds offset 0x%04x\n",
292
+ __func__, (uint32_t)offset);
145
+ break;
293
+ break;
146
+ default:
294
+ default:
147
+ qemu_log_mask(LOG_GUEST_ERROR,
295
+ qemu_log_mask(LOG_UNIMP, "%s: unimplemented write offset 0x%04x\n",
148
+ "IoTKit SysInfo read: bad offset %x\n", (int)offset);
296
+ __func__, (uint32_t)offset);
149
+ r = 0;
150
+ break;
297
+ break;
151
+ }
298
+ }
152
+ trace_iotkit_sysinfo_read(offset, r, size);
299
+
153
+ return r;
300
+ s->regs[idx] = (uint32_t) val;
154
+}
301
+}
155
+
302
+
156
+static void iotkit_sysinfo_write(void *opaque, hwaddr offset,
303
+static const MemoryRegionOps allwinner_a10_ccm_ops = {
157
+ uint64_t value, unsigned size)
304
+ .read = allwinner_a10_ccm_read,
158
+{
305
+ .write = allwinner_a10_ccm_write,
159
+ trace_iotkit_sysinfo_write(offset, value, size);
306
+ .endianness = DEVICE_NATIVE_ENDIAN,
160
+
307
+ .valid = {
161
+ qemu_log_mask(LOG_GUEST_ERROR,
308
+ .min_access_size = 4,
162
+ "IoTKit SysInfo: write to RO offset 0x%x\n", (int)offset);
309
+ .max_access_size = 4,
163
+}
310
+ },
164
+
165
+static const MemoryRegionOps iotkit_sysinfo_ops = {
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,
311
+ .impl.min_access_size = 4,
171
+ .impl.max_access_size = 4,
312
+};
172
+ .valid.min_access_size = 1,
313
+
173
+ .valid.max_access_size = 4,
314
+static void allwinner_a10_ccm_reset_enter(Object *obj, ResetType type)
174
+};
315
+{
175
+
316
+ AwA10ClockCtlState *s = AW_A10_CCM(obj);
176
+static void iotkit_sysinfo_init(Object *obj)
317
+
318
+ /* Set default values for registers */
319
+ s->regs[REG_INDEX(REG_PLL1_CFG)] = REG_PLL1_CFG_RST;
320
+ s->regs[REG_INDEX(REG_PLL1_TUN)] = REG_PLL1_TUN_RST;
321
+ s->regs[REG_INDEX(REG_PLL2_CFG)] = REG_PLL2_CFG_RST;
322
+ s->regs[REG_INDEX(REG_PLL2_TUN)] = REG_PLL2_TUN_RST;
323
+ s->regs[REG_INDEX(REG_PLL3_CFG)] = REG_PLL3_CFG_RST;
324
+ s->regs[REG_INDEX(REG_PLL4_CFG)] = REG_PLL4_CFG_RST;
325
+ s->regs[REG_INDEX(REG_PLL5_CFG)] = REG_PLL5_CFG_RST;
326
+ s->regs[REG_INDEX(REG_PLL5_TUN)] = REG_PLL5_TUN_RST;
327
+ s->regs[REG_INDEX(REG_PLL6_CFG)] = REG_PLL6_CFG_RST;
328
+ s->regs[REG_INDEX(REG_PLL6_TUN)] = REG_PLL6_TUN_RST;
329
+ s->regs[REG_INDEX(REG_PLL7_CFG)] = REG_PLL7_CFG_RST;
330
+ s->regs[REG_INDEX(REG_PLL1_TUN2)] = REG_PLL1_TUN2_RST;
331
+ s->regs[REG_INDEX(REG_PLL5_TUN2)] = REG_PLL5_TUN2_RST;
332
+ s->regs[REG_INDEX(REG_PLL8_CFG)] = REG_PLL8_CFG_RST;
333
+ s->regs[REG_INDEX(REG_OSC24M_CFG)] = REG_OSC24M_CFG_RST;
334
+ s->regs[REG_INDEX(REG_CPU_AHB_APB0_CFG)] = REG_CPU_AHB_APB0_CFG_RST;
335
+}
336
+
337
+static void allwinner_a10_ccm_init(Object *obj)
177
+{
338
+{
178
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
339
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
179
+ IoTKitSysInfo *s = IOTKIT_SYSINFO(obj);
340
+ AwA10ClockCtlState *s = AW_A10_CCM(obj);
180
+
341
+
181
+ memory_region_init_io(&s->iomem, obj, &iotkit_sysinfo_ops,
342
+ /* Memory mapping */
182
+ s, "iotkit-sysinfo", 0x1000);
343
+ memory_region_init_io(&s->iomem, OBJECT(s), &allwinner_a10_ccm_ops, s,
344
+ TYPE_AW_A10_CCM, AW_A10_CCM_IOSIZE);
183
+ sysbus_init_mmio(sbd, &s->iomem);
345
+ sysbus_init_mmio(sbd, &s->iomem);
184
+}
346
+}
185
+
347
+
186
+static void iotkit_sysinfo_class_init(ObjectClass *klass, void *data)
348
+static const VMStateDescription allwinner_a10_ccm_vmstate = {
187
+{
349
+ .name = "allwinner-a10-ccm",
188
+ /*
350
+ .version_id = 1,
189
+ * This device has no guest-modifiable state and so it
351
+ .minimum_version_id = 1,
190
+ * does not need a reset function or VMState.
352
+ .fields = (VMStateField[]) {
191
+ */
353
+ VMSTATE_UINT32_ARRAY(regs, AwA10ClockCtlState, AW_A10_CCM_REGS_NUM),
192
+}
354
+ VMSTATE_END_OF_LIST()
193
+
355
+ }
194
+static const TypeInfo iotkit_sysinfo_info = {
356
+};
195
+ .name = TYPE_IOTKIT_SYSINFO,
357
+
196
+ .parent = TYPE_SYS_BUS_DEVICE,
358
+static void allwinner_a10_ccm_class_init(ObjectClass *klass, void *data)
197
+ .instance_size = sizeof(IoTKitSysInfo),
359
+{
198
+ .instance_init = iotkit_sysinfo_init,
360
+ DeviceClass *dc = DEVICE_CLASS(klass);
199
+ .class_init = iotkit_sysinfo_class_init,
361
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
200
+};
362
+
201
+
363
+ rc->phases.enter = allwinner_a10_ccm_reset_enter;
202
+static void iotkit_sysinfo_register_types(void)
364
+ dc->vmsd = &allwinner_a10_ccm_vmstate;
203
+{
365
+}
204
+ type_register_static(&iotkit_sysinfo_info);
366
+
205
+}
367
+static const TypeInfo allwinner_a10_ccm_info = {
206
+
368
+ .name = TYPE_AW_A10_CCM,
207
+type_init(iotkit_sysinfo_register_types);
369
+ .parent = TYPE_SYS_BUS_DEVICE,
208
diff --git a/MAINTAINERS b/MAINTAINERS
370
+ .instance_init = allwinner_a10_ccm_init,
371
+ .instance_size = sizeof(AwA10ClockCtlState),
372
+ .class_init = allwinner_a10_ccm_class_init,
373
+};
374
+
375
+static void allwinner_a10_ccm_register(void)
376
+{
377
+ type_register_static(&allwinner_a10_ccm_info);
378
+}
379
+
380
+type_init(allwinner_a10_ccm_register)
381
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
209
index XXXXXXX..XXXXXXX 100644
382
index XXXXXXX..XXXXXXX 100644
210
--- a/MAINTAINERS
383
--- a/hw/arm/Kconfig
211
+++ b/MAINTAINERS
384
+++ b/hw/arm/Kconfig
212
@@ -XXX,XX +XXX,XX @@ F: hw/arm/iotkit.c
385
@@ -XXX,XX +XXX,XX @@ config ALLWINNER_A10
213
F: include/hw/arm/iotkit.h
386
select AHCI
214
F: hw/misc/iotkit-sysctl.c
387
select ALLWINNER_A10_PIT
215
F: include/hw/misc/iotkit-sysctl.h
388
select ALLWINNER_A10_PIC
216
+F: hw/misc/iotkit-sysinfo.c
389
+ select ALLWINNER_A10_CCM
217
+F: include/hw/misc/iotkit-sysinfo.h
390
select ALLWINNER_EMAC
218
391
select SERIAL
219
Musicpal
392
select UNIMP
220
M: Jan Kiszka <jan.kiszka@web.de>
393
diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
221
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
222
index XXXXXXX..XXXXXXX 100644
394
index XXXXXXX..XXXXXXX 100644
223
--- a/default-configs/arm-softmmu.mak
395
--- a/hw/misc/Kconfig
224
+++ b/default-configs/arm-softmmu.mak
396
+++ b/hw/misc/Kconfig
225
@@ -XXX,XX +XXX,XX @@ CONFIG_TZ_PPC=y
397
@@ -XXX,XX +XXX,XX @@ config VIRT_CTRL
226
CONFIG_IOTKIT=y
398
config LASI
227
CONFIG_IOTKIT_SECCTL=y
399
bool
228
CONFIG_IOTKIT_SYSCTL=y
400
229
+CONFIG_IOTKIT_SYSINFO=y
401
+config ALLWINNER_A10_CCM
230
402
+ bool
231
CONFIG_VERSATILE=y
403
+
232
CONFIG_VERSATILE_PCI=y
404
source macio/Kconfig
405
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
406
index XXXXXXX..XXXXXXX 100644
407
--- a/hw/misc/meson.build
408
+++ b/hw/misc/meson.build
409
@@ -XXX,XX +XXX,XX @@ subdir('macio')
410
411
softmmu_ss.add(when: 'CONFIG_IVSHMEM_DEVICE', if_true: files('ivshmem.c'))
412
413
+softmmu_ss.add(when: 'CONFIG_ALLWINNER_A10_CCM', if_true: files('allwinner-a10-ccm.c'))
414
softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-ccu.c'))
415
specific_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-cpucfg.c'))
416
softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-dramc.c'))
233
--
417
--
234
2.18.0
418
2.34.1
235
236
diff view generated by jsdifflib
1
The Arm IoTKit includes a system control element which
1
From: Strahinja Jankovic <strahinjapjankovic@gmail.com>
2
provides a block of read-only ID registers and a block
2
3
of read-write control registers. Implement a minimal
3
During SPL boot several DRAM Controller registers are used. Most
4
version of this.
4
important registers are those related to DRAM initialization and
5
5
calibration, where SPL initiates process and waits until certain bit is
6
set/cleared.
7
8
This patch adds these registers, initializes reset values from user's
9
guide and updates state of registers as SPL expects it.
10
11
Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
12
13
Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>
14
Message-id: 20221226220303.14420-3-strahinja.p.jankovic@gmail.com
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
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
---
16
---
10
hw/misc/Makefile.objs | 1 +
17
include/hw/arm/allwinner-a10.h | 2 +
11
include/hw/misc/iotkit-sysctl.h | 49 ++++++
18
include/hw/misc/allwinner-a10-dramc.h | 68 ++++++++++
12
hw/misc/iotkit-sysctl.c | 261 ++++++++++++++++++++++++++++++++
19
hw/arm/allwinner-a10.c | 7 +
13
MAINTAINERS | 2 +
20
hw/misc/allwinner-a10-dramc.c | 179 ++++++++++++++++++++++++++
14
default-configs/arm-softmmu.mak | 1 +
21
hw/arm/Kconfig | 1 +
15
hw/misc/trace-events | 7 +
22
hw/misc/Kconfig | 3 +
16
6 files changed, 321 insertions(+)
23
hw/misc/meson.build | 1 +
17
create mode 100644 include/hw/misc/iotkit-sysctl.h
24
7 files changed, 261 insertions(+)
18
create mode 100644 hw/misc/iotkit-sysctl.c
25
create mode 100644 include/hw/misc/allwinner-a10-dramc.h
19
26
create mode 100644 hw/misc/allwinner-a10-dramc.c
20
diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs
27
21
index XXXXXXX..XXXXXXX 100644
28
diff --git a/include/hw/arm/allwinner-a10.h b/include/hw/arm/allwinner-a10.h
22
--- a/hw/misc/Makefile.objs
29
index XXXXXXX..XXXXXXX 100644
23
+++ b/hw/misc/Makefile.objs
30
--- a/include/hw/arm/allwinner-a10.h
24
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_MPS2_SCC) += mps2-scc.o
31
+++ b/include/hw/arm/allwinner-a10.h
25
obj-$(CONFIG_TZ_MPC) += tz-mpc.o
32
@@ -XXX,XX +XXX,XX @@
26
obj-$(CONFIG_TZ_PPC) += tz-ppc.o
33
#include "hw/usb/hcd-ehci.h"
27
obj-$(CONFIG_IOTKIT_SECCTL) += iotkit-secctl.o
34
#include "hw/rtc/allwinner-rtc.h"
28
+obj-$(CONFIG_IOTKIT_SYSCTL) += iotkit-sysctl.o
35
#include "hw/misc/allwinner-a10-ccm.h"
29
36
+#include "hw/misc/allwinner-a10-dramc.h"
30
obj-$(CONFIG_PVPANIC) += pvpanic.o
37
31
obj-$(CONFIG_HYPERV_TESTDEV) += hyperv_testdev.o
38
#include "target/arm/cpu.h"
32
diff --git a/include/hw/misc/iotkit-sysctl.h b/include/hw/misc/iotkit-sysctl.h
39
#include "qom/object.h"
40
@@ -XXX,XX +XXX,XX @@ struct AwA10State {
41
42
ARMCPU cpu;
43
AwA10ClockCtlState ccm;
44
+ AwA10DramControllerState dramc;
45
AwA10PITState timer;
46
AwA10PICState intc;
47
AwEmacState emac;
48
diff --git a/include/hw/misc/allwinner-a10-dramc.h b/include/hw/misc/allwinner-a10-dramc.h
33
new file mode 100644
49
new file mode 100644
34
index XXXXXXX..XXXXXXX
50
index XXXXXXX..XXXXXXX
35
--- /dev/null
51
--- /dev/null
36
+++ b/include/hw/misc/iotkit-sysctl.h
52
+++ b/include/hw/misc/allwinner-a10-dramc.h
37
@@ -XXX,XX +XXX,XX @@
53
@@ -XXX,XX +XXX,XX @@
38
+/*
54
+/*
39
+ * ARM IoTKit system control element
55
+ * Allwinner A10 DRAM Controller emulation
40
+ *
56
+ *
41
+ * Copyright (c) 2018 Linaro Limited
57
+ * Copyright (C) 2022 Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
42
+ * Written by Peter Maydell
58
+ *
43
+ *
59
+ * This file is derived from Allwinner H3 DRAMC,
44
+ * This program is free software; you can redistribute it and/or modify
60
+ * by Niek Linnenbank.
45
+ * it under the terms of the GNU General Public License version 2 or
61
+ *
46
+ * (at your option) any later version.
62
+ * This program is free software: you can redistribute it and/or modify
47
+ */
63
+ * it under the terms of the GNU General Public License as published by
48
+
64
+ * the Free Software Foundation, either version 2 of the License, or
49
+/*
65
+ * (at your option) any later version.
50
+ * This is a model of the "system control element" which is part of the
66
+ *
51
+ * Arm IoTKit and documented in
67
+ * This program is distributed in the hope that it will be useful,
52
+ * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ecm0601256/index.html
68
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
53
+ * Specifically, it implements the "system information block" and
69
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
54
+ * "system control register" blocks.
70
+ * GNU General Public License for more details.
55
+ *
71
+ *
56
+ * QEMU interface:
72
+ * You should have received a copy of the GNU General Public License
57
+ * + sysbus MMIO region 0: the system information register bank
73
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
58
+ * + sysbus MMIO region 1: the system control register bank
74
+ */
59
+ */
75
+
60
+
76
+#ifndef HW_MISC_ALLWINNER_A10_DRAMC_H
61
+#ifndef HW_MISC_IOTKIT_SYSCTL_H
77
+#define HW_MISC_ALLWINNER_A10_DRAMC_H
62
+#define HW_MISC_IOTKIT_SYSCTL_H
78
+
63
+
79
+#include "qom/object.h"
64
+#include "hw/sysbus.h"
80
+#include "hw/sysbus.h"
65
+
81
+#include "hw/register.h"
66
+#define TYPE_IOTKIT_SYSCTL "iotkit-sysctl"
82
+
67
+#define IOTKIT_SYSCTL(obj) OBJECT_CHECK(IoTKitSysCtl, (obj), \
83
+/**
68
+ TYPE_IOTKIT_SYSCTL)
84
+ * @name Constants
69
+
85
+ * @{
70
+typedef struct IoTKitSysCtl {
86
+ */
87
+
88
+/** Size of register I/O address space used by DRAMC device */
89
+#define AW_A10_DRAMC_IOSIZE (0x1000)
90
+
91
+/** Total number of known registers */
92
+#define AW_A10_DRAMC_REGS_NUM (AW_A10_DRAMC_IOSIZE / sizeof(uint32_t))
93
+
94
+/** @} */
95
+
96
+/**
97
+ * @name Object model
98
+ * @{
99
+ */
100
+
101
+#define TYPE_AW_A10_DRAMC "allwinner-a10-dramc"
102
+OBJECT_DECLARE_SIMPLE_TYPE(AwA10DramControllerState, AW_A10_DRAMC)
103
+
104
+/** @} */
105
+
106
+/**
107
+ * Allwinner A10 DRAMC object instance state.
108
+ */
109
+struct AwA10DramControllerState {
71
+ /*< private >*/
110
+ /*< private >*/
72
+ SysBusDevice parent_obj;
111
+ SysBusDevice parent_obj;
73
+
74
+ /*< public >*/
112
+ /*< public >*/
113
+
114
+ /** Maps I/O registers in physical memory */
75
+ MemoryRegion iomem;
115
+ MemoryRegion iomem;
76
+
116
+
77
+ uint32_t secure_debug;
117
+ /** Array of hardware registers */
78
+ uint32_t reset_syndrome;
118
+ uint32_t regs[AW_A10_DRAMC_REGS_NUM];
79
+ uint32_t reset_mask;
119
+};
80
+ uint32_t gretreg;
120
+
81
+ uint32_t initsvrtor0;
121
+#endif /* HW_MISC_ALLWINNER_A10_DRAMC_H */
82
+ uint32_t cpuwait;
122
diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
83
+ uint32_t wicctrl;
123
index XXXXXXX..XXXXXXX 100644
84
+} IoTKitSysCtl;
124
--- a/hw/arm/allwinner-a10.c
85
+
125
+++ b/hw/arm/allwinner-a10.c
86
+#endif
126
@@ -XXX,XX +XXX,XX @@
87
diff --git a/hw/misc/iotkit-sysctl.c b/hw/misc/iotkit-sysctl.c
127
#include "hw/boards.h"
128
#include "hw/usb/hcd-ohci.h"
129
130
+#define AW_A10_DRAMC_BASE 0x01c01000
131
#define AW_A10_MMC0_BASE 0x01c0f000
132
#define AW_A10_CCM_BASE 0x01c20000
133
#define AW_A10_PIC_REG_BASE 0x01c20400
134
@@ -XXX,XX +XXX,XX @@ static void aw_a10_init(Object *obj)
135
136
object_initialize_child(obj, "ccm", &s->ccm, TYPE_AW_A10_CCM);
137
138
+ object_initialize_child(obj, "dramc", &s->dramc, TYPE_AW_A10_DRAMC);
139
+
140
object_initialize_child(obj, "emac", &s->emac, TYPE_AW_EMAC);
141
142
object_initialize_child(obj, "sata", &s->sata, TYPE_ALLWINNER_AHCI);
143
@@ -XXX,XX +XXX,XX @@ static void aw_a10_realize(DeviceState *dev, Error **errp)
144
sysbus_realize(SYS_BUS_DEVICE(&s->ccm), &error_fatal);
145
sysbus_mmio_map(SYS_BUS_DEVICE(&s->ccm), 0, AW_A10_CCM_BASE);
146
147
+ /* DRAM Control Module */
148
+ sysbus_realize(SYS_BUS_DEVICE(&s->dramc), &error_fatal);
149
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->dramc), 0, AW_A10_DRAMC_BASE);
150
+
151
/* FIXME use qdev NIC properties instead of nd_table[] */
152
if (nd_table[0].used) {
153
qemu_check_nic_model(&nd_table[0], TYPE_AW_EMAC);
154
diff --git a/hw/misc/allwinner-a10-dramc.c b/hw/misc/allwinner-a10-dramc.c
88
new file mode 100644
155
new file mode 100644
89
index XXXXXXX..XXXXXXX
156
index XXXXXXX..XXXXXXX
90
--- /dev/null
157
--- /dev/null
91
+++ b/hw/misc/iotkit-sysctl.c
158
+++ b/hw/misc/allwinner-a10-dramc.c
92
@@ -XXX,XX +XXX,XX @@
159
@@ -XXX,XX +XXX,XX @@
93
+/*
160
+/*
94
+ * ARM IoTKit system control element
161
+ * Allwinner A10 DRAM Controller emulation
95
+ *
162
+ *
96
+ * Copyright (c) 2018 Linaro Limited
163
+ * Copyright (C) 2022 Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
97
+ * Written by Peter Maydell
164
+ *
98
+ *
165
+ * This file is derived from Allwinner H3 DRAMC,
99
+ * This program is free software; you can redistribute it and/or modify
166
+ * by Niek Linnenbank.
100
+ * it under the terms of the GNU General Public License version 2 or
167
+ *
101
+ * (at your option) any later version.
168
+ * This program is free software: you can redistribute it and/or modify
102
+ */
169
+ * it under the terms of the GNU General Public License as published by
103
+
170
+ * the Free Software Foundation, either version 2 of the License, or
104
+/*
171
+ * (at your option) any later version.
105
+ * This is a model of the "system control element" which is part of the
172
+ *
106
+ * Arm IoTKit and documented in
173
+ * This program is distributed in the hope that it will be useful,
107
+ * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ecm0601256/index.html
174
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
108
+ * Specifically, it implements the "system control register" blocks.
175
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
176
+ * GNU General Public License for more details.
177
+ *
178
+ * You should have received a copy of the GNU General Public License
179
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
109
+ */
180
+ */
110
+
181
+
111
+#include "qemu/osdep.h"
182
+#include "qemu/osdep.h"
183
+#include "qemu/units.h"
184
+#include "hw/sysbus.h"
185
+#include "migration/vmstate.h"
112
+#include "qemu/log.h"
186
+#include "qemu/log.h"
113
+#include "trace.h"
187
+#include "qemu/module.h"
114
+#include "qapi/error.h"
188
+#include "hw/misc/allwinner-a10-dramc.h"
115
+#include "sysemu/sysemu.h"
189
+
116
+#include "hw/sysbus.h"
190
+/* DRAMC register offsets */
117
+#include "hw/registerfields.h"
191
+enum {
118
+#include "hw/misc/iotkit-sysctl.h"
192
+ REG_SDR_CCR = 0x0000,
119
+
193
+ REG_SDR_ZQCR0 = 0x00a8,
120
+REG32(SECDBGSTAT, 0x0)
194
+ REG_SDR_ZQSR = 0x00b0
121
+REG32(SECDBGSET, 0x4)
195
+};
122
+REG32(SECDBGCLR, 0x8)
196
+
123
+REG32(RESET_SYNDROME, 0x100)
197
+#define REG_INDEX(offset) (offset / sizeof(uint32_t))
124
+REG32(RESET_MASK, 0x104)
198
+
125
+REG32(SWRESET, 0x108)
199
+/* DRAMC register flags */
126
+ FIELD(SWRESET, SWRESETREQ, 9, 1)
200
+enum {
127
+REG32(GRETREG, 0x10c)
201
+ REG_SDR_CCR_DATA_TRAINING = (1 << 30),
128
+REG32(INITSVRTOR0, 0x110)
202
+ REG_SDR_CCR_DRAM_INIT = (1 << 31),
129
+REG32(CPUWAIT, 0x118)
203
+};
130
+REG32(BUSWAIT, 0x11c)
204
+enum {
131
+REG32(WICCTRL, 0x120)
205
+ REG_SDR_ZQSR_ZCAL = (1 << 31),
132
+REG32(PID4, 0xfd0)
206
+};
133
+REG32(PID5, 0xfd4)
207
+
134
+REG32(PID6, 0xfd8)
208
+/* DRAMC register reset values */
135
+REG32(PID7, 0xfdc)
209
+enum {
136
+REG32(PID0, 0xfe0)
210
+ REG_SDR_CCR_RESET = 0x80020000,
137
+REG32(PID1, 0xfe4)
211
+ REG_SDR_ZQCR0_RESET = 0x07b00000,
138
+REG32(PID2, 0xfe8)
212
+ REG_SDR_ZQSR_RESET = 0x80000000
139
+REG32(PID3, 0xfec)
213
+};
140
+REG32(CID0, 0xff0)
214
+
141
+REG32(CID1, 0xff4)
215
+static uint64_t allwinner_a10_dramc_read(void *opaque, hwaddr offset,
142
+REG32(CID2, 0xff8)
216
+ unsigned size)
143
+REG32(CID3, 0xffc)
217
+{
144
+
218
+ const AwA10DramControllerState *s = AW_A10_DRAMC(opaque);
145
+/* PID/CID values */
219
+ const uint32_t idx = REG_INDEX(offset);
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
+
220
+
158
+ switch (offset) {
221
+ switch (offset) {
159
+ case A_SECDBGSTAT:
222
+ case REG_SDR_CCR:
160
+ r = s->secure_debug;
223
+ case REG_SDR_ZQCR0:
161
+ break;
224
+ case REG_SDR_ZQSR:
162
+ case A_RESET_SYNDROME:
225
+ break;
163
+ r = s->reset_syndrome;
226
+ case 0x2e4 ... AW_A10_DRAMC_IOSIZE:
164
+ break;
227
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: out-of-bounds offset 0x%04x\n",
165
+ case A_RESET_MASK:
228
+ __func__, (uint32_t)offset);
166
+ r = s->reset_mask;
229
+ return 0;
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:
230
+ default:
196
+ qemu_log_mask(LOG_GUEST_ERROR,
231
+ qemu_log_mask(LOG_UNIMP, "%s: unimplemented read offset 0x%04x\n",
197
+ "IoTKit SysCtl read: bad offset %x\n", (int)offset);
232
+ __func__, (uint32_t)offset);
198
+ r = 0;
233
+ return 0;
199
+ break;
200
+ }
234
+ }
201
+ trace_iotkit_sysctl_read(offset, r, size);
235
+
202
+ return r;
236
+ return s->regs[idx];
203
+}
237
+}
204
+
238
+
205
+static void iotkit_sysctl_write(void *opaque, hwaddr offset,
239
+static void allwinner_a10_dramc_write(void *opaque, hwaddr offset,
206
+ uint64_t value, unsigned size)
240
+ uint64_t val, unsigned size)
207
+{
241
+{
208
+ IoTKitSysCtl *s = IOTKIT_SYSCTL(opaque);
242
+ AwA10DramControllerState *s = AW_A10_DRAMC(opaque);
209
+
243
+ const uint32_t idx = REG_INDEX(offset);
210
+ trace_iotkit_sysctl_write(offset, value, size);
211
+
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
+
244
+
222
+ switch (offset) {
245
+ switch (offset) {
223
+ case A_RESET_SYNDROME:
246
+ case REG_SDR_CCR:
224
+ qemu_log_mask(LOG_UNIMP,
247
+ if (val & REG_SDR_CCR_DRAM_INIT) {
225
+ "IoTKit SysCtl RESET_SYNDROME unimplemented\n");
248
+ /* Clear DRAM_INIT to indicate process is done. */
226
+ s->reset_syndrome = value;
249
+ val &= ~REG_SDR_CCR_DRAM_INIT;
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
+ }
250
+ }
266
+ break;
251
+ if (val & REG_SDR_CCR_DATA_TRAINING) {
267
+ case A_BUSWAIT: /* In IoTKit BUSWAIT is reserved, R/O, zero */
252
+ /* Clear DATA_TRAINING to indicate process is done. */
268
+ case A_SECDBGSTAT:
253
+ val &= ~REG_SDR_CCR_DATA_TRAINING;
269
+ case A_PID4 ... A_CID3:
254
+ }
270
+ qemu_log_mask(LOG_GUEST_ERROR,
255
+ break;
271
+ "IoTKit SysCtl write: write of RO offset %x\n",
256
+ case REG_SDR_ZQCR0:
272
+ (int)offset);
257
+ /* Set ZCAL in ZQSR to indicate calibration is done. */
258
+ s->regs[REG_INDEX(REG_SDR_ZQSR)] |= REG_SDR_ZQSR_ZCAL;
259
+ break;
260
+ case 0x2e4 ... AW_A10_DRAMC_IOSIZE:
261
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: out-of-bounds offset 0x%04x\n",
262
+ __func__, (uint32_t)offset);
273
+ break;
263
+ break;
274
+ default:
264
+ default:
275
+ qemu_log_mask(LOG_GUEST_ERROR,
265
+ qemu_log_mask(LOG_UNIMP, "%s: unimplemented write offset 0x%04x\n",
276
+ "IoTKit SysCtl write: bad offset %x\n", (int)offset);
266
+ __func__, (uint32_t)offset);
277
+ break;
267
+ break;
278
+ }
268
+ }
279
+}
269
+
280
+
270
+ s->regs[idx] = (uint32_t) val;
281
+static const MemoryRegionOps iotkit_sysctl_ops = {
271
+}
282
+ .read = iotkit_sysctl_read,
272
+
283
+ .write = iotkit_sysctl_write,
273
+static const MemoryRegionOps allwinner_a10_dramc_ops = {
284
+ .endianness = DEVICE_LITTLE_ENDIAN,
274
+ .read = allwinner_a10_dramc_read,
285
+ /* byte/halfword accesses are just zero-padded on reads and writes */
275
+ .write = allwinner_a10_dramc_write,
276
+ .endianness = DEVICE_NATIVE_ENDIAN,
277
+ .valid = {
278
+ .min_access_size = 4,
279
+ .max_access_size = 4,
280
+ },
286
+ .impl.min_access_size = 4,
281
+ .impl.min_access_size = 4,
287
+ .impl.max_access_size = 4,
282
+};
288
+ .valid.min_access_size = 1,
283
+
289
+ .valid.max_access_size = 4,
284
+static void allwinner_a10_dramc_reset_enter(Object *obj, ResetType type)
290
+};
285
+{
291
+
286
+ AwA10DramControllerState *s = AW_A10_DRAMC(obj);
292
+static void iotkit_sysctl_reset(DeviceState *dev)
287
+
293
+{
288
+ /* Set default values for registers */
294
+ IoTKitSysCtl *s = IOTKIT_SYSCTL(dev);
289
+ s->regs[REG_INDEX(REG_SDR_CCR)] = REG_SDR_CCR_RESET;
295
+
290
+ s->regs[REG_INDEX(REG_SDR_ZQCR0)] = REG_SDR_ZQCR0_RESET;
296
+ trace_iotkit_sysctl_reset();
291
+ s->regs[REG_INDEX(REG_SDR_ZQSR)] = REG_SDR_ZQSR_RESET;
297
+ s->secure_debug = 0;
292
+}
298
+ s->reset_syndrome = 1;
293
+
299
+ s->reset_mask = 0;
294
+static void allwinner_a10_dramc_init(Object *obj)
300
+ s->gretreg = 0;
301
+ s->initsvrtor0 = 0x10000000;
302
+ s->cpuwait = 0;
303
+ s->wicctrl = 0;
304
+}
305
+
306
+static void iotkit_sysctl_init(Object *obj)
307
+{
295
+{
308
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
296
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
309
+ IoTKitSysCtl *s = IOTKIT_SYSCTL(obj);
297
+ AwA10DramControllerState *s = AW_A10_DRAMC(obj);
310
+
298
+
311
+ memory_region_init_io(&s->iomem, obj, &iotkit_sysctl_ops,
299
+ /* Memory mapping */
312
+ s, "iotkit-sysctl", 0x1000);
300
+ memory_region_init_io(&s->iomem, OBJECT(s), &allwinner_a10_dramc_ops, s,
301
+ TYPE_AW_A10_DRAMC, AW_A10_DRAMC_IOSIZE);
313
+ sysbus_init_mmio(sbd, &s->iomem);
302
+ sysbus_init_mmio(sbd, &s->iomem);
314
+}
303
+}
315
+
304
+
316
+static const VMStateDescription iotkit_sysctl_vmstate = {
305
+static const VMStateDescription allwinner_a10_dramc_vmstate = {
317
+ .name = "iotkit-sysctl",
306
+ .name = "allwinner-a10-dramc",
318
+ .version_id = 1,
307
+ .version_id = 1,
319
+ .minimum_version_id = 1,
308
+ .minimum_version_id = 1,
320
+ .fields = (VMStateField[]) {
309
+ .fields = (VMStateField[]) {
321
+ VMSTATE_UINT32(secure_debug, IoTKitSysCtl),
310
+ VMSTATE_UINT32_ARRAY(regs, AwA10DramControllerState,
322
+ VMSTATE_UINT32(reset_syndrome, IoTKitSysCtl),
311
+ AW_A10_DRAMC_REGS_NUM),
323
+ VMSTATE_UINT32(reset_mask, IoTKitSysCtl),
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()
312
+ VMSTATE_END_OF_LIST()
329
+ }
313
+ }
330
+};
314
+};
331
+
315
+
332
+static void iotkit_sysctl_class_init(ObjectClass *klass, void *data)
316
+static void allwinner_a10_dramc_class_init(ObjectClass *klass, void *data)
333
+{
317
+{
334
+ DeviceClass *dc = DEVICE_CLASS(klass);
318
+ DeviceClass *dc = DEVICE_CLASS(klass);
335
+
319
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
336
+ dc->vmsd = &iotkit_sysctl_vmstate;
320
+
337
+ dc->reset = iotkit_sysctl_reset;
321
+ rc->phases.enter = allwinner_a10_dramc_reset_enter;
338
+}
322
+ dc->vmsd = &allwinner_a10_dramc_vmstate;
339
+
323
+}
340
+static const TypeInfo iotkit_sysctl_info = {
324
+
341
+ .name = TYPE_IOTKIT_SYSCTL,
325
+static const TypeInfo allwinner_a10_dramc_info = {
342
+ .parent = TYPE_SYS_BUS_DEVICE,
326
+ .name = TYPE_AW_A10_DRAMC,
343
+ .instance_size = sizeof(IoTKitSysCtl),
327
+ .parent = TYPE_SYS_BUS_DEVICE,
344
+ .instance_init = iotkit_sysctl_init,
328
+ .instance_init = allwinner_a10_dramc_init,
345
+ .class_init = iotkit_sysctl_class_init,
329
+ .instance_size = sizeof(AwA10DramControllerState),
346
+};
330
+ .class_init = allwinner_a10_dramc_class_init,
347
+
331
+};
348
+static void iotkit_sysctl_register_types(void)
332
+
349
+{
333
+static void allwinner_a10_dramc_register(void)
350
+ type_register_static(&iotkit_sysctl_info);
334
+{
351
+}
335
+ type_register_static(&allwinner_a10_dramc_info);
352
+
336
+}
353
+type_init(iotkit_sysctl_register_types);
337
+
354
diff --git a/MAINTAINERS b/MAINTAINERS
338
+type_init(allwinner_a10_dramc_register)
355
index XXXXXXX..XXXXXXX 100644
339
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
356
--- a/MAINTAINERS
340
index XXXXXXX..XXXXXXX 100644
357
+++ b/MAINTAINERS
341
--- a/hw/arm/Kconfig
358
@@ -XXX,XX +XXX,XX @@ F: hw/misc/mps2-*.c
342
+++ b/hw/arm/Kconfig
359
F: include/hw/misc/mps2-*.h
343
@@ -XXX,XX +XXX,XX @@ config ALLWINNER_A10
360
F: hw/arm/iotkit.c
344
select ALLWINNER_A10_PIT
361
F: include/hw/arm/iotkit.h
345
select ALLWINNER_A10_PIC
362
+F: hw/misc/iotkit-sysctl.c
346
select ALLWINNER_A10_CCM
363
+F: include/hw/misc/iotkit-sysctl.h
347
+ select ALLWINNER_A10_DRAMC
364
348
select ALLWINNER_EMAC
365
Musicpal
349
select SERIAL
366
M: Jan Kiszka <jan.kiszka@web.de>
350
select UNIMP
367
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
351
diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
368
index XXXXXXX..XXXXXXX 100644
352
index XXXXXXX..XXXXXXX 100644
369
--- a/default-configs/arm-softmmu.mak
353
--- a/hw/misc/Kconfig
370
+++ b/default-configs/arm-softmmu.mak
354
+++ b/hw/misc/Kconfig
371
@@ -XXX,XX +XXX,XX @@ CONFIG_TZ_MPC=y
355
@@ -XXX,XX +XXX,XX @@ config LASI
372
CONFIG_TZ_PPC=y
356
config ALLWINNER_A10_CCM
373
CONFIG_IOTKIT=y
357
bool
374
CONFIG_IOTKIT_SECCTL=y
358
375
+CONFIG_IOTKIT_SYSCTL=y
359
+config ALLWINNER_A10_DRAMC
376
360
+ bool
377
CONFIG_VERSATILE=y
361
+
378
CONFIG_VERSATILE_PCI=y
362
source macio/Kconfig
379
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
363
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
380
index XXXXXXX..XXXXXXX 100644
364
index XXXXXXX..XXXXXXX 100644
381
--- a/hw/misc/trace-events
365
--- a/hw/misc/meson.build
382
+++ b/hw/misc/trace-events
366
+++ b/hw/misc/meson.build
383
@@ -XXX,XX +XXX,XX @@ ccm_freq(uint32_t freq) "freq = %d\n"
367
@@ -XXX,XX +XXX,XX @@ subdir('macio')
384
ccm_clock_freq(uint32_t clock, uint32_t freq) "(Clock = %d) = %d\n"
368
softmmu_ss.add(when: 'CONFIG_IVSHMEM_DEVICE', if_true: files('ivshmem.c'))
385
ccm_read_reg(const char *reg_name, uint32_t value) "reg[%s] <= 0x%" PRIx32 "\n"
369
386
ccm_write_reg(const char *reg_name, uint32_t value) "reg[%s] => 0x%" PRIx32 "\n"
370
softmmu_ss.add(when: 'CONFIG_ALLWINNER_A10_CCM', if_true: files('allwinner-a10-ccm.c'))
387
+
371
+softmmu_ss.add(when: 'CONFIG_ALLWINNER_A10_DRAMC', if_true: files('allwinner-a10-dramc.c'))
388
+# hw/misc/iotkit-sysctl.c
372
softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-ccu.c'))
389
+iotkit_sysinfo_read(uint64_t offset, uint64_t data, unsigned size) "IoTKit SysInfo read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
373
specific_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-cpucfg.c'))
390
+iotkit_sysinfo_write(uint64_t offset, uint64_t data, unsigned size) "IoTKit SysInfo write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
374
softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-dramc.c'))
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
--
375
--
395
2.18.0
376
2.34.1
396
397
diff view generated by jsdifflib
1
The Arm Cortex-M System Design Kit includes a "dual-input timer module"
1
From: Strahinja Jankovic <strahinjapjankovic@gmail.com>
2
which combines two programmable down-counters. Implement a model
3
of this device.
4
2
3
This patch implements Allwinner TWI/I2C controller emulation. Only
4
master-mode functionality is implemented.
5
6
The SPL boot for Cubieboard expects AXP209 PMIC on TWI0/I2C0 bus, so this is
7
first part enabling the TWI/I2C bus operation.
8
9
Since both Allwinner A10 and H3 use the same module, it is added for
10
both boards.
11
12
Docs are also updated for Cubieboard and Orangepi-PC board to indicate
13
I2C availability.
14
15
Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
16
Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>
17
Message-id: 20221226220303.14420-4-strahinja.p.jankovic@gmail.com
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
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
---
19
---
9
hw/timer/Makefile.objs | 1 +
20
docs/system/arm/cubieboard.rst | 1 +
10
include/hw/timer/cmsdk-apb-dualtimer.h | 72 ++++
21
docs/system/arm/orangepi.rst | 1 +
11
hw/timer/cmsdk-apb-dualtimer.c | 515 +++++++++++++++++++++++++
22
include/hw/arm/allwinner-a10.h | 2 +
12
MAINTAINERS | 2 +
23
include/hw/arm/allwinner-h3.h | 3 +
13
default-configs/arm-softmmu.mak | 1 +
24
include/hw/i2c/allwinner-i2c.h | 55 ++++
14
hw/timer/trace-events | 5 +
25
hw/arm/allwinner-a10.c | 8 +
15
6 files changed, 596 insertions(+)
26
hw/arm/allwinner-h3.c | 11 +-
16
create mode 100644 include/hw/timer/cmsdk-apb-dualtimer.h
27
hw/i2c/allwinner-i2c.c | 459 +++++++++++++++++++++++++++++++++
17
create mode 100644 hw/timer/cmsdk-apb-dualtimer.c
28
hw/arm/Kconfig | 2 +
29
hw/i2c/Kconfig | 4 +
30
hw/i2c/meson.build | 1 +
31
hw/i2c/trace-events | 5 +
32
12 files changed, 551 insertions(+), 1 deletion(-)
33
create mode 100644 include/hw/i2c/allwinner-i2c.h
34
create mode 100644 hw/i2c/allwinner-i2c.c
18
35
19
diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
36
diff --git a/docs/system/arm/cubieboard.rst b/docs/system/arm/cubieboard.rst
20
index XXXXXXX..XXXXXXX 100644
37
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/timer/Makefile.objs
38
--- a/docs/system/arm/cubieboard.rst
22
+++ b/hw/timer/Makefile.objs
39
+++ b/docs/system/arm/cubieboard.rst
23
@@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o
40
@@ -XXX,XX +XXX,XX @@ Emulated devices:
24
41
- SDHCI
25
common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o
42
- USB controller
26
common-obj-$(CONFIG_CMSDK_APB_TIMER) += cmsdk-apb-timer.o
43
- SATA controller
27
+common-obj-$(CONFIG_CMSDK_APB_DUALTIMER) += cmsdk-apb-dualtimer.o
44
+- TWI (I2C) controller
28
common-obj-$(CONFIG_MSF2) += mss-timer.o
45
diff --git a/docs/system/arm/orangepi.rst b/docs/system/arm/orangepi.rst
29
diff --git a/include/hw/timer/cmsdk-apb-dualtimer.h b/include/hw/timer/cmsdk-apb-dualtimer.h
46
index XXXXXXX..XXXXXXX 100644
47
--- a/docs/system/arm/orangepi.rst
48
+++ b/docs/system/arm/orangepi.rst
49
@@ -XXX,XX +XXX,XX @@ The Orange Pi PC machine supports the following devices:
50
* Clock Control Unit
51
* System Control module
52
* Security Identifier device
53
+ * TWI (I2C)
54
55
Limitations
56
"""""""""""
57
diff --git a/include/hw/arm/allwinner-a10.h b/include/hw/arm/allwinner-a10.h
58
index XXXXXXX..XXXXXXX 100644
59
--- a/include/hw/arm/allwinner-a10.h
60
+++ b/include/hw/arm/allwinner-a10.h
61
@@ -XXX,XX +XXX,XX @@
62
#include "hw/rtc/allwinner-rtc.h"
63
#include "hw/misc/allwinner-a10-ccm.h"
64
#include "hw/misc/allwinner-a10-dramc.h"
65
+#include "hw/i2c/allwinner-i2c.h"
66
67
#include "target/arm/cpu.h"
68
#include "qom/object.h"
69
@@ -XXX,XX +XXX,XX @@ struct AwA10State {
70
AwEmacState emac;
71
AllwinnerAHCIState sata;
72
AwSdHostState mmc0;
73
+ AWI2CState i2c0;
74
AwRtcState rtc;
75
MemoryRegion sram_a;
76
EHCISysBusState ehci[AW_A10_NUM_USB];
77
diff --git a/include/hw/arm/allwinner-h3.h b/include/hw/arm/allwinner-h3.h
78
index XXXXXXX..XXXXXXX 100644
79
--- a/include/hw/arm/allwinner-h3.h
80
+++ b/include/hw/arm/allwinner-h3.h
81
@@ -XXX,XX +XXX,XX @@
82
#include "hw/sd/allwinner-sdhost.h"
83
#include "hw/net/allwinner-sun8i-emac.h"
84
#include "hw/rtc/allwinner-rtc.h"
85
+#include "hw/i2c/allwinner-i2c.h"
86
#include "target/arm/cpu.h"
87
#include "sysemu/block-backend.h"
88
89
@@ -XXX,XX +XXX,XX @@ enum {
90
AW_H3_DEV_UART2,
91
AW_H3_DEV_UART3,
92
AW_H3_DEV_EMAC,
93
+ AW_H3_DEV_TWI0,
94
AW_H3_DEV_DRAMCOM,
95
AW_H3_DEV_DRAMCTL,
96
AW_H3_DEV_DRAMPHY,
97
@@ -XXX,XX +XXX,XX @@ struct AwH3State {
98
AwH3SysCtrlState sysctrl;
99
AwSidState sid;
100
AwSdHostState mmc0;
101
+ AWI2CState i2c0;
102
AwSun8iEmacState emac;
103
AwRtcState rtc;
104
GICState gic;
105
diff --git a/include/hw/i2c/allwinner-i2c.h b/include/hw/i2c/allwinner-i2c.h
30
new file mode 100644
106
new file mode 100644
31
index XXXXXXX..XXXXXXX
107
index XXXXXXX..XXXXXXX
32
--- /dev/null
108
--- /dev/null
33
+++ b/include/hw/timer/cmsdk-apb-dualtimer.h
109
+++ b/include/hw/i2c/allwinner-i2c.h
34
@@ -XXX,XX +XXX,XX @@
110
@@ -XXX,XX +XXX,XX @@
35
+/*
111
+/*
36
+ * ARM CMSDK APB dual-timer emulation
112
+ * Allwinner I2C Bus Serial Interface registers definition
37
+ *
113
+ *
38
+ * Copyright (c) 2018 Linaro Limited
114
+ * Copyright (C) 2022 Strahinja Jankovic. <strahinja.p.jankovic@gmail.com>
39
+ * Written by Peter Maydell
115
+ *
40
+ *
116
+ * This file is derived from IMX I2C controller,
41
+ * This program is free software; you can redistribute it and/or modify
117
+ * by Jean-Christophe DUBOIS .
42
+ * it under the terms of the GNU General Public License version 2 or
118
+ *
119
+ * This program is free software; you can redistribute it and/or modify it
120
+ * under the terms of the GNU General Public License as published by the
121
+ * Free Software Foundation; either version 2 of the License, or
43
+ * (at your option) any later version.
122
+ * (at your option) any later version.
123
+ *
124
+ * This program is distributed in the hope that it will be useful, but WITHOUT
125
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
126
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
127
+ * for more details.
128
+ *
129
+ * You should have received a copy of the GNU General Public License along
130
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
131
+ *
44
+ */
132
+ */
45
+
133
+
46
+/*
134
+#ifndef ALLWINNER_I2C_H
47
+ * This is a model of the "APB dual-input timer" which is part of the Cortex-M
135
+#define ALLWINNER_I2C_H
48
+ * System Design Kit (CMSDK) and documented in the Cortex-M System
49
+ * Design Kit Technical Reference Manual (ARM DDI0479C):
50
+ * https://developer.arm.com/products/system-design/system-design-kits/cortex-m-system-design-kit
51
+ *
52
+ * QEMU interface:
53
+ * + QOM property "pclk-frq": frequency at which the timer is clocked
54
+ * + sysbus MMIO region 0: the register bank
55
+ * + sysbus IRQ 0: combined timer interrupt TIMINTC
56
+ * + sysbus IRO 1: timer block 1 interrupt TIMINT1
57
+ * + sysbus IRQ 2: timer block 2 interrupt TIMINT2
58
+ */
59
+
60
+#ifndef CMSDK_APB_DUALTIMER_H
61
+#define CMSDK_APB_DUALTIMER_H
62
+
136
+
63
+#include "hw/sysbus.h"
137
+#include "hw/sysbus.h"
64
+#include "hw/ptimer.h"
138
+#include "qom/object.h"
65
+
139
+
66
+#define TYPE_CMSDK_APB_DUALTIMER "cmsdk-apb-dualtimer"
140
+#define TYPE_AW_I2C "allwinner.i2c"
67
+#define CMSDK_APB_DUALTIMER(obj) OBJECT_CHECK(CMSDKAPBDualTimer, (obj), \
141
+OBJECT_DECLARE_SIMPLE_TYPE(AWI2CState, AW_I2C)
68
+ TYPE_CMSDK_APB_DUALTIMER)
142
+
69
+
143
+#define AW_I2C_MEM_SIZE 0x24
70
+typedef struct CMSDKAPBDualTimer CMSDKAPBDualTimer;
144
+
71
+
145
+struct AWI2CState {
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 >*/
146
+ /*< private >*/
94
+ SysBusDevice parent_obj;
147
+ SysBusDevice parent_obj;
95
+
148
+
96
+ /*< public >*/
149
+ /*< public >*/
97
+ MemoryRegion iomem;
150
+ MemoryRegion iomem;
98
+ qemu_irq timerintc;
151
+ I2CBus *bus;
99
+ uint32_t pclk_frq;
152
+ qemu_irq irq;
100
+
153
+
101
+ CMSDKAPBDualTimerModule timermod[CMSDK_APB_DUALTIMER_NUM_MODULES];
154
+ uint8_t addr;
102
+ uint32_t timeritcr;
155
+ uint8_t xaddr;
103
+ uint32_t timeritop;
156
+ uint8_t data;
157
+ uint8_t cntr;
158
+ uint8_t stat;
159
+ uint8_t ccr;
160
+ uint8_t srst;
161
+ uint8_t efr;
162
+ uint8_t lcr;
104
+};
163
+};
105
+
164
+
106
+#endif
165
+#endif /* ALLWINNER_I2C_H */
107
diff --git a/hw/timer/cmsdk-apb-dualtimer.c b/hw/timer/cmsdk-apb-dualtimer.c
166
diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
167
index XXXXXXX..XXXXXXX 100644
168
--- a/hw/arm/allwinner-a10.c
169
+++ b/hw/arm/allwinner-a10.c
170
@@ -XXX,XX +XXX,XX @@
171
#define AW_A10_OHCI_BASE 0x01c14400
172
#define AW_A10_SATA_BASE 0x01c18000
173
#define AW_A10_RTC_BASE 0x01c20d00
174
+#define AW_A10_I2C0_BASE 0x01c2ac00
175
176
static void aw_a10_init(Object *obj)
177
{
178
@@ -XXX,XX +XXX,XX @@ static void aw_a10_init(Object *obj)
179
180
object_initialize_child(obj, "sata", &s->sata, TYPE_ALLWINNER_AHCI);
181
182
+ object_initialize_child(obj, "i2c0", &s->i2c0, TYPE_AW_I2C);
183
+
184
if (machine_usb(current_machine)) {
185
int i;
186
187
@@ -XXX,XX +XXX,XX @@ static void aw_a10_realize(DeviceState *dev, Error **errp)
188
/* RTC */
189
sysbus_realize(SYS_BUS_DEVICE(&s->rtc), &error_fatal);
190
sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->rtc), 0, AW_A10_RTC_BASE, 10);
191
+
192
+ /* I2C */
193
+ sysbus_realize(SYS_BUS_DEVICE(&s->i2c0), &error_fatal);
194
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c0), 0, AW_A10_I2C0_BASE);
195
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c0), 0, qdev_get_gpio_in(dev, 7));
196
}
197
198
static void aw_a10_class_init(ObjectClass *oc, void *data)
199
diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
200
index XXXXXXX..XXXXXXX 100644
201
--- a/hw/arm/allwinner-h3.c
202
+++ b/hw/arm/allwinner-h3.c
203
@@ -XXX,XX +XXX,XX @@ const hwaddr allwinner_h3_memmap[] = {
204
[AW_H3_DEV_UART1] = 0x01c28400,
205
[AW_H3_DEV_UART2] = 0x01c28800,
206
[AW_H3_DEV_UART3] = 0x01c28c00,
207
+ [AW_H3_DEV_TWI0] = 0x01c2ac00,
208
[AW_H3_DEV_EMAC] = 0x01c30000,
209
[AW_H3_DEV_DRAMCOM] = 0x01c62000,
210
[AW_H3_DEV_DRAMCTL] = 0x01c63000,
211
@@ -XXX,XX +XXX,XX @@ struct AwH3Unimplemented {
212
{ "uart1", 0x01c28400, 1 * KiB },
213
{ "uart2", 0x01c28800, 1 * KiB },
214
{ "uart3", 0x01c28c00, 1 * KiB },
215
- { "twi0", 0x01c2ac00, 1 * KiB },
216
{ "twi1", 0x01c2b000, 1 * KiB },
217
{ "twi2", 0x01c2b400, 1 * KiB },
218
{ "scr", 0x01c2c400, 1 * KiB },
219
@@ -XXX,XX +XXX,XX @@ enum {
220
AW_H3_GIC_SPI_UART1 = 1,
221
AW_H3_GIC_SPI_UART2 = 2,
222
AW_H3_GIC_SPI_UART3 = 3,
223
+ AW_H3_GIC_SPI_TWI0 = 6,
224
AW_H3_GIC_SPI_TIMER0 = 18,
225
AW_H3_GIC_SPI_TIMER1 = 19,
226
AW_H3_GIC_SPI_MMC0 = 60,
227
@@ -XXX,XX +XXX,XX @@ static void allwinner_h3_init(Object *obj)
228
"ram-size");
229
230
object_initialize_child(obj, "rtc", &s->rtc, TYPE_AW_RTC_SUN6I);
231
+
232
+ object_initialize_child(obj, "twi0", &s->i2c0, TYPE_AW_I2C);
233
}
234
235
static void allwinner_h3_realize(DeviceState *dev, Error **errp)
236
@@ -XXX,XX +XXX,XX @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp)
237
sysbus_realize(SYS_BUS_DEVICE(&s->rtc), &error_fatal);
238
sysbus_mmio_map(SYS_BUS_DEVICE(&s->rtc), 0, s->memmap[AW_H3_DEV_RTC]);
239
240
+ /* I2C */
241
+ sysbus_realize(SYS_BUS_DEVICE(&s->i2c0), &error_fatal);
242
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c0), 0, s->memmap[AW_H3_DEV_TWI0]);
243
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c0), 0,
244
+ qdev_get_gpio_in(DEVICE(&s->gic), AW_H3_GIC_SPI_TWI0));
245
+
246
/* Unimplemented devices */
247
for (i = 0; i < ARRAY_SIZE(unimplemented); i++) {
248
create_unimplemented_device(unimplemented[i].device_name,
249
diff --git a/hw/i2c/allwinner-i2c.c b/hw/i2c/allwinner-i2c.c
108
new file mode 100644
250
new file mode 100644
109
index XXXXXXX..XXXXXXX
251
index XXXXXXX..XXXXXXX
110
--- /dev/null
252
--- /dev/null
111
+++ b/hw/timer/cmsdk-apb-dualtimer.c
253
+++ b/hw/i2c/allwinner-i2c.c
112
@@ -XXX,XX +XXX,XX @@
254
@@ -XXX,XX +XXX,XX @@
113
+/*
255
+/*
114
+ * ARM CMSDK APB dual-timer emulation
256
+ * Allwinner I2C Bus Serial Interface Emulation
115
+ *
257
+ *
116
+ * Copyright (c) 2018 Linaro Limited
258
+ * Copyright (C) 2022 Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
117
+ * Written by Peter Maydell
259
+ *
118
+ *
260
+ * This file is derived from IMX I2C controller,
119
+ * This program is free software; you can redistribute it and/or modify
261
+ * by Jean-Christophe DUBOIS .
120
+ * it under the terms of the GNU General Public License version 2 or
262
+ *
263
+ * This program is free software; you can redistribute it and/or modify it
264
+ * under the terms of the GNU General Public License as published by the
265
+ * Free Software Foundation; either version 2 of the License, or
121
+ * (at your option) any later version.
266
+ * (at your option) any later version.
267
+ *
268
+ * This program is distributed in the hope that it will be useful, but WITHOUT
269
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
270
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
271
+ * for more details.
272
+ *
273
+ * You should have received a copy of the GNU General Public License along
274
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
275
+ *
276
+ * SPDX-License-Identifier: MIT
122
+ */
277
+ */
123
+
278
+
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"
279
+#include "qemu/osdep.h"
280
+#include "hw/i2c/allwinner-i2c.h"
281
+#include "hw/irq.h"
282
+#include "migration/vmstate.h"
283
+#include "hw/i2c/i2c.h"
132
+#include "qemu/log.h"
284
+#include "qemu/log.h"
133
+#include "trace.h"
285
+#include "trace.h"
134
+#include "qapi/error.h"
286
+#include "qemu/module.h"
135
+#include "qemu/main-loop.h"
287
+
136
+#include "hw/sysbus.h"
288
+/* Allwinner I2C memory map */
137
+#include "hw/registerfields.h"
289
+#define TWI_ADDR_REG 0x00 /* slave address register */
138
+#include "hw/timer/cmsdk-apb-dualtimer.h"
290
+#define TWI_XADDR_REG 0x04 /* extended slave address register */
139
+
291
+#define TWI_DATA_REG 0x08 /* data register */
140
+REG32(TIMER1LOAD, 0x0)
292
+#define TWI_CNTR_REG 0x0c /* control register */
141
+REG32(TIMER1VALUE, 0x4)
293
+#define TWI_STAT_REG 0x10 /* status register */
142
+REG32(TIMER1CONTROL, 0x8)
294
+#define TWI_CCR_REG 0x14 /* clock control register */
143
+ FIELD(CONTROL, ONESHOT, 0, 1)
295
+#define TWI_SRST_REG 0x18 /* software reset register */
144
+ FIELD(CONTROL, SIZE, 1, 1)
296
+#define TWI_EFR_REG 0x1c /* enhance feature register */
145
+ FIELD(CONTROL, PRESCALE, 2, 2)
297
+#define TWI_LCR_REG 0x20 /* line control register */
146
+ FIELD(CONTROL, INTEN, 5, 1)
298
+
147
+ FIELD(CONTROL, MODE, 6, 1)
299
+/* Used only in slave mode, do not set */
148
+ FIELD(CONTROL, ENABLE, 7, 1)
300
+#define TWI_ADDR_RESET 0
149
+#define R_CONTROL_VALID_MASK (R_CONTROL_ONESHOT_MASK | R_CONTROL_SIZE_MASK | \
301
+#define TWI_XADDR_RESET 0
150
+ R_CONTROL_PRESCALE_MASK | R_CONTROL_INTEN_MASK | \
302
+
151
+ R_CONTROL_MODE_MASK | R_CONTROL_ENABLE_MASK)
303
+/* Data register */
152
+REG32(TIMER1INTCLR, 0xc)
304
+#define TWI_DATA_MASK 0xFF
153
+REG32(TIMER1RIS, 0x10)
305
+#define TWI_DATA_RESET 0
154
+REG32(TIMER1MIS, 0x14)
306
+
155
+REG32(TIMER1BGLOAD, 0x18)
307
+/* Control register */
156
+REG32(TIMER2LOAD, 0x20)
308
+#define TWI_CNTR_INT_EN (1 << 7)
157
+REG32(TIMER2VALUE, 0x24)
309
+#define TWI_CNTR_BUS_EN (1 << 6)
158
+REG32(TIMER2CONTROL, 0x28)
310
+#define TWI_CNTR_M_STA (1 << 5)
159
+REG32(TIMER2INTCLR, 0x2c)
311
+#define TWI_CNTR_M_STP (1 << 4)
160
+REG32(TIMER2RIS, 0x30)
312
+#define TWI_CNTR_INT_FLAG (1 << 3)
161
+REG32(TIMER2MIS, 0x34)
313
+#define TWI_CNTR_A_ACK (1 << 2)
162
+REG32(TIMER2BGLOAD, 0x38)
314
+#define TWI_CNTR_MASK 0xFC
163
+REG32(TIMERITCR, 0xf00)
315
+#define TWI_CNTR_RESET 0
164
+ FIELD(TIMERITCR, ENABLE, 0, 1)
316
+
165
+#define R_TIMERITCR_VALID_MASK R_TIMERITCR_ENABLE_MASK
317
+/* Status register */
166
+REG32(TIMERITOP, 0xf04)
318
+#define TWI_STAT_MASK 0xF8
167
+ FIELD(TIMERITOP, TIMINT1, 0, 1)
319
+#define TWI_STAT_RESET 0xF8
168
+ FIELD(TIMERITOP, TIMINT2, 1, 1)
320
+
169
+#define R_TIMERITOP_VALID_MASK (R_TIMERITOP_TIMINT1_MASK | \
321
+/* Clock register */
170
+ R_TIMERITOP_TIMINT2_MASK)
322
+#define TWI_CCR_CLK_M_MASK 0x78
171
+REG32(PID4, 0xfd0)
323
+#define TWI_CCR_CLK_N_MASK 0x07
172
+REG32(PID5, 0xfd4)
324
+#define TWI_CCR_MASK 0x7F
173
+REG32(PID6, 0xfd8)
325
+#define TWI_CCR_RESET 0
174
+REG32(PID7, 0xfdc)
326
+
175
+REG32(PID0, 0xfe0)
327
+/* Soft reset */
176
+REG32(PID1, 0xfe4)
328
+#define TWI_SRST_MASK 0x01
177
+REG32(PID2, 0xfe8)
329
+#define TWI_SRST_RESET 0
178
+REG32(PID3, 0xfec)
330
+
179
+REG32(CID0, 0xff0)
331
+/* Enhance feature */
180
+REG32(CID1, 0xff4)
332
+#define TWI_EFR_MASK 0x03
181
+REG32(CID2, 0xff8)
333
+#define TWI_EFR_RESET 0
182
+REG32(CID3, 0xffc)
334
+
183
+
335
+/* Line control */
184
+/* PID/CID values */
336
+#define TWI_LCR_SCL_STATE (1 << 5)
185
+static const int timer_id[] = {
337
+#define TWI_LCR_SDA_STATE (1 << 4)
186
+ 0x04, 0x00, 0x00, 0x00, /* PID4..PID7 */
338
+#define TWI_LCR_SCL_CTL (1 << 3)
187
+ 0x23, 0xb8, 0x1b, 0x00, /* PID0..PID3 */
339
+#define TWI_LCR_SCL_CTL_EN (1 << 2)
188
+ 0x0d, 0xf0, 0x05, 0xb1, /* CID0..CID3 */
340
+#define TWI_LCR_SDA_CTL (1 << 1)
189
+};
341
+#define TWI_LCR_SDA_CTL_EN (1 << 0)
190
+
342
+#define TWI_LCR_MASK 0x3F
191
+static bool cmsdk_dualtimermod_intstatus(CMSDKAPBDualTimerModule *m)
343
+#define TWI_LCR_RESET 0x3A
192
+{
344
+
193
+ /* Return masked interrupt status for the timer module */
345
+/* Status value in STAT register is shifted by 3 bits */
194
+ return m->intstatus && (m->control & R_CONTROL_INTEN_MASK);
346
+#define TWI_STAT_SHIFT 3
195
+}
347
+#define STAT_FROM_STA(x) ((x) << TWI_STAT_SHIFT)
196
+
348
+#define STAT_TO_STA(x) ((x) >> TWI_STAT_SHIFT)
197
+static void cmsdk_apb_dualtimer_update(CMSDKAPBDualTimer *s)
349
+
198
+{
350
+enum {
199
+ bool timint1, timint2, timintc;
351
+ STAT_BUS_ERROR = 0,
200
+
352
+ /* Master mode */
201
+ if (s->timeritcr) {
353
+ STAT_M_STA_TX,
202
+ /* Integration test mode: outputs driven directly from TIMERITOP bits */
354
+ STAT_M_RSTA_TX,
203
+ timint1 = s->timeritop & R_TIMERITOP_TIMINT1_MASK;
355
+ STAT_M_ADDR_WR_ACK,
204
+ timint2 = s->timeritop & R_TIMERITOP_TIMINT2_MASK;
356
+ STAT_M_ADDR_WR_NACK,
205
+ } else {
357
+ STAT_M_DATA_TX_ACK,
206
+ timint1 = cmsdk_dualtimermod_intstatus(&s->timermod[0]);
358
+ STAT_M_DATA_TX_NACK,
207
+ timint2 = cmsdk_dualtimermod_intstatus(&s->timermod[1]);
359
+ STAT_M_ARB_LOST,
360
+ STAT_M_ADDR_RD_ACK,
361
+ STAT_M_ADDR_RD_NACK,
362
+ STAT_M_DATA_RX_ACK,
363
+ STAT_M_DATA_RX_NACK,
364
+ /* Slave mode */
365
+ STAT_S_ADDR_WR_ACK,
366
+ STAT_S_ARB_LOST_AW_ACK,
367
+ STAT_S_GCA_ACK,
368
+ STAT_S_ARB_LOST_GCA_ACK,
369
+ STAT_S_DATA_RX_SA_ACK,
370
+ STAT_S_DATA_RX_SA_NACK,
371
+ STAT_S_DATA_RX_GCA_ACK,
372
+ STAT_S_DATA_RX_GCA_NACK,
373
+ STAT_S_STP_RSTA,
374
+ STAT_S_ADDR_RD_ACK,
375
+ STAT_S_ARB_LOST_AR_ACK,
376
+ STAT_S_DATA_TX_ACK,
377
+ STAT_S_DATA_TX_NACK,
378
+ STAT_S_LB_TX_ACK,
379
+ /* Master mode, 10-bit */
380
+ STAT_M_2ND_ADDR_WR_ACK,
381
+ STAT_M_2ND_ADDR_WR_NACK,
382
+ /* Idle */
383
+ STAT_IDLE = 0x1f
384
+} TWI_STAT_STA;
385
+
386
+static const char *allwinner_i2c_get_regname(unsigned offset)
387
+{
388
+ switch (offset) {
389
+ case TWI_ADDR_REG:
390
+ return "ADDR";
391
+ case TWI_XADDR_REG:
392
+ return "XADDR";
393
+ case TWI_DATA_REG:
394
+ return "DATA";
395
+ case TWI_CNTR_REG:
396
+ return "CNTR";
397
+ case TWI_STAT_REG:
398
+ return "STAT";
399
+ case TWI_CCR_REG:
400
+ return "CCR";
401
+ case TWI_SRST_REG:
402
+ return "SRST";
403
+ case TWI_EFR_REG:
404
+ return "EFR";
405
+ case TWI_LCR_REG:
406
+ return "LCR";
407
+ default:
408
+ return "[?]";
208
+ }
409
+ }
209
+
410
+}
210
+ timintc = timint1 || timint2;
411
+
211
+
412
+static inline bool allwinner_i2c_is_reset(AWI2CState *s)
212
+ qemu_set_irq(s->timermod[0].timerint, timint1);
413
+{
213
+ qemu_set_irq(s->timermod[1].timerint, timint2);
414
+ return s->srst & TWI_SRST_MASK;
214
+ qemu_set_irq(s->timerintc, timintc);
415
+}
215
+}
416
+
216
+
417
+static inline bool allwinner_i2c_bus_is_enabled(AWI2CState *s)
217
+static void cmsdk_dualtimermod_write_control(CMSDKAPBDualTimerModule *m,
418
+{
218
+ uint32_t newctrl)
419
+ return s->cntr & TWI_CNTR_BUS_EN;
219
+{
420
+}
220
+ /* Handle a write to the CONTROL register */
421
+
221
+ uint32_t changed;
422
+static inline bool allwinner_i2c_interrupt_is_enabled(AWI2CState *s)
222
+
423
+{
223
+ newctrl &= R_CONTROL_VALID_MASK;
424
+ return s->cntr & TWI_CNTR_INT_EN;
224
+
425
+}
225
+ changed = m->control ^ newctrl;
426
+
226
+
427
+static void allwinner_i2c_reset_hold(Object *obj)
227
+ if (changed & ~newctrl & R_CONTROL_ENABLE_MASK) {
428
+{
228
+ /* ENABLE cleared, stop timer before any further changes */
429
+ AWI2CState *s = AW_I2C(obj);
229
+ ptimer_stop(m->timer);
430
+
431
+ if (STAT_TO_STA(s->stat) != STAT_IDLE) {
432
+ i2c_end_transfer(s->bus);
230
+ }
433
+ }
231
+
434
+
232
+ if (changed & R_CONTROL_PRESCALE_MASK) {
435
+ s->addr = TWI_ADDR_RESET;
233
+ int divisor;
436
+ s->xaddr = TWI_XADDR_RESET;
234
+
437
+ s->data = TWI_DATA_RESET;
235
+ switch (FIELD_EX32(newctrl, CONTROL, PRESCALE)) {
438
+ s->cntr = TWI_CNTR_RESET;
236
+ case 0:
439
+ s->stat = TWI_STAT_RESET;
237
+ divisor = 1;
440
+ s->ccr = TWI_CCR_RESET;
441
+ s->srst = TWI_SRST_RESET;
442
+ s->efr = TWI_EFR_RESET;
443
+ s->lcr = TWI_LCR_RESET;
444
+}
445
+
446
+static inline void allwinner_i2c_raise_interrupt(AWI2CState *s)
447
+{
448
+ /*
449
+ * Raise an interrupt if the device is not reset and it is configured
450
+ * to generate some interrupts.
451
+ */
452
+ if (!allwinner_i2c_is_reset(s) && allwinner_i2c_bus_is_enabled(s)) {
453
+ if (STAT_TO_STA(s->stat) != STAT_IDLE) {
454
+ s->cntr |= TWI_CNTR_INT_FLAG;
455
+ if (allwinner_i2c_interrupt_is_enabled(s)) {
456
+ qemu_irq_raise(s->irq);
457
+ }
458
+ }
459
+ }
460
+}
461
+
462
+static uint64_t allwinner_i2c_read(void *opaque, hwaddr offset,
463
+ unsigned size)
464
+{
465
+ uint16_t value;
466
+ AWI2CState *s = AW_I2C(opaque);
467
+
468
+ switch (offset) {
469
+ case TWI_ADDR_REG:
470
+ value = s->addr;
471
+ break;
472
+ case TWI_XADDR_REG:
473
+ value = s->xaddr;
474
+ break;
475
+ case TWI_DATA_REG:
476
+ if ((STAT_TO_STA(s->stat) == STAT_M_ADDR_RD_ACK) ||
477
+ (STAT_TO_STA(s->stat) == STAT_M_DATA_RX_ACK) ||
478
+ (STAT_TO_STA(s->stat) == STAT_M_DATA_RX_NACK)) {
479
+ /* Get the next byte */
480
+ s->data = i2c_recv(s->bus);
481
+
482
+ if (s->cntr & TWI_CNTR_A_ACK) {
483
+ s->stat = STAT_FROM_STA(STAT_M_DATA_RX_ACK);
484
+ } else {
485
+ s->stat = STAT_FROM_STA(STAT_M_DATA_RX_NACK);
486
+ }
487
+ allwinner_i2c_raise_interrupt(s);
488
+ }
489
+ value = s->data;
490
+ break;
491
+ case TWI_CNTR_REG:
492
+ value = s->cntr;
493
+ break;
494
+ case TWI_STAT_REG:
495
+ value = s->stat;
496
+ /*
497
+ * If polling when reading then change state to indicate data
498
+ * is available
499
+ */
500
+ if (STAT_TO_STA(s->stat) == STAT_M_ADDR_RD_ACK) {
501
+ if (s->cntr & TWI_CNTR_A_ACK) {
502
+ s->stat = STAT_FROM_STA(STAT_M_DATA_RX_ACK);
503
+ } else {
504
+ s->stat = STAT_FROM_STA(STAT_M_DATA_RX_NACK);
505
+ }
506
+ allwinner_i2c_raise_interrupt(s);
507
+ }
508
+ break;
509
+ case TWI_CCR_REG:
510
+ value = s->ccr;
511
+ break;
512
+ case TWI_SRST_REG:
513
+ value = s->srst;
514
+ break;
515
+ case TWI_EFR_REG:
516
+ value = s->efr;
517
+ break;
518
+ case TWI_LCR_REG:
519
+ value = s->lcr;
520
+ break;
521
+ default:
522
+ qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad address at offset 0x%"
523
+ HWADDR_PRIx "\n", TYPE_AW_I2C, __func__, offset);
524
+ value = 0;
525
+ break;
526
+ }
527
+
528
+ trace_allwinner_i2c_read(allwinner_i2c_get_regname(offset), offset, value);
529
+
530
+ return (uint64_t)value;
531
+}
532
+
533
+static void allwinner_i2c_write(void *opaque, hwaddr offset,
534
+ uint64_t value, unsigned size)
535
+{
536
+ AWI2CState *s = AW_I2C(opaque);
537
+
538
+ value &= 0xff;
539
+
540
+ trace_allwinner_i2c_write(allwinner_i2c_get_regname(offset), offset, value);
541
+
542
+ switch (offset) {
543
+ case TWI_ADDR_REG:
544
+ s->addr = (uint8_t)value;
545
+ break;
546
+ case TWI_XADDR_REG:
547
+ s->xaddr = (uint8_t)value;
548
+ break;
549
+ case TWI_DATA_REG:
550
+ /* If the device is in reset or not enabled, nothing to do */
551
+ if (allwinner_i2c_is_reset(s) || (!allwinner_i2c_bus_is_enabled(s))) {
238
+ break;
552
+ break;
239
+ case 1:
553
+ }
240
+ divisor = 16;
554
+
555
+ s->data = value & TWI_DATA_MASK;
556
+
557
+ switch (STAT_TO_STA(s->stat)) {
558
+ case STAT_M_STA_TX:
559
+ case STAT_M_RSTA_TX:
560
+ /* Send address */
561
+ if (i2c_start_transfer(s->bus, extract32(s->data, 1, 7),
562
+ extract32(s->data, 0, 1))) {
563
+ /* If non zero is returned, the address is not valid */
564
+ s->stat = STAT_FROM_STA(STAT_M_ADDR_WR_NACK);
565
+ } else {
566
+ /* Determine if read of write */
567
+ if (extract32(s->data, 0, 1)) {
568
+ s->stat = STAT_FROM_STA(STAT_M_ADDR_RD_ACK);
569
+ } else {
570
+ s->stat = STAT_FROM_STA(STAT_M_ADDR_WR_ACK);
571
+ }
572
+ allwinner_i2c_raise_interrupt(s);
573
+ }
241
+ break;
574
+ break;
242
+ case 2:
575
+ case STAT_M_ADDR_WR_ACK:
243
+ divisor = 256;
576
+ case STAT_M_DATA_TX_ACK:
244
+ break;
577
+ if (i2c_send(s->bus, s->data)) {
245
+ case 3:
578
+ /* If the target return non zero then end the transfer */
246
+ /* UNDEFINED; complain, and arbitrarily treat like 2 */
579
+ s->stat = STAT_FROM_STA(STAT_M_DATA_TX_NACK);
247
+ qemu_log_mask(LOG_GUEST_ERROR,
580
+ i2c_end_transfer(s->bus);
248
+ "CMSDK APB dual-timer: CONTROL.PRESCALE==0b11"
581
+ } else {
249
+ " is undefined behaviour\n");
582
+ s->stat = STAT_FROM_STA(STAT_M_DATA_TX_ACK);
250
+ divisor = 256;
583
+ allwinner_i2c_raise_interrupt(s);
584
+ }
251
+ break;
585
+ break;
252
+ default:
586
+ default:
253
+ g_assert_not_reached();
254
+ }
255
+ ptimer_set_freq(m->timer, m->parent->pclk_frq / divisor);
256
+ }
257
+
258
+ if (changed & R_CONTROL_MODE_MASK) {
259
+ uint32_t load;
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
+ }
269
+ m->load = load;
270
+ load = 0xffffffff;
271
+ }
272
+ if (!(m->control & R_CONTROL_SIZE_MASK)) {
273
+ load &= 0xffff;
274
+ }
275
+ ptimer_set_limit(m->timer, load, 0);
276
+ }
277
+
278
+ if (changed & R_CONTROL_SIZE_MASK) {
279
+ /* Timer switched between 16 and 32 bit count */
280
+ uint32_t value, load;
281
+
282
+ value = ptimer_get_count(m->timer);
283
+ load = ptimer_get_limit(m->timer);
284
+ if (newctrl & R_CONTROL_SIZE_MASK) {
285
+ /* 16 -> 32, top half of VALUE is in struct field */
286
+ value = deposit32(m->value, 0, 16, value);
287
+ } else {
288
+ /* 32 -> 16: save top half to struct field and truncate */
289
+ m->value = value;
290
+ value &= 0xffff;
291
+ }
292
+
293
+ if (newctrl & R_CONTROL_MODE_MASK) {
294
+ /* Periodic, timer limit has LOAD value */
295
+ if (newctrl & R_CONTROL_SIZE_MASK) {
296
+ load = deposit32(m->load, 0, 16, load);
297
+ } else {
298
+ m->load = load;
299
+ load &= 0xffff;
300
+ }
301
+ } else {
302
+ /* Free-running, timer limit is set to give wraparound */
303
+ if (newctrl & R_CONTROL_SIZE_MASK) {
304
+ load = 0xffffffff;
305
+ } else {
306
+ load = 0xffff;
307
+ }
308
+ }
309
+ ptimer_set_count(m->timer, value);
310
+ ptimer_set_limit(m->timer, load, 0);
311
+ }
312
+
313
+ if (newctrl & R_CONTROL_ENABLE_MASK) {
314
+ /*
315
+ * ENABLE is set; start the timer after all other changes.
316
+ * We start it even if the ENABLE bit didn't actually change,
317
+ * in case the timer was an expired one-shot timer that has
318
+ * now been changed into a free-running or periodic timer.
319
+ */
320
+ ptimer_run(m->timer, !!(newctrl & R_CONTROL_ONESHOT_MASK));
321
+ }
322
+
323
+ m->control = newctrl;
324
+}
325
+
326
+static uint64_t cmsdk_apb_dualtimer_read(void *opaque, hwaddr offset,
327
+ unsigned size)
328
+{
329
+ CMSDKAPBDualTimer *s = CMSDK_APB_DUALTIMER(opaque);
330
+ uint64_t r;
331
+
332
+ if (offset >= A_TIMERITCR) {
333
+ switch (offset) {
334
+ case A_TIMERITCR:
335
+ r = s->timeritcr;
336
+ break;
337
+ case A_PID4 ... A_CID3:
338
+ r = timer_id[(offset - A_PID4) / 4];
339
+ break;
340
+ default:
341
+ bad_offset:
342
+ qemu_log_mask(LOG_GUEST_ERROR,
343
+ "CMSDK APB dual-timer read: bad offset %x\n",
344
+ (int) offset);
345
+ r = 0;
346
+ break;
587
+ break;
347
+ }
588
+ }
348
+ } else {
589
+ break;
349
+ int timer = offset >> 5;
590
+ case TWI_CNTR_REG:
350
+ CMSDKAPBDualTimerModule *m;
591
+ if (!allwinner_i2c_is_reset(s)) {
351
+
592
+ /* Do something only if not in software reset */
352
+ if (timer >= ARRAY_SIZE(s->timermod)) {
593
+ s->cntr = value & TWI_CNTR_MASK;
353
+ goto bad_offset;
594
+
354
+ }
595
+ /* Check if start condition should be sent */
355
+
596
+ if (s->cntr & TWI_CNTR_M_STA) {
356
+ m = &s->timermod[timer];
597
+ /* Update status */
357
+
598
+ if (STAT_TO_STA(s->stat) == STAT_IDLE) {
358
+ switch (offset & 0x1F) {
599
+ /* Send start condition */
359
+ case A_TIMER1LOAD:
600
+ s->stat = STAT_FROM_STA(STAT_M_STA_TX);
360
+ case A_TIMER1BGLOAD:
601
+ } else {
361
+ if (m->control & R_CONTROL_MODE_MASK) {
602
+ /* Send repeated start condition */
362
+ /*
603
+ s->stat = STAT_FROM_STA(STAT_M_RSTA_TX);
363
+ * Periodic: the ptimer limit is the LOAD register value, (or
604
+ }
364
+ * just the low 16 bits of it if the timer is in 16-bit mode)
605
+ /* Clear start condition */
365
+ */
606
+ s->cntr &= ~TWI_CNTR_M_STA;
366
+ r = ptimer_get_limit(m->timer);
607
+ }
367
+ if (!(m->control & R_CONTROL_SIZE_MASK)) {
608
+ if (s->cntr & TWI_CNTR_M_STP) {
368
+ r = deposit32(m->load, 0, 16, r);
609
+ /* Update status */
610
+ i2c_end_transfer(s->bus);
611
+ s->stat = STAT_FROM_STA(STAT_IDLE);
612
+ s->cntr &= ~TWI_CNTR_M_STP;
613
+ }
614
+ if ((s->cntr & TWI_CNTR_INT_FLAG) == 0) {
615
+ /* Interrupt flag cleared */
616
+ qemu_irq_lower(s->irq);
617
+ }
618
+ if ((s->cntr & TWI_CNTR_A_ACK) == 0) {
619
+ if (STAT_TO_STA(s->stat) == STAT_M_DATA_RX_ACK) {
620
+ s->stat = STAT_FROM_STA(STAT_M_DATA_RX_NACK);
369
+ }
621
+ }
370
+ } else {
622
+ } else {
371
+ /* Free-running: LOAD register value is just in m->load */
623
+ if (STAT_TO_STA(s->stat) == STAT_M_DATA_RX_NACK) {
372
+ r = m->load;
624
+ s->stat = STAT_FROM_STA(STAT_M_DATA_RX_ACK);
373
+ }
625
+ }
374
+ break;
626
+ }
375
+ case A_TIMER1VALUE:
627
+ allwinner_i2c_raise_interrupt(s);
376
+ r = ptimer_get_count(m->timer);
628
+
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
+ }
629
+ }
630
+ break;
631
+ case TWI_CCR_REG:
632
+ s->ccr = value & TWI_CCR_MASK;
633
+ break;
634
+ case TWI_SRST_REG:
635
+ if (((value & TWI_SRST_MASK) == 0) && (s->srst & TWI_SRST_MASK)) {
636
+ /* Perform reset */
637
+ allwinner_i2c_reset_hold(OBJECT(s));
638
+ }
639
+ s->srst = value & TWI_SRST_MASK;
640
+ break;
641
+ case TWI_EFR_REG:
642
+ s->efr = value & TWI_EFR_MASK;
643
+ break;
644
+ case TWI_LCR_REG:
645
+ s->lcr = value & TWI_LCR_MASK;
646
+ break;
647
+ default:
648
+ qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad address at offset 0x%"
649
+ HWADDR_PRIx "\n", TYPE_AW_I2C, __func__, offset);
650
+ break;
393
+ }
651
+ }
394
+
652
+}
395
+ trace_cmsdk_apb_dualtimer_read(offset, r, size);
653
+
396
+ return r;
654
+static const MemoryRegionOps allwinner_i2c_ops = {
397
+}
655
+ .read = allwinner_i2c_read,
398
+
656
+ .write = allwinner_i2c_write,
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,
657
+ .valid.min_access_size = 1,
490
+ .valid.max_access_size = 4,
658
+ .valid.max_access_size = 4,
659
+ .endianness = DEVICE_NATIVE_ENDIAN,
491
+};
660
+};
492
+
661
+
493
+static void cmsdk_dualtimermod_tick(void *opaque)
662
+static const VMStateDescription allwinner_i2c_vmstate = {
494
+{
663
+ .name = TYPE_AW_I2C,
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,
664
+ .version_id = 1,
573
+ .minimum_version_id = 1,
665
+ .minimum_version_id = 1,
574
+ .fields = (VMStateField[]) {
666
+ .fields = (VMStateField[]) {
575
+ VMSTATE_PTIMER(timer, CMSDKAPBDualTimerModule),
667
+ VMSTATE_UINT8(addr, AWI2CState),
576
+ VMSTATE_UINT32(load, CMSDKAPBDualTimerModule),
668
+ VMSTATE_UINT8(xaddr, AWI2CState),
577
+ VMSTATE_UINT32(value, CMSDKAPBDualTimerModule),
669
+ VMSTATE_UINT8(data, AWI2CState),
578
+ VMSTATE_UINT32(control, CMSDKAPBDualTimerModule),
670
+ VMSTATE_UINT8(cntr, AWI2CState),
579
+ VMSTATE_UINT32(intstatus, CMSDKAPBDualTimerModule),
671
+ VMSTATE_UINT8(ccr, AWI2CState),
672
+ VMSTATE_UINT8(srst, AWI2CState),
673
+ VMSTATE_UINT8(efr, AWI2CState),
674
+ VMSTATE_UINT8(lcr, AWI2CState),
580
+ VMSTATE_END_OF_LIST()
675
+ VMSTATE_END_OF_LIST()
581
+ }
676
+ }
582
+};
677
+};
583
+
678
+
584
+static const VMStateDescription cmsdk_apb_dualtimer_vmstate = {
679
+static void allwinner_i2c_realize(DeviceState *dev, Error **errp)
585
+ .name = "cmsdk-apb-dualtimer",
680
+{
586
+ .version_id = 1,
681
+ AWI2CState *s = AW_I2C(dev);
587
+ .minimum_version_id = 1,
682
+
588
+ .fields = (VMStateField[]) {
683
+ memory_region_init_io(&s->iomem, OBJECT(s), &allwinner_i2c_ops, s,
589
+ VMSTATE_STRUCT_ARRAY(timermod, CMSDKAPBDualTimer,
684
+ TYPE_AW_I2C, AW_I2C_MEM_SIZE);
590
+ CMSDK_APB_DUALTIMER_NUM_MODULES,
685
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
591
+ 1, cmsdk_dualtimermod_vmstate,
686
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq);
592
+ CMSDKAPBDualTimerModule),
687
+ s->bus = i2c_init_bus(dev, "i2c");
593
+ VMSTATE_UINT32(timeritcr, CMSDKAPBDualTimer),
688
+}
594
+ VMSTATE_UINT32(timeritop, CMSDKAPBDualTimer),
689
+
595
+ VMSTATE_END_OF_LIST()
690
+static void allwinner_i2c_class_init(ObjectClass *klass, void *data)
596
+ }
691
+{
692
+ DeviceClass *dc = DEVICE_CLASS(klass);
693
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
694
+
695
+ rc->phases.hold = allwinner_i2c_reset_hold;
696
+ dc->vmsd = &allwinner_i2c_vmstate;
697
+ dc->realize = allwinner_i2c_realize;
698
+ dc->desc = "Allwinner I2C Controller";
699
+}
700
+
701
+static const TypeInfo allwinner_i2c_type_info = {
702
+ .name = TYPE_AW_I2C,
703
+ .parent = TYPE_SYS_BUS_DEVICE,
704
+ .instance_size = sizeof(AWI2CState),
705
+ .class_init = allwinner_i2c_class_init,
597
+};
706
+};
598
+
707
+
599
+static Property cmsdk_apb_dualtimer_properties[] = {
708
+static void allwinner_i2c_register_types(void)
600
+ DEFINE_PROP_UINT32("pclk-frq", CMSDKAPBDualTimer, pclk_frq, 0),
709
+{
601
+ DEFINE_PROP_END_OF_LIST(),
710
+ type_register_static(&allwinner_i2c_type_info);
602
+};
711
+}
603
+
712
+
604
+static void cmsdk_apb_dualtimer_class_init(ObjectClass *klass, void *data)
713
+type_init(allwinner_i2c_register_types)
605
+{
714
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
606
+ DeviceClass *dc = DEVICE_CLASS(klass);
715
index XXXXXXX..XXXXXXX 100644
607
+
716
--- a/hw/arm/Kconfig
608
+ dc->realize = cmsdk_apb_dualtimer_realize;
717
+++ b/hw/arm/Kconfig
609
+ dc->vmsd = &cmsdk_apb_dualtimer_vmstate;
718
@@ -XXX,XX +XXX,XX @@ config ALLWINNER_A10
610
+ dc->reset = cmsdk_apb_dualtimer_reset;
719
select ALLWINNER_A10_CCM
611
+ dc->props = cmsdk_apb_dualtimer_properties;
720
select ALLWINNER_A10_DRAMC
612
+}
721
select ALLWINNER_EMAC
613
+
722
+ select ALLWINNER_I2C
614
+static const TypeInfo cmsdk_apb_dualtimer_info = {
723
select SERIAL
615
+ .name = TYPE_CMSDK_APB_DUALTIMER,
724
select UNIMP
616
+ .parent = TYPE_SYS_BUS_DEVICE,
725
617
+ .instance_size = sizeof(CMSDKAPBDualTimer),
726
@@ -XXX,XX +XXX,XX @@ config ALLWINNER_H3
618
+ .instance_init = cmsdk_apb_dualtimer_init,
727
bool
619
+ .class_init = cmsdk_apb_dualtimer_class_init,
728
select ALLWINNER_A10_PIT
620
+};
729
select ALLWINNER_SUN8I_EMAC
621
+
730
+ select ALLWINNER_I2C
622
+static void cmsdk_apb_dualtimer_register_types(void)
731
select SERIAL
623
+{
732
select ARM_TIMER
624
+ type_register_static(&cmsdk_apb_dualtimer_info);
733
select ARM_GIC
625
+}
734
diff --git a/hw/i2c/Kconfig b/hw/i2c/Kconfig
626
+
735
index XXXXXXX..XXXXXXX 100644
627
+type_init(cmsdk_apb_dualtimer_register_types);
736
--- a/hw/i2c/Kconfig
628
diff --git a/MAINTAINERS b/MAINTAINERS
737
+++ b/hw/i2c/Kconfig
629
index XXXXXXX..XXXXXXX 100644
738
@@ -XXX,XX +XXX,XX @@ config MPC_I2C
630
--- a/MAINTAINERS
739
bool
631
+++ b/MAINTAINERS
740
select I2C
632
@@ -XXX,XX +XXX,XX @@ F: hw/timer/pl031.c
741
633
F: include/hw/arm/primecell.h
742
+config ALLWINNER_I2C
634
F: hw/timer/cmsdk-apb-timer.c
743
+ bool
635
F: include/hw/timer/cmsdk-apb-timer.h
744
+ select I2C
636
+F: hw/timer/cmsdk-apb-dualtimer.c
745
+
637
+F: include/hw/timer/cmsdk-apb-dualtimer.h
746
config PCA954X
638
F: hw/char/cmsdk-apb-uart.c
747
bool
639
F: include/hw/char/cmsdk-apb-uart.h
748
select I2C
640
F: hw/watchdog/cmsdk-apb-watchdog.c
749
diff --git a/hw/i2c/meson.build b/hw/i2c/meson.build
641
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
750
index XXXXXXX..XXXXXXX 100644
642
index XXXXXXX..XXXXXXX 100644
751
--- a/hw/i2c/meson.build
643
--- a/default-configs/arm-softmmu.mak
752
+++ b/hw/i2c/meson.build
644
+++ b/default-configs/arm-softmmu.mak
753
@@ -XXX,XX +XXX,XX @@ i2c_ss.add(when: 'CONFIG_BITBANG_I2C', if_true: files('bitbang_i2c.c'))
645
@@ -XXX,XX +XXX,XX @@ CONFIG_STM32F2XX_SPI=y
754
i2c_ss.add(when: 'CONFIG_EXYNOS4', if_true: files('exynos4210_i2c.c'))
646
CONFIG_STM32F205_SOC=y
755
i2c_ss.add(when: 'CONFIG_IMX_I2C', if_true: files('imx_i2c.c'))
647
756
i2c_ss.add(when: 'CONFIG_MPC_I2C', if_true: files('mpc_i2c.c'))
648
CONFIG_CMSDK_APB_TIMER=y
757
+i2c_ss.add(when: 'CONFIG_ALLWINNER_I2C', if_true: files('allwinner-i2c.c'))
649
+CONFIG_CMSDK_APB_DUALTIMER=y
758
i2c_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('microbit_i2c.c'))
650
CONFIG_CMSDK_APB_UART=y
759
i2c_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_smbus.c'))
651
CONFIG_CMSDK_APB_WATCHDOG=y
760
i2c_ss.add(when: 'CONFIG_SMBUS_EEPROM', if_true: files('smbus_eeprom.c'))
652
761
diff --git a/hw/i2c/trace-events b/hw/i2c/trace-events
653
diff --git a/hw/timer/trace-events b/hw/timer/trace-events
762
index XXXXXXX..XXXXXXX 100644
654
index XXXXXXX..XXXXXXX 100644
763
--- a/hw/i2c/trace-events
655
--- a/hw/timer/trace-events
764
+++ b/hw/i2c/trace-events
656
+++ b/hw/timer/trace-events
765
@@ -XXX,XX +XXX,XX @@ i2c_send_async(uint8_t address, uint8_t data) "send_async(addr:0x%02x) data:0x%0
657
@@ -XXX,XX +XXX,XX @@ cmsdk_apb_timer_read(uint64_t offset, uint64_t data, unsigned size) "CMSDK APB t
766
i2c_recv(uint8_t address, uint8_t data) "recv(addr:0x%02x) data:0x%02x"
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"
767
i2c_ack(void) ""
659
cmsdk_apb_timer_reset(void) "CMSDK APB timer: reset"
768
660
769
+# allwinner_i2c.c
661
+# hw/timer/cmsdk_apb_dualtimer.c
770
+
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"
771
+allwinner_i2c_read(const char* reg_name, uint64_t offset, uint64_t value) "read %s [0x%" PRIx64 "]: -> 0x%" PRIx64
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"
772
+allwinner_i2c_write(const char* reg_name, uint64_t offset, uint64_t value) "write %s [0x%" PRIx64 "]: <- 0x%" PRIx64
664
+cmsdk_apb_dualtimer_reset(void) "CMSDK APB dualtimer: reset"
773
+
665
+
774
# aspeed_i2c.c
666
# hw/timer/xlnx-zynqmp-rtc.c
775
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"
776
aspeed_i2c_bus_cmd(uint32_t cmd, const char *cmd_flags, uint32_t count, uint32_t intr_status) "handling cmd=0x%x %s count=%d intr=0x%x"
668
--
777
--
669
2.18.0
778
2.34.1
670
671
diff view generated by jsdifflib
1
Implement a model of the TrustZone Master Securtiy Controller,
1
From: Strahinja Jankovic <strahinjapjankovic@gmail.com>
2
as documented in the Arm CoreLink SIE-200 System IP for
3
Embedded TRM (DDI0571G):
4
https://developer.arm.com/products/architecture/m-profile/docs/ddi0571/g
5
2
6
The MSC is intended to sit in front of a device which can
3
This patch adds minimal support for AXP-209 PMU.
7
be a bus master (eg a DMA controller) and programmably gate
4
Most important is chip ID since U-Boot SPL expects version 0x1. Besides
8
its transactions. This allows a bus-mastering device to be
5
the chip ID register, reset values for two more registers used by A10
9
controlled by non-secure code but still restricted from
6
U-Boot SPL are covered.
10
making accesses to addresses which are secure-only.
11
7
8
Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
9
Message-id: 20221226220303.14420-5-strahinja.p.jankovic@gmail.com
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
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
---
12
---
16
hw/misc/Makefile.objs | 1 +
13
hw/misc/axp209.c | 238 +++++++++++++++++++++++++++++++++++++++++++
17
include/hw/misc/tz-msc.h | 79 ++++++++
14
MAINTAINERS | 2 +
18
hw/misc/tz-msc.c | 308 ++++++++++++++++++++++++++++++++
15
hw/misc/Kconfig | 4 +
19
MAINTAINERS | 2 +
16
hw/misc/meson.build | 1 +
20
default-configs/arm-softmmu.mak | 1 +
17
hw/misc/trace-events | 5 +
21
hw/misc/trace-events | 9 +
18
5 files changed, 250 insertions(+)
22
6 files changed, 400 insertions(+)
19
create mode 100644 hw/misc/axp209.c
23
create mode 100644 include/hw/misc/tz-msc.h
24
create mode 100644 hw/misc/tz-msc.c
25
20
26
diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs
21
diff --git a/hw/misc/axp209.c b/hw/misc/axp209.c
27
index XXXXXXX..XXXXXXX 100644
28
--- a/hw/misc/Makefile.objs
29
+++ b/hw/misc/Makefile.objs
30
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_MPS2_FPGAIO) += mps2-fpgaio.o
31
obj-$(CONFIG_MPS2_SCC) += mps2-scc.o
32
33
obj-$(CONFIG_TZ_MPC) += tz-mpc.o
34
+obj-$(CONFIG_TZ_MSC) += tz-msc.o
35
obj-$(CONFIG_TZ_PPC) += tz-ppc.o
36
obj-$(CONFIG_IOTKIT_SECCTL) += iotkit-secctl.o
37
obj-$(CONFIG_IOTKIT_SYSCTL) += iotkit-sysctl.o
38
diff --git a/include/hw/misc/tz-msc.h b/include/hw/misc/tz-msc.h
39
new file mode 100644
22
new file mode 100644
40
index XXXXXXX..XXXXXXX
23
index XXXXXXX..XXXXXXX
41
--- /dev/null
24
--- /dev/null
42
+++ b/include/hw/misc/tz-msc.h
25
+++ b/hw/misc/axp209.c
43
@@ -XXX,XX +XXX,XX @@
26
@@ -XXX,XX +XXX,XX @@
44
+/*
27
+/*
45
+ * ARM TrustZone master security controller emulation
28
+ * AXP-209 PMU Emulation
46
+ *
29
+ *
47
+ * Copyright (c) 2018 Linaro Limited
30
+ * Copyright (C) 2022 Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
48
+ * Written by Peter Maydell
31
+ *
49
+ *
32
+ * Permission is hereby granted, free of charge, to any person obtaining a
50
+ * This program is free software; you can redistribute it and/or modify
33
+ * copy of this software and associated documentation files (the "Software"),
51
+ * it under the terms of the GNU General Public License version 2 or
34
+ * to deal in the Software without restriction, including without limitation
52
+ * (at your option) any later version.
35
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
53
+ */
36
+ * and/or sell copies of the Software, and to permit persons to whom the
54
+
37
+ * Software is furnished to do so, subject to the following conditions:
55
+/*
38
+ *
56
+ * This is a model of the TrustZone master security controller (MSC).
39
+ * The above copyright notice and this permission notice shall be included in
57
+ * It is documented in the ARM CoreLink SIE-200 System IP for Embedded TRM
40
+ * all copies or substantial portions of the Software.
58
+ * (DDI 0571G):
41
+ *
59
+ * https://developer.arm.com/products/architecture/m-profile/docs/ddi0571/g
42
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
60
+ *
43
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
61
+ * The MSC sits in front of a device which can be a bus master (such as
44
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
62
+ * a DMA controller) and allows secure software to configure it to either
45
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
63
+ * pass through or reject transactions made by that bus master.
46
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
64
+ * Rejected transactions may be configured to either be aborted, or to
47
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
65
+ * behave as RAZ/WI. An interrupt can be signalled for a rejected transaction.
48
+ * DEALINGS IN THE SOFTWARE.
66
+ *
49
+ *
67
+ * The MSC has no register interface -- it is configured purely by a
50
+ * SPDX-License-Identifier: MIT
68
+ * collection of input signals from other hardware in the system. Typically
69
+ * they are either hardwired or exposed in an ad-hoc register interface by
70
+ * the SoC that uses the MSC.
71
+ *
72
+ * We don't currently implement the irq_enable GPIO input, because on
73
+ * the MPS2 FPGA images it is always tied high, which is awkward to
74
+ * implement in QEMU.
75
+ *
76
+ * QEMU interface:
77
+ * + Named GPIO input "cfg_nonsec": set to 1 if the bus master should be
78
+ * treated as nonsecure, or 0 for secure
79
+ * + Named GPIO input "cfg_sec_resp": set to 1 if a rejected transaction should
80
+ * result in a transaction error, or 0 for the transaction to RAZ/WI
81
+ * + Named GPIO input "irq_clear": set to 1 to clear a pending interrupt
82
+ * + Named GPIO output "irq": set for a transaction-failed interrupt
83
+ * + Property "downstream": MemoryRegion defining where bus master transactions
84
+ * are made if they are not blocked
85
+ * + Property "idau": an object implementing IDAUInterface, which defines which
86
+ * addresses should be treated as secure and which as non-secure.
87
+ * This need not be the same IDAU as the one used by the CPU.
88
+ * + sysbus MMIO region 0: MemoryRegion defining the upstream end of the MSC;
89
+ * this should be passed to the bus master device as the region it should
90
+ * make memory transactions to
91
+ */
92
+
93
+#ifndef TZ_MSC_H
94
+#define TZ_MSC_H
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
+ */
51
+ */
139
+
52
+
140
+#include "qemu/osdep.h"
53
+#include "qemu/osdep.h"
141
+#include "qemu/log.h"
54
+#include "qemu/log.h"
142
+#include "qapi/error.h"
143
+#include "trace.h"
55
+#include "trace.h"
144
+#include "hw/sysbus.h"
56
+#include "hw/i2c/i2c.h"
145
+#include "hw/registerfields.h"
57
+#include "migration/vmstate.h"
146
+#include "hw/misc/tz-msc.h"
58
+
147
+
59
+#define TYPE_AXP209_PMU "axp209_pmu"
148
+static void tz_msc_update_irq(TZMSC *s)
60
+
149
+{
61
+#define AXP209(obj) \
150
+ bool level = s->irq_status;
62
+ OBJECT_CHECK(AXP209I2CState, (obj), TYPE_AXP209_PMU)
151
+
63
+
152
+ trace_tz_msc_update_irq(level);
64
+/* registers */
153
+ qemu_set_irq(s->irq, level);
65
+enum {
154
+}
66
+ REG_POWER_STATUS = 0x0u,
155
+
67
+ REG_OPERATING_MODE,
156
+static void tz_msc_cfg_nonsec(void *opaque, int n, int level)
68
+ REG_OTG_VBUS_STATUS,
157
+{
69
+ REG_CHIP_VERSION,
158
+ TZMSC *s = TZ_MSC(opaque);
70
+ REG_DATA_CACHE_0,
159
+
71
+ REG_DATA_CACHE_1,
160
+ trace_tz_msc_cfg_nonsec(level);
72
+ REG_DATA_CACHE_2,
161
+ s->cfg_nonsec = level;
73
+ REG_DATA_CACHE_3,
162
+}
74
+ REG_DATA_CACHE_4,
163
+
75
+ REG_DATA_CACHE_5,
164
+static void tz_msc_cfg_sec_resp(void *opaque, int n, int level)
76
+ REG_DATA_CACHE_6,
165
+{
77
+ REG_DATA_CACHE_7,
166
+ TZMSC *s = TZ_MSC(opaque);
78
+ REG_DATA_CACHE_8,
167
+
79
+ REG_DATA_CACHE_9,
168
+ trace_tz_msc_cfg_sec_resp(level);
80
+ REG_DATA_CACHE_A,
169
+ s->cfg_sec_resp = level;
81
+ REG_DATA_CACHE_B,
170
+}
82
+ REG_POWER_OUTPUT_CTRL = 0x12u,
171
+
83
+ REG_DC_DC2_OUT_V_CTRL = 0x23u,
172
+static void tz_msc_irq_clear(void *opaque, int n, int level)
84
+ REG_DC_DC2_DVS_CTRL = 0x25u,
173
+{
85
+ REG_DC_DC3_OUT_V_CTRL = 0x27u,
174
+ TZMSC *s = TZ_MSC(opaque);
86
+ REG_LDO2_4_OUT_V_CTRL,
175
+
87
+ REG_LDO3_OUT_V_CTRL,
176
+ trace_tz_msc_irq_clear(level);
88
+ REG_VBUS_CH_MGMT = 0x30u,
177
+
89
+ REG_SHUTDOWN_V_CTRL,
178
+ s->irq_clear = level;
90
+ REG_SHUTDOWN_CTRL,
179
+ if (level) {
91
+ REG_CHARGE_CTRL_1,
180
+ s->irq_status = false;
92
+ REG_CHARGE_CTRL_2,
181
+ tz_msc_update_irq(s);
93
+ REG_SPARE_CHARGE_CTRL,
94
+ REG_PEK_KEY_CTRL,
95
+ REG_DC_DC_FREQ_SET,
96
+ REG_CHR_TEMP_TH_SET,
97
+ REG_CHR_HIGH_TEMP_TH_CTRL,
98
+ REG_IPSOUT_WARN_L1,
99
+ REG_IPSOUT_WARN_L2,
100
+ REG_DISCHR_TEMP_TH_SET,
101
+ REG_DISCHR_HIGH_TEMP_TH_CTRL,
102
+ REG_IRQ_BANK_1_CTRL = 0x40u,
103
+ REG_IRQ_BANK_2_CTRL,
104
+ REG_IRQ_BANK_3_CTRL,
105
+ REG_IRQ_BANK_4_CTRL,
106
+ REG_IRQ_BANK_5_CTRL,
107
+ REG_IRQ_BANK_1_STAT = 0x48u,
108
+ REG_IRQ_BANK_2_STAT,
109
+ REG_IRQ_BANK_3_STAT,
110
+ REG_IRQ_BANK_4_STAT,
111
+ REG_IRQ_BANK_5_STAT,
112
+ REG_ADC_ACIN_V_H = 0x56u,
113
+ REG_ADC_ACIN_V_L,
114
+ REG_ADC_ACIN_CURR_H,
115
+ REG_ADC_ACIN_CURR_L,
116
+ REG_ADC_VBUS_V_H,
117
+ REG_ADC_VBUS_V_L,
118
+ REG_ADC_VBUS_CURR_H,
119
+ REG_ADC_VBUS_CURR_L,
120
+ REG_ADC_INT_TEMP_H,
121
+ REG_ADC_INT_TEMP_L,
122
+ REG_ADC_TEMP_SENS_V_H = 0x62u,
123
+ REG_ADC_TEMP_SENS_V_L,
124
+ REG_ADC_BAT_V_H = 0x78u,
125
+ REG_ADC_BAT_V_L,
126
+ REG_ADC_BAT_DISCHR_CURR_H,
127
+ REG_ADC_BAT_DISCHR_CURR_L,
128
+ REG_ADC_BAT_CHR_CURR_H,
129
+ REG_ADC_BAT_CHR_CURR_L,
130
+ REG_ADC_IPSOUT_V_H,
131
+ REG_ADC_IPSOUT_V_L,
132
+ REG_DC_DC_MOD_SEL = 0x80u,
133
+ REG_ADC_EN_1,
134
+ REG_ADC_EN_2,
135
+ REG_ADC_SR_CTRL,
136
+ REG_ADC_IN_RANGE,
137
+ REG_GPIO1_ADC_IRQ_RISING_TH,
138
+ REG_GPIO1_ADC_IRQ_FALLING_TH,
139
+ REG_TIMER_CTRL = 0x8au,
140
+ REG_VBUS_CTRL_MON_SRP,
141
+ REG_OVER_TEMP_SHUTDOWN = 0x8fu,
142
+ REG_GPIO0_FEAT_SET,
143
+ REG_GPIO_OUT_HIGH_SET,
144
+ REG_GPIO1_FEAT_SET,
145
+ REG_GPIO2_FEAT_SET,
146
+ REG_GPIO_SIG_STATE_SET_MON,
147
+ REG_GPIO3_SET,
148
+ REG_COULOMB_CNTR_CTRL = 0xb8u,
149
+ REG_POWER_MEAS_RES,
150
+ NR_REGS
151
+};
152
+
153
+#define AXP209_CHIP_VERSION_ID (0x01)
154
+#define AXP209_DC_DC2_OUT_V_CTRL_RESET (0x16)
155
+#define AXP209_IRQ_BANK_1_CTRL_RESET (0xd8)
156
+
157
+/* A simple I2C slave which returns values of ID or CNT register. */
158
+typedef struct AXP209I2CState {
159
+ /*< private >*/
160
+ I2CSlave i2c;
161
+ /*< public >*/
162
+ uint8_t regs[NR_REGS]; /* peripheral registers */
163
+ uint8_t ptr; /* current register index */
164
+ uint8_t count; /* counter used for tx/rx */
165
+} AXP209I2CState;
166
+
167
+/* Reset all counters and load ID register */
168
+static void axp209_reset_enter(Object *obj, ResetType type)
169
+{
170
+ AXP209I2CState *s = AXP209(obj);
171
+
172
+ memset(s->regs, 0, NR_REGS);
173
+ s->ptr = 0;
174
+ s->count = 0;
175
+ s->regs[REG_CHIP_VERSION] = AXP209_CHIP_VERSION_ID;
176
+ s->regs[REG_DC_DC2_OUT_V_CTRL] = AXP209_DC_DC2_OUT_V_CTRL_RESET;
177
+ s->regs[REG_IRQ_BANK_1_CTRL] = AXP209_IRQ_BANK_1_CTRL_RESET;
178
+}
179
+
180
+/* Handle events from master. */
181
+static int axp209_event(I2CSlave *i2c, enum i2c_event event)
182
+{
183
+ AXP209I2CState *s = AXP209(i2c);
184
+
185
+ s->count = 0;
186
+
187
+ return 0;
188
+}
189
+
190
+/* Called when master requests read */
191
+static uint8_t axp209_rx(I2CSlave *i2c)
192
+{
193
+ AXP209I2CState *s = AXP209(i2c);
194
+ uint8_t ret = 0xff;
195
+
196
+ if (s->ptr < NR_REGS) {
197
+ ret = s->regs[s->ptr++];
182
+ }
198
+ }
183
+}
199
+
184
+
200
+ trace_axp209_rx(s->ptr - 1, ret);
185
+/* The MSC may either block a transaction by aborting it, block a
201
+
186
+ * transaction by making it RAZ/WI, allow it through with
202
+ return ret;
187
+ * MemTxAttrs indicating a secure transaction, or allow it with
203
+}
188
+ * MemTxAttrs indicating a non-secure transaction.
204
+
205
+/*
206
+ * Called when master sends write.
207
+ * Update ptr with byte 0, then perform write with second byte.
189
+ */
208
+ */
190
+typedef enum MSCAction {
209
+static int axp209_tx(I2CSlave *i2c, uint8_t data)
191
+ MSCBlockAbort,
210
+{
192
+ MSCBlockRAZWI,
211
+ AXP209I2CState *s = AXP209(i2c);
193
+ MSCAllowSecure,
212
+
194
+ MSCAllowNonSecure,
213
+ if (s->count == 0) {
195
+} MSCAction;
214
+ /* Store register address */
196
+
215
+ s->ptr = data;
197
+static MSCAction tz_msc_check(TZMSC *s, hwaddr addr)
216
+ s->count++;
198
+{
217
+ trace_axp209_select(data);
199
+ /*
218
+ } else {
200
+ * Check whether to allow an access from the bus master, returning
219
+ trace_axp209_tx(s->ptr, data);
201
+ * an MSCAction indicating the required behaviour. If the transaction
220
+ if (s->ptr == REG_DC_DC2_OUT_V_CTRL) {
202
+ * is blocked, the caller must check cfg_sec_resp to determine
221
+ s->regs[s->ptr++] = data;
203
+ * whether to abort or RAZ/WI the transaction.
222
+ }
204
+ */
205
+ IDAUInterfaceClass *iic = IDAU_INTERFACE_GET_CLASS(s->idau);
206
+ IDAUInterface *ii = IDAU_INTERFACE(s->idau);
207
+ bool idau_exempt = false, idau_ns = true, idau_nsc = true;
208
+ int idau_region = IREGION_NOTVALID;
209
+
210
+ iic->check(ii, addr, &idau_region, &idau_exempt, &idau_ns, &idau_nsc);
211
+
212
+ if (idau_exempt) {
213
+ /*
214
+ * Uncheck region -- OK, transaction type depends on
215
+ * whether bus master is configured as Secure or NonSecure
216
+ */
217
+ return s->cfg_nonsec ? MSCAllowNonSecure : MSCAllowSecure;
218
+ }
223
+ }
219
+
224
+
220
+ if (idau_ns) {
225
+ return 0;
221
+ /* NonSecure region -- always forward as NS transaction */
226
+}
222
+ return MSCAllowNonSecure;
227
+
223
+ }
228
+static const VMStateDescription vmstate_axp209 = {
224
+
229
+ .name = TYPE_AXP209_PMU,
225
+ if (!s->cfg_nonsec) {
226
+ /* Access to Secure region by Secure bus master: OK */
227
+ return MSCAllowSecure;
228
+ }
229
+
230
+ /* Attempted access to Secure region by NS bus master: block */
231
+ trace_tz_msc_access_blocked(addr);
232
+ if (!s->cfg_sec_resp) {
233
+ return MSCBlockRAZWI;
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,
230
+ .version_id = 1,
395
+ .minimum_version_id = 1,
396
+ .fields = (VMStateField[]) {
231
+ .fields = (VMStateField[]) {
397
+ VMSTATE_BOOL(cfg_nonsec, TZMSC),
232
+ VMSTATE_UINT8_ARRAY(regs, AXP209I2CState, NR_REGS),
398
+ VMSTATE_BOOL(cfg_sec_resp, TZMSC),
233
+ VMSTATE_UINT8(count, AXP209I2CState),
399
+ VMSTATE_BOOL(irq_clear, TZMSC),
234
+ VMSTATE_UINT8(ptr, AXP209I2CState),
400
+ VMSTATE_BOOL(irq_status, TZMSC),
401
+ VMSTATE_END_OF_LIST()
235
+ VMSTATE_END_OF_LIST()
402
+ }
236
+ }
403
+};
237
+};
404
+
238
+
405
+static Property tz_msc_properties[] = {
239
+static void axp209_class_init(ObjectClass *oc, void *data)
406
+ DEFINE_PROP_LINK("downstream", TZMSC, downstream,
240
+{
407
+ TYPE_MEMORY_REGION, MemoryRegion *),
241
+ DeviceClass *dc = DEVICE_CLASS(oc);
408
+ DEFINE_PROP_LINK("idau", TZMSC, idau,
242
+ I2CSlaveClass *isc = I2C_SLAVE_CLASS(oc);
409
+ TYPE_IDAU_INTERFACE, IDAUInterface *),
243
+ ResettableClass *rc = RESETTABLE_CLASS(oc);
410
+ DEFINE_PROP_END_OF_LIST(),
244
+
245
+ rc->phases.enter = axp209_reset_enter;
246
+ dc->vmsd = &vmstate_axp209;
247
+ isc->event = axp209_event;
248
+ isc->recv = axp209_rx;
249
+ isc->send = axp209_tx;
250
+}
251
+
252
+static const TypeInfo axp209_info = {
253
+ .name = TYPE_AXP209_PMU,
254
+ .parent = TYPE_I2C_SLAVE,
255
+ .instance_size = sizeof(AXP209I2CState),
256
+ .class_init = axp209_class_init
411
+};
257
+};
412
+
258
+
413
+static void tz_msc_class_init(ObjectClass *klass, void *data)
259
+static void axp209_register_devices(void)
414
+{
260
+{
415
+ DeviceClass *dc = DEVICE_CLASS(klass);
261
+ type_register_static(&axp209_info);
416
+
262
+}
417
+ dc->realize = tz_msc_realize;
263
+
418
+ dc->vmsd = &tz_msc_vmstate;
264
+type_init(axp209_register_devices);
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
265
diff --git a/MAINTAINERS b/MAINTAINERS
438
index XXXXXXX..XXXXXXX 100644
266
index XXXXXXX..XXXXXXX 100644
439
--- a/MAINTAINERS
267
--- a/MAINTAINERS
440
+++ b/MAINTAINERS
268
+++ b/MAINTAINERS
441
@@ -XXX,XX +XXX,XX @@ F: hw/misc/tz-ppc.c
269
@@ -XXX,XX +XXX,XX @@ ARM Machines
442
F: include/hw/misc/tz-ppc.h
270
Allwinner-a10
443
F: hw/misc/tz-mpc.c
271
M: Beniamino Galvani <b.galvani@gmail.com>
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>
272
M: Peter Maydell <peter.maydell@linaro.org>
450
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
273
+R: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
274
L: qemu-arm@nongnu.org
275
S: Odd Fixes
276
F: hw/*/allwinner*
277
F: include/hw/*/allwinner*
278
F: hw/arm/cubieboard.c
279
F: docs/system/arm/cubieboard.rst
280
+F: hw/misc/axp209.c
281
282
Allwinner-h3
283
M: Niek Linnenbank <nieklinnenbank@gmail.com>
284
diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
451
index XXXXXXX..XXXXXXX 100644
285
index XXXXXXX..XXXXXXX 100644
452
--- a/default-configs/arm-softmmu.mak
286
--- a/hw/misc/Kconfig
453
+++ b/default-configs/arm-softmmu.mak
287
+++ b/hw/misc/Kconfig
454
@@ -XXX,XX +XXX,XX @@ CONFIG_MPS2_FPGAIO=y
288
@@ -XXX,XX +XXX,XX @@ config ALLWINNER_A10_CCM
455
CONFIG_MPS2_SCC=y
289
config ALLWINNER_A10_DRAMC
456
290
bool
457
CONFIG_TZ_MPC=y
291
458
+CONFIG_TZ_MSC=y
292
+config AXP209_PMU
459
CONFIG_TZ_PPC=y
293
+ bool
460
CONFIG_IOTKIT=y
294
+ depends on I2C
461
CONFIG_IOTKIT_SECCTL=y
295
+
296
source macio/Kconfig
297
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
298
index XXXXXXX..XXXXXXX 100644
299
--- a/hw/misc/meson.build
300
+++ b/hw/misc/meson.build
301
@@ -XXX,XX +XXX,XX @@ specific_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-cpucfg.c'
302
softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-dramc.c'))
303
softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-sysctrl.c'))
304
softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-sid.c'))
305
+softmmu_ss.add(when: 'CONFIG_AXP209_PMU', if_true: files('axp209.c'))
306
softmmu_ss.add(when: 'CONFIG_REALVIEW', if_true: files('arm_sysctl.c'))
307
softmmu_ss.add(when: 'CONFIG_NSERIES', if_true: files('cbus.c'))
308
softmmu_ss.add(when: 'CONFIG_ECCMEMCTL', if_true: files('eccmemctl.c'))
462
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
309
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
463
index XXXXXXX..XXXXXXX 100644
310
index XXXXXXX..XXXXXXX 100644
464
--- a/hw/misc/trace-events
311
--- a/hw/misc/trace-events
465
+++ b/hw/misc/trace-events
312
+++ 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
313
@@ -XXX,XX +XXX,XX @@ allwinner_sid_write(uint64_t offset, uint64_t data, unsigned size) "offset 0x%"
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"
314
avr_power_read(uint8_t value) "power_reduc read value:%u"
468
tz_mpc_iommu_notify(uint64_t addr) "TZ MPC iommu: notifying UNMAP/MAP for 0x%" PRIx64
315
avr_power_write(uint8_t value) "power_reduc write value:%u"
469
316
470
+# hw/misc/tz-msc.c
317
+# axp209.c
471
+tz_msc_reset(void) "TZ MSC: reset"
318
+axp209_rx(uint8_t reg, uint8_t data) "Read reg 0x%" PRIx8 " : 0x%" PRIx8
472
+tz_msc_cfg_nonsec(int level) "TZ MSC: cfg_nonsec = %d"
319
+axp209_select(uint8_t reg) "Accessing reg 0x%" PRIx8
473
+tz_msc_cfg_sec_resp(int level) "TZ MSC: cfg_sec_resp = %d"
320
+axp209_tx(uint8_t reg, uint8_t data) "Write reg 0x%" PRIx8 " : 0x%" PRIx8
474
+tz_msc_irq_enable(int level) "TZ MSC: int_enable = %d"
321
+
475
+tz_msc_irq_clear(int level) "TZ MSC: int_clear = %d"
322
# eccmemctl.c
476
+tz_msc_update_irq(int level) "TZ MSC: setting irq line to %d"
323
ecc_mem_writel_mer(uint32_t val) "Write memory enable 0x%08x"
477
+tz_msc_access_blocked(uint64_t offset) "TZ MSC: offset 0x%" PRIx64 " access blocked"
324
ecc_mem_writel_mdr(uint32_t val) "Write memory delay 0x%08x"
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
--
325
--
483
2.18.0
326
2.34.1
484
485
diff view generated by jsdifflib
1
The bcm2835_fb's initial resolution and other parameters are set
1
From: Strahinja Jankovic <strahinjapjankovic@gmail.com>
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
SPL Boot for Cubieboard expects AXP209 connected to I2C0 bus.
4
5
Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
6
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Message-id: 20221226220303.14420-6-strahinja.p.jankovic@gmail.com
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
hw/arm/cubieboard.c | 6 ++++++
12
hw/display/bcm2835_fb.c | 27 +++++++++++++++------------
12
hw/arm/Kconfig | 1 +
13
2 files changed, 16 insertions(+), 12 deletions(-)
13
2 files changed, 7 insertions(+)
14
14
15
diff --git a/include/hw/display/bcm2835_fb.h b/include/hw/display/bcm2835_fb.h
15
diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c
16
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/display/bcm2835_fb.h
17
--- a/hw/arm/cubieboard.c
18
+++ b/include/hw/display/bcm2835_fb.h
18
+++ b/hw/arm/cubieboard.c
19
@@ -XXX,XX +XXX,XX @@ typedef struct {
19
@@ -XXX,XX +XXX,XX @@
20
bool lock, invalidate, pending;
20
#include "hw/boards.h"
21
21
#include "hw/qdev-properties.h"
22
BCM2835FBConfig config;
22
#include "hw/arm/allwinner-a10.h"
23
+ BCM2835FBConfig initial_config;
23
+#include "hw/i2c/i2c.h"
24
} BCM2835FBState;
24
25
25
static struct arm_boot_info cubieboard_binfo = {
26
void bcm2835_fb_reconfigure(BCM2835FBState *s, BCM2835FBConfig *newconfig);
26
.loader_start = AW_A10_SDRAM_BASE,
27
diff --git a/hw/display/bcm2835_fb.c b/hw/display/bcm2835_fb.c
27
@@ -XXX,XX +XXX,XX @@ static void cubieboard_init(MachineState *machine)
28
BlockBackend *blk;
29
BusState *bus;
30
DeviceState *carddev;
31
+ I2CBus *i2c;
32
33
/* BIOS is not supported by this board */
34
if (machine->firmware) {
35
@@ -XXX,XX +XXX,XX @@ static void cubieboard_init(MachineState *machine)
36
exit(1);
37
}
38
39
+ /* Connect AXP 209 */
40
+ i2c = I2C_BUS(qdev_get_child_bus(DEVICE(&a10->i2c0), "i2c"));
41
+ i2c_slave_create_simple(i2c, "axp209_pmu", 0x34);
42
+
43
/* Retrieve SD bus */
44
di = drive_get(IF_SD, 0, 0);
45
blk = di ? blk_by_legacy_dinfo(di) : NULL;
46
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
28
index XXXXXXX..XXXXXXX 100644
47
index XXXXXXX..XXXXXXX 100644
29
--- a/hw/display/bcm2835_fb.c
48
--- a/hw/arm/Kconfig
30
+++ b/hw/display/bcm2835_fb.c
49
+++ b/hw/arm/Kconfig
31
@@ -XXX,XX +XXX,XX @@ static void bcm2835_fb_reset(DeviceState *dev)
50
@@ -XXX,XX +XXX,XX @@ config ALLWINNER_A10
32
51
select ALLWINNER_A10_DRAMC
33
s->pending = false;
52
select ALLWINNER_EMAC
34
53
select ALLWINNER_I2C
35
- s->config.xres_virtual = s->config.xres;
54
+ select AXP209_PMU
36
- s->config.yres_virtual = s->config.yres;
55
select SERIAL
37
- s->config.xoffset = 0;
56
select UNIMP
38
- s->config.yoffset = 0;
39
- s->config.base = s->vcram_base + BCM2835_FB_OFFSET;
40
+ s->config = s->initial_config;
41
42
s->invalidate = true;
43
s->lock = false;
44
@@ -XXX,XX +XXX,XX @@ static void bcm2835_fb_realize(DeviceState *dev, Error **errp)
45
return;
46
}
47
48
+ /* Fill in the parts of initial_config that are not set by QOM properties */
49
+ s->initial_config.xres_virtual = s->initial_config.xres;
50
+ s->initial_config.yres_virtual = s->initial_config.yres;
51
+ s->initial_config.xoffset = 0;
52
+ s->initial_config.yoffset = 0;
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
57
79
--
58
--
80
2.18.0
59
2.34.1
81
60
82
61
diff view generated by jsdifflib
1
Validate the config settings that the guest tries to set.
1
From: Strahinja Jankovic <strahinjapjankovic@gmail.com>
2
2
3
The wiki page documentation is not really accurate here:
3
This patch enables copying of SPL from MMC if `-kernel` parameter is not
4
generally rather than failing requests to set bad parameters,
4
passed when starting QEMU. SPL is copied to SRAM_A.
5
the hardware will just clip them to something sensible.
6
5
7
Validate the most important parameters: sizes and
6
The approach is reused from Allwinner H3 implementation.
8
the viewport offsets. This prevents the framebuffer
9
code from trying to read out-of-range memory.
10
7
11
In the property handling code, we validate the new parameters every
8
Tested with Armbian and custom Yocto image.
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
9
18
Validation of settings made via the older bcm2835_fb_mbox_push()
10
Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
19
function will be done in the next commit.
20
11
12
Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>
13
Message-id: 20221226220303.14420-7-strahinja.p.jankovic@gmail.com
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
23
Message-id: 20180814144436.679-8-peter.maydell@linaro.org
24
---
15
---
25
include/hw/display/bcm2835_fb.h | 8 +++++
16
include/hw/arm/allwinner-a10.h | 21 +++++++++++++++++++++
26
hw/display/bcm2835_fb.c | 48 +++++++++++++++++++++++++++--
17
hw/arm/allwinner-a10.c | 18 ++++++++++++++++++
27
hw/misc/bcm2835_property.c | 54 ++++++++++++++++-----------------
18
hw/arm/cubieboard.c | 5 +++++
28
3 files changed, 81 insertions(+), 29 deletions(-)
19
3 files changed, 44 insertions(+)
29
20
30
diff --git a/include/hw/display/bcm2835_fb.h b/include/hw/display/bcm2835_fb.h
21
diff --git a/include/hw/arm/allwinner-a10.h b/include/hw/arm/allwinner-a10.h
31
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
32
--- a/include/hw/display/bcm2835_fb.h
23
--- a/include/hw/arm/allwinner-a10.h
33
+++ b/include/hw/display/bcm2835_fb.h
24
+++ b/include/hw/arm/allwinner-a10.h
34
@@ -XXX,XX +XXX,XX @@ static inline uint32_t bcm2835_fb_get_size(BCM2835FBConfig *config)
25
@@ -XXX,XX +XXX,XX @@
35
return yres * bcm2835_fb_get_pitch(config);
26
#include "hw/misc/allwinner-a10-ccm.h"
36
}
27
#include "hw/misc/allwinner-a10-dramc.h"
28
#include "hw/i2c/allwinner-i2c.h"
29
+#include "sysemu/block-backend.h"
30
31
#include "target/arm/cpu.h"
32
#include "qom/object.h"
33
@@ -XXX,XX +XXX,XX @@ struct AwA10State {
34
OHCISysBusState ohci[AW_A10_NUM_USB];
35
};
37
36
38
+/**
37
+/**
39
+ * bcm2835_fb_validate_config: check provided config
38
+ * Emulate Boot ROM firmware setup functionality.
40
+ *
39
+ *
41
+ * Validates the configuration information provided by the guest and
40
+ * A real Allwinner A10 SoC contains a Boot ROM
42
+ * adjusts it if necessary.
41
+ * which is the first code that runs right after
42
+ * the SoC is powered on. The Boot ROM is responsible
43
+ * for loading user code (e.g. a bootloader) from any
44
+ * of the supported external devices and writing the
45
+ * downloaded code to internal SRAM. After loading the SoC
46
+ * begins executing the code written to SRAM.
47
+ *
48
+ * This function emulates the Boot ROM by copying 32 KiB
49
+ * of data at offset 8 KiB from the given block device and writes it to
50
+ * the start of the first internal SRAM memory.
51
+ *
52
+ * @s: Allwinner A10 state object pointer
53
+ * @blk: Block backend device object pointer
43
+ */
54
+ */
44
+void bcm2835_fb_validate_config(BCM2835FBConfig *config);
55
+void allwinner_a10_bootrom_setup(AwA10State *s, BlockBackend *blk);
45
+
56
+
46
#endif
57
#endif
47
diff --git a/hw/display/bcm2835_fb.c b/hw/display/bcm2835_fb.c
58
diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
48
index XXXXXXX..XXXXXXX 100644
59
index XXXXXXX..XXXXXXX 100644
49
--- a/hw/display/bcm2835_fb.c
60
--- a/hw/arm/allwinner-a10.c
50
+++ b/hw/display/bcm2835_fb.c
61
+++ b/hw/arm/allwinner-a10.c
51
@@ -XXX,XX +XXX,XX @@
62
@@ -XXX,XX +XXX,XX @@
52
#define DEFAULT_VCRAM_SIZE 0x4000000
63
#include "sysemu/sysemu.h"
53
#define BCM2835_FB_OFFSET 0x00100000
64
#include "hw/boards.h"
54
65
#include "hw/usb/hcd-ohci.h"
55
+/* Maximum permitted framebuffer size; experimentally determined on an rpi2 */
66
+#include "hw/loader.h"
56
+#define XRES_MAX 3840
67
57
+#define YRES_MAX 2560
68
+#define AW_A10_SRAM_A_BASE 0x00000000
58
+/* Framebuffer size used if guest requests zero size */
69
#define AW_A10_DRAMC_BASE 0x01c01000
59
+#define XRES_SMALL 592
70
#define AW_A10_MMC0_BASE 0x01c0f000
60
+#define YRES_SMALL 488
71
#define AW_A10_CCM_BASE 0x01c20000
72
@@ -XXX,XX +XXX,XX @@
73
#define AW_A10_RTC_BASE 0x01c20d00
74
#define AW_A10_I2C0_BASE 0x01c2ac00
75
76
+void allwinner_a10_bootrom_setup(AwA10State *s, BlockBackend *blk)
77
+{
78
+ const int64_t rom_size = 32 * KiB;
79
+ g_autofree uint8_t *buffer = g_new0(uint8_t, rom_size);
61
+
80
+
62
static void fb_invalidate_display(void *opaque)
81
+ if (blk_pread(blk, 8 * KiB, rom_size, buffer, 0) < 0) {
63
{
82
+ error_setg(&error_fatal, "%s: failed to read BlockBackend data",
64
BCM2835FBState *s = BCM2835_FB(opaque);
83
+ __func__);
65
@@ -XXX,XX +XXX,XX @@ static void fb_update_display(void *opaque)
84
+ return;
66
s->invalidate = false;
67
}
68
69
+void bcm2835_fb_validate_config(BCM2835FBConfig *config)
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
+ }
85
+ }
98
+
86
+
99
+ if (fb_use_offsets(config)) {
87
+ rom_add_blob("allwinner-a10.bootrom", buffer, rom_size,
100
+ /* Clip the offsets so the viewport is within the physical screen */
88
+ rom_size, AW_A10_SRAM_A_BASE,
101
+ config->xoffset = MIN(config->xoffset,
89
+ NULL, NULL, NULL, NULL, false);
102
+ config->xres_virtual - config->xres);
103
+ config->yoffset = MIN(config->yoffset,
104
+ config->yres_virtual - config->yres);
105
+ }
106
+}
90
+}
107
+
91
+
108
static void bcm2835_fb_mbox_push(BCM2835FBState *s, uint32_t value)
92
static void aw_a10_init(Object *obj)
109
{
93
{
110
uint32_t pitch;
94
AwA10State *s = AW_A10(obj);
111
@@ -XXX,XX +XXX,XX @@ void bcm2835_fb_reconfigure(BCM2835FBState *s, BCM2835FBConfig *newconfig)
95
diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c
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
96
index XXXXXXX..XXXXXXX 100644
122
--- a/hw/misc/bcm2835_property.c
97
--- a/hw/arm/cubieboard.c
123
+++ b/hw/misc/bcm2835_property.c
98
+++ b/hw/arm/cubieboard.c
124
@@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value)
99
@@ -XXX,XX +XXX,XX @@ static void cubieboard_init(MachineState *machine)
125
case 0x00040002: /* Blank screen */
100
memory_region_add_subregion(get_system_memory(), AW_A10_SDRAM_BASE,
126
resplen = 4;
101
machine->ram);
127
break;
102
128
- case 0x00040003: /* Get physical display width/height */
103
+ /* Load target kernel or start using BootROM */
129
- stl_le_phys(&s->dma_as, value + 12, fbconfig.xres);
104
+ if (!machine->kernel_filename && blk && blk_is_available(blk)) {
130
- stl_le_phys(&s->dma_as, value + 16, fbconfig.yres);
105
+ /* Use Boot ROM to copy data from SD card to SRAM */
131
- resplen = 8;
106
+ allwinner_a10_bootrom_setup(a10, blk);
132
- break;
107
+ }
133
- case 0x00040004: /* Get virtual display width/height */
108
/* TODO create and connect IDE devices for ide_drive_get() */
134
- stl_le_phys(&s->dma_as, value + 12, fbconfig.xres_virtual);
109
135
- stl_le_phys(&s->dma_as, value + 16, fbconfig.yres_virtual);
110
cubieboard_binfo.ram_size = machine->ram_size;
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
--
111
--
238
2.18.0
112
2.34.1
239
240
diff view generated by jsdifflib
1
Refactor bcm2835_fb_mbox_push() to work by calling
1
From: Strahinja Jankovic <strahinjapjankovic@gmail.com>
2
bcm2835_fb_validate_config() and bcm2835_fb_reconfigure(),
3
so that config set this way is also validated.
4
2
3
Cubieboard now can boot directly from SD card, without the need to pass
4
`-kernel` parameter. Update Avocado tests to cover this functionality.
5
6
Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
7
Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>
8
Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com>
9
Message-id: 20221226220303.14420-8-strahinja.p.jankovic@gmail.com
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: 20180814144436.679-9-peter.maydell@linaro.org
8
---
11
---
9
hw/display/bcm2835_fb.c | 63 ++++++++++++++++++++---------------------
12
tests/avocado/boot_linux_console.py | 47 +++++++++++++++++++++++++++++
10
1 file changed, 31 insertions(+), 32 deletions(-)
13
1 file changed, 47 insertions(+)
11
14
12
diff --git a/hw/display/bcm2835_fb.c b/hw/display/bcm2835_fb.c
15
diff --git a/tests/avocado/boot_linux_console.py b/tests/avocado/boot_linux_console.py
13
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/display/bcm2835_fb.c
17
--- a/tests/avocado/boot_linux_console.py
15
+++ b/hw/display/bcm2835_fb.c
18
+++ b/tests/avocado/boot_linux_console.py
16
@@ -XXX,XX +XXX,XX @@ void bcm2835_fb_validate_config(BCM2835FBConfig *config)
19
@@ -XXX,XX +XXX,XX @@ def test_arm_cubieboard_sata(self):
17
}
20
'sda')
18
}
21
# cubieboard's reboot is not functioning; omit reboot test.
19
22
20
-static void bcm2835_fb_mbox_push(BCM2835FBState *s, uint32_t value)
23
+ @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
21
-{
24
+ def test_arm_cubieboard_openwrt_22_03_2(self):
22
- uint32_t pitch;
25
+ """
23
- uint32_t size;
26
+ :avocado: tags=arch:arm
24
-
27
+ :avocado: tags=machine:cubieboard
25
- value &= ~0xf;
28
+ :avocado: tags=device:sd
26
-
29
+ """
27
- s->lock = 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
-}
51
-
52
void bcm2835_fb_reconfigure(BCM2835FBState *s, BCM2835FBConfig *newconfig)
53
{
54
s->lock = true;
55
@@ -XXX,XX +XXX,XX @@ void bcm2835_fb_reconfigure(BCM2835FBState *s, BCM2835FBConfig *newconfig)
56
s->lock = false;
57
}
58
59
+static void bcm2835_fb_mbox_push(BCM2835FBState *s, uint32_t value)
60
+{
61
+ uint32_t pitch;
62
+ uint32_t size;
63
+ BCM2835FBConfig newconf;
64
+
30
+
65
+ value &= ~0xf;
31
+ # This test download a 7.5 MiB compressed image and expand it
32
+ # to 126 MiB.
33
+ image_url = ('https://downloads.openwrt.org/releases/22.03.2/targets/'
34
+ 'sunxi/cortexa8/openwrt-22.03.2-sunxi-cortexa8-'
35
+ 'cubietech_a10-cubieboard-ext4-sdcard.img.gz')
36
+ image_hash = ('94b5ecbfbc0b3b56276e5146b899eafa'
37
+ '2ac5dc2d08733d6705af9f144f39f554')
38
+ image_path_gz = self.fetch_asset(image_url, asset_hash=image_hash,
39
+ algorithm='sha256')
40
+ image_path = archive.extract(image_path_gz, self.workdir)
41
+ image_pow2ceil_expand(image_path)
66
+
42
+
67
+ newconf.xres = ldl_le_phys(&s->dma_as, value);
43
+ self.vm.set_console()
68
+ newconf.yres = ldl_le_phys(&s->dma_as, value + 4);
44
+ self.vm.add_args('-drive', 'file=' + image_path + ',if=sd,format=raw',
69
+ newconf.xres_virtual = ldl_le_phys(&s->dma_as, value + 8);
45
+ '-nic', 'user',
70
+ newconf.yres_virtual = ldl_le_phys(&s->dma_as, value + 12);
46
+ '-no-reboot')
71
+ newconf.bpp = ldl_le_phys(&s->dma_as, value + 20);
47
+ self.vm.launch()
72
+ newconf.xoffset = ldl_le_phys(&s->dma_as, value + 24);
73
+ newconf.yoffset = ldl_le_phys(&s->dma_as, value + 28);
74
+
48
+
75
+ newconf.base = s->vcram_base | (value & 0xc0000000);
49
+ kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
76
+ newconf.base += BCM2835_FB_OFFSET;
50
+ 'usbcore.nousb '
51
+ 'noreboot')
77
+
52
+
78
+ bcm2835_fb_validate_config(&newconf);
53
+ self.wait_for_console_pattern('U-Boot SPL')
79
+
54
+
80
+ pitch = bcm2835_fb_get_pitch(&newconf);
55
+ interrupt_interactive_console_until_pattern(
81
+ size = bcm2835_fb_get_size(&newconf);
56
+ self, 'Hit any key to stop autoboot:', '=>')
57
+ exec_command_and_wait_for_pattern(self, "setenv extraargs '" +
58
+ kernel_command_line + "'", '=>')
59
+ exec_command_and_wait_for_pattern(self, 'boot', 'Starting kernel ...');
82
+
60
+
83
+ stl_le_phys(&s->dma_as, value + 16, pitch);
61
+ self.wait_for_console_pattern(
84
+ stl_le_phys(&s->dma_as, value + 32, newconf.base);
62
+ 'Please press Enter to activate this console.')
85
+ stl_le_phys(&s->dma_as, value + 36, size);
86
+
63
+
87
+ bcm2835_fb_reconfigure(s, &newconf);
64
+ exec_command_and_wait_for_pattern(self, ' ', 'root@')
88
+}
89
+
65
+
90
static uint64_t bcm2835_fb_read(void *opaque, hwaddr offset, unsigned size)
66
+ exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
91
{
67
+ 'Allwinner sun4i/sun5i')
92
BCM2835FBState *s = opaque;
68
+ # cubieboard's reboot is not functioning; omit reboot test.
69
+
70
@skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might timeout')
71
def test_arm_quanta_gsj(self):
72
"""
93
--
73
--
94
2.18.0
74
2.34.1
95
96
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Don't dereference CPUTLBEntryFull until we verify that
4
the page is valid. Move the other user-only info field
5
updates after the valid check to match.
6
7
Cc: qemu-stable@nongnu.org
8
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1412
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-5-richard.henderson@linaro.org
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Message-id: 20230104190056.305143-1-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
target/arm/helper.c | 101 ++++++++++++++++++++++----------------------
14
target/arm/sve_helper.c | 14 +++++++++-----
9
1 file changed, 51 insertions(+), 50 deletions(-)
15
1 file changed, 9 insertions(+), 5 deletions(-)
10
16
11
diff --git a/target/arm/helper.c b/target/arm/helper.c
17
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
12
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/helper.c
19
--- a/target/arm/sve_helper.c
14
+++ b/target/arm/helper.c
20
+++ b/target/arm/sve_helper.c
15
@@ -XXX,XX +XXX,XX @@ float##fsz HELPER(vfp_##name##to##p)(uint##isz##_t x, uint32_t shift, \
21
@@ -XXX,XX +XXX,XX @@ bool sve_probe_page(SVEHostPage *info, bool nofault, CPUARMState *env,
16
void *fpstp) \
22
#ifdef CONFIG_USER_ONLY
17
{ return itype##_to_##float##fsz##_scalbn(x, -shift, fpstp); }
23
flags = probe_access_flags(env, addr, access_type, mmu_idx, nofault,
18
24
&info->host, retaddr);
19
-/* Notice that we want only input-denormal exception flags from the
25
- memset(&info->attrs, 0, sizeof(info->attrs));
20
- * scalbn operation: the other possible flags (overflow+inexact if
26
- /* Require both ANON and MTE; see allocation_tag_mem(). */
21
- * we overflow to infinity, output-denormal) aren't correct for the
27
- info->tagged = (flags & PAGE_ANON) && (flags & PAGE_MTE);
22
- * complete scale-and-convert operation.
28
#else
23
- */
29
CPUTLBEntryFull *full;
24
-#define VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, round) \
30
flags = probe_access_full(env, addr, access_type, mmu_idx, nofault,
25
-uint##isz##_t HELPER(vfp_to##name##p##round)(float##fsz x, \
31
&info->host, &full, retaddr);
26
- uint32_t shift, \
32
- info->attrs = full->attrs;
27
- void *fpstp) \
33
- info->tagged = full->pte_attrs == 0xf0;
28
-{ \
34
#endif
29
- float_status *fpst = fpstp; \
35
info->flags = flags;
30
- int old_exc_flags = get_float_exception_flags(fpst); \
36
31
- float##fsz tmp; \
37
@@ -XXX,XX +XXX,XX @@ bool sve_probe_page(SVEHostPage *info, bool nofault, CPUARMState *env,
32
- if (float##fsz##_is_any_nan(x)) { \
38
return false;
33
- float_raise(float_flag_invalid, fpst); \
39
}
34
- return 0; \
40
35
- } \
41
+#ifdef CONFIG_USER_ONLY
36
- tmp = float##fsz##_scalbn(x, shift, fpst); \
42
+ memset(&info->attrs, 0, sizeof(info->attrs));
37
- old_exc_flags |= get_float_exception_flags(fpst) \
43
+ /* Require both ANON and MTE; see allocation_tag_mem(). */
38
- & float_flag_input_denormal; \
44
+ info->tagged = (flags & PAGE_ANON) && (flags & PAGE_MTE);
39
- set_float_exception_flags(old_exc_flags, fpst); \
45
+#else
40
- return float##fsz##_to_##itype##round(tmp, fpst); \
46
+ info->attrs = full->attrs;
41
+#define VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, ROUND, suff) \
47
+ info->tagged = full->pte_attrs == 0xf0;
42
+uint##isz##_t HELPER(vfp_to##name##p##suff)(float##fsz x, uint32_t shift, \
48
+#endif
43
+ void *fpst) \
49
+
44
+{ \
50
/* Ensure that info->host[] is relative to addr, not addr + mem_off. */
45
+ if (unlikely(float##fsz##_is_any_nan(x))) { \
51
info->host -= mem_off;
46
+ float_raise(float_flag_invalid, fpst); \
52
return true;
47
+ return 0; \
48
+ } \
49
+ return float##fsz##_to_##itype##_scalbn(x, ROUND, shift, fpst); \
50
}
51
52
#define VFP_CONV_FIX(name, p, fsz, isz, itype) \
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
-{
75
- if (unlikely(float16_is_any_nan(f))) {
76
- float_raise(float_flag_invalid, fpst);
77
- return 0;
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
-}
91
-
92
uint32_t HELPER(vfp_toshh)(uint32_t x, uint32_t shift, void *fpst)
93
{
94
- return float64_to_int16(do_prescale_fp16(x, shift, fpst), fpst);
95
+ if (unlikely(float16_is_any_nan(x))) {
96
+ float_raise(float_flag_invalid, fpst);
97
+ return 0;
98
+ }
99
+ return float16_to_int16_scalbn(x, get_float_rounding_mode(fpst),
100
+ shift, fpst);
101
}
102
103
uint32_t HELPER(vfp_touhh)(uint32_t x, uint32_t shift, void *fpst)
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
--
53
--
160
2.18.0
54
2.34.1
161
55
162
56
diff view generated by jsdifflib
1
The raspi framebuffir in bcm2835_fb supports the definition
1
From: Philippe Mathieu-Daudé <philmd@linaro.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
Since pxa255_init() must map the device in the system memory,
10
* the property mailbox code needs to distinguish the
4
there is no point in passing get_system_memory() by argument.
11
virtual width/height from the physical width/height
12
* the framebuffer code needs to do something with the
13
virtual width/height/origin information
14
5
15
Note that the wiki documentation on the semantics of the
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
16
virtual and physical height and width has it the wrong way
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
17
around -- the virtual size is the size of the allocated
8
Message-id: 20230109115316.2235-2-philmd@linaro.org
18
buffer, and the physical size is the size of the display,
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
so the virtual size is always the same as or larger than
10
---
20
the physical.
11
include/hw/arm/pxa.h | 2 +-
12
hw/arm/gumstix.c | 3 +--
13
hw/arm/pxa2xx.c | 4 +++-
14
hw/arm/tosa.c | 2 +-
15
4 files changed, 6 insertions(+), 5 deletions(-)
21
16
22
If the viewport size is set smaller than the physical
17
diff --git a/include/hw/arm/pxa.h b/include/hw/arm/pxa.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
18
index XXXXXXX..XXXXXXX 100644
37
--- a/include/hw/display/bcm2835_fb.h
19
--- a/include/hw/arm/pxa.h
38
+++ b/include/hw/display/bcm2835_fb.h
20
+++ b/include/hw/arm/pxa.h
39
@@ -XXX,XX +XXX,XX @@ void bcm2835_fb_reconfigure(BCM2835FBState *s, BCM2835FBConfig *newconfig);
21
@@ -XXX,XX +XXX,XX @@ struct PXA2xxI2SState {
40
*/
22
41
static inline uint32_t bcm2835_fb_get_pitch(BCM2835FBConfig *config)
23
PXA2xxState *pxa270_init(MemoryRegion *address_space, unsigned int sdram_size,
24
const char *revision);
25
-PXA2xxState *pxa255_init(MemoryRegion *address_space, unsigned int sdram_size);
26
+PXA2xxState *pxa255_init(unsigned int sdram_size);
27
28
#endif /* PXA_H */
29
diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
30
index XXXXXXX..XXXXXXX 100644
31
--- a/hw/arm/gumstix.c
32
+++ b/hw/arm/gumstix.c
33
@@ -XXX,XX +XXX,XX @@ static void connex_init(MachineState *machine)
42
{
34
{
43
- return config->xres * (config->bpp >> 3);
35
PXA2xxState *cpu;
44
+ uint32_t xres = MAX(config->xres, config->xres_virtual);
36
DriveInfo *dinfo;
45
+ return xres * (config->bpp >> 3);
37
- MemoryRegion *address_space_mem = get_system_memory();
38
39
uint32_t connex_rom = 0x01000000;
40
uint32_t connex_ram = 0x04000000;
41
42
- cpu = pxa255_init(address_space_mem, connex_ram);
43
+ cpu = pxa255_init(connex_ram);
44
45
dinfo = drive_get(IF_PFLASH, 0, 0);
46
if (!dinfo && !qtest_enabled()) {
47
diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/hw/arm/pxa2xx.c
50
+++ b/hw/arm/pxa2xx.c
51
@@ -XXX,XX +XXX,XX @@
52
#include "qemu/error-report.h"
53
#include "qemu/module.h"
54
#include "qapi/error.h"
55
+#include "exec/address-spaces.h"
56
#include "cpu.h"
57
#include "hw/sysbus.h"
58
#include "migration/vmstate.h"
59
@@ -XXX,XX +XXX,XX @@ PXA2xxState *pxa270_init(MemoryRegion *address_space,
46
}
60
}
47
61
48
/**
62
/* Initialise a PXA255 integrated chip (ARM based core). */
49
@@ -XXX,XX +XXX,XX @@ static inline uint32_t bcm2835_fb_get_pitch(BCM2835FBConfig *config)
63
-PXA2xxState *pxa255_init(MemoryRegion *address_space, unsigned int sdram_size)
50
*/
64
+PXA2xxState *pxa255_init(unsigned int sdram_size)
51
static inline uint32_t bcm2835_fb_get_size(BCM2835FBConfig *config)
52
{
65
{
53
- return config->yres * bcm2835_fb_get_pitch(config);
66
+ MemoryRegion *address_space = get_system_memory();
54
+ uint32_t yres = MAX(config->yres, config->yres_virtual);
67
PXA2xxState *s;
55
+ return yres * bcm2835_fb_get_pitch(config);
68
int i;
56
}
69
DriveInfo *dinfo;
57
70
diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c
58
#endif
59
diff --git a/hw/display/bcm2835_fb.c b/hw/display/bcm2835_fb.c
60
index XXXXXXX..XXXXXXX 100644
71
index XXXXXXX..XXXXXXX 100644
61
--- a/hw/display/bcm2835_fb.c
72
--- a/hw/arm/tosa.c
62
+++ b/hw/display/bcm2835_fb.c
73
+++ b/hw/arm/tosa.c
63
@@ -XXX,XX +XXX,XX @@ static void draw_line_src16(void *opaque, uint8_t *dst, const uint8_t *src,
74
@@ -XXX,XX +XXX,XX @@ static void tosa_init(MachineState *machine)
64
}
75
TC6393xbState *tmio;
65
}
76
DeviceState *scp0, *scp1;
66
77
67
+static bool fb_use_offsets(BCM2835FBConfig *config)
78
- mpu = pxa255_init(address_space_mem, tosa_binfo.ram_size);
68
+{
79
+ mpu = pxa255_init(tosa_binfo.ram_size);
69
+ /*
80
70
+ * Return true if we should use the viewport offsets.
81
memory_region_init_rom(rom, NULL, "tosa.rom", TOSA_ROM, &error_fatal);
71
+ * Experimentally, the hardware seems to do this only if the
82
memory_region_add_subregion(address_space_mem, 0, rom);
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;
90
}
91
92
src_width = bcm2835_fb_get_pitch(&s->config);
93
+ if (fb_use_offsets(&s->config)) {
94
+ xoff = s->config.xoffset;
95
+ yoff = s->config.yoffset;
96
+ }
97
+
98
dest_width = s->config.xres;
99
100
switch (surface_bits_per_pixel(surface)) {
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
--
83
--
184
2.18.0
84
2.34.1
185
85
186
86
diff view generated by jsdifflib
1
Move from the legacy SysBusDevice::init method to using
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
DeviceState::realize.
3
2
3
Since pxa270_init() must map the device in the system memory,
4
there is no point in passing get_system_memory() by argument.
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20230109115316.2235-3-philmd@linaro.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
Message-id: 20180820141116.9118-19-peter.maydell@linaro.org
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
---
10
---
9
hw/ssi/pl022.c | 8 +++-----
11
include/hw/arm/pxa.h | 3 +--
10
1 file changed, 3 insertions(+), 5 deletions(-)
12
hw/arm/gumstix.c | 3 +--
13
hw/arm/mainstone.c | 10 ++++------
14
hw/arm/pxa2xx.c | 4 ++--
15
hw/arm/spitz.c | 6 ++----
16
hw/arm/z2.c | 3 +--
17
6 files changed, 11 insertions(+), 18 deletions(-)
11
18
12
diff --git a/hw/ssi/pl022.c b/hw/ssi/pl022.c
19
diff --git a/include/hw/arm/pxa.h b/include/hw/arm/pxa.h
13
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/ssi/pl022.c
21
--- a/include/hw/arm/pxa.h
15
+++ b/hw/ssi/pl022.c
22
+++ b/include/hw/arm/pxa.h
16
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_pl022 = {
23
@@ -XXX,XX +XXX,XX @@ struct PXA2xxI2SState {
17
}
24
25
# define PA_FMT            "0x%08lx"
26
27
-PXA2xxState *pxa270_init(MemoryRegion *address_space, unsigned int sdram_size,
28
- const char *revision);
29
+PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision);
30
PXA2xxState *pxa255_init(unsigned int sdram_size);
31
32
#endif /* PXA_H */
33
diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
34
index XXXXXXX..XXXXXXX 100644
35
--- a/hw/arm/gumstix.c
36
+++ b/hw/arm/gumstix.c
37
@@ -XXX,XX +XXX,XX @@ static void verdex_init(MachineState *machine)
38
{
39
PXA2xxState *cpu;
40
DriveInfo *dinfo;
41
- MemoryRegion *address_space_mem = get_system_memory();
42
43
uint32_t verdex_rom = 0x02000000;
44
uint32_t verdex_ram = 0x10000000;
45
46
- cpu = pxa270_init(address_space_mem, verdex_ram, machine->cpu_type);
47
+ cpu = pxa270_init(verdex_ram, machine->cpu_type);
48
49
dinfo = drive_get(IF_PFLASH, 0, 0);
50
if (!dinfo && !qtest_enabled()) {
51
diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c
52
index XXXXXXX..XXXXXXX 100644
53
--- a/hw/arm/mainstone.c
54
+++ b/hw/arm/mainstone.c
55
@@ -XXX,XX +XXX,XX @@ static struct arm_boot_info mainstone_binfo = {
56
.ram_size = 0x04000000,
18
};
57
};
19
58
20
-static int pl022_init(SysBusDevice *sbd)
59
-static void mainstone_common_init(MemoryRegion *address_space_mem,
21
+static void pl022_realize(DeviceState *dev, Error **errp)
60
- MachineState *machine,
61
+static void mainstone_common_init(MachineState *machine,
62
enum mainstone_model_e model, int arm_id)
22
{
63
{
23
- DeviceState *dev = DEVICE(sbd);
64
uint32_t sector_len = 256 * 1024;
24
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
65
@@ -XXX,XX +XXX,XX @@ static void mainstone_common_init(MemoryRegion *address_space_mem,
25
PL022State *s = PL022(dev);
66
MemoryRegion *rom = g_new(MemoryRegion, 1);
26
67
27
memory_region_init_io(&s->iomem, OBJECT(s), &pl022_ops, s, "pl022", 0x1000);
68
/* Setup CPU & memory */
28
sysbus_init_mmio(sbd, &s->iomem);
69
- mpu = pxa270_init(address_space_mem, mainstone_binfo.ram_size,
29
sysbus_init_irq(sbd, &s->irq);
70
- machine->cpu_type);
30
s->ssi = ssi_create_bus(dev, "ssi");
71
+ mpu = pxa270_init(mainstone_binfo.ram_size, machine->cpu_type);
31
- return 0;
72
memory_region_init_rom(rom, NULL, "mainstone.rom", MAINSTONE_ROM,
73
&error_fatal);
74
- memory_region_add_subregion(address_space_mem, 0, rom);
75
+ memory_region_add_subregion(get_system_memory(), 0x00000000, rom);
76
77
/* There are two 32MiB flash devices on the board */
78
for (i = 0; i < 2; i ++) {
79
@@ -XXX,XX +XXX,XX @@ static void mainstone_common_init(MemoryRegion *address_space_mem,
80
81
static void mainstone_init(MachineState *machine)
82
{
83
- mainstone_common_init(get_system_memory(), machine, mainstone, 0x196);
84
+ mainstone_common_init(machine, mainstone, 0x196);
32
}
85
}
33
86
34
static void pl022_class_init(ObjectClass *klass, void *data)
87
static void mainstone2_machine_init(MachineClass *mc)
88
diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
89
index XXXXXXX..XXXXXXX 100644
90
--- a/hw/arm/pxa2xx.c
91
+++ b/hw/arm/pxa2xx.c
92
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_reset(void *opaque, int line, int level)
93
}
94
95
/* Initialise a PXA270 integrated chip (ARM based core). */
96
-PXA2xxState *pxa270_init(MemoryRegion *address_space,
97
- unsigned int sdram_size, const char *cpu_type)
98
+PXA2xxState *pxa270_init(unsigned int sdram_size, const char *cpu_type)
35
{
99
{
36
- SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
100
+ MemoryRegion *address_space = get_system_memory();
37
DeviceClass *dc = DEVICE_CLASS(klass);
101
PXA2xxState *s;
38
102
int i;
39
- sdc->init = pl022_init;
103
DriveInfo *dinfo;
40
dc->reset = pl022_reset;
104
diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c
41
dc->vmsd = &vmstate_pl022;
105
index XXXXXXX..XXXXXXX 100644
42
+ dc->realize = pl022_realize;
106
--- a/hw/arm/spitz.c
43
}
107
+++ b/hw/arm/spitz.c
44
108
@@ -XXX,XX +XXX,XX @@ static void spitz_common_init(MachineState *machine)
45
static const TypeInfo pl022_info = {
109
SpitzMachineState *sms = SPITZ_MACHINE(machine);
110
enum spitz_model_e model = smc->model;
111
PXA2xxState *mpu;
112
- MemoryRegion *address_space_mem = get_system_memory();
113
MemoryRegion *rom = g_new(MemoryRegion, 1);
114
115
/* Setup CPU & memory */
116
- mpu = pxa270_init(address_space_mem, spitz_binfo.ram_size,
117
- machine->cpu_type);
118
+ mpu = pxa270_init(spitz_binfo.ram_size, machine->cpu_type);
119
sms->mpu = mpu;
120
121
sl_flash_register(mpu, (model == spitz) ? FLASH_128M : FLASH_1024M);
122
123
memory_region_init_rom(rom, NULL, "spitz.rom", SPITZ_ROM, &error_fatal);
124
- memory_region_add_subregion(address_space_mem, 0, rom);
125
+ memory_region_add_subregion(get_system_memory(), 0, rom);
126
127
/* Setup peripherals */
128
spitz_keyboard_register(mpu);
129
diff --git a/hw/arm/z2.c b/hw/arm/z2.c
130
index XXXXXXX..XXXXXXX 100644
131
--- a/hw/arm/z2.c
132
+++ b/hw/arm/z2.c
133
@@ -XXX,XX +XXX,XX @@ static const TypeInfo aer915_info = {
134
135
static void z2_init(MachineState *machine)
136
{
137
- MemoryRegion *address_space_mem = get_system_memory();
138
uint32_t sector_len = 0x10000;
139
PXA2xxState *mpu;
140
DriveInfo *dinfo;
141
@@ -XXX,XX +XXX,XX @@ static void z2_init(MachineState *machine)
142
DeviceState *wm;
143
144
/* Setup CPU & memory */
145
- mpu = pxa270_init(address_space_mem, z2_binfo.ram_size, machine->cpu_type);
146
+ mpu = pxa270_init(z2_binfo.ram_size, machine->cpu_type);
147
148
dinfo = drive_get(IF_PFLASH, 0, 0);
149
if (!pflash_cfi01_register(Z2_FLASH_BASE, "z2.flash0", Z2_FLASH_SIZE,
46
--
150
--
47
2.18.0
151
2.34.1
48
152
49
153
diff view generated by jsdifflib
1
Connect the VIRQ and VFIQ lines from the GIC to the CPU;
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
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
2
3
IEC binary prefixes ease code review: the unit is explicit.
4
5
Add definitions for RAM / Flash / Flash blocksize.
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230109115316.2235-4-philmd@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
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
---
11
---
10
hw/arm/vexpress.c | 4 ++++
12
hw/arm/collie.c | 16 ++++++++++------
11
1 file changed, 4 insertions(+)
13
1 file changed, 10 insertions(+), 6 deletions(-)
12
14
13
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
15
diff --git a/hw/arm/collie.c b/hw/arm/collie.c
14
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/arm/vexpress.c
17
--- a/hw/arm/collie.c
16
+++ b/hw/arm/vexpress.c
18
+++ b/hw/arm/collie.c
17
@@ -XXX,XX +XXX,XX @@ static void init_cpus(const char *cpu_type, const char *privdev,
19
@@ -XXX,XX +XXX,XX @@
18
sysbus_connect_irq(busdev, n, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ));
20
#include "cpu.h"
19
sysbus_connect_irq(busdev, n + smp_cpus,
21
#include "qom/object.h"
20
qdev_get_gpio_in(cpudev, ARM_CPU_FIQ));
22
21
+ sysbus_connect_irq(busdev, n + 2 * smp_cpus,
23
+#define RAM_SIZE (512 * MiB)
22
+ qdev_get_gpio_in(cpudev, ARM_CPU_VIRQ));
24
+#define FLASH_SIZE (32 * MiB)
23
+ sysbus_connect_irq(busdev, n + 3 * smp_cpus,
25
+#define FLASH_SECTOR_SIZE (64 * KiB)
24
+ qdev_get_gpio_in(cpudev, ARM_CPU_VFIQ));
26
+
25
}
27
struct CollieMachineState {
28
MachineState parent;
29
30
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(CollieMachineState, COLLIE_MACHINE)
31
32
static struct arm_boot_info collie_binfo = {
33
.loader_start = SA_SDCS0,
34
- .ram_size = 0x20000000,
35
+ .ram_size = RAM_SIZE,
36
};
37
38
static void collie_init(MachineState *machine)
39
@@ -XXX,XX +XXX,XX @@ static void collie_init(MachineState *machine)
40
memory_region_add_subregion(get_system_memory(), SA_SDCS0, machine->ram);
41
42
dinfo = drive_get(IF_PFLASH, 0, 0);
43
- pflash_cfi01_register(SA_CS0, "collie.fl1", 0x02000000,
44
+ pflash_cfi01_register(SA_CS0, "collie.fl1", FLASH_SIZE,
45
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
46
- 64 * KiB, 4, 0x00, 0x00, 0x00, 0x00, 0);
47
+ FLASH_SECTOR_SIZE, 4, 0x00, 0x00, 0x00, 0x00, 0);
48
49
dinfo = drive_get(IF_PFLASH, 0, 1);
50
- pflash_cfi01_register(SA_CS1, "collie.fl2", 0x02000000,
51
+ pflash_cfi01_register(SA_CS1, "collie.fl2", FLASH_SIZE,
52
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
53
- 64 * KiB, 4, 0x00, 0x00, 0x00, 0x00, 0);
54
+ FLASH_SECTOR_SIZE, 4, 0x00, 0x00, 0x00, 0x00, 0);
55
56
sysbus_create_simple("scoop", 0x40800000, NULL);
57
58
@@ -XXX,XX +XXX,XX @@ static void collie_machine_class_init(ObjectClass *oc, void *data)
59
mc->init = collie_init;
60
mc->ignore_memory_transaction_failures = true;
61
mc->default_cpu_type = ARM_CPU_TYPE_NAME("sa1110");
62
- mc->default_ram_size = 0x20000000;
63
+ mc->default_ram_size = RAM_SIZE;
64
mc->default_ram_id = "strongarm.sdram";
26
}
65
}
27
66
28
--
67
--
29
2.18.0
68
2.34.1
30
69
31
70
diff view generated by jsdifflib
1
The PL022 interrupt registers have bits allocated as:
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
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
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
the PL022_INT_RT constant. This bug doesn't affect device
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
behaviour, because we don't implement the receive timeout
5
Message-id: 20230109115316.2235-5-philmd@linaro.org
10
feature and so never set that interrupt bit.
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
hw/arm/collie.c | 17 +++++++----------
9
1 file changed, 7 insertions(+), 10 deletions(-)
11
10
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
diff --git a/hw/arm/collie.c b/hw/arm/collie.c
13
Message-id: 20180820141116.9118-20-peter.maydell@linaro.org
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
---
16
hw/ssi/pl022.c | 2 +-
17
1 file changed, 1 insertion(+), 1 deletion(-)
18
19
diff --git a/hw/ssi/pl022.c b/hw/ssi/pl022.c
20
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/ssi/pl022.c
13
--- a/hw/arm/collie.c
22
+++ b/hw/ssi/pl022.c
14
+++ b/hw/arm/collie.c
23
@@ -XXX,XX +XXX,XX @@ do { fprintf(stderr, "pl022: error: " fmt , ## __VA_ARGS__);} while (0)
15
@@ -XXX,XX +XXX,XX @@ static struct arm_boot_info collie_binfo = {
24
#define PL022_SR_BSY 0x10
16
25
17
static void collie_init(MachineState *machine)
26
#define PL022_INT_ROR 0x01
18
{
27
-#define PL022_INT_RT 0x04
19
- DriveInfo *dinfo;
28
+#define PL022_INT_RT 0x02
20
MachineClass *mc = MACHINE_GET_CLASS(machine);
29
#define PL022_INT_RX 0x04
21
CollieMachineState *cms = COLLIE_MACHINE(machine);
30
#define PL022_INT_TX 0x08
22
23
@@ -XXX,XX +XXX,XX @@ static void collie_init(MachineState *machine)
24
25
memory_region_add_subregion(get_system_memory(), SA_SDCS0, machine->ram);
26
27
- dinfo = drive_get(IF_PFLASH, 0, 0);
28
- pflash_cfi01_register(SA_CS0, "collie.fl1", FLASH_SIZE,
29
- dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
30
- FLASH_SECTOR_SIZE, 4, 0x00, 0x00, 0x00, 0x00, 0);
31
-
32
- dinfo = drive_get(IF_PFLASH, 0, 1);
33
- pflash_cfi01_register(SA_CS1, "collie.fl2", FLASH_SIZE,
34
- dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
35
- FLASH_SECTOR_SIZE, 4, 0x00, 0x00, 0x00, 0x00, 0);
36
+ for (unsigned i = 0; i < 2; i++) {
37
+ DriveInfo *dinfo = drive_get(IF_PFLASH, 0, i);
38
+ pflash_cfi01_register(i ? SA_CS1 : SA_CS0,
39
+ i ? "collie.fl2" : "collie.fl1", FLASH_SIZE,
40
+ dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
41
+ FLASH_SECTOR_SIZE, 4, 0x00, 0x00, 0x00, 0x00, 0);
42
+ }
43
44
sysbus_create_simple("scoop", 0x40800000, NULL);
31
45
32
--
46
--
33
2.18.0
47
2.34.1
34
48
35
49
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
Add a comment describing the Connex uses a Numonyx RC28F128J3F75
4
flash, and the Verdex uses a Micron RC28F256P30TFA.
5
6
Correct the Verdex machine description (we model the 'Pro' board).
7
8
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20230109115316.2235-6-philmd@linaro.org
11
Message-Id: <20200223231044.8003-3-philmd@redhat.com>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
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
---
13
---
13
hw/cpu/a15mpcore.c | 31 ++++++++++++++++++++++++++++---
14
hw/arm/gumstix.c | 6 ++++--
14
1 file changed, 28 insertions(+), 3 deletions(-)
15
1 file changed, 4 insertions(+), 2 deletions(-)
15
16
16
diff --git a/hw/cpu/a15mpcore.c b/hw/cpu/a15mpcore.c
17
diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
17
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/cpu/a15mpcore.c
19
--- a/hw/arm/gumstix.c
19
+++ b/hw/cpu/a15mpcore.c
20
+++ b/hw/arm/gumstix.c
20
@@ -XXX,XX +XXX,XX @@ static void a15mp_priv_realize(DeviceState *dev, Error **errp)
21
@@ -XXX,XX +XXX,XX @@
21
int i;
22
* Contributions after 2012-01-13 are licensed under the terms of the
22
Error *err = NULL;
23
* GNU GPL, version 2 or (at your option) any later version.
23
bool has_el3;
24
*/
24
+ bool has_el2;
25
-
25
Object *cpuobj;
26
+
26
27
/*
27
gicdev = DEVICE(&s->gic);
28
* Example usage:
28
@@ -XXX,XX +XXX,XX @@ static void a15mp_priv_realize(DeviceState *dev, Error **errp)
29
*
29
has_el3 = object_property_find(cpuobj, "has_el3", NULL) &&
30
@@ -XXX,XX +XXX,XX @@ static void connex_init(MachineState *machine)
30
object_property_get_bool(cpuobj, "has_el3", &error_abort);
31
exit(1);
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
}
32
}
37
33
38
object_property_set_bool(OBJECT(&s->gic), true, "realized", &err);
34
+ /* Numonyx RC28F128J3F75 */
39
@@ -XXX,XX +XXX,XX @@ static void a15mp_priv_realize(DeviceState *dev, Error **errp)
35
if (!pflash_cfi01_register(0x00000000, "connext.rom", connex_rom,
40
qdev_get_gpio_in(gicdev,
36
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
41
ppibase + timer_irq[irq]));
37
sector_len, 2, 0, 0, 0, 0, 0)) {
42
}
38
@@ -XXX,XX +XXX,XX @@ static void verdex_init(MachineState *machine)
43
+ if (has_el2) {
39
exit(1);
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
}
40
}
49
41
50
/* Memory map (addresses are offsets from PERIPHBASE):
42
+ /* Micron RC28F256P30TFA */
51
* 0x0000-0x0fff -- reserved
43
if (!pflash_cfi01_register(0x00000000, "verdex.rom", verdex_rom,
52
* 0x1000-0x1fff -- GIC Distributor
44
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
53
* 0x2000-0x3fff -- GIC CPU interface
45
sector_len, 2, 0, 0, 0, 0, 0)) {
54
- * 0x4000-0x4fff -- GIC virtual interface control (not modelled)
46
@@ -XXX,XX +XXX,XX @@ static void verdex_class_init(ObjectClass *oc, void *data)
55
- * 0x5000-0x5fff -- GIC virtual interface control (not modelled)
47
{
56
- * 0x6000-0x7fff -- GIC virtual CPU interface (not modelled)
48
MachineClass *mc = MACHINE_CLASS(oc);
57
+ * 0x4000-0x4fff -- GIC virtual interface control for this CPU
49
58
+ * 0x5000-0x51ff -- GIC virtual interface control for CPU 0
50
- mc->desc = "Gumstix Verdex (PXA270)";
59
+ * 0x5200-0x53ff -- GIC virtual interface control for CPU 1
51
+ mc->desc = "Gumstix Verdex Pro XL6P COMs (PXA270)";
60
+ * 0x5400-0x55ff -- GIC virtual interface control for CPU 2
52
mc->init = verdex_init;
61
+ * 0x5600-0x57ff -- GIC virtual interface control for CPU 3
53
mc->ignore_memory_transaction_failures = true;
62
+ * 0x6000-0x7fff -- GIC virtual CPU interface
54
mc->default_cpu_type = ARM_CPU_TYPE_NAME("pxa270-c0");
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
+ }
80
}
81
82
static Property a15mp_priv_properties[] = {
83
--
55
--
84
2.18.0
56
2.34.1
85
57
86
58
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
3
we try to track the value we're about to set and whether we're going
4
to be setting a value, and then we hand all the new values off
5
to the framebuffer via a function which takes them all as separate
6
arguments. It would be simpler if the property code could easily
7
copy all the framebuffer's current settings, update them with
8
the new specified values and then ask the framebuffer to switch
9
to the new set.
10
2
11
As the first part of this refactoring, pull all the fb config
3
IEC binary prefixes ease code review: the unit is explicit.
12
settings fields in BCM2835FBState out into their own struct.
13
4
5
Add definitions for RAM / Flash / Flash blocksize.
6
7
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230109115316.2235-7-philmd@linaro.org
10
Message-Id: <20200223231044.8003-3-philmd@redhat.com>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
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
---
12
---
18
include/hw/display/bcm2835_fb.h | 26 ++++++--
13
hw/arm/gumstix.c | 27 ++++++++++++++-------------
19
hw/display/bcm2835_fb.c | 114 +++++++++++++++++---------------
14
1 file changed, 14 insertions(+), 13 deletions(-)
20
hw/misc/bcm2835_property.c | 28 ++++----
21
3 files changed, 94 insertions(+), 74 deletions(-)
22
15
23
diff --git a/include/hw/display/bcm2835_fb.h b/include/hw/display/bcm2835_fb.h
16
diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
24
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
25
--- a/include/hw/display/bcm2835_fb.h
18
--- a/hw/arm/gumstix.c
26
+++ b/include/hw/display/bcm2835_fb.h
19
+++ b/hw/arm/gumstix.c
27
@@ -XXX,XX +XXX,XX @@
20
@@ -XXX,XX +XXX,XX @@
28
#define TYPE_BCM2835_FB "bcm2835-fb"
21
*/
29
#define BCM2835_FB(obj) OBJECT_CHECK(BCM2835FBState, (obj), TYPE_BCM2835_FB)
22
30
23
#include "qemu/osdep.h"
31
+/*
24
+#include "qemu/units.h"
32
+ * Configuration information about the fb which the guest can program
25
#include "qemu/error-report.h"
33
+ * via the mailbox property interface.
26
#include "hw/arm/pxa.h"
34
+ */
27
#include "net/net.h"
35
+typedef struct {
28
@@ -XXX,XX +XXX,XX @@
36
+ uint32_t xres, yres;
29
#include "sysemu/qtest.h"
37
+ uint32_t xres_virtual, yres_virtual;
30
#include "cpu.h"
38
+ uint32_t xoffset, yoffset;
31
39
+ uint32_t bpp;
32
-static const int sector_len = 128 * 1024;
40
+ uint32_t base;
33
+#define CONNEX_FLASH_SIZE (16 * MiB)
41
+ uint32_t pixo;
34
+#define CONNEX_RAM_SIZE (64 * MiB)
42
+ uint32_t alpha;
43
+} BCM2835FBConfig;
44
+
35
+
45
typedef struct {
36
+#define VERDEX_FLASH_SIZE (32 * MiB)
46
/*< private >*/
37
+#define VERDEX_RAM_SIZE (256 * MiB)
47
SysBusDevice busdev;
48
@@ -XXX,XX +XXX,XX @@ typedef struct {
49
qemu_irq mbox_irq;
50
51
bool lock, invalidate, pending;
52
- uint32_t xres, yres;
53
- uint32_t xres_virtual, yres_virtual;
54
- uint32_t xoffset, yoffset;
55
- uint32_t bpp;
56
- uint32_t base, pitch, size;
57
- uint32_t pixo, alpha;
58
+
38
+
59
+ BCM2835FBConfig config;
39
+#define FLASH_SECTOR_SIZE (128 * KiB)
60
+
40
61
+ /* These are just cached values calculated from the config settings */
41
static void connex_init(MachineState *machine)
62
+ uint32_t size;
42
{
63
+ uint32_t pitch;
43
PXA2xxState *cpu;
64
} BCM2835FBState;
44
DriveInfo *dinfo;
65
45
66
void bcm2835_fb_reconfigure(BCM2835FBState *s, uint32_t *xres, uint32_t *yres,
46
- uint32_t connex_rom = 0x01000000;
67
diff --git a/hw/display/bcm2835_fb.c b/hw/display/bcm2835_fb.c
47
- uint32_t connex_ram = 0x04000000;
68
index XXXXXXX..XXXXXXX 100644
48
-
69
--- a/hw/display/bcm2835_fb.c
49
- cpu = pxa255_init(connex_ram);
70
+++ b/hw/display/bcm2835_fb.c
50
+ cpu = pxa255_init(CONNEX_RAM_SIZE);
71
@@ -XXX,XX +XXX,XX @@ static void draw_line_src16(void *opaque, uint8_t *dst, const uint8_t *src,
51
72
int bpp = surface_bits_per_pixel(surface);
52
dinfo = drive_get(IF_PFLASH, 0, 0);
73
53
if (!dinfo && !qtest_enabled()) {
74
while (width--) {
54
@@ -XXX,XX +XXX,XX @@ static void connex_init(MachineState *machine)
75
- switch (s->bpp) {
76
+ switch (s->config.bpp) {
77
case 8:
78
/* lookup palette starting at video ram base
79
* TODO: cache translation, rather than doing this each time!
80
@@ -XXX,XX +XXX,XX @@ static void draw_line_src16(void *opaque, uint8_t *dst, const uint8_t *src,
81
break;
82
}
83
84
- if (s->pixo == 0) {
85
+ if (s->config.pixo == 0) {
86
/* swap to BGR pixel format */
87
uint8_t tmp = r;
88
r = b;
89
@@ -XXX,XX +XXX,XX @@ static void fb_update_display(void *opaque)
90
int src_width = 0;
91
int dest_width = 0;
92
93
- if (s->lock || !s->xres) {
94
+ if (s->lock || !s->config.xres) {
95
return;
96
}
55
}
97
56
98
- src_width = s->xres * (s->bpp >> 3);
57
/* Numonyx RC28F128J3F75 */
99
- dest_width = s->xres;
58
- if (!pflash_cfi01_register(0x00000000, "connext.rom", connex_rom,
100
+ src_width = s->config.xres * (s->config.bpp >> 3);
59
+ if (!pflash_cfi01_register(0x00000000, "connext.rom", CONNEX_FLASH_SIZE,
101
+ dest_width = s->config.xres;
60
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
102
61
- sector_len, 2, 0, 0, 0, 0, 0)) {
103
switch (surface_bits_per_pixel(surface)) {
62
+ FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0)) {
104
case 0:
63
error_report("Error registering flash memory");
105
@@ -XXX,XX +XXX,XX @@ static void fb_update_display(void *opaque)
64
exit(1);
106
}
65
}
107
66
@@ -XXX,XX +XXX,XX @@ static void verdex_init(MachineState *machine)
108
if (s->invalidate) {
67
PXA2xxState *cpu;
109
- framebuffer_update_memory_section(&s->fbsection, s->dma_mr, s->base,
68
DriveInfo *dinfo;
110
- s->yres, src_width);
69
111
+ framebuffer_update_memory_section(&s->fbsection, s->dma_mr,
70
- uint32_t verdex_rom = 0x02000000;
112
+ s->config.base,
71
- uint32_t verdex_ram = 0x10000000;
113
+ s->config.yres, src_width);
72
-
73
- cpu = pxa270_init(verdex_ram, machine->cpu_type);
74
+ cpu = pxa270_init(VERDEX_RAM_SIZE, machine->cpu_type);
75
76
dinfo = drive_get(IF_PFLASH, 0, 0);
77
if (!dinfo && !qtest_enabled()) {
78
@@ -XXX,XX +XXX,XX @@ static void verdex_init(MachineState *machine)
114
}
79
}
115
80
116
- framebuffer_update_display(surface, &s->fbsection, s->xres, s->yres,
81
/* Micron RC28F256P30TFA */
117
+ framebuffer_update_display(surface, &s->fbsection,
82
- if (!pflash_cfi01_register(0x00000000, "verdex.rom", verdex_rom,
118
+ s->config.xres, s->config.yres,
83
+ if (!pflash_cfi01_register(0x00000000, "verdex.rom", VERDEX_FLASH_SIZE,
119
src_width, dest_width, 0, s->invalidate,
84
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
120
draw_line_src16, s, &first, &last);
85
- sector_len, 2, 0, 0, 0, 0, 0)) {
121
86
+ FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0)) {
122
if (first >= 0) {
87
error_report("Error registering flash memory");
123
- dpy_gfx_update(s->con, 0, first, s->xres, last - first + 1);
88
exit(1);
124
+ dpy_gfx_update(s->con, 0, first, s->config.xres, last - first + 1);
125
}
89
}
126
127
s->invalidate = false;
128
@@ -XXX,XX +XXX,XX @@ static void bcm2835_fb_mbox_push(BCM2835FBState *s, uint32_t value)
129
130
s->lock = true;
131
132
- s->xres = ldl_le_phys(&s->dma_as, value);
133
- s->yres = ldl_le_phys(&s->dma_as, value + 4);
134
- s->xres_virtual = ldl_le_phys(&s->dma_as, value + 8);
135
- s->yres_virtual = ldl_le_phys(&s->dma_as, value + 12);
136
- s->bpp = ldl_le_phys(&s->dma_as, value + 20);
137
- s->xoffset = ldl_le_phys(&s->dma_as, value + 24);
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
};
244
@@ -XXX,XX +XXX,XX @@ static void bcm2835_fb_reset(DeviceState *dev)
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
--
90
--
371
2.18.0
91
2.34.1
372
92
373
93
diff view generated by jsdifflib
1
Untabify the arm translate.c. This affects only some lines,
1
From: Philippe Mathieu-Daudé <philmd@linaro.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
IEC binary prefixes ease code review: the unit is explicit.
8
a whitespace-only change.
9
4
5
Add the FLASH_SECTOR_SIZE definition.
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230109115316.2235-8-philmd@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Message-id: 20180821165215.29069-2-peter.maydell@linaro.org
12
---
11
---
13
target/arm/translate.c | 122 ++++++++++++++++++++---------------------
12
hw/arm/mainstone.c | 18 ++++++++++--------
14
1 file changed, 61 insertions(+), 61 deletions(-)
13
1 file changed, 10 insertions(+), 8 deletions(-)
15
14
16
diff --git a/target/arm/translate.c b/target/arm/translate.c
15
diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c
17
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/translate.c
17
--- a/hw/arm/mainstone.c
19
+++ b/target/arm/translate.c
18
+++ b/hw/arm/mainstone.c
20
@@ -XXX,XX +XXX,XX @@ static inline void gen_mov_vreg_F0(int dp, int reg)
19
@@ -XXX,XX +XXX,XX @@
21
tcg_gen_st_f32(cpu_F0s, cpu_env, vfp_reg_offset(dp, reg));
20
* GNU GPL, version 2 or (at your option) any later version.
22
}
21
*/
23
22
#include "qemu/osdep.h"
24
-#define ARM_CP_RW_BIT    (1 << 20)
23
+#include "qemu/units.h"
25
+#define ARM_CP_RW_BIT (1 << 20)
24
#include "qemu/error-report.h"
26
25
#include "qapi/error.h"
27
static inline void iwmmxt_load_reg(TCGv_i64 var, int reg)
26
#include "hw/arm/pxa.h"
27
@@ -XXX,XX +XXX,XX @@ static const struct keymap map[0xE0] = {
28
29
enum mainstone_model_e { mainstone };
30
31
-#define MAINSTONE_RAM    0x04000000
32
-#define MAINSTONE_ROM    0x00800000
33
-#define MAINSTONE_FLASH    0x02000000
34
+#define MAINSTONE_RAM_SIZE (64 * MiB)
35
+#define MAINSTONE_ROM_SIZE (8 * MiB)
36
+#define MAINSTONE_FLASH_SIZE (32 * MiB)
37
38
static struct arm_boot_info mainstone_binfo = {
39
.loader_start = PXA2XX_SDRAM_BASE,
40
- .ram_size = 0x04000000,
41
+ .ram_size = MAINSTONE_RAM_SIZE,
42
};
43
44
+#define FLASH_SECTOR_SIZE (256 * KiB)
45
+
46
static void mainstone_common_init(MachineState *machine,
47
enum mainstone_model_e model, int arm_id)
28
{
48
{
29
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
49
- uint32_t sector_len = 256 * 1024;
30
wrd = insn & 0xf;
50
hwaddr mainstone_flash_base[] = { MST_FLASH_0, MST_FLASH_1 };
31
rdlo = (insn >> 12) & 0xf;
51
PXA2xxState *mpu;
32
rdhi = (insn >> 16) & 0xf;
52
DeviceState *mst_irq;
33
- if (insn & ARM_CP_RW_BIT) {            /* TMRRC */
53
@@ -XXX,XX +XXX,XX @@ static void mainstone_common_init(MachineState *machine,
34
+ if (insn & ARM_CP_RW_BIT) { /* TMRRC */
54
35
iwmmxt_load_reg(cpu_V0, wrd);
55
/* Setup CPU & memory */
36
tcg_gen_extrl_i64_i32(cpu_R[rdlo], cpu_V0);
56
mpu = pxa270_init(mainstone_binfo.ram_size, machine->cpu_type);
37
tcg_gen_shri_i64(cpu_V0, cpu_V0, 32);
57
- memory_region_init_rom(rom, NULL, "mainstone.rom", MAINSTONE_ROM,
38
tcg_gen_extrl_i64_i32(cpu_R[rdhi], cpu_V0);
58
+ memory_region_init_rom(rom, NULL, "mainstone.rom", MAINSTONE_ROM_SIZE,
39
- } else {                    /* TMCRR */
59
&error_fatal);
40
+ } else { /* TMCRR */
60
memory_region_add_subregion(get_system_memory(), 0x00000000, rom);
41
tcg_gen_concat_i32_i64(cpu_V0, cpu_R[rdlo], cpu_R[rdhi]);
61
42
iwmmxt_store_reg(cpu_V0, wrd);
62
@@ -XXX,XX +XXX,XX @@ static void mainstone_common_init(MachineState *machine,
43
gen_op_iwmmxt_set_mup();
63
dinfo = drive_get(IF_PFLASH, 0, i);
44
@@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn)
64
if (!pflash_cfi01_register(mainstone_flash_base[i],
45
return 1;
65
i ? "mainstone.flash1" : "mainstone.flash0",
46
}
66
- MAINSTONE_FLASH,
47
if (insn & ARM_CP_RW_BIT) {
67
+ MAINSTONE_FLASH_SIZE,
48
- if ((insn >> 28) == 0xf) {            /* WLDRW wCx */
68
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
49
+ if ((insn >> 28) == 0xf) { /* WLDRW wCx */
69
- sector_len, 4, 0, 0, 0, 0, 0)) {
50
tmp = tcg_temp_new_i32();
70
+ FLASH_SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
51
gen_aa32_ld32u(s, tmp, addr, get_mem_index(s));
71
error_report("Error registering flash memory");
52
iwmmxt_store_creg(wrd, tmp);
72
exit(1);
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
}
73
}
494
--
74
--
495
2.18.0
75
2.34.1
496
76
497
77
diff view generated by jsdifflib
1
The IoTKit doesn't have any MSCs itself but it does need
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
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
2
6
We also need to expose a MemoryRegion corresponding to
3
IEC binary prefixes ease code review: the unit is explicit.
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
4
5
Add the FLASH_SECTOR_SIZE definition.
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230109115316.2235-9-philmd@linaro.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
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
---
11
---
17
include/hw/arm/iotkit.h | 8 ++++++++
12
hw/arm/musicpal.c | 9 ++++++---
18
hw/arm/iotkit.c | 15 +++++++++++++++
13
1 file changed, 6 insertions(+), 3 deletions(-)
19
2 files changed, 23 insertions(+)
20
14
21
diff --git a/include/hw/arm/iotkit.h b/include/hw/arm/iotkit.h
15
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
22
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
23
--- a/include/hw/arm/iotkit.h
17
--- a/hw/arm/musicpal.c
24
+++ b/include/hw/arm/iotkit.h
18
+++ b/hw/arm/musicpal.c
25
@@ -XXX,XX +XXX,XX @@
19
@@ -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
*/
20
*/
45
21
46
#ifndef IOTKIT_H
22
#include "qemu/osdep.h"
47
diff --git a/hw/arm/iotkit.c b/hw/arm/iotkit.c
23
+#include "qemu/units.h"
48
index XXXXXXX..XXXXXXX 100644
24
#include "qapi/error.h"
49
--- a/hw/arm/iotkit.c
25
#include "cpu.h"
50
+++ b/hw/arm/iotkit.c
26
#include "hw/sysbus.h"
51
@@ -XXX,XX +XXX,XX @@ static void iotkit_realize(DeviceState *dev, Error **errp)
27
@@ -XXX,XX +XXX,XX @@ static const TypeInfo musicpal_key_info = {
52
28
.class_init = musicpal_key_class_init,
53
iotkit_forward_sec_resp_cfg(s);
29
};
54
30
55
+ /* Forward the MSC related signals */
31
+#define FLASH_SECTOR_SIZE (64 * KiB)
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
+
32
+
62
+ /*
33
static struct arm_boot_info musicpal_binfo = {
63
+ * Expose our container region to the board model; this corresponds
34
.loader_start = 0x0,
64
+ * to the AHB Slave Expansion ports which allow bus master devices
35
.board_id = 0x20e,
65
+ * (eg DMA controllers) in the board model to make transactions into
36
@@ -XXX,XX +XXX,XX @@ static void musicpal_init(MachineState *machine)
66
+ * devices in the IoTKit.
37
BlockBackend *blk = blk_by_legacy_dinfo(dinfo);
67
+ */
38
68
+ sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->container);
39
flash_size = blk_getlength(blk);
69
+
40
- if (flash_size != 8*1024*1024 && flash_size != 16*1024*1024 &&
70
system_clock_scale = NANOSECONDS_PER_SECOND / s->mainclk_frq;
41
- flash_size != 32*1024*1024) {
71
}
42
+ if (flash_size != 8 * MiB && flash_size != 16 * MiB &&
72
43
+ flash_size != 32 * MiB) {
44
error_report("Invalid flash image size");
45
exit(1);
46
}
47
@@ -XXX,XX +XXX,XX @@ static void musicpal_init(MachineState *machine)
48
*/
49
pflash_cfi02_register(0x100000000ULL - MP_FLASH_SIZE_MAX,
50
"musicpal.flash", flash_size,
51
- blk, 0x10000,
52
+ blk, FLASH_SECTOR_SIZE,
53
MP_FLASH_SIZE_MAX / flash_size,
54
2, 0x00BF, 0x236D, 0x0000, 0x0000,
55
0x5555, 0x2AAA, 0);
73
--
56
--
74
2.18.0
57
2.34.1
75
58
76
59
diff view generated by jsdifflib
1
Abstract out the calculation of the pitch and size of the
1
From: Philippe Mathieu-Daudé <philmd@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
The total_ram_v1/total_ram_v2 definitions were never used.
4
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20230109115316.2235-10-philmd@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: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20180814144436.679-6-peter.maydell@linaro.org
9
---
9
---
10
include/hw/display/bcm2835_fb.h | 22 ++++++++++++++++++++++
10
hw/arm/omap_sx1.c | 2 --
11
hw/display/bcm2835_fb.c | 6 +++---
11
1 file changed, 2 deletions(-)
12
hw/misc/bcm2835_property.c | 4 ++--
13
3 files changed, 27 insertions(+), 5 deletions(-)
14
12
15
diff --git a/include/hw/display/bcm2835_fb.h b/include/hw/display/bcm2835_fb.h
13
diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c
16
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/display/bcm2835_fb.h
15
--- a/hw/arm/omap_sx1.c
18
+++ b/include/hw/display/bcm2835_fb.h
16
+++ b/hw/arm/omap_sx1.c
19
@@ -XXX,XX +XXX,XX @@ typedef struct {
17
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps static_ops = {
20
18
#define flash0_size    (16 * 1024 * 1024)
21
void bcm2835_fb_reconfigure(BCM2835FBState *s, BCM2835FBConfig *newconfig);
19
#define flash1_size    ( 8 * 1024 * 1024)
22
20
#define flash2_size    (32 * 1024 * 1024)
23
+/**
21
-#define total_ram_v1    (sdram_size + flash0_size + flash1_size + OMAP15XX_SRAM_SIZE)
24
+ * bcm2835_fb_get_pitch: return number of bytes per line of the framebuffer
22
-#define total_ram_v2    (sdram_size + flash2_size + OMAP15XX_SRAM_SIZE)
25
+ * @config: configuration info for the framebuffer
23
26
+ *
24
static struct arm_boot_info sx1_binfo = {
27
+ * Return the number of bytes per line of the framebuffer, ie the number
25
.loader_start = OMAP_EMIFF_BASE,
28
+ * that must be added to a pixel address to get the address of the pixel
29
+ * directly below it on screen.
30
+ */
31
+static inline uint32_t bcm2835_fb_get_pitch(BCM2835FBConfig *config)
32
+{
33
+ return config->xres * (config->bpp >> 3);
34
+}
35
+
36
+/**
37
+ * bcm2835_fb_get_size: return total size of framebuffer in bytes
38
+ * @config: configuration info for the framebuffer
39
+ */
40
+static inline uint32_t bcm2835_fb_get_size(BCM2835FBConfig *config)
41
+{
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
--
26
--
93
2.18.0
27
2.34.1
94
28
95
29
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3
IEC binary prefixes ease code review: the unit is explicit.
4
Message-id: 20180814002653.12828-2-richard.henderson@linaro.org
4
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20230109115316.2235-11-philmd@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
9
---
8
include/fpu/softfloat.h | 56 ++++++++----
10
hw/arm/omap_sx1.c | 33 +++++++++++++++++----------------
9
fpu/softfloat.c | 188 +++++++++++++++++++++++++++++-----------
11
1 file changed, 17 insertions(+), 16 deletions(-)
10
2 files changed, 179 insertions(+), 65 deletions(-)
11
12
12
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
13
diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c
13
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
14
--- a/include/fpu/softfloat.h
15
--- a/hw/arm/omap_sx1.c
15
+++ b/include/fpu/softfloat.h
16
+++ b/hw/arm/omap_sx1.c
16
@@ -XXX,XX +XXX,XX @@ enum {
17
@@ -XXX,XX +XXX,XX @@
17
/*----------------------------------------------------------------------------
18
* with this program; if not, see <http://www.gnu.org/licenses/>.
18
| Software IEC/IEEE integer-to-floating-point conversion routines.
19
*----------------------------------------------------------------------------*/
20
+
21
+float16 int16_to_float16_scalbn(int16_t a, int, float_status *status);
22
+float16 int32_to_float16_scalbn(int32_t a, int, float_status *status);
23
+float16 int64_to_float16_scalbn(int64_t a, int, float_status *status);
24
+float16 uint16_to_float16_scalbn(uint16_t a, int, float_status *status);
25
+float16 uint32_to_float16_scalbn(uint32_t a, int, float_status *status);
26
+float16 uint64_to_float16_scalbn(uint64_t a, int, float_status *status);
27
+
28
+float16 int16_to_float16(int16_t a, float_status *status);
29
+float16 int32_to_float16(int32_t a, float_status *status);
30
+float16 int64_to_float16(int64_t a, float_status *status);
31
+float16 uint16_to_float16(uint16_t a, float_status *status);
32
+float16 uint32_to_float16(uint32_t a, float_status *status);
33
+float16 uint64_to_float16(uint64_t a, float_status *status);
34
+
35
+float32 int16_to_float32_scalbn(int16_t, int, float_status *status);
36
+float32 int32_to_float32_scalbn(int32_t, int, float_status *status);
37
+float32 int64_to_float32_scalbn(int64_t, int, float_status *status);
38
+float32 uint16_to_float32_scalbn(uint16_t, int, float_status *status);
39
+float32 uint32_to_float32_scalbn(uint32_t, int, float_status *status);
40
+float32 uint64_to_float32_scalbn(uint64_t, int, float_status *status);
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
*/
19
*/
100
20
#include "qemu/osdep.h"
101
-static FloatParts int_to_float(int64_t a, float_status *status)
21
+#include "qemu/units.h"
102
+static FloatParts int_to_float(int64_t a, int scale, float_status *status)
22
#include "qapi/error.h"
103
{
23
#include "ui/console.h"
104
- FloatParts r = {};
24
#include "hw/arm/omap.h"
105
+ FloatParts r = { .sign = false };
25
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps static_ops = {
106
+
26
.endianness = DEVICE_NATIVE_ENDIAN,
107
if (a == 0) {
27
};
108
r.cls = float_class_zero;
28
109
- r.sign = false;
29
-#define sdram_size    0x02000000
110
- } else if (a == (1ULL << 63)) {
30
-#define sector_size    (128 * 1024)
111
- r.cls = float_class_normal;
31
-#define flash0_size    (16 * 1024 * 1024)
112
- r.sign = true;
32
-#define flash1_size    ( 8 * 1024 * 1024)
113
- r.frac = DECOMPOSED_IMPLICIT_BIT;
33
-#define flash2_size    (32 * 1024 * 1024)
114
- r.exp = 63;
34
+#define SDRAM_SIZE (32 * MiB)
115
} else {
35
+#define SECTOR_SIZE (128 * KiB)
116
- uint64_t f;
36
+#define FLASH0_SIZE (16 * MiB)
117
- if (a < 0) {
37
+#define FLASH1_SIZE (8 * MiB)
118
- f = -a;
38
+#define FLASH2_SIZE (32 * MiB)
119
- r.sign = true;
39
120
- } else {
40
static struct arm_boot_info sx1_binfo = {
121
- f = a;
41
.loader_start = OMAP_EMIFF_BASE,
122
- r.sign = false;
42
- .ram_size = sdram_size,
123
- }
43
+ .ram_size = SDRAM_SIZE,
124
- int shift = clz64(f) - 1;
44
.board_id = 0x265,
125
+ uint64_t f = a;
45
};
126
+ int shift;
46
127
+
47
@@ -XXX,XX +XXX,XX @@ static void sx1_init(MachineState *machine, const int version)
128
r.cls = float_class_normal;
48
static uint32_t cs3val = 0x00001139;
129
- r.exp = (DECOMPOSED_BINARY_POINT - shift);
49
DriveInfo *dinfo;
130
- r.frac = f << shift;
50
int fl_idx;
131
+ if (a < 0) {
51
- uint32_t flash_size = flash0_size;
132
+ f = -f;
52
+ uint32_t flash_size = FLASH0_SIZE;
133
+ r.sign = true;
53
134
+ }
54
if (machine->ram_size != mc->default_ram_size) {
135
+ shift = clz64(f) - 1;
55
char *sz = size_to_str(mc->default_ram_size);
136
+ scale = MIN(MAX(scale, -0x10000), 0x10000);
56
@@ -XXX,XX +XXX,XX @@ static void sx1_init(MachineState *machine, const int version)
137
+
138
+ r.exp = DECOMPOSED_BINARY_POINT - shift + scale;
139
+ r.frac = (shift < 0 ? DECOMPOSED_IMPLICIT_BIT : f << shift);
140
}
57
}
141
58
142
return r;
59
if (version == 2) {
60
- flash_size = flash2_size;
61
+ flash_size = FLASH2_SIZE;
62
}
63
64
memory_region_add_subregion(address_space, OMAP_EMIFF_BASE, machine->ram);
65
@@ -XXX,XX +XXX,XX @@ static void sx1_init(MachineState *machine, const int version)
66
if (!pflash_cfi01_register(OMAP_CS0_BASE,
67
"omap_sx1.flash0-1", flash_size,
68
blk_by_legacy_dinfo(dinfo),
69
- sector_size, 4, 0, 0, 0, 0, 0)) {
70
+ SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
71
fprintf(stderr, "qemu: Error registering flash memory %d.\n",
72
fl_idx);
73
}
74
@@ -XXX,XX +XXX,XX @@ static void sx1_init(MachineState *machine, const int version)
75
(dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) {
76
MemoryRegion *flash_1 = g_new(MemoryRegion, 1);
77
memory_region_init_rom(flash_1, NULL, "omap_sx1.flash1-0",
78
- flash1_size, &error_fatal);
79
+ FLASH1_SIZE, &error_fatal);
80
memory_region_add_subregion(address_space, OMAP_CS1_BASE, flash_1);
81
82
memory_region_init_io(&cs[1], NULL, &static_ops, &cs1val,
83
- "sx1.cs1", OMAP_CS1_SIZE - flash1_size);
84
+ "sx1.cs1", OMAP_CS1_SIZE - FLASH1_SIZE);
85
memory_region_add_subregion(address_space,
86
- OMAP_CS1_BASE + flash1_size, &cs[1]);
87
+ OMAP_CS1_BASE + FLASH1_SIZE, &cs[1]);
88
89
if (!pflash_cfi01_register(OMAP_CS1_BASE,
90
- "omap_sx1.flash1-1", flash1_size,
91
+ "omap_sx1.flash1-1", FLASH1_SIZE,
92
blk_by_legacy_dinfo(dinfo),
93
- sector_size, 4, 0, 0, 0, 0, 0)) {
94
+ SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
95
fprintf(stderr, "qemu: Error registering flash memory %d.\n",
96
fl_idx);
97
}
98
@@ -XXX,XX +XXX,XX @@ static void sx1_machine_v2_class_init(ObjectClass *oc, void *data)
99
mc->init = sx1_init_v2;
100
mc->ignore_memory_transaction_failures = true;
101
mc->default_cpu_type = ARM_CPU_TYPE_NAME("ti925t");
102
- mc->default_ram_size = sdram_size;
103
+ mc->default_ram_size = SDRAM_SIZE;
104
mc->default_ram_id = "omap1.dram";
143
}
105
}
144
106
145
+float16 int64_to_float16_scalbn(int64_t a, int scale, float_status *status)
107
@@ -XXX,XX +XXX,XX @@ static void sx1_machine_v1_class_init(ObjectClass *oc, void *data)
146
+{
108
mc->init = sx1_init_v1;
147
+ FloatParts pa = int_to_float(a, scale, status);
109
mc->ignore_memory_transaction_failures = true;
148
+ return float16_round_pack_canonical(pa, status);
110
mc->default_cpu_type = ARM_CPU_TYPE_NAME("ti925t");
149
+}
111
- mc->default_ram_size = sdram_size;
150
+
112
+ mc->default_ram_size = SDRAM_SIZE;
151
+float16 int32_to_float16_scalbn(int32_t a, int scale, float_status *status)
113
mc->default_ram_id = "omap1.dram";
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
{
163
- FloatParts pa = int_to_float(a, status);
164
- return float16_round_pack_canonical(pa, status);
165
+ return int64_to_float16_scalbn(a, 0, status);
166
}
114
}
167
115
168
float16 int32_to_float16(int32_t a, float_status *status)
169
{
170
- return int64_to_float16(a, status);
171
+ return int64_to_float16_scalbn(a, 0, status);
172
}
173
174
float16 int16_to_float16(int16_t a, float_status *status)
175
{
176
- return int64_to_float16(a, status);
177
+ return int64_to_float16_scalbn(a, 0, status);
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
}
195
196
float32 int64_to_float32(int64_t a, float_status *status)
197
{
198
- FloatParts pa = int_to_float(a, status);
199
- return float32_round_pack_canonical(pa, status);
200
+ return int64_to_float32_scalbn(a, 0, status);
201
}
202
203
float32 int32_to_float32(int32_t a, float_status *status)
204
{
205
- return int64_to_float32(a, status);
206
+ return int64_to_float32_scalbn(a, 0, status);
207
}
208
209
float32 int16_to_float32(int16_t a, float_status *status)
210
{
211
- return int64_to_float32(a, status);
212
+ return int64_to_float32_scalbn(a, 0, status);
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
}
230
231
float64 int64_to_float64(int64_t a, float_status *status)
232
{
233
- FloatParts pa = int_to_float(a, status);
234
- return float64_round_pack_canonical(pa, status);
235
+ return int64_to_float64_scalbn(a, 0, status);
236
}
237
238
float64 int32_to_float64(int32_t a, float_status *status)
239
{
240
- return int64_to_float64(a, status);
241
+ return int64_to_float64_scalbn(a, 0, status);
242
}
243
244
float64 int16_to_float64(int16_t a, float_status *status)
245
{
246
- return int64_to_float64(a, status);
247
+ return int64_to_float64_scalbn(a, 0, status);
248
}
249
250
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
{
258
- FloatParts r = { .sign = false};
259
+ FloatParts r = { .sign = false };
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
}
284
285
+float16 uint64_to_float16_scalbn(uint64_t a, int scale, float_status *status)
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
--
116
--
392
2.18.0
117
2.34.1
393
118
394
119
diff view generated by jsdifflib
1
Reduce the size of the per-cpu GICH memory regions from 0x1000
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
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
2
3
IEC binary prefixes ease code review: the unit is explicit.
4
5
Add the FLASH_SECTOR_SIZE definition.
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230109115316.2235-12-philmd@linaro.org
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
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
---
11
hw/intc/arm_gic.c | 2 +-
12
hw/arm/z2.c | 6 ++++--
12
1 file changed, 1 insertion(+), 1 deletion(-)
13
1 file changed, 4 insertions(+), 2 deletions(-)
13
14
14
diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
15
diff --git a/hw/arm/z2.c b/hw/arm/z2.c
15
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/intc/arm_gic.c
17
--- a/hw/arm/z2.c
17
+++ b/hw/intc/arm_gic.c
18
+++ b/hw/arm/z2.c
18
@@ -XXX,XX +XXX,XX @@ static void arm_gic_realize(DeviceState *dev, Error **errp)
19
@@ -XXX,XX +XXX,XX @@
19
for (i = 0; i < s->num_cpu; i++) {
20
*/
20
memory_region_init_io(&s->vifaceiomem[i + 1], OBJECT(s),
21
21
&gic_viface_ops, &s->backref[i],
22
#include "qemu/osdep.h"
22
- "gic_viface", 0x1000);
23
+#include "qemu/units.h"
23
+ "gic_viface", 0x200);
24
#include "hw/arm/pxa.h"
24
sysbus_init_mmio(sbd, &s->vifaceiomem[i + 1]);
25
#include "hw/arm/boot.h"
25
}
26
#include "hw/i2c/i2c.h"
27
@@ -XXX,XX +XXX,XX @@ static const TypeInfo aer915_info = {
28
.class_init = aer915_class_init,
29
};
30
31
+#define FLASH_SECTOR_SIZE (64 * KiB)
32
+
33
static void z2_init(MachineState *machine)
34
{
35
- uint32_t sector_len = 0x10000;
36
PXA2xxState *mpu;
37
DriveInfo *dinfo;
38
void *z2_lcd;
39
@@ -XXX,XX +XXX,XX @@ static void z2_init(MachineState *machine)
40
dinfo = drive_get(IF_PFLASH, 0, 0);
41
if (!pflash_cfi01_register(Z2_FLASH_BASE, "z2.flash0", Z2_FLASH_SIZE,
42
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
43
- sector_len, 4, 0, 0, 0, 0, 0)) {
44
+ FLASH_SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
45
error_report("Error registering flash memory");
46
exit(1);
26
}
47
}
27
--
48
--
28
2.18.0
49
2.34.1
29
50
30
51
diff view generated by jsdifflib
1
Don't request that the arm_load_kernel() code should boot in secure
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
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
2
3
Upon introduction in commit b8433303fb ("Set proper device-width
4
for vexpress flash"), ve_pflash_cfi01_register() was calling
5
qdev_init_nofail() which can not fail. This call was later
6
converted with a script to use &error_fatal, still unable to
7
fail. Remove the unreachable code.
8
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20230109115316.2235-13-philmd@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
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
---
13
---
12
hw/arm/vexpress.c | 4 ++--
14
hw/arm/vexpress.c | 10 +---------
13
1 file changed, 2 insertions(+), 2 deletions(-)
15
1 file changed, 1 insertion(+), 9 deletions(-)
14
16
15
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
17
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
16
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/vexpress.c
19
--- a/hw/arm/vexpress.c
18
+++ b/hw/arm/vexpress.c
20
+++ b/hw/arm/vexpress.c
19
@@ -XXX,XX +XXX,XX @@ static void vexpress_common_init(MachineState *machine)
21
@@ -XXX,XX +XXX,XX @@ static void vexpress_common_init(MachineState *machine)
20
daughterboard->bootinfo.smp_bootreg_addr = map[VE_SYSREGS] + 0x30;
22
dinfo = drive_get(IF_PFLASH, 0, 0);
21
daughterboard->bootinfo.gic_cpu_if_addr = daughterboard->gic_cpu_if_addr;
23
pflash0 = ve_pflash_cfi01_register(map[VE_NORFLASH0], "vexpress.flash0",
22
daughterboard->bootinfo.modify_dtb = vexpress_modify_dtb;
24
dinfo);
23
- /* Indicate that when booting Linux we should be in secure state */
25
- if (!pflash0) {
24
- daughterboard->bootinfo.secure_boot = true;
26
- error_report("vexpress: error registering flash 0");
25
+ /* When booting Linux we should be in secure state if the CPU has one. */
27
- exit(1);
26
+ daughterboard->bootinfo.secure_boot = vms->secure;
28
- }
27
arm_load_kernel(ARM_CPU(first_cpu), &daughterboard->bootinfo);
29
28
}
30
if (map[VE_NORFLASHALIAS] != -1) {
29
31
/* Map flash 0 as an alias into low memory */
32
@@ -XXX,XX +XXX,XX @@ static void vexpress_common_init(MachineState *machine)
33
}
34
35
dinfo = drive_get(IF_PFLASH, 0, 1);
36
- if (!ve_pflash_cfi01_register(map[VE_NORFLASH1], "vexpress.flash1",
37
- dinfo)) {
38
- error_report("vexpress: error registering flash 1");
39
- exit(1);
40
- }
41
+ ve_pflash_cfi01_register(map[VE_NORFLASH1], "vexpress.flash1", dinfo);
42
43
sram_size = 0x2000000;
44
memory_region_init_ram(sram, NULL, "vexpress.sram", sram_size,
30
--
45
--
31
2.18.0
46
2.34.1
32
47
33
48
diff view generated by jsdifflib
1
Connect the VIRQ and VFIQ lines from the GIC to the CPU;
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
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
2
3
Since its QOM'ification in commit 368a354f02 ("pflash_cfi0x:
4
QOMified") the pflash_cfi01_register() function does not fail.
5
6
This call was later converted with a script to use &error_fatal,
7
still unable to fail. Remove the unreachable code.
8
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20230109115316.2235-14-philmd@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: Luc Michel <luc.michel@greensocs.com>
8
Message-id: 20180821132811.17675-5-peter.maydell@linaro.org
9
---
13
---
10
hw/arm/highbank.c | 6 ++++++
14
hw/arm/gumstix.c | 18 ++++++------------
11
1 file changed, 6 insertions(+)
15
hw/arm/mainstone.c | 13 +++++--------
16
hw/arm/omap_sx1.c | 22 ++++++++--------------
17
hw/arm/versatilepb.c | 6 ++----
18
hw/arm/z2.c | 9 +++------
19
5 files changed, 24 insertions(+), 44 deletions(-)
12
20
13
diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c
21
diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
14
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/arm/highbank.c
23
--- a/hw/arm/gumstix.c
16
+++ b/hw/arm/highbank.c
24
+++ b/hw/arm/gumstix.c
17
@@ -XXX,XX +XXX,XX @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id)
25
@@ -XXX,XX +XXX,XX @@ static void connex_init(MachineState *machine)
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
}
26
}
33
27
34
sysmem = get_system_memory();
28
/* Numonyx RC28F128J3F75 */
35
@@ -XXX,XX +XXX,XX @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id)
29
- if (!pflash_cfi01_register(0x00000000, "connext.rom", CONNEX_FLASH_SIZE,
36
for (n = 0; n < smp_cpus; n++) {
30
- dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
37
sysbus_connect_irq(busdev, n, cpu_irq[n]);
31
- FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0)) {
38
sysbus_connect_irq(busdev, n + smp_cpus, cpu_fiq[n]);
32
- error_report("Error registering flash memory");
39
+ sysbus_connect_irq(busdev, n + 2 * smp_cpus, cpu_virq[n]);
33
- exit(1);
40
+ sysbus_connect_irq(busdev, n + 3 * smp_cpus, cpu_vfiq[n]);
34
- }
35
+ pflash_cfi01_register(0x00000000, "connext.rom", CONNEX_FLASH_SIZE,
36
+ dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
37
+ FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0);
38
39
/* Interrupt line of NIC is connected to GPIO line 36 */
40
smc91c111_init(&nd_table[0], 0x04000300,
41
@@ -XXX,XX +XXX,XX @@ static void verdex_init(MachineState *machine)
41
}
42
}
42
43
43
for (n = 0; n < 128; n++) {
44
/* Micron RC28F256P30TFA */
45
- if (!pflash_cfi01_register(0x00000000, "verdex.rom", VERDEX_FLASH_SIZE,
46
- dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
47
- FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0)) {
48
- error_report("Error registering flash memory");
49
- exit(1);
50
- }
51
+ pflash_cfi01_register(0x00000000, "verdex.rom", VERDEX_FLASH_SIZE,
52
+ dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
53
+ FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0);
54
55
/* Interrupt line of NIC is connected to GPIO line 99 */
56
smc91c111_init(&nd_table[0], 0x04000300,
57
diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c
58
index XXXXXXX..XXXXXXX 100644
59
--- a/hw/arm/mainstone.c
60
+++ b/hw/arm/mainstone.c
61
@@ -XXX,XX +XXX,XX @@ static void mainstone_common_init(MachineState *machine,
62
/* There are two 32MiB flash devices on the board */
63
for (i = 0; i < 2; i ++) {
64
dinfo = drive_get(IF_PFLASH, 0, i);
65
- if (!pflash_cfi01_register(mainstone_flash_base[i],
66
- i ? "mainstone.flash1" : "mainstone.flash0",
67
- MAINSTONE_FLASH_SIZE,
68
- dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
69
- FLASH_SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
70
- error_report("Error registering flash memory");
71
- exit(1);
72
- }
73
+ pflash_cfi01_register(mainstone_flash_base[i],
74
+ i ? "mainstone.flash1" : "mainstone.flash0",
75
+ MAINSTONE_FLASH_SIZE,
76
+ dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
77
+ FLASH_SECTOR_SIZE, 4, 0, 0, 0, 0, 0);
78
}
79
80
mst_irq = sysbus_create_simple("mainstone-fpga", MST_FPGA_PHYS,
81
diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c
82
index XXXXXXX..XXXXXXX 100644
83
--- a/hw/arm/omap_sx1.c
84
+++ b/hw/arm/omap_sx1.c
85
@@ -XXX,XX +XXX,XX @@ static void sx1_init(MachineState *machine, const int version)
86
87
fl_idx = 0;
88
if ((dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) {
89
- if (!pflash_cfi01_register(OMAP_CS0_BASE,
90
- "omap_sx1.flash0-1", flash_size,
91
- blk_by_legacy_dinfo(dinfo),
92
- SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
93
- fprintf(stderr, "qemu: Error registering flash memory %d.\n",
94
- fl_idx);
95
- }
96
+ pflash_cfi01_register(OMAP_CS0_BASE,
97
+ "omap_sx1.flash0-1", flash_size,
98
+ blk_by_legacy_dinfo(dinfo),
99
+ SECTOR_SIZE, 4, 0, 0, 0, 0, 0);
100
fl_idx++;
101
}
102
103
@@ -XXX,XX +XXX,XX @@ static void sx1_init(MachineState *machine, const int version)
104
memory_region_add_subregion(address_space,
105
OMAP_CS1_BASE + FLASH1_SIZE, &cs[1]);
106
107
- if (!pflash_cfi01_register(OMAP_CS1_BASE,
108
- "omap_sx1.flash1-1", FLASH1_SIZE,
109
- blk_by_legacy_dinfo(dinfo),
110
- SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
111
- fprintf(stderr, "qemu: Error registering flash memory %d.\n",
112
- fl_idx);
113
- }
114
+ pflash_cfi01_register(OMAP_CS1_BASE,
115
+ "omap_sx1.flash1-1", FLASH1_SIZE,
116
+ blk_by_legacy_dinfo(dinfo),
117
+ SECTOR_SIZE, 4, 0, 0, 0, 0, 0);
118
fl_idx++;
119
} else {
120
memory_region_init_io(&cs[1], NULL, &static_ops, &cs1val,
121
diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c
122
index XXXXXXX..XXXXXXX 100644
123
--- a/hw/arm/versatilepb.c
124
+++ b/hw/arm/versatilepb.c
125
@@ -XXX,XX +XXX,XX @@ static void versatile_init(MachineState *machine, int board_id)
126
/* 0x34000000 NOR Flash */
127
128
dinfo = drive_get(IF_PFLASH, 0, 0);
129
- if (!pflash_cfi01_register(VERSATILE_FLASH_ADDR, "versatile.flash",
130
+ pflash_cfi01_register(VERSATILE_FLASH_ADDR, "versatile.flash",
131
VERSATILE_FLASH_SIZE,
132
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
133
VERSATILE_FLASH_SECT_SIZE,
134
- 4, 0x0089, 0x0018, 0x0000, 0x0, 0)) {
135
- fprintf(stderr, "qemu: Error registering flash memory.\n");
136
- }
137
+ 4, 0x0089, 0x0018, 0x0000, 0x0, 0);
138
139
versatile_binfo.ram_size = machine->ram_size;
140
versatile_binfo.board_id = board_id;
141
diff --git a/hw/arm/z2.c b/hw/arm/z2.c
142
index XXXXXXX..XXXXXXX 100644
143
--- a/hw/arm/z2.c
144
+++ b/hw/arm/z2.c
145
@@ -XXX,XX +XXX,XX @@ static void z2_init(MachineState *machine)
146
mpu = pxa270_init(z2_binfo.ram_size, machine->cpu_type);
147
148
dinfo = drive_get(IF_PFLASH, 0, 0);
149
- if (!pflash_cfi01_register(Z2_FLASH_BASE, "z2.flash0", Z2_FLASH_SIZE,
150
- dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
151
- FLASH_SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
152
- error_report("Error registering flash memory");
153
- exit(1);
154
- }
155
+ pflash_cfi01_register(Z2_FLASH_BASE, "z2.flash0", Z2_FLASH_SIZE,
156
+ dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
157
+ FLASH_SECTOR_SIZE, 4, 0, 0, 0, 0, 0);
158
159
/* setup keypad */
160
pxa27x_register_keypad(mpu->kp, map, 0x100);
44
--
161
--
45
2.18.0
162
2.34.1
46
163
47
164
diff view generated by jsdifflib
1
Fix MPS2 SCC config register values for the mps2-an511
1
From: Philippe Mathieu-Daudé <philmd@linaro.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
To avoid forward-declaring PXA2xxI2CState, declare
4
PXA2XX_I2C before its use in pxa2xx_i2c_init() prototype.
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20230109140306.23161-2-philmd@linaro.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/arm/pxa.h | 6 +++---
14
1 file changed, 3 insertions(+), 3 deletions(-)
12
1 file changed, 3 insertions(+), 3 deletions(-)
15
13
16
diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
14
diff --git a/include/hw/arm/pxa.h b/include/hw/arm/pxa.h
17
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/arm/mps2.c
16
--- a/include/hw/arm/pxa.h
19
+++ b/hw/arm/mps2.c
17
+++ b/include/hw/arm/pxa.h
20
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
18
@@ -XXX,XX +XXX,XX @@ void pxa27x_register_keypad(PXA2xxKeyPadState *kp,
21
sccdev = DEVICE(&mms->scc);
19
const struct keymap *map, int size);
22
qdev_set_parent_bus(sccdev, sysbus_get_default());
20
23
qdev_prop_set_uint32(sccdev, "scc-cfg4", 0x2);
21
/* pxa2xx.c */
24
- qdev_prop_set_uint32(sccdev, "scc-aid", 0x02000008);
22
-typedef struct PXA2xxI2CState PXA2xxI2CState;
25
+ qdev_prop_set_uint32(sccdev, "scc-aid", 0x00200008);
23
+#define TYPE_PXA2XX_I2C "pxa2xx_i2c"
26
qdev_prop_set_uint32(sccdev, "scc-id", mmc->scc_id);
24
+OBJECT_DECLARE_SIMPLE_TYPE(PXA2xxI2CState, PXA2XX_I2C)
27
object_property_set_bool(OBJECT(&mms->scc), true, "realized",
25
+
28
&error_fatal);
26
PXA2xxI2CState *pxa2xx_i2c_init(hwaddr base,
29
@@ -XXX,XX +XXX,XX @@ static void mps2_an385_class_init(ObjectClass *oc, void *data)
27
qemu_irq irq, uint32_t page_size);
30
mc->desc = "ARM MPS2 with AN385 FPGA image for Cortex-M3";
28
I2CBus *pxa2xx_i2c_bus(PXA2xxI2CState *s);
31
mmc->fpga_type = FPGA_AN385;
29
32
mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m3");
30
-#define TYPE_PXA2XX_I2C "pxa2xx_i2c"
33
- mmc->scc_id = 0x41040000 | (385 << 4);
31
typedef struct PXA2xxI2SState PXA2xxI2SState;
34
+ mmc->scc_id = 0x41043850;
32
-OBJECT_DECLARE_SIMPLE_TYPE(PXA2xxI2CState, PXA2XX_I2C)
35
}
33
36
34
#define TYPE_PXA2XX_FIR "pxa2xx-fir"
37
static void mps2_an511_class_init(ObjectClass *oc, void *data)
35
OBJECT_DECLARE_SIMPLE_TYPE(PXA2xxFIrState, PXA2XX_FIR)
38
@@ -XXX,XX +XXX,XX @@ static void mps2_an511_class_init(ObjectClass *oc, void *data)
39
mc->desc = "ARM MPS2 with AN511 DesignStart FPGA image for Cortex-M3";
40
mmc->fpga_type = FPGA_AN511;
41
mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m3");
42
- mmc->scc_id = 0x4104000 | (511 << 4);
43
+ mmc->scc_id = 0x41045110;
44
}
45
46
static const TypeInfo mps2_info = {
47
--
36
--
48
2.18.0
37
2.34.1
49
38
50
39
diff view generated by jsdifflib
1
The BCM2835FBState struct has a 'pitch' field which is a
1
From: Philippe Mathieu-Daudé <philmd@linaro.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
Add a local 'struct omap_gpif_s *' variable to improve readability.
4
(This also eases next commit conversion).
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20230109140306.23161-3-philmd@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
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
---
10
---
12
include/hw/display/bcm2835_fb.h | 4 ----
11
hw/gpio/omap_gpio.c | 3 ++-
13
hw/display/bcm2835_fb.c | 19 ++++++++-----------
12
1 file changed, 2 insertions(+), 1 deletion(-)
14
2 files changed, 8 insertions(+), 15 deletions(-)
15
13
16
diff --git a/include/hw/display/bcm2835_fb.h b/include/hw/display/bcm2835_fb.h
14
diff --git a/hw/gpio/omap_gpio.c b/hw/gpio/omap_gpio.c
17
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/display/bcm2835_fb.h
16
--- a/hw/gpio/omap_gpio.c
19
+++ b/include/hw/display/bcm2835_fb.h
17
+++ b/hw/gpio/omap_gpio.c
20
@@ -XXX,XX +XXX,XX @@ typedef struct {
18
@@ -XXX,XX +XXX,XX @@ struct omap_gpif_s {
21
bool lock, invalidate, pending;
19
/* General-Purpose I/O of OMAP1 */
22
20
static void omap_gpio_set(void *opaque, int line, int level)
23
BCM2835FBConfig config;
24
-
25
- /* These are just cached values calculated from the config settings */
26
- uint32_t size;
27
- uint32_t pitch;
28
} BCM2835FBState;
29
30
void bcm2835_fb_reconfigure(BCM2835FBState *s, BCM2835FBConfig *newconfig);
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
{
21
{
39
+ uint32_t pitch;
22
- struct omap_gpio_s *s = &((struct omap_gpif_s *) opaque)->omap1;
40
+ uint32_t size;
23
+ struct omap_gpif_s *p = opaque;
41
+
24
+ struct omap_gpio_s *s = &p->omap1;
42
value &= ~0xf;
25
uint16_t prev = s->inputs;
43
26
44
s->lock = true;
27
if (level)
45
@@ -XXX,XX +XXX,XX @@ static void bcm2835_fb_mbox_push(BCM2835FBState *s, uint32_t value)
46
47
/* TODO - Manage properly virtual resolution */
48
49
- s->pitch = s->config.xres * (s->config.bpp >> 3);
50
- s->size = s->config.yres * s->pitch;
51
+ pitch = s->config.xres * (s->config.bpp >> 3);
52
+ size = s->config.yres * pitch;
53
54
- stl_le_phys(&s->dma_as, value + 16, s->pitch);
55
+ stl_le_phys(&s->dma_as, value + 16, pitch);
56
stl_le_phys(&s->dma_as, value + 32, s->config.base);
57
- stl_le_phys(&s->dma_as, value + 36, s->size);
58
+ stl_le_phys(&s->dma_as, value + 36, size);
59
60
s->invalidate = true;
61
qemu_console_resize(s->con, s->config.xres, s->config.yres);
62
@@ -XXX,XX +XXX,XX @@ void bcm2835_fb_reconfigure(BCM2835FBState *s, BCM2835FBConfig *newconfig)
63
64
/* TODO - Manage properly virtual resolution */
65
66
- s->pitch = s->config.xres * (s->config.bpp >> 3);
67
- s->size = s->config.yres * s->pitch;
68
-
69
s->invalidate = true;
70
qemu_console_resize(s->con, s->config.xres, s->config.yres);
71
s->lock = false;
72
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_bcm2835_fb = {
73
VMSTATE_UINT32(config.yoffset, BCM2835FBState),
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
--
28
--
92
2.18.0
29
2.34.1
93
30
94
31
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4
Message-id: 20180814002653.12828-3-richard.henderson@linaro.org
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Message-id: 20230109140306.23161-4-philmd@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
hw/arm/omap1.c | 115 ++++++++++++++++++--------------------
9
fpu/softfloat.c | 391 ++++++++++++++++++++++++++++++++--------
9
hw/arm/omap2.c | 40 ++++++-------
10
2 files changed, 379 insertions(+), 97 deletions(-)
10
hw/arm/omap_sx1.c | 2 +-
11
hw/arm/palm.c | 2 +-
12
hw/char/omap_uart.c | 7 +--
13
hw/display/omap_dss.c | 15 +++--
14
hw/display/omap_lcdc.c | 9 ++-
15
hw/dma/omap_dma.c | 15 +++--
16
hw/gpio/omap_gpio.c | 15 +++--
17
hw/intc/omap_intc.c | 12 ++--
18
hw/misc/omap_gpmc.c | 12 ++--
19
hw/misc/omap_l4.c | 7 +--
20
hw/misc/omap_sdrc.c | 7 +--
21
hw/misc/omap_tap.c | 5 +-
22
hw/sd/omap_mmc.c | 9 ++-
23
hw/ssi/omap_spi.c | 7 +--
24
hw/timer/omap_gptimer.c | 22 ++++----
25
hw/timer/omap_synctimer.c | 4 +-
26
18 files changed, 142 insertions(+), 163 deletions(-)
11
27
12
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
28
diff --git a/hw/arm/omap1.c b/hw/arm/omap1.c
13
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
14
--- a/include/fpu/softfloat.h
30
--- a/hw/arm/omap1.c
15
+++ b/include/fpu/softfloat.h
31
+++ b/hw/arm/omap1.c
16
@@ -XXX,XX +XXX,XX @@ float128 uint64_to_float128(uint64_t, float_status *status);
32
@@ -XXX,XX +XXX,XX @@ static void omap_timer_fire(void *opaque)
17
/*----------------------------------------------------------------------------
33
18
| Software half-precision conversion routines.
34
static void omap_timer_tick(void *opaque)
19
*----------------------------------------------------------------------------*/
35
{
20
+
36
- struct omap_mpu_timer_s *timer = (struct omap_mpu_timer_s *) opaque;
21
float16 float32_to_float16(float32, bool ieee, float_status *status);
37
+ struct omap_mpu_timer_s *timer = opaque;
22
float32 float16_to_float32(float16, bool ieee, float_status *status);
38
23
float16 float64_to_float16(float64 a, bool ieee, float_status *status);
39
omap_timer_sync(timer);
24
float64 float16_to_float64(float16 a, bool ieee, float_status *status);
40
omap_timer_fire(timer);
25
+
41
@@ -XXX,XX +XXX,XX @@ static void omap_timer_tick(void *opaque)
26
+int16_t float16_to_int16_scalbn(float16, int, int, float_status *status);
42
27
+int32_t float16_to_int32_scalbn(float16, int, int, float_status *status);
43
static void omap_timer_clk_update(void *opaque, int line, int on)
28
+int64_t float16_to_int64_scalbn(float16, int, int, float_status *status);
44
{
29
+
45
- struct omap_mpu_timer_s *timer = (struct omap_mpu_timer_s *) opaque;
30
int16_t float16_to_int16(float16, float_status *status);
46
+ struct omap_mpu_timer_s *timer = opaque;
31
-uint16_t float16_to_uint16(float16 a, float_status *status);
47
32
-int16_t float16_to_int16_round_to_zero(float16, float_status *status);
48
omap_timer_sync(timer);
33
-uint16_t float16_to_uint16_round_to_zero(float16 a, float_status *status);
49
timer->rate = on ? omap_clk_getrate(timer->clk) : 0;
34
int32_t float16_to_int32(float16, float_status *status);
50
@@ -XXX,XX +XXX,XX @@ static void omap_timer_clk_setup(struct omap_mpu_timer_s *timer)
35
-uint32_t float16_to_uint32(float16 a, float_status *status);
51
static uint64_t omap_mpu_timer_read(void *opaque, hwaddr addr,
36
-int32_t float16_to_int32_round_to_zero(float16, float_status *status);
52
unsigned size)
37
-uint32_t float16_to_uint32_round_to_zero(float16 a, float_status *status);
53
{
38
int64_t float16_to_int64(float16, float_status *status);
54
- struct omap_mpu_timer_s *s = (struct omap_mpu_timer_s *) opaque;
39
-uint64_t float16_to_uint64(float16 a, float_status *status);
55
+ struct omap_mpu_timer_s *s = opaque;
40
+
56
41
+int16_t float16_to_int16_round_to_zero(float16, float_status *status);
57
if (size != 4) {
42
+int32_t float16_to_int32_round_to_zero(float16, float_status *status);
58
return omap_badwidth_read32(opaque, addr);
43
int64_t float16_to_int64_round_to_zero(float16, float_status *status);
59
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_mpu_timer_read(void *opaque, hwaddr addr,
44
+
60
static void omap_mpu_timer_write(void *opaque, hwaddr addr,
45
+uint16_t float16_to_uint16_scalbn(float16 a, int, int, float_status *status);
61
uint64_t value, unsigned size)
46
+uint32_t float16_to_uint32_scalbn(float16 a, int, int, float_status *status);
62
{
47
+uint64_t float16_to_uint64_scalbn(float16 a, int, int, float_status *status);
63
- struct omap_mpu_timer_s *s = (struct omap_mpu_timer_s *) opaque;
48
+
64
+ struct omap_mpu_timer_s *s = opaque;
49
+uint16_t float16_to_uint16(float16 a, float_status *status);
65
50
+uint32_t float16_to_uint32(float16 a, float_status *status);
66
if (size != 4) {
51
+uint64_t float16_to_uint64(float16 a, float_status *status);
67
omap_badwidth_write32(opaque, addr, value);
52
+
68
@@ -XXX,XX +XXX,XX @@ struct omap_watchdog_timer_s {
53
+uint16_t float16_to_uint16_round_to_zero(float16 a, float_status *status);
69
static uint64_t omap_wd_timer_read(void *opaque, hwaddr addr,
54
+uint32_t float16_to_uint32_round_to_zero(float16 a, float_status *status);
70
unsigned size)
55
uint64_t float16_to_uint64_round_to_zero(float16 a, float_status *status);
71
{
56
72
- struct omap_watchdog_timer_s *s = (struct omap_watchdog_timer_s *) opaque;
57
/*----------------------------------------------------------------------------
73
+ struct omap_watchdog_timer_s *s = opaque;
58
@@ -XXX,XX +XXX,XX @@ float16 float16_default_nan(float_status *status);
74
59
/*----------------------------------------------------------------------------
75
if (size != 2) {
60
| Software IEC/IEEE single-precision conversion routines.
76
return omap_badwidth_read16(opaque, addr);
61
*----------------------------------------------------------------------------*/
77
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_wd_timer_read(void *opaque, hwaddr addr,
62
+
78
static void omap_wd_timer_write(void *opaque, hwaddr addr,
63
+int16_t float32_to_int16_scalbn(float32, int, int, float_status *status);
79
uint64_t value, unsigned size)
64
+int32_t float32_to_int32_scalbn(float32, int, int, float_status *status);
80
{
65
+int64_t float32_to_int64_scalbn(float32, int, int, float_status *status);
81
- struct omap_watchdog_timer_s *s = (struct omap_watchdog_timer_s *) opaque;
66
+
82
+ struct omap_watchdog_timer_s *s = opaque;
67
int16_t float32_to_int16(float32, float_status *status);
83
68
-uint16_t float32_to_uint16(float32, float_status *status);
84
if (size != 2) {
69
-int16_t float32_to_int16_round_to_zero(float32, float_status *status);
85
omap_badwidth_write16(opaque, addr, value);
70
-uint16_t float32_to_uint16_round_to_zero(float32, float_status *status);
86
@@ -XXX,XX +XXX,XX @@ struct omap_32khz_timer_s {
71
int32_t float32_to_int32(float32, float_status *status);
87
static uint64_t omap_os_timer_read(void *opaque, hwaddr addr,
72
-int32_t float32_to_int32_round_to_zero(float32, float_status *status);
88
unsigned size)
73
-uint32_t float32_to_uint32(float32, float_status *status);
89
{
74
-uint32_t float32_to_uint32_round_to_zero(float32, float_status *status);
90
- struct omap_32khz_timer_s *s = (struct omap_32khz_timer_s *) opaque;
75
int64_t float32_to_int64(float32, float_status *status);
91
+ struct omap_32khz_timer_s *s = opaque;
76
-uint64_t float32_to_uint64(float32, float_status *status);
92
int offset = addr & OMAP_MPUI_REG_MASK;
77
-uint64_t float32_to_uint64_round_to_zero(float32, float_status *status);
93
78
+
94
if (size != 4) {
79
+int16_t float32_to_int16_round_to_zero(float32, float_status *status);
95
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_os_timer_read(void *opaque, hwaddr addr,
80
+int32_t float32_to_int32_round_to_zero(float32, float_status *status);
96
static void omap_os_timer_write(void *opaque, hwaddr addr,
81
int64_t float32_to_int64_round_to_zero(float32, float_status *status);
97
uint64_t value, unsigned size)
82
+
98
{
83
+uint16_t float32_to_uint16_scalbn(float32, int, int, float_status *status);
99
- struct omap_32khz_timer_s *s = (struct omap_32khz_timer_s *) opaque;
84
+uint32_t float32_to_uint32_scalbn(float32, int, int, float_status *status);
100
+ struct omap_32khz_timer_s *s = opaque;
85
+uint64_t float32_to_uint64_scalbn(float32, int, int, float_status *status);
101
int offset = addr & OMAP_MPUI_REG_MASK;
86
+
102
87
+uint16_t float32_to_uint16(float32, float_status *status);
103
if (size != 4) {
88
+uint32_t float32_to_uint32(float32, float_status *status);
104
@@ -XXX,XX +XXX,XX @@ static struct omap_32khz_timer_s *omap_os_timer_init(MemoryRegion *memory,
89
+uint64_t float32_to_uint64(float32, float_status *status);
105
static uint64_t omap_ulpd_pm_read(void *opaque, hwaddr addr,
90
+
106
unsigned size)
91
+uint16_t float32_to_uint16_round_to_zero(float32, float_status *status);
107
{
92
+uint32_t float32_to_uint32_round_to_zero(float32, float_status *status);
108
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
93
+uint64_t float32_to_uint64_round_to_zero(float32, float_status *status);
109
+ struct omap_mpu_state_s *s = opaque;
94
+
110
uint16_t ret;
95
float64 float32_to_float64(float32, float_status *status);
111
96
floatx80 float32_to_floatx80(float32, float_status *status);
112
if (size != 2) {
97
float128 float32_to_float128(float32, float_status *status);
113
@@ -XXX,XX +XXX,XX @@ static inline void omap_ulpd_req_update(struct omap_mpu_state_s *s,
98
@@ -XXX,XX +XXX,XX @@ float32 float32_default_nan(float_status *status);
114
static void omap_ulpd_pm_write(void *opaque, hwaddr addr,
99
/*----------------------------------------------------------------------------
115
uint64_t value, unsigned size)
100
| Software IEC/IEEE double-precision conversion routines.
116
{
101
*----------------------------------------------------------------------------*/
117
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
102
+
118
+ struct omap_mpu_state_s *s = opaque;
103
+int16_t float64_to_int16_scalbn(float64, int, int, float_status *status);
119
int64_t now, ticks;
104
+int32_t float64_to_int32_scalbn(float64, int, int, float_status *status);
120
int div, mult;
105
+int64_t float64_to_int64_scalbn(float64, int, int, float_status *status);
121
static const int bypass_div[4] = { 1, 2, 4, 4 };
106
+
122
@@ -XXX,XX +XXX,XX @@ static void omap_ulpd_pm_init(MemoryRegion *system_memory,
107
int16_t float64_to_int16(float64, float_status *status);
123
static uint64_t omap_pin_cfg_read(void *opaque, hwaddr addr,
108
-uint16_t float64_to_uint16(float64, float_status *status);
124
unsigned size)
109
-int16_t float64_to_int16_round_to_zero(float64, float_status *status);
125
{
110
-uint16_t float64_to_uint16_round_to_zero(float64, float_status *status);
126
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
111
int32_t float64_to_int32(float64, float_status *status);
127
+ struct omap_mpu_state_s *s = opaque;
112
-int32_t float64_to_int32_round_to_zero(float64, float_status *status);
128
113
-uint32_t float64_to_uint32(float64, float_status *status);
129
if (size != 4) {
114
-uint32_t float64_to_uint32_round_to_zero(float64, float_status *status);
130
return omap_badwidth_read32(opaque, addr);
115
int64_t float64_to_int64(float64, float_status *status);
131
@@ -XXX,XX +XXX,XX @@ static inline void omap_pin_modconf1_update(struct omap_mpu_state_s *s,
116
+
132
static void omap_pin_cfg_write(void *opaque, hwaddr addr,
117
+int16_t float64_to_int16_round_to_zero(float64, float_status *status);
133
uint64_t value, unsigned size)
118
+int32_t float64_to_int32_round_to_zero(float64, float_status *status);
134
{
119
int64_t float64_to_int64_round_to_zero(float64, float_status *status);
135
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
120
-uint64_t float64_to_uint64(float64 a, float_status *status);
136
+ struct omap_mpu_state_s *s = opaque;
121
-uint64_t float64_to_uint64_round_to_zero(float64 a, float_status *status);
137
uint32_t diff;
122
+
138
123
+uint16_t float64_to_uint16_scalbn(float64, int, int, float_status *status);
139
if (size != 4) {
124
+uint32_t float64_to_uint32_scalbn(float64, int, int, float_status *status);
140
@@ -XXX,XX +XXX,XX @@ static void omap_pin_cfg_init(MemoryRegion *system_memory,
125
+uint64_t float64_to_uint64_scalbn(float64, int, int, float_status *status);
141
static uint64_t omap_id_read(void *opaque, hwaddr addr,
126
+
142
unsigned size)
127
+uint16_t float64_to_uint16(float64, float_status *status);
143
{
128
+uint32_t float64_to_uint32(float64, float_status *status);
144
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
129
+uint64_t float64_to_uint64(float64, float_status *status);
145
+ struct omap_mpu_state_s *s = opaque;
130
+
146
131
+uint16_t float64_to_uint16_round_to_zero(float64, float_status *status);
147
if (size != 4) {
132
+uint32_t float64_to_uint32_round_to_zero(float64, float_status *status);
148
return omap_badwidth_read32(opaque, addr);
133
+uint64_t float64_to_uint64_round_to_zero(float64, float_status *status);
149
@@ -XXX,XX +XXX,XX @@ static void omap_id_init(MemoryRegion *memory, struct omap_mpu_state_s *mpu)
134
+
150
static uint64_t omap_mpui_read(void *opaque, hwaddr addr,
135
float32 float64_to_float32(float64, float_status *status);
151
unsigned size)
136
floatx80 float64_to_floatx80(float64, float_status *status);
152
{
137
float128 float64_to_float128(float64, float_status *status);
153
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
138
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
154
+ struct omap_mpu_state_s *s = opaque;
139
index XXXXXXX..XXXXXXX 100644
155
140
--- a/fpu/softfloat.c
156
if (size != 4) {
141
+++ b/fpu/softfloat.c
157
return omap_badwidth_read32(opaque, addr);
142
@@ -XXX,XX +XXX,XX @@ float32 float64_to_float32(float64 a, float_status *s)
158
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_mpui_read(void *opaque, hwaddr addr,
143
* Arithmetic.
159
static void omap_mpui_write(void *opaque, hwaddr addr,
144
*/
160
uint64_t value, unsigned size)
145
161
{
146
-static FloatParts round_to_int(FloatParts a, int rounding_mode, float_status *s)
162
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
147
+static FloatParts round_to_int(FloatParts a, int rmode,
163
+ struct omap_mpu_state_s *s = opaque;
148
+ int scale, float_status *s)
164
149
{
165
if (size != 4) {
150
- if (is_nan(a.cls)) {
166
omap_badwidth_write32(opaque, addr, value);
151
- return return_nan(a, s);
167
@@ -XXX,XX +XXX,XX @@ struct omap_tipb_bridge_s {
152
- }
168
static uint64_t omap_tipb_bridge_read(void *opaque, hwaddr addr,
153
-
169
unsigned size)
154
switch (a.cls) {
170
{
155
+ case float_class_qnan:
171
- struct omap_tipb_bridge_s *s = (struct omap_tipb_bridge_s *) opaque;
156
+ case float_class_snan:
172
+ struct omap_tipb_bridge_s *s = opaque;
157
+ return return_nan(a, s);
173
158
+
174
if (size < 2) {
159
case float_class_zero:
175
return omap_badwidth_read16(opaque, addr);
160
case float_class_inf:
176
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_tipb_bridge_read(void *opaque, hwaddr addr,
161
- case float_class_qnan:
177
static void omap_tipb_bridge_write(void *opaque, hwaddr addr,
162
/* already "integral" */
178
uint64_t value, unsigned size)
163
break;
179
{
164
+
180
- struct omap_tipb_bridge_s *s = (struct omap_tipb_bridge_s *) opaque;
165
case float_class_normal:
181
+ struct omap_tipb_bridge_s *s = opaque;
166
+ scale = MIN(MAX(scale, -0x10000), 0x10000);
182
167
+ a.exp += scale;
183
if (size < 2) {
168
+
184
omap_badwidth_write16(opaque, addr, value);
169
if (a.exp >= DECOMPOSED_BINARY_POINT) {
185
@@ -XXX,XX +XXX,XX @@ static struct omap_tipb_bridge_s *omap_tipb_bridge_init(
170
/* already integral */
186
static uint64_t omap_tcmi_read(void *opaque, hwaddr addr,
171
break;
187
unsigned size)
172
@@ -XXX,XX +XXX,XX @@ static FloatParts round_to_int(FloatParts a, int rounding_mode, float_status *s)
188
{
173
bool one;
189
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
174
/* all fractional */
190
+ struct omap_mpu_state_s *s = opaque;
175
s->float_exception_flags |= float_flag_inexact;
191
uint32_t ret;
176
- switch (rounding_mode) {
192
177
+ switch (rmode) {
193
if (size != 4) {
178
case float_round_nearest_even:
194
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_tcmi_read(void *opaque, hwaddr addr,
179
one = a.exp == -1 && a.frac > DECOMPOSED_IMPLICIT_BIT;
195
static void omap_tcmi_write(void *opaque, hwaddr addr,
180
break;
196
uint64_t value, unsigned size)
181
@@ -XXX,XX +XXX,XX @@ static FloatParts round_to_int(FloatParts a, int rounding_mode, float_status *s)
197
{
182
uint64_t rnd_mask = rnd_even_mask >> 1;
198
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
183
uint64_t inc;
199
+ struct omap_mpu_state_s *s = opaque;
184
200
185
- switch (rounding_mode) {
201
if (size != 4) {
186
+ switch (rmode) {
202
omap_badwidth_write32(opaque, addr, value);
187
case float_round_nearest_even:
203
@@ -XXX,XX +XXX,XX @@ struct dpll_ctl_s {
188
inc = ((a.frac & rnd_even_mask) != frac_lsbm1 ? frac_lsbm1 : 0);
204
static uint64_t omap_dpll_read(void *opaque, hwaddr addr,
189
break;
205
unsigned size)
190
@@ -XXX,XX +XXX,XX @@ static FloatParts round_to_int(FloatParts a, int rounding_mode, float_status *s)
206
{
191
float16 float16_round_to_int(float16 a, float_status *s)
207
- struct dpll_ctl_s *s = (struct dpll_ctl_s *) opaque;
192
{
208
+ struct dpll_ctl_s *s = opaque;
193
FloatParts pa = float16_unpack_canonical(a, s);
209
194
- FloatParts pr = round_to_int(pa, s->float_rounding_mode, s);
210
if (size != 2) {
195
+ FloatParts pr = round_to_int(pa, s->float_rounding_mode, 0, s);
211
return omap_badwidth_read16(opaque, addr);
196
return float16_round_pack_canonical(pr, s);
212
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_dpll_read(void *opaque, hwaddr addr,
197
}
213
static void omap_dpll_write(void *opaque, hwaddr addr,
198
214
uint64_t value, unsigned size)
199
float32 float32_round_to_int(float32 a, float_status *s)
215
{
200
{
216
- struct dpll_ctl_s *s = (struct dpll_ctl_s *) opaque;
201
FloatParts pa = float32_unpack_canonical(a, s);
217
+ struct dpll_ctl_s *s = opaque;
202
- FloatParts pr = round_to_int(pa, s->float_rounding_mode, s);
218
uint16_t diff;
203
+ FloatParts pr = round_to_int(pa, s->float_rounding_mode, 0, s);
219
static const int bypass_div[4] = { 1, 2, 4, 4 };
204
return float32_round_pack_canonical(pr, s);
220
int div, mult;
205
}
221
@@ -XXX,XX +XXX,XX @@ static struct dpll_ctl_s *omap_dpll_init(MemoryRegion *memory,
206
222
static uint64_t omap_clkm_read(void *opaque, hwaddr addr,
207
float64 float64_round_to_int(float64 a, float_status *s)
223
unsigned size)
208
{
224
{
209
FloatParts pa = float64_unpack_canonical(a, s);
225
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
210
- FloatParts pr = round_to_int(pa, s->float_rounding_mode, s);
226
+ struct omap_mpu_state_s *s = opaque;
211
+ FloatParts pr = round_to_int(pa, s->float_rounding_mode, 0, s);
227
212
return float64_round_pack_canonical(pr, s);
228
if (size != 2) {
213
}
229
return omap_badwidth_read16(opaque, addr);
214
230
@@ -XXX,XX +XXX,XX @@ static inline void omap_clkm_ckout1_update(struct omap_mpu_state_s *s,
215
float64 float64_trunc_to_int(float64 a, float_status *s)
231
static void omap_clkm_write(void *opaque, hwaddr addr,
216
{
232
uint64_t value, unsigned size)
217
FloatParts pa = float64_unpack_canonical(a, s);
233
{
218
- FloatParts pr = round_to_int(pa, float_round_to_zero, s);
234
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
219
+ FloatParts pr = round_to_int(pa, float_round_to_zero, 0, s);
235
+ struct omap_mpu_state_s *s = opaque;
220
return float64_round_pack_canonical(pr, s);
236
uint16_t diff;
221
}
237
omap_clk clk;
222
238
static const char *clkschemename[8] = {
223
@@ -XXX,XX +XXX,XX @@ float64 float64_trunc_to_int(float64 a, float_status *s)
239
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap_clkm_ops = {
224
* is returned.
240
static uint64_t omap_clkdsp_read(void *opaque, hwaddr addr,
225
*/
241
unsigned size)
226
242
{
227
-static int64_t round_to_int_and_pack(FloatParts in, int rmode,
243
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
228
+static int64_t round_to_int_and_pack(FloatParts in, int rmode, int scale,
244
+ struct omap_mpu_state_s *s = opaque;
229
int64_t min, int64_t max,
245
CPUState *cpu = CPU(s->cpu);
230
float_status *s)
246
231
{
247
if (size != 2) {
232
uint64_t r;
248
@@ -XXX,XX +XXX,XX @@ static inline void omap_clkdsp_idlect2_update(struct omap_mpu_state_s *s,
233
int orig_flags = get_float_exception_flags(s);
249
static void omap_clkdsp_write(void *opaque, hwaddr addr,
234
- FloatParts p = round_to_int(in, rmode, s);
250
uint64_t value, unsigned size)
235
+ FloatParts p = round_to_int(in, rmode, scale, s);
251
{
236
252
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
237
switch (p.cls) {
253
+ struct omap_mpu_state_s *s = opaque;
238
case float_class_snan:
254
uint16_t diff;
239
@@ -XXX,XX +XXX,XX @@ static int64_t round_to_int_and_pack(FloatParts in, int rmode,
255
256
if (size != 2) {
257
@@ -XXX,XX +XXX,XX @@ struct omap_mpuio_s {
258
259
static void omap_mpuio_set(void *opaque, int line, int level)
260
{
261
- struct omap_mpuio_s *s = (struct omap_mpuio_s *) opaque;
262
+ struct omap_mpuio_s *s = opaque;
263
uint16_t prev = s->inputs;
264
265
if (level)
266
@@ -XXX,XX +XXX,XX @@ static void omap_mpuio_kbd_update(struct omap_mpuio_s *s)
267
static uint64_t omap_mpuio_read(void *opaque, hwaddr addr,
268
unsigned size)
269
{
270
- struct omap_mpuio_s *s = (struct omap_mpuio_s *) opaque;
271
+ struct omap_mpuio_s *s = opaque;
272
int offset = addr & OMAP_MPUI_REG_MASK;
273
uint16_t ret;
274
275
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_mpuio_read(void *opaque, hwaddr addr,
276
static void omap_mpuio_write(void *opaque, hwaddr addr,
277
uint64_t value, unsigned size)
278
{
279
- struct omap_mpuio_s *s = (struct omap_mpuio_s *) opaque;
280
+ struct omap_mpuio_s *s = opaque;
281
int offset = addr & OMAP_MPUI_REG_MASK;
282
uint16_t diff;
283
int ln;
284
@@ -XXX,XX +XXX,XX @@ static void omap_mpuio_reset(struct omap_mpuio_s *s)
285
286
static void omap_mpuio_onoff(void *opaque, int line, int on)
287
{
288
- struct omap_mpuio_s *s = (struct omap_mpuio_s *) opaque;
289
+ struct omap_mpuio_s *s = opaque;
290
291
s->clk = on;
292
if (on)
293
@@ -XXX,XX +XXX,XX @@ static void omap_uwire_transfer_start(struct omap_uwire_s *s)
240
}
294
}
241
}
295
}
242
296
243
-#define FLOAT_TO_INT(fsz, isz) \
297
-static uint64_t omap_uwire_read(void *opaque, hwaddr addr,
244
-int ## isz ## _t float ## fsz ## _to_int ## isz(float ## fsz a, \
298
- unsigned size)
245
- float_status *s) \
299
+static uint64_t omap_uwire_read(void *opaque, hwaddr addr, unsigned size)
246
-{ \
300
{
247
- FloatParts p = float ## fsz ## _unpack_canonical(a, s); \
301
- struct omap_uwire_s *s = (struct omap_uwire_s *) opaque;
248
- return round_to_int_and_pack(p, s->float_rounding_mode, \
302
+ struct omap_uwire_s *s = opaque;
249
- INT ## isz ## _MIN, INT ## isz ## _MAX,\
303
int offset = addr & OMAP_MPUI_REG_MASK;
250
- s); \
304
251
-} \
305
if (size != 2) {
252
- \
306
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_uwire_read(void *opaque, hwaddr addr,
253
-int ## isz ## _t float ## fsz ## _to_int ## isz ## _round_to_zero \
307
static void omap_uwire_write(void *opaque, hwaddr addr,
254
- (float ## fsz a, float_status *s) \
308
uint64_t value, unsigned size)
255
-{ \
309
{
256
- FloatParts p = float ## fsz ## _unpack_canonical(a, s); \
310
- struct omap_uwire_s *s = (struct omap_uwire_s *) opaque;
257
- return round_to_int_and_pack(p, float_round_to_zero, \
311
+ struct omap_uwire_s *s = opaque;
258
- INT ## isz ## _MIN, INT ## isz ## _MAX,\
312
int offset = addr & OMAP_MPUI_REG_MASK;
259
- s); \
313
260
+int16_t float16_to_int16_scalbn(float16 a, int rmode, int scale,
314
if (size != 2) {
261
+ float_status *s)
315
@@ -XXX,XX +XXX,XX @@ static void omap_pwl_update(struct omap_pwl_s *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
+}
304
+
305
+int64_t float32_to_int64_scalbn(float32 a, int rmode, int scale,
306
+ float_status *s)
307
+{
308
+ return round_to_int_and_pack(float32_unpack_canonical(a, s),
309
+ rmode, scale, INT64_MIN, INT64_MAX, s);
310
+}
311
+
312
+int16_t float64_to_int16_scalbn(float64 a, int rmode, int scale,
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
+
319
+int32_t float64_to_int32_scalbn(float64 a, int rmode, int scale,
320
+ float_status *s)
321
+{
322
+ return round_to_int_and_pack(float64_unpack_canonical(a, s),
323
+ rmode, scale, INT32_MIN, INT32_MAX, s);
324
+}
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
}
316
}
462
}
317
}
463
318
464
-#define FLOAT_TO_UINT(fsz, isz) \
319
-static uint64_t omap_pwl_read(void *opaque, hwaddr addr,
465
-uint ## isz ## _t float ## fsz ## _to_uint ## isz(float ## fsz a, \
320
- unsigned size)
466
- float_status *s) \
321
+static uint64_t omap_pwl_read(void *opaque, hwaddr addr, unsigned size)
467
-{ \
322
{
468
- FloatParts p = float ## fsz ## _unpack_canonical(a, s); \
323
- struct omap_pwl_s *s = (struct omap_pwl_s *) opaque;
469
- return round_to_uint_and_pack(p, s->float_rounding_mode, \
324
+ struct omap_pwl_s *s = opaque;
470
- UINT ## isz ## _MAX, s); \
325
int offset = addr & OMAP_MPUI_REG_MASK;
471
-} \
326
472
- \
327
if (size != 1) {
473
-uint ## isz ## _t float ## fsz ## _to_uint ## isz ## _round_to_zero \
328
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_pwl_read(void *opaque, hwaddr addr,
474
- (float ## fsz a, float_status *s) \
329
static void omap_pwl_write(void *opaque, hwaddr addr,
475
-{ \
330
uint64_t value, unsigned size)
476
- FloatParts p = float ## fsz ## _unpack_canonical(a, s); \
331
{
477
- return round_to_uint_and_pack(p, float_round_to_zero, \
332
- struct omap_pwl_s *s = (struct omap_pwl_s *) opaque;
478
- UINT ## isz ## _MAX, s); \
333
+ struct omap_pwl_s *s = opaque;
479
+uint16_t float16_to_uint16_scalbn(float16 a, int rmode, int scale,
334
int offset = addr & OMAP_MPUI_REG_MASK;
480
+ float_status *s)
335
481
+{
336
if (size != 1) {
482
+ return round_to_uint_and_pack(float16_unpack_canonical(a, s),
337
@@ -XXX,XX +XXX,XX @@ static void omap_pwl_reset(struct omap_pwl_s *s)
483
+ rmode, scale, UINT16_MAX, s);
338
484
}
339
static void omap_pwl_clk_update(void *opaque, int line, int on)
485
340
{
486
-FLOAT_TO_UINT(16, 16)
341
- struct omap_pwl_s *s = (struct omap_pwl_s *) opaque;
487
-FLOAT_TO_UINT(16, 32)
342
+ struct omap_pwl_s *s = opaque;
488
-FLOAT_TO_UINT(16, 64)
343
489
+uint32_t float16_to_uint32_scalbn(float16 a, int rmode, int scale,
344
s->clk = on;
490
+ float_status *s)
345
omap_pwl_update(s);
491
+{
346
@@ -XXX,XX +XXX,XX @@ struct omap_pwt_s {
492
+ return round_to_uint_and_pack(float16_unpack_canonical(a, s),
347
omap_clk clk;
493
+ rmode, scale, UINT32_MAX, s);
348
};
494
+}
349
495
350
-static uint64_t omap_pwt_read(void *opaque, hwaddr addr,
496
-FLOAT_TO_UINT(32, 16)
351
- unsigned size)
497
-FLOAT_TO_UINT(32, 32)
352
+static uint64_t omap_pwt_read(void *opaque, hwaddr addr, unsigned size)
498
-FLOAT_TO_UINT(32, 64)
353
{
499
+uint64_t float16_to_uint64_scalbn(float16 a, int rmode, int scale,
354
- struct omap_pwt_s *s = (struct omap_pwt_s *) opaque;
500
+ float_status *s)
355
+ struct omap_pwt_s *s = opaque;
501
+{
356
int offset = addr & OMAP_MPUI_REG_MASK;
502
+ return round_to_uint_and_pack(float16_unpack_canonical(a, s),
357
503
+ rmode, scale, UINT64_MAX, s);
358
if (size != 1) {
504
+}
359
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_pwt_read(void *opaque, hwaddr addr,
505
360
static void omap_pwt_write(void *opaque, hwaddr addr,
506
-FLOAT_TO_UINT(64, 16)
361
uint64_t value, unsigned size)
507
-FLOAT_TO_UINT(64, 32)
362
{
508
-FLOAT_TO_UINT(64, 64)
363
- struct omap_pwt_s *s = (struct omap_pwt_s *) opaque;
509
+uint16_t float32_to_uint16_scalbn(float32 a, int rmode, int scale,
364
+ struct omap_pwt_s *s = opaque;
510
+ float_status *s)
365
int offset = addr & OMAP_MPUI_REG_MASK;
511
+{
366
512
+ return round_to_uint_and_pack(float32_unpack_canonical(a, s),
367
if (size != 1) {
513
+ rmode, scale, UINT16_MAX, s);
368
@@ -XXX,XX +XXX,XX @@ static void omap_rtc_alarm_update(struct omap_rtc_s *s)
514
+}
369
printf("%s: conversion failed\n", __func__);
515
370
}
516
-#undef FLOAT_TO_UINT
371
517
+uint32_t float32_to_uint32_scalbn(float32 a, int rmode, int scale,
372
-static uint64_t omap_rtc_read(void *opaque, hwaddr addr,
518
+ float_status *s)
373
- unsigned size)
519
+{
374
+static uint64_t omap_rtc_read(void *opaque, hwaddr addr, unsigned size)
520
+ return round_to_uint_and_pack(float32_unpack_canonical(a, s),
375
{
521
+ rmode, scale, UINT32_MAX, s);
376
- struct omap_rtc_s *s = (struct omap_rtc_s *) opaque;
522
+}
377
+ struct omap_rtc_s *s = opaque;
523
+
378
int offset = addr & OMAP_MPUI_REG_MASK;
524
+uint64_t float32_to_uint64_scalbn(float32 a, int rmode, int scale,
379
uint8_t i;
525
+ float_status *s)
380
526
+{
381
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_rtc_read(void *opaque, hwaddr addr,
527
+ return round_to_uint_and_pack(float32_unpack_canonical(a, s),
382
static void omap_rtc_write(void *opaque, hwaddr addr,
528
+ rmode, scale, UINT64_MAX, s);
383
uint64_t value, unsigned size)
529
+}
384
{
530
+
385
- struct omap_rtc_s *s = (struct omap_rtc_s *) opaque;
531
+uint16_t float64_to_uint16_scalbn(float64 a, int rmode, int scale,
386
+ struct omap_rtc_s *s = opaque;
532
+ float_status *s)
387
int offset = addr & OMAP_MPUI_REG_MASK;
533
+{
388
struct tm new_tm;
534
+ return round_to_uint_and_pack(float64_unpack_canonical(a, s),
389
time_t ti[2];
535
+ rmode, scale, UINT16_MAX, s);
390
@@ -XXX,XX +XXX,XX @@ static void omap_mcbsp_rx_newdata(struct omap_mcbsp_s *s)
536
+}
391
537
+
392
static void omap_mcbsp_source_tick(void *opaque)
538
+uint32_t float64_to_uint32_scalbn(float64 a, int rmode, int scale,
393
{
539
+ float_status *s)
394
- struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque;
540
+{
395
+ struct omap_mcbsp_s *s = opaque;
541
+ return round_to_uint_and_pack(float64_unpack_canonical(a, s),
396
static const int bps[8] = { 0, 1, 1, 2, 2, 2, -255, -255 };
542
+ rmode, scale, UINT32_MAX, s);
397
543
+}
398
if (!s->rx_rate)
544
+
399
@@ -XXX,XX +XXX,XX @@ static void omap_mcbsp_tx_newdata(struct omap_mcbsp_s *s)
545
+uint64_t float64_to_uint64_scalbn(float64 a, int rmode, int scale,
400
546
+ float_status *s)
401
static void omap_mcbsp_sink_tick(void *opaque)
547
+{
402
{
548
+ return round_to_uint_and_pack(float64_unpack_canonical(a, s),
403
- struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque;
549
+ rmode, scale, UINT64_MAX, s);
404
+ struct omap_mcbsp_s *s = opaque;
550
+}
405
static const int bps[8] = { 0, 1, 1, 2, 2, 2, -255, -255 };
551
+
406
552
+uint16_t float16_to_uint16(float16 a, float_status *s)
407
if (!s->tx_rate)
553
+{
408
@@ -XXX,XX +XXX,XX @@ static void omap_mcbsp_req_update(struct omap_mcbsp_s *s)
554
+ return float16_to_uint16_scalbn(a, s->float_rounding_mode, 0, s);
409
static uint64_t omap_mcbsp_read(void *opaque, hwaddr addr,
555
+}
410
unsigned size)
556
+
411
{
557
+uint32_t float16_to_uint32(float16 a, float_status *s)
412
- struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque;
558
+{
413
+ struct omap_mcbsp_s *s = opaque;
559
+ return float16_to_uint32_scalbn(a, s->float_rounding_mode, 0, s);
414
int offset = addr & OMAP_MPUI_REG_MASK;
560
+}
415
uint16_t ret;
561
+
416
562
+uint64_t float16_to_uint64(float16 a, float_status *s)
417
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_mcbsp_read(void *opaque, hwaddr addr,
563
+{
418
static void omap_mcbsp_writeh(void *opaque, hwaddr addr,
564
+ return float16_to_uint64_scalbn(a, s->float_rounding_mode, 0, s);
419
uint32_t value)
565
+}
420
{
566
+
421
- struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque;
567
+uint16_t float32_to_uint16(float32 a, float_status *s)
422
+ struct omap_mcbsp_s *s = opaque;
568
+{
423
int offset = addr & OMAP_MPUI_REG_MASK;
569
+ return float32_to_uint16_scalbn(a, s->float_rounding_mode, 0, s);
424
570
+}
425
switch (offset) {
571
+
426
@@ -XXX,XX +XXX,XX @@ static void omap_mcbsp_writeh(void *opaque, hwaddr addr,
572
+uint32_t float32_to_uint32(float32 a, float_status *s)
427
static void omap_mcbsp_writew(void *opaque, hwaddr addr,
573
+{
428
uint32_t value)
574
+ return float32_to_uint32_scalbn(a, s->float_rounding_mode, 0, s);
429
{
575
+}
430
- struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque;
576
+
431
+ struct omap_mcbsp_s *s = opaque;
577
+uint64_t float32_to_uint64(float32 a, float_status *s)
432
int offset = addr & OMAP_MPUI_REG_MASK;
578
+{
433
579
+ return float32_to_uint64_scalbn(a, s->float_rounding_mode, 0, s);
434
if (offset == 0x04) {                /* DXR */
580
+}
435
@@ -XXX,XX +XXX,XX @@ static struct omap_mcbsp_s *omap_mcbsp_init(MemoryRegion *system_memory,
581
+
436
582
+uint16_t float64_to_uint16(float64 a, float_status *s)
437
static void omap_mcbsp_i2s_swallow(void *opaque, int line, int level)
583
+{
438
{
584
+ return float64_to_uint16_scalbn(a, s->float_rounding_mode, 0, s);
439
- struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque;
585
+}
440
+ struct omap_mcbsp_s *s = opaque;
586
+
441
587
+uint32_t float64_to_uint32(float64 a, float_status *s)
442
if (s->rx_rate) {
588
+{
443
s->rx_req = s->codec->in.len;
589
+ return float64_to_uint32_scalbn(a, s->float_rounding_mode, 0, s);
444
@@ -XXX,XX +XXX,XX @@ static void omap_mcbsp_i2s_swallow(void *opaque, int line, int level)
590
+}
445
591
+
446
static void omap_mcbsp_i2s_start(void *opaque, int line, int level)
592
+uint64_t float64_to_uint64(float64 a, float_status *s)
447
{
593
+{
448
- struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque;
594
+ return float64_to_uint64_scalbn(a, s->float_rounding_mode, 0, s);
449
+ struct omap_mcbsp_s *s = opaque;
595
+}
450
596
+
451
if (s->tx_rate) {
597
+uint16_t float16_to_uint16_round_to_zero(float16 a, float_status *s)
452
s->tx_req = s->codec->out.size;
598
+{
453
@@ -XXX,XX +XXX,XX @@ static void omap_lpg_reset(struct omap_lpg_s *s)
599
+ return float16_to_uint16_scalbn(a, float_round_to_zero, 0, s);
454
omap_lpg_update(s);
600
+}
455
}
601
+
456
602
+uint32_t float16_to_uint32_round_to_zero(float16 a, float_status *s)
457
-static uint64_t omap_lpg_read(void *opaque, hwaddr addr,
603
+{
458
- unsigned size)
604
+ return float16_to_uint32_scalbn(a, float_round_to_zero, 0, s);
459
+static uint64_t omap_lpg_read(void *opaque, hwaddr addr, unsigned size)
605
+}
460
{
606
+
461
- struct omap_lpg_s *s = (struct omap_lpg_s *) opaque;
607
+uint64_t float16_to_uint64_round_to_zero(float16 a, float_status *s)
462
+ struct omap_lpg_s *s = opaque;
608
+{
463
int offset = addr & OMAP_MPUI_REG_MASK;
609
+ return float16_to_uint64_scalbn(a, float_round_to_zero, 0, s);
464
610
+}
465
if (size != 1) {
611
+
466
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_lpg_read(void *opaque, hwaddr addr,
612
+uint16_t float32_to_uint16_round_to_zero(float32 a, float_status *s)
467
static void omap_lpg_write(void *opaque, hwaddr addr,
613
+{
468
uint64_t value, unsigned size)
614
+ return float32_to_uint16_scalbn(a, float_round_to_zero, 0, s);
469
{
615
+}
470
- struct omap_lpg_s *s = (struct omap_lpg_s *) opaque;
616
+
471
+ struct omap_lpg_s *s = opaque;
617
+uint32_t float32_to_uint32_round_to_zero(float32 a, float_status *s)
472
int offset = addr & OMAP_MPUI_REG_MASK;
618
+{
473
619
+ return float32_to_uint32_scalbn(a, float_round_to_zero, 0, s);
474
if (size != 1) {
620
+}
475
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap_lpg_ops = {
621
+
476
622
+uint64_t float32_to_uint64_round_to_zero(float32 a, float_status *s)
477
static void omap_lpg_clk_update(void *opaque, int line, int on)
623
+{
478
{
624
+ return float32_to_uint64_scalbn(a, float_round_to_zero, 0, s);
479
- struct omap_lpg_s *s = (struct omap_lpg_s *) opaque;
625
+}
480
+ struct omap_lpg_s *s = opaque;
626
+
481
627
+uint16_t float64_to_uint16_round_to_zero(float64 a, float_status *s)
482
s->clk = on;
628
+{
483
omap_lpg_update(s);
629
+ return float64_to_uint16_scalbn(a, float_round_to_zero, 0, s);
484
@@ -XXX,XX +XXX,XX @@ static void omap_setup_mpui_io(MemoryRegion *system_memory,
630
+}
485
/* General chip reset */
631
+
486
static void omap1_mpu_reset(void *opaque)
632
+uint32_t float64_to_uint32_round_to_zero(float64 a, float_status *s)
487
{
633
+{
488
- struct omap_mpu_state_s *mpu = (struct omap_mpu_state_s *) opaque;
634
+ return float64_to_uint32_scalbn(a, float_round_to_zero, 0, s);
489
+ struct omap_mpu_state_s *mpu = opaque;
635
+}
490
636
+
491
omap_dma_reset(mpu->dma);
637
+uint64_t float64_to_uint64_round_to_zero(float64 a, float_status *s)
492
omap_mpu_timer_reset(mpu->timer[0]);
638
+{
493
@@ -XXX,XX +XXX,XX @@ static void omap_setup_dsp_mapping(MemoryRegion *system_memory,
639
+ return float64_to_uint64_scalbn(a, float_round_to_zero, 0, s);
494
640
+}
495
void omap_mpu_wakeup(void *opaque, int irq, int req)
641
496
{
642
/*
497
- struct omap_mpu_state_s *mpu = (struct omap_mpu_state_s *) opaque;
643
* Integer to float conversions
498
+ struct omap_mpu_state_s *mpu = opaque;
499
CPUState *cpu = CPU(mpu->cpu);
500
501
if (cpu->halted) {
502
diff --git a/hw/arm/omap2.c b/hw/arm/omap2.c
503
index XXXXXXX..XXXXXXX 100644
504
--- a/hw/arm/omap2.c
505
+++ b/hw/arm/omap2.c
506
@@ -XXX,XX +XXX,XX @@ static inline void omap_eac_out_empty(struct omap_eac_s *s)
507
508
static void omap_eac_in_cb(void *opaque, int avail_b)
509
{
510
- struct omap_eac_s *s = (struct omap_eac_s *) opaque;
511
+ struct omap_eac_s *s = opaque;
512
513
s->codec.rxavail = avail_b >> 2;
514
omap_eac_in_refill(s);
515
@@ -XXX,XX +XXX,XX @@ static void omap_eac_in_cb(void *opaque, int avail_b)
516
517
static void omap_eac_out_cb(void *opaque, int free_b)
518
{
519
- struct omap_eac_s *s = (struct omap_eac_s *) opaque;
520
+ struct omap_eac_s *s = opaque;
521
522
s->codec.txavail = free_b >> 2;
523
if (s->codec.txlen)
524
@@ -XXX,XX +XXX,XX @@ static void omap_eac_reset(struct omap_eac_s *s)
525
omap_eac_interrupt_update(s);
526
}
527
528
-static uint64_t omap_eac_read(void *opaque, hwaddr addr,
529
- unsigned size)
530
+static uint64_t omap_eac_read(void *opaque, hwaddr addr, unsigned size)
531
{
532
- struct omap_eac_s *s = (struct omap_eac_s *) opaque;
533
+ struct omap_eac_s *s = opaque;
534
uint32_t ret;
535
536
if (size != 2) {
537
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_eac_read(void *opaque, hwaddr addr,
538
static void omap_eac_write(void *opaque, hwaddr addr,
539
uint64_t value, unsigned size)
540
{
541
- struct omap_eac_s *s = (struct omap_eac_s *) opaque;
542
+ struct omap_eac_s *s = opaque;
543
544
if (size != 2) {
545
omap_badwidth_write16(opaque, addr, value);
546
@@ -XXX,XX +XXX,XX @@ static void omap_sti_reset(struct omap_sti_s *s)
547
static uint64_t omap_sti_read(void *opaque, hwaddr addr,
548
unsigned size)
549
{
550
- struct omap_sti_s *s = (struct omap_sti_s *) opaque;
551
+ struct omap_sti_s *s = opaque;
552
553
if (size != 4) {
554
return omap_badwidth_read32(opaque, addr);
555
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_sti_read(void *opaque, hwaddr addr,
556
static void omap_sti_write(void *opaque, hwaddr addr,
557
uint64_t value, unsigned size)
558
{
559
- struct omap_sti_s *s = (struct omap_sti_s *) opaque;
560
+ struct omap_sti_s *s = opaque;
561
562
if (size != 4) {
563
omap_badwidth_write32(opaque, addr, value);
564
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap_sti_ops = {
565
.endianness = DEVICE_NATIVE_ENDIAN,
566
};
567
568
-static uint64_t omap_sti_fifo_read(void *opaque, hwaddr addr,
569
- unsigned size)
570
+static uint64_t omap_sti_fifo_read(void *opaque, hwaddr addr, unsigned size)
571
{
572
OMAP_BAD_REG(addr);
573
return 0;
574
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_sti_fifo_read(void *opaque, hwaddr addr,
575
static void omap_sti_fifo_write(void *opaque, hwaddr addr,
576
uint64_t value, unsigned size)
577
{
578
- struct omap_sti_s *s = (struct omap_sti_s *) opaque;
579
+ struct omap_sti_s *s = opaque;
580
int ch = addr >> 6;
581
uint8_t byte = value;
582
583
@@ -XXX,XX +XXX,XX @@ static void omap_prcm_int_update(struct omap_prcm_s *s, int dom)
584
static uint64_t omap_prcm_read(void *opaque, hwaddr addr,
585
unsigned size)
586
{
587
- struct omap_prcm_s *s = (struct omap_prcm_s *) opaque;
588
+ struct omap_prcm_s *s = opaque;
589
uint32_t ret;
590
591
if (size != 4) {
592
@@ -XXX,XX +XXX,XX @@ static void omap_prcm_dpll_update(struct omap_prcm_s *s)
593
static void omap_prcm_write(void *opaque, hwaddr addr,
594
uint64_t value, unsigned size)
595
{
596
- struct omap_prcm_s *s = (struct omap_prcm_s *) opaque;
597
+ struct omap_prcm_s *s = opaque;
598
599
if (size != 4) {
600
omap_badwidth_write32(opaque, addr, value);
601
@@ -XXX,XX +XXX,XX @@ struct omap_sysctl_s {
602
static uint32_t omap_sysctl_read8(void *opaque, hwaddr addr)
603
{
604
605
- struct omap_sysctl_s *s = (struct omap_sysctl_s *) opaque;
606
+ struct omap_sysctl_s *s = opaque;
607
int pad_offset, byte_offset;
608
int value;
609
610
@@ -XXX,XX +XXX,XX @@ static uint32_t omap_sysctl_read8(void *opaque, hwaddr addr)
611
612
static uint32_t omap_sysctl_read(void *opaque, hwaddr addr)
613
{
614
- struct omap_sysctl_s *s = (struct omap_sysctl_s *) opaque;
615
+ struct omap_sysctl_s *s = opaque;
616
617
switch (addr) {
618
case 0x000:    /* CONTROL_REVISION */
619
@@ -XXX,XX +XXX,XX @@ static uint32_t omap_sysctl_read(void *opaque, hwaddr addr)
620
return 0;
621
}
622
623
-static void omap_sysctl_write8(void *opaque, hwaddr addr,
624
- uint32_t value)
625
+static void omap_sysctl_write8(void *opaque, hwaddr addr, uint32_t value)
626
{
627
- struct omap_sysctl_s *s = (struct omap_sysctl_s *) opaque;
628
+ struct omap_sysctl_s *s = opaque;
629
int pad_offset, byte_offset;
630
int prev_value;
631
632
@@ -XXX,XX +XXX,XX @@ static void omap_sysctl_write8(void *opaque, hwaddr addr,
633
}
634
}
635
636
-static void omap_sysctl_write(void *opaque, hwaddr addr,
637
- uint32_t value)
638
+static void omap_sysctl_write(void *opaque, hwaddr addr, uint32_t value)
639
{
640
- struct omap_sysctl_s *s = (struct omap_sysctl_s *) opaque;
641
+ struct omap_sysctl_s *s = opaque;
642
643
switch (addr) {
644
case 0x000:    /* CONTROL_REVISION */
645
@@ -XXX,XX +XXX,XX @@ static struct omap_sysctl_s *omap_sysctl_init(struct omap_target_agent_s *ta,
646
/* General chip reset */
647
static void omap2_mpu_reset(void *opaque)
648
{
649
- struct omap_mpu_state_s *mpu = (struct omap_mpu_state_s *) opaque;
650
+ struct omap_mpu_state_s *mpu = opaque;
651
652
omap_dma_reset(mpu->dma);
653
omap_prcm_reset(mpu->prcm);
654
diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c
655
index XXXXXXX..XXXXXXX 100644
656
--- a/hw/arm/omap_sx1.c
657
+++ b/hw/arm/omap_sx1.c
658
@@ -XXX,XX +XXX,XX @@
659
static uint64_t static_read(void *opaque, hwaddr offset,
660
unsigned size)
661
{
662
- uint32_t *val = (uint32_t *) opaque;
663
+ uint32_t *val = opaque;
664
uint32_t mask = (4 / size) - 1;
665
666
return *val >> ((offset & mask) << 3);
667
diff --git a/hw/arm/palm.c b/hw/arm/palm.c
668
index XXXXXXX..XXXXXXX 100644
669
--- a/hw/arm/palm.c
670
+++ b/hw/arm/palm.c
671
@@ -XXX,XX +XXX,XX @@ static struct {
672
673
static void palmte_button_event(void *opaque, int keycode)
674
{
675
- struct omap_mpu_state_s *cpu = (struct omap_mpu_state_s *) opaque;
676
+ struct omap_mpu_state_s *cpu = opaque;
677
678
if (palmte_keymap[keycode & 0x7f].row != -1)
679
omap_mpuio_key(cpu->mpuio,
680
diff --git a/hw/char/omap_uart.c b/hw/char/omap_uart.c
681
index XXXXXXX..XXXXXXX 100644
682
--- a/hw/char/omap_uart.c
683
+++ b/hw/char/omap_uart.c
684
@@ -XXX,XX +XXX,XX @@ struct omap_uart_s *omap_uart_init(hwaddr base,
685
return s;
686
}
687
688
-static uint64_t omap_uart_read(void *opaque, hwaddr addr,
689
- unsigned size)
690
+static uint64_t omap_uart_read(void *opaque, hwaddr addr, unsigned size)
691
{
692
- struct omap_uart_s *s = (struct omap_uart_s *) opaque;
693
+ struct omap_uart_s *s = opaque;
694
695
if (size == 4) {
696
return omap_badwidth_read8(opaque, addr);
697
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_uart_read(void *opaque, hwaddr addr,
698
static void omap_uart_write(void *opaque, hwaddr addr,
699
uint64_t value, unsigned size)
700
{
701
- struct omap_uart_s *s = (struct omap_uart_s *) opaque;
702
+ struct omap_uart_s *s = opaque;
703
704
if (size == 4) {
705
omap_badwidth_write8(opaque, addr, value);
706
diff --git a/hw/display/omap_dss.c b/hw/display/omap_dss.c
707
index XXXXXXX..XXXXXXX 100644
708
--- a/hw/display/omap_dss.c
709
+++ b/hw/display/omap_dss.c
710
@@ -XXX,XX +XXX,XX @@ void omap_dss_reset(struct omap_dss_s *s)
711
static uint64_t omap_diss_read(void *opaque, hwaddr addr,
712
unsigned size)
713
{
714
- struct omap_dss_s *s = (struct omap_dss_s *) opaque;
715
+ struct omap_dss_s *s = opaque;
716
717
if (size != 4) {
718
return omap_badwidth_read32(opaque, addr);
719
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_diss_read(void *opaque, hwaddr addr,
720
static void omap_diss_write(void *opaque, hwaddr addr,
721
uint64_t value, unsigned size)
722
{
723
- struct omap_dss_s *s = (struct omap_dss_s *) opaque;
724
+ struct omap_dss_s *s = opaque;
725
726
if (size != 4) {
727
omap_badwidth_write32(opaque, addr, value);
728
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap_diss_ops = {
729
static uint64_t omap_disc_read(void *opaque, hwaddr addr,
730
unsigned size)
731
{
732
- struct omap_dss_s *s = (struct omap_dss_s *) opaque;
733
+ struct omap_dss_s *s = opaque;
734
735
if (size != 4) {
736
return omap_badwidth_read32(opaque, addr);
737
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_disc_read(void *opaque, hwaddr addr,
738
static void omap_disc_write(void *opaque, hwaddr addr,
739
uint64_t value, unsigned size)
740
{
741
- struct omap_dss_s *s = (struct omap_dss_s *) opaque;
742
+ struct omap_dss_s *s = opaque;
743
744
if (size != 4) {
745
omap_badwidth_write32(opaque, addr, value);
746
@@ -XXX,XX +XXX,XX @@ static void omap_rfbi_transfer_start(struct omap_dss_s *s)
747
omap_dispc_interrupt_update(s);
748
}
749
750
-static uint64_t omap_rfbi_read(void *opaque, hwaddr addr,
751
- unsigned size)
752
+static uint64_t omap_rfbi_read(void *opaque, hwaddr addr, unsigned size)
753
{
754
- struct omap_dss_s *s = (struct omap_dss_s *) opaque;
755
+ struct omap_dss_s *s = opaque;
756
757
if (size != 4) {
758
return omap_badwidth_read32(opaque, addr);
759
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_rfbi_read(void *opaque, hwaddr addr,
760
static void omap_rfbi_write(void *opaque, hwaddr addr,
761
uint64_t value, unsigned size)
762
{
763
- struct omap_dss_s *s = (struct omap_dss_s *) opaque;
764
+ struct omap_dss_s *s = opaque;
765
766
if (size != 4) {
767
omap_badwidth_write32(opaque, addr, value);
768
diff --git a/hw/display/omap_lcdc.c b/hw/display/omap_lcdc.c
769
index XXXXXXX..XXXXXXX 100644
770
--- a/hw/display/omap_lcdc.c
771
+++ b/hw/display/omap_lcdc.c
772
@@ -XXX,XX +XXX,XX @@ static void draw_line16_32(void *opaque, uint8_t *d, const uint8_t *s,
773
774
static void omap_update_display(void *opaque)
775
{
776
- struct omap_lcd_panel_s *omap_lcd = (struct omap_lcd_panel_s *) opaque;
777
+ struct omap_lcd_panel_s *omap_lcd = opaque;
778
DisplaySurface *surface;
779
drawfn draw_line;
780
int size, height, first, last;
781
@@ -XXX,XX +XXX,XX @@ static void omap_lcd_update(struct omap_lcd_panel_s *s) {
782
}
783
}
784
785
-static uint64_t omap_lcdc_read(void *opaque, hwaddr addr,
786
- unsigned size)
787
+static uint64_t omap_lcdc_read(void *opaque, hwaddr addr, unsigned size)
788
{
789
- struct omap_lcd_panel_s *s = (struct omap_lcd_panel_s *) opaque;
790
+ struct omap_lcd_panel_s *s = opaque;
791
792
switch (addr) {
793
case 0x00:    /* LCD_CONTROL */
794
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_lcdc_read(void *opaque, hwaddr addr,
795
static void omap_lcdc_write(void *opaque, hwaddr addr,
796
uint64_t value, unsigned size)
797
{
798
- struct omap_lcd_panel_s *s = (struct omap_lcd_panel_s *) opaque;
799
+ struct omap_lcd_panel_s *s = opaque;
800
801
switch (addr) {
802
case 0x00:    /* LCD_CONTROL */
803
diff --git a/hw/dma/omap_dma.c b/hw/dma/omap_dma.c
804
index XXXXXXX..XXXXXXX 100644
805
--- a/hw/dma/omap_dma.c
806
+++ b/hw/dma/omap_dma.c
807
@@ -XXX,XX +XXX,XX @@ static int omap_dma_sys_read(struct omap_dma_s *s, int offset,
808
return 0;
809
}
810
811
-static uint64_t omap_dma_read(void *opaque, hwaddr addr,
812
- unsigned size)
813
+static uint64_t omap_dma_read(void *opaque, hwaddr addr, unsigned size)
814
{
815
- struct omap_dma_s *s = (struct omap_dma_s *) opaque;
816
+ struct omap_dma_s *s = opaque;
817
int reg, ch;
818
uint16_t ret;
819
820
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_dma_read(void *opaque, hwaddr addr,
821
static void omap_dma_write(void *opaque, hwaddr addr,
822
uint64_t value, unsigned size)
823
{
824
- struct omap_dma_s *s = (struct omap_dma_s *) opaque;
825
+ struct omap_dma_s *s = opaque;
826
int reg, ch;
827
828
if (size != 2) {
829
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap_dma_ops = {
830
831
static void omap_dma_request(void *opaque, int drq, int req)
832
{
833
- struct omap_dma_s *s = (struct omap_dma_s *) opaque;
834
+ struct omap_dma_s *s = opaque;
835
/* The request pins are level triggered in QEMU. */
836
if (req) {
837
if (~s->dma->drqbmp & (1ULL << drq)) {
838
@@ -XXX,XX +XXX,XX @@ static void omap_dma_request(void *opaque, int drq, int req)
839
/* XXX: this won't be needed once soc_dma knows about clocks. */
840
static void omap_dma_clk_update(void *opaque, int line, int on)
841
{
842
- struct omap_dma_s *s = (struct omap_dma_s *) opaque;
843
+ struct omap_dma_s *s = opaque;
844
int i;
845
846
s->dma->freq = omap_clk_getrate(s->clk);
847
@@ -XXX,XX +XXX,XX @@ static void omap_dma_interrupts_4_update(struct omap_dma_s *s)
848
static uint64_t omap_dma4_read(void *opaque, hwaddr addr,
849
unsigned size)
850
{
851
- struct omap_dma_s *s = (struct omap_dma_s *) opaque;
852
+ struct omap_dma_s *s = opaque;
853
int irqn = 0, chnum;
854
struct omap_dma_channel_s *ch;
855
856
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_dma4_read(void *opaque, hwaddr addr,
857
static void omap_dma4_write(void *opaque, hwaddr addr,
858
uint64_t value, unsigned size)
859
{
860
- struct omap_dma_s *s = (struct omap_dma_s *) opaque;
861
+ struct omap_dma_s *s = opaque;
862
int chnum, irqn = 0;
863
struct omap_dma_channel_s *ch;
864
865
diff --git a/hw/gpio/omap_gpio.c b/hw/gpio/omap_gpio.c
866
index XXXXXXX..XXXXXXX 100644
867
--- a/hw/gpio/omap_gpio.c
868
+++ b/hw/gpio/omap_gpio.c
869
@@ -XXX,XX +XXX,XX @@ static void omap_gpio_set(void *opaque, int line, int level)
870
static uint64_t omap_gpio_read(void *opaque, hwaddr addr,
871
unsigned size)
872
{
873
- struct omap_gpio_s *s = (struct omap_gpio_s *) opaque;
874
+ struct omap_gpio_s *s = opaque;
875
int offset = addr & OMAP_MPUI_REG_MASK;
876
877
if (size != 2) {
878
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_gpio_read(void *opaque, hwaddr addr,
879
static void omap_gpio_write(void *opaque, hwaddr addr,
880
uint64_t value, unsigned size)
881
{
882
- struct omap_gpio_s *s = (struct omap_gpio_s *) opaque;
883
+ struct omap_gpio_s *s = opaque;
884
int offset = addr & OMAP_MPUI_REG_MASK;
885
uint16_t diff;
886
int ln;
887
@@ -XXX,XX +XXX,XX @@ static void omap2_gpio_module_reset(struct omap2_gpio_s *s)
888
889
static uint32_t omap2_gpio_module_read(void *opaque, hwaddr addr)
890
{
891
- struct omap2_gpio_s *s = (struct omap2_gpio_s *) opaque;
892
+ struct omap2_gpio_s *s = opaque;
893
894
switch (addr) {
895
case 0x00:    /* GPIO_REVISION */
896
@@ -XXX,XX +XXX,XX @@ static uint32_t omap2_gpio_module_read(void *opaque, hwaddr addr)
897
static void omap2_gpio_module_write(void *opaque, hwaddr addr,
898
uint32_t value)
899
{
900
- struct omap2_gpio_s *s = (struct omap2_gpio_s *) opaque;
901
+ struct omap2_gpio_s *s = opaque;
902
uint32_t diff;
903
int ln;
904
905
@@ -XXX,XX +XXX,XX @@ static void omap2_gpif_reset(DeviceState *dev)
906
s->gpo = 0;
907
}
908
909
-static uint64_t omap2_gpif_top_read(void *opaque, hwaddr addr,
910
- unsigned size)
911
+static uint64_t omap2_gpif_top_read(void *opaque, hwaddr addr, unsigned size)
912
{
913
- struct omap2_gpif_s *s = (struct omap2_gpif_s *) opaque;
914
+ struct omap2_gpif_s *s = opaque;
915
916
switch (addr) {
917
case 0x00:    /* IPGENERICOCPSPL_REVISION */
918
@@ -XXX,XX +XXX,XX @@ static uint64_t omap2_gpif_top_read(void *opaque, hwaddr addr,
919
static void omap2_gpif_top_write(void *opaque, hwaddr addr,
920
uint64_t value, unsigned size)
921
{
922
- struct omap2_gpif_s *s = (struct omap2_gpif_s *) opaque;
923
+ struct omap2_gpif_s *s = opaque;
924
925
switch (addr) {
926
case 0x00:    /* IPGENERICOCPSPL_REVISION */
927
diff --git a/hw/intc/omap_intc.c b/hw/intc/omap_intc.c
928
index XXXXXXX..XXXXXXX 100644
929
--- a/hw/intc/omap_intc.c
930
+++ b/hw/intc/omap_intc.c
931
@@ -XXX,XX +XXX,XX @@ static inline void omap_inth_update(struct omap_intr_handler_s *s, int is_fiq)
932
933
static void omap_set_intr(void *opaque, int irq, int req)
934
{
935
- struct omap_intr_handler_s *ih = (struct omap_intr_handler_s *) opaque;
936
+ struct omap_intr_handler_s *ih = opaque;
937
uint32_t rise;
938
939
struct omap_intr_handler_bank_s *bank = &ih->bank[irq >> 5];
940
@@ -XXX,XX +XXX,XX @@ static void omap_set_intr(void *opaque, int irq, int req)
941
/* Simplified version with no edge detection */
942
static void omap_set_intr_noedge(void *opaque, int irq, int req)
943
{
944
- struct omap_intr_handler_s *ih = (struct omap_intr_handler_s *) opaque;
945
+ struct omap_intr_handler_s *ih = opaque;
946
uint32_t rise;
947
948
struct omap_intr_handler_bank_s *bank = &ih->bank[irq >> 5];
949
@@ -XXX,XX +XXX,XX @@ static void omap_set_intr_noedge(void *opaque, int irq, int req)
950
static uint64_t omap_inth_read(void *opaque, hwaddr addr,
951
unsigned size)
952
{
953
- struct omap_intr_handler_s *s = (struct omap_intr_handler_s *) opaque;
954
+ struct omap_intr_handler_s *s = opaque;
955
int i, offset = addr;
956
int bank_no = offset >> 8;
957
int line_no;
958
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_inth_read(void *opaque, hwaddr addr,
959
static void omap_inth_write(void *opaque, hwaddr addr,
960
uint64_t value, unsigned size)
961
{
962
- struct omap_intr_handler_s *s = (struct omap_intr_handler_s *) opaque;
963
+ struct omap_intr_handler_s *s = opaque;
964
int i, offset = addr;
965
int bank_no = offset >> 8;
966
struct omap_intr_handler_bank_s *bank = &s->bank[bank_no];
967
@@ -XXX,XX +XXX,XX @@ static const TypeInfo omap_intc_info = {
968
static uint64_t omap2_inth_read(void *opaque, hwaddr addr,
969
unsigned size)
970
{
971
- struct omap_intr_handler_s *s = (struct omap_intr_handler_s *) opaque;
972
+ struct omap_intr_handler_s *s = opaque;
973
int offset = addr;
974
int bank_no, line_no;
975
struct omap_intr_handler_bank_s *bank = NULL;
976
@@ -XXX,XX +XXX,XX @@ static uint64_t omap2_inth_read(void *opaque, hwaddr addr,
977
static void omap2_inth_write(void *opaque, hwaddr addr,
978
uint64_t value, unsigned size)
979
{
980
- struct omap_intr_handler_s *s = (struct omap_intr_handler_s *) opaque;
981
+ struct omap_intr_handler_s *s = opaque;
982
int offset = addr;
983
int bank_no, line_no;
984
struct omap_intr_handler_bank_s *bank = NULL;
985
diff --git a/hw/misc/omap_gpmc.c b/hw/misc/omap_gpmc.c
986
index XXXXXXX..XXXXXXX 100644
987
--- a/hw/misc/omap_gpmc.c
988
+++ b/hw/misc/omap_gpmc.c
989
@@ -XXX,XX +XXX,XX @@ static void omap_gpmc_dma_update(struct omap_gpmc_s *s, int value)
990
static uint64_t omap_nand_read(void *opaque, hwaddr addr,
991
unsigned size)
992
{
993
- struct omap_gpmc_cs_file_s *f = (struct omap_gpmc_cs_file_s *)opaque;
994
+ struct omap_gpmc_cs_file_s *f = opaque;
995
uint64_t v;
996
nand_setpins(f->dev, 0, 0, 0, 1, 0);
997
switch (omap_gpmc_devsize(f)) {
998
@@ -XXX,XX +XXX,XX @@ static void omap_nand_setio(DeviceState *dev, uint64_t value,
999
static void omap_nand_write(void *opaque, hwaddr addr,
1000
uint64_t value, unsigned size)
1001
{
1002
- struct omap_gpmc_cs_file_s *f = (struct omap_gpmc_cs_file_s *)opaque;
1003
+ struct omap_gpmc_cs_file_s *f = opaque;
1004
nand_setpins(f->dev, 0, 0, 0, 1, 0);
1005
omap_nand_setio(f->dev, value, omap_gpmc_devsize(f), size);
1006
}
1007
@@ -XXX,XX +XXX,XX @@ static void fill_prefetch_fifo(struct omap_gpmc_s *s)
1008
static uint64_t omap_gpmc_prefetch_read(void *opaque, hwaddr addr,
1009
unsigned size)
1010
{
1011
- struct omap_gpmc_s *s = (struct omap_gpmc_s *) opaque;
1012
+ struct omap_gpmc_s *s = opaque;
1013
uint32_t data;
1014
if (s->prefetch.config1 & 1) {
1015
/* The TRM doesn't define the behaviour if you read from the
1016
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_gpmc_prefetch_read(void *opaque, hwaddr addr,
1017
static void omap_gpmc_prefetch_write(void *opaque, hwaddr addr,
1018
uint64_t value, unsigned size)
1019
{
1020
- struct omap_gpmc_s *s = (struct omap_gpmc_s *) opaque;
1021
+ struct omap_gpmc_s *s = opaque;
1022
int cs = prefetch_cs(s->prefetch.config1);
1023
if ((s->prefetch.config1 & 1) == 0) {
1024
/* The TRM doesn't define the behaviour of writing to the
1025
@@ -XXX,XX +XXX,XX @@ static int gpmc_wordaccess_only(hwaddr addr)
1026
static uint64_t omap_gpmc_read(void *opaque, hwaddr addr,
1027
unsigned size)
1028
{
1029
- struct omap_gpmc_s *s = (struct omap_gpmc_s *) opaque;
1030
+ struct omap_gpmc_s *s = opaque;
1031
int cs;
1032
struct omap_gpmc_cs_file_s *f;
1033
1034
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_gpmc_read(void *opaque, hwaddr addr,
1035
static void omap_gpmc_write(void *opaque, hwaddr addr,
1036
uint64_t value, unsigned size)
1037
{
1038
- struct omap_gpmc_s *s = (struct omap_gpmc_s *) opaque;
1039
+ struct omap_gpmc_s *s = opaque;
1040
int cs;
1041
struct omap_gpmc_cs_file_s *f;
1042
1043
diff --git a/hw/misc/omap_l4.c b/hw/misc/omap_l4.c
1044
index XXXXXXX..XXXXXXX 100644
1045
--- a/hw/misc/omap_l4.c
1046
+++ b/hw/misc/omap_l4.c
1047
@@ -XXX,XX +XXX,XX @@ hwaddr omap_l4_region_size(struct omap_target_agent_s *ta,
1048
return ta->start[region].size;
1049
}
1050
1051
-static uint64_t omap_l4ta_read(void *opaque, hwaddr addr,
1052
- unsigned size)
1053
+static uint64_t omap_l4ta_read(void *opaque, hwaddr addr, unsigned size)
1054
{
1055
- struct omap_target_agent_s *s = (struct omap_target_agent_s *) opaque;
1056
+ struct omap_target_agent_s *s = opaque;
1057
1058
if (size != 2) {
1059
return omap_badwidth_read16(opaque, addr);
1060
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_l4ta_read(void *opaque, hwaddr addr,
1061
static void omap_l4ta_write(void *opaque, hwaddr addr,
1062
uint64_t value, unsigned size)
1063
{
1064
- struct omap_target_agent_s *s = (struct omap_target_agent_s *) opaque;
1065
+ struct omap_target_agent_s *s = opaque;
1066
1067
if (size != 4) {
1068
omap_badwidth_write32(opaque, addr, value);
1069
diff --git a/hw/misc/omap_sdrc.c b/hw/misc/omap_sdrc.c
1070
index XXXXXXX..XXXXXXX 100644
1071
--- a/hw/misc/omap_sdrc.c
1072
+++ b/hw/misc/omap_sdrc.c
1073
@@ -XXX,XX +XXX,XX @@ void omap_sdrc_reset(struct omap_sdrc_s *s)
1074
s->config = 0x10;
1075
}
1076
1077
-static uint64_t omap_sdrc_read(void *opaque, hwaddr addr,
1078
- unsigned size)
1079
+static uint64_t omap_sdrc_read(void *opaque, hwaddr addr, unsigned size)
1080
{
1081
- struct omap_sdrc_s *s = (struct omap_sdrc_s *) opaque;
1082
+ struct omap_sdrc_s *s = opaque;
1083
1084
if (size != 4) {
1085
return omap_badwidth_read32(opaque, addr);
1086
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_sdrc_read(void *opaque, hwaddr addr,
1087
static void omap_sdrc_write(void *opaque, hwaddr addr,
1088
uint64_t value, unsigned size)
1089
{
1090
- struct omap_sdrc_s *s = (struct omap_sdrc_s *) opaque;
1091
+ struct omap_sdrc_s *s = opaque;
1092
1093
if (size != 4) {
1094
omap_badwidth_write32(opaque, addr, value);
1095
diff --git a/hw/misc/omap_tap.c b/hw/misc/omap_tap.c
1096
index XXXXXXX..XXXXXXX 100644
1097
--- a/hw/misc/omap_tap.c
1098
+++ b/hw/misc/omap_tap.c
1099
@@ -XXX,XX +XXX,XX @@
1100
#include "hw/arm/omap.h"
1101
1102
/* TEST-Chip-level TAP */
1103
-static uint64_t omap_tap_read(void *opaque, hwaddr addr,
1104
- unsigned size)
1105
+static uint64_t omap_tap_read(void *opaque, hwaddr addr, unsigned size)
1106
{
1107
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
1108
+ struct omap_mpu_state_s *s = opaque;
1109
1110
if (size != 4) {
1111
return omap_badwidth_read32(opaque, addr);
1112
diff --git a/hw/sd/omap_mmc.c b/hw/sd/omap_mmc.c
1113
index XXXXXXX..XXXXXXX 100644
1114
--- a/hw/sd/omap_mmc.c
1115
+++ b/hw/sd/omap_mmc.c
1116
@@ -XXX,XX +XXX,XX @@ void omap_mmc_reset(struct omap_mmc_s *host)
1117
device_cold_reset(DEVICE(host->card));
1118
}
1119
1120
-static uint64_t omap_mmc_read(void *opaque, hwaddr offset,
1121
- unsigned size)
1122
+static uint64_t omap_mmc_read(void *opaque, hwaddr offset, unsigned size)
1123
{
1124
uint16_t i;
1125
- struct omap_mmc_s *s = (struct omap_mmc_s *) opaque;
1126
+ struct omap_mmc_s *s = opaque;
1127
1128
if (size != 2) {
1129
return omap_badwidth_read16(opaque, offset);
1130
@@ -XXX,XX +XXX,XX @@ static void omap_mmc_write(void *opaque, hwaddr offset,
1131
uint64_t value, unsigned size)
1132
{
1133
int i;
1134
- struct omap_mmc_s *s = (struct omap_mmc_s *) opaque;
1135
+ struct omap_mmc_s *s = opaque;
1136
1137
if (size != 2) {
1138
omap_badwidth_write16(opaque, offset, value);
1139
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap_mmc_ops = {
1140
1141
static void omap_mmc_cover_cb(void *opaque, int line, int level)
1142
{
1143
- struct omap_mmc_s *host = (struct omap_mmc_s *) opaque;
1144
+ struct omap_mmc_s *host = opaque;
1145
1146
if (!host->cdet_state && level) {
1147
host->status |= 0x0002;
1148
diff --git a/hw/ssi/omap_spi.c b/hw/ssi/omap_spi.c
1149
index XXXXXXX..XXXXXXX 100644
1150
--- a/hw/ssi/omap_spi.c
1151
+++ b/hw/ssi/omap_spi.c
1152
@@ -XXX,XX +XXX,XX @@ void omap_mcspi_reset(struct omap_mcspi_s *s)
1153
omap_mcspi_interrupt_update(s);
1154
}
1155
1156
-static uint64_t omap_mcspi_read(void *opaque, hwaddr addr,
1157
- unsigned size)
1158
+static uint64_t omap_mcspi_read(void *opaque, hwaddr addr, unsigned size)
1159
{
1160
- struct omap_mcspi_s *s = (struct omap_mcspi_s *) opaque;
1161
+ struct omap_mcspi_s *s = opaque;
1162
int ch = 0;
1163
uint32_t ret;
1164
1165
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_mcspi_read(void *opaque, hwaddr addr,
1166
static void omap_mcspi_write(void *opaque, hwaddr addr,
1167
uint64_t value, unsigned size)
1168
{
1169
- struct omap_mcspi_s *s = (struct omap_mcspi_s *) opaque;
1170
+ struct omap_mcspi_s *s = opaque;
1171
int ch = 0;
1172
1173
if (size != 4) {
1174
diff --git a/hw/timer/omap_gptimer.c b/hw/timer/omap_gptimer.c
1175
index XXXXXXX..XXXXXXX 100644
1176
--- a/hw/timer/omap_gptimer.c
1177
+++ b/hw/timer/omap_gptimer.c
1178
@@ -XXX,XX +XXX,XX @@ static inline void omap_gp_timer_trigger(struct omap_gp_timer_s *timer)
1179
1180
static void omap_gp_timer_tick(void *opaque)
1181
{
1182
- struct omap_gp_timer_s *timer = (struct omap_gp_timer_s *) opaque;
1183
+ struct omap_gp_timer_s *timer = opaque;
1184
1185
if (!timer->ar) {
1186
timer->st = 0;
1187
@@ -XXX,XX +XXX,XX @@ static void omap_gp_timer_tick(void *opaque)
1188
1189
static void omap_gp_timer_match(void *opaque)
1190
{
1191
- struct omap_gp_timer_s *timer = (struct omap_gp_timer_s *) opaque;
1192
+ struct omap_gp_timer_s *timer = opaque;
1193
1194
if (timer->trigger == gpt_trigger_both)
1195
omap_gp_timer_trigger(timer);
1196
@@ -XXX,XX +XXX,XX @@ static void omap_gp_timer_match(void *opaque)
1197
1198
static void omap_gp_timer_input(void *opaque, int line, int on)
1199
{
1200
- struct omap_gp_timer_s *s = (struct omap_gp_timer_s *) opaque;
1201
+ struct omap_gp_timer_s *s = opaque;
1202
int trigger;
1203
1204
switch (s->capture) {
1205
@@ -XXX,XX +XXX,XX @@ static void omap_gp_timer_input(void *opaque, int line, int on)
1206
1207
static void omap_gp_timer_clk_update(void *opaque, int line, int on)
1208
{
1209
- struct omap_gp_timer_s *timer = (struct omap_gp_timer_s *) opaque;
1210
+ struct omap_gp_timer_s *timer = opaque;
1211
1212
omap_gp_timer_sync(timer);
1213
timer->rate = on ? omap_clk_getrate(timer->clk) : 0;
1214
@@ -XXX,XX +XXX,XX @@ void omap_gp_timer_reset(struct omap_gp_timer_s *s)
1215
1216
static uint32_t omap_gp_timer_readw(void *opaque, hwaddr addr)
1217
{
1218
- struct omap_gp_timer_s *s = (struct omap_gp_timer_s *) opaque;
1219
+ struct omap_gp_timer_s *s = opaque;
1220
1221
switch (addr) {
1222
case 0x00:    /* TIDR */
1223
@@ -XXX,XX +XXX,XX @@ static uint32_t omap_gp_timer_readw(void *opaque, hwaddr addr)
1224
1225
static uint32_t omap_gp_timer_readh(void *opaque, hwaddr addr)
1226
{
1227
- struct omap_gp_timer_s *s = (struct omap_gp_timer_s *) opaque;
1228
+ struct omap_gp_timer_s *s = opaque;
1229
uint32_t ret;
1230
1231
if (addr & 2)
1232
@@ -XXX,XX +XXX,XX @@ static uint32_t omap_gp_timer_readh(void *opaque, hwaddr addr)
1233
}
1234
}
1235
1236
-static void omap_gp_timer_write(void *opaque, hwaddr addr,
1237
- uint32_t value)
1238
+static void omap_gp_timer_write(void *opaque, hwaddr addr, uint32_t value)
1239
{
1240
- struct omap_gp_timer_s *s = (struct omap_gp_timer_s *) opaque;
1241
+ struct omap_gp_timer_s *s = opaque;
1242
1243
switch (addr) {
1244
case 0x00:    /* TIDR */
1245
@@ -XXX,XX +XXX,XX @@ static void omap_gp_timer_write(void *opaque, hwaddr addr,
1246
}
1247
}
1248
1249
-static void omap_gp_timer_writeh(void *opaque, hwaddr addr,
1250
- uint32_t value)
1251
+static void omap_gp_timer_writeh(void *opaque, hwaddr addr, uint32_t value)
1252
{
1253
- struct omap_gp_timer_s *s = (struct omap_gp_timer_s *) opaque;
1254
+ struct omap_gp_timer_s *s = opaque;
1255
1256
if (addr & 2)
1257
omap_gp_timer_write(opaque, addr, (value << 16) | s->writeh);
1258
diff --git a/hw/timer/omap_synctimer.c b/hw/timer/omap_synctimer.c
1259
index XXXXXXX..XXXXXXX 100644
1260
--- a/hw/timer/omap_synctimer.c
1261
+++ b/hw/timer/omap_synctimer.c
1262
@@ -XXX,XX +XXX,XX @@ void omap_synctimer_reset(struct omap_synctimer_s *s)
1263
1264
static uint32_t omap_synctimer_readw(void *opaque, hwaddr addr)
1265
{
1266
- struct omap_synctimer_s *s = (struct omap_synctimer_s *) opaque;
1267
+ struct omap_synctimer_s *s = opaque;
1268
1269
switch (addr) {
1270
case 0x00:    /* 32KSYNCNT_REV */
1271
@@ -XXX,XX +XXX,XX @@ static uint32_t omap_synctimer_readw(void *opaque, hwaddr addr)
1272
1273
static uint32_t omap_synctimer_readh(void *opaque, hwaddr addr)
1274
{
1275
- struct omap_synctimer_s *s = (struct omap_synctimer_s *) opaque;
1276
+ struct omap_synctimer_s *s = opaque;
1277
uint32_t ret;
1278
1279
if (addr & 2)
644
--
1280
--
645
2.18.0
1281
2.34.1
646
1282
647
1283
diff view generated by jsdifflib
1
The MPS2 FPGAIO block includes some simple free-running counters.
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
Implement these.
3
2
3
Following docs/devel/style.rst guidelines, rename omap_gpif_s ->
4
Omap1GpioState. This also remove a use of 'struct' in the
5
DECLARE_INSTANCE_CHECKER() macro call.
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230109140306.23161-5-philmd@linaro.org
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20180820141116.9118-2-peter.maydell@linaro.org
7
---
11
---
8
include/hw/misc/mps2-fpgaio.h | 4 +++
12
include/hw/arm/omap.h | 6 +++---
9
hw/misc/mps2-fpgaio.c | 53 ++++++++++++++++++++++++++++++++++-
13
hw/gpio/omap_gpio.c | 16 ++++++++--------
10
2 files changed, 56 insertions(+), 1 deletion(-)
14
2 files changed, 11 insertions(+), 11 deletions(-)
11
15
12
diff --git a/include/hw/misc/mps2-fpgaio.h b/include/hw/misc/mps2-fpgaio.h
16
diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h
13
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
14
--- a/include/hw/misc/mps2-fpgaio.h
18
--- a/include/hw/arm/omap.h
15
+++ b/include/hw/misc/mps2-fpgaio.h
19
+++ b/include/hw/arm/omap.h
16
@@ -XXX,XX +XXX,XX @@ typedef struct {
20
@@ -XXX,XX +XXX,XX @@ void omap_i2c_set_fclk(OMAPI2CState *i2c, omap_clk clk);
17
uint32_t misc;
21
18
22
/* omap_gpio.c */
19
uint32_t prescale_clk;
23
#define TYPE_OMAP1_GPIO "omap-gpio"
20
+
24
-DECLARE_INSTANCE_CHECKER(struct omap_gpif_s, OMAP1_GPIO,
21
+ /* These hold the CLOCK_VIRTUAL ns tick when the CLK1HZ/CLK100HZ was zero */
25
+typedef struct Omap1GpioState Omap1GpioState;
22
+ int64_t clk1hz_tick_offset;
26
+DECLARE_INSTANCE_CHECKER(Omap1GpioState, OMAP1_GPIO,
23
+ int64_t clk100hz_tick_offset;
27
TYPE_OMAP1_GPIO)
24
} MPS2FPGAIO;
28
25
29
#define TYPE_OMAP2_GPIO "omap2-gpio"
26
#endif
30
DECLARE_INSTANCE_CHECKER(struct omap2_gpif_s, OMAP2_GPIO,
27
diff --git a/hw/misc/mps2-fpgaio.c b/hw/misc/mps2-fpgaio.c
31
TYPE_OMAP2_GPIO)
32
33
-typedef struct omap_gpif_s omap_gpif;
34
typedef struct omap2_gpif_s omap2_gpif;
35
36
/* TODO: clock framework (see above) */
37
-void omap_gpio_set_clk(omap_gpif *gpio, omap_clk clk);
38
+void omap_gpio_set_clk(Omap1GpioState *gpio, omap_clk clk);
39
40
void omap2_gpio_set_iclk(omap2_gpif *gpio, omap_clk clk);
41
void omap2_gpio_set_fclk(omap2_gpif *gpio, uint8_t i, omap_clk clk);
42
diff --git a/hw/gpio/omap_gpio.c b/hw/gpio/omap_gpio.c
28
index XXXXXXX..XXXXXXX 100644
43
index XXXXXXX..XXXXXXX 100644
29
--- a/hw/misc/mps2-fpgaio.c
44
--- a/hw/gpio/omap_gpio.c
30
+++ b/hw/misc/mps2-fpgaio.c
45
+++ b/hw/gpio/omap_gpio.c
31
@@ -XXX,XX +XXX,XX @@
46
@@ -XXX,XX +XXX,XX @@ struct omap_gpio_s {
32
#include "hw/sysbus.h"
47
uint16_t pins;
33
#include "hw/registerfields.h"
48
};
34
#include "hw/misc/mps2-fpgaio.h"
49
35
+#include "qemu/timer.h"
50
-struct omap_gpif_s {
36
51
+struct Omap1GpioState {
37
REG32(LED0, 0)
52
SysBusDevice parent_obj;
38
REG32(BUTTON, 8)
53
39
@@ -XXX,XX +XXX,XX @@ REG32(PRESCALE, 0x1c)
54
MemoryRegion iomem;
40
REG32(PSCNTR, 0x20)
55
@@ -XXX,XX +XXX,XX @@ struct omap_gpif_s {
41
REG32(MISC, 0x4c)
56
/* General-Purpose I/O of OMAP1 */
42
57
static void omap_gpio_set(void *opaque, int line, int level)
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
{
58
{
55
MPS2FPGAIO *s = MPS2_FPGAIO(opaque);
59
- struct omap_gpif_s *p = opaque;
56
uint64_t r;
60
+ Omap1GpioState *p = opaque;
57
+ int64_t now;
61
struct omap_gpio_s *s = &p->omap1;
58
62
uint16_t prev = s->inputs;
59
switch (offset) {
63
60
case A_LED0:
64
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap2_gpio_module_ops = {
61
@@ -XXX,XX +XXX,XX @@ static uint64_t mps2_fpgaio_read(void *opaque, hwaddr offset, unsigned size)
65
62
r = s->misc;
66
static void omap_gpif_reset(DeviceState *dev)
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
{
67
{
81
MPS2FPGAIO *s = MPS2_FPGAIO(opaque);
68
- struct omap_gpif_s *s = OMAP1_GPIO(dev);
82
+ int64_t now;
69
+ Omap1GpioState *s = OMAP1_GPIO(dev);
83
70
84
trace_mps2_fpgaio_write(offset, value, size);
71
omap_gpio_reset(&s->omap1);
85
72
}
86
@@ -XXX,XX +XXX,XX @@ static void mps2_fpgaio_write(void *opaque, hwaddr offset, uint64_t value,
73
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap2_gpif_top_ops = {
87
"MPS2 FPGAIO: MISC control bits unimplemented\n");
74
static void omap_gpio_init(Object *obj)
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
{
75
{
104
MPS2FPGAIO *s = MPS2_FPGAIO(dev);
76
DeviceState *dev = DEVICE(obj);
105
+ int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
77
- struct omap_gpif_s *s = OMAP1_GPIO(obj);
106
78
+ Omap1GpioState *s = OMAP1_GPIO(obj);
107
trace_mps2_fpgaio_reset();
79
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
108
s->led0 = 0;
80
109
s->prescale = 0;
81
qdev_init_gpio_in(dev, omap_gpio_set, 16);
110
s->misc = 0;
82
@@ -XXX,XX +XXX,XX @@ static void omap_gpio_init(Object *obj)
111
+ s->clk1hz_tick_offset = tickoff_from_counter(now, 0, 1);
83
112
+ s->clk100hz_tick_offset = tickoff_from_counter(now, 0, 100);
84
static void omap_gpio_realize(DeviceState *dev, Error **errp)
85
{
86
- struct omap_gpif_s *s = OMAP1_GPIO(dev);
87
+ Omap1GpioState *s = OMAP1_GPIO(dev);
88
89
if (!s->clk) {
90
error_setg(errp, "omap-gpio: clk not connected");
91
@@ -XXX,XX +XXX,XX @@ static void omap2_gpio_realize(DeviceState *dev, Error **errp)
92
}
113
}
93
}
114
94
115
static void mps2_fpgaio_init(Object *obj)
95
-void omap_gpio_set_clk(omap_gpif *gpio, omap_clk clk)
116
@@ -XXX,XX +XXX,XX @@ static void mps2_fpgaio_init(Object *obj)
96
+void omap_gpio_set_clk(Omap1GpioState *gpio, omap_clk clk)
117
sysbus_init_mmio(sbd, &s->iomem);
97
{
98
gpio->clk = clk;
118
}
99
}
119
100
120
+static bool mps2_fpgaio_counters_needed(void *opaque)
101
static Property omap_gpio_properties[] = {
121
+{
102
- DEFINE_PROP_INT32("mpu_model", struct omap_gpif_s, mpu_model, 0),
122
+ /* Currently vmstate.c insists all subsections have a 'needed' function */
103
+ DEFINE_PROP_INT32("mpu_model", Omap1GpioState, mpu_model, 0),
123
+ return true;
104
DEFINE_PROP_END_OF_LIST(),
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
};
105
};
151
106
107
@@ -XXX,XX +XXX,XX @@ static void omap_gpio_class_init(ObjectClass *klass, void *data)
108
static const TypeInfo omap_gpio_info = {
109
.name = TYPE_OMAP1_GPIO,
110
.parent = TYPE_SYS_BUS_DEVICE,
111
- .instance_size = sizeof(struct omap_gpif_s),
112
+ .instance_size = sizeof(Omap1GpioState),
113
.instance_init = omap_gpio_init,
114
.class_init = omap_gpio_class_init,
115
};
152
--
116
--
153
2.18.0
117
2.34.1
154
118
155
119
diff view generated by jsdifflib
1
Add a "virtualization" property to the vexpress-a15 board,
1
From: Philippe Mathieu-Daudé <philmd@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
Following docs/devel/style.rst guidelines, rename omap2_gpif_s ->
4
Omap2GpioState. This also remove a use of 'struct' in the
5
DECLARE_INSTANCE_CHECKER() macro call.
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230109140306.23161-6-philmd@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
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
---
11
---
10
hw/arm/vexpress.c | 56 ++++++++++++++++++++++++++++++++++++++++++++---
12
include/hw/arm/omap.h | 9 ++++-----
11
1 file changed, 53 insertions(+), 3 deletions(-)
13
hw/gpio/omap_gpio.c | 20 ++++++++++----------
14
2 files changed, 14 insertions(+), 15 deletions(-)
12
15
13
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
16
diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h
14
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/arm/vexpress.c
18
--- a/include/hw/arm/omap.h
16
+++ b/hw/arm/vexpress.c
19
+++ b/include/hw/arm/omap.h
17
@@ -XXX,XX +XXX,XX @@ typedef struct {
20
@@ -XXX,XX +XXX,XX @@ DECLARE_INSTANCE_CHECKER(Omap1GpioState, OMAP1_GPIO,
18
typedef struct {
21
TYPE_OMAP1_GPIO)
19
MachineState parent;
22
20
bool secure;
23
#define TYPE_OMAP2_GPIO "omap2-gpio"
21
+ bool virt;
24
-DECLARE_INSTANCE_CHECKER(struct omap2_gpif_s, OMAP2_GPIO,
22
} VexpressMachineState;
25
+typedef struct Omap2GpioState Omap2GpioState;
23
26
+DECLARE_INSTANCE_CHECKER(Omap2GpioState, OMAP2_GPIO,
24
#define TYPE_VEXPRESS_MACHINE "vexpress"
27
TYPE_OMAP2_GPIO)
25
@@ -XXX,XX +XXX,XX @@ struct VEDBoardInfo {
28
29
-typedef struct omap2_gpif_s omap2_gpif;
30
-
31
/* TODO: clock framework (see above) */
32
void omap_gpio_set_clk(Omap1GpioState *gpio, omap_clk clk);
33
34
-void omap2_gpio_set_iclk(omap2_gpif *gpio, omap_clk clk);
35
-void omap2_gpio_set_fclk(omap2_gpif *gpio, uint8_t i, omap_clk clk);
36
+void omap2_gpio_set_iclk(Omap2GpioState *gpio, omap_clk clk);
37
+void omap2_gpio_set_fclk(Omap2GpioState *gpio, uint8_t i, omap_clk clk);
38
39
/* OMAP2 l4 Interconnect */
40
struct omap_l4_s;
41
diff --git a/hw/gpio/omap_gpio.c b/hw/gpio/omap_gpio.c
42
index XXXXXXX..XXXXXXX 100644
43
--- a/hw/gpio/omap_gpio.c
44
+++ b/hw/gpio/omap_gpio.c
45
@@ -XXX,XX +XXX,XX @@ struct omap2_gpio_s {
46
uint8_t delay;
26
};
47
};
27
48
28
static void init_cpus(const char *cpu_type, const char *privdev,
49
-struct omap2_gpif_s {
29
- hwaddr periphbase, qemu_irq *pic, bool secure)
50
+struct Omap2GpioState {
30
+ hwaddr periphbase, qemu_irq *pic, bool secure, bool virt)
51
SysBusDevice parent_obj;
52
53
MemoryRegion iomem;
54
@@ -XXX,XX +XXX,XX @@ static inline void omap2_gpio_module_int(struct omap2_gpio_s *s, int line)
55
56
static void omap2_gpio_set(void *opaque, int line, int level)
31
{
57
{
32
DeviceState *dev;
58
- struct omap2_gpif_s *p = opaque;
33
SysBusDevice *busdev;
59
+ Omap2GpioState *p = opaque;
34
@@ -XXX,XX +XXX,XX @@ static void init_cpus(const char *cpu_type, const char *privdev,
60
struct omap2_gpio_s *s = &p->modules[line >> 5];
35
if (!secure) {
61
36
object_property_set_bool(cpuobj, false, "has_el3", NULL);
62
line &= 31;
37
}
63
@@ -XXX,XX +XXX,XX @@ static void omap_gpif_reset(DeviceState *dev)
38
+ if (!virt) {
64
39
+ if (object_property_find(cpuobj, "has_el2", NULL)) {
65
static void omap2_gpif_reset(DeviceState *dev)
40
+ object_property_set_bool(cpuobj, false, "has_el2", NULL);
66
{
41
+ }
67
- struct omap2_gpif_s *s = OMAP2_GPIO(dev);
42
+ }
68
+ Omap2GpioState *s = OMAP2_GPIO(dev);
43
69
int i;
44
if (object_property_find(cpuobj, "reset-cbar", NULL)) {
70
45
object_property_set_int(cpuobj, periphbase,
71
for (i = 0; i < s->modulecount; i++) {
46
@@ -XXX,XX +XXX,XX @@ static void a9_daughterboard_init(const VexpressMachineState *vms,
72
@@ -XXX,XX +XXX,XX @@ static void omap2_gpif_reset(DeviceState *dev)
47
memory_region_add_subregion(sysmem, 0x60000000, ram);
73
48
74
static uint64_t omap2_gpif_top_read(void *opaque, hwaddr addr, unsigned size)
49
/* 0x1e000000 A9MPCore (SCU) private memory region */
75
{
50
- init_cpus(cpu_type, TYPE_A9MPCORE_PRIV, 0x1e000000, pic, vms->secure);
76
- struct omap2_gpif_s *s = opaque;
51
+ init_cpus(cpu_type, TYPE_A9MPCORE_PRIV, 0x1e000000, pic,
77
+ Omap2GpioState *s = opaque;
52
+ vms->secure, vms->virt);
78
53
79
switch (addr) {
54
/* Daughterboard peripherals : 0x10020000 .. 0x20000000 */
80
case 0x00:    /* IPGENERICOCPSPL_REVISION */
55
81
@@ -XXX,XX +XXX,XX @@ static uint64_t omap2_gpif_top_read(void *opaque, hwaddr addr, unsigned size)
56
@@ -XXX,XX +XXX,XX @@ static void a15_daughterboard_init(const VexpressMachineState *vms,
82
static void omap2_gpif_top_write(void *opaque, hwaddr addr,
57
memory_region_add_subregion(sysmem, 0x80000000, ram);
83
uint64_t value, unsigned size)
58
84
{
59
/* 0x2c000000 A15MPCore private memory region (GIC) */
85
- struct omap2_gpif_s *s = opaque;
60
- init_cpus(cpu_type, TYPE_A15MPCORE_PRIV, 0x2c000000, pic, vms->secure);
86
+ Omap2GpioState *s = opaque;
61
+ init_cpus(cpu_type, TYPE_A15MPCORE_PRIV, 0x2c000000, pic, vms->secure,
87
62
+ vms->virt);
88
switch (addr) {
63
89
case 0x00:    /* IPGENERICOCPSPL_REVISION */
64
/* A15 daughterboard peripherals: */
90
@@ -XXX,XX +XXX,XX @@ static void omap_gpio_realize(DeviceState *dev, Error **errp)
65
91
66
@@ -XXX,XX +XXX,XX @@ static void vexpress_set_secure(Object *obj, bool value, Error **errp)
92
static void omap2_gpio_realize(DeviceState *dev, Error **errp)
67
vms->secure = value;
93
{
94
- struct omap2_gpif_s *s = OMAP2_GPIO(dev);
95
+ Omap2GpioState *s = OMAP2_GPIO(dev);
96
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
97
int i;
98
99
@@ -XXX,XX +XXX,XX @@ static const TypeInfo omap_gpio_info = {
100
.class_init = omap_gpio_class_init,
101
};
102
103
-void omap2_gpio_set_iclk(omap2_gpif *gpio, omap_clk clk)
104
+void omap2_gpio_set_iclk(Omap2GpioState *gpio, omap_clk clk)
105
{
106
gpio->iclk = clk;
68
}
107
}
69
108
70
+static bool vexpress_get_virt(Object *obj, Error **errp)
109
-void omap2_gpio_set_fclk(omap2_gpif *gpio, uint8_t i, omap_clk clk)
71
+{
110
+void omap2_gpio_set_fclk(Omap2GpioState *gpio, uint8_t i, omap_clk clk)
72
+ VexpressMachineState *vms = VEXPRESS_MACHINE(obj);
73
+
74
+ return vms->virt;
75
+}
76
+
77
+static void vexpress_set_virt(Object *obj, bool value, Error **errp)
78
+{
79
+ VexpressMachineState *vms = VEXPRESS_MACHINE(obj);
80
+
81
+ vms->virt = value;
82
+}
83
+
84
static void vexpress_instance_init(Object *obj)
85
{
111
{
86
VexpressMachineState *vms = VEXPRESS_MACHINE(obj);
112
assert(i <= 5);
87
@@ -XXX,XX +XXX,XX @@ static void vexpress_instance_init(Object *obj)
113
gpio->fclk[i] = clk;
88
NULL);
89
}
114
}
90
115
91
+static void vexpress_a15_instance_init(Object *obj)
116
static Property omap2_gpio_properties[] = {
92
+{
117
- DEFINE_PROP_INT32("mpu_model", struct omap2_gpif_s, mpu_model, 0),
93
+ VexpressMachineState *vms = VEXPRESS_MACHINE(obj);
118
+ DEFINE_PROP_INT32("mpu_model", Omap2GpioState, mpu_model, 0),
94
+
119
DEFINE_PROP_END_OF_LIST(),
95
+ /*
96
+ * For the vexpress-a15, EL2 is by default enabled if EL3 is,
97
+ * but can also be specifically set to on or off.
98
+ */
99
+ vms->virt = true;
100
+ object_property_add_bool(obj, "virtualization", vexpress_get_virt,
101
+ vexpress_set_virt, NULL);
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
};
120
};
126
121
127
static const TypeInfo vexpress_a15_info = {
122
@@ -XXX,XX +XXX,XX @@ static void omap2_gpio_class_init(ObjectClass *klass, void *data)
128
.name = TYPE_VEXPRESS_A15_MACHINE,
123
static const TypeInfo omap2_gpio_info = {
129
.parent = TYPE_VEXPRESS_MACHINE,
124
.name = TYPE_OMAP2_GPIO,
130
.class_init = vexpress_a15_class_init,
125
.parent = TYPE_SYS_BUS_DEVICE,
131
+ .instance_init = vexpress_a15_instance_init,
126
- .instance_size = sizeof(struct omap2_gpif_s),
127
+ .instance_size = sizeof(Omap2GpioState),
128
.class_init = omap2_gpio_class_init,
132
};
129
};
133
130
134
static void vexpress_machine_init(void)
135
--
131
--
136
2.18.0
132
2.34.1
137
133
138
134
diff view generated by jsdifflib
1
Currently the PL022 calls pl022_reset() from its class init
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
function. Make it register a DeviceState reset method instead,
2
3
so that we reset the device on system reset.
3
Following docs/devel/style.rst guidelines, rename
4
4
omap_intr_handler_s -> OMAPIntcState. This also remove a
5
use of 'struct' in the DECLARE_INSTANCE_CHECKER() macro call.
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230109140306.23161-7-philmd@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: 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
---
11
---
10
hw/ssi/pl022.c | 7 +++++--
12
include/hw/arm/omap.h | 9 ++++-----
11
1 file changed, 5 insertions(+), 2 deletions(-)
13
hw/intc/omap_intc.c | 38 +++++++++++++++++++-------------------
12
14
2 files changed, 23 insertions(+), 24 deletions(-)
13
diff --git a/hw/ssi/pl022.c b/hw/ssi/pl022.c
15
16
diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h
14
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/ssi/pl022.c
18
--- a/include/hw/arm/omap.h
16
+++ b/hw/ssi/pl022.c
19
+++ b/include/hw/arm/omap.h
17
@@ -XXX,XX +XXX,XX @@ static void pl022_write(void *opaque, hwaddr offset,
20
@@ -XXX,XX +XXX,XX @@ void omap_clk_reparent(omap_clk clk, omap_clk parent);
21
22
/* omap_intc.c */
23
#define TYPE_OMAP_INTC "common-omap-intc"
24
-typedef struct omap_intr_handler_s omap_intr_handler;
25
-DECLARE_INSTANCE_CHECKER(omap_intr_handler, OMAP_INTC,
26
- TYPE_OMAP_INTC)
27
+typedef struct OMAPIntcState OMAPIntcState;
28
+DECLARE_INSTANCE_CHECKER(OMAPIntcState, OMAP_INTC, TYPE_OMAP_INTC)
29
30
31
/*
32
@@ -XXX,XX +XXX,XX @@ DECLARE_INSTANCE_CHECKER(omap_intr_handler, OMAP_INTC,
33
* (ie the struct omap_mpu_state_s*) to do the clockname to pointer
34
* translation.)
35
*/
36
-void omap_intc_set_iclk(omap_intr_handler *intc, omap_clk clk);
37
-void omap_intc_set_fclk(omap_intr_handler *intc, omap_clk clk);
38
+void omap_intc_set_iclk(OMAPIntcState *intc, omap_clk clk);
39
+void omap_intc_set_fclk(OMAPIntcState *intc, omap_clk clk);
40
41
/* omap_i2c.c */
42
#define TYPE_OMAP_I2C "omap_i2c"
43
diff --git a/hw/intc/omap_intc.c b/hw/intc/omap_intc.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/hw/intc/omap_intc.c
46
+++ b/hw/intc/omap_intc.c
47
@@ -XXX,XX +XXX,XX @@ struct omap_intr_handler_bank_s {
48
unsigned char priority[32];
49
};
50
51
-struct omap_intr_handler_s {
52
+struct OMAPIntcState {
53
SysBusDevice parent_obj;
54
55
qemu_irq *pins;
56
@@ -XXX,XX +XXX,XX @@ struct omap_intr_handler_s {
57
struct omap_intr_handler_bank_s bank[3];
58
};
59
60
-static void omap_inth_sir_update(struct omap_intr_handler_s *s, int is_fiq)
61
+static void omap_inth_sir_update(OMAPIntcState *s, int is_fiq)
62
{
63
int i, j, sir_intr, p_intr, p;
64
uint32_t level;
65
@@ -XXX,XX +XXX,XX @@ static void omap_inth_sir_update(struct omap_intr_handler_s *s, int is_fiq)
66
s->sir_intr[is_fiq] = sir_intr;
67
}
68
69
-static inline void omap_inth_update(struct omap_intr_handler_s *s, int is_fiq)
70
+static inline void omap_inth_update(OMAPIntcState *s, int is_fiq)
71
{
72
int i;
73
uint32_t has_intr = 0;
74
@@ -XXX,XX +XXX,XX @@ static inline void omap_inth_update(struct omap_intr_handler_s *s, int is_fiq)
75
76
static void omap_set_intr(void *opaque, int irq, int req)
77
{
78
- struct omap_intr_handler_s *ih = opaque;
79
+ OMAPIntcState *ih = opaque;
80
uint32_t rise;
81
82
struct omap_intr_handler_bank_s *bank = &ih->bank[irq >> 5];
83
@@ -XXX,XX +XXX,XX @@ static void omap_set_intr(void *opaque, int irq, int req)
84
/* Simplified version with no edge detection */
85
static void omap_set_intr_noedge(void *opaque, int irq, int req)
86
{
87
- struct omap_intr_handler_s *ih = opaque;
88
+ OMAPIntcState *ih = opaque;
89
uint32_t rise;
90
91
struct omap_intr_handler_bank_s *bank = &ih->bank[irq >> 5];
92
@@ -XXX,XX +XXX,XX @@ static void omap_set_intr_noedge(void *opaque, int irq, int req)
93
static uint64_t omap_inth_read(void *opaque, hwaddr addr,
94
unsigned size)
95
{
96
- struct omap_intr_handler_s *s = opaque;
97
+ OMAPIntcState *s = opaque;
98
int i, offset = addr;
99
int bank_no = offset >> 8;
100
int line_no;
101
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_inth_read(void *opaque, hwaddr addr,
102
static void omap_inth_write(void *opaque, hwaddr addr,
103
uint64_t value, unsigned size)
104
{
105
- struct omap_intr_handler_s *s = opaque;
106
+ OMAPIntcState *s = opaque;
107
int i, offset = addr;
108
int bank_no = offset >> 8;
109
struct omap_intr_handler_bank_s *bank = &s->bank[bank_no];
110
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap_inth_mem_ops = {
111
112
static void omap_inth_reset(DeviceState *dev)
113
{
114
- struct omap_intr_handler_s *s = OMAP_INTC(dev);
115
+ OMAPIntcState *s = OMAP_INTC(dev);
116
int i;
117
118
for (i = 0; i < s->nbanks; ++i){
119
@@ -XXX,XX +XXX,XX @@ static void omap_inth_reset(DeviceState *dev)
120
static void omap_intc_init(Object *obj)
121
{
122
DeviceState *dev = DEVICE(obj);
123
- struct omap_intr_handler_s *s = OMAP_INTC(obj);
124
+ OMAPIntcState *s = OMAP_INTC(obj);
125
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
126
127
s->nbanks = 1;
128
@@ -XXX,XX +XXX,XX @@ static void omap_intc_init(Object *obj)
129
130
static void omap_intc_realize(DeviceState *dev, Error **errp)
131
{
132
- struct omap_intr_handler_s *s = OMAP_INTC(dev);
133
+ OMAPIntcState *s = OMAP_INTC(dev);
134
135
if (!s->iclk) {
136
error_setg(errp, "omap-intc: clk not connected");
18
}
137
}
19
}
138
}
20
139
21
-static void pl022_reset(PL022State *s)
140
-void omap_intc_set_iclk(omap_intr_handler *intc, omap_clk clk)
22
+static void pl022_reset(DeviceState *dev)
141
+void omap_intc_set_iclk(OMAPIntcState *intc, omap_clk clk)
23
{
142
{
24
+ PL022State *s = PL022(dev);
143
intc->iclk = clk;
25
+
144
}
26
s->rx_fifo_len = 0;
145
27
s->tx_fifo_len = 0;
146
-void omap_intc_set_fclk(omap_intr_handler *intc, omap_clk clk)
28
s->im = 0;
147
+void omap_intc_set_fclk(OMAPIntcState *intc, omap_clk clk)
29
@@ -XXX,XX +XXX,XX @@ static int pl022_init(SysBusDevice *sbd)
148
{
30
sysbus_init_mmio(sbd, &s->iomem);
149
intc->fclk = clk;
31
sysbus_init_irq(sbd, &s->irq);
150
}
32
s->ssi = ssi_create_bus(dev, "ssi");
151
33
- pl022_reset(s);
152
static Property omap_intc_properties[] = {
34
vmstate_register(dev, -1, &vmstate_pl022, s);
153
- DEFINE_PROP_UINT32("size", struct omap_intr_handler_s, size, 0x100),
35
return 0;
154
+ DEFINE_PROP_UINT32("size", OMAPIntcState, size, 0x100),
36
}
155
DEFINE_PROP_END_OF_LIST(),
37
@@ -XXX,XX +XXX,XX @@ static int pl022_init(SysBusDevice *sbd)
156
};
38
static void pl022_class_init(ObjectClass *klass, void *data)
157
39
{
158
@@ -XXX,XX +XXX,XX @@ static const TypeInfo omap_intc_info = {
40
SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
159
static uint64_t omap2_inth_read(void *opaque, hwaddr addr,
41
+ DeviceClass *dc = DEVICE_CLASS(klass);
160
unsigned size)
42
161
{
43
sdc->init = pl022_init;
162
- struct omap_intr_handler_s *s = opaque;
44
+ dc->reset = pl022_reset;
163
+ OMAPIntcState *s = opaque;
45
}
164
int offset = addr;
46
165
int bank_no, line_no;
47
static const TypeInfo pl022_info = {
166
struct omap_intr_handler_bank_s *bank = NULL;
167
@@ -XXX,XX +XXX,XX @@ static uint64_t omap2_inth_read(void *opaque, hwaddr addr,
168
static void omap2_inth_write(void *opaque, hwaddr addr,
169
uint64_t value, unsigned size)
170
{
171
- struct omap_intr_handler_s *s = opaque;
172
+ OMAPIntcState *s = opaque;
173
int offset = addr;
174
int bank_no, line_no;
175
struct omap_intr_handler_bank_s *bank = NULL;
176
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap2_inth_mem_ops = {
177
static void omap2_intc_init(Object *obj)
178
{
179
DeviceState *dev = DEVICE(obj);
180
- struct omap_intr_handler_s *s = OMAP_INTC(obj);
181
+ OMAPIntcState *s = OMAP_INTC(obj);
182
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
183
184
s->level_only = 1;
185
@@ -XXX,XX +XXX,XX @@ static void omap2_intc_init(Object *obj)
186
187
static void omap2_intc_realize(DeviceState *dev, Error **errp)
188
{
189
- struct omap_intr_handler_s *s = OMAP_INTC(dev);
190
+ OMAPIntcState *s = OMAP_INTC(dev);
191
192
if (!s->iclk) {
193
error_setg(errp, "omap2-intc: iclk not connected");
194
@@ -XXX,XX +XXX,XX @@ static void omap2_intc_realize(DeviceState *dev, Error **errp)
195
}
196
197
static Property omap2_intc_properties[] = {
198
- DEFINE_PROP_UINT8("revision", struct omap_intr_handler_s,
199
+ DEFINE_PROP_UINT8("revision", OMAPIntcState,
200
revision, 0x21),
201
DEFINE_PROP_END_OF_LIST(),
202
};
203
@@ -XXX,XX +XXX,XX @@ static const TypeInfo omap2_intc_info = {
204
static const TypeInfo omap_intc_type_info = {
205
.name = TYPE_OMAP_INTC,
206
.parent = TYPE_SYS_BUS_DEVICE,
207
- .instance_size = sizeof(omap_intr_handler),
208
+ .instance_size = sizeof(OMAPIntcState),
209
.abstract = true,
210
};
211
48
--
212
--
49
2.18.0
213
2.34.1
50
214
51
215
diff view generated by jsdifflib
1
Refactor the fb property setting code so that rather than
1
From: Philippe Mathieu-Daudé <philmd@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
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20230109140306.23161-8-philmd@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
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
---
7
---
13
include/hw/display/bcm2835_fb.h | 4 +-
8
hw/arm/stellaris.c | 6 +++---
14
hw/display/bcm2835_fb.c | 27 ++---------
9
1 file changed, 3 insertions(+), 3 deletions(-)
15
hw/misc/bcm2835_property.c | 80 ++++++++++++++-------------------
16
3 files changed, 37 insertions(+), 74 deletions(-)
17
10
18
diff --git a/include/hw/display/bcm2835_fb.h b/include/hw/display/bcm2835_fb.h
11
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
19
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
20
--- a/include/hw/display/bcm2835_fb.h
13
--- a/hw/arm/stellaris.c
21
+++ b/include/hw/display/bcm2835_fb.h
14
+++ b/hw/arm/stellaris.c
22
@@ -XXX,XX +XXX,XX @@ typedef struct {
15
@@ -XXX,XX +XXX,XX @@ static void stellaris_adc_update(stellaris_adc_state *s)
23
uint32_t pitch;
16
24
} BCM2835FBState;
17
static void stellaris_adc_trigger(void *opaque, int irq, int level)
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
}
39
40
-void bcm2835_fb_reconfigure(BCM2835FBState *s, uint32_t *xres, uint32_t *yres,
41
- uint32_t *xoffset, uint32_t *yoffset, uint32_t *bpp,
42
- uint32_t *pixo, uint32_t *alpha)
43
+void bcm2835_fb_reconfigure(BCM2835FBState *s, BCM2835FBConfig *newconfig)
44
{
18
{
45
s->lock = true;
19
- stellaris_adc_state *s = (stellaris_adc_state *)opaque;
46
20
+ stellaris_adc_state *s = opaque;
47
/* TODO: input validation! */
48
- if (xres) {
49
- s->config.xres = *xres;
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;
21
int n;
81
uint32_t offset, length, color;
22
82
- uint32_t xres, yres, xoffset, yoffset, bpp, pixo, alpha;
23
for (n = 0; n < 4; n++) {
83
- uint32_t tmp_xres, tmp_yres, tmp_xoffset, tmp_yoffset;
24
@@ -XXX,XX +XXX,XX @@ static void stellaris_adc_reset(stellaris_adc_state *s)
84
- uint32_t tmp_bpp, tmp_pixo, tmp_alpha;
25
static uint64_t stellaris_adc_read(void *opaque, hwaddr offset,
85
- uint32_t *newxres = NULL, *newyres = NULL, *newxoffset = NULL,
26
unsigned size)
86
- *newyoffset = NULL, *newbpp = NULL, *newpixo = NULL, *newalpha = NULL;
27
{
87
+
28
- stellaris_adc_state *s = (stellaris_adc_state *)opaque;
88
+ /*
29
+ stellaris_adc_state *s = opaque;
89
+ * Copy the current state of the framebuffer config; we will update
30
90
+ * this copy as we process tags and then ask the framebuffer to use
31
/* TODO: Implement this. */
91
+ * it at the end.
32
if (offset >= 0x40 && offset < 0xc0) {
92
+ */
33
@@ -XXX,XX +XXX,XX @@ static uint64_t stellaris_adc_read(void *opaque, hwaddr offset,
93
+ BCM2835FBConfig fbconfig = s->fbdev->config;
34
static void stellaris_adc_write(void *opaque, hwaddr offset,
94
+ bool fbconfig_updated = false;
35
uint64_t value, unsigned size)
95
36
{
96
value &= ~0xf;
37
- stellaris_adc_state *s = (stellaris_adc_state *)opaque;
97
38
+ stellaris_adc_state *s = opaque;
98
@@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value)
39
99
/* Frame buffer */
40
/* TODO: Implement this. */
100
41
if (offset >= 0x40 && offset < 0xc0) {
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
}
222
223
/* Reconfigure framebuffer if required */
224
- if (newxres || newyres || newxoffset || newyoffset || newbpp || newpixo
225
- || newalpha) {
226
- bcm2835_fb_reconfigure(s->fbdev, newxres, newyres, newxoffset,
227
- newyoffset, newbpp, newpixo, newalpha);
228
+ if (fbconfig_updated) {
229
+ bcm2835_fb_reconfigure(s->fbdev, &fbconfig);
230
}
231
232
/* Buffer response code */
233
--
42
--
234
2.18.0
43
2.34.1
235
44
236
45
diff view generated by jsdifflib
1
In the MPS2 FPGAIO, PSCNTR is a free-running downcounter with
1
From: Philippe Mathieu-Daudé <philmd@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
Following docs/devel/style.rst guidelines, rename
7
version ID because we only added it in the previous commit,
4
stellaris_adc_state -> StellarisADCState. This also remove a
8
so no released QEMU versions will be using it.
5
use of 'struct' in the DECLARE_INSTANCE_CHECKER() macro call.
9
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230109140306.23161-9-philmd@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
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
---
11
---
15
include/hw/misc/mps2-fpgaio.h | 6 +++
12
hw/arm/stellaris.c | 73 +++++++++++++++++++++++-----------------------
16
hw/misc/mps2-fpgaio.c | 97 +++++++++++++++++++++++++++++++++--
13
1 file changed, 36 insertions(+), 37 deletions(-)
17
2 files changed, 99 insertions(+), 4 deletions(-)
18
14
19
diff --git a/include/hw/misc/mps2-fpgaio.h b/include/hw/misc/mps2-fpgaio.h
15
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
20
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
21
--- a/include/hw/misc/mps2-fpgaio.h
17
--- a/hw/arm/stellaris.c
22
+++ b/include/hw/misc/mps2-fpgaio.h
18
+++ b/hw/arm/stellaris.c
23
@@ -XXX,XX +XXX,XX @@ typedef struct {
19
@@ -XXX,XX +XXX,XX @@ static void stellaris_i2c_init(Object *obj)
24
uint32_t prescale;
20
#define STELLARIS_ADC_FIFO_FULL 0x1000
25
uint32_t misc;
21
26
22
#define TYPE_STELLARIS_ADC "stellaris-adc"
27
+ /* QEMU_CLOCK_VIRTUAL time at which counter and pscntr were last synced */
23
-typedef struct StellarisADCState stellaris_adc_state;
28
+ int64_t pscntr_sync_ticks;
24
-DECLARE_INSTANCE_CHECKER(stellaris_adc_state, STELLARIS_ADC,
29
+ /* Values of COUNTER and PSCNTR at time pscntr_sync_ticks */
25
- TYPE_STELLARIS_ADC)
30
+ uint32_t counter;
26
+typedef struct StellarisADCState StellarisADCState;
31
+ uint32_t pscntr;
27
+DECLARE_INSTANCE_CHECKER(StellarisADCState, STELLARIS_ADC, TYPE_STELLARIS_ADC)
32
+
28
33
uint32_t prescale_clk;
29
struct StellarisADCState {
34
30
SysBusDevice parent_obj;
35
/* These hold the CLOCK_VIRTUAL ns tick when the CLK1HZ/CLK100HZ was zero */
31
@@ -XXX,XX +XXX,XX @@ struct StellarisADCState {
36
diff --git a/hw/misc/mps2-fpgaio.c b/hw/misc/mps2-fpgaio.c
32
qemu_irq irq[4];
37
index XXXXXXX..XXXXXXX 100644
33
};
38
--- a/hw/misc/mps2-fpgaio.c
34
39
+++ b/hw/misc/mps2-fpgaio.c
35
-static uint32_t stellaris_adc_fifo_read(stellaris_adc_state *s, int n)
40
@@ -XXX,XX +XXX,XX @@ static int64_t tickoff_from_counter(int64_t now, uint32_t count, int frq)
36
+static uint32_t stellaris_adc_fifo_read(StellarisADCState *s, int n)
41
return now - muldiv64(count, NANOSECONDS_PER_SECOND, frq);
37
{
38
int tail;
39
40
@@ -XXX,XX +XXX,XX @@ static uint32_t stellaris_adc_fifo_read(stellaris_adc_state *s, int n)
41
return s->fifo[n].data[tail];
42
}
42
}
43
43
44
+static void resync_counter(MPS2FPGAIO *s)
44
-static void stellaris_adc_fifo_write(stellaris_adc_state *s, int n,
45
+{
45
+static void stellaris_adc_fifo_write(StellarisADCState *s, int n,
46
+ /*
46
uint32_t value)
47
+ * Update s->counter and s->pscntr to their true current values
48
+ * by calculating how many times PSCNTR has ticked since the
49
+ * last time we did a resync.
50
+ */
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
+}
114
+
115
static uint64_t mps2_fpgaio_read(void *opaque, hwaddr offset, unsigned size)
116
{
47
{
117
MPS2FPGAIO *s = MPS2_FPGAIO(opaque);
48
int head;
118
@@ -XXX,XX +XXX,XX @@ static uint64_t mps2_fpgaio_read(void *opaque, hwaddr offset, unsigned size)
49
@@ -XXX,XX +XXX,XX @@ static void stellaris_adc_fifo_write(stellaris_adc_state *s, int n,
119
r = counter_from_tickoff(now, s->clk100hz_tick_offset, 100);
50
s->fifo[n].state |= STELLARIS_ADC_FIFO_FULL;
120
break;
121
case A_COUNTER:
122
+ resync_counter(s);
123
+ r = s->counter;
124
+ break;
125
case A_PSCNTR:
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
}
51
}
164
52
165
static void mps2_fpgaio_init(Object *obj)
53
-static void stellaris_adc_update(stellaris_adc_state *s)
166
@@ -XXX,XX +XXX,XX @@ static bool mps2_fpgaio_counters_needed(void *opaque)
54
+static void stellaris_adc_update(StellarisADCState *s)
167
55
{
168
static const VMStateDescription mps2_fpgaio_counters_vmstate = {
56
int level;
169
.name = "mps2-fpgaio/counters",
57
int n;
170
- .version_id = 1,
58
@@ -XXX,XX +XXX,XX @@ static void stellaris_adc_update(stellaris_adc_state *s)
171
- .minimum_version_id = 1,
59
172
+ .version_id = 2,
60
static void stellaris_adc_trigger(void *opaque, int irq, int level)
173
+ .minimum_version_id = 2,
61
{
174
.needed = mps2_fpgaio_counters_needed,
62
- stellaris_adc_state *s = opaque;
63
+ StellarisADCState *s = opaque;
64
int n;
65
66
for (n = 0; n < 4; n++) {
67
@@ -XXX,XX +XXX,XX @@ static void stellaris_adc_trigger(void *opaque, int irq, int level)
68
}
69
}
70
71
-static void stellaris_adc_reset(stellaris_adc_state *s)
72
+static void stellaris_adc_reset(StellarisADCState *s)
73
{
74
int n;
75
76
@@ -XXX,XX +XXX,XX @@ static void stellaris_adc_reset(stellaris_adc_state *s)
77
static uint64_t stellaris_adc_read(void *opaque, hwaddr offset,
78
unsigned size)
79
{
80
- stellaris_adc_state *s = opaque;
81
+ StellarisADCState *s = opaque;
82
83
/* TODO: Implement this. */
84
if (offset >= 0x40 && offset < 0xc0) {
85
@@ -XXX,XX +XXX,XX @@ static uint64_t stellaris_adc_read(void *opaque, hwaddr offset,
86
static void stellaris_adc_write(void *opaque, hwaddr offset,
87
uint64_t value, unsigned size)
88
{
89
- stellaris_adc_state *s = opaque;
90
+ StellarisADCState *s = opaque;
91
92
/* TODO: Implement this. */
93
if (offset >= 0x40 && offset < 0xc0) {
94
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_stellaris_adc = {
95
.version_id = 1,
96
.minimum_version_id = 1,
175
.fields = (VMStateField[]) {
97
.fields = (VMStateField[]) {
176
VMSTATE_INT64(clk1hz_tick_offset, MPS2FPGAIO),
98
- VMSTATE_UINT32(actss, stellaris_adc_state),
177
VMSTATE_INT64(clk100hz_tick_offset, MPS2FPGAIO),
99
- VMSTATE_UINT32(ris, stellaris_adc_state),
178
+ VMSTATE_UINT32(counter, MPS2FPGAIO),
100
- VMSTATE_UINT32(im, stellaris_adc_state),
179
+ VMSTATE_UINT32(pscntr, MPS2FPGAIO),
101
- VMSTATE_UINT32(emux, stellaris_adc_state),
180
+ VMSTATE_INT64(pscntr_sync_ticks, MPS2FPGAIO),
102
- VMSTATE_UINT32(ostat, stellaris_adc_state),
103
- VMSTATE_UINT32(ustat, stellaris_adc_state),
104
- VMSTATE_UINT32(sspri, stellaris_adc_state),
105
- VMSTATE_UINT32(sac, stellaris_adc_state),
106
- VMSTATE_UINT32(fifo[0].state, stellaris_adc_state),
107
- VMSTATE_UINT32_ARRAY(fifo[0].data, stellaris_adc_state, 16),
108
- VMSTATE_UINT32(ssmux[0], stellaris_adc_state),
109
- VMSTATE_UINT32(ssctl[0], stellaris_adc_state),
110
- VMSTATE_UINT32(fifo[1].state, stellaris_adc_state),
111
- VMSTATE_UINT32_ARRAY(fifo[1].data, stellaris_adc_state, 16),
112
- VMSTATE_UINT32(ssmux[1], stellaris_adc_state),
113
- VMSTATE_UINT32(ssctl[1], stellaris_adc_state),
114
- VMSTATE_UINT32(fifo[2].state, stellaris_adc_state),
115
- VMSTATE_UINT32_ARRAY(fifo[2].data, stellaris_adc_state, 16),
116
- VMSTATE_UINT32(ssmux[2], stellaris_adc_state),
117
- VMSTATE_UINT32(ssctl[2], stellaris_adc_state),
118
- VMSTATE_UINT32(fifo[3].state, stellaris_adc_state),
119
- VMSTATE_UINT32_ARRAY(fifo[3].data, stellaris_adc_state, 16),
120
- VMSTATE_UINT32(ssmux[3], stellaris_adc_state),
121
- VMSTATE_UINT32(ssctl[3], stellaris_adc_state),
122
- VMSTATE_UINT32(noise, stellaris_adc_state),
123
+ VMSTATE_UINT32(actss, StellarisADCState),
124
+ VMSTATE_UINT32(ris, StellarisADCState),
125
+ VMSTATE_UINT32(im, StellarisADCState),
126
+ VMSTATE_UINT32(emux, StellarisADCState),
127
+ VMSTATE_UINT32(ostat, StellarisADCState),
128
+ VMSTATE_UINT32(ustat, StellarisADCState),
129
+ VMSTATE_UINT32(sspri, StellarisADCState),
130
+ VMSTATE_UINT32(sac, StellarisADCState),
131
+ VMSTATE_UINT32(fifo[0].state, StellarisADCState),
132
+ VMSTATE_UINT32_ARRAY(fifo[0].data, StellarisADCState, 16),
133
+ VMSTATE_UINT32(ssmux[0], StellarisADCState),
134
+ VMSTATE_UINT32(ssctl[0], StellarisADCState),
135
+ VMSTATE_UINT32(fifo[1].state, StellarisADCState),
136
+ VMSTATE_UINT32_ARRAY(fifo[1].data, StellarisADCState, 16),
137
+ VMSTATE_UINT32(ssmux[1], StellarisADCState),
138
+ VMSTATE_UINT32(ssctl[1], StellarisADCState),
139
+ VMSTATE_UINT32(fifo[2].state, StellarisADCState),
140
+ VMSTATE_UINT32_ARRAY(fifo[2].data, StellarisADCState, 16),
141
+ VMSTATE_UINT32(ssmux[2], StellarisADCState),
142
+ VMSTATE_UINT32(ssctl[2], StellarisADCState),
143
+ VMSTATE_UINT32(fifo[3].state, StellarisADCState),
144
+ VMSTATE_UINT32_ARRAY(fifo[3].data, StellarisADCState, 16),
145
+ VMSTATE_UINT32(ssmux[3], StellarisADCState),
146
+ VMSTATE_UINT32(ssctl[3], StellarisADCState),
147
+ VMSTATE_UINT32(noise, StellarisADCState),
181
VMSTATE_END_OF_LIST()
148
VMSTATE_END_OF_LIST()
182
}
149
}
183
};
150
};
151
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_stellaris_adc = {
152
static void stellaris_adc_init(Object *obj)
153
{
154
DeviceState *dev = DEVICE(obj);
155
- stellaris_adc_state *s = STELLARIS_ADC(obj);
156
+ StellarisADCState *s = STELLARIS_ADC(obj);
157
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
158
int n;
159
160
@@ -XXX,XX +XXX,XX @@ static void stellaris_adc_class_init(ObjectClass *klass, void *data)
161
static const TypeInfo stellaris_adc_info = {
162
.name = TYPE_STELLARIS_ADC,
163
.parent = TYPE_SYS_BUS_DEVICE,
164
- .instance_size = sizeof(stellaris_adc_state),
165
+ .instance_size = sizeof(StellarisADCState),
166
.instance_init = stellaris_adc_init,
167
.class_init = stellaris_adc_class_init,
168
};
184
--
169
--
185
2.18.0
170
2.34.1
186
171
187
172
diff view generated by jsdifflib
1
Following the bulk conversion of the iwMMXt code, there are
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
just a handful of hard coded tabs in target/arm; fix them.
3
This is a whitespace-only patch.
4
2
3
The typedef and definitions are generated by the OBJECT_DECLARE_TYPE
4
macro in "hw/arm/bcm2836.h":
5
6
20 #define TYPE_BCM283X "bcm283x"
7
21 OBJECT_DECLARE_TYPE(BCM283XState, BCM283XClass, BCM283X)
8
9
The script ran in commit a489d1951c ("Use OBJECT_DECLARE_TYPE when
10
possible") missed them because they are declared in a different
11
file unit. Remove them.
12
13
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20230109140306.23161-10-philmd@linaro.org
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Message-id: 20180821165215.29069-4-peter.maydell@linaro.org
7
---
17
---
8
target/arm/cpu.h | 16 ++++++++--------
18
hw/arm/bcm2836.c | 9 ++-------
9
target/arm/arm-semi.c | 2 +-
19
1 file changed, 2 insertions(+), 7 deletions(-)
10
2 files changed, 9 insertions(+), 9 deletions(-)
11
20
12
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
21
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
13
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/cpu.h
23
--- a/hw/arm/bcm2836.c
15
+++ b/target/arm/cpu.h
24
+++ b/hw/arm/bcm2836.c
16
@@ -XXX,XX +XXX,XX @@ enum arm_cpu_mode {
25
@@ -XXX,XX +XXX,XX @@
17
#define ARM_VFP_FPINST2 10
26
#include "hw/arm/raspi_platform.h"
18
27
#include "hw/sysbus.h"
19
/* iwMMXt coprocessor control registers. */
28
20
-#define ARM_IWMMXT_wCID        0
29
-typedef struct BCM283XClass {
21
-#define ARM_IWMMXT_wCon        1
30
+struct BCM283XClass {
22
-#define ARM_IWMMXT_wCSSF    2
31
/*< private >*/
23
-#define ARM_IWMMXT_wCASF    3
32
DeviceClass parent_class;
24
-#define ARM_IWMMXT_wCGR0    8
33
/*< public >*/
25
-#define ARM_IWMMXT_wCGR1    9
34
@@ -XXX,XX +XXX,XX @@ typedef struct BCM283XClass {
26
-#define ARM_IWMMXT_wCGR2    10
35
hwaddr peri_base; /* Peripheral base address seen by the CPU */
27
-#define ARM_IWMMXT_wCGR3    11
36
hwaddr ctrl_base; /* Interrupt controller and mailboxes etc. */
28
+#define ARM_IWMMXT_wCID 0
37
int clusterid;
29
+#define ARM_IWMMXT_wCon 1
38
-} BCM283XClass;
30
+#define ARM_IWMMXT_wCSSF 2
39
-
31
+#define ARM_IWMMXT_wCASF 3
40
-#define BCM283X_CLASS(klass) \
32
+#define ARM_IWMMXT_wCGR0 8
41
- OBJECT_CLASS_CHECK(BCM283XClass, (klass), TYPE_BCM283X)
33
+#define ARM_IWMMXT_wCGR1 9
42
-#define BCM283X_GET_CLASS(obj) \
34
+#define ARM_IWMMXT_wCGR2 10
43
- OBJECT_GET_CLASS(BCM283XClass, (obj), TYPE_BCM283X)
35
+#define ARM_IWMMXT_wCGR3 11
44
+};
36
45
37
/* V7M CCR bits */
46
static Property bcm2836_enabled_cores_property =
38
FIELD(V7M_CCR, NONBASETHRDENA, 0, 1)
47
DEFINE_PROP_UINT32("enabled-cpus", BCM283XState, enabled_cpus, 0);
39
diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c
40
index XXXXXXX..XXXXXXX 100644
41
--- a/target/arm/arm-semi.c
42
+++ b/target/arm/arm-semi.c
43
@@ -XXX,XX +XXX,XX @@ static void arm_semi_cb(CPUState *cs, target_ulong ret, target_ulong err)
44
#ifdef CONFIG_USER_ONLY
45
ts->swi_errno = err;
46
#else
47
-    syscall_err = err;
48
+ syscall_err = err;
49
#endif
50
reg0 = ret;
51
} else {
52
--
48
--
53
2.18.0
49
2.34.1
54
50
55
51
diff view generated by jsdifflib
1
The AArch32 HCR and HCR2 registers alias HCR_EL2
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
bits [31:0] and [63:32]; implement them.
2
3
3
NPCM7XX models have been commited after the conversion from
4
Since HCR2 exists in ARMv8 but not ARMv7, we need new
4
commit 8063396bf3 ("Use OBJECT_DECLARE_SIMPLE_TYPE when possible").
5
regdef arrays for "we have EL3, not EL2, we're ARMv8"
5
Manually convert them.
6
and "we have EL2, we're ARMv8" to hold the definitions.
6
7
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230109140306.23161-11-philmd@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
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
---
11
---
14
target/arm/helper.c | 54 +++++++++++++++++++++++++++++++++++++++++----
12
include/hw/adc/npcm7xx_adc.h | 7 +++----
15
1 file changed, 50 insertions(+), 4 deletions(-)
13
include/hw/arm/npcm7xx.h | 18 ++++++------------
16
14
include/hw/i2c/npcm7xx_smbus.h | 7 +++----
17
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
include/hw/misc/npcm7xx_clk.h | 2 +-
18
index XXXXXXX..XXXXXXX 100644
16
include/hw/misc/npcm7xx_gcr.h | 6 +++---
19
--- a/target/arm/helper.c
17
include/hw/misc/npcm7xx_mft.h | 7 +++----
20
+++ b/target/arm/helper.c
18
include/hw/misc/npcm7xx_pwm.h | 3 +--
21
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_no_el2_cp_reginfo[] = {
19
include/hw/misc/npcm7xx_rng.h | 6 +++---
22
.opc0 = 3, .opc1 = 4, .crn = 12, .crm = 0, .opc2 = 0,
20
include/hw/net/npcm7xx_emc.h | 5 +----
23
.access = PL2_RW,
21
include/hw/sd/npcm7xx_sdhci.h | 4 ++--
24
.readfn = arm_cp_read_zero, .writefn = arm_cp_write_ignore },
22
10 files changed, 26 insertions(+), 39 deletions(-)
25
- { .name = "HCR_EL2", .state = ARM_CP_STATE_AA64,
23
26
+ { .name = "HCR_EL2", .state = ARM_CP_STATE_BOTH,
24
diff --git a/include/hw/adc/npcm7xx_adc.h b/include/hw/adc/npcm7xx_adc.h
27
.type = ARM_CP_NO_RAW,
25
index XXXXXXX..XXXXXXX 100644
28
.opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0,
26
--- a/include/hw/adc/npcm7xx_adc.h
29
.access = PL2_RW,
27
+++ b/include/hw/adc/npcm7xx_adc.h
30
- .readfn = arm_cp_read_zero, .writefn = arm_cp_write_ignore },
28
@@ -XXX,XX +XXX,XX @@
31
+ .type = ARM_CP_CONST, .resetvalue = 0 },
29
* @iref: The internal reference voltage, initialized at launch time.
32
{ .name = "ESR_EL2", .state = ARM_CP_STATE_BOTH,
30
* @rv: The calibrated output values of 0.5V and 1.5V for the ADC.
33
.opc0 = 3, .opc1 = 4, .crn = 5, .crm = 2, .opc2 = 0,
31
*/
34
.access = PL2_RW,
32
-typedef struct {
35
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_no_el2_cp_reginfo[] = {
33
+struct NPCM7xxADCState {
36
REGINFO_SENTINEL
34
SysBusDevice parent;
35
36
MemoryRegion iomem;
37
@@ -XXX,XX +XXX,XX @@ typedef struct {
38
uint32_t iref;
39
40
uint16_t calibration_r_values[NPCM7XX_ADC_NUM_CALIB];
41
-} NPCM7xxADCState;
42
+};
43
44
#define TYPE_NPCM7XX_ADC "npcm7xx-adc"
45
-#define NPCM7XX_ADC(obj) \
46
- OBJECT_CHECK(NPCM7xxADCState, (obj), TYPE_NPCM7XX_ADC)
47
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxADCState, NPCM7XX_ADC)
48
49
#endif /* NPCM7XX_ADC_H */
50
diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h
51
index XXXXXXX..XXXXXXX 100644
52
--- a/include/hw/arm/npcm7xx.h
53
+++ b/include/hw/arm/npcm7xx.h
54
@@ -XXX,XX +XXX,XX @@
55
56
#define NPCM7XX_NR_PWM_MODULES 2
57
58
-typedef struct NPCM7xxMachine {
59
+struct NPCM7xxMachine {
60
MachineState parent;
61
/*
62
* PWM fan splitter. each splitter connects to one PWM output and
63
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxMachine {
64
*/
65
SplitIRQ fan_splitter[NPCM7XX_NR_PWM_MODULES *
66
NPCM7XX_PWM_PER_MODULE];
67
-} NPCM7xxMachine;
68
+};
69
70
#define TYPE_NPCM7XX_MACHINE MACHINE_TYPE_NAME("npcm7xx")
71
-#define NPCM7XX_MACHINE(obj) \
72
- OBJECT_CHECK(NPCM7xxMachine, (obj), TYPE_NPCM7XX_MACHINE)
73
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxMachine, NPCM7XX_MACHINE)
74
75
typedef struct NPCM7xxMachineClass {
76
MachineClass parent;
77
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxMachineClass {
78
#define NPCM7XX_MACHINE_GET_CLASS(obj) \
79
OBJECT_GET_CLASS(NPCM7xxMachineClass, (obj), TYPE_NPCM7XX_MACHINE)
80
81
-typedef struct NPCM7xxState {
82
+struct NPCM7xxState {
83
DeviceState parent;
84
85
ARMCPU cpu[NPCM7XX_MAX_NUM_CPUS];
86
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxState {
87
NPCM7xxFIUState fiu[2];
88
NPCM7xxEMCState emc[2];
89
NPCM7xxSDHCIState mmc;
90
-} NPCM7xxState;
91
+};
92
93
#define TYPE_NPCM7XX "npcm7xx"
94
-#define NPCM7XX(obj) OBJECT_CHECK(NPCM7xxState, (obj), TYPE_NPCM7XX)
95
+OBJECT_DECLARE_TYPE(NPCM7xxState, NPCM7xxClass, NPCM7XX)
96
97
#define TYPE_NPCM730 "npcm730"
98
#define TYPE_NPCM750 "npcm750"
99
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxClass {
100
uint32_t num_cpus;
101
} NPCM7xxClass;
102
103
-#define NPCM7XX_CLASS(klass) \
104
- OBJECT_CLASS_CHECK(NPCM7xxClass, (klass), TYPE_NPCM7XX)
105
-#define NPCM7XX_GET_CLASS(obj) \
106
- OBJECT_GET_CLASS(NPCM7xxClass, (obj), TYPE_NPCM7XX)
107
-
108
/**
109
* npcm7xx_load_kernel - Loads memory with everything needed to boot
110
* @machine - The machine containing the SoC to be booted.
111
diff --git a/include/hw/i2c/npcm7xx_smbus.h b/include/hw/i2c/npcm7xx_smbus.h
112
index XXXXXXX..XXXXXXX 100644
113
--- a/include/hw/i2c/npcm7xx_smbus.h
114
+++ b/include/hw/i2c/npcm7xx_smbus.h
115
@@ -XXX,XX +XXX,XX @@ typedef enum NPCM7xxSMBusStatus {
116
* @rx_cur: The current position of rx_fifo.
117
* @status: The current status of the SMBus.
118
*/
119
-typedef struct NPCM7xxSMBusState {
120
+struct NPCM7xxSMBusState {
121
SysBusDevice parent;
122
123
MemoryRegion iomem;
124
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxSMBusState {
125
uint8_t rx_cur;
126
127
NPCM7xxSMBusStatus status;
128
-} NPCM7xxSMBusState;
129
+};
130
131
#define TYPE_NPCM7XX_SMBUS "npcm7xx-smbus"
132
-#define NPCM7XX_SMBUS(obj) OBJECT_CHECK(NPCM7xxSMBusState, (obj), \
133
- TYPE_NPCM7XX_SMBUS)
134
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxSMBusState, NPCM7XX_SMBUS)
135
136
#endif /* NPCM7XX_SMBUS_H */
137
diff --git a/include/hw/misc/npcm7xx_clk.h b/include/hw/misc/npcm7xx_clk.h
138
index XXXXXXX..XXXXXXX 100644
139
--- a/include/hw/misc/npcm7xx_clk.h
140
+++ b/include/hw/misc/npcm7xx_clk.h
141
@@ -XXX,XX +XXX,XX @@ struct NPCM7xxCLKState {
37
};
142
};
38
143
39
+/* Ditto, but for registers which exist in ARMv8 but not v7 */
144
#define TYPE_NPCM7XX_CLK "npcm7xx-clk"
40
+static const ARMCPRegInfo el3_no_el2_v8_cp_reginfo[] = {
145
-#define NPCM7XX_CLK(obj) OBJECT_CHECK(NPCM7xxCLKState, (obj), TYPE_NPCM7XX_CLK)
41
+ { .name = "HCR2", .state = ARM_CP_STATE_AA32,
146
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxCLKState, NPCM7XX_CLK)
42
+ .cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 4,
147
43
+ .access = PL2_RW,
148
#endif /* NPCM7XX_CLK_H */
44
+ .type = ARM_CP_CONST, .resetvalue = 0 },
149
diff --git a/include/hw/misc/npcm7xx_gcr.h b/include/hw/misc/npcm7xx_gcr.h
45
+ REGINFO_SENTINEL
150
index XXXXXXX..XXXXXXX 100644
46
+};
151
--- a/include/hw/misc/npcm7xx_gcr.h
47
+
152
+++ b/include/hw/misc/npcm7xx_gcr.h
48
static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
153
@@ -XXX,XX +XXX,XX @@
49
{
154
*/
50
ARMCPU *cpu = arm_env_get_cpu(env);
155
#define NPCM7XX_GCR_NR_REGS (0x148 / sizeof(uint32_t))
51
@@ -XXX,XX +XXX,XX @@ static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
156
52
* HCR_PTW forbids certain page-table setups
157
-typedef struct NPCM7xxGCRState {
53
* HCR_DC Disables stage1 and enables stage2 translation
158
+struct NPCM7xxGCRState {
54
*/
159
SysBusDevice parent;
55
- if ((raw_read(env, ri) ^ value) & (HCR_VM | HCR_PTW | HCR_DC)) {
160
56
+ if ((env->cp15.hcr_el2 ^ value) & (HCR_VM | HCR_PTW | HCR_DC)) {
161
MemoryRegion iomem;
57
tlb_flush(CPU(cpu));
162
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxGCRState {
58
}
163
uint32_t reset_pwron;
59
- raw_write(env, ri, value);
164
uint32_t reset_mdlr;
60
+ env->cp15.hcr_el2 = value;
165
uint32_t reset_intcr3;
61
+}
166
-} NPCM7xxGCRState;
62
+
167
+};
63
+static void hcr_writehigh(CPUARMState *env, const ARMCPRegInfo *ri,
168
64
+ uint64_t value)
169
#define TYPE_NPCM7XX_GCR "npcm7xx-gcr"
65
+{
170
-#define NPCM7XX_GCR(obj) OBJECT_CHECK(NPCM7xxGCRState, (obj), TYPE_NPCM7XX_GCR)
66
+ /* Handle HCR2 write, i.e. write to high half of HCR_EL2 */
171
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxGCRState, NPCM7XX_GCR)
67
+ value = deposit64(env->cp15.hcr_el2, 32, 32, value);
172
68
+ hcr_write(env, NULL, value);
173
#endif /* NPCM7XX_GCR_H */
69
+}
174
diff --git a/include/hw/misc/npcm7xx_mft.h b/include/hw/misc/npcm7xx_mft.h
70
+
175
index XXXXXXX..XXXXXXX 100644
71
+static void hcr_writelow(CPUARMState *env, const ARMCPRegInfo *ri,
176
--- a/include/hw/misc/npcm7xx_mft.h
72
+ uint64_t value)
177
+++ b/include/hw/misc/npcm7xx_mft.h
73
+{
178
@@ -XXX,XX +XXX,XX @@
74
+ /* Handle HCR write, i.e. write to low half of HCR_EL2 */
179
* @max_rpm: The maximum rpm for fans. Order: A0, B0, A1, B1.
75
+ value = deposit64(env->cp15.hcr_el2, 0, 32, value);
180
* @duty: The duty cycles for fans, relative to NPCM7XX_PWM_MAX_DUTY.
76
+ hcr_write(env, NULL, value);
181
*/
77
}
182
-typedef struct NPCM7xxMFTState {
78
183
+struct NPCM7xxMFTState {
79
static const ARMCPRegInfo el2_cp_reginfo[] = {
184
SysBusDevice parent;
80
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = {
185
81
.opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0,
186
MemoryRegion iomem;
82
.access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.hcr_el2),
187
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxMFTState {
83
.writefn = hcr_write },
188
84
+ { .name = "HCR", .state = ARM_CP_STATE_AA32,
189
uint32_t max_rpm[NPCM7XX_MFT_FANIN_COUNT];
85
+ .type = ARM_CP_ALIAS,
190
uint32_t duty[NPCM7XX_MFT_FANIN_COUNT];
86
+ .cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0,
191
-} NPCM7xxMFTState;
87
+ .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.hcr_el2),
192
+};
88
+ .writefn = hcr_writelow },
193
89
{ .name = "ELR_EL2", .state = ARM_CP_STATE_AA64,
194
#define TYPE_NPCM7XX_MFT "npcm7xx-mft"
90
.type = ARM_CP_ALIAS,
195
-#define NPCM7XX_MFT(obj) \
91
.opc0 = 3, .opc1 = 4, .crn = 4, .crm = 0, .opc2 = 1,
196
- OBJECT_CHECK(NPCM7xxMFTState, (obj), TYPE_NPCM7XX_MFT)
92
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = {
197
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxMFTState, NPCM7XX_MFT)
93
REGINFO_SENTINEL
198
199
#endif /* NPCM7XX_MFT_H */
200
diff --git a/include/hw/misc/npcm7xx_pwm.h b/include/hw/misc/npcm7xx_pwm.h
201
index XXXXXXX..XXXXXXX 100644
202
--- a/include/hw/misc/npcm7xx_pwm.h
203
+++ b/include/hw/misc/npcm7xx_pwm.h
204
@@ -XXX,XX +XXX,XX @@ struct NPCM7xxPWMState {
94
};
205
};
95
206
96
+static const ARMCPRegInfo el2_v8_cp_reginfo[] = {
207
#define TYPE_NPCM7XX_PWM "npcm7xx-pwm"
97
+ { .name = "HCR2", .state = ARM_CP_STATE_AA32,
208
-#define NPCM7XX_PWM(obj) \
98
+ .type = ARM_CP_ALIAS,
209
- OBJECT_CHECK(NPCM7xxPWMState, (obj), TYPE_NPCM7XX_PWM)
99
+ .cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 4,
210
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxPWMState, NPCM7XX_PWM)
100
+ .access = PL2_RW,
211
101
+ .fieldoffset = offsetofhigh32(CPUARMState, cp15.hcr_el2),
212
#endif /* NPCM7XX_PWM_H */
102
+ .writefn = hcr_writehigh },
213
diff --git a/include/hw/misc/npcm7xx_rng.h b/include/hw/misc/npcm7xx_rng.h
103
+ REGINFO_SENTINEL
214
index XXXXXXX..XXXXXXX 100644
104
+};
215
--- a/include/hw/misc/npcm7xx_rng.h
105
+
216
+++ b/include/hw/misc/npcm7xx_rng.h
106
static CPAccessResult nsacr_access(CPUARMState *env, const ARMCPRegInfo *ri,
217
@@ -XXX,XX +XXX,XX @@
107
bool isread)
218
108
{
219
#include "hw/sysbus.h"
109
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
220
110
};
221
-typedef struct NPCM7xxRNGState {
111
define_arm_cp_regs(cpu, vpidr_regs);
222
+struct NPCM7xxRNGState {
112
define_arm_cp_regs(cpu, el2_cp_reginfo);
223
SysBusDevice parent;
113
+ if (arm_feature(env, ARM_FEATURE_V8)) {
224
114
+ define_arm_cp_regs(cpu, el2_v8_cp_reginfo);
225
MemoryRegion iomem;
115
+ }
226
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxRNGState {
116
/* RVBAR_EL2 is only implemented if EL2 is the highest EL */
227
uint8_t rngcs;
117
if (!arm_feature(env, ARM_FEATURE_EL3)) {
228
uint8_t rngd;
118
ARMCPRegInfo rvbar = {
229
uint8_t rngmode;
119
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
230
-} NPCM7xxRNGState;
120
};
231
+};
121
define_arm_cp_regs(cpu, vpidr_regs);
232
122
define_arm_cp_regs(cpu, el3_no_el2_cp_reginfo);
233
#define TYPE_NPCM7XX_RNG "npcm7xx-rng"
123
+ if (arm_feature(env, ARM_FEATURE_V8)) {
234
-#define NPCM7XX_RNG(obj) OBJECT_CHECK(NPCM7xxRNGState, (obj), TYPE_NPCM7XX_RNG)
124
+ define_arm_cp_regs(cpu, el3_no_el2_v8_cp_reginfo);
235
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxRNGState, NPCM7XX_RNG)
125
+ }
236
126
}
237
#endif /* NPCM7XX_RNG_H */
127
}
238
diff --git a/include/hw/net/npcm7xx_emc.h b/include/hw/net/npcm7xx_emc.h
128
if (arm_feature(env, ARM_FEATURE_EL3)) {
239
index XXXXXXX..XXXXXXX 100644
240
--- a/include/hw/net/npcm7xx_emc.h
241
+++ b/include/hw/net/npcm7xx_emc.h
242
@@ -XXX,XX +XXX,XX @@ struct NPCM7xxEMCState {
243
bool rx_active;
244
};
245
246
-typedef struct NPCM7xxEMCState NPCM7xxEMCState;
247
-
248
#define TYPE_NPCM7XX_EMC "npcm7xx-emc"
249
-#define NPCM7XX_EMC(obj) \
250
- OBJECT_CHECK(NPCM7xxEMCState, (obj), TYPE_NPCM7XX_EMC)
251
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxEMCState, NPCM7XX_EMC)
252
253
#endif /* NPCM7XX_EMC_H */
254
diff --git a/include/hw/sd/npcm7xx_sdhci.h b/include/hw/sd/npcm7xx_sdhci.h
255
index XXXXXXX..XXXXXXX 100644
256
--- a/include/hw/sd/npcm7xx_sdhci.h
257
+++ b/include/hw/sd/npcm7xx_sdhci.h
258
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxRegs {
259
uint32_t boottoctrl;
260
} NPCM7xxRegisters;
261
262
-typedef struct NPCM7xxSDHCIState {
263
+struct NPCM7xxSDHCIState {
264
SysBusDevice parent;
265
266
MemoryRegion container;
267
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxSDHCIState {
268
NPCM7xxRegisters regs;
269
270
SDHCIState sdhci;
271
-} NPCM7xxSDHCIState;
272
+};
273
274
#endif /* NPCM7XX_SDHCI_H */
129
--
275
--
130
2.18.0
276
2.34.1
131
277
132
278
diff view generated by jsdifflib
1
Use the DeviceState vmsd pointer rather than calling vmstate_register()
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
directly.
3
2
3
The structure is named SECUREECState. Rename the type accordingly.
4
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20230109140306.23161-12-philmd@linaro.org
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
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
---
9
---
8
hw/ssi/pl022.c | 2 +-
10
hw/misc/sbsa_ec.c | 13 +++++++------
9
1 file changed, 1 insertion(+), 1 deletion(-)
11
1 file changed, 7 insertions(+), 6 deletions(-)
10
12
11
diff --git a/hw/ssi/pl022.c b/hw/ssi/pl022.c
13
diff --git a/hw/misc/sbsa_ec.c b/hw/misc/sbsa_ec.c
12
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/ssi/pl022.c
15
--- a/hw/misc/sbsa_ec.c
14
+++ b/hw/ssi/pl022.c
16
+++ b/hw/misc/sbsa_ec.c
15
@@ -XXX,XX +XXX,XX @@ static int pl022_init(SysBusDevice *sbd)
17
@@ -XXX,XX +XXX,XX @@
16
sysbus_init_mmio(sbd, &s->iomem);
18
#include "hw/sysbus.h"
17
sysbus_init_irq(sbd, &s->irq);
19
#include "sysemu/runstate.h"
18
s->ssi = ssi_create_bus(dev, "ssi");
20
19
- vmstate_register(dev, -1, &vmstate_pl022, s);
21
-typedef struct {
20
return 0;
22
+typedef struct SECUREECState {
23
SysBusDevice parent_obj;
24
MemoryRegion iomem;
25
} SECUREECState;
26
27
-#define TYPE_SBSA_EC "sbsa-ec"
28
-#define SECURE_EC(obj) OBJECT_CHECK(SECUREECState, (obj), TYPE_SBSA_EC)
29
+#define TYPE_SBSA_SECURE_EC "sbsa-ec"
30
+#define SBSA_SECURE_EC(obj) \
31
+ OBJECT_CHECK(SECUREECState, (obj), TYPE_SBSA_SECURE_EC)
32
33
enum sbsa_ec_powerstates {
34
SBSA_EC_CMD_POWEROFF = 0x01,
35
@@ -XXX,XX +XXX,XX @@ static uint64_t sbsa_ec_read(void *opaque, hwaddr offset, unsigned size)
21
}
36
}
22
37
23
@@ -XXX,XX +XXX,XX @@ static void pl022_class_init(ObjectClass *klass, void *data)
38
static void sbsa_ec_write(void *opaque, hwaddr offset,
24
39
- uint64_t value, unsigned size)
25
sdc->init = pl022_init;
40
+ uint64_t value, unsigned size)
26
dc->reset = pl022_reset;
41
{
27
+ dc->vmsd = &vmstate_pl022;
42
if (offset == 0) { /* PSCI machine power command register */
43
switch (value) {
44
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps sbsa_ec_ops = {
45
46
static void sbsa_ec_init(Object *obj)
47
{
48
- SECUREECState *s = SECURE_EC(obj);
49
+ SECUREECState *s = SBSA_SECURE_EC(obj);
50
SysBusDevice *dev = SYS_BUS_DEVICE(obj);
51
52
memory_region_init_io(&s->iomem, obj, &sbsa_ec_ops, s, "sbsa-ec",
53
@@ -XXX,XX +XXX,XX @@ static void sbsa_ec_class_init(ObjectClass *klass, void *data)
28
}
54
}
29
55
30
static const TypeInfo pl022_info = {
56
static const TypeInfo sbsa_ec_info = {
57
- .name = TYPE_SBSA_EC,
58
+ .name = TYPE_SBSA_SECURE_EC,
59
.parent = TYPE_SYS_BUS_DEVICE,
60
.instance_size = sizeof(SECUREECState),
61
.instance_init = sbsa_ec_init,
31
--
62
--
32
2.18.0
63
2.34.1
33
64
34
65
diff view generated by jsdifflib
1
Untabify the arm iwmmxt_helper.c. This affects only the iwMMXt code.
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
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
This model was merged few days before the QOM cleanup from
7
by-hand removal of a space to fix a checkpatch nit); it is
4
commit 8063396bf3 ("Use OBJECT_DECLARE_SIMPLE_TYPE when possible")
8
a whitespace-only change.
5
was pulled and merged. Manually adapt.
9
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230109140306.23161-13-philmd@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Message-id: 20180821165215.29069-3-peter.maydell@linaro.org
12
---
11
---
13
target/arm/iwmmxt_helper.c | 234 ++++++++++++++++++-------------------
12
hw/misc/sbsa_ec.c | 3 +--
14
1 file changed, 117 insertions(+), 117 deletions(-)
13
1 file changed, 1 insertion(+), 2 deletions(-)
15
14
16
diff --git a/target/arm/iwmmxt_helper.c b/target/arm/iwmmxt_helper.c
15
diff --git a/hw/misc/sbsa_ec.c b/hw/misc/sbsa_ec.c
17
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/iwmmxt_helper.c
17
--- a/hw/misc/sbsa_ec.c
19
+++ b/target/arm/iwmmxt_helper.c
18
+++ b/hw/misc/sbsa_ec.c
20
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@ typedef struct SECUREECState {
21
/* iwMMXt macros extracted from GNU gdb. */
20
} SECUREECState;
22
21
23
/* Set the SIMD wCASF flags for 8, 16, 32 or 64-bit operations. */
22
#define TYPE_SBSA_SECURE_EC "sbsa-ec"
24
-#define SIMD8_SET( v, n, b)    ((v != 0) << ((((b) + 1) * 4) + (n)))
23
-#define SBSA_SECURE_EC(obj) \
25
-#define SIMD16_SET(v, n, h)    ((v != 0) << ((((h) + 1) * 8) + (n)))
24
- OBJECT_CHECK(SECUREECState, (obj), TYPE_SBSA_SECURE_EC)
26
-#define SIMD32_SET(v, n, w)    ((v != 0) << ((((w) + 1) * 16) + (n)))
25
+OBJECT_DECLARE_SIMPLE_TYPE(SECUREECState, SBSA_SECURE_EC)
27
-#define SIMD64_SET(v, n)    ((v != 0) << (32 + (n)))
26
28
+#define SIMD8_SET(v, n, b) ((v != 0) << ((((b) + 1) * 4) + (n)))
27
enum sbsa_ec_powerstates {
29
+#define SIMD16_SET(v, n, h) ((v != 0) << ((((h) + 1) * 8) + (n)))
28
SBSA_EC_CMD_POWEROFF = 0x01,
30
+#define SIMD32_SET(v, n, w) ((v != 0) << ((((w) + 1) * 16) + (n)))
31
+#define SIMD64_SET(v, n) ((v != 0) << (32 + (n)))
32
/* Flags to pass as "n" above. */
33
-#define SIMD_NBIT    -1
34
-#define SIMD_ZBIT    -2
35
-#define SIMD_CBIT    -3
36
-#define SIMD_VBIT    -4
37
+#define SIMD_NBIT -1
38
+#define SIMD_ZBIT -2
39
+#define SIMD_CBIT -3
40
+#define SIMD_VBIT -4
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
--
29
--
311
2.18.0
30
2.34.1
312
31
313
32
diff view generated by jsdifflib
1
The AN505 FPGA image includes four PL081 DMA controllers, each
1
From: Philippe Mathieu-Daudé <philmd@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
This remove a use of 'struct' in the DECLARE_INSTANCE_CHECKER()
4
macro call, to avoid after a QOM refactor:
5
6
hw/intc/xilinx_intc.c:45:1: error: declaration of anonymous struct must be a definition
7
DECLARE_INSTANCE_CHECKER(struct xlx_pic, XILINX_INTC,
8
^
9
10
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Reviewed-by: Edgar E. Iglesias <edgar@zeroasic.com>
13
Message-id: 20230109140306.23161-14-philmd@linaro.org
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
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
---
15
---
12
hw/arm/mps2-tz.c | 100 +++++++++++++++++++++++++++++++++++++++++++----
16
hw/intc/xilinx_intc.c | 28 +++++++++++++---------------
13
1 file changed, 93 insertions(+), 7 deletions(-)
17
1 file changed, 13 insertions(+), 15 deletions(-)
14
18
15
diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c
19
diff --git a/hw/intc/xilinx_intc.c b/hw/intc/xilinx_intc.c
16
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/mps2-tz.c
21
--- a/hw/intc/xilinx_intc.c
18
+++ b/hw/arm/mps2-tz.c
22
+++ b/hw/intc/xilinx_intc.c
19
@@ -XXX,XX +XXX,XX @@
23
@@ -XXX,XX +XXX,XX @@
20
#include "hw/misc/mps2-scc.h"
24
#define R_MAX 8
21
#include "hw/misc/mps2-fpgaio.h"
25
22
#include "hw/misc/tz-mpc.h"
26
#define TYPE_XILINX_INTC "xlnx.xps-intc"
23
+#include "hw/misc/tz-msc.h"
27
-DECLARE_INSTANCE_CHECKER(struct xlx_pic, XILINX_INTC,
24
#include "hw/arm/iotkit.h"
28
- TYPE_XILINX_INTC)
25
+#include "hw/dma/pl080.h"
29
+typedef struct XpsIntc XpsIntc;
26
#include "hw/devices.h"
30
+DECLARE_INSTANCE_CHECKER(XpsIntc, XILINX_INTC, TYPE_XILINX_INTC)
27
#include "net/net.h"
31
28
#include "hw/core/split-irq.h"
32
-struct xlx_pic
29
@@ -XXX,XX +XXX,XX @@ typedef struct {
33
+struct XpsIntc
30
UnimplementedDeviceState i2c[4];
34
{
31
UnimplementedDeviceState i2s_audio;
35
SysBusDevice parent_obj;
32
UnimplementedDeviceState gpio[4];
36
33
- UnimplementedDeviceState dma[4];
37
@@ -XXX,XX +XXX,XX @@ struct xlx_pic
34
UnimplementedDeviceState gfx;
38
uint32_t irq_pin_state;
35
+ PL080State dma[4];
39
};
36
+ TZMSC msc[4];
40
37
CMSDKAPBUART uart[5];
41
-static void update_irq(struct xlx_pic *p)
38
SplitIRQ sec_resp_splitter;
42
+static void update_irq(XpsIntc *p)
39
qemu_or_irq uart_irq_orgate;
43
{
40
@@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_mpc(MPS2TZMachineState *mms, void *opaque,
44
uint32_t i;
41
return sysbus_mmio_get_region(SYS_BUS_DEVICE(mpc), 0);
45
46
@@ -XXX,XX +XXX,XX @@ static void update_irq(struct xlx_pic *p)
47
qemu_set_irq(p->parent_irq, (p->regs[R_MER] & 1) && p->regs[R_IPR]);
42
}
48
}
43
49
44
+static MemoryRegion *make_dma(MPS2TZMachineState *mms, void *opaque,
50
-static uint64_t
45
+ const char *name, hwaddr size)
51
-pic_read(void *opaque, hwaddr addr, unsigned int size)
46
+{
52
+static uint64_t pic_read(void *opaque, hwaddr addr, unsigned int size)
47
+ PL080State *dma = opaque;
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
+}
101
+
102
static void mps2tz_common_init(MachineState *machine)
103
{
53
{
104
MPS2TZMachineState *mms = MPS2TZ_MACHINE(machine);
54
- struct xlx_pic *p = opaque;
105
@@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine)
55
+ XpsIntc *p = opaque;
106
&error_fatal);
56
uint32_t r = 0;
107
57
108
/* The sec_resp_cfg output from the IoTKit must be split into multiple
58
addr >>= 2;
109
- * lines, one for each of the PPCs we create here.
59
@@ -XXX,XX +XXX,XX @@ pic_read(void *opaque, hwaddr addr, unsigned int size)
110
+ * lines, one for each of the PPCs we create here, plus one per MSC.
60
return r;
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
}
61
}
140
62
141
+static void mps2_tz_idau_check(IDAUInterface *ii, uint32_t address,
63
-static void
142
+ int *iregion, bool *exempt, bool *ns, bool *nsc)
64
-pic_write(void *opaque, hwaddr addr,
143
+{
65
- uint64_t val64, unsigned int size)
144
+ /*
66
+static void pic_write(void *opaque, hwaddr addr,
145
+ * The MPS2 TZ FPGA images have IDAUs in them which are connected to
67
+ uint64_t val64, unsigned int size)
146
+ * the Master Security Controllers. Thes have the same logic as
147
+ * is used by the IoTKit for the IDAU connected to the CPU, except
148
+ * that MSCs don't care about the NSC attribute.
149
+ */
150
+ int region = extract32(address, 28, 4);
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
+}
158
+
159
static void mps2tz_class_init(ObjectClass *oc, void *data)
160
{
68
{
161
MachineClass *mc = MACHINE_CLASS(oc);
69
- struct xlx_pic *p = opaque;
162
+ IDAUInterfaceClass *iic = IDAU_INTERFACE_CLASS(oc);
70
+ XpsIntc *p = opaque;
163
71
uint32_t value = val64;
164
mc->init = mps2tz_common_init;
72
165
mc->max_cpus = 1;
73
addr >>= 2;
166
+ iic->check = mps2_tz_idau_check;
74
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps pic_ops = {
75
76
static void irq_handler(void *opaque, int irq, int level)
77
{
78
- struct xlx_pic *p = opaque;
79
+ XpsIntc *p = opaque;
80
81
/* edge triggered interrupt */
82
if (p->c_kind_of_intr & (1 << irq) && p->regs[R_MER] & 2) {
83
@@ -XXX,XX +XXX,XX @@ static void irq_handler(void *opaque, int irq, int level)
84
85
static void xilinx_intc_init(Object *obj)
86
{
87
- struct xlx_pic *p = XILINX_INTC(obj);
88
+ XpsIntc *p = XILINX_INTC(obj);
89
90
qdev_init_gpio_in(DEVICE(obj), irq_handler, 32);
91
sysbus_init_irq(SYS_BUS_DEVICE(obj), &p->parent_irq);
92
@@ -XXX,XX +XXX,XX @@ static void xilinx_intc_init(Object *obj)
167
}
93
}
168
94
169
static void mps2tz_an505_class_init(ObjectClass *oc, void *data)
95
static Property xilinx_intc_properties[] = {
170
@@ -XXX,XX +XXX,XX @@ static const TypeInfo mps2tz_info = {
96
- DEFINE_PROP_UINT32("kind-of-intr", struct xlx_pic, c_kind_of_intr, 0),
171
.instance_size = sizeof(MPS2TZMachineState),
97
+ DEFINE_PROP_UINT32("kind-of-intr", XpsIntc, c_kind_of_intr, 0),
172
.class_size = sizeof(MPS2TZMachineClass),
98
DEFINE_PROP_END_OF_LIST(),
173
.class_init = mps2tz_class_init,
174
+ .interfaces = (InterfaceInfo[]) {
175
+ { TYPE_IDAU_INTERFACE },
176
+ { }
177
+ },
178
};
99
};
179
100
180
static const TypeInfo mps2tz_an505_info = {
101
@@ -XXX,XX +XXX,XX @@ static void xilinx_intc_class_init(ObjectClass *klass, void *data)
102
static const TypeInfo xilinx_intc_info = {
103
.name = TYPE_XILINX_INTC,
104
.parent = TYPE_SYS_BUS_DEVICE,
105
- .instance_size = sizeof(struct xlx_pic),
106
+ .instance_size = sizeof(XpsIntc),
107
.instance_init = xilinx_intc_init,
108
.class_init = xilinx_intc_class_init,
109
};
181
--
110
--
182
2.18.0
111
2.34.1
183
112
184
113
diff view generated by jsdifflib
1
The IoTKit does not have any Master Security Contollers itself,
1
From: Philippe Mathieu-Daudé <philmd@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
This remove a use of 'struct' in the DECLARE_INSTANCE_CHECKER()
4
macro call, to avoid after a QOM refactor:
5
6
hw/timer/xilinx_timer.c:65:1: error: declaration of anonymous struct must be a definition
7
DECLARE_INSTANCE_CHECKER(struct timerblock, XILINX_TIMER,
8
^
9
10
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Reviewed-by: Edgar E. Iglesias <edgar@zeroasic.com>
13
Message-id: 20230109140306.23161-15-philmd@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
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
---
15
---
11
include/hw/misc/iotkit-secctl.h | 14 +++++++
16
hw/timer/xilinx_timer.c | 27 +++++++++++++--------------
12
hw/misc/iotkit-secctl.c | 73 +++++++++++++++++++++++++++++----
17
1 file changed, 13 insertions(+), 14 deletions(-)
13
2 files changed, 79 insertions(+), 8 deletions(-)
14
18
15
diff --git a/include/hw/misc/iotkit-secctl.h b/include/hw/misc/iotkit-secctl.h
19
diff --git a/hw/timer/xilinx_timer.c b/hw/timer/xilinx_timer.c
16
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/misc/iotkit-secctl.h
21
--- a/hw/timer/xilinx_timer.c
18
+++ b/include/hw/misc/iotkit-secctl.h
22
+++ b/hw/timer/xilinx_timer.c
19
@@ -XXX,XX +XXX,XX @@
23
@@ -XXX,XX +XXX,XX @@ struct xlx_timer
20
* + named GPIO output "sec_resp_cfg" indicating whether blocked accesses
24
};
21
* should RAZ/WI or bus error
25
22
* + named GPIO output "nsc_cfg" whose value tracks the NSCCFG register value
26
#define TYPE_XILINX_TIMER "xlnx.xps-timer"
23
+ * + named GPIO output "msc_irq" for the combined IRQ line from the MSCs
27
-DECLARE_INSTANCE_CHECKER(struct timerblock, XILINX_TIMER,
24
* Controlling the 2 APB PPCs in the IoTKit:
28
- TYPE_XILINX_TIMER)
25
* + named GPIO outputs apb_ppc0_nonsec[0..2] and apb_ppc1_nonsec
29
+typedef struct XpsTimerState XpsTimerState;
26
* + named GPIO outputs apb_ppc0_ap[0..2] and apb_ppc1_ap
30
+DECLARE_INSTANCE_CHECKER(XpsTimerState, XILINX_TIMER, TYPE_XILINX_TIMER)
27
@@ -XXX,XX +XXX,XX @@
31
28
* Controlling each of the 16 expansion MPCs which a system using the IoTKit
32
-struct timerblock
29
* might provide:
33
+struct XpsTimerState
30
* + named GPIO inputs mpcexp_status[0..15]
34
{
31
+ * Controlling each of the 16 expansion MSCs which a system using the IoTKit
35
SysBusDevice parent_obj;
32
+ * might provide:
36
33
+ * + named GPIO inputs mscexp_status[0..15]
37
@@ -XXX,XX +XXX,XX @@ struct timerblock
34
+ * + named GPIO outputs mscexp_clear[0..15]
38
struct xlx_timer *timers;
35
+ * + named GPIO outputs mscexp_ns[0..15]
39
};
36
*/
40
37
41
-static inline unsigned int num_timers(struct timerblock *t)
38
#ifndef IOTKIT_SECCTL_H
42
+static inline unsigned int num_timers(XpsTimerState *t)
39
@@ -XXX,XX +XXX,XX @@
43
{
40
#define IOTS_NUM_AHB_EXP_PPC 4
44
return 2 - t->one_timer_only;
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
}
45
}
86
46
@@ -XXX,XX +XXX,XX @@ static inline unsigned int timer_from_addr(hwaddr addr)
87
+static void iotkit_secctl_update_mscexp_irqs(qemu_irq *msc_irqs, uint32_t value)
47
return addr >> 2;
88
+{
89
+ int i;
90
+
91
+ for (i = 0; i < IOTS_NUM_EXP_MSC; i++) {
92
+ qemu_set_irq(msc_irqs[i], extract32(value, i + 16, 1));
93
+ }
94
+}
95
+
96
+static void iotkit_secctl_update_msc_irq(IoTKitSecCtl *s)
97
+{
98
+ /* Update the combined MSC IRQ, based on S_MSCEXP_STATUS and S_MSCEXP_EN */
99
+ bool level = s->secmscintstat & s->secmscinten;
100
+
101
+ qemu_set_irq(s->msc_irq, level);
102
+}
103
+
104
static MemTxResult iotkit_secctl_s_write(void *opaque, hwaddr addr,
105
uint64_t value,
106
unsigned size, MemTxAttrs attrs)
107
@@ -XXX,XX +XXX,XX @@ static MemTxResult iotkit_secctl_s_write(void *opaque, hwaddr addr,
108
iotkit_secctl_ppc_sp_write(ppc, value);
109
break;
110
case A_SECMSCINTCLR:
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
}
48
}
137
49
138
+static void iotkit_secctl_mscexp_status(void *opaque, int n, int level)
50
-static void timer_update_irq(struct timerblock *t)
139
+{
51
+static void timer_update_irq(XpsTimerState *t)
140
+ IoTKitSecCtl *s = IOTKIT_SECCTL(opaque);
141
+
142
+ s->secmscintstat = deposit32(s->secmscintstat, n + 16, 1, !!level);
143
+ iotkit_secctl_update_msc_irq(s);
144
+}
145
+
146
static void iotkit_secctl_ppc_irqstatus(void *opaque, int n, int level)
147
{
52
{
148
IoTKitSecCtlPPC *ppc = opaque;
53
unsigned int i, irq = 0;
149
@@ -XXX,XX +XXX,XX @@ static void iotkit_secctl_init(Object *obj)
54
uint32_t csr;
150
qdev_init_gpio_in_named(dev, iotkit_secctl_mpcexp_status,
55
@@ -XXX,XX +XXX,XX @@ static void timer_update_irq(struct timerblock *t)
151
"mpcexp_status", IOTS_NUM_EXP_MPC);
56
static uint64_t
152
57
timer_read(void *opaque, hwaddr addr, unsigned int size)
153
+ qdev_init_gpio_in_named(dev, iotkit_secctl_mscexp_status,
58
{
154
+ "mscexp_status", IOTS_NUM_EXP_MSC);
59
- struct timerblock *t = opaque;
155
+ qdev_init_gpio_out_named(dev, s->mscexp_clear, "mscexp_clear",
60
+ XpsTimerState *t = opaque;
156
+ IOTS_NUM_EXP_MSC);
61
struct xlx_timer *xt;
157
+ qdev_init_gpio_out_named(dev, s->mscexp_ns, "mscexp_ns",
62
uint32_t r = 0;
158
+ IOTS_NUM_EXP_MSC);
63
unsigned int timer;
159
+ qdev_init_gpio_out_named(dev, &s->msc_irq, "msc_irq", 1);
64
@@ -XXX,XX +XXX,XX @@ static void
160
+
65
timer_write(void *opaque, hwaddr addr,
161
memory_region_init_io(&s->s_regs, obj, &iotkit_secctl_s_ops,
66
uint64_t val64, unsigned int size)
162
s, "iotkit-secctl-s-regs", 0x1000);
67
{
163
memory_region_init_io(&s->ns_regs, obj, &iotkit_secctl_ns_ops,
68
- struct timerblock *t = opaque;
164
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription iotkit_secctl_mpcintstatus_vmstate = {
69
+ XpsTimerState *t = opaque;
165
}
70
struct xlx_timer *xt;
71
unsigned int timer;
72
uint32_t value = val64;
73
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps timer_ops = {
74
static void timer_hit(void *opaque)
75
{
76
struct xlx_timer *xt = opaque;
77
- struct timerblock *t = xt->parent;
78
+ XpsTimerState *t = xt->parent;
79
D(fprintf(stderr, "%s %d\n", __func__, xt->nr));
80
xt->regs[R_TCSR] |= TCSR_TINT;
81
82
@@ -XXX,XX +XXX,XX @@ static void timer_hit(void *opaque)
83
84
static void xilinx_timer_realize(DeviceState *dev, Error **errp)
85
{
86
- struct timerblock *t = XILINX_TIMER(dev);
87
+ XpsTimerState *t = XILINX_TIMER(dev);
88
unsigned int i;
89
90
/* Init all the ptimers. */
91
@@ -XXX,XX +XXX,XX @@ static void xilinx_timer_realize(DeviceState *dev, Error **errp)
92
93
static void xilinx_timer_init(Object *obj)
94
{
95
- struct timerblock *t = XILINX_TIMER(obj);
96
+ XpsTimerState *t = XILINX_TIMER(obj);
97
98
/* All timers share a single irq line. */
99
sysbus_init_irq(SYS_BUS_DEVICE(obj), &t->irq);
100
}
101
102
static Property xilinx_timer_properties[] = {
103
- DEFINE_PROP_UINT32("clock-frequency", struct timerblock, freq_hz,
104
- 62 * 1000000),
105
- DEFINE_PROP_UINT8("one-timer-only", struct timerblock, one_timer_only, 0),
106
+ DEFINE_PROP_UINT32("clock-frequency", XpsTimerState, freq_hz, 62 * 1000000),
107
+ DEFINE_PROP_UINT8("one-timer-only", XpsTimerState, one_timer_only, 0),
108
DEFINE_PROP_END_OF_LIST(),
166
};
109
};
167
110
168
+static bool needed_always(void *opaque)
111
@@ -XXX,XX +XXX,XX @@ static void xilinx_timer_class_init(ObjectClass *klass, void *data)
169
+{
112
static const TypeInfo xilinx_timer_info = {
170
+ return true;
113
.name = TYPE_XILINX_TIMER,
171
+}
114
.parent = TYPE_SYS_BUS_DEVICE,
172
+
115
- .instance_size = sizeof(struct timerblock),
173
+static const VMStateDescription iotkit_secctl_msc_vmstate = {
116
+ .instance_size = sizeof(XpsTimerState),
174
+ .name = "iotkit-secctl/msc",
117
.instance_init = xilinx_timer_init,
175
+ .version_id = 1,
118
.class_init = xilinx_timer_class_init,
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
};
119
};
197
--
120
--
198
2.18.0
121
2.34.1
199
122
200
123
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Evgeny Iakovlev <eiakovlev@linux.microsoft.com>
2
2
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3
ARM trusted firmware, when built with FEAT_HCX support, sets SCR_EL3.HXEn bit
4
Message-id: 20180814002653.12828-4-richard.henderson@linaro.org
4
to allow EL2 to modify HCRX_EL2 register without trapping it in EL3. Qemu
5
uses a valid mask to clear unsupported SCR_EL3 bits when emulating SCR_EL3
6
write, and that mask doesn't include SCR_EL3.HXEn bit even if FEAT_HCX is
7
enabled and exposed to the guest. As a result EL3 writes of that bit are
8
ignored.
9
10
Cc: qemu-stable@nongnu.org
11
Signed-off-by: Evgeny Iakovlev <eiakovlev@linux.microsoft.com>
12
Message-id: 20230105221251.17896-4-eiakovlev@linux.microsoft.com
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
15
---
8
target/arm/helper.c | 29 +++++------------------------
16
target/arm/helper.c | 3 +++
9
1 file changed, 5 insertions(+), 24 deletions(-)
17
1 file changed, 3 insertions(+)
10
18
11
diff --git a/target/arm/helper.c b/target/arm/helper.c
19
diff --git a/target/arm/helper.c b/target/arm/helper.c
12
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/helper.c
21
--- a/target/arm/helper.c
14
+++ b/target/arm/helper.c
22
+++ b/target/arm/helper.c
15
@@ -XXX,XX +XXX,XX @@ float32 VFP_HELPER(fcvts, d)(float64 x, CPUARMState *env)
23
@@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
16
#define VFP_CONV_FIX_FLOAT(name, p, fsz, isz, itype) \
24
if (cpu_isar_feature(aa64_sme, cpu)) {
17
float##fsz HELPER(vfp_##name##to##p)(uint##isz##_t x, uint32_t shift, \
25
valid_mask |= SCR_ENTP2;
18
void *fpstp) \
26
}
19
-{ \
27
+ if (cpu_isar_feature(aa64_hcx, cpu)) {
20
- float_status *fpst = fpstp; \
28
+ valid_mask |= SCR_HXEN;
21
- float##fsz tmp; \
29
+ }
22
- tmp = itype##_to_##float##fsz(x, fpst); \
30
} else {
23
- return float##fsz##_scalbn(tmp, -(int)shift, fpst); \
31
valid_mask &= ~(SCR_RW | SCR_ST);
24
-}
32
if (cpu_isar_feature(aa32_ras, cpu)) {
25
+{ return itype##_to_##float##fsz##_scalbn(x, -shift, fpstp); }
26
27
/* Notice that we want only input-denormal exception flags from the
28
* scalbn operation: the other possible flags (overflow+inexact if
29
@@ -XXX,XX +XXX,XX @@ VFP_CONV_FIX_A64(uq, s, 32, 64, uint64)
30
#undef VFP_CONV_FLOAT_FIX_ROUND
31
#undef VFP_CONV_FIX_A64
32
33
-/* Conversion to/from f16 can overflow to infinity before/after scaling.
34
- * Therefore we convert to f64, scale, and then convert f64 to f16; or
35
- * vice versa for conversion to integer.
36
- *
37
- * For 16- and 32-bit integers, the conversion to f64 never rounds.
38
- * For 64-bit integers, any integer that would cause rounding will also
39
- * overflow to f16 infinity, so there is no double rounding problem.
40
- */
41
-
42
-static float16 do_postscale_fp16(float64 f, int shift, float_status *fpst)
43
-{
44
- return float64_to_float16(float64_scalbn(f, -shift, fpst), true, fpst);
45
-}
46
-
47
uint32_t HELPER(vfp_sltoh)(uint32_t x, uint32_t shift, void *fpst)
48
{
49
- return do_postscale_fp16(int32_to_float64(x, fpst), shift, fpst);
50
+ return int32_to_float16_scalbn(x, -shift, fpst);
51
}
52
53
uint32_t HELPER(vfp_ultoh)(uint32_t x, uint32_t shift, void *fpst)
54
{
55
- return do_postscale_fp16(uint32_to_float64(x, fpst), shift, fpst);
56
+ return uint32_to_float16_scalbn(x, -shift, fpst);
57
}
58
59
uint32_t HELPER(vfp_sqtoh)(uint64_t x, uint32_t shift, void *fpst)
60
{
61
- return do_postscale_fp16(int64_to_float64(x, fpst), shift, fpst);
62
+ return int64_to_float16_scalbn(x, -shift, fpst);
63
}
64
65
uint32_t HELPER(vfp_uqtoh)(uint64_t x, uint32_t shift, void *fpst)
66
{
67
- return do_postscale_fp16(uint64_to_float64(x, fpst), shift, fpst);
68
+ return uint64_to_float16_scalbn(x, -shift, fpst);
69
}
70
71
static float64 do_prescale_fp16(float16 f, int shift, float_status *fpst)
72
--
33
--
73
2.18.0
34
2.34.1
74
75
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
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
Factor out the code which changes the CPU state so as to
2
actually take an exception to AArch32. We're going to want
3
to use this for handling exception entry to Hyp mode.
4
1
5
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
---
11
target/arm/helper.c | 64 +++++++++++++++++++++++++++++----------------
12
1 file changed, 41 insertions(+), 23 deletions(-)
13
14
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/helper.c
17
+++ b/target/arm/helper.c
18
@@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env)
19
env->regs[15] = env->pc;
20
}
21
22
+static void take_aarch32_exception(CPUARMState *env, int new_mode,
23
+ uint32_t mask, uint32_t offset,
24
+ uint32_t newpc)
25
+{
26
+ /* Change the CPU state so as to actually take the exception. */
27
+ switch_mode(env, new_mode);
28
+ /*
29
+ * For exceptions taken to AArch32 we must clear the SS bit in both
30
+ * PSTATE and in the old-state value we save to SPSR_<mode>, so zero it now.
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
+
45
+ if (new_mode == ARM_CPU_MODE_HYP) {
46
+ env->thumb = (env->cp15.sctlr_el[2] & SCTLR_TE) != 0;
47
+ env->elr_el[2] = env->regs[15];
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
}
68
69
- switch_mode (env, new_mode);
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
}
94
95
/* Handle exception entry to a target EL which is using AArch64 */
96
--
97
2.18.0
98
99
diff view generated by jsdifflib
Deleted patch
1
Implement the necessary support code for taking exceptions
2
to Hyp mode in AArch32.
3
1
4
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
---
10
target/arm/helper.c | 82 +++++++++++++++++++++++++++++++++++++++++++++
11
1 file changed, 82 insertions(+)
12
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
16
+++ b/target/arm/helper.c
17
@@ -XXX,XX +XXX,XX @@ static void take_aarch32_exception(CPUARMState *env, int new_mode,
18
env->regs[15] = newpc;
19
}
20
21
+static void arm_cpu_do_interrupt_aarch32_hyp(CPUState *cs)
22
+{
23
+ /*
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
{
100
ARMCPU *cpu = ARM_CPU(cs);
101
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch32(CPUState *cs)
102
env->cp15.mdscr_el1 = deposit64(env->cp15.mdscr_el1, 2, 4, moe);
103
}
104
105
+ if (env->exception.target_el == 2) {
106
+ arm_cpu_do_interrupt_aarch32_hyp(cs);
107
+ return;
108
+ }
109
+
110
/* TODO: Vectored interrupt controller. */
111
switch (cs->exception_index) {
112
case EXCP_UDEF:
113
--
114
2.18.0
115
116
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
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
Deleted patch
1
The IoTKit has a CMSDK timer device that runs on the S32KCLK.
2
Create this and wire it 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-8-peter.maydell@linaro.org
8
---
9
include/hw/arm/iotkit.h | 2 +-
10
hw/arm/iotkit.c | 9 +++++----
11
2 files changed, 6 insertions(+), 5 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 @@ typedef struct IoTKit {
18
TZMPC mpc;
19
CMSDKAPBTIMER timer0;
20
CMSDKAPBTIMER timer1;
21
+ CMSDKAPBTIMER s32ktimer;
22
qemu_or_irq ppc_irq_orgate;
23
SplitIRQ sec_resp_splitter;
24
SplitIRQ ppc_irq_splitter[NUM_PPCS];
25
@@ -XXX,XX +XXX,XX @@ typedef struct IoTKit {
26
qemu_or_irq nmi_orgate;
27
28
CMSDKAPBDualTimer dualtimer;
29
- UnimplementedDeviceState s32ktimer;
30
31
CMSDKAPBWatchdog s32kwatchdog;
32
CMSDKAPBWatchdog nswatchdog;
33
diff --git a/hw/arm/iotkit.c b/hw/arm/iotkit.c
34
index XXXXXXX..XXXXXXX 100644
35
--- a/hw/arm/iotkit.c
36
+++ b/hw/arm/iotkit.c
37
@@ -XXX,XX +XXX,XX @@ static void iotkit_init(Object *obj)
38
TYPE_CMSDK_APB_TIMER);
39
sysbus_init_child_obj(obj, "timer1", &s->timer1, sizeof(s->timer1),
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
}
53
54
static void iotkit_exp_irq(void *opaque, int n, int level)
55
@@ -XXX,XX +XXX,XX @@ static void iotkit_realize(DeviceState *dev, Error **errp)
56
/* Devices behind APB PPC1:
57
* 0x4002f000: S32K timer
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
--
73
2.18.0
74
75
diff view generated by jsdifflib
Deleted patch
1
In the PL022, register offset 0x20 is the ICR, a write-only
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
1
7
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
---
11
hw/ssi/pl022.c | 12 ++++++++++--
12
1 file changed, 10 insertions(+), 2 deletions(-)
13
14
diff --git a/hw/ssi/pl022.c b/hw/ssi/pl022.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/ssi/pl022.c
17
+++ b/hw/ssi/pl022.c
18
@@ -XXX,XX +XXX,XX @@ static uint64_t pl022_read(void *opaque, hwaddr offset,
19
return s->is;
20
case 0x1c: /* MIS */
21
return s->im & s->is;
22
- case 0x20: /* DMACR */
23
+ case 0x24: /* DMACR */
24
/* Not implemented. */
25
return 0;
26
default:
27
@@ -XXX,XX +XXX,XX @@ static void pl022_write(void *opaque, hwaddr offset,
28
s->im = value;
29
pl022_update(s);
30
break;
31
- case 0x20: /* DMACR */
32
+ case 0x20: /* ICR */
33
+ /*
34
+ * write-1-to-clear: bit 0 clears ROR, bit 1 clears RT;
35
+ * RX and TX interrupts cannot be cleared this way.
36
+ */
37
+ value &= PL022_INT_ROR | PL022_INT_RT;
38
+ s->is &= ~value;
39
+ break;
40
+ case 0x24: /* DMACR */
41
if (value) {
42
qemu_log_mask(LOG_UNIMP, "pl022: DMA not implemented\n");
43
}
44
--
45
2.18.0
46
47
diff view generated by jsdifflib
Deleted patch
1
The SPI controllers in the MPS2 AN505 board are PL022s.
2
We have a model of the PL022, so create these devices.
3
1
4
We don't currently model the LCD controller that sits behind
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
9
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
---
13
hw/arm/mps2-tz.c | 38 ++++++++++++++++++++++++++++++++------
14
1 file changed, 32 insertions(+), 6 deletions(-)
15
16
diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/arm/mps2-tz.c
19
+++ b/hw/arm/mps2-tz.c
20
@@ -XXX,XX +XXX,XX @@
21
#include "hw/misc/tz-msc.h"
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
}
40
41
+static MemoryRegion *make_spi(MPS2TZMachineState *mms, void *opaque,
42
+ const char *name, hwaddr size)
43
+{
44
+ /*
45
+ * The AN505 has five PL022 SPI controllers.
46
+ * One of these should have the LCD controller behind it; the others
47
+ * are connected only to the FPGA's "general purpose SPI connector"
48
+ * or "shield" expansion connectors.
49
+ * Note that if we do implement devices behind SPI, the chip select
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
+}
65
+
66
static void mps2tz_common_init(MachineState *machine)
67
{
68
MPS2TZMachineState *mms = MPS2TZ_MACHINE(machine);
69
@@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine)
70
}, {
71
.name = "apb_ppcexp1",
72
.ports = {
73
- { "spi0", make_unimp_dev, &mms->spi[0], 0x40205000, 0x1000 },
74
- { "spi1", make_unimp_dev, &mms->spi[1], 0x40206000, 0x1000 },
75
- { "spi2", make_unimp_dev, &mms->spi[2], 0x40209000, 0x1000 },
76
- { "spi3", make_unimp_dev, &mms->spi[3], 0x4020a000, 0x1000 },
77
- { "spi4", make_unimp_dev, &mms->spi[4], 0x4020b000, 0x1000 },
78
+ { "spi0", make_spi, &mms->spi[0], 0x40205000, 0x1000 },
79
+ { "spi1", make_spi, &mms->spi[1], 0x40206000, 0x1000 },
80
+ { "spi2", make_spi, &mms->spi[2], 0x40209000, 0x1000 },
81
+ { "spi3", make_spi, &mms->spi[3], 0x4020a000, 0x1000 },
82
+ { "spi4", make_spi, &mms->spi[4], 0x4020b000, 0x1000 },
83
{ "uart0", make_uart, &mms->uart[0], 0x40200000, 0x1000 },
84
{ "uart1", make_uart, &mms->uart[1], 0x40201000, 0x1000 },
85
{ "uart2", make_uart, &mms->uart[2], 0x40202000, 0x1000 },
86
--
87
2.18.0
88
89
diff view generated by jsdifflib
Deleted patch
1
Some of the config register values we were setting for the MPS2 SCC
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
1
9
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
---
13
hw/arm/mps2-tz.c | 4 ++--
14
1 file changed, 2 insertions(+), 2 deletions(-)
15
16
diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/arm/mps2-tz.c
19
+++ b/hw/arm/mps2-tz.c
20
@@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_scc(MPS2TZMachineState *mms, void *opaque,
21
sccdev = DEVICE(scc);
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(scc), true, "realized", &error_fatal);
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
}
36
37
static const TypeInfo mps2tz_info = {
38
--
39
2.18.0
40
41
diff view generated by jsdifflib