1 | target-arm queue for softfreeze: this is quite big as I | 1 | The following changes since commit 7e7eb9f852a46b51a71ae9d82590b2e4d28827ee: |
---|---|---|---|
2 | was on holiday last week, so this is all just sneaking in | ||
3 | under the wire. I particularly wanted to get Philippe's | ||
4 | patches in before freeze as that sort of code-movement | ||
5 | patchset is painful to have to rebase. | ||
6 | 2 | ||
7 | thanks | 3 | Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2021-01-28' into staging (2021-01-28 22:43:18 +0000) |
8 | -- PMM | ||
9 | |||
10 | The following changes since commit ae9108f8f0746ce64d02afb1a216153a50926132: | ||
11 | |||
12 | Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-4.1-pull-request' into staging (2019-07-01 15:55:40 +0100) | ||
13 | 4 | ||
14 | are available in the Git repository at: | 5 | are available in the Git repository at: |
15 | 6 | ||
16 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190701 | 7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210129 |
17 | 8 | ||
18 | for you to fetch changes up to 787a7e76c2e93a48c47b324fea592c9910a70483: | 9 | for you to fetch changes up to 11749122e1a86866591306d43603d2795a3dea1a: |
19 | 10 | ||
20 | target/arm: Declare some M-profile functions publicly (2019-07-01 17:29:01 +0100) | 11 | hw/arm/stellaris: Remove board-creation reset of STELLARIS_SYS (2021-01-29 10:47:29 +0000) |
21 | 12 | ||
22 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
23 | target-arm queue: | 14 | target-arm queue: |
24 | * hw/arm/boot: fix direct kernel boot with initrd | 15 | * Implement ID_PFR2 |
25 | * hw/arm/msf2-som: Exit when the cpu is not the expected one | 16 | * Conditionalize DBGDIDR |
26 | * i.mx7: fix bugs in PCI controller needed to boot recent kernels | 17 | * rename xlnx-zcu102.canbusN properties |
27 | * aspeed: add RTC device | 18 | * provide powerdown/reset mechanism for secure firmware on 'virt' board |
28 | * aspeed: fix some timer device bugs | 19 | * hw/misc: Fix arith overflow in NPCM7XX PWM module |
29 | * aspeed: add swift-bmc board | 20 | * target/arm: Replace magic value by MMU_DATA_LOAD definition |
30 | * aspeed: vic: Add support for legacy register interface | 21 | * configure: fix preadv errors on Catalina macOS with new XCode |
31 | * aspeed: add aspeed-xdma device | 22 | * Various configure and other cleanups in preparation for iOS support |
32 | * Add new sbsa-ref board for aarch64 | 23 | * hvf: Add hypervisor entitlement to output binaries (needed for Big Sur) |
33 | * target/arm: code refactoring in preparation for support of | 24 | * Implement pvpanic-pci device |
34 | compilation with TCG disabled | 25 | * Convert the CMSDK timer devices to the Clock framework |
35 | 26 | ||
36 | ---------------------------------------------------------------- | 27 | ---------------------------------------------------------------- |
37 | Adriana Kobylak (1): | 28 | Alexander Graf (1): |
38 | aspeed: Add support for the swift-bmc board | 29 | hvf: Add hypervisor entitlement to output binaries |
39 | 30 | ||
40 | Andrew Jeffery (3): | 31 | Hao Wu (1): |
41 | aspeed/timer: Status register contains reload for stopped timer | 32 | hw/misc: Fix arith overflow in NPCM7XX PWM module |
42 | aspeed/timer: Fix match calculations | ||
43 | aspeed: vic: Add support for legacy register interface | ||
44 | 33 | ||
45 | Andrew Jones (1): | 34 | Joelle van Dyne (7): |
46 | hw/arm/boot: fix direct kernel boot with initrd | 35 | configure: cross-compiling with empty cross_prefix |
36 | osdep: build with non-working system() function | ||
37 | darwin: remove redundant dependency declaration | ||
38 | darwin: fix cross-compiling for Darwin | ||
39 | configure: cross compile should use x86_64 cpu_family | ||
40 | darwin: detect CoreAudio for build | ||
41 | darwin: remove 64-bit build detection on 32-bit OS | ||
47 | 42 | ||
48 | Andrey Smirnov (5): | 43 | Maxim Uvarov (3): |
49 | i.mx7d: Add no-op/unimplemented APBH DMA module | 44 | hw: gpio: implement gpio-pwr driver for qemu reset/poweroff |
50 | i.mx7d: Add no-op/unimplemented PCIE PHY IP block | 45 | arm-virt: refactor gpios creation |
51 | pci: designware: Update MSI mapping unconditionally | 46 | arm-virt: add secure pl061 for reset/power down |
52 | pci: designware: Update MSI mapping when MSI address changes | ||
53 | i.mx7d: pci: Update PCI IRQ mapping to match HW | ||
54 | 47 | ||
55 | Christian Svensson (1): | 48 | Mihai Carabas (4): |
56 | aspeed/timer: Ensure positive muldiv delta | 49 | hw/misc/pvpanic: split-out generic and bus dependent code |
50 | hw/misc/pvpanic: add PCI interface support | ||
51 | pvpanic : update pvpanic spec document | ||
52 | tests/qtest: add a test case for pvpanic-pci | ||
57 | 53 | ||
58 | Cédric Le Goater (7): | 54 | Paolo Bonzini (1): |
59 | aspeed: add a per SoC mapping for the interrupt space | 55 | arm: rename xlnx-zcu102.canbusN properties |
60 | aspeed: add a per SoC mapping for the memory space | ||
61 | aspeed: introduce a configurable number of CPU per machine | ||
62 | aspeed: add support for multiple NICs | ||
63 | aspeed: remove the "ram" link | ||
64 | aspeed: add a RAM memory region container | ||
65 | aspeed/smc: add a 'sdram_base' property | ||
66 | 56 | ||
67 | Eddie James (1): | 57 | Peter Maydell (26): |
68 | hw/misc/aspeed_xdma: New device | 58 | configure: Move preadv check to meson.build |
59 | ptimer: Add new ptimer_set_period_from_clock() function | ||
60 | clock: Add new clock_has_source() function | ||
61 | tests: Add a simple test of the CMSDK APB timer | ||
62 | tests: Add a simple test of the CMSDK APB watchdog | ||
63 | tests: Add a simple test of the CMSDK APB dual timer | ||
64 | hw/timer/cmsdk-apb-timer: Rename CMSDKAPBTIMER struct to CMSDKAPBTimer | ||
65 | hw/timer/cmsdk-apb-timer: Add Clock input | ||
66 | hw/timer/cmsdk-apb-dualtimer: Add Clock input | ||
67 | hw/watchdog/cmsdk-apb-watchdog: Add Clock input | ||
68 | hw/arm/armsse: Rename "MAINCLK" property to "MAINCLK_FRQ" | ||
69 | hw/arm/armsse: Wire up clocks | ||
70 | hw/arm/mps2: Inline CMSDK_APB_TIMER creation | ||
71 | hw/arm/mps2: Create and connect SYSCLK Clock | ||
72 | hw/arm/mps2-tz: Create and connect ARMSSE Clocks | ||
73 | hw/arm/musca: Create and connect ARMSSE Clocks | ||
74 | hw/arm/stellaris: Convert SSYS to QOM device | ||
75 | hw/arm/stellaris: Create Clock input for watchdog | ||
76 | hw/timer/cmsdk-apb-timer: Convert to use Clock input | ||
77 | hw/timer/cmsdk-apb-dualtimer: Convert to use Clock input | ||
78 | hw/watchdog/cmsdk-apb-watchdog: Convert to use Clock input | ||
79 | tests/qtest/cmsdk-apb-watchdog-test: Test clock changes | ||
80 | hw/arm/armsse: Use Clock to set system_clock_scale | ||
81 | arm: Don't set freq properties on CMSDK timer, dualtimer, watchdog, ARMSSE | ||
82 | arm: Remove frq properties on CMSDK timer, dualtimer, watchdog, ARMSSE | ||
83 | hw/arm/stellaris: Remove board-creation reset of STELLARIS_SYS | ||
69 | 84 | ||
70 | Hongbo Zhang (2): | 85 | Philippe Mathieu-Daudé (1): |
71 | hw/arm: Add arm SBSA reference machine, skeleton part | 86 | target/arm: Replace magic value by MMU_DATA_LOAD definition |
72 | hw/arm: Add arm SBSA reference machine, devices part | ||
73 | 87 | ||
74 | Jan Kiszka (1): | 88 | Richard Henderson (2): |
75 | hw/arm/virt: Add support for Cortex-A7 | 89 | target/arm: Implement ID_PFR2 |
90 | target/arm: Conditionalize DBGDIDR | ||
76 | 91 | ||
77 | Joel Stanley (4): | 92 | docs/devel/clocks.rst | 16 +++ |
78 | hw: timer: Add ASPEED RTC device | 93 | docs/specs/pci-ids.txt | 1 + |
79 | hw/arm/aspeed: Add RTC to SoC | 94 | docs/specs/pvpanic.txt | 13 ++- |
80 | aspeed/timer: Fix behaviour running Linux | 95 | docs/system/arm/virt.rst | 2 + |
81 | aspeed: Link SCU to the watchdog | 96 | configure | 78 ++++++++------ |
97 | meson.build | 34 ++++++- | ||
98 | include/hw/arm/armsse.h | 14 ++- | ||
99 | include/hw/arm/virt.h | 2 + | ||
100 | include/hw/clock.h | 15 +++ | ||
101 | include/hw/misc/pvpanic.h | 24 ++++- | ||
102 | include/hw/pci/pci.h | 1 + | ||
103 | include/hw/ptimer.h | 22 ++++ | ||
104 | include/hw/timer/cmsdk-apb-dualtimer.h | 5 +- | ||
105 | include/hw/timer/cmsdk-apb-timer.h | 34 ++----- | ||
106 | include/hw/watchdog/cmsdk-apb-watchdog.h | 5 +- | ||
107 | include/qemu/osdep.h | 12 +++ | ||
108 | include/qemu/typedefs.h | 1 + | ||
109 | target/arm/cpu.h | 1 + | ||
110 | hw/arm/armsse.c | 48 ++++++--- | ||
111 | hw/arm/mps2-tz.c | 14 ++- | ||
112 | hw/arm/mps2.c | 28 ++++- | ||
113 | hw/arm/musca.c | 13 ++- | ||
114 | hw/arm/stellaris.c | 170 +++++++++++++++++++++++-------- | ||
115 | hw/arm/virt.c | 111 ++++++++++++++++---- | ||
116 | hw/arm/xlnx-zcu102.c | 4 +- | ||
117 | hw/core/ptimer.c | 34 +++++++ | ||
118 | hw/gpio/gpio_pwr.c | 70 +++++++++++++ | ||
119 | hw/misc/npcm7xx_pwm.c | 23 ++++- | ||
120 | hw/misc/pvpanic-isa.c | 94 +++++++++++++++++ | ||
121 | hw/misc/pvpanic-pci.c | 94 +++++++++++++++++ | ||
122 | hw/misc/pvpanic.c | 85 ++-------------- | ||
123 | hw/timer/cmsdk-apb-dualtimer.c | 53 +++++++--- | ||
124 | hw/timer/cmsdk-apb-timer.c | 55 +++++----- | ||
125 | hw/watchdog/cmsdk-apb-watchdog.c | 29 ++++-- | ||
126 | target/arm/helper.c | 27 +++-- | ||
127 | target/arm/kvm64.c | 2 + | ||
128 | tests/qtest/cmsdk-apb-dualtimer-test.c | 130 +++++++++++++++++++++++ | ||
129 | tests/qtest/cmsdk-apb-timer-test.c | 75 ++++++++++++++ | ||
130 | tests/qtest/cmsdk-apb-watchdog-test.c | 131 ++++++++++++++++++++++++ | ||
131 | tests/qtest/npcm7xx_pwm-test.c | 4 +- | ||
132 | tests/qtest/pvpanic-pci-test.c | 94 +++++++++++++++++ | ||
133 | tests/qtest/xlnx-can-test.c | 30 +++--- | ||
134 | MAINTAINERS | 3 + | ||
135 | accel/hvf/entitlements.plist | 8 ++ | ||
136 | hw/arm/Kconfig | 1 + | ||
137 | hw/gpio/Kconfig | 3 + | ||
138 | hw/gpio/meson.build | 1 + | ||
139 | hw/i386/Kconfig | 2 +- | ||
140 | hw/misc/Kconfig | 12 ++- | ||
141 | hw/misc/meson.build | 4 +- | ||
142 | scripts/entitlement.sh | 13 +++ | ||
143 | tests/qtest/meson.build | 6 +- | ||
144 | 52 files changed, 1432 insertions(+), 319 deletions(-) | ||
145 | create mode 100644 hw/gpio/gpio_pwr.c | ||
146 | create mode 100644 hw/misc/pvpanic-isa.c | ||
147 | create mode 100644 hw/misc/pvpanic-pci.c | ||
148 | create mode 100644 tests/qtest/cmsdk-apb-dualtimer-test.c | ||
149 | create mode 100644 tests/qtest/cmsdk-apb-timer-test.c | ||
150 | create mode 100644 tests/qtest/cmsdk-apb-watchdog-test.c | ||
151 | create mode 100644 tests/qtest/pvpanic-pci-test.c | ||
152 | create mode 100644 accel/hvf/entitlements.plist | ||
153 | create mode 100755 scripts/entitlement.sh | ||
82 | 154 | ||
83 | Philippe Mathieu-Daudé (19): | ||
84 | hw/arm/msf2-som: Exit when the cpu is not the expected one | ||
85 | target/arm: Makefile cleanup (Aarch64) | ||
86 | target/arm: Makefile cleanup (ARM) | ||
87 | target/arm: Makefile cleanup (KVM) | ||
88 | target/arm: Makefile cleanup (softmmu) | ||
89 | target/arm: Add copyright boilerplate | ||
90 | target/arm/helper: Remove unused include | ||
91 | target/arm: Fix multiline comment syntax | ||
92 | target/arm: Fix coding style issues | ||
93 | target/arm: Move CPU state dumping routines to cpu.c | ||
94 | target/arm: Declare get_phys_addr() function publicly | ||
95 | target/arm: Move TLB related routines to tlb_helper.c | ||
96 | target/arm/vfp_helper: Move code around | ||
97 | target/arm/vfp_helper: Extract vfp_set_fpscr_to_host() | ||
98 | target/arm/vfp_helper: Extract vfp_set_fpscr_from_host() | ||
99 | target/arm/vfp_helper: Restrict the SoftFloat use to TCG | ||
100 | target/arm: Restrict PSCI to TCG | ||
101 | target/arm: Declare arm_log_exception() function publicly | ||
102 | target/arm: Declare some M-profile functions publicly | ||
103 | |||
104 | Samuel Ortiz (1): | ||
105 | target/arm: Move the DC ZVA helper into op_helper | ||
106 | |||
107 | hw/arm/Makefile.objs | 1 + | ||
108 | hw/misc/Makefile.objs | 1 + | ||
109 | hw/timer/Makefile.objs | 2 +- | ||
110 | target/arm/Makefile.objs | 24 +- | ||
111 | include/hw/arm/aspeed_soc.h | 53 ++- | ||
112 | include/hw/arm/fsl-imx7.h | 14 +- | ||
113 | include/hw/misc/aspeed_xdma.h | 30 ++ | ||
114 | include/hw/ssi/aspeed_smc.h | 3 + | ||
115 | include/hw/timer/aspeed_rtc.h | 31 ++ | ||
116 | include/hw/watchdog/wdt_aspeed.h | 1 + | ||
117 | target/arm/cpu.h | 2 - | ||
118 | target/arm/internals.h | 69 ++- | ||
119 | target/arm/translate.h | 5 - | ||
120 | hw/arm/aspeed.c | 76 +++- | ||
121 | hw/arm/aspeed_soc.c | 262 +++++++++--- | ||
122 | hw/arm/boot.c | 3 +- | ||
123 | hw/arm/fsl-imx7.c | 11 + | ||
124 | hw/arm/msf2-som.c | 1 + | ||
125 | hw/arm/sbsa-ref.c | 806 ++++++++++++++++++++++++++++++++++++ | ||
126 | hw/arm/virt.c | 1 + | ||
127 | hw/intc/aspeed_vic.c | 105 +++-- | ||
128 | hw/misc/aspeed_xdma.c | 165 ++++++++ | ||
129 | hw/pci-host/designware.c | 18 +- | ||
130 | hw/ssi/aspeed_smc.c | 1 + | ||
131 | hw/timer/aspeed_rtc.c | 180 ++++++++ | ||
132 | hw/timer/aspeed_timer.c | 76 ++-- | ||
133 | hw/watchdog/wdt_aspeed.c | 20 + | ||
134 | target/arm/cpu.c | 232 ++++++++++- | ||
135 | target/arm/helper.c | 498 +++++++++------------- | ||
136 | target/arm/op_helper.c | 262 ++++++------ | ||
137 | target/arm/tlb_helper.c | 200 +++++++++ | ||
138 | target/arm/translate-a64.c | 128 ------ | ||
139 | target/arm/translate.c | 91 +--- | ||
140 | target/arm/vfp_helper.c | 199 +++++---- | ||
141 | MAINTAINERS | 8 + | ||
142 | default-configs/aarch64-softmmu.mak | 1 + | ||
143 | hw/arm/Kconfig | 14 + | ||
144 | hw/misc/trace-events | 3 + | ||
145 | hw/timer/trace-events | 4 + | ||
146 | 39 files changed, 2675 insertions(+), 926 deletions(-) | ||
147 | create mode 100644 include/hw/misc/aspeed_xdma.h | ||
148 | create mode 100644 include/hw/timer/aspeed_rtc.h | ||
149 | create mode 100644 hw/arm/sbsa-ref.c | ||
150 | create mode 100644 hw/misc/aspeed_xdma.c | ||
151 | create mode 100644 hw/timer/aspeed_rtc.c | ||
152 | create mode 100644 target/arm/tlb_helper.c | ||
153 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | In the next commit we will split the TLB related routines of | 3 | This was defined at some point before ARMv8.4, and will |
4 | this file, and this function will also be called in the new | 4 | shortly be used by new processor descriptions. |
5 | file. Declare it in the "internals.h" header. | ||
6 | 5 | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Message-id: 20190701132516.26392-12-philmd@redhat.com | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210120204400.1056582-1-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 10 | --- |
12 | target/arm/internals.h | 16 ++++++++++++++++ | 11 | target/arm/cpu.h | 1 + |
13 | target/arm/helper.c | 21 +++++---------------- | 12 | target/arm/helper.c | 4 ++-- |
14 | 2 files changed, 21 insertions(+), 16 deletions(-) | 13 | target/arm/kvm64.c | 2 ++ |
14 | 3 files changed, 5 insertions(+), 2 deletions(-) | ||
15 | 15 | ||
16 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
17 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/internals.h | 18 | --- a/target/arm/cpu.h |
19 | +++ b/target/arm/internals.h | 19 | +++ b/target/arm/cpu.h |
20 | @@ -XXX,XX +XXX,XX @@ static inline int exception_target_el(CPUARMState *env) | 20 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { |
21 | return target_el; | 21 | uint32_t id_mmfr4; |
22 | } | 22 | uint32_t id_pfr0; |
23 | 23 | uint32_t id_pfr1; | |
24 | +#ifndef CONFIG_USER_ONLY | 24 | + uint32_t id_pfr2; |
25 | + | 25 | uint32_t mvfr0; |
26 | +/* Cacheability and shareability attributes for a memory access */ | 26 | uint32_t mvfr1; |
27 | +typedef struct ARMCacheAttrs { | 27 | uint32_t mvfr2; |
28 | + unsigned int attrs:8; /* as in the MAIR register encoding */ | ||
29 | + unsigned int shareability:2; /* as in the SH field of the VMSAv8-64 PTEs */ | ||
30 | +} ARMCacheAttrs; | ||
31 | + | ||
32 | +bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
33 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
34 | + hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | ||
35 | + target_ulong *page_size, | ||
36 | + ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs); | ||
37 | + | ||
38 | +#endif /* !CONFIG_USER_ONLY */ | ||
39 | + | ||
40 | #endif | ||
41 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 28 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
42 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
43 | --- a/target/arm/helper.c | 30 | --- a/target/arm/helper.c |
44 | +++ b/target/arm/helper.c | 31 | +++ b/target/arm/helper.c |
45 | @@ -XXX,XX +XXX,XX @@ | 32 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
46 | #define ARM_CPU_FREQ 1000000000 /* FIXME: 1 GHz, should be configurable */ | 33 | .access = PL1_R, .type = ARM_CP_CONST, |
47 | 34 | .accessfn = access_aa64_tid3, | |
48 | #ifndef CONFIG_USER_ONLY | 35 | .resetvalue = 0 }, |
49 | -/* Cacheability and shareability attributes for a memory access */ | 36 | - { .name = "MVFR4_EL1_RESERVED", .state = ARM_CP_STATE_AA64, |
50 | -typedef struct ARMCacheAttrs { | 37 | + { .name = "ID_PFR2", .state = ARM_CP_STATE_BOTH, |
51 | - unsigned int attrs:8; /* as in the MAIR register encoding */ | 38 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 4, |
52 | - unsigned int shareability:2; /* as in the SH field of the VMSAv8-64 PTEs */ | 39 | .access = PL1_R, .type = ARM_CP_CONST, |
53 | -} ARMCacheAttrs; | 40 | .accessfn = access_aa64_tid3, |
54 | - | 41 | - .resetvalue = 0 }, |
55 | -static bool get_phys_addr(CPUARMState *env, target_ulong address, | 42 | + .resetvalue = cpu->isar.id_pfr2 }, |
56 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | 43 | { .name = "MVFR5_EL1_RESERVED", .state = ARM_CP_STATE_AA64, |
57 | - hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | 44 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 5, |
58 | - target_ulong *page_size, | 45 | .access = PL1_R, .type = ARM_CP_CONST, |
59 | - ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs); | 46 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c |
60 | 47 | index XXXXXXX..XXXXXXX 100644 | |
61 | static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, | 48 | --- a/target/arm/kvm64.c |
62 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | 49 | +++ b/target/arm/kvm64.c |
63 | @@ -XXX,XX +XXX,XX @@ static ARMCacheAttrs combine_cacheattrs(ARMCacheAttrs s1, ARMCacheAttrs s2) | 50 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) |
64 | * @fi: set to fault info if the translation fails | 51 | ARM64_SYS_REG(3, 0, 0, 1, 0)); |
65 | * @cacheattrs: (if non-NULL) set to the cacheability/shareability attributes | 52 | err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr1, |
66 | */ | 53 | ARM64_SYS_REG(3, 0, 0, 1, 1)); |
67 | -static bool get_phys_addr(CPUARMState *env, target_ulong address, | 54 | + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr2, |
68 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | 55 | + ARM64_SYS_REG(3, 0, 0, 3, 4)); |
69 | - hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | 56 | err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_dfr0, |
70 | - target_ulong *page_size, | 57 | ARM64_SYS_REG(3, 0, 0, 1, 2)); |
71 | - ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) | 58 | err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr0, |
72 | +bool get_phys_addr(CPUARMState *env, target_ulong address, | ||
73 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
74 | + hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, | ||
75 | + target_ulong *page_size, | ||
76 | + ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) | ||
77 | { | ||
78 | if (mmu_idx == ARMMMUIdx_S12NSE0 || mmu_idx == ARMMMUIdx_S12NSE1) { | ||
79 | /* Call ourselves recursively to do the stage 1 and then stage 2 | ||
80 | -- | 59 | -- |
81 | 2.20.1 | 60 | 2.20.1 |
82 | 61 | ||
83 | 62 | diff view generated by jsdifflib |
1 | From: Samuel Ortiz <sameo@linux.intel.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Those helpers are a software implementation of the ARM v8 memory zeroing | 3 | Only define the register if it exists for the cpu. |
4 | op code. They should be moved to the op helper file, which is going to | ||
5 | eventually be built only when TCG is enabled. | ||
6 | 4 | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Reviewed-by: Robert Bradford <robert.bradford@intel.com> | 6 | Message-id: 20210120031656.737646-1-richard.henderson@linaro.org |
9 | Signed-off-by: Samuel Ortiz <sameo@linux.intel.com> | ||
10 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
11 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Message-id: 20190701132516.26392-10-philmd@redhat.com | ||
13 | [PMD: Rebased] | ||
14 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | --- | 9 | --- |
18 | target/arm/helper.c | 92 ----------------------------------------- | 10 | target/arm/helper.c | 21 +++++++++++++++------ |
19 | target/arm/op_helper.c | 93 ++++++++++++++++++++++++++++++++++++++++++ | 11 | 1 file changed, 15 insertions(+), 6 deletions(-) |
20 | 2 files changed, 93 insertions(+), 92 deletions(-) | ||
21 | 12 | ||
22 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 13 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
23 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/arm/helper.c | 15 | --- a/target/arm/helper.c |
25 | +++ b/target/arm/helper.c | 16 | +++ b/target/arm/helper.c |
26 | @@ -XXX,XX +XXX,XX @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, | 17 | @@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu) |
27 | #endif | 18 | */ |
28 | } | 19 | int i; |
29 | 20 | int wrps, brps, ctx_cmps; | |
30 | -void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in) | 21 | - ARMCPRegInfo dbgdidr = { |
31 | -{ | 22 | - .name = "DBGDIDR", .cp = 14, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 0, |
32 | - /* | 23 | - .access = PL0_R, .accessfn = access_tda, |
33 | - * Implement DC ZVA, which zeroes a fixed-length block of memory. | 24 | - .type = ARM_CP_CONST, .resetvalue = cpu->isar.dbgdidr, |
34 | - * Note that we do not implement the (architecturally mandated) | 25 | - }; |
35 | - * alignment fault for attempts to use this on Device memory | ||
36 | - * (which matches the usual QEMU behaviour of not implementing either | ||
37 | - * alignment faults or any memory attribute handling). | ||
38 | - */ | ||
39 | - | ||
40 | - ARMCPU *cpu = env_archcpu(env); | ||
41 | - uint64_t blocklen = 4 << cpu->dcz_blocksize; | ||
42 | - uint64_t vaddr = vaddr_in & ~(blocklen - 1); | ||
43 | - | ||
44 | -#ifndef CONFIG_USER_ONLY | ||
45 | - { | ||
46 | - /* | ||
47 | - * Slightly awkwardly, QEMU's TARGET_PAGE_SIZE may be less than | ||
48 | - * the block size so we might have to do more than one TLB lookup. | ||
49 | - * We know that in fact for any v8 CPU the page size is at least 4K | ||
50 | - * and the block size must be 2K or less, but TARGET_PAGE_SIZE is only | ||
51 | - * 1K as an artefact of legacy v5 subpage support being present in the | ||
52 | - * same QEMU executable. So in practice the hostaddr[] array has | ||
53 | - * two entries, given the current setting of TARGET_PAGE_BITS_MIN. | ||
54 | - */ | ||
55 | - int maxidx = DIV_ROUND_UP(blocklen, TARGET_PAGE_SIZE); | ||
56 | - void *hostaddr[DIV_ROUND_UP(2 * KiB, 1 << TARGET_PAGE_BITS_MIN)]; | ||
57 | - int try, i; | ||
58 | - unsigned mmu_idx = cpu_mmu_index(env, false); | ||
59 | - TCGMemOpIdx oi = make_memop_idx(MO_UB, mmu_idx); | ||
60 | - | ||
61 | - assert(maxidx <= ARRAY_SIZE(hostaddr)); | ||
62 | - | ||
63 | - for (try = 0; try < 2; try++) { | ||
64 | - | ||
65 | - for (i = 0; i < maxidx; i++) { | ||
66 | - hostaddr[i] = tlb_vaddr_to_host(env, | ||
67 | - vaddr + TARGET_PAGE_SIZE * i, | ||
68 | - 1, mmu_idx); | ||
69 | - if (!hostaddr[i]) { | ||
70 | - break; | ||
71 | - } | ||
72 | - } | ||
73 | - if (i == maxidx) { | ||
74 | - /* | ||
75 | - * If it's all in the TLB it's fair game for just writing to; | ||
76 | - * we know we don't need to update dirty status, etc. | ||
77 | - */ | ||
78 | - for (i = 0; i < maxidx - 1; i++) { | ||
79 | - memset(hostaddr[i], 0, TARGET_PAGE_SIZE); | ||
80 | - } | ||
81 | - memset(hostaddr[i], 0, blocklen - (i * TARGET_PAGE_SIZE)); | ||
82 | - return; | ||
83 | - } | ||
84 | - /* | ||
85 | - * OK, try a store and see if we can populate the tlb. This | ||
86 | - * might cause an exception if the memory isn't writable, | ||
87 | - * in which case we will longjmp out of here. We must for | ||
88 | - * this purpose use the actual register value passed to us | ||
89 | - * so that we get the fault address right. | ||
90 | - */ | ||
91 | - helper_ret_stb_mmu(env, vaddr_in, 0, oi, GETPC()); | ||
92 | - /* Now we can populate the other TLB entries, if any */ | ||
93 | - for (i = 0; i < maxidx; i++) { | ||
94 | - uint64_t va = vaddr + TARGET_PAGE_SIZE * i; | ||
95 | - if (va != (vaddr_in & TARGET_PAGE_MASK)) { | ||
96 | - helper_ret_stb_mmu(env, va, 0, oi, GETPC()); | ||
97 | - } | ||
98 | - } | ||
99 | - } | ||
100 | - | ||
101 | - /* | ||
102 | - * Slow path (probably attempt to do this to an I/O device or | ||
103 | - * similar, or clearing of a block of code we have translations | ||
104 | - * cached for). Just do a series of byte writes as the architecture | ||
105 | - * demands. It's not worth trying to use a cpu_physical_memory_map(), | ||
106 | - * memset(), unmap() sequence here because: | ||
107 | - * + we'd need to account for the blocksize being larger than a page | ||
108 | - * + the direct-RAM access case is almost always going to be dealt | ||
109 | - * with in the fastpath code above, so there's no speed benefit | ||
110 | - * + we would have to deal with the map returning NULL because the | ||
111 | - * bounce buffer was in use | ||
112 | - */ | ||
113 | - for (i = 0; i < blocklen; i++) { | ||
114 | - helper_ret_stb_mmu(env, vaddr + i, 0, oi, GETPC()); | ||
115 | - } | ||
116 | - } | ||
117 | -#else | ||
118 | - memset(g2h(vaddr), 0, blocklen); | ||
119 | -#endif | ||
120 | -} | ||
121 | - | ||
122 | /* Note that signed overflow is undefined in C. The following routines are | ||
123 | careful to use unsigned types where modulo arithmetic is required. | ||
124 | Failure to do so _will_ break on newer gcc. */ | ||
125 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
126 | index XXXXXXX..XXXXXXX 100644 | ||
127 | --- a/target/arm/op_helper.c | ||
128 | +++ b/target/arm/op_helper.c | ||
129 | @@ -XXX,XX +XXX,XX @@ | ||
130 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
131 | */ | ||
132 | #include "qemu/osdep.h" | ||
133 | +#include "qemu/units.h" | ||
134 | #include "qemu/log.h" | ||
135 | #include "qemu/main-loop.h" | ||
136 | #include "cpu.h" | ||
137 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(ror_cc)(CPUARMState *env, uint32_t x, uint32_t i) | ||
138 | return ((uint32_t)x >> shift) | (x << (32 - shift)); | ||
139 | } | ||
140 | } | ||
141 | + | 26 | + |
142 | +void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in) | ||
143 | +{ | ||
144 | + /* | 27 | + /* |
145 | + * Implement DC ZVA, which zeroes a fixed-length block of memory. | 28 | + * The Arm ARM says DBGDIDR is optional and deprecated if EL1 cannot |
146 | + * Note that we do not implement the (architecturally mandated) | 29 | + * use AArch32. Given that bit 15 is RES1, if the value is 0 then |
147 | + * alignment fault for attempts to use this on Device memory | 30 | + * the register must not exist for this cpu. |
148 | + * (which matches the usual QEMU behaviour of not implementing either | ||
149 | + * alignment faults or any memory attribute handling). | ||
150 | + */ | 31 | + */ |
151 | + | 32 | + if (cpu->isar.dbgdidr != 0) { |
152 | + ARMCPU *cpu = env_archcpu(env); | 33 | + ARMCPRegInfo dbgdidr = { |
153 | + uint64_t blocklen = 4 << cpu->dcz_blocksize; | 34 | + .name = "DBGDIDR", .cp = 14, .crn = 0, .crm = 0, |
154 | + uint64_t vaddr = vaddr_in & ~(blocklen - 1); | 35 | + .opc1 = 0, .opc2 = 0, |
155 | + | 36 | + .access = PL0_R, .accessfn = access_tda, |
156 | +#ifndef CONFIG_USER_ONLY | 37 | + .type = ARM_CP_CONST, .resetvalue = cpu->isar.dbgdidr, |
157 | + { | 38 | + }; |
158 | + /* | 39 | + define_one_arm_cp_reg(cpu, &dbgdidr); |
159 | + * Slightly awkwardly, QEMU's TARGET_PAGE_SIZE may be less than | ||
160 | + * the block size so we might have to do more than one TLB lookup. | ||
161 | + * We know that in fact for any v8 CPU the page size is at least 4K | ||
162 | + * and the block size must be 2K or less, but TARGET_PAGE_SIZE is only | ||
163 | + * 1K as an artefact of legacy v5 subpage support being present in the | ||
164 | + * same QEMU executable. So in practice the hostaddr[] array has | ||
165 | + * two entries, given the current setting of TARGET_PAGE_BITS_MIN. | ||
166 | + */ | ||
167 | + int maxidx = DIV_ROUND_UP(blocklen, TARGET_PAGE_SIZE); | ||
168 | + void *hostaddr[DIV_ROUND_UP(2 * KiB, 1 << TARGET_PAGE_BITS_MIN)]; | ||
169 | + int try, i; | ||
170 | + unsigned mmu_idx = cpu_mmu_index(env, false); | ||
171 | + TCGMemOpIdx oi = make_memop_idx(MO_UB, mmu_idx); | ||
172 | + | ||
173 | + assert(maxidx <= ARRAY_SIZE(hostaddr)); | ||
174 | + | ||
175 | + for (try = 0; try < 2; try++) { | ||
176 | + | ||
177 | + for (i = 0; i < maxidx; i++) { | ||
178 | + hostaddr[i] = tlb_vaddr_to_host(env, | ||
179 | + vaddr + TARGET_PAGE_SIZE * i, | ||
180 | + 1, mmu_idx); | ||
181 | + if (!hostaddr[i]) { | ||
182 | + break; | ||
183 | + } | ||
184 | + } | ||
185 | + if (i == maxidx) { | ||
186 | + /* | ||
187 | + * If it's all in the TLB it's fair game for just writing to; | ||
188 | + * we know we don't need to update dirty status, etc. | ||
189 | + */ | ||
190 | + for (i = 0; i < maxidx - 1; i++) { | ||
191 | + memset(hostaddr[i], 0, TARGET_PAGE_SIZE); | ||
192 | + } | ||
193 | + memset(hostaddr[i], 0, blocklen - (i * TARGET_PAGE_SIZE)); | ||
194 | + return; | ||
195 | + } | ||
196 | + /* | ||
197 | + * OK, try a store and see if we can populate the tlb. This | ||
198 | + * might cause an exception if the memory isn't writable, | ||
199 | + * in which case we will longjmp out of here. We must for | ||
200 | + * this purpose use the actual register value passed to us | ||
201 | + * so that we get the fault address right. | ||
202 | + */ | ||
203 | + helper_ret_stb_mmu(env, vaddr_in, 0, oi, GETPC()); | ||
204 | + /* Now we can populate the other TLB entries, if any */ | ||
205 | + for (i = 0; i < maxidx; i++) { | ||
206 | + uint64_t va = vaddr + TARGET_PAGE_SIZE * i; | ||
207 | + if (va != (vaddr_in & TARGET_PAGE_MASK)) { | ||
208 | + helper_ret_stb_mmu(env, va, 0, oi, GETPC()); | ||
209 | + } | ||
210 | + } | ||
211 | + } | ||
212 | + | ||
213 | + /* | ||
214 | + * Slow path (probably attempt to do this to an I/O device or | ||
215 | + * similar, or clearing of a block of code we have translations | ||
216 | + * cached for). Just do a series of byte writes as the architecture | ||
217 | + * demands. It's not worth trying to use a cpu_physical_memory_map(), | ||
218 | + * memset(), unmap() sequence here because: | ||
219 | + * + we'd need to account for the blocksize being larger than a page | ||
220 | + * + the direct-RAM access case is almost always going to be dealt | ||
221 | + * with in the fastpath code above, so there's no speed benefit | ||
222 | + * + we would have to deal with the map returning NULL because the | ||
223 | + * bounce buffer was in use | ||
224 | + */ | ||
225 | + for (i = 0; i < blocklen; i++) { | ||
226 | + helper_ret_stb_mmu(env, vaddr + i, 0, oi, GETPC()); | ||
227 | + } | ||
228 | + } | 40 | + } |
229 | +#else | 41 | |
230 | + memset(g2h(vaddr), 0, blocklen); | 42 | /* Note that all these register fields hold "number of Xs minus 1". */ |
231 | +#endif | 43 | brps = arm_num_brps(cpu); |
232 | +} | 44 | @@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu) |
45 | |||
46 | assert(ctx_cmps <= brps); | ||
47 | |||
48 | - define_one_arm_cp_reg(cpu, &dbgdidr); | ||
49 | define_arm_cp_regs(cpu, debug_cp_reginfo); | ||
50 | |||
51 | if (arm_feature(&cpu->env, ARM_FEATURE_LPAE)) { | ||
233 | -- | 52 | -- |
234 | 2.20.1 | 53 | 2.20.1 |
235 | 54 | ||
236 | 55 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Paolo Bonzini <pbonzini@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Group KVM rules together. | 3 | The properties to attach a CANBUS object to the xlnx-zcu102 machine have |
4 | a period in them. We want to use periods in properties for compound QAPI types, | ||
5 | and besides the "xlnx-zcu102." prefix is both unnecessary and different | ||
6 | from any other machine property name. Remove it. | ||
4 | 7 | ||
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 8 | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> |
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 9 | Message-id: 20210118162537.779542-1-pbonzini@redhat.com |
7 | Message-id: 20190701132516.26392-4-philmd@redhat.com | 10 | Reviewed-by: Vikram Garhwal <fnu.vikram@xilinx.com> |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 12 | --- |
10 | target/arm/Makefile.objs | 9 +++++---- | 13 | hw/arm/xlnx-zcu102.c | 4 ++-- |
11 | 1 file changed, 5 insertions(+), 4 deletions(-) | 14 | tests/qtest/xlnx-can-test.c | 30 +++++++++++++++--------------- |
15 | 2 files changed, 17 insertions(+), 17 deletions(-) | ||
12 | 16 | ||
13 | diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs | 17 | diff --git a/hw/arm/xlnx-zcu102.c b/hw/arm/xlnx-zcu102.c |
14 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/Makefile.objs | 19 | --- a/hw/arm/xlnx-zcu102.c |
16 | +++ b/target/arm/Makefile.objs | 20 | +++ b/hw/arm/xlnx-zcu102.c |
17 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zcu102_machine_instance_init(Object *obj) |
18 | obj-y += arm-semi.o | 22 | s->secure = false; |
19 | obj-$(CONFIG_SOFTMMU) += machine.o psci.o arch_dump.o monitor.o | 23 | /* Default to virt (EL2) being disabled */ |
20 | -obj-$(CONFIG_KVM) += kvm.o | 24 | s->virt = false; |
21 | -obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o | 25 | - object_property_add_link(obj, "xlnx-zcu102.canbus0", TYPE_CAN_BUS, |
22 | -obj-$(call land,$(CONFIG_KVM),$(TARGET_AARCH64)) += kvm64.o | 26 | + object_property_add_link(obj, "canbus0", TYPE_CAN_BUS, |
23 | -obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o | 27 | (Object **)&s->canbus[0], |
24 | obj-y += helper.o vfp_helper.o | 28 | object_property_allow_set_link, |
25 | obj-y += cpu.o gdbstub.o | 29 | 0); |
26 | obj-$(TARGET_AARCH64) += cpu64.o gdbstub64.o | 30 | |
27 | obj-$(CONFIG_SOFTMMU) += arm-powerctl.o | 31 | - object_property_add_link(obj, "xlnx-zcu102.canbus1", TYPE_CAN_BUS, |
28 | 32 | + object_property_add_link(obj, "canbus1", TYPE_CAN_BUS, | |
29 | +obj-$(CONFIG_KVM) += kvm.o | 33 | (Object **)&s->canbus[1], |
30 | +obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o | 34 | object_property_allow_set_link, |
31 | +obj-$(call land,$(CONFIG_KVM),$(TARGET_AARCH64)) += kvm64.o | 35 | 0); |
32 | +obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o | 36 | diff --git a/tests/qtest/xlnx-can-test.c b/tests/qtest/xlnx-can-test.c |
33 | + | 37 | index XXXXXXX..XXXXXXX 100644 |
34 | DECODETREE = $(SRC_PATH)/scripts/decodetree.py | 38 | --- a/tests/qtest/xlnx-can-test.c |
35 | 39 | +++ b/tests/qtest/xlnx-can-test.c | |
36 | target/arm/decode-sve.inc.c: $(SRC_PATH)/target/arm/sve.decode $(DECODETREE) | 40 | @@ -XXX,XX +XXX,XX @@ static void test_can_bus(void) |
41 | uint8_t can_timestamp = 1; | ||
42 | |||
43 | QTestState *qts = qtest_init("-machine xlnx-zcu102" | ||
44 | - " -object can-bus,id=canbus0" | ||
45 | - " -machine xlnx-zcu102.canbus0=canbus0" | ||
46 | - " -machine xlnx-zcu102.canbus1=canbus0" | ||
47 | + " -object can-bus,id=canbus" | ||
48 | + " -machine canbus0=canbus" | ||
49 | + " -machine canbus1=canbus" | ||
50 | ); | ||
51 | |||
52 | /* Configure the CAN0 and CAN1. */ | ||
53 | @@ -XXX,XX +XXX,XX @@ static void test_can_loopback(void) | ||
54 | uint32_t status = 0; | ||
55 | |||
56 | QTestState *qts = qtest_init("-machine xlnx-zcu102" | ||
57 | - " -object can-bus,id=canbus0" | ||
58 | - " -machine xlnx-zcu102.canbus0=canbus0" | ||
59 | - " -machine xlnx-zcu102.canbus1=canbus0" | ||
60 | + " -object can-bus,id=canbus" | ||
61 | + " -machine canbus0=canbus" | ||
62 | + " -machine canbus1=canbus" | ||
63 | ); | ||
64 | |||
65 | /* Configure the CAN0 in loopback mode. */ | ||
66 | @@ -XXX,XX +XXX,XX @@ static void test_can_filter(void) | ||
67 | uint8_t can_timestamp = 1; | ||
68 | |||
69 | QTestState *qts = qtest_init("-machine xlnx-zcu102" | ||
70 | - " -object can-bus,id=canbus0" | ||
71 | - " -machine xlnx-zcu102.canbus0=canbus0" | ||
72 | - " -machine xlnx-zcu102.canbus1=canbus0" | ||
73 | + " -object can-bus,id=canbus" | ||
74 | + " -machine canbus0=canbus" | ||
75 | + " -machine canbus1=canbus" | ||
76 | ); | ||
77 | |||
78 | /* Configure the CAN0 and CAN1. */ | ||
79 | @@ -XXX,XX +XXX,XX @@ static void test_can_sleepmode(void) | ||
80 | uint8_t can_timestamp = 1; | ||
81 | |||
82 | QTestState *qts = qtest_init("-machine xlnx-zcu102" | ||
83 | - " -object can-bus,id=canbus0" | ||
84 | - " -machine xlnx-zcu102.canbus0=canbus0" | ||
85 | - " -machine xlnx-zcu102.canbus1=canbus0" | ||
86 | + " -object can-bus,id=canbus" | ||
87 | + " -machine canbus0=canbus" | ||
88 | + " -machine canbus1=canbus" | ||
89 | ); | ||
90 | |||
91 | /* Configure the CAN0. */ | ||
92 | @@ -XXX,XX +XXX,XX @@ static void test_can_snoopmode(void) | ||
93 | uint8_t can_timestamp = 1; | ||
94 | |||
95 | QTestState *qts = qtest_init("-machine xlnx-zcu102" | ||
96 | - " -object can-bus,id=canbus0" | ||
97 | - " -machine xlnx-zcu102.canbus0=canbus0" | ||
98 | - " -machine xlnx-zcu102.canbus1=canbus0" | ||
99 | + " -object can-bus,id=canbus" | ||
100 | + " -machine canbus0=canbus" | ||
101 | + " -machine canbus1=canbus" | ||
102 | ); | ||
103 | |||
104 | /* Configure the CAN0. */ | ||
37 | -- | 105 | -- |
38 | 2.20.1 | 106 | 2.20.1 |
39 | 107 | ||
40 | 108 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Maxim Uvarov <maxim.uvarov@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | These routines are TCG specific. | 3 | Implement gpio-pwr driver to allow reboot and poweroff machine. |
4 | The arm_deliver_fault() function is only used within the new | 4 | This is simple driver with just 2 gpios lines. Current use case |
5 | helper. Make it static. | 5 | is to reboot and poweroff virt machine in secure mode. Secure |
6 | pl066 gpio chip is needed for that. | ||
6 | 7 | ||
7 | Suggested-by: Alex Bennée <alex.bennee@linaro.org> | 8 | Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> |
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 9 | Reviewed-by: Hao Wu <wuhaotsh@google.com> |
9 | Message-id: 20190701132516.26392-13-philmd@redhat.com | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 12 | --- |
13 | target/arm/Makefile.objs | 1 + | 13 | hw/gpio/gpio_pwr.c | 70 +++++++++++++++++++++++++++++++++++++++++++++ |
14 | target/arm/internals.h | 3 - | 14 | hw/gpio/Kconfig | 3 ++ |
15 | target/arm/cpu.c | 6 +- | 15 | hw/gpio/meson.build | 1 + |
16 | target/arm/helper.c | 53 ----------- | 16 | 3 files changed, 74 insertions(+) |
17 | target/arm/op_helper.c | 135 -------------------------- | 17 | create mode 100644 hw/gpio/gpio_pwr.c |
18 | target/arm/tlb_helper.c | 200 +++++++++++++++++++++++++++++++++++++++ | ||
19 | 6 files changed, 205 insertions(+), 193 deletions(-) | ||
20 | create mode 100644 target/arm/tlb_helper.c | ||
21 | 18 | ||
22 | diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs | 19 | diff --git a/hw/gpio/gpio_pwr.c b/hw/gpio/gpio_pwr.c |
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/target/arm/Makefile.objs | ||
25 | +++ b/target/arm/Makefile.objs | ||
26 | @@ -XXX,XX +XXX,XX @@ target/arm/translate-sve.o: target/arm/decode-sve.inc.c | ||
27 | target/arm/translate.o: target/arm/decode-vfp.inc.c | ||
28 | target/arm/translate.o: target/arm/decode-vfp-uncond.inc.c | ||
29 | |||
30 | +obj-y += tlb_helper.o | ||
31 | obj-y += translate.o op_helper.o | ||
32 | obj-y += crypto_helper.o | ||
33 | obj-y += iwmmxt_helper.o vec_helper.o neon_helper.o | ||
34 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/target/arm/internals.h | ||
37 | +++ b/target/arm/internals.h | ||
38 | @@ -XXX,XX +XXX,XX @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, | ||
39 | MMUAccessType access_type, int mmu_idx, | ||
40 | bool probe, uintptr_t retaddr); | ||
41 | |||
42 | -void arm_deliver_fault(ARMCPU *cpu, vaddr addr, MMUAccessType access_type, | ||
43 | - int mmu_idx, ARMMMUFaultInfo *fi) QEMU_NORETURN; | ||
44 | - | ||
45 | /* Return true if the stage 1 translation regime is using LPAE format page | ||
46 | * tables */ | ||
47 | bool arm_s1_regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx); | ||
48 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/target/arm/cpu.c | ||
51 | +++ b/target/arm/cpu.c | ||
52 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) | ||
53 | cc->gdb_write_register = arm_cpu_gdb_write_register; | ||
54 | #ifndef CONFIG_USER_ONLY | ||
55 | cc->do_interrupt = arm_cpu_do_interrupt; | ||
56 | - cc->do_unaligned_access = arm_cpu_do_unaligned_access; | ||
57 | - cc->do_transaction_failed = arm_cpu_do_transaction_failed; | ||
58 | cc->get_phys_page_attrs_debug = arm_cpu_get_phys_page_attrs_debug; | ||
59 | cc->asidx_from_attrs = arm_asidx_from_attrs; | ||
60 | cc->vmsd = &vmstate_arm_cpu; | ||
61 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) | ||
62 | #ifdef CONFIG_TCG | ||
63 | cc->tcg_initialize = arm_translate_init; | ||
64 | cc->tlb_fill = arm_cpu_tlb_fill; | ||
65 | +#if !defined(CONFIG_USER_ONLY) | ||
66 | + cc->do_unaligned_access = arm_cpu_do_unaligned_access; | ||
67 | + cc->do_transaction_failed = arm_cpu_do_transaction_failed; | ||
68 | +#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */ | ||
69 | #endif | ||
70 | } | ||
71 | |||
72 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
73 | index XXXXXXX..XXXXXXX 100644 | ||
74 | --- a/target/arm/helper.c | ||
75 | +++ b/target/arm/helper.c | ||
76 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | ||
77 | |||
78 | #endif | ||
79 | |||
80 | -bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, | ||
81 | - MMUAccessType access_type, int mmu_idx, | ||
82 | - bool probe, uintptr_t retaddr) | ||
83 | -{ | ||
84 | - ARMCPU *cpu = ARM_CPU(cs); | ||
85 | - | ||
86 | -#ifdef CONFIG_USER_ONLY | ||
87 | - cpu->env.exception.vaddress = address; | ||
88 | - if (access_type == MMU_INST_FETCH) { | ||
89 | - cs->exception_index = EXCP_PREFETCH_ABORT; | ||
90 | - } else { | ||
91 | - cs->exception_index = EXCP_DATA_ABORT; | ||
92 | - } | ||
93 | - cpu_loop_exit_restore(cs, retaddr); | ||
94 | -#else | ||
95 | - hwaddr phys_addr; | ||
96 | - target_ulong page_size; | ||
97 | - int prot, ret; | ||
98 | - MemTxAttrs attrs = {}; | ||
99 | - ARMMMUFaultInfo fi = {}; | ||
100 | - | ||
101 | - /* | ||
102 | - * Walk the page table and (if the mapping exists) add the page | ||
103 | - * to the TLB. On success, return true. Otherwise, if probing, | ||
104 | - * return false. Otherwise populate fsr with ARM DFSR/IFSR fault | ||
105 | - * register format, and signal the fault. | ||
106 | - */ | ||
107 | - ret = get_phys_addr(&cpu->env, address, access_type, | ||
108 | - core_to_arm_mmu_idx(&cpu->env, mmu_idx), | ||
109 | - &phys_addr, &attrs, &prot, &page_size, &fi, NULL); | ||
110 | - if (likely(!ret)) { | ||
111 | - /* | ||
112 | - * Map a single [sub]page. Regions smaller than our declared | ||
113 | - * target page size are handled specially, so for those we | ||
114 | - * pass in the exact addresses. | ||
115 | - */ | ||
116 | - if (page_size >= TARGET_PAGE_SIZE) { | ||
117 | - phys_addr &= TARGET_PAGE_MASK; | ||
118 | - address &= TARGET_PAGE_MASK; | ||
119 | - } | ||
120 | - tlb_set_page_with_attrs(cs, address, phys_addr, attrs, | ||
121 | - prot, mmu_idx, page_size); | ||
122 | - return true; | ||
123 | - } else if (probe) { | ||
124 | - return false; | ||
125 | - } else { | ||
126 | - /* now we have a real cpu fault */ | ||
127 | - cpu_restore_state(cs, retaddr, true); | ||
128 | - arm_deliver_fault(cpu, address, access_type, mmu_idx, &fi); | ||
129 | - } | ||
130 | -#endif | ||
131 | -} | ||
132 | - | ||
133 | /* Note that signed overflow is undefined in C. The following routines are | ||
134 | careful to use unsigned types where modulo arithmetic is required. | ||
135 | Failure to do so _will_ break on newer gcc. */ | ||
136 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
137 | index XXXXXXX..XXXXXXX 100644 | ||
138 | --- a/target/arm/op_helper.c | ||
139 | +++ b/target/arm/op_helper.c | ||
140 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(neon_tbl)(uint32_t ireg, uint32_t def, void *vn, | ||
141 | return val; | ||
142 | } | ||
143 | |||
144 | -#if !defined(CONFIG_USER_ONLY) | ||
145 | - | ||
146 | -static inline uint32_t merge_syn_data_abort(uint32_t template_syn, | ||
147 | - unsigned int target_el, | ||
148 | - bool same_el, bool ea, | ||
149 | - bool s1ptw, bool is_write, | ||
150 | - int fsc) | ||
151 | -{ | ||
152 | - uint32_t syn; | ||
153 | - | ||
154 | - /* | ||
155 | - * ISV is only set for data aborts routed to EL2 and | ||
156 | - * never for stage-1 page table walks faulting on stage 2. | ||
157 | - * | ||
158 | - * Furthermore, ISV is only set for certain kinds of load/stores. | ||
159 | - * If the template syndrome does not have ISV set, we should leave | ||
160 | - * it cleared. | ||
161 | - * | ||
162 | - * See ARMv8 specs, D7-1974: | ||
163 | - * ISS encoding for an exception from a Data Abort, the | ||
164 | - * ISV field. | ||
165 | - */ | ||
166 | - if (!(template_syn & ARM_EL_ISV) || target_el != 2 || s1ptw) { | ||
167 | - syn = syn_data_abort_no_iss(same_el, | ||
168 | - ea, 0, s1ptw, is_write, fsc); | ||
169 | - } else { | ||
170 | - /* | ||
171 | - * Fields: IL, ISV, SAS, SSE, SRT, SF and AR come from the template | ||
172 | - * syndrome created at translation time. | ||
173 | - * Now we create the runtime syndrome with the remaining fields. | ||
174 | - */ | ||
175 | - syn = syn_data_abort_with_iss(same_el, | ||
176 | - 0, 0, 0, 0, 0, | ||
177 | - ea, 0, s1ptw, is_write, fsc, | ||
178 | - false); | ||
179 | - /* Merge the runtime syndrome with the template syndrome. */ | ||
180 | - syn |= template_syn; | ||
181 | - } | ||
182 | - return syn; | ||
183 | -} | ||
184 | - | ||
185 | -void arm_deliver_fault(ARMCPU *cpu, vaddr addr, MMUAccessType access_type, | ||
186 | - int mmu_idx, ARMMMUFaultInfo *fi) | ||
187 | -{ | ||
188 | - CPUARMState *env = &cpu->env; | ||
189 | - int target_el; | ||
190 | - bool same_el; | ||
191 | - uint32_t syn, exc, fsr, fsc; | ||
192 | - ARMMMUIdx arm_mmu_idx = core_to_arm_mmu_idx(env, mmu_idx); | ||
193 | - | ||
194 | - target_el = exception_target_el(env); | ||
195 | - if (fi->stage2) { | ||
196 | - target_el = 2; | ||
197 | - env->cp15.hpfar_el2 = extract64(fi->s2addr, 12, 47) << 4; | ||
198 | - } | ||
199 | - same_el = (arm_current_el(env) == target_el); | ||
200 | - | ||
201 | - if (target_el == 2 || arm_el_is_aa64(env, target_el) || | ||
202 | - arm_s1_regime_using_lpae_format(env, arm_mmu_idx)) { | ||
203 | - /* | ||
204 | - * LPAE format fault status register : bottom 6 bits are | ||
205 | - * status code in the same form as needed for syndrome | ||
206 | - */ | ||
207 | - fsr = arm_fi_to_lfsc(fi); | ||
208 | - fsc = extract32(fsr, 0, 6); | ||
209 | - } else { | ||
210 | - fsr = arm_fi_to_sfsc(fi); | ||
211 | - /* | ||
212 | - * Short format FSR : this fault will never actually be reported | ||
213 | - * to an EL that uses a syndrome register. Use a (currently) | ||
214 | - * reserved FSR code in case the constructed syndrome does leak | ||
215 | - * into the guest somehow. | ||
216 | - */ | ||
217 | - fsc = 0x3f; | ||
218 | - } | ||
219 | - | ||
220 | - if (access_type == MMU_INST_FETCH) { | ||
221 | - syn = syn_insn_abort(same_el, fi->ea, fi->s1ptw, fsc); | ||
222 | - exc = EXCP_PREFETCH_ABORT; | ||
223 | - } else { | ||
224 | - syn = merge_syn_data_abort(env->exception.syndrome, target_el, | ||
225 | - same_el, fi->ea, fi->s1ptw, | ||
226 | - access_type == MMU_DATA_STORE, | ||
227 | - fsc); | ||
228 | - if (access_type == MMU_DATA_STORE | ||
229 | - && arm_feature(env, ARM_FEATURE_V6)) { | ||
230 | - fsr |= (1 << 11); | ||
231 | - } | ||
232 | - exc = EXCP_DATA_ABORT; | ||
233 | - } | ||
234 | - | ||
235 | - env->exception.vaddress = addr; | ||
236 | - env->exception.fsr = fsr; | ||
237 | - raise_exception(env, exc, syn, target_el); | ||
238 | -} | ||
239 | - | ||
240 | -/* Raise a data fault alignment exception for the specified virtual address */ | ||
241 | -void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, | ||
242 | - MMUAccessType access_type, | ||
243 | - int mmu_idx, uintptr_t retaddr) | ||
244 | -{ | ||
245 | - ARMCPU *cpu = ARM_CPU(cs); | ||
246 | - ARMMMUFaultInfo fi = {}; | ||
247 | - | ||
248 | - /* now we have a real cpu fault */ | ||
249 | - cpu_restore_state(cs, retaddr, true); | ||
250 | - | ||
251 | - fi.type = ARMFault_Alignment; | ||
252 | - arm_deliver_fault(cpu, vaddr, access_type, mmu_idx, &fi); | ||
253 | -} | ||
254 | - | ||
255 | -/* | ||
256 | - * arm_cpu_do_transaction_failed: handle a memory system error response | ||
257 | - * (eg "no device/memory present at address") by raising an external abort | ||
258 | - * exception | ||
259 | - */ | ||
260 | -void arm_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, | ||
261 | - vaddr addr, unsigned size, | ||
262 | - MMUAccessType access_type, | ||
263 | - int mmu_idx, MemTxAttrs attrs, | ||
264 | - MemTxResult response, uintptr_t retaddr) | ||
265 | -{ | ||
266 | - ARMCPU *cpu = ARM_CPU(cs); | ||
267 | - ARMMMUFaultInfo fi = {}; | ||
268 | - | ||
269 | - /* now we have a real cpu fault */ | ||
270 | - cpu_restore_state(cs, retaddr, true); | ||
271 | - | ||
272 | - fi.ea = arm_extabort_type(response); | ||
273 | - fi.type = ARMFault_SyncExternal; | ||
274 | - arm_deliver_fault(cpu, addr, access_type, mmu_idx, &fi); | ||
275 | -} | ||
276 | - | ||
277 | -#endif /* !defined(CONFIG_USER_ONLY) */ | ||
278 | - | ||
279 | void HELPER(v8m_stackcheck)(CPUARMState *env, uint32_t newvalue) | ||
280 | { | ||
281 | /* | ||
282 | diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c | ||
283 | new file mode 100644 | 20 | new file mode 100644 |
284 | index XXXXXXX..XXXXXXX | 21 | index XXXXXXX..XXXXXXX |
285 | --- /dev/null | 22 | --- /dev/null |
286 | +++ b/target/arm/tlb_helper.c | 23 | +++ b/hw/gpio/gpio_pwr.c |
287 | @@ -XXX,XX +XXX,XX @@ | 24 | @@ -XXX,XX +XXX,XX @@ |
288 | +/* | 25 | +/* |
289 | + * ARM TLB (Translation lookaside buffer) helpers. | 26 | + * GPIO qemu power controller |
290 | + * | 27 | + * |
291 | + * This code is licensed under the GNU GPL v2 or later. | 28 | + * Copyright (c) 2020 Linaro Limited |
292 | + * | 29 | + * |
30 | + * Author: Maxim Uvarov <maxim.uvarov@linaro.org> | ||
31 | + * | ||
32 | + * Virtual gpio driver which can be used on top of pl061 | ||
33 | + * to reboot and shutdown qemu virtual machine. One of use | ||
34 | + * case is gpio driver for secure world application (ARM | ||
35 | + * Trusted Firmware.). | ||
36 | + * | ||
37 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
38 | + * See the COPYING file in the top-level directory. | ||
293 | + * SPDX-License-Identifier: GPL-2.0-or-later | 39 | + * SPDX-License-Identifier: GPL-2.0-or-later |
294 | + */ | 40 | + */ |
41 | + | ||
42 | +/* | ||
43 | + * QEMU interface: | ||
44 | + * two named input GPIO lines: | ||
45 | + * 'reset' : when asserted, trigger system reset | ||
46 | + * 'shutdown' : when asserted, trigger system shutdown | ||
47 | + */ | ||
48 | + | ||
295 | +#include "qemu/osdep.h" | 49 | +#include "qemu/osdep.h" |
296 | +#include "cpu.h" | 50 | +#include "hw/sysbus.h" |
297 | +#include "internals.h" | 51 | +#include "sysemu/runstate.h" |
298 | +#include "exec/exec-all.h" | ||
299 | + | 52 | + |
300 | +#if !defined(CONFIG_USER_ONLY) | 53 | +#define TYPE_GPIOPWR "gpio-pwr" |
54 | +OBJECT_DECLARE_SIMPLE_TYPE(GPIO_PWR_State, GPIOPWR) | ||
301 | + | 55 | + |
302 | +static inline uint32_t merge_syn_data_abort(uint32_t template_syn, | 56 | +struct GPIO_PWR_State { |
303 | + unsigned int target_el, | 57 | + SysBusDevice parent_obj; |
304 | + bool same_el, bool ea, | 58 | +}; |
305 | + bool s1ptw, bool is_write, | 59 | + |
306 | + int fsc) | 60 | +static void gpio_pwr_reset(void *opaque, int n, int level) |
307 | +{ | 61 | +{ |
308 | + uint32_t syn; | 62 | + if (level) { |
309 | + | 63 | + qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); |
310 | + /* | ||
311 | + * ISV is only set for data aborts routed to EL2 and | ||
312 | + * never for stage-1 page table walks faulting on stage 2. | ||
313 | + * | ||
314 | + * Furthermore, ISV is only set for certain kinds of load/stores. | ||
315 | + * If the template syndrome does not have ISV set, we should leave | ||
316 | + * it cleared. | ||
317 | + * | ||
318 | + * See ARMv8 specs, D7-1974: | ||
319 | + * ISS encoding for an exception from a Data Abort, the | ||
320 | + * ISV field. | ||
321 | + */ | ||
322 | + if (!(template_syn & ARM_EL_ISV) || target_el != 2 || s1ptw) { | ||
323 | + syn = syn_data_abort_no_iss(same_el, | ||
324 | + ea, 0, s1ptw, is_write, fsc); | ||
325 | + } else { | ||
326 | + /* | ||
327 | + * Fields: IL, ISV, SAS, SSE, SRT, SF and AR come from the template | ||
328 | + * syndrome created at translation time. | ||
329 | + * Now we create the runtime syndrome with the remaining fields. | ||
330 | + */ | ||
331 | + syn = syn_data_abort_with_iss(same_el, | ||
332 | + 0, 0, 0, 0, 0, | ||
333 | + ea, 0, s1ptw, is_write, fsc, | ||
334 | + false); | ||
335 | + /* Merge the runtime syndrome with the template syndrome. */ | ||
336 | + syn |= template_syn; | ||
337 | + } | 64 | + } |
338 | + return syn; | ||
339 | +} | 65 | +} |
340 | + | 66 | + |
341 | +static void QEMU_NORETURN arm_deliver_fault(ARMCPU *cpu, vaddr addr, | 67 | +static void gpio_pwr_shutdown(void *opaque, int n, int level) |
342 | + MMUAccessType access_type, | ||
343 | + int mmu_idx, ARMMMUFaultInfo *fi) | ||
344 | +{ | 68 | +{ |
345 | + CPUARMState *env = &cpu->env; | 69 | + if (level) { |
346 | + int target_el; | 70 | + qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); |
347 | + bool same_el; | ||
348 | + uint32_t syn, exc, fsr, fsc; | ||
349 | + ARMMMUIdx arm_mmu_idx = core_to_arm_mmu_idx(env, mmu_idx); | ||
350 | + | ||
351 | + target_el = exception_target_el(env); | ||
352 | + if (fi->stage2) { | ||
353 | + target_el = 2; | ||
354 | + env->cp15.hpfar_el2 = extract64(fi->s2addr, 12, 47) << 4; | ||
355 | + } | 71 | + } |
356 | + same_el = (arm_current_el(env) == target_el); | ||
357 | + | ||
358 | + if (target_el == 2 || arm_el_is_aa64(env, target_el) || | ||
359 | + arm_s1_regime_using_lpae_format(env, arm_mmu_idx)) { | ||
360 | + /* | ||
361 | + * LPAE format fault status register : bottom 6 bits are | ||
362 | + * status code in the same form as needed for syndrome | ||
363 | + */ | ||
364 | + fsr = arm_fi_to_lfsc(fi); | ||
365 | + fsc = extract32(fsr, 0, 6); | ||
366 | + } else { | ||
367 | + fsr = arm_fi_to_sfsc(fi); | ||
368 | + /* | ||
369 | + * Short format FSR : this fault will never actually be reported | ||
370 | + * to an EL that uses a syndrome register. Use a (currently) | ||
371 | + * reserved FSR code in case the constructed syndrome does leak | ||
372 | + * into the guest somehow. | ||
373 | + */ | ||
374 | + fsc = 0x3f; | ||
375 | + } | ||
376 | + | ||
377 | + if (access_type == MMU_INST_FETCH) { | ||
378 | + syn = syn_insn_abort(same_el, fi->ea, fi->s1ptw, fsc); | ||
379 | + exc = EXCP_PREFETCH_ABORT; | ||
380 | + } else { | ||
381 | + syn = merge_syn_data_abort(env->exception.syndrome, target_el, | ||
382 | + same_el, fi->ea, fi->s1ptw, | ||
383 | + access_type == MMU_DATA_STORE, | ||
384 | + fsc); | ||
385 | + if (access_type == MMU_DATA_STORE | ||
386 | + && arm_feature(env, ARM_FEATURE_V6)) { | ||
387 | + fsr |= (1 << 11); | ||
388 | + } | ||
389 | + exc = EXCP_DATA_ABORT; | ||
390 | + } | ||
391 | + | ||
392 | + env->exception.vaddress = addr; | ||
393 | + env->exception.fsr = fsr; | ||
394 | + raise_exception(env, exc, syn, target_el); | ||
395 | +} | 72 | +} |
396 | + | 73 | + |
397 | +/* Raise a data fault alignment exception for the specified virtual address */ | 74 | +static void gpio_pwr_init(Object *obj) |
398 | +void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, | ||
399 | + MMUAccessType access_type, | ||
400 | + int mmu_idx, uintptr_t retaddr) | ||
401 | +{ | 75 | +{ |
402 | + ARMCPU *cpu = ARM_CPU(cs); | 76 | + DeviceState *dev = DEVICE(obj); |
403 | + ARMMMUFaultInfo fi = {}; | ||
404 | + | 77 | + |
405 | + /* now we have a real cpu fault */ | 78 | + qdev_init_gpio_in_named(dev, gpio_pwr_reset, "reset", 1); |
406 | + cpu_restore_state(cs, retaddr, true); | 79 | + qdev_init_gpio_in_named(dev, gpio_pwr_shutdown, "shutdown", 1); |
407 | + | ||
408 | + fi.type = ARMFault_Alignment; | ||
409 | + arm_deliver_fault(cpu, vaddr, access_type, mmu_idx, &fi); | ||
410 | +} | 80 | +} |
411 | + | 81 | + |
412 | +/* | 82 | +static const TypeInfo gpio_pwr_info = { |
413 | + * arm_cpu_do_transaction_failed: handle a memory system error response | 83 | + .name = TYPE_GPIOPWR, |
414 | + * (eg "no device/memory present at address") by raising an external abort | 84 | + .parent = TYPE_SYS_BUS_DEVICE, |
415 | + * exception | 85 | + .instance_size = sizeof(GPIO_PWR_State), |
416 | + */ | 86 | + .instance_init = gpio_pwr_init, |
417 | +void arm_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, | 87 | +}; |
418 | + vaddr addr, unsigned size, | 88 | + |
419 | + MMUAccessType access_type, | 89 | +static void gpio_pwr_register_types(void) |
420 | + int mmu_idx, MemTxAttrs attrs, | ||
421 | + MemTxResult response, uintptr_t retaddr) | ||
422 | +{ | 90 | +{ |
423 | + ARMCPU *cpu = ARM_CPU(cs); | 91 | + type_register_static(&gpio_pwr_info); |
424 | + ARMMMUFaultInfo fi = {}; | ||
425 | + | ||
426 | + /* now we have a real cpu fault */ | ||
427 | + cpu_restore_state(cs, retaddr, true); | ||
428 | + | ||
429 | + fi.ea = arm_extabort_type(response); | ||
430 | + fi.type = ARMFault_SyncExternal; | ||
431 | + arm_deliver_fault(cpu, addr, access_type, mmu_idx, &fi); | ||
432 | +} | 92 | +} |
433 | + | 93 | + |
434 | +#endif /* !defined(CONFIG_USER_ONLY) */ | 94 | +type_init(gpio_pwr_register_types) |
95 | diff --git a/hw/gpio/Kconfig b/hw/gpio/Kconfig | ||
96 | index XXXXXXX..XXXXXXX 100644 | ||
97 | --- a/hw/gpio/Kconfig | ||
98 | +++ b/hw/gpio/Kconfig | ||
99 | @@ -XXX,XX +XXX,XX @@ config PL061 | ||
100 | config GPIO_KEY | ||
101 | bool | ||
102 | |||
103 | +config GPIO_PWR | ||
104 | + bool | ||
435 | + | 105 | + |
436 | +bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, | 106 | config SIFIVE_GPIO |
437 | + MMUAccessType access_type, int mmu_idx, | 107 | bool |
438 | + bool probe, uintptr_t retaddr) | 108 | diff --git a/hw/gpio/meson.build b/hw/gpio/meson.build |
439 | +{ | 109 | index XXXXXXX..XXXXXXX 100644 |
440 | + ARMCPU *cpu = ARM_CPU(cs); | 110 | --- a/hw/gpio/meson.build |
441 | + | 111 | +++ b/hw/gpio/meson.build |
442 | +#ifdef CONFIG_USER_ONLY | 112 | @@ -XXX,XX +XXX,XX @@ |
443 | + cpu->env.exception.vaddress = address; | 113 | softmmu_ss.add(when: 'CONFIG_E500', if_true: files('mpc8xxx.c')) |
444 | + if (access_type == MMU_INST_FETCH) { | 114 | softmmu_ss.add(when: 'CONFIG_GPIO_KEY', if_true: files('gpio_key.c')) |
445 | + cs->exception_index = EXCP_PREFETCH_ABORT; | 115 | +softmmu_ss.add(when: 'CONFIG_GPIO_PWR', if_true: files('gpio_pwr.c')) |
446 | + } else { | 116 | softmmu_ss.add(when: 'CONFIG_MAX7310', if_true: files('max7310.c')) |
447 | + cs->exception_index = EXCP_DATA_ABORT; | 117 | softmmu_ss.add(when: 'CONFIG_PL061', if_true: files('pl061.c')) |
448 | + } | 118 | softmmu_ss.add(when: 'CONFIG_PUV3', if_true: files('puv3_gpio.c')) |
449 | + cpu_loop_exit_restore(cs, retaddr); | ||
450 | +#else | ||
451 | + hwaddr phys_addr; | ||
452 | + target_ulong page_size; | ||
453 | + int prot, ret; | ||
454 | + MemTxAttrs attrs = {}; | ||
455 | + ARMMMUFaultInfo fi = {}; | ||
456 | + | ||
457 | + /* | ||
458 | + * Walk the page table and (if the mapping exists) add the page | ||
459 | + * to the TLB. On success, return true. Otherwise, if probing, | ||
460 | + * return false. Otherwise populate fsr with ARM DFSR/IFSR fault | ||
461 | + * register format, and signal the fault. | ||
462 | + */ | ||
463 | + ret = get_phys_addr(&cpu->env, address, access_type, | ||
464 | + core_to_arm_mmu_idx(&cpu->env, mmu_idx), | ||
465 | + &phys_addr, &attrs, &prot, &page_size, &fi, NULL); | ||
466 | + if (likely(!ret)) { | ||
467 | + /* | ||
468 | + * Map a single [sub]page. Regions smaller than our declared | ||
469 | + * target page size are handled specially, so for those we | ||
470 | + * pass in the exact addresses. | ||
471 | + */ | ||
472 | + if (page_size >= TARGET_PAGE_SIZE) { | ||
473 | + phys_addr &= TARGET_PAGE_MASK; | ||
474 | + address &= TARGET_PAGE_MASK; | ||
475 | + } | ||
476 | + tlb_set_page_with_attrs(cs, address, phys_addr, attrs, | ||
477 | + prot, mmu_idx, page_size); | ||
478 | + return true; | ||
479 | + } else if (probe) { | ||
480 | + return false; | ||
481 | + } else { | ||
482 | + /* now we have a real cpu fault */ | ||
483 | + cpu_restore_state(cs, retaddr, true); | ||
484 | + arm_deliver_fault(cpu, address, access_type, mmu_idx, &fi); | ||
485 | + } | ||
486 | +#endif | ||
487 | +} | ||
488 | -- | 119 | -- |
489 | 2.20.1 | 120 | 2.20.1 |
490 | 121 | ||
491 | 122 | diff view generated by jsdifflib |
1 | From: Jan Kiszka <jan.kiszka@siemens.com> | 1 | From: Maxim Uvarov <maxim.uvarov@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Allow cortex-a7 to be used with the virt board; it supports | 3 | No functional change. Just refactor code to better |
4 | the v7VE features and there is no reason to deny this type. | 4 | support secure and normal world gpios. |
5 | 5 | ||
6 | Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> | 6 | Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 7 | Reviewed-by: Andrew Jones <drjones@redhat.com> |
8 | Message-id: fc5404f7-4d1d-c28f-6e48-d8799c82acc0@web.de | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 9 | --- |
12 | hw/arm/virt.c | 1 + | 10 | hw/arm/virt.c | 57 ++++++++++++++++++++++++++++++++------------------- |
13 | 1 file changed, 1 insertion(+) | 11 | 1 file changed, 36 insertions(+), 21 deletions(-) |
14 | 12 | ||
15 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 13 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
16 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/virt.c | 15 | --- a/hw/arm/virt.c |
18 | +++ b/hw/arm/virt.c | 16 | +++ b/hw/arm/virt.c |
19 | @@ -XXX,XX +XXX,XX @@ static const int a15irqmap[] = { | 17 | @@ -XXX,XX +XXX,XX @@ static void virt_powerdown_req(Notifier *n, void *opaque) |
20 | }; | 18 | } |
21 | 19 | } | |
22 | static const char *valid_cpus[] = { | 20 | |
23 | + ARM_CPU_TYPE_NAME("cortex-a7"), | 21 | -static void create_gpio(const VirtMachineState *vms) |
24 | ARM_CPU_TYPE_NAME("cortex-a15"), | 22 | +static void create_gpio_keys(const VirtMachineState *vms, |
25 | ARM_CPU_TYPE_NAME("cortex-a53"), | 23 | + DeviceState *pl061_dev, |
26 | ARM_CPU_TYPE_NAME("cortex-a57"), | 24 | + uint32_t phandle) |
25 | +{ | ||
26 | + gpio_key_dev = sysbus_create_simple("gpio-key", -1, | ||
27 | + qdev_get_gpio_in(pl061_dev, 3)); | ||
28 | + | ||
29 | + qemu_fdt_add_subnode(vms->fdt, "/gpio-keys"); | ||
30 | + qemu_fdt_setprop_string(vms->fdt, "/gpio-keys", "compatible", "gpio-keys"); | ||
31 | + qemu_fdt_setprop_cell(vms->fdt, "/gpio-keys", "#size-cells", 0); | ||
32 | + qemu_fdt_setprop_cell(vms->fdt, "/gpio-keys", "#address-cells", 1); | ||
33 | + | ||
34 | + qemu_fdt_add_subnode(vms->fdt, "/gpio-keys/poweroff"); | ||
35 | + qemu_fdt_setprop_string(vms->fdt, "/gpio-keys/poweroff", | ||
36 | + "label", "GPIO Key Poweroff"); | ||
37 | + qemu_fdt_setprop_cell(vms->fdt, "/gpio-keys/poweroff", "linux,code", | ||
38 | + KEY_POWER); | ||
39 | + qemu_fdt_setprop_cells(vms->fdt, "/gpio-keys/poweroff", | ||
40 | + "gpios", phandle, 3, 0); | ||
41 | +} | ||
42 | + | ||
43 | +static void create_gpio_devices(const VirtMachineState *vms, int gpio, | ||
44 | + MemoryRegion *mem) | ||
45 | { | ||
46 | char *nodename; | ||
47 | DeviceState *pl061_dev; | ||
48 | - hwaddr base = vms->memmap[VIRT_GPIO].base; | ||
49 | - hwaddr size = vms->memmap[VIRT_GPIO].size; | ||
50 | - int irq = vms->irqmap[VIRT_GPIO]; | ||
51 | + hwaddr base = vms->memmap[gpio].base; | ||
52 | + hwaddr size = vms->memmap[gpio].size; | ||
53 | + int irq = vms->irqmap[gpio]; | ||
54 | const char compat[] = "arm,pl061\0arm,primecell"; | ||
55 | + SysBusDevice *s; | ||
56 | |||
57 | - pl061_dev = sysbus_create_simple("pl061", base, | ||
58 | - qdev_get_gpio_in(vms->gic, irq)); | ||
59 | + pl061_dev = qdev_new("pl061"); | ||
60 | + s = SYS_BUS_DEVICE(pl061_dev); | ||
61 | + sysbus_realize_and_unref(s, &error_fatal); | ||
62 | + memory_region_add_subregion(mem, base, sysbus_mmio_get_region(s, 0)); | ||
63 | + sysbus_connect_irq(s, 0, qdev_get_gpio_in(vms->gic, irq)); | ||
64 | |||
65 | uint32_t phandle = qemu_fdt_alloc_phandle(vms->fdt); | ||
66 | nodename = g_strdup_printf("/pl061@%" PRIx64, base); | ||
67 | @@ -XXX,XX +XXX,XX @@ static void create_gpio(const VirtMachineState *vms) | ||
68 | qemu_fdt_setprop_string(vms->fdt, nodename, "clock-names", "apb_pclk"); | ||
69 | qemu_fdt_setprop_cell(vms->fdt, nodename, "phandle", phandle); | ||
70 | |||
71 | - gpio_key_dev = sysbus_create_simple("gpio-key", -1, | ||
72 | - qdev_get_gpio_in(pl061_dev, 3)); | ||
73 | - qemu_fdt_add_subnode(vms->fdt, "/gpio-keys"); | ||
74 | - qemu_fdt_setprop_string(vms->fdt, "/gpio-keys", "compatible", "gpio-keys"); | ||
75 | - qemu_fdt_setprop_cell(vms->fdt, "/gpio-keys", "#size-cells", 0); | ||
76 | - qemu_fdt_setprop_cell(vms->fdt, "/gpio-keys", "#address-cells", 1); | ||
77 | - | ||
78 | - qemu_fdt_add_subnode(vms->fdt, "/gpio-keys/poweroff"); | ||
79 | - qemu_fdt_setprop_string(vms->fdt, "/gpio-keys/poweroff", | ||
80 | - "label", "GPIO Key Poweroff"); | ||
81 | - qemu_fdt_setprop_cell(vms->fdt, "/gpio-keys/poweroff", "linux,code", | ||
82 | - KEY_POWER); | ||
83 | - qemu_fdt_setprop_cells(vms->fdt, "/gpio-keys/poweroff", | ||
84 | - "gpios", phandle, 3, 0); | ||
85 | g_free(nodename); | ||
86 | + | ||
87 | + /* Child gpio devices */ | ||
88 | + create_gpio_keys(vms, pl061_dev, phandle); | ||
89 | } | ||
90 | |||
91 | static void create_virtio_devices(const VirtMachineState *vms) | ||
92 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
93 | if (has_ged && aarch64 && firmware_loaded && virt_is_acpi_enabled(vms)) { | ||
94 | vms->acpi_dev = create_acpi_ged(vms); | ||
95 | } else { | ||
96 | - create_gpio(vms); | ||
97 | + create_gpio_devices(vms, VIRT_GPIO, sysmem); | ||
98 | } | ||
99 | |||
100 | /* connect powerdown request */ | ||
27 | -- | 101 | -- |
28 | 2.20.1 | 102 | 2.20.1 |
29 | 103 | ||
30 | 104 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Maxim Uvarov <maxim.uvarov@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The vfp_set_fpscr() helper contains code specific to the host | 3 | Add secure pl061 for reset/power down machine from |
4 | floating point implementation (here the SoftFloat library). | 4 | the secure world (Arm Trusted Firmware). Connect it |
5 | Extract this code to vfp_set_fpscr_to_host(). | 5 | with gpio-pwr driver. |
6 | 6 | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 7 | Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> |
8 | Message-id: 20190701132516.26392-16-philmd@redhat.com | 8 | Reviewed-by: Andrew Jones <drjones@redhat.com> |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | [PMM: Added mention of the new device to the documentation] |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 11 | --- |
12 | target/arm/vfp_helper.c | 127 +++++++++++++++++++++------------------- | 12 | docs/system/arm/virt.rst | 2 ++ |
13 | 1 file changed, 66 insertions(+), 61 deletions(-) | 13 | include/hw/arm/virt.h | 2 ++ |
14 | hw/arm/virt.c | 56 +++++++++++++++++++++++++++++++++++++++- | ||
15 | hw/arm/Kconfig | 1 + | ||
16 | 4 files changed, 60 insertions(+), 1 deletion(-) | ||
14 | 17 | ||
15 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | 18 | diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst |
16 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/vfp_helper.c | 20 | --- a/docs/system/arm/virt.rst |
18 | +++ b/target/arm/vfp_helper.c | 21 | +++ b/docs/system/arm/virt.rst |
19 | @@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_to_host(int target_bits) | 22 | @@ -XXX,XX +XXX,XX @@ The virt board supports: |
20 | return host_bits; | 23 | - Secure-World-only devices if the CPU has TrustZone: |
24 | |||
25 | - A second PL011 UART | ||
26 | + - A second PL061 GPIO controller, with GPIO lines for triggering | ||
27 | + a system reset or system poweroff | ||
28 | - A secure flash memory | ||
29 | - 16MB of secure RAM | ||
30 | |||
31 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/include/hw/arm/virt.h | ||
34 | +++ b/include/hw/arm/virt.h | ||
35 | @@ -XXX,XX +XXX,XX @@ enum { | ||
36 | VIRT_GPIO, | ||
37 | VIRT_SECURE_UART, | ||
38 | VIRT_SECURE_MEM, | ||
39 | + VIRT_SECURE_GPIO, | ||
40 | VIRT_PCDIMM_ACPI, | ||
41 | VIRT_ACPI_GED, | ||
42 | VIRT_NVDIMM_ACPI, | ||
43 | @@ -XXX,XX +XXX,XX @@ struct VirtMachineClass { | ||
44 | bool kvm_no_adjvtime; | ||
45 | bool no_kvm_steal_time; | ||
46 | bool acpi_expose_flash; | ||
47 | + bool no_secure_gpio; | ||
48 | }; | ||
49 | |||
50 | struct VirtMachineState { | ||
51 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/hw/arm/virt.c | ||
54 | +++ b/hw/arm/virt.c | ||
55 | @@ -XXX,XX +XXX,XX @@ static const MemMapEntry base_memmap[] = { | ||
56 | [VIRT_ACPI_GED] = { 0x09080000, ACPI_GED_EVT_SEL_LEN }, | ||
57 | [VIRT_NVDIMM_ACPI] = { 0x09090000, NVDIMM_ACPI_IO_LEN}, | ||
58 | [VIRT_PVTIME] = { 0x090a0000, 0x00010000 }, | ||
59 | + [VIRT_SECURE_GPIO] = { 0x090b0000, 0x00001000 }, | ||
60 | [VIRT_MMIO] = { 0x0a000000, 0x00000200 }, | ||
61 | /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */ | ||
62 | [VIRT_PLATFORM_BUS] = { 0x0c000000, 0x02000000 }, | ||
63 | @@ -XXX,XX +XXX,XX @@ static void create_gpio_keys(const VirtMachineState *vms, | ||
64 | "gpios", phandle, 3, 0); | ||
21 | } | 65 | } |
22 | 66 | ||
23 | -uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env) | 67 | +#define SECURE_GPIO_POWEROFF 0 |
24 | -{ | 68 | +#define SECURE_GPIO_RESET 1 |
25 | - uint32_t i, fpscr; | 69 | + |
26 | - | 70 | +static void create_secure_gpio_pwr(const VirtMachineState *vms, |
27 | - fpscr = env->vfp.xregs[ARM_VFP_FPSCR] | 71 | + DeviceState *pl061_dev, |
28 | - | (env->vfp.vec_len << 16) | 72 | + uint32_t phandle) |
29 | - | (env->vfp.vec_stride << 20); | ||
30 | - | ||
31 | - i = get_float_exception_flags(&env->vfp.fp_status); | ||
32 | - i |= get_float_exception_flags(&env->vfp.standard_fp_status); | ||
33 | - /* FZ16 does not generate an input denormal exception. */ | ||
34 | - i |= (get_float_exception_flags(&env->vfp.fp_status_f16) | ||
35 | - & ~float_flag_input_denormal); | ||
36 | - fpscr |= vfp_exceptbits_from_host(i); | ||
37 | - | ||
38 | - i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3]; | ||
39 | - fpscr |= i ? FPCR_QC : 0; | ||
40 | - | ||
41 | - return fpscr; | ||
42 | -} | ||
43 | - | ||
44 | -uint32_t vfp_get_fpscr(CPUARMState *env) | ||
45 | -{ | ||
46 | - return HELPER(vfp_get_fpscr)(env); | ||
47 | -} | ||
48 | - | ||
49 | -void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) | ||
50 | +static void vfp_set_fpscr_to_host(CPUARMState *env, uint32_t val) | ||
51 | { | ||
52 | int i; | ||
53 | uint32_t changed = env->vfp.xregs[ARM_VFP_FPSCR]; | ||
54 | |||
55 | - /* When ARMv8.2-FP16 is not supported, FZ16 is RES0. */ | ||
56 | - if (!cpu_isar_feature(aa64_fp16, env_archcpu(env))) { | ||
57 | - val &= ~FPCR_FZ16; | ||
58 | - } | ||
59 | - | ||
60 | - if (arm_feature(env, ARM_FEATURE_M)) { | ||
61 | - /* | ||
62 | - * M profile FPSCR is RES0 for the QC, STRIDE, FZ16, LEN bits | ||
63 | - * and also for the trapped-exception-handling bits IxE. | ||
64 | - */ | ||
65 | - val &= 0xf7c0009f; | ||
66 | - } | ||
67 | - | ||
68 | - /* | ||
69 | - * We don't implement trapped exception handling, so the | ||
70 | - * trap enable bits, IDE|IXE|UFE|OFE|DZE|IOE are all RAZ/WI (not RES0!) | ||
71 | - * | ||
72 | - * If we exclude the exception flags, IOC|DZC|OFC|UFC|IXC|IDC | ||
73 | - * (which are stored in fp_status), and the other RES0 bits | ||
74 | - * in between, then we clear all of the low 16 bits. | ||
75 | - */ | ||
76 | - env->vfp.xregs[ARM_VFP_FPSCR] = val & 0xf7c80000; | ||
77 | - env->vfp.vec_len = (val >> 16) & 7; | ||
78 | - env->vfp.vec_stride = (val >> 20) & 3; | ||
79 | - | ||
80 | - /* | ||
81 | - * The bit we set within fpscr_q is arbitrary; the register as a | ||
82 | - * whole being zero/non-zero is what counts. | ||
83 | - */ | ||
84 | - env->vfp.qc[0] = val & FPCR_QC; | ||
85 | - env->vfp.qc[1] = 0; | ||
86 | - env->vfp.qc[2] = 0; | ||
87 | - env->vfp.qc[3] = 0; | ||
88 | - | ||
89 | changed ^= val; | ||
90 | if (changed & (3 << 22)) { | ||
91 | i = (val >> 22) & 3; | ||
92 | @@ -XXX,XX +XXX,XX @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) | ||
93 | set_float_exception_flags(0, &env->vfp.standard_fp_status); | ||
94 | } | ||
95 | |||
96 | +uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env) | ||
97 | +{ | 73 | +{ |
98 | + uint32_t i, fpscr; | 74 | + DeviceState *gpio_pwr_dev; |
99 | + | 75 | + |
100 | + fpscr = env->vfp.xregs[ARM_VFP_FPSCR] | 76 | + /* gpio-pwr */ |
101 | + | (env->vfp.vec_len << 16) | 77 | + gpio_pwr_dev = sysbus_create_simple("gpio-pwr", -1, NULL); |
102 | + | (env->vfp.vec_stride << 20); | ||
103 | + | 78 | + |
104 | + i = get_float_exception_flags(&env->vfp.fp_status); | 79 | + /* connect secure pl061 to gpio-pwr */ |
105 | + i |= get_float_exception_flags(&env->vfp.standard_fp_status); | 80 | + qdev_connect_gpio_out(pl061_dev, SECURE_GPIO_RESET, |
106 | + /* FZ16 does not generate an input denormal exception. */ | 81 | + qdev_get_gpio_in_named(gpio_pwr_dev, "reset", 0)); |
107 | + i |= (get_float_exception_flags(&env->vfp.fp_status_f16) | 82 | + qdev_connect_gpio_out(pl061_dev, SECURE_GPIO_POWEROFF, |
108 | + & ~float_flag_input_denormal); | 83 | + qdev_get_gpio_in_named(gpio_pwr_dev, "shutdown", 0)); |
109 | + fpscr |= vfp_exceptbits_from_host(i); | ||
110 | + | 84 | + |
111 | + i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3]; | 85 | + qemu_fdt_add_subnode(vms->fdt, "/gpio-poweroff"); |
112 | + fpscr |= i ? FPCR_QC : 0; | 86 | + qemu_fdt_setprop_string(vms->fdt, "/gpio-poweroff", "compatible", |
87 | + "gpio-poweroff"); | ||
88 | + qemu_fdt_setprop_cells(vms->fdt, "/gpio-poweroff", | ||
89 | + "gpios", phandle, SECURE_GPIO_POWEROFF, 0); | ||
90 | + qemu_fdt_setprop_string(vms->fdt, "/gpio-poweroff", "status", "disabled"); | ||
91 | + qemu_fdt_setprop_string(vms->fdt, "/gpio-poweroff", "secure-status", | ||
92 | + "okay"); | ||
113 | + | 93 | + |
114 | + return fpscr; | 94 | + qemu_fdt_add_subnode(vms->fdt, "/gpio-restart"); |
95 | + qemu_fdt_setprop_string(vms->fdt, "/gpio-restart", "compatible", | ||
96 | + "gpio-restart"); | ||
97 | + qemu_fdt_setprop_cells(vms->fdt, "/gpio-restart", | ||
98 | + "gpios", phandle, SECURE_GPIO_RESET, 0); | ||
99 | + qemu_fdt_setprop_string(vms->fdt, "/gpio-restart", "status", "disabled"); | ||
100 | + qemu_fdt_setprop_string(vms->fdt, "/gpio-restart", "secure-status", | ||
101 | + "okay"); | ||
115 | +} | 102 | +} |
116 | + | 103 | + |
117 | +uint32_t vfp_get_fpscr(CPUARMState *env) | 104 | static void create_gpio_devices(const VirtMachineState *vms, int gpio, |
118 | +{ | 105 | MemoryRegion *mem) |
119 | + return HELPER(vfp_get_fpscr)(env); | 106 | { |
120 | +} | 107 | @@ -XXX,XX +XXX,XX @@ static void create_gpio_devices(const VirtMachineState *vms, int gpio, |
121 | + | 108 | qemu_fdt_setprop_string(vms->fdt, nodename, "clock-names", "apb_pclk"); |
122 | +void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) | 109 | qemu_fdt_setprop_cell(vms->fdt, nodename, "phandle", phandle); |
123 | +{ | 110 | |
124 | + /* When ARMv8.2-FP16 is not supported, FZ16 is RES0. */ | 111 | + if (gpio != VIRT_GPIO) { |
125 | + if (!cpu_isar_feature(aa64_fp16, env_archcpu(env))) { | 112 | + /* Mark as not usable by the normal world */ |
126 | + val &= ~FPCR_FZ16; | 113 | + qemu_fdt_setprop_string(vms->fdt, nodename, "status", "disabled"); |
114 | + qemu_fdt_setprop_string(vms->fdt, nodename, "secure-status", "okay"); | ||
115 | + } | ||
116 | g_free(nodename); | ||
117 | |||
118 | /* Child gpio devices */ | ||
119 | - create_gpio_keys(vms, pl061_dev, phandle); | ||
120 | + if (gpio == VIRT_GPIO) { | ||
121 | + create_gpio_keys(vms, pl061_dev, phandle); | ||
122 | + } else { | ||
123 | + create_secure_gpio_pwr(vms, pl061_dev, phandle); | ||
124 | + } | ||
125 | } | ||
126 | |||
127 | static void create_virtio_devices(const VirtMachineState *vms) | ||
128 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
129 | create_gpio_devices(vms, VIRT_GPIO, sysmem); | ||
130 | } | ||
131 | |||
132 | + if (vms->secure && !vmc->no_secure_gpio) { | ||
133 | + create_gpio_devices(vms, VIRT_SECURE_GPIO, secure_sysmem); | ||
127 | + } | 134 | + } |
128 | + | 135 | + |
129 | + if (arm_feature(env, ARM_FEATURE_M)) { | 136 | /* connect powerdown request */ |
130 | + /* | 137 | vms->powerdown_notifier.notify = virt_powerdown_req; |
131 | + * M profile FPSCR is RES0 for the QC, STRIDE, FZ16, LEN bits | 138 | qemu_register_powerdown_notifier(&vms->powerdown_notifier); |
132 | + * and also for the trapped-exception-handling bits IxE. | 139 | @@ -XXX,XX +XXX,XX @@ DEFINE_VIRT_MACHINE_AS_LATEST(6, 0) |
133 | + */ | 140 | |
134 | + val &= 0xf7c0009f; | 141 | static void virt_machine_5_2_options(MachineClass *mc) |
135 | + } | 142 | { |
143 | + VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc)); | ||
136 | + | 144 | + |
137 | + /* | 145 | virt_machine_6_0_options(mc); |
138 | + * We don't implement trapped exception handling, so the | 146 | compat_props_add(mc->compat_props, hw_compat_5_2, hw_compat_5_2_len); |
139 | + * trap enable bits, IDE|IXE|UFE|OFE|DZE|IOE are all RAZ/WI (not RES0!) | 147 | + vmc->no_secure_gpio = true; |
140 | + * | 148 | } |
141 | + * If we exclude the exception flags, IOC|DZC|OFC|UFC|IXC|IDC | 149 | DEFINE_VIRT_MACHINE(5, 2) |
142 | + * (which are stored in fp_status), and the other RES0 bits | 150 | |
143 | + * in between, then we clear all of the low 16 bits. | 151 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig |
144 | + */ | 152 | index XXXXXXX..XXXXXXX 100644 |
145 | + env->vfp.xregs[ARM_VFP_FPSCR] = val & 0xf7c80000; | 153 | --- a/hw/arm/Kconfig |
146 | + env->vfp.vec_len = (val >> 16) & 7; | 154 | +++ b/hw/arm/Kconfig |
147 | + env->vfp.vec_stride = (val >> 20) & 3; | 155 | @@ -XXX,XX +XXX,XX @@ config ARM_VIRT |
148 | + | 156 | select PL011 # UART |
149 | + /* | 157 | select PL031 # RTC |
150 | + * The bit we set within fpscr_q is arbitrary; the register as a | 158 | select PL061 # GPIO |
151 | + * whole being zero/non-zero is what counts. | 159 | + select GPIO_PWR |
152 | + */ | 160 | select PLATFORM_BUS |
153 | + env->vfp.qc[0] = val & FPCR_QC; | 161 | select SMBIOS |
154 | + env->vfp.qc[1] = 0; | 162 | select VIRTIO_MMIO |
155 | + env->vfp.qc[2] = 0; | ||
156 | + env->vfp.qc[3] = 0; | ||
157 | + | ||
158 | + vfp_set_fpscr_to_host(env, val); | ||
159 | +} | ||
160 | + | ||
161 | void vfp_set_fpscr(CPUARMState *env, uint32_t val) | ||
162 | { | ||
163 | HELPER(vfp_set_fpscr)(env, val); | ||
164 | -- | 163 | -- |
165 | 2.20.1 | 164 | 2.20.1 |
166 | 165 | ||
167 | 166 | diff view generated by jsdifflib |
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | 1 | From: Hao Wu <wuhaotsh@google.com> |
---|---|---|---|
2 | 2 | ||
3 | MSI mapping needs to be update when MSI address changes, so add the | 3 | Fix potential overflow problem when calculating pwm_duty. |
4 | code to do so. | 4 | 1. Ensure p->cmr and p->cnr to be from [0,65535], according to the |
5 | hardware specification. | ||
6 | 2. Changed duty to uint32_t. However, since MAX_DUTY * (p->cmr+1) | ||
7 | can excceed UINT32_MAX, we convert them to uint64_t in computation | ||
8 | and converted them back to uint32_t. | ||
9 | (duty is guaranteed to be <= MAX_DUTY so it won't overflow.) | ||
5 | 10 | ||
6 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> | 11 | Fixes: CID 1442342 |
7 | Cc: Peter Maydell <peter.maydell@linaro.org> | 12 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Cc: Michael S. Tsirkin <mst@redhat.com> | 13 | Reviewed-by: Doug Evans <dje@google.com> |
9 | Cc: qemu-devel@nongnu.org | 14 | Signed-off-by: Hao Wu <wuhaotsh@google.com> |
10 | Cc: qemu-arm@nongnu.org | 15 | Message-id: 20210127011142.2122790-1-wuhaotsh@google.com |
11 | Acked-by: Michael S. Tsirkin <mst@redhat.com> | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 18 | --- |
15 | hw/pci-host/designware.c | 2 ++ | 19 | hw/misc/npcm7xx_pwm.c | 23 +++++++++++++++++++---- |
16 | 1 file changed, 2 insertions(+) | 20 | tests/qtest/npcm7xx_pwm-test.c | 4 ++-- |
21 | 2 files changed, 21 insertions(+), 6 deletions(-) | ||
17 | 22 | ||
18 | diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c | 23 | diff --git a/hw/misc/npcm7xx_pwm.c b/hw/misc/npcm7xx_pwm.c |
19 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/pci-host/designware.c | 25 | --- a/hw/misc/npcm7xx_pwm.c |
21 | +++ b/hw/pci-host/designware.c | 26 | +++ b/hw/misc/npcm7xx_pwm.c |
22 | @@ -XXX,XX +XXX,XX @@ static void designware_pcie_root_config_write(PCIDevice *d, uint32_t address, | 27 | @@ -XXX,XX +XXX,XX @@ REG32(NPCM7XX_PWM_PWDR3, 0x50); |
23 | case DESIGNWARE_PCIE_MSI_ADDR_LO: | 28 | #define NPCM7XX_CH_INV BIT(2) |
24 | root->msi.base &= 0xFFFFFFFF00000000ULL; | 29 | #define NPCM7XX_CH_MOD BIT(3) |
25 | root->msi.base |= val; | 30 | |
26 | + designware_pcie_root_update_msi_mapping(root); | 31 | +#define NPCM7XX_MAX_CMR 65535 |
32 | +#define NPCM7XX_MAX_CNR 65535 | ||
33 | + | ||
34 | /* Offset of each PWM channel's prescaler in the PPR register. */ | ||
35 | static const int npcm7xx_ppr_base[] = { 0, 0, 8, 8 }; | ||
36 | /* Offset of each PWM channel's clock selector in the CSR register. */ | ||
37 | @@ -XXX,XX +XXX,XX @@ static uint32_t npcm7xx_pwm_calculate_freq(NPCM7xxPWM *p) | ||
38 | |||
39 | static uint32_t npcm7xx_pwm_calculate_duty(NPCM7xxPWM *p) | ||
40 | { | ||
41 | - uint64_t duty; | ||
42 | + uint32_t duty; | ||
43 | |||
44 | if (p->running) { | ||
45 | if (p->cnr == 0) { | ||
46 | @@ -XXX,XX +XXX,XX @@ static uint32_t npcm7xx_pwm_calculate_duty(NPCM7xxPWM *p) | ||
47 | } else if (p->cmr >= p->cnr) { | ||
48 | duty = NPCM7XX_PWM_MAX_DUTY; | ||
49 | } else { | ||
50 | - duty = NPCM7XX_PWM_MAX_DUTY * (p->cmr + 1) / (p->cnr + 1); | ||
51 | + duty = (uint64_t)NPCM7XX_PWM_MAX_DUTY * (p->cmr + 1) / (p->cnr + 1); | ||
52 | } | ||
53 | } else { | ||
54 | duty = 0; | ||
55 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_pwm_write(void *opaque, hwaddr offset, | ||
56 | case A_NPCM7XX_PWM_CNR2: | ||
57 | case A_NPCM7XX_PWM_CNR3: | ||
58 | p = &s->pwm[npcm7xx_cnr_index(offset)]; | ||
59 | - p->cnr = value; | ||
60 | + if (value > NPCM7XX_MAX_CNR) { | ||
61 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
62 | + "%s: invalid cnr value: %u", __func__, value); | ||
63 | + p->cnr = NPCM7XX_MAX_CNR; | ||
64 | + } else { | ||
65 | + p->cnr = value; | ||
66 | + } | ||
67 | npcm7xx_pwm_update_output(p); | ||
27 | break; | 68 | break; |
28 | 69 | ||
29 | case DESIGNWARE_PCIE_MSI_ADDR_HI: | 70 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_pwm_write(void *opaque, hwaddr offset, |
30 | root->msi.base &= 0x00000000FFFFFFFFULL; | 71 | case A_NPCM7XX_PWM_CMR2: |
31 | root->msi.base |= (uint64_t)val << 32; | 72 | case A_NPCM7XX_PWM_CMR3: |
32 | + designware_pcie_root_update_msi_mapping(root); | 73 | p = &s->pwm[npcm7xx_cmr_index(offset)]; |
74 | - p->cmr = value; | ||
75 | + if (value > NPCM7XX_MAX_CMR) { | ||
76 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
77 | + "%s: invalid cmr value: %u", __func__, value); | ||
78 | + p->cmr = NPCM7XX_MAX_CMR; | ||
79 | + } else { | ||
80 | + p->cmr = value; | ||
81 | + } | ||
82 | npcm7xx_pwm_update_output(p); | ||
33 | break; | 83 | break; |
34 | 84 | ||
35 | case DESIGNWARE_PCIE_MSI_INTR0_ENABLE: | 85 | diff --git a/tests/qtest/npcm7xx_pwm-test.c b/tests/qtest/npcm7xx_pwm-test.c |
86 | index XXXXXXX..XXXXXXX 100644 | ||
87 | --- a/tests/qtest/npcm7xx_pwm-test.c | ||
88 | +++ b/tests/qtest/npcm7xx_pwm-test.c | ||
89 | @@ -XXX,XX +XXX,XX @@ static uint64_t pwm_compute_freq(QTestState *qts, uint32_t ppr, uint32_t csr, | ||
90 | |||
91 | static uint64_t pwm_compute_duty(uint32_t cnr, uint32_t cmr, bool inverted) | ||
92 | { | ||
93 | - uint64_t duty; | ||
94 | + uint32_t duty; | ||
95 | |||
96 | if (cnr == 0) { | ||
97 | /* PWM is stopped. */ | ||
98 | @@ -XXX,XX +XXX,XX @@ static uint64_t pwm_compute_duty(uint32_t cnr, uint32_t cmr, bool inverted) | ||
99 | } else if (cmr >= cnr) { | ||
100 | duty = MAX_DUTY; | ||
101 | } else { | ||
102 | - duty = MAX_DUTY * (cmr + 1) / (cnr + 1); | ||
103 | + duty = (uint64_t)MAX_DUTY * (cmr + 1) / (cnr + 1); | ||
104 | } | ||
105 | |||
106 | if (inverted) { | ||
36 | -- | 107 | -- |
37 | 2.20.1 | 108 | 2.20.1 |
38 | 109 | ||
39 | 110 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 3 | cpu_get_phys_page_debug() uses 'DATA LOAD' MMU access type. |
4 | Message-id: 20190701132516.26392-7-philmd@redhat.com | 4 | |
5 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Message-id: 20210127232822.3530782-1-f4bug@amsat.org | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 9 | --- |
8 | target/arm/helper.c | 2 -- | 10 | target/arm/helper.c | 2 +- |
9 | 1 file changed, 2 deletions(-) | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
10 | 12 | ||
11 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 13 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
12 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/helper.c | 15 | --- a/target/arm/helper.c |
14 | +++ b/target/arm/helper.c | 16 | +++ b/target/arm/helper.c |
15 | @@ -XXX,XX +XXX,XX @@ | 17 | @@ -XXX,XX +XXX,XX @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, |
16 | #include "exec/gdbstub.h" | 18 | |
17 | #include "exec/helper-proto.h" | 19 | *attrs = (MemTxAttrs) {}; |
18 | #include "qemu/host-utils.h" | 20 | |
19 | -#include "sysemu/arch_init.h" | 21 | - ret = get_phys_addr(env, addr, 0, mmu_idx, &phys_addr, |
20 | #include "sysemu/sysemu.h" | 22 | + ret = get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &phys_addr, |
21 | #include "qemu/bitops.h" | 23 | attrs, &prot, &page_size, &fi, &cacheattrs); |
22 | #include "qemu/crc32c.h" | 24 | |
23 | @@ -XXX,XX +XXX,XX @@ | 25 | if (ret) { |
24 | #include "hw/semihosting/semihost.h" | ||
25 | #include "sysemu/cpus.h" | ||
26 | #include "sysemu/kvm.h" | ||
27 | -#include "fpu/softfloat.h" | ||
28 | #include "qemu/range.h" | ||
29 | #include "qapi/qapi-commands-target.h" | ||
30 | #include "qapi/error.h" | ||
31 | -- | 26 | -- |
32 | 2.20.1 | 27 | 2.20.1 |
33 | 28 | ||
34 | 29 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | Move the preadv availability check to meson.build. This is what we |
---|---|---|---|
2 | want to be doing for host-OS-feature-checks anyway, but it also fixes | ||
3 | a problem with building for macOS with the most recent XCode SDK on a | ||
4 | Catalina host. | ||
2 | 5 | ||
3 | Group ARM objects together, TCG related ones at the bottom. | 6 | On that configuration, 'preadv()' is provided as a weak symbol, so |
4 | This will help when restricting TCG-only objects. | 7 | that programs can be built with optional support for it and make a |
8 | runtime availability check to see whether the preadv() they have is a | ||
9 | working one or one which they must not call because it will | ||
10 | runtime-assert. QEMU's configure test passes (unless you're building | ||
11 | with --enable-werror) because the test program using preadv() | ||
12 | compiles, but then QEMU crashes at runtime when preadv() is called, | ||
13 | with errors like: | ||
5 | 14 | ||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 15 | dyld: lazy symbol binding failed: Symbol not found: _preadv |
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 16 | Referenced from: /Users/pm215/src/qemu/./build/x86/tests/test-replication |
8 | Message-id: 20190701132516.26392-3-philmd@redhat.com | 17 | Expected in: /usr/lib/libSystem.B.dylib |
18 | |||
19 | dyld: Symbol not found: _preadv | ||
20 | Referenced from: /Users/pm215/src/qemu/./build/x86/tests/test-replication | ||
21 | Expected in: /usr/lib/libSystem.B.dylib | ||
22 | |||
23 | Meson's own function availability check has a special case for macOS | ||
24 | which adds '-Wl,-no_weak_imports' to the compiler flags, which forces | ||
25 | the test to require the real function, not the macOS-version-too-old | ||
26 | stub. | ||
27 | |||
28 | So this commit fixes the bug where macOS builds on Catalina currently | ||
29 | require --disable-werror. | ||
30 | |||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 31 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
32 | Acked-by: Paolo Bonzini <pbonzini@redhat.com> | ||
33 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
34 | Message-id: 20210126155846.17109-1-peter.maydell@linaro.org | ||
10 | --- | 35 | --- |
11 | target/arm/Makefile.objs | 10 ++++++---- | 36 | configure | 16 ---------------- |
12 | 1 file changed, 6 insertions(+), 4 deletions(-) | 37 | meson.build | 4 +++- |
38 | 2 files changed, 3 insertions(+), 17 deletions(-) | ||
13 | 39 | ||
14 | diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs | 40 | diff --git a/configure b/configure |
41 | index XXXXXXX..XXXXXXX 100755 | ||
42 | --- a/configure | ||
43 | +++ b/configure | ||
44 | @@ -XXX,XX +XXX,XX @@ if compile_prog "" "" ; then | ||
45 | iovec=yes | ||
46 | fi | ||
47 | |||
48 | -########################################## | ||
49 | -# preadv probe | ||
50 | -cat > $TMPC <<EOF | ||
51 | -#include <sys/types.h> | ||
52 | -#include <sys/uio.h> | ||
53 | -#include <unistd.h> | ||
54 | -int main(void) { return preadv(0, 0, 0, 0); } | ||
55 | -EOF | ||
56 | -preadv=no | ||
57 | -if compile_prog "" "" ; then | ||
58 | - preadv=yes | ||
59 | -fi | ||
60 | - | ||
61 | ########################################## | ||
62 | # fdt probe | ||
63 | |||
64 | @@ -XXX,XX +XXX,XX @@ fi | ||
65 | if test "$iovec" = "yes" ; then | ||
66 | echo "CONFIG_IOVEC=y" >> $config_host_mak | ||
67 | fi | ||
68 | -if test "$preadv" = "yes" ; then | ||
69 | - echo "CONFIG_PREADV=y" >> $config_host_mak | ||
70 | -fi | ||
71 | if test "$membarrier" = "yes" ; then | ||
72 | echo "CONFIG_MEMBARRIER=y" >> $config_host_mak | ||
73 | fi | ||
74 | diff --git a/meson.build b/meson.build | ||
15 | index XXXXXXX..XXXXXXX 100644 | 75 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/Makefile.objs | 76 | --- a/meson.build |
17 | +++ b/target/arm/Makefile.objs | 77 | +++ b/meson.build |
18 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_KVM) += kvm.o | 78 | @@ -XXX,XX +XXX,XX @@ config_host_data.set('HAVE_PTY_H', cc.has_header('pty.h')) |
19 | obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o | 79 | config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h')) |
20 | obj-$(call land,$(CONFIG_KVM),$(TARGET_AARCH64)) += kvm64.o | 80 | config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h')) |
21 | obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o | 81 | |
22 | -obj-y += translate.o op_helper.o helper.o cpu.o | 82 | +config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include <sys/uio.h>')) |
23 | -obj-y += neon_helper.o iwmmxt_helper.o vec_helper.o vfp_helper.o | ||
24 | -obj-y += gdbstub.o | ||
25 | +obj-y += helper.o vfp_helper.o | ||
26 | +obj-y += cpu.o gdbstub.o | ||
27 | obj-$(TARGET_AARCH64) += cpu64.o gdbstub64.o | ||
28 | -obj-y += crypto_helper.o | ||
29 | obj-$(CONFIG_SOFTMMU) += arm-powerctl.o | ||
30 | |||
31 | DECODETREE = $(SRC_PATH)/scripts/decodetree.py | ||
32 | @@ -XXX,XX +XXX,XX @@ target/arm/translate-sve.o: target/arm/decode-sve.inc.c | ||
33 | target/arm/translate.o: target/arm/decode-vfp.inc.c | ||
34 | target/arm/translate.o: target/arm/decode-vfp-uncond.inc.c | ||
35 | |||
36 | +obj-y += translate.o op_helper.o | ||
37 | +obj-y += crypto_helper.o | ||
38 | +obj-y += iwmmxt_helper.o vec_helper.o neon_helper.o | ||
39 | + | 83 | + |
40 | obj-$(TARGET_AARCH64) += translate-a64.o helper-a64.o | 84 | ignored = ['CONFIG_QEMU_INTERP_PREFIX'] # actually per-target |
41 | obj-$(TARGET_AARCH64) += translate-sve.o sve_helper.o | 85 | arrays = ['CONFIG_AUDIO_DRIVERS', 'CONFIG_BDRV_RW_WHITELIST', 'CONFIG_BDRV_RO_WHITELIST'] |
42 | obj-$(TARGET_AARCH64) += pauth_helper.o | 86 | strings = ['HOST_DSOSUF', 'CONFIG_IASL'] |
87 | @@ -XXX,XX +XXX,XX @@ summary_info += {'PIE': get_option('b_pie')} | ||
88 | summary_info += {'static build': config_host.has_key('CONFIG_STATIC')} | ||
89 | summary_info += {'malloc trim support': has_malloc_trim} | ||
90 | summary_info += {'membarrier': config_host.has_key('CONFIG_MEMBARRIER')} | ||
91 | -summary_info += {'preadv support': config_host.has_key('CONFIG_PREADV')} | ||
92 | +summary_info += {'preadv support': config_host_data.get('CONFIG_PREADV')} | ||
93 | summary_info += {'fdatasync': config_host.has_key('CONFIG_FDATASYNC')} | ||
94 | summary_info += {'madvise': config_host.has_key('CONFIG_MADVISE')} | ||
95 | summary_info += {'posix_madvise': config_host.has_key('CONFIG_POSIX_MADVISE')} | ||
43 | -- | 96 | -- |
44 | 2.20.1 | 97 | 2.20.1 |
45 | 98 | ||
46 | 99 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Joelle van Dyne <j@getutm.app> |
---|---|---|---|
2 | 2 | ||
3 | Group Aarch64 rules together, TCG related ones at the bottom. | 3 | The iOS toolchain does not use the host prefix naming convention. So we |
4 | This will help when restricting TCG-only objects. | 4 | need to enable cross-compile options while allowing the PREFIX to be |
5 | blank. | ||
5 | 6 | ||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 8 | Signed-off-by: Joelle van Dyne <j@getutm.app> |
8 | Message-id: 20190701132516.26392-2-philmd@redhat.com | 9 | Message-id: 20210126012457.39046-3-j@getutm.app |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 11 | --- |
11 | target/arm/Makefile.objs | 5 +++-- | 12 | configure | 6 ++++-- |
12 | 1 file changed, 3 insertions(+), 2 deletions(-) | 13 | 1 file changed, 4 insertions(+), 2 deletions(-) |
13 | 14 | ||
14 | diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs | 15 | diff --git a/configure b/configure |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100755 |
16 | --- a/target/arm/Makefile.objs | 17 | --- a/configure |
17 | +++ b/target/arm/Makefile.objs | 18 | +++ b/configure |
18 | @@ -XXX,XX +XXX,XX @@ obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o | 19 | @@ -XXX,XX +XXX,XX @@ cpu="" |
19 | obj-y += translate.o op_helper.o helper.o cpu.o | 20 | iasl="iasl" |
20 | obj-y += neon_helper.o iwmmxt_helper.o vec_helper.o vfp_helper.o | 21 | interp_prefix="/usr/gnemul/qemu-%M" |
21 | obj-y += gdbstub.o | 22 | static="no" |
22 | -obj-$(TARGET_AARCH64) += cpu64.o translate-a64.o helper-a64.o gdbstub64.o | 23 | +cross_compile="no" |
23 | -obj-$(TARGET_AARCH64) += pauth_helper.o | 24 | cross_prefix="" |
24 | +obj-$(TARGET_AARCH64) += cpu64.o gdbstub64.o | 25 | audio_drv_list="" |
25 | obj-y += crypto_helper.o | 26 | block_drv_rw_whitelist="" |
26 | obj-$(CONFIG_SOFTMMU) += arm-powerctl.o | 27 | @@ -XXX,XX +XXX,XX @@ for opt do |
27 | 28 | optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') | |
28 | @@ -XXX,XX +XXX,XX @@ target/arm/translate-sve.o: target/arm/decode-sve.inc.c | 29 | case "$opt" in |
29 | target/arm/translate.o: target/arm/decode-vfp.inc.c | 30 | --cross-prefix=*) cross_prefix="$optarg" |
30 | target/arm/translate.o: target/arm/decode-vfp-uncond.inc.c | 31 | + cross_compile="yes" |
31 | 32 | ;; | |
32 | +obj-$(TARGET_AARCH64) += translate-a64.o helper-a64.o | 33 | --cc=*) CC="$optarg" |
33 | obj-$(TARGET_AARCH64) += translate-sve.o sve_helper.o | 34 | ;; |
34 | +obj-$(TARGET_AARCH64) += pauth_helper.o | 35 | @@ -XXX,XX +XXX,XX @@ $(echo Deprecated targets: $deprecated_targets_list | \ |
36 | --target-list-exclude=LIST exclude a set of targets from the default target-list | ||
37 | |||
38 | Advanced options (experts only): | ||
39 | - --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix] | ||
40 | + --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix] | ||
41 | --cc=CC use C compiler CC [$cc] | ||
42 | --iasl=IASL use ACPI compiler IASL [$iasl] | ||
43 | --host-cc=CC use C compiler CC [$host_cc] for code run at | ||
44 | @@ -XXX,XX +XXX,XX @@ if has $sdl2_config; then | ||
45 | fi | ||
46 | echo "strip = [$(meson_quote $strip)]" >> $cross | ||
47 | echo "windres = [$(meson_quote $windres)]" >> $cross | ||
48 | -if test -n "$cross_prefix"; then | ||
49 | +if test "$cross_compile" = "yes"; then | ||
50 | cross_arg="--cross-file config-meson.cross" | ||
51 | echo "[host_machine]" >> $cross | ||
52 | if test "$mingw32" = "yes" ; then | ||
35 | -- | 53 | -- |
36 | 2.20.1 | 54 | 2.20.1 |
37 | 55 | ||
38 | 56 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Joelle van Dyne <j@getutm.app> |
---|---|---|---|
2 | 2 | ||
3 | Under KVM, the kernel gets the HVC call and handle the PSCI requests. | 3 | Build without error on hosts without a working system(). If system() |
4 | is called, return -1 with ENOSYS. | ||
4 | 5 | ||
5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 6 | Signed-off-by: Joelle van Dyne <j@getutm.app> |
6 | Message-id: 20190701132516.26392-20-philmd@redhat.com | 7 | Message-id: 20210126012457.39046-6-j@getutm.app |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 10 | --- |
10 | target/arm/internals.h | 6 +++++- | 11 | meson.build | 1 + |
11 | 1 file changed, 5 insertions(+), 1 deletion(-) | 12 | include/qemu/osdep.h | 12 ++++++++++++ |
13 | 2 files changed, 13 insertions(+) | ||
12 | 14 | ||
13 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 15 | diff --git a/meson.build b/meson.build |
14 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/internals.h | 17 | --- a/meson.build |
16 | +++ b/target/arm/internals.h | 18 | +++ b/meson.build |
17 | @@ -XXX,XX +XXX,XX @@ vaddr arm_adjust_watchpoint_address(CPUState *cs, vaddr addr, int len); | 19 | @@ -XXX,XX +XXX,XX @@ config_host_data.set('HAVE_DRM_H', cc.has_header('libdrm/drm.h')) |
18 | /* Callback function for when a watchpoint or breakpoint triggers. */ | 20 | config_host_data.set('HAVE_PTY_H', cc.has_header('pty.h')) |
19 | void arm_debug_excp_handler(CPUState *cs); | 21 | config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h')) |
20 | 22 | config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h')) | |
21 | -#ifdef CONFIG_USER_ONLY | 23 | +config_host_data.set('HAVE_SYSTEM_FUNCTION', cc.has_function('system', prefix: '#include <stdlib.h>')) |
22 | +#if defined(CONFIG_USER_ONLY) || !defined(CONFIG_TCG) | 24 | |
23 | static inline bool arm_is_psci_call(ARMCPU *cpu, int excp_type) | 25 | config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include <sys/uio.h>')) |
24 | { | 26 | |
25 | return false; | 27 | diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h |
26 | } | 28 | index XXXXXXX..XXXXXXX 100644 |
27 | +static inline void arm_handle_psci_call(ARMCPU *cpu) | 29 | --- a/include/qemu/osdep.h |
30 | +++ b/include/qemu/osdep.h | ||
31 | @@ -XXX,XX +XXX,XX @@ static inline void qemu_thread_jit_write(void) {} | ||
32 | static inline void qemu_thread_jit_execute(void) {} | ||
33 | #endif | ||
34 | |||
35 | +/** | ||
36 | + * Platforms which do not support system() return ENOSYS | ||
37 | + */ | ||
38 | +#ifndef HAVE_SYSTEM_FUNCTION | ||
39 | +#define system platform_does_not_support_system | ||
40 | +static inline int platform_does_not_support_system(const char *command) | ||
28 | +{ | 41 | +{ |
29 | + g_assert_not_reached(); | 42 | + errno = ENOSYS; |
43 | + return -1; | ||
30 | +} | 44 | +} |
31 | #else | 45 | +#endif /* !HAVE_SYSTEM_FUNCTION */ |
32 | /* Return true if the r0/x0 value indicates that this SMC/HVC is a PSCI call. */ | 46 | + |
33 | bool arm_is_psci_call(ARMCPU *cpu, int excp_type); | 47 | #endif |
34 | -- | 48 | -- |
35 | 2.20.1 | 49 | 2.20.1 |
36 | 50 | ||
37 | 51 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | From: Joelle van Dyne <j@getutm.app> |
---|---|---|---|
2 | 2 | ||
3 | The RAM memory region is defined after the SoC is realized when the | 3 | Meson will find CoreFoundation, IOKit, and Cocoa as needed. |
4 | SDMC controller has checked that the defined RAM size for the machine | ||
5 | is correct. This is problematic for controller models requiring a link | ||
6 | on the RAM region, for DMA support in the SMC controller for instance. | ||
7 | 4 | ||
8 | Introduce a container memory region for the RAM that we can link into | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | the controllers early, before the SoC is realized. It will be | 6 | Signed-off-by: Joelle van Dyne <j@getutm.app> |
10 | populated with the RAM region after the checks have be done. | 7 | Message-id: 20210126012457.39046-7-j@getutm.app |
11 | |||
12 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
13 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
14 | Message-id: 20190618165311.27066-14-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.c | 13 +++++++++---- | 10 | configure | 1 - |
18 | 1 file changed, 9 insertions(+), 4 deletions(-) | 11 | 1 file changed, 1 deletion(-) |
19 | 12 | ||
20 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | 13 | diff --git a/configure b/configure |
21 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100755 |
22 | --- a/hw/arm/aspeed.c | 15 | --- a/configure |
23 | +++ b/hw/arm/aspeed.c | 16 | +++ b/configure |
24 | @@ -XXX,XX +XXX,XX @@ static struct arm_boot_info aspeed_board_binfo = { | 17 | @@ -XXX,XX +XXX,XX @@ Darwin) |
25 | 18 | fi | |
26 | struct AspeedBoardState { | 19 | audio_drv_list="coreaudio try-sdl" |
27 | AspeedSoCState soc; | 20 | audio_possible_drivers="coreaudio sdl" |
28 | + MemoryRegion ram_container; | 21 | - QEMU_LDFLAGS="-framework CoreFoundation -framework IOKit $QEMU_LDFLAGS" |
29 | MemoryRegion ram; | 22 | # Disable attempts to use ObjectiveC features in os/object.h since they |
30 | MemoryRegion max_ram; | 23 | # won't work when we're compiling with gcc as a C compiler. |
31 | }; | 24 | QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS" |
32 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | ||
33 | ram_addr_t max_ram_size; | ||
34 | |||
35 | bmc = g_new0(AspeedBoardState, 1); | ||
36 | + | ||
37 | + memory_region_init(&bmc->ram_container, NULL, "aspeed-ram-container", | ||
38 | + UINT32_MAX); | ||
39 | + | ||
40 | object_initialize_child(OBJECT(machine), "soc", &bmc->soc, | ||
41 | (sizeof(bmc->soc)), cfg->soc_name, &error_abort, | ||
42 | NULL); | ||
43 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | ||
44 | &error_abort); | ||
45 | |||
46 | memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size); | ||
47 | + memory_region_add_subregion(&bmc->ram_container, 0, &bmc->ram); | ||
48 | memory_region_add_subregion(get_system_memory(), | ||
49 | - sc->info->memmap[ASPEED_SDRAM], &bmc->ram); | ||
50 | + sc->info->memmap[ASPEED_SDRAM], | ||
51 | + &bmc->ram_container); | ||
52 | |||
53 | max_ram_size = object_property_get_uint(OBJECT(&bmc->soc), "max-ram-size", | ||
54 | &error_abort); | ||
55 | memory_region_init_io(&bmc->max_ram, NULL, &max_ram_ops, NULL, | ||
56 | "max_ram", max_ram_size - ram_size); | ||
57 | - memory_region_add_subregion(get_system_memory(), | ||
58 | - sc->info->memmap[ASPEED_SDRAM] + ram_size, | ||
59 | - &bmc->max_ram); | ||
60 | + memory_region_add_subregion(&bmc->ram_container, ram_size, &bmc->max_ram); | ||
61 | |||
62 | aspeed_board_init_flashes(&bmc->soc.fmc, cfg->fmc_model, &error_abort); | ||
63 | aspeed_board_init_flashes(&bmc->soc.spi[0], cfg->spi_model, &error_abort); | ||
64 | -- | 25 | -- |
65 | 2.20.1 | 26 | 2.20.1 |
66 | 27 | ||
67 | 28 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | From: Joelle van Dyne <j@getutm.app> |
---|---|---|---|
2 | 2 | ||
3 | It has never been used as far as I can tell from the git history. | 3 | Add objc to the Meson cross file as well as detection of Darwin. |
4 | 4 | ||
5 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Joel Stanley <joel@jms.id.au> | 6 | Signed-off-by: Joelle van Dyne <j@getutm.app> |
7 | Message-id: 20190618165311.27066-13-clg@kaod.org | 7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
8 | Message-id: 20210126012457.39046-8-j@getutm.app | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 10 | --- |
10 | hw/arm/aspeed.c | 2 -- | 11 | configure | 4 ++++ |
11 | 1 file changed, 2 deletions(-) | 12 | 1 file changed, 4 insertions(+) |
12 | 13 | ||
13 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | 14 | diff --git a/configure b/configure |
14 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100755 |
15 | --- a/hw/arm/aspeed.c | 16 | --- a/configure |
16 | +++ b/hw/arm/aspeed.c | 17 | +++ b/configure |
17 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | 18 | @@ -XXX,XX +XXX,XX @@ echo "cpp_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross |
18 | memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size); | 19 | echo "[binaries]" >> $cross |
19 | memory_region_add_subregion(get_system_memory(), | 20 | echo "c = [$(meson_quote $cc)]" >> $cross |
20 | sc->info->memmap[ASPEED_SDRAM], &bmc->ram); | 21 | test -n "$cxx" && echo "cpp = [$(meson_quote $cxx)]" >> $cross |
21 | - object_property_add_const_link(OBJECT(&bmc->soc), "ram", OBJECT(&bmc->ram), | 22 | +test -n "$objcc" && echo "objc = [$(meson_quote $objcc)]" >> $cross |
22 | - &error_abort); | 23 | echo "ar = [$(meson_quote $ar)]" >> $cross |
23 | 24 | echo "nm = [$(meson_quote $nm)]" >> $cross | |
24 | max_ram_size = object_property_get_uint(OBJECT(&bmc->soc), "max-ram-size", | 25 | echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross |
25 | &error_abort); | 26 | @@ -XXX,XX +XXX,XX @@ if test "$cross_compile" = "yes"; then |
27 | if test "$linux" = "yes" ; then | ||
28 | echo "system = 'linux'" >> $cross | ||
29 | fi | ||
30 | + if test "$darwin" = "yes" ; then | ||
31 | + echo "system = 'darwin'" >> $cross | ||
32 | + fi | ||
33 | case "$ARCH" in | ||
34 | i386|x86_64) | ||
35 | echo "cpu_family = 'x86'" >> $cross | ||
26 | -- | 36 | -- |
27 | 2.20.1 | 37 | 2.20.1 |
28 | 38 | ||
29 | 39 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Joelle van Dyne <j@getutm.app> |
---|---|---|---|
2 | 2 | ||
3 | Group SOFTMMU objects together. | 3 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
4 | Since PSCI is TCG specific, keep it separate. | 4 | Signed-off-by: Joelle van Dyne <j@getutm.app> |
5 | 5 | Message-id: 20210126012457.39046-9-j@getutm.app | |
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Message-id: 20190701132516.26392-5-philmd@redhat.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 7 | --- |
11 | target/arm/Makefile.objs | 5 ++++- | 8 | configure | 5 ++++- |
12 | 1 file changed, 4 insertions(+), 1 deletion(-) | 9 | 1 file changed, 4 insertions(+), 1 deletion(-) |
13 | 10 | ||
14 | diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs | 11 | diff --git a/configure b/configure |
15 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100755 |
16 | --- a/target/arm/Makefile.objs | 13 | --- a/configure |
17 | +++ b/target/arm/Makefile.objs | 14 | +++ b/configure |
18 | @@ -XXX,XX +XXX,XX @@ | 15 | @@ -XXX,XX +XXX,XX @@ if test "$cross_compile" = "yes"; then |
19 | obj-y += arm-semi.o | 16 | echo "system = 'darwin'" >> $cross |
20 | -obj-$(CONFIG_SOFTMMU) += machine.o psci.o arch_dump.o monitor.o | 17 | fi |
21 | obj-y += helper.o vfp_helper.o | 18 | case "$ARCH" in |
22 | obj-y += cpu.o gdbstub.o | 19 | - i386|x86_64) |
23 | obj-$(TARGET_AARCH64) += cpu64.o gdbstub64.o | 20 | + i386) |
24 | + | 21 | echo "cpu_family = 'x86'" >> $cross |
25 | +obj-$(CONFIG_SOFTMMU) += machine.o arch_dump.o monitor.o | 22 | ;; |
26 | obj-$(CONFIG_SOFTMMU) += arm-powerctl.o | 23 | + x86_64) |
27 | 24 | + echo "cpu_family = 'x86_64'" >> $cross | |
28 | obj-$(CONFIG_KVM) += kvm.o | 25 | + ;; |
29 | @@ -XXX,XX +XXX,XX @@ obj-y += translate.o op_helper.o | 26 | ppc64le) |
30 | obj-y += crypto_helper.o | 27 | echo "cpu_family = 'ppc64'" >> $cross |
31 | obj-y += iwmmxt_helper.o vec_helper.o neon_helper.o | 28 | ;; |
32 | |||
33 | +obj-$(CONFIG_SOFTMMU) += psci.o | ||
34 | + | ||
35 | obj-$(TARGET_AARCH64) += translate-a64.o helper-a64.o | ||
36 | obj-$(TARGET_AARCH64) += translate-sve.o sve_helper.o | ||
37 | obj-$(TARGET_AARCH64) += pauth_helper.o | ||
38 | -- | 29 | -- |
39 | 2.20.1 | 30 | 2.20.1 |
40 | 31 | ||
41 | 32 | diff view generated by jsdifflib |
1 | From: Christian Svensson <bluecmd@google.com> | 1 | From: Joelle van Dyne <j@getutm.app> |
---|---|---|---|
2 | 2 | ||
3 | If the host decrements the counter register that results in a negative | 3 | On iOS there is no CoreAudio, so we should not assume Darwin always |
4 | delta. This is then passed to muldiv64 which only handles unsigned | 4 | has it. |
5 | numbers resulting in bogus results. | ||
6 | 5 | ||
7 | This fix ensures the delta being operated on is positive. | 6 | Signed-off-by: Joelle van Dyne <j@getutm.app> |
8 | 7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | |
9 | Test case: kexec a kernel using aspeed_timer and it will freeze on the | 8 | Message-id: 20210126012457.39046-11-j@getutm.app |
10 | second bootup when the kernel initializes the timer. With this patch | ||
11 | that no longer happens and the timer appears to run OK. | ||
12 | |||
13 | Signed-off-by: Christian Svensson <bluecmd@google.com> | ||
14 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
15 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
16 | Reviewed-by: Andrew Jeffery <andrew@aj.id.au> | ||
17 | Message-id: 20190618165311.27066-12-clg@kaod.org | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | --- | 10 | --- |
20 | hw/timer/aspeed_timer.c | 6 +++++- | 11 | configure | 35 +++++++++++++++++++++++++++++++++-- |
21 | 1 file changed, 5 insertions(+), 1 deletion(-) | 12 | 1 file changed, 33 insertions(+), 2 deletions(-) |
22 | 13 | ||
23 | diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c | 14 | diff --git a/configure b/configure |
24 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100755 |
25 | --- a/hw/timer/aspeed_timer.c | 16 | --- a/configure |
26 | +++ b/hw/timer/aspeed_timer.c | 17 | +++ b/configure |
27 | @@ -XXX,XX +XXX,XX @@ static void aspeed_timer_set_value(AspeedTimerCtrlState *s, int timer, int reg, | 18 | @@ -XXX,XX +XXX,XX @@ fdt="auto" |
28 | int64_t delta = (int64_t) value - (int64_t) calculate_ticks(t, now); | 19 | netmap="no" |
29 | uint32_t rate = calculate_rate(t); | 20 | sdl="auto" |
30 | 21 | sdl_image="auto" | |
31 | - t->start += muldiv64(delta, NANOSECONDS_PER_SECOND, rate); | 22 | +coreaudio="auto" |
32 | + if (delta >= 0) { | 23 | virtiofsd="auto" |
33 | + t->start += muldiv64(delta, NANOSECONDS_PER_SECOND, rate); | 24 | virtfs="auto" |
34 | + } else { | 25 | libudev="auto" |
35 | + t->start -= muldiv64(-delta, NANOSECONDS_PER_SECOND, rate); | 26 | @@ -XXX,XX +XXX,XX @@ Darwin) |
36 | + } | 27 | QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS" |
37 | aspeed_timer_mod(t); | 28 | QEMU_LDFLAGS="-arch x86_64 $QEMU_LDFLAGS" |
38 | } | 29 | fi |
39 | break; | 30 | - audio_drv_list="coreaudio try-sdl" |
31 | + audio_drv_list="try-coreaudio try-sdl" | ||
32 | audio_possible_drivers="coreaudio sdl" | ||
33 | # Disable attempts to use ObjectiveC features in os/object.h since they | ||
34 | # won't work when we're compiling with gcc as a C compiler. | ||
35 | @@ -XXX,XX +XXX,XX @@ EOF | ||
36 | fi | ||
37 | fi | ||
38 | |||
39 | +########################################## | ||
40 | +# detect CoreAudio | ||
41 | +if test "$coreaudio" != "no" ; then | ||
42 | + coreaudio_libs="-framework CoreAudio" | ||
43 | + cat > $TMPC << EOF | ||
44 | +#include <CoreAudio/CoreAudio.h> | ||
45 | +int main(void) | ||
46 | +{ | ||
47 | + return (int)AudioGetCurrentHostTime(); | ||
48 | +} | ||
49 | +EOF | ||
50 | + if compile_prog "" "$coreaudio_libs" ; then | ||
51 | + coreaudio=yes | ||
52 | + else | ||
53 | + coreaudio=no | ||
54 | + fi | ||
55 | +fi | ||
56 | + | ||
57 | ########################################## | ||
58 | # Sound support libraries probe | ||
59 | |||
60 | @@ -XXX,XX +XXX,XX @@ for drv in $audio_drv_list; do | ||
61 | fi | ||
62 | ;; | ||
63 | |||
64 | - coreaudio) | ||
65 | + coreaudio | try-coreaudio) | ||
66 | + if test "$coreaudio" = "no"; then | ||
67 | + if test "$drv" = "try-coreaudio"; then | ||
68 | + audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-coreaudio//') | ||
69 | + else | ||
70 | + error_exit "$drv check failed" \ | ||
71 | + "Make sure to have the $drv is available." | ||
72 | + fi | ||
73 | + else | ||
74 | coreaudio_libs="-framework CoreAudio" | ||
75 | + if test "$drv" = "try-coreaudio"; then | ||
76 | + audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-coreaudio/coreaudio/') | ||
77 | + fi | ||
78 | + fi | ||
79 | ;; | ||
80 | |||
81 | dsound) | ||
40 | -- | 82 | -- |
41 | 2.20.1 | 83 | 2.20.1 |
42 | 84 | ||
43 | 85 | diff view generated by jsdifflib |
1 | From: Andrew Jeffery <andrew@aj.id.au> | 1 | From: Joelle van Dyne <j@getutm.app> |
---|---|---|---|
2 | 2 | ||
3 | From the datasheet: | 3 | A workaround added in early days of 64-bit OSX forced x86_64 if the |
4 | host machine had 64-bit support. This creates issues when cross- | ||
5 | compiling for ARM64. Additionally, the user can always use --cpu=* to | ||
6 | manually set the host CPU and therefore this workaround should be | ||
7 | removed. | ||
4 | 8 | ||
5 | This register stores the current status of counter #N. When timer | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | enable bit TMC30[N * b] is disabled, the reload register will be | 10 | Signed-off-by: Joelle van Dyne <j@getutm.app> |
7 | loaded into this counter. When timer bit TMC30[N * b] is set, the | 11 | Message-id: 20210126012457.39046-12-j@getutm.app |
8 | counter will start to decrement. CPU can update this register value | ||
9 | when enable bit is set. | ||
10 | |||
11 | Signed-off-by: Andrew Jeffery <andrew@aj.id.au> | ||
12 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
13 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
14 | Message-id: 20190618165311.27066-9-clg@kaod.org | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 13 | --- |
17 | hw/timer/aspeed_timer.c | 6 +++++- | 14 | configure | 11 ----------- |
18 | 1 file changed, 5 insertions(+), 1 deletion(-) | 15 | 1 file changed, 11 deletions(-) |
19 | 16 | ||
20 | diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c | 17 | diff --git a/configure b/configure |
21 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100755 |
22 | --- a/hw/timer/aspeed_timer.c | 19 | --- a/configure |
23 | +++ b/hw/timer/aspeed_timer.c | 20 | +++ b/configure |
24 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_timer_get_value(AspeedTimer *t, int reg) | 21 | @@ -XXX,XX +XXX,XX @@ fi |
25 | 22 | # the correct CPU with the --cpu option. | |
26 | switch (reg) { | 23 | case $targetos in |
27 | case TIMER_REG_STATUS: | 24 | Darwin) |
28 | - value = calculate_ticks(t, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)); | 25 | - # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can |
29 | + if (timer_enabled(t)) { | 26 | - # run 64-bit userspace code. |
30 | + value = calculate_ticks(t, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)); | 27 | - # If the user didn't specify a CPU explicitly and the kernel says this is |
31 | + } else { | 28 | - # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code. |
32 | + value = t->reload; | 29 | - if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then |
33 | + } | 30 | - cpu="x86_64" |
34 | break; | 31 | - fi |
35 | case TIMER_REG_RELOAD: | 32 | HOST_DSOSUF=".dylib" |
36 | value = t->reload; | 33 | ;; |
34 | SunOS) | ||
35 | @@ -XXX,XX +XXX,XX @@ OpenBSD) | ||
36 | Darwin) | ||
37 | bsd="yes" | ||
38 | darwin="yes" | ||
39 | - if [ "$cpu" = "x86_64" ] ; then | ||
40 | - QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS" | ||
41 | - QEMU_LDFLAGS="-arch x86_64 $QEMU_LDFLAGS" | ||
42 | - fi | ||
43 | audio_drv_list="try-coreaudio try-sdl" | ||
44 | audio_possible_drivers="coreaudio sdl" | ||
45 | # Disable attempts to use ObjectiveC features in os/object.h since they | ||
37 | -- | 46 | -- |
38 | 2.20.1 | 47 | 2.20.1 |
39 | 48 | ||
40 | 49 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | From: Alexander Graf <agraf@csgraf.de> |
---|---|---|---|
2 | 2 | ||
3 | All systems have an RTC. | 3 | In macOS 11, QEMU only gets access to Hypervisor.framework if it has the |
4 | respective entitlement. Add an entitlement template and automatically self | ||
5 | sign and apply the entitlement in the build. | ||
4 | 6 | ||
5 | The IRQ is hooked up but the model does not use it at this stage. There | 7 | Signed-off-by: Alexander Graf <agraf@csgraf.de> |
6 | is no guest code that uses it, so this limitation is acceptable. | 8 | Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com> |
7 | 9 | Tested-by: Roman Bolshakov <r.bolshakov@yadro.com> | |
8 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Message-id: 20190618165311.27066-5-clg@kaod.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 11 | --- |
13 | include/hw/arm/aspeed_soc.h | 2 ++ | 12 | meson.build | 29 +++++++++++++++++++++++++---- |
14 | hw/arm/aspeed_soc.c | 13 +++++++++++++ | 13 | accel/hvf/entitlements.plist | 8 ++++++++ |
15 | 2 files changed, 15 insertions(+) | 14 | scripts/entitlement.sh | 13 +++++++++++++ |
15 | 3 files changed, 46 insertions(+), 4 deletions(-) | ||
16 | create mode 100644 accel/hvf/entitlements.plist | ||
17 | create mode 100755 scripts/entitlement.sh | ||
16 | 18 | ||
17 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h | 19 | diff --git a/meson.build b/meson.build |
18 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/hw/arm/aspeed_soc.h | 21 | --- a/meson.build |
20 | +++ b/include/hw/arm/aspeed_soc.h | 22 | +++ b/meson.build |
23 | @@ -XXX,XX +XXX,XX @@ foreach target : target_dirs | ||
24 | }] | ||
25 | endif | ||
26 | foreach exe: execs | ||
27 | - emulators += {exe['name']: | ||
28 | - executable(exe['name'], exe['sources'], | ||
29 | - install: true, | ||
30 | + exe_name = exe['name'] | ||
31 | + exe_sign = 'CONFIG_HVF' in config_target | ||
32 | + if exe_sign | ||
33 | + exe_name += '-unsigned' | ||
34 | + endif | ||
35 | + | ||
36 | + emulator = executable(exe_name, exe['sources'], | ||
37 | + install: not exe_sign, | ||
38 | c_args: c_args, | ||
39 | dependencies: arch_deps + deps + exe['dependencies'], | ||
40 | objects: lib.extract_all_objects(recursive: true), | ||
41 | @@ -XXX,XX +XXX,XX @@ foreach target : target_dirs | ||
42 | link_depends: [block_syms, qemu_syms] + exe.get('link_depends', []), | ||
43 | link_args: link_args, | ||
44 | gui_app: exe['gui']) | ||
45 | - } | ||
46 | + | ||
47 | + if exe_sign | ||
48 | + emulators += {exe['name'] : custom_target(exe['name'], | ||
49 | + install: true, | ||
50 | + install_dir: get_option('bindir'), | ||
51 | + depends: emulator, | ||
52 | + output: exe['name'], | ||
53 | + command: [ | ||
54 | + meson.current_source_dir() / 'scripts/entitlement.sh', | ||
55 | + meson.current_build_dir() / exe_name, | ||
56 | + meson.current_build_dir() / exe['name'], | ||
57 | + meson.current_source_dir() / 'accel/hvf/entitlements.plist' | ||
58 | + ]) | ||
59 | + } | ||
60 | + else | ||
61 | + emulators += {exe['name']: emulator} | ||
62 | + endif | ||
63 | |||
64 | if 'CONFIG_TRACE_SYSTEMTAP' in config_host | ||
65 | foreach stp: [ | ||
66 | diff --git a/accel/hvf/entitlements.plist b/accel/hvf/entitlements.plist | ||
67 | new file mode 100644 | ||
68 | index XXXXXXX..XXXXXXX | ||
69 | --- /dev/null | ||
70 | +++ b/accel/hvf/entitlements.plist | ||
21 | @@ -XXX,XX +XXX,XX @@ | 71 | @@ -XXX,XX +XXX,XX @@ |
22 | #include "hw/misc/aspeed_scu.h" | 72 | +<?xml version="1.0" encoding="UTF-8"?> |
23 | #include "hw/misc/aspeed_sdmc.h" | 73 | +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
24 | #include "hw/timer/aspeed_timer.h" | 74 | +<plist version="1.0"> |
25 | +#include "hw/timer/aspeed_rtc.h" | 75 | +<dict> |
26 | #include "hw/i2c/aspeed_i2c.h" | 76 | + <key>com.apple.security.hypervisor</key> |
27 | #include "hw/ssi/aspeed_smc.h" | 77 | + <true/> |
28 | #include "hw/watchdog/wdt_aspeed.h" | 78 | +</dict> |
29 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState { | 79 | +</plist> |
30 | ARMCPU cpu; | 80 | diff --git a/scripts/entitlement.sh b/scripts/entitlement.sh |
31 | MemoryRegion sram; | 81 | new file mode 100755 |
32 | AspeedVICState vic; | 82 | index XXXXXXX..XXXXXXX |
33 | + AspeedRtcState rtc; | 83 | --- /dev/null |
34 | AspeedTimerCtrlState timerctrl; | 84 | +++ b/scripts/entitlement.sh |
35 | AspeedI2CState i2c; | 85 | @@ -XXX,XX +XXX,XX @@ |
36 | AspeedSCUState scu; | 86 | +#!/bin/sh -e |
37 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | 87 | +# |
38 | index XXXXXXX..XXXXXXX 100644 | 88 | +# Helper script for the build process to apply entitlements |
39 | --- a/hw/arm/aspeed_soc.c | ||
40 | +++ b/hw/arm/aspeed_soc.c | ||
41 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | ||
42 | sysbus_init_child_obj(obj, "vic", OBJECT(&s->vic), sizeof(s->vic), | ||
43 | TYPE_ASPEED_VIC); | ||
44 | |||
45 | + sysbus_init_child_obj(obj, "rtc", OBJECT(&s->rtc), sizeof(s->rtc), | ||
46 | + TYPE_ASPEED_RTC); | ||
47 | + | 89 | + |
48 | sysbus_init_child_obj(obj, "timerctrl", OBJECT(&s->timerctrl), | 90 | +SRC="$1" |
49 | sizeof(s->timerctrl), TYPE_ASPEED_TIMER); | 91 | +DST="$2" |
50 | object_property_add_const_link(OBJECT(&s->timerctrl), "scu", | 92 | +ENTITLEMENT="$3" |
51 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
52 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->vic), 1, | ||
53 | qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_FIQ)); | ||
54 | |||
55 | + /* RTC */ | ||
56 | + object_property_set_bool(OBJECT(&s->rtc), true, "realized", &err); | ||
57 | + if (err) { | ||
58 | + error_propagate(errp, err); | ||
59 | + return; | ||
60 | + } | ||
61 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->rtc), 0, sc->info->memmap[ASPEED_RTC]); | ||
62 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->rtc), 0, | ||
63 | + aspeed_soc_get_irq(s, ASPEED_RTC)); | ||
64 | + | 93 | + |
65 | /* Timer */ | 94 | +trap 'rm "$DST.tmp"' exit |
66 | object_property_set_bool(OBJECT(&s->timerctrl), true, "realized", &err); | 95 | +cp -af "$SRC" "$DST.tmp" |
67 | if (err) { | 96 | +codesign --entitlements "$ENTITLEMENT" --force -s - "$DST.tmp" |
97 | +mv "$DST.tmp" "$DST" | ||
98 | +trap '' exit | ||
68 | -- | 99 | -- |
69 | 2.20.1 | 100 | 2.20.1 |
70 | 101 | ||
71 | 102 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Mihai Carabas <mihai.carabas@oracle.com> |
---|---|---|---|
2 | 2 | ||
3 | Suggested-by: Samuel Ortiz <sameo@linux.intel.com> | 3 | To ease the PCI device addition in next patches, split the code as follows: |
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 4 | - generic code (read/write/setup) is being kept in pvpanic.c |
5 | Message-id: 20190701132516.26392-11-philmd@redhat.com | 5 | - ISA dependent code moved to pvpanic-isa.c |
6 | |||
7 | Also, rename: | ||
8 | - ISA_PVPANIC_DEVICE -> PVPANIC_ISA_DEVICE. | ||
9 | - TYPE_PVPANIC -> TYPE_PVPANIC_ISA. | ||
10 | - MemoryRegion io -> mr. | ||
11 | - pvpanic_ioport_* in pvpanic_*. | ||
12 | |||
13 | Update the build system with the new files and config structure. | ||
14 | |||
15 | Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 18 | --- |
9 | target/arm/cpu.h | 2 - | 19 | include/hw/misc/pvpanic.h | 23 +++++++++- |
10 | target/arm/translate.h | 5 - | 20 | hw/misc/pvpanic-isa.c | 94 +++++++++++++++++++++++++++++++++++++++ |
11 | target/arm/cpu.c | 226 +++++++++++++++++++++++++++++++++++++ | 21 | hw/misc/pvpanic.c | 85 +++-------------------------------- |
12 | target/arm/translate-a64.c | 128 --------------------- | 22 | hw/i386/Kconfig | 2 +- |
13 | target/arm/translate.c | 88 --------------- | 23 | hw/misc/Kconfig | 6 ++- |
14 | 5 files changed, 226 insertions(+), 223 deletions(-) | 24 | hw/misc/meson.build | 3 +- |
15 | 25 | tests/qtest/meson.build | 2 +- | |
16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 26 | 7 files changed, 130 insertions(+), 85 deletions(-) |
17 | index XXXXXXX..XXXXXXX 100644 | 27 | create mode 100644 hw/misc/pvpanic-isa.c |
18 | --- a/target/arm/cpu.h | 28 | |
19 | +++ b/target/arm/cpu.h | 29 | diff --git a/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.h |
20 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cpu); | 30 | index XXXXXXX..XXXXXXX 100644 |
21 | void arm_v7m_cpu_do_interrupt(CPUState *cpu); | 31 | --- a/include/hw/misc/pvpanic.h |
22 | bool arm_cpu_exec_interrupt(CPUState *cpu, int int_req); | 32 | +++ b/include/hw/misc/pvpanic.h |
23 | |||
24 | -void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags); | ||
25 | - | ||
26 | hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr, | ||
27 | MemTxAttrs *attrs); | ||
28 | |||
29 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/translate.h | ||
32 | +++ b/target/arm/translate.h | ||
33 | @@ -XXX,XX +XXX,XX @@ static inline void disas_set_insn_syndrome(DisasContext *s, uint32_t syn) | ||
34 | #ifdef TARGET_AARCH64 | ||
35 | void a64_translate_init(void); | ||
36 | void gen_a64_set_pc_im(uint64_t val); | ||
37 | -void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags); | ||
38 | extern const TranslatorOps aarch64_translator_ops; | ||
39 | #else | ||
40 | static inline void a64_translate_init(void) | ||
41 | @@ -XXX,XX +XXX,XX @@ static inline void a64_translate_init(void) | ||
42 | static inline void gen_a64_set_pc_im(uint64_t val) | ||
43 | { | ||
44 | } | ||
45 | - | ||
46 | -static inline void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) | ||
47 | -{ | ||
48 | -} | ||
49 | #endif | ||
50 | |||
51 | void arm_test_cc(DisasCompare *cmp, int cc); | ||
52 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/target/arm/cpu.c | ||
55 | +++ b/target/arm/cpu.c | ||
56 | @@ -XXX,XX +XXX,XX @@ | 33 | @@ -XXX,XX +XXX,XX @@ |
57 | */ | 34 | |
58 | 35 | #include "qom/object.h" | |
59 | #include "qemu/osdep.h" | 36 | |
60 | +#include "qemu/qemu-print.h" | 37 | -#define TYPE_PVPANIC "pvpanic" |
61 | #include "qemu-common.h" | 38 | +#define TYPE_PVPANIC_ISA_DEVICE "pvpanic" |
62 | #include "target/arm/idau.h" | 39 | |
63 | #include "qemu/module.h" | 40 | #define PVPANIC_IOPORT_PROP "ioport" |
64 | @@ -XXX,XX +XXX,XX @@ static void arm_disas_set_info(CPUState *cpu, disassemble_info *info) | 41 | |
65 | #endif | 42 | +/* The bit of supported pv event, TODO: include uapi header and remove this */ |
66 | } | 43 | +#define PVPANIC_F_PANICKED 0 |
67 | 44 | +#define PVPANIC_F_CRASHLOADED 1 | |
68 | +#ifdef TARGET_AARCH64 | 45 | + |
69 | + | 46 | +/* The pv event value */ |
70 | +static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) | 47 | +#define PVPANIC_PANICKED (1 << PVPANIC_F_PANICKED) |
48 | +#define PVPANIC_CRASHLOADED (1 << PVPANIC_F_CRASHLOADED) | ||
49 | + | ||
50 | +/* | ||
51 | + * PVPanicState for any device type | ||
52 | + */ | ||
53 | +typedef struct PVPanicState PVPanicState; | ||
54 | +struct PVPanicState { | ||
55 | + MemoryRegion mr; | ||
56 | + uint8_t events; | ||
57 | +}; | ||
58 | + | ||
59 | +void pvpanic_setup_io(PVPanicState *s, DeviceState *dev, unsigned size); | ||
60 | + | ||
61 | static inline uint16_t pvpanic_port(void) | ||
62 | { | ||
63 | - Object *o = object_resolve_path_type("", TYPE_PVPANIC, NULL); | ||
64 | + Object *o = object_resolve_path_type("", TYPE_PVPANIC_ISA_DEVICE, NULL); | ||
65 | if (!o) { | ||
66 | return 0; | ||
67 | } | ||
68 | diff --git a/hw/misc/pvpanic-isa.c b/hw/misc/pvpanic-isa.c | ||
69 | new file mode 100644 | ||
70 | index XXXXXXX..XXXXXXX | ||
71 | --- /dev/null | ||
72 | +++ b/hw/misc/pvpanic-isa.c | ||
73 | @@ -XXX,XX +XXX,XX @@ | ||
74 | +/* | ||
75 | + * QEMU simulated pvpanic device. | ||
76 | + * | ||
77 | + * Copyright Fujitsu, Corp. 2013 | ||
78 | + * | ||
79 | + * Authors: | ||
80 | + * Wen Congyang <wency@cn.fujitsu.com> | ||
81 | + * Hu Tao <hutao@cn.fujitsu.com> | ||
82 | + * | ||
83 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
84 | + * See the COPYING file in the top-level directory. | ||
85 | + * | ||
86 | + */ | ||
87 | + | ||
88 | +#include "qemu/osdep.h" | ||
89 | +#include "qemu/log.h" | ||
90 | +#include "qemu/module.h" | ||
91 | +#include "sysemu/runstate.h" | ||
92 | + | ||
93 | +#include "hw/nvram/fw_cfg.h" | ||
94 | +#include "hw/qdev-properties.h" | ||
95 | +#include "hw/misc/pvpanic.h" | ||
96 | +#include "qom/object.h" | ||
97 | +#include "hw/isa/isa.h" | ||
98 | + | ||
99 | +OBJECT_DECLARE_SIMPLE_TYPE(PVPanicISAState, PVPANIC_ISA_DEVICE) | ||
100 | + | ||
101 | +/* | ||
102 | + * PVPanicISAState for ISA device and | ||
103 | + * use ioport. | ||
104 | + */ | ||
105 | +struct PVPanicISAState { | ||
106 | + ISADevice parent_obj; | ||
107 | + | ||
108 | + uint16_t ioport; | ||
109 | + PVPanicState pvpanic; | ||
110 | +}; | ||
111 | + | ||
112 | +static void pvpanic_isa_initfn(Object *obj) | ||
71 | +{ | 113 | +{ |
72 | + ARMCPU *cpu = ARM_CPU(cs); | 114 | + PVPanicISAState *s = PVPANIC_ISA_DEVICE(obj); |
73 | + CPUARMState *env = &cpu->env; | 115 | + |
74 | + uint32_t psr = pstate_read(env); | 116 | + pvpanic_setup_io(&s->pvpanic, DEVICE(s), 1); |
75 | + int i; | 117 | +} |
76 | + int el = arm_current_el(env); | 118 | + |
77 | + const char *ns_status; | 119 | +static void pvpanic_isa_realizefn(DeviceState *dev, Error **errp) |
78 | + | 120 | +{ |
79 | + qemu_fprintf(f, " PC=%016" PRIx64 " ", env->pc); | 121 | + ISADevice *d = ISA_DEVICE(dev); |
80 | + for (i = 0; i < 32; i++) { | 122 | + PVPanicISAState *s = PVPANIC_ISA_DEVICE(dev); |
81 | + if (i == 31) { | 123 | + PVPanicState *ps = &s->pvpanic; |
82 | + qemu_fprintf(f, " SP=%016" PRIx64 "\n", env->xregs[i]); | 124 | + FWCfgState *fw_cfg = fw_cfg_find(); |
83 | + } else { | 125 | + uint16_t *pvpanic_port; |
84 | + qemu_fprintf(f, "X%02d=%016" PRIx64 "%s", i, env->xregs[i], | 126 | + |
85 | + (i + 2) % 3 ? " " : "\n"); | 127 | + if (!fw_cfg) { |
86 | + } | ||
87 | + } | ||
88 | + | ||
89 | + if (arm_feature(env, ARM_FEATURE_EL3) && el != 3) { | ||
90 | + ns_status = env->cp15.scr_el3 & SCR_NS ? "NS " : "S "; | ||
91 | + } else { | ||
92 | + ns_status = ""; | ||
93 | + } | ||
94 | + qemu_fprintf(f, "PSTATE=%08x %c%c%c%c %sEL%d%c", | ||
95 | + psr, | ||
96 | + psr & PSTATE_N ? 'N' : '-', | ||
97 | + psr & PSTATE_Z ? 'Z' : '-', | ||
98 | + psr & PSTATE_C ? 'C' : '-', | ||
99 | + psr & PSTATE_V ? 'V' : '-', | ||
100 | + ns_status, | ||
101 | + el, | ||
102 | + psr & PSTATE_SP ? 'h' : 't'); | ||
103 | + | ||
104 | + if (cpu_isar_feature(aa64_bti, cpu)) { | ||
105 | + qemu_fprintf(f, " BTYPE=%d", (psr & PSTATE_BTYPE) >> 10); | ||
106 | + } | ||
107 | + if (!(flags & CPU_DUMP_FPU)) { | ||
108 | + qemu_fprintf(f, "\n"); | ||
109 | + return; | 128 | + return; |
110 | + } | 129 | + } |
111 | + if (fp_exception_el(env, el) != 0) { | 130 | + |
112 | + qemu_fprintf(f, " FPU disabled\n"); | 131 | + pvpanic_port = g_malloc(sizeof(*pvpanic_port)); |
113 | + return; | 132 | + *pvpanic_port = cpu_to_le16(s->ioport); |
114 | + } | 133 | + fw_cfg_add_file(fw_cfg, "etc/pvpanic-port", pvpanic_port, |
115 | + qemu_fprintf(f, " FPCR=%08x FPSR=%08x\n", | 134 | + sizeof(*pvpanic_port)); |
116 | + vfp_get_fpcr(env), vfp_get_fpsr(env)); | 135 | + |
117 | + | 136 | + isa_register_ioport(d, &ps->mr, s->ioport); |
118 | + if (cpu_isar_feature(aa64_sve, cpu) && sve_exception_el(env, el) == 0) { | ||
119 | + int j, zcr_len = sve_zcr_len_for_el(env, el); | ||
120 | + | ||
121 | + for (i = 0; i <= FFR_PRED_NUM; i++) { | ||
122 | + bool eol; | ||
123 | + if (i == FFR_PRED_NUM) { | ||
124 | + qemu_fprintf(f, "FFR="); | ||
125 | + /* It's last, so end the line. */ | ||
126 | + eol = true; | ||
127 | + } else { | ||
128 | + qemu_fprintf(f, "P%02d=", i); | ||
129 | + switch (zcr_len) { | ||
130 | + case 0: | ||
131 | + eol = i % 8 == 7; | ||
132 | + break; | ||
133 | + case 1: | ||
134 | + eol = i % 6 == 5; | ||
135 | + break; | ||
136 | + case 2: | ||
137 | + case 3: | ||
138 | + eol = i % 3 == 2; | ||
139 | + break; | ||
140 | + default: | ||
141 | + /* More than one quadword per predicate. */ | ||
142 | + eol = true; | ||
143 | + break; | ||
144 | + } | ||
145 | + } | ||
146 | + for (j = zcr_len / 4; j >= 0; j--) { | ||
147 | + int digits; | ||
148 | + if (j * 4 + 4 <= zcr_len + 1) { | ||
149 | + digits = 16; | ||
150 | + } else { | ||
151 | + digits = (zcr_len % 4 + 1) * 4; | ||
152 | + } | ||
153 | + qemu_fprintf(f, "%0*" PRIx64 "%s", digits, | ||
154 | + env->vfp.pregs[i].p[j], | ||
155 | + j ? ":" : eol ? "\n" : " "); | ||
156 | + } | ||
157 | + } | ||
158 | + | ||
159 | + for (i = 0; i < 32; i++) { | ||
160 | + if (zcr_len == 0) { | ||
161 | + qemu_fprintf(f, "Z%02d=%016" PRIx64 ":%016" PRIx64 "%s", | ||
162 | + i, env->vfp.zregs[i].d[1], | ||
163 | + env->vfp.zregs[i].d[0], i & 1 ? "\n" : " "); | ||
164 | + } else if (zcr_len == 1) { | ||
165 | + qemu_fprintf(f, "Z%02d=%016" PRIx64 ":%016" PRIx64 | ||
166 | + ":%016" PRIx64 ":%016" PRIx64 "\n", | ||
167 | + i, env->vfp.zregs[i].d[3], env->vfp.zregs[i].d[2], | ||
168 | + env->vfp.zregs[i].d[1], env->vfp.zregs[i].d[0]); | ||
169 | + } else { | ||
170 | + for (j = zcr_len; j >= 0; j--) { | ||
171 | + bool odd = (zcr_len - j) % 2 != 0; | ||
172 | + if (j == zcr_len) { | ||
173 | + qemu_fprintf(f, "Z%02d[%x-%x]=", i, j, j - 1); | ||
174 | + } else if (!odd) { | ||
175 | + if (j > 0) { | ||
176 | + qemu_fprintf(f, " [%x-%x]=", j, j - 1); | ||
177 | + } else { | ||
178 | + qemu_fprintf(f, " [%x]=", j); | ||
179 | + } | ||
180 | + } | ||
181 | + qemu_fprintf(f, "%016" PRIx64 ":%016" PRIx64 "%s", | ||
182 | + env->vfp.zregs[i].d[j * 2 + 1], | ||
183 | + env->vfp.zregs[i].d[j * 2], | ||
184 | + odd || j == 0 ? "\n" : ":"); | ||
185 | + } | ||
186 | + } | ||
187 | + } | ||
188 | + } else { | ||
189 | + for (i = 0; i < 32; i++) { | ||
190 | + uint64_t *q = aa64_vfp_qreg(env, i); | ||
191 | + qemu_fprintf(f, "Q%02d=%016" PRIx64 ":%016" PRIx64 "%s", | ||
192 | + i, q[1], q[0], (i & 1 ? "\n" : " ")); | ||
193 | + } | ||
194 | + } | ||
195 | +} | 137 | +} |
196 | + | 138 | + |
197 | +#else | 139 | +static Property pvpanic_isa_properties[] = { |
198 | + | 140 | + DEFINE_PROP_UINT16(PVPANIC_IOPORT_PROP, PVPanicISAState, ioport, 0x505), |
199 | +static inline void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) | 141 | + DEFINE_PROP_UINT8("events", PVPanicISAState, pvpanic.events, PVPANIC_PANICKED | PVPANIC_CRASHLOADED), |
142 | + DEFINE_PROP_END_OF_LIST(), | ||
143 | +}; | ||
144 | + | ||
145 | +static void pvpanic_isa_class_init(ObjectClass *klass, void *data) | ||
200 | +{ | 146 | +{ |
201 | + g_assert_not_reached(); | 147 | + DeviceClass *dc = DEVICE_CLASS(klass); |
148 | + | ||
149 | + dc->realize = pvpanic_isa_realizefn; | ||
150 | + device_class_set_props(dc, pvpanic_isa_properties); | ||
151 | + set_bit(DEVICE_CATEGORY_MISC, dc->categories); | ||
202 | +} | 152 | +} |
203 | + | 153 | + |
204 | +#endif | 154 | +static TypeInfo pvpanic_isa_info = { |
205 | + | 155 | + .name = TYPE_PVPANIC_ISA_DEVICE, |
206 | +static void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags) | 156 | + .parent = TYPE_ISA_DEVICE, |
157 | + .instance_size = sizeof(PVPanicISAState), | ||
158 | + .instance_init = pvpanic_isa_initfn, | ||
159 | + .class_init = pvpanic_isa_class_init, | ||
160 | +}; | ||
161 | + | ||
162 | +static void pvpanic_register_types(void) | ||
207 | +{ | 163 | +{ |
208 | + ARMCPU *cpu = ARM_CPU(cs); | 164 | + type_register_static(&pvpanic_isa_info); |
209 | + CPUARMState *env = &cpu->env; | ||
210 | + int i; | ||
211 | + | ||
212 | + if (is_a64(env)) { | ||
213 | + aarch64_cpu_dump_state(cs, f, flags); | ||
214 | + return; | ||
215 | + } | ||
216 | + | ||
217 | + for (i = 0; i < 16; i++) { | ||
218 | + qemu_fprintf(f, "R%02d=%08x", i, env->regs[i]); | ||
219 | + if ((i % 4) == 3) { | ||
220 | + qemu_fprintf(f, "\n"); | ||
221 | + } else { | ||
222 | + qemu_fprintf(f, " "); | ||
223 | + } | ||
224 | + } | ||
225 | + | ||
226 | + if (arm_feature(env, ARM_FEATURE_M)) { | ||
227 | + uint32_t xpsr = xpsr_read(env); | ||
228 | + const char *mode; | ||
229 | + const char *ns_status = ""; | ||
230 | + | ||
231 | + if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
232 | + ns_status = env->v7m.secure ? "S " : "NS "; | ||
233 | + } | ||
234 | + | ||
235 | + if (xpsr & XPSR_EXCP) { | ||
236 | + mode = "handler"; | ||
237 | + } else { | ||
238 | + if (env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_NPRIV_MASK) { | ||
239 | + mode = "unpriv-thread"; | ||
240 | + } else { | ||
241 | + mode = "priv-thread"; | ||
242 | + } | ||
243 | + } | ||
244 | + | ||
245 | + qemu_fprintf(f, "XPSR=%08x %c%c%c%c %c %s%s\n", | ||
246 | + xpsr, | ||
247 | + xpsr & XPSR_N ? 'N' : '-', | ||
248 | + xpsr & XPSR_Z ? 'Z' : '-', | ||
249 | + xpsr & XPSR_C ? 'C' : '-', | ||
250 | + xpsr & XPSR_V ? 'V' : '-', | ||
251 | + xpsr & XPSR_T ? 'T' : 'A', | ||
252 | + ns_status, | ||
253 | + mode); | ||
254 | + } else { | ||
255 | + uint32_t psr = cpsr_read(env); | ||
256 | + const char *ns_status = ""; | ||
257 | + | ||
258 | + if (arm_feature(env, ARM_FEATURE_EL3) && | ||
259 | + (psr & CPSR_M) != ARM_CPU_MODE_MON) { | ||
260 | + ns_status = env->cp15.scr_el3 & SCR_NS ? "NS " : "S "; | ||
261 | + } | ||
262 | + | ||
263 | + qemu_fprintf(f, "PSR=%08x %c%c%c%c %c %s%s%d\n", | ||
264 | + psr, | ||
265 | + psr & CPSR_N ? 'N' : '-', | ||
266 | + psr & CPSR_Z ? 'Z' : '-', | ||
267 | + psr & CPSR_C ? 'C' : '-', | ||
268 | + psr & CPSR_V ? 'V' : '-', | ||
269 | + psr & CPSR_T ? 'T' : 'A', | ||
270 | + ns_status, | ||
271 | + aarch32_mode_name(psr), (psr & 0x10) ? 32 : 26); | ||
272 | + } | ||
273 | + | ||
274 | + if (flags & CPU_DUMP_FPU) { | ||
275 | + int numvfpregs = 0; | ||
276 | + if (arm_feature(env, ARM_FEATURE_VFP)) { | ||
277 | + numvfpregs += 16; | ||
278 | + } | ||
279 | + if (arm_feature(env, ARM_FEATURE_VFP3)) { | ||
280 | + numvfpregs += 16; | ||
281 | + } | ||
282 | + for (i = 0; i < numvfpregs; i++) { | ||
283 | + uint64_t v = *aa32_vfp_dreg(env, i); | ||
284 | + qemu_fprintf(f, "s%02d=%08x s%02d=%08x d%02d=%016" PRIx64 "\n", | ||
285 | + i * 2, (uint32_t)v, | ||
286 | + i * 2 + 1, (uint32_t)(v >> 32), | ||
287 | + i, v); | ||
288 | + } | ||
289 | + qemu_fprintf(f, "FPSCR: %08x\n", vfp_get_fpscr(env)); | ||
290 | + } | ||
291 | +} | 165 | +} |
292 | + | 166 | + |
293 | uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz) | 167 | +type_init(pvpanic_register_types) |
294 | { | 168 | diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c |
295 | uint32_t Aff1 = idx / clustersz; | 169 | index XXXXXXX..XXXXXXX 100644 |
296 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 170 | --- a/hw/misc/pvpanic.c |
297 | index XXXXXXX..XXXXXXX 100644 | 171 | +++ b/hw/misc/pvpanic.c |
298 | --- a/target/arm/translate-a64.c | ||
299 | +++ b/target/arm/translate-a64.c | ||
300 | @@ -XXX,XX +XXX,XX @@ | 172 | @@ -XXX,XX +XXX,XX @@ |
301 | #include "translate.h" | 173 | #include "hw/misc/pvpanic.h" |
302 | #include "internals.h" | 174 | #include "qom/object.h" |
303 | #include "qemu/host-utils.h" | 175 | |
304 | -#include "qemu/qemu-print.h" | 176 | -/* The bit of supported pv event, TODO: include uapi header and remove this */ |
305 | 177 | -#define PVPANIC_F_PANICKED 0 | |
306 | #include "hw/semihosting/semihost.h" | 178 | -#define PVPANIC_F_CRASHLOADED 1 |
307 | #include "exec/gen-icount.h" | 179 | - |
308 | @@ -XXX,XX +XXX,XX @@ static void set_btype(DisasContext *s, int val) | 180 | -/* The pv event value */ |
309 | s->btype = -1; | 181 | -#define PVPANIC_PANICKED (1 << PVPANIC_F_PANICKED) |
182 | -#define PVPANIC_CRASHLOADED (1 << PVPANIC_F_CRASHLOADED) | ||
183 | - | ||
184 | -typedef struct PVPanicState PVPanicState; | ||
185 | -DECLARE_INSTANCE_CHECKER(PVPanicState, ISA_PVPANIC_DEVICE, | ||
186 | - TYPE_PVPANIC) | ||
187 | - | ||
188 | static void handle_event(int event) | ||
189 | { | ||
190 | static bool logged; | ||
191 | @@ -XXX,XX +XXX,XX @@ static void handle_event(int event) | ||
192 | } | ||
310 | } | 193 | } |
311 | 194 | ||
312 | -void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) | 195 | -#include "hw/isa/isa.h" |
196 | - | ||
197 | -struct PVPanicState { | ||
198 | - ISADevice parent_obj; | ||
199 | - | ||
200 | - MemoryRegion io; | ||
201 | - uint16_t ioport; | ||
202 | - uint8_t events; | ||
203 | -}; | ||
204 | - | ||
205 | /* return supported events on read */ | ||
206 | -static uint64_t pvpanic_ioport_read(void *opaque, hwaddr addr, unsigned size) | ||
207 | +static uint64_t pvpanic_read(void *opaque, hwaddr addr, unsigned size) | ||
208 | { | ||
209 | PVPanicState *pvp = opaque; | ||
210 | return pvp->events; | ||
211 | } | ||
212 | |||
213 | -static void pvpanic_ioport_write(void *opaque, hwaddr addr, uint64_t val, | ||
214 | +static void pvpanic_write(void *opaque, hwaddr addr, uint64_t val, | ||
215 | unsigned size) | ||
216 | { | ||
217 | handle_event(val); | ||
218 | } | ||
219 | |||
220 | static const MemoryRegionOps pvpanic_ops = { | ||
221 | - .read = pvpanic_ioport_read, | ||
222 | - .write = pvpanic_ioport_write, | ||
223 | + .read = pvpanic_read, | ||
224 | + .write = pvpanic_write, | ||
225 | .impl = { | ||
226 | .min_access_size = 1, | ||
227 | .max_access_size = 1, | ||
228 | }, | ||
229 | }; | ||
230 | |||
231 | -static void pvpanic_isa_initfn(Object *obj) | ||
232 | +void pvpanic_setup_io(PVPanicState *s, DeviceState *dev, unsigned size) | ||
233 | { | ||
234 | - PVPanicState *s = ISA_PVPANIC_DEVICE(obj); | ||
235 | - | ||
236 | - memory_region_init_io(&s->io, OBJECT(s), &pvpanic_ops, s, "pvpanic", 1); | ||
237 | + memory_region_init_io(&s->mr, OBJECT(dev), &pvpanic_ops, s, "pvpanic", size); | ||
238 | } | ||
239 | - | ||
240 | -static void pvpanic_isa_realizefn(DeviceState *dev, Error **errp) | ||
313 | -{ | 241 | -{ |
314 | - ARMCPU *cpu = ARM_CPU(cs); | 242 | - ISADevice *d = ISA_DEVICE(dev); |
315 | - CPUARMState *env = &cpu->env; | 243 | - PVPanicState *s = ISA_PVPANIC_DEVICE(dev); |
316 | - uint32_t psr = pstate_read(env); | 244 | - FWCfgState *fw_cfg = fw_cfg_find(); |
317 | - int i; | 245 | - uint16_t *pvpanic_port; |
318 | - int el = arm_current_el(env); | 246 | - |
319 | - const char *ns_status; | 247 | - if (!fw_cfg) { |
320 | - | ||
321 | - qemu_fprintf(f, " PC=%016" PRIx64 " ", env->pc); | ||
322 | - for (i = 0; i < 32; i++) { | ||
323 | - if (i == 31) { | ||
324 | - qemu_fprintf(f, " SP=%016" PRIx64 "\n", env->xregs[i]); | ||
325 | - } else { | ||
326 | - qemu_fprintf(f, "X%02d=%016" PRIx64 "%s", i, env->xregs[i], | ||
327 | - (i + 2) % 3 ? " " : "\n"); | ||
328 | - } | ||
329 | - } | ||
330 | - | ||
331 | - if (arm_feature(env, ARM_FEATURE_EL3) && el != 3) { | ||
332 | - ns_status = env->cp15.scr_el3 & SCR_NS ? "NS " : "S "; | ||
333 | - } else { | ||
334 | - ns_status = ""; | ||
335 | - } | ||
336 | - qemu_fprintf(f, "PSTATE=%08x %c%c%c%c %sEL%d%c", | ||
337 | - psr, | ||
338 | - psr & PSTATE_N ? 'N' : '-', | ||
339 | - psr & PSTATE_Z ? 'Z' : '-', | ||
340 | - psr & PSTATE_C ? 'C' : '-', | ||
341 | - psr & PSTATE_V ? 'V' : '-', | ||
342 | - ns_status, | ||
343 | - el, | ||
344 | - psr & PSTATE_SP ? 'h' : 't'); | ||
345 | - | ||
346 | - if (cpu_isar_feature(aa64_bti, cpu)) { | ||
347 | - qemu_fprintf(f, " BTYPE=%d", (psr & PSTATE_BTYPE) >> 10); | ||
348 | - } | ||
349 | - if (!(flags & CPU_DUMP_FPU)) { | ||
350 | - qemu_fprintf(f, "\n"); | ||
351 | - return; | 248 | - return; |
352 | - } | 249 | - } |
353 | - if (fp_exception_el(env, el) != 0) { | 250 | - |
354 | - qemu_fprintf(f, " FPU disabled\n"); | 251 | - pvpanic_port = g_malloc(sizeof(*pvpanic_port)); |
355 | - return; | 252 | - *pvpanic_port = cpu_to_le16(s->ioport); |
356 | - } | 253 | - fw_cfg_add_file(fw_cfg, "etc/pvpanic-port", pvpanic_port, |
357 | - qemu_fprintf(f, " FPCR=%08x FPSR=%08x\n", | 254 | - sizeof(*pvpanic_port)); |
358 | - vfp_get_fpcr(env), vfp_get_fpsr(env)); | 255 | - |
359 | - | 256 | - isa_register_ioport(d, &s->io, s->ioport); |
360 | - if (cpu_isar_feature(aa64_sve, cpu) && sve_exception_el(env, el) == 0) { | ||
361 | - int j, zcr_len = sve_zcr_len_for_el(env, el); | ||
362 | - | ||
363 | - for (i = 0; i <= FFR_PRED_NUM; i++) { | ||
364 | - bool eol; | ||
365 | - if (i == FFR_PRED_NUM) { | ||
366 | - qemu_fprintf(f, "FFR="); | ||
367 | - /* It's last, so end the line. */ | ||
368 | - eol = true; | ||
369 | - } else { | ||
370 | - qemu_fprintf(f, "P%02d=", i); | ||
371 | - switch (zcr_len) { | ||
372 | - case 0: | ||
373 | - eol = i % 8 == 7; | ||
374 | - break; | ||
375 | - case 1: | ||
376 | - eol = i % 6 == 5; | ||
377 | - break; | ||
378 | - case 2: | ||
379 | - case 3: | ||
380 | - eol = i % 3 == 2; | ||
381 | - break; | ||
382 | - default: | ||
383 | - /* More than one quadword per predicate. */ | ||
384 | - eol = true; | ||
385 | - break; | ||
386 | - } | ||
387 | - } | ||
388 | - for (j = zcr_len / 4; j >= 0; j--) { | ||
389 | - int digits; | ||
390 | - if (j * 4 + 4 <= zcr_len + 1) { | ||
391 | - digits = 16; | ||
392 | - } else { | ||
393 | - digits = (zcr_len % 4 + 1) * 4; | ||
394 | - } | ||
395 | - qemu_fprintf(f, "%0*" PRIx64 "%s", digits, | ||
396 | - env->vfp.pregs[i].p[j], | ||
397 | - j ? ":" : eol ? "\n" : " "); | ||
398 | - } | ||
399 | - } | ||
400 | - | ||
401 | - for (i = 0; i < 32; i++) { | ||
402 | - if (zcr_len == 0) { | ||
403 | - qemu_fprintf(f, "Z%02d=%016" PRIx64 ":%016" PRIx64 "%s", | ||
404 | - i, env->vfp.zregs[i].d[1], | ||
405 | - env->vfp.zregs[i].d[0], i & 1 ? "\n" : " "); | ||
406 | - } else if (zcr_len == 1) { | ||
407 | - qemu_fprintf(f, "Z%02d=%016" PRIx64 ":%016" PRIx64 | ||
408 | - ":%016" PRIx64 ":%016" PRIx64 "\n", | ||
409 | - i, env->vfp.zregs[i].d[3], env->vfp.zregs[i].d[2], | ||
410 | - env->vfp.zregs[i].d[1], env->vfp.zregs[i].d[0]); | ||
411 | - } else { | ||
412 | - for (j = zcr_len; j >= 0; j--) { | ||
413 | - bool odd = (zcr_len - j) % 2 != 0; | ||
414 | - if (j == zcr_len) { | ||
415 | - qemu_fprintf(f, "Z%02d[%x-%x]=", i, j, j - 1); | ||
416 | - } else if (!odd) { | ||
417 | - if (j > 0) { | ||
418 | - qemu_fprintf(f, " [%x-%x]=", j, j - 1); | ||
419 | - } else { | ||
420 | - qemu_fprintf(f, " [%x]=", j); | ||
421 | - } | ||
422 | - } | ||
423 | - qemu_fprintf(f, "%016" PRIx64 ":%016" PRIx64 "%s", | ||
424 | - env->vfp.zregs[i].d[j * 2 + 1], | ||
425 | - env->vfp.zregs[i].d[j * 2], | ||
426 | - odd || j == 0 ? "\n" : ":"); | ||
427 | - } | ||
428 | - } | ||
429 | - } | ||
430 | - } else { | ||
431 | - for (i = 0; i < 32; i++) { | ||
432 | - uint64_t *q = aa64_vfp_qreg(env, i); | ||
433 | - qemu_fprintf(f, "Q%02d=%016" PRIx64 ":%016" PRIx64 "%s", | ||
434 | - i, q[1], q[0], (i & 1 ? "\n" : " ")); | ||
435 | - } | ||
436 | - } | ||
437 | -} | 257 | -} |
438 | - | 258 | - |
439 | void gen_a64_set_pc_im(uint64_t val) | 259 | -static Property pvpanic_isa_properties[] = { |
440 | { | 260 | - DEFINE_PROP_UINT16(PVPANIC_IOPORT_PROP, PVPanicState, ioport, 0x505), |
441 | tcg_gen_movi_i64(cpu_pc, val); | 261 | - DEFINE_PROP_UINT8("events", PVPanicState, events, PVPANIC_PANICKED | PVPANIC_CRASHLOADED), |
442 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 262 | - DEFINE_PROP_END_OF_LIST(), |
443 | index XXXXXXX..XXXXXXX 100644 | 263 | -}; |
444 | --- a/target/arm/translate.c | 264 | - |
445 | +++ b/target/arm/translate.c | 265 | -static void pvpanic_isa_class_init(ObjectClass *klass, void *data) |
446 | @@ -XXX,XX +XXX,XX @@ | ||
447 | #include "tcg-op-gvec.h" | ||
448 | #include "qemu/log.h" | ||
449 | #include "qemu/bitops.h" | ||
450 | -#include "qemu/qemu-print.h" | ||
451 | #include "arm_ldst.h" | ||
452 | #include "hw/semihosting/semihost.h" | ||
453 | |||
454 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns) | ||
455 | translator_loop(ops, &dc.base, cpu, tb, max_insns); | ||
456 | } | ||
457 | |||
458 | -void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags) | ||
459 | -{ | 266 | -{ |
460 | - ARMCPU *cpu = ARM_CPU(cs); | 267 | - DeviceClass *dc = DEVICE_CLASS(klass); |
461 | - CPUARMState *env = &cpu->env; | 268 | - |
462 | - int i; | 269 | - dc->realize = pvpanic_isa_realizefn; |
463 | - | 270 | - device_class_set_props(dc, pvpanic_isa_properties); |
464 | - if (is_a64(env)) { | 271 | - set_bit(DEVICE_CATEGORY_MISC, dc->categories); |
465 | - aarch64_cpu_dump_state(cs, f, flags); | ||
466 | - return; | ||
467 | - } | ||
468 | - | ||
469 | - for (i = 0; i < 16; i++) { | ||
470 | - qemu_fprintf(f, "R%02d=%08x", i, env->regs[i]); | ||
471 | - if ((i % 4) == 3) { | ||
472 | - qemu_fprintf(f, "\n"); | ||
473 | - } else { | ||
474 | - qemu_fprintf(f, " "); | ||
475 | - } | ||
476 | - } | ||
477 | - | ||
478 | - if (arm_feature(env, ARM_FEATURE_M)) { | ||
479 | - uint32_t xpsr = xpsr_read(env); | ||
480 | - const char *mode; | ||
481 | - const char *ns_status = ""; | ||
482 | - | ||
483 | - if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
484 | - ns_status = env->v7m.secure ? "S " : "NS "; | ||
485 | - } | ||
486 | - | ||
487 | - if (xpsr & XPSR_EXCP) { | ||
488 | - mode = "handler"; | ||
489 | - } else { | ||
490 | - if (env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_NPRIV_MASK) { | ||
491 | - mode = "unpriv-thread"; | ||
492 | - } else { | ||
493 | - mode = "priv-thread"; | ||
494 | - } | ||
495 | - } | ||
496 | - | ||
497 | - qemu_fprintf(f, "XPSR=%08x %c%c%c%c %c %s%s\n", | ||
498 | - xpsr, | ||
499 | - xpsr & XPSR_N ? 'N' : '-', | ||
500 | - xpsr & XPSR_Z ? 'Z' : '-', | ||
501 | - xpsr & XPSR_C ? 'C' : '-', | ||
502 | - xpsr & XPSR_V ? 'V' : '-', | ||
503 | - xpsr & XPSR_T ? 'T' : 'A', | ||
504 | - ns_status, | ||
505 | - mode); | ||
506 | - } else { | ||
507 | - uint32_t psr = cpsr_read(env); | ||
508 | - const char *ns_status = ""; | ||
509 | - | ||
510 | - if (arm_feature(env, ARM_FEATURE_EL3) && | ||
511 | - (psr & CPSR_M) != ARM_CPU_MODE_MON) { | ||
512 | - ns_status = env->cp15.scr_el3 & SCR_NS ? "NS " : "S "; | ||
513 | - } | ||
514 | - | ||
515 | - qemu_fprintf(f, "PSR=%08x %c%c%c%c %c %s%s%d\n", | ||
516 | - psr, | ||
517 | - psr & CPSR_N ? 'N' : '-', | ||
518 | - psr & CPSR_Z ? 'Z' : '-', | ||
519 | - psr & CPSR_C ? 'C' : '-', | ||
520 | - psr & CPSR_V ? 'V' : '-', | ||
521 | - psr & CPSR_T ? 'T' : 'A', | ||
522 | - ns_status, | ||
523 | - aarch32_mode_name(psr), (psr & 0x10) ? 32 : 26); | ||
524 | - } | ||
525 | - | ||
526 | - if (flags & CPU_DUMP_FPU) { | ||
527 | - int numvfpregs = 0; | ||
528 | - if (arm_feature(env, ARM_FEATURE_VFP)) { | ||
529 | - numvfpregs += 16; | ||
530 | - } | ||
531 | - if (arm_feature(env, ARM_FEATURE_VFP3)) { | ||
532 | - numvfpregs += 16; | ||
533 | - } | ||
534 | - for (i = 0; i < numvfpregs; i++) { | ||
535 | - uint64_t v = *aa32_vfp_dreg(env, i); | ||
536 | - qemu_fprintf(f, "s%02d=%08x s%02d=%08x d%02d=%016" PRIx64 "\n", | ||
537 | - i * 2, (uint32_t)v, | ||
538 | - i * 2 + 1, (uint32_t)(v >> 32), | ||
539 | - i, v); | ||
540 | - } | ||
541 | - qemu_fprintf(f, "FPSCR: %08x\n", vfp_get_fpscr(env)); | ||
542 | - } | ||
543 | -} | 272 | -} |
544 | - | 273 | - |
545 | void restore_state_to_opc(CPUARMState *env, TranslationBlock *tb, | 274 | -static TypeInfo pvpanic_isa_info = { |
546 | target_ulong *data) | 275 | - .name = TYPE_PVPANIC, |
547 | { | 276 | - .parent = TYPE_ISA_DEVICE, |
277 | - .instance_size = sizeof(PVPanicState), | ||
278 | - .instance_init = pvpanic_isa_initfn, | ||
279 | - .class_init = pvpanic_isa_class_init, | ||
280 | -}; | ||
281 | - | ||
282 | -static void pvpanic_register_types(void) | ||
283 | -{ | ||
284 | - type_register_static(&pvpanic_isa_info); | ||
285 | -} | ||
286 | - | ||
287 | -type_init(pvpanic_register_types) | ||
288 | diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig | ||
289 | index XXXXXXX..XXXXXXX 100644 | ||
290 | --- a/hw/i386/Kconfig | ||
291 | +++ b/hw/i386/Kconfig | ||
292 | @@ -XXX,XX +XXX,XX @@ config PC | ||
293 | imply ISA_DEBUG | ||
294 | imply PARALLEL | ||
295 | imply PCI_DEVICES | ||
296 | - imply PVPANIC | ||
297 | + imply PVPANIC_ISA | ||
298 | imply QXL | ||
299 | imply SEV | ||
300 | imply SGA | ||
301 | diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig | ||
302 | index XXXXXXX..XXXXXXX 100644 | ||
303 | --- a/hw/misc/Kconfig | ||
304 | +++ b/hw/misc/Kconfig | ||
305 | @@ -XXX,XX +XXX,XX @@ config IOTKIT_SYSCTL | ||
306 | config IOTKIT_SYSINFO | ||
307 | bool | ||
308 | |||
309 | -config PVPANIC | ||
310 | +config PVPANIC_COMMON | ||
311 | + bool | ||
312 | + | ||
313 | +config PVPANIC_ISA | ||
314 | bool | ||
315 | depends on ISA_BUS | ||
316 | + select PVPANIC_COMMON | ||
317 | |||
318 | config AUX | ||
319 | bool | ||
320 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build | ||
321 | index XXXXXXX..XXXXXXX 100644 | ||
322 | --- a/hw/misc/meson.build | ||
323 | +++ b/hw/misc/meson.build | ||
324 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_EMC141X', if_true: files('emc141x.c')) | ||
325 | softmmu_ss.add(when: 'CONFIG_UNIMP', if_true: files('unimp.c')) | ||
326 | softmmu_ss.add(when: 'CONFIG_EMPTY_SLOT', if_true: files('empty_slot.c')) | ||
327 | softmmu_ss.add(when: 'CONFIG_LED', if_true: files('led.c')) | ||
328 | +softmmu_ss.add(when: 'CONFIG_PVPANIC_COMMON', if_true: files('pvpanic.c')) | ||
329 | |||
330 | # ARM devices | ||
331 | softmmu_ss.add(when: 'CONFIG_PL310', if_true: files('arm_l2x0.c')) | ||
332 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_IOTKIT_SYSINFO', if_true: files('iotkit-sysinfo.c') | ||
333 | softmmu_ss.add(when: 'CONFIG_ARMSSE_CPUID', if_true: files('armsse-cpuid.c')) | ||
334 | softmmu_ss.add(when: 'CONFIG_ARMSSE_MHU', if_true: files('armsse-mhu.c')) | ||
335 | |||
336 | -softmmu_ss.add(when: 'CONFIG_PVPANIC', if_true: files('pvpanic.c')) | ||
337 | +softmmu_ss.add(when: 'CONFIG_PVPANIC_ISA', if_true: files('pvpanic-isa.c')) | ||
338 | softmmu_ss.add(when: 'CONFIG_AUX', if_true: files('auxbus.c')) | ||
339 | softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_scu.c', 'aspeed_sdmc.c', 'aspeed_xdma.c')) | ||
340 | softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('msf2-sysreg.c')) | ||
341 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build | ||
342 | index XXXXXXX..XXXXXXX 100644 | ||
343 | --- a/tests/qtest/meson.build | ||
344 | +++ b/tests/qtest/meson.build | ||
345 | @@ -XXX,XX +XXX,XX @@ qtests_i386 = \ | ||
346 | (config_host.has_key('CONFIG_LINUX') and \ | ||
347 | config_all_devices.has_key('CONFIG_ISA_IPMI_BT') ? ['ipmi-bt-test'] : []) + \ | ||
348 | (config_all_devices.has_key('CONFIG_WDT_IB700') ? ['wdt_ib700-test'] : []) + \ | ||
349 | - (config_all_devices.has_key('CONFIG_PVPANIC') ? ['pvpanic-test'] : []) + \ | ||
350 | + (config_all_devices.has_key('CONFIG_PVPANIC_ISA') ? ['pvpanic-test'] : []) + \ | ||
351 | (config_all_devices.has_key('CONFIG_HDA') ? ['intel-hda-test'] : []) + \ | ||
352 | (config_all_devices.has_key('CONFIG_I82801B11') ? ['i82801b11-test'] : []) + \ | ||
353 | (config_all_devices.has_key('CONFIG_IOH3420') ? ['ioh3420-test'] : []) + \ | ||
548 | -- | 354 | -- |
549 | 2.20.1 | 355 | 2.20.1 |
550 | 356 | ||
551 | 357 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | From: Mihai Carabas <mihai.carabas@oracle.com> |
---|---|---|---|
2 | 2 | ||
3 | The RTC is modeled to provide time and date functionality. It is | 3 | Add PCI interface support for PVPANIC device. Create a new file pvpanic-pci.c |
4 | initialised at zero to match the hardware. | 4 | where the PCI specific routines reside and update the build system with the new |
5 | files and config structure. | ||
5 | 6 | ||
6 | There is no modelling of the alarm functionality, which includes the IRQ | 7 | Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com> |
7 | line. As there is no guest code to exercise this function that is | 8 | Reviewed-by: Gerd Hoffmann <kraxel@redhat.com> |
8 | acceptable for now. | ||
9 | |||
10 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Message-id: 20190618165311.27066-4-clg@kaod.org | 10 | Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com> |
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 12 | --- |
15 | hw/timer/Makefile.objs | 2 +- | 13 | docs/specs/pci-ids.txt | 1 + |
16 | include/hw/timer/aspeed_rtc.h | 31 ++++++ | 14 | include/hw/misc/pvpanic.h | 1 + |
17 | hw/timer/aspeed_rtc.c | 180 ++++++++++++++++++++++++++++++++++ | 15 | include/hw/pci/pci.h | 1 + |
18 | hw/timer/trace-events | 4 + | 16 | hw/misc/pvpanic-pci.c | 94 +++++++++++++++++++++++++++++++++++++++ |
19 | 4 files changed, 216 insertions(+), 1 deletion(-) | 17 | hw/misc/Kconfig | 6 +++ |
20 | create mode 100644 include/hw/timer/aspeed_rtc.h | 18 | hw/misc/meson.build | 1 + |
21 | create mode 100644 hw/timer/aspeed_rtc.c | 19 | 6 files changed, 104 insertions(+) |
20 | create mode 100644 hw/misc/pvpanic-pci.c | ||
22 | 21 | ||
23 | diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs | 22 | diff --git a/docs/specs/pci-ids.txt b/docs/specs/pci-ids.txt |
24 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/hw/timer/Makefile.objs | 24 | --- a/docs/specs/pci-ids.txt |
26 | +++ b/hw/timer/Makefile.objs | 25 | +++ b/docs/specs/pci-ids.txt |
27 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_MC146818RTC) += mc146818rtc.o | 26 | @@ -XXX,XX +XXX,XX @@ PCI devices (other than virtio): |
28 | obj-$(CONFIG_ALLWINNER_A10_PIT) += allwinner-a10-pit.o | 27 | 1b36:000d PCI xhci usb host adapter |
29 | 28 | 1b36:000f mdpy (mdev sample device), linux/samples/vfio-mdev/mdpy.c | |
30 | common-obj-$(CONFIG_STM32F2XX_TIMER) += stm32f2xx_timer.o | 29 | 1b36:0010 PCIe NVMe device (-device nvme) |
31 | -common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o | 30 | +1b36:0011 PCI PVPanic device (-device pvpanic-pci) |
32 | +common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o aspeed_rtc.o | 31 | |
33 | 32 | All these devices are documented in docs/specs. | |
34 | common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o | 33 | |
35 | common-obj-$(CONFIG_CMSDK_APB_TIMER) += cmsdk-apb-timer.o | 34 | diff --git a/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.h |
36 | diff --git a/include/hw/timer/aspeed_rtc.h b/include/hw/timer/aspeed_rtc.h | 35 | index XXXXXXX..XXXXXXX 100644 |
36 | --- a/include/hw/misc/pvpanic.h | ||
37 | +++ b/include/hw/misc/pvpanic.h | ||
38 | @@ -XXX,XX +XXX,XX @@ | ||
39 | #include "qom/object.h" | ||
40 | |||
41 | #define TYPE_PVPANIC_ISA_DEVICE "pvpanic" | ||
42 | +#define TYPE_PVPANIC_PCI_DEVICE "pvpanic-pci" | ||
43 | |||
44 | #define PVPANIC_IOPORT_PROP "ioport" | ||
45 | |||
46 | diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/include/hw/pci/pci.h | ||
49 | +++ b/include/hw/pci/pci.h | ||
50 | @@ -XXX,XX +XXX,XX @@ extern bool pci_available; | ||
51 | #define PCI_DEVICE_ID_REDHAT_PCIE_BRIDGE 0x000e | ||
52 | #define PCI_DEVICE_ID_REDHAT_MDPY 0x000f | ||
53 | #define PCI_DEVICE_ID_REDHAT_NVME 0x0010 | ||
54 | +#define PCI_DEVICE_ID_REDHAT_PVPANIC 0x0011 | ||
55 | #define PCI_DEVICE_ID_REDHAT_QXL 0x0100 | ||
56 | |||
57 | #define FMT_PCIBUS PRIx64 | ||
58 | diff --git a/hw/misc/pvpanic-pci.c b/hw/misc/pvpanic-pci.c | ||
37 | new file mode 100644 | 59 | new file mode 100644 |
38 | index XXXXXXX..XXXXXXX | 60 | index XXXXXXX..XXXXXXX |
39 | --- /dev/null | 61 | --- /dev/null |
40 | +++ b/include/hw/timer/aspeed_rtc.h | 62 | +++ b/hw/misc/pvpanic-pci.c |
41 | @@ -XXX,XX +XXX,XX @@ | 63 | @@ -XXX,XX +XXX,XX @@ |
42 | +/* | 64 | +/* |
43 | + * ASPEED Real Time Clock | 65 | + * QEMU simulated PCI pvpanic device. |
44 | + * Joel Stanley <joel@jms.id.au> | ||
45 | + * | 66 | + * |
46 | + * Copyright 2019 IBM Corp | 67 | + * Copyright (C) 2020 Oracle |
47 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
48 | + */ | ||
49 | +#ifndef ASPEED_RTC_H | ||
50 | +#define ASPEED_RTC_H | ||
51 | + | ||
52 | +#include <stdint.h> | ||
53 | + | ||
54 | +#include "hw/hw.h" | ||
55 | +#include "hw/irq.h" | ||
56 | +#include "hw/sysbus.h" | ||
57 | + | ||
58 | +typedef struct AspeedRtcState { | ||
59 | + SysBusDevice parent_obj; | ||
60 | + | ||
61 | + MemoryRegion iomem; | ||
62 | + qemu_irq irq; | ||
63 | + | ||
64 | + uint32_t reg[0x18]; | ||
65 | + int offset; | ||
66 | + | ||
67 | +} AspeedRtcState; | ||
68 | + | ||
69 | +#define TYPE_ASPEED_RTC "aspeed.rtc" | ||
70 | +#define ASPEED_RTC(obj) OBJECT_CHECK(AspeedRtcState, (obj), TYPE_ASPEED_RTC) | ||
71 | + | ||
72 | +#endif /* ASPEED_RTC_H */ | ||
73 | diff --git a/hw/timer/aspeed_rtc.c b/hw/timer/aspeed_rtc.c | ||
74 | new file mode 100644 | ||
75 | index XXXXXXX..XXXXXXX | ||
76 | --- /dev/null | ||
77 | +++ b/hw/timer/aspeed_rtc.c | ||
78 | @@ -XXX,XX +XXX,XX @@ | ||
79 | +/* | ||
80 | + * ASPEED Real Time Clock | ||
81 | + * Joel Stanley <joel@jms.id.au> | ||
82 | + * | 68 | + * |
83 | + * Copyright 2019 IBM Corp | 69 | + * Authors: |
84 | + * SPDX-License-Identifier: GPL-2.0-or-later | 70 | + * Mihai Carabas <mihai.carabas@oracle.com> |
71 | + * | ||
72 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
73 | + * See the COPYING file in the top-level directory. | ||
74 | + * | ||
85 | + */ | 75 | + */ |
86 | + | 76 | + |
87 | +#include "qemu/osdep.h" | 77 | +#include "qemu/osdep.h" |
88 | +#include "qemu-common.h" | ||
89 | +#include "hw/timer/aspeed_rtc.h" | ||
90 | +#include "qemu/log.h" | 78 | +#include "qemu/log.h" |
91 | +#include "qemu/timer.h" | 79 | +#include "qemu/module.h" |
80 | +#include "sysemu/runstate.h" | ||
92 | + | 81 | + |
93 | +#include "trace.h" | 82 | +#include "hw/nvram/fw_cfg.h" |
83 | +#include "hw/qdev-properties.h" | ||
84 | +#include "migration/vmstate.h" | ||
85 | +#include "hw/misc/pvpanic.h" | ||
86 | +#include "qom/object.h" | ||
87 | +#include "hw/pci/pci.h" | ||
94 | + | 88 | + |
95 | +#define COUNTER1 (0x00 / 4) | 89 | +OBJECT_DECLARE_SIMPLE_TYPE(PVPanicPCIState, PVPANIC_PCI_DEVICE) |
96 | +#define COUNTER2 (0x04 / 4) | ||
97 | +#define ALARM (0x08 / 4) | ||
98 | +#define CONTROL (0x10 / 4) | ||
99 | +#define ALARM_STATUS (0x14 / 4) | ||
100 | + | 90 | + |
101 | +#define RTC_UNLOCKED BIT(1) | 91 | +/* |
102 | +#define RTC_ENABLED BIT(0) | 92 | + * PVPanicPCIState for PCI device |
93 | + */ | ||
94 | +typedef struct PVPanicPCIState { | ||
95 | + PCIDevice dev; | ||
96 | + PVPanicState pvpanic; | ||
97 | +} PVPanicPCIState; | ||
103 | + | 98 | + |
104 | +static void aspeed_rtc_calc_offset(AspeedRtcState *rtc) | 99 | +static const VMStateDescription vmstate_pvpanic_pci = { |
105 | +{ | 100 | + .name = "pvpanic-pci", |
106 | + struct tm tm; | ||
107 | + uint32_t year, cent; | ||
108 | + uint32_t reg1 = rtc->reg[COUNTER1]; | ||
109 | + uint32_t reg2 = rtc->reg[COUNTER2]; | ||
110 | + | ||
111 | + tm.tm_mday = (reg1 >> 24) & 0x1f; | ||
112 | + tm.tm_hour = (reg1 >> 16) & 0x1f; | ||
113 | + tm.tm_min = (reg1 >> 8) & 0x3f; | ||
114 | + tm.tm_sec = (reg1 >> 0) & 0x3f; | ||
115 | + | ||
116 | + cent = (reg2 >> 16) & 0x1f; | ||
117 | + year = (reg2 >> 8) & 0x7f; | ||
118 | + tm.tm_mon = ((reg2 >> 0) & 0x0f) - 1; | ||
119 | + tm.tm_year = year + (cent * 100) - 1900; | ||
120 | + | ||
121 | + rtc->offset = qemu_timedate_diff(&tm); | ||
122 | +} | ||
123 | + | ||
124 | +static uint32_t aspeed_rtc_get_counter(AspeedRtcState *rtc, int r) | ||
125 | +{ | ||
126 | + uint32_t year, cent; | ||
127 | + struct tm now; | ||
128 | + | ||
129 | + qemu_get_timedate(&now, rtc->offset); | ||
130 | + | ||
131 | + switch (r) { | ||
132 | + case COUNTER1: | ||
133 | + return (now.tm_mday << 24) | (now.tm_hour << 16) | | ||
134 | + (now.tm_min << 8) | now.tm_sec; | ||
135 | + case COUNTER2: | ||
136 | + cent = (now.tm_year + 1900) / 100; | ||
137 | + year = now.tm_year % 100; | ||
138 | + return ((cent & 0x1f) << 16) | ((year & 0x7f) << 8) | | ||
139 | + ((now.tm_mon + 1) & 0xf); | ||
140 | + default: | ||
141 | + g_assert_not_reached(); | ||
142 | + } | ||
143 | +} | ||
144 | + | ||
145 | +static uint64_t aspeed_rtc_read(void *opaque, hwaddr addr, | ||
146 | + unsigned size) | ||
147 | +{ | ||
148 | + AspeedRtcState *rtc = opaque; | ||
149 | + uint64_t val; | ||
150 | + uint32_t r = addr >> 2; | ||
151 | + | ||
152 | + switch (r) { | ||
153 | + case COUNTER1: | ||
154 | + case COUNTER2: | ||
155 | + if (rtc->reg[CONTROL] & RTC_ENABLED) { | ||
156 | + rtc->reg[r] = aspeed_rtc_get_counter(rtc, r); | ||
157 | + } | ||
158 | + /* fall through */ | ||
159 | + case CONTROL: | ||
160 | + val = rtc->reg[r]; | ||
161 | + break; | ||
162 | + case ALARM: | ||
163 | + case ALARM_STATUS: | ||
164 | + default: | ||
165 | + qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx "\n", __func__, addr); | ||
166 | + return 0; | ||
167 | + } | ||
168 | + | ||
169 | + trace_aspeed_rtc_read(addr, val); | ||
170 | + | ||
171 | + return val; | ||
172 | +} | ||
173 | + | ||
174 | +static void aspeed_rtc_write(void *opaque, hwaddr addr, | ||
175 | + uint64_t val, unsigned size) | ||
176 | +{ | ||
177 | + AspeedRtcState *rtc = opaque; | ||
178 | + uint32_t r = addr >> 2; | ||
179 | + | ||
180 | + switch (r) { | ||
181 | + case COUNTER1: | ||
182 | + case COUNTER2: | ||
183 | + if (!(rtc->reg[CONTROL] & RTC_UNLOCKED)) { | ||
184 | + break; | ||
185 | + } | ||
186 | + /* fall through */ | ||
187 | + case CONTROL: | ||
188 | + rtc->reg[r] = val; | ||
189 | + aspeed_rtc_calc_offset(rtc); | ||
190 | + break; | ||
191 | + case ALARM: | ||
192 | + case ALARM_STATUS: | ||
193 | + default: | ||
194 | + qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx "\n", __func__, addr); | ||
195 | + break; | ||
196 | + } | ||
197 | + trace_aspeed_rtc_write(addr, val); | ||
198 | +} | ||
199 | + | ||
200 | +static void aspeed_rtc_reset(DeviceState *d) | ||
201 | +{ | ||
202 | + AspeedRtcState *rtc = ASPEED_RTC(d); | ||
203 | + | ||
204 | + rtc->offset = 0; | ||
205 | + memset(rtc->reg, 0, sizeof(rtc->reg)); | ||
206 | +} | ||
207 | + | ||
208 | +static const MemoryRegionOps aspeed_rtc_ops = { | ||
209 | + .read = aspeed_rtc_read, | ||
210 | + .write = aspeed_rtc_write, | ||
211 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
212 | +}; | ||
213 | + | ||
214 | +static const VMStateDescription vmstate_aspeed_rtc = { | ||
215 | + .name = TYPE_ASPEED_RTC, | ||
216 | + .version_id = 1, | 101 | + .version_id = 1, |
102 | + .minimum_version_id = 1, | ||
217 | + .fields = (VMStateField[]) { | 103 | + .fields = (VMStateField[]) { |
218 | + VMSTATE_UINT32_ARRAY(reg, AspeedRtcState, 0x18), | 104 | + VMSTATE_PCI_DEVICE(dev, PVPanicPCIState), |
219 | + VMSTATE_INT32(offset, AspeedRtcState), | ||
220 | + VMSTATE_INT32(offset, AspeedRtcState), | ||
221 | + VMSTATE_END_OF_LIST() | 105 | + VMSTATE_END_OF_LIST() |
222 | + } | 106 | + } |
223 | +}; | 107 | +}; |
224 | + | 108 | + |
225 | +static void aspeed_rtc_realize(DeviceState *dev, Error **errp) | 109 | +static void pvpanic_pci_realizefn(PCIDevice *dev, Error **errp) |
226 | +{ | 110 | +{ |
227 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | 111 | + PVPanicPCIState *s = PVPANIC_PCI_DEVICE(dev); |
228 | + AspeedRtcState *s = ASPEED_RTC(dev); | 112 | + PVPanicState *ps = &s->pvpanic; |
229 | + | 113 | + |
230 | + sysbus_init_irq(sbd, &s->irq); | 114 | + pvpanic_setup_io(&s->pvpanic, DEVICE(s), 2); |
231 | + | 115 | + |
232 | + memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_rtc_ops, s, | 116 | + pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &ps->mr); |
233 | + "aspeed-rtc", 0x18ULL); | ||
234 | + sysbus_init_mmio(sbd, &s->iomem); | ||
235 | +} | 117 | +} |
236 | + | 118 | + |
237 | +static void aspeed_rtc_class_init(ObjectClass *klass, void *data) | 119 | +static Property pvpanic_pci_properties[] = { |
120 | + DEFINE_PROP_UINT8("events", PVPanicPCIState, pvpanic.events, PVPANIC_PANICKED | PVPANIC_CRASHLOADED), | ||
121 | + DEFINE_PROP_END_OF_LIST(), | ||
122 | +}; | ||
123 | + | ||
124 | +static void pvpanic_pci_class_init(ObjectClass *klass, void *data) | ||
238 | +{ | 125 | +{ |
239 | + DeviceClass *dc = DEVICE_CLASS(klass); | 126 | + DeviceClass *dc = DEVICE_CLASS(klass); |
127 | + PCIDeviceClass *pc = PCI_DEVICE_CLASS(klass); | ||
240 | + | 128 | + |
241 | + dc->realize = aspeed_rtc_realize; | 129 | + device_class_set_props(dc, pvpanic_pci_properties); |
242 | + dc->vmsd = &vmstate_aspeed_rtc; | 130 | + |
243 | + dc->reset = aspeed_rtc_reset; | 131 | + pc->realize = pvpanic_pci_realizefn; |
132 | + pc->vendor_id = PCI_VENDOR_ID_REDHAT; | ||
133 | + pc->device_id = PCI_DEVICE_ID_REDHAT_PVPANIC; | ||
134 | + pc->revision = 1; | ||
135 | + pc->class_id = PCI_CLASS_SYSTEM_OTHER; | ||
136 | + dc->vmsd = &vmstate_pvpanic_pci; | ||
137 | + | ||
138 | + set_bit(DEVICE_CATEGORY_MISC, dc->categories); | ||
244 | +} | 139 | +} |
245 | + | 140 | + |
246 | +static const TypeInfo aspeed_rtc_info = { | 141 | +static TypeInfo pvpanic_pci_info = { |
247 | + .name = TYPE_ASPEED_RTC, | 142 | + .name = TYPE_PVPANIC_PCI_DEVICE, |
248 | + .parent = TYPE_SYS_BUS_DEVICE, | 143 | + .parent = TYPE_PCI_DEVICE, |
249 | + .instance_size = sizeof(AspeedRtcState), | 144 | + .instance_size = sizeof(PVPanicPCIState), |
250 | + .class_init = aspeed_rtc_class_init, | 145 | + .class_init = pvpanic_pci_class_init, |
146 | + .interfaces = (InterfaceInfo[]) { | ||
147 | + { INTERFACE_CONVENTIONAL_PCI_DEVICE }, | ||
148 | + { } | ||
149 | + } | ||
251 | +}; | 150 | +}; |
252 | + | 151 | + |
253 | +static void aspeed_rtc_register_types(void) | 152 | +static void pvpanic_register_types(void) |
254 | +{ | 153 | +{ |
255 | + type_register_static(&aspeed_rtc_info); | 154 | + type_register_static(&pvpanic_pci_info); |
256 | +} | 155 | +} |
257 | + | 156 | + |
258 | +type_init(aspeed_rtc_register_types) | 157 | +type_init(pvpanic_register_types); |
259 | diff --git a/hw/timer/trace-events b/hw/timer/trace-events | 158 | diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig |
260 | index XXXXXXX..XXXXXXX 100644 | 159 | index XXXXXXX..XXXXXXX 100644 |
261 | --- a/hw/timer/trace-events | 160 | --- a/hw/misc/Kconfig |
262 | +++ b/hw/timer/trace-events | 161 | +++ b/hw/misc/Kconfig |
263 | @@ -XXX,XX +XXX,XX @@ cmsdk_apb_dualtimer_read(uint64_t offset, uint64_t data, unsigned size) "CMSDK A | 162 | @@ -XXX,XX +XXX,XX @@ config IOTKIT_SYSINFO |
264 | cmsdk_apb_dualtimer_write(uint64_t offset, uint64_t data, unsigned size) "CMSDK APB dualtimer write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" | 163 | config PVPANIC_COMMON |
265 | cmsdk_apb_dualtimer_reset(void) "CMSDK APB dualtimer: reset" | 164 | bool |
266 | 165 | ||
267 | +# hw/timer/aspeed-rtc.c | 166 | +config PVPANIC_PCI |
268 | +aspeed_rtc_read(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 0x%08" PRIx64 | 167 | + bool |
269 | +aspeed_rtc_write(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 0x%08" PRIx64 | 168 | + default y if PCI_DEVICES |
169 | + depends on PCI | ||
170 | + select PVPANIC_COMMON | ||
270 | + | 171 | + |
271 | # sun4v-rtc.c | 172 | config PVPANIC_ISA |
272 | sun4v_rtc_read(uint64_t addr, uint64_t value) "read: addr 0x%" PRIx64 " value 0x%" PRIx64 | 173 | bool |
273 | sun4v_rtc_write(uint64_t addr, uint64_t value) "write: addr 0x%" PRIx64 " value 0x%" PRIx64 | 174 | depends on ISA_BUS |
175 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build | ||
176 | index XXXXXXX..XXXXXXX 100644 | ||
177 | --- a/hw/misc/meson.build | ||
178 | +++ b/hw/misc/meson.build | ||
179 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_ARMSSE_CPUID', if_true: files('armsse-cpuid.c')) | ||
180 | softmmu_ss.add(when: 'CONFIG_ARMSSE_MHU', if_true: files('armsse-mhu.c')) | ||
181 | |||
182 | softmmu_ss.add(when: 'CONFIG_PVPANIC_ISA', if_true: files('pvpanic-isa.c')) | ||
183 | +softmmu_ss.add(when: 'CONFIG_PVPANIC_PCI', if_true: files('pvpanic-pci.c')) | ||
184 | softmmu_ss.add(when: 'CONFIG_AUX', if_true: files('auxbus.c')) | ||
185 | softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_scu.c', 'aspeed_sdmc.c', 'aspeed_xdma.c')) | ||
186 | softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('msf2-sysreg.c')) | ||
274 | -- | 187 | -- |
275 | 2.20.1 | 188 | 2.20.1 |
276 | 189 | ||
277 | 190 | diff view generated by jsdifflib |
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | 1 | From: Mihai Carabas <mihai.carabas@oracle.com> |
---|---|---|---|
2 | 2 | ||
3 | Expression to calculate update_msi_mapping in code handling writes to | 3 | Add pvpanic PCI device support details in docs/specs/pvpanic.txt. |
4 | DESIGNWARE_PCIE_MSI_INTR0_ENABLE is missing an ! operator and should | ||
5 | be: | ||
6 | 4 | ||
7 | !!root->msi.intr[0].enable ^ !!val; | 5 | Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com> |
8 | |||
9 | so that MSI mapping is updated when enabled transitions from either | ||
10 | "none" -> "any" or "any" -> "none". Since that register shouldn't be | ||
11 | written to very often, change the code to update MSI mapping | ||
12 | unconditionally instead of trying to fix the update_msi_mapping logic. | ||
13 | |||
14 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
15 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
16 | Cc: Michael S. Tsirkin <mst@redhat.com> | ||
17 | Cc: qemu-devel@nongnu.org | ||
18 | Cc: qemu-arm@nongnu.org | ||
19 | Acked-by: Michael S. Tsirkin <mst@redhat.com> | ||
20 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
22 | --- | 8 | --- |
23 | hw/pci-host/designware.c | 10 ++-------- | 9 | docs/specs/pvpanic.txt | 13 ++++++++++++- |
24 | 1 file changed, 2 insertions(+), 8 deletions(-) | 10 | 1 file changed, 12 insertions(+), 1 deletion(-) |
25 | 11 | ||
26 | diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c | 12 | diff --git a/docs/specs/pvpanic.txt b/docs/specs/pvpanic.txt |
27 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/hw/pci-host/designware.c | 14 | --- a/docs/specs/pvpanic.txt |
29 | +++ b/hw/pci-host/designware.c | 15 | +++ b/docs/specs/pvpanic.txt |
30 | @@ -XXX,XX +XXX,XX @@ static void designware_pcie_root_config_write(PCIDevice *d, uint32_t address, | 16 | @@ -XXX,XX +XXX,XX @@ |
31 | root->msi.base |= (uint64_t)val << 32; | 17 | PVPANIC DEVICE |
32 | break; | 18 | ============== |
33 | 19 | ||
34 | - case DESIGNWARE_PCIE_MSI_INTR0_ENABLE: { | 20 | -pvpanic device is a simulated ISA device, through which a guest panic |
35 | - const bool update_msi_mapping = !root->msi.intr[0].enable ^ !!val; | 21 | +pvpanic device is a simulated device, through which a guest panic |
36 | - | 22 | event is sent to qemu, and a QMP event is generated. This allows |
37 | + case DESIGNWARE_PCIE_MSI_INTR0_ENABLE: | 23 | management apps (e.g. libvirt) to be notified and respond to the event. |
38 | root->msi.intr[0].enable = val; | 24 | |
39 | - | 25 | @@ -XXX,XX +XXX,XX @@ The management app has the option of waiting for GUEST_PANICKED events, |
40 | - if (update_msi_mapping) { | 26 | and/or polling for guest-panicked RunState, to learn when the pvpanic |
41 | - designware_pcie_root_update_msi_mapping(root); | 27 | device has fired a panic event. |
42 | - } | 28 | |
43 | + designware_pcie_root_update_msi_mapping(root); | 29 | +The pvpanic device can be implemented as an ISA device (using IOPORT) or as a |
44 | break; | 30 | +PCI device. |
45 | - } | 31 | + |
46 | 32 | ISA Interface | |
47 | case DESIGNWARE_PCIE_MSI_INTR0_MASK: | 33 | ------------- |
48 | root->msi.intr[0].mask = val; | 34 | |
35 | @@ -XXX,XX +XXX,XX @@ bit 1: a guest panic has happened and will be handled by the guest; | ||
36 | the host should record it or report it, but should not affect | ||
37 | the execution of the guest. | ||
38 | |||
39 | +PCI Interface | ||
40 | +------------- | ||
41 | + | ||
42 | +The PCI interface is similar to the ISA interface except that it uses an MMIO | ||
43 | +address space provided by its BAR0, 1 byte long. Any machine with a PCI bus | ||
44 | +can enable a pvpanic device by adding '-device pvpanic-pci' to the command | ||
45 | +line. | ||
46 | + | ||
47 | ACPI Interface | ||
48 | -------------- | ||
49 | |||
49 | -- | 50 | -- |
50 | 2.20.1 | 51 | 2.20.1 |
51 | 52 | ||
52 | 53 | diff view generated by jsdifflib |
1 | From: Eddie James <eajames@linux.ibm.com> | 1 | From: Mihai Carabas <mihai.carabas@oracle.com> |
---|---|---|---|
2 | 2 | ||
3 | The XDMA engine embedded in the Aspeed SOCs performs PCI DMA operations | 3 | Add a test case for pvpanic-pci device. The scenario is the same as pvpanic |
4 | between the SOC (acting as a BMC) and a host processor in a server. | 4 | ISA device, but is using the PCI bus. |
5 | 5 | ||
6 | The XDMA engine exists on the AST2400, AST2500, and AST2600 SOCs, so | 6 | Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com> |
7 | enable it for all of those. Add trace events on the important register | 7 | Acked-by: Thomas Huth <thuth@redhat.com> |
8 | writes in the XDMA engine. | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | 9 | Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com> | |
10 | Signed-off-by: Eddie James <eajames@linux.ibm.com> | ||
11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
13 | Message-id: 20190618165311.27066-21-clg@kaod.org | ||
14 | [clg: - changed title ] | ||
15 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | --- | 11 | --- |
18 | hw/misc/Makefile.objs | 1 + | 12 | tests/qtest/pvpanic-pci-test.c | 94 ++++++++++++++++++++++++++++++++++ |
19 | include/hw/arm/aspeed_soc.h | 3 + | 13 | tests/qtest/meson.build | 1 + |
20 | include/hw/misc/aspeed_xdma.h | 30 +++++++ | 14 | 2 files changed, 95 insertions(+) |
21 | hw/arm/aspeed_soc.c | 17 ++++ | 15 | create mode 100644 tests/qtest/pvpanic-pci-test.c |
22 | hw/misc/aspeed_xdma.c | 165 ++++++++++++++++++++++++++++++++++ | ||
23 | hw/misc/trace-events | 3 + | ||
24 | 6 files changed, 219 insertions(+) | ||
25 | create mode 100644 include/hw/misc/aspeed_xdma.h | ||
26 | create mode 100644 hw/misc/aspeed_xdma.c | ||
27 | 16 | ||
28 | diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs | 17 | diff --git a/tests/qtest/pvpanic-pci-test.c b/tests/qtest/pvpanic-pci-test.c |
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/hw/misc/Makefile.objs | ||
31 | +++ b/hw/misc/Makefile.objs | ||
32 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_ARMSSE_MHU) += armsse-mhu.o | ||
33 | |||
34 | obj-$(CONFIG_PVPANIC) += pvpanic.o | ||
35 | obj-$(CONFIG_AUX) += auxbus.o | ||
36 | +obj-$(CONFIG_ASPEED_SOC) += aspeed_xdma.o | ||
37 | obj-$(CONFIG_ASPEED_SOC) += aspeed_scu.o aspeed_sdmc.o | ||
38 | obj-$(CONFIG_MSF2) += msf2-sysreg.o | ||
39 | obj-$(CONFIG_NRF51_SOC) += nrf51_rng.o | ||
40 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/include/hw/arm/aspeed_soc.h | ||
43 | +++ b/include/hw/arm/aspeed_soc.h | ||
44 | @@ -XXX,XX +XXX,XX @@ | ||
45 | #include "hw/intc/aspeed_vic.h" | ||
46 | #include "hw/misc/aspeed_scu.h" | ||
47 | #include "hw/misc/aspeed_sdmc.h" | ||
48 | +#include "hw/misc/aspeed_xdma.h" | ||
49 | #include "hw/timer/aspeed_timer.h" | ||
50 | #include "hw/timer/aspeed_rtc.h" | ||
51 | #include "hw/i2c/aspeed_i2c.h" | ||
52 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState { | ||
53 | AspeedTimerCtrlState timerctrl; | ||
54 | AspeedI2CState i2c; | ||
55 | AspeedSCUState scu; | ||
56 | + AspeedXDMAState xdma; | ||
57 | AspeedSMCState fmc; | ||
58 | AspeedSMCState spi[ASPEED_SPIS_NUM]; | ||
59 | AspeedSDMCState sdmc; | ||
60 | @@ -XXX,XX +XXX,XX @@ enum { | ||
61 | ASPEED_ETH1, | ||
62 | ASPEED_ETH2, | ||
63 | ASPEED_SDRAM, | ||
64 | + ASPEED_XDMA, | ||
65 | }; | ||
66 | |||
67 | #endif /* ASPEED_SOC_H */ | ||
68 | diff --git a/include/hw/misc/aspeed_xdma.h b/include/hw/misc/aspeed_xdma.h | ||
69 | new file mode 100644 | 18 | new file mode 100644 |
70 | index XXXXXXX..XXXXXXX | 19 | index XXXXXXX..XXXXXXX |
71 | --- /dev/null | 20 | --- /dev/null |
72 | +++ b/include/hw/misc/aspeed_xdma.h | 21 | +++ b/tests/qtest/pvpanic-pci-test.c |
73 | @@ -XXX,XX +XXX,XX @@ | 22 | @@ -XXX,XX +XXX,XX @@ |
74 | +/* | 23 | +/* |
75 | + * ASPEED XDMA Controller | 24 | + * QTest testcase for PV Panic PCI device |
76 | + * Eddie James <eajames@linux.ibm.com> | ||
77 | + * | 25 | + * |
78 | + * Copyright (C) 2019 IBM Corp. | 26 | + * Copyright (C) 2020 Oracle |
79 | + * SPDX-License-Identifer: GPL-2.0-or-later | ||
80 | + */ | ||
81 | + | ||
82 | +#ifndef ASPEED_XDMA_H | ||
83 | +#define ASPEED_XDMA_H | ||
84 | + | ||
85 | +#include "hw/sysbus.h" | ||
86 | + | ||
87 | +#define TYPE_ASPEED_XDMA "aspeed.xdma" | ||
88 | +#define ASPEED_XDMA(obj) OBJECT_CHECK(AspeedXDMAState, (obj), TYPE_ASPEED_XDMA) | ||
89 | + | ||
90 | +#define ASPEED_XDMA_NUM_REGS (ASPEED_XDMA_REG_SIZE / sizeof(uint32_t)) | ||
91 | +#define ASPEED_XDMA_REG_SIZE 0x7C | ||
92 | + | ||
93 | +typedef struct AspeedXDMAState { | ||
94 | + SysBusDevice parent; | ||
95 | + | ||
96 | + MemoryRegion iomem; | ||
97 | + qemu_irq irq; | ||
98 | + | ||
99 | + char bmc_cmdq_readp_set; | ||
100 | + uint32_t regs[ASPEED_XDMA_NUM_REGS]; | ||
101 | +} AspeedXDMAState; | ||
102 | + | ||
103 | +#endif /* ASPEED_XDMA_H */ | ||
104 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
105 | index XXXXXXX..XXXXXXX 100644 | ||
106 | --- a/hw/arm/aspeed_soc.c | ||
107 | +++ b/hw/arm/aspeed_soc.c | ||
108 | @@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2400_memmap[] = { | ||
109 | [ASPEED_VIC] = 0x1E6C0000, | ||
110 | [ASPEED_SDMC] = 0x1E6E0000, | ||
111 | [ASPEED_SCU] = 0x1E6E2000, | ||
112 | + [ASPEED_XDMA] = 0x1E6E7000, | ||
113 | [ASPEED_ADC] = 0x1E6E9000, | ||
114 | [ASPEED_SRAM] = 0x1E720000, | ||
115 | [ASPEED_GPIO] = 0x1E780000, | ||
116 | @@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2500_memmap[] = { | ||
117 | [ASPEED_VIC] = 0x1E6C0000, | ||
118 | [ASPEED_SDMC] = 0x1E6E0000, | ||
119 | [ASPEED_SCU] = 0x1E6E2000, | ||
120 | + [ASPEED_XDMA] = 0x1E6E7000, | ||
121 | [ASPEED_ADC] = 0x1E6E9000, | ||
122 | [ASPEED_SRAM] = 0x1E720000, | ||
123 | [ASPEED_GPIO] = 0x1E780000, | ||
124 | @@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2400_irqmap[] = { | ||
125 | [ASPEED_I2C] = 12, | ||
126 | [ASPEED_ETH1] = 2, | ||
127 | [ASPEED_ETH2] = 3, | ||
128 | + [ASPEED_XDMA] = 6, | ||
129 | }; | ||
130 | |||
131 | #define aspeed_soc_ast2500_irqmap aspeed_soc_ast2400_irqmap | ||
132 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | ||
133 | sysbus_init_child_obj(obj, "ftgmac100[*]", OBJECT(&s->ftgmac100[i]), | ||
134 | sizeof(s->ftgmac100[i]), TYPE_FTGMAC100); | ||
135 | } | ||
136 | + | ||
137 | + sysbus_init_child_obj(obj, "xdma", OBJECT(&s->xdma), sizeof(s->xdma), | ||
138 | + TYPE_ASPEED_XDMA); | ||
139 | } | ||
140 | |||
141 | static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
142 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
143 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, | ||
144 | aspeed_soc_get_irq(s, ASPEED_ETH1 + i)); | ||
145 | } | ||
146 | + | ||
147 | + /* XDMA */ | ||
148 | + object_property_set_bool(OBJECT(&s->xdma), true, "realized", &err); | ||
149 | + if (err) { | ||
150 | + error_propagate(errp, err); | ||
151 | + return; | ||
152 | + } | ||
153 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->xdma), 0, | ||
154 | + sc->info->memmap[ASPEED_XDMA]); | ||
155 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->xdma), 0, | ||
156 | + aspeed_soc_get_irq(s, ASPEED_XDMA)); | ||
157 | } | ||
158 | static Property aspeed_soc_properties[] = { | ||
159 | DEFINE_PROP_UINT32("num-cpus", AspeedSoCState, num_cpus, 0), | ||
160 | diff --git a/hw/misc/aspeed_xdma.c b/hw/misc/aspeed_xdma.c | ||
161 | new file mode 100644 | ||
162 | index XXXXXXX..XXXXXXX | ||
163 | --- /dev/null | ||
164 | +++ b/hw/misc/aspeed_xdma.c | ||
165 | @@ -XXX,XX +XXX,XX @@ | ||
166 | +/* | ||
167 | + * ASPEED XDMA Controller | ||
168 | + * Eddie James <eajames@linux.ibm.com> | ||
169 | + * | 27 | + * |
170 | + * Copyright (C) 2019 IBM Corp | 28 | + * Authors: |
171 | + * SPDX-License-Identifer: GPL-2.0-or-later | 29 | + * Mihai Carabas <mihai.carabas@oracle.com> |
30 | + * | ||
31 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
32 | + * See the COPYING file in the top-level directory. | ||
33 | + * | ||
172 | + */ | 34 | + */ |
173 | + | 35 | + |
174 | +#include "qemu/osdep.h" | 36 | +#include "qemu/osdep.h" |
175 | +#include "qemu/log.h" | 37 | +#include "libqos/libqtest.h" |
176 | +#include "qemu/error-report.h" | 38 | +#include "qapi/qmp/qdict.h" |
177 | +#include "hw/misc/aspeed_xdma.h" | 39 | +#include "libqos/pci.h" |
178 | +#include "qapi/error.h" | 40 | +#include "libqos/pci-pc.h" |
41 | +#include "hw/pci/pci_regs.h" | ||
179 | + | 42 | + |
180 | +#include "trace.h" | 43 | +static void test_panic_nopause(void) |
44 | +{ | ||
45 | + uint8_t val; | ||
46 | + QDict *response, *data; | ||
47 | + QTestState *qts; | ||
48 | + QPCIBus *pcibus; | ||
49 | + QPCIDevice *dev; | ||
50 | + QPCIBar bar; | ||
181 | + | 51 | + |
182 | +#define XDMA_BMC_CMDQ_ADDR 0x10 | 52 | + qts = qtest_init("-device pvpanic-pci,addr=04.0 -action panic=none"); |
183 | +#define XDMA_BMC_CMDQ_ENDP 0x14 | 53 | + pcibus = qpci_new_pc(qts, NULL); |
184 | +#define XDMA_BMC_CMDQ_WRP 0x18 | 54 | + dev = qpci_device_find(pcibus, QPCI_DEVFN(0x4, 0x0)); |
185 | +#define XDMA_BMC_CMDQ_W_MASK 0x0003FFFF | 55 | + qpci_device_enable(dev); |
186 | +#define XDMA_BMC_CMDQ_RDP 0x1C | 56 | + bar = qpci_iomap(dev, 0, NULL); |
187 | +#define XDMA_BMC_CMDQ_RDP_MAGIC 0xEE882266 | ||
188 | +#define XDMA_IRQ_ENG_CTRL 0x20 | ||
189 | +#define XDMA_IRQ_ENG_CTRL_US_COMP BIT(4) | ||
190 | +#define XDMA_IRQ_ENG_CTRL_DS_COMP BIT(5) | ||
191 | +#define XDMA_IRQ_ENG_CTRL_W_MASK 0xBFEFF07F | ||
192 | +#define XDMA_IRQ_ENG_STAT 0x24 | ||
193 | +#define XDMA_IRQ_ENG_STAT_US_COMP BIT(4) | ||
194 | +#define XDMA_IRQ_ENG_STAT_DS_COMP BIT(5) | ||
195 | +#define XDMA_IRQ_ENG_STAT_RESET 0xF8000000 | ||
196 | +#define XDMA_MEM_SIZE 0x1000 | ||
197 | + | 57 | + |
198 | +#define TO_REG(addr) ((addr) / sizeof(uint32_t)) | 58 | + qpci_memread(dev, bar, 0, &val, sizeof(val)); |
59 | + g_assert_cmpuint(val, ==, 3); | ||
199 | + | 60 | + |
200 | +static uint64_t aspeed_xdma_read(void *opaque, hwaddr addr, unsigned int size) | 61 | + val = 1; |
201 | +{ | 62 | + qpci_memwrite(dev, bar, 0, &val, sizeof(val)); |
202 | + uint32_t val = 0; | ||
203 | + AspeedXDMAState *xdma = opaque; | ||
204 | + | 63 | + |
205 | + if (addr < ASPEED_XDMA_REG_SIZE) { | 64 | + response = qtest_qmp_eventwait_ref(qts, "GUEST_PANICKED"); |
206 | + val = xdma->regs[TO_REG(addr)]; | 65 | + g_assert(qdict_haskey(response, "data")); |
207 | + } | 66 | + data = qdict_get_qdict(response, "data"); |
67 | + g_assert(qdict_haskey(data, "action")); | ||
68 | + g_assert_cmpstr(qdict_get_str(data, "action"), ==, "run"); | ||
69 | + qobject_unref(response); | ||
208 | + | 70 | + |
209 | + return (uint64_t)val; | 71 | + qtest_quit(qts); |
210 | +} | 72 | +} |
211 | + | 73 | + |
212 | +static void aspeed_xdma_write(void *opaque, hwaddr addr, uint64_t val, | 74 | +static void test_panic(void) |
213 | + unsigned int size) | ||
214 | +{ | 75 | +{ |
215 | + unsigned int idx; | 76 | + uint8_t val; |
216 | + uint32_t val32 = (uint32_t)val; | 77 | + QDict *response, *data; |
217 | + AspeedXDMAState *xdma = opaque; | 78 | + QTestState *qts; |
79 | + QPCIBus *pcibus; | ||
80 | + QPCIDevice *dev; | ||
81 | + QPCIBar bar; | ||
218 | + | 82 | + |
219 | + if (addr >= ASPEED_XDMA_REG_SIZE) { | 83 | + qts = qtest_init("-device pvpanic-pci,addr=04.0 -action panic=pause"); |
220 | + return; | 84 | + pcibus = qpci_new_pc(qts, NULL); |
221 | + } | 85 | + dev = qpci_device_find(pcibus, QPCI_DEVFN(0x4, 0x0)); |
86 | + qpci_device_enable(dev); | ||
87 | + bar = qpci_iomap(dev, 0, NULL); | ||
222 | + | 88 | + |
223 | + switch (addr) { | 89 | + qpci_memread(dev, bar, 0, &val, sizeof(val)); |
224 | + case XDMA_BMC_CMDQ_ENDP: | 90 | + g_assert_cmpuint(val, ==, 3); |
225 | + xdma->regs[TO_REG(addr)] = val32 & XDMA_BMC_CMDQ_W_MASK; | ||
226 | + break; | ||
227 | + case XDMA_BMC_CMDQ_WRP: | ||
228 | + idx = TO_REG(addr); | ||
229 | + xdma->regs[idx] = val32 & XDMA_BMC_CMDQ_W_MASK; | ||
230 | + xdma->regs[TO_REG(XDMA_BMC_CMDQ_RDP)] = xdma->regs[idx]; | ||
231 | + | 91 | + |
232 | + trace_aspeed_xdma_write(addr, val); | 92 | + val = 1; |
93 | + qpci_memwrite(dev, bar, 0, &val, sizeof(val)); | ||
233 | + | 94 | + |
234 | + if (xdma->bmc_cmdq_readp_set) { | 95 | + response = qtest_qmp_eventwait_ref(qts, "GUEST_PANICKED"); |
235 | + xdma->bmc_cmdq_readp_set = 0; | 96 | + g_assert(qdict_haskey(response, "data")); |
236 | + } else { | 97 | + data = qdict_get_qdict(response, "data"); |
237 | + xdma->regs[TO_REG(XDMA_IRQ_ENG_STAT)] |= | 98 | + g_assert(qdict_haskey(data, "action")); |
238 | + XDMA_IRQ_ENG_STAT_US_COMP | XDMA_IRQ_ENG_STAT_DS_COMP; | 99 | + g_assert_cmpstr(qdict_get_str(data, "action"), ==, "pause"); |
100 | + qobject_unref(response); | ||
239 | + | 101 | + |
240 | + if (xdma->regs[TO_REG(XDMA_IRQ_ENG_CTRL)] & | 102 | + qtest_quit(qts); |
241 | + (XDMA_IRQ_ENG_CTRL_US_COMP | XDMA_IRQ_ENG_CTRL_DS_COMP)) | ||
242 | + qemu_irq_raise(xdma->irq); | ||
243 | + } | ||
244 | + break; | ||
245 | + case XDMA_BMC_CMDQ_RDP: | ||
246 | + trace_aspeed_xdma_write(addr, val); | ||
247 | + | ||
248 | + if (val32 == XDMA_BMC_CMDQ_RDP_MAGIC) { | ||
249 | + xdma->bmc_cmdq_readp_set = 1; | ||
250 | + } | ||
251 | + break; | ||
252 | + case XDMA_IRQ_ENG_CTRL: | ||
253 | + xdma->regs[TO_REG(addr)] = val32 & XDMA_IRQ_ENG_CTRL_W_MASK; | ||
254 | + break; | ||
255 | + case XDMA_IRQ_ENG_STAT: | ||
256 | + trace_aspeed_xdma_write(addr, val); | ||
257 | + | ||
258 | + idx = TO_REG(addr); | ||
259 | + if (val32 & (XDMA_IRQ_ENG_STAT_US_COMP | XDMA_IRQ_ENG_STAT_DS_COMP)) { | ||
260 | + xdma->regs[idx] &= | ||
261 | + ~(XDMA_IRQ_ENG_STAT_US_COMP | XDMA_IRQ_ENG_STAT_DS_COMP); | ||
262 | + qemu_irq_lower(xdma->irq); | ||
263 | + } | ||
264 | + break; | ||
265 | + default: | ||
266 | + xdma->regs[TO_REG(addr)] = val32; | ||
267 | + break; | ||
268 | + } | ||
269 | +} | 103 | +} |
270 | + | 104 | + |
271 | +static const MemoryRegionOps aspeed_xdma_ops = { | 105 | +int main(int argc, char **argv) |
272 | + .read = aspeed_xdma_read, | 106 | +{ |
273 | + .write = aspeed_xdma_write, | 107 | + int ret; |
274 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
275 | + .valid.min_access_size = 4, | ||
276 | + .valid.max_access_size = 4, | ||
277 | +}; | ||
278 | + | 108 | + |
279 | +static void aspeed_xdma_realize(DeviceState *dev, Error **errp) | 109 | + g_test_init(&argc, &argv, NULL); |
280 | +{ | 110 | + qtest_add_func("/pvpanic-pci/panic", test_panic); |
281 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | 111 | + qtest_add_func("/pvpanic-pci/panic-nopause", test_panic_nopause); |
282 | + AspeedXDMAState *xdma = ASPEED_XDMA(dev); | ||
283 | + | 112 | + |
284 | + sysbus_init_irq(sbd, &xdma->irq); | 113 | + ret = g_test_run(); |
285 | + memory_region_init_io(&xdma->iomem, OBJECT(xdma), &aspeed_xdma_ops, xdma, | 114 | + |
286 | + TYPE_ASPEED_XDMA, XDMA_MEM_SIZE); | 115 | + return ret; |
287 | + sysbus_init_mmio(sbd, &xdma->iomem); | ||
288 | +} | 116 | +} |
289 | + | 117 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build |
290 | +static void aspeed_xdma_reset(DeviceState *dev) | ||
291 | +{ | ||
292 | + AspeedXDMAState *xdma = ASPEED_XDMA(dev); | ||
293 | + | ||
294 | + xdma->bmc_cmdq_readp_set = 0; | ||
295 | + memset(xdma->regs, 0, ASPEED_XDMA_REG_SIZE); | ||
296 | + xdma->regs[TO_REG(XDMA_IRQ_ENG_STAT)] = XDMA_IRQ_ENG_STAT_RESET; | ||
297 | + | ||
298 | + qemu_irq_lower(xdma->irq); | ||
299 | +} | ||
300 | + | ||
301 | +static const VMStateDescription aspeed_xdma_vmstate = { | ||
302 | + .name = TYPE_ASPEED_XDMA, | ||
303 | + .version_id = 1, | ||
304 | + .fields = (VMStateField[]) { | ||
305 | + VMSTATE_UINT32_ARRAY(regs, AspeedXDMAState, ASPEED_XDMA_NUM_REGS), | ||
306 | + VMSTATE_END_OF_LIST(), | ||
307 | + }, | ||
308 | +}; | ||
309 | + | ||
310 | +static void aspeed_xdma_class_init(ObjectClass *classp, void *data) | ||
311 | +{ | ||
312 | + DeviceClass *dc = DEVICE_CLASS(classp); | ||
313 | + | ||
314 | + dc->realize = aspeed_xdma_realize; | ||
315 | + dc->reset = aspeed_xdma_reset; | ||
316 | + dc->vmsd = &aspeed_xdma_vmstate; | ||
317 | +} | ||
318 | + | ||
319 | +static const TypeInfo aspeed_xdma_info = { | ||
320 | + .name = TYPE_ASPEED_XDMA, | ||
321 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
322 | + .instance_size = sizeof(AspeedXDMAState), | ||
323 | + .class_init = aspeed_xdma_class_init, | ||
324 | +}; | ||
325 | + | ||
326 | +static void aspeed_xdma_register_type(void) | ||
327 | +{ | ||
328 | + type_register_static(&aspeed_xdma_info); | ||
329 | +} | ||
330 | +type_init(aspeed_xdma_register_type); | ||
331 | diff --git a/hw/misc/trace-events b/hw/misc/trace-events | ||
332 | index XXXXXXX..XXXXXXX 100644 | 118 | index XXXXXXX..XXXXXXX 100644 |
333 | --- a/hw/misc/trace-events | 119 | --- a/tests/qtest/meson.build |
334 | +++ b/hw/misc/trace-events | 120 | +++ b/tests/qtest/meson.build |
335 | @@ -XXX,XX +XXX,XX @@ armsse_cpuid_write(uint64_t offset, uint64_t data, unsigned size) "SSE-200 CPU_I | 121 | @@ -XXX,XX +XXX,XX @@ qtests_i386 = \ |
336 | # armsse-mhu.c | 122 | config_all_devices.has_key('CONFIG_ISA_IPMI_BT') ? ['ipmi-bt-test'] : []) + \ |
337 | armsse_mhu_read(uint64_t offset, uint64_t data, unsigned size) "SSE-200 MHU read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" | 123 | (config_all_devices.has_key('CONFIG_WDT_IB700') ? ['wdt_ib700-test'] : []) + \ |
338 | armsse_mhu_write(uint64_t offset, uint64_t data, unsigned size) "SSE-200 MHU write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" | 124 | (config_all_devices.has_key('CONFIG_PVPANIC_ISA') ? ['pvpanic-test'] : []) + \ |
339 | + | 125 | + (config_all_devices.has_key('CONFIG_PVPANIC_PCI') ? ['pvpanic-pci-test'] : []) + \ |
340 | +# aspeed_xdma.c | 126 | (config_all_devices.has_key('CONFIG_HDA') ? ['intel-hda-test'] : []) + \ |
341 | +aspeed_xdma_write(uint64_t offset, uint64_t data) "XDMA write: offset 0x%" PRIx64 " data 0x%" PRIx64 | 127 | (config_all_devices.has_key('CONFIG_I82801B11') ? ['i82801b11-test'] : []) + \ |
128 | (config_all_devices.has_key('CONFIG_IOH3420') ? ['ioh3420-test'] : []) + \ | ||
342 | -- | 129 | -- |
343 | 2.20.1 | 130 | 2.20.1 |
344 | 131 | ||
345 | 132 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | The ptimer API currently provides two methods for setting the period: |
---|---|---|---|
2 | ptimer_set_period(), which takes a period in nanoseconds, and | ||
3 | ptimer_set_freq(), which takes a frequency in Hz. Neither of these | ||
4 | lines up nicely with the Clock API, because although both the Clock | ||
5 | and the ptimer track the frequency using a representation of whole | ||
6 | and fractional nanoseconds, conversion via either period-in-ns or | ||
7 | frequency-in-Hz will introduce a rounding error. | ||
2 | 8 | ||
3 | In few commits we will split the M-profile functions from this | 9 | Add a new function ptimer_set_period_from_clock() which takes the |
4 | file, and this function will also be called in the new file. | 10 | Clock object directly to avoid the rounding issues. This includes a |
5 | Declare it in the "internals.h" header. | 11 | facility for the user to specify that there is a frequency divider |
6 | Since it is in the middle of a block of M profile functions, | 12 | between the Clock proper and the timer, as some timer devices like |
7 | move it previous to this block to ease the later refactor. | 13 | the CMSDK APB dualtimer need this. |
8 | 14 | ||
9 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 15 | To avoid having to drag in clock.h from ptimer.h we add the Clock |
10 | Message-id: 20190701132516.26392-21-philmd@redhat.com | 16 | type to typedefs.h. |
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 17 | |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
20 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
21 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
22 | Message-id: 20210128114145.20536-2-peter.maydell@linaro.org | ||
23 | Message-id: 20210121190622.22000-2-peter.maydell@linaro.org | ||
13 | --- | 24 | --- |
14 | target/arm/internals.h | 2 ++ | 25 | include/hw/ptimer.h | 22 ++++++++++++++++++++++ |
15 | target/arm/helper.c | 76 +++++++++++++++++++++--------------------- | 26 | include/qemu/typedefs.h | 1 + |
16 | 2 files changed, 40 insertions(+), 38 deletions(-) | 27 | hw/core/ptimer.c | 34 ++++++++++++++++++++++++++++++++++ |
28 | 3 files changed, 57 insertions(+) | ||
17 | 29 | ||
18 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 30 | diff --git a/include/hw/ptimer.h b/include/hw/ptimer.h |
19 | index XXXXXXX..XXXXXXX 100644 | 31 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/internals.h | 32 | --- a/include/hw/ptimer.h |
21 | +++ b/target/arm/internals.h | 33 | +++ b/include/hw/ptimer.h |
22 | @@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address, | 34 | @@ -XXX,XX +XXX,XX @@ void ptimer_transaction_commit(ptimer_state *s); |
23 | target_ulong *page_size, | 35 | */ |
24 | ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs); | 36 | void ptimer_set_period(ptimer_state *s, int64_t period); |
25 | 37 | ||
26 | +void arm_log_exception(int idx); | 38 | +/** |
39 | + * ptimer_set_period_from_clock - Set counter increment from a Clock | ||
40 | + * @s: ptimer to configure | ||
41 | + * @clk: pointer to Clock object to take period from | ||
42 | + * @divisor: value to scale the clock frequency down by | ||
43 | + * | ||
44 | + * If the ptimer is being driven from a Clock, this is the preferred | ||
45 | + * way to tell the ptimer about the period, because it avoids any | ||
46 | + * possible rounding errors that might happen if the internal | ||
47 | + * representation of the Clock period was converted to either a period | ||
48 | + * in ns or a frequency in Hz. | ||
49 | + * | ||
50 | + * If the ptimer should run at the same frequency as the clock, | ||
51 | + * pass 1 as the @divisor; if the ptimer should run at half the | ||
52 | + * frequency, pass 2, and so on. | ||
53 | + * | ||
54 | + * This function will assert if it is called outside a | ||
55 | + * ptimer_transaction_begin/commit block. | ||
56 | + */ | ||
57 | +void ptimer_set_period_from_clock(ptimer_state *s, const Clock *clock, | ||
58 | + unsigned int divisor); | ||
27 | + | 59 | + |
28 | #endif /* !CONFIG_USER_ONLY */ | 60 | /** |
29 | 61 | * ptimer_set_freq - Set counter frequency in Hz | |
30 | #endif | 62 | * @s: ptimer to configure |
31 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 63 | diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h |
32 | index XXXXXXX..XXXXXXX 100644 | 64 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/target/arm/helper.c | 65 | --- a/include/qemu/typedefs.h |
34 | +++ b/target/arm/helper.c | 66 | +++ b/include/qemu/typedefs.h |
35 | @@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx, | 67 | @@ -XXX,XX +XXX,XX @@ typedef struct BlockDriverState BlockDriverState; |
36 | return target_el; | 68 | typedef struct BusClass BusClass; |
69 | typedef struct BusState BusState; | ||
70 | typedef struct Chardev Chardev; | ||
71 | +typedef struct Clock Clock; | ||
72 | typedef struct CompatProperty CompatProperty; | ||
73 | typedef struct CoMutex CoMutex; | ||
74 | typedef struct CPUAddressSpace CPUAddressSpace; | ||
75 | diff --git a/hw/core/ptimer.c b/hw/core/ptimer.c | ||
76 | index XXXXXXX..XXXXXXX 100644 | ||
77 | --- a/hw/core/ptimer.c | ||
78 | +++ b/hw/core/ptimer.c | ||
79 | @@ -XXX,XX +XXX,XX @@ | ||
80 | #include "sysemu/qtest.h" | ||
81 | #include "block/aio.h" | ||
82 | #include "sysemu/cpus.h" | ||
83 | +#include "hw/clock.h" | ||
84 | |||
85 | #define DELTA_ADJUST 1 | ||
86 | #define DELTA_NO_ADJUST -1 | ||
87 | @@ -XXX,XX +XXX,XX @@ void ptimer_set_period(ptimer_state *s, int64_t period) | ||
88 | } | ||
37 | } | 89 | } |
38 | 90 | ||
39 | +void arm_log_exception(int idx) | 91 | +/* Set counter increment interval from a Clock */ |
92 | +void ptimer_set_period_from_clock(ptimer_state *s, const Clock *clk, | ||
93 | + unsigned int divisor) | ||
40 | +{ | 94 | +{ |
41 | + if (qemu_loglevel_mask(CPU_LOG_INT)) { | 95 | + /* |
42 | + const char *exc = NULL; | 96 | + * The raw clock period is a 64-bit value in units of 2^-32 ns; |
43 | + static const char * const excnames[] = { | 97 | + * put another way it's a 32.32 fixed-point ns value. Our internal |
44 | + [EXCP_UDEF] = "Undefined Instruction", | 98 | + * representation of the period is 64.32 fixed point ns, so |
45 | + [EXCP_SWI] = "SVC", | 99 | + * the conversion is simple. |
46 | + [EXCP_PREFETCH_ABORT] = "Prefetch Abort", | 100 | + */ |
47 | + [EXCP_DATA_ABORT] = "Data Abort", | 101 | + uint64_t raw_period = clock_get(clk); |
48 | + [EXCP_IRQ] = "IRQ", | 102 | + uint64_t period_frac; |
49 | + [EXCP_FIQ] = "FIQ", | ||
50 | + [EXCP_BKPT] = "Breakpoint", | ||
51 | + [EXCP_EXCEPTION_EXIT] = "QEMU v7M exception exit", | ||
52 | + [EXCP_KERNEL_TRAP] = "QEMU intercept of kernel commpage", | ||
53 | + [EXCP_HVC] = "Hypervisor Call", | ||
54 | + [EXCP_HYP_TRAP] = "Hypervisor Trap", | ||
55 | + [EXCP_SMC] = "Secure Monitor Call", | ||
56 | + [EXCP_VIRQ] = "Virtual IRQ", | ||
57 | + [EXCP_VFIQ] = "Virtual FIQ", | ||
58 | + [EXCP_SEMIHOST] = "Semihosting call", | ||
59 | + [EXCP_NOCP] = "v7M NOCP UsageFault", | ||
60 | + [EXCP_INVSTATE] = "v7M INVSTATE UsageFault", | ||
61 | + [EXCP_STKOF] = "v8M STKOF UsageFault", | ||
62 | + [EXCP_LAZYFP] = "v7M exception during lazy FP stacking", | ||
63 | + [EXCP_LSERR] = "v8M LSERR UsageFault", | ||
64 | + [EXCP_UNALIGNED] = "v7M UNALIGNED UsageFault", | ||
65 | + }; | ||
66 | + | 103 | + |
67 | + if (idx >= 0 && idx < ARRAY_SIZE(excnames)) { | 104 | + assert(s->in_transaction); |
68 | + exc = excnames[idx]; | 105 | + s->delta = ptimer_get_count(s); |
69 | + } | 106 | + s->period = extract64(raw_period, 32, 32); |
70 | + if (!exc) { | 107 | + period_frac = extract64(raw_period, 0, 32); |
71 | + exc = "unknown"; | 108 | + /* |
72 | + } | 109 | + * divisor specifies a possible frequency divisor between the |
73 | + qemu_log_mask(CPU_LOG_INT, "Taking exception %d [%s]\n", idx, exc); | 110 | + * clock and the timer, so it is a multiplier on the period. |
111 | + * We do the multiply after splitting the raw period out into | ||
112 | + * period and frac to avoid having to do a 32*64->96 multiply. | ||
113 | + */ | ||
114 | + s->period *= divisor; | ||
115 | + period_frac *= divisor; | ||
116 | + s->period += extract64(period_frac, 32, 32); | ||
117 | + s->period_frac = (uint32_t)period_frac; | ||
118 | + | ||
119 | + if (s->enabled) { | ||
120 | + s->need_reload = true; | ||
74 | + } | 121 | + } |
75 | +} | 122 | +} |
76 | + | 123 | + |
77 | /* | 124 | /* Set counter frequency in Hz. */ |
78 | * Return true if the v7M CPACR permits access to the FPU for the specified | 125 | void ptimer_set_freq(ptimer_state *s, uint32_t freq) |
79 | * security state and privilege level. | ||
80 | @@ -XXX,XX +XXX,XX @@ static bool do_v7m_function_return(ARMCPU *cpu) | ||
81 | return true; | ||
82 | } | ||
83 | |||
84 | -static void arm_log_exception(int idx) | ||
85 | -{ | ||
86 | - if (qemu_loglevel_mask(CPU_LOG_INT)) { | ||
87 | - const char *exc = NULL; | ||
88 | - static const char * const excnames[] = { | ||
89 | - [EXCP_UDEF] = "Undefined Instruction", | ||
90 | - [EXCP_SWI] = "SVC", | ||
91 | - [EXCP_PREFETCH_ABORT] = "Prefetch Abort", | ||
92 | - [EXCP_DATA_ABORT] = "Data Abort", | ||
93 | - [EXCP_IRQ] = "IRQ", | ||
94 | - [EXCP_FIQ] = "FIQ", | ||
95 | - [EXCP_BKPT] = "Breakpoint", | ||
96 | - [EXCP_EXCEPTION_EXIT] = "QEMU v7M exception exit", | ||
97 | - [EXCP_KERNEL_TRAP] = "QEMU intercept of kernel commpage", | ||
98 | - [EXCP_HVC] = "Hypervisor Call", | ||
99 | - [EXCP_HYP_TRAP] = "Hypervisor Trap", | ||
100 | - [EXCP_SMC] = "Secure Monitor Call", | ||
101 | - [EXCP_VIRQ] = "Virtual IRQ", | ||
102 | - [EXCP_VFIQ] = "Virtual FIQ", | ||
103 | - [EXCP_SEMIHOST] = "Semihosting call", | ||
104 | - [EXCP_NOCP] = "v7M NOCP UsageFault", | ||
105 | - [EXCP_INVSTATE] = "v7M INVSTATE UsageFault", | ||
106 | - [EXCP_STKOF] = "v8M STKOF UsageFault", | ||
107 | - [EXCP_LAZYFP] = "v7M exception during lazy FP stacking", | ||
108 | - [EXCP_LSERR] = "v8M LSERR UsageFault", | ||
109 | - [EXCP_UNALIGNED] = "v7M UNALIGNED UsageFault", | ||
110 | - }; | ||
111 | - | ||
112 | - if (idx >= 0 && idx < ARRAY_SIZE(excnames)) { | ||
113 | - exc = excnames[idx]; | ||
114 | - } | ||
115 | - if (!exc) { | ||
116 | - exc = "unknown"; | ||
117 | - } | ||
118 | - qemu_log_mask(CPU_LOG_INT, "Taking exception %d [%s]\n", idx, exc); | ||
119 | - } | ||
120 | -} | ||
121 | - | ||
122 | static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx, | ||
123 | uint32_t addr, uint16_t *insn) | ||
124 | { | 126 | { |
125 | -- | 127 | -- |
126 | 2.20.1 | 128 | 2.20.1 |
127 | 129 | ||
128 | 130 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | Add a function for checking whether a clock has a source. This is |
---|---|---|---|
2 | useful for devices which have input clocks that must be wired up by | ||
3 | the board as it allows them to fail in realize rather than ploughing | ||
4 | on with a zero-period clock. | ||
2 | 5 | ||
3 | In the next commit we will split the M-profile functions from this | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | file. Some function will be called out of helper.c. Declare them in | 7 | Reviewed-by: Luc Michel <luc@lmichel.fr> |
5 | the "internals.h" header. | 8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
9 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
10 | Message-id: 20210128114145.20536-3-peter.maydell@linaro.org | ||
11 | Message-id: 20210121190622.22000-3-peter.maydell@linaro.org | ||
12 | --- | ||
13 | docs/devel/clocks.rst | 16 ++++++++++++++++ | ||
14 | include/hw/clock.h | 15 +++++++++++++++ | ||
15 | 2 files changed, 31 insertions(+) | ||
6 | 16 | ||
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 17 | diff --git a/docs/devel/clocks.rst b/docs/devel/clocks.rst |
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 20190701132516.26392-22-philmd@redhat.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/internals.h | 42 ++++++++++++++++++++++++++++++++++++++++++ | ||
13 | target/arm/helper.c | 38 ++------------------------------------ | ||
14 | 2 files changed, 44 insertions(+), 36 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/internals.h | 19 | --- a/docs/devel/clocks.rst |
19 | +++ b/target/arm/internals.h | 20 | +++ b/docs/devel/clocks.rst |
20 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t v7m_sp_limit(CPUARMState *env) | 21 | @@ -XXX,XX +XXX,XX @@ object during device instance init. For example: |
21 | } | 22 | /* set initial value to 10ns / 100MHz */ |
22 | } | 23 | clock_set_ns(clk, 10); |
24 | |||
25 | +To enforce that the clock is wired up by the board code, you can | ||
26 | +call ``clock_has_source()`` in your device's realize method: | ||
27 | + | ||
28 | +.. code-block:: c | ||
29 | + | ||
30 | + if (!clock_has_source(s->clk)) { | ||
31 | + error_setg(errp, "MyDevice: clk input must be connected"); | ||
32 | + return; | ||
33 | + } | ||
34 | + | ||
35 | +Note that this only checks that the clock has been wired up; it is | ||
36 | +still possible that the output clock connected to it is disabled | ||
37 | +or has not yet been configured, in which case the period will be | ||
38 | +zero. You should use the clock callback to find out when the clock | ||
39 | +period changes. | ||
40 | + | ||
41 | Fetching clock frequency/period | ||
42 | ------------------------------- | ||
43 | |||
44 | diff --git a/include/hw/clock.h b/include/hw/clock.h | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/include/hw/clock.h | ||
47 | +++ b/include/hw/clock.h | ||
48 | @@ -XXX,XX +XXX,XX @@ void clock_clear_callback(Clock *clk); | ||
49 | */ | ||
50 | void clock_set_source(Clock *clk, Clock *src); | ||
23 | 51 | ||
24 | +/** | 52 | +/** |
25 | + * v7m_cpacr_pass: | 53 | + * clock_has_source: |
26 | + * Return true if the v7M CPACR permits access to the FPU for the specified | 54 | + * @clk: the clock |
27 | + * security state and privilege level. | 55 | + * |
56 | + * Returns true if the clock has a source clock connected to it. | ||
57 | + * This is useful for devices which have input clocks which must | ||
58 | + * be connected by the board/SoC code which creates them. The | ||
59 | + * device code can use this to check in its realize method that | ||
60 | + * the clock has been connected. | ||
28 | + */ | 61 | + */ |
29 | +static inline bool v7m_cpacr_pass(CPUARMState *env, | 62 | +static inline bool clock_has_source(const Clock *clk) |
30 | + bool is_secure, bool is_priv) | ||
31 | +{ | 63 | +{ |
32 | + switch (extract32(env->v7m.cpacr[is_secure], 20, 2)) { | 64 | + return clk->source != NULL; |
33 | + case 0: | ||
34 | + case 2: /* UNPREDICTABLE: we treat like 0 */ | ||
35 | + return false; | ||
36 | + case 1: | ||
37 | + return is_priv; | ||
38 | + case 3: | ||
39 | + return true; | ||
40 | + default: | ||
41 | + g_assert_not_reached(); | ||
42 | + } | ||
43 | +} | 65 | +} |
44 | + | 66 | + |
45 | /** | 67 | /** |
46 | * aarch32_mode_name(): Return name of the AArch32 CPU mode | 68 | * clock_set: |
47 | * @psr: Program Status Register indicating CPU mode | 69 | * @clk: the clock to initialize. |
48 | @@ -XXX,XX +XXX,XX @@ static inline int exception_target_el(CPUARMState *env) | ||
49 | |||
50 | #ifndef CONFIG_USER_ONLY | ||
51 | |||
52 | +/* Security attributes for an address, as returned by v8m_security_lookup. */ | ||
53 | +typedef struct V8M_SAttributes { | ||
54 | + bool subpage; /* true if these attrs don't cover the whole TARGET_PAGE */ | ||
55 | + bool ns; | ||
56 | + bool nsc; | ||
57 | + uint8_t sregion; | ||
58 | + bool srvalid; | ||
59 | + uint8_t iregion; | ||
60 | + bool irvalid; | ||
61 | +} V8M_SAttributes; | ||
62 | + | ||
63 | +void v8m_security_lookup(CPUARMState *env, uint32_t address, | ||
64 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
65 | + V8M_SAttributes *sattrs); | ||
66 | + | ||
67 | +bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
68 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
69 | + hwaddr *phys_ptr, MemTxAttrs *txattrs, | ||
70 | + int *prot, bool *is_subpage, | ||
71 | + ARMMMUFaultInfo *fi, uint32_t *mregion); | ||
72 | + | ||
73 | /* Cacheability and shareability attributes for a memory access */ | ||
74 | typedef struct ARMCacheAttrs { | ||
75 | unsigned int attrs:8; /* as in the MAIR register encoding */ | ||
76 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/target/arm/helper.c | ||
79 | +++ b/target/arm/helper.c | ||
80 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, | ||
81 | hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot, | ||
82 | target_ulong *page_size_ptr, | ||
83 | ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs); | ||
84 | - | ||
85 | -/* Security attributes for an address, as returned by v8m_security_lookup. */ | ||
86 | -typedef struct V8M_SAttributes { | ||
87 | - bool subpage; /* true if these attrs don't cover the whole TARGET_PAGE */ | ||
88 | - bool ns; | ||
89 | - bool nsc; | ||
90 | - uint8_t sregion; | ||
91 | - bool srvalid; | ||
92 | - uint8_t iregion; | ||
93 | - bool irvalid; | ||
94 | -} V8M_SAttributes; | ||
95 | - | ||
96 | -static void v8m_security_lookup(CPUARMState *env, uint32_t address, | ||
97 | - MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
98 | - V8M_SAttributes *sattrs); | ||
99 | #endif | ||
100 | |||
101 | static void switch_mode(CPUARMState *env, int mode); | ||
102 | @@ -XXX,XX +XXX,XX @@ void arm_log_exception(int idx) | ||
103 | } | ||
104 | } | ||
105 | |||
106 | -/* | ||
107 | - * Return true if the v7M CPACR permits access to the FPU for the specified | ||
108 | - * security state and privilege level. | ||
109 | - */ | ||
110 | -static bool v7m_cpacr_pass(CPUARMState *env, bool is_secure, bool is_priv) | ||
111 | -{ | ||
112 | - switch (extract32(env->v7m.cpacr[is_secure], 20, 2)) { | ||
113 | - case 0: | ||
114 | - case 2: /* UNPREDICTABLE: we treat like 0 */ | ||
115 | - return false; | ||
116 | - case 1: | ||
117 | - return is_priv; | ||
118 | - case 3: | ||
119 | - return true; | ||
120 | - default: | ||
121 | - g_assert_not_reached(); | ||
122 | - } | ||
123 | -} | ||
124 | - | ||
125 | /* | ||
126 | * What kind of stack write are we doing? This affects how exceptions | ||
127 | * generated during the stacking are treated. | ||
128 | @@ -XXX,XX +XXX,XX @@ static bool v8m_is_sau_exempt(CPUARMState *env, | ||
129 | (address >= 0xe00ff000 && address <= 0xe00fffff); | ||
130 | } | ||
131 | |||
132 | -static void v8m_security_lookup(CPUARMState *env, uint32_t address, | ||
133 | +void v8m_security_lookup(CPUARMState *env, uint32_t address, | ||
134 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
135 | V8M_SAttributes *sattrs) | ||
136 | { | ||
137 | @@ -XXX,XX +XXX,XX @@ static void v8m_security_lookup(CPUARMState *env, uint32_t address, | ||
138 | } | ||
139 | } | ||
140 | |||
141 | -static bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
142 | +bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, | ||
143 | MMUAccessType access_type, ARMMMUIdx mmu_idx, | ||
144 | hwaddr *phys_ptr, MemTxAttrs *txattrs, | ||
145 | int *prot, bool *is_subpage, | ||
146 | -- | 70 | -- |
147 | 2.20.1 | 71 | 2.20.1 |
148 | 72 | ||
149 | 73 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | Add a simple test of the CMSDK APB timer, since we're about to do |
---|---|---|---|
2 | some refactoring of how it is clocked. | ||
2 | 3 | ||
3 | Reviewed-by: Robert Bradford <robert.bradford@intel.com> | ||
4 | Reviewed-by: Samuel Ortiz <sameo@linux.intel.com> | ||
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Message-id: 20190701132516.26392-6-philmd@redhat.com | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
7 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Message-id: 20210128114145.20536-4-peter.maydell@linaro.org | ||
9 | Message-id: 20210121190622.22000-4-peter.maydell@linaro.org | ||
9 | --- | 10 | --- |
10 | target/arm/helper.c | 7 +++++++ | 11 | tests/qtest/cmsdk-apb-timer-test.c | 75 ++++++++++++++++++++++++++++++ |
11 | 1 file changed, 7 insertions(+) | 12 | MAINTAINERS | 1 + |
13 | tests/qtest/meson.build | 1 + | ||
14 | 3 files changed, 77 insertions(+) | ||
15 | create mode 100644 tests/qtest/cmsdk-apb-timer-test.c | ||
12 | 16 | ||
13 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 17 | diff --git a/tests/qtest/cmsdk-apb-timer-test.c b/tests/qtest/cmsdk-apb-timer-test.c |
14 | index XXXXXXX..XXXXXXX 100644 | 18 | new file mode 100644 |
15 | --- a/target/arm/helper.c | 19 | index XXXXXXX..XXXXXXX |
16 | +++ b/target/arm/helper.c | 20 | --- /dev/null |
21 | +++ b/tests/qtest/cmsdk-apb-timer-test.c | ||
17 | @@ -XXX,XX +XXX,XX @@ | 22 | @@ -XXX,XX +XXX,XX @@ |
18 | +/* | 23 | +/* |
19 | + * ARM generic helpers. | 24 | + * QTest testcase for the CMSDK APB timer device |
20 | + * | 25 | + * |
21 | + * This code is licensed under the GNU GPL v2 or later. | 26 | + * Copyright (c) 2021 Linaro Limited |
22 | + * | 27 | + * |
23 | + * SPDX-License-Identifier: GPL-2.0-or-later | 28 | + * This program is free software; you can redistribute it and/or modify it |
29 | + * under the terms of the GNU General Public License as published by the | ||
30 | + * Free Software Foundation; either version 2 of the License, or | ||
31 | + * (at your option) any later version. | ||
32 | + * | ||
33 | + * This program is distributed in the hope that it will be useful, but WITHOUT | ||
34 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
35 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
36 | + * for more details. | ||
24 | + */ | 37 | + */ |
25 | #include "qemu/osdep.h" | 38 | + |
26 | #include "qemu/units.h" | 39 | +#include "qemu/osdep.h" |
27 | #include "target/arm/idau.h" | 40 | +#include "libqtest-single.h" |
41 | + | ||
42 | +/* IoTKit/ARMSSE-200 timer0; driven at 25MHz in mps2-an385, so 40ns per tick */ | ||
43 | +#define TIMER_BASE 0x40000000 | ||
44 | + | ||
45 | +#define CTRL 0 | ||
46 | +#define VALUE 4 | ||
47 | +#define RELOAD 8 | ||
48 | +#define INTSTATUS 0xc | ||
49 | + | ||
50 | +static void test_timer(void) | ||
51 | +{ | ||
52 | + g_assert_true(readl(TIMER_BASE + INTSTATUS) == 0); | ||
53 | + | ||
54 | + /* Start timer: will fire after 40 * 1000 == 40000 ns */ | ||
55 | + writel(TIMER_BASE + RELOAD, 1000); | ||
56 | + writel(TIMER_BASE + CTRL, 9); | ||
57 | + | ||
58 | + /* Step to just past the 500th tick and check VALUE */ | ||
59 | + clock_step(40 * 500 + 1); | ||
60 | + g_assert_cmpuint(readl(TIMER_BASE + INTSTATUS), ==, 0); | ||
61 | + g_assert_cmpuint(readl(TIMER_BASE + VALUE), ==, 500); | ||
62 | + | ||
63 | + /* Just past the 1000th tick: timer should have fired */ | ||
64 | + clock_step(40 * 500); | ||
65 | + g_assert_cmpuint(readl(TIMER_BASE + INTSTATUS), ==, 1); | ||
66 | + g_assert_cmpuint(readl(TIMER_BASE + VALUE), ==, 0); | ||
67 | + | ||
68 | + /* VALUE reloads at the following tick */ | ||
69 | + clock_step(40); | ||
70 | + g_assert_cmpuint(readl(TIMER_BASE + VALUE), ==, 1000); | ||
71 | + | ||
72 | + /* Check write-1-to-clear behaviour of INTSTATUS */ | ||
73 | + writel(TIMER_BASE + INTSTATUS, 0); | ||
74 | + g_assert_cmpuint(readl(TIMER_BASE + INTSTATUS), ==, 1); | ||
75 | + writel(TIMER_BASE + INTSTATUS, 1); | ||
76 | + g_assert_cmpuint(readl(TIMER_BASE + INTSTATUS), ==, 0); | ||
77 | + | ||
78 | + /* Turn off the timer */ | ||
79 | + writel(TIMER_BASE + CTRL, 0); | ||
80 | +} | ||
81 | + | ||
82 | +int main(int argc, char **argv) | ||
83 | +{ | ||
84 | + int r; | ||
85 | + | ||
86 | + g_test_init(&argc, &argv, NULL); | ||
87 | + | ||
88 | + qtest_start("-machine mps2-an385"); | ||
89 | + | ||
90 | + qtest_add_func("/cmsdk-apb-timer/timer", test_timer); | ||
91 | + | ||
92 | + r = g_test_run(); | ||
93 | + | ||
94 | + qtest_end(); | ||
95 | + | ||
96 | + return r; | ||
97 | +} | ||
98 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
99 | index XXXXXXX..XXXXXXX 100644 | ||
100 | --- a/MAINTAINERS | ||
101 | +++ b/MAINTAINERS | ||
102 | @@ -XXX,XX +XXX,XX @@ F: include/hw/rtc/pl031.h | ||
103 | F: include/hw/arm/primecell.h | ||
104 | F: hw/timer/cmsdk-apb-timer.c | ||
105 | F: include/hw/timer/cmsdk-apb-timer.h | ||
106 | +F: tests/qtest/cmsdk-apb-timer-test.c | ||
107 | F: hw/timer/cmsdk-apb-dualtimer.c | ||
108 | F: include/hw/timer/cmsdk-apb-dualtimer.h | ||
109 | F: hw/char/cmsdk-apb-uart.c | ||
110 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build | ||
111 | index XXXXXXX..XXXXXXX 100644 | ||
112 | --- a/tests/qtest/meson.build | ||
113 | +++ b/tests/qtest/meson.build | ||
114 | @@ -XXX,XX +XXX,XX @@ qtests_npcm7xx = \ | ||
115 | 'npcm7xx_timer-test', | ||
116 | 'npcm7xx_watchdog_timer-test'] | ||
117 | qtests_arm = \ | ||
118 | + (config_all_devices.has_key('CONFIG_CMSDK_APB_TIMER') ? ['cmsdk-apb-timer-test'] : []) + \ | ||
119 | (config_all_devices.has_key('CONFIG_PFLASH_CFI02') ? ['pflash-cfi02-test'] : []) + \ | ||
120 | (config_all_devices.has_key('CONFIG_NPCM7XX') ? qtests_npcm7xx : []) + \ | ||
121 | ['arm-cpu-features', | ||
28 | -- | 122 | -- |
29 | 2.20.1 | 123 | 2.20.1 |
30 | 124 | ||
31 | 125 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | Add a simple test of the CMSDK watchdog, since we're about to do some |
---|---|---|---|
2 | refactoring of how it is clocked. | ||
2 | 3 | ||
3 | The vfp_set_fpscr() helper contains code specific to the host | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | floating point implementation (here the SoftFloat library). | 5 | Reviewed-by: Luc Michel <luc@lmichel.fr> |
5 | Extract this code to vfp_set_fpscr_from_host(). | 6 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Message-id: 20210128114145.20536-5-peter.maydell@linaro.org | ||
9 | Message-id: 20210121190622.22000-5-peter.maydell@linaro.org | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | --- | ||
12 | tests/qtest/cmsdk-apb-watchdog-test.c | 79 +++++++++++++++++++++++++++ | ||
13 | MAINTAINERS | 1 + | ||
14 | tests/qtest/meson.build | 1 + | ||
15 | 3 files changed, 81 insertions(+) | ||
16 | create mode 100644 tests/qtest/cmsdk-apb-watchdog-test.c | ||
6 | 17 | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 18 | diff --git a/tests/qtest/cmsdk-apb-watchdog-test.c b/tests/qtest/cmsdk-apb-watchdog-test.c |
8 | Message-id: 20190701132516.26392-17-philmd@redhat.com | 19 | new file mode 100644 |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 20 | index XXXXXXX..XXXXXXX |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 21 | --- /dev/null |
11 | --- | 22 | +++ b/tests/qtest/cmsdk-apb-watchdog-test.c |
12 | target/arm/vfp_helper.c | 19 +++++++++++++------ | 23 | @@ -XXX,XX +XXX,XX @@ |
13 | 1 file changed, 13 insertions(+), 6 deletions(-) | 24 | +/* |
14 | 25 | + * QTest testcase for the CMSDK APB watchdog device | |
15 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | 26 | + * |
16 | index XXXXXXX..XXXXXXX 100644 | 27 | + * Copyright (c) 2021 Linaro Limited |
17 | --- a/target/arm/vfp_helper.c | 28 | + * |
18 | +++ b/target/arm/vfp_helper.c | 29 | + * This program is free software; you can redistribute it and/or modify it |
19 | @@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_to_host(int target_bits) | 30 | + * under the terms of the GNU General Public License as published by the |
20 | return host_bits; | 31 | + * Free Software Foundation; either version 2 of the License, or |
21 | } | 32 | + * (at your option) any later version. |
22 | 33 | + * | |
23 | +static uint32_t vfp_get_fpscr_from_host(CPUARMState *env) | 34 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
35 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
36 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
37 | + * for more details. | ||
38 | + */ | ||
39 | + | ||
40 | +#include "qemu/osdep.h" | ||
41 | +#include "libqtest-single.h" | ||
42 | + | ||
43 | +/* | ||
44 | + * lm3s811evb watchdog; at board startup this runs at 200MHz / 16 == 12.5MHz, | ||
45 | + * which is 80ns per tick. | ||
46 | + */ | ||
47 | +#define WDOG_BASE 0x40000000 | ||
48 | + | ||
49 | +#define WDOGLOAD 0 | ||
50 | +#define WDOGVALUE 4 | ||
51 | +#define WDOGCONTROL 8 | ||
52 | +#define WDOGINTCLR 0xc | ||
53 | +#define WDOGRIS 0x10 | ||
54 | +#define WDOGMIS 0x14 | ||
55 | +#define WDOGLOCK 0xc00 | ||
56 | + | ||
57 | +static void test_watchdog(void) | ||
24 | +{ | 58 | +{ |
25 | + uint32_t i; | 59 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0); |
26 | + | 60 | + |
27 | + i = get_float_exception_flags(&env->vfp.fp_status); | 61 | + writel(WDOG_BASE + WDOGCONTROL, 1); |
28 | + i |= get_float_exception_flags(&env->vfp.standard_fp_status); | 62 | + writel(WDOG_BASE + WDOGLOAD, 1000); |
29 | + /* FZ16 does not generate an input denormal exception. */ | 63 | + |
30 | + i |= (get_float_exception_flags(&env->vfp.fp_status_f16) | 64 | + /* Step to just past the 500th tick */ |
31 | + & ~float_flag_input_denormal); | 65 | + clock_step(500 * 80 + 1); |
32 | + return vfp_exceptbits_from_host(i); | 66 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0); |
67 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 500); | ||
68 | + | ||
69 | + /* Just past the 1000th tick: timer should have fired */ | ||
70 | + clock_step(500 * 80); | ||
71 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 1); | ||
72 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 0); | ||
73 | + | ||
74 | + /* VALUE reloads at following tick */ | ||
75 | + clock_step(80); | ||
76 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 1000); | ||
77 | + | ||
78 | + /* Writing any value to WDOGINTCLR clears the interrupt and reloads */ | ||
79 | + clock_step(500 * 80); | ||
80 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 500); | ||
81 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 1); | ||
82 | + writel(WDOG_BASE + WDOGINTCLR, 0); | ||
83 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 1000); | ||
84 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0); | ||
33 | +} | 85 | +} |
34 | + | 86 | + |
35 | static void vfp_set_fpscr_to_host(CPUARMState *env, uint32_t val) | 87 | +int main(int argc, char **argv) |
36 | { | 88 | +{ |
37 | int i; | 89 | + int r; |
38 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env) | 90 | + |
39 | | (env->vfp.vec_len << 16) | 91 | + g_test_init(&argc, &argv, NULL); |
40 | | (env->vfp.vec_stride << 20); | 92 | + |
41 | 93 | + qtest_start("-machine lm3s811evb"); | |
42 | - i = get_float_exception_flags(&env->vfp.fp_status); | 94 | + |
43 | - i |= get_float_exception_flags(&env->vfp.standard_fp_status); | 95 | + qtest_add_func("/cmsdk-apb-watchdog/watchdog", test_watchdog); |
44 | - /* FZ16 does not generate an input denormal exception. */ | 96 | + |
45 | - i |= (get_float_exception_flags(&env->vfp.fp_status_f16) | 97 | + r = g_test_run(); |
46 | - & ~float_flag_input_denormal); | 98 | + |
47 | - fpscr |= vfp_exceptbits_from_host(i); | 99 | + qtest_end(); |
48 | + fpscr |= vfp_get_fpscr_from_host(env); | 100 | + |
49 | 101 | + return r; | |
50 | i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3]; | 102 | +} |
51 | fpscr |= i ? FPCR_QC : 0; | 103 | diff --git a/MAINTAINERS b/MAINTAINERS |
104 | index XXXXXXX..XXXXXXX 100644 | ||
105 | --- a/MAINTAINERS | ||
106 | +++ b/MAINTAINERS | ||
107 | @@ -XXX,XX +XXX,XX @@ F: hw/char/cmsdk-apb-uart.c | ||
108 | F: include/hw/char/cmsdk-apb-uart.h | ||
109 | F: hw/watchdog/cmsdk-apb-watchdog.c | ||
110 | F: include/hw/watchdog/cmsdk-apb-watchdog.h | ||
111 | +F: tests/qtest/cmsdk-apb-watchdog-test.c | ||
112 | F: hw/misc/tz-ppc.c | ||
113 | F: include/hw/misc/tz-ppc.h | ||
114 | F: hw/misc/tz-mpc.c | ||
115 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build | ||
116 | index XXXXXXX..XXXXXXX 100644 | ||
117 | --- a/tests/qtest/meson.build | ||
118 | +++ b/tests/qtest/meson.build | ||
119 | @@ -XXX,XX +XXX,XX @@ qtests_npcm7xx = \ | ||
120 | 'npcm7xx_watchdog_timer-test'] | ||
121 | qtests_arm = \ | ||
122 | (config_all_devices.has_key('CONFIG_CMSDK_APB_TIMER') ? ['cmsdk-apb-timer-test'] : []) + \ | ||
123 | + (config_all_devices.has_key('CONFIG_CMSDK_APB_WATCHDOG') ? ['cmsdk-apb-watchdog-test'] : []) + \ | ||
124 | (config_all_devices.has_key('CONFIG_PFLASH_CFI02') ? ['pflash-cfi02-test'] : []) + \ | ||
125 | (config_all_devices.has_key('CONFIG_NPCM7XX') ? qtests_npcm7xx : []) + \ | ||
126 | ['arm-cpu-features', | ||
52 | -- | 127 | -- |
53 | 2.20.1 | 128 | 2.20.1 |
54 | 129 | ||
55 | 130 | diff view generated by jsdifflib |
1 | From: Hongbo Zhang <hongbo.zhang@linaro.org> | 1 | Add a simple test of the CMSDK dual timer, since we're about to do |
---|---|---|---|
2 | some refactoring of how it is clocked. | ||
2 | 3 | ||
3 | For AArch64, the existing "virt" machine is primarily meant to | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | run on KVM and execute virtualization workloads, but we need an | 5 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
5 | environment as faithful as possible to physical hardware, for supporting | 6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
6 | firmware and OS development for physical Aarch64 machines. | 7 | Reviewed-by: Luc Michel <luc@lmichel.fr> |
8 | Message-id: 20210128114145.20536-6-peter.maydell@linaro.org | ||
9 | Message-id: 20210121190622.22000-6-peter.maydell@linaro.org | ||
10 | --- | ||
11 | tests/qtest/cmsdk-apb-dualtimer-test.c | 130 +++++++++++++++++++++++++ | ||
12 | MAINTAINERS | 1 + | ||
13 | tests/qtest/meson.build | 1 + | ||
14 | 3 files changed, 132 insertions(+) | ||
15 | create mode 100644 tests/qtest/cmsdk-apb-dualtimer-test.c | ||
7 | 16 | ||
8 | This patch introduces new machine type 'sbsa-ref' with main features: | 17 | diff --git a/tests/qtest/cmsdk-apb-dualtimer-test.c b/tests/qtest/cmsdk-apb-dualtimer-test.c |
9 | - Based on 'virt' machine type. | ||
10 | - A new memory map. | ||
11 | - CPU type cortex-a57. | ||
12 | - EL2 and EL3 are enabled. | ||
13 | - GIC version 3. | ||
14 | - System bus AHCI controller. | ||
15 | - System bus EHCI controller. | ||
16 | - CDROM and hard disc on AHCI bus. | ||
17 | - E1000E ethernet card on PCIE bus. | ||
18 | - VGA display adaptor on PCIE bus. | ||
19 | - No virtio devices. | ||
20 | - No fw_cfg device. | ||
21 | - No ACPI table supplied. | ||
22 | - Only minimal device tree nodes. | ||
23 | |||
24 | Arm Trusted Firmware and UEFI porting to this are done accordingly, | ||
25 | and the firmware should supply ACPI tables to the guest OS. The | ||
26 | minimal device tree nodes supplied by QEMU for this platform are only | ||
27 | to pass the dynamic info reflecting command line input to firmware, | ||
28 | not for loading the guest OS. | ||
29 | |||
30 | To make the review easier, this task is split into two patches, the | ||
31 | fundamental skeleton part and the peripheral devices part; this patch is | ||
32 | the first part. | ||
33 | |||
34 | Signed-off-by: Hongbo Zhang <hongbo.zhang@linaro.org> | ||
35 | Message-id: 1561890034-15921-2-git-send-email-hongbo.zhang@linaro.org | ||
36 | [PMM: commit message tweaks; moved some bits between patch 1 and 2 | ||
37 | to ensure patch 1 builds cleanly; removed unneeded lines from | ||
38 | Kconfig stanza; only provide board for qemu-system-aarch64, not | ||
39 | qemu-system-arm; added MAINTAINERS entry] | ||
40 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
41 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
42 | --- | ||
43 | hw/arm/Makefile.objs | 1 + | ||
44 | hw/arm/sbsa-ref.c | 271 ++++++++++++++++++++++++++++ | ||
45 | MAINTAINERS | 8 + | ||
46 | default-configs/aarch64-softmmu.mak | 1 + | ||
47 | hw/arm/Kconfig | 14 ++ | ||
48 | 5 files changed, 295 insertions(+) | ||
49 | create mode 100644 hw/arm/sbsa-ref.c | ||
50 | |||
51 | diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/hw/arm/Makefile.objs | ||
54 | +++ b/hw/arm/Makefile.objs | ||
55 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_SPITZ) += spitz.o | ||
56 | obj-$(CONFIG_TOSA) += tosa.o | ||
57 | obj-$(CONFIG_Z2) += z2.o | ||
58 | obj-$(CONFIG_REALVIEW) += realview.o | ||
59 | +obj-$(CONFIG_SBSA_REF) += sbsa-ref.o | ||
60 | obj-$(CONFIG_STELLARIS) += stellaris.o | ||
61 | obj-$(CONFIG_COLLIE) += collie.o | ||
62 | obj-$(CONFIG_VERSATILE) += versatilepb.o | ||
63 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c | ||
64 | new file mode 100644 | 18 | new file mode 100644 |
65 | index XXXXXXX..XXXXXXX | 19 | index XXXXXXX..XXXXXXX |
66 | --- /dev/null | 20 | --- /dev/null |
67 | +++ b/hw/arm/sbsa-ref.c | 21 | +++ b/tests/qtest/cmsdk-apb-dualtimer-test.c |
68 | @@ -XXX,XX +XXX,XX @@ | 22 | @@ -XXX,XX +XXX,XX @@ |
69 | +/* | 23 | +/* |
70 | + * ARM SBSA Reference Platform emulation | 24 | + * QTest testcase for the CMSDK APB dualtimer device |
71 | + * | 25 | + * |
72 | + * Copyright (c) 2018 Linaro Limited | 26 | + * Copyright (c) 2021 Linaro Limited |
73 | + * Written by Hongbo Zhang <hongbo.zhang@linaro.org> | ||
74 | + * | 27 | + * |
75 | + * This program is free software; you can redistribute it and/or modify it | 28 | + * This program is free software; you can redistribute it and/or modify it |
76 | + * under the terms and conditions of the GNU General Public License, | 29 | + * under the terms of the GNU General Public License as published by the |
77 | + * version 2 or later, as published by the Free Software Foundation. | 30 | + * Free Software Foundation; either version 2 of the License, or |
31 | + * (at your option) any later version. | ||
78 | + * | 32 | + * |
79 | + * This program is distributed in the hope it will be useful, but WITHOUT | 33 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
80 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | 34 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
81 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | 35 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
82 | + * more details. | 36 | + * for more details. |
83 | + * | ||
84 | + * You should have received a copy of the GNU General Public License along with | ||
85 | + * this program. If not, see <http://www.gnu.org/licenses/>. | ||
86 | + */ | 37 | + */ |
87 | + | 38 | + |
88 | +#include "qemu/osdep.h" | 39 | +#include "qemu/osdep.h" |
89 | +#include "qapi/error.h" | 40 | +#include "libqtest-single.h" |
90 | +#include "qemu/error-report.h" | ||
91 | +#include "qemu/units.h" | ||
92 | +#include "sysemu/numa.h" | ||
93 | +#include "sysemu/sysemu.h" | ||
94 | +#include "exec/address-spaces.h" | ||
95 | +#include "exec/hwaddr.h" | ||
96 | +#include "kvm_arm.h" | ||
97 | +#include "hw/arm/boot.h" | ||
98 | +#include "hw/boards.h" | ||
99 | +#include "hw/intc/arm_gicv3_common.h" | ||
100 | + | 41 | + |
101 | +#define RAMLIMIT_GB 8192 | 42 | +/* IoTKit/ARMSSE dualtimer; driven at 25MHz in mps2-an385, so 40ns per tick */ |
102 | +#define RAMLIMIT_BYTES (RAMLIMIT_GB * GiB) | 43 | +#define TIMER_BASE 0x40002000 |
103 | + | 44 | + |
104 | +enum { | 45 | +#define TIMER1LOAD 0 |
105 | + SBSA_FLASH, | 46 | +#define TIMER1VALUE 4 |
106 | + SBSA_MEM, | 47 | +#define TIMER1CONTROL 8 |
107 | + SBSA_CPUPERIPHS, | 48 | +#define TIMER1INTCLR 0xc |
108 | + SBSA_GIC_DIST, | 49 | +#define TIMER1RIS 0x10 |
109 | + SBSA_GIC_REDIST, | 50 | +#define TIMER1MIS 0x14 |
110 | + SBSA_SMMU, | 51 | +#define TIMER1BGLOAD 0x18 |
111 | + SBSA_UART, | ||
112 | + SBSA_RTC, | ||
113 | + SBSA_PCIE, | ||
114 | + SBSA_PCIE_MMIO, | ||
115 | + SBSA_PCIE_MMIO_HIGH, | ||
116 | + SBSA_PCIE_PIO, | ||
117 | + SBSA_PCIE_ECAM, | ||
118 | + SBSA_GPIO, | ||
119 | + SBSA_SECURE_UART, | ||
120 | + SBSA_SECURE_UART_MM, | ||
121 | + SBSA_SECURE_MEM, | ||
122 | + SBSA_AHCI, | ||
123 | + SBSA_EHCI, | ||
124 | +}; | ||
125 | + | 52 | + |
126 | +typedef struct MemMapEntry { | 53 | +#define TIMER2LOAD 0x20 |
127 | + hwaddr base; | 54 | +#define TIMER2VALUE 0x24 |
128 | + hwaddr size; | 55 | +#define TIMER2CONTROL 0x28 |
129 | +} MemMapEntry; | 56 | +#define TIMER2INTCLR 0x2c |
57 | +#define TIMER2RIS 0x30 | ||
58 | +#define TIMER2MIS 0x34 | ||
59 | +#define TIMER2BGLOAD 0x38 | ||
130 | + | 60 | + |
131 | +typedef struct { | 61 | +#define CTRL_ENABLE (1 << 7) |
132 | + MachineState parent; | 62 | +#define CTRL_PERIODIC (1 << 6) |
133 | + struct arm_boot_info bootinfo; | 63 | +#define CTRL_INTEN (1 << 5) |
134 | + int smp_cpus; | 64 | +#define CTRL_PRESCALE_1 (0 << 2) |
135 | + void *fdt; | 65 | +#define CTRL_PRESCALE_16 (1 << 2) |
136 | + int fdt_size; | 66 | +#define CTRL_PRESCALE_256 (2 << 2) |
137 | + int psci_conduit; | 67 | +#define CTRL_32BIT (1 << 1) |
138 | +} SBSAMachineState; | 68 | +#define CTRL_ONESHOT (1 << 0) |
139 | + | 69 | + |
140 | +#define TYPE_SBSA_MACHINE MACHINE_TYPE_NAME("sbsa-ref") | 70 | +static void test_dualtimer(void) |
141 | +#define SBSA_MACHINE(obj) \ | 71 | +{ |
142 | + OBJECT_CHECK(SBSAMachineState, (obj), TYPE_SBSA_MACHINE) | 72 | + g_assert_true(readl(TIMER_BASE + TIMER1RIS) == 0); |
143 | + | 73 | + |
144 | +static const MemMapEntry sbsa_ref_memmap[] = { | 74 | + /* Start timer: will fire after 40000 ns */ |
145 | + /* 512M boot ROM */ | 75 | + writel(TIMER_BASE + TIMER1LOAD, 1000); |
146 | + [SBSA_FLASH] = { 0, 0x20000000 }, | 76 | + /* enable in free-running, wrapping, interrupt mode */ |
147 | + /* 512M secure memory */ | 77 | + writel(TIMER_BASE + TIMER1CONTROL, CTRL_ENABLE | CTRL_INTEN); |
148 | + [SBSA_SECURE_MEM] = { 0x20000000, 0x20000000 }, | ||
149 | + /* Space reserved for CPU peripheral devices */ | ||
150 | + [SBSA_CPUPERIPHS] = { 0x40000000, 0x00040000 }, | ||
151 | + [SBSA_GIC_DIST] = { 0x40060000, 0x00010000 }, | ||
152 | + [SBSA_GIC_REDIST] = { 0x40080000, 0x04000000 }, | ||
153 | + [SBSA_UART] = { 0x60000000, 0x00001000 }, | ||
154 | + [SBSA_RTC] = { 0x60010000, 0x00001000 }, | ||
155 | + [SBSA_GPIO] = { 0x60020000, 0x00001000 }, | ||
156 | + [SBSA_SECURE_UART] = { 0x60030000, 0x00001000 }, | ||
157 | + [SBSA_SECURE_UART_MM] = { 0x60040000, 0x00001000 }, | ||
158 | + [SBSA_SMMU] = { 0x60050000, 0x00020000 }, | ||
159 | + /* Space here reserved for more SMMUs */ | ||
160 | + [SBSA_AHCI] = { 0x60100000, 0x00010000 }, | ||
161 | + [SBSA_EHCI] = { 0x60110000, 0x00010000 }, | ||
162 | + /* Space here reserved for other devices */ | ||
163 | + [SBSA_PCIE_PIO] = { 0x7fff0000, 0x00010000 }, | ||
164 | + /* 32-bit address PCIE MMIO space */ | ||
165 | + [SBSA_PCIE_MMIO] = { 0x80000000, 0x70000000 }, | ||
166 | + /* 256M PCIE ECAM space */ | ||
167 | + [SBSA_PCIE_ECAM] = { 0xf0000000, 0x10000000 }, | ||
168 | + /* ~1TB PCIE MMIO space (4GB to 1024GB boundary) */ | ||
169 | + [SBSA_PCIE_MMIO_HIGH] = { 0x100000000ULL, 0xFF00000000ULL }, | ||
170 | + [SBSA_MEM] = { 0x10000000000ULL, RAMLIMIT_BYTES }, | ||
171 | +}; | ||
172 | + | 78 | + |
173 | +static void sbsa_ref_init(MachineState *machine) | 79 | + /* Step to just past the 500th tick and check VALUE */ |
174 | +{ | 80 | + clock_step(500 * 40 + 1); |
175 | + SBSAMachineState *sms = SBSA_MACHINE(machine); | 81 | + g_assert_cmpuint(readl(TIMER_BASE + TIMER1RIS), ==, 0); |
176 | + MachineClass *mc = MACHINE_GET_CLASS(machine); | 82 | + g_assert_cmpuint(readl(TIMER_BASE + TIMER1VALUE), ==, 500); |
177 | + MemoryRegion *sysmem = get_system_memory(); | ||
178 | + MemoryRegion *secure_sysmem = NULL; | ||
179 | + MemoryRegion *ram = g_new(MemoryRegion, 1); | ||
180 | + const CPUArchIdList *possible_cpus; | ||
181 | + int n, sbsa_max_cpus; | ||
182 | + | 83 | + |
183 | + if (strcmp(machine->cpu_type, ARM_CPU_TYPE_NAME("cortex-a57"))) { | 84 | + /* Just past the 1000th tick: timer should have fired */ |
184 | + error_report("sbsa-ref: CPU type other than the built-in " | 85 | + clock_step(500 * 40); |
185 | + "cortex-a57 not supported"); | 86 | + g_assert_cmpuint(readl(TIMER_BASE + TIMER1RIS), ==, 1); |
186 | + exit(1); | 87 | + g_assert_cmpuint(readl(TIMER_BASE + TIMER1VALUE), ==, 0); |
187 | + } | ||
188 | + | ||
189 | + if (kvm_enabled()) { | ||
190 | + error_report("sbsa-ref: KVM is not supported for this machine"); | ||
191 | + exit(1); | ||
192 | + } | ||
193 | + | 88 | + |
194 | + /* | 89 | + /* |
195 | + * This machine has EL3 enabled, external firmware should supply PSCI | 90 | + * We are in free-running wrapping 16-bit mode, so on the following |
196 | + * implementation, so the QEMU's internal PSCI is disabled. | 91 | + * tick VALUE should have wrapped round to 0xffff. |
197 | + */ | 92 | + */ |
198 | + sms->psci_conduit = QEMU_PSCI_CONDUIT_DISABLED; | 93 | + clock_step(40); |
94 | + g_assert_cmpuint(readl(TIMER_BASE + TIMER1VALUE), ==, 0xffff); | ||
199 | + | 95 | + |
200 | + sbsa_max_cpus = sbsa_ref_memmap[SBSA_GIC_REDIST].size / GICV3_REDIST_SIZE; | 96 | + /* Check that any write to INTCLR clears interrupt */ |
97 | + writel(TIMER_BASE + TIMER1INTCLR, 1); | ||
98 | + g_assert_cmpuint(readl(TIMER_BASE + TIMER1RIS), ==, 0); | ||
201 | + | 99 | + |
202 | + if (max_cpus > sbsa_max_cpus) { | 100 | + /* Turn off the timer */ |
203 | + error_report("Number of SMP CPUs requested (%d) exceeds max CPUs " | 101 | + writel(TIMER_BASE + TIMER1CONTROL, 0); |
204 | + "supported by machine 'sbsa-ref' (%d)", | ||
205 | + max_cpus, sbsa_max_cpus); | ||
206 | + exit(1); | ||
207 | + } | ||
208 | + | ||
209 | + sms->smp_cpus = smp_cpus; | ||
210 | + | ||
211 | + if (machine->ram_size > sbsa_ref_memmap[SBSA_MEM].size) { | ||
212 | + error_report("sbsa-ref: cannot model more than %dGB RAM", RAMLIMIT_GB); | ||
213 | + exit(1); | ||
214 | + } | ||
215 | + | ||
216 | + possible_cpus = mc->possible_cpu_arch_ids(machine); | ||
217 | + for (n = 0; n < possible_cpus->len; n++) { | ||
218 | + Object *cpuobj; | ||
219 | + CPUState *cs; | ||
220 | + | ||
221 | + if (n >= smp_cpus) { | ||
222 | + break; | ||
223 | + } | ||
224 | + | ||
225 | + cpuobj = object_new(possible_cpus->cpus[n].type); | ||
226 | + object_property_set_int(cpuobj, possible_cpus->cpus[n].arch_id, | ||
227 | + "mp-affinity", NULL); | ||
228 | + | ||
229 | + cs = CPU(cpuobj); | ||
230 | + cs->cpu_index = n; | ||
231 | + | ||
232 | + numa_cpu_pre_plug(&possible_cpus->cpus[cs->cpu_index], DEVICE(cpuobj), | ||
233 | + &error_fatal); | ||
234 | + | ||
235 | + if (object_property_find(cpuobj, "reset-cbar", NULL)) { | ||
236 | + object_property_set_int(cpuobj, | ||
237 | + sbsa_ref_memmap[SBSA_CPUPERIPHS].base, | ||
238 | + "reset-cbar", &error_abort); | ||
239 | + } | ||
240 | + | ||
241 | + object_property_set_link(cpuobj, OBJECT(sysmem), "memory", | ||
242 | + &error_abort); | ||
243 | + | ||
244 | + object_property_set_link(cpuobj, OBJECT(secure_sysmem), | ||
245 | + "secure-memory", &error_abort); | ||
246 | + | ||
247 | + object_property_set_bool(cpuobj, true, "realized", &error_fatal); | ||
248 | + object_unref(cpuobj); | ||
249 | + } | ||
250 | + | ||
251 | + memory_region_allocate_system_memory(ram, NULL, "sbsa-ref.ram", | ||
252 | + machine->ram_size); | ||
253 | + memory_region_add_subregion(sysmem, sbsa_ref_memmap[SBSA_MEM].base, ram); | ||
254 | + | ||
255 | + sms->bootinfo.ram_size = machine->ram_size; | ||
256 | + sms->bootinfo.kernel_filename = machine->kernel_filename; | ||
257 | + sms->bootinfo.nb_cpus = smp_cpus; | ||
258 | + sms->bootinfo.board_id = -1; | ||
259 | + sms->bootinfo.loader_start = sbsa_ref_memmap[SBSA_MEM].base; | ||
260 | + arm_load_kernel(ARM_CPU(first_cpu), &sms->bootinfo); | ||
261 | +} | 102 | +} |
262 | + | 103 | + |
263 | +static uint64_t sbsa_ref_cpu_mp_affinity(SBSAMachineState *sms, int idx) | 104 | +static void test_prescale(void) |
264 | +{ | 105 | +{ |
265 | + uint8_t clustersz = ARM_DEFAULT_CPUS_PER_CLUSTER; | 106 | + g_assert_true(readl(TIMER_BASE + TIMER2RIS) == 0); |
266 | + return arm_cpu_mp_affinity(idx, clustersz); | 107 | + |
108 | + /* Start timer: will fire after 40 * 256 * 1000 == 1024000 ns */ | ||
109 | + writel(TIMER_BASE + TIMER2LOAD, 1000); | ||
110 | + /* enable in periodic, wrapping, interrupt mode, prescale 256 */ | ||
111 | + writel(TIMER_BASE + TIMER2CONTROL, | ||
112 | + CTRL_ENABLE | CTRL_INTEN | CTRL_PERIODIC | CTRL_PRESCALE_256); | ||
113 | + | ||
114 | + /* Step to just past the 500th tick and check VALUE */ | ||
115 | + clock_step(40 * 256 * 501); | ||
116 | + g_assert_cmpuint(readl(TIMER_BASE + TIMER2RIS), ==, 0); | ||
117 | + g_assert_cmpuint(readl(TIMER_BASE + TIMER2VALUE), ==, 500); | ||
118 | + | ||
119 | + /* Just past the 1000th tick: timer should have fired */ | ||
120 | + clock_step(40 * 256 * 500); | ||
121 | + g_assert_cmpuint(readl(TIMER_BASE + TIMER2RIS), ==, 1); | ||
122 | + g_assert_cmpuint(readl(TIMER_BASE + TIMER2VALUE), ==, 0); | ||
123 | + | ||
124 | + /* In periodic mode the tick VALUE now reloads */ | ||
125 | + clock_step(40 * 256); | ||
126 | + g_assert_cmpuint(readl(TIMER_BASE + TIMER2VALUE), ==, 1000); | ||
127 | + | ||
128 | + /* Check that any write to INTCLR clears interrupt */ | ||
129 | + writel(TIMER_BASE + TIMER2INTCLR, 1); | ||
130 | + g_assert_cmpuint(readl(TIMER_BASE + TIMER2RIS), ==, 0); | ||
131 | + | ||
132 | + /* Turn off the timer */ | ||
133 | + writel(TIMER_BASE + TIMER2CONTROL, 0); | ||
267 | +} | 134 | +} |
268 | + | 135 | + |
269 | +static const CPUArchIdList *sbsa_ref_possible_cpu_arch_ids(MachineState *ms) | 136 | +int main(int argc, char **argv) |
270 | +{ | 137 | +{ |
271 | + SBSAMachineState *sms = SBSA_MACHINE(ms); | 138 | + int r; |
272 | + int n; | ||
273 | + | 139 | + |
274 | + if (ms->possible_cpus) { | 140 | + g_test_init(&argc, &argv, NULL); |
275 | + assert(ms->possible_cpus->len == max_cpus); | ||
276 | + return ms->possible_cpus; | ||
277 | + } | ||
278 | + | 141 | + |
279 | + ms->possible_cpus = g_malloc0(sizeof(CPUArchIdList) + | 142 | + qtest_start("-machine mps2-an385"); |
280 | + sizeof(CPUArchId) * max_cpus); | 143 | + |
281 | + ms->possible_cpus->len = max_cpus; | 144 | + qtest_add_func("/cmsdk-apb-dualtimer/dualtimer", test_dualtimer); |
282 | + for (n = 0; n < ms->possible_cpus->len; n++) { | 145 | + qtest_add_func("/cmsdk-apb-dualtimer/prescale", test_prescale); |
283 | + ms->possible_cpus->cpus[n].type = ms->cpu_type; | 146 | + |
284 | + ms->possible_cpus->cpus[n].arch_id = | 147 | + r = g_test_run(); |
285 | + sbsa_ref_cpu_mp_affinity(sms, n); | 148 | + |
286 | + ms->possible_cpus->cpus[n].props.has_thread_id = true; | 149 | + qtest_end(); |
287 | + ms->possible_cpus->cpus[n].props.thread_id = n; | 150 | + |
288 | + } | 151 | + return r; |
289 | + return ms->possible_cpus; | ||
290 | +} | 152 | +} |
291 | + | ||
292 | +static CpuInstanceProperties | ||
293 | +sbsa_ref_cpu_index_to_props(MachineState *ms, unsigned cpu_index) | ||
294 | +{ | ||
295 | + MachineClass *mc = MACHINE_GET_CLASS(ms); | ||
296 | + const CPUArchIdList *possible_cpus = mc->possible_cpu_arch_ids(ms); | ||
297 | + | ||
298 | + assert(cpu_index < possible_cpus->len); | ||
299 | + return possible_cpus->cpus[cpu_index].props; | ||
300 | +} | ||
301 | + | ||
302 | +static int64_t | ||
303 | +sbsa_ref_get_default_cpu_node_id(const MachineState *ms, int idx) | ||
304 | +{ | ||
305 | + return idx % nb_numa_nodes; | ||
306 | +} | ||
307 | + | ||
308 | +static void sbsa_ref_class_init(ObjectClass *oc, void *data) | ||
309 | +{ | ||
310 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
311 | + | ||
312 | + mc->init = sbsa_ref_init; | ||
313 | + mc->desc = "QEMU 'SBSA Reference' ARM Virtual Machine"; | ||
314 | + mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a57"); | ||
315 | + mc->max_cpus = 512; | ||
316 | + mc->pci_allow_0_address = true; | ||
317 | + mc->minimum_page_bits = 12; | ||
318 | + mc->block_default_type = IF_IDE; | ||
319 | + mc->no_cdrom = 1; | ||
320 | + mc->default_ram_size = 1 * GiB; | ||
321 | + mc->default_cpus = 4; | ||
322 | + mc->possible_cpu_arch_ids = sbsa_ref_possible_cpu_arch_ids; | ||
323 | + mc->cpu_index_to_instance_props = sbsa_ref_cpu_index_to_props; | ||
324 | + mc->get_default_cpu_node_id = sbsa_ref_get_default_cpu_node_id; | ||
325 | +} | ||
326 | + | ||
327 | +static const TypeInfo sbsa_ref_info = { | ||
328 | + .name = TYPE_SBSA_MACHINE, | ||
329 | + .parent = TYPE_MACHINE, | ||
330 | + .class_init = sbsa_ref_class_init, | ||
331 | + .instance_size = sizeof(SBSAMachineState), | ||
332 | +}; | ||
333 | + | ||
334 | +static void sbsa_ref_machine_init(void) | ||
335 | +{ | ||
336 | + type_register_static(&sbsa_ref_info); | ||
337 | +} | ||
338 | + | ||
339 | +type_init(sbsa_ref_machine_init); | ||
340 | diff --git a/MAINTAINERS b/MAINTAINERS | 153 | diff --git a/MAINTAINERS b/MAINTAINERS |
341 | index XXXXXXX..XXXXXXX 100644 | 154 | index XXXXXXX..XXXXXXX 100644 |
342 | --- a/MAINTAINERS | 155 | --- a/MAINTAINERS |
343 | +++ b/MAINTAINERS | 156 | +++ b/MAINTAINERS |
344 | @@ -XXX,XX +XXX,XX @@ F: include/hw/arm/fsl-imx6.h | 157 | @@ -XXX,XX +XXX,XX @@ F: include/hw/timer/cmsdk-apb-timer.h |
345 | F: include/hw/misc/imx6_*.h | 158 | F: tests/qtest/cmsdk-apb-timer-test.c |
346 | F: include/hw/ssi/imx_spi.h | 159 | F: hw/timer/cmsdk-apb-dualtimer.c |
347 | 160 | F: include/hw/timer/cmsdk-apb-dualtimer.h | |
348 | +SBSA-REF | 161 | +F: tests/qtest/cmsdk-apb-dualtimer-test.c |
349 | +M: Radoslaw Biernacki <radoslaw.biernacki@linaro.org> | 162 | F: hw/char/cmsdk-apb-uart.c |
350 | +M: Peter Maydell <peter.maydell@linaro.org> | 163 | F: include/hw/char/cmsdk-apb-uart.h |
351 | +R: Leif Lindholm <leif.lindholm@linaro.org> | 164 | F: hw/watchdog/cmsdk-apb-watchdog.c |
352 | +L: qemu-arm@nongnu.org | 165 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build |
353 | +S: Maintained | ||
354 | +F: hw/arm/sbsa-ref.c | ||
355 | + | ||
356 | Sharp SL-5500 (Collie) PDA | ||
357 | M: Peter Maydell <peter.maydell@linaro.org> | ||
358 | L: qemu-arm@nongnu.org | ||
359 | diff --git a/default-configs/aarch64-softmmu.mak b/default-configs/aarch64-softmmu.mak | ||
360 | index XXXXXXX..XXXXXXX 100644 | 166 | index XXXXXXX..XXXXXXX 100644 |
361 | --- a/default-configs/aarch64-softmmu.mak | 167 | --- a/tests/qtest/meson.build |
362 | +++ b/default-configs/aarch64-softmmu.mak | 168 | +++ b/tests/qtest/meson.build |
363 | @@ -XXX,XX +XXX,XX @@ include arm-softmmu.mak | 169 | @@ -XXX,XX +XXX,XX @@ qtests_npcm7xx = \ |
364 | 170 | 'npcm7xx_timer-test', | |
365 | CONFIG_XLNX_ZYNQMP_ARM=y | 171 | 'npcm7xx_watchdog_timer-test'] |
366 | CONFIG_XLNX_VERSAL=y | 172 | qtests_arm = \ |
367 | +CONFIG_SBSA_REF=y | 173 | + (config_all_devices.has_key('CONFIG_CMSDK_APB_DUALTIMER') ? ['cmsdk-apb-dualtimer-test'] : []) + \ |
368 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | 174 | (config_all_devices.has_key('CONFIG_CMSDK_APB_TIMER') ? ['cmsdk-apb-timer-test'] : []) + \ |
369 | index XXXXXXX..XXXXXXX 100644 | 175 | (config_all_devices.has_key('CONFIG_CMSDK_APB_WATCHDOG') ? ['cmsdk-apb-watchdog-test'] : []) + \ |
370 | --- a/hw/arm/Kconfig | 176 | (config_all_devices.has_key('CONFIG_PFLASH_CFI02') ? ['pflash-cfi02-test'] : []) + \ |
371 | +++ b/hw/arm/Kconfig | ||
372 | @@ -XXX,XX +XXX,XX @@ config REALVIEW | ||
373 | select DS1338 # I2C RTC+NVRAM | ||
374 | select USB_OHCI | ||
375 | |||
376 | +config SBSA_REF | ||
377 | + bool | ||
378 | + imply PCI_DEVICES | ||
379 | + select AHCI | ||
380 | + select ARM_SMMUV3 | ||
381 | + select GPIO_KEY | ||
382 | + select PCI_EXPRESS | ||
383 | + select PCI_EXPRESS_GENERIC_BRIDGE | ||
384 | + select PFLASH_CFI01 | ||
385 | + select PL011 # UART | ||
386 | + select PL031 # RTC | ||
387 | + select PL061 # GPIO | ||
388 | + select USB_EHCI_SYSBUS | ||
389 | + | ||
390 | config SABRELITE | ||
391 | bool | ||
392 | select FSL_IMX6 | ||
393 | -- | 177 | -- |
394 | 2.20.1 | 178 | 2.20.1 |
395 | 179 | ||
396 | 180 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | The state struct for the CMSDK APB timer device doesn't follow our |
---|---|---|---|
2 | usual naming convention of camelcase -- "CMSDK" and "APB" are both | ||
3 | acronyms, but "TIMER" is not so should not be all-uppercase. | ||
4 | Globally rename the struct to "CMSDKAPBTimer" (bringing it into line | ||
5 | with CMSDKAPBWatchdog and CMSDKAPBDualTimer; CMSDKAPBUART remains | ||
6 | as-is because "UART" is an acronym). | ||
2 | 7 | ||
3 | The current models of the Aspeed SoCs only have one CPU but future | 8 | Commit created with: |
4 | ones will support SMP. Introduce a new num_cpus field at the SoC class | 9 | perl -p -i -e 's/CMSDKAPBTIMER/CMSDKAPBTimer/g' hw/timer/cmsdk-apb-timer.c include/hw/arm/armsse.h include/hw/timer/cmsdk-apb-timer.h |
5 | level to define the number of available CPUs per SoC and also | ||
6 | introduce a 'num-cpus' property to activate the CPUs configured for | ||
7 | the machine. | ||
8 | 10 | ||
9 | The max_cpus limit of the machine should depend on the SoC definition | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | but, unfortunately, these values are not available when the machine | 12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
11 | class is initialized. This is the reason why we add a check on | 13 | Reviewed-by: Luc Michel <luc@lmichel.fr> |
12 | num_cpus in the AspeedSoC realize handler. | 14 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
15 | Message-id: 20210128114145.20536-7-peter.maydell@linaro.org | ||
16 | Message-id: 20210121190622.22000-7-peter.maydell@linaro.org | ||
17 | --- | ||
18 | include/hw/arm/armsse.h | 6 +++--- | ||
19 | include/hw/timer/cmsdk-apb-timer.h | 4 ++-- | ||
20 | hw/timer/cmsdk-apb-timer.c | 28 ++++++++++++++-------------- | ||
21 | 3 files changed, 19 insertions(+), 19 deletions(-) | ||
13 | 22 | ||
14 | SMP support will be activated when models for such SoCs are implemented. | 23 | diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h |
15 | |||
16 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
17 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
18 | Message-id: 20190618165311.27066-6-clg@kaod.org | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | --- | ||
21 | include/hw/arm/aspeed_soc.h | 5 ++++- | ||
22 | hw/arm/aspeed.c | 7 +++++-- | ||
23 | hw/arm/aspeed_soc.c | 33 +++++++++++++++++++++++++++------ | ||
24 | 3 files changed, 36 insertions(+), 9 deletions(-) | ||
25 | |||
26 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h | ||
27 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/include/hw/arm/aspeed_soc.h | 25 | --- a/include/hw/arm/armsse.h |
29 | +++ b/include/hw/arm/aspeed_soc.h | 26 | +++ b/include/hw/arm/armsse.h |
27 | @@ -XXX,XX +XXX,XX @@ struct ARMSSE { | ||
28 | TZPPC apb_ppc0; | ||
29 | TZPPC apb_ppc1; | ||
30 | TZMPC mpc[IOTS_NUM_MPC]; | ||
31 | - CMSDKAPBTIMER timer0; | ||
32 | - CMSDKAPBTIMER timer1; | ||
33 | - CMSDKAPBTIMER s32ktimer; | ||
34 | + CMSDKAPBTimer timer0; | ||
35 | + CMSDKAPBTimer timer1; | ||
36 | + CMSDKAPBTimer s32ktimer; | ||
37 | qemu_or_irq ppc_irq_orgate; | ||
38 | SplitIRQ sec_resp_splitter; | ||
39 | SplitIRQ ppc_irq_splitter[NUM_PPCS]; | ||
40 | diff --git a/include/hw/timer/cmsdk-apb-timer.h b/include/hw/timer/cmsdk-apb-timer.h | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/include/hw/timer/cmsdk-apb-timer.h | ||
43 | +++ b/include/hw/timer/cmsdk-apb-timer.h | ||
30 | @@ -XXX,XX +XXX,XX @@ | 44 | @@ -XXX,XX +XXX,XX @@ |
31 | 45 | #include "qom/object.h" | |
32 | #define ASPEED_SPIS_NUM 2 | 46 | |
33 | #define ASPEED_WDTS_NUM 3 | 47 | #define TYPE_CMSDK_APB_TIMER "cmsdk-apb-timer" |
34 | +#define ASPEED_CPUS_NUM 2 | 48 | -OBJECT_DECLARE_SIMPLE_TYPE(CMSDKAPBTIMER, CMSDK_APB_TIMER) |
35 | 49 | +OBJECT_DECLARE_SIMPLE_TYPE(CMSDKAPBTimer, CMSDK_APB_TIMER) | |
36 | typedef struct AspeedSoCState { | 50 | |
51 | -struct CMSDKAPBTIMER { | ||
52 | +struct CMSDKAPBTimer { | ||
37 | /*< private >*/ | 53 | /*< private >*/ |
38 | DeviceState parent; | 54 | SysBusDevice parent_obj; |
39 | 55 | ||
40 | /*< public >*/ | 56 | diff --git a/hw/timer/cmsdk-apb-timer.c b/hw/timer/cmsdk-apb-timer.c |
41 | - ARMCPU cpu; | ||
42 | + ARMCPU cpu[ASPEED_CPUS_NUM]; | ||
43 | + uint32_t num_cpus; | ||
44 | MemoryRegion sram; | ||
45 | AspeedVICState vic; | ||
46 | AspeedRtcState rtc; | ||
47 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCInfo { | ||
48 | int wdts_num; | ||
49 | const int *irqmap; | ||
50 | const hwaddr *memmap; | ||
51 | + uint32_t num_cpus; | ||
52 | } AspeedSoCInfo; | ||
53 | |||
54 | typedef struct AspeedSoCClass { | ||
55 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | 57 | index XXXXXXX..XXXXXXX 100644 |
57 | --- a/hw/arm/aspeed.c | 58 | --- a/hw/timer/cmsdk-apb-timer.c |
58 | +++ b/hw/arm/aspeed.c | 59 | +++ b/hw/timer/cmsdk-apb-timer.c |
59 | @@ -XXX,XX +XXX,XX @@ | 60 | @@ -XXX,XX +XXX,XX @@ static const int timer_id[] = { |
60 | #include "hw/misc/tmp105.h" | 61 | 0x0d, 0xf0, 0x05, 0xb1, /* CID0..CID3 */ |
61 | #include "qemu/log.h" | ||
62 | #include "sysemu/block-backend.h" | ||
63 | +#include "sysemu/sysemu.h" | ||
64 | #include "hw/loader.h" | ||
65 | #include "qemu/error-report.h" | ||
66 | #include "qemu/units.h" | ||
67 | |||
68 | static struct arm_boot_info aspeed_board_binfo = { | ||
69 | .board_id = -1, /* device-tree-only board */ | ||
70 | - .nb_cpus = 1, | ||
71 | }; | 62 | }; |
72 | 63 | ||
73 | struct AspeedBoardState { | 64 | -static void cmsdk_apb_timer_update(CMSDKAPBTIMER *s) |
74 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | 65 | +static void cmsdk_apb_timer_update(CMSDKAPBTimer *s) |
75 | &error_abort); | 66 | { |
76 | object_property_set_int(OBJECT(&bmc->soc), cfg->num_cs, "num-cs", | 67 | qemu_set_irq(s->timerint, !!(s->intstatus & R_INTSTATUS_IRQ_MASK)); |
77 | &error_abort); | 68 | } |
78 | + object_property_set_int(OBJECT(&bmc->soc), smp_cpus, "num-cpus", | 69 | |
79 | + &error_abort); | 70 | static uint64_t cmsdk_apb_timer_read(void *opaque, hwaddr offset, unsigned size) |
80 | if (machine->kernel_filename) { | 71 | { |
81 | /* | 72 | - CMSDKAPBTIMER *s = CMSDK_APB_TIMER(opaque); |
82 | * When booting with a -kernel command line there is no u-boot | 73 | + CMSDKAPBTimer *s = CMSDK_APB_TIMER(opaque); |
83 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | 74 | uint64_t r; |
84 | aspeed_board_binfo.kernel_cmdline = machine->kernel_cmdline; | 75 | |
85 | aspeed_board_binfo.ram_size = ram_size; | 76 | switch (offset) { |
86 | aspeed_board_binfo.loader_start = sc->info->memmap[ASPEED_SDRAM]; | 77 | @@ -XXX,XX +XXX,XX @@ static uint64_t cmsdk_apb_timer_read(void *opaque, hwaddr offset, unsigned size) |
87 | + aspeed_board_binfo.nb_cpus = bmc->soc.num_cpus; | 78 | static void cmsdk_apb_timer_write(void *opaque, hwaddr offset, uint64_t value, |
88 | 79 | unsigned size) | |
89 | if (cfg->i2c_init) { | 80 | { |
90 | cfg->i2c_init(bmc); | 81 | - CMSDKAPBTIMER *s = CMSDK_APB_TIMER(opaque); |
91 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_class_init(ObjectClass *oc, void *data) | 82 | + CMSDKAPBTimer *s = CMSDK_APB_TIMER(opaque); |
92 | 83 | ||
93 | mc->desc = board->desc; | 84 | trace_cmsdk_apb_timer_write(offset, value, size); |
94 | mc->init = aspeed_machine_init; | 85 | |
95 | - mc->max_cpus = 1; | 86 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps cmsdk_apb_timer_ops = { |
96 | + mc->max_cpus = ASPEED_CPUS_NUM; | 87 | |
97 | mc->no_sdcard = 1; | 88 | static void cmsdk_apb_timer_tick(void *opaque) |
98 | mc->no_floppy = 1; | 89 | { |
99 | mc->no_cdrom = 1; | 90 | - CMSDKAPBTIMER *s = CMSDK_APB_TIMER(opaque); |
100 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | 91 | + CMSDKAPBTimer *s = CMSDK_APB_TIMER(opaque); |
101 | index XXXXXXX..XXXXXXX 100644 | 92 | |
102 | --- a/hw/arm/aspeed_soc.c | 93 | if (s->ctrl & R_CTRL_IRQEN_MASK) { |
103 | +++ b/hw/arm/aspeed_soc.c | 94 | s->intstatus |= R_INTSTATUS_IRQ_MASK; |
104 | @@ -XXX,XX +XXX,XX @@ | 95 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_tick(void *opaque) |
105 | #include "hw/char/serial.h" | 96 | |
106 | #include "qemu/log.h" | 97 | static void cmsdk_apb_timer_reset(DeviceState *dev) |
107 | #include "qemu/module.h" | 98 | { |
108 | +#include "qemu/error-report.h" | 99 | - CMSDKAPBTIMER *s = CMSDK_APB_TIMER(dev); |
109 | #include "hw/i2c/aspeed_i2c.h" | 100 | + CMSDKAPBTimer *s = CMSDK_APB_TIMER(dev); |
110 | #include "net/net.h" | 101 | |
111 | 102 | trace_cmsdk_apb_timer_reset(); | |
112 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | 103 | s->ctrl = 0; |
113 | .wdts_num = 2, | 104 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_reset(DeviceState *dev) |
114 | .irqmap = aspeed_soc_ast2400_irqmap, | 105 | static void cmsdk_apb_timer_init(Object *obj) |
115 | .memmap = aspeed_soc_ast2400_memmap, | 106 | { |
116 | + .num_cpus = 1, | 107 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); |
117 | }, { | 108 | - CMSDKAPBTIMER *s = CMSDK_APB_TIMER(obj); |
118 | .name = "ast2400-a1", | 109 | + CMSDKAPBTimer *s = CMSDK_APB_TIMER(obj); |
119 | .cpu_type = ARM_CPU_TYPE_NAME("arm926"), | 110 | |
120 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | 111 | memory_region_init_io(&s->iomem, obj, &cmsdk_apb_timer_ops, |
121 | .wdts_num = 2, | 112 | s, "cmsdk-apb-timer", 0x1000); |
122 | .irqmap = aspeed_soc_ast2400_irqmap, | 113 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_init(Object *obj) |
123 | .memmap = aspeed_soc_ast2400_memmap, | 114 | |
124 | + .num_cpus = 1, | 115 | static void cmsdk_apb_timer_realize(DeviceState *dev, Error **errp) |
125 | }, { | 116 | { |
126 | .name = "ast2400", | 117 | - CMSDKAPBTIMER *s = CMSDK_APB_TIMER(dev); |
127 | .cpu_type = ARM_CPU_TYPE_NAME("arm926"), | 118 | + CMSDKAPBTimer *s = CMSDK_APB_TIMER(dev); |
128 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | 119 | |
129 | .wdts_num = 2, | 120 | if (s->pclk_frq == 0) { |
130 | .irqmap = aspeed_soc_ast2400_irqmap, | 121 | error_setg(errp, "CMSDK APB timer: pclk-frq property must be set"); |
131 | .memmap = aspeed_soc_ast2400_memmap, | 122 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription cmsdk_apb_timer_vmstate = { |
132 | + .num_cpus = 1, | 123 | .version_id = 1, |
133 | }, { | 124 | .minimum_version_id = 1, |
134 | .name = "ast2500-a1", | 125 | .fields = (VMStateField[]) { |
135 | .cpu_type = ARM_CPU_TYPE_NAME("arm1176"), | 126 | - VMSTATE_PTIMER(timer, CMSDKAPBTIMER), |
136 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | 127 | - VMSTATE_UINT32(ctrl, CMSDKAPBTIMER), |
137 | .wdts_num = 3, | 128 | - VMSTATE_UINT32(value, CMSDKAPBTIMER), |
138 | .irqmap = aspeed_soc_ast2500_irqmap, | 129 | - VMSTATE_UINT32(reload, CMSDKAPBTIMER), |
139 | .memmap = aspeed_soc_ast2500_memmap, | 130 | - VMSTATE_UINT32(intstatus, CMSDKAPBTIMER), |
140 | + .num_cpus = 1, | 131 | + VMSTATE_PTIMER(timer, CMSDKAPBTimer), |
141 | }, | 132 | + VMSTATE_UINT32(ctrl, CMSDKAPBTimer), |
133 | + VMSTATE_UINT32(value, CMSDKAPBTimer), | ||
134 | + VMSTATE_UINT32(reload, CMSDKAPBTimer), | ||
135 | + VMSTATE_UINT32(intstatus, CMSDKAPBTimer), | ||
136 | VMSTATE_END_OF_LIST() | ||
137 | } | ||
142 | }; | 138 | }; |
143 | 139 | ||
144 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | 140 | static Property cmsdk_apb_timer_properties[] = { |
145 | AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); | 141 | - DEFINE_PROP_UINT32("pclk-frq", CMSDKAPBTIMER, pclk_frq, 0), |
146 | int i; | 142 | + DEFINE_PROP_UINT32("pclk-frq", CMSDKAPBTimer, pclk_frq, 0), |
147 | 143 | DEFINE_PROP_END_OF_LIST(), | |
148 | - object_initialize_child(obj, "cpu", OBJECT(&s->cpu), sizeof(s->cpu), | 144 | }; |
149 | - sc->info->cpu_type, &error_abort, NULL); | 145 | |
150 | + for (i = 0; i < sc->info->num_cpus; i++) { | 146 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_class_init(ObjectClass *klass, void *data) |
151 | + object_initialize_child(obj, "cpu[*]", OBJECT(&s->cpu[i]), | 147 | static const TypeInfo cmsdk_apb_timer_info = { |
152 | + sizeof(s->cpu[i]), sc->info->cpu_type, | 148 | .name = TYPE_CMSDK_APB_TIMER, |
153 | + &error_abort, NULL); | 149 | .parent = TYPE_SYS_BUS_DEVICE, |
154 | + } | 150 | - .instance_size = sizeof(CMSDKAPBTIMER), |
155 | 151 | + .instance_size = sizeof(CMSDKAPBTimer), | |
156 | sysbus_init_child_obj(obj, "scu", OBJECT(&s->scu), sizeof(s->scu), | 152 | .instance_init = cmsdk_apb_timer_init, |
157 | TYPE_ASPEED_SCU); | 153 | .class_init = cmsdk_apb_timer_class_init, |
158 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | 154 | }; |
159 | create_unimplemented_device("aspeed_soc.io", sc->info->memmap[ASPEED_IOMEM], | ||
160 | ASPEED_SOC_IOMEM_SIZE); | ||
161 | |||
162 | + if (s->num_cpus > sc->info->num_cpus) { | ||
163 | + warn_report("%s: invalid number of CPUs %d, using default %d", | ||
164 | + sc->info->name, s->num_cpus, sc->info->num_cpus); | ||
165 | + s->num_cpus = sc->info->num_cpus; | ||
166 | + } | ||
167 | + | ||
168 | /* CPU */ | ||
169 | - object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err); | ||
170 | - if (err) { | ||
171 | - error_propagate(errp, err); | ||
172 | - return; | ||
173 | + for (i = 0; i < s->num_cpus; i++) { | ||
174 | + object_property_set_bool(OBJECT(&s->cpu[i]), true, "realized", &err); | ||
175 | + if (err) { | ||
176 | + error_propagate(errp, err); | ||
177 | + return; | ||
178 | + } | ||
179 | } | ||
180 | |||
181 | /* SRAM */ | ||
182 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
183 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100), 0, | ||
184 | aspeed_soc_get_irq(s, ASPEED_ETH1)); | ||
185 | } | ||
186 | +static Property aspeed_soc_properties[] = { | ||
187 | + DEFINE_PROP_UINT32("num-cpus", AspeedSoCState, num_cpus, 0), | ||
188 | + DEFINE_PROP_END_OF_LIST(), | ||
189 | +}; | ||
190 | |||
191 | static void aspeed_soc_class_init(ObjectClass *oc, void *data) | ||
192 | { | ||
193 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_class_init(ObjectClass *oc, void *data) | ||
194 | dc->realize = aspeed_soc_realize; | ||
195 | /* Reason: Uses serial_hds and nd_table in realize() directly */ | ||
196 | dc->user_creatable = false; | ||
197 | + dc->props = aspeed_soc_properties; | ||
198 | } | ||
199 | |||
200 | static const TypeInfo aspeed_soc_type_info = { | ||
201 | -- | 155 | -- |
202 | 2.20.1 | 156 | 2.20.1 |
203 | 157 | ||
204 | 158 | diff view generated by jsdifflib |
1 | From: Adriana Kobylak <anoo@us.ibm.com> | 1 | As the first step in converting the CMSDK_APB_TIMER device to the |
---|---|---|---|
2 | Clock framework, add a Clock input. For the moment we do nothing | ||
3 | with this clock; we will change the behaviour from using the pclk-frq | ||
4 | property to using the Clock once all the users of this device have | ||
5 | been converted to wire up the Clock. | ||
2 | 6 | ||
3 | The Swift board is an OpenPOWER system hosting POWER processors. | 7 | Since the device doesn't already have a doc comment for its "QEMU |
4 | Add support for their BMC including the I2C devices as found on HW. | 8 | interface", we add one including the new Clock. |
5 | 9 | ||
6 | Signed-off-by: Adriana Kobylak <anoo@us.ibm.com> | 10 | This is a migration compatibility break for machines mps2-an505, |
7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 11 | mps2-an521, musca-a, musca-b1. |
8 | Reviewed-by: Joel Stanley <joel@jms.id.au> | 12 | |
9 | Message-id: 20190618165311.27066-20-clg@kaod.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
15 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
16 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
17 | Message-id: 20210128114145.20536-8-peter.maydell@linaro.org | ||
18 | Message-id: 20210121190622.22000-8-peter.maydell@linaro.org | ||
11 | --- | 19 | --- |
12 | hw/arm/aspeed.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ | 20 | include/hw/timer/cmsdk-apb-timer.h | 9 +++++++++ |
13 | 1 file changed, 50 insertions(+) | 21 | hw/timer/cmsdk-apb-timer.c | 7 +++++-- |
22 | 2 files changed, 14 insertions(+), 2 deletions(-) | ||
14 | 23 | ||
15 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | 24 | diff --git a/include/hw/timer/cmsdk-apb-timer.h b/include/hw/timer/cmsdk-apb-timer.h |
16 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/aspeed.c | 26 | --- a/include/hw/timer/cmsdk-apb-timer.h |
18 | +++ b/hw/arm/aspeed.c | 27 | +++ b/include/hw/timer/cmsdk-apb-timer.h |
19 | @@ -XXX,XX +XXX,XX @@ struct AspeedBoardState { | 28 | @@ -XXX,XX +XXX,XX @@ |
20 | SCU_AST2500_HW_STRAP_ACPI_ENABLE | \ | 29 | #include "hw/qdev-properties.h" |
21 | SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER)) | 30 | #include "hw/sysbus.h" |
22 | 31 | #include "hw/ptimer.h" | |
23 | +/* Swift hardware value: 0xF11AD206 */ | 32 | +#include "hw/clock.h" |
24 | +#define SWIFT_BMC_HW_STRAP1 ( \ | 33 | #include "qom/object.h" |
25 | + AST2500_HW_STRAP1_DEFAULTS | \ | 34 | |
26 | + SCU_AST2500_HW_STRAP_SPI_AUTOFETCH_ENABLE | \ | 35 | #define TYPE_CMSDK_APB_TIMER "cmsdk-apb-timer" |
27 | + SCU_AST2500_HW_STRAP_GPIO_STRAP_ENABLE | \ | 36 | OBJECT_DECLARE_SIMPLE_TYPE(CMSDKAPBTimer, CMSDK_APB_TIMER) |
28 | + SCU_AST2500_HW_STRAP_UART_DEBUG | \ | 37 | |
29 | + SCU_AST2500_HW_STRAP_DDR4_ENABLE | \ | 38 | +/* |
30 | + SCU_H_PLL_BYPASS_EN | \ | 39 | + * QEMU interface: |
31 | + SCU_AST2500_HW_STRAP_ACPI_ENABLE | \ | 40 | + * + QOM property "pclk-frq": frequency at which the timer is clocked |
32 | + SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER)) | 41 | + * + Clock input "pclk": clock for the timer |
33 | + | 42 | + * + sysbus MMIO region 0: the register bank |
34 | /* Witherspoon hardware value: 0xF10AD216 (but use romulus definition) */ | 43 | + * + sysbus IRQ 0: timer interrupt TIMERINT |
35 | #define WITHERSPOON_BMC_HW_STRAP1 ROMULUS_BMC_HW_STRAP1 | 44 | + */ |
36 | 45 | struct CMSDKAPBTimer { | |
37 | @@ -XXX,XX +XXX,XX @@ static void romulus_bmc_i2c_init(AspeedBoardState *bmc) | 46 | /*< private >*/ |
38 | i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32); | 47 | SysBusDevice parent_obj; |
48 | @@ -XXX,XX +XXX,XX @@ struct CMSDKAPBTimer { | ||
49 | qemu_irq timerint; | ||
50 | uint32_t pclk_frq; | ||
51 | struct ptimer_state *timer; | ||
52 | + Clock *pclk; | ||
53 | |||
54 | uint32_t ctrl; | ||
55 | uint32_t value; | ||
56 | diff --git a/hw/timer/cmsdk-apb-timer.c b/hw/timer/cmsdk-apb-timer.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/hw/timer/cmsdk-apb-timer.c | ||
59 | +++ b/hw/timer/cmsdk-apb-timer.c | ||
60 | @@ -XXX,XX +XXX,XX @@ | ||
61 | #include "hw/sysbus.h" | ||
62 | #include "hw/irq.h" | ||
63 | #include "hw/registerfields.h" | ||
64 | +#include "hw/qdev-clock.h" | ||
65 | #include "hw/timer/cmsdk-apb-timer.h" | ||
66 | #include "migration/vmstate.h" | ||
67 | |||
68 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_init(Object *obj) | ||
69 | s, "cmsdk-apb-timer", 0x1000); | ||
70 | sysbus_init_mmio(sbd, &s->iomem); | ||
71 | sysbus_init_irq(sbd, &s->timerint); | ||
72 | + s->pclk = qdev_init_clock_in(DEVICE(s), "pclk", NULL, NULL); | ||
39 | } | 73 | } |
40 | 74 | ||
41 | +static void swift_bmc_i2c_init(AspeedBoardState *bmc) | 75 | static void cmsdk_apb_timer_realize(DeviceState *dev, Error **errp) |
42 | +{ | 76 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_realize(DeviceState *dev, Error **errp) |
43 | + AspeedSoCState *soc = &bmc->soc; | 77 | |
44 | + | 78 | static const VMStateDescription cmsdk_apb_timer_vmstate = { |
45 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), "pca9552", 0x60); | 79 | .name = "cmsdk-apb-timer", |
46 | + | 80 | - .version_id = 1, |
47 | + /* The swift board expects a TMP275 but a TMP105 is compatible */ | 81 | - .minimum_version_id = 1, |
48 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0x48); | 82 | + .version_id = 2, |
49 | + /* The swift board expects a pca9551 but a pca9552 is compatible */ | 83 | + .minimum_version_id = 2, |
50 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "pca9552", 0x60); | 84 | .fields = (VMStateField[]) { |
51 | + | 85 | VMSTATE_PTIMER(timer, CMSDKAPBTimer), |
52 | + /* The swift board expects an Epson RX8900 RTC but a ds1338 is compatible */ | 86 | + VMSTATE_CLOCK(pclk, CMSDKAPBTimer), |
53 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "ds1338", 0x32); | 87 | VMSTATE_UINT32(ctrl, CMSDKAPBTimer), |
54 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "pca9552", 0x60); | 88 | VMSTATE_UINT32(value, CMSDKAPBTimer), |
55 | + | 89 | VMSTATE_UINT32(reload, CMSDKAPBTimer), |
56 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp423", 0x4c); | ||
57 | + /* The swift board expects a pca9539 but a pca9552 is compatible */ | ||
58 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "pca9552", 0x74); | ||
59 | + | ||
60 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 10), "tmp423", 0x4c); | ||
61 | + /* The swift board expects a pca9539 but a pca9552 is compatible */ | ||
62 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 10), "pca9552", | ||
63 | + 0x74); | ||
64 | + | ||
65 | + /* The swift board expects a TMP275 but a TMP105 is compatible */ | ||
66 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 12), "tmp105", 0x48); | ||
67 | + i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 12), "tmp105", 0x4a); | ||
68 | +} | ||
69 | + | ||
70 | static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc) | ||
71 | { | ||
72 | AspeedSoCState *soc = &bmc->soc; | ||
73 | @@ -XXX,XX +XXX,XX @@ static const AspeedBoardConfig aspeed_boards[] = { | ||
74 | .num_cs = 2, | ||
75 | .i2c_init = romulus_bmc_i2c_init, | ||
76 | .ram = 512 * MiB, | ||
77 | + }, { | ||
78 | + .name = MACHINE_TYPE_NAME("swift-bmc"), | ||
79 | + .desc = "OpenPOWER Swift BMC (ARM1176)", | ||
80 | + .soc_name = "ast2500-a1", | ||
81 | + .hw_strap1 = SWIFT_BMC_HW_STRAP1, | ||
82 | + .fmc_model = "mx66l1g45g", | ||
83 | + .spi_model = "mx66l1g45g", | ||
84 | + .num_cs = 2, | ||
85 | + .i2c_init = swift_bmc_i2c_init, | ||
86 | + .ram = 512 * MiB, | ||
87 | }, { | ||
88 | .name = MACHINE_TYPE_NAME("witherspoon-bmc"), | ||
89 | .desc = "OpenPOWER Witherspoon BMC (ARM1176)", | ||
90 | -- | 90 | -- |
91 | 2.20.1 | 91 | 2.20.1 |
92 | 92 | ||
93 | 93 | diff view generated by jsdifflib |
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | 1 | As the first step in converting the CMSDK_APB_DUALTIMER device to the |
---|---|---|---|
2 | Clock framework, add a Clock input. For the moment we do nothing | ||
3 | with this clock; we will change the behaviour from using the pclk-frq | ||
4 | property to using the Clock once all the users of this device have | ||
5 | been converted to wire up the Clock. | ||
2 | 6 | ||
3 | Datasheet for i.MX7 is incorrect and i.MX7's PCI IRQ mapping matches | 7 | We take the opportunity to correct the name of the clock input to |
4 | that of i.MX6: | 8 | match the hardware -- the dual timer names the clock which drives the |
9 | timers TIMCLK. (It does also have a 'pclk' input, which is used only | ||
10 | for the register and APB bus logic; on the SSE-200 these clocks are | ||
11 | both connected together.) | ||
5 | 12 | ||
6 | * INTD/MSI 122 | 13 | This is a migration compatibility break for machines mps2-an385, |
7 | * INTC 123 | 14 | mps2-an386, mps2-an500, mps2-an511, mps2-an505, mps2-an521, musca-a, |
8 | * INTB 124 | 15 | musca-b1. |
9 | * INTA 125 | ||
10 | 16 | ||
11 | Fix all of the relevant code to reflect that fact. Needed by latest | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Linux kernels. | 18 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
19 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
20 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
21 | Message-id: 20210128114145.20536-9-peter.maydell@linaro.org | ||
22 | Message-id: 20210121190622.22000-9-peter.maydell@linaro.org | ||
23 | --- | ||
24 | include/hw/timer/cmsdk-apb-dualtimer.h | 3 +++ | ||
25 | hw/timer/cmsdk-apb-dualtimer.c | 7 +++++-- | ||
26 | 2 files changed, 8 insertions(+), 2 deletions(-) | ||
13 | 27 | ||
14 | (Reference: Linux kernel commit 538d6e9d597584e80 from an | 28 | diff --git a/include/hw/timer/cmsdk-apb-dualtimer.h b/include/hw/timer/cmsdk-apb-dualtimer.h |
15 | NXP employee confirming that the datasheet is incorrect and | ||
16 | with a report of a test against hardware.) | ||
17 | |||
18 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
19 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
20 | Cc: Michael S. Tsirkin <mst@redhat.com> | ||
21 | Cc: qemu-devel@nongnu.org | ||
22 | Cc: qemu-arm@nongnu.org | ||
23 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
24 | [PMM: added ref to kernel commit confirming the datasheet error] | ||
25 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
26 | --- | ||
27 | include/hw/arm/fsl-imx7.h | 8 ++++---- | ||
28 | hw/pci-host/designware.c | 6 ++++-- | ||
29 | 2 files changed, 8 insertions(+), 6 deletions(-) | ||
30 | |||
31 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h | ||
32 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/include/hw/arm/fsl-imx7.h | 30 | --- a/include/hw/timer/cmsdk-apb-dualtimer.h |
34 | +++ b/include/hw/arm/fsl-imx7.h | 31 | +++ b/include/hw/timer/cmsdk-apb-dualtimer.h |
35 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7IRQs { | 32 | @@ -XXX,XX +XXX,XX @@ |
36 | FSL_IMX7_USB2_IRQ = 42, | 33 | * |
37 | FSL_IMX7_USB3_IRQ = 40, | 34 | * QEMU interface: |
38 | 35 | * + QOM property "pclk-frq": frequency at which the timer is clocked | |
39 | - FSL_IMX7_PCI_INTA_IRQ = 122, | 36 | + * + Clock input "TIMCLK": clock (for both timers) |
40 | - FSL_IMX7_PCI_INTB_IRQ = 123, | 37 | * + sysbus MMIO region 0: the register bank |
41 | - FSL_IMX7_PCI_INTC_IRQ = 124, | 38 | * + sysbus IRQ 0: combined timer interrupt TIMINTC |
42 | - FSL_IMX7_PCI_INTD_IRQ = 125, | 39 | * + sysbus IRO 1: timer block 1 interrupt TIMINT1 |
43 | + FSL_IMX7_PCI_INTA_IRQ = 125, | 40 | @@ -XXX,XX +XXX,XX @@ |
44 | + FSL_IMX7_PCI_INTB_IRQ = 124, | 41 | |
45 | + FSL_IMX7_PCI_INTC_IRQ = 123, | 42 | #include "hw/sysbus.h" |
46 | + FSL_IMX7_PCI_INTD_IRQ = 122, | 43 | #include "hw/ptimer.h" |
47 | 44 | +#include "hw/clock.h" | |
48 | FSL_IMX7_UART7_IRQ = 126, | 45 | #include "qom/object.h" |
49 | 46 | ||
50 | diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c | 47 | #define TYPE_CMSDK_APB_DUALTIMER "cmsdk-apb-dualtimer" |
48 | @@ -XXX,XX +XXX,XX @@ struct CMSDKAPBDualTimer { | ||
49 | MemoryRegion iomem; | ||
50 | qemu_irq timerintc; | ||
51 | uint32_t pclk_frq; | ||
52 | + Clock *timclk; | ||
53 | |||
54 | CMSDKAPBDualTimerModule timermod[CMSDK_APB_DUALTIMER_NUM_MODULES]; | ||
55 | uint32_t timeritcr; | ||
56 | diff --git a/hw/timer/cmsdk-apb-dualtimer.c b/hw/timer/cmsdk-apb-dualtimer.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | 57 | index XXXXXXX..XXXXXXX 100644 |
52 | --- a/hw/pci-host/designware.c | 58 | --- a/hw/timer/cmsdk-apb-dualtimer.c |
53 | +++ b/hw/pci-host/designware.c | 59 | +++ b/hw/timer/cmsdk-apb-dualtimer.c |
54 | @@ -XXX,XX +XXX,XX @@ | 60 | @@ -XXX,XX +XXX,XX @@ |
55 | #define DESIGNWARE_PCIE_ATU_DEVFN(x) (((x) >> 16) & 0xff) | 61 | #include "hw/irq.h" |
56 | #define DESIGNWARE_PCIE_ATU_UPPER_TARGET 0x91C | 62 | #include "hw/qdev-properties.h" |
57 | 63 | #include "hw/registerfields.h" | |
58 | +#define DESIGNWARE_PCIE_IRQ_MSI 3 | 64 | +#include "hw/qdev-clock.h" |
59 | + | 65 | #include "hw/timer/cmsdk-apb-dualtimer.h" |
60 | static DesignwarePCIEHost * | 66 | #include "migration/vmstate.h" |
61 | designware_pcie_root_to_host(DesignwarePCIERoot *root) | 67 | |
62 | { | 68 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_dualtimer_init(Object *obj) |
63 | @@ -XXX,XX +XXX,XX @@ static void designware_pcie_root_msi_write(void *opaque, hwaddr addr, | 69 | for (i = 0; i < ARRAY_SIZE(s->timermod); i++) { |
64 | root->msi.intr[0].status |= BIT(val) & root->msi.intr[0].enable; | 70 | sysbus_init_irq(sbd, &s->timermod[i].timerint); |
65 | |||
66 | if (root->msi.intr[0].status & ~root->msi.intr[0].mask) { | ||
67 | - qemu_set_irq(host->pci.irqs[0], 1); | ||
68 | + qemu_set_irq(host->pci.irqs[DESIGNWARE_PCIE_IRQ_MSI], 1); | ||
69 | } | 71 | } |
72 | + s->timclk = qdev_init_clock_in(DEVICE(s), "TIMCLK", NULL, NULL); | ||
70 | } | 73 | } |
71 | 74 | ||
72 | @@ -XXX,XX +XXX,XX @@ static void designware_pcie_root_config_write(PCIDevice *d, uint32_t address, | 75 | static void cmsdk_apb_dualtimer_realize(DeviceState *dev, Error **errp) |
73 | case DESIGNWARE_PCIE_MSI_INTR0_STATUS: | 76 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription cmsdk_dualtimermod_vmstate = { |
74 | root->msi.intr[0].status ^= val; | 77 | |
75 | if (!root->msi.intr[0].status) { | 78 | static const VMStateDescription cmsdk_apb_dualtimer_vmstate = { |
76 | - qemu_set_irq(host->pci.irqs[0], 0); | 79 | .name = "cmsdk-apb-dualtimer", |
77 | + qemu_set_irq(host->pci.irqs[DESIGNWARE_PCIE_IRQ_MSI], 0); | 80 | - .version_id = 1, |
78 | } | 81 | - .minimum_version_id = 1, |
79 | break; | 82 | + .version_id = 2, |
80 | 83 | + .minimum_version_id = 2, | |
84 | .fields = (VMStateField[]) { | ||
85 | + VMSTATE_CLOCK(timclk, CMSDKAPBDualTimer), | ||
86 | VMSTATE_STRUCT_ARRAY(timermod, CMSDKAPBDualTimer, | ||
87 | CMSDK_APB_DUALTIMER_NUM_MODULES, | ||
88 | 1, cmsdk_dualtimermod_vmstate, | ||
81 | -- | 89 | -- |
82 | 2.20.1 | 90 | 2.20.1 |
83 | 91 | ||
84 | 92 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | As the first step in converting the CMSDK_APB_TIMER device to the |
---|---|---|---|
2 | Clock framework, add a Clock input. For the moment we do nothing | ||
3 | with this clock; we will change the behaviour from using the | ||
4 | wdogclk-frq property to using the Clock once all the users of this | ||
5 | device have been converted to wire up the Clock. | ||
2 | 6 | ||
3 | Fix the condition used to check whether the initrd fits | 7 | This is a migration compatibility break for machines mps2-an385, |
4 | into RAM; in some cases if an initrd was also passed on | 8 | mps2-an386, mps2-an500, mps2-an511, mps2-an505, mps2-an521, musca-a, |
5 | the command line we would get an error stating that it | 9 | musca-b1, lm3s811evb, lm3s6965evb. |
6 | was too big to fit into RAM after the kernel. Despite the | ||
7 | error the loader continued anyway, though, so also add an | ||
8 | exit(1) when the initrd is actually too big. | ||
9 | 10 | ||
10 | Fixes: 852dc64d665f ("hw/arm/boot: Diagnose layouts that put initrd or | ||
11 | DTB off the end of RAM") | ||
12 | Signed-off-by: Andrew Jones <drjones@redhat.com> | ||
13 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
14 | Message-id: 20190618125844.4863-1-drjones@redhat.com | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
14 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
15 | Message-id: 20210128114145.20536-10-peter.maydell@linaro.org | ||
16 | Message-id: 20210121190622.22000-10-peter.maydell@linaro.org | ||
16 | --- | 17 | --- |
17 | hw/arm/boot.c | 3 ++- | 18 | include/hw/watchdog/cmsdk-apb-watchdog.h | 3 +++ |
18 | 1 file changed, 2 insertions(+), 1 deletion(-) | 19 | hw/watchdog/cmsdk-apb-watchdog.c | 7 +++++-- |
20 | 2 files changed, 8 insertions(+), 2 deletions(-) | ||
19 | 21 | ||
20 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | 22 | diff --git a/include/hw/watchdog/cmsdk-apb-watchdog.h b/include/hw/watchdog/cmsdk-apb-watchdog.h |
21 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/arm/boot.c | 24 | --- a/include/hw/watchdog/cmsdk-apb-watchdog.h |
23 | +++ b/hw/arm/boot.c | 25 | +++ b/include/hw/watchdog/cmsdk-apb-watchdog.h |
24 | @@ -XXX,XX +XXX,XX @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu, | 26 | @@ -XXX,XX +XXX,XX @@ |
25 | info->initrd_filename); | 27 | * |
26 | exit(1); | 28 | * QEMU interface: |
27 | } | 29 | * + QOM property "wdogclk-frq": frequency at which the watchdog is clocked |
28 | - if (info->initrd_start + initrd_size > info->ram_size) { | 30 | + * + Clock input "WDOGCLK": clock for the watchdog's timer |
29 | + if (info->initrd_start + initrd_size > ram_end) { | 31 | * + sysbus MMIO region 0: the register bank |
30 | error_report("could not load initrd '%s': " | 32 | * + sysbus IRQ 0: watchdog interrupt |
31 | "too big to fit into RAM after the kernel", | 33 | * |
32 | info->initrd_filename); | 34 | @@ -XXX,XX +XXX,XX @@ |
33 | + exit(1); | 35 | |
34 | } | 36 | #include "hw/sysbus.h" |
35 | } else { | 37 | #include "hw/ptimer.h" |
36 | initrd_size = 0; | 38 | +#include "hw/clock.h" |
39 | #include "qom/object.h" | ||
40 | |||
41 | #define TYPE_CMSDK_APB_WATCHDOG "cmsdk-apb-watchdog" | ||
42 | @@ -XXX,XX +XXX,XX @@ struct CMSDKAPBWatchdog { | ||
43 | uint32_t wdogclk_frq; | ||
44 | bool is_luminary; | ||
45 | struct ptimer_state *timer; | ||
46 | + Clock *wdogclk; | ||
47 | |||
48 | uint32_t control; | ||
49 | uint32_t intstatus; | ||
50 | diff --git a/hw/watchdog/cmsdk-apb-watchdog.c b/hw/watchdog/cmsdk-apb-watchdog.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/hw/watchdog/cmsdk-apb-watchdog.c | ||
53 | +++ b/hw/watchdog/cmsdk-apb-watchdog.c | ||
54 | @@ -XXX,XX +XXX,XX @@ | ||
55 | #include "hw/irq.h" | ||
56 | #include "hw/qdev-properties.h" | ||
57 | #include "hw/registerfields.h" | ||
58 | +#include "hw/qdev-clock.h" | ||
59 | #include "hw/watchdog/cmsdk-apb-watchdog.h" | ||
60 | #include "migration/vmstate.h" | ||
61 | |||
62 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_init(Object *obj) | ||
63 | s, "cmsdk-apb-watchdog", 0x1000); | ||
64 | sysbus_init_mmio(sbd, &s->iomem); | ||
65 | sysbus_init_irq(sbd, &s->wdogint); | ||
66 | + s->wdogclk = qdev_init_clock_in(DEVICE(s), "WDOGCLK", NULL, NULL); | ||
67 | |||
68 | s->is_luminary = false; | ||
69 | s->id = cmsdk_apb_watchdog_id; | ||
70 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_realize(DeviceState *dev, Error **errp) | ||
71 | |||
72 | static const VMStateDescription cmsdk_apb_watchdog_vmstate = { | ||
73 | .name = "cmsdk-apb-watchdog", | ||
74 | - .version_id = 1, | ||
75 | - .minimum_version_id = 1, | ||
76 | + .version_id = 2, | ||
77 | + .minimum_version_id = 2, | ||
78 | .fields = (VMStateField[]) { | ||
79 | + VMSTATE_CLOCK(wdogclk, CMSDKAPBWatchdog), | ||
80 | VMSTATE_PTIMER(timer, CMSDKAPBWatchdog), | ||
81 | VMSTATE_UINT32(control, CMSDKAPBWatchdog), | ||
82 | VMSTATE_UINT32(intstatus, CMSDKAPBWatchdog), | ||
37 | -- | 83 | -- |
38 | 2.20.1 | 84 | 2.20.1 |
39 | 85 | ||
40 | 86 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | While we transition the ARMSSE code from integer properties |
---|---|---|---|
2 | specifying clock frequencies to Clock objects, we want to have the | ||
3 | device provide both at once. We want the final name of the main | ||
4 | input Clock to be "MAINCLK", following the hardware name. | ||
5 | Unfortunately creating an input Clock with a name X creates an | ||
6 | under-the-hood QOM property X; for "MAINCLK" this clashes with the | ||
7 | existing UINT32 property of that name. | ||
2 | 8 | ||
3 | The Aspeed SoCs have two MACs. Extend the Aspeed model to support a | 9 | Rename the UINT32 property to MAINCLK_FRQ so it can coexist with the |
4 | second NIC. | 10 | MAINCLK Clock; once the transition is complete MAINCLK_FRQ will be |
11 | deleted. | ||
5 | 12 | ||
6 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 13 | Commit created with: |
7 | Reviewed-by: Joel Stanley <joel@jms.id.au> | 14 | perl -p -i -e 's/MAINCLK/MAINCLK_FRQ/g' hw/arm/{armsse,mps2-tz,musca}.c include/hw/arm/armsse.h |
8 | Message-id: 20190618165311.27066-7-clg@kaod.org | 15 | |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
18 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
19 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
20 | Message-id: 20210128114145.20536-11-peter.maydell@linaro.org | ||
21 | Message-id: 20210121190622.22000-11-peter.maydell@linaro.org | ||
10 | --- | 22 | --- |
11 | include/hw/arm/aspeed_soc.h | 3 ++- | 23 | include/hw/arm/armsse.h | 2 +- |
12 | hw/arm/aspeed_soc.c | 33 +++++++++++++++++++-------------- | 24 | hw/arm/armsse.c | 6 +++--- |
13 | 2 files changed, 21 insertions(+), 15 deletions(-) | 25 | hw/arm/mps2-tz.c | 2 +- |
26 | hw/arm/musca.c | 2 +- | ||
27 | 4 files changed, 6 insertions(+), 6 deletions(-) | ||
14 | 28 | ||
15 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h | 29 | diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h |
16 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/include/hw/arm/aspeed_soc.h | 31 | --- a/include/hw/arm/armsse.h |
18 | +++ b/include/hw/arm/aspeed_soc.h | 32 | +++ b/include/hw/arm/armsse.h |
19 | @@ -XXX,XX +XXX,XX @@ | 33 | @@ -XXX,XX +XXX,XX @@ |
20 | #define ASPEED_SPIS_NUM 2 | 34 | * QEMU interface: |
21 | #define ASPEED_WDTS_NUM 3 | 35 | * + QOM property "memory" is a MemoryRegion containing the devices provided |
22 | #define ASPEED_CPUS_NUM 2 | 36 | * by the board model. |
23 | +#define ASPEED_MACS_NUM 2 | 37 | - * + QOM property "MAINCLK" is the frequency of the main system clock |
24 | 38 | + * + QOM property "MAINCLK_FRQ" is the frequency of the main system clock | |
25 | typedef struct AspeedSoCState { | 39 | * + QOM property "EXP_NUMIRQ" sets the number of expansion interrupts. |
26 | /*< private >*/ | 40 | * (In hardware, the SSE-200 permits the number of expansion interrupts |
27 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState { | 41 | * for the two CPUs to be configured separately, but we restrict it to |
28 | AspeedSMCState spi[ASPEED_SPIS_NUM]; | 42 | diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c |
29 | AspeedSDMCState sdmc; | ||
30 | AspeedWDTState wdt[ASPEED_WDTS_NUM]; | ||
31 | - FTGMAC100State ftgmac100; | ||
32 | + FTGMAC100State ftgmac100[ASPEED_MACS_NUM]; | ||
33 | } AspeedSoCState; | ||
34 | |||
35 | #define TYPE_ASPEED_SOC "aspeed-soc" | ||
36 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | 43 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/hw/arm/aspeed_soc.c | 44 | --- a/hw/arm/armsse.c |
39 | +++ b/hw/arm/aspeed_soc.c | 45 | +++ b/hw/arm/armsse.c |
40 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | 46 | @@ -XXX,XX +XXX,XX @@ static Property iotkit_properties[] = { |
41 | sc->info->silicon_rev); | 47 | DEFINE_PROP_LINK("memory", ARMSSE, board_memory, TYPE_MEMORY_REGION, |
48 | MemoryRegion *), | ||
49 | DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64), | ||
50 | - DEFINE_PROP_UINT32("MAINCLK", ARMSSE, mainclk_frq, 0), | ||
51 | + DEFINE_PROP_UINT32("MAINCLK_FRQ", ARMSSE, mainclk_frq, 0), | ||
52 | DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 15), | ||
53 | DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000), | ||
54 | DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], true), | ||
55 | @@ -XXX,XX +XXX,XX @@ static Property armsse_properties[] = { | ||
56 | DEFINE_PROP_LINK("memory", ARMSSE, board_memory, TYPE_MEMORY_REGION, | ||
57 | MemoryRegion *), | ||
58 | DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64), | ||
59 | - DEFINE_PROP_UINT32("MAINCLK", ARMSSE, mainclk_frq, 0), | ||
60 | + DEFINE_PROP_UINT32("MAINCLK_FRQ", ARMSSE, mainclk_frq, 0), | ||
61 | DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 15), | ||
62 | DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000), | ||
63 | DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], false), | ||
64 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) | ||
42 | } | 65 | } |
43 | 66 | ||
44 | - sysbus_init_child_obj(obj, "ftgmac100", OBJECT(&s->ftgmac100), | 67 | if (!s->mainclk_frq) { |
45 | - sizeof(s->ftgmac100), TYPE_FTGMAC100); | 68 | - error_setg(errp, "MAINCLK property was not set"); |
46 | + for (i = 0; i < ASPEED_MACS_NUM; i++) { | 69 | + error_setg(errp, "MAINCLK_FRQ property was not set"); |
47 | + sysbus_init_child_obj(obj, "ftgmac100[*]", OBJECT(&s->ftgmac100[i]), | 70 | return; |
48 | + sizeof(s->ftgmac100[i]), TYPE_FTGMAC100); | ||
49 | + } | ||
50 | } | ||
51 | |||
52 | static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
53 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
54 | } | 71 | } |
55 | 72 | ||
56 | /* Net */ | 73 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c |
57 | - qdev_set_nic_properties(DEVICE(&s->ftgmac100), &nd_table[0]); | 74 | index XXXXXXX..XXXXXXX 100644 |
58 | - object_property_set_bool(OBJECT(&s->ftgmac100), true, "aspeed", &err); | 75 | --- a/hw/arm/mps2-tz.c |
59 | - object_property_set_bool(OBJECT(&s->ftgmac100), true, "realized", | 76 | +++ b/hw/arm/mps2-tz.c |
60 | - &local_err); | 77 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) |
61 | - error_propagate(&err, local_err); | 78 | object_property_set_link(OBJECT(&mms->iotkit), "memory", |
62 | - if (err) { | 79 | OBJECT(system_memory), &error_abort); |
63 | - error_propagate(errp, err); | 80 | qdev_prop_set_uint32(iotkitdev, "EXP_NUMIRQ", MPS2TZ_NUMIRQ); |
64 | - return; | 81 | - qdev_prop_set_uint32(iotkitdev, "MAINCLK", SYSCLK_FRQ); |
65 | + for (i = 0; i < nb_nics; i++) { | 82 | + qdev_prop_set_uint32(iotkitdev, "MAINCLK_FRQ", SYSCLK_FRQ); |
66 | + qdev_set_nic_properties(DEVICE(&s->ftgmac100[i]), &nd_table[i]); | 83 | sysbus_realize(SYS_BUS_DEVICE(&mms->iotkit), &error_fatal); |
67 | + object_property_set_bool(OBJECT(&s->ftgmac100[i]), true, "aspeed", | 84 | |
68 | + &err); | 85 | /* |
69 | + object_property_set_bool(OBJECT(&s->ftgmac100[i]), true, "realized", | 86 | diff --git a/hw/arm/musca.c b/hw/arm/musca.c |
70 | + &local_err); | 87 | index XXXXXXX..XXXXXXX 100644 |
71 | + error_propagate(&err, local_err); | 88 | --- a/hw/arm/musca.c |
72 | + if (err) { | 89 | +++ b/hw/arm/musca.c |
73 | + error_propagate(errp, err); | 90 | @@ -XXX,XX +XXX,XX @@ static void musca_init(MachineState *machine) |
74 | + return; | 91 | qdev_prop_set_uint32(ssedev, "EXP_NUMIRQ", mmc->num_irqs); |
75 | + } | 92 | qdev_prop_set_uint32(ssedev, "init-svtor", mmc->init_svtor); |
76 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, | 93 | qdev_prop_set_uint32(ssedev, "SRAM_ADDR_WIDTH", mmc->sram_addr_width); |
77 | + sc->info->memmap[ASPEED_ETH1 + i]); | 94 | - qdev_prop_set_uint32(ssedev, "MAINCLK", SYSCLK_FRQ); |
78 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0, | 95 | + qdev_prop_set_uint32(ssedev, "MAINCLK_FRQ", SYSCLK_FRQ); |
79 | + aspeed_soc_get_irq(s, ASPEED_ETH1 + i)); | 96 | /* |
80 | } | 97 | * Musca-A takes the default SSE-200 FPU/DSP settings (ie no for |
81 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100), 0, | 98 | * CPU0 and yes for CPU1); Musca-B1 explicitly enables them for CPU0. |
82 | - sc->info->memmap[ASPEED_ETH1]); | ||
83 | - sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100), 0, | ||
84 | - aspeed_soc_get_irq(s, ASPEED_ETH1)); | ||
85 | } | ||
86 | static Property aspeed_soc_properties[] = { | ||
87 | DEFINE_PROP_UINT32("num-cpus", AspeedSoCState, num_cpus, 0), | ||
88 | -- | 99 | -- |
89 | 2.20.1 | 100 | 2.20.1 |
90 | 101 | ||
91 | 102 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | Create two input clocks on the ARMSSE devices, one for the normal |
---|---|---|---|
2 | MAINCLK, and one for the 32KHz S32KCLK, and wire these up to the | ||
3 | appropriate devices. The old property-based clock frequency setting | ||
4 | will remain in place until conversion is complete. | ||
2 | 5 | ||
3 | This will simplify the definition of new SoCs, like the AST2600 which | 6 | This is a migration compatibility break for machines mps2-an505, |
4 | should use a slightly different address space and have a different set | 7 | mps2-an521, musca-a, musca-b1. |
5 | of controllers. | ||
6 | 8 | ||
7 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
10 | Message-id: 20190618165311.27066-3-clg@kaod.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
12 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | Message-id: 20210128114145.20536-12-peter.maydell@linaro.org | ||
14 | Message-id: 20210121190622.22000-12-peter.maydell@linaro.org | ||
12 | --- | 15 | --- |
13 | include/hw/arm/aspeed_soc.h | 4 +- | 16 | include/hw/arm/armsse.h | 6 ++++++ |
14 | hw/arm/aspeed.c | 8 +-- | 17 | hw/arm/armsse.c | 17 +++++++++++++++-- |
15 | hw/arm/aspeed_soc.c | 117 ++++++++++++++++++++++-------------- | 18 | 2 files changed, 21 insertions(+), 2 deletions(-) |
16 | 3 files changed, 78 insertions(+), 51 deletions(-) | ||
17 | 19 | ||
18 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h | 20 | diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h |
19 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/include/hw/arm/aspeed_soc.h | 22 | --- a/include/hw/arm/armsse.h |
21 | +++ b/include/hw/arm/aspeed_soc.h | 23 | +++ b/include/hw/arm/armsse.h |
22 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCInfo { | 24 | @@ -XXX,XX +XXX,XX @@ |
23 | const char *name; | 25 | * per-CPU identity and control register blocks |
24 | const char *cpu_type; | 26 | * |
25 | uint32_t silicon_rev; | 27 | * QEMU interface: |
26 | - hwaddr sdram_base; | 28 | + * + Clock input "MAINCLK": clock for CPUs and most peripherals |
27 | uint64_t sram_size; | 29 | + * + Clock input "S32KCLK": slow 32KHz clock used for a few peripherals |
28 | int spis_num; | 30 | * + QOM property "memory" is a MemoryRegion containing the devices provided |
29 | - const hwaddr *spi_bases; | 31 | * by the board model. |
30 | const char *fmc_typename; | 32 | * + QOM property "MAINCLK_FRQ" is the frequency of the main system clock |
31 | const char **spi_typename; | 33 | @@ -XXX,XX +XXX,XX @@ |
32 | int wdts_num; | 34 | #include "hw/misc/armsse-mhu.h" |
33 | const int *irqmap; | 35 | #include "hw/misc/unimp.h" |
34 | + const hwaddr *memmap; | 36 | #include "hw/or-irq.h" |
35 | } AspeedSoCInfo; | 37 | +#include "hw/clock.h" |
36 | 38 | #include "hw/core/split-irq.h" | |
37 | typedef struct AspeedSoCClass { | 39 | #include "hw/cpu/cluster.h" |
38 | @@ -XXX,XX +XXX,XX @@ enum { | 40 | #include "qom/object.h" |
39 | ASPEED_I2C, | 41 | @@ -XXX,XX +XXX,XX @@ struct ARMSSE { |
40 | ASPEED_ETH1, | 42 | |
41 | ASPEED_ETH2, | 43 | uint32_t nsccfg; |
42 | + ASPEED_SDRAM, | 44 | |
43 | }; | 45 | + Clock *mainclk; |
44 | 46 | + Clock *s32kclk; | |
45 | #endif /* ASPEED_SOC_H */ | 47 | + |
46 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | 48 | /* Properties */ |
49 | MemoryRegion *board_memory; | ||
50 | uint32_t exp_numirq; | ||
51 | diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | 52 | index XXXXXXX..XXXXXXX 100644 |
48 | --- a/hw/arm/aspeed.c | 53 | --- a/hw/arm/armsse.c |
49 | +++ b/hw/arm/aspeed.c | 54 | +++ b/hw/arm/armsse.c |
50 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | ||
51 | &error_abort); | ||
52 | |||
53 | memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size); | ||
54 | - memory_region_add_subregion(get_system_memory(), sc->info->sdram_base, | ||
55 | - &bmc->ram); | ||
56 | + memory_region_add_subregion(get_system_memory(), | ||
57 | + sc->info->memmap[ASPEED_SDRAM], &bmc->ram); | ||
58 | object_property_add_const_link(OBJECT(&bmc->soc), "ram", OBJECT(&bmc->ram), | ||
59 | &error_abort); | ||
60 | |||
61 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | ||
62 | memory_region_init_io(&bmc->max_ram, NULL, &max_ram_ops, NULL, | ||
63 | "max_ram", max_ram_size - ram_size); | ||
64 | memory_region_add_subregion(get_system_memory(), | ||
65 | - sc->info->sdram_base + ram_size, | ||
66 | + sc->info->memmap[ASPEED_SDRAM] + ram_size, | ||
67 | &bmc->max_ram); | ||
68 | |||
69 | aspeed_board_init_flashes(&bmc->soc.fmc, cfg->fmc_model, &error_abort); | ||
70 | @@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine, | ||
71 | aspeed_board_binfo.initrd_filename = machine->initrd_filename; | ||
72 | aspeed_board_binfo.kernel_cmdline = machine->kernel_cmdline; | ||
73 | aspeed_board_binfo.ram_size = ram_size; | ||
74 | - aspeed_board_binfo.loader_start = sc->info->sdram_base; | ||
75 | + aspeed_board_binfo.loader_start = sc->info->memmap[ASPEED_SDRAM]; | ||
76 | |||
77 | if (cfg->i2c_init) { | ||
78 | cfg->i2c_init(bmc); | ||
79 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
80 | index XXXXXXX..XXXXXXX 100644 | ||
81 | --- a/hw/arm/aspeed_soc.c | ||
82 | +++ b/hw/arm/aspeed_soc.c | ||
83 | @@ -XXX,XX +XXX,XX @@ | 55 | @@ -XXX,XX +XXX,XX @@ |
84 | #include "hw/i2c/aspeed_i2c.h" | 56 | #include "hw/arm/armsse.h" |
85 | #include "net/net.h" | 57 | #include "hw/arm/boot.h" |
86 | 58 | #include "hw/irq.h" | |
87 | -#define ASPEED_SOC_UART_5_BASE 0x00184000 | 59 | +#include "hw/qdev-clock.h" |
88 | #define ASPEED_SOC_IOMEM_SIZE 0x00200000 | 60 | |
89 | -#define ASPEED_SOC_IOMEM_BASE 0x1E600000 | 61 | /* Format of the System Information block SYS_CONFIG register */ |
90 | -#define ASPEED_SOC_FMC_BASE 0x1E620000 | 62 | typedef enum SysConfigFormat { |
91 | -#define ASPEED_SOC_SPI_BASE 0x1E630000 | 63 | @@ -XXX,XX +XXX,XX @@ static void armsse_init(Object *obj) |
92 | -#define ASPEED_SOC_SPI2_BASE 0x1E631000 | 64 | assert(info->sram_banks <= MAX_SRAM_BANKS); |
93 | -#define ASPEED_SOC_VIC_BASE 0x1E6C0000 | 65 | assert(info->num_cpus <= SSE_MAX_CPUS); |
94 | -#define ASPEED_SOC_SDMC_BASE 0x1E6E0000 | 66 | |
95 | -#define ASPEED_SOC_SCU_BASE 0x1E6E2000 | 67 | + s->mainclk = qdev_init_clock_in(DEVICE(s), "MAINCLK", NULL, NULL); |
96 | -#define ASPEED_SOC_SRAM_BASE 0x1E720000 | 68 | + s->s32kclk = qdev_init_clock_in(DEVICE(s), "S32KCLK", NULL, NULL); |
97 | -#define ASPEED_SOC_TIMER_BASE 0x1E782000 | ||
98 | -#define ASPEED_SOC_WDT_BASE 0x1E785000 | ||
99 | -#define ASPEED_SOC_I2C_BASE 0x1E78A000 | ||
100 | -#define ASPEED_SOC_ETH1_BASE 0x1E660000 | ||
101 | -#define ASPEED_SOC_ETH2_BASE 0x1E680000 | ||
102 | + | 69 | + |
103 | +static const hwaddr aspeed_soc_ast2400_memmap[] = { | 70 | memory_region_init(&s->container, obj, "armsse-container", UINT64_MAX); |
104 | + [ASPEED_IOMEM] = 0x1E600000, | 71 | |
105 | + [ASPEED_FMC] = 0x1E620000, | 72 | for (i = 0; i < info->num_cpus; i++) { |
106 | + [ASPEED_SPI1] = 0x1E630000, | 73 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) |
107 | + [ASPEED_VIC] = 0x1E6C0000, | 74 | * map its upstream ends to the right place in the container. |
108 | + [ASPEED_SDMC] = 0x1E6E0000, | 75 | */ |
109 | + [ASPEED_SCU] = 0x1E6E2000, | 76 | qdev_prop_set_uint32(DEVICE(&s->timer0), "pclk-frq", s->mainclk_frq); |
110 | + [ASPEED_ADC] = 0x1E6E9000, | 77 | + qdev_connect_clock_in(DEVICE(&s->timer0), "pclk", s->mainclk); |
111 | + [ASPEED_SRAM] = 0x1E720000, | 78 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->timer0), errp)) { |
112 | + [ASPEED_GPIO] = 0x1E780000, | ||
113 | + [ASPEED_RTC] = 0x1E781000, | ||
114 | + [ASPEED_TIMER1] = 0x1E782000, | ||
115 | + [ASPEED_WDT] = 0x1E785000, | ||
116 | + [ASPEED_PWM] = 0x1E786000, | ||
117 | + [ASPEED_LPC] = 0x1E789000, | ||
118 | + [ASPEED_IBT] = 0x1E789140, | ||
119 | + [ASPEED_I2C] = 0x1E78A000, | ||
120 | + [ASPEED_ETH1] = 0x1E660000, | ||
121 | + [ASPEED_ETH2] = 0x1E680000, | ||
122 | + [ASPEED_UART1] = 0x1E783000, | ||
123 | + [ASPEED_UART5] = 0x1E784000, | ||
124 | + [ASPEED_VUART] = 0x1E787000, | ||
125 | + [ASPEED_SDRAM] = 0x40000000, | ||
126 | +}; | ||
127 | + | ||
128 | +static const hwaddr aspeed_soc_ast2500_memmap[] = { | ||
129 | + [ASPEED_IOMEM] = 0x1E600000, | ||
130 | + [ASPEED_FMC] = 0x1E620000, | ||
131 | + [ASPEED_SPI1] = 0x1E630000, | ||
132 | + [ASPEED_SPI2] = 0x1E631000, | ||
133 | + [ASPEED_VIC] = 0x1E6C0000, | ||
134 | + [ASPEED_SDMC] = 0x1E6E0000, | ||
135 | + [ASPEED_SCU] = 0x1E6E2000, | ||
136 | + [ASPEED_ADC] = 0x1E6E9000, | ||
137 | + [ASPEED_SRAM] = 0x1E720000, | ||
138 | + [ASPEED_GPIO] = 0x1E780000, | ||
139 | + [ASPEED_RTC] = 0x1E781000, | ||
140 | + [ASPEED_TIMER1] = 0x1E782000, | ||
141 | + [ASPEED_WDT] = 0x1E785000, | ||
142 | + [ASPEED_PWM] = 0x1E786000, | ||
143 | + [ASPEED_LPC] = 0x1E789000, | ||
144 | + [ASPEED_IBT] = 0x1E789140, | ||
145 | + [ASPEED_I2C] = 0x1E78A000, | ||
146 | + [ASPEED_ETH1] = 0x1E660000, | ||
147 | + [ASPEED_ETH2] = 0x1E680000, | ||
148 | + [ASPEED_UART1] = 0x1E783000, | ||
149 | + [ASPEED_UART5] = 0x1E784000, | ||
150 | + [ASPEED_VUART] = 0x1E787000, | ||
151 | + [ASPEED_SDRAM] = 0x80000000, | ||
152 | +}; | ||
153 | |||
154 | static const int aspeed_soc_ast2400_irqmap[] = { | ||
155 | [ASPEED_UART1] = 9, | ||
156 | @@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2400_irqmap[] = { | ||
157 | [ASPEED_ETH2] = 3, | ||
158 | }; | ||
159 | |||
160 | -#define AST2400_SDRAM_BASE 0x40000000 | ||
161 | -#define AST2500_SDRAM_BASE 0x80000000 | ||
162 | - | ||
163 | -/* AST2500 uses the same IRQs as the AST2400 */ | ||
164 | #define aspeed_soc_ast2500_irqmap aspeed_soc_ast2400_irqmap | ||
165 | |||
166 | -static const hwaddr aspeed_soc_ast2400_spi_bases[] = { ASPEED_SOC_SPI_BASE }; | ||
167 | static const char *aspeed_soc_ast2400_typenames[] = { "aspeed.smc.spi" }; | ||
168 | - | ||
169 | -static const hwaddr aspeed_soc_ast2500_spi_bases[] = { ASPEED_SOC_SPI_BASE, | ||
170 | - ASPEED_SOC_SPI2_BASE}; | ||
171 | static const char *aspeed_soc_ast2500_typenames[] = { | ||
172 | "aspeed.smc.ast2500-spi1", "aspeed.smc.ast2500-spi2" }; | ||
173 | |||
174 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | ||
175 | .name = "ast2400-a0", | ||
176 | .cpu_type = ARM_CPU_TYPE_NAME("arm926"), | ||
177 | .silicon_rev = AST2400_A0_SILICON_REV, | ||
178 | - .sdram_base = AST2400_SDRAM_BASE, | ||
179 | .sram_size = 0x8000, | ||
180 | .spis_num = 1, | ||
181 | - .spi_bases = aspeed_soc_ast2400_spi_bases, | ||
182 | .fmc_typename = "aspeed.smc.fmc", | ||
183 | .spi_typename = aspeed_soc_ast2400_typenames, | ||
184 | .wdts_num = 2, | ||
185 | .irqmap = aspeed_soc_ast2400_irqmap, | ||
186 | + .memmap = aspeed_soc_ast2400_memmap, | ||
187 | }, { | ||
188 | .name = "ast2400-a1", | ||
189 | .cpu_type = ARM_CPU_TYPE_NAME("arm926"), | ||
190 | .silicon_rev = AST2400_A1_SILICON_REV, | ||
191 | - .sdram_base = AST2400_SDRAM_BASE, | ||
192 | .sram_size = 0x8000, | ||
193 | .spis_num = 1, | ||
194 | - .spi_bases = aspeed_soc_ast2400_spi_bases, | ||
195 | .fmc_typename = "aspeed.smc.fmc", | ||
196 | .spi_typename = aspeed_soc_ast2400_typenames, | ||
197 | .wdts_num = 2, | ||
198 | .irqmap = aspeed_soc_ast2400_irqmap, | ||
199 | + .memmap = aspeed_soc_ast2400_memmap, | ||
200 | }, { | ||
201 | .name = "ast2400", | ||
202 | .cpu_type = ARM_CPU_TYPE_NAME("arm926"), | ||
203 | .silicon_rev = AST2400_A0_SILICON_REV, | ||
204 | - .sdram_base = AST2400_SDRAM_BASE, | ||
205 | .sram_size = 0x8000, | ||
206 | .spis_num = 1, | ||
207 | - .spi_bases = aspeed_soc_ast2400_spi_bases, | ||
208 | .fmc_typename = "aspeed.smc.fmc", | ||
209 | .spi_typename = aspeed_soc_ast2400_typenames, | ||
210 | .wdts_num = 2, | ||
211 | .irqmap = aspeed_soc_ast2400_irqmap, | ||
212 | + .memmap = aspeed_soc_ast2400_memmap, | ||
213 | }, { | ||
214 | .name = "ast2500-a1", | ||
215 | .cpu_type = ARM_CPU_TYPE_NAME("arm1176"), | ||
216 | .silicon_rev = AST2500_A1_SILICON_REV, | ||
217 | - .sdram_base = AST2500_SDRAM_BASE, | ||
218 | .sram_size = 0x9000, | ||
219 | .spis_num = 2, | ||
220 | - .spi_bases = aspeed_soc_ast2500_spi_bases, | ||
221 | .fmc_typename = "aspeed.smc.ast2500-fmc", | ||
222 | .spi_typename = aspeed_soc_ast2500_typenames, | ||
223 | .wdts_num = 3, | ||
224 | .irqmap = aspeed_soc_ast2500_irqmap, | ||
225 | + .memmap = aspeed_soc_ast2500_memmap, | ||
226 | }, | ||
227 | }; | ||
228 | |||
229 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
230 | Error *err = NULL, *local_err = NULL; | ||
231 | |||
232 | /* IO space */ | ||
233 | - create_unimplemented_device("aspeed_soc.io", | ||
234 | - ASPEED_SOC_IOMEM_BASE, ASPEED_SOC_IOMEM_SIZE); | ||
235 | + create_unimplemented_device("aspeed_soc.io", sc->info->memmap[ASPEED_IOMEM], | ||
236 | + ASPEED_SOC_IOMEM_SIZE); | ||
237 | |||
238 | /* CPU */ | ||
239 | object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err); | ||
240 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
241 | error_propagate(errp, err); | ||
242 | return; | 79 | return; |
243 | } | 80 | } |
244 | - memory_region_add_subregion(get_system_memory(), ASPEED_SOC_SRAM_BASE, | 81 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) |
245 | - &s->sram); | 82 | &error_abort); |
246 | + memory_region_add_subregion(get_system_memory(), | 83 | |
247 | + sc->info->memmap[ASPEED_SRAM], &s->sram); | 84 | qdev_prop_set_uint32(DEVICE(&s->timer1), "pclk-frq", s->mainclk_frq); |
248 | 85 | + qdev_connect_clock_in(DEVICE(&s->timer1), "pclk", s->mainclk); | |
249 | /* SCU */ | 86 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->timer1), errp)) { |
250 | object_property_set_bool(OBJECT(&s->scu), true, "realized", &err); | ||
251 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
252 | error_propagate(errp, err); | ||
253 | return; | 87 | return; |
254 | } | 88 | } |
255 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->scu), 0, ASPEED_SOC_SCU_BASE); | 89 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) |
256 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->scu), 0, sc->info->memmap[ASPEED_SCU]); | 90 | &error_abort); |
257 | 91 | ||
258 | /* VIC */ | 92 | qdev_prop_set_uint32(DEVICE(&s->dualtimer), "pclk-frq", s->mainclk_frq); |
259 | object_property_set_bool(OBJECT(&s->vic), true, "realized", &err); | 93 | + qdev_connect_clock_in(DEVICE(&s->dualtimer), "TIMCLK", s->mainclk); |
260 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | 94 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->dualtimer), errp)) { |
261 | error_propagate(errp, err); | ||
262 | return; | 95 | return; |
263 | } | 96 | } |
264 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->vic), 0, ASPEED_SOC_VIC_BASE); | 97 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) |
265 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->vic), 0, sc->info->memmap[ASPEED_VIC]); | 98 | * 0x4002f000: S32K timer |
266 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->vic), 0, | 99 | */ |
267 | qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_IRQ)); | 100 | qdev_prop_set_uint32(DEVICE(&s->s32ktimer), "pclk-frq", S32KCLK); |
268 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->vic), 1, | 101 | + qdev_connect_clock_in(DEVICE(&s->s32ktimer), "pclk", s->s32kclk); |
269 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | 102 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->s32ktimer), errp)) { |
270 | error_propagate(errp, err); | ||
271 | return; | 103 | return; |
272 | } | 104 | } |
273 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->timerctrl), 0, ASPEED_SOC_TIMER_BASE); | 105 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) |
274 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->timerctrl), 0, | 106 | qdev_get_gpio_in_named(DEVICE(&s->armv7m), "NMI", 0)); |
275 | + sc->info->memmap[ASPEED_TIMER1]); | 107 | |
276 | for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) { | 108 | qdev_prop_set_uint32(DEVICE(&s->s32kwatchdog), "wdogclk-frq", S32KCLK); |
277 | qemu_irq irq = aspeed_soc_get_irq(s, ASPEED_TIMER1 + i); | 109 | + qdev_connect_clock_in(DEVICE(&s->s32kwatchdog), "WDOGCLK", s->s32kclk); |
278 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->timerctrl), i, irq); | 110 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->s32kwatchdog), errp)) { |
279 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
280 | /* UART - attach an 8250 to the IO space as our UART5 */ | ||
281 | if (serial_hd(0)) { | ||
282 | qemu_irq uart5 = aspeed_soc_get_irq(s, ASPEED_UART5); | ||
283 | - serial_mm_init(get_system_memory(), | ||
284 | - ASPEED_SOC_IOMEM_BASE + ASPEED_SOC_UART_5_BASE, 2, | ||
285 | + serial_mm_init(get_system_memory(), sc->info->memmap[ASPEED_UART5], 2, | ||
286 | uart5, 38400, serial_hd(0), DEVICE_LITTLE_ENDIAN); | ||
287 | } | ||
288 | |||
289 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
290 | error_propagate(errp, err); | ||
291 | return; | 111 | return; |
292 | } | 112 | } |
293 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c), 0, ASPEED_SOC_I2C_BASE); | 113 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) |
294 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c), 0, sc->info->memmap[ASPEED_I2C]); | 114 | /* 0x40080000 .. 0x4008ffff : ARMSSE second Base peripheral region */ |
295 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c), 0, | 115 | |
296 | aspeed_soc_get_irq(s, ASPEED_I2C)); | 116 | qdev_prop_set_uint32(DEVICE(&s->nswatchdog), "wdogclk-frq", s->mainclk_frq); |
297 | 117 | + qdev_connect_clock_in(DEVICE(&s->nswatchdog), "WDOGCLK", s->mainclk); | |
298 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | 118 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->nswatchdog), errp)) { |
299 | error_propagate(errp, err); | ||
300 | return; | 119 | return; |
301 | } | 120 | } |
302 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 0, ASPEED_SOC_FMC_BASE); | 121 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) |
303 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 0, sc->info->memmap[ASPEED_FMC]); | 122 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->nswatchdog), 0, 0x40081000); |
304 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 1, | 123 | |
305 | s->fmc.ctrl->flash_window_base); | 124 | qdev_prop_set_uint32(DEVICE(&s->swatchdog), "wdogclk-frq", s->mainclk_frq); |
306 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->fmc), 0, | 125 | + qdev_connect_clock_in(DEVICE(&s->swatchdog), "WDOGCLK", s->mainclk); |
307 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | 126 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->swatchdog), errp)) { |
308 | error_propagate(errp, err); | ||
309 | return; | ||
310 | } | ||
311 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, sc->info->spi_bases[i]); | ||
312 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, | ||
313 | + sc->info->memmap[ASPEED_SPI1 + i]); | ||
314 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 1, | ||
315 | s->spi[i].ctrl->flash_window_base); | ||
316 | } | ||
317 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
318 | error_propagate(errp, err); | ||
319 | return; | 127 | return; |
320 | } | 128 | } |
321 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdmc), 0, ASPEED_SOC_SDMC_BASE); | 129 | @@ -XXX,XX +XXX,XX @@ static void armsse_idau_check(IDAUInterface *ii, uint32_t address, |
322 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdmc), 0, sc->info->memmap[ASPEED_SDMC]); | 130 | |
323 | 131 | static const VMStateDescription armsse_vmstate = { | |
324 | /* Watch dog */ | 132 | .name = "iotkit", |
325 | for (i = 0; i < sc->info->wdts_num; i++) { | 133 | - .version_id = 1, |
326 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | 134 | - .minimum_version_id = 1, |
327 | return; | 135 | + .version_id = 2, |
328 | } | 136 | + .minimum_version_id = 2, |
329 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt[i]), 0, | 137 | .fields = (VMStateField[]) { |
330 | - ASPEED_SOC_WDT_BASE + i * 0x20); | 138 | + VMSTATE_CLOCK(mainclk, ARMSSE), |
331 | + sc->info->memmap[ASPEED_WDT] + i * 0x20); | 139 | + VMSTATE_CLOCK(s32kclk, ARMSSE), |
140 | VMSTATE_UINT32(nsccfg, ARMSSE), | ||
141 | VMSTATE_END_OF_LIST() | ||
332 | } | 142 | } |
333 | |||
334 | /* Net */ | ||
335 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
336 | error_propagate(errp, err); | ||
337 | return; | ||
338 | } | ||
339 | - sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100), 0, ASPEED_SOC_ETH1_BASE); | ||
340 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100), 0, | ||
341 | + sc->info->memmap[ASPEED_ETH1]); | ||
342 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100), 0, | ||
343 | aspeed_soc_get_irq(s, ASPEED_ETH1)); | ||
344 | } | ||
345 | -- | 143 | -- |
346 | 2.20.1 | 144 | 2.20.1 |
347 | 145 | ||
348 | 146 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | The old-style convenience function cmsdk_apb_timer_create() for |
---|---|---|---|
2 | creating CMSDK_APB_TIMER objects is used in only two places in | ||
3 | mps2.c. Most of the rest of the code in that file uses the new | ||
4 | "initialize in place" coding style. | ||
2 | 5 | ||
3 | The ast2500 uses the watchdog to reset the SDRAM controller. This | 6 | We want to connect up a Clock object which should be done between the |
4 | operation is usually performed by u-boot's memory training procedure, | 7 | object creation and realization; rather than adding a Clock* argument |
5 | and it is enabled by setting a bit in the SCU and then causing the | 8 | to the convenience function, convert the timer creation code in |
6 | watchdog to expire. Therefore, we need the watchdog to be able to | 9 | mps2.c to the same style as is used already for the watchdog, |
7 | access the SCU's register space. | 10 | dualtimer and other devices, and delete the now-unused convenience |
11 | function. | ||
8 | 12 | ||
9 | This causes the watchdog to not perform a system reset when the bit is | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | set. In the future it could perform a reset of the SDMC model. | 14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
15 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
16 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
17 | Message-id: 20210128114145.20536-13-peter.maydell@linaro.org | ||
18 | Message-id: 20210121190622.22000-13-peter.maydell@linaro.org | ||
19 | --- | ||
20 | include/hw/timer/cmsdk-apb-timer.h | 21 --------------------- | ||
21 | hw/arm/mps2.c | 18 ++++++++++++++++-- | ||
22 | 2 files changed, 16 insertions(+), 23 deletions(-) | ||
11 | 23 | ||
12 | Signed-off-by: Joel Stanley <joel@jms.id.au> | 24 | diff --git a/include/hw/timer/cmsdk-apb-timer.h b/include/hw/timer/cmsdk-apb-timer.h |
13 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
14 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
15 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
16 | Message-id: 20190621065242.32535-1-joel@jms.id.au | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | --- | ||
19 | include/hw/watchdog/wdt_aspeed.h | 1 + | ||
20 | hw/arm/aspeed_soc.c | 2 ++ | ||
21 | hw/watchdog/wdt_aspeed.c | 20 ++++++++++++++++++++ | ||
22 | 3 files changed, 23 insertions(+) | ||
23 | |||
24 | diff --git a/include/hw/watchdog/wdt_aspeed.h b/include/hw/watchdog/wdt_aspeed.h | ||
25 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/hw/watchdog/wdt_aspeed.h | 26 | --- a/include/hw/timer/cmsdk-apb-timer.h |
27 | +++ b/include/hw/watchdog/wdt_aspeed.h | 27 | +++ b/include/hw/timer/cmsdk-apb-timer.h |
28 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedWDTState { | 28 | @@ -XXX,XX +XXX,XX @@ struct CMSDKAPBTimer { |
29 | MemoryRegion iomem; | 29 | uint32_t intstatus; |
30 | uint32_t regs[ASPEED_WDT_REGS_MAX]; | 30 | }; |
31 | 31 | ||
32 | + AspeedSCUState *scu; | 32 | -/** |
33 | uint32_t pclk_freq; | 33 | - * cmsdk_apb_timer_create - convenience function to create TYPE_CMSDK_APB_TIMER |
34 | uint32_t silicon_rev; | 34 | - * @addr: location in system memory to map registers |
35 | uint32_t ext_pulse_width_mask; | 35 | - * @pclk_frq: frequency in Hz of the PCLK clock (used for calculating baud rate) |
36 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | 36 | - */ |
37 | -static inline DeviceState *cmsdk_apb_timer_create(hwaddr addr, | ||
38 | - qemu_irq timerint, | ||
39 | - uint32_t pclk_frq) | ||
40 | -{ | ||
41 | - DeviceState *dev; | ||
42 | - SysBusDevice *s; | ||
43 | - | ||
44 | - dev = qdev_new(TYPE_CMSDK_APB_TIMER); | ||
45 | - s = SYS_BUS_DEVICE(dev); | ||
46 | - qdev_prop_set_uint32(dev, "pclk-frq", pclk_frq); | ||
47 | - sysbus_realize_and_unref(s, &error_fatal); | ||
48 | - sysbus_mmio_map(s, 0, addr); | ||
49 | - sysbus_connect_irq(s, 0, timerint); | ||
50 | - return dev; | ||
51 | -} | ||
52 | - | ||
53 | #endif | ||
54 | diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | 55 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/hw/arm/aspeed_soc.c | 56 | --- a/hw/arm/mps2.c |
39 | +++ b/hw/arm/aspeed_soc.c | 57 | +++ b/hw/arm/mps2.c |
40 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj) | 58 | @@ -XXX,XX +XXX,XX @@ struct MPS2MachineState { |
41 | sizeof(s->wdt[i]), TYPE_ASPEED_WDT); | 59 | /* CMSDK APB subsystem */ |
42 | qdev_prop_set_uint32(DEVICE(&s->wdt[i]), "silicon-rev", | 60 | CMSDKAPBDualTimer dualtimer; |
43 | sc->info->silicon_rev); | 61 | CMSDKAPBWatchdog watchdog; |
44 | + object_property_add_const_link(OBJECT(&s->wdt[i]), "scu", | 62 | + CMSDKAPBTimer timer[2]; |
45 | + OBJECT(&s->scu), &error_abort); | 63 | }; |
64 | |||
65 | #define TYPE_MPS2_MACHINE "mps2" | ||
66 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) | ||
46 | } | 67 | } |
47 | 68 | ||
48 | for (i = 0; i < ASPEED_MACS_NUM; i++) { | 69 | /* CMSDK APB subsystem */ |
49 | diff --git a/hw/watchdog/wdt_aspeed.c b/hw/watchdog/wdt_aspeed.c | 70 | - cmsdk_apb_timer_create(0x40000000, qdev_get_gpio_in(armv7m, 8), SYSCLK_FRQ); |
50 | index XXXXXXX..XXXXXXX 100644 | 71 | - cmsdk_apb_timer_create(0x40001000, qdev_get_gpio_in(armv7m, 9), SYSCLK_FRQ); |
51 | --- a/hw/watchdog/wdt_aspeed.c | 72 | + for (i = 0; i < ARRAY_SIZE(mms->timer); i++) { |
52 | +++ b/hw/watchdog/wdt_aspeed.c | 73 | + g_autofree char *name = g_strdup_printf("timer%d", i); |
53 | @@ -XXX,XX +XXX,XX @@ | 74 | + hwaddr base = 0x40000000 + i * 0x1000; |
54 | 75 | + int irqno = 8 + i; | |
55 | #define WDT_RESTART_MAGIC 0x4755 | 76 | + SysBusDevice *sbd; |
56 | |||
57 | +#define SCU_RESET_CONTROL1 (0x04 / 4) | ||
58 | +#define SCU_RESET_SDRAM BIT(0) | ||
59 | + | 77 | + |
60 | static bool aspeed_wdt_is_enabled(const AspeedWDTState *s) | 78 | + object_initialize_child(OBJECT(mms), name, &mms->timer[i], |
61 | { | 79 | + TYPE_CMSDK_APB_TIMER); |
62 | return s->regs[WDT_CTRL] & WDT_CTRL_ENABLE; | 80 | + sbd = SYS_BUS_DEVICE(&mms->timer[i]); |
63 | @@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_timer_expired(void *dev) | 81 | + qdev_prop_set_uint32(DEVICE(&mms->timer[i]), "pclk-frq", SYSCLK_FRQ); |
64 | { | 82 | + sysbus_realize_and_unref(sbd, &error_fatal); |
65 | AspeedWDTState *s = ASPEED_WDT(dev); | 83 | + sysbus_mmio_map(sbd, 0, base); |
66 | 84 | + sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(armv7m, irqno)); | |
67 | + /* Do not reset on SDRAM controller reset */ | ||
68 | + if (s->scu->regs[SCU_RESET_CONTROL1] & SCU_RESET_SDRAM) { | ||
69 | + timer_del(s->timer); | ||
70 | + s->regs[WDT_CTRL] = 0; | ||
71 | + return; | ||
72 | + } | 85 | + } |
73 | + | 86 | + |
74 | qemu_log_mask(CPU_LOG_RESET, "Watchdog timer expired.\n"); | 87 | object_initialize_child(OBJECT(mms), "dualtimer", &mms->dualtimer, |
75 | watchdog_perform_action(); | 88 | TYPE_CMSDK_APB_DUALTIMER); |
76 | timer_del(s->timer); | 89 | qdev_prop_set_uint32(DEVICE(&mms->dualtimer), "pclk-frq", SYSCLK_FRQ); |
77 | @@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_realize(DeviceState *dev, Error **errp) | ||
78 | { | ||
79 | SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
80 | AspeedWDTState *s = ASPEED_WDT(dev); | ||
81 | + Error *err = NULL; | ||
82 | + Object *obj; | ||
83 | + | ||
84 | + obj = object_property_get_link(OBJECT(dev), "scu", &err); | ||
85 | + if (!obj) { | ||
86 | + error_propagate(errp, err); | ||
87 | + error_prepend(errp, "required link 'scu' not found: "); | ||
88 | + return; | ||
89 | + } | ||
90 | + s->scu = ASPEED_SCU(obj); | ||
91 | |||
92 | if (!is_supported_silicon_rev(s->silicon_rev)) { | ||
93 | error_setg(errp, "Unknown silicon revision: 0x%" PRIx32, | ||
94 | -- | 90 | -- |
95 | 2.20.1 | 91 | 2.20.1 |
96 | 92 | ||
97 | 93 | diff view generated by jsdifflib |
1 | From: Andrew Jeffery <andrew@aj.id.au> | 1 | Create a fixed-frequency Clock object to be the SYSCLK, and wire it |
---|---|---|---|
2 | up to the devices that require it. | ||
2 | 3 | ||
3 | The legacy interface only supported up to 32 IRQs, which became | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | restrictive around the AST2400 generation. QEMU support for the SoCs | 5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
5 | started with the AST2400 along with an effort to reimplement and | 6 | Reviewed-by: Luc Michel <luc@lmichel.fr> |
6 | upstream drivers for Linux, so up until this point the consumers of the | 7 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
7 | QEMU ASPEED support only required the 64 IRQ register interface. | 8 | Message-id: 20210128114145.20536-14-peter.maydell@linaro.org |
9 | Message-id: 20210121190622.22000-14-peter.maydell@linaro.org | ||
10 | --- | ||
11 | hw/arm/mps2.c | 9 +++++++++ | ||
12 | 1 file changed, 9 insertions(+) | ||
8 | 13 | ||
9 | In an effort to support older BMC firmware, add support for the 32 IRQ | 14 | diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c |
10 | interface. | ||
11 | |||
12 | Signed-off-by: Andrew Jeffery <andrew@aj.id.au> | ||
13 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
14 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
15 | Message-id: 20190618165311.27066-22-clg@kaod.org | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | --- | ||
18 | hw/intc/aspeed_vic.c | 105 ++++++++++++++++++++++++++----------------- | ||
19 | 1 file changed, 63 insertions(+), 42 deletions(-) | ||
20 | |||
21 | diff --git a/hw/intc/aspeed_vic.c b/hw/intc/aspeed_vic.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/hw/intc/aspeed_vic.c | 16 | --- a/hw/arm/mps2.c |
24 | +++ b/hw/intc/aspeed_vic.c | 17 | +++ b/hw/arm/mps2.c |
25 | @@ -XXX,XX +XXX,XX @@ static void aspeed_vic_set_irq(void *opaque, int irq, int level) | 18 | @@ -XXX,XX +XXX,XX @@ |
26 | 19 | #include "hw/net/lan9118.h" | |
27 | static uint64_t aspeed_vic_read(void *opaque, hwaddr offset, unsigned size) | 20 | #include "net/net.h" |
28 | { | 21 | #include "hw/watchdog/cmsdk-apb-watchdog.h" |
29 | - uint64_t val; | 22 | +#include "hw/qdev-clock.h" |
30 | - const bool high = !!(offset & 0x4); | 23 | #include "qom/object.h" |
31 | - hwaddr n_offset = (offset & ~0x4); | 24 | |
32 | AspeedVICState *s = (AspeedVICState *)opaque; | 25 | typedef enum MPS2FPGAType { |
33 | + hwaddr n_offset; | 26 | @@ -XXX,XX +XXX,XX @@ struct MPS2MachineState { |
34 | + uint64_t val; | 27 | CMSDKAPBDualTimer dualtimer; |
35 | + bool high; | 28 | CMSDKAPBWatchdog watchdog; |
36 | 29 | CMSDKAPBTimer timer[2]; | |
37 | if (offset < AVIC_NEW_BASE_OFFSET) { | 30 | + Clock *sysclk; |
38 | - qemu_log_mask(LOG_UNIMP, "%s: Ignoring read from legacy registers " | 31 | }; |
39 | - "at 0x%" HWADDR_PRIx "[%u]\n", __func__, offset, size); | 32 | |
40 | - return 0; | 33 | #define TYPE_MPS2_MACHINE "mps2" |
41 | + high = false; | 34 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) |
42 | + n_offset = offset; | 35 | exit(EXIT_FAILURE); |
43 | + } else { | ||
44 | + high = !!(offset & 0x4); | ||
45 | + n_offset = (offset & ~0x4); | ||
46 | } | 36 | } |
47 | 37 | ||
48 | - n_offset -= AVIC_NEW_BASE_OFFSET; | 38 | + /* This clock doesn't need migration because it is fixed-frequency */ |
49 | - | 39 | + mms->sysclk = clock_new(OBJECT(machine), "SYSCLK"); |
50 | switch (n_offset) { | 40 | + clock_set_hz(mms->sysclk, SYSCLK_FRQ); |
51 | - case 0x0: /* IRQ Status */ | 41 | + |
52 | + case 0x80: /* IRQ Status */ | 42 | /* The FPGA images have an odd combination of different RAMs, |
53 | + case 0x00: | 43 | * because in hardware they are different implementations and |
54 | val = s->raw & ~s->select & s->enable; | 44 | * connected to different buses, giving varying performance/size |
55 | break; | 45 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) |
56 | - case 0x08: /* FIQ Status */ | 46 | TYPE_CMSDK_APB_TIMER); |
57 | + case 0x88: /* FIQ Status */ | 47 | sbd = SYS_BUS_DEVICE(&mms->timer[i]); |
58 | + case 0x04: | 48 | qdev_prop_set_uint32(DEVICE(&mms->timer[i]), "pclk-frq", SYSCLK_FRQ); |
59 | val = s->raw & s->select & s->enable; | 49 | + qdev_connect_clock_in(DEVICE(&mms->timer[i]), "pclk", mms->sysclk); |
60 | break; | 50 | sysbus_realize_and_unref(sbd, &error_fatal); |
61 | - case 0x10: /* Raw Interrupt Status */ | 51 | sysbus_mmio_map(sbd, 0, base); |
62 | + case 0x90: /* Raw Interrupt Status */ | 52 | sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(armv7m, irqno)); |
63 | + case 0x08: | 53 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) |
64 | val = s->raw; | 54 | object_initialize_child(OBJECT(mms), "dualtimer", &mms->dualtimer, |
65 | break; | 55 | TYPE_CMSDK_APB_DUALTIMER); |
66 | - case 0x18: /* Interrupt Selection */ | 56 | qdev_prop_set_uint32(DEVICE(&mms->dualtimer), "pclk-frq", SYSCLK_FRQ); |
67 | + case 0x98: /* Interrupt Selection */ | 57 | + qdev_connect_clock_in(DEVICE(&mms->dualtimer), "TIMCLK", mms->sysclk); |
68 | + case 0x0c: | 58 | sysbus_realize(SYS_BUS_DEVICE(&mms->dualtimer), &error_fatal); |
69 | val = s->select; | 59 | sysbus_connect_irq(SYS_BUS_DEVICE(&mms->dualtimer), 0, |
70 | break; | 60 | qdev_get_gpio_in(armv7m, 10)); |
71 | - case 0x20: /* Interrupt Enable */ | 61 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) |
72 | + case 0xa0: /* Interrupt Enable */ | 62 | object_initialize_child(OBJECT(mms), "watchdog", &mms->watchdog, |
73 | + case 0x10: | 63 | TYPE_CMSDK_APB_WATCHDOG); |
74 | val = s->enable; | 64 | qdev_prop_set_uint32(DEVICE(&mms->watchdog), "wdogclk-frq", SYSCLK_FRQ); |
75 | break; | 65 | + qdev_connect_clock_in(DEVICE(&mms->watchdog), "WDOGCLK", mms->sysclk); |
76 | - case 0x30: /* Software Interrupt */ | 66 | sysbus_realize(SYS_BUS_DEVICE(&mms->watchdog), &error_fatal); |
77 | + case 0xb0: /* Software Interrupt */ | 67 | sysbus_connect_irq(SYS_BUS_DEVICE(&mms->watchdog), 0, |
78 | + case 0x18: | 68 | qdev_get_gpio_in_named(armv7m, "NMI", 0)); |
79 | val = s->trigger; | ||
80 | break; | ||
81 | - case 0x40: /* Interrupt Sensitivity */ | ||
82 | + case 0xc0: /* Interrupt Sensitivity */ | ||
83 | + case 0x24: | ||
84 | val = s->sense; | ||
85 | break; | ||
86 | - case 0x48: /* Interrupt Both Edge Trigger Control */ | ||
87 | + case 0xc8: /* Interrupt Both Edge Trigger Control */ | ||
88 | + case 0x28: | ||
89 | val = s->dual_edge; | ||
90 | break; | ||
91 | - case 0x50: /* Interrupt Event */ | ||
92 | + case 0xd0: /* Interrupt Event */ | ||
93 | + case 0x2c: | ||
94 | val = s->event; | ||
95 | break; | ||
96 | - case 0x60: /* Edge Triggered Interrupt Status */ | ||
97 | + case 0xe0: /* Edge Triggered Interrupt Status */ | ||
98 | val = s->raw & ~s->sense; | ||
99 | break; | ||
100 | /* Illegal */ | ||
101 | - case 0x28: /* Interrupt Enable Clear */ | ||
102 | - case 0x38: /* Software Interrupt Clear */ | ||
103 | - case 0x58: /* Edge Triggered Interrupt Clear */ | ||
104 | + case 0xa8: /* Interrupt Enable Clear */ | ||
105 | + case 0xb8: /* Software Interrupt Clear */ | ||
106 | + case 0xd8: /* Edge Triggered Interrupt Clear */ | ||
107 | qemu_log_mask(LOG_GUEST_ERROR, | ||
108 | "%s: Read of write-only register with offset 0x%" | ||
109 | HWADDR_PRIx "\n", __func__, offset); | ||
110 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_vic_read(void *opaque, hwaddr offset, unsigned size) | ||
111 | } | ||
112 | if (high) { | ||
113 | val = extract64(val, 32, 19); | ||
114 | + } else { | ||
115 | + val = extract64(val, 0, 32); | ||
116 | } | ||
117 | trace_aspeed_vic_read(offset, size, val); | ||
118 | return val; | ||
119 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_vic_read(void *opaque, hwaddr offset, unsigned size) | ||
120 | static void aspeed_vic_write(void *opaque, hwaddr offset, uint64_t data, | ||
121 | unsigned size) | ||
122 | { | ||
123 | - const bool high = !!(offset & 0x4); | ||
124 | - hwaddr n_offset = (offset & ~0x4); | ||
125 | AspeedVICState *s = (AspeedVICState *)opaque; | ||
126 | + hwaddr n_offset; | ||
127 | + bool high; | ||
128 | |||
129 | if (offset < AVIC_NEW_BASE_OFFSET) { | ||
130 | - qemu_log_mask(LOG_UNIMP, | ||
131 | - "%s: Ignoring write to legacy registers at 0x%" | ||
132 | - HWADDR_PRIx "[%u] <- 0x%" PRIx64 "\n", __func__, offset, | ||
133 | - size, data); | ||
134 | - return; | ||
135 | + high = false; | ||
136 | + n_offset = offset; | ||
137 | + } else { | ||
138 | + high = !!(offset & 0x4); | ||
139 | + n_offset = (offset & ~0x4); | ||
140 | } | ||
141 | |||
142 | - n_offset -= AVIC_NEW_BASE_OFFSET; | ||
143 | trace_aspeed_vic_write(offset, size, data); | ||
144 | |||
145 | /* Given we have members using separate enable/clear registers, deposit64() | ||
146 | @@ -XXX,XX +XXX,XX @@ static void aspeed_vic_write(void *opaque, hwaddr offset, uint64_t data, | ||
147 | } | ||
148 | |||
149 | switch (n_offset) { | ||
150 | - case 0x18: /* Interrupt Selection */ | ||
151 | + case 0x98: /* Interrupt Selection */ | ||
152 | + case 0x0c: | ||
153 | /* Register has deposit64() semantics - overwrite requested 32 bits */ | ||
154 | if (high) { | ||
155 | s->select &= AVIC_L_MASK; | ||
156 | @@ -XXX,XX +XXX,XX @@ static void aspeed_vic_write(void *opaque, hwaddr offset, uint64_t data, | ||
157 | } | ||
158 | s->select |= data; | ||
159 | break; | ||
160 | - case 0x20: /* Interrupt Enable */ | ||
161 | + case 0xa0: /* Interrupt Enable */ | ||
162 | + case 0x10: | ||
163 | s->enable |= data; | ||
164 | break; | ||
165 | - case 0x28: /* Interrupt Enable Clear */ | ||
166 | + case 0xa8: /* Interrupt Enable Clear */ | ||
167 | + case 0x14: | ||
168 | s->enable &= ~data; | ||
169 | break; | ||
170 | - case 0x30: /* Software Interrupt */ | ||
171 | + case 0xb0: /* Software Interrupt */ | ||
172 | + case 0x18: | ||
173 | qemu_log_mask(LOG_UNIMP, "%s: Software interrupts unavailable. " | ||
174 | "IRQs requested: 0x%016" PRIx64 "\n", __func__, data); | ||
175 | break; | ||
176 | - case 0x38: /* Software Interrupt Clear */ | ||
177 | + case 0xb8: /* Software Interrupt Clear */ | ||
178 | + case 0x1c: | ||
179 | qemu_log_mask(LOG_UNIMP, "%s: Software interrupts unavailable. " | ||
180 | "IRQs to be cleared: 0x%016" PRIx64 "\n", __func__, data); | ||
181 | break; | ||
182 | - case 0x50: /* Interrupt Event */ | ||
183 | + case 0xd0: /* Interrupt Event */ | ||
184 | /* Register has deposit64() semantics - overwrite the top four valid | ||
185 | * IRQ bits, as only the top four IRQs (GPIOs) can change their event | ||
186 | * type */ | ||
187 | @@ -XXX,XX +XXX,XX @@ static void aspeed_vic_write(void *opaque, hwaddr offset, uint64_t data, | ||
188 | "Ignoring invalid write to interrupt event register"); | ||
189 | } | ||
190 | break; | ||
191 | - case 0x58: /* Edge Triggered Interrupt Clear */ | ||
192 | + case 0xd8: /* Edge Triggered Interrupt Clear */ | ||
193 | + case 0x38: | ||
194 | s->raw &= ~(data & ~s->sense); | ||
195 | break; | ||
196 | - case 0x00: /* IRQ Status */ | ||
197 | - case 0x08: /* FIQ Status */ | ||
198 | - case 0x10: /* Raw Interrupt Status */ | ||
199 | - case 0x40: /* Interrupt Sensitivity */ | ||
200 | - case 0x48: /* Interrupt Both Edge Trigger Control */ | ||
201 | - case 0x60: /* Edge Triggered Interrupt Status */ | ||
202 | + case 0x80: /* IRQ Status */ | ||
203 | + case 0x00: | ||
204 | + case 0x88: /* FIQ Status */ | ||
205 | + case 0x04: | ||
206 | + case 0x90: /* Raw Interrupt Status */ | ||
207 | + case 0x08: | ||
208 | + case 0xc0: /* Interrupt Sensitivity */ | ||
209 | + case 0x24: | ||
210 | + case 0xc8: /* Interrupt Both Edge Trigger Control */ | ||
211 | + case 0x28: | ||
212 | + case 0xe0: /* Edge Triggered Interrupt Status */ | ||
213 | qemu_log_mask(LOG_GUEST_ERROR, | ||
214 | "%s: Write of read-only register with offset 0x%" | ||
215 | HWADDR_PRIx "\n", __func__, offset); | ||
216 | -- | 69 | -- |
217 | 2.20.1 | 70 | 2.20.1 |
218 | 71 | ||
219 | 72 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | Create and connect the two clocks needed by the ARMSSE. |
---|---|---|---|
2 | 2 | ||
3 | The Linux kernel driver was updated in commit 4451d3f59f2a | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | ("clocksource/drivers/fttmr010: Fix set_next_event handler) to fix an | 4 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
5 | issue observed on hardware: | 5 | Reviewed-by: Luc Michel <luc@lmichel.fr> |
6 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Message-id: 20210128114145.20536-15-peter.maydell@linaro.org | ||
8 | Message-id: 20210121190622.22000-15-peter.maydell@linaro.org | ||
9 | --- | ||
10 | hw/arm/mps2-tz.c | 13 +++++++++++++ | ||
11 | 1 file changed, 13 insertions(+) | ||
6 | 12 | ||
7 | > RELOAD register is loaded into COUNT register when the aspeed timer | 13 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c |
8 | > is enabled, which means the next event may be delayed because timer | ||
9 | > interrupt won't be generated until <0xFFFFFFFF - current_count + | ||
10 | > cycles>. | ||
11 | |||
12 | When running under Qemu, the system appeared "laggy". The guest is now | ||
13 | scheduling timer events too regularly, starving the host of CPU time. | ||
14 | |||
15 | This patch modifies the timer model to attempt to schedule the timer | ||
16 | expiry as the guest requests, but if we have missed the deadline we | ||
17 | re interrupt and try again, which allows the guest to catch up. | ||
18 | |||
19 | Provides expected behaviour with old and new guest code. | ||
20 | |||
21 | Fixes: c04bd47db6b9 ("hw/timer: Add ASPEED timer device model") | ||
22 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
23 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
24 | Message-id: 20190618165311.27066-8-clg@kaod.org | ||
25 | [clg: - merged a fix from Andrew Jeffery <andrew@aj.id.au> | ||
26 | "Fire interrupt on failure to meet deadline" | ||
27 | https://lists.ozlabs.org/pipermail/openbmc/2019-January/014641.html | ||
28 | - adapted commit log | ||
29 | - checkpatch fixes ] | ||
30 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
31 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
32 | --- | ||
33 | hw/timer/aspeed_timer.c | 57 ++++++++++++++++++++++------------------- | ||
34 | 1 file changed, 30 insertions(+), 27 deletions(-) | ||
35 | |||
36 | diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/hw/timer/aspeed_timer.c | 15 | --- a/hw/arm/mps2-tz.c |
39 | +++ b/hw/timer/aspeed_timer.c | 16 | +++ b/hw/arm/mps2-tz.c |
40 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t calculate_time(struct AspeedTimer *t, uint32_t ticks) | 17 | @@ -XXX,XX +XXX,XX @@ |
41 | 18 | #include "hw/net/lan9118.h" | |
42 | static uint64_t calculate_next(struct AspeedTimer *t) | 19 | #include "net/net.h" |
43 | { | 20 | #include "hw/core/split-irq.h" |
44 | - uint64_t next = 0; | 21 | +#include "hw/qdev-clock.h" |
45 | - uint32_t rate = calculate_rate(t); | 22 | #include "qom/object.h" |
46 | + uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | 23 | |
47 | + uint64_t next; | 24 | #define MPS2TZ_NUMIRQ 92 |
48 | 25 | @@ -XXX,XX +XXX,XX @@ struct MPS2TZMachineState { | |
49 | - while (!next) { | 26 | qemu_or_irq uart_irq_orgate; |
50 | - /* We don't know the relationship between the values in the match | 27 | DeviceState *lan9118; |
51 | - * registers, so sort using MAX/MIN/zero. We sort in that order as the | 28 | SplitIRQ cpu_irq_splitter[MPS2TZ_NUMIRQ]; |
52 | - * timer counts down to zero. */ | 29 | + Clock *sysclk; |
53 | - uint64_t seq[] = { | 30 | + Clock *s32kclk; |
54 | - calculate_time(t, MAX(t->match[0], t->match[1])), | 31 | }; |
55 | - calculate_time(t, MIN(t->match[0], t->match[1])), | 32 | |
56 | - calculate_time(t, 0), | 33 | #define TYPE_MPS2TZ_MACHINE "mps2tz" |
57 | - }; | 34 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_TYPE(MPS2TZMachineState, MPS2TZMachineClass, MPS2TZ_MACHINE) |
58 | - uint64_t reload_ns; | 35 | |
59 | - uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | 36 | /* Main SYSCLK frequency in Hz */ |
60 | + /* | 37 | #define SYSCLK_FRQ 20000000 |
61 | + * We don't know the relationship between the values in the match | 38 | +/* Slow 32Khz S32KCLK frequency in Hz */ |
62 | + * registers, so sort using MAX/MIN/zero. We sort in that order as | 39 | +#define S32KCLK_FRQ (32 * 1000) |
63 | + * the timer counts down to zero. | 40 | |
64 | + */ | 41 | /* Create an alias of an entire original MemoryRegion @orig |
65 | 42 | * located at @base in the memory map. | |
66 | - if (now < seq[0]) { | 43 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) |
67 | - next = seq[0]; | 44 | exit(EXIT_FAILURE); |
68 | - } else if (now < seq[1]) { | ||
69 | - next = seq[1]; | ||
70 | - } else if (now < seq[2]) { | ||
71 | - next = seq[2]; | ||
72 | - } else if (t->reload) { | ||
73 | - reload_ns = muldiv64(t->reload, NANOSECONDS_PER_SECOND, rate); | ||
74 | - t->start = now - ((now - t->start) % reload_ns); | ||
75 | - } else { | ||
76 | - /* no reload value, return 0 */ | ||
77 | - break; | ||
78 | - } | ||
79 | + next = calculate_time(t, MAX(t->match[0], t->match[1])); | ||
80 | + if (now < next) { | ||
81 | + return next; | ||
82 | } | 45 | } |
83 | 46 | ||
84 | - return next; | 47 | + /* These clocks don't need migration because they are fixed-frequency */ |
85 | + next = calculate_time(t, MIN(t->match[0], t->match[1])); | 48 | + mms->sysclk = clock_new(OBJECT(machine), "SYSCLK"); |
86 | + if (now < next) { | 49 | + clock_set_hz(mms->sysclk, SYSCLK_FRQ); |
87 | + return next; | 50 | + mms->s32kclk = clock_new(OBJECT(machine), "S32KCLK"); |
88 | + } | 51 | + clock_set_hz(mms->s32kclk, S32KCLK_FRQ); |
89 | + | 52 | + |
90 | + next = calculate_time(t, 0); | 53 | object_initialize_child(OBJECT(machine), TYPE_IOTKIT, &mms->iotkit, |
91 | + if (now < next) { | 54 | mmc->armsse_type); |
92 | + return next; | 55 | iotkitdev = DEVICE(&mms->iotkit); |
93 | + } | 56 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) |
94 | + | 57 | OBJECT(system_memory), &error_abort); |
95 | + /* We've missed all deadlines, fire interrupt and try again */ | 58 | qdev_prop_set_uint32(iotkitdev, "EXP_NUMIRQ", MPS2TZ_NUMIRQ); |
96 | + timer_del(&t->timer); | 59 | qdev_prop_set_uint32(iotkitdev, "MAINCLK_FRQ", SYSCLK_FRQ); |
97 | + | 60 | + qdev_connect_clock_in(iotkitdev, "MAINCLK", mms->sysclk); |
98 | + if (timer_overflow_interrupt(t)) { | 61 | + qdev_connect_clock_in(iotkitdev, "S32KCLK", mms->s32kclk); |
99 | + t->level = !t->level; | 62 | sysbus_realize(SYS_BUS_DEVICE(&mms->iotkit), &error_fatal); |
100 | + qemu_set_irq(t->irq, t->level); | 63 | |
101 | + } | 64 | /* |
102 | + | ||
103 | + t->start = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | ||
104 | + return calculate_time(t, MAX(MAX(t->match[0], t->match[1]), 0)); | ||
105 | } | ||
106 | |||
107 | static void aspeed_timer_mod(AspeedTimer *t) | ||
108 | -- | 65 | -- |
109 | 2.20.1 | 66 | 2.20.1 |
110 | 67 | ||
111 | 68 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | Create and connect the two clocks needed by the ARMSSE. |
---|---|---|---|
2 | 2 | ||
3 | This machine correctly defines its default_cpu_type to cortex-m3 | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | and report an error if the user requested another cpu_type, | 4 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
5 | however it does not exit, and this can confuse users trying | 5 | Reviewed-by: Luc Michel <luc@lmichel.fr> |
6 | to use another core: | 6 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
7 | Message-id: 20210128114145.20536-16-peter.maydell@linaro.org | ||
8 | Message-id: 20210121190622.22000-16-peter.maydell@linaro.org | ||
9 | --- | ||
10 | hw/arm/musca.c | 12 ++++++++++++ | ||
11 | 1 file changed, 12 insertions(+) | ||
7 | 12 | ||
8 | $ qemu-system-arm -M emcraft-sf2 -cpu cortex-m4 -kernel test-m4.elf | 13 | diff --git a/hw/arm/musca.c b/hw/arm/musca.c |
9 | qemu-system-arm: This board can only be used with CPU cortex-m3-arm-cpu | ||
10 | [output related to M3 core ...] | ||
11 | |||
12 | The CPU is indeed a M3 core: | ||
13 | |||
14 | (qemu) info qom-tree | ||
15 | /machine (emcraft-sf2-machine) | ||
16 | /unattached (container) | ||
17 | /device[0] (msf2-soc) | ||
18 | /armv7m (armv7m) | ||
19 | /cpu (cortex-m3-arm-cpu) | ||
20 | |||
21 | Add the missing exit() call to return to the shell. | ||
22 | |||
23 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
24 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
25 | Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> | ||
26 | Message-id: 20190617160136.29930-1-philmd@redhat.com | ||
27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
28 | --- | ||
29 | hw/arm/msf2-som.c | 1 + | ||
30 | 1 file changed, 1 insertion(+) | ||
31 | |||
32 | diff --git a/hw/arm/msf2-som.c b/hw/arm/msf2-som.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/hw/arm/msf2-som.c | 15 | --- a/hw/arm/musca.c |
35 | +++ b/hw/arm/msf2-som.c | 16 | +++ b/hw/arm/musca.c |
36 | @@ -XXX,XX +XXX,XX @@ static void emcraft_sf2_s2s010_init(MachineState *machine) | 17 | @@ -XXX,XX +XXX,XX @@ |
37 | if (strcmp(machine->cpu_type, mc->default_cpu_type) != 0) { | 18 | #include "hw/misc/tz-ppc.h" |
38 | error_report("This board can only be used with CPU %s", | 19 | #include "hw/misc/unimp.h" |
39 | mc->default_cpu_type); | 20 | #include "hw/rtc/pl031.h" |
40 | + exit(1); | 21 | +#include "hw/qdev-clock.h" |
22 | #include "qom/object.h" | ||
23 | |||
24 | #define MUSCA_NUMIRQ_MAX 96 | ||
25 | @@ -XXX,XX +XXX,XX @@ struct MuscaMachineState { | ||
26 | UnimplementedDeviceState sdio; | ||
27 | UnimplementedDeviceState gpio; | ||
28 | UnimplementedDeviceState cryptoisland; | ||
29 | + Clock *sysclk; | ||
30 | + Clock *s32kclk; | ||
31 | }; | ||
32 | |||
33 | #define TYPE_MUSCA_MACHINE "musca" | ||
34 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_TYPE(MuscaMachineState, MuscaMachineClass, MUSCA_MACHINE) | ||
35 | * don't model that in our SSE-200 model yet. | ||
36 | */ | ||
37 | #define SYSCLK_FRQ 40000000 | ||
38 | +/* Slow 32Khz S32KCLK frequency in Hz */ | ||
39 | +#define S32KCLK_FRQ (32 * 1000) | ||
40 | |||
41 | static qemu_irq get_sse_irq_in(MuscaMachineState *mms, int irqno) | ||
42 | { | ||
43 | @@ -XXX,XX +XXX,XX @@ static void musca_init(MachineState *machine) | ||
44 | exit(1); | ||
41 | } | 45 | } |
42 | 46 | ||
43 | memory_region_init_ram(ddr, NULL, "ddr-ram", DDR_SIZE, | 47 | + mms->sysclk = clock_new(OBJECT(machine), "SYSCLK"); |
48 | + clock_set_hz(mms->sysclk, SYSCLK_FRQ); | ||
49 | + mms->s32kclk = clock_new(OBJECT(machine), "S32KCLK"); | ||
50 | + clock_set_hz(mms->s32kclk, S32KCLK_FRQ); | ||
51 | + | ||
52 | object_initialize_child(OBJECT(machine), "sse-200", &mms->sse, | ||
53 | TYPE_SSE200); | ||
54 | ssedev = DEVICE(&mms->sse); | ||
55 | @@ -XXX,XX +XXX,XX @@ static void musca_init(MachineState *machine) | ||
56 | qdev_prop_set_uint32(ssedev, "init-svtor", mmc->init_svtor); | ||
57 | qdev_prop_set_uint32(ssedev, "SRAM_ADDR_WIDTH", mmc->sram_addr_width); | ||
58 | qdev_prop_set_uint32(ssedev, "MAINCLK_FRQ", SYSCLK_FRQ); | ||
59 | + qdev_connect_clock_in(ssedev, "MAINCLK", mms->sysclk); | ||
60 | + qdev_connect_clock_in(ssedev, "S32KCLK", mms->s32kclk); | ||
61 | /* | ||
62 | * Musca-A takes the default SSE-200 FPU/DSP settings (ie no for | ||
63 | * CPU0 and yes for CPU1); Musca-B1 explicitly enables them for CPU0. | ||
44 | -- | 64 | -- |
45 | 2.20.1 | 65 | 2.20.1 |
46 | 66 | ||
47 | 67 | diff view generated by jsdifflib |
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | 1 | Convert the SSYS code in the Stellaris boards (which encapsulates the |
---|---|---|---|
2 | 2 | system registers) to a proper QOM device. This will provide us with | |
3 | Instantiate no-op APBH DMA module. Needed to boot latest Linux kernel. | 3 | somewhere to put the output Clock whose frequency depends on the |
4 | 4 | setting of the PLL configuration registers. | |
5 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> | 5 | |
6 | Cc: Peter Maydell <peter.maydell@linaro.org> | 6 | This is a migration compatibility break for lm3s811evb, lm3s6965evb. |
7 | Cc: Michael S. Tsirkin <mst@redhat.com> | 7 | |
8 | Cc: qemu-devel@nongnu.org | 8 | We use 3-phase reset here because the Clock will need to propagate |
9 | Cc: qemu-arm@nongnu.org | 9 | its value in the hold phase. |
10 | |||
11 | For the moment we reset the device during the board creation so that | ||
12 | the system_clock_scale global gets set; this will be removed in a | ||
13 | subsequent commit. | ||
14 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Reviewed-by: Luc Michel <luc@lmichel.fr> |
17 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
18 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
19 | Message-id: 20210128114145.20536-17-peter.maydell@linaro.org | ||
20 | Message-id: 20210121190622.22000-17-peter.maydell@linaro.org | ||
21 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
12 | --- | 22 | --- |
13 | include/hw/arm/fsl-imx7.h | 3 +++ | 23 | hw/arm/stellaris.c | 132 ++++++++++++++++++++++++++++++++++++--------- |
14 | hw/arm/fsl-imx7.c | 6 ++++++ | 24 | 1 file changed, 107 insertions(+), 25 deletions(-) |
15 | 2 files changed, 9 insertions(+) | 25 | |
16 | 26 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | |
17 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/hw/arm/fsl-imx7.h | 28 | --- a/hw/arm/stellaris.c |
20 | +++ b/include/hw/arm/fsl-imx7.h | 29 | +++ b/hw/arm/stellaris.c |
21 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7MemoryMap { | 30 | @@ -XXX,XX +XXX,XX @@ static void stellaris_gptm_realize(DeviceState *dev, Error **errp) |
22 | FSL_IMX7_PCIE_REG_SIZE = 16 * 1024, | 31 | |
23 | 32 | /* System controller. */ | |
24 | FSL_IMX7_GPR_ADDR = 0x30340000, | 33 | |
25 | + | 34 | -typedef struct { |
26 | + FSL_IMX7_DMA_APBH_ADDR = 0x33000000, | 35 | +#define TYPE_STELLARIS_SYS "stellaris-sys" |
27 | + FSL_IMX7_DMA_APBH_SIZE = 0x2000, | 36 | +OBJECT_DECLARE_SIMPLE_TYPE(ssys_state, STELLARIS_SYS) |
37 | + | ||
38 | +struct ssys_state { | ||
39 | + SysBusDevice parent_obj; | ||
40 | + | ||
41 | MemoryRegion iomem; | ||
42 | uint32_t pborctl; | ||
43 | uint32_t ldopctl; | ||
44 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
45 | uint32_t dcgc[3]; | ||
46 | uint32_t clkvclr; | ||
47 | uint32_t ldoarst; | ||
48 | + qemu_irq irq; | ||
49 | + /* Properties (all read-only registers) */ | ||
50 | uint32_t user0; | ||
51 | uint32_t user1; | ||
52 | - qemu_irq irq; | ||
53 | - stellaris_board_info *board; | ||
54 | -} ssys_state; | ||
55 | + uint32_t did0; | ||
56 | + uint32_t did1; | ||
57 | + uint32_t dc0; | ||
58 | + uint32_t dc1; | ||
59 | + uint32_t dc2; | ||
60 | + uint32_t dc3; | ||
61 | + uint32_t dc4; | ||
62 | +}; | ||
63 | |||
64 | static void ssys_update(ssys_state *s) | ||
65 | { | ||
66 | @@ -XXX,XX +XXX,XX @@ static uint32_t pllcfg_fury[16] = { | ||
67 | |||
68 | static int ssys_board_class(const ssys_state *s) | ||
69 | { | ||
70 | - uint32_t did0 = s->board->did0; | ||
71 | + uint32_t did0 = s->did0; | ||
72 | switch (did0 & DID0_VER_MASK) { | ||
73 | case DID0_VER_0: | ||
74 | return DID0_CLASS_SANDSTORM; | ||
75 | @@ -XXX,XX +XXX,XX @@ static uint64_t ssys_read(void *opaque, hwaddr offset, | ||
76 | |||
77 | switch (offset) { | ||
78 | case 0x000: /* DID0 */ | ||
79 | - return s->board->did0; | ||
80 | + return s->did0; | ||
81 | case 0x004: /* DID1 */ | ||
82 | - return s->board->did1; | ||
83 | + return s->did1; | ||
84 | case 0x008: /* DC0 */ | ||
85 | - return s->board->dc0; | ||
86 | + return s->dc0; | ||
87 | case 0x010: /* DC1 */ | ||
88 | - return s->board->dc1; | ||
89 | + return s->dc1; | ||
90 | case 0x014: /* DC2 */ | ||
91 | - return s->board->dc2; | ||
92 | + return s->dc2; | ||
93 | case 0x018: /* DC3 */ | ||
94 | - return s->board->dc3; | ||
95 | + return s->dc3; | ||
96 | case 0x01c: /* DC4 */ | ||
97 | - return s->board->dc4; | ||
98 | + return s->dc4; | ||
99 | case 0x030: /* PBORCTL */ | ||
100 | return s->pborctl; | ||
101 | case 0x034: /* LDOPCTL */ | ||
102 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps ssys_ops = { | ||
103 | .endianness = DEVICE_NATIVE_ENDIAN, | ||
28 | }; | 104 | }; |
29 | 105 | ||
30 | enum FslIMX7IRQs { | 106 | -static void ssys_reset(void *opaque) |
31 | diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c | 107 | +static void stellaris_sys_reset_enter(Object *obj, ResetType type) |
32 | index XXXXXXX..XXXXXXX 100644 | 108 | { |
33 | --- a/hw/arm/fsl-imx7.c | 109 | - ssys_state *s = (ssys_state *)opaque; |
34 | +++ b/hw/arm/fsl-imx7.c | 110 | + ssys_state *s = STELLARIS_SYS(obj); |
35 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | 111 | |
36 | */ | 112 | s->pborctl = 0x7ffd; |
37 | create_unimplemented_device("lcdif", FSL_IMX7_LCDIF_ADDR, | 113 | s->rcc = 0x078e3ac0; |
38 | FSL_IMX7_LCDIF_SIZE); | 114 | @@ -XXX,XX +XXX,XX @@ static void ssys_reset(void *opaque) |
115 | s->rcgc[0] = 1; | ||
116 | s->scgc[0] = 1; | ||
117 | s->dcgc[0] = 1; | ||
118 | +} | ||
119 | + | ||
120 | +static void stellaris_sys_reset_hold(Object *obj) | ||
121 | +{ | ||
122 | + ssys_state *s = STELLARIS_SYS(obj); | ||
123 | + | ||
124 | ssys_calculate_system_clock(s); | ||
125 | } | ||
126 | |||
127 | +static void stellaris_sys_reset_exit(Object *obj) | ||
128 | +{ | ||
129 | +} | ||
130 | + | ||
131 | static int stellaris_sys_post_load(void *opaque, int version_id) | ||
132 | { | ||
133 | ssys_state *s = opaque; | ||
134 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_stellaris_sys = { | ||
135 | } | ||
136 | }; | ||
137 | |||
138 | +static Property stellaris_sys_properties[] = { | ||
139 | + DEFINE_PROP_UINT32("user0", ssys_state, user0, 0), | ||
140 | + DEFINE_PROP_UINT32("user1", ssys_state, user1, 0), | ||
141 | + DEFINE_PROP_UINT32("did0", ssys_state, did0, 0), | ||
142 | + DEFINE_PROP_UINT32("did1", ssys_state, did1, 0), | ||
143 | + DEFINE_PROP_UINT32("dc0", ssys_state, dc0, 0), | ||
144 | + DEFINE_PROP_UINT32("dc1", ssys_state, dc1, 0), | ||
145 | + DEFINE_PROP_UINT32("dc2", ssys_state, dc2, 0), | ||
146 | + DEFINE_PROP_UINT32("dc3", ssys_state, dc3, 0), | ||
147 | + DEFINE_PROP_UINT32("dc4", ssys_state, dc4, 0), | ||
148 | + DEFINE_PROP_END_OF_LIST() | ||
149 | +}; | ||
150 | + | ||
151 | +static void stellaris_sys_instance_init(Object *obj) | ||
152 | +{ | ||
153 | + ssys_state *s = STELLARIS_SYS(obj); | ||
154 | + SysBusDevice *sbd = SYS_BUS_DEVICE(s); | ||
155 | + | ||
156 | + memory_region_init_io(&s->iomem, obj, &ssys_ops, s, "ssys", 0x00001000); | ||
157 | + sysbus_init_mmio(sbd, &s->iomem); | ||
158 | + sysbus_init_irq(sbd, &s->irq); | ||
159 | +} | ||
160 | + | ||
161 | static int stellaris_sys_init(uint32_t base, qemu_irq irq, | ||
162 | stellaris_board_info * board, | ||
163 | uint8_t *macaddr) | ||
164 | { | ||
165 | - ssys_state *s; | ||
166 | + DeviceState *dev = qdev_new(TYPE_STELLARIS_SYS); | ||
167 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
168 | |||
169 | - s = g_new0(ssys_state, 1); | ||
170 | - s->irq = irq; | ||
171 | - s->board = board; | ||
172 | /* Most devices come preprogrammed with a MAC address in the user data. */ | ||
173 | - s->user0 = macaddr[0] | (macaddr[1] << 8) | (macaddr[2] << 16); | ||
174 | - s->user1 = macaddr[3] | (macaddr[4] << 8) | (macaddr[5] << 16); | ||
175 | + qdev_prop_set_uint32(dev, "user0", | ||
176 | + macaddr[0] | (macaddr[1] << 8) | (macaddr[2] << 16)); | ||
177 | + qdev_prop_set_uint32(dev, "user1", | ||
178 | + macaddr[3] | (macaddr[4] << 8) | (macaddr[5] << 16)); | ||
179 | + qdev_prop_set_uint32(dev, "did0", board->did0); | ||
180 | + qdev_prop_set_uint32(dev, "did1", board->did1); | ||
181 | + qdev_prop_set_uint32(dev, "dc0", board->dc0); | ||
182 | + qdev_prop_set_uint32(dev, "dc1", board->dc1); | ||
183 | + qdev_prop_set_uint32(dev, "dc2", board->dc2); | ||
184 | + qdev_prop_set_uint32(dev, "dc3", board->dc3); | ||
185 | + qdev_prop_set_uint32(dev, "dc4", board->dc4); | ||
186 | + | ||
187 | + sysbus_realize_and_unref(sbd, &error_fatal); | ||
188 | + sysbus_mmio_map(sbd, 0, base); | ||
189 | + sysbus_connect_irq(sbd, 0, irq); | ||
39 | + | 190 | + |
40 | + /* | 191 | + /* |
41 | + * DMA APBH | 192 | + * Normally we should not be resetting devices like this during |
193 | + * board creation. For the moment we need to do so, because | ||
194 | + * system_clock_scale will only get set when the STELLARIS_SYS | ||
195 | + * device is reset, and we need its initial value to pass to | ||
196 | + * the watchdog device. This hack can be removed once the | ||
197 | + * watchdog has been converted to use a Clock input instead. | ||
42 | + */ | 198 | + */ |
43 | + create_unimplemented_device("dma-apbh", FSL_IMX7_DMA_APBH_ADDR, | 199 | + device_cold_reset(dev); |
44 | + FSL_IMX7_DMA_APBH_SIZE); | 200 | |
201 | - memory_region_init_io(&s->iomem, NULL, &ssys_ops, s, "ssys", 0x00001000); | ||
202 | - memory_region_add_subregion(get_system_memory(), base, &s->iomem); | ||
203 | - ssys_reset(s); | ||
204 | - vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY, &vmstate_stellaris_sys, s); | ||
205 | return 0; | ||
45 | } | 206 | } |
46 | 207 | ||
47 | static void fsl_imx7_class_init(ObjectClass *oc, void *data) | 208 | - |
209 | /* I2C controller. */ | ||
210 | |||
211 | #define TYPE_STELLARIS_I2C "stellaris-i2c" | ||
212 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo stellaris_adc_info = { | ||
213 | .class_init = stellaris_adc_class_init, | ||
214 | }; | ||
215 | |||
216 | +static void stellaris_sys_class_init(ObjectClass *klass, void *data) | ||
217 | +{ | ||
218 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
219 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
220 | + | ||
221 | + dc->vmsd = &vmstate_stellaris_sys; | ||
222 | + rc->phases.enter = stellaris_sys_reset_enter; | ||
223 | + rc->phases.hold = stellaris_sys_reset_hold; | ||
224 | + rc->phases.exit = stellaris_sys_reset_exit; | ||
225 | + device_class_set_props(dc, stellaris_sys_properties); | ||
226 | +} | ||
227 | + | ||
228 | +static const TypeInfo stellaris_sys_info = { | ||
229 | + .name = TYPE_STELLARIS_SYS, | ||
230 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
231 | + .instance_size = sizeof(ssys_state), | ||
232 | + .instance_init = stellaris_sys_instance_init, | ||
233 | + .class_init = stellaris_sys_class_init, | ||
234 | +}; | ||
235 | + | ||
236 | static void stellaris_register_types(void) | ||
237 | { | ||
238 | type_register_static(&stellaris_i2c_info); | ||
239 | type_register_static(&stellaris_gptm_info); | ||
240 | type_register_static(&stellaris_adc_info); | ||
241 | + type_register_static(&stellaris_sys_info); | ||
242 | } | ||
243 | |||
244 | type_init(stellaris_register_types) | ||
48 | -- | 245 | -- |
49 | 2.20.1 | 246 | 2.20.1 |
50 | 247 | ||
51 | 248 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | Create and connect the Clock input for the watchdog device on the |
---|---|---|---|
2 | Stellaris boards. Because the Stellaris boards model the ability to | ||
3 | change the clock rate by programming PLL registers, we have to create | ||
4 | an output Clock on the ssys_state device and wire it up to the | ||
5 | watchdog. | ||
2 | 6 | ||
3 | To ease the review of the next commit, | 7 | Note that the old comment on ssys_calculate_system_clock() got the |
4 | move the vfp_exceptbits_to_host() function directly after | 8 | units wrong -- system_clock_scale is in nanoseconds, not |
5 | vfp_exceptbits_from_host(). Amusingly the diff shows we | 9 | milliseconds. Improve the commentary to clarify how we are |
6 | are moving vfp_get_fpscr(). | 10 | calculating the period. |
7 | 11 | ||
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 20190701132516.26392-15-philmd@redhat.com | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
14 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
15 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
16 | Message-id: 20210128114145.20536-18-peter.maydell@linaro.org | ||
17 | Message-id: 20210121190622.22000-18-peter.maydell@linaro.org | ||
18 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
12 | --- | 19 | --- |
13 | target/arm/vfp_helper.c | 52 ++++++++++++++++++++--------------------- | 20 | hw/arm/stellaris.c | 43 +++++++++++++++++++++++++++++++------------ |
14 | 1 file changed, 26 insertions(+), 26 deletions(-) | 21 | 1 file changed, 31 insertions(+), 12 deletions(-) |
15 | 22 | ||
16 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | 23 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c |
17 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/vfp_helper.c | 25 | --- a/hw/arm/stellaris.c |
19 | +++ b/target/arm/vfp_helper.c | 26 | +++ b/hw/arm/stellaris.c |
20 | @@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_from_host(int host_bits) | 27 | @@ -XXX,XX +XXX,XX @@ |
21 | return target_bits; | 28 | #include "hw/watchdog/cmsdk-apb-watchdog.h" |
29 | #include "migration/vmstate.h" | ||
30 | #include "hw/misc/unimp.h" | ||
31 | +#include "hw/qdev-clock.h" | ||
32 | #include "cpu.h" | ||
33 | #include "qom/object.h" | ||
34 | |||
35 | @@ -XXX,XX +XXX,XX @@ struct ssys_state { | ||
36 | uint32_t clkvclr; | ||
37 | uint32_t ldoarst; | ||
38 | qemu_irq irq; | ||
39 | + Clock *sysclk; | ||
40 | /* Properties (all read-only registers) */ | ||
41 | uint32_t user0; | ||
42 | uint32_t user1; | ||
43 | @@ -XXX,XX +XXX,XX @@ static bool ssys_use_rcc2(ssys_state *s) | ||
22 | } | 44 | } |
23 | 45 | ||
24 | -uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env) | 46 | /* |
25 | -{ | 47 | - * Caculate the sys. clock period in ms. |
26 | - uint32_t i, fpscr; | 48 | + * Calculate the system clock period. We only want to propagate |
27 | - | 49 | + * this change to the rest of the system if we're not being called |
28 | - fpscr = env->vfp.xregs[ARM_VFP_FPSCR] | 50 | + * from migration post-load. |
29 | - | (env->vfp.vec_len << 16) | 51 | */ |
30 | - | (env->vfp.vec_stride << 20); | 52 | -static void ssys_calculate_system_clock(ssys_state *s) |
31 | - | 53 | +static void ssys_calculate_system_clock(ssys_state *s, bool propagate_clock) |
32 | - i = get_float_exception_flags(&env->vfp.fp_status); | ||
33 | - i |= get_float_exception_flags(&env->vfp.standard_fp_status); | ||
34 | - /* FZ16 does not generate an input denormal exception. */ | ||
35 | - i |= (get_float_exception_flags(&env->vfp.fp_status_f16) | ||
36 | - & ~float_flag_input_denormal); | ||
37 | - fpscr |= vfp_exceptbits_from_host(i); | ||
38 | - | ||
39 | - i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3]; | ||
40 | - fpscr |= i ? FPCR_QC : 0; | ||
41 | - | ||
42 | - return fpscr; | ||
43 | -} | ||
44 | - | ||
45 | -uint32_t vfp_get_fpscr(CPUARMState *env) | ||
46 | -{ | ||
47 | - return HELPER(vfp_get_fpscr)(env); | ||
48 | -} | ||
49 | - | ||
50 | /* Convert vfp exception flags to target form. */ | ||
51 | static inline int vfp_exceptbits_to_host(int target_bits) | ||
52 | { | 54 | { |
53 | @@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_to_host(int target_bits) | 55 | + /* |
54 | return host_bits; | 56 | + * SYSDIV field specifies divisor: 0 == /1, 1 == /2, etc. Input |
57 | + * clock is 200MHz, which is a period of 5 ns. Dividing the clock | ||
58 | + * frequency by X is the same as multiplying the period by X. | ||
59 | + */ | ||
60 | if (ssys_use_rcc2(s)) { | ||
61 | system_clock_scale = 5 * (((s->rcc2 >> 23) & 0x3f) + 1); | ||
62 | } else { | ||
63 | system_clock_scale = 5 * (((s->rcc >> 23) & 0xf) + 1); | ||
64 | } | ||
65 | + clock_set_ns(s->sysclk, system_clock_scale); | ||
66 | + if (propagate_clock) { | ||
67 | + clock_propagate(s->sysclk); | ||
68 | + } | ||
55 | } | 69 | } |
56 | 70 | ||
57 | +uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env) | 71 | static void ssys_write(void *opaque, hwaddr offset, |
58 | +{ | 72 | @@ -XXX,XX +XXX,XX @@ static void ssys_write(void *opaque, hwaddr offset, |
59 | + uint32_t i, fpscr; | 73 | s->int_status |= (1 << 6); |
60 | + | 74 | } |
61 | + fpscr = env->vfp.xregs[ARM_VFP_FPSCR] | 75 | s->rcc = value; |
62 | + | (env->vfp.vec_len << 16) | 76 | - ssys_calculate_system_clock(s); |
63 | + | (env->vfp.vec_stride << 20); | 77 | + ssys_calculate_system_clock(s, true); |
64 | + | 78 | break; |
65 | + i = get_float_exception_flags(&env->vfp.fp_status); | 79 | case 0x070: /* RCC2 */ |
66 | + i |= get_float_exception_flags(&env->vfp.standard_fp_status); | 80 | if (ssys_board_class(s) == DID0_CLASS_SANDSTORM) { |
67 | + /* FZ16 does not generate an input denormal exception. */ | 81 | @@ -XXX,XX +XXX,XX @@ static void ssys_write(void *opaque, hwaddr offset, |
68 | + i |= (get_float_exception_flags(&env->vfp.fp_status_f16) | 82 | s->int_status |= (1 << 6); |
69 | + & ~float_flag_input_denormal); | 83 | } |
70 | + fpscr |= vfp_exceptbits_from_host(i); | 84 | s->rcc2 = value; |
71 | + | 85 | - ssys_calculate_system_clock(s); |
72 | + i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3]; | 86 | + ssys_calculate_system_clock(s, true); |
73 | + fpscr |= i ? FPCR_QC : 0; | 87 | break; |
74 | + | 88 | case 0x100: /* RCGC0 */ |
75 | + return fpscr; | 89 | s->rcgc[0] = value; |
76 | +} | 90 | @@ -XXX,XX +XXX,XX @@ static void stellaris_sys_reset_hold(Object *obj) |
77 | + | ||
78 | +uint32_t vfp_get_fpscr(CPUARMState *env) | ||
79 | +{ | ||
80 | + return HELPER(vfp_get_fpscr)(env); | ||
81 | +} | ||
82 | + | ||
83 | void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) | ||
84 | { | 91 | { |
92 | ssys_state *s = STELLARIS_SYS(obj); | ||
93 | |||
94 | - ssys_calculate_system_clock(s); | ||
95 | + /* OK to propagate clocks from the hold phase */ | ||
96 | + ssys_calculate_system_clock(s, true); | ||
97 | } | ||
98 | |||
99 | static void stellaris_sys_reset_exit(Object *obj) | ||
100 | @@ -XXX,XX +XXX,XX @@ static int stellaris_sys_post_load(void *opaque, int version_id) | ||
101 | { | ||
102 | ssys_state *s = opaque; | ||
103 | |||
104 | - ssys_calculate_system_clock(s); | ||
105 | + ssys_calculate_system_clock(s, false); | ||
106 | |||
107 | return 0; | ||
108 | } | ||
109 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_stellaris_sys = { | ||
110 | VMSTATE_UINT32_ARRAY(dcgc, ssys_state, 3), | ||
111 | VMSTATE_UINT32(clkvclr, ssys_state), | ||
112 | VMSTATE_UINT32(ldoarst, ssys_state), | ||
113 | + /* No field for sysclk -- handled in post-load instead */ | ||
114 | VMSTATE_END_OF_LIST() | ||
115 | } | ||
116 | }; | ||
117 | @@ -XXX,XX +XXX,XX @@ static void stellaris_sys_instance_init(Object *obj) | ||
118 | memory_region_init_io(&s->iomem, obj, &ssys_ops, s, "ssys", 0x00001000); | ||
119 | sysbus_init_mmio(sbd, &s->iomem); | ||
120 | sysbus_init_irq(sbd, &s->irq); | ||
121 | + s->sysclk = qdev_init_clock_out(DEVICE(s), "SYSCLK"); | ||
122 | } | ||
123 | |||
124 | -static int stellaris_sys_init(uint32_t base, qemu_irq irq, | ||
125 | - stellaris_board_info * board, | ||
126 | - uint8_t *macaddr) | ||
127 | +static DeviceState *stellaris_sys_init(uint32_t base, qemu_irq irq, | ||
128 | + stellaris_board_info *board, | ||
129 | + uint8_t *macaddr) | ||
130 | { | ||
131 | DeviceState *dev = qdev_new(TYPE_STELLARIS_SYS); | ||
132 | SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
133 | @@ -XXX,XX +XXX,XX @@ static int stellaris_sys_init(uint32_t base, qemu_irq irq, | ||
134 | */ | ||
135 | device_cold_reset(dev); | ||
136 | |||
137 | - return 0; | ||
138 | + return dev; | ||
139 | } | ||
140 | |||
141 | /* I2C controller. */ | ||
142 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
143 | int flash_size; | ||
144 | I2CBus *i2c; | ||
145 | DeviceState *dev; | ||
146 | + DeviceState *ssys_dev; | ||
85 | int i; | 147 | int i; |
148 | int j; | ||
149 | |||
150 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
151 | } | ||
152 | } | ||
153 | |||
154 | - stellaris_sys_init(0x400fe000, qdev_get_gpio_in(nvic, 28), | ||
155 | - board, nd_table[0].macaddr.a); | ||
156 | + ssys_dev = stellaris_sys_init(0x400fe000, qdev_get_gpio_in(nvic, 28), | ||
157 | + board, nd_table[0].macaddr.a); | ||
158 | |||
159 | |||
160 | if (board->dc1 & (1 << 3)) { /* watchdog present */ | ||
161 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
162 | /* system_clock_scale is valid now */ | ||
163 | uint32_t mainclk = NANOSECONDS_PER_SECOND / system_clock_scale; | ||
164 | qdev_prop_set_uint32(dev, "wdogclk-frq", mainclk); | ||
165 | + qdev_connect_clock_in(dev, "WDOGCLK", | ||
166 | + qdev_get_clock_out(ssys_dev, "SYSCLK")); | ||
167 | |||
168 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); | ||
169 | sysbus_mmio_map(SYS_BUS_DEVICE(dev), | ||
86 | -- | 170 | -- |
87 | 2.20.1 | 171 | 2.20.1 |
88 | 172 | ||
89 | 173 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | Switch the CMSDK APB timer device over to using its Clock input; the |
---|---|---|---|
2 | pclk-frq property is now ignored. | ||
2 | 3 | ||
3 | Since we'll move this code around, fix its style first. | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
7 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Message-id: 20210128114145.20536-19-peter.maydell@linaro.org | ||
9 | Message-id: 20210121190622.22000-19-peter.maydell@linaro.org | ||
10 | --- | ||
11 | hw/timer/cmsdk-apb-timer.c | 18 ++++++++++++++---- | ||
12 | 1 file changed, 14 insertions(+), 4 deletions(-) | ||
4 | 13 | ||
5 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 14 | diff --git a/hw/timer/cmsdk-apb-timer.c b/hw/timer/cmsdk-apb-timer.c |
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Message-id: 20190701132516.26392-9-philmd@redhat.com | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/translate.c | 11 ++++++----- | ||
11 | target/arm/vfp_helper.c | 36 ++++++++++++++++++++++++------------ | ||
12 | 2 files changed, 30 insertions(+), 17 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 16 | --- a/hw/timer/cmsdk-apb-timer.c |
17 | +++ b/target/arm/translate.c | 17 | +++ b/hw/timer/cmsdk-apb-timer.c |
18 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 18 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_reset(DeviceState *dev) |
19 | loaded_base = 0; | 19 | ptimer_transaction_commit(s->timer); |
20 | loaded_var = NULL; | 20 | } |
21 | n = 0; | 21 | |
22 | - for(i=0;i<16;i++) { | 22 | +static void cmsdk_apb_timer_clk_update(void *opaque) |
23 | + for (i = 0; i < 16; i++) { | 23 | +{ |
24 | if (insn & (1 << i)) | 24 | + CMSDKAPBTimer *s = CMSDK_APB_TIMER(opaque); |
25 | n++; | 25 | + |
26 | } | 26 | + ptimer_transaction_begin(s->timer); |
27 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 27 | + ptimer_set_period_from_clock(s->timer, s->pclk, 1); |
28 | } | 28 | + ptimer_transaction_commit(s->timer); |
29 | } | 29 | +} |
30 | j = 0; | 30 | + |
31 | - for(i=0;i<16;i++) { | 31 | static void cmsdk_apb_timer_init(Object *obj) |
32 | + for (i = 0; i < 16; i++) { | 32 | { |
33 | if (insn & (1 << i)) { | 33 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); |
34 | if (is_load) { | 34 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_init(Object *obj) |
35 | /* load */ | 35 | s, "cmsdk-apb-timer", 0x1000); |
36 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags) | 36 | sysbus_init_mmio(sbd, &s->iomem); |
37 | sysbus_init_irq(sbd, &s->timerint); | ||
38 | - s->pclk = qdev_init_clock_in(DEVICE(s), "pclk", NULL, NULL); | ||
39 | + s->pclk = qdev_init_clock_in(DEVICE(s), "pclk", | ||
40 | + cmsdk_apb_timer_clk_update, s); | ||
41 | } | ||
42 | |||
43 | static void cmsdk_apb_timer_realize(DeviceState *dev, Error **errp) | ||
44 | { | ||
45 | CMSDKAPBTimer *s = CMSDK_APB_TIMER(dev); | ||
46 | |||
47 | - if (s->pclk_frq == 0) { | ||
48 | - error_setg(errp, "CMSDK APB timer: pclk-frq property must be set"); | ||
49 | + if (!clock_has_source(s->pclk)) { | ||
50 | + error_setg(errp, "CMSDK APB timer: pclk clock must be connected"); | ||
37 | return; | 51 | return; |
38 | } | 52 | } |
39 | 53 | ||
40 | - for(i=0;i<16;i++) { | 54 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_realize(DeviceState *dev, Error **errp) |
41 | + for (i = 0; i < 16; i++) { | 55 | PTIMER_POLICY_NO_COUNTER_ROUND_DOWN); |
42 | qemu_fprintf(f, "R%02d=%08x", i, env->regs[i]); | 56 | |
43 | - if ((i % 4) == 3) | 57 | ptimer_transaction_begin(s->timer); |
44 | + if ((i % 4) == 3) { | 58 | - ptimer_set_freq(s->timer, s->pclk_frq); |
45 | qemu_fprintf(f, "\n"); | 59 | + ptimer_set_period_from_clock(s->timer, s->pclk, 1); |
46 | - else | 60 | ptimer_transaction_commit(s->timer); |
47 | + } else { | ||
48 | qemu_fprintf(f, " "); | ||
49 | + } | ||
50 | } | ||
51 | |||
52 | if (arm_feature(env, ARM_FEATURE_M)) { | ||
53 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/target/arm/vfp_helper.c | ||
56 | +++ b/target/arm/vfp_helper.c | ||
57 | @@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_from_host(int host_bits) | ||
58 | { | ||
59 | int target_bits = 0; | ||
60 | |||
61 | - if (host_bits & float_flag_invalid) | ||
62 | + if (host_bits & float_flag_invalid) { | ||
63 | target_bits |= 1; | ||
64 | - if (host_bits & float_flag_divbyzero) | ||
65 | + } | ||
66 | + if (host_bits & float_flag_divbyzero) { | ||
67 | target_bits |= 2; | ||
68 | - if (host_bits & float_flag_overflow) | ||
69 | + } | ||
70 | + if (host_bits & float_flag_overflow) { | ||
71 | target_bits |= 4; | ||
72 | - if (host_bits & (float_flag_underflow | float_flag_output_denormal)) | ||
73 | + } | ||
74 | + if (host_bits & (float_flag_underflow | float_flag_output_denormal)) { | ||
75 | target_bits |= 8; | ||
76 | - if (host_bits & float_flag_inexact) | ||
77 | + } | ||
78 | + if (host_bits & float_flag_inexact) { | ||
79 | target_bits |= 0x10; | ||
80 | - if (host_bits & float_flag_input_denormal) | ||
81 | + } | ||
82 | + if (host_bits & float_flag_input_denormal) { | ||
83 | target_bits |= 0x80; | ||
84 | + } | ||
85 | return target_bits; | ||
86 | } | 61 | } |
87 | |||
88 | @@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_to_host(int target_bits) | ||
89 | { | ||
90 | int host_bits = 0; | ||
91 | |||
92 | - if (target_bits & 1) | ||
93 | + if (target_bits & 1) { | ||
94 | host_bits |= float_flag_invalid; | ||
95 | - if (target_bits & 2) | ||
96 | + } | ||
97 | + if (target_bits & 2) { | ||
98 | host_bits |= float_flag_divbyzero; | ||
99 | - if (target_bits & 4) | ||
100 | + } | ||
101 | + if (target_bits & 4) { | ||
102 | host_bits |= float_flag_overflow; | ||
103 | - if (target_bits & 8) | ||
104 | + } | ||
105 | + if (target_bits & 8) { | ||
106 | host_bits |= float_flag_underflow; | ||
107 | - if (target_bits & 0x10) | ||
108 | + } | ||
109 | + if (target_bits & 0x10) { | ||
110 | host_bits |= float_flag_inexact; | ||
111 | - if (target_bits & 0x80) | ||
112 | + } | ||
113 | + if (target_bits & 0x80) { | ||
114 | host_bits |= float_flag_input_denormal; | ||
115 | + } | ||
116 | return host_bits; | ||
117 | } | ||
118 | 62 | ||
119 | -- | 63 | -- |
120 | 2.20.1 | 64 | 2.20.1 |
121 | 65 | ||
122 | 66 | diff view generated by jsdifflib |
1 | From: Hongbo Zhang <hongbo.zhang@linaro.org> | 1 | Switch the CMSDK APB dualtimer device over to using its Clock input; |
---|---|---|---|
2 | the pclk-frq property is now ignored. | ||
2 | 3 | ||
3 | Following the previous patch, this patch adds peripheral devices to the | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | newly introduced SBSA-ref machine. | 5 | Reviewed-by: Luc Michel <luc@lmichel.fr> |
6 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Message-id: 20210128114145.20536-20-peter.maydell@linaro.org | ||
9 | Message-id: 20210121190622.22000-20-peter.maydell@linaro.org | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | --- | ||
12 | hw/timer/cmsdk-apb-dualtimer.c | 42 ++++++++++++++++++++++++++++++---- | ||
13 | 1 file changed, 37 insertions(+), 5 deletions(-) | ||
5 | 14 | ||
6 | Signed-off-by: Hongbo Zhang <hongbo.zhang@linaro.org> | 15 | diff --git a/hw/timer/cmsdk-apb-dualtimer.c b/hw/timer/cmsdk-apb-dualtimer.c |
7 | Message-id: 1561890034-15921-3-git-send-email-hongbo.zhang@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/arm/sbsa-ref.c | 535 ++++++++++++++++++++++++++++++++++++++++++++++ | ||
12 | 1 file changed, 535 insertions(+) | ||
13 | |||
14 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/arm/sbsa-ref.c | 17 | --- a/hw/timer/cmsdk-apb-dualtimer.c |
17 | +++ b/hw/arm/sbsa-ref.c | 18 | +++ b/hw/timer/cmsdk-apb-dualtimer.c |
18 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_dualtimer_update(CMSDKAPBDualTimer *s) |
19 | */ | 20 | qemu_set_irq(s->timerintc, timintc); |
20 | 21 | } | |
21 | #include "qemu/osdep.h" | 22 | |
22 | +#include "qemu-common.h" | 23 | +static int cmsdk_dualtimermod_divisor(CMSDKAPBDualTimerModule *m) |
23 | #include "qapi/error.h" | ||
24 | #include "qemu/error-report.h" | ||
25 | #include "qemu/units.h" | ||
26 | +#include "sysemu/device_tree.h" | ||
27 | #include "sysemu/numa.h" | ||
28 | #include "sysemu/sysemu.h" | ||
29 | #include "exec/address-spaces.h" | ||
30 | #include "exec/hwaddr.h" | ||
31 | #include "kvm_arm.h" | ||
32 | #include "hw/arm/boot.h" | ||
33 | +#include "hw/block/flash.h" | ||
34 | #include "hw/boards.h" | ||
35 | +#include "hw/ide/internal.h" | ||
36 | +#include "hw/ide/ahci_internal.h" | ||
37 | #include "hw/intc/arm_gicv3_common.h" | ||
38 | +#include "hw/loader.h" | ||
39 | +#include "hw/pci-host/gpex.h" | ||
40 | +#include "hw/usb.h" | ||
41 | +#include "net/net.h" | ||
42 | |||
43 | #define RAMLIMIT_GB 8192 | ||
44 | #define RAMLIMIT_BYTES (RAMLIMIT_GB * GiB) | ||
45 | |||
46 | +#define NUM_IRQS 256 | ||
47 | +#define NUM_SMMU_IRQS 4 | ||
48 | +#define NUM_SATA_PORTS 6 | ||
49 | + | ||
50 | +#define VIRTUAL_PMU_IRQ 7 | ||
51 | +#define ARCH_GIC_MAINT_IRQ 9 | ||
52 | +#define ARCH_TIMER_VIRT_IRQ 11 | ||
53 | +#define ARCH_TIMER_S_EL1_IRQ 13 | ||
54 | +#define ARCH_TIMER_NS_EL1_IRQ 14 | ||
55 | +#define ARCH_TIMER_NS_EL2_IRQ 10 | ||
56 | + | ||
57 | enum { | ||
58 | SBSA_FLASH, | ||
59 | SBSA_MEM, | ||
60 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
61 | void *fdt; | ||
62 | int fdt_size; | ||
63 | int psci_conduit; | ||
64 | + PFlashCFI01 *flash[2]; | ||
65 | } SBSAMachineState; | ||
66 | |||
67 | #define TYPE_SBSA_MACHINE MACHINE_TYPE_NAME("sbsa-ref") | ||
68 | @@ -XXX,XX +XXX,XX @@ static const MemMapEntry sbsa_ref_memmap[] = { | ||
69 | [SBSA_MEM] = { 0x10000000000ULL, RAMLIMIT_BYTES }, | ||
70 | }; | ||
71 | |||
72 | +static const int sbsa_ref_irqmap[] = { | ||
73 | + [SBSA_UART] = 1, | ||
74 | + [SBSA_RTC] = 2, | ||
75 | + [SBSA_PCIE] = 3, /* ... to 6 */ | ||
76 | + [SBSA_GPIO] = 7, | ||
77 | + [SBSA_SECURE_UART] = 8, | ||
78 | + [SBSA_SECURE_UART_MM] = 9, | ||
79 | + [SBSA_AHCI] = 10, | ||
80 | + [SBSA_EHCI] = 11, | ||
81 | +}; | ||
82 | + | ||
83 | +/* | ||
84 | + * Firmware on this machine only uses ACPI table to load OS, these limited | ||
85 | + * device tree nodes are just to let firmware know the info which varies from | ||
86 | + * command line parameters, so it is not necessary to be fully compatible | ||
87 | + * with the kernel CPU and NUMA binding rules. | ||
88 | + */ | ||
89 | +static void create_fdt(SBSAMachineState *sms) | ||
90 | +{ | 24 | +{ |
91 | + void *fdt = create_device_tree(&sms->fdt_size); | 25 | + /* Return the divisor set by the current CONTROL.PRESCALE value */ |
92 | + const MachineState *ms = MACHINE(sms); | 26 | + switch (FIELD_EX32(m->control, CONTROL, PRESCALE)) { |
93 | + int cpu; | 27 | + case 0: |
94 | + | 28 | + return 1; |
95 | + if (!fdt) { | 29 | + case 1: |
96 | + error_report("create_device_tree() failed"); | 30 | + return 16; |
97 | + exit(1); | 31 | + case 2: |
98 | + } | 32 | + case 3: /* UNDEFINED, we treat like 2 (and complained when it was set) */ |
99 | + | 33 | + return 256; |
100 | + sms->fdt = fdt; | 34 | + default: |
101 | + | 35 | + g_assert_not_reached(); |
102 | + qemu_fdt_setprop_string(fdt, "/", "compatible", "linux,sbsa-ref"); | ||
103 | + qemu_fdt_setprop_cell(fdt, "/", "#address-cells", 0x2); | ||
104 | + qemu_fdt_setprop_cell(fdt, "/", "#size-cells", 0x2); | ||
105 | + | ||
106 | + if (have_numa_distance) { | ||
107 | + int size = nb_numa_nodes * nb_numa_nodes * 3 * sizeof(uint32_t); | ||
108 | + uint32_t *matrix = g_malloc0(size); | ||
109 | + int idx, i, j; | ||
110 | + | ||
111 | + for (i = 0; i < nb_numa_nodes; i++) { | ||
112 | + for (j = 0; j < nb_numa_nodes; j++) { | ||
113 | + idx = (i * nb_numa_nodes + j) * 3; | ||
114 | + matrix[idx + 0] = cpu_to_be32(i); | ||
115 | + matrix[idx + 1] = cpu_to_be32(j); | ||
116 | + matrix[idx + 2] = cpu_to_be32(numa_info[i].distance[j]); | ||
117 | + } | ||
118 | + } | ||
119 | + | ||
120 | + qemu_fdt_add_subnode(fdt, "/distance-map"); | ||
121 | + qemu_fdt_setprop(fdt, "/distance-map", "distance-matrix", | ||
122 | + matrix, size); | ||
123 | + g_free(matrix); | ||
124 | + } | ||
125 | + | ||
126 | + qemu_fdt_add_subnode(sms->fdt, "/cpus"); | ||
127 | + | ||
128 | + for (cpu = sms->smp_cpus - 1; cpu >= 0; cpu--) { | ||
129 | + char *nodename = g_strdup_printf("/cpus/cpu@%d", cpu); | ||
130 | + ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu)); | ||
131 | + CPUState *cs = CPU(armcpu); | ||
132 | + | ||
133 | + qemu_fdt_add_subnode(sms->fdt, nodename); | ||
134 | + | ||
135 | + if (ms->possible_cpus->cpus[cs->cpu_index].props.has_node_id) { | ||
136 | + qemu_fdt_setprop_cell(sms->fdt, nodename, "numa-node-id", | ||
137 | + ms->possible_cpus->cpus[cs->cpu_index].props.node_id); | ||
138 | + } | ||
139 | + | ||
140 | + g_free(nodename); | ||
141 | + } | 36 | + } |
142 | +} | 37 | +} |
143 | + | 38 | + |
144 | +#define SBSA_FLASH_SECTOR_SIZE (256 * KiB) | 39 | static void cmsdk_dualtimermod_write_control(CMSDKAPBDualTimerModule *m, |
145 | + | 40 | uint32_t newctrl) |
146 | +static PFlashCFI01 *sbsa_flash_create1(SBSAMachineState *sms, | 41 | { |
147 | + const char *name, | 42 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_dualtimermod_write_control(CMSDKAPBDualTimerModule *m, |
148 | + const char *alias_prop_name) | 43 | default: |
44 | g_assert_not_reached(); | ||
45 | } | ||
46 | - ptimer_set_freq(m->timer, m->parent->pclk_frq / divisor); | ||
47 | + ptimer_set_period_from_clock(m->timer, m->parent->timclk, divisor); | ||
48 | } | ||
49 | |||
50 | if (changed & R_CONTROL_MODE_MASK) { | ||
51 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_dualtimermod_reset(CMSDKAPBDualTimerModule *m) | ||
52 | * limit must both be set to 0xffff, so we wrap at 16 bits. | ||
53 | */ | ||
54 | ptimer_set_limit(m->timer, 0xffff, 1); | ||
55 | - ptimer_set_freq(m->timer, m->parent->pclk_frq); | ||
56 | + ptimer_set_period_from_clock(m->timer, m->parent->timclk, | ||
57 | + cmsdk_dualtimermod_divisor(m)); | ||
58 | ptimer_transaction_commit(m->timer); | ||
59 | } | ||
60 | |||
61 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_dualtimer_reset(DeviceState *dev) | ||
62 | s->timeritop = 0; | ||
63 | } | ||
64 | |||
65 | +static void cmsdk_apb_dualtimer_clk_update(void *opaque) | ||
149 | +{ | 66 | +{ |
150 | + /* | 67 | + CMSDKAPBDualTimer *s = CMSDK_APB_DUALTIMER(opaque); |
151 | + * Create a single flash device. We use the same parameters as | ||
152 | + * the flash devices on the Versatile Express board. | ||
153 | + */ | ||
154 | + DeviceState *dev = qdev_create(NULL, TYPE_PFLASH_CFI01); | ||
155 | + | ||
156 | + qdev_prop_set_uint64(dev, "sector-length", SBSA_FLASH_SECTOR_SIZE); | ||
157 | + qdev_prop_set_uint8(dev, "width", 4); | ||
158 | + qdev_prop_set_uint8(dev, "device-width", 2); | ||
159 | + qdev_prop_set_bit(dev, "big-endian", false); | ||
160 | + qdev_prop_set_uint16(dev, "id0", 0x89); | ||
161 | + qdev_prop_set_uint16(dev, "id1", 0x18); | ||
162 | + qdev_prop_set_uint16(dev, "id2", 0x00); | ||
163 | + qdev_prop_set_uint16(dev, "id3", 0x00); | ||
164 | + qdev_prop_set_string(dev, "name", name); | ||
165 | + object_property_add_child(OBJECT(sms), name, OBJECT(dev), | ||
166 | + &error_abort); | ||
167 | + object_property_add_alias(OBJECT(sms), alias_prop_name, | ||
168 | + OBJECT(dev), "drive", &error_abort); | ||
169 | + return PFLASH_CFI01(dev); | ||
170 | +} | ||
171 | + | ||
172 | +static void sbsa_flash_create(SBSAMachineState *sms) | ||
173 | +{ | ||
174 | + sms->flash[0] = sbsa_flash_create1(sms, "sbsa.flash0", "pflash0"); | ||
175 | + sms->flash[1] = sbsa_flash_create1(sms, "sbsa.flash1", "pflash1"); | ||
176 | +} | ||
177 | + | ||
178 | +static void sbsa_flash_map1(PFlashCFI01 *flash, | ||
179 | + hwaddr base, hwaddr size, | ||
180 | + MemoryRegion *sysmem) | ||
181 | +{ | ||
182 | + DeviceState *dev = DEVICE(flash); | ||
183 | + | ||
184 | + assert(size % SBSA_FLASH_SECTOR_SIZE == 0); | ||
185 | + assert(size / SBSA_FLASH_SECTOR_SIZE <= UINT32_MAX); | ||
186 | + qdev_prop_set_uint32(dev, "num-blocks", size / SBSA_FLASH_SECTOR_SIZE); | ||
187 | + qdev_init_nofail(dev); | ||
188 | + | ||
189 | + memory_region_add_subregion(sysmem, base, | ||
190 | + sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), | ||
191 | + 0)); | ||
192 | +} | ||
193 | + | ||
194 | +static void sbsa_flash_map(SBSAMachineState *sms, | ||
195 | + MemoryRegion *sysmem, | ||
196 | + MemoryRegion *secure_sysmem) | ||
197 | +{ | ||
198 | + /* | ||
199 | + * Map two flash devices to fill the SBSA_FLASH space in the memmap. | ||
200 | + * sysmem is the system memory space. secure_sysmem is the secure view | ||
201 | + * of the system, and the first flash device should be made visible only | ||
202 | + * there. The second flash device is visible to both secure and nonsecure. | ||
203 | + * If sysmem == secure_sysmem this means there is no separate Secure | ||
204 | + * address space and both flash devices are generally visible. | ||
205 | + */ | ||
206 | + hwaddr flashsize = sbsa_ref_memmap[SBSA_FLASH].size / 2; | ||
207 | + hwaddr flashbase = sbsa_ref_memmap[SBSA_FLASH].base; | ||
208 | + | ||
209 | + sbsa_flash_map1(sms->flash[0], flashbase, flashsize, | ||
210 | + secure_sysmem); | ||
211 | + sbsa_flash_map1(sms->flash[1], flashbase + flashsize, flashsize, | ||
212 | + sysmem); | ||
213 | +} | ||
214 | + | ||
215 | +static bool sbsa_firmware_init(SBSAMachineState *sms, | ||
216 | + MemoryRegion *sysmem, | ||
217 | + MemoryRegion *secure_sysmem) | ||
218 | +{ | ||
219 | + int i; | ||
220 | + BlockBackend *pflash_blk0; | ||
221 | + | ||
222 | + /* Map legacy -drive if=pflash to machine properties */ | ||
223 | + for (i = 0; i < ARRAY_SIZE(sms->flash); i++) { | ||
224 | + pflash_cfi01_legacy_drive(sms->flash[i], | ||
225 | + drive_get(IF_PFLASH, 0, i)); | ||
226 | + } | ||
227 | + | ||
228 | + sbsa_flash_map(sms, sysmem, secure_sysmem); | ||
229 | + | ||
230 | + pflash_blk0 = pflash_cfi01_get_blk(sms->flash[0]); | ||
231 | + | ||
232 | + if (bios_name) { | ||
233 | + char *fname; | ||
234 | + MemoryRegion *mr; | ||
235 | + int image_size; | ||
236 | + | ||
237 | + if (pflash_blk0) { | ||
238 | + error_report("The contents of the first flash device may be " | ||
239 | + "specified with -bios or with -drive if=pflash... " | ||
240 | + "but you cannot use both options at once"); | ||
241 | + exit(1); | ||
242 | + } | ||
243 | + | ||
244 | + /* Fall back to -bios */ | ||
245 | + | ||
246 | + fname = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); | ||
247 | + if (!fname) { | ||
248 | + error_report("Could not find ROM image '%s'", bios_name); | ||
249 | + exit(1); | ||
250 | + } | ||
251 | + mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(sms->flash[0]), 0); | ||
252 | + image_size = load_image_mr(fname, mr); | ||
253 | + g_free(fname); | ||
254 | + if (image_size < 0) { | ||
255 | + error_report("Could not load ROM image '%s'", bios_name); | ||
256 | + exit(1); | ||
257 | + } | ||
258 | + } | ||
259 | + | ||
260 | + return pflash_blk0 || bios_name; | ||
261 | +} | ||
262 | + | ||
263 | +static void create_secure_ram(SBSAMachineState *sms, | ||
264 | + MemoryRegion *secure_sysmem) | ||
265 | +{ | ||
266 | + MemoryRegion *secram = g_new(MemoryRegion, 1); | ||
267 | + hwaddr base = sbsa_ref_memmap[SBSA_SECURE_MEM].base; | ||
268 | + hwaddr size = sbsa_ref_memmap[SBSA_SECURE_MEM].size; | ||
269 | + | ||
270 | + memory_region_init_ram(secram, NULL, "sbsa-ref.secure-ram", size, | ||
271 | + &error_fatal); | ||
272 | + memory_region_add_subregion(secure_sysmem, base, secram); | ||
273 | +} | ||
274 | + | ||
275 | +static void create_gic(SBSAMachineState *sms, qemu_irq *pic) | ||
276 | +{ | ||
277 | + DeviceState *gicdev; | ||
278 | + SysBusDevice *gicbusdev; | ||
279 | + const char *gictype; | ||
280 | + uint32_t redist0_capacity, redist0_count; | ||
281 | + int i; | 68 | + int i; |
282 | + | 69 | + |
283 | + gictype = gicv3_class_name(); | 70 | + for (i = 0; i < ARRAY_SIZE(s->timermod); i++) { |
284 | + | 71 | + CMSDKAPBDualTimerModule *m = &s->timermod[i]; |
285 | + gicdev = qdev_create(NULL, gictype); | 72 | + ptimer_transaction_begin(m->timer); |
286 | + qdev_prop_set_uint32(gicdev, "revision", 3); | 73 | + ptimer_set_period_from_clock(m->timer, m->parent->timclk, |
287 | + qdev_prop_set_uint32(gicdev, "num-cpu", smp_cpus); | 74 | + cmsdk_dualtimermod_divisor(m)); |
288 | + /* | 75 | + ptimer_transaction_commit(m->timer); |
289 | + * Note that the num-irq property counts both internal and external | ||
290 | + * interrupts; there are always 32 of the former (mandated by GIC spec). | ||
291 | + */ | ||
292 | + qdev_prop_set_uint32(gicdev, "num-irq", NUM_IRQS + 32); | ||
293 | + qdev_prop_set_bit(gicdev, "has-security-extensions", true); | ||
294 | + | ||
295 | + redist0_capacity = | ||
296 | + sbsa_ref_memmap[SBSA_GIC_REDIST].size / GICV3_REDIST_SIZE; | ||
297 | + redist0_count = MIN(smp_cpus, redist0_capacity); | ||
298 | + | ||
299 | + qdev_prop_set_uint32(gicdev, "len-redist-region-count", 1); | ||
300 | + qdev_prop_set_uint32(gicdev, "redist-region-count[0]", redist0_count); | ||
301 | + | ||
302 | + qdev_init_nofail(gicdev); | ||
303 | + gicbusdev = SYS_BUS_DEVICE(gicdev); | ||
304 | + sysbus_mmio_map(gicbusdev, 0, sbsa_ref_memmap[SBSA_GIC_DIST].base); | ||
305 | + sysbus_mmio_map(gicbusdev, 1, sbsa_ref_memmap[SBSA_GIC_REDIST].base); | ||
306 | + | ||
307 | + /* | ||
308 | + * Wire the outputs from each CPU's generic timer and the GICv3 | ||
309 | + * maintenance interrupt signal to the appropriate GIC PPI inputs, | ||
310 | + * and the GIC's IRQ/FIQ/VIRQ/VFIQ interrupt outputs to the CPU's inputs. | ||
311 | + */ | ||
312 | + for (i = 0; i < smp_cpus; i++) { | ||
313 | + DeviceState *cpudev = DEVICE(qemu_get_cpu(i)); | ||
314 | + int ppibase = NUM_IRQS + i * GIC_INTERNAL + GIC_NR_SGIS; | ||
315 | + int irq; | ||
316 | + /* | ||
317 | + * Mapping from the output timer irq lines from the CPU to the | ||
318 | + * GIC PPI inputs used for this board. | ||
319 | + */ | ||
320 | + const int timer_irq[] = { | ||
321 | + [GTIMER_PHYS] = ARCH_TIMER_NS_EL1_IRQ, | ||
322 | + [GTIMER_VIRT] = ARCH_TIMER_VIRT_IRQ, | ||
323 | + [GTIMER_HYP] = ARCH_TIMER_NS_EL2_IRQ, | ||
324 | + [GTIMER_SEC] = ARCH_TIMER_S_EL1_IRQ, | ||
325 | + }; | ||
326 | + | ||
327 | + for (irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) { | ||
328 | + qdev_connect_gpio_out(cpudev, irq, | ||
329 | + qdev_get_gpio_in(gicdev, | ||
330 | + ppibase + timer_irq[irq])); | ||
331 | + } | ||
332 | + | ||
333 | + qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interrupt", 0, | ||
334 | + qdev_get_gpio_in(gicdev, ppibase | ||
335 | + + ARCH_GIC_MAINT_IRQ)); | ||
336 | + qdev_connect_gpio_out_named(cpudev, "pmu-interrupt", 0, | ||
337 | + qdev_get_gpio_in(gicdev, ppibase | ||
338 | + + VIRTUAL_PMU_IRQ)); | ||
339 | + | ||
340 | + sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ)); | ||
341 | + sysbus_connect_irq(gicbusdev, i + smp_cpus, | ||
342 | + qdev_get_gpio_in(cpudev, ARM_CPU_FIQ)); | ||
343 | + sysbus_connect_irq(gicbusdev, i + 2 * smp_cpus, | ||
344 | + qdev_get_gpio_in(cpudev, ARM_CPU_VIRQ)); | ||
345 | + sysbus_connect_irq(gicbusdev, i + 3 * smp_cpus, | ||
346 | + qdev_get_gpio_in(cpudev, ARM_CPU_VFIQ)); | ||
347 | + } | ||
348 | + | ||
349 | + for (i = 0; i < NUM_IRQS; i++) { | ||
350 | + pic[i] = qdev_get_gpio_in(gicdev, i); | ||
351 | + } | 76 | + } |
352 | +} | 77 | +} |
353 | + | 78 | + |
354 | +static void create_uart(const SBSAMachineState *sms, qemu_irq *pic, int uart, | 79 | static void cmsdk_apb_dualtimer_init(Object *obj) |
355 | + MemoryRegion *mem, Chardev *chr) | ||
356 | +{ | ||
357 | + hwaddr base = sbsa_ref_memmap[uart].base; | ||
358 | + int irq = sbsa_ref_irqmap[uart]; | ||
359 | + DeviceState *dev = qdev_create(NULL, "pl011"); | ||
360 | + SysBusDevice *s = SYS_BUS_DEVICE(dev); | ||
361 | + | ||
362 | + qdev_prop_set_chr(dev, "chardev", chr); | ||
363 | + qdev_init_nofail(dev); | ||
364 | + memory_region_add_subregion(mem, base, | ||
365 | + sysbus_mmio_get_region(s, 0)); | ||
366 | + sysbus_connect_irq(s, 0, pic[irq]); | ||
367 | +} | ||
368 | + | ||
369 | +static void create_rtc(const SBSAMachineState *sms, qemu_irq *pic) | ||
370 | +{ | ||
371 | + hwaddr base = sbsa_ref_memmap[SBSA_RTC].base; | ||
372 | + int irq = sbsa_ref_irqmap[SBSA_RTC]; | ||
373 | + | ||
374 | + sysbus_create_simple("pl031", base, pic[irq]); | ||
375 | +} | ||
376 | + | ||
377 | +static DeviceState *gpio_key_dev; | ||
378 | +static void sbsa_ref_powerdown_req(Notifier *n, void *opaque) | ||
379 | +{ | ||
380 | + /* use gpio Pin 3 for power button event */ | ||
381 | + qemu_set_irq(qdev_get_gpio_in(gpio_key_dev, 0), 1); | ||
382 | +} | ||
383 | + | ||
384 | +static Notifier sbsa_ref_powerdown_notifier = { | ||
385 | + .notify = sbsa_ref_powerdown_req | ||
386 | +}; | ||
387 | + | ||
388 | +static void create_gpio(const SBSAMachineState *sms, qemu_irq *pic) | ||
389 | +{ | ||
390 | + DeviceState *pl061_dev; | ||
391 | + hwaddr base = sbsa_ref_memmap[SBSA_GPIO].base; | ||
392 | + int irq = sbsa_ref_irqmap[SBSA_GPIO]; | ||
393 | + | ||
394 | + pl061_dev = sysbus_create_simple("pl061", base, pic[irq]); | ||
395 | + | ||
396 | + gpio_key_dev = sysbus_create_simple("gpio-key", -1, | ||
397 | + qdev_get_gpio_in(pl061_dev, 3)); | ||
398 | + | ||
399 | + /* connect powerdown request */ | ||
400 | + qemu_register_powerdown_notifier(&sbsa_ref_powerdown_notifier); | ||
401 | +} | ||
402 | + | ||
403 | +static void create_ahci(const SBSAMachineState *sms, qemu_irq *pic) | ||
404 | +{ | ||
405 | + hwaddr base = sbsa_ref_memmap[SBSA_AHCI].base; | ||
406 | + int irq = sbsa_ref_irqmap[SBSA_AHCI]; | ||
407 | + DeviceState *dev; | ||
408 | + DriveInfo *hd[NUM_SATA_PORTS]; | ||
409 | + SysbusAHCIState *sysahci; | ||
410 | + AHCIState *ahci; | ||
411 | + int i; | ||
412 | + | ||
413 | + dev = qdev_create(NULL, "sysbus-ahci"); | ||
414 | + qdev_prop_set_uint32(dev, "num-ports", NUM_SATA_PORTS); | ||
415 | + qdev_init_nofail(dev); | ||
416 | + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); | ||
417 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[irq]); | ||
418 | + | ||
419 | + sysahci = SYSBUS_AHCI(dev); | ||
420 | + ahci = &sysahci->ahci; | ||
421 | + ide_drive_get(hd, ARRAY_SIZE(hd)); | ||
422 | + for (i = 0; i < ahci->ports; i++) { | ||
423 | + if (hd[i] == NULL) { | ||
424 | + continue; | ||
425 | + } | ||
426 | + ide_create_drive(&ahci->dev[i].port, 0, hd[i]); | ||
427 | + } | ||
428 | +} | ||
429 | + | ||
430 | +static void create_ehci(const SBSAMachineState *sms, qemu_irq *pic) | ||
431 | +{ | ||
432 | + hwaddr base = sbsa_ref_memmap[SBSA_EHCI].base; | ||
433 | + int irq = sbsa_ref_irqmap[SBSA_EHCI]; | ||
434 | + | ||
435 | + sysbus_create_simple("platform-ehci-usb", base, pic[irq]); | ||
436 | +} | ||
437 | + | ||
438 | +static void create_smmu(const SBSAMachineState *sms, qemu_irq *pic, | ||
439 | + PCIBus *bus) | ||
440 | +{ | ||
441 | + hwaddr base = sbsa_ref_memmap[SBSA_SMMU].base; | ||
442 | + int irq = sbsa_ref_irqmap[SBSA_SMMU]; | ||
443 | + DeviceState *dev; | ||
444 | + int i; | ||
445 | + | ||
446 | + dev = qdev_create(NULL, "arm-smmuv3"); | ||
447 | + | ||
448 | + object_property_set_link(OBJECT(dev), OBJECT(bus), "primary-bus", | ||
449 | + &error_abort); | ||
450 | + qdev_init_nofail(dev); | ||
451 | + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); | ||
452 | + for (i = 0; i < NUM_SMMU_IRQS; i++) { | ||
453 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, pic[irq + i]); | ||
454 | + } | ||
455 | +} | ||
456 | + | ||
457 | +static void create_pcie(SBSAMachineState *sms, qemu_irq *pic) | ||
458 | +{ | ||
459 | + hwaddr base_ecam = sbsa_ref_memmap[SBSA_PCIE_ECAM].base; | ||
460 | + hwaddr size_ecam = sbsa_ref_memmap[SBSA_PCIE_ECAM].size; | ||
461 | + hwaddr base_mmio = sbsa_ref_memmap[SBSA_PCIE_MMIO].base; | ||
462 | + hwaddr size_mmio = sbsa_ref_memmap[SBSA_PCIE_MMIO].size; | ||
463 | + hwaddr base_mmio_high = sbsa_ref_memmap[SBSA_PCIE_MMIO_HIGH].base; | ||
464 | + hwaddr size_mmio_high = sbsa_ref_memmap[SBSA_PCIE_MMIO_HIGH].size; | ||
465 | + hwaddr base_pio = sbsa_ref_memmap[SBSA_PCIE_PIO].base; | ||
466 | + int irq = sbsa_ref_irqmap[SBSA_PCIE]; | ||
467 | + MemoryRegion *mmio_alias, *mmio_alias_high, *mmio_reg; | ||
468 | + MemoryRegion *ecam_alias, *ecam_reg; | ||
469 | + DeviceState *dev; | ||
470 | + PCIHostState *pci; | ||
471 | + int i; | ||
472 | + | ||
473 | + dev = qdev_create(NULL, TYPE_GPEX_HOST); | ||
474 | + qdev_init_nofail(dev); | ||
475 | + | ||
476 | + /* Map ECAM space */ | ||
477 | + ecam_alias = g_new0(MemoryRegion, 1); | ||
478 | + ecam_reg = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0); | ||
479 | + memory_region_init_alias(ecam_alias, OBJECT(dev), "pcie-ecam", | ||
480 | + ecam_reg, 0, size_ecam); | ||
481 | + memory_region_add_subregion(get_system_memory(), base_ecam, ecam_alias); | ||
482 | + | ||
483 | + /* Map the MMIO space */ | ||
484 | + mmio_alias = g_new0(MemoryRegion, 1); | ||
485 | + mmio_reg = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 1); | ||
486 | + memory_region_init_alias(mmio_alias, OBJECT(dev), "pcie-mmio", | ||
487 | + mmio_reg, base_mmio, size_mmio); | ||
488 | + memory_region_add_subregion(get_system_memory(), base_mmio, mmio_alias); | ||
489 | + | ||
490 | + /* Map the MMIO_HIGH space */ | ||
491 | + mmio_alias_high = g_new0(MemoryRegion, 1); | ||
492 | + memory_region_init_alias(mmio_alias_high, OBJECT(dev), "pcie-mmio-high", | ||
493 | + mmio_reg, base_mmio_high, size_mmio_high); | ||
494 | + memory_region_add_subregion(get_system_memory(), base_mmio_high, | ||
495 | + mmio_alias_high); | ||
496 | + | ||
497 | + /* Map IO port space */ | ||
498 | + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 2, base_pio); | ||
499 | + | ||
500 | + for (i = 0; i < GPEX_NUM_IRQS; i++) { | ||
501 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, pic[irq + i]); | ||
502 | + gpex_set_irq_num(GPEX_HOST(dev), i, irq + i); | ||
503 | + } | ||
504 | + | ||
505 | + pci = PCI_HOST_BRIDGE(dev); | ||
506 | + if (pci->bus) { | ||
507 | + for (i = 0; i < nb_nics; i++) { | ||
508 | + NICInfo *nd = &nd_table[i]; | ||
509 | + | ||
510 | + if (!nd->model) { | ||
511 | + nd->model = g_strdup("e1000e"); | ||
512 | + } | ||
513 | + | ||
514 | + pci_nic_init_nofail(nd, pci->bus, nd->model, NULL); | ||
515 | + } | ||
516 | + } | ||
517 | + | ||
518 | + pci_create_simple(pci->bus, -1, "VGA"); | ||
519 | + | ||
520 | + create_smmu(sms, pic, pci->bus); | ||
521 | +} | ||
522 | + | ||
523 | +static void *sbsa_ref_dtb(const struct arm_boot_info *binfo, int *fdt_size) | ||
524 | +{ | ||
525 | + const SBSAMachineState *board = container_of(binfo, SBSAMachineState, | ||
526 | + bootinfo); | ||
527 | + | ||
528 | + *fdt_size = board->fdt_size; | ||
529 | + return board->fdt; | ||
530 | +} | ||
531 | + | ||
532 | static void sbsa_ref_init(MachineState *machine) | ||
533 | { | 80 | { |
534 | SBSAMachineState *sms = SBSA_MACHINE(machine); | 81 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); |
535 | @@ -XXX,XX +XXX,XX @@ static void sbsa_ref_init(MachineState *machine) | 82 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_dualtimer_init(Object *obj) |
536 | MemoryRegion *sysmem = get_system_memory(); | 83 | for (i = 0; i < ARRAY_SIZE(s->timermod); i++) { |
537 | MemoryRegion *secure_sysmem = NULL; | 84 | sysbus_init_irq(sbd, &s->timermod[i].timerint); |
538 | MemoryRegion *ram = g_new(MemoryRegion, 1); | ||
539 | + bool firmware_loaded; | ||
540 | const CPUArchIdList *possible_cpus; | ||
541 | int n, sbsa_max_cpus; | ||
542 | + qemu_irq pic[NUM_IRQS]; | ||
543 | |||
544 | if (strcmp(machine->cpu_type, ARM_CPU_TYPE_NAME("cortex-a57"))) { | ||
545 | error_report("sbsa-ref: CPU type other than the built-in " | ||
546 | @@ -XXX,XX +XXX,XX @@ static void sbsa_ref_init(MachineState *machine) | ||
547 | exit(1); | ||
548 | } | 85 | } |
549 | 86 | - s->timclk = qdev_init_clock_in(DEVICE(s), "TIMCLK", NULL, NULL); | |
550 | + /* | 87 | + s->timclk = qdev_init_clock_in(DEVICE(s), "TIMCLK", |
551 | + * The Secure view of the world is the same as the NonSecure, | 88 | + cmsdk_apb_dualtimer_clk_update, s); |
552 | + * but with a few extra devices. Create it as a container region | ||
553 | + * containing the system memory at low priority; any secure-only | ||
554 | + * devices go in at higher priority and take precedence. | ||
555 | + */ | ||
556 | + secure_sysmem = g_new(MemoryRegion, 1); | ||
557 | + memory_region_init(secure_sysmem, OBJECT(machine), "secure-memory", | ||
558 | + UINT64_MAX); | ||
559 | + memory_region_add_subregion_overlap(secure_sysmem, 0, sysmem, -1); | ||
560 | + | ||
561 | + firmware_loaded = sbsa_firmware_init(sms, sysmem, | ||
562 | + secure_sysmem ?: sysmem); | ||
563 | + | ||
564 | + if (machine->kernel_filename && firmware_loaded) { | ||
565 | + error_report("sbsa-ref: No fw_cfg device on this machine, " | ||
566 | + "so -kernel option is not supported when firmware loaded, " | ||
567 | + "please load OS from hard disk instead"); | ||
568 | + exit(1); | ||
569 | + } | ||
570 | + | ||
571 | /* | ||
572 | * This machine has EL3 enabled, external firmware should supply PSCI | ||
573 | * implementation, so the QEMU's internal PSCI is disabled. | ||
574 | @@ -XXX,XX +XXX,XX @@ static void sbsa_ref_init(MachineState *machine) | ||
575 | machine->ram_size); | ||
576 | memory_region_add_subregion(sysmem, sbsa_ref_memmap[SBSA_MEM].base, ram); | ||
577 | |||
578 | + create_fdt(sms); | ||
579 | + | ||
580 | + create_secure_ram(sms, secure_sysmem); | ||
581 | + | ||
582 | + create_gic(sms, pic); | ||
583 | + | ||
584 | + create_uart(sms, pic, SBSA_UART, sysmem, serial_hd(0)); | ||
585 | + create_uart(sms, pic, SBSA_SECURE_UART, secure_sysmem, serial_hd(1)); | ||
586 | + /* Second secure UART for RAS and MM from EL0 */ | ||
587 | + create_uart(sms, pic, SBSA_SECURE_UART_MM, secure_sysmem, serial_hd(2)); | ||
588 | + | ||
589 | + create_rtc(sms, pic); | ||
590 | + | ||
591 | + create_gpio(sms, pic); | ||
592 | + | ||
593 | + create_ahci(sms, pic); | ||
594 | + | ||
595 | + create_ehci(sms, pic); | ||
596 | + | ||
597 | + create_pcie(sms, pic); | ||
598 | + | ||
599 | sms->bootinfo.ram_size = machine->ram_size; | ||
600 | sms->bootinfo.kernel_filename = machine->kernel_filename; | ||
601 | sms->bootinfo.nb_cpus = smp_cpus; | ||
602 | sms->bootinfo.board_id = -1; | ||
603 | sms->bootinfo.loader_start = sbsa_ref_memmap[SBSA_MEM].base; | ||
604 | + sms->bootinfo.get_dtb = sbsa_ref_dtb; | ||
605 | + sms->bootinfo.firmware_loaded = firmware_loaded; | ||
606 | arm_load_kernel(ARM_CPU(first_cpu), &sms->bootinfo); | ||
607 | } | 89 | } |
608 | 90 | ||
609 | @@ -XXX,XX +XXX,XX @@ sbsa_ref_get_default_cpu_node_id(const MachineState *ms, int idx) | 91 | static void cmsdk_apb_dualtimer_realize(DeviceState *dev, Error **errp) |
610 | return idx % nb_numa_nodes; | 92 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_dualtimer_realize(DeviceState *dev, Error **errp) |
611 | } | 93 | CMSDKAPBDualTimer *s = CMSDK_APB_DUALTIMER(dev); |
612 | 94 | int i; | |
613 | +static void sbsa_ref_instance_init(Object *obj) | 95 | |
614 | +{ | 96 | - if (s->pclk_frq == 0) { |
615 | + SBSAMachineState *sms = SBSA_MACHINE(obj); | 97 | - error_setg(errp, "CMSDK APB timer: pclk-frq property must be set"); |
616 | + | 98 | + if (!clock_has_source(s->timclk)) { |
617 | + sbsa_flash_create(sms); | 99 | + error_setg(errp, "CMSDK APB dualtimer: TIMCLK clock must be connected"); |
618 | +} | 100 | return; |
619 | + | 101 | } |
620 | static void sbsa_ref_class_init(ObjectClass *oc, void *data) | 102 | |
621 | { | ||
622 | MachineClass *mc = MACHINE_CLASS(oc); | ||
623 | @@ -XXX,XX +XXX,XX @@ static void sbsa_ref_class_init(ObjectClass *oc, void *data) | ||
624 | static const TypeInfo sbsa_ref_info = { | ||
625 | .name = TYPE_SBSA_MACHINE, | ||
626 | .parent = TYPE_MACHINE, | ||
627 | + .instance_init = sbsa_ref_instance_init, | ||
628 | .class_init = sbsa_ref_class_init, | ||
629 | .instance_size = sizeof(SBSAMachineState), | ||
630 | }; | ||
631 | -- | 103 | -- |
632 | 2.20.1 | 104 | 2.20.1 |
633 | 105 | ||
634 | 106 | diff view generated by jsdifflib |
1 | From: Andrew Jeffery <andrew@aj.id.au> | 1 | Switch the CMSDK APB watchdog device over to using its Clock input; |
---|---|---|---|
2 | the wdogclk_frq property is now ignored. | ||
2 | 3 | ||
3 | If the match value exceeds reload then we don't want to include it in | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | calculations for the next event. | 5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
6 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
7 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Message-id: 20210128114145.20536-21-peter.maydell@linaro.org | ||
9 | Message-id: 20210121190622.22000-21-peter.maydell@linaro.org | ||
10 | --- | ||
11 | hw/watchdog/cmsdk-apb-watchdog.c | 18 ++++++++++++++---- | ||
12 | 1 file changed, 14 insertions(+), 4 deletions(-) | ||
5 | 13 | ||
6 | Signed-off-by: Andrew Jeffery <andrew@aj.id.au> | 14 | diff --git a/hw/watchdog/cmsdk-apb-watchdog.c b/hw/watchdog/cmsdk-apb-watchdog.c |
7 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
8 | Message-id: 20190618165311.27066-10-clg@kaod.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/timer/aspeed_timer.c | 13 ++++++++++--- | ||
12 | 1 file changed, 10 insertions(+), 3 deletions(-) | ||
13 | |||
14 | diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/timer/aspeed_timer.c | 16 | --- a/hw/watchdog/cmsdk-apb-watchdog.c |
17 | +++ b/hw/timer/aspeed_timer.c | 17 | +++ b/hw/watchdog/cmsdk-apb-watchdog.c |
18 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t calculate_time(struct AspeedTimer *t, uint32_t ticks) | 18 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_reset(DeviceState *dev) |
19 | return t->start + delta_ns; | 19 | ptimer_transaction_commit(s->timer); |
20 | } | 20 | } |
21 | 21 | ||
22 | +static inline uint32_t calculate_match(struct AspeedTimer *t, int i) | 22 | +static void cmsdk_apb_watchdog_clk_update(void *opaque) |
23 | +{ | 23 | +{ |
24 | + return t->match[i] < t->reload ? t->match[i] : 0; | 24 | + CMSDKAPBWatchdog *s = CMSDK_APB_WATCHDOG(opaque); |
25 | + | ||
26 | + ptimer_transaction_begin(s->timer); | ||
27 | + ptimer_set_period_from_clock(s->timer, s->wdogclk, 1); | ||
28 | + ptimer_transaction_commit(s->timer); | ||
25 | +} | 29 | +} |
26 | + | 30 | + |
27 | static uint64_t calculate_next(struct AspeedTimer *t) | 31 | static void cmsdk_apb_watchdog_init(Object *obj) |
28 | { | 32 | { |
29 | uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | 33 | SysBusDevice *sbd = SYS_BUS_DEVICE(obj); |
30 | @@ -XXX,XX +XXX,XX @@ static uint64_t calculate_next(struct AspeedTimer *t) | 34 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_init(Object *obj) |
31 | * the timer counts down to zero. | 35 | s, "cmsdk-apb-watchdog", 0x1000); |
32 | */ | 36 | sysbus_init_mmio(sbd, &s->iomem); |
33 | 37 | sysbus_init_irq(sbd, &s->wdogint); | |
34 | - next = calculate_time(t, MAX(t->match[0], t->match[1])); | 38 | - s->wdogclk = qdev_init_clock_in(DEVICE(s), "WDOGCLK", NULL, NULL); |
35 | + next = calculate_time(t, MAX(calculate_match(t, 0), calculate_match(t, 1))); | 39 | + s->wdogclk = qdev_init_clock_in(DEVICE(s), "WDOGCLK", |
36 | if (now < next) { | 40 | + cmsdk_apb_watchdog_clk_update, s); |
37 | return next; | 41 | |
42 | s->is_luminary = false; | ||
43 | s->id = cmsdk_apb_watchdog_id; | ||
44 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_realize(DeviceState *dev, Error **errp) | ||
45 | { | ||
46 | CMSDKAPBWatchdog *s = CMSDK_APB_WATCHDOG(dev); | ||
47 | |||
48 | - if (s->wdogclk_frq == 0) { | ||
49 | + if (!clock_has_source(s->wdogclk)) { | ||
50 | error_setg(errp, | ||
51 | - "CMSDK APB watchdog: wdogclk-frq property must be set"); | ||
52 | + "CMSDK APB watchdog: WDOGCLK clock must be connected"); | ||
53 | return; | ||
38 | } | 54 | } |
39 | 55 | ||
40 | - next = calculate_time(t, MIN(t->match[0], t->match[1])); | 56 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_realize(DeviceState *dev, Error **errp) |
41 | + next = calculate_time(t, MIN(calculate_match(t, 0), calculate_match(t, 1))); | 57 | PTIMER_POLICY_NO_COUNTER_ROUND_DOWN); |
42 | if (now < next) { | 58 | |
43 | return next; | 59 | ptimer_transaction_begin(s->timer); |
44 | } | 60 | - ptimer_set_freq(s->timer, s->wdogclk_frq); |
45 | @@ -XXX,XX +XXX,XX @@ static uint64_t calculate_next(struct AspeedTimer *t) | 61 | + ptimer_set_period_from_clock(s->timer, s->wdogclk, 1); |
46 | qemu_set_irq(t->irq, t->level); | 62 | ptimer_transaction_commit(s->timer); |
47 | } | ||
48 | |||
49 | + next = MAX(MAX(calculate_match(t, 0), calculate_match(t, 1)), 0); | ||
50 | t->start = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); | ||
51 | - return calculate_time(t, MAX(MAX(t->match[0], t->match[1]), 0)); | ||
52 | + | ||
53 | + return calculate_time(t, next); | ||
54 | } | 63 | } |
55 | 64 | ||
56 | static void aspeed_timer_mod(AspeedTimer *t) | ||
57 | -- | 65 | -- |
58 | 2.20.1 | 66 | 2.20.1 |
59 | 67 | ||
60 | 68 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | Now that the CMSDK APB watchdog uses its Clock input, it will |
---|---|---|---|
2 | correctly respond when the system clock frequency is changed using | ||
3 | the RCC register on in the Stellaris board system registers. Test | ||
4 | that when the RCC register is written it causes the watchdog timer to | ||
5 | change speed. | ||
2 | 6 | ||
3 | This code is specific to the SoftFloat floating-point | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | implementation, which is only used by TCG. | 8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
9 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
10 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Message-id: 20210128114145.20536-22-peter.maydell@linaro.org | ||
12 | Message-id: 20210121190622.22000-22-peter.maydell@linaro.org | ||
13 | --- | ||
14 | tests/qtest/cmsdk-apb-watchdog-test.c | 52 +++++++++++++++++++++++++++ | ||
15 | 1 file changed, 52 insertions(+) | ||
5 | 16 | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 17 | diff --git a/tests/qtest/cmsdk-apb-watchdog-test.c b/tests/qtest/cmsdk-apb-watchdog-test.c |
7 | Message-id: 20190701132516.26392-18-philmd@redhat.com | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/vfp_helper.c | 26 +++++++++++++++++++++++--- | ||
12 | 1 file changed, 23 insertions(+), 3 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/vfp_helper.c | 19 | --- a/tests/qtest/cmsdk-apb-watchdog-test.c |
17 | +++ b/target/arm/vfp_helper.c | 20 | +++ b/tests/qtest/cmsdk-apb-watchdog-test.c |
18 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ |
19 | */ | 22 | */ |
20 | 23 | ||
21 | #include "qemu/osdep.h" | 24 | #include "qemu/osdep.h" |
22 | -#include "qemu/log.h" | 25 | +#include "qemu/bitops.h" |
23 | #include "cpu.h" | 26 | #include "libqtest-single.h" |
24 | #include "exec/helper-proto.h" | 27 | |
25 | -#include "fpu/softfloat.h" | 28 | /* |
26 | #include "internals.h" | 29 | @@ -XXX,XX +XXX,XX @@ |
27 | - | 30 | #define WDOGMIS 0x14 |
28 | +#ifdef CONFIG_TCG | 31 | #define WDOGLOCK 0xc00 |
29 | +#include "qemu/log.h" | 32 | |
30 | +#include "fpu/softfloat.h" | 33 | +#define SSYS_BASE 0x400fe000 |
31 | +#endif | 34 | +#define RCC 0x60 |
32 | 35 | +#define SYSDIV_SHIFT 23 | |
33 | /* VFP support. We follow the convention used for VFP instructions: | 36 | +#define SYSDIV_LENGTH 4 |
34 | Single precision routines have a "s" suffix, double precision a | ||
35 | "d" suffix. */ | ||
36 | |||
37 | +#ifdef CONFIG_TCG | ||
38 | + | 37 | + |
39 | /* Convert host exception flags to vfp form. */ | 38 | static void test_watchdog(void) |
40 | static inline int vfp_exceptbits_from_host(int host_bits) | ||
41 | { | 39 | { |
42 | @@ -XXX,XX +XXX,XX @@ static void vfp_set_fpscr_to_host(CPUARMState *env, uint32_t val) | 40 | g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0); |
43 | set_float_exception_flags(0, &env->vfp.standard_fp_status); | 41 | @@ -XXX,XX +XXX,XX @@ static void test_watchdog(void) |
42 | g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0); | ||
44 | } | 43 | } |
45 | 44 | ||
46 | +#else | 45 | +static void test_clock_change(void) |
46 | +{ | ||
47 | + uint32_t rcc; | ||
47 | + | 48 | + |
48 | +static uint32_t vfp_get_fpscr_from_host(CPUARMState *env) | 49 | + /* |
49 | +{ | 50 | + * Test that writing to the stellaris board's RCC register to |
50 | + return 0; | 51 | + * change the system clock frequency causes the watchdog |
52 | + * to change the speed it counts at. | ||
53 | + */ | ||
54 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0); | ||
55 | + | ||
56 | + writel(WDOG_BASE + WDOGCONTROL, 1); | ||
57 | + writel(WDOG_BASE + WDOGLOAD, 1000); | ||
58 | + | ||
59 | + /* Step to just past the 500th tick */ | ||
60 | + clock_step(80 * 500 + 1); | ||
61 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0); | ||
62 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 500); | ||
63 | + | ||
64 | + /* Rewrite RCC.SYSDIV from 16 to 8, so the clock is now 40ns per tick */ | ||
65 | + rcc = readl(SSYS_BASE + RCC); | ||
66 | + g_assert_cmpuint(extract32(rcc, SYSDIV_SHIFT, SYSDIV_LENGTH), ==, 0xf); | ||
67 | + rcc = deposit32(rcc, SYSDIV_SHIFT, SYSDIV_LENGTH, 7); | ||
68 | + writel(SSYS_BASE + RCC, rcc); | ||
69 | + | ||
70 | + /* Just past the 1000th tick: timer should have fired */ | ||
71 | + clock_step(40 * 500); | ||
72 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 1); | ||
73 | + | ||
74 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 0); | ||
75 | + | ||
76 | + /* VALUE reloads at following tick */ | ||
77 | + clock_step(41); | ||
78 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 1000); | ||
79 | + | ||
80 | + /* Writing any value to WDOGINTCLR clears the interrupt and reloads */ | ||
81 | + clock_step(40 * 500); | ||
82 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 500); | ||
83 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 1); | ||
84 | + writel(WDOG_BASE + WDOGINTCLR, 0); | ||
85 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGVALUE), ==, 1000); | ||
86 | + g_assert_cmpuint(readl(WDOG_BASE + WDOGRIS), ==, 0); | ||
51 | +} | 87 | +} |
52 | + | 88 | + |
53 | +static void vfp_set_fpscr_to_host(CPUARMState *env, uint32_t val) | 89 | int main(int argc, char **argv) |
54 | +{ | ||
55 | +} | ||
56 | + | ||
57 | +#endif | ||
58 | + | ||
59 | uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env) | ||
60 | { | 90 | { |
61 | uint32_t i, fpscr; | 91 | int r; |
62 | @@ -XXX,XX +XXX,XX @@ void vfp_set_fpscr(CPUARMState *env, uint32_t val) | 92 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) |
63 | HELPER(vfp_set_fpscr)(env, val); | 93 | qtest_start("-machine lm3s811evb"); |
64 | } | 94 | |
65 | 95 | qtest_add_func("/cmsdk-apb-watchdog/watchdog", test_watchdog); | |
66 | +#ifdef CONFIG_TCG | 96 | + qtest_add_func("/cmsdk-apb-watchdog/watchdog_clock_change", |
67 | + | 97 | + test_clock_change); |
68 | #define VFP_HELPER(name, p) HELPER(glue(glue(vfp_,name),p)) | 98 | |
69 | 99 | r = g_test_run(); | |
70 | #define VFP_BINOP(name) \ | 100 | |
71 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(frint64_d)(float64 f, void *fpst) | ||
72 | { | ||
73 | return frint_d(f, fpst, 64); | ||
74 | } | ||
75 | + | ||
76 | +#endif | ||
77 | -- | 101 | -- |
78 | 2.20.1 | 102 | 2.20.1 |
79 | 103 | ||
80 | 104 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | Use the MAINCLK Clock input to set the system_clock_scale variable |
---|---|---|---|
2 | rather than using the mainclk_frq property. | ||
2 | 3 | ||
3 | This will simplify the definition of new SoCs, like the AST2600 which | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | should use a different CPU and a different IRQ number layout. | 5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
6 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
8 | Message-id: 20210128114145.20536-23-peter.maydell@linaro.org | ||
9 | Message-id: 20210121190622.22000-23-peter.maydell@linaro.org | ||
10 | --- | ||
11 | hw/arm/armsse.c | 24 +++++++++++++++++++----- | ||
12 | 1 file changed, 19 insertions(+), 5 deletions(-) | ||
5 | 13 | ||
6 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 14 | diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
9 | Message-id: 20190618165311.27066-2-clg@kaod.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | include/hw/arm/aspeed_soc.h | 36 +++++++++++++++++++++++ | ||
13 | hw/arm/aspeed_soc.c | 57 +++++++++++++++++++++++++++++++------ | ||
14 | 2 files changed, 85 insertions(+), 8 deletions(-) | ||
15 | |||
16 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/include/hw/arm/aspeed_soc.h | 16 | --- a/hw/arm/armsse.c |
19 | +++ b/include/hw/arm/aspeed_soc.h | 17 | +++ b/hw/arm/armsse.c |
20 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCInfo { | 18 | @@ -XXX,XX +XXX,XX @@ static void armsse_forward_sec_resp_cfg(ARMSSE *s) |
21 | const char *fmc_typename; | 19 | qdev_connect_gpio_out(dev_splitter, 2, s->sec_resp_cfg_in); |
22 | const char **spi_typename; | 20 | } |
23 | int wdts_num; | 21 | |
24 | + const int *irqmap; | 22 | +static void armsse_mainclk_update(void *opaque) |
25 | } AspeedSoCInfo; | ||
26 | |||
27 | typedef struct AspeedSoCClass { | ||
28 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCClass { | ||
29 | #define ASPEED_SOC_GET_CLASS(obj) \ | ||
30 | OBJECT_GET_CLASS(AspeedSoCClass, (obj), TYPE_ASPEED_SOC) | ||
31 | |||
32 | +enum { | ||
33 | + ASPEED_IOMEM, | ||
34 | + ASPEED_UART1, | ||
35 | + ASPEED_UART2, | ||
36 | + ASPEED_UART3, | ||
37 | + ASPEED_UART4, | ||
38 | + ASPEED_UART5, | ||
39 | + ASPEED_VUART, | ||
40 | + ASPEED_FMC, | ||
41 | + ASPEED_SPI1, | ||
42 | + ASPEED_SPI2, | ||
43 | + ASPEED_VIC, | ||
44 | + ASPEED_SDMC, | ||
45 | + ASPEED_SCU, | ||
46 | + ASPEED_ADC, | ||
47 | + ASPEED_SRAM, | ||
48 | + ASPEED_GPIO, | ||
49 | + ASPEED_RTC, | ||
50 | + ASPEED_TIMER1, | ||
51 | + ASPEED_TIMER2, | ||
52 | + ASPEED_TIMER3, | ||
53 | + ASPEED_TIMER4, | ||
54 | + ASPEED_TIMER5, | ||
55 | + ASPEED_TIMER6, | ||
56 | + ASPEED_TIMER7, | ||
57 | + ASPEED_TIMER8, | ||
58 | + ASPEED_WDT, | ||
59 | + ASPEED_PWM, | ||
60 | + ASPEED_LPC, | ||
61 | + ASPEED_IBT, | ||
62 | + ASPEED_I2C, | ||
63 | + ASPEED_ETH1, | ||
64 | + ASPEED_ETH2, | ||
65 | +}; | ||
66 | + | ||
67 | #endif /* ASPEED_SOC_H */ | ||
68 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/hw/arm/aspeed_soc.c | ||
71 | +++ b/hw/arm/aspeed_soc.c | ||
72 | @@ -XXX,XX +XXX,XX @@ | ||
73 | #define ASPEED_SOC_ETH1_BASE 0x1E660000 | ||
74 | #define ASPEED_SOC_ETH2_BASE 0x1E680000 | ||
75 | |||
76 | -static const int uart_irqs[] = { 9, 32, 33, 34, 10 }; | ||
77 | -static const int timer_irqs[] = { 16, 17, 18, 35, 36, 37, 38, 39, }; | ||
78 | +static const int aspeed_soc_ast2400_irqmap[] = { | ||
79 | + [ASPEED_UART1] = 9, | ||
80 | + [ASPEED_UART2] = 32, | ||
81 | + [ASPEED_UART3] = 33, | ||
82 | + [ASPEED_UART4] = 34, | ||
83 | + [ASPEED_UART5] = 10, | ||
84 | + [ASPEED_VUART] = 8, | ||
85 | + [ASPEED_FMC] = 19, | ||
86 | + [ASPEED_SDMC] = 0, | ||
87 | + [ASPEED_SCU] = 21, | ||
88 | + [ASPEED_ADC] = 31, | ||
89 | + [ASPEED_GPIO] = 20, | ||
90 | + [ASPEED_RTC] = 22, | ||
91 | + [ASPEED_TIMER1] = 16, | ||
92 | + [ASPEED_TIMER2] = 17, | ||
93 | + [ASPEED_TIMER3] = 18, | ||
94 | + [ASPEED_TIMER4] = 35, | ||
95 | + [ASPEED_TIMER5] = 36, | ||
96 | + [ASPEED_TIMER6] = 37, | ||
97 | + [ASPEED_TIMER7] = 38, | ||
98 | + [ASPEED_TIMER8] = 39, | ||
99 | + [ASPEED_WDT] = 27, | ||
100 | + [ASPEED_PWM] = 28, | ||
101 | + [ASPEED_LPC] = 8, | ||
102 | + [ASPEED_IBT] = 8, /* LPC */ | ||
103 | + [ASPEED_I2C] = 12, | ||
104 | + [ASPEED_ETH1] = 2, | ||
105 | + [ASPEED_ETH2] = 3, | ||
106 | +}; | ||
107 | |||
108 | #define AST2400_SDRAM_BASE 0x40000000 | ||
109 | #define AST2500_SDRAM_BASE 0x80000000 | ||
110 | |||
111 | +/* AST2500 uses the same IRQs as the AST2400 */ | ||
112 | +#define aspeed_soc_ast2500_irqmap aspeed_soc_ast2400_irqmap | ||
113 | + | ||
114 | static const hwaddr aspeed_soc_ast2400_spi_bases[] = { ASPEED_SOC_SPI_BASE }; | ||
115 | static const char *aspeed_soc_ast2400_typenames[] = { "aspeed.smc.spi" }; | ||
116 | |||
117 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | ||
118 | .fmc_typename = "aspeed.smc.fmc", | ||
119 | .spi_typename = aspeed_soc_ast2400_typenames, | ||
120 | .wdts_num = 2, | ||
121 | + .irqmap = aspeed_soc_ast2400_irqmap, | ||
122 | }, { | ||
123 | .name = "ast2400-a1", | ||
124 | .cpu_type = ARM_CPU_TYPE_NAME("arm926"), | ||
125 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | ||
126 | .fmc_typename = "aspeed.smc.fmc", | ||
127 | .spi_typename = aspeed_soc_ast2400_typenames, | ||
128 | .wdts_num = 2, | ||
129 | + .irqmap = aspeed_soc_ast2400_irqmap, | ||
130 | }, { | ||
131 | .name = "ast2400", | ||
132 | .cpu_type = ARM_CPU_TYPE_NAME("arm926"), | ||
133 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | ||
134 | .fmc_typename = "aspeed.smc.fmc", | ||
135 | .spi_typename = aspeed_soc_ast2400_typenames, | ||
136 | .wdts_num = 2, | ||
137 | + .irqmap = aspeed_soc_ast2400_irqmap, | ||
138 | }, { | ||
139 | .name = "ast2500-a1", | ||
140 | .cpu_type = ARM_CPU_TYPE_NAME("arm1176"), | ||
141 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | ||
142 | .fmc_typename = "aspeed.smc.ast2500-fmc", | ||
143 | .spi_typename = aspeed_soc_ast2500_typenames, | ||
144 | .wdts_num = 3, | ||
145 | + .irqmap = aspeed_soc_ast2500_irqmap, | ||
146 | }, | ||
147 | }; | ||
148 | |||
149 | +static qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int ctrl) | ||
150 | +{ | 23 | +{ |
151 | + AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); | 24 | + ARMSSE *s = ARM_SSE(opaque); |
152 | + | 25 | + /* |
153 | + return qdev_get_gpio_in(DEVICE(&s->vic), sc->info->irqmap[ctrl]); | 26 | + * Set system_clock_scale from our Clock input; this is what |
27 | + * controls the tick rate of the CPU SysTick timer. | ||
28 | + */ | ||
29 | + system_clock_scale = clock_ticks_to_ns(s->mainclk, 1); | ||
154 | +} | 30 | +} |
155 | + | 31 | + |
156 | static void aspeed_soc_init(Object *obj) | 32 | static void armsse_init(Object *obj) |
157 | { | 33 | { |
158 | AspeedSoCState *s = ASPEED_SOC(obj); | 34 | ARMSSE *s = ARM_SSE(obj); |
159 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | 35 | @@ -XXX,XX +XXX,XX @@ static void armsse_init(Object *obj) |
36 | assert(info->sram_banks <= MAX_SRAM_BANKS); | ||
37 | assert(info->num_cpus <= SSE_MAX_CPUS); | ||
38 | |||
39 | - s->mainclk = qdev_init_clock_in(DEVICE(s), "MAINCLK", NULL, NULL); | ||
40 | + s->mainclk = qdev_init_clock_in(DEVICE(s), "MAINCLK", | ||
41 | + armsse_mainclk_update, s); | ||
42 | s->s32kclk = qdev_init_clock_in(DEVICE(s), "S32KCLK", NULL, NULL); | ||
43 | |||
44 | memory_region_init(&s->container, obj, "armsse-container", UINT64_MAX); | ||
45 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) | ||
160 | return; | 46 | return; |
161 | } | 47 | } |
162 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->timerctrl), 0, ASPEED_SOC_TIMER_BASE); | 48 | |
163 | - for (i = 0; i < ARRAY_SIZE(timer_irqs); i++) { | 49 | - if (!s->mainclk_frq) { |
164 | - qemu_irq irq = qdev_get_gpio_in(DEVICE(&s->vic), timer_irqs[i]); | 50 | - error_setg(errp, "MAINCLK_FRQ property was not set"); |
165 | + for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) { | 51 | - return; |
166 | + qemu_irq irq = aspeed_soc_get_irq(s, ASPEED_TIMER1 + i); | 52 | + if (!clock_has_source(s->mainclk)) { |
167 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->timerctrl), i, irq); | 53 | + error_setg(errp, "MAINCLK clock was not connected"); |
54 | + } | ||
55 | + if (!clock_has_source(s->s32kclk)) { | ||
56 | + error_setg(errp, "S32KCLK clock was not connected"); | ||
168 | } | 57 | } |
169 | 58 | ||
170 | /* UART - attach an 8250 to the IO space as our UART5 */ | 59 | assert(info->num_cpus <= SSE_MAX_CPUS); |
171 | if (serial_hd(0)) { | 60 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) |
172 | - qemu_irq uart5 = qdev_get_gpio_in(DEVICE(&s->vic), uart_irqs[4]); | 61 | */ |
173 | + qemu_irq uart5 = aspeed_soc_get_irq(s, ASPEED_UART5); | 62 | sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->container); |
174 | serial_mm_init(get_system_memory(), | 63 | |
175 | ASPEED_SOC_IOMEM_BASE + ASPEED_SOC_UART_5_BASE, 2, | 64 | - system_clock_scale = NANOSECONDS_PER_SECOND / s->mainclk_frq; |
176 | uart5, 38400, serial_hd(0), DEVICE_LITTLE_ENDIAN); | 65 | + /* Set initial system_clock_scale from MAINCLK */ |
177 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | 66 | + armsse_mainclk_update(s); |
178 | } | ||
179 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c), 0, ASPEED_SOC_I2C_BASE); | ||
180 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c), 0, | ||
181 | - qdev_get_gpio_in(DEVICE(&s->vic), 12)); | ||
182 | + aspeed_soc_get_irq(s, ASPEED_I2C)); | ||
183 | |||
184 | /* FMC, The number of CS is set at the board level */ | ||
185 | object_property_set_bool(OBJECT(&s->fmc), true, "realized", &err); | ||
186 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
187 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 1, | ||
188 | s->fmc.ctrl->flash_window_base); | ||
189 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->fmc), 0, | ||
190 | - qdev_get_gpio_in(DEVICE(&s->vic), 19)); | ||
191 | + aspeed_soc_get_irq(s, ASPEED_FMC)); | ||
192 | |||
193 | /* SPI */ | ||
194 | for (i = 0; i < sc->info->spis_num; i++) { | ||
195 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
196 | } | ||
197 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100), 0, ASPEED_SOC_ETH1_BASE); | ||
198 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100), 0, | ||
199 | - qdev_get_gpio_in(DEVICE(&s->vic), 2)); | ||
200 | + aspeed_soc_get_irq(s, ASPEED_ETH1)); | ||
201 | } | 67 | } |
202 | 68 | ||
203 | static void aspeed_soc_class_init(ObjectClass *oc, void *data) | 69 | static void armsse_idau_check(IDAUInterface *ii, uint32_t address, |
204 | -- | 70 | -- |
205 | 2.20.1 | 71 | 2.20.1 |
206 | 72 | ||
207 | 73 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | Remove all the code that sets frequency properties on the CMSDK |
---|---|---|---|
2 | timer, dualtimer and watchdog devices and on the ARMSSE SoC device: | ||
3 | these properties are unused now that the devices rely on their Clock | ||
4 | inputs instead. | ||
2 | 5 | ||
3 | The DRAM address of a DMA transaction depends on the DRAM base address | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | of the SoC. Inform the SMC controller model with this value. | 7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
8 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
9 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
10 | Message-id: 20210128114145.20536-24-peter.maydell@linaro.org | ||
11 | Message-id: 20210121190622.22000-24-peter.maydell@linaro.org | ||
12 | --- | ||
13 | hw/arm/armsse.c | 7 ------- | ||
14 | hw/arm/mps2-tz.c | 1 - | ||
15 | hw/arm/mps2.c | 3 --- | ||
16 | hw/arm/musca.c | 1 - | ||
17 | hw/arm/stellaris.c | 3 --- | ||
18 | 5 files changed, 15 deletions(-) | ||
5 | 19 | ||
6 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 20 | diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c |
7 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 20190618165311.27066-15-clg@kaod.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | include/hw/ssi/aspeed_smc.h | 3 +++ | ||
13 | hw/arm/aspeed_soc.c | 6 ++++++ | ||
14 | hw/ssi/aspeed_smc.c | 1 + | ||
15 | 3 files changed, 10 insertions(+) | ||
16 | |||
17 | diff --git a/include/hw/ssi/aspeed_smc.h b/include/hw/ssi/aspeed_smc.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/hw/ssi/aspeed_smc.h | 22 | --- a/hw/arm/armsse.c |
20 | +++ b/include/hw/ssi/aspeed_smc.h | 23 | +++ b/hw/arm/armsse.c |
21 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSMCState { | 24 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) |
22 | uint8_t r_timings; | 25 | * it to the appropriate PPC port; then we can realize the PPC and |
23 | uint8_t conf_enable_w0; | 26 | * map its upstream ends to the right place in the container. |
24 | 27 | */ | |
25 | + /* for DMA support */ | 28 | - qdev_prop_set_uint32(DEVICE(&s->timer0), "pclk-frq", s->mainclk_frq); |
26 | + uint64_t sdram_base; | 29 | qdev_connect_clock_in(DEVICE(&s->timer0), "pclk", s->mainclk); |
27 | + | 30 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->timer0), errp)) { |
28 | AspeedSMCFlash *flashes; | 31 | return; |
29 | 32 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) | |
30 | uint8_t snoop_index; | 33 | object_property_set_link(OBJECT(&s->apb_ppc0), "port[0]", OBJECT(mr), |
31 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | 34 | &error_abort); |
35 | |||
36 | - qdev_prop_set_uint32(DEVICE(&s->timer1), "pclk-frq", s->mainclk_frq); | ||
37 | qdev_connect_clock_in(DEVICE(&s->timer1), "pclk", s->mainclk); | ||
38 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->timer1), errp)) { | ||
39 | return; | ||
40 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) | ||
41 | object_property_set_link(OBJECT(&s->apb_ppc0), "port[1]", OBJECT(mr), | ||
42 | &error_abort); | ||
43 | |||
44 | - qdev_prop_set_uint32(DEVICE(&s->dualtimer), "pclk-frq", s->mainclk_frq); | ||
45 | qdev_connect_clock_in(DEVICE(&s->dualtimer), "TIMCLK", s->mainclk); | ||
46 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->dualtimer), errp)) { | ||
47 | return; | ||
48 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) | ||
49 | /* Devices behind APB PPC1: | ||
50 | * 0x4002f000: S32K timer | ||
51 | */ | ||
52 | - qdev_prop_set_uint32(DEVICE(&s->s32ktimer), "pclk-frq", S32KCLK); | ||
53 | qdev_connect_clock_in(DEVICE(&s->s32ktimer), "pclk", s->s32kclk); | ||
54 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->s32ktimer), errp)) { | ||
55 | return; | ||
56 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) | ||
57 | qdev_connect_gpio_out(DEVICE(&s->nmi_orgate), 0, | ||
58 | qdev_get_gpio_in_named(DEVICE(&s->armv7m), "NMI", 0)); | ||
59 | |||
60 | - qdev_prop_set_uint32(DEVICE(&s->s32kwatchdog), "wdogclk-frq", S32KCLK); | ||
61 | qdev_connect_clock_in(DEVICE(&s->s32kwatchdog), "WDOGCLK", s->s32kclk); | ||
62 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->s32kwatchdog), errp)) { | ||
63 | return; | ||
64 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) | ||
65 | |||
66 | /* 0x40080000 .. 0x4008ffff : ARMSSE second Base peripheral region */ | ||
67 | |||
68 | - qdev_prop_set_uint32(DEVICE(&s->nswatchdog), "wdogclk-frq", s->mainclk_frq); | ||
69 | qdev_connect_clock_in(DEVICE(&s->nswatchdog), "WDOGCLK", s->mainclk); | ||
70 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->nswatchdog), errp)) { | ||
71 | return; | ||
72 | @@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp) | ||
73 | armsse_get_common_irq_in(s, 1)); | ||
74 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->nswatchdog), 0, 0x40081000); | ||
75 | |||
76 | - qdev_prop_set_uint32(DEVICE(&s->swatchdog), "wdogclk-frq", s->mainclk_frq); | ||
77 | qdev_connect_clock_in(DEVICE(&s->swatchdog), "WDOGCLK", s->mainclk); | ||
78 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->swatchdog), errp)) { | ||
79 | return; | ||
80 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | 81 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/hw/arm/aspeed_soc.c | 82 | --- a/hw/arm/mps2-tz.c |
34 | +++ b/hw/arm/aspeed_soc.c | 83 | +++ b/hw/arm/mps2-tz.c |
35 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | 84 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) |
36 | aspeed_soc_get_irq(s, ASPEED_I2C)); | 85 | object_property_set_link(OBJECT(&mms->iotkit), "memory", |
37 | 86 | OBJECT(system_memory), &error_abort); | |
38 | /* FMC, The number of CS is set at the board level */ | 87 | qdev_prop_set_uint32(iotkitdev, "EXP_NUMIRQ", MPS2TZ_NUMIRQ); |
39 | + object_property_set_int(OBJECT(&s->fmc), sc->info->memmap[ASPEED_SDRAM], | 88 | - qdev_prop_set_uint32(iotkitdev, "MAINCLK_FRQ", SYSCLK_FRQ); |
40 | + "sdram-base", &err); | 89 | qdev_connect_clock_in(iotkitdev, "MAINCLK", mms->sysclk); |
41 | + if (err) { | 90 | qdev_connect_clock_in(iotkitdev, "S32KCLK", mms->s32kclk); |
42 | + error_propagate(errp, err); | 91 | sysbus_realize(SYS_BUS_DEVICE(&mms->iotkit), &error_fatal); |
43 | + return; | 92 | diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c |
44 | + } | ||
45 | object_property_set_bool(OBJECT(&s->fmc), true, "realized", &err); | ||
46 | if (err) { | ||
47 | error_propagate(errp, err); | ||
48 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | 93 | index XXXXXXX..XXXXXXX 100644 |
50 | --- a/hw/ssi/aspeed_smc.c | 94 | --- a/hw/arm/mps2.c |
51 | +++ b/hw/ssi/aspeed_smc.c | 95 | +++ b/hw/arm/mps2.c |
52 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_aspeed_smc = { | 96 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) |
53 | 97 | object_initialize_child(OBJECT(mms), name, &mms->timer[i], | |
54 | static Property aspeed_smc_properties[] = { | 98 | TYPE_CMSDK_APB_TIMER); |
55 | DEFINE_PROP_UINT32("num-cs", AspeedSMCState, num_cs, 1), | 99 | sbd = SYS_BUS_DEVICE(&mms->timer[i]); |
56 | + DEFINE_PROP_UINT64("sdram-base", AspeedSMCState, sdram_base, 0), | 100 | - qdev_prop_set_uint32(DEVICE(&mms->timer[i]), "pclk-frq", SYSCLK_FRQ); |
57 | DEFINE_PROP_END_OF_LIST(), | 101 | qdev_connect_clock_in(DEVICE(&mms->timer[i]), "pclk", mms->sysclk); |
58 | }; | 102 | sysbus_realize_and_unref(sbd, &error_fatal); |
103 | sysbus_mmio_map(sbd, 0, base); | ||
104 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) | ||
105 | |||
106 | object_initialize_child(OBJECT(mms), "dualtimer", &mms->dualtimer, | ||
107 | TYPE_CMSDK_APB_DUALTIMER); | ||
108 | - qdev_prop_set_uint32(DEVICE(&mms->dualtimer), "pclk-frq", SYSCLK_FRQ); | ||
109 | qdev_connect_clock_in(DEVICE(&mms->dualtimer), "TIMCLK", mms->sysclk); | ||
110 | sysbus_realize(SYS_BUS_DEVICE(&mms->dualtimer), &error_fatal); | ||
111 | sysbus_connect_irq(SYS_BUS_DEVICE(&mms->dualtimer), 0, | ||
112 | @@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine) | ||
113 | sysbus_mmio_map(SYS_BUS_DEVICE(&mms->dualtimer), 0, 0x40002000); | ||
114 | object_initialize_child(OBJECT(mms), "watchdog", &mms->watchdog, | ||
115 | TYPE_CMSDK_APB_WATCHDOG); | ||
116 | - qdev_prop_set_uint32(DEVICE(&mms->watchdog), "wdogclk-frq", SYSCLK_FRQ); | ||
117 | qdev_connect_clock_in(DEVICE(&mms->watchdog), "WDOGCLK", mms->sysclk); | ||
118 | sysbus_realize(SYS_BUS_DEVICE(&mms->watchdog), &error_fatal); | ||
119 | sysbus_connect_irq(SYS_BUS_DEVICE(&mms->watchdog), 0, | ||
120 | diff --git a/hw/arm/musca.c b/hw/arm/musca.c | ||
121 | index XXXXXXX..XXXXXXX 100644 | ||
122 | --- a/hw/arm/musca.c | ||
123 | +++ b/hw/arm/musca.c | ||
124 | @@ -XXX,XX +XXX,XX @@ static void musca_init(MachineState *machine) | ||
125 | qdev_prop_set_uint32(ssedev, "EXP_NUMIRQ", mmc->num_irqs); | ||
126 | qdev_prop_set_uint32(ssedev, "init-svtor", mmc->init_svtor); | ||
127 | qdev_prop_set_uint32(ssedev, "SRAM_ADDR_WIDTH", mmc->sram_addr_width); | ||
128 | - qdev_prop_set_uint32(ssedev, "MAINCLK_FRQ", SYSCLK_FRQ); | ||
129 | qdev_connect_clock_in(ssedev, "MAINCLK", mms->sysclk); | ||
130 | qdev_connect_clock_in(ssedev, "S32KCLK", mms->s32kclk); | ||
131 | /* | ||
132 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | ||
133 | index XXXXXXX..XXXXXXX 100644 | ||
134 | --- a/hw/arm/stellaris.c | ||
135 | +++ b/hw/arm/stellaris.c | ||
136 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
137 | if (board->dc1 & (1 << 3)) { /* watchdog present */ | ||
138 | dev = qdev_new(TYPE_LUMINARY_WATCHDOG); | ||
139 | |||
140 | - /* system_clock_scale is valid now */ | ||
141 | - uint32_t mainclk = NANOSECONDS_PER_SECOND / system_clock_scale; | ||
142 | - qdev_prop_set_uint32(dev, "wdogclk-frq", mainclk); | ||
143 | qdev_connect_clock_in(dev, "WDOGCLK", | ||
144 | qdev_get_clock_out(ssys_dev, "SYSCLK")); | ||
59 | 145 | ||
60 | -- | 146 | -- |
61 | 2.20.1 | 147 | 2.20.1 |
62 | 148 | ||
63 | 149 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | Now no users are setting the frq properties on the CMSDK timer, |
---|---|---|---|
2 | dualtimer, watchdog or ARMSSE SoC devices, we can remove the | ||
3 | properties and the struct fields that back them. | ||
2 | 4 | ||
3 | Since commit 8c06fbdf36b checkpatch.pl enforce a new multiline | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | comment syntax. Since we'll move this code around, fix its style | 6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
5 | first. | 7 | Reviewed-by: Luc Michel <luc@lmichel.fr> |
8 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Message-id: 20210128114145.20536-25-peter.maydell@linaro.org | ||
10 | Message-id: 20210121190622.22000-25-peter.maydell@linaro.org | ||
11 | --- | ||
12 | include/hw/arm/armsse.h | 2 -- | ||
13 | include/hw/timer/cmsdk-apb-dualtimer.h | 2 -- | ||
14 | include/hw/timer/cmsdk-apb-timer.h | 2 -- | ||
15 | include/hw/watchdog/cmsdk-apb-watchdog.h | 2 -- | ||
16 | hw/arm/armsse.c | 2 -- | ||
17 | hw/timer/cmsdk-apb-dualtimer.c | 6 ------ | ||
18 | hw/timer/cmsdk-apb-timer.c | 6 ------ | ||
19 | hw/watchdog/cmsdk-apb-watchdog.c | 6 ------ | ||
20 | 8 files changed, 28 deletions(-) | ||
6 | 21 | ||
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 22 | diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h |
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 20190701132516.26392-8-philmd@redhat.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/helper.c | 237 ++++++++++++++++++++++++++-------------- | ||
13 | target/arm/op_helper.c | 54 ++++++--- | ||
14 | target/arm/vfp_helper.c | 3 +- | ||
15 | 3 files changed, 196 insertions(+), 98 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper.c | 24 | --- a/include/hw/arm/armsse.h |
20 | +++ b/target/arm/helper.c | 25 | +++ b/include/hw/arm/armsse.h |
21 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr) | 26 | @@ -XXX,XX +XXX,XX @@ |
22 | 27 | * + Clock input "S32KCLK": slow 32KHz clock used for a few peripherals | |
23 | uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | 28 | * + QOM property "memory" is a MemoryRegion containing the devices provided |
29 | * by the board model. | ||
30 | - * + QOM property "MAINCLK_FRQ" is the frequency of the main system clock | ||
31 | * + QOM property "EXP_NUMIRQ" sets the number of expansion interrupts. | ||
32 | * (In hardware, the SSE-200 permits the number of expansion interrupts | ||
33 | * for the two CPUs to be configured separately, but we restrict it to | ||
34 | @@ -XXX,XX +XXX,XX @@ struct ARMSSE { | ||
35 | /* Properties */ | ||
36 | MemoryRegion *board_memory; | ||
37 | uint32_t exp_numirq; | ||
38 | - uint32_t mainclk_frq; | ||
39 | uint32_t sram_addr_width; | ||
40 | uint32_t init_svtor; | ||
41 | bool cpu_fpu[SSE_MAX_CPUS]; | ||
42 | diff --git a/include/hw/timer/cmsdk-apb-dualtimer.h b/include/hw/timer/cmsdk-apb-dualtimer.h | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/include/hw/timer/cmsdk-apb-dualtimer.h | ||
45 | +++ b/include/hw/timer/cmsdk-apb-dualtimer.h | ||
46 | @@ -XXX,XX +XXX,XX @@ | ||
47 | * https://developer.arm.com/products/system-design/system-design-kits/cortex-m-system-design-kit | ||
48 | * | ||
49 | * QEMU interface: | ||
50 | - * + QOM property "pclk-frq": frequency at which the timer is clocked | ||
51 | * + Clock input "TIMCLK": clock (for both timers) | ||
52 | * + sysbus MMIO region 0: the register bank | ||
53 | * + sysbus IRQ 0: combined timer interrupt TIMINTC | ||
54 | @@ -XXX,XX +XXX,XX @@ struct CMSDKAPBDualTimer { | ||
55 | /*< public >*/ | ||
56 | MemoryRegion iomem; | ||
57 | qemu_irq timerintc; | ||
58 | - uint32_t pclk_frq; | ||
59 | Clock *timclk; | ||
60 | |||
61 | CMSDKAPBDualTimerModule timermod[CMSDK_APB_DUALTIMER_NUM_MODULES]; | ||
62 | diff --git a/include/hw/timer/cmsdk-apb-timer.h b/include/hw/timer/cmsdk-apb-timer.h | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/include/hw/timer/cmsdk-apb-timer.h | ||
65 | +++ b/include/hw/timer/cmsdk-apb-timer.h | ||
66 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(CMSDKAPBTimer, CMSDK_APB_TIMER) | ||
67 | |||
68 | /* | ||
69 | * QEMU interface: | ||
70 | - * + QOM property "pclk-frq": frequency at which the timer is clocked | ||
71 | * + Clock input "pclk": clock for the timer | ||
72 | * + sysbus MMIO region 0: the register bank | ||
73 | * + sysbus IRQ 0: timer interrupt TIMERINT | ||
74 | @@ -XXX,XX +XXX,XX @@ struct CMSDKAPBTimer { | ||
75 | /*< public >*/ | ||
76 | MemoryRegion iomem; | ||
77 | qemu_irq timerint; | ||
78 | - uint32_t pclk_frq; | ||
79 | struct ptimer_state *timer; | ||
80 | Clock *pclk; | ||
81 | |||
82 | diff --git a/include/hw/watchdog/cmsdk-apb-watchdog.h b/include/hw/watchdog/cmsdk-apb-watchdog.h | ||
83 | index XXXXXXX..XXXXXXX 100644 | ||
84 | --- a/include/hw/watchdog/cmsdk-apb-watchdog.h | ||
85 | +++ b/include/hw/watchdog/cmsdk-apb-watchdog.h | ||
86 | @@ -XXX,XX +XXX,XX @@ | ||
87 | * https://developer.arm.com/products/system-design/system-design-kits/cortex-m-system-design-kit | ||
88 | * | ||
89 | * QEMU interface: | ||
90 | - * + QOM property "wdogclk-frq": frequency at which the watchdog is clocked | ||
91 | * + Clock input "WDOGCLK": clock for the watchdog's timer | ||
92 | * + sysbus MMIO region 0: the register bank | ||
93 | * + sysbus IRQ 0: watchdog interrupt | ||
94 | @@ -XXX,XX +XXX,XX @@ struct CMSDKAPBWatchdog { | ||
95 | /*< public >*/ | ||
96 | MemoryRegion iomem; | ||
97 | qemu_irq wdogint; | ||
98 | - uint32_t wdogclk_frq; | ||
99 | bool is_luminary; | ||
100 | struct ptimer_state *timer; | ||
101 | Clock *wdogclk; | ||
102 | diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c | ||
103 | index XXXXXXX..XXXXXXX 100644 | ||
104 | --- a/hw/arm/armsse.c | ||
105 | +++ b/hw/arm/armsse.c | ||
106 | @@ -XXX,XX +XXX,XX @@ static Property iotkit_properties[] = { | ||
107 | DEFINE_PROP_LINK("memory", ARMSSE, board_memory, TYPE_MEMORY_REGION, | ||
108 | MemoryRegion *), | ||
109 | DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64), | ||
110 | - DEFINE_PROP_UINT32("MAINCLK_FRQ", ARMSSE, mainclk_frq, 0), | ||
111 | DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 15), | ||
112 | DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000), | ||
113 | DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], true), | ||
114 | @@ -XXX,XX +XXX,XX @@ static Property armsse_properties[] = { | ||
115 | DEFINE_PROP_LINK("memory", ARMSSE, board_memory, TYPE_MEMORY_REGION, | ||
116 | MemoryRegion *), | ||
117 | DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64), | ||
118 | - DEFINE_PROP_UINT32("MAINCLK_FRQ", ARMSSE, mainclk_frq, 0), | ||
119 | DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 15), | ||
120 | DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000), | ||
121 | DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], false), | ||
122 | diff --git a/hw/timer/cmsdk-apb-dualtimer.c b/hw/timer/cmsdk-apb-dualtimer.c | ||
123 | index XXXXXXX..XXXXXXX 100644 | ||
124 | --- a/hw/timer/cmsdk-apb-dualtimer.c | ||
125 | +++ b/hw/timer/cmsdk-apb-dualtimer.c | ||
126 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription cmsdk_apb_dualtimer_vmstate = { | ||
127 | } | ||
128 | }; | ||
129 | |||
130 | -static Property cmsdk_apb_dualtimer_properties[] = { | ||
131 | - DEFINE_PROP_UINT32("pclk-frq", CMSDKAPBDualTimer, pclk_frq, 0), | ||
132 | - DEFINE_PROP_END_OF_LIST(), | ||
133 | -}; | ||
134 | - | ||
135 | static void cmsdk_apb_dualtimer_class_init(ObjectClass *klass, void *data) | ||
24 | { | 136 | { |
25 | - /* The TT instructions can be used by unprivileged code, but in | 137 | DeviceClass *dc = DEVICE_CLASS(klass); |
26 | + /* | 138 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_dualtimer_class_init(ObjectClass *klass, void *data) |
27 | + * The TT instructions can be used by unprivileged code, but in | 139 | dc->realize = cmsdk_apb_dualtimer_realize; |
28 | * user-only emulation we don't have the MPU. | 140 | dc->vmsd = &cmsdk_apb_dualtimer_vmstate; |
29 | * Luckily since we know we are NonSecure unprivileged (and that in | 141 | dc->reset = cmsdk_apb_dualtimer_reset; |
30 | * turn means that the A flag wasn't specified), all the bits in the | 142 | - device_class_set_props(dc, cmsdk_apb_dualtimer_properties); |
31 | @@ -XXX,XX +XXX,XX @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value, | ||
32 | return true; | ||
33 | |||
34 | pend_fault: | ||
35 | - /* By pending the exception at this point we are making | ||
36 | + /* | ||
37 | + * By pending the exception at this point we are making | ||
38 | * the IMPDEF choice "overridden exceptions pended" (see the | ||
39 | * MergeExcInfo() pseudocode). The other choice would be to not | ||
40 | * pend them now and then make a choice about which to throw away | ||
41 | @@ -XXX,XX +XXX,XX @@ static bool v7m_stack_read(ARMCPU *cpu, uint32_t *dest, uint32_t addr, | ||
42 | return true; | ||
43 | |||
44 | pend_fault: | ||
45 | - /* By pending the exception at this point we are making | ||
46 | + /* | ||
47 | + * By pending the exception at this point we are making | ||
48 | * the IMPDEF choice "overridden exceptions pended" (see the | ||
49 | * MergeExcInfo() pseudocode). The other choice would be to not | ||
50 | * pend them now and then make a choice about which to throw away | ||
51 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_preserve_fp_state)(CPUARMState *env) | ||
52 | */ | ||
53 | } | 143 | } |
54 | 144 | ||
55 | -/* Write to v7M CONTROL.SPSEL bit for the specified security bank. | 145 | static const TypeInfo cmsdk_apb_dualtimer_info = { |
56 | +/* | 146 | diff --git a/hw/timer/cmsdk-apb-timer.c b/hw/timer/cmsdk-apb-timer.c |
57 | + * Write to v7M CONTROL.SPSEL bit for the specified security bank. | 147 | index XXXXXXX..XXXXXXX 100644 |
58 | * This may change the current stack pointer between Main and Process | 148 | --- a/hw/timer/cmsdk-apb-timer.c |
59 | * stack pointers if it is done for the CONTROL register for the current | 149 | +++ b/hw/timer/cmsdk-apb-timer.c |
60 | * security state. | 150 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription cmsdk_apb_timer_vmstate = { |
61 | @@ -XXX,XX +XXX,XX @@ static void write_v7m_control_spsel_for_secstate(CPUARMState *env, | ||
62 | } | 151 | } |
152 | }; | ||
153 | |||
154 | -static Property cmsdk_apb_timer_properties[] = { | ||
155 | - DEFINE_PROP_UINT32("pclk-frq", CMSDKAPBTimer, pclk_frq, 0), | ||
156 | - DEFINE_PROP_END_OF_LIST(), | ||
157 | -}; | ||
158 | - | ||
159 | static void cmsdk_apb_timer_class_init(ObjectClass *klass, void *data) | ||
160 | { | ||
161 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
162 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_timer_class_init(ObjectClass *klass, void *data) | ||
163 | dc->realize = cmsdk_apb_timer_realize; | ||
164 | dc->vmsd = &cmsdk_apb_timer_vmstate; | ||
165 | dc->reset = cmsdk_apb_timer_reset; | ||
166 | - device_class_set_props(dc, cmsdk_apb_timer_properties); | ||
63 | } | 167 | } |
64 | 168 | ||
65 | -/* Write to v7M CONTROL.SPSEL bit. This may change the current | 169 | static const TypeInfo cmsdk_apb_timer_info = { |
66 | +/* | 170 | diff --git a/hw/watchdog/cmsdk-apb-watchdog.c b/hw/watchdog/cmsdk-apb-watchdog.c |
67 | + * Write to v7M CONTROL.SPSEL bit. This may change the current | 171 | index XXXXXXX..XXXXXXX 100644 |
68 | * stack pointer between Main and Process stack pointers. | 172 | --- a/hw/watchdog/cmsdk-apb-watchdog.c |
69 | */ | 173 | +++ b/hw/watchdog/cmsdk-apb-watchdog.c |
70 | static void write_v7m_control_spsel(CPUARMState *env, bool new_spsel) | 174 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription cmsdk_apb_watchdog_vmstate = { |
71 | @@ -XXX,XX +XXX,XX @@ static void write_v7m_control_spsel(CPUARMState *env, bool new_spsel) | 175 | } |
72 | 176 | }; | |
73 | void write_v7m_exception(CPUARMState *env, uint32_t new_exc) | 177 | |
178 | -static Property cmsdk_apb_watchdog_properties[] = { | ||
179 | - DEFINE_PROP_UINT32("wdogclk-frq", CMSDKAPBWatchdog, wdogclk_frq, 0), | ||
180 | - DEFINE_PROP_END_OF_LIST(), | ||
181 | -}; | ||
182 | - | ||
183 | static void cmsdk_apb_watchdog_class_init(ObjectClass *klass, void *data) | ||
74 | { | 184 | { |
75 | - /* Write a new value to v7m.exception, thus transitioning into or out | 185 | DeviceClass *dc = DEVICE_CLASS(klass); |
76 | + /* | 186 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_class_init(ObjectClass *klass, void *data) |
77 | + * Write a new value to v7m.exception, thus transitioning into or out | 187 | dc->realize = cmsdk_apb_watchdog_realize; |
78 | * of Handler mode; this may result in a change of active stack pointer. | 188 | dc->vmsd = &cmsdk_apb_watchdog_vmstate; |
79 | */ | 189 | dc->reset = cmsdk_apb_watchdog_reset; |
80 | bool new_is_psp, old_is_psp = v7m_using_psp(env); | 190 | - device_class_set_props(dc, cmsdk_apb_watchdog_properties); |
81 | @@ -XXX,XX +XXX,XX @@ static void switch_v7m_security_state(CPUARMState *env, bool new_secstate) | ||
82 | return; | ||
83 | } | ||
84 | |||
85 | - /* All the banked state is accessed by looking at env->v7m.secure | ||
86 | + /* | ||
87 | + * All the banked state is accessed by looking at env->v7m.secure | ||
88 | * except for the stack pointer; rearrange the SP appropriately. | ||
89 | */ | ||
90 | new_ss_msp = env->v7m.other_ss_msp; | ||
91 | @@ -XXX,XX +XXX,XX @@ static void switch_v7m_security_state(CPUARMState *env, bool new_secstate) | ||
92 | |||
93 | void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest) | ||
94 | { | ||
95 | - /* Handle v7M BXNS: | ||
96 | + /* | ||
97 | + * Handle v7M BXNS: | ||
98 | * - if the return value is a magic value, do exception return (like BX) | ||
99 | * - otherwise bit 0 of the return value is the target security state | ||
100 | */ | ||
101 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest) | ||
102 | } | ||
103 | |||
104 | if (dest >= min_magic) { | ||
105 | - /* This is an exception return magic value; put it where | ||
106 | + /* | ||
107 | + * This is an exception return magic value; put it where | ||
108 | * do_v7m_exception_exit() expects and raise EXCEPTION_EXIT. | ||
109 | * Note that if we ever add gen_ss_advance() singlestep support to | ||
110 | * M profile this should count as an "instruction execution complete" | ||
111 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest) | ||
112 | |||
113 | void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) | ||
114 | { | ||
115 | - /* Handle v7M BLXNS: | ||
116 | + /* | ||
117 | + * Handle v7M BLXNS: | ||
118 | * - bit 0 of the destination address is the target security state | ||
119 | */ | ||
120 | |||
121 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) | ||
122 | assert(env->v7m.secure); | ||
123 | |||
124 | if (dest & 1) { | ||
125 | - /* target is Secure, so this is just a normal BLX, | ||
126 | + /* | ||
127 | + * Target is Secure, so this is just a normal BLX, | ||
128 | * except that the low bit doesn't indicate Thumb/not. | ||
129 | */ | ||
130 | env->regs[14] = nextinst; | ||
131 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) | ||
132 | env->regs[13] = sp; | ||
133 | env->regs[14] = 0xfeffffff; | ||
134 | if (arm_v7m_is_handler_mode(env)) { | ||
135 | - /* Write a dummy value to IPSR, to avoid leaking the current secure | ||
136 | + /* | ||
137 | + * Write a dummy value to IPSR, to avoid leaking the current secure | ||
138 | * exception number to non-secure code. This is guaranteed not | ||
139 | * to cause write_v7m_exception() to actually change stacks. | ||
140 | */ | ||
141 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) | ||
142 | static uint32_t *get_v7m_sp_ptr(CPUARMState *env, bool secure, bool threadmode, | ||
143 | bool spsel) | ||
144 | { | ||
145 | - /* Return a pointer to the location where we currently store the | ||
146 | + /* | ||
147 | + * Return a pointer to the location where we currently store the | ||
148 | * stack pointer for the requested security state and thread mode. | ||
149 | * This pointer will become invalid if the CPU state is updated | ||
150 | * such that the stack pointers are switched around (eg changing | ||
151 | @@ -XXX,XX +XXX,XX @@ static bool arm_v7m_load_vector(ARMCPU *cpu, int exc, bool targets_secure, | ||
152 | |||
153 | mmu_idx = arm_v7m_mmu_idx_for_secstate_and_priv(env, targets_secure, true); | ||
154 | |||
155 | - /* We don't do a get_phys_addr() here because the rules for vector | ||
156 | + /* | ||
157 | + * We don't do a get_phys_addr() here because the rules for vector | ||
158 | * loads are special: they always use the default memory map, and | ||
159 | * the default memory map permits reads from all addresses. | ||
160 | * Since there's no easy way to pass through to pmsav8_mpu_lookup() | ||
161 | @@ -XXX,XX +XXX,XX @@ static bool arm_v7m_load_vector(ARMCPU *cpu, int exc, bool targets_secure, | ||
162 | return true; | ||
163 | |||
164 | load_fail: | ||
165 | - /* All vector table fetch fails are reported as HardFault, with | ||
166 | + /* | ||
167 | + * All vector table fetch fails are reported as HardFault, with | ||
168 | * HFSR.VECTTBL and .FORCED set. (FORCED is set because | ||
169 | * technically the underlying exception is a MemManage or BusFault | ||
170 | * that is escalated to HardFault.) This is a terminal exception, | ||
171 | @@ -XXX,XX +XXX,XX @@ static uint32_t v7m_integrity_sig(CPUARMState *env, uint32_t lr) | ||
172 | static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
173 | bool ignore_faults) | ||
174 | { | ||
175 | - /* For v8M, push the callee-saves register part of the stack frame. | ||
176 | + /* | ||
177 | + * For v8M, push the callee-saves register part of the stack frame. | ||
178 | * Compare the v8M pseudocode PushCalleeStack(). | ||
179 | * In the tailchaining case this may not be the current stack. | ||
180 | */ | ||
181 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
182 | return true; | ||
183 | } | ||
184 | |||
185 | - /* Write as much of the stack frame as we can. A write failure may | ||
186 | + /* | ||
187 | + * Write as much of the stack frame as we can. A write failure may | ||
188 | * cause us to pend a derived exception. | ||
189 | */ | ||
190 | sig = v7m_integrity_sig(env, lr); | ||
191 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
192 | static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
193 | bool ignore_stackfaults) | ||
194 | { | ||
195 | - /* Do the "take the exception" parts of exception entry, | ||
196 | + /* | ||
197 | + * Do the "take the exception" parts of exception entry, | ||
198 | * but not the pushing of state to the stack. This is | ||
199 | * similar to the pseudocode ExceptionTaken() function. | ||
200 | */ | ||
201 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
202 | if (arm_feature(env, ARM_FEATURE_V8)) { | ||
203 | if (arm_feature(env, ARM_FEATURE_M_SECURITY) && | ||
204 | (lr & R_V7M_EXCRET_S_MASK)) { | ||
205 | - /* The background code (the owner of the registers in the | ||
206 | + /* | ||
207 | + * The background code (the owner of the registers in the | ||
208 | * exception frame) is Secure. This means it may either already | ||
209 | * have or now needs to push callee-saves registers. | ||
210 | */ | ||
211 | if (targets_secure) { | ||
212 | if (dotailchain && !(lr & R_V7M_EXCRET_ES_MASK)) { | ||
213 | - /* We took an exception from Secure to NonSecure | ||
214 | + /* | ||
215 | + * We took an exception from Secure to NonSecure | ||
216 | * (which means the callee-saved registers got stacked) | ||
217 | * and are now tailchaining to a Secure exception. | ||
218 | * Clear DCRS so eventual return from this Secure | ||
219 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
220 | lr &= ~R_V7M_EXCRET_DCRS_MASK; | ||
221 | } | ||
222 | } else { | ||
223 | - /* We're going to a non-secure exception; push the | ||
224 | + /* | ||
225 | + * We're going to a non-secure exception; push the | ||
226 | * callee-saves registers to the stack now, if they're | ||
227 | * not already saved. | ||
228 | */ | ||
229 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
230 | lr |= R_V7M_EXCRET_SPSEL_MASK; | ||
231 | } | ||
232 | |||
233 | - /* Clear registers if necessary to prevent non-secure exception | ||
234 | + /* | ||
235 | + * Clear registers if necessary to prevent non-secure exception | ||
236 | * code being able to see register values from secure code. | ||
237 | * Where register values become architecturally UNKNOWN we leave | ||
238 | * them with their previous values. | ||
239 | */ | ||
240 | if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
241 | if (!targets_secure) { | ||
242 | - /* Always clear the caller-saved registers (they have been | ||
243 | + /* | ||
244 | + * Always clear the caller-saved registers (they have been | ||
245 | * pushed to the stack earlier in v7m_push_stack()). | ||
246 | * Clear callee-saved registers if the background code is | ||
247 | * Secure (in which case these regs were saved in | ||
248 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
249 | } | ||
250 | |||
251 | if (push_failed && !ignore_stackfaults) { | ||
252 | - /* Derived exception on callee-saves register stacking: | ||
253 | + /* | ||
254 | + * Derived exception on callee-saves register stacking: | ||
255 | * we might now want to take a different exception which | ||
256 | * targets a different security state, so try again from the top. | ||
257 | */ | ||
258 | @@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, | ||
259 | return; | ||
260 | } | ||
261 | |||
262 | - /* Now we've done everything that might cause a derived exception | ||
263 | + /* | ||
264 | + * Now we've done everything that might cause a derived exception | ||
265 | * we can go ahead and activate whichever exception we're going to | ||
266 | * take (which might now be the derived exception). | ||
267 | */ | ||
268 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr) | ||
269 | |||
270 | static bool v7m_push_stack(ARMCPU *cpu) | ||
271 | { | ||
272 | - /* Do the "set up stack frame" part of exception entry, | ||
273 | + /* | ||
274 | + * Do the "set up stack frame" part of exception entry, | ||
275 | * similar to pseudocode PushStack(). | ||
276 | * Return true if we generate a derived exception (and so | ||
277 | * should ignore further stack faults trying to process | ||
278 | @@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu) | ||
279 | } | ||
280 | } | ||
281 | |||
282 | - /* Write as much of the stack frame as we can. If we fail a stack | ||
283 | + /* | ||
284 | + * Write as much of the stack frame as we can. If we fail a stack | ||
285 | * write this will result in a derived exception being pended | ||
286 | * (which may be taken in preference to the one we started with | ||
287 | * if it has higher priority). | ||
288 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
289 | bool ftype; | ||
290 | bool restore_s16_s31; | ||
291 | |||
292 | - /* If we're not in Handler mode then jumps to magic exception-exit | ||
293 | + /* | ||
294 | + * If we're not in Handler mode then jumps to magic exception-exit | ||
295 | * addresses don't have magic behaviour. However for the v8M | ||
296 | * security extensions the magic secure-function-return has to | ||
297 | * work in thread mode too, so to avoid doing an extra check in | ||
298 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
299 | return; | ||
300 | } | ||
301 | |||
302 | - /* In the spec pseudocode ExceptionReturn() is called directly | ||
303 | + /* | ||
304 | + * In the spec pseudocode ExceptionReturn() is called directly | ||
305 | * from BXWritePC() and gets the full target PC value including | ||
306 | * bit zero. In QEMU's implementation we treat it as a normal | ||
307 | * jump-to-register (which is then caught later on), and so split | ||
308 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
309 | } | ||
310 | |||
311 | if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
312 | - /* EXC_RETURN.ES validation check (R_SMFL). We must do this before | ||
313 | + /* | ||
314 | + * EXC_RETURN.ES validation check (R_SMFL). We must do this before | ||
315 | * we pick which FAULTMASK to clear. | ||
316 | */ | ||
317 | if (!env->v7m.secure && | ||
318 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
319 | } | ||
320 | |||
321 | if (env->v7m.exception != ARMV7M_EXCP_NMI) { | ||
322 | - /* Auto-clear FAULTMASK on return from other than NMI. | ||
323 | + /* | ||
324 | + * Auto-clear FAULTMASK on return from other than NMI. | ||
325 | * If the security extension is implemented then this only | ||
326 | * happens if the raw execution priority is >= 0; the | ||
327 | * value of the ES bit in the exception return value indicates | ||
328 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
329 | /* still an irq active now */ | ||
330 | break; | ||
331 | case 1: | ||
332 | - /* we returned to base exception level, no nesting. | ||
333 | + /* | ||
334 | + * We returned to base exception level, no nesting. | ||
335 | * (In the pseudocode this is written using "NestedActivation != 1" | ||
336 | * where we have 'rettobase == false'.) | ||
337 | */ | ||
338 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
339 | |||
340 | if (arm_feature(env, ARM_FEATURE_V8)) { | ||
341 | if (!arm_feature(env, ARM_FEATURE_M_SECURITY)) { | ||
342 | - /* UNPREDICTABLE if S == 1 or DCRS == 0 or ES == 1 (R_XLCP); | ||
343 | + /* | ||
344 | + * UNPREDICTABLE if S == 1 or DCRS == 0 or ES == 1 (R_XLCP); | ||
345 | * we choose to take the UsageFault. | ||
346 | */ | ||
347 | if ((excret & R_V7M_EXCRET_S_MASK) || | ||
348 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
349 | break; | ||
350 | case 13: /* Return to Thread using Process stack */ | ||
351 | case 9: /* Return to Thread using Main stack */ | ||
352 | - /* We only need to check NONBASETHRDENA for v7M, because in | ||
353 | + /* | ||
354 | + * We only need to check NONBASETHRDENA for v7M, because in | ||
355 | * v8M this bit does not exist (it is RES1). | ||
356 | */ | ||
357 | if (!rettobase && | ||
358 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
359 | } | ||
360 | |||
361 | if (ufault) { | ||
362 | - /* Bad exception return: instead of popping the exception | ||
363 | + /* | ||
364 | + * Bad exception return: instead of popping the exception | ||
365 | * stack, directly take a usage fault on the current stack. | ||
366 | */ | ||
367 | env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVPC_MASK; | ||
368 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
369 | switch_v7m_security_state(env, return_to_secure); | ||
370 | |||
371 | { | ||
372 | - /* The stack pointer we should be reading the exception frame from | ||
373 | + /* | ||
374 | + * The stack pointer we should be reading the exception frame from | ||
375 | * depends on bits in the magic exception return type value (and | ||
376 | * for v8M isn't necessarily the stack pointer we will eventually | ||
377 | * end up resuming execution with). Get a pointer to the location | ||
378 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
379 | v7m_stack_read(cpu, &xpsr, frameptr + 0x1c, mmu_idx); | ||
380 | |||
381 | if (!pop_ok) { | ||
382 | - /* v7m_stack_read() pended a fault, so take it (as a tail | ||
383 | + /* | ||
384 | + * v7m_stack_read() pended a fault, so take it (as a tail | ||
385 | * chained exception on the same stack frame) | ||
386 | */ | ||
387 | qemu_log_mask(CPU_LOG_INT, "...derived exception on unstacking\n"); | ||
388 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
389 | return; | ||
390 | } | ||
391 | |||
392 | - /* Returning from an exception with a PC with bit 0 set is defined | ||
393 | + /* | ||
394 | + * Returning from an exception with a PC with bit 0 set is defined | ||
395 | * behaviour on v8M (bit 0 is ignored), but for v7M it was specified | ||
396 | * to be UNPREDICTABLE. In practice actual v7M hardware seems to ignore | ||
397 | * the lsbit, and there are several RTOSes out there which incorrectly | ||
398 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
399 | } | ||
400 | |||
401 | if (arm_feature(env, ARM_FEATURE_V8)) { | ||
402 | - /* For v8M we have to check whether the xPSR exception field | ||
403 | + /* | ||
404 | + * For v8M we have to check whether the xPSR exception field | ||
405 | * matches the EXCRET value for return to handler/thread | ||
406 | * before we commit to changing the SP and xPSR. | ||
407 | */ | ||
408 | bool will_be_handler = (xpsr & XPSR_EXCP) != 0; | ||
409 | if (return_to_handler != will_be_handler) { | ||
410 | - /* Take an INVPC UsageFault on the current stack. | ||
411 | + /* | ||
412 | + * Take an INVPC UsageFault on the current stack. | ||
413 | * By this point we will have switched to the security state | ||
414 | * for the background state, so this UsageFault will target | ||
415 | * that state. | ||
416 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
417 | frameptr += 0x40; | ||
418 | } | ||
419 | } | ||
420 | - /* Undo stack alignment (the SPREALIGN bit indicates that the original | ||
421 | + /* | ||
422 | + * Undo stack alignment (the SPREALIGN bit indicates that the original | ||
423 | * pre-exception SP was not 8-aligned and we added a padding word to | ||
424 | * align it, so we undo this by ORing in the bit that increases it | ||
425 | * from the current 8-aligned value to the 8-unaligned value. (Adding 4 | ||
426 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
427 | V7M_CONTROL, SFPA, sfpa); | ||
428 | } | ||
429 | |||
430 | - /* The restored xPSR exception field will be zero if we're | ||
431 | + /* | ||
432 | + * The restored xPSR exception field will be zero if we're | ||
433 | * resuming in Thread mode. If that doesn't match what the | ||
434 | * exception return excret specified then this is a UsageFault. | ||
435 | * v7M requires we make this check here; v8M did it earlier. | ||
436 | */ | ||
437 | if (return_to_handler != arm_v7m_is_handler_mode(env)) { | ||
438 | - /* Take an INVPC UsageFault by pushing the stack again; | ||
439 | + /* | ||
440 | + * Take an INVPC UsageFault by pushing the stack again; | ||
441 | * we know we're v7M so this is never a Secure UsageFault. | ||
442 | */ | ||
443 | bool ignore_stackfaults; | ||
444 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | ||
445 | |||
446 | static bool do_v7m_function_return(ARMCPU *cpu) | ||
447 | { | ||
448 | - /* v8M security extensions magic function return. | ||
449 | + /* | ||
450 | + * v8M security extensions magic function return. | ||
451 | * We may either: | ||
452 | * (1) throw an exception (longjump) | ||
453 | * (2) return true if we successfully handled the function return | ||
454 | @@ -XXX,XX +XXX,XX @@ static bool do_v7m_function_return(ARMCPU *cpu) | ||
455 | frame_sp_p = get_v7m_sp_ptr(env, true, threadmode, spsel); | ||
456 | frameptr = *frame_sp_p; | ||
457 | |||
458 | - /* These loads may throw an exception (for MPU faults). We want to | ||
459 | + /* | ||
460 | + * These loads may throw an exception (for MPU faults). We want to | ||
461 | * do them as secure, so work out what MMU index that is. | ||
462 | */ | ||
463 | mmu_idx = arm_v7m_mmu_idx_for_secstate(env, true); | ||
464 | @@ -XXX,XX +XXX,XX @@ static void arm_log_exception(int idx) | ||
465 | static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx, | ||
466 | uint32_t addr, uint16_t *insn) | ||
467 | { | ||
468 | - /* Load a 16-bit portion of a v7M instruction, returning true on success, | ||
469 | + /* | ||
470 | + * Load a 16-bit portion of a v7M instruction, returning true on success, | ||
471 | * or false on failure (in which case we will have pended the appropriate | ||
472 | * exception). | ||
473 | * We need to do the instruction fetch's MPU and SAU checks | ||
474 | @@ -XXX,XX +XXX,XX @@ static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx, | ||
475 | |||
476 | v8m_security_lookup(env, addr, MMU_INST_FETCH, mmu_idx, &sattrs); | ||
477 | if (!sattrs.nsc || sattrs.ns) { | ||
478 | - /* This must be the second half of the insn, and it straddles a | ||
479 | + /* | ||
480 | + * This must be the second half of the insn, and it straddles a | ||
481 | * region boundary with the second half not being S&NSC. | ||
482 | */ | ||
483 | env->v7m.sfsr |= R_V7M_SFSR_INVEP_MASK; | ||
484 | @@ -XXX,XX +XXX,XX @@ static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx, | ||
485 | |||
486 | static bool v7m_handle_execute_nsc(ARMCPU *cpu) | ||
487 | { | ||
488 | - /* Check whether this attempt to execute code in a Secure & NS-Callable | ||
489 | + /* | ||
490 | + * Check whether this attempt to execute code in a Secure & NS-Callable | ||
491 | * memory region is for an SG instruction; if so, then emulate the | ||
492 | * effect of the SG instruction and return true. Otherwise pend | ||
493 | * the correct kind of exception and return false. | ||
494 | @@ -XXX,XX +XXX,XX @@ static bool v7m_handle_execute_nsc(ARMCPU *cpu) | ||
495 | ARMMMUIdx mmu_idx; | ||
496 | uint16_t insn; | ||
497 | |||
498 | - /* We should never get here unless get_phys_addr_pmsav8() caused | ||
499 | + /* | ||
500 | + * We should never get here unless get_phys_addr_pmsav8() caused | ||
501 | * an exception for NS executing in S&NSC memory. | ||
502 | */ | ||
503 | assert(!env->v7m.secure); | ||
504 | @@ -XXX,XX +XXX,XX @@ static bool v7m_handle_execute_nsc(ARMCPU *cpu) | ||
505 | } | ||
506 | |||
507 | if (insn != 0xe97f) { | ||
508 | - /* Not an SG instruction first half (we choose the IMPDEF | ||
509 | + /* | ||
510 | + * Not an SG instruction first half (we choose the IMPDEF | ||
511 | * early-SG-check option). | ||
512 | */ | ||
513 | goto gen_invep; | ||
514 | @@ -XXX,XX +XXX,XX @@ static bool v7m_handle_execute_nsc(ARMCPU *cpu) | ||
515 | } | ||
516 | |||
517 | if (insn != 0xe97f) { | ||
518 | - /* Not an SG instruction second half (yes, both halves of the SG | ||
519 | + /* | ||
520 | + * Not an SG instruction second half (yes, both halves of the SG | ||
521 | * insn have the same hex value) | ||
522 | */ | ||
523 | goto gen_invep; | ||
524 | } | ||
525 | |||
526 | - /* OK, we have confirmed that we really have an SG instruction. | ||
527 | + /* | ||
528 | + * OK, we have confirmed that we really have an SG instruction. | ||
529 | * We know we're NS in S memory so don't need to repeat those checks. | ||
530 | */ | ||
531 | qemu_log_mask(CPU_LOG_INT, "...really an SG instruction at 0x%08" PRIx32 | ||
532 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | ||
533 | |||
534 | arm_log_exception(cs->exception_index); | ||
535 | |||
536 | - /* For exceptions we just mark as pending on the NVIC, and let that | ||
537 | - handle it. */ | ||
538 | + /* | ||
539 | + * For exceptions we just mark as pending on the NVIC, and let that | ||
540 | + * handle it. | ||
541 | + */ | ||
542 | switch (cs->exception_index) { | ||
543 | case EXCP_UDEF: | ||
544 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); | ||
545 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | ||
546 | break; | ||
547 | case EXCP_PREFETCH_ABORT: | ||
548 | case EXCP_DATA_ABORT: | ||
549 | - /* Note that for M profile we don't have a guest facing FSR, but | ||
550 | + /* | ||
551 | + * Note that for M profile we don't have a guest facing FSR, but | ||
552 | * the env->exception.fsr will be populated by the code that | ||
553 | * raises the fault, in the A profile short-descriptor format. | ||
554 | */ | ||
555 | switch (env->exception.fsr & 0xf) { | ||
556 | case M_FAKE_FSR_NSC_EXEC: | ||
557 | - /* Exception generated when we try to execute code at an address | ||
558 | + /* | ||
559 | + * Exception generated when we try to execute code at an address | ||
560 | * which is marked as Secure & Non-Secure Callable and the CPU | ||
561 | * is in the Non-Secure state. The only instruction which can | ||
562 | * be executed like this is SG (and that only if both halves of | ||
563 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | ||
564 | } | ||
565 | break; | ||
566 | case M_FAKE_FSR_SFAULT: | ||
567 | - /* Various flavours of SecureFault for attempts to execute or | ||
568 | + /* | ||
569 | + * Various flavours of SecureFault for attempts to execute or | ||
570 | * access data in the wrong security state. | ||
571 | */ | ||
572 | switch (cs->exception_index) { | ||
573 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | ||
574 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_BUS, false); | ||
575 | break; | ||
576 | default: | ||
577 | - /* All other FSR values are either MPU faults or "can't happen | ||
578 | + /* | ||
579 | + * All other FSR values are either MPU faults or "can't happen | ||
580 | * for M profile" cases. | ||
581 | */ | ||
582 | switch (cs->exception_index) { | ||
583 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | ||
584 | if (arm_feature(env, ARM_FEATURE_V8)) { | ||
585 | lr = R_V7M_EXCRET_RES1_MASK | | ||
586 | R_V7M_EXCRET_DCRS_MASK; | ||
587 | - /* The S bit indicates whether we should return to Secure | ||
588 | + /* | ||
589 | + * The S bit indicates whether we should return to Secure | ||
590 | * or NonSecure (ie our current state). | ||
591 | * The ES bit indicates whether we're taking this exception | ||
592 | * to Secure or NonSecure (ie our target state). We set it | ||
593 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | ||
594 | v7m_exception_taken(cpu, lr, false, ignore_stackfaults); | ||
595 | } | 191 | } |
596 | 192 | ||
597 | -/* Function used to synchronize QEMU's AArch64 register set with AArch32 | 193 | static const TypeInfo cmsdk_apb_watchdog_info = { |
598 | +/* | ||
599 | + * Function used to synchronize QEMU's AArch64 register set with AArch32 | ||
600 | * register set. This is necessary when switching between AArch32 and AArch64 | ||
601 | * execution state. | ||
602 | */ | ||
603 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env) | ||
604 | env->xregs[i] = env->regs[i]; | ||
605 | } | ||
606 | |||
607 | - /* Unless we are in FIQ mode, x8-x12 come from the user registers r8-r12. | ||
608 | + /* | ||
609 | + * Unless we are in FIQ mode, x8-x12 come from the user registers r8-r12. | ||
610 | * Otherwise, they come from the banked user regs. | ||
611 | */ | ||
612 | if (mode == ARM_CPU_MODE_FIQ) { | ||
613 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env) | ||
614 | } | ||
615 | } | ||
616 | |||
617 | - /* Registers x13-x23 are the various mode SP and FP registers. Registers | ||
618 | + /* | ||
619 | + * Registers x13-x23 are the various mode SP and FP registers. Registers | ||
620 | * r13 and r14 are only copied if we are in that mode, otherwise we copy | ||
621 | * from the mode banked register. | ||
622 | */ | ||
623 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env) | ||
624 | env->xregs[23] = env->banked_r13[bank_number(ARM_CPU_MODE_UND)]; | ||
625 | } | ||
626 | |||
627 | - /* Registers x24-x30 are mapped to r8-r14 in FIQ mode. If we are in FIQ | ||
628 | + /* | ||
629 | + * Registers x24-x30 are mapped to r8-r14 in FIQ mode. If we are in FIQ | ||
630 | * mode, then we can copy from r8-r14. Otherwise, we copy from the | ||
631 | * FIQ bank for r8-r14. | ||
632 | */ | ||
633 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env) | ||
634 | env->pc = env->regs[15]; | ||
635 | } | ||
636 | |||
637 | -/* Function used to synchronize QEMU's AArch32 register set with AArch64 | ||
638 | +/* | ||
639 | + * Function used to synchronize QEMU's AArch32 register set with AArch64 | ||
640 | * register set. This is necessary when switching between AArch32 and AArch64 | ||
641 | * execution state. | ||
642 | */ | ||
643 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env) | ||
644 | env->regs[i] = env->xregs[i]; | ||
645 | } | ||
646 | |||
647 | - /* Unless we are in FIQ mode, r8-r12 come from the user registers x8-x12. | ||
648 | + /* | ||
649 | + * Unless we are in FIQ mode, r8-r12 come from the user registers x8-x12. | ||
650 | * Otherwise, we copy x8-x12 into the banked user regs. | ||
651 | */ | ||
652 | if (mode == ARM_CPU_MODE_FIQ) { | ||
653 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env) | ||
654 | } | ||
655 | } | ||
656 | |||
657 | - /* Registers r13 & r14 depend on the current mode. | ||
658 | + /* | ||
659 | + * Registers r13 & r14 depend on the current mode. | ||
660 | * If we are in a given mode, we copy the corresponding x registers to r13 | ||
661 | * and r14. Otherwise, we copy the x register to the banked r13 and r14 | ||
662 | * for the mode. | ||
663 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env) | ||
664 | } else { | ||
665 | env->banked_r13[bank_number(ARM_CPU_MODE_USR)] = env->xregs[13]; | ||
666 | |||
667 | - /* HYP is an exception in that it does not have its own banked r14 but | ||
668 | + /* | ||
669 | + * HYP is an exception in that it does not have its own banked r14 but | ||
670 | * shares the USR r14 | ||
671 | */ | ||
672 | if (mode == ARM_CPU_MODE_HYP) { | ||
673 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) | ||
674 | return value; | ||
675 | } | ||
676 | case 0x94: /* CONTROL_NS */ | ||
677 | - /* We have to handle this here because unprivileged Secure code | ||
678 | + /* | ||
679 | + * We have to handle this here because unprivileged Secure code | ||
680 | * can read the NS CONTROL register. | ||
681 | */ | ||
682 | if (!env->v7m.secure) { | ||
683 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) | ||
684 | return env->v7m.faultmask[M_REG_NS]; | ||
685 | case 0x98: /* SP_NS */ | ||
686 | { | ||
687 | - /* This gives the non-secure SP selected based on whether we're | ||
688 | + /* | ||
689 | + * This gives the non-secure SP selected based on whether we're | ||
690 | * currently in handler mode or not, using the NS CONTROL.SPSEL. | ||
691 | */ | ||
692 | bool spsel = env->v7m.control[M_REG_NS] & R_V7M_CONTROL_SPSEL_MASK; | ||
693 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) | ||
694 | |||
695 | void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | ||
696 | { | ||
697 | - /* We're passed bits [11..0] of the instruction; extract | ||
698 | + /* | ||
699 | + * We're passed bits [11..0] of the instruction; extract | ||
700 | * SYSm and the mask bits. | ||
701 | * Invalid combinations of SYSm and mask are UNPREDICTABLE; | ||
702 | * we choose to treat them as if the mask bits were valid. | ||
703 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | ||
704 | return; | ||
705 | case 0x98: /* SP_NS */ | ||
706 | { | ||
707 | - /* This gives the non-secure SP selected based on whether we're | ||
708 | + /* | ||
709 | + * This gives the non-secure SP selected based on whether we're | ||
710 | * currently in handler mode or not, using the NS CONTROL.SPSEL. | ||
711 | */ | ||
712 | bool spsel = env->v7m.control[M_REG_NS] & R_V7M_CONTROL_SPSEL_MASK; | ||
713 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | ||
714 | bool targetsec = env->v7m.secure; | ||
715 | bool is_subpage; | ||
716 | |||
717 | - /* Work out what the security state and privilege level we're | ||
718 | + /* | ||
719 | + * Work out what the security state and privilege level we're | ||
720 | * interested in is... | ||
721 | */ | ||
722 | if (alt) { | ||
723 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | ||
724 | /* ...and then figure out which MMU index this is */ | ||
725 | mmu_idx = arm_v7m_mmu_idx_for_secstate_and_priv(env, targetsec, targetpriv); | ||
726 | |||
727 | - /* We know that the MPU and SAU don't care about the access type | ||
728 | + /* | ||
729 | + * We know that the MPU and SAU don't care about the access type | ||
730 | * for our purposes beyond that we don't want to claim to be | ||
731 | * an insn fetch, so we arbitrarily call this a read. | ||
732 | */ | ||
733 | |||
734 | - /* MPU region info only available for privileged or if | ||
735 | + /* | ||
736 | + * MPU region info only available for privileged or if | ||
737 | * inspecting the other MPU state. | ||
738 | */ | ||
739 | if (arm_current_el(env) != 0 || alt) { | ||
740 | @@ -XXX,XX +XXX,XX @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, | ||
741 | |||
742 | void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in) | ||
743 | { | ||
744 | - /* Implement DC ZVA, which zeroes a fixed-length block of memory. | ||
745 | + /* | ||
746 | + * Implement DC ZVA, which zeroes a fixed-length block of memory. | ||
747 | * Note that we do not implement the (architecturally mandated) | ||
748 | * alignment fault for attempts to use this on Device memory | ||
749 | * (which matches the usual QEMU behaviour of not implementing either | ||
750 | @@ -XXX,XX +XXX,XX @@ void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in) | ||
751 | |||
752 | #ifndef CONFIG_USER_ONLY | ||
753 | { | ||
754 | - /* Slightly awkwardly, QEMU's TARGET_PAGE_SIZE may be less than | ||
755 | + /* | ||
756 | + * Slightly awkwardly, QEMU's TARGET_PAGE_SIZE may be less than | ||
757 | * the block size so we might have to do more than one TLB lookup. | ||
758 | * We know that in fact for any v8 CPU the page size is at least 4K | ||
759 | * and the block size must be 2K or less, but TARGET_PAGE_SIZE is only | ||
760 | @@ -XXX,XX +XXX,XX @@ void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in) | ||
761 | } | ||
762 | } | ||
763 | if (i == maxidx) { | ||
764 | - /* If it's all in the TLB it's fair game for just writing to; | ||
765 | + /* | ||
766 | + * If it's all in the TLB it's fair game for just writing to; | ||
767 | * we know we don't need to update dirty status, etc. | ||
768 | */ | ||
769 | for (i = 0; i < maxidx - 1; i++) { | ||
770 | @@ -XXX,XX +XXX,XX @@ void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in) | ||
771 | memset(hostaddr[i], 0, blocklen - (i * TARGET_PAGE_SIZE)); | ||
772 | return; | ||
773 | } | ||
774 | - /* OK, try a store and see if we can populate the tlb. This | ||
775 | + /* | ||
776 | + * OK, try a store and see if we can populate the tlb. This | ||
777 | * might cause an exception if the memory isn't writable, | ||
778 | * in which case we will longjmp out of here. We must for | ||
779 | * this purpose use the actual register value passed to us | ||
780 | @@ -XXX,XX +XXX,XX @@ void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in) | ||
781 | } | ||
782 | } | ||
783 | |||
784 | - /* Slow path (probably attempt to do this to an I/O device or | ||
785 | + /* | ||
786 | + * Slow path (probably attempt to do this to an I/O device or | ||
787 | * similar, or clearing of a block of code we have translations | ||
788 | * cached for). Just do a series of byte writes as the architecture | ||
789 | * demands. It's not worth trying to use a cpu_physical_memory_map(), | ||
790 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
791 | index XXXXXXX..XXXXXXX 100644 | ||
792 | --- a/target/arm/op_helper.c | ||
793 | +++ b/target/arm/op_helper.c | ||
794 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t merge_syn_data_abort(uint32_t template_syn, | ||
795 | { | ||
796 | uint32_t syn; | ||
797 | |||
798 | - /* ISV is only set for data aborts routed to EL2 and | ||
799 | + /* | ||
800 | + * ISV is only set for data aborts routed to EL2 and | ||
801 | * never for stage-1 page table walks faulting on stage 2. | ||
802 | * | ||
803 | * Furthermore, ISV is only set for certain kinds of load/stores. | ||
804 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t merge_syn_data_abort(uint32_t template_syn, | ||
805 | syn = syn_data_abort_no_iss(same_el, | ||
806 | ea, 0, s1ptw, is_write, fsc); | ||
807 | } else { | ||
808 | - /* Fields: IL, ISV, SAS, SSE, SRT, SF and AR come from the template | ||
809 | + /* | ||
810 | + * Fields: IL, ISV, SAS, SSE, SRT, SF and AR come from the template | ||
811 | * syndrome created at translation time. | ||
812 | * Now we create the runtime syndrome with the remaining fields. | ||
813 | */ | ||
814 | @@ -XXX,XX +XXX,XX @@ void arm_deliver_fault(ARMCPU *cpu, vaddr addr, MMUAccessType access_type, | ||
815 | |||
816 | if (target_el == 2 || arm_el_is_aa64(env, target_el) || | ||
817 | arm_s1_regime_using_lpae_format(env, arm_mmu_idx)) { | ||
818 | - /* LPAE format fault status register : bottom 6 bits are | ||
819 | + /* | ||
820 | + * LPAE format fault status register : bottom 6 bits are | ||
821 | * status code in the same form as needed for syndrome | ||
822 | */ | ||
823 | fsr = arm_fi_to_lfsc(fi); | ||
824 | fsc = extract32(fsr, 0, 6); | ||
825 | } else { | ||
826 | fsr = arm_fi_to_sfsc(fi); | ||
827 | - /* Short format FSR : this fault will never actually be reported | ||
828 | + /* | ||
829 | + * Short format FSR : this fault will never actually be reported | ||
830 | * to an EL that uses a syndrome register. Use a (currently) | ||
831 | * reserved FSR code in case the constructed syndrome does leak | ||
832 | * into the guest somehow. | ||
833 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, | ||
834 | arm_deliver_fault(cpu, vaddr, access_type, mmu_idx, &fi); | ||
835 | } | ||
836 | |||
837 | -/* arm_cpu_do_transaction_failed: handle a memory system error response | ||
838 | +/* | ||
839 | + * arm_cpu_do_transaction_failed: handle a memory system error response | ||
840 | * (eg "no device/memory present at address") by raising an external abort | ||
841 | * exception | ||
842 | */ | ||
843 | @@ -XXX,XX +XXX,XX @@ static bool linked_bp_matches(ARMCPU *cpu, int lbn) | ||
844 | int bt; | ||
845 | uint32_t contextidr; | ||
846 | |||
847 | - /* Links to unimplemented or non-context aware breakpoints are | ||
848 | + /* | ||
849 | + * Links to unimplemented or non-context aware breakpoints are | ||
850 | * CONSTRAINED UNPREDICTABLE: either behave as if disabled, or | ||
851 | * as if linked to an UNKNOWN context-aware breakpoint (in which | ||
852 | * case DBGWCR<n>_EL1.LBN must indicate that breakpoint). | ||
853 | @@ -XXX,XX +XXX,XX @@ static bool linked_bp_matches(ARMCPU *cpu, int lbn) | ||
854 | |||
855 | bt = extract64(bcr, 20, 4); | ||
856 | |||
857 | - /* We match the whole register even if this is AArch32 using the | ||
858 | + /* | ||
859 | + * We match the whole register even if this is AArch32 using the | ||
860 | * short descriptor format (in which case it holds both PROCID and ASID), | ||
861 | * since we don't implement the optional v7 context ID masking. | ||
862 | */ | ||
863 | @@ -XXX,XX +XXX,XX @@ static bool linked_bp_matches(ARMCPU *cpu, int lbn) | ||
864 | case 9: /* linked VMID match (reserved if no EL2) */ | ||
865 | case 11: /* linked context ID and VMID match (reserved if no EL2) */ | ||
866 | default: | ||
867 | - /* Links to Unlinked context breakpoints must generate no | ||
868 | + /* | ||
869 | + * Links to Unlinked context breakpoints must generate no | ||
870 | * events; we choose to do the same for reserved values too. | ||
871 | */ | ||
872 | return false; | ||
873 | @@ -XXX,XX +XXX,XX @@ static bool bp_wp_matches(ARMCPU *cpu, int n, bool is_wp) | ||
874 | CPUARMState *env = &cpu->env; | ||
875 | uint64_t cr; | ||
876 | int pac, hmc, ssc, wt, lbn; | ||
877 | - /* Note that for watchpoints the check is against the CPU security | ||
878 | + /* | ||
879 | + * Note that for watchpoints the check is against the CPU security | ||
880 | * state, not the S/NS attribute on the offending data access. | ||
881 | */ | ||
882 | bool is_secure = arm_is_secure(env); | ||
883 | @@ -XXX,XX +XXX,XX @@ static bool bp_wp_matches(ARMCPU *cpu, int n, bool is_wp) | ||
884 | } | ||
885 | cr = env->cp15.dbgwcr[n]; | ||
886 | if (wp->hitattrs.user) { | ||
887 | - /* The LDRT/STRT/LDT/STT "unprivileged access" instructions should | ||
888 | + /* | ||
889 | + * The LDRT/STRT/LDT/STT "unprivileged access" instructions should | ||
890 | * match watchpoints as if they were accesses done at EL0, even if | ||
891 | * the CPU is at EL1 or higher. | ||
892 | */ | ||
893 | @@ -XXX,XX +XXX,XX @@ static bool bp_wp_matches(ARMCPU *cpu, int n, bool is_wp) | ||
894 | } | ||
895 | cr = env->cp15.dbgbcr[n]; | ||
896 | } | ||
897 | - /* The WATCHPOINT_HIT flag guarantees us that the watchpoint is | ||
898 | + /* | ||
899 | + * The WATCHPOINT_HIT flag guarantees us that the watchpoint is | ||
900 | * enabled and that the address and access type match; for breakpoints | ||
901 | * we know the address matched; check the remaining fields, including | ||
902 | * linked breakpoints. We rely on WCR and BCR having the same layout | ||
903 | @@ -XXX,XX +XXX,XX @@ static bool check_watchpoints(ARMCPU *cpu) | ||
904 | CPUARMState *env = &cpu->env; | ||
905 | int n; | ||
906 | |||
907 | - /* If watchpoints are disabled globally or we can't take debug | ||
908 | + /* | ||
909 | + * If watchpoints are disabled globally or we can't take debug | ||
910 | * exceptions here then watchpoint firings are ignored. | ||
911 | */ | ||
912 | if (extract32(env->cp15.mdscr_el1, 15, 1) == 0 | ||
913 | @@ -XXX,XX +XXX,XX @@ static bool check_breakpoints(ARMCPU *cpu) | ||
914 | CPUARMState *env = &cpu->env; | ||
915 | int n; | ||
916 | |||
917 | - /* If breakpoints are disabled globally or we can't take debug | ||
918 | + /* | ||
919 | + * If breakpoints are disabled globally or we can't take debug | ||
920 | * exceptions here then breakpoint firings are ignored. | ||
921 | */ | ||
922 | if (extract32(env->cp15.mdscr_el1, 15, 1) == 0 | ||
923 | @@ -XXX,XX +XXX,XX @@ void HELPER(check_breakpoints)(CPUARMState *env) | ||
924 | |||
925 | bool arm_debug_check_watchpoint(CPUState *cs, CPUWatchpoint *wp) | ||
926 | { | ||
927 | - /* Called by core code when a CPU watchpoint fires; need to check if this | ||
928 | + /* | ||
929 | + * Called by core code when a CPU watchpoint fires; need to check if this | ||
930 | * is also an architectural watchpoint match. | ||
931 | */ | ||
932 | ARMCPU *cpu = ARM_CPU(cs); | ||
933 | @@ -XXX,XX +XXX,XX @@ vaddr arm_adjust_watchpoint_address(CPUState *cs, vaddr addr, int len) | ||
934 | ARMCPU *cpu = ARM_CPU(cs); | ||
935 | CPUARMState *env = &cpu->env; | ||
936 | |||
937 | - /* In BE32 system mode, target memory is stored byteswapped (on a | ||
938 | + /* | ||
939 | + * In BE32 system mode, target memory is stored byteswapped (on a | ||
940 | * little-endian host system), and by the time we reach here (via an | ||
941 | * opcode helper) the addresses of subword accesses have been adjusted | ||
942 | * to account for that, which means that watchpoints will not match. | ||
943 | @@ -XXX,XX +XXX,XX @@ vaddr arm_adjust_watchpoint_address(CPUState *cs, vaddr addr, int len) | ||
944 | |||
945 | void arm_debug_excp_handler(CPUState *cs) | ||
946 | { | ||
947 | - /* Called by core code when a watchpoint or breakpoint fires; | ||
948 | + /* | ||
949 | + * Called by core code when a watchpoint or breakpoint fires; | ||
950 | * need to check which one and raise the appropriate exception. | ||
951 | */ | ||
952 | ARMCPU *cpu = ARM_CPU(cs); | ||
953 | @@ -XXX,XX +XXX,XX @@ void arm_debug_excp_handler(CPUState *cs) | ||
954 | uint64_t pc = is_a64(env) ? env->pc : env->regs[15]; | ||
955 | bool same_el = (arm_debug_target_el(env) == arm_current_el(env)); | ||
956 | |||
957 | - /* (1) GDB breakpoints should be handled first. | ||
958 | + /* | ||
959 | + * (1) GDB breakpoints should be handled first. | ||
960 | * (2) Do not raise a CPU exception if no CPU breakpoint has fired, | ||
961 | * since singlestep is also done by generating a debug internal | ||
962 | * exception. | ||
963 | @@ -XXX,XX +XXX,XX @@ void arm_debug_excp_handler(CPUState *cs) | ||
964 | } | ||
965 | |||
966 | env->exception.fsr = arm_debug_exception_fsr(env); | ||
967 | - /* FAR is UNKNOWN: clear vaddress to avoid potentially exposing | ||
968 | + /* | ||
969 | + * FAR is UNKNOWN: clear vaddress to avoid potentially exposing | ||
970 | * values to the guest that it shouldn't be able to see at its | ||
971 | * exception/security level. | ||
972 | */ | ||
973 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | ||
974 | index XXXXXXX..XXXXXXX 100644 | ||
975 | --- a/target/arm/vfp_helper.c | ||
976 | +++ b/target/arm/vfp_helper.c | ||
977 | @@ -XXX,XX +XXX,XX @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) | ||
978 | set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_f16); | ||
979 | } | ||
980 | |||
981 | - /* The exception flags are ORed together when we read fpscr so we | ||
982 | + /* | ||
983 | + * The exception flags are ORed together when we read fpscr so we | ||
984 | * only need to preserve the current state in one of our | ||
985 | * float_status values. | ||
986 | */ | ||
987 | -- | 194 | -- |
988 | 2.20.1 | 195 | 2.20.1 |
989 | 196 | ||
990 | 197 | diff view generated by jsdifflib |
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | 1 | Now that the watchdog device uses its Clock input rather than being |
---|---|---|---|
2 | passed the value of system_clock_scale at creation time, we can | ||
3 | remove the hack where we reset the STELLARIS_SYS at board creation | ||
4 | time to force it to set system_clock_scale. Instead it will be reset | ||
5 | at the usual point in startup and will inform the watchdog of the | ||
6 | clock frequency at that point. | ||
2 | 7 | ||
3 | Add no-op/unimplemented PCIE PHY IP block. Needed by new kernels to | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | use PCIE. | 9 | Reviewed-by: Luc Michel <luc@lmichel.fr> |
10 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
12 | Message-id: 20210128114145.20536-26-peter.maydell@linaro.org | ||
13 | Message-id: 20210121190622.22000-26-peter.maydell@linaro.org | ||
14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
15 | --- | ||
16 | hw/arm/stellaris.c | 10 ---------- | ||
17 | 1 file changed, 10 deletions(-) | ||
5 | 18 | ||
6 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> | 19 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c |
7 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Cc: Michael S. Tsirkin <mst@redhat.com> | ||
9 | Cc: qemu-devel@nongnu.org | ||
10 | Cc: qemu-arm@nongnu.org | ||
11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | include/hw/arm/fsl-imx7.h | 3 +++ | ||
15 | hw/arm/fsl-imx7.c | 5 +++++ | ||
16 | 2 files changed, 8 insertions(+) | ||
17 | |||
18 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/include/hw/arm/fsl-imx7.h | 21 | --- a/hw/arm/stellaris.c |
21 | +++ b/include/hw/arm/fsl-imx7.h | 22 | +++ b/hw/arm/stellaris.c |
22 | @@ -XXX,XX +XXX,XX @@ enum FslIMX7MemoryMap { | 23 | @@ -XXX,XX +XXX,XX @@ static DeviceState *stellaris_sys_init(uint32_t base, qemu_irq irq, |
23 | FSL_IMX7_ADC2_ADDR = 0x30620000, | 24 | sysbus_mmio_map(sbd, 0, base); |
24 | FSL_IMX7_ADCn_SIZE = 0x1000, | 25 | sysbus_connect_irq(sbd, 0, irq); |
25 | 26 | ||
26 | + FSL_IMX7_PCIE_PHY_ADDR = 0x306D0000, | 27 | - /* |
27 | + FSL_IMX7_PCIE_PHY_SIZE = 0x10000, | 28 | - * Normally we should not be resetting devices like this during |
28 | + | 29 | - * board creation. For the moment we need to do so, because |
29 | FSL_IMX7_GPC_ADDR = 0x303A0000, | 30 | - * system_clock_scale will only get set when the STELLARIS_SYS |
30 | 31 | - * device is reset, and we need its initial value to pass to | |
31 | FSL_IMX7_I2C1_ADDR = 0x30A20000, | 32 | - * the watchdog device. This hack can be removed once the |
32 | diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c | 33 | - * watchdog has been converted to use a Clock input instead. |
33 | index XXXXXXX..XXXXXXX 100644 | 34 | - */ |
34 | --- a/hw/arm/fsl-imx7.c | 35 | - device_cold_reset(dev); |
35 | +++ b/hw/arm/fsl-imx7.c | 36 | - |
36 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) | 37 | return dev; |
37 | */ | ||
38 | create_unimplemented_device("dma-apbh", FSL_IMX7_DMA_APBH_ADDR, | ||
39 | FSL_IMX7_DMA_APBH_SIZE); | ||
40 | + /* | ||
41 | + * PCIe PHY | ||
42 | + */ | ||
43 | + create_unimplemented_device("pcie-phy", FSL_IMX7_PCIE_PHY_ADDR, | ||
44 | + FSL_IMX7_PCIE_PHY_SIZE); | ||
45 | } | 38 | } |
46 | 39 | ||
47 | static void fsl_imx7_class_init(ObjectClass *oc, void *data) | ||
48 | -- | 40 | -- |
49 | 2.20.1 | 41 | 2.20.1 |
50 | 42 | ||
51 | 43 | diff view generated by jsdifflib |