1
The following changes since commit 9435a8b3dd35f1f926f1b9127e8a906217a5518a:
1
From: Alistair Francis <alistair.francis@wdc.com>
2
2
3
Merge remote-tracking branch 'remotes/kraxel/tags/sirius/ipxe-20200908-pull-request' into staging (2020-09-08 21:21:13 +0100)
3
The following changes since commit 4c127fdbe81d66e7cafed90908d0fd1f6f2a6cd0:
4
5
Merge remote-tracking branch 'remotes/rth/tags/pull-arm-20211021' into staging (2021-10-21 09:53:27 -0700)
4
6
5
are available in the Git repository at:
7
are available in the Git repository at:
6
8
7
git@github.com:alistair23/qemu.git tags/pull-riscv-to-apply-20200910
9
git@github.com:alistair23/qemu.git tags/pull-riscv-to-apply-20211022-2
8
10
9
for you to fetch changes up to 7595a65818ea9b49c36650a8c217a1ef9bd6e62a:
11
for you to fetch changes up to 11ec06f9eaedc801ded34c79861367b76ab2b731:
10
12
11
hw/riscv: Sort the Kconfig options in alphabetical order (2020-09-09 15:54:19 -0700)
13
hw/riscv: spike: Use MachineState::ram and MachineClass::default_ram_id (2021-10-22 23:35:47 +1000)
12
14
13
----------------------------------------------------------------
15
----------------------------------------------------------------
14
This PR includes multiple fixes and features for RISC-V:
16
Fourth RISC-V PR for QEMU 6.2
15
- Fixes a bug in printing trap causes
17
16
- Allows 16-bit writes to the SiFive test device. This fixes the
18
- Vector extension bug fixes
17
failure to reboot the RISC-V virt machine
19
- Bit manipulation extension bug fix
18
- Support for the Microchip PolarFire SoC and Icicle Kit
20
- Support vhost-user and numa mem options on all boards
19
- A reafactor of RISC-V code out of hw/riscv
21
- Rationalise XLEN and operand lengths
22
- Bump the OpenTitan FPGA support
23
- Remove the Ibex PLIC
24
- General code cleanup
20
25
21
----------------------------------------------------------------
26
----------------------------------------------------------------
22
Bin Meng (28):
27
Alistair Francis (7):
23
target/riscv: cpu: Add a new 'resetvec' property
28
target/riscv: Remove some unused macros
24
hw/riscv: hart: Add a new 'resetvec' property
29
target/riscv: Organise the CPU properties
25
target/riscv: cpu: Set reset vector based on the configured property value
30
hw/riscv: opentitan: Update to the latest build
26
hw/riscv: Initial support for Microchip PolarFire SoC Icicle Kit board
31
hw/intc: Remove the Ibex PLIC
27
hw/char: Add Microchip PolarFire SoC MMUART emulation
32
hw/intc: sifive_plic: Move the properties
28
hw/riscv: microchip_pfsoc: Connect 5 MMUARTs
33
hw/intc: sifive_plic: Cleanup the realize function
29
hw/sd: Add Cadence SDHCI emulation
34
hw/intc: sifive_plic: Cleanup the irq_request function
30
hw/riscv: microchip_pfsoc: Connect a Cadence SDHCI controller and an SD card
31
hw/dma: Add SiFive platform DMA controller emulation
32
hw/riscv: microchip_pfsoc: Connect a DMA controller
33
hw/net: cadence_gem: Add a new 'phy-addr' property
34
hw/arm: xlnx: Set all boards' GEM 'phy-addr' property value to 23
35
hw/riscv: microchip_pfsoc: Connect 2 Cadence GEMs
36
hw/riscv: microchip_pfsoc: Hook GPIO controllers
37
hw/riscv: clint: Avoid using hard-coded timebase frequency
38
hw/riscv: sifive_u: Connect a DMA controller
39
hw/riscv: Move sifive_e_prci model to hw/misc
40
hw/riscv: Move sifive_u_prci model to hw/misc
41
hw/riscv: Move sifive_u_otp model to hw/misc
42
hw/riscv: Move sifive_gpio model to hw/gpio
43
hw/riscv: Move sifive_clint model to hw/intc
44
hw/riscv: Move sifive_plic model to hw/intc
45
hw/riscv: Move riscv_htif model to hw/char
46
hw/riscv: Move sifive_uart model to hw/char
47
hw/riscv: Move sifive_test model to hw/misc
48
hw/riscv: Always build riscv_hart.c
49
hw/riscv: Drop CONFIG_SIFIVE
50
hw/riscv: Sort the Kconfig options in alphabetical order
51
35
52
Nathan Chancellor (1):
36
Bin Meng (6):
53
riscv: sifive_test: Allow 16-bit writes to memory region
37
hw/riscv: microchip_pfsoc: Use MachineState::ram and MachineClass::default_ram_id
38
hw/riscv: opentitan: Use MachineState::ram and MachineClass::default_ram_id
39
hw/riscv: shakti_c: Use MachineState::ram and MachineClass::default_ram_id
40
hw/riscv: sifive_e: Use MachineState::ram and MachineClass::default_ram_id
41
hw/riscv: sifive_u: Use MachineState::ram and MachineClass::default_ram_id
42
hw/riscv: spike: Use MachineState::ram and MachineClass::default_ram_id
54
43
55
Yifei Jiang (1):
44
Frank Chang (2):
56
target/riscv: Fix bug in getting trap cause name for trace_riscv_trap
45
target/riscv: Pass the same value to oprsz and maxsz for vmv.v.v
46
target/riscv: fix TB_FLAGS bits overlapping bug for rvv/rvh
57
47
58
default-configs/riscv64-softmmu.mak | 1 +
48
Mingwang Li (1):
59
{include/hw/riscv => hw/intc}/sifive_plic.h | 0
49
hw/riscv: virt: Use machine->ram as the system memory
60
hw/riscv/trace.h | 1 -
61
include/hw/char/mchp_pfsoc_mmuart.h | 61 ++++
62
include/hw/{riscv => char}/riscv_htif.h | 0
63
include/hw/{riscv => char}/sifive_uart.h | 0
64
include/hw/dma/sifive_pdma.h | 57 ++++
65
include/hw/{riscv => gpio}/sifive_gpio.h | 0
66
include/hw/{riscv => intc}/sifive_clint.h | 4 +-
67
include/hw/{riscv => misc}/sifive_e_prci.h | 0
68
include/hw/{riscv => misc}/sifive_test.h | 0
69
include/hw/{riscv => misc}/sifive_u_otp.h | 0
70
include/hw/{riscv => misc}/sifive_u_prci.h | 0
71
include/hw/net/cadence_gem.h | 2 +
72
include/hw/riscv/microchip_pfsoc.h | 133 +++++++++
73
include/hw/riscv/riscv_hart.h | 1 +
74
include/hw/riscv/sifive_e.h | 2 +-
75
include/hw/riscv/sifive_u.h | 17 +-
76
include/hw/sd/cadence_sdhci.h | 47 +++
77
target/riscv/cpu.h | 8 +-
78
hw/arm/xilinx_zynq.c | 1 +
79
hw/arm/xlnx-versal.c | 1 +
80
hw/arm/xlnx-zynqmp.c | 2 +
81
hw/char/mchp_pfsoc_mmuart.c | 86 ++++++
82
hw/{riscv => char}/riscv_htif.c | 2 +-
83
hw/{riscv => char}/sifive_uart.c | 2 +-
84
hw/dma/sifive_pdma.c | 313 ++++++++++++++++++++
85
hw/{riscv => gpio}/sifive_gpio.c | 2 +-
86
hw/{riscv => intc}/sifive_clint.c | 28 +-
87
hw/{riscv => intc}/sifive_plic.c | 2 +-
88
hw/{riscv => misc}/sifive_e_prci.c | 2 +-
89
hw/{riscv => misc}/sifive_test.c | 4 +-
90
hw/{riscv => misc}/sifive_u_otp.c | 2 +-
91
hw/{riscv => misc}/sifive_u_prci.c | 2 +-
92
hw/net/cadence_gem.c | 7 +-
93
hw/riscv/microchip_pfsoc.c | 437 ++++++++++++++++++++++++++++
94
hw/riscv/opentitan.c | 1 +
95
hw/riscv/riscv_hart.c | 3 +
96
hw/riscv/sifive_e.c | 12 +-
97
hw/riscv/sifive_u.c | 41 ++-
98
hw/riscv/spike.c | 7 +-
99
hw/riscv/virt.c | 9 +-
100
hw/sd/cadence_sdhci.c | 193 ++++++++++++
101
target/riscv/cpu.c | 19 +-
102
target/riscv/cpu_helper.c | 8 +-
103
target/riscv/csr.c | 4 +-
104
MAINTAINERS | 9 +
105
hw/char/Kconfig | 9 +
106
hw/char/meson.build | 3 +
107
hw/dma/Kconfig | 3 +
108
hw/dma/meson.build | 1 +
109
hw/gpio/Kconfig | 3 +
110
hw/gpio/meson.build | 1 +
111
hw/gpio/trace-events | 6 +
112
hw/intc/Kconfig | 6 +
113
hw/intc/meson.build | 2 +
114
hw/misc/Kconfig | 12 +
115
hw/misc/meson.build | 6 +
116
hw/riscv/Kconfig | 70 +++--
117
hw/riscv/meson.build | 12 +-
118
hw/riscv/trace-events | 7 -
119
hw/sd/Kconfig | 4 +
120
hw/sd/meson.build | 1 +
121
meson.build | 1 -
122
64 files changed, 1575 insertions(+), 105 deletions(-)
123
rename {include/hw/riscv => hw/intc}/sifive_plic.h (100%)
124
delete mode 100644 hw/riscv/trace.h
125
create mode 100644 include/hw/char/mchp_pfsoc_mmuart.h
126
rename include/hw/{riscv => char}/riscv_htif.h (100%)
127
rename include/hw/{riscv => char}/sifive_uart.h (100%)
128
create mode 100644 include/hw/dma/sifive_pdma.h
129
rename include/hw/{riscv => gpio}/sifive_gpio.h (100%)
130
rename include/hw/{riscv => intc}/sifive_clint.h (92%)
131
rename include/hw/{riscv => misc}/sifive_e_prci.h (100%)
132
rename include/hw/{riscv => misc}/sifive_test.h (100%)
133
rename include/hw/{riscv => misc}/sifive_u_otp.h (100%)
134
rename include/hw/{riscv => misc}/sifive_u_prci.h (100%)
135
create mode 100644 include/hw/riscv/microchip_pfsoc.h
136
create mode 100644 include/hw/sd/cadence_sdhci.h
137
create mode 100644 hw/char/mchp_pfsoc_mmuart.c
138
rename hw/{riscv => char}/riscv_htif.c (99%)
139
rename hw/{riscv => char}/sifive_uart.c (99%)
140
create mode 100644 hw/dma/sifive_pdma.c
141
rename hw/{riscv => gpio}/sifive_gpio.c (99%)
142
rename hw/{riscv => intc}/sifive_clint.c (90%)
143
rename hw/{riscv => intc}/sifive_plic.c (99%)
144
rename hw/{riscv => misc}/sifive_e_prci.c (99%)
145
rename hw/{riscv => misc}/sifive_test.c (97%)
146
rename hw/{riscv => misc}/sifive_u_otp.c (99%)
147
rename hw/{riscv => misc}/sifive_u_prci.c (99%)
148
create mode 100644 hw/riscv/microchip_pfsoc.c
149
create mode 100644 hw/sd/cadence_sdhci.c
150
delete mode 100644 hw/riscv/trace-events
151
50
51
Philipp Tomsich (1):
52
target/riscv: Fix orc.b implementation
53
54
Richard Henderson (15):
55
target/riscv: Move cpu_get_tb_cpu_state out of line
56
target/riscv: Create RISCVMXL enumeration
57
target/riscv: Split misa.mxl and misa.ext
58
target/riscv: Replace riscv_cpu_is_32bit with riscv_cpu_mxl
59
target/riscv: Add MXL/SXL/UXL to TB_FLAGS
60
target/riscv: Use REQUIRE_64BIT in amo_check64
61
target/riscv: Properly check SEW in amo_op
62
target/riscv: Replace is_32bit with get_xl/get_xlen
63
target/riscv: Replace DisasContext.w with DisasContext.ol
64
target/riscv: Use gen_arith_per_ol for RVM
65
target/riscv: Adjust trans_rev8_32 for riscv64
66
target/riscv: Use gen_unary_per_ol for RVB
67
target/riscv: Use gen_shift*_per_ol for RVB, RVI
68
target/riscv: Use riscv_csrrw_debug for cpu_dump
69
target/riscv: Compute mstatus.sd on demand
70
71
Travis Geiselbrecht (1):
72
target/riscv: line up all of the registers in the info register dump
73
74
include/hw/riscv/opentitan.h | 6 +-
75
target/riscv/cpu.h | 87 +++------
76
target/riscv/cpu_bits.h | 16 +-
77
hw/intc/ibex_plic.c | 307 --------------------------------
78
hw/intc/sifive_plic.c | 85 ++++-----
79
hw/riscv/boot.c | 2 +-
80
hw/riscv/microchip_pfsoc.c | 36 ++--
81
hw/riscv/opentitan.c | 38 +++-
82
hw/riscv/shakti_c.c | 6 +-
83
hw/riscv/sifive_e.c | 16 +-
84
hw/riscv/sifive_u.c | 6 +-
85
hw/riscv/spike.c | 6 +-
86
hw/riscv/virt.c | 6 +-
87
linux-user/elfload.c | 2 +-
88
linux-user/riscv/cpu_loop.c | 2 +-
89
semihosting/arm-compat-semi.c | 2 +-
90
target/riscv/cpu.c | 216 ++++++++++++----------
91
target/riscv/cpu_helper.c | 92 +++++++++-
92
target/riscv/csr.c | 104 ++++++-----
93
target/riscv/gdbstub.c | 10 +-
94
target/riscv/machine.c | 10 +-
95
target/riscv/monitor.c | 4 +-
96
target/riscv/translate.c | 174 +++++++++++++-----
97
target/riscv/insn_trans/trans_rvb.c.inc | 153 +++++++++-------
98
target/riscv/insn_trans/trans_rvi.c.inc | 44 ++---
99
target/riscv/insn_trans/trans_rvm.c.inc | 36 +++-
100
target/riscv/insn_trans/trans_rvv.c.inc | 32 ++--
101
hw/intc/meson.build | 1 -
102
28 files changed, 720 insertions(+), 779 deletions(-)
103
delete mode 100644 hw/intc/ibex_plic.c
104
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Frank Chang <frank.chang@sifive.com>
2
2
3
At present the Kconfig file is in disorder. Let's sort the options.
3
oprsz and maxsz are passed with the same value in commit: eee2d61e202.
4
However, vmv.v.v was missed in that commit and should pass the same
5
value as well in its tcg_gen_gvec_2_ptr() call.
4
6
5
Signed-off-by: Bin Meng <bin.meng@windriver.com>
7
Signed-off-by: Frank Chang <frank.chang@sifive.com>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-Id: <1599129623-68957-13-git-send-email-bmeng.cn@gmail.com>
9
Message-id: 20211007081803.1705656-1-frank.chang@sifive.com
8
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
9
---
11
---
10
hw/riscv/Kconfig | 58 ++++++++++++++++++++++++------------------------
12
target/riscv/insn_trans/trans_rvv.c.inc | 3 ++-
11
1 file changed, 29 insertions(+), 29 deletions(-)
13
1 file changed, 2 insertions(+), 1 deletion(-)
12
14
13
diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
15
diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_trans/trans_rvv.c.inc
14
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/riscv/Kconfig
17
--- a/target/riscv/insn_trans/trans_rvv.c.inc
16
+++ b/hw/riscv/Kconfig
18
+++ b/target/riscv/insn_trans/trans_rvv.c.inc
17
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@ static bool trans_vmv_v_v(DisasContext *s, arg_vmv_v_v *a)
18
config IBEX
20
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over);
19
bool
21
20
22
tcg_gen_gvec_2_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, a->rs1),
21
-config SIFIVE_E
23
- cpu_env, 0, s->vlen / 8, data, fns[s->sew]);
22
- bool
24
+ cpu_env, s->vlen / 8, s->vlen / 8, data,
23
- select MSI_NONBROKEN
25
+ fns[s->sew]);
24
- select SIFIVE_CLINT
26
gen_set_label(over);
25
- select SIFIVE_GPIO
27
}
26
- select SIFIVE_PLIC
28
return true;
27
- select SIFIVE_UART
28
- select SIFIVE_E_PRCI
29
- select UNIMP
30
-
31
-config SIFIVE_U
32
+config MICROCHIP_PFSOC
33
bool
34
- select CADENCE
35
+ select CADENCE_SDHCI
36
+ select MCHP_PFSOC_MMUART
37
select MSI_NONBROKEN
38
select SIFIVE_CLINT
39
- select SIFIVE_GPIO
40
select SIFIVE_PDMA
41
select SIFIVE_PLIC
42
- select SIFIVE_UART
43
- select SIFIVE_U_OTP
44
- select SIFIVE_U_PRCI
45
select UNIMP
46
47
-config SPIKE
48
- bool
49
- select HTIF
50
- select MSI_NONBROKEN
51
- select SIFIVE_CLINT
52
- select SIFIVE_PLIC
53
-
54
config OPENTITAN
55
bool
56
select IBEX
57
@@ -XXX,XX +XXX,XX @@ config RISCV_VIRT
58
bool
59
imply PCI_DEVICES
60
imply TEST_DEVICES
61
+ select GOLDFISH_RTC
62
select MSI_NONBROKEN
63
select PCI
64
- select SERIAL
65
- select GOLDFISH_RTC
66
- select VIRTIO_MMIO
67
select PCI_EXPRESS_GENERIC_BRIDGE
68
select PFLASH_CFI01
69
+ select SERIAL
70
select SIFIVE_CLINT
71
select SIFIVE_PLIC
72
select SIFIVE_TEST
73
+ select VIRTIO_MMIO
74
75
-config MICROCHIP_PFSOC
76
+config SIFIVE_E
77
bool
78
select MSI_NONBROKEN
79
select SIFIVE_CLINT
80
+ select SIFIVE_GPIO
81
+ select SIFIVE_PLIC
82
+ select SIFIVE_UART
83
+ select SIFIVE_E_PRCI
84
select UNIMP
85
- select MCHP_PFSOC_MMUART
86
+
87
+config SIFIVE_U
88
+ bool
89
+ select CADENCE
90
+ select MSI_NONBROKEN
91
+ select SIFIVE_CLINT
92
+ select SIFIVE_GPIO
93
select SIFIVE_PDMA
94
select SIFIVE_PLIC
95
- select CADENCE_SDHCI
96
+ select SIFIVE_UART
97
+ select SIFIVE_U_OTP
98
+ select SIFIVE_U_PRCI
99
+ select UNIMP
100
+
101
+config SPIKE
102
+ bool
103
+ select HTIF
104
+ select MSI_NONBROKEN
105
+ select SIFIVE_CLINT
106
+ select SIFIVE_PLIC
107
--
29
--
108
2.28.0
30
2.31.1
109
31
110
32
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Travis Geiselbrecht <travisg@gmail.com>
2
2
3
The name SIFIVE is too vague to convey the required component of
3
Ensure the columns for all of the register names and values line up.
4
MSI_NONBROKEN. Let's drop the option, and select MSI_NONBROKEN in
4
No functional change, just a minor tweak to the output.
5
each machine instead.
6
5
7
Signed-off-by: Bin Meng <bin.meng@windriver.com>
6
Signed-off-by: Travis Geiselbrecht <travisg@gmail.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-Id: <1599129623-68957-12-git-send-email-bmeng.cn@gmail.com>
8
Message-id: 20211009055019.545153-1-travisg@gmail.com
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
9
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
10
---
12
hw/riscv/Kconfig | 14 +++++---------
11
target/riscv/cpu.c | 10 +++++-----
13
1 file changed, 5 insertions(+), 9 deletions(-)
12
1 file changed, 5 insertions(+), 5 deletions(-)
14
13
15
diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
14
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
16
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/riscv/Kconfig
16
--- a/target/riscv/cpu.c
18
+++ b/hw/riscv/Kconfig
17
+++ b/target/riscv/cpu.c
19
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags)
20
config IBEX
19
}
21
bool
20
if (riscv_has_ext(env, RVH)) {
22
21
qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "hstatus ", env->hstatus);
23
-config SIFIVE
22
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "vsstatus ",
24
- bool
23
+ qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "vsstatus",
25
- select MSI_NONBROKEN
24
(target_ulong)env->vsstatus);
26
-
25
}
27
config SIFIVE_E
26
qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mip ", env->mip);
28
bool
27
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags)
29
- select SIFIVE
28
qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtval ", env->mtval);
30
+ select MSI_NONBROKEN
29
qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "stval ", env->stval);
31
select SIFIVE_CLINT
30
if (riscv_has_ext(env, RVH)) {
32
select SIFIVE_GPIO
31
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "htval ", env->htval);
33
select SIFIVE_PLIC
32
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtval2 ", env->mtval2);
34
@@ -XXX,XX +XXX,XX @@ config SIFIVE_E
33
+ qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "htval ", env->htval);
35
config SIFIVE_U
34
+ qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtval2 ", env->mtval2);
36
bool
35
}
37
select CADENCE
36
qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mscratch", env->mscratch);
38
- select SIFIVE
37
qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "sscratch", env->sscratch);
39
+ select MSI_NONBROKEN
38
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags)
40
select SIFIVE_CLINT
39
#endif
41
select SIFIVE_GPIO
40
42
select SIFIVE_PDMA
41
for (i = 0; i < 32; i++) {
43
@@ -XXX,XX +XXX,XX @@ config SIFIVE_U
42
- qemu_fprintf(f, " %s " TARGET_FMT_lx,
44
config SPIKE
43
+ qemu_fprintf(f, " %-8s " TARGET_FMT_lx,
45
bool
44
riscv_int_regnames[i], env->gpr[i]);
46
select HTIF
45
if ((i & 3) == 3) {
47
- select SIFIVE
46
qemu_fprintf(f, "\n");
48
+ select MSI_NONBROKEN
47
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags)
49
select SIFIVE_CLINT
48
}
50
select SIFIVE_PLIC
49
if (flags & CPU_DUMP_FPU) {
51
50
for (i = 0; i < 32; i++) {
52
@@ -XXX,XX +XXX,XX @@ config RISCV_VIRT
51
- qemu_fprintf(f, " %s %016" PRIx64,
53
bool
52
+ qemu_fprintf(f, " %-8s %016" PRIx64,
54
imply PCI_DEVICES
53
riscv_fpr_regnames[i], env->fpr[i]);
55
imply TEST_DEVICES
54
if ((i & 3) == 3) {
56
+ select MSI_NONBROKEN
55
qemu_fprintf(f, "\n");
57
select PCI
58
select SERIAL
59
select GOLDFISH_RTC
60
select VIRTIO_MMIO
61
select PCI_EXPRESS_GENERIC_BRIDGE
62
select PFLASH_CFI01
63
- select SIFIVE
64
select SIFIVE_CLINT
65
select SIFIVE_PLIC
66
select SIFIVE_TEST
67
68
config MICROCHIP_PFSOC
69
bool
70
- select SIFIVE
71
+ select MSI_NONBROKEN
72
select SIFIVE_CLINT
73
select UNIMP
74
select MCHP_PFSOC_MMUART
75
--
56
--
76
2.28.0
57
2.31.1
77
58
78
59
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Philipp Tomsich <philipp.tomsich@vrull.eu>
2
2
3
Every RISC-V machine needs riscv_hart hence there is no need to
3
The earlier implementation fell into a corner case for bytes that were
4
have a dedicated Kconfig option for it. Drop the Kconfig option
4
0x01, giving a wrong result (but not affecting our application test
5
and always build riscv_hart.c.
5
cases for strings, as an ASCII value 0x01 is rare in those...).
6
6
7
Signed-off-by: Bin Meng <bin.meng@windriver.com>
7
This changes the algorithm to:
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
1. Mask out the high-bit of each bytes (so that each byte is <= 127).
9
Message-Id: <1599129623-68957-11-git-send-email-bmeng.cn@gmail.com>
9
2. Add 127 to each byte (i.e. if the low 7 bits are not 0, this will overflow
10
into the highest bit of each byte).
11
3. Bitwise-or the original value back in (to cover those cases where the
12
source byte was exactly 128) to saturate the high-bit.
13
4. Shift-and-mask (implemented as a mask-and-shift) to extract the MSB of
14
each byte into its LSB.
15
5. Multiply with 0xff to fan out the LSB to all bits of each byte.
16
17
Fixes: d7a4fcb034 ("target/riscv: Add orc.b instruction for Zbb, removing gorc/gorci")
18
19
Signed-off-by: Philipp Tomsich <philipp.tomsich@vrull.eu>
20
Reported-by: Vincent Palatin <vpalatin@rivosinc.com>
21
Tested-by: Vincent Palatin <vpalatin@rivosinc.com>
22
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
23
Message-id: 20211013184125.2010897-1-philipp.tomsich@vrull.eu
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
24
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
25
---
12
hw/riscv/Kconfig | 9 ---------
26
target/riscv/insn_trans/trans_rvb.c.inc | 13 ++++++++-----
13
hw/riscv/meson.build | 2 +-
27
1 file changed, 8 insertions(+), 5 deletions(-)
14
2 files changed, 1 insertion(+), 10 deletions(-)
15
28
16
diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
29
diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_trans/trans_rvb.c.inc
17
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/riscv/Kconfig
31
--- a/target/riscv/insn_trans/trans_rvb.c.inc
19
+++ b/hw/riscv/Kconfig
32
+++ b/target/riscv/insn_trans/trans_rvb.c.inc
20
@@ -XXX,XX +XXX,XX @@
33
@@ -XXX,XX +XXX,XX @@ static bool trans_rev8_64(DisasContext *ctx, arg_rev8_64 *a)
21
-config HART
34
static void gen_orc_b(TCGv ret, TCGv source1)
22
- bool
35
{
23
-
36
TCGv tmp = tcg_temp_new();
24
config IBEX
37
- TCGv ones = tcg_constant_tl(dup_const_tl(MO_8, 0x01));
25
bool
38
+ TCGv low7 = tcg_constant_tl(dup_const_tl(MO_8, 0x7f));
26
39
27
@@ -XXX,XX +XXX,XX @@ config SIFIVE
40
- /* Set lsb in each byte if the byte was zero. */
28
41
- tcg_gen_sub_tl(tmp, source1, ones);
29
config SIFIVE_E
42
- tcg_gen_andc_tl(tmp, tmp, source1);
30
bool
43
+ /* Set msb in each byte if the byte was non-zero. */
31
- select HART
44
+ tcg_gen_and_tl(tmp, source1, low7);
32
select SIFIVE
45
+ tcg_gen_add_tl(tmp, tmp, low7);
33
select SIFIVE_CLINT
46
+ tcg_gen_or_tl(tmp, tmp, source1);
34
select SIFIVE_GPIO
47
+
35
@@ -XXX,XX +XXX,XX @@ config SIFIVE_E
48
+ /* Extract the msb to the lsb in each byte */
36
config SIFIVE_U
49
+ tcg_gen_andc_tl(tmp, tmp, low7);
37
bool
50
tcg_gen_shri_tl(tmp, tmp, 7);
38
select CADENCE
51
- tcg_gen_andc_tl(tmp, ones, tmp);
39
- select HART
52
40
select SIFIVE
53
/* Replicate the lsb of each byte across the byte. */
41
select SIFIVE_CLINT
54
tcg_gen_muli_tl(ret, tmp, 0xff);
42
select SIFIVE_GPIO
43
@@ -XXX,XX +XXX,XX @@ config SIFIVE_U
44
45
config SPIKE
46
bool
47
- select HART
48
select HTIF
49
select SIFIVE
50
select SIFIVE_CLINT
51
@@ -XXX,XX +XXX,XX @@ config SPIKE
52
config OPENTITAN
53
bool
54
select IBEX
55
- select HART
56
select UNIMP
57
58
config RISCV_VIRT
59
@@ -XXX,XX +XXX,XX @@ config RISCV_VIRT
60
imply PCI_DEVICES
61
imply TEST_DEVICES
62
select PCI
63
- select HART
64
select SERIAL
65
select GOLDFISH_RTC
66
select VIRTIO_MMIO
67
@@ -XXX,XX +XXX,XX @@ config RISCV_VIRT
68
69
config MICROCHIP_PFSOC
70
bool
71
- select HART
72
select SIFIVE
73
select SIFIVE_CLINT
74
select UNIMP
75
diff --git a/hw/riscv/meson.build b/hw/riscv/meson.build
76
index XXXXXXX..XXXXXXX 100644
77
--- a/hw/riscv/meson.build
78
+++ b/hw/riscv/meson.build
79
@@ -XXX,XX +XXX,XX @@
80
riscv_ss = ss.source_set()
81
riscv_ss.add(files('boot.c'), fdt)
82
riscv_ss.add(files('numa.c'))
83
-riscv_ss.add(when: 'CONFIG_HART', if_true: files('riscv_hart.c'))
84
+riscv_ss.add(files('riscv_hart.c'))
85
riscv_ss.add(when: 'CONFIG_OPENTITAN', if_true: files('opentitan.c'))
86
riscv_ss.add(when: 'CONFIG_RISCV_VIRT', if_true: files('virt.c'))
87
riscv_ss.add(when: 'CONFIG_SIFIVE_E', if_true: files('sifive_e.c'))
88
--
55
--
89
2.28.0
56
2.31.1
90
57
91
58
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Mingwang Li <limingwang@huawei.com>
2
2
3
This is an effort to clean up the hw/riscv directory. Ideally it
3
If default main_mem is used to be registered as the system memory,
4
should only contain the RISC-V SoC / machine codes plus generic
4
other memory cannot be initialized. Therefore, the system memory
5
codes. Let's move sifive_test model to hw/misc directory.
5
should be initialized to the machine->ram, which consists of the
6
default main_mem and other possible memory required by applications,
7
such as shared hugepage memory in DPDK.
6
8
7
Signed-off-by: Bin Meng <bin.meng@windriver.com>
9
Also, the mc->defaul_ram_id should be set to the default main_mem,
10
such as "riscv_virt_board.ram" for the virt machine.
11
12
Signed-off-by: Mingwang Li <limingwang@huawei.com>
13
Signed-off-by: Yifei Jiang <jiangyifei@huawei.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
14
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-Id: <1599129623-68957-10-git-send-email-bmeng.cn@gmail.com>
15
Message-id: 20211016030908.40480-1-limingwang@huawei.com
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
16
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
17
---
12
include/hw/{riscv => misc}/sifive_test.h | 0
18
hw/riscv/virt.c | 6 ++----
13
hw/{riscv => misc}/sifive_test.c | 2 +-
19
1 file changed, 2 insertions(+), 4 deletions(-)
14
hw/riscv/virt.c | 2 +-
15
hw/misc/Kconfig | 3 +++
16
hw/misc/meson.build | 1 +
17
hw/riscv/Kconfig | 1 +
18
hw/riscv/meson.build | 1 -
19
7 files changed, 7 insertions(+), 3 deletions(-)
20
rename include/hw/{riscv => misc}/sifive_test.h (100%)
21
rename hw/{riscv => misc}/sifive_test.c (98%)
22
20
23
diff --git a/include/hw/riscv/sifive_test.h b/include/hw/misc/sifive_test.h
24
similarity index 100%
25
rename from include/hw/riscv/sifive_test.h
26
rename to include/hw/misc/sifive_test.h
27
diff --git a/hw/riscv/sifive_test.c b/hw/misc/sifive_test.c
28
similarity index 98%
29
rename from hw/riscv/sifive_test.c
30
rename to hw/misc/sifive_test.c
31
index XXXXXXX..XXXXXXX 100644
32
--- a/hw/riscv/sifive_test.c
33
+++ b/hw/misc/sifive_test.c
34
@@ -XXX,XX +XXX,XX @@
35
#include "qemu/module.h"
36
#include "sysemu/runstate.h"
37
#include "hw/hw.h"
38
-#include "hw/riscv/sifive_test.h"
39
+#include "hw/misc/sifive_test.h"
40
41
static uint64_t sifive_test_read(void *opaque, hwaddr addr, unsigned int size)
42
{
43
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
21
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
44
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
45
--- a/hw/riscv/virt.c
23
--- a/hw/riscv/virt.c
46
+++ b/hw/riscv/virt.c
24
+++ b/hw/riscv/virt.c
47
@@ -XXX,XX +XXX,XX @@
25
@@ -XXX,XX +XXX,XX @@ static void virt_machine_init(MachineState *machine)
48
#include "hw/char/serial.h"
26
const MemMapEntry *memmap = virt_memmap;
49
#include "target/riscv/cpu.h"
27
RISCVVirtState *s = RISCV_VIRT_MACHINE(machine);
50
#include "hw/riscv/riscv_hart.h"
28
MemoryRegion *system_memory = get_system_memory();
51
-#include "hw/riscv/sifive_test.h"
29
- MemoryRegion *main_mem = g_new(MemoryRegion, 1);
52
#include "hw/riscv/virt.h"
30
MemoryRegion *mask_rom = g_new(MemoryRegion, 1);
53
#include "hw/riscv/boot.h"
31
char *plic_hart_config, *soc_name;
54
#include "hw/riscv/numa.h"
32
target_ulong start_addr = memmap[VIRT_DRAM].base;
55
#include "hw/intc/sifive_clint.h"
33
@@ -XXX,XX +XXX,XX @@ static void virt_machine_init(MachineState *machine)
56
#include "hw/intc/sifive_plic.h"
34
}
57
+#include "hw/misc/sifive_test.h"
35
58
#include "chardev/char.h"
36
/* register system main memory (actual RAM) */
59
#include "sysemu/arch_init.h"
37
- memory_region_init_ram(main_mem, NULL, "riscv_virt_board.ram",
60
#include "sysemu/device_tree.h"
38
- machine->ram_size, &error_fatal);
61
diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
39
memory_region_add_subregion(system_memory, memmap[VIRT_DRAM].base,
62
index XXXXXXX..XXXXXXX 100644
40
- main_mem);
63
--- a/hw/misc/Kconfig
41
+ machine->ram);
64
+++ b/hw/misc/Kconfig
42
65
@@ -XXX,XX +XXX,XX @@ config MAC_VIA
43
/* create device tree */
66
config AVR_POWER
44
create_fdt(s, memmap, machine->ram_size, machine->kernel_cmdline,
67
bool
45
@@ -XXX,XX +XXX,XX @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
68
46
mc->cpu_index_to_instance_props = riscv_numa_cpu_index_to_props;
69
+config SIFIVE_TEST
47
mc->get_default_cpu_node_id = riscv_numa_get_default_cpu_node_id;
70
+ bool
48
mc->numa_mem_supported = true;
71
+
49
+ mc->default_ram_id = "riscv_virt_board.ram";
72
config SIFIVE_E_PRCI
50
73
bool
51
machine_class_allow_dynamic_sysbus_dev(mc, TYPE_RAMFB_DEVICE);
74
52
75
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
76
index XXXXXXX..XXXXXXX 100644
77
--- a/hw/misc/meson.build
78
+++ b/hw/misc/meson.build
79
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_ARM11SCU', if_true: files('arm11scu.c'))
80
softmmu_ss.add(when: 'CONFIG_MOS6522', if_true: files('mos6522.c'))
81
82
# RISC-V devices
83
+softmmu_ss.add(when: 'CONFIG_SIFIVE_TEST', if_true: files('sifive_test.c'))
84
softmmu_ss.add(when: 'CONFIG_SIFIVE_E_PRCI', if_true: files('sifive_e_prci.c'))
85
softmmu_ss.add(when: 'CONFIG_SIFIVE_U_OTP', if_true: files('sifive_u_otp.c'))
86
softmmu_ss.add(when: 'CONFIG_SIFIVE_U_PRCI', if_true: files('sifive_u_prci.c'))
87
diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
88
index XXXXXXX..XXXXXXX 100644
89
--- a/hw/riscv/Kconfig
90
+++ b/hw/riscv/Kconfig
91
@@ -XXX,XX +XXX,XX @@ config RISCV_VIRT
92
select SIFIVE
93
select SIFIVE_CLINT
94
select SIFIVE_PLIC
95
+ select SIFIVE_TEST
96
97
config MICROCHIP_PFSOC
98
bool
99
diff --git a/hw/riscv/meson.build b/hw/riscv/meson.build
100
index XXXXXXX..XXXXXXX 100644
101
--- a/hw/riscv/meson.build
102
+++ b/hw/riscv/meson.build
103
@@ -XXX,XX +XXX,XX @@ riscv_ss.add(files('numa.c'))
104
riscv_ss.add(when: 'CONFIG_HART', if_true: files('riscv_hart.c'))
105
riscv_ss.add(when: 'CONFIG_OPENTITAN', if_true: files('opentitan.c'))
106
riscv_ss.add(when: 'CONFIG_RISCV_VIRT', if_true: files('virt.c'))
107
-riscv_ss.add(when: 'CONFIG_SIFIVE', if_true: files('sifive_test.c'))
108
riscv_ss.add(when: 'CONFIG_SIFIVE_E', if_true: files('sifive_e.c'))
109
riscv_ss.add(when: 'CONFIG_SIFIVE_U', if_true: files('sifive_u.c'))
110
riscv_ss.add(when: 'CONFIG_SPIKE', if_true: files('spike.c'))
111
--
53
--
112
2.28.0
54
2.31.1
113
55
114
56
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Frank Chang <frank.chang@sifive.com>
2
2
3
This is an effort to clean up the hw/riscv directory. Ideally it
3
TB_FLAGS mem_idx bits was extended from 2 bits to 3 bits in
4
should only contain the RISC-V SoC / machine codes plus generic
4
commit: c445593, but other TB_FLAGS bits for rvv and rvh were
5
codes. Let's move sifive_gpio model to hw/gpio directory.
5
not shift as well so these bits may overlap with each other when
6
rvv is enabled.
6
7
7
Note this also removes the trace-events in the hw/riscv directory,
8
Signed-off-by: Frank Chang <frank.chang@sifive.com>
8
since gpio is the only supported trace target in that directory.
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
10
Signed-off-by: Bin Meng <bin.meng@windriver.com>
11
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
12
Message-Id: <1599129623-68957-5-git-send-email-bmeng.cn@gmail.com>
11
Message-Id: <20211015074627.3957162-2-frank.chang@sifive.com>
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
12
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
14
---
13
---
15
hw/riscv/trace.h | 1 -
14
target/riscv/cpu.h | 14 +++++++-------
16
include/hw/{riscv => gpio}/sifive_gpio.h | 0
15
target/riscv/translate.c | 2 +-
17
include/hw/riscv/sifive_e.h | 2 +-
16
2 files changed, 8 insertions(+), 8 deletions(-)
18
include/hw/riscv/sifive_u.h | 2 +-
19
hw/{riscv => gpio}/sifive_gpio.c | 2 +-
20
hw/gpio/Kconfig | 3 +++
21
hw/gpio/meson.build | 1 +
22
hw/gpio/trace-events | 6 ++++++
23
hw/riscv/Kconfig | 2 ++
24
hw/riscv/meson.build | 1 -
25
hw/riscv/trace-events | 7 -------
26
meson.build | 1 -
27
12 files changed, 15 insertions(+), 13 deletions(-)
28
delete mode 100644 hw/riscv/trace.h
29
rename include/hw/{riscv => gpio}/sifive_gpio.h (100%)
30
rename hw/{riscv => gpio}/sifive_gpio.c (99%)
31
delete mode 100644 hw/riscv/trace-events
32
17
33
diff --git a/hw/riscv/trace.h b/hw/riscv/trace.h
18
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
34
deleted file mode 100644
35
index XXXXXXX..XXXXXXX
36
--- a/hw/riscv/trace.h
37
+++ /dev/null
38
@@ -1 +0,0 @@
39
-#include "trace/trace-hw_riscv.h"
40
diff --git a/include/hw/riscv/sifive_gpio.h b/include/hw/gpio/sifive_gpio.h
41
similarity index 100%
42
rename from include/hw/riscv/sifive_gpio.h
43
rename to include/hw/gpio/sifive_gpio.h
44
diff --git a/include/hw/riscv/sifive_e.h b/include/hw/riscv/sifive_e.h
45
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
46
--- a/include/hw/riscv/sifive_e.h
20
--- a/target/riscv/cpu.h
47
+++ b/include/hw/riscv/sifive_e.h
21
+++ b/target/riscv/cpu.h
48
@@ -XXX,XX +XXX,XX @@
22
@@ -XXX,XX +XXX,XX @@ void QEMU_NORETURN riscv_raise_exception(CPURISCVState *env,
49
23
target_ulong riscv_cpu_get_fflags(CPURISCVState *env);
50
#include "hw/riscv/riscv_hart.h"
24
void riscv_cpu_set_fflags(CPURISCVState *env, target_ulong);
51
#include "hw/riscv/sifive_cpu.h"
25
52
-#include "hw/riscv/sifive_gpio.h"
26
-#define TB_FLAGS_MMU_MASK 7
53
+#include "hw/gpio/sifive_gpio.h"
27
#define TB_FLAGS_PRIV_MMU_MASK 3
54
28
#define TB_FLAGS_PRIV_HYP_ACCESS_MASK (1 << 2)
55
#define TYPE_RISCV_E_SOC "riscv.sifive.e.soc"
29
#define TB_FLAGS_MSTATUS_FS MSTATUS_FS
56
#define RISCV_E_SOC(obj) \
30
@@ -XXX,XX +XXX,XX @@ typedef CPURISCVState CPUArchState;
57
diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h
31
typedef RISCVCPU ArchCPU;
32
#include "exec/cpu-all.h"
33
34
-FIELD(TB_FLAGS, VL_EQ_VLMAX, 2, 1)
35
-FIELD(TB_FLAGS, LMUL, 3, 2)
36
-FIELD(TB_FLAGS, SEW, 5, 3)
37
-FIELD(TB_FLAGS, VILL, 8, 1)
38
+FIELD(TB_FLAGS, MEM_IDX, 0, 3)
39
+FIELD(TB_FLAGS, VL_EQ_VLMAX, 3, 1)
40
+FIELD(TB_FLAGS, LMUL, 4, 2)
41
+FIELD(TB_FLAGS, SEW, 6, 3)
42
+FIELD(TB_FLAGS, VILL, 9, 1)
43
/* Is a Hypervisor instruction load/store allowed? */
44
-FIELD(TB_FLAGS, HLSX, 9, 1)
45
-FIELD(TB_FLAGS, MSTATUS_HS_FS, 10, 2)
46
+FIELD(TB_FLAGS, HLSX, 10, 1)
47
+FIELD(TB_FLAGS, MSTATUS_HS_FS, 11, 2)
48
49
bool riscv_cpu_is_32bit(CPURISCVState *env);
50
51
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
58
index XXXXXXX..XXXXXXX 100644
52
index XXXXXXX..XXXXXXX 100644
59
--- a/include/hw/riscv/sifive_u.h
53
--- a/target/riscv/translate.c
60
+++ b/include/hw/riscv/sifive_u.h
54
+++ b/target/riscv/translate.c
61
@@ -XXX,XX +XXX,XX @@
55
@@ -XXX,XX +XXX,XX @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
62
#include "hw/net/cadence_gem.h"
56
uint32_t tb_flags = ctx->base.tb->flags;
63
#include "hw/riscv/riscv_hart.h"
57
64
#include "hw/riscv/sifive_cpu.h"
58
ctx->pc_succ_insn = ctx->base.pc_first;
65
-#include "hw/riscv/sifive_gpio.h"
59
- ctx->mem_idx = tb_flags & TB_FLAGS_MMU_MASK;
66
+#include "hw/gpio/sifive_gpio.h"
60
+ ctx->mem_idx = FIELD_EX32(tb_flags, TB_FLAGS, MEM_IDX);
67
#include "hw/misc/sifive_u_otp.h"
61
ctx->mstatus_fs = tb_flags & TB_FLAGS_MSTATUS_FS;
68
#include "hw/misc/sifive_u_prci.h"
62
ctx->priv_ver = env->priv_ver;
69
63
#if !defined(CONFIG_USER_ONLY)
70
diff --git a/hw/riscv/sifive_gpio.c b/hw/gpio/sifive_gpio.c
71
similarity index 99%
72
rename from hw/riscv/sifive_gpio.c
73
rename to hw/gpio/sifive_gpio.c
74
index XXXXXXX..XXXXXXX 100644
75
--- a/hw/riscv/sifive_gpio.c
76
+++ b/hw/gpio/sifive_gpio.c
77
@@ -XXX,XX +XXX,XX @@
78
#include "qemu/log.h"
79
#include "hw/irq.h"
80
#include "hw/qdev-properties.h"
81
-#include "hw/riscv/sifive_gpio.h"
82
+#include "hw/gpio/sifive_gpio.h"
83
#include "migration/vmstate.h"
84
#include "trace.h"
85
86
diff --git a/hw/gpio/Kconfig b/hw/gpio/Kconfig
87
index XXXXXXX..XXXXXXX 100644
88
--- a/hw/gpio/Kconfig
89
+++ b/hw/gpio/Kconfig
90
@@ -XXX,XX +XXX,XX @@ config PL061
91
92
config GPIO_KEY
93
bool
94
+
95
+config SIFIVE_GPIO
96
+ bool
97
diff --git a/hw/gpio/meson.build b/hw/gpio/meson.build
98
index XXXXXXX..XXXXXXX 100644
99
--- a/hw/gpio/meson.build
100
+++ b/hw/gpio/meson.build
101
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_gpio.c'))
102
softmmu_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_gpio.c'))
103
softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_gpio.c'))
104
softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_gpio.c'))
105
+softmmu_ss.add(when: 'CONFIG_SIFIVE_GPIO', if_true: files('sifive_gpio.c'))
106
diff --git a/hw/gpio/trace-events b/hw/gpio/trace-events
107
index XXXXXXX..XXXXXXX 100644
108
--- a/hw/gpio/trace-events
109
+++ b/hw/gpio/trace-events
110
@@ -XXX,XX +XXX,XX @@ nrf51_gpio_read(uint64_t offset, uint64_t r) "offset 0x%" PRIx64 " value 0x%" PR
111
nrf51_gpio_write(uint64_t offset, uint64_t value) "offset 0x%" PRIx64 " value 0x%" PRIx64
112
nrf51_gpio_set(int64_t line, int64_t value) "line %" PRIi64 " value %" PRIi64
113
nrf51_gpio_update_output_irq(int64_t line, int64_t value) "line %" PRIi64 " value %" PRIi64
114
+
115
+# sifive_gpio.c
116
+sifive_gpio_read(uint64_t offset, uint64_t r) "offset 0x%" PRIx64 " value 0x%" PRIx64
117
+sifive_gpio_write(uint64_t offset, uint64_t value) "offset 0x%" PRIx64 " value 0x%" PRIx64
118
+sifive_gpio_set(int64_t line, int64_t value) "line %" PRIi64 " value %" PRIi64
119
+sifive_gpio_update_output_irq(int64_t line, int64_t value) "line %" PRIi64 " value %" PRIi64
120
diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
121
index XXXXXXX..XXXXXXX 100644
122
--- a/hw/riscv/Kconfig
123
+++ b/hw/riscv/Kconfig
124
@@ -XXX,XX +XXX,XX @@ config SIFIVE_E
125
bool
126
select HART
127
select SIFIVE
128
+ select SIFIVE_GPIO
129
select SIFIVE_E_PRCI
130
select UNIMP
131
132
@@ -XXX,XX +XXX,XX @@ config SIFIVE_U
133
select CADENCE
134
select HART
135
select SIFIVE
136
+ select SIFIVE_GPIO
137
select SIFIVE_PDMA
138
select SIFIVE_U_OTP
139
select SIFIVE_U_PRCI
140
diff --git a/hw/riscv/meson.build b/hw/riscv/meson.build
141
index XXXXXXX..XXXXXXX 100644
142
--- a/hw/riscv/meson.build
143
+++ b/hw/riscv/meson.build
144
@@ -XXX,XX +XXX,XX @@ riscv_ss.add(when: 'CONFIG_HART', if_true: files('riscv_hart.c'))
145
riscv_ss.add(when: 'CONFIG_OPENTITAN', if_true: files('opentitan.c'))
146
riscv_ss.add(when: 'CONFIG_RISCV_VIRT', if_true: files('virt.c'))
147
riscv_ss.add(when: 'CONFIG_SIFIVE', if_true: files('sifive_clint.c'))
148
-riscv_ss.add(when: 'CONFIG_SIFIVE', if_true: files('sifive_gpio.c'))
149
riscv_ss.add(when: 'CONFIG_SIFIVE', if_true: files('sifive_plic.c'))
150
riscv_ss.add(when: 'CONFIG_SIFIVE', if_true: files('sifive_test.c'))
151
riscv_ss.add(when: 'CONFIG_SIFIVE', if_true: files('sifive_uart.c'))
152
diff --git a/hw/riscv/trace-events b/hw/riscv/trace-events
153
deleted file mode 100644
154
index XXXXXXX..XXXXXXX
155
--- a/hw/riscv/trace-events
156
+++ /dev/null
157
@@ -XXX,XX +XXX,XX @@
158
-# See docs/devel/tracing.txt for syntax documentation.
159
-
160
-# hw/gpio/sifive_gpio.c
161
-sifive_gpio_read(uint64_t offset, uint64_t r) "offset 0x%" PRIx64 " value 0x%" PRIx64
162
-sifive_gpio_write(uint64_t offset, uint64_t value) "offset 0x%" PRIx64 " value 0x%" PRIx64
163
-sifive_gpio_set(int64_t line, int64_t value) "line %" PRIi64 " value %" PRIi64
164
-sifive_gpio_update_output_irq(int64_t line, int64_t value) "line %" PRIi64 " value %" PRIi64
165
diff --git a/meson.build b/meson.build
166
index XXXXXXX..XXXXXXX 100644
167
--- a/meson.build
168
+++ b/meson.build
169
@@ -XXX,XX +XXX,XX @@ if have_system
170
'hw/watchdog',
171
'hw/xen',
172
'hw/gpio',
173
- 'hw/riscv',
174
'migration',
175
'net',
176
'ui',
177
--
64
--
178
2.28.0
65
2.31.1
179
66
180
67
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Alistair Francis <alistair.francis@wdc.com>
2
2
3
This is an effort to clean up the hw/riscv directory. Ideally it
3
Since commit 1a9540d1f1a
4
should only contain the RISC-V SoC / machine codes plus generic
4
("target/riscv: Drop support for ISA spec version 1.09.1")
5
codes. Let's move sifive_u_otp model to hw/misc directory.
5
these definitions are unused, remove them.
6
6
7
Signed-off-by: Bin Meng <bin.meng@windriver.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-Id: <1599129623-68957-4-git-send-email-bmeng.cn@gmail.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
7
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
8
Reviewed-by: Frank Chang <frank.chang@sifive.com>
9
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
11
Message-id: f4d8a7a035f39c0a35d44c1e371c5c99cc2fa15a.1634531504.git.alistair.francis@wdc.com
11
---
12
---
12
include/hw/{riscv => misc}/sifive_u_otp.h | 0
13
target/riscv/cpu_bits.h | 8 --------
13
include/hw/riscv/sifive_u.h | 2 +-
14
1 file changed, 8 deletions(-)
14
hw/{riscv => misc}/sifive_u_otp.c | 2 +-
15
hw/misc/Kconfig | 3 +++
16
hw/misc/meson.build | 1 +
17
hw/riscv/Kconfig | 1 +
18
hw/riscv/meson.build | 1 -
19
7 files changed, 7 insertions(+), 3 deletions(-)
20
rename include/hw/{riscv => misc}/sifive_u_otp.h (100%)
21
rename hw/{riscv => misc}/sifive_u_otp.c (99%)
22
15
23
diff --git a/include/hw/riscv/sifive_u_otp.h b/include/hw/misc/sifive_u_otp.h
16
diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h
24
similarity index 100%
25
rename from include/hw/riscv/sifive_u_otp.h
26
rename to include/hw/misc/sifive_u_otp.h
27
diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h
28
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
29
--- a/include/hw/riscv/sifive_u.h
18
--- a/target/riscv/cpu_bits.h
30
+++ b/include/hw/riscv/sifive_u.h
19
+++ b/target/riscv/cpu_bits.h
31
@@ -XXX,XX +XXX,XX @@
20
@@ -XXX,XX +XXX,XX @@
32
#include "hw/riscv/riscv_hart.h"
21
#define SATP64_ASID 0x0FFFF00000000000ULL
33
#include "hw/riscv/sifive_cpu.h"
22
#define SATP64_PPN 0x00000FFFFFFFFFFFULL
34
#include "hw/riscv/sifive_gpio.h"
23
35
-#include "hw/riscv/sifive_u_otp.h"
24
-/* VM modes (mstatus.vm) privileged ISA 1.9.1 */
36
+#include "hw/misc/sifive_u_otp.h"
25
-#define VM_1_09_MBARE 0
37
#include "hw/misc/sifive_u_prci.h"
26
-#define VM_1_09_MBB 1
38
27
-#define VM_1_09_MBBID 2
39
#define TYPE_RISCV_U_SOC "riscv.sifive.u.soc"
28
-#define VM_1_09_SV32 8
40
diff --git a/hw/riscv/sifive_u_otp.c b/hw/misc/sifive_u_otp.c
29
-#define VM_1_09_SV39 9
41
similarity index 99%
30
-#define VM_1_09_SV48 10
42
rename from hw/riscv/sifive_u_otp.c
31
-
43
rename to hw/misc/sifive_u_otp.c
32
/* VM modes (satp.mode) privileged ISA 1.10 */
44
index XXXXXXX..XXXXXXX 100644
33
#define VM_1_10_MBARE 0
45
--- a/hw/riscv/sifive_u_otp.c
34
#define VM_1_10_SV32 1
46
+++ b/hw/misc/sifive_u_otp.c
47
@@ -XXX,XX +XXX,XX @@
48
#include "hw/sysbus.h"
49
#include "qemu/log.h"
50
#include "qemu/module.h"
51
-#include "hw/riscv/sifive_u_otp.h"
52
+#include "hw/misc/sifive_u_otp.h"
53
54
static uint64_t sifive_u_otp_read(void *opaque, hwaddr addr, unsigned int size)
55
{
56
diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
57
index XXXXXXX..XXXXXXX 100644
58
--- a/hw/misc/Kconfig
59
+++ b/hw/misc/Kconfig
60
@@ -XXX,XX +XXX,XX @@ config AVR_POWER
61
config SIFIVE_E_PRCI
62
bool
63
64
+config SIFIVE_U_OTP
65
+ bool
66
+
67
config SIFIVE_U_PRCI
68
bool
69
70
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
71
index XXXXXXX..XXXXXXX 100644
72
--- a/hw/misc/meson.build
73
+++ b/hw/misc/meson.build
74
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_MOS6522', if_true: files('mos6522.c'))
75
76
# RISC-V devices
77
softmmu_ss.add(when: 'CONFIG_SIFIVE_E_PRCI', if_true: files('sifive_e_prci.c'))
78
+softmmu_ss.add(when: 'CONFIG_SIFIVE_U_OTP', if_true: files('sifive_u_otp.c'))
79
softmmu_ss.add(when: 'CONFIG_SIFIVE_U_PRCI', if_true: files('sifive_u_prci.c'))
80
81
# PKUnity SoC devices
82
diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
83
index XXXXXXX..XXXXXXX 100644
84
--- a/hw/riscv/Kconfig
85
+++ b/hw/riscv/Kconfig
86
@@ -XXX,XX +XXX,XX @@ config SIFIVE_U
87
select HART
88
select SIFIVE
89
select SIFIVE_PDMA
90
+ select SIFIVE_U_OTP
91
select SIFIVE_U_PRCI
92
select UNIMP
93
94
diff --git a/hw/riscv/meson.build b/hw/riscv/meson.build
95
index XXXXXXX..XXXXXXX 100644
96
--- a/hw/riscv/meson.build
97
+++ b/hw/riscv/meson.build
98
@@ -XXX,XX +XXX,XX @@ riscv_ss.add(when: 'CONFIG_SIFIVE', if_true: files('sifive_test.c'))
99
riscv_ss.add(when: 'CONFIG_SIFIVE', if_true: files('sifive_uart.c'))
100
riscv_ss.add(when: 'CONFIG_SIFIVE_E', if_true: files('sifive_e.c'))
101
riscv_ss.add(when: 'CONFIG_SIFIVE_U', if_true: files('sifive_u.c'))
102
-riscv_ss.add(when: 'CONFIG_SIFIVE_U', if_true: files('sifive_u_otp.c'))
103
riscv_ss.add(when: 'CONFIG_SPIKE', if_true: files('riscv_htif.c'))
104
riscv_ss.add(when: 'CONFIG_SPIKE', if_true: files('spike.c'))
105
riscv_ss.add(when: 'CONFIG_MICROCHIP_PFSOC', if_true: files('microchip_pfsoc.c'))
106
--
35
--
107
2.28.0
36
2.31.1
108
37
109
38
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Alistair Francis <alistair.francis@wdc.com>
2
2
3
This is an effort to clean up the hw/riscv directory. Ideally it
3
Organise the CPU properties so that standard extensions come first
4
should only contain the RISC-V SoC / machine codes plus generic
4
then followed by experimental extensions.
5
codes. Let's move riscv_htif model to hw/char directory.
6
5
7
Signed-off-by: Bin Meng <bin.meng@windriver.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-Id: <1599129623-68957-8-git-send-email-bmeng.cn@gmail.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
6
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
7
Reviewed-by: Frank Chang <frank.chang@sifive.com>
8
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
9
Message-id: b6598570f60c5ee7f402be56d837bb44b289cc4d.1634531504.git.alistair.francis@wdc.com
11
---
10
---
12
include/hw/{riscv => char}/riscv_htif.h | 0
11
target/riscv/cpu.c | 17 ++++++++++-------
13
hw/{riscv => char}/riscv_htif.c | 2 +-
12
1 file changed, 10 insertions(+), 7 deletions(-)
14
hw/riscv/spike.c | 2 +-
15
hw/char/Kconfig | 3 +++
16
hw/char/meson.build | 1 +
17
hw/riscv/Kconfig | 3 ---
18
hw/riscv/meson.build | 1 -
19
7 files changed, 6 insertions(+), 6 deletions(-)
20
rename include/hw/{riscv => char}/riscv_htif.h (100%)
21
rename hw/{riscv => char}/riscv_htif.c (99%)
22
13
23
diff --git a/include/hw/riscv/riscv_htif.h b/include/hw/char/riscv_htif.h
14
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
24
similarity index 100%
25
rename from include/hw/riscv/riscv_htif.h
26
rename to include/hw/char/riscv_htif.h
27
diff --git a/hw/riscv/riscv_htif.c b/hw/char/riscv_htif.c
28
similarity index 99%
29
rename from hw/riscv/riscv_htif.c
30
rename to hw/char/riscv_htif.c
31
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
32
--- a/hw/riscv/riscv_htif.c
16
--- a/target/riscv/cpu.c
33
+++ b/hw/char/riscv_htif.c
17
+++ b/target/riscv/cpu.c
34
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_init(Object *obj)
35
#include "qapi/error.h"
19
}
36
#include "qemu/log.h"
20
37
#include "hw/sysbus.h"
21
static Property riscv_cpu_properties[] = {
38
+#include "hw/char/riscv_htif.h"
22
+ /* Defaults for standard extensions */
39
#include "hw/char/serial.h"
23
DEFINE_PROP_BOOL("i", RISCVCPU, cfg.ext_i, true),
40
#include "chardev/char.h"
24
DEFINE_PROP_BOOL("e", RISCVCPU, cfg.ext_e, false),
41
#include "chardev/char-fe.h"
25
DEFINE_PROP_BOOL("g", RISCVCPU, cfg.ext_g, true),
42
-#include "hw/riscv/riscv_htif.h"
26
@@ -XXX,XX +XXX,XX @@ static Property riscv_cpu_properties[] = {
43
#include "qemu/timer.h"
27
DEFINE_PROP_BOOL("c", RISCVCPU, cfg.ext_c, true),
44
#include "qemu/error-report.h"
28
DEFINE_PROP_BOOL("s", RISCVCPU, cfg.ext_s, true),
45
29
DEFINE_PROP_BOOL("u", RISCVCPU, cfg.ext_u, true),
46
diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c
30
- /* This is experimental so mark with 'x-' */
47
index XXXXXXX..XXXXXXX 100644
31
+ DEFINE_PROP_BOOL("Counters", RISCVCPU, cfg.ext_counters, true),
48
--- a/hw/riscv/spike.c
32
+ DEFINE_PROP_BOOL("Zifencei", RISCVCPU, cfg.ext_ifencei, true),
49
+++ b/hw/riscv/spike.c
33
+ DEFINE_PROP_BOOL("Zicsr", RISCVCPU, cfg.ext_icsr, true),
50
@@ -XXX,XX +XXX,XX @@
34
+ DEFINE_PROP_BOOL("mmu", RISCVCPU, cfg.mmu, true),
51
#include "hw/loader.h"
35
+ DEFINE_PROP_BOOL("pmp", RISCVCPU, cfg.pmp, true),
52
#include "hw/sysbus.h"
53
#include "target/riscv/cpu.h"
54
-#include "hw/riscv/riscv_htif.h"
55
#include "hw/riscv/riscv_hart.h"
56
#include "hw/riscv/spike.h"
57
#include "hw/riscv/boot.h"
58
#include "hw/riscv/numa.h"
59
+#include "hw/char/riscv_htif.h"
60
#include "hw/intc/sifive_clint.h"
61
#include "chardev/char.h"
62
#include "sysemu/arch_init.h"
63
diff --git a/hw/char/Kconfig b/hw/char/Kconfig
64
index XXXXXXX..XXXXXXX 100644
65
--- a/hw/char/Kconfig
66
+++ b/hw/char/Kconfig
67
@@ -XXX,XX +XXX,XX @@
68
config ESCC
69
bool
70
71
+config HTIF
72
+ bool
73
+
36
+
74
config PARALLEL
37
+ DEFINE_PROP_STRING("priv_spec", RISCVCPU, cfg.priv_spec),
75
bool
38
+
76
default y
39
+ /* These are experimental so mark with 'x-' */
77
diff --git a/hw/char/meson.build b/hw/char/meson.build
40
DEFINE_PROP_BOOL("x-zba", RISCVCPU, cfg.ext_zba, false),
78
index XXXXXXX..XXXXXXX 100644
41
DEFINE_PROP_BOOL("x-zbb", RISCVCPU, cfg.ext_zbb, false),
79
--- a/hw/char/meson.build
42
DEFINE_PROP_BOOL("x-zbc", RISCVCPU, cfg.ext_zbc, false),
80
+++ b/hw/char/meson.build
43
DEFINE_PROP_BOOL("x-zbs", RISCVCPU, cfg.ext_zbs, false),
81
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_SH4', if_true: files('sh_serial.c'))
44
DEFINE_PROP_BOOL("x-h", RISCVCPU, cfg.ext_h, false),
82
softmmu_ss.add(when: 'CONFIG_STM32F2XX_USART', if_true: files('stm32f2xx_usart.c'))
45
DEFINE_PROP_BOOL("x-v", RISCVCPU, cfg.ext_v, false),
83
softmmu_ss.add(when: 'CONFIG_MCHP_PFSOC_MMUART', if_true: files('mchp_pfsoc_mmuart.c'))
46
- DEFINE_PROP_BOOL("Counters", RISCVCPU, cfg.ext_counters, true),
84
47
- DEFINE_PROP_BOOL("Zifencei", RISCVCPU, cfg.ext_ifencei, true),
85
+specific_ss.add(when: 'CONFIG_HTIF', if_true: files('riscv_htif.c'))
48
- DEFINE_PROP_BOOL("Zicsr", RISCVCPU, cfg.ext_icsr, true),
86
specific_ss.add(when: 'CONFIG_TERMINAL3270', if_true: files('terminal3270.c'))
49
- DEFINE_PROP_STRING("priv_spec", RISCVCPU, cfg.priv_spec),
87
specific_ss.add(when: 'CONFIG_VIRTIO', if_true: files('virtio-serial-bus.c'))
50
DEFINE_PROP_STRING("vext_spec", RISCVCPU, cfg.vext_spec),
88
specific_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr_vty.c'))
51
DEFINE_PROP_UINT16("vlen", RISCVCPU, cfg.vlen, 128),
89
diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
52
DEFINE_PROP_UINT16("elen", RISCVCPU, cfg.elen, 64),
90
index XXXXXXX..XXXXXXX 100644
53
- DEFINE_PROP_BOOL("mmu", RISCVCPU, cfg.mmu, true),
91
--- a/hw/riscv/Kconfig
54
- DEFINE_PROP_BOOL("pmp", RISCVCPU, cfg.pmp, true),
92
+++ b/hw/riscv/Kconfig
55
/* ePMP 0.9.3 */
93
@@ -XXX,XX +XXX,XX @@
56
DEFINE_PROP_BOOL("x-epmp", RISCVCPU, cfg.epmp, false),
94
-config HTIF
95
- bool
96
-
97
config HART
98
bool
99
100
diff --git a/hw/riscv/meson.build b/hw/riscv/meson.build
101
index XXXXXXX..XXXXXXX 100644
102
--- a/hw/riscv/meson.build
103
+++ b/hw/riscv/meson.build
104
@@ -XXX,XX +XXX,XX @@ riscv_ss.add(when: 'CONFIG_SIFIVE', if_true: files('sifive_test.c'))
105
riscv_ss.add(when: 'CONFIG_SIFIVE', if_true: files('sifive_uart.c'))
106
riscv_ss.add(when: 'CONFIG_SIFIVE_E', if_true: files('sifive_e.c'))
107
riscv_ss.add(when: 'CONFIG_SIFIVE_U', if_true: files('sifive_u.c'))
108
-riscv_ss.add(when: 'CONFIG_SPIKE', if_true: files('riscv_htif.c'))
109
riscv_ss.add(when: 'CONFIG_SPIKE', if_true: files('spike.c'))
110
riscv_ss.add(when: 'CONFIG_MICROCHIP_PFSOC', if_true: files('microchip_pfsoc.c'))
111
57
112
--
58
--
113
2.28.0
59
2.31.1
114
60
115
61
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Microchip PolarFire SoC integrates a DMA engine that supports:
3
Move the function to cpu_helper.c, as it is large and growing.
4
* Independent concurrent DMA transfers using 4 DMA channels
5
* Generation of interrupts on various conditions during execution
6
which is actually an IP reused from the SiFive FU540 chip.
7
4
8
This creates a model to support both polling and interrupt modes.
5
Reviewed-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
9
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
Signed-off-by: Bin Meng <bin.meng@windriver.com>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11
Acked-by: Alistair Francis <alistair.francis@wdc.com>
8
Message-id: 20211020031709.359469-2-richard.henderson@linaro.org
12
Message-Id: <1598924352-89526-10-git-send-email-bmeng.cn@gmail.com>
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
9
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
14
---
10
---
15
include/hw/dma/sifive_pdma.h | 57 +++++++
11
target/riscv/cpu.h | 47 ++-------------------------------------
16
hw/dma/sifive_pdma.c | 313 +++++++++++++++++++++++++++++++++++
12
target/riscv/cpu_helper.c | 46 ++++++++++++++++++++++++++++++++++++++
17
hw/dma/Kconfig | 3 +
13
2 files changed, 48 insertions(+), 45 deletions(-)
18
hw/dma/meson.build | 1 +
19
4 files changed, 374 insertions(+)
20
create mode 100644 include/hw/dma/sifive_pdma.h
21
create mode 100644 hw/dma/sifive_pdma.c
22
14
23
diff --git a/include/hw/dma/sifive_pdma.h b/include/hw/dma/sifive_pdma.h
15
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
24
new file mode 100644
16
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX
17
--- a/target/riscv/cpu.h
26
--- /dev/null
18
+++ b/target/riscv/cpu.h
27
+++ b/include/hw/dma/sifive_pdma.h
19
@@ -XXX,XX +XXX,XX @@ static inline uint32_t vext_get_vlmax(RISCVCPU *cpu, target_ulong vtype)
28
@@ -XXX,XX +XXX,XX @@
20
return cpu->cfg.vlen >> (sew + 3 - lmul);
29
+/*
21
}
30
+ * SiFive Platform DMA emulation
22
31
+ *
23
-static inline void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc,
32
+ * Copyright (c) 2020 Wind River Systems, Inc.
24
- target_ulong *cs_base, uint32_t *pflags)
33
+ *
25
-{
34
+ * Author:
26
- uint32_t flags = 0;
35
+ * Bin Meng <bin.meng@windriver.com>
27
-
36
+ *
28
- *pc = env->pc;
37
+ * This program is free software; you can redistribute it and/or
29
- *cs_base = 0;
38
+ * modify it under the terms of the GNU General Public License as
30
-
39
+ * published by the Free Software Foundation; either version 2 or
31
- if (riscv_has_ext(env, RVV)) {
40
+ * (at your option) version 3 of the License.
32
- uint32_t vlmax = vext_get_vlmax(env_archcpu(env), env->vtype);
41
+ *
33
- bool vl_eq_vlmax = (env->vstart == 0) && (vlmax == env->vl);
42
+ * This program is distributed in the hope that it will be useful,
34
- flags = FIELD_DP32(flags, TB_FLAGS, VILL,
43
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
35
- FIELD_EX64(env->vtype, VTYPE, VILL));
44
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36
- flags = FIELD_DP32(flags, TB_FLAGS, SEW,
45
+ * GNU General Public License for more details.
37
- FIELD_EX64(env->vtype, VTYPE, VSEW));
46
+ *
38
- flags = FIELD_DP32(flags, TB_FLAGS, LMUL,
47
+ * You should have received a copy of the GNU General Public License along
39
- FIELD_EX64(env->vtype, VTYPE, VLMUL));
48
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
40
- flags = FIELD_DP32(flags, TB_FLAGS, VL_EQ_VLMAX, vl_eq_vlmax);
49
+ */
41
- } else {
42
- flags = FIELD_DP32(flags, TB_FLAGS, VILL, 1);
43
- }
44
-
45
-#ifdef CONFIG_USER_ONLY
46
- flags |= TB_FLAGS_MSTATUS_FS;
47
-#else
48
- flags |= cpu_mmu_index(env, 0);
49
- if (riscv_cpu_fp_enabled(env)) {
50
- flags |= env->mstatus & MSTATUS_FS;
51
- }
52
-
53
- if (riscv_has_ext(env, RVH)) {
54
- if (env->priv == PRV_M ||
55
- (env->priv == PRV_S && !riscv_cpu_virt_enabled(env)) ||
56
- (env->priv == PRV_U && !riscv_cpu_virt_enabled(env) &&
57
- get_field(env->hstatus, HSTATUS_HU))) {
58
- flags = FIELD_DP32(flags, TB_FLAGS, HLSX, 1);
59
- }
60
-
61
- flags = FIELD_DP32(flags, TB_FLAGS, MSTATUS_HS_FS,
62
- get_field(env->mstatus_hs, MSTATUS_FS));
63
- }
64
-#endif
65
-
66
- *pflags = flags;
67
-}
68
+void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc,
69
+ target_ulong *cs_base, uint32_t *pflags);
70
71
RISCVException riscv_csrrw(CPURISCVState *env, int csrno,
72
target_ulong *ret_value,
73
diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
74
index XXXXXXX..XXXXXXX 100644
75
--- a/target/riscv/cpu_helper.c
76
+++ b/target/riscv/cpu_helper.c
77
@@ -XXX,XX +XXX,XX @@ int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch)
78
#endif
79
}
80
81
+void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc,
82
+ target_ulong *cs_base, uint32_t *pflags)
83
+{
84
+ uint32_t flags = 0;
50
+
85
+
51
+#ifndef SIFIVE_PDMA_H
86
+ *pc = env->pc;
52
+#define SIFIVE_PDMA_H
87
+ *cs_base = 0;
53
+
88
+
54
+struct sifive_pdma_chan {
89
+ if (riscv_has_ext(env, RVV)) {
55
+ uint32_t control;
90
+ uint32_t vlmax = vext_get_vlmax(env_archcpu(env), env->vtype);
56
+ uint32_t next_config;
91
+ bool vl_eq_vlmax = (env->vstart == 0) && (vlmax == env->vl);
57
+ uint64_t next_bytes;
92
+ flags = FIELD_DP32(flags, TB_FLAGS, VILL,
58
+ uint64_t next_dst;
93
+ FIELD_EX64(env->vtype, VTYPE, VILL));
59
+ uint64_t next_src;
94
+ flags = FIELD_DP32(flags, TB_FLAGS, SEW,
60
+ uint32_t exec_config;
95
+ FIELD_EX64(env->vtype, VTYPE, VSEW));
61
+ uint64_t exec_bytes;
96
+ flags = FIELD_DP32(flags, TB_FLAGS, LMUL,
62
+ uint64_t exec_dst;
97
+ FIELD_EX64(env->vtype, VTYPE, VLMUL));
63
+ uint64_t exec_src;
98
+ flags = FIELD_DP32(flags, TB_FLAGS, VL_EQ_VLMAX, vl_eq_vlmax);
64
+ int state;
99
+ } else {
65
+};
100
+ flags = FIELD_DP32(flags, TB_FLAGS, VILL, 1);
66
+
67
+#define SIFIVE_PDMA_CHANS 4
68
+#define SIFIVE_PDMA_IRQS (SIFIVE_PDMA_CHANS * 2)
69
+#define SIFIVE_PDMA_REG_SIZE 0x100000
70
+#define SIFIVE_PDMA_CHAN_NO(reg) ((reg & (SIFIVE_PDMA_REG_SIZE - 1)) >> 12)
71
+
72
+typedef struct SiFivePDMAState {
73
+ SysBusDevice parent;
74
+ MemoryRegion iomem;
75
+ qemu_irq irq[SIFIVE_PDMA_IRQS];
76
+
77
+ struct sifive_pdma_chan chan[SIFIVE_PDMA_CHANS];
78
+} SiFivePDMAState;
79
+
80
+#define TYPE_SIFIVE_PDMA "sifive.pdma"
81
+
82
+#define SIFIVE_PDMA(obj) \
83
+ OBJECT_CHECK(SiFivePDMAState, (obj), TYPE_SIFIVE_PDMA)
84
+
85
+#endif /* SIFIVE_PDMA_H */
86
diff --git a/hw/dma/sifive_pdma.c b/hw/dma/sifive_pdma.c
87
new file mode 100644
88
index XXXXXXX..XXXXXXX
89
--- /dev/null
90
+++ b/hw/dma/sifive_pdma.c
91
@@ -XXX,XX +XXX,XX @@
92
+/*
93
+ * SiFive Platform DMA emulation
94
+ *
95
+ * Copyright (c) 2020 Wind River Systems, Inc.
96
+ *
97
+ * Author:
98
+ * Bin Meng <bin.meng@windriver.com>
99
+ *
100
+ * This program is free software; you can redistribute it and/or
101
+ * modify it under the terms of the GNU General Public License as
102
+ * published by the Free Software Foundation; either version 2 or
103
+ * (at your option) version 3 of the License.
104
+ *
105
+ * This program is distributed in the hope that it will be useful,
106
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
107
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
108
+ * GNU General Public License for more details.
109
+ *
110
+ * You should have received a copy of the GNU General Public License along
111
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
112
+ */
113
+
114
+#include "qemu/osdep.h"
115
+#include "qemu/bitops.h"
116
+#include "qemu/log.h"
117
+#include "qapi/error.h"
118
+#include "hw/hw.h"
119
+#include "hw/irq.h"
120
+#include "hw/qdev-properties.h"
121
+#include "hw/sysbus.h"
122
+#include "migration/vmstate.h"
123
+#include "sysemu/dma.h"
124
+#include "hw/dma/sifive_pdma.h"
125
+
126
+#define DMA_CONTROL 0x000
127
+#define CONTROL_CLAIM BIT(0)
128
+#define CONTROL_RUN BIT(1)
129
+#define CONTROL_DONE_IE BIT(14)
130
+#define CONTROL_ERR_IE BIT(15)
131
+#define CONTROL_DONE BIT(30)
132
+#define CONTROL_ERR BIT(31)
133
+
134
+#define DMA_NEXT_CONFIG 0x004
135
+#define CONFIG_REPEAT BIT(2)
136
+#define CONFIG_ORDER BIT(3)
137
+#define CONFIG_WRSZ_SHIFT 24
138
+#define CONFIG_RDSZ_SHIFT 28
139
+#define CONFIG_SZ_MASK 0xf
140
+
141
+#define DMA_NEXT_BYTES 0x008
142
+#define DMA_NEXT_DST 0x010
143
+#define DMA_NEXT_SRC 0x018
144
+#define DMA_EXEC_CONFIG 0x104
145
+#define DMA_EXEC_BYTES 0x108
146
+#define DMA_EXEC_DST 0x110
147
+#define DMA_EXEC_SRC 0x118
148
+
149
+enum dma_chan_state {
150
+ DMA_CHAN_STATE_IDLE,
151
+ DMA_CHAN_STATE_STARTED,
152
+ DMA_CHAN_STATE_ERROR,
153
+ DMA_CHAN_STATE_DONE
154
+};
155
+
156
+static void sifive_pdma_run(SiFivePDMAState *s, int ch)
157
+{
158
+ uint64_t bytes = s->chan[ch].next_bytes;
159
+ uint64_t dst = s->chan[ch].next_dst;
160
+ uint64_t src = s->chan[ch].next_src;
161
+ uint32_t config = s->chan[ch].next_config;
162
+ int wsize, rsize, size;
163
+ uint8_t buf[64];
164
+ int n;
165
+
166
+ /* do nothing if bytes to transfer is zero */
167
+ if (!bytes) {
168
+ goto error;
169
+ }
101
+ }
170
+
102
+
171
+ /*
103
+#ifdef CONFIG_USER_ONLY
172
+ * The manual does not describe how the hardware behaviors when
104
+ flags |= TB_FLAGS_MSTATUS_FS;
173
+ * config.wsize and config.rsize are given different values.
105
+#else
174
+ * A common case is memory to memory DMA, and in this case they
106
+ flags |= cpu_mmu_index(env, 0);
175
+ * are normally the same. Abort if this expectation fails.
107
+ if (riscv_cpu_fp_enabled(env)) {
176
+ */
108
+ flags |= env->mstatus & MSTATUS_FS;
177
+ wsize = (config >> CONFIG_WRSZ_SHIFT) & CONFIG_SZ_MASK;
178
+ rsize = (config >> CONFIG_RDSZ_SHIFT) & CONFIG_SZ_MASK;
179
+ if (wsize != rsize) {
180
+ goto error;
181
+ }
109
+ }
182
+
110
+
183
+ /*
111
+ if (riscv_has_ext(env, RVH)) {
184
+ * Calculate the transaction size
112
+ if (env->priv == PRV_M ||
185
+ *
113
+ (env->priv == PRV_S && !riscv_cpu_virt_enabled(env)) ||
186
+ * size field is base 2 logarithm of DMA transaction size,
114
+ (env->priv == PRV_U && !riscv_cpu_virt_enabled(env) &&
187
+ * but there is an upper limit of 64 bytes per transaction.
115
+ get_field(env->hstatus, HSTATUS_HU))) {
188
+ */
116
+ flags = FIELD_DP32(flags, TB_FLAGS, HLSX, 1);
189
+ size = wsize;
117
+ }
190
+ if (size > 6) {
118
+
191
+ size = 6;
119
+ flags = FIELD_DP32(flags, TB_FLAGS, MSTATUS_HS_FS,
120
+ get_field(env->mstatus_hs, MSTATUS_FS));
192
+ }
121
+ }
193
+ size = 1 << size;
122
+#endif
194
+
123
+
195
+ /* the bytes to transfer should be multiple of transaction size */
124
+ *pflags = flags;
196
+ if (bytes % size) {
197
+ goto error;
198
+ }
199
+
200
+ /* indicate a DMA transfer is started */
201
+ s->chan[ch].state = DMA_CHAN_STATE_STARTED;
202
+ s->chan[ch].control &= ~CONTROL_DONE;
203
+ s->chan[ch].control &= ~CONTROL_ERR;
204
+
205
+ /* load the next_ registers into their exec_ counterparts */
206
+ s->chan[ch].exec_config = config;
207
+ s->chan[ch].exec_bytes = bytes;
208
+ s->chan[ch].exec_dst = dst;
209
+ s->chan[ch].exec_src = src;
210
+
211
+ for (n = 0; n < bytes / size; n++) {
212
+ cpu_physical_memory_read(s->chan[ch].exec_src, buf, size);
213
+ cpu_physical_memory_write(s->chan[ch].exec_dst, buf, size);
214
+ s->chan[ch].exec_src += size;
215
+ s->chan[ch].exec_dst += size;
216
+ s->chan[ch].exec_bytes -= size;
217
+ }
218
+
219
+ /* indicate a DMA transfer is done */
220
+ s->chan[ch].state = DMA_CHAN_STATE_DONE;
221
+ s->chan[ch].control &= ~CONTROL_RUN;
222
+ s->chan[ch].control |= CONTROL_DONE;
223
+
224
+ /* reload exec_ registers if repeat is required */
225
+ if (s->chan[ch].next_config & CONFIG_REPEAT) {
226
+ s->chan[ch].exec_bytes = bytes;
227
+ s->chan[ch].exec_dst = dst;
228
+ s->chan[ch].exec_src = src;
229
+ }
230
+
231
+ return;
232
+
233
+error:
234
+ s->chan[ch].state = DMA_CHAN_STATE_ERROR;
235
+ s->chan[ch].control |= CONTROL_ERR;
236
+ return;
237
+}
125
+}
238
+
126
+
239
+static inline void sifive_pdma_update_irq(SiFivePDMAState *s, int ch)
127
#ifndef CONFIG_USER_ONLY
240
+{
128
static int riscv_cpu_local_irq_pending(CPURISCVState *env)
241
+ bool done_ie, err_ie;
129
{
242
+
243
+ done_ie = !!(s->chan[ch].control & CONTROL_DONE_IE);
244
+ err_ie = !!(s->chan[ch].control & CONTROL_ERR_IE);
245
+
246
+ if (done_ie && (s->chan[ch].control & CONTROL_DONE)) {
247
+ qemu_irq_raise(s->irq[ch * 2]);
248
+ } else {
249
+ qemu_irq_lower(s->irq[ch * 2]);
250
+ }
251
+
252
+ if (err_ie && (s->chan[ch].control & CONTROL_ERR)) {
253
+ qemu_irq_raise(s->irq[ch * 2 + 1]);
254
+ } else {
255
+ qemu_irq_lower(s->irq[ch * 2 + 1]);
256
+ }
257
+
258
+ s->chan[ch].state = DMA_CHAN_STATE_IDLE;
259
+}
260
+
261
+static uint64_t sifive_pdma_read(void *opaque, hwaddr offset, unsigned size)
262
+{
263
+ SiFivePDMAState *s = opaque;
264
+ int ch = SIFIVE_PDMA_CHAN_NO(offset);
265
+ uint64_t val = 0;
266
+
267
+ if (ch >= SIFIVE_PDMA_CHANS) {
268
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: Invalid channel no %d\n",
269
+ __func__, ch);
270
+ return 0;
271
+ }
272
+
273
+ offset &= 0xfff;
274
+ switch (offset) {
275
+ case DMA_CONTROL:
276
+ val = s->chan[ch].control;
277
+ break;
278
+ case DMA_NEXT_CONFIG:
279
+ val = s->chan[ch].next_config;
280
+ break;
281
+ case DMA_NEXT_BYTES:
282
+ val = s->chan[ch].next_bytes;
283
+ break;
284
+ case DMA_NEXT_DST:
285
+ val = s->chan[ch].next_dst;
286
+ break;
287
+ case DMA_NEXT_SRC:
288
+ val = s->chan[ch].next_src;
289
+ break;
290
+ case DMA_EXEC_CONFIG:
291
+ val = s->chan[ch].exec_config;
292
+ break;
293
+ case DMA_EXEC_BYTES:
294
+ val = s->chan[ch].exec_bytes;
295
+ break;
296
+ case DMA_EXEC_DST:
297
+ val = s->chan[ch].exec_dst;
298
+ break;
299
+ case DMA_EXEC_SRC:
300
+ val = s->chan[ch].exec_src;
301
+ break;
302
+ default:
303
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIX "\n",
304
+ __func__, offset);
305
+ break;
306
+ }
307
+
308
+ return val;
309
+}
310
+
311
+static void sifive_pdma_write(void *opaque, hwaddr offset,
312
+ uint64_t value, unsigned size)
313
+{
314
+ SiFivePDMAState *s = opaque;
315
+ int ch = SIFIVE_PDMA_CHAN_NO(offset);
316
+
317
+ if (ch >= SIFIVE_PDMA_CHANS) {
318
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: Invalid channel no %d\n",
319
+ __func__, ch);
320
+ return;
321
+ }
322
+
323
+ offset &= 0xfff;
324
+ switch (offset) {
325
+ case DMA_CONTROL:
326
+ s->chan[ch].control = value;
327
+
328
+ if (value & CONTROL_RUN) {
329
+ sifive_pdma_run(s, ch);
330
+ }
331
+
332
+ sifive_pdma_update_irq(s, ch);
333
+ break;
334
+ case DMA_NEXT_CONFIG:
335
+ s->chan[ch].next_config = value;
336
+ break;
337
+ case DMA_NEXT_BYTES:
338
+ s->chan[ch].next_bytes = value;
339
+ break;
340
+ case DMA_NEXT_DST:
341
+ s->chan[ch].next_dst = value;
342
+ break;
343
+ case DMA_NEXT_SRC:
344
+ s->chan[ch].next_src = value;
345
+ break;
346
+ case DMA_EXEC_CONFIG:
347
+ case DMA_EXEC_BYTES:
348
+ case DMA_EXEC_DST:
349
+ case DMA_EXEC_SRC:
350
+ /* these are read-only registers */
351
+ break;
352
+ default:
353
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIX "\n",
354
+ __func__, offset);
355
+ break;
356
+ }
357
+}
358
+
359
+static const MemoryRegionOps sifive_pdma_ops = {
360
+ .read = sifive_pdma_read,
361
+ .write = sifive_pdma_write,
362
+ .endianness = DEVICE_LITTLE_ENDIAN,
363
+ /* there are 32-bit and 64-bit wide registers */
364
+ .impl = {
365
+ .min_access_size = 4,
366
+ .max_access_size = 8,
367
+ }
368
+};
369
+
370
+static void sifive_pdma_realize(DeviceState *dev, Error **errp)
371
+{
372
+ SiFivePDMAState *s = SIFIVE_PDMA(dev);
373
+ int i;
374
+
375
+ memory_region_init_io(&s->iomem, OBJECT(dev), &sifive_pdma_ops, s,
376
+ TYPE_SIFIVE_PDMA, SIFIVE_PDMA_REG_SIZE);
377
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
378
+
379
+ for (i = 0; i < SIFIVE_PDMA_IRQS; i++) {
380
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq[i]);
381
+ }
382
+}
383
+
384
+static void sifive_pdma_class_init(ObjectClass *klass, void *data)
385
+{
386
+ DeviceClass *dc = DEVICE_CLASS(klass);
387
+
388
+ dc->desc = "SiFive Platform DMA controller";
389
+ dc->realize = sifive_pdma_realize;
390
+}
391
+
392
+static const TypeInfo sifive_pdma_info = {
393
+ .name = TYPE_SIFIVE_PDMA,
394
+ .parent = TYPE_SYS_BUS_DEVICE,
395
+ .instance_size = sizeof(SiFivePDMAState),
396
+ .class_init = sifive_pdma_class_init,
397
+};
398
+
399
+static void sifive_pdma_register_types(void)
400
+{
401
+ type_register_static(&sifive_pdma_info);
402
+}
403
+
404
+type_init(sifive_pdma_register_types)
405
diff --git a/hw/dma/Kconfig b/hw/dma/Kconfig
406
index XXXXXXX..XXXXXXX 100644
407
--- a/hw/dma/Kconfig
408
+++ b/hw/dma/Kconfig
409
@@ -XXX,XX +XXX,XX @@ config ZYNQ_DEVCFG
410
411
config STP2000
412
bool
413
+
414
+config SIFIVE_PDMA
415
+ bool
416
diff --git a/hw/dma/meson.build b/hw/dma/meson.build
417
index XXXXXXX..XXXXXXX 100644
418
--- a/hw/dma/meson.build
419
+++ b/hw/dma/meson.build
420
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx-zdma.c'))
421
softmmu_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_dma.c', 'soc_dma.c'))
422
softmmu_ss.add(when: 'CONFIG_PXA2XX', if_true: files('pxa2xx_dma.c'))
423
softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_dma.c'))
424
+softmmu_ss.add(when: 'CONFIG_SIFIVE_PDMA', if_true: files('sifive_pdma.c'))
425
--
130
--
426
2.28.0
131
2.31.1
427
132
428
133
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
This is an effort to clean up the hw/riscv directory. Ideally it
3
Move the MXL_RV* defines to enumerators.
4
should only contain the RISC-V SoC / machine codes plus generic
5
codes. Let's move sifive_u_prci model to hw/misc directory.
6
4
7
Signed-off-by: Bin Meng <bin.meng@windriver.com>
5
Reviewed-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-Id: <1599129623-68957-3-git-send-email-bmeng.cn@gmail.com>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20211020031709.359469-3-richard.henderson@linaro.org
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
9
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
10
---
12
include/hw/{riscv => misc}/sifive_u_prci.h | 0
11
target/riscv/cpu_bits.h | 8 +++++---
13
include/hw/riscv/sifive_u.h | 2 +-
12
1 file changed, 5 insertions(+), 3 deletions(-)
14
hw/{riscv => misc}/sifive_u_prci.c | 2 +-
15
hw/misc/Kconfig | 3 +++
16
hw/misc/meson.build | 1 +
17
hw/riscv/Kconfig | 1 +
18
hw/riscv/meson.build | 1 -
19
7 files changed, 7 insertions(+), 3 deletions(-)
20
rename include/hw/{riscv => misc}/sifive_u_prci.h (100%)
21
rename hw/{riscv => misc}/sifive_u_prci.c (99%)
22
13
23
diff --git a/include/hw/riscv/sifive_u_prci.h b/include/hw/misc/sifive_u_prci.h
14
diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h
24
similarity index 100%
25
rename from include/hw/riscv/sifive_u_prci.h
26
rename to include/hw/misc/sifive_u_prci.h
27
diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h
28
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
29
--- a/include/hw/riscv/sifive_u.h
16
--- a/target/riscv/cpu_bits.h
30
+++ b/include/hw/riscv/sifive_u.h
17
+++ b/target/riscv/cpu_bits.h
31
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@
32
#include "hw/riscv/riscv_hart.h"
19
#define MISA32_MXL 0xC0000000
33
#include "hw/riscv/sifive_cpu.h"
20
#define MISA64_MXL 0xC000000000000000ULL
34
#include "hw/riscv/sifive_gpio.h"
21
35
-#include "hw/riscv/sifive_u_prci.h"
22
-#define MXL_RV32 1
36
#include "hw/riscv/sifive_u_otp.h"
23
-#define MXL_RV64 2
37
+#include "hw/misc/sifive_u_prci.h"
24
-#define MXL_RV128 3
38
25
+typedef enum {
39
#define TYPE_RISCV_U_SOC "riscv.sifive.u.soc"
26
+ MXL_RV32 = 1,
40
#define RISCV_U_SOC(obj) \
27
+ MXL_RV64 = 2,
41
diff --git a/hw/riscv/sifive_u_prci.c b/hw/misc/sifive_u_prci.c
28
+ MXL_RV128 = 3,
42
similarity index 99%
29
+} RISCVMXL;
43
rename from hw/riscv/sifive_u_prci.c
30
44
rename to hw/misc/sifive_u_prci.c
31
/* sstatus CSR bits */
45
index XXXXXXX..XXXXXXX 100644
32
#define SSTATUS_UIE 0x00000001
46
--- a/hw/riscv/sifive_u_prci.c
47
+++ b/hw/misc/sifive_u_prci.c
48
@@ -XXX,XX +XXX,XX @@
49
#include "hw/sysbus.h"
50
#include "qemu/log.h"
51
#include "qemu/module.h"
52
-#include "hw/riscv/sifive_u_prci.h"
53
+#include "hw/misc/sifive_u_prci.h"
54
55
static uint64_t sifive_u_prci_read(void *opaque, hwaddr addr, unsigned int size)
56
{
57
diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
58
index XXXXXXX..XXXXXXX 100644
59
--- a/hw/misc/Kconfig
60
+++ b/hw/misc/Kconfig
61
@@ -XXX,XX +XXX,XX @@ config AVR_POWER
62
config SIFIVE_E_PRCI
63
bool
64
65
+config SIFIVE_U_PRCI
66
+ bool
67
+
68
source macio/Kconfig
69
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
70
index XXXXXXX..XXXXXXX 100644
71
--- a/hw/misc/meson.build
72
+++ b/hw/misc/meson.build
73
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_MOS6522', if_true: files('mos6522.c'))
74
75
# RISC-V devices
76
softmmu_ss.add(when: 'CONFIG_SIFIVE_E_PRCI', if_true: files('sifive_e_prci.c'))
77
+softmmu_ss.add(when: 'CONFIG_SIFIVE_U_PRCI', if_true: files('sifive_u_prci.c'))
78
79
# PKUnity SoC devices
80
softmmu_ss.add(when: 'CONFIG_PUV3', if_true: files('puv3_pm.c'))
81
diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
82
index XXXXXXX..XXXXXXX 100644
83
--- a/hw/riscv/Kconfig
84
+++ b/hw/riscv/Kconfig
85
@@ -XXX,XX +XXX,XX @@ config SIFIVE_U
86
select HART
87
select SIFIVE
88
select SIFIVE_PDMA
89
+ select SIFIVE_U_PRCI
90
select UNIMP
91
92
config SPIKE
93
diff --git a/hw/riscv/meson.build b/hw/riscv/meson.build
94
index XXXXXXX..XXXXXXX 100644
95
--- a/hw/riscv/meson.build
96
+++ b/hw/riscv/meson.build
97
@@ -XXX,XX +XXX,XX @@ riscv_ss.add(when: 'CONFIG_SIFIVE', if_true: files('sifive_uart.c'))
98
riscv_ss.add(when: 'CONFIG_SIFIVE_E', if_true: files('sifive_e.c'))
99
riscv_ss.add(when: 'CONFIG_SIFIVE_U', if_true: files('sifive_u.c'))
100
riscv_ss.add(when: 'CONFIG_SIFIVE_U', if_true: files('sifive_u_otp.c'))
101
-riscv_ss.add(when: 'CONFIG_SIFIVE_U', if_true: files('sifive_u_prci.c'))
102
riscv_ss.add(when: 'CONFIG_SPIKE', if_true: files('riscv_htif.c'))
103
riscv_ss.add(when: 'CONFIG_SPIKE', if_true: files('spike.c'))
104
riscv_ss.add(when: 'CONFIG_MICROCHIP_PFSOC', if_true: files('microchip_pfsoc.c'))
105
--
33
--
106
2.28.0
34
2.31.1
107
35
108
36
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Currently the reset vector address is hard-coded in a RISC-V CPU's
3
The hw representation of misa.mxl is at the high bits of the
4
instance_init() routine. In a real world we can have 2 exact same
4
misa csr. Representing this in the same way inside QEMU
5
CPUs except for the reset vector address, which is pretty common in
5
results in overly complex code trying to check that field.
6
the RISC-V core IP licensing business.
7
6
8
Normally reset vector address is a configurable parameter. Let's
7
Reviewed-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
9
create a 64-bit property to store the reset vector address which
10
covers both 32-bit and 64-bit CPUs.
11
12
Signed-off-by: Bin Meng <bin.meng@windriver.com>
13
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-Id: <1598924352-89526-2-git-send-email-bmeng.cn@gmail.com>
10
Message-id: 20211020031709.359469-4-richard.henderson@linaro.org
16
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
17
---
12
---
18
target/riscv/cpu.h | 1 +
13
target/riscv/cpu.h | 15 +++----
19
target/riscv/cpu.c | 1 +
14
linux-user/elfload.c | 2 +-
20
2 files changed, 2 insertions(+)
15
linux-user/riscv/cpu_loop.c | 2 +-
16
target/riscv/cpu.c | 78 +++++++++++++++++++++----------------
17
target/riscv/csr.c | 44 ++++++++++++++-------
18
target/riscv/gdbstub.c | 8 ++--
19
target/riscv/machine.c | 10 +++--
20
target/riscv/translate.c | 10 +++--
21
8 files changed, 100 insertions(+), 69 deletions(-)
21
22
22
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
23
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
23
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
24
--- a/target/riscv/cpu.h
25
--- a/target/riscv/cpu.h
25
+++ b/target/riscv/cpu.h
26
+++ b/target/riscv/cpu.h
26
@@ -XXX,XX +XXX,XX @@ typedef struct RISCVCPU {
27
@@ -XXX,XX +XXX,XX @@
27
uint16_t elen;
28
#include "exec/cpu-defs.h"
28
bool mmu;
29
#include "fpu/softfloat-types.h"
29
bool pmp;
30
#include "qom/object.h"
30
+ uint64_t resetvec;
31
+#include "cpu_bits.h"
31
} cfg;
32
32
} RISCVCPU;
33
#define TCG_GUEST_DEFAULT_MO 0
33
34
35
@@ -XXX,XX +XXX,XX @@
36
# define TYPE_RISCV_CPU_BASE TYPE_RISCV_CPU_BASE64
37
#endif
38
39
-#define RV32 ((target_ulong)1 << (TARGET_LONG_BITS - 2))
40
-#define RV64 ((target_ulong)2 << (TARGET_LONG_BITS - 2))
41
-
42
#define RV(x) ((target_ulong)1 << (x - 'A'))
43
44
#define RVI RV('I')
45
@@ -XXX,XX +XXX,XX @@ struct CPURISCVState {
46
target_ulong priv_ver;
47
target_ulong bext_ver;
48
target_ulong vext_ver;
49
- target_ulong misa;
50
- target_ulong misa_mask;
51
+
52
+ /* RISCVMXL, but uint32_t for vmstate migration */
53
+ uint32_t misa_mxl; /* current mxl */
54
+ uint32_t misa_mxl_max; /* max mxl for this cpu */
55
+ uint32_t misa_ext; /* current extensions */
56
+ uint32_t misa_ext_mask; /* max ext for this cpu */
57
58
uint32_t features;
59
60
@@ -XXX,XX +XXX,XX @@ struct RISCVCPU {
61
62
static inline int riscv_has_ext(CPURISCVState *env, target_ulong ext)
63
{
64
- return (env->misa & ext) != 0;
65
+ return (env->misa_ext & ext) != 0;
66
}
67
68
static inline bool riscv_feature(CPURISCVState *env, int feature)
69
@@ -XXX,XX +XXX,XX @@ static inline bool riscv_feature(CPURISCVState *env, int feature)
70
}
71
72
#include "cpu_user.h"
73
-#include "cpu_bits.h"
74
75
extern const char * const riscv_int_regnames[];
76
extern const char * const riscv_fpr_regnames[];
77
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
78
index XXXXXXX..XXXXXXX 100644
79
--- a/linux-user/elfload.c
80
+++ b/linux-user/elfload.c
81
@@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap(void)
82
uint32_t mask = MISA_BIT('I') | MISA_BIT('M') | MISA_BIT('A')
83
| MISA_BIT('F') | MISA_BIT('D') | MISA_BIT('C');
84
85
- return cpu->env.misa & mask;
86
+ return cpu->env.misa_ext & mask;
87
#undef MISA_BIT
88
}
89
90
diff --git a/linux-user/riscv/cpu_loop.c b/linux-user/riscv/cpu_loop.c
91
index XXXXXXX..XXXXXXX 100644
92
--- a/linux-user/riscv/cpu_loop.c
93
+++ b/linux-user/riscv/cpu_loop.c
94
@@ -XXX,XX +XXX,XX @@ void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs)
95
env->gpr[xSP] = regs->sp;
96
env->elf_flags = info->elf_flags;
97
98
- if ((env->misa & RVE) && !(env->elf_flags & EF_RISCV_RVE)) {
99
+ if ((env->misa_ext & RVE) && !(env->elf_flags & EF_RISCV_RVE)) {
100
error_report("Incompatible ELF: RVE cpu requires RVE ABI binary");
101
exit(EXIT_FAILURE);
102
}
34
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
103
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
35
index XXXXXXX..XXXXXXX 100644
104
index XXXXXXX..XXXXXXX 100644
36
--- a/target/riscv/cpu.c
105
--- a/target/riscv/cpu.c
37
+++ b/target/riscv/cpu.c
106
+++ b/target/riscv/cpu.c
38
@@ -XXX,XX +XXX,XX @@ static Property riscv_cpu_properties[] = {
107
@@ -XXX,XX +XXX,XX @@ const char *riscv_cpu_get_trap_name(target_ulong cause, bool async)
39
DEFINE_PROP_UINT16("elen", RISCVCPU, cfg.elen, 64),
108
40
DEFINE_PROP_BOOL("mmu", RISCVCPU, cfg.mmu, true),
109
bool riscv_cpu_is_32bit(CPURISCVState *env)
41
DEFINE_PROP_BOOL("pmp", RISCVCPU, cfg.pmp, true),
110
{
42
+ DEFINE_PROP_UINT64("resetvec", RISCVCPU, cfg.resetvec, DEFAULT_RSTVEC),
111
- if (env->misa & RV64) {
43
DEFINE_PROP_END_OF_LIST(),
112
- return false;
44
};
113
- }
45
114
-
115
- return true;
116
+ return env->misa_mxl == MXL_RV32;
117
}
118
119
-static void set_misa(CPURISCVState *env, target_ulong misa)
120
+static void set_misa(CPURISCVState *env, RISCVMXL mxl, uint32_t ext)
121
{
122
- env->misa_mask = env->misa = misa;
123
+ env->misa_mxl_max = env->misa_mxl = mxl;
124
+ env->misa_ext_mask = env->misa_ext = ext;
125
}
126
127
static void set_priv_version(CPURISCVState *env, int priv_ver)
128
@@ -XXX,XX +XXX,XX @@ static void riscv_any_cpu_init(Object *obj)
129
{
130
CPURISCVState *env = &RISCV_CPU(obj)->env;
131
#if defined(TARGET_RISCV32)
132
- set_misa(env, RV32 | RVI | RVM | RVA | RVF | RVD | RVC | RVU);
133
+ set_misa(env, MXL_RV32, RVI | RVM | RVA | RVF | RVD | RVC | RVU);
134
#elif defined(TARGET_RISCV64)
135
- set_misa(env, RV64 | RVI | RVM | RVA | RVF | RVD | RVC | RVU);
136
+ set_misa(env, MXL_RV64, RVI | RVM | RVA | RVF | RVD | RVC | RVU);
137
#endif
138
set_priv_version(env, PRIV_VERSION_1_11_0);
139
}
140
@@ -XXX,XX +XXX,XX @@ static void rv64_base_cpu_init(Object *obj)
141
{
142
CPURISCVState *env = &RISCV_CPU(obj)->env;
143
/* We set this in the realise function */
144
- set_misa(env, RV64);
145
+ set_misa(env, MXL_RV64, 0);
146
}
147
148
static void rv64_sifive_u_cpu_init(Object *obj)
149
{
150
CPURISCVState *env = &RISCV_CPU(obj)->env;
151
- set_misa(env, RV64 | RVI | RVM | RVA | RVF | RVD | RVC | RVS | RVU);
152
+ set_misa(env, MXL_RV64, RVI | RVM | RVA | RVF | RVD | RVC | RVS | RVU);
153
set_priv_version(env, PRIV_VERSION_1_10_0);
154
}
155
156
static void rv64_sifive_e_cpu_init(Object *obj)
157
{
158
CPURISCVState *env = &RISCV_CPU(obj)->env;
159
- set_misa(env, RV64 | RVI | RVM | RVA | RVC | RVU);
160
+ set_misa(env, MXL_RV64, RVI | RVM | RVA | RVC | RVU);
161
set_priv_version(env, PRIV_VERSION_1_10_0);
162
qdev_prop_set_bit(DEVICE(obj), "mmu", false);
163
}
164
@@ -XXX,XX +XXX,XX @@ static void rv32_base_cpu_init(Object *obj)
165
{
166
CPURISCVState *env = &RISCV_CPU(obj)->env;
167
/* We set this in the realise function */
168
- set_misa(env, RV32);
169
+ set_misa(env, MXL_RV32, 0);
170
}
171
172
static void rv32_sifive_u_cpu_init(Object *obj)
173
{
174
CPURISCVState *env = &RISCV_CPU(obj)->env;
175
- set_misa(env, RV32 | RVI | RVM | RVA | RVF | RVD | RVC | RVS | RVU);
176
+ set_misa(env, MXL_RV32, RVI | RVM | RVA | RVF | RVD | RVC | RVS | RVU);
177
set_priv_version(env, PRIV_VERSION_1_10_0);
178
}
179
180
static void rv32_sifive_e_cpu_init(Object *obj)
181
{
182
CPURISCVState *env = &RISCV_CPU(obj)->env;
183
- set_misa(env, RV32 | RVI | RVM | RVA | RVC | RVU);
184
+ set_misa(env, MXL_RV32, RVI | RVM | RVA | RVC | RVU);
185
set_priv_version(env, PRIV_VERSION_1_10_0);
186
qdev_prop_set_bit(DEVICE(obj), "mmu", false);
187
}
188
@@ -XXX,XX +XXX,XX @@ static void rv32_sifive_e_cpu_init(Object *obj)
189
static void rv32_ibex_cpu_init(Object *obj)
190
{
191
CPURISCVState *env = &RISCV_CPU(obj)->env;
192
- set_misa(env, RV32 | RVI | RVM | RVC | RVU);
193
+ set_misa(env, MXL_RV32, RVI | RVM | RVC | RVU);
194
set_priv_version(env, PRIV_VERSION_1_10_0);
195
qdev_prop_set_bit(DEVICE(obj), "mmu", false);
196
qdev_prop_set_bit(DEVICE(obj), "x-epmp", true);
197
@@ -XXX,XX +XXX,XX @@ static void rv32_ibex_cpu_init(Object *obj)
198
static void rv32_imafcu_nommu_cpu_init(Object *obj)
199
{
200
CPURISCVState *env = &RISCV_CPU(obj)->env;
201
- set_misa(env, RV32 | RVI | RVM | RVA | RVF | RVC | RVU);
202
+ set_misa(env, MXL_RV32, RVI | RVM | RVA | RVF | RVC | RVU);
203
set_priv_version(env, PRIV_VERSION_1_10_0);
204
set_resetvec(env, DEFAULT_RSTVEC);
205
qdev_prop_set_bit(DEVICE(obj), "mmu", false);
206
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_reset(DeviceState *dev)
207
208
mcc->parent_reset(dev);
209
#ifndef CONFIG_USER_ONLY
210
+ env->misa_mxl = env->misa_mxl_max;
211
env->priv = PRV_M;
212
env->mstatus &= ~(MSTATUS_MIE | MSTATUS_MPRV);
213
env->mcause = 0;
214
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
215
CPURISCVState *env = &cpu->env;
216
RISCVCPUClass *mcc = RISCV_CPU_GET_CLASS(dev);
217
int priv_version = 0;
218
- target_ulong target_misa = env->misa;
219
Error *local_err = NULL;
220
221
cpu_exec_realizefn(cs, &local_err);
222
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
223
224
set_resetvec(env, cpu->cfg.resetvec);
225
226
- /* If only XLEN is set for misa, then set misa from properties */
227
- if (env->misa == RV32 || env->misa == RV64) {
228
+ /* Validate that MISA_MXL is set properly. */
229
+ switch (env->misa_mxl_max) {
230
+#ifdef TARGET_RISCV64
231
+ case MXL_RV64:
232
+ break;
233
+#endif
234
+ case MXL_RV32:
235
+ break;
236
+ default:
237
+ g_assert_not_reached();
238
+ }
239
+ assert(env->misa_mxl_max == env->misa_mxl);
240
+
241
+ /* If only MISA_EXT is unset for misa, then set it from properties */
242
+ if (env->misa_ext == 0) {
243
+ uint32_t ext = 0;
244
+
245
/* Do some ISA extension error checking */
246
if (cpu->cfg.ext_i && cpu->cfg.ext_e) {
247
error_setg(errp,
248
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
249
250
/* Set the ISA extensions, checks should have happened above */
251
if (cpu->cfg.ext_i) {
252
- target_misa |= RVI;
253
+ ext |= RVI;
254
}
255
if (cpu->cfg.ext_e) {
256
- target_misa |= RVE;
257
+ ext |= RVE;
258
}
259
if (cpu->cfg.ext_m) {
260
- target_misa |= RVM;
261
+ ext |= RVM;
262
}
263
if (cpu->cfg.ext_a) {
264
- target_misa |= RVA;
265
+ ext |= RVA;
266
}
267
if (cpu->cfg.ext_f) {
268
- target_misa |= RVF;
269
+ ext |= RVF;
270
}
271
if (cpu->cfg.ext_d) {
272
- target_misa |= RVD;
273
+ ext |= RVD;
274
}
275
if (cpu->cfg.ext_c) {
276
- target_misa |= RVC;
277
+ ext |= RVC;
278
}
279
if (cpu->cfg.ext_s) {
280
- target_misa |= RVS;
281
+ ext |= RVS;
282
}
283
if (cpu->cfg.ext_u) {
284
- target_misa |= RVU;
285
+ ext |= RVU;
286
}
287
if (cpu->cfg.ext_h) {
288
- target_misa |= RVH;
289
+ ext |= RVH;
290
}
291
if (cpu->cfg.ext_v) {
292
int vext_version = VEXT_VERSION_0_07_1;
293
- target_misa |= RVV;
294
+ ext |= RVV;
295
if (!is_power_of_2(cpu->cfg.vlen)) {
296
error_setg(errp,
297
"Vector extension VLEN must be power of 2");
298
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
299
set_vext_version(env, vext_version);
300
}
301
302
- set_misa(env, target_misa);
303
+ set_misa(env, env->misa_mxl, ext);
304
}
305
306
riscv_cpu_register_gdb_regs_for_features(cs);
307
@@ -XXX,XX +XXX,XX @@ char *riscv_isa_string(RISCVCPU *cpu)
308
char *isa_str = g_new(char, maxlen);
309
char *p = isa_str + snprintf(isa_str, maxlen, "rv%d", TARGET_LONG_BITS);
310
for (i = 0; i < sizeof(riscv_exts); i++) {
311
- if (cpu->env.misa & RV(riscv_exts[i])) {
312
+ if (cpu->env.misa_ext & RV(riscv_exts[i])) {
313
*p++ = qemu_tolower(riscv_exts[i]);
314
}
315
}
316
diff --git a/target/riscv/csr.c b/target/riscv/csr.c
317
index XXXXXXX..XXXXXXX 100644
318
--- a/target/riscv/csr.c
319
+++ b/target/riscv/csr.c
320
@@ -XXX,XX +XXX,XX @@ static RISCVException fs(CPURISCVState *env, int csrno)
321
{
322
#if !defined(CONFIG_USER_ONLY)
323
/* loose check condition for fcsr in vector extension */
324
- if ((csrno == CSR_FCSR) && (env->misa & RVV)) {
325
+ if ((csrno == CSR_FCSR) && (env->misa_ext & RVV)) {
326
return RISCV_EXCP_NONE;
327
}
328
if (!env->debugger && !riscv_cpu_fp_enabled(env)) {
329
@@ -XXX,XX +XXX,XX @@ static RISCVException fs(CPURISCVState *env, int csrno)
330
331
static RISCVException vs(CPURISCVState *env, int csrno)
332
{
333
- if (env->misa & RVV) {
334
+ if (env->misa_ext & RVV) {
335
return RISCV_EXCP_NONE;
336
}
337
return RISCV_EXCP_ILLEGAL_INST;
338
@@ -XXX,XX +XXX,XX @@ static RISCVException write_mstatush(CPURISCVState *env, int csrno,
339
static RISCVException read_misa(CPURISCVState *env, int csrno,
340
target_ulong *val)
341
{
342
- *val = env->misa;
343
+ target_ulong misa;
344
+
345
+ switch (env->misa_mxl) {
346
+ case MXL_RV32:
347
+ misa = (target_ulong)MXL_RV32 << 30;
348
+ break;
349
+#ifdef TARGET_RISCV64
350
+ case MXL_RV64:
351
+ misa = (target_ulong)MXL_RV64 << 62;
352
+ break;
353
+#endif
354
+ default:
355
+ g_assert_not_reached();
356
+ }
357
+
358
+ *val = misa | env->misa_ext;
359
return RISCV_EXCP_NONE;
360
}
361
362
@@ -XXX,XX +XXX,XX @@ static RISCVException write_misa(CPURISCVState *env, int csrno,
363
return RISCV_EXCP_NONE;
364
}
365
366
+ /*
367
+ * misa.MXL writes are not supported by QEMU.
368
+ * Drop writes to those bits.
369
+ */
370
+
371
/* Mask extensions that are not supported by this hart */
372
- val &= env->misa_mask;
373
+ val &= env->misa_ext_mask;
374
375
/* Mask extensions that are not supported by QEMU */
376
val &= (RVI | RVE | RVM | RVA | RVF | RVD | RVC | RVS | RVU);
377
@@ -XXX,XX +XXX,XX @@ static RISCVException write_misa(CPURISCVState *env, int csrno,
378
val &= ~RVC;
379
}
380
381
- /* misa.MXL writes are not supported by QEMU */
382
- if (riscv_cpu_is_32bit(env)) {
383
- val = (env->misa & MISA32_MXL) | (val & ~MISA32_MXL);
384
- } else {
385
- val = (env->misa & MISA64_MXL) | (val & ~MISA64_MXL);
386
+ /* If nothing changed, do nothing. */
387
+ if (val == env->misa_ext) {
388
+ return RISCV_EXCP_NONE;
389
}
390
391
/* flush translation cache */
392
- if (val != env->misa) {
393
- tb_flush(env_cpu(env));
394
- }
395
-
396
- env->misa = val;
397
-
398
+ tb_flush(env_cpu(env));
399
+ env->misa_ext = val;
400
return RISCV_EXCP_NONE;
401
}
402
403
diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c
404
index XXXXXXX..XXXXXXX 100644
405
--- a/target/riscv/gdbstub.c
406
+++ b/target/riscv/gdbstub.c
407
@@ -XXX,XX +XXX,XX @@ int riscv_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
408
static int riscv_gdb_get_fpu(CPURISCVState *env, GByteArray *buf, int n)
409
{
410
if (n < 32) {
411
- if (env->misa & RVD) {
412
+ if (env->misa_ext & RVD) {
413
return gdb_get_reg64(buf, env->fpr[n]);
414
}
415
- if (env->misa & RVF) {
416
+ if (env->misa_ext & RVF) {
417
return gdb_get_reg32(buf, env->fpr[n]);
418
}
419
/* there is hole between ft11 and fflags in fpu.xml */
420
@@ -XXX,XX +XXX,XX @@ void riscv_cpu_register_gdb_regs_for_features(CPUState *cs)
421
{
422
RISCVCPU *cpu = RISCV_CPU(cs);
423
CPURISCVState *env = &cpu->env;
424
- if (env->misa & RVD) {
425
+ if (env->misa_ext & RVD) {
426
gdb_register_coprocessor(cs, riscv_gdb_get_fpu, riscv_gdb_set_fpu,
427
36, "riscv-64bit-fpu.xml", 0);
428
- } else if (env->misa & RVF) {
429
+ } else if (env->misa_ext & RVF) {
430
gdb_register_coprocessor(cs, riscv_gdb_get_fpu, riscv_gdb_set_fpu,
431
36, "riscv-32bit-fpu.xml", 0);
432
}
433
diff --git a/target/riscv/machine.c b/target/riscv/machine.c
434
index XXXXXXX..XXXXXXX 100644
435
--- a/target/riscv/machine.c
436
+++ b/target/riscv/machine.c
437
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_hyper = {
438
439
const VMStateDescription vmstate_riscv_cpu = {
440
.name = "cpu",
441
- .version_id = 2,
442
- .minimum_version_id = 2,
443
+ .version_id = 3,
444
+ .minimum_version_id = 3,
445
.fields = (VMStateField[]) {
446
VMSTATE_UINTTL_ARRAY(env.gpr, RISCVCPU, 32),
447
VMSTATE_UINT64_ARRAY(env.fpr, RISCVCPU, 32),
448
@@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_riscv_cpu = {
449
VMSTATE_UINTTL(env.guest_phys_fault_addr, RISCVCPU),
450
VMSTATE_UINTTL(env.priv_ver, RISCVCPU),
451
VMSTATE_UINTTL(env.vext_ver, RISCVCPU),
452
- VMSTATE_UINTTL(env.misa, RISCVCPU),
453
- VMSTATE_UINTTL(env.misa_mask, RISCVCPU),
454
+ VMSTATE_UINT32(env.misa_mxl, RISCVCPU),
455
+ VMSTATE_UINT32(env.misa_ext, RISCVCPU),
456
+ VMSTATE_UINT32(env.misa_mxl_max, RISCVCPU),
457
+ VMSTATE_UINT32(env.misa_ext_mask, RISCVCPU),
458
VMSTATE_UINT32(env.features, RISCVCPU),
459
VMSTATE_UINTTL(env.priv, RISCVCPU),
460
VMSTATE_UINTTL(env.virt, RISCVCPU),
461
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
462
index XXXXXXX..XXXXXXX 100644
463
--- a/target/riscv/translate.c
464
+++ b/target/riscv/translate.c
465
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
466
/* pc_succ_insn points to the instruction following base.pc_next */
467
target_ulong pc_succ_insn;
468
target_ulong priv_ver;
469
- target_ulong misa;
470
+ RISCVMXL xl;
471
+ uint32_t misa_ext;
472
uint32_t opcode;
473
uint32_t mstatus_fs;
474
uint32_t mstatus_hs_fs;
475
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
476
477
static inline bool has_ext(DisasContext *ctx, uint32_t ext)
478
{
479
- return ctx->misa & ext;
480
+ return ctx->misa_ext & ext;
481
}
482
483
#ifdef TARGET_RISCV32
484
@@ -XXX,XX +XXX,XX @@ static inline bool has_ext(DisasContext *ctx, uint32_t ext)
485
#else
486
static inline bool is_32bit(DisasContext *ctx)
487
{
488
- return (ctx->misa & RV32) == RV32;
489
+ return ctx->xl == MXL_RV32;
490
}
491
#endif
492
493
@@ -XXX,XX +XXX,XX @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
494
#else
495
ctx->virt_enabled = false;
496
#endif
497
- ctx->misa = env->misa;
498
+ ctx->xl = env->misa_mxl;
499
+ ctx->misa_ext = env->misa_ext;
500
ctx->frm = -1; /* unknown rounding mode */
501
ctx->ext_ifencei = cpu->cfg.ext_ifencei;
502
ctx->vlen = cpu->cfg.vlen;
46
--
503
--
47
2.28.0
504
2.31.1
48
505
49
506
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
At present the CLINT timestamp is using a hard-coded timebase
3
Shortly, the set of supported XL will not be just 32 and 64,
4
frequency value SIFIVE_CLINT_TIMEBASE_FREQ. This might not be
4
and representing that properly using the enumeration will be
5
true for all boards.
5
imperative.
6
6
7
Add a new 'timebase-freq' property to the CLINT device, and
7
Two places, booting and gdb, intentionally use misa_mxl_max
8
update various functions to accept this as a parameter.
8
to emphasize the use of the reset value of misa.mxl, and not
9
9
the current cpu state.
10
Signed-off-by: Bin Meng <bin.meng@windriver.com>
10
11
Reviewed-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
11
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
12
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
12
Message-Id: <1598924352-89526-16-git-send-email-bmeng.cn@gmail.com>
13
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20211020031709.359469-5-richard.henderson@linaro.org
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
15
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
14
---
16
---
15
include/hw/riscv/sifive_clint.h | 4 +++-
17
target/riscv/cpu.h | 9 ++++++++-
16
target/riscv/cpu.h | 6 ++++--
18
hw/riscv/boot.c | 2 +-
17
hw/riscv/microchip_pfsoc.c | 6 +++++-
19
semihosting/arm-compat-semi.c | 2 +-
18
hw/riscv/sifive_clint.c | 26 +++++++++++++++-----------
20
target/riscv/cpu.c | 24 ++++++++++++++----------
19
hw/riscv/sifive_e.c | 3 ++-
21
target/riscv/cpu_helper.c | 12 ++++++------
20
hw/riscv/sifive_u.c | 3 ++-
22
target/riscv/csr.c | 24 ++++++++++++------------
21
hw/riscv/spike.c | 3 ++-
23
target/riscv/gdbstub.c | 2 +-
22
hw/riscv/virt.c | 3 ++-
24
target/riscv/monitor.c | 4 ++--
23
target/riscv/cpu_helper.c | 4 +++-
25
8 files changed, 45 insertions(+), 34 deletions(-)
24
target/riscv/csr.c | 4 ++--
26
25
10 files changed, 40 insertions(+), 22 deletions(-)
26
27
diff --git a/include/hw/riscv/sifive_clint.h b/include/hw/riscv/sifive_clint.h
28
index XXXXXXX..XXXXXXX 100644
29
--- a/include/hw/riscv/sifive_clint.h
30
+++ b/include/hw/riscv/sifive_clint.h
31
@@ -XXX,XX +XXX,XX @@ typedef struct SiFiveCLINTState {
32
uint32_t timecmp_base;
33
uint32_t time_base;
34
uint32_t aperture_size;
35
+ uint32_t timebase_freq;
36
} SiFiveCLINTState;
37
38
DeviceState *sifive_clint_create(hwaddr addr, hwaddr size,
39
uint32_t hartid_base, uint32_t num_harts, uint32_t sip_base,
40
- uint32_t timecmp_base, uint32_t time_base, bool provide_rdtime);
41
+ uint32_t timecmp_base, uint32_t time_base, uint32_t timebase_freq,
42
+ bool provide_rdtime);
43
44
enum {
45
SIFIVE_SIP_BASE = 0x0,
46
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
27
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
47
index XXXXXXX..XXXXXXX 100644
28
index XXXXXXX..XXXXXXX 100644
48
--- a/target/riscv/cpu.h
29
--- a/target/riscv/cpu.h
49
+++ b/target/riscv/cpu.h
30
+++ b/target/riscv/cpu.h
50
@@ -XXX,XX +XXX,XX @@ struct CPURISCVState {
31
@@ -XXX,XX +XXX,XX @@ FIELD(TB_FLAGS, VILL, 9, 1)
51
pmp_table_t pmp_state;
32
FIELD(TB_FLAGS, HLSX, 10, 1)
52
33
FIELD(TB_FLAGS, MSTATUS_HS_FS, 11, 2)
53
/* machine specific rdtime callback */
34
54
- uint64_t (*rdtime_fn)(void);
35
-bool riscv_cpu_is_32bit(CPURISCVState *env);
55
+ uint64_t (*rdtime_fn)(uint32_t);
36
+#ifdef TARGET_RISCV32
56
+ uint32_t rdtime_fn_arg;
37
+#define riscv_cpu_mxl(env) ((void)(env), MXL_RV32)
57
38
+#else
58
/* True if in debugger mode. */
39
+static inline RISCVMXL riscv_cpu_mxl(CPURISCVState *env)
59
bool debugger;
40
+{
60
@@ -XXX,XX +XXX,XX @@ void riscv_cpu_swap_hypervisor_regs(CPURISCVState *env);
41
+ return env->misa_mxl;
61
int riscv_cpu_claim_interrupts(RISCVCPU *cpu, uint32_t interrupts);
42
+}
62
uint32_t riscv_cpu_update_mip(RISCVCPU *cpu, uint32_t mask, uint32_t value);
43
+#endif
63
#define BOOL_TO_MASK(x) (-!!(x)) /* helper for riscv_cpu_update_mip value */
44
64
-void riscv_cpu_set_rdtime_fn(CPURISCVState *env, uint64_t (*fn)(void));
45
/*
65
+void riscv_cpu_set_rdtime_fn(CPURISCVState *env, uint64_t (*fn)(uint32_t),
46
* A simplification for VLMAX
66
+ uint32_t arg);
47
diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/hw/riscv/boot.c
50
+++ b/hw/riscv/boot.c
51
@@ -XXX,XX +XXX,XX @@
52
53
bool riscv_is_32bit(RISCVHartArrayState *harts)
54
{
55
- return riscv_cpu_is_32bit(&harts->harts[0].env);
56
+ return harts->harts[0].env.misa_mxl_max == MXL_RV32;
57
}
58
59
target_ulong riscv_calc_kernel_start_addr(RISCVHartArrayState *harts,
60
diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c
61
index XXXXXXX..XXXXXXX 100644
62
--- a/semihosting/arm-compat-semi.c
63
+++ b/semihosting/arm-compat-semi.c
64
@@ -XXX,XX +XXX,XX @@ static inline bool is_64bit_semihosting(CPUArchState *env)
65
#if defined(TARGET_ARM)
66
return is_a64(env);
67
#elif defined(TARGET_RISCV)
68
- return !riscv_cpu_is_32bit(env);
69
+ return riscv_cpu_mxl(env) != MXL_RV32;
70
#else
71
#error un-handled architecture
67
#endif
72
#endif
68
void riscv_cpu_set_mode(CPURISCVState *env, target_ulong newpriv);
73
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
69
74
index XXXXXXX..XXXXXXX 100644
70
diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c
75
--- a/target/riscv/cpu.c
71
index XXXXXXX..XXXXXXX 100644
76
+++ b/target/riscv/cpu.c
72
--- a/hw/riscv/microchip_pfsoc.c
77
@@ -XXX,XX +XXX,XX @@ const char *riscv_cpu_get_trap_name(target_ulong cause, bool async)
73
+++ b/hw/riscv/microchip_pfsoc.c
78
}
74
@@ -XXX,XX +XXX,XX @@
79
}
75
#define BIOS_FILENAME "hss.bin"
80
76
#define RESET_VECTOR 0x20220000
81
-bool riscv_cpu_is_32bit(CPURISCVState *env)
77
82
-{
78
+/* CLINT timebase frequency */
83
- return env->misa_mxl == MXL_RV32;
79
+#define CLINT_TIMEBASE_FREQ 1000000
84
-}
85
-
86
static void set_misa(CPURISCVState *env, RISCVMXL mxl, uint32_t ext)
87
{
88
env->misa_mxl_max = env->misa_mxl = mxl;
89
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags)
90
#ifndef CONFIG_USER_ONLY
91
qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mhartid ", env->mhartid);
92
qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mstatus ", (target_ulong)env->mstatus);
93
- if (riscv_cpu_is_32bit(env)) {
94
+ if (riscv_cpu_mxl(env) == MXL_RV32) {
95
qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mstatush ",
96
(target_ulong)(env->mstatus >> 32));
97
}
98
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_reset(DeviceState *dev)
99
static void riscv_cpu_disas_set_info(CPUState *s, disassemble_info *info)
100
{
101
RISCVCPU *cpu = RISCV_CPU(s);
102
- if (riscv_cpu_is_32bit(&cpu->env)) {
80
+
103
+
81
/* GEM version */
104
+ switch (riscv_cpu_mxl(&cpu->env)) {
82
#define GEM_REVISION 0x0107010c
105
+ case MXL_RV32:
83
106
info->print_insn = print_insn_riscv32;
84
@@ -XXX,XX +XXX,XX @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp)
107
- } else {
85
/* CLINT */
108
+ break;
86
sifive_clint_create(memmap[MICROCHIP_PFSOC_CLINT].base,
109
+ case MXL_RV64:
87
memmap[MICROCHIP_PFSOC_CLINT].size, 0, ms->smp.cpus,
110
info->print_insn = print_insn_riscv64;
88
- SIFIVE_SIP_BASE, SIFIVE_TIMECMP_BASE, SIFIVE_TIME_BASE, false);
111
+ break;
89
+ SIFIVE_SIP_BASE, SIFIVE_TIMECMP_BASE, SIFIVE_TIME_BASE,
112
+ default:
90
+ CLINT_TIMEBASE_FREQ, false);
113
+ g_assert_not_reached();
91
114
}
92
/* L2 cache controller */
93
create_unimplemented_device("microchip.pfsoc.l2cc",
94
diff --git a/hw/riscv/sifive_clint.c b/hw/riscv/sifive_clint.c
95
index XXXXXXX..XXXXXXX 100644
96
--- a/hw/riscv/sifive_clint.c
97
+++ b/hw/riscv/sifive_clint.c
98
@@ -XXX,XX +XXX,XX @@
99
#include "hw/riscv/sifive_clint.h"
100
#include "qemu/timer.h"
101
102
-static uint64_t cpu_riscv_read_rtc(void)
103
+static uint64_t cpu_riscv_read_rtc(uint32_t timebase_freq)
104
{
105
return muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL),
106
- SIFIVE_CLINT_TIMEBASE_FREQ, NANOSECONDS_PER_SECOND);
107
+ timebase_freq, NANOSECONDS_PER_SECOND);
108
}
115
}
109
116
110
/*
117
@@ -XXX,XX +XXX,XX @@ static gchar *riscv_gdb_arch_name(CPUState *cs)
111
* Called when timecmp is written to update the QEMU timer or immediately
118
RISCVCPU *cpu = RISCV_CPU(cs);
112
* trigger timer interrupt if mtimecmp <= current timer value.
119
CPURISCVState *env = &cpu->env;
113
*/
120
114
-static void sifive_clint_write_timecmp(RISCVCPU *cpu, uint64_t value)
121
- if (riscv_cpu_is_32bit(env)) {
115
+static void sifive_clint_write_timecmp(RISCVCPU *cpu, uint64_t value,
122
+ switch (riscv_cpu_mxl(env)) {
116
+ uint32_t timebase_freq)
123
+ case MXL_RV32:
117
{
124
return g_strdup("riscv:rv32");
118
uint64_t next;
125
- } else {
119
uint64_t diff;
126
+ case MXL_RV64:
120
127
return g_strdup("riscv:rv64");
121
- uint64_t rtc_r = cpu_riscv_read_rtc();
128
+ default:
122
+ uint64_t rtc_r = cpu_riscv_read_rtc(timebase_freq);
129
+ g_assert_not_reached();
123
130
}
124
cpu->env.timecmp = value;
125
if (cpu->env.timecmp <= rtc_r) {
126
@@ -XXX,XX +XXX,XX @@ static void sifive_clint_write_timecmp(RISCVCPU *cpu, uint64_t value)
127
diff = cpu->env.timecmp - rtc_r;
128
/* back to ns (note args switched in muldiv64) */
129
next = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
130
- muldiv64(diff, NANOSECONDS_PER_SECOND, SIFIVE_CLINT_TIMEBASE_FREQ);
131
+ muldiv64(diff, NANOSECONDS_PER_SECOND, timebase_freq);
132
timer_mod(cpu->env.timer, next);
133
}
131
}
134
132
135
@@ -XXX,XX +XXX,XX @@ static uint64_t sifive_clint_read(void *opaque, hwaddr addr, unsigned size)
136
}
137
} else if (addr == clint->time_base) {
138
/* time_lo */
139
- return cpu_riscv_read_rtc() & 0xFFFFFFFF;
140
+ return cpu_riscv_read_rtc(clint->timebase_freq) & 0xFFFFFFFF;
141
} else if (addr == clint->time_base + 4) {
142
/* time_hi */
143
- return (cpu_riscv_read_rtc() >> 32) & 0xFFFFFFFF;
144
+ return (cpu_riscv_read_rtc(clint->timebase_freq) >> 32) & 0xFFFFFFFF;
145
}
146
147
error_report("clint: invalid read: %08x", (uint32_t)addr);
148
@@ -XXX,XX +XXX,XX @@ static void sifive_clint_write(void *opaque, hwaddr addr, uint64_t value,
149
/* timecmp_lo */
150
uint64_t timecmp_hi = env->timecmp >> 32;
151
sifive_clint_write_timecmp(RISCV_CPU(cpu),
152
- timecmp_hi << 32 | (value & 0xFFFFFFFF));
153
+ timecmp_hi << 32 | (value & 0xFFFFFFFF), clint->timebase_freq);
154
return;
155
} else if ((addr & 0x7) == 4) {
156
/* timecmp_hi */
157
uint64_t timecmp_lo = env->timecmp;
158
sifive_clint_write_timecmp(RISCV_CPU(cpu),
159
- value << 32 | (timecmp_lo & 0xFFFFFFFF));
160
+ value << 32 | (timecmp_lo & 0xFFFFFFFF), clint->timebase_freq);
161
} else {
162
error_report("clint: invalid timecmp write: %08x", (uint32_t)addr);
163
}
164
@@ -XXX,XX +XXX,XX @@ static Property sifive_clint_properties[] = {
165
DEFINE_PROP_UINT32("timecmp-base", SiFiveCLINTState, timecmp_base, 0),
166
DEFINE_PROP_UINT32("time-base", SiFiveCLINTState, time_base, 0),
167
DEFINE_PROP_UINT32("aperture-size", SiFiveCLINTState, aperture_size, 0),
168
+ DEFINE_PROP_UINT32("timebase-freq", SiFiveCLINTState, timebase_freq, 0),
169
DEFINE_PROP_END_OF_LIST(),
170
};
171
172
@@ -XXX,XX +XXX,XX @@ type_init(sifive_clint_register_types)
173
*/
174
DeviceState *sifive_clint_create(hwaddr addr, hwaddr size,
175
uint32_t hartid_base, uint32_t num_harts, uint32_t sip_base,
176
- uint32_t timecmp_base, uint32_t time_base, bool provide_rdtime)
177
+ uint32_t timecmp_base, uint32_t time_base, uint32_t timebase_freq,
178
+ bool provide_rdtime)
179
{
180
int i;
181
for (i = 0; i < num_harts; i++) {
182
@@ -XXX,XX +XXX,XX @@ DeviceState *sifive_clint_create(hwaddr addr, hwaddr size,
183
continue;
184
}
185
if (provide_rdtime) {
186
- riscv_cpu_set_rdtime_fn(env, cpu_riscv_read_rtc);
187
+ riscv_cpu_set_rdtime_fn(env, cpu_riscv_read_rtc, timebase_freq);
188
}
189
env->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
190
&sifive_clint_timer_cb, cpu);
191
@@ -XXX,XX +XXX,XX @@ DeviceState *sifive_clint_create(hwaddr addr, hwaddr size,
192
qdev_prop_set_uint32(dev, "timecmp-base", timecmp_base);
193
qdev_prop_set_uint32(dev, "time-base", time_base);
194
qdev_prop_set_uint32(dev, "aperture-size", size);
195
+ qdev_prop_set_uint32(dev, "timebase-freq", timebase_freq);
196
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
197
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, addr);
198
return dev;
199
diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c
200
index XXXXXXX..XXXXXXX 100644
201
--- a/hw/riscv/sifive_e.c
202
+++ b/hw/riscv/sifive_e.c
203
@@ -XXX,XX +XXX,XX @@ static void sifive_e_soc_realize(DeviceState *dev, Error **errp)
204
memmap[SIFIVE_E_PLIC].size);
205
sifive_clint_create(memmap[SIFIVE_E_CLINT].base,
206
memmap[SIFIVE_E_CLINT].size, 0, ms->smp.cpus,
207
- SIFIVE_SIP_BASE, SIFIVE_TIMECMP_BASE, SIFIVE_TIME_BASE, false);
208
+ SIFIVE_SIP_BASE, SIFIVE_TIMECMP_BASE, SIFIVE_TIME_BASE,
209
+ SIFIVE_CLINT_TIMEBASE_FREQ, false);
210
create_unimplemented_device("riscv.sifive.e.aon",
211
memmap[SIFIVE_E_AON].base, memmap[SIFIVE_E_AON].size);
212
sifive_e_prci_create(memmap[SIFIVE_E_PRCI].base);
213
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
214
index XXXXXXX..XXXXXXX 100644
215
--- a/hw/riscv/sifive_u.c
216
+++ b/hw/riscv/sifive_u.c
217
@@ -XXX,XX +XXX,XX @@ static void sifive_u_soc_realize(DeviceState *dev, Error **errp)
218
serial_hd(1), qdev_get_gpio_in(DEVICE(s->plic), SIFIVE_U_UART1_IRQ));
219
sifive_clint_create(memmap[SIFIVE_U_CLINT].base,
220
memmap[SIFIVE_U_CLINT].size, 0, ms->smp.cpus,
221
- SIFIVE_SIP_BASE, SIFIVE_TIMECMP_BASE, SIFIVE_TIME_BASE, false);
222
+ SIFIVE_SIP_BASE, SIFIVE_TIMECMP_BASE, SIFIVE_TIME_BASE,
223
+ SIFIVE_CLINT_TIMEBASE_FREQ, false);
224
225
if (!sysbus_realize(SYS_BUS_DEVICE(&s->prci), errp)) {
226
return;
227
diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c
228
index XXXXXXX..XXXXXXX 100644
229
--- a/hw/riscv/spike.c
230
+++ b/hw/riscv/spike.c
231
@@ -XXX,XX +XXX,XX @@ static void spike_board_init(MachineState *machine)
232
sifive_clint_create(
233
memmap[SPIKE_CLINT].base + i * memmap[SPIKE_CLINT].size,
234
memmap[SPIKE_CLINT].size, base_hartid, hart_count,
235
- SIFIVE_SIP_BASE, SIFIVE_TIMECMP_BASE, SIFIVE_TIME_BASE, false);
236
+ SIFIVE_SIP_BASE, SIFIVE_TIMECMP_BASE, SIFIVE_TIME_BASE,
237
+ SIFIVE_CLINT_TIMEBASE_FREQ, false);
238
}
239
240
/* register system main memory (actual RAM) */
241
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
242
index XXXXXXX..XXXXXXX 100644
243
--- a/hw/riscv/virt.c
244
+++ b/hw/riscv/virt.c
245
@@ -XXX,XX +XXX,XX @@ static void virt_machine_init(MachineState *machine)
246
sifive_clint_create(
247
memmap[VIRT_CLINT].base + i * memmap[VIRT_CLINT].size,
248
memmap[VIRT_CLINT].size, base_hartid, hart_count,
249
- SIFIVE_SIP_BASE, SIFIVE_TIMECMP_BASE, SIFIVE_TIME_BASE, true);
250
+ SIFIVE_SIP_BASE, SIFIVE_TIMECMP_BASE, SIFIVE_TIME_BASE,
251
+ SIFIVE_CLINT_TIMEBASE_FREQ, true);
252
253
/* Per-socket PLIC hart topology configuration string */
254
plic_hart_config_len =
255
diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
133
diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
256
index XXXXXXX..XXXXXXX 100644
134
index XXXXXXX..XXXXXXX 100644
257
--- a/target/riscv/cpu_helper.c
135
--- a/target/riscv/cpu_helper.c
258
+++ b/target/riscv/cpu_helper.c
136
+++ b/target/riscv/cpu_helper.c
259
@@ -XXX,XX +XXX,XX @@ uint32_t riscv_cpu_update_mip(RISCVCPU *cpu, uint32_t mask, uint32_t value)
137
@@ -XXX,XX +XXX,XX @@ bool riscv_cpu_fp_enabled(CPURISCVState *env)
260
return old;
138
261
}
139
void riscv_cpu_swap_hypervisor_regs(CPURISCVState *env)
262
140
{
263
-void riscv_cpu_set_rdtime_fn(CPURISCVState *env, uint64_t (*fn)(void))
141
- uint64_t sd = riscv_cpu_is_32bit(env) ? MSTATUS32_SD : MSTATUS64_SD;
264
+void riscv_cpu_set_rdtime_fn(CPURISCVState *env, uint64_t (*fn)(uint32_t),
142
+ uint64_t sd = riscv_cpu_mxl(env) == MXL_RV32 ? MSTATUS32_SD : MSTATUS64_SD;
265
+ uint32_t arg)
143
uint64_t mstatus_mask = MSTATUS_MXR | MSTATUS_SUM | MSTATUS_FS |
266
{
144
MSTATUS_SPP | MSTATUS_SPIE | MSTATUS_SIE |
267
env->rdtime_fn = fn;
145
MSTATUS64_UXL | sd;
268
+ env->rdtime_fn_arg = arg;
146
@@ -XXX,XX +XXX,XX @@ static int get_physical_address(CPURISCVState *env, hwaddr *physical,
269
}
147
270
148
if (first_stage == true) {
271
void riscv_cpu_set_mode(CPURISCVState *env, target_ulong newpriv)
149
if (use_background) {
150
- if (riscv_cpu_is_32bit(env)) {
151
+ if (riscv_cpu_mxl(env) == MXL_RV32) {
152
base = (hwaddr)get_field(env->vsatp, SATP32_PPN) << PGSHIFT;
153
vm = get_field(env->vsatp, SATP32_MODE);
154
} else {
155
@@ -XXX,XX +XXX,XX @@ static int get_physical_address(CPURISCVState *env, hwaddr *physical,
156
vm = get_field(env->vsatp, SATP64_MODE);
157
}
158
} else {
159
- if (riscv_cpu_is_32bit(env)) {
160
+ if (riscv_cpu_mxl(env) == MXL_RV32) {
161
base = (hwaddr)get_field(env->satp, SATP32_PPN) << PGSHIFT;
162
vm = get_field(env->satp, SATP32_MODE);
163
} else {
164
@@ -XXX,XX +XXX,XX @@ static int get_physical_address(CPURISCVState *env, hwaddr *physical,
165
}
166
widened = 0;
167
} else {
168
- if (riscv_cpu_is_32bit(env)) {
169
+ if (riscv_cpu_mxl(env) == MXL_RV32) {
170
base = (hwaddr)get_field(env->hgatp, SATP32_PPN) << PGSHIFT;
171
vm = get_field(env->hgatp, SATP32_MODE);
172
} else {
173
@@ -XXX,XX +XXX,XX @@ restart:
174
}
175
176
target_ulong pte;
177
- if (riscv_cpu_is_32bit(env)) {
178
+ if (riscv_cpu_mxl(env) == MXL_RV32) {
179
pte = address_space_ldl(cs->as, pte_addr, attrs, &res);
180
} else {
181
pte = address_space_ldq(cs->as, pte_addr, attrs, &res);
182
@@ -XXX,XX +XXX,XX @@ static void raise_mmu_exception(CPURISCVState *env, target_ulong address,
183
int page_fault_exceptions, vm;
184
uint64_t stap_mode;
185
186
- if (riscv_cpu_is_32bit(env)) {
187
+ if (riscv_cpu_mxl(env) == MXL_RV32) {
188
stap_mode = SATP32_MODE;
189
} else {
190
stap_mode = SATP64_MODE;
272
diff --git a/target/riscv/csr.c b/target/riscv/csr.c
191
diff --git a/target/riscv/csr.c b/target/riscv/csr.c
273
index XXXXXXX..XXXXXXX 100644
192
index XXXXXXX..XXXXXXX 100644
274
--- a/target/riscv/csr.c
193
--- a/target/riscv/csr.c
275
+++ b/target/riscv/csr.c
194
+++ b/target/riscv/csr.c
276
@@ -XXX,XX +XXX,XX @@ static int read_time(CPURISCVState *env, int csrno, target_ulong *val)
195
@@ -XXX,XX +XXX,XX @@ static RISCVException ctr(CPURISCVState *env, int csrno)
277
return -RISCV_EXCP_ILLEGAL_INST;
196
}
278
}
197
break;
279
198
}
280
- *val = env->rdtime_fn() + delta;
199
- if (riscv_cpu_is_32bit(env)) {
281
+ *val = env->rdtime_fn(env->rdtime_fn_arg) + delta;
200
+ if (riscv_cpu_mxl(env) == MXL_RV32) {
282
return 0;
201
switch (csrno) {
283
}
202
case CSR_CYCLEH:
284
203
if (!get_field(env->hcounteren, COUNTEREN_CY) &&
285
@@ -XXX,XX +XXX,XX @@ static int read_timeh(CPURISCVState *env, int csrno, target_ulong *val)
204
@@ -XXX,XX +XXX,XX @@ static RISCVException ctr(CPURISCVState *env, int csrno)
286
return -RISCV_EXCP_ILLEGAL_INST;
205
287
}
206
static RISCVException ctr32(CPURISCVState *env, int csrno)
288
207
{
289
- *val = (env->rdtime_fn() + delta) >> 32;
208
- if (!riscv_cpu_is_32bit(env)) {
290
+ *val = (env->rdtime_fn(env->rdtime_fn_arg) + delta) >> 32;
209
+ if (riscv_cpu_mxl(env) != MXL_RV32) {
291
return 0;
210
return RISCV_EXCP_ILLEGAL_INST;
292
}
211
}
293
#endif
212
213
@@ -XXX,XX +XXX,XX @@ static RISCVException any(CPURISCVState *env, int csrno)
214
215
static RISCVException any32(CPURISCVState *env, int csrno)
216
{
217
- if (!riscv_cpu_is_32bit(env)) {
218
+ if (riscv_cpu_mxl(env) != MXL_RV32) {
219
return RISCV_EXCP_ILLEGAL_INST;
220
}
221
222
@@ -XXX,XX +XXX,XX @@ static RISCVException hmode(CPURISCVState *env, int csrno)
223
224
static RISCVException hmode32(CPURISCVState *env, int csrno)
225
{
226
- if (!riscv_cpu_is_32bit(env)) {
227
+ if (riscv_cpu_mxl(env) != MXL_RV32) {
228
if (riscv_cpu_virt_enabled(env)) {
229
return RISCV_EXCP_ILLEGAL_INST;
230
} else {
231
@@ -XXX,XX +XXX,XX @@ static RISCVException read_mstatus(CPURISCVState *env, int csrno,
232
233
static int validate_vm(CPURISCVState *env, target_ulong vm)
234
{
235
- if (riscv_cpu_is_32bit(env)) {
236
+ if (riscv_cpu_mxl(env) == MXL_RV32) {
237
return valid_vm_1_10_32[vm & 0xf];
238
} else {
239
return valid_vm_1_10_64[vm & 0xf];
240
@@ -XXX,XX +XXX,XX @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno,
241
MSTATUS_MPP | MSTATUS_MXR | MSTATUS_TVM | MSTATUS_TSR |
242
MSTATUS_TW;
243
244
- if (!riscv_cpu_is_32bit(env)) {
245
+ if (riscv_cpu_mxl(env) != MXL_RV32) {
246
/*
247
* RV32: MPV and GVA are not in mstatus. The current plan is to
248
* add them to mstatush. For now, we just don't support it.
249
@@ -XXX,XX +XXX,XX @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno,
250
251
dirty = ((mstatus & MSTATUS_FS) == MSTATUS_FS) |
252
((mstatus & MSTATUS_XS) == MSTATUS_XS);
253
- if (riscv_cpu_is_32bit(env)) {
254
+ if (riscv_cpu_mxl(env) == MXL_RV32) {
255
mstatus = set_field(mstatus, MSTATUS32_SD, dirty);
256
} else {
257
mstatus = set_field(mstatus, MSTATUS64_SD, dirty);
258
@@ -XXX,XX +XXX,XX @@ static RISCVException read_sstatus(CPURISCVState *env, int csrno,
259
{
260
target_ulong mask = (sstatus_v1_10_mask);
261
262
- if (riscv_cpu_is_32bit(env)) {
263
+ if (riscv_cpu_mxl(env) == MXL_RV32) {
264
mask |= SSTATUS32_SD;
265
} else {
266
mask |= SSTATUS64_SD;
267
@@ -XXX,XX +XXX,XX @@ static RISCVException write_satp(CPURISCVState *env, int csrno,
268
return RISCV_EXCP_NONE;
269
}
270
271
- if (riscv_cpu_is_32bit(env)) {
272
+ if (riscv_cpu_mxl(env) == MXL_RV32) {
273
vm = validate_vm(env, get_field(val, SATP32_MODE));
274
mask = (val ^ env->satp) & (SATP32_MODE | SATP32_ASID | SATP32_PPN);
275
asid = (val ^ env->satp) & SATP32_ASID;
276
@@ -XXX,XX +XXX,XX @@ static RISCVException read_hstatus(CPURISCVState *env, int csrno,
277
target_ulong *val)
278
{
279
*val = env->hstatus;
280
- if (!riscv_cpu_is_32bit(env)) {
281
+ if (riscv_cpu_mxl(env) != MXL_RV32) {
282
/* We only support 64-bit VSXL */
283
*val = set_field(*val, HSTATUS_VSXL, 2);
284
}
285
@@ -XXX,XX +XXX,XX @@ static RISCVException write_hstatus(CPURISCVState *env, int csrno,
286
target_ulong val)
287
{
288
env->hstatus = val;
289
- if (!riscv_cpu_is_32bit(env) && get_field(val, HSTATUS_VSXL) != 2) {
290
+ if (riscv_cpu_mxl(env) != MXL_RV32 && get_field(val, HSTATUS_VSXL) != 2) {
291
qemu_log_mask(LOG_UNIMP, "QEMU does not support mixed HSXLEN options.");
292
}
293
if (get_field(val, HSTATUS_VSBE) != 0) {
294
@@ -XXX,XX +XXX,XX @@ static RISCVException write_htimedelta(CPURISCVState *env, int csrno,
295
return RISCV_EXCP_ILLEGAL_INST;
296
}
297
298
- if (riscv_cpu_is_32bit(env)) {
299
+ if (riscv_cpu_mxl(env) == MXL_RV32) {
300
env->htimedelta = deposit64(env->htimedelta, 0, 32, (uint64_t)val);
301
} else {
302
env->htimedelta = val;
303
diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c
304
index XXXXXXX..XXXXXXX 100644
305
--- a/target/riscv/gdbstub.c
306
+++ b/target/riscv/gdbstub.c
307
@@ -XXX,XX +XXX,XX @@ static int riscv_gen_dynamic_csr_xml(CPUState *cs, int base_reg)
308
CPURISCVState *env = &cpu->env;
309
GString *s = g_string_new(NULL);
310
riscv_csr_predicate_fn predicate;
311
- int bitsize = riscv_cpu_is_32bit(env) ? 32 : 64;
312
+ int bitsize = 16 << env->misa_mxl_max;
313
int i;
314
315
g_string_printf(s, "<?xml version=\"1.0\"?>");
316
diff --git a/target/riscv/monitor.c b/target/riscv/monitor.c
317
index XXXXXXX..XXXXXXX 100644
318
--- a/target/riscv/monitor.c
319
+++ b/target/riscv/monitor.c
320
@@ -XXX,XX +XXX,XX @@ static void mem_info_svxx(Monitor *mon, CPUArchState *env)
321
target_ulong last_size;
322
int last_attr;
323
324
- if (riscv_cpu_is_32bit(env)) {
325
+ if (riscv_cpu_mxl(env) == MXL_RV32) {
326
base = (hwaddr)get_field(env->satp, SATP32_PPN) << PGSHIFT;
327
vm = get_field(env->satp, SATP32_MODE);
328
} else {
329
@@ -XXX,XX +XXX,XX @@ void hmp_info_mem(Monitor *mon, const QDict *qdict)
330
return;
331
}
332
333
- if (riscv_cpu_is_32bit(env)) {
334
+ if (riscv_cpu_mxl(env) == MXL_RV32) {
335
if (!(env->satp & SATP32_MODE)) {
336
monitor_printf(mon, "No translation or protection\n");
337
return;
294
--
338
--
295
2.28.0
339
2.31.1
296
340
297
341
diff view generated by jsdifflib
1
From: Yifei Jiang <jiangyifei@huawei.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
When the cause number is equal to or greater than 23, print "(unknown)" in
3
Begin adding support for switching XLEN at runtime. Extract the
4
trace_riscv_trap. The max valid number of riscv_excp_names is 23, so the last
4
effective XLEN from MISA and MSTATUS and store for use during translation.
5
excpetion "guest_store_page_fault" can not be printed.
6
5
7
In addition, the current check of cause is invalid for riscv_intr_names. So
6
Reviewed-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
8
introduce riscv_cpu_get_trap_name to get the trap cause name.
9
10
Signed-off-by: Yifei Jiang <jiangyifei@huawei.com>
11
Signed-off-by: Yipeng Yin <yinyipeng1@huawei.com>
12
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
13
Message-Id: <20200814035819.1214-1-jiangyifei@huawei.com>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20211020031709.359469-6-richard.henderson@linaro.org
14
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
15
---
11
---
16
target/riscv/cpu.h | 1 +
12
target/riscv/cpu.h | 2 ++
17
target/riscv/cpu.c | 11 +++++++++++
13
target/riscv/cpu.c | 8 ++++++++
18
target/riscv/cpu_helper.c | 4 ++--
14
target/riscv/cpu_helper.c | 33 +++++++++++++++++++++++++++++++++
19
3 files changed, 14 insertions(+), 2 deletions(-)
15
target/riscv/csr.c | 3 +++
16
target/riscv/translate.c | 2 +-
17
5 files changed, 47 insertions(+), 1 deletion(-)
20
18
21
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
19
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
22
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
23
--- a/target/riscv/cpu.h
21
--- a/target/riscv/cpu.h
24
+++ b/target/riscv/cpu.h
22
+++ b/target/riscv/cpu.h
25
@@ -XXX,XX +XXX,XX @@ extern const char * const riscv_fpr_regnames[];
23
@@ -XXX,XX +XXX,XX @@ FIELD(TB_FLAGS, VILL, 9, 1)
26
extern const char * const riscv_excp_names[];
24
/* Is a Hypervisor instruction load/store allowed? */
27
extern const char * const riscv_intr_names[];
25
FIELD(TB_FLAGS, HLSX, 10, 1)
28
26
FIELD(TB_FLAGS, MSTATUS_HS_FS, 11, 2)
29
+const char *riscv_cpu_get_trap_name(target_ulong cause, bool async);
27
+/* The combination of MXL/SXL/UXL that applies to the current cpu mode. */
30
void riscv_cpu_do_interrupt(CPUState *cpu);
28
+FIELD(TB_FLAGS, XL, 13, 2)
31
int riscv_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
29
32
int riscv_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
30
#ifdef TARGET_RISCV32
31
#define riscv_cpu_mxl(env) ((void)(env), MXL_RV32)
33
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
32
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
34
index XXXXXXX..XXXXXXX 100644
33
index XXXXXXX..XXXXXXX 100644
35
--- a/target/riscv/cpu.c
34
--- a/target/riscv/cpu.c
36
+++ b/target/riscv/cpu.c
35
+++ b/target/riscv/cpu.c
37
@@ -XXX,XX +XXX,XX @@ const char * const riscv_intr_names[] = {
36
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_reset(DeviceState *dev)
38
"reserved"
37
env->misa_mxl = env->misa_mxl_max;
39
};
38
env->priv = PRV_M;
40
39
env->mstatus &= ~(MSTATUS_MIE | MSTATUS_MPRV);
41
+const char *riscv_cpu_get_trap_name(target_ulong cause, bool async)
40
+ if (env->misa_mxl > MXL_RV32) {
42
+{
41
+ /*
43
+ if (async) {
42
+ * The reset status of SXL/UXL is undefined, but mstatus is WARL
44
+ return (cause < ARRAY_SIZE(riscv_intr_names)) ?
43
+ * and we must ensure that the value after init is valid for read.
45
+ riscv_intr_names[cause] : "(unknown)";
44
+ */
46
+ } else {
45
+ env->mstatus = set_field(env->mstatus, MSTATUS64_SXL, env->misa_mxl);
47
+ return (cause < ARRAY_SIZE(riscv_excp_names)) ?
46
+ env->mstatus = set_field(env->mstatus, MSTATUS64_UXL, env->misa_mxl);
48
+ riscv_excp_names[cause] : "(unknown)";
49
+ }
47
+ }
50
+}
48
env->mcause = 0;
51
+
49
env->pc = env->resetvec;
52
static void set_misa(CPURISCVState *env, target_ulong misa)
50
env->two_stage_lookup = false;
53
{
54
env->misa_mask = env->misa = misa;
55
diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
51
diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
56
index XXXXXXX..XXXXXXX 100644
52
index XXXXXXX..XXXXXXX 100644
57
--- a/target/riscv/cpu_helper.c
53
--- a/target/riscv/cpu_helper.c
58
+++ b/target/riscv/cpu_helper.c
54
+++ b/target/riscv/cpu_helper.c
59
@@ -XXX,XX +XXX,XX @@ void riscv_cpu_do_interrupt(CPUState *cs)
55
@@ -XXX,XX +XXX,XX @@ int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch)
60
}
56
#endif
57
}
58
59
+static RISCVMXL cpu_get_xl(CPURISCVState *env)
60
+{
61
+#if defined(TARGET_RISCV32)
62
+ return MXL_RV32;
63
+#elif defined(CONFIG_USER_ONLY)
64
+ return MXL_RV64;
65
+#else
66
+ RISCVMXL xl = riscv_cpu_mxl(env);
67
+
68
+ /*
69
+ * When emulating a 32-bit-only cpu, use RV32.
70
+ * When emulating a 64-bit cpu, and MXL has been reduced to RV32,
71
+ * MSTATUSH doesn't have UXL/SXL, therefore XLEN cannot be widened
72
+ * back to RV64 for lower privs.
73
+ */
74
+ if (xl != MXL_RV32) {
75
+ switch (env->priv) {
76
+ case PRV_M:
77
+ break;
78
+ case PRV_U:
79
+ xl = get_field(env->mstatus, MSTATUS64_UXL);
80
+ break;
81
+ default: /* PRV_S | PRV_H */
82
+ xl = get_field(env->mstatus, MSTATUS64_SXL);
83
+ break;
84
+ }
85
+ }
86
+ return xl;
87
+#endif
88
+}
89
+
90
void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc,
91
target_ulong *cs_base, uint32_t *pflags)
92
{
93
@@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc,
61
}
94
}
62
95
#endif
63
- trace_riscv_trap(env->mhartid, async, cause, env->pc, tval, cause < 23 ?
96
64
- (async ? riscv_intr_names : riscv_excp_names)[cause] : "(unknown)");
97
+ flags = FIELD_DP32(flags, TB_FLAGS, XL, cpu_get_xl(env));
65
+ trace_riscv_trap(env->mhartid, async, cause, env->pc, tval,
98
+
66
+ riscv_cpu_get_trap_name(cause, async));
99
*pflags = flags;
67
100
}
68
if (env->priv <= PRV_S &&
101
69
cause < TARGET_LONG_BITS && ((deleg >> cause) & 1)) {
102
diff --git a/target/riscv/csr.c b/target/riscv/csr.c
103
index XXXXXXX..XXXXXXX 100644
104
--- a/target/riscv/csr.c
105
+++ b/target/riscv/csr.c
106
@@ -XXX,XX +XXX,XX @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno,
107
mstatus = set_field(mstatus, MSTATUS32_SD, dirty);
108
} else {
109
mstatus = set_field(mstatus, MSTATUS64_SD, dirty);
110
+ /* SXL and UXL fields are for now read only */
111
+ mstatus = set_field(mstatus, MSTATUS64_SXL, MXL_RV64);
112
+ mstatus = set_field(mstatus, MSTATUS64_UXL, MXL_RV64);
113
}
114
env->mstatus = mstatus;
115
116
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
117
index XXXXXXX..XXXXXXX 100644
118
--- a/target/riscv/translate.c
119
+++ b/target/riscv/translate.c
120
@@ -XXX,XX +XXX,XX @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
121
#else
122
ctx->virt_enabled = false;
123
#endif
124
- ctx->xl = env->misa_mxl;
125
ctx->misa_ext = env->misa_ext;
126
ctx->frm = -1; /* unknown rounding mode */
127
ctx->ext_ifencei = cpu->cfg.ext_ifencei;
128
@@ -XXX,XX +XXX,XX @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
129
ctx->lmul = FIELD_EX32(tb_flags, TB_FLAGS, LMUL);
130
ctx->mlen = 1 << (ctx->sew + 3 - ctx->lmul);
131
ctx->vl_eq_vlmax = FIELD_EX32(tb_flags, TB_FLAGS, VL_EQ_VLMAX);
132
+ ctx->xl = FIELD_EX32(tb_flags, TB_FLAGS, XL);
133
ctx->cs = cs;
134
ctx->w = false;
135
ctx->ntemp = 0;
70
--
136
--
71
2.28.0
137
2.31.1
72
138
73
139
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
SiFive FU540 SoC integrates a platform DMA controller with 4 DMA
3
Use the same REQUIRE_64BIT check that we use elsewhere,
4
channels. This connects the exsiting SiFive PDMA model to the SoC,
4
rather than open-coding the use of is_32bit.
5
and adds its device tree data as well.
6
5
7
Signed-off-by: Bin Meng <bin.meng@windriver.com>
6
Reviewed-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-Id: <1598924352-89526-17-git-send-email-bmeng.cn@gmail.com>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20211020031709.359469-7-richard.henderson@linaro.org
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
11
---
12
include/hw/riscv/sifive_u.h | 11 +++++++++++
12
target/riscv/insn_trans/trans_rvv.c.inc | 3 ++-
13
hw/riscv/sifive_u.c | 30 ++++++++++++++++++++++++++++++
13
1 file changed, 2 insertions(+), 1 deletion(-)
14
hw/riscv/Kconfig | 1 +
15
3 files changed, 42 insertions(+)
16
14
17
diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h
15
diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_trans/trans_rvv.c.inc
18
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/riscv/sifive_u.h
17
--- a/target/riscv/insn_trans/trans_rvv.c.inc
20
+++ b/include/hw/riscv/sifive_u.h
18
+++ b/target/riscv/insn_trans/trans_rvv.c.inc
21
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@ static bool amo_check(DisasContext *s, arg_rwdvm* a)
22
#ifndef HW_SIFIVE_U_H
20
23
#define HW_SIFIVE_U_H
21
static bool amo_check64(DisasContext *s, arg_rwdvm* a)
24
22
{
25
+#include "hw/dma/sifive_pdma.h"
23
- return !is_32bit(s) && amo_check(s, a);
26
#include "hw/net/cadence_gem.h"
24
+ REQUIRE_64BIT(s);
27
#include "hw/riscv/riscv_hart.h"
25
+ return amo_check(s, a);
28
#include "hw/riscv/sifive_cpu.h"
29
@@ -XXX,XX +XXX,XX @@ typedef struct SiFiveUSoCState {
30
SiFiveUPRCIState prci;
31
SIFIVEGPIOState gpio;
32
SiFiveUOTPState otp;
33
+ SiFivePDMAState dma;
34
CadenceGEMState gem;
35
36
uint32_t serial;
37
@@ -XXX,XX +XXX,XX @@ enum {
38
SIFIVE_U_MROM,
39
SIFIVE_U_CLINT,
40
SIFIVE_U_L2CC,
41
+ SIFIVE_U_PDMA,
42
SIFIVE_U_L2LIM,
43
SIFIVE_U_PLIC,
44
SIFIVE_U_PRCI,
45
@@ -XXX,XX +XXX,XX @@ enum {
46
SIFIVE_U_GPIO_IRQ13 = 20,
47
SIFIVE_U_GPIO_IRQ14 = 21,
48
SIFIVE_U_GPIO_IRQ15 = 22,
49
+ SIFIVE_U_PDMA_IRQ0 = 23,
50
+ SIFIVE_U_PDMA_IRQ1 = 24,
51
+ SIFIVE_U_PDMA_IRQ2 = 25,
52
+ SIFIVE_U_PDMA_IRQ3 = 26,
53
+ SIFIVE_U_PDMA_IRQ4 = 27,
54
+ SIFIVE_U_PDMA_IRQ5 = 28,
55
+ SIFIVE_U_PDMA_IRQ6 = 29,
56
+ SIFIVE_U_PDMA_IRQ7 = 30,
57
SIFIVE_U_GEM_IRQ = 0x35
58
};
59
60
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
61
index XXXXXXX..XXXXXXX 100644
62
--- a/hw/riscv/sifive_u.c
63
+++ b/hw/riscv/sifive_u.c
64
@@ -XXX,XX +XXX,XX @@
65
* 4) GPIO (General Purpose Input/Output Controller)
66
* 5) OTP (One-Time Programmable) memory with stored serial number
67
* 6) GEM (Gigabit Ethernet Controller) and management block
68
+ * 7) DMA (Direct Memory Access Controller)
69
*
70
* This board currently generates devicetree dynamically that indicates at least
71
* two harts and up to five harts.
72
@@ -XXX,XX +XXX,XX @@ static const struct MemmapEntry {
73
[SIFIVE_U_MROM] = { 0x1000, 0xf000 },
74
[SIFIVE_U_CLINT] = { 0x2000000, 0x10000 },
75
[SIFIVE_U_L2CC] = { 0x2010000, 0x1000 },
76
+ [SIFIVE_U_PDMA] = { 0x3000000, 0x100000 },
77
[SIFIVE_U_L2LIM] = { 0x8000000, 0x2000000 },
78
[SIFIVE_U_PLIC] = { 0xc000000, 0x4000000 },
79
[SIFIVE_U_PRCI] = { 0x10000000, 0x1000 },
80
@@ -XXX,XX +XXX,XX @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap,
81
qemu_fdt_setprop_string(fdt, nodename, "compatible", "gpio-restart");
82
g_free(nodename);
83
84
+ nodename = g_strdup_printf("/soc/dma@%lx",
85
+ (long)memmap[SIFIVE_U_PDMA].base);
86
+ qemu_fdt_add_subnode(fdt, nodename);
87
+ qemu_fdt_setprop_cell(fdt, nodename, "#dma-cells", 1);
88
+ qemu_fdt_setprop_cells(fdt, nodename, "interrupts",
89
+ SIFIVE_U_PDMA_IRQ0, SIFIVE_U_PDMA_IRQ1, SIFIVE_U_PDMA_IRQ2,
90
+ SIFIVE_U_PDMA_IRQ3, SIFIVE_U_PDMA_IRQ4, SIFIVE_U_PDMA_IRQ5,
91
+ SIFIVE_U_PDMA_IRQ6, SIFIVE_U_PDMA_IRQ7);
92
+ qemu_fdt_setprop_cell(fdt, nodename, "interrupt-parent", plic_phandle);
93
+ qemu_fdt_setprop_cells(fdt, nodename, "reg",
94
+ 0x0, memmap[SIFIVE_U_PDMA].base,
95
+ 0x0, memmap[SIFIVE_U_PDMA].size);
96
+ qemu_fdt_setprop_string(fdt, nodename, "compatible",
97
+ "sifive,fu540-c000-pdma");
98
+ g_free(nodename);
99
+
100
nodename = g_strdup_printf("/soc/cache-controller@%lx",
101
(long)memmap[SIFIVE_U_L2CC].base);
102
qemu_fdt_add_subnode(fdt, nodename);
103
@@ -XXX,XX +XXX,XX @@ static void sifive_u_soc_instance_init(Object *obj)
104
object_initialize_child(obj, "otp", &s->otp, TYPE_SIFIVE_U_OTP);
105
object_initialize_child(obj, "gem", &s->gem, TYPE_CADENCE_GEM);
106
object_initialize_child(obj, "gpio", &s->gpio, TYPE_SIFIVE_GPIO);
107
+ object_initialize_child(obj, "pdma", &s->dma, TYPE_SIFIVE_PDMA);
108
}
26
}
109
27
110
static void sifive_u_soc_realize(DeviceState *dev, Error **errp)
28
GEN_VEXT_TRANS(vamoswapw_v, 0, rwdvm, amo_op, amo_check)
111
@@ -XXX,XX +XXX,XX @@ static void sifive_u_soc_realize(DeviceState *dev, Error **errp)
112
SIFIVE_U_GPIO_IRQ0 + i));
113
}
114
115
+ /* PDMA */
116
+ sysbus_realize(SYS_BUS_DEVICE(&s->dma), errp);
117
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->dma), 0, memmap[SIFIVE_U_PDMA].base);
118
+
119
+ /* Connect PDMA interrupts to the PLIC */
120
+ for (i = 0; i < SIFIVE_PDMA_IRQS; i++) {
121
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->dma), i,
122
+ qdev_get_gpio_in(DEVICE(s->plic),
123
+ SIFIVE_U_PDMA_IRQ0 + i));
124
+ }
125
+
126
qdev_prop_set_uint32(DEVICE(&s->otp), "serial", s->serial);
127
if (!sysbus_realize(SYS_BUS_DEVICE(&s->otp), errp)) {
128
return;
129
diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
130
index XXXXXXX..XXXXXXX 100644
131
--- a/hw/riscv/Kconfig
132
+++ b/hw/riscv/Kconfig
133
@@ -XXX,XX +XXX,XX @@ config SIFIVE_U
134
select CADENCE
135
select HART
136
select SIFIVE
137
+ select SIFIVE_PDMA
138
select UNIMP
139
140
config SPIKE
141
--
29
--
142
2.28.0
30
2.31.1
143
31
144
32
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Microchip PolarFire SoC integrates 2 Candence GEMs to provide
3
We're currently assuming SEW <= 3, and the "else" from
4
IEEE 802.3 standard-compliant 10/100/1000 Mbps ethernet interface.
4
the SEW == 3 must be less. Use a switch and explicitly
5
bound both SEW and SEQ for all cases.
5
6
6
On the Icicle Kit board, GEM0 connects to a PHY at address 8 while
7
Reviewed-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
7
GEM1 connects to a PHY at address 9.
8
9
The 2nd stage bootloader (U-Boot) is using GEM1 by default, so we
10
must specify 2 '-nic' options from the command line in order to get
11
a working ethernet.
12
13
Signed-off-by: Bin Meng <bin.meng@windriver.com>
14
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
15
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
16
Message-Id: <1598924352-89526-14-git-send-email-bmeng.cn@gmail.com>
10
Message-id: 20211020031709.359469-8-richard.henderson@linaro.org
17
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
18
---
12
---
19
include/hw/riscv/microchip_pfsoc.h | 7 ++++++
13
target/riscv/insn_trans/trans_rvv.c.inc | 26 +++++++++++++------------
20
hw/riscv/microchip_pfsoc.c | 39 ++++++++++++++++++++++++++++++
14
1 file changed, 14 insertions(+), 12 deletions(-)
21
2 files changed, 46 insertions(+)
22
15
23
diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchip_pfsoc.h
16
diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_trans/trans_rvv.c.inc
24
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
25
--- a/include/hw/riscv/microchip_pfsoc.h
18
--- a/target/riscv/insn_trans/trans_rvv.c.inc
26
+++ b/include/hw/riscv/microchip_pfsoc.h
19
+++ b/target/riscv/insn_trans/trans_rvv.c.inc
27
@@ -XXX,XX +XXX,XX @@
20
@@ -XXX,XX +XXX,XX @@ static bool amo_op(DisasContext *s, arg_rwdvm *a, uint8_t seq)
28
21
gen_helper_exit_atomic(cpu_env);
29
#include "hw/char/mchp_pfsoc_mmuart.h"
22
s->base.is_jmp = DISAS_NORETURN;
30
#include "hw/dma/sifive_pdma.h"
23
return true;
31
+#include "hw/net/cadence_gem.h"
24
- } else {
32
#include "hw/sd/cadence_sdhci.h"
25
- if (s->sew == 3) {
33
26
- if (!is_32bit(s)) {
34
typedef struct MicrochipPFSoCState {
27
- fn = fnsd[seq];
35
@@ -XXX,XX +XXX,XX @@ typedef struct MicrochipPFSoCState {
28
- } else {
36
MchpPfSoCMMUartState *serial3;
29
- /* Check done in amo_check(). */
37
MchpPfSoCMMUartState *serial4;
30
- g_assert_not_reached();
38
SiFivePDMAState dma;
31
- }
39
+ CadenceGEMState gem0;
32
- } else {
40
+ CadenceGEMState gem1;
33
- assert(seq < ARRAY_SIZE(fnsw));
41
CadenceSDHCIState sdhci;
34
- fn = fnsw[seq];
42
} MicrochipPFSoCState;
35
- }
43
44
@@ -XXX,XX +XXX,XX @@ enum {
45
MICROCHIP_PFSOC_MMUART2,
46
MICROCHIP_PFSOC_MMUART3,
47
MICROCHIP_PFSOC_MMUART4,
48
+ MICROCHIP_PFSOC_GEM0,
49
+ MICROCHIP_PFSOC_GEM1,
50
MICROCHIP_PFSOC_ENVM_CFG,
51
MICROCHIP_PFSOC_ENVM_DATA,
52
MICROCHIP_PFSOC_IOSCB_CFG,
53
@@ -XXX,XX +XXX,XX @@ enum {
54
MICROCHIP_PFSOC_DMA_IRQ5 = 10,
55
MICROCHIP_PFSOC_DMA_IRQ6 = 11,
56
MICROCHIP_PFSOC_DMA_IRQ7 = 12,
57
+ MICROCHIP_PFSOC_GEM0_IRQ = 64,
58
+ MICROCHIP_PFSOC_GEM1_IRQ = 70,
59
MICROCHIP_PFSOC_EMMC_SD_IRQ = 88,
60
MICROCHIP_PFSOC_MMUART0_IRQ = 90,
61
MICROCHIP_PFSOC_MMUART1_IRQ = 91,
62
diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c
63
index XXXXXXX..XXXXXXX 100644
64
--- a/hw/riscv/microchip_pfsoc.c
65
+++ b/hw/riscv/microchip_pfsoc.c
66
@@ -XXX,XX +XXX,XX @@
67
* 3) MMUARTs (Multi-Mode UART)
68
* 4) Cadence eMMC/SDHC controller and an SD card connected to it
69
* 5) SiFive Platform DMA (Direct Memory Access Controller)
70
+ * 6) GEM (Gigabit Ethernet MAC Controller)
71
*
72
* This board currently generates devicetree dynamically that indicates at least
73
* two harts and up to five harts.
74
@@ -XXX,XX +XXX,XX @@
75
#define BIOS_FILENAME "hss.bin"
76
#define RESET_VECTOR 0x20220000
77
78
+/* GEM version */
79
+#define GEM_REVISION 0x0107010c
80
+
81
static const struct MemmapEntry {
82
hwaddr base;
83
hwaddr size;
84
@@ -XXX,XX +XXX,XX @@ static const struct MemmapEntry {
85
[MICROCHIP_PFSOC_MMUART2] = { 0x20102000, 0x1000 },
86
[MICROCHIP_PFSOC_MMUART3] = { 0x20104000, 0x1000 },
87
[MICROCHIP_PFSOC_MMUART4] = { 0x20106000, 0x1000 },
88
+ [MICROCHIP_PFSOC_GEM0] = { 0x20110000, 0x2000 },
89
+ [MICROCHIP_PFSOC_GEM1] = { 0x20112000, 0x2000 },
90
[MICROCHIP_PFSOC_ENVM_CFG] = { 0x20200000, 0x1000 },
91
[MICROCHIP_PFSOC_ENVM_DATA] = { 0x20220000, 0x20000 },
92
[MICROCHIP_PFSOC_IOSCB_CFG] = { 0x37080000, 0x1000 },
93
@@ -XXX,XX +XXX,XX @@ static void microchip_pfsoc_soc_instance_init(Object *obj)
94
object_initialize_child(obj, "dma-controller", &s->dma,
95
TYPE_SIFIVE_PDMA);
96
97
+ object_initialize_child(obj, "gem0", &s->gem0, TYPE_CADENCE_GEM);
98
+ object_initialize_child(obj, "gem1", &s->gem1, TYPE_CADENCE_GEM);
99
+
100
object_initialize_child(obj, "sd-controller", &s->sdhci,
101
TYPE_CADENCE_SDHCI);
102
}
103
@@ -XXX,XX +XXX,XX @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp)
104
MemoryRegion *envm_data = g_new(MemoryRegion, 1);
105
char *plic_hart_config;
106
size_t plic_hart_config_len;
107
+ NICInfo *nd;
108
int i;
109
110
sysbus_realize(SYS_BUS_DEVICE(&s->e_cpus), &error_abort);
111
@@ -XXX,XX +XXX,XX @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp)
112
qdev_get_gpio_in(DEVICE(s->plic), MICROCHIP_PFSOC_MMUART4_IRQ),
113
serial_hd(4));
114
115
+ /* GEMs */
116
+
117
+ nd = &nd_table[0];
118
+ if (nd->used) {
119
+ qemu_check_nic_model(nd, TYPE_CADENCE_GEM);
120
+ qdev_set_nic_properties(DEVICE(&s->gem0), nd);
121
+ }
122
+ nd = &nd_table[1];
123
+ if (nd->used) {
124
+ qemu_check_nic_model(nd, TYPE_CADENCE_GEM);
125
+ qdev_set_nic_properties(DEVICE(&s->gem1), nd);
126
+ }
36
+ }
127
+
37
+
128
+ object_property_set_int(OBJECT(&s->gem0), "revision", GEM_REVISION, errp);
38
+ switch (s->sew) {
129
+ object_property_set_int(OBJECT(&s->gem0), "phy-addr", 8, errp);
39
+ case 0 ... 2:
130
+ sysbus_realize(SYS_BUS_DEVICE(&s->gem0), errp);
40
+ assert(seq < ARRAY_SIZE(fnsw));
131
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->gem0), 0,
41
+ fn = fnsw[seq];
132
+ memmap[MICROCHIP_PFSOC_GEM0].base);
42
+ break;
133
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->gem0), 0,
43
+ case 3:
134
+ qdev_get_gpio_in(DEVICE(s->plic), MICROCHIP_PFSOC_GEM0_IRQ));
44
+ /* XLEN check done in amo_check(). */
135
+
45
+ assert(seq < ARRAY_SIZE(fnsd));
136
+ object_property_set_int(OBJECT(&s->gem1), "revision", GEM_REVISION, errp);
46
+ fn = fnsd[seq];
137
+ object_property_set_int(OBJECT(&s->gem1), "phy-addr", 9, errp);
47
+ break;
138
+ sysbus_realize(SYS_BUS_DEVICE(&s->gem1), errp);
48
+ default:
139
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->gem1), 0,
49
+ g_assert_not_reached();
140
+ memmap[MICROCHIP_PFSOC_GEM1].base);
50
}
141
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->gem1), 0,
51
142
+ qdev_get_gpio_in(DEVICE(s->plic), MICROCHIP_PFSOC_GEM1_IRQ));
52
data = FIELD_DP32(data, VDATA, MLEN, s->mlen);
143
+
144
/* eNVM */
145
memory_region_init_rom(envm_data, OBJECT(dev), "microchip.pfsoc.envm.data",
146
memmap[MICROCHIP_PFSOC_ENVM_DATA].size,
147
--
53
--
148
2.28.0
54
2.31.1
149
55
150
56
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
When cadence_gem model was created for Xilinx boards, the PHY address
3
In preparation for RV128, replace a simple predicate
4
was hard-coded to 23 in the GEM model. Now that we have introduced a
4
with a more versatile test.
5
property we can use that to tell GEM model what our PHY address is.
6
Change all boards' GEM 'phy-addr' property value to 23, and set the
7
PHY address default value to 0 in the GEM model.
8
5
9
Signed-off-by: Bin Meng <bin.meng@windriver.com>
6
Reviewed-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
12
Message-Id: <1598924352-89526-13-git-send-email-bmeng.cn@gmail.com>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20211020031709.359469-9-richard.henderson@linaro.org
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
14
---
11
---
15
hw/arm/xilinx_zynq.c | 1 +
12
target/riscv/translate.c | 31 +++++++++++++++++--------------
16
hw/arm/xlnx-versal.c | 1 +
13
1 file changed, 17 insertions(+), 14 deletions(-)
17
hw/arm/xlnx-zynqmp.c | 2 ++
18
hw/net/cadence_gem.c | 6 +++---
19
4 files changed, 7 insertions(+), 3 deletions(-)
20
14
21
diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
15
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
22
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
23
--- a/hw/arm/xilinx_zynq.c
17
--- a/target/riscv/translate.c
24
+++ b/hw/arm/xilinx_zynq.c
18
+++ b/target/riscv/translate.c
25
@@ -XXX,XX +XXX,XX @@ static void gem_init(NICInfo *nd, uint32_t base, qemu_irq irq)
19
@@ -XXX,XX +XXX,XX @@ static inline bool has_ext(DisasContext *ctx, uint32_t ext)
26
qemu_check_nic_model(nd, TYPE_CADENCE_GEM);
20
}
27
qdev_set_nic_properties(dev, nd);
21
28
}
22
#ifdef TARGET_RISCV32
29
+ object_property_set_int(OBJECT(dev), "phy-addr", 23, &error_abort);
23
-# define is_32bit(ctx) true
30
s = SYS_BUS_DEVICE(dev);
24
+#define get_xl(ctx) MXL_RV32
31
sysbus_realize_and_unref(s, &error_fatal);
25
#elif defined(CONFIG_USER_ONLY)
32
sysbus_mmio_map(s, 0, base);
26
-# define is_32bit(ctx) false
33
diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c
27
+#define get_xl(ctx) MXL_RV64
34
index XXXXXXX..XXXXXXX 100644
28
#else
35
--- a/hw/arm/xlnx-versal.c
29
-static inline bool is_32bit(DisasContext *ctx)
36
+++ b/hw/arm/xlnx-versal.c
30
+#define get_xl(ctx) ((ctx)->xl)
37
@@ -XXX,XX +XXX,XX @@ static void versal_create_gems(Versal *s, qemu_irq *pic)
31
+#endif
38
qemu_check_nic_model(nd, "cadence_gem");
32
+
39
qdev_set_nic_properties(dev, nd);
33
+/* The word size for this machine mode. */
40
}
34
+static inline int __attribute__((unused)) get_xlen(DisasContext *ctx)
41
+ object_property_set_int(OBJECT(dev), "phy-addr", 23, &error_abort);
35
{
42
object_property_set_int(OBJECT(dev), "num-priority-queues", 2,
36
- return ctx->xl == MXL_RV32;
43
&error_abort);
37
+ return 16 << get_xl(ctx);
44
object_property_set_link(OBJECT(dev), "dma", OBJECT(&s->mr_ps),
38
}
45
diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c
39
-#endif
46
index XXXXXXX..XXXXXXX 100644
40
47
--- a/hw/arm/xlnx-zynqmp.c
41
/* The word size for this operation. */
48
+++ b/hw/arm/xlnx-zynqmp.c
42
static inline int oper_len(DisasContext *ctx)
49
@@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
43
@@ -XXX,XX +XXX,XX @@ static void gen_jal(DisasContext *ctx, int rd, target_ulong imm)
50
}
44
static void mark_fs_dirty(DisasContext *ctx)
51
object_property_set_int(OBJECT(&s->gem[i]), "revision", GEM_REVISION,
45
{
52
&error_abort);
46
TCGv tmp;
53
+ object_property_set_int(OBJECT(&s->gem[i]), "phy-addr", 23,
47
- target_ulong sd = is_32bit(ctx) ? MSTATUS32_SD : MSTATUS64_SD;
54
+ &error_abort);
48
+ target_ulong sd = get_xl(ctx) == MXL_RV32 ? MSTATUS32_SD : MSTATUS64_SD;
55
object_property_set_int(OBJECT(&s->gem[i]), "num-priority-queues", 2,
49
56
&error_abort);
50
if (ctx->mstatus_fs != MSTATUS_FS) {
57
if (!sysbus_realize(SYS_BUS_DEVICE(&s->gem[i]), errp)) {
51
/* Remember the state change for the rest of the TB. */
58
diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
52
@@ -XXX,XX +XXX,XX @@ EX_SH(12)
59
index XXXXXXX..XXXXXXX 100644
53
} \
60
--- a/hw/net/cadence_gem.c
54
} while (0)
61
+++ b/hw/net/cadence_gem.c
55
62
@@ -XXX,XX +XXX,XX @@
56
-#define REQUIRE_32BIT(ctx) do { \
63
#define GEM_PHYMNTNC_REG_SHIFT 18
57
- if (!is_32bit(ctx)) { \
64
58
- return false; \
65
/* Marvell PHY definitions */
59
- } \
66
-#define BOARD_PHY_ADDRESS 23 /* PHY address we will emulate a device at */
60
+#define REQUIRE_32BIT(ctx) do { \
67
+#define BOARD_PHY_ADDRESS 0 /* PHY address we will emulate a device at */
61
+ if (get_xl(ctx) != MXL_RV32) { \
68
62
+ return false; \
69
#define PHY_REG_CONTROL 0
63
+ } \
70
#define PHY_REG_STATUS 1
64
} while (0)
71
@@ -XXX,XX +XXX,XX @@ static uint64_t gem_read(void *opaque, hwaddr offset, unsigned size)
65
72
uint32_t phy_addr, reg_num;
66
-#define REQUIRE_64BIT(ctx) do { \
73
67
- if (is_32bit(ctx)) { \
74
phy_addr = (retval & GEM_PHYMNTNC_ADDR) >> GEM_PHYMNTNC_ADDR_SHFT;
68
- return false; \
75
- if (phy_addr == s->phy_addr || phy_addr == 0) {
69
- } \
76
+ if (phy_addr == s->phy_addr) {
70
+#define REQUIRE_64BIT(ctx) do { \
77
reg_num = (retval & GEM_PHYMNTNC_REG) >> GEM_PHYMNTNC_REG_SHIFT;
71
+ if (get_xl(ctx) < MXL_RV64) { \
78
retval &= 0xFFFF0000;
72
+ return false; \
79
retval |= gem_phy_read(s, reg_num);
73
+ } \
80
@@ -XXX,XX +XXX,XX @@ static void gem_write(void *opaque, hwaddr offset, uint64_t val,
74
} while (0)
81
uint32_t phy_addr, reg_num;
75
82
76
static int ex_rvc_register(DisasContext *ctx, int reg)
83
phy_addr = (val & GEM_PHYMNTNC_ADDR) >> GEM_PHYMNTNC_ADDR_SHFT;
84
- if (phy_addr == s->phy_addr || phy_addr == 0) {
85
+ if (phy_addr == s->phy_addr) {
86
reg_num = (val & GEM_PHYMNTNC_REG) >> GEM_PHYMNTNC_REG_SHIFT;
87
gem_phy_write(s, reg_num, val);
88
}
89
--
77
--
90
2.28.0
78
2.31.1
91
79
92
80
diff view generated by jsdifflib
New patch
1
1
From: Richard Henderson <richard.henderson@linaro.org>
2
3
In preparation for RV128, consider more than just "w" for
4
operand size modification. This will be used for the "d"
5
insns from RV128 as well.
6
7
Rename oper_len to get_olen to better match get_xlen.
8
9
Reviewed-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
10
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
11
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20211020031709.359469-10-richard.henderson@linaro.org
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
14
---
15
target/riscv/translate.c | 69 ++++++++++++++++---------
16
target/riscv/insn_trans/trans_rvb.c.inc | 8 +--
17
target/riscv/insn_trans/trans_rvi.c.inc | 18 +++----
18
target/riscv/insn_trans/trans_rvm.c.inc | 10 ++--
19
4 files changed, 62 insertions(+), 43 deletions(-)
20
21
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
22
index XXXXXXX..XXXXXXX 100644
23
--- a/target/riscv/translate.c
24
+++ b/target/riscv/translate.c
25
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
26
to any system register, which includes CSR_FRM, so we do not have
27
to reset this known value. */
28
int frm;
29
- bool w;
30
+ RISCVMXL ol;
31
bool virt_enabled;
32
bool ext_ifencei;
33
bool hlsx;
34
@@ -XXX,XX +XXX,XX @@ static inline int __attribute__((unused)) get_xlen(DisasContext *ctx)
35
return 16 << get_xl(ctx);
36
}
37
38
-/* The word size for this operation. */
39
-static inline int oper_len(DisasContext *ctx)
40
+/* The operation length, as opposed to the xlen. */
41
+#ifdef TARGET_RISCV32
42
+#define get_ol(ctx) MXL_RV32
43
+#else
44
+#define get_ol(ctx) ((ctx)->ol)
45
+#endif
46
+
47
+static inline int get_olen(DisasContext *ctx)
48
{
49
- return ctx->w ? 32 : TARGET_LONG_BITS;
50
+ return 16 << get_ol(ctx);
51
}
52
53
-
54
/*
55
* RISC-V requires NaN-boxing of narrower width floating point values.
56
* This applies when a 32-bit value is assigned to a 64-bit FP register.
57
@@ -XXX,XX +XXX,XX @@ static TCGv get_gpr(DisasContext *ctx, int reg_num, DisasExtend ext)
58
return ctx->zero;
59
}
60
61
- switch (ctx->w ? ext : EXT_NONE) {
62
- case EXT_NONE:
63
- return cpu_gpr[reg_num];
64
- case EXT_SIGN:
65
- t = temp_new(ctx);
66
- tcg_gen_ext32s_tl(t, cpu_gpr[reg_num]);
67
- return t;
68
- case EXT_ZERO:
69
- t = temp_new(ctx);
70
- tcg_gen_ext32u_tl(t, cpu_gpr[reg_num]);
71
- return t;
72
+ switch (get_ol(ctx)) {
73
+ case MXL_RV32:
74
+ switch (ext) {
75
+ case EXT_NONE:
76
+ break;
77
+ case EXT_SIGN:
78
+ t = temp_new(ctx);
79
+ tcg_gen_ext32s_tl(t, cpu_gpr[reg_num]);
80
+ return t;
81
+ case EXT_ZERO:
82
+ t = temp_new(ctx);
83
+ tcg_gen_ext32u_tl(t, cpu_gpr[reg_num]);
84
+ return t;
85
+ default:
86
+ g_assert_not_reached();
87
+ }
88
+ break;
89
+ case MXL_RV64:
90
+ break;
91
+ default:
92
+ g_assert_not_reached();
93
}
94
- g_assert_not_reached();
95
+ return cpu_gpr[reg_num];
96
}
97
98
static TCGv dest_gpr(DisasContext *ctx, int reg_num)
99
{
100
- if (reg_num == 0 || ctx->w) {
101
+ if (reg_num == 0 || get_olen(ctx) < TARGET_LONG_BITS) {
102
return temp_new(ctx);
103
}
104
return cpu_gpr[reg_num];
105
@@ -XXX,XX +XXX,XX @@ static TCGv dest_gpr(DisasContext *ctx, int reg_num)
106
static void gen_set_gpr(DisasContext *ctx, int reg_num, TCGv t)
107
{
108
if (reg_num != 0) {
109
- if (ctx->w) {
110
+ switch (get_ol(ctx)) {
111
+ case MXL_RV32:
112
tcg_gen_ext32s_tl(cpu_gpr[reg_num], t);
113
- } else {
114
+ break;
115
+ case MXL_RV64:
116
tcg_gen_mov_tl(cpu_gpr[reg_num], t);
117
+ break;
118
+ default:
119
+ g_assert_not_reached();
120
}
121
}
122
}
123
@@ -XXX,XX +XXX,XX @@ static bool gen_shift_imm_fn(DisasContext *ctx, arg_shift *a, DisasExtend ext,
124
void (*func)(TCGv, TCGv, target_long))
125
{
126
TCGv dest, src1;
127
- int max_len = oper_len(ctx);
128
+ int max_len = get_olen(ctx);
129
130
if (a->shamt >= max_len) {
131
return false;
132
@@ -XXX,XX +XXX,XX @@ static bool gen_shift_imm_tl(DisasContext *ctx, arg_shift *a, DisasExtend ext,
133
void (*func)(TCGv, TCGv, TCGv))
134
{
135
TCGv dest, src1, src2;
136
- int max_len = oper_len(ctx);
137
+ int max_len = get_olen(ctx);
138
139
if (a->shamt >= max_len) {
140
return false;
141
@@ -XXX,XX +XXX,XX @@ static bool gen_shift(DisasContext *ctx, arg_r *a, DisasExtend ext,
142
TCGv src2 = get_gpr(ctx, a->rs2, EXT_NONE);
143
TCGv ext2 = tcg_temp_new();
144
145
- tcg_gen_andi_tl(ext2, src2, oper_len(ctx) - 1);
146
+ tcg_gen_andi_tl(ext2, src2, get_olen(ctx) - 1);
147
func(dest, src1, ext2);
148
149
gen_set_gpr(ctx, a->rd, dest);
150
@@ -XXX,XX +XXX,XX @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
151
ctx->vl_eq_vlmax = FIELD_EX32(tb_flags, TB_FLAGS, VL_EQ_VLMAX);
152
ctx->xl = FIELD_EX32(tb_flags, TB_FLAGS, XL);
153
ctx->cs = cs;
154
- ctx->w = false;
155
ctx->ntemp = 0;
156
memset(ctx->temp, 0, sizeof(ctx->temp));
157
158
@@ -XXX,XX +XXX,XX @@ static void riscv_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
159
CPURISCVState *env = cpu->env_ptr;
160
uint16_t opcode16 = translator_lduw(env, &ctx->base, ctx->base.pc_next);
161
162
+ ctx->ol = ctx->xl;
163
decode_opc(env, ctx, opcode16);
164
ctx->base.pc_next = ctx->pc_succ_insn;
165
- ctx->w = false;
166
167
for (int i = ctx->ntemp - 1; i >= 0; --i) {
168
tcg_temp_free(ctx->temp[i]);
169
diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_trans/trans_rvb.c.inc
170
index XXXXXXX..XXXXXXX 100644
171
--- a/target/riscv/insn_trans/trans_rvb.c.inc
172
+++ b/target/riscv/insn_trans/trans_rvb.c.inc
173
@@ -XXX,XX +XXX,XX @@ static bool trans_cpopw(DisasContext *ctx, arg_cpopw *a)
174
{
175
REQUIRE_64BIT(ctx);
176
REQUIRE_ZBB(ctx);
177
- ctx->w = true;
178
+ ctx->ol = MXL_RV32;
179
return gen_unary(ctx, a, EXT_ZERO, tcg_gen_ctpop_tl);
180
}
181
182
@@ -XXX,XX +XXX,XX @@ static bool trans_rorw(DisasContext *ctx, arg_rorw *a)
183
{
184
REQUIRE_64BIT(ctx);
185
REQUIRE_ZBB(ctx);
186
- ctx->w = true;
187
+ ctx->ol = MXL_RV32;
188
return gen_shift(ctx, a, EXT_NONE, gen_rorw);
189
}
190
191
@@ -XXX,XX +XXX,XX @@ static bool trans_roriw(DisasContext *ctx, arg_roriw *a)
192
{
193
REQUIRE_64BIT(ctx);
194
REQUIRE_ZBB(ctx);
195
- ctx->w = true;
196
+ ctx->ol = MXL_RV32;
197
return gen_shift_imm_tl(ctx, a, EXT_NONE, gen_rorw);
198
}
199
200
@@ -XXX,XX +XXX,XX @@ static bool trans_rolw(DisasContext *ctx, arg_rolw *a)
201
{
202
REQUIRE_64BIT(ctx);
203
REQUIRE_ZBB(ctx);
204
- ctx->w = true;
205
+ ctx->ol = MXL_RV32;
206
return gen_shift(ctx, a, EXT_NONE, gen_rolw);
207
}
208
209
diff --git a/target/riscv/insn_trans/trans_rvi.c.inc b/target/riscv/insn_trans/trans_rvi.c.inc
210
index XXXXXXX..XXXXXXX 100644
211
--- a/target/riscv/insn_trans/trans_rvi.c.inc
212
+++ b/target/riscv/insn_trans/trans_rvi.c.inc
213
@@ -XXX,XX +XXX,XX @@ static bool trans_and(DisasContext *ctx, arg_and *a)
214
static bool trans_addiw(DisasContext *ctx, arg_addiw *a)
215
{
216
REQUIRE_64BIT(ctx);
217
- ctx->w = true;
218
+ ctx->ol = MXL_RV32;
219
return gen_arith_imm_fn(ctx, a, EXT_NONE, tcg_gen_addi_tl);
220
}
221
222
static bool trans_slliw(DisasContext *ctx, arg_slliw *a)
223
{
224
REQUIRE_64BIT(ctx);
225
- ctx->w = true;
226
+ ctx->ol = MXL_RV32;
227
return gen_shift_imm_fn(ctx, a, EXT_NONE, tcg_gen_shli_tl);
228
}
229
230
@@ -XXX,XX +XXX,XX @@ static void gen_srliw(TCGv dst, TCGv src, target_long shamt)
231
static bool trans_srliw(DisasContext *ctx, arg_srliw *a)
232
{
233
REQUIRE_64BIT(ctx);
234
- ctx->w = true;
235
+ ctx->ol = MXL_RV32;
236
return gen_shift_imm_fn(ctx, a, EXT_NONE, gen_srliw);
237
}
238
239
@@ -XXX,XX +XXX,XX @@ static void gen_sraiw(TCGv dst, TCGv src, target_long shamt)
240
static bool trans_sraiw(DisasContext *ctx, arg_sraiw *a)
241
{
242
REQUIRE_64BIT(ctx);
243
- ctx->w = true;
244
+ ctx->ol = MXL_RV32;
245
return gen_shift_imm_fn(ctx, a, EXT_NONE, gen_sraiw);
246
}
247
248
static bool trans_addw(DisasContext *ctx, arg_addw *a)
249
{
250
REQUIRE_64BIT(ctx);
251
- ctx->w = true;
252
+ ctx->ol = MXL_RV32;
253
return gen_arith(ctx, a, EXT_NONE, tcg_gen_add_tl);
254
}
255
256
static bool trans_subw(DisasContext *ctx, arg_subw *a)
257
{
258
REQUIRE_64BIT(ctx);
259
- ctx->w = true;
260
+ ctx->ol = MXL_RV32;
261
return gen_arith(ctx, a, EXT_NONE, tcg_gen_sub_tl);
262
}
263
264
static bool trans_sllw(DisasContext *ctx, arg_sllw *a)
265
{
266
REQUIRE_64BIT(ctx);
267
- ctx->w = true;
268
+ ctx->ol = MXL_RV32;
269
return gen_shift(ctx, a, EXT_NONE, tcg_gen_shl_tl);
270
}
271
272
static bool trans_srlw(DisasContext *ctx, arg_srlw *a)
273
{
274
REQUIRE_64BIT(ctx);
275
- ctx->w = true;
276
+ ctx->ol = MXL_RV32;
277
return gen_shift(ctx, a, EXT_ZERO, tcg_gen_shr_tl);
278
}
279
280
static bool trans_sraw(DisasContext *ctx, arg_sraw *a)
281
{
282
REQUIRE_64BIT(ctx);
283
- ctx->w = true;
284
+ ctx->ol = MXL_RV32;
285
return gen_shift(ctx, a, EXT_SIGN, tcg_gen_sar_tl);
286
}
287
288
diff --git a/target/riscv/insn_trans/trans_rvm.c.inc b/target/riscv/insn_trans/trans_rvm.c.inc
289
index XXXXXXX..XXXXXXX 100644
290
--- a/target/riscv/insn_trans/trans_rvm.c.inc
291
+++ b/target/riscv/insn_trans/trans_rvm.c.inc
292
@@ -XXX,XX +XXX,XX @@ static bool trans_mulw(DisasContext *ctx, arg_mulw *a)
293
{
294
REQUIRE_64BIT(ctx);
295
REQUIRE_EXT(ctx, RVM);
296
- ctx->w = true;
297
+ ctx->ol = MXL_RV32;
298
return gen_arith(ctx, a, EXT_NONE, tcg_gen_mul_tl);
299
}
300
301
@@ -XXX,XX +XXX,XX @@ static bool trans_divw(DisasContext *ctx, arg_divw *a)
302
{
303
REQUIRE_64BIT(ctx);
304
REQUIRE_EXT(ctx, RVM);
305
- ctx->w = true;
306
+ ctx->ol = MXL_RV32;
307
return gen_arith(ctx, a, EXT_SIGN, gen_div);
308
}
309
310
@@ -XXX,XX +XXX,XX @@ static bool trans_divuw(DisasContext *ctx, arg_divuw *a)
311
{
312
REQUIRE_64BIT(ctx);
313
REQUIRE_EXT(ctx, RVM);
314
- ctx->w = true;
315
+ ctx->ol = MXL_RV32;
316
return gen_arith(ctx, a, EXT_ZERO, gen_divu);
317
}
318
319
@@ -XXX,XX +XXX,XX @@ static bool trans_remw(DisasContext *ctx, arg_remw *a)
320
{
321
REQUIRE_64BIT(ctx);
322
REQUIRE_EXT(ctx, RVM);
323
- ctx->w = true;
324
+ ctx->ol = MXL_RV32;
325
return gen_arith(ctx, a, EXT_SIGN, gen_rem);
326
}
327
328
@@ -XXX,XX +XXX,XX @@ static bool trans_remuw(DisasContext *ctx, arg_remuw *a)
329
{
330
REQUIRE_64BIT(ctx);
331
REQUIRE_EXT(ctx, RVM);
332
- ctx->w = true;
333
+ ctx->ol = MXL_RV32;
334
return gen_arith(ctx, a, EXT_ZERO, gen_remu);
335
}
336
--
337
2.31.1
338
339
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
This is an initial support for Microchip PolarFire SoC Icicle Kit.
3
The multiply high-part instructions require a separate
4
The Icicle Kit board integrates a PolarFire SoC, with one SiFive's
4
implementation for RV32 when TARGET_LONG_BITS == 64.
5
E51 plus four U54 cores and many on-chip peripherals and an FPGA.
6
5
7
For more details about Microchip PolarFire Soc, please see:
6
Reviewed-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
8
https://www.microsemi.com/product-directory/soc-fpgas/5498-polarfire-soc-fpga
9
10
Unlike SiFive FU540, the RISC-V core resect vector is at 0x20220000.
11
The following perepherals are created as an unimplemented device:
12
13
- Bus Error Uint 0/1/2/3/4
14
- L2 cache controller
15
- SYSREG
16
- MPUCFG
17
- IOSCBCFG
18
19
More devices will be added later.
20
21
The BIOS image used by this machine is hss.bin, aka Hart Software
22
Services, which can be built from:
23
https://github.com/polarfire-soc/hart-software-services
24
25
To launch this machine:
26
$ qemu-system-riscv64 -nographic -M microchip-icicle-kit
27
28
The memory is set to 1 GiB by default to match the hardware.
29
A sanity check on ram size is performed in the machine init routine
30
to prompt user to increase the RAM size to > 1 GiB when less than
31
1 GiB ram is detected.
32
33
Signed-off-by: Bin Meng <bin.meng@windriver.com>
34
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
35
Message-Id: <1598924352-89526-5-git-send-email-bmeng.cn@gmail.com>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20211020031709.359469-11-richard.henderson@linaro.org
36
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
37
---
11
---
38
default-configs/riscv64-softmmu.mak | 1 +
12
target/riscv/translate.c | 16 +++++++++++++++
39
include/hw/riscv/microchip_pfsoc.h | 88 ++++++++
13
target/riscv/insn_trans/trans_rvm.c.inc | 26 ++++++++++++++++++++++---
40
hw/riscv/microchip_pfsoc.c | 312 ++++++++++++++++++++++++++++
14
2 files changed, 39 insertions(+), 3 deletions(-)
41
MAINTAINERS | 7 +
42
hw/riscv/Kconfig | 6 +
43
hw/riscv/meson.build | 1 +
44
6 files changed, 415 insertions(+)
45
create mode 100644 include/hw/riscv/microchip_pfsoc.h
46
create mode 100644 hw/riscv/microchip_pfsoc.c
47
15
48
diff --git a/default-configs/riscv64-softmmu.mak b/default-configs/riscv64-softmmu.mak
16
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
49
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
50
--- a/default-configs/riscv64-softmmu.mak
18
--- a/target/riscv/translate.c
51
+++ b/default-configs/riscv64-softmmu.mak
19
+++ b/target/riscv/translate.c
52
@@ -XXX,XX +XXX,XX @@ CONFIG_SPIKE=y
20
@@ -XXX,XX +XXX,XX @@ static bool gen_arith(DisasContext *ctx, arg_r *a, DisasExtend ext,
53
CONFIG_SIFIVE_E=y
21
return true;
54
CONFIG_SIFIVE_U=y
22
}
55
CONFIG_RISCV_VIRT=y
23
56
+CONFIG_MICROCHIP_PFSOC=y
24
+static bool gen_arith_per_ol(DisasContext *ctx, arg_r *a, DisasExtend ext,
57
diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchip_pfsoc.h
25
+ void (*f_tl)(TCGv, TCGv, TCGv),
58
new file mode 100644
26
+ void (*f_32)(TCGv, TCGv, TCGv))
59
index XXXXXXX..XXXXXXX
27
+{
60
--- /dev/null
28
+ int olen = get_olen(ctx);
61
+++ b/include/hw/riscv/microchip_pfsoc.h
62
@@ -XXX,XX +XXX,XX @@
63
+/*
64
+ * Microchip PolarFire SoC machine interface
65
+ *
66
+ * Copyright (c) 2020 Wind River Systems, Inc.
67
+ *
68
+ * Author:
69
+ * Bin Meng <bin.meng@windriver.com>
70
+ *
71
+ * This program is free software; you can redistribute it and/or modify it
72
+ * under the terms and conditions of the GNU General Public License,
73
+ * version 2 or later, as published by the Free Software Foundation.
74
+ *
75
+ * This program is distributed in the hope it will be useful, but WITHOUT
76
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
77
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
78
+ * more details.
79
+ *
80
+ * You should have received a copy of the GNU General Public License along with
81
+ * this program. If not, see <http://www.gnu.org/licenses/>.
82
+ */
83
+
29
+
84
+#ifndef HW_MICROCHIP_PFSOC_H
30
+ if (olen != TARGET_LONG_BITS) {
85
+#define HW_MICROCHIP_PFSOC_H
31
+ if (olen == 32) {
86
+
32
+ f_tl = f_32;
87
+typedef struct MicrochipPFSoCState {
33
+ } else {
88
+ /*< private >*/
34
+ g_assert_not_reached();
89
+ DeviceState parent_obj;
35
+ }
90
+
36
+ }
91
+ /*< public >*/
37
+ return gen_arith(ctx, a, ext, f_tl);
92
+ CPUClusterState e_cluster;
93
+ CPUClusterState u_cluster;
94
+ RISCVHartArrayState e_cpus;
95
+ RISCVHartArrayState u_cpus;
96
+ DeviceState *plic;
97
+} MicrochipPFSoCState;
98
+
99
+#define TYPE_MICROCHIP_PFSOC "microchip.pfsoc"
100
+#define MICROCHIP_PFSOC(obj) \
101
+ OBJECT_CHECK(MicrochipPFSoCState, (obj), TYPE_MICROCHIP_PFSOC)
102
+
103
+typedef struct MicrochipIcicleKitState {
104
+ /*< private >*/
105
+ MachineState parent_obj;
106
+
107
+ /*< public >*/
108
+ MicrochipPFSoCState soc;
109
+} MicrochipIcicleKitState;
110
+
111
+#define TYPE_MICROCHIP_ICICLE_KIT_MACHINE \
112
+ MACHINE_TYPE_NAME("microchip-icicle-kit")
113
+#define MICROCHIP_ICICLE_KIT_MACHINE(obj) \
114
+ OBJECT_CHECK(MicrochipIcicleKitState, (obj), \
115
+ TYPE_MICROCHIP_ICICLE_KIT_MACHINE)
116
+
117
+enum {
118
+ MICROCHIP_PFSOC_DEBUG,
119
+ MICROCHIP_PFSOC_E51_DTIM,
120
+ MICROCHIP_PFSOC_BUSERR_UNIT0,
121
+ MICROCHIP_PFSOC_BUSERR_UNIT1,
122
+ MICROCHIP_PFSOC_BUSERR_UNIT2,
123
+ MICROCHIP_PFSOC_BUSERR_UNIT3,
124
+ MICROCHIP_PFSOC_BUSERR_UNIT4,
125
+ MICROCHIP_PFSOC_CLINT,
126
+ MICROCHIP_PFSOC_L2CC,
127
+ MICROCHIP_PFSOC_L2LIM,
128
+ MICROCHIP_PFSOC_PLIC,
129
+ MICROCHIP_PFSOC_SYSREG,
130
+ MICROCHIP_PFSOC_MPUCFG,
131
+ MICROCHIP_PFSOC_ENVM_CFG,
132
+ MICROCHIP_PFSOC_ENVM_DATA,
133
+ MICROCHIP_PFSOC_IOSCB_CFG,
134
+ MICROCHIP_PFSOC_DRAM,
135
+};
136
+
137
+#define MICROCHIP_PFSOC_MANAGEMENT_CPU_COUNT 1
138
+#define MICROCHIP_PFSOC_COMPUTE_CPU_COUNT 4
139
+
140
+#define MICROCHIP_PFSOC_PLIC_HART_CONFIG "MS"
141
+#define MICROCHIP_PFSOC_PLIC_NUM_SOURCES 185
142
+#define MICROCHIP_PFSOC_PLIC_NUM_PRIORITIES 7
143
+#define MICROCHIP_PFSOC_PLIC_PRIORITY_BASE 0x04
144
+#define MICROCHIP_PFSOC_PLIC_PENDING_BASE 0x1000
145
+#define MICROCHIP_PFSOC_PLIC_ENABLE_BASE 0x2000
146
+#define MICROCHIP_PFSOC_PLIC_ENABLE_STRIDE 0x80
147
+#define MICROCHIP_PFSOC_PLIC_CONTEXT_BASE 0x200000
148
+#define MICROCHIP_PFSOC_PLIC_CONTEXT_STRIDE 0x1000
149
+
150
+#endif /* HW_MICROCHIP_PFSOC_H */
151
diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c
152
new file mode 100644
153
index XXXXXXX..XXXXXXX
154
--- /dev/null
155
+++ b/hw/riscv/microchip_pfsoc.c
156
@@ -XXX,XX +XXX,XX @@
157
+/*
158
+ * QEMU RISC-V Board Compatible with Microchip PolarFire SoC Icicle Kit
159
+ *
160
+ * Copyright (c) 2020 Wind River Systems, Inc.
161
+ *
162
+ * Author:
163
+ * Bin Meng <bin.meng@windriver.com>
164
+ *
165
+ * Provides a board compatible with the Microchip PolarFire SoC Icicle Kit
166
+ *
167
+ * 0) CLINT (Core Level Interruptor)
168
+ * 1) PLIC (Platform Level Interrupt Controller)
169
+ * 2) eNVM (Embedded Non-Volatile Memory)
170
+ *
171
+ * This board currently generates devicetree dynamically that indicates at least
172
+ * two harts and up to five harts.
173
+ *
174
+ * This program is free software; you can redistribute it and/or modify it
175
+ * under the terms and conditions of the GNU General Public License,
176
+ * version 2 or later, as published by the Free Software Foundation.
177
+ *
178
+ * This program is distributed in the hope it will be useful, but WITHOUT
179
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
180
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
181
+ * more details.
182
+ *
183
+ * You should have received a copy of the GNU General Public License along with
184
+ * this program. If not, see <http://www.gnu.org/licenses/>.
185
+ */
186
+
187
+#include "qemu/osdep.h"
188
+#include "qemu/error-report.h"
189
+#include "qemu/log.h"
190
+#include "qemu/units.h"
191
+#include "qemu/cutils.h"
192
+#include "qapi/error.h"
193
+#include "hw/boards.h"
194
+#include "hw/irq.h"
195
+#include "hw/loader.h"
196
+#include "hw/sysbus.h"
197
+#include "hw/cpu/cluster.h"
198
+#include "target/riscv/cpu.h"
199
+#include "hw/misc/unimp.h"
200
+#include "hw/riscv/boot.h"
201
+#include "hw/riscv/riscv_hart.h"
202
+#include "hw/riscv/sifive_clint.h"
203
+#include "hw/riscv/sifive_plic.h"
204
+#include "hw/riscv/microchip_pfsoc.h"
205
+
206
+/*
207
+ * The BIOS image used by this machine is called Hart Software Services (HSS).
208
+ * See https://github.com/polarfire-soc/hart-software-services
209
+ */
210
+#define BIOS_FILENAME "hss.bin"
211
+#define RESET_VECTOR 0x20220000
212
+
213
+static const struct MemmapEntry {
214
+ hwaddr base;
215
+ hwaddr size;
216
+} microchip_pfsoc_memmap[] = {
217
+ [MICROCHIP_PFSOC_DEBUG] = { 0x0, 0x1000 },
218
+ [MICROCHIP_PFSOC_E51_DTIM] = { 0x1000000, 0x2000 },
219
+ [MICROCHIP_PFSOC_BUSERR_UNIT0] = { 0x1700000, 0x1000 },
220
+ [MICROCHIP_PFSOC_BUSERR_UNIT1] = { 0x1701000, 0x1000 },
221
+ [MICROCHIP_PFSOC_BUSERR_UNIT2] = { 0x1702000, 0x1000 },
222
+ [MICROCHIP_PFSOC_BUSERR_UNIT3] = { 0x1703000, 0x1000 },
223
+ [MICROCHIP_PFSOC_BUSERR_UNIT4] = { 0x1704000, 0x1000 },
224
+ [MICROCHIP_PFSOC_CLINT] = { 0x2000000, 0x10000 },
225
+ [MICROCHIP_PFSOC_L2CC] = { 0x2010000, 0x1000 },
226
+ [MICROCHIP_PFSOC_L2LIM] = { 0x8000000, 0x2000000 },
227
+ [MICROCHIP_PFSOC_PLIC] = { 0xc000000, 0x4000000 },
228
+ [MICROCHIP_PFSOC_SYSREG] = { 0x20002000, 0x2000 },
229
+ [MICROCHIP_PFSOC_MPUCFG] = { 0x20005000, 0x1000 },
230
+ [MICROCHIP_PFSOC_ENVM_CFG] = { 0x20200000, 0x1000 },
231
+ [MICROCHIP_PFSOC_ENVM_DATA] = { 0x20220000, 0x20000 },
232
+ [MICROCHIP_PFSOC_IOSCB_CFG] = { 0x37080000, 0x1000 },
233
+ [MICROCHIP_PFSOC_DRAM] = { 0x80000000, 0x0 },
234
+};
235
+
236
+static void microchip_pfsoc_soc_instance_init(Object *obj)
237
+{
238
+ MachineState *ms = MACHINE(qdev_get_machine());
239
+ MicrochipPFSoCState *s = MICROCHIP_PFSOC(obj);
240
+
241
+ object_initialize_child(obj, "e-cluster", &s->e_cluster, TYPE_CPU_CLUSTER);
242
+ qdev_prop_set_uint32(DEVICE(&s->e_cluster), "cluster-id", 0);
243
+
244
+ object_initialize_child(OBJECT(&s->e_cluster), "e-cpus", &s->e_cpus,
245
+ TYPE_RISCV_HART_ARRAY);
246
+ qdev_prop_set_uint32(DEVICE(&s->e_cpus), "num-harts", 1);
247
+ qdev_prop_set_uint32(DEVICE(&s->e_cpus), "hartid-base", 0);
248
+ qdev_prop_set_string(DEVICE(&s->e_cpus), "cpu-type",
249
+ TYPE_RISCV_CPU_SIFIVE_E51);
250
+ qdev_prop_set_uint64(DEVICE(&s->e_cpus), "resetvec", RESET_VECTOR);
251
+
252
+ object_initialize_child(obj, "u-cluster", &s->u_cluster, TYPE_CPU_CLUSTER);
253
+ qdev_prop_set_uint32(DEVICE(&s->u_cluster), "cluster-id", 1);
254
+
255
+ object_initialize_child(OBJECT(&s->u_cluster), "u-cpus", &s->u_cpus,
256
+ TYPE_RISCV_HART_ARRAY);
257
+ qdev_prop_set_uint32(DEVICE(&s->u_cpus), "num-harts", ms->smp.cpus - 1);
258
+ qdev_prop_set_uint32(DEVICE(&s->u_cpus), "hartid-base", 1);
259
+ qdev_prop_set_string(DEVICE(&s->u_cpus), "cpu-type",
260
+ TYPE_RISCV_CPU_SIFIVE_U54);
261
+ qdev_prop_set_uint64(DEVICE(&s->u_cpus), "resetvec", RESET_VECTOR);
262
+}
38
+}
263
+
39
+
264
+static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp)
40
static bool gen_shift_imm_fn(DisasContext *ctx, arg_shift *a, DisasExtend ext,
41
void (*func)(TCGv, TCGv, target_long))
42
{
43
diff --git a/target/riscv/insn_trans/trans_rvm.c.inc b/target/riscv/insn_trans/trans_rvm.c.inc
44
index XXXXXXX..XXXXXXX 100644
45
--- a/target/riscv/insn_trans/trans_rvm.c.inc
46
+++ b/target/riscv/insn_trans/trans_rvm.c.inc
47
@@ -XXX,XX +XXX,XX @@ static void gen_mulh(TCGv ret, TCGv s1, TCGv s2)
48
tcg_temp_free(discard);
49
}
50
51
+static void gen_mulh_w(TCGv ret, TCGv s1, TCGv s2)
265
+{
52
+{
266
+ MachineState *ms = MACHINE(qdev_get_machine());
53
+ tcg_gen_mul_tl(ret, s1, s2);
267
+ MicrochipPFSoCState *s = MICROCHIP_PFSOC(dev);
54
+ tcg_gen_sari_tl(ret, ret, 32);
268
+ const struct MemmapEntry *memmap = microchip_pfsoc_memmap;
269
+ MemoryRegion *system_memory = get_system_memory();
270
+ MemoryRegion *e51_dtim_mem = g_new(MemoryRegion, 1);
271
+ MemoryRegion *l2lim_mem = g_new(MemoryRegion, 1);
272
+ MemoryRegion *envm_data = g_new(MemoryRegion, 1);
273
+ char *plic_hart_config;
274
+ size_t plic_hart_config_len;
275
+ int i;
276
+
277
+ sysbus_realize(SYS_BUS_DEVICE(&s->e_cpus), &error_abort);
278
+ sysbus_realize(SYS_BUS_DEVICE(&s->u_cpus), &error_abort);
279
+ /*
280
+ * The cluster must be realized after the RISC-V hart array container,
281
+ * as the container's CPU object is only created on realize, and the
282
+ * CPU must exist and have been parented into the cluster before the
283
+ * cluster is realized.
284
+ */
285
+ qdev_realize(DEVICE(&s->e_cluster), NULL, &error_abort);
286
+ qdev_realize(DEVICE(&s->u_cluster), NULL, &error_abort);
287
+
288
+ /* E51 DTIM */
289
+ memory_region_init_ram(e51_dtim_mem, NULL, "microchip.pfsoc.e51_dtim_mem",
290
+ memmap[MICROCHIP_PFSOC_E51_DTIM].size, &error_fatal);
291
+ memory_region_add_subregion(system_memory,
292
+ memmap[MICROCHIP_PFSOC_E51_DTIM].base,
293
+ e51_dtim_mem);
294
+
295
+ /* Bus Error Units */
296
+ create_unimplemented_device("microchip.pfsoc.buserr_unit0_mem",
297
+ memmap[MICROCHIP_PFSOC_BUSERR_UNIT0].base,
298
+ memmap[MICROCHIP_PFSOC_BUSERR_UNIT0].size);
299
+ create_unimplemented_device("microchip.pfsoc.buserr_unit1_mem",
300
+ memmap[MICROCHIP_PFSOC_BUSERR_UNIT1].base,
301
+ memmap[MICROCHIP_PFSOC_BUSERR_UNIT1].size);
302
+ create_unimplemented_device("microchip.pfsoc.buserr_unit2_mem",
303
+ memmap[MICROCHIP_PFSOC_BUSERR_UNIT2].base,
304
+ memmap[MICROCHIP_PFSOC_BUSERR_UNIT2].size);
305
+ create_unimplemented_device("microchip.pfsoc.buserr_unit3_mem",
306
+ memmap[MICROCHIP_PFSOC_BUSERR_UNIT3].base,
307
+ memmap[MICROCHIP_PFSOC_BUSERR_UNIT3].size);
308
+ create_unimplemented_device("microchip.pfsoc.buserr_unit4_mem",
309
+ memmap[MICROCHIP_PFSOC_BUSERR_UNIT4].base,
310
+ memmap[MICROCHIP_PFSOC_BUSERR_UNIT4].size);
311
+
312
+ /* CLINT */
313
+ sifive_clint_create(memmap[MICROCHIP_PFSOC_CLINT].base,
314
+ memmap[MICROCHIP_PFSOC_CLINT].size, 0, ms->smp.cpus,
315
+ SIFIVE_SIP_BASE, SIFIVE_TIMECMP_BASE, SIFIVE_TIME_BASE, false);
316
+
317
+ /* L2 cache controller */
318
+ create_unimplemented_device("microchip.pfsoc.l2cc",
319
+ memmap[MICROCHIP_PFSOC_L2CC].base, memmap[MICROCHIP_PFSOC_L2CC].size);
320
+
321
+ /*
322
+ * Add L2-LIM at reset size.
323
+ * This should be reduced in size as the L2 Cache Controller WayEnable
324
+ * register is incremented. Unfortunately I don't see a nice (or any) way
325
+ * to handle reducing or blocking out the L2 LIM while still allowing it
326
+ * be re returned to all enabled after a reset. For the time being, just
327
+ * leave it enabled all the time. This won't break anything, but will be
328
+ * too generous to misbehaving guests.
329
+ */
330
+ memory_region_init_ram(l2lim_mem, NULL, "microchip.pfsoc.l2lim",
331
+ memmap[MICROCHIP_PFSOC_L2LIM].size, &error_fatal);
332
+ memory_region_add_subregion(system_memory,
333
+ memmap[MICROCHIP_PFSOC_L2LIM].base,
334
+ l2lim_mem);
335
+
336
+ /* create PLIC hart topology configuration string */
337
+ plic_hart_config_len = (strlen(MICROCHIP_PFSOC_PLIC_HART_CONFIG) + 1) *
338
+ ms->smp.cpus;
339
+ plic_hart_config = g_malloc0(plic_hart_config_len);
340
+ for (i = 0; i < ms->smp.cpus; i++) {
341
+ if (i != 0) {
342
+ strncat(plic_hart_config, "," MICROCHIP_PFSOC_PLIC_HART_CONFIG,
343
+ plic_hart_config_len);
344
+ } else {
345
+ strncat(plic_hart_config, "M", plic_hart_config_len);
346
+ }
347
+ plic_hart_config_len -= (strlen(MICROCHIP_PFSOC_PLIC_HART_CONFIG) + 1);
348
+ }
349
+
350
+ /* PLIC */
351
+ s->plic = sifive_plic_create(memmap[MICROCHIP_PFSOC_PLIC].base,
352
+ plic_hart_config, 0,
353
+ MICROCHIP_PFSOC_PLIC_NUM_SOURCES,
354
+ MICROCHIP_PFSOC_PLIC_NUM_PRIORITIES,
355
+ MICROCHIP_PFSOC_PLIC_PRIORITY_BASE,
356
+ MICROCHIP_PFSOC_PLIC_PENDING_BASE,
357
+ MICROCHIP_PFSOC_PLIC_ENABLE_BASE,
358
+ MICROCHIP_PFSOC_PLIC_ENABLE_STRIDE,
359
+ MICROCHIP_PFSOC_PLIC_CONTEXT_BASE,
360
+ MICROCHIP_PFSOC_PLIC_CONTEXT_STRIDE,
361
+ memmap[MICROCHIP_PFSOC_PLIC].size);
362
+ g_free(plic_hart_config);
363
+
364
+ /* SYSREG */
365
+ create_unimplemented_device("microchip.pfsoc.sysreg",
366
+ memmap[MICROCHIP_PFSOC_SYSREG].base,
367
+ memmap[MICROCHIP_PFSOC_SYSREG].size);
368
+
369
+ /* MPUCFG */
370
+ create_unimplemented_device("microchip.pfsoc.mpucfg",
371
+ memmap[MICROCHIP_PFSOC_MPUCFG].base,
372
+ memmap[MICROCHIP_PFSOC_MPUCFG].size);
373
+
374
+ /* eNVM */
375
+ memory_region_init_rom(envm_data, OBJECT(dev), "microchip.pfsoc.envm.data",
376
+ memmap[MICROCHIP_PFSOC_ENVM_DATA].size,
377
+ &error_fatal);
378
+ memory_region_add_subregion(system_memory,
379
+ memmap[MICROCHIP_PFSOC_ENVM_DATA].base,
380
+ envm_data);
381
+
382
+ /* IOSCBCFG */
383
+ create_unimplemented_device("microchip.pfsoc.ioscb.cfg",
384
+ memmap[MICROCHIP_PFSOC_IOSCB_CFG].base,
385
+ memmap[MICROCHIP_PFSOC_IOSCB_CFG].size);
386
+}
55
+}
387
+
56
+
388
+static void microchip_pfsoc_soc_class_init(ObjectClass *oc, void *data)
57
static bool trans_mulh(DisasContext *ctx, arg_mulh *a)
58
{
59
REQUIRE_EXT(ctx, RVM);
60
- return gen_arith(ctx, a, EXT_NONE, gen_mulh);
61
+ return gen_arith_per_ol(ctx, a, EXT_SIGN, gen_mulh, gen_mulh_w);
62
}
63
64
static void gen_mulhsu(TCGv ret, TCGv arg1, TCGv arg2)
65
@@ -XXX,XX +XXX,XX @@ static void gen_mulhsu(TCGv ret, TCGv arg1, TCGv arg2)
66
tcg_temp_free(rh);
67
}
68
69
+static void gen_mulhsu_w(TCGv ret, TCGv arg1, TCGv arg2)
389
+{
70
+{
390
+ DeviceClass *dc = DEVICE_CLASS(oc);
71
+ TCGv t1 = tcg_temp_new();
72
+ TCGv t2 = tcg_temp_new();
391
+
73
+
392
+ dc->realize = microchip_pfsoc_soc_realize;
74
+ tcg_gen_ext32s_tl(t1, arg1);
393
+ /* Reason: Uses serial_hds in realize function, thus can't be used twice */
75
+ tcg_gen_ext32u_tl(t2, arg2);
394
+ dc->user_creatable = false;
76
+ tcg_gen_mul_tl(ret, t1, t2);
77
+ tcg_temp_free(t1);
78
+ tcg_temp_free(t2);
79
+ tcg_gen_sari_tl(ret, ret, 32);
395
+}
80
+}
396
+
81
+
397
+static const TypeInfo microchip_pfsoc_soc_type_info = {
82
static bool trans_mulhsu(DisasContext *ctx, arg_mulhsu *a)
398
+ .name = TYPE_MICROCHIP_PFSOC,
83
{
399
+ .parent = TYPE_DEVICE,
84
REQUIRE_EXT(ctx, RVM);
400
+ .instance_size = sizeof(MicrochipPFSoCState),
85
- return gen_arith(ctx, a, EXT_NONE, gen_mulhsu);
401
+ .instance_init = microchip_pfsoc_soc_instance_init,
86
+ return gen_arith_per_ol(ctx, a, EXT_NONE, gen_mulhsu, gen_mulhsu_w);
402
+ .class_init = microchip_pfsoc_soc_class_init,
87
}
403
+};
88
404
+
89
static void gen_mulhu(TCGv ret, TCGv s1, TCGv s2)
405
+static void microchip_pfsoc_soc_register_types(void)
90
@@ -XXX,XX +XXX,XX @@ static void gen_mulhu(TCGv ret, TCGv s1, TCGv s2)
406
+{
91
static bool trans_mulhu(DisasContext *ctx, arg_mulhu *a)
407
+ type_register_static(&microchip_pfsoc_soc_type_info);
92
{
408
+}
93
REQUIRE_EXT(ctx, RVM);
409
+
94
- return gen_arith(ctx, a, EXT_NONE, gen_mulhu);
410
+type_init(microchip_pfsoc_soc_register_types)
95
+ /* gen_mulh_w works for either sign as input. */
411
+
96
+ return gen_arith_per_ol(ctx, a, EXT_ZERO, gen_mulhu, gen_mulh_w);
412
+static void microchip_icicle_kit_machine_init(MachineState *machine)
97
}
413
+{
98
414
+ MachineClass *mc = MACHINE_GET_CLASS(machine);
99
static void gen_div(TCGv ret, TCGv source1, TCGv source2)
415
+ const struct MemmapEntry *memmap = microchip_pfsoc_memmap;
416
+ MicrochipIcicleKitState *s = MICROCHIP_ICICLE_KIT_MACHINE(machine);
417
+ MemoryRegion *system_memory = get_system_memory();
418
+ MemoryRegion *main_mem = g_new(MemoryRegion, 1);
419
+
420
+ /* Sanity check on RAM size */
421
+ if (machine->ram_size < mc->default_ram_size) {
422
+ char *sz = size_to_str(mc->default_ram_size);
423
+ error_report("Invalid RAM size, should be bigger than %s", sz);
424
+ g_free(sz);
425
+ exit(EXIT_FAILURE);
426
+ }
427
+
428
+ /* Initialize SoC */
429
+ object_initialize_child(OBJECT(machine), "soc", &s->soc,
430
+ TYPE_MICROCHIP_PFSOC);
431
+ qdev_realize(DEVICE(&s->soc), NULL, &error_abort);
432
+
433
+ /* Register RAM */
434
+ memory_region_init_ram(main_mem, NULL, "microchip.icicle.kit.ram",
435
+ machine->ram_size, &error_fatal);
436
+ memory_region_add_subregion(system_memory,
437
+ memmap[MICROCHIP_PFSOC_DRAM].base, main_mem);
438
+
439
+ /* Load the firmware */
440
+ riscv_find_and_load_firmware(machine, BIOS_FILENAME, RESET_VECTOR, NULL);
441
+}
442
+
443
+static void microchip_icicle_kit_machine_class_init(ObjectClass *oc, void *data)
444
+{
445
+ MachineClass *mc = MACHINE_CLASS(oc);
446
+
447
+ mc->desc = "Microchip PolarFire SoC Icicle Kit";
448
+ mc->init = microchip_icicle_kit_machine_init;
449
+ mc->max_cpus = MICROCHIP_PFSOC_MANAGEMENT_CPU_COUNT +
450
+ MICROCHIP_PFSOC_COMPUTE_CPU_COUNT;
451
+ mc->min_cpus = MICROCHIP_PFSOC_MANAGEMENT_CPU_COUNT + 1;
452
+ mc->default_cpus = mc->min_cpus;
453
+ mc->default_ram_size = 1 * GiB;
454
+}
455
+
456
+static const TypeInfo microchip_icicle_kit_machine_typeinfo = {
457
+ .name = MACHINE_TYPE_NAME("microchip-icicle-kit"),
458
+ .parent = TYPE_MACHINE,
459
+ .class_init = microchip_icicle_kit_machine_class_init,
460
+ .instance_size = sizeof(MicrochipIcicleKitState),
461
+};
462
+
463
+static void microchip_icicle_kit_machine_init_register_types(void)
464
+{
465
+ type_register_static(&microchip_icicle_kit_machine_typeinfo);
466
+}
467
+
468
+type_init(microchip_icicle_kit_machine_init_register_types)
469
diff --git a/MAINTAINERS b/MAINTAINERS
470
index XXXXXXX..XXXXXXX 100644
471
--- a/MAINTAINERS
472
+++ b/MAINTAINERS
473
@@ -XXX,XX +XXX,XX @@ F: include/hw/riscv/opentitan.h
474
F: include/hw/char/ibex_uart.h
475
F: include/hw/intc/ibex_plic.h
476
477
+Microchip PolarFire SoC Icicle Kit
478
+M: Bin Meng <bin.meng@windriver.com>
479
+L: qemu-riscv@nongnu.org
480
+S: Supported
481
+F: hw/riscv/microchip_pfsoc.c
482
+F: include/hw/riscv/microchip_pfsoc.h
483
+
484
RX Machines
485
-----------
486
rx-gdbsim
487
diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
488
index XXXXXXX..XXXXXXX 100644
489
--- a/hw/riscv/Kconfig
490
+++ b/hw/riscv/Kconfig
491
@@ -XXX,XX +XXX,XX @@ config RISCV_VIRT
492
select PCI_EXPRESS_GENERIC_BRIDGE
493
select PFLASH_CFI01
494
select SIFIVE
495
+
496
+config MICROCHIP_PFSOC
497
+ bool
498
+ select HART
499
+ select SIFIVE
500
+ select UNIMP
501
diff --git a/hw/riscv/meson.build b/hw/riscv/meson.build
502
index XXXXXXX..XXXXXXX 100644
503
--- a/hw/riscv/meson.build
504
+++ b/hw/riscv/meson.build
505
@@ -XXX,XX +XXX,XX @@ riscv_ss.add(when: 'CONFIG_SIFIVE_U', if_true: files('sifive_u_otp.c'))
506
riscv_ss.add(when: 'CONFIG_SIFIVE_U', if_true: files('sifive_u_prci.c'))
507
riscv_ss.add(when: 'CONFIG_SPIKE', if_true: files('riscv_htif.c'))
508
riscv_ss.add(when: 'CONFIG_SPIKE', if_true: files('spike.c'))
509
+riscv_ss.add(when: 'CONFIG_MICROCHIP_PFSOC', if_true: files('microchip_pfsoc.c'))
510
511
hw_arch += {'riscv': riscv_ss}
512
--
100
--
513
2.28.0
101
2.31.1
514
102
515
103
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Microchip PolarFire SoC MMUART is ns16550 compatible, with some
3
When target_long is 64-bit, we still want a 32-bit bswap for rev8.
4
additional registers. Create a simple MMUART model built on top
4
Since this opcode is specific to RV32, we need not conditionalize.
5
of the existing ns16550 model.
6
5
7
Signed-off-by: Bin Meng <bin.meng@windriver.com>
6
Acked-by: Alistair Francis <alistair.francis@wdc.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Reviewed-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
9
Message-Id: <1598924352-89526-6-git-send-email-bmeng.cn@gmail.com>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20211020031709.359469-12-richard.henderson@linaro.org
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
11
---
12
include/hw/char/mchp_pfsoc_mmuart.h | 61 ++++++++++++++++++++
12
target/riscv/insn_trans/trans_rvb.c.inc | 7 ++++++-
13
hw/char/mchp_pfsoc_mmuart.c | 86 +++++++++++++++++++++++++++++
13
1 file changed, 6 insertions(+), 1 deletion(-)
14
MAINTAINERS | 2 +
15
hw/char/Kconfig | 3 +
16
hw/char/meson.build | 1 +
17
5 files changed, 153 insertions(+)
18
create mode 100644 include/hw/char/mchp_pfsoc_mmuart.h
19
create mode 100644 hw/char/mchp_pfsoc_mmuart.c
20
14
21
diff --git a/include/hw/char/mchp_pfsoc_mmuart.h b/include/hw/char/mchp_pfsoc_mmuart.h
15
diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_trans/trans_rvb.c.inc
22
new file mode 100644
16
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX
17
--- a/target/riscv/insn_trans/trans_rvb.c.inc
24
--- /dev/null
18
+++ b/target/riscv/insn_trans/trans_rvb.c.inc
25
+++ b/include/hw/char/mchp_pfsoc_mmuart.h
19
@@ -XXX,XX +XXX,XX @@ static bool trans_rol(DisasContext *ctx, arg_rol *a)
26
@@ -XXX,XX +XXX,XX @@
20
return gen_shift(ctx, a, EXT_NONE, tcg_gen_rotl_tl);
27
+/*
21
}
28
+ * Microchip PolarFire SoC MMUART emulation
22
29
+ *
23
+static void gen_rev8_32(TCGv ret, TCGv src1)
30
+ * Copyright (c) 2020 Wind River Systems, Inc.
31
+ *
32
+ * Author:
33
+ * Bin Meng <bin.meng@windriver.com>
34
+ *
35
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
36
+ * of this software and associated documentation files (the "Software"), to deal
37
+ * in the Software without restriction, including without limitation the rights
38
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
39
+ * copies of the Software, and to permit persons to whom the Software is
40
+ * furnished to do so, subject to the following conditions:
41
+ *
42
+ * The above copyright notice and this permission notice shall be included in
43
+ * all copies or substantial portions of the Software.
44
+ *
45
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
46
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
47
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
48
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
49
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
50
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
51
+ * THE SOFTWARE.
52
+ */
53
+
54
+#ifndef HW_MCHP_PFSOC_MMUART_H
55
+#define HW_MCHP_PFSOC_MMUART_H
56
+
57
+#include "hw/char/serial.h"
58
+
59
+#define MCHP_PFSOC_MMUART_REG_SIZE 52
60
+
61
+typedef struct MchpPfSoCMMUartState {
62
+ MemoryRegion iomem;
63
+ hwaddr base;
64
+ qemu_irq irq;
65
+
66
+ SerialMM *serial;
67
+
68
+ uint32_t reg[MCHP_PFSOC_MMUART_REG_SIZE / sizeof(uint32_t)];
69
+} MchpPfSoCMMUartState;
70
+
71
+/**
72
+ * mchp_pfsoc_mmuart_create - Create a Microchip PolarFire SoC MMUART
73
+ *
74
+ * This is a helper routine for board to create a MMUART device that is
75
+ * compatible with Microchip PolarFire SoC.
76
+ *
77
+ * @sysmem: system memory region to map
78
+ * @base: base address of the MMUART registers
79
+ * @irq: IRQ number of the MMUART device
80
+ * @chr: character device to associate to
81
+ *
82
+ * @return: a pointer to the device specific control structure
83
+ */
84
+MchpPfSoCMMUartState *mchp_pfsoc_mmuart_create(MemoryRegion *sysmem,
85
+ hwaddr base, qemu_irq irq, Chardev *chr);
86
+
87
+#endif /* HW_MCHP_PFSOC_MMUART_H */
88
diff --git a/hw/char/mchp_pfsoc_mmuart.c b/hw/char/mchp_pfsoc_mmuart.c
89
new file mode 100644
90
index XXXXXXX..XXXXXXX
91
--- /dev/null
92
+++ b/hw/char/mchp_pfsoc_mmuart.c
93
@@ -XXX,XX +XXX,XX @@
94
+/*
95
+ * Microchip PolarFire SoC MMUART emulation
96
+ *
97
+ * Copyright (c) 2020 Wind River Systems, Inc.
98
+ *
99
+ * Author:
100
+ * Bin Meng <bin.meng@windriver.com>
101
+ *
102
+ * This program is free software; you can redistribute it and/or
103
+ * modify it under the terms of the GNU General Public License as
104
+ * published by the Free Software Foundation; either version 2 or
105
+ * (at your option) version 3 of the License.
106
+ *
107
+ * This program is distributed in the hope that it will be useful,
108
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
109
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
110
+ * GNU General Public License for more details.
111
+ *
112
+ * You should have received a copy of the GNU General Public License along
113
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
114
+ */
115
+
116
+#include "qemu/osdep.h"
117
+#include "qemu/log.h"
118
+#include "chardev/char.h"
119
+#include "exec/address-spaces.h"
120
+#include "hw/char/mchp_pfsoc_mmuart.h"
121
+
122
+static uint64_t mchp_pfsoc_mmuart_read(void *opaque, hwaddr addr, unsigned size)
123
+{
24
+{
124
+ MchpPfSoCMMUartState *s = opaque;
25
+ tcg_gen_bswap32_tl(ret, src1, TCG_BSWAP_OS);
125
+
126
+ if (addr >= MCHP_PFSOC_MMUART_REG_SIZE) {
127
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: read: addr=0x%" HWADDR_PRIx "\n",
128
+ __func__, addr);
129
+ return 0;
130
+ }
131
+
132
+ return s->reg[addr / sizeof(uint32_t)];
133
+}
26
+}
134
+
27
+
135
+static void mchp_pfsoc_mmuart_write(void *opaque, hwaddr addr,
28
static bool trans_rev8_32(DisasContext *ctx, arg_rev8_32 *a)
136
+ uint64_t value, unsigned size)
29
{
137
+{
30
REQUIRE_32BIT(ctx);
138
+ MchpPfSoCMMUartState *s = opaque;
31
REQUIRE_ZBB(ctx);
139
+ uint32_t val32 = (uint32_t)value;
32
- return gen_unary(ctx, a, EXT_NONE, tcg_gen_bswap_tl);
140
+
33
+ return gen_unary(ctx, a, EXT_NONE, gen_rev8_32);
141
+ if (addr >= MCHP_PFSOC_MMUART_REG_SIZE) {
34
}
142
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: bad write: addr=0x%" HWADDR_PRIx
35
143
+ " v=0x%x\n", __func__, addr, val32);
36
static bool trans_rev8_64(DisasContext *ctx, arg_rev8_64 *a)
144
+ return;
145
+ }
146
+
147
+ s->reg[addr / sizeof(uint32_t)] = val32;
148
+}
149
+
150
+static const MemoryRegionOps mchp_pfsoc_mmuart_ops = {
151
+ .read = mchp_pfsoc_mmuart_read,
152
+ .write = mchp_pfsoc_mmuart_write,
153
+ .endianness = DEVICE_LITTLE_ENDIAN,
154
+ .impl = {
155
+ .min_access_size = 4,
156
+ .max_access_size = 4,
157
+ },
158
+};
159
+
160
+MchpPfSoCMMUartState *mchp_pfsoc_mmuart_create(MemoryRegion *sysmem,
161
+ hwaddr base, qemu_irq irq, Chardev *chr)
162
+{
163
+ MchpPfSoCMMUartState *s;
164
+
165
+ s = g_new0(MchpPfSoCMMUartState, 1);
166
+
167
+ memory_region_init_io(&s->iomem, NULL, &mchp_pfsoc_mmuart_ops, s,
168
+ "mchp.pfsoc.mmuart", 0x1000);
169
+
170
+ s->base = base;
171
+ s->irq = irq;
172
+
173
+ s->serial = serial_mm_init(sysmem, base, 2, irq, 399193, chr,
174
+ DEVICE_LITTLE_ENDIAN);
175
+
176
+ memory_region_add_subregion(sysmem, base + 0x20, &s->iomem);
177
+
178
+ return s;
179
+}
180
diff --git a/MAINTAINERS b/MAINTAINERS
181
index XXXXXXX..XXXXXXX 100644
182
--- a/MAINTAINERS
183
+++ b/MAINTAINERS
184
@@ -XXX,XX +XXX,XX @@ M: Bin Meng <bin.meng@windriver.com>
185
L: qemu-riscv@nongnu.org
186
S: Supported
187
F: hw/riscv/microchip_pfsoc.c
188
+F: hw/char/mchp_pfsoc_mmuart.c
189
F: include/hw/riscv/microchip_pfsoc.h
190
+F: include/hw/char/mchp_pfsoc_mmuart.h
191
192
RX Machines
193
-----------
194
diff --git a/hw/char/Kconfig b/hw/char/Kconfig
195
index XXXXXXX..XXXXXXX 100644
196
--- a/hw/char/Kconfig
197
+++ b/hw/char/Kconfig
198
@@ -XXX,XX +XXX,XX @@ config RENESAS_SCI
199
200
config AVR_USART
201
bool
202
+
203
+config MCHP_PFSOC_MMUART
204
+ bool
205
diff --git a/hw/char/meson.build b/hw/char/meson.build
206
index XXXXXXX..XXXXXXX 100644
207
--- a/hw/char/meson.build
208
+++ b/hw/char/meson.build
209
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_aux.c'))
210
softmmu_ss.add(when: 'CONFIG_RENESAS_SCI', if_true: files('renesas_sci.c'))
211
softmmu_ss.add(when: 'CONFIG_SH4', if_true: files('sh_serial.c'))
212
softmmu_ss.add(when: 'CONFIG_STM32F2XX_USART', if_true: files('stm32f2xx_usart.c'))
213
+softmmu_ss.add(when: 'CONFIG_MCHP_PFSOC_MMUART', if_true: files('mchp_pfsoc_mmuart.c'))
214
215
specific_ss.add(when: 'CONFIG_TERMINAL3270', if_true: files('terminal3270.c'))
216
specific_ss.add(when: 'CONFIG_VIRTIO', if_true: files('virtio-serial-bus.c'))
217
--
37
--
218
2.28.0
38
2.31.1
219
39
220
40
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Cadence SD/SDIO/eMMC Host Controller (SD4HC) is an SDHCI compatible
3
The count zeros instructions require a separate implementation
4
controller. The SDHCI compatible registers start from offset 0x200,
4
for RV32 when TARGET_LONG_BITS == 64.
5
which are called Slot Register Set (SRS) in its datasheet.
6
5
7
This creates a Cadence SDHCI model built on top of the existing
6
Reviewed-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
8
generic SDHCI model. Cadence specific Host Register Set (HRS) is
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
implemented to make guest software happy.
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
9
Message-id: 20211020031709.359469-13-richard.henderson@linaro.org
11
Signed-off-by: Bin Meng <bin.meng@windriver.com>
12
Acked-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
Acked-by: Alistair Francis <alistair.francis@wdc.com>
14
Message-Id: <1598924352-89526-8-git-send-email-bmeng.cn@gmail.com>
15
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
16
---
11
---
17
include/hw/sd/cadence_sdhci.h | 47 +++++++++
12
target/riscv/translate.c | 16 ++++++++++++
18
hw/sd/cadence_sdhci.c | 193 ++++++++++++++++++++++++++++++++++
13
target/riscv/insn_trans/trans_rvb.c.inc | 33 ++++++++++++-------------
19
hw/sd/Kconfig | 4 +
14
2 files changed, 32 insertions(+), 17 deletions(-)
20
hw/sd/meson.build | 1 +
21
4 files changed, 245 insertions(+)
22
create mode 100644 include/hw/sd/cadence_sdhci.h
23
create mode 100644 hw/sd/cadence_sdhci.c
24
15
25
diff --git a/include/hw/sd/cadence_sdhci.h b/include/hw/sd/cadence_sdhci.h
16
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
26
new file mode 100644
17
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX
18
--- a/target/riscv/translate.c
28
--- /dev/null
19
+++ b/target/riscv/translate.c
29
+++ b/include/hw/sd/cadence_sdhci.h
20
@@ -XXX,XX +XXX,XX @@ static bool gen_unary(DisasContext *ctx, arg_r2 *a, DisasExtend ext,
30
@@ -XXX,XX +XXX,XX @@
21
return true;
31
+/*
22
}
32
+ * Cadence SDHCI emulation
23
33
+ *
24
+static bool gen_unary_per_ol(DisasContext *ctx, arg_r2 *a, DisasExtend ext,
34
+ * Copyright (c) 2020 Wind River Systems, Inc.
25
+ void (*f_tl)(TCGv, TCGv),
35
+ *
26
+ void (*f_32)(TCGv, TCGv))
36
+ * Author:
27
+{
37
+ * Bin Meng <bin.meng@windriver.com>
28
+ int olen = get_olen(ctx);
38
+ *
39
+ * This program is free software; you can redistribute it and/or
40
+ * modify it under the terms of the GNU General Public License as
41
+ * published by the Free Software Foundation; either version 2 or
42
+ * (at your option) version 3 of the License.
43
+ *
44
+ * This program is distributed in the hope that it will be useful,
45
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
46
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47
+ * GNU General Public License for more details.
48
+ *
49
+ * You should have received a copy of the GNU General Public License along
50
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
51
+ */
52
+
29
+
53
+#ifndef CADENCE_SDHCI_H
30
+ if (olen != TARGET_LONG_BITS) {
54
+#define CADENCE_SDHCI_H
31
+ if (olen == 32) {
55
+
32
+ f_tl = f_32;
56
+#include "hw/sd/sdhci.h"
33
+ } else {
57
+
34
+ g_assert_not_reached();
58
+#define CADENCE_SDHCI_REG_SIZE 0x100
35
+ }
59
+#define CADENCE_SDHCI_NUM_REGS (CADENCE_SDHCI_REG_SIZE / sizeof(uint32_t))
36
+ }
60
+
37
+ return gen_unary(ctx, a, ext, f_tl);
61
+typedef struct CadenceSDHCIState {
62
+ SysBusDevice parent;
63
+
64
+ MemoryRegion container;
65
+ MemoryRegion iomem;
66
+ BusState *bus;
67
+
68
+ uint32_t regs[CADENCE_SDHCI_NUM_REGS];
69
+
70
+ SDHCIState sdhci;
71
+} CadenceSDHCIState;
72
+
73
+#define TYPE_CADENCE_SDHCI "cadence.sdhci"
74
+#define CADENCE_SDHCI(obj) OBJECT_CHECK(CadenceSDHCIState, (obj), \
75
+ TYPE_CADENCE_SDHCI)
76
+
77
+#endif /* CADENCE_SDHCI_H */
78
diff --git a/hw/sd/cadence_sdhci.c b/hw/sd/cadence_sdhci.c
79
new file mode 100644
80
index XXXXXXX..XXXXXXX
81
--- /dev/null
82
+++ b/hw/sd/cadence_sdhci.c
83
@@ -XXX,XX +XXX,XX @@
84
+/*
85
+ * Cadence SDHCI emulation
86
+ *
87
+ * Copyright (c) 2020 Wind River Systems, Inc.
88
+ *
89
+ * Author:
90
+ * Bin Meng <bin.meng@windriver.com>
91
+ *
92
+ * This program is free software; you can redistribute it and/or
93
+ * modify it under the terms of the GNU General Public License as
94
+ * published by the Free Software Foundation; either version 2 or
95
+ * (at your option) version 3 of the License.
96
+ *
97
+ * This program is distributed in the hope that it will be useful,
98
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
99
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
100
+ * GNU General Public License for more details.
101
+ *
102
+ * You should have received a copy of the GNU General Public License along
103
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
104
+ */
105
+
106
+#include "qemu/osdep.h"
107
+#include "qemu/bitops.h"
108
+#include "qemu/error-report.h"
109
+#include "qemu/log.h"
110
+#include "qapi/error.h"
111
+#include "migration/vmstate.h"
112
+#include "hw/irq.h"
113
+#include "hw/sd/cadence_sdhci.h"
114
+#include "sdhci-internal.h"
115
+
116
+/* HRS - Host Register Set (specific to Cadence) */
117
+
118
+#define CADENCE_SDHCI_HRS00 0x00 /* general information */
119
+#define CADENCE_SDHCI_HRS00_SWR BIT(0)
120
+#define CADENCE_SDHCI_HRS00_POR_VAL 0x00010000
121
+
122
+#define CADENCE_SDHCI_HRS04 0x10 /* PHY access port */
123
+#define CADENCE_SDHCI_HRS04_WR BIT(24)
124
+#define CADENCE_SDHCI_HRS04_RD BIT(25)
125
+#define CADENCE_SDHCI_HRS04_ACK BIT(26)
126
+
127
+#define CADENCE_SDHCI_HRS06 0x18 /* eMMC control */
128
+#define CADENCE_SDHCI_HRS06_TUNE_UP BIT(15)
129
+
130
+/* SRS - Slot Register Set (SDHCI-compatible) */
131
+
132
+#define CADENCE_SDHCI_SRS_BASE 0x200
133
+
134
+#define TO_REG(addr) ((addr) / sizeof(uint32_t))
135
+
136
+static void cadence_sdhci_instance_init(Object *obj)
137
+{
138
+ CadenceSDHCIState *s = CADENCE_SDHCI(obj);
139
+
140
+ object_initialize_child(OBJECT(s), "generic-sdhci",
141
+ &s->sdhci, TYPE_SYSBUS_SDHCI);
142
+}
38
+}
143
+
39
+
144
+static void cadence_sdhci_reset(DeviceState *dev)
40
static uint32_t opcode_at(DisasContextBase *dcbase, target_ulong pc)
41
{
42
DisasContext *ctx = container_of(dcbase, DisasContext, base);
43
diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_trans/trans_rvb.c.inc
44
index XXXXXXX..XXXXXXX 100644
45
--- a/target/riscv/insn_trans/trans_rvb.c.inc
46
+++ b/target/riscv/insn_trans/trans_rvb.c.inc
47
@@ -XXX,XX +XXX,XX @@ static void gen_clz(TCGv ret, TCGv arg1)
48
tcg_gen_clzi_tl(ret, arg1, TARGET_LONG_BITS);
49
}
50
51
+static void gen_clzw(TCGv ret, TCGv arg1)
145
+{
52
+{
146
+ CadenceSDHCIState *s = CADENCE_SDHCI(dev);
53
+ TCGv t = tcg_temp_new();
147
+
54
+ tcg_gen_shli_tl(t, arg1, 32);
148
+ memset(s->regs, 0, CADENCE_SDHCI_REG_SIZE);
55
+ tcg_gen_clzi_tl(ret, t, 32);
149
+ s->regs[TO_REG(CADENCE_SDHCI_HRS00)] = CADENCE_SDHCI_HRS00_POR_VAL;
56
+ tcg_temp_free(t);
150
+
151
+ device_cold_reset(DEVICE(&s->sdhci));
152
+}
57
+}
153
+
58
+
154
+static uint64_t cadence_sdhci_read(void *opaque, hwaddr addr, unsigned int size)
59
static bool trans_clz(DisasContext *ctx, arg_clz *a)
60
{
61
REQUIRE_ZBB(ctx);
62
- return gen_unary(ctx, a, EXT_ZERO, gen_clz);
63
+ return gen_unary_per_ol(ctx, a, EXT_NONE, gen_clz, gen_clzw);
64
}
65
66
static void gen_ctz(TCGv ret, TCGv arg1)
67
@@ -XXX,XX +XXX,XX @@ static void gen_ctz(TCGv ret, TCGv arg1)
68
tcg_gen_ctzi_tl(ret, arg1, TARGET_LONG_BITS);
69
}
70
71
+static void gen_ctzw(TCGv ret, TCGv arg1)
155
+{
72
+{
156
+ CadenceSDHCIState *s = opaque;
73
+ tcg_gen_ctzi_tl(ret, arg1, 32);
157
+ uint32_t val;
158
+
159
+ val = s->regs[TO_REG(addr)];
160
+
161
+ return (uint64_t)val;
162
+}
74
+}
163
+
75
+
164
+static void cadence_sdhci_write(void *opaque, hwaddr addr, uint64_t val,
76
static bool trans_ctz(DisasContext *ctx, arg_ctz *a)
165
+ unsigned int size)
77
{
166
+{
78
REQUIRE_ZBB(ctx);
167
+ CadenceSDHCIState *s = opaque;
79
- return gen_unary(ctx, a, EXT_ZERO, gen_ctz);
168
+ uint32_t val32 = (uint32_t)val;
80
+ return gen_unary_per_ol(ctx, a, EXT_ZERO, gen_ctz, gen_ctzw);
169
+
81
}
170
+ switch (addr) {
82
171
+ case CADENCE_SDHCI_HRS00:
83
static bool trans_cpop(DisasContext *ctx, arg_cpop *a)
172
+ /*
84
@@ -XXX,XX +XXX,XX @@ static bool trans_zext_h_64(DisasContext *ctx, arg_zext_h_64 *a)
173
+ * The only writable bit is SWR (software reset) and it automatically
85
return gen_unary(ctx, a, EXT_NONE, tcg_gen_ext16u_tl);
174
+ * clears to zero, so essentially this register remains unchanged.
86
}
175
+ */
87
176
+ if (val32 & CADENCE_SDHCI_HRS00_SWR) {
88
-static void gen_clzw(TCGv ret, TCGv arg1)
177
+ cadence_sdhci_reset(DEVICE(s));
89
-{
178
+ }
90
- TCGv t = tcg_temp_new();
179
+
91
- tcg_gen_shli_tl(t, arg1, 32);
180
+ break;
92
- tcg_gen_clzi_tl(ret, t, 32);
181
+ case CADENCE_SDHCI_HRS04:
93
- tcg_temp_free(t);
182
+ /*
94
-}
183
+ * Only emulate the ACK bit behavior when read or write transaction
95
-
184
+ * are requested.
96
static bool trans_clzw(DisasContext *ctx, arg_clzw *a)
185
+ */
97
{
186
+ if (val32 & (CADENCE_SDHCI_HRS04_WR | CADENCE_SDHCI_HRS04_RD)) {
98
REQUIRE_64BIT(ctx);
187
+ val32 |= CADENCE_SDHCI_HRS04_ACK;
99
@@ -XXX,XX +XXX,XX @@ static bool trans_clzw(DisasContext *ctx, arg_clzw *a)
188
+ } else {
100
return gen_unary(ctx, a, EXT_NONE, gen_clzw);
189
+ val32 &= ~CADENCE_SDHCI_HRS04_ACK;
101
}
190
+ }
102
191
+
103
-static void gen_ctzw(TCGv ret, TCGv arg1)
192
+ s->regs[TO_REG(addr)] = val32;
104
-{
193
+ break;
105
- tcg_gen_ori_tl(ret, arg1, (target_ulong)MAKE_64BIT_MASK(32, 32));
194
+ case CADENCE_SDHCI_HRS06:
106
- tcg_gen_ctzi_tl(ret, ret, 64);
195
+ if (val32 & CADENCE_SDHCI_HRS06_TUNE_UP) {
107
-}
196
+ val32 &= ~CADENCE_SDHCI_HRS06_TUNE_UP;
108
-
197
+ }
109
static bool trans_ctzw(DisasContext *ctx, arg_ctzw *a)
198
+
110
{
199
+ s->regs[TO_REG(addr)] = val32;
111
REQUIRE_64BIT(ctx);
200
+ break;
112
REQUIRE_ZBB(ctx);
201
+ default:
113
- return gen_unary(ctx, a, EXT_NONE, gen_ctzw);
202
+ s->regs[TO_REG(addr)] = val32;
114
+ return gen_unary(ctx, a, EXT_ZERO, gen_ctzw);
203
+ break;
115
}
204
+ }
116
205
+}
117
static bool trans_cpopw(DisasContext *ctx, arg_cpopw *a)
206
+
207
+static const MemoryRegionOps cadence_sdhci_ops = {
208
+ .read = cadence_sdhci_read,
209
+ .write = cadence_sdhci_write,
210
+ .endianness = DEVICE_NATIVE_ENDIAN,
211
+ .impl = {
212
+ .min_access_size = 4,
213
+ .max_access_size = 4,
214
+ },
215
+ .valid = {
216
+ .min_access_size = 4,
217
+ .max_access_size = 4,
218
+ }
219
+};
220
+
221
+static void cadence_sdhci_realize(DeviceState *dev, Error **errp)
222
+{
223
+ CadenceSDHCIState *s = CADENCE_SDHCI(dev);
224
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
225
+ SysBusDevice *sbd_sdhci = SYS_BUS_DEVICE(&s->sdhci);
226
+
227
+ memory_region_init(&s->container, OBJECT(s),
228
+ "cadence.sdhci-container", 0x1000);
229
+ sysbus_init_mmio(sbd, &s->container);
230
+
231
+ memory_region_init_io(&s->iomem, OBJECT(s), &cadence_sdhci_ops,
232
+ s, TYPE_CADENCE_SDHCI, CADENCE_SDHCI_REG_SIZE);
233
+ memory_region_add_subregion(&s->container, 0, &s->iomem);
234
+
235
+ sysbus_realize(sbd_sdhci, errp);
236
+ memory_region_add_subregion(&s->container, CADENCE_SDHCI_SRS_BASE,
237
+ sysbus_mmio_get_region(sbd_sdhci, 0));
238
+
239
+ /* propagate irq and "sd-bus" from generic-sdhci */
240
+ sysbus_pass_irq(sbd, sbd_sdhci);
241
+ s->bus = qdev_get_child_bus(DEVICE(sbd_sdhci), "sd-bus");
242
+}
243
+
244
+static const VMStateDescription vmstate_cadence_sdhci = {
245
+ .name = TYPE_CADENCE_SDHCI,
246
+ .version_id = 1,
247
+ .fields = (VMStateField[]) {
248
+ VMSTATE_UINT32_ARRAY(regs, CadenceSDHCIState, CADENCE_SDHCI_NUM_REGS),
249
+ VMSTATE_END_OF_LIST(),
250
+ },
251
+};
252
+
253
+static void cadence_sdhci_class_init(ObjectClass *classp, void *data)
254
+{
255
+ DeviceClass *dc = DEVICE_CLASS(classp);
256
+
257
+ dc->desc = "Cadence SD/SDIO/eMMC Host Controller (SD4HC)";
258
+ dc->realize = cadence_sdhci_realize;
259
+ dc->reset = cadence_sdhci_reset;
260
+ dc->vmsd = &vmstate_cadence_sdhci;
261
+}
262
+
263
+static TypeInfo cadence_sdhci_info = {
264
+ .name = TYPE_CADENCE_SDHCI,
265
+ .parent = TYPE_SYS_BUS_DEVICE,
266
+ .instance_size = sizeof(CadenceSDHCIState),
267
+ .instance_init = cadence_sdhci_instance_init,
268
+ .class_init = cadence_sdhci_class_init,
269
+};
270
+
271
+static void cadence_sdhci_register_types(void)
272
+{
273
+ type_register_static(&cadence_sdhci_info);
274
+}
275
+
276
+type_init(cadence_sdhci_register_types)
277
diff --git a/hw/sd/Kconfig b/hw/sd/Kconfig
278
index XXXXXXX..XXXXXXX 100644
279
--- a/hw/sd/Kconfig
280
+++ b/hw/sd/Kconfig
281
@@ -XXX,XX +XXX,XX @@ config SDHCI_PCI
282
default y if PCI_DEVICES
283
depends on PCI
284
select SDHCI
285
+
286
+config CADENCE_SDHCI
287
+ bool
288
+ select SDHCI
289
diff --git a/hw/sd/meson.build b/hw/sd/meson.build
290
index XXXXXXX..XXXXXXX 100644
291
--- a/hw/sd/meson.build
292
+++ b/hw/sd/meson.build
293
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_PXA2XX', if_true: files('pxa2xx_mmci.c'))
294
softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_sdhost.c'))
295
softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_sdhci.c'))
296
softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-sdhost.c'))
297
+softmmu_ss.add(when: 'CONFIG_CADENCE_SDHCI', if_true: files('cadence_sdhci.c'))
298
--
118
--
299
2.28.0
119
2.31.1
300
120
301
121
diff view generated by jsdifflib
New patch
1
1
From: Richard Henderson <richard.henderson@linaro.org>
2
3
Most shift instructions require a separate implementation
4
for RV32 when TARGET_LONG_BITS == 64.
5
6
Reviewed-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20211020031709.359469-14-richard.henderson@linaro.org
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
12
target/riscv/translate.c | 31 +++++++++
13
target/riscv/insn_trans/trans_rvb.c.inc | 92 ++++++++++++++-----------
14
target/riscv/insn_trans/trans_rvi.c.inc | 26 +++----
15
3 files changed, 97 insertions(+), 52 deletions(-)
16
17
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/target/riscv/translate.c
20
+++ b/target/riscv/translate.c
21
@@ -XXX,XX +XXX,XX @@ static bool gen_shift_imm_fn(DisasContext *ctx, arg_shift *a, DisasExtend ext,
22
return true;
23
}
24
25
+static bool gen_shift_imm_fn_per_ol(DisasContext *ctx, arg_shift *a,
26
+ DisasExtend ext,
27
+ void (*f_tl)(TCGv, TCGv, target_long),
28
+ void (*f_32)(TCGv, TCGv, target_long))
29
+{
30
+ int olen = get_olen(ctx);
31
+ if (olen != TARGET_LONG_BITS) {
32
+ if (olen == 32) {
33
+ f_tl = f_32;
34
+ } else {
35
+ g_assert_not_reached();
36
+ }
37
+ }
38
+ return gen_shift_imm_fn(ctx, a, ext, f_tl);
39
+}
40
+
41
static bool gen_shift_imm_tl(DisasContext *ctx, arg_shift *a, DisasExtend ext,
42
void (*func)(TCGv, TCGv, TCGv))
43
{
44
@@ -XXX,XX +XXX,XX @@ static bool gen_shift(DisasContext *ctx, arg_r *a, DisasExtend ext,
45
return true;
46
}
47
48
+static bool gen_shift_per_ol(DisasContext *ctx, arg_r *a, DisasExtend ext,
49
+ void (*f_tl)(TCGv, TCGv, TCGv),
50
+ void (*f_32)(TCGv, TCGv, TCGv))
51
+{
52
+ int olen = get_olen(ctx);
53
+ if (olen != TARGET_LONG_BITS) {
54
+ if (olen == 32) {
55
+ f_tl = f_32;
56
+ } else {
57
+ g_assert_not_reached();
58
+ }
59
+ }
60
+ return gen_shift(ctx, a, ext, f_tl);
61
+}
62
+
63
static bool gen_unary(DisasContext *ctx, arg_r2 *a, DisasExtend ext,
64
void (*func)(TCGv, TCGv))
65
{
66
diff --git a/target/riscv/insn_trans/trans_rvb.c.inc b/target/riscv/insn_trans/trans_rvb.c.inc
67
index XXXXXXX..XXXXXXX 100644
68
--- a/target/riscv/insn_trans/trans_rvb.c.inc
69
+++ b/target/riscv/insn_trans/trans_rvb.c.inc
70
@@ -XXX,XX +XXX,XX @@ static bool trans_bexti(DisasContext *ctx, arg_bexti *a)
71
return gen_shift_imm_tl(ctx, a, EXT_NONE, gen_bext);
72
}
73
74
+static void gen_rorw(TCGv ret, TCGv arg1, TCGv arg2)
75
+{
76
+ TCGv_i32 t1 = tcg_temp_new_i32();
77
+ TCGv_i32 t2 = tcg_temp_new_i32();
78
+
79
+ /* truncate to 32-bits */
80
+ tcg_gen_trunc_tl_i32(t1, arg1);
81
+ tcg_gen_trunc_tl_i32(t2, arg2);
82
+
83
+ tcg_gen_rotr_i32(t1, t1, t2);
84
+
85
+ /* sign-extend 64-bits */
86
+ tcg_gen_ext_i32_tl(ret, t1);
87
+
88
+ tcg_temp_free_i32(t1);
89
+ tcg_temp_free_i32(t2);
90
+}
91
+
92
static bool trans_ror(DisasContext *ctx, arg_ror *a)
93
{
94
REQUIRE_ZBB(ctx);
95
- return gen_shift(ctx, a, EXT_NONE, tcg_gen_rotr_tl);
96
+ return gen_shift_per_ol(ctx, a, EXT_NONE, tcg_gen_rotr_tl, gen_rorw);
97
+}
98
+
99
+static void gen_roriw(TCGv ret, TCGv arg1, target_long shamt)
100
+{
101
+ TCGv_i32 t1 = tcg_temp_new_i32();
102
+
103
+ tcg_gen_trunc_tl_i32(t1, arg1);
104
+ tcg_gen_rotri_i32(t1, t1, shamt);
105
+ tcg_gen_ext_i32_tl(ret, t1);
106
+
107
+ tcg_temp_free_i32(t1);
108
}
109
110
static bool trans_rori(DisasContext *ctx, arg_rori *a)
111
{
112
REQUIRE_ZBB(ctx);
113
- return gen_shift_imm_fn(ctx, a, EXT_NONE, tcg_gen_rotri_tl);
114
+ return gen_shift_imm_fn_per_ol(ctx, a, EXT_NONE,
115
+ tcg_gen_rotri_tl, gen_roriw);
116
+}
117
+
118
+static void gen_rolw(TCGv ret, TCGv arg1, TCGv arg2)
119
+{
120
+ TCGv_i32 t1 = tcg_temp_new_i32();
121
+ TCGv_i32 t2 = tcg_temp_new_i32();
122
+
123
+ /* truncate to 32-bits */
124
+ tcg_gen_trunc_tl_i32(t1, arg1);
125
+ tcg_gen_trunc_tl_i32(t2, arg2);
126
+
127
+ tcg_gen_rotl_i32(t1, t1, t2);
128
+
129
+ /* sign-extend 64-bits */
130
+ tcg_gen_ext_i32_tl(ret, t1);
131
+
132
+ tcg_temp_free_i32(t1);
133
+ tcg_temp_free_i32(t2);
134
}
135
136
static bool trans_rol(DisasContext *ctx, arg_rol *a)
137
{
138
REQUIRE_ZBB(ctx);
139
- return gen_shift(ctx, a, EXT_NONE, tcg_gen_rotl_tl);
140
+ return gen_shift_per_ol(ctx, a, EXT_NONE, tcg_gen_rotl_tl, gen_rolw);
141
}
142
143
static void gen_rev8_32(TCGv ret, TCGv src1)
144
@@ -XXX,XX +XXX,XX @@ static bool trans_cpopw(DisasContext *ctx, arg_cpopw *a)
145
return gen_unary(ctx, a, EXT_ZERO, tcg_gen_ctpop_tl);
146
}
147
148
-static void gen_rorw(TCGv ret, TCGv arg1, TCGv arg2)
149
-{
150
- TCGv_i32 t1 = tcg_temp_new_i32();
151
- TCGv_i32 t2 = tcg_temp_new_i32();
152
-
153
- /* truncate to 32-bits */
154
- tcg_gen_trunc_tl_i32(t1, arg1);
155
- tcg_gen_trunc_tl_i32(t2, arg2);
156
-
157
- tcg_gen_rotr_i32(t1, t1, t2);
158
-
159
- /* sign-extend 64-bits */
160
- tcg_gen_ext_i32_tl(ret, t1);
161
-
162
- tcg_temp_free_i32(t1);
163
- tcg_temp_free_i32(t2);
164
-}
165
-
166
static bool trans_rorw(DisasContext *ctx, arg_rorw *a)
167
{
168
REQUIRE_64BIT(ctx);
169
@@ -XXX,XX +XXX,XX @@ static bool trans_roriw(DisasContext *ctx, arg_roriw *a)
170
REQUIRE_64BIT(ctx);
171
REQUIRE_ZBB(ctx);
172
ctx->ol = MXL_RV32;
173
- return gen_shift_imm_tl(ctx, a, EXT_NONE, gen_rorw);
174
-}
175
-
176
-static void gen_rolw(TCGv ret, TCGv arg1, TCGv arg2)
177
-{
178
- TCGv_i32 t1 = tcg_temp_new_i32();
179
- TCGv_i32 t2 = tcg_temp_new_i32();
180
-
181
- /* truncate to 32-bits */
182
- tcg_gen_trunc_tl_i32(t1, arg1);
183
- tcg_gen_trunc_tl_i32(t2, arg2);
184
-
185
- tcg_gen_rotl_i32(t1, t1, t2);
186
-
187
- /* sign-extend 64-bits */
188
- tcg_gen_ext_i32_tl(ret, t1);
189
-
190
- tcg_temp_free_i32(t1);
191
- tcg_temp_free_i32(t2);
192
+ return gen_shift_imm_fn(ctx, a, EXT_NONE, gen_roriw);
193
}
194
195
static bool trans_rolw(DisasContext *ctx, arg_rolw *a)
196
diff --git a/target/riscv/insn_trans/trans_rvi.c.inc b/target/riscv/insn_trans/trans_rvi.c.inc
197
index XXXXXXX..XXXXXXX 100644
198
--- a/target/riscv/insn_trans/trans_rvi.c.inc
199
+++ b/target/riscv/insn_trans/trans_rvi.c.inc
200
@@ -XXX,XX +XXX,XX @@ static bool trans_slli(DisasContext *ctx, arg_slli *a)
201
return gen_shift_imm_fn(ctx, a, EXT_NONE, tcg_gen_shli_tl);
202
}
203
204
+static void gen_srliw(TCGv dst, TCGv src, target_long shamt)
205
+{
206
+ tcg_gen_extract_tl(dst, src, shamt, 32 - shamt);
207
+}
208
+
209
static bool trans_srli(DisasContext *ctx, arg_srli *a)
210
{
211
- return gen_shift_imm_fn(ctx, a, EXT_ZERO, tcg_gen_shri_tl);
212
+ return gen_shift_imm_fn_per_ol(ctx, a, EXT_NONE,
213
+ tcg_gen_shri_tl, gen_srliw);
214
+}
215
+
216
+static void gen_sraiw(TCGv dst, TCGv src, target_long shamt)
217
+{
218
+ tcg_gen_sextract_tl(dst, src, shamt, 32 - shamt);
219
}
220
221
static bool trans_srai(DisasContext *ctx, arg_srai *a)
222
{
223
- return gen_shift_imm_fn(ctx, a, EXT_SIGN, tcg_gen_sari_tl);
224
+ return gen_shift_imm_fn_per_ol(ctx, a, EXT_NONE,
225
+ tcg_gen_sari_tl, gen_sraiw);
226
}
227
228
static bool trans_add(DisasContext *ctx, arg_add *a)
229
@@ -XXX,XX +XXX,XX @@ static bool trans_slliw(DisasContext *ctx, arg_slliw *a)
230
return gen_shift_imm_fn(ctx, a, EXT_NONE, tcg_gen_shli_tl);
231
}
232
233
-static void gen_srliw(TCGv dst, TCGv src, target_long shamt)
234
-{
235
- tcg_gen_extract_tl(dst, src, shamt, 32 - shamt);
236
-}
237
-
238
static bool trans_srliw(DisasContext *ctx, arg_srliw *a)
239
{
240
REQUIRE_64BIT(ctx);
241
@@ -XXX,XX +XXX,XX @@ static bool trans_srliw(DisasContext *ctx, arg_srliw *a)
242
return gen_shift_imm_fn(ctx, a, EXT_NONE, gen_srliw);
243
}
244
245
-static void gen_sraiw(TCGv dst, TCGv src, target_long shamt)
246
-{
247
- tcg_gen_sextract_tl(dst, src, shamt, 32 - shamt);
248
-}
249
-
250
static bool trans_sraiw(DisasContext *ctx, arg_sraiw *a)
251
{
252
REQUIRE_64BIT(ctx);
253
--
254
2.31.1
255
256
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
At present the PHY address of the PHY connected to GEM is hard-coded
3
Use the official debug read interface to the csrs,
4
to either 23 (BOARD_PHY_ADDRESS) or 0. This might not be the case for
4
rather than referencing the env slots directly.
5
all boards. Add a new 'phy-addr' property so that board can specify
5
Put the list of csrs to dump into a table.
6
the PHY address for each GEM instance.
7
6
8
Signed-off-by: Bin Meng <bin.meng@windriver.com>
9
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
11
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
12
Message-Id: <1598924352-89526-12-git-send-email-bmeng.cn@gmail.com>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20211020031709.359469-15-richard.henderson@linaro.org
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
14
---
11
---
15
include/hw/net/cadence_gem.h | 2 ++
12
target/riscv/cpu.c | 89 +++++++++++++++++++++++-----------------------
16
hw/net/cadence_gem.c | 5 +++--
13
1 file changed, 45 insertions(+), 44 deletions(-)
17
2 files changed, 5 insertions(+), 2 deletions(-)
18
14
19
diff --git a/include/hw/net/cadence_gem.h b/include/hw/net/cadence_gem.h
15
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
20
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
21
--- a/include/hw/net/cadence_gem.h
17
--- a/target/riscv/cpu.c
22
+++ b/include/hw/net/cadence_gem.h
18
+++ b/target/riscv/cpu.c
23
@@ -XXX,XX +XXX,XX @@ typedef struct CadenceGEMState {
19
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags)
24
/* Mask of register bits which are write 1 to clear */
20
#endif
25
uint32_t regs_w1c[CADENCE_GEM_MAXREG];
21
qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "pc ", env->pc);
26
22
#ifndef CONFIG_USER_ONLY
27
+ /* PHY address */
23
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mhartid ", env->mhartid);
28
+ uint8_t phy_addr;
24
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mstatus ", (target_ulong)env->mstatus);
29
/* PHY registers backing store */
25
- if (riscv_cpu_mxl(env) == MXL_RV32) {
30
uint16_t phy_regs[32];
26
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mstatush ",
31
27
- (target_ulong)(env->mstatus >> 32));
32
diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
28
- }
33
index XXXXXXX..XXXXXXX 100644
29
- if (riscv_has_ext(env, RVH)) {
34
--- a/hw/net/cadence_gem.c
30
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "hstatus ", env->hstatus);
35
+++ b/hw/net/cadence_gem.c
31
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "vsstatus",
36
@@ -XXX,XX +XXX,XX @@ static uint64_t gem_read(void *opaque, hwaddr offset, unsigned size)
32
- (target_ulong)env->vsstatus);
37
uint32_t phy_addr, reg_num;
33
- }
38
34
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mip ", env->mip);
39
phy_addr = (retval & GEM_PHYMNTNC_ADDR) >> GEM_PHYMNTNC_ADDR_SHFT;
35
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mie ", env->mie);
40
- if (phy_addr == BOARD_PHY_ADDRESS || phy_addr == 0) {
36
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mideleg ", env->mideleg);
41
+ if (phy_addr == s->phy_addr || phy_addr == 0) {
37
- if (riscv_has_ext(env, RVH)) {
42
reg_num = (retval & GEM_PHYMNTNC_REG) >> GEM_PHYMNTNC_REG_SHIFT;
38
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "hideleg ", env->hideleg);
43
retval &= 0xFFFF0000;
39
- }
44
retval |= gem_phy_read(s, reg_num);
40
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "medeleg ", env->medeleg);
45
@@ -XXX,XX +XXX,XX @@ static void gem_write(void *opaque, hwaddr offset, uint64_t val,
41
- if (riscv_has_ext(env, RVH)) {
46
uint32_t phy_addr, reg_num;
42
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "hedeleg ", env->hedeleg);
47
43
- }
48
phy_addr = (val & GEM_PHYMNTNC_ADDR) >> GEM_PHYMNTNC_ADDR_SHFT;
44
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtvec ", env->mtvec);
49
- if (phy_addr == BOARD_PHY_ADDRESS || phy_addr == 0) {
45
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "stvec ", env->stvec);
50
+ if (phy_addr == s->phy_addr || phy_addr == 0) {
46
- if (riscv_has_ext(env, RVH)) {
51
reg_num = (val & GEM_PHYMNTNC_REG) >> GEM_PHYMNTNC_REG_SHIFT;
47
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "vstvec ", env->vstvec);
52
gem_phy_write(s, reg_num, val);
48
- }
53
}
49
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mepc ", env->mepc);
54
@@ -XXX,XX +XXX,XX @@ static Property gem_properties[] = {
50
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "sepc ", env->sepc);
55
DEFINE_NIC_PROPERTIES(CadenceGEMState, conf),
51
- if (riscv_has_ext(env, RVH)) {
56
DEFINE_PROP_UINT32("revision", CadenceGEMState, revision,
52
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "vsepc ", env->vsepc);
57
GEM_MODID_VALUE),
53
- }
58
+ DEFINE_PROP_UINT8("phy-addr", CadenceGEMState, phy_addr, BOARD_PHY_ADDRESS),
54
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mcause ", env->mcause);
59
DEFINE_PROP_UINT8("num-priority-queues", CadenceGEMState,
55
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "scause ", env->scause);
60
num_priority_queues, 1),
56
- if (riscv_has_ext(env, RVH)) {
61
DEFINE_PROP_UINT8("num-type1-screeners", CadenceGEMState,
57
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "vscause ", env->vscause);
58
- }
59
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtval ", env->mtval);
60
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "stval ", env->stval);
61
- if (riscv_has_ext(env, RVH)) {
62
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "htval ", env->htval);
63
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtval2 ", env->mtval2);
64
+ {
65
+ static const int dump_csrs[] = {
66
+ CSR_MHARTID,
67
+ CSR_MSTATUS,
68
+ CSR_MSTATUSH,
69
+ CSR_HSTATUS,
70
+ CSR_VSSTATUS,
71
+ CSR_MIP,
72
+ CSR_MIE,
73
+ CSR_MIDELEG,
74
+ CSR_HIDELEG,
75
+ CSR_MEDELEG,
76
+ CSR_HEDELEG,
77
+ CSR_MTVEC,
78
+ CSR_STVEC,
79
+ CSR_VSTVEC,
80
+ CSR_MEPC,
81
+ CSR_SEPC,
82
+ CSR_VSEPC,
83
+ CSR_MCAUSE,
84
+ CSR_SCAUSE,
85
+ CSR_VSCAUSE,
86
+ CSR_MTVAL,
87
+ CSR_STVAL,
88
+ CSR_HTVAL,
89
+ CSR_MTVAL2,
90
+ CSR_MSCRATCH,
91
+ CSR_SSCRATCH,
92
+ CSR_SATP,
93
+ };
94
+
95
+ for (int i = 0; i < ARRAY_SIZE(dump_csrs); ++i) {
96
+ int csrno = dump_csrs[i];
97
+ target_ulong val = 0;
98
+ RISCVException res = riscv_csrrw_debug(env, csrno, &val, 0, 0);
99
+
100
+ /*
101
+ * Rely on the smode, hmode, etc, predicates within csr.c
102
+ * to do the filtering of the registers that are present.
103
+ */
104
+ if (res == RISCV_EXCP_NONE) {
105
+ qemu_fprintf(f, " %-8s " TARGET_FMT_lx "\n",
106
+ csr_ops[csrno].name, val);
107
+ }
108
+ }
109
}
110
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mscratch", env->mscratch);
111
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "sscratch", env->sscratch);
112
- qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "satp ", env->satp);
113
#endif
114
115
for (i = 0; i < 32; i++) {
62
--
116
--
63
2.28.0
117
2.31.1
64
118
65
119
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Microchip PolarFire SoC integrates one Cadence SDHCI controller.
3
The position of this read-only field is dependent on the current xlen.
4
On the Icicle Kit board, one eMMC chip and an external SD card
4
Rather than having to compute that difference in many places, compute
5
connect to this controller depending on different configuration.
5
it only on read.
6
6
7
As QEMU does not support eMMC yet, we just emulate the SD card
8
configuration. To test this, the Hart Software Services (HSS)
9
should choose the SD card configuration:
10
11
$ cp boards/icicle-kit-es/def_config.sdcard .config
12
$ make BOARD=icicle-kit-es
13
14
The SD card image can be built from the Yocto BSP at:
15
https://github.com/polarfire-soc/meta-polarfire-soc-yocto-bsp
16
17
Note the generated SD card image should be resized before use:
18
$ qemu-img resize /path/to/sdcard.img 4G
19
20
Launch QEMU with the following command:
21
$ qemu-system-riscv64 -nographic -M microchip-icicle-kit -sd sdcard.img
22
23
Signed-off-by: Bin Meng <bin.meng@windriver.com>
24
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
25
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
26
Message-Id: <1598924352-89526-9-git-send-email-bmeng.cn@gmail.com>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20211020031709.359469-16-richard.henderson@linaro.org
27
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
28
---
11
---
29
include/hw/riscv/microchip_pfsoc.h | 4 ++++
12
target/riscv/cpu_helper.c | 3 +--
30
hw/riscv/microchip_pfsoc.c | 23 +++++++++++++++++++++++
13
target/riscv/csr.c | 37 ++++++++++++++++++++++---------------
31
hw/riscv/Kconfig | 1 +
14
target/riscv/translate.c | 5 ++---
32
3 files changed, 28 insertions(+)
15
3 files changed, 25 insertions(+), 20 deletions(-)
33
16
34
diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchip_pfsoc.h
17
diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
35
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
36
--- a/include/hw/riscv/microchip_pfsoc.h
19
--- a/target/riscv/cpu_helper.c
37
+++ b/include/hw/riscv/microchip_pfsoc.h
20
+++ b/target/riscv/cpu_helper.c
38
@@ -XXX,XX +XXX,XX @@
21
@@ -XXX,XX +XXX,XX @@ bool riscv_cpu_fp_enabled(CPURISCVState *env)
39
#define HW_MICROCHIP_PFSOC_H
22
40
23
void riscv_cpu_swap_hypervisor_regs(CPURISCVState *env)
41
#include "hw/char/mchp_pfsoc_mmuart.h"
24
{
42
+#include "hw/sd/cadence_sdhci.h"
25
- uint64_t sd = riscv_cpu_mxl(env) == MXL_RV32 ? MSTATUS32_SD : MSTATUS64_SD;
43
26
uint64_t mstatus_mask = MSTATUS_MXR | MSTATUS_SUM | MSTATUS_FS |
44
typedef struct MicrochipPFSoCState {
27
MSTATUS_SPP | MSTATUS_SPIE | MSTATUS_SIE |
45
/*< private >*/
28
- MSTATUS64_UXL | sd;
46
@@ -XXX,XX +XXX,XX @@ typedef struct MicrochipPFSoCState {
29
+ MSTATUS64_UXL;
47
MchpPfSoCMMUartState *serial2;
30
bool current_virt = riscv_cpu_virt_enabled(env);
48
MchpPfSoCMMUartState *serial3;
31
49
MchpPfSoCMMUartState *serial4;
32
g_assert(riscv_has_ext(env, RVH));
50
+ CadenceSDHCIState sdhci;
33
diff --git a/target/riscv/csr.c b/target/riscv/csr.c
51
} MicrochipPFSoCState;
52
53
#define TYPE_MICROCHIP_PFSOC "microchip.pfsoc"
54
@@ -XXX,XX +XXX,XX @@ enum {
55
MICROCHIP_PFSOC_MMUART0,
56
MICROCHIP_PFSOC_SYSREG,
57
MICROCHIP_PFSOC_MPUCFG,
58
+ MICROCHIP_PFSOC_EMMC_SD,
59
MICROCHIP_PFSOC_MMUART1,
60
MICROCHIP_PFSOC_MMUART2,
61
MICROCHIP_PFSOC_MMUART3,
62
@@ -XXX,XX +XXX,XX @@ enum {
63
};
64
65
enum {
66
+ MICROCHIP_PFSOC_EMMC_SD_IRQ = 88,
67
MICROCHIP_PFSOC_MMUART0_IRQ = 90,
68
MICROCHIP_PFSOC_MMUART1_IRQ = 91,
69
MICROCHIP_PFSOC_MMUART2_IRQ = 92,
70
diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c
71
index XXXXXXX..XXXXXXX 100644
34
index XXXXXXX..XXXXXXX 100644
72
--- a/hw/riscv/microchip_pfsoc.c
35
--- a/target/riscv/csr.c
73
+++ b/hw/riscv/microchip_pfsoc.c
36
+++ b/target/riscv/csr.c
74
@@ -XXX,XX +XXX,XX @@
37
@@ -XXX,XX +XXX,XX @@ static RISCVException read_mhartid(CPURISCVState *env, int csrno,
75
* 1) PLIC (Platform Level Interrupt Controller)
38
}
76
* 2) eNVM (Embedded Non-Volatile Memory)
39
77
* 3) MMUARTs (Multi-Mode UART)
40
/* Machine Trap Setup */
78
+ * 4) Cadence eMMC/SDHC controller and an SD card connected to it
79
*
80
* This board currently generates devicetree dynamically that indicates at least
81
* two harts and up to five harts.
82
@@ -XXX,XX +XXX,XX @@ static const struct MemmapEntry {
83
[MICROCHIP_PFSOC_MMUART0] = { 0x20000000, 0x1000 },
84
[MICROCHIP_PFSOC_SYSREG] = { 0x20002000, 0x2000 },
85
[MICROCHIP_PFSOC_MPUCFG] = { 0x20005000, 0x1000 },
86
+ [MICROCHIP_PFSOC_EMMC_SD] = { 0x20008000, 0x1000 },
87
[MICROCHIP_PFSOC_MMUART1] = { 0x20100000, 0x1000 },
88
[MICROCHIP_PFSOC_MMUART2] = { 0x20102000, 0x1000 },
89
[MICROCHIP_PFSOC_MMUART3] = { 0x20104000, 0x1000 },
90
@@ -XXX,XX +XXX,XX @@ static void microchip_pfsoc_soc_instance_init(Object *obj)
91
qdev_prop_set_string(DEVICE(&s->u_cpus), "cpu-type",
92
TYPE_RISCV_CPU_SIFIVE_U54);
93
qdev_prop_set_uint64(DEVICE(&s->u_cpus), "resetvec", RESET_VECTOR);
94
+
41
+
95
+ object_initialize_child(obj, "sd-controller", &s->sdhci,
42
+/* We do not store SD explicitly, only compute it on demand. */
96
+ TYPE_CADENCE_SDHCI);
43
+static uint64_t add_status_sd(RISCVMXL xl, uint64_t status)
44
+{
45
+ if ((status & MSTATUS_FS) == MSTATUS_FS ||
46
+ (status & MSTATUS_XS) == MSTATUS_XS) {
47
+ switch (xl) {
48
+ case MXL_RV32:
49
+ return status | MSTATUS32_SD;
50
+ case MXL_RV64:
51
+ return status | MSTATUS64_SD;
52
+ default:
53
+ g_assert_not_reached();
54
+ }
55
+ }
56
+ return status;
57
+}
58
+
59
static RISCVException read_mstatus(CPURISCVState *env, int csrno,
60
target_ulong *val)
61
{
62
- *val = env->mstatus;
63
+ *val = add_status_sd(riscv_cpu_mxl(env), env->mstatus);
64
return RISCV_EXCP_NONE;
97
}
65
}
98
66
99
static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp)
67
@@ -XXX,XX +XXX,XX @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno,
100
@@ -XXX,XX +XXX,XX @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp)
68
{
101
memmap[MICROCHIP_PFSOC_MPUCFG].base,
69
uint64_t mstatus = env->mstatus;
102
memmap[MICROCHIP_PFSOC_MPUCFG].size);
70
uint64_t mask = 0;
103
71
- int dirty;
104
+ /* SDHCI */
72
105
+ sysbus_realize(SYS_BUS_DEVICE(&s->sdhci), errp);
73
/* flush tlb on mstatus fields that affect VM */
106
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdhci), 0,
74
if ((val ^ mstatus) & (MSTATUS_MXR | MSTATUS_MPP | MSTATUS_MPV |
107
+ memmap[MICROCHIP_PFSOC_EMMC_SD].base);
75
@@ -XXX,XX +XXX,XX @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno,
108
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci), 0,
76
109
+ qdev_get_gpio_in(DEVICE(s->plic), MICROCHIP_PFSOC_EMMC_SD_IRQ));
77
mstatus = (mstatus & ~mask) | (val & mask);
110
+
78
111
/* MMUARTs */
79
- dirty = ((mstatus & MSTATUS_FS) == MSTATUS_FS) |
112
s->serial0 = mchp_pfsoc_mmuart_create(system_memory,
80
- ((mstatus & MSTATUS_XS) == MSTATUS_XS);
113
memmap[MICROCHIP_PFSOC_MMUART0].base,
81
- if (riscv_cpu_mxl(env) == MXL_RV32) {
114
@@ -XXX,XX +XXX,XX @@ static void microchip_icicle_kit_machine_init(MachineState *machine)
82
- mstatus = set_field(mstatus, MSTATUS32_SD, dirty);
115
MicrochipIcicleKitState *s = MICROCHIP_ICICLE_KIT_MACHINE(machine);
83
- } else {
116
MemoryRegion *system_memory = get_system_memory();
84
- mstatus = set_field(mstatus, MSTATUS64_SD, dirty);
117
MemoryRegion *main_mem = g_new(MemoryRegion, 1);
85
+ if (riscv_cpu_mxl(env) == MXL_RV64) {
118
+ DriveInfo *dinfo = drive_get_next(IF_SD);
86
/* SXL and UXL fields are for now read only */
119
87
mstatus = set_field(mstatus, MSTATUS64_SXL, MXL_RV64);
120
/* Sanity check on RAM size */
88
mstatus = set_field(mstatus, MSTATUS64_UXL, MXL_RV64);
121
if (machine->ram_size < mc->default_ram_size) {
89
@@ -XXX,XX +XXX,XX @@ static RISCVException read_sstatus(CPURISCVState *env, int csrno,
122
@@ -XXX,XX +XXX,XX @@ static void microchip_icicle_kit_machine_init(MachineState *machine)
90
{
123
91
target_ulong mask = (sstatus_v1_10_mask);
124
/* Load the firmware */
92
125
riscv_find_and_load_firmware(machine, BIOS_FILENAME, RESET_VECTOR, NULL);
93
- if (riscv_cpu_mxl(env) == MXL_RV32) {
126
+
94
- mask |= SSTATUS32_SD;
127
+ /* Attach an SD card */
95
- } else {
128
+ if (dinfo) {
96
- mask |= SSTATUS64_SD;
129
+ CadenceSDHCIState *sdhci = &(s->soc.sdhci);
97
- }
130
+ DeviceState *card = qdev_new(TYPE_SD_CARD);
98
-
131
+
99
- *val = env->mstatus & mask;
132
+ qdev_prop_set_drive_err(card, "drive", blk_by_legacy_dinfo(dinfo),
100
+ /* TODO: Use SXL not MXL. */
133
+ &error_fatal);
101
+ *val = add_status_sd(riscv_cpu_mxl(env), env->mstatus & mask);
134
+ qdev_realize_and_unref(card, sdhci->bus, &error_fatal);
102
return RISCV_EXCP_NONE;
135
+ }
136
}
103
}
137
104
138
static void microchip_icicle_kit_machine_class_init(ObjectClass *oc, void *data)
105
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
139
diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
140
index XXXXXXX..XXXXXXX 100644
106
index XXXXXXX..XXXXXXX 100644
141
--- a/hw/riscv/Kconfig
107
--- a/target/riscv/translate.c
142
+++ b/hw/riscv/Kconfig
108
+++ b/target/riscv/translate.c
143
@@ -XXX,XX +XXX,XX @@ config MICROCHIP_PFSOC
109
@@ -XXX,XX +XXX,XX @@ static void gen_jal(DisasContext *ctx, int rd, target_ulong imm)
144
select SIFIVE
110
static void mark_fs_dirty(DisasContext *ctx)
145
select UNIMP
111
{
146
select MCHP_PFSOC_MMUART
112
TCGv tmp;
147
+ select CADENCE_SDHCI
113
- target_ulong sd = get_xl(ctx) == MXL_RV32 ? MSTATUS32_SD : MSTATUS64_SD;
114
115
if (ctx->mstatus_fs != MSTATUS_FS) {
116
/* Remember the state change for the rest of the TB. */
117
@@ -XXX,XX +XXX,XX @@ static void mark_fs_dirty(DisasContext *ctx)
118
119
tmp = tcg_temp_new();
120
tcg_gen_ld_tl(tmp, cpu_env, offsetof(CPURISCVState, mstatus));
121
- tcg_gen_ori_tl(tmp, tmp, MSTATUS_FS | sd);
122
+ tcg_gen_ori_tl(tmp, tmp, MSTATUS_FS);
123
tcg_gen_st_tl(tmp, cpu_env, offsetof(CPURISCVState, mstatus));
124
tcg_temp_free(tmp);
125
}
126
@@ -XXX,XX +XXX,XX @@ static void mark_fs_dirty(DisasContext *ctx)
127
128
tmp = tcg_temp_new();
129
tcg_gen_ld_tl(tmp, cpu_env, offsetof(CPURISCVState, mstatus_hs));
130
- tcg_gen_ori_tl(tmp, tmp, MSTATUS_FS | sd);
131
+ tcg_gen_ori_tl(tmp, tmp, MSTATUS_FS);
132
tcg_gen_st_tl(tmp, cpu_env, offsetof(CPURISCVState, mstatus_hs));
133
tcg_temp_free(tmp);
134
}
148
--
135
--
149
2.28.0
136
2.31.1
150
137
151
138
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Alistair Francis <alistair.francis@wdc.com>
2
2
3
On the Icicle Kit board, the HSS firmware utilizes the on-chip DMA
3
Update the OpenTitan machine model to match the latest OpenTitan FPGA
4
controller to move the 2nd stage bootloader in the system memory.
4
design.
5
Let's connect a DMA controller to Microchip PolarFire SoC.
6
5
7
Signed-off-by: Bin Meng <bin.meng@windriver.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-Id: <1598924352-89526-11-git-send-email-bmeng.cn@gmail.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
6
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
7
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
8
Message-id: 18b1b681b0f8dd2461e819d1217bf0b530812680.1634524691.git.alistair.francis@wdc.com
11
---
9
---
12
include/hw/riscv/microchip_pfsoc.h | 11 +++++++++++
10
include/hw/riscv/opentitan.h | 6 +++---
13
hw/riscv/microchip_pfsoc.c | 15 +++++++++++++++
11
hw/riscv/opentitan.c | 22 +++++++++++++++++-----
14
hw/riscv/Kconfig | 1 +
12
2 files changed, 20 insertions(+), 8 deletions(-)
15
3 files changed, 27 insertions(+)
16
13
17
diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchip_pfsoc.h
14
diff --git a/include/hw/riscv/opentitan.h b/include/hw/riscv/opentitan.h
18
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/riscv/microchip_pfsoc.h
16
--- a/include/hw/riscv/opentitan.h
20
+++ b/include/hw/riscv/microchip_pfsoc.h
17
+++ b/include/hw/riscv/opentitan.h
21
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@
22
#define HW_MICROCHIP_PFSOC_H
19
#define HW_OPENTITAN_H
23
20
24
#include "hw/char/mchp_pfsoc_mmuart.h"
21
#include "hw/riscv/riscv_hart.h"
25
+#include "hw/dma/sifive_pdma.h"
22
-#include "hw/intc/ibex_plic.h"
26
#include "hw/sd/cadence_sdhci.h"
23
+#include "hw/intc/sifive_plic.h"
27
24
#include "hw/char/ibex_uart.h"
28
typedef struct MicrochipPFSoCState {
25
#include "hw/timer/ibex_timer.h"
29
@@ -XXX,XX +XXX,XX @@ typedef struct MicrochipPFSoCState {
26
#include "qom/object.h"
30
MchpPfSoCMMUartState *serial2;
27
@@ -XXX,XX +XXX,XX @@ struct LowRISCIbexSoCState {
31
MchpPfSoCMMUartState *serial3;
28
32
MchpPfSoCMMUartState *serial4;
29
/*< public >*/
33
+ SiFivePDMAState dma;
30
RISCVHartArrayState cpus;
34
CadenceSDHCIState sdhci;
31
- IbexPlicState plic;
35
} MicrochipPFSoCState;
32
+ SiFivePLICState plic;
36
33
IbexUartState uart;
37
@@ -XXX,XX +XXX,XX @@ enum {
34
IbexTimerState timer;
38
MICROCHIP_PFSOC_BUSERR_UNIT4,
35
39
MICROCHIP_PFSOC_CLINT,
40
MICROCHIP_PFSOC_L2CC,
41
+ MICROCHIP_PFSOC_DMA,
42
MICROCHIP_PFSOC_L2LIM,
43
MICROCHIP_PFSOC_PLIC,
44
MICROCHIP_PFSOC_MMUART0,
45
@@ -XXX,XX +XXX,XX @@ enum {
36
@@ -XXX,XX +XXX,XX @@ enum {
46
};
37
};
47
38
48
enum {
39
enum {
49
+ MICROCHIP_PFSOC_DMA_IRQ0 = 5,
40
- IBEX_TIMER_TIMEREXPIRED0_0 = 125,
50
+ MICROCHIP_PFSOC_DMA_IRQ1 = 6,
41
+ IBEX_TIMER_TIMEREXPIRED0_0 = 126,
51
+ MICROCHIP_PFSOC_DMA_IRQ2 = 7,
42
IBEX_UART0_RX_PARITY_ERR_IRQ = 8,
52
+ MICROCHIP_PFSOC_DMA_IRQ3 = 8,
43
IBEX_UART0_RX_TIMEOUT_IRQ = 7,
53
+ MICROCHIP_PFSOC_DMA_IRQ4 = 9,
44
IBEX_UART0_RX_BREAK_ERR_IRQ = 6,
54
+ MICROCHIP_PFSOC_DMA_IRQ5 = 10,
45
diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c
55
+ MICROCHIP_PFSOC_DMA_IRQ6 = 11,
56
+ MICROCHIP_PFSOC_DMA_IRQ7 = 12,
57
MICROCHIP_PFSOC_EMMC_SD_IRQ = 88,
58
MICROCHIP_PFSOC_MMUART0_IRQ = 90,
59
MICROCHIP_PFSOC_MMUART1_IRQ = 91,
60
diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c
61
index XXXXXXX..XXXXXXX 100644
46
index XXXXXXX..XXXXXXX 100644
62
--- a/hw/riscv/microchip_pfsoc.c
47
--- a/hw/riscv/opentitan.c
63
+++ b/hw/riscv/microchip_pfsoc.c
48
+++ b/hw/riscv/opentitan.c
64
@@ -XXX,XX +XXX,XX @@
49
@@ -XXX,XX +XXX,XX @@ static const MemMapEntry ibex_memmap[] = {
65
* 2) eNVM (Embedded Non-Volatile Memory)
50
[IBEX_DEV_PINMUX] = { 0x40460000, 0x1000 },
66
* 3) MMUARTs (Multi-Mode UART)
51
[IBEX_DEV_PADCTRL] = { 0x40470000, 0x1000 },
67
* 4) Cadence eMMC/SDHC controller and an SD card connected to it
52
[IBEX_DEV_FLASH_CTRL] = { 0x41000000, 0x1000 },
68
+ * 5) SiFive Platform DMA (Direct Memory Access Controller)
53
- [IBEX_DEV_PLIC] = { 0x41010000, 0x1000 },
69
*
54
[IBEX_DEV_AES] = { 0x41100000, 0x1000 },
70
* This board currently generates devicetree dynamically that indicates at least
55
[IBEX_DEV_HMAC] = { 0x41110000, 0x1000 },
71
* two harts and up to five harts.
56
[IBEX_DEV_KMAC] = { 0x41120000, 0x1000 },
72
@@ -XXX,XX +XXX,XX @@ static const struct MemmapEntry {
57
- [IBEX_DEV_KEYMGR] = { 0x41130000, 0x1000 },
73
[MICROCHIP_PFSOC_BUSERR_UNIT4] = { 0x1704000, 0x1000 },
58
+ [IBEX_DEV_OTBN] = { 0x41130000, 0x10000 },
74
[MICROCHIP_PFSOC_CLINT] = { 0x2000000, 0x10000 },
59
+ [IBEX_DEV_KEYMGR] = { 0x41140000, 0x1000 },
75
[MICROCHIP_PFSOC_L2CC] = { 0x2010000, 0x1000 },
60
[IBEX_DEV_CSRNG] = { 0x41150000, 0x1000 },
76
+ [MICROCHIP_PFSOC_DMA] = { 0x3000000, 0x100000 },
61
[IBEX_DEV_ENTROPY] = { 0x41160000, 0x1000 },
77
[MICROCHIP_PFSOC_L2LIM] = { 0x8000000, 0x2000000 },
62
[IBEX_DEV_EDNO] = { 0x41170000, 0x1000 },
78
[MICROCHIP_PFSOC_PLIC] = { 0xc000000, 0x4000000 },
63
[IBEX_DEV_EDN1] = { 0x41180000, 0x1000 },
79
[MICROCHIP_PFSOC_MMUART0] = { 0x20000000, 0x1000 },
64
[IBEX_DEV_ALERT_HANDLER] = { 0x411b0000, 0x1000 },
80
@@ -XXX,XX +XXX,XX @@ static void microchip_pfsoc_soc_instance_init(Object *obj)
65
[IBEX_DEV_NMI_GEN] = { 0x411c0000, 0x1000 },
81
TYPE_RISCV_CPU_SIFIVE_U54);
66
- [IBEX_DEV_OTBN] = { 0x411d0000, 0x10000 },
82
qdev_prop_set_uint64(DEVICE(&s->u_cpus), "resetvec", RESET_VECTOR);
67
[IBEX_DEV_PERI] = { 0x411f0000, 0x10000 },
83
68
+ [IBEX_DEV_PLIC] = { 0x48000000, 0x4005000 },
84
+ object_initialize_child(obj, "dma-controller", &s->dma,
69
[IBEX_DEV_FLASH_VIRTUAL] = { 0x80000000, 0x80000 },
85
+ TYPE_SIFIVE_PDMA);
70
};
71
72
@@ -XXX,XX +XXX,XX @@ static void lowrisc_ibex_soc_init(Object *obj)
73
74
object_initialize_child(obj, "cpus", &s->cpus, TYPE_RISCV_HART_ARRAY);
75
76
- object_initialize_child(obj, "plic", &s->plic, TYPE_IBEX_PLIC);
77
+ object_initialize_child(obj, "plic", &s->plic, TYPE_SIFIVE_PLIC);
78
79
object_initialize_child(obj, "uart", &s->uart, TYPE_IBEX_UART);
80
81
@@ -XXX,XX +XXX,XX @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **errp)
82
&s->flash_alias);
83
84
/* PLIC */
85
+ qdev_prop_set_string(DEVICE(&s->plic), "hart-config", "M");
86
+ qdev_prop_set_uint32(DEVICE(&s->plic), "hartid-base", 0);
87
+ qdev_prop_set_uint32(DEVICE(&s->plic), "num-sources", 180);
88
+ qdev_prop_set_uint32(DEVICE(&s->plic), "num-priorities", 3);
89
+ qdev_prop_set_uint32(DEVICE(&s->plic), "priority-base", 0x00);
90
+ qdev_prop_set_uint32(DEVICE(&s->plic), "pending-base", 0x1000);
91
+ qdev_prop_set_uint32(DEVICE(&s->plic), "enable-base", 0x2000);
92
+ qdev_prop_set_uint32(DEVICE(&s->plic), "enable-stride", 0x18);
93
+ qdev_prop_set_uint32(DEVICE(&s->plic), "context-base", 0x200004);
94
+ qdev_prop_set_uint32(DEVICE(&s->plic), "context-stride", 4);
95
+ qdev_prop_set_uint32(DEVICE(&s->plic), "aperture-size", memmap[IBEX_DEV_PLIC].size);
86
+
96
+
87
object_initialize_child(obj, "sd-controller", &s->sdhci,
97
if (!sysbus_realize(SYS_BUS_DEVICE(&s->plic), errp)) {
88
TYPE_CADENCE_SDHCI);
98
return;
89
}
99
}
90
@@ -XXX,XX +XXX,XX @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp)
100
@@ -XXX,XX +XXX,XX @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **errp)
91
memmap[MICROCHIP_PFSOC_PLIC].size);
101
for (i = 0; i < ms->smp.cpus; i++) {
92
g_free(plic_hart_config);
102
CPUState *cpu = qemu_get_cpu(i);
93
103
94
+ /* DMA */
104
- qdev_connect_gpio_out(DEVICE(&s->plic), i,
95
+ sysbus_realize(SYS_BUS_DEVICE(&s->dma), errp);
105
+ qdev_connect_gpio_out(DEVICE(&s->plic), ms->smp.cpus + i,
96
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->dma), 0,
106
qdev_get_gpio_in(DEVICE(cpu), IRQ_M_EXT));
97
+ memmap[MICROCHIP_PFSOC_DMA].base);
107
}
98
+ for (i = 0; i < SIFIVE_PDMA_IRQS; i++) {
108
99
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->dma), i,
100
+ qdev_get_gpio_in(DEVICE(s->plic),
101
+ MICROCHIP_PFSOC_DMA_IRQ0 + i));
102
+ }
103
+
104
/* SYSREG */
105
create_unimplemented_device("microchip.pfsoc.sysreg",
106
memmap[MICROCHIP_PFSOC_SYSREG].base,
107
diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
108
index XXXXXXX..XXXXXXX 100644
109
--- a/hw/riscv/Kconfig
110
+++ b/hw/riscv/Kconfig
111
@@ -XXX,XX +XXX,XX @@ config MICROCHIP_PFSOC
112
select SIFIVE
113
select UNIMP
114
select MCHP_PFSOC_MMUART
115
+ select SIFIVE_PDMA
116
select CADENCE_SDHCI
117
--
109
--
118
2.28.0
110
2.31.1
119
111
120
112
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Alistair Francis <alistair.francis@wdc.com>
2
2
3
This is an effort to clean up the hw/riscv directory. Ideally it
3
The Ibex PLIC is now spec compliant. Let's remove the Ibex PLIC and
4
should only contain the RISC-V SoC / machine codes plus generic
4
instead use the SiFive PLIC.
5
codes. Let's move sifive_plic model to hw/intc directory.
5
6
7
Signed-off-by: Bin Meng <bin.meng@windriver.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-Id: <1599129623-68957-7-git-send-email-bmeng.cn@gmail.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
6
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
7
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
8
Message-id: 5557935c2660c5e6281b6d21e6514e019593662e.1634524691.git.alistair.francis@wdc.com
11
---
9
---
12
{include/hw/riscv => hw/intc}/sifive_plic.h | 0
10
hw/intc/ibex_plic.c | 307 --------------------------------------------
13
hw/{riscv => intc}/sifive_plic.c | 2 +-
11
hw/intc/meson.build | 1 -
14
hw/riscv/microchip_pfsoc.c | 2 +-
12
2 files changed, 308 deletions(-)
15
hw/riscv/sifive_e.c | 2 +-
13
delete mode 100644 hw/intc/ibex_plic.c
16
hw/riscv/sifive_u.c | 2 +-
14
17
hw/riscv/virt.c | 2 +-
15
diff --git a/hw/intc/ibex_plic.c b/hw/intc/ibex_plic.c
18
hw/intc/Kconfig | 3 +++
16
deleted file mode 100644
19
hw/intc/meson.build | 1 +
17
index XXXXXXX..XXXXXXX
20
hw/riscv/Kconfig | 5 +++++
18
--- a/hw/intc/ibex_plic.c
21
hw/riscv/meson.build | 1 -
19
+++ /dev/null
22
10 files changed, 14 insertions(+), 6 deletions(-)
23
rename {include/hw/riscv => hw/intc}/sifive_plic.h (100%)
24
rename hw/{riscv => intc}/sifive_plic.c (99%)
25
26
diff --git a/include/hw/riscv/sifive_plic.h b/hw/intc/sifive_plic.h
27
similarity index 100%
28
rename from include/hw/riscv/sifive_plic.h
29
rename to hw/intc/sifive_plic.h
30
diff --git a/hw/riscv/sifive_plic.c b/hw/intc/sifive_plic.c
31
similarity index 99%
32
rename from hw/riscv/sifive_plic.c
33
rename to hw/intc/sifive_plic.c
34
index XXXXXXX..XXXXXXX 100644
35
--- a/hw/riscv/sifive_plic.c
36
+++ b/hw/intc/sifive_plic.c
37
@@ -XXX,XX +XXX,XX @@
20
@@ -XXX,XX +XXX,XX @@
38
#include "hw/pci/msi.h"
21
-/*
39
#include "hw/boards.h"
22
- * QEMU RISC-V lowRISC Ibex PLIC
40
#include "hw/qdev-properties.h"
23
- *
41
+#include "hw/intc/sifive_plic.h"
24
- * Copyright (c) 2020 Western Digital
42
#include "target/riscv/cpu.h"
25
- *
43
#include "sysemu/sysemu.h"
26
- * Documentation avaliable: https://docs.opentitan.org/hw/ip/rv_plic/doc/
44
-#include "hw/riscv/sifive_plic.h"
27
- *
45
28
- * This program is free software; you can redistribute it and/or modify it
46
#define RISCV_DEBUG_PLIC 0
29
- * under the terms and conditions of the GNU General Public License,
47
30
- * version 2 or later, as published by the Free Software Foundation.
48
diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c
31
- *
49
index XXXXXXX..XXXXXXX 100644
32
- * This program is distributed in the hope it will be useful, but WITHOUT
50
--- a/hw/riscv/microchip_pfsoc.c
33
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
51
+++ b/hw/riscv/microchip_pfsoc.c
34
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
52
@@ -XXX,XX +XXX,XX @@
35
- * more details.
53
#include "hw/misc/unimp.h"
36
- *
54
#include "hw/riscv/boot.h"
37
- * You should have received a copy of the GNU General Public License along with
55
#include "hw/riscv/riscv_hart.h"
38
- * this program. If not, see <http://www.gnu.org/licenses/>.
56
-#include "hw/riscv/sifive_plic.h"
39
- */
57
#include "hw/riscv/microchip_pfsoc.h"
40
-
58
#include "hw/intc/sifive_clint.h"
41
-#include "qemu/osdep.h"
59
+#include "hw/intc/sifive_plic.h"
42
-#include "qemu/log.h"
60
#include "sysemu/sysemu.h"
43
-#include "hw/qdev-properties.h"
61
44
-#include "hw/core/cpu.h"
62
/*
45
-#include "hw/boards.h"
63
diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c
46
-#include "hw/pci/msi.h"
64
index XXXXXXX..XXXXXXX 100644
47
-#include "target/riscv/cpu_bits.h"
65
--- a/hw/riscv/sifive_e.c
48
-#include "target/riscv/cpu.h"
66
+++ b/hw/riscv/sifive_e.c
49
-#include "hw/intc/ibex_plic.h"
67
@@ -XXX,XX +XXX,XX @@
50
-#include "hw/irq.h"
68
#include "hw/misc/unimp.h"
51
-
69
#include "target/riscv/cpu.h"
52
-static bool addr_between(uint32_t addr, uint32_t base, uint32_t num)
70
#include "hw/riscv/riscv_hart.h"
53
-{
71
-#include "hw/riscv/sifive_plic.h"
54
- uint32_t end = base + (num * 0x04);
72
#include "hw/riscv/sifive_uart.h"
55
-
73
#include "hw/riscv/sifive_e.h"
56
- if (addr >= base && addr < end) {
74
#include "hw/riscv/boot.h"
57
- return true;
75
#include "hw/intc/sifive_clint.h"
58
- }
76
+#include "hw/intc/sifive_plic.h"
59
-
77
#include "hw/misc/sifive_e_prci.h"
60
- return false;
78
#include "chardev/char.h"
61
-}
79
#include "sysemu/arch_init.h"
62
-
80
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
63
-static void ibex_plic_irqs_set_pending(IbexPlicState *s, int irq, bool level)
81
index XXXXXXX..XXXXXXX 100644
64
-{
82
--- a/hw/riscv/sifive_u.c
65
- int pending_num = irq / 32;
83
+++ b/hw/riscv/sifive_u.c
66
-
84
@@ -XXX,XX +XXX,XX @@
67
- if (!level) {
85
#include "hw/misc/unimp.h"
68
- /*
86
#include "target/riscv/cpu.h"
69
- * If the level is low make sure we clear the hidden_pending.
87
#include "hw/riscv/riscv_hart.h"
70
- */
88
-#include "hw/riscv/sifive_plic.h"
71
- s->hidden_pending[pending_num] &= ~(1 << (irq % 32));
89
#include "hw/riscv/sifive_uart.h"
72
- }
90
#include "hw/riscv/sifive_u.h"
73
-
91
#include "hw/riscv/boot.h"
74
- if (s->claimed[pending_num] & 1 << (irq % 32)) {
92
#include "hw/intc/sifive_clint.h"
75
- /*
93
+#include "hw/intc/sifive_plic.h"
76
- * The interrupt has been claimed, but not completed.
94
#include "chardev/char.h"
77
- * The pending bit can't be set.
95
#include "net/eth.h"
78
- * Save the pending level for after the interrupt is completed.
96
#include "sysemu/arch_init.h"
79
- */
97
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
80
- s->hidden_pending[pending_num] |= level << (irq % 32);
98
index XXXXXXX..XXXXXXX 100644
81
- } else {
99
--- a/hw/riscv/virt.c
82
- s->pending[pending_num] |= level << (irq % 32);
100
+++ b/hw/riscv/virt.c
83
- }
101
@@ -XXX,XX +XXX,XX @@
84
-}
102
#include "hw/char/serial.h"
85
-
103
#include "target/riscv/cpu.h"
86
-static bool ibex_plic_irqs_pending(IbexPlicState *s, uint32_t context)
104
#include "hw/riscv/riscv_hart.h"
87
-{
105
-#include "hw/riscv/sifive_plic.h"
88
- int i;
106
#include "hw/riscv/sifive_test.h"
89
- uint32_t max_irq = 0;
107
#include "hw/riscv/virt.h"
90
- uint32_t max_prio = s->threshold;
108
#include "hw/riscv/boot.h"
91
-
109
#include "hw/riscv/numa.h"
92
- for (i = 0; i < s->pending_num; i++) {
110
#include "hw/intc/sifive_clint.h"
93
- uint32_t irq_num = ctz64(s->pending[i]) + (i * 32);
111
+#include "hw/intc/sifive_plic.h"
94
-
112
#include "chardev/char.h"
95
- if (!(s->pending[i] & s->enable[i])) {
113
#include "sysemu/arch_init.h"
96
- /* No pending and enabled IRQ */
114
#include "sysemu/device_tree.h"
97
- continue;
115
diff --git a/hw/intc/Kconfig b/hw/intc/Kconfig
98
- }
116
index XXXXXXX..XXXXXXX 100644
99
-
117
--- a/hw/intc/Kconfig
100
- if (s->priority[irq_num] > max_prio) {
118
+++ b/hw/intc/Kconfig
101
- max_irq = irq_num;
119
@@ -XXX,XX +XXX,XX @@ config LOONGSON_LIOINTC
102
- max_prio = s->priority[irq_num];
120
103
- }
121
config SIFIVE_CLINT
104
- }
122
bool
105
-
123
+
106
- if (max_irq) {
124
+config SIFIVE_PLIC
107
- s->claim = max_irq;
125
+ bool
108
- return true;
109
- }
110
-
111
- return false;
112
-}
113
-
114
-static void ibex_plic_update(IbexPlicState *s)
115
-{
116
- int i;
117
-
118
- for (i = 0; i < s->num_cpus; i++) {
119
- qemu_set_irq(s->external_irqs[i], ibex_plic_irqs_pending(s, 0));
120
- }
121
-}
122
-
123
-static void ibex_plic_reset(DeviceState *dev)
124
-{
125
- IbexPlicState *s = IBEX_PLIC(dev);
126
-
127
- s->threshold = 0x00000000;
128
- s->claim = 0x00000000;
129
-}
130
-
131
-static uint64_t ibex_plic_read(void *opaque, hwaddr addr,
132
- unsigned int size)
133
-{
134
- IbexPlicState *s = opaque;
135
- int offset;
136
- uint32_t ret = 0;
137
-
138
- if (addr_between(addr, s->pending_base, s->pending_num)) {
139
- offset = (addr - s->pending_base) / 4;
140
- ret = s->pending[offset];
141
- } else if (addr_between(addr, s->source_base, s->source_num)) {
142
- qemu_log_mask(LOG_UNIMP,
143
- "%s: Interrupt source mode not supported\n", __func__);
144
- } else if (addr_between(addr, s->priority_base, s->priority_num)) {
145
- offset = (addr - s->priority_base) / 4;
146
- ret = s->priority[offset];
147
- } else if (addr_between(addr, s->enable_base, s->enable_num)) {
148
- offset = (addr - s->enable_base) / 4;
149
- ret = s->enable[offset];
150
- } else if (addr_between(addr, s->threshold_base, 1)) {
151
- ret = s->threshold;
152
- } else if (addr_between(addr, s->claim_base, 1)) {
153
- int pending_num = s->claim / 32;
154
- s->pending[pending_num] &= ~(1 << (s->claim % 32));
155
-
156
- /* Set the interrupt as claimed, but not completed */
157
- s->claimed[pending_num] |= 1 << (s->claim % 32);
158
-
159
- /* Return the current claimed interrupt */
160
- ret = s->claim;
161
-
162
- /* Clear the claimed interrupt */
163
- s->claim = 0x00000000;
164
-
165
- /* Update the interrupt status after the claim */
166
- ibex_plic_update(s);
167
- }
168
-
169
- return ret;
170
-}
171
-
172
-static void ibex_plic_write(void *opaque, hwaddr addr,
173
- uint64_t value, unsigned int size)
174
-{
175
- IbexPlicState *s = opaque;
176
-
177
- if (addr_between(addr, s->pending_base, s->pending_num)) {
178
- qemu_log_mask(LOG_GUEST_ERROR,
179
- "%s: Pending registers are read only\n", __func__);
180
- } else if (addr_between(addr, s->source_base, s->source_num)) {
181
- qemu_log_mask(LOG_UNIMP,
182
- "%s: Interrupt source mode not supported\n", __func__);
183
- } else if (addr_between(addr, s->priority_base, s->priority_num)) {
184
- uint32_t irq = ((addr - s->priority_base) >> 2) + 1;
185
- s->priority[irq] = value & 7;
186
- ibex_plic_update(s);
187
- } else if (addr_between(addr, s->enable_base, s->enable_num)) {
188
- uint32_t enable_reg = (addr - s->enable_base) / 4;
189
-
190
- s->enable[enable_reg] = value;
191
- } else if (addr_between(addr, s->threshold_base, 1)) {
192
- s->threshold = value & 3;
193
- } else if (addr_between(addr, s->claim_base, 1)) {
194
- if (s->claim == value) {
195
- /* Interrupt was completed */
196
- s->claim = 0;
197
- }
198
- if (s->claimed[value / 32] & 1 << (value % 32)) {
199
- int pending_num = value / 32;
200
-
201
- /* This value was already claimed, clear it. */
202
- s->claimed[pending_num] &= ~(1 << (value % 32));
203
-
204
- if (s->hidden_pending[pending_num] & (1 << (value % 32))) {
205
- /*
206
- * If the bit in hidden_pending is set then that means we
207
- * received an interrupt between claiming and completing
208
- * the interrupt that hasn't since been de-asserted.
209
- * On hardware this would trigger an interrupt, so let's
210
- * trigger one here as well.
211
- */
212
- s->pending[pending_num] |= 1 << (value % 32);
213
- }
214
- }
215
- }
216
-
217
- ibex_plic_update(s);
218
-}
219
-
220
-static const MemoryRegionOps ibex_plic_ops = {
221
- .read = ibex_plic_read,
222
- .write = ibex_plic_write,
223
- .endianness = DEVICE_NATIVE_ENDIAN,
224
- .valid = {
225
- .min_access_size = 4,
226
- .max_access_size = 4
227
- }
228
-};
229
-
230
-static void ibex_plic_irq_request(void *opaque, int irq, int level)
231
-{
232
- IbexPlicState *s = opaque;
233
-
234
- ibex_plic_irqs_set_pending(s, irq, level > 0);
235
- ibex_plic_update(s);
236
-}
237
-
238
-static Property ibex_plic_properties[] = {
239
- DEFINE_PROP_UINT32("num-cpus", IbexPlicState, num_cpus, 1),
240
- DEFINE_PROP_UINT32("num-sources", IbexPlicState, num_sources, 176),
241
-
242
- DEFINE_PROP_UINT32("pending-base", IbexPlicState, pending_base, 0),
243
- DEFINE_PROP_UINT32("pending-num", IbexPlicState, pending_num, 6),
244
-
245
- DEFINE_PROP_UINT32("source-base", IbexPlicState, source_base, 0x18),
246
- DEFINE_PROP_UINT32("source-num", IbexPlicState, source_num, 6),
247
-
248
- DEFINE_PROP_UINT32("priority-base", IbexPlicState, priority_base, 0x30),
249
- DEFINE_PROP_UINT32("priority-num", IbexPlicState, priority_num, 177),
250
-
251
- DEFINE_PROP_UINT32("enable-base", IbexPlicState, enable_base, 0x300),
252
- DEFINE_PROP_UINT32("enable-num", IbexPlicState, enable_num, 6),
253
-
254
- DEFINE_PROP_UINT32("threshold-base", IbexPlicState, threshold_base, 0x318),
255
-
256
- DEFINE_PROP_UINT32("claim-base", IbexPlicState, claim_base, 0x31c),
257
- DEFINE_PROP_END_OF_LIST(),
258
-};
259
-
260
-static void ibex_plic_init(Object *obj)
261
-{
262
- IbexPlicState *s = IBEX_PLIC(obj);
263
-
264
- memory_region_init_io(&s->mmio, obj, &ibex_plic_ops, s,
265
- TYPE_IBEX_PLIC, 0x400);
266
- sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio);
267
-}
268
-
269
-static void ibex_plic_realize(DeviceState *dev, Error **errp)
270
-{
271
- IbexPlicState *s = IBEX_PLIC(dev);
272
- int i;
273
-
274
- s->pending = g_new0(uint32_t, s->pending_num);
275
- s->hidden_pending = g_new0(uint32_t, s->pending_num);
276
- s->claimed = g_new0(uint32_t, s->pending_num);
277
- s->source = g_new0(uint32_t, s->source_num);
278
- s->priority = g_new0(uint32_t, s->priority_num);
279
- s->enable = g_new0(uint32_t, s->enable_num);
280
-
281
- qdev_init_gpio_in(dev, ibex_plic_irq_request, s->num_sources);
282
-
283
- s->external_irqs = g_malloc(sizeof(qemu_irq) * s->num_cpus);
284
- qdev_init_gpio_out(dev, s->external_irqs, s->num_cpus);
285
-
286
- /*
287
- * We can't allow the supervisor to control SEIP as this would allow the
288
- * supervisor to clear a pending external interrupt which will result in
289
- * a lost interrupt in the case a PLIC is attached. The SEIP bit must be
290
- * hardware controlled when a PLIC is attached.
291
- */
292
- MachineState *ms = MACHINE(qdev_get_machine());
293
- unsigned int smp_cpus = ms->smp.cpus;
294
- for (i = 0; i < smp_cpus; i++) {
295
- RISCVCPU *cpu = RISCV_CPU(qemu_get_cpu(i));
296
- if (riscv_cpu_claim_interrupts(cpu, MIP_SEIP) < 0) {
297
- error_report("SEIP already claimed");
298
- exit(1);
299
- }
300
- }
301
-
302
- msi_nonbroken = true;
303
-}
304
-
305
-static void ibex_plic_class_init(ObjectClass *klass, void *data)
306
-{
307
- DeviceClass *dc = DEVICE_CLASS(klass);
308
-
309
- dc->reset = ibex_plic_reset;
310
- device_class_set_props(dc, ibex_plic_properties);
311
- dc->realize = ibex_plic_realize;
312
-}
313
-
314
-static const TypeInfo ibex_plic_info = {
315
- .name = TYPE_IBEX_PLIC,
316
- .parent = TYPE_SYS_BUS_DEVICE,
317
- .instance_size = sizeof(IbexPlicState),
318
- .instance_init = ibex_plic_init,
319
- .class_init = ibex_plic_class_init,
320
-};
321
-
322
-static void ibex_plic_register_types(void)
323
-{
324
- type_register_static(&ibex_plic_info);
325
-}
326
-
327
-type_init(ibex_plic_register_types)
126
diff --git a/hw/intc/meson.build b/hw/intc/meson.build
328
diff --git a/hw/intc/meson.build b/hw/intc/meson.build
127
index XXXXXXX..XXXXXXX 100644
329
index XXXXXXX..XXXXXXX 100644
128
--- a/hw/intc/meson.build
330
--- a/hw/intc/meson.build
129
+++ b/hw/intc/meson.build
331
+++ b/hw/intc/meson.build
130
@@ -XXX,XX +XXX,XX @@ specific_ss.add(when: 'CONFIG_S390_FLIC', if_true: files('s390_flic.c'))
332
@@ -XXX,XX +XXX,XX @@ specific_ss.add(when: 'CONFIG_ARM_V7M', if_true: files('armv7m_nvic.c'))
131
specific_ss.add(when: 'CONFIG_S390_FLIC_KVM', if_true: files('s390_flic_kvm.c'))
333
specific_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_vic.c'))
132
specific_ss.add(when: 'CONFIG_SH4', if_true: files('sh_intc.c'))
334
specific_ss.add(when: 'CONFIG_EXYNOS4', if_true: files('exynos4210_gic.c', 'exynos4210_combiner.c'))
133
specific_ss.add(when: 'CONFIG_SIFIVE_CLINT', if_true: files('sifive_clint.c'))
335
specific_ss.add(when: 'CONFIG_GRLIB', if_true: files('grlib_irqmp.c'))
134
+specific_ss.add(when: 'CONFIG_SIFIVE_PLIC', if_true: files('sifive_plic.c'))
336
-specific_ss.add(when: 'CONFIG_IBEX', if_true: files('ibex_plic.c'))
135
specific_ss.add(when: 'CONFIG_XICS', if_true: files('xics.c'))
337
specific_ss.add(when: 'CONFIG_IOAPIC', if_true: files('ioapic.c'))
136
specific_ss.add(when: 'CONFIG_XICS_KVM', if_true: files('xics_kvm.c'))
338
specific_ss.add(when: 'CONFIG_LOONGSON_LIOINTC', if_true: files('loongson_liointc.c'))
137
specific_ss.add(when: 'CONFIG_XICS_SPAPR', if_true: files('xics_spapr.c'))
339
specific_ss.add(when: 'CONFIG_MIPS_CPS', if_true: files('mips_gic.c'))
138
diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
139
index XXXXXXX..XXXXXXX 100644
140
--- a/hw/riscv/Kconfig
141
+++ b/hw/riscv/Kconfig
142
@@ -XXX,XX +XXX,XX @@ config SIFIVE_E
143
select SIFIVE
144
select SIFIVE_CLINT
145
select SIFIVE_GPIO
146
+ select SIFIVE_PLIC
147
select SIFIVE_E_PRCI
148
select UNIMP
149
150
@@ -XXX,XX +XXX,XX @@ config SIFIVE_U
151
select SIFIVE_CLINT
152
select SIFIVE_GPIO
153
select SIFIVE_PDMA
154
+ select SIFIVE_PLIC
155
select SIFIVE_U_OTP
156
select SIFIVE_U_PRCI
157
select UNIMP
158
@@ -XXX,XX +XXX,XX @@ config SPIKE
159
select HTIF
160
select SIFIVE
161
select SIFIVE_CLINT
162
+ select SIFIVE_PLIC
163
164
config OPENTITAN
165
bool
166
@@ -XXX,XX +XXX,XX @@ config RISCV_VIRT
167
select PFLASH_CFI01
168
select SIFIVE
169
select SIFIVE_CLINT
170
+ select SIFIVE_PLIC
171
172
config MICROCHIP_PFSOC
173
bool
174
@@ -XXX,XX +XXX,XX @@ config MICROCHIP_PFSOC
175
select UNIMP
176
select MCHP_PFSOC_MMUART
177
select SIFIVE_PDMA
178
+ select SIFIVE_PLIC
179
select CADENCE_SDHCI
180
diff --git a/hw/riscv/meson.build b/hw/riscv/meson.build
181
index XXXXXXX..XXXXXXX 100644
182
--- a/hw/riscv/meson.build
183
+++ b/hw/riscv/meson.build
184
@@ -XXX,XX +XXX,XX @@ riscv_ss.add(files('numa.c'))
185
riscv_ss.add(when: 'CONFIG_HART', if_true: files('riscv_hart.c'))
186
riscv_ss.add(when: 'CONFIG_OPENTITAN', if_true: files('opentitan.c'))
187
riscv_ss.add(when: 'CONFIG_RISCV_VIRT', if_true: files('virt.c'))
188
-riscv_ss.add(when: 'CONFIG_SIFIVE', if_true: files('sifive_plic.c'))
189
riscv_ss.add(when: 'CONFIG_SIFIVE', if_true: files('sifive_test.c'))
190
riscv_ss.add(when: 'CONFIG_SIFIVE', if_true: files('sifive_uart.c'))
191
riscv_ss.add(when: 'CONFIG_SIFIVE_E', if_true: files('sifive_e.c'))
192
--
340
--
193
2.28.0
341
2.31.1
194
342
195
343
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Alistair Francis <alistair.francis@wdc.com>
2
2
3
Microchip PolarFire SoC has 5 MMUARTs, and the Icicle Kit board
3
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
4
wires 4 of them out. Let's connect all 5 MMUARTs.
4
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
5
Message-id: 3c125e27c49a4969df82bf8b197535ccd1996939.1634524691.git.alistair.francis@wdc.com
6
---
7
hw/intc/sifive_plic.c | 30 +++++++++++++++---------------
8
1 file changed, 15 insertions(+), 15 deletions(-)
5
9
6
Signed-off-by: Bin Meng <bin.meng@windriver.com>
10
diff --git a/hw/intc/sifive_plic.c b/hw/intc/sifive_plic.c
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Message-Id: <1598924352-89526-7-git-send-email-bmeng.cn@gmail.com>
9
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
---
11
include/hw/riscv/microchip_pfsoc.h | 20 ++++++++++++++++++++
12
hw/riscv/microchip_pfsoc.c | 30 ++++++++++++++++++++++++++++++
13
hw/riscv/Kconfig | 1 +
14
3 files changed, 51 insertions(+)
15
16
diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchip_pfsoc.h
17
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/riscv/microchip_pfsoc.h
12
--- a/hw/intc/sifive_plic.c
19
+++ b/include/hw/riscv/microchip_pfsoc.h
13
+++ b/hw/intc/sifive_plic.c
20
@@ -XXX,XX +XXX,XX @@
14
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps sifive_plic_ops = {
21
#ifndef HW_MICROCHIP_PFSOC_H
15
}
22
#define HW_MICROCHIP_PFSOC_H
23
24
+#include "hw/char/mchp_pfsoc_mmuart.h"
25
+
26
typedef struct MicrochipPFSoCState {
27
/*< private >*/
28
DeviceState parent_obj;
29
@@ -XXX,XX +XXX,XX @@ typedef struct MicrochipPFSoCState {
30
RISCVHartArrayState e_cpus;
31
RISCVHartArrayState u_cpus;
32
DeviceState *plic;
33
+ MchpPfSoCMMUartState *serial0;
34
+ MchpPfSoCMMUartState *serial1;
35
+ MchpPfSoCMMUartState *serial2;
36
+ MchpPfSoCMMUartState *serial3;
37
+ MchpPfSoCMMUartState *serial4;
38
} MicrochipPFSoCState;
39
40
#define TYPE_MICROCHIP_PFSOC "microchip.pfsoc"
41
@@ -XXX,XX +XXX,XX @@ enum {
42
MICROCHIP_PFSOC_L2CC,
43
MICROCHIP_PFSOC_L2LIM,
44
MICROCHIP_PFSOC_PLIC,
45
+ MICROCHIP_PFSOC_MMUART0,
46
MICROCHIP_PFSOC_SYSREG,
47
MICROCHIP_PFSOC_MPUCFG,
48
+ MICROCHIP_PFSOC_MMUART1,
49
+ MICROCHIP_PFSOC_MMUART2,
50
+ MICROCHIP_PFSOC_MMUART3,
51
+ MICROCHIP_PFSOC_MMUART4,
52
MICROCHIP_PFSOC_ENVM_CFG,
53
MICROCHIP_PFSOC_ENVM_DATA,
54
MICROCHIP_PFSOC_IOSCB_CFG,
55
MICROCHIP_PFSOC_DRAM,
56
};
16
};
57
17
58
+enum {
18
-static Property sifive_plic_properties[] = {
59
+ MICROCHIP_PFSOC_MMUART0_IRQ = 90,
19
- DEFINE_PROP_STRING("hart-config", SiFivePLICState, hart_config),
60
+ MICROCHIP_PFSOC_MMUART1_IRQ = 91,
20
- DEFINE_PROP_UINT32("hartid-base", SiFivePLICState, hartid_base, 0),
61
+ MICROCHIP_PFSOC_MMUART2_IRQ = 92,
21
- DEFINE_PROP_UINT32("num-sources", SiFivePLICState, num_sources, 0),
62
+ MICROCHIP_PFSOC_MMUART3_IRQ = 93,
22
- DEFINE_PROP_UINT32("num-priorities", SiFivePLICState, num_priorities, 0),
63
+ MICROCHIP_PFSOC_MMUART4_IRQ = 94,
23
- DEFINE_PROP_UINT32("priority-base", SiFivePLICState, priority_base, 0),
24
- DEFINE_PROP_UINT32("pending-base", SiFivePLICState, pending_base, 0),
25
- DEFINE_PROP_UINT32("enable-base", SiFivePLICState, enable_base, 0),
26
- DEFINE_PROP_UINT32("enable-stride", SiFivePLICState, enable_stride, 0),
27
- DEFINE_PROP_UINT32("context-base", SiFivePLICState, context_base, 0),
28
- DEFINE_PROP_UINT32("context-stride", SiFivePLICState, context_stride, 0),
29
- DEFINE_PROP_UINT32("aperture-size", SiFivePLICState, aperture_size, 0),
30
- DEFINE_PROP_END_OF_LIST(),
31
-};
32
-
33
/*
34
* parse PLIC hart/mode address offset config
35
*
36
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_sifive_plic = {
37
}
38
};
39
40
+static Property sifive_plic_properties[] = {
41
+ DEFINE_PROP_STRING("hart-config", SiFivePLICState, hart_config),
42
+ DEFINE_PROP_UINT32("hartid-base", SiFivePLICState, hartid_base, 0),
43
+ DEFINE_PROP_UINT32("num-sources", SiFivePLICState, num_sources, 0),
44
+ DEFINE_PROP_UINT32("num-priorities", SiFivePLICState, num_priorities, 0),
45
+ DEFINE_PROP_UINT32("priority-base", SiFivePLICState, priority_base, 0),
46
+ DEFINE_PROP_UINT32("pending-base", SiFivePLICState, pending_base, 0),
47
+ DEFINE_PROP_UINT32("enable-base", SiFivePLICState, enable_base, 0),
48
+ DEFINE_PROP_UINT32("enable-stride", SiFivePLICState, enable_stride, 0),
49
+ DEFINE_PROP_UINT32("context-base", SiFivePLICState, context_base, 0),
50
+ DEFINE_PROP_UINT32("context-stride", SiFivePLICState, context_stride, 0),
51
+ DEFINE_PROP_UINT32("aperture-size", SiFivePLICState, aperture_size, 0),
52
+ DEFINE_PROP_END_OF_LIST(),
64
+};
53
+};
65
+
54
+
66
#define MICROCHIP_PFSOC_MANAGEMENT_CPU_COUNT 1
55
static void sifive_plic_class_init(ObjectClass *klass, void *data)
67
#define MICROCHIP_PFSOC_COMPUTE_CPU_COUNT 4
56
{
68
57
DeviceClass *dc = DEVICE_CLASS(klass);
69
diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c
70
index XXXXXXX..XXXXXXX 100644
71
--- a/hw/riscv/microchip_pfsoc.c
72
+++ b/hw/riscv/microchip_pfsoc.c
73
@@ -XXX,XX +XXX,XX @@
74
* 0) CLINT (Core Level Interruptor)
75
* 1) PLIC (Platform Level Interrupt Controller)
76
* 2) eNVM (Embedded Non-Volatile Memory)
77
+ * 3) MMUARTs (Multi-Mode UART)
78
*
79
* This board currently generates devicetree dynamically that indicates at least
80
* two harts and up to five harts.
81
@@ -XXX,XX +XXX,XX @@
82
#include "hw/irq.h"
83
#include "hw/loader.h"
84
#include "hw/sysbus.h"
85
+#include "chardev/char.h"
86
#include "hw/cpu/cluster.h"
87
#include "target/riscv/cpu.h"
88
#include "hw/misc/unimp.h"
89
@@ -XXX,XX +XXX,XX @@
90
#include "hw/riscv/sifive_clint.h"
91
#include "hw/riscv/sifive_plic.h"
92
#include "hw/riscv/microchip_pfsoc.h"
93
+#include "sysemu/sysemu.h"
94
95
/*
96
* The BIOS image used by this machine is called Hart Software Services (HSS).
97
@@ -XXX,XX +XXX,XX @@ static const struct MemmapEntry {
98
[MICROCHIP_PFSOC_L2CC] = { 0x2010000, 0x1000 },
99
[MICROCHIP_PFSOC_L2LIM] = { 0x8000000, 0x2000000 },
100
[MICROCHIP_PFSOC_PLIC] = { 0xc000000, 0x4000000 },
101
+ [MICROCHIP_PFSOC_MMUART0] = { 0x20000000, 0x1000 },
102
[MICROCHIP_PFSOC_SYSREG] = { 0x20002000, 0x2000 },
103
[MICROCHIP_PFSOC_MPUCFG] = { 0x20005000, 0x1000 },
104
+ [MICROCHIP_PFSOC_MMUART1] = { 0x20100000, 0x1000 },
105
+ [MICROCHIP_PFSOC_MMUART2] = { 0x20102000, 0x1000 },
106
+ [MICROCHIP_PFSOC_MMUART3] = { 0x20104000, 0x1000 },
107
+ [MICROCHIP_PFSOC_MMUART4] = { 0x20106000, 0x1000 },
108
[MICROCHIP_PFSOC_ENVM_CFG] = { 0x20200000, 0x1000 },
109
[MICROCHIP_PFSOC_ENVM_DATA] = { 0x20220000, 0x20000 },
110
[MICROCHIP_PFSOC_IOSCB_CFG] = { 0x37080000, 0x1000 },
111
@@ -XXX,XX +XXX,XX @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp)
112
memmap[MICROCHIP_PFSOC_MPUCFG].base,
113
memmap[MICROCHIP_PFSOC_MPUCFG].size);
114
115
+ /* MMUARTs */
116
+ s->serial0 = mchp_pfsoc_mmuart_create(system_memory,
117
+ memmap[MICROCHIP_PFSOC_MMUART0].base,
118
+ qdev_get_gpio_in(DEVICE(s->plic), MICROCHIP_PFSOC_MMUART0_IRQ),
119
+ serial_hd(0));
120
+ s->serial1 = mchp_pfsoc_mmuart_create(system_memory,
121
+ memmap[MICROCHIP_PFSOC_MMUART1].base,
122
+ qdev_get_gpio_in(DEVICE(s->plic), MICROCHIP_PFSOC_MMUART1_IRQ),
123
+ serial_hd(1));
124
+ s->serial2 = mchp_pfsoc_mmuart_create(system_memory,
125
+ memmap[MICROCHIP_PFSOC_MMUART2].base,
126
+ qdev_get_gpio_in(DEVICE(s->plic), MICROCHIP_PFSOC_MMUART2_IRQ),
127
+ serial_hd(2));
128
+ s->serial3 = mchp_pfsoc_mmuart_create(system_memory,
129
+ memmap[MICROCHIP_PFSOC_MMUART3].base,
130
+ qdev_get_gpio_in(DEVICE(s->plic), MICROCHIP_PFSOC_MMUART3_IRQ),
131
+ serial_hd(3));
132
+ s->serial4 = mchp_pfsoc_mmuart_create(system_memory,
133
+ memmap[MICROCHIP_PFSOC_MMUART4].base,
134
+ qdev_get_gpio_in(DEVICE(s->plic), MICROCHIP_PFSOC_MMUART4_IRQ),
135
+ serial_hd(4));
136
+
137
/* eNVM */
138
memory_region_init_rom(envm_data, OBJECT(dev), "microchip.pfsoc.envm.data",
139
memmap[MICROCHIP_PFSOC_ENVM_DATA].size,
140
diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
141
index XXXXXXX..XXXXXXX 100644
142
--- a/hw/riscv/Kconfig
143
+++ b/hw/riscv/Kconfig
144
@@ -XXX,XX +XXX,XX @@ config MICROCHIP_PFSOC
145
select HART
146
select SIFIVE
147
select UNIMP
148
+ select MCHP_PFSOC_MMUART
149
--
58
--
150
2.28.0
59
2.31.1
151
60
152
61
diff view generated by jsdifflib
New patch
1
From: Alistair Francis <alistair.francis@wdc.com>
1
2
3
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
4
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
5
Message-id: b94c098cb221e744683349b1ac794c23102ef471.1634524691.git.alistair.francis@wdc.com
6
---
7
hw/intc/sifive_plic.c | 45 +++++++++++++++++++++++--------------------
8
1 file changed, 24 insertions(+), 21 deletions(-)
9
10
diff --git a/hw/intc/sifive_plic.c b/hw/intc/sifive_plic.c
11
index XXXXXXX..XXXXXXX 100644
12
--- a/hw/intc/sifive_plic.c
13
+++ b/hw/intc/sifive_plic.c
14
@@ -XXX,XX +XXX,XX @@ static void sifive_plic_irq_request(void *opaque, int irq, int level)
15
16
static void sifive_plic_realize(DeviceState *dev, Error **errp)
17
{
18
- SiFivePLICState *plic = SIFIVE_PLIC(dev);
19
+ SiFivePLICState *s = SIFIVE_PLIC(dev);
20
int i;
21
22
- memory_region_init_io(&plic->mmio, OBJECT(dev), &sifive_plic_ops, plic,
23
- TYPE_SIFIVE_PLIC, plic->aperture_size);
24
- parse_hart_config(plic);
25
- plic->bitfield_words = (plic->num_sources + 31) >> 5;
26
- plic->num_enables = plic->bitfield_words * plic->num_addrs;
27
- plic->source_priority = g_new0(uint32_t, plic->num_sources);
28
- plic->target_priority = g_new(uint32_t, plic->num_addrs);
29
- plic->pending = g_new0(uint32_t, plic->bitfield_words);
30
- plic->claimed = g_new0(uint32_t, plic->bitfield_words);
31
- plic->enable = g_new0(uint32_t, plic->num_enables);
32
- sysbus_init_mmio(SYS_BUS_DEVICE(dev), &plic->mmio);
33
- qdev_init_gpio_in(dev, sifive_plic_irq_request, plic->num_sources);
34
-
35
- plic->s_external_irqs = g_malloc(sizeof(qemu_irq) * plic->num_harts);
36
- qdev_init_gpio_out(dev, plic->s_external_irqs, plic->num_harts);
37
-
38
- plic->m_external_irqs = g_malloc(sizeof(qemu_irq) * plic->num_harts);
39
- qdev_init_gpio_out(dev, plic->m_external_irqs, plic->num_harts);
40
+ memory_region_init_io(&s->mmio, OBJECT(dev), &sifive_plic_ops, s,
41
+ TYPE_SIFIVE_PLIC, s->aperture_size);
42
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mmio);
43
+
44
+ parse_hart_config(s);
45
+
46
+ s->bitfield_words = (s->num_sources + 31) >> 5;
47
+ s->num_enables = s->bitfield_words * s->num_addrs;
48
+ s->source_priority = g_new0(uint32_t, s->num_sources);
49
+ s->target_priority = g_new(uint32_t, s->num_addrs);
50
+ s->pending = g_new0(uint32_t, s->bitfield_words);
51
+ s->claimed = g_new0(uint32_t, s->bitfield_words);
52
+ s->enable = g_new0(uint32_t, s->num_enables);
53
+
54
+ qdev_init_gpio_in(dev, sifive_plic_irq_request, s->num_sources);
55
+
56
+ s->s_external_irqs = g_malloc(sizeof(qemu_irq) * s->num_harts);
57
+ qdev_init_gpio_out(dev, s->s_external_irqs, s->num_harts);
58
+
59
+ s->m_external_irqs = g_malloc(sizeof(qemu_irq) * s->num_harts);
60
+ qdev_init_gpio_out(dev, s->m_external_irqs, s->num_harts);
61
62
/* We can't allow the supervisor to control SEIP as this would allow the
63
* supervisor to clear a pending external interrupt which will result in
64
* lost a interrupt in the case a PLIC is attached. The SEIP bit must be
65
* hardware controlled when a PLIC is attached.
66
*/
67
- for (i = 0; i < plic->num_harts; i++) {
68
- RISCVCPU *cpu = RISCV_CPU(qemu_get_cpu(plic->hartid_base + i));
69
+ for (i = 0; i < s->num_harts; i++) {
70
+ RISCVCPU *cpu = RISCV_CPU(qemu_get_cpu(s->hartid_base + i));
71
if (riscv_cpu_claim_interrupts(cpu, MIP_SEIP) < 0) {
72
error_report("SEIP already claimed");
73
exit(1);
74
--
75
2.31.1
76
77
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Alistair Francis <alistair.francis@wdc.com>
2
2
3
RISC-V machines do not instantiate RISC-V CPUs directly, instead
3
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
4
they do that via the hart array. Add a new property for the reset
4
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
5
vector address to allow the value to be passed to the CPU, before
5
Message-id: 4200da222a65c89ed1ba35f754dcca7fdd9f08d6.1634524691.git.alistair.francis@wdc.com
6
CPU is realized.
6
---
7
hw/intc/sifive_plic.c | 10 ++++------
8
1 file changed, 4 insertions(+), 6 deletions(-)
7
9
8
Signed-off-by: Bin Meng <bin.meng@windriver.com>
10
diff --git a/hw/intc/sifive_plic.c b/hw/intc/sifive_plic.c
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Message-Id: <1598924352-89526-3-git-send-email-bmeng.cn@gmail.com>
12
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
13
---
14
include/hw/riscv/riscv_hart.h | 1 +
15
hw/riscv/riscv_hart.c | 3 +++
16
2 files changed, 4 insertions(+)
17
18
diff --git a/include/hw/riscv/riscv_hart.h b/include/hw/riscv/riscv_hart.h
19
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
20
--- a/include/hw/riscv/riscv_hart.h
12
--- a/hw/intc/sifive_plic.c
21
+++ b/include/hw/riscv/riscv_hart.h
13
+++ b/hw/intc/sifive_plic.c
22
@@ -XXX,XX +XXX,XX @@ typedef struct RISCVHartArrayState {
14
@@ -XXX,XX +XXX,XX @@ static void parse_hart_config(SiFivePLICState *plic)
23
uint32_t num_harts;
15
24
uint32_t hartid_base;
16
static void sifive_plic_irq_request(void *opaque, int irq, int level)
25
char *cpu_type;
26
+ uint64_t resetvec;
27
RISCVCPU *harts;
28
} RISCVHartArrayState;
29
30
diff --git a/hw/riscv/riscv_hart.c b/hw/riscv/riscv_hart.c
31
index XXXXXXX..XXXXXXX 100644
32
--- a/hw/riscv/riscv_hart.c
33
+++ b/hw/riscv/riscv_hart.c
34
@@ -XXX,XX +XXX,XX @@ static Property riscv_harts_props[] = {
35
DEFINE_PROP_UINT32("num-harts", RISCVHartArrayState, num_harts, 1),
36
DEFINE_PROP_UINT32("hartid-base", RISCVHartArrayState, hartid_base, 0),
37
DEFINE_PROP_STRING("cpu-type", RISCVHartArrayState, cpu_type),
38
+ DEFINE_PROP_UINT64("resetvec", RISCVHartArrayState, resetvec,
39
+ DEFAULT_RSTVEC),
40
DEFINE_PROP_END_OF_LIST(),
41
};
42
43
@@ -XXX,XX +XXX,XX @@ static bool riscv_hart_realize(RISCVHartArrayState *s, int idx,
44
char *cpu_type, Error **errp)
45
{
17
{
46
object_initialize_child(OBJECT(s), "harts[*]", &s->harts[idx], cpu_type);
18
- SiFivePLICState *plic = opaque;
47
+ qdev_prop_set_uint64(DEVICE(&s->harts[idx]), "resetvec", s->resetvec);
19
- if (RISCV_DEBUG_PLIC) {
48
s->harts[idx].env.mhartid = s->hartid_base + idx;
20
- qemu_log("sifive_plic_irq_request: irq=%d level=%d\n", irq, level);
49
qemu_register_reset(riscv_harts_cpu_reset, &s->harts[idx]);
21
- }
50
return qdev_realize(DEVICE(&s->harts[idx]), NULL, errp);
22
- sifive_plic_set_pending(plic, irq, level > 0);
23
- sifive_plic_update(plic);
24
+ SiFivePLICState *s = opaque;
25
+
26
+ sifive_plic_set_pending(s, irq, level > 0);
27
+ sifive_plic_update(s);
28
}
29
30
static void sifive_plic_realize(DeviceState *dev, Error **errp)
51
--
31
--
52
2.28.0
32
2.31.1
53
33
54
34
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Bin Meng <bmeng.cn@gmail.com>
2
2
3
Microchip PolarFire SoC integrates 3 GPIOs controllers. It seems
3
Using memory_region_init_ram(), which can't possibly handle vhost-user,
4
enough to create unimplemented devices to cover their register
4
and can't work as expected with '-numa node,memdev' options.
5
spaces at this point.
6
5
7
With this commit, QEMU can boot to U-Boot (2nd stage bootloader)
6
Use MachineState::ram instead of manually initializing RAM memory
8
all the way to the Linux shell login prompt, with a modified HSS
7
region, as well as by providing MachineClass::default_ram_id to
9
(1st stage bootloader).
8
opt in to memdev scheme.
10
9
11
For detailed instructions on how to create images for the Icicle
10
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
12
Kit board, please check QEMU RISC-V WiKi page at:
13
https://wiki.qemu.org/Documentation/Platforms/RISCV
14
15
Signed-off-by: Bin Meng <bin.meng@windriver.com>
16
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
11
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
17
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
12
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
18
Message-Id: <1598924352-89526-15-git-send-email-bmeng.cn@gmail.com>
13
Message-id: 20211020014112.7336-2-bmeng.cn@gmail.com
19
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
14
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
20
---
15
---
21
include/hw/riscv/microchip_pfsoc.h | 3 +++
16
hw/riscv/microchip_pfsoc.c | 36 ++++++++++++++++++++----------------
22
hw/riscv/microchip_pfsoc.c | 14 ++++++++++++++
17
1 file changed, 20 insertions(+), 16 deletions(-)
23
2 files changed, 17 insertions(+)
24
18
25
diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchip_pfsoc.h
26
index XXXXXXX..XXXXXXX 100644
27
--- a/include/hw/riscv/microchip_pfsoc.h
28
+++ b/include/hw/riscv/microchip_pfsoc.h
29
@@ -XXX,XX +XXX,XX @@ enum {
30
MICROCHIP_PFSOC_MMUART4,
31
MICROCHIP_PFSOC_GEM0,
32
MICROCHIP_PFSOC_GEM1,
33
+ MICROCHIP_PFSOC_GPIO0,
34
+ MICROCHIP_PFSOC_GPIO1,
35
+ MICROCHIP_PFSOC_GPIO2,
36
MICROCHIP_PFSOC_ENVM_CFG,
37
MICROCHIP_PFSOC_ENVM_DATA,
38
MICROCHIP_PFSOC_IOSCB_CFG,
39
diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c
19
diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c
40
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
41
--- a/hw/riscv/microchip_pfsoc.c
21
--- a/hw/riscv/microchip_pfsoc.c
42
+++ b/hw/riscv/microchip_pfsoc.c
22
+++ b/hw/riscv/microchip_pfsoc.c
43
@@ -XXX,XX +XXX,XX @@ static const struct MemmapEntry {
23
@@ -XXX,XX +XXX,XX @@ static void microchip_icicle_kit_machine_init(MachineState *machine)
44
[MICROCHIP_PFSOC_MMUART4] = { 0x20106000, 0x1000 },
24
MemoryRegion *mem_low_alias = g_new(MemoryRegion, 1);
45
[MICROCHIP_PFSOC_GEM0] = { 0x20110000, 0x2000 },
25
MemoryRegion *mem_high = g_new(MemoryRegion, 1);
46
[MICROCHIP_PFSOC_GEM1] = { 0x20112000, 0x2000 },
26
MemoryRegion *mem_high_alias = g_new(MemoryRegion, 1);
47
+ [MICROCHIP_PFSOC_GPIO0] = { 0x20120000, 0x1000 },
27
- uint64_t mem_high_size;
48
+ [MICROCHIP_PFSOC_GPIO1] = { 0x20121000, 0x1000 },
28
+ uint64_t mem_low_size, mem_high_size;
49
+ [MICROCHIP_PFSOC_GPIO2] = { 0x20122000, 0x1000 },
29
hwaddr firmware_load_addr;
50
[MICROCHIP_PFSOC_ENVM_CFG] = { 0x20200000, 0x1000 },
30
const char *firmware_name;
51
[MICROCHIP_PFSOC_ENVM_DATA] = { 0x20220000, 0x20000 },
31
bool kernel_as_payload = false;
52
[MICROCHIP_PFSOC_IOSCB_CFG] = { 0x37080000, 0x1000 },
32
@@ -XXX,XX +XXX,XX @@ static void microchip_icicle_kit_machine_init(MachineState *machine)
53
@@ -XXX,XX +XXX,XX @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp)
33
TYPE_MICROCHIP_PFSOC);
54
sysbus_connect_irq(SYS_BUS_DEVICE(&s->gem1), 0,
34
qdev_realize(DEVICE(&s->soc), NULL, &error_abort);
55
qdev_get_gpio_in(DEVICE(s->plic), MICROCHIP_PFSOC_GEM1_IRQ));
35
56
36
+ /* Split RAM into low and high regions using aliases to machine->ram */
57
+ /* GPIOs */
37
+ mem_low_size = memmap[MICROCHIP_PFSOC_DRAM_LO].size;
58
+ create_unimplemented_device("microchip.pfsoc.gpio0",
38
+ mem_high_size = machine->ram_size - mem_low_size;
59
+ memmap[MICROCHIP_PFSOC_GPIO0].base,
39
+ memory_region_init_alias(mem_low, NULL,
60
+ memmap[MICROCHIP_PFSOC_GPIO0].size);
40
+ "microchip.icicle.kit.ram_low", machine->ram,
61
+ create_unimplemented_device("microchip.pfsoc.gpio1",
41
+ 0, mem_low_size);
62
+ memmap[MICROCHIP_PFSOC_GPIO1].base,
42
+ memory_region_init_alias(mem_high, NULL,
63
+ memmap[MICROCHIP_PFSOC_GPIO1].size);
43
+ "microchip.icicle.kit.ram_high", machine->ram,
64
+ create_unimplemented_device("microchip.pfsoc.gpio2",
44
+ mem_low_size, mem_high_size);
65
+ memmap[MICROCHIP_PFSOC_GPIO2].base,
66
+ memmap[MICROCHIP_PFSOC_GPIO2].size);
67
+
45
+
68
/* eNVM */
46
/* Register RAM */
69
memory_region_init_rom(envm_data, OBJECT(dev), "microchip.pfsoc.envm.data",
47
- memory_region_init_ram(mem_low, NULL, "microchip.icicle.kit.ram_low",
70
memmap[MICROCHIP_PFSOC_ENVM_DATA].size,
48
- memmap[MICROCHIP_PFSOC_DRAM_LO].size,
49
- &error_fatal);
50
- memory_region_init_alias(mem_low_alias, NULL,
51
- "microchip.icicle.kit.ram_low.alias",
52
- mem_low, 0,
53
- memmap[MICROCHIP_PFSOC_DRAM_LO_ALIAS].size);
54
memory_region_add_subregion(system_memory,
55
memmap[MICROCHIP_PFSOC_DRAM_LO].base,
56
mem_low);
57
+ memory_region_add_subregion(system_memory,
58
+ memmap[MICROCHIP_PFSOC_DRAM_HI].base,
59
+ mem_high);
60
+
61
+ /* Create aliases for the low and high RAM regions */
62
+ memory_region_init_alias(mem_low_alias, NULL,
63
+ "microchip.icicle.kit.ram_low.alias",
64
+ mem_low, 0, mem_low_size);
65
memory_region_add_subregion(system_memory,
66
memmap[MICROCHIP_PFSOC_DRAM_LO_ALIAS].base,
67
mem_low_alias);
68
-
69
- mem_high_size = machine->ram_size - 1 * GiB;
70
-
71
- memory_region_init_ram(mem_high, NULL, "microchip.icicle.kit.ram_high",
72
- mem_high_size, &error_fatal);
73
memory_region_init_alias(mem_high_alias, NULL,
74
"microchip.icicle.kit.ram_high.alias",
75
mem_high, 0, mem_high_size);
76
- memory_region_add_subregion(system_memory,
77
- memmap[MICROCHIP_PFSOC_DRAM_HI].base,
78
- mem_high);
79
memory_region_add_subregion(system_memory,
80
memmap[MICROCHIP_PFSOC_DRAM_HI_ALIAS].base,
81
mem_high_alias);
82
@@ -XXX,XX +XXX,XX @@ static void microchip_icicle_kit_machine_class_init(ObjectClass *oc, void *data)
83
MICROCHIP_PFSOC_COMPUTE_CPU_COUNT;
84
mc->min_cpus = MICROCHIP_PFSOC_MANAGEMENT_CPU_COUNT + 1;
85
mc->default_cpus = mc->min_cpus;
86
+ mc->default_ram_id = "microchip.icicle.kit.ram";
87
88
/*
89
* Map 513 MiB high memory, the mimimum required high memory size, because
71
--
90
--
72
2.28.0
91
2.31.1
73
92
74
93
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Bin Meng <bmeng.cn@gmail.com>
2
2
3
Now that we have the newly introduced 'resetvec' property in the
3
Using memory_region_init_ram(), which can't possibly handle vhost-user,
4
RISC-V CPU and HART, instead of hard-coding the reset vector addr
4
and can't work as expected with '-numa node,memdev' options.
5
in the CPU's instance_init(), move that to riscv_cpu_realize()
6
based on the configured property value from the RISC-V machines.
7
5
8
Signed-off-by: Bin Meng <bin.meng@windriver.com>
6
Use MachineState::ram instead of manually initializing RAM memory
7
region, as well as by providing MachineClass::default_ram_id to
8
opt in to memdev scheme.
9
10
While at it add check for user supplied RAM size and error out if it
11
mismatches board expected value.
12
13
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
14
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
15
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
16
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
11
Message-Id: <1598924352-89526-4-git-send-email-bmeng.cn@gmail.com>
17
Message-id: 20211020014112.7336-3-bmeng.cn@gmail.com
12
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
18
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
13
---
19
---
14
hw/riscv/opentitan.c | 1 +
20
hw/riscv/opentitan.c | 16 ++++++++++++----
15
hw/riscv/sifive_e.c | 1 +
21
1 file changed, 12 insertions(+), 4 deletions(-)
16
hw/riscv/sifive_u.c | 2 ++
17
target/riscv/cpu.c | 7 ++-----
18
4 files changed, 6 insertions(+), 5 deletions(-)
19
22
20
diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c
23
diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c
21
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/riscv/opentitan.c
25
--- a/hw/riscv/opentitan.c
23
+++ b/hw/riscv/opentitan.c
26
+++ b/hw/riscv/opentitan.c
24
@@ -XXX,XX +XXX,XX @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **errp)
27
@@ -XXX,XX +XXX,XX @@
25
&error_abort);
28
*/
26
object_property_set_int(OBJECT(&s->cpus), "num-harts", ms->smp.cpus,
29
27
&error_abort);
30
#include "qemu/osdep.h"
28
+ object_property_set_int(OBJECT(&s->cpus), "resetvec", 0x8090, &error_abort);
31
+#include "qemu/cutils.h"
29
sysbus_realize(SYS_BUS_DEVICE(&s->cpus), &error_abort);
32
#include "hw/riscv/opentitan.h"
30
33
#include "qapi/error.h"
31
/* Boot ROM */
34
#include "hw/boards.h"
32
diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c
35
@@ -XXX,XX +XXX,XX @@ static const MemMapEntry ibex_memmap[] = {
33
index XXXXXXX..XXXXXXX 100644
36
34
--- a/hw/riscv/sifive_e.c
37
static void opentitan_board_init(MachineState *machine)
35
+++ b/hw/riscv/sifive_e.c
38
{
36
@@ -XXX,XX +XXX,XX @@ static void sifive_e_soc_init(Object *obj)
39
+ MachineClass *mc = MACHINE_GET_CLASS(machine);
37
object_initialize_child(obj, "cpus", &s->cpus, TYPE_RISCV_HART_ARRAY);
40
const MemMapEntry *memmap = ibex_memmap;
38
object_property_set_int(OBJECT(&s->cpus), "num-harts", ms->smp.cpus,
41
OpenTitanState *s = g_new0(OpenTitanState, 1);
39
&error_abort);
42
MemoryRegion *sys_mem = get_system_memory();
40
+ object_property_set_int(OBJECT(&s->cpus), "resetvec", 0x1004, &error_abort);
43
- MemoryRegion *main_mem = g_new(MemoryRegion, 1);
41
object_initialize_child(obj, "riscv.sifive.e.gpio0", &s->gpio,
44
+
42
TYPE_SIFIVE_GPIO);
45
+ if (machine->ram_size != mc->default_ram_size) {
46
+ char *sz = size_to_str(mc->default_ram_size);
47
+ error_report("Invalid RAM size, should be %s", sz);
48
+ g_free(sz);
49
+ exit(EXIT_FAILURE);
50
+ }
51
52
/* Initialize SoC */
53
object_initialize_child(OBJECT(machine), "soc", &s->soc,
54
TYPE_RISCV_IBEX_SOC);
55
qdev_realize(DEVICE(&s->soc), NULL, &error_abort);
56
57
- memory_region_init_ram(main_mem, NULL, "riscv.lowrisc.ibex.ram",
58
- memmap[IBEX_DEV_RAM].size, &error_fatal);
59
memory_region_add_subregion(sys_mem,
60
- memmap[IBEX_DEV_RAM].base, main_mem);
61
+ memmap[IBEX_DEV_RAM].base, machine->ram);
62
63
if (machine->firmware) {
64
riscv_load_firmware(machine->firmware, memmap[IBEX_DEV_RAM].base, NULL);
65
@@ -XXX,XX +XXX,XX @@ static void opentitan_machine_init(MachineClass *mc)
66
mc->init = opentitan_board_init;
67
mc->max_cpus = 1;
68
mc->default_cpu_type = TYPE_RISCV_CPU_IBEX;
69
+ mc->default_ram_id = "riscv.lowrisc.ibex.ram";
70
+ mc->default_ram_size = ibex_memmap[IBEX_DEV_RAM].size;
43
}
71
}
44
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
72
45
index XXXXXXX..XXXXXXX 100644
73
DEFINE_MACHINE("opentitan", opentitan_machine_init)
46
--- a/hw/riscv/sifive_u.c
47
+++ b/hw/riscv/sifive_u.c
48
@@ -XXX,XX +XXX,XX @@ static void sifive_u_soc_instance_init(Object *obj)
49
qdev_prop_set_uint32(DEVICE(&s->e_cpus), "num-harts", 1);
50
qdev_prop_set_uint32(DEVICE(&s->e_cpus), "hartid-base", 0);
51
qdev_prop_set_string(DEVICE(&s->e_cpus), "cpu-type", SIFIVE_E_CPU);
52
+ qdev_prop_set_uint64(DEVICE(&s->e_cpus), "resetvec", 0x1004);
53
54
object_initialize_child(obj, "u-cluster", &s->u_cluster, TYPE_CPU_CLUSTER);
55
qdev_prop_set_uint32(DEVICE(&s->u_cluster), "cluster-id", 1);
56
@@ -XXX,XX +XXX,XX @@ static void sifive_u_soc_instance_init(Object *obj)
57
qdev_prop_set_uint32(DEVICE(&s->u_cpus), "num-harts", ms->smp.cpus - 1);
58
qdev_prop_set_uint32(DEVICE(&s->u_cpus), "hartid-base", 1);
59
qdev_prop_set_string(DEVICE(&s->u_cpus), "cpu-type", SIFIVE_U_CPU);
60
+ qdev_prop_set_uint64(DEVICE(&s->u_cpus), "resetvec", 0x1004);
61
62
object_initialize_child(obj, "prci", &s->prci, TYPE_SIFIVE_U_PRCI);
63
object_initialize_child(obj, "otp", &s->otp, TYPE_SIFIVE_U_OTP);
64
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
65
index XXXXXXX..XXXXXXX 100644
66
--- a/target/riscv/cpu.c
67
+++ b/target/riscv/cpu.c
68
@@ -XXX,XX +XXX,XX @@ static void riscv_any_cpu_init(Object *obj)
69
CPURISCVState *env = &RISCV_CPU(obj)->env;
70
set_misa(env, RVXLEN | RVI | RVM | RVA | RVF | RVD | RVC | RVU);
71
set_priv_version(env, PRIV_VERSION_1_11_0);
72
- set_resetvec(env, DEFAULT_RSTVEC);
73
}
74
75
static void riscv_base_cpu_init(Object *obj)
76
@@ -XXX,XX +XXX,XX @@ static void riscv_base_cpu_init(Object *obj)
77
CPURISCVState *env = &RISCV_CPU(obj)->env;
78
/* We set this in the realise function */
79
set_misa(env, 0);
80
- set_resetvec(env, DEFAULT_RSTVEC);
81
}
82
83
static void rvxx_sifive_u_cpu_init(Object *obj)
84
@@ -XXX,XX +XXX,XX @@ static void rvxx_sifive_u_cpu_init(Object *obj)
85
CPURISCVState *env = &RISCV_CPU(obj)->env;
86
set_misa(env, RVXLEN | RVI | RVM | RVA | RVF | RVD | RVC | RVS | RVU);
87
set_priv_version(env, PRIV_VERSION_1_10_0);
88
- set_resetvec(env, 0x1004);
89
}
90
91
static void rvxx_sifive_e_cpu_init(Object *obj)
92
@@ -XXX,XX +XXX,XX @@ static void rvxx_sifive_e_cpu_init(Object *obj)
93
CPURISCVState *env = &RISCV_CPU(obj)->env;
94
set_misa(env, RVXLEN | RVI | RVM | RVA | RVC | RVU);
95
set_priv_version(env, PRIV_VERSION_1_10_0);
96
- set_resetvec(env, 0x1004);
97
qdev_prop_set_bit(DEVICE(obj), "mmu", false);
98
}
99
100
@@ -XXX,XX +XXX,XX @@ static void rv32_ibex_cpu_init(Object *obj)
101
CPURISCVState *env = &RISCV_CPU(obj)->env;
102
set_misa(env, RV32 | RVI | RVM | RVC | RVU);
103
set_priv_version(env, PRIV_VERSION_1_10_0);
104
- set_resetvec(env, 0x8090);
105
qdev_prop_set_bit(DEVICE(obj), "mmu", false);
106
}
107
108
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
109
set_feature(env, RISCV_FEATURE_PMP);
110
}
111
112
+ set_resetvec(env, cpu->cfg.resetvec);
113
+
114
/* If misa isn't set (rv32 and rv64 machines) set it here */
115
if (!env->misa) {
116
/* Do some ISA extension error checking */
117
--
74
--
118
2.28.0
75
2.31.1
119
76
120
77
diff view generated by jsdifflib
1
From: Nathan Chancellor <natechancellor@gmail.com>
1
From: Bin Meng <bmeng.cn@gmail.com>
2
2
3
When shutting down the machine running a mainline Linux kernel, the
3
Using memory_region_init_ram(), which can't possibly handle vhost-user,
4
following error happens:
4
and can't work as expected with '-numa node,memdev' options.
5
5
6
$ build/riscv64-softmmu/qemu-system-riscv64 -bios default -M virt \
6
Use MachineState::ram instead of manually initializing RAM memory
7
-display none -initrd rootfs.cpio -kernel Image -m 512m \
7
region, as well as by providing MachineClass::default_ram_id to
8
-nodefaults -serial mon:stdio
8
opt in to memdev scheme.
9
...
10
Requesting system poweroff
11
[ 4.999630] reboot: Power down
12
sbi_trap_error: hart0: trap handler failed (error -2)
13
sbi_trap_error: hart0: mcause=0x0000000000000007 mtval=0x0000000000100000
14
sbi_trap_error: hart0: mepc=0x000000008000d4cc mstatus=0x0000000000001822
15
sbi_trap_error: hart0: ra=0x000000008000999e sp=0x0000000080015c78
16
sbi_trap_error: hart0: gp=0xffffffe000e76610 tp=0xffffffe0081b89c0
17
sbi_trap_error: hart0: s0=0x0000000080015c88 s1=0x0000000000000040
18
sbi_trap_error: hart0: a0=0x0000000000000000 a1=0x0000000080004024
19
sbi_trap_error: hart0: a2=0x0000000080004024 a3=0x0000000080004024
20
sbi_trap_error: hart0: a4=0x0000000000100000 a5=0x0000000000005555
21
sbi_trap_error: hart0: a6=0x0000000000004024 a7=0x0000000080011158
22
sbi_trap_error: hart0: s2=0x0000000000000000 s3=0x0000000080016000
23
sbi_trap_error: hart0: s4=0x0000000000000000 s5=0x0000000000000000
24
sbi_trap_error: hart0: s6=0x0000000000000001 s7=0x0000000000000000
25
sbi_trap_error: hart0: s8=0x0000000000000000 s9=0x0000000000000000
26
sbi_trap_error: hart0: s10=0x0000000000000000 s11=0x0000000000000008
27
sbi_trap_error: hart0: t0=0x0000000000000000 t1=0x0000000000000000
28
sbi_trap_error: hart0: t2=0x0000000000000000 t3=0x0000000000000000
29
sbi_trap_error: hart0: t4=0x0000000000000000 t5=0x0000000000000000
30
sbi_trap_error: hart0: t6=0x0000000000000000
31
9
32
The kernel does a 16-bit write when powering off the machine, which
10
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
33
was allowed before commit 5d971f9e67 ("memory: Revert "memory: accept
11
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
34
mismatching sizes in memory_region_access_valid""). Make min_access_size
12
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
35
match reality so that the machine can shut down properly now.
36
37
Cc: qemu-stable@nongnu.org
38
Fixes: 88a07990fa ("SiFive RISC-V Test Finisher")
39
Fixes: 5d971f9e67 ("memory: Revert "memory: accept mismatching sizes in memory_region_access_valid"")
40
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
41
Acked-by: Michael S. Tsirkin <mst@redhat.com>
42
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
13
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
43
Message-Id: <20200901055822.2721209-1-natechancellor@gmail.com>
14
Message-id: 20211020014112.7336-4-bmeng.cn@gmail.com
44
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
15
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
45
---
16
---
46
hw/riscv/sifive_test.c | 2 +-
17
hw/riscv/shakti_c.c | 6 ++----
47
1 file changed, 1 insertion(+), 1 deletion(-)
18
1 file changed, 2 insertions(+), 4 deletions(-)
48
19
49
diff --git a/hw/riscv/sifive_test.c b/hw/riscv/sifive_test.c
20
diff --git a/hw/riscv/shakti_c.c b/hw/riscv/shakti_c.c
50
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
51
--- a/hw/riscv/sifive_test.c
22
--- a/hw/riscv/shakti_c.c
52
+++ b/hw/riscv/sifive_test.c
23
+++ b/hw/riscv/shakti_c.c
53
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps sifive_test_ops = {
24
@@ -XXX,XX +XXX,XX @@ static void shakti_c_machine_state_init(MachineState *mstate)
54
.write = sifive_test_write,
25
{
55
.endianness = DEVICE_NATIVE_ENDIAN,
26
ShaktiCMachineState *sms = RISCV_SHAKTI_MACHINE(mstate);
56
.valid = {
27
MemoryRegion *system_memory = get_system_memory();
57
- .min_access_size = 4,
28
- MemoryRegion *main_mem = g_new(MemoryRegion, 1);
58
+ .min_access_size = 2,
29
59
.max_access_size = 4
30
/* Allow only Shakti C CPU for this platform */
60
}
31
if (strcmp(mstate->cpu_type, TYPE_RISCV_CPU_SHAKTI_C) != 0) {
61
};
32
@@ -XXX,XX +XXX,XX @@ static void shakti_c_machine_state_init(MachineState *mstate)
33
qdev_realize(DEVICE(&sms->soc), NULL, &error_abort);
34
35
/* register RAM */
36
- memory_region_init_ram(main_mem, NULL, "riscv.shakti.c.ram",
37
- mstate->ram_size, &error_fatal);
38
memory_region_add_subregion(system_memory,
39
shakti_c_memmap[SHAKTI_C_RAM].base,
40
- main_mem);
41
+ mstate->ram);
42
43
/* ROM reset vector */
44
riscv_setup_rom_reset_vec(mstate, &sms->soc.cpus,
45
@@ -XXX,XX +XXX,XX @@ static void shakti_c_machine_class_init(ObjectClass *klass, void *data)
46
mc->desc = "RISC-V Board compatible with Shakti SDK";
47
mc->init = shakti_c_machine_state_init;
48
mc->default_cpu_type = TYPE_RISCV_CPU_SHAKTI_C;
49
+ mc->default_ram_id = "riscv.shakti.c.ram";
50
}
51
52
static const TypeInfo shakti_c_machine_type_info = {
62
--
53
--
63
2.28.0
54
2.31.1
64
55
65
56
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Bin Meng <bmeng.cn@gmail.com>
2
2
3
This is an effort to clean up the hw/riscv directory. Ideally it
3
Using memory_region_init_ram(), which can't possibly handle vhost-user,
4
should only contain the RISC-V SoC / machine codes plus generic
4
and can't work as expected with '-numa node,memdev' options.
5
codes. Let's move sifive_e_prci model to hw/misc directory.
6
5
7
Signed-off-by: Bin Meng <bin.meng@windriver.com>
6
Use MachineState::ram instead of manually initializing RAM memory
7
region, as well as by providing MachineClass::default_ram_id to
8
opt in to memdev scheme.
9
10
While at it add check for user supplied RAM size and error out if it
11
mismatches board expected value.
12
13
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
14
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
15
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-Id: <1599129623-68957-2-git-send-email-bmeng.cn@gmail.com>
16
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
17
Message-id: 20211020014112.7336-5-bmeng.cn@gmail.com
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
18
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
19
---
12
include/hw/{riscv => misc}/sifive_e_prci.h | 0
20
hw/riscv/sifive_e.c | 16 ++++++++++++----
13
hw/{riscv => misc}/sifive_e_prci.c | 2 +-
21
1 file changed, 12 insertions(+), 4 deletions(-)
14
hw/riscv/sifive_e.c | 2 +-
15
hw/misc/Kconfig | 3 +++
16
hw/misc/meson.build | 3 +++
17
hw/riscv/Kconfig | 1 +
18
hw/riscv/meson.build | 1 -
19
7 files changed, 9 insertions(+), 3 deletions(-)
20
rename include/hw/{riscv => misc}/sifive_e_prci.h (100%)
21
rename hw/{riscv => misc}/sifive_e_prci.c (99%)
22
22
23
diff --git a/include/hw/riscv/sifive_e_prci.h b/include/hw/misc/sifive_e_prci.h
24
similarity index 100%
25
rename from include/hw/riscv/sifive_e_prci.h
26
rename to include/hw/misc/sifive_e_prci.h
27
diff --git a/hw/riscv/sifive_e_prci.c b/hw/misc/sifive_e_prci.c
28
similarity index 99%
29
rename from hw/riscv/sifive_e_prci.c
30
rename to hw/misc/sifive_e_prci.c
31
index XXXXXXX..XXXXXXX 100644
32
--- a/hw/riscv/sifive_e_prci.c
33
+++ b/hw/misc/sifive_e_prci.c
34
@@ -XXX,XX +XXX,XX @@
35
#include "qemu/log.h"
36
#include "qemu/module.h"
37
#include "hw/hw.h"
38
-#include "hw/riscv/sifive_e_prci.h"
39
+#include "hw/misc/sifive_e_prci.h"
40
41
static uint64_t sifive_e_prci_read(void *opaque, hwaddr addr, unsigned int size)
42
{
43
diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c
23
diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c
44
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
45
--- a/hw/riscv/sifive_e.c
25
--- a/hw/riscv/sifive_e.c
46
+++ b/hw/riscv/sifive_e.c
26
+++ b/hw/riscv/sifive_e.c
47
@@ -XXX,XX +XXX,XX @@
27
@@ -XXX,XX +XXX,XX @@
48
#include "hw/riscv/sifive_clint.h"
28
*/
49
#include "hw/riscv/sifive_uart.h"
29
50
#include "hw/riscv/sifive_e.h"
30
#include "qemu/osdep.h"
51
-#include "hw/riscv/sifive_e_prci.h"
31
+#include "qemu/cutils.h"
52
#include "hw/riscv/boot.h"
32
#include "qemu/error-report.h"
53
+#include "hw/misc/sifive_e_prci.h"
33
#include "qapi/error.h"
54
#include "chardev/char.h"
34
#include "hw/boards.h"
55
#include "sysemu/arch_init.h"
35
@@ -XXX,XX +XXX,XX @@ static const MemMapEntry sifive_e_memmap[] = {
56
#include "sysemu/sysemu.h"
36
57
diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
37
static void sifive_e_machine_init(MachineState *machine)
58
index XXXXXXX..XXXXXXX 100644
38
{
59
--- a/hw/misc/Kconfig
39
+ MachineClass *mc = MACHINE_GET_CLASS(machine);
60
+++ b/hw/misc/Kconfig
40
const MemMapEntry *memmap = sifive_e_memmap;
61
@@ -XXX,XX +XXX,XX @@ config MAC_VIA
41
62
config AVR_POWER
42
SiFiveEState *s = RISCV_E_MACHINE(machine);
63
bool
43
MemoryRegion *sys_mem = get_system_memory();
64
44
- MemoryRegion *main_mem = g_new(MemoryRegion, 1);
65
+config SIFIVE_E_PRCI
45
int i;
66
+ bool
46
47
+ if (machine->ram_size != mc->default_ram_size) {
48
+ char *sz = size_to_str(mc->default_ram_size);
49
+ error_report("Invalid RAM size, should be %s", sz);
50
+ g_free(sz);
51
+ exit(EXIT_FAILURE);
52
+ }
67
+
53
+
68
source macio/Kconfig
54
/* Initialize SoC */
69
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
55
object_initialize_child(OBJECT(machine), "soc", &s->soc, TYPE_RISCV_E_SOC);
70
index XXXXXXX..XXXXXXX 100644
56
qdev_realize(DEVICE(&s->soc), NULL, &error_abort);
71
--- a/hw/misc/meson.build
57
72
+++ b/hw/misc/meson.build
58
/* Data Tightly Integrated Memory */
73
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_ARM11SCU', if_true: files('arm11scu.c'))
59
- memory_region_init_ram(main_mem, NULL, "riscv.sifive.e.ram",
74
# Mac devices
60
- memmap[SIFIVE_E_DEV_DTIM].size, &error_fatal);
75
softmmu_ss.add(when: 'CONFIG_MOS6522', if_true: files('mos6522.c'))
61
memory_region_add_subregion(sys_mem,
76
62
- memmap[SIFIVE_E_DEV_DTIM].base, main_mem);
77
+# RISC-V devices
63
+ memmap[SIFIVE_E_DEV_DTIM].base, machine->ram);
78
+softmmu_ss.add(when: 'CONFIG_SIFIVE_E_PRCI', if_true: files('sifive_e_prci.c'))
64
79
+
65
/* Mask ROM reset vector */
80
# PKUnity SoC devices
66
uint32_t reset_vec[4];
81
softmmu_ss.add(when: 'CONFIG_PUV3', if_true: files('puv3_pm.c'))
67
@@ -XXX,XX +XXX,XX @@ static void sifive_e_machine_class_init(ObjectClass *oc, void *data)
82
68
mc->init = sifive_e_machine_init;
83
diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
69
mc->max_cpus = 1;
84
index XXXXXXX..XXXXXXX 100644
70
mc->default_cpu_type = SIFIVE_E_CPU;
85
--- a/hw/riscv/Kconfig
71
+ mc->default_ram_id = "riscv.sifive.e.ram";
86
+++ b/hw/riscv/Kconfig
72
+ mc->default_ram_size = sifive_e_memmap[SIFIVE_E_DEV_DTIM].size;
87
@@ -XXX,XX +XXX,XX @@ config SIFIVE_E
73
88
bool
74
object_class_property_add_bool(oc, "revb", sifive_e_machine_get_revb,
89
select HART
75
sifive_e_machine_set_revb);
90
select SIFIVE
91
+ select SIFIVE_E_PRCI
92
select UNIMP
93
94
config SIFIVE_U
95
diff --git a/hw/riscv/meson.build b/hw/riscv/meson.build
96
index XXXXXXX..XXXXXXX 100644
97
--- a/hw/riscv/meson.build
98
+++ b/hw/riscv/meson.build
99
@@ -XXX,XX +XXX,XX @@ riscv_ss.add(when: 'CONFIG_SIFIVE', if_true: files('sifive_plic.c'))
100
riscv_ss.add(when: 'CONFIG_SIFIVE', if_true: files('sifive_test.c'))
101
riscv_ss.add(when: 'CONFIG_SIFIVE', if_true: files('sifive_uart.c'))
102
riscv_ss.add(when: 'CONFIG_SIFIVE_E', if_true: files('sifive_e.c'))
103
-riscv_ss.add(when: 'CONFIG_SIFIVE_E', if_true: files('sifive_e_prci.c'))
104
riscv_ss.add(when: 'CONFIG_SIFIVE_U', if_true: files('sifive_u.c'))
105
riscv_ss.add(when: 'CONFIG_SIFIVE_U', if_true: files('sifive_u_otp.c'))
106
riscv_ss.add(when: 'CONFIG_SIFIVE_U', if_true: files('sifive_u_prci.c'))
107
--
76
--
108
2.28.0
77
2.31.1
109
78
110
79
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Bin Meng <bmeng.cn@gmail.com>
2
2
3
This is an effort to clean up the hw/riscv directory. Ideally it
3
Using memory_region_init_ram(), which can't possibly handle vhost-user,
4
should only contain the RISC-V SoC / machine codes plus generic
4
and can't work as expected with '-numa node,memdev' options.
5
codes. Let's move sifive_uart model to hw/char directory.
6
5
7
Signed-off-by: Bin Meng <bin.meng@windriver.com>
6
Use MachineState::ram instead of manually initializing RAM memory
7
region, as well as by providing MachineClass::default_ram_id to
8
opt in to memdev scheme.
9
10
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
11
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
13
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-Id: <1599129623-68957-9-git-send-email-bmeng.cn@gmail.com>
14
Message-id: 20211020014112.7336-6-bmeng.cn@gmail.com
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
15
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
16
---
12
include/hw/{riscv => char}/sifive_uart.h | 0
17
hw/riscv/sifive_u.c | 6 ++----
13
hw/{riscv => char}/sifive_uart.c | 2 +-
18
1 file changed, 2 insertions(+), 4 deletions(-)
14
hw/riscv/sifive_e.c | 2 +-
15
hw/riscv/sifive_u.c | 2 +-
16
hw/char/Kconfig | 3 +++
17
hw/char/meson.build | 1 +
18
hw/riscv/Kconfig | 2 ++
19
hw/riscv/meson.build | 1 -
20
8 files changed, 9 insertions(+), 4 deletions(-)
21
rename include/hw/{riscv => char}/sifive_uart.h (100%)
22
rename hw/{riscv => char}/sifive_uart.c (99%)
23
19
24
diff --git a/include/hw/riscv/sifive_uart.h b/include/hw/char/sifive_uart.h
25
similarity index 100%
26
rename from include/hw/riscv/sifive_uart.h
27
rename to include/hw/char/sifive_uart.h
28
diff --git a/hw/riscv/sifive_uart.c b/hw/char/sifive_uart.c
29
similarity index 99%
30
rename from hw/riscv/sifive_uart.c
31
rename to hw/char/sifive_uart.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/hw/riscv/sifive_uart.c
34
+++ b/hw/char/sifive_uart.c
35
@@ -XXX,XX +XXX,XX @@
36
#include "chardev/char-fe.h"
37
#include "hw/hw.h"
38
#include "hw/irq.h"
39
-#include "hw/riscv/sifive_uart.h"
40
+#include "hw/char/sifive_uart.h"
41
42
/*
43
* Not yet implemented:
44
diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/hw/riscv/sifive_e.c
47
+++ b/hw/riscv/sifive_e.c
48
@@ -XXX,XX +XXX,XX @@
49
#include "hw/misc/unimp.h"
50
#include "target/riscv/cpu.h"
51
#include "hw/riscv/riscv_hart.h"
52
-#include "hw/riscv/sifive_uart.h"
53
#include "hw/riscv/sifive_e.h"
54
#include "hw/riscv/boot.h"
55
+#include "hw/char/sifive_uart.h"
56
#include "hw/intc/sifive_clint.h"
57
#include "hw/intc/sifive_plic.h"
58
#include "hw/misc/sifive_e_prci.h"
59
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
20
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
60
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
61
--- a/hw/riscv/sifive_u.c
22
--- a/hw/riscv/sifive_u.c
62
+++ b/hw/riscv/sifive_u.c
23
+++ b/hw/riscv/sifive_u.c
63
@@ -XXX,XX +XXX,XX @@
24
@@ -XXX,XX +XXX,XX @@ static void sifive_u_machine_init(MachineState *machine)
64
#include "hw/misc/unimp.h"
25
const MemMapEntry *memmap = sifive_u_memmap;
65
#include "target/riscv/cpu.h"
26
SiFiveUState *s = RISCV_U_MACHINE(machine);
66
#include "hw/riscv/riscv_hart.h"
27
MemoryRegion *system_memory = get_system_memory();
67
-#include "hw/riscv/sifive_uart.h"
28
- MemoryRegion *main_mem = g_new(MemoryRegion, 1);
68
#include "hw/riscv/sifive_u.h"
29
MemoryRegion *flash0 = g_new(MemoryRegion, 1);
69
#include "hw/riscv/boot.h"
30
target_ulong start_addr = memmap[SIFIVE_U_DEV_DRAM].base;
70
+#include "hw/char/sifive_uart.h"
31
target_ulong firmware_end_addr, kernel_start_addr;
71
#include "hw/intc/sifive_clint.h"
32
@@ -XXX,XX +XXX,XX @@ static void sifive_u_machine_init(MachineState *machine)
72
#include "hw/intc/sifive_plic.h"
33
qdev_realize(DEVICE(&s->soc), NULL, &error_abort);
73
#include "chardev/char.h"
34
74
diff --git a/hw/char/Kconfig b/hw/char/Kconfig
35
/* register RAM */
75
index XXXXXXX..XXXXXXX 100644
36
- memory_region_init_ram(main_mem, NULL, "riscv.sifive.u.ram",
76
--- a/hw/char/Kconfig
37
- machine->ram_size, &error_fatal);
77
+++ b/hw/char/Kconfig
38
memory_region_add_subregion(system_memory, memmap[SIFIVE_U_DEV_DRAM].base,
78
@@ -XXX,XX +XXX,XX @@ config AVR_USART
39
- main_mem);
79
40
+ machine->ram);
80
config MCHP_PFSOC_MMUART
41
81
bool
42
/* register QSPI0 Flash */
82
+
43
memory_region_init_ram(flash0, NULL, "riscv.sifive.u.flash0",
83
+config SIFIVE_UART
44
@@ -XXX,XX +XXX,XX @@ static void sifive_u_machine_class_init(ObjectClass *oc, void *data)
84
+ bool
45
mc->min_cpus = SIFIVE_U_MANAGEMENT_CPU_COUNT + 1;
85
diff --git a/hw/char/meson.build b/hw/char/meson.build
46
mc->default_cpu_type = SIFIVE_U_CPU;
86
index XXXXXXX..XXXXXXX 100644
47
mc->default_cpus = mc->min_cpus;
87
--- a/hw/char/meson.build
48
+ mc->default_ram_id = "riscv.sifive.u.ram";
88
+++ b/hw/char/meson.build
49
89
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_EXYNOS4', if_true: files('exynos4210_uart.c'))
50
object_class_property_add_bool(oc, "start-in-flash",
90
softmmu_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_uart.c'))
51
sifive_u_machine_get_start_in_flash,
91
softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_aux.c'))
92
softmmu_ss.add(when: 'CONFIG_RENESAS_SCI', if_true: files('renesas_sci.c'))
93
+softmmu_ss.add(when: 'CONFIG_SIFIVE_UART', if_true: files('sifive_uart.c'))
94
softmmu_ss.add(when: 'CONFIG_SH4', if_true: files('sh_serial.c'))
95
softmmu_ss.add(when: 'CONFIG_STM32F2XX_USART', if_true: files('stm32f2xx_usart.c'))
96
softmmu_ss.add(when: 'CONFIG_MCHP_PFSOC_MMUART', if_true: files('mchp_pfsoc_mmuart.c'))
97
diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
98
index XXXXXXX..XXXXXXX 100644
99
--- a/hw/riscv/Kconfig
100
+++ b/hw/riscv/Kconfig
101
@@ -XXX,XX +XXX,XX @@ config SIFIVE_E
102
select SIFIVE_CLINT
103
select SIFIVE_GPIO
104
select SIFIVE_PLIC
105
+ select SIFIVE_UART
106
select SIFIVE_E_PRCI
107
select UNIMP
108
109
@@ -XXX,XX +XXX,XX @@ config SIFIVE_U
110
select SIFIVE_GPIO
111
select SIFIVE_PDMA
112
select SIFIVE_PLIC
113
+ select SIFIVE_UART
114
select SIFIVE_U_OTP
115
select SIFIVE_U_PRCI
116
select UNIMP
117
diff --git a/hw/riscv/meson.build b/hw/riscv/meson.build
118
index XXXXXXX..XXXXXXX 100644
119
--- a/hw/riscv/meson.build
120
+++ b/hw/riscv/meson.build
121
@@ -XXX,XX +XXX,XX @@ riscv_ss.add(when: 'CONFIG_HART', if_true: files('riscv_hart.c'))
122
riscv_ss.add(when: 'CONFIG_OPENTITAN', if_true: files('opentitan.c'))
123
riscv_ss.add(when: 'CONFIG_RISCV_VIRT', if_true: files('virt.c'))
124
riscv_ss.add(when: 'CONFIG_SIFIVE', if_true: files('sifive_test.c'))
125
-riscv_ss.add(when: 'CONFIG_SIFIVE', if_true: files('sifive_uart.c'))
126
riscv_ss.add(when: 'CONFIG_SIFIVE_E', if_true: files('sifive_e.c'))
127
riscv_ss.add(when: 'CONFIG_SIFIVE_U', if_true: files('sifive_u.c'))
128
riscv_ss.add(when: 'CONFIG_SPIKE', if_true: files('spike.c'))
129
--
52
--
130
2.28.0
53
2.31.1
131
54
132
55
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Bin Meng <bmeng.cn@gmail.com>
2
2
3
This is an effort to clean up the hw/riscv directory. Ideally it
3
Using memory_region_init_ram(), which can't possibly handle vhost-user,
4
should only contain the RISC-V SoC / machine codes plus generic
4
and can't work as expected with '-numa node,memdev' options.
5
codes. Let's move sifive_clint model to hw/intc directory.
6
5
7
Signed-off-by: Bin Meng <bin.meng@windriver.com>
6
Use MachineState::ram instead of manually initializing RAM memory
7
region, as well as by providing MachineClass::default_ram_id to
8
opt in to memdev scheme.
9
10
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
11
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
13
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-Id: <1599129623-68957-6-git-send-email-bmeng.cn@gmail.com>
14
Message-id: 20211020014112.7336-7-bmeng.cn@gmail.com
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
15
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
16
---
12
include/hw/{riscv => intc}/sifive_clint.h | 0
17
hw/riscv/spike.c | 6 ++----
13
hw/{riscv => intc}/sifive_clint.c | 2 +-
18
1 file changed, 2 insertions(+), 4 deletions(-)
14
hw/riscv/microchip_pfsoc.c | 2 +-
15
hw/riscv/sifive_e.c | 2 +-
16
hw/riscv/sifive_u.c | 2 +-
17
hw/riscv/spike.c | 2 +-
18
hw/riscv/virt.c | 2 +-
19
hw/intc/Kconfig | 3 +++
20
hw/intc/meson.build | 1 +
21
hw/riscv/Kconfig | 5 +++++
22
hw/riscv/meson.build | 1 -
23
11 files changed, 15 insertions(+), 7 deletions(-)
24
rename include/hw/{riscv => intc}/sifive_clint.h (100%)
25
rename hw/{riscv => intc}/sifive_clint.c (99%)
26
19
27
diff --git a/include/hw/riscv/sifive_clint.h b/include/hw/intc/sifive_clint.h
28
similarity index 100%
29
rename from include/hw/riscv/sifive_clint.h
30
rename to include/hw/intc/sifive_clint.h
31
diff --git a/hw/riscv/sifive_clint.c b/hw/intc/sifive_clint.c
32
similarity index 99%
33
rename from hw/riscv/sifive_clint.c
34
rename to hw/intc/sifive_clint.c
35
index XXXXXXX..XXXXXXX 100644
36
--- a/hw/riscv/sifive_clint.c
37
+++ b/hw/intc/sifive_clint.c
38
@@ -XXX,XX +XXX,XX @@
39
#include "hw/sysbus.h"
40
#include "target/riscv/cpu.h"
41
#include "hw/qdev-properties.h"
42
-#include "hw/riscv/sifive_clint.h"
43
+#include "hw/intc/sifive_clint.h"
44
#include "qemu/timer.h"
45
46
static uint64_t cpu_riscv_read_rtc(uint32_t timebase_freq)
47
diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/hw/riscv/microchip_pfsoc.c
50
+++ b/hw/riscv/microchip_pfsoc.c
51
@@ -XXX,XX +XXX,XX @@
52
#include "hw/misc/unimp.h"
53
#include "hw/riscv/boot.h"
54
#include "hw/riscv/riscv_hart.h"
55
-#include "hw/riscv/sifive_clint.h"
56
#include "hw/riscv/sifive_plic.h"
57
#include "hw/riscv/microchip_pfsoc.h"
58
+#include "hw/intc/sifive_clint.h"
59
#include "sysemu/sysemu.h"
60
61
/*
62
diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c
63
index XXXXXXX..XXXXXXX 100644
64
--- a/hw/riscv/sifive_e.c
65
+++ b/hw/riscv/sifive_e.c
66
@@ -XXX,XX +XXX,XX @@
67
#include "target/riscv/cpu.h"
68
#include "hw/riscv/riscv_hart.h"
69
#include "hw/riscv/sifive_plic.h"
70
-#include "hw/riscv/sifive_clint.h"
71
#include "hw/riscv/sifive_uart.h"
72
#include "hw/riscv/sifive_e.h"
73
#include "hw/riscv/boot.h"
74
+#include "hw/intc/sifive_clint.h"
75
#include "hw/misc/sifive_e_prci.h"
76
#include "chardev/char.h"
77
#include "sysemu/arch_init.h"
78
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
79
index XXXXXXX..XXXXXXX 100644
80
--- a/hw/riscv/sifive_u.c
81
+++ b/hw/riscv/sifive_u.c
82
@@ -XXX,XX +XXX,XX @@
83
#include "target/riscv/cpu.h"
84
#include "hw/riscv/riscv_hart.h"
85
#include "hw/riscv/sifive_plic.h"
86
-#include "hw/riscv/sifive_clint.h"
87
#include "hw/riscv/sifive_uart.h"
88
#include "hw/riscv/sifive_u.h"
89
#include "hw/riscv/boot.h"
90
+#include "hw/intc/sifive_clint.h"
91
#include "chardev/char.h"
92
#include "net/eth.h"
93
#include "sysemu/arch_init.h"
94
diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c
20
diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c
95
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
96
--- a/hw/riscv/spike.c
22
--- a/hw/riscv/spike.c
97
+++ b/hw/riscv/spike.c
23
+++ b/hw/riscv/spike.c
98
@@ -XXX,XX +XXX,XX @@
24
@@ -XXX,XX +XXX,XX @@ static void spike_board_init(MachineState *machine)
99
#include "target/riscv/cpu.h"
25
const MemMapEntry *memmap = spike_memmap;
100
#include "hw/riscv/riscv_htif.h"
26
SpikeState *s = SPIKE_MACHINE(machine);
101
#include "hw/riscv/riscv_hart.h"
27
MemoryRegion *system_memory = get_system_memory();
102
-#include "hw/riscv/sifive_clint.h"
28
- MemoryRegion *main_mem = g_new(MemoryRegion, 1);
103
#include "hw/riscv/spike.h"
29
MemoryRegion *mask_rom = g_new(MemoryRegion, 1);
104
#include "hw/riscv/boot.h"
30
target_ulong firmware_end_addr, kernel_start_addr;
105
#include "hw/riscv/numa.h"
31
uint32_t fdt_load_addr;
106
+#include "hw/intc/sifive_clint.h"
32
@@ -XXX,XX +XXX,XX @@ static void spike_board_init(MachineState *machine)
107
#include "chardev/char.h"
33
}
108
#include "sysemu/arch_init.h"
34
109
#include "sysemu/device_tree.h"
35
/* register system main memory (actual RAM) */
110
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
36
- memory_region_init_ram(main_mem, NULL, "riscv.spike.ram",
111
index XXXXXXX..XXXXXXX 100644
37
- machine->ram_size, &error_fatal);
112
--- a/hw/riscv/virt.c
38
memory_region_add_subregion(system_memory, memmap[SPIKE_DRAM].base,
113
+++ b/hw/riscv/virt.c
39
- main_mem);
114
@@ -XXX,XX +XXX,XX @@
40
+ machine->ram);
115
#include "target/riscv/cpu.h"
41
116
#include "hw/riscv/riscv_hart.h"
42
/* create device tree */
117
#include "hw/riscv/sifive_plic.h"
43
create_fdt(s, memmap, machine->ram_size, machine->kernel_cmdline,
118
-#include "hw/riscv/sifive_clint.h"
44
@@ -XXX,XX +XXX,XX @@ static void spike_machine_class_init(ObjectClass *oc, void *data)
119
#include "hw/riscv/sifive_test.h"
45
mc->cpu_index_to_instance_props = riscv_numa_cpu_index_to_props;
120
#include "hw/riscv/virt.h"
46
mc->get_default_cpu_node_id = riscv_numa_get_default_cpu_node_id;
121
#include "hw/riscv/boot.h"
47
mc->numa_mem_supported = true;
122
#include "hw/riscv/numa.h"
48
+ mc->default_ram_id = "riscv.spike.ram";
123
+#include "hw/intc/sifive_clint.h"
49
}
124
#include "chardev/char.h"
50
125
#include "sysemu/arch_init.h"
51
static const TypeInfo spike_machine_typeinfo = {
126
#include "sysemu/device_tree.h"
127
diff --git a/hw/intc/Kconfig b/hw/intc/Kconfig
128
index XXXXXXX..XXXXXXX 100644
129
--- a/hw/intc/Kconfig
130
+++ b/hw/intc/Kconfig
131
@@ -XXX,XX +XXX,XX @@ config RX_ICU
132
133
config LOONGSON_LIOINTC
134
bool
135
+
136
+config SIFIVE_CLINT
137
+ bool
138
diff --git a/hw/intc/meson.build b/hw/intc/meson.build
139
index XXXXXXX..XXXXXXX 100644
140
--- a/hw/intc/meson.build
141
+++ b/hw/intc/meson.build
142
@@ -XXX,XX +XXX,XX @@ specific_ss.add(when: 'CONFIG_RX_ICU', if_true: files('rx_icu.c'))
143
specific_ss.add(when: 'CONFIG_S390_FLIC', if_true: files('s390_flic.c'))
144
specific_ss.add(when: 'CONFIG_S390_FLIC_KVM', if_true: files('s390_flic_kvm.c'))
145
specific_ss.add(when: 'CONFIG_SH4', if_true: files('sh_intc.c'))
146
+specific_ss.add(when: 'CONFIG_SIFIVE_CLINT', if_true: files('sifive_clint.c'))
147
specific_ss.add(when: 'CONFIG_XICS', if_true: files('xics.c'))
148
specific_ss.add(when: 'CONFIG_XICS_KVM', if_true: files('xics_kvm.c'))
149
specific_ss.add(when: 'CONFIG_XICS_SPAPR', if_true: files('xics_spapr.c'))
150
diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
151
index XXXXXXX..XXXXXXX 100644
152
--- a/hw/riscv/Kconfig
153
+++ b/hw/riscv/Kconfig
154
@@ -XXX,XX +XXX,XX @@ config SIFIVE_E
155
bool
156
select HART
157
select SIFIVE
158
+ select SIFIVE_CLINT
159
select SIFIVE_GPIO
160
select SIFIVE_E_PRCI
161
select UNIMP
162
@@ -XXX,XX +XXX,XX @@ config SIFIVE_U
163
select CADENCE
164
select HART
165
select SIFIVE
166
+ select SIFIVE_CLINT
167
select SIFIVE_GPIO
168
select SIFIVE_PDMA
169
select SIFIVE_U_OTP
170
@@ -XXX,XX +XXX,XX @@ config SPIKE
171
select HART
172
select HTIF
173
select SIFIVE
174
+ select SIFIVE_CLINT
175
176
config OPENTITAN
177
bool
178
@@ -XXX,XX +XXX,XX @@ config RISCV_VIRT
179
select PCI_EXPRESS_GENERIC_BRIDGE
180
select PFLASH_CFI01
181
select SIFIVE
182
+ select SIFIVE_CLINT
183
184
config MICROCHIP_PFSOC
185
bool
186
select HART
187
select SIFIVE
188
+ select SIFIVE_CLINT
189
select UNIMP
190
select MCHP_PFSOC_MMUART
191
select SIFIVE_PDMA
192
diff --git a/hw/riscv/meson.build b/hw/riscv/meson.build
193
index XXXXXXX..XXXXXXX 100644
194
--- a/hw/riscv/meson.build
195
+++ b/hw/riscv/meson.build
196
@@ -XXX,XX +XXX,XX @@ riscv_ss.add(files('numa.c'))
197
riscv_ss.add(when: 'CONFIG_HART', if_true: files('riscv_hart.c'))
198
riscv_ss.add(when: 'CONFIG_OPENTITAN', if_true: files('opentitan.c'))
199
riscv_ss.add(when: 'CONFIG_RISCV_VIRT', if_true: files('virt.c'))
200
-riscv_ss.add(when: 'CONFIG_SIFIVE', if_true: files('sifive_clint.c'))
201
riscv_ss.add(when: 'CONFIG_SIFIVE', if_true: files('sifive_plic.c'))
202
riscv_ss.add(when: 'CONFIG_SIFIVE', if_true: files('sifive_test.c'))
203
riscv_ss.add(when: 'CONFIG_SIFIVE', if_true: files('sifive_uart.c'))
204
--
52
--
205
2.28.0
53
2.31.1
206
54
207
55
diff view generated by jsdifflib