1
target-arm queue for softfreeze: this is quite big as I
1
Arm queue; not huge but I figured I might as well send it out since
2
was on holiday last week, so this is all just sneaking in
2
I've been doing code review today and there's no queue of unprocessed
3
under the wire. I particularly wanted to get Philippe's
3
pullreqs...
4
patches in before freeze as that sort of code-movement
5
patchset is painful to have to rebase.
6
4
7
thanks
5
thanks
8
-- PMM
6
-- PMM
9
7
10
The following changes since commit ae9108f8f0746ce64d02afb1a216153a50926132:
8
The following changes since commit b3f846c59d8405bb87c551187721fc92ff2f1b92:
11
9
12
Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-4.1-pull-request' into staging (2019-07-01 15:55:40 +0100)
10
Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2021-01-11v2' into staging (2021-01-11 15:15:35 +0000)
13
11
14
are available in the Git repository at:
12
are available in the Git repository at:
15
13
16
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190701
14
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210112
17
15
18
for you to fetch changes up to 787a7e76c2e93a48c47b324fea592c9910a70483:
16
for you to fetch changes up to 19d131395ccaf503db21dadd8257e6dc9fc1d7de:
19
17
20
target/arm: Declare some M-profile functions publicly (2019-07-01 17:29:01 +0100)
18
ui/cocoa: Fix openFile: deprecation on Big Sur (2021-01-12 11:38:37 +0000)
21
19
22
----------------------------------------------------------------
20
----------------------------------------------------------------
23
target-arm queue:
21
target-arm queue:
24
* hw/arm/boot: fix direct kernel boot with initrd
22
* arm: Support emulation of ARMv8.4-TTST extension
25
* hw/arm/msf2-som: Exit when the cpu is not the expected one
23
* arm: Update cpu.h ID register field definitions
26
* i.mx7: fix bugs in PCI controller needed to boot recent kernels
24
* arm: Fix breakage of XScale instruction emulation
27
* aspeed: add RTC device
25
* hw/net/lan9118: Fix RX Status FIFO PEEK value
28
* aspeed: fix some timer device bugs
26
* npcm7xx: Add ADC and PWM emulation
29
* aspeed: add swift-bmc board
27
* ui/cocoa: Make "open docs" help menu entry work again when binary
30
* aspeed: vic: Add support for legacy register interface
28
is run from the build tree
31
* aspeed: add aspeed-xdma device
29
* ui/cocoa: Fix openFile: deprecation on Big Sur
32
* Add new sbsa-ref board for aarch64
30
* docs: Add qemu-storage-daemon(1) manpage to meson.build
33
* target/arm: code refactoring in preparation for support of
31
* docs: Build and install all the docs in a single manual
34
compilation with TCG disabled
35
32
36
----------------------------------------------------------------
33
----------------------------------------------------------------
37
Adriana Kobylak (1):
34
Hao Wu (6):
38
aspeed: Add support for the swift-bmc board
35
hw/misc: Add clock converter in NPCM7XX CLK module
36
hw/timer: Refactor NPCM7XX Timer to use CLK clock
37
hw/adc: Add an ADC module for NPCM7XX
38
hw/misc: Add a PWM module for NPCM7XX
39
hw/misc: Add QTest for NPCM7XX PWM Module
40
hw/*: Use type casting for SysBusDevice in NPCM7XX
39
41
40
Andrew Jeffery (3):
42
Leif Lindholm (6):
41
aspeed/timer: Status register contains reload for stopped timer
43
target/arm: fix typo in cpu.h ID_AA64PFR1 field name
42
aspeed/timer: Fix match calculations
44
target/arm: make ARMCPU.clidr 64-bit
43
aspeed: vic: Add support for legacy register interface
45
target/arm: make ARMCPU.ctr 64-bit
46
target/arm: add descriptions of CLIDR_EL1, CCSIDR_EL1, CTR_EL0 to cpu.h
47
target/arm: add aarch64 ID register fields to cpu.h
48
target/arm: add aarch32 ID register fields to cpu.h
44
49
45
Andrew Jones (1):
50
Peter Maydell (5):
46
hw/arm/boot: fix direct kernel boot with initrd
51
docs: Add qemu-storage-daemon(1) manpage to meson.build
52
docs: Build and install all the docs in a single manual
53
target/arm: Don't decode insns in the XScale/iWMMXt space as cp insns
54
hw/net/lan9118: Fix RX Status FIFO PEEK value
55
hw/net/lan9118: Add symbolic constants for register offsets
47
56
48
Andrey Smirnov (5):
57
Roman Bolshakov (2):
49
i.mx7d: Add no-op/unimplemented APBH DMA module
58
ui/cocoa: Update path to docs in build tree
50
i.mx7d: Add no-op/unimplemented PCIE PHY IP block
59
ui/cocoa: Fix openFile: deprecation on Big Sur
51
pci: designware: Update MSI mapping unconditionally
52
pci: designware: Update MSI mapping when MSI address changes
53
i.mx7d: pci: Update PCI IRQ mapping to match HW
54
60
55
Christian Svensson (1):
61
Rémi Denis-Courmont (2):
56
aspeed/timer: Ensure positive muldiv delta
62
target/arm: ARMv8.4-TTST extension
63
target/arm: enable Small Translation tables in max CPU
57
64
58
Cédric Le Goater (7):
65
docs/conf.py | 46 ++-
59
aspeed: add a per SoC mapping for the interrupt space
66
docs/devel/conf.py | 15 -
60
aspeed: add a per SoC mapping for the memory space
67
docs/index.html.in | 17 -
61
aspeed: introduce a configurable number of CPU per machine
68
docs/interop/conf.py | 28 --
62
aspeed: add support for multiple NICs
69
docs/meson.build | 65 ++--
63
aspeed: remove the "ram" link
70
docs/specs/conf.py | 16 -
64
aspeed: add a RAM memory region container
71
docs/system/arm/nuvoton.rst | 4 +-
65
aspeed/smc: add a 'sdram_base' property
72
docs/system/conf.py | 28 --
73
docs/tools/conf.py | 37 --
74
docs/user/conf.py | 15 -
75
meson.build | 1 +
76
hw/adc/trace.h | 1 +
77
include/hw/adc/npcm7xx_adc.h | 69 ++++
78
include/hw/arm/npcm7xx.h | 4 +
79
include/hw/misc/npcm7xx_clk.h | 146 ++++++-
80
include/hw/misc/npcm7xx_pwm.h | 105 +++++
81
include/hw/timer/npcm7xx_timer.h | 1 +
82
target/arm/cpu.h | 85 ++++-
83
hw/adc/npcm7xx_adc.c | 301 +++++++++++++++
84
hw/arm/npcm7xx.c | 55 ++-
85
hw/arm/npcm7xx_boards.c | 2 +-
86
hw/mem/npcm7xx_mc.c | 2 +-
87
hw/misc/npcm7xx_clk.c | 807 ++++++++++++++++++++++++++++++++++++++-
88
hw/misc/npcm7xx_gcr.c | 2 +-
89
hw/misc/npcm7xx_pwm.c | 550 ++++++++++++++++++++++++++
90
hw/misc/npcm7xx_rng.c | 2 +-
91
hw/net/lan9118.c | 26 +-
92
hw/nvram/npcm7xx_otp.c | 2 +-
93
hw/ssi/npcm7xx_fiu.c | 2 +-
94
hw/timer/npcm7xx_timer.c | 39 +-
95
target/arm/cpu64.c | 1 +
96
target/arm/helper.c | 15 +-
97
target/arm/translate.c | 7 +
98
tests/qtest/npcm7xx_adc-test.c | 377 ++++++++++++++++++
99
tests/qtest/npcm7xx_pwm-test.c | 490 ++++++++++++++++++++++++
100
hw/adc/meson.build | 1 +
101
hw/adc/trace-events | 5 +
102
hw/misc/meson.build | 1 +
103
hw/misc/trace-events | 6 +
104
tests/qtest/meson.build | 4 +-
105
ui/cocoa.m | 7 +-
106
41 files changed, 3124 insertions(+), 263 deletions(-)
107
delete mode 100644 docs/devel/conf.py
108
delete mode 100644 docs/index.html.in
109
delete mode 100644 docs/interop/conf.py
110
delete mode 100644 docs/specs/conf.py
111
delete mode 100644 docs/system/conf.py
112
delete mode 100644 docs/tools/conf.py
113
delete mode 100644 docs/user/conf.py
114
create mode 100644 hw/adc/trace.h
115
create mode 100644 include/hw/adc/npcm7xx_adc.h
116
create mode 100644 include/hw/misc/npcm7xx_pwm.h
117
create mode 100644 hw/adc/npcm7xx_adc.c
118
create mode 100644 hw/misc/npcm7xx_pwm.c
119
create mode 100644 tests/qtest/npcm7xx_adc-test.c
120
create mode 100644 tests/qtest/npcm7xx_pwm-test.c
121
create mode 100644 hw/adc/trace-events
66
122
67
Eddie James (1):
68
hw/misc/aspeed_xdma: New device
69
70
Hongbo Zhang (2):
71
hw/arm: Add arm SBSA reference machine, skeleton part
72
hw/arm: Add arm SBSA reference machine, devices part
73
74
Jan Kiszka (1):
75
hw/arm/virt: Add support for Cortex-A7
76
77
Joel Stanley (4):
78
hw: timer: Add ASPEED RTC device
79
hw/arm/aspeed: Add RTC to SoC
80
aspeed/timer: Fix behaviour running Linux
81
aspeed: Link SCU to the watchdog
82
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
Deleted patch
1
From: Andrew Jones <drjones@redhat.com>
2
1
3
Fix the condition used to check whether the initrd fits
4
into RAM; in some cases if an initrd was also passed on
5
the command line we would get an error stating that it
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
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>
16
---
17
hw/arm/boot.c | 3 ++-
18
1 file changed, 2 insertions(+), 1 deletion(-)
19
20
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
21
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/arm/boot.c
23
+++ b/hw/arm/boot.c
24
@@ -XXX,XX +XXX,XX @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu,
25
info->initrd_filename);
26
exit(1);
27
}
28
- if (info->initrd_start + initrd_size > info->ram_size) {
29
+ if (info->initrd_start + initrd_size > ram_end) {
30
error_report("could not load initrd '%s': "
31
"too big to fit into RAM after the kernel",
32
info->initrd_filename);
33
+ exit(1);
34
}
35
} else {
36
initrd_size = 0;
37
--
38
2.20.1
39
40
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
2
2
3
These routines are TCG specific.
3
This adds for the Small Translation tables extension in AArch64 state.
4
The arm_deliver_fault() function is only used within the new
5
helper. Make it static.
6
4
7
Suggested-by: Alex Bennée <alex.bennee@linaro.org>
5
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20190701132516.26392-13-philmd@redhat.com
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
8
---
13
target/arm/Makefile.objs | 1 +
9
target/arm/cpu.h | 5 +++++
14
target/arm/internals.h | 3 -
10
target/arm/helper.c | 15 +++++++++++++--
15
target/arm/cpu.c | 6 +-
11
2 files changed, 18 insertions(+), 2 deletions(-)
16
target/arm/helper.c | 53 -----------
17
target/arm/op_helper.c | 135 --------------------------
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
12
22
diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs
13
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
23
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
24
--- a/target/arm/Makefile.objs
15
--- a/target/arm/cpu.h
25
+++ b/target/arm/Makefile.objs
16
+++ b/target/arm/cpu.h
26
@@ -XXX,XX +XXX,XX @@ target/arm/translate-sve.o: target/arm/decode-sve.inc.c
17
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_uao(const ARMISARegisters *id)
27
target/arm/translate.o: target/arm/decode-vfp.inc.c
18
return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, UAO) != 0;
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
}
19
}
71
20
21
+static inline bool isar_feature_aa64_st(const ARMISARegisters *id)
22
+{
23
+ return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, ST) != 0;
24
+}
25
+
26
static inline bool isar_feature_aa64_bti(const ARMISARegisters *id)
27
{
28
return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, BT) != 0;
72
diff --git a/target/arm/helper.c b/target/arm/helper.c
29
diff --git a/target/arm/helper.c b/target/arm/helper.c
73
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
74
--- a/target/arm/helper.c
31
--- a/target/arm/helper.c
75
+++ b/target/arm/helper.c
32
+++ b/target/arm/helper.c
76
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
33
@@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va,
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
{
34
{
281
/*
35
uint64_t tcr = regime_tcr(env, mmu_idx)->raw_tcr;
282
diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c
36
bool epd, hpd, using16k, using64k;
283
new file mode 100644
37
- int select, tsz, tbi;
284
index XXXXXXX..XXXXXXX
38
+ int select, tsz, tbi, max_tsz;
285
--- /dev/null
39
286
+++ b/target/arm/tlb_helper.c
40
if (!regime_has_2_ranges(mmu_idx)) {
287
@@ -XXX,XX +XXX,XX @@
41
select = 0;
288
+/*
42
@@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va,
289
+ * ARM TLB (Translation lookaside buffer) helpers.
43
hpd = extract64(tcr, 42, 1);
290
+ *
44
}
291
+ * This code is licensed under the GNU GPL v2 or later.
45
}
292
+ *
46
- tsz = MIN(tsz, 39); /* TODO: ARMv8.4-TTST */
293
+ * SPDX-License-Identifier: GPL-2.0-or-later
294
+ */
295
+#include "qemu/osdep.h"
296
+#include "cpu.h"
297
+#include "internals.h"
298
+#include "exec/exec-all.h"
299
+
47
+
300
+#if !defined(CONFIG_USER_ONLY)
48
+ if (cpu_isar_feature(aa64_st, env_archcpu(env))) {
301
+
49
+ max_tsz = 48 - using64k;
302
+static inline uint32_t merge_syn_data_abort(uint32_t template_syn,
303
+ unsigned int target_el,
304
+ bool same_el, bool ea,
305
+ bool s1ptw, bool is_write,
306
+ int fsc)
307
+{
308
+ uint32_t syn;
309
+
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 {
50
+ } else {
326
+ /*
51
+ max_tsz = 39;
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
+ }
338
+ return syn;
339
+}
340
+
341
+static void QEMU_NORETURN arm_deliver_fault(ARMCPU *cpu, vaddr addr,
342
+ MMUAccessType access_type,
343
+ int mmu_idx, ARMMMUFaultInfo *fi)
344
+{
345
+ CPUARMState *env = &cpu->env;
346
+ int target_el;
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
+ }
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
+ }
52
+ }
376
+
53
+
377
+ if (access_type == MMU_INST_FETCH) {
54
+ tsz = MIN(tsz, max_tsz);
378
+ syn = syn_insn_abort(same_el, fi->ea, fi->s1ptw, fsc);
55
tsz = MAX(tsz, 16); /* TODO: ARMv8.2-LVA */
379
+ exc = EXCP_PREFETCH_ABORT;
56
380
+ } else {
57
/* Present TBI as a composite with TBID. */
381
+ syn = merge_syn_data_abort(env->exception.syndrome, target_el,
58
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address,
382
+ same_el, fi->ea, fi->s1ptw,
59
if (!aarch64 || stride == 9) {
383
+ access_type == MMU_DATA_STORE,
60
/* AArch32 or 4KB pages */
384
+ fsc);
61
startlevel = 2 - sl0;
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
+
62
+
392
+ env->exception.vaddress = addr;
63
+ if (cpu_isar_feature(aa64_st, cpu)) {
393
+ env->exception.fsr = fsr;
64
+ startlevel &= 3;
394
+ raise_exception(env, exc, syn, target_el);
65
+ }
395
+}
66
} else {
396
+
67
/* 16KB or 64KB pages */
397
+/* Raise a data fault alignment exception for the specified virtual address */
68
startlevel = 3 - sl0;
398
+void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,
399
+ MMUAccessType access_type,
400
+ int mmu_idx, uintptr_t retaddr)
401
+{
402
+ ARMCPU *cpu = ARM_CPU(cs);
403
+ ARMMMUFaultInfo fi = {};
404
+
405
+ /* now we have a real cpu fault */
406
+ cpu_restore_state(cs, retaddr, true);
407
+
408
+ fi.type = ARMFault_Alignment;
409
+ arm_deliver_fault(cpu, vaddr, access_type, mmu_idx, &fi);
410
+}
411
+
412
+/*
413
+ * arm_cpu_do_transaction_failed: handle a memory system error response
414
+ * (eg "no device/memory present at address") by raising an external abort
415
+ * exception
416
+ */
417
+void arm_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
418
+ vaddr addr, unsigned size,
419
+ MMUAccessType access_type,
420
+ int mmu_idx, MemTxAttrs attrs,
421
+ MemTxResult response, uintptr_t retaddr)
422
+{
423
+ ARMCPU *cpu = ARM_CPU(cs);
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
+}
433
+
434
+#endif /* !defined(CONFIG_USER_ONLY) */
435
+
436
+bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
437
+ MMUAccessType access_type, int mmu_idx,
438
+ bool probe, uintptr_t retaddr)
439
+{
440
+ ARMCPU *cpu = ARM_CPU(cs);
441
+
442
+#ifdef CONFIG_USER_ONLY
443
+ cpu->env.exception.vaddress = address;
444
+ if (access_type == MMU_INST_FETCH) {
445
+ cs->exception_index = EXCP_PREFETCH_ABORT;
446
+ } else {
447
+ cs->exception_index = EXCP_DATA_ABORT;
448
+ }
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
--
69
--
489
2.20.1
70
2.20.1
490
71
491
72
diff view generated by jsdifflib
1
From: Jan Kiszka <jan.kiszka@siemens.com>
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
2
2
3
Allow cortex-a7 to be used with the virt board; it supports
3
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
4
the v7VE features and there is no reason to deny this type.
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
6
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@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>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
6
---
12
hw/arm/virt.c | 1 +
7
target/arm/cpu64.c | 1 +
13
1 file changed, 1 insertion(+)
8
1 file changed, 1 insertion(+)
14
9
15
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
10
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
16
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/virt.c
12
--- a/target/arm/cpu64.c
18
+++ b/hw/arm/virt.c
13
+++ b/target/arm/cpu64.c
19
@@ -XXX,XX +XXX,XX @@ static const int a15irqmap[] = {
14
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
20
};
15
t = cpu->isar.id_aa64mmfr2;
21
16
t = FIELD_DP64(t, ID_AA64MMFR2, UAO, 1);
22
static const char *valid_cpus[] = {
17
t = FIELD_DP64(t, ID_AA64MMFR2, CNP, 1); /* TTCNP */
23
+ ARM_CPU_TYPE_NAME("cortex-a7"),
18
+ t = FIELD_DP64(t, ID_AA64MMFR2, ST, 1); /* TTST */
24
ARM_CPU_TYPE_NAME("cortex-a15"),
19
cpu->isar.id_aa64mmfr2 = t;
25
ARM_CPU_TYPE_NAME("cortex-a53"),
20
26
ARM_CPU_TYPE_NAME("cortex-a57"),
21
/* Replicate the same data to the 32-bit id registers. */
27
--
22
--
28
2.20.1
23
2.20.1
29
24
30
25
diff view generated by jsdifflib
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
1
From: Leif Lindholm <leif@nuviainc.com>
2
2
3
Datasheet for i.MX7 is incorrect and i.MX7's PCI IRQ mapping matches
3
SBSS -> SSBS
4
that of i.MX6:
5
4
6
* INTD/MSI 122
5
Signed-off-by: Leif Lindholm <leif@nuviainc.com>
7
* INTC 123
6
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
* INTB 124
9
* INTA 125
10
11
Fix all of the relevant code to reflect that fact. Needed by latest
12
Linux kernels.
13
14
(Reference: Linux kernel commit 538d6e9d597584e80 from an
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>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
24
[PMM: added ref to kernel commit confirming the datasheet error]
8
Reviewed-by: Laurent Desnogues <laurent.desnogues@gmail.com>
9
Message-id: 20210108185154.8108-2-leif@nuviainc.com
25
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
26
---
11
---
27
include/hw/arm/fsl-imx7.h | 8 ++++----
12
target/arm/cpu.h | 2 +-
28
hw/pci-host/designware.c | 6 ++++--
13
1 file changed, 1 insertion(+), 1 deletion(-)
29
2 files changed, 8 insertions(+), 6 deletions(-)
30
14
31
diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h
15
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
32
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
33
--- a/include/hw/arm/fsl-imx7.h
17
--- a/target/arm/cpu.h
34
+++ b/include/hw/arm/fsl-imx7.h
18
+++ b/target/arm/cpu.h
35
@@ -XXX,XX +XXX,XX @@ enum FslIMX7IRQs {
19
@@ -XXX,XX +XXX,XX @@ FIELD(ID_AA64PFR0, RAS, 28, 4)
36
FSL_IMX7_USB2_IRQ = 42,
20
FIELD(ID_AA64PFR0, SVE, 32, 4)
37
FSL_IMX7_USB3_IRQ = 40,
21
38
22
FIELD(ID_AA64PFR1, BT, 0, 4)
39
- FSL_IMX7_PCI_INTA_IRQ = 122,
23
-FIELD(ID_AA64PFR1, SBSS, 4, 4)
40
- FSL_IMX7_PCI_INTB_IRQ = 123,
24
+FIELD(ID_AA64PFR1, SSBS, 4, 4)
41
- FSL_IMX7_PCI_INTC_IRQ = 124,
25
FIELD(ID_AA64PFR1, MTE, 8, 4)
42
- FSL_IMX7_PCI_INTD_IRQ = 125,
26
FIELD(ID_AA64PFR1, RAS_FRAC, 12, 4)
43
+ FSL_IMX7_PCI_INTA_IRQ = 125,
44
+ FSL_IMX7_PCI_INTB_IRQ = 124,
45
+ FSL_IMX7_PCI_INTC_IRQ = 123,
46
+ FSL_IMX7_PCI_INTD_IRQ = 122,
47
48
FSL_IMX7_UART7_IRQ = 126,
49
50
diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c
51
index XXXXXXX..XXXXXXX 100644
52
--- a/hw/pci-host/designware.c
53
+++ b/hw/pci-host/designware.c
54
@@ -XXX,XX +XXX,XX @@
55
#define DESIGNWARE_PCIE_ATU_DEVFN(x) (((x) >> 16) & 0xff)
56
#define DESIGNWARE_PCIE_ATU_UPPER_TARGET 0x91C
57
58
+#define DESIGNWARE_PCIE_IRQ_MSI 3
59
+
60
static DesignwarePCIEHost *
61
designware_pcie_root_to_host(DesignwarePCIERoot *root)
62
{
63
@@ -XXX,XX +XXX,XX @@ static void designware_pcie_root_msi_write(void *opaque, hwaddr addr,
64
root->msi.intr[0].status |= BIT(val) & root->msi.intr[0].enable;
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
}
70
}
71
72
@@ -XXX,XX +XXX,XX @@ static void designware_pcie_root_config_write(PCIDevice *d, uint32_t address,
73
case DESIGNWARE_PCIE_MSI_INTR0_STATUS:
74
root->msi.intr[0].status ^= val;
75
if (!root->msi.intr[0].status) {
76
- qemu_set_irq(host->pci.irqs[0], 0);
77
+ qemu_set_irq(host->pci.irqs[DESIGNWARE_PCIE_IRQ_MSI], 0);
78
}
79
break;
80
27
81
--
28
--
82
2.20.1
29
2.20.1
83
30
84
31
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Leif Lindholm <leif@nuviainc.com>
2
2
3
In few commits we will split the M-profile functions from this
3
The AArch64 view of CLIDR_EL1 extends the ICB field to include also bit
4
file, and this function will also be called in the new file.
4
32, as well as adding a Ttype<n> field when FEAT_MTE is implemented.
5
Declare it in the "internals.h" header.
5
Extend the clidr field to be able to hold this context.
6
Since it is in the middle of a block of M profile functions,
7
move it previous to this block to ease the later refactor.
8
6
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Signed-off-by: Leif Lindholm <leif@nuviainc.com>
10
Message-id: 20190701132516.26392-21-philmd@redhat.com
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Laurent Desnogues <laurent.desnogues@gmail.com>
11
Message-id: 20210108185154.8108-3-leif@nuviainc.com
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
13
---
14
target/arm/internals.h | 2 ++
14
target/arm/cpu.h | 2 +-
15
target/arm/helper.c | 76 +++++++++++++++++++++---------------------
15
1 file changed, 1 insertion(+), 1 deletion(-)
16
2 files changed, 40 insertions(+), 38 deletions(-)
17
16
18
diff --git a/target/arm/internals.h b/target/arm/internals.h
17
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
19
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/internals.h
19
--- a/target/arm/cpu.h
21
+++ b/target/arm/internals.h
20
+++ b/target/arm/cpu.h
22
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
21
@@ -XXX,XX +XXX,XX @@ struct ARMCPU {
23
target_ulong *page_size,
22
uint32_t id_afr0;
24
ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs);
23
uint64_t id_aa64afr0;
25
24
uint64_t id_aa64afr1;
26
+void arm_log_exception(int idx);
25
- uint32_t clidr;
27
+
26
+ uint64_t clidr;
28
#endif /* !CONFIG_USER_ONLY */
27
uint64_t mp_affinity; /* MP ID without feature bits */
29
28
/* The elements of this array are the CCSIDR values for each cache,
30
#endif
29
* in the order L1DCache, L1ICache, L2DCache, L2ICache, etc.
31
diff --git a/target/arm/helper.c b/target/arm/helper.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/target/arm/helper.c
34
+++ b/target/arm/helper.c
35
@@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx,
36
return target_el;
37
}
38
39
+void arm_log_exception(int idx)
40
+{
41
+ if (qemu_loglevel_mask(CPU_LOG_INT)) {
42
+ const char *exc = NULL;
43
+ static const char * const excnames[] = {
44
+ [EXCP_UDEF] = "Undefined Instruction",
45
+ [EXCP_SWI] = "SVC",
46
+ [EXCP_PREFETCH_ABORT] = "Prefetch Abort",
47
+ [EXCP_DATA_ABORT] = "Data Abort",
48
+ [EXCP_IRQ] = "IRQ",
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
+
67
+ if (idx >= 0 && idx < ARRAY_SIZE(excnames)) {
68
+ exc = excnames[idx];
69
+ }
70
+ if (!exc) {
71
+ exc = "unknown";
72
+ }
73
+ qemu_log_mask(CPU_LOG_INT, "Taking exception %d [%s]\n", idx, exc);
74
+ }
75
+}
76
+
77
/*
78
* Return true if the v7M CPACR permits access to the FPU for the specified
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
{
125
--
30
--
126
2.20.1
31
2.20.1
127
32
128
33
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Leif Lindholm <leif@nuviainc.com>
2
2
3
Under KVM, the kernel gets the HVC call and handle the PSCI requests.
3
When FEAT_MTE is implemented, the AArch64 view of CTR_EL0 adds the
4
TminLine field in bits [37:32].
5
Extend the ctr field to be able to hold this context.
4
6
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Signed-off-by: Leif Lindholm <leif@nuviainc.com>
6
Message-id: 20190701132516.26392-20-philmd@redhat.com
8
Reviewed-by: Hao Wu <wuhaotsh@google.com>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Laurent Desnogues <laurent.desnogues@gmail.com>
11
Message-id: 20210108185154.8108-4-leif@nuviainc.com
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
13
---
10
target/arm/internals.h | 6 +++++-
14
target/arm/cpu.h | 2 +-
11
1 file changed, 5 insertions(+), 1 deletion(-)
15
1 file changed, 1 insertion(+), 1 deletion(-)
12
16
13
diff --git a/target/arm/internals.h b/target/arm/internals.h
17
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
14
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/internals.h
19
--- a/target/arm/cpu.h
16
+++ b/target/arm/internals.h
20
+++ b/target/arm/cpu.h
17
@@ -XXX,XX +XXX,XX @@ vaddr arm_adjust_watchpoint_address(CPUState *cs, vaddr addr, int len);
21
@@ -XXX,XX +XXX,XX @@ struct ARMCPU {
18
/* Callback function for when a watchpoint or breakpoint triggers. */
22
uint64_t midr;
19
void arm_debug_excp_handler(CPUState *cs);
23
uint32_t revidr;
20
24
uint32_t reset_fpsid;
21
-#ifdef CONFIG_USER_ONLY
25
- uint32_t ctr;
22
+#if defined(CONFIG_USER_ONLY) || !defined(CONFIG_TCG)
26
+ uint64_t ctr;
23
static inline bool arm_is_psci_call(ARMCPU *cpu, int excp_type)
27
uint32_t reset_sctlr;
24
{
28
uint64_t pmceid0;
25
return false;
29
uint64_t pmceid1;
26
}
27
+static inline void arm_handle_psci_call(ARMCPU *cpu)
28
+{
29
+ g_assert_not_reached();
30
+}
31
#else
32
/* Return true if the r0/x0 value indicates that this SMC/HVC is a PSCI call. */
33
bool arm_is_psci_call(ARMCPU *cpu, int excp_type);
34
--
30
--
35
2.20.1
31
2.20.1
36
32
37
33
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Leif Lindholm <leif@nuviainc.com>
2
2
3
This code is specific to the SoftFloat floating-point
3
Signed-off-by: Leif Lindholm <leif@nuviainc.com>
4
implementation, which is only used by TCG.
4
Reviewed-by: Laurent Desnogues <laurent.desnogues@gmail.com>
5
5
Message-id: 20210108185154.8108-5-leif@nuviainc.com
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
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>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
7
---
11
target/arm/vfp_helper.c | 26 +++++++++++++++++++++++---
8
target/arm/cpu.h | 31 +++++++++++++++++++++++++++++++
12
1 file changed, 23 insertions(+), 3 deletions(-)
9
1 file changed, 31 insertions(+)
13
10
14
diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c
11
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
15
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/vfp_helper.c
13
--- a/target/arm/cpu.h
17
+++ b/target/arm/vfp_helper.c
14
+++ b/target/arm/cpu.h
18
@@ -XXX,XX +XXX,XX @@
15
@@ -XXX,XX +XXX,XX @@ FIELD(V7M_FPCCR, ASPEN, 31, 1)
16
/*
17
* System register ID fields.
19
*/
18
*/
20
19
+FIELD(CLIDR_EL1, CTYPE1, 0, 3)
21
#include "qemu/osdep.h"
20
+FIELD(CLIDR_EL1, CTYPE2, 3, 3)
22
-#include "qemu/log.h"
21
+FIELD(CLIDR_EL1, CTYPE3, 6, 3)
23
#include "cpu.h"
22
+FIELD(CLIDR_EL1, CTYPE4, 9, 3)
24
#include "exec/helper-proto.h"
23
+FIELD(CLIDR_EL1, CTYPE5, 12, 3)
25
-#include "fpu/softfloat.h"
24
+FIELD(CLIDR_EL1, CTYPE6, 15, 3)
26
#include "internals.h"
25
+FIELD(CLIDR_EL1, CTYPE7, 18, 3)
27
-
26
+FIELD(CLIDR_EL1, LOUIS, 21, 3)
28
+#ifdef CONFIG_TCG
27
+FIELD(CLIDR_EL1, LOC, 24, 3)
29
+#include "qemu/log.h"
28
+FIELD(CLIDR_EL1, LOUU, 27, 3)
30
+#include "fpu/softfloat.h"
29
+FIELD(CLIDR_EL1, ICB, 30, 3)
31
+#endif
32
33
/* VFP support. We follow the convention used for VFP instructions:
34
Single precision routines have a "s" suffix, double precision a
35
"d" suffix. */
36
37
+#ifdef CONFIG_TCG
38
+
30
+
39
/* Convert host exception flags to vfp form. */
31
+/* When FEAT_CCIDX is implemented */
40
static inline int vfp_exceptbits_from_host(int host_bits)
32
+FIELD(CCSIDR_EL1, CCIDX_LINESIZE, 0, 3)
41
{
33
+FIELD(CCSIDR_EL1, CCIDX_ASSOCIATIVITY, 3, 21)
42
@@ -XXX,XX +XXX,XX @@ static void vfp_set_fpscr_to_host(CPUARMState *env, uint32_t val)
34
+FIELD(CCSIDR_EL1, CCIDX_NUMSETS, 32, 24)
43
set_float_exception_flags(0, &env->vfp.standard_fp_status);
44
}
45
46
+#else
47
+
35
+
48
+static uint32_t vfp_get_fpscr_from_host(CPUARMState *env)
36
+/* When FEAT_CCIDX is not implemented */
49
+{
37
+FIELD(CCSIDR_EL1, LINESIZE, 0, 3)
50
+ return 0;
38
+FIELD(CCSIDR_EL1, ASSOCIATIVITY, 3, 10)
51
+}
39
+FIELD(CCSIDR_EL1, NUMSETS, 13, 15)
52
+
40
+
53
+static void vfp_set_fpscr_to_host(CPUARMState *env, uint32_t val)
41
+FIELD(CTR_EL0, IMINLINE, 0, 4)
54
+{
42
+FIELD(CTR_EL0, L1IP, 14, 2)
55
+}
43
+FIELD(CTR_EL0, DMINLINE, 16, 4)
44
+FIELD(CTR_EL0, ERG, 20, 4)
45
+FIELD(CTR_EL0, CWG, 24, 4)
46
+FIELD(CTR_EL0, IDC, 28, 1)
47
+FIELD(CTR_EL0, DIC, 29, 1)
48
+FIELD(CTR_EL0, TMINLINE, 32, 6)
56
+
49
+
57
+#endif
50
FIELD(MIDR_EL1, REVISION, 0, 4)
58
+
51
FIELD(MIDR_EL1, PARTNUM, 4, 12)
59
uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env)
52
FIELD(MIDR_EL1, ARCHITECTURE, 16, 4)
60
{
61
uint32_t i, fpscr;
62
@@ -XXX,XX +XXX,XX @@ void vfp_set_fpscr(CPUARMState *env, uint32_t val)
63
HELPER(vfp_set_fpscr)(env, val);
64
}
65
66
+#ifdef CONFIG_TCG
67
+
68
#define VFP_HELPER(name, p) HELPER(glue(glue(vfp_,name),p))
69
70
#define VFP_BINOP(name) \
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
--
53
--
78
2.20.1
54
2.20.1
79
55
80
56
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Leif Lindholm <leif@nuviainc.com>
2
2
3
The vfp_set_fpscr() helper contains code specific to the host
3
Add entries present in ARM DDI 0487F.c (August 2020).
4
floating point implementation (here the SoftFloat library).
5
Extract this code to vfp_set_fpscr_from_host().
6
4
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Signed-off-by: Leif Lindholm <leif@nuviainc.com>
8
Message-id: 20190701132516.26392-17-philmd@redhat.com
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Laurent Desnogues <laurent.desnogues@gmail.com>
8
Message-id: 20210108185154.8108-6-leif@nuviainc.com
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/vfp_helper.c | 19 +++++++++++++------
11
target/arm/cpu.h | 15 +++++++++++++++
13
1 file changed, 13 insertions(+), 6 deletions(-)
12
1 file changed, 15 insertions(+)
14
13
15
diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c
14
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
16
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/vfp_helper.c
16
--- a/target/arm/cpu.h
18
+++ b/target/arm/vfp_helper.c
17
+++ b/target/arm/cpu.h
19
@@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_to_host(int target_bits)
18
@@ -XXX,XX +XXX,XX @@ FIELD(ID_AA64ISAR1, GPI, 28, 4)
20
return host_bits;
19
FIELD(ID_AA64ISAR1, FRINTTS, 32, 4)
21
}
20
FIELD(ID_AA64ISAR1, SB, 36, 4)
22
21
FIELD(ID_AA64ISAR1, SPECRES, 40, 4)
23
+static uint32_t vfp_get_fpscr_from_host(CPUARMState *env)
22
+FIELD(ID_AA64ISAR1, BF16, 44, 4)
24
+{
23
+FIELD(ID_AA64ISAR1, DGH, 48, 4)
25
+ uint32_t i;
24
+FIELD(ID_AA64ISAR1, I8MM, 52, 4)
26
+
25
27
+ i = get_float_exception_flags(&env->vfp.fp_status);
26
FIELD(ID_AA64PFR0, EL0, 0, 4)
28
+ i |= get_float_exception_flags(&env->vfp.standard_fp_status);
27
FIELD(ID_AA64PFR0, EL1, 4, 4)
29
+ /* FZ16 does not generate an input denormal exception. */
28
@@ -XXX,XX +XXX,XX @@ FIELD(ID_AA64PFR0, ADVSIMD, 20, 4)
30
+ i |= (get_float_exception_flags(&env->vfp.fp_status_f16)
29
FIELD(ID_AA64PFR0, GIC, 24, 4)
31
+ & ~float_flag_input_denormal);
30
FIELD(ID_AA64PFR0, RAS, 28, 4)
32
+ return vfp_exceptbits_from_host(i);
31
FIELD(ID_AA64PFR0, SVE, 32, 4)
33
+}
32
+FIELD(ID_AA64PFR0, SEL2, 36, 4)
34
+
33
+FIELD(ID_AA64PFR0, MPAM, 40, 4)
35
static void vfp_set_fpscr_to_host(CPUARMState *env, uint32_t val)
34
+FIELD(ID_AA64PFR0, AMU, 44, 4)
36
{
35
+FIELD(ID_AA64PFR0, DIT, 48, 4)
37
int i;
36
+FIELD(ID_AA64PFR0, CSV2, 56, 4)
38
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env)
37
+FIELD(ID_AA64PFR0, CSV3, 60, 4)
39
| (env->vfp.vec_len << 16)
38
40
| (env->vfp.vec_stride << 20);
39
FIELD(ID_AA64PFR1, BT, 0, 4)
41
40
FIELD(ID_AA64PFR1, SSBS, 4, 4)
42
- i = get_float_exception_flags(&env->vfp.fp_status);
41
FIELD(ID_AA64PFR1, MTE, 8, 4)
43
- i |= get_float_exception_flags(&env->vfp.standard_fp_status);
42
FIELD(ID_AA64PFR1, RAS_FRAC, 12, 4)
44
- /* FZ16 does not generate an input denormal exception. */
43
+FIELD(ID_AA64PFR1, MPAM_FRAC, 16, 4)
45
- i |= (get_float_exception_flags(&env->vfp.fp_status_f16)
44
46
- & ~float_flag_input_denormal);
45
FIELD(ID_AA64MMFR0, PARANGE, 0, 4)
47
- fpscr |= vfp_exceptbits_from_host(i);
46
FIELD(ID_AA64MMFR0, ASIDBITS, 4, 4)
48
+ fpscr |= vfp_get_fpscr_from_host(env);
47
@@ -XXX,XX +XXX,XX @@ FIELD(ID_AA64MMFR0, TGRAN16_2, 32, 4)
49
48
FIELD(ID_AA64MMFR0, TGRAN64_2, 36, 4)
50
i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3];
49
FIELD(ID_AA64MMFR0, TGRAN4_2, 40, 4)
51
fpscr |= i ? FPCR_QC : 0;
50
FIELD(ID_AA64MMFR0, EXS, 44, 4)
51
+FIELD(ID_AA64MMFR0, FGT, 56, 4)
52
+FIELD(ID_AA64MMFR0, ECV, 60, 4)
53
54
FIELD(ID_AA64MMFR1, HAFDBS, 0, 4)
55
FIELD(ID_AA64MMFR1, VMIDBITS, 4, 4)
56
@@ -XXX,XX +XXX,XX @@ FIELD(ID_AA64MMFR1, LO, 16, 4)
57
FIELD(ID_AA64MMFR1, PAN, 20, 4)
58
FIELD(ID_AA64MMFR1, SPECSEI, 24, 4)
59
FIELD(ID_AA64MMFR1, XNX, 28, 4)
60
+FIELD(ID_AA64MMFR1, TWED, 32, 4)
61
+FIELD(ID_AA64MMFR1, ETS, 36, 4)
62
63
FIELD(ID_AA64MMFR2, CNP, 0, 4)
64
FIELD(ID_AA64MMFR2, UAO, 4, 4)
65
@@ -XXX,XX +XXX,XX @@ FIELD(ID_AA64DFR0, CTX_CMPS, 28, 4)
66
FIELD(ID_AA64DFR0, PMSVER, 32, 4)
67
FIELD(ID_AA64DFR0, DOUBLELOCK, 36, 4)
68
FIELD(ID_AA64DFR0, TRACEFILT, 40, 4)
69
+FIELD(ID_AA64DFR0, MTPMU, 48, 4)
70
71
FIELD(ID_DFR0, COPDBG, 0, 4)
72
FIELD(ID_DFR0, COPSDBG, 4, 4)
52
--
73
--
53
2.20.1
74
2.20.1
54
75
55
76
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Leif Lindholm <leif@nuviainc.com>
2
2
3
Suggested-by: Samuel Ortiz <sameo@linux.intel.com>
3
Add entries present in ARM DDI 0487F.c (August 2020).
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
5
Message-id: 20190701132516.26392-11-philmd@redhat.com
5
Signed-off-by: Leif Lindholm <leif@nuviainc.com>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Laurent Desnogues <laurent.desnogues@gmail.com>
8
Message-id: 20210108185154.8108-7-leif@nuviainc.com
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
10
---
9
target/arm/cpu.h | 2 -
11
target/arm/cpu.h | 28 ++++++++++++++++++++++++++++
10
target/arm/translate.h | 5 -
12
1 file changed, 28 insertions(+)
11
target/arm/cpu.c | 226 +++++++++++++++++++++++++++++++++++++
12
target/arm/translate-a64.c | 128 ---------------------
13
target/arm/translate.c | 88 ---------------
14
5 files changed, 226 insertions(+), 223 deletions(-)
15
13
16
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
14
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
17
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/cpu.h
16
--- a/target/arm/cpu.h
19
+++ b/target/arm/cpu.h
17
+++ b/target/arm/cpu.h
20
@@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cpu);
18
@@ -XXX,XX +XXX,XX @@ FIELD(ID_ISAR6, DP, 4, 4)
21
void arm_v7m_cpu_do_interrupt(CPUState *cpu);
19
FIELD(ID_ISAR6, FHM, 8, 4)
22
bool arm_cpu_exec_interrupt(CPUState *cpu, int int_req);
20
FIELD(ID_ISAR6, SB, 12, 4)
23
21
FIELD(ID_ISAR6, SPECRES, 16, 4)
24
-void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags);
22
+FIELD(ID_ISAR6, BF16, 20, 4)
25
-
23
+FIELD(ID_ISAR6, I8MM, 24, 4)
26
hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,
24
27
MemTxAttrs *attrs);
25
FIELD(ID_MMFR0, VMSA, 0, 4)
28
26
FIELD(ID_MMFR0, PMSA, 4, 4)
29
diff --git a/target/arm/translate.h b/target/arm/translate.h
27
@@ -XXX,XX +XXX,XX @@ FIELD(ID_MMFR0, AUXREG, 20, 4)
30
index XXXXXXX..XXXXXXX 100644
28
FIELD(ID_MMFR0, FCSE, 24, 4)
31
--- a/target/arm/translate.h
29
FIELD(ID_MMFR0, INNERSHR, 28, 4)
32
+++ b/target/arm/translate.h
30
33
@@ -XXX,XX +XXX,XX @@ static inline void disas_set_insn_syndrome(DisasContext *s, uint32_t syn)
31
+FIELD(ID_MMFR1, L1HVDVA, 0, 4)
34
#ifdef TARGET_AARCH64
32
+FIELD(ID_MMFR1, L1UNIVA, 4, 4)
35
void a64_translate_init(void);
33
+FIELD(ID_MMFR1, L1HVDSW, 8, 4)
36
void gen_a64_set_pc_im(uint64_t val);
34
+FIELD(ID_MMFR1, L1UNISW, 12, 4)
37
-void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags);
35
+FIELD(ID_MMFR1, L1HVD, 16, 4)
38
extern const TranslatorOps aarch64_translator_ops;
36
+FIELD(ID_MMFR1, L1UNI, 20, 4)
39
#else
37
+FIELD(ID_MMFR1, L1TSTCLN, 24, 4)
40
static inline void a64_translate_init(void)
38
+FIELD(ID_MMFR1, BPRED, 28, 4)
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 @@
57
*/
58
59
#include "qemu/osdep.h"
60
+#include "qemu/qemu-print.h"
61
#include "qemu-common.h"
62
#include "target/arm/idau.h"
63
#include "qemu/module.h"
64
@@ -XXX,XX +XXX,XX @@ static void arm_disas_set_info(CPUState *cpu, disassemble_info *info)
65
#endif
66
}
67
68
+#ifdef TARGET_AARCH64
69
+
39
+
70
+static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags)
40
+FIELD(ID_MMFR2, L1HVDFG, 0, 4)
71
+{
41
+FIELD(ID_MMFR2, L1HVDBG, 4, 4)
72
+ ARMCPU *cpu = ARM_CPU(cs);
42
+FIELD(ID_MMFR2, L1HVDRNG, 8, 4)
73
+ CPUARMState *env = &cpu->env;
43
+FIELD(ID_MMFR2, HVDTLB, 12, 4)
74
+ uint32_t psr = pstate_read(env);
44
+FIELD(ID_MMFR2, UNITLB, 16, 4)
75
+ int i;
45
+FIELD(ID_MMFR2, MEMBARR, 20, 4)
76
+ int el = arm_current_el(env);
46
+FIELD(ID_MMFR2, WFISTALL, 24, 4)
77
+ const char *ns_status;
47
+FIELD(ID_MMFR2, HWACCFLG, 28, 4)
78
+
48
+
79
+ qemu_fprintf(f, " PC=%016" PRIx64 " ", env->pc);
49
FIELD(ID_MMFR3, CMAINTVA, 0, 4)
80
+ for (i = 0; i < 32; i++) {
50
FIELD(ID_MMFR3, CMAINTSW, 4, 4)
81
+ if (i == 31) {
51
FIELD(ID_MMFR3, BPMAINT, 8, 4)
82
+ qemu_fprintf(f, " SP=%016" PRIx64 "\n", env->xregs[i]);
52
@@ -XXX,XX +XXX,XX @@ FIELD(ID_MMFR4, LSM, 20, 4)
83
+ } else {
53
FIELD(ID_MMFR4, CCIDX, 24, 4)
84
+ qemu_fprintf(f, "X%02d=%016" PRIx64 "%s", i, env->xregs[i],
54
FIELD(ID_MMFR4, EVT, 28, 4)
85
+ (i + 2) % 3 ? " " : "\n");
55
86
+ }
56
+FIELD(ID_MMFR5, ETS, 0, 4)
87
+ }
88
+
57
+
89
+ if (arm_feature(env, ARM_FEATURE_EL3) && el != 3) {
58
FIELD(ID_PFR0, STATE0, 0, 4)
90
+ ns_status = env->cp15.scr_el3 & SCR_NS ? "NS " : "S ";
59
FIELD(ID_PFR0, STATE1, 4, 4)
91
+ } else {
60
FIELD(ID_PFR0, STATE2, 8, 4)
92
+ ns_status = "";
61
@@ -XXX,XX +XXX,XX @@ FIELD(ID_PFR1, SEC_FRAC, 20, 4)
93
+ }
62
FIELD(ID_PFR1, VIRT_FRAC, 24, 4)
94
+ qemu_fprintf(f, "PSTATE=%08x %c%c%c%c %sEL%d%c",
63
FIELD(ID_PFR1, GIC, 28, 4)
95
+ psr,
64
96
+ psr & PSTATE_N ? 'N' : '-',
65
+FIELD(ID_PFR2, CSV3, 0, 4)
97
+ psr & PSTATE_Z ? 'Z' : '-',
66
+FIELD(ID_PFR2, SSBS, 4, 4)
98
+ psr & PSTATE_C ? 'C' : '-',
67
+FIELD(ID_PFR2, RAS_FRAC, 8, 4)
99
+ psr & PSTATE_V ? 'V' : '-',
100
+ ns_status,
101
+ el,
102
+ psr & PSTATE_SP ? 'h' : 't');
103
+
68
+
104
+ if (cpu_isar_feature(aa64_bti, cpu)) {
69
FIELD(ID_AA64ISAR0, AES, 4, 4)
105
+ qemu_fprintf(f, " BTYPE=%d", (psr & PSTATE_BTYPE) >> 10);
70
FIELD(ID_AA64ISAR0, SHA1, 8, 4)
106
+ }
71
FIELD(ID_AA64ISAR0, SHA2, 12, 4)
107
+ if (!(flags & CPU_DUMP_FPU)) {
72
@@ -XXX,XX +XXX,XX @@ FIELD(ID_DFR0, MPROFDBG, 20, 4)
108
+ qemu_fprintf(f, "\n");
73
FIELD(ID_DFR0, PERFMON, 24, 4)
109
+ return;
74
FIELD(ID_DFR0, TRACEFILT, 28, 4)
110
+ }
75
111
+ if (fp_exception_el(env, el) != 0) {
76
+FIELD(ID_DFR1, MTPMU, 0, 4)
112
+ qemu_fprintf(f, " FPU disabled\n");
113
+ return;
114
+ }
115
+ qemu_fprintf(f, " FPCR=%08x FPSR=%08x\n",
116
+ vfp_get_fpcr(env), vfp_get_fpsr(env));
117
+
77
+
118
+ if (cpu_isar_feature(aa64_sve, cpu) && sve_exception_el(env, el) == 0) {
78
FIELD(DBGDIDR, SE_IMP, 12, 1)
119
+ int j, zcr_len = sve_zcr_len_for_el(env, el);
79
FIELD(DBGDIDR, NSUHD_IMP, 14, 1)
120
+
80
FIELD(DBGDIDR, VERSION, 16, 4)
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
+}
196
+
197
+#else
198
+
199
+static inline void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags)
200
+{
201
+ g_assert_not_reached();
202
+}
203
+
204
+#endif
205
+
206
+static void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags)
207
+{
208
+ ARMCPU *cpu = ARM_CPU(cs);
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
+}
292
+
293
uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz)
294
{
295
uint32_t Aff1 = idx / clustersz;
296
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
297
index XXXXXXX..XXXXXXX 100644
298
--- a/target/arm/translate-a64.c
299
+++ b/target/arm/translate-a64.c
300
@@ -XXX,XX +XXX,XX @@
301
#include "translate.h"
302
#include "internals.h"
303
#include "qemu/host-utils.h"
304
-#include "qemu/qemu-print.h"
305
306
#include "hw/semihosting/semihost.h"
307
#include "exec/gen-icount.h"
308
@@ -XXX,XX +XXX,XX @@ static void set_btype(DisasContext *s, int val)
309
s->btype = -1;
310
}
311
312
-void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags)
313
-{
314
- ARMCPU *cpu = ARM_CPU(cs);
315
- CPUARMState *env = &cpu->env;
316
- uint32_t psr = pstate_read(env);
317
- int i;
318
- int el = arm_current_el(env);
319
- const char *ns_status;
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;
352
- }
353
- if (fp_exception_el(env, el) != 0) {
354
- qemu_fprintf(f, " FPU disabled\n");
355
- return;
356
- }
357
- qemu_fprintf(f, " FPCR=%08x FPSR=%08x\n",
358
- vfp_get_fpcr(env), vfp_get_fpsr(env));
359
-
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
-}
438
-
439
void gen_a64_set_pc_im(uint64_t val)
440
{
441
tcg_gen_movi_i64(cpu_pc, val);
442
diff --git a/target/arm/translate.c b/target/arm/translate.c
443
index XXXXXXX..XXXXXXX 100644
444
--- a/target/arm/translate.c
445
+++ b/target/arm/translate.c
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
-{
460
- ARMCPU *cpu = ARM_CPU(cs);
461
- CPUARMState *env = &cpu->env;
462
- int i;
463
-
464
- if (is_a64(env)) {
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
-}
544
-
545
void restore_state_to_opc(CPUARMState *env, TranslationBlock *tb,
546
target_ulong *data)
547
{
548
--
81
--
549
2.20.1
82
2.20.1
550
83
551
84
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Roman Bolshakov <r.bolshakov@yadro.com>
2
2
3
The vfp_set_fpscr() helper contains code specific to the host
3
QEMU documentation can't be opened if QEMU is run from build tree
4
floating point implementation (here the SoftFloat library).
4
because executables are placed in the top of build tree after conversion
5
Extract this code to vfp_set_fpscr_to_host().
5
to meson.
6
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
8
Message-id: 20190701132516.26392-16-philmd@redhat.com
8
Reported-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20210108213815.64678-1-r.bolshakov@yadro.com
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
---
12
target/arm/vfp_helper.c | 127 +++++++++++++++++++++-------------------
13
ui/cocoa.m | 2 +-
13
1 file changed, 66 insertions(+), 61 deletions(-)
14
1 file changed, 1 insertion(+), 1 deletion(-)
14
15
15
diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c
16
diff --git a/ui/cocoa.m b/ui/cocoa.m
16
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/vfp_helper.c
18
--- a/ui/cocoa.m
18
+++ b/target/arm/vfp_helper.c
19
+++ b/ui/cocoa.m
19
@@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_to_host(int target_bits)
20
@@ -XXX,XX +XXX,XX @@ QemuCocoaView *cocoaView;
20
return host_bits;
21
- (void) openDocumentation: (NSString *) filename
21
}
22
23
-uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env)
24
-{
25
- uint32_t i, fpscr;
26
-
27
- fpscr = env->vfp.xregs[ARM_VFP_FPSCR]
28
- | (env->vfp.vec_len << 16)
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
{
22
{
52
int i;
23
/* Where to look for local files */
53
uint32_t changed = env->vfp.xregs[ARM_VFP_FPSCR];
24
- NSString *path_array[] = {@"../share/doc/qemu/", @"../doc/qemu/", @"../docs/"};
54
25
+ NSString *path_array[] = {@"../share/doc/qemu/", @"../doc/qemu/", @"docs/"};
55
- /* When ARMv8.2-FP16 is not supported, FZ16 is RES0. */
26
NSString *full_file_path;
56
- if (!cpu_isar_feature(aa64_fp16, env_archcpu(env))) {
27
57
- val &= ~FPCR_FZ16;
28
/* iterate thru the possible paths until the file is found */
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
+{
98
+ uint32_t i, fpscr;
99
+
100
+ fpscr = env->vfp.xregs[ARM_VFP_FPSCR]
101
+ | (env->vfp.vec_len << 16)
102
+ | (env->vfp.vec_stride << 20);
103
+
104
+ i = get_float_exception_flags(&env->vfp.fp_status);
105
+ i |= get_float_exception_flags(&env->vfp.standard_fp_status);
106
+ /* FZ16 does not generate an input denormal exception. */
107
+ i |= (get_float_exception_flags(&env->vfp.fp_status_f16)
108
+ & ~float_flag_input_denormal);
109
+ fpscr |= vfp_exceptbits_from_host(i);
110
+
111
+ i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3];
112
+ fpscr |= i ? FPCR_QC : 0;
113
+
114
+ return fpscr;
115
+}
116
+
117
+uint32_t vfp_get_fpscr(CPUARMState *env)
118
+{
119
+ return HELPER(vfp_get_fpscr)(env);
120
+}
121
+
122
+void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val)
123
+{
124
+ /* When ARMv8.2-FP16 is not supported, FZ16 is RES0. */
125
+ if (!cpu_isar_feature(aa64_fp16, env_archcpu(env))) {
126
+ val &= ~FPCR_FZ16;
127
+ }
128
+
129
+ if (arm_feature(env, ARM_FEATURE_M)) {
130
+ /*
131
+ * M profile FPSCR is RES0 for the QC, STRIDE, FZ16, LEN bits
132
+ * and also for the trapped-exception-handling bits IxE.
133
+ */
134
+ val &= 0xf7c0009f;
135
+ }
136
+
137
+ /*
138
+ * We don't implement trapped exception handling, so the
139
+ * trap enable bits, IDE|IXE|UFE|OFE|DZE|IOE are all RAZ/WI (not RES0!)
140
+ *
141
+ * If we exclude the exception flags, IOC|DZC|OFC|UFC|IXC|IDC
142
+ * (which are stored in fp_status), and the other RES0 bits
143
+ * in between, then we clear all of the low 16 bits.
144
+ */
145
+ env->vfp.xregs[ARM_VFP_FPSCR] = val & 0xf7c80000;
146
+ env->vfp.vec_len = (val >> 16) & 7;
147
+ env->vfp.vec_stride = (val >> 20) & 3;
148
+
149
+ /*
150
+ * The bit we set within fpscr_q is arbitrary; the register as a
151
+ * whole being zero/non-zero is what counts.
152
+ */
153
+ env->vfp.qc[0] = val & FPCR_QC;
154
+ env->vfp.qc[1] = 0;
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
--
29
--
165
2.20.1
30
2.20.1
166
31
167
32
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
In commit 1982e1602d15 we added a new qemu-storage-daemon(1) manpage.
2
At the moment new manpages have to be listed both in the conf.py for
3
Sphinx and also in docs/meson.build for Meson. We forgot the second
4
of those -- correct the omission.
2
5
3
This machine correctly defines its default_cpu_type to cortex-m3
4
and report an error if the user requested another cpu_type,
5
however it does not exit, and this can confuse users trying
6
to use another core:
7
8
$ qemu-system-arm -M emcraft-sf2 -cpu cortex-m4 -kernel test-m4.elf
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>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
9
Message-id: 20210108161416.21129-2-peter.maydell@linaro.org
28
---
10
---
29
hw/arm/msf2-som.c | 1 +
11
docs/meson.build | 1 +
30
1 file changed, 1 insertion(+)
12
1 file changed, 1 insertion(+)
31
13
32
diff --git a/hw/arm/msf2-som.c b/hw/arm/msf2-som.c
14
diff --git a/docs/meson.build b/docs/meson.build
33
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/arm/msf2-som.c
16
--- a/docs/meson.build
35
+++ b/hw/arm/msf2-som.c
17
+++ b/docs/meson.build
36
@@ -XXX,XX +XXX,XX @@ static void emcraft_sf2_s2s010_init(MachineState *machine)
18
@@ -XXX,XX +XXX,XX @@ if build_docs
37
if (strcmp(machine->cpu_type, mc->default_cpu_type) != 0) {
19
'qemu-img.1': (have_tools ? 'man1' : ''),
38
error_report("This board can only be used with CPU %s",
20
'qemu-nbd.8': (have_tools ? 'man8' : ''),
39
mc->default_cpu_type);
21
'qemu-pr-helper.8': (have_tools ? 'man8' : ''),
40
+ exit(1);
22
+ 'qemu-storage-daemon.1': (have_tools ? 'man1' : ''),
41
}
23
'qemu-trace-stap.1': (config_host.has_key('CONFIG_TRACE_SYSTEMTAP') ? 'man1' : ''),
42
24
'virtfs-proxy-helper.1': (have_virtfs_proxy_helper ? 'man1' : ''),
43
memory_region_init_ram(ddr, NULL, "ddr-ram", DDR_SIZE,
25
'virtiofsd.1': (have_virtiofsd ? 'man1' : ''),
44
--
26
--
45
2.20.1
27
2.20.1
46
28
47
29
diff view generated by jsdifflib
Deleted patch
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
2
1
3
Instantiate no-op APBH DMA module. Needed to boot latest Linux kernel.
4
5
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
6
Cc: Peter Maydell <peter.maydell@linaro.org>
7
Cc: Michael S. Tsirkin <mst@redhat.com>
8
Cc: qemu-devel@nongnu.org
9
Cc: qemu-arm@nongnu.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
include/hw/arm/fsl-imx7.h | 3 +++
14
hw/arm/fsl-imx7.c | 6 ++++++
15
2 files changed, 9 insertions(+)
16
17
diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h
18
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/arm/fsl-imx7.h
20
+++ b/include/hw/arm/fsl-imx7.h
21
@@ -XXX,XX +XXX,XX @@ enum FslIMX7MemoryMap {
22
FSL_IMX7_PCIE_REG_SIZE = 16 * 1024,
23
24
FSL_IMX7_GPR_ADDR = 0x30340000,
25
+
26
+ FSL_IMX7_DMA_APBH_ADDR = 0x33000000,
27
+ FSL_IMX7_DMA_APBH_SIZE = 0x2000,
28
};
29
30
enum FslIMX7IRQs {
31
diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/hw/arm/fsl-imx7.c
34
+++ b/hw/arm/fsl-imx7.c
35
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
36
*/
37
create_unimplemented_device("lcdif", FSL_IMX7_LCDIF_ADDR,
38
FSL_IMX7_LCDIF_SIZE);
39
+
40
+ /*
41
+ * DMA APBH
42
+ */
43
+ create_unimplemented_device("dma-apbh", FSL_IMX7_DMA_APBH_ADDR,
44
+ FSL_IMX7_DMA_APBH_SIZE);
45
}
46
47
static void fsl_imx7_class_init(ObjectClass *oc, void *data)
48
--
49
2.20.1
50
51
diff view generated by jsdifflib
Deleted patch
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
2
1
3
Add no-op/unimplemented PCIE PHY IP block. Needed by new kernels to
4
use PCIE.
5
6
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
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
--- a/include/hw/arm/fsl-imx7.h
21
+++ b/include/hw/arm/fsl-imx7.h
22
@@ -XXX,XX +XXX,XX @@ enum FslIMX7MemoryMap {
23
FSL_IMX7_ADC2_ADDR = 0x30620000,
24
FSL_IMX7_ADCn_SIZE = 0x1000,
25
26
+ FSL_IMX7_PCIE_PHY_ADDR = 0x306D0000,
27
+ FSL_IMX7_PCIE_PHY_SIZE = 0x10000,
28
+
29
FSL_IMX7_GPC_ADDR = 0x303A0000,
30
31
FSL_IMX7_I2C1_ADDR = 0x30A20000,
32
diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/arm/fsl-imx7.c
35
+++ b/hw/arm/fsl-imx7.c
36
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
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
}
46
47
static void fsl_imx7_class_init(ObjectClass *oc, void *data)
48
--
49
2.20.1
50
51
diff view generated by jsdifflib
Deleted patch
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
2
1
3
Expression to calculate update_msi_mapping in code handling writes to
4
DESIGNWARE_PCIE_MSI_INTR0_ENABLE is missing an ! operator and should
5
be:
6
7
!!root->msi.intr[0].enable ^ !!val;
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>
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
---
23
hw/pci-host/designware.c | 10 ++--------
24
1 file changed, 2 insertions(+), 8 deletions(-)
25
26
diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c
27
index XXXXXXX..XXXXXXX 100644
28
--- a/hw/pci-host/designware.c
29
+++ b/hw/pci-host/designware.c
30
@@ -XXX,XX +XXX,XX @@ static void designware_pcie_root_config_write(PCIDevice *d, uint32_t address,
31
root->msi.base |= (uint64_t)val << 32;
32
break;
33
34
- case DESIGNWARE_PCIE_MSI_INTR0_ENABLE: {
35
- const bool update_msi_mapping = !root->msi.intr[0].enable ^ !!val;
36
-
37
+ case DESIGNWARE_PCIE_MSI_INTR0_ENABLE:
38
root->msi.intr[0].enable = val;
39
-
40
- if (update_msi_mapping) {
41
- designware_pcie_root_update_msi_mapping(root);
42
- }
43
+ designware_pcie_root_update_msi_mapping(root);
44
break;
45
- }
46
47
case DESIGNWARE_PCIE_MSI_INTR0_MASK:
48
root->msi.intr[0].mask = val;
49
--
50
2.20.1
51
52
diff view generated by jsdifflib
Deleted patch
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
2
1
3
MSI mapping needs to be update when MSI address changes, so add the
4
code to do so.
5
6
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
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
Acked-by: Michael S. Tsirkin <mst@redhat.com>
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
15
hw/pci-host/designware.c | 2 ++
16
1 file changed, 2 insertions(+)
17
18
diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/pci-host/designware.c
21
+++ b/hw/pci-host/designware.c
22
@@ -XXX,XX +XXX,XX @@ static void designware_pcie_root_config_write(PCIDevice *d, uint32_t address,
23
case DESIGNWARE_PCIE_MSI_ADDR_LO:
24
root->msi.base &= 0xFFFFFFFF00000000ULL;
25
root->msi.base |= val;
26
+ designware_pcie_root_update_msi_mapping(root);
27
break;
28
29
case DESIGNWARE_PCIE_MSI_ADDR_HI:
30
root->msi.base &= 0x00000000FFFFFFFFULL;
31
root->msi.base |= (uint64_t)val << 32;
32
+ designware_pcie_root_update_msi_mapping(root);
33
break;
34
35
case DESIGNWARE_PCIE_MSI_INTR0_ENABLE:
36
--
37
2.20.1
38
39
diff view generated by jsdifflib
Deleted patch
1
From: Cédric Le Goater <clg@kaod.org>
2
1
3
This will simplify the definition of new SoCs, like the AST2600 which
4
should use a different CPU and a different IRQ number layout.
5
6
Signed-off-by: Cédric Le Goater <clg@kaod.org>
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
18
--- a/include/hw/arm/aspeed_soc.h
19
+++ b/include/hw/arm/aspeed_soc.h
20
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCInfo {
21
const char *fmc_typename;
22
const char **spi_typename;
23
int wdts_num;
24
+ const int *irqmap;
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
+{
151
+ AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
152
+
153
+ return qdev_get_gpio_in(DEVICE(&s->vic), sc->info->irqmap[ctrl]);
154
+}
155
+
156
static void aspeed_soc_init(Object *obj)
157
{
158
AspeedSoCState *s = ASPEED_SOC(obj);
159
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
160
return;
161
}
162
sysbus_mmio_map(SYS_BUS_DEVICE(&s->timerctrl), 0, ASPEED_SOC_TIMER_BASE);
163
- for (i = 0; i < ARRAY_SIZE(timer_irqs); i++) {
164
- qemu_irq irq = qdev_get_gpio_in(DEVICE(&s->vic), timer_irqs[i]);
165
+ for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) {
166
+ qemu_irq irq = aspeed_soc_get_irq(s, ASPEED_TIMER1 + i);
167
sysbus_connect_irq(SYS_BUS_DEVICE(&s->timerctrl), i, irq);
168
}
169
170
/* UART - attach an 8250 to the IO space as our UART5 */
171
if (serial_hd(0)) {
172
- qemu_irq uart5 = qdev_get_gpio_in(DEVICE(&s->vic), uart_irqs[4]);
173
+ qemu_irq uart5 = aspeed_soc_get_irq(s, ASPEED_UART5);
174
serial_mm_init(get_system_memory(),
175
ASPEED_SOC_IOMEM_BASE + ASPEED_SOC_UART_5_BASE, 2,
176
uart5, 38400, serial_hd(0), DEVICE_LITTLE_ENDIAN);
177
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
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
}
202
203
static void aspeed_soc_class_init(ObjectClass *oc, void *data)
204
--
205
2.20.1
206
207
diff view generated by jsdifflib
Deleted patch
1
From: Cédric Le Goater <clg@kaod.org>
2
1
3
This will simplify the definition of new SoCs, like the AST2600 which
4
should use a slightly different address space and have a different set
5
of controllers.
6
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>
12
---
13
include/hw/arm/aspeed_soc.h | 4 +-
14
hw/arm/aspeed.c | 8 +--
15
hw/arm/aspeed_soc.c | 117 ++++++++++++++++++++++--------------
16
3 files changed, 78 insertions(+), 51 deletions(-)
17
18
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
19
index XXXXXXX..XXXXXXX 100644
20
--- a/include/hw/arm/aspeed_soc.h
21
+++ b/include/hw/arm/aspeed_soc.h
22
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCInfo {
23
const char *name;
24
const char *cpu_type;
25
uint32_t silicon_rev;
26
- hwaddr sdram_base;
27
uint64_t sram_size;
28
int spis_num;
29
- const hwaddr *spi_bases;
30
const char *fmc_typename;
31
const char **spi_typename;
32
int wdts_num;
33
const int *irqmap;
34
+ const hwaddr *memmap;
35
} AspeedSoCInfo;
36
37
typedef struct AspeedSoCClass {
38
@@ -XXX,XX +XXX,XX @@ enum {
39
ASPEED_I2C,
40
ASPEED_ETH1,
41
ASPEED_ETH2,
42
+ ASPEED_SDRAM,
43
};
44
45
#endif /* ASPEED_SOC_H */
46
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
47
index XXXXXXX..XXXXXXX 100644
48
--- a/hw/arm/aspeed.c
49
+++ b/hw/arm/aspeed.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 @@
84
#include "hw/i2c/aspeed_i2c.h"
85
#include "net/net.h"
86
87
-#define ASPEED_SOC_UART_5_BASE 0x00184000
88
#define ASPEED_SOC_IOMEM_SIZE 0x00200000
89
-#define ASPEED_SOC_IOMEM_BASE 0x1E600000
90
-#define ASPEED_SOC_FMC_BASE 0x1E620000
91
-#define ASPEED_SOC_SPI_BASE 0x1E630000
92
-#define ASPEED_SOC_SPI2_BASE 0x1E631000
93
-#define ASPEED_SOC_VIC_BASE 0x1E6C0000
94
-#define ASPEED_SOC_SDMC_BASE 0x1E6E0000
95
-#define ASPEED_SOC_SCU_BASE 0x1E6E2000
96
-#define ASPEED_SOC_SRAM_BASE 0x1E720000
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
+
103
+static const hwaddr aspeed_soc_ast2400_memmap[] = {
104
+ [ASPEED_IOMEM] = 0x1E600000,
105
+ [ASPEED_FMC] = 0x1E620000,
106
+ [ASPEED_SPI1] = 0x1E630000,
107
+ [ASPEED_VIC] = 0x1E6C0000,
108
+ [ASPEED_SDMC] = 0x1E6E0000,
109
+ [ASPEED_SCU] = 0x1E6E2000,
110
+ [ASPEED_ADC] = 0x1E6E9000,
111
+ [ASPEED_SRAM] = 0x1E720000,
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;
243
}
244
- memory_region_add_subregion(get_system_memory(), ASPEED_SOC_SRAM_BASE,
245
- &s->sram);
246
+ memory_region_add_subregion(get_system_memory(),
247
+ sc->info->memmap[ASPEED_SRAM], &s->sram);
248
249
/* SCU */
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;
254
}
255
- sysbus_mmio_map(SYS_BUS_DEVICE(&s->scu), 0, ASPEED_SOC_SCU_BASE);
256
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->scu), 0, sc->info->memmap[ASPEED_SCU]);
257
258
/* VIC */
259
object_property_set_bool(OBJECT(&s->vic), true, "realized", &err);
260
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
261
error_propagate(errp, err);
262
return;
263
}
264
- sysbus_mmio_map(SYS_BUS_DEVICE(&s->vic), 0, ASPEED_SOC_VIC_BASE);
265
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->vic), 0, sc->info->memmap[ASPEED_VIC]);
266
sysbus_connect_irq(SYS_BUS_DEVICE(&s->vic), 0,
267
qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_IRQ));
268
sysbus_connect_irq(SYS_BUS_DEVICE(&s->vic), 1,
269
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
270
error_propagate(errp, err);
271
return;
272
}
273
- sysbus_mmio_map(SYS_BUS_DEVICE(&s->timerctrl), 0, ASPEED_SOC_TIMER_BASE);
274
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->timerctrl), 0,
275
+ sc->info->memmap[ASPEED_TIMER1]);
276
for (i = 0; i < ASPEED_TIMER_NR_TIMERS; i++) {
277
qemu_irq irq = aspeed_soc_get_irq(s, ASPEED_TIMER1 + i);
278
sysbus_connect_irq(SYS_BUS_DEVICE(&s->timerctrl), i, irq);
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;
292
}
293
- sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c), 0, ASPEED_SOC_I2C_BASE);
294
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c), 0, sc->info->memmap[ASPEED_I2C]);
295
sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c), 0,
296
aspeed_soc_get_irq(s, ASPEED_I2C));
297
298
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
299
error_propagate(errp, err);
300
return;
301
}
302
- sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 0, ASPEED_SOC_FMC_BASE);
303
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 0, sc->info->memmap[ASPEED_FMC]);
304
sysbus_mmio_map(SYS_BUS_DEVICE(&s->fmc), 1,
305
s->fmc.ctrl->flash_window_base);
306
sysbus_connect_irq(SYS_BUS_DEVICE(&s->fmc), 0,
307
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **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;
320
}
321
- sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdmc), 0, ASPEED_SOC_SDMC_BASE);
322
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdmc), 0, sc->info->memmap[ASPEED_SDMC]);
323
324
/* Watch dog */
325
for (i = 0; i < sc->info->wdts_num; i++) {
326
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
327
return;
328
}
329
sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt[i]), 0,
330
- ASPEED_SOC_WDT_BASE + i * 0x20);
331
+ sc->info->memmap[ASPEED_WDT] + i * 0x20);
332
}
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
--
346
2.20.1
347
348
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
When we first converted our documentation to Sphinx, we split it into
2
2
multiple manuals (system, interop, tools, etc), which are all built
3
To ease the review of the next commit,
3
separately. The primary driver for this was wanting to be able to
4
move the vfp_exceptbits_to_host() function directly after
4
avoid shipping the 'devel' manual to end-users. However, this is
5
vfp_exceptbits_from_host(). Amusingly the diff shows we
5
working against the grain of the way Sphinx wants to be used and
6
are moving vfp_get_fpscr().
6
causes some annoyances:
7
7
* Cross-references between documents become much harder or
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
possibly impossible
9
Message-id: 20190701132516.26392-15-philmd@redhat.com
9
* There is no single index to the whole documentation
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
* Within one manual there's no links or table-of-contents info
11
that lets you easily navigate to the others
12
* The devel manual doesn't get published on the QEMU website
13
(it would be nice to able to refer to it there)
14
15
Merely hiding our developer documentation from end users seems like
16
it's not enough benefit for these costs. Combine all the
17
documentation into a single manual (the same way that the readthedocs
18
site builds it) and install the whole thing. The previous manual
19
divisions remain as the new top level sections in the manual.
20
21
* The per-manual conf.py files are no longer needed
22
* The man_pages[] specifications previously in each per-manual
23
conf.py move to the top level conf.py
24
* docs/meson.build logic is simplified as we now only need to run
25
Sphinx once for the HTML and then once for the manpages5B
26
* The old index.html.in that produced the top-level page with
27
links to each manual is no longer needed
28
29
Unfortunately this means that we now have to build the HTML
30
documentation into docs/manual in the build tree rather than directly
31
into docs/; otherwise it is too awkward to ensure we install only the
32
built manual and not also the dependency info, stamp file, etc. The
33
manual still ends up in the same place in the final installed
34
directory, but anybody who was consulting documentation from within
35
the build tree will have to adjust where they're looking.
36
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
37
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
38
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
39
Message-id: 20210108161416.21129-3-peter.maydell@linaro.org
12
---
40
---
13
target/arm/vfp_helper.c | 52 ++++++++++++++++++++---------------------
41
docs/conf.py | 46 ++++++++++++++++++++++++++++++-
14
1 file changed, 26 insertions(+), 26 deletions(-)
42
docs/devel/conf.py | 15 -----------
15
43
docs/index.html.in | 17 ------------
16
diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c
44
docs/interop/conf.py | 28 -------------------
45
docs/meson.build | 64 +++++++++++++++++---------------------------
46
docs/specs/conf.py | 16 -----------
47
docs/system/conf.py | 28 -------------------
48
docs/tools/conf.py | 37 -------------------------
49
docs/user/conf.py | 15 -----------
50
9 files changed, 70 insertions(+), 196 deletions(-)
51
delete mode 100644 docs/devel/conf.py
52
delete mode 100644 docs/index.html.in
53
delete mode 100644 docs/interop/conf.py
54
delete mode 100644 docs/specs/conf.py
55
delete mode 100644 docs/system/conf.py
56
delete mode 100644 docs/tools/conf.py
57
delete mode 100644 docs/user/conf.py
58
59
diff --git a/docs/conf.py b/docs/conf.py
17
index XXXXXXX..XXXXXXX 100644
60
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/vfp_helper.c
61
--- a/docs/conf.py
19
+++ b/target/arm/vfp_helper.c
62
+++ b/docs/conf.py
20
@@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_from_host(int host_bits)
63
@@ -XXX,XX +XXX,XX @@ latex_documents = [
21
return target_bits;
64
22
}
65
# -- Options for manual page output ---------------------------------------
23
66
# Individual manual/conf.py can override this to create man pages
24
-uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env)
67
-man_pages = []
25
-{
68
+man_pages = [
26
- uint32_t i, fpscr;
69
+ ('interop/qemu-ga', 'qemu-ga',
27
-
70
+ 'QEMU Guest Agent',
28
- fpscr = env->vfp.xregs[ARM_VFP_FPSCR]
71
+ ['Michael Roth <mdroth@linux.vnet.ibm.com>'], 8),
29
- | (env->vfp.vec_len << 16)
72
+ ('interop/qemu-ga-ref', 'qemu-ga-ref',
30
- | (env->vfp.vec_stride << 20);
73
+ 'QEMU Guest Agent Protocol Reference',
31
-
74
+ [], 7),
32
- i = get_float_exception_flags(&env->vfp.fp_status);
75
+ ('interop/qemu-qmp-ref', 'qemu-qmp-ref',
33
- i |= get_float_exception_flags(&env->vfp.standard_fp_status);
76
+ 'QEMU QMP Reference Manual',
34
- /* FZ16 does not generate an input denormal exception. */
77
+ [], 7),
35
- i |= (get_float_exception_flags(&env->vfp.fp_status_f16)
78
+ ('interop/qemu-storage-daemon-qmp-ref', 'qemu-storage-daemon-qmp-ref',
36
- & ~float_flag_input_denormal);
79
+ 'QEMU Storage Daemon QMP Reference Manual',
37
- fpscr |= vfp_exceptbits_from_host(i);
80
+ [], 7),
38
-
81
+ ('system/qemu-manpage', 'qemu',
39
- i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3];
82
+ 'QEMU User Documentation',
40
- fpscr |= i ? FPCR_QC : 0;
83
+ ['Fabrice Bellard'], 1),
41
-
84
+ ('system/qemu-block-drivers', 'qemu-block-drivers',
42
- return fpscr;
85
+ 'QEMU block drivers reference',
43
-}
86
+ ['Fabrice Bellard and the QEMU Project developers'], 7),
44
-
87
+ ('system/qemu-cpu-models', 'qemu-cpu-models',
45
-uint32_t vfp_get_fpscr(CPUARMState *env)
88
+ 'QEMU CPU Models',
46
-{
89
+ ['The QEMU Project developers'], 7),
47
- return HELPER(vfp_get_fpscr)(env);
90
+ ('tools/qemu-img', 'qemu-img',
48
-}
91
+ 'QEMU disk image utility',
49
-
92
+ ['Fabrice Bellard'], 1),
50
/* Convert vfp exception flags to target form. */
93
+ ('tools/qemu-nbd', 'qemu-nbd',
51
static inline int vfp_exceptbits_to_host(int target_bits)
94
+ 'QEMU Disk Network Block Device Server',
52
{
95
+ ['Anthony Liguori <anthony@codemonkey.ws>'], 8),
53
@@ -XXX,XX +XXX,XX @@ static inline int vfp_exceptbits_to_host(int target_bits)
96
+ ('tools/qemu-pr-helper', 'qemu-pr-helper',
54
return host_bits;
97
+ 'QEMU persistent reservation helper',
55
}
98
+ [], 8),
56
99
+ ('tools/qemu-storage-daemon', 'qemu-storage-daemon',
57
+uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env)
100
+ 'QEMU storage daemon',
58
+{
101
+ [], 1),
59
+ uint32_t i, fpscr;
102
+ ('tools/qemu-trace-stap', 'qemu-trace-stap',
103
+ 'QEMU SystemTap trace tool',
104
+ [], 1),
105
+ ('tools/virtfs-proxy-helper', 'virtfs-proxy-helper',
106
+ 'QEMU 9p virtfs proxy filesystem helper',
107
+ ['M. Mohan Kumar'], 1),
108
+ ('tools/virtiofsd', 'virtiofsd',
109
+ 'QEMU virtio-fs shared file system daemon',
110
+ ['Stefan Hajnoczi <stefanha@redhat.com>',
111
+ 'Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>'], 1),
112
+]
113
114
# -- Options for Texinfo output -------------------------------------------
115
116
diff --git a/docs/devel/conf.py b/docs/devel/conf.py
117
deleted file mode 100644
118
index XXXXXXX..XXXXXXX
119
--- a/docs/devel/conf.py
120
+++ /dev/null
121
@@ -XXX,XX +XXX,XX @@
122
-# -*- coding: utf-8 -*-
123
-#
124
-# QEMU documentation build configuration file for the 'devel' manual.
125
-#
126
-# This includes the top level conf file and then makes any necessary tweaks.
127
-import sys
128
-import os
129
-
130
-qemu_docdir = os.path.abspath("..")
131
-parent_config = os.path.join(qemu_docdir, "conf.py")
132
-exec(compile(open(parent_config, "rb").read(), parent_config, 'exec'))
133
-
134
-# This slightly misuses the 'description', but is the best way to get
135
-# the manual title to appear in the sidebar.
136
-html_theme_options['description'] = u'Developer''s Guide'
137
diff --git a/docs/index.html.in b/docs/index.html.in
138
deleted file mode 100644
139
index XXXXXXX..XXXXXXX
140
--- a/docs/index.html.in
141
+++ /dev/null
142
@@ -XXX,XX +XXX,XX @@
143
-<!DOCTYPE html>
144
-<html lang="en">
145
- <head>
146
- <meta charset="UTF-8">
147
- <title>QEMU @VERSION@ Documentation</title>
148
- </head>
149
- <body>
150
- <h1>QEMU @VERSION@ Documentation</h1>
151
- <ul>
152
- <li><a href="system/index.html">System Emulation User's Guide</a></li>
153
- <li><a href="user/index.html">User Mode Emulation User's Guide</a></li>
154
- <li><a href="tools/index.html">Tools Guide</a></li>
155
- <li><a href="interop/index.html">System Emulation Management and Interoperability Guide</a></li>
156
- <li><a href="specs/index.html">System Emulation Guest Hardware Specifications</a></li>
157
- </ul>
158
- </body>
159
-</html>
160
diff --git a/docs/interop/conf.py b/docs/interop/conf.py
161
deleted file mode 100644
162
index XXXXXXX..XXXXXXX
163
--- a/docs/interop/conf.py
164
+++ /dev/null
165
@@ -XXX,XX +XXX,XX @@
166
-# -*- coding: utf-8 -*-
167
-#
168
-# QEMU documentation build configuration file for the 'interop' manual.
169
-#
170
-# This includes the top level conf file and then makes any necessary tweaks.
171
-import sys
172
-import os
173
-
174
-qemu_docdir = os.path.abspath("..")
175
-parent_config = os.path.join(qemu_docdir, "conf.py")
176
-exec(compile(open(parent_config, "rb").read(), parent_config, 'exec'))
177
-
178
-# This slightly misuses the 'description', but is the best way to get
179
-# the manual title to appear in the sidebar.
180
-html_theme_options['description'] = u'System Emulation Management and Interoperability Guide'
181
-
182
-# One entry per manual page. List of tuples
183
-# (source start file, name, description, authors, manual section).
184
-man_pages = [
185
- ('qemu-ga', 'qemu-ga', u'QEMU Guest Agent',
186
- ['Michael Roth <mdroth@linux.vnet.ibm.com>'], 8),
187
- ('qemu-ga-ref', 'qemu-ga-ref', 'QEMU Guest Agent Protocol Reference',
188
- [], 7),
189
- ('qemu-qmp-ref', 'qemu-qmp-ref', 'QEMU QMP Reference Manual',
190
- [], 7),
191
- ('qemu-storage-daemon-qmp-ref', 'qemu-storage-daemon-qmp-ref',
192
- 'QEMU Storage Daemon QMP Reference Manual', [], 7),
193
-]
194
diff --git a/docs/meson.build b/docs/meson.build
195
index XXXXXXX..XXXXXXX 100644
196
--- a/docs/meson.build
197
+++ b/docs/meson.build
198
@@ -XXX,XX +XXX,XX @@ if build_docs
199
meson.source_root() / 'docs/sphinx/qmp_lexer.py',
200
qapi_gen_depends ]
201
202
- configure_file(output: 'index.html',
203
- input: files('index.html.in'),
204
- configuration: {'VERSION': meson.project_version()},
205
- install_dir: qemu_docdir)
206
- manuals = [ 'devel', 'interop', 'tools', 'specs', 'system', 'user' ]
207
man_pages = {
208
- 'interop' : {
209
'qemu-ga.8': (have_tools ? 'man8' : ''),
210
'qemu-ga-ref.7': 'man7',
211
'qemu-qmp-ref.7': 'man7',
212
'qemu-storage-daemon-qmp-ref.7': (have_tools ? 'man7' : ''),
213
- },
214
- 'tools': {
215
'qemu-img.1': (have_tools ? 'man1' : ''),
216
'qemu-nbd.8': (have_tools ? 'man8' : ''),
217
'qemu-pr-helper.8': (have_tools ? 'man8' : ''),
218
@@ -XXX,XX +XXX,XX @@ if build_docs
219
'qemu-trace-stap.1': (config_host.has_key('CONFIG_TRACE_SYSTEMTAP') ? 'man1' : ''),
220
'virtfs-proxy-helper.1': (have_virtfs_proxy_helper ? 'man1' : ''),
221
'virtiofsd.1': (have_virtiofsd ? 'man1' : ''),
222
- },
223
- 'system': {
224
'qemu.1': 'man1',
225
'qemu-block-drivers.7': 'man7',
226
'qemu-cpu-models.7': 'man7'
227
- },
228
}
229
230
sphinxdocs = []
231
sphinxmans = []
232
- foreach manual : manuals
233
- private_dir = meson.current_build_dir() / (manual + '.p')
234
- output_dir = meson.current_build_dir() / manual
235
- input_dir = meson.current_source_dir() / manual
236
237
- this_manual = custom_target(manual + ' manual',
238
+ private_dir = meson.current_build_dir() / 'manual.p'
239
+ output_dir = meson.current_build_dir() / 'manual'
240
+ input_dir = meson.current_source_dir()
60
+
241
+
61
+ fpscr = env->vfp.xregs[ARM_VFP_FPSCR]
242
+ this_manual = custom_target('QEMU manual',
62
+ | (env->vfp.vec_len << 16)
243
build_by_default: build_docs,
63
+ | (env->vfp.vec_stride << 20);
244
- output: [manual + '.stamp'],
245
- input: [files('conf.py'), files(manual / 'conf.py')],
246
- depfile: manual + '.d',
247
+ output: 'docs.stamp',
248
+ input: files('conf.py'),
249
+ depfile: 'docs.d',
250
depend_files: sphinx_extn_depends,
251
command: [SPHINX_ARGS, '-Ddepfile=@DEPFILE@',
252
'-Ddepfile_stamp=@OUTPUT0@',
253
'-b', 'html', '-d', private_dir,
254
input_dir, output_dir])
255
- sphinxdocs += this_manual
256
- if build_docs and manual != 'devel'
257
- install_subdir(output_dir, install_dir: qemu_docdir)
258
- endif
259
+ sphinxdocs += this_manual
260
+ install_subdir(output_dir, install_dir: qemu_docdir, strip_directory: true)
261
262
- these_man_pages = []
263
- install_dirs = []
264
- foreach page, section : man_pages.get(manual, {})
265
- these_man_pages += page
266
- install_dirs += section == '' ? false : get_option('mandir') / section
267
- endforeach
268
- if these_man_pages.length() > 0
269
- sphinxmans += custom_target(manual + ' man pages',
270
- build_by_default: build_docs,
271
- output: these_man_pages,
272
- input: this_manual,
273
- install: build_docs,
274
- install_dir: install_dirs,
275
- command: [SPHINX_ARGS, '-b', 'man', '-d', private_dir,
276
- input_dir, meson.current_build_dir()])
277
- endif
278
+ these_man_pages = []
279
+ install_dirs = []
280
+ foreach page, section : man_pages
281
+ these_man_pages += page
282
+ install_dirs += section == '' ? false : get_option('mandir') / section
283
endforeach
64
+
284
+
65
+ i = get_float_exception_flags(&env->vfp.fp_status);
285
+ sphinxmans += custom_target('QEMU man pages',
66
+ i |= get_float_exception_flags(&env->vfp.standard_fp_status);
286
+ build_by_default: build_docs,
67
+ /* FZ16 does not generate an input denormal exception. */
287
+ output: these_man_pages,
68
+ i |= (get_float_exception_flags(&env->vfp.fp_status_f16)
288
+ input: this_manual,
69
+ & ~float_flag_input_denormal);
289
+ install: build_docs,
70
+ fpscr |= vfp_exceptbits_from_host(i);
290
+ install_dir: install_dirs,
291
+ command: [SPHINX_ARGS, '-b', 'man', '-d', private_dir,
292
+ input_dir, meson.current_build_dir()])
71
+
293
+
72
+ i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3];
294
alias_target('sphinxdocs', sphinxdocs)
73
+ fpscr |= i ? FPCR_QC : 0;
295
alias_target('html', sphinxdocs)
74
+
296
alias_target('man', sphinxmans)
75
+ return fpscr;
297
diff --git a/docs/specs/conf.py b/docs/specs/conf.py
76
+}
298
deleted file mode 100644
77
+
299
index XXXXXXX..XXXXXXX
78
+uint32_t vfp_get_fpscr(CPUARMState *env)
300
--- a/docs/specs/conf.py
79
+{
301
+++ /dev/null
80
+ return HELPER(vfp_get_fpscr)(env);
302
@@ -XXX,XX +XXX,XX @@
81
+}
303
-# -*- coding: utf-8 -*-
82
+
304
-#
83
void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val)
305
-# QEMU documentation build configuration file for the 'specs' manual.
84
{
306
-#
85
int i;
307
-# This includes the top level conf file and then makes any necessary tweaks.
308
-import sys
309
-import os
310
-
311
-qemu_docdir = os.path.abspath("..")
312
-parent_config = os.path.join(qemu_docdir, "conf.py")
313
-exec(compile(open(parent_config, "rb").read(), parent_config, 'exec'))
314
-
315
-# This slightly misuses the 'description', but is the best way to get
316
-# the manual title to appear in the sidebar.
317
-html_theme_options['description'] = \
318
- u'System Emulation Guest Hardware Specifications'
319
diff --git a/docs/system/conf.py b/docs/system/conf.py
320
deleted file mode 100644
321
index XXXXXXX..XXXXXXX
322
--- a/docs/system/conf.py
323
+++ /dev/null
324
@@ -XXX,XX +XXX,XX @@
325
-# -*- coding: utf-8 -*-
326
-#
327
-# QEMU documentation build configuration file for the 'system' manual.
328
-#
329
-# This includes the top level conf file and then makes any necessary tweaks.
330
-import sys
331
-import os
332
-
333
-qemu_docdir = os.path.abspath("..")
334
-parent_config = os.path.join(qemu_docdir, "conf.py")
335
-exec(compile(open(parent_config, "rb").read(), parent_config, 'exec'))
336
-
337
-# This slightly misuses the 'description', but is the best way to get
338
-# the manual title to appear in the sidebar.
339
-html_theme_options['description'] = u'System Emulation User''s Guide'
340
-
341
-# One entry per manual page. List of tuples
342
-# (source start file, name, description, authors, manual section).
343
-man_pages = [
344
- ('qemu-manpage', 'qemu', u'QEMU User Documentation',
345
- ['Fabrice Bellard'], 1),
346
- ('qemu-block-drivers', 'qemu-block-drivers',
347
- u'QEMU block drivers reference',
348
- ['Fabrice Bellard and the QEMU Project developers'], 7),
349
- ('qemu-cpu-models', 'qemu-cpu-models',
350
- u'QEMU CPU Models',
351
- ['The QEMU Project developers'], 7)
352
-]
353
diff --git a/docs/tools/conf.py b/docs/tools/conf.py
354
deleted file mode 100644
355
index XXXXXXX..XXXXXXX
356
--- a/docs/tools/conf.py
357
+++ /dev/null
358
@@ -XXX,XX +XXX,XX @@
359
-# -*- coding: utf-8 -*-
360
-#
361
-# QEMU documentation build configuration file for the 'tools' manual.
362
-#
363
-# This includes the top level conf file and then makes any necessary tweaks.
364
-import sys
365
-import os
366
-
367
-qemu_docdir = os.path.abspath("..")
368
-parent_config = os.path.join(qemu_docdir, "conf.py")
369
-exec(compile(open(parent_config, "rb").read(), parent_config, 'exec'))
370
-
371
-# This slightly misuses the 'description', but is the best way to get
372
-# the manual title to appear in the sidebar.
373
-html_theme_options['description'] = \
374
- u'Tools Guide'
375
-
376
-# One entry per manual page. List of tuples
377
-# (source start file, name, description, authors, manual section).
378
-man_pages = [
379
- ('qemu-img', 'qemu-img', u'QEMU disk image utility',
380
- ['Fabrice Bellard'], 1),
381
- ('qemu-storage-daemon', 'qemu-storage-daemon', u'QEMU storage daemon',
382
- [], 1),
383
- ('qemu-nbd', 'qemu-nbd', u'QEMU Disk Network Block Device Server',
384
- ['Anthony Liguori <anthony@codemonkey.ws>'], 8),
385
- ('qemu-pr-helper', 'qemu-pr-helper', 'QEMU persistent reservation helper',
386
- [], 8),
387
- ('qemu-trace-stap', 'qemu-trace-stap', u'QEMU SystemTap trace tool',
388
- [], 1),
389
- ('virtfs-proxy-helper', 'virtfs-proxy-helper',
390
- u'QEMU 9p virtfs proxy filesystem helper',
391
- ['M. Mohan Kumar'], 1),
392
- ('virtiofsd', 'virtiofsd', u'QEMU virtio-fs shared file system daemon',
393
- ['Stefan Hajnoczi <stefanha@redhat.com>',
394
- 'Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>'], 1),
395
-]
396
diff --git a/docs/user/conf.py b/docs/user/conf.py
397
deleted file mode 100644
398
index XXXXXXX..XXXXXXX
399
--- a/docs/user/conf.py
400
+++ /dev/null
401
@@ -XXX,XX +XXX,XX @@
402
-# -*- coding: utf-8 -*-
403
-#
404
-# QEMU documentation build configuration file for the 'user' manual.
405
-#
406
-# This includes the top level conf file and then makes any necessary tweaks.
407
-import sys
408
-import os
409
-
410
-qemu_docdir = os.path.abspath("..")
411
-parent_config = os.path.join(qemu_docdir, "conf.py")
412
-exec(compile(open(parent_config, "rb").read(), parent_config, 'exec'))
413
-
414
-# This slightly misuses the 'description', but is the best way to get
415
-# the manual title to appear in the sidebar.
416
-html_theme_options['description'] = u'User Mode Emulation User''s Guide'
86
--
417
--
87
2.20.1
418
2.20.1
88
419
89
420
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
In commit cd8be50e58f63413c0 we converted the A32 coprocessor
2
insns to decodetree. This accidentally broke XScale/iWMMXt insns,
3
because it moved the handling of "cp insns which are handled
4
by looking up the cp register in the hashtable" from after the
5
call to the legacy disas_xscale_insn() decode to before it,
6
with the result that all XScale/iWMMXt insns now UNDEF.
2
7
3
Since we'll move this code around, fix its style first.
8
Update valid_cp() so that it knows that on XScale cp 0 and 1
9
are not standard coprocessor instructions; this will cause
10
the decodetree trans_ functions to ignore them, so that
11
execution will correctly get through to the legacy decode again.
4
12
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
13
Cc: qemu-stable@nongnu.org
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
14
Reported-by: Guenter Roeck <linux@roeck-us.net>
7
Message-id: 20190701132516.26392-9-philmd@redhat.com
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
17
Tested-by: Guenter Roeck <linux@roeck-us.net>
18
Message-id: 20210108195157.32067-1-peter.maydell@linaro.org
9
---
19
---
10
target/arm/translate.c | 11 ++++++-----
20
target/arm/translate.c | 7 +++++++
11
target/arm/vfp_helper.c | 36 ++++++++++++++++++++++++------------
21
1 file changed, 7 insertions(+)
12
2 files changed, 30 insertions(+), 17 deletions(-)
13
22
14
diff --git a/target/arm/translate.c b/target/arm/translate.c
23
diff --git a/target/arm/translate.c b/target/arm/translate.c
15
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/translate.c
25
--- a/target/arm/translate.c
17
+++ b/target/arm/translate.c
26
+++ b/target/arm/translate.c
18
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
27
@@ -XXX,XX +XXX,XX @@ static bool valid_cp(DisasContext *s, int cp)
19
loaded_base = 0;
28
* only cp14 and cp15 are valid, and other values aren't considered
20
loaded_var = NULL;
29
* to be in the coprocessor-instruction space at all. v8M still
21
n = 0;
30
* permits coprocessors 0..7.
22
- for(i=0;i<16;i++) {
31
+ * For XScale, we must not decode the XScale cp0, cp1 space as
23
+ for (i = 0; i < 16; i++) {
32
+ * a standard coprocessor insn, because we want to fall through to
24
if (insn & (1 << i))
33
+ * the legacy disas_xscale_insn() decoder after decodetree is done.
25
n++;
34
*/
26
}
35
+ if (arm_dc_feature(s, ARM_FEATURE_XSCALE) && (cp == 0 || cp == 1)) {
27
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
36
+ return false;
28
}
29
}
30
j = 0;
31
- for(i=0;i<16;i++) {
32
+ for (i = 0; i < 16; i++) {
33
if (insn & (1 << i)) {
34
if (is_load) {
35
/* load */
36
@@ -XXX,XX +XXX,XX @@ void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags)
37
return;
38
}
39
40
- for(i=0;i<16;i++) {
41
+ for (i = 0; i < 16; i++) {
42
qemu_fprintf(f, "R%02d=%08x", i, env->regs[i]);
43
- if ((i % 4) == 3)
44
+ if ((i % 4) == 3) {
45
qemu_fprintf(f, "\n");
46
- else
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
+ }
37
+ }
66
+ if (host_bits & float_flag_divbyzero) {
38
+
67
target_bits |= 2;
39
if (arm_dc_feature(s, ARM_FEATURE_V8) &&
68
- if (host_bits & float_flag_overflow)
40
!arm_dc_feature(s, ARM_FEATURE_M)) {
69
+ }
41
return cp >= 14;
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
}
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
119
--
42
--
120
2.20.1
43
2.20.1
121
44
122
45
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
A copy-and-paste error meant that the return value for register offset 0x44
2
(the RX Status FIFO PEEK register) returned a byte from a bogus offset in
3
the rx status FIFO. Fix the typo.
2
4
3
In the next commit we will split the TLB related routines of
5
Cc: qemu-stable@nongnu.org
4
this file, and this function will also be called in the new
6
Fixes: https://bugs.launchpad.net/qemu/+bug/1904954
5
file. Declare it in the "internals.h" header.
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-id: 20210108180401.2263-2-peter.maydell@linaro.org
10
---
11
hw/net/lan9118.c | 2 +-
12
1 file changed, 1 insertion(+), 1 deletion(-)
6
13
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
14
diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c
8
Message-id: 20190701132516.26392-12-philmd@redhat.com
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
target/arm/internals.h | 16 ++++++++++++++++
13
target/arm/helper.c | 21 +++++----------------
14
2 files changed, 21 insertions(+), 16 deletions(-)
15
16
diff --git a/target/arm/internals.h b/target/arm/internals.h
17
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/internals.h
16
--- a/hw/net/lan9118.c
19
+++ b/target/arm/internals.h
17
+++ b/hw/net/lan9118.c
20
@@ -XXX,XX +XXX,XX @@ static inline int exception_target_el(CPUARMState *env)
18
@@ -XXX,XX +XXX,XX @@ static uint64_t lan9118_readl(void *opaque, hwaddr offset,
21
return target_el;
19
case 0x40:
22
}
20
return rx_status_fifo_pop(s);
23
21
case 0x44:
24
+#ifndef CONFIG_USER_ONLY
22
- return s->rx_status_fifo[s->tx_status_fifo_head];
25
+
23
+ return s->rx_status_fifo[s->rx_status_fifo_head];
26
+/* Cacheability and shareability attributes for a memory access */
24
case 0x48:
27
+typedef struct ARMCacheAttrs {
25
return tx_status_fifo_pop(s);
28
+ unsigned int attrs:8; /* as in the MAIR register encoding */
26
case 0x4c:
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
42
index XXXXXXX..XXXXXXX 100644
43
--- a/target/arm/helper.c
44
+++ b/target/arm/helper.c
45
@@ -XXX,XX +XXX,XX @@
46
#define ARM_CPU_FREQ 1000000000 /* FIXME: 1 GHz, should be configurable */
47
48
#ifndef CONFIG_USER_ONLY
49
-/* Cacheability and shareability attributes for a memory access */
50
-typedef struct ARMCacheAttrs {
51
- unsigned int attrs:8; /* as in the MAIR register encoding */
52
- unsigned int shareability:2; /* as in the SH field of the VMSAv8-64 PTEs */
53
-} ARMCacheAttrs;
54
-
55
-static bool get_phys_addr(CPUARMState *env, target_ulong address,
56
- MMUAccessType access_type, ARMMMUIdx mmu_idx,
57
- hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot,
58
- target_ulong *page_size,
59
- ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs);
60
61
static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,
62
MMUAccessType access_type, ARMMMUIdx mmu_idx,
63
@@ -XXX,XX +XXX,XX @@ static ARMCacheAttrs combine_cacheattrs(ARMCacheAttrs s1, ARMCacheAttrs s2)
64
* @fi: set to fault info if the translation fails
65
* @cacheattrs: (if non-NULL) set to the cacheability/shareability attributes
66
*/
67
-static bool get_phys_addr(CPUARMState *env, target_ulong address,
68
- MMUAccessType access_type, ARMMMUIdx mmu_idx,
69
- hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot,
70
- target_ulong *page_size,
71
- ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs)
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
--
27
--
81
2.20.1
28
2.20.1
82
29
83
30
diff view generated by jsdifflib
1
From: Samuel Ortiz <sameo@linux.intel.com>
1
The lan9118 code mostly uses symbolic constants for register offsets;
2
the exceptions are those which the datasheet doesn't give an official
3
symbolic name to.
2
4
3
Those helpers are a software implementation of the ARM v8 memory zeroing
5
Add some names for the registers which don't already have them, based
4
op code. They should be moved to the op helper file, which is going to
6
on the longer names they are given in the memory map.
5
eventually be built only when TCG is enabled.
6
7
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Reviewed-by: Robert Bradford <robert.bradford@intel.com>
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>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Message-id: 20210108180401.2263-3-peter.maydell@linaro.org
17
---
11
---
18
target/arm/helper.c | 92 -----------------------------------------
12
hw/net/lan9118.c | 24 ++++++++++++++++++------
19
target/arm/op_helper.c | 93 ++++++++++++++++++++++++++++++++++++++++++
13
1 file changed, 18 insertions(+), 6 deletions(-)
20
2 files changed, 93 insertions(+), 92 deletions(-)
21
14
22
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c
23
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
24
--- a/target/arm/helper.c
17
--- a/hw/net/lan9118.c
25
+++ b/target/arm/helper.c
18
+++ b/hw/net/lan9118.c
26
@@ -XXX,XX +XXX,XX @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
19
@@ -XXX,XX +XXX,XX @@ do { hw_error("lan9118: error: " fmt , ## __VA_ARGS__);} while (0)
20
do { fprintf(stderr, "lan9118: error: " fmt , ## __VA_ARGS__);} while (0)
27
#endif
21
#endif
28
}
22
29
23
+/* The tx and rx fifo ports are a range of aliased 32-bit registers */
30
-void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in)
24
+#define RX_DATA_FIFO_PORT_FIRST 0x00
31
-{
25
+#define RX_DATA_FIFO_PORT_LAST 0x1f
32
- /*
26
+#define TX_DATA_FIFO_PORT_FIRST 0x20
33
- * Implement DC ZVA, which zeroes a fixed-length block of memory.
27
+#define TX_DATA_FIFO_PORT_LAST 0x3f
34
- * Note that we do not implement the (architecturally mandated)
28
+
35
- * alignment fault for attempts to use this on Device memory
29
+#define RX_STATUS_FIFO_PORT 0x40
36
- * (which matches the usual QEMU behaviour of not implementing either
30
+#define RX_STATUS_FIFO_PEEK 0x44
37
- * alignment faults or any memory attribute handling).
31
+#define TX_STATUS_FIFO_PORT 0x48
38
- */
32
+#define TX_STATUS_FIFO_PEEK 0x4c
39
-
33
+
40
- ARMCPU *cpu = env_archcpu(env);
34
#define CSR_ID_REV 0x50
41
- uint64_t blocklen = 4 << cpu->dcz_blocksize;
35
#define CSR_IRQ_CFG 0x54
42
- uint64_t vaddr = vaddr_in & ~(blocklen - 1);
36
#define CSR_INT_STS 0x58
43
-
37
@@ -XXX,XX +XXX,XX @@ static void lan9118_writel(void *opaque, hwaddr offset,
44
-#ifndef CONFIG_USER_ONLY
38
offset &= 0xff;
45
- {
39
46
- /*
40
//DPRINTF("Write reg 0x%02x = 0x%08x\n", (int)offset, val);
47
- * Slightly awkwardly, QEMU's TARGET_PAGE_SIZE may be less than
41
- if (offset >= 0x20 && offset < 0x40) {
48
- * the block size so we might have to do more than one TLB lookup.
42
+ if (offset >= TX_DATA_FIFO_PORT_FIRST &&
49
- * We know that in fact for any v8 CPU the page size is at least 4K
43
+ offset <= TX_DATA_FIFO_PORT_LAST) {
50
- * and the block size must be 2K or less, but TARGET_PAGE_SIZE is only
44
/* TX FIFO */
51
- * 1K as an artefact of legacy v5 subpage support being present in the
45
tx_fifo_push(s, val);
52
- * same QEMU executable. So in practice the hostaddr[] array has
46
return;
53
- * two entries, given the current setting of TARGET_PAGE_BITS_MIN.
47
@@ -XXX,XX +XXX,XX @@ static uint64_t lan9118_readl(void *opaque, hwaddr offset,
54
- */
48
lan9118_state *s = (lan9118_state *)opaque;
55
- int maxidx = DIV_ROUND_UP(blocklen, TARGET_PAGE_SIZE);
49
56
- void *hostaddr[DIV_ROUND_UP(2 * KiB, 1 << TARGET_PAGE_BITS_MIN)];
50
//DPRINTF("Read reg 0x%02x\n", (int)offset);
57
- int try, i;
51
- if (offset < 0x20) {
58
- unsigned mmu_idx = cpu_mmu_index(env, false);
52
+ if (offset <= RX_DATA_FIFO_PORT_LAST) {
59
- TCGMemOpIdx oi = make_memop_idx(MO_UB, mmu_idx);
53
/* RX FIFO */
60
-
54
return rx_fifo_pop(s);
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
}
55
}
140
}
56
switch (offset) {
141
+
57
- case 0x40:
142
+void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in)
58
+ case RX_STATUS_FIFO_PORT:
143
+{
59
return rx_status_fifo_pop(s);
144
+ /*
60
- case 0x44:
145
+ * Implement DC ZVA, which zeroes a fixed-length block of memory.
61
+ case RX_STATUS_FIFO_PEEK:
146
+ * Note that we do not implement the (architecturally mandated)
62
return s->rx_status_fifo[s->rx_status_fifo_head];
147
+ * alignment fault for attempts to use this on Device memory
63
- case 0x48:
148
+ * (which matches the usual QEMU behaviour of not implementing either
64
+ case TX_STATUS_FIFO_PORT:
149
+ * alignment faults or any memory attribute handling).
65
return tx_status_fifo_pop(s);
150
+ */
66
- case 0x4c:
151
+
67
+ case TX_STATUS_FIFO_PEEK:
152
+ ARMCPU *cpu = env_archcpu(env);
68
return s->tx_status_fifo[s->tx_status_fifo_head];
153
+ uint64_t blocklen = 4 << cpu->dcz_blocksize;
69
case CSR_ID_REV:
154
+ uint64_t vaddr = vaddr_in & ~(blocklen - 1);
70
return 0x01180001;
155
+
156
+#ifndef CONFIG_USER_ONLY
157
+ {
158
+ /*
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
+ }
229
+#else
230
+ memset(g2h(vaddr), 0, blocklen);
231
+#endif
232
+}
233
--
71
--
234
2.20.1
72
2.20.1
235
73
236
74
diff view generated by jsdifflib
1
From: Hongbo Zhang <hongbo.zhang@linaro.org>
1
From: Hao Wu <wuhaotsh@google.com>
2
2
3
Following the previous patch, this patch adds peripheral devices to the
3
This patch allows NPCM7XX CLK module to compute clocks that are used by
4
newly introduced SBSA-ref machine.
4
other NPCM7XX modules.
5
5
6
Signed-off-by: Hongbo Zhang <hongbo.zhang@linaro.org>
6
Add a new struct NPCM7xxClockConverterState which represents a
7
Message-id: 1561890034-15921-3-git-send-email-hongbo.zhang@linaro.org
7
single converter. Each clock converter in CLK module represents one
8
converter in NPCM7XX CLK Module(PLL, SEL or Divider). Each converter
9
takes one or more input clocks and converts them into one output clock.
10
They form a clock hierarchy in the CLK module and are responsible for
11
outputing clocks for various other modules in an NPCM7XX SoC.
12
13
Each converter has a function pointer called "convert" which represents
14
the unique logic for that converter.
15
16
The clock contains two initialization information: ConverterInitInfo and
17
ConverterConnectionInfo. They represent the vertices and edges in the
18
clock diagram respectively.
19
20
Reviewed-by: Havard Skinnemoen <hskinnemoen@google.com>
21
Reviewed-by: Tyrone Ting <kfting@nuvoton.com>
22
Signed-off-by: Hao Wu <wuhaotsh@google.com>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
23
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
24
Message-id: 20210108190945.949196-2-wuhaotsh@google.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
25
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
26
---
11
hw/arm/sbsa-ref.c | 535 ++++++++++++++++++++++++++++++++++++++++++++++
27
include/hw/misc/npcm7xx_clk.h | 140 +++++-
12
1 file changed, 535 insertions(+)
28
hw/misc/npcm7xx_clk.c | 805 +++++++++++++++++++++++++++++++++-
29
2 files changed, 932 insertions(+), 13 deletions(-)
13
30
14
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
31
diff --git a/include/hw/misc/npcm7xx_clk.h b/include/hw/misc/npcm7xx_clk.h
15
index XXXXXXX..XXXXXXX 100644
32
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/arm/sbsa-ref.c
33
--- a/include/hw/misc/npcm7xx_clk.h
17
+++ b/hw/arm/sbsa-ref.c
34
+++ b/include/hw/misc/npcm7xx_clk.h
18
@@ -XXX,XX +XXX,XX @@
35
@@ -XXX,XX +XXX,XX @@
19
*/
36
#define NPCM7XX_CLK_H
20
37
21
#include "qemu/osdep.h"
38
#include "exec/memory.h"
22
+#include "qemu-common.h"
39
+#include "hw/clock.h"
23
#include "qapi/error.h"
40
#include "hw/sysbus.h"
41
42
/*
43
@@ -XXX,XX +XXX,XX @@
44
45
#define NPCM7XX_WATCHDOG_RESET_GPIO_IN "npcm7xx-clk-watchdog-reset-gpio-in"
46
47
-typedef struct NPCM7xxCLKState {
48
+/* Maximum amount of clock inputs in a SEL module. */
49
+#define NPCM7XX_CLK_SEL_MAX_INPUT 5
50
+
51
+/* PLLs in CLK module. */
52
+typedef enum NPCM7xxClockPLL {
53
+ NPCM7XX_CLOCK_PLL0,
54
+ NPCM7XX_CLOCK_PLL1,
55
+ NPCM7XX_CLOCK_PLL2,
56
+ NPCM7XX_CLOCK_PLLG,
57
+ NPCM7XX_CLOCK_NR_PLLS,
58
+} NPCM7xxClockPLL;
59
+
60
+/* SEL/MUX in CLK module. */
61
+typedef enum NPCM7xxClockSEL {
62
+ NPCM7XX_CLOCK_PIXCKSEL,
63
+ NPCM7XX_CLOCK_MCCKSEL,
64
+ NPCM7XX_CLOCK_CPUCKSEL,
65
+ NPCM7XX_CLOCK_CLKOUTSEL,
66
+ NPCM7XX_CLOCK_UARTCKSEL,
67
+ NPCM7XX_CLOCK_TIMCKSEL,
68
+ NPCM7XX_CLOCK_SDCKSEL,
69
+ NPCM7XX_CLOCK_GFXMSEL,
70
+ NPCM7XX_CLOCK_SUCKSEL,
71
+ NPCM7XX_CLOCK_NR_SELS,
72
+} NPCM7xxClockSEL;
73
+
74
+/* Dividers in CLK module. */
75
+typedef enum NPCM7xxClockDivider {
76
+ NPCM7XX_CLOCK_PLL1D2, /* PLL1/2 */
77
+ NPCM7XX_CLOCK_PLL2D2, /* PLL2/2 */
78
+ NPCM7XX_CLOCK_MC_DIVIDER,
79
+ NPCM7XX_CLOCK_AXI_DIVIDER,
80
+ NPCM7XX_CLOCK_AHB_DIVIDER,
81
+ NPCM7XX_CLOCK_AHB3_DIVIDER,
82
+ NPCM7XX_CLOCK_SPI0_DIVIDER,
83
+ NPCM7XX_CLOCK_SPIX_DIVIDER,
84
+ NPCM7XX_CLOCK_APB1_DIVIDER,
85
+ NPCM7XX_CLOCK_APB2_DIVIDER,
86
+ NPCM7XX_CLOCK_APB3_DIVIDER,
87
+ NPCM7XX_CLOCK_APB4_DIVIDER,
88
+ NPCM7XX_CLOCK_APB5_DIVIDER,
89
+ NPCM7XX_CLOCK_CLKOUT_DIVIDER,
90
+ NPCM7XX_CLOCK_UART_DIVIDER,
91
+ NPCM7XX_CLOCK_TIMER_DIVIDER,
92
+ NPCM7XX_CLOCK_ADC_DIVIDER,
93
+ NPCM7XX_CLOCK_MMC_DIVIDER,
94
+ NPCM7XX_CLOCK_SDHC_DIVIDER,
95
+ NPCM7XX_CLOCK_GFXM_DIVIDER, /* divide by 3 */
96
+ NPCM7XX_CLOCK_UTMI_DIVIDER,
97
+ NPCM7XX_CLOCK_NR_DIVIDERS,
98
+} NPCM7xxClockConverter;
99
+
100
+typedef struct NPCM7xxCLKState NPCM7xxCLKState;
101
+
102
+/**
103
+ * struct NPCM7xxClockPLLState - A PLL module in CLK module.
104
+ * @name: The name of the module.
105
+ * @clk: The CLK module that owns this module.
106
+ * @clock_in: The input clock of this module.
107
+ * @clock_out: The output clock of this module.
108
+ * @reg: The control registers for this PLL module.
109
+ */
110
+typedef struct NPCM7xxClockPLLState {
111
+ DeviceState parent;
112
+
113
+ const char *name;
114
+ NPCM7xxCLKState *clk;
115
+ Clock *clock_in;
116
+ Clock *clock_out;
117
+
118
+ int reg;
119
+} NPCM7xxClockPLLState;
120
+
121
+/**
122
+ * struct NPCM7xxClockSELState - A SEL module in CLK module.
123
+ * @name: The name of the module.
124
+ * @clk: The CLK module that owns this module.
125
+ * @input_size: The size of inputs of this module.
126
+ * @clock_in: The input clocks of this module.
127
+ * @clock_out: The output clocks of this module.
128
+ * @offset: The offset of this module in the control register.
129
+ * @len: The length of this module in the control register.
130
+ */
131
+typedef struct NPCM7xxClockSELState {
132
+ DeviceState parent;
133
+
134
+ const char *name;
135
+ NPCM7xxCLKState *clk;
136
+ uint8_t input_size;
137
+ Clock *clock_in[NPCM7XX_CLK_SEL_MAX_INPUT];
138
+ Clock *clock_out;
139
+
140
+ int offset;
141
+ int len;
142
+} NPCM7xxClockSELState;
143
+
144
+/**
145
+ * struct NPCM7xxClockDividerState - A Divider module in CLK module.
146
+ * @name: The name of the module.
147
+ * @clk: The CLK module that owns this module.
148
+ * @clock_in: The input clock of this module.
149
+ * @clock_out: The output clock of this module.
150
+ * @divide: The function the divider uses to divide the input.
151
+ * @reg: The index of the control register that contains the divisor.
152
+ * @offset: The offset of the divisor in the control register.
153
+ * @len: The length of the divisor in the control register.
154
+ * @divisor: The divisor for a constant divisor
155
+ */
156
+typedef struct NPCM7xxClockDividerState {
157
+ DeviceState parent;
158
+
159
+ const char *name;
160
+ NPCM7xxCLKState *clk;
161
+ Clock *clock_in;
162
+ Clock *clock_out;
163
+
164
+ uint32_t (*divide)(struct NPCM7xxClockDividerState *s);
165
+ union {
166
+ struct {
167
+ int reg;
168
+ int offset;
169
+ int len;
170
+ };
171
+ int divisor;
172
+ };
173
+} NPCM7xxClockDividerState;
174
+
175
+struct NPCM7xxCLKState {
176
SysBusDevice parent;
177
178
MemoryRegion iomem;
179
180
+ /* Clock converters */
181
+ NPCM7xxClockPLLState plls[NPCM7XX_CLOCK_NR_PLLS];
182
+ NPCM7xxClockSELState sels[NPCM7XX_CLOCK_NR_SELS];
183
+ NPCM7xxClockDividerState dividers[NPCM7XX_CLOCK_NR_DIVIDERS];
184
+
185
uint32_t regs[NPCM7XX_CLK_NR_REGS];
186
187
/* Time reference for SECCNT and CNTR25M, initialized by power on reset */
188
int64_t ref_ns;
189
-} NPCM7xxCLKState;
190
+
191
+ /* The incoming reference clock. */
192
+ Clock *clkref;
193
+};
194
195
#define TYPE_NPCM7XX_CLK "npcm7xx-clk"
196
#define NPCM7XX_CLK(obj) OBJECT_CHECK(NPCM7xxCLKState, (obj), TYPE_NPCM7XX_CLK)
197
diff --git a/hw/misc/npcm7xx_clk.c b/hw/misc/npcm7xx_clk.c
198
index XXXXXXX..XXXXXXX 100644
199
--- a/hw/misc/npcm7xx_clk.c
200
+++ b/hw/misc/npcm7xx_clk.c
201
@@ -XXX,XX +XXX,XX @@
202
203
#include "hw/misc/npcm7xx_clk.h"
204
#include "hw/timer/npcm7xx_timer.h"
205
+#include "hw/qdev-clock.h"
206
#include "migration/vmstate.h"
24
#include "qemu/error-report.h"
207
#include "qemu/error-report.h"
25
#include "qemu/units.h"
208
#include "qemu/log.h"
26
+#include "sysemu/device_tree.h"
209
@@ -XXX,XX +XXX,XX @@
27
#include "sysemu/numa.h"
210
#include "trace.h"
28
#include "sysemu/sysemu.h"
211
#include "sysemu/watchdog.h"
29
#include "exec/address-spaces.h"
212
30
#include "exec/hwaddr.h"
213
+/*
31
#include "kvm_arm.h"
214
+ * The reference clock hz, and the SECCNT and CNTR25M registers in this module,
32
#include "hw/arm/boot.h"
215
+ * is always 25 MHz.
33
+#include "hw/block/flash.h"
216
+ */
34
#include "hw/boards.h"
217
+#define NPCM7XX_CLOCK_REF_HZ (25000000)
35
+#include "hw/ide/internal.h"
218
+
36
+#include "hw/ide/ahci_internal.h"
219
+/* Register Field Definitions */
37
#include "hw/intc/arm_gicv3_common.h"
220
+#define NPCM7XX_CLK_WDRCR_CA9C BIT(0) /* Cortex A9 Cores */
38
+#include "hw/loader.h"
221
+
39
+#include "hw/pci-host/gpex.h"
222
#define PLLCON_LOKI BIT(31)
40
+#include "hw/usb.h"
223
#define PLLCON_LOKS BIT(30)
41
+#include "net/net.h"
224
#define PLLCON_PWDEN BIT(12)
42
225
+#define PLLCON_FBDV(con) extract32((con), 16, 12)
43
#define RAMLIMIT_GB 8192
226
+#define PLLCON_OTDV2(con) extract32((con), 13, 3)
44
#define RAMLIMIT_BYTES (RAMLIMIT_GB * GiB)
227
+#define PLLCON_OTDV1(con) extract32((con), 8, 3)
45
228
+#define PLLCON_INDV(con) extract32((con), 0, 6)
46
+#define NUM_IRQS 256
229
47
+#define NUM_SMMU_IRQS 4
230
enum NPCM7xxCLKRegisters {
48
+#define NUM_SATA_PORTS 6
231
NPCM7XX_CLK_CLKEN1,
49
+
232
@@ -XXX,XX +XXX,XX @@ static const uint32_t cold_reset_values[NPCM7XX_CLK_NR_REGS] = {
50
+#define VIRTUAL_PMU_IRQ 7
233
[NPCM7XX_CLK_AHBCKFI] = 0x000000c8,
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
};
234
};
71
235
72
+static const int sbsa_ref_irqmap[] = {
236
-/* Register Field Definitions */
73
+ [SBSA_UART] = 1,
237
-#define NPCM7XX_CLK_WDRCR_CA9C BIT(0) /* Cortex A9 Cores */
74
+ [SBSA_RTC] = 2,
238
-
75
+ [SBSA_PCIE] = 3, /* ... to 6 */
239
/* The number of watchdogs that can trigger a reset. */
76
+ [SBSA_GPIO] = 7,
240
#define NPCM7XX_NR_WATCHDOGS (3)
77
+ [SBSA_SECURE_UART] = 8,
241
78
+ [SBSA_SECURE_UART_MM] = 9,
242
+/* Clock converter functions */
79
+ [SBSA_AHCI] = 10,
243
+
80
+ [SBSA_EHCI] = 11,
244
+#define TYPE_NPCM7XX_CLOCK_PLL "npcm7xx-clock-pll"
245
+#define NPCM7XX_CLOCK_PLL(obj) OBJECT_CHECK(NPCM7xxClockPLLState, \
246
+ (obj), TYPE_NPCM7XX_CLOCK_PLL)
247
+#define TYPE_NPCM7XX_CLOCK_SEL "npcm7xx-clock-sel"
248
+#define NPCM7XX_CLOCK_SEL(obj) OBJECT_CHECK(NPCM7xxClockSELState, \
249
+ (obj), TYPE_NPCM7XX_CLOCK_SEL)
250
+#define TYPE_NPCM7XX_CLOCK_DIVIDER "npcm7xx-clock-divider"
251
+#define NPCM7XX_CLOCK_DIVIDER(obj) OBJECT_CHECK(NPCM7xxClockDividerState, \
252
+ (obj), TYPE_NPCM7XX_CLOCK_DIVIDER)
253
+
254
+static void npcm7xx_clk_update_pll(void *opaque)
255
+{
256
+ NPCM7xxClockPLLState *s = opaque;
257
+ uint32_t con = s->clk->regs[s->reg];
258
+ uint64_t freq;
259
+
260
+ /* The PLL is grounded if it is not locked yet. */
261
+ if (con & PLLCON_LOKI) {
262
+ freq = clock_get_hz(s->clock_in);
263
+ freq *= PLLCON_FBDV(con);
264
+ freq /= PLLCON_INDV(con) * PLLCON_OTDV1(con) * PLLCON_OTDV2(con);
265
+ } else {
266
+ freq = 0;
267
+ }
268
+
269
+ clock_update_hz(s->clock_out, freq);
270
+}
271
+
272
+static void npcm7xx_clk_update_sel(void *opaque)
273
+{
274
+ NPCM7xxClockSELState *s = opaque;
275
+ uint32_t index = extract32(s->clk->regs[NPCM7XX_CLK_CLKSEL], s->offset,
276
+ s->len);
277
+
278
+ if (index >= s->input_size) {
279
+ qemu_log_mask(LOG_GUEST_ERROR,
280
+ "%s: SEL index: %u out of range\n",
281
+ __func__, index);
282
+ index = 0;
283
+ }
284
+ clock_update_hz(s->clock_out, clock_get_hz(s->clock_in[index]));
285
+}
286
+
287
+static void npcm7xx_clk_update_divider(void *opaque)
288
+{
289
+ NPCM7xxClockDividerState *s = opaque;
290
+ uint32_t freq;
291
+
292
+ freq = s->divide(s);
293
+ clock_update_hz(s->clock_out, freq);
294
+}
295
+
296
+static uint32_t divide_by_constant(NPCM7xxClockDividerState *s)
297
+{
298
+ return clock_get_hz(s->clock_in) / s->divisor;
299
+}
300
+
301
+static uint32_t divide_by_reg_divisor(NPCM7xxClockDividerState *s)
302
+{
303
+ return clock_get_hz(s->clock_in) /
304
+ (extract32(s->clk->regs[s->reg], s->offset, s->len) + 1);
305
+}
306
+
307
+static uint32_t divide_by_reg_divisor_times_2(NPCM7xxClockDividerState *s)
308
+{
309
+ return divide_by_reg_divisor(s) / 2;
310
+}
311
+
312
+static uint32_t shift_by_reg_divisor(NPCM7xxClockDividerState *s)
313
+{
314
+ return clock_get_hz(s->clock_in) >>
315
+ extract32(s->clk->regs[s->reg], s->offset, s->len);
316
+}
317
+
318
+static NPCM7xxClockPLL find_pll_by_reg(enum NPCM7xxCLKRegisters reg)
319
+{
320
+ switch (reg) {
321
+ case NPCM7XX_CLK_PLLCON0:
322
+ return NPCM7XX_CLOCK_PLL0;
323
+ case NPCM7XX_CLK_PLLCON1:
324
+ return NPCM7XX_CLOCK_PLL1;
325
+ case NPCM7XX_CLK_PLLCON2:
326
+ return NPCM7XX_CLOCK_PLL2;
327
+ case NPCM7XX_CLK_PLLCONG:
328
+ return NPCM7XX_CLOCK_PLLG;
329
+ default:
330
+ g_assert_not_reached();
331
+ }
332
+}
333
+
334
+static void npcm7xx_clk_update_all_plls(NPCM7xxCLKState *clk)
335
+{
336
+ int i;
337
+
338
+ for (i = 0; i < NPCM7XX_CLOCK_NR_PLLS; ++i) {
339
+ npcm7xx_clk_update_pll(&clk->plls[i]);
340
+ }
341
+}
342
+
343
+static void npcm7xx_clk_update_all_sels(NPCM7xxCLKState *clk)
344
+{
345
+ int i;
346
+
347
+ for (i = 0; i < NPCM7XX_CLOCK_NR_SELS; ++i) {
348
+ npcm7xx_clk_update_sel(&clk->sels[i]);
349
+ }
350
+}
351
+
352
+static void npcm7xx_clk_update_all_dividers(NPCM7xxCLKState *clk)
353
+{
354
+ int i;
355
+
356
+ for (i = 0; i < NPCM7XX_CLOCK_NR_DIVIDERS; ++i) {
357
+ npcm7xx_clk_update_divider(&clk->dividers[i]);
358
+ }
359
+}
360
+
361
+static void npcm7xx_clk_update_all_clocks(NPCM7xxCLKState *clk)
362
+{
363
+ clock_update_hz(clk->clkref, NPCM7XX_CLOCK_REF_HZ);
364
+ npcm7xx_clk_update_all_plls(clk);
365
+ npcm7xx_clk_update_all_sels(clk);
366
+ npcm7xx_clk_update_all_dividers(clk);
367
+}
368
+
369
+/* Types of clock sources. */
370
+typedef enum ClockSrcType {
371
+ CLKSRC_REF,
372
+ CLKSRC_PLL,
373
+ CLKSRC_SEL,
374
+ CLKSRC_DIV,
375
+} ClockSrcType;
376
+
377
+typedef struct PLLInitInfo {
378
+ const char *name;
379
+ ClockSrcType src_type;
380
+ int src_index;
381
+ int reg;
382
+ const char *public_name;
383
+} PLLInitInfo;
384
+
385
+typedef struct SELInitInfo {
386
+ const char *name;
387
+ uint8_t input_size;
388
+ ClockSrcType src_type[NPCM7XX_CLK_SEL_MAX_INPUT];
389
+ int src_index[NPCM7XX_CLK_SEL_MAX_INPUT];
390
+ int offset;
391
+ int len;
392
+ const char *public_name;
393
+} SELInitInfo;
394
+
395
+typedef struct DividerInitInfo {
396
+ const char *name;
397
+ ClockSrcType src_type;
398
+ int src_index;
399
+ uint32_t (*divide)(NPCM7xxClockDividerState *s);
400
+ int reg; /* not used when type == CONSTANT */
401
+ int offset; /* not used when type == CONSTANT */
402
+ int len; /* not used when type == CONSTANT */
403
+ int divisor; /* used only when type == CONSTANT */
404
+ const char *public_name;
405
+} DividerInitInfo;
406
+
407
+static const PLLInitInfo pll_init_info_list[] = {
408
+ [NPCM7XX_CLOCK_PLL0] = {
409
+ .name = "pll0",
410
+ .src_type = CLKSRC_REF,
411
+ .reg = NPCM7XX_CLK_PLLCON0,
412
+ },
413
+ [NPCM7XX_CLOCK_PLL1] = {
414
+ .name = "pll1",
415
+ .src_type = CLKSRC_REF,
416
+ .reg = NPCM7XX_CLK_PLLCON1,
417
+ },
418
+ [NPCM7XX_CLOCK_PLL2] = {
419
+ .name = "pll2",
420
+ .src_type = CLKSRC_REF,
421
+ .reg = NPCM7XX_CLK_PLLCON2,
422
+ },
423
+ [NPCM7XX_CLOCK_PLLG] = {
424
+ .name = "pllg",
425
+ .src_type = CLKSRC_REF,
426
+ .reg = NPCM7XX_CLK_PLLCONG,
427
+ },
81
+};
428
+};
82
+
429
+
83
+/*
430
+static const SELInitInfo sel_init_info_list[] = {
84
+ * Firmware on this machine only uses ACPI table to load OS, these limited
431
+ [NPCM7XX_CLOCK_PIXCKSEL] = {
85
+ * device tree nodes are just to let firmware know the info which varies from
432
+ .name = "pixcksel",
86
+ * command line parameters, so it is not necessary to be fully compatible
433
+ .input_size = 2,
87
+ * with the kernel CPU and NUMA binding rules.
434
+ .src_type = {CLKSRC_PLL, CLKSRC_REF},
88
+ */
435
+ .src_index = {NPCM7XX_CLOCK_PLLG, 0},
89
+static void create_fdt(SBSAMachineState *sms)
436
+ .offset = 5,
90
+{
437
+ .len = 1,
91
+ void *fdt = create_device_tree(&sms->fdt_size);
438
+ .public_name = "pixel-clock",
92
+ const MachineState *ms = MACHINE(sms);
439
+ },
93
+ int cpu;
440
+ [NPCM7XX_CLOCK_MCCKSEL] = {
94
+
441
+ .name = "mccksel",
95
+ if (!fdt) {
442
+ .input_size = 4,
96
+ error_report("create_device_tree() failed");
443
+ .src_type = {CLKSRC_DIV, CLKSRC_REF, CLKSRC_REF,
97
+ exit(1);
444
+ /*MCBPCK, shouldn't be used in normal operation*/
98
+ }
445
+ CLKSRC_REF},
99
+
446
+ .src_index = {NPCM7XX_CLOCK_PLL1D2, 0, 0, 0},
100
+ sms->fdt = fdt;
447
+ .offset = 12,
101
+
448
+ .len = 2,
102
+ qemu_fdt_setprop_string(fdt, "/", "compatible", "linux,sbsa-ref");
449
+ .public_name = "mc-phy-clock",
103
+ qemu_fdt_setprop_cell(fdt, "/", "#address-cells", 0x2);
450
+ },
104
+ qemu_fdt_setprop_cell(fdt, "/", "#size-cells", 0x2);
451
+ [NPCM7XX_CLOCK_CPUCKSEL] = {
105
+
452
+ .name = "cpucksel",
106
+ if (have_numa_distance) {
453
+ .input_size = 4,
107
+ int size = nb_numa_nodes * nb_numa_nodes * 3 * sizeof(uint32_t);
454
+ .src_type = {CLKSRC_PLL, CLKSRC_DIV, CLKSRC_REF,
108
+ uint32_t *matrix = g_malloc0(size);
455
+ /*SYSBPCK, shouldn't be used in normal operation*/
109
+ int idx, i, j;
456
+ CLKSRC_REF},
110
+
457
+ .src_index = {NPCM7XX_CLOCK_PLL0, NPCM7XX_CLOCK_PLL1D2, 0, 0},
111
+ for (i = 0; i < nb_numa_nodes; i++) {
458
+ .offset = 0,
112
+ for (j = 0; j < nb_numa_nodes; j++) {
459
+ .len = 2,
113
+ idx = (i * nb_numa_nodes + j) * 3;
460
+ .public_name = "system-clock",
114
+ matrix[idx + 0] = cpu_to_be32(i);
461
+ },
115
+ matrix[idx + 1] = cpu_to_be32(j);
462
+ [NPCM7XX_CLOCK_CLKOUTSEL] = {
116
+ matrix[idx + 2] = cpu_to_be32(numa_info[i].distance[j]);
463
+ .name = "clkoutsel",
117
+ }
464
+ .input_size = 5,
465
+ .src_type = {CLKSRC_PLL, CLKSRC_DIV, CLKSRC_REF,
466
+ CLKSRC_PLL, CLKSRC_DIV},
467
+ .src_index = {NPCM7XX_CLOCK_PLL0, NPCM7XX_CLOCK_PLL1D2, 0,
468
+ NPCM7XX_CLOCK_PLLG, NPCM7XX_CLOCK_PLL2D2},
469
+ .offset = 18,
470
+ .len = 3,
471
+ .public_name = "tock",
472
+ },
473
+ [NPCM7XX_CLOCK_UARTCKSEL] = {
474
+ .name = "uartcksel",
475
+ .input_size = 4,
476
+ .src_type = {CLKSRC_PLL, CLKSRC_DIV, CLKSRC_REF, CLKSRC_DIV},
477
+ .src_index = {NPCM7XX_CLOCK_PLL0, NPCM7XX_CLOCK_PLL1D2, 0,
478
+ NPCM7XX_CLOCK_PLL2D2},
479
+ .offset = 8,
480
+ .len = 2,
481
+ },
482
+ [NPCM7XX_CLOCK_TIMCKSEL] = {
483
+ .name = "timcksel",
484
+ .input_size = 4,
485
+ .src_type = {CLKSRC_PLL, CLKSRC_DIV, CLKSRC_REF, CLKSRC_DIV},
486
+ .src_index = {NPCM7XX_CLOCK_PLL0, NPCM7XX_CLOCK_PLL1D2, 0,
487
+ NPCM7XX_CLOCK_PLL2D2},
488
+ .offset = 14,
489
+ .len = 2,
490
+ },
491
+ [NPCM7XX_CLOCK_SDCKSEL] = {
492
+ .name = "sdcksel",
493
+ .input_size = 4,
494
+ .src_type = {CLKSRC_PLL, CLKSRC_DIV, CLKSRC_REF, CLKSRC_DIV},
495
+ .src_index = {NPCM7XX_CLOCK_PLL0, NPCM7XX_CLOCK_PLL1D2, 0,
496
+ NPCM7XX_CLOCK_PLL2D2},
497
+ .offset = 6,
498
+ .len = 2,
499
+ },
500
+ [NPCM7XX_CLOCK_GFXMSEL] = {
501
+ .name = "gfxmksel",
502
+ .input_size = 2,
503
+ .src_type = {CLKSRC_REF, CLKSRC_PLL},
504
+ .src_index = {0, NPCM7XX_CLOCK_PLL2},
505
+ .offset = 21,
506
+ .len = 1,
507
+ },
508
+ [NPCM7XX_CLOCK_SUCKSEL] = {
509
+ .name = "sucksel",
510
+ .input_size = 4,
511
+ .src_type = {CLKSRC_PLL, CLKSRC_DIV, CLKSRC_REF, CLKSRC_DIV},
512
+ .src_index = {NPCM7XX_CLOCK_PLL0, NPCM7XX_CLOCK_PLL1D2, 0,
513
+ NPCM7XX_CLOCK_PLL2D2},
514
+ .offset = 10,
515
+ .len = 2,
516
+ },
517
+};
518
+
519
+static const DividerInitInfo divider_init_info_list[] = {
520
+ [NPCM7XX_CLOCK_PLL1D2] = {
521
+ .name = "pll1d2",
522
+ .src_type = CLKSRC_PLL,
523
+ .src_index = NPCM7XX_CLOCK_PLL1,
524
+ .divide = divide_by_constant,
525
+ .divisor = 2,
526
+ },
527
+ [NPCM7XX_CLOCK_PLL2D2] = {
528
+ .name = "pll2d2",
529
+ .src_type = CLKSRC_PLL,
530
+ .src_index = NPCM7XX_CLOCK_PLL2,
531
+ .divide = divide_by_constant,
532
+ .divisor = 2,
533
+ },
534
+ [NPCM7XX_CLOCK_MC_DIVIDER] = {
535
+ .name = "mc-divider",
536
+ .src_type = CLKSRC_SEL,
537
+ .src_index = NPCM7XX_CLOCK_MCCKSEL,
538
+ .divide = divide_by_constant,
539
+ .divisor = 2,
540
+ .public_name = "mc-clock"
541
+ },
542
+ [NPCM7XX_CLOCK_AXI_DIVIDER] = {
543
+ .name = "axi-divider",
544
+ .src_type = CLKSRC_SEL,
545
+ .src_index = NPCM7XX_CLOCK_CPUCKSEL,
546
+ .divide = shift_by_reg_divisor,
547
+ .reg = NPCM7XX_CLK_CLKDIV1,
548
+ .offset = 0,
549
+ .len = 1,
550
+ .public_name = "clk2"
551
+ },
552
+ [NPCM7XX_CLOCK_AHB_DIVIDER] = {
553
+ .name = "ahb-divider",
554
+ .src_type = CLKSRC_DIV,
555
+ .src_index = NPCM7XX_CLOCK_AXI_DIVIDER,
556
+ .divide = divide_by_reg_divisor,
557
+ .reg = NPCM7XX_CLK_CLKDIV1,
558
+ .offset = 26,
559
+ .len = 2,
560
+ .public_name = "clk4"
561
+ },
562
+ [NPCM7XX_CLOCK_AHB3_DIVIDER] = {
563
+ .name = "ahb3-divider",
564
+ .src_type = CLKSRC_DIV,
565
+ .src_index = NPCM7XX_CLOCK_AHB_DIVIDER,
566
+ .divide = divide_by_reg_divisor,
567
+ .reg = NPCM7XX_CLK_CLKDIV1,
568
+ .offset = 6,
569
+ .len = 5,
570
+ .public_name = "ahb3-spi3-clock"
571
+ },
572
+ [NPCM7XX_CLOCK_SPI0_DIVIDER] = {
573
+ .name = "spi0-divider",
574
+ .src_type = CLKSRC_DIV,
575
+ .src_index = NPCM7XX_CLOCK_AHB_DIVIDER,
576
+ .divide = divide_by_reg_divisor,
577
+ .reg = NPCM7XX_CLK_CLKDIV3,
578
+ .offset = 6,
579
+ .len = 5,
580
+ .public_name = "spi0-clock",
581
+ },
582
+ [NPCM7XX_CLOCK_SPIX_DIVIDER] = {
583
+ .name = "spix-divider",
584
+ .src_type = CLKSRC_DIV,
585
+ .src_index = NPCM7XX_CLOCK_AHB_DIVIDER,
586
+ .divide = divide_by_reg_divisor,
587
+ .reg = NPCM7XX_CLK_CLKDIV3,
588
+ .offset = 1,
589
+ .len = 5,
590
+ .public_name = "spix-clock",
591
+ },
592
+ [NPCM7XX_CLOCK_APB1_DIVIDER] = {
593
+ .name = "apb1-divider",
594
+ .src_type = CLKSRC_DIV,
595
+ .src_index = NPCM7XX_CLOCK_AHB_DIVIDER,
596
+ .divide = shift_by_reg_divisor,
597
+ .reg = NPCM7XX_CLK_CLKDIV2,
598
+ .offset = 24,
599
+ .len = 2,
600
+ .public_name = "apb1-clock",
601
+ },
602
+ [NPCM7XX_CLOCK_APB2_DIVIDER] = {
603
+ .name = "apb2-divider",
604
+ .src_type = CLKSRC_DIV,
605
+ .src_index = NPCM7XX_CLOCK_AHB_DIVIDER,
606
+ .divide = shift_by_reg_divisor,
607
+ .reg = NPCM7XX_CLK_CLKDIV2,
608
+ .offset = 26,
609
+ .len = 2,
610
+ .public_name = "apb2-clock",
611
+ },
612
+ [NPCM7XX_CLOCK_APB3_DIVIDER] = {
613
+ .name = "apb3-divider",
614
+ .src_type = CLKSRC_DIV,
615
+ .src_index = NPCM7XX_CLOCK_AHB_DIVIDER,
616
+ .divide = shift_by_reg_divisor,
617
+ .reg = NPCM7XX_CLK_CLKDIV2,
618
+ .offset = 28,
619
+ .len = 2,
620
+ .public_name = "apb3-clock",
621
+ },
622
+ [NPCM7XX_CLOCK_APB4_DIVIDER] = {
623
+ .name = "apb4-divider",
624
+ .src_type = CLKSRC_DIV,
625
+ .src_index = NPCM7XX_CLOCK_AHB_DIVIDER,
626
+ .divide = shift_by_reg_divisor,
627
+ .reg = NPCM7XX_CLK_CLKDIV2,
628
+ .offset = 30,
629
+ .len = 2,
630
+ .public_name = "apb4-clock",
631
+ },
632
+ [NPCM7XX_CLOCK_APB5_DIVIDER] = {
633
+ .name = "apb5-divider",
634
+ .src_type = CLKSRC_DIV,
635
+ .src_index = NPCM7XX_CLOCK_AHB_DIVIDER,
636
+ .divide = shift_by_reg_divisor,
637
+ .reg = NPCM7XX_CLK_CLKDIV2,
638
+ .offset = 22,
639
+ .len = 2,
640
+ .public_name = "apb5-clock",
641
+ },
642
+ [NPCM7XX_CLOCK_CLKOUT_DIVIDER] = {
643
+ .name = "clkout-divider",
644
+ .src_type = CLKSRC_SEL,
645
+ .src_index = NPCM7XX_CLOCK_CLKOUTSEL,
646
+ .divide = divide_by_reg_divisor,
647
+ .reg = NPCM7XX_CLK_CLKDIV2,
648
+ .offset = 16,
649
+ .len = 5,
650
+ .public_name = "clkout",
651
+ },
652
+ [NPCM7XX_CLOCK_UART_DIVIDER] = {
653
+ .name = "uart-divider",
654
+ .src_type = CLKSRC_SEL,
655
+ .src_index = NPCM7XX_CLOCK_UARTCKSEL,
656
+ .divide = divide_by_reg_divisor,
657
+ .reg = NPCM7XX_CLK_CLKDIV1,
658
+ .offset = 16,
659
+ .len = 5,
660
+ .public_name = "uart-clock",
661
+ },
662
+ [NPCM7XX_CLOCK_TIMER_DIVIDER] = {
663
+ .name = "timer-divider",
664
+ .src_type = CLKSRC_SEL,
665
+ .src_index = NPCM7XX_CLOCK_TIMCKSEL,
666
+ .divide = divide_by_reg_divisor,
667
+ .reg = NPCM7XX_CLK_CLKDIV1,
668
+ .offset = 21,
669
+ .len = 5,
670
+ .public_name = "timer-clock",
671
+ },
672
+ [NPCM7XX_CLOCK_ADC_DIVIDER] = {
673
+ .name = "adc-divider",
674
+ .src_type = CLKSRC_DIV,
675
+ .src_index = NPCM7XX_CLOCK_TIMER_DIVIDER,
676
+ .divide = shift_by_reg_divisor,
677
+ .reg = NPCM7XX_CLK_CLKDIV1,
678
+ .offset = 28,
679
+ .len = 3,
680
+ .public_name = "adc-clock",
681
+ },
682
+ [NPCM7XX_CLOCK_MMC_DIVIDER] = {
683
+ .name = "mmc-divider",
684
+ .src_type = CLKSRC_SEL,
685
+ .src_index = NPCM7XX_CLOCK_SDCKSEL,
686
+ .divide = divide_by_reg_divisor,
687
+ .reg = NPCM7XX_CLK_CLKDIV1,
688
+ .offset = 11,
689
+ .len = 5,
690
+ .public_name = "mmc-clock",
691
+ },
692
+ [NPCM7XX_CLOCK_SDHC_DIVIDER] = {
693
+ .name = "sdhc-divider",
694
+ .src_type = CLKSRC_SEL,
695
+ .src_index = NPCM7XX_CLOCK_SDCKSEL,
696
+ .divide = divide_by_reg_divisor_times_2,
697
+ .reg = NPCM7XX_CLK_CLKDIV2,
698
+ .offset = 0,
699
+ .len = 4,
700
+ .public_name = "sdhc-clock",
701
+ },
702
+ [NPCM7XX_CLOCK_GFXM_DIVIDER] = {
703
+ .name = "gfxm-divider",
704
+ .src_type = CLKSRC_SEL,
705
+ .src_index = NPCM7XX_CLOCK_GFXMSEL,
706
+ .divide = divide_by_constant,
707
+ .divisor = 3,
708
+ .public_name = "gfxm-clock",
709
+ },
710
+ [NPCM7XX_CLOCK_UTMI_DIVIDER] = {
711
+ .name = "utmi-divider",
712
+ .src_type = CLKSRC_SEL,
713
+ .src_index = NPCM7XX_CLOCK_SUCKSEL,
714
+ .divide = divide_by_reg_divisor,
715
+ .reg = NPCM7XX_CLK_CLKDIV2,
716
+ .offset = 8,
717
+ .len = 5,
718
+ .public_name = "utmi-clock",
719
+ },
720
+};
721
+
722
+static void npcm7xx_clk_pll_init(Object *obj)
723
+{
724
+ NPCM7xxClockPLLState *pll = NPCM7XX_CLOCK_PLL(obj);
725
+
726
+ pll->clock_in = qdev_init_clock_in(DEVICE(pll), "clock-in",
727
+ npcm7xx_clk_update_pll, pll);
728
+ pll->clock_out = qdev_init_clock_out(DEVICE(pll), "clock-out");
729
+}
730
+
731
+static void npcm7xx_clk_sel_init(Object *obj)
732
+{
733
+ int i;
734
+ NPCM7xxClockSELState *sel = NPCM7XX_CLOCK_SEL(obj);
735
+
736
+ for (i = 0; i < NPCM7XX_CLK_SEL_MAX_INPUT; ++i) {
737
+ sel->clock_in[i] = qdev_init_clock_in(DEVICE(sel),
738
+ g_strdup_printf("clock-in[%d]", i),
739
+ npcm7xx_clk_update_sel, sel);
740
+ }
741
+ sel->clock_out = qdev_init_clock_out(DEVICE(sel), "clock-out");
742
+}
743
+static void npcm7xx_clk_divider_init(Object *obj)
744
+{
745
+ NPCM7xxClockDividerState *div = NPCM7XX_CLOCK_DIVIDER(obj);
746
+
747
+ div->clock_in = qdev_init_clock_in(DEVICE(div), "clock-in",
748
+ npcm7xx_clk_update_divider, div);
749
+ div->clock_out = qdev_init_clock_out(DEVICE(div), "clock-out");
750
+}
751
+
752
+static void npcm7xx_init_clock_pll(NPCM7xxClockPLLState *pll,
753
+ NPCM7xxCLKState *clk, const PLLInitInfo *init_info)
754
+{
755
+ pll->name = init_info->name;
756
+ pll->clk = clk;
757
+ pll->reg = init_info->reg;
758
+ if (init_info->public_name != NULL) {
759
+ qdev_alias_clock(DEVICE(pll), "clock-out", DEVICE(clk),
760
+ init_info->public_name);
761
+ }
762
+}
763
+
764
+static void npcm7xx_init_clock_sel(NPCM7xxClockSELState *sel,
765
+ NPCM7xxCLKState *clk, const SELInitInfo *init_info)
766
+{
767
+ int input_size = init_info->input_size;
768
+
769
+ sel->name = init_info->name;
770
+ sel->clk = clk;
771
+ sel->input_size = init_info->input_size;
772
+ g_assert(input_size <= NPCM7XX_CLK_SEL_MAX_INPUT);
773
+ sel->offset = init_info->offset;
774
+ sel->len = init_info->len;
775
+ if (init_info->public_name != NULL) {
776
+ qdev_alias_clock(DEVICE(sel), "clock-out", DEVICE(clk),
777
+ init_info->public_name);
778
+ }
779
+}
780
+
781
+static void npcm7xx_init_clock_divider(NPCM7xxClockDividerState *div,
782
+ NPCM7xxCLKState *clk, const DividerInitInfo *init_info)
783
+{
784
+ div->name = init_info->name;
785
+ div->clk = clk;
786
+
787
+ div->divide = init_info->divide;
788
+ if (div->divide == divide_by_constant) {
789
+ div->divisor = init_info->divisor;
790
+ } else {
791
+ div->reg = init_info->reg;
792
+ div->offset = init_info->offset;
793
+ div->len = init_info->len;
794
+ }
795
+ if (init_info->public_name != NULL) {
796
+ qdev_alias_clock(DEVICE(div), "clock-out", DEVICE(clk),
797
+ init_info->public_name);
798
+ }
799
+}
800
+
801
+static Clock *npcm7xx_get_clock(NPCM7xxCLKState *clk, ClockSrcType type,
802
+ int index)
803
+{
804
+ switch (type) {
805
+ case CLKSRC_REF:
806
+ return clk->clkref;
807
+ case CLKSRC_PLL:
808
+ return clk->plls[index].clock_out;
809
+ case CLKSRC_SEL:
810
+ return clk->sels[index].clock_out;
811
+ case CLKSRC_DIV:
812
+ return clk->dividers[index].clock_out;
813
+ default:
814
+ g_assert_not_reached();
815
+ }
816
+}
817
+
818
+static void npcm7xx_connect_clocks(NPCM7xxCLKState *clk)
819
+{
820
+ int i, j;
821
+ Clock *src;
822
+
823
+ for (i = 0; i < NPCM7XX_CLOCK_NR_PLLS; ++i) {
824
+ src = npcm7xx_get_clock(clk, pll_init_info_list[i].src_type,
825
+ pll_init_info_list[i].src_index);
826
+ clock_set_source(clk->plls[i].clock_in, src);
827
+ }
828
+ for (i = 0; i < NPCM7XX_CLOCK_NR_SELS; ++i) {
829
+ for (j = 0; j < sel_init_info_list[i].input_size; ++j) {
830
+ src = npcm7xx_get_clock(clk, sel_init_info_list[i].src_type[j],
831
+ sel_init_info_list[i].src_index[j]);
832
+ clock_set_source(clk->sels[i].clock_in[j], src);
118
+ }
833
+ }
119
+
834
+ }
120
+ qemu_fdt_add_subnode(fdt, "/distance-map");
835
+ for (i = 0; i < NPCM7XX_CLOCK_NR_DIVIDERS; ++i) {
121
+ qemu_fdt_setprop(fdt, "/distance-map", "distance-matrix",
836
+ src = npcm7xx_get_clock(clk, divider_init_info_list[i].src_type,
122
+ matrix, size);
837
+ divider_init_info_list[i].src_index);
123
+ g_free(matrix);
838
+ clock_set_source(clk->dividers[i].clock_in, src);
124
+ }
839
+ }
125
+
840
+}
126
+ qemu_fdt_add_subnode(sms->fdt, "/cpus");
841
+
127
+
842
static uint64_t npcm7xx_clk_read(void *opaque, hwaddr offset, unsigned size)
128
+ for (cpu = sms->smp_cpus - 1; cpu >= 0; cpu--) {
843
{
129
+ char *nodename = g_strdup_printf("/cpus/cpu@%d", cpu);
844
uint32_t reg = offset / sizeof(uint32_t);
130
+ ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu));
845
@@ -XXX,XX +XXX,XX @@ static uint64_t npcm7xx_clk_read(void *opaque, hwaddr offset, unsigned size)
131
+ CPUState *cs = CPU(armcpu);
846
*
132
+
847
* The 4 LSBs are always zero: (1e9 / 640) << 4 = 25000000.
133
+ qemu_fdt_add_subnode(sms->fdt, nodename);
848
*/
134
+
849
- value = (((now_ns - s->ref_ns) / 640) << 4) % NPCM7XX_TIMER_REF_HZ;
135
+ if (ms->possible_cpus->cpus[cs->cpu_index].props.has_node_id) {
850
+ value = (((now_ns - s->ref_ns) / 640) << 4) % NPCM7XX_CLOCK_REF_HZ;
136
+ qemu_fdt_setprop_cell(sms->fdt, nodename, "numa-node-id",
851
break;
137
+ ms->possible_cpus->cpus[cs->cpu_index].props.node_id);
852
853
default:
854
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_clk_write(void *opaque, hwaddr offset,
855
value |= (value & PLLCON_LOKS);
856
}
857
}
858
+ /* Only update PLL when it is locked. */
859
+ if (value & PLLCON_LOKI) {
860
+ npcm7xx_clk_update_pll(&s->plls[find_pll_by_reg(reg)]);
138
+ }
861
+ }
139
+
862
+ break;
140
+ g_free(nodename);
863
+
141
+ }
864
+ case NPCM7XX_CLK_CLKSEL:
142
+}
865
+ npcm7xx_clk_update_all_sels(s);
143
+
866
+ break;
144
+#define SBSA_FLASH_SECTOR_SIZE (256 * KiB)
867
+
145
+
868
+ case NPCM7XX_CLK_CLKDIV1:
146
+static PFlashCFI01 *sbsa_flash_create1(SBSAMachineState *sms,
869
+ case NPCM7XX_CLK_CLKDIV2:
147
+ const char *name,
870
+ case NPCM7XX_CLK_CLKDIV3:
148
+ const char *alias_prop_name)
871
+ npcm7xx_clk_update_all_dividers(s);
149
+{
872
break;
150
+ /*
873
151
+ * Create a single flash device. We use the same parameters as
874
case NPCM7XX_CLK_CNTR25M:
152
+ * the flash devices on the Versatile Express board.
875
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_clk_enter_reset(Object *obj, ResetType type)
153
+ */
876
case RESET_TYPE_COLD:
154
+ DeviceState *dev = qdev_create(NULL, TYPE_PFLASH_CFI01);
877
memcpy(s->regs, cold_reset_values, sizeof(cold_reset_values));
155
+
878
s->ref_ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
156
+ qdev_prop_set_uint64(dev, "sector-length", SBSA_FLASH_SECTOR_SIZE);
879
+ npcm7xx_clk_update_all_clocks(s);
157
+ qdev_prop_set_uint8(dev, "width", 4);
880
return;
158
+ qdev_prop_set_uint8(dev, "device-width", 2);
881
}
159
+ qdev_prop_set_bit(dev, "big-endian", false);
882
160
+ qdev_prop_set_uint16(dev, "id0", 0x89);
883
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_clk_enter_reset(Object *obj, ResetType type)
161
+ qdev_prop_set_uint16(dev, "id1", 0x18);
884
__func__, type);
162
+ qdev_prop_set_uint16(dev, "id2", 0x00);
885
}
163
+ qdev_prop_set_uint16(dev, "id3", 0x00);
886
164
+ qdev_prop_set_string(dev, "name", name);
887
+static void npcm7xx_clk_init_clock_hierarchy(NPCM7xxCLKState *s)
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
+{
888
+{
219
+ int i;
889
+ int i;
220
+ BlockBackend *pflash_blk0;
890
+
221
+
891
+ s->clkref = qdev_init_clock_in(DEVICE(s), "clkref", NULL, NULL);
222
+ /* Map legacy -drive if=pflash to machine properties */
892
+
223
+ for (i = 0; i < ARRAY_SIZE(sms->flash); i++) {
893
+ /* First pass: init all converter modules */
224
+ pflash_cfi01_legacy_drive(sms->flash[i],
894
+ QEMU_BUILD_BUG_ON(ARRAY_SIZE(pll_init_info_list) != NPCM7XX_CLOCK_NR_PLLS);
225
+ drive_get(IF_PFLASH, 0, i));
895
+ QEMU_BUILD_BUG_ON(ARRAY_SIZE(sel_init_info_list) != NPCM7XX_CLOCK_NR_SELS);
226
+ }
896
+ QEMU_BUILD_BUG_ON(ARRAY_SIZE(divider_init_info_list)
227
+
897
+ != NPCM7XX_CLOCK_NR_DIVIDERS);
228
+ sbsa_flash_map(sms, sysmem, secure_sysmem);
898
+ for (i = 0; i < NPCM7XX_CLOCK_NR_PLLS; ++i) {
229
+
899
+ object_initialize_child(OBJECT(s), pll_init_info_list[i].name,
230
+ pflash_blk0 = pflash_cfi01_get_blk(sms->flash[0]);
900
+ &s->plls[i], TYPE_NPCM7XX_CLOCK_PLL);
231
+
901
+ npcm7xx_init_clock_pll(&s->plls[i], s,
232
+ if (bios_name) {
902
+ &pll_init_info_list[i]);
233
+ char *fname;
903
+ }
234
+ MemoryRegion *mr;
904
+ for (i = 0; i < NPCM7XX_CLOCK_NR_SELS; ++i) {
235
+ int image_size;
905
+ object_initialize_child(OBJECT(s), sel_init_info_list[i].name,
236
+
906
+ &s->sels[i], TYPE_NPCM7XX_CLOCK_SEL);
237
+ if (pflash_blk0) {
907
+ npcm7xx_init_clock_sel(&s->sels[i], s,
238
+ error_report("The contents of the first flash device may be "
908
+ &sel_init_info_list[i]);
239
+ "specified with -bios or with -drive if=pflash... "
909
+ }
240
+ "but you cannot use both options at once");
910
+ for (i = 0; i < NPCM7XX_CLOCK_NR_DIVIDERS; ++i) {
241
+ exit(1);
911
+ object_initialize_child(OBJECT(s), divider_init_info_list[i].name,
912
+ &s->dividers[i], TYPE_NPCM7XX_CLOCK_DIVIDER);
913
+ npcm7xx_init_clock_divider(&s->dividers[i], s,
914
+ &divider_init_info_list[i]);
915
+ }
916
+
917
+ /* Second pass: connect converter modules */
918
+ npcm7xx_connect_clocks(s);
919
+
920
+ clock_update_hz(s->clkref, NPCM7XX_CLOCK_REF_HZ);
921
+}
922
+
923
static void npcm7xx_clk_init(Object *obj)
924
{
925
NPCM7xxCLKState *s = NPCM7XX_CLK(obj);
926
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_clk_init(Object *obj)
927
memory_region_init_io(&s->iomem, obj, &npcm7xx_clk_ops, s,
928
TYPE_NPCM7XX_CLK, 4 * KiB);
929
sysbus_init_mmio(&s->parent, &s->iomem);
930
- qdev_init_gpio_in_named(DEVICE(s), npcm7xx_clk_perform_watchdog_reset,
931
- NPCM7XX_WATCHDOG_RESET_GPIO_IN, NPCM7XX_NR_WATCHDOGS);
932
}
933
934
-static const VMStateDescription vmstate_npcm7xx_clk = {
935
- .name = "npcm7xx-clk",
936
+static int npcm7xx_clk_post_load(void *opaque, int version_id)
937
+{
938
+ if (version_id >= 1) {
939
+ NPCM7xxCLKState *clk = opaque;
940
+
941
+ npcm7xx_clk_update_all_clocks(clk);
942
+ }
943
+
944
+ return 0;
945
+}
946
+
947
+static void npcm7xx_clk_realize(DeviceState *dev, Error **errp)
948
+{
949
+ int i;
950
+ NPCM7xxCLKState *s = NPCM7XX_CLK(dev);
951
+
952
+ qdev_init_gpio_in_named(DEVICE(s), npcm7xx_clk_perform_watchdog_reset,
953
+ NPCM7XX_WATCHDOG_RESET_GPIO_IN, NPCM7XX_NR_WATCHDOGS);
954
+ npcm7xx_clk_init_clock_hierarchy(s);
955
+
956
+ /* Realize child devices */
957
+ for (i = 0; i < NPCM7XX_CLOCK_NR_PLLS; ++i) {
958
+ if (!qdev_realize(DEVICE(&s->plls[i]), NULL, errp)) {
959
+ return;
242
+ }
960
+ }
243
+
961
+ }
244
+ /* Fall back to -bios */
962
+ for (i = 0; i < NPCM7XX_CLOCK_NR_SELS; ++i) {
245
+
963
+ if (!qdev_realize(DEVICE(&s->sels[i]), NULL, errp)) {
246
+ fname = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
964
+ return;
247
+ if (!fname) {
248
+ error_report("Could not find ROM image '%s'", bios_name);
249
+ exit(1);
250
+ }
965
+ }
251
+ mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(sms->flash[0]), 0);
966
+ }
252
+ image_size = load_image_mr(fname, mr);
967
+ for (i = 0; i < NPCM7XX_CLOCK_NR_DIVIDERS; ++i) {
253
+ g_free(fname);
968
+ if (!qdev_realize(DEVICE(&s->dividers[i]), NULL, errp)) {
254
+ if (image_size < 0) {
969
+ return;
255
+ error_report("Could not load ROM image '%s'", bios_name);
256
+ exit(1);
257
+ }
970
+ }
258
+ }
971
+ }
259
+
972
+}
260
+ return pflash_blk0 || bios_name;
973
+
261
+}
974
+static const VMStateDescription vmstate_npcm7xx_clk_pll = {
262
+
975
+ .name = "npcm7xx-clock-pll",
263
+static void create_secure_ram(SBSAMachineState *sms,
976
.version_id = 0,
264
+ MemoryRegion *secure_sysmem)
977
.minimum_version_id = 0,
265
+{
978
- .fields = (VMStateField[]) {
266
+ MemoryRegion *secram = g_new(MemoryRegion, 1);
979
- VMSTATE_UINT32_ARRAY(regs, NPCM7xxCLKState, NPCM7XX_CLK_NR_REGS),
267
+ hwaddr base = sbsa_ref_memmap[SBSA_SECURE_MEM].base;
980
- VMSTATE_INT64(ref_ns, NPCM7xxCLKState),
268
+ hwaddr size = sbsa_ref_memmap[SBSA_SECURE_MEM].size;
981
+ .fields = (VMStateField[]) {
269
+
982
+ VMSTATE_CLOCK(clock_in, NPCM7xxClockPLLState),
270
+ memory_region_init_ram(secram, NULL, "sbsa-ref.secure-ram", size,
983
VMSTATE_END_OF_LIST(),
271
+ &error_fatal);
984
},
272
+ memory_region_add_subregion(secure_sysmem, base, secram);
985
};
273
+}
986
274
+
987
+static const VMStateDescription vmstate_npcm7xx_clk_sel = {
275
+static void create_gic(SBSAMachineState *sms, qemu_irq *pic)
988
+ .name = "npcm7xx-clock-sel",
276
+{
989
+ .version_id = 0,
277
+ DeviceState *gicdev;
990
+ .minimum_version_id = 0,
278
+ SysBusDevice *gicbusdev;
991
+ .fields = (VMStateField[]) {
279
+ const char *gictype;
992
+ VMSTATE_ARRAY_OF_POINTER_TO_STRUCT(clock_in, NPCM7xxClockSELState,
280
+ uint32_t redist0_capacity, redist0_count;
993
+ NPCM7XX_CLK_SEL_MAX_INPUT, 0, vmstate_clock, Clock),
281
+ int i;
994
+ VMSTATE_END_OF_LIST(),
282
+
995
+ },
283
+ gictype = gicv3_class_name();
284
+
285
+ gicdev = qdev_create(NULL, gictype);
286
+ qdev_prop_set_uint32(gicdev, "revision", 3);
287
+ qdev_prop_set_uint32(gicdev, "num-cpu", smp_cpus);
288
+ /*
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
+ }
352
+}
353
+
354
+static void create_uart(const SBSAMachineState *sms, qemu_irq *pic, int uart,
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
+};
996
+};
387
+
997
+
388
+static void create_gpio(const SBSAMachineState *sms, qemu_irq *pic)
998
+static const VMStateDescription vmstate_npcm7xx_clk_divider = {
389
+{
999
+ .name = "npcm7xx-clock-divider",
390
+ DeviceState *pl061_dev;
1000
+ .version_id = 0,
391
+ hwaddr base = sbsa_ref_memmap[SBSA_GPIO].base;
1001
+ .minimum_version_id = 0,
392
+ int irq = sbsa_ref_irqmap[SBSA_GPIO];
1002
+ .fields = (VMStateField[]) {
393
+
1003
+ VMSTATE_CLOCK(clock_in, NPCM7xxClockDividerState),
394
+ pl061_dev = sysbus_create_simple("pl061", base, pic[irq]);
1004
+ VMSTATE_END_OF_LIST(),
395
+
1005
+ },
396
+ gpio_key_dev = sysbus_create_simple("gpio-key", -1,
1006
+};
397
+ qdev_get_gpio_in(pl061_dev, 3));
1007
+
398
+
1008
+static const VMStateDescription vmstate_npcm7xx_clk = {
399
+ /* connect powerdown request */
1009
+ .name = "npcm7xx-clk",
400
+ qemu_register_powerdown_notifier(&sbsa_ref_powerdown_notifier);
1010
+ .version_id = 1,
401
+}
1011
+ .minimum_version_id = 1,
402
+
1012
+ .post_load = npcm7xx_clk_post_load,
403
+static void create_ahci(const SBSAMachineState *sms, qemu_irq *pic)
1013
+ .fields = (VMStateField[]) {
404
+{
1014
+ VMSTATE_UINT32_ARRAY(regs, NPCM7xxCLKState, NPCM7XX_CLK_NR_REGS),
405
+ hwaddr base = sbsa_ref_memmap[SBSA_AHCI].base;
1015
+ VMSTATE_INT64(ref_ns, NPCM7xxCLKState),
406
+ int irq = sbsa_ref_irqmap[SBSA_AHCI];
1016
+ VMSTATE_CLOCK(clkref, NPCM7xxCLKState),
407
+ DeviceState *dev;
1017
+ VMSTATE_END_OF_LIST(),
408
+ DriveInfo *hd[NUM_SATA_PORTS];
1018
+ },
409
+ SysbusAHCIState *sysahci;
1019
+};
410
+ AHCIState *ahci;
1020
+
411
+ int i;
1021
+static void npcm7xx_clk_pll_class_init(ObjectClass *klass, void *data)
412
+
1022
+{
413
+ dev = qdev_create(NULL, "sysbus-ahci");
1023
+ DeviceClass *dc = DEVICE_CLASS(klass);
414
+ qdev_prop_set_uint32(dev, "num-ports", NUM_SATA_PORTS);
1024
+
415
+ qdev_init_nofail(dev);
1025
+ dc->desc = "NPCM7xx Clock PLL Module";
416
+ sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
1026
+ dc->vmsd = &vmstate_npcm7xx_clk_pll;
417
+ sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[irq]);
1027
+}
418
+
1028
+
419
+ sysahci = SYSBUS_AHCI(dev);
1029
+static void npcm7xx_clk_sel_class_init(ObjectClass *klass, void *data)
420
+ ahci = &sysahci->ahci;
1030
+{
421
+ ide_drive_get(hd, ARRAY_SIZE(hd));
1031
+ DeviceClass *dc = DEVICE_CLASS(klass);
422
+ for (i = 0; i < ahci->ports; i++) {
1032
+
423
+ if (hd[i] == NULL) {
1033
+ dc->desc = "NPCM7xx Clock SEL Module";
424
+ continue;
1034
+ dc->vmsd = &vmstate_npcm7xx_clk_sel;
425
+ }
1035
+}
426
+ ide_create_drive(&ahci->dev[i].port, 0, hd[i]);
1036
+
427
+ }
1037
+static void npcm7xx_clk_divider_class_init(ObjectClass *klass, void *data)
428
+}
1038
+{
429
+
1039
+ DeviceClass *dc = DEVICE_CLASS(klass);
430
+static void create_ehci(const SBSAMachineState *sms, qemu_irq *pic)
1040
+
431
+{
1041
+ dc->desc = "NPCM7xx Clock Divider Module";
432
+ hwaddr base = sbsa_ref_memmap[SBSA_EHCI].base;
1042
+ dc->vmsd = &vmstate_npcm7xx_clk_divider;
433
+ int irq = sbsa_ref_irqmap[SBSA_EHCI];
1043
+}
434
+
1044
+
435
+ sysbus_create_simple("platform-ehci-usb", base, pic[irq]);
1045
static void npcm7xx_clk_class_init(ObjectClass *klass, void *data)
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
{
1046
{
534
SBSAMachineState *sms = SBSA_MACHINE(machine);
1047
ResettableClass *rc = RESETTABLE_CLASS(klass);
535
@@ -XXX,XX +XXX,XX @@ static void sbsa_ref_init(MachineState *machine)
1048
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_clk_class_init(ObjectClass *klass, void *data)
536
MemoryRegion *sysmem = get_system_memory();
1049
537
MemoryRegion *secure_sysmem = NULL;
1050
dc->desc = "NPCM7xx Clock Control Registers";
538
MemoryRegion *ram = g_new(MemoryRegion, 1);
1051
dc->vmsd = &vmstate_npcm7xx_clk;
539
+ bool firmware_loaded;
1052
+ dc->realize = npcm7xx_clk_realize;
540
const CPUArchIdList *possible_cpus;
1053
rc->phases.enter = npcm7xx_clk_enter_reset;
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
}
549
550
+ /*
551
+ * The Secure view of the world is the same as the NonSecure,
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
}
1054
}
608
1055
609
@@ -XXX,XX +XXX,XX @@ sbsa_ref_get_default_cpu_node_id(const MachineState *ms, int idx)
1056
+static const TypeInfo npcm7xx_clk_pll_info = {
610
return idx % nb_numa_nodes;
1057
+ .name = TYPE_NPCM7XX_CLOCK_PLL,
1058
+ .parent = TYPE_DEVICE,
1059
+ .instance_size = sizeof(NPCM7xxClockPLLState),
1060
+ .instance_init = npcm7xx_clk_pll_init,
1061
+ .class_init = npcm7xx_clk_pll_class_init,
1062
+};
1063
+
1064
+static const TypeInfo npcm7xx_clk_sel_info = {
1065
+ .name = TYPE_NPCM7XX_CLOCK_SEL,
1066
+ .parent = TYPE_DEVICE,
1067
+ .instance_size = sizeof(NPCM7xxClockSELState),
1068
+ .instance_init = npcm7xx_clk_sel_init,
1069
+ .class_init = npcm7xx_clk_sel_class_init,
1070
+};
1071
+
1072
+static const TypeInfo npcm7xx_clk_divider_info = {
1073
+ .name = TYPE_NPCM7XX_CLOCK_DIVIDER,
1074
+ .parent = TYPE_DEVICE,
1075
+ .instance_size = sizeof(NPCM7xxClockDividerState),
1076
+ .instance_init = npcm7xx_clk_divider_init,
1077
+ .class_init = npcm7xx_clk_divider_class_init,
1078
+};
1079
+
1080
static const TypeInfo npcm7xx_clk_info = {
1081
.name = TYPE_NPCM7XX_CLK,
1082
.parent = TYPE_SYS_BUS_DEVICE,
1083
@@ -XXX,XX +XXX,XX @@ static const TypeInfo npcm7xx_clk_info = {
1084
1085
static void npcm7xx_clk_register_type(void)
1086
{
1087
+ type_register_static(&npcm7xx_clk_pll_info);
1088
+ type_register_static(&npcm7xx_clk_sel_info);
1089
+ type_register_static(&npcm7xx_clk_divider_info);
1090
type_register_static(&npcm7xx_clk_info);
611
}
1091
}
612
1092
type_init(npcm7xx_clk_register_type);
613
+static void sbsa_ref_instance_init(Object *obj)
614
+{
615
+ SBSAMachineState *sms = SBSA_MACHINE(obj);
616
+
617
+ sbsa_flash_create(sms);
618
+}
619
+
620
static void sbsa_ref_class_init(ObjectClass *oc, void *data)
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
--
1093
--
632
2.20.1
1094
2.20.1
633
1095
634
1096
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Hao Wu <wuhaotsh@google.com>
2
2
3
In the next commit we will split the M-profile functions from this
3
This patch makes NPCM7XX Timer to use a the timer clock generated by the
4
file. Some function will be called out of helper.c. Declare them in
4
CLK module instead of the magic number TIMER_REF_HZ.
5
the "internals.h" header.
6
5
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Reviewed-by: Havard Skinnemoen <hskinnemoen@google.com>
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Reviewed-by: Tyrone Ting <kfting@nuvoton.com>
9
Message-id: 20190701132516.26392-22-philmd@redhat.com
8
Signed-off-by: Hao Wu <wuhaotsh@google.com>
9
Message-id: 20210108190945.949196-3-wuhaotsh@google.com
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
---
12
target/arm/internals.h | 42 ++++++++++++++++++++++++++++++++++++++++++
13
include/hw/misc/npcm7xx_clk.h | 6 -----
13
target/arm/helper.c | 38 ++------------------------------------
14
include/hw/timer/npcm7xx_timer.h | 1 +
14
2 files changed, 44 insertions(+), 36 deletions(-)
15
hw/arm/npcm7xx.c | 5 ++++
16
hw/timer/npcm7xx_timer.c | 39 +++++++++++++++-----------------
17
4 files changed, 24 insertions(+), 27 deletions(-)
15
18
16
diff --git a/target/arm/internals.h b/target/arm/internals.h
19
diff --git a/include/hw/misc/npcm7xx_clk.h b/include/hw/misc/npcm7xx_clk.h
17
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/internals.h
21
--- a/include/hw/misc/npcm7xx_clk.h
19
+++ b/target/arm/internals.h
22
+++ b/include/hw/misc/npcm7xx_clk.h
20
@@ -XXX,XX +XXX,XX @@ static inline uint32_t v7m_sp_limit(CPUARMState *env)
23
@@ -XXX,XX +XXX,XX @@
21
}
24
#include "hw/clock.h"
22
}
25
#include "hw/sysbus.h"
23
24
+/**
25
+ * v7m_cpacr_pass:
26
+ * Return true if the v7M CPACR permits access to the FPU for the specified
27
+ * security state and privilege level.
28
+ */
29
+static inline bool v7m_cpacr_pass(CPUARMState *env,
30
+ bool is_secure, bool is_priv)
31
+{
32
+ switch (extract32(env->v7m.cpacr[is_secure], 20, 2)) {
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
+}
44
+
45
/**
46
* aarch32_mode_name(): Return name of the AArch32 CPU mode
47
* @psr: Program Status Register indicating CPU mode
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
26
106
-/*
27
-/*
107
- * Return true if the v7M CPACR permits access to the FPU for the specified
28
- * The reference clock frequency for the timer modules, and the SECCNT and
108
- * security state and privilege level.
29
- * CNTR25M registers in this module, is always 25 MHz.
109
- */
30
- */
110
-static bool v7m_cpacr_pass(CPUARMState *env, bool is_secure, bool is_priv)
31
-#define NPCM7XX_TIMER_REF_HZ (25000000)
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
-
32
-
125
/*
33
/*
126
* What kind of stack write are we doing? This affects how exceptions
34
* Number of registers in our device state structure. Don't change this without
127
* generated during the stacking are treated.
35
* incrementing the version_id in the vmstate.
128
@@ -XXX,XX +XXX,XX @@ static bool v8m_is_sau_exempt(CPUARMState *env,
36
diff --git a/include/hw/timer/npcm7xx_timer.h b/include/hw/timer/npcm7xx_timer.h
129
(address >= 0xe00ff000 && address <= 0xe00fffff);
37
index XXXXXXX..XXXXXXX 100644
38
--- a/include/hw/timer/npcm7xx_timer.h
39
+++ b/include/hw/timer/npcm7xx_timer.h
40
@@ -XXX,XX +XXX,XX @@ struct NPCM7xxTimerCtrlState {
41
42
uint32_t tisr;
43
44
+ Clock *clock;
45
NPCM7xxTimer timer[NPCM7XX_TIMERS_PER_CTRL];
46
NPCM7xxWatchdogTimer watchdog_timer;
47
};
48
diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c
49
index XXXXXXX..XXXXXXX 100644
50
--- a/hw/arm/npcm7xx.c
51
+++ b/hw/arm/npcm7xx.c
52
@@ -XXX,XX +XXX,XX @@
53
#include "hw/char/serial.h"
54
#include "hw/loader.h"
55
#include "hw/misc/unimp.h"
56
+#include "hw/qdev-clock.h"
57
#include "hw/qdev-properties.h"
58
#include "qapi/error.h"
59
#include "qemu/units.h"
60
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)
61
int first_irq;
62
int j;
63
64
+ /* Connect the timer clock. */
65
+ qdev_connect_clock_in(DEVICE(&s->tim[i]), "clock", qdev_get_clock_out(
66
+ DEVICE(&s->clk), "timer-clock"));
67
+
68
sysbus_realize(sbd, &error_abort);
69
sysbus_mmio_map(sbd, 0, npcm7xx_tim_addr[i]);
70
71
diff --git a/hw/timer/npcm7xx_timer.c b/hw/timer/npcm7xx_timer.c
72
index XXXXXXX..XXXXXXX 100644
73
--- a/hw/timer/npcm7xx_timer.c
74
+++ b/hw/timer/npcm7xx_timer.c
75
@@ -XXX,XX +XXX,XX @@
76
#include "qemu/osdep.h"
77
78
#include "hw/irq.h"
79
+#include "hw/qdev-clock.h"
80
#include "hw/qdev-properties.h"
81
-#include "hw/misc/npcm7xx_clk.h"
82
#include "hw/timer/npcm7xx_timer.h"
83
#include "migration/vmstate.h"
84
#include "qemu/bitops.h"
85
@@ -XXX,XX +XXX,XX @@ static uint32_t npcm7xx_tcsr_prescaler(uint32_t tcsr)
86
/* Convert a timer cycle count to a time interval in nanoseconds. */
87
static int64_t npcm7xx_timer_count_to_ns(NPCM7xxTimer *t, uint32_t count)
88
{
89
- int64_t ns = count;
90
+ int64_t ticks = count;
91
92
- ns *= NANOSECONDS_PER_SECOND / NPCM7XX_TIMER_REF_HZ;
93
- ns *= npcm7xx_tcsr_prescaler(t->tcsr);
94
+ ticks *= npcm7xx_tcsr_prescaler(t->tcsr);
95
96
- return ns;
97
+ return clock_ticks_to_ns(t->ctrl->clock, ticks);
130
}
98
}
131
99
132
-static void v8m_security_lookup(CPUARMState *env, uint32_t address,
100
/* Convert a time interval in nanoseconds to a timer cycle count. */
133
+void v8m_security_lookup(CPUARMState *env, uint32_t address,
101
static uint32_t npcm7xx_timer_ns_to_count(NPCM7xxTimer *t, int64_t ns)
134
MMUAccessType access_type, ARMMMUIdx mmu_idx,
135
V8M_SAttributes *sattrs)
136
{
102
{
137
@@ -XXX,XX +XXX,XX @@ static void v8m_security_lookup(CPUARMState *env, uint32_t address,
103
- int64_t count;
138
}
104
-
105
- count = ns / (NANOSECONDS_PER_SECOND / NPCM7XX_TIMER_REF_HZ);
106
- count /= npcm7xx_tcsr_prescaler(t->tcsr);
107
-
108
- return count;
109
+ return ns / clock_ticks_to_ns(t->ctrl->clock,
110
+ npcm7xx_tcsr_prescaler(t->tcsr));
139
}
111
}
140
112
141
-static bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
113
static uint32_t npcm7xx_watchdog_timer_prescaler(const NPCM7xxWatchdogTimer *t)
142
+bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
114
@@ -XXX,XX +XXX,XX @@ static uint32_t npcm7xx_watchdog_timer_prescaler(const NPCM7xxWatchdogTimer *t)
143
MMUAccessType access_type, ARMMMUIdx mmu_idx,
115
static void npcm7xx_watchdog_timer_reset_cycles(NPCM7xxWatchdogTimer *t,
144
hwaddr *phys_ptr, MemTxAttrs *txattrs,
116
int64_t cycles)
145
int *prot, bool *is_subpage,
117
{
118
- uint32_t prescaler = npcm7xx_watchdog_timer_prescaler(t);
119
- int64_t ns = (NANOSECONDS_PER_SECOND / NPCM7XX_TIMER_REF_HZ) * cycles;
120
+ int64_t ticks = cycles * npcm7xx_watchdog_timer_prescaler(t);
121
+ int64_t ns = clock_ticks_to_ns(t->ctrl->clock, ticks);
122
123
/*
124
* The reset function always clears the current timer. The caller of the
125
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_watchdog_timer_reset_cycles(NPCM7xxWatchdogTimer *t,
126
*/
127
npcm7xx_timer_clear(&t->base_timer);
128
129
- ns *= prescaler;
130
t->base_timer.remaining_ns = ns;
131
}
132
133
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_timer_hold_reset(Object *obj)
134
qemu_irq_lower(s->watchdog_timer.irq);
135
}
136
137
-static void npcm7xx_timer_realize(DeviceState *dev, Error **errp)
138
+static void npcm7xx_timer_init(Object *obj)
139
{
140
- NPCM7xxTimerCtrlState *s = NPCM7XX_TIMER(dev);
141
- SysBusDevice *sbd = &s->parent;
142
+ NPCM7xxTimerCtrlState *s = NPCM7XX_TIMER(obj);
143
+ DeviceState *dev = DEVICE(obj);
144
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
145
int i;
146
NPCM7xxWatchdogTimer *w;
147
148
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_timer_realize(DeviceState *dev, Error **errp)
149
npcm7xx_watchdog_timer_expired, w);
150
sysbus_init_irq(sbd, &w->irq);
151
152
- memory_region_init_io(&s->iomem, OBJECT(s), &npcm7xx_timer_ops, s,
153
+ memory_region_init_io(&s->iomem, obj, &npcm7xx_timer_ops, s,
154
TYPE_NPCM7XX_TIMER, 4 * KiB);
155
sysbus_init_mmio(sbd, &s->iomem);
156
qdev_init_gpio_out_named(dev, &w->reset_signal,
157
NPCM7XX_WATCHDOG_RESET_GPIO_OUT, 1);
158
+ s->clock = qdev_init_clock_in(dev, "clock", NULL, NULL);
159
}
160
161
static const VMStateDescription vmstate_npcm7xx_base_timer = {
162
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_npcm7xx_watchdog_timer = {
163
164
static const VMStateDescription vmstate_npcm7xx_timer_ctrl = {
165
.name = "npcm7xx-timer-ctrl",
166
- .version_id = 1,
167
- .minimum_version_id = 1,
168
+ .version_id = 2,
169
+ .minimum_version_id = 2,
170
.fields = (VMStateField[]) {
171
VMSTATE_UINT32(tisr, NPCM7xxTimerCtrlState),
172
+ VMSTATE_CLOCK(clock, NPCM7xxTimerCtrlState),
173
VMSTATE_STRUCT_ARRAY(timer, NPCM7xxTimerCtrlState,
174
NPCM7XX_TIMERS_PER_CTRL, 0, vmstate_npcm7xx_timer,
175
NPCM7xxTimer),
176
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_timer_class_init(ObjectClass *klass, void *data)
177
QEMU_BUILD_BUG_ON(NPCM7XX_TIMER_REGS_END > NPCM7XX_TIMER_NR_REGS);
178
179
dc->desc = "NPCM7xx Timer Controller";
180
- dc->realize = npcm7xx_timer_realize;
181
dc->vmsd = &vmstate_npcm7xx_timer_ctrl;
182
rc->phases.enter = npcm7xx_timer_enter_reset;
183
rc->phases.hold = npcm7xx_timer_hold_reset;
184
@@ -XXX,XX +XXX,XX @@ static const TypeInfo npcm7xx_timer_info = {
185
.parent = TYPE_SYS_BUS_DEVICE,
186
.instance_size = sizeof(NPCM7xxTimerCtrlState),
187
.class_init = npcm7xx_timer_class_init,
188
+ .instance_init = npcm7xx_timer_init,
189
};
190
191
static void npcm7xx_timer_register_type(void)
146
--
192
--
147
2.20.1
193
2.20.1
148
194
149
195
diff view generated by jsdifflib
1
From: Eddie James <eajames@linux.ibm.com>
1
From: Hao Wu <wuhaotsh@google.com>
2
2
3
The XDMA engine embedded in the Aspeed SOCs performs PCI DMA operations
3
The ADC is part of NPCM7XX Module. Its behavior is controled by the
4
between the SOC (acting as a BMC) and a host processor in a server.
4
ADC_CON register. It converts one of the eight analog inputs into a
5
digital input and stores it in the ADC_DATA register when enabled.
5
6
6
The XDMA engine exists on the AST2400, AST2500, and AST2600 SOCs, so
7
Users can alter input value by using qom-set QMP command.
7
enable it for all of those. Add trace events on the important register
8
writes in the XDMA engine.
9
8
10
Signed-off-by: Eddie James <eajames@linux.ibm.com>
9
Reviewed-by: Havard Skinnemoen <hskinnemoen@google.com>
11
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
10
Reviewed-by: Tyrone Ting <kfting@nuvoton.com>
12
Signed-off-by: Cédric Le Goater <clg@kaod.org>
11
Signed-off-by: Hao Wu <wuhaotsh@google.com>
13
Message-id: 20190618165311.27066-21-clg@kaod.org
12
Message-id: 20210108190945.949196-4-wuhaotsh@google.com
14
[clg: - changed title ]
13
[PMM: Added missing hw/adc/trace.h file]
15
Signed-off-by: Cédric Le Goater <clg@kaod.org>
14
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
16
---
18
hw/misc/Makefile.objs | 1 +
17
docs/system/arm/nuvoton.rst | 2 +-
19
include/hw/arm/aspeed_soc.h | 3 +
18
meson.build | 1 +
20
include/hw/misc/aspeed_xdma.h | 30 +++++++
19
hw/adc/trace.h | 1 +
21
hw/arm/aspeed_soc.c | 17 ++++
20
include/hw/adc/npcm7xx_adc.h | 69 ++++++
22
hw/misc/aspeed_xdma.c | 165 ++++++++++++++++++++++++++++++++++
21
include/hw/arm/npcm7xx.h | 2 +
23
hw/misc/trace-events | 3 +
22
hw/adc/npcm7xx_adc.c | 301 ++++++++++++++++++++++++++
24
6 files changed, 219 insertions(+)
23
hw/arm/npcm7xx.c | 24 ++-
25
create mode 100644 include/hw/misc/aspeed_xdma.h
24
tests/qtest/npcm7xx_adc-test.c | 377 +++++++++++++++++++++++++++++++++
26
create mode 100644 hw/misc/aspeed_xdma.c
25
hw/adc/meson.build | 1 +
26
hw/adc/trace-events | 5 +
27
tests/qtest/meson.build | 3 +-
28
11 files changed, 783 insertions(+), 3 deletions(-)
29
create mode 100644 hw/adc/trace.h
30
create mode 100644 include/hw/adc/npcm7xx_adc.h
31
create mode 100644 hw/adc/npcm7xx_adc.c
32
create mode 100644 tests/qtest/npcm7xx_adc-test.c
33
create mode 100644 hw/adc/trace-events
27
34
28
diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs
35
diff --git a/docs/system/arm/nuvoton.rst b/docs/system/arm/nuvoton.rst
29
index XXXXXXX..XXXXXXX 100644
36
index XXXXXXX..XXXXXXX 100644
30
--- a/hw/misc/Makefile.objs
37
--- a/docs/system/arm/nuvoton.rst
31
+++ b/hw/misc/Makefile.objs
38
+++ b/docs/system/arm/nuvoton.rst
32
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_ARMSSE_MHU) += armsse-mhu.o
39
@@ -XXX,XX +XXX,XX @@ Supported devices
33
40
* Random Number Generator (RNG)
34
obj-$(CONFIG_PVPANIC) += pvpanic.o
41
* USB host (USBH)
35
obj-$(CONFIG_AUX) += auxbus.o
42
* GPIO controller
36
+obj-$(CONFIG_ASPEED_SOC) += aspeed_xdma.o
43
+ * Analog to Digital Converter (ADC)
37
obj-$(CONFIG_ASPEED_SOC) += aspeed_scu.o aspeed_sdmc.o
44
38
obj-$(CONFIG_MSF2) += msf2-sysreg.o
45
Missing devices
39
obj-$(CONFIG_NRF51_SOC) += nrf51_rng.o
46
---------------
40
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
47
@@ -XXX,XX +XXX,XX @@ Missing devices
48
* USB device (USBD)
49
* SMBus controller (SMBF)
50
* Peripheral SPI controller (PSPI)
51
- * Analog to Digital Converter (ADC)
52
* SD/MMC host
53
* PECI interface
54
* Pulse Width Modulation (PWM)
55
diff --git a/meson.build b/meson.build
41
index XXXXXXX..XXXXXXX 100644
56
index XXXXXXX..XXXXXXX 100644
42
--- a/include/hw/arm/aspeed_soc.h
57
--- a/meson.build
43
+++ b/include/hw/arm/aspeed_soc.h
58
+++ b/meson.build
44
@@ -XXX,XX +XXX,XX @@
59
@@ -XXX,XX +XXX,XX @@ if have_system
45
#include "hw/intc/aspeed_vic.h"
60
'chardev',
46
#include "hw/misc/aspeed_scu.h"
61
'hw/9pfs',
47
#include "hw/misc/aspeed_sdmc.h"
62
'hw/acpi',
48
+#include "hw/misc/aspeed_xdma.h"
63
+ 'hw/adc',
49
#include "hw/timer/aspeed_timer.h"
64
'hw/alpha',
50
#include "hw/timer/aspeed_rtc.h"
65
'hw/arm',
51
#include "hw/i2c/aspeed_i2c.h"
66
'hw/audio',
52
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState {
67
diff --git a/hw/adc/trace.h b/hw/adc/trace.h
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
68
new file mode 100644
70
index XXXXXXX..XXXXXXX
69
index XXXXXXX..XXXXXXX
71
--- /dev/null
70
--- /dev/null
72
+++ b/include/hw/misc/aspeed_xdma.h
71
+++ b/hw/adc/trace.h
73
@@ -XXX,XX +XXX,XX @@
72
@@ -0,0 +1 @@
74
+/*
73
+#include "trace/trace-hw_adc.h"
75
+ * ASPEED XDMA Controller
74
diff --git a/include/hw/adc/npcm7xx_adc.h b/include/hw/adc/npcm7xx_adc.h
76
+ * Eddie James <eajames@linux.ibm.com>
77
+ *
78
+ * Copyright (C) 2019 IBM Corp.
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
75
new file mode 100644
162
index XXXXXXX..XXXXXXX
76
index XXXXXXX..XXXXXXX
163
--- /dev/null
77
--- /dev/null
164
+++ b/hw/misc/aspeed_xdma.c
78
+++ b/include/hw/adc/npcm7xx_adc.h
165
@@ -XXX,XX +XXX,XX @@
79
@@ -XXX,XX +XXX,XX @@
166
+/*
80
+/*
167
+ * ASPEED XDMA Controller
81
+ * Nuvoton NPCM7xx ADC Module
168
+ * Eddie James <eajames@linux.ibm.com>
169
+ *
82
+ *
170
+ * Copyright (C) 2019 IBM Corp
83
+ * Copyright 2020 Google LLC
171
+ * SPDX-License-Identifer: GPL-2.0-or-later
84
+ *
85
+ * This program is free software; you can redistribute it and/or modify it
86
+ * under the terms of the GNU General Public License as published by the
87
+ * Free Software Foundation; either version 2 of the License, or
88
+ * (at your option) any later version.
89
+ *
90
+ * This program is distributed in the hope that it will be useful, but WITHOUT
91
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
92
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
93
+ * for more details.
172
+ */
94
+ */
95
+#ifndef NPCM7XX_ADC_H
96
+#define NPCM7XX_ADC_H
97
+
98
+#include "hw/clock.h"
99
+#include "hw/irq.h"
100
+#include "hw/sysbus.h"
101
+#include "qemu/timer.h"
102
+
103
+#define NPCM7XX_ADC_NUM_INPUTS 8
104
+/**
105
+ * This value should not be changed unless write_adc_calibration function in
106
+ * hw/arm/npcm7xx.c is also changed.
107
+ */
108
+#define NPCM7XX_ADC_NUM_CALIB 2
109
+
110
+/**
111
+ * struct NPCM7xxADCState - Analog to Digital Converter Module device state.
112
+ * @parent: System bus device.
113
+ * @iomem: Memory region through which registers are accessed.
114
+ * @conv_timer: The timer counts down remaining cycles for the conversion.
115
+ * @irq: GIC interrupt line to fire on expiration (if enabled).
116
+ * @con: The Control Register.
117
+ * @data: The Data Buffer.
118
+ * @clock: The ADC Clock.
119
+ * @adci: The input voltage in units of uV. 1uv = 1e-6V.
120
+ * @vref: The external reference voltage.
121
+ * @iref: The internal reference voltage, initialized at launch time.
122
+ * @rv: The calibrated output values of 0.5V and 1.5V for the ADC.
123
+ */
124
+typedef struct {
125
+ SysBusDevice parent;
126
+
127
+ MemoryRegion iomem;
128
+
129
+ QEMUTimer conv_timer;
130
+
131
+ qemu_irq irq;
132
+ uint32_t con;
133
+ uint32_t data;
134
+ Clock *clock;
135
+
136
+ /* Voltages are in unit of uV. 1V = 1000000uV. */
137
+ uint32_t adci[NPCM7XX_ADC_NUM_INPUTS];
138
+ uint32_t vref;
139
+ uint32_t iref;
140
+
141
+ uint16_t calibration_r_values[NPCM7XX_ADC_NUM_CALIB];
142
+} NPCM7xxADCState;
143
+
144
+#define TYPE_NPCM7XX_ADC "npcm7xx-adc"
145
+#define NPCM7XX_ADC(obj) \
146
+ OBJECT_CHECK(NPCM7xxADCState, (obj), TYPE_NPCM7XX_ADC)
147
+
148
+#endif /* NPCM7XX_ADC_H */
149
diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h
150
index XXXXXXX..XXXXXXX 100644
151
--- a/include/hw/arm/npcm7xx.h
152
+++ b/include/hw/arm/npcm7xx.h
153
@@ -XXX,XX +XXX,XX @@
154
#define NPCM7XX_H
155
156
#include "hw/boards.h"
157
+#include "hw/adc/npcm7xx_adc.h"
158
#include "hw/cpu/a9mpcore.h"
159
#include "hw/gpio/npcm7xx_gpio.h"
160
#include "hw/mem/npcm7xx_mc.h"
161
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxState {
162
NPCM7xxGCRState gcr;
163
NPCM7xxCLKState clk;
164
NPCM7xxTimerCtrlState tim[3];
165
+ NPCM7xxADCState adc;
166
NPCM7xxOTPState key_storage;
167
NPCM7xxOTPState fuse_array;
168
NPCM7xxMCState mc;
169
diff --git a/hw/adc/npcm7xx_adc.c b/hw/adc/npcm7xx_adc.c
170
new file mode 100644
171
index XXXXXXX..XXXXXXX
172
--- /dev/null
173
+++ b/hw/adc/npcm7xx_adc.c
174
@@ -XXX,XX +XXX,XX @@
175
+/*
176
+ * Nuvoton NPCM7xx ADC Module
177
+ *
178
+ * Copyright 2020 Google LLC
179
+ *
180
+ * This program is free software; you can redistribute it and/or modify it
181
+ * under the terms of the GNU General Public License as published by the
182
+ * Free Software Foundation; either version 2 of the License, or
183
+ * (at your option) any later version.
184
+ *
185
+ * This program is distributed in the hope that it will be useful, but WITHOUT
186
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
187
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
188
+ * for more details.
189
+ */
173
+
190
+
174
+#include "qemu/osdep.h"
191
+#include "qemu/osdep.h"
192
+#include "hw/adc/npcm7xx_adc.h"
193
+#include "hw/qdev-clock.h"
194
+#include "hw/qdev-properties.h"
195
+#include "hw/registerfields.h"
196
+#include "migration/vmstate.h"
175
+#include "qemu/log.h"
197
+#include "qemu/log.h"
176
+#include "qemu/error-report.h"
198
+#include "qemu/module.h"
177
+#include "hw/misc/aspeed_xdma.h"
199
+#include "qemu/timer.h"
178
+#include "qapi/error.h"
200
+#include "qemu/units.h"
179
+
180
+#include "trace.h"
201
+#include "trace.h"
181
+
202
+
182
+#define XDMA_BMC_CMDQ_ADDR 0x10
203
+REG32(NPCM7XX_ADC_CON, 0x0)
183
+#define XDMA_BMC_CMDQ_ENDP 0x14
204
+REG32(NPCM7XX_ADC_DATA, 0x4)
184
+#define XDMA_BMC_CMDQ_WRP 0x18
205
+
185
+#define XDMA_BMC_CMDQ_W_MASK 0x0003FFFF
206
+/* Register field definitions. */
186
+#define XDMA_BMC_CMDQ_RDP 0x1C
207
+#define NPCM7XX_ADC_CON_MUX(rv) extract32(rv, 24, 4)
187
+#define XDMA_BMC_CMDQ_RDP_MAGIC 0xEE882266
208
+#define NPCM7XX_ADC_CON_INT_EN BIT(21)
188
+#define XDMA_IRQ_ENG_CTRL 0x20
209
+#define NPCM7XX_ADC_CON_REFSEL BIT(19)
189
+#define XDMA_IRQ_ENG_CTRL_US_COMP BIT(4)
210
+#define NPCM7XX_ADC_CON_INT BIT(18)
190
+#define XDMA_IRQ_ENG_CTRL_DS_COMP BIT(5)
211
+#define NPCM7XX_ADC_CON_EN BIT(17)
191
+#define XDMA_IRQ_ENG_CTRL_W_MASK 0xBFEFF07F
212
+#define NPCM7XX_ADC_CON_RST BIT(16)
192
+#define XDMA_IRQ_ENG_STAT 0x24
213
+#define NPCM7XX_ADC_CON_CONV BIT(14)
193
+#define XDMA_IRQ_ENG_STAT_US_COMP BIT(4)
214
+#define NPCM7XX_ADC_CON_DIV(rv) extract32(rv, 1, 8)
194
+#define XDMA_IRQ_ENG_STAT_DS_COMP BIT(5)
215
+
195
+#define XDMA_IRQ_ENG_STAT_RESET 0xF8000000
216
+#define NPCM7XX_ADC_MAX_RESULT 1023
196
+#define XDMA_MEM_SIZE 0x1000
217
+#define NPCM7XX_ADC_DEFAULT_IREF 2000000
197
+
218
+#define NPCM7XX_ADC_CONV_CYCLES 20
198
+#define TO_REG(addr) ((addr) / sizeof(uint32_t))
219
+#define NPCM7XX_ADC_RESET_CYCLES 10
199
+
220
+#define NPCM7XX_ADC_R0_INPUT 500000
200
+static uint64_t aspeed_xdma_read(void *opaque, hwaddr addr, unsigned int size)
221
+#define NPCM7XX_ADC_R1_INPUT 1500000
201
+{
222
+
202
+ uint32_t val = 0;
223
+static void npcm7xx_adc_reset(NPCM7xxADCState *s)
203
+ AspeedXDMAState *xdma = opaque;
224
+{
204
+
225
+ timer_del(&s->conv_timer);
205
+ if (addr < ASPEED_XDMA_REG_SIZE) {
226
+ s->con = 0x000c0001;
206
+ val = xdma->regs[TO_REG(addr)];
227
+ s->data = 0x00000000;
207
+ }
228
+}
208
+
229
+
209
+ return (uint64_t)val;
230
+static uint32_t npcm7xx_adc_convert(uint32_t input, uint32_t ref)
210
+}
231
+{
211
+
232
+ uint32_t result;
212
+static void aspeed_xdma_write(void *opaque, hwaddr addr, uint64_t val,
233
+
213
+ unsigned int size)
234
+ result = input * (NPCM7XX_ADC_MAX_RESULT + 1) / ref;
214
+{
235
+ if (result > NPCM7XX_ADC_MAX_RESULT) {
215
+ unsigned int idx;
236
+ result = NPCM7XX_ADC_MAX_RESULT;
216
+ uint32_t val32 = (uint32_t)val;
237
+ }
217
+ AspeedXDMAState *xdma = opaque;
238
+
218
+
239
+ return result;
219
+ if (addr >= ASPEED_XDMA_REG_SIZE) {
240
+}
241
+
242
+static uint32_t npcm7xx_adc_prescaler(NPCM7xxADCState *s)
243
+{
244
+ return 2 * (NPCM7XX_ADC_CON_DIV(s->con) + 1);
245
+}
246
+
247
+static void npcm7xx_adc_start_timer(Clock *clk, QEMUTimer *timer,
248
+ uint32_t cycles, uint32_t prescaler)
249
+{
250
+ int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
251
+ int64_t ticks = cycles;
252
+ int64_t ns;
253
+
254
+ ticks *= prescaler;
255
+ ns = clock_ticks_to_ns(clk, ticks);
256
+ ns += now;
257
+ timer_mod(timer, ns);
258
+}
259
+
260
+static void npcm7xx_adc_start_convert(NPCM7xxADCState *s)
261
+{
262
+ uint32_t prescaler = npcm7xx_adc_prescaler(s);
263
+
264
+ npcm7xx_adc_start_timer(s->clock, &s->conv_timer, NPCM7XX_ADC_CONV_CYCLES,
265
+ prescaler);
266
+}
267
+
268
+static void npcm7xx_adc_convert_done(void *opaque)
269
+{
270
+ NPCM7xxADCState *s = opaque;
271
+ uint32_t input = NPCM7XX_ADC_CON_MUX(s->con);
272
+ uint32_t ref = (s->con & NPCM7XX_ADC_CON_REFSEL)
273
+ ? s->iref : s->vref;
274
+
275
+ if (input >= NPCM7XX_ADC_NUM_INPUTS) {
276
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid input: %u\n",
277
+ __func__, input);
220
+ return;
278
+ return;
221
+ }
279
+ }
222
+
280
+ s->data = npcm7xx_adc_convert(s->adci[input], ref);
223
+ switch (addr) {
281
+ if (s->con & NPCM7XX_ADC_CON_INT_EN) {
224
+ case XDMA_BMC_CMDQ_ENDP:
282
+ s->con |= NPCM7XX_ADC_CON_INT;
225
+ xdma->regs[TO_REG(addr)] = val32 & XDMA_BMC_CMDQ_W_MASK;
283
+ qemu_irq_raise(s->irq);
284
+ }
285
+ s->con &= ~NPCM7XX_ADC_CON_CONV;
286
+}
287
+
288
+static void npcm7xx_adc_calibrate(NPCM7xxADCState *adc)
289
+{
290
+ adc->calibration_r_values[0] = npcm7xx_adc_convert(NPCM7XX_ADC_R0_INPUT,
291
+ adc->iref);
292
+ adc->calibration_r_values[1] = npcm7xx_adc_convert(NPCM7XX_ADC_R1_INPUT,
293
+ adc->iref);
294
+}
295
+
296
+static void npcm7xx_adc_write_con(NPCM7xxADCState *s, uint32_t new_con)
297
+{
298
+ uint32_t old_con = s->con;
299
+
300
+ /* Write ADC_INT to 1 to clear it */
301
+ if (new_con & NPCM7XX_ADC_CON_INT) {
302
+ new_con &= ~NPCM7XX_ADC_CON_INT;
303
+ qemu_irq_lower(s->irq);
304
+ } else if (old_con & NPCM7XX_ADC_CON_INT) {
305
+ new_con |= NPCM7XX_ADC_CON_INT;
306
+ }
307
+
308
+ s->con = new_con;
309
+
310
+ if (s->con & NPCM7XX_ADC_CON_RST) {
311
+ npcm7xx_adc_reset(s);
312
+ return;
313
+ }
314
+
315
+ if ((s->con & NPCM7XX_ADC_CON_EN)) {
316
+ if (s->con & NPCM7XX_ADC_CON_CONV) {
317
+ if (!(old_con & NPCM7XX_ADC_CON_CONV)) {
318
+ npcm7xx_adc_start_convert(s);
319
+ }
320
+ } else {
321
+ timer_del(&s->conv_timer);
322
+ }
323
+ }
324
+}
325
+
326
+static uint64_t npcm7xx_adc_read(void *opaque, hwaddr offset, unsigned size)
327
+{
328
+ uint64_t value = 0;
329
+ NPCM7xxADCState *s = opaque;
330
+
331
+ switch (offset) {
332
+ case A_NPCM7XX_ADC_CON:
333
+ value = s->con;
226
+ break;
334
+ break;
227
+ case XDMA_BMC_CMDQ_WRP:
335
+
228
+ idx = TO_REG(addr);
336
+ case A_NPCM7XX_ADC_DATA:
229
+ xdma->regs[idx] = val32 & XDMA_BMC_CMDQ_W_MASK;
337
+ value = s->data;
230
+ xdma->regs[TO_REG(XDMA_BMC_CMDQ_RDP)] = xdma->regs[idx];
231
+
232
+ trace_aspeed_xdma_write(addr, val);
233
+
234
+ if (xdma->bmc_cmdq_readp_set) {
235
+ xdma->bmc_cmdq_readp_set = 0;
236
+ } else {
237
+ xdma->regs[TO_REG(XDMA_IRQ_ENG_STAT)] |=
238
+ XDMA_IRQ_ENG_STAT_US_COMP | XDMA_IRQ_ENG_STAT_DS_COMP;
239
+
240
+ if (xdma->regs[TO_REG(XDMA_IRQ_ENG_CTRL)] &
241
+ (XDMA_IRQ_ENG_CTRL_US_COMP | XDMA_IRQ_ENG_CTRL_DS_COMP))
242
+ qemu_irq_raise(xdma->irq);
243
+ }
244
+ break;
338
+ break;
245
+ case XDMA_BMC_CMDQ_RDP:
339
+
246
+ trace_aspeed_xdma_write(addr, val);
340
+ default:
247
+
341
+ qemu_log_mask(LOG_GUEST_ERROR,
248
+ if (val32 == XDMA_BMC_CMDQ_RDP_MAGIC) {
342
+ "%s: invalid offset 0x%04" HWADDR_PRIx "\n",
249
+ xdma->bmc_cmdq_readp_set = 1;
343
+ __func__, offset);
250
+ }
251
+ break;
344
+ break;
252
+ case XDMA_IRQ_ENG_CTRL:
345
+ }
253
+ xdma->regs[TO_REG(addr)] = val32 & XDMA_IRQ_ENG_CTRL_W_MASK;
346
+
347
+ trace_npcm7xx_adc_read(DEVICE(s)->canonical_path, offset, value);
348
+ return value;
349
+}
350
+
351
+static void npcm7xx_adc_write(void *opaque, hwaddr offset, uint64_t v,
352
+ unsigned size)
353
+{
354
+ NPCM7xxADCState *s = opaque;
355
+
356
+ trace_npcm7xx_adc_write(DEVICE(s)->canonical_path, offset, v);
357
+ switch (offset) {
358
+ case A_NPCM7XX_ADC_CON:
359
+ npcm7xx_adc_write_con(s, v);
254
+ break;
360
+ break;
255
+ case XDMA_IRQ_ENG_STAT:
361
+
256
+ trace_aspeed_xdma_write(addr, val);
362
+ case A_NPCM7XX_ADC_DATA:
257
+
363
+ qemu_log_mask(LOG_GUEST_ERROR,
258
+ idx = TO_REG(addr);
364
+ "%s: register @ 0x%04" HWADDR_PRIx " is read-only\n",
259
+ if (val32 & (XDMA_IRQ_ENG_STAT_US_COMP | XDMA_IRQ_ENG_STAT_DS_COMP)) {
365
+ __func__, offset);
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;
366
+ break;
367
+
265
+ default:
368
+ default:
266
+ xdma->regs[TO_REG(addr)] = val32;
369
+ qemu_log_mask(LOG_GUEST_ERROR,
370
+ "%s: invalid offset 0x%04" HWADDR_PRIx "\n",
371
+ __func__, offset);
267
+ break;
372
+ break;
268
+ }
373
+ }
269
+}
374
+
270
+
375
+}
271
+static const MemoryRegionOps aspeed_xdma_ops = {
376
+
272
+ .read = aspeed_xdma_read,
377
+static const struct MemoryRegionOps npcm7xx_adc_ops = {
273
+ .write = aspeed_xdma_write,
378
+ .read = npcm7xx_adc_read,
274
+ .endianness = DEVICE_NATIVE_ENDIAN,
379
+ .write = npcm7xx_adc_write,
275
+ .valid.min_access_size = 4,
380
+ .endianness = DEVICE_LITTLE_ENDIAN,
276
+ .valid.max_access_size = 4,
381
+ .valid = {
382
+ .min_access_size = 4,
383
+ .max_access_size = 4,
384
+ .unaligned = false,
385
+ },
277
+};
386
+};
278
+
387
+
279
+static void aspeed_xdma_realize(DeviceState *dev, Error **errp)
388
+static void npcm7xx_adc_enter_reset(Object *obj, ResetType type)
280
+{
389
+{
281
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
390
+ NPCM7xxADCState *s = NPCM7XX_ADC(obj);
282
+ AspeedXDMAState *xdma = ASPEED_XDMA(dev);
391
+
283
+
392
+ npcm7xx_adc_reset(s);
284
+ sysbus_init_irq(sbd, &xdma->irq);
393
+}
285
+ memory_region_init_io(&xdma->iomem, OBJECT(xdma), &aspeed_xdma_ops, xdma,
394
+
286
+ TYPE_ASPEED_XDMA, XDMA_MEM_SIZE);
395
+static void npcm7xx_adc_hold_reset(Object *obj)
287
+ sysbus_init_mmio(sbd, &xdma->iomem);
396
+{
288
+}
397
+ NPCM7xxADCState *s = NPCM7XX_ADC(obj);
289
+
398
+
290
+static void aspeed_xdma_reset(DeviceState *dev)
399
+ qemu_irq_lower(s->irq);
291
+{
400
+}
292
+ AspeedXDMAState *xdma = ASPEED_XDMA(dev);
401
+
293
+
402
+static void npcm7xx_adc_init(Object *obj)
294
+ xdma->bmc_cmdq_readp_set = 0;
403
+{
295
+ memset(xdma->regs, 0, ASPEED_XDMA_REG_SIZE);
404
+ NPCM7xxADCState *s = NPCM7XX_ADC(obj);
296
+ xdma->regs[TO_REG(XDMA_IRQ_ENG_STAT)] = XDMA_IRQ_ENG_STAT_RESET;
405
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
297
+
406
+ int i;
298
+ qemu_irq_lower(xdma->irq);
407
+
299
+}
408
+ sysbus_init_irq(sbd, &s->irq);
300
+
409
+
301
+static const VMStateDescription aspeed_xdma_vmstate = {
410
+ timer_init_ns(&s->conv_timer, QEMU_CLOCK_VIRTUAL,
302
+ .name = TYPE_ASPEED_XDMA,
411
+ npcm7xx_adc_convert_done, s);
303
+ .version_id = 1,
412
+ memory_region_init_io(&s->iomem, obj, &npcm7xx_adc_ops, s,
413
+ TYPE_NPCM7XX_ADC, 4 * KiB);
414
+ sysbus_init_mmio(sbd, &s->iomem);
415
+ s->clock = qdev_init_clock_in(DEVICE(s), "clock", NULL, NULL);
416
+
417
+ for (i = 0; i < NPCM7XX_ADC_NUM_INPUTS; ++i) {
418
+ object_property_add_uint32_ptr(obj, "adci[*]",
419
+ &s->adci[i], OBJ_PROP_FLAG_WRITE);
420
+ }
421
+ object_property_add_uint32_ptr(obj, "vref",
422
+ &s->vref, OBJ_PROP_FLAG_WRITE);
423
+ npcm7xx_adc_calibrate(s);
424
+}
425
+
426
+static const VMStateDescription vmstate_npcm7xx_adc = {
427
+ .name = "npcm7xx-adc",
428
+ .version_id = 0,
429
+ .minimum_version_id = 0,
304
+ .fields = (VMStateField[]) {
430
+ .fields = (VMStateField[]) {
305
+ VMSTATE_UINT32_ARRAY(regs, AspeedXDMAState, ASPEED_XDMA_NUM_REGS),
431
+ VMSTATE_TIMER(conv_timer, NPCM7xxADCState),
432
+ VMSTATE_UINT32(con, NPCM7xxADCState),
433
+ VMSTATE_UINT32(data, NPCM7xxADCState),
434
+ VMSTATE_CLOCK(clock, NPCM7xxADCState),
435
+ VMSTATE_UINT32_ARRAY(adci, NPCM7xxADCState, NPCM7XX_ADC_NUM_INPUTS),
436
+ VMSTATE_UINT32(vref, NPCM7xxADCState),
437
+ VMSTATE_UINT32(iref, NPCM7xxADCState),
438
+ VMSTATE_UINT16_ARRAY(calibration_r_values, NPCM7xxADCState,
439
+ NPCM7XX_ADC_NUM_CALIB),
306
+ VMSTATE_END_OF_LIST(),
440
+ VMSTATE_END_OF_LIST(),
307
+ },
441
+ },
308
+};
442
+};
309
+
443
+
310
+static void aspeed_xdma_class_init(ObjectClass *classp, void *data)
444
+static Property npcm7xx_timer_properties[] = {
311
+{
445
+ DEFINE_PROP_UINT32("iref", NPCM7xxADCState, iref, NPCM7XX_ADC_DEFAULT_IREF),
312
+ DeviceClass *dc = DEVICE_CLASS(classp);
446
+ DEFINE_PROP_END_OF_LIST(),
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
+};
447
+};
325
+
448
+
326
+static void aspeed_xdma_register_type(void)
449
+static void npcm7xx_adc_class_init(ObjectClass *klass, void *data)
327
+{
450
+{
328
+ type_register_static(&aspeed_xdma_info);
451
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
329
+}
452
+ DeviceClass *dc = DEVICE_CLASS(klass);
330
+type_init(aspeed_xdma_register_type);
453
+
331
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
454
+ dc->desc = "NPCM7xx ADC Module";
455
+ dc->vmsd = &vmstate_npcm7xx_adc;
456
+ rc->phases.enter = npcm7xx_adc_enter_reset;
457
+ rc->phases.hold = npcm7xx_adc_hold_reset;
458
+
459
+ device_class_set_props(dc, npcm7xx_timer_properties);
460
+}
461
+
462
+static const TypeInfo npcm7xx_adc_info = {
463
+ .name = TYPE_NPCM7XX_ADC,
464
+ .parent = TYPE_SYS_BUS_DEVICE,
465
+ .instance_size = sizeof(NPCM7xxADCState),
466
+ .class_init = npcm7xx_adc_class_init,
467
+ .instance_init = npcm7xx_adc_init,
468
+};
469
+
470
+static void npcm7xx_adc_register_types(void)
471
+{
472
+ type_register_static(&npcm7xx_adc_info);
473
+}
474
+
475
+type_init(npcm7xx_adc_register_types);
476
diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c
332
index XXXXXXX..XXXXXXX 100644
477
index XXXXXXX..XXXXXXX 100644
333
--- a/hw/misc/trace-events
478
--- a/hw/arm/npcm7xx.c
334
+++ b/hw/misc/trace-events
479
+++ b/hw/arm/npcm7xx.c
335
@@ -XXX,XX +XXX,XX @@ armsse_cpuid_write(uint64_t offset, uint64_t data, unsigned size) "SSE-200 CPU_I
480
@@ -XXX,XX +XXX,XX @@
336
# armsse-mhu.c
481
#define NPCM7XX_EHCI_BA (0xf0806000)
337
armsse_mhu_read(uint64_t offset, uint64_t data, unsigned size) "SSE-200 MHU read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
482
#define NPCM7XX_OHCI_BA (0xf0807000)
338
armsse_mhu_write(uint64_t offset, uint64_t data, unsigned size) "SSE-200 MHU write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
483
339
+
484
+/* ADC Module */
340
+# aspeed_xdma.c
485
+#define NPCM7XX_ADC_BA (0xf000c000)
341
+aspeed_xdma_write(uint64_t offset, uint64_t data) "XDMA write: offset 0x%" PRIx64 " data 0x%" PRIx64
486
+
487
/* Internal AHB SRAM */
488
#define NPCM7XX_RAM3_BA (0xc0008000)
489
#define NPCM7XX_RAM3_SZ (4 * KiB)
490
@@ -XXX,XX +XXX,XX @@
491
#define NPCM7XX_ROM_BA (0xffff0000)
492
#define NPCM7XX_ROM_SZ (64 * KiB)
493
494
+
495
/* Clock configuration values to be fixed up when bypassing bootloader */
496
497
/* Run PLL1 at 1600 MHz */
498
@@ -XXX,XX +XXX,XX @@
499
* interrupts.
500
*/
501
enum NPCM7xxInterrupt {
502
+ NPCM7XX_ADC_IRQ = 0,
503
NPCM7XX_UART0_IRQ = 2,
504
NPCM7XX_UART1_IRQ,
505
NPCM7XX_UART2_IRQ,
506
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_init_fuses(NPCM7xxState *s)
507
sizeof(value));
508
}
509
510
+static void npcm7xx_write_adc_calibration(NPCM7xxState *s)
511
+{
512
+ /* Both ADC and the fuse array must have realized. */
513
+ QEMU_BUILD_BUG_ON(sizeof(s->adc.calibration_r_values) != 4);
514
+ npcm7xx_otp_array_write(&s->fuse_array, s->adc.calibration_r_values,
515
+ NPCM7XX_FUSE_ADC_CALIB, sizeof(s->adc.calibration_r_values));
516
+}
517
+
518
static qemu_irq npcm7xx_irq(NPCM7xxState *s, int n)
519
{
520
return qdev_get_gpio_in(DEVICE(&s->a9mpcore), n);
521
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_init(Object *obj)
522
TYPE_NPCM7XX_FUSE_ARRAY);
523
object_initialize_child(obj, "mc", &s->mc, TYPE_NPCM7XX_MC);
524
object_initialize_child(obj, "rng", &s->rng, TYPE_NPCM7XX_RNG);
525
+ object_initialize_child(obj, "adc", &s->adc, TYPE_NPCM7XX_ADC);
526
527
for (i = 0; i < ARRAY_SIZE(s->tim); i++) {
528
object_initialize_child(obj, "tim[*]", &s->tim[i], TYPE_NPCM7XX_TIMER);
529
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)
530
sysbus_realize(SYS_BUS_DEVICE(&s->mc), &error_abort);
531
sysbus_mmio_map(SYS_BUS_DEVICE(&s->mc), 0, NPCM7XX_MC_BA);
532
533
+ /* ADC Modules. Cannot fail. */
534
+ qdev_connect_clock_in(DEVICE(&s->adc), "clock", qdev_get_clock_out(
535
+ DEVICE(&s->clk), "adc-clock"));
536
+ sysbus_realize(SYS_BUS_DEVICE(&s->adc), &error_abort);
537
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->adc), 0, NPCM7XX_ADC_BA);
538
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->adc), 0,
539
+ npcm7xx_irq(s, NPCM7XX_ADC_IRQ));
540
+ npcm7xx_write_adc_calibration(s);
541
+
542
/* Timer Modules (TIM). Cannot fail. */
543
QEMU_BUILD_BUG_ON(ARRAY_SIZE(npcm7xx_tim_addr) != ARRAY_SIZE(s->tim));
544
for (i = 0; i < ARRAY_SIZE(s->tim); i++) {
545
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)
546
create_unimplemented_device("npcm7xx.vdmx", 0xe0800000, 4 * KiB);
547
create_unimplemented_device("npcm7xx.pcierc", 0xe1000000, 64 * KiB);
548
create_unimplemented_device("npcm7xx.kcs", 0xf0007000, 4 * KiB);
549
- create_unimplemented_device("npcm7xx.adc", 0xf000c000, 4 * KiB);
550
create_unimplemented_device("npcm7xx.gfxi", 0xf000e000, 4 * KiB);
551
create_unimplemented_device("npcm7xx.gpio[0]", 0xf0010000, 4 * KiB);
552
create_unimplemented_device("npcm7xx.gpio[1]", 0xf0011000, 4 * KiB);
553
diff --git a/tests/qtest/npcm7xx_adc-test.c b/tests/qtest/npcm7xx_adc-test.c
554
new file mode 100644
555
index XXXXXXX..XXXXXXX
556
--- /dev/null
557
+++ b/tests/qtest/npcm7xx_adc-test.c
558
@@ -XXX,XX +XXX,XX @@
559
+/*
560
+ * QTests for Nuvoton NPCM7xx ADCModules.
561
+ *
562
+ * Copyright 2020 Google LLC
563
+ *
564
+ * This program is free software; you can redistribute it and/or modify it
565
+ * under the terms of the GNU General Public License as published by the
566
+ * Free Software Foundation; either version 2 of the License, or
567
+ * (at your option) any later version.
568
+ *
569
+ * This program is distributed in the hope that it will be useful, but WITHOUT
570
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
571
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
572
+ * for more details.
573
+ */
574
+
575
+#include "qemu/osdep.h"
576
+#include "qemu/bitops.h"
577
+#include "qemu/timer.h"
578
+#include "libqos/libqtest.h"
579
+#include "qapi/qmp/qdict.h"
580
+
581
+#define REF_HZ (25000000)
582
+
583
+#define CON_OFFSET 0x0
584
+#define DATA_OFFSET 0x4
585
+
586
+#define NUM_INPUTS 8
587
+#define DEFAULT_IREF 2000000
588
+#define CONV_CYCLES 20
589
+#define RESET_CYCLES 10
590
+#define R0_INPUT 500000
591
+#define R1_INPUT 1500000
592
+#define MAX_RESULT 1023
593
+
594
+#define DEFAULT_CLKDIV 5
595
+
596
+#define FUSE_ARRAY_BA 0xf018a000
597
+#define FCTL_OFFSET 0x14
598
+#define FST_OFFSET 0x0
599
+#define FADDR_OFFSET 0x4
600
+#define FDATA_OFFSET 0x8
601
+#define ADC_CALIB_ADDR 24
602
+#define FUSE_READ 0x2
603
+
604
+/* Register field definitions. */
605
+#define CON_MUX(rv) ((rv) << 24)
606
+#define CON_INT_EN BIT(21)
607
+#define CON_REFSEL BIT(19)
608
+#define CON_INT BIT(18)
609
+#define CON_EN BIT(17)
610
+#define CON_RST BIT(16)
611
+#define CON_CONV BIT(14)
612
+#define CON_DIV(rv) extract32(rv, 1, 8)
613
+
614
+#define FST_RDST BIT(1)
615
+#define FDATA_MASK 0xff
616
+
617
+#define MAX_ERROR 10000
618
+#define MIN_CALIB_INPUT 100000
619
+#define MAX_CALIB_INPUT 1800000
620
+
621
+static const uint32_t input_list[] = {
622
+ 100000,
623
+ 500000,
624
+ 1000000,
625
+ 1500000,
626
+ 1800000,
627
+ 2000000,
628
+};
629
+
630
+static const uint32_t vref_list[] = {
631
+ 2000000,
632
+ 2200000,
633
+ 2500000,
634
+};
635
+
636
+static const uint32_t iref_list[] = {
637
+ 1800000,
638
+ 1900000,
639
+ 2000000,
640
+ 2100000,
641
+ 2200000,
642
+};
643
+
644
+static const uint32_t div_list[] = {0, 1, 3, 7, 15};
645
+
646
+typedef struct ADC {
647
+ int irq;
648
+ uint64_t base_addr;
649
+} ADC;
650
+
651
+ADC adc = {
652
+ .irq = 0,
653
+ .base_addr = 0xf000c000
654
+};
655
+
656
+static uint32_t adc_read_con(QTestState *qts, const ADC *adc)
657
+{
658
+ return qtest_readl(qts, adc->base_addr + CON_OFFSET);
659
+}
660
+
661
+static void adc_write_con(QTestState *qts, const ADC *adc, uint32_t value)
662
+{
663
+ qtest_writel(qts, adc->base_addr + CON_OFFSET, value);
664
+}
665
+
666
+static uint32_t adc_read_data(QTestState *qts, const ADC *adc)
667
+{
668
+ return qtest_readl(qts, adc->base_addr + DATA_OFFSET);
669
+}
670
+
671
+static uint32_t adc_calibrate(uint32_t measured, uint32_t *rv)
672
+{
673
+ return R0_INPUT + (R1_INPUT - R0_INPUT) * (int32_t)(measured - rv[0])
674
+ / (int32_t)(rv[1] - rv[0]);
675
+}
676
+
677
+static void adc_qom_set(QTestState *qts, const ADC *adc,
678
+ const char *name, uint32_t value)
679
+{
680
+ QDict *response;
681
+ const char *path = "/machine/soc/adc";
682
+
683
+ g_test_message("Setting properties %s of %s with value %u",
684
+ name, path, value);
685
+ response = qtest_qmp(qts, "{ 'execute': 'qom-set',"
686
+ " 'arguments': { 'path': %s, 'property': %s, 'value': %u}}",
687
+ path, name, value);
688
+ /* The qom set message returns successfully. */
689
+ g_assert_true(qdict_haskey(response, "return"));
690
+}
691
+
692
+static void adc_write_input(QTestState *qts, const ADC *adc,
693
+ uint32_t index, uint32_t value)
694
+{
695
+ char name[100];
696
+
697
+ sprintf(name, "adci[%u]", index);
698
+ adc_qom_set(qts, adc, name, value);
699
+}
700
+
701
+static void adc_write_vref(QTestState *qts, const ADC *adc, uint32_t value)
702
+{
703
+ adc_qom_set(qts, adc, "vref", value);
704
+}
705
+
706
+static uint32_t adc_calculate_output(uint32_t input, uint32_t ref)
707
+{
708
+ uint32_t output;
709
+
710
+ g_assert_cmpuint(input, <=, ref);
711
+ output = (input * (MAX_RESULT + 1)) / ref;
712
+ if (output > MAX_RESULT) {
713
+ output = MAX_RESULT;
714
+ }
715
+
716
+ return output;
717
+}
718
+
719
+static uint32_t adc_prescaler(QTestState *qts, const ADC *adc)
720
+{
721
+ uint32_t div = extract32(adc_read_con(qts, adc), 1, 8);
722
+
723
+ return 2 * (div + 1);
724
+}
725
+
726
+static int64_t adc_calculate_steps(uint32_t cycles, uint32_t prescale,
727
+ uint32_t clkdiv)
728
+{
729
+ return (NANOSECONDS_PER_SECOND / (REF_HZ >> clkdiv)) * cycles * prescale;
730
+}
731
+
732
+static void adc_wait_conv_finished(QTestState *qts, const ADC *adc,
733
+ uint32_t clkdiv)
734
+{
735
+ uint32_t prescaler = adc_prescaler(qts, adc);
736
+
737
+ /*
738
+ * ADC should takes roughly 20 cycles to convert one sample. So we assert it
739
+ * should take 10~30 cycles here.
740
+ */
741
+ qtest_clock_step(qts, adc_calculate_steps(CONV_CYCLES / 2, prescaler,
742
+ clkdiv));
743
+ /* ADC is still converting. */
744
+ g_assert_true(adc_read_con(qts, adc) & CON_CONV);
745
+ qtest_clock_step(qts, adc_calculate_steps(CONV_CYCLES, prescaler, clkdiv));
746
+ /* ADC has finished conversion. */
747
+ g_assert_false(adc_read_con(qts, adc) & CON_CONV);
748
+}
749
+
750
+/* Check ADC can be reset to default value. */
751
+static void test_init(gconstpointer adc_p)
752
+{
753
+ const ADC *adc = adc_p;
754
+
755
+ QTestState *qts = qtest_init("-machine quanta-gsj");
756
+ adc_write_con(qts, adc, CON_REFSEL | CON_INT);
757
+ g_assert_cmphex(adc_read_con(qts, adc), ==, CON_REFSEL);
758
+ qtest_quit(qts);
759
+}
760
+
761
+/* Check ADC can convert from an internal reference. */
762
+static void test_convert_internal(gconstpointer adc_p)
763
+{
764
+ const ADC *adc = adc_p;
765
+ uint32_t index, input, output, expected_output;
766
+ QTestState *qts = qtest_init("-machine quanta-gsj");
767
+ qtest_irq_intercept_in(qts, "/machine/soc/a9mpcore/gic");
768
+
769
+ for (index = 0; index < NUM_INPUTS; ++index) {
770
+ for (size_t i = 0; i < ARRAY_SIZE(input_list); ++i) {
771
+ input = input_list[i];
772
+ expected_output = adc_calculate_output(input, DEFAULT_IREF);
773
+
774
+ adc_write_input(qts, adc, index, input);
775
+ adc_write_con(qts, adc, CON_MUX(index) | CON_REFSEL | CON_INT |
776
+ CON_EN | CON_CONV);
777
+ adc_wait_conv_finished(qts, adc, DEFAULT_CLKDIV);
778
+ g_assert_cmphex(adc_read_con(qts, adc), ==, CON_MUX(index) |
779
+ CON_REFSEL | CON_EN);
780
+ g_assert_false(qtest_get_irq(qts, adc->irq));
781
+ output = adc_read_data(qts, adc);
782
+ g_assert_cmpuint(output, ==, expected_output);
783
+ }
784
+ }
785
+
786
+ qtest_quit(qts);
787
+}
788
+
789
+/* Check ADC can convert from an external reference. */
790
+static void test_convert_external(gconstpointer adc_p)
791
+{
792
+ const ADC *adc = adc_p;
793
+ uint32_t index, input, vref, output, expected_output;
794
+ QTestState *qts = qtest_init("-machine quanta-gsj");
795
+ qtest_irq_intercept_in(qts, "/machine/soc/a9mpcore/gic");
796
+
797
+ for (index = 0; index < NUM_INPUTS; ++index) {
798
+ for (size_t i = 0; i < ARRAY_SIZE(input_list); ++i) {
799
+ for (size_t j = 0; j < ARRAY_SIZE(vref_list); ++j) {
800
+ input = input_list[i];
801
+ vref = vref_list[j];
802
+ expected_output = adc_calculate_output(input, vref);
803
+
804
+ adc_write_input(qts, adc, index, input);
805
+ adc_write_vref(qts, adc, vref);
806
+ adc_write_con(qts, adc, CON_MUX(index) | CON_INT | CON_EN |
807
+ CON_CONV);
808
+ adc_wait_conv_finished(qts, adc, DEFAULT_CLKDIV);
809
+ g_assert_cmphex(adc_read_con(qts, adc), ==,
810
+ CON_MUX(index) | CON_EN);
811
+ g_assert_false(qtest_get_irq(qts, adc->irq));
812
+ output = adc_read_data(qts, adc);
813
+ g_assert_cmpuint(output, ==, expected_output);
814
+ }
815
+ }
816
+ }
817
+
818
+ qtest_quit(qts);
819
+}
820
+
821
+/* Check ADC interrupt files if and only if CON_INT_EN is set. */
822
+static void test_interrupt(gconstpointer adc_p)
823
+{
824
+ const ADC *adc = adc_p;
825
+ uint32_t index, input, output, expected_output;
826
+ QTestState *qts = qtest_init("-machine quanta-gsj");
827
+
828
+ index = 1;
829
+ input = input_list[1];
830
+ expected_output = adc_calculate_output(input, DEFAULT_IREF);
831
+
832
+ qtest_irq_intercept_in(qts, "/machine/soc/a9mpcore/gic");
833
+ adc_write_input(qts, adc, index, input);
834
+ g_assert_false(qtest_get_irq(qts, adc->irq));
835
+ adc_write_con(qts, adc, CON_MUX(index) | CON_INT_EN | CON_REFSEL | CON_INT
836
+ | CON_EN | CON_CONV);
837
+ adc_wait_conv_finished(qts, adc, DEFAULT_CLKDIV);
838
+ g_assert_cmphex(adc_read_con(qts, adc), ==, CON_MUX(index) | CON_INT_EN
839
+ | CON_REFSEL | CON_INT | CON_EN);
840
+ g_assert_true(qtest_get_irq(qts, adc->irq));
841
+ output = adc_read_data(qts, adc);
842
+ g_assert_cmpuint(output, ==, expected_output);
843
+
844
+ qtest_quit(qts);
845
+}
846
+
847
+/* Check ADC is reset after setting ADC_RST for 10 ADC cycles. */
848
+static void test_reset(gconstpointer adc_p)
849
+{
850
+ const ADC *adc = adc_p;
851
+ QTestState *qts = qtest_init("-machine quanta-gsj");
852
+
853
+ for (size_t i = 0; i < ARRAY_SIZE(div_list); ++i) {
854
+ uint32_t div = div_list[i];
855
+
856
+ adc_write_con(qts, adc, CON_INT | CON_EN | CON_RST | CON_DIV(div));
857
+ qtest_clock_step(qts, adc_calculate_steps(RESET_CYCLES,
858
+ adc_prescaler(qts, adc), DEFAULT_CLKDIV));
859
+ g_assert_false(adc_read_con(qts, adc) & CON_EN);
860
+ }
861
+ qtest_quit(qts);
862
+}
863
+
864
+/* Check ADC Calibration works as desired. */
865
+static void test_calibrate(gconstpointer adc_p)
866
+{
867
+ int i, j;
868
+ const ADC *adc = adc_p;
869
+
870
+ for (j = 0; j < ARRAY_SIZE(iref_list); ++j) {
871
+ uint32_t iref = iref_list[j];
872
+ uint32_t expected_rv[] = {
873
+ adc_calculate_output(R0_INPUT, iref),
874
+ adc_calculate_output(R1_INPUT, iref),
875
+ };
876
+ char buf[100];
877
+ QTestState *qts;
878
+
879
+ sprintf(buf, "-machine quanta-gsj -global npcm7xx-adc.iref=%u", iref);
880
+ qts = qtest_init(buf);
881
+
882
+ /* Check the converted value is correct using the calibration value. */
883
+ for (i = 0; i < ARRAY_SIZE(input_list); ++i) {
884
+ uint32_t input;
885
+ uint32_t output;
886
+ uint32_t expected_output;
887
+ uint32_t calibrated_voltage;
888
+ uint32_t index = 0;
889
+
890
+ input = input_list[i];
891
+ /* Calibration only works for input range 0.1V ~ 1.8V. */
892
+ if (input < MIN_CALIB_INPUT || input > MAX_CALIB_INPUT) {
893
+ continue;
894
+ }
895
+ expected_output = adc_calculate_output(input, iref);
896
+
897
+ adc_write_input(qts, adc, index, input);
898
+ adc_write_con(qts, adc, CON_MUX(index) | CON_REFSEL | CON_INT |
899
+ CON_EN | CON_CONV);
900
+ adc_wait_conv_finished(qts, adc, DEFAULT_CLKDIV);
901
+ g_assert_cmphex(adc_read_con(qts, adc), ==,
902
+ CON_REFSEL | CON_MUX(index) | CON_EN);
903
+ output = adc_read_data(qts, adc);
904
+ g_assert_cmpuint(output, ==, expected_output);
905
+
906
+ calibrated_voltage = adc_calibrate(output, expected_rv);
907
+ g_assert_cmpuint(calibrated_voltage, >, input - MAX_ERROR);
908
+ g_assert_cmpuint(calibrated_voltage, <, input + MAX_ERROR);
909
+ }
910
+
911
+ qtest_quit(qts);
912
+ }
913
+}
914
+
915
+static void adc_add_test(const char *name, const ADC* wd,
916
+ GTestDataFunc fn)
917
+{
918
+ g_autofree char *full_name = g_strdup_printf("npcm7xx_adc/%s", name);
919
+ qtest_add_data_func(full_name, wd, fn);
920
+}
921
+#define add_test(name, td) adc_add_test(#name, td, test_##name)
922
+
923
+int main(int argc, char **argv)
924
+{
925
+ g_test_init(&argc, &argv, NULL);
926
+
927
+ add_test(init, &adc);
928
+ add_test(convert_internal, &adc);
929
+ add_test(convert_external, &adc);
930
+ add_test(interrupt, &adc);
931
+ add_test(reset, &adc);
932
+ add_test(calibrate, &adc);
933
+
934
+ return g_test_run();
935
+}
936
diff --git a/hw/adc/meson.build b/hw/adc/meson.build
937
index XXXXXXX..XXXXXXX 100644
938
--- a/hw/adc/meson.build
939
+++ b/hw/adc/meson.build
940
@@ -1 +1,2 @@
941
softmmu_ss.add(when: 'CONFIG_STM32F2XX_ADC', if_true: files('stm32f2xx_adc.c'))
942
+softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_adc.c'))
943
diff --git a/hw/adc/trace-events b/hw/adc/trace-events
944
new file mode 100644
945
index XXXXXXX..XXXXXXX
946
--- /dev/null
947
+++ b/hw/adc/trace-events
948
@@ -XXX,XX +XXX,XX @@
949
+# See docs/devel/tracing.txt for syntax documentation.
950
+
951
+# npcm7xx_adc.c
952
+npcm7xx_adc_read(const char *id, uint64_t offset, uint32_t value) " %s offset: 0x%04" PRIx64 " value 0x%04" PRIx32
953
+npcm7xx_adc_write(const char *id, uint64_t offset, uint32_t value) "%s offset: 0x%04" PRIx64 " value 0x%04" PRIx32
954
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
955
index XXXXXXX..XXXXXXX 100644
956
--- a/tests/qtest/meson.build
957
+++ b/tests/qtest/meson.build
958
@@ -XXX,XX +XXX,XX @@ qtests_sparc64 = \
959
['prom-env-test', 'boot-serial-test']
960
961
qtests_npcm7xx = \
962
- ['npcm7xx_gpio-test',
963
+ ['npcm7xx_adc-test',
964
+ 'npcm7xx_gpio-test',
965
'npcm7xx_rng-test',
966
'npcm7xx_timer-test',
967
'npcm7xx_watchdog_timer-test']
342
--
968
--
343
2.20.1
969
2.20.1
344
970
345
971
diff view generated by jsdifflib
1
From: Joel Stanley <joel@jms.id.au>
1
From: Hao Wu <wuhaotsh@google.com>
2
2
3
The RTC is modeled to provide time and date functionality. It is
3
The PWM module is part of NPCM7XX module. Each NPCM7XX module has two
4
initialised at zero to match the hardware.
4
identical PWM modules. Each module contains 4 PWM entries. Each PWM has
5
two outputs: frequency and duty_cycle. Both are computed using inputs
6
from software side.
5
7
6
There is no modelling of the alarm functionality, which includes the IRQ
8
This module does not model detail pulse signals since it is expensive.
7
line. As there is no guest code to exercise this function that is
9
It also does not model interrupts and watchdogs that are dependant on
8
acceptable for now.
10
the detail models. The interfaces for these are left in the module so
11
that anyone in need for these functionalities can implement on their
12
own.
9
13
10
Signed-off-by: Joel Stanley <joel@jms.id.au>
14
The user can read the duty cycle and frequency using qom-get command.
15
16
Reviewed-by: Havard Skinnemoen <hskinnemoen@google.com>
17
Reviewed-by: Tyrone Ting <kfting@nuvoton.com>
18
Signed-off-by: Hao Wu <wuhaotsh@google.com>
19
Message-id: 20210108190945.949196-5-wuhaotsh@google.com
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
20
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Message-id: 20190618165311.27066-4-clg@kaod.org
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
22
---
15
hw/timer/Makefile.objs | 2 +-
23
docs/system/arm/nuvoton.rst | 2 +-
16
include/hw/timer/aspeed_rtc.h | 31 ++++++
24
include/hw/arm/npcm7xx.h | 2 +
17
hw/timer/aspeed_rtc.c | 180 ++++++++++++++++++++++++++++++++++
25
include/hw/misc/npcm7xx_pwm.h | 105 +++++++
18
hw/timer/trace-events | 4 +
26
hw/arm/npcm7xx.c | 26 +-
19
4 files changed, 216 insertions(+), 1 deletion(-)
27
hw/misc/npcm7xx_pwm.c | 550 ++++++++++++++++++++++++++++++++++
20
create mode 100644 include/hw/timer/aspeed_rtc.h
28
hw/misc/meson.build | 1 +
21
create mode 100644 hw/timer/aspeed_rtc.c
29
hw/misc/trace-events | 6 +
30
7 files changed, 689 insertions(+), 3 deletions(-)
31
create mode 100644 include/hw/misc/npcm7xx_pwm.h
32
create mode 100644 hw/misc/npcm7xx_pwm.c
22
33
23
diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
34
diff --git a/docs/system/arm/nuvoton.rst b/docs/system/arm/nuvoton.rst
24
index XXXXXXX..XXXXXXX 100644
35
index XXXXXXX..XXXXXXX 100644
25
--- a/hw/timer/Makefile.objs
36
--- a/docs/system/arm/nuvoton.rst
26
+++ b/hw/timer/Makefile.objs
37
+++ b/docs/system/arm/nuvoton.rst
27
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_MC146818RTC) += mc146818rtc.o
38
@@ -XXX,XX +XXX,XX @@ Supported devices
28
obj-$(CONFIG_ALLWINNER_A10_PIT) += allwinner-a10-pit.o
39
* USB host (USBH)
29
40
* GPIO controller
30
common-obj-$(CONFIG_STM32F2XX_TIMER) += stm32f2xx_timer.o
41
* Analog to Digital Converter (ADC)
31
-common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o
42
+ * Pulse Width Modulation (PWM)
32
+common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o aspeed_rtc.o
43
33
44
Missing devices
34
common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o
45
---------------
35
common-obj-$(CONFIG_CMSDK_APB_TIMER) += cmsdk-apb-timer.o
46
@@ -XXX,XX +XXX,XX @@ Missing devices
36
diff --git a/include/hw/timer/aspeed_rtc.h b/include/hw/timer/aspeed_rtc.h
47
* Peripheral SPI controller (PSPI)
48
* SD/MMC host
49
* PECI interface
50
- * Pulse Width Modulation (PWM)
51
* Tachometer
52
* PCI and PCIe root complex and bridges
53
* VDM and MCTP support
54
diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h
55
index XXXXXXX..XXXXXXX 100644
56
--- a/include/hw/arm/npcm7xx.h
57
+++ b/include/hw/arm/npcm7xx.h
58
@@ -XXX,XX +XXX,XX @@
59
#include "hw/mem/npcm7xx_mc.h"
60
#include "hw/misc/npcm7xx_clk.h"
61
#include "hw/misc/npcm7xx_gcr.h"
62
+#include "hw/misc/npcm7xx_pwm.h"
63
#include "hw/misc/npcm7xx_rng.h"
64
#include "hw/nvram/npcm7xx_otp.h"
65
#include "hw/timer/npcm7xx_timer.h"
66
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxState {
67
NPCM7xxCLKState clk;
68
NPCM7xxTimerCtrlState tim[3];
69
NPCM7xxADCState adc;
70
+ NPCM7xxPWMState pwm[2];
71
NPCM7xxOTPState key_storage;
72
NPCM7xxOTPState fuse_array;
73
NPCM7xxMCState mc;
74
diff --git a/include/hw/misc/npcm7xx_pwm.h b/include/hw/misc/npcm7xx_pwm.h
37
new file mode 100644
75
new file mode 100644
38
index XXXXXXX..XXXXXXX
76
index XXXXXXX..XXXXXXX
39
--- /dev/null
77
--- /dev/null
40
+++ b/include/hw/timer/aspeed_rtc.h
78
+++ b/include/hw/misc/npcm7xx_pwm.h
41
@@ -XXX,XX +XXX,XX @@
79
@@ -XXX,XX +XXX,XX @@
42
+/*
80
+/*
43
+ * ASPEED Real Time Clock
81
+ * Nuvoton NPCM7xx PWM Module
44
+ * Joel Stanley <joel@jms.id.au>
45
+ *
82
+ *
46
+ * Copyright 2019 IBM Corp
83
+ * Copyright 2020 Google LLC
47
+ * SPDX-License-Identifier: GPL-2.0-or-later
84
+ *
85
+ * This program is free software; you can redistribute it and/or modify it
86
+ * under the terms of the GNU General Public License as published by the
87
+ * Free Software Foundation; either version 2 of the License, or
88
+ * (at your option) any later version.
89
+ *
90
+ * This program is distributed in the hope that it will be useful, but WITHOUT
91
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
92
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
93
+ * for more details.
48
+ */
94
+ */
49
+#ifndef ASPEED_RTC_H
95
+#ifndef NPCM7XX_PWM_H
50
+#define ASPEED_RTC_H
96
+#define NPCM7XX_PWM_H
51
+
97
+
52
+#include <stdint.h>
98
+#include "hw/clock.h"
53
+
99
+#include "hw/sysbus.h"
54
+#include "hw/hw.h"
55
+#include "hw/irq.h"
100
+#include "hw/irq.h"
56
+#include "hw/sysbus.h"
101
+
57
+
102
+/* Each PWM module holds 4 PWM channels. */
58
+typedef struct AspeedRtcState {
103
+#define NPCM7XX_PWM_PER_MODULE 4
59
+ SysBusDevice parent_obj;
104
+
105
+/*
106
+ * Number of registers in one pwm module. Don't change this without increasing
107
+ * the version_id in vmstate.
108
+ */
109
+#define NPCM7XX_PWM_NR_REGS (0x54 / sizeof(uint32_t))
110
+
111
+/*
112
+ * The maximum duty values. Each duty unit represents 1/NPCM7XX_PWM_MAX_DUTY
113
+ * cycles. For example, if NPCM7XX_PWM_MAX_DUTY=1,000,000 and a PWM has a duty
114
+ * value of 100,000 the duty cycle for that PWM is 10%.
115
+ */
116
+#define NPCM7XX_PWM_MAX_DUTY 1000000
117
+
118
+typedef struct NPCM7xxPWMState NPCM7xxPWMState;
119
+
120
+/**
121
+ * struct NPCM7xxPWM - The state of a single PWM channel.
122
+ * @module: The PWM module that contains this channel.
123
+ * @irq: GIC interrupt line to fire on expiration if enabled.
124
+ * @running: Whether this PWM channel is generating output.
125
+ * @inverted: Whether this PWM channel is inverted.
126
+ * @index: The index of this PWM channel.
127
+ * @cnr: The counter register.
128
+ * @cmr: The comparator register.
129
+ * @pdr: The data register.
130
+ * @pwdr: The watchdog register.
131
+ * @freq: The frequency of this PWM channel.
132
+ * @duty: The duty cycle of this PWM channel. One unit represents
133
+ * 1/NPCM7XX_MAX_DUTY cycles.
134
+ */
135
+typedef struct NPCM7xxPWM {
136
+ NPCM7xxPWMState *module;
137
+
138
+ qemu_irq irq;
139
+
140
+ bool running;
141
+ bool inverted;
142
+
143
+ uint8_t index;
144
+ uint32_t cnr;
145
+ uint32_t cmr;
146
+ uint32_t pdr;
147
+ uint32_t pwdr;
148
+
149
+ uint32_t freq;
150
+ uint32_t duty;
151
+} NPCM7xxPWM;
152
+
153
+/**
154
+ * struct NPCM7xxPWMState - Pulse Width Modulation device state.
155
+ * @parent: System bus device.
156
+ * @iomem: Memory region through which registers are accessed.
157
+ * @clock: The PWM clock.
158
+ * @pwm: The PWM channels owned by this module.
159
+ * @ppr: The prescaler register.
160
+ * @csr: The clock selector register.
161
+ * @pcr: The control register.
162
+ * @pier: The interrupt enable register.
163
+ * @piir: The interrupt indication register.
164
+ */
165
+struct NPCM7xxPWMState {
166
+ SysBusDevice parent;
60
+
167
+
61
+ MemoryRegion iomem;
168
+ MemoryRegion iomem;
62
+ qemu_irq irq;
169
+
63
+
170
+ Clock *clock;
64
+ uint32_t reg[0x18];
171
+ NPCM7xxPWM pwm[NPCM7XX_PWM_PER_MODULE];
65
+ int offset;
172
+
66
+
173
+ uint32_t ppr;
67
+} AspeedRtcState;
174
+ uint32_t csr;
68
+
175
+ uint32_t pcr;
69
+#define TYPE_ASPEED_RTC "aspeed.rtc"
176
+ uint32_t pier;
70
+#define ASPEED_RTC(obj) OBJECT_CHECK(AspeedRtcState, (obj), TYPE_ASPEED_RTC)
177
+ uint32_t piir;
71
+
178
+};
72
+#endif /* ASPEED_RTC_H */
179
+
73
diff --git a/hw/timer/aspeed_rtc.c b/hw/timer/aspeed_rtc.c
180
+#define TYPE_NPCM7XX_PWM "npcm7xx-pwm"
181
+#define NPCM7XX_PWM(obj) \
182
+ OBJECT_CHECK(NPCM7xxPWMState, (obj), TYPE_NPCM7XX_PWM)
183
+
184
+#endif /* NPCM7XX_PWM_H */
185
diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c
186
index XXXXXXX..XXXXXXX 100644
187
--- a/hw/arm/npcm7xx.c
188
+++ b/hw/arm/npcm7xx.c
189
@@ -XXX,XX +XXX,XX @@ enum NPCM7xxInterrupt {
190
NPCM7XX_WDG2_IRQ, /* Timer Module 2 Watchdog */
191
NPCM7XX_EHCI_IRQ = 61,
192
NPCM7XX_OHCI_IRQ = 62,
193
+ NPCM7XX_PWM0_IRQ = 93, /* PWM module 0 */
194
+ NPCM7XX_PWM1_IRQ, /* PWM module 1 */
195
NPCM7XX_GPIO0_IRQ = 116,
196
NPCM7XX_GPIO1_IRQ,
197
NPCM7XX_GPIO2_IRQ,
198
@@ -XXX,XX +XXX,XX @@ static const hwaddr npcm7xx_fiu3_flash_addr[] = {
199
0xb8000000, /* CS3 */
200
};
201
202
+/* Register base address for each PWM Module */
203
+static const hwaddr npcm7xx_pwm_addr[] = {
204
+ 0xf0103000,
205
+ 0xf0104000,
206
+};
207
+
208
static const struct {
209
hwaddr regs_addr;
210
uint32_t unconnected_pins;
211
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_init(Object *obj)
212
object_initialize_child(obj, npcm7xx_fiu[i].name, &s->fiu[i],
213
TYPE_NPCM7XX_FIU);
214
}
215
+
216
+ for (i = 0; i < ARRAY_SIZE(s->pwm); i++) {
217
+ object_initialize_child(obj, "pwm[*]", &s->pwm[i], TYPE_NPCM7XX_PWM);
218
+ }
219
}
220
221
static void npcm7xx_realize(DeviceState *dev, Error **errp)
222
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)
223
sysbus_connect_irq(SYS_BUS_DEVICE(&s->ohci), 0,
224
npcm7xx_irq(s, NPCM7XX_OHCI_IRQ));
225
226
+ /* PWM Modules. Cannot fail. */
227
+ QEMU_BUILD_BUG_ON(ARRAY_SIZE(npcm7xx_pwm_addr) != ARRAY_SIZE(s->pwm));
228
+ for (i = 0; i < ARRAY_SIZE(s->pwm); i++) {
229
+ SysBusDevice *sbd = SYS_BUS_DEVICE(&s->pwm[i]);
230
+
231
+ qdev_connect_clock_in(DEVICE(&s->pwm[i]), "clock", qdev_get_clock_out(
232
+ DEVICE(&s->clk), "apb3-clock"));
233
+ sysbus_realize(sbd, &error_abort);
234
+ sysbus_mmio_map(sbd, 0, npcm7xx_pwm_addr[i]);
235
+ sysbus_connect_irq(sbd, i, npcm7xx_irq(s, NPCM7XX_PWM0_IRQ + i));
236
+ }
237
+
238
/*
239
* Flash Interface Unit (FIU). Can fail if incorrect number of chip selects
240
* specified, but this is a programming error.
241
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)
242
create_unimplemented_device("npcm7xx.peci", 0xf0100000, 4 * KiB);
243
create_unimplemented_device("npcm7xx.siox[1]", 0xf0101000, 4 * KiB);
244
create_unimplemented_device("npcm7xx.siox[2]", 0xf0102000, 4 * KiB);
245
- create_unimplemented_device("npcm7xx.pwm[0]", 0xf0103000, 4 * KiB);
246
- create_unimplemented_device("npcm7xx.pwm[1]", 0xf0104000, 4 * KiB);
247
create_unimplemented_device("npcm7xx.mft[0]", 0xf0180000, 4 * KiB);
248
create_unimplemented_device("npcm7xx.mft[1]", 0xf0181000, 4 * KiB);
249
create_unimplemented_device("npcm7xx.mft[2]", 0xf0182000, 4 * KiB);
250
diff --git a/hw/misc/npcm7xx_pwm.c b/hw/misc/npcm7xx_pwm.c
74
new file mode 100644
251
new file mode 100644
75
index XXXXXXX..XXXXXXX
252
index XXXXXXX..XXXXXXX
76
--- /dev/null
253
--- /dev/null
77
+++ b/hw/timer/aspeed_rtc.c
254
+++ b/hw/misc/npcm7xx_pwm.c
78
@@ -XXX,XX +XXX,XX @@
255
@@ -XXX,XX +XXX,XX @@
79
+/*
256
+/*
80
+ * ASPEED Real Time Clock
257
+ * Nuvoton NPCM7xx PWM Module
81
+ * Joel Stanley <joel@jms.id.au>
82
+ *
258
+ *
83
+ * Copyright 2019 IBM Corp
259
+ * Copyright 2020 Google LLC
84
+ * SPDX-License-Identifier: GPL-2.0-or-later
260
+ *
261
+ * This program is free software; you can redistribute it and/or modify it
262
+ * under the terms of the GNU General Public License as published by the
263
+ * Free Software Foundation; either version 2 of the License, or
264
+ * (at your option) any later version.
265
+ *
266
+ * This program is distributed in the hope that it will be useful, but WITHOUT
267
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
268
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
269
+ * for more details.
85
+ */
270
+ */
86
+
271
+
87
+#include "qemu/osdep.h"
272
+#include "qemu/osdep.h"
88
+#include "qemu-common.h"
273
+#include "hw/irq.h"
89
+#include "hw/timer/aspeed_rtc.h"
274
+#include "hw/qdev-clock.h"
275
+#include "hw/qdev-properties.h"
276
+#include "hw/misc/npcm7xx_pwm.h"
277
+#include "hw/registerfields.h"
278
+#include "migration/vmstate.h"
279
+#include "qemu/bitops.h"
280
+#include "qemu/error-report.h"
90
+#include "qemu/log.h"
281
+#include "qemu/log.h"
91
+#include "qemu/timer.h"
282
+#include "qemu/module.h"
92
+
283
+#include "qemu/units.h"
93
+#include "trace.h"
284
+#include "trace.h"
94
+
285
+
95
+#define COUNTER1 (0x00 / 4)
286
+REG32(NPCM7XX_PWM_PPR, 0x00);
96
+#define COUNTER2 (0x04 / 4)
287
+REG32(NPCM7XX_PWM_CSR, 0x04);
97
+#define ALARM (0x08 / 4)
288
+REG32(NPCM7XX_PWM_PCR, 0x08);
98
+#define CONTROL (0x10 / 4)
289
+REG32(NPCM7XX_PWM_CNR0, 0x0c);
99
+#define ALARM_STATUS (0x14 / 4)
290
+REG32(NPCM7XX_PWM_CMR0, 0x10);
100
+
291
+REG32(NPCM7XX_PWM_PDR0, 0x14);
101
+#define RTC_UNLOCKED BIT(1)
292
+REG32(NPCM7XX_PWM_CNR1, 0x18);
102
+#define RTC_ENABLED BIT(0)
293
+REG32(NPCM7XX_PWM_CMR1, 0x1c);
103
+
294
+REG32(NPCM7XX_PWM_PDR1, 0x20);
104
+static void aspeed_rtc_calc_offset(AspeedRtcState *rtc)
295
+REG32(NPCM7XX_PWM_CNR2, 0x24);
105
+{
296
+REG32(NPCM7XX_PWM_CMR2, 0x28);
106
+ struct tm tm;
297
+REG32(NPCM7XX_PWM_PDR2, 0x2c);
107
+ uint32_t year, cent;
298
+REG32(NPCM7XX_PWM_CNR3, 0x30);
108
+ uint32_t reg1 = rtc->reg[COUNTER1];
299
+REG32(NPCM7XX_PWM_CMR3, 0x34);
109
+ uint32_t reg2 = rtc->reg[COUNTER2];
300
+REG32(NPCM7XX_PWM_PDR3, 0x38);
110
+
301
+REG32(NPCM7XX_PWM_PIER, 0x3c);
111
+ tm.tm_mday = (reg1 >> 24) & 0x1f;
302
+REG32(NPCM7XX_PWM_PIIR, 0x40);
112
+ tm.tm_hour = (reg1 >> 16) & 0x1f;
303
+REG32(NPCM7XX_PWM_PWDR0, 0x44);
113
+ tm.tm_min = (reg1 >> 8) & 0x3f;
304
+REG32(NPCM7XX_PWM_PWDR1, 0x48);
114
+ tm.tm_sec = (reg1 >> 0) & 0x3f;
305
+REG32(NPCM7XX_PWM_PWDR2, 0x4c);
115
+
306
+REG32(NPCM7XX_PWM_PWDR3, 0x50);
116
+ cent = (reg2 >> 16) & 0x1f;
307
+
117
+ year = (reg2 >> 8) & 0x7f;
308
+/* Register field definitions. */
118
+ tm.tm_mon = ((reg2 >> 0) & 0x0f) - 1;
309
+#define NPCM7XX_PPR(rv, index) extract32((rv), npcm7xx_ppr_base[index], 8)
119
+ tm.tm_year = year + (cent * 100) - 1900;
310
+#define NPCM7XX_CSR(rv, index) extract32((rv), npcm7xx_csr_base[index], 3)
120
+
311
+#define NPCM7XX_CH(rv, index) extract32((rv), npcm7xx_ch_base[index], 4)
121
+ rtc->offset = qemu_timedate_diff(&tm);
312
+#define NPCM7XX_CH_EN BIT(0)
122
+}
313
+#define NPCM7XX_CH_INV BIT(2)
123
+
314
+#define NPCM7XX_CH_MOD BIT(3)
124
+static uint32_t aspeed_rtc_get_counter(AspeedRtcState *rtc, int r)
315
+
125
+{
316
+/* Offset of each PWM channel's prescaler in the PPR register. */
126
+ uint32_t year, cent;
317
+static const int npcm7xx_ppr_base[] = { 0, 0, 8, 8 };
127
+ struct tm now;
318
+/* Offset of each PWM channel's clock selector in the CSR register. */
128
+
319
+static const int npcm7xx_csr_base[] = { 0, 4, 8, 12 };
129
+ qemu_get_timedate(&now, rtc->offset);
320
+/* Offset of each PWM channel's control variable in the PCR register. */
130
+
321
+static const int npcm7xx_ch_base[] = { 0, 8, 12, 16 };
131
+ switch (r) {
322
+
132
+ case COUNTER1:
323
+static uint32_t npcm7xx_pwm_calculate_freq(NPCM7xxPWM *p)
133
+ return (now.tm_mday << 24) | (now.tm_hour << 16) |
324
+{
134
+ (now.tm_min << 8) | now.tm_sec;
325
+ uint32_t ppr;
135
+ case COUNTER2:
326
+ uint32_t csr;
136
+ cent = (now.tm_year + 1900) / 100;
327
+ uint32_t freq;
137
+ year = now.tm_year % 100;
328
+
138
+ return ((cent & 0x1f) << 16) | ((year & 0x7f) << 8) |
329
+ if (!p->running) {
139
+ ((now.tm_mon + 1) & 0xf);
330
+ return 0;
331
+ }
332
+
333
+ csr = NPCM7XX_CSR(p->module->csr, p->index);
334
+ ppr = NPCM7XX_PPR(p->module->ppr, p->index);
335
+ freq = clock_get_hz(p->module->clock);
336
+ freq /= ppr + 1;
337
+ /* csr can only be 0~4 */
338
+ if (csr > 4) {
339
+ qemu_log_mask(LOG_GUEST_ERROR,
340
+ "%s: invalid csr value %u\n",
341
+ __func__, csr);
342
+ csr = 4;
343
+ }
344
+ /* freq won't be changed if csr == 4. */
345
+ if (csr < 4) {
346
+ freq >>= csr + 1;
347
+ }
348
+
349
+ return freq / (p->cnr + 1);
350
+}
351
+
352
+static uint32_t npcm7xx_pwm_calculate_duty(NPCM7xxPWM *p)
353
+{
354
+ uint64_t duty;
355
+
356
+ if (p->running) {
357
+ if (p->cnr == 0) {
358
+ duty = 0;
359
+ } else if (p->cmr >= p->cnr) {
360
+ duty = NPCM7XX_PWM_MAX_DUTY;
361
+ } else {
362
+ duty = NPCM7XX_PWM_MAX_DUTY * (p->cmr + 1) / (p->cnr + 1);
363
+ }
364
+ } else {
365
+ duty = 0;
366
+ }
367
+
368
+ if (p->inverted) {
369
+ duty = NPCM7XX_PWM_MAX_DUTY - duty;
370
+ }
371
+
372
+ return duty;
373
+}
374
+
375
+static void npcm7xx_pwm_update_freq(NPCM7xxPWM *p)
376
+{
377
+ uint32_t freq = npcm7xx_pwm_calculate_freq(p);
378
+
379
+ if (freq != p->freq) {
380
+ trace_npcm7xx_pwm_update_freq(DEVICE(p->module)->canonical_path,
381
+ p->index, p->freq, freq);
382
+ p->freq = freq;
383
+ }
384
+}
385
+
386
+static void npcm7xx_pwm_update_duty(NPCM7xxPWM *p)
387
+{
388
+ uint32_t duty = npcm7xx_pwm_calculate_duty(p);
389
+
390
+ if (duty != p->duty) {
391
+ trace_npcm7xx_pwm_update_duty(DEVICE(p->module)->canonical_path,
392
+ p->index, p->duty, duty);
393
+ p->duty = duty;
394
+ }
395
+}
396
+
397
+static void npcm7xx_pwm_update_output(NPCM7xxPWM *p)
398
+{
399
+ npcm7xx_pwm_update_freq(p);
400
+ npcm7xx_pwm_update_duty(p);
401
+}
402
+
403
+static void npcm7xx_pwm_write_ppr(NPCM7xxPWMState *s, uint32_t new_ppr)
404
+{
405
+ int i;
406
+ uint32_t old_ppr = s->ppr;
407
+
408
+ QEMU_BUILD_BUG_ON(ARRAY_SIZE(npcm7xx_ppr_base) != NPCM7XX_PWM_PER_MODULE);
409
+ s->ppr = new_ppr;
410
+ for (i = 0; i < NPCM7XX_PWM_PER_MODULE; ++i) {
411
+ if (NPCM7XX_PPR(old_ppr, i) != NPCM7XX_PPR(new_ppr, i)) {
412
+ npcm7xx_pwm_update_freq(&s->pwm[i]);
413
+ }
414
+ }
415
+}
416
+
417
+static void npcm7xx_pwm_write_csr(NPCM7xxPWMState *s, uint32_t new_csr)
418
+{
419
+ int i;
420
+ uint32_t old_csr = s->csr;
421
+
422
+ QEMU_BUILD_BUG_ON(ARRAY_SIZE(npcm7xx_csr_base) != NPCM7XX_PWM_PER_MODULE);
423
+ s->csr = new_csr;
424
+ for (i = 0; i < NPCM7XX_PWM_PER_MODULE; ++i) {
425
+ if (NPCM7XX_CSR(old_csr, i) != NPCM7XX_CSR(new_csr, i)) {
426
+ npcm7xx_pwm_update_freq(&s->pwm[i]);
427
+ }
428
+ }
429
+}
430
+
431
+static void npcm7xx_pwm_write_pcr(NPCM7xxPWMState *s, uint32_t new_pcr)
432
+{
433
+ int i;
434
+ bool inverted;
435
+ uint32_t pcr;
436
+ NPCM7xxPWM *p;
437
+
438
+ s->pcr = new_pcr;
439
+ QEMU_BUILD_BUG_ON(ARRAY_SIZE(npcm7xx_ch_base) != NPCM7XX_PWM_PER_MODULE);
440
+ for (i = 0; i < NPCM7XX_PWM_PER_MODULE; ++i) {
441
+ p = &s->pwm[i];
442
+ pcr = NPCM7XX_CH(new_pcr, i);
443
+ inverted = pcr & NPCM7XX_CH_INV;
444
+
445
+ /*
446
+ * We only run a PWM channel with toggle mode. Single-shot mode does not
447
+ * generate frequency and duty-cycle values.
448
+ */
449
+ if ((pcr & NPCM7XX_CH_EN) && (pcr & NPCM7XX_CH_MOD)) {
450
+ if (p->running) {
451
+ /* Re-run this PWM channel if inverted changed. */
452
+ if (p->inverted ^ inverted) {
453
+ p->inverted = inverted;
454
+ npcm7xx_pwm_update_duty(p);
455
+ }
456
+ } else {
457
+ /* Run this PWM channel. */
458
+ p->running = true;
459
+ p->inverted = inverted;
460
+ npcm7xx_pwm_update_output(p);
461
+ }
462
+ } else {
463
+ /* Clear this PWM channel. */
464
+ p->running = false;
465
+ p->inverted = inverted;
466
+ npcm7xx_pwm_update_output(p);
467
+ }
468
+ }
469
+
470
+}
471
+
472
+static hwaddr npcm7xx_cnr_index(hwaddr offset)
473
+{
474
+ switch (offset) {
475
+ case A_NPCM7XX_PWM_CNR0:
476
+ return 0;
477
+ case A_NPCM7XX_PWM_CNR1:
478
+ return 1;
479
+ case A_NPCM7XX_PWM_CNR2:
480
+ return 2;
481
+ case A_NPCM7XX_PWM_CNR3:
482
+ return 3;
140
+ default:
483
+ default:
141
+ g_assert_not_reached();
484
+ g_assert_not_reached();
142
+ }
485
+ }
143
+}
486
+}
144
+
487
+
145
+static uint64_t aspeed_rtc_read(void *opaque, hwaddr addr,
488
+static hwaddr npcm7xx_cmr_index(hwaddr offset)
146
+ unsigned size)
489
+{
147
+{
490
+ switch (offset) {
148
+ AspeedRtcState *rtc = opaque;
491
+ case A_NPCM7XX_PWM_CMR0:
149
+ uint64_t val;
492
+ return 0;
150
+ uint32_t r = addr >> 2;
493
+ case A_NPCM7XX_PWM_CMR1:
151
+
494
+ return 1;
152
+ switch (r) {
495
+ case A_NPCM7XX_PWM_CMR2:
153
+ case COUNTER1:
496
+ return 2;
154
+ case COUNTER2:
497
+ case A_NPCM7XX_PWM_CMR3:
155
+ if (rtc->reg[CONTROL] & RTC_ENABLED) {
498
+ return 3;
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:
499
+ default:
165
+ qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx "\n", __func__, addr);
500
+ g_assert_not_reached();
501
+ }
502
+}
503
+
504
+static hwaddr npcm7xx_pdr_index(hwaddr offset)
505
+{
506
+ switch (offset) {
507
+ case A_NPCM7XX_PWM_PDR0:
166
+ return 0;
508
+ return 0;
167
+ }
509
+ case A_NPCM7XX_PWM_PDR1:
168
+
510
+ return 1;
169
+ trace_aspeed_rtc_read(addr, val);
511
+ case A_NPCM7XX_PWM_PDR2:
170
+
512
+ return 2;
171
+ return val;
513
+ case A_NPCM7XX_PWM_PDR3:
172
+}
514
+ return 3;
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:
515
+ default:
194
+ qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx "\n", __func__, addr);
516
+ g_assert_not_reached();
195
+ break;
517
+ }
196
+ }
518
+}
197
+ trace_aspeed_rtc_write(addr, val);
519
+
198
+}
520
+static hwaddr npcm7xx_pwdr_index(hwaddr offset)
199
+
521
+{
200
+static void aspeed_rtc_reset(DeviceState *d)
522
+ switch (offset) {
201
+{
523
+ case A_NPCM7XX_PWM_PWDR0:
202
+ AspeedRtcState *rtc = ASPEED_RTC(d);
524
+ return 0;
203
+
525
+ case A_NPCM7XX_PWM_PWDR1:
204
+ rtc->offset = 0;
526
+ return 1;
205
+ memset(rtc->reg, 0, sizeof(rtc->reg));
527
+ case A_NPCM7XX_PWM_PWDR2:
206
+}
528
+ return 2;
207
+
529
+ case A_NPCM7XX_PWM_PWDR3:
208
+static const MemoryRegionOps aspeed_rtc_ops = {
530
+ return 3;
209
+ .read = aspeed_rtc_read,
531
+ default:
210
+ .write = aspeed_rtc_write,
532
+ g_assert_not_reached();
211
+ .endianness = DEVICE_NATIVE_ENDIAN,
533
+ }
534
+}
535
+
536
+static uint64_t npcm7xx_pwm_read(void *opaque, hwaddr offset, unsigned size)
537
+{
538
+ NPCM7xxPWMState *s = opaque;
539
+ uint64_t value = 0;
540
+
541
+ switch (offset) {
542
+ case A_NPCM7XX_PWM_CNR0:
543
+ case A_NPCM7XX_PWM_CNR1:
544
+ case A_NPCM7XX_PWM_CNR2:
545
+ case A_NPCM7XX_PWM_CNR3:
546
+ value = s->pwm[npcm7xx_cnr_index(offset)].cnr;
547
+ break;
548
+
549
+ case A_NPCM7XX_PWM_CMR0:
550
+ case A_NPCM7XX_PWM_CMR1:
551
+ case A_NPCM7XX_PWM_CMR2:
552
+ case A_NPCM7XX_PWM_CMR3:
553
+ value = s->pwm[npcm7xx_cmr_index(offset)].cmr;
554
+ break;
555
+
556
+ case A_NPCM7XX_PWM_PDR0:
557
+ case A_NPCM7XX_PWM_PDR1:
558
+ case A_NPCM7XX_PWM_PDR2:
559
+ case A_NPCM7XX_PWM_PDR3:
560
+ value = s->pwm[npcm7xx_pdr_index(offset)].pdr;
561
+ break;
562
+
563
+ case A_NPCM7XX_PWM_PWDR0:
564
+ case A_NPCM7XX_PWM_PWDR1:
565
+ case A_NPCM7XX_PWM_PWDR2:
566
+ case A_NPCM7XX_PWM_PWDR3:
567
+ value = s->pwm[npcm7xx_pwdr_index(offset)].pwdr;
568
+ break;
569
+
570
+ case A_NPCM7XX_PWM_PPR:
571
+ value = s->ppr;
572
+ break;
573
+
574
+ case A_NPCM7XX_PWM_CSR:
575
+ value = s->csr;
576
+ break;
577
+
578
+ case A_NPCM7XX_PWM_PCR:
579
+ value = s->pcr;
580
+ break;
581
+
582
+ case A_NPCM7XX_PWM_PIER:
583
+ value = s->pier;
584
+ break;
585
+
586
+ case A_NPCM7XX_PWM_PIIR:
587
+ value = s->piir;
588
+ break;
589
+
590
+ default:
591
+ qemu_log_mask(LOG_GUEST_ERROR,
592
+ "%s: invalid offset 0x%04" HWADDR_PRIx "\n",
593
+ __func__, offset);
594
+ break;
595
+ }
596
+
597
+ trace_npcm7xx_pwm_read(DEVICE(s)->canonical_path, offset, value);
598
+ return value;
599
+}
600
+
601
+static void npcm7xx_pwm_write(void *opaque, hwaddr offset,
602
+ uint64_t v, unsigned size)
603
+{
604
+ NPCM7xxPWMState *s = opaque;
605
+ NPCM7xxPWM *p;
606
+ uint32_t value = v;
607
+
608
+ trace_npcm7xx_pwm_write(DEVICE(s)->canonical_path, offset, value);
609
+ switch (offset) {
610
+ case A_NPCM7XX_PWM_CNR0:
611
+ case A_NPCM7XX_PWM_CNR1:
612
+ case A_NPCM7XX_PWM_CNR2:
613
+ case A_NPCM7XX_PWM_CNR3:
614
+ p = &s->pwm[npcm7xx_cnr_index(offset)];
615
+ p->cnr = value;
616
+ npcm7xx_pwm_update_output(p);
617
+ break;
618
+
619
+ case A_NPCM7XX_PWM_CMR0:
620
+ case A_NPCM7XX_PWM_CMR1:
621
+ case A_NPCM7XX_PWM_CMR2:
622
+ case A_NPCM7XX_PWM_CMR3:
623
+ p = &s->pwm[npcm7xx_cmr_index(offset)];
624
+ p->cmr = value;
625
+ npcm7xx_pwm_update_output(p);
626
+ break;
627
+
628
+ case A_NPCM7XX_PWM_PDR0:
629
+ case A_NPCM7XX_PWM_PDR1:
630
+ case A_NPCM7XX_PWM_PDR2:
631
+ case A_NPCM7XX_PWM_PDR3:
632
+ qemu_log_mask(LOG_GUEST_ERROR,
633
+ "%s: register @ 0x%04" HWADDR_PRIx " is read-only\n",
634
+ __func__, offset);
635
+ break;
636
+
637
+ case A_NPCM7XX_PWM_PWDR0:
638
+ case A_NPCM7XX_PWM_PWDR1:
639
+ case A_NPCM7XX_PWM_PWDR2:
640
+ case A_NPCM7XX_PWM_PWDR3:
641
+ qemu_log_mask(LOG_UNIMP,
642
+ "%s: register @ 0x%04" HWADDR_PRIx " is not implemented\n",
643
+ __func__, offset);
644
+ break;
645
+
646
+ case A_NPCM7XX_PWM_PPR:
647
+ npcm7xx_pwm_write_ppr(s, value);
648
+ break;
649
+
650
+ case A_NPCM7XX_PWM_CSR:
651
+ npcm7xx_pwm_write_csr(s, value);
652
+ break;
653
+
654
+ case A_NPCM7XX_PWM_PCR:
655
+ npcm7xx_pwm_write_pcr(s, value);
656
+ break;
657
+
658
+ case A_NPCM7XX_PWM_PIER:
659
+ qemu_log_mask(LOG_UNIMP,
660
+ "%s: register @ 0x%04" HWADDR_PRIx " is not implemented\n",
661
+ __func__, offset);
662
+ break;
663
+
664
+ case A_NPCM7XX_PWM_PIIR:
665
+ qemu_log_mask(LOG_UNIMP,
666
+ "%s: register @ 0x%04" HWADDR_PRIx " is not implemented\n",
667
+ __func__, offset);
668
+ break;
669
+
670
+ default:
671
+ qemu_log_mask(LOG_GUEST_ERROR,
672
+ "%s: invalid offset 0x%04" HWADDR_PRIx "\n",
673
+ __func__, offset);
674
+ break;
675
+ }
676
+}
677
+
678
+static const struct MemoryRegionOps npcm7xx_pwm_ops = {
679
+ .read = npcm7xx_pwm_read,
680
+ .write = npcm7xx_pwm_write,
681
+ .endianness = DEVICE_LITTLE_ENDIAN,
682
+ .valid = {
683
+ .min_access_size = 4,
684
+ .max_access_size = 4,
685
+ .unaligned = false,
686
+ },
212
+};
687
+};
213
+
688
+
214
+static const VMStateDescription vmstate_aspeed_rtc = {
689
+static void npcm7xx_pwm_enter_reset(Object *obj, ResetType type)
215
+ .name = TYPE_ASPEED_RTC,
690
+{
216
+ .version_id = 1,
691
+ NPCM7xxPWMState *s = NPCM7XX_PWM(obj);
692
+ int i;
693
+
694
+ for (i = 0; i < NPCM7XX_PWM_PER_MODULE; i++) {
695
+ NPCM7xxPWM *p = &s->pwm[i];
696
+
697
+ p->cnr = 0x00000000;
698
+ p->cmr = 0x00000000;
699
+ p->pdr = 0x00000000;
700
+ p->pwdr = 0x00000000;
701
+ }
702
+
703
+ s->ppr = 0x00000000;
704
+ s->csr = 0x00000000;
705
+ s->pcr = 0x00000000;
706
+ s->pier = 0x00000000;
707
+ s->piir = 0x00000000;
708
+}
709
+
710
+static void npcm7xx_pwm_hold_reset(Object *obj)
711
+{
712
+ NPCM7xxPWMState *s = NPCM7XX_PWM(obj);
713
+ int i;
714
+
715
+ for (i = 0; i < NPCM7XX_PWM_PER_MODULE; i++) {
716
+ qemu_irq_lower(s->pwm[i].irq);
717
+ }
718
+}
719
+
720
+static void npcm7xx_pwm_init(Object *obj)
721
+{
722
+ NPCM7xxPWMState *s = NPCM7XX_PWM(obj);
723
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
724
+ int i;
725
+
726
+ for (i = 0; i < NPCM7XX_PWM_PER_MODULE; i++) {
727
+ NPCM7xxPWM *p = &s->pwm[i];
728
+ p->module = s;
729
+ p->index = i;
730
+ sysbus_init_irq(sbd, &p->irq);
731
+ }
732
+
733
+ memory_region_init_io(&s->iomem, obj, &npcm7xx_pwm_ops, s,
734
+ TYPE_NPCM7XX_PWM, 4 * KiB);
735
+ sysbus_init_mmio(sbd, &s->iomem);
736
+ s->clock = qdev_init_clock_in(DEVICE(s), "clock", NULL, NULL);
737
+
738
+ for (i = 0; i < NPCM7XX_PWM_PER_MODULE; ++i) {
739
+ object_property_add_uint32_ptr(obj, "freq[*]",
740
+ &s->pwm[i].freq, OBJ_PROP_FLAG_READ);
741
+ object_property_add_uint32_ptr(obj, "duty[*]",
742
+ &s->pwm[i].duty, OBJ_PROP_FLAG_READ);
743
+ }
744
+}
745
+
746
+static const VMStateDescription vmstate_npcm7xx_pwm = {
747
+ .name = "npcm7xx-pwm",
748
+ .version_id = 0,
749
+ .minimum_version_id = 0,
217
+ .fields = (VMStateField[]) {
750
+ .fields = (VMStateField[]) {
218
+ VMSTATE_UINT32_ARRAY(reg, AspeedRtcState, 0x18),
751
+ VMSTATE_BOOL(running, NPCM7xxPWM),
219
+ VMSTATE_INT32(offset, AspeedRtcState),
752
+ VMSTATE_BOOL(inverted, NPCM7xxPWM),
220
+ VMSTATE_INT32(offset, AspeedRtcState),
753
+ VMSTATE_UINT8(index, NPCM7xxPWM),
221
+ VMSTATE_END_OF_LIST()
754
+ VMSTATE_UINT32(cnr, NPCM7xxPWM),
222
+ }
755
+ VMSTATE_UINT32(cmr, NPCM7xxPWM),
756
+ VMSTATE_UINT32(pdr, NPCM7xxPWM),
757
+ VMSTATE_UINT32(pwdr, NPCM7xxPWM),
758
+ VMSTATE_UINT32(freq, NPCM7xxPWM),
759
+ VMSTATE_UINT32(duty, NPCM7xxPWM),
760
+ VMSTATE_END_OF_LIST(),
761
+ },
223
+};
762
+};
224
+
763
+
225
+static void aspeed_rtc_realize(DeviceState *dev, Error **errp)
764
+static const VMStateDescription vmstate_npcm7xx_pwm_module = {
226
+{
765
+ .name = "npcm7xx-pwm-module",
227
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
766
+ .version_id = 0,
228
+ AspeedRtcState *s = ASPEED_RTC(dev);
767
+ .minimum_version_id = 0,
229
+
768
+ .fields = (VMStateField[]) {
230
+ sysbus_init_irq(sbd, &s->irq);
769
+ VMSTATE_CLOCK(clock, NPCM7xxPWMState),
231
+
770
+ VMSTATE_STRUCT_ARRAY(pwm, NPCM7xxPWMState,
232
+ memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_rtc_ops, s,
771
+ NPCM7XX_PWM_PER_MODULE, 0, vmstate_npcm7xx_pwm,
233
+ "aspeed-rtc", 0x18ULL);
772
+ NPCM7xxPWM),
234
+ sysbus_init_mmio(sbd, &s->iomem);
773
+ VMSTATE_UINT32(ppr, NPCM7xxPWMState),
235
+}
774
+ VMSTATE_UINT32(csr, NPCM7xxPWMState),
236
+
775
+ VMSTATE_UINT32(pcr, NPCM7xxPWMState),
237
+static void aspeed_rtc_class_init(ObjectClass *klass, void *data)
776
+ VMSTATE_UINT32(pier, NPCM7xxPWMState),
238
+{
777
+ VMSTATE_UINT32(piir, NPCM7xxPWMState),
778
+ VMSTATE_END_OF_LIST(),
779
+ },
780
+};
781
+
782
+static void npcm7xx_pwm_class_init(ObjectClass *klass, void *data)
783
+{
784
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
239
+ DeviceClass *dc = DEVICE_CLASS(klass);
785
+ DeviceClass *dc = DEVICE_CLASS(klass);
240
+
786
+
241
+ dc->realize = aspeed_rtc_realize;
787
+ dc->desc = "NPCM7xx PWM Controller";
242
+ dc->vmsd = &vmstate_aspeed_rtc;
788
+ dc->vmsd = &vmstate_npcm7xx_pwm_module;
243
+ dc->reset = aspeed_rtc_reset;
789
+ rc->phases.enter = npcm7xx_pwm_enter_reset;
244
+}
790
+ rc->phases.hold = npcm7xx_pwm_hold_reset;
245
+
791
+}
246
+static const TypeInfo aspeed_rtc_info = {
792
+
247
+ .name = TYPE_ASPEED_RTC,
793
+static const TypeInfo npcm7xx_pwm_info = {
248
+ .parent = TYPE_SYS_BUS_DEVICE,
794
+ .name = TYPE_NPCM7XX_PWM,
249
+ .instance_size = sizeof(AspeedRtcState),
795
+ .parent = TYPE_SYS_BUS_DEVICE,
250
+ .class_init = aspeed_rtc_class_init,
796
+ .instance_size = sizeof(NPCM7xxPWMState),
797
+ .class_init = npcm7xx_pwm_class_init,
798
+ .instance_init = npcm7xx_pwm_init,
251
+};
799
+};
252
+
800
+
253
+static void aspeed_rtc_register_types(void)
801
+static void npcm7xx_pwm_register_type(void)
254
+{
802
+{
255
+ type_register_static(&aspeed_rtc_info);
803
+ type_register_static(&npcm7xx_pwm_info);
256
+}
804
+}
257
+
805
+type_init(npcm7xx_pwm_register_type);
258
+type_init(aspeed_rtc_register_types)
806
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
259
diff --git a/hw/timer/trace-events b/hw/timer/trace-events
260
index XXXXXXX..XXXXXXX 100644
807
index XXXXXXX..XXXXXXX 100644
261
--- a/hw/timer/trace-events
808
--- a/hw/misc/meson.build
262
+++ b/hw/timer/trace-events
809
+++ b/hw/misc/meson.build
263
@@ -XXX,XX +XXX,XX @@ cmsdk_apb_dualtimer_read(uint64_t offset, uint64_t data, unsigned size) "CMSDK A
810
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_MAINSTONE', if_true: files('mst_fpga.c'))
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"
811
softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files(
265
cmsdk_apb_dualtimer_reset(void) "CMSDK APB dualtimer: reset"
812
'npcm7xx_clk.c',
266
813
'npcm7xx_gcr.c',
267
+# hw/timer/aspeed-rtc.c
814
+ 'npcm7xx_pwm.c',
268
+aspeed_rtc_read(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 0x%08" PRIx64
815
'npcm7xx_rng.c',
269
+aspeed_rtc_write(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 0x%08" PRIx64
816
))
270
+
817
softmmu_ss.add(when: 'CONFIG_OMAP', if_true: files(
271
# sun4v-rtc.c
818
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
272
sun4v_rtc_read(uint64_t addr, uint64_t value) "read: addr 0x%" PRIx64 " value 0x%" PRIx64
819
index XXXXXXX..XXXXXXX 100644
273
sun4v_rtc_write(uint64_t addr, uint64_t value) "write: addr 0x%" PRIx64 " value 0x%" PRIx64
820
--- a/hw/misc/trace-events
821
+++ b/hw/misc/trace-events
822
@@ -XXX,XX +XXX,XX @@ npcm7xx_gcr_write(uint64_t offset, uint32_t value) "offset: 0x%04" PRIx64 " valu
823
npcm7xx_rng_read(uint64_t offset, uint64_t value, unsigned size) "offset: 0x%04" PRIx64 " value: 0x%02" PRIx64 " size: %u"
824
npcm7xx_rng_write(uint64_t offset, uint64_t value, unsigned size) "offset: 0x%04" PRIx64 " value: 0x%02" PRIx64 " size: %u"
825
826
+# npcm7xx_pwm.c
827
+npcm7xx_pwm_read(const char *id, uint64_t offset, uint32_t value) "%s offset: 0x%04" PRIx64 " value: 0x%08" PRIx32
828
+npcm7xx_pwm_write(const char *id, uint64_t offset, uint32_t value) "%s offset: 0x%04" PRIx64 " value: 0x%08" PRIx32
829
+npcm7xx_pwm_update_freq(const char *id, uint8_t index, uint32_t old_value, uint32_t new_value) "%s pwm[%u] Update Freq: old_freq: %u, new_freq: %u"
830
+npcm7xx_pwm_update_duty(const char *id, uint8_t index, uint32_t old_value, uint32_t new_value) "%s pwm[%u] Update Duty: old_duty: %u, new_duty: %u"
831
+
832
# stm32f4xx_syscfg.c
833
stm32f4xx_syscfg_set_irq(int gpio, int line, int level) "Interupt: GPIO: %d, Line: %d; Level: %d"
834
stm32f4xx_pulse_exti(int irq) "Pulse EXTI: %d"
274
--
835
--
275
2.20.1
836
2.20.1
276
837
277
838
diff view generated by jsdifflib
Deleted patch
1
From: Joel Stanley <joel@jms.id.au>
2
1
3
All systems have an RTC.
4
5
The IRQ is hooked up but the model does not use it at this stage. There
6
is no guest code that uses it, so this limitation is acceptable.
7
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>
12
---
13
include/hw/arm/aspeed_soc.h | 2 ++
14
hw/arm/aspeed_soc.c | 13 +++++++++++++
15
2 files changed, 15 insertions(+)
16
17
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
18
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/arm/aspeed_soc.h
20
+++ b/include/hw/arm/aspeed_soc.h
21
@@ -XXX,XX +XXX,XX @@
22
#include "hw/misc/aspeed_scu.h"
23
#include "hw/misc/aspeed_sdmc.h"
24
#include "hw/timer/aspeed_timer.h"
25
+#include "hw/timer/aspeed_rtc.h"
26
#include "hw/i2c/aspeed_i2c.h"
27
#include "hw/ssi/aspeed_smc.h"
28
#include "hw/watchdog/wdt_aspeed.h"
29
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState {
30
ARMCPU cpu;
31
MemoryRegion sram;
32
AspeedVICState vic;
33
+ AspeedRtcState rtc;
34
AspeedTimerCtrlState timerctrl;
35
AspeedI2CState i2c;
36
AspeedSCUState scu;
37
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
38
index XXXXXXX..XXXXXXX 100644
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
+
48
sysbus_init_child_obj(obj, "timerctrl", OBJECT(&s->timerctrl),
49
sizeof(s->timerctrl), TYPE_ASPEED_TIMER);
50
object_property_add_const_link(OBJECT(&s->timerctrl), "scu",
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
+
65
/* Timer */
66
object_property_set_bool(OBJECT(&s->timerctrl), true, "realized", &err);
67
if (err) {
68
--
69
2.20.1
70
71
diff view generated by jsdifflib
Deleted patch
1
From: Cédric Le Goater <clg@kaod.org>
2
1
3
The current models of the Aspeed SoCs only have one CPU but future
4
ones will support SMP. Introduce a new num_cpus field at the SoC class
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
9
The max_cpus limit of the machine should depend on the SoC definition
10
but, unfortunately, these values are not available when the machine
11
class is initialized. This is the reason why we add a check on
12
num_cpus in the AspeedSoC realize handler.
13
14
SMP support will be activated when models for such SoCs are implemented.
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
28
--- a/include/hw/arm/aspeed_soc.h
29
+++ b/include/hw/arm/aspeed_soc.h
30
@@ -XXX,XX +XXX,XX @@
31
32
#define ASPEED_SPIS_NUM 2
33
#define ASPEED_WDTS_NUM 3
34
+#define ASPEED_CPUS_NUM 2
35
36
typedef struct AspeedSoCState {
37
/*< private >*/
38
DeviceState parent;
39
40
/*< public >*/
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
--- a/hw/arm/aspeed.c
58
+++ b/hw/arm/aspeed.c
59
@@ -XXX,XX +XXX,XX @@
60
#include "hw/misc/tmp105.h"
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
};
72
73
struct AspeedBoardState {
74
@@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine,
75
&error_abort);
76
object_property_set_int(OBJECT(&bmc->soc), cfg->num_cs, "num-cs",
77
&error_abort);
78
+ object_property_set_int(OBJECT(&bmc->soc), smp_cpus, "num-cpus",
79
+ &error_abort);
80
if (machine->kernel_filename) {
81
/*
82
* When booting with a -kernel command line there is no u-boot
83
@@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine,
84
aspeed_board_binfo.kernel_cmdline = machine->kernel_cmdline;
85
aspeed_board_binfo.ram_size = ram_size;
86
aspeed_board_binfo.loader_start = sc->info->memmap[ASPEED_SDRAM];
87
+ aspeed_board_binfo.nb_cpus = bmc->soc.num_cpus;
88
89
if (cfg->i2c_init) {
90
cfg->i2c_init(bmc);
91
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_class_init(ObjectClass *oc, void *data)
92
93
mc->desc = board->desc;
94
mc->init = aspeed_machine_init;
95
- mc->max_cpus = 1;
96
+ mc->max_cpus = ASPEED_CPUS_NUM;
97
mc->no_sdcard = 1;
98
mc->no_floppy = 1;
99
mc->no_cdrom = 1;
100
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
101
index XXXXXXX..XXXXXXX 100644
102
--- a/hw/arm/aspeed_soc.c
103
+++ b/hw/arm/aspeed_soc.c
104
@@ -XXX,XX +XXX,XX @@
105
#include "hw/char/serial.h"
106
#include "qemu/log.h"
107
#include "qemu/module.h"
108
+#include "qemu/error-report.h"
109
#include "hw/i2c/aspeed_i2c.h"
110
#include "net/net.h"
111
112
@@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = {
113
.wdts_num = 2,
114
.irqmap = aspeed_soc_ast2400_irqmap,
115
.memmap = aspeed_soc_ast2400_memmap,
116
+ .num_cpus = 1,
117
}, {
118
.name = "ast2400-a1",
119
.cpu_type = ARM_CPU_TYPE_NAME("arm926"),
120
@@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = {
121
.wdts_num = 2,
122
.irqmap = aspeed_soc_ast2400_irqmap,
123
.memmap = aspeed_soc_ast2400_memmap,
124
+ .num_cpus = 1,
125
}, {
126
.name = "ast2400",
127
.cpu_type = ARM_CPU_TYPE_NAME("arm926"),
128
@@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = {
129
.wdts_num = 2,
130
.irqmap = aspeed_soc_ast2400_irqmap,
131
.memmap = aspeed_soc_ast2400_memmap,
132
+ .num_cpus = 1,
133
}, {
134
.name = "ast2500-a1",
135
.cpu_type = ARM_CPU_TYPE_NAME("arm1176"),
136
@@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = {
137
.wdts_num = 3,
138
.irqmap = aspeed_soc_ast2500_irqmap,
139
.memmap = aspeed_soc_ast2500_memmap,
140
+ .num_cpus = 1,
141
},
142
};
143
144
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj)
145
AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
146
int i;
147
148
- object_initialize_child(obj, "cpu", OBJECT(&s->cpu), sizeof(s->cpu),
149
- sc->info->cpu_type, &error_abort, NULL);
150
+ for (i = 0; i < sc->info->num_cpus; i++) {
151
+ object_initialize_child(obj, "cpu[*]", OBJECT(&s->cpu[i]),
152
+ sizeof(s->cpu[i]), sc->info->cpu_type,
153
+ &error_abort, NULL);
154
+ }
155
156
sysbus_init_child_obj(obj, "scu", OBJECT(&s->scu), sizeof(s->scu),
157
TYPE_ASPEED_SCU);
158
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
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
--
202
2.20.1
203
204
diff view generated by jsdifflib
Deleted patch
1
From: Cédric Le Goater <clg@kaod.org>
2
1
3
The Aspeed SoCs have two MACs. Extend the Aspeed model to support a
4
second NIC.
5
6
Signed-off-by: Cédric Le Goater <clg@kaod.org>
7
Reviewed-by: Joel Stanley <joel@jms.id.au>
8
Message-id: 20190618165311.27066-7-clg@kaod.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
include/hw/arm/aspeed_soc.h | 3 ++-
12
hw/arm/aspeed_soc.c | 33 +++++++++++++++++++--------------
13
2 files changed, 21 insertions(+), 15 deletions(-)
14
15
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
16
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/arm/aspeed_soc.h
18
+++ b/include/hw/arm/aspeed_soc.h
19
@@ -XXX,XX +XXX,XX @@
20
#define ASPEED_SPIS_NUM 2
21
#define ASPEED_WDTS_NUM 3
22
#define ASPEED_CPUS_NUM 2
23
+#define ASPEED_MACS_NUM 2
24
25
typedef struct AspeedSoCState {
26
/*< private >*/
27
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState {
28
AspeedSMCState spi[ASPEED_SPIS_NUM];
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
38
--- a/hw/arm/aspeed_soc.c
39
+++ b/hw/arm/aspeed_soc.c
40
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj)
41
sc->info->silicon_rev);
42
}
43
44
- sysbus_init_child_obj(obj, "ftgmac100", OBJECT(&s->ftgmac100),
45
- sizeof(s->ftgmac100), TYPE_FTGMAC100);
46
+ for (i = 0; i < ASPEED_MACS_NUM; i++) {
47
+ sysbus_init_child_obj(obj, "ftgmac100[*]", OBJECT(&s->ftgmac100[i]),
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
}
55
56
/* Net */
57
- qdev_set_nic_properties(DEVICE(&s->ftgmac100), &nd_table[0]);
58
- object_property_set_bool(OBJECT(&s->ftgmac100), true, "aspeed", &err);
59
- object_property_set_bool(OBJECT(&s->ftgmac100), true, "realized",
60
- &local_err);
61
- error_propagate(&err, local_err);
62
- if (err) {
63
- error_propagate(errp, err);
64
- return;
65
+ for (i = 0; i < nb_nics; i++) {
66
+ qdev_set_nic_properties(DEVICE(&s->ftgmac100[i]), &nd_table[i]);
67
+ object_property_set_bool(OBJECT(&s->ftgmac100[i]), true, "aspeed",
68
+ &err);
69
+ object_property_set_bool(OBJECT(&s->ftgmac100[i]), true, "realized",
70
+ &local_err);
71
+ error_propagate(&err, local_err);
72
+ if (err) {
73
+ error_propagate(errp, err);
74
+ return;
75
+ }
76
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0,
77
+ sc->info->memmap[ASPEED_ETH1 + i]);
78
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100[i]), 0,
79
+ aspeed_soc_get_irq(s, ASPEED_ETH1 + i));
80
}
81
- sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100), 0,
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
--
89
2.20.1
90
91
diff view generated by jsdifflib
Deleted patch
1
From: Joel Stanley <joel@jms.id.au>
2
1
3
The Linux kernel driver was updated in commit 4451d3f59f2a
4
("clocksource/drivers/fttmr010: Fix set_next_event handler) to fix an
5
issue observed on hardware:
6
7
> RELOAD register is loaded into COUNT register when the aspeed timer
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
38
--- a/hw/timer/aspeed_timer.c
39
+++ b/hw/timer/aspeed_timer.c
40
@@ -XXX,XX +XXX,XX @@ static inline uint64_t calculate_time(struct AspeedTimer *t, uint32_t ticks)
41
42
static uint64_t calculate_next(struct AspeedTimer *t)
43
{
44
- uint64_t next = 0;
45
- uint32_t rate = calculate_rate(t);
46
+ uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
47
+ uint64_t next;
48
49
- while (!next) {
50
- /* We don't know the relationship between the values in the match
51
- * registers, so sort using MAX/MIN/zero. We sort in that order as the
52
- * timer counts down to zero. */
53
- uint64_t seq[] = {
54
- calculate_time(t, MAX(t->match[0], t->match[1])),
55
- calculate_time(t, MIN(t->match[0], t->match[1])),
56
- calculate_time(t, 0),
57
- };
58
- uint64_t reload_ns;
59
- uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
60
+ /*
61
+ * We don't know the relationship between the values in the match
62
+ * registers, so sort using MAX/MIN/zero. We sort in that order as
63
+ * the timer counts down to zero.
64
+ */
65
66
- if (now < seq[0]) {
67
- next = seq[0];
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
}
83
84
- return next;
85
+ next = calculate_time(t, MIN(t->match[0], t->match[1]));
86
+ if (now < next) {
87
+ return next;
88
+ }
89
+
90
+ next = calculate_time(t, 0);
91
+ if (now < next) {
92
+ return next;
93
+ }
94
+
95
+ /* We've missed all deadlines, fire interrupt and try again */
96
+ timer_del(&t->timer);
97
+
98
+ if (timer_overflow_interrupt(t)) {
99
+ t->level = !t->level;
100
+ qemu_set_irq(t->irq, t->level);
101
+ }
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
--
109
2.20.1
110
111
diff view generated by jsdifflib
Deleted patch
1
From: Andrew Jeffery <andrew@aj.id.au>
2
1
3
From the datasheet:
4
5
This register stores the current status of counter #N. When timer
6
enable bit TMC30[N * b] is disabled, the reload register will be
7
loaded into this counter. When timer bit TMC30[N * b] is set, the
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>
16
---
17
hw/timer/aspeed_timer.c | 6 +++++-
18
1 file changed, 5 insertions(+), 1 deletion(-)
19
20
diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c
21
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/timer/aspeed_timer.c
23
+++ b/hw/timer/aspeed_timer.c
24
@@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_timer_get_value(AspeedTimer *t, int reg)
25
26
switch (reg) {
27
case TIMER_REG_STATUS:
28
- value = calculate_ticks(t, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL));
29
+ if (timer_enabled(t)) {
30
+ value = calculate_ticks(t, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL));
31
+ } else {
32
+ value = t->reload;
33
+ }
34
break;
35
case TIMER_REG_RELOAD:
36
value = t->reload;
37
--
38
2.20.1
39
40
diff view generated by jsdifflib
Deleted patch
1
From: Andrew Jeffery <andrew@aj.id.au>
2
1
3
If the match value exceeds reload then we don't want to include it in
4
calculations for the next event.
5
6
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
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
16
--- a/hw/timer/aspeed_timer.c
17
+++ b/hw/timer/aspeed_timer.c
18
@@ -XXX,XX +XXX,XX @@ static inline uint64_t calculate_time(struct AspeedTimer *t, uint32_t ticks)
19
return t->start + delta_ns;
20
}
21
22
+static inline uint32_t calculate_match(struct AspeedTimer *t, int i)
23
+{
24
+ return t->match[i] < t->reload ? t->match[i] : 0;
25
+}
26
+
27
static uint64_t calculate_next(struct AspeedTimer *t)
28
{
29
uint64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
30
@@ -XXX,XX +XXX,XX @@ static uint64_t calculate_next(struct AspeedTimer *t)
31
* the timer counts down to zero.
32
*/
33
34
- next = calculate_time(t, MAX(t->match[0], t->match[1]));
35
+ next = calculate_time(t, MAX(calculate_match(t, 0), calculate_match(t, 1)));
36
if (now < next) {
37
return next;
38
}
39
40
- next = calculate_time(t, MIN(t->match[0], t->match[1]));
41
+ next = calculate_time(t, MIN(calculate_match(t, 0), calculate_match(t, 1)));
42
if (now < next) {
43
return next;
44
}
45
@@ -XXX,XX +XXX,XX @@ static uint64_t calculate_next(struct AspeedTimer *t)
46
qemu_set_irq(t->irq, t->level);
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
}
55
56
static void aspeed_timer_mod(AspeedTimer *t)
57
--
58
2.20.1
59
60
diff view generated by jsdifflib
Deleted patch
1
From: Christian Svensson <bluecmd@google.com>
2
1
3
If the host decrements the counter register that results in a negative
4
delta. This is then passed to muldiv64 which only handles unsigned
5
numbers resulting in bogus results.
6
7
This fix ensures the delta being operated on is positive.
8
9
Test case: kexec a kernel using aspeed_timer and it will freeze on the
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>
19
---
20
hw/timer/aspeed_timer.c | 6 +++++-
21
1 file changed, 5 insertions(+), 1 deletion(-)
22
23
diff --git a/hw/timer/aspeed_timer.c b/hw/timer/aspeed_timer.c
24
index XXXXXXX..XXXXXXX 100644
25
--- a/hw/timer/aspeed_timer.c
26
+++ b/hw/timer/aspeed_timer.c
27
@@ -XXX,XX +XXX,XX @@ static void aspeed_timer_set_value(AspeedTimerCtrlState *s, int timer, int reg,
28
int64_t delta = (int64_t) value - (int64_t) calculate_ticks(t, now);
29
uint32_t rate = calculate_rate(t);
30
31
- t->start += muldiv64(delta, NANOSECONDS_PER_SECOND, rate);
32
+ if (delta >= 0) {
33
+ t->start += muldiv64(delta, NANOSECONDS_PER_SECOND, rate);
34
+ } else {
35
+ t->start -= muldiv64(-delta, NANOSECONDS_PER_SECOND, rate);
36
+ }
37
aspeed_timer_mod(t);
38
}
39
break;
40
--
41
2.20.1
42
43
diff view generated by jsdifflib
Deleted patch
1
From: Cédric Le Goater <clg@kaod.org>
2
1
3
It has never been used as far as I can tell from the git history.
4
5
Signed-off-by: Cédric Le Goater <clg@kaod.org>
6
Reviewed-by: Joel Stanley <joel@jms.id.au>
7
Message-id: 20190618165311.27066-13-clg@kaod.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
hw/arm/aspeed.c | 2 --
11
1 file changed, 2 deletions(-)
12
13
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/arm/aspeed.c
16
+++ b/hw/arm/aspeed.c
17
@@ -XXX,XX +XXX,XX @@ static void aspeed_board_init(MachineState *machine,
18
memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size);
19
memory_region_add_subregion(get_system_memory(),
20
sc->info->memmap[ASPEED_SDRAM], &bmc->ram);
21
- object_property_add_const_link(OBJECT(&bmc->soc), "ram", OBJECT(&bmc->ram),
22
- &error_abort);
23
24
max_ram_size = object_property_get_uint(OBJECT(&bmc->soc), "max-ram-size",
25
&error_abort);
26
--
27
2.20.1
28
29
diff view generated by jsdifflib
Deleted patch
1
From: Cédric Le Goater <clg@kaod.org>
2
1
3
The RAM memory region is defined after the SoC is realized when the
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
8
Introduce a container memory region for the RAM that we can link into
9
the controllers early, before the SoC is realized. It will be
10
populated with the RAM region after the checks have be done.
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>
16
---
17
hw/arm/aspeed.c | 13 +++++++++----
18
1 file changed, 9 insertions(+), 4 deletions(-)
19
20
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
21
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/arm/aspeed.c
23
+++ b/hw/arm/aspeed.c
24
@@ -XXX,XX +XXX,XX @@ static struct arm_boot_info aspeed_board_binfo = {
25
26
struct AspeedBoardState {
27
AspeedSoCState soc;
28
+ MemoryRegion ram_container;
29
MemoryRegion ram;
30
MemoryRegion max_ram;
31
};
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
--
65
2.20.1
66
67
diff view generated by jsdifflib
Deleted patch
1
From: Cédric Le Goater <clg@kaod.org>
2
1
3
The DRAM address of a DMA transaction depends on the DRAM base address
4
of the SoC. Inform the SMC controller model with this value.
5
6
Signed-off-by: Cédric Le Goater <clg@kaod.org>
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
19
--- a/include/hw/ssi/aspeed_smc.h
20
+++ b/include/hw/ssi/aspeed_smc.h
21
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedSMCState {
22
uint8_t r_timings;
23
uint8_t conf_enable_w0;
24
25
+ /* for DMA support */
26
+ uint64_t sdram_base;
27
+
28
AspeedSMCFlash *flashes;
29
30
uint8_t snoop_index;
31
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/hw/arm/aspeed_soc.c
34
+++ b/hw/arm/aspeed_soc.c
35
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
36
aspeed_soc_get_irq(s, ASPEED_I2C));
37
38
/* FMC, The number of CS is set at the board level */
39
+ object_property_set_int(OBJECT(&s->fmc), sc->info->memmap[ASPEED_SDRAM],
40
+ "sdram-base", &err);
41
+ if (err) {
42
+ error_propagate(errp, err);
43
+ return;
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
50
--- a/hw/ssi/aspeed_smc.c
51
+++ b/hw/ssi/aspeed_smc.c
52
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_aspeed_smc = {
53
54
static Property aspeed_smc_properties[] = {
55
DEFINE_PROP_UINT32("num-cs", AspeedSMCState, num_cs, 1),
56
+ DEFINE_PROP_UINT64("sdram-base", AspeedSMCState, sdram_base, 0),
57
DEFINE_PROP_END_OF_LIST(),
58
};
59
60
--
61
2.20.1
62
63
diff view generated by jsdifflib
Deleted patch
1
From: Adriana Kobylak <anoo@us.ibm.com>
2
1
3
The Swift board is an OpenPOWER system hosting POWER processors.
4
Add support for their BMC including the I2C devices as found on HW.
5
6
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
7
Reviewed-by: Cédric Le Goater <clg@kaod.org>
8
Reviewed-by: Joel Stanley <joel@jms.id.au>
9
Message-id: 20190618165311.27066-20-clg@kaod.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
hw/arm/aspeed.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++
13
1 file changed, 50 insertions(+)
14
15
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/aspeed.c
18
+++ b/hw/arm/aspeed.c
19
@@ -XXX,XX +XXX,XX @@ struct AspeedBoardState {
20
SCU_AST2500_HW_STRAP_ACPI_ENABLE | \
21
SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER))
22
23
+/* Swift hardware value: 0xF11AD206 */
24
+#define SWIFT_BMC_HW_STRAP1 ( \
25
+ AST2500_HW_STRAP1_DEFAULTS | \
26
+ SCU_AST2500_HW_STRAP_SPI_AUTOFETCH_ENABLE | \
27
+ SCU_AST2500_HW_STRAP_GPIO_STRAP_ENABLE | \
28
+ SCU_AST2500_HW_STRAP_UART_DEBUG | \
29
+ SCU_AST2500_HW_STRAP_DDR4_ENABLE | \
30
+ SCU_H_PLL_BYPASS_EN | \
31
+ SCU_AST2500_HW_STRAP_ACPI_ENABLE | \
32
+ SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER))
33
+
34
/* Witherspoon hardware value: 0xF10AD216 (but use romulus definition) */
35
#define WITHERSPOON_BMC_HW_STRAP1 ROMULUS_BMC_HW_STRAP1
36
37
@@ -XXX,XX +XXX,XX @@ static void romulus_bmc_i2c_init(AspeedBoardState *bmc)
38
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32);
39
}
40
41
+static void swift_bmc_i2c_init(AspeedBoardState *bmc)
42
+{
43
+ AspeedSoCState *soc = &bmc->soc;
44
+
45
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), "pca9552", 0x60);
46
+
47
+ /* The swift board expects a TMP275 but a TMP105 is compatible */
48
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0x48);
49
+ /* The swift board expects a pca9551 but a pca9552 is compatible */
50
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "pca9552", 0x60);
51
+
52
+ /* The swift board expects an Epson RX8900 RTC but a ds1338 is compatible */
53
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "ds1338", 0x32);
54
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 8), "pca9552", 0x60);
55
+
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
--
91
2.20.1
92
93
diff view generated by jsdifflib
Deleted patch
1
From: Andrew Jeffery <andrew@aj.id.au>
2
1
3
The legacy interface only supported up to 32 IRQs, which became
4
restrictive around the AST2400 generation. QEMU support for the SoCs
5
started with the AST2400 along with an effort to reimplement and
6
upstream drivers for Linux, so up until this point the consumers of the
7
QEMU ASPEED support only required the 64 IRQ register interface.
8
9
In an effort to support older BMC firmware, add support for the 32 IRQ
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
23
--- a/hw/intc/aspeed_vic.c
24
+++ b/hw/intc/aspeed_vic.c
25
@@ -XXX,XX +XXX,XX @@ static void aspeed_vic_set_irq(void *opaque, int irq, int level)
26
27
static uint64_t aspeed_vic_read(void *opaque, hwaddr offset, unsigned size)
28
{
29
- uint64_t val;
30
- const bool high = !!(offset & 0x4);
31
- hwaddr n_offset = (offset & ~0x4);
32
AspeedVICState *s = (AspeedVICState *)opaque;
33
+ hwaddr n_offset;
34
+ uint64_t val;
35
+ bool high;
36
37
if (offset < AVIC_NEW_BASE_OFFSET) {
38
- qemu_log_mask(LOG_UNIMP, "%s: Ignoring read from legacy registers "
39
- "at 0x%" HWADDR_PRIx "[%u]\n", __func__, offset, size);
40
- return 0;
41
+ high = false;
42
+ n_offset = offset;
43
+ } else {
44
+ high = !!(offset & 0x4);
45
+ n_offset = (offset & ~0x4);
46
}
47
48
- n_offset -= AVIC_NEW_BASE_OFFSET;
49
-
50
switch (n_offset) {
51
- case 0x0: /* IRQ Status */
52
+ case 0x80: /* IRQ Status */
53
+ case 0x00:
54
val = s->raw & ~s->select & s->enable;
55
break;
56
- case 0x08: /* FIQ Status */
57
+ case 0x88: /* FIQ Status */
58
+ case 0x04:
59
val = s->raw & s->select & s->enable;
60
break;
61
- case 0x10: /* Raw Interrupt Status */
62
+ case 0x90: /* Raw Interrupt Status */
63
+ case 0x08:
64
val = s->raw;
65
break;
66
- case 0x18: /* Interrupt Selection */
67
+ case 0x98: /* Interrupt Selection */
68
+ case 0x0c:
69
val = s->select;
70
break;
71
- case 0x20: /* Interrupt Enable */
72
+ case 0xa0: /* Interrupt Enable */
73
+ case 0x10:
74
val = s->enable;
75
break;
76
- case 0x30: /* Software Interrupt */
77
+ case 0xb0: /* Software Interrupt */
78
+ case 0x18:
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
--
217
2.20.1
218
219
diff view generated by jsdifflib
Deleted patch
1
From: Joel Stanley <joel@jms.id.au>
2
1
3
The ast2500 uses the watchdog to reset the SDRAM controller. This
4
operation is usually performed by u-boot's memory training procedure,
5
and it is enabled by setting a bit in the SCU and then causing the
6
watchdog to expire. Therefore, we need the watchdog to be able to
7
access the SCU's register space.
8
9
This causes the watchdog to not perform a system reset when the bit is
10
set. In the future it could perform a reset of the SDMC model.
11
12
Signed-off-by: Joel Stanley <joel@jms.id.au>
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
26
--- a/include/hw/watchdog/wdt_aspeed.h
27
+++ b/include/hw/watchdog/wdt_aspeed.h
28
@@ -XXX,XX +XXX,XX @@ typedef struct AspeedWDTState {
29
MemoryRegion iomem;
30
uint32_t regs[ASPEED_WDT_REGS_MAX];
31
32
+ AspeedSCUState *scu;
33
uint32_t pclk_freq;
34
uint32_t silicon_rev;
35
uint32_t ext_pulse_width_mask;
36
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
37
index XXXXXXX..XXXXXXX 100644
38
--- a/hw/arm/aspeed_soc.c
39
+++ b/hw/arm/aspeed_soc.c
40
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj)
41
sizeof(s->wdt[i]), TYPE_ASPEED_WDT);
42
qdev_prop_set_uint32(DEVICE(&s->wdt[i]), "silicon-rev",
43
sc->info->silicon_rev);
44
+ object_property_add_const_link(OBJECT(&s->wdt[i]), "scu",
45
+ OBJECT(&s->scu), &error_abort);
46
}
47
48
for (i = 0; i < ASPEED_MACS_NUM; i++) {
49
diff --git a/hw/watchdog/wdt_aspeed.c b/hw/watchdog/wdt_aspeed.c
50
index XXXXXXX..XXXXXXX 100644
51
--- a/hw/watchdog/wdt_aspeed.c
52
+++ b/hw/watchdog/wdt_aspeed.c
53
@@ -XXX,XX +XXX,XX @@
54
55
#define WDT_RESTART_MAGIC 0x4755
56
57
+#define SCU_RESET_CONTROL1 (0x04 / 4)
58
+#define SCU_RESET_SDRAM BIT(0)
59
+
60
static bool aspeed_wdt_is_enabled(const AspeedWDTState *s)
61
{
62
return s->regs[WDT_CTRL] & WDT_CTRL_ENABLE;
63
@@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_timer_expired(void *dev)
64
{
65
AspeedWDTState *s = ASPEED_WDT(dev);
66
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
+ }
73
+
74
qemu_log_mask(CPU_LOG_RESET, "Watchdog timer expired.\n");
75
watchdog_perform_action();
76
timer_del(s->timer);
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
--
95
2.20.1
96
97
diff view generated by jsdifflib
1
From: Hongbo Zhang <hongbo.zhang@linaro.org>
1
From: Hao Wu <wuhaotsh@google.com>
2
2
3
For AArch64, the existing "virt" machine is primarily meant to
3
We add a qtest for the PWM in the previous patch. It proves it works as
4
run on KVM and execute virtualization workloads, but we need an
4
expected.
5
environment as faithful as possible to physical hardware, for supporting
6
firmware and OS development for physical Aarch64 machines.
7
5
8
This patch introduces new machine type 'sbsa-ref' with main features:
6
Reviewed-by: Havard Skinnemoen <hskinnemoen@google.com>
9
- Based on 'virt' machine type.
7
Reviewed-by: Tyrone Ting <kfting@nuvoton.com>
10
- A new memory map.
8
Signed-off-by: Hao Wu <wuhaotsh@google.com>
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>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 20210108190945.949196-6-wuhaotsh@google.com
41
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
42
---
12
---
43
hw/arm/Makefile.objs | 1 +
13
tests/qtest/npcm7xx_pwm-test.c | 490 +++++++++++++++++++++++++++++++++
44
hw/arm/sbsa-ref.c | 271 ++++++++++++++++++++++++++++
14
tests/qtest/meson.build | 1 +
45
MAINTAINERS | 8 +
15
2 files changed, 491 insertions(+)
46
default-configs/aarch64-softmmu.mak | 1 +
16
create mode 100644 tests/qtest/npcm7xx_pwm-test.c
47
hw/arm/Kconfig | 14 ++
48
5 files changed, 295 insertions(+)
49
create mode 100644 hw/arm/sbsa-ref.c
50
17
51
diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs
18
diff --git a/tests/qtest/npcm7xx_pwm-test.c b/tests/qtest/npcm7xx_pwm-test.c
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
19
new file mode 100644
65
index XXXXXXX..XXXXXXX
20
index XXXXXXX..XXXXXXX
66
--- /dev/null
21
--- /dev/null
67
+++ b/hw/arm/sbsa-ref.c
22
+++ b/tests/qtest/npcm7xx_pwm-test.c
68
@@ -XXX,XX +XXX,XX @@
23
@@ -XXX,XX +XXX,XX @@
69
+/*
24
+/*
70
+ * ARM SBSA Reference Platform emulation
25
+ * QTests for Nuvoton NPCM7xx PWM Modules.
71
+ *
26
+ *
72
+ * Copyright (c) 2018 Linaro Limited
27
+ * Copyright 2020 Google LLC
73
+ * Written by Hongbo Zhang <hongbo.zhang@linaro.org>
74
+ *
28
+ *
75
+ * This program is free software; you can redistribute it and/or modify it
29
+ * 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,
30
+ * 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.
31
+ * Free Software Foundation; either version 2 of the License, or
32
+ * (at your option) any later version.
78
+ *
33
+ *
79
+ * This program is distributed in the hope it will be useful, but WITHOUT
34
+ * 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
35
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
81
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
36
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
82
+ * more details.
37
+ * 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
+ */
38
+ */
87
+
39
+
88
+#include "qemu/osdep.h"
40
+#include "qemu/osdep.h"
89
+#include "qapi/error.h"
41
+#include "qemu/bitops.h"
90
+#include "qemu/error-report.h"
42
+#include "libqos/libqtest.h"
91
+#include "qemu/units.h"
43
+#include "qapi/qmp/qdict.h"
92
+#include "sysemu/numa.h"
44
+#include "qapi/qmp/qnum.h"
93
+#include "sysemu/sysemu.h"
45
+
94
+#include "exec/address-spaces.h"
46
+#define REF_HZ 25000000
95
+#include "exec/hwaddr.h"
47
+
96
+#include "kvm_arm.h"
48
+/* Register field definitions. */
97
+#include "hw/arm/boot.h"
49
+#define CH_EN BIT(0)
98
+#include "hw/boards.h"
50
+#define CH_INV BIT(2)
99
+#include "hw/intc/arm_gicv3_common.h"
51
+#define CH_MOD BIT(3)
100
+
52
+
101
+#define RAMLIMIT_GB 8192
53
+/* Registers shared between all PWMs in a module */
102
+#define RAMLIMIT_BYTES (RAMLIMIT_GB * GiB)
54
+#define PPR 0x00
103
+
55
+#define CSR 0x04
104
+enum {
56
+#define PCR 0x08
105
+ SBSA_FLASH,
57
+#define PIER 0x3c
106
+ SBSA_MEM,
58
+#define PIIR 0x40
107
+ SBSA_CPUPERIPHS,
59
+
108
+ SBSA_GIC_DIST,
60
+/* CLK module related */
109
+ SBSA_GIC_REDIST,
61
+#define CLK_BA 0xf0801000
110
+ SBSA_SMMU,
62
+#define CLKSEL 0x04
111
+ SBSA_UART,
63
+#define CLKDIV1 0x08
112
+ SBSA_RTC,
64
+#define CLKDIV2 0x2c
113
+ SBSA_PCIE,
65
+#define PLLCON0 0x0c
114
+ SBSA_PCIE_MMIO,
66
+#define PLLCON1 0x10
115
+ SBSA_PCIE_MMIO_HIGH,
67
+#define PLL_INDV(rv) extract32((rv), 0, 6)
116
+ SBSA_PCIE_PIO,
68
+#define PLL_FBDV(rv) extract32((rv), 16, 12)
117
+ SBSA_PCIE_ECAM,
69
+#define PLL_OTDV1(rv) extract32((rv), 8, 3)
118
+ SBSA_GPIO,
70
+#define PLL_OTDV2(rv) extract32((rv), 13, 3)
119
+ SBSA_SECURE_UART,
71
+#define APB3CKDIV(rv) extract32((rv), 28, 2)
120
+ SBSA_SECURE_UART_MM,
72
+#define CLK2CKDIV(rv) extract32((rv), 0, 1)
121
+ SBSA_SECURE_MEM,
73
+#define CLK4CKDIV(rv) extract32((rv), 26, 2)
122
+ SBSA_AHCI,
74
+#define CPUCKSEL(rv) extract32((rv), 0, 2)
123
+ SBSA_EHCI,
75
+
76
+#define MAX_DUTY 1000000
77
+
78
+typedef struct PWMModule {
79
+ int irq;
80
+ uint64_t base_addr;
81
+} PWMModule;
82
+
83
+typedef struct PWM {
84
+ uint32_t cnr_offset;
85
+ uint32_t cmr_offset;
86
+ uint32_t pdr_offset;
87
+ uint32_t pwdr_offset;
88
+} PWM;
89
+
90
+typedef struct TestData {
91
+ const PWMModule *module;
92
+ const PWM *pwm;
93
+} TestData;
94
+
95
+static const PWMModule pwm_module_list[] = {
96
+ {
97
+ .irq = 93,
98
+ .base_addr = 0xf0103000
99
+ },
100
+ {
101
+ .irq = 94,
102
+ .base_addr = 0xf0104000
103
+ }
124
+};
104
+};
125
+
105
+
126
+typedef struct MemMapEntry {
106
+static const PWM pwm_list[] = {
127
+ hwaddr base;
107
+ {
128
+ hwaddr size;
108
+ .cnr_offset = 0x0c,
129
+} MemMapEntry;
109
+ .cmr_offset = 0x10,
130
+
110
+ .pdr_offset = 0x14,
131
+typedef struct {
111
+ .pwdr_offset = 0x44,
132
+ MachineState parent;
112
+ },
133
+ struct arm_boot_info bootinfo;
113
+ {
134
+ int smp_cpus;
114
+ .cnr_offset = 0x18,
135
+ void *fdt;
115
+ .cmr_offset = 0x1c,
136
+ int fdt_size;
116
+ .pdr_offset = 0x20,
137
+ int psci_conduit;
117
+ .pwdr_offset = 0x48,
138
+} SBSAMachineState;
118
+ },
139
+
119
+ {
140
+#define TYPE_SBSA_MACHINE MACHINE_TYPE_NAME("sbsa-ref")
120
+ .cnr_offset = 0x24,
141
+#define SBSA_MACHINE(obj) \
121
+ .cmr_offset = 0x28,
142
+ OBJECT_CHECK(SBSAMachineState, (obj), TYPE_SBSA_MACHINE)
122
+ .pdr_offset = 0x2c,
143
+
123
+ .pwdr_offset = 0x4c,
144
+static const MemMapEntry sbsa_ref_memmap[] = {
124
+ },
145
+ /* 512M boot ROM */
125
+ {
146
+ [SBSA_FLASH] = { 0, 0x20000000 },
126
+ .cnr_offset = 0x30,
147
+ /* 512M secure memory */
127
+ .cmr_offset = 0x34,
148
+ [SBSA_SECURE_MEM] = { 0x20000000, 0x20000000 },
128
+ .pdr_offset = 0x38,
149
+ /* Space reserved for CPU peripheral devices */
129
+ .pwdr_offset = 0x50,
150
+ [SBSA_CPUPERIPHS] = { 0x40000000, 0x00040000 },
130
+ },
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
+};
131
+};
172
+
132
+
173
+static void sbsa_ref_init(MachineState *machine)
133
+static const int ppr_base[] = { 0, 0, 8, 8 };
174
+{
134
+static const int csr_base[] = { 0, 4, 8, 12 };
175
+ SBSAMachineState *sms = SBSA_MACHINE(machine);
135
+static const int pcr_base[] = { 0, 8, 12, 16 };
176
+ MachineClass *mc = MACHINE_GET_CLASS(machine);
136
+
177
+ MemoryRegion *sysmem = get_system_memory();
137
+static const uint32_t ppr_list[] = {
178
+ MemoryRegion *secure_sysmem = NULL;
138
+ 0,
179
+ MemoryRegion *ram = g_new(MemoryRegion, 1);
139
+ 1,
180
+ const CPUArchIdList *possible_cpus;
140
+ 10,
181
+ int n, sbsa_max_cpus;
141
+ 100,
182
+
142
+ 255, /* Max possible value. */
183
+ if (strcmp(machine->cpu_type, ARM_CPU_TYPE_NAME("cortex-a57"))) {
143
+};
184
+ error_report("sbsa-ref: CPU type other than the built-in "
144
+
185
+ "cortex-a57 not supported");
145
+static const uint32_t csr_list[] = {
186
+ exit(1);
146
+ 0,
187
+ }
147
+ 1,
188
+
148
+ 2,
189
+ if (kvm_enabled()) {
149
+ 3,
190
+ error_report("sbsa-ref: KVM is not supported for this machine");
150
+ 4, /* Max possible value. */
191
+ exit(1);
151
+};
192
+ }
152
+
193
+
153
+static const uint32_t cnr_list[] = {
194
+ /*
154
+ 0,
195
+ * This machine has EL3 enabled, external firmware should supply PSCI
155
+ 1,
196
+ * implementation, so the QEMU's internal PSCI is disabled.
156
+ 50,
197
+ */
157
+ 100,
198
+ sms->psci_conduit = QEMU_PSCI_CONDUIT_DISABLED;
158
+ 150,
199
+
159
+ 200,
200
+ sbsa_max_cpus = sbsa_ref_memmap[SBSA_GIC_REDIST].size / GICV3_REDIST_SIZE;
160
+ 1000,
201
+
161
+ 10000,
202
+ if (max_cpus > sbsa_max_cpus) {
162
+ 65535, /* Max possible value. */
203
+ error_report("Number of SMP CPUs requested (%d) exceeds max CPUs "
163
+};
204
+ "supported by machine 'sbsa-ref' (%d)",
164
+
205
+ max_cpus, sbsa_max_cpus);
165
+static const uint32_t cmr_list[] = {
206
+ exit(1);
166
+ 0,
207
+ }
167
+ 1,
208
+
168
+ 10,
209
+ sms->smp_cpus = smp_cpus;
169
+ 50,
210
+
170
+ 100,
211
+ if (machine->ram_size > sbsa_ref_memmap[SBSA_MEM].size) {
171
+ 150,
212
+ error_report("sbsa-ref: cannot model more than %dGB RAM", RAMLIMIT_GB);
172
+ 200,
213
+ exit(1);
173
+ 1000,
214
+ }
174
+ 10000,
215
+
175
+ 65535, /* Max possible value. */
216
+ possible_cpus = mc->possible_cpu_arch_ids(machine);
176
+};
217
+ for (n = 0; n < possible_cpus->len; n++) {
177
+
218
+ Object *cpuobj;
178
+/* Returns the index of the PWM module. */
219
+ CPUState *cs;
179
+static int pwm_module_index(const PWMModule *module)
220
+
180
+{
221
+ if (n >= smp_cpus) {
181
+ ptrdiff_t diff = module - pwm_module_list;
222
+ break;
182
+
183
+ g_assert_true(diff >= 0 && diff < ARRAY_SIZE(pwm_module_list));
184
+
185
+ return diff;
186
+}
187
+
188
+/* Returns the index of the PWM entry. */
189
+static int pwm_index(const PWM *pwm)
190
+{
191
+ ptrdiff_t diff = pwm - pwm_list;
192
+
193
+ g_assert_true(diff >= 0 && diff < ARRAY_SIZE(pwm_list));
194
+
195
+ return diff;
196
+}
197
+
198
+static uint64_t pwm_qom_get(QTestState *qts, const char *path, const char *name)
199
+{
200
+ QDict *response;
201
+
202
+ g_test_message("Getting properties %s from %s", name, path);
203
+ response = qtest_qmp(qts, "{ 'execute': 'qom-get',"
204
+ " 'arguments': { 'path': %s, 'property': %s}}",
205
+ path, name);
206
+ /* The qom set message returns successfully. */
207
+ g_assert_true(qdict_haskey(response, "return"));
208
+ return qnum_get_uint(qobject_to(QNum, qdict_get(response, "return")));
209
+}
210
+
211
+static uint64_t pwm_get_freq(QTestState *qts, int module_index, int pwm_index)
212
+{
213
+ char path[100];
214
+ char name[100];
215
+
216
+ sprintf(path, "/machine/soc/pwm[%d]", module_index);
217
+ sprintf(name, "freq[%d]", pwm_index);
218
+
219
+ return pwm_qom_get(qts, path, name);
220
+}
221
+
222
+static uint64_t pwm_get_duty(QTestState *qts, int module_index, int pwm_index)
223
+{
224
+ char path[100];
225
+ char name[100];
226
+
227
+ sprintf(path, "/machine/soc/pwm[%d]", module_index);
228
+ sprintf(name, "duty[%d]", pwm_index);
229
+
230
+ return pwm_qom_get(qts, path, name);
231
+}
232
+
233
+static uint32_t get_pll(uint32_t con)
234
+{
235
+ return REF_HZ * PLL_FBDV(con) / (PLL_INDV(con) * PLL_OTDV1(con)
236
+ * PLL_OTDV2(con));
237
+}
238
+
239
+static uint64_t read_pclk(QTestState *qts)
240
+{
241
+ uint64_t freq = REF_HZ;
242
+ uint32_t clksel = qtest_readl(qts, CLK_BA + CLKSEL);
243
+ uint32_t pllcon;
244
+ uint32_t clkdiv1 = qtest_readl(qts, CLK_BA + CLKDIV1);
245
+ uint32_t clkdiv2 = qtest_readl(qts, CLK_BA + CLKDIV2);
246
+
247
+ switch (CPUCKSEL(clksel)) {
248
+ case 0:
249
+ pllcon = qtest_readl(qts, CLK_BA + PLLCON0);
250
+ freq = get_pll(pllcon);
251
+ break;
252
+ case 1:
253
+ pllcon = qtest_readl(qts, CLK_BA + PLLCON1);
254
+ freq = get_pll(pllcon);
255
+ break;
256
+ case 2:
257
+ break;
258
+ case 3:
259
+ break;
260
+ default:
261
+ g_assert_not_reached();
262
+ }
263
+
264
+ freq >>= (CLK2CKDIV(clkdiv1) + CLK4CKDIV(clkdiv1) + APB3CKDIV(clkdiv2));
265
+
266
+ return freq;
267
+}
268
+
269
+static uint32_t pwm_selector(uint32_t csr)
270
+{
271
+ switch (csr) {
272
+ case 0:
273
+ return 2;
274
+ case 1:
275
+ return 4;
276
+ case 2:
277
+ return 8;
278
+ case 3:
279
+ return 16;
280
+ case 4:
281
+ return 1;
282
+ default:
283
+ g_assert_not_reached();
284
+ }
285
+}
286
+
287
+static uint64_t pwm_compute_freq(QTestState *qts, uint32_t ppr, uint32_t csr,
288
+ uint32_t cnr)
289
+{
290
+ return read_pclk(qts) / ((ppr + 1) * pwm_selector(csr) * (cnr + 1));
291
+}
292
+
293
+static uint64_t pwm_compute_duty(uint32_t cnr, uint32_t cmr, bool inverted)
294
+{
295
+ uint64_t duty;
296
+
297
+ if (cnr == 0) {
298
+ /* PWM is stopped. */
299
+ duty = 0;
300
+ } else if (cmr >= cnr) {
301
+ duty = MAX_DUTY;
302
+ } else {
303
+ duty = MAX_DUTY * (cmr + 1) / (cnr + 1);
304
+ }
305
+
306
+ if (inverted) {
307
+ duty = MAX_DUTY - duty;
308
+ }
309
+
310
+ return duty;
311
+}
312
+
313
+static uint32_t pwm_read(QTestState *qts, const TestData *td, unsigned offset)
314
+{
315
+ return qtest_readl(qts, td->module->base_addr + offset);
316
+}
317
+
318
+static void pwm_write(QTestState *qts, const TestData *td, unsigned offset,
319
+ uint32_t value)
320
+{
321
+ qtest_writel(qts, td->module->base_addr + offset, value);
322
+}
323
+
324
+static uint32_t pwm_read_ppr(QTestState *qts, const TestData *td)
325
+{
326
+ return extract32(pwm_read(qts, td, PPR), ppr_base[pwm_index(td->pwm)], 8);
327
+}
328
+
329
+static void pwm_write_ppr(QTestState *qts, const TestData *td, uint32_t value)
330
+{
331
+ pwm_write(qts, td, PPR, value << ppr_base[pwm_index(td->pwm)]);
332
+}
333
+
334
+static uint32_t pwm_read_csr(QTestState *qts, const TestData *td)
335
+{
336
+ return extract32(pwm_read(qts, td, CSR), csr_base[pwm_index(td->pwm)], 3);
337
+}
338
+
339
+static void pwm_write_csr(QTestState *qts, const TestData *td, uint32_t value)
340
+{
341
+ pwm_write(qts, td, CSR, value << csr_base[pwm_index(td->pwm)]);
342
+}
343
+
344
+static uint32_t pwm_read_pcr(QTestState *qts, const TestData *td)
345
+{
346
+ return extract32(pwm_read(qts, td, PCR), pcr_base[pwm_index(td->pwm)], 4);
347
+}
348
+
349
+static void pwm_write_pcr(QTestState *qts, const TestData *td, uint32_t value)
350
+{
351
+ pwm_write(qts, td, PCR, value << pcr_base[pwm_index(td->pwm)]);
352
+}
353
+
354
+static uint32_t pwm_read_cnr(QTestState *qts, const TestData *td)
355
+{
356
+ return pwm_read(qts, td, td->pwm->cnr_offset);
357
+}
358
+
359
+static void pwm_write_cnr(QTestState *qts, const TestData *td, uint32_t value)
360
+{
361
+ pwm_write(qts, td, td->pwm->cnr_offset, value);
362
+}
363
+
364
+static uint32_t pwm_read_cmr(QTestState *qts, const TestData *td)
365
+{
366
+ return pwm_read(qts, td, td->pwm->cmr_offset);
367
+}
368
+
369
+static void pwm_write_cmr(QTestState *qts, const TestData *td, uint32_t value)
370
+{
371
+ pwm_write(qts, td, td->pwm->cmr_offset, value);
372
+}
373
+
374
+/* Check pwm registers can be reset to default value */
375
+static void test_init(gconstpointer test_data)
376
+{
377
+ const TestData *td = test_data;
378
+ QTestState *qts = qtest_init("-machine quanta-gsj");
379
+ int module = pwm_module_index(td->module);
380
+ int pwm = pwm_index(td->pwm);
381
+
382
+ g_assert_cmpuint(pwm_get_freq(qts, module, pwm), ==, 0);
383
+ g_assert_cmpuint(pwm_get_duty(qts, module, pwm), ==, 0);
384
+
385
+ qtest_quit(qts);
386
+}
387
+
388
+/* One-shot mode should not change frequency and duty cycle. */
389
+static void test_oneshot(gconstpointer test_data)
390
+{
391
+ const TestData *td = test_data;
392
+ QTestState *qts = qtest_init("-machine quanta-gsj");
393
+ int module = pwm_module_index(td->module);
394
+ int pwm = pwm_index(td->pwm);
395
+ uint32_t ppr, csr, pcr;
396
+ int i, j;
397
+
398
+ pcr = CH_EN;
399
+ for (i = 0; i < ARRAY_SIZE(ppr_list); ++i) {
400
+ ppr = ppr_list[i];
401
+ pwm_write_ppr(qts, td, ppr);
402
+
403
+ for (j = 0; j < ARRAY_SIZE(csr_list); ++j) {
404
+ csr = csr_list[j];
405
+ pwm_write_csr(qts, td, csr);
406
+ pwm_write_pcr(qts, td, pcr);
407
+
408
+ g_assert_cmpuint(pwm_read_ppr(qts, td), ==, ppr);
409
+ g_assert_cmpuint(pwm_read_csr(qts, td), ==, csr);
410
+ g_assert_cmpuint(pwm_read_pcr(qts, td), ==, pcr);
411
+ g_assert_cmpuint(pwm_get_freq(qts, module, pwm), ==, 0);
412
+ g_assert_cmpuint(pwm_get_duty(qts, module, pwm), ==, 0);
223
+ }
413
+ }
224
+
414
+ }
225
+ cpuobj = object_new(possible_cpus->cpus[n].type);
415
+
226
+ object_property_set_int(cpuobj, possible_cpus->cpus[n].arch_id,
416
+ qtest_quit(qts);
227
+ "mp-affinity", NULL);
417
+}
228
+
418
+
229
+ cs = CPU(cpuobj);
419
+/* In toggle mode, the PWM generates correct outputs. */
230
+ cs->cpu_index = n;
420
+static void test_toggle(gconstpointer test_data)
231
+
421
+{
232
+ numa_cpu_pre_plug(&possible_cpus->cpus[cs->cpu_index], DEVICE(cpuobj),
422
+ const TestData *td = test_data;
233
+ &error_fatal);
423
+ QTestState *qts = qtest_init("-machine quanta-gsj");
234
+
424
+ int module = pwm_module_index(td->module);
235
+ if (object_property_find(cpuobj, "reset-cbar", NULL)) {
425
+ int pwm = pwm_index(td->pwm);
236
+ object_property_set_int(cpuobj,
426
+ uint32_t ppr, csr, pcr, cnr, cmr;
237
+ sbsa_ref_memmap[SBSA_CPUPERIPHS].base,
427
+ int i, j, k, l;
238
+ "reset-cbar", &error_abort);
428
+ uint64_t expected_freq, expected_duty;
429
+
430
+ pcr = CH_EN | CH_MOD;
431
+ for (i = 0; i < ARRAY_SIZE(ppr_list); ++i) {
432
+ ppr = ppr_list[i];
433
+ pwm_write_ppr(qts, td, ppr);
434
+
435
+ for (j = 0; j < ARRAY_SIZE(csr_list); ++j) {
436
+ csr = csr_list[j];
437
+ pwm_write_csr(qts, td, csr);
438
+
439
+ for (k = 0; k < ARRAY_SIZE(cnr_list); ++k) {
440
+ cnr = cnr_list[k];
441
+ pwm_write_cnr(qts, td, cnr);
442
+
443
+ for (l = 0; l < ARRAY_SIZE(cmr_list); ++l) {
444
+ cmr = cmr_list[l];
445
+ pwm_write_cmr(qts, td, cmr);
446
+ expected_freq = pwm_compute_freq(qts, ppr, csr, cnr);
447
+ expected_duty = pwm_compute_duty(cnr, cmr, false);
448
+
449
+ pwm_write_pcr(qts, td, pcr);
450
+ g_assert_cmpuint(pwm_read_ppr(qts, td), ==, ppr);
451
+ g_assert_cmpuint(pwm_read_csr(qts, td), ==, csr);
452
+ g_assert_cmpuint(pwm_read_pcr(qts, td), ==, pcr);
453
+ g_assert_cmpuint(pwm_read_cnr(qts, td), ==, cnr);
454
+ g_assert_cmpuint(pwm_read_cmr(qts, td), ==, cmr);
455
+ g_assert_cmpuint(pwm_get_duty(qts, module, pwm),
456
+ ==, expected_duty);
457
+ if (expected_duty != 0 && expected_duty != 100) {
458
+ /* Duty cycle with 0 or 100 doesn't need frequency. */
459
+ g_assert_cmpuint(pwm_get_freq(qts, module, pwm),
460
+ ==, expected_freq);
461
+ }
462
+
463
+ /* Test inverted mode */
464
+ expected_duty = pwm_compute_duty(cnr, cmr, true);
465
+ pwm_write_pcr(qts, td, pcr | CH_INV);
466
+ g_assert_cmpuint(pwm_read_pcr(qts, td), ==, pcr | CH_INV);
467
+ g_assert_cmpuint(pwm_get_duty(qts, module, pwm),
468
+ ==, expected_duty);
469
+ if (expected_duty != 0 && expected_duty != 100) {
470
+ /* Duty cycle with 0 or 100 doesn't need frequency. */
471
+ g_assert_cmpuint(pwm_get_freq(qts, module, pwm),
472
+ ==, expected_freq);
473
+ }
474
+
475
+ }
476
+ }
239
+ }
477
+ }
240
+
478
+ }
241
+ object_property_set_link(cpuobj, OBJECT(sysmem), "memory",
479
+
242
+ &error_abort);
480
+ qtest_quit(qts);
243
+
481
+}
244
+ object_property_set_link(cpuobj, OBJECT(secure_sysmem),
482
+
245
+ "secure-memory", &error_abort);
483
+static void pwm_add_test(const char *name, const TestData* td,
246
+
484
+ GTestDataFunc fn)
247
+ object_property_set_bool(cpuobj, true, "realized", &error_fatal);
485
+{
248
+ object_unref(cpuobj);
486
+ g_autofree char *full_name = g_strdup_printf(
249
+ }
487
+ "npcm7xx_pwm/module[%d]/pwm[%d]/%s", pwm_module_index(td->module),
250
+
488
+ pwm_index(td->pwm), name);
251
+ memory_region_allocate_system_memory(ram, NULL, "sbsa-ref.ram",
489
+ qtest_add_data_func(full_name, td, fn);
252
+ machine->ram_size);
490
+}
253
+ memory_region_add_subregion(sysmem, sbsa_ref_memmap[SBSA_MEM].base, ram);
491
+#define add_test(name, td) pwm_add_test(#name, td, test_##name)
254
+
492
+
255
+ sms->bootinfo.ram_size = machine->ram_size;
493
+int main(int argc, char **argv)
256
+ sms->bootinfo.kernel_filename = machine->kernel_filename;
494
+{
257
+ sms->bootinfo.nb_cpus = smp_cpus;
495
+ TestData test_data_list[ARRAY_SIZE(pwm_module_list) * ARRAY_SIZE(pwm_list)];
258
+ sms->bootinfo.board_id = -1;
496
+
259
+ sms->bootinfo.loader_start = sbsa_ref_memmap[SBSA_MEM].base;
497
+ g_test_init(&argc, &argv, NULL);
260
+ arm_load_kernel(ARM_CPU(first_cpu), &sms->bootinfo);
498
+
261
+}
499
+ for (int i = 0; i < ARRAY_SIZE(pwm_module_list); ++i) {
262
+
500
+ for (int j = 0; j < ARRAY_SIZE(pwm_list); ++j) {
263
+static uint64_t sbsa_ref_cpu_mp_affinity(SBSAMachineState *sms, int idx)
501
+ TestData *td = &test_data_list[i * ARRAY_SIZE(pwm_list) + j];
264
+{
502
+
265
+ uint8_t clustersz = ARM_DEFAULT_CPUS_PER_CLUSTER;
503
+ td->module = &pwm_module_list[i];
266
+ return arm_cpu_mp_affinity(idx, clustersz);
504
+ td->pwm = &pwm_list[j];
267
+}
505
+
268
+
506
+ add_test(init, td);
269
+static const CPUArchIdList *sbsa_ref_possible_cpu_arch_ids(MachineState *ms)
507
+ add_test(oneshot, td);
270
+{
508
+ add_test(toggle, td);
271
+ SBSAMachineState *sms = SBSA_MACHINE(ms);
509
+ }
272
+ int n;
510
+ }
273
+
511
+
274
+ if (ms->possible_cpus) {
512
+ return g_test_run();
275
+ assert(ms->possible_cpus->len == max_cpus);
513
+}
276
+ return ms->possible_cpus;
514
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
277
+ }
278
+
279
+ ms->possible_cpus = g_malloc0(sizeof(CPUArchIdList) +
280
+ sizeof(CPUArchId) * max_cpus);
281
+ ms->possible_cpus->len = max_cpus;
282
+ for (n = 0; n < ms->possible_cpus->len; n++) {
283
+ ms->possible_cpus->cpus[n].type = ms->cpu_type;
284
+ ms->possible_cpus->cpus[n].arch_id =
285
+ sbsa_ref_cpu_mp_affinity(sms, n);
286
+ ms->possible_cpus->cpus[n].props.has_thread_id = true;
287
+ ms->possible_cpus->cpus[n].props.thread_id = n;
288
+ }
289
+ return ms->possible_cpus;
290
+}
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
341
index XXXXXXX..XXXXXXX 100644
515
index XXXXXXX..XXXXXXX 100644
342
--- a/MAINTAINERS
516
--- a/tests/qtest/meson.build
343
+++ b/MAINTAINERS
517
+++ b/tests/qtest/meson.build
344
@@ -XXX,XX +XXX,XX @@ F: include/hw/arm/fsl-imx6.h
518
@@ -XXX,XX +XXX,XX @@ qtests_sparc64 = \
345
F: include/hw/misc/imx6_*.h
519
qtests_npcm7xx = \
346
F: include/hw/ssi/imx_spi.h
520
['npcm7xx_adc-test',
347
521
'npcm7xx_gpio-test',
348
+SBSA-REF
522
+ 'npcm7xx_pwm-test',
349
+M: Radoslaw Biernacki <radoslaw.biernacki@linaro.org>
523
'npcm7xx_rng-test',
350
+M: Peter Maydell <peter.maydell@linaro.org>
524
'npcm7xx_timer-test',
351
+R: Leif Lindholm <leif.lindholm@linaro.org>
525
'npcm7xx_watchdog_timer-test']
352
+L: qemu-arm@nongnu.org
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
361
--- a/default-configs/aarch64-softmmu.mak
362
+++ b/default-configs/aarch64-softmmu.mak
363
@@ -XXX,XX +XXX,XX @@ include arm-softmmu.mak
364
365
CONFIG_XLNX_ZYNQMP_ARM=y
366
CONFIG_XLNX_VERSAL=y
367
+CONFIG_SBSA_REF=y
368
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
369
index XXXXXXX..XXXXXXX 100644
370
--- a/hw/arm/Kconfig
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
--
526
--
394
2.20.1
527
2.20.1
395
528
396
529
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
1
3
Group Aarch64 rules together, TCG related ones at the bottom.
4
This will help when restricting TCG-only objects.
5
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-2-philmd@redhat.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/Makefile.objs | 5 +++--
12
1 file changed, 3 insertions(+), 2 deletions(-)
13
14
diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/Makefile.objs
17
+++ b/target/arm/Makefile.objs
18
@@ -XXX,XX +XXX,XX @@ obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
19
obj-y += translate.o op_helper.o helper.o cpu.o
20
obj-y += neon_helper.o iwmmxt_helper.o vec_helper.o vfp_helper.o
21
obj-y += gdbstub.o
22
-obj-$(TARGET_AARCH64) += cpu64.o translate-a64.o helper-a64.o gdbstub64.o
23
-obj-$(TARGET_AARCH64) += pauth_helper.o
24
+obj-$(TARGET_AARCH64) += cpu64.o gdbstub64.o
25
obj-y += crypto_helper.o
26
obj-$(CONFIG_SOFTMMU) += arm-powerctl.o
27
28
@@ -XXX,XX +XXX,XX @@ target/arm/translate-sve.o: target/arm/decode-sve.inc.c
29
target/arm/translate.o: target/arm/decode-vfp.inc.c
30
target/arm/translate.o: target/arm/decode-vfp-uncond.inc.c
31
32
+obj-$(TARGET_AARCH64) += translate-a64.o helper-a64.o
33
obj-$(TARGET_AARCH64) += translate-sve.o sve_helper.o
34
+obj-$(TARGET_AARCH64) += pauth_helper.o
35
--
36
2.20.1
37
38
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
1
3
Group ARM objects together, TCG related ones at the bottom.
4
This will help when restricting TCG-only objects.
5
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-3-philmd@redhat.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/Makefile.objs | 10 ++++++----
12
1 file changed, 6 insertions(+), 4 deletions(-)
13
14
diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/Makefile.objs
17
+++ b/target/arm/Makefile.objs
18
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_KVM) += kvm.o
19
obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o
20
obj-$(call land,$(CONFIG_KVM),$(TARGET_AARCH64)) += kvm64.o
21
obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
22
-obj-y += translate.o op_helper.o helper.o cpu.o
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
+
40
obj-$(TARGET_AARCH64) += translate-a64.o helper-a64.o
41
obj-$(TARGET_AARCH64) += translate-sve.o sve_helper.o
42
obj-$(TARGET_AARCH64) += pauth_helper.o
43
--
44
2.20.1
45
46
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
1
3
Group KVM rules together.
4
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-4-philmd@redhat.com
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
target/arm/Makefile.objs | 9 +++++----
11
1 file changed, 5 insertions(+), 4 deletions(-)
12
13
diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/Makefile.objs
16
+++ b/target/arm/Makefile.objs
17
@@ -XXX,XX +XXX,XX @@
18
obj-y += arm-semi.o
19
obj-$(CONFIG_SOFTMMU) += machine.o psci.o arch_dump.o monitor.o
20
-obj-$(CONFIG_KVM) += kvm.o
21
-obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o
22
-obj-$(call land,$(CONFIG_KVM),$(TARGET_AARCH64)) += kvm64.o
23
-obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
24
obj-y += helper.o vfp_helper.o
25
obj-y += cpu.o gdbstub.o
26
obj-$(TARGET_AARCH64) += cpu64.o gdbstub64.o
27
obj-$(CONFIG_SOFTMMU) += arm-powerctl.o
28
29
+obj-$(CONFIG_KVM) += kvm.o
30
+obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o
31
+obj-$(call land,$(CONFIG_KVM),$(TARGET_AARCH64)) += kvm64.o
32
+obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
33
+
34
DECODETREE = $(SRC_PATH)/scripts/decodetree.py
35
36
target/arm/decode-sve.inc.c: $(SRC_PATH)/target/arm/sve.decode $(DECODETREE)
37
--
38
2.20.1
39
40
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Hao Wu <wuhaotsh@google.com>
2
2
3
Since commit 8c06fbdf36b checkpatch.pl enforce a new multiline
3
A device shouldn't access its parent object which is QOM internal.
4
comment syntax. Since we'll move this code around, fix its style
4
Instead it should use type cast for this purporse. This patch fixes this
5
first.
5
issue for all NPCM7XX Devices.
6
6
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Hao Wu <wuhaotsh@google.com>
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20190701132516.26392-8-philmd@redhat.com
9
Message-id: 20210108190945.949196-7-wuhaotsh@google.com
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/helper.c | 237 ++++++++++++++++++++++++++--------------
12
hw/arm/npcm7xx_boards.c | 2 +-
13
target/arm/op_helper.c | 54 ++++++---
13
hw/mem/npcm7xx_mc.c | 2 +-
14
target/arm/vfp_helper.c | 3 +-
14
hw/misc/npcm7xx_clk.c | 2 +-
15
3 files changed, 196 insertions(+), 98 deletions(-)
15
hw/misc/npcm7xx_gcr.c | 2 +-
16
hw/misc/npcm7xx_rng.c | 2 +-
17
hw/nvram/npcm7xx_otp.c | 2 +-
18
hw/ssi/npcm7xx_fiu.c | 2 +-
19
7 files changed, 7 insertions(+), 7 deletions(-)
16
20
17
diff --git a/target/arm/helper.c b/target/arm/helper.c
21
diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c
18
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/helper.c
23
--- a/hw/arm/npcm7xx_boards.c
20
+++ b/target/arm/helper.c
24
+++ b/hw/arm/npcm7xx_boards.c
21
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr)
25
@@ -XXX,XX +XXX,XX @@ static NPCM7xxState *npcm7xx_create_soc(MachineState *machine,
22
26
uint32_t hw_straps)
23
uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
24
{
27
{
25
- /* The TT instructions can be used by unprivileged code, but in
28
NPCM7xxMachineClass *nmc = NPCM7XX_MACHINE_GET_CLASS(machine);
26
+ /*
29
- MachineClass *mc = &nmc->parent;
27
+ * The TT instructions can be used by unprivileged code, but in
30
+ MachineClass *mc = MACHINE_CLASS(nmc);
28
* user-only emulation we don't have the MPU.
31
Object *obj;
29
* Luckily since we know we are NonSecure unprivileged (and that in
32
30
* turn means that the A flag wasn't specified), all the bits in the
33
if (strcmp(machine->cpu_type, mc->default_cpu_type) != 0) {
31
@@ -XXX,XX +XXX,XX @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value,
34
diff --git a/hw/mem/npcm7xx_mc.c b/hw/mem/npcm7xx_mc.c
32
return true;
35
index XXXXXXX..XXXXXXX 100644
33
36
--- a/hw/mem/npcm7xx_mc.c
34
pend_fault:
37
+++ b/hw/mem/npcm7xx_mc.c
35
- /* By pending the exception at this point we are making
38
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_mc_realize(DeviceState *dev, Error **errp)
36
+ /*
39
37
+ * By pending the exception at this point we are making
40
memory_region_init_io(&s->mmio, OBJECT(s), &npcm7xx_mc_ops, s, "regs",
38
* the IMPDEF choice "overridden exceptions pended" (see the
41
NPCM7XX_MC_REGS_SIZE);
39
* MergeExcInfo() pseudocode). The other choice would be to not
42
- sysbus_init_mmio(&s->parent, &s->mmio);
40
* pend them now and then make a choice about which to throw away
43
+ sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->mmio);
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
}
44
}
54
45
55
-/* Write to v7M CONTROL.SPSEL bit for the specified security bank.
46
static void npcm7xx_mc_class_init(ObjectClass *klass, void *data)
56
+/*
47
diff --git a/hw/misc/npcm7xx_clk.c b/hw/misc/npcm7xx_clk.c
57
+ * Write to v7M CONTROL.SPSEL bit for the specified security bank.
48
index XXXXXXX..XXXXXXX 100644
58
* This may change the current stack pointer between Main and Process
49
--- a/hw/misc/npcm7xx_clk.c
59
* stack pointers if it is done for the CONTROL register for the current
50
+++ b/hw/misc/npcm7xx_clk.c
60
* security state.
51
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_clk_init(Object *obj)
61
@@ -XXX,XX +XXX,XX @@ static void write_v7m_control_spsel_for_secstate(CPUARMState *env,
52
62
}
53
memory_region_init_io(&s->iomem, obj, &npcm7xx_clk_ops, s,
54
TYPE_NPCM7XX_CLK, 4 * KiB);
55
- sysbus_init_mmio(&s->parent, &s->iomem);
56
+ sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem);
63
}
57
}
64
58
65
-/* Write to v7M CONTROL.SPSEL bit. This may change the current
59
static int npcm7xx_clk_post_load(void *opaque, int version_id)
66
+/*
60
diff --git a/hw/misc/npcm7xx_gcr.c b/hw/misc/npcm7xx_gcr.c
67
+ * Write to v7M CONTROL.SPSEL bit. This may change the current
61
index XXXXXXX..XXXXXXX 100644
68
* stack pointer between Main and Process stack pointers.
62
--- a/hw/misc/npcm7xx_gcr.c
69
*/
63
+++ b/hw/misc/npcm7xx_gcr.c
70
static void write_v7m_control_spsel(CPUARMState *env, bool new_spsel)
64
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_gcr_init(Object *obj)
71
@@ -XXX,XX +XXX,XX @@ static void write_v7m_control_spsel(CPUARMState *env, bool new_spsel)
65
72
66
memory_region_init_io(&s->iomem, obj, &npcm7xx_gcr_ops, s,
73
void write_v7m_exception(CPUARMState *env, uint32_t new_exc)
67
TYPE_NPCM7XX_GCR, 4 * KiB);
68
- sysbus_init_mmio(&s->parent, &s->iomem);
69
+ sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem);
70
}
71
72
static const VMStateDescription vmstate_npcm7xx_gcr = {
73
diff --git a/hw/misc/npcm7xx_rng.c b/hw/misc/npcm7xx_rng.c
74
index XXXXXXX..XXXXXXX 100644
75
--- a/hw/misc/npcm7xx_rng.c
76
+++ b/hw/misc/npcm7xx_rng.c
77
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_rng_init(Object *obj)
78
79
memory_region_init_io(&s->iomem, obj, &npcm7xx_rng_ops, s, "regs",
80
NPCM7XX_RNG_REGS_SIZE);
81
- sysbus_init_mmio(&s->parent, &s->iomem);
82
+ sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem);
83
}
84
85
static const VMStateDescription vmstate_npcm7xx_rng = {
86
diff --git a/hw/nvram/npcm7xx_otp.c b/hw/nvram/npcm7xx_otp.c
87
index XXXXXXX..XXXXXXX 100644
88
--- a/hw/nvram/npcm7xx_otp.c
89
+++ b/hw/nvram/npcm7xx_otp.c
90
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_otp_realize(DeviceState *dev, Error **errp)
74
{
91
{
75
- /* Write a new value to v7m.exception, thus transitioning into or out
92
NPCM7xxOTPClass *oc = NPCM7XX_OTP_GET_CLASS(dev);
76
+ /*
93
NPCM7xxOTPState *s = NPCM7XX_OTP(dev);
77
+ * Write a new value to v7m.exception, thus transitioning into or out
94
- SysBusDevice *sbd = &s->parent;
78
* of Handler mode; this may result in a change of active stack pointer.
95
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
79
*/
96
80
bool new_is_psp, old_is_psp = v7m_using_psp(env);
97
memset(s->array, 0, sizeof(s->array));
81
@@ -XXX,XX +XXX,XX @@ static void switch_v7m_security_state(CPUARMState *env, bool new_secstate)
98
82
return;
99
diff --git a/hw/ssi/npcm7xx_fiu.c b/hw/ssi/npcm7xx_fiu.c
83
}
100
index XXXXXXX..XXXXXXX 100644
84
101
--- a/hw/ssi/npcm7xx_fiu.c
85
- /* All the banked state is accessed by looking at env->v7m.secure
102
+++ b/hw/ssi/npcm7xx_fiu.c
86
+ /*
103
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_fiu_hold_reset(Object *obj)
87
+ * All the banked state is accessed by looking at env->v7m.secure
104
static void npcm7xx_fiu_realize(DeviceState *dev, Error **errp)
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
{
105
{
95
- /* Handle v7M BXNS:
106
NPCM7xxFIUState *s = NPCM7XX_FIU(dev);
96
+ /*
107
- SysBusDevice *sbd = &s->parent;
97
+ * Handle v7M BXNS:
108
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
98
* - if the return value is a magic value, do exception return (like BX)
109
int i;
99
* - otherwise bit 0 of the return value is the target security state
110
100
*/
111
if (s->cs_count <= 0) {
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
}
596
597
-/* Function used to synchronize QEMU's AArch64 register set with AArch32
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
--
112
--
988
2.20.1
113
2.20.1
989
114
990
115
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Roman Bolshakov <r.bolshakov@yadro.com>
2
2
3
Group SOFTMMU objects together.
3
ui/cocoa.m:1188:44: warning: 'openFile:' is deprecated: first deprecated in macOS 11.0 - Use -[NSWorkspace openURL:] instead.
4
Since PSCI is TCG specific, keep it separate.
4
[-Wdeprecated-declarations]
5
if ([[NSWorkspace sharedWorkspace] openFile: full_file_path] == YES) {
6
^
7
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSWorkspace.h:350:1: note:
8
'openFile:' has been explicitly marked deprecated here
9
- (BOOL)openFile:(NSString *)fullPath API_DEPRECATED("Use -[NSWorkspace openURL:] instead.", macos(10.0, 11.0));
10
^
5
11
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
12
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20190701132516.26392-5-philmd@redhat.com
14
Message-id: 20210102150718.47618-1-r.bolshakov@yadro.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
16
---
11
target/arm/Makefile.objs | 5 ++++-
17
ui/cocoa.m | 5 ++++-
12
1 file changed, 4 insertions(+), 1 deletion(-)
18
1 file changed, 4 insertions(+), 1 deletion(-)
13
19
14
diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs
20
diff --git a/ui/cocoa.m b/ui/cocoa.m
15
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/Makefile.objs
22
--- a/ui/cocoa.m
17
+++ b/target/arm/Makefile.objs
23
+++ b/ui/cocoa.m
18
@@ -XXX,XX +XXX,XX @@
24
@@ -XXX,XX +XXX,XX @@ QemuCocoaView *cocoaView;
19
obj-y += arm-semi.o
25
/* Where to look for local files */
20
-obj-$(CONFIG_SOFTMMU) += machine.o psci.o arch_dump.o monitor.o
26
NSString *path_array[] = {@"../share/doc/qemu/", @"../doc/qemu/", @"docs/"};
21
obj-y += helper.o vfp_helper.o
27
NSString *full_file_path;
22
obj-y += cpu.o gdbstub.o
28
+ NSURL *full_file_url;
23
obj-$(TARGET_AARCH64) += cpu64.o gdbstub64.o
29
24
+
30
/* iterate thru the possible paths until the file is found */
25
+obj-$(CONFIG_SOFTMMU) += machine.o arch_dump.o monitor.o
31
int index;
26
obj-$(CONFIG_SOFTMMU) += arm-powerctl.o
32
@@ -XXX,XX +XXX,XX @@ QemuCocoaView *cocoaView;
27
33
full_file_path = [full_file_path stringByDeletingLastPathComponent];
28
obj-$(CONFIG_KVM) += kvm.o
34
full_file_path = [NSString stringWithFormat: @"%@/%@%@", full_file_path,
29
@@ -XXX,XX +XXX,XX @@ obj-y += translate.o op_helper.o
35
path_array[index], filename];
30
obj-y += crypto_helper.o
36
- if ([[NSWorkspace sharedWorkspace] openFile: full_file_path] == YES) {
31
obj-y += iwmmxt_helper.o vec_helper.o neon_helper.o
37
+ full_file_url = [NSURL fileURLWithPath: full_file_path
32
38
+ isDirectory: false];
33
+obj-$(CONFIG_SOFTMMU) += psci.o
39
+ if ([[NSWorkspace sharedWorkspace] openURL: full_file_url] == YES) {
34
+
40
return;
35
obj-$(TARGET_AARCH64) += translate-a64.o helper-a64.o
41
}
36
obj-$(TARGET_AARCH64) += translate-sve.o sve_helper.o
42
}
37
obj-$(TARGET_AARCH64) += pauth_helper.o
38
--
43
--
39
2.20.1
44
2.20.1
40
45
41
46
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
1
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>
9
---
10
target/arm/helper.c | 7 +++++++
11
1 file changed, 7 insertions(+)
12
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
16
+++ b/target/arm/helper.c
17
@@ -XXX,XX +XXX,XX @@
18
+/*
19
+ * ARM generic helpers.
20
+ *
21
+ * This code is licensed under the GNU GPL v2 or later.
22
+ *
23
+ * SPDX-License-Identifier: GPL-2.0-or-later
24
+ */
25
#include "qemu/osdep.h"
26
#include "qemu/units.h"
27
#include "target/arm/idau.h"
28
--
29
2.20.1
30
31
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
1
3
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
Message-id: 20190701132516.26392-7-philmd@redhat.com
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
target/arm/helper.c | 2 --
9
1 file changed, 2 deletions(-)
10
11
diff --git a/target/arm/helper.c b/target/arm/helper.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/helper.c
14
+++ b/target/arm/helper.c
15
@@ -XXX,XX +XXX,XX @@
16
#include "exec/gdbstub.h"
17
#include "exec/helper-proto.h"
18
#include "qemu/host-utils.h"
19
-#include "sysemu/arch_init.h"
20
#include "sysemu/sysemu.h"
21
#include "qemu/bitops.h"
22
#include "qemu/crc32c.h"
23
@@ -XXX,XX +XXX,XX @@
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
--
32
2.20.1
33
34
diff view generated by jsdifflib