1
target-arm queue: aspeed patches from Cédric, and
1
The following changes since commit 003ba52a8b327180e284630b289c6ece5a3e08b9:
2
cleanup and sd card patches from Philippe.
3
2
4
thanks
3
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2023-02-16 11:16:39 +0000)
5
-- PMM
6
7
The following changes since commit bac5ba3dc5da706f52c149fa6c0bd1dc96899bec:
8
9
Merge remote-tracking branch 'remotes/thibault/tags/samuel-thibault' into staging (2018-06-08 10:26:16 +0100)
10
4
11
are available in the Git repository at:
5
are available in the Git repository at:
12
6
13
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180608
7
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230216
14
8
15
for you to fetch changes up to 113f31c06c6bf16451892b2459d83c9b9c5e9844:
9
for you to fetch changes up to caf01d6a435d9f4a95aeae2f9fc6cb8b889b1fb8:
16
10
17
sdcard: Disable CMD19/CMD23 for Spec v2 (2018-06-08 13:15:34 +0100)
11
tests/qtest: Restrict tpm-tis-devices-{swtpm}-test to CONFIG_TCG (2023-02-16 16:28:53 +0000)
18
12
19
----------------------------------------------------------------
13
----------------------------------------------------------------
20
target-arm queue:
14
target-arm queue:
21
* arm_gicv3_kvm: fix migration of registers corresponding to
15
* Some mostly M-profile-related code cleanups
22
IRQs 992 to 1020 in the KVM GIC
16
* avocado: Retire the boot_linux.py AArch64 TCG tests
23
* aspeed: remove ignore_memory_transaction_failures on all boards
17
* hw/arm/smmuv3: Add GBPA register
24
* aspeed: add support for the witherspoon-bmc board
18
* arm/virt: don't try to spell out the accelerator
25
* aspeed: add an I2C RTC device and EEPROM I2C devices
19
* hw/arm: Attach PSPI module to NPCM7XX SoC
26
* aspeed: add the pc9552 chips to the witherspoon machine
20
* Some cleanup/refactoring patches aiming towards
27
* ftgmac100: fix various bugs
21
allowing building Arm targets without CONFIG_TCG
28
* hw/arm: Remove the deprecated xlnx-ep108 machine
29
* hw/i2c: Add trace events
30
* add missing '\n' on various qemu_log() logging strings
31
* sdcard: clean up spec version support so we report the
32
right spec version to the guest and only implement the
33
commands that are supposed to be present in that version
34
22
35
----------------------------------------------------------------
23
----------------------------------------------------------------
36
Cédric Le Goater (11):
24
Alex Bennée (1):
37
aspeed: remove ignore_memory_transaction_failures on all boards
25
tests/avocado: retire the Aarch64 TCG tests from boot_linux.py
38
aspeed: add support for the witherspoon-bmc board
39
aspeed: add an I2C RTC device to all machines
40
smbus: add a smbus_eeprom_init_one() routine
41
aspeed: Add EEPROM I2C devices
42
misc: add pca9552 LED blinker model
43
aspeed: add the pc9552 chips to the witherspoon machine
44
ftgmac100: compute maximum frame size depending on the protocol
45
ftgmac100: add IEEE 802.1Q VLAN support
46
ftgmac100: fix multicast hash routine
47
ftgmac100: remove check on runt messages
48
26
49
Philippe Mathieu-Daudé (18):
27
Claudio Fontana (3):
50
hw/i2c: Add trace events
28
target/arm: rename handle_semihosting to tcg_handle_semihosting
51
hw/sd/milkymist-memcard: Add trailing '\n' to qemu_log() call
29
target/arm: wrap psci call with tcg_enabled
52
hw/digic: Add trailing '\n' to qemu_log() calls
30
target/arm: wrap call to aarch64_sve_change_el in tcg_enabled()
53
xilinx-dp: Add trailing '\n' to qemu_log() call
54
ppc/pnv: Add trailing '\n' to qemu_log() calls
55
hw/core/register: Add trailing '\n' to qemu_log() call
56
hw/mips/boston: Add trailing '\n' to qemu_log() calls
57
stellaris: Add trailing '\n' to qemu_log() calls
58
target/arm: Add trailing '\n' to qemu_log() calls
59
target/m68k: Add trailing '\n' to qemu_log() call
60
RISC-V: Add trailing '\n' to qemu_log() calls
61
target/xtensa: Add trailing '\n' to qemu_log() calls
62
sdcard: Update the Configuration Register (SCR) to Spec Version 1.10
63
sdcard: Allow commands valid in SPI mode
64
sdcard: Add a 'spec_version' property, default to Spec v2.00
65
sdcard: Disable SEND_IF_COND (CMD8) for Spec v1
66
sdcard: Reflect when the Spec v3 is supported in the Config Register (SCR)
67
sdcard: Disable CMD19/CMD23 for Spec v2
68
31
69
Shannon Zhao (1):
32
Cornelia Huck (1):
70
arm_gicv3_kvm: kvm_dist_get/put: skip the registers banked by GICR
33
arm/virt: don't try to spell out the accelerator
71
34
72
Thomas Huth (1):
35
Fabiano Rosas (7):
73
hw/arm: Remove the deprecated xlnx-ep108 machine
36
target/arm: Move PC alignment check
37
target/arm: Move cpregs code out of cpu.h
38
tests/avocado: Skip tests that require a missing accelerator
39
tests/avocado: Tag TCG tests with accel:tcg
40
target/arm: Use "max" as default cpu for the virt machine with KVM
41
tests/qtest: arm-cpu-features: Match tests to required accelerators
42
tests/qtest: Restrict tpm-tis-devices-{swtpm}-test to CONFIG_TCG
74
43
75
Makefile.objs | 1 +
44
Hao Wu (3):
76
hw/misc/Makefile.objs | 1 +
45
MAINTAINERS: Add myself to maintainers and remove Havard
77
tests/Makefile.include | 2 +
46
hw/ssi: Add Nuvoton PSPI Module
78
include/hw/i2c/smbus.h | 1 +
47
hw/arm: Attach PSPI module to NPCM7XX SoC
79
include/hw/intc/arm_gicv3_common.h | 1 +
80
include/hw/misc/pca9552.h | 32 +++++
81
include/hw/misc/pca9552_regs.h | 32 +++++
82
include/hw/net/ftgmac100.h | 7 +-
83
include/hw/sd/sd.h | 6 +
84
tests/libqos/i2c.h | 2 +
85
hw/arm/aspeed.c | 88 +++++++++++++-
86
hw/arm/stellaris.c | 11 +-
87
hw/arm/xlnx-zcu102.c | 62 +---------
88
hw/char/digic-uart.c | 4 +-
89
hw/core/register.c | 2 +-
90
hw/display/xlnx_dp.c | 4 +-
91
hw/i2c/core.c | 25 ++--
92
hw/i2c/smbus_eeprom.c | 16 ++-
93
hw/intc/arm_gicv3_common.c | 79 ++++++++++++
94
hw/intc/arm_gicv3_kvm.c | 38 ++++++
95
hw/mips/boston.c | 8 +-
96
hw/misc/pca9552.c | 240 +++++++++++++++++++++++++++++++++++++
97
hw/net/ftgmac100.c | 64 ++++++----
98
hw/ppc/pnv_core.c | 4 +-
99
hw/sd/milkymist-memcard.c | 2 +-
100
hw/sd/sd.c | 50 +++++---
101
hw/timer/digic-timer.c | 4 +-
102
target/arm/helper.c | 4 +-
103
target/m68k/translate.c | 2 +-
104
target/riscv/op_helper.c | 6 +-
105
target/xtensa/translate.c | 6 +-
106
tests/pca9552-test.c | 116 ++++++++++++++++++
107
tests/tmp105-test.c | 2 -
108
default-configs/arm-softmmu.mak | 1 +
109
hw/i2c/trace-events | 7 ++
110
qemu-doc.texi | 5 -
111
36 files changed, 788 insertions(+), 147 deletions(-)
112
create mode 100644 include/hw/misc/pca9552.h
113
create mode 100644 include/hw/misc/pca9552_regs.h
114
create mode 100644 hw/misc/pca9552.c
115
create mode 100644 tests/pca9552-test.c
116
create mode 100644 hw/i2c/trace-events
117
48
49
Jean-Philippe Brucker (2):
50
hw/arm/smmu-common: Support 64-bit addresses
51
hw/arm/smmu-common: Fix TTB1 handling
52
53
Mostafa Saleh (1):
54
hw/arm/smmuv3: Add GBPA register
55
56
Philippe Mathieu-Daudé (12):
57
hw/intc/armv7m_nvic: Use OBJECT_DECLARE_SIMPLE_TYPE() macro
58
target/arm: Simplify arm_v7m_mmu_idx_for_secstate() for user emulation
59
target/arm: Reduce arm_v7m_mmu_idx_[all/for_secstate_and_priv]() scope
60
target/arm: Constify ID_PFR1 on user emulation
61
target/arm: Convert CPUARMState::eabi to boolean
62
target/arm: Avoid resetting CPUARMState::eabi field
63
target/arm: Restrict CPUARMState::gicv3state to sysemu
64
target/arm: Restrict CPUARMState::arm_boot_info to sysemu
65
target/arm: Restrict CPUARMState::nvic to sysemu
66
target/arm: Store CPUARMState::nvic as NVICState*
67
target/arm: Declare CPU <-> NVIC helpers in 'hw/intc/armv7m_nvic.h'
68
hw/arm: Add missing XLNX_ZYNQMP_ARM -> USB_DWC3 Kconfig dependency
69
70
MAINTAINERS | 8 +-
71
docs/system/arm/nuvoton.rst | 2 +-
72
hw/arm/smmuv3-internal.h | 7 +
73
include/hw/arm/npcm7xx.h | 2 +
74
include/hw/arm/smmu-common.h | 2 -
75
include/hw/arm/smmuv3.h | 1 +
76
include/hw/intc/armv7m_nvic.h | 128 +++++++++++++++++-
77
include/hw/ssi/npcm_pspi.h | 53 ++++++++
78
linux-user/user-internals.h | 2 +-
79
target/arm/cpregs.h | 98 ++++++++++++++
80
target/arm/cpu.h | 228 ++-------------------------------
81
target/arm/internals.h | 14 --
82
hw/arm/npcm7xx.c | 25 +++-
83
hw/arm/smmu-common.c | 4 +-
84
hw/arm/smmuv3.c | 43 ++++++-
85
hw/arm/virt.c | 10 +-
86
hw/intc/armv7m_nvic.c | 38 ++----
87
hw/ssi/npcm_pspi.c | 221 ++++++++++++++++++++++++++++++++
88
linux-user/arm/cpu_loop.c | 4 +-
89
target/arm/cpu.c | 5 +-
90
target/arm/cpu_tcg.c | 3 +
91
target/arm/helper.c | 31 +++--
92
target/arm/m_helper.c | 86 +++++++------
93
target/arm/machine.c | 18 +--
94
tests/qtest/arm-cpu-features.c | 28 ++--
95
hw/arm/Kconfig | 1 +
96
hw/ssi/meson.build | 2 +-
97
hw/ssi/trace-events | 5 +
98
tests/avocado/avocado_qemu/__init__.py | 4 +
99
tests/avocado/boot_linux.py | 48 ++-----
100
tests/avocado/boot_linux_console.py | 1 +
101
tests/avocado/machine_aarch64_virt.py | 63 ++++++++-
102
tests/avocado/reverse_debugging.py | 8 ++
103
tests/qtest/meson.build | 4 +-
104
34 files changed, 798 insertions(+), 399 deletions(-)
105
create mode 100644 include/hw/ssi/npcm_pspi.h
106
create mode 100644 hw/ssi/npcm_pspi.c
107
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
These commands got introduced by Spec v3
3
Manually convert to OBJECT_DECLARE_SIMPLE_TYPE() macro,
4
(see 0c3fb03f7ec and 4481bbc79d2).
4
similarly to automatic conversion from commit 8063396bf3
5
("Use OBJECT_DECLARE_SIMPLE_TYPE when possible").
5
6
6
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Message-id: 20180607180641.874-7-f4bug@amsat.org
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20230206223502.25122-2-philmd@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
---
11
hw/sd/sd.c | 6 ++++++
12
include/hw/intc/armv7m_nvic.h | 5 +----
12
1 file changed, 6 insertions(+)
13
1 file changed, 1 insertion(+), 4 deletions(-)
13
14
14
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
15
diff --git a/include/hw/intc/armv7m_nvic.h b/include/hw/intc/armv7m_nvic.h
15
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/sd/sd.c
17
--- a/include/hw/intc/armv7m_nvic.h
17
+++ b/hw/sd/sd.c
18
+++ b/include/hw/intc/armv7m_nvic.h
18
@@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
19
@@ -XXX,XX +XXX,XX @@
19
break;
20
#include "qom/object.h"
20
21
21
case 19: /* CMD19: SEND_TUNING_BLOCK (SD) */
22
#define TYPE_NVIC "armv7m_nvic"
22
+ if (sd->spec_version < SD_PHY_SPECv3_01_VERS) {
23
-
23
+ break;
24
-typedef struct NVICState NVICState;
24
+ }
25
-DECLARE_INSTANCE_CHECKER(NVICState, NVIC,
25
if (sd->state == sd_transfer_state) {
26
- TYPE_NVIC)
26
sd->state = sd_sendingdata_state;
27
+OBJECT_DECLARE_SIMPLE_TYPE(NVICState, NVIC)
27
sd->data_offset = 0;
28
28
@@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
29
/* Highest permitted number of exceptions (architectural limit) */
29
break;
30
#define NVIC_MAX_VECTORS 512
30
31
case 23: /* CMD23: SET_BLOCK_COUNT */
32
+ if (sd->spec_version < SD_PHY_SPECv3_01_VERS) {
33
+ break;
34
+ }
35
switch (sd->state) {
36
case sd_transfer_state:
37
sd->multi_blk_cnt = req.arg;
38
--
31
--
39
2.17.1
32
2.34.1
40
33
41
34
diff view generated by jsdifflib
1
From: Cédric Le Goater <clg@kaod.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Signed-off-by: Cédric Le Goater <clg@kaod.org>
3
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
Message-id: 20180530064049.27976-2-clg@kaod.org
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20230206223502.25122-3-philmd@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
---
8
hw/arm/aspeed.c | 3 ---
9
target/arm/m_helper.c | 11 ++++++++---
9
1 file changed, 3 deletions(-)
10
1 file changed, 8 insertions(+), 3 deletions(-)
10
11
11
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
12
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
12
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/arm/aspeed.c
14
--- a/target/arm/m_helper.c
14
+++ b/hw/arm/aspeed.c
15
+++ b/target/arm/m_helper.c
15
@@ -XXX,XX +XXX,XX @@ static void palmetto_bmc_class_init(ObjectClass *oc, void *data)
16
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
16
mc->no_floppy = 1;
17
return 0;
17
mc->no_cdrom = 1;
18
mc->no_parallel = 1;
19
- mc->ignore_memory_transaction_failures = true;
20
}
18
}
21
19
22
static const TypeInfo palmetto_bmc_type = {
20
-#else
23
@@ -XXX,XX +XXX,XX @@ static void ast2500_evb_class_init(ObjectClass *oc, void *data)
21
+ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate)
24
mc->no_floppy = 1;
22
+{
25
mc->no_cdrom = 1;
23
+ return ARMMMUIdx_MUser;
26
mc->no_parallel = 1;
24
+}
27
- mc->ignore_memory_transaction_failures = true;
25
+
26
+#else /* !CONFIG_USER_ONLY */
27
28
/*
29
* What kind of stack write are we doing? This affects how exceptions
30
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
31
return tt_resp;
28
}
32
}
29
33
30
static const TypeInfo ast2500_evb_type = {
34
-#endif /* !CONFIG_USER_ONLY */
31
@@ -XXX,XX +XXX,XX @@ static void romulus_bmc_class_init(ObjectClass *oc, void *data)
35
-
32
mc->no_floppy = 1;
36
ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env,
33
mc->no_cdrom = 1;
37
bool secstate, bool priv, bool negpri)
34
mc->no_parallel = 1;
38
{
35
- mc->ignore_memory_transaction_failures = true;
39
@@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate)
40
41
return arm_v7m_mmu_idx_for_secstate_and_priv(env, secstate, priv);
36
}
42
}
37
43
+
38
static const TypeInfo romulus_bmc_type = {
44
+#endif /* !CONFIG_USER_ONLY */
39
--
45
--
40
2.17.1
46
2.34.1
41
47
42
48
diff view generated by jsdifflib
1
From: Thomas Huth <thuth@redhat.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
It has been marked as deprecated since QEMU v2.11, so it is time to
3
arm_v7m_mmu_idx_all() and arm_v7m_mmu_idx_for_secstate_and_priv()
4
remove this now. The xlnx-zcu102 machine is very much the same and
4
are only used for system emulation in m_helper.c.
5
can be used as a replacement instead.
5
Move the definitions to avoid prototype forward declarations.
6
6
7
Signed-off-by: Thomas Huth <thuth@redhat.com>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230206223502.25122-4-philmd@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
---
11
hw/arm/xlnx-zcu102.c | 62 ++------------------------------------------
12
target/arm/internals.h | 14 --------
12
qemu-doc.texi | 5 ----
13
target/arm/m_helper.c | 74 +++++++++++++++++++++---------------------
13
2 files changed, 2 insertions(+), 65 deletions(-)
14
2 files changed, 37 insertions(+), 51 deletions(-)
14
15
15
diff --git a/hw/arm/xlnx-zcu102.c b/hw/arm/xlnx-zcu102.c
16
diff --git a/target/arm/internals.h b/target/arm/internals.h
16
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/xlnx-zcu102.c
18
--- a/target/arm/internals.h
18
+++ b/hw/arm/xlnx-zcu102.c
19
+++ b/target/arm/internals.h
19
@@ -XXX,XX +XXX,XX @@ typedef struct XlnxZCU102 {
20
@@ -XXX,XX +XXX,XX @@ static inline ARMMMUIdx core_to_aa64_mmu_idx(int mmu_idx)
20
#define ZCU102_MACHINE(obj) \
21
21
OBJECT_CHECK(XlnxZCU102, (obj), TYPE_ZCU102_MACHINE)
22
int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx);
22
23
23
-#define TYPE_EP108_MACHINE MACHINE_TYPE_NAME("xlnx-ep108")
24
-/*
24
-#define EP108_MACHINE(obj) \
25
- * Return the MMU index for a v7M CPU with all relevant information
25
- OBJECT_CHECK(XlnxZCU102, (obj), TYPE_EP108_MACHINE)
26
- * manually specified.
27
- */
28
-ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env,
29
- bool secstate, bool priv, bool negpri);
26
-
30
-
27
static struct arm_boot_info xlnx_zcu102_binfo;
31
-/*
28
32
- * Return the MMU index for a v7M CPU in the specified security and
29
static bool zcu102_get_secure(Object *obj, Error **errp)
33
- * privilege state.
30
@@ -XXX,XX +XXX,XX @@ static void zcu102_set_virt(Object *obj, bool value, Error **errp)
34
- */
31
s->virt = value;
35
-ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,
36
- bool secstate, bool priv);
37
-
38
/* Return the MMU index for a v7M CPU in the specified security state */
39
ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate);
40
41
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
42
index XXXXXXX..XXXXXXX 100644
43
--- a/target/arm/m_helper.c
44
+++ b/target/arm/m_helper.c
45
@@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate)
46
47
#else /* !CONFIG_USER_ONLY */
48
49
+static ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env,
50
+ bool secstate, bool priv, bool negpri)
51
+{
52
+ ARMMMUIdx mmu_idx = ARM_MMU_IDX_M;
53
+
54
+ if (priv) {
55
+ mmu_idx |= ARM_MMU_IDX_M_PRIV;
56
+ }
57
+
58
+ if (negpri) {
59
+ mmu_idx |= ARM_MMU_IDX_M_NEGPRI;
60
+ }
61
+
62
+ if (secstate) {
63
+ mmu_idx |= ARM_MMU_IDX_M_S;
64
+ }
65
+
66
+ return mmu_idx;
67
+}
68
+
69
+static ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,
70
+ bool secstate, bool priv)
71
+{
72
+ bool negpri = armv7m_nvic_neg_prio_requested(env->nvic, secstate);
73
+
74
+ return arm_v7m_mmu_idx_all(env, secstate, priv, negpri);
75
+}
76
+
77
+/* Return the MMU index for a v7M CPU in the specified security state */
78
+ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate)
79
+{
80
+ bool priv = arm_v7m_is_handler_mode(env) ||
81
+ !(env->v7m.control[secstate] & 1);
82
+
83
+ return arm_v7m_mmu_idx_for_secstate_and_priv(env, secstate, priv);
84
+}
85
+
86
/*
87
* What kind of stack write are we doing? This affects how exceptions
88
* generated during the stacking are treated.
89
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
90
return tt_resp;
32
}
91
}
33
92
34
-static void xlnx_zynqmp_init(XlnxZCU102 *s, MachineState *machine)
93
-ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env,
35
+static void xlnx_zcu102_init(MachineState *machine)
94
- bool secstate, bool priv, bool negpri)
36
{
37
+ XlnxZCU102 *s = ZCU102_MACHINE(machine);
38
int i;
39
uint64_t ram_size = machine->ram_size;
40
41
@@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_init(XlnxZCU102 *s, MachineState *machine)
42
arm_load_kernel(s->soc.boot_cpu_ptr, &xlnx_zcu102_binfo);
43
}
44
45
-static void xlnx_ep108_init(MachineState *machine)
46
-{
95
-{
47
- XlnxZCU102 *s = EP108_MACHINE(machine);
96
- ARMMMUIdx mmu_idx = ARM_MMU_IDX_M;
48
-
97
-
49
- if (!qtest_enabled()) {
98
- if (priv) {
50
- info_report("The Xilinx EP108 machine is deprecated, please use the "
99
- mmu_idx |= ARM_MMU_IDX_M_PRIV;
51
- "ZCU102 machine (which has the same features) instead.");
52
- }
100
- }
53
-
101
-
54
- xlnx_zynqmp_init(s, machine);
102
- if (negpri) {
103
- mmu_idx |= ARM_MMU_IDX_M_NEGPRI;
104
- }
105
-
106
- if (secstate) {
107
- mmu_idx |= ARM_MMU_IDX_M_S;
108
- }
109
-
110
- return mmu_idx;
55
-}
111
-}
56
-
112
-
57
-static void xlnx_ep108_machine_instance_init(Object *obj)
113
-ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,
114
- bool secstate, bool priv)
58
-{
115
-{
59
- XlnxZCU102 *s = EP108_MACHINE(obj);
116
- bool negpri = armv7m_nvic_neg_prio_requested(env->nvic, secstate);
60
-
117
-
61
- /* EP108, we don't support setting secure or virt */
118
- return arm_v7m_mmu_idx_all(env, secstate, priv, negpri);
62
- s->secure = false;
63
- s->virt = false;
64
-}
119
-}
65
-
120
-
66
-static void xlnx_ep108_machine_class_init(ObjectClass *oc, void *data)
121
-/* Return the MMU index for a v7M CPU in the specified security state */
122
-ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate)
67
-{
123
-{
68
- MachineClass *mc = MACHINE_CLASS(oc);
124
- bool priv = arm_v7m_is_handler_mode(env) ||
125
- !(env->v7m.control[secstate] & 1);
69
-
126
-
70
- mc->desc = "Xilinx ZynqMP EP108 board (Deprecated, please use xlnx-zcu102)";
127
- return arm_v7m_mmu_idx_for_secstate_and_priv(env, secstate, priv);
71
- mc->init = xlnx_ep108_init;
72
- mc->block_default_type = IF_IDE;
73
- mc->units_per_default_bus = 1;
74
- mc->ignore_memory_transaction_failures = true;
75
- mc->max_cpus = XLNX_ZYNQMP_NUM_APU_CPUS + XLNX_ZYNQMP_NUM_RPU_CPUS;
76
- mc->default_cpus = XLNX_ZYNQMP_NUM_APU_CPUS;
77
-}
128
-}
78
-
129
-
79
-static const TypeInfo xlnx_ep108_machine_init_typeinfo = {
130
#endif /* !CONFIG_USER_ONLY */
80
- .name = MACHINE_TYPE_NAME("xlnx-ep108"),
81
- .parent = TYPE_MACHINE,
82
- .class_init = xlnx_ep108_machine_class_init,
83
- .instance_init = xlnx_ep108_machine_instance_init,
84
- .instance_size = sizeof(XlnxZCU102),
85
-};
86
-
87
-static void xlnx_ep108_machine_init_register_types(void)
88
-{
89
- type_register_static(&xlnx_ep108_machine_init_typeinfo);
90
-}
91
-
92
-static void xlnx_zcu102_init(MachineState *machine)
93
-{
94
- XlnxZCU102 *s = ZCU102_MACHINE(machine);
95
-
96
- xlnx_zynqmp_init(s, machine);
97
-}
98
-
99
static void xlnx_zcu102_machine_instance_init(Object *obj)
100
{
101
XlnxZCU102 *s = ZCU102_MACHINE(obj);
102
@@ -XXX,XX +XXX,XX @@ static void xlnx_zcu102_machine_init_register_types(void)
103
}
104
105
type_init(xlnx_zcu102_machine_init_register_types)
106
-type_init(xlnx_ep108_machine_init_register_types)
107
diff --git a/qemu-doc.texi b/qemu-doc.texi
108
index XXXXXXX..XXXXXXX 100644
109
--- a/qemu-doc.texi
110
+++ b/qemu-doc.texi
111
@@ -XXX,XX +XXX,XX @@ support page sizes < 4096 any longer.
112
113
@section System emulator machines
114
115
-@subsection Xilinx EP108 (since 2.11.0)
116
-
117
-The ``xlnx-ep108'' machine has been replaced by the ``xlnx-zcu102'' machine.
118
-The ``xlnx-zcu102'' machine has the same features and capabilites in QEMU.
119
-
120
@section Block device options
121
122
@subsection "backing": "" (since 2.12.0)
123
--
131
--
124
2.17.1
132
2.34.1
125
133
126
134
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
3
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
4
Message-id: 20180606152128.449-3-f4bug@amsat.org
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Message-id: 20230206223502.25122-5-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
hw/char/digic-uart.c | 4 ++--
8
target/arm/helper.c | 12 ++++++++++--
9
hw/timer/digic-timer.c | 4 ++--
9
1 file changed, 10 insertions(+), 2 deletions(-)
10
2 files changed, 4 insertions(+), 4 deletions(-)
11
10
12
diff --git a/hw/char/digic-uart.c b/hw/char/digic-uart.c
11
diff --git a/target/arm/helper.c b/target/arm/helper.c
13
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/char/digic-uart.c
13
--- a/target/arm/helper.c
15
+++ b/hw/char/digic-uart.c
14
+++ b/target/arm/helper.c
16
@@ -XXX,XX +XXX,XX @@ static uint64_t digic_uart_read(void *opaque, hwaddr addr,
15
@@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu)
17
default:
18
qemu_log_mask(LOG_UNIMP,
19
"digic-uart: read access to unknown register 0x"
20
- TARGET_FMT_plx, addr << 2);
21
+ TARGET_FMT_plx "\n", addr << 2);
22
}
23
24
return ret;
25
@@ -XXX,XX +XXX,XX @@ static void digic_uart_write(void *opaque, hwaddr addr, uint64_t value,
26
default:
27
qemu_log_mask(LOG_UNIMP,
28
"digic-uart: write access to unknown register 0x"
29
- TARGET_FMT_plx, addr << 2);
30
+ TARGET_FMT_plx "\n", addr << 2);
31
}
16
}
32
}
17
}
33
18
34
diff --git a/hw/timer/digic-timer.c b/hw/timer/digic-timer.c
19
+#ifndef CONFIG_USER_ONLY
35
index XXXXXXX..XXXXXXX 100644
20
/*
36
--- a/hw/timer/digic-timer.c
21
* We don't know until after realize whether there's a GICv3
37
+++ b/hw/timer/digic-timer.c
22
* attached, and that is what registers the gicv3 sysregs.
38
@@ -XXX,XX +XXX,XX @@ static uint64_t digic_timer_read(void *opaque, hwaddr offset, unsigned size)
23
@@ -XXX,XX +XXX,XX @@ static uint64_t id_pfr1_read(CPUARMState *env, const ARMCPRegInfo *ri)
39
default:
24
return pfr1;
40
qemu_log_mask(LOG_UNIMP,
41
"digic-timer: read access to unknown register 0x"
42
- TARGET_FMT_plx, offset);
43
+ TARGET_FMT_plx "\n", offset);
44
}
45
46
return ret;
47
@@ -XXX,XX +XXX,XX @@ static void digic_timer_write(void *opaque, hwaddr offset,
48
default:
49
qemu_log_mask(LOG_UNIMP,
50
"digic-timer: read access to unknown register 0x"
51
- TARGET_FMT_plx, offset);
52
+ TARGET_FMT_plx "\n", offset);
53
}
54
}
25
}
55
26
27
-#ifndef CONFIG_USER_ONLY
28
static uint64_t id_aa64pfr0_read(CPUARMState *env, const ARMCPRegInfo *ri)
29
{
30
ARMCPU *cpu = env_archcpu(env);
31
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
32
.opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 1,
33
.access = PL1_R, .type = ARM_CP_NO_RAW,
34
.accessfn = access_aa32_tid3,
35
+#ifdef CONFIG_USER_ONLY
36
+ .type = ARM_CP_CONST,
37
+ .resetvalue = cpu->isar.id_pfr1,
38
+#else
39
+ .type = ARM_CP_NO_RAW,
40
+ .accessfn = access_aa32_tid3,
41
.readfn = id_pfr1_read,
42
- .writefn = arm_cp_write_ignore },
43
+ .writefn = arm_cp_write_ignore
44
+#endif
45
+ },
46
{ .name = "ID_DFR0", .state = ARM_CP_STATE_BOTH,
47
.opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 2,
48
.access = PL1_R, .type = ARM_CP_CONST,
56
--
49
--
57
2.17.1
50
2.34.1
58
51
59
52
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
3
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
4
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
Message-id: 20180607180641.874-6-f4bug@amsat.org
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20230206223502.25122-6-philmd@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
---
8
include/hw/sd/sd.h | 1 +
9
linux-user/user-internals.h | 2 +-
9
hw/sd/sd.c | 7 +++++--
10
target/arm/cpu.h | 2 +-
10
2 files changed, 6 insertions(+), 2 deletions(-)
11
linux-user/arm/cpu_loop.c | 4 ++--
12
3 files changed, 4 insertions(+), 4 deletions(-)
11
13
12
diff --git a/include/hw/sd/sd.h b/include/hw/sd/sd.h
14
diff --git a/linux-user/user-internals.h b/linux-user/user-internals.h
13
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
14
--- a/include/hw/sd/sd.h
16
--- a/linux-user/user-internals.h
15
+++ b/include/hw/sd/sd.h
17
+++ b/linux-user/user-internals.h
16
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@ void print_termios(void *arg);
17
enum SDPhySpecificationVersion {
19
#ifdef TARGET_ARM
18
SD_PHY_SPECv1_10_VERS = 1,
20
static inline int regpairs_aligned(CPUArchState *cpu_env, int num)
19
SD_PHY_SPECv2_00_VERS = 2,
21
{
20
+ SD_PHY_SPECv3_01_VERS = 3,
22
- return cpu_env->eabi == 1;
21
};
23
+ return cpu_env->eabi;
22
24
}
23
typedef enum {
25
#elif defined(TARGET_MIPS) && defined(TARGET_ABI_MIPSO32)
24
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
26
static inline int regpairs_aligned(CPUArchState *cpu_env, int num) { return 1; }
27
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
25
index XXXXXXX..XXXXXXX 100644
28
index XXXXXXX..XXXXXXX 100644
26
--- a/hw/sd/sd.c
29
--- a/target/arm/cpu.h
27
+++ b/hw/sd/sd.c
30
+++ b/target/arm/cpu.h
28
@@ -XXX,XX +XXX,XX @@ static void sd_set_scr(SDState *sd)
31
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
29
if (sd->spec_version == SD_PHY_SPECv1_10_VERS) {
32
30
sd->scr[0] |= 1; /* Spec Version 1.10 */
33
#if defined(CONFIG_USER_ONLY)
31
} else {
34
/* For usermode syscall translation. */
32
- sd->scr[0] |= 2; /* Spec Version 2.00 */
35
- int eabi;
33
+ sd->scr[0] |= 2; /* Spec Version 2.00 or Version 3.0X */
36
+ bool eabi;
34
}
37
#endif
35
sd->scr[1] = (2 << 4) /* SDSC Card (Security Version 1.01) */
38
36
| 0b0101; /* 1-bit or 4-bit width bus modes */
39
struct CPUBreakpoint *cpu_breakpoint[16];
37
sd->scr[2] = 0x00; /* Extended Security is not supported. */
40
diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c
38
+ if (sd->spec_version >= SD_PHY_SPECv3_01_VERS) {
41
index XXXXXXX..XXXXXXX 100644
39
+ sd->scr[2] |= 1 << 7; /* Spec Version 3.0X */
42
--- a/linux-user/arm/cpu_loop.c
40
+ }
43
+++ b/linux-user/arm/cpu_loop.c
41
sd->scr[3] = 0x00;
44
@@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env)
42
/* reserved for manufacturer usage */
45
break;
43
sd->scr[4] = 0x00;
46
case EXCP_SWI:
44
@@ -XXX,XX +XXX,XX @@ static void sd_realize(DeviceState *dev, Error **errp)
47
{
45
48
- env->eabi = 1;
46
switch (sd->spec_version) {
49
+ env->eabi = true;
47
case SD_PHY_SPECv1_10_VERS
50
/* system call */
48
- ... SD_PHY_SPECv2_00_VERS:
51
if (env->thumb) {
49
+ ... SD_PHY_SPECv3_01_VERS:
52
/* Thumb is always EABI style with syscall number in r7 */
50
break;
53
@@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env)
51
default:
54
* > 0xfffff and are handled below as out-of-range.
52
error_setg(errp, "Invalid SD card Spec version: %u", sd->spec_version);
55
*/
56
n ^= ARM_SYSCALL_BASE;
57
- env->eabi = 0;
58
+ env->eabi = false;
59
}
60
}
61
53
--
62
--
54
2.17.1
63
2.34.1
55
64
56
65
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
CMD8 is "Reserved" in Spec v1.10.
3
Although the 'eabi' field is only used in user emulation where
4
CPU reset doesn't occur, it doesn't belong to the area to reset.
5
Move it after the 'end_reset_fields' for consistency.
4
6
5
Spec v2.00 introduces the SEND_IF_COND command:
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
6.4.1 Power Up
9
Message-id: 20230206223502.25122-7-philmd@linaro.org
8
9
CMD8 is newly added in the Physical Layer Specification Version
10
2.00 to support multiple voltage ranges and used to check whether
11
the card supports supplied voltage. The version 2.00 or later host
12
shall issue CMD8 and verify voltage before card initialization.
13
The host that does not support CMD8 shall supply high voltage range.
14
15
Message-Id: 201204252110.20873.paul@codesourcery.com
16
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
17
Message-id: 20180607180641.874-5-f4bug@amsat.org
18
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
---
11
---
21
hw/sd/sd.c | 4 +++-
12
target/arm/cpu.h | 9 ++++-----
22
1 file changed, 3 insertions(+), 1 deletion(-)
13
1 file changed, 4 insertions(+), 5 deletions(-)
23
14
24
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
15
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
25
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
26
--- a/hw/sd/sd.c
17
--- a/target/arm/cpu.h
27
+++ b/hw/sd/sd.c
18
+++ b/target/arm/cpu.h
28
@@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
19
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
29
break;
20
ARMVectorReg zarray[ARM_MAX_VQ * 16];
30
21
#endif
31
case 8:    /* CMD8: SEND_IF_COND */
22
32
- /* Physical Layer Specification Version 2.00 command */
23
-#if defined(CONFIG_USER_ONLY)
33
+ if (sd->spec_version < SD_PHY_SPECv2_00_VERS) {
24
- /* For usermode syscall translation. */
34
+ break;
25
- bool eabi;
35
+ }
26
-#endif
36
if (sd->state != sd_idle_state) {
27
-
37
break;
28
struct CPUBreakpoint *cpu_breakpoint[16];
38
}
29
struct CPUWatchpoint *cpu_watchpoint[16];
30
31
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
32
const struct arm_boot_info *boot_info;
33
/* Store GICv3CPUState to access from this struct */
34
void *gicv3state;
35
+#if defined(CONFIG_USER_ONLY)
36
+ /* For usermode syscall translation. */
37
+ bool eabi;
38
+#endif /* CONFIG_USER_ONLY */
39
40
#ifdef TARGET_TAGGED_ADDRESSES
41
/* Linux syscall tagged address support */
39
--
42
--
40
2.17.1
43
2.34.1
41
44
42
45
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
As of this commit, the Spec v1 is not working, and all controllers
3
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
4
expect the cards to be conformant to Spec v2.
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
5
Message-id: 20230206223502.25122-8-philmd@linaro.org
6
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Message-id: 20180607180641.874-4-f4bug@amsat.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
7
---
11
include/hw/sd/sd.h | 5 +++++
8
target/arm/cpu.h | 3 ++-
12
hw/sd/sd.c | 23 ++++++++++++++++++++---
9
1 file changed, 2 insertions(+), 1 deletion(-)
13
2 files changed, 25 insertions(+), 3 deletions(-)
14
10
15
diff --git a/include/hw/sd/sd.h b/include/hw/sd/sd.h
11
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
16
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/sd/sd.h
13
--- a/target/arm/cpu.h
18
+++ b/include/hw/sd/sd.h
14
+++ b/target/arm/cpu.h
19
@@ -XXX,XX +XXX,XX @@
15
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
20
#define APP_CMD            (1 << 5)
16
21
#define AKE_SEQ_ERROR        (1 << 3)
17
void *nvic;
22
18
const struct arm_boot_info *boot_info;
23
+enum SDPhySpecificationVersion {
19
+#if !defined(CONFIG_USER_ONLY)
24
+ SD_PHY_SPECv1_10_VERS = 1,
20
/* Store GICv3CPUState to access from this struct */
25
+ SD_PHY_SPECv2_00_VERS = 2,
21
void *gicv3state;
26
+};
22
-#if defined(CONFIG_USER_ONLY)
27
+
23
+#else /* CONFIG_USER_ONLY */
28
typedef enum {
24
/* For usermode syscall translation. */
29
SD_VOLTAGE_0_4V = 400, /* currently not supported */
25
bool eabi;
30
SD_VOLTAGE_1_8V = 1800,
26
#endif /* CONFIG_USER_ONLY */
31
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/hw/sd/sd.c
34
+++ b/hw/sd/sd.c
35
@@ -XXX,XX +XXX,XX @@
36
/*
37
* SD Memory Card emulation as defined in the "SD Memory Card Physical
38
- * layer specification, Version 1.10."
39
+ * layer specification, Version 2.00."
40
*
41
* Copyright (c) 2006 Andrzej Zaborowski <balrog@zabor.org>
42
* Copyright (c) 2007 CodeSourcery
43
+ * Copyright (c) 2018 Philippe Mathieu-Daudé <f4bug@amsat.org>
44
*
45
* Redistribution and use in source and binary forms, with or without
46
* modification, are permitted provided that the following conditions
47
@@ -XXX,XX +XXX,XX @@ struct SDState {
48
uint8_t sd_status[64];
49
50
/* Configurable properties */
51
+ uint8_t spec_version;
52
BlockBackend *blk;
53
bool spi;
54
55
@@ -XXX,XX +XXX,XX @@ static void sd_ocr_powerup(void *opaque)
56
57
static void sd_set_scr(SDState *sd)
58
{
59
- sd->scr[0] = (0 << 4) /* SCR structure version 1.0 */
60
- | 1; /* Spec Version 1.10 */
61
+ sd->scr[0] = 0 << 4; /* SCR structure version 1.0 */
62
+ if (sd->spec_version == SD_PHY_SPECv1_10_VERS) {
63
+ sd->scr[0] |= 1; /* Spec Version 1.10 */
64
+ } else {
65
+ sd->scr[0] |= 2; /* Spec Version 2.00 */
66
+ }
67
sd->scr[1] = (2 << 4) /* SDSC Card (Security Version 1.01) */
68
| 0b0101; /* 1-bit or 4-bit width bus modes */
69
sd->scr[2] = 0x00; /* Extended Security is not supported. */
70
@@ -XXX,XX +XXX,XX @@ static void sd_realize(DeviceState *dev, Error **errp)
71
72
sd->proto_name = sd->spi ? "SPI" : "SD";
73
74
+ switch (sd->spec_version) {
75
+ case SD_PHY_SPECv1_10_VERS
76
+ ... SD_PHY_SPECv2_00_VERS:
77
+ break;
78
+ default:
79
+ error_setg(errp, "Invalid SD card Spec version: %u", sd->spec_version);
80
+ return;
81
+ }
82
+
83
if (sd->blk && blk_is_read_only(sd->blk)) {
84
error_setg(errp, "Cannot use read-only drive as SD card");
85
return;
86
@@ -XXX,XX +XXX,XX @@ static void sd_realize(DeviceState *dev, Error **errp)
87
}
88
89
static Property sd_properties[] = {
90
+ DEFINE_PROP_UINT8("spec_version", SDState,
91
+ spec_version, SD_PHY_SPECv2_00_VERS),
92
DEFINE_PROP_DRIVE("drive", SDState, blk),
93
/* We do not model the chip select pin, so allow the board to select
94
* whether card should be in SSI or MMC/SD mode. It is also up to the
95
--
27
--
96
2.17.1
28
2.34.1
97
29
98
30
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
From the "Physical Layer Simplified Specification Version 1.10"
3
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
4
Chapter 7.3 "SPI Mode Transaction Packets"
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
Table 57: "Commands and arguments"
5
Message-id: 20230206223502.25122-9-philmd@linaro.org
6
7
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Acked-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-id: 20180607180641.874-3-f4bug@amsat.org
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
7
---
13
hw/sd/sd.c | 14 --------------
8
target/arm/cpu.h | 2 +-
14
1 file changed, 14 deletions(-)
9
1 file changed, 1 insertion(+), 1 deletion(-)
15
10
16
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
11
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
17
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/sd/sd.c
13
--- a/target/arm/cpu.h
19
+++ b/hw/sd/sd.c
14
+++ b/target/arm/cpu.h
20
@@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
15
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
21
return sd_illegal;
16
} sau;
22
17
23
case 6:    /* CMD6: SWITCH_FUNCTION */
18
void *nvic;
24
- if (sd->spi)
19
- const struct arm_boot_info *boot_info;
25
- goto bad_cmd;
20
#if !defined(CONFIG_USER_ONLY)
26
switch (sd->mode) {
21
+ const struct arm_boot_info *boot_info;
27
case sd_data_transfer_mode:
22
/* Store GICv3CPUState to access from this struct */
28
sd_function_switch(sd, req.arg);
23
void *gicv3state;
29
@@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
24
#else /* CONFIG_USER_ONLY */
30
31
/* Block write commands (Class 4) */
32
case 24:    /* CMD24: WRITE_SINGLE_BLOCK */
33
- if (sd->spi) {
34
- goto unimplemented_spi_cmd;
35
- }
36
switch (sd->state) {
37
case sd_transfer_state:
38
/* Writing in SPI mode not implemented. */
39
@@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
40
break;
41
42
case 25:    /* CMD25: WRITE_MULTIPLE_BLOCK */
43
- if (sd->spi) {
44
- goto unimplemented_spi_cmd;
45
- }
46
switch (sd->state) {
47
case sd_transfer_state:
48
/* Writing in SPI mode not implemented. */
49
@@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
50
break;
51
52
case 27:    /* CMD27: PROGRAM_CSD */
53
- if (sd->spi) {
54
- goto unimplemented_spi_cmd;
55
- }
56
switch (sd->state) {
57
case sd_transfer_state:
58
sd->state = sd_receivingdata_state;
59
@@ -XXX,XX +XXX,XX @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
60
61
/* Lock card commands (Class 7) */
62
case 42:    /* CMD42: LOCK_UNLOCK */
63
- if (sd->spi) {
64
- goto unimplemented_spi_cmd;
65
- }
66
switch (sd->state) {
67
case sd_transfer_state:
68
sd->state = sd_receivingdata_state;
69
--
25
--
70
2.17.1
26
2.34.1
71
27
72
28
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
The initial implementation is based on the Specs v1.10 (see a1bb27b1e98).
3
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
However the SCR is anouncing the card being v1.01.
5
Message-id: 20230206223502.25122-10-philmd@linaro.org
6
7
The new chapters added in version 1.10 are:
8
9
4.3.10 Switch function command
10
11
Switch function command (CMD6) 1 is used to switch or expand
12
memory card functions. [...]
13
This is a new feature, introduced in SD physical Layer
14
Specification Version 1.10. Therefore, cards that are
15
compatible with earlier versions of the spec do not support
16
it. The host shall check the "SD_SPEC" field in the SCR
17
register to recognize what version of the spec the card
18
complies with before using CMD6. It is mandatory for SD
19
memory card of Ver1.10 to support CMD6.
20
21
4.3.11 High-Speed mode (25MB/sec interface speed)
22
23
Though the Rev 1.01 SD memory card supports up to 12.5MB/sec
24
interface speed, the speed of 25MB/sec is necessary to support
25
increasing performance needs of the host and because of memory
26
size which continues to grow.
27
To achieve 25MB/sec interface speed, clock rate is increased to
28
50MHz and CLK/CMD/DAT signal timing and circuit conditions are
29
reconsidered and changed from Physical Layer Specification
30
Version 1.01.
31
32
4.3.12 Command system (This chapter is newly added in version 1.10)
33
34
SD commands CMD34-37, CMD50, CMD57 are reserved for SD command
35
system expansion via the switch command.
36
[These commands] will be considered as illegal commands (as
37
defined in revision 1.01 of the SD physical layer specification).
38
39
The SWITCH_FUNCTION is implemented since the first commit, a1bb27b1e98.
40
41
The 25MB/sec High-Speed mode was already updated in d7ecb867529.
42
43
The current implementation does not implements CMD34-37, CMD50 and
44
CMD57, thus these commands already return ILLEGAL.
45
46
With this patch, the SCR register now matches the description of the header:
47
48
* SD Memory Card emulation as defined in the "SD Memory Card Physical
49
* layer specification, Version 1.10."
50
51
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
52
Message-id: 20180607180641.874-2-f4bug@amsat.org
53
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
54
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
55
---
7
---
56
hw/sd/sd.c | 4 ++--
8
target/arm/cpu.h | 2 +-
57
1 file changed, 2 insertions(+), 2 deletions(-)
9
1 file changed, 1 insertion(+), 1 deletion(-)
58
10
59
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
11
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
60
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
61
--- a/hw/sd/sd.c
13
--- a/target/arm/cpu.h
62
+++ b/hw/sd/sd.c
14
+++ b/target/arm/cpu.h
63
@@ -XXX,XX +XXX,XX @@ static void sd_ocr_powerup(void *opaque)
15
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
64
16
uint32_t ctrl;
65
static void sd_set_scr(SDState *sd)
17
} sau;
66
{
18
67
- sd->scr[0] = (0 << 4) /* SCR version 1.0 */
19
- void *nvic;
68
- | 0; /* Spec Versions 1.0 and 1.01 */
20
#if !defined(CONFIG_USER_ONLY)
69
+ sd->scr[0] = (0 << 4) /* SCR structure version 1.0 */
21
+ void *nvic;
70
+ | 1; /* Spec Version 1.10 */
22
const struct arm_boot_info *boot_info;
71
sd->scr[1] = (2 << 4) /* SDSC Card (Security Version 1.01) */
23
/* Store GICv3CPUState to access from this struct */
72
| 0b0101; /* 1-bit or 4-bit width bus modes */
24
void *gicv3state;
73
sd->scr[2] = 0x00; /* Extended Security is not supported. */
74
--
25
--
75
2.17.1
26
2.34.1
76
27
77
28
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
3
There is no point in using a void pointer to access the NVIC.
4
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
4
Use the real type to avoid casting it while debugging.
5
Message-id: 20180606152128.449-12-f4bug@amsat.org
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20230206223502.25122-11-philmd@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
10
---
8
target/xtensa/translate.c | 6 +++---
11
target/arm/cpu.h | 46 ++++++++++++++++++++++---------------------
9
1 file changed, 3 insertions(+), 3 deletions(-)
12
hw/intc/armv7m_nvic.c | 38 ++++++++++++-----------------------
10
13
target/arm/cpu.c | 1 +
11
diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c
14
target/arm/m_helper.c | 2 +-
15
4 files changed, 39 insertions(+), 48 deletions(-)
16
17
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
12
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
13
--- a/target/xtensa/translate.c
19
--- a/target/arm/cpu.h
14
+++ b/target/xtensa/translate.c
20
+++ b/target/arm/cpu.h
15
@@ -XXX,XX +XXX,XX @@ static void translate_rur(DisasContext *dc, const uint32_t arg[],
21
@@ -XXX,XX +XXX,XX @@ typedef struct CPUARMTBFlags {
16
if (uregnames[par[0]].name) {
22
17
tcg_gen_mov_i32(cpu_R[arg[0]], cpu_UR[par[0]]);
23
typedef struct ARMMMUFaultInfo ARMMMUFaultInfo;
18
} else {
24
19
- qemu_log_mask(LOG_UNIMP, "RUR %d not implemented, ", par[0]);
25
+typedef struct NVICState NVICState;
20
+ qemu_log_mask(LOG_UNIMP, "RUR %d not implemented\n", par[0]);
26
+
21
}
27
typedef struct CPUArchState {
28
/* Regs for current mode. */
29
uint32_t regs[16];
30
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
31
} sau;
32
33
#if !defined(CONFIG_USER_ONLY)
34
- void *nvic;
35
+ NVICState *nvic;
36
const struct arm_boot_info *boot_info;
37
/* Store GICv3CPUState to access from this struct */
38
void *gicv3state;
39
@@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx,
40
41
/* Interface between CPU and Interrupt controller. */
42
#ifndef CONFIG_USER_ONLY
43
-bool armv7m_nvic_can_take_pending_exception(void *opaque);
44
+bool armv7m_nvic_can_take_pending_exception(NVICState *s);
45
#else
46
-static inline bool armv7m_nvic_can_take_pending_exception(void *opaque)
47
+static inline bool armv7m_nvic_can_take_pending_exception(NVICState *s)
48
{
49
return true;
50
}
51
#endif
52
/**
53
* armv7m_nvic_set_pending: mark the specified exception as pending
54
- * @opaque: the NVIC
55
+ * @s: the NVIC
56
* @irq: the exception number to mark pending
57
* @secure: false for non-banked exceptions or for the nonsecure
58
* version of a banked exception, true for the secure version of a banked
59
@@ -XXX,XX +XXX,XX @@ static inline bool armv7m_nvic_can_take_pending_exception(void *opaque)
60
* if @secure is true and @irq does not specify one of the fixed set
61
* of architecturally banked exceptions.
62
*/
63
-void armv7m_nvic_set_pending(void *opaque, int irq, bool secure);
64
+void armv7m_nvic_set_pending(NVICState *s, int irq, bool secure);
65
/**
66
* armv7m_nvic_set_pending_derived: mark this derived exception as pending
67
- * @opaque: the NVIC
68
+ * @s: the NVIC
69
* @irq: the exception number to mark pending
70
* @secure: false for non-banked exceptions or for the nonsecure
71
* version of a banked exception, true for the secure version of a banked
72
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending(void *opaque, int irq, bool secure);
73
* exceptions (exceptions generated in the course of trying to take
74
* a different exception).
75
*/
76
-void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure);
77
+void armv7m_nvic_set_pending_derived(NVICState *s, int irq, bool secure);
78
/**
79
* armv7m_nvic_set_pending_lazyfp: mark this lazy FP exception as pending
80
- * @opaque: the NVIC
81
+ * @s: the NVIC
82
* @irq: the exception number to mark pending
83
* @secure: false for non-banked exceptions or for the nonsecure
84
* version of a banked exception, true for the secure version of a banked
85
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure);
86
* Similar to armv7m_nvic_set_pending(), but specifically for exceptions
87
* generated in the course of lazy stacking of FP registers.
88
*/
89
-void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure);
90
+void armv7m_nvic_set_pending_lazyfp(NVICState *s, int irq, bool secure);
91
/**
92
* armv7m_nvic_get_pending_irq_info: return highest priority pending
93
* exception, and whether it targets Secure state
94
- * @opaque: the NVIC
95
+ * @s: the NVIC
96
* @pirq: set to pending exception number
97
* @ptargets_secure: set to whether pending exception targets Secure
98
*
99
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure);
100
* to true if the current highest priority pending exception should
101
* be taken to Secure state, false for NS.
102
*/
103
-void armv7m_nvic_get_pending_irq_info(void *opaque, int *pirq,
104
+void armv7m_nvic_get_pending_irq_info(NVICState *s, int *pirq,
105
bool *ptargets_secure);
106
/**
107
* armv7m_nvic_acknowledge_irq: make highest priority pending exception active
108
- * @opaque: the NVIC
109
+ * @s: the NVIC
110
*
111
* Move the current highest priority pending exception from the pending
112
* state to the active state, and update v7m.exception to indicate that
113
* it is the exception currently being handled.
114
*/
115
-void armv7m_nvic_acknowledge_irq(void *opaque);
116
+void armv7m_nvic_acknowledge_irq(NVICState *s);
117
/**
118
* armv7m_nvic_complete_irq: complete specified interrupt or exception
119
- * @opaque: the NVIC
120
+ * @s: the NVIC
121
* @irq: the exception number to complete
122
* @secure: true if this exception was secure
123
*
124
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_acknowledge_irq(void *opaque);
125
* 0 if there is still an irq active after this one was completed
126
* (Ignoring -1, this is the same as the RETTOBASE value before completion.)
127
*/
128
-int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure);
129
+int armv7m_nvic_complete_irq(NVICState *s, int irq, bool secure);
130
/**
131
* armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure)
132
- * @opaque: the NVIC
133
+ * @s: the NVIC
134
* @irq: the exception number to mark pending
135
* @secure: false for non-banked exceptions or for the nonsecure
136
* version of a banked exception, true for the secure version of a banked
137
@@ -XXX,XX +XXX,XX @@ int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure);
138
* interrupt the current execution priority. This controls whether the
139
* RDY bit for it in the FPCCR is set.
140
*/
141
-bool armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure);
142
+bool armv7m_nvic_get_ready_status(NVICState *s, int irq, bool secure);
143
/**
144
* armv7m_nvic_raw_execution_priority: return the raw execution priority
145
- * @opaque: the NVIC
146
+ * @s: the NVIC
147
*
148
* Returns: the raw execution priority as defined by the v8M architecture.
149
* This is the execution priority minus the effects of AIRCR.PRIS,
150
* and minus any PRIMASK/FAULTMASK/BASEPRI priority boosting.
151
* (v8M ARM ARM I_PKLD.)
152
*/
153
-int armv7m_nvic_raw_execution_priority(void *opaque);
154
+int armv7m_nvic_raw_execution_priority(NVICState *s);
155
/**
156
* armv7m_nvic_neg_prio_requested: return true if the requested execution
157
* priority is negative for the specified security state.
158
- * @opaque: the NVIC
159
+ * @s: the NVIC
160
* @secure: the security state to test
161
* This corresponds to the pseudocode IsReqExecPriNeg().
162
*/
163
#ifndef CONFIG_USER_ONLY
164
-bool armv7m_nvic_neg_prio_requested(void *opaque, bool secure);
165
+bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure);
166
#else
167
-static inline bool armv7m_nvic_neg_prio_requested(void *opaque, bool secure)
168
+static inline bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure)
169
{
170
return false;
171
}
172
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
173
index XXXXXXX..XXXXXXX 100644
174
--- a/hw/intc/armv7m_nvic.c
175
+++ b/hw/intc/armv7m_nvic.c
176
@@ -XXX,XX +XXX,XX @@ static inline int nvic_exec_prio(NVICState *s)
177
return MIN(running, s->exception_prio);
178
}
179
180
-bool armv7m_nvic_neg_prio_requested(void *opaque, bool secure)
181
+bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure)
182
{
183
/* Return true if the requested execution priority is negative
184
* for the specified security state, ie that security state
185
@@ -XXX,XX +XXX,XX @@ bool armv7m_nvic_neg_prio_requested(void *opaque, bool secure)
186
* mean we don't allow FAULTMASK_NS to actually make the execution
187
* priority negative). Compare pseudocode IsReqExcPriNeg().
188
*/
189
- NVICState *s = opaque;
190
-
191
if (s->cpu->env.v7m.faultmask[secure]) {
192
return true;
22
}
193
}
23
}
194
@@ -XXX,XX +XXX,XX @@ bool armv7m_nvic_neg_prio_requested(void *opaque, bool secure)
24
@@ -XXX,XX +XXX,XX @@ static void translate_slli(DisasContext *dc, const uint32_t arg[],
195
return false;
25
{
196
}
26
if (gen_window_check2(dc, arg[0], arg[1])) {
197
27
if (arg[2] == 32) {
198
-bool armv7m_nvic_can_take_pending_exception(void *opaque)
28
- qemu_log_mask(LOG_GUEST_ERROR, "slli a%d, a%d, 32 is undefined",
199
+bool armv7m_nvic_can_take_pending_exception(NVICState *s)
29
+ qemu_log_mask(LOG_GUEST_ERROR, "slli a%d, a%d, 32 is undefined\n",
200
{
30
arg[0], arg[1]);
201
- NVICState *s = opaque;
31
}
202
-
32
tcg_gen_shli_i32(cpu_R[arg[0]], cpu_R[arg[1]], arg[2] & 0x1f);
203
return nvic_exec_prio(s) > nvic_pending_prio(s);
33
@@ -XXX,XX +XXX,XX @@ static void translate_wur(DisasContext *dc, const uint32_t arg[],
204
}
34
if (uregnames[par[0]].name) {
205
35
gen_wur(par[0], cpu_R[arg[0]]);
206
-int armv7m_nvic_raw_execution_priority(void *opaque)
36
} else {
207
+int armv7m_nvic_raw_execution_priority(NVICState *s)
37
- qemu_log_mask(LOG_UNIMP, "WUR %d not implemented, ", par[0]);
208
{
38
+ qemu_log_mask(LOG_UNIMP, "WUR %d not implemented\n", par[0]);
209
- NVICState *s = opaque;
39
}
210
-
211
return s->exception_prio;
212
}
213
214
@@ -XXX,XX +XXX,XX @@ static void nvic_irq_update(NVICState *s)
215
* if @secure is true and @irq does not specify one of the fixed set
216
* of architecturally banked exceptions.
217
*/
218
-static void armv7m_nvic_clear_pending(void *opaque, int irq, bool secure)
219
+static void armv7m_nvic_clear_pending(NVICState *s, int irq, bool secure)
220
{
221
- NVICState *s = (NVICState *)opaque;
222
VecInfo *vec;
223
224
assert(irq > ARMV7M_EXCP_RESET && irq < s->num_irq);
225
@@ -XXX,XX +XXX,XX @@ static void do_armv7m_nvic_set_pending(void *opaque, int irq, bool secure,
40
}
226
}
41
}
227
}
228
229
-void armv7m_nvic_set_pending(void *opaque, int irq, bool secure)
230
+void armv7m_nvic_set_pending(NVICState *s, int irq, bool secure)
231
{
232
- do_armv7m_nvic_set_pending(opaque, irq, secure, false);
233
+ do_armv7m_nvic_set_pending(s, irq, secure, false);
234
}
235
236
-void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure)
237
+void armv7m_nvic_set_pending_derived(NVICState *s, int irq, bool secure)
238
{
239
- do_armv7m_nvic_set_pending(opaque, irq, secure, true);
240
+ do_armv7m_nvic_set_pending(s, irq, secure, true);
241
}
242
243
-void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure)
244
+void armv7m_nvic_set_pending_lazyfp(NVICState *s, int irq, bool secure)
245
{
246
/*
247
* Pend an exception during lazy FP stacking. This differs
248
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure)
249
* whether we should escalate depends on the saved context
250
* in the FPCCR register, not on the current state of the CPU/NVIC.
251
*/
252
- NVICState *s = (NVICState *)opaque;
253
bool banked = exc_is_banked(irq);
254
VecInfo *vec;
255
bool targets_secure;
256
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure)
257
}
258
259
/* Make pending IRQ active. */
260
-void armv7m_nvic_acknowledge_irq(void *opaque)
261
+void armv7m_nvic_acknowledge_irq(NVICState *s)
262
{
263
- NVICState *s = (NVICState *)opaque;
264
CPUARMState *env = &s->cpu->env;
265
const int pending = s->vectpending;
266
const int running = nvic_exec_prio(s);
267
@@ -XXX,XX +XXX,XX @@ static bool vectpending_targets_secure(NVICState *s)
268
exc_targets_secure(s, s->vectpending);
269
}
270
271
-void armv7m_nvic_get_pending_irq_info(void *opaque,
272
+void armv7m_nvic_get_pending_irq_info(NVICState *s,
273
int *pirq, bool *ptargets_secure)
274
{
275
- NVICState *s = (NVICState *)opaque;
276
const int pending = s->vectpending;
277
bool targets_secure;
278
279
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_get_pending_irq_info(void *opaque,
280
*pirq = pending;
281
}
282
283
-int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure)
284
+int armv7m_nvic_complete_irq(NVICState *s, int irq, bool secure)
285
{
286
- NVICState *s = (NVICState *)opaque;
287
VecInfo *vec = NULL;
288
int ret = 0;
289
290
@@ -XXX,XX +XXX,XX @@ int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure)
291
return ret;
292
}
293
294
-bool armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure)
295
+bool armv7m_nvic_get_ready_status(NVICState *s, int irq, bool secure)
296
{
297
/*
298
* Return whether an exception is "ready", i.e. it is enabled and is
299
@@ -XXX,XX +XXX,XX @@ bool armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure)
300
* for non-banked exceptions secure is always false; for banked exceptions
301
* it indicates which of the exceptions is required.
302
*/
303
- NVICState *s = (NVICState *)opaque;
304
bool banked = exc_is_banked(irq);
305
VecInfo *vec;
306
int running = nvic_exec_prio(s);
307
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
308
index XXXXXXX..XXXXXXX 100644
309
--- a/target/arm/cpu.c
310
+++ b/target/arm/cpu.c
311
@@ -XXX,XX +XXX,XX @@
312
#if !defined(CONFIG_USER_ONLY)
313
#include "hw/loader.h"
314
#include "hw/boards.h"
315
+#include "hw/intc/armv7m_nvic.h"
316
#endif
317
#include "sysemu/tcg.h"
318
#include "sysemu/qtest.h"
319
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
320
index XXXXXXX..XXXXXXX 100644
321
--- a/target/arm/m_helper.c
322
+++ b/target/arm/m_helper.c
323
@@ -XXX,XX +XXX,XX @@ static void v7m_update_fpccr(CPUARMState *env, uint32_t frameptr,
324
* that we will need later in order to do lazy FP reg stacking.
325
*/
326
bool is_secure = env->v7m.secure;
327
- void *nvic = env->nvic;
328
+ NVICState *nvic = env->nvic;
329
/*
330
* Some bits are unbanked and live always in fpccr[M_REG_S]; some bits
331
* are banked and we want to update the bit in the bank for the
42
--
332
--
43
2.17.1
333
2.34.1
44
334
45
335
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
3
While dozens of files include "cpu.h", only 3 files require
4
Message-id: 20180606152128.449-11-f4bug@amsat.org
4
these NVIC helper declarations.
5
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Message-id: 20230206223502.25122-12-philmd@linaro.org
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
---
10
---
7
target/riscv/op_helper.c | 6 ++++--
11
include/hw/intc/armv7m_nvic.h | 123 ++++++++++++++++++++++++++++++++++
8
1 file changed, 4 insertions(+), 2 deletions(-)
12
target/arm/cpu.h | 123 ----------------------------------
9
13
target/arm/cpu.c | 4 +-
10
diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c
14
target/arm/cpu_tcg.c | 3 +
11
index XXXXXXX..XXXXXXX 100644
15
target/arm/m_helper.c | 3 +
12
--- a/target/riscv/op_helper.c
16
5 files changed, 132 insertions(+), 124 deletions(-)
13
+++ b/target/riscv/op_helper.c
17
14
@@ -XXX,XX +XXX,XX @@ void csr_write_helper(CPURISCVState *env, target_ulong val_to_write,
18
diff --git a/include/hw/intc/armv7m_nvic.h b/include/hw/intc/armv7m_nvic.h
15
if ((val_to_write & 3) == 0) {
19
index XXXXXXX..XXXXXXX 100644
16
env->stvec = val_to_write >> 2 << 2;
20
--- a/include/hw/intc/armv7m_nvic.h
17
} else {
21
+++ b/include/hw/intc/armv7m_nvic.h
18
- qemu_log_mask(LOG_UNIMP, "CSR_STVEC: vectored traps not supported");
22
@@ -XXX,XX +XXX,XX @@ struct NVICState {
19
+ qemu_log_mask(LOG_UNIMP,
23
qemu_irq sysresetreq;
20
+ "CSR_STVEC: vectored traps not supported\n");
24
};
21
}
25
22
break;
26
+/* Interface between CPU and Interrupt controller. */
23
case CSR_SCOUNTEREN:
27
+/**
24
@@ -XXX,XX +XXX,XX @@ void csr_write_helper(CPURISCVState *env, target_ulong val_to_write,
28
+ * armv7m_nvic_set_pending: mark the specified exception as pending
25
if ((val_to_write & 3) == 0) {
29
+ * @s: the NVIC
26
env->mtvec = val_to_write >> 2 << 2;
30
+ * @irq: the exception number to mark pending
27
} else {
31
+ * @secure: false for non-banked exceptions or for the nonsecure
28
- qemu_log_mask(LOG_UNIMP, "CSR_MTVEC: vectored traps not supported");
32
+ * version of a banked exception, true for the secure version of a banked
29
+ qemu_log_mask(LOG_UNIMP,
33
+ * exception.
30
+ "CSR_MTVEC: vectored traps not supported\n");
34
+ *
31
}
35
+ * Marks the specified exception as pending. Note that we will assert()
32
break;
36
+ * if @secure is true and @irq does not specify one of the fixed set
33
case CSR_MCOUNTEREN:
37
+ * of architecturally banked exceptions.
38
+ */
39
+void armv7m_nvic_set_pending(NVICState *s, int irq, bool secure);
40
+/**
41
+ * armv7m_nvic_set_pending_derived: mark this derived exception as pending
42
+ * @s: the NVIC
43
+ * @irq: the exception number to mark pending
44
+ * @secure: false for non-banked exceptions or for the nonsecure
45
+ * version of a banked exception, true for the secure version of a banked
46
+ * exception.
47
+ *
48
+ * Similar to armv7m_nvic_set_pending(), but specifically for derived
49
+ * exceptions (exceptions generated in the course of trying to take
50
+ * a different exception).
51
+ */
52
+void armv7m_nvic_set_pending_derived(NVICState *s, int irq, bool secure);
53
+/**
54
+ * armv7m_nvic_set_pending_lazyfp: mark this lazy FP exception as pending
55
+ * @s: the NVIC
56
+ * @irq: the exception number to mark pending
57
+ * @secure: false for non-banked exceptions or for the nonsecure
58
+ * version of a banked exception, true for the secure version of a banked
59
+ * exception.
60
+ *
61
+ * Similar to armv7m_nvic_set_pending(), but specifically for exceptions
62
+ * generated in the course of lazy stacking of FP registers.
63
+ */
64
+void armv7m_nvic_set_pending_lazyfp(NVICState *s, int irq, bool secure);
65
+/**
66
+ * armv7m_nvic_get_pending_irq_info: return highest priority pending
67
+ * exception, and whether it targets Secure state
68
+ * @s: the NVIC
69
+ * @pirq: set to pending exception number
70
+ * @ptargets_secure: set to whether pending exception targets Secure
71
+ *
72
+ * This function writes the number of the highest priority pending
73
+ * exception (the one which would be made active by
74
+ * armv7m_nvic_acknowledge_irq()) to @pirq, and sets @ptargets_secure
75
+ * to true if the current highest priority pending exception should
76
+ * be taken to Secure state, false for NS.
77
+ */
78
+void armv7m_nvic_get_pending_irq_info(NVICState *s, int *pirq,
79
+ bool *ptargets_secure);
80
+/**
81
+ * armv7m_nvic_acknowledge_irq: make highest priority pending exception active
82
+ * @s: the NVIC
83
+ *
84
+ * Move the current highest priority pending exception from the pending
85
+ * state to the active state, and update v7m.exception to indicate that
86
+ * it is the exception currently being handled.
87
+ */
88
+void armv7m_nvic_acknowledge_irq(NVICState *s);
89
+/**
90
+ * armv7m_nvic_complete_irq: complete specified interrupt or exception
91
+ * @s: the NVIC
92
+ * @irq: the exception number to complete
93
+ * @secure: true if this exception was secure
94
+ *
95
+ * Returns: -1 if the irq was not active
96
+ * 1 if completing this irq brought us back to base (no active irqs)
97
+ * 0 if there is still an irq active after this one was completed
98
+ * (Ignoring -1, this is the same as the RETTOBASE value before completion.)
99
+ */
100
+int armv7m_nvic_complete_irq(NVICState *s, int irq, bool secure);
101
+/**
102
+ * armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure)
103
+ * @s: the NVIC
104
+ * @irq: the exception number to mark pending
105
+ * @secure: false for non-banked exceptions or for the nonsecure
106
+ * version of a banked exception, true for the secure version of a banked
107
+ * exception.
108
+ *
109
+ * Return whether an exception is "ready", i.e. whether the exception is
110
+ * enabled and is configured at a priority which would allow it to
111
+ * interrupt the current execution priority. This controls whether the
112
+ * RDY bit for it in the FPCCR is set.
113
+ */
114
+bool armv7m_nvic_get_ready_status(NVICState *s, int irq, bool secure);
115
+/**
116
+ * armv7m_nvic_raw_execution_priority: return the raw execution priority
117
+ * @s: the NVIC
118
+ *
119
+ * Returns: the raw execution priority as defined by the v8M architecture.
120
+ * This is the execution priority minus the effects of AIRCR.PRIS,
121
+ * and minus any PRIMASK/FAULTMASK/BASEPRI priority boosting.
122
+ * (v8M ARM ARM I_PKLD.)
123
+ */
124
+int armv7m_nvic_raw_execution_priority(NVICState *s);
125
+/**
126
+ * armv7m_nvic_neg_prio_requested: return true if the requested execution
127
+ * priority is negative for the specified security state.
128
+ * @s: the NVIC
129
+ * @secure: the security state to test
130
+ * This corresponds to the pseudocode IsReqExecPriNeg().
131
+ */
132
+#ifndef CONFIG_USER_ONLY
133
+bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure);
134
+#else
135
+static inline bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure)
136
+{
137
+ return false;
138
+}
139
+#endif
140
+#ifndef CONFIG_USER_ONLY
141
+bool armv7m_nvic_can_take_pending_exception(NVICState *s);
142
+#else
143
+static inline bool armv7m_nvic_can_take_pending_exception(NVICState *s)
144
+{
145
+ return true;
146
+}
147
+#endif
148
+
149
#endif
150
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
151
index XXXXXXX..XXXXXXX 100644
152
--- a/target/arm/cpu.h
153
+++ b/target/arm/cpu.h
154
@@ -XXX,XX +XXX,XX @@ void arm_cpu_list(void);
155
uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx,
156
uint32_t cur_el, bool secure);
157
158
-/* Interface between CPU and Interrupt controller. */
159
-#ifndef CONFIG_USER_ONLY
160
-bool armv7m_nvic_can_take_pending_exception(NVICState *s);
161
-#else
162
-static inline bool armv7m_nvic_can_take_pending_exception(NVICState *s)
163
-{
164
- return true;
165
-}
166
-#endif
167
-/**
168
- * armv7m_nvic_set_pending: mark the specified exception as pending
169
- * @s: the NVIC
170
- * @irq: the exception number to mark pending
171
- * @secure: false for non-banked exceptions or for the nonsecure
172
- * version of a banked exception, true for the secure version of a banked
173
- * exception.
174
- *
175
- * Marks the specified exception as pending. Note that we will assert()
176
- * if @secure is true and @irq does not specify one of the fixed set
177
- * of architecturally banked exceptions.
178
- */
179
-void armv7m_nvic_set_pending(NVICState *s, int irq, bool secure);
180
-/**
181
- * armv7m_nvic_set_pending_derived: mark this derived exception as pending
182
- * @s: the NVIC
183
- * @irq: the exception number to mark pending
184
- * @secure: false for non-banked exceptions or for the nonsecure
185
- * version of a banked exception, true for the secure version of a banked
186
- * exception.
187
- *
188
- * Similar to armv7m_nvic_set_pending(), but specifically for derived
189
- * exceptions (exceptions generated in the course of trying to take
190
- * a different exception).
191
- */
192
-void armv7m_nvic_set_pending_derived(NVICState *s, int irq, bool secure);
193
-/**
194
- * armv7m_nvic_set_pending_lazyfp: mark this lazy FP exception as pending
195
- * @s: the NVIC
196
- * @irq: the exception number to mark pending
197
- * @secure: false for non-banked exceptions or for the nonsecure
198
- * version of a banked exception, true for the secure version of a banked
199
- * exception.
200
- *
201
- * Similar to armv7m_nvic_set_pending(), but specifically for exceptions
202
- * generated in the course of lazy stacking of FP registers.
203
- */
204
-void armv7m_nvic_set_pending_lazyfp(NVICState *s, int irq, bool secure);
205
-/**
206
- * armv7m_nvic_get_pending_irq_info: return highest priority pending
207
- * exception, and whether it targets Secure state
208
- * @s: the NVIC
209
- * @pirq: set to pending exception number
210
- * @ptargets_secure: set to whether pending exception targets Secure
211
- *
212
- * This function writes the number of the highest priority pending
213
- * exception (the one which would be made active by
214
- * armv7m_nvic_acknowledge_irq()) to @pirq, and sets @ptargets_secure
215
- * to true if the current highest priority pending exception should
216
- * be taken to Secure state, false for NS.
217
- */
218
-void armv7m_nvic_get_pending_irq_info(NVICState *s, int *pirq,
219
- bool *ptargets_secure);
220
-/**
221
- * armv7m_nvic_acknowledge_irq: make highest priority pending exception active
222
- * @s: the NVIC
223
- *
224
- * Move the current highest priority pending exception from the pending
225
- * state to the active state, and update v7m.exception to indicate that
226
- * it is the exception currently being handled.
227
- */
228
-void armv7m_nvic_acknowledge_irq(NVICState *s);
229
-/**
230
- * armv7m_nvic_complete_irq: complete specified interrupt or exception
231
- * @s: the NVIC
232
- * @irq: the exception number to complete
233
- * @secure: true if this exception was secure
234
- *
235
- * Returns: -1 if the irq was not active
236
- * 1 if completing this irq brought us back to base (no active irqs)
237
- * 0 if there is still an irq active after this one was completed
238
- * (Ignoring -1, this is the same as the RETTOBASE value before completion.)
239
- */
240
-int armv7m_nvic_complete_irq(NVICState *s, int irq, bool secure);
241
-/**
242
- * armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure)
243
- * @s: the NVIC
244
- * @irq: the exception number to mark pending
245
- * @secure: false for non-banked exceptions or for the nonsecure
246
- * version of a banked exception, true for the secure version of a banked
247
- * exception.
248
- *
249
- * Return whether an exception is "ready", i.e. whether the exception is
250
- * enabled and is configured at a priority which would allow it to
251
- * interrupt the current execution priority. This controls whether the
252
- * RDY bit for it in the FPCCR is set.
253
- */
254
-bool armv7m_nvic_get_ready_status(NVICState *s, int irq, bool secure);
255
-/**
256
- * armv7m_nvic_raw_execution_priority: return the raw execution priority
257
- * @s: the NVIC
258
- *
259
- * Returns: the raw execution priority as defined by the v8M architecture.
260
- * This is the execution priority minus the effects of AIRCR.PRIS,
261
- * and minus any PRIMASK/FAULTMASK/BASEPRI priority boosting.
262
- * (v8M ARM ARM I_PKLD.)
263
- */
264
-int armv7m_nvic_raw_execution_priority(NVICState *s);
265
-/**
266
- * armv7m_nvic_neg_prio_requested: return true if the requested execution
267
- * priority is negative for the specified security state.
268
- * @s: the NVIC
269
- * @secure: the security state to test
270
- * This corresponds to the pseudocode IsReqExecPriNeg().
271
- */
272
-#ifndef CONFIG_USER_ONLY
273
-bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure);
274
-#else
275
-static inline bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure)
276
-{
277
- return false;
278
-}
279
-#endif
280
-
281
/* Interface for defining coprocessor registers.
282
* Registers are defined in tables of arm_cp_reginfo structs
283
* which are passed to define_arm_cp_regs().
284
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
285
index XXXXXXX..XXXXXXX 100644
286
--- a/target/arm/cpu.c
287
+++ b/target/arm/cpu.c
288
@@ -XXX,XX +XXX,XX @@
289
#if !defined(CONFIG_USER_ONLY)
290
#include "hw/loader.h"
291
#include "hw/boards.h"
292
+#ifdef CONFIG_TCG
293
#include "hw/intc/armv7m_nvic.h"
294
-#endif
295
+#endif /* CONFIG_TCG */
296
+#endif /* !CONFIG_USER_ONLY */
297
#include "sysemu/tcg.h"
298
#include "sysemu/qtest.h"
299
#include "sysemu/hw_accel.h"
300
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
301
index XXXXXXX..XXXXXXX 100644
302
--- a/target/arm/cpu_tcg.c
303
+++ b/target/arm/cpu_tcg.c
304
@@ -XXX,XX +XXX,XX @@
305
#include "hw/boards.h"
306
#endif
307
#include "cpregs.h"
308
+#if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG)
309
+#include "hw/intc/armv7m_nvic.h"
310
+#endif
311
312
313
/* Share AArch32 -cpu max features with AArch64. */
314
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
315
index XXXXXXX..XXXXXXX 100644
316
--- a/target/arm/m_helper.c
317
+++ b/target/arm/m_helper.c
318
@@ -XXX,XX +XXX,XX @@
319
#include "exec/cpu_ldst.h"
320
#include "semihosting/common-semi.h"
321
#endif
322
+#if !defined(CONFIG_USER_ONLY)
323
+#include "hw/intc/armv7m_nvic.h"
324
+#endif
325
326
static void v7m_msr_xpsr(CPUARMState *env, uint32_t mask,
327
uint32_t reg, uint32_t val)
34
--
328
--
35
2.17.1
329
2.34.1
36
330
37
331
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Alex Bennée <alex.bennee@linaro.org>
2
2
3
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
3
The two TCG tests for GICv2 and GICv3 are very heavy weight distros
4
Message-id: 20180606191801.6331-1-f4bug@amsat.org
4
that take a long time to boot up, especially for an --enable-debug
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
build. The total code coverage they give is:
6
7
Overall coverage rate:
8
lines......: 11.2% (59584 of 530123 lines)
9
functions..: 15.0% (7436 of 49443 functions)
10
branches...: 6.3% (19273 of 303933 branches)
11
12
We already get pretty close to that with the machine_aarch64_virt
13
tests which only does one full boot (~120s vs ~600s) of alpine. We
14
expand the kernel+initrd boot (~8s) to test both GICs and also add an
15
RNG device and a block device to generate a few IRQs and exercise the
16
storage layer. With that we get to a coverage of:
17
18
Overall coverage rate:
19
lines......: 11.0% (58121 of 530123 lines)
20
functions..: 14.9% (7343 of 49443 functions)
21
branches...: 6.0% (18269 of 303933 branches)
22
23
which I feel is close enough given the massive time saving. If we want
24
to target any more sub-systems we can use lighter weight more directed
25
tests.
26
27
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
28
Reviewed-by: Fabiano Rosas <farosas@suse.de>
29
Acked-by: Richard Henderson <richard.henderson@linaro.org>
30
Message-id: 20230203181632.2919715-1-alex.bennee@linaro.org
31
Cc: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
32
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
33
---
8
Makefile.objs | 1 +
34
tests/avocado/boot_linux.py | 48 ++++----------------
9
hw/i2c/core.c | 25 ++++++++++++++++++-------
35
tests/avocado/machine_aarch64_virt.py | 63 ++++++++++++++++++++++++---
10
hw/i2c/trace-events | 7 +++++++
36
2 files changed, 65 insertions(+), 46 deletions(-)
11
3 files changed, 26 insertions(+), 7 deletions(-)
37
12
create mode 100644 hw/i2c/trace-events
38
diff --git a/tests/avocado/boot_linux.py b/tests/avocado/boot_linux.py
13
14
diff --git a/Makefile.objs b/Makefile.objs
15
index XXXXXXX..XXXXXXX 100644
39
index XXXXXXX..XXXXXXX 100644
16
--- a/Makefile.objs
40
--- a/tests/avocado/boot_linux.py
17
+++ b/Makefile.objs
41
+++ b/tests/avocado/boot_linux.py
18
@@ -XXX,XX +XXX,XX @@ trace-events-subdirs += hw/char
42
@@ -XXX,XX +XXX,XX @@ def test_pc_q35_kvm(self):
19
trace-events-subdirs += hw/display
43
self.launch_and_wait(set_up_ssh_connection=False)
20
trace-events-subdirs += hw/dma
44
21
trace-events-subdirs += hw/hppa
45
22
+trace-events-subdirs += hw/i2c
46
-# For Aarch64 we only boot KVM tests in CI as the TCG tests are very
23
trace-events-subdirs += hw/i386
47
-# heavyweight. There are lighter weight distros which we use in the
24
trace-events-subdirs += hw/i386/xen
48
-# machine_aarch64_virt.py tests.
25
trace-events-subdirs += hw/ide
49
+# For Aarch64 we only boot KVM tests in CI as booting the current
26
diff --git a/hw/i2c/core.c b/hw/i2c/core.c
50
+# Fedora OS in TCG tests is very heavyweight. There are lighter weight
51
+# distros which we use in the machine_aarch64_virt.py tests.
52
class BootLinuxAarch64(LinuxTest):
53
"""
54
:avocado: tags=arch:aarch64
55
:avocado: tags=machine:virt
56
- :avocado: tags=machine:gic-version=2
57
"""
58
timeout = 720
59
60
- def add_common_args(self):
61
- self.vm.add_args('-bios',
62
- os.path.join(BUILD_DIR, 'pc-bios',
63
- 'edk2-aarch64-code.fd'))
64
- self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0')
65
- self.vm.add_args('-object', 'rng-random,id=rng0,filename=/dev/urandom')
66
-
67
- @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
68
- def test_fedora_cloud_tcg_gicv2(self):
69
- """
70
- :avocado: tags=accel:tcg
71
- :avocado: tags=cpu:max
72
- :avocado: tags=device:gicv2
73
- """
74
- self.require_accelerator("tcg")
75
- self.vm.add_args("-accel", "tcg")
76
- self.vm.add_args("-cpu", "max,lpa2=off")
77
- self.vm.add_args("-machine", "virt,gic-version=2")
78
- self.add_common_args()
79
- self.launch_and_wait(set_up_ssh_connection=False)
80
-
81
- @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
82
- def test_fedora_cloud_tcg_gicv3(self):
83
- """
84
- :avocado: tags=accel:tcg
85
- :avocado: tags=cpu:max
86
- :avocado: tags=device:gicv3
87
- """
88
- self.require_accelerator("tcg")
89
- self.vm.add_args("-accel", "tcg")
90
- self.vm.add_args("-cpu", "max,lpa2=off")
91
- self.vm.add_args("-machine", "virt,gic-version=3")
92
- self.add_common_args()
93
- self.launch_and_wait(set_up_ssh_connection=False)
94
-
95
def test_virt_kvm(self):
96
"""
97
:avocado: tags=accel:kvm
98
@@ -XXX,XX +XXX,XX @@ def test_virt_kvm(self):
99
self.require_accelerator("kvm")
100
self.vm.add_args("-accel", "kvm")
101
self.vm.add_args("-machine", "virt,gic-version=host")
102
- self.add_common_args()
103
+ self.vm.add_args('-bios',
104
+ os.path.join(BUILD_DIR, 'pc-bios',
105
+ 'edk2-aarch64-code.fd'))
106
+ self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0')
107
+ self.vm.add_args('-object', 'rng-random,id=rng0,filename=/dev/urandom')
108
self.launch_and_wait(set_up_ssh_connection=False)
109
110
111
diff --git a/tests/avocado/machine_aarch64_virt.py b/tests/avocado/machine_aarch64_virt.py
27
index XXXXXXX..XXXXXXX 100644
112
index XXXXXXX..XXXXXXX 100644
28
--- a/hw/i2c/core.c
113
--- a/tests/avocado/machine_aarch64_virt.py
29
+++ b/hw/i2c/core.c
114
+++ b/tests/avocado/machine_aarch64_virt.py
30
@@ -XXX,XX +XXX,XX @@
115
@@ -XXX,XX +XXX,XX @@
31
116
32
#include "qemu/osdep.h"
117
import time
33
#include "hw/i2c/i2c.h"
118
import os
34
+#include "trace.h"
119
+import logging
35
120
36
#define I2C_BROADCAST 0x00
121
from avocado_qemu import QemuSystemTest
37
122
from avocado_qemu import wait_for_console_pattern
38
@@ -XXX,XX +XXX,XX @@ int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv)
123
from avocado_qemu import exec_command
39
}
124
from avocado_qemu import BUILD_DIR
40
125
+from avocado.utils import process
41
QLIST_FOREACH(node, &bus->current_devs, next) {
126
+from avocado.utils.path import find_command
42
+ I2CSlave *s = node->elt;
127
43
int rv;
128
class Aarch64VirtMachine(QemuSystemTest):
44
129
KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
45
- sc = I2C_SLAVE_GET_CLASS(node->elt);
130
@@ -XXX,XX +XXX,XX @@ def test_alpine_virt_tcg_gic_max(self):
46
+ sc = I2C_SLAVE_GET_CLASS(s);
131
self.wait_for_console_pattern('Welcome to Alpine Linux 3.16')
47
/* If the bus is already busy, assume this is a repeated
132
48
start condition. */
133
49
134
- def test_aarch64_virt(self):
50
if (sc->event) {
135
+ def common_aarch64_virt(self, machine):
51
- rv = sc->event(node->elt, recv ? I2C_START_RECV : I2C_START_SEND);
136
"""
52
+ trace_i2c_event("start", s->address);
137
- :avocado: tags=arch:aarch64
53
+ rv = sc->event(s, recv ? I2C_START_RECV : I2C_START_SEND);
138
- :avocado: tags=machine:virt
54
if (rv && !bus->broadcast) {
139
- :avocado: tags=accel:tcg
55
if (bus_scanned) {
140
- :avocado: tags=cpu:max
56
/* First call, terminate the transfer. */
141
+ Common code to launch basic virt machine with kernel+initrd
57
@@ -XXX,XX +XXX,XX @@ void i2c_end_transfer(I2CBus *bus)
142
+ and a scratch disk.
58
I2CNode *node, *next;
143
"""
59
144
+ logger = logging.getLogger('aarch64_virt')
60
QLIST_FOREACH_SAFE(node, &bus->current_devs, next, next) {
145
+
61
- sc = I2C_SLAVE_GET_CLASS(node->elt);
146
kernel_url = ('https://fileserver.linaro.org/s/'
62
+ I2CSlave *s = node->elt;
147
'z6B2ARM7DQT3HWN/download')
63
+ sc = I2C_SLAVE_GET_CLASS(s);
148
-
64
if (sc->event) {
149
kernel_hash = 'ed11daab50c151dde0e1e9c9cb8b2d9bd3215347'
65
- sc->event(node->elt, I2C_FINISH);
150
kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
66
+ trace_i2c_event("finish", s->address);
151
67
+ sc->event(s, I2C_FINISH);
152
@@ -XXX,XX +XXX,XX @@ def test_aarch64_virt(self):
68
}
153
'console=ttyAMA0')
69
QLIST_REMOVE(node, next);
154
self.require_accelerator("tcg")
70
g_free(node);
155
self.vm.add_args('-cpu', 'max,pauth-impdef=on',
71
@@ -XXX,XX +XXX,XX @@ void i2c_end_transfer(I2CBus *bus)
156
+ '-machine', machine,
72
int i2c_send_recv(I2CBus *bus, uint8_t *data, bool send)
157
'-accel', 'tcg',
73
{
158
'-kernel', kernel_path,
74
I2CSlaveClass *sc;
159
'-append', kernel_command_line)
75
+ I2CSlave *s;
160
+
76
I2CNode *node;
161
+ # A RNG offers an easy way to generate a few IRQs
77
int ret = 0;
162
+ self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0')
78
163
+ self.vm.add_args('-object',
79
if (send) {
164
+ 'rng-random,id=rng0,filename=/dev/urandom')
80
QLIST_FOREACH(node, &bus->current_devs, next) {
165
+
81
- sc = I2C_SLAVE_GET_CLASS(node->elt);
166
+ # Also add a scratch block device
82
+ s = node->elt;
167
+ logger.info('creating scratch qcow2 image')
83
+ sc = I2C_SLAVE_GET_CLASS(s);
168
+ image_path = os.path.join(self.workdir, 'scratch.qcow2')
84
if (sc->send) {
169
+ qemu_img = os.path.join(BUILD_DIR, 'qemu-img')
85
- ret = ret || sc->send(node->elt, *data);
170
+ if not os.path.exists(qemu_img):
86
+ trace_i2c_send(s->address, *data);
171
+ qemu_img = find_command('qemu-img', False)
87
+ ret = ret || sc->send(s, *data);
172
+ if qemu_img is False:
88
} else {
173
+ self.cancel('Could not find "qemu-img", which is required to '
89
ret = -1;
174
+ 'create the temporary qcow2 image')
90
}
175
+ cmd = '%s create -f qcow2 %s 8M' % (qemu_img, image_path)
91
@@ -XXX,XX +XXX,XX @@ int i2c_send_recv(I2CBus *bus, uint8_t *data, bool send)
176
+ process.run(cmd)
92
177
+
93
sc = I2C_SLAVE_GET_CLASS(QLIST_FIRST(&bus->current_devs)->elt);
178
+ # Add the device
94
if (sc->recv) {
179
+ self.vm.add_args('-blockdev',
95
- ret = sc->recv(QLIST_FIRST(&bus->current_devs)->elt);
180
+ f"driver=qcow2,file.driver=file,file.filename={image_path},node-name=scratch")
96
+ s = QLIST_FIRST(&bus->current_devs)->elt;
181
+ self.vm.add_args('-device',
97
+ ret = sc->recv(s);
182
+ 'virtio-blk-device,drive=scratch')
98
+ trace_i2c_recv(s->address, ret);
183
+
99
if (ret < 0) {
184
self.vm.launch()
100
return ret;
185
self.wait_for_console_pattern('Welcome to Buildroot')
101
} else {
186
time.sleep(0.1)
102
@@ -XXX,XX +XXX,XX @@ void i2c_nack(I2CBus *bus)
187
exec_command(self, 'root')
103
QLIST_FOREACH(node, &bus->current_devs, next) {
188
time.sleep(0.1)
104
sc = I2C_SLAVE_GET_CLASS(node->elt);
189
+ exec_command(self, 'dd if=/dev/hwrng of=/dev/vda bs=512 count=4')
105
if (sc->event) {
190
+ time.sleep(0.1)
106
+ trace_i2c_event("nack", node->elt->address);
191
+ exec_command(self, 'md5sum /dev/vda')
107
sc->event(node->elt, I2C_NACK);
192
+ time.sleep(0.1)
108
}
193
+ exec_command(self, 'cat /proc/interrupts')
109
}
194
+ time.sleep(0.1)
110
diff --git a/hw/i2c/trace-events b/hw/i2c/trace-events
195
exec_command(self, 'cat /proc/self/maps')
111
new file mode 100644
196
time.sleep(0.1)
112
index XXXXXXX..XXXXXXX
197
+
113
--- /dev/null
198
+ def test_aarch64_virt_gicv3(self):
114
+++ b/hw/i2c/trace-events
199
+ """
115
@@ -XXX,XX +XXX,XX @@
200
+ :avocado: tags=arch:aarch64
116
+# See docs/devel/tracing.txt for syntax documentation.
201
+ :avocado: tags=machine:virt
117
+
202
+ :avocado: tags=accel:tcg
118
+# hw/i2c/core.c
203
+ :avocado: tags=cpu:max
119
+
204
+ """
120
+i2c_event(const char *event, uint8_t address) "%s(addr:0x%02x)"
205
+ self.common_aarch64_virt("virt,gic_version=3")
121
+i2c_send(uint8_t address, uint8_t data) "send(addr:0x%02x) data:0x%02x"
206
+
122
+i2c_recv(uint8_t address, uint8_t data) "recv(addr:0x%02x) data:0x%02x"
207
+ def test_aarch64_virt_gicv2(self):
208
+ """
209
+ :avocado: tags=arch:aarch64
210
+ :avocado: tags=machine:virt
211
+ :avocado: tags=accel:tcg
212
+ :avocado: tags=cpu:max
213
+ """
214
+ self.common_aarch64_virt("virt,gic-version=2")
123
--
215
--
124
2.17.1
216
2.34.1
125
217
126
218
diff view generated by jsdifflib
1
From: Shannon Zhao <zhaoshenglong@huawei.com>
1
From: Mostafa Saleh <smostafa@google.com>
2
2
3
While we skip the GIC_INTERNAL irqs, we don't change the register offset
3
GBPA register can be used to globally abort all
4
accordingly. This will overlap the GICR registers value and leave the
4
transactions.
5
last GIC_INTERNAL irq's registers out of update.
6
5
7
Fix this by skipping the registers banked by GICR.
6
It is described in the SMMU manual in "6.3.14 SMMU_GBPA".
7
ABORT reset value is IMPLEMENTATION DEFINED, it is chosen to
8
be zero(Do not abort incoming transactions).
8
9
9
Also for migration compatibility if the migration source (old version
10
Other fields have default values of Use Incoming.
10
qemu) doesn't send gicd_no_migration_shift_bug = 1 to destination, then
11
we shift the data of PPI to get the right data for SPI.
12
11
13
Fixes: 367b9f527becdd20ddf116e17a3c0c2bbc486920
12
If UPDATE is not set, the write is ignored. This is the only permitted
14
Cc: qemu-stable@nongnu.org
13
behavior in SMMUv3.2 and later.(6.3.14.1 Update procedure)
14
15
As this patch adds a new state to the SMMU (GBPA), it is added
16
in a new subsection for forward migration compatibility.
17
GBPA is only migrated if its value is different from the reset value.
18
It does this to be backward migration compatible if SW didn't write
19
the register.
20
21
Signed-off-by: Mostafa Saleh <smostafa@google.com>
22
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Reviewed-by: Eric Auger <eric.auger@redhat.com>
23
Reviewed-by: Eric Auger <eric.auger@redhat.com>
24
Message-id: 20230214094009.2445653-1-smostafa@google.com
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
25
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
18
Message-id: 1527816987-16108-1-git-send-email-zhaoshenglong@huawei.com
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
26
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
---
27
---
21
include/hw/intc/arm_gicv3_common.h | 1 +
28
hw/arm/smmuv3-internal.h | 7 +++++++
22
hw/intc/arm_gicv3_common.c | 79 ++++++++++++++++++++++++++++++
29
include/hw/arm/smmuv3.h | 1 +
23
hw/intc/arm_gicv3_kvm.c | 38 ++++++++++++++
30
hw/arm/smmuv3.c | 43 +++++++++++++++++++++++++++++++++++++++-
24
3 files changed, 118 insertions(+)
31
3 files changed, 50 insertions(+), 1 deletion(-)
25
32
26
diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h
33
diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h
27
index XXXXXXX..XXXXXXX 100644
34
index XXXXXXX..XXXXXXX 100644
28
--- a/include/hw/intc/arm_gicv3_common.h
35
--- a/hw/arm/smmuv3-internal.h
29
+++ b/include/hw/intc/arm_gicv3_common.h
36
+++ b/hw/arm/smmuv3-internal.h
30
@@ -XXX,XX +XXX,XX @@ struct GICv3State {
37
@@ -XXX,XX +XXX,XX @@ REG32(CR0ACK, 0x24)
31
uint32_t revision;
38
REG32(CR1, 0x28)
32
bool security_extn;
39
REG32(CR2, 0x2c)
33
bool irq_reset_nonsecure;
40
REG32(STATUSR, 0x40)
34
+ bool gicd_no_migration_shift_bug;
41
+REG32(GBPA, 0x44)
35
42
+ FIELD(GBPA, ABORT, 20, 1)
36
int dev_fd; /* kvm device fd if backed by kvm vgic support */
43
+ FIELD(GBPA, UPDATE, 31, 1)
37
Error *migration_blocker;
44
+
38
diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c
45
+/* Use incoming. */
46
+#define SMMU_GBPA_RESET_VAL 0x1000
47
+
48
REG32(IRQ_CTRL, 0x50)
49
FIELD(IRQ_CTRL, GERROR_IRQEN, 0, 1)
50
FIELD(IRQ_CTRL, PRI_IRQEN, 1, 1)
51
diff --git a/include/hw/arm/smmuv3.h b/include/hw/arm/smmuv3.h
39
index XXXXXXX..XXXXXXX 100644
52
index XXXXXXX..XXXXXXX 100644
40
--- a/hw/intc/arm_gicv3_common.c
53
--- a/include/hw/arm/smmuv3.h
41
+++ b/hw/intc/arm_gicv3_common.c
54
+++ b/include/hw/arm/smmuv3.h
42
@@ -XXX,XX +XXX,XX @@
55
@@ -XXX,XX +XXX,XX @@ struct SMMUv3State {
43
#include "hw/intc/arm_gicv3_common.h"
56
uint32_t cr[3];
44
#include "gicv3_internal.h"
57
uint32_t cr0ack;
45
#include "hw/arm/linux-boot-if.h"
58
uint32_t statusr;
46
+#include "sysemu/kvm.h"
59
+ uint32_t gbpa;
47
60
uint32_t irq_ctrl;
48
static int gicv3_pre_save(void *opaque)
61
uint32_t gerror;
49
{
62
uint32_t gerrorn;
50
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_gicv3_cpu = {
63
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
64
index XXXXXXX..XXXXXXX 100644
65
--- a/hw/arm/smmuv3.c
66
+++ b/hw/arm/smmuv3.c
67
@@ -XXX,XX +XXX,XX @@ static void smmuv3_init_regs(SMMUv3State *s)
68
s->gerror = 0;
69
s->gerrorn = 0;
70
s->statusr = 0;
71
+ s->gbpa = SMMU_GBPA_RESET_VAL;
72
}
73
74
static int smmu_get_ste(SMMUv3State *s, dma_addr_t addr, STE *buf,
75
@@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr,
76
qemu_mutex_lock(&s->mutex);
77
78
if (!smmu_enabled(s)) {
79
- status = SMMU_TRANS_DISABLE;
80
+ if (FIELD_EX32(s->gbpa, GBPA, ABORT)) {
81
+ status = SMMU_TRANS_ABORT;
82
+ } else {
83
+ status = SMMU_TRANS_DISABLE;
84
+ }
85
goto epilogue;
51
}
86
}
87
88
@@ -XXX,XX +XXX,XX @@ static MemTxResult smmu_writel(SMMUv3State *s, hwaddr offset,
89
case A_GERROR_IRQ_CFG2:
90
s->gerror_irq_cfg2 = data;
91
return MEMTX_OK;
92
+ case A_GBPA:
93
+ /*
94
+ * If UPDATE is not set, the write is ignored. This is the only
95
+ * permitted behavior in SMMUv3.2 and later.
96
+ */
97
+ if (data & R_GBPA_UPDATE_MASK) {
98
+ /* Ignore update bit as write is synchronous. */
99
+ s->gbpa = data & ~R_GBPA_UPDATE_MASK;
100
+ }
101
+ return MEMTX_OK;
102
case A_STRTAB_BASE: /* 64b */
103
s->strtab_base = deposit64(s->strtab_base, 0, 32, data);
104
return MEMTX_OK;
105
@@ -XXX,XX +XXX,XX @@ static MemTxResult smmu_readl(SMMUv3State *s, hwaddr offset,
106
case A_STATUSR:
107
*data = s->statusr;
108
return MEMTX_OK;
109
+ case A_GBPA:
110
+ *data = s->gbpa;
111
+ return MEMTX_OK;
112
case A_IRQ_CTRL:
113
case A_IRQ_CTRL_ACK:
114
*data = s->irq_ctrl;
115
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_smmuv3_queue = {
116
},
52
};
117
};
53
118
54
+static int gicv3_gicd_no_migration_shift_bug_pre_load(void *opaque)
119
+static bool smmuv3_gbpa_needed(void *opaque)
55
+{
120
+{
56
+ GICv3State *cs = opaque;
121
+ SMMUv3State *s = opaque;
57
+
122
+
58
+ /*
123
+ /* Only migrate GBPA if it has different reset value. */
59
+ * The gicd_no_migration_shift_bug flag is used for migration compatibility
124
+ return s->gbpa != SMMU_GBPA_RESET_VAL;
60
+ * for old version QEMU which may have the GICD bmp shift bug under KVM mode.
61
+ * Strictly, what we want to know is whether the migration source is using
62
+ * KVM. Since we don't have any way to determine that, we look at whether the
63
+ * destination is using KVM; this is close enough because for the older QEMU
64
+ * versions with this bug KVM -> TCG migration didn't work anyway. If the
65
+ * source is a newer QEMU without this bug it will transmit the migration
66
+ * subsection which sets the flag to true; otherwise it will remain set to
67
+ * the value we select here.
68
+ */
69
+ if (kvm_enabled()) {
70
+ cs->gicd_no_migration_shift_bug = false;
71
+ }
72
+
73
+ return 0;
74
+}
125
+}
75
+
126
+
76
+static int gicv3_gicd_no_migration_shift_bug_post_load(void *opaque,
127
+static const VMStateDescription vmstate_gbpa = {
77
+ int version_id)
128
+ .name = "smmuv3/gbpa",
78
+{
79
+ GICv3State *cs = opaque;
80
+
81
+ if (cs->gicd_no_migration_shift_bug) {
82
+ return 0;
83
+ }
84
+
85
+ /* Older versions of QEMU had a bug in the handling of state save/restore
86
+ * to the KVM GICv3: they got the offset in the bitmap arrays wrong,
87
+ * so that instead of the data for external interrupts 32 and up
88
+ * starting at bit position 32 in the bitmap, it started at bit
89
+ * position 64. If we're receiving data from a QEMU with that bug,
90
+ * we must move the data down into the right place.
91
+ */
92
+ memmove(cs->group, (uint8_t *)cs->group + GIC_INTERNAL / 8,
93
+ sizeof(cs->group) - GIC_INTERNAL / 8);
94
+ memmove(cs->grpmod, (uint8_t *)cs->grpmod + GIC_INTERNAL / 8,
95
+ sizeof(cs->grpmod) - GIC_INTERNAL / 8);
96
+ memmove(cs->enabled, (uint8_t *)cs->enabled + GIC_INTERNAL / 8,
97
+ sizeof(cs->enabled) - GIC_INTERNAL / 8);
98
+ memmove(cs->pending, (uint8_t *)cs->pending + GIC_INTERNAL / 8,
99
+ sizeof(cs->pending) - GIC_INTERNAL / 8);
100
+ memmove(cs->active, (uint8_t *)cs->active + GIC_INTERNAL / 8,
101
+ sizeof(cs->active) - GIC_INTERNAL / 8);
102
+ memmove(cs->edge_trigger, (uint8_t *)cs->edge_trigger + GIC_INTERNAL / 8,
103
+ sizeof(cs->edge_trigger) - GIC_INTERNAL / 8);
104
+
105
+ /*
106
+ * While this new version QEMU doesn't have this kind of bug as we fix it,
107
+ * so it needs to set the flag to true to indicate that and it's necessary
108
+ * for next migration to work from this new version QEMU.
109
+ */
110
+ cs->gicd_no_migration_shift_bug = true;
111
+
112
+ return 0;
113
+}
114
+
115
+const VMStateDescription vmstate_gicv3_gicd_no_migration_shift_bug = {
116
+ .name = "arm_gicv3/gicd_no_migration_shift_bug",
117
+ .version_id = 1,
129
+ .version_id = 1,
118
+ .minimum_version_id = 1,
130
+ .minimum_version_id = 1,
119
+ .pre_load = gicv3_gicd_no_migration_shift_bug_pre_load,
131
+ .needed = smmuv3_gbpa_needed,
120
+ .post_load = gicv3_gicd_no_migration_shift_bug_post_load,
121
+ .fields = (VMStateField[]) {
132
+ .fields = (VMStateField[]) {
122
+ VMSTATE_BOOL(gicd_no_migration_shift_bug, GICv3State),
133
+ VMSTATE_UINT32(gbpa, SMMUv3State),
123
+ VMSTATE_END_OF_LIST()
134
+ VMSTATE_END_OF_LIST()
124
+ }
135
+ }
125
+};
136
+};
126
+
137
+
127
static const VMStateDescription vmstate_gicv3 = {
138
static const VMStateDescription vmstate_smmuv3 = {
128
.name = "arm_gicv3",
139
.name = "smmuv3",
129
.version_id = 1,
140
.version_id = 1,
130
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_gicv3 = {
141
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_smmuv3 = {
131
VMSTATE_STRUCT_VARRAY_POINTER_UINT32(cpu, GICv3State, num_cpu,
142
132
vmstate_gicv3_cpu, GICv3CPUState),
143
VMSTATE_END_OF_LIST(),
133
VMSTATE_END_OF_LIST()
144
},
134
+ },
135
+ .subsections = (const VMStateDescription * []) {
145
+ .subsections = (const VMStateDescription * []) {
136
+ &vmstate_gicv3_gicd_no_migration_shift_bug,
146
+ &vmstate_gbpa,
137
+ NULL
147
+ NULL
138
}
148
+ }
139
};
149
};
140
150
141
@@ -XXX,XX +XXX,XX @@ static void arm_gicv3_common_reset(DeviceState *dev)
151
static void smmuv3_instance_init(Object *obj)
142
gicv3_gicd_group_set(s, i);
143
}
144
}
145
+ s->gicd_no_migration_shift_bug = true;
146
}
147
148
static void arm_gic_common_linux_init(ARMLinuxBootIf *obj,
149
diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c
150
index XXXXXXX..XXXXXXX 100644
151
--- a/hw/intc/arm_gicv3_kvm.c
152
+++ b/hw/intc/arm_gicv3_kvm.c
153
@@ -XXX,XX +XXX,XX @@ static void kvm_dist_get_edge_trigger(GICv3State *s, uint32_t offset,
154
uint32_t reg;
155
int irq;
156
157
+ /* For the KVM GICv3, affinity routing is always enabled, and the first 2
158
+ * GICD_ICFGR<n> registers are always RAZ/WI. The corresponding
159
+ * functionality is replaced by GICR_ICFGR<n>. It doesn't need to sync
160
+ * them. So it should increase the offset to skip GIC_INTERNAL irqs.
161
+ * This matches the for_each_dist_irq_reg() macro which also skips the
162
+ * first GIC_INTERNAL irqs.
163
+ */
164
+ offset += (GIC_INTERNAL * 2) / 8;
165
for_each_dist_irq_reg(irq, s->num_irq, 2) {
166
kvm_gicd_access(s, offset, &reg, false);
167
reg = half_unshuffle32(reg >> 1);
168
@@ -XXX,XX +XXX,XX @@ static void kvm_dist_put_edge_trigger(GICv3State *s, uint32_t offset,
169
uint32_t reg;
170
int irq;
171
172
+ /* For the KVM GICv3, affinity routing is always enabled, and the first 2
173
+ * GICD_ICFGR<n> registers are always RAZ/WI. The corresponding
174
+ * functionality is replaced by GICR_ICFGR<n>. It doesn't need to sync
175
+ * them. So it should increase the offset to skip GIC_INTERNAL irqs.
176
+ * This matches the for_each_dist_irq_reg() macro which also skips the
177
+ * first GIC_INTERNAL irqs.
178
+ */
179
+ offset += (GIC_INTERNAL * 2) / 8;
180
for_each_dist_irq_reg(irq, s->num_irq, 2) {
181
reg = *gic_bmp_ptr32(bmp, irq);
182
if (irq % 32 != 0) {
183
@@ -XXX,XX +XXX,XX @@ static void kvm_dist_getbmp(GICv3State *s, uint32_t offset, uint32_t *bmp)
184
uint32_t reg;
185
int irq;
186
187
+ /* For the KVM GICv3, affinity routing is always enabled, and the
188
+ * GICD_IGROUPR0/GICD_IGRPMODR0/GICD_ISENABLER0/GICD_ISPENDR0/
189
+ * GICD_ISACTIVER0 registers are always RAZ/WI. The corresponding
190
+ * functionality is replaced by the GICR registers. It doesn't need to sync
191
+ * them. So it should increase the offset to skip GIC_INTERNAL irqs.
192
+ * This matches the for_each_dist_irq_reg() macro which also skips the
193
+ * first GIC_INTERNAL irqs.
194
+ */
195
+ offset += (GIC_INTERNAL * 1) / 8;
196
for_each_dist_irq_reg(irq, s->num_irq, 1) {
197
kvm_gicd_access(s, offset, &reg, false);
198
*gic_bmp_ptr32(bmp, irq) = reg;
199
@@ -XXX,XX +XXX,XX @@ static void kvm_dist_putbmp(GICv3State *s, uint32_t offset,
200
uint32_t reg;
201
int irq;
202
203
+ /* For the KVM GICv3, affinity routing is always enabled, and the
204
+ * GICD_IGROUPR0/GICD_IGRPMODR0/GICD_ISENABLER0/GICD_ISPENDR0/
205
+ * GICD_ISACTIVER0 registers are always RAZ/WI. The corresponding
206
+ * functionality is replaced by the GICR registers. It doesn't need to sync
207
+ * them. So it should increase the offset and clroffset to skip GIC_INTERNAL
208
+ * irqs. This matches the for_each_dist_irq_reg() macro which also skips the
209
+ * first GIC_INTERNAL irqs.
210
+ */
211
+ offset += (GIC_INTERNAL * 1) / 8;
212
+ if (clroffset != 0) {
213
+ clroffset += (GIC_INTERNAL * 1) / 8;
214
+ }
215
+
216
for_each_dist_irq_reg(irq, s->num_irq, 1) {
217
/* If this bitmap is a set/clear register pair, first write to the
218
* clear-reg to clear all bits before using the set-reg to write
219
--
152
--
220
2.17.1
153
2.34.1
221
222
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
3
Since commit acc0b8b05a when running the ZynqMP ZCU102 board with
4
Message-id: 20180606152128.449-8-f4bug@amsat.org
4
a QEMU configured using --without-default-devices, we get:
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
6
$ qemu-system-aarch64 -M xlnx-zcu102
7
qemu-system-aarch64: missing object type 'usb_dwc3'
8
Abort trap: 6
9
10
Fix by adding the missing Kconfig dependency.
11
12
Fixes: acc0b8b05a ("hw/arm/xlnx-zynqmp: Connect ZynqMP's USB controllers")
13
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
14
Message-id: 20230216092327.2203-1-philmd@linaro.org
15
Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
17
---
8
hw/arm/stellaris.c | 11 ++++++-----
18
hw/arm/Kconfig | 1 +
9
1 file changed, 6 insertions(+), 5 deletions(-)
19
1 file changed, 1 insertion(+)
10
20
11
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
21
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
12
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/arm/stellaris.c
23
--- a/hw/arm/Kconfig
14
+++ b/hw/arm/stellaris.c
24
+++ b/hw/arm/Kconfig
15
@@ -XXX,XX +XXX,XX @@ static uint64_t gptm_read(void *opaque, hwaddr offset,
25
@@ -XXX,XX +XXX,XX @@ config XLNX_ZYNQMP_ARM
16
return s->rtc;
26
select XLNX_CSU_DMA
17
}
27
select XLNX_ZYNQMP
18
qemu_log_mask(LOG_UNIMP,
28
select XLNX_ZDMA
19
- "GPTM: read of TAR but timer read not supported");
29
+ select USB_DWC3
20
+ "GPTM: read of TAR but timer read not supported\n");
30
21
return 0;
31
config XLNX_VERSAL
22
case 0x4c: /* TBR */
32
bool
23
qemu_log_mask(LOG_UNIMP,
24
- "GPTM: read of TBR but timer read not supported");
25
+ "GPTM: read of TBR but timer read not supported\n");
26
return 0;
27
default:
28
qemu_log_mask(LOG_GUEST_ERROR,
29
@@ -XXX,XX +XXX,XX @@ static void stellaris_i2c_write(void *opaque, hwaddr offset,
30
break;
31
case 0x20: /* MCR */
32
if (value & 1) {
33
- qemu_log_mask(LOG_UNIMP, "stellaris_i2c: Loopback not implemented");
34
+ qemu_log_mask(LOG_UNIMP,
35
+ "stellaris_i2c: Loopback not implemented\n");
36
}
37
if (value & 0x20) {
38
qemu_log_mask(LOG_UNIMP,
39
- "stellaris_i2c: Slave mode not implemented");
40
+ "stellaris_i2c: Slave mode not implemented\n");
41
}
42
s->mcr = value & 0x31;
43
break;
44
@@ -XXX,XX +XXX,XX @@ static void stellaris_adc_write(void *opaque, hwaddr offset,
45
s->sspri = value;
46
break;
47
case 0x28: /* PSSI */
48
- qemu_log_mask(LOG_UNIMP, "ADC: sample initiate unimplemented");
49
+ qemu_log_mask(LOG_UNIMP, "ADC: sample initiate unimplemented\n");
50
break;
51
case 0x30: /* SAC */
52
s->sac = value;
53
--
33
--
54
2.17.1
34
2.34.1
55
35
56
36
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Cornelia Huck <cohuck@redhat.com>
2
2
3
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
3
Just use current_accel_name() directly.
4
Acked-by: David Gibson <david@gibson.dropbear.id.au>
4
5
Message-id: 20180606152128.449-5-f4bug@amsat.org
5
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
6
Reviewed-by: Eric Auger <eric.auger@redhat.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
9
---
8
hw/ppc/pnv_core.c | 4 ++--
10
hw/arm/virt.c | 6 +++---
9
1 file changed, 2 insertions(+), 2 deletions(-)
11
1 file changed, 3 insertions(+), 3 deletions(-)
10
12
11
diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c
13
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
12
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/ppc/pnv_core.c
15
--- a/hw/arm/virt.c
14
+++ b/hw/ppc/pnv_core.c
16
+++ b/hw/arm/virt.c
15
@@ -XXX,XX +XXX,XX @@ static uint64_t pnv_core_xscom_read(void *opaque, hwaddr addr,
17
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
16
val = 0x24f000000000000ull;
18
if (vms->secure && (kvm_enabled() || hvf_enabled())) {
17
break;
19
error_report("mach-virt: %s does not support providing "
18
default:
20
"Security extensions (TrustZone) to the guest CPU",
19
- qemu_log_mask(LOG_UNIMP, "Warning: reading reg=0x%" HWADDR_PRIx,
21
- kvm_enabled() ? "KVM" : "HVF");
20
+ qemu_log_mask(LOG_UNIMP, "Warning: reading reg=0x%" HWADDR_PRIx "\n",
22
+ current_accel_name());
21
addr);
23
exit(1);
22
}
24
}
23
25
24
@@ -XXX,XX +XXX,XX @@ static uint64_t pnv_core_xscom_read(void *opaque, hwaddr addr,
26
if (vms->virt && (kvm_enabled() || hvf_enabled())) {
25
static void pnv_core_xscom_write(void *opaque, hwaddr addr, uint64_t val,
27
error_report("mach-virt: %s does not support providing "
26
unsigned int width)
28
"Virtualization extensions to the guest CPU",
27
{
29
- kvm_enabled() ? "KVM" : "HVF");
28
- qemu_log_mask(LOG_UNIMP, "Warning: writing to reg=0x%" HWADDR_PRIx,
30
+ current_accel_name());
29
+ qemu_log_mask(LOG_UNIMP, "Warning: writing to reg=0x%" HWADDR_PRIx "\n",
31
exit(1);
30
addr);
32
}
31
}
33
34
if (vms->mte && (kvm_enabled() || hvf_enabled())) {
35
error_report("mach-virt: %s does not support providing "
36
"MTE to the guest CPU",
37
- kvm_enabled() ? "KVM" : "HVF");
38
+ current_accel_name());
39
exit(1);
40
}
32
41
33
--
42
--
34
2.17.1
43
2.34.1
35
36
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Hao Wu <wuhaotsh@google.com>
2
2
3
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
3
Havard is no longer working on the Nuvoton systems for a while
4
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
4
and won't be able to do any work on it in the future. So I'll
5
Message-id: 20180606152128.449-10-f4bug@amsat.org
5
take over maintaining the Nuvoton system from him.
6
7
Signed-off-by: Hao Wu <wuhaotsh@google.com>
8
Acked-by: Havard Skinnemoen <hskinnemoen@google.com>
9
Reviewed-by: Philippe Mathieu-Daude <philmd@linaro.org>
10
Message-id: 20230208235433.3989937-2-wuhaotsh@google.com
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
12
---
8
target/m68k/translate.c | 2 +-
13
MAINTAINERS | 2 +-
9
1 file changed, 1 insertion(+), 1 deletion(-)
14
1 file changed, 1 insertion(+), 1 deletion(-)
10
15
11
diff --git a/target/m68k/translate.c b/target/m68k/translate.c
16
diff --git a/MAINTAINERS b/MAINTAINERS
12
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
13
--- a/target/m68k/translate.c
18
--- a/MAINTAINERS
14
+++ b/target/m68k/translate.c
19
+++ b/MAINTAINERS
15
@@ -XXX,XX +XXX,XX @@ DISAS_INSN(undef)
20
@@ -XXX,XX +XXX,XX @@ F: include/hw/net/mv88w8618_eth.h
16
/* ??? This is both instructions that are as yet unimplemented
21
F: docs/system/arm/musicpal.rst
17
for the 680x0 series, as well as those that are implemented
22
18
but actually illegal for CPU32 or pre-68020. */
23
Nuvoton NPCM7xx
19
- qemu_log_mask(LOG_UNIMP, "Illegal instruction: %04x @ %08x",
24
-M: Havard Skinnemoen <hskinnemoen@google.com>
20
+ qemu_log_mask(LOG_UNIMP, "Illegal instruction: %04x @ %08x\n",
25
M: Tyrone Ting <kfting@nuvoton.com>
21
insn, s->insn_pc);
26
+M: Hao Wu <wuhaotsh@google.com>
22
gen_exception(s, s->insn_pc, EXCP_UNSUPPORTED);
27
L: qemu-arm@nongnu.org
23
}
28
S: Supported
29
F: hw/*/npcm7xx*
24
--
30
--
25
2.17.1
31
2.34.1
26
27
diff view generated by jsdifflib
1
From: Cédric Le Goater <clg@kaod.org>
1
From: Hao Wu <wuhaotsh@google.com>
2
2
3
Specs are available here :
3
Nuvoton's PSPI is a general purpose SPI module which enables
4
connections to SPI-based peripheral devices.
4
5
5
https://www.nxp.com/docs/en/application-note/AN264.pdf
6
Signed-off-by: Hao Wu <wuhaotsh@google.com>
6
7
Reviewed-by: Chris Rauer <crauer@google.com>
7
This is a simple model supporting the basic registers for led and GPIO
8
Reviewed-by: Philippe Mathieu-Daude <philmd@linaro.org>
8
mode. The device also supports two blinking rates but not the model
9
Message-id: 20230208235433.3989937-3-wuhaotsh@google.com
9
yet.
10
11
Signed-off-by: Cédric Le Goater <clg@kaod.org>
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
14
Message-id: 20180530064049.27976-7-clg@kaod.org
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
---
11
---
17
hw/misc/Makefile.objs | 1 +
12
MAINTAINERS | 6 +-
18
tests/Makefile.include | 2 +
13
include/hw/ssi/npcm_pspi.h | 53 +++++++++
19
include/hw/misc/pca9552.h | 32 +++++
14
hw/ssi/npcm_pspi.c | 221 +++++++++++++++++++++++++++++++++++++
20
include/hw/misc/pca9552_regs.h | 32 +++++
15
hw/ssi/meson.build | 2 +-
21
tests/libqos/i2c.h | 2 +
16
hw/ssi/trace-events | 5 +
22
hw/misc/pca9552.c | 240 ++++++++++++++++++++++++++++++++
17
5 files changed, 283 insertions(+), 4 deletions(-)
23
tests/pca9552-test.c | 116 +++++++++++++++
18
create mode 100644 include/hw/ssi/npcm_pspi.h
24
tests/tmp105-test.c | 2 -
19
create mode 100644 hw/ssi/npcm_pspi.c
25
default-configs/arm-softmmu.mak | 1 +
26
9 files changed, 426 insertions(+), 2 deletions(-)
27
create mode 100644 include/hw/misc/pca9552.h
28
create mode 100644 include/hw/misc/pca9552_regs.h
29
create mode 100644 hw/misc/pca9552.c
30
create mode 100644 tests/pca9552-test.c
31
20
32
diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs
21
diff --git a/MAINTAINERS b/MAINTAINERS
33
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/misc/Makefile.objs
23
--- a/MAINTAINERS
35
+++ b/hw/misc/Makefile.objs
24
+++ b/MAINTAINERS
36
@@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_SGA) += sga.o
25
@@ -XXX,XX +XXX,XX @@ M: Tyrone Ting <kfting@nuvoton.com>
37
common-obj-$(CONFIG_ISA_TESTDEV) += pc-testdev.o
26
M: Hao Wu <wuhaotsh@google.com>
38
common-obj-$(CONFIG_PCI_TESTDEV) += pci-testdev.o
27
L: qemu-arm@nongnu.org
39
common-obj-$(CONFIG_EDU) += edu.o
28
S: Supported
40
+common-obj-$(CONFIG_PCA9552) += pca9552.o
29
-F: hw/*/npcm7xx*
41
30
-F: include/hw/*/npcm7xx*
42
common-obj-y += unimp.o
31
-F: tests/qtest/npcm7xx*
43
common-obj-$(CONFIG_FW_CFG_DMA) += vmcoreinfo.o
32
+F: hw/*/npcm*
44
diff --git a/tests/Makefile.include b/tests/Makefile.include
33
+F: include/hw/*/npcm*
45
index XXXXXXX..XXXXXXX 100644
34
+F: tests/qtest/npcm*
46
--- a/tests/Makefile.include
35
F: pc-bios/npcm7xx_bootrom.bin
47
+++ b/tests/Makefile.include
36
F: roms/vbootrom
48
@@ -XXX,XX +XXX,XX @@ check-qtest-sparc64-y += tests/prom-env-test$(EXESUF)
37
F: docs/system/arm/nuvoton.rst
49
check-qtest-sparc64-y += tests/boot-serial-test$(EXESUF)
38
diff --git a/include/hw/ssi/npcm_pspi.h b/include/hw/ssi/npcm_pspi.h
50
51
check-qtest-arm-y = tests/tmp105-test$(EXESUF)
52
+check-qtest-arm-y += tests/pca9552-test$(EXESUF)
53
check-qtest-arm-y += tests/ds1338-test$(EXESUF)
54
check-qtest-arm-y += tests/m25p80-test$(EXESUF)
55
gcov-files-arm-y += hw/misc/tmp105.c
56
@@ -XXX,XX +XXX,XX @@ tests/bios-tables-test$(EXESUF): tests/bios-tables-test.o \
57
    tests/boot-sector.o tests/acpi-utils.o $(libqos-obj-y)
58
tests/pxe-test$(EXESUF): tests/pxe-test.o tests/boot-sector.o $(libqos-obj-y)
59
tests/tmp105-test$(EXESUF): tests/tmp105-test.o $(libqos-omap-obj-y)
60
+tests/pca9552-test$(EXESUF): tests/pca9552-test.o $(libqos-omap-obj-y)
61
tests/ds1338-test$(EXESUF): tests/ds1338-test.o $(libqos-imx-obj-y)
62
tests/m25p80-test$(EXESUF): tests/m25p80-test.o
63
tests/i440fx-test$(EXESUF): tests/i440fx-test.o $(libqos-pc-obj-y)
64
diff --git a/include/hw/misc/pca9552.h b/include/hw/misc/pca9552.h
65
new file mode 100644
39
new file mode 100644
66
index XXXXXXX..XXXXXXX
40
index XXXXXXX..XXXXXXX
67
--- /dev/null
41
--- /dev/null
68
+++ b/include/hw/misc/pca9552.h
42
+++ b/include/hw/ssi/npcm_pspi.h
69
@@ -XXX,XX +XXX,XX @@
43
@@ -XXX,XX +XXX,XX @@
70
+/*
44
+/*
71
+ * PCA9552 I2C LED blinker
45
+ * Nuvoton Peripheral SPI Module
72
+ *
46
+ *
73
+ * Copyright (c) 2017-2018, IBM Corporation.
47
+ * Copyright 2023 Google LLC
74
+ *
48
+ *
75
+ * This work is licensed under the terms of the GNU GPL, version 2 or
49
+ * This program is free software; you can redistribute it and/or modify it
76
+ * later. See the COPYING file in the top-level directory.
50
+ * under the terms of the GNU General Public License as published by the
51
+ * Free Software Foundation; either version 2 of the License, or
52
+ * (at your option) any later version.
53
+ *
54
+ * This program is distributed in the hope that it will be useful, but WITHOUT
55
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
56
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
57
+ * for more details.
77
+ */
58
+ */
78
+#ifndef PCA9552_H
59
+#ifndef NPCM_PSPI_H
79
+#define PCA9552_H
60
+#define NPCM_PSPI_H
80
+
61
+
81
+#include "hw/i2c/i2c.h"
62
+#include "hw/ssi/ssi.h"
82
+
63
+#include "hw/sysbus.h"
83
+#define TYPE_PCA9552 "pca9552"
64
+
84
+#define PCA9552(obj) OBJECT_CHECK(PCA9552State, (obj), TYPE_PCA9552)
65
+/*
85
+
66
+ * Number of registers in our device state structure. Don't change this without
86
+#define PCA9552_NR_REGS 10
67
+ * incrementing the version_id in the vmstate.
87
+
68
+ */
88
+typedef struct PCA9552State {
69
+#define NPCM_PSPI_NR_REGS 3
89
+ /*< private >*/
70
+
90
+ I2CSlave i2c;
71
+/**
91
+ /*< public >*/
72
+ * NPCMPSPIState - Device state for one Flash Interface Unit.
92
+
73
+ * @parent: System bus device.
93
+ uint8_t len;
74
+ * @mmio: Memory region for register access.
94
+ uint8_t pointer;
75
+ * @spi: The SPI bus mastered by this controller.
95
+
76
+ * @regs: Register contents.
96
+ uint8_t regs[PCA9552_NR_REGS];
77
+ * @irq: The interrupt request queue for this module.
97
+ uint8_t max_reg;
78
+ *
98
+ uint8_t nr_leds;
79
+ * Each PSPI has a shared bank of registers, and controls up to four chip
99
+} PCA9552State;
80
+ * selects. Each chip select has a dedicated memory region which may be used to
100
+
81
+ * read and write the flash connected to that chip select as if it were memory.
101
+#endif
82
+ */
102
diff --git a/include/hw/misc/pca9552_regs.h b/include/hw/misc/pca9552_regs.h
83
+typedef struct NPCMPSPIState {
84
+ SysBusDevice parent;
85
+
86
+ MemoryRegion mmio;
87
+
88
+ SSIBus *spi;
89
+ uint16_t regs[NPCM_PSPI_NR_REGS];
90
+ qemu_irq irq;
91
+} NPCMPSPIState;
92
+
93
+#define TYPE_NPCM_PSPI "npcm-pspi"
94
+OBJECT_DECLARE_SIMPLE_TYPE(NPCMPSPIState, NPCM_PSPI)
95
+
96
+#endif /* NPCM_PSPI_H */
97
diff --git a/hw/ssi/npcm_pspi.c b/hw/ssi/npcm_pspi.c
103
new file mode 100644
98
new file mode 100644
104
index XXXXXXX..XXXXXXX
99
index XXXXXXX..XXXXXXX
105
--- /dev/null
100
--- /dev/null
106
+++ b/include/hw/misc/pca9552_regs.h
101
+++ b/hw/ssi/npcm_pspi.c
107
@@ -XXX,XX +XXX,XX @@
102
@@ -XXX,XX +XXX,XX @@
108
+/*
103
+/*
109
+ * PCA9552 I2C LED blinker registers
104
+ * Nuvoton NPCM Peripheral SPI Module (PSPI)
110
+ *
105
+ *
111
+ * Copyright (c) 2017-2018, IBM Corporation.
106
+ * Copyright 2023 Google LLC
112
+ *
107
+ *
113
+ * This work is licensed under the terms of the GNU GPL, version 2 or
108
+ * This program is free software; you can redistribute it and/or modify it
114
+ * later. See the COPYING file in the top-level directory.
109
+ * under the terms of the GNU General Public License as published by the
110
+ * Free Software Foundation; either version 2 of the License, or
111
+ * (at your option) any later version.
112
+ *
113
+ * This program is distributed in the hope that it will be useful, but WITHOUT
114
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
115
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
116
+ * for more details.
115
+ */
117
+ */
116
+#ifndef PCA9552_REGS_H
117
+#define PCA9552_REGS_H
118
+
119
+/*
120
+ * Bits [0:3] are used to address a specific register.
121
+ */
122
+#define PCA9552_INPUT0 0 /* read only input register 0 */
123
+#define PCA9552_INPUT1 1 /* read only input register 1 */
124
+#define PCA9552_PSC0 2 /* read/write frequency prescaler 0 */
125
+#define PCA9552_PWM0 3 /* read/write PWM register 0 */
126
+#define PCA9552_PSC1 4 /* read/write frequency prescaler 1 */
127
+#define PCA9552_PWM1 5 /* read/write PWM register 1 */
128
+#define PCA9552_LS0 6 /* read/write LED0 to LED3 selector */
129
+#define PCA9552_LS1 7 /* read/write LED4 to LED7 selector */
130
+#define PCA9552_LS2 8 /* read/write LED8 to LED11 selector */
131
+#define PCA9552_LS3 9 /* read/write LED12 to LED15 selector */
132
+
133
+/*
134
+ * Bit [4] is used to activate the Auto-Increment option of the
135
+ * register address
136
+ */
137
+#define PCA9552_AUTOINC (1 << 4)
138
+
139
+#endif
140
diff --git a/tests/libqos/i2c.h b/tests/libqos/i2c.h
141
index XXXXXXX..XXXXXXX 100644
142
--- a/tests/libqos/i2c.h
143
+++ b/tests/libqos/i2c.h
144
@@ -XXX,XX +XXX,XX @@ struct I2CAdapter {
145
QTestState *qts;
146
};
147
148
+#define OMAP2_I2C_1_BASE 0x48070000
149
+
150
void i2c_send(I2CAdapter *i2c, uint8_t addr,
151
const uint8_t *buf, uint16_t len);
152
void i2c_recv(I2CAdapter *i2c, uint8_t addr,
153
diff --git a/hw/misc/pca9552.c b/hw/misc/pca9552.c
154
new file mode 100644
155
index XXXXXXX..XXXXXXX
156
--- /dev/null
157
+++ b/hw/misc/pca9552.c
158
@@ -XXX,XX +XXX,XX @@
159
+/*
160
+ * PCA9552 I2C LED blinker
161
+ *
162
+ * https://www.nxp.com/docs/en/application-note/AN264.pdf
163
+ *
164
+ * Copyright (c) 2017-2018, IBM Corporation.
165
+ *
166
+ * This work is licensed under the terms of the GNU GPL, version 2 or
167
+ * later. See the COPYING file in the top-level directory.
168
+ */
169
+
118
+
170
+#include "qemu/osdep.h"
119
+#include "qemu/osdep.h"
120
+
121
+#include "hw/irq.h"
122
+#include "hw/registerfields.h"
123
+#include "hw/ssi/npcm_pspi.h"
124
+#include "migration/vmstate.h"
125
+#include "qapi/error.h"
126
+#include "qemu/error-report.h"
171
+#include "qemu/log.h"
127
+#include "qemu/log.h"
172
+#include "hw/hw.h"
128
+#include "qemu/module.h"
173
+#include "hw/misc/pca9552.h"
129
+#include "qemu/units.h"
174
+#include "hw/misc/pca9552_regs.h"
130
+
175
+
131
+#include "trace.h"
176
+#define PCA9552_LED_ON 0x0
132
+
177
+#define PCA9552_LED_OFF 0x1
133
+REG16(PSPI_DATA, 0x0)
178
+#define PCA9552_LED_PWM0 0x2
134
+REG16(PSPI_CTL1, 0x2)
179
+#define PCA9552_LED_PWM1 0x3
135
+ FIELD(PSPI_CTL1, SPIEN, 0, 1)
180
+
136
+ FIELD(PSPI_CTL1, MOD, 2, 1)
181
+static uint8_t pca9552_pin_get_config(PCA9552State *s, int pin)
137
+ FIELD(PSPI_CTL1, EIR, 5, 1)
182
+{
138
+ FIELD(PSPI_CTL1, EIW, 6, 1)
183
+ uint8_t reg = PCA9552_LS0 + (pin / 4);
139
+ FIELD(PSPI_CTL1, SCM, 7, 1)
184
+ uint8_t shift = (pin % 4) << 1;
140
+ FIELD(PSPI_CTL1, SCIDL, 8, 1)
185
+
141
+ FIELD(PSPI_CTL1, SCDV, 9, 7)
186
+ return extract32(s->regs[reg], shift, 2);
142
+REG16(PSPI_STAT, 0x4)
187
+}
143
+ FIELD(PSPI_STAT, BSY, 0, 1)
188
+
144
+ FIELD(PSPI_STAT, RBF, 1, 1)
189
+static void pca9552_update_pin_input(PCA9552State *s)
145
+
190
+{
146
+static void npcm_pspi_update_irq(NPCMPSPIState *s)
191
+ int i;
147
+{
192
+
148
+ int level = 0;
193
+ for (i = 0; i < s->nr_leds; i++) {
149
+
194
+ uint8_t input_reg = PCA9552_INPUT0 + (i / 8);
150
+ /* Only fire IRQ when the module is enabled. */
195
+ uint8_t input_shift = (i % 8);
151
+ if (FIELD_EX16(s->regs[R_PSPI_CTL1], PSPI_CTL1, SPIEN)) {
196
+ uint8_t config = pca9552_pin_get_config(s, i);
152
+ /* Update interrupt as BSY is cleared. */
197
+
153
+ if ((!FIELD_EX16(s->regs[R_PSPI_STAT], PSPI_STAT, BSY)) &&
198
+ switch (config) {
154
+ FIELD_EX16(s->regs[R_PSPI_CTL1], PSPI_CTL1, EIW)) {
199
+ case PCA9552_LED_ON:
155
+ level = 1;
200
+ s->regs[input_reg] |= 1 << input_shift;
156
+ }
201
+ break;
157
+
202
+ case PCA9552_LED_OFF:
158
+ /* Update interrupt as RBF is set. */
203
+ s->regs[input_reg] &= ~(1 << input_shift);
159
+ if (FIELD_EX16(s->regs[R_PSPI_STAT], PSPI_STAT, RBF) &&
204
+ break;
160
+ FIELD_EX16(s->regs[R_PSPI_CTL1], PSPI_CTL1, EIR)) {
205
+ case PCA9552_LED_PWM0:
161
+ level = 1;
206
+ case PCA9552_LED_PWM1:
207
+ /* TODO */
208
+ default:
209
+ break;
210
+ }
162
+ }
211
+ }
163
+ }
212
+}
164
+ qemu_set_irq(s->irq, level);
213
+
165
+}
214
+static uint8_t pca9552_read(PCA9552State *s, uint8_t reg)
166
+
215
+{
167
+static uint16_t npcm_pspi_read_data(NPCMPSPIState *s)
216
+ switch (reg) {
168
+{
217
+ case PCA9552_INPUT0:
169
+ uint16_t value = s->regs[R_PSPI_DATA];
218
+ case PCA9552_INPUT1:
170
+
219
+ case PCA9552_PSC0:
171
+ /* Clear stat bits as the value are read out. */
220
+ case PCA9552_PWM0:
172
+ s->regs[R_PSPI_STAT] = 0;
221
+ case PCA9552_PSC1:
173
+
222
+ case PCA9552_PWM1:
174
+ return value;
223
+ case PCA9552_LS0:
175
+}
224
+ case PCA9552_LS1:
176
+
225
+ case PCA9552_LS2:
177
+static void npcm_pspi_write_data(NPCMPSPIState *s, uint16_t data)
226
+ case PCA9552_LS3:
178
+{
227
+ return s->regs[reg];
179
+ uint16_t value = 0;
180
+
181
+ if (FIELD_EX16(s->regs[R_PSPI_CTL1], PSPI_CTL1, MOD)) {
182
+ value = ssi_transfer(s->spi, extract16(data, 8, 8)) << 8;
183
+ }
184
+ value |= ssi_transfer(s->spi, extract16(data, 0, 8));
185
+ s->regs[R_PSPI_DATA] = value;
186
+
187
+ /* Mark data as available */
188
+ s->regs[R_PSPI_STAT] = R_PSPI_STAT_BSY_MASK | R_PSPI_STAT_RBF_MASK;
189
+}
190
+
191
+/* Control register read handler. */
192
+static uint64_t npcm_pspi_ctrl_read(void *opaque, hwaddr addr,
193
+ unsigned int size)
194
+{
195
+ NPCMPSPIState *s = opaque;
196
+ uint16_t value;
197
+
198
+ switch (addr) {
199
+ case A_PSPI_DATA:
200
+ value = npcm_pspi_read_data(s);
201
+ break;
202
+
203
+ case A_PSPI_CTL1:
204
+ value = s->regs[R_PSPI_CTL1];
205
+ break;
206
+
207
+ case A_PSPI_STAT:
208
+ value = s->regs[R_PSPI_STAT];
209
+ break;
210
+
228
+ default:
211
+ default:
229
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: unexpected read to register %d\n",
212
+ qemu_log_mask(LOG_GUEST_ERROR,
230
+ __func__, reg);
213
+ "%s: write to invalid offset 0x%" PRIx64 "\n",
231
+ return 0xFF;
214
+ DEVICE(s)->canonical_path, addr);
215
+ return 0;
232
+ }
216
+ }
233
+}
217
+ trace_npcm_pspi_ctrl_read(DEVICE(s)->canonical_path, addr, value);
234
+
218
+ npcm_pspi_update_irq(s);
235
+static void pca9552_write(PCA9552State *s, uint8_t reg, uint8_t data)
219
+
236
+{
220
+ return value;
237
+ switch (reg) {
221
+}
238
+ case PCA9552_PSC0:
222
+
239
+ case PCA9552_PWM0:
223
+/* Control register write handler. */
240
+ case PCA9552_PSC1:
224
+static void npcm_pspi_ctrl_write(void *opaque, hwaddr addr, uint64_t v,
241
+ case PCA9552_PWM1:
225
+ unsigned int size)
242
+ s->regs[reg] = data;
226
+{
243
+ break;
227
+ NPCMPSPIState *s = opaque;
244
+
228
+ uint16_t value = v;
245
+ case PCA9552_LS0:
229
+
246
+ case PCA9552_LS1:
230
+ trace_npcm_pspi_ctrl_write(DEVICE(s)->canonical_path, addr, value);
247
+ case PCA9552_LS2:
231
+
248
+ case PCA9552_LS3:
232
+ switch (addr) {
249
+ s->regs[reg] = data;
233
+ case A_PSPI_DATA:
250
+ pca9552_update_pin_input(s);
234
+ npcm_pspi_write_data(s, value);
251
+ break;
235
+ break;
252
+
236
+
253
+ case PCA9552_INPUT0:
237
+ case A_PSPI_CTL1:
254
+ case PCA9552_INPUT1:
238
+ s->regs[R_PSPI_CTL1] = value;
239
+ break;
240
+
241
+ case A_PSPI_STAT:
242
+ qemu_log_mask(LOG_GUEST_ERROR,
243
+ "%s: write to read-only register PSPI_STAT: 0x%08"
244
+ PRIx64 "\n", DEVICE(s)->canonical_path, v);
245
+ break;
246
+
255
+ default:
247
+ default:
256
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: unexpected write to register %d\n",
248
+ qemu_log_mask(LOG_GUEST_ERROR,
257
+ __func__, reg);
249
+ "%s: write to invalid offset 0x%" PRIx64 "\n",
250
+ DEVICE(s)->canonical_path, addr);
251
+ return;
258
+ }
252
+ }
259
+}
253
+ npcm_pspi_update_irq(s);
260
+
254
+}
261
+/*
255
+
262
+ * When Auto-Increment is on, the register address is incremented
256
+static const MemoryRegionOps npcm_pspi_ctrl_ops = {
263
+ * after each byte is sent to or received by the device. The index
257
+ .read = npcm_pspi_ctrl_read,
264
+ * rollovers to 0 when the maximum register address is reached.
258
+ .write = npcm_pspi_ctrl_write,
265
+ */
259
+ .endianness = DEVICE_LITTLE_ENDIAN,
266
+static void pca9552_autoinc(PCA9552State *s)
260
+ .valid = {
267
+{
261
+ .min_access_size = 1,
268
+ if (s->pointer != 0xFF && s->pointer & PCA9552_AUTOINC) {
262
+ .max_access_size = 2,
269
+ uint8_t reg = s->pointer & 0xf;
263
+ .unaligned = false,
270
+
264
+ },
271
+ reg = (reg + 1) % (s->max_reg + 1);
265
+ .impl = {
272
+ s->pointer = reg | PCA9552_AUTOINC;
266
+ .min_access_size = 2,
273
+ }
267
+ .max_access_size = 2,
274
+}
268
+ .unaligned = false,
275
+
269
+ },
276
+static int pca9552_recv(I2CSlave *i2c)
270
+};
277
+{
271
+
278
+ PCA9552State *s = PCA9552(i2c);
272
+static void npcm_pspi_enter_reset(Object *obj, ResetType type)
279
+ uint8_t ret;
273
+{
280
+
274
+ NPCMPSPIState *s = NPCM_PSPI(obj);
281
+ ret = pca9552_read(s, s->pointer & 0xf);
275
+
282
+
276
+ trace_npcm_pspi_enter_reset(DEVICE(obj)->canonical_path, type);
283
+ /*
277
+ memset(s->regs, 0, sizeof(s->regs));
284
+ * From the Specs:
278
+}
285
+ *
279
+
286
+ * Important Note: When a Read sequence is initiated and the
280
+static void npcm_pspi_realize(DeviceState *dev, Error **errp)
287
+ * AI bit is set to Logic Level 1, the Read Sequence MUST
281
+{
288
+ * start by a register different from 0.
282
+ NPCMPSPIState *s = NPCM_PSPI(dev);
289
+ *
283
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
290
+ * I don't know what should be done in this case, so throw an
284
+ Object *obj = OBJECT(dev);
291
+ * error.
285
+
292
+ */
286
+ s->spi = ssi_create_bus(dev, "pspi");
293
+ if (s->pointer == PCA9552_AUTOINC) {
287
+ memory_region_init_io(&s->mmio, obj, &npcm_pspi_ctrl_ops, s,
294
+ qemu_log_mask(LOG_GUEST_ERROR,
288
+ "mmio", 4 * KiB);
295
+ "%s: Autoincrement read starting with register 0\n",
289
+ sysbus_init_mmio(sbd, &s->mmio);
296
+ __func__);
290
+ sysbus_init_irq(sbd, &s->irq);
297
+ }
291
+}
298
+
292
+
299
+ pca9552_autoinc(s);
293
+static const VMStateDescription vmstate_npcm_pspi = {
300
+
294
+ .name = "npcm-pspi",
301
+ return ret;
302
+}
303
+
304
+static int pca9552_send(I2CSlave *i2c, uint8_t data)
305
+{
306
+ PCA9552State *s = PCA9552(i2c);
307
+
308
+ /* First byte sent by is the register address */
309
+ if (s->len == 0) {
310
+ s->pointer = data;
311
+ s->len++;
312
+ } else {
313
+ pca9552_write(s, s->pointer & 0xf, data);
314
+
315
+ pca9552_autoinc(s);
316
+ }
317
+
318
+ return 0;
319
+}
320
+
321
+static int pca9552_event(I2CSlave *i2c, enum i2c_event event)
322
+{
323
+ PCA9552State *s = PCA9552(i2c);
324
+
325
+ s->len = 0;
326
+ return 0;
327
+}
328
+
329
+static const VMStateDescription pca9552_vmstate = {
330
+ .name = "PCA9552",
331
+ .version_id = 0,
295
+ .version_id = 0,
332
+ .minimum_version_id = 0,
296
+ .minimum_version_id = 0,
333
+ .fields = (VMStateField[]) {
297
+ .fields = (VMStateField[]) {
334
+ VMSTATE_UINT8(len, PCA9552State),
298
+ VMSTATE_UINT16_ARRAY(regs, NPCMPSPIState, NPCM_PSPI_NR_REGS),
335
+ VMSTATE_UINT8(pointer, PCA9552State),
299
+ VMSTATE_END_OF_LIST(),
336
+ VMSTATE_UINT8_ARRAY(regs, PCA9552State, PCA9552_NR_REGS),
300
+ },
337
+ VMSTATE_I2C_SLAVE(i2c, PCA9552State),
338
+ VMSTATE_END_OF_LIST()
339
+ }
340
+};
301
+};
341
+
302
+
342
+static void pca9552_reset(DeviceState *dev)
303
+
343
+{
304
+static void npcm_pspi_class_init(ObjectClass *klass, void *data)
344
+ PCA9552State *s = PCA9552(dev);
305
+{
345
+
306
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
346
+ s->regs[PCA9552_PSC0] = 0xFF;
347
+ s->regs[PCA9552_PWM0] = 0x80;
348
+ s->regs[PCA9552_PSC1] = 0xFF;
349
+ s->regs[PCA9552_PWM1] = 0x80;
350
+ s->regs[PCA9552_LS0] = 0x55; /* all OFF */
351
+ s->regs[PCA9552_LS1] = 0x55;
352
+ s->regs[PCA9552_LS2] = 0x55;
353
+ s->regs[PCA9552_LS3] = 0x55;
354
+
355
+ pca9552_update_pin_input(s);
356
+
357
+ s->pointer = 0xFF;
358
+ s->len = 0;
359
+}
360
+
361
+static void pca9552_initfn(Object *obj)
362
+{
363
+ PCA9552State *s = PCA9552(obj);
364
+
365
+ /* If support for the other PCA955X devices are implemented, these
366
+ * constant values might be part of class structure describing the
367
+ * PCA955X device
368
+ */
369
+ s->max_reg = PCA9552_LS3;
370
+ s->nr_leds = 16;
371
+}
372
+
373
+static void pca9552_class_init(ObjectClass *klass, void *data)
374
+{
375
+ DeviceClass *dc = DEVICE_CLASS(klass);
307
+ DeviceClass *dc = DEVICE_CLASS(klass);
376
+ I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
308
+
377
+
309
+ dc->desc = "NPCM Peripheral SPI Module";
378
+ k->event = pca9552_event;
310
+ dc->realize = npcm_pspi_realize;
379
+ k->recv = pca9552_recv;
311
+ dc->vmsd = &vmstate_npcm_pspi;
380
+ k->send = pca9552_send;
312
+ rc->phases.enter = npcm_pspi_enter_reset;
381
+ dc->reset = pca9552_reset;
313
+}
382
+ dc->vmsd = &pca9552_vmstate;
314
+
383
+}
315
+static const TypeInfo npcm_pspi_types[] = {
384
+
316
+ {
385
+static const TypeInfo pca9552_info = {
317
+ .name = TYPE_NPCM_PSPI,
386
+ .name = TYPE_PCA9552,
318
+ .parent = TYPE_SYS_BUS_DEVICE,
387
+ .parent = TYPE_I2C_SLAVE,
319
+ .instance_size = sizeof(NPCMPSPIState),
388
+ .instance_init = pca9552_initfn,
320
+ .class_init = npcm_pspi_class_init,
389
+ .instance_size = sizeof(PCA9552State),
321
+ },
390
+ .class_init = pca9552_class_init,
391
+};
322
+};
392
+
323
+DEFINE_TYPES(npcm_pspi_types);
393
+static void pca9552_register_types(void)
324
diff --git a/hw/ssi/meson.build b/hw/ssi/meson.build
394
+{
325
index XXXXXXX..XXXXXXX 100644
395
+ type_register_static(&pca9552_info);
326
--- a/hw/ssi/meson.build
396
+}
327
+++ b/hw/ssi/meson.build
397
+
398
+type_init(pca9552_register_types)
399
diff --git a/tests/pca9552-test.c b/tests/pca9552-test.c
400
new file mode 100644
401
index XXXXXXX..XXXXXXX
402
--- /dev/null
403
+++ b/tests/pca9552-test.c
404
@@ -XXX,XX +XXX,XX @@
328
@@ -XXX,XX +XXX,XX @@
405
+/*
329
softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_smc.c'))
406
+ * QTest testcase for the PCA9552 LED blinker
330
softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('mss-spi.c'))
407
+ *
331
-softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_fiu.c'))
408
+ * Copyright (c) 2017-2018, IBM Corporation.
332
+softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_fiu.c', 'npcm_pspi.c'))
409
+ *
333
softmmu_ss.add(when: 'CONFIG_PL022', if_true: files('pl022.c'))
410
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
334
softmmu_ss.add(when: 'CONFIG_SIFIVE_SPI', if_true: files('sifive_spi.c'))
411
+ * See the COPYING file in the top-level directory.
335
softmmu_ss.add(when: 'CONFIG_SSI', if_true: files('ssi.c'))
412
+ */
336
diff --git a/hw/ssi/trace-events b/hw/ssi/trace-events
413
+
414
+#include "qemu/osdep.h"
415
+
416
+#include "libqtest.h"
417
+#include "libqos/i2c.h"
418
+#include "hw/misc/pca9552_regs.h"
419
+
420
+#define PCA9552_TEST_ID "pca9552-test"
421
+#define PCA9552_TEST_ADDR 0x60
422
+
423
+static I2CAdapter *i2c;
424
+
425
+static uint8_t pca9552_get8(I2CAdapter *i2c, uint8_t addr, uint8_t reg)
426
+{
427
+ uint8_t resp[1];
428
+ i2c_send(i2c, addr, &reg, 1);
429
+ i2c_recv(i2c, addr, resp, 1);
430
+ return resp[0];
431
+}
432
+
433
+static void pca9552_set8(I2CAdapter *i2c, uint8_t addr, uint8_t reg,
434
+ uint8_t value)
435
+{
436
+ uint8_t cmd[2];
437
+ uint8_t resp[1];
438
+
439
+ cmd[0] = reg;
440
+ cmd[1] = value;
441
+ i2c_send(i2c, addr, cmd, 2);
442
+ i2c_recv(i2c, addr, resp, 1);
443
+ g_assert_cmphex(resp[0], ==, cmd[1]);
444
+}
445
+
446
+static void receive_autoinc(void)
447
+{
448
+ uint8_t resp;
449
+ uint8_t reg = PCA9552_LS0 | PCA9552_AUTOINC;
450
+
451
+ i2c_send(i2c, PCA9552_TEST_ADDR, &reg, 1);
452
+
453
+ /* PCA9552_LS0 */
454
+ i2c_recv(i2c, PCA9552_TEST_ADDR, &resp, 1);
455
+ g_assert_cmphex(resp, ==, 0x54);
456
+
457
+ /* PCA9552_LS1 */
458
+ i2c_recv(i2c, PCA9552_TEST_ADDR, &resp, 1);
459
+ g_assert_cmphex(resp, ==, 0x55);
460
+
461
+ /* PCA9552_LS2 */
462
+ i2c_recv(i2c, PCA9552_TEST_ADDR, &resp, 1);
463
+ g_assert_cmphex(resp, ==, 0x55);
464
+
465
+ /* PCA9552_LS3 */
466
+ i2c_recv(i2c, PCA9552_TEST_ADDR, &resp, 1);
467
+ g_assert_cmphex(resp, ==, 0x54);
468
+}
469
+
470
+static void send_and_receive(void)
471
+{
472
+ uint8_t value;
473
+
474
+ value = pca9552_get8(i2c, PCA9552_TEST_ADDR, PCA9552_LS0);
475
+ g_assert_cmphex(value, ==, 0x55);
476
+
477
+ value = pca9552_get8(i2c, PCA9552_TEST_ADDR, PCA9552_INPUT0);
478
+ g_assert_cmphex(value, ==, 0x0);
479
+
480
+ /* Switch on LED 0 */
481
+ pca9552_set8(i2c, PCA9552_TEST_ADDR, PCA9552_LS0, 0x54);
482
+ value = pca9552_get8(i2c, PCA9552_TEST_ADDR, PCA9552_LS0);
483
+ g_assert_cmphex(value, ==, 0x54);
484
+
485
+ value = pca9552_get8(i2c, PCA9552_TEST_ADDR, PCA9552_INPUT0);
486
+ g_assert_cmphex(value, ==, 0x01);
487
+
488
+ /* Switch on LED 12 */
489
+ pca9552_set8(i2c, PCA9552_TEST_ADDR, PCA9552_LS3, 0x54);
490
+ value = pca9552_get8(i2c, PCA9552_TEST_ADDR, PCA9552_LS3);
491
+ g_assert_cmphex(value, ==, 0x54);
492
+
493
+ value = pca9552_get8(i2c, PCA9552_TEST_ADDR, PCA9552_INPUT1);
494
+ g_assert_cmphex(value, ==, 0x10);
495
+}
496
+
497
+int main(int argc, char **argv)
498
+{
499
+ QTestState *s = NULL;
500
+ int ret;
501
+
502
+ g_test_init(&argc, &argv, NULL);
503
+
504
+ s = qtest_start("-machine n800 "
505
+ "-device pca9552,bus=i2c-bus.0,id=" PCA9552_TEST_ID
506
+ ",address=0x60");
507
+ i2c = omap_i2c_create(s, OMAP2_I2C_1_BASE);
508
+
509
+ qtest_add_func("/pca9552/tx-rx", send_and_receive);
510
+ qtest_add_func("/pca9552/rx-autoinc", receive_autoinc);
511
+
512
+ ret = g_test_run();
513
+
514
+ if (s) {
515
+ qtest_quit(s);
516
+ }
517
+ g_free(i2c);
518
+
519
+ return ret;
520
+}
521
diff --git a/tests/tmp105-test.c b/tests/tmp105-test.c
522
index XXXXXXX..XXXXXXX 100644
337
index XXXXXXX..XXXXXXX 100644
523
--- a/tests/tmp105-test.c
338
--- a/hw/ssi/trace-events
524
+++ b/tests/tmp105-test.c
339
+++ b/hw/ssi/trace-events
525
@@ -XXX,XX +XXX,XX @@
340
@@ -XXX,XX +XXX,XX @@ npcm7xx_fiu_ctrl_write(const char *id, uint64_t addr, uint32_t data) "%s offset:
526
#include "qapi/qmp/qdict.h"
341
npcm7xx_fiu_flash_read(const char *id, int cs, uint64_t addr, unsigned int size, uint64_t value) "%s[%d] offset: 0x%08" PRIx64 " size: %u value: 0x%" PRIx64
527
#include "hw/misc/tmp105_regs.h"
342
npcm7xx_fiu_flash_write(const char *id, unsigned cs, uint64_t addr, unsigned int size, uint64_t value) "%s[%d] offset: 0x%08" PRIx64 " size: %u value: 0x%" PRIx64
528
343
529
-#define OMAP2_I2C_1_BASE 0x48070000
344
+# npcm_pspi.c
530
-
345
+npcm_pspi_enter_reset(const char *id, int reset_type) "%s reset type: %d"
531
#define TMP105_TEST_ID "tmp105-test"
346
+npcm_pspi_ctrl_read(const char *id, uint64_t addr, uint16_t data) "%s offset: 0x%03" PRIx64 " value: 0x%04" PRIx16
532
#define TMP105_TEST_ADDR 0x49
347
+npcm_pspi_ctrl_write(const char *id, uint64_t addr, uint16_t data) "%s offset: 0x%03" PRIx64 " value: 0x%04" PRIx16
533
348
+
534
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
349
# ibex_spi_host.c
535
index XXXXXXX..XXXXXXX 100644
350
536
--- a/default-configs/arm-softmmu.mak
351
ibex_spi_host_reset(const char *msg) "%s"
537
+++ b/default-configs/arm-softmmu.mak
538
@@ -XXX,XX +XXX,XX @@ CONFIG_TSC2005=y
539
CONFIG_LM832X=y
540
CONFIG_TMP105=y
541
CONFIG_TMP421=y
542
+CONFIG_PCA9552=y
543
CONFIG_STELLARIS=y
544
CONFIG_STELLARIS_INPUT=y
545
CONFIG_STELLARIS_ENET=y
546
--
352
--
547
2.17.1
353
2.34.1
548
549
diff view generated by jsdifflib
1
From: Cédric Le Goater <clg@kaod.org>
1
From: Hao Wu <wuhaotsh@google.com>
2
2
3
The Witherspoon boards are OpenPOWER system hosting POWER9 Processors.
3
Signed-off-by: Hao Wu <wuhaotsh@google.com>
4
Add support for their BMC including a couple of I2C devices as found
4
Reviewed-by: Titus Rwantare <titusr@google.com>
5
on real HW.
5
Reviewed-by: Philippe Mathieu-Daude <philmd@linaro.org>
6
6
Message-id: 20230208235433.3989937-4-wuhaotsh@google.com
7
Signed-off-by: Cédric Le Goater <clg@kaod.org>
8
Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
9
Message-id: 20180530064049.27976-3-clg@kaod.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
8
---
12
hw/arm/aspeed.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
9
docs/system/arm/nuvoton.rst | 2 +-
13
1 file changed, 49 insertions(+)
10
include/hw/arm/npcm7xx.h | 2 ++
11
hw/arm/npcm7xx.c | 25 +++++++++++++++++++++++--
12
3 files changed, 26 insertions(+), 3 deletions(-)
14
13
15
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
14
diff --git a/docs/system/arm/nuvoton.rst b/docs/system/arm/nuvoton.rst
16
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/aspeed.c
16
--- a/docs/system/arm/nuvoton.rst
18
+++ b/hw/arm/aspeed.c
17
+++ b/docs/system/arm/nuvoton.rst
19
@@ -XXX,XX +XXX,XX @@ enum {
18
@@ -XXX,XX +XXX,XX @@ Supported devices
20
PALMETTO_BMC,
19
* SMBus controller (SMBF)
21
AST2500_EVB,
20
* Ethernet controller (EMC)
22
ROMULUS_BMC,
21
* Tachometer
23
+ WITHERSPOON_BMC,
22
+ * Peripheral SPI controller (PSPI)
23
24
Missing devices
25
---------------
26
@@ -XXX,XX +XXX,XX @@ Missing devices
27
28
* Ethernet controller (GMAC)
29
* USB device (USBD)
30
- * Peripheral SPI controller (PSPI)
31
* SD/MMC host
32
* PECI interface
33
* PCI and PCIe root complex and bridges
34
diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h
35
index XXXXXXX..XXXXXXX 100644
36
--- a/include/hw/arm/npcm7xx.h
37
+++ b/include/hw/arm/npcm7xx.h
38
@@ -XXX,XX +XXX,XX @@
39
#include "hw/nvram/npcm7xx_otp.h"
40
#include "hw/timer/npcm7xx_timer.h"
41
#include "hw/ssi/npcm7xx_fiu.h"
42
+#include "hw/ssi/npcm_pspi.h"
43
#include "hw/usb/hcd-ehci.h"
44
#include "hw/usb/hcd-ohci.h"
45
#include "target/arm/cpu.h"
46
@@ -XXX,XX +XXX,XX @@ struct NPCM7xxState {
47
NPCM7xxFIUState fiu[2];
48
NPCM7xxEMCState emc[2];
49
NPCM7xxSDHCIState mmc;
50
+ NPCMPSPIState pspi[2];
24
};
51
};
25
52
26
/* Palmetto hardware value: 0x120CE416 */
53
#define TYPE_NPCM7XX "npcm7xx"
27
@@ -XXX,XX +XXX,XX @@ enum {
54
diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c
28
SCU_AST2500_HW_STRAP_ACPI_ENABLE | \
55
index XXXXXXX..XXXXXXX 100644
29
SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER))
56
--- a/hw/arm/npcm7xx.c
30
57
+++ b/hw/arm/npcm7xx.c
31
+/* Witherspoon hardware value: 0xF10AD216 (but use romulus definition) */
58
@@ -XXX,XX +XXX,XX @@ enum NPCM7xxInterrupt {
32
+#define WITHERSPOON_BMC_HW_STRAP1 ROMULUS_BMC_HW_STRAP1
59
NPCM7XX_EMC1RX_IRQ = 15,
33
+
60
NPCM7XX_EMC1TX_IRQ,
34
static void palmetto_bmc_i2c_init(AspeedBoardState *bmc);
61
NPCM7XX_MMC_IRQ = 26,
35
static void ast2500_evb_i2c_init(AspeedBoardState *bmc);
62
+ NPCM7XX_PSPI2_IRQ = 28,
36
+static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc);
63
+ NPCM7XX_PSPI1_IRQ = 31,
37
64
NPCM7XX_TIMER0_IRQ = 32, /* Timer Module 0 */
38
static const AspeedBoardConfig aspeed_boards[] = {
65
NPCM7XX_TIMER1_IRQ,
39
[PALMETTO_BMC] = {
66
NPCM7XX_TIMER2_IRQ,
40
@@ -XXX,XX +XXX,XX @@ static const AspeedBoardConfig aspeed_boards[] = {
67
@@ -XXX,XX +XXX,XX @@ static const hwaddr npcm7xx_emc_addr[] = {
41
.spi_model = "mx66l1g45g",
68
0xf0826000,
42
.num_cs = 2,
43
},
44
+ [WITHERSPOON_BMC] = {
45
+ .soc_name = "ast2500-a1",
46
+ .hw_strap1 = WITHERSPOON_BMC_HW_STRAP1,
47
+ .fmc_model = "mx25l25635e",
48
+ .spi_model = "mx66l1g45g",
49
+ .num_cs = 2,
50
+ .i2c_init = witherspoon_bmc_i2c_init,
51
+ },
52
};
69
};
53
70
54
#define FIRMWARE_ADDR 0x0
71
+/* Register base address for each PSPI Module */
55
@@ -XXX,XX +XXX,XX @@ static const TypeInfo romulus_bmc_type = {
72
+static const hwaddr npcm7xx_pspi_addr[] = {
56
.class_init = romulus_bmc_class_init,
73
+ 0xf0200000,
57
};
74
+ 0xf0201000,
58
59
+static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
60
+{
61
+ AspeedSoCState *soc = &bmc->soc;
62
+
63
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c);
64
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c);
65
+
66
+ /* The Witherspoon expects a TMP275 but a TMP105 is compatible */
67
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp105", 0x4a);
68
+}
69
+
70
+static void witherspoon_bmc_init(MachineState *machine)
71
+{
72
+ aspeed_board_init(machine, &aspeed_boards[WITHERSPOON_BMC]);
73
+}
74
+
75
+static void witherspoon_bmc_class_init(ObjectClass *oc, void *data)
76
+{
77
+ MachineClass *mc = MACHINE_CLASS(oc);
78
+
79
+ mc->desc = "OpenPOWER Witherspoon BMC (ARM1176)";
80
+ mc->init = witherspoon_bmc_init;
81
+ mc->max_cpus = 1;
82
+ mc->no_sdcard = 1;
83
+ mc->no_floppy = 1;
84
+ mc->no_cdrom = 1;
85
+ mc->no_parallel = 1;
86
+}
87
+
88
+static const TypeInfo witherspoon_bmc_type = {
89
+ .name = MACHINE_TYPE_NAME("witherspoon-bmc"),
90
+ .parent = TYPE_MACHINE,
91
+ .class_init = witherspoon_bmc_class_init,
92
+};
75
+};
93
+
76
+
94
static void aspeed_machine_init(void)
77
static const struct {
95
{
78
hwaddr regs_addr;
96
type_register_static(&palmetto_bmc_type);
79
uint32_t unconnected_pins;
97
type_register_static(&ast2500_evb_type);
80
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_init(Object *obj)
98
type_register_static(&romulus_bmc_type);
81
object_initialize_child(obj, "emc[*]", &s->emc[i], TYPE_NPCM7XX_EMC);
99
+ type_register_static(&witherspoon_bmc_type);
82
}
83
84
+ for (i = 0; i < ARRAY_SIZE(s->pspi); i++) {
85
+ object_initialize_child(obj, "pspi[*]", &s->pspi[i], TYPE_NPCM_PSPI);
86
+ }
87
+
88
object_initialize_child(obj, "mmc", &s->mmc, TYPE_NPCM7XX_SDHCI);
100
}
89
}
101
90
102
type_init(aspeed_machine_init)
91
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)
92
sysbus_connect_irq(SYS_BUS_DEVICE(&s->mmc), 0,
93
npcm7xx_irq(s, NPCM7XX_MMC_IRQ));
94
95
+ /* PSPI */
96
+ QEMU_BUILD_BUG_ON(ARRAY_SIZE(npcm7xx_pspi_addr) != ARRAY_SIZE(s->pspi));
97
+ for (i = 0; i < ARRAY_SIZE(s->pspi); i++) {
98
+ SysBusDevice *sbd = SYS_BUS_DEVICE(&s->pspi[i]);
99
+ int irq = (i == 0) ? NPCM7XX_PSPI1_IRQ : NPCM7XX_PSPI2_IRQ;
100
+
101
+ sysbus_realize(sbd, &error_abort);
102
+ sysbus_mmio_map(sbd, 0, npcm7xx_pspi_addr[i]);
103
+ sysbus_connect_irq(sbd, 0, npcm7xx_irq(s, irq));
104
+ }
105
+
106
create_unimplemented_device("npcm7xx.shm", 0xc0001000, 4 * KiB);
107
create_unimplemented_device("npcm7xx.vdmx", 0xe0800000, 4 * KiB);
108
create_unimplemented_device("npcm7xx.pcierc", 0xe1000000, 64 * KiB);
109
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)
110
create_unimplemented_device("npcm7xx.peci", 0xf0100000, 4 * KiB);
111
create_unimplemented_device("npcm7xx.siox[1]", 0xf0101000, 4 * KiB);
112
create_unimplemented_device("npcm7xx.siox[2]", 0xf0102000, 4 * KiB);
113
- create_unimplemented_device("npcm7xx.pspi1", 0xf0200000, 4 * KiB);
114
- create_unimplemented_device("npcm7xx.pspi2", 0xf0201000, 4 * KiB);
115
create_unimplemented_device("npcm7xx.ahbpci", 0xf0400000, 1 * MiB);
116
create_unimplemented_device("npcm7xx.mcphy", 0xf05f0000, 64 * KiB);
117
create_unimplemented_device("npcm7xx.gmac1", 0xf0802000, 8 * KiB);
103
--
118
--
104
2.17.1
119
2.34.1
105
106
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Jean-Philippe Brucker <jean-philippe@linaro.org>
2
2
3
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
3
Addresses targeting the second translation table (TTB1) in the SMMU have
4
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
4
all upper bits set. Ensure the IOMMU region covers all 64 bits.
5
Message-id: 20180606152128.449-4-f4bug@amsat.org
5
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
8
Reviewed-by: Eric Auger <eric.auger@redhat.com>
9
Message-id: 20230214171921.1917916-2-jean-philippe@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
11
---
8
hw/display/xlnx_dp.c | 4 +++-
12
include/hw/arm/smmu-common.h | 2 --
9
1 file changed, 3 insertions(+), 1 deletion(-)
13
hw/arm/smmu-common.c | 2 +-
14
2 files changed, 1 insertion(+), 3 deletions(-)
10
15
11
diff --git a/hw/display/xlnx_dp.c b/hw/display/xlnx_dp.c
16
diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h
12
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/display/xlnx_dp.c
18
--- a/include/hw/arm/smmu-common.h
14
+++ b/hw/display/xlnx_dp.c
19
+++ b/include/hw/arm/smmu-common.h
15
@@ -XXX,XX +XXX,XX @@ static void xlnx_dp_avbufm_write(void *opaque, hwaddr offset, uint64_t value,
20
@@ -XXX,XX +XXX,XX @@
16
case AV_BUF_STC_SNAPSHOT1:
21
#define SMMU_PCI_DEVFN_MAX 256
17
case AV_BUF_HCOUNT_VCOUNT_INT0:
22
#define SMMU_PCI_DEVFN(sid) (sid & 0xFF)
18
case AV_BUF_HCOUNT_VCOUNT_INT1:
23
19
- qemu_log_mask(LOG_UNIMP, "avbufm: unimplmented");
24
-#define SMMU_MAX_VA_BITS 48
20
+ qemu_log_mask(LOG_UNIMP, "avbufm: unimplemented register 0x%04"
25
-
21
+ PRIx64 "\n",
26
/*
22
+ offset << 2);
27
* Page table walk error types
23
break;
28
*/
24
default:
29
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
25
s->avbufm_registers[offset] = value;
30
index XXXXXXX..XXXXXXX 100644
31
--- a/hw/arm/smmu-common.c
32
+++ b/hw/arm/smmu-common.c
33
@@ -XXX,XX +XXX,XX @@ static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn)
34
35
memory_region_init_iommu(&sdev->iommu, sizeof(sdev->iommu),
36
s->mrtypename,
37
- OBJECT(s), name, 1ULL << SMMU_MAX_VA_BITS);
38
+ OBJECT(s), name, UINT64_MAX);
39
address_space_init(&sdev->as,
40
MEMORY_REGION(&sdev->iommu), name);
41
trace_smmu_add_mr(name);
26
--
42
--
27
2.17.1
43
2.34.1
28
29
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Jean-Philippe Brucker <jean-philippe@linaro.org>
2
2
3
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
3
Addresses targeting the second translation table (TTB1) in the SMMU have
4
Message-id: 20180606152128.449-2-f4bug@amsat.org
4
all upper bits set (except for the top byte when TBI is enabled). Fix
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
the TTB1 check.
6
7
Reported-by: Ola Hugosson <ola.hugosson@arm.com>
8
Reviewed-by: Eric Auger <eric.auger@redhat.com>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
11
Message-id: 20230214171921.1917916-3-jean-philippe@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
hw/sd/milkymist-memcard.c | 2 +-
14
hw/arm/smmu-common.c | 2 +-
9
1 file changed, 1 insertion(+), 1 deletion(-)
15
1 file changed, 1 insertion(+), 1 deletion(-)
10
16
11
diff --git a/hw/sd/milkymist-memcard.c b/hw/sd/milkymist-memcard.c
17
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
12
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/sd/milkymist-memcard.c
19
--- a/hw/arm/smmu-common.c
14
+++ b/hw/sd/milkymist-memcard.c
20
+++ b/hw/arm/smmu-common.c
15
@@ -XXX,XX +XXX,XX @@ static uint64_t memcard_read(void *opaque, hwaddr addr,
21
@@ -XXX,XX +XXX,XX @@ SMMUTransTableInfo *select_tt(SMMUTransCfg *cfg, dma_addr_t iova)
16
r = s->response[s->response_read_ptr++];
22
/* there is a ttbr0 region and we are in it (high bits all zero) */
17
if (s->response_read_ptr > s->response_len) {
23
return &cfg->tt[0];
18
qemu_log_mask(LOG_GUEST_ERROR, "milkymist_memcard: "
24
} else if (cfg->tt[1].tsz &&
19
- "read more cmd bytes than available. Clipping.");
25
- !extract64(iova, 64 - cfg->tt[1].tsz, cfg->tt[1].tsz - tbi_byte)) {
20
+ "read more cmd bytes than available: clipping\n");
26
+ sextract64(iova, 64 - cfg->tt[1].tsz, cfg->tt[1].tsz - tbi_byte) == -1) {
21
s->response_read_ptr = 0;
27
/* there is a ttbr1 region and we are in it (high bits all one) */
22
}
28
return &cfg->tt[1];
23
}
29
} else if (!cfg->tt[0].tsz) {
24
--
30
--
25
2.17.1
31
2.34.1
26
27
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Claudio Fontana <cfontana@suse.de>
2
2
3
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
3
make it clearer from the name that this is a tcg-only function.
4
Message-id: 20180606152128.449-9-f4bug@amsat.org
4
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Claudio Fontana <cfontana@suse.de>
6
Signed-off-by: Fabiano Rosas <farosas@suse.de>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
11
---
8
target/arm/helper.c | 4 ++--
12
target/arm/helper.c | 4 ++--
9
1 file changed, 2 insertions(+), 2 deletions(-)
13
1 file changed, 2 insertions(+), 2 deletions(-)
10
14
11
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
diff --git a/target/arm/helper.c b/target/arm/helper.c
12
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/helper.c
17
--- a/target/arm/helper.c
14
+++ b/target/arm/helper.c
18
+++ b/target/arm/helper.c
15
@@ -XXX,XX +XXX,XX @@ void hw_breakpoint_update(ARMCPU *cpu, int n)
19
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs)
16
case 4: /* unlinked address mismatch (reserved if AArch64) */
20
* trapped to the hypervisor in KVM.
17
case 5: /* linked address mismatch (reserved if AArch64) */
21
*/
18
qemu_log_mask(LOG_UNIMP,
22
#ifdef CONFIG_TCG
19
- "arm: address mismatch breakpoint types not implemented");
23
-static void handle_semihosting(CPUState *cs)
20
+ "arm: address mismatch breakpoint types not implemented\n");
24
+static void tcg_handle_semihosting(CPUState *cs)
25
{
26
ARMCPU *cpu = ARM_CPU(cs);
27
CPUARMState *env = &cpu->env;
28
@@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cs)
29
*/
30
#ifdef CONFIG_TCG
31
if (cs->exception_index == EXCP_SEMIHOST) {
32
- handle_semihosting(cs);
33
+ tcg_handle_semihosting(cs);
21
return;
34
return;
22
case 0: /* unlinked address match */
35
}
23
case 1: /* linked address match */
36
#endif
24
@@ -XXX,XX +XXX,XX @@ void hw_breakpoint_update(ARMCPU *cpu, int n)
25
case 8: /* unlinked VMID match (reserved if no EL2) */
26
case 10: /* unlinked context ID and VMID match (reserved if no EL2) */
27
qemu_log_mask(LOG_UNIMP,
28
- "arm: unlinked context breakpoint types not implemented");
29
+ "arm: unlinked context breakpoint types not implemented\n");
30
return;
31
case 9: /* linked VMID match (reserved if no EL2) */
32
case 11: /* linked context ID and VMID match (reserved if no EL2) */
33
--
37
--
34
2.17.1
38
2.34.1
35
39
36
40
diff view generated by jsdifflib
1
From: Cédric Le Goater <clg@kaod.org>
1
From: Claudio Fontana <cfontana@suse.de>
2
2
3
The maximum frame size includes the CRC and depends if a VLAN tag is
3
for "all" builds (tcg + kvm), we want to avoid doing
4
inserted or not. Adjust the frame size limit in the transmit handler
4
the psci check if tcg is built-in, but not enabled.
5
using on the FTGMAC100State buffer size and in the receive handler use
6
the packet protocol.
7
5
8
Signed-off-by: Cédric Le Goater <clg@kaod.org>
6
Signed-off-by: Claudio Fontana <cfontana@suse.de>
9
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20180530061711.23673-2-clg@kaod.org
8
Signed-off-by: Fabiano Rosas <farosas@suse.de>
9
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
11
---
13
include/hw/net/ftgmac100.h | 7 ++++++-
12
target/arm/helper.c | 3 ++-
14
hw/net/ftgmac100.c | 23 ++++++++++++-----------
13
1 file changed, 2 insertions(+), 1 deletion(-)
15
2 files changed, 18 insertions(+), 12 deletions(-)
16
14
17
diff --git a/include/hw/net/ftgmac100.h b/include/hw/net/ftgmac100.h
15
diff --git a/target/arm/helper.c b/target/arm/helper.c
18
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/net/ftgmac100.h
17
--- a/target/arm/helper.c
20
+++ b/include/hw/net/ftgmac100.h
18
+++ b/target/arm/helper.c
21
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@
22
#include "hw/sysbus.h"
20
#include "hw/irq.h"
23
#include "net/net.h"
21
#include "sysemu/cpu-timers.h"
24
22
#include "sysemu/kvm.h"
25
+/*
23
+#include "sysemu/tcg.h"
26
+ * Max frame size for the receiving buffer
24
#include "qapi/qapi-commands-machine-target.h"
27
+ */
25
#include "qapi/error.h"
28
+#define FTGMAC100_MAX_FRAME_SIZE 9220
26
#include "qemu/guest-random.h"
29
+
27
@@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cs)
30
typedef struct FTGMAC100State {
28
env->exception.syndrome);
31
/*< private >*/
32
SysBusDevice parent_obj;
33
@@ -XXX,XX +XXX,XX @@ typedef struct FTGMAC100State {
34
qemu_irq irq;
35
MemoryRegion iomem;
36
37
- uint8_t *frame;
38
+ uint8_t frame[FTGMAC100_MAX_FRAME_SIZE];
39
40
uint32_t irq_state;
41
uint32_t isr;
42
diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c
43
index XXXXXXX..XXXXXXX 100644
44
--- a/hw/net/ftgmac100.c
45
+++ b/hw/net/ftgmac100.c
46
@@ -XXX,XX +XXX,XX @@ typedef struct {
47
/*
48
* Max frame size for the receiving buffer
49
*/
50
-#define FTGMAC100_MAX_FRAME_SIZE 10240
51
+#define FTGMAC100_MAX_FRAME_SIZE 9220
52
53
/* Limits depending on the type of the frame
54
*
55
* 9216 for Jumbo frames (+ 4 for VLAN)
56
* 1518 for other frames (+ 4 for VLAN)
57
*/
58
-static int ftgmac100_max_frame_size(FTGMAC100State *s)
59
+static int ftgmac100_max_frame_size(FTGMAC100State *s, uint16_t proto)
60
{
61
- return (s->maccr & FTGMAC100_MACCR_JUMBO_LF ? 9216 : 1518) + 4;
62
+ int max = (s->maccr & FTGMAC100_MACCR_JUMBO_LF ? 9216 : 1518);
63
+
64
+ return max + (proto == ETH_P_VLAN ? 4 : 0);
65
}
66
67
static void ftgmac100_update_irq(FTGMAC100State *s)
68
@@ -XXX,XX +XXX,XX @@ static void ftgmac100_do_tx(FTGMAC100State *s, uint32_t tx_ring,
69
uint8_t *ptr = s->frame;
70
uint32_t addr = tx_descriptor;
71
uint32_t flags = 0;
72
- int max_frame_size = ftgmac100_max_frame_size(s);
73
74
while (1) {
75
FTGMAC100Desc bd;
76
@@ -XXX,XX +XXX,XX @@ static void ftgmac100_do_tx(FTGMAC100State *s, uint32_t tx_ring,
77
flags = bd.des1;
78
}
79
80
- len = bd.des0 & 0x3FFF;
81
- if (frame_size + len > max_frame_size) {
82
+ len = FTGMAC100_TXDES0_TXBUF_SIZE(bd.des0);
83
+ if (frame_size + len > sizeof(s->frame)) {
84
qemu_log_mask(LOG_GUEST_ERROR, "%s: frame too big : %d bytes\n",
85
__func__, len);
86
- len = max_frame_size - frame_size;
87
+ s->isr |= FTGMAC100_INT_XPKT_LOST;
88
+ len = sizeof(s->frame) - frame_size;
89
}
90
91
if (dma_memory_read(&address_space_memory, bd.des3, ptr, len)) {
92
@@ -XXX,XX +XXX,XX @@ static ssize_t ftgmac100_receive(NetClientState *nc, const uint8_t *buf,
93
uint32_t buf_len;
94
size_t size = len;
95
uint32_t first = FTGMAC100_RXDES0_FRS;
96
- int max_frame_size = ftgmac100_max_frame_size(s);
97
+ uint16_t proto = be16_to_cpu(PKT_GET_ETH_HDR(buf)->h_proto);
98
+ int max_frame_size = ftgmac100_max_frame_size(s, proto);
99
100
if ((s->maccr & (FTGMAC100_MACCR_RXDMA_EN | FTGMAC100_MACCR_RXMAC_EN))
101
!= (FTGMAC100_MACCR_RXDMA_EN | FTGMAC100_MACCR_RXMAC_EN)) {
102
@@ -XXX,XX +XXX,XX @@ static ssize_t ftgmac100_receive(NetClientState *nc, const uint8_t *buf,
103
104
/* Huge frames are truncated. */
105
if (size > max_frame_size) {
106
- size = max_frame_size;
107
qemu_log_mask(LOG_GUEST_ERROR, "%s: frame too big : %zd bytes\n",
108
__func__, size);
109
+ size = max_frame_size;
110
flags |= FTGMAC100_RXDES0_FTL;
111
}
29
}
112
30
113
@@ -XXX,XX +XXX,XX @@ static void ftgmac100_realize(DeviceState *dev, Error **errp)
31
- if (arm_is_psci_call(cpu, cs->exception_index)) {
114
object_get_typename(OBJECT(dev)), DEVICE(dev)->id,
32
+ if (tcg_enabled() && arm_is_psci_call(cpu, cs->exception_index)) {
115
s);
33
arm_handle_psci_call(cpu);
116
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
34
qemu_log_mask(CPU_LOG_INT, "...handled as PSCI call\n");
117
-
35
return;
118
- s->frame = g_malloc(FTGMAC100_MAX_FRAME_SIZE);
119
}
120
121
static const VMStateDescription vmstate_ftgmac100 = {
122
--
36
--
123
2.17.1
37
2.34.1
124
38
125
39
diff view generated by jsdifflib
1
From: Cédric Le Goater <clg@kaod.org>
1
From: Claudio Fontana <cfontana@suse.de>
2
2
3
The ftgmac100 NIC supports VLAN tag insertion and the MAC engine also
3
Signed-off-by: Claudio Fontana <cfontana@suse.de>
4
has a control to remove VLAN tags from received packets.
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
5
Signed-off-by: Fabiano Rosas <farosas@suse.de>
6
The VLAN control bits and VLAN tag information are contained in the
6
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
second word of the transmit and receive descriptors. The Insert VLAN
8
bit and the VLAN Tag available bit are only valid in the first segment
9
of the packet.
10
11
Signed-off-by: Cédric Le Goater <clg@kaod.org>
12
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
Message-id: 20180530061711.23673-3-clg@kaod.org
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
8
---
16
hw/net/ftgmac100.c | 31 ++++++++++++++++++++++++++++++-
9
target/arm/helper.c | 12 +++++++-----
17
1 file changed, 30 insertions(+), 1 deletion(-)
10
1 file changed, 7 insertions(+), 5 deletions(-)
18
11
19
diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c
12
diff --git a/target/arm/helper.c b/target/arm/helper.c
20
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/net/ftgmac100.c
14
--- a/target/arm/helper.c
22
+++ b/hw/net/ftgmac100.c
15
+++ b/target/arm/helper.c
23
@@ -XXX,XX +XXX,XX @@ static void ftgmac100_do_tx(FTGMAC100State *s, uint32_t tx_ring,
16
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs)
24
break;
17
unsigned int cur_el = arm_current_el(env);
25
}
18
int rt;
26
19
27
+ /* Check for VLAN */
20
- /*
28
+ if (bd.des0 & FTGMAC100_TXDES0_FTS &&
21
- * Note that new_el can never be 0. If cur_el is 0, then
29
+ bd.des1 & FTGMAC100_TXDES1_INS_VLANTAG &&
22
- * el0_a64 is is_a64(), else el0_a64 is ignored.
30
+ be16_to_cpu(PKT_GET_ETH_HDR(ptr)->h_proto) != ETH_P_VLAN) {
23
- */
31
+ if (frame_size + len + 4 > sizeof(s->frame)) {
24
- aarch64_sve_change_el(env, cur_el, new_el, is_a64(env));
32
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: frame too big : %d bytes\n",
25
+ if (tcg_enabled()) {
33
+ __func__, len);
26
+ /*
34
+ s->isr |= FTGMAC100_INT_XPKT_LOST;
27
+ * Note that new_el can never be 0. If cur_el is 0, then
35
+ len = sizeof(s->frame) - frame_size - 4;
28
+ * el0_a64 is is_a64(), else el0_a64 is ignored.
36
+ }
29
+ */
37
+ memmove(ptr + 16, ptr + 12, len - 12);
30
+ aarch64_sve_change_el(env, cur_el, new_el, is_a64(env));
38
+ stw_be_p(ptr + 12, ETH_P_VLAN);
31
+ }
39
+ stw_be_p(ptr + 14, bd.des1);
32
40
+ len += 4;
33
if (cur_el < new_el) {
41
+ }
34
/*
42
+
43
ptr += len;
44
frame_size += len;
45
if (bd.des0 & FTGMAC100_TXDES0_LTS) {
46
@@ -XXX,XX +XXX,XX @@ static ssize_t ftgmac100_receive(NetClientState *nc, const uint8_t *buf,
47
buf_len += size - 4;
48
}
49
buf_addr = bd.des3;
50
- dma_memory_write(&address_space_memory, buf_addr, buf, buf_len);
51
+ if (first && proto == ETH_P_VLAN && buf_len >= 18) {
52
+ bd.des1 = lduw_be_p(buf + 14) | FTGMAC100_RXDES1_VLANTAG_AVAIL;
53
+
54
+ if (s->maccr & FTGMAC100_MACCR_RM_VLAN) {
55
+ dma_memory_write(&address_space_memory, buf_addr, buf, 12);
56
+ dma_memory_write(&address_space_memory, buf_addr + 12, buf + 16,
57
+ buf_len - 16);
58
+ } else {
59
+ dma_memory_write(&address_space_memory, buf_addr, buf, buf_len);
60
+ }
61
+ } else {
62
+ bd.des1 = 0;
63
+ dma_memory_write(&address_space_memory, buf_addr, buf, buf_len);
64
+ }
65
buf += buf_len;
66
if (size < 4) {
67
dma_memory_write(&address_space_memory, buf_addr + buf_len,
68
--
35
--
69
2.17.1
36
2.34.1
70
37
71
38
diff view generated by jsdifflib
1
From: Cédric Le Goater <clg@kaod.org>
1
From: Fabiano Rosas <farosas@suse.de>
2
2
3
This is a ethernet wire limitation not needed in emulation. It breaks
3
Move this earlier to make the next patch diff cleaner. While here
4
U-Boot n/w stack also.
4
update the comment slightly to not give the impression that the
5
misalignment affects only TCG.
5
6
6
Signed-off-by: Cédric Le Goater <clg@kaod.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20180530061711.23673-5-clg@kaod.org
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Fabiano Rosas <farosas@suse.de>
10
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
12
---
11
hw/net/ftgmac100.c | 6 ------
13
target/arm/machine.c | 18 +++++++++---------
12
1 file changed, 6 deletions(-)
14
1 file changed, 9 insertions(+), 9 deletions(-)
13
15
14
diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c
16
diff --git a/target/arm/machine.c b/target/arm/machine.c
15
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/net/ftgmac100.c
18
--- a/target/arm/machine.c
17
+++ b/hw/net/ftgmac100.c
19
+++ b/target/arm/machine.c
18
@@ -XXX,XX +XXX,XX @@ static ssize_t ftgmac100_receive(NetClientState *nc, const uint8_t *buf,
20
@@ -XXX,XX +XXX,XX @@ static int cpu_post_load(void *opaque, int version_id)
19
return size;
21
}
20
}
22
}
21
23
22
- if (size < 64 && !(s->maccr & FTGMAC100_MACCR_RX_RUNT)) {
24
+ /*
23
- qemu_log_mask(LOG_GUEST_ERROR, "%s: dropped runt frame of %zd bytes\n",
25
+ * Misaligned thumb pc is architecturally impossible. Fail the
24
- __func__, size);
26
+ * incoming migration. For TCG it would trigger the assert in
25
- return size;
27
+ * thumb_tr_translate_insn().
28
+ */
29
+ if (!is_a64(env) && env->thumb && (env->regs[15] & 1)) {
30
+ return -1;
31
+ }
32
+
33
hw_breakpoint_update_all(cpu);
34
hw_watchpoint_update_all(cpu);
35
36
@@ -XXX,XX +XXX,XX @@ static int cpu_post_load(void *opaque, int version_id)
37
}
38
}
39
40
- /*
41
- * Misaligned thumb pc is architecturally impossible.
42
- * We have an assert in thumb_tr_translate_insn to verify this.
43
- * Fail an incoming migrate to avoid this assert.
44
- */
45
- if (!is_a64(env) && env->thumb && (env->regs[15] & 1)) {
46
- return -1;
26
- }
47
- }
27
-
48
-
28
if (!ftgmac100_filter(s, buf, size)) {
49
if (!kvm_enabled()) {
29
return size;
50
pmu_op_finish(&cpu->env);
30
}
51
}
31
--
52
--
32
2.17.1
53
2.34.1
33
54
34
55
diff view generated by jsdifflib
1
From: Cédric Le Goater <clg@kaod.org>
1
From: Fabiano Rosas <farosas@suse.de>
2
2
3
The AST2500 EVB does not have an RTC but we can pretend that one is
3
Since commit cf7c6d1004 ("target/arm: Split out cpregs.h") we now have
4
plugged on the I2C bus header.
4
a cpregs.h header which is more suitable for this code.
5
5
6
The romulus and witherspoon boards expects an Epson RX8900 I2C RTC but
6
Code moved verbatim.
7
a ds1338 is good enough for the basic features we need.
7
8
8
Signed-off-by: Fabiano Rosas <farosas@suse.de>
9
Signed-off-by: Cédric Le Goater <clg@kaod.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
11
Message-id: 20180530064049.27976-4-clg@kaod.org
11
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
13
---
14
hw/arm/aspeed.c | 19 +++++++++++++++++++
14
target/arm/cpregs.h | 98 +++++++++++++++++++++++++++++++++++++++++++++
15
1 file changed, 19 insertions(+)
15
target/arm/cpu.h | 91 -----------------------------------------
16
16
2 files changed, 98 insertions(+), 91 deletions(-)
17
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
17
18
diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
18
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/arm/aspeed.c
20
--- a/target/arm/cpregs.h
20
+++ b/hw/arm/aspeed.c
21
+++ b/target/arm/cpregs.h
21
@@ -XXX,XX +XXX,XX @@ enum {
22
@@ -XXX,XX +XXX,XX @@ enum {
22
23
ARM_CP_SME = 1 << 19,
23
static void palmetto_bmc_i2c_init(AspeedBoardState *bmc);
24
static void ast2500_evb_i2c_init(AspeedBoardState *bmc);
25
+static void romulus_bmc_i2c_init(AspeedBoardState *bmc);
26
static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc);
27
28
static const AspeedBoardConfig aspeed_boards[] = {
29
@@ -XXX,XX +XXX,XX @@ static const AspeedBoardConfig aspeed_boards[] = {
30
.fmc_model = "n25q256a",
31
.spi_model = "mx66l1g45g",
32
.num_cs = 2,
33
+ .i2c_init = romulus_bmc_i2c_init,
34
},
35
[WITHERSPOON_BMC] = {
36
.soc_name = "ast2500-a1",
37
@@ -XXX,XX +XXX,XX @@ static void ast2500_evb_i2c_init(AspeedBoardState *bmc)
38
39
/* The AST2500 EVB expects a LM75 but a TMP105 is compatible */
40
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0x4d);
41
+
42
+ /* The AST2500 EVB does not have an RTC. Let's pretend that one is
43
+ * plugged on the I2C bus header */
44
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32);
45
}
46
47
static void ast2500_evb_init(MachineState *machine)
48
@@ -XXX,XX +XXX,XX @@ static const TypeInfo ast2500_evb_type = {
49
.class_init = ast2500_evb_class_init,
50
};
24
};
51
25
52
+static void romulus_bmc_i2c_init(AspeedBoardState *bmc)
26
+/*
27
+ * Interface for defining coprocessor registers.
28
+ * Registers are defined in tables of arm_cp_reginfo structs
29
+ * which are passed to define_arm_cp_regs().
30
+ */
31
+
32
+/*
33
+ * When looking up a coprocessor register we look for it
34
+ * via an integer which encodes all of:
35
+ * coprocessor number
36
+ * Crn, Crm, opc1, opc2 fields
37
+ * 32 or 64 bit register (ie is it accessed via MRC/MCR
38
+ * or via MRRC/MCRR?)
39
+ * non-secure/secure bank (AArch32 only)
40
+ * We allow 4 bits for opc1 because MRRC/MCRR have a 4 bit field.
41
+ * (In this case crn and opc2 should be zero.)
42
+ * For AArch64, there is no 32/64 bit size distinction;
43
+ * instead all registers have a 2 bit op0, 3 bit op1 and op2,
44
+ * and 4 bit CRn and CRm. The encoding patterns are chosen
45
+ * to be easy to convert to and from the KVM encodings, and also
46
+ * so that the hashtable can contain both AArch32 and AArch64
47
+ * registers (to allow for interprocessing where we might run
48
+ * 32 bit code on a 64 bit core).
49
+ */
50
+/*
51
+ * This bit is private to our hashtable cpreg; in KVM register
52
+ * IDs the AArch64/32 distinction is the KVM_REG_ARM/ARM64
53
+ * in the upper bits of the 64 bit ID.
54
+ */
55
+#define CP_REG_AA64_SHIFT 28
56
+#define CP_REG_AA64_MASK (1 << CP_REG_AA64_SHIFT)
57
+
58
+/*
59
+ * To enable banking of coprocessor registers depending on ns-bit we
60
+ * add a bit to distinguish between secure and non-secure cpregs in the
61
+ * hashtable.
62
+ */
63
+#define CP_REG_NS_SHIFT 29
64
+#define CP_REG_NS_MASK (1 << CP_REG_NS_SHIFT)
65
+
66
+#define ENCODE_CP_REG(cp, is64, ns, crn, crm, opc1, opc2) \
67
+ ((ns) << CP_REG_NS_SHIFT | ((cp) << 16) | ((is64) << 15) | \
68
+ ((crn) << 11) | ((crm) << 7) | ((opc1) << 3) | (opc2))
69
+
70
+#define ENCODE_AA64_CP_REG(cp, crn, crm, op0, op1, op2) \
71
+ (CP_REG_AA64_MASK | \
72
+ ((cp) << CP_REG_ARM_COPROC_SHIFT) | \
73
+ ((op0) << CP_REG_ARM64_SYSREG_OP0_SHIFT) | \
74
+ ((op1) << CP_REG_ARM64_SYSREG_OP1_SHIFT) | \
75
+ ((crn) << CP_REG_ARM64_SYSREG_CRN_SHIFT) | \
76
+ ((crm) << CP_REG_ARM64_SYSREG_CRM_SHIFT) | \
77
+ ((op2) << CP_REG_ARM64_SYSREG_OP2_SHIFT))
78
+
79
+/*
80
+ * Convert a full 64 bit KVM register ID to the truncated 32 bit
81
+ * version used as a key for the coprocessor register hashtable
82
+ */
83
+static inline uint32_t kvm_to_cpreg_id(uint64_t kvmid)
53
+{
84
+{
54
+ AspeedSoCState *soc = &bmc->soc;
85
+ uint32_t cpregid = kvmid;
55
+
86
+ if ((kvmid & CP_REG_ARCH_MASK) == CP_REG_ARM64) {
56
+ /* The romulus board expects Epson RX8900 I2C RTC but a ds1338 is
87
+ cpregid |= CP_REG_AA64_MASK;
57
+ * good enough */
88
+ } else {
58
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32);
89
+ if ((kvmid & CP_REG_SIZE_MASK) == CP_REG_SIZE_U64) {
90
+ cpregid |= (1 << 15);
91
+ }
92
+
93
+ /*
94
+ * KVM is always non-secure so add the NS flag on AArch32 register
95
+ * entries.
96
+ */
97
+ cpregid |= 1 << CP_REG_NS_SHIFT;
98
+ }
99
+ return cpregid;
59
+}
100
+}
60
+
101
+
61
static void romulus_bmc_init(MachineState *machine)
102
+/*
103
+ * Convert a truncated 32 bit hashtable key into the full
104
+ * 64 bit KVM register ID.
105
+ */
106
+static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid)
107
+{
108
+ uint64_t kvmid;
109
+
110
+ if (cpregid & CP_REG_AA64_MASK) {
111
+ kvmid = cpregid & ~CP_REG_AA64_MASK;
112
+ kvmid |= CP_REG_SIZE_U64 | CP_REG_ARM64;
113
+ } else {
114
+ kvmid = cpregid & ~(1 << 15);
115
+ if (cpregid & (1 << 15)) {
116
+ kvmid |= CP_REG_SIZE_U64 | CP_REG_ARM;
117
+ } else {
118
+ kvmid |= CP_REG_SIZE_U32 | CP_REG_ARM;
119
+ }
120
+ }
121
+ return kvmid;
122
+}
123
+
124
/*
125
* Valid values for ARMCPRegInfo state field, indicating which of
126
* the AArch32 and AArch64 execution states this register is visible in.
127
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
128
index XXXXXXX..XXXXXXX 100644
129
--- a/target/arm/cpu.h
130
+++ b/target/arm/cpu.h
131
@@ -XXX,XX +XXX,XX @@ void arm_cpu_list(void);
132
uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx,
133
uint32_t cur_el, bool secure);
134
135
-/* Interface for defining coprocessor registers.
136
- * Registers are defined in tables of arm_cp_reginfo structs
137
- * which are passed to define_arm_cp_regs().
138
- */
139
-
140
-/* When looking up a coprocessor register we look for it
141
- * via an integer which encodes all of:
142
- * coprocessor number
143
- * Crn, Crm, opc1, opc2 fields
144
- * 32 or 64 bit register (ie is it accessed via MRC/MCR
145
- * or via MRRC/MCRR?)
146
- * non-secure/secure bank (AArch32 only)
147
- * We allow 4 bits for opc1 because MRRC/MCRR have a 4 bit field.
148
- * (In this case crn and opc2 should be zero.)
149
- * For AArch64, there is no 32/64 bit size distinction;
150
- * instead all registers have a 2 bit op0, 3 bit op1 and op2,
151
- * and 4 bit CRn and CRm. The encoding patterns are chosen
152
- * to be easy to convert to and from the KVM encodings, and also
153
- * so that the hashtable can contain both AArch32 and AArch64
154
- * registers (to allow for interprocessing where we might run
155
- * 32 bit code on a 64 bit core).
156
- */
157
-/* This bit is private to our hashtable cpreg; in KVM register
158
- * IDs the AArch64/32 distinction is the KVM_REG_ARM/ARM64
159
- * in the upper bits of the 64 bit ID.
160
- */
161
-#define CP_REG_AA64_SHIFT 28
162
-#define CP_REG_AA64_MASK (1 << CP_REG_AA64_SHIFT)
163
-
164
-/* To enable banking of coprocessor registers depending on ns-bit we
165
- * add a bit to distinguish between secure and non-secure cpregs in the
166
- * hashtable.
167
- */
168
-#define CP_REG_NS_SHIFT 29
169
-#define CP_REG_NS_MASK (1 << CP_REG_NS_SHIFT)
170
-
171
-#define ENCODE_CP_REG(cp, is64, ns, crn, crm, opc1, opc2) \
172
- ((ns) << CP_REG_NS_SHIFT | ((cp) << 16) | ((is64) << 15) | \
173
- ((crn) << 11) | ((crm) << 7) | ((opc1) << 3) | (opc2))
174
-
175
-#define ENCODE_AA64_CP_REG(cp, crn, crm, op0, op1, op2) \
176
- (CP_REG_AA64_MASK | \
177
- ((cp) << CP_REG_ARM_COPROC_SHIFT) | \
178
- ((op0) << CP_REG_ARM64_SYSREG_OP0_SHIFT) | \
179
- ((op1) << CP_REG_ARM64_SYSREG_OP1_SHIFT) | \
180
- ((crn) << CP_REG_ARM64_SYSREG_CRN_SHIFT) | \
181
- ((crm) << CP_REG_ARM64_SYSREG_CRM_SHIFT) | \
182
- ((op2) << CP_REG_ARM64_SYSREG_OP2_SHIFT))
183
-
184
-/* Convert a full 64 bit KVM register ID to the truncated 32 bit
185
- * version used as a key for the coprocessor register hashtable
186
- */
187
-static inline uint32_t kvm_to_cpreg_id(uint64_t kvmid)
188
-{
189
- uint32_t cpregid = kvmid;
190
- if ((kvmid & CP_REG_ARCH_MASK) == CP_REG_ARM64) {
191
- cpregid |= CP_REG_AA64_MASK;
192
- } else {
193
- if ((kvmid & CP_REG_SIZE_MASK) == CP_REG_SIZE_U64) {
194
- cpregid |= (1 << 15);
195
- }
196
-
197
- /* KVM is always non-secure so add the NS flag on AArch32 register
198
- * entries.
199
- */
200
- cpregid |= 1 << CP_REG_NS_SHIFT;
201
- }
202
- return cpregid;
203
-}
204
-
205
-/* Convert a truncated 32 bit hashtable key into the full
206
- * 64 bit KVM register ID.
207
- */
208
-static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid)
209
-{
210
- uint64_t kvmid;
211
-
212
- if (cpregid & CP_REG_AA64_MASK) {
213
- kvmid = cpregid & ~CP_REG_AA64_MASK;
214
- kvmid |= CP_REG_SIZE_U64 | CP_REG_ARM64;
215
- } else {
216
- kvmid = cpregid & ~(1 << 15);
217
- if (cpregid & (1 << 15)) {
218
- kvmid |= CP_REG_SIZE_U64 | CP_REG_ARM;
219
- } else {
220
- kvmid |= CP_REG_SIZE_U32 | CP_REG_ARM;
221
- }
222
- }
223
- return kvmid;
224
-}
225
-
226
/* Return the highest implemented Exception Level */
227
static inline int arm_highest_el(CPUARMState *env)
62
{
228
{
63
aspeed_board_init(machine, &aspeed_boards[ROMULUS_BMC]);
64
@@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
65
66
/* The Witherspoon expects a TMP275 but a TMP105 is compatible */
67
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp105", 0x4a);
68
+
69
+ /* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is
70
+ * good enough */
71
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32);
72
}
73
74
static void witherspoon_bmc_init(MachineState *machine)
75
--
229
--
76
2.17.1
230
2.34.1
77
231
78
232
diff view generated by jsdifflib
Deleted patch
1
From: Cédric Le Goater <clg@kaod.org>
2
1
3
This is an helper routine to add a single EEPROM on an I2C bus. It can
4
be directly used by smbus_eeprom_init() which adds a certain number of
5
EEPROMs on mips and x86 machines.
6
7
Signed-off-by: Cédric Le Goater <clg@kaod.org>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-id: 20180530064049.27976-5-clg@kaod.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
include/hw/i2c/smbus.h | 1 +
13
hw/i2c/smbus_eeprom.c | 16 +++++++++++-----
14
2 files changed, 12 insertions(+), 5 deletions(-)
15
16
diff --git a/include/hw/i2c/smbus.h b/include/hw/i2c/smbus.h
17
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/i2c/smbus.h
19
+++ b/include/hw/i2c/smbus.h
20
@@ -XXX,XX +XXX,XX @@ int smbus_read_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data);
21
int smbus_write_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data,
22
int len);
23
24
+void smbus_eeprom_init_one(I2CBus *smbus, uint8_t address, uint8_t *eeprom_buf);
25
void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom,
26
const uint8_t *eeprom_spd, int size);
27
28
diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/hw/i2c/smbus_eeprom.c
31
+++ b/hw/i2c/smbus_eeprom.c
32
@@ -XXX,XX +XXX,XX @@ static void smbus_eeprom_register_types(void)
33
34
type_init(smbus_eeprom_register_types)
35
36
+void smbus_eeprom_init_one(I2CBus *smbus, uint8_t address, uint8_t *eeprom_buf)
37
+{
38
+ DeviceState *dev;
39
+
40
+ dev = qdev_create((BusState *) smbus, "smbus-eeprom");
41
+ qdev_prop_set_uint8(dev, "address", address);
42
+ qdev_prop_set_ptr(dev, "data", eeprom_buf);
43
+ qdev_init_nofail(dev);
44
+}
45
+
46
void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom,
47
const uint8_t *eeprom_spd, int eeprom_spd_size)
48
{
49
@@ -XXX,XX +XXX,XX @@ void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom,
50
}
51
52
for (i = 0; i < nb_eeprom; i++) {
53
- DeviceState *eeprom;
54
- eeprom = qdev_create((BusState *)smbus, "smbus-eeprom");
55
- qdev_prop_set_uint8(eeprom, "address", 0x50 + i);
56
- qdev_prop_set_ptr(eeprom, "data", eeprom_buf + (i * 256));
57
- qdev_init_nofail(eeprom);
58
+ smbus_eeprom_init_one(smbus, 0x50 + i, eeprom_buf + (i * 256));
59
}
60
}
61
--
62
2.17.1
63
64
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Fabiano Rosas <farosas@suse.de>
2
2
3
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
3
If a test was tagged with the "accel" tag and the specified
4
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
4
accelerator it not present in the qemu binary, cancel the test.
5
Message-id: 20180606152128.449-6-f4bug@amsat.org
5
6
We can now write tests without explicit calls to require_accelerator,
7
just the tag is enough.
8
9
Signed-off-by: Fabiano Rosas <farosas@suse.de>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Tested-by: Philippe Mathieu-Daudé <philmd@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
hw/core/register.c | 2 +-
14
tests/avocado/avocado_qemu/__init__.py | 4 ++++
9
1 file changed, 1 insertion(+), 1 deletion(-)
15
1 file changed, 4 insertions(+)
10
16
11
diff --git a/hw/core/register.c b/hw/core/register.c
17
diff --git a/tests/avocado/avocado_qemu/__init__.py b/tests/avocado/avocado_qemu/__init__.py
12
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/core/register.c
19
--- a/tests/avocado/avocado_qemu/__init__.py
14
+++ b/hw/core/register.c
20
+++ b/tests/avocado/avocado_qemu/__init__.py
15
@@ -XXX,XX +XXX,XX @@ void register_write(RegisterInfo *reg, uint64_t val, uint64_t we,
21
@@ -XXX,XX +XXX,XX @@ def setUp(self):
16
if (test) {
22
17
qemu_log_mask(LOG_UNIMP,
23
super().setUp('qemu-system-')
18
"%s:%s writing %#" PRIx64 " to unimplemented bits:" \
24
19
- " %#" PRIx64 "",
25
+ accel_required = self._get_unique_tag_val('accel')
20
+ " %#" PRIx64 "\n",
26
+ if accel_required:
21
prefix, reg->access->name, val, ac->unimp);
27
+ self.require_accelerator(accel_required)
22
}
28
+
29
self.machine = self.params.get('machine',
30
default=self._get_unique_tag_val('machine'))
23
31
24
--
32
--
25
2.17.1
33
2.34.1
26
34
27
35
diff view generated by jsdifflib
1
From: Cédric Le Goater <clg@kaod.org>
1
From: Fabiano Rosas <farosas@suse.de>
2
2
3
The Aspeed boards have at least one EEPROM to hold the Vital Product
3
This allows the test to be skipped when TCG is not present in the QEMU
4
Data (VPD).
4
binary.
5
5
6
Signed-off-by: Cédric Le Goater <clg@kaod.org>
6
Signed-off-by: Fabiano Rosas <farosas@suse.de>
7
Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20180530064049.27976-6-clg@kaod.org
8
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
10
---
11
hw/arm/aspeed.c | 13 +++++++++++++
11
tests/avocado/boot_linux_console.py | 1 +
12
1 file changed, 13 insertions(+)
12
tests/avocado/reverse_debugging.py | 8 ++++++++
13
2 files changed, 9 insertions(+)
13
14
14
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
15
diff --git a/tests/avocado/boot_linux_console.py b/tests/avocado/boot_linux_console.py
15
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/arm/aspeed.c
17
--- a/tests/avocado/boot_linux_console.py
17
+++ b/hw/arm/aspeed.c
18
+++ b/tests/avocado/boot_linux_console.py
18
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_uboot_netbsd9(self):
19
#include "hw/arm/arm.h"
20
20
#include "hw/arm/aspeed_soc.h"
21
def test_aarch64_raspi3_atf(self):
21
#include "hw/boards.h"
22
"""
22
+#include "hw/i2c/smbus.h"
23
+ :avocado: tags=accel:tcg
23
#include "qemu/log.h"
24
:avocado: tags=arch:aarch64
24
#include "sysemu/block-backend.h"
25
:avocado: tags=machine:raspi3b
25
#include "hw/loader.h"
26
:avocado: tags=cpu:cortex-a53
26
@@ -XXX,XX +XXX,XX @@ static void palmetto_bmc_i2c_init(AspeedBoardState *bmc)
27
diff --git a/tests/avocado/reverse_debugging.py b/tests/avocado/reverse_debugging.py
27
{
28
index XXXXXXX..XXXXXXX 100644
28
AspeedSoCState *soc = &bmc->soc;
29
--- a/tests/avocado/reverse_debugging.py
29
DeviceState *dev;
30
+++ b/tests/avocado/reverse_debugging.py
30
+ uint8_t *eeprom_buf = g_malloc0(32 * 1024);
31
@@ -XXX,XX +XXX,XX @@ def reverse_debugging(self, shift=7, args=None):
31
32
vm.shutdown()
32
/* The palmetto platform expects a ds3231 RTC but a ds1338 is
33
33
* enough to provide basic RTC features. Alarms will be missing */
34
class ReverseDebugging_X86_64(ReverseDebugging):
34
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), "ds1338", 0x68);
35
+ """
35
36
+ :avocado: tags=accel:tcg
36
+ smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 0), 0x50,
37
+ """
37
+ eeprom_buf);
38
+
38
+
39
/* add a TMP423 temperature sensor */
39
REG_PC = 0x10
40
dev = i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 2),
40
REG_CS = 0x12
41
"tmp423", 0x4c);
41
def get_pc(self, g):
42
@@ -XXX,XX +XXX,XX @@ static const TypeInfo palmetto_bmc_type = {
42
@@ -XXX,XX +XXX,XX @@ def test_x86_64_pc(self):
43
static void ast2500_evb_i2c_init(AspeedBoardState *bmc)
43
self.reverse_debugging()
44
{
44
45
AspeedSoCState *soc = &bmc->soc;
45
class ReverseDebugging_AArch64(ReverseDebugging):
46
+ uint8_t *eeprom_buf = g_malloc0(8 * 1024);
46
+ """
47
+ :avocado: tags=accel:tcg
48
+ """
47
+
49
+
48
+ smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), 0x50,
50
REG_PC = 32
49
+ eeprom_buf);
51
50
52
# unidentified gitlab timeout problem
51
/* The AST2500 EVB expects a LM75 but a TMP105 is compatible */
52
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0x4d);
53
@@ -XXX,XX +XXX,XX @@ static const TypeInfo romulus_bmc_type = {
54
static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
55
{
56
AspeedSoCState *soc = &bmc->soc;
57
+ uint8_t *eeprom_buf = g_malloc0(8 * 1024);
58
59
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c);
60
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c);
61
@@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
62
/* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is
63
* good enough */
64
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32);
65
+
66
+ smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), 0x51,
67
+ eeprom_buf);
68
}
69
70
static void witherspoon_bmc_init(MachineState *machine)
71
--
53
--
72
2.17.1
54
2.34.1
73
55
74
56
diff view generated by jsdifflib
1
From: Cédric Le Goater <clg@kaod.org>
1
From: Fabiano Rosas <farosas@suse.de>
2
2
3
The pca9552 LED blinkers on the Witherspoon machine are used for leds
3
Now that the cortex-a15 is under CONFIG_TCG, use as default CPU for a
4
but also as GPIOs to control fans and GPUs.
4
KVM-only build the 'max' cpu.
5
5
6
Signed-off-by: Cédric Le Goater <clg@kaod.org>
6
Note that we cannot use 'host' here because the qtests can run without
7
Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
7
any other accelerator (than qtest) and 'host' depends on KVM being
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
enabled.
9
Message-id: 20180530064049.27976-8-clg@kaod.org
9
10
Signed-off-by: Fabiano Rosas <farosas@suse.de>
11
Acked-by: Richard Henderson <richard.henderson@linaro.org>
12
Reviewed-by: Thomas Huth <thuth@redhat.com>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
14
---
12
hw/arm/aspeed.c | 4 ++++
15
hw/arm/virt.c | 4 ++++
13
1 file changed, 4 insertions(+)
16
1 file changed, 4 insertions(+)
14
17
15
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
18
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
16
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/aspeed.c
20
--- a/hw/arm/virt.c
18
+++ b/hw/arm/aspeed.c
21
+++ b/hw/arm/virt.c
19
@@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
22
@@ -XXX,XX +XXX,XX @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
20
AspeedSoCState *soc = &bmc->soc;
23
mc->minimum_page_bits = 12;
21
uint8_t *eeprom_buf = g_malloc0(8 * 1024);
24
mc->possible_cpu_arch_ids = virt_possible_cpu_arch_ids;
22
25
mc->cpu_index_to_instance_props = virt_cpu_index_to_props;
23
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), "pca9552", 0x60);
26
+#ifdef CONFIG_TCG
24
+
27
mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15");
25
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c);
28
+#else
26
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c);
29
+ mc->default_cpu_type = ARM_CPU_TYPE_NAME("max");
27
30
+#endif
28
@@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
31
mc->get_default_cpu_node_id = virt_get_default_cpu_node_id;
29
32
mc->kvm_type = virt_kvm_type;
30
smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), 0x51,
33
assert(!mc->get_hotplug_handler);
31
eeprom_buf);
32
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "pca9552",
33
+ 0x60);
34
}
35
36
static void witherspoon_bmc_init(MachineState *machine)
37
--
34
--
38
2.17.1
35
2.34.1
39
40
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Fabiano Rosas <farosas@suse.de>
2
2
3
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
3
Signed-off-by: Fabiano Rosas <farosas@suse.de>
4
Message-id: 20180606152128.449-7-f4bug@amsat.org
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Acked-by: Thomas Huth <thuth@redhat.com>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
7
---
8
hw/mips/boston.c | 8 ++++----
8
tests/qtest/arm-cpu-features.c | 28 ++++++++++++++++++----------
9
1 file changed, 4 insertions(+), 4 deletions(-)
9
1 file changed, 18 insertions(+), 10 deletions(-)
10
10
11
diff --git a/hw/mips/boston.c b/hw/mips/boston.c
11
diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
12
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/mips/boston.c
13
--- a/tests/qtest/arm-cpu-features.c
14
+++ b/hw/mips/boston.c
14
+++ b/tests/qtest/arm-cpu-features.c
15
@@ -XXX,XX +XXX,XX @@ static uint64_t boston_platreg_read(void *opaque, hwaddr addr,
15
@@ -XXX,XX +XXX,XX @@
16
uint32_t gic_freq, val;
16
#define SVE_MAX_VQ 16
17
17
18
if (size != 4) {
18
#define MACHINE "-machine virt,gic-version=max -accel tcg "
19
- qemu_log_mask(LOG_UNIMP, "%uB platform register read", size);
19
-#define MACHINE_KVM "-machine virt,gic-version=max -accel kvm -accel tcg "
20
+ qemu_log_mask(LOG_UNIMP, "%uB platform register read\n", size);
20
+#define MACHINE_KVM "-machine virt,gic-version=max -accel kvm "
21
return 0;
21
#define QUERY_HEAD "{ 'execute': 'query-cpu-model-expansion', " \
22
" 'arguments': { 'type': 'full', "
23
#define QUERY_TAIL "}}"
24
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv)
25
{
26
g_test_init(&argc, &argv, NULL);
27
28
- qtest_add_data_func("/arm/query-cpu-model-expansion",
29
- NULL, test_query_cpu_model_expansion);
30
+ if (qtest_has_accel("tcg")) {
31
+ qtest_add_data_func("/arm/query-cpu-model-expansion",
32
+ NULL, test_query_cpu_model_expansion);
33
+ }
34
+
35
+ if (!g_str_equal(qtest_get_arch(), "aarch64")) {
36
+ goto out;
37
+ }
38
39
/*
40
* For now we only run KVM specific tests with AArch64 QEMU in
41
* order avoid attempting to run an AArch32 QEMU with KVM on
42
* AArch64 hosts. That won't work and isn't easy to detect.
43
*/
44
- if (g_str_equal(qtest_get_arch(), "aarch64") && qtest_has_accel("kvm")) {
45
+ if (qtest_has_accel("kvm")) {
46
/*
47
* This tests target the 'host' CPU type, so register it only if
48
* KVM is available.
49
*/
50
qtest_add_data_func("/arm/kvm/query-cpu-model-expansion",
51
NULL, test_query_cpu_model_expansion_kvm);
52
- }
53
54
- if (g_str_equal(qtest_get_arch(), "aarch64")) {
55
- qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-max-vq-8",
56
- NULL, sve_tests_sve_max_vq_8);
57
- qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-off",
58
- NULL, sve_tests_sve_off);
59
qtest_add_data_func("/arm/kvm/query-cpu-model-expansion/sve-off",
60
NULL, sve_tests_sve_off_kvm);
22
}
61
}
23
62
24
@@ -XXX,XX +XXX,XX @@ static uint64_t boston_platreg_read(void *opaque, hwaddr addr,
63
+ if (qtest_has_accel("tcg")) {
25
val |= PLAT_DDR_CFG_MHZ;
64
+ qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-max-vq-8",
26
return val;
65
+ NULL, sve_tests_sve_max_vq_8);
27
default:
66
+ qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-off",
28
- qemu_log_mask(LOG_UNIMP, "Read platform register 0x%" HWADDR_PRIx,
67
+ NULL, sve_tests_sve_off);
29
+ qemu_log_mask(LOG_UNIMP, "Read platform register 0x%" HWADDR_PRIx "\n",
68
+ }
30
addr & 0xffff);
69
+
31
return 0;
70
+out:
32
}
71
return g_test_run();
33
@@ -XXX,XX +XXX,XX @@ static void boston_platreg_write(void *opaque, hwaddr addr,
34
uint64_t val, unsigned size)
35
{
36
if (size != 4) {
37
- qemu_log_mask(LOG_UNIMP, "%uB platform register write", size);
38
+ qemu_log_mask(LOG_UNIMP, "%uB platform register write\n", size);
39
return;
40
}
41
42
@@ -XXX,XX +XXX,XX @@ static void boston_platreg_write(void *opaque, hwaddr addr,
43
break;
44
default:
45
qemu_log_mask(LOG_UNIMP, "Write platform register 0x%" HWADDR_PRIx
46
- " = 0x%" PRIx64, addr & 0xffff, val);
47
+ " = 0x%" PRIx64 "\n", addr & 0xffff, val);
48
break;
49
}
50
}
72
}
51
--
73
--
52
2.17.1
74
2.34.1
53
54
diff view generated by jsdifflib
1
From: Cédric Le Goater <clg@kaod.org>
1
From: Fabiano Rosas <farosas@suse.de>
2
2
3
Based on the multicast hash calculation of the FTGMAC100 Linux driver.
3
These tests set -accel tcg, so restrict them to when TCG is present.
4
4
5
Signed-off-by: Cédric Le Goater <clg@kaod.org>
5
Signed-off-by: Fabiano Rosas <farosas@suse.de>
6
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Acked-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20180530061711.23673-4-clg@kaod.org
7
Reviewed-by: Thomas Huth <thuth@redhat.com>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
9
---
10
hw/net/ftgmac100.c | 4 ++--
10
tests/qtest/meson.build | 4 ++--
11
1 file changed, 2 insertions(+), 2 deletions(-)
11
1 file changed, 2 insertions(+), 2 deletions(-)
12
12
13
diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c
13
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
14
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/net/ftgmac100.c
15
--- a/tests/qtest/meson.build
16
+++ b/hw/net/ftgmac100.c
16
+++ b/tests/qtest/meson.build
17
@@ -XXX,XX +XXX,XX @@ static int ftgmac100_filter(FTGMAC100State *s, const uint8_t *buf, size_t len)
17
@@ -XXX,XX +XXX,XX @@ qtests_arm = \
18
return 0;
18
# TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-test unconditional
19
}
19
qtests_aarch64 = \
20
20
(cpu != 'arm' and unpack_edk2_blobs ? ['bios-tables-test'] : []) + \
21
- /* TODO: this does not seem to work for ftgmac100 */
21
- (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-test'] : []) + \
22
- mcast_idx = net_crc32(buf, ETH_ALEN) >> 26;
22
- (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-swtpm-test'] : []) + \
23
+ mcast_idx = net_crc32_le(buf, ETH_ALEN);
23
+ (config_all.has_key('CONFIG_TCG') and config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? \
24
+ mcast_idx = (~(mcast_idx >> 2)) & 0x3f;
24
+ ['tpm-tis-device-test', 'tpm-tis-device-swtpm-test'] : []) + \
25
if (!(s->math[mcast_idx / 32] & (1 << (mcast_idx % 32)))) {
25
(config_all_devices.has_key('CONFIG_XLNX_ZYNQMP_ARM') ? ['xlnx-can-test', 'fuzz-xlnx-dp-test'] : []) + \
26
return 0;
26
(config_all_devices.has_key('CONFIG_RASPI') ? ['bcm2835-dma-test'] : []) + \
27
}
27
['arm-cpu-features',
28
--
28
--
29
2.17.1
29
2.34.1
30
31
diff view generated by jsdifflib