1 | First arm pullreq of 5.0! | 1 | The following changes since commit 8f6330a807f2642dc2a3cdf33347aa28a4c00a87: |
---|---|---|---|
2 | 2 | ||
3 | The following changes since commit 084a398bf8aa7634738e6c6c0103236ee1b3b72f: | 3 | Merge tag 'pull-maintainer-updates-060324-1' of https://gitlab.com/stsquad/qemu into staging (2024-03-06 16:56:20 +0000) |
4 | |||
5 | Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging (2019-12-13 18:14:07 +0000) | ||
6 | 4 | ||
7 | are available in the Git repository at: | 5 | are available in the Git repository at: |
8 | 6 | ||
9 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20191216-1 | 7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20240308 |
10 | 8 | ||
11 | for you to fetch changes up to f80741d107673f162e3b097fc76a1590036cc9d1: | 9 | for you to fetch changes up to bbf6c6dbead82292a20951eb1204442a6b838de9: |
12 | 10 | ||
13 | target/arm: ensure we use current exception state after SCR update (2019-12-16 10:52:58 +0000) | 11 | target/arm: Move v7m-related code from cpu32.c into a separate file (2024-03-08 14:45:03 +0000) |
14 | 12 | ||
15 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
16 | target-arm queue: | 14 | target-arm queue: |
17 | * Add support for Cortex-M7 CPU | 15 | * Implement FEAT_ECV |
18 | * exynos4210_gic: Suppress gcc9 format-truncation warnings | 16 | * STM32L4x5: Implement GPIO device |
19 | * aspeed: Various minor bug fixes and improvements | 17 | * Fix 32-bit SMOPA |
20 | * aspeed: Add support for the tacoma-bmc board | 18 | * Refactor v7m related code from cpu32.c into its own file |
21 | * Honour HCR_EL32.TID1 and .TID2 trapping requirements | 19 | * hw/rtc/sun4v-rtc: Relicense to GPLv2-or-later |
22 | * Handle trapping to EL2 of AArch32 VMRS instructions | ||
23 | * Handle AArch32 CP15 trapping via HSTR_EL2 | ||
24 | * Add support for missing Jazelle system registers | ||
25 | * arm/arm-powerctl: set NSACR.{CP11, CP10} bits in arm_set_cpu_on | ||
26 | * Add support for DC CVAP & DC CVADP instructions | ||
27 | * Fix assertion when SCR.NS is changed in Secure-SVC &c | ||
28 | * enable SHPC native hot plug in arm ACPI | ||
29 | 20 | ||
30 | ---------------------------------------------------------------- | 21 | ---------------------------------------------------------------- |
31 | Alex Bennée (1): | 22 | Inès Varhol (3): |
32 | target/arm: ensure we use current exception state after SCR update | 23 | hw/gpio: Implement STM32L4x5 GPIO |
24 | hw/arm: Connect STM32L4x5 GPIO to STM32L4x5 SoC | ||
25 | tests/qtest: Add STM32L4x5 GPIO QTest testcase | ||
33 | 26 | ||
34 | Beata Michalska (4): | 27 | Peter Maydell (9): |
35 | tcg: cputlb: Add probe_read | 28 | target/arm: Move some register related defines to internals.h |
36 | Memory: Enable writeback for given memory region | 29 | target/arm: Timer _EL02 registers UNDEF for E2H == 0 |
37 | migration: ram: Switch to ram block writeback | 30 | target/arm: use FIELD macro for CNTHCTL bit definitions |
38 | target/arm: Add support for DC CVAP & DC CVADP ins | 31 | target/arm: Don't allow RES0 CNTHCTL_EL2 bits to be written |
32 | target/arm: Implement new FEAT_ECV trap bits | ||
33 | target/arm: Define CNTPCTSS_EL0 and CNTVCTSS_EL0 | ||
34 | target/arm: Implement FEAT_ECV CNTPOFF_EL2 handling | ||
35 | target/arm: Enable FEAT_ECV for 'max' CPU | ||
36 | hw/rtc/sun4v-rtc: Relicense to GPLv2-or-later | ||
39 | 37 | ||
40 | Christophe Lyon (1): | 38 | Richard Henderson (1): |
41 | target/arm: Add support for cortex-m7 CPU | 39 | target/arm: Fix 32-bit SMOPA |
42 | 40 | ||
43 | Cédric Le Goater (12): | 41 | Thomas Huth (1): |
44 | aspeed/i2c: Add support for pool buffer transfers | 42 | target/arm: Move v7m-related code from cpu32.c into a separate file |
45 | aspeed/i2c: Check SRAM enablement on AST2500 | ||
46 | aspeed: Add a DRAM memory region at the SoC level | ||
47 | aspeed/i2c: Add support for DMA transfers | ||
48 | aspeed/i2c: Add trace events | ||
49 | aspeed/smc: Restore default AHB window mapping at reset | ||
50 | aspeed/smc: Do not map disabled segment on the AST2600 | ||
51 | aspeed/smc: Add AST2600 timings registers | ||
52 | aspeed: Remove AspeedBoardConfig array and use AspeedMachineClass | ||
53 | aspeed: Add support for the tacoma-bmc board | ||
54 | aspeed: Change the "scu" property definition | ||
55 | aspeed: Change the "nic" property definition | ||
56 | 43 | ||
57 | David Gibson (1): | 44 | MAINTAINERS | 1 + |
58 | exynos4210_gic: Suppress gcc9 format-truncation warnings | 45 | docs/system/arm/b-l475e-iot01a.rst | 2 +- |
46 | docs/system/arm/emulation.rst | 1 + | ||
47 | include/hw/arm/stm32l4x5_soc.h | 2 + | ||
48 | include/hw/gpio/stm32l4x5_gpio.h | 71 +++++ | ||
49 | include/hw/misc/stm32l4x5_syscfg.h | 3 +- | ||
50 | include/hw/rtc/sun4v-rtc.h | 2 +- | ||
51 | target/arm/cpu-features.h | 10 + | ||
52 | target/arm/cpu.h | 129 +-------- | ||
53 | target/arm/internals.h | 151 ++++++++++ | ||
54 | hw/arm/stm32l4x5_soc.c | 71 ++++- | ||
55 | hw/gpio/stm32l4x5_gpio.c | 477 ++++++++++++++++++++++++++++++++ | ||
56 | hw/misc/stm32l4x5_syscfg.c | 1 + | ||
57 | hw/rtc/sun4v-rtc.c | 2 +- | ||
58 | target/arm/helper.c | 189 ++++++++++++- | ||
59 | target/arm/tcg/cpu-v7m.c | 290 +++++++++++++++++++ | ||
60 | target/arm/tcg/cpu32.c | 261 ------------------ | ||
61 | target/arm/tcg/cpu64.c | 1 + | ||
62 | target/arm/tcg/sme_helper.c | 77 +++--- | ||
63 | tests/qtest/stm32l4x5_gpio-test.c | 551 +++++++++++++++++++++++++++++++++++++ | ||
64 | tests/tcg/aarch64/sme-smopa-1.c | 47 ++++ | ||
65 | tests/tcg/aarch64/sme-smopa-2.c | 54 ++++ | ||
66 | hw/arm/Kconfig | 3 +- | ||
67 | hw/gpio/Kconfig | 3 + | ||
68 | hw/gpio/meson.build | 1 + | ||
69 | hw/gpio/trace-events | 6 + | ||
70 | target/arm/meson.build | 3 + | ||
71 | target/arm/tcg/meson.build | 3 + | ||
72 | target/arm/trace-events | 1 + | ||
73 | tests/qtest/meson.build | 3 +- | ||
74 | tests/tcg/aarch64/Makefile.target | 2 +- | ||
75 | 31 files changed, 1962 insertions(+), 456 deletions(-) | ||
76 | create mode 100644 include/hw/gpio/stm32l4x5_gpio.h | ||
77 | create mode 100644 hw/gpio/stm32l4x5_gpio.c | ||
78 | create mode 100644 target/arm/tcg/cpu-v7m.c | ||
79 | create mode 100644 tests/qtest/stm32l4x5_gpio-test.c | ||
80 | create mode 100644 tests/tcg/aarch64/sme-smopa-1.c | ||
81 | create mode 100644 tests/tcg/aarch64/sme-smopa-2.c | ||
59 | 82 | ||
60 | Heyi Guo (2): | ||
61 | hw/arm/acpi: simplify AML bit and/or statement | ||
62 | hw/arm/acpi: enable SHPC native hot plug | ||
63 | |||
64 | Joel Stanley (4): | ||
65 | aspeed/sdmc: Make ast2600 default 1G | ||
66 | aspeed/scu: Fix W1C behavior | ||
67 | watchdog/aspeed: Improve watchdog timeout message | ||
68 | watchdog/aspeed: Fix AST2600 frequency behaviour | ||
69 | |||
70 | Marc Zyngier (5): | ||
71 | target/arm: Honor HCR_EL2.TID2 trapping requirements | ||
72 | target/arm: Honor HCR_EL2.TID1 trapping requirements | ||
73 | target/arm: Handle trapping to EL2 of AArch32 VMRS instructions | ||
74 | target/arm: Handle AArch32 CP15 trapping via HSTR_EL2 | ||
75 | target/arm: Add support for missing Jazelle system registers | ||
76 | |||
77 | Niek Linnenbank (1): | ||
78 | arm/arm-powerctl: set NSACR.{CP11, CP10} bits in arm_set_cpu_on() | ||
79 | |||
80 | PanNengyuan (1): | ||
81 | gpio: fix memory leak in aspeed_gpio_init() | ||
82 | |||
83 | Philippe Mathieu-Daudé (2): | ||
84 | hw/arm/sbsa-ref: Simplify by moving the gic in the machine state | ||
85 | hw/arm/virt: Simplify by moving the gic in the machine state | ||
86 | |||
87 | include/exec/exec-all.h | 6 + | ||
88 | include/exec/memory.h | 6 + | ||
89 | include/exec/ram_addr.h | 8 + | ||
90 | include/hw/arm/aspeed.h | 24 +-- | ||
91 | include/hw/arm/aspeed_soc.h | 1 + | ||
92 | include/hw/arm/virt.h | 1 + | ||
93 | include/hw/i2c/aspeed_i2c.h | 16 ++ | ||
94 | include/hw/ssi/aspeed_smc.h | 1 + | ||
95 | include/hw/watchdog/wdt_aspeed.h | 1 + | ||
96 | include/qemu/cutils.h | 1 + | ||
97 | target/arm/cpu.h | 20 +- | ||
98 | target/arm/helper.h | 3 + | ||
99 | target/arm/translate.h | 2 + | ||
100 | exec.c | 36 ++++ | ||
101 | hw/arm/aspeed.c | 271 +++++++++++++---------- | ||
102 | hw/arm/aspeed_ast2600.c | 25 ++- | ||
103 | hw/arm/aspeed_soc.c | 22 +- | ||
104 | hw/arm/sbsa-ref.c | 86 ++++---- | ||
105 | hw/arm/virt-acpi-build.c | 21 +- | ||
106 | hw/arm/virt.c | 109 +++++----- | ||
107 | hw/gpio/aspeed_gpio.c | 1 + | ||
108 | hw/i2c/aspeed_i2c.c | 439 +++++++++++++++++++++++++++++++++++--- | ||
109 | hw/intc/exynos4210_gic.c | 9 +- | ||
110 | hw/misc/aspeed_scu.c | 19 +- | ||
111 | hw/misc/aspeed_sdmc.c | 6 +- | ||
112 | hw/net/ftgmac100.c | 19 +- | ||
113 | hw/ssi/aspeed_smc.c | 63 ++++-- | ||
114 | hw/timer/aspeed_timer.c | 17 +- | ||
115 | hw/watchdog/wdt_aspeed.c | 41 ++-- | ||
116 | linux-user/elfload.c | 2 + | ||
117 | memory.c | 12 ++ | ||
118 | migration/ram.c | 5 +- | ||
119 | target/arm/arm-powerctl.c | 3 + | ||
120 | target/arm/cpu.c | 33 +++ | ||
121 | target/arm/cpu64.c | 1 + | ||
122 | target/arm/helper.c | 170 ++++++++++++++- | ||
123 | target/arm/op_helper.c | 22 ++ | ||
124 | target/arm/translate-vfp.inc.c | 20 +- | ||
125 | target/arm/translate.c | 9 +- | ||
126 | target/arm/vfp_helper.c | 29 +++ | ||
127 | util/cutils.c | 38 ++++ | ||
128 | hw/i2c/trace-events | 9 + | ||
129 | tests/data/acpi/virt/DSDT | Bin 18470 -> 18462 bytes | ||
130 | tests/data/acpi/virt/DSDT.memhp | Bin 19807 -> 19799 bytes | ||
131 | tests/data/acpi/virt/DSDT.numamem | Bin 18470 -> 18462 bytes | ||
132 | 45 files changed, 1273 insertions(+), 354 deletions(-) | ||
133 | diff view generated by jsdifflib |
1 | From: Marc Zyngier <maz@kernel.org> | 1 | cpu.h has a lot of #defines relating to CPU register fields. |
---|---|---|---|
2 | Most of these aren't actually used outside target/arm code, | ||
3 | so there's no point in cluttering up the cpu.h file with them. | ||
4 | Move some easy ones to internals.h. | ||
2 | 5 | ||
3 | HSTR_EL2 offers a way to trap ranges of CP15 system register | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | accesses to EL2, and it looks like this register is completely | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
5 | ignored by QEMU. | ||
6 | |||
7 | To avoid adding extra .accessfn filters all over the place (which | ||
8 | would have a direct performance impact), let's add a new TB flag | ||
9 | that gets set whenever HSTR_EL2 is non-zero and that QEMU translates | ||
10 | a context where this trap has a chance to apply, and only generate | ||
11 | the extra access check if the hypervisor is actively using this feature. | ||
12 | |||
13 | Tested with a hand-crafted KVM guest accessing CBAR. | ||
14 | |||
15 | Signed-off-by: Marc Zyngier <maz@kernel.org> | ||
16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
17 | Message-id: 20191201122018.25808-5-maz@kernel.org | 9 | Message-id: 20240301183219.2424889-2-peter.maydell@linaro.org |
18 | [PMM: use is_a64(); fix comment syntax] | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | --- | 10 | --- |
21 | target/arm/cpu.h | 2 ++ | 11 | target/arm/cpu.h | 128 ----------------------------------------- |
22 | target/arm/translate.h | 2 ++ | 12 | target/arm/internals.h | 128 +++++++++++++++++++++++++++++++++++++++++ |
23 | target/arm/helper.c | 6 ++++++ | 13 | 2 files changed, 128 insertions(+), 128 deletions(-) |
24 | target/arm/op_helper.c | 22 ++++++++++++++++++++++ | ||
25 | target/arm/translate.c | 3 ++- | ||
26 | 5 files changed, 34 insertions(+), 1 deletion(-) | ||
27 | 14 | ||
28 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
29 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/target/arm/cpu.h | 17 | --- a/target/arm/cpu.h |
31 | +++ b/target/arm/cpu.h | 18 | +++ b/target/arm/cpu.h |
32 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1) | 19 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMGenericTimer { |
33 | FIELD(TBFLAG_A32, VFPEN, 7, 1) /* Partially cached, minus FPEXC. */ | 20 | uint64_t ctl; /* Timer Control register */ |
34 | FIELD(TBFLAG_A32, CONDEXEC, 8, 8) /* Not cached. */ | 21 | } ARMGenericTimer; |
35 | FIELD(TBFLAG_A32, SCTLR_B, 16, 1) | 22 | |
36 | +FIELD(TBFLAG_A32, HSTR_ACTIVE, 17, 1) | 23 | -#define VTCR_NSW (1u << 29) |
37 | + | 24 | -#define VTCR_NSA (1u << 30) |
38 | /* For M profile only, set if FPCCR.LSPACT is set */ | 25 | -#define VSTCR_SW VTCR_NSW |
39 | FIELD(TBFLAG_A32, LSPACT, 18, 1) /* Not cached. */ | 26 | -#define VSTCR_SA VTCR_NSA |
40 | /* For M profile only, set if we must create a new FP context */ | 27 | - |
41 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 28 | /* Define a maximum sized vector register. |
29 | * For 32-bit, this is a 128-bit NEON/AdvSIMD register. | ||
30 | * For 64-bit, this is a 2048-bit SVE register. | ||
31 | @@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu); | ||
32 | #define SCTLR_SPINTMASK (1ULL << 62) /* FEAT_NMI */ | ||
33 | #define SCTLR_TIDCP (1ULL << 63) /* FEAT_TIDCP1 */ | ||
34 | |||
35 | -/* Bit definitions for CPACR (AArch32 only) */ | ||
36 | -FIELD(CPACR, CP10, 20, 2) | ||
37 | -FIELD(CPACR, CP11, 22, 2) | ||
38 | -FIELD(CPACR, TRCDIS, 28, 1) /* matches CPACR_EL1.TTA */ | ||
39 | -FIELD(CPACR, D32DIS, 30, 1) /* up to v7; RAZ in v8 */ | ||
40 | -FIELD(CPACR, ASEDIS, 31, 1) | ||
41 | - | ||
42 | -/* Bit definitions for CPACR_EL1 (AArch64 only) */ | ||
43 | -FIELD(CPACR_EL1, ZEN, 16, 2) | ||
44 | -FIELD(CPACR_EL1, FPEN, 20, 2) | ||
45 | -FIELD(CPACR_EL1, SMEN, 24, 2) | ||
46 | -FIELD(CPACR_EL1, TTA, 28, 1) /* matches CPACR.TRCDIS */ | ||
47 | - | ||
48 | -/* Bit definitions for HCPTR (AArch32 only) */ | ||
49 | -FIELD(HCPTR, TCP10, 10, 1) | ||
50 | -FIELD(HCPTR, TCP11, 11, 1) | ||
51 | -FIELD(HCPTR, TASE, 15, 1) | ||
52 | -FIELD(HCPTR, TTA, 20, 1) | ||
53 | -FIELD(HCPTR, TAM, 30, 1) /* matches CPTR_EL2.TAM */ | ||
54 | -FIELD(HCPTR, TCPAC, 31, 1) /* matches CPTR_EL2.TCPAC */ | ||
55 | - | ||
56 | -/* Bit definitions for CPTR_EL2 (AArch64 only) */ | ||
57 | -FIELD(CPTR_EL2, TZ, 8, 1) /* !E2H */ | ||
58 | -FIELD(CPTR_EL2, TFP, 10, 1) /* !E2H, matches HCPTR.TCP10 */ | ||
59 | -FIELD(CPTR_EL2, TSM, 12, 1) /* !E2H */ | ||
60 | -FIELD(CPTR_EL2, ZEN, 16, 2) /* E2H */ | ||
61 | -FIELD(CPTR_EL2, FPEN, 20, 2) /* E2H */ | ||
62 | -FIELD(CPTR_EL2, SMEN, 24, 2) /* E2H */ | ||
63 | -FIELD(CPTR_EL2, TTA, 28, 1) | ||
64 | -FIELD(CPTR_EL2, TAM, 30, 1) /* matches HCPTR.TAM */ | ||
65 | -FIELD(CPTR_EL2, TCPAC, 31, 1) /* matches HCPTR.TCPAC */ | ||
66 | - | ||
67 | -/* Bit definitions for CPTR_EL3 (AArch64 only) */ | ||
68 | -FIELD(CPTR_EL3, EZ, 8, 1) | ||
69 | -FIELD(CPTR_EL3, TFP, 10, 1) | ||
70 | -FIELD(CPTR_EL3, ESM, 12, 1) | ||
71 | -FIELD(CPTR_EL3, TTA, 20, 1) | ||
72 | -FIELD(CPTR_EL3, TAM, 30, 1) | ||
73 | -FIELD(CPTR_EL3, TCPAC, 31, 1) | ||
74 | - | ||
75 | -#define MDCR_MTPME (1U << 28) | ||
76 | -#define MDCR_TDCC (1U << 27) | ||
77 | -#define MDCR_HLP (1U << 26) /* MDCR_EL2 */ | ||
78 | -#define MDCR_SCCD (1U << 23) /* MDCR_EL3 */ | ||
79 | -#define MDCR_HCCD (1U << 23) /* MDCR_EL2 */ | ||
80 | -#define MDCR_EPMAD (1U << 21) | ||
81 | -#define MDCR_EDAD (1U << 20) | ||
82 | -#define MDCR_TTRF (1U << 19) | ||
83 | -#define MDCR_STE (1U << 18) /* MDCR_EL3 */ | ||
84 | -#define MDCR_SPME (1U << 17) /* MDCR_EL3 */ | ||
85 | -#define MDCR_HPMD (1U << 17) /* MDCR_EL2 */ | ||
86 | -#define MDCR_SDD (1U << 16) | ||
87 | -#define MDCR_SPD (3U << 14) | ||
88 | -#define MDCR_TDRA (1U << 11) | ||
89 | -#define MDCR_TDOSA (1U << 10) | ||
90 | -#define MDCR_TDA (1U << 9) | ||
91 | -#define MDCR_TDE (1U << 8) | ||
92 | -#define MDCR_HPME (1U << 7) | ||
93 | -#define MDCR_TPM (1U << 6) | ||
94 | -#define MDCR_TPMCR (1U << 5) | ||
95 | -#define MDCR_HPMN (0x1fU) | ||
96 | - | ||
97 | -/* Not all of the MDCR_EL3 bits are present in the 32-bit SDCR */ | ||
98 | -#define SDCR_VALID_MASK (MDCR_MTPME | MDCR_TDCC | MDCR_SCCD | \ | ||
99 | - MDCR_EPMAD | MDCR_EDAD | MDCR_TTRF | \ | ||
100 | - MDCR_STE | MDCR_SPME | MDCR_SPD) | ||
101 | - | ||
102 | #define CPSR_M (0x1fU) | ||
103 | #define CPSR_T (1U << 5) | ||
104 | #define CPSR_F (1U << 6) | ||
105 | @@ -XXX,XX +XXX,XX @@ FIELD(CPTR_EL3, TCPAC, 31, 1) | ||
106 | #define XPSR_NZCV CPSR_NZCV | ||
107 | #define XPSR_IT CPSR_IT | ||
108 | |||
109 | -#define TTBCR_N (7U << 0) /* TTBCR.EAE==0 */ | ||
110 | -#define TTBCR_T0SZ (7U << 0) /* TTBCR.EAE==1 */ | ||
111 | -#define TTBCR_PD0 (1U << 4) | ||
112 | -#define TTBCR_PD1 (1U << 5) | ||
113 | -#define TTBCR_EPD0 (1U << 7) | ||
114 | -#define TTBCR_IRGN0 (3U << 8) | ||
115 | -#define TTBCR_ORGN0 (3U << 10) | ||
116 | -#define TTBCR_SH0 (3U << 12) | ||
117 | -#define TTBCR_T1SZ (3U << 16) | ||
118 | -#define TTBCR_A1 (1U << 22) | ||
119 | -#define TTBCR_EPD1 (1U << 23) | ||
120 | -#define TTBCR_IRGN1 (3U << 24) | ||
121 | -#define TTBCR_ORGN1 (3U << 26) | ||
122 | -#define TTBCR_SH1 (1U << 28) | ||
123 | -#define TTBCR_EAE (1U << 31) | ||
124 | - | ||
125 | -FIELD(VTCR, T0SZ, 0, 6) | ||
126 | -FIELD(VTCR, SL0, 6, 2) | ||
127 | -FIELD(VTCR, IRGN0, 8, 2) | ||
128 | -FIELD(VTCR, ORGN0, 10, 2) | ||
129 | -FIELD(VTCR, SH0, 12, 2) | ||
130 | -FIELD(VTCR, TG0, 14, 2) | ||
131 | -FIELD(VTCR, PS, 16, 3) | ||
132 | -FIELD(VTCR, VS, 19, 1) | ||
133 | -FIELD(VTCR, HA, 21, 1) | ||
134 | -FIELD(VTCR, HD, 22, 1) | ||
135 | -FIELD(VTCR, HWU59, 25, 1) | ||
136 | -FIELD(VTCR, HWU60, 26, 1) | ||
137 | -FIELD(VTCR, HWU61, 27, 1) | ||
138 | -FIELD(VTCR, HWU62, 28, 1) | ||
139 | -FIELD(VTCR, NSW, 29, 1) | ||
140 | -FIELD(VTCR, NSA, 30, 1) | ||
141 | -FIELD(VTCR, DS, 32, 1) | ||
142 | -FIELD(VTCR, SL2, 33, 1) | ||
143 | - | ||
144 | /* Bit definitions for ARMv8 SPSR (PSTATE) format. | ||
145 | * Only these are valid when in AArch64 mode; in | ||
146 | * AArch32 mode SPSRs are basically CPSR-format. | ||
147 | @@ -XXX,XX +XXX,XX @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) | ||
148 | #define HCR_TWEDEN (1ULL << 59) | ||
149 | #define HCR_TWEDEL MAKE_64BIT_MASK(60, 4) | ||
150 | |||
151 | -#define HCRX_ENAS0 (1ULL << 0) | ||
152 | -#define HCRX_ENALS (1ULL << 1) | ||
153 | -#define HCRX_ENASR (1ULL << 2) | ||
154 | -#define HCRX_FNXS (1ULL << 3) | ||
155 | -#define HCRX_FGTNXS (1ULL << 4) | ||
156 | -#define HCRX_SMPME (1ULL << 5) | ||
157 | -#define HCRX_TALLINT (1ULL << 6) | ||
158 | -#define HCRX_VINMI (1ULL << 7) | ||
159 | -#define HCRX_VFNMI (1ULL << 8) | ||
160 | -#define HCRX_CMOW (1ULL << 9) | ||
161 | -#define HCRX_MCE2 (1ULL << 10) | ||
162 | -#define HCRX_MSCEN (1ULL << 11) | ||
163 | - | ||
164 | -#define HPFAR_NS (1ULL << 63) | ||
165 | - | ||
166 | #define SCR_NS (1ULL << 0) | ||
167 | #define SCR_IRQ (1ULL << 1) | ||
168 | #define SCR_FIQ (1ULL << 2) | ||
169 | @@ -XXX,XX +XXX,XX @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) | ||
170 | #define SCR_GPF (1ULL << 48) | ||
171 | #define SCR_NSE (1ULL << 62) | ||
172 | |||
173 | -#define HSTR_TTEE (1 << 16) | ||
174 | -#define HSTR_TJDBX (1 << 17) | ||
175 | - | ||
176 | -#define CNTHCTL_CNTVMASK (1 << 18) | ||
177 | -#define CNTHCTL_CNTPMASK (1 << 19) | ||
178 | - | ||
179 | /* Return the current FPSCR value. */ | ||
180 | uint32_t vfp_get_fpscr(CPUARMState *env); | ||
181 | void vfp_set_fpscr(CPUARMState *env, uint32_t val); | ||
182 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
42 | index XXXXXXX..XXXXXXX 100644 | 183 | index XXXXXXX..XXXXXXX 100644 |
43 | --- a/target/arm/translate.h | 184 | --- a/target/arm/internals.h |
44 | +++ b/target/arm/translate.h | 185 | +++ b/target/arm/internals.h |
45 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | 186 | @@ -XXX,XX +XXX,XX @@ FIELD(DBGWCR, WT, 20, 1) |
46 | bool pauth_active; | 187 | FIELD(DBGWCR, MASK, 24, 5) |
47 | /* True with v8.5-BTI and SCTLR_ELx.BT* set. */ | 188 | FIELD(DBGWCR, SSCE, 29, 1) |
48 | bool bt; | 189 | |
49 | + /* True if any CP15 access is trapped by HSTR_EL2 */ | 190 | +#define VTCR_NSW (1u << 29) |
50 | + bool hstr_active; | 191 | +#define VTCR_NSA (1u << 30) |
51 | /* | 192 | +#define VSTCR_SW VTCR_NSW |
52 | * >= 0, a copy of PSTATE.BTYPE, which will be 0 without v8.5-BTI. | 193 | +#define VSTCR_SA VTCR_NSA |
53 | * < 0, set by the current instruction. | 194 | + |
54 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 195 | +/* Bit definitions for CPACR (AArch32 only) */ |
55 | index XXXXXXX..XXXXXXX 100644 | 196 | +FIELD(CPACR, CP10, 20, 2) |
56 | --- a/target/arm/helper.c | 197 | +FIELD(CPACR, CP11, 22, 2) |
57 | +++ b/target/arm/helper.c | 198 | +FIELD(CPACR, TRCDIS, 28, 1) /* matches CPACR_EL1.TTA */ |
58 | @@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a32(CPUARMState *env, int fp_el, | 199 | +FIELD(CPACR, D32DIS, 30, 1) /* up to v7; RAZ in v8 */ |
59 | if (arm_el_is_aa64(env, 1)) { | 200 | +FIELD(CPACR, ASEDIS, 31, 1) |
60 | flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1); | 201 | + |
61 | } | 202 | +/* Bit definitions for CPACR_EL1 (AArch64 only) */ |
62 | + | 203 | +FIELD(CPACR_EL1, ZEN, 16, 2) |
63 | + if (arm_current_el(env) < 2 && env->cp15.hstr_el2 && | 204 | +FIELD(CPACR_EL1, FPEN, 20, 2) |
64 | + (arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { | 205 | +FIELD(CPACR_EL1, SMEN, 24, 2) |
65 | + flags = FIELD_DP32(flags, TBFLAG_A32, HSTR_ACTIVE, 1); | 206 | +FIELD(CPACR_EL1, TTA, 28, 1) /* matches CPACR.TRCDIS */ |
66 | + } | 207 | + |
67 | + | 208 | +/* Bit definitions for HCPTR (AArch32 only) */ |
68 | return rebuild_hflags_common_32(env, fp_el, mmu_idx, flags); | 209 | +FIELD(HCPTR, TCP10, 10, 1) |
69 | } | 210 | +FIELD(HCPTR, TCP11, 11, 1) |
70 | 211 | +FIELD(HCPTR, TASE, 15, 1) | |
71 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | 212 | +FIELD(HCPTR, TTA, 20, 1) |
72 | index XXXXXXX..XXXXXXX 100644 | 213 | +FIELD(HCPTR, TAM, 30, 1) /* matches CPTR_EL2.TAM */ |
73 | --- a/target/arm/op_helper.c | 214 | +FIELD(HCPTR, TCPAC, 31, 1) /* matches CPTR_EL2.TCPAC */ |
74 | +++ b/target/arm/op_helper.c | 215 | + |
75 | @@ -XXX,XX +XXX,XX @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome, | 216 | +/* Bit definitions for CPTR_EL2 (AArch64 only) */ |
76 | raise_exception(env, EXCP_UDEF, syndrome, exception_target_el(env)); | 217 | +FIELD(CPTR_EL2, TZ, 8, 1) /* !E2H */ |
77 | } | 218 | +FIELD(CPTR_EL2, TFP, 10, 1) /* !E2H, matches HCPTR.TCP10 */ |
78 | 219 | +FIELD(CPTR_EL2, TSM, 12, 1) /* !E2H */ | |
79 | + /* | 220 | +FIELD(CPTR_EL2, ZEN, 16, 2) /* E2H */ |
80 | + * Check for an EL2 trap due to HSTR_EL2. We expect EL0 accesses | 221 | +FIELD(CPTR_EL2, FPEN, 20, 2) /* E2H */ |
81 | + * to sysregs non accessible at EL0 to have UNDEF-ed already. | 222 | +FIELD(CPTR_EL2, SMEN, 24, 2) /* E2H */ |
82 | + */ | 223 | +FIELD(CPTR_EL2, TTA, 28, 1) |
83 | + if (!is_a64(env) && arm_current_el(env) < 2 && ri->cp == 15 && | 224 | +FIELD(CPTR_EL2, TAM, 30, 1) /* matches HCPTR.TAM */ |
84 | + (arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { | 225 | +FIELD(CPTR_EL2, TCPAC, 31, 1) /* matches HCPTR.TCPAC */ |
85 | + uint32_t mask = 1 << ri->crn; | 226 | + |
86 | + | 227 | +/* Bit definitions for CPTR_EL3 (AArch64 only) */ |
87 | + if (ri->type & ARM_CP_64BIT) { | 228 | +FIELD(CPTR_EL3, EZ, 8, 1) |
88 | + mask = 1 << ri->crm; | 229 | +FIELD(CPTR_EL3, TFP, 10, 1) |
89 | + } | 230 | +FIELD(CPTR_EL3, ESM, 12, 1) |
90 | + | 231 | +FIELD(CPTR_EL3, TTA, 20, 1) |
91 | + /* T4 and T14 are RES0 */ | 232 | +FIELD(CPTR_EL3, TAM, 30, 1) |
92 | + mask &= ~((1 << 4) | (1 << 14)); | 233 | +FIELD(CPTR_EL3, TCPAC, 31, 1) |
93 | + | 234 | + |
94 | + if (env->cp15.hstr_el2 & mask) { | 235 | +#define MDCR_MTPME (1U << 28) |
95 | + target_el = 2; | 236 | +#define MDCR_TDCC (1U << 27) |
96 | + goto exept; | 237 | +#define MDCR_HLP (1U << 26) /* MDCR_EL2 */ |
97 | + } | 238 | +#define MDCR_SCCD (1U << 23) /* MDCR_EL3 */ |
98 | + } | 239 | +#define MDCR_HCCD (1U << 23) /* MDCR_EL2 */ |
99 | + | 240 | +#define MDCR_EPMAD (1U << 21) |
100 | if (!ri->accessfn) { | 241 | +#define MDCR_EDAD (1U << 20) |
101 | return; | 242 | +#define MDCR_TTRF (1U << 19) |
102 | } | 243 | +#define MDCR_STE (1U << 18) /* MDCR_EL3 */ |
103 | @@ -XXX,XX +XXX,XX @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome, | 244 | +#define MDCR_SPME (1U << 17) /* MDCR_EL3 */ |
104 | g_assert_not_reached(); | 245 | +#define MDCR_HPMD (1U << 17) /* MDCR_EL2 */ |
105 | } | 246 | +#define MDCR_SDD (1U << 16) |
106 | 247 | +#define MDCR_SPD (3U << 14) | |
107 | +exept: | 248 | +#define MDCR_TDRA (1U << 11) |
108 | raise_exception(env, EXCP_UDEF, syndrome, target_el); | 249 | +#define MDCR_TDOSA (1U << 10) |
109 | } | 250 | +#define MDCR_TDA (1U << 9) |
110 | 251 | +#define MDCR_TDE (1U << 8) | |
111 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 252 | +#define MDCR_HPME (1U << 7) |
112 | index XXXXXXX..XXXXXXX 100644 | 253 | +#define MDCR_TPM (1U << 6) |
113 | --- a/target/arm/translate.c | 254 | +#define MDCR_TPMCR (1U << 5) |
114 | +++ b/target/arm/translate.c | 255 | +#define MDCR_HPMN (0x1fU) |
115 | @@ -XXX,XX +XXX,XX @@ static int disas_coproc_insn(DisasContext *s, uint32_t insn) | 256 | + |
116 | return 1; | 257 | +/* Not all of the MDCR_EL3 bits are present in the 32-bit SDCR */ |
117 | } | 258 | +#define SDCR_VALID_MASK (MDCR_MTPME | MDCR_TDCC | MDCR_SCCD | \ |
118 | 259 | + MDCR_EPMAD | MDCR_EDAD | MDCR_TTRF | \ | |
119 | - if (ri->accessfn || | 260 | + MDCR_STE | MDCR_SPME | MDCR_SPD) |
120 | + if (s->hstr_active || ri->accessfn || | 261 | + |
121 | (arm_dc_feature(s, ARM_FEATURE_XSCALE) && cpnum < 14)) { | 262 | +#define TTBCR_N (7U << 0) /* TTBCR.EAE==0 */ |
122 | /* Emit code to perform further access permissions checks at | 263 | +#define TTBCR_T0SZ (7U << 0) /* TTBCR.EAE==1 */ |
123 | * runtime; this may result in an exception. | 264 | +#define TTBCR_PD0 (1U << 4) |
124 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | 265 | +#define TTBCR_PD1 (1U << 5) |
125 | !arm_el_is_aa64(env, 3); | 266 | +#define TTBCR_EPD0 (1U << 7) |
126 | dc->thumb = FIELD_EX32(tb_flags, TBFLAG_A32, THUMB); | 267 | +#define TTBCR_IRGN0 (3U << 8) |
127 | dc->sctlr_b = FIELD_EX32(tb_flags, TBFLAG_A32, SCTLR_B); | 268 | +#define TTBCR_ORGN0 (3U << 10) |
128 | + dc->hstr_active = FIELD_EX32(tb_flags, TBFLAG_A32, HSTR_ACTIVE); | 269 | +#define TTBCR_SH0 (3U << 12) |
129 | dc->be_data = FIELD_EX32(tb_flags, TBFLAG_ANY, BE_DATA) ? MO_BE : MO_LE; | 270 | +#define TTBCR_T1SZ (3U << 16) |
130 | condexec = FIELD_EX32(tb_flags, TBFLAG_A32, CONDEXEC); | 271 | +#define TTBCR_A1 (1U << 22) |
131 | dc->condexec_mask = (condexec & 0xf) << 1; | 272 | +#define TTBCR_EPD1 (1U << 23) |
273 | +#define TTBCR_IRGN1 (3U << 24) | ||
274 | +#define TTBCR_ORGN1 (3U << 26) | ||
275 | +#define TTBCR_SH1 (1U << 28) | ||
276 | +#define TTBCR_EAE (1U << 31) | ||
277 | + | ||
278 | +FIELD(VTCR, T0SZ, 0, 6) | ||
279 | +FIELD(VTCR, SL0, 6, 2) | ||
280 | +FIELD(VTCR, IRGN0, 8, 2) | ||
281 | +FIELD(VTCR, ORGN0, 10, 2) | ||
282 | +FIELD(VTCR, SH0, 12, 2) | ||
283 | +FIELD(VTCR, TG0, 14, 2) | ||
284 | +FIELD(VTCR, PS, 16, 3) | ||
285 | +FIELD(VTCR, VS, 19, 1) | ||
286 | +FIELD(VTCR, HA, 21, 1) | ||
287 | +FIELD(VTCR, HD, 22, 1) | ||
288 | +FIELD(VTCR, HWU59, 25, 1) | ||
289 | +FIELD(VTCR, HWU60, 26, 1) | ||
290 | +FIELD(VTCR, HWU61, 27, 1) | ||
291 | +FIELD(VTCR, HWU62, 28, 1) | ||
292 | +FIELD(VTCR, NSW, 29, 1) | ||
293 | +FIELD(VTCR, NSA, 30, 1) | ||
294 | +FIELD(VTCR, DS, 32, 1) | ||
295 | +FIELD(VTCR, SL2, 33, 1) | ||
296 | + | ||
297 | +#define HCRX_ENAS0 (1ULL << 0) | ||
298 | +#define HCRX_ENALS (1ULL << 1) | ||
299 | +#define HCRX_ENASR (1ULL << 2) | ||
300 | +#define HCRX_FNXS (1ULL << 3) | ||
301 | +#define HCRX_FGTNXS (1ULL << 4) | ||
302 | +#define HCRX_SMPME (1ULL << 5) | ||
303 | +#define HCRX_TALLINT (1ULL << 6) | ||
304 | +#define HCRX_VINMI (1ULL << 7) | ||
305 | +#define HCRX_VFNMI (1ULL << 8) | ||
306 | +#define HCRX_CMOW (1ULL << 9) | ||
307 | +#define HCRX_MCE2 (1ULL << 10) | ||
308 | +#define HCRX_MSCEN (1ULL << 11) | ||
309 | + | ||
310 | +#define HPFAR_NS (1ULL << 63) | ||
311 | + | ||
312 | +#define HSTR_TTEE (1 << 16) | ||
313 | +#define HSTR_TJDBX (1 << 17) | ||
314 | + | ||
315 | +#define CNTHCTL_CNTVMASK (1 << 18) | ||
316 | +#define CNTHCTL_CNTPMASK (1 << 19) | ||
317 | + | ||
318 | /* We use a few fake FSR values for internal purposes in M profile. | ||
319 | * M profile cores don't have A/R format FSRs, but currently our | ||
320 | * get_phys_addr() code assumes A/R profile and reports failures via | ||
132 | -- | 321 | -- |
133 | 2.20.1 | 322 | 2.34.1 |
134 | 323 | ||
135 | 324 | diff view generated by jsdifflib |
1 | From: Marc Zyngier <maz@kernel.org> | 1 | The timer _EL02 registers should UNDEF for invalid accesses from EL2 |
---|---|---|---|
2 | or EL3 when HCR_EL2.E2H == 0, not take a cp access trap. We were | ||
3 | delivering the exception to EL2 with the wrong syndrome. | ||
2 | 4 | ||
3 | QEMU lacks the minimum Jazelle implementation that is required | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | by the architecture (everything is RAZ or RAZ/WI). Add it | ||
5 | together with the HCR_EL2.TID0 trapping that goes with it. | ||
6 | |||
7 | Signed-off-by: Marc Zyngier <maz@kernel.org> | ||
8 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20191201122018.25808-6-maz@kernel.org | 7 | Message-id: 20240301183219.2424889-3-peter.maydell@linaro.org |
11 | [PMM: moved ARMCPRegInfo array to file scope, marked it | ||
12 | 'static global', moved new condition down in | ||
13 | register_cp_regs_for_features() to go with other feature | ||
14 | things rather than up with the v6/v7/v8 stuff] | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | 8 | --- |
17 | target/arm/helper.c | 27 +++++++++++++++++++++++++++ | 9 | target/arm/helper.c | 2 +- |
18 | 1 file changed, 27 insertions(+) | 10 | 1 file changed, 1 insertion(+), 1 deletion(-) |
19 | 11 | ||
20 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 12 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
21 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/helper.c | 14 | --- a/target/arm/helper.c |
23 | +++ b/target/arm/helper.c | 15 | +++ b/target/arm/helper.c |
24 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_aa32_tid3(CPUARMState *env, const ARMCPRegInfo *ri, | 16 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult e2h_access(CPUARMState *env, const ARMCPRegInfo *ri, |
17 | return CP_ACCESS_OK; | ||
18 | } | ||
19 | if (!(arm_hcr_el2_eff(env) & HCR_E2H)) { | ||
20 | - return CP_ACCESS_TRAP; | ||
21 | + return CP_ACCESS_TRAP_UNCATEGORIZED; | ||
22 | } | ||
25 | return CP_ACCESS_OK; | 23 | return CP_ACCESS_OK; |
26 | } | 24 | } |
27 | |||
28 | +static CPAccessResult access_jazelle(CPUARMState *env, const ARMCPRegInfo *ri, | ||
29 | + bool isread) | ||
30 | +{ | ||
31 | + if (arm_current_el(env) == 1 && (arm_hcr_el2_eff(env) & HCR_TID0)) { | ||
32 | + return CP_ACCESS_TRAP_EL2; | ||
33 | + } | ||
34 | + | ||
35 | + return CP_ACCESS_OK; | ||
36 | +} | ||
37 | + | ||
38 | +static const ARMCPRegInfo jazelle_regs[] = { | ||
39 | + { .name = "JIDR", | ||
40 | + .cp = 14, .crn = 0, .crm = 0, .opc1 = 7, .opc2 = 0, | ||
41 | + .access = PL1_R, .accessfn = access_jazelle, | ||
42 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
43 | + { .name = "JOSCR", | ||
44 | + .cp = 14, .crn = 1, .crm = 0, .opc1 = 7, .opc2 = 0, | ||
45 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
46 | + { .name = "JMCR", | ||
47 | + .cp = 14, .crn = 2, .crm = 0, .opc1 = 7, .opc2 = 0, | ||
48 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
49 | + REGINFO_SENTINEL | ||
50 | +}; | ||
51 | + | ||
52 | void register_cp_regs_for_features(ARMCPU *cpu) | ||
53 | { | ||
54 | /* Register all the coprocessor registers based on feature bits */ | ||
55 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
56 | if (arm_feature(env, ARM_FEATURE_LPAE)) { | ||
57 | define_arm_cp_regs(cpu, lpae_cp_reginfo); | ||
58 | } | ||
59 | + if (cpu_isar_feature(jazelle, cpu)) { | ||
60 | + define_arm_cp_regs(cpu, jazelle_regs); | ||
61 | + } | ||
62 | /* Slightly awkwardly, the OMAP and StrongARM cores need all of | ||
63 | * cp15 crn=0 to be writes-ignored, whereas for other cores they should | ||
64 | * be read-only (ie write causes UNDEF exception). | ||
65 | -- | 25 | -- |
66 | 2.20.1 | 26 | 2.34.1 |
67 | |||
68 | diff view generated by jsdifflib |
1 | From: Marc Zyngier <maz@kernel.org> | 1 | We prefer the FIELD macro over ad-hoc #defines for register bits; |
---|---|---|---|
2 | switch CNTHCTL to that style before we add any more bits. | ||
2 | 3 | ||
3 | HCR_EL2.TID2 mandates that access from EL1 to CTR_EL0, CCSIDR_EL1, | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | CCSIDR2_EL1, CLIDR_EL1, CSSELR_EL1 are trapped to EL2, and QEMU | 5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
5 | completely ignores it, making it impossible for hypervisors to | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | virtualize the cache hierarchy. | 7 | Message-id: 20240301183219.2424889-4-peter.maydell@linaro.org |
8 | --- | ||
9 | target/arm/internals.h | 27 +++++++++++++++++++++++++-- | ||
10 | target/arm/helper.c | 9 ++++----- | ||
11 | 2 files changed, 29 insertions(+), 7 deletions(-) | ||
7 | 12 | ||
8 | Do the right thing by trapping to EL2 if HCR_EL2.TID2 is set. | 13 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
9 | 14 | index XXXXXXX..XXXXXXX 100644 | |
10 | Signed-off-by: Marc Zyngier <maz@kernel.org> | 15 | --- a/target/arm/internals.h |
11 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 16 | +++ b/target/arm/internals.h |
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 17 | @@ -XXX,XX +XXX,XX @@ FIELD(VTCR, SL2, 33, 1) |
13 | Message-id: 20191201122018.25808-2-maz@kernel.org | 18 | #define HSTR_TTEE (1 << 16) |
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | #define HSTR_TJDBX (1 << 17) |
15 | --- | 20 | |
16 | target/arm/helper.c | 31 +++++++++++++++++++++++++++---- | 21 | -#define CNTHCTL_CNTVMASK (1 << 18) |
17 | 1 file changed, 27 insertions(+), 4 deletions(-) | 22 | -#define CNTHCTL_CNTPMASK (1 << 19) |
18 | 23 | +/* | |
24 | + * Depending on the value of HCR_EL2.E2H, bits 0 and 1 | ||
25 | + * have different bit definitions, and EL1PCTEN might be | ||
26 | + * bit 0 or bit 10. We use _E2H1 and _E2H0 suffixes to | ||
27 | + * disambiguate if necessary. | ||
28 | + */ | ||
29 | +FIELD(CNTHCTL, EL0PCTEN_E2H1, 0, 1) | ||
30 | +FIELD(CNTHCTL, EL0VCTEN_E2H1, 1, 1) | ||
31 | +FIELD(CNTHCTL, EL1PCTEN_E2H0, 0, 1) | ||
32 | +FIELD(CNTHCTL, EL1PCEN_E2H0, 1, 1) | ||
33 | +FIELD(CNTHCTL, EVNTEN, 2, 1) | ||
34 | +FIELD(CNTHCTL, EVNTDIR, 3, 1) | ||
35 | +FIELD(CNTHCTL, EVNTI, 4, 4) | ||
36 | +FIELD(CNTHCTL, EL0VTEN, 8, 1) | ||
37 | +FIELD(CNTHCTL, EL0PTEN, 9, 1) | ||
38 | +FIELD(CNTHCTL, EL1PCTEN_E2H1, 10, 1) | ||
39 | +FIELD(CNTHCTL, EL1PTEN, 11, 1) | ||
40 | +FIELD(CNTHCTL, ECV, 12, 1) | ||
41 | +FIELD(CNTHCTL, EL1TVT, 13, 1) | ||
42 | +FIELD(CNTHCTL, EL1TVCT, 14, 1) | ||
43 | +FIELD(CNTHCTL, EL1NVPCT, 15, 1) | ||
44 | +FIELD(CNTHCTL, EL1NVVCT, 16, 1) | ||
45 | +FIELD(CNTHCTL, EVNTIS, 17, 1) | ||
46 | +FIELD(CNTHCTL, CNTVMASK, 18, 1) | ||
47 | +FIELD(CNTHCTL, CNTPMASK, 19, 1) | ||
48 | |||
49 | /* We use a few fake FSR values for internal purposes in M profile. | ||
50 | * M profile cores don't have A/R format FSRs, but currently our | ||
19 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 51 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
20 | index XXXXXXX..XXXXXXX 100644 | 52 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/helper.c | 53 | --- a/target/arm/helper.c |
22 | +++ b/target/arm/helper.c | 54 | +++ b/target/arm/helper.c |
23 | @@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | 55 | @@ -XXX,XX +XXX,XX @@ static void gt_update_irq(ARMCPU *cpu, int timeridx) |
24 | raw_write(env, ri, value); | 56 | * It is RES0 in Secure and NonSecure state. |
25 | } | 57 | */ |
26 | 58 | if ((ss == ARMSS_Root || ss == ARMSS_Realm) && | |
27 | +static CPAccessResult access_aa64_tid2(CPUARMState *env, | 59 | - ((timeridx == GTIMER_VIRT && (cnthctl & CNTHCTL_CNTVMASK)) || |
28 | + const ARMCPRegInfo *ri, | 60 | - (timeridx == GTIMER_PHYS && (cnthctl & CNTHCTL_CNTPMASK)))) { |
29 | + bool isread) | 61 | + ((timeridx == GTIMER_VIRT && (cnthctl & R_CNTHCTL_CNTVMASK_MASK)) || |
30 | +{ | 62 | + (timeridx == GTIMER_PHYS && (cnthctl & R_CNTHCTL_CNTPMASK_MASK)))) { |
31 | + if (arm_current_el(env) == 1 && (arm_hcr_el2_eff(env) & HCR_TID2)) { | 63 | irqstate = 0; |
32 | + return CP_ACCESS_TRAP_EL2; | 64 | } |
33 | + } | 65 | |
34 | + | 66 | @@ -XXX,XX +XXX,XX @@ static void gt_cnthctl_write(CPUARMState *env, const ARMCPRegInfo *ri, |
35 | + return CP_ACCESS_OK; | ||
36 | +} | ||
37 | + | ||
38 | static uint64_t ccsidr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
39 | { | 67 | { |
40 | ARMCPU *cpu = env_archcpu(env); | 68 | ARMCPU *cpu = env_archcpu(env); |
41 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | 69 | uint32_t oldval = env->cp15.cnthctl_el2; |
42 | .writefn = pmintenclr_write }, | 70 | - |
43 | { .name = "CCSIDR", .state = ARM_CP_STATE_BOTH, | 71 | raw_write(env, ri, value); |
44 | .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 1, .opc2 = 0, | 72 | |
45 | - .access = PL1_R, .readfn = ccsidr_read, .type = ARM_CP_NO_RAW }, | 73 | - if ((oldval ^ value) & CNTHCTL_CNTVMASK) { |
46 | + .access = PL1_R, | 74 | + if ((oldval ^ value) & R_CNTHCTL_CNTVMASK_MASK) { |
47 | + .accessfn = access_aa64_tid2, | 75 | gt_update_irq(cpu, GTIMER_VIRT); |
48 | + .readfn = ccsidr_read, .type = ARM_CP_NO_RAW }, | 76 | - } else if ((oldval ^ value) & CNTHCTL_CNTPMASK) { |
49 | { .name = "CSSELR", .state = ARM_CP_STATE_BOTH, | 77 | + } else if ((oldval ^ value) & R_CNTHCTL_CNTPMASK_MASK) { |
50 | .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 2, .opc2 = 0, | 78 | gt_update_irq(cpu, GTIMER_PHYS); |
51 | - .access = PL1_RW, .writefn = csselr_write, .resetvalue = 0, | ||
52 | + .access = PL1_RW, | ||
53 | + .accessfn = access_aa64_tid2, | ||
54 | + .writefn = csselr_write, .resetvalue = 0, | ||
55 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.csselr_s), | ||
56 | offsetof(CPUARMState, cp15.csselr_ns) } }, | ||
57 | /* Auxiliary ID register: this actually has an IMPDEF value but for now | ||
58 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult ctr_el0_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
59 | if (arm_current_el(env) == 0 && !(env->cp15.sctlr_el[1] & SCTLR_UCT)) { | ||
60 | return CP_ACCESS_TRAP; | ||
61 | } | 79 | } |
62 | + | ||
63 | + if (arm_current_el(env) < 2 && arm_hcr_el2_eff(env) & HCR_TID2) { | ||
64 | + return CP_ACCESS_TRAP_EL2; | ||
65 | + } | ||
66 | + | ||
67 | return CP_ACCESS_OK; | ||
68 | } | 80 | } |
69 | |||
70 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
71 | ARMCPRegInfo clidr = { | ||
72 | .name = "CLIDR", .state = ARM_CP_STATE_BOTH, | ||
73 | .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 1, .opc2 = 1, | ||
74 | - .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->clidr | ||
75 | + .access = PL1_R, .type = ARM_CP_CONST, | ||
76 | + .accessfn = access_aa64_tid2, | ||
77 | + .resetvalue = cpu->clidr | ||
78 | }; | ||
79 | define_one_arm_cp_reg(cpu, &clidr); | ||
80 | define_arm_cp_regs(cpu, v7_cp_reginfo); | ||
81 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
82 | /* These are common to v8 and pre-v8 */ | ||
83 | { .name = "CTR", | ||
84 | .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 1, | ||
85 | - .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->ctr }, | ||
86 | + .access = PL1_R, .accessfn = ctr_el0_access, | ||
87 | + .type = ARM_CP_CONST, .resetvalue = cpu->ctr }, | ||
88 | { .name = "CTR_EL0", .state = ARM_CP_STATE_AA64, | ||
89 | .opc0 = 3, .opc1 = 3, .opc2 = 1, .crn = 0, .crm = 0, | ||
90 | .access = PL0_R, .accessfn = ctr_el0_access, | ||
91 | -- | 81 | -- |
92 | 2.20.1 | 82 | 2.34.1 |
93 | 83 | ||
94 | 84 | diff view generated by jsdifflib |
1 | From: Marc Zyngier <maz@kernel.org> | 1 | Don't allow the guest to write CNTHCTL_EL2 bits which don't exist. |
---|---|---|---|
2 | This is not strictly architecturally required, but it is how we've | ||
3 | tended to implement registers more recently. | ||
2 | 4 | ||
3 | HCR_EL2.TID1 mandates that access from EL1 to REVIDR_EL1, AIDR_EL1 | 5 | In particular, bits [19:18] are only present with FEAT_RME, |
4 | (and their 32bit equivalents) as well as TCMTR, TLBTR are trapped | 6 | and bits [17:12] will only be present with FEAT_ECV. |
5 | to EL2. QEMU ignores it, making it harder for a hypervisor to | ||
6 | virtualize the HW (though to be fair, no known hypervisor actually | ||
7 | cares). | ||
8 | 7 | ||
9 | Do the right thing by trapping to EL2 if HCR_EL2.TID1 is set. | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | |||
11 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
12 | Signed-off-by: Marc Zyngier <maz@kernel.org> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
14 | Message-id: 20191201122018.25808-3-maz@kernel.org | 10 | Message-id: 20240301183219.2424889-5-peter.maydell@linaro.org |
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | 11 | --- |
17 | target/arm/helper.c | 36 ++++++++++++++++++++++++++++++++---- | 12 | target/arm/helper.c | 18 ++++++++++++++++++ |
18 | 1 file changed, 32 insertions(+), 4 deletions(-) | 13 | 1 file changed, 18 insertions(+) |
19 | 14 | ||
20 | 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 |
21 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/helper.c | 17 | --- a/target/arm/helper.c |
23 | +++ b/target/arm/helper.c | 18 | +++ b/target/arm/helper.c |
24 | @@ -XXX,XX +XXX,XX @@ static uint64_t isr_read(CPUARMState *env, const ARMCPRegInfo *ri) | 19 | @@ -XXX,XX +XXX,XX @@ static void gt_cnthctl_write(CPUARMState *env, const ARMCPRegInfo *ri, |
25 | return ret; | 20 | { |
26 | } | 21 | ARMCPU *cpu = env_archcpu(env); |
27 | 22 | uint32_t oldval = env->cp15.cnthctl_el2; | |
28 | +static CPAccessResult access_aa64_tid1(CPUARMState *env, const ARMCPRegInfo *ri, | 23 | + uint32_t valid_mask = |
29 | + bool isread) | 24 | + R_CNTHCTL_EL0PCTEN_E2H1_MASK | |
30 | +{ | 25 | + R_CNTHCTL_EL0VCTEN_E2H1_MASK | |
31 | + if (arm_current_el(env) == 1 && (arm_hcr_el2_eff(env) & HCR_TID1)) { | 26 | + R_CNTHCTL_EVNTEN_MASK | |
32 | + return CP_ACCESS_TRAP_EL2; | 27 | + R_CNTHCTL_EVNTDIR_MASK | |
28 | + R_CNTHCTL_EVNTI_MASK | | ||
29 | + R_CNTHCTL_EL0VTEN_MASK | | ||
30 | + R_CNTHCTL_EL0PTEN_MASK | | ||
31 | + R_CNTHCTL_EL1PCTEN_E2H1_MASK | | ||
32 | + R_CNTHCTL_EL1PTEN_MASK; | ||
33 | + | ||
34 | + if (cpu_isar_feature(aa64_rme, cpu)) { | ||
35 | + valid_mask |= R_CNTHCTL_CNTVMASK_MASK | R_CNTHCTL_CNTPMASK_MASK; | ||
33 | + } | 36 | + } |
34 | + | 37 | + |
35 | + return CP_ACCESS_OK; | 38 | + /* Clear RES0 bits */ |
36 | +} | 39 | + value &= valid_mask; |
37 | + | 40 | + |
38 | +static CPAccessResult access_aa32_tid1(CPUARMState *env, const ARMCPRegInfo *ri, | 41 | raw_write(env, ri, value); |
39 | + bool isread) | 42 | |
40 | +{ | 43 | if ((oldval ^ value) & R_CNTHCTL_CNTVMASK_MASK) { |
41 | + if (arm_feature(env, ARM_FEATURE_V8)) { | ||
42 | + return access_aa64_tid1(env, ri, isread); | ||
43 | + } | ||
44 | + | ||
45 | + return CP_ACCESS_OK; | ||
46 | +} | ||
47 | + | ||
48 | static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
49 | /* the old v6 WFI, UNPREDICTABLE in v7 but we choose to NOP */ | ||
50 | { .name = "NOP", .cp = 15, .crn = 7, .crm = 0, .opc1 = 0, .opc2 = 4, | ||
51 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
52 | */ | ||
53 | { .name = "AIDR", .state = ARM_CP_STATE_BOTH, | ||
54 | .opc0 = 3, .opc1 = 1, .crn = 0, .crm = 0, .opc2 = 7, | ||
55 | - .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
56 | + .access = PL1_R, .type = ARM_CP_CONST, | ||
57 | + .accessfn = access_aa64_tid1, | ||
58 | + .resetvalue = 0 }, | ||
59 | /* Auxiliary fault status registers: these also are IMPDEF, and we | ||
60 | * choose to RAZ/WI for all cores. | ||
61 | */ | ||
62 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
63 | .access = PL1_R, .resetvalue = cpu->midr }, | ||
64 | { .name = "REVIDR_EL1", .state = ARM_CP_STATE_BOTH, | ||
65 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 0, .opc2 = 6, | ||
66 | - .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->revidr }, | ||
67 | + .access = PL1_R, | ||
68 | + .accessfn = access_aa64_tid1, | ||
69 | + .type = ARM_CP_CONST, .resetvalue = cpu->revidr }, | ||
70 | REGINFO_SENTINEL | ||
71 | }; | ||
72 | ARMCPRegInfo id_cp_reginfo[] = { | ||
73 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
74 | /* TCMTR and TLBTR exist in v8 but have no 64-bit versions */ | ||
75 | { .name = "TCMTR", | ||
76 | .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 2, | ||
77 | - .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
78 | + .access = PL1_R, | ||
79 | + .accessfn = access_aa32_tid1, | ||
80 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
81 | REGINFO_SENTINEL | ||
82 | }; | ||
83 | /* TLBTR is specific to VMSA */ | ||
84 | ARMCPRegInfo id_tlbtr_reginfo = { | ||
85 | .name = "TLBTR", | ||
86 | .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 3, | ||
87 | - .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0, | ||
88 | + .access = PL1_R, | ||
89 | + .accessfn = access_aa32_tid1, | ||
90 | + .type = ARM_CP_CONST, .resetvalue = 0, | ||
91 | }; | ||
92 | /* MPUIR is specific to PMSA V6+ */ | ||
93 | ARMCPRegInfo id_mpuir_reginfo = { | ||
94 | -- | 44 | -- |
95 | 2.20.1 | 45 | 2.34.1 |
96 | |||
97 | diff view generated by jsdifflib |
1 | From: Beata Michalska <beata.michalska@linaro.org> | 1 | The functionality defined by ID_AA64MMFR0_EL1.ECV == 1 is: |
---|---|---|---|
2 | * four new trap bits for various counter and timer registers | ||
3 | * the CNTHCTL_EL2.EVNTIS and CNTKCTL_EL1.EVNTIS bits which control | ||
4 | scaling of the event stream. This is a no-op for us, because we don't | ||
5 | implement the event stream (our WFE is a NOP): all we need to do is | ||
6 | allow CNTHCTL_EL2.ENVTIS to be read and written. | ||
7 | * extensions to PMSCR_EL1.PCT, PMSCR_EL2.PCT, TRFCR_EL1.TS and | ||
8 | TRFCR_EL2.TS: these are all no-ops for us, because we don't implement | ||
9 | FEAT_SPE or FEAT_TRF. | ||
10 | * new registers CNTPCTSS_EL0 and NCTVCTSS_EL0 which are | ||
11 | "self-sychronizing" views of the CNTPCT_EL0 and CNTVCT_EL0, meaning | ||
12 | that no barriers are needed around their accesses. For us these | ||
13 | are just the same as the normal views, because all our sysregs are | ||
14 | inherently self-sychronizing. | ||
2 | 15 | ||
3 | Add an option to trigger memory writeback to sync given memory region | 16 | In this commit we implement the trap handling and permit the new |
4 | with the corresponding backing store, case one is available. | 17 | CNTHCTL_EL2 bits to be written. |
5 | This extends the support for persistent memory, allowing syncing on-demand. | ||
6 | 18 | ||
7 | Signed-off-by: Beata Michalska <beata.michalska@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20191121000843.24844-3-beata.michalska@linaro.org | 21 | Message-id: 20240301183219.2424889-6-peter.maydell@linaro.org |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | 22 | --- |
12 | include/exec/memory.h | 6 ++++++ | 23 | target/arm/cpu-features.h | 5 ++++ |
13 | include/exec/ram_addr.h | 8 ++++++++ | 24 | target/arm/helper.c | 51 +++++++++++++++++++++++++++++++++++---- |
14 | include/qemu/cutils.h | 1 + | 25 | 2 files changed, 51 insertions(+), 5 deletions(-) |
15 | exec.c | 36 ++++++++++++++++++++++++++++++++++++ | ||
16 | memory.c | 12 ++++++++++++ | ||
17 | util/cutils.c | 38 ++++++++++++++++++++++++++++++++++++++ | ||
18 | 6 files changed, 101 insertions(+) | ||
19 | 26 | ||
20 | diff --git a/include/exec/memory.h b/include/exec/memory.h | 27 | diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h |
21 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/exec/memory.h | 29 | --- a/target/arm/cpu-features.h |
23 | +++ b/include/exec/memory.h | 30 | +++ b/target/arm/cpu-features.h |
24 | @@ -XXX,XX +XXX,XX @@ void *memory_region_get_ram_ptr(MemoryRegion *mr); | 31 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_fgt(const ARMISARegisters *id) |
25 | */ | 32 | return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, FGT) != 0; |
26 | void memory_region_ram_resize(MemoryRegion *mr, ram_addr_t newsize, | 33 | } |
27 | Error **errp); | 34 | |
28 | +/** | 35 | +static inline bool isar_feature_aa64_ecv_traps(const ARMISARegisters *id) |
29 | + * memory_region_do_writeback: Trigger writeback for selected address range | ||
30 | + * [addr, addr + size] | ||
31 | + * | ||
32 | + */ | ||
33 | +void memory_region_do_writeback(MemoryRegion *mr, hwaddr addr, hwaddr size); | ||
34 | |||
35 | /** | ||
36 | * memory_region_set_log: Turn dirty logging on or off for a region. | ||
37 | diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/include/exec/ram_addr.h | ||
40 | +++ b/include/exec/ram_addr.h | ||
41 | @@ -XXX,XX +XXX,XX @@ void qemu_ram_free(RAMBlock *block); | ||
42 | |||
43 | int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp); | ||
44 | |||
45 | +void qemu_ram_writeback(RAMBlock *block, ram_addr_t start, ram_addr_t length); | ||
46 | + | ||
47 | +/* Clear whole block of mem */ | ||
48 | +static inline void qemu_ram_block_writeback(RAMBlock *block) | ||
49 | +{ | 36 | +{ |
50 | + qemu_ram_writeback(block, 0, block->used_length); | 37 | + return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, ECV) > 0; |
51 | +} | 38 | +} |
52 | + | 39 | + |
53 | #define DIRTY_CLIENTS_ALL ((1 << DIRTY_MEMORY_NUM) - 1) | 40 | static inline bool isar_feature_aa64_vh(const ARMISARegisters *id) |
54 | #define DIRTY_CLIENTS_NOCODE (DIRTY_CLIENTS_ALL & ~(1 << DIRTY_MEMORY_CODE)) | 41 | { |
55 | 42 | return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, VH) != 0; | |
56 | diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h | 43 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
57 | index XXXXXXX..XXXXXXX 100644 | 44 | index XXXXXXX..XXXXXXX 100644 |
58 | --- a/include/qemu/cutils.h | 45 | --- a/target/arm/helper.c |
59 | +++ b/include/qemu/cutils.h | 46 | +++ b/target/arm/helper.c |
60 | @@ -XXX,XX +XXX,XX @@ const char *qemu_strchrnul(const char *s, int c); | 47 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult gt_counter_access(CPUARMState *env, int timeridx, |
61 | #endif | 48 | : !extract32(env->cp15.cnthctl_el2, 0, 1))) { |
62 | time_t mktimegm(struct tm *tm); | 49 | return CP_ACCESS_TRAP_EL2; |
63 | int qemu_fdatasync(int fd); | 50 | } |
64 | +int qemu_msync(void *addr, size_t length, int fd); | 51 | + if (has_el2 && timeridx == GTIMER_VIRT) { |
65 | int fcntl_setfl(int fd, int flag); | 52 | + if (FIELD_EX64(env->cp15.cnthctl_el2, CNTHCTL, EL1TVCT)) { |
66 | int qemu_parse_fd(const char *param); | 53 | + return CP_ACCESS_TRAP_EL2; |
67 | int qemu_strtoi(const char *nptr, const char **endptr, int base, | 54 | + } |
68 | diff --git a/exec.c b/exec.c | 55 | + } |
69 | index XXXXXXX..XXXXXXX 100644 | 56 | break; |
70 | --- a/exec.c | 57 | } |
71 | +++ b/exec.c | 58 | return CP_ACCESS_OK; |
72 | @@ -XXX,XX +XXX,XX @@ | 59 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult gt_timer_access(CPUARMState *env, int timeridx, |
73 | #include "exec/ram_addr.h" | 60 | } |
74 | #include "exec/log.h" | 61 | } |
75 | 62 | } | |
76 | +#include "qemu/pmem.h" | 63 | + if (has_el2 && timeridx == GTIMER_VIRT) { |
77 | + | 64 | + if (FIELD_EX64(env->cp15.cnthctl_el2, CNTHCTL, EL1TVT)) { |
78 | #include "migration/vmstate.h" | 65 | + return CP_ACCESS_TRAP_EL2; |
79 | 66 | + } | |
80 | #include "qemu/range.h" | 67 | + } |
81 | @@ -XXX,XX +XXX,XX @@ int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp) | 68 | break; |
82 | return 0; | 69 | } |
70 | return CP_ACCESS_OK; | ||
71 | @@ -XXX,XX +XXX,XX @@ static void gt_cnthctl_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
72 | if (cpu_isar_feature(aa64_rme, cpu)) { | ||
73 | valid_mask |= R_CNTHCTL_CNTVMASK_MASK | R_CNTHCTL_CNTPMASK_MASK; | ||
74 | } | ||
75 | + if (cpu_isar_feature(aa64_ecv_traps, cpu)) { | ||
76 | + valid_mask |= | ||
77 | + R_CNTHCTL_EL1TVT_MASK | | ||
78 | + R_CNTHCTL_EL1TVCT_MASK | | ||
79 | + R_CNTHCTL_EL1NVPCT_MASK | | ||
80 | + R_CNTHCTL_EL1NVVCT_MASK | | ||
81 | + R_CNTHCTL_EVNTIS_MASK; | ||
82 | + } | ||
83 | |||
84 | /* Clear RES0 bits */ | ||
85 | value &= valid_mask; | ||
86 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult e2h_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
87 | { | ||
88 | if (arm_current_el(env) == 1) { | ||
89 | /* This must be a FEAT_NV access */ | ||
90 | - /* TODO: FEAT_ECV will need to check CNTHCTL_EL2 here */ | ||
91 | return CP_ACCESS_OK; | ||
92 | } | ||
93 | if (!(arm_hcr_el2_eff(env) & HCR_E2H)) { | ||
94 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult e2h_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
95 | return CP_ACCESS_OK; | ||
83 | } | 96 | } |
84 | 97 | ||
85 | +/* | 98 | +static CPAccessResult access_el1nvpct(CPUARMState *env, const ARMCPRegInfo *ri, |
86 | + * Trigger sync on the given ram block for range [start, start + length] | 99 | + bool isread) |
87 | + * with the backing store if one is available. | ||
88 | + * Otherwise no-op. | ||
89 | + * @Note: this is supposed to be a synchronous op. | ||
90 | + */ | ||
91 | +void qemu_ram_writeback(RAMBlock *block, ram_addr_t start, ram_addr_t length) | ||
92 | +{ | 100 | +{ |
93 | + void *addr = ramblock_ptr(block, start); | 101 | + if (arm_current_el(env) == 1) { |
94 | + | 102 | + /* This must be a FEAT_NV access with NVx == 101 */ |
95 | + /* The requested range should fit in within the block range */ | 103 | + if (FIELD_EX64(env->cp15.cnthctl_el2, CNTHCTL, EL1NVPCT)) { |
96 | + g_assert((start + length) <= block->used_length); | 104 | + return CP_ACCESS_TRAP_EL2; |
97 | + | ||
98 | +#ifdef CONFIG_LIBPMEM | ||
99 | + /* The lack of support for pmem should not block the sync */ | ||
100 | + if (ramblock_is_pmem(block)) { | ||
101 | + pmem_persist(addr, length); | ||
102 | + return; | ||
103 | + } | ||
104 | +#endif | ||
105 | + if (block->fd >= 0) { | ||
106 | + /** | ||
107 | + * Case there is no support for PMEM or the memory has not been | ||
108 | + * specified as persistent (or is not one) - use the msync. | ||
109 | + * Less optimal but still achieves the same goal | ||
110 | + */ | ||
111 | + if (qemu_msync(addr, length, block->fd)) { | ||
112 | + warn_report("%s: failed to sync memory range: start: " | ||
113 | + RAM_ADDR_FMT " length: " RAM_ADDR_FMT, | ||
114 | + __func__, start, length); | ||
115 | + } | 105 | + } |
116 | + } | 106 | + } |
107 | + return e2h_access(env, ri, isread); | ||
117 | +} | 108 | +} |
118 | + | 109 | + |
119 | /* Called with ram_list.mutex held */ | 110 | +static CPAccessResult access_el1nvvct(CPUARMState *env, const ARMCPRegInfo *ri, |
120 | static void dirty_memory_extend(ram_addr_t old_ram_size, | 111 | + bool isread) |
121 | ram_addr_t new_ram_size) | ||
122 | diff --git a/memory.c b/memory.c | ||
123 | index XXXXXXX..XXXXXXX 100644 | ||
124 | --- a/memory.c | ||
125 | +++ b/memory.c | ||
126 | @@ -XXX,XX +XXX,XX @@ void memory_region_ram_resize(MemoryRegion *mr, ram_addr_t newsize, Error **errp | ||
127 | qemu_ram_resize(mr->ram_block, newsize, errp); | ||
128 | } | ||
129 | |||
130 | + | ||
131 | +void memory_region_do_writeback(MemoryRegion *mr, hwaddr addr, hwaddr size) | ||
132 | +{ | 112 | +{ |
133 | + /* | 113 | + if (arm_current_el(env) == 1) { |
134 | + * Might be extended case needed to cover | 114 | + /* This must be a FEAT_NV access with NVx == 101 */ |
135 | + * different types of memory regions | 115 | + if (FIELD_EX64(env->cp15.cnthctl_el2, CNTHCTL, EL1NVVCT)) { |
136 | + */ | 116 | + return CP_ACCESS_TRAP_EL2; |
137 | + if (mr->ram_block && mr->dirty_log_mask) { | 117 | + } |
138 | + qemu_ram_writeback(mr->ram_block, addr, size); | ||
139 | + } | 118 | + } |
119 | + return e2h_access(env, ri, isread); | ||
140 | +} | 120 | +} |
141 | + | 121 | + |
142 | /* | 122 | /* Test if system register redirection is to occur in the current state. */ |
143 | * Call proper memory listeners about the change on the newly | 123 | static bool redirect_for_e2h(CPUARMState *env) |
144 | * added/removed CoalescedMemoryRange. | 124 | { |
145 | diff --git a/util/cutils.c b/util/cutils.c | 125 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vhe_reginfo[] = { |
146 | index XXXXXXX..XXXXXXX 100644 | 126 | { .name = "CNTP_CTL_EL02", .state = ARM_CP_STATE_AA64, |
147 | --- a/util/cutils.c | 127 | .opc0 = 3, .opc1 = 5, .crn = 14, .crm = 2, .opc2 = 1, |
148 | +++ b/util/cutils.c | 128 | .type = ARM_CP_IO | ARM_CP_ALIAS, |
149 | @@ -XXX,XX +XXX,XX @@ int qemu_fdatasync(int fd) | 129 | - .access = PL2_RW, .accessfn = e2h_access, |
130 | + .access = PL2_RW, .accessfn = access_el1nvpct, | ||
131 | .nv2_redirect_offset = 0x180 | NV2_REDIR_NO_NV1, | ||
132 | .fieldoffset = offsetof(CPUARMState, cp15.c14_timer[GTIMER_PHYS].ctl), | ||
133 | .writefn = gt_phys_ctl_write, .raw_writefn = raw_write }, | ||
134 | { .name = "CNTV_CTL_EL02", .state = ARM_CP_STATE_AA64, | ||
135 | .opc0 = 3, .opc1 = 5, .crn = 14, .crm = 3, .opc2 = 1, | ||
136 | .type = ARM_CP_IO | ARM_CP_ALIAS, | ||
137 | - .access = PL2_RW, .accessfn = e2h_access, | ||
138 | + .access = PL2_RW, .accessfn = access_el1nvvct, | ||
139 | .nv2_redirect_offset = 0x170 | NV2_REDIR_NO_NV1, | ||
140 | .fieldoffset = offsetof(CPUARMState, cp15.c14_timer[GTIMER_VIRT].ctl), | ||
141 | .writefn = gt_virt_ctl_write, .raw_writefn = raw_write }, | ||
142 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vhe_reginfo[] = { | ||
143 | .type = ARM_CP_IO | ARM_CP_ALIAS, | ||
144 | .fieldoffset = offsetof(CPUARMState, cp15.c14_timer[GTIMER_PHYS].cval), | ||
145 | .nv2_redirect_offset = 0x178 | NV2_REDIR_NO_NV1, | ||
146 | - .access = PL2_RW, .accessfn = e2h_access, | ||
147 | + .access = PL2_RW, .accessfn = access_el1nvpct, | ||
148 | .writefn = gt_phys_cval_write, .raw_writefn = raw_write }, | ||
149 | { .name = "CNTV_CVAL_EL02", .state = ARM_CP_STATE_AA64, | ||
150 | .opc0 = 3, .opc1 = 5, .crn = 14, .crm = 3, .opc2 = 2, | ||
151 | .type = ARM_CP_IO | ARM_CP_ALIAS, | ||
152 | .nv2_redirect_offset = 0x168 | NV2_REDIR_NO_NV1, | ||
153 | .fieldoffset = offsetof(CPUARMState, cp15.c14_timer[GTIMER_VIRT].cval), | ||
154 | - .access = PL2_RW, .accessfn = e2h_access, | ||
155 | + .access = PL2_RW, .accessfn = access_el1nvvct, | ||
156 | .writefn = gt_virt_cval_write, .raw_writefn = raw_write }, | ||
150 | #endif | 157 | #endif |
151 | } | 158 | }; |
152 | |||
153 | +/** | ||
154 | + * Sync changes made to the memory mapped file back to the backing | ||
155 | + * storage. For POSIX compliant systems this will fallback | ||
156 | + * to regular msync call. Otherwise it will trigger whole file sync | ||
157 | + * (including the metadata case there is no support to skip that otherwise) | ||
158 | + * | ||
159 | + * @addr - start of the memory area to be synced | ||
160 | + * @length - length of the are to be synced | ||
161 | + * @fd - file descriptor for the file to be synced | ||
162 | + * (mandatory only for POSIX non-compliant systems) | ||
163 | + */ | ||
164 | +int qemu_msync(void *addr, size_t length, int fd) | ||
165 | +{ | ||
166 | +#ifdef CONFIG_POSIX | ||
167 | + size_t align_mask = ~(qemu_real_host_page_size - 1); | ||
168 | + | ||
169 | + /** | ||
170 | + * There are no strict reqs as per the length of mapping | ||
171 | + * to be synced. Still the length needs to follow the address | ||
172 | + * alignment changes. Additionally - round the size to the multiple | ||
173 | + * of PAGE_SIZE | ||
174 | + */ | ||
175 | + length += ((uintptr_t)addr & (qemu_real_host_page_size - 1)); | ||
176 | + length = (length + ~align_mask) & align_mask; | ||
177 | + | ||
178 | + addr = (void *)((uintptr_t)addr & align_mask); | ||
179 | + | ||
180 | + return msync(addr, length, MS_SYNC); | ||
181 | +#else /* CONFIG_POSIX */ | ||
182 | + /** | ||
183 | + * Perform the sync based on the file descriptor | ||
184 | + * The sync range will most probably be wider than the one | ||
185 | + * requested - but it will still get the job done | ||
186 | + */ | ||
187 | + return qemu_fdatasync(fd); | ||
188 | +#endif /* CONFIG_POSIX */ | ||
189 | +} | ||
190 | + | ||
191 | #ifndef _WIN32 | ||
192 | /* Sets a specific flag */ | ||
193 | int fcntl_setfl(int fd, int flag) | ||
194 | -- | 159 | -- |
195 | 2.20.1 | 160 | 2.34.1 |
196 | |||
197 | diff view generated by jsdifflib |
1 | From: Beata Michalska <beata.michalska@linaro.org> | 1 | For FEAT_ECV, new registers CNTPCTSS_EL0 and CNTVCTSS_EL0 are |
---|---|---|---|
2 | defined, which are "self-synchronized" views of the physical and | ||
3 | virtual counts as seen in the CNTPCT_EL0 and CNTVCT_EL0 registers | ||
4 | (meaning that no barriers are needed around accesses to them to | ||
5 | ensure that reads of them do not occur speculatively and out-of-order | ||
6 | with other instructions). | ||
2 | 7 | ||
3 | ARMv8.2 introduced support for Data Cache Clean instructions | 8 | For QEMU, all our system registers are self-synchronized, so we can |
4 | to PoP (point-of-persistence) - DC CVAP and PoDP (point-of-deep-persistence) | 9 | simply copy the existing implementation of CNTPCT_EL0 and CNTVCT_EL0 |
5 | - DV CVADP. Both specify conceptual points in a memory system where all writes | 10 | to the new register encodings. |
6 | that are to reach them are considered persistent. | ||
7 | The support provided considers both to be actually the same so there is no | ||
8 | distinction between the two. If none is available (there is no backing store | ||
9 | for given memory) both will result in Data Cache Clean up to the point of | ||
10 | coherency. Otherwise sync for the specified range shall be performed. | ||
11 | 11 | ||
12 | Signed-off-by: Beata Michalska <beata.michalska@linaro.org> | 12 | This means we now implement all the functionality required for |
13 | ID_AA64MMFR0_EL1.ECV == 0b0001. | ||
14 | |||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
14 | Message-id: 20191121000843.24844-5-beata.michalska@linaro.org | 17 | Message-id: 20240301183219.2424889-7-peter.maydell@linaro.org |
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | 18 | --- |
17 | target/arm/cpu.h | 10 ++++++++ | 19 | target/arm/helper.c | 43 +++++++++++++++++++++++++++++++++++++++++++ |
18 | linux-user/elfload.c | 2 ++ | 20 | 1 file changed, 43 insertions(+) |
19 | target/arm/cpu64.c | 1 + | ||
20 | target/arm/helper.c | 56 ++++++++++++++++++++++++++++++++++++++++++++ | ||
21 | 4 files changed, 69 insertions(+) | ||
22 | 21 | ||
23 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/target/arm/cpu.h | ||
26 | +++ b/target/arm/cpu.h | ||
27 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_frint(const ARMISARegisters *id) | ||
28 | return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, FRINTTS) != 0; | ||
29 | } | ||
30 | |||
31 | +static inline bool isar_feature_aa64_dcpop(const ARMISARegisters *id) | ||
32 | +{ | ||
33 | + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, DPB) != 0; | ||
34 | +} | ||
35 | + | ||
36 | +static inline bool isar_feature_aa64_dcpodp(const ARMISARegisters *id) | ||
37 | +{ | ||
38 | + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, DPB) >= 2; | ||
39 | +} | ||
40 | + | ||
41 | static inline bool isar_feature_aa64_fp16(const ARMISARegisters *id) | ||
42 | { | ||
43 | /* We always set the AdvSIMD and FP fields identically wrt FP16. */ | ||
44 | diff --git a/linux-user/elfload.c b/linux-user/elfload.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/linux-user/elfload.c | ||
47 | +++ b/linux-user/elfload.c | ||
48 | @@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap(void) | ||
49 | GET_FEATURE_ID(aa64_jscvt, ARM_HWCAP_A64_JSCVT); | ||
50 | GET_FEATURE_ID(aa64_sb, ARM_HWCAP_A64_SB); | ||
51 | GET_FEATURE_ID(aa64_condm_4, ARM_HWCAP_A64_FLAGM); | ||
52 | + GET_FEATURE_ID(aa64_dcpop, ARM_HWCAP_A64_DCPOP); | ||
53 | |||
54 | return hwcaps; | ||
55 | } | ||
56 | @@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap2(void) | ||
57 | ARMCPU *cpu = ARM_CPU(thread_cpu); | ||
58 | uint32_t hwcaps = 0; | ||
59 | |||
60 | + GET_FEATURE_ID(aa64_dcpodp, ARM_HWCAP2_A64_DCPODP); | ||
61 | GET_FEATURE_ID(aa64_condm_5, ARM_HWCAP2_A64_FLAGM2); | ||
62 | GET_FEATURE_ID(aa64_frint, ARM_HWCAP2_A64_FRINT); | ||
63 | |||
64 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
65 | index XXXXXXX..XXXXXXX 100644 | ||
66 | --- a/target/arm/cpu64.c | ||
67 | +++ b/target/arm/cpu64.c | ||
68 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
69 | cpu->isar.id_aa64isar0 = t; | ||
70 | |||
71 | t = cpu->isar.id_aa64isar1; | ||
72 | + t = FIELD_DP64(t, ID_AA64ISAR1, DPB, 2); | ||
73 | t = FIELD_DP64(t, ID_AA64ISAR1, JSCVT, 1); | ||
74 | t = FIELD_DP64(t, ID_AA64ISAR1, FCMA, 1); | ||
75 | t = FIELD_DP64(t, ID_AA64ISAR1, APA, 1); /* PAuth, architected only */ | ||
76 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 22 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
77 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
78 | --- a/target/arm/helper.c | 24 | --- a/target/arm/helper.c |
79 | +++ b/target/arm/helper.c | 25 | +++ b/target/arm/helper.c |
80 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo rndr_reginfo[] = { | 26 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { |
81 | .access = PL0_R, .readfn = rndr_readfn }, | 27 | }, |
82 | REGINFO_SENTINEL | ||
83 | }; | 28 | }; |
84 | + | 29 | |
85 | +#ifndef CONFIG_USER_ONLY | 30 | +/* |
86 | +static void dccvap_writefn(CPUARMState *env, const ARMCPRegInfo *opaque, | 31 | + * FEAT_ECV adds extra views of CNTVCT_EL0 and CNTPCT_EL0 which |
87 | + uint64_t value) | 32 | + * are "self-synchronizing". For QEMU all sysregs are self-synchronizing, |
88 | +{ | 33 | + * so our implementations here are identical to the normal registers. |
89 | + ARMCPU *cpu = env_archcpu(env); | 34 | + */ |
90 | + /* CTR_EL0 System register -> DminLine, bits [19:16] */ | 35 | +static const ARMCPRegInfo gen_timer_ecv_cp_reginfo[] = { |
91 | + uint64_t dline_size = 4 << ((cpu->ctr >> 16) & 0xF); | 36 | + { .name = "CNTVCTSS", .cp = 15, .crm = 14, .opc1 = 9, |
92 | + uint64_t vaddr_in = (uint64_t) value; | 37 | + .access = PL0_R, .type = ARM_CP_64BIT | ARM_CP_NO_RAW | ARM_CP_IO, |
93 | + uint64_t vaddr = vaddr_in & ~(dline_size - 1); | 38 | + .accessfn = gt_vct_access, |
94 | + void *haddr; | 39 | + .readfn = gt_virt_cnt_read, .resetfn = arm_cp_reset_ignore, |
95 | + int mem_idx = cpu_mmu_index(env, false); | 40 | + }, |
96 | + | 41 | + { .name = "CNTVCTSS_EL0", .state = ARM_CP_STATE_AA64, |
97 | + /* This won't be crossing page boundaries */ | 42 | + .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 0, .opc2 = 6, |
98 | + haddr = probe_read(env, vaddr, dline_size, mem_idx, GETPC()); | 43 | + .access = PL0_R, .type = ARM_CP_NO_RAW | ARM_CP_IO, |
99 | + if (haddr) { | 44 | + .accessfn = gt_vct_access, .readfn = gt_virt_cnt_read, |
100 | + | 45 | + }, |
101 | + ram_addr_t offset; | 46 | + { .name = "CNTPCTSS", .cp = 15, .crm = 14, .opc1 = 8, |
102 | + MemoryRegion *mr; | 47 | + .access = PL0_R, .type = ARM_CP_64BIT | ARM_CP_NO_RAW | ARM_CP_IO, |
103 | + | 48 | + .accessfn = gt_pct_access, |
104 | + /* RCU lock is already being held */ | 49 | + .readfn = gt_cnt_read, .resetfn = arm_cp_reset_ignore, |
105 | + mr = memory_region_from_host(haddr, &offset); | 50 | + }, |
106 | + | 51 | + { .name = "CNTPCTSS_EL0", .state = ARM_CP_STATE_AA64, |
107 | + if (mr) { | 52 | + .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 0, .opc2 = 5, |
108 | + memory_region_do_writeback(mr, offset, dline_size); | 53 | + .access = PL0_R, .type = ARM_CP_NO_RAW | ARM_CP_IO, |
109 | + } | 54 | + .accessfn = gt_pct_access, .readfn = gt_cnt_read, |
110 | + } | 55 | + }, |
111 | +} | ||
112 | + | ||
113 | +static const ARMCPRegInfo dcpop_reg[] = { | ||
114 | + { .name = "DC_CVAP", .state = ARM_CP_STATE_AA64, | ||
115 | + .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 12, .opc2 = 1, | ||
116 | + .access = PL0_W, .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END, | ||
117 | + .accessfn = aa64_cacheop_access, .writefn = dccvap_writefn }, | ||
118 | + REGINFO_SENTINEL | ||
119 | +}; | 56 | +}; |
120 | + | 57 | + |
121 | +static const ARMCPRegInfo dcpodp_reg[] = { | 58 | #else |
122 | + { .name = "DC_CVADP", .state = ARM_CP_STATE_AA64, | 59 | |
123 | + .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 13, .opc2 = 1, | 60 | /* |
124 | + .access = PL0_W, .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END, | 61 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { |
125 | + .accessfn = aa64_cacheop_access, .writefn = dccvap_writefn }, | 62 | }, |
126 | + REGINFO_SENTINEL | 63 | }; |
64 | |||
65 | +/* | ||
66 | + * CNTVCTSS_EL0 has the same trap conditions as CNTVCT_EL0, so it also | ||
67 | + * is exposed to userspace by Linux. | ||
68 | + */ | ||
69 | +static const ARMCPRegInfo gen_timer_ecv_cp_reginfo[] = { | ||
70 | + { .name = "CNTVCTSS_EL0", .state = ARM_CP_STATE_AA64, | ||
71 | + .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 0, .opc2 = 6, | ||
72 | + .access = PL0_R, .type = ARM_CP_NO_RAW | ARM_CP_IO, | ||
73 | + .readfn = gt_virt_cnt_read, | ||
74 | + }, | ||
127 | +}; | 75 | +}; |
128 | +#endif /*CONFIG_USER_ONLY*/ | ||
129 | + | 76 | + |
130 | #endif | 77 | #endif |
131 | 78 | ||
132 | static CPAccessResult access_predinv(CPUARMState *env, const ARMCPRegInfo *ri, | 79 | static void par_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) |
133 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | 80 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
134 | if (cpu_isar_feature(aa64_rndr, cpu)) { | 81 | if (arm_feature(env, ARM_FEATURE_GENERIC_TIMER)) { |
135 | define_arm_cp_regs(cpu, rndr_reginfo); | 82 | define_arm_cp_regs(cpu, generic_timer_cp_reginfo); |
136 | } | 83 | } |
137 | +#ifndef CONFIG_USER_ONLY | 84 | + if (cpu_isar_feature(aa64_ecv_traps, cpu)) { |
138 | + /* Data Cache clean instructions up to PoP */ | 85 | + define_arm_cp_regs(cpu, gen_timer_ecv_cp_reginfo); |
139 | + if (cpu_isar_feature(aa64_dcpop, cpu)) { | ||
140 | + define_one_arm_cp_reg(cpu, dcpop_reg); | ||
141 | + | ||
142 | + if (cpu_isar_feature(aa64_dcpodp, cpu)) { | ||
143 | + define_one_arm_cp_reg(cpu, dcpodp_reg); | ||
144 | + } | ||
145 | + } | 86 | + } |
146 | +#endif /*CONFIG_USER_ONLY*/ | 87 | if (arm_feature(env, ARM_FEATURE_VAPA)) { |
147 | #endif | 88 | ARMCPRegInfo vapa_cp_reginfo[] = { |
148 | 89 | { .name = "PAR", .cp = 15, .crn = 7, .crm = 4, .opc1 = 0, .opc2 = 0, | |
149 | /* | ||
150 | -- | 90 | -- |
151 | 2.20.1 | 91 | 2.34.1 |
152 | |||
153 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | When ID_AA64MMFR0_EL1.ECV is 0b0010, a new register CNTPOFF_EL2 is |
---|---|---|---|
2 | implemented. This is similar to the existing CNTVOFF_EL2, except | ||
3 | that it controls a hypervisor-adjustable offset made to the physical | ||
4 | counter and timer. | ||
2 | 5 | ||
3 | A write to the SCR can change the effective EL by droppping the system | 6 | Implement the handling for this register, which includes control/trap |
4 | from secure to non-secure mode. However if we use a cached current_el | 7 | bits in SCR_EL3 and CNTHCTL_EL2. |
5 | from before the change we'll rebuild the flags incorrectly. To fix | ||
6 | this we introduce the ARM_CP_NEWEL CP flag to indicate the new EL | ||
7 | should be used when recomputing the flags. | ||
8 | 8 | ||
9 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
12 | Message-id: 20191212114734.6962-1-alex.bennee@linaro.org | 11 | Message-id: 20240301183219.2424889-8-peter.maydell@linaro.org |
13 | Cc: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-Id: <20191209143723.6368-1-alex.bennee@linaro.org> | ||
15 | Cc: qemu-stable@nongnu.org | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | --- | 12 | --- |
18 | target/arm/cpu.h | 8 ++++++-- | 13 | target/arm/cpu-features.h | 5 +++ |
19 | target/arm/helper.h | 1 + | 14 | target/arm/cpu.h | 1 + |
20 | target/arm/helper.c | 14 +++++++++++++- | 15 | target/arm/helper.c | 68 +++++++++++++++++++++++++++++++++++++-- |
21 | target/arm/translate.c | 6 +++++- | 16 | target/arm/trace-events | 1 + |
22 | 4 files changed, 25 insertions(+), 4 deletions(-) | 17 | 4 files changed, 73 insertions(+), 2 deletions(-) |
23 | 18 | ||
19 | diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/target/arm/cpu-features.h | ||
22 | +++ b/target/arm/cpu-features.h | ||
23 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_ecv_traps(const ARMISARegisters *id) | ||
24 | return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, ECV) > 0; | ||
25 | } | ||
26 | |||
27 | +static inline bool isar_feature_aa64_ecv(const ARMISARegisters *id) | ||
28 | +{ | ||
29 | + return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, ECV) > 1; | ||
30 | +} | ||
31 | + | ||
32 | static inline bool isar_feature_aa64_vh(const ARMISARegisters *id) | ||
33 | { | ||
34 | return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, VH) != 0; | ||
24 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 35 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
25 | index XXXXXXX..XXXXXXX 100644 | 36 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/target/arm/cpu.h | 37 | --- a/target/arm/cpu.h |
27 | +++ b/target/arm/cpu.h | 38 | +++ b/target/arm/cpu.h |
28 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid) | 39 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
29 | * RAISES_EXC is for when the read or write hook might raise an exception; | 40 | uint64_t c14_cntkctl; /* Timer Control register */ |
30 | * the generated code will synchronize the CPU state before calling the hook | 41 | uint64_t cnthctl_el2; /* Counter/Timer Hyp Control register */ |
31 | * so that it is safe for the hook to call raise_exception(). | 42 | uint64_t cntvoff_el2; /* Counter Virtual Offset register */ |
32 | + * NEWEL is for writes to registers that might change the exception | 43 | + uint64_t cntpoff_el2; /* Counter Physical Offset register */ |
33 | + * level - typically on older ARM chips. For those cases we need to | 44 | ARMGenericTimer c14_timer[NUM_GTIMERS]; |
34 | + * re-read the new el when recomputing the translation flags. | 45 | uint32_t c15_cpar; /* XScale Coprocessor Access Register */ |
35 | */ | 46 | uint32_t c15_ticonfig; /* TI925T configuration byte. */ |
36 | #define ARM_CP_SPECIAL 0x0001 | ||
37 | #define ARM_CP_CONST 0x0002 | ||
38 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid) | ||
39 | #define ARM_CP_SVE 0x2000 | ||
40 | #define ARM_CP_NO_GDB 0x4000 | ||
41 | #define ARM_CP_RAISES_EXC 0x8000 | ||
42 | +#define ARM_CP_NEWEL 0x10000 | ||
43 | /* Used only as a terminator for ARMCPRegInfo lists */ | ||
44 | -#define ARM_CP_SENTINEL 0xffff | ||
45 | +#define ARM_CP_SENTINEL 0xfffff | ||
46 | /* Mask of only the flag bits in a type field */ | ||
47 | -#define ARM_CP_FLAG_MASK 0xf0ff | ||
48 | +#define ARM_CP_FLAG_MASK 0x1f0ff | ||
49 | |||
50 | /* Valid values for ARMCPRegInfo state field, indicating which of | ||
51 | * the AArch32 and AArch64 execution states this register is visible in. | ||
52 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/target/arm/helper.h | ||
55 | +++ b/target/arm/helper.h | ||
56 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(get_user_reg, i32, env, i32) | ||
57 | DEF_HELPER_3(set_user_reg, void, env, i32, i32) | ||
58 | |||
59 | DEF_HELPER_FLAGS_2(rebuild_hflags_m32, TCG_CALL_NO_RWG, void, env, int) | ||
60 | +DEF_HELPER_FLAGS_1(rebuild_hflags_a32_newel, TCG_CALL_NO_RWG, void, env) | ||
61 | DEF_HELPER_FLAGS_2(rebuild_hflags_a32, TCG_CALL_NO_RWG, void, env, int) | ||
62 | DEF_HELPER_FLAGS_2(rebuild_hflags_a64, TCG_CALL_NO_RWG, void, env, int) | ||
63 | |||
64 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 47 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
65 | index XXXXXXX..XXXXXXX 100644 | 48 | index XXXXXXX..XXXXXXX 100644 |
66 | --- a/target/arm/helper.c | 49 | --- a/target/arm/helper.c |
67 | +++ b/target/arm/helper.c | 50 | +++ b/target/arm/helper.c |
68 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_cp_reginfo[] = { | 51 | @@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) |
69 | .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 1, .opc2 = 0, | 52 | if (cpu_isar_feature(aa64_rme, cpu)) { |
70 | .access = PL3_RW, .fieldoffset = offsetof(CPUARMState, cp15.scr_el3), | 53 | valid_mask |= SCR_NSE | SCR_GPF; |
71 | .resetvalue = 0, .writefn = scr_write }, | 54 | } |
72 | - { .name = "SCR", .type = ARM_CP_ALIAS, | 55 | + if (cpu_isar_feature(aa64_ecv, cpu)) { |
73 | + { .name = "SCR", .type = ARM_CP_ALIAS | ARM_CP_NEWEL, | 56 | + valid_mask |= SCR_ECVEN; |
74 | .cp = 15, .opc1 = 0, .crn = 1, .crm = 1, .opc2 = 0, | 57 | + } |
75 | .access = PL1_RW, .accessfn = access_trap_aa32s_el1, | 58 | } else { |
76 | .fieldoffset = offsetoflow32(CPUARMState, cp15.scr_el3), | 59 | valid_mask &= ~(SCR_RW | SCR_ST); |
77 | @@ -XXX,XX +XXX,XX @@ void HELPER(rebuild_hflags_m32)(CPUARMState *env, int el) | 60 | if (cpu_isar_feature(aa32_ras, cpu)) { |
78 | env->hflags = rebuild_hflags_m32(env, fp_el, mmu_idx); | 61 | @@ -XXX,XX +XXX,XX @@ void gt_rme_post_el_change(ARMCPU *cpu, void *ignored) |
62 | gt_update_irq(cpu, GTIMER_PHYS); | ||
79 | } | 63 | } |
80 | 64 | ||
81 | +/* | 65 | +static uint64_t gt_phys_raw_cnt_offset(CPUARMState *env) |
82 | + * If we have triggered a EL state change we can't rely on the | ||
83 | + * translator having passed it too us, we need to recompute. | ||
84 | + */ | ||
85 | +void HELPER(rebuild_hflags_a32_newel)(CPUARMState *env) | ||
86 | +{ | 66 | +{ |
87 | + int el = arm_current_el(env); | 67 | + if ((env->cp15.scr_el3 & SCR_ECVEN) && |
88 | + int fp_el = fp_exception_el(env, el); | 68 | + FIELD_EX64(env->cp15.cnthctl_el2, CNTHCTL, ECV) && |
89 | + ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, el); | 69 | + arm_is_el2_enabled(env) && |
90 | + env->hflags = rebuild_hflags_a32(env, fp_el, mmu_idx); | 70 | + (arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { |
71 | + return env->cp15.cntpoff_el2; | ||
72 | + } | ||
73 | + return 0; | ||
91 | +} | 74 | +} |
92 | + | 75 | + |
93 | void HELPER(rebuild_hflags_a32)(CPUARMState *env, int el) | 76 | +static uint64_t gt_phys_cnt_offset(CPUARMState *env) |
77 | +{ | ||
78 | + if (arm_current_el(env) >= 2) { | ||
79 | + return 0; | ||
80 | + } | ||
81 | + return gt_phys_raw_cnt_offset(env); | ||
82 | +} | ||
83 | + | ||
84 | static void gt_recalc_timer(ARMCPU *cpu, int timeridx) | ||
94 | { | 85 | { |
95 | int fp_el = fp_exception_el(env, el); | 86 | ARMGenericTimer *gt = &cpu->env.cp15.c14_timer[timeridx]; |
96 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 87 | @@ -XXX,XX +XXX,XX @@ static void gt_recalc_timer(ARMCPU *cpu, int timeridx) |
88 | * reset timer to when ISTATUS next has to change | ||
89 | */ | ||
90 | uint64_t offset = timeridx == GTIMER_VIRT ? | ||
91 | - cpu->env.cp15.cntvoff_el2 : 0; | ||
92 | + cpu->env.cp15.cntvoff_el2 : gt_phys_raw_cnt_offset(&cpu->env); | ||
93 | uint64_t count = gt_get_countervalue(&cpu->env); | ||
94 | /* Note that this must be unsigned 64 bit arithmetic: */ | ||
95 | int istatus = count - offset >= gt->cval; | ||
96 | @@ -XXX,XX +XXX,XX @@ static void gt_timer_reset(CPUARMState *env, const ARMCPRegInfo *ri, | ||
97 | |||
98 | static uint64_t gt_cnt_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
99 | { | ||
100 | - return gt_get_countervalue(env); | ||
101 | + return gt_get_countervalue(env) - gt_phys_cnt_offset(env); | ||
102 | } | ||
103 | |||
104 | static uint64_t gt_virt_cnt_offset(CPUARMState *env) | ||
105 | @@ -XXX,XX +XXX,XX @@ static uint64_t gt_tval_read(CPUARMState *env, const ARMCPRegInfo *ri, | ||
106 | case GTIMER_HYPVIRT: | ||
107 | offset = gt_virt_cnt_offset(env); | ||
108 | break; | ||
109 | + case GTIMER_PHYS: | ||
110 | + offset = gt_phys_cnt_offset(env); | ||
111 | + break; | ||
112 | } | ||
113 | |||
114 | return (uint32_t)(env->cp15.c14_timer[timeridx].cval - | ||
115 | @@ -XXX,XX +XXX,XX @@ static void gt_tval_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
116 | case GTIMER_HYPVIRT: | ||
117 | offset = gt_virt_cnt_offset(env); | ||
118 | break; | ||
119 | + case GTIMER_PHYS: | ||
120 | + offset = gt_phys_cnt_offset(env); | ||
121 | + break; | ||
122 | } | ||
123 | |||
124 | trace_arm_gt_tval_write(timeridx, value); | ||
125 | @@ -XXX,XX +XXX,XX @@ static void gt_cnthctl_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
126 | R_CNTHCTL_EL1NVVCT_MASK | | ||
127 | R_CNTHCTL_EVNTIS_MASK; | ||
128 | } | ||
129 | + if (cpu_isar_feature(aa64_ecv, cpu)) { | ||
130 | + valid_mask |= R_CNTHCTL_ECV_MASK; | ||
131 | + } | ||
132 | |||
133 | /* Clear RES0 bits */ | ||
134 | value &= valid_mask; | ||
135 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gen_timer_ecv_cp_reginfo[] = { | ||
136 | }, | ||
137 | }; | ||
138 | |||
139 | +static CPAccessResult gt_cntpoff_access(CPUARMState *env, | ||
140 | + const ARMCPRegInfo *ri, | ||
141 | + bool isread) | ||
142 | +{ | ||
143 | + if (arm_current_el(env) == 2 && !(env->cp15.scr_el3 & SCR_ECVEN)) { | ||
144 | + return CP_ACCESS_TRAP_EL3; | ||
145 | + } | ||
146 | + return CP_ACCESS_OK; | ||
147 | +} | ||
148 | + | ||
149 | +static void gt_cntpoff_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
150 | + uint64_t value) | ||
151 | +{ | ||
152 | + ARMCPU *cpu = env_archcpu(env); | ||
153 | + | ||
154 | + trace_arm_gt_cntpoff_write(value); | ||
155 | + raw_write(env, ri, value); | ||
156 | + gt_recalc_timer(cpu, GTIMER_PHYS); | ||
157 | +} | ||
158 | + | ||
159 | +static const ARMCPRegInfo gen_timer_cntpoff_reginfo = { | ||
160 | + .name = "CNTPOFF_EL2", .state = ARM_CP_STATE_AA64, | ||
161 | + .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 0, .opc2 = 6, | ||
162 | + .access = PL2_RW, .type = ARM_CP_IO, .resetvalue = 0, | ||
163 | + .accessfn = gt_cntpoff_access, .writefn = gt_cntpoff_write, | ||
164 | + .nv2_redirect_offset = 0x1a8, | ||
165 | + .fieldoffset = offsetof(CPUARMState, cp15.cntpoff_el2), | ||
166 | +}; | ||
167 | #else | ||
168 | |||
169 | /* | ||
170 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
171 | if (cpu_isar_feature(aa64_ecv_traps, cpu)) { | ||
172 | define_arm_cp_regs(cpu, gen_timer_ecv_cp_reginfo); | ||
173 | } | ||
174 | +#ifndef CONFIG_USER_ONLY | ||
175 | + if (cpu_isar_feature(aa64_ecv, cpu)) { | ||
176 | + define_one_arm_cp_reg(cpu, &gen_timer_cntpoff_reginfo); | ||
177 | + } | ||
178 | +#endif | ||
179 | if (arm_feature(env, ARM_FEATURE_VAPA)) { | ||
180 | ARMCPRegInfo vapa_cp_reginfo[] = { | ||
181 | { .name = "PAR", .cp = 15, .crn = 7, .crm = 4, .opc1 = 0, .opc2 = 0, | ||
182 | diff --git a/target/arm/trace-events b/target/arm/trace-events | ||
97 | index XXXXXXX..XXXXXXX 100644 | 183 | index XXXXXXX..XXXXXXX 100644 |
98 | --- a/target/arm/translate.c | 184 | --- a/target/arm/trace-events |
99 | +++ b/target/arm/translate.c | 185 | +++ b/target/arm/trace-events |
100 | @@ -XXX,XX +XXX,XX @@ static int disas_coproc_insn(DisasContext *s, uint32_t insn) | 186 | @@ -XXX,XX +XXX,XX @@ arm_gt_tval_write(int timer, uint64_t value) "gt_tval_write: timer %d value 0x%" |
101 | if (arm_dc_feature(s, ARM_FEATURE_M)) { | 187 | arm_gt_ctl_write(int timer, uint64_t value) "gt_ctl_write: timer %d value 0x%" PRIx64 |
102 | gen_helper_rebuild_hflags_m32(cpu_env, tcg_el); | 188 | arm_gt_imask_toggle(int timer) "gt_ctl_write: timer %d IMASK toggle" |
103 | } else { | 189 | arm_gt_cntvoff_write(uint64_t value) "gt_cntvoff_write: value 0x%" PRIx64 |
104 | - gen_helper_rebuild_hflags_a32(cpu_env, tcg_el); | 190 | +arm_gt_cntpoff_write(uint64_t value) "gt_cntpoff_write: value 0x%" PRIx64 |
105 | + if (ri->type & ARM_CP_NEWEL) { | 191 | arm_gt_update_irq(int timer, int irqstate) "gt_update_irq: timer %d irqstate %d" |
106 | + gen_helper_rebuild_hflags_a32_newel(cpu_env); | 192 | |
107 | + } else { | 193 | # kvm.c |
108 | + gen_helper_rebuild_hflags_a32(cpu_env, tcg_el); | ||
109 | + } | ||
110 | } | ||
111 | tcg_temp_free_i32(tcg_el); | ||
112 | /* | ||
113 | -- | 194 | -- |
114 | 2.20.1 | 195 | 2.34.1 |
115 | |||
116 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | Enable all FEAT_ECV features on the 'max' CPU. |
---|---|---|---|
2 | 2 | ||
3 | Make the gic a field in the machine state, and instead of filling | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | an array of qemu_irq and passing it around, directly call | 4 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
5 | qdev_get_gpio_in() on the gic field. | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20240301183219.2424889-9-peter.maydell@linaro.org | ||
7 | --- | ||
8 | docs/system/arm/emulation.rst | 1 + | ||
9 | target/arm/tcg/cpu64.c | 1 + | ||
10 | 2 files changed, 2 insertions(+) | ||
6 | 11 | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 12 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
8 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | ||
9 | Message-id: 20191209090306.20433-1-philmd@redhat.com | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | include/hw/arm/virt.h | 1 + | ||
14 | hw/arm/virt.c | 109 +++++++++++++++++++++--------------------- | ||
15 | 2 files changed, 55 insertions(+), 55 deletions(-) | ||
16 | |||
17 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/hw/arm/virt.h | 14 | --- a/docs/system/arm/emulation.rst |
20 | +++ b/include/hw/arm/virt.h | 15 | +++ b/docs/system/arm/emulation.rst |
21 | @@ -XXX,XX +XXX,XX @@ typedef struct { | 16 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
22 | uint32_t iommu_phandle; | 17 | - FEAT_DotProd (Advanced SIMD dot product instructions) |
23 | int psci_conduit; | 18 | - FEAT_DoubleFault (Double Fault Extension) |
24 | hwaddr highest_gpa; | 19 | - FEAT_E0PD (Preventing EL0 access to halves of address maps) |
25 | + DeviceState *gic; | 20 | +- FEAT_ECV (Enhanced Counter Virtualization) |
26 | DeviceState *acpi_dev; | 21 | - FEAT_EPAC (Enhanced pointer authentication) |
27 | Notifier powerdown_notifier; | 22 | - FEAT_ETS (Enhanced Translation Synchronization) |
28 | } VirtMachineState; | 23 | - FEAT_EVT (Enhanced Virtualization Traps) |
29 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 24 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c |
30 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
31 | --- a/hw/arm/virt.c | 26 | --- a/target/arm/tcg/cpu64.c |
32 | +++ b/hw/arm/virt.c | 27 | +++ b/target/arm/tcg/cpu64.c |
33 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms) | 28 | @@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj) |
34 | } | 29 | t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN64_2, 2); /* 64k stage2 supported */ |
35 | } | 30 | t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN4_2, 2); /* 4k stage2 supported */ |
36 | 31 | t = FIELD_DP64(t, ID_AA64MMFR0, FGT, 1); /* FEAT_FGT */ | |
37 | -static inline DeviceState *create_acpi_ged(VirtMachineState *vms, qemu_irq *pic) | 32 | + t = FIELD_DP64(t, ID_AA64MMFR0, ECV, 2); /* FEAT_ECV */ |
38 | +static inline DeviceState *create_acpi_ged(VirtMachineState *vms) | 33 | cpu->isar.id_aa64mmfr0 = t; |
39 | { | 34 | |
40 | DeviceState *dev; | 35 | t = cpu->isar.id_aa64mmfr1; |
41 | MachineState *ms = MACHINE(vms); | ||
42 | @@ -XXX,XX +XXX,XX @@ static inline DeviceState *create_acpi_ged(VirtMachineState *vms, qemu_irq *pic) | ||
43 | |||
44 | sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, vms->memmap[VIRT_ACPI_GED].base); | ||
45 | sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1, vms->memmap[VIRT_PCDIMM_ACPI].base); | ||
46 | - sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[irq]); | ||
47 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, qdev_get_gpio_in(vms->gic, irq)); | ||
48 | |||
49 | qdev_init_nofail(dev); | ||
50 | |||
51 | return dev; | ||
52 | } | ||
53 | |||
54 | -static void create_its(VirtMachineState *vms, DeviceState *gicdev) | ||
55 | +static void create_its(VirtMachineState *vms) | ||
56 | { | ||
57 | const char *itsclass = its_class_name(); | ||
58 | DeviceState *dev; | ||
59 | @@ -XXX,XX +XXX,XX @@ static void create_its(VirtMachineState *vms, DeviceState *gicdev) | ||
60 | |||
61 | dev = qdev_create(NULL, itsclass); | ||
62 | |||
63 | - object_property_set_link(OBJECT(dev), OBJECT(gicdev), "parent-gicv3", | ||
64 | + object_property_set_link(OBJECT(dev), OBJECT(vms->gic), "parent-gicv3", | ||
65 | &error_abort); | ||
66 | qdev_init_nofail(dev); | ||
67 | sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, vms->memmap[VIRT_GIC_ITS].base); | ||
68 | @@ -XXX,XX +XXX,XX @@ static void create_its(VirtMachineState *vms, DeviceState *gicdev) | ||
69 | fdt_add_its_gic_node(vms); | ||
70 | } | ||
71 | |||
72 | -static void create_v2m(VirtMachineState *vms, qemu_irq *pic) | ||
73 | +static void create_v2m(VirtMachineState *vms) | ||
74 | { | ||
75 | int i; | ||
76 | int irq = vms->irqmap[VIRT_GIC_V2M]; | ||
77 | @@ -XXX,XX +XXX,XX @@ static void create_v2m(VirtMachineState *vms, qemu_irq *pic) | ||
78 | qdev_init_nofail(dev); | ||
79 | |||
80 | for (i = 0; i < NUM_GICV2M_SPIS; i++) { | ||
81 | - sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, pic[irq + i]); | ||
82 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, | ||
83 | + qdev_get_gpio_in(vms->gic, irq + i)); | ||
84 | } | ||
85 | |||
86 | fdt_add_v2m_gic_node(vms); | ||
87 | } | ||
88 | |||
89 | -static void create_gic(VirtMachineState *vms, qemu_irq *pic) | ||
90 | +static void create_gic(VirtMachineState *vms) | ||
91 | { | ||
92 | MachineState *ms = MACHINE(vms); | ||
93 | /* We create a standalone GIC */ | ||
94 | - DeviceState *gicdev; | ||
95 | SysBusDevice *gicbusdev; | ||
96 | const char *gictype; | ||
97 | int type = vms->gic_version, i; | ||
98 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, qemu_irq *pic) | ||
99 | |||
100 | gictype = (type == 3) ? gicv3_class_name() : gic_class_name(); | ||
101 | |||
102 | - gicdev = qdev_create(NULL, gictype); | ||
103 | - qdev_prop_set_uint32(gicdev, "revision", type); | ||
104 | - qdev_prop_set_uint32(gicdev, "num-cpu", smp_cpus); | ||
105 | + vms->gic = qdev_create(NULL, gictype); | ||
106 | + qdev_prop_set_uint32(vms->gic, "revision", type); | ||
107 | + qdev_prop_set_uint32(vms->gic, "num-cpu", smp_cpus); | ||
108 | /* Note that the num-irq property counts both internal and external | ||
109 | * interrupts; there are always 32 of the former (mandated by GIC spec). | ||
110 | */ | ||
111 | - qdev_prop_set_uint32(gicdev, "num-irq", NUM_IRQS + 32); | ||
112 | + qdev_prop_set_uint32(vms->gic, "num-irq", NUM_IRQS + 32); | ||
113 | if (!kvm_irqchip_in_kernel()) { | ||
114 | - qdev_prop_set_bit(gicdev, "has-security-extensions", vms->secure); | ||
115 | + qdev_prop_set_bit(vms->gic, "has-security-extensions", vms->secure); | ||
116 | } | ||
117 | |||
118 | if (type == 3) { | ||
119 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, qemu_irq *pic) | ||
120 | |||
121 | nb_redist_regions = virt_gicv3_redist_region_count(vms); | ||
122 | |||
123 | - qdev_prop_set_uint32(gicdev, "len-redist-region-count", | ||
124 | + qdev_prop_set_uint32(vms->gic, "len-redist-region-count", | ||
125 | nb_redist_regions); | ||
126 | - qdev_prop_set_uint32(gicdev, "redist-region-count[0]", redist0_count); | ||
127 | + qdev_prop_set_uint32(vms->gic, "redist-region-count[0]", redist0_count); | ||
128 | |||
129 | if (nb_redist_regions == 2) { | ||
130 | uint32_t redist1_capacity = | ||
131 | vms->memmap[VIRT_HIGH_GIC_REDIST2].size / GICV3_REDIST_SIZE; | ||
132 | |||
133 | - qdev_prop_set_uint32(gicdev, "redist-region-count[1]", | ||
134 | + qdev_prop_set_uint32(vms->gic, "redist-region-count[1]", | ||
135 | MIN(smp_cpus - redist0_count, redist1_capacity)); | ||
136 | } | ||
137 | } else { | ||
138 | if (!kvm_irqchip_in_kernel()) { | ||
139 | - qdev_prop_set_bit(gicdev, "has-virtualization-extensions", | ||
140 | + qdev_prop_set_bit(vms->gic, "has-virtualization-extensions", | ||
141 | vms->virt); | ||
142 | } | ||
143 | } | ||
144 | - qdev_init_nofail(gicdev); | ||
145 | - gicbusdev = SYS_BUS_DEVICE(gicdev); | ||
146 | + qdev_init_nofail(vms->gic); | ||
147 | + gicbusdev = SYS_BUS_DEVICE(vms->gic); | ||
148 | sysbus_mmio_map(gicbusdev, 0, vms->memmap[VIRT_GIC_DIST].base); | ||
149 | if (type == 3) { | ||
150 | sysbus_mmio_map(gicbusdev, 1, vms->memmap[VIRT_GIC_REDIST].base); | ||
151 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, qemu_irq *pic) | ||
152 | |||
153 | for (irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) { | ||
154 | qdev_connect_gpio_out(cpudev, irq, | ||
155 | - qdev_get_gpio_in(gicdev, | ||
156 | + qdev_get_gpio_in(vms->gic, | ||
157 | ppibase + timer_irq[irq])); | ||
158 | } | ||
159 | |||
160 | if (type == 3) { | ||
161 | - qemu_irq irq = qdev_get_gpio_in(gicdev, | ||
162 | + qemu_irq irq = qdev_get_gpio_in(vms->gic, | ||
163 | ppibase + ARCH_GIC_MAINT_IRQ); | ||
164 | qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interrupt", | ||
165 | 0, irq); | ||
166 | } else if (vms->virt) { | ||
167 | - qemu_irq irq = qdev_get_gpio_in(gicdev, | ||
168 | + qemu_irq irq = qdev_get_gpio_in(vms->gic, | ||
169 | ppibase + ARCH_GIC_MAINT_IRQ); | ||
170 | sysbus_connect_irq(gicbusdev, i + 4 * smp_cpus, irq); | ||
171 | } | ||
172 | |||
173 | qdev_connect_gpio_out_named(cpudev, "pmu-interrupt", 0, | ||
174 | - qdev_get_gpio_in(gicdev, ppibase | ||
175 | + qdev_get_gpio_in(vms->gic, ppibase | ||
176 | + VIRTUAL_PMU_IRQ)); | ||
177 | |||
178 | sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ)); | ||
179 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, qemu_irq *pic) | ||
180 | qdev_get_gpio_in(cpudev, ARM_CPU_VFIQ)); | ||
181 | } | ||
182 | |||
183 | - for (i = 0; i < NUM_IRQS; i++) { | ||
184 | - pic[i] = qdev_get_gpio_in(gicdev, i); | ||
185 | - } | ||
186 | - | ||
187 | fdt_add_gic_node(vms); | ||
188 | |||
189 | if (type == 3 && vms->its) { | ||
190 | - create_its(vms, gicdev); | ||
191 | + create_its(vms); | ||
192 | } else if (type == 2) { | ||
193 | - create_v2m(vms, pic); | ||
194 | + create_v2m(vms); | ||
195 | } | ||
196 | } | ||
197 | |||
198 | -static void create_uart(const VirtMachineState *vms, qemu_irq *pic, int uart, | ||
199 | +static void create_uart(const VirtMachineState *vms, int uart, | ||
200 | MemoryRegion *mem, Chardev *chr) | ||
201 | { | ||
202 | char *nodename; | ||
203 | @@ -XXX,XX +XXX,XX @@ static void create_uart(const VirtMachineState *vms, qemu_irq *pic, int uart, | ||
204 | qdev_init_nofail(dev); | ||
205 | memory_region_add_subregion(mem, base, | ||
206 | sysbus_mmio_get_region(s, 0)); | ||
207 | - sysbus_connect_irq(s, 0, pic[irq]); | ||
208 | + sysbus_connect_irq(s, 0, qdev_get_gpio_in(vms->gic, irq)); | ||
209 | |||
210 | nodename = g_strdup_printf("/pl011@%" PRIx64, base); | ||
211 | qemu_fdt_add_subnode(vms->fdt, nodename); | ||
212 | @@ -XXX,XX +XXX,XX @@ static void create_uart(const VirtMachineState *vms, qemu_irq *pic, int uart, | ||
213 | g_free(nodename); | ||
214 | } | ||
215 | |||
216 | -static void create_rtc(const VirtMachineState *vms, qemu_irq *pic) | ||
217 | +static void create_rtc(const VirtMachineState *vms) | ||
218 | { | ||
219 | char *nodename; | ||
220 | hwaddr base = vms->memmap[VIRT_RTC].base; | ||
221 | @@ -XXX,XX +XXX,XX @@ static void create_rtc(const VirtMachineState *vms, qemu_irq *pic) | ||
222 | int irq = vms->irqmap[VIRT_RTC]; | ||
223 | const char compat[] = "arm,pl031\0arm,primecell"; | ||
224 | |||
225 | - sysbus_create_simple("pl031", base, pic[irq]); | ||
226 | + sysbus_create_simple("pl031", base, qdev_get_gpio_in(vms->gic, irq)); | ||
227 | |||
228 | nodename = g_strdup_printf("/pl031@%" PRIx64, base); | ||
229 | qemu_fdt_add_subnode(vms->fdt, nodename); | ||
230 | @@ -XXX,XX +XXX,XX @@ static void virt_powerdown_req(Notifier *n, void *opaque) | ||
231 | } | ||
232 | } | ||
233 | |||
234 | -static void create_gpio(const VirtMachineState *vms, qemu_irq *pic) | ||
235 | +static void create_gpio(const VirtMachineState *vms) | ||
236 | { | ||
237 | char *nodename; | ||
238 | DeviceState *pl061_dev; | ||
239 | @@ -XXX,XX +XXX,XX @@ static void create_gpio(const VirtMachineState *vms, qemu_irq *pic) | ||
240 | int irq = vms->irqmap[VIRT_GPIO]; | ||
241 | const char compat[] = "arm,pl061\0arm,primecell"; | ||
242 | |||
243 | - pl061_dev = sysbus_create_simple("pl061", base, pic[irq]); | ||
244 | + pl061_dev = sysbus_create_simple("pl061", base, | ||
245 | + qdev_get_gpio_in(vms->gic, irq)); | ||
246 | |||
247 | uint32_t phandle = qemu_fdt_alloc_phandle(vms->fdt); | ||
248 | nodename = g_strdup_printf("/pl061@%" PRIx64, base); | ||
249 | @@ -XXX,XX +XXX,XX @@ static void create_gpio(const VirtMachineState *vms, qemu_irq *pic) | ||
250 | g_free(nodename); | ||
251 | } | ||
252 | |||
253 | -static void create_virtio_devices(const VirtMachineState *vms, qemu_irq *pic) | ||
254 | +static void create_virtio_devices(const VirtMachineState *vms) | ||
255 | { | ||
256 | int i; | ||
257 | hwaddr size = vms->memmap[VIRT_MMIO].size; | ||
258 | @@ -XXX,XX +XXX,XX @@ static void create_virtio_devices(const VirtMachineState *vms, qemu_irq *pic) | ||
259 | int irq = vms->irqmap[VIRT_MMIO] + i; | ||
260 | hwaddr base = vms->memmap[VIRT_MMIO].base + i * size; | ||
261 | |||
262 | - sysbus_create_simple("virtio-mmio", base, pic[irq]); | ||
263 | + sysbus_create_simple("virtio-mmio", base, | ||
264 | + qdev_get_gpio_in(vms->gic, irq)); | ||
265 | } | ||
266 | |||
267 | /* We add dtb nodes in reverse order so that they appear in the finished | ||
268 | @@ -XXX,XX +XXX,XX @@ static void create_pcie_irq_map(const VirtMachineState *vms, | ||
269 | 0x7 /* PCI irq */); | ||
270 | } | ||
271 | |||
272 | -static void create_smmu(const VirtMachineState *vms, qemu_irq *pic, | ||
273 | +static void create_smmu(const VirtMachineState *vms, | ||
274 | PCIBus *bus) | ||
275 | { | ||
276 | char *node; | ||
277 | @@ -XXX,XX +XXX,XX @@ static void create_smmu(const VirtMachineState *vms, qemu_irq *pic, | ||
278 | qdev_init_nofail(dev); | ||
279 | sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); | ||
280 | for (i = 0; i < NUM_SMMU_IRQS; i++) { | ||
281 | - sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, pic[irq + i]); | ||
282 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, | ||
283 | + qdev_get_gpio_in(vms->gic, irq + i)); | ||
284 | } | ||
285 | |||
286 | node = g_strdup_printf("/smmuv3@%" PRIx64, base); | ||
287 | @@ -XXX,XX +XXX,XX @@ static void create_smmu(const VirtMachineState *vms, qemu_irq *pic, | ||
288 | g_free(node); | ||
289 | } | ||
290 | |||
291 | -static void create_pcie(VirtMachineState *vms, qemu_irq *pic) | ||
292 | +static void create_pcie(VirtMachineState *vms) | ||
293 | { | ||
294 | hwaddr base_mmio = vms->memmap[VIRT_PCIE_MMIO].base; | ||
295 | hwaddr size_mmio = vms->memmap[VIRT_PCIE_MMIO].size; | ||
296 | @@ -XXX,XX +XXX,XX @@ static void create_pcie(VirtMachineState *vms, qemu_irq *pic) | ||
297 | sysbus_mmio_map(SYS_BUS_DEVICE(dev), 2, base_pio); | ||
298 | |||
299 | for (i = 0; i < GPEX_NUM_IRQS; i++) { | ||
300 | - sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, pic[irq + i]); | ||
301 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, | ||
302 | + qdev_get_gpio_in(vms->gic, irq + i)); | ||
303 | gpex_set_irq_num(GPEX_HOST(dev), i, irq + i); | ||
304 | } | ||
305 | |||
306 | @@ -XXX,XX +XXX,XX @@ static void create_pcie(VirtMachineState *vms, qemu_irq *pic) | ||
307 | if (vms->iommu) { | ||
308 | vms->iommu_phandle = qemu_fdt_alloc_phandle(vms->fdt); | ||
309 | |||
310 | - create_smmu(vms, pic, pci->bus); | ||
311 | + create_smmu(vms, pci->bus); | ||
312 | |||
313 | qemu_fdt_setprop_cells(vms->fdt, nodename, "iommu-map", | ||
314 | 0x0, vms->iommu_phandle, 0x0, 0x10000); | ||
315 | @@ -XXX,XX +XXX,XX @@ static void create_pcie(VirtMachineState *vms, qemu_irq *pic) | ||
316 | g_free(nodename); | ||
317 | } | ||
318 | |||
319 | -static void create_platform_bus(VirtMachineState *vms, qemu_irq *pic) | ||
320 | +static void create_platform_bus(VirtMachineState *vms) | ||
321 | { | ||
322 | DeviceState *dev; | ||
323 | SysBusDevice *s; | ||
324 | @@ -XXX,XX +XXX,XX @@ static void create_platform_bus(VirtMachineState *vms, qemu_irq *pic) | ||
325 | |||
326 | s = SYS_BUS_DEVICE(dev); | ||
327 | for (i = 0; i < PLATFORM_BUS_NUM_IRQS; i++) { | ||
328 | - int irqn = vms->irqmap[VIRT_PLATFORM_BUS] + i; | ||
329 | - sysbus_connect_irq(s, i, pic[irqn]); | ||
330 | + int irq = vms->irqmap[VIRT_PLATFORM_BUS] + i; | ||
331 | + sysbus_connect_irq(s, i, qdev_get_gpio_in(vms->gic, irq)); | ||
332 | } | ||
333 | |||
334 | memory_region_add_subregion(sysmem, | ||
335 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
336 | VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(machine); | ||
337 | MachineClass *mc = MACHINE_GET_CLASS(machine); | ||
338 | const CPUArchIdList *possible_cpus; | ||
339 | - qemu_irq pic[NUM_IRQS]; | ||
340 | MemoryRegion *sysmem = get_system_memory(); | ||
341 | MemoryRegion *secure_sysmem = NULL; | ||
342 | int n, virt_max_cpus; | ||
343 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
344 | |||
345 | virt_flash_fdt(vms, sysmem, secure_sysmem ?: sysmem); | ||
346 | |||
347 | - create_gic(vms, pic); | ||
348 | + create_gic(vms); | ||
349 | |||
350 | fdt_add_pmu_nodes(vms); | ||
351 | |||
352 | - create_uart(vms, pic, VIRT_UART, sysmem, serial_hd(0)); | ||
353 | + create_uart(vms, VIRT_UART, sysmem, serial_hd(0)); | ||
354 | |||
355 | if (vms->secure) { | ||
356 | create_secure_ram(vms, secure_sysmem); | ||
357 | - create_uart(vms, pic, VIRT_SECURE_UART, secure_sysmem, serial_hd(1)); | ||
358 | + create_uart(vms, VIRT_SECURE_UART, secure_sysmem, serial_hd(1)); | ||
359 | } | ||
360 | |||
361 | vms->highmem_ecam &= vms->highmem && (!firmware_loaded || aarch64); | ||
362 | |||
363 | - create_rtc(vms, pic); | ||
364 | + create_rtc(vms); | ||
365 | |||
366 | - create_pcie(vms, pic); | ||
367 | + create_pcie(vms); | ||
368 | |||
369 | if (has_ged && aarch64 && firmware_loaded && acpi_enabled) { | ||
370 | - vms->acpi_dev = create_acpi_ged(vms, pic); | ||
371 | + vms->acpi_dev = create_acpi_ged(vms); | ||
372 | } else { | ||
373 | - create_gpio(vms, pic); | ||
374 | + create_gpio(vms); | ||
375 | } | ||
376 | |||
377 | /* connect powerdown request */ | ||
378 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
379 | * (which will be automatically plugged in to the transports). If | ||
380 | * no backend is created the transport will just sit harmlessly idle. | ||
381 | */ | ||
382 | - create_virtio_devices(vms, pic); | ||
383 | + create_virtio_devices(vms); | ||
384 | |||
385 | vms->fw_cfg = create_fw_cfg(vms, &address_space_memory); | ||
386 | rom_set_fw(vms->fw_cfg); | ||
387 | |||
388 | - create_platform_bus(vms, pic); | ||
389 | + create_platform_bus(vms); | ||
390 | |||
391 | vms->bootinfo.ram_size = machine->ram_size; | ||
392 | vms->bootinfo.nb_cpus = smp_cpus; | ||
393 | -- | 36 | -- |
394 | 2.20.1 | 37 | 2.34.1 |
395 | 38 | ||
396 | 39 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | From: Inès Varhol <ines.varhol@telecom-paris.fr> |
---|---|---|---|
2 | 2 | ||
3 | The I2C controller of the Aspeed AST2500 and AST2600 SoCs supports DMA | 3 | Features supported : |
4 | transfers to and from DRAM. | 4 | - the 8 STM32L4x5 GPIOs are initialized with their reset values |
5 | (except IDR, see below) | ||
6 | - input mode : setting a pin in input mode "externally" (using input | ||
7 | irqs) results in an out irq (transmitted to SYSCFG) | ||
8 | - output mode : setting a bit in ODR sets the corresponding out irq | ||
9 | (if this line is configured in output mode) | ||
10 | - pull-up, pull-down | ||
11 | - push-pull, open-drain | ||
5 | 12 | ||
6 | A pair of registers defines the buffer address and the length of the | 13 | Difference with the real GPIOs : |
7 | DMA transfer. The address should be aligned on 4 bytes and the maximum | 14 | - Alternate Function and Analog mode aren't implemented : |
8 | length should not exceed 4K. The receive or transmit DMA transfer can | 15 | pins in AF/Analog behave like pins in input mode |
9 | then be initiated with specific bits in the Command/Status register of | 16 | - floating pins stay at their last value |
10 | the controller. | 17 | - register IDR reset values differ from the real one : |
18 | values are coherent with the other registers reset values | ||
19 | and the fact that AF/Analog modes aren't implemented | ||
20 | - setting I/O output speed isn't supported | ||
21 | - locking port bits isn't supported | ||
22 | - ADC function isn't supported | ||
23 | - GPIOH has 16 pins instead of 2 pins | ||
24 | - writing to registers LCKR, AFRL, AFRH and ASCR is ineffective | ||
11 | 25 | ||
12 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 26 | Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> |
13 | Reviewed-by: Joel Stanley <joel@jms.id.au> | 27 | Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> |
14 | Tested-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com> | 28 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
15 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 29 | Acked-by: Alistair Francis <alistair.francis@wdc.com> |
16 | Message-id: 20191119141211.25716-5-clg@kaod.org | 30 | Message-id: 20240305210444.310665-2-ines.varhol@telecom-paris.fr |
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 31 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | --- | 32 | --- |
19 | include/hw/i2c/aspeed_i2c.h | 5 ++ | 33 | MAINTAINERS | 1 + |
20 | hw/arm/aspeed_ast2600.c | 5 ++ | 34 | docs/system/arm/b-l475e-iot01a.rst | 2 +- |
21 | hw/arm/aspeed_soc.c | 5 ++ | 35 | include/hw/gpio/stm32l4x5_gpio.h | 70 +++++ |
22 | hw/i2c/aspeed_i2c.c | 126 +++++++++++++++++++++++++++++++++++- | 36 | hw/gpio/stm32l4x5_gpio.c | 477 +++++++++++++++++++++++++++++ |
23 | 4 files changed, 138 insertions(+), 3 deletions(-) | 37 | hw/gpio/Kconfig | 3 + |
38 | hw/gpio/meson.build | 1 + | ||
39 | hw/gpio/trace-events | 6 + | ||
40 | 7 files changed, 559 insertions(+), 1 deletion(-) | ||
41 | create mode 100644 include/hw/gpio/stm32l4x5_gpio.h | ||
42 | create mode 100644 hw/gpio/stm32l4x5_gpio.c | ||
24 | 43 | ||
25 | diff --git a/include/hw/i2c/aspeed_i2c.h b/include/hw/i2c/aspeed_i2c.h | 44 | diff --git a/MAINTAINERS b/MAINTAINERS |
26 | index XXXXXXX..XXXXXXX 100644 | 45 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/include/hw/i2c/aspeed_i2c.h | 46 | --- a/MAINTAINERS |
28 | +++ b/include/hw/i2c/aspeed_i2c.h | 47 | +++ b/MAINTAINERS |
29 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedI2CBus { | 48 | @@ -XXX,XX +XXX,XX @@ F: hw/arm/stm32l4x5_soc.c |
30 | uint32_t cmd; | 49 | F: hw/misc/stm32l4x5_exti.c |
31 | uint32_t buf; | 50 | F: hw/misc/stm32l4x5_syscfg.c |
32 | uint32_t pool_ctrl; | 51 | F: hw/misc/stm32l4x5_rcc.c |
33 | + uint32_t dma_addr; | 52 | +F: hw/gpio/stm32l4x5_gpio.c |
34 | + uint32_t dma_len; | 53 | F: include/hw/*/stm32l4x5_*.h |
35 | } AspeedI2CBus; | 54 | |
36 | 55 | B-L475E-IOT01A IoT Node | |
37 | typedef struct AspeedI2CState { | 56 | diff --git a/docs/system/arm/b-l475e-iot01a.rst b/docs/system/arm/b-l475e-iot01a.rst |
38 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedI2CState { | ||
39 | uint8_t pool[ASPEED_I2C_MAX_POOL_SIZE]; | ||
40 | |||
41 | AspeedI2CBus busses[ASPEED_I2C_NR_BUSSES]; | ||
42 | + MemoryRegion *dram_mr; | ||
43 | + AddressSpace dram_as; | ||
44 | } AspeedI2CState; | ||
45 | |||
46 | #define ASPEED_I2C_CLASS(klass) \ | ||
47 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedI2CClass { | ||
48 | hwaddr pool_base; | ||
49 | uint8_t *(*bus_pool_base)(AspeedI2CBus *); | ||
50 | bool check_sram; | ||
51 | + bool has_dma; | ||
52 | |||
53 | } AspeedI2CClass; | ||
54 | |||
55 | diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | 57 | index XXXXXXX..XXXXXXX 100644 |
57 | --- a/hw/arm/aspeed_ast2600.c | 58 | --- a/docs/system/arm/b-l475e-iot01a.rst |
58 | +++ b/hw/arm/aspeed_ast2600.c | 59 | +++ b/docs/system/arm/b-l475e-iot01a.rst |
59 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) | 60 | @@ -XXX,XX +XXX,XX @@ Currently B-L475E-IOT01A machine's only supports the following devices: |
60 | } | 61 | - STM32L4x5 EXTI (Extended interrupts and events controller) |
61 | 62 | - STM32L4x5 SYSCFG (System configuration controller) | |
62 | /* I2C */ | 63 | - STM32L4x5 RCC (Reset and clock control) |
63 | + object_property_set_link(OBJECT(&s->i2c), OBJECT(s->dram_mr), "dram", &err); | 64 | +- STM32L4x5 GPIOs (General-purpose I/Os) |
64 | + if (err) { | 65 | |
65 | + error_propagate(errp, err); | 66 | Missing devices |
66 | + return; | 67 | """"""""""""""" |
67 | + } | 68 | @@ -XXX,XX +XXX,XX @@ Missing devices |
68 | object_property_set_bool(OBJECT(&s->i2c), true, "realized", &err); | 69 | The B-L475E-IOT01A does *not* support the following devices: |
69 | if (err) { | 70 | |
70 | error_propagate(errp, err); | 71 | - Serial ports (UART) |
71 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | 72 | -- General-purpose I/Os (GPIO) |
72 | index XXXXXXX..XXXXXXX 100644 | 73 | - Analog to Digital Converter (ADC) |
73 | --- a/hw/arm/aspeed_soc.c | 74 | - SPI controller |
74 | +++ b/hw/arm/aspeed_soc.c | 75 | - Timer controller (TIMER) |
75 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | 76 | diff --git a/include/hw/gpio/stm32l4x5_gpio.h b/include/hw/gpio/stm32l4x5_gpio.h |
76 | } | 77 | new file mode 100644 |
77 | 78 | index XXXXXXX..XXXXXXX | |
78 | /* I2C */ | 79 | --- /dev/null |
79 | + object_property_set_link(OBJECT(&s->i2c), OBJECT(s->dram_mr), "dram", &err); | 80 | +++ b/include/hw/gpio/stm32l4x5_gpio.h |
80 | + if (err) { | ||
81 | + error_propagate(errp, err); | ||
82 | + return; | ||
83 | + } | ||
84 | object_property_set_bool(OBJECT(&s->i2c), true, "realized", &err); | ||
85 | if (err) { | ||
86 | error_propagate(errp, err); | ||
87 | diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c | ||
88 | index XXXXXXX..XXXXXXX 100644 | ||
89 | --- a/hw/i2c/aspeed_i2c.c | ||
90 | +++ b/hw/i2c/aspeed_i2c.c | ||
91 | @@ -XXX,XX +XXX,XX @@ | 81 | @@ -XXX,XX +XXX,XX @@ |
92 | #include "migration/vmstate.h" | 82 | +/* |
93 | #include "qemu/log.h" | 83 | + * STM32L4x5 GPIO (General Purpose Input/Ouput) |
94 | #include "qemu/module.h" | 84 | + * |
95 | +#include "qemu/error-report.h" | 85 | + * Copyright (c) 2024 Arnaud Minier <arnaud.minier@telecom-paris.fr> |
86 | + * Copyright (c) 2024 Inès Varhol <ines.varhol@telecom-paris.fr> | ||
87 | + * | ||
88 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
89 | + * | ||
90 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
91 | + * See the COPYING file in the top-level directory. | ||
92 | + */ | ||
93 | + | ||
94 | +/* | ||
95 | + * The reference used is the STMicroElectronics RM0351 Reference manual | ||
96 | + * for STM32L4x5 and STM32L4x6 advanced Arm ® -based 32-bit MCUs. | ||
97 | + * https://www.st.com/en/microcontrollers-microprocessors/stm32l4x5/documentation.html | ||
98 | + */ | ||
99 | + | ||
100 | +#ifndef HW_STM32L4X5_GPIO_H | ||
101 | +#define HW_STM32L4X5_GPIO_H | ||
102 | + | ||
103 | +#include "hw/sysbus.h" | ||
104 | +#include "qom/object.h" | ||
105 | + | ||
106 | +#define TYPE_STM32L4X5_GPIO "stm32l4x5-gpio" | ||
107 | +OBJECT_DECLARE_SIMPLE_TYPE(Stm32l4x5GpioState, STM32L4X5_GPIO) | ||
108 | + | ||
109 | +#define GPIO_NUM_PINS 16 | ||
110 | + | ||
111 | +struct Stm32l4x5GpioState { | ||
112 | + SysBusDevice parent_obj; | ||
113 | + | ||
114 | + MemoryRegion mmio; | ||
115 | + | ||
116 | + /* GPIO registers */ | ||
117 | + uint32_t moder; | ||
118 | + uint32_t otyper; | ||
119 | + uint32_t ospeedr; | ||
120 | + uint32_t pupdr; | ||
121 | + uint32_t idr; | ||
122 | + uint32_t odr; | ||
123 | + uint32_t lckr; | ||
124 | + uint32_t afrl; | ||
125 | + uint32_t afrh; | ||
126 | + uint32_t ascr; | ||
127 | + | ||
128 | + /* GPIO registers reset values */ | ||
129 | + uint32_t moder_reset; | ||
130 | + uint32_t ospeedr_reset; | ||
131 | + uint32_t pupdr_reset; | ||
132 | + | ||
133 | + /* | ||
134 | + * External driving of pins. | ||
135 | + * The pins can be set externally through the device | ||
136 | + * anonymous input GPIOs lines under certain conditions. | ||
137 | + * The pin must not be in push-pull output mode, | ||
138 | + * and can't be set high in open-drain mode. | ||
139 | + * Pins driven externally and configured to | ||
140 | + * output mode will in general be "disconnected" | ||
141 | + * (see `get_gpio_pinmask_to_disconnect()`) | ||
142 | + */ | ||
143 | + uint16_t disconnected_pins; | ||
144 | + uint16_t pins_connected_high; | ||
145 | + | ||
146 | + char *name; | ||
147 | + Clock *clk; | ||
148 | + qemu_irq pin[GPIO_NUM_PINS]; | ||
149 | +}; | ||
150 | + | ||
151 | +#endif | ||
152 | diff --git a/hw/gpio/stm32l4x5_gpio.c b/hw/gpio/stm32l4x5_gpio.c | ||
153 | new file mode 100644 | ||
154 | index XXXXXXX..XXXXXXX | ||
155 | --- /dev/null | ||
156 | +++ b/hw/gpio/stm32l4x5_gpio.c | ||
157 | @@ -XXX,XX +XXX,XX @@ | ||
158 | +/* | ||
159 | + * STM32L4x5 GPIO (General Purpose Input/Ouput) | ||
160 | + * | ||
161 | + * Copyright (c) 2024 Arnaud Minier <arnaud.minier@telecom-paris.fr> | ||
162 | + * Copyright (c) 2024 Inès Varhol <ines.varhol@telecom-paris.fr> | ||
163 | + * | ||
164 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
165 | + * | ||
166 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
167 | + * See the COPYING file in the top-level directory. | ||
168 | + */ | ||
169 | + | ||
170 | +/* | ||
171 | + * The reference used is the STMicroElectronics RM0351 Reference manual | ||
172 | + * for STM32L4x5 and STM32L4x6 advanced Arm ® -based 32-bit MCUs. | ||
173 | + * https://www.st.com/en/microcontrollers-microprocessors/stm32l4x5/documentation.html | ||
174 | + */ | ||
175 | + | ||
176 | +#include "qemu/osdep.h" | ||
177 | +#include "qemu/log.h" | ||
178 | +#include "hw/gpio/stm32l4x5_gpio.h" | ||
179 | +#include "hw/irq.h" | ||
180 | +#include "hw/qdev-clock.h" | ||
181 | +#include "hw/qdev-properties.h" | ||
182 | +#include "qapi/visitor.h" | ||
96 | +#include "qapi/error.h" | 183 | +#include "qapi/error.h" |
97 | #include "hw/i2c/aspeed_i2c.h" | 184 | +#include "migration/vmstate.h" |
98 | #include "hw/irq.h" | 185 | +#include "trace.h" |
99 | +#include "hw/qdev-properties.h" | 186 | + |
100 | 187 | +#define GPIO_MODER 0x00 | |
101 | /* I2C Global Register */ | 188 | +#define GPIO_OTYPER 0x04 |
102 | 189 | +#define GPIO_OSPEEDR 0x08 | |
103 | @@ -XXX,XX +XXX,XX @@ | 190 | +#define GPIO_PUPDR 0x0C |
104 | #define I2CD_BYTE_BUF_TX_MASK 0xff | 191 | +#define GPIO_IDR 0x10 |
105 | #define I2CD_BYTE_BUF_RX_SHIFT 8 | 192 | +#define GPIO_ODR 0x14 |
106 | #define I2CD_BYTE_BUF_RX_MASK 0xff | 193 | +#define GPIO_BSRR 0x18 |
107 | - | 194 | +#define GPIO_LCKR 0x1C |
108 | +#define I2CD_DMA_ADDR 0x24 /* DMA Buffer Address */ | 195 | +#define GPIO_AFRL 0x20 |
109 | +#define I2CD_DMA_LEN 0x28 /* DMA Transfer Length < 4KB */ | 196 | +#define GPIO_AFRH 0x24 |
110 | 197 | +#define GPIO_BRR 0x28 | |
111 | static inline bool aspeed_i2c_bus_is_master(AspeedI2CBus *bus) | 198 | +#define GPIO_ASCR 0x2C |
112 | { | 199 | + |
113 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_i2c_bus_read(void *opaque, hwaddr offset, | 200 | +/* 0b11111111_11111111_00000000_00000000 */ |
114 | unsigned size) | 201 | +#define RESERVED_BITS_MASK 0xFFFF0000 |
115 | { | 202 | + |
116 | AspeedI2CBus *bus = opaque; | 203 | +static void update_gpio_idr(Stm32l4x5GpioState *s); |
117 | + AspeedI2CClass *aic = ASPEED_I2C_GET_CLASS(bus->controller); | 204 | + |
118 | 205 | +static bool is_pull_up(Stm32l4x5GpioState *s, unsigned pin) | |
119 | switch (offset) { | 206 | +{ |
120 | case I2CD_FUN_CTRL_REG: | 207 | + return extract32(s->pupdr, 2 * pin, 2) == 1; |
121 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_i2c_bus_read(void *opaque, hwaddr offset, | 208 | +} |
122 | return bus->buf; | 209 | + |
123 | case I2CD_CMD_REG: | 210 | +static bool is_pull_down(Stm32l4x5GpioState *s, unsigned pin) |
124 | return bus->cmd | (i2c_bus_busy(bus->bus) << 16); | 211 | +{ |
125 | + case I2CD_DMA_ADDR: | 212 | + return extract32(s->pupdr, 2 * pin, 2) == 2; |
126 | + if (!aic->has_dma) { | 213 | +} |
127 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: No DMA support\n", __func__); | 214 | + |
128 | + return -1; | 215 | +static bool is_output(Stm32l4x5GpioState *s, unsigned pin) |
216 | +{ | ||
217 | + return extract32(s->moder, 2 * pin, 2) == 1; | ||
218 | +} | ||
219 | + | ||
220 | +static bool is_open_drain(Stm32l4x5GpioState *s, unsigned pin) | ||
221 | +{ | ||
222 | + return extract32(s->otyper, pin, 1) == 1; | ||
223 | +} | ||
224 | + | ||
225 | +static bool is_push_pull(Stm32l4x5GpioState *s, unsigned pin) | ||
226 | +{ | ||
227 | + return extract32(s->otyper, pin, 1) == 0; | ||
228 | +} | ||
229 | + | ||
230 | +static void stm32l4x5_gpio_reset_hold(Object *obj) | ||
231 | +{ | ||
232 | + Stm32l4x5GpioState *s = STM32L4X5_GPIO(obj); | ||
233 | + | ||
234 | + s->moder = s->moder_reset; | ||
235 | + s->otyper = 0x00000000; | ||
236 | + s->ospeedr = s->ospeedr_reset; | ||
237 | + s->pupdr = s->pupdr_reset; | ||
238 | + s->idr = 0x00000000; | ||
239 | + s->odr = 0x00000000; | ||
240 | + s->lckr = 0x00000000; | ||
241 | + s->afrl = 0x00000000; | ||
242 | + s->afrh = 0x00000000; | ||
243 | + s->ascr = 0x00000000; | ||
244 | + | ||
245 | + s->disconnected_pins = 0xFFFF; | ||
246 | + s->pins_connected_high = 0x0000; | ||
247 | + update_gpio_idr(s); | ||
248 | +} | ||
249 | + | ||
250 | +static void stm32l4x5_gpio_set(void *opaque, int line, int level) | ||
251 | +{ | ||
252 | + Stm32l4x5GpioState *s = opaque; | ||
253 | + /* | ||
254 | + * The pin isn't set if line is configured in output mode | ||
255 | + * except if level is 0 and the output is open-drain. | ||
256 | + * This way there will be no short-circuit prone situations. | ||
257 | + */ | ||
258 | + if (is_output(s, line) && !(is_open_drain(s, line) && (level == 0))) { | ||
259 | + qemu_log_mask(LOG_GUEST_ERROR, "Line %d can't be driven externally\n", | ||
260 | + line); | ||
261 | + return; | ||
262 | + } | ||
263 | + | ||
264 | + s->disconnected_pins &= ~(1 << line); | ||
265 | + if (level) { | ||
266 | + s->pins_connected_high |= (1 << line); | ||
267 | + } else { | ||
268 | + s->pins_connected_high &= ~(1 << line); | ||
269 | + } | ||
270 | + trace_stm32l4x5_gpio_pins(s->name, s->disconnected_pins, | ||
271 | + s->pins_connected_high); | ||
272 | + update_gpio_idr(s); | ||
273 | +} | ||
274 | + | ||
275 | + | ||
276 | +static void update_gpio_idr(Stm32l4x5GpioState *s) | ||
277 | +{ | ||
278 | + uint32_t new_idr_mask = 0; | ||
279 | + uint32_t new_idr = s->odr; | ||
280 | + uint32_t old_idr = s->idr; | ||
281 | + int new_pin_state, old_pin_state; | ||
282 | + | ||
283 | + for (int i = 0; i < GPIO_NUM_PINS; i++) { | ||
284 | + if (is_output(s, i)) { | ||
285 | + if (is_push_pull(s, i)) { | ||
286 | + new_idr_mask |= (1 << i); | ||
287 | + } else if (!(s->odr & (1 << i))) { | ||
288 | + /* open-drain ODR 0 */ | ||
289 | + new_idr_mask |= (1 << i); | ||
290 | + /* open-drain ODR 1 */ | ||
291 | + } else if (!(s->disconnected_pins & (1 << i)) && | ||
292 | + !(s->pins_connected_high & (1 << i))) { | ||
293 | + /* open-drain ODR 1 with pin connected low */ | ||
294 | + new_idr_mask |= (1 << i); | ||
295 | + new_idr &= ~(1 << i); | ||
296 | + /* open-drain ODR 1 with unactive pin */ | ||
297 | + } else if (is_pull_up(s, i)) { | ||
298 | + new_idr_mask |= (1 << i); | ||
299 | + } else if (is_pull_down(s, i)) { | ||
300 | + new_idr_mask |= (1 << i); | ||
301 | + new_idr &= ~(1 << i); | ||
302 | + } | ||
303 | + /* | ||
304 | + * The only case left is for open-drain ODR 1 | ||
305 | + * with unactive pin without pull-up or pull-down : | ||
306 | + * the value is floating. | ||
307 | + */ | ||
308 | + /* input or analog mode with connected pin */ | ||
309 | + } else if (!(s->disconnected_pins & (1 << i))) { | ||
310 | + if (s->pins_connected_high & (1 << i)) { | ||
311 | + /* pin high */ | ||
312 | + new_idr_mask |= (1 << i); | ||
313 | + new_idr |= (1 << i); | ||
314 | + } else { | ||
315 | + /* pin low */ | ||
316 | + new_idr_mask |= (1 << i); | ||
317 | + new_idr &= ~(1 << i); | ||
318 | + } | ||
319 | + /* input or analog mode with disconnected pin */ | ||
320 | + } else { | ||
321 | + if (is_pull_up(s, i)) { | ||
322 | + /* pull-up */ | ||
323 | + new_idr_mask |= (1 << i); | ||
324 | + new_idr |= (1 << i); | ||
325 | + } else if (is_pull_down(s, i)) { | ||
326 | + /* pull-down */ | ||
327 | + new_idr_mask |= (1 << i); | ||
328 | + new_idr &= ~(1 << i); | ||
329 | + } | ||
330 | + /* | ||
331 | + * The only case left is for a disconnected pin | ||
332 | + * without pull-up or pull-down : | ||
333 | + * the value is floating. | ||
334 | + */ | ||
129 | + } | 335 | + } |
130 | + return bus->dma_addr; | 336 | + } |
131 | + case I2CD_DMA_LEN: | 337 | + |
132 | + if (!aic->has_dma) { | 338 | + s->idr = (old_idr & ~new_idr_mask) | (new_idr & new_idr_mask); |
133 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: No DMA support\n", __func__); | 339 | + trace_stm32l4x5_gpio_update_idr(s->name, old_idr, s->idr); |
134 | + return -1; | 340 | + |
135 | + } | 341 | + for (int i = 0; i < GPIO_NUM_PINS; i++) { |
136 | + return bus->dma_len; | 342 | + if (new_idr_mask & (1 << i)) { |
137 | default: | 343 | + new_pin_state = (new_idr & (1 << i)) > 0; |
138 | qemu_log_mask(LOG_GUEST_ERROR, | 344 | + old_pin_state = (old_idr & (1 << i)) > 0; |
139 | "%s: Bad offset 0x%" HWADDR_PRIx "\n", __func__, offset); | 345 | + if (new_pin_state > old_pin_state) { |
140 | @@ -XXX,XX +XXX,XX @@ static uint8_t aspeed_i2c_get_state(AspeedI2CBus *bus) | 346 | + qemu_irq_raise(s->pin[i]); |
141 | return (bus->cmd >> I2CD_TX_STATE_SHIFT) & I2CD_TX_STATE_MASK; | 347 | + } else if (new_pin_state < old_pin_state) { |
142 | } | 348 | + qemu_irq_lower(s->pin[i]); |
143 | |||
144 | +static int aspeed_i2c_dma_read(AspeedI2CBus *bus, uint8_t *data) | ||
145 | +{ | ||
146 | + MemTxResult result; | ||
147 | + AspeedI2CState *s = bus->controller; | ||
148 | + | ||
149 | + result = address_space_read(&s->dram_as, bus->dma_addr, | ||
150 | + MEMTXATTRS_UNSPECIFIED, data, 1); | ||
151 | + if (result != MEMTX_OK) { | ||
152 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: DRAM read failed @%08x\n", | ||
153 | + __func__, bus->dma_addr); | ||
154 | + return -1; | ||
155 | + } | ||
156 | + | ||
157 | + bus->dma_addr++; | ||
158 | + bus->dma_len--; | ||
159 | + return 0; | ||
160 | +} | ||
161 | + | ||
162 | static int aspeed_i2c_bus_send(AspeedI2CBus *bus, uint8_t pool_start) | ||
163 | { | ||
164 | AspeedI2CClass *aic = ASPEED_I2C_GET_CLASS(bus->controller); | ||
165 | @@ -XXX,XX +XXX,XX @@ static int aspeed_i2c_bus_send(AspeedI2CBus *bus, uint8_t pool_start) | ||
166 | } | ||
167 | } | ||
168 | bus->cmd &= ~I2CD_TX_BUFF_ENABLE; | ||
169 | + } else if (bus->cmd & I2CD_TX_DMA_ENABLE) { | ||
170 | + while (bus->dma_len) { | ||
171 | + uint8_t data; | ||
172 | + aspeed_i2c_dma_read(bus, &data); | ||
173 | + ret = i2c_send(bus->bus, data); | ||
174 | + if (ret) { | ||
175 | + break; | ||
176 | + } | 349 | + } |
177 | + } | 350 | + } |
178 | + bus->cmd &= ~I2CD_TX_DMA_ENABLE; | 351 | + } |
179 | } else { | 352 | +} |
180 | ret = i2c_send(bus->bus, bus->buf); | 353 | + |
181 | } | 354 | +/* |
182 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_recv(AspeedI2CBus *bus) | 355 | + * Return mask of pins that are both configured in output |
183 | bus->pool_ctrl &= ~(0xff << 24); | 356 | + * mode and externally driven (except pins in open-drain |
184 | bus->pool_ctrl |= (i & 0xff) << 24; | 357 | + * mode externally set to 0). |
185 | bus->cmd &= ~I2CD_RX_BUFF_ENABLE; | 358 | + */ |
186 | + } else if (bus->cmd & I2CD_RX_DMA_ENABLE) { | 359 | +static uint32_t get_gpio_pinmask_to_disconnect(Stm32l4x5GpioState *s) |
187 | + uint8_t data; | 360 | +{ |
188 | + | 361 | + uint32_t pins_to_disconnect = 0; |
189 | + while (bus->dma_len) { | 362 | + for (int i = 0; i < GPIO_NUM_PINS; i++) { |
190 | + MemTxResult result; | 363 | + /* for each connected pin in output mode */ |
191 | + | 364 | + if (!(s->disconnected_pins & (1 << i)) && is_output(s, i)) { |
192 | + data = i2c_recv(bus->bus); | 365 | + /* if either push-pull or high level */ |
193 | + result = address_space_write(&s->dram_as, bus->dma_addr, | 366 | + if (is_push_pull(s, i) || s->pins_connected_high & (1 << i)) { |
194 | + MEMTXATTRS_UNSPECIFIED, &data, 1); | 367 | + pins_to_disconnect |= (1 << i); |
195 | + if (result != MEMTX_OK) { | 368 | + qemu_log_mask(LOG_GUEST_ERROR, |
196 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: DRAM write failed @%08x\n", | 369 | + "Line %d can't be driven externally\n", |
197 | + __func__, bus->dma_addr); | 370 | + i); |
198 | + return; | ||
199 | + } | 371 | + } |
200 | + bus->dma_addr++; | ||
201 | + bus->dma_len--; | ||
202 | + } | 372 | + } |
203 | + bus->cmd &= ~I2CD_RX_DMA_ENABLE; | 373 | + } |
204 | } else { | 374 | + return pins_to_disconnect; |
205 | data = i2c_recv(bus->bus); | 375 | +} |
206 | bus->buf = (data & I2CD_BYTE_BUF_RX_MASK) << I2CD_BYTE_BUF_RX_SHIFT; | 376 | + |
207 | @@ -XXX,XX +XXX,XX @@ static uint8_t aspeed_i2c_get_addr(AspeedI2CBus *bus) | 377 | +/* |
208 | uint8_t *pool_base = aic->bus_pool_base(bus); | 378 | + * Set field `disconnected_pins` and call `update_gpio_idr()` |
209 | 379 | + */ | |
210 | return pool_base[0]; | 380 | +static void disconnect_gpio_pins(Stm32l4x5GpioState *s, uint16_t lines) |
211 | + } else if (bus->cmd & I2CD_TX_DMA_ENABLE) { | 381 | +{ |
212 | + uint8_t data; | 382 | + s->disconnected_pins |= lines; |
213 | + | 383 | + trace_stm32l4x5_gpio_pins(s->name, s->disconnected_pins, |
214 | + aspeed_i2c_dma_read(bus, &data); | 384 | + s->pins_connected_high); |
215 | + return data; | 385 | + update_gpio_idr(s); |
216 | } else { | 386 | +} |
217 | return bus->buf; | 387 | + |
218 | } | 388 | +static void disconnected_pins_set(Object *obj, Visitor *v, |
219 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value) | 389 | + const char *name, void *opaque, Error **errp) |
220 | */ | 390 | +{ |
221 | pool_start++; | 391 | + Stm32l4x5GpioState *s = STM32L4X5_GPIO(obj); |
222 | } | 392 | + uint16_t value; |
223 | + } else if (bus->cmd & I2CD_TX_DMA_ENABLE) { | 393 | + if (!visit_type_uint16(v, name, &value, errp)) { |
224 | + if (bus->dma_len == 0) { | 394 | + return; |
225 | + bus->cmd &= ~I2CD_M_TX_CMD; | 395 | + } |
226 | + } | 396 | + disconnect_gpio_pins(s, value); |
227 | } else { | 397 | +} |
228 | bus->cmd &= ~I2CD_M_TX_CMD; | 398 | + |
229 | } | 399 | +static void disconnected_pins_get(Object *obj, Visitor *v, |
230 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_write(void *opaque, hwaddr offset, | 400 | + const char *name, void *opaque, Error **errp) |
231 | break; | 401 | +{ |
232 | } | 402 | + visit_type_uint16(v, name, (uint16_t *)opaque, errp); |
233 | 403 | +} | |
234 | + if (!aic->has_dma && | 404 | + |
235 | + value & (I2CD_RX_DMA_ENABLE | I2CD_TX_DMA_ENABLE)) { | 405 | +static void clock_freq_get(Object *obj, Visitor *v, |
236 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: No DMA support\n", __func__); | 406 | + const char *name, void *opaque, Error **errp) |
237 | + break; | 407 | +{ |
238 | + } | 408 | + Stm32l4x5GpioState *s = STM32L4X5_GPIO(obj); |
239 | + | 409 | + uint32_t clock_freq_hz = clock_get_hz(s->clk); |
240 | aspeed_i2c_bus_handle_cmd(bus, value); | 410 | + visit_type_uint32(v, name, &clock_freq_hz, errp); |
241 | aspeed_i2c_bus_raise_interrupt(bus); | 411 | +} |
242 | break; | 412 | + |
243 | + case I2CD_DMA_ADDR: | 413 | +static void stm32l4x5_gpio_write(void *opaque, hwaddr addr, |
244 | + if (!aic->has_dma) { | 414 | + uint64_t val64, unsigned int size) |
245 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: No DMA support\n", __func__); | 415 | +{ |
246 | + break; | 416 | + Stm32l4x5GpioState *s = opaque; |
247 | + } | 417 | + |
248 | + | 418 | + uint32_t value = val64; |
249 | + bus->dma_addr = value & 0xfffffffc; | 419 | + trace_stm32l4x5_gpio_write(s->name, addr, val64); |
250 | + break; | 420 | + |
251 | + | 421 | + switch (addr) { |
252 | + case I2CD_DMA_LEN: | 422 | + case GPIO_MODER: |
253 | + if (!aic->has_dma) { | 423 | + s->moder = value; |
254 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: No DMA support\n", __func__); | 424 | + disconnect_gpio_pins(s, get_gpio_pinmask_to_disconnect(s)); |
255 | + break; | 425 | + qemu_log_mask(LOG_UNIMP, |
256 | + } | 426 | + "%s: Analog and AF modes aren't supported\n\ |
257 | + | 427 | + Analog and AF mode behave like input mode\n", |
258 | + bus->dma_len = value & 0xfff; | 428 | + __func__); |
259 | + if (!bus->dma_len) { | 429 | + return; |
260 | + qemu_log_mask(LOG_UNIMP, "%s: invalid DMA length\n", __func__); | 430 | + case GPIO_OTYPER: |
261 | + } | 431 | + s->otyper = value & ~RESERVED_BITS_MASK; |
262 | + break; | 432 | + disconnect_gpio_pins(s, get_gpio_pinmask_to_disconnect(s)); |
263 | 433 | + return; | |
264 | default: | 434 | + case GPIO_OSPEEDR: |
265 | qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIx "\n", | 435 | + qemu_log_mask(LOG_UNIMP, |
266 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps aspeed_i2c_pool_ops = { | 436 | + "%s: Changing I/O output speed isn't supported\n\ |
267 | 437 | + I/O speed is already maximal\n", | |
268 | static const VMStateDescription aspeed_i2c_bus_vmstate = { | 438 | + __func__); |
269 | .name = TYPE_ASPEED_I2C, | 439 | + s->ospeedr = value; |
270 | - .version_id = 2, | 440 | + return; |
271 | - .minimum_version_id = 2, | 441 | + case GPIO_PUPDR: |
272 | + .version_id = 3, | 442 | + s->pupdr = value; |
273 | + .minimum_version_id = 3, | 443 | + update_gpio_idr(s); |
274 | .fields = (VMStateField[]) { | 444 | + return; |
275 | VMSTATE_UINT8(id, AspeedI2CBus), | 445 | + case GPIO_IDR: |
276 | VMSTATE_UINT32(ctrl, AspeedI2CBus), | 446 | + qemu_log_mask(LOG_UNIMP, |
277 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription aspeed_i2c_bus_vmstate = { | 447 | + "%s: GPIO->IDR is read-only\n", |
278 | VMSTATE_UINT32(cmd, AspeedI2CBus), | 448 | + __func__); |
279 | VMSTATE_UINT32(buf, AspeedI2CBus), | 449 | + return; |
280 | VMSTATE_UINT32(pool_ctrl, AspeedI2CBus), | 450 | + case GPIO_ODR: |
281 | + VMSTATE_UINT32(dma_addr, AspeedI2CBus), | 451 | + s->odr = value & ~RESERVED_BITS_MASK; |
282 | + VMSTATE_UINT32(dma_len, AspeedI2CBus), | 452 | + update_gpio_idr(s); |
283 | VMSTATE_END_OF_LIST() | 453 | + return; |
284 | } | 454 | + case GPIO_BSRR: { |
285 | }; | 455 | + uint32_t bits_to_reset = (value & RESERVED_BITS_MASK) >> GPIO_NUM_PINS; |
286 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_reset(DeviceState *dev) | 456 | + uint32_t bits_to_set = value & ~RESERVED_BITS_MASK; |
287 | s->busses[i].intr_status = 0; | 457 | + /* If both BSx and BRx are set, BSx has priority.*/ |
288 | s->busses[i].cmd = 0; | 458 | + s->odr &= ~bits_to_reset; |
289 | s->busses[i].buf = 0; | 459 | + s->odr |= bits_to_set; |
290 | + s->busses[i].dma_addr = 0; | 460 | + update_gpio_idr(s); |
291 | + s->busses[i].dma_len = 0; | 461 | + return; |
292 | i2c_end_transfer(s->busses[i].bus); | 462 | + } |
293 | } | 463 | + case GPIO_LCKR: |
294 | } | 464 | + qemu_log_mask(LOG_UNIMP, |
295 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_realize(DeviceState *dev, Error **errp) | 465 | + "%s: Locking port bits configuration isn't supported\n", |
296 | memory_region_init_io(&s->pool_iomem, OBJECT(s), &aspeed_i2c_pool_ops, s, | 466 | + __func__); |
297 | "aspeed.i2c-pool", aic->pool_size); | 467 | + s->lckr = value & ~RESERVED_BITS_MASK; |
298 | memory_region_add_subregion(&s->iomem, aic->pool_base, &s->pool_iomem); | 468 | + return; |
299 | + | 469 | + case GPIO_AFRL: |
300 | + if (aic->has_dma) { | 470 | + qemu_log_mask(LOG_UNIMP, |
301 | + if (!s->dram_mr) { | 471 | + "%s: Alternate functions aren't supported\n", |
302 | + error_setg(errp, TYPE_ASPEED_I2C ": 'dram' link not set"); | 472 | + __func__); |
303 | + return; | 473 | + s->afrl = value; |
304 | + } | 474 | + return; |
305 | + | 475 | + case GPIO_AFRH: |
306 | + address_space_init(&s->dram_as, s->dram_mr, "dma-dram"); | 476 | + qemu_log_mask(LOG_UNIMP, |
307 | + } | 477 | + "%s: Alternate functions aren't supported\n", |
308 | } | 478 | + __func__); |
309 | 479 | + s->afrh = value; | |
310 | +static Property aspeed_i2c_properties[] = { | 480 | + return; |
311 | + DEFINE_PROP_LINK("dram", AspeedI2CState, dram_mr, | 481 | + case GPIO_BRR: { |
312 | + TYPE_MEMORY_REGION, MemoryRegion *), | 482 | + uint32_t bits_to_reset = value & ~RESERVED_BITS_MASK; |
483 | + s->odr &= ~bits_to_reset; | ||
484 | + update_gpio_idr(s); | ||
485 | + return; | ||
486 | + } | ||
487 | + case GPIO_ASCR: | ||
488 | + qemu_log_mask(LOG_UNIMP, | ||
489 | + "%s: ADC function isn't supported\n", | ||
490 | + __func__); | ||
491 | + s->ascr = value & ~RESERVED_BITS_MASK; | ||
492 | + return; | ||
493 | + default: | ||
494 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
495 | + "%s: Bad offset 0x%" HWADDR_PRIx "\n", __func__, addr); | ||
496 | + } | ||
497 | +} | ||
498 | + | ||
499 | +static uint64_t stm32l4x5_gpio_read(void *opaque, hwaddr addr, | ||
500 | + unsigned int size) | ||
501 | +{ | ||
502 | + Stm32l4x5GpioState *s = opaque; | ||
503 | + | ||
504 | + trace_stm32l4x5_gpio_read(s->name, addr); | ||
505 | + | ||
506 | + switch (addr) { | ||
507 | + case GPIO_MODER: | ||
508 | + return s->moder; | ||
509 | + case GPIO_OTYPER: | ||
510 | + return s->otyper; | ||
511 | + case GPIO_OSPEEDR: | ||
512 | + return s->ospeedr; | ||
513 | + case GPIO_PUPDR: | ||
514 | + return s->pupdr; | ||
515 | + case GPIO_IDR: | ||
516 | + return s->idr; | ||
517 | + case GPIO_ODR: | ||
518 | + return s->odr; | ||
519 | + case GPIO_BSRR: | ||
520 | + return 0; | ||
521 | + case GPIO_LCKR: | ||
522 | + return s->lckr; | ||
523 | + case GPIO_AFRL: | ||
524 | + return s->afrl; | ||
525 | + case GPIO_AFRH: | ||
526 | + return s->afrh; | ||
527 | + case GPIO_BRR: | ||
528 | + return 0; | ||
529 | + case GPIO_ASCR: | ||
530 | + return s->ascr; | ||
531 | + default: | ||
532 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
533 | + "%s: Bad offset 0x%" HWADDR_PRIx "\n", __func__, addr); | ||
534 | + return 0; | ||
535 | + } | ||
536 | +} | ||
537 | + | ||
538 | +static const MemoryRegionOps stm32l4x5_gpio_ops = { | ||
539 | + .read = stm32l4x5_gpio_read, | ||
540 | + .write = stm32l4x5_gpio_write, | ||
541 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
542 | + .impl = { | ||
543 | + .min_access_size = 4, | ||
544 | + .max_access_size = 4, | ||
545 | + .unaligned = false, | ||
546 | + }, | ||
547 | + .valid = { | ||
548 | + .min_access_size = 4, | ||
549 | + .max_access_size = 4, | ||
550 | + .unaligned = false, | ||
551 | + }, | ||
552 | +}; | ||
553 | + | ||
554 | +static void stm32l4x5_gpio_init(Object *obj) | ||
555 | +{ | ||
556 | + Stm32l4x5GpioState *s = STM32L4X5_GPIO(obj); | ||
557 | + | ||
558 | + memory_region_init_io(&s->mmio, obj, &stm32l4x5_gpio_ops, s, | ||
559 | + TYPE_STM32L4X5_GPIO, 0x400); | ||
560 | + | ||
561 | + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); | ||
562 | + | ||
563 | + qdev_init_gpio_out(DEVICE(obj), s->pin, GPIO_NUM_PINS); | ||
564 | + qdev_init_gpio_in(DEVICE(obj), stm32l4x5_gpio_set, GPIO_NUM_PINS); | ||
565 | + | ||
566 | + s->clk = qdev_init_clock_in(DEVICE(s), "clk", NULL, s, 0); | ||
567 | + | ||
568 | + object_property_add(obj, "disconnected-pins", "uint16", | ||
569 | + disconnected_pins_get, disconnected_pins_set, | ||
570 | + NULL, &s->disconnected_pins); | ||
571 | + object_property_add(obj, "clock-freq-hz", "uint32", | ||
572 | + clock_freq_get, NULL, NULL, NULL); | ||
573 | +} | ||
574 | + | ||
575 | +static void stm32l4x5_gpio_realize(DeviceState *dev, Error **errp) | ||
576 | +{ | ||
577 | + Stm32l4x5GpioState *s = STM32L4X5_GPIO(dev); | ||
578 | + if (!clock_has_source(s->clk)) { | ||
579 | + error_setg(errp, "GPIO: clk input must be connected"); | ||
580 | + return; | ||
581 | + } | ||
582 | +} | ||
583 | + | ||
584 | +static const VMStateDescription vmstate_stm32l4x5_gpio = { | ||
585 | + .name = TYPE_STM32L4X5_GPIO, | ||
586 | + .version_id = 1, | ||
587 | + .minimum_version_id = 1, | ||
588 | + .fields = (VMStateField[]){ | ||
589 | + VMSTATE_UINT32(moder, Stm32l4x5GpioState), | ||
590 | + VMSTATE_UINT32(otyper, Stm32l4x5GpioState), | ||
591 | + VMSTATE_UINT32(ospeedr, Stm32l4x5GpioState), | ||
592 | + VMSTATE_UINT32(pupdr, Stm32l4x5GpioState), | ||
593 | + VMSTATE_UINT32(idr, Stm32l4x5GpioState), | ||
594 | + VMSTATE_UINT32(odr, Stm32l4x5GpioState), | ||
595 | + VMSTATE_UINT32(lckr, Stm32l4x5GpioState), | ||
596 | + VMSTATE_UINT32(afrl, Stm32l4x5GpioState), | ||
597 | + VMSTATE_UINT32(afrh, Stm32l4x5GpioState), | ||
598 | + VMSTATE_UINT32(ascr, Stm32l4x5GpioState), | ||
599 | + VMSTATE_UINT16(disconnected_pins, Stm32l4x5GpioState), | ||
600 | + VMSTATE_UINT16(pins_connected_high, Stm32l4x5GpioState), | ||
601 | + VMSTATE_END_OF_LIST() | ||
602 | + } | ||
603 | +}; | ||
604 | + | ||
605 | +static Property stm32l4x5_gpio_properties[] = { | ||
606 | + DEFINE_PROP_STRING("name", Stm32l4x5GpioState, name), | ||
607 | + DEFINE_PROP_UINT32("mode-reset", Stm32l4x5GpioState, moder_reset, 0), | ||
608 | + DEFINE_PROP_UINT32("ospeed-reset", Stm32l4x5GpioState, ospeedr_reset, 0), | ||
609 | + DEFINE_PROP_UINT32("pupd-reset", Stm32l4x5GpioState, pupdr_reset, 0), | ||
313 | + DEFINE_PROP_END_OF_LIST(), | 610 | + DEFINE_PROP_END_OF_LIST(), |
314 | +}; | 611 | +}; |
315 | + | 612 | + |
316 | static void aspeed_i2c_class_init(ObjectClass *klass, void *data) | 613 | +static void stm32l4x5_gpio_class_init(ObjectClass *klass, void *data) |
317 | { | 614 | +{ |
318 | DeviceClass *dc = DEVICE_CLASS(klass); | 615 | + DeviceClass *dc = DEVICE_CLASS(klass); |
319 | 616 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | |
320 | dc->vmsd = &aspeed_i2c_vmstate; | 617 | + |
321 | dc->reset = aspeed_i2c_reset; | 618 | + device_class_set_props(dc, stm32l4x5_gpio_properties); |
322 | + dc->props = aspeed_i2c_properties; | 619 | + dc->vmsd = &vmstate_stm32l4x5_gpio; |
323 | dc->realize = aspeed_i2c_realize; | 620 | + dc->realize = stm32l4x5_gpio_realize; |
324 | dc->desc = "Aspeed I2C Controller"; | 621 | + rc->phases.hold = stm32l4x5_gpio_reset_hold; |
325 | } | 622 | +} |
326 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2500_i2c_class_init(ObjectClass *klass, void *data) | 623 | + |
327 | aic->pool_base = 0x200; | 624 | +static const TypeInfo stm32l4x5_gpio_types[] = { |
328 | aic->bus_pool_base = aspeed_2500_i2c_bus_pool_base; | 625 | + { |
329 | aic->check_sram = true; | 626 | + .name = TYPE_STM32L4X5_GPIO, |
330 | + aic->has_dma = true; | 627 | + .parent = TYPE_SYS_BUS_DEVICE, |
331 | } | 628 | + .instance_size = sizeof(Stm32l4x5GpioState), |
332 | 629 | + .instance_init = stm32l4x5_gpio_init, | |
333 | static const TypeInfo aspeed_2500_i2c_info = { | 630 | + .class_init = stm32l4x5_gpio_class_init, |
334 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2600_i2c_class_init(ObjectClass *klass, void *data) | 631 | + }, |
335 | aic->pool_size = 0x200; | 632 | +}; |
336 | aic->pool_base = 0xC00; | 633 | + |
337 | aic->bus_pool_base = aspeed_2600_i2c_bus_pool_base; | 634 | +DEFINE_TYPES(stm32l4x5_gpio_types) |
338 | + aic->has_dma = true; | 635 | diff --git a/hw/gpio/Kconfig b/hw/gpio/Kconfig |
339 | } | 636 | index XXXXXXX..XXXXXXX 100644 |
340 | 637 | --- a/hw/gpio/Kconfig | |
341 | static const TypeInfo aspeed_2600_i2c_info = { | 638 | +++ b/hw/gpio/Kconfig |
639 | @@ -XXX,XX +XXX,XX @@ config GPIO_PWR | ||
640 | |||
641 | config SIFIVE_GPIO | ||
642 | bool | ||
643 | + | ||
644 | +config STM32L4X5_GPIO | ||
645 | + bool | ||
646 | diff --git a/hw/gpio/meson.build b/hw/gpio/meson.build | ||
647 | index XXXXXXX..XXXXXXX 100644 | ||
648 | --- a/hw/gpio/meson.build | ||
649 | +++ b/hw/gpio/meson.build | ||
650 | @@ -XXX,XX +XXX,XX @@ system_ss.add(when: 'CONFIG_RASPI', if_true: files( | ||
651 | 'bcm2835_gpio.c', | ||
652 | 'bcm2838_gpio.c' | ||
653 | )) | ||
654 | +system_ss.add(when: 'CONFIG_STM32L4X5_SOC', if_true: files('stm32l4x5_gpio.c')) | ||
655 | system_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_gpio.c')) | ||
656 | system_ss.add(when: 'CONFIG_SIFIVE_GPIO', if_true: files('sifive_gpio.c')) | ||
657 | diff --git a/hw/gpio/trace-events b/hw/gpio/trace-events | ||
658 | index XXXXXXX..XXXXXXX 100644 | ||
659 | --- a/hw/gpio/trace-events | ||
660 | +++ b/hw/gpio/trace-events | ||
661 | @@ -XXX,XX +XXX,XX @@ sifive_gpio_update_output_irq(int64_t line, int64_t value) "line %" PRIi64 " val | ||
662 | # aspeed_gpio.c | ||
663 | aspeed_gpio_read(uint64_t offset, uint64_t value) "offset: 0x%" PRIx64 " value 0x%" PRIx64 | ||
664 | aspeed_gpio_write(uint64_t offset, uint64_t value) "offset: 0x%" PRIx64 " value 0x%" PRIx64 | ||
665 | + | ||
666 | +# stm32l4x5_gpio.c | ||
667 | +stm32l4x5_gpio_read(char *gpio, uint64_t addr) "GPIO%s addr: 0x%" PRIx64 " " | ||
668 | +stm32l4x5_gpio_write(char *gpio, uint64_t addr, uint64_t data) "GPIO%s addr: 0x%" PRIx64 " val: 0x%" PRIx64 "" | ||
669 | +stm32l4x5_gpio_update_idr(char *gpio, uint32_t old_idr, uint32_t new_idr) "GPIO%s from: 0x%x to: 0x%x" | ||
670 | +stm32l4x5_gpio_pins(char *gpio, uint16_t disconnected, uint16_t high) "GPIO%s disconnected pins: 0x%x levels: 0x%x" | ||
342 | -- | 671 | -- |
343 | 2.20.1 | 672 | 2.34.1 |
344 | 673 | ||
345 | 674 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | From: Inès Varhol <ines.varhol@telecom-paris.fr> |
---|---|---|---|
2 | 2 | ||
3 | The Aspeed Watchdog and Timer models have a link pointing to the SCU | 3 | Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> |
4 | controller model of the machine. | 4 | Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> |
5 | 5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | |
6 | Change the "scu" property definition so that it explicitly sets the | 6 | Acked-by: Alistair Francis <alistair.francis@wdc.com> |
7 | pointer. The property isn't optional : not being able to set the link | 7 | Message-id: 20240305210444.310665-3-ines.varhol@telecom-paris.fr |
8 | is a bug and QEMU should rather abort than exit in this case. | ||
9 | |||
10 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
11 | Reviewed-by: Greg Kurz <groug@kaod.org> | ||
12 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
13 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
14 | Message-id: 20191119141211.25716-17-clg@kaod.org | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 9 | --- |
17 | hw/arm/aspeed_ast2600.c | 8 ++++---- | 10 | include/hw/arm/stm32l4x5_soc.h | 2 + |
18 | hw/arm/aspeed_soc.c | 8 ++++---- | 11 | include/hw/gpio/stm32l4x5_gpio.h | 1 + |
19 | hw/timer/aspeed_timer.c | 17 +++++++++-------- | 12 | include/hw/misc/stm32l4x5_syscfg.h | 3 +- |
20 | hw/watchdog/wdt_aspeed.c | 17 ++++++++--------- | 13 | hw/arm/stm32l4x5_soc.c | 71 +++++++++++++++++++++++------- |
21 | 4 files changed, 25 insertions(+), 25 deletions(-) | 14 | hw/misc/stm32l4x5_syscfg.c | 1 + |
22 | 15 | hw/arm/Kconfig | 3 +- | |
23 | diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c | 16 | 6 files changed, 63 insertions(+), 18 deletions(-) |
24 | index XXXXXXX..XXXXXXX 100644 | 17 | |
25 | --- a/hw/arm/aspeed_ast2600.c | 18 | diff --git a/include/hw/arm/stm32l4x5_soc.h b/include/hw/arm/stm32l4x5_soc.h |
26 | +++ b/hw/arm/aspeed_ast2600.c | 19 | index XXXXXXX..XXXXXXX 100644 |
27 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj) | 20 | --- a/include/hw/arm/stm32l4x5_soc.h |
28 | snprintf(typename, sizeof(typename), "aspeed.timer-%s", socname); | 21 | +++ b/include/hw/arm/stm32l4x5_soc.h |
29 | sysbus_init_child_obj(obj, "timerctrl", OBJECT(&s->timerctrl), | 22 | @@ -XXX,XX +XXX,XX @@ |
30 | sizeof(s->timerctrl), typename); | 23 | #include "hw/misc/stm32l4x5_syscfg.h" |
31 | - object_property_add_const_link(OBJECT(&s->timerctrl), "scu", | 24 | #include "hw/misc/stm32l4x5_exti.h" |
32 | - OBJECT(&s->scu), &error_abort); | 25 | #include "hw/misc/stm32l4x5_rcc.h" |
33 | 26 | +#include "hw/gpio/stm32l4x5_gpio.h" | |
34 | snprintf(typename, sizeof(typename), "aspeed.i2c-%s", socname); | 27 | #include "qom/object.h" |
35 | sysbus_init_child_obj(obj, "i2c", OBJECT(&s->i2c), sizeof(s->i2c), | 28 | |
36 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj) | 29 | #define TYPE_STM32L4X5_SOC "stm32l4x5-soc" |
37 | snprintf(typename, sizeof(typename), "aspeed.wdt-%s", socname); | 30 | @@ -XXX,XX +XXX,XX @@ struct Stm32l4x5SocState { |
38 | sysbus_init_child_obj(obj, "wdt[*]", OBJECT(&s->wdt[i]), | 31 | OrIRQState exti_or_gates[NUM_EXTI_OR_GATES]; |
39 | sizeof(s->wdt[i]), typename); | 32 | Stm32l4x5SyscfgState syscfg; |
40 | - object_property_add_const_link(OBJECT(&s->wdt[i]), "scu", | 33 | Stm32l4x5RccState rcc; |
41 | - OBJECT(&s->scu), &error_abort); | 34 | + Stm32l4x5GpioState gpio[NUM_GPIOS]; |
42 | } | 35 | |
43 | 36 | MemoryRegion sram1; | |
44 | for (i = 0; i < sc->macs_num; i++) { | 37 | MemoryRegion sram2; |
45 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) | 38 | diff --git a/include/hw/gpio/stm32l4x5_gpio.h b/include/hw/gpio/stm32l4x5_gpio.h |
46 | aspeed_soc_get_irq(s, ASPEED_RTC)); | 39 | index XXXXXXX..XXXXXXX 100644 |
47 | 40 | --- a/include/hw/gpio/stm32l4x5_gpio.h | |
48 | /* Timer */ | 41 | +++ b/include/hw/gpio/stm32l4x5_gpio.h |
49 | + object_property_set_link(OBJECT(&s->timerctrl), | 42 | @@ -XXX,XX +XXX,XX @@ |
50 | + OBJECT(&s->scu), "scu", &error_abort); | 43 | #define TYPE_STM32L4X5_GPIO "stm32l4x5-gpio" |
51 | object_property_set_bool(OBJECT(&s->timerctrl), true, "realized", &err); | 44 | OBJECT_DECLARE_SIMPLE_TYPE(Stm32l4x5GpioState, STM32L4X5_GPIO) |
52 | if (err) { | 45 | |
53 | error_propagate(errp, err); | 46 | +#define NUM_GPIOS 8 |
54 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) | 47 | #define GPIO_NUM_PINS 16 |
55 | for (i = 0; i < sc->wdts_num; i++) { | 48 | |
56 | AspeedWDTClass *awc = ASPEED_WDT_GET_CLASS(&s->wdt[i]); | 49 | struct Stm32l4x5GpioState { |
57 | 50 | diff --git a/include/hw/misc/stm32l4x5_syscfg.h b/include/hw/misc/stm32l4x5_syscfg.h | |
58 | + object_property_set_link(OBJECT(&s->wdt[i]), | 51 | index XXXXXXX..XXXXXXX 100644 |
59 | + OBJECT(&s->scu), "scu", &error_abort); | 52 | --- a/include/hw/misc/stm32l4x5_syscfg.h |
60 | object_property_set_bool(OBJECT(&s->wdt[i]), true, "realized", &err); | 53 | +++ b/include/hw/misc/stm32l4x5_syscfg.h |
61 | if (err) { | 54 | @@ -XXX,XX +XXX,XX @@ |
62 | error_propagate(errp, err); | 55 | |
63 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | 56 | #include "hw/sysbus.h" |
64 | index XXXXXXX..XXXXXXX 100644 | 57 | #include "qom/object.h" |
65 | --- a/hw/arm/aspeed_soc.c | 58 | +#include "hw/gpio/stm32l4x5_gpio.h" |
66 | +++ b/hw/arm/aspeed_soc.c | 59 | |
67 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | 60 | #define TYPE_STM32L4X5_SYSCFG "stm32l4x5-syscfg" |
68 | snprintf(typename, sizeof(typename), "aspeed.timer-%s", socname); | 61 | OBJECT_DECLARE_SIMPLE_TYPE(Stm32l4x5SyscfgState, STM32L4X5_SYSCFG) |
69 | sysbus_init_child_obj(obj, "timerctrl", OBJECT(&s->timerctrl), | 62 | |
70 | sizeof(s->timerctrl), typename); | 63 | -#define NUM_GPIOS 8 |
71 | - object_property_add_const_link(OBJECT(&s->timerctrl), "scu", | 64 | -#define GPIO_NUM_PINS 16 |
72 | - OBJECT(&s->scu), &error_abort); | 65 | #define SYSCFG_NUM_EXTICR 4 |
73 | 66 | ||
74 | snprintf(typename, sizeof(typename), "aspeed.i2c-%s", socname); | 67 | struct Stm32l4x5SyscfgState { |
75 | sysbus_init_child_obj(obj, "i2c", OBJECT(&s->i2c), sizeof(s->i2c), | 68 | diff --git a/hw/arm/stm32l4x5_soc.c b/hw/arm/stm32l4x5_soc.c |
76 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | 69 | index XXXXXXX..XXXXXXX 100644 |
77 | snprintf(typename, sizeof(typename), "aspeed.wdt-%s", socname); | 70 | --- a/hw/arm/stm32l4x5_soc.c |
78 | sysbus_init_child_obj(obj, "wdt[*]", OBJECT(&s->wdt[i]), | 71 | +++ b/hw/arm/stm32l4x5_soc.c |
79 | sizeof(s->wdt[i]), typename); | 72 | @@ -XXX,XX +XXX,XX @@ |
80 | - object_property_add_const_link(OBJECT(&s->wdt[i]), "scu", | 73 | #include "sysemu/sysemu.h" |
81 | - OBJECT(&s->scu), &error_abort); | 74 | #include "hw/or-irq.h" |
82 | } | 75 | #include "hw/arm/stm32l4x5_soc.h" |
83 | 76 | +#include "hw/gpio/stm32l4x5_gpio.h" | |
84 | for (i = 0; i < sc->macs_num; i++) { | 77 | #include "hw/qdev-clock.h" |
85 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | 78 | #include "hw/misc/unimp.h" |
86 | aspeed_soc_get_irq(s, ASPEED_RTC)); | 79 | |
87 | 80 | @@ -XXX,XX +XXX,XX @@ static const int exti_or_gate1_lines_in[EXTI_OR_GATE1_NUM_LINES_IN] = { | |
88 | /* Timer */ | 81 | 16, 35, 36, 37, 38, |
89 | + object_property_set_link(OBJECT(&s->timerctrl), | ||
90 | + OBJECT(&s->scu), "scu", &error_abort); | ||
91 | object_property_set_bool(OBJECT(&s->timerctrl), true, "realized", &err); | ||
92 | if (err) { | ||
93 | error_propagate(errp, err); | ||
94 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
95 | for (i = 0; i < sc->wdts_num; i++) { | ||
96 | AspeedWDTClass *awc = ASPEED_WDT_GET_CLASS(&s->wdt[i]); | ||
97 | |||
98 | + object_property_set_link(OBJECT(&s->wdt[i]), | ||
99 | + OBJECT(&s->scu), "scu", &error_abort); | ||
100 | object_property_set_bool(OBJECT(&s->wdt[i]), true, "realized", &err); | ||
101 | if (err) { | ||
102 | error_propagate(errp, err); | ||
103 | diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c | ||
104 | index XXXXXXX..XXXXXXX 100644 | ||
105 | --- a/hw/timer/aspeed_timer.c | ||
106 | +++ b/hw/timer/aspeed_timer.c | ||
107 | @@ -XXX,XX +XXX,XX @@ | ||
108 | #include "qemu/timer.h" | ||
109 | #include "qemu/log.h" | ||
110 | #include "qemu/module.h" | ||
111 | +#include "hw/qdev-properties.h" | ||
112 | #include "trace.h" | ||
113 | |||
114 | #define TIMER_NR_REGS 4 | ||
115 | @@ -XXX,XX +XXX,XX @@ static void aspeed_timer_realize(DeviceState *dev, Error **errp) | ||
116 | int i; | ||
117 | SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
118 | AspeedTimerCtrlState *s = ASPEED_TIMER(dev); | ||
119 | - Object *obj; | ||
120 | - Error *err = NULL; | ||
121 | |||
122 | - obj = object_property_get_link(OBJECT(dev), "scu", &err); | ||
123 | - if (!obj) { | ||
124 | - error_propagate_prepend(errp, err, "required link 'scu' not found: "); | ||
125 | - return; | ||
126 | - } | ||
127 | - s->scu = ASPEED_SCU(obj); | ||
128 | + assert(s->scu); | ||
129 | |||
130 | for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) { | ||
131 | aspeed_init_one_timer(s, i); | ||
132 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_aspeed_timer_state = { | ||
133 | } | ||
134 | }; | 82 | }; |
135 | 83 | ||
136 | +static Property aspeed_timer_properties[] = { | 84 | +static const struct { |
137 | + DEFINE_PROP_LINK("scu", AspeedTimerCtrlState, scu, TYPE_ASPEED_SCU, | 85 | + uint32_t addr; |
138 | + AspeedSCUState *), | 86 | + uint32_t moder_reset; |
139 | + DEFINE_PROP_END_OF_LIST(), | 87 | + uint32_t ospeedr_reset; |
88 | + uint32_t pupdr_reset; | ||
89 | +} stm32l4x5_gpio_cfg[NUM_GPIOS] = { | ||
90 | + { 0x48000000, 0xABFFFFFF, 0x0C000000, 0x64000000 }, | ||
91 | + { 0x48000400, 0xFFFFFEBF, 0x00000000, 0x00000100 }, | ||
92 | + { 0x48000800, 0xFFFFFFFF, 0x00000000, 0x00000000 }, | ||
93 | + { 0x48000C00, 0xFFFFFFFF, 0x00000000, 0x00000000 }, | ||
94 | + { 0x48001000, 0xFFFFFFFF, 0x00000000, 0x00000000 }, | ||
95 | + { 0x48001400, 0xFFFFFFFF, 0x00000000, 0x00000000 }, | ||
96 | + { 0x48001800, 0xFFFFFFFF, 0x00000000, 0x00000000 }, | ||
97 | + { 0x48001C00, 0x0000000F, 0x00000000, 0x00000000 }, | ||
140 | +}; | 98 | +}; |
141 | + | 99 | + |
142 | static void timer_class_init(ObjectClass *klass, void *data) | 100 | static void stm32l4x5_soc_initfn(Object *obj) |
143 | { | 101 | { |
144 | DeviceClass *dc = DEVICE_CLASS(klass); | 102 | Stm32l4x5SocState *s = STM32L4X5_SOC(obj); |
145 | @@ -XXX,XX +XXX,XX @@ static void timer_class_init(ObjectClass *klass, void *data) | 103 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_initfn(Object *obj) |
146 | dc->reset = aspeed_timer_reset; | 104 | } |
147 | dc->desc = "ASPEED Timer"; | 105 | object_initialize_child(obj, "syscfg", &s->syscfg, TYPE_STM32L4X5_SYSCFG); |
148 | dc->vmsd = &vmstate_aspeed_timer_state; | 106 | object_initialize_child(obj, "rcc", &s->rcc, TYPE_STM32L4X5_RCC); |
149 | + dc->props = aspeed_timer_properties; | 107 | + |
108 | + for (unsigned i = 0; i < NUM_GPIOS; i++) { | ||
109 | + g_autofree char *name = g_strdup_printf("gpio%c", 'a' + i); | ||
110 | + object_initialize_child(obj, name, &s->gpio[i], TYPE_STM32L4X5_GPIO); | ||
111 | + } | ||
150 | } | 112 | } |
151 | 113 | ||
152 | static const TypeInfo aspeed_timer_info = { | 114 | static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp) |
153 | diff --git a/hw/watchdog/wdt_aspeed.c b/hw/watchdog/wdt_aspeed.c | 115 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp) |
154 | index XXXXXXX..XXXXXXX 100644 | 116 | Stm32l4x5SocState *s = STM32L4X5_SOC(dev_soc); |
155 | --- a/hw/watchdog/wdt_aspeed.c | 117 | const Stm32l4x5SocClass *sc = STM32L4X5_SOC_GET_CLASS(dev_soc); |
156 | +++ b/hw/watchdog/wdt_aspeed.c | 118 | MemoryRegion *system_memory = get_system_memory(); |
157 | @@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_realize(DeviceState *dev, Error **errp) | 119 | - DeviceState *armv7m; |
158 | { | 120 | + DeviceState *armv7m, *dev; |
159 | SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | 121 | SysBusDevice *busdev; |
160 | AspeedWDTState *s = ASPEED_WDT(dev); | 122 | + uint32_t pin_index; |
161 | - Error *err = NULL; | 123 | |
162 | - Object *obj; | 124 | if (!memory_region_init_rom(&s->flash, OBJECT(dev_soc), "flash", |
163 | 125 | sc->flash_size, errp)) { | |
164 | - obj = object_property_get_link(OBJECT(dev), "scu", &err); | 126 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp) |
165 | - if (!obj) { | 127 | return; |
166 | - error_propagate(errp, err); | 128 | } |
167 | - error_prepend(errp, "required link 'scu' not found: "); | 129 | |
168 | - return; | 130 | + /* GPIOs */ |
169 | - } | 131 | + for (unsigned i = 0; i < NUM_GPIOS; i++) { |
170 | - s->scu = ASPEED_SCU(obj); | 132 | + g_autofree char *name = g_strdup_printf("%c", 'A' + i); |
171 | + assert(s->scu); | 133 | + dev = DEVICE(&s->gpio[i]); |
172 | 134 | + qdev_prop_set_string(dev, "name", name); | |
173 | s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, aspeed_wdt_timer_expired, dev); | 135 | + qdev_prop_set_uint32(dev, "mode-reset", |
174 | 136 | + stm32l4x5_gpio_cfg[i].moder_reset); | |
175 | @@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_realize(DeviceState *dev, Error **errp) | 137 | + qdev_prop_set_uint32(dev, "ospeed-reset", |
176 | sysbus_init_mmio(sbd, &s->iomem); | 138 | + stm32l4x5_gpio_cfg[i].ospeedr_reset); |
177 | } | 139 | + qdev_prop_set_uint32(dev, "pupd-reset", |
178 | 140 | + stm32l4x5_gpio_cfg[i].pupdr_reset); | |
179 | +static Property aspeed_wdt_properties[] = { | 141 | + busdev = SYS_BUS_DEVICE(&s->gpio[i]); |
180 | + DEFINE_PROP_LINK("scu", AspeedWDTState, scu, TYPE_ASPEED_SCU, | 142 | + g_free(name); |
181 | + AspeedSCUState *), | 143 | + name = g_strdup_printf("gpio%c-out", 'a' + i); |
182 | + DEFINE_PROP_END_OF_LIST(), | 144 | + qdev_connect_clock_in(DEVICE(&s->gpio[i]), "clk", |
183 | +}; | 145 | + qdev_get_clock_out(DEVICE(&(s->rcc)), name)); |
184 | + | 146 | + if (!sysbus_realize(busdev, errp)) { |
185 | static void aspeed_wdt_class_init(ObjectClass *klass, void *data) | 147 | + return; |
186 | { | 148 | + } |
187 | DeviceClass *dc = DEVICE_CLASS(klass); | 149 | + sysbus_mmio_map(busdev, 0, stm32l4x5_gpio_cfg[i].addr); |
188 | @@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_class_init(ObjectClass *klass, void *data) | 150 | + } |
189 | dc->reset = aspeed_wdt_reset; | 151 | + |
190 | set_bit(DEVICE_CATEGORY_MISC, dc->categories); | 152 | /* System configuration controller */ |
191 | dc->vmsd = &vmstate_aspeed_wdt; | 153 | busdev = SYS_BUS_DEVICE(&s->syscfg); |
192 | + dc->props = aspeed_wdt_properties; | 154 | if (!sysbus_realize(busdev, errp)) { |
193 | } | 155 | return; |
194 | 156 | } | |
195 | static const TypeInfo aspeed_wdt_info = { | 157 | sysbus_mmio_map(busdev, 0, SYSCFG_ADDR); |
158 | - /* | ||
159 | - * TODO: when the GPIO device is implemented, connect it | ||
160 | - * to SYCFG using `qdev_connect_gpio_out`, NUM_GPIOS and | ||
161 | - * GPIO_NUM_PINS. | ||
162 | - */ | ||
163 | + | ||
164 | + for (unsigned i = 0; i < NUM_GPIOS; i++) { | ||
165 | + for (unsigned j = 0; j < GPIO_NUM_PINS; j++) { | ||
166 | + pin_index = GPIO_NUM_PINS * i + j; | ||
167 | + qdev_connect_gpio_out(DEVICE(&s->gpio[i]), j, | ||
168 | + qdev_get_gpio_in(DEVICE(&s->syscfg), | ||
169 | + pin_index)); | ||
170 | + } | ||
171 | + } | ||
172 | |||
173 | /* EXTI device */ | ||
174 | busdev = SYS_BUS_DEVICE(&s->exti); | ||
175 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp) | ||
176 | } | ||
177 | } | ||
178 | |||
179 | - for (unsigned i = 0; i < 16; i++) { | ||
180 | + for (unsigned i = 0; i < GPIO_NUM_PINS; i++) { | ||
181 | qdev_connect_gpio_out(DEVICE(&s->syscfg), i, | ||
182 | qdev_get_gpio_in(DEVICE(&s->exti), i)); | ||
183 | } | ||
184 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp) | ||
185 | /* RESERVED: 0x40024400, 0x7FDBC00 */ | ||
186 | |||
187 | /* AHB2 BUS */ | ||
188 | - create_unimplemented_device("GPIOA", 0x48000000, 0x400); | ||
189 | - create_unimplemented_device("GPIOB", 0x48000400, 0x400); | ||
190 | - create_unimplemented_device("GPIOC", 0x48000800, 0x400); | ||
191 | - create_unimplemented_device("GPIOD", 0x48000C00, 0x400); | ||
192 | - create_unimplemented_device("GPIOE", 0x48001000, 0x400); | ||
193 | - create_unimplemented_device("GPIOF", 0x48001400, 0x400); | ||
194 | - create_unimplemented_device("GPIOG", 0x48001800, 0x400); | ||
195 | - create_unimplemented_device("GPIOH", 0x48001C00, 0x400); | ||
196 | /* RESERVED: 0x48002000, 0x7FDBC00 */ | ||
197 | create_unimplemented_device("OTG_FS", 0x50000000, 0x40000); | ||
198 | create_unimplemented_device("ADC", 0x50040000, 0x400); | ||
199 | diff --git a/hw/misc/stm32l4x5_syscfg.c b/hw/misc/stm32l4x5_syscfg.c | ||
200 | index XXXXXXX..XXXXXXX 100644 | ||
201 | --- a/hw/misc/stm32l4x5_syscfg.c | ||
202 | +++ b/hw/misc/stm32l4x5_syscfg.c | ||
203 | @@ -XXX,XX +XXX,XX @@ | ||
204 | #include "hw/irq.h" | ||
205 | #include "migration/vmstate.h" | ||
206 | #include "hw/misc/stm32l4x5_syscfg.h" | ||
207 | +#include "hw/gpio/stm32l4x5_gpio.h" | ||
208 | |||
209 | #define SYSCFG_MEMRMP 0x00 | ||
210 | #define SYSCFG_CFGR1 0x04 | ||
211 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | ||
212 | index XXXXXXX..XXXXXXX 100644 | ||
213 | --- a/hw/arm/Kconfig | ||
214 | +++ b/hw/arm/Kconfig | ||
215 | @@ -XXX,XX +XXX,XX @@ config STM32L4X5_SOC | ||
216 | bool | ||
217 | select ARM_V7M | ||
218 | select OR_IRQ | ||
219 | - select STM32L4X5_SYSCFG | ||
220 | select STM32L4X5_EXTI | ||
221 | + select STM32L4X5_SYSCFG | ||
222 | select STM32L4X5_RCC | ||
223 | + select STM32L4X5_GPIO | ||
224 | |||
225 | config XLNX_ZYNQMP_ARM | ||
226 | bool | ||
196 | -- | 227 | -- |
197 | 2.20.1 | 228 | 2.34.1 |
198 | 229 | ||
199 | 230 | diff view generated by jsdifflib |
1 | From: Heyi Guo <guoheyi@huawei.com> | 1 | From: Inès Varhol <ines.varhol@telecom-paris.fr> |
---|---|---|---|
2 | 2 | ||
3 | After the introduction of generic PCIe root port and PCIe-PCI bridge, | 3 | The testcase contains : |
4 | we will also have SHPC controller on ARM, so just enable SHPC native | 4 | - `test_idr_reset_value()` : |
5 | hot plug. | 5 | Checks the reset values of MODER, OTYPER, PUPDR, ODR and IDR. |
6 | - `test_gpio_output_mode()` : | ||
7 | Checks that writing a bit in register ODR results in the corresponding | ||
8 | pin rising or lowering, if this pin is configured in output mode. | ||
9 | - `test_gpio_input_mode()` : | ||
10 | Checks that a input pin set high or low externally results | ||
11 | in the pin rising and lowering. | ||
12 | - `test_pull_up_pull_down()` : | ||
13 | Checks that a floating pin in pull-up/down mode is actually high/down. | ||
14 | - `test_push_pull()` : | ||
15 | Checks that a pin set externally is disconnected when configured in | ||
16 | push-pull output mode, and can't be set externally while in this mode. | ||
17 | - `test_open_drain()` : | ||
18 | Checks that a pin set externally high is disconnected when configured | ||
19 | in open-drain output mode, and can't be set high while in this mode. | ||
20 | - `test_bsrr_brr()` : | ||
21 | Checks that writing to BSRR and BRR has the desired result in ODR. | ||
22 | - `test_clock_enable()` : | ||
23 | Checks that GPIO clock is at the right frequency after enabling it. | ||
6 | 24 | ||
7 | Also update tests/data/acpi/virt/DSDT* to pass "make check". | 25 | Acked-by: Thomas Huth <thuth@redhat.com> |
8 | 26 | Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> | |
9 | Cc: Shannon Zhao <shannon.zhaosl@gmail.com> | 27 | Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> |
10 | Cc: Peter Maydell <peter.maydell@linaro.org> | 28 | Message-id: 20240305210444.310665-4-ines.varhol@telecom-paris.fr |
11 | Cc: "Michael S. Tsirkin" <mst@redhat.com> | ||
12 | Cc: Igor Mammedov <imammedo@redhat.com> | ||
13 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> | ||
14 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
15 | Signed-off-by: Heyi Guo <guoheyi@huawei.com> | ||
16 | Message-id: 20191209063719.23086-3-guoheyi@huawei.com | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 29 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | --- | 30 | --- |
19 | hw/arm/virt-acpi-build.c | 7 ++++++- | 31 | tests/qtest/stm32l4x5_gpio-test.c | 551 ++++++++++++++++++++++++++++++ |
20 | tests/data/acpi/virt/DSDT | Bin 18462 -> 18462 bytes | 32 | tests/qtest/meson.build | 3 +- |
21 | tests/data/acpi/virt/DSDT.memhp | Bin 19799 -> 19799 bytes | 33 | 2 files changed, 553 insertions(+), 1 deletion(-) |
22 | tests/data/acpi/virt/DSDT.numamem | Bin 18462 -> 18462 bytes | 34 | create mode 100644 tests/qtest/stm32l4x5_gpio-test.c |
23 | 4 files changed, 6 insertions(+), 1 deletion(-) | ||
24 | 35 | ||
25 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | 36 | diff --git a/tests/qtest/stm32l4x5_gpio-test.c b/tests/qtest/stm32l4x5_gpio-test.c |
37 | new file mode 100644 | ||
38 | index XXXXXXX..XXXXXXX | ||
39 | --- /dev/null | ||
40 | +++ b/tests/qtest/stm32l4x5_gpio-test.c | ||
41 | @@ -XXX,XX +XXX,XX @@ | ||
42 | +/* | ||
43 | + * QTest testcase for STM32L4x5_GPIO | ||
44 | + * | ||
45 | + * Copyright (c) 2024 Arnaud Minier <arnaud.minier@telecom-paris.fr> | ||
46 | + * Copyright (c) 2024 Inès Varhol <ines.varhol@telecom-paris.fr> | ||
47 | + * | ||
48 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
49 | + * See the COPYING file in the top-level directory. | ||
50 | + */ | ||
51 | + | ||
52 | +#include "qemu/osdep.h" | ||
53 | +#include "libqtest-single.h" | ||
54 | + | ||
55 | +#define GPIO_BASE_ADDR 0x48000000 | ||
56 | +#define GPIO_SIZE 0x400 | ||
57 | +#define NUM_GPIOS 8 | ||
58 | +#define NUM_GPIO_PINS 16 | ||
59 | + | ||
60 | +#define GPIO_A 0x48000000 | ||
61 | +#define GPIO_B 0x48000400 | ||
62 | +#define GPIO_C 0x48000800 | ||
63 | +#define GPIO_D 0x48000C00 | ||
64 | +#define GPIO_E 0x48001000 | ||
65 | +#define GPIO_F 0x48001400 | ||
66 | +#define GPIO_G 0x48001800 | ||
67 | +#define GPIO_H 0x48001C00 | ||
68 | + | ||
69 | +#define MODER 0x00 | ||
70 | +#define OTYPER 0x04 | ||
71 | +#define PUPDR 0x0C | ||
72 | +#define IDR 0x10 | ||
73 | +#define ODR 0x14 | ||
74 | +#define BSRR 0x18 | ||
75 | +#define BRR 0x28 | ||
76 | + | ||
77 | +#define MODER_INPUT 0 | ||
78 | +#define MODER_OUTPUT 1 | ||
79 | + | ||
80 | +#define PUPDR_NONE 0 | ||
81 | +#define PUPDR_PULLUP 1 | ||
82 | +#define PUPDR_PULLDOWN 2 | ||
83 | + | ||
84 | +#define OTYPER_PUSH_PULL 0 | ||
85 | +#define OTYPER_OPEN_DRAIN 1 | ||
86 | + | ||
87 | +const uint32_t moder_reset[NUM_GPIOS] = { | ||
88 | + 0xABFFFFFF, | ||
89 | + 0xFFFFFEBF, | ||
90 | + 0xFFFFFFFF, | ||
91 | + 0xFFFFFFFF, | ||
92 | + 0xFFFFFFFF, | ||
93 | + 0xFFFFFFFF, | ||
94 | + 0xFFFFFFFF, | ||
95 | + 0x0000000F | ||
96 | +}; | ||
97 | + | ||
98 | +const uint32_t pupdr_reset[NUM_GPIOS] = { | ||
99 | + 0x64000000, | ||
100 | + 0x00000100, | ||
101 | + 0x00000000, | ||
102 | + 0x00000000, | ||
103 | + 0x00000000, | ||
104 | + 0x00000000, | ||
105 | + 0x00000000, | ||
106 | + 0x00000000 | ||
107 | +}; | ||
108 | + | ||
109 | +const uint32_t idr_reset[NUM_GPIOS] = { | ||
110 | + 0x0000A000, | ||
111 | + 0x00000010, | ||
112 | + 0x00000000, | ||
113 | + 0x00000000, | ||
114 | + 0x00000000, | ||
115 | + 0x00000000, | ||
116 | + 0x00000000, | ||
117 | + 0x00000000 | ||
118 | +}; | ||
119 | + | ||
120 | +static uint32_t gpio_readl(unsigned int gpio, unsigned int offset) | ||
121 | +{ | ||
122 | + return readl(gpio + offset); | ||
123 | +} | ||
124 | + | ||
125 | +static void gpio_writel(unsigned int gpio, unsigned int offset, uint32_t value) | ||
126 | +{ | ||
127 | + writel(gpio + offset, value); | ||
128 | +} | ||
129 | + | ||
130 | +static void gpio_set_bit(unsigned int gpio, unsigned int reg, | ||
131 | + unsigned int pin, uint32_t value) | ||
132 | +{ | ||
133 | + uint32_t mask = 0xFFFFFFFF & ~(0x1 << pin); | ||
134 | + gpio_writel(gpio, reg, (gpio_readl(gpio, reg) & mask) | value << pin); | ||
135 | +} | ||
136 | + | ||
137 | +static void gpio_set_2bits(unsigned int gpio, unsigned int reg, | ||
138 | + unsigned int pin, uint32_t value) | ||
139 | +{ | ||
140 | + uint32_t offset = 2 * pin; | ||
141 | + uint32_t mask = 0xFFFFFFFF & ~(0x3 << offset); | ||
142 | + gpio_writel(gpio, reg, (gpio_readl(gpio, reg) & mask) | value << offset); | ||
143 | +} | ||
144 | + | ||
145 | +static unsigned int get_gpio_id(uint32_t gpio_addr) | ||
146 | +{ | ||
147 | + return (gpio_addr - GPIO_BASE_ADDR) / GPIO_SIZE; | ||
148 | +} | ||
149 | + | ||
150 | +static void gpio_set_irq(unsigned int gpio, int num, int level) | ||
151 | +{ | ||
152 | + g_autofree char *name = g_strdup_printf("/machine/soc/gpio%c", | ||
153 | + get_gpio_id(gpio) + 'a'); | ||
154 | + qtest_set_irq_in(global_qtest, name, NULL, num, level); | ||
155 | +} | ||
156 | + | ||
157 | +static void disconnect_all_pins(unsigned int gpio) | ||
158 | +{ | ||
159 | + g_autofree char *path = g_strdup_printf("/machine/soc/gpio%c", | ||
160 | + get_gpio_id(gpio) + 'a'); | ||
161 | + QDict *r; | ||
162 | + | ||
163 | + r = qtest_qmp(global_qtest, "{ 'execute': 'qom-set', 'arguments': " | ||
164 | + "{ 'path': %s, 'property': 'disconnected-pins', 'value': %d } }", | ||
165 | + path, 0xFFFF); | ||
166 | + g_assert_false(qdict_haskey(r, "error")); | ||
167 | + qobject_unref(r); | ||
168 | +} | ||
169 | + | ||
170 | +static uint32_t get_disconnected_pins(unsigned int gpio) | ||
171 | +{ | ||
172 | + g_autofree char *path = g_strdup_printf("/machine/soc/gpio%c", | ||
173 | + get_gpio_id(gpio) + 'a'); | ||
174 | + uint32_t disconnected_pins = 0; | ||
175 | + QDict *r; | ||
176 | + | ||
177 | + r = qtest_qmp(global_qtest, "{ 'execute': 'qom-get', 'arguments':" | ||
178 | + " { 'path': %s, 'property': 'disconnected-pins'} }", path); | ||
179 | + g_assert_false(qdict_haskey(r, "error")); | ||
180 | + disconnected_pins = qdict_get_int(r, "return"); | ||
181 | + qobject_unref(r); | ||
182 | + return disconnected_pins; | ||
183 | +} | ||
184 | + | ||
185 | +static uint32_t reset(uint32_t gpio, unsigned int offset) | ||
186 | +{ | ||
187 | + switch (offset) { | ||
188 | + case MODER: | ||
189 | + return moder_reset[get_gpio_id(gpio)]; | ||
190 | + case PUPDR: | ||
191 | + return pupdr_reset[get_gpio_id(gpio)]; | ||
192 | + case IDR: | ||
193 | + return idr_reset[get_gpio_id(gpio)]; | ||
194 | + } | ||
195 | + return 0x0; | ||
196 | +} | ||
197 | + | ||
198 | +static void system_reset(void) | ||
199 | +{ | ||
200 | + QDict *r; | ||
201 | + r = qtest_qmp(global_qtest, "{'execute': 'system_reset'}"); | ||
202 | + g_assert_false(qdict_haskey(r, "error")); | ||
203 | + qobject_unref(r); | ||
204 | +} | ||
205 | + | ||
206 | +static void test_idr_reset_value(void) | ||
207 | +{ | ||
208 | + /* | ||
209 | + * Checks that the values in MODER, OTYPER, PUPDR and ODR | ||
210 | + * after reset are correct, and that the value in IDR is | ||
211 | + * coherent. | ||
212 | + * Since AF and analog modes aren't implemented, IDR reset | ||
213 | + * values aren't the same as with a real board. | ||
214 | + * | ||
215 | + * Register IDR contains the actual values of all GPIO pins. | ||
216 | + * Its value depends on the pins' configuration | ||
217 | + * (intput/output/analog : register MODER, push-pull/open-drain : | ||
218 | + * register OTYPER, pull-up/pull-down/none : register PUPDR) | ||
219 | + * and on the values stored in register ODR | ||
220 | + * (in case the pin is in output mode). | ||
221 | + */ | ||
222 | + | ||
223 | + gpio_writel(GPIO_A, MODER, 0xDEADBEEF); | ||
224 | + gpio_writel(GPIO_A, ODR, 0xDEADBEEF); | ||
225 | + gpio_writel(GPIO_A, OTYPER, 0xDEADBEEF); | ||
226 | + gpio_writel(GPIO_A, PUPDR, 0xDEADBEEF); | ||
227 | + | ||
228 | + gpio_writel(GPIO_B, MODER, 0xDEADBEEF); | ||
229 | + gpio_writel(GPIO_B, ODR, 0xDEADBEEF); | ||
230 | + gpio_writel(GPIO_B, OTYPER, 0xDEADBEEF); | ||
231 | + gpio_writel(GPIO_B, PUPDR, 0xDEADBEEF); | ||
232 | + | ||
233 | + gpio_writel(GPIO_C, MODER, 0xDEADBEEF); | ||
234 | + gpio_writel(GPIO_C, ODR, 0xDEADBEEF); | ||
235 | + gpio_writel(GPIO_C, OTYPER, 0xDEADBEEF); | ||
236 | + gpio_writel(GPIO_C, PUPDR, 0xDEADBEEF); | ||
237 | + | ||
238 | + gpio_writel(GPIO_H, MODER, 0xDEADBEEF); | ||
239 | + gpio_writel(GPIO_H, ODR, 0xDEADBEEF); | ||
240 | + gpio_writel(GPIO_H, OTYPER, 0xDEADBEEF); | ||
241 | + gpio_writel(GPIO_H, PUPDR, 0xDEADBEEF); | ||
242 | + | ||
243 | + system_reset(); | ||
244 | + | ||
245 | + uint32_t moder = gpio_readl(GPIO_A, MODER); | ||
246 | + uint32_t odr = gpio_readl(GPIO_A, ODR); | ||
247 | + uint32_t otyper = gpio_readl(GPIO_A, OTYPER); | ||
248 | + uint32_t pupdr = gpio_readl(GPIO_A, PUPDR); | ||
249 | + uint32_t idr = gpio_readl(GPIO_A, IDR); | ||
250 | + /* 15: AF, 14: AF, 13: AF, 12: Analog ... */ | ||
251 | + /* here AF is the same as Analog and Input mode */ | ||
252 | + g_assert_cmphex(moder, ==, reset(GPIO_A, MODER)); | ||
253 | + g_assert_cmphex(odr, ==, reset(GPIO_A, ODR)); | ||
254 | + g_assert_cmphex(otyper, ==, reset(GPIO_A, OTYPER)); | ||
255 | + /* 15: pull-up, 14: pull-down, 13: pull-up, 12: neither ... */ | ||
256 | + g_assert_cmphex(pupdr, ==, reset(GPIO_A, PUPDR)); | ||
257 | + /* 15 : 1, 14: 0, 13: 1, 12 : reset value ... */ | ||
258 | + g_assert_cmphex(idr, ==, reset(GPIO_A, IDR)); | ||
259 | + | ||
260 | + moder = gpio_readl(GPIO_B, MODER); | ||
261 | + odr = gpio_readl(GPIO_B, ODR); | ||
262 | + otyper = gpio_readl(GPIO_B, OTYPER); | ||
263 | + pupdr = gpio_readl(GPIO_B, PUPDR); | ||
264 | + idr = gpio_readl(GPIO_B, IDR); | ||
265 | + /* ... 5: Analog, 4: AF, 3: AF, 2: Analog ... */ | ||
266 | + /* here AF is the same as Analog and Input mode */ | ||
267 | + g_assert_cmphex(moder, ==, reset(GPIO_B, MODER)); | ||
268 | + g_assert_cmphex(odr, ==, reset(GPIO_B, ODR)); | ||
269 | + g_assert_cmphex(otyper, ==, reset(GPIO_B, OTYPER)); | ||
270 | + /* ... 5: neither, 4: pull-up, 3: neither ... */ | ||
271 | + g_assert_cmphex(pupdr, ==, reset(GPIO_B, PUPDR)); | ||
272 | + /* ... 5 : reset value, 4 : 1, 3 : reset value ... */ | ||
273 | + g_assert_cmphex(idr, ==, reset(GPIO_B, IDR)); | ||
274 | + | ||
275 | + moder = gpio_readl(GPIO_C, MODER); | ||
276 | + odr = gpio_readl(GPIO_C, ODR); | ||
277 | + otyper = gpio_readl(GPIO_C, OTYPER); | ||
278 | + pupdr = gpio_readl(GPIO_C, PUPDR); | ||
279 | + idr = gpio_readl(GPIO_C, IDR); | ||
280 | + /* Analog, same as Input mode*/ | ||
281 | + g_assert_cmphex(moder, ==, reset(GPIO_C, MODER)); | ||
282 | + g_assert_cmphex(odr, ==, reset(GPIO_C, ODR)); | ||
283 | + g_assert_cmphex(otyper, ==, reset(GPIO_C, OTYPER)); | ||
284 | + /* no pull-up or pull-down */ | ||
285 | + g_assert_cmphex(pupdr, ==, reset(GPIO_C, PUPDR)); | ||
286 | + /* reset value */ | ||
287 | + g_assert_cmphex(idr, ==, reset(GPIO_C, IDR)); | ||
288 | + | ||
289 | + moder = gpio_readl(GPIO_H, MODER); | ||
290 | + odr = gpio_readl(GPIO_H, ODR); | ||
291 | + otyper = gpio_readl(GPIO_H, OTYPER); | ||
292 | + pupdr = gpio_readl(GPIO_H, PUPDR); | ||
293 | + idr = gpio_readl(GPIO_H, IDR); | ||
294 | + /* Analog, same as Input mode */ | ||
295 | + g_assert_cmphex(moder, ==, reset(GPIO_H, MODER)); | ||
296 | + g_assert_cmphex(odr, ==, reset(GPIO_H, ODR)); | ||
297 | + g_assert_cmphex(otyper, ==, reset(GPIO_H, OTYPER)); | ||
298 | + /* no pull-up or pull-down */ | ||
299 | + g_assert_cmphex(pupdr, ==, reset(GPIO_H, PUPDR)); | ||
300 | + /* reset value */ | ||
301 | + g_assert_cmphex(idr, ==, reset(GPIO_H, IDR)); | ||
302 | +} | ||
303 | + | ||
304 | +static void test_gpio_output_mode(const void *data) | ||
305 | +{ | ||
306 | + /* | ||
307 | + * Checks that setting a bit in ODR sets the corresponding | ||
308 | + * GPIO line high : it should set the right bit in IDR | ||
309 | + * and send an irq to syscfg. | ||
310 | + * Additionally, it checks that values written to ODR | ||
311 | + * when not in output mode are stored and not discarded. | ||
312 | + */ | ||
313 | + unsigned int pin = ((uint64_t)data) & 0xF; | ||
314 | + uint32_t gpio = ((uint64_t)data) >> 32; | ||
315 | + unsigned int gpio_id = get_gpio_id(gpio); | ||
316 | + | ||
317 | + qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
318 | + | ||
319 | + /* Set a bit in ODR and check nothing happens */ | ||
320 | + gpio_set_bit(gpio, ODR, pin, 1); | ||
321 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR)); | ||
322 | + g_assert_false(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
323 | + | ||
324 | + /* Configure the relevant line as output and check the pin is high */ | ||
325 | + gpio_set_2bits(gpio, MODER, pin, MODER_OUTPUT); | ||
326 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) | (1 << pin)); | ||
327 | + g_assert_true(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
328 | + | ||
329 | + /* Reset the bit in ODR and check the pin is low */ | ||
330 | + gpio_set_bit(gpio, ODR, pin, 0); | ||
331 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
332 | + g_assert_false(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
333 | + | ||
334 | + /* Clean the test */ | ||
335 | + gpio_writel(gpio, ODR, reset(gpio, ODR)); | ||
336 | + gpio_writel(gpio, MODER, reset(gpio, MODER)); | ||
337 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR)); | ||
338 | + g_assert_false(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
339 | +} | ||
340 | + | ||
341 | +static void test_gpio_input_mode(const void *data) | ||
342 | +{ | ||
343 | + /* | ||
344 | + * Test that setting a line high/low externally sets the | ||
345 | + * corresponding GPIO line high/low : it should set the | ||
346 | + * right bit in IDR and send an irq to syscfg. | ||
347 | + */ | ||
348 | + unsigned int pin = ((uint64_t)data) & 0xF; | ||
349 | + uint32_t gpio = ((uint64_t)data) >> 32; | ||
350 | + unsigned int gpio_id = get_gpio_id(gpio); | ||
351 | + | ||
352 | + qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
353 | + | ||
354 | + /* Configure a line as input, raise it, and check that the pin is high */ | ||
355 | + gpio_set_2bits(gpio, MODER, pin, MODER_INPUT); | ||
356 | + gpio_set_irq(gpio, pin, 1); | ||
357 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) | (1 << pin)); | ||
358 | + g_assert_true(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
359 | + | ||
360 | + /* Lower the line and check that the pin is low */ | ||
361 | + gpio_set_irq(gpio, pin, 0); | ||
362 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
363 | + g_assert_false(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
364 | + | ||
365 | + /* Clean the test */ | ||
366 | + gpio_writel(gpio, MODER, reset(gpio, MODER)); | ||
367 | + disconnect_all_pins(gpio); | ||
368 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR)); | ||
369 | +} | ||
370 | + | ||
371 | +static void test_pull_up_pull_down(const void *data) | ||
372 | +{ | ||
373 | + /* | ||
374 | + * Test that a floating pin with pull-up sets the pin | ||
375 | + * high and vice-versa. | ||
376 | + */ | ||
377 | + unsigned int pin = ((uint64_t)data) & 0xF; | ||
378 | + uint32_t gpio = ((uint64_t)data) >> 32; | ||
379 | + unsigned int gpio_id = get_gpio_id(gpio); | ||
380 | + | ||
381 | + qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
382 | + | ||
383 | + /* Configure a line as input with pull-up, check the line is set high */ | ||
384 | + gpio_set_2bits(gpio, MODER, pin, MODER_INPUT); | ||
385 | + gpio_set_2bits(gpio, PUPDR, pin, PUPDR_PULLUP); | ||
386 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) | (1 << pin)); | ||
387 | + g_assert_true(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
388 | + | ||
389 | + /* Configure the line with pull-down, check the line is low */ | ||
390 | + gpio_set_2bits(gpio, PUPDR, pin, PUPDR_PULLDOWN); | ||
391 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
392 | + g_assert_false(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
393 | + | ||
394 | + /* Clean the test */ | ||
395 | + gpio_writel(gpio, MODER, reset(gpio, MODER)); | ||
396 | + gpio_writel(gpio, PUPDR, reset(gpio, PUPDR)); | ||
397 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR)); | ||
398 | +} | ||
399 | + | ||
400 | +static void test_push_pull(const void *data) | ||
401 | +{ | ||
402 | + /* | ||
403 | + * Test that configuring a line in push-pull output mode | ||
404 | + * disconnects the pin, that the pin can't be set or reset | ||
405 | + * externally afterwards. | ||
406 | + */ | ||
407 | + unsigned int pin = ((uint64_t)data) & 0xF; | ||
408 | + uint32_t gpio = ((uint64_t)data) >> 32; | ||
409 | + uint32_t gpio2 = GPIO_BASE_ADDR + (GPIO_H - gpio); | ||
410 | + | ||
411 | + qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
412 | + | ||
413 | + /* Setting a line high externally, configuring it in push-pull output */ | ||
414 | + /* And checking the pin was disconnected */ | ||
415 | + gpio_set_irq(gpio, pin, 1); | ||
416 | + gpio_set_2bits(gpio, MODER, pin, MODER_OUTPUT); | ||
417 | + g_assert_cmphex(get_disconnected_pins(gpio), ==, 0xFFFF); | ||
418 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
419 | + | ||
420 | + /* Setting a line low externally, configuring it in push-pull output */ | ||
421 | + /* And checking the pin was disconnected */ | ||
422 | + gpio_set_irq(gpio2, pin, 0); | ||
423 | + gpio_set_bit(gpio2, ODR, pin, 1); | ||
424 | + gpio_set_2bits(gpio2, MODER, pin, MODER_OUTPUT); | ||
425 | + g_assert_cmphex(get_disconnected_pins(gpio2), ==, 0xFFFF); | ||
426 | + g_assert_cmphex(gpio_readl(gpio2, IDR), ==, reset(gpio2, IDR) | (1 << pin)); | ||
427 | + | ||
428 | + /* Trying to set a push-pull output pin, checking it doesn't work */ | ||
429 | + gpio_set_irq(gpio, pin, 1); | ||
430 | + g_assert_cmphex(get_disconnected_pins(gpio), ==, 0xFFFF); | ||
431 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
432 | + | ||
433 | + /* Trying to reset a push-pull output pin, checking it doesn't work */ | ||
434 | + gpio_set_irq(gpio2, pin, 0); | ||
435 | + g_assert_cmphex(get_disconnected_pins(gpio2), ==, 0xFFFF); | ||
436 | + g_assert_cmphex(gpio_readl(gpio2, IDR), ==, reset(gpio2, IDR) | (1 << pin)); | ||
437 | + | ||
438 | + /* Clean the test */ | ||
439 | + gpio_writel(gpio, MODER, reset(gpio, MODER)); | ||
440 | + gpio_writel(gpio2, ODR, reset(gpio2, ODR)); | ||
441 | + gpio_writel(gpio2, MODER, reset(gpio2, MODER)); | ||
442 | +} | ||
443 | + | ||
444 | +static void test_open_drain(const void *data) | ||
445 | +{ | ||
446 | + /* | ||
447 | + * Test that configuring a line in open-drain output mode | ||
448 | + * disconnects a pin set high externally and that the pin | ||
449 | + * can't be set high externally while configured in open-drain. | ||
450 | + * | ||
451 | + * However a pin set low externally shouldn't be disconnected, | ||
452 | + * and it can be set low externally when in open-drain mode. | ||
453 | + */ | ||
454 | + unsigned int pin = ((uint64_t)data) & 0xF; | ||
455 | + uint32_t gpio = ((uint64_t)data) >> 32; | ||
456 | + uint32_t gpio2 = GPIO_BASE_ADDR + (GPIO_H - gpio); | ||
457 | + | ||
458 | + qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
459 | + | ||
460 | + /* Setting a line high externally, configuring it in open-drain output */ | ||
461 | + /* And checking the pin was disconnected */ | ||
462 | + gpio_set_irq(gpio, pin, 1); | ||
463 | + gpio_set_bit(gpio, OTYPER, pin, OTYPER_OPEN_DRAIN); | ||
464 | + gpio_set_2bits(gpio, MODER, pin, MODER_OUTPUT); | ||
465 | + g_assert_cmphex(get_disconnected_pins(gpio), ==, 0xFFFF); | ||
466 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
467 | + | ||
468 | + /* Setting a line low externally, configuring it in open-drain output */ | ||
469 | + /* And checking the pin wasn't disconnected */ | ||
470 | + gpio_set_irq(gpio2, pin, 0); | ||
471 | + gpio_set_bit(gpio2, ODR, pin, 1); | ||
472 | + gpio_set_bit(gpio2, OTYPER, pin, OTYPER_OPEN_DRAIN); | ||
473 | + gpio_set_2bits(gpio2, MODER, pin, MODER_OUTPUT); | ||
474 | + g_assert_cmphex(get_disconnected_pins(gpio2), ==, 0xFFFF & ~(1 << pin)); | ||
475 | + g_assert_cmphex(gpio_readl(gpio2, IDR), ==, | ||
476 | + reset(gpio2, IDR) & ~(1 << pin)); | ||
477 | + | ||
478 | + /* Trying to set a open-drain output pin, checking it doesn't work */ | ||
479 | + gpio_set_irq(gpio, pin, 1); | ||
480 | + g_assert_cmphex(get_disconnected_pins(gpio), ==, 0xFFFF); | ||
481 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
482 | + | ||
483 | + /* Trying to reset a open-drain output pin, checking it works */ | ||
484 | + gpio_set_bit(gpio, ODR, pin, 1); | ||
485 | + gpio_set_irq(gpio, pin, 0); | ||
486 | + g_assert_cmphex(get_disconnected_pins(gpio2), ==, 0xFFFF & ~(1 << pin)); | ||
487 | + g_assert_cmphex(gpio_readl(gpio2, IDR), ==, | ||
488 | + reset(gpio2, IDR) & ~(1 << pin)); | ||
489 | + | ||
490 | + /* Clean the test */ | ||
491 | + disconnect_all_pins(gpio2); | ||
492 | + gpio_writel(gpio2, OTYPER, reset(gpio2, OTYPER)); | ||
493 | + gpio_writel(gpio2, ODR, reset(gpio2, ODR)); | ||
494 | + gpio_writel(gpio2, MODER, reset(gpio2, MODER)); | ||
495 | + g_assert_cmphex(gpio_readl(gpio2, IDR), ==, reset(gpio2, IDR)); | ||
496 | + disconnect_all_pins(gpio); | ||
497 | + gpio_writel(gpio, OTYPER, reset(gpio, OTYPER)); | ||
498 | + gpio_writel(gpio, ODR, reset(gpio, ODR)); | ||
499 | + gpio_writel(gpio, MODER, reset(gpio, MODER)); | ||
500 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR)); | ||
501 | +} | ||
502 | + | ||
503 | +static void test_bsrr_brr(const void *data) | ||
504 | +{ | ||
505 | + /* | ||
506 | + * Test that writing a '1' in BSS and BSRR | ||
507 | + * has the desired effect on ODR. | ||
508 | + * In BSRR, BSx has priority over BRx. | ||
509 | + */ | ||
510 | + unsigned int pin = ((uint64_t)data) & 0xF; | ||
511 | + uint32_t gpio = ((uint64_t)data) >> 32; | ||
512 | + | ||
513 | + gpio_writel(gpio, BSRR, (1 << pin)); | ||
514 | + g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR) | (1 << pin)); | ||
515 | + | ||
516 | + gpio_writel(gpio, BSRR, (1 << (pin + NUM_GPIO_PINS))); | ||
517 | + g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR)); | ||
518 | + | ||
519 | + gpio_writel(gpio, BSRR, (1 << pin)); | ||
520 | + g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR) | (1 << pin)); | ||
521 | + | ||
522 | + gpio_writel(gpio, BRR, (1 << pin)); | ||
523 | + g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR)); | ||
524 | + | ||
525 | + /* BSx should have priority over BRx */ | ||
526 | + gpio_writel(gpio, BSRR, (1 << pin) | (1 << (pin + NUM_GPIO_PINS))); | ||
527 | + g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR) | (1 << pin)); | ||
528 | + | ||
529 | + gpio_writel(gpio, BRR, (1 << pin)); | ||
530 | + g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR)); | ||
531 | + | ||
532 | + gpio_writel(gpio, ODR, reset(gpio, ODR)); | ||
533 | +} | ||
534 | + | ||
535 | +int main(int argc, char **argv) | ||
536 | +{ | ||
537 | + int ret; | ||
538 | + | ||
539 | + g_test_init(&argc, &argv, NULL); | ||
540 | + g_test_set_nonfatal_assertions(); | ||
541 | + qtest_add_func("stm32l4x5/gpio/test_idr_reset_value", | ||
542 | + test_idr_reset_value); | ||
543 | + /* | ||
544 | + * The inputs for the tests (gpio and pin) can be changed, | ||
545 | + * but the tests don't work for pins that are high at reset | ||
546 | + * (GPIOA15, GPIO13 and GPIOB5). | ||
547 | + * Specifically, rising the pin then checking `get_irq()` | ||
548 | + * is problematic since the pin was already high. | ||
549 | + */ | ||
550 | + qtest_add_data_func("stm32l4x5/gpio/test_gpioc5_output_mode", | ||
551 | + (void *)((uint64_t)GPIO_C << 32 | 5), | ||
552 | + test_gpio_output_mode); | ||
553 | + qtest_add_data_func("stm32l4x5/gpio/test_gpioh3_output_mode", | ||
554 | + (void *)((uint64_t)GPIO_H << 32 | 3), | ||
555 | + test_gpio_output_mode); | ||
556 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_input_mode1", | ||
557 | + (void *)((uint64_t)GPIO_D << 32 | 6), | ||
558 | + test_gpio_input_mode); | ||
559 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_input_mode2", | ||
560 | + (void *)((uint64_t)GPIO_C << 32 | 10), | ||
561 | + test_gpio_input_mode); | ||
562 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_pull_up_pull_down1", | ||
563 | + (void *)((uint64_t)GPIO_B << 32 | 5), | ||
564 | + test_pull_up_pull_down); | ||
565 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_pull_up_pull_down2", | ||
566 | + (void *)((uint64_t)GPIO_F << 32 | 1), | ||
567 | + test_pull_up_pull_down); | ||
568 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_push_pull1", | ||
569 | + (void *)((uint64_t)GPIO_G << 32 | 6), | ||
570 | + test_push_pull); | ||
571 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_push_pull2", | ||
572 | + (void *)((uint64_t)GPIO_H << 32 | 3), | ||
573 | + test_push_pull); | ||
574 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_open_drain1", | ||
575 | + (void *)((uint64_t)GPIO_C << 32 | 4), | ||
576 | + test_open_drain); | ||
577 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_open_drain2", | ||
578 | + (void *)((uint64_t)GPIO_E << 32 | 11), | ||
579 | + test_open_drain); | ||
580 | + qtest_add_data_func("stm32l4x5/gpio/test_bsrr_brr1", | ||
581 | + (void *)((uint64_t)GPIO_A << 32 | 12), | ||
582 | + test_bsrr_brr); | ||
583 | + qtest_add_data_func("stm32l4x5/gpio/test_bsrr_brr2", | ||
584 | + (void *)((uint64_t)GPIO_D << 32 | 0), | ||
585 | + test_bsrr_brr); | ||
586 | + | ||
587 | + qtest_start("-machine b-l475e-iot01a"); | ||
588 | + ret = g_test_run(); | ||
589 | + qtest_end(); | ||
590 | + | ||
591 | + return ret; | ||
592 | +} | ||
593 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build | ||
26 | index XXXXXXX..XXXXXXX 100644 | 594 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/hw/arm/virt-acpi-build.c | 595 | --- a/tests/qtest/meson.build |
28 | +++ b/hw/arm/virt-acpi-build.c | 596 | +++ b/tests/qtest/meson.build |
29 | @@ -XXX,XX +XXX,XX @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, | 597 | @@ -XXX,XX +XXX,XX @@ qtests_aspeed = \ |
30 | aml_create_dword_field(aml_arg(3), aml_int(8), "CDW3")); | 598 | qtests_stm32l4x5 = \ |
31 | aml_append(ifctx, aml_store(aml_name("CDW2"), aml_name("SUPP"))); | 599 | ['stm32l4x5_exti-test', |
32 | aml_append(ifctx, aml_store(aml_name("CDW3"), aml_name("CTRL"))); | 600 | 'stm32l4x5_syscfg-test', |
33 | - aml_append(ifctx, aml_and(aml_name("CTRL"), aml_int(0x1D), | 601 | - 'stm32l4x5_rcc-test'] |
34 | + | 602 | + 'stm32l4x5_rcc-test', |
35 | + /* | 603 | + 'stm32l4x5_gpio-test'] |
36 | + * Allow OS control for all 5 features: | 604 | |
37 | + * PCIeHotplug SHPCHotplug PME AER PCIeCapability. | 605 | qtests_arm = \ |
38 | + */ | 606 | (config_all_devices.has_key('CONFIG_MPS2') ? ['sse-timer-test'] : []) + \ |
39 | + aml_append(ifctx, aml_and(aml_name("CTRL"), aml_int(0x1F), | ||
40 | aml_name("CTRL"))); | ||
41 | |||
42 | ifctx1 = aml_if(aml_lnot(aml_equal(aml_arg(1), aml_int(0x1)))); | ||
43 | diff --git a/tests/data/acpi/virt/DSDT b/tests/data/acpi/virt/DSDT | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | GIT binary patch | ||
46 | delta 28 | ||
47 | kcmbO?fpOjhMlP3Nmk>D*1_q{tja=*8809zbbW3Ff0C~9xM*si- | ||
48 | |||
49 | delta 28 | ||
50 | kcmbO?fpOjhMlP3Nmk>D*1_q|2ja=*87-cu_bW3Ff0C~j-M*si- | ||
51 | |||
52 | diff --git a/tests/data/acpi/virt/DSDT.memhp b/tests/data/acpi/virt/DSDT.memhp | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | GIT binary patch | ||
55 | delta 28 | ||
56 | kcmcaUi}Cs_MlP3NmymE@1_mbija=*8809zbbeqQp0Eq|*2mk;8 | ||
57 | |||
58 | delta 28 | ||
59 | kcmcaUi}Cs_MlP3NmymE@1_ma@ja=*87-cu_beqQp0ErX{2mk;8 | ||
60 | |||
61 | diff --git a/tests/data/acpi/virt/DSDT.numamem b/tests/data/acpi/virt/DSDT.numamem | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | GIT binary patch | ||
64 | delta 28 | ||
65 | kcmbO?fpOjhMlP3Nmk>D*1_q{tja=*8809zbbW3Ff0C~9xM*si- | ||
66 | |||
67 | delta 28 | ||
68 | kcmbO?fpOjhMlP3Nmk>D*1_q|2ja=*87-cu_bW3Ff0C~j-M*si- | ||
69 | |||
70 | -- | 607 | -- |
71 | 2.20.1 | 608 | 2.34.1 |
72 | 609 | ||
73 | 610 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The AST2600 control register sneakily changed the meaning of bit 4 | 3 | While the 8-bit input elements are sequential in the input vector, |
4 | without anyone noticing. It no longer controls the 1MHz vs APB clock | 4 | the 32-bit output elements are not sequential in the output matrix. |
5 | select, and instead always runs at 1MHz. | 5 | Do not attempt to compute 2 32-bit outputs at the same time. |
6 | 6 | ||
7 | The AST2500 was always 1MHz too, but it retained bit 4, making it read | 7 | Cc: qemu-stable@nongnu.org |
8 | only. We can model both using the same fixed 1MHz calculation. | 8 | Fixes: 23a5e3859f5 ("target/arm: Implement SME integer outer product") |
9 | 9 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2083 | |
10 | Fixes: 6b2b2a703cad ("hw: wdt_aspeed: Add AST2600 support") | 10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
12 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 12 | Message-id: 20240305163931.242795-1-richard.henderson@linaro.org |
13 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
14 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
15 | Message-id: 20191119141211.25716-10-clg@kaod.org | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | --- | 14 | --- |
18 | include/hw/watchdog/wdt_aspeed.h | 1 + | 15 | target/arm/tcg/sme_helper.c | 77 ++++++++++++++++++------------- |
19 | hw/watchdog/wdt_aspeed.c | 21 +++++++++++++++++---- | 16 | tests/tcg/aarch64/sme-smopa-1.c | 47 +++++++++++++++++++ |
20 | 2 files changed, 18 insertions(+), 4 deletions(-) | 17 | tests/tcg/aarch64/sme-smopa-2.c | 54 ++++++++++++++++++++++ |
21 | 18 | tests/tcg/aarch64/Makefile.target | 2 +- | |
22 | diff --git a/include/hw/watchdog/wdt_aspeed.h b/include/hw/watchdog/wdt_aspeed.h | 19 | 4 files changed, 147 insertions(+), 33 deletions(-) |
20 | create mode 100644 tests/tcg/aarch64/sme-smopa-1.c | ||
21 | create mode 100644 tests/tcg/aarch64/sme-smopa-2.c | ||
22 | |||
23 | diff --git a/target/arm/tcg/sme_helper.c b/target/arm/tcg/sme_helper.c | ||
23 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/include/hw/watchdog/wdt_aspeed.h | 25 | --- a/target/arm/tcg/sme_helper.c |
25 | +++ b/include/hw/watchdog/wdt_aspeed.h | 26 | +++ b/target/arm/tcg/sme_helper.c |
26 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedWDTClass { | 27 | @@ -XXX,XX +XXX,XX @@ void HELPER(sme_bfmopa)(void *vza, void *vzn, void *vzm, void *vpn, |
27 | uint32_t ext_pulse_width_mask; | ||
28 | uint32_t reset_ctrl_reg; | ||
29 | void (*reset_pulse)(AspeedWDTState *s, uint32_t property); | ||
30 | + void (*wdt_reload)(AspeedWDTState *s); | ||
31 | } AspeedWDTClass; | ||
32 | |||
33 | #endif /* WDT_ASPEED_H */ | ||
34 | diff --git a/hw/watchdog/wdt_aspeed.c b/hw/watchdog/wdt_aspeed.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/hw/watchdog/wdt_aspeed.c | ||
37 | +++ b/hw/watchdog/wdt_aspeed.c | ||
38 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_wdt_read(void *opaque, hwaddr offset, unsigned size) | ||
39 | |||
40 | } | ||
41 | |||
42 | -static void aspeed_wdt_reload(AspeedWDTState *s, bool pclk) | ||
43 | +static void aspeed_wdt_reload(AspeedWDTState *s) | ||
44 | { | ||
45 | uint64_t reload; | ||
46 | |||
47 | - if (pclk) { | ||
48 | + if (!(s->regs[WDT_CTRL] & WDT_CTRL_1MHZ_CLK)) { | ||
49 | reload = muldiv64(s->regs[WDT_RELOAD_VALUE], NANOSECONDS_PER_SECOND, | ||
50 | s->pclk_freq); | ||
51 | } else { | ||
52 | @@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_reload(AspeedWDTState *s, bool pclk) | ||
53 | } | 28 | } |
54 | } | 29 | } |
55 | 30 | ||
56 | +static void aspeed_wdt_reload_1mhz(AspeedWDTState *s) | 31 | -typedef uint64_t IMOPFn(uint64_t, uint64_t, uint64_t, uint8_t, bool); |
32 | +typedef uint32_t IMOPFn32(uint32_t, uint32_t, uint32_t, uint8_t, bool); | ||
33 | +static inline void do_imopa_s(uint32_t *za, uint32_t *zn, uint32_t *zm, | ||
34 | + uint8_t *pn, uint8_t *pm, | ||
35 | + uint32_t desc, IMOPFn32 *fn) | ||
57 | +{ | 36 | +{ |
58 | + uint64_t reload = s->regs[WDT_RELOAD_VALUE] * 1000ULL; | 37 | + intptr_t row, col, oprsz = simd_oprsz(desc) / 4; |
59 | + | 38 | + bool neg = simd_data(desc); |
60 | + if (aspeed_wdt_is_enabled(s)) { | 39 | |
61 | + timer_mod(s->timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + reload); | 40 | -static inline void do_imopa(uint64_t *za, uint64_t *zn, uint64_t *zm, |
41 | - uint8_t *pn, uint8_t *pm, | ||
42 | - uint32_t desc, IMOPFn *fn) | ||
43 | + for (row = 0; row < oprsz; ++row) { | ||
44 | + uint8_t pa = (pn[H1(row >> 1)] >> ((row & 1) * 4)) & 0xf; | ||
45 | + uint32_t *za_row = &za[tile_vslice_index(row)]; | ||
46 | + uint32_t n = zn[H4(row)]; | ||
47 | + | ||
48 | + for (col = 0; col < oprsz; ++col) { | ||
49 | + uint8_t pb = pm[H1(col >> 1)] >> ((col & 1) * 4); | ||
50 | + uint32_t *a = &za_row[H4(col)]; | ||
51 | + | ||
52 | + *a = fn(n, zm[H4(col)], *a, pa & pb, neg); | ||
53 | + } | ||
62 | + } | 54 | + } |
63 | +} | 55 | +} |
64 | + | 56 | + |
65 | + | 57 | +typedef uint64_t IMOPFn64(uint64_t, uint64_t, uint64_t, uint8_t, bool); |
66 | static void aspeed_wdt_write(void *opaque, hwaddr offset, uint64_t data, | 58 | +static inline void do_imopa_d(uint64_t *za, uint64_t *zn, uint64_t *zm, |
67 | unsigned size) | 59 | + uint8_t *pn, uint8_t *pm, |
60 | + uint32_t desc, IMOPFn64 *fn) | ||
68 | { | 61 | { |
69 | @@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_write(void *opaque, hwaddr offset, uint64_t data, | 62 | intptr_t row, col, oprsz = simd_oprsz(desc) / 8; |
70 | case WDT_RESTART: | 63 | bool neg = simd_data(desc); |
71 | if ((data & 0xFFFF) == WDT_RESTART_MAGIC) { | 64 | @@ -XXX,XX +XXX,XX @@ static inline void do_imopa(uint64_t *za, uint64_t *zn, uint64_t *zm, |
72 | s->regs[WDT_STATUS] = s->regs[WDT_RELOAD_VALUE]; | ||
73 | - aspeed_wdt_reload(s, !(s->regs[WDT_CTRL] & WDT_CTRL_1MHZ_CLK)); | ||
74 | + awc->wdt_reload(s); | ||
75 | } | ||
76 | break; | ||
77 | case WDT_CTRL: | ||
78 | if (enable && !aspeed_wdt_is_enabled(s)) { | ||
79 | s->regs[WDT_CTRL] = data; | ||
80 | - aspeed_wdt_reload(s, !(data & WDT_CTRL_1MHZ_CLK)); | ||
81 | + awc->wdt_reload(s); | ||
82 | } else if (!enable && aspeed_wdt_is_enabled(s)) { | ||
83 | s->regs[WDT_CTRL] = data; | ||
84 | timer_del(s->timer); | ||
85 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2400_wdt_class_init(ObjectClass *klass, void *data) | ||
86 | awc->offset = 0x20; | ||
87 | awc->ext_pulse_width_mask = 0xff; | ||
88 | awc->reset_ctrl_reg = SCU_RESET_CONTROL1; | ||
89 | + awc->wdt_reload = aspeed_wdt_reload; | ||
90 | } | 65 | } |
91 | 66 | ||
92 | static const TypeInfo aspeed_2400_wdt_info = { | 67 | #define DEF_IMOP_32(NAME, NTYPE, MTYPE) \ |
93 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2500_wdt_class_init(ObjectClass *klass, void *data) | 68 | -static uint64_t NAME(uint64_t n, uint64_t m, uint64_t a, uint8_t p, bool neg) \ |
94 | awc->ext_pulse_width_mask = 0xfffff; | 69 | +static uint32_t NAME(uint32_t n, uint32_t m, uint32_t a, uint8_t p, bool neg) \ |
95 | awc->reset_ctrl_reg = SCU_RESET_CONTROL1; | 70 | { \ |
96 | awc->reset_pulse = aspeed_2500_wdt_reset_pulse; | 71 | - uint32_t sum0 = 0, sum1 = 0; \ |
97 | + awc->wdt_reload = aspeed_wdt_reload_1mhz; | 72 | + uint32_t sum = 0; \ |
73 | /* Apply P to N as a mask, making the inactive elements 0. */ \ | ||
74 | n &= expand_pred_b(p); \ | ||
75 | - sum0 += (NTYPE)(n >> 0) * (MTYPE)(m >> 0); \ | ||
76 | - sum0 += (NTYPE)(n >> 8) * (MTYPE)(m >> 8); \ | ||
77 | - sum0 += (NTYPE)(n >> 16) * (MTYPE)(m >> 16); \ | ||
78 | - sum0 += (NTYPE)(n >> 24) * (MTYPE)(m >> 24); \ | ||
79 | - sum1 += (NTYPE)(n >> 32) * (MTYPE)(m >> 32); \ | ||
80 | - sum1 += (NTYPE)(n >> 40) * (MTYPE)(m >> 40); \ | ||
81 | - sum1 += (NTYPE)(n >> 48) * (MTYPE)(m >> 48); \ | ||
82 | - sum1 += (NTYPE)(n >> 56) * (MTYPE)(m >> 56); \ | ||
83 | - if (neg) { \ | ||
84 | - sum0 = (uint32_t)a - sum0, sum1 = (uint32_t)(a >> 32) - sum1; \ | ||
85 | - } else { \ | ||
86 | - sum0 = (uint32_t)a + sum0, sum1 = (uint32_t)(a >> 32) + sum1; \ | ||
87 | - } \ | ||
88 | - return ((uint64_t)sum1 << 32) | sum0; \ | ||
89 | + sum += (NTYPE)(n >> 0) * (MTYPE)(m >> 0); \ | ||
90 | + sum += (NTYPE)(n >> 8) * (MTYPE)(m >> 8); \ | ||
91 | + sum += (NTYPE)(n >> 16) * (MTYPE)(m >> 16); \ | ||
92 | + sum += (NTYPE)(n >> 24) * (MTYPE)(m >> 24); \ | ||
93 | + return neg ? a - sum : a + sum; \ | ||
98 | } | 94 | } |
99 | 95 | ||
100 | static const TypeInfo aspeed_2500_wdt_info = { | 96 | #define DEF_IMOP_64(NAME, NTYPE, MTYPE) \ |
101 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2600_wdt_class_init(ObjectClass *klass, void *data) | 97 | @@ -XXX,XX +XXX,XX @@ DEF_IMOP_64(umopa_d, uint16_t, uint16_t) |
102 | awc->ext_pulse_width_mask = 0xfffff; /* TODO */ | 98 | DEF_IMOP_64(sumopa_d, int16_t, uint16_t) |
103 | awc->reset_ctrl_reg = AST2600_SCU_RESET_CONTROL1; | 99 | DEF_IMOP_64(usmopa_d, uint16_t, int16_t) |
104 | awc->reset_pulse = aspeed_2500_wdt_reset_pulse; | 100 | |
105 | + awc->wdt_reload = aspeed_wdt_reload_1mhz; | 101 | -#define DEF_IMOPH(NAME) \ |
106 | } | 102 | - void HELPER(sme_##NAME)(void *vza, void *vzn, void *vzm, void *vpn, \ |
107 | 103 | - void *vpm, uint32_t desc) \ | |
108 | static const TypeInfo aspeed_2600_wdt_info = { | 104 | - { do_imopa(vza, vzn, vzm, vpn, vpm, desc, NAME); } |
105 | +#define DEF_IMOPH(NAME, S) \ | ||
106 | + void HELPER(sme_##NAME##_##S)(void *vza, void *vzn, void *vzm, \ | ||
107 | + void *vpn, void *vpm, uint32_t desc) \ | ||
108 | + { do_imopa_##S(vza, vzn, vzm, vpn, vpm, desc, NAME##_##S); } | ||
109 | |||
110 | -DEF_IMOPH(smopa_s) | ||
111 | -DEF_IMOPH(umopa_s) | ||
112 | -DEF_IMOPH(sumopa_s) | ||
113 | -DEF_IMOPH(usmopa_s) | ||
114 | -DEF_IMOPH(smopa_d) | ||
115 | -DEF_IMOPH(umopa_d) | ||
116 | -DEF_IMOPH(sumopa_d) | ||
117 | -DEF_IMOPH(usmopa_d) | ||
118 | +DEF_IMOPH(smopa, s) | ||
119 | +DEF_IMOPH(umopa, s) | ||
120 | +DEF_IMOPH(sumopa, s) | ||
121 | +DEF_IMOPH(usmopa, s) | ||
122 | + | ||
123 | +DEF_IMOPH(smopa, d) | ||
124 | +DEF_IMOPH(umopa, d) | ||
125 | +DEF_IMOPH(sumopa, d) | ||
126 | +DEF_IMOPH(usmopa, d) | ||
127 | diff --git a/tests/tcg/aarch64/sme-smopa-1.c b/tests/tcg/aarch64/sme-smopa-1.c | ||
128 | new file mode 100644 | ||
129 | index XXXXXXX..XXXXXXX | ||
130 | --- /dev/null | ||
131 | +++ b/tests/tcg/aarch64/sme-smopa-1.c | ||
132 | @@ -XXX,XX +XXX,XX @@ | ||
133 | +#include <stdio.h> | ||
134 | +#include <string.h> | ||
135 | + | ||
136 | +int main() | ||
137 | +{ | ||
138 | + static const int cmp[4][4] = { | ||
139 | + { 110, 134, 158, 182 }, | ||
140 | + { 390, 478, 566, 654 }, | ||
141 | + { 670, 822, 974, 1126 }, | ||
142 | + { 950, 1166, 1382, 1598 } | ||
143 | + }; | ||
144 | + int dst[4][4]; | ||
145 | + int *tmp = &dst[0][0]; | ||
146 | + | ||
147 | + asm volatile( | ||
148 | + ".arch armv8-r+sme\n\t" | ||
149 | + "smstart\n\t" | ||
150 | + "index z0.b, #0, #1\n\t" | ||
151 | + "movprfx z1, z0\n\t" | ||
152 | + "add z1.b, z1.b, #16\n\t" | ||
153 | + "ptrue p0.b\n\t" | ||
154 | + "smopa za0.s, p0/m, p0/m, z0.b, z1.b\n\t" | ||
155 | + "ptrue p0.s, vl4\n\t" | ||
156 | + "mov w12, #0\n\t" | ||
157 | + "st1w { za0h.s[w12, #0] }, p0, [%0]\n\t" | ||
158 | + "add %0, %0, #16\n\t" | ||
159 | + "st1w { za0h.s[w12, #1] }, p0, [%0]\n\t" | ||
160 | + "add %0, %0, #16\n\t" | ||
161 | + "st1w { za0h.s[w12, #2] }, p0, [%0]\n\t" | ||
162 | + "add %0, %0, #16\n\t" | ||
163 | + "st1w { za0h.s[w12, #3] }, p0, [%0]\n\t" | ||
164 | + "smstop" | ||
165 | + : "+r"(tmp) : : "memory"); | ||
166 | + | ||
167 | + if (memcmp(cmp, dst, sizeof(dst)) == 0) { | ||
168 | + return 0; | ||
169 | + } | ||
170 | + | ||
171 | + /* See above for correct results. */ | ||
172 | + for (int i = 0; i < 4; ++i) { | ||
173 | + for (int j = 0; j < 4; ++j) { | ||
174 | + printf("%6d", dst[i][j]); | ||
175 | + } | ||
176 | + printf("\n"); | ||
177 | + } | ||
178 | + return 1; | ||
179 | +} | ||
180 | diff --git a/tests/tcg/aarch64/sme-smopa-2.c b/tests/tcg/aarch64/sme-smopa-2.c | ||
181 | new file mode 100644 | ||
182 | index XXXXXXX..XXXXXXX | ||
183 | --- /dev/null | ||
184 | +++ b/tests/tcg/aarch64/sme-smopa-2.c | ||
185 | @@ -XXX,XX +XXX,XX @@ | ||
186 | +#include <stdio.h> | ||
187 | +#include <string.h> | ||
188 | + | ||
189 | +int main() | ||
190 | +{ | ||
191 | + static const long cmp[4][4] = { | ||
192 | + { 110, 134, 158, 182 }, | ||
193 | + { 390, 478, 566, 654 }, | ||
194 | + { 670, 822, 974, 1126 }, | ||
195 | + { 950, 1166, 1382, 1598 } | ||
196 | + }; | ||
197 | + long dst[4][4]; | ||
198 | + long *tmp = &dst[0][0]; | ||
199 | + long svl; | ||
200 | + | ||
201 | + /* Validate that we have a wide enough vector for 4 elements. */ | ||
202 | + asm(".arch armv8-r+sme-i64\n\trdsvl %0, #1" : "=r"(svl)); | ||
203 | + if (svl < 32) { | ||
204 | + return 0; | ||
205 | + } | ||
206 | + | ||
207 | + asm volatile( | ||
208 | + "smstart\n\t" | ||
209 | + "index z0.h, #0, #1\n\t" | ||
210 | + "movprfx z1, z0\n\t" | ||
211 | + "add z1.h, z1.h, #16\n\t" | ||
212 | + "ptrue p0.b\n\t" | ||
213 | + "smopa za0.d, p0/m, p0/m, z0.h, z1.h\n\t" | ||
214 | + "ptrue p0.d, vl4\n\t" | ||
215 | + "mov w12, #0\n\t" | ||
216 | + "st1d { za0h.d[w12, #0] }, p0, [%0]\n\t" | ||
217 | + "add %0, %0, #32\n\t" | ||
218 | + "st1d { za0h.d[w12, #1] }, p0, [%0]\n\t" | ||
219 | + "mov w12, #2\n\t" | ||
220 | + "add %0, %0, #32\n\t" | ||
221 | + "st1d { za0h.d[w12, #0] }, p0, [%0]\n\t" | ||
222 | + "add %0, %0, #32\n\t" | ||
223 | + "st1d { za0h.d[w12, #1] }, p0, [%0]\n\t" | ||
224 | + "smstop" | ||
225 | + : "+r"(tmp) : : "memory"); | ||
226 | + | ||
227 | + if (memcmp(cmp, dst, sizeof(dst)) == 0) { | ||
228 | + return 0; | ||
229 | + } | ||
230 | + | ||
231 | + /* See above for correct results. */ | ||
232 | + for (int i = 0; i < 4; ++i) { | ||
233 | + for (int j = 0; j < 4; ++j) { | ||
234 | + printf("%6ld", dst[i][j]); | ||
235 | + } | ||
236 | + printf("\n"); | ||
237 | + } | ||
238 | + return 1; | ||
239 | +} | ||
240 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target | ||
241 | index XXXXXXX..XXXXXXX 100644 | ||
242 | --- a/tests/tcg/aarch64/Makefile.target | ||
243 | +++ b/tests/tcg/aarch64/Makefile.target | ||
244 | @@ -XXX,XX +XXX,XX @@ endif | ||
245 | |||
246 | # SME Tests | ||
247 | ifneq ($(CROSS_AS_HAS_ARMV9_SME),) | ||
248 | -AARCH64_TESTS += sme-outprod1 | ||
249 | +AARCH64_TESTS += sme-outprod1 sme-smopa-1 sme-smopa-2 | ||
250 | endif | ||
251 | |||
252 | # System Registers Tests | ||
109 | -- | 253 | -- |
110 | 2.20.1 | 254 | 2.34.1 |
111 | 255 | ||
112 | 256 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | The sun4v RTC device model added under commit a0e893039cf2ce0 in 2016 |
---|---|---|---|
2 | was unfortunately added with a license of GPL-v3-or-later, which is | ||
3 | not compatible with other QEMU code which has a GPL-v2-only license. | ||
2 | 4 | ||
3 | Currently, we link the DRAM memory region to the FMC model (for DMAs) | 5 | Relicense the code in the .c and the .h file to GPL-v2-or-later, |
4 | through a property alias at the SoC level. The I2C model will need a | 6 | to make it compatible with the rest of QEMU. |
5 | similar region for DMA support, add a DRAM region property at the SoC | ||
6 | level for both model to use. | ||
7 | 7 | ||
8 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 8 | Cc: qemu-stable@nongnu.org |
9 | Reviewed-by: Joel Stanley <joel@jms.id.au> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Tested-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com> | 10 | Signed-off-by: Paolo Bonzini (for Red Hat) <pbonzini@redhat.com> |
11 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 11 | Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com> |
12 | Message-id: 20191119141211.25716-4-clg@kaod.org | 12 | Signed-off-by: Markus Armbruster <armbru@redhat.com> |
13 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
14 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
15 | Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> | ||
16 | Acked-by: Alex Bennée <alex.bennee@linaro.org> | ||
17 | Message-id: 20240223161300.938542-1-peter.maydell@linaro.org | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 19 | --- |
15 | include/hw/arm/aspeed_soc.h | 1 + | 20 | include/hw/rtc/sun4v-rtc.h | 2 +- |
16 | hw/arm/aspeed_ast2600.c | 7 +++++-- | 21 | hw/rtc/sun4v-rtc.c | 2 +- |
17 | hw/arm/aspeed_soc.c | 9 +++++++-- | 22 | 2 files changed, 2 insertions(+), 2 deletions(-) |
18 | 3 files changed, 13 insertions(+), 4 deletions(-) | ||
19 | 23 | ||
20 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h | 24 | diff --git a/include/hw/rtc/sun4v-rtc.h b/include/hw/rtc/sun4v-rtc.h |
21 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/hw/arm/aspeed_soc.h | 26 | --- a/include/hw/rtc/sun4v-rtc.h |
23 | +++ b/include/hw/arm/aspeed_soc.h | 27 | +++ b/include/hw/rtc/sun4v-rtc.h |
24 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState { | 28 | @@ -XXX,XX +XXX,XX @@ |
25 | ARMCPU cpu[ASPEED_CPUS_NUM]; | 29 | * |
26 | uint32_t num_cpus; | 30 | * Copyright (c) 2016 Artyom Tarasenko |
27 | A15MPPrivState a7mpcore; | 31 | * |
28 | + MemoryRegion *dram_mr; | 32 | - * This code is licensed under the GNU GPL v3 or (at your option) any later |
29 | MemoryRegion sram; | 33 | + * This code is licensed under the GNU GPL v2 or (at your option) any later |
30 | AspeedVICState vic; | 34 | * version. |
31 | AspeedRtcState rtc; | 35 | */ |
32 | diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c | 36 | |
37 | diff --git a/hw/rtc/sun4v-rtc.c b/hw/rtc/sun4v-rtc.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | 38 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/hw/arm/aspeed_ast2600.c | 39 | --- a/hw/rtc/sun4v-rtc.c |
35 | +++ b/hw/arm/aspeed_ast2600.c | 40 | +++ b/hw/rtc/sun4v-rtc.c |
36 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj) | 41 | @@ -XXX,XX +XXX,XX @@ |
37 | typename); | 42 | * |
38 | object_property_add_alias(obj, "num-cs", OBJECT(&s->fmc), "num-cs", | 43 | * Copyright (c) 2016 Artyom Tarasenko |
39 | &error_abort); | 44 | * |
40 | - object_property_add_alias(obj, "dram", OBJECT(&s->fmc), "dram", | 45 | - * This code is licensed under the GNU GPL v3 or (at your option) any later |
41 | - &error_abort); | 46 | + * This code is licensed under the GNU GPL v2 or (at your option) any later |
42 | 47 | * version. | |
43 | for (i = 0; i < sc->spis_num; i++) { | 48 | */ |
44 | snprintf(typename, sizeof(typename), "aspeed.spi%d-%s", i + 1, socname); | ||
45 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) | ||
46 | } | ||
47 | |||
48 | /* FMC, The number of CS is set at the board level */ | ||
49 | + object_property_set_link(OBJECT(&s->fmc), OBJECT(s->dram_mr), "dram", &err); | ||
50 | + if (err) { | ||
51 | + error_propagate(errp, err); | ||
52 | + return; | ||
53 | + } | ||
54 | object_property_set_int(OBJECT(&s->fmc), sc->memmap[ASPEED_SDRAM], | ||
55 | "sdram-base", &err); | ||
56 | if (err) { | ||
57 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/hw/arm/aspeed_soc.c | ||
60 | +++ b/hw/arm/aspeed_soc.c | ||
61 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | ||
62 | typename); | ||
63 | object_property_add_alias(obj, "num-cs", OBJECT(&s->fmc), "num-cs", | ||
64 | &error_abort); | ||
65 | - object_property_add_alias(obj, "dram", OBJECT(&s->fmc), "dram", | ||
66 | - &error_abort); | ||
67 | |||
68 | for (i = 0; i < sc->spis_num; i++) { | ||
69 | snprintf(typename, sizeof(typename), "aspeed.spi%d-%s", i + 1, socname); | ||
70 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
71 | aspeed_soc_get_irq(s, ASPEED_I2C)); | ||
72 | |||
73 | /* FMC, The number of CS is set at the board level */ | ||
74 | + object_property_set_link(OBJECT(&s->fmc), OBJECT(s->dram_mr), "dram", &err); | ||
75 | + if (err) { | ||
76 | + error_propagate(errp, err); | ||
77 | + return; | ||
78 | + } | ||
79 | object_property_set_int(OBJECT(&s->fmc), sc->memmap[ASPEED_SDRAM], | ||
80 | "sdram-base", &err); | ||
81 | if (err) { | ||
82 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
83 | } | ||
84 | static Property aspeed_soc_properties[] = { | ||
85 | DEFINE_PROP_UINT32("num-cpus", AspeedSoCState, num_cpus, 0), | ||
86 | + DEFINE_PROP_LINK("dram", AspeedSoCState, dram_mr, TYPE_MEMORY_REGION, | ||
87 | + MemoryRegion *), | ||
88 | DEFINE_PROP_END_OF_LIST(), | ||
89 | }; | ||
90 | 49 | ||
91 | -- | 50 | -- |
92 | 2.20.1 | 51 | 2.34.1 |
93 | 52 | ||
94 | 53 | diff view generated by jsdifflib |
1 | From: Christophe Lyon <christophe.lyon@linaro.org> | 1 | From: Thomas Huth <thuth@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | This is derived from cortex-m4 description, adding DP support and FPv5 | 3 | Move the code to a separate file so that we do not have to compile |
4 | instructions with the corresponding flags in isar and mvfr2. | 4 | it anymore if CONFIG_ARM_V7M is not set. |
5 | 5 | ||
6 | Checked that it could successfully execute | 6 | Signed-off-by: Thomas Huth <thuth@redhat.com> |
7 | vrinta.f32 s15, s15 | 7 | Message-id: 20240308141051.536599-2-thuth@redhat.com |
8 | while cortex-m4 emulation rejects it with "illegal instruction". | ||
9 | |||
10 | Signed-off-by: Christophe Lyon <christophe.lyon@linaro.org> | ||
11 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Message-id: 20191025090841.10299-1-christophe.lyon@linaro.org | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 10 | --- |
16 | target/arm/cpu.c | 33 +++++++++++++++++++++++++++++++++ | 11 | target/arm/tcg/cpu-v7m.c | 290 +++++++++++++++++++++++++++++++++++++ |
17 | 1 file changed, 33 insertions(+) | 12 | target/arm/tcg/cpu32.c | 261 --------------------------------- |
13 | target/arm/meson.build | 3 + | ||
14 | target/arm/tcg/meson.build | 3 + | ||
15 | 4 files changed, 296 insertions(+), 261 deletions(-) | ||
16 | create mode 100644 target/arm/tcg/cpu-v7m.c | ||
18 | 17 | ||
19 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 18 | diff --git a/target/arm/tcg/cpu-v7m.c b/target/arm/tcg/cpu-v7m.c |
20 | index XXXXXXX..XXXXXXX 100644 | 19 | new file mode 100644 |
21 | --- a/target/arm/cpu.c | 20 | index XXXXXXX..XXXXXXX |
22 | +++ b/target/arm/cpu.c | 21 | --- /dev/null |
23 | @@ -XXX,XX +XXX,XX @@ static void cortex_m4_initfn(Object *obj) | 22 | +++ b/target/arm/tcg/cpu-v7m.c |
24 | cpu->isar.id_isar6 = 0x00000000; | 23 | @@ -XXX,XX +XXX,XX @@ |
25 | } | 24 | +/* |
26 | 25 | + * QEMU ARMv7-M TCG-only CPUs. | |
27 | +static void cortex_m7_initfn(Object *obj) | 26 | + * |
27 | + * Copyright (c) 2012 SUSE LINUX Products GmbH | ||
28 | + * | ||
29 | + * This code is licensed under the GNU GPL v2 or later. | ||
30 | + * | ||
31 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
32 | + */ | ||
33 | + | ||
34 | +#include "qemu/osdep.h" | ||
35 | +#include "cpu.h" | ||
36 | +#include "hw/core/tcg-cpu-ops.h" | ||
37 | +#include "internals.h" | ||
38 | + | ||
39 | +#if !defined(CONFIG_USER_ONLY) | ||
40 | + | ||
41 | +#include "hw/intc/armv7m_nvic.h" | ||
42 | + | ||
43 | +static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request) | ||
44 | +{ | ||
45 | + CPUClass *cc = CPU_GET_CLASS(cs); | ||
46 | + ARMCPU *cpu = ARM_CPU(cs); | ||
47 | + CPUARMState *env = &cpu->env; | ||
48 | + bool ret = false; | ||
49 | + | ||
50 | + /* | ||
51 | + * ARMv7-M interrupt masking works differently than -A or -R. | ||
52 | + * There is no FIQ/IRQ distinction. Instead of I and F bits | ||
53 | + * masking FIQ and IRQ interrupts, an exception is taken only | ||
54 | + * if it is higher priority than the current execution priority | ||
55 | + * (which depends on state like BASEPRI, FAULTMASK and the | ||
56 | + * currently active exception). | ||
57 | + */ | ||
58 | + if (interrupt_request & CPU_INTERRUPT_HARD | ||
59 | + && (armv7m_nvic_can_take_pending_exception(env->nvic))) { | ||
60 | + cs->exception_index = EXCP_IRQ; | ||
61 | + cc->tcg_ops->do_interrupt(cs); | ||
62 | + ret = true; | ||
63 | + } | ||
64 | + return ret; | ||
65 | +} | ||
66 | + | ||
67 | +#endif /* !CONFIG_USER_ONLY */ | ||
68 | + | ||
69 | +static void cortex_m0_initfn(Object *obj) | ||
70 | +{ | ||
71 | + ARMCPU *cpu = ARM_CPU(obj); | ||
72 | + set_feature(&cpu->env, ARM_FEATURE_V6); | ||
73 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
74 | + | ||
75 | + cpu->midr = 0x410cc200; | ||
76 | + | ||
77 | + /* | ||
78 | + * These ID register values are not guest visible, because | ||
79 | + * we do not implement the Main Extension. They must be set | ||
80 | + * to values corresponding to the Cortex-M0's implemented | ||
81 | + * features, because QEMU generally controls its emulation | ||
82 | + * by looking at ID register fields. We use the same values as | ||
83 | + * for the M3. | ||
84 | + */ | ||
85 | + cpu->isar.id_pfr0 = 0x00000030; | ||
86 | + cpu->isar.id_pfr1 = 0x00000200; | ||
87 | + cpu->isar.id_dfr0 = 0x00100000; | ||
88 | + cpu->id_afr0 = 0x00000000; | ||
89 | + cpu->isar.id_mmfr0 = 0x00000030; | ||
90 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
91 | + cpu->isar.id_mmfr2 = 0x00000000; | ||
92 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
93 | + cpu->isar.id_isar0 = 0x01141110; | ||
94 | + cpu->isar.id_isar1 = 0x02111000; | ||
95 | + cpu->isar.id_isar2 = 0x21112231; | ||
96 | + cpu->isar.id_isar3 = 0x01111110; | ||
97 | + cpu->isar.id_isar4 = 0x01310102; | ||
98 | + cpu->isar.id_isar5 = 0x00000000; | ||
99 | + cpu->isar.id_isar6 = 0x00000000; | ||
100 | +} | ||
101 | + | ||
102 | +static void cortex_m3_initfn(Object *obj) | ||
103 | +{ | ||
104 | + ARMCPU *cpu = ARM_CPU(obj); | ||
105 | + set_feature(&cpu->env, ARM_FEATURE_V7); | ||
106 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
107 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
108 | + cpu->midr = 0x410fc231; | ||
109 | + cpu->pmsav7_dregion = 8; | ||
110 | + cpu->isar.id_pfr0 = 0x00000030; | ||
111 | + cpu->isar.id_pfr1 = 0x00000200; | ||
112 | + cpu->isar.id_dfr0 = 0x00100000; | ||
113 | + cpu->id_afr0 = 0x00000000; | ||
114 | + cpu->isar.id_mmfr0 = 0x00000030; | ||
115 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
116 | + cpu->isar.id_mmfr2 = 0x00000000; | ||
117 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
118 | + cpu->isar.id_isar0 = 0x01141110; | ||
119 | + cpu->isar.id_isar1 = 0x02111000; | ||
120 | + cpu->isar.id_isar2 = 0x21112231; | ||
121 | + cpu->isar.id_isar3 = 0x01111110; | ||
122 | + cpu->isar.id_isar4 = 0x01310102; | ||
123 | + cpu->isar.id_isar5 = 0x00000000; | ||
124 | + cpu->isar.id_isar6 = 0x00000000; | ||
125 | +} | ||
126 | + | ||
127 | +static void cortex_m4_initfn(Object *obj) | ||
28 | +{ | 128 | +{ |
29 | + ARMCPU *cpu = ARM_CPU(obj); | 129 | + ARMCPU *cpu = ARM_CPU(obj); |
30 | + | 130 | + |
31 | + set_feature(&cpu->env, ARM_FEATURE_V7); | 131 | + set_feature(&cpu->env, ARM_FEATURE_V7); |
32 | + set_feature(&cpu->env, ARM_FEATURE_M); | 132 | + set_feature(&cpu->env, ARM_FEATURE_M); |
33 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | 133 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); |
34 | + set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | 134 | + set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); |
35 | + set_feature(&cpu->env, ARM_FEATURE_VFP4); | 135 | + cpu->midr = 0x410fc240; /* r0p0 */ |
136 | + cpu->pmsav7_dregion = 8; | ||
137 | + cpu->isar.mvfr0 = 0x10110021; | ||
138 | + cpu->isar.mvfr1 = 0x11000011; | ||
139 | + cpu->isar.mvfr2 = 0x00000000; | ||
140 | + cpu->isar.id_pfr0 = 0x00000030; | ||
141 | + cpu->isar.id_pfr1 = 0x00000200; | ||
142 | + cpu->isar.id_dfr0 = 0x00100000; | ||
143 | + cpu->id_afr0 = 0x00000000; | ||
144 | + cpu->isar.id_mmfr0 = 0x00000030; | ||
145 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
146 | + cpu->isar.id_mmfr2 = 0x00000000; | ||
147 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
148 | + cpu->isar.id_isar0 = 0x01141110; | ||
149 | + cpu->isar.id_isar1 = 0x02111000; | ||
150 | + cpu->isar.id_isar2 = 0x21112231; | ||
151 | + cpu->isar.id_isar3 = 0x01111110; | ||
152 | + cpu->isar.id_isar4 = 0x01310102; | ||
153 | + cpu->isar.id_isar5 = 0x00000000; | ||
154 | + cpu->isar.id_isar6 = 0x00000000; | ||
155 | +} | ||
156 | + | ||
157 | +static void cortex_m7_initfn(Object *obj) | ||
158 | +{ | ||
159 | + ARMCPU *cpu = ARM_CPU(obj); | ||
160 | + | ||
161 | + set_feature(&cpu->env, ARM_FEATURE_V7); | ||
162 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
163 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
164 | + set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
36 | + cpu->midr = 0x411fc272; /* r1p2 */ | 165 | + cpu->midr = 0x411fc272; /* r1p2 */ |
37 | + cpu->pmsav7_dregion = 8; | 166 | + cpu->pmsav7_dregion = 8; |
38 | + cpu->isar.mvfr0 = 0x10110221; | 167 | + cpu->isar.mvfr0 = 0x10110221; |
39 | + cpu->isar.mvfr1 = 0x12000011; | 168 | + cpu->isar.mvfr1 = 0x12000011; |
40 | + cpu->isar.mvfr2 = 0x00000040; | 169 | + cpu->isar.mvfr2 = 0x00000040; |
41 | + cpu->id_pfr0 = 0x00000030; | 170 | + cpu->isar.id_pfr0 = 0x00000030; |
42 | + cpu->id_pfr1 = 0x00000200; | 171 | + cpu->isar.id_pfr1 = 0x00000200; |
43 | + cpu->id_dfr0 = 0x00100000; | 172 | + cpu->isar.id_dfr0 = 0x00100000; |
44 | + cpu->id_afr0 = 0x00000000; | 173 | + cpu->id_afr0 = 0x00000000; |
45 | + cpu->id_mmfr0 = 0x00100030; | 174 | + cpu->isar.id_mmfr0 = 0x00100030; |
46 | + cpu->id_mmfr1 = 0x00000000; | 175 | + cpu->isar.id_mmfr1 = 0x00000000; |
47 | + cpu->id_mmfr2 = 0x01000000; | 176 | + cpu->isar.id_mmfr2 = 0x01000000; |
48 | + cpu->id_mmfr3 = 0x00000000; | 177 | + cpu->isar.id_mmfr3 = 0x00000000; |
49 | + cpu->isar.id_isar0 = 0x01101110; | 178 | + cpu->isar.id_isar0 = 0x01101110; |
50 | + cpu->isar.id_isar1 = 0x02112000; | 179 | + cpu->isar.id_isar1 = 0x02112000; |
51 | + cpu->isar.id_isar2 = 0x20232231; | 180 | + cpu->isar.id_isar2 = 0x20232231; |
52 | + cpu->isar.id_isar3 = 0x01111131; | 181 | + cpu->isar.id_isar3 = 0x01111131; |
53 | + cpu->isar.id_isar4 = 0x01310132; | 182 | + cpu->isar.id_isar4 = 0x01310132; |
54 | + cpu->isar.id_isar5 = 0x00000000; | 183 | + cpu->isar.id_isar5 = 0x00000000; |
55 | + cpu->isar.id_isar6 = 0x00000000; | 184 | + cpu->isar.id_isar6 = 0x00000000; |
56 | +} | 185 | +} |
57 | + | 186 | + |
58 | static void cortex_m33_initfn(Object *obj) | 187 | +static void cortex_m33_initfn(Object *obj) |
188 | +{ | ||
189 | + ARMCPU *cpu = ARM_CPU(obj); | ||
190 | + | ||
191 | + set_feature(&cpu->env, ARM_FEATURE_V8); | ||
192 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
193 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
194 | + set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); | ||
195 | + set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
196 | + cpu->midr = 0x410fd213; /* r0p3 */ | ||
197 | + cpu->pmsav7_dregion = 16; | ||
198 | + cpu->sau_sregion = 8; | ||
199 | + cpu->isar.mvfr0 = 0x10110021; | ||
200 | + cpu->isar.mvfr1 = 0x11000011; | ||
201 | + cpu->isar.mvfr2 = 0x00000040; | ||
202 | + cpu->isar.id_pfr0 = 0x00000030; | ||
203 | + cpu->isar.id_pfr1 = 0x00000210; | ||
204 | + cpu->isar.id_dfr0 = 0x00200000; | ||
205 | + cpu->id_afr0 = 0x00000000; | ||
206 | + cpu->isar.id_mmfr0 = 0x00101F40; | ||
207 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
208 | + cpu->isar.id_mmfr2 = 0x01000000; | ||
209 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
210 | + cpu->isar.id_isar0 = 0x01101110; | ||
211 | + cpu->isar.id_isar1 = 0x02212000; | ||
212 | + cpu->isar.id_isar2 = 0x20232232; | ||
213 | + cpu->isar.id_isar3 = 0x01111131; | ||
214 | + cpu->isar.id_isar4 = 0x01310132; | ||
215 | + cpu->isar.id_isar5 = 0x00000000; | ||
216 | + cpu->isar.id_isar6 = 0x00000000; | ||
217 | + cpu->clidr = 0x00000000; | ||
218 | + cpu->ctr = 0x8000c000; | ||
219 | +} | ||
220 | + | ||
221 | +static void cortex_m55_initfn(Object *obj) | ||
222 | +{ | ||
223 | + ARMCPU *cpu = ARM_CPU(obj); | ||
224 | + | ||
225 | + set_feature(&cpu->env, ARM_FEATURE_V8); | ||
226 | + set_feature(&cpu->env, ARM_FEATURE_V8_1M); | ||
227 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
228 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
229 | + set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); | ||
230 | + set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
231 | + cpu->midr = 0x410fd221; /* r0p1 */ | ||
232 | + cpu->revidr = 0; | ||
233 | + cpu->pmsav7_dregion = 16; | ||
234 | + cpu->sau_sregion = 8; | ||
235 | + /* These are the MVFR* values for the FPU + full MVE configuration */ | ||
236 | + cpu->isar.mvfr0 = 0x10110221; | ||
237 | + cpu->isar.mvfr1 = 0x12100211; | ||
238 | + cpu->isar.mvfr2 = 0x00000040; | ||
239 | + cpu->isar.id_pfr0 = 0x20000030; | ||
240 | + cpu->isar.id_pfr1 = 0x00000230; | ||
241 | + cpu->isar.id_dfr0 = 0x10200000; | ||
242 | + cpu->id_afr0 = 0x00000000; | ||
243 | + cpu->isar.id_mmfr0 = 0x00111040; | ||
244 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
245 | + cpu->isar.id_mmfr2 = 0x01000000; | ||
246 | + cpu->isar.id_mmfr3 = 0x00000011; | ||
247 | + cpu->isar.id_isar0 = 0x01103110; | ||
248 | + cpu->isar.id_isar1 = 0x02212000; | ||
249 | + cpu->isar.id_isar2 = 0x20232232; | ||
250 | + cpu->isar.id_isar3 = 0x01111131; | ||
251 | + cpu->isar.id_isar4 = 0x01310132; | ||
252 | + cpu->isar.id_isar5 = 0x00000000; | ||
253 | + cpu->isar.id_isar6 = 0x00000000; | ||
254 | + cpu->clidr = 0x00000000; /* caches not implemented */ | ||
255 | + cpu->ctr = 0x8303c003; | ||
256 | +} | ||
257 | + | ||
258 | +static const TCGCPUOps arm_v7m_tcg_ops = { | ||
259 | + .initialize = arm_translate_init, | ||
260 | + .synchronize_from_tb = arm_cpu_synchronize_from_tb, | ||
261 | + .debug_excp_handler = arm_debug_excp_handler, | ||
262 | + .restore_state_to_opc = arm_restore_state_to_opc, | ||
263 | + | ||
264 | +#ifdef CONFIG_USER_ONLY | ||
265 | + .record_sigsegv = arm_cpu_record_sigsegv, | ||
266 | + .record_sigbus = arm_cpu_record_sigbus, | ||
267 | +#else | ||
268 | + .tlb_fill = arm_cpu_tlb_fill, | ||
269 | + .cpu_exec_interrupt = arm_v7m_cpu_exec_interrupt, | ||
270 | + .do_interrupt = arm_v7m_cpu_do_interrupt, | ||
271 | + .do_transaction_failed = arm_cpu_do_transaction_failed, | ||
272 | + .do_unaligned_access = arm_cpu_do_unaligned_access, | ||
273 | + .adjust_watchpoint_address = arm_adjust_watchpoint_address, | ||
274 | + .debug_check_watchpoint = arm_debug_check_watchpoint, | ||
275 | + .debug_check_breakpoint = arm_debug_check_breakpoint, | ||
276 | +#endif /* !CONFIG_USER_ONLY */ | ||
277 | +}; | ||
278 | + | ||
279 | +static void arm_v7m_class_init(ObjectClass *oc, void *data) | ||
280 | +{ | ||
281 | + ARMCPUClass *acc = ARM_CPU_CLASS(oc); | ||
282 | + CPUClass *cc = CPU_CLASS(oc); | ||
283 | + | ||
284 | + acc->info = data; | ||
285 | + cc->tcg_ops = &arm_v7m_tcg_ops; | ||
286 | + cc->gdb_core_xml_file = "arm-m-profile.xml"; | ||
287 | +} | ||
288 | + | ||
289 | +static const ARMCPUInfo arm_v7m_cpus[] = { | ||
290 | + { .name = "cortex-m0", .initfn = cortex_m0_initfn, | ||
291 | + .class_init = arm_v7m_class_init }, | ||
292 | + { .name = "cortex-m3", .initfn = cortex_m3_initfn, | ||
293 | + .class_init = arm_v7m_class_init }, | ||
294 | + { .name = "cortex-m4", .initfn = cortex_m4_initfn, | ||
295 | + .class_init = arm_v7m_class_init }, | ||
296 | + { .name = "cortex-m7", .initfn = cortex_m7_initfn, | ||
297 | + .class_init = arm_v7m_class_init }, | ||
298 | + { .name = "cortex-m33", .initfn = cortex_m33_initfn, | ||
299 | + .class_init = arm_v7m_class_init }, | ||
300 | + { .name = "cortex-m55", .initfn = cortex_m55_initfn, | ||
301 | + .class_init = arm_v7m_class_init }, | ||
302 | +}; | ||
303 | + | ||
304 | +static void arm_v7m_cpu_register_types(void) | ||
305 | +{ | ||
306 | + size_t i; | ||
307 | + | ||
308 | + for (i = 0; i < ARRAY_SIZE(arm_v7m_cpus); ++i) { | ||
309 | + arm_cpu_register(&arm_v7m_cpus[i]); | ||
310 | + } | ||
311 | +} | ||
312 | + | ||
313 | +type_init(arm_v7m_cpu_register_types) | ||
314 | diff --git a/target/arm/tcg/cpu32.c b/target/arm/tcg/cpu32.c | ||
315 | index XXXXXXX..XXXXXXX 100644 | ||
316 | --- a/target/arm/tcg/cpu32.c | ||
317 | +++ b/target/arm/tcg/cpu32.c | ||
318 | @@ -XXX,XX +XXX,XX @@ | ||
319 | #include "hw/boards.h" | ||
320 | #endif | ||
321 | #include "cpregs.h" | ||
322 | -#if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG) | ||
323 | -#include "hw/intc/armv7m_nvic.h" | ||
324 | -#endif | ||
325 | |||
326 | |||
327 | /* Share AArch32 -cpu max features with AArch64. */ | ||
328 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) | ||
329 | /* CPU models. These are not needed for the AArch64 linux-user build. */ | ||
330 | #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) | ||
331 | |||
332 | -#if !defined(CONFIG_USER_ONLY) | ||
333 | -static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request) | ||
334 | -{ | ||
335 | - CPUClass *cc = CPU_GET_CLASS(cs); | ||
336 | - ARMCPU *cpu = ARM_CPU(cs); | ||
337 | - CPUARMState *env = &cpu->env; | ||
338 | - bool ret = false; | ||
339 | - | ||
340 | - /* | ||
341 | - * ARMv7-M interrupt masking works differently than -A or -R. | ||
342 | - * There is no FIQ/IRQ distinction. Instead of I and F bits | ||
343 | - * masking FIQ and IRQ interrupts, an exception is taken only | ||
344 | - * if it is higher priority than the current execution priority | ||
345 | - * (which depends on state like BASEPRI, FAULTMASK and the | ||
346 | - * currently active exception). | ||
347 | - */ | ||
348 | - if (interrupt_request & CPU_INTERRUPT_HARD | ||
349 | - && (armv7m_nvic_can_take_pending_exception(env->nvic))) { | ||
350 | - cs->exception_index = EXCP_IRQ; | ||
351 | - cc->tcg_ops->do_interrupt(cs); | ||
352 | - ret = true; | ||
353 | - } | ||
354 | - return ret; | ||
355 | -} | ||
356 | -#endif /* !CONFIG_USER_ONLY */ | ||
357 | - | ||
358 | static void arm926_initfn(Object *obj) | ||
59 | { | 359 | { |
60 | ARMCPU *cpu = ARM_CPU(obj); | 360 | ARMCPU *cpu = ARM_CPU(obj); |
61 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_cpus[] = { | 361 | @@ -XXX,XX +XXX,XX @@ static void cortex_a15_initfn(Object *obj) |
62 | .class_init = arm_v7m_class_init }, | 362 | define_arm_cp_regs(cpu, cortexa15_cp_reginfo); |
63 | { .name = "cortex-m4", .initfn = cortex_m4_initfn, | 363 | } |
64 | .class_init = arm_v7m_class_init }, | 364 | |
65 | + { .name = "cortex-m7", .initfn = cortex_m7_initfn, | 365 | -static void cortex_m0_initfn(Object *obj) |
66 | + .class_init = arm_v7m_class_init }, | 366 | -{ |
67 | { .name = "cortex-m33", .initfn = cortex_m33_initfn, | 367 | - ARMCPU *cpu = ARM_CPU(obj); |
68 | .class_init = arm_v7m_class_init }, | 368 | - set_feature(&cpu->env, ARM_FEATURE_V6); |
369 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
370 | - | ||
371 | - cpu->midr = 0x410cc200; | ||
372 | - | ||
373 | - /* | ||
374 | - * These ID register values are not guest visible, because | ||
375 | - * we do not implement the Main Extension. They must be set | ||
376 | - * to values corresponding to the Cortex-M0's implemented | ||
377 | - * features, because QEMU generally controls its emulation | ||
378 | - * by looking at ID register fields. We use the same values as | ||
379 | - * for the M3. | ||
380 | - */ | ||
381 | - cpu->isar.id_pfr0 = 0x00000030; | ||
382 | - cpu->isar.id_pfr1 = 0x00000200; | ||
383 | - cpu->isar.id_dfr0 = 0x00100000; | ||
384 | - cpu->id_afr0 = 0x00000000; | ||
385 | - cpu->isar.id_mmfr0 = 0x00000030; | ||
386 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
387 | - cpu->isar.id_mmfr2 = 0x00000000; | ||
388 | - cpu->isar.id_mmfr3 = 0x00000000; | ||
389 | - cpu->isar.id_isar0 = 0x01141110; | ||
390 | - cpu->isar.id_isar1 = 0x02111000; | ||
391 | - cpu->isar.id_isar2 = 0x21112231; | ||
392 | - cpu->isar.id_isar3 = 0x01111110; | ||
393 | - cpu->isar.id_isar4 = 0x01310102; | ||
394 | - cpu->isar.id_isar5 = 0x00000000; | ||
395 | - cpu->isar.id_isar6 = 0x00000000; | ||
396 | -} | ||
397 | - | ||
398 | -static void cortex_m3_initfn(Object *obj) | ||
399 | -{ | ||
400 | - ARMCPU *cpu = ARM_CPU(obj); | ||
401 | - set_feature(&cpu->env, ARM_FEATURE_V7); | ||
402 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
403 | - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
404 | - cpu->midr = 0x410fc231; | ||
405 | - cpu->pmsav7_dregion = 8; | ||
406 | - cpu->isar.id_pfr0 = 0x00000030; | ||
407 | - cpu->isar.id_pfr1 = 0x00000200; | ||
408 | - cpu->isar.id_dfr0 = 0x00100000; | ||
409 | - cpu->id_afr0 = 0x00000000; | ||
410 | - cpu->isar.id_mmfr0 = 0x00000030; | ||
411 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
412 | - cpu->isar.id_mmfr2 = 0x00000000; | ||
413 | - cpu->isar.id_mmfr3 = 0x00000000; | ||
414 | - cpu->isar.id_isar0 = 0x01141110; | ||
415 | - cpu->isar.id_isar1 = 0x02111000; | ||
416 | - cpu->isar.id_isar2 = 0x21112231; | ||
417 | - cpu->isar.id_isar3 = 0x01111110; | ||
418 | - cpu->isar.id_isar4 = 0x01310102; | ||
419 | - cpu->isar.id_isar5 = 0x00000000; | ||
420 | - cpu->isar.id_isar6 = 0x00000000; | ||
421 | -} | ||
422 | - | ||
423 | -static void cortex_m4_initfn(Object *obj) | ||
424 | -{ | ||
425 | - ARMCPU *cpu = ARM_CPU(obj); | ||
426 | - | ||
427 | - set_feature(&cpu->env, ARM_FEATURE_V7); | ||
428 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
429 | - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
430 | - set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
431 | - cpu->midr = 0x410fc240; /* r0p0 */ | ||
432 | - cpu->pmsav7_dregion = 8; | ||
433 | - cpu->isar.mvfr0 = 0x10110021; | ||
434 | - cpu->isar.mvfr1 = 0x11000011; | ||
435 | - cpu->isar.mvfr2 = 0x00000000; | ||
436 | - cpu->isar.id_pfr0 = 0x00000030; | ||
437 | - cpu->isar.id_pfr1 = 0x00000200; | ||
438 | - cpu->isar.id_dfr0 = 0x00100000; | ||
439 | - cpu->id_afr0 = 0x00000000; | ||
440 | - cpu->isar.id_mmfr0 = 0x00000030; | ||
441 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
442 | - cpu->isar.id_mmfr2 = 0x00000000; | ||
443 | - cpu->isar.id_mmfr3 = 0x00000000; | ||
444 | - cpu->isar.id_isar0 = 0x01141110; | ||
445 | - cpu->isar.id_isar1 = 0x02111000; | ||
446 | - cpu->isar.id_isar2 = 0x21112231; | ||
447 | - cpu->isar.id_isar3 = 0x01111110; | ||
448 | - cpu->isar.id_isar4 = 0x01310102; | ||
449 | - cpu->isar.id_isar5 = 0x00000000; | ||
450 | - cpu->isar.id_isar6 = 0x00000000; | ||
451 | -} | ||
452 | - | ||
453 | -static void cortex_m7_initfn(Object *obj) | ||
454 | -{ | ||
455 | - ARMCPU *cpu = ARM_CPU(obj); | ||
456 | - | ||
457 | - set_feature(&cpu->env, ARM_FEATURE_V7); | ||
458 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
459 | - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
460 | - set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
461 | - cpu->midr = 0x411fc272; /* r1p2 */ | ||
462 | - cpu->pmsav7_dregion = 8; | ||
463 | - cpu->isar.mvfr0 = 0x10110221; | ||
464 | - cpu->isar.mvfr1 = 0x12000011; | ||
465 | - cpu->isar.mvfr2 = 0x00000040; | ||
466 | - cpu->isar.id_pfr0 = 0x00000030; | ||
467 | - cpu->isar.id_pfr1 = 0x00000200; | ||
468 | - cpu->isar.id_dfr0 = 0x00100000; | ||
469 | - cpu->id_afr0 = 0x00000000; | ||
470 | - cpu->isar.id_mmfr0 = 0x00100030; | ||
471 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
472 | - cpu->isar.id_mmfr2 = 0x01000000; | ||
473 | - cpu->isar.id_mmfr3 = 0x00000000; | ||
474 | - cpu->isar.id_isar0 = 0x01101110; | ||
475 | - cpu->isar.id_isar1 = 0x02112000; | ||
476 | - cpu->isar.id_isar2 = 0x20232231; | ||
477 | - cpu->isar.id_isar3 = 0x01111131; | ||
478 | - cpu->isar.id_isar4 = 0x01310132; | ||
479 | - cpu->isar.id_isar5 = 0x00000000; | ||
480 | - cpu->isar.id_isar6 = 0x00000000; | ||
481 | -} | ||
482 | - | ||
483 | -static void cortex_m33_initfn(Object *obj) | ||
484 | -{ | ||
485 | - ARMCPU *cpu = ARM_CPU(obj); | ||
486 | - | ||
487 | - set_feature(&cpu->env, ARM_FEATURE_V8); | ||
488 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
489 | - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
490 | - set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); | ||
491 | - set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
492 | - cpu->midr = 0x410fd213; /* r0p3 */ | ||
493 | - cpu->pmsav7_dregion = 16; | ||
494 | - cpu->sau_sregion = 8; | ||
495 | - cpu->isar.mvfr0 = 0x10110021; | ||
496 | - cpu->isar.mvfr1 = 0x11000011; | ||
497 | - cpu->isar.mvfr2 = 0x00000040; | ||
498 | - cpu->isar.id_pfr0 = 0x00000030; | ||
499 | - cpu->isar.id_pfr1 = 0x00000210; | ||
500 | - cpu->isar.id_dfr0 = 0x00200000; | ||
501 | - cpu->id_afr0 = 0x00000000; | ||
502 | - cpu->isar.id_mmfr0 = 0x00101F40; | ||
503 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
504 | - cpu->isar.id_mmfr2 = 0x01000000; | ||
505 | - cpu->isar.id_mmfr3 = 0x00000000; | ||
506 | - cpu->isar.id_isar0 = 0x01101110; | ||
507 | - cpu->isar.id_isar1 = 0x02212000; | ||
508 | - cpu->isar.id_isar2 = 0x20232232; | ||
509 | - cpu->isar.id_isar3 = 0x01111131; | ||
510 | - cpu->isar.id_isar4 = 0x01310132; | ||
511 | - cpu->isar.id_isar5 = 0x00000000; | ||
512 | - cpu->isar.id_isar6 = 0x00000000; | ||
513 | - cpu->clidr = 0x00000000; | ||
514 | - cpu->ctr = 0x8000c000; | ||
515 | -} | ||
516 | - | ||
517 | -static void cortex_m55_initfn(Object *obj) | ||
518 | -{ | ||
519 | - ARMCPU *cpu = ARM_CPU(obj); | ||
520 | - | ||
521 | - set_feature(&cpu->env, ARM_FEATURE_V8); | ||
522 | - set_feature(&cpu->env, ARM_FEATURE_V8_1M); | ||
523 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
524 | - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
525 | - set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); | ||
526 | - set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
527 | - cpu->midr = 0x410fd221; /* r0p1 */ | ||
528 | - cpu->revidr = 0; | ||
529 | - cpu->pmsav7_dregion = 16; | ||
530 | - cpu->sau_sregion = 8; | ||
531 | - /* These are the MVFR* values for the FPU + full MVE configuration */ | ||
532 | - cpu->isar.mvfr0 = 0x10110221; | ||
533 | - cpu->isar.mvfr1 = 0x12100211; | ||
534 | - cpu->isar.mvfr2 = 0x00000040; | ||
535 | - cpu->isar.id_pfr0 = 0x20000030; | ||
536 | - cpu->isar.id_pfr1 = 0x00000230; | ||
537 | - cpu->isar.id_dfr0 = 0x10200000; | ||
538 | - cpu->id_afr0 = 0x00000000; | ||
539 | - cpu->isar.id_mmfr0 = 0x00111040; | ||
540 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
541 | - cpu->isar.id_mmfr2 = 0x01000000; | ||
542 | - cpu->isar.id_mmfr3 = 0x00000011; | ||
543 | - cpu->isar.id_isar0 = 0x01103110; | ||
544 | - cpu->isar.id_isar1 = 0x02212000; | ||
545 | - cpu->isar.id_isar2 = 0x20232232; | ||
546 | - cpu->isar.id_isar3 = 0x01111131; | ||
547 | - cpu->isar.id_isar4 = 0x01310132; | ||
548 | - cpu->isar.id_isar5 = 0x00000000; | ||
549 | - cpu->isar.id_isar6 = 0x00000000; | ||
550 | - cpu->clidr = 0x00000000; /* caches not implemented */ | ||
551 | - cpu->ctr = 0x8303c003; | ||
552 | -} | ||
553 | - | ||
554 | static const ARMCPRegInfo cortexr5_cp_reginfo[] = { | ||
555 | /* Dummy the TCM region regs for the moment */ | ||
556 | { .name = "ATCM", .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 0, | ||
557 | @@ -XXX,XX +XXX,XX @@ static void pxa270c5_initfn(Object *obj) | ||
558 | cpu->reset_sctlr = 0x00000078; | ||
559 | } | ||
560 | |||
561 | -static const TCGCPUOps arm_v7m_tcg_ops = { | ||
562 | - .initialize = arm_translate_init, | ||
563 | - .synchronize_from_tb = arm_cpu_synchronize_from_tb, | ||
564 | - .debug_excp_handler = arm_debug_excp_handler, | ||
565 | - .restore_state_to_opc = arm_restore_state_to_opc, | ||
566 | - | ||
567 | -#ifdef CONFIG_USER_ONLY | ||
568 | - .record_sigsegv = arm_cpu_record_sigsegv, | ||
569 | - .record_sigbus = arm_cpu_record_sigbus, | ||
570 | -#else | ||
571 | - .tlb_fill = arm_cpu_tlb_fill, | ||
572 | - .cpu_exec_interrupt = arm_v7m_cpu_exec_interrupt, | ||
573 | - .do_interrupt = arm_v7m_cpu_do_interrupt, | ||
574 | - .do_transaction_failed = arm_cpu_do_transaction_failed, | ||
575 | - .do_unaligned_access = arm_cpu_do_unaligned_access, | ||
576 | - .adjust_watchpoint_address = arm_adjust_watchpoint_address, | ||
577 | - .debug_check_watchpoint = arm_debug_check_watchpoint, | ||
578 | - .debug_check_breakpoint = arm_debug_check_breakpoint, | ||
579 | -#endif /* !CONFIG_USER_ONLY */ | ||
580 | -}; | ||
581 | - | ||
582 | -static void arm_v7m_class_init(ObjectClass *oc, void *data) | ||
583 | -{ | ||
584 | - ARMCPUClass *acc = ARM_CPU_CLASS(oc); | ||
585 | - CPUClass *cc = CPU_CLASS(oc); | ||
586 | - | ||
587 | - acc->info = data; | ||
588 | - cc->tcg_ops = &arm_v7m_tcg_ops; | ||
589 | - cc->gdb_core_xml_file = "arm-m-profile.xml"; | ||
590 | -} | ||
591 | - | ||
592 | #ifndef TARGET_AARCH64 | ||
593 | /* | ||
594 | * -cpu max: a CPU with as many features enabled as our emulation supports. | ||
595 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_tcg_cpus[] = { | ||
596 | { .name = "cortex-a8", .initfn = cortex_a8_initfn }, | ||
597 | { .name = "cortex-a9", .initfn = cortex_a9_initfn }, | ||
598 | { .name = "cortex-a15", .initfn = cortex_a15_initfn }, | ||
599 | - { .name = "cortex-m0", .initfn = cortex_m0_initfn, | ||
600 | - .class_init = arm_v7m_class_init }, | ||
601 | - { .name = "cortex-m3", .initfn = cortex_m3_initfn, | ||
602 | - .class_init = arm_v7m_class_init }, | ||
603 | - { .name = "cortex-m4", .initfn = cortex_m4_initfn, | ||
604 | - .class_init = arm_v7m_class_init }, | ||
605 | - { .name = "cortex-m7", .initfn = cortex_m7_initfn, | ||
606 | - .class_init = arm_v7m_class_init }, | ||
607 | - { .name = "cortex-m33", .initfn = cortex_m33_initfn, | ||
608 | - .class_init = arm_v7m_class_init }, | ||
609 | - { .name = "cortex-m55", .initfn = cortex_m55_initfn, | ||
610 | - .class_init = arm_v7m_class_init }, | ||
69 | { .name = "cortex-r5", .initfn = cortex_r5_initfn }, | 611 | { .name = "cortex-r5", .initfn = cortex_r5_initfn }, |
612 | { .name = "cortex-r5f", .initfn = cortex_r5f_initfn }, | ||
613 | { .name = "cortex-r52", .initfn = cortex_r52_initfn }, | ||
614 | diff --git a/target/arm/meson.build b/target/arm/meson.build | ||
615 | index XXXXXXX..XXXXXXX 100644 | ||
616 | --- a/target/arm/meson.build | ||
617 | +++ b/target/arm/meson.build | ||
618 | @@ -XXX,XX +XXX,XX @@ arm_system_ss.add(files( | ||
619 | 'ptw.c', | ||
620 | )) | ||
621 | |||
622 | +arm_user_ss = ss.source_set() | ||
623 | + | ||
624 | subdir('hvf') | ||
625 | |||
626 | if 'CONFIG_TCG' in config_all_accel | ||
627 | @@ -XXX,XX +XXX,XX @@ endif | ||
628 | |||
629 | target_arch += {'arm': arm_ss} | ||
630 | target_system_arch += {'arm': arm_system_ss} | ||
631 | +target_user_arch += {'arm': arm_user_ss} | ||
632 | diff --git a/target/arm/tcg/meson.build b/target/arm/tcg/meson.build | ||
633 | index XXXXXXX..XXXXXXX 100644 | ||
634 | --- a/target/arm/tcg/meson.build | ||
635 | +++ b/target/arm/tcg/meson.build | ||
636 | @@ -XXX,XX +XXX,XX @@ arm_ss.add(when: 'TARGET_AARCH64', if_true: files( | ||
637 | arm_system_ss.add(files( | ||
638 | 'psci.c', | ||
639 | )) | ||
640 | + | ||
641 | +arm_system_ss.add(when: 'CONFIG_ARM_V7M', if_true: files('cpu-v7m.c')) | ||
642 | +arm_user_ss.add(when: 'TARGET_AARCH64', if_false: files('cpu-v7m.c')) | ||
70 | -- | 643 | -- |
71 | 2.20.1 | 644 | 2.34.1 |
72 | |||
73 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: David Gibson <david@gibson.dropbear.id.au> | ||
2 | 1 | ||
3 | exynos4210_gic_realize() prints the number of cpus into some temporary | ||
4 | buffers, but it only allows 3 bytes space for it. That's plenty: | ||
5 | existing machines will only ever set this value to EXYNOS4210_NCPUS | ||
6 | (2). But the compiler can't always figure that out, so some[*] gcc9 | ||
7 | versions emit -Wformat-truncation warnings. | ||
8 | |||
9 | We can fix that by hinting the constraint to the compiler with a | ||
10 | suitably placed assert(). | ||
11 | |||
12 | [*] The bizarre thing here, is that I've long gotten these warnings | ||
13 | compiling in a 32-bit x86 container as host - Fedora 30 with | ||
14 | gcc-9.2.1-1.fc30.i686 - but it compiles just fine on my normal | ||
15 | x86_64 host - Fedora 30 with and gcc-9.2.1-1.fc30.x86_64. | ||
16 | |||
17 | Signed-off-by: David Gibson <david@gibson.dropbear.id.au> | ||
18 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
19 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
20 | [PMM: deleted stray blank line] | ||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
22 | --- | ||
23 | hw/intc/exynos4210_gic.c | 9 ++++++++- | ||
24 | 1 file changed, 8 insertions(+), 1 deletion(-) | ||
25 | |||
26 | diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/hw/intc/exynos4210_gic.c | ||
29 | +++ b/hw/intc/exynos4210_gic.c | ||
30 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_gic_realize(DeviceState *dev, Error **errp) | ||
31 | char cpu_alias_name[sizeof(cpu_prefix) + 3]; | ||
32 | char dist_alias_name[sizeof(cpu_prefix) + 3]; | ||
33 | SysBusDevice *gicbusdev; | ||
34 | + uint32_t n = s->num_cpu; | ||
35 | uint32_t i; | ||
36 | |||
37 | s->gic = qdev_create(NULL, "arm_gic"); | ||
38 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_gic_realize(DeviceState *dev, Error **errp) | ||
39 | memory_region_init(&s->dist_container, obj, "exynos4210-dist-container", | ||
40 | EXYNOS4210_EXT_GIC_DIST_REGION_SIZE); | ||
41 | |||
42 | - for (i = 0; i < s->num_cpu; i++) { | ||
43 | + /* | ||
44 | + * This clues in gcc that our on-stack buffers do, in fact have | ||
45 | + * enough room for the cpu numbers. gcc 9.2.1 on 32-bit x86 | ||
46 | + * doesn't figure this out, otherwise and gives spurious warnings. | ||
47 | + */ | ||
48 | + assert(n <= EXYNOS4210_NCPUS); | ||
49 | + for (i = 0; i < n; i++) { | ||
50 | /* Map CPU interface per SMP Core */ | ||
51 | sprintf(cpu_alias_name, "%s%x", cpu_prefix, i); | ||
52 | memory_region_init_alias(&s->cpu_alias[i], obj, | ||
53 | -- | ||
54 | 2.20.1 | ||
55 | |||
56 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Cédric Le Goater <clg@kaod.org> | ||
2 | 1 | ||
3 | The Aspeed I2C controller can operate in different transfer modes : | ||
4 | |||
5 | - Byte Buffer mode, using a dedicated register to transfer a | ||
6 | byte. This is what the model supports today. | ||
7 | |||
8 | - Pool Buffer mode, using an internal SRAM to transfer multiple | ||
9 | bytes in the same command sequence. | ||
10 | |||
11 | Each SoC has different SRAM characteristics. On the AST2400, 2048 | ||
12 | bytes of SRAM are available at offset 0x800 of the controller AHB | ||
13 | window. The pool buffer can be configured from 1 to 256 bytes per bus. | ||
14 | |||
15 | On the AST2500, the SRAM is at offset 0x200 and the pool buffer is of | ||
16 | 16 bytes per bus. | ||
17 | |||
18 | On the AST2600, the SRAM is at offset 0xC00 and the pool buffer is of | ||
19 | 32 bytes per bus. It can be splitted in two for TX and RX but the | ||
20 | current model does not add support for it as it it unused by known | ||
21 | drivers. | ||
22 | |||
23 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
24 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
25 | Tested-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com> | ||
26 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
27 | Message-id: 20191119141211.25716-2-clg@kaod.org | ||
28 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
29 | --- | ||
30 | include/hw/i2c/aspeed_i2c.h | 8 ++ | ||
31 | hw/i2c/aspeed_i2c.c | 197 ++++++++++++++++++++++++++++++++---- | ||
32 | 2 files changed, 186 insertions(+), 19 deletions(-) | ||
33 | |||
34 | diff --git a/include/hw/i2c/aspeed_i2c.h b/include/hw/i2c/aspeed_i2c.h | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/include/hw/i2c/aspeed_i2c.h | ||
37 | +++ b/include/hw/i2c/aspeed_i2c.h | ||
38 | @@ -XXX,XX +XXX,XX @@ | ||
39 | OBJECT_CHECK(AspeedI2CState, (obj), TYPE_ASPEED_I2C) | ||
40 | |||
41 | #define ASPEED_I2C_NR_BUSSES 16 | ||
42 | +#define ASPEED_I2C_MAX_POOL_SIZE 0x800 | ||
43 | |||
44 | struct AspeedI2CState; | ||
45 | |||
46 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedI2CBus { | ||
47 | uint32_t intr_status; | ||
48 | uint32_t cmd; | ||
49 | uint32_t buf; | ||
50 | + uint32_t pool_ctrl; | ||
51 | } AspeedI2CBus; | ||
52 | |||
53 | typedef struct AspeedI2CState { | ||
54 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedI2CState { | ||
55 | qemu_irq irq; | ||
56 | |||
57 | uint32_t intr_status; | ||
58 | + MemoryRegion pool_iomem; | ||
59 | + uint8_t pool[ASPEED_I2C_MAX_POOL_SIZE]; | ||
60 | |||
61 | AspeedI2CBus busses[ASPEED_I2C_NR_BUSSES]; | ||
62 | } AspeedI2CState; | ||
63 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedI2CClass { | ||
64 | uint8_t reg_size; | ||
65 | uint8_t gap; | ||
66 | qemu_irq (*bus_get_irq)(AspeedI2CBus *); | ||
67 | + | ||
68 | + uint64_t pool_size; | ||
69 | + hwaddr pool_base; | ||
70 | + uint8_t *(*bus_pool_base)(AspeedI2CBus *); | ||
71 | } AspeedI2CClass; | ||
72 | |||
73 | I2CBus *aspeed_i2c_get_bus(DeviceState *dev, int busnr); | ||
74 | diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c | ||
75 | index XXXXXXX..XXXXXXX 100644 | ||
76 | --- a/hw/i2c/aspeed_i2c.c | ||
77 | +++ b/hw/i2c/aspeed_i2c.c | ||
78 | @@ -XXX,XX +XXX,XX @@ | ||
79 | /* I2C Device (Bus) Register */ | ||
80 | |||
81 | #define I2CD_FUN_CTRL_REG 0x00 /* I2CD Function Control */ | ||
82 | -#define I2CD_BUFF_SEL_MASK (0x7 << 20) | ||
83 | -#define I2CD_BUFF_SEL(x) (x << 20) | ||
84 | +#define I2CD_POOL_PAGE_SEL(x) (((x) >> 20) & 0x7) /* AST2400 */ | ||
85 | #define I2CD_M_SDA_LOCK_EN (0x1 << 16) | ||
86 | #define I2CD_MULTI_MASTER_DIS (0x1 << 15) | ||
87 | #define I2CD_M_SCL_DRIVE_EN (0x1 << 14) | ||
88 | @@ -XXX,XX +XXX,XX @@ | ||
89 | #define I2CD_SCL_O_OUT_DIR (0x1 << 12) | ||
90 | #define I2CD_BUS_RECOVER_CMD_EN (0x1 << 11) | ||
91 | #define I2CD_S_ALT_EN (0x1 << 10) | ||
92 | -#define I2CD_RX_DMA_ENABLE (0x1 << 9) | ||
93 | -#define I2CD_TX_DMA_ENABLE (0x1 << 8) | ||
94 | |||
95 | /* Command Bit */ | ||
96 | +#define I2CD_RX_DMA_ENABLE (0x1 << 9) | ||
97 | +#define I2CD_TX_DMA_ENABLE (0x1 << 8) | ||
98 | +#define I2CD_RX_BUFF_ENABLE (0x1 << 7) | ||
99 | +#define I2CD_TX_BUFF_ENABLE (0x1 << 6) | ||
100 | #define I2CD_M_STOP_CMD (0x1 << 5) | ||
101 | #define I2CD_M_S_RX_CMD_LAST (0x1 << 4) | ||
102 | #define I2CD_M_RX_CMD (0x1 << 3) | ||
103 | @@ -XXX,XX +XXX,XX @@ | ||
104 | #define I2CD_M_START_CMD (0x1) | ||
105 | |||
106 | #define I2CD_DEV_ADDR_REG 0x18 /* Slave Device Address */ | ||
107 | -#define I2CD_BUF_CTRL_REG 0x1c /* Pool Buffer Control */ | ||
108 | +#define I2CD_POOL_CTRL_REG 0x1c /* Pool Buffer Control */ | ||
109 | +#define I2CD_POOL_RX_COUNT(x) (((x) >> 24) & 0xff) | ||
110 | +#define I2CD_POOL_RX_SIZE(x) ((((x) >> 16) & 0xff) + 1) | ||
111 | +#define I2CD_POOL_TX_COUNT(x) ((((x) >> 8) & 0xff) + 1) | ||
112 | +#define I2CD_POOL_OFFSET(x) (((x) & 0x3f) << 2) /* AST2400 */ | ||
113 | #define I2CD_BYTE_BUF_REG 0x20 /* Transmit/Receive Byte Buffer */ | ||
114 | #define I2CD_BYTE_BUF_TX_SHIFT 0 | ||
115 | #define I2CD_BYTE_BUF_TX_MASK 0xff | ||
116 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_i2c_bus_read(void *opaque, hwaddr offset, | ||
117 | return bus->intr_ctrl; | ||
118 | case I2CD_INTR_STS_REG: | ||
119 | return bus->intr_status; | ||
120 | + case I2CD_POOL_CTRL_REG: | ||
121 | + return bus->pool_ctrl; | ||
122 | case I2CD_BYTE_BUF_REG: | ||
123 | return bus->buf; | ||
124 | case I2CD_CMD_REG: | ||
125 | @@ -XXX,XX +XXX,XX @@ static uint8_t aspeed_i2c_get_state(AspeedI2CBus *bus) | ||
126 | return (bus->cmd >> I2CD_TX_STATE_SHIFT) & I2CD_TX_STATE_MASK; | ||
127 | } | ||
128 | |||
129 | +static int aspeed_i2c_bus_send(AspeedI2CBus *bus, uint8_t pool_start) | ||
130 | +{ | ||
131 | + AspeedI2CClass *aic = ASPEED_I2C_GET_CLASS(bus->controller); | ||
132 | + int ret = -1; | ||
133 | + int i; | ||
134 | + | ||
135 | + if (bus->cmd & I2CD_TX_BUFF_ENABLE) { | ||
136 | + for (i = pool_start; i < I2CD_POOL_TX_COUNT(bus->pool_ctrl); i++) { | ||
137 | + uint8_t *pool_base = aic->bus_pool_base(bus); | ||
138 | + | ||
139 | + ret = i2c_send(bus->bus, pool_base[i]); | ||
140 | + if (ret) { | ||
141 | + break; | ||
142 | + } | ||
143 | + } | ||
144 | + bus->cmd &= ~I2CD_TX_BUFF_ENABLE; | ||
145 | + } else { | ||
146 | + ret = i2c_send(bus->bus, bus->buf); | ||
147 | + } | ||
148 | + | ||
149 | + return ret; | ||
150 | +} | ||
151 | + | ||
152 | +static void aspeed_i2c_bus_recv(AspeedI2CBus *bus) | ||
153 | +{ | ||
154 | + AspeedI2CState *s = bus->controller; | ||
155 | + AspeedI2CClass *aic = ASPEED_I2C_GET_CLASS(s); | ||
156 | + uint8_t data; | ||
157 | + int i; | ||
158 | + | ||
159 | + if (bus->cmd & I2CD_RX_BUFF_ENABLE) { | ||
160 | + uint8_t *pool_base = aic->bus_pool_base(bus); | ||
161 | + | ||
162 | + for (i = 0; i < I2CD_POOL_RX_SIZE(bus->pool_ctrl); i++) { | ||
163 | + pool_base[i] = i2c_recv(bus->bus); | ||
164 | + } | ||
165 | + | ||
166 | + /* Update RX count */ | ||
167 | + bus->pool_ctrl &= ~(0xff << 24); | ||
168 | + bus->pool_ctrl |= (i & 0xff) << 24; | ||
169 | + bus->cmd &= ~I2CD_RX_BUFF_ENABLE; | ||
170 | + } else { | ||
171 | + data = i2c_recv(bus->bus); | ||
172 | + bus->buf = (data & I2CD_BYTE_BUF_RX_MASK) << I2CD_BYTE_BUF_RX_SHIFT; | ||
173 | + } | ||
174 | +} | ||
175 | + | ||
176 | static void aspeed_i2c_handle_rx_cmd(AspeedI2CBus *bus) | ||
177 | { | ||
178 | - uint8_t ret; | ||
179 | - | ||
180 | aspeed_i2c_set_state(bus, I2CD_MRXD); | ||
181 | - ret = i2c_recv(bus->bus); | ||
182 | + aspeed_i2c_bus_recv(bus); | ||
183 | bus->intr_status |= I2CD_INTR_RX_DONE; | ||
184 | - bus->buf = (ret & I2CD_BYTE_BUF_RX_MASK) << I2CD_BYTE_BUF_RX_SHIFT; | ||
185 | if (bus->cmd & I2CD_M_S_RX_CMD_LAST) { | ||
186 | i2c_nack(bus->bus); | ||
187 | } | ||
188 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_handle_rx_cmd(AspeedI2CBus *bus) | ||
189 | aspeed_i2c_set_state(bus, I2CD_MACTIVE); | ||
190 | } | ||
191 | |||
192 | +static uint8_t aspeed_i2c_get_addr(AspeedI2CBus *bus) | ||
193 | +{ | ||
194 | + AspeedI2CClass *aic = ASPEED_I2C_GET_CLASS(bus->controller); | ||
195 | + | ||
196 | + if (bus->cmd & I2CD_TX_BUFF_ENABLE) { | ||
197 | + uint8_t *pool_base = aic->bus_pool_base(bus); | ||
198 | + | ||
199 | + return pool_base[0]; | ||
200 | + } else { | ||
201 | + return bus->buf; | ||
202 | + } | ||
203 | +} | ||
204 | + | ||
205 | /* | ||
206 | * The state machine needs some refinement. It is only used to track | ||
207 | * invalid STOP commands for the moment. | ||
208 | */ | ||
209 | static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value) | ||
210 | { | ||
211 | + uint8_t pool_start = 0; | ||
212 | + | ||
213 | bus->cmd &= ~0xFFFF; | ||
214 | bus->cmd |= value & 0xFFFF; | ||
215 | |||
216 | if (bus->cmd & I2CD_M_START_CMD) { | ||
217 | uint8_t state = aspeed_i2c_get_state(bus) & I2CD_MACTIVE ? | ||
218 | I2CD_MSTARTR : I2CD_MSTART; | ||
219 | + uint8_t addr; | ||
220 | |||
221 | aspeed_i2c_set_state(bus, state); | ||
222 | |||
223 | - if (i2c_start_transfer(bus->bus, extract32(bus->buf, 1, 7), | ||
224 | - extract32(bus->buf, 0, 1))) { | ||
225 | + addr = aspeed_i2c_get_addr(bus); | ||
226 | + | ||
227 | + if (i2c_start_transfer(bus->bus, extract32(addr, 1, 7), | ||
228 | + extract32(addr, 0, 1))) { | ||
229 | bus->intr_status |= I2CD_INTR_TX_NAK; | ||
230 | } else { | ||
231 | bus->intr_status |= I2CD_INTR_TX_ACK; | ||
232 | } | ||
233 | |||
234 | - /* START command is also a TX command, as the slave address is | ||
235 | - * sent on the bus */ | ||
236 | - bus->cmd &= ~(I2CD_M_START_CMD | I2CD_M_TX_CMD); | ||
237 | + bus->cmd &= ~I2CD_M_START_CMD; | ||
238 | + | ||
239 | + /* | ||
240 | + * The START command is also a TX command, as the slave | ||
241 | + * address is sent on the bus. Drop the TX flag if nothing | ||
242 | + * else needs to be sent in this sequence. | ||
243 | + */ | ||
244 | + if (bus->cmd & I2CD_TX_BUFF_ENABLE) { | ||
245 | + if (I2CD_POOL_TX_COUNT(bus->pool_ctrl) == 1) { | ||
246 | + bus->cmd &= ~I2CD_M_TX_CMD; | ||
247 | + } else { | ||
248 | + /* | ||
249 | + * Increase the start index in the TX pool buffer to | ||
250 | + * skip the address byte. | ||
251 | + */ | ||
252 | + pool_start++; | ||
253 | + } | ||
254 | + } else { | ||
255 | + bus->cmd &= ~I2CD_M_TX_CMD; | ||
256 | + } | ||
257 | |||
258 | /* No slave found */ | ||
259 | if (!i2c_bus_busy(bus->bus)) { | ||
260 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value) | ||
261 | |||
262 | if (bus->cmd & I2CD_M_TX_CMD) { | ||
263 | aspeed_i2c_set_state(bus, I2CD_MTXD); | ||
264 | - if (i2c_send(bus->bus, bus->buf)) { | ||
265 | + if (aspeed_i2c_bus_send(bus, pool_start)) { | ||
266 | bus->intr_status |= (I2CD_INTR_TX_NAK); | ||
267 | i2c_end_transfer(bus->bus); | ||
268 | } else { | ||
269 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_write(void *opaque, hwaddr offset, | ||
270 | qemu_log_mask(LOG_UNIMP, "%s: slave mode not implemented\n", | ||
271 | __func__); | ||
272 | break; | ||
273 | + case I2CD_POOL_CTRL_REG: | ||
274 | + bus->pool_ctrl &= ~0xffffff; | ||
275 | + bus->pool_ctrl |= (value & 0xffffff); | ||
276 | + break; | ||
277 | + | ||
278 | case I2CD_BYTE_BUF_REG: | ||
279 | bus->buf = (value & I2CD_BYTE_BUF_TX_MASK) << I2CD_BYTE_BUF_TX_SHIFT; | ||
280 | break; | ||
281 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps aspeed_i2c_ctrl_ops = { | ||
282 | .endianness = DEVICE_LITTLE_ENDIAN, | ||
283 | }; | ||
284 | |||
285 | +static uint64_t aspeed_i2c_pool_read(void *opaque, hwaddr offset, | ||
286 | + unsigned size) | ||
287 | +{ | ||
288 | + AspeedI2CState *s = opaque; | ||
289 | + uint64_t ret = 0; | ||
290 | + int i; | ||
291 | + | ||
292 | + for (i = 0; i < size; i++) { | ||
293 | + ret |= (uint64_t) s->pool[offset + i] << (8 * i); | ||
294 | + } | ||
295 | + | ||
296 | + return ret; | ||
297 | +} | ||
298 | + | ||
299 | +static void aspeed_i2c_pool_write(void *opaque, hwaddr offset, | ||
300 | + uint64_t value, unsigned size) | ||
301 | +{ | ||
302 | + AspeedI2CState *s = opaque; | ||
303 | + int i; | ||
304 | + | ||
305 | + for (i = 0; i < size; i++) { | ||
306 | + s->pool[offset + i] = (value >> (8 * i)) & 0xFF; | ||
307 | + } | ||
308 | +} | ||
309 | + | ||
310 | +static const MemoryRegionOps aspeed_i2c_pool_ops = { | ||
311 | + .read = aspeed_i2c_pool_read, | ||
312 | + .write = aspeed_i2c_pool_write, | ||
313 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
314 | + .valid = { | ||
315 | + .min_access_size = 1, | ||
316 | + .max_access_size = 4, | ||
317 | + }, | ||
318 | +}; | ||
319 | + | ||
320 | static const VMStateDescription aspeed_i2c_bus_vmstate = { | ||
321 | .name = TYPE_ASPEED_I2C, | ||
322 | - .version_id = 1, | ||
323 | - .minimum_version_id = 1, | ||
324 | + .version_id = 2, | ||
325 | + .minimum_version_id = 2, | ||
326 | .fields = (VMStateField[]) { | ||
327 | VMSTATE_UINT8(id, AspeedI2CBus), | ||
328 | VMSTATE_UINT32(ctrl, AspeedI2CBus), | ||
329 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription aspeed_i2c_bus_vmstate = { | ||
330 | VMSTATE_UINT32(intr_status, AspeedI2CBus), | ||
331 | VMSTATE_UINT32(cmd, AspeedI2CBus), | ||
332 | VMSTATE_UINT32(buf, AspeedI2CBus), | ||
333 | + VMSTATE_UINT32(pool_ctrl, AspeedI2CBus), | ||
334 | VMSTATE_END_OF_LIST() | ||
335 | } | ||
336 | }; | ||
337 | |||
338 | static const VMStateDescription aspeed_i2c_vmstate = { | ||
339 | .name = TYPE_ASPEED_I2C, | ||
340 | - .version_id = 1, | ||
341 | - .minimum_version_id = 1, | ||
342 | + .version_id = 2, | ||
343 | + .minimum_version_id = 2, | ||
344 | .fields = (VMStateField[]) { | ||
345 | VMSTATE_UINT32(intr_status, AspeedI2CState), | ||
346 | VMSTATE_STRUCT_ARRAY(busses, AspeedI2CState, | ||
347 | ASPEED_I2C_NR_BUSSES, 1, aspeed_i2c_bus_vmstate, | ||
348 | AspeedI2CBus), | ||
349 | + VMSTATE_UINT8_ARRAY(pool, AspeedI2CState, ASPEED_I2C_MAX_POOL_SIZE), | ||
350 | VMSTATE_END_OF_LIST() | ||
351 | } | ||
352 | }; | ||
353 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_realize(DeviceState *dev, Error **errp) | ||
354 | memory_region_add_subregion(&s->iomem, aic->reg_size * (i + offset), | ||
355 | &s->busses[i].mr); | ||
356 | } | ||
357 | + | ||
358 | + memory_region_init_io(&s->pool_iomem, OBJECT(s), &aspeed_i2c_pool_ops, s, | ||
359 | + "aspeed.i2c-pool", aic->pool_size); | ||
360 | + memory_region_add_subregion(&s->iomem, aic->pool_base, &s->pool_iomem); | ||
361 | } | ||
362 | |||
363 | static void aspeed_i2c_class_init(ObjectClass *klass, void *data) | ||
364 | @@ -XXX,XX +XXX,XX @@ static qemu_irq aspeed_2400_i2c_bus_get_irq(AspeedI2CBus *bus) | ||
365 | return bus->controller->irq; | ||
366 | } | ||
367 | |||
368 | +static uint8_t *aspeed_2400_i2c_bus_pool_base(AspeedI2CBus *bus) | ||
369 | +{ | ||
370 | + uint8_t *pool_page = | ||
371 | + &bus->controller->pool[I2CD_POOL_PAGE_SEL(bus->ctrl) * 0x100]; | ||
372 | + | ||
373 | + return &pool_page[I2CD_POOL_OFFSET(bus->pool_ctrl)]; | ||
374 | +} | ||
375 | + | ||
376 | static void aspeed_2400_i2c_class_init(ObjectClass *klass, void *data) | ||
377 | { | ||
378 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
379 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2400_i2c_class_init(ObjectClass *klass, void *data) | ||
380 | aic->reg_size = 0x40; | ||
381 | aic->gap = 7; | ||
382 | aic->bus_get_irq = aspeed_2400_i2c_bus_get_irq; | ||
383 | + aic->pool_size = 0x800; | ||
384 | + aic->pool_base = 0x800; | ||
385 | + aic->bus_pool_base = aspeed_2400_i2c_bus_pool_base; | ||
386 | } | ||
387 | |||
388 | static const TypeInfo aspeed_2400_i2c_info = { | ||
389 | @@ -XXX,XX +XXX,XX @@ static qemu_irq aspeed_2500_i2c_bus_get_irq(AspeedI2CBus *bus) | ||
390 | return bus->controller->irq; | ||
391 | } | ||
392 | |||
393 | +static uint8_t *aspeed_2500_i2c_bus_pool_base(AspeedI2CBus *bus) | ||
394 | +{ | ||
395 | + return &bus->controller->pool[bus->id * 0x10]; | ||
396 | +} | ||
397 | + | ||
398 | static void aspeed_2500_i2c_class_init(ObjectClass *klass, void *data) | ||
399 | { | ||
400 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
401 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2500_i2c_class_init(ObjectClass *klass, void *data) | ||
402 | aic->reg_size = 0x40; | ||
403 | aic->gap = 7; | ||
404 | aic->bus_get_irq = aspeed_2500_i2c_bus_get_irq; | ||
405 | + aic->pool_size = 0x100; | ||
406 | + aic->pool_base = 0x200; | ||
407 | + aic->bus_pool_base = aspeed_2500_i2c_bus_pool_base; | ||
408 | } | ||
409 | |||
410 | static const TypeInfo aspeed_2500_i2c_info = { | ||
411 | @@ -XXX,XX +XXX,XX @@ static qemu_irq aspeed_2600_i2c_bus_get_irq(AspeedI2CBus *bus) | ||
412 | return bus->irq; | ||
413 | } | ||
414 | |||
415 | +static uint8_t *aspeed_2600_i2c_bus_pool_base(AspeedI2CBus *bus) | ||
416 | +{ | ||
417 | + return &bus->controller->pool[bus->id * 0x20]; | ||
418 | +} | ||
419 | + | ||
420 | static void aspeed_2600_i2c_class_init(ObjectClass *klass, void *data) | ||
421 | { | ||
422 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
423 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2600_i2c_class_init(ObjectClass *klass, void *data) | ||
424 | aic->reg_size = 0x80; | ||
425 | aic->gap = -1; /* no gap */ | ||
426 | aic->bus_get_irq = aspeed_2600_i2c_bus_get_irq; | ||
427 | + aic->pool_size = 0x200; | ||
428 | + aic->pool_base = 0xC00; | ||
429 | + aic->bus_pool_base = aspeed_2600_i2c_bus_pool_base; | ||
430 | } | ||
431 | |||
432 | static const TypeInfo aspeed_2600_i2c_info = { | ||
433 | -- | ||
434 | 2.20.1 | ||
435 | |||
436 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Cédric Le Goater <clg@kaod.org> | ||
2 | 1 | ||
3 | The SRAM must be enabled before using the Buffer Pool mode or the DMA | ||
4 | mode. This is not required on other SoCs. | ||
5 | |||
6 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
7 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
8 | Tested-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com> | ||
9 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
10 | Message-id: 20191119141211.25716-3-clg@kaod.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | include/hw/i2c/aspeed_i2c.h | 3 +++ | ||
14 | hw/i2c/aspeed_i2c.c | 37 +++++++++++++++++++++++++++++++++++++ | ||
15 | 2 files changed, 40 insertions(+) | ||
16 | |||
17 | diff --git a/include/hw/i2c/aspeed_i2c.h b/include/hw/i2c/aspeed_i2c.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/include/hw/i2c/aspeed_i2c.h | ||
20 | +++ b/include/hw/i2c/aspeed_i2c.h | ||
21 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedI2CState { | ||
22 | qemu_irq irq; | ||
23 | |||
24 | uint32_t intr_status; | ||
25 | + uint32_t ctrl_global; | ||
26 | MemoryRegion pool_iomem; | ||
27 | uint8_t pool[ASPEED_I2C_MAX_POOL_SIZE]; | ||
28 | |||
29 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedI2CClass { | ||
30 | uint64_t pool_size; | ||
31 | hwaddr pool_base; | ||
32 | uint8_t *(*bus_pool_base)(AspeedI2CBus *); | ||
33 | + bool check_sram; | ||
34 | + | ||
35 | } AspeedI2CClass; | ||
36 | |||
37 | I2CBus *aspeed_i2c_get_bus(DeviceState *dev, int busnr); | ||
38 | diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/hw/i2c/aspeed_i2c.c | ||
41 | +++ b/hw/i2c/aspeed_i2c.c | ||
42 | @@ -XXX,XX +XXX,XX @@ | ||
43 | #define I2C_CTRL_STATUS 0x00 /* Device Interrupt Status */ | ||
44 | #define I2C_CTRL_ASSIGN 0x08 /* Device Interrupt Target | ||
45 | Assignment */ | ||
46 | +#define I2C_CTRL_GLOBAL 0x0C /* Global Control Register */ | ||
47 | +#define I2C_CTRL_SRAM_EN BIT(0) | ||
48 | |||
49 | /* I2C Device (Bus) Register */ | ||
50 | |||
51 | @@ -XXX,XX +XXX,XX @@ static uint8_t aspeed_i2c_get_addr(AspeedI2CBus *bus) | ||
52 | } | ||
53 | } | ||
54 | |||
55 | +static bool aspeed_i2c_check_sram(AspeedI2CBus *bus) | ||
56 | +{ | ||
57 | + AspeedI2CState *s = bus->controller; | ||
58 | + AspeedI2CClass *aic = ASPEED_I2C_GET_CLASS(s); | ||
59 | + | ||
60 | + if (!aic->check_sram) { | ||
61 | + return true; | ||
62 | + } | ||
63 | + | ||
64 | + /* | ||
65 | + * AST2500: SRAM must be enabled before using the Buffer Pool or | ||
66 | + * DMA mode. | ||
67 | + */ | ||
68 | + if (!(s->ctrl_global & I2C_CTRL_SRAM_EN) && | ||
69 | + (bus->cmd & (I2CD_RX_DMA_ENABLE | I2CD_TX_DMA_ENABLE | | ||
70 | + I2CD_RX_BUFF_ENABLE | I2CD_TX_BUFF_ENABLE))) { | ||
71 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: SRAM is not enabled\n", __func__); | ||
72 | + return false; | ||
73 | + } | ||
74 | + | ||
75 | + return true; | ||
76 | +} | ||
77 | + | ||
78 | /* | ||
79 | * The state machine needs some refinement. It is only used to track | ||
80 | * invalid STOP commands for the moment. | ||
81 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value) | ||
82 | bus->cmd &= ~0xFFFF; | ||
83 | bus->cmd |= value & 0xFFFF; | ||
84 | |||
85 | + if (!aspeed_i2c_check_sram(bus)) { | ||
86 | + return; | ||
87 | + } | ||
88 | + | ||
89 | if (bus->cmd & I2CD_M_START_CMD) { | ||
90 | uint8_t state = aspeed_i2c_get_state(bus) & I2CD_MACTIVE ? | ||
91 | I2CD_MSTARTR : I2CD_MSTART; | ||
92 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_i2c_ctrl_read(void *opaque, hwaddr offset, | ||
93 | switch (offset) { | ||
94 | case I2C_CTRL_STATUS: | ||
95 | return s->intr_status; | ||
96 | + case I2C_CTRL_GLOBAL: | ||
97 | + return s->ctrl_global; | ||
98 | default: | ||
99 | qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIx "\n", | ||
100 | __func__, offset); | ||
101 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_i2c_ctrl_read(void *opaque, hwaddr offset, | ||
102 | static void aspeed_i2c_ctrl_write(void *opaque, hwaddr offset, | ||
103 | uint64_t value, unsigned size) | ||
104 | { | ||
105 | + AspeedI2CState *s = opaque; | ||
106 | + | ||
107 | switch (offset) { | ||
108 | + case I2C_CTRL_GLOBAL: | ||
109 | + s->ctrl_global = value; | ||
110 | + break; | ||
111 | case I2C_CTRL_STATUS: | ||
112 | default: | ||
113 | qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIx "\n", | ||
114 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2500_i2c_class_init(ObjectClass *klass, void *data) | ||
115 | aic->pool_size = 0x100; | ||
116 | aic->pool_base = 0x200; | ||
117 | aic->bus_pool_base = aspeed_2500_i2c_bus_pool_base; | ||
118 | + aic->check_sram = true; | ||
119 | } | ||
120 | |||
121 | static const TypeInfo aspeed_2500_i2c_info = { | ||
122 | -- | ||
123 | 2.20.1 | ||
124 | |||
125 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Cédric Le Goater <clg@kaod.org> | ||
2 | 1 | ||
3 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
4 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
5 | Tested-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com> | ||
6 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
8 | Message-id: 20191119141211.25716-6-clg@kaod.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/i2c/aspeed_i2c.c | 93 ++++++++++++++++++++++++++++++++++++++------- | ||
12 | hw/i2c/trace-events | 9 +++++ | ||
13 | 2 files changed, 89 insertions(+), 13 deletions(-) | ||
14 | |||
15 | diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/i2c/aspeed_i2c.c | ||
18 | +++ b/hw/i2c/aspeed_i2c.c | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | #include "hw/i2c/aspeed_i2c.h" | ||
21 | #include "hw/irq.h" | ||
22 | #include "hw/qdev-properties.h" | ||
23 | +#include "trace.h" | ||
24 | |||
25 | /* I2C Global Register */ | ||
26 | |||
27 | @@ -XXX,XX +XXX,XX @@ static inline void aspeed_i2c_bus_raise_interrupt(AspeedI2CBus *bus) | ||
28 | { | ||
29 | AspeedI2CClass *aic = ASPEED_I2C_GET_CLASS(bus->controller); | ||
30 | |||
31 | + trace_aspeed_i2c_bus_raise_interrupt(bus->intr_status, | ||
32 | + bus->intr_status & I2CD_INTR_TX_NAK ? "nak|" : "", | ||
33 | + bus->intr_status & I2CD_INTR_TX_ACK ? "ack|" : "", | ||
34 | + bus->intr_status & I2CD_INTR_RX_DONE ? "done|" : "", | ||
35 | + bus->intr_status & I2CD_INTR_NORMAL_STOP ? "normal|" : "", | ||
36 | + bus->intr_status & I2CD_INTR_ABNORMAL ? "abnormal" : ""); | ||
37 | + | ||
38 | bus->intr_status &= bus->intr_ctrl; | ||
39 | if (bus->intr_status) { | ||
40 | bus->controller->intr_status |= 1 << bus->id; | ||
41 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_i2c_bus_read(void *opaque, hwaddr offset, | ||
42 | { | ||
43 | AspeedI2CBus *bus = opaque; | ||
44 | AspeedI2CClass *aic = ASPEED_I2C_GET_CLASS(bus->controller); | ||
45 | + uint64_t value = -1; | ||
46 | |||
47 | switch (offset) { | ||
48 | case I2CD_FUN_CTRL_REG: | ||
49 | - return bus->ctrl; | ||
50 | + value = bus->ctrl; | ||
51 | + break; | ||
52 | case I2CD_AC_TIMING_REG1: | ||
53 | - return bus->timing[0]; | ||
54 | + value = bus->timing[0]; | ||
55 | + break; | ||
56 | case I2CD_AC_TIMING_REG2: | ||
57 | - return bus->timing[1]; | ||
58 | + value = bus->timing[1]; | ||
59 | + break; | ||
60 | case I2CD_INTR_CTRL_REG: | ||
61 | - return bus->intr_ctrl; | ||
62 | + value = bus->intr_ctrl; | ||
63 | + break; | ||
64 | case I2CD_INTR_STS_REG: | ||
65 | - return bus->intr_status; | ||
66 | + value = bus->intr_status; | ||
67 | + break; | ||
68 | case I2CD_POOL_CTRL_REG: | ||
69 | - return bus->pool_ctrl; | ||
70 | + value = bus->pool_ctrl; | ||
71 | + break; | ||
72 | case I2CD_BYTE_BUF_REG: | ||
73 | - return bus->buf; | ||
74 | + value = bus->buf; | ||
75 | + break; | ||
76 | case I2CD_CMD_REG: | ||
77 | - return bus->cmd | (i2c_bus_busy(bus->bus) << 16); | ||
78 | + value = bus->cmd | (i2c_bus_busy(bus->bus) << 16); | ||
79 | + break; | ||
80 | case I2CD_DMA_ADDR: | ||
81 | if (!aic->has_dma) { | ||
82 | qemu_log_mask(LOG_GUEST_ERROR, "%s: No DMA support\n", __func__); | ||
83 | - return -1; | ||
84 | + break; | ||
85 | } | ||
86 | - return bus->dma_addr; | ||
87 | + value = bus->dma_addr; | ||
88 | + break; | ||
89 | case I2CD_DMA_LEN: | ||
90 | if (!aic->has_dma) { | ||
91 | qemu_log_mask(LOG_GUEST_ERROR, "%s: No DMA support\n", __func__); | ||
92 | - return -1; | ||
93 | + break; | ||
94 | } | ||
95 | - return bus->dma_len; | ||
96 | + value = bus->dma_len; | ||
97 | + break; | ||
98 | + | ||
99 | default: | ||
100 | qemu_log_mask(LOG_GUEST_ERROR, | ||
101 | "%s: Bad offset 0x%" HWADDR_PRIx "\n", __func__, offset); | ||
102 | - return -1; | ||
103 | + value = -1; | ||
104 | + break; | ||
105 | } | ||
106 | + | ||
107 | + trace_aspeed_i2c_bus_read(bus->id, offset, size, value); | ||
108 | + return value; | ||
109 | } | ||
110 | |||
111 | static void aspeed_i2c_set_state(AspeedI2CBus *bus, uint8_t state) | ||
112 | @@ -XXX,XX +XXX,XX @@ static int aspeed_i2c_bus_send(AspeedI2CBus *bus, uint8_t pool_start) | ||
113 | for (i = pool_start; i < I2CD_POOL_TX_COUNT(bus->pool_ctrl); i++) { | ||
114 | uint8_t *pool_base = aic->bus_pool_base(bus); | ||
115 | |||
116 | + trace_aspeed_i2c_bus_send("BUF", i + 1, | ||
117 | + I2CD_POOL_TX_COUNT(bus->pool_ctrl), | ||
118 | + pool_base[i]); | ||
119 | ret = i2c_send(bus->bus, pool_base[i]); | ||
120 | if (ret) { | ||
121 | break; | ||
122 | @@ -XXX,XX +XXX,XX @@ static int aspeed_i2c_bus_send(AspeedI2CBus *bus, uint8_t pool_start) | ||
123 | while (bus->dma_len) { | ||
124 | uint8_t data; | ||
125 | aspeed_i2c_dma_read(bus, &data); | ||
126 | + trace_aspeed_i2c_bus_send("DMA", bus->dma_len, bus->dma_len, data); | ||
127 | ret = i2c_send(bus->bus, data); | ||
128 | if (ret) { | ||
129 | break; | ||
130 | @@ -XXX,XX +XXX,XX @@ static int aspeed_i2c_bus_send(AspeedI2CBus *bus, uint8_t pool_start) | ||
131 | } | ||
132 | bus->cmd &= ~I2CD_TX_DMA_ENABLE; | ||
133 | } else { | ||
134 | + trace_aspeed_i2c_bus_send("BYTE", pool_start, 1, bus->buf); | ||
135 | ret = i2c_send(bus->bus, bus->buf); | ||
136 | } | ||
137 | |||
138 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_recv(AspeedI2CBus *bus) | ||
139 | |||
140 | for (i = 0; i < I2CD_POOL_RX_SIZE(bus->pool_ctrl); i++) { | ||
141 | pool_base[i] = i2c_recv(bus->bus); | ||
142 | + trace_aspeed_i2c_bus_recv("BUF", i + 1, | ||
143 | + I2CD_POOL_RX_SIZE(bus->pool_ctrl), | ||
144 | + pool_base[i]); | ||
145 | } | ||
146 | |||
147 | /* Update RX count */ | ||
148 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_recv(AspeedI2CBus *bus) | ||
149 | MemTxResult result; | ||
150 | |||
151 | data = i2c_recv(bus->bus); | ||
152 | + trace_aspeed_i2c_bus_recv("DMA", bus->dma_len, bus->dma_len, data); | ||
153 | result = address_space_write(&s->dram_as, bus->dma_addr, | ||
154 | MEMTXATTRS_UNSPECIFIED, &data, 1); | ||
155 | if (result != MEMTX_OK) { | ||
156 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_recv(AspeedI2CBus *bus) | ||
157 | bus->cmd &= ~I2CD_RX_DMA_ENABLE; | ||
158 | } else { | ||
159 | data = i2c_recv(bus->bus); | ||
160 | + trace_aspeed_i2c_bus_recv("BYTE", 1, 1, bus->buf); | ||
161 | bus->buf = (data & I2CD_BYTE_BUF_RX_MASK) << I2CD_BYTE_BUF_RX_SHIFT; | ||
162 | } | ||
163 | } | ||
164 | @@ -XXX,XX +XXX,XX @@ static bool aspeed_i2c_check_sram(AspeedI2CBus *bus) | ||
165 | return true; | ||
166 | } | ||
167 | |||
168 | +static void aspeed_i2c_bus_cmd_dump(AspeedI2CBus *bus) | ||
169 | +{ | ||
170 | + g_autofree char *cmd_flags; | ||
171 | + uint32_t count; | ||
172 | + | ||
173 | + if (bus->cmd & (I2CD_RX_BUFF_ENABLE | I2CD_RX_BUFF_ENABLE)) { | ||
174 | + count = I2CD_POOL_TX_COUNT(bus->pool_ctrl); | ||
175 | + } else if (bus->cmd & (I2CD_RX_DMA_ENABLE | I2CD_RX_DMA_ENABLE)) { | ||
176 | + count = bus->dma_len; | ||
177 | + } else { /* BYTE mode */ | ||
178 | + count = 1; | ||
179 | + } | ||
180 | + | ||
181 | + cmd_flags = g_strdup_printf("%s%s%s%s%s%s%s%s%s", | ||
182 | + bus->cmd & I2CD_M_START_CMD ? "start|" : "", | ||
183 | + bus->cmd & I2CD_RX_DMA_ENABLE ? "rxdma|" : "", | ||
184 | + bus->cmd & I2CD_TX_DMA_ENABLE ? "txdma|" : "", | ||
185 | + bus->cmd & I2CD_RX_BUFF_ENABLE ? "rxbuf|" : "", | ||
186 | + bus->cmd & I2CD_TX_BUFF_ENABLE ? "txbuf|" : "", | ||
187 | + bus->cmd & I2CD_M_TX_CMD ? "tx|" : "", | ||
188 | + bus->cmd & I2CD_M_RX_CMD ? "rx|" : "", | ||
189 | + bus->cmd & I2CD_M_S_RX_CMD_LAST ? "last|" : "", | ||
190 | + bus->cmd & I2CD_M_STOP_CMD ? "stop" : ""); | ||
191 | + | ||
192 | + trace_aspeed_i2c_bus_cmd(bus->cmd, cmd_flags, count, bus->intr_status); | ||
193 | +} | ||
194 | + | ||
195 | /* | ||
196 | * The state machine needs some refinement. It is only used to track | ||
197 | * invalid STOP commands for the moment. | ||
198 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value) | ||
199 | return; | ||
200 | } | ||
201 | |||
202 | + if (trace_event_get_state_backends(TRACE_ASPEED_I2C_BUS_CMD)) { | ||
203 | + aspeed_i2c_bus_cmd_dump(bus); | ||
204 | + } | ||
205 | + | ||
206 | if (bus->cmd & I2CD_M_START_CMD) { | ||
207 | uint8_t state = aspeed_i2c_get_state(bus) & I2CD_MACTIVE ? | ||
208 | I2CD_MSTARTR : I2CD_MSTART; | ||
209 | @@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_write(void *opaque, hwaddr offset, | ||
210 | AspeedI2CClass *aic = ASPEED_I2C_GET_CLASS(bus->controller); | ||
211 | bool handle_rx; | ||
212 | |||
213 | + trace_aspeed_i2c_bus_write(bus->id, offset, size, value); | ||
214 | + | ||
215 | switch (offset) { | ||
216 | case I2CD_FUN_CTRL_REG: | ||
217 | if (value & I2CD_SLAVE_EN) { | ||
218 | diff --git a/hw/i2c/trace-events b/hw/i2c/trace-events | ||
219 | index XXXXXXX..XXXXXXX 100644 | ||
220 | --- a/hw/i2c/trace-events | ||
221 | +++ b/hw/i2c/trace-events | ||
222 | @@ -XXX,XX +XXX,XX @@ | ||
223 | i2c_event(const char *event, uint8_t address) "%s(addr:0x%02x)" | ||
224 | i2c_send(uint8_t address, uint8_t data) "send(addr:0x%02x) data:0x%02x" | ||
225 | i2c_recv(uint8_t address, uint8_t data) "recv(addr:0x%02x) data:0x%02x" | ||
226 | + | ||
227 | +# aspeed_i2c.c | ||
228 | + | ||
229 | +aspeed_i2c_bus_cmd(uint32_t cmd, const char *cmd_flags, uint32_t count, uint32_t intr_status) "handling cmd=0x%x %s count=%d intr=0x%x" | ||
230 | +aspeed_i2c_bus_raise_interrupt(uint32_t intr_status, const char *str1, const char *str2, const char *str3, const char *str4, const char *str5) "handled intr=0x%x %s%s%s%s%s" | ||
231 | +aspeed_i2c_bus_read(uint32_t busid, uint64_t offset, unsigned size, uint64_t value) "bus[%d]: To 0x%" PRIx64 " of size %u: 0x%" PRIx64 | ||
232 | +aspeed_i2c_bus_write(uint32_t busid, uint64_t offset, unsigned size, uint64_t value) "bus[%d]: To 0x%" PRIx64 " of size %u: 0x%" PRIx64 | ||
233 | +aspeed_i2c_bus_send(const char *mode, int i, int count, uint8_t byte) "%s send %d/%d 0x%02x" | ||
234 | +aspeed_i2c_bus_recv(const char *mode, int i, int count, uint8_t byte) "%s recv %d/%d 0x%02x" | ||
235 | -- | ||
236 | 2.20.1 | ||
237 | |||
238 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Joel Stanley <joel@jms.id.au> | ||
2 | 1 | ||
3 | Most boards have this much. | ||
4 | |||
5 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
8 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
9 | Message-id: 20191119141211.25716-7-clg@kaod.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/misc/aspeed_sdmc.c | 6 +++--- | ||
13 | 1 file changed, 3 insertions(+), 3 deletions(-) | ||
14 | |||
15 | diff --git a/hw/misc/aspeed_sdmc.c b/hw/misc/aspeed_sdmc.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/misc/aspeed_sdmc.c | ||
18 | +++ b/hw/misc/aspeed_sdmc.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static int ast2600_rambits(AspeedSDMCState *s) | ||
20 | } | ||
21 | |||
22 | /* use a common default */ | ||
23 | - warn_report("Invalid RAM size 0x%" PRIx64 ". Using default 512M", | ||
24 | + warn_report("Invalid RAM size 0x%" PRIx64 ". Using default 1024M", | ||
25 | s->ram_size); | ||
26 | - s->ram_size = 512 << 20; | ||
27 | - return ASPEED_SDMC_AST2600_512MB; | ||
28 | + s->ram_size = 1024 << 20; | ||
29 | + return ASPEED_SDMC_AST2600_1024MB; | ||
30 | } | ||
31 | |||
32 | static void aspeed_sdmc_reset(DeviceState *dev) | ||
33 | -- | ||
34 | 2.20.1 | ||
35 | |||
36 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Joel Stanley <joel@jms.id.au> | ||
2 | 1 | ||
3 | This models the clock write one to clear registers, and fixes up some | ||
4 | incorrect behavior in all of the write to clear registers. | ||
5 | |||
6 | There was also a typo in one of the register definitions. | ||
7 | |||
8 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
9 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
10 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
11 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
12 | Message-id: 20191119141211.25716-8-clg@kaod.org | ||
13 | [clg: checkpatch.pl fixes ] | ||
14 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | hw/misc/aspeed_scu.c | 19 ++++++++++++++----- | ||
18 | 1 file changed, 14 insertions(+), 5 deletions(-) | ||
19 | |||
20 | diff --git a/hw/misc/aspeed_scu.c b/hw/misc/aspeed_scu.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/hw/misc/aspeed_scu.c | ||
23 | +++ b/hw/misc/aspeed_scu.c | ||
24 | @@ -XXX,XX +XXX,XX @@ | ||
25 | #define AST2600_CLK_STOP_CTRL TO_REG(0x80) | ||
26 | #define AST2600_CLK_STOP_CTRL_CLR TO_REG(0x84) | ||
27 | #define AST2600_CLK_STOP_CTRL2 TO_REG(0x90) | ||
28 | -#define AST2600_CLK_STOP_CTR2L_CLR TO_REG(0x94) | ||
29 | +#define AST2600_CLK_STOP_CTRL2_CLR TO_REG(0x94) | ||
30 | #define AST2600_SDRAM_HANDSHAKE TO_REG(0x100) | ||
31 | #define AST2600_HPLL_PARAM TO_REG(0x200) | ||
32 | #define AST2600_HPLL_EXT TO_REG(0x204) | ||
33 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_ast2600_scu_read(void *opaque, hwaddr offset, | ||
34 | return s->regs[reg]; | ||
35 | } | ||
36 | |||
37 | -static void aspeed_ast2600_scu_write(void *opaque, hwaddr offset, uint64_t data, | ||
38 | - unsigned size) | ||
39 | +static void aspeed_ast2600_scu_write(void *opaque, hwaddr offset, | ||
40 | + uint64_t data64, unsigned size) | ||
41 | { | ||
42 | AspeedSCUState *s = ASPEED_SCU(opaque); | ||
43 | int reg = TO_REG(offset); | ||
44 | + /* Truncate here so bitwise operations below behave as expected */ | ||
45 | + uint32_t data = data64; | ||
46 | |||
47 | if (reg >= ASPEED_AST2600_SCU_NR_REGS) { | ||
48 | qemu_log_mask(LOG_GUEST_ERROR, | ||
49 | @@ -XXX,XX +XXX,XX @@ static void aspeed_ast2600_scu_write(void *opaque, hwaddr offset, uint64_t data, | ||
50 | /* fall through */ | ||
51 | case AST2600_SYS_RST_CTRL: | ||
52 | case AST2600_SYS_RST_CTRL2: | ||
53 | + case AST2600_CLK_STOP_CTRL: | ||
54 | + case AST2600_CLK_STOP_CTRL2: | ||
55 | /* W1S (Write 1 to set) registers */ | ||
56 | s->regs[reg] |= data; | ||
57 | return; | ||
58 | case AST2600_SYS_RST_CTRL_CLR: | ||
59 | case AST2600_SYS_RST_CTRL2_CLR: | ||
60 | + case AST2600_CLK_STOP_CTRL_CLR: | ||
61 | + case AST2600_CLK_STOP_CTRL2_CLR: | ||
62 | case AST2600_HW_STRAP1_CLR: | ||
63 | case AST2600_HW_STRAP2_CLR: | ||
64 | - /* W1C (Write 1 to clear) registers */ | ||
65 | - s->regs[reg] &= ~data; | ||
66 | + /* | ||
67 | + * W1C (Write 1 to clear) registers are offset by one address from | ||
68 | + * the data register | ||
69 | + */ | ||
70 | + s->regs[reg - 1] &= ~data; | ||
71 | return; | ||
72 | |||
73 | case AST2600_RNG_DATA: | ||
74 | -- | ||
75 | 2.20.1 | ||
76 | |||
77 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Joel Stanley <joel@jms.id.au> | ||
2 | 1 | ||
3 | Users benefit from knowing which watchdog timer has expired. The address | ||
4 | of the watchdog's registers unambiguously indicates which has expired, | ||
5 | so log that. | ||
6 | |||
7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
8 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
9 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
10 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
11 | Message-id: 20191119141211.25716-9-clg@kaod.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | hw/watchdog/wdt_aspeed.c | 3 ++- | ||
15 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
16 | |||
17 | diff --git a/hw/watchdog/wdt_aspeed.c b/hw/watchdog/wdt_aspeed.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/hw/watchdog/wdt_aspeed.c | ||
20 | +++ b/hw/watchdog/wdt_aspeed.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_timer_expired(void *dev) | ||
22 | return; | ||
23 | } | ||
24 | |||
25 | - qemu_log_mask(CPU_LOG_RESET, "Watchdog timer expired.\n"); | ||
26 | + qemu_log_mask(CPU_LOG_RESET, "Watchdog timer %" HWADDR_PRIx " expired.\n", | ||
27 | + s->iomem.addr); | ||
28 | watchdog_perform_action(); | ||
29 | timer_del(s->timer); | ||
30 | } | ||
31 | -- | ||
32 | 2.20.1 | ||
33 | |||
34 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Cédric Le Goater <clg@kaod.org> | ||
2 | 1 | ||
3 | The current model only restores the Segment Register values but leaves | ||
4 | the previous CS mapping behind. Introduce a helper setting the | ||
5 | register value and mapping the region at the requested address. Use | ||
6 | this helper when a Segment register is set and at reset. | ||
7 | |||
8 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
9 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
10 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
11 | Message-id: 20191119141211.25716-11-clg@kaod.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | hw/ssi/aspeed_smc.c | 32 +++++++++++++++++++++----------- | ||
15 | 1 file changed, 21 insertions(+), 11 deletions(-) | ||
16 | |||
17 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/hw/ssi/aspeed_smc.c | ||
20 | +++ b/hw/ssi/aspeed_smc.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static bool aspeed_smc_flash_overlap(const AspeedSMCState *s, | ||
22 | return false; | ||
23 | } | ||
24 | |||
25 | +static void aspeed_smc_flash_set_segment_region(AspeedSMCState *s, int cs, | ||
26 | + uint64_t regval) | ||
27 | +{ | ||
28 | + AspeedSMCFlash *fl = &s->flashes[cs]; | ||
29 | + AspeedSegments seg; | ||
30 | + | ||
31 | + s->ctrl->reg_to_segment(s, regval, &seg); | ||
32 | + | ||
33 | + memory_region_transaction_begin(); | ||
34 | + memory_region_set_size(&fl->mmio, seg.size); | ||
35 | + memory_region_set_address(&fl->mmio, seg.addr - s->ctrl->flash_window_base); | ||
36 | + memory_region_set_enabled(&fl->mmio, true); | ||
37 | + memory_region_transaction_commit(); | ||
38 | + | ||
39 | + s->regs[R_SEG_ADDR0 + cs] = regval; | ||
40 | +} | ||
41 | + | ||
42 | static void aspeed_smc_flash_set_segment(AspeedSMCState *s, int cs, | ||
43 | uint64_t new) | ||
44 | { | ||
45 | - AspeedSMCFlash *fl = &s->flashes[cs]; | ||
46 | AspeedSegments seg; | ||
47 | |||
48 | s->ctrl->reg_to_segment(s, new, &seg); | ||
49 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_flash_set_segment(AspeedSMCState *s, int cs, | ||
50 | aspeed_smc_flash_overlap(s, &seg, cs); | ||
51 | |||
52 | /* All should be fine now to move the region */ | ||
53 | - memory_region_transaction_begin(); | ||
54 | - memory_region_set_size(&fl->mmio, seg.size); | ||
55 | - memory_region_set_address(&fl->mmio, seg.addr - s->ctrl->flash_window_base); | ||
56 | - memory_region_set_enabled(&fl->mmio, true); | ||
57 | - memory_region_transaction_commit(); | ||
58 | - | ||
59 | - s->regs[R_SEG_ADDR0 + cs] = new; | ||
60 | + aspeed_smc_flash_set_segment_region(s, cs, new); | ||
61 | } | ||
62 | |||
63 | static uint64_t aspeed_smc_flash_default_read(void *opaque, hwaddr addr, | ||
64 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_reset(DeviceState *d) | ||
65 | qemu_set_irq(s->cs_lines[i], true); | ||
66 | } | ||
67 | |||
68 | - /* setup default segment register values for all */ | ||
69 | + /* setup the default segment register values and regions for all */ | ||
70 | for (i = 0; i < s->ctrl->max_slaves; ++i) { | ||
71 | - s->regs[R_SEG_ADDR0 + i] = | ||
72 | - s->ctrl->segment_to_reg(s, &s->ctrl->segments[i]); | ||
73 | + aspeed_smc_flash_set_segment_region(s, i, | ||
74 | + s->ctrl->segment_to_reg(s, &s->ctrl->segments[i])); | ||
75 | } | ||
76 | |||
77 | /* HW strapping flash type for the AST2600 controllers */ | ||
78 | -- | ||
79 | 2.20.1 | ||
80 | |||
81 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Cédric Le Goater <clg@kaod.org> | ||
2 | 1 | ||
3 | The segments can be disabled on the AST2600 (zero register value). | ||
4 | CS0 is open by default but not the other CS. This is closing the | ||
5 | access to the flash device in user mode and forbids scanning. | ||
6 | |||
7 | In the model, check the segment size and disable the associated region | ||
8 | when the value is zero. | ||
9 | |||
10 | Fixes: bcaa8ddd081c ("aspeed/smc: Add AST2600 support") | ||
11 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
12 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
13 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
14 | Message-id: 20191119141211.25716-12-clg@kaod.org | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | hw/ssi/aspeed_smc.c | 16 +++++++++++----- | ||
18 | 1 file changed, 11 insertions(+), 5 deletions(-) | ||
19 | |||
20 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/hw/ssi/aspeed_smc.c | ||
23 | +++ b/hw/ssi/aspeed_smc.c | ||
24 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2600_smc_reg_to_segment(const AspeedSMCState *s, | ||
25 | uint32_t start_offset = (reg << 16) & AST2600_SEG_ADDR_MASK; | ||
26 | uint32_t end_offset = reg & AST2600_SEG_ADDR_MASK; | ||
27 | |||
28 | - seg->addr = s->ctrl->flash_window_base + start_offset; | ||
29 | - seg->size = end_offset + MiB - start_offset; | ||
30 | + if (reg) { | ||
31 | + seg->addr = s->ctrl->flash_window_base + start_offset; | ||
32 | + seg->size = end_offset + MiB - start_offset; | ||
33 | + } else { | ||
34 | + seg->addr = s->ctrl->flash_window_base; | ||
35 | + seg->size = 0; | ||
36 | + } | ||
37 | } | ||
38 | |||
39 | static bool aspeed_smc_flash_overlap(const AspeedSMCState *s, | ||
40 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_flash_set_segment_region(AspeedSMCState *s, int cs, | ||
41 | memory_region_transaction_begin(); | ||
42 | memory_region_set_size(&fl->mmio, seg.size); | ||
43 | memory_region_set_address(&fl->mmio, seg.addr - s->ctrl->flash_window_base); | ||
44 | - memory_region_set_enabled(&fl->mmio, true); | ||
45 | + memory_region_set_enabled(&fl->mmio, !!seg.size); | ||
46 | memory_region_transaction_commit(); | ||
47 | |||
48 | s->regs[R_SEG_ADDR0 + cs] = regval; | ||
49 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_flash_set_segment(AspeedSMCState *s, int cs, | ||
50 | } | ||
51 | |||
52 | /* Keep the segment in the overall flash window */ | ||
53 | - if (seg.addr + seg.size <= s->ctrl->flash_window_base || | ||
54 | - seg.addr > s->ctrl->flash_window_base + s->ctrl->flash_window_size) { | ||
55 | + if (seg.size && | ||
56 | + (seg.addr + seg.size <= s->ctrl->flash_window_base || | ||
57 | + seg.addr > s->ctrl->flash_window_base + s->ctrl->flash_window_size)) { | ||
58 | qemu_log_mask(LOG_GUEST_ERROR, "%s: new segment for CS%d is invalid : " | ||
59 | "[ 0x%"HWADDR_PRIx" - 0x%"HWADDR_PRIx" ]\n", | ||
60 | s->ctrl->name, cs, seg.addr, seg.addr + seg.size); | ||
61 | -- | ||
62 | 2.20.1 | ||
63 | |||
64 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Cédric Le Goater <clg@kaod.org> | ||
2 | 1 | ||
3 | Each CS has its own Read Timing Compensation Register on newer SoCs. | ||
4 | |||
5 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
6 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
7 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
8 | Message-id: 20191119141211.25716-13-clg@kaod.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | include/hw/ssi/aspeed_smc.h | 1 + | ||
12 | hw/ssi/aspeed_smc.c | 17 ++++++++++++++--- | ||
13 | 2 files changed, 15 insertions(+), 3 deletions(-) | ||
14 | |||
15 | diff --git a/include/hw/ssi/aspeed_smc.h b/include/hw/ssi/aspeed_smc.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/include/hw/ssi/aspeed_smc.h | ||
18 | +++ b/include/hw/ssi/aspeed_smc.h | ||
19 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSMCController { | ||
20 | uint8_t r_ce_ctrl; | ||
21 | uint8_t r_ctrl0; | ||
22 | uint8_t r_timings; | ||
23 | + uint8_t nregs_timings; | ||
24 | uint8_t conf_enable_w0; | ||
25 | uint8_t max_slaves; | ||
26 | const AspeedSegments *segments; | ||
27 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/hw/ssi/aspeed_smc.c | ||
30 | +++ b/hw/ssi/aspeed_smc.c | ||
31 | @@ -XXX,XX +XXX,XX @@ | ||
32 | /* Checksum Calculation Result */ | ||
33 | #define R_DMA_CHECKSUM (0x90 / 4) | ||
34 | |||
35 | -/* Misc Control Register #2 */ | ||
36 | +/* Read Timing Compensation Register */ | ||
37 | #define R_TIMINGS (0x94 / 4) | ||
38 | |||
39 | /* SPI controller registers and bits (AST2400) */ | ||
40 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
41 | .r_ce_ctrl = R_CE_CTRL, | ||
42 | .r_ctrl0 = R_CTRL0, | ||
43 | .r_timings = R_TIMINGS, | ||
44 | + .nregs_timings = 1, | ||
45 | .conf_enable_w0 = CONF_ENABLE_W0, | ||
46 | .max_slaves = 5, | ||
47 | .segments = aspeed_segments_legacy, | ||
48 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
49 | .r_ce_ctrl = R_CE_CTRL, | ||
50 | .r_ctrl0 = R_CTRL0, | ||
51 | .r_timings = R_TIMINGS, | ||
52 | + .nregs_timings = 1, | ||
53 | .conf_enable_w0 = CONF_ENABLE_W0, | ||
54 | .max_slaves = 5, | ||
55 | .segments = aspeed_segments_fmc, | ||
56 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
57 | .r_ce_ctrl = 0xff, | ||
58 | .r_ctrl0 = R_SPI_CTRL0, | ||
59 | .r_timings = R_SPI_TIMINGS, | ||
60 | + .nregs_timings = 1, | ||
61 | .conf_enable_w0 = SPI_CONF_ENABLE_W0, | ||
62 | .max_slaves = 1, | ||
63 | .segments = aspeed_segments_spi, | ||
64 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
65 | .r_ce_ctrl = R_CE_CTRL, | ||
66 | .r_ctrl0 = R_CTRL0, | ||
67 | .r_timings = R_TIMINGS, | ||
68 | + .nregs_timings = 1, | ||
69 | .conf_enable_w0 = CONF_ENABLE_W0, | ||
70 | .max_slaves = 3, | ||
71 | .segments = aspeed_segments_ast2500_fmc, | ||
72 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
73 | .r_ce_ctrl = R_CE_CTRL, | ||
74 | .r_ctrl0 = R_CTRL0, | ||
75 | .r_timings = R_TIMINGS, | ||
76 | + .nregs_timings = 1, | ||
77 | .conf_enable_w0 = CONF_ENABLE_W0, | ||
78 | .max_slaves = 2, | ||
79 | .segments = aspeed_segments_ast2500_spi1, | ||
80 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
81 | .r_ce_ctrl = R_CE_CTRL, | ||
82 | .r_ctrl0 = R_CTRL0, | ||
83 | .r_timings = R_TIMINGS, | ||
84 | + .nregs_timings = 1, | ||
85 | .conf_enable_w0 = CONF_ENABLE_W0, | ||
86 | .max_slaves = 2, | ||
87 | .segments = aspeed_segments_ast2500_spi2, | ||
88 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
89 | .r_ce_ctrl = R_CE_CTRL, | ||
90 | .r_ctrl0 = R_CTRL0, | ||
91 | .r_timings = R_TIMINGS, | ||
92 | + .nregs_timings = 1, | ||
93 | .conf_enable_w0 = CONF_ENABLE_W0, | ||
94 | .max_slaves = 3, | ||
95 | .segments = aspeed_segments_ast2600_fmc, | ||
96 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
97 | .r_ce_ctrl = R_CE_CTRL, | ||
98 | .r_ctrl0 = R_CTRL0, | ||
99 | .r_timings = R_TIMINGS, | ||
100 | + .nregs_timings = 2, | ||
101 | .conf_enable_w0 = CONF_ENABLE_W0, | ||
102 | .max_slaves = 2, | ||
103 | .segments = aspeed_segments_ast2600_spi1, | ||
104 | @@ -XXX,XX +XXX,XX @@ static const AspeedSMCController controllers[] = { | ||
105 | .r_ce_ctrl = R_CE_CTRL, | ||
106 | .r_ctrl0 = R_CTRL0, | ||
107 | .r_timings = R_TIMINGS, | ||
108 | + .nregs_timings = 3, | ||
109 | .conf_enable_w0 = CONF_ENABLE_W0, | ||
110 | .max_slaves = 3, | ||
111 | .segments = aspeed_segments_ast2600_spi2, | ||
112 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_smc_read(void *opaque, hwaddr addr, unsigned int size) | ||
113 | addr >>= 2; | ||
114 | |||
115 | if (addr == s->r_conf || | ||
116 | - addr == s->r_timings || | ||
117 | + (addr >= s->r_timings && | ||
118 | + addr < s->r_timings + s->ctrl->nregs_timings) || | ||
119 | addr == s->r_ce_ctrl || | ||
120 | addr == R_INTR_CTRL || | ||
121 | addr == R_DUMMY_DATA || | ||
122 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_write(void *opaque, hwaddr addr, uint64_t data, | ||
123 | addr >>= 2; | ||
124 | |||
125 | if (addr == s->r_conf || | ||
126 | - addr == s->r_timings || | ||
127 | + (addr >= s->r_timings && | ||
128 | + addr < s->r_timings + s->ctrl->nregs_timings) || | ||
129 | addr == s->r_ce_ctrl) { | ||
130 | s->regs[addr] = value; | ||
131 | } else if (addr >= s->r_ctrl0 && addr < s->r_ctrl0 + s->num_cs) { | ||
132 | -- | ||
133 | 2.20.1 | ||
134 | |||
135 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Cédric Le Goater <clg@kaod.org> | ||
2 | 1 | ||
3 | AspeedBoardConfig is a redundant way to define class attributes and it | ||
4 | complexifies the machine definition and initialization. | ||
5 | |||
6 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
7 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
8 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
9 | Message-id: 20191119141211.25716-14-clg@kaod.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | include/hw/arm/aspeed.h | 24 ++-- | ||
13 | hw/arm/aspeed.c | 243 ++++++++++++++++++++++------------------ | ||
14 | 2 files changed, 143 insertions(+), 124 deletions(-) | ||
15 | |||
16 | diff --git a/include/hw/arm/aspeed.h b/include/hw/arm/aspeed.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/include/hw/arm/aspeed.h | ||
19 | +++ b/include/hw/arm/aspeed.h | ||
20 | @@ -XXX,XX +XXX,XX @@ | ||
21 | |||
22 | typedef struct AspeedBoardState AspeedBoardState; | ||
23 | |||
24 | -typedef struct AspeedBoardConfig { | ||
25 | - const char *name; | ||
26 | - const char *desc; | ||
27 | - const char *soc_name; | ||
28 | - uint32_t hw_strap1; | ||
29 | - uint32_t hw_strap2; | ||
30 | - const char *fmc_model; | ||
31 | - const char *spi_model; | ||
32 | - uint32_t num_cs; | ||
33 | - void (*i2c_init)(AspeedBoardState *bmc); | ||
34 | - uint32_t ram; | ||
35 | -} AspeedBoardConfig; | ||
36 | - | ||
37 | #define TYPE_ASPEED_MACHINE MACHINE_TYPE_NAME("aspeed") | ||
38 | #define ASPEED_MACHINE(obj) \ | ||
39 | OBJECT_CHECK(AspeedMachine, (obj), TYPE_ASPEED_MACHINE) | ||
40 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedMachine { | ||
41 | |||
42 | typedef struct AspeedMachineClass { | ||
43 | MachineClass parent_obj; | ||
44 | - const AspeedBoardConfig *board; | ||
45 | + | ||
46 | + const char *name; | ||
47 | + const char *desc; | ||
48 | + const char *soc_name; | ||
49 | + uint32_t hw_strap1; | ||
50 | + uint32_t hw_strap2; | ||
51 | + const char *fmc_model; | ||
52 | + const char *spi_model; | ||
53 | + uint32_t num_cs; | ||
54 | + void (*i2c_init)(AspeedBoardState *bmc); | ||
55 | } AspeedMachineClass; | ||
56 | |||
57 | |||
58 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | ||
59 | index XXXXXXX..XXXXXXX 100644 | ||
60 | --- a/hw/arm/aspeed.c | ||
61 | +++ b/hw/arm/aspeed.c | ||
62 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype, | ||
63 | } | ||
64 | } | ||
65 | |||
66 | -static void aspeed_board_init(MachineState *machine, | ||
67 | - const AspeedBoardConfig *cfg) | ||
68 | +static void aspeed_machine_init(MachineState *machine) | ||
69 | { | ||
70 | AspeedBoardState *bmc; | ||
71 | + AspeedMachineClass *amc = ASPEED_MACHINE_GET_CLASS(machine); | ||
72 | AspeedSoCClass *sc; | ||
73 | DriveInfo *drive0 = drive_get(IF_MTD, 0, 0); | ||
74 | ram_addr_t max_ram_size; | ||
75 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | ||
76 | UINT32_MAX); | ||
77 | |||
78 | object_initialize_child(OBJECT(machine), "soc", &bmc->soc, | ||
79 | - (sizeof(bmc->soc)), cfg->soc_name, &error_abort, | ||
80 | + (sizeof(bmc->soc)), amc->soc_name, &error_abort, | ||
81 | NULL); | ||
82 | |||
83 | sc = ASPEED_SOC_GET_CLASS(&bmc->soc); | ||
84 | |||
85 | object_property_set_uint(OBJECT(&bmc->soc), ram_size, "ram-size", | ||
86 | &error_abort); | ||
87 | - object_property_set_int(OBJECT(&bmc->soc), cfg->hw_strap1, "hw-strap1", | ||
88 | + object_property_set_int(OBJECT(&bmc->soc), amc->hw_strap1, "hw-strap1", | ||
89 | &error_abort); | ||
90 | - object_property_set_int(OBJECT(&bmc->soc), cfg->hw_strap2, "hw-strap2", | ||
91 | + object_property_set_int(OBJECT(&bmc->soc), amc->hw_strap2, "hw-strap2", | ||
92 | &error_abort); | ||
93 | - object_property_set_int(OBJECT(&bmc->soc), cfg->num_cs, "num-cs", | ||
94 | + object_property_set_int(OBJECT(&bmc->soc), amc->num_cs, "num-cs", | ||
95 | &error_abort); | ||
96 | object_property_set_int(OBJECT(&bmc->soc), machine->smp.cpus, "num-cpus", | ||
97 | &error_abort); | ||
98 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | ||
99 | "max_ram", max_ram_size - ram_size); | ||
100 | memory_region_add_subregion(&bmc->ram_container, ram_size, &bmc->max_ram); | ||
101 | |||
102 | - aspeed_board_init_flashes(&bmc->soc.fmc, cfg->fmc_model, &error_abort); | ||
103 | - aspeed_board_init_flashes(&bmc->soc.spi[0], cfg->spi_model, &error_abort); | ||
104 | + aspeed_board_init_flashes(&bmc->soc.fmc, amc->fmc_model, &error_abort); | ||
105 | + aspeed_board_init_flashes(&bmc->soc.spi[0], amc->spi_model, &error_abort); | ||
106 | |||
107 | /* Install first FMC flash content as a boot rom. */ | ||
108 | if (drive0) { | ||
109 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | ||
110 | aspeed_board_binfo.loader_start = sc->memmap[ASPEED_SDRAM]; | ||
111 | aspeed_board_binfo.nb_cpus = bmc->soc.num_cpus; | ||
112 | |||
113 | - if (cfg->i2c_init) { | ||
114 | - cfg->i2c_init(bmc); | ||
115 | + if (amc->i2c_init) { | ||
116 | + amc->i2c_init(bmc); | ||
117 | } | ||
118 | |||
119 | for (i = 0; i < ARRAY_SIZE(bmc->soc.sdhci.slots); i++) { | ||
120 | @@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc) | ||
121 | 0x60); | ||
122 | } | ||
123 | |||
124 | -static void aspeed_machine_init(MachineState *machine) | ||
125 | -{ | ||
126 | - AspeedMachineClass *amc = ASPEED_MACHINE_GET_CLASS(machine); | ||
127 | - | ||
128 | - aspeed_board_init(machine, amc->board); | ||
129 | -} | ||
130 | - | ||
131 | static void aspeed_machine_class_init(ObjectClass *oc, void *data) | ||
132 | { | ||
133 | MachineClass *mc = MACHINE_CLASS(oc); | ||
134 | - AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); | ||
135 | - const AspeedBoardConfig *board = data; | ||
136 | |||
137 | - mc->desc = board->desc; | ||
138 | mc->init = aspeed_machine_init; | ||
139 | mc->max_cpus = ASPEED_CPUS_NUM; | ||
140 | mc->no_floppy = 1; | ||
141 | mc->no_cdrom = 1; | ||
142 | mc->no_parallel = 1; | ||
143 | - if (board->ram) { | ||
144 | - mc->default_ram_size = board->ram; | ||
145 | - } | ||
146 | - amc->board = board; | ||
147 | } | ||
148 | |||
149 | -static const TypeInfo aspeed_machine_type = { | ||
150 | - .name = TYPE_ASPEED_MACHINE, | ||
151 | - .parent = TYPE_MACHINE, | ||
152 | - .instance_size = sizeof(AspeedMachine), | ||
153 | - .class_size = sizeof(AspeedMachineClass), | ||
154 | - .abstract = true, | ||
155 | -}; | ||
156 | - | ||
157 | -static const AspeedBoardConfig aspeed_boards[] = { | ||
158 | - { | ||
159 | - .name = MACHINE_TYPE_NAME("palmetto-bmc"), | ||
160 | - .desc = "OpenPOWER Palmetto BMC (ARM926EJ-S)", | ||
161 | - .soc_name = "ast2400-a1", | ||
162 | - .hw_strap1 = PALMETTO_BMC_HW_STRAP1, | ||
163 | - .fmc_model = "n25q256a", | ||
164 | - .spi_model = "mx25l25635e", | ||
165 | - .num_cs = 1, | ||
166 | - .i2c_init = palmetto_bmc_i2c_init, | ||
167 | - .ram = 256 * MiB, | ||
168 | - }, { | ||
169 | - .name = MACHINE_TYPE_NAME("ast2500-evb"), | ||
170 | - .desc = "Aspeed AST2500 EVB (ARM1176)", | ||
171 | - .soc_name = "ast2500-a1", | ||
172 | - .hw_strap1 = AST2500_EVB_HW_STRAP1, | ||
173 | - .fmc_model = "w25q256", | ||
174 | - .spi_model = "mx25l25635e", | ||
175 | - .num_cs = 1, | ||
176 | - .i2c_init = ast2500_evb_i2c_init, | ||
177 | - .ram = 512 * MiB, | ||
178 | - }, { | ||
179 | - .name = MACHINE_TYPE_NAME("romulus-bmc"), | ||
180 | - .desc = "OpenPOWER Romulus BMC (ARM1176)", | ||
181 | - .soc_name = "ast2500-a1", | ||
182 | - .hw_strap1 = ROMULUS_BMC_HW_STRAP1, | ||
183 | - .fmc_model = "n25q256a", | ||
184 | - .spi_model = "mx66l1g45g", | ||
185 | - .num_cs = 2, | ||
186 | - .i2c_init = romulus_bmc_i2c_init, | ||
187 | - .ram = 512 * MiB, | ||
188 | - }, { | ||
189 | - .name = MACHINE_TYPE_NAME("swift-bmc"), | ||
190 | - .desc = "OpenPOWER Swift BMC (ARM1176)", | ||
191 | - .soc_name = "ast2500-a1", | ||
192 | - .hw_strap1 = SWIFT_BMC_HW_STRAP1, | ||
193 | - .fmc_model = "mx66l1g45g", | ||
194 | - .spi_model = "mx66l1g45g", | ||
195 | - .num_cs = 2, | ||
196 | - .i2c_init = swift_bmc_i2c_init, | ||
197 | - .ram = 512 * MiB, | ||
198 | - }, { | ||
199 | - .name = MACHINE_TYPE_NAME("witherspoon-bmc"), | ||
200 | - .desc = "OpenPOWER Witherspoon BMC (ARM1176)", | ||
201 | - .soc_name = "ast2500-a1", | ||
202 | - .hw_strap1 = WITHERSPOON_BMC_HW_STRAP1, | ||
203 | - .fmc_model = "mx25l25635e", | ||
204 | - .spi_model = "mx66l1g45g", | ||
205 | - .num_cs = 2, | ||
206 | - .i2c_init = witherspoon_bmc_i2c_init, | ||
207 | - .ram = 512 * MiB, | ||
208 | - }, { | ||
209 | - .name = MACHINE_TYPE_NAME("ast2600-evb"), | ||
210 | - .desc = "Aspeed AST2600 EVB (Cortex A7)", | ||
211 | - .soc_name = "ast2600-a0", | ||
212 | - .hw_strap1 = AST2600_EVB_HW_STRAP1, | ||
213 | - .hw_strap2 = AST2600_EVB_HW_STRAP2, | ||
214 | - .fmc_model = "w25q512jv", | ||
215 | - .spi_model = "mx66u51235f", | ||
216 | - .num_cs = 1, | ||
217 | - .i2c_init = ast2600_evb_i2c_init, | ||
218 | - .ram = 1 * GiB, | ||
219 | - }, | ||
220 | -}; | ||
221 | - | ||
222 | -static void aspeed_machine_types(void) | ||
223 | +static void aspeed_machine_palmetto_class_init(ObjectClass *oc, void *data) | ||
224 | { | ||
225 | - int i; | ||
226 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
227 | + AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); | ||
228 | |||
229 | - type_register_static(&aspeed_machine_type); | ||
230 | - for (i = 0; i < ARRAY_SIZE(aspeed_boards); ++i) { | ||
231 | - TypeInfo ti = { | ||
232 | - .name = aspeed_boards[i].name, | ||
233 | - .parent = TYPE_ASPEED_MACHINE, | ||
234 | - .class_init = aspeed_machine_class_init, | ||
235 | - .class_data = (void *)&aspeed_boards[i], | ||
236 | - }; | ||
237 | - type_register(&ti); | ||
238 | + mc->desc = "OpenPOWER Palmetto BMC (ARM926EJ-S)"; | ||
239 | + amc->soc_name = "ast2400-a1"; | ||
240 | + amc->hw_strap1 = PALMETTO_BMC_HW_STRAP1; | ||
241 | + amc->fmc_model = "n25q256a"; | ||
242 | + amc->spi_model = "mx25l25635e"; | ||
243 | + amc->num_cs = 1; | ||
244 | + amc->i2c_init = palmetto_bmc_i2c_init; | ||
245 | + mc->default_ram_size = 256 * MiB; | ||
246 | +}; | ||
247 | + | ||
248 | +static void aspeed_machine_ast2500_evb_class_init(ObjectClass *oc, void *data) | ||
249 | +{ | ||
250 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
251 | + AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); | ||
252 | + | ||
253 | + mc->desc = "Aspeed AST2500 EVB (ARM1176)"; | ||
254 | + amc->soc_name = "ast2500-a1"; | ||
255 | + amc->hw_strap1 = AST2500_EVB_HW_STRAP1; | ||
256 | + amc->fmc_model = "w25q256"; | ||
257 | + amc->spi_model = "mx25l25635e"; | ||
258 | + amc->num_cs = 1; | ||
259 | + amc->i2c_init = ast2500_evb_i2c_init; | ||
260 | + mc->default_ram_size = 512 * MiB; | ||
261 | +}; | ||
262 | + | ||
263 | +static void aspeed_machine_romulus_class_init(ObjectClass *oc, void *data) | ||
264 | +{ | ||
265 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
266 | + AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); | ||
267 | + | ||
268 | + mc->desc = "OpenPOWER Romulus BMC (ARM1176)"; | ||
269 | + amc->soc_name = "ast2500-a1"; | ||
270 | + amc->hw_strap1 = ROMULUS_BMC_HW_STRAP1; | ||
271 | + amc->fmc_model = "n25q256a"; | ||
272 | + amc->spi_model = "mx66l1g45g"; | ||
273 | + amc->num_cs = 2; | ||
274 | + amc->i2c_init = romulus_bmc_i2c_init; | ||
275 | + mc->default_ram_size = 512 * MiB; | ||
276 | +}; | ||
277 | + | ||
278 | +static void aspeed_machine_swift_class_init(ObjectClass *oc, void *data) | ||
279 | +{ | ||
280 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
281 | + AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); | ||
282 | + | ||
283 | + mc->desc = "OpenPOWER Swift BMC (ARM1176)"; | ||
284 | + amc->soc_name = "ast2500-a1"; | ||
285 | + amc->hw_strap1 = SWIFT_BMC_HW_STRAP1; | ||
286 | + amc->fmc_model = "mx66l1g45g"; | ||
287 | + amc->spi_model = "mx66l1g45g"; | ||
288 | + amc->num_cs = 2; | ||
289 | + amc->i2c_init = swift_bmc_i2c_init; | ||
290 | + mc->default_ram_size = 512 * MiB; | ||
291 | +}; | ||
292 | + | ||
293 | +static void aspeed_machine_witherspoon_class_init(ObjectClass *oc, void *data) | ||
294 | +{ | ||
295 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
296 | + AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); | ||
297 | + | ||
298 | + mc->desc = "OpenPOWER Witherspoon BMC (ARM1176)"; | ||
299 | + amc->soc_name = "ast2500-a1"; | ||
300 | + amc->hw_strap1 = WITHERSPOON_BMC_HW_STRAP1; | ||
301 | + amc->fmc_model = "mx25l25635e"; | ||
302 | + amc->spi_model = "mx66l1g45g"; | ||
303 | + amc->num_cs = 2; | ||
304 | + amc->i2c_init = witherspoon_bmc_i2c_init; | ||
305 | + mc->default_ram_size = 512 * MiB; | ||
306 | +}; | ||
307 | + | ||
308 | +static void aspeed_machine_ast2600_evb_class_init(ObjectClass *oc, void *data) | ||
309 | +{ | ||
310 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
311 | + AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); | ||
312 | + | ||
313 | + mc->desc = "Aspeed AST2600 EVB (Cortex A7)"; | ||
314 | + amc->soc_name = "ast2600-a0"; | ||
315 | + amc->hw_strap1 = AST2600_EVB_HW_STRAP1; | ||
316 | + amc->hw_strap2 = AST2600_EVB_HW_STRAP2; | ||
317 | + amc->fmc_model = "w25q512jv"; | ||
318 | + amc->spi_model = "mx66u51235f"; | ||
319 | + amc->num_cs = 1; | ||
320 | + amc->i2c_init = ast2600_evb_i2c_init; | ||
321 | + mc->default_ram_size = 1 * GiB; | ||
322 | +}; | ||
323 | + | ||
324 | +static const TypeInfo aspeed_machine_types[] = { | ||
325 | + { | ||
326 | + .name = MACHINE_TYPE_NAME("palmetto-bmc"), | ||
327 | + .parent = TYPE_ASPEED_MACHINE, | ||
328 | + .class_init = aspeed_machine_palmetto_class_init, | ||
329 | + }, { | ||
330 | + .name = MACHINE_TYPE_NAME("ast2500-evb"), | ||
331 | + .parent = TYPE_ASPEED_MACHINE, | ||
332 | + .class_init = aspeed_machine_ast2500_evb_class_init, | ||
333 | + }, { | ||
334 | + .name = MACHINE_TYPE_NAME("romulus-bmc"), | ||
335 | + .parent = TYPE_ASPEED_MACHINE, | ||
336 | + .class_init = aspeed_machine_romulus_class_init, | ||
337 | + }, { | ||
338 | + .name = MACHINE_TYPE_NAME("swift-bmc"), | ||
339 | + .parent = TYPE_ASPEED_MACHINE, | ||
340 | + .class_init = aspeed_machine_swift_class_init, | ||
341 | + }, { | ||
342 | + .name = MACHINE_TYPE_NAME("witherspoon-bmc"), | ||
343 | + .parent = TYPE_ASPEED_MACHINE, | ||
344 | + .class_init = aspeed_machine_witherspoon_class_init, | ||
345 | + }, { | ||
346 | + .name = MACHINE_TYPE_NAME("ast2600-evb"), | ||
347 | + .parent = TYPE_ASPEED_MACHINE, | ||
348 | + .class_init = aspeed_machine_ast2600_evb_class_init, | ||
349 | + }, { | ||
350 | + .name = TYPE_ASPEED_MACHINE, | ||
351 | + .parent = TYPE_MACHINE, | ||
352 | + .instance_size = sizeof(AspeedMachine), | ||
353 | + .class_size = sizeof(AspeedMachineClass), | ||
354 | + .class_init = aspeed_machine_class_init, | ||
355 | + .abstract = true, | ||
356 | } | ||
357 | -} | ||
358 | +}; | ||
359 | |||
360 | -type_init(aspeed_machine_types) | ||
361 | +DEFINE_TYPES(aspeed_machine_types) | ||
362 | -- | ||
363 | 2.20.1 | ||
364 | |||
365 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Cédric Le Goater <clg@kaod.org> | ||
2 | 1 | ||
3 | The Tacoma BMC board is replacement board for the BMC of the OpenPOWER | ||
4 | Witherspoon system. It uses a AST2600 SoC instead of a AST2500 and the | ||
5 | I2C layout is the same as it controls the same main board. Used for HW | ||
6 | bringup. | ||
7 | |||
8 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
9 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
10 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
11 | Message-id: 20191119141211.25716-15-clg@kaod.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | hw/arm/aspeed.c | 28 ++++++++++++++++++++++++++++ | ||
15 | 1 file changed, 28 insertions(+) | ||
16 | |||
17 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/hw/arm/aspeed.c | ||
20 | +++ b/hw/arm/aspeed.c | ||
21 | @@ -XXX,XX +XXX,XX @@ struct AspeedBoardState { | ||
22 | #define AST2600_EVB_HW_STRAP1 0x000000C0 | ||
23 | #define AST2600_EVB_HW_STRAP2 0x00000003 | ||
24 | |||
25 | +/* Tacoma hardware value */ | ||
26 | +#define TACOMA_BMC_HW_STRAP1 0x00000000 | ||
27 | +#define TACOMA_BMC_HW_STRAP2 0x00000000 | ||
28 | + | ||
29 | /* | ||
30 | * The max ram region is for firmwares that scan the address space | ||
31 | * with load/store to guess how much RAM the SoC has. | ||
32 | @@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc) | ||
33 | AspeedSoCState *soc = &bmc->soc; | ||
34 | uint8_t *eeprom_buf = g_malloc0(8 * 1024); | ||
35 | |||
36 | + /* Bus 3: TODO bmp280@77 */ | ||
37 | + /* Bus 3: TODO max31785@52 */ | ||
38 | + /* Bus 3: TODO dps310@76 */ | ||
39 | i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), TYPE_PCA9552, | ||
40 | 0x60); | ||
41 | |||
42 | @@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc) | ||
43 | eeprom_buf); | ||
44 | i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), TYPE_PCA9552, | ||
45 | 0x60); | ||
46 | + /* Bus 11: TODO ucd90160@64 */ | ||
47 | } | ||
48 | |||
49 | static void aspeed_machine_class_init(ObjectClass *oc, void *data) | ||
50 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_ast2600_evb_class_init(ObjectClass *oc, void *data) | ||
51 | mc->default_ram_size = 1 * GiB; | ||
52 | }; | ||
53 | |||
54 | +static void aspeed_machine_tacoma_class_init(ObjectClass *oc, void *data) | ||
55 | +{ | ||
56 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
57 | + AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); | ||
58 | + | ||
59 | + mc->desc = "Aspeed AST2600 EVB (Cortex A7)"; | ||
60 | + amc->soc_name = "ast2600-a0"; | ||
61 | + amc->hw_strap1 = TACOMA_BMC_HW_STRAP1; | ||
62 | + amc->hw_strap2 = TACOMA_BMC_HW_STRAP2; | ||
63 | + amc->fmc_model = "mx66l1g45g"; | ||
64 | + amc->spi_model = "mx66l1g45g"; | ||
65 | + amc->num_cs = 2; | ||
66 | + amc->i2c_init = witherspoon_bmc_i2c_init; /* Same board layout */ | ||
67 | + mc->default_ram_size = 1 * GiB; | ||
68 | +}; | ||
69 | + | ||
70 | static const TypeInfo aspeed_machine_types[] = { | ||
71 | { | ||
72 | .name = MACHINE_TYPE_NAME("palmetto-bmc"), | ||
73 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo aspeed_machine_types[] = { | ||
74 | .name = MACHINE_TYPE_NAME("ast2600-evb"), | ||
75 | .parent = TYPE_ASPEED_MACHINE, | ||
76 | .class_init = aspeed_machine_ast2600_evb_class_init, | ||
77 | + }, { | ||
78 | + .name = MACHINE_TYPE_NAME("tacoma-bmc"), | ||
79 | + .parent = TYPE_ASPEED_MACHINE, | ||
80 | + .class_init = aspeed_machine_tacoma_class_init, | ||
81 | }, { | ||
82 | .name = TYPE_ASPEED_MACHINE, | ||
83 | .parent = TYPE_MACHINE, | ||
84 | -- | ||
85 | 2.20.1 | ||
86 | |||
87 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: PanNengyuan <pannengyuan@huawei.com> | ||
2 | 1 | ||
3 | Address Sanitizer shows memory leak in hw/gpio/aspeed_gpio.c:875 | ||
4 | |||
5 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
6 | Signed-off-by: PanNengyuan <pannengyuan@huawei.com> | ||
7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
8 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
9 | Message-id: 20191119141211.25716-16-clg@kaod.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/gpio/aspeed_gpio.c | 1 + | ||
13 | 1 file changed, 1 insertion(+) | ||
14 | |||
15 | diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/gpio/aspeed_gpio.c | ||
18 | +++ b/hw/gpio/aspeed_gpio.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static void aspeed_gpio_init(Object *obj) | ||
20 | pin_idx % GPIOS_PER_GROUP); | ||
21 | object_property_add(obj, name, "bool", aspeed_gpio_get_pin, | ||
22 | aspeed_gpio_set_pin, NULL, NULL, NULL); | ||
23 | + g_free(name); | ||
24 | } | ||
25 | } | ||
26 | |||
27 | -- | ||
28 | 2.20.1 | ||
29 | |||
30 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Cédric Le Goater <clg@kaod.org> | ||
2 | 1 | ||
3 | The Aspeed MII model has a link pointing to its associated FTGMAC100 | ||
4 | NIC in the machine. | ||
5 | |||
6 | Change the "nic" property definition so that it explicitly sets the | ||
7 | pointer. The property isn't optional : not being able to set the link | ||
8 | is a bug and QEMU should rather abort than exit in this case. | ||
9 | |||
10 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
11 | Reviewed-by: Greg Kurz <groug@kaod.org> | ||
12 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
13 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
14 | Message-id: 20191119141211.25716-18-clg@kaod.org | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | hw/arm/aspeed_ast2600.c | 5 ++--- | ||
18 | hw/net/ftgmac100.c | 19 +++++++++---------- | ||
19 | 2 files changed, 11 insertions(+), 13 deletions(-) | ||
20 | |||
21 | diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/hw/arm/aspeed_ast2600.c | ||
24 | +++ b/hw/arm/aspeed_ast2600.c | ||
25 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj) | ||
26 | |||
27 | sysbus_init_child_obj(obj, "mii[*]", &s->mii[i], sizeof(s->mii[i]), | ||
28 | TYPE_ASPEED_MII); | ||
29 | - object_property_add_const_link(OBJECT(&s->mii[i]), "nic", | ||
30 | - OBJECT(&s->ftgmac100[i]), | ||
31 | - &error_abort); | ||
32 | } | ||
33 | |||
34 | sysbus_init_child_obj(obj, "xdma", OBJECT(&s->xdma), sizeof(s->xdma), | ||
35 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) | ||
36 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, | ||
37 | aspeed_soc_get_irq(s, ASPEED_ETH1 + i)); | ||
38 | |||
39 | + object_property_set_link(OBJECT(&s->mii[i]), OBJECT(&s->ftgmac100[i]), | ||
40 | + "nic", &error_abort); | ||
41 | object_property_set_bool(OBJECT(&s->mii[i]), true, "realized", | ||
42 | &err); | ||
43 | if (err) { | ||
44 | diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/hw/net/ftgmac100.c | ||
47 | +++ b/hw/net/ftgmac100.c | ||
48 | @@ -XXX,XX +XXX,XX @@ static void aspeed_mii_realize(DeviceState *dev, Error **errp) | ||
49 | { | ||
50 | AspeedMiiState *s = ASPEED_MII(dev); | ||
51 | SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
52 | - Object *obj; | ||
53 | - Error *local_err = NULL; | ||
54 | |||
55 | - obj = object_property_get_link(OBJECT(dev), "nic", &local_err); | ||
56 | - if (!obj) { | ||
57 | - error_propagate(errp, local_err); | ||
58 | - error_prepend(errp, "required link 'nic' not found: "); | ||
59 | - return; | ||
60 | - } | ||
61 | - | ||
62 | - s->nic = FTGMAC100(obj); | ||
63 | + assert(s->nic); | ||
64 | |||
65 | memory_region_init_io(&s->iomem, OBJECT(dev), &aspeed_mii_ops, s, | ||
66 | TYPE_ASPEED_MII, 0x8); | ||
67 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_aspeed_mii = { | ||
68 | VMSTATE_END_OF_LIST() | ||
69 | } | ||
70 | }; | ||
71 | + | ||
72 | +static Property aspeed_mii_properties[] = { | ||
73 | + DEFINE_PROP_LINK("nic", AspeedMiiState, nic, TYPE_FTGMAC100, | ||
74 | + FTGMAC100State *), | ||
75 | + DEFINE_PROP_END_OF_LIST(), | ||
76 | +}; | ||
77 | + | ||
78 | static void aspeed_mii_class_init(ObjectClass *klass, void *data) | ||
79 | { | ||
80 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
81 | @@ -XXX,XX +XXX,XX @@ static void aspeed_mii_class_init(ObjectClass *klass, void *data) | ||
82 | dc->reset = aspeed_mii_reset; | ||
83 | dc->realize = aspeed_mii_realize; | ||
84 | dc->desc = "Aspeed MII controller"; | ||
85 | + dc->props = aspeed_mii_properties; | ||
86 | } | ||
87 | |||
88 | static const TypeInfo aspeed_mii_info = { | ||
89 | -- | ||
90 | 2.20.1 | ||
91 | |||
92 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Marc Zyngier <maz@kernel.org> | ||
2 | 1 | ||
3 | HCR_EL2.TID3 requires that AArch32 reads of MVFR[012] are trapped to | ||
4 | EL2, and HCR_EL2.TID0 does the same for reads of FPSID. | ||
5 | In order to handle this, introduce a new TCG helper function that | ||
6 | checks for these control bits before executing the VMRC instruction. | ||
7 | |||
8 | Tested with a hacked-up version of KVM/arm64 that sets the control | ||
9 | bits for 32bit guests. | ||
10 | |||
11 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
12 | Signed-off-by: Marc Zyngier <maz@kernel.org> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20191201122018.25808-4-maz@kernel.org | ||
15 | [PMM: move helper declaration to helper.h; make it | ||
16 | TCG_CALL_NO_WG] | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | --- | ||
19 | target/arm/helper.h | 2 ++ | ||
20 | target/arm/translate-vfp.inc.c | 20 ++++++++++++++++---- | ||
21 | target/arm/vfp_helper.c | 29 +++++++++++++++++++++++++++++ | ||
22 | 3 files changed, 47 insertions(+), 4 deletions(-) | ||
23 | |||
24 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/arm/helper.h | ||
27 | +++ b/target/arm/helper.h | ||
28 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_2(rintd, TCG_CALL_NO_RWG, f64, f64, ptr) | ||
29 | DEF_HELPER_FLAGS_2(vjcvt, TCG_CALL_NO_RWG, i32, f64, env) | ||
30 | DEF_HELPER_FLAGS_2(fjcvtzs, TCG_CALL_NO_RWG, i64, f64, ptr) | ||
31 | |||
32 | +DEF_HELPER_FLAGS_3(check_hcr_el2_trap, TCG_CALL_NO_WG, void, env, i32, i32) | ||
33 | + | ||
34 | /* neon_helper.c */ | ||
35 | DEF_HELPER_FLAGS_3(neon_qadd_u8, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
36 | DEF_HELPER_FLAGS_3(neon_qadd_s8, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
37 | diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/target/arm/translate-vfp.inc.c | ||
40 | +++ b/target/arm/translate-vfp.inc.c | ||
41 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMSR_VMRS(DisasContext *s, arg_VMSR_VMRS *a) | ||
42 | if (a->l) { | ||
43 | /* VMRS, move VFP special register to gp register */ | ||
44 | switch (a->reg) { | ||
45 | - case ARM_VFP_FPSID: | ||
46 | - case ARM_VFP_FPEXC: | ||
47 | - case ARM_VFP_FPINST: | ||
48 | - case ARM_VFP_FPINST2: | ||
49 | case ARM_VFP_MVFR0: | ||
50 | case ARM_VFP_MVFR1: | ||
51 | case ARM_VFP_MVFR2: | ||
52 | + case ARM_VFP_FPSID: | ||
53 | + if (s->current_el == 1) { | ||
54 | + TCGv_i32 tcg_reg, tcg_rt; | ||
55 | + | ||
56 | + gen_set_condexec(s); | ||
57 | + gen_set_pc_im(s, s->pc_curr); | ||
58 | + tcg_reg = tcg_const_i32(a->reg); | ||
59 | + tcg_rt = tcg_const_i32(a->rt); | ||
60 | + gen_helper_check_hcr_el2_trap(cpu_env, tcg_rt, tcg_reg); | ||
61 | + tcg_temp_free_i32(tcg_reg); | ||
62 | + tcg_temp_free_i32(tcg_rt); | ||
63 | + } | ||
64 | + /* fall through */ | ||
65 | + case ARM_VFP_FPEXC: | ||
66 | + case ARM_VFP_FPINST: | ||
67 | + case ARM_VFP_FPINST2: | ||
68 | tmp = load_cpu_field(vfp.xregs[a->reg]); | ||
69 | break; | ||
70 | case ARM_VFP_FPSCR: | ||
71 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/target/arm/vfp_helper.c | ||
74 | +++ b/target/arm/vfp_helper.c | ||
75 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(frint64_d)(float64 f, void *fpst) | ||
76 | return frint_d(f, fpst, 64); | ||
77 | } | ||
78 | |||
79 | +void HELPER(check_hcr_el2_trap)(CPUARMState *env, uint32_t rt, uint32_t reg) | ||
80 | +{ | ||
81 | + uint32_t syndrome; | ||
82 | + | ||
83 | + switch (reg) { | ||
84 | + case ARM_VFP_MVFR0: | ||
85 | + case ARM_VFP_MVFR1: | ||
86 | + case ARM_VFP_MVFR2: | ||
87 | + if (!(arm_hcr_el2_eff(env) & HCR_TID3)) { | ||
88 | + return; | ||
89 | + } | ||
90 | + break; | ||
91 | + case ARM_VFP_FPSID: | ||
92 | + if (!(arm_hcr_el2_eff(env) & HCR_TID0)) { | ||
93 | + return; | ||
94 | + } | ||
95 | + break; | ||
96 | + default: | ||
97 | + g_assert_not_reached(); | ||
98 | + } | ||
99 | + | ||
100 | + syndrome = ((EC_FPIDTRAP << ARM_EL_EC_SHIFT) | ||
101 | + | ARM_EL_IL | ||
102 | + | (1 << 24) | (0xe << 20) | (7 << 14) | ||
103 | + | (reg << 10) | (rt << 5) | 1); | ||
104 | + | ||
105 | + raise_exception(env, EXCP_HYP_TRAP, syndrome, 2); | ||
106 | +} | ||
107 | + | ||
108 | #endif | ||
109 | -- | ||
110 | 2.20.1 | ||
111 | |||
112 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Niek Linnenbank <nieklinnenbank@gmail.com> | ||
2 | 1 | ||
3 | This change ensures that the FPU can be accessed in Non-Secure mode | ||
4 | when the CPU core is reset using the arm_set_cpu_on() function call. | ||
5 | The NSACR.{CP11,CP10} bits define the exception level required to | ||
6 | access the FPU in Non-Secure mode. Without these bits set, the CPU | ||
7 | will give an undefined exception trap on the first FPU access for the | ||
8 | secondary cores under Linux. | ||
9 | |||
10 | This is necessary because in this power-control codepath QEMU | ||
11 | is effectively emulating a bit of EL3 firmware, and has to set | ||
12 | the CPU up as the EL3 firmware would. | ||
13 | |||
14 | Fixes: fc1120a7f5 | ||
15 | Cc: qemu-stable@nongnu.org | ||
16 | Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com> | ||
17 | [PMM: added clarifying para to commit message] | ||
18 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | --- | ||
21 | target/arm/arm-powerctl.c | 3 +++ | ||
22 | 1 file changed, 3 insertions(+) | ||
23 | |||
24 | diff --git a/target/arm/arm-powerctl.c b/target/arm/arm-powerctl.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/arm/arm-powerctl.c | ||
27 | +++ b/target/arm/arm-powerctl.c | ||
28 | @@ -XXX,XX +XXX,XX @@ static void arm_set_cpu_on_async_work(CPUState *target_cpu_state, | ||
29 | /* Processor is not in secure mode */ | ||
30 | target_cpu->env.cp15.scr_el3 |= SCR_NS; | ||
31 | |||
32 | + /* Set NSACR.{CP11,CP10} so NS can access the FPU */ | ||
33 | + target_cpu->env.cp15.nsacr |= 3 << 10; | ||
34 | + | ||
35 | /* | ||
36 | * If QEMU is providing the equivalent of EL3 firmware, then we need | ||
37 | * to make sure a CPU targeting EL2 comes out of reset with a | ||
38 | -- | ||
39 | 2.20.1 | ||
40 | |||
41 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Beata Michalska <beata.michalska@linaro.org> | ||
2 | 1 | ||
3 | Add probe_read alongside the write probing equivalent. | ||
4 | |||
5 | Signed-off-by: Beata Michalska <beata.michalska@linaro.org> | ||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20191121000843.24844-2-beata.michalska@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | include/exec/exec-all.h | 6 ++++++ | ||
12 | 1 file changed, 6 insertions(+) | ||
13 | |||
14 | diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/include/exec/exec-all.h | ||
17 | +++ b/include/exec/exec-all.h | ||
18 | @@ -XXX,XX +XXX,XX @@ static inline void *probe_write(CPUArchState *env, target_ulong addr, int size, | ||
19 | return probe_access(env, addr, size, MMU_DATA_STORE, mmu_idx, retaddr); | ||
20 | } | ||
21 | |||
22 | +static inline void *probe_read(CPUArchState *env, target_ulong addr, int size, | ||
23 | + int mmu_idx, uintptr_t retaddr) | ||
24 | +{ | ||
25 | + return probe_access(env, addr, size, MMU_DATA_LOAD, mmu_idx, retaddr); | ||
26 | +} | ||
27 | + | ||
28 | #define CODE_GEN_ALIGN 16 /* must be >= of the size of a icache line */ | ||
29 | |||
30 | /* Estimated block size for TB allocation. */ | ||
31 | -- | ||
32 | 2.20.1 | ||
33 | |||
34 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Beata Michalska <beata.michalska@linaro.org> | ||
2 | 1 | ||
3 | Switch to ram block writeback for pmem migration. | ||
4 | |||
5 | Signed-off-by: Beata Michalska <beata.michalska@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com> | ||
9 | Message-id: 20191121000843.24844-4-beata.michalska@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | migration/ram.c | 5 +---- | ||
13 | 1 file changed, 1 insertion(+), 4 deletions(-) | ||
14 | |||
15 | diff --git a/migration/ram.c b/migration/ram.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/migration/ram.c | ||
18 | +++ b/migration/ram.c | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | #include "qemu/bitops.h" | ||
21 | #include "qemu/bitmap.h" | ||
22 | #include "qemu/main-loop.h" | ||
23 | -#include "qemu/pmem.h" | ||
24 | #include "xbzrle.h" | ||
25 | #include "ram.h" | ||
26 | #include "migration.h" | ||
27 | @@ -XXX,XX +XXX,XX @@ static int ram_load_cleanup(void *opaque) | ||
28 | RAMBlock *rb; | ||
29 | |||
30 | RAMBLOCK_FOREACH_NOT_IGNORED(rb) { | ||
31 | - if (ramblock_is_pmem(rb)) { | ||
32 | - pmem_persist(rb->host, rb->used_length); | ||
33 | - } | ||
34 | + qemu_ram_block_writeback(rb); | ||
35 | } | ||
36 | |||
37 | xbzrle_load_cleanup(); | ||
38 | -- | ||
39 | 2.20.1 | ||
40 | |||
41 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
2 | 1 | ||
3 | Make the gic a field in the machine state, and instead of filling | ||
4 | an array of qemu_irq and passing it around, directly call | ||
5 | qdev_get_gpio_in() on the gic field. | ||
6 | |||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Message-id: 20191206162303.30338-1-philmd@redhat.com | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/arm/sbsa-ref.c | 86 +++++++++++++++++++++++------------------------ | ||
13 | 1 file changed, 42 insertions(+), 44 deletions(-) | ||
14 | |||
15 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/arm/sbsa-ref.c | ||
18 | +++ b/hw/arm/sbsa-ref.c | ||
19 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
20 | void *fdt; | ||
21 | int fdt_size; | ||
22 | int psci_conduit; | ||
23 | + DeviceState *gic; | ||
24 | PFlashCFI01 *flash[2]; | ||
25 | } SBSAMachineState; | ||
26 | |||
27 | @@ -XXX,XX +XXX,XX @@ static void create_secure_ram(SBSAMachineState *sms, | ||
28 | memory_region_add_subregion(secure_sysmem, base, secram); | ||
29 | } | ||
30 | |||
31 | -static void create_gic(SBSAMachineState *sms, qemu_irq *pic) | ||
32 | +static void create_gic(SBSAMachineState *sms) | ||
33 | { | ||
34 | unsigned int smp_cpus = MACHINE(sms)->smp.cpus; | ||
35 | - DeviceState *gicdev; | ||
36 | SysBusDevice *gicbusdev; | ||
37 | const char *gictype; | ||
38 | uint32_t redist0_capacity, redist0_count; | ||
39 | @@ -XXX,XX +XXX,XX @@ static void create_gic(SBSAMachineState *sms, qemu_irq *pic) | ||
40 | |||
41 | gictype = gicv3_class_name(); | ||
42 | |||
43 | - gicdev = qdev_create(NULL, gictype); | ||
44 | - qdev_prop_set_uint32(gicdev, "revision", 3); | ||
45 | - qdev_prop_set_uint32(gicdev, "num-cpu", smp_cpus); | ||
46 | + sms->gic = qdev_create(NULL, gictype); | ||
47 | + qdev_prop_set_uint32(sms->gic, "revision", 3); | ||
48 | + qdev_prop_set_uint32(sms->gic, "num-cpu", smp_cpus); | ||
49 | /* | ||
50 | * Note that the num-irq property counts both internal and external | ||
51 | * interrupts; there are always 32 of the former (mandated by GIC spec). | ||
52 | */ | ||
53 | - qdev_prop_set_uint32(gicdev, "num-irq", NUM_IRQS + 32); | ||
54 | - qdev_prop_set_bit(gicdev, "has-security-extensions", true); | ||
55 | + qdev_prop_set_uint32(sms->gic, "num-irq", NUM_IRQS + 32); | ||
56 | + qdev_prop_set_bit(sms->gic, "has-security-extensions", true); | ||
57 | |||
58 | redist0_capacity = | ||
59 | sbsa_ref_memmap[SBSA_GIC_REDIST].size / GICV3_REDIST_SIZE; | ||
60 | redist0_count = MIN(smp_cpus, redist0_capacity); | ||
61 | |||
62 | - qdev_prop_set_uint32(gicdev, "len-redist-region-count", 1); | ||
63 | - qdev_prop_set_uint32(gicdev, "redist-region-count[0]", redist0_count); | ||
64 | + qdev_prop_set_uint32(sms->gic, "len-redist-region-count", 1); | ||
65 | + qdev_prop_set_uint32(sms->gic, "redist-region-count[0]", redist0_count); | ||
66 | |||
67 | - qdev_init_nofail(gicdev); | ||
68 | - gicbusdev = SYS_BUS_DEVICE(gicdev); | ||
69 | + qdev_init_nofail(sms->gic); | ||
70 | + gicbusdev = SYS_BUS_DEVICE(sms->gic); | ||
71 | sysbus_mmio_map(gicbusdev, 0, sbsa_ref_memmap[SBSA_GIC_DIST].base); | ||
72 | sysbus_mmio_map(gicbusdev, 1, sbsa_ref_memmap[SBSA_GIC_REDIST].base); | ||
73 | |||
74 | @@ -XXX,XX +XXX,XX @@ static void create_gic(SBSAMachineState *sms, qemu_irq *pic) | ||
75 | |||
76 | for (irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) { | ||
77 | qdev_connect_gpio_out(cpudev, irq, | ||
78 | - qdev_get_gpio_in(gicdev, | ||
79 | + qdev_get_gpio_in(sms->gic, | ||
80 | ppibase + timer_irq[irq])); | ||
81 | } | ||
82 | |||
83 | qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interrupt", 0, | ||
84 | - qdev_get_gpio_in(gicdev, ppibase | ||
85 | + qdev_get_gpio_in(sms->gic, ppibase | ||
86 | + ARCH_GIC_MAINT_IRQ)); | ||
87 | qdev_connect_gpio_out_named(cpudev, "pmu-interrupt", 0, | ||
88 | - qdev_get_gpio_in(gicdev, ppibase | ||
89 | + qdev_get_gpio_in(sms->gic, ppibase | ||
90 | + VIRTUAL_PMU_IRQ)); | ||
91 | |||
92 | sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ)); | ||
93 | @@ -XXX,XX +XXX,XX @@ static void create_gic(SBSAMachineState *sms, qemu_irq *pic) | ||
94 | sysbus_connect_irq(gicbusdev, i + 3 * smp_cpus, | ||
95 | qdev_get_gpio_in(cpudev, ARM_CPU_VFIQ)); | ||
96 | } | ||
97 | - | ||
98 | - for (i = 0; i < NUM_IRQS; i++) { | ||
99 | - pic[i] = qdev_get_gpio_in(gicdev, i); | ||
100 | - } | ||
101 | } | ||
102 | |||
103 | -static void create_uart(const SBSAMachineState *sms, qemu_irq *pic, int uart, | ||
104 | +static void create_uart(const SBSAMachineState *sms, int uart, | ||
105 | MemoryRegion *mem, Chardev *chr) | ||
106 | { | ||
107 | hwaddr base = sbsa_ref_memmap[uart].base; | ||
108 | @@ -XXX,XX +XXX,XX @@ static void create_uart(const SBSAMachineState *sms, qemu_irq *pic, int uart, | ||
109 | qdev_init_nofail(dev); | ||
110 | memory_region_add_subregion(mem, base, | ||
111 | sysbus_mmio_get_region(s, 0)); | ||
112 | - sysbus_connect_irq(s, 0, pic[irq]); | ||
113 | + sysbus_connect_irq(s, 0, qdev_get_gpio_in(sms->gic, irq)); | ||
114 | } | ||
115 | |||
116 | -static void create_rtc(const SBSAMachineState *sms, qemu_irq *pic) | ||
117 | +static void create_rtc(const SBSAMachineState *sms) | ||
118 | { | ||
119 | hwaddr base = sbsa_ref_memmap[SBSA_RTC].base; | ||
120 | int irq = sbsa_ref_irqmap[SBSA_RTC]; | ||
121 | |||
122 | - sysbus_create_simple("pl031", base, pic[irq]); | ||
123 | + sysbus_create_simple("pl031", base, qdev_get_gpio_in(sms->gic, irq)); | ||
124 | } | ||
125 | |||
126 | static DeviceState *gpio_key_dev; | ||
127 | @@ -XXX,XX +XXX,XX @@ static Notifier sbsa_ref_powerdown_notifier = { | ||
128 | .notify = sbsa_ref_powerdown_req | ||
129 | }; | ||
130 | |||
131 | -static void create_gpio(const SBSAMachineState *sms, qemu_irq *pic) | ||
132 | +static void create_gpio(const SBSAMachineState *sms) | ||
133 | { | ||
134 | DeviceState *pl061_dev; | ||
135 | hwaddr base = sbsa_ref_memmap[SBSA_GPIO].base; | ||
136 | int irq = sbsa_ref_irqmap[SBSA_GPIO]; | ||
137 | |||
138 | - pl061_dev = sysbus_create_simple("pl061", base, pic[irq]); | ||
139 | + pl061_dev = sysbus_create_simple("pl061", base, | ||
140 | + qdev_get_gpio_in(sms->gic, irq)); | ||
141 | |||
142 | gpio_key_dev = sysbus_create_simple("gpio-key", -1, | ||
143 | qdev_get_gpio_in(pl061_dev, 3)); | ||
144 | @@ -XXX,XX +XXX,XX @@ static void create_gpio(const SBSAMachineState *sms, qemu_irq *pic) | ||
145 | qemu_register_powerdown_notifier(&sbsa_ref_powerdown_notifier); | ||
146 | } | ||
147 | |||
148 | -static void create_ahci(const SBSAMachineState *sms, qemu_irq *pic) | ||
149 | +static void create_ahci(const SBSAMachineState *sms) | ||
150 | { | ||
151 | hwaddr base = sbsa_ref_memmap[SBSA_AHCI].base; | ||
152 | int irq = sbsa_ref_irqmap[SBSA_AHCI]; | ||
153 | @@ -XXX,XX +XXX,XX @@ static void create_ahci(const SBSAMachineState *sms, qemu_irq *pic) | ||
154 | qdev_prop_set_uint32(dev, "num-ports", NUM_SATA_PORTS); | ||
155 | qdev_init_nofail(dev); | ||
156 | sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); | ||
157 | - sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[irq]); | ||
158 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, qdev_get_gpio_in(sms->gic, irq)); | ||
159 | |||
160 | sysahci = SYSBUS_AHCI(dev); | ||
161 | ahci = &sysahci->ahci; | ||
162 | @@ -XXX,XX +XXX,XX @@ static void create_ahci(const SBSAMachineState *sms, qemu_irq *pic) | ||
163 | } | ||
164 | } | ||
165 | |||
166 | -static void create_ehci(const SBSAMachineState *sms, qemu_irq *pic) | ||
167 | +static void create_ehci(const SBSAMachineState *sms) | ||
168 | { | ||
169 | hwaddr base = sbsa_ref_memmap[SBSA_EHCI].base; | ||
170 | int irq = sbsa_ref_irqmap[SBSA_EHCI]; | ||
171 | |||
172 | - sysbus_create_simple("platform-ehci-usb", base, pic[irq]); | ||
173 | + sysbus_create_simple("platform-ehci-usb", base, | ||
174 | + qdev_get_gpio_in(sms->gic, irq)); | ||
175 | } | ||
176 | |||
177 | -static void create_smmu(const SBSAMachineState *sms, qemu_irq *pic, | ||
178 | - PCIBus *bus) | ||
179 | +static void create_smmu(const SBSAMachineState *sms, PCIBus *bus) | ||
180 | { | ||
181 | hwaddr base = sbsa_ref_memmap[SBSA_SMMU].base; | ||
182 | int irq = sbsa_ref_irqmap[SBSA_SMMU]; | ||
183 | @@ -XXX,XX +XXX,XX @@ static void create_smmu(const SBSAMachineState *sms, qemu_irq *pic, | ||
184 | qdev_init_nofail(dev); | ||
185 | sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); | ||
186 | for (i = 0; i < NUM_SMMU_IRQS; i++) { | ||
187 | - sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, pic[irq + i]); | ||
188 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, | ||
189 | + qdev_get_gpio_in(sms->gic, irq + 1)); | ||
190 | } | ||
191 | } | ||
192 | |||
193 | -static void create_pcie(SBSAMachineState *sms, qemu_irq *pic) | ||
194 | +static void create_pcie(SBSAMachineState *sms) | ||
195 | { | ||
196 | hwaddr base_ecam = sbsa_ref_memmap[SBSA_PCIE_ECAM].base; | ||
197 | hwaddr size_ecam = sbsa_ref_memmap[SBSA_PCIE_ECAM].size; | ||
198 | @@ -XXX,XX +XXX,XX @@ static void create_pcie(SBSAMachineState *sms, qemu_irq *pic) | ||
199 | sysbus_mmio_map(SYS_BUS_DEVICE(dev), 2, base_pio); | ||
200 | |||
201 | for (i = 0; i < GPEX_NUM_IRQS; i++) { | ||
202 | - sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, pic[irq + i]); | ||
203 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, | ||
204 | + qdev_get_gpio_in(sms->gic, irq + 1)); | ||
205 | gpex_set_irq_num(GPEX_HOST(dev), i, irq + i); | ||
206 | } | ||
207 | |||
208 | @@ -XXX,XX +XXX,XX @@ static void create_pcie(SBSAMachineState *sms, qemu_irq *pic) | ||
209 | |||
210 | pci_create_simple(pci->bus, -1, "VGA"); | ||
211 | |||
212 | - create_smmu(sms, pic, pci->bus); | ||
213 | + create_smmu(sms, pci->bus); | ||
214 | } | ||
215 | |||
216 | static void *sbsa_ref_dtb(const struct arm_boot_info *binfo, int *fdt_size) | ||
217 | @@ -XXX,XX +XXX,XX @@ static void sbsa_ref_init(MachineState *machine) | ||
218 | bool firmware_loaded; | ||
219 | const CPUArchIdList *possible_cpus; | ||
220 | int n, sbsa_max_cpus; | ||
221 | - qemu_irq pic[NUM_IRQS]; | ||
222 | |||
223 | if (strcmp(machine->cpu_type, ARM_CPU_TYPE_NAME("cortex-a57"))) { | ||
224 | error_report("sbsa-ref: CPU type other than the built-in " | ||
225 | @@ -XXX,XX +XXX,XX @@ static void sbsa_ref_init(MachineState *machine) | ||
226 | |||
227 | create_secure_ram(sms, secure_sysmem); | ||
228 | |||
229 | - create_gic(sms, pic); | ||
230 | + create_gic(sms); | ||
231 | |||
232 | - create_uart(sms, pic, SBSA_UART, sysmem, serial_hd(0)); | ||
233 | - create_uart(sms, pic, SBSA_SECURE_UART, secure_sysmem, serial_hd(1)); | ||
234 | + create_uart(sms, SBSA_UART, sysmem, serial_hd(0)); | ||
235 | + create_uart(sms, SBSA_SECURE_UART, secure_sysmem, serial_hd(1)); | ||
236 | /* Second secure UART for RAS and MM from EL0 */ | ||
237 | - create_uart(sms, pic, SBSA_SECURE_UART_MM, secure_sysmem, serial_hd(2)); | ||
238 | + create_uart(sms, SBSA_SECURE_UART_MM, secure_sysmem, serial_hd(2)); | ||
239 | |||
240 | - create_rtc(sms, pic); | ||
241 | + create_rtc(sms); | ||
242 | |||
243 | - create_gpio(sms, pic); | ||
244 | + create_gpio(sms); | ||
245 | |||
246 | - create_ahci(sms, pic); | ||
247 | + create_ahci(sms); | ||
248 | |||
249 | - create_ehci(sms, pic); | ||
250 | + create_ehci(sms); | ||
251 | |||
252 | - create_pcie(sms, pic); | ||
253 | + create_pcie(sms); | ||
254 | |||
255 | sms->bootinfo.ram_size = machine->ram_size; | ||
256 | sms->bootinfo.nb_cpus = smp_cpus; | ||
257 | -- | ||
258 | 2.20.1 | ||
259 | |||
260 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Heyi Guo <guoheyi@huawei.com> | ||
2 | 1 | ||
3 | The last argument of AML bit and/or statement is the target variable, | ||
4 | so we don't need to use a NULL target and then an additional store | ||
5 | operation; using just aml_and() or aml_or() statement is enough. | ||
6 | |||
7 | Also update tests/data/acpi/virt/DSDT* to pass "make check". | ||
8 | |||
9 | Cc: Shannon Zhao <shannon.zhaosl@gmail.com> | ||
10 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Cc: "Michael S. Tsirkin" <mst@redhat.com> | ||
12 | Cc: Igor Mammedov <imammedo@redhat.com> | ||
13 | Suggested-by: Igor Mammedov <imammedo@redhat.com> | ||
14 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
15 | Signed-off-by: Heyi Guo <guoheyi@huawei.com> | ||
16 | Message-id: 20191209063719.23086-2-guoheyi@huawei.com | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | --- | ||
19 | hw/arm/virt-acpi-build.c | 16 ++++++++-------- | ||
20 | tests/data/acpi/virt/DSDT | Bin 18470 -> 18462 bytes | ||
21 | tests/data/acpi/virt/DSDT.memhp | Bin 19807 -> 19799 bytes | ||
22 | tests/data/acpi/virt/DSDT.numamem | Bin 18470 -> 18462 bytes | ||
23 | 4 files changed, 8 insertions(+), 8 deletions(-) | ||
24 | |||
25 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/hw/arm/virt-acpi-build.c | ||
28 | +++ b/hw/arm/virt-acpi-build.c | ||
29 | @@ -XXX,XX +XXX,XX @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, | ||
30 | aml_create_dword_field(aml_arg(3), aml_int(8), "CDW3")); | ||
31 | aml_append(ifctx, aml_store(aml_name("CDW2"), aml_name("SUPP"))); | ||
32 | aml_append(ifctx, aml_store(aml_name("CDW3"), aml_name("CTRL"))); | ||
33 | - aml_append(ifctx, aml_store(aml_and(aml_name("CTRL"), aml_int(0x1D), NULL), | ||
34 | - aml_name("CTRL"))); | ||
35 | + aml_append(ifctx, aml_and(aml_name("CTRL"), aml_int(0x1D), | ||
36 | + aml_name("CTRL"))); | ||
37 | |||
38 | ifctx1 = aml_if(aml_lnot(aml_equal(aml_arg(1), aml_int(0x1)))); | ||
39 | - aml_append(ifctx1, aml_store(aml_or(aml_name("CDW1"), aml_int(0x08), NULL), | ||
40 | - aml_name("CDW1"))); | ||
41 | + aml_append(ifctx1, aml_or(aml_name("CDW1"), aml_int(0x08), | ||
42 | + aml_name("CDW1"))); | ||
43 | aml_append(ifctx, ifctx1); | ||
44 | |||
45 | ifctx1 = aml_if(aml_lnot(aml_equal(aml_name("CDW3"), aml_name("CTRL")))); | ||
46 | - aml_append(ifctx1, aml_store(aml_or(aml_name("CDW1"), aml_int(0x10), NULL), | ||
47 | - aml_name("CDW1"))); | ||
48 | + aml_append(ifctx1, aml_or(aml_name("CDW1"), aml_int(0x10), | ||
49 | + aml_name("CDW1"))); | ||
50 | aml_append(ifctx, ifctx1); | ||
51 | |||
52 | aml_append(ifctx, aml_store(aml_name("CTRL"), aml_name("CDW3"))); | ||
53 | @@ -XXX,XX +XXX,XX @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, | ||
54 | aml_append(method, ifctx); | ||
55 | |||
56 | elsectx = aml_else(); | ||
57 | - aml_append(elsectx, aml_store(aml_or(aml_name("CDW1"), aml_int(4), NULL), | ||
58 | - aml_name("CDW1"))); | ||
59 | + aml_append(elsectx, aml_or(aml_name("CDW1"), aml_int(4), | ||
60 | + aml_name("CDW1"))); | ||
61 | aml_append(elsectx, aml_return(aml_arg(3))); | ||
62 | aml_append(method, elsectx); | ||
63 | aml_append(dev, method); | ||
64 | diff --git a/tests/data/acpi/virt/DSDT b/tests/data/acpi/virt/DSDT | ||
65 | index XXXXXXX..XXXXXXX 100644 | ||
66 | GIT binary patch | ||
67 | delta 133 | ||
68 | zcmZ2BfpOjhMlP3Nmk>D*1_q|2iCof5o%I{lJ2{y;?{412x!p#<jWgaq*qNm(o59&7 | ||
69 | z+;D-%<VrV7_iE>mARjJS5V=5L(&S9WT970c2Uv;Nq{%?q7$gZ1761tsfcPNsCD{x4 | ||
70 | MAmS{W8QoPG0j8@bzW@LL | ||
71 | |||
72 | delta 141 | ||
73 | zcmbO?fpOUcMlP3Nmk>1%1_q`n6S<_B8XGpMcXBc{-rKy1bGwazA7{LOuro_nHiNTE | ||
74 | zxZwi7$(3%F{sq;}AwfP|vJ4<<fzYJMnT!RsAbBnhh%$*ulYv}gkTg_604z}e5&_99 | ||
75 | R$zCV`m0@An{L@X95dZ+BD!u>! | ||
76 | |||
77 | diff --git a/tests/data/acpi/virt/DSDT.memhp b/tests/data/acpi/virt/DSDT.memhp | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | GIT binary patch | ||
80 | delta 132 | ||
81 | zcmcaVi}Cs_MlP3NmymE@1_ma@iCof*O&is^IGH-{Zr;SX-A2HTGu}VgnWZb6!PzC; | ||
82 | zaDm6<N;gaQYUhw3A1+xCxj<mj<V?m|kR%reSc%xA$w1l|Bnc4~00|d>_#p8m*$ep~ | ||
83 | L;w+mP-Q(B*s{AMU | ||
84 | |||
85 | delta 140 | ||
86 | zcmcaUi}C&}MlP3Nmymd01_maViCof*T^rT9IGGynZQjJW-A2HVGu}VgnWZb6!PzC; | ||
87 | zaDm_CN;gaYf@<fGARjJS1`xGCXwu|N#)4XqJQoK<nZ%^YK&~-J8Y&?GmM8#;fMk|r | ||
88 | QFBE{vurO@?=@!QZ00dYn_y7O^ | ||
89 | |||
90 | diff --git a/tests/data/acpi/virt/DSDT.numamem b/tests/data/acpi/virt/DSDT.numamem | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | GIT binary patch | ||
93 | delta 133 | ||
94 | zcmZ2BfpOjhMlP3Nmk>D*1_q|2iCof5o%I{lJ2{y;?{412x!p#<jWgaq*qNm(o59&7 | ||
95 | z+;D-%<VrV7_iE>mARjJS5V=5L(&S9WT970c2Uv;Nq{%?q7$gZ1761tsfcPNsCD{x4 | ||
96 | MAmS{W8QoPG0j8@bzW@LL | ||
97 | |||
98 | delta 141 | ||
99 | zcmbO?fpOUcMlP3Nmk>1%1_q`n6S<_B8XGpMcXBc{-rKy1bGwazA7{LOuro_nHiNTE | ||
100 | zxZwi7$(3%F{sq;}AwfP|vJ4<<fzYJMnT!RsAbBnhh%$*ulYv}gkTg_604z}e5&_99 | ||
101 | R$zCV`m0@An{L@X95dZ+BD!u>! | ||
102 | |||
103 | -- | ||
104 | 2.20.1 | ||
105 | |||
106 | diff view generated by jsdifflib |