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 99d6b11b5b44d7dd64f4cb1973184e40a4a174f8:
4
5
Merge tag 'pull-target-arm-20220922' of https://git.linaro.org/people/pmaydell/qemu-arm into staging (2022-09-26 13:38:26 -0400)
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
https://github.com/alistair23/qemu.git tags/pull-riscv-to-apply-20220927
8
10
9
for you to fetch changes up to 7595a65818ea9b49c36650a8c217a1ef9bd6e62a:
11
for you to fetch changes up to a3ab69f9f6c000481c439923d16416b8941d5b37:
10
12
11
hw/riscv: Sort the Kconfig options in alphabetical order (2020-09-09 15:54:19 -0700)
13
target/riscv: rvv-1.0: vf[w]redsum distinguish between ordered/unordered (2022-09-27 11:23:57 +1000)
12
14
13
----------------------------------------------------------------
15
----------------------------------------------------------------
14
This PR includes multiple fixes and features for RISC-V:
16
Second RISC-V PR for QEMU 7.2
15
- Fixes a bug in printing trap causes
17
16
- Allows 16-bit writes to the SiFive test device. This fixes the
18
* Fixup typos and register addresses for Ibex SPI
17
failure to reboot the RISC-V virt machine
19
* Cleanup the RISC-V virt machine documentation
18
- Support for the Microchip PolarFire SoC and Icicle Kit
20
* Remove the sideleg and sedeleg CSR macros
19
- A reafactor of RISC-V code out of hw/riscv
21
* Fix the CSR check for cycle{h}, instret{h}, time{h}, hpmcounter3-31{h}
22
* Remove fixed numbering from GDB xml feature files
23
* Allow setting the resetvec for the OpenTitan machine
24
* Check the correct exception cause in vector GDB stub
25
* Fix inheritance of SiFiveEState
26
* Improvements to the RISC-V debugger spec
27
* Simplify some vector code
20
28
21
----------------------------------------------------------------
29
----------------------------------------------------------------
22
Bin Meng (28):
30
Alex Bennée (1):
23
target/riscv: cpu: Add a new 'resetvec' property
31
docs/system: clean up code escape for riscv virt platform
24
hw/riscv: hart: Add a new 'resetvec' property
25
target/riscv: cpu: Set reset vector based on the configured property value
26
hw/riscv: Initial support for Microchip PolarFire SoC Icicle Kit board
27
hw/char: Add Microchip PolarFire SoC MMUART emulation
28
hw/riscv: microchip_pfsoc: Connect 5 MMUARTs
29
hw/sd: Add Cadence SDHCI emulation
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
32
52
Nathan Chancellor (1):
33
Alistair Francis (3):
53
riscv: sifive_test: Allow 16-bit writes to memory region
34
target/riscv: Set the CPU resetvec directly
35
hw/riscv: opentitan: Fixup resetvec
36
hw/riscv: opentitan: Expose the resetvec as a SoC property
54
37
55
Yifei Jiang (1):
38
Andrew Burgess (2):
56
target/riscv: Fix bug in getting trap cause name for trace_riscv_trap
39
target/riscv: remove fflags, frm, and fcsr from riscv-*-fpu.xml
40
target/riscv: remove fixed numbering from GDB xml feature files
57
41
58
default-configs/riscv64-softmmu.mak | 1 +
42
Bernhard Beschow (1):
59
{include/hw/riscv => hw/intc}/sifive_plic.h | 0
43
hw/riscv/sifive_e: Fix inheritance of SiFiveEState
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
44
45
Frank Chang (9):
46
target/riscv: Check the correct exception cause in vector GDB stub
47
target/riscv: debug: Determine the trigger type from tdata1.type
48
target/riscv: debug: Introduce build_tdata1() to build tdata1 register content
49
target/riscv: debug: Introduce tdata1, tdata2, and tdata3 CSRs
50
target/riscv: debug: Restrict the range of tselect value can be written
51
target/riscv: debug: Introduce tinfo CSR
52
target/riscv: debug: Create common trigger actions function
53
target/riscv: debug: Check VU/VS modes for type 2 trigger
54
target/riscv: debug: Add initial support of type 6 trigger
55
56
Rahul Pathak (1):
57
target/riscv: Remove sideleg and sedeleg
58
59
Weiwei Li (1):
60
target/riscv: fix csr check for cycle{h}, instret{h}, time{h}, hpmcounter3-31{h}
61
62
Wilfred Mallawa (2):
63
hw/ssi: ibex_spi: fixup typos in ibex_spi_host
64
hw/ssi: ibex_spi: update reg addr
65
66
Yang Liu (2):
67
target/riscv: rvv-1.0: Simplify vfwredsum code
68
target/riscv: rvv-1.0: vf[w]redsum distinguish between ordered/unordered
69
70
docs/system/riscv/virt.rst | 13 +-
71
include/hw/riscv/opentitan.h | 2 +
72
include/hw/riscv/sifive_e.h | 3 +-
73
target/riscv/cpu.h | 9 +-
74
target/riscv/cpu_bits.h | 3 +-
75
target/riscv/debug.h | 55 ++--
76
target/riscv/helper.h | 15 +-
77
target/riscv/insn32.decode | 6 +-
78
disas/riscv.c | 2 -
79
hw/riscv/opentitan.c | 8 +-
80
hw/ssi/ibex_spi_host.c | 8 +-
81
target/riscv/cpu.c | 13 +-
82
target/riscv/csr.c | 23 +-
83
target/riscv/debug.c | 484 +++++++++++++++++++++++++-------
84
target/riscv/gdbstub.c | 36 +--
85
target/riscv/machine.c | 26 +-
86
target/riscv/vector_helper.c | 69 ++---
87
target/riscv/insn_trans/trans_rvv.c.inc | 6 +-
88
gdb-xml/riscv-32bit-cpu.xml | 6 +-
89
gdb-xml/riscv-32bit-fpu.xml | 10 +-
90
gdb-xml/riscv-64bit-cpu.xml | 6 +-
91
gdb-xml/riscv-64bit-fpu.xml | 10 +-
92
22 files changed, 531 insertions(+), 282 deletions(-)
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Wilfred Mallawa <wilfred.mallawa@wdc.com>
2
2
3
At present the Kconfig file is in disorder. Let's sort the options.
3
This patch fixes up minor typos in ibex_spi_host
4
4
5
Signed-off-by: Bin Meng <bin.meng@windriver.com>
5
Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Message-Id: <1599129623-68957-13-git-send-email-bmeng.cn@gmail.com>
7
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
8
Message-Id: <20220823061201.132342-2-wilfred.mallawa@opensource.wdc.com>
8
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
9
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
9
---
10
---
10
hw/riscv/Kconfig | 58 ++++++++++++++++++++++++------------------------
11
hw/ssi/ibex_spi_host.c | 6 +++---
11
1 file changed, 29 insertions(+), 29 deletions(-)
12
1 file changed, 3 insertions(+), 3 deletions(-)
12
13
13
diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
14
diff --git a/hw/ssi/ibex_spi_host.c b/hw/ssi/ibex_spi_host.c
14
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/riscv/Kconfig
16
--- a/hw/ssi/ibex_spi_host.c
16
+++ b/hw/riscv/Kconfig
17
+++ b/hw/ssi/ibex_spi_host.c
17
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@ static void ibex_spi_host_irq(IbexSPIHostState *s)
18
config IBEX
19
& R_INTR_STATE_SPI_EVENT_MASK;
19
bool
20
int err_irq = 0, event_irq = 0;
20
21
21
-config SIFIVE_E
22
- /* Error IRQ enabled and Error IRQ Cleared*/
22
- bool
23
+ /* Error IRQ enabled and Error IRQ Cleared */
23
- select MSI_NONBROKEN
24
if (error_en && !err_pending) {
24
- select SIFIVE_CLINT
25
/* Event enabled, Interrupt Test Error */
25
- select SIFIVE_GPIO
26
if (s->regs[IBEX_SPI_HOST_INTR_TEST] & R_INTR_TEST_ERROR_MASK) {
26
- select SIFIVE_PLIC
27
@@ -XXX,XX +XXX,XX @@ static void ibex_spi_host_write(void *opaque, hwaddr addr,
27
- select SIFIVE_UART
28
case IBEX_SPI_HOST_TXDATA:
28
- select SIFIVE_E_PRCI
29
/*
29
- select UNIMP
30
* This is a hardware `feature` where
30
-
31
- * the first word written TXDATA after init is omitted entirely
31
-config SIFIVE_U
32
+ * the first word written to TXDATA after init is omitted entirely
32
+config MICROCHIP_PFSOC
33
*/
33
bool
34
if (s->init_status) {
34
- select CADENCE
35
s->init_status = false;
35
+ select CADENCE_SDHCI
36
@@ -XXX,XX +XXX,XX @@ static void ibex_spi_host_write(void *opaque, hwaddr addr,
36
+ select MCHP_PFSOC_MMUART
37
break;
37
select MSI_NONBROKEN
38
case IBEX_SPI_HOST_ERROR_STATUS:
38
select SIFIVE_CLINT
39
/*
39
- select SIFIVE_GPIO
40
- * Indicates that any errors that have occurred.
40
select SIFIVE_PDMA
41
+ * Indicates any errors that have occurred.
41
select SIFIVE_PLIC
42
* When an error occurs, the corresponding bit must be cleared
42
- select SIFIVE_UART
43
* here before issuing any further commands
43
- select SIFIVE_U_OTP
44
*/
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
--
45
--
108
2.28.0
46
2.37.3
109
110
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Wilfred Mallawa <wilfred.mallawa@wdc.com>
2
2
3
The name SIFIVE is too vague to convey the required component of
3
Updates the `EVENT_ENABLE` register to offset `0x34` as per
4
MSI_NONBROKEN. Let's drop the option, and select MSI_NONBROKEN in
4
OpenTitan spec [1].
5
each machine instead.
6
5
7
Signed-off-by: Bin Meng <bin.meng@windriver.com>
6
[1] https://docs.opentitan.org/hw/ip/spi_host/doc/#Reg_event_enable
7
8
Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-Id: <1599129623-68957-12-git-send-email-bmeng.cn@gmail.com>
10
Message-Id: <20220823061201.132342-5-wilfred.mallawa@opensource.wdc.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
12
---
12
hw/riscv/Kconfig | 14 +++++---------
13
hw/ssi/ibex_spi_host.c | 2 +-
13
1 file changed, 5 insertions(+), 9 deletions(-)
14
1 file changed, 1 insertion(+), 1 deletion(-)
14
15
15
diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
16
diff --git a/hw/ssi/ibex_spi_host.c b/hw/ssi/ibex_spi_host.c
16
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/riscv/Kconfig
18
--- a/hw/ssi/ibex_spi_host.c
18
+++ b/hw/riscv/Kconfig
19
+++ b/hw/ssi/ibex_spi_host.c
19
@@ -XXX,XX +XXX,XX @@
20
@@ -XXX,XX +XXX,XX @@ REG32(ERROR_STATUS, 0x30)
20
config IBEX
21
FIELD(ERROR_STATUS, CMDINVAL, 3, 1)
21
bool
22
FIELD(ERROR_STATUS, CSIDINVAL, 4, 1)
22
23
FIELD(ERROR_STATUS, ACCESSINVAL, 5, 1)
23
-config SIFIVE
24
-REG32(EVENT_ENABLE, 0x30)
24
- bool
25
+REG32(EVENT_ENABLE, 0x34)
25
- select MSI_NONBROKEN
26
FIELD(EVENT_ENABLE, RXFULL, 0, 1)
26
-
27
FIELD(EVENT_ENABLE, TXEMPTY, 1, 1)
27
config SIFIVE_E
28
FIELD(EVENT_ENABLE, RXWM, 2, 1)
28
bool
29
- select SIFIVE
30
+ select MSI_NONBROKEN
31
select SIFIVE_CLINT
32
select SIFIVE_GPIO
33
select SIFIVE_PLIC
34
@@ -XXX,XX +XXX,XX @@ config SIFIVE_E
35
config SIFIVE_U
36
bool
37
select CADENCE
38
- select SIFIVE
39
+ select MSI_NONBROKEN
40
select SIFIVE_CLINT
41
select SIFIVE_GPIO
42
select SIFIVE_PDMA
43
@@ -XXX,XX +XXX,XX @@ config SIFIVE_U
44
config SPIKE
45
bool
46
select HTIF
47
- select SIFIVE
48
+ select MSI_NONBROKEN
49
select SIFIVE_CLINT
50
select SIFIVE_PLIC
51
52
@@ -XXX,XX +XXX,XX @@ config RISCV_VIRT
53
bool
54
imply PCI_DEVICES
55
imply TEST_DEVICES
56
+ select MSI_NONBROKEN
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
--
29
--
76
2.28.0
30
2.37.3
77
78
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Alex Bennée <alex.bennee@linaro.org>
2
2
3
Every RISC-V machine needs riscv_hart hence there is no need to
3
The example code is rendered slightly mangled due to missing code
4
have a dedicated Kconfig option for it. Drop the Kconfig option
4
block. Properly escape the code block and add shell prompt and qemu to
5
and always build riscv_hart.c.
5
fit in with the other examples on the page.
6
6
7
Signed-off-by: Bin Meng <bin.meng@windriver.com>
7
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-Id: <1599129623-68957-11-git-send-email-bmeng.cn@gmail.com>
9
Message-Id: <20220905163939.1599368-1-alex.bennee@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
hw/riscv/Kconfig | 9 ---------
12
docs/system/riscv/virt.rst | 13 +++++++++----
13
hw/riscv/meson.build | 2 +-
13
1 file changed, 9 insertions(+), 4 deletions(-)
14
2 files changed, 1 insertion(+), 10 deletions(-)
15
14
16
diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
15
diff --git a/docs/system/riscv/virt.rst b/docs/system/riscv/virt.rst
17
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/riscv/Kconfig
17
--- a/docs/system/riscv/virt.rst
19
+++ b/hw/riscv/Kconfig
18
+++ b/docs/system/riscv/virt.rst
20
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@ Enabling TPM
21
-config HART
20
22
- bool
21
A TPM device can be connected to the virt board by following the steps below.
23
-
22
24
config IBEX
23
-First launch the TPM emulator
25
bool
24
+First launch the TPM emulator:
26
25
27
@@ -XXX,XX +XXX,XX @@ config SIFIVE
26
- swtpm socket --tpm2 -t -d --tpmstate dir=/tmp/tpm \
28
27
+.. code-block:: bash
29
config SIFIVE_E
28
+
30
bool
29
+ $ swtpm socket --tpm2 -t -d --tpmstate dir=/tmp/tpm \
31
- select HART
30
--ctrl type=unixio,path=swtpm-sock
32
select SIFIVE
31
33
select SIFIVE_CLINT
32
-Then launch QEMU with:
34
select SIFIVE_GPIO
33
+Then launch QEMU with some additional arguments to link a TPM device to the backend:
35
@@ -XXX,XX +XXX,XX @@ config SIFIVE_E
34
+
36
config SIFIVE_U
35
+.. code-block:: bash
37
bool
36
38
select CADENCE
37
- ...
39
- select HART
38
+ $ qemu-system-riscv64 \
40
select SIFIVE
39
+ ... other args .... \
41
select SIFIVE_CLINT
40
-chardev socket,id=chrtpm,path=swtpm-sock \
42
select SIFIVE_GPIO
41
-tpmdev emulator,id=tpm0,chardev=chrtpm \
43
@@ -XXX,XX +XXX,XX @@ config SIFIVE_U
42
-device tpm-tis-device,tpmdev=tpm0
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
--
43
--
89
2.28.0
44
2.37.3
90
91
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Rahul Pathak <rpathak@ventanamicro.com>
2
2
3
Microchip PolarFire SoC integrates 2 Candence GEMs to provide
3
sideleg and sedeleg csrs are not part of riscv isa spec
4
IEEE 802.3 standard-compliant 10/100/1000 Mbps ethernet interface.
4
anymore, these csrs were part of N extension which
5
is removed from the riscv isa specification.
5
6
6
On the Icicle Kit board, GEM0 connects to a PHY at address 8 while
7
These commits removed all traces of these csrs from
7
GEM1 connects to a PHY at address 9.
8
riscv spec (https://github.com/riscv/riscv-isa-manual) -
8
9
9
The 2nd stage bootloader (U-Boot) is using GEM1 by default, so we
10
commit f8d27f805b65 ("Remove or downgrade more references to N extension (#674)")
10
must specify 2 '-nic' options from the command line in order to get
11
commit b6cade07034d ("Remove N extension chapter for now")
11
a working ethernet.
12
12
13
Signed-off-by: Bin Meng <bin.meng@windriver.com>
13
Signed-off-by: Rahul Pathak <rpathak@ventanamicro.com>
14
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
14
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
15
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
15
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
16
Message-Id: <20220824145255.400040-1-rpathak@ventanamicro.com>
16
Message-Id: <1598924352-89526-14-git-send-email-bmeng.cn@gmail.com>
17
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
17
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
18
---
18
---
19
include/hw/riscv/microchip_pfsoc.h | 7 ++++++
19
target/riscv/cpu_bits.h | 2 --
20
hw/riscv/microchip_pfsoc.c | 39 ++++++++++++++++++++++++++++++
20
disas/riscv.c | 2 --
21
2 files changed, 46 insertions(+)
21
2 files changed, 4 deletions(-)
22
22
23
diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchip_pfsoc.h
23
diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h
24
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
25
--- a/include/hw/riscv/microchip_pfsoc.h
25
--- a/target/riscv/cpu_bits.h
26
+++ b/include/hw/riscv/microchip_pfsoc.h
26
+++ b/target/riscv/cpu_bits.h
27
@@ -XXX,XX +XXX,XX @@
27
@@ -XXX,XX +XXX,XX @@
28
28
29
#include "hw/char/mchp_pfsoc_mmuart.h"
29
/* Supervisor Trap Setup */
30
#include "hw/dma/sifive_pdma.h"
30
#define CSR_SSTATUS 0x100
31
+#include "hw/net/cadence_gem.h"
31
-#define CSR_SEDELEG 0x102
32
#include "hw/sd/cadence_sdhci.h"
32
-#define CSR_SIDELEG 0x103
33
33
#define CSR_SIE 0x104
34
typedef struct MicrochipPFSoCState {
34
#define CSR_STVEC 0x105
35
@@ -XXX,XX +XXX,XX @@ typedef struct MicrochipPFSoCState {
35
#define CSR_SCOUNTEREN 0x106
36
MchpPfSoCMMUartState *serial3;
36
diff --git a/disas/riscv.c b/disas/riscv.c
37
MchpPfSoCMMUartState *serial4;
38
SiFivePDMAState dma;
39
+ CadenceGEMState gem0;
40
+ CadenceGEMState gem1;
41
CadenceSDHCIState sdhci;
42
} MicrochipPFSoCState;
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
37
index XXXXXXX..XXXXXXX 100644
64
--- a/hw/riscv/microchip_pfsoc.c
38
--- a/disas/riscv.c
65
+++ b/hw/riscv/microchip_pfsoc.c
39
+++ b/disas/riscv.c
66
@@ -XXX,XX +XXX,XX @@
40
@@ -XXX,XX +XXX,XX @@ static const char *csr_name(int csrno)
67
* 3) MMUARTs (Multi-Mode UART)
41
case 0x0043: return "utval";
68
* 4) Cadence eMMC/SDHC controller and an SD card connected to it
42
case 0x0044: return "uip";
69
* 5) SiFive Platform DMA (Direct Memory Access Controller)
43
case 0x0100: return "sstatus";
70
+ * 6) GEM (Gigabit Ethernet MAC Controller)
44
- case 0x0102: return "sedeleg";
71
*
45
- case 0x0103: return "sideleg";
72
* This board currently generates devicetree dynamically that indicates at least
46
case 0x0104: return "sie";
73
* two harts and up to five harts.
47
case 0x0105: return "stvec";
74
@@ -XXX,XX +XXX,XX @@
48
case 0x0106: return "scounteren";
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
+ }
127
+
128
+ object_property_set_int(OBJECT(&s->gem0), "revision", GEM_REVISION, errp);
129
+ object_property_set_int(OBJECT(&s->gem0), "phy-addr", 8, errp);
130
+ sysbus_realize(SYS_BUS_DEVICE(&s->gem0), errp);
131
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->gem0), 0,
132
+ memmap[MICROCHIP_PFSOC_GEM0].base);
133
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->gem0), 0,
134
+ qdev_get_gpio_in(DEVICE(s->plic), MICROCHIP_PFSOC_GEM0_IRQ));
135
+
136
+ object_property_set_int(OBJECT(&s->gem1), "revision", GEM_REVISION, errp);
137
+ object_property_set_int(OBJECT(&s->gem1), "phy-addr", 9, errp);
138
+ sysbus_realize(SYS_BUS_DEVICE(&s->gem1), errp);
139
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->gem1), 0,
140
+ memmap[MICROCHIP_PFSOC_GEM1].base);
141
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->gem1), 0,
142
+ qdev_get_gpio_in(DEVICE(s->plic), MICROCHIP_PFSOC_GEM1_IRQ));
143
+
144
/* eNVM */
145
memory_region_init_rom(envm_data, OBJECT(dev), "microchip.pfsoc.envm.data",
146
memmap[MICROCHIP_PFSOC_ENVM_DATA].size,
147
--
49
--
148
2.28.0
50
2.37.3
149
150
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Weiwei Li <liweiwei@iscas.ac.cn>
2
2
3
At present the CLINT timestamp is using a hard-coded timebase
3
- modify check for mcounteren to work in all less-privilege mode
4
frequency value SIFIVE_CLINT_TIMEBASE_FREQ. This might not be
4
- modify check for scounteren to work only when S mode is enabled
5
true for all boards.
5
- distinguish the exception type raised by check for scounteren between U
6
and VU mode
6
7
7
Add a new 'timebase-freq' property to the CLINT device, and
8
Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
8
update various functions to accept this as a parameter.
9
Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
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: <1598924352-89526-16-git-send-email-bmeng.cn@gmail.com>
11
Message-Id: <20220817083756.12471-1-liweiwei@iscas.ac.cn>
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
12
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
14
---
13
---
15
include/hw/riscv/sifive_clint.h | 4 +++-
14
target/riscv/csr.c | 13 +++++++++----
16
target/riscv/cpu.h | 6 ++++--
15
1 file changed, 9 insertions(+), 4 deletions(-)
17
hw/riscv/microchip_pfsoc.c | 6 +++++-
18
hw/riscv/sifive_clint.c | 26 +++++++++++++++-----------
19
hw/riscv/sifive_e.c | 3 ++-
20
hw/riscv/sifive_u.c | 3 ++-
21
hw/riscv/spike.c | 3 ++-
22
hw/riscv/virt.c | 3 ++-
23
target/riscv/cpu_helper.c | 4 +++-
24
target/riscv/csr.c | 4 ++--
25
10 files changed, 40 insertions(+), 22 deletions(-)
26
16
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
47
index XXXXXXX..XXXXXXX 100644
48
--- a/target/riscv/cpu.h
49
+++ b/target/riscv/cpu.h
50
@@ -XXX,XX +XXX,XX @@ struct CPURISCVState {
51
pmp_table_t pmp_state;
52
53
/* machine specific rdtime callback */
54
- uint64_t (*rdtime_fn)(void);
55
+ uint64_t (*rdtime_fn)(uint32_t);
56
+ uint32_t rdtime_fn_arg;
57
58
/* True if in debugger mode. */
59
bool debugger;
60
@@ -XXX,XX +XXX,XX @@ void riscv_cpu_swap_hypervisor_regs(CPURISCVState *env);
61
int riscv_cpu_claim_interrupts(RISCVCPU *cpu, uint32_t interrupts);
62
uint32_t riscv_cpu_update_mip(RISCVCPU *cpu, uint32_t mask, uint32_t value);
63
#define BOOL_TO_MASK(x) (-!!(x)) /* helper for riscv_cpu_update_mip value */
64
-void riscv_cpu_set_rdtime_fn(CPURISCVState *env, uint64_t (*fn)(void));
65
+void riscv_cpu_set_rdtime_fn(CPURISCVState *env, uint64_t (*fn)(uint32_t),
66
+ uint32_t arg);
67
#endif
68
void riscv_cpu_set_mode(CPURISCVState *env, target_ulong newpriv);
69
70
diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c
71
index XXXXXXX..XXXXXXX 100644
72
--- a/hw/riscv/microchip_pfsoc.c
73
+++ b/hw/riscv/microchip_pfsoc.c
74
@@ -XXX,XX +XXX,XX @@
75
#define BIOS_FILENAME "hss.bin"
76
#define RESET_VECTOR 0x20220000
77
78
+/* CLINT timebase frequency */
79
+#define CLINT_TIMEBASE_FREQ 1000000
80
+
81
/* GEM version */
82
#define GEM_REVISION 0x0107010c
83
84
@@ -XXX,XX +XXX,XX @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp)
85
/* CLINT */
86
sifive_clint_create(memmap[MICROCHIP_PFSOC_CLINT].base,
87
memmap[MICROCHIP_PFSOC_CLINT].size, 0, ms->smp.cpus,
88
- SIFIVE_SIP_BASE, SIFIVE_TIMECMP_BASE, SIFIVE_TIME_BASE, false);
89
+ SIFIVE_SIP_BASE, SIFIVE_TIMECMP_BASE, SIFIVE_TIME_BASE,
90
+ CLINT_TIMEBASE_FREQ, false);
91
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
}
109
110
/*
111
* Called when timecmp is written to update the QEMU timer or immediately
112
* trigger timer interrupt if mtimecmp <= current timer value.
113
*/
114
-static void sifive_clint_write_timecmp(RISCVCPU *cpu, uint64_t value)
115
+static void sifive_clint_write_timecmp(RISCVCPU *cpu, uint64_t value,
116
+ uint32_t timebase_freq)
117
{
118
uint64_t next;
119
uint64_t diff;
120
121
- uint64_t rtc_r = cpu_riscv_read_rtc();
122
+ uint64_t rtc_r = cpu_riscv_read_rtc(timebase_freq);
123
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
}
134
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
256
index XXXXXXX..XXXXXXX 100644
257
--- a/target/riscv/cpu_helper.c
258
+++ 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)
260
return old;
261
}
262
263
-void riscv_cpu_set_rdtime_fn(CPURISCVState *env, uint64_t (*fn)(void))
264
+void riscv_cpu_set_rdtime_fn(CPURISCVState *env, uint64_t (*fn)(uint32_t),
265
+ uint32_t arg)
266
{
267
env->rdtime_fn = fn;
268
+ env->rdtime_fn_arg = arg;
269
}
270
271
void riscv_cpu_set_mode(CPURISCVState *env, target_ulong newpriv)
272
diff --git a/target/riscv/csr.c b/target/riscv/csr.c
17
diff --git a/target/riscv/csr.c b/target/riscv/csr.c
273
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
274
--- a/target/riscv/csr.c
19
--- a/target/riscv/csr.c
275
+++ b/target/riscv/csr.c
20
+++ b/target/riscv/csr.c
276
@@ -XXX,XX +XXX,XX @@ static int read_time(CPURISCVState *env, int csrno, target_ulong *val)
21
@@ -XXX,XX +XXX,XX @@ static RISCVException ctr(CPURISCVState *env, int csrno)
277
return -RISCV_EXCP_ILLEGAL_INST;
22
23
skip_ext_pmu_check:
24
25
- if (((env->priv == PRV_S) && (!get_field(env->mcounteren, ctr_mask))) ||
26
- ((env->priv == PRV_U) && (!get_field(env->scounteren, ctr_mask)))) {
27
+ if (env->priv < PRV_M && !get_field(env->mcounteren, ctr_mask)) {
28
return RISCV_EXCP_ILLEGAL_INST;
278
}
29
}
279
30
280
- *val = env->rdtime_fn() + delta;
31
if (riscv_cpu_virt_enabled(env)) {
281
+ *val = env->rdtime_fn(env->rdtime_fn_arg) + delta;
32
- if (!get_field(env->hcounteren, ctr_mask) &&
282
return 0;
33
- get_field(env->mcounteren, ctr_mask)) {
34
+ if (!get_field(env->hcounteren, ctr_mask) ||
35
+ (env->priv == PRV_U && !get_field(env->scounteren, ctr_mask))) {
36
return RISCV_EXCP_VIRT_INSTRUCTION_FAULT;
37
}
38
}
39
+
40
+ if (riscv_has_ext(env, RVS) && env->priv == PRV_U &&
41
+ !get_field(env->scounteren, ctr_mask)) {
42
+ return RISCV_EXCP_ILLEGAL_INST;
43
+ }
44
+
45
#endif
46
return RISCV_EXCP_NONE;
283
}
47
}
284
285
@@ -XXX,XX +XXX,XX @@ static int read_timeh(CPURISCVState *env, int csrno, target_ulong *val)
286
return -RISCV_EXCP_ILLEGAL_INST;
287
}
288
289
- *val = (env->rdtime_fn() + delta) >> 32;
290
+ *val = (env->rdtime_fn(env->rdtime_fn_arg) + delta) >> 32;
291
return 0;
292
}
293
#endif
294
--
48
--
295
2.28.0
49
2.37.3
296
297
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Andrew Burgess <aburgess@redhat.com>
2
2
3
This is an effort to clean up the hw/riscv directory. Ideally it
3
While testing some changes to GDB's handling for the RISC-V registers
4
should only contain the RISC-V SoC / machine codes plus generic
4
fcsr, fflags, and frm, I spotted that QEMU includes these registers
5
codes. Let's move sifive_test model to hw/misc directory.
5
twice in the target description it sends to GDB, once in the fpu
6
feature, and once in the csr feature.
6
7
7
Signed-off-by: Bin Meng <bin.meng@windriver.com>
8
Right now things basically work OK, QEMU maps these registers onto two
9
different register numbers, e.g. fcsr maps to both 68 and 73, and GDB
10
can use either of these to access the register.
11
12
However, GDB's target descriptions don't really work this way, each
13
register should appear just once in a target description, mapping the
14
register name onto the number GDB should use when accessing the
15
register on the target. Duplicate register names actually result in
16
duplicate registers on the GDB side, however, as the registers have
17
the same name, the user can only access one of these registers.
18
19
Currently GDB has a hack in place, specifically for RISC-V, to spot
20
the duplicate copies of these three registers, and hide them from the
21
user, ensuring the user only ever sees a single copy of each.
22
23
In this commit I propose fixing this issue on the QEMU side, and in
24
the process, simplify the fpu register handling a little.
25
26
I think we should, remove fflags, frm, and fcsr from the two (32-bit
27
and 64-bit) fpu feature xml files. These files will only contain the
28
32 core floating point register f0 to f31. The fflags, frm, and fcsr
29
registers will continue to be advertised in the csr feature as they
30
currently are.
31
32
With that change made, I will simplify riscv_gdb_get_fpu and
33
riscv_gdb_set_fpu, removing the extra handling for the 3 status
34
registers.
35
36
Signed-off-by: Andrew Burgess <aburgess@redhat.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
37
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-Id: <1599129623-68957-10-git-send-email-bmeng.cn@gmail.com>
38
Message-Id: <0fbf2a5b12e3210ff3867d5cf7022b3f3462c9c8.1661934573.git.aburgess@redhat.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
39
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
40
---
12
include/hw/{riscv => misc}/sifive_test.h | 0
41
target/riscv/gdbstub.c | 32 ++------------------------------
13
hw/{riscv => misc}/sifive_test.c | 2 +-
42
gdb-xml/riscv-32bit-fpu.xml | 4 ----
14
hw/riscv/virt.c | 2 +-
43
gdb-xml/riscv-64bit-fpu.xml | 4 ----
15
hw/misc/Kconfig | 3 +++
44
3 files changed, 2 insertions(+), 38 deletions(-)
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
45
23
diff --git a/include/hw/riscv/sifive_test.h b/include/hw/misc/sifive_test.h
46
diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c
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
47
index XXXXXXX..XXXXXXX 100644
32
--- a/hw/riscv/sifive_test.c
48
--- a/target/riscv/gdbstub.c
33
+++ b/hw/misc/sifive_test.c
49
+++ b/target/riscv/gdbstub.c
50
@@ -XXX,XX +XXX,XX @@ static int riscv_gdb_get_fpu(CPURISCVState *env, GByteArray *buf, int n)
51
if (env->misa_ext & RVF) {
52
return gdb_get_reg32(buf, env->fpr[n]);
53
}
54
- /* there is hole between ft11 and fflags in fpu.xml */
55
- } else if (n < 36 && n > 32) {
56
- target_ulong val = 0;
57
- int result;
58
- /*
59
- * CSR_FFLAGS is at index 1 in csr_register, and gdb says it is FP
60
- * register 33, so we recalculate the map index.
61
- * This also works for CSR_FRM and CSR_FCSR.
62
- */
63
- result = riscv_csrrw_debug(env, n - 32, &val,
64
- 0, 0);
65
- if (result == RISCV_EXCP_NONE) {
66
- return gdb_get_regl(buf, val);
67
- }
68
}
69
return 0;
70
}
71
@@ -XXX,XX +XXX,XX @@ static int riscv_gdb_set_fpu(CPURISCVState *env, uint8_t *mem_buf, int n)
72
if (n < 32) {
73
env->fpr[n] = ldq_p(mem_buf); /* always 64-bit */
74
return sizeof(uint64_t);
75
- /* there is hole between ft11 and fflags in fpu.xml */
76
- } else if (n < 36 && n > 32) {
77
- target_ulong val = ldtul_p(mem_buf);
78
- int result;
79
- /*
80
- * CSR_FFLAGS is at index 1 in csr_register, and gdb says it is FP
81
- * register 33, so we recalculate the map index.
82
- * This also works for CSR_FRM and CSR_FCSR.
83
- */
84
- result = riscv_csrrw_debug(env, n - 32, NULL,
85
- val, -1);
86
- if (result == RISCV_EXCP_NONE) {
87
- return sizeof(target_ulong);
88
- }
89
}
90
return 0;
91
}
92
@@ -XXX,XX +XXX,XX @@ void riscv_cpu_register_gdb_regs_for_features(CPUState *cs)
93
CPURISCVState *env = &cpu->env;
94
if (env->misa_ext & RVD) {
95
gdb_register_coprocessor(cs, riscv_gdb_get_fpu, riscv_gdb_set_fpu,
96
- 36, "riscv-64bit-fpu.xml", 0);
97
+ 32, "riscv-64bit-fpu.xml", 0);
98
} else if (env->misa_ext & RVF) {
99
gdb_register_coprocessor(cs, riscv_gdb_get_fpu, riscv_gdb_set_fpu,
100
- 36, "riscv-32bit-fpu.xml", 0);
101
+ 32, "riscv-32bit-fpu.xml", 0);
102
}
103
if (env->misa_ext & RVV) {
104
gdb_register_coprocessor(cs, riscv_gdb_get_vector, riscv_gdb_set_vector,
105
diff --git a/gdb-xml/riscv-32bit-fpu.xml b/gdb-xml/riscv-32bit-fpu.xml
106
index XXXXXXX..XXXXXXX 100644
107
--- a/gdb-xml/riscv-32bit-fpu.xml
108
+++ b/gdb-xml/riscv-32bit-fpu.xml
34
@@ -XXX,XX +XXX,XX @@
109
@@ -XXX,XX +XXX,XX @@
35
#include "qemu/module.h"
110
<reg name="ft9" bitsize="32" type="ieee_single"/>
36
#include "sysemu/runstate.h"
111
<reg name="ft10" bitsize="32" type="ieee_single"/>
37
#include "hw/hw.h"
112
<reg name="ft11" bitsize="32" type="ieee_single"/>
38
-#include "hw/riscv/sifive_test.h"
113
-
39
+#include "hw/misc/sifive_test.h"
114
- <reg name="fflags" bitsize="32" type="int" regnum="66"/>
40
115
- <reg name="frm" bitsize="32" type="int" regnum="67"/>
41
static uint64_t sifive_test_read(void *opaque, hwaddr addr, unsigned int size)
116
- <reg name="fcsr" bitsize="32" type="int" regnum="68"/>
42
{
117
</feature>
43
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
118
diff --git a/gdb-xml/riscv-64bit-fpu.xml b/gdb-xml/riscv-64bit-fpu.xml
44
index XXXXXXX..XXXXXXX 100644
119
index XXXXXXX..XXXXXXX 100644
45
--- a/hw/riscv/virt.c
120
--- a/gdb-xml/riscv-64bit-fpu.xml
46
+++ b/hw/riscv/virt.c
121
+++ b/gdb-xml/riscv-64bit-fpu.xml
47
@@ -XXX,XX +XXX,XX @@
122
@@ -XXX,XX +XXX,XX @@
48
#include "hw/char/serial.h"
123
<reg name="ft9" bitsize="64" type="riscv_double"/>
49
#include "target/riscv/cpu.h"
124
<reg name="ft10" bitsize="64" type="riscv_double"/>
50
#include "hw/riscv/riscv_hart.h"
125
<reg name="ft11" bitsize="64" type="riscv_double"/>
51
-#include "hw/riscv/sifive_test.h"
126
-
52
#include "hw/riscv/virt.h"
127
- <reg name="fflags" bitsize="32" type="int" regnum="66"/>
53
#include "hw/riscv/boot.h"
128
- <reg name="frm" bitsize="32" type="int" regnum="67"/>
54
#include "hw/riscv/numa.h"
129
- <reg name="fcsr" bitsize="32" type="int" regnum="68"/>
55
#include "hw/intc/sifive_clint.h"
130
</feature>
56
#include "hw/intc/sifive_plic.h"
57
+#include "hw/misc/sifive_test.h"
58
#include "chardev/char.h"
59
#include "sysemu/arch_init.h"
60
#include "sysemu/device_tree.h"
61
diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
62
index XXXXXXX..XXXXXXX 100644
63
--- a/hw/misc/Kconfig
64
+++ b/hw/misc/Kconfig
65
@@ -XXX,XX +XXX,XX @@ config MAC_VIA
66
config AVR_POWER
67
bool
68
69
+config SIFIVE_TEST
70
+ bool
71
+
72
config SIFIVE_E_PRCI
73
bool
74
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
--
131
--
112
2.28.0
132
2.37.3
113
114
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Andrew Burgess <aburgess@redhat.com>
2
2
3
This is an effort to clean up the hw/riscv directory. Ideally it
3
The fixed register numbering in the various GDB feature files for
4
should only contain the RISC-V SoC / machine codes plus generic
4
RISC-V only exists because these files were originally copied from the
5
codes. Let's move sifive_uart model to hw/char directory.
5
GDB source tree.
6
6
7
Signed-off-by: Bin Meng <bin.meng@windriver.com>
7
However, the fixed numbering only exists in the GDB source tree so
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
that GDB, when it connects to a target that doesn't provide a target
9
Message-Id: <1599129623-68957-9-git-send-email-bmeng.cn@gmail.com>
9
description, will use a specific numbering scheme.
10
11
That numbering scheme is designed to be compatible with the first
12
versions of QEMU (for RISC-V), that didn't send a target description,
13
and relied on a fixed numbering scheme.
14
15
Because of the way that QEMU manages its target descriptions,
16
recording the number of registers in each feature, and just relying on
17
GDB's numbering starting from 0, then I propose that we remove all the
18
fixed numbering from the RISC-V feature xml files, and just rely on
19
the standard numbering scheme. Plenty of other targets manage their
20
xml files this way, e.g. ARM, AArch64, Loongarch, m68k, rx, and s390.
21
22
Signed-off-by: Andrew Burgess <aburgess@redhat.com>
23
Acked-by: Alistair Francis <alistair.francis@wdc.com>
24
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
25
Message-Id: <6069395f90e6fc24dac92197be815fedf42f5974.1661934573.git.aburgess@redhat.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
26
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
27
---
12
include/hw/{riscv => char}/sifive_uart.h | 0
28
gdb-xml/riscv-32bit-cpu.xml | 6 +-----
13
hw/{riscv => char}/sifive_uart.c | 2 +-
29
gdb-xml/riscv-32bit-fpu.xml | 6 +-----
14
hw/riscv/sifive_e.c | 2 +-
30
gdb-xml/riscv-64bit-cpu.xml | 6 +-----
15
hw/riscv/sifive_u.c | 2 +-
31
gdb-xml/riscv-64bit-fpu.xml | 6 +-----
16
hw/char/Kconfig | 3 +++
32
4 files changed, 4 insertions(+), 20 deletions(-)
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
33
24
diff --git a/include/hw/riscv/sifive_uart.h b/include/hw/char/sifive_uart.h
34
diff --git a/gdb-xml/riscv-32bit-cpu.xml b/gdb-xml/riscv-32bit-cpu.xml
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
35
index XXXXXXX..XXXXXXX 100644
33
--- a/hw/riscv/sifive_uart.c
36
--- a/gdb-xml/riscv-32bit-cpu.xml
34
+++ b/hw/char/sifive_uart.c
37
+++ b/gdb-xml/riscv-32bit-cpu.xml
35
@@ -XXX,XX +XXX,XX @@
38
@@ -XXX,XX +XXX,XX @@
36
#include "chardev/char-fe.h"
39
are permitted in any medium without royalty provided the copyright
37
#include "hw/hw.h"
40
notice and this notice are preserved. -->
38
#include "hw/irq.h"
41
39
-#include "hw/riscv/sifive_uart.h"
42
-<!-- Register numbers are hard-coded in order to maintain backward
40
+#include "hw/char/sifive_uart.h"
43
- compatibility with older versions of tools that didn't use xml
41
44
- register descriptions. -->
42
/*
45
-
43
* Not yet implemented:
46
<!DOCTYPE feature SYSTEM "gdb-target.dtd">
44
diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c
47
<feature name="org.gnu.gdb.riscv.cpu">
48
- <reg name="zero" bitsize="32" type="int" regnum="0"/>
49
+ <reg name="zero" bitsize="32" type="int"/>
50
<reg name="ra" bitsize="32" type="code_ptr"/>
51
<reg name="sp" bitsize="32" type="data_ptr"/>
52
<reg name="gp" bitsize="32" type="data_ptr"/>
53
diff --git a/gdb-xml/riscv-32bit-fpu.xml b/gdb-xml/riscv-32bit-fpu.xml
45
index XXXXXXX..XXXXXXX 100644
54
index XXXXXXX..XXXXXXX 100644
46
--- a/hw/riscv/sifive_e.c
55
--- a/gdb-xml/riscv-32bit-fpu.xml
47
+++ b/hw/riscv/sifive_e.c
56
+++ b/gdb-xml/riscv-32bit-fpu.xml
48
@@ -XXX,XX +XXX,XX @@
57
@@ -XXX,XX +XXX,XX @@
49
#include "hw/misc/unimp.h"
58
are permitted in any medium without royalty provided the copyright
50
#include "target/riscv/cpu.h"
59
notice and this notice are preserved. -->
51
#include "hw/riscv/riscv_hart.h"
60
52
-#include "hw/riscv/sifive_uart.h"
61
-<!-- Register numbers are hard-coded in order to maintain backward
53
#include "hw/riscv/sifive_e.h"
62
- compatibility with older versions of tools that didn't use xml
54
#include "hw/riscv/boot.h"
63
- register descriptions. -->
55
+#include "hw/char/sifive_uart.h"
64
-
56
#include "hw/intc/sifive_clint.h"
65
<!DOCTYPE feature SYSTEM "gdb-target.dtd">
57
#include "hw/intc/sifive_plic.h"
66
<feature name="org.gnu.gdb.riscv.fpu">
58
#include "hw/misc/sifive_e_prci.h"
67
- <reg name="ft0" bitsize="32" type="ieee_single" regnum="33"/>
59
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
68
+ <reg name="ft0" bitsize="32" type="ieee_single"/>
69
<reg name="ft1" bitsize="32" type="ieee_single"/>
70
<reg name="ft2" bitsize="32" type="ieee_single"/>
71
<reg name="ft3" bitsize="32" type="ieee_single"/>
72
diff --git a/gdb-xml/riscv-64bit-cpu.xml b/gdb-xml/riscv-64bit-cpu.xml
60
index XXXXXXX..XXXXXXX 100644
73
index XXXXXXX..XXXXXXX 100644
61
--- a/hw/riscv/sifive_u.c
74
--- a/gdb-xml/riscv-64bit-cpu.xml
62
+++ b/hw/riscv/sifive_u.c
75
+++ b/gdb-xml/riscv-64bit-cpu.xml
63
@@ -XXX,XX +XXX,XX @@
76
@@ -XXX,XX +XXX,XX @@
64
#include "hw/misc/unimp.h"
77
are permitted in any medium without royalty provided the copyright
65
#include "target/riscv/cpu.h"
78
notice and this notice are preserved. -->
66
#include "hw/riscv/riscv_hart.h"
79
67
-#include "hw/riscv/sifive_uart.h"
80
-<!-- Register numbers are hard-coded in order to maintain backward
68
#include "hw/riscv/sifive_u.h"
81
- compatibility with older versions of tools that didn't use xml
69
#include "hw/riscv/boot.h"
82
- register descriptions. -->
70
+#include "hw/char/sifive_uart.h"
83
-
71
#include "hw/intc/sifive_clint.h"
84
<!DOCTYPE feature SYSTEM "gdb-target.dtd">
72
#include "hw/intc/sifive_plic.h"
85
<feature name="org.gnu.gdb.riscv.cpu">
73
#include "chardev/char.h"
86
- <reg name="zero" bitsize="64" type="int" regnum="0"/>
74
diff --git a/hw/char/Kconfig b/hw/char/Kconfig
87
+ <reg name="zero" bitsize="64" type="int"/>
88
<reg name="ra" bitsize="64" type="code_ptr"/>
89
<reg name="sp" bitsize="64" type="data_ptr"/>
90
<reg name="gp" bitsize="64" type="data_ptr"/>
91
diff --git a/gdb-xml/riscv-64bit-fpu.xml b/gdb-xml/riscv-64bit-fpu.xml
75
index XXXXXXX..XXXXXXX 100644
92
index XXXXXXX..XXXXXXX 100644
76
--- a/hw/char/Kconfig
93
--- a/gdb-xml/riscv-64bit-fpu.xml
77
+++ b/hw/char/Kconfig
94
+++ b/gdb-xml/riscv-64bit-fpu.xml
78
@@ -XXX,XX +XXX,XX @@ config AVR_USART
95
@@ -XXX,XX +XXX,XX @@
79
96
are permitted in any medium without royalty provided the copyright
80
config MCHP_PFSOC_MMUART
97
notice and this notice are preserved. -->
81
bool
98
82
+
99
-<!-- Register numbers are hard-coded in order to maintain backward
83
+config SIFIVE_UART
100
- compatibility with older versions of tools that didn't use xml
84
+ bool
101
- register descriptions. -->
85
diff --git a/hw/char/meson.build b/hw/char/meson.build
102
-
86
index XXXXXXX..XXXXXXX 100644
103
<!DOCTYPE feature SYSTEM "gdb-target.dtd">
87
--- a/hw/char/meson.build
104
<feature name="org.gnu.gdb.riscv.fpu">
88
+++ b/hw/char/meson.build
105
89
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_EXYNOS4', if_true: files('exynos4210_uart.c'))
106
@@ -XXX,XX +XXX,XX @@
90
softmmu_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_uart.c'))
107
<field name="double" type="ieee_double"/>
91
softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_aux.c'))
108
</union>
92
softmmu_ss.add(when: 'CONFIG_RENESAS_SCI', if_true: files('renesas_sci.c'))
109
93
+softmmu_ss.add(when: 'CONFIG_SIFIVE_UART', if_true: files('sifive_uart.c'))
110
- <reg name="ft0" bitsize="64" type="riscv_double" regnum="33"/>
94
softmmu_ss.add(when: 'CONFIG_SH4', if_true: files('sh_serial.c'))
111
+ <reg name="ft0" bitsize="64" type="riscv_double"/>
95
softmmu_ss.add(when: 'CONFIG_STM32F2XX_USART', if_true: files('stm32f2xx_usart.c'))
112
<reg name="ft1" bitsize="64" type="riscv_double"/>
96
softmmu_ss.add(when: 'CONFIG_MCHP_PFSOC_MMUART', if_true: files('mchp_pfsoc_mmuart.c'))
113
<reg name="ft2" bitsize="64" type="riscv_double"/>
97
diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
114
<reg name="ft3" bitsize="64" type="riscv_double"/>
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
--
115
--
130
2.28.0
116
2.37.3
131
132
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Alistair Francis <alistair.francis@wdc.com>
2
2
3
Currently the reset vector address is hard-coded in a RISC-V CPU's
3
Instead of using our properties to set a config value which then might
4
instance_init() routine. In a real world we can have 2 exact same
4
be used to set the resetvec (depending on your timing), let's instead
5
CPUs except for the reset vector address, which is pretty common in
5
just set the resetvec directly in the env struct.
6
the RISC-V core IP licensing business.
7
6
8
Normally reset vector address is a configurable parameter. Let's
7
This allows us to set the reset vec from the command line with:
9
create a 64-bit property to store the reset vector address which
8
-global driver=riscv.hart_array,property=resetvec,value=0x20000400
10
covers both 32-bit and 64-bit CPUs.
11
9
12
Signed-off-by: Bin Meng <bin.meng@windriver.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
13
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
Message-Id: <1598924352-89526-2-git-send-email-bmeng.cn@gmail.com>
12
Message-Id: <20220914101108.82571-2-alistair.francis@wdc.com>
16
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
17
---
14
---
18
target/riscv/cpu.h | 1 +
15
target/riscv/cpu.h | 3 +--
19
target/riscv/cpu.c | 1 +
16
target/riscv/cpu.c | 13 +++----------
20
2 files changed, 2 insertions(+)
17
target/riscv/machine.c | 6 +++---
18
3 files changed, 7 insertions(+), 15 deletions(-)
21
19
22
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
20
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
23
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
24
--- a/target/riscv/cpu.h
22
--- a/target/riscv/cpu.h
25
+++ b/target/riscv/cpu.h
23
+++ b/target/riscv/cpu.h
26
@@ -XXX,XX +XXX,XX @@ typedef struct RISCVCPU {
24
@@ -XXX,XX +XXX,XX @@ struct CPUArchState {
27
uint16_t elen;
25
/* This contains QEMU specific information about the virt state. */
28
bool mmu;
26
target_ulong virt;
29
bool pmp;
27
target_ulong geilen;
30
+ uint64_t resetvec;
28
- target_ulong resetvec;
31
} cfg;
29
+ uint64_t resetvec;
32
} RISCVCPU;
30
33
31
target_ulong mhartid;
32
/*
33
@@ -XXX,XX +XXX,XX @@ struct RISCVCPUConfig {
34
bool pmp;
35
bool epmp;
36
bool debug;
37
- uint64_t resetvec;
38
39
bool short_isa_string;
40
};
34
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
41
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
35
index XXXXXXX..XXXXXXX 100644
42
index XXXXXXX..XXXXXXX 100644
36
--- a/target/riscv/cpu.c
43
--- a/target/riscv/cpu.c
37
+++ b/target/riscv/cpu.c
44
+++ b/target/riscv/cpu.c
45
@@ -XXX,XX +XXX,XX @@ static void set_vext_version(CPURISCVState *env, int vext_ver)
46
env->vext_ver = vext_ver;
47
}
48
49
-static void set_resetvec(CPURISCVState *env, target_ulong resetvec)
50
-{
51
-#ifndef CONFIG_USER_ONLY
52
- env->resetvec = resetvec;
53
-#endif
54
-}
55
-
56
static void riscv_any_cpu_init(Object *obj)
57
{
58
CPURISCVState *env = &RISCV_CPU(obj)->env;
59
@@ -XXX,XX +XXX,XX @@ static void rv32_imafcu_nommu_cpu_init(Object *obj)
60
61
set_misa(env, MXL_RV32, RVI | RVM | RVA | RVF | RVC | RVU);
62
set_priv_version(env, PRIV_VERSION_1_10_0);
63
- set_resetvec(env, DEFAULT_RSTVEC);
64
cpu->cfg.mmu = false;
65
}
66
#endif
67
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
68
riscv_set_feature(env, RISCV_FEATURE_DEBUG);
69
}
70
71
- set_resetvec(env, cpu->cfg.resetvec);
72
73
#ifndef CONFIG_USER_ONLY
74
if (cpu->cfg.ext_sstc) {
38
@@ -XXX,XX +XXX,XX @@ static Property riscv_cpu_properties[] = {
75
@@ -XXX,XX +XXX,XX @@ static Property riscv_cpu_properties[] = {
39
DEFINE_PROP_UINT16("elen", RISCVCPU, cfg.elen, 64),
76
DEFINE_PROP_UINT64("marchid", RISCVCPU, cfg.marchid, RISCV_CPU_MARCHID),
40
DEFINE_PROP_BOOL("mmu", RISCVCPU, cfg.mmu, true),
77
DEFINE_PROP_UINT64("mimpid", RISCVCPU, cfg.mimpid, RISCV_CPU_MIMPID),
41
DEFINE_PROP_BOOL("pmp", RISCVCPU, cfg.pmp, true),
78
42
+ DEFINE_PROP_UINT64("resetvec", RISCVCPU, cfg.resetvec, DEFAULT_RSTVEC),
79
- DEFINE_PROP_UINT64("resetvec", RISCVCPU, cfg.resetvec, DEFAULT_RSTVEC),
43
DEFINE_PROP_END_OF_LIST(),
80
+#ifndef CONFIG_USER_ONLY
44
};
81
+ DEFINE_PROP_UINT64("resetvec", RISCVCPU, env.resetvec, DEFAULT_RSTVEC),
45
82
+#endif
83
84
DEFINE_PROP_BOOL("short-isa-string", RISCVCPU, cfg.short_isa_string, false),
85
86
diff --git a/target/riscv/machine.c b/target/riscv/machine.c
87
index XXXXXXX..XXXXXXX 100644
88
--- a/target/riscv/machine.c
89
+++ b/target/riscv/machine.c
90
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_pmu_ctr_state = {
91
92
const VMStateDescription vmstate_riscv_cpu = {
93
.name = "cpu",
94
- .version_id = 4,
95
- .minimum_version_id = 4,
96
+ .version_id = 5,
97
+ .minimum_version_id = 5,
98
.post_load = riscv_cpu_post_load,
99
.fields = (VMStateField[]) {
100
VMSTATE_UINTTL_ARRAY(env.gpr, RISCVCPU, 32),
101
@@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_riscv_cpu = {
102
VMSTATE_UINT32(env.features, RISCVCPU),
103
VMSTATE_UINTTL(env.priv, RISCVCPU),
104
VMSTATE_UINTTL(env.virt, RISCVCPU),
105
- VMSTATE_UINTTL(env.resetvec, RISCVCPU),
106
+ VMSTATE_UINT64(env.resetvec, RISCVCPU),
107
VMSTATE_UINTTL(env.mhartid, RISCVCPU),
108
VMSTATE_UINT64(env.mstatus, RISCVCPU),
109
VMSTATE_UINT64(env.mip, RISCVCPU),
46
--
110
--
47
2.28.0
111
2.37.3
48
49
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Alistair Francis <alistair.francis@wdc.com>
2
2
3
Now that we have the newly introduced 'resetvec' property in the
3
The resetvec for the OpenTitan machine ended up being set to an out of
4
RISC-V CPU and HART, instead of hard-coding the reset vector addr
4
date value, so let's fix that and bump it to the correct start address
5
in the CPU's instance_init(), move that to riscv_cpu_realize()
5
(after the boot ROM)
6
based on the configured property value from the RISC-V machines.
7
6
8
Signed-off-by: Bin Meng <bin.meng@windriver.com>
7
Fixes: bf8803c64d75 "hw/riscv: opentitan: bump opentitan version"
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-Id: <20220914101108.82571-3-alistair.francis@wdc.com>
11
Message-Id: <1598924352-89526-4-git-send-email-bmeng.cn@gmail.com>
12
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
13
---
11
---
14
hw/riscv/opentitan.c | 1 +
12
hw/riscv/opentitan.c | 2 +-
15
hw/riscv/sifive_e.c | 1 +
13
1 file changed, 1 insertion(+), 1 deletion(-)
16
hw/riscv/sifive_u.c | 2 ++
17
target/riscv/cpu.c | 7 ++-----
18
4 files changed, 6 insertions(+), 5 deletions(-)
19
14
20
diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c
15
diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c
21
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/riscv/opentitan.c
17
--- a/hw/riscv/opentitan.c
23
+++ b/hw/riscv/opentitan.c
18
+++ b/hw/riscv/opentitan.c
24
@@ -XXX,XX +XXX,XX @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **errp)
19
@@ -XXX,XX +XXX,XX @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **errp)
25
&error_abort);
20
&error_abort);
26
object_property_set_int(OBJECT(&s->cpus), "num-harts", ms->smp.cpus,
21
object_property_set_int(OBJECT(&s->cpus), "num-harts", ms->smp.cpus,
27
&error_abort);
22
&error_abort);
28
+ object_property_set_int(OBJECT(&s->cpus), "resetvec", 0x8090, &error_abort);
23
- object_property_set_int(OBJECT(&s->cpus), "resetvec", 0x20000490,
29
sysbus_realize(SYS_BUS_DEVICE(&s->cpus), &error_abort);
24
+ object_property_set_int(OBJECT(&s->cpus), "resetvec", 0x20000400,
30
31
/* Boot ROM */
32
diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/riscv/sifive_e.c
35
+++ b/hw/riscv/sifive_e.c
36
@@ -XXX,XX +XXX,XX @@ static void sifive_e_soc_init(Object *obj)
37
object_initialize_child(obj, "cpus", &s->cpus, TYPE_RISCV_HART_ARRAY);
38
object_property_set_int(OBJECT(&s->cpus), "num-harts", ms->smp.cpus,
39
&error_abort);
25
&error_abort);
40
+ object_property_set_int(OBJECT(&s->cpus), "resetvec", 0x1004, &error_abort);
26
sysbus_realize(SYS_BUS_DEVICE(&s->cpus), &error_fatal);
41
object_initialize_child(obj, "riscv.sifive.e.gpio0", &s->gpio,
27
42
TYPE_SIFIVE_GPIO);
43
}
44
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
45
index XXXXXXX..XXXXXXX 100644
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
--
28
--
118
2.28.0
29
2.37.3
119
120
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 initial support for Microchip PolarFire SoC Icicle Kit.
3
On the OpenTitan hardware the resetvec is fixed at the start of ROM. In
4
The Icicle Kit board integrates a PolarFire SoC, with one SiFive's
4
QEMU we don't run the ROM code and instead just jump to the next stage.
5
E51 plus four U54 cores and many on-chip peripherals and an FPGA.
5
This means we need to be a little more flexible about what the resetvec
6
is.
6
7
7
For more details about Microchip PolarFire Soc, please see:
8
This patch allows us to set the resetvec from the command line with
8
https://www.microsemi.com/product-directory/soc-fpgas/5498-polarfire-soc-fpga
9
something like this:
10
-global driver=riscv.lowrisc.ibex.soc,property=resetvec,value=0x20000400
9
11
10
Unlike SiFive FU540, the RISC-V core resect vector is at 0x20220000.
12
This way as the next stage changes we can update the resetvec.
11
The following perepherals are created as an unimplemented device:
12
13
13
- Bus Error Uint 0/1/2/3/4
14
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
14
- L2 cache controller
15
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
- SYSREG
16
Message-Id: <20220914101108.82571-4-alistair.francis@wdc.com>
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>
35
Message-Id: <1598924352-89526-5-git-send-email-bmeng.cn@gmail.com>
36
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
17
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
37
---
18
---
38
default-configs/riscv64-softmmu.mak | 1 +
19
include/hw/riscv/opentitan.h | 2 ++
39
include/hw/riscv/microchip_pfsoc.h | 88 ++++++++
20
hw/riscv/opentitan.c | 8 +++++++-
40
hw/riscv/microchip_pfsoc.c | 312 ++++++++++++++++++++++++++++
21
2 files changed, 9 insertions(+), 1 deletion(-)
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
22
48
diff --git a/default-configs/riscv64-softmmu.mak b/default-configs/riscv64-softmmu.mak
23
diff --git a/include/hw/riscv/opentitan.h b/include/hw/riscv/opentitan.h
49
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
50
--- a/default-configs/riscv64-softmmu.mak
25
--- a/include/hw/riscv/opentitan.h
51
+++ b/default-configs/riscv64-softmmu.mak
26
+++ b/include/hw/riscv/opentitan.h
52
@@ -XXX,XX +XXX,XX @@ CONFIG_SPIKE=y
27
@@ -XXX,XX +XXX,XX @@ struct LowRISCIbexSoCState {
53
CONFIG_SIFIVE_E=y
28
IbexTimerState timer;
54
CONFIG_SIFIVE_U=y
29
IbexSPIHostState spi_host[OPENTITAN_NUM_SPI_HOSTS];
55
CONFIG_RISCV_VIRT=y
30
56
+CONFIG_MICROCHIP_PFSOC=y
31
+ uint32_t resetvec;
57
diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchip_pfsoc.h
58
new file mode 100644
59
index XXXXXXX..XXXXXXX
60
--- /dev/null
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
+
32
+
84
+#ifndef HW_MICROCHIP_PFSOC_H
33
MemoryRegion flash_mem;
85
+#define HW_MICROCHIP_PFSOC_H
34
MemoryRegion rom;
86
+
35
MemoryRegion flash_alias;
87
+typedef struct MicrochipPFSoCState {
36
diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c
88
+ /*< private >*/
37
index XXXXXXX..XXXXXXX 100644
89
+ DeviceState parent_obj;
38
--- a/hw/riscv/opentitan.c
90
+
39
+++ b/hw/riscv/opentitan.c
91
+ /*< public >*/
40
@@ -XXX,XX +XXX,XX @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **errp)
92
+ CPUClusterState e_cluster;
41
&error_abort);
93
+ CPUClusterState u_cluster;
42
object_property_set_int(OBJECT(&s->cpus), "num-harts", ms->smp.cpus,
94
+ RISCVHartArrayState e_cpus;
43
&error_abort);
95
+ RISCVHartArrayState u_cpus;
44
- object_property_set_int(OBJECT(&s->cpus), "resetvec", 0x20000400,
96
+ DeviceState *plic;
45
+ object_property_set_int(OBJECT(&s->cpus), "resetvec", s->resetvec,
97
+} MicrochipPFSoCState;
46
&error_abort);
98
+
47
sysbus_realize(SYS_BUS_DEVICE(&s->cpus), &error_fatal);
99
+#define TYPE_MICROCHIP_PFSOC "microchip.pfsoc"
48
100
+#define MICROCHIP_PFSOC(obj) \
49
@@ -XXX,XX +XXX,XX @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **errp)
101
+ OBJECT_CHECK(MicrochipPFSoCState, (obj), TYPE_MICROCHIP_PFSOC)
50
memmap[IBEX_DEV_PERI].base, memmap[IBEX_DEV_PERI].size);
102
+
51
}
103
+typedef struct MicrochipIcicleKitState {
52
104
+ /*< private >*/
53
+static Property lowrisc_ibex_soc_props[] = {
105
+ MachineState parent_obj;
54
+ DEFINE_PROP_UINT32("resetvec", LowRISCIbexSoCState, resetvec, 0x20000400),
106
+
55
+ DEFINE_PROP_END_OF_LIST()
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
+};
56
+};
136
+
57
+
137
+#define MICROCHIP_PFSOC_MANAGEMENT_CPU_COUNT 1
58
static void lowrisc_ibex_soc_class_init(ObjectClass *oc, void *data)
138
+#define MICROCHIP_PFSOC_COMPUTE_CPU_COUNT 4
59
{
139
+
60
DeviceClass *dc = DEVICE_CLASS(oc);
140
+#define MICROCHIP_PFSOC_PLIC_HART_CONFIG "MS"
61
141
+#define MICROCHIP_PFSOC_PLIC_NUM_SOURCES 185
62
+ device_class_set_props(dc, lowrisc_ibex_soc_props);
142
+#define MICROCHIP_PFSOC_PLIC_NUM_PRIORITIES 7
63
dc->realize = lowrisc_ibex_soc_realize;
143
+#define MICROCHIP_PFSOC_PLIC_PRIORITY_BASE 0x04
64
/* Reason: Uses serial_hds in realize function, thus can't be used twice */
144
+#define MICROCHIP_PFSOC_PLIC_PENDING_BASE 0x1000
65
dc->user_creatable = false;
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
+}
263
+
264
+static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp)
265
+{
266
+ MachineState *ms = MACHINE(qdev_get_machine());
267
+ MicrochipPFSoCState *s = MICROCHIP_PFSOC(dev);
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
+}
387
+
388
+static void microchip_pfsoc_soc_class_init(ObjectClass *oc, void *data)
389
+{
390
+ DeviceClass *dc = DEVICE_CLASS(oc);
391
+
392
+ dc->realize = microchip_pfsoc_soc_realize;
393
+ /* Reason: Uses serial_hds in realize function, thus can't be used twice */
394
+ dc->user_creatable = false;
395
+}
396
+
397
+static const TypeInfo microchip_pfsoc_soc_type_info = {
398
+ .name = TYPE_MICROCHIP_PFSOC,
399
+ .parent = TYPE_DEVICE,
400
+ .instance_size = sizeof(MicrochipPFSoCState),
401
+ .instance_init = microchip_pfsoc_soc_instance_init,
402
+ .class_init = microchip_pfsoc_soc_class_init,
403
+};
404
+
405
+static void microchip_pfsoc_soc_register_types(void)
406
+{
407
+ type_register_static(&microchip_pfsoc_soc_type_info);
408
+}
409
+
410
+type_init(microchip_pfsoc_soc_register_types)
411
+
412
+static void microchip_icicle_kit_machine_init(MachineState *machine)
413
+{
414
+ MachineClass *mc = MACHINE_GET_CLASS(machine);
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
--
66
--
513
2.28.0
67
2.37.3
514
515
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
After RISCVException enum is introduced, riscv_csrrw_debug() returns
4
should only contain the RISC-V SoC / machine codes plus generic
4
RISCV_EXCP_NONE to indicate there's no error. RISC-V vector GDB stub
5
codes. Let's move riscv_htif model to hw/char directory.
5
should check the result against RISCV_EXCP_NONE instead of value 0.
6
Otherwise, 'E14' packet would be incorrectly reported for vector CSRs
7
when using "info reg vector" GDB command.
6
8
7
Signed-off-by: Bin Meng <bin.meng@windriver.com>
9
Signed-off-by: Frank Chang <frank.chang@sifive.com>
10
Reviewed-by: Jim Shu <jim.shu@sifive.com>
11
Reviewed-by: Tommy Wu <tommy.wu@sifive.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
12
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-Id: <1599129623-68957-8-git-send-email-bmeng.cn@gmail.com>
13
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
14
Message-Id: <20220918083245.13028-1-frank.chang@sifive.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}/riscv_htif.h | 0
17
target/riscv/gdbstub.c | 4 ++--
13
hw/{riscv => char}/riscv_htif.c | 2 +-
18
1 file changed, 2 insertions(+), 2 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
19
23
diff --git a/include/hw/riscv/riscv_htif.h b/include/hw/char/riscv_htif.h
20
diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.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
21
index XXXXXXX..XXXXXXX 100644
32
--- a/hw/riscv/riscv_htif.c
22
--- a/target/riscv/gdbstub.c
33
+++ b/hw/char/riscv_htif.c
23
+++ b/target/riscv/gdbstub.c
34
@@ -XXX,XX +XXX,XX @@
24
@@ -XXX,XX +XXX,XX @@ static int riscv_gdb_get_vector(CPURISCVState *env, GByteArray *buf, int n)
35
#include "qapi/error.h"
25
target_ulong val = 0;
36
#include "qemu/log.h"
26
int result = riscv_csrrw_debug(env, csrno, &val, 0, 0);
37
#include "hw/sysbus.h"
27
38
+#include "hw/char/riscv_htif.h"
28
- if (result == 0) {
39
#include "hw/char/serial.h"
29
+ if (result == RISCV_EXCP_NONE) {
40
#include "chardev/char.h"
30
return gdb_get_regl(buf, val);
41
#include "chardev/char-fe.h"
31
}
42
-#include "hw/riscv/riscv_htif.h"
32
43
#include "qemu/timer.h"
33
@@ -XXX,XX +XXX,XX @@ static int riscv_gdb_set_vector(CPURISCVState *env, uint8_t *mem_buf, int n)
44
#include "qemu/error-report.h"
34
target_ulong val = ldtul_p(mem_buf);
45
35
int result = riscv_csrrw_debug(env, csrno, NULL, val, -1);
46
diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c
36
47
index XXXXXXX..XXXXXXX 100644
37
- if (result == 0) {
48
--- a/hw/riscv/spike.c
38
+ if (result == RISCV_EXCP_NONE) {
49
+++ b/hw/riscv/spike.c
39
return sizeof(target_ulong);
50
@@ -XXX,XX +XXX,XX @@
40
}
51
#include "hw/loader.h"
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
+
74
config PARALLEL
75
bool
76
default y
77
diff --git a/hw/char/meson.build b/hw/char/meson.build
78
index XXXXXXX..XXXXXXX 100644
79
--- a/hw/char/meson.build
80
+++ b/hw/char/meson.build
81
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_SH4', if_true: files('sh_serial.c'))
82
softmmu_ss.add(when: 'CONFIG_STM32F2XX_USART', if_true: files('stm32f2xx_usart.c'))
83
softmmu_ss.add(when: 'CONFIG_MCHP_PFSOC_MMUART', if_true: files('mchp_pfsoc_mmuart.c'))
84
85
+specific_ss.add(when: 'CONFIG_HTIF', if_true: files('riscv_htif.c'))
86
specific_ss.add(when: 'CONFIG_TERMINAL3270', if_true: files('terminal3270.c'))
87
specific_ss.add(when: 'CONFIG_VIRTIO', if_true: files('virtio-serial-bus.c'))
88
specific_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr_vty.c'))
89
diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
90
index XXXXXXX..XXXXXXX 100644
91
--- a/hw/riscv/Kconfig
92
+++ b/hw/riscv/Kconfig
93
@@ -XXX,XX +XXX,XX @@
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
41
112
--
42
--
113
2.28.0
43
2.37.3
114
115
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Bernhard Beschow <shentey@gmail.com>
2
2
3
This is an effort to clean up the hw/riscv directory. Ideally it
3
SiFiveEState inherits from SysBusDevice while it's TypeInfo claims it to
4
should only contain the RISC-V SoC / machine codes plus generic
4
inherit from TYPE_MACHINE. This is an inconsistency which can cause
5
codes. Let's move sifive_gpio model to hw/gpio directory.
5
undefined behavior such as memory corruption.
6
6
7
Note this also removes the trace-events in the hw/riscv directory,
7
Change SiFiveEState to inherit from MachineState since it is registered
8
since gpio is the only supported trace target in that directory.
8
as a machine.
9
9
10
Signed-off-by: Bin Meng <bin.meng@windriver.com>
10
Fixes: 0869490b1c ("riscv: sifive_e: Manually define the machine")
11
12
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
11
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
13
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
12
Message-Id: <1599129623-68957-5-git-send-email-bmeng.cn@gmail.com>
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
Message-Id: <20220922075232.33653-1-shentey@gmail.com>
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
16
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
14
---
17
---
15
hw/riscv/trace.h | 1 -
18
include/hw/riscv/sifive_e.h | 3 ++-
16
include/hw/{riscv => gpio}/sifive_gpio.h | 0
19
1 file changed, 2 insertions(+), 1 deletion(-)
17
include/hw/riscv/sifive_e.h | 2 +-
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
20
33
diff --git a/hw/riscv/trace.h b/hw/riscv/trace.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
21
diff --git a/include/hw/riscv/sifive_e.h b/include/hw/riscv/sifive_e.h
45
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
46
--- a/include/hw/riscv/sifive_e.h
23
--- a/include/hw/riscv/sifive_e.h
47
+++ b/include/hw/riscv/sifive_e.h
24
+++ b/include/hw/riscv/sifive_e.h
48
@@ -XXX,XX +XXX,XX @@
25
@@ -XXX,XX +XXX,XX @@
49
50
#include "hw/riscv/riscv_hart.h"
26
#include "hw/riscv/riscv_hart.h"
51
#include "hw/riscv/sifive_cpu.h"
27
#include "hw/riscv/sifive_cpu.h"
52
-#include "hw/riscv/sifive_gpio.h"
28
#include "hw/gpio/sifive_gpio.h"
53
+#include "hw/gpio/sifive_gpio.h"
29
+#include "hw/boards.h"
54
30
55
#define TYPE_RISCV_E_SOC "riscv.sifive.e.soc"
31
#define TYPE_RISCV_E_SOC "riscv.sifive.e.soc"
56
#define RISCV_E_SOC(obj) \
32
#define RISCV_E_SOC(obj) \
57
diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h
33
@@ -XXX,XX +XXX,XX @@ typedef struct SiFiveESoCState {
58
index XXXXXXX..XXXXXXX 100644
34
59
--- a/include/hw/riscv/sifive_u.h
35
typedef struct SiFiveEState {
60
+++ b/include/hw/riscv/sifive_u.h
36
/*< private >*/
61
@@ -XXX,XX +XXX,XX @@
37
- SysBusDevice parent_obj;
62
#include "hw/net/cadence_gem.h"
38
+ MachineState parent_obj;
63
#include "hw/riscv/riscv_hart.h"
39
64
#include "hw/riscv/sifive_cpu.h"
40
/*< public >*/
65
-#include "hw/riscv/sifive_gpio.h"
41
SiFiveESoCState soc;
66
+#include "hw/gpio/sifive_gpio.h"
67
#include "hw/misc/sifive_u_otp.h"
68
#include "hw/misc/sifive_u_prci.h"
69
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
--
42
--
178
2.28.0
43
2.37.3
179
180
diff view generated by jsdifflib
1
From: Yifei Jiang <jiangyifei@huawei.com>
1
From: Frank Chang <frank.chang@sifive.com>
2
2
3
When the cause number is equal to or greater than 23, print "(unknown)" in
3
Current RISC-V debug assumes that only type 2 trigger is supported.
4
trace_riscv_trap. The max valid number of riscv_excp_names is 23, so the last
4
To allow more types of triggers to be supported in the future
5
excpetion "guest_store_page_fault" can not be printed.
5
(e.g. type 6 trigger, which is similar to type 2 trigger with additional
6
functionality), we should determine the trigger type from tdata1.type.
6
7
7
In addition, the current check of cause is invalid for riscv_intr_names. So
8
RV_MAX_TRIGGERS is also introduced in replacement of TRIGGER_TYPE2_NUM.
8
introduce riscv_cpu_get_trap_name to get the trap cause name.
9
9
10
Signed-off-by: Yifei Jiang <jiangyifei@huawei.com>
10
Signed-off-by: Frank Chang <frank.chang@sifive.com>
11
Signed-off-by: Yipeng Yin <yinyipeng1@huawei.com>
11
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
12
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
12
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
13
Message-Id: <20200814035819.1214-1-jiangyifei@huawei.com>
13
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
14
[bmeng: fixed MXL_RV128 case, and moved macros to the following patch]
15
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
16
Message-Id: <20220909134215.1843865-2-bmeng.cn@gmail.com>
14
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
17
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
15
---
18
---
16
target/riscv/cpu.h | 1 +
19
target/riscv/cpu.h | 2 +-
17
target/riscv/cpu.c | 11 +++++++++++
20
target/riscv/debug.h | 13 +--
18
target/riscv/cpu_helper.c | 4 ++--
21
target/riscv/csr.c | 2 +-
19
3 files changed, 14 insertions(+), 2 deletions(-)
22
target/riscv/debug.c | 188 +++++++++++++++++++++++++++++------------
23
target/riscv/machine.c | 2 +-
24
5 files changed, 140 insertions(+), 67 deletions(-)
20
25
21
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
26
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
22
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
23
--- a/target/riscv/cpu.h
28
--- a/target/riscv/cpu.h
24
+++ b/target/riscv/cpu.h
29
+++ b/target/riscv/cpu.h
25
@@ -XXX,XX +XXX,XX @@ extern const char * const riscv_fpr_regnames[];
30
@@ -XXX,XX +XXX,XX @@ struct CPUArchState {
26
extern const char * const riscv_excp_names[];
31
27
extern const char * const riscv_intr_names[];
32
/* trigger module */
28
33
target_ulong trigger_cur;
29
+const char *riscv_cpu_get_trap_name(target_ulong cause, bool async);
34
- type2_trigger_t type2_trig[TRIGGER_TYPE2_NUM];
30
void riscv_cpu_do_interrupt(CPUState *cpu);
35
+ type2_trigger_t type2_trig[RV_MAX_TRIGGERS];
31
int riscv_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
36
32
int riscv_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
37
/* machine specific rdtime callback */
33
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
38
uint64_t (*rdtime_fn)(void *);
39
diff --git a/target/riscv/debug.h b/target/riscv/debug.h
34
index XXXXXXX..XXXXXXX 100644
40
index XXXXXXX..XXXXXXX 100644
35
--- a/target/riscv/cpu.c
41
--- a/target/riscv/debug.h
36
+++ b/target/riscv/cpu.c
42
+++ b/target/riscv/debug.h
37
@@ -XXX,XX +XXX,XX @@ const char * const riscv_intr_names[] = {
43
@@ -XXX,XX +XXX,XX @@
38
"reserved"
44
#ifndef RISCV_DEBUG_H
45
#define RISCV_DEBUG_H
46
47
-/* trigger indexes implemented */
48
-enum {
49
- TRIGGER_TYPE2_IDX_0 = 0,
50
- TRIGGER_TYPE2_IDX_1,
51
- TRIGGER_TYPE2_NUM,
52
- TRIGGER_NUM = TRIGGER_TYPE2_NUM
53
-};
54
+#define RV_MAX_TRIGGERS 2
55
56
/* register index of tdata CSRs */
57
enum {
58
@@ -XXX,XX +XXX,XX @@ typedef enum {
59
TRIGGER_TYPE_EXCP = 5, /* exception trigger */
60
TRIGGER_TYPE_AD_MATCH6 = 6, /* new address/data match trigger */
61
TRIGGER_TYPE_EXT_SRC = 7, /* external source trigger */
62
- TRIGGER_TYPE_UNAVAIL = 15 /* trigger exists, but unavailable */
63
+ TRIGGER_TYPE_UNAVAIL = 15, /* trigger exists, but unavailable */
64
+ TRIGGER_TYPE_NUM
65
} trigger_type_t;
66
67
typedef struct {
68
@@ -XXX,XX +XXX,XX @@ typedef struct {
69
struct CPUWatchpoint *wp;
70
} type2_trigger_t;
71
72
-/* tdata field masks */
73
+/* tdata1 field masks */
74
75
#define RV32_TYPE(t) ((uint32_t)(t) << 28)
76
#define RV32_TYPE_MASK (0xf << 28)
77
diff --git a/target/riscv/csr.c b/target/riscv/csr.c
78
index XXXXXXX..XXXXXXX 100644
79
--- a/target/riscv/csr.c
80
+++ b/target/riscv/csr.c
81
@@ -XXX,XX +XXX,XX @@ static RISCVException read_tdata(CPURISCVState *env, int csrno,
82
target_ulong *val)
83
{
84
/* return 0 in tdata1 to end the trigger enumeration */
85
- if (env->trigger_cur >= TRIGGER_NUM && csrno == CSR_TDATA1) {
86
+ if (env->trigger_cur >= RV_MAX_TRIGGERS && csrno == CSR_TDATA1) {
87
*val = 0;
88
return RISCV_EXCP_NONE;
89
}
90
diff --git a/target/riscv/debug.c b/target/riscv/debug.c
91
index XXXXXXX..XXXXXXX 100644
92
--- a/target/riscv/debug.c
93
+++ b/target/riscv/debug.c
94
@@ -XXX,XX +XXX,XX @@
95
/* tdata availability of a trigger */
96
typedef bool tdata_avail[TDATA_NUM];
97
98
-static tdata_avail tdata_mapping[TRIGGER_NUM] = {
99
- [TRIGGER_TYPE2_IDX_0 ... TRIGGER_TYPE2_IDX_1] = { true, true, false },
100
+static tdata_avail tdata_mapping[TRIGGER_TYPE_NUM] = {
101
+ [TRIGGER_TYPE_NO_EXIST] = { false, false, false },
102
+ [TRIGGER_TYPE_AD_MATCH] = { true, true, true },
103
+ [TRIGGER_TYPE_INST_CNT] = { true, false, true },
104
+ [TRIGGER_TYPE_INT] = { true, true, true },
105
+ [TRIGGER_TYPE_EXCP] = { true, true, true },
106
+ [TRIGGER_TYPE_AD_MATCH6] = { true, true, true },
107
+ [TRIGGER_TYPE_EXT_SRC] = { true, false, false },
108
+ [TRIGGER_TYPE_UNAVAIL] = { true, true, true }
39
};
109
};
40
110
41
+const char *riscv_cpu_get_trap_name(target_ulong cause, bool async)
111
/* only breakpoint size 1/2/4/8 supported */
112
@@ -XXX,XX +XXX,XX @@ static int access_size[SIZE_NUM] = {
113
[6 ... 15] = -1,
114
};
115
116
+static inline target_ulong extract_trigger_type(CPURISCVState *env,
117
+ target_ulong tdata1)
42
+{
118
+{
43
+ if (async) {
119
+ switch (riscv_cpu_mxl(env)) {
44
+ return (cause < ARRAY_SIZE(riscv_intr_names)) ?
120
+ case MXL_RV32:
45
+ riscv_intr_names[cause] : "(unknown)";
121
+ return extract32(tdata1, 28, 4);
46
+ } else {
122
+ case MXL_RV64:
47
+ return (cause < ARRAY_SIZE(riscv_excp_names)) ?
123
+ case MXL_RV128:
48
+ riscv_excp_names[cause] : "(unknown)";
124
+ return extract64(tdata1, 60, 4);
125
+ default:
126
+ g_assert_not_reached();
49
+ }
127
+ }
50
+}
128
+}
51
+
129
+
52
static void set_misa(CPURISCVState *env, target_ulong misa)
130
+static inline target_ulong get_trigger_type(CPURISCVState *env,
53
{
131
+ target_ulong trigger_index)
54
env->misa_mask = env->misa = misa;
132
+{
55
diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
133
+ target_ulong tdata1 = env->type2_trig[trigger_index].mcontrol;
134
+ return extract_trigger_type(env, tdata1);
135
+}
136
+
137
static inline target_ulong trigger_type(CPURISCVState *env,
138
trigger_type_t type)
139
{
140
@@ -XXX,XX +XXX,XX @@ static inline target_ulong trigger_type(CPURISCVState *env,
141
142
bool tdata_available(CPURISCVState *env, int tdata_index)
143
{
144
+ int trigger_type = get_trigger_type(env, env->trigger_cur);
145
+
146
if (unlikely(tdata_index >= TDATA_NUM)) {
147
return false;
148
}
149
150
- if (unlikely(env->trigger_cur >= TRIGGER_NUM)) {
151
+ if (unlikely(env->trigger_cur >= RV_MAX_TRIGGERS)) {
152
return false;
153
}
154
155
- return tdata_mapping[env->trigger_cur][tdata_index];
156
+ return tdata_mapping[trigger_type][tdata_index];
157
}
158
159
target_ulong tselect_csr_read(CPURISCVState *env)
160
@@ -XXX,XX +XXX,XX @@ static target_ulong tdata1_validate(CPURISCVState *env, target_ulong val,
161
qemu_log_mask(LOG_GUEST_ERROR,
162
"ignoring type write to tdata1 register\n");
163
}
164
+
165
if (dmode != 0) {
166
qemu_log_mask(LOG_UNIMP, "debug mode is not supported\n");
167
}
168
@@ -XXX,XX +XXX,XX @@ static void type2_breakpoint_remove(CPURISCVState *env, target_ulong index)
169
}
170
171
static target_ulong type2_reg_read(CPURISCVState *env,
172
- target_ulong trigger_index, int tdata_index)
173
+ target_ulong index, int tdata_index)
174
{
175
- uint32_t index = trigger_index - TRIGGER_TYPE2_IDX_0;
176
target_ulong tdata;
177
178
switch (tdata_index) {
179
@@ -XXX,XX +XXX,XX @@ static target_ulong type2_reg_read(CPURISCVState *env,
180
return tdata;
181
}
182
183
-static void type2_reg_write(CPURISCVState *env, target_ulong trigger_index,
184
+static void type2_reg_write(CPURISCVState *env, target_ulong index,
185
int tdata_index, target_ulong val)
186
{
187
- uint32_t index = trigger_index - TRIGGER_TYPE2_IDX_0;
188
target_ulong new_val;
189
190
switch (tdata_index) {
191
@@ -XXX,XX +XXX,XX @@ static void type2_reg_write(CPURISCVState *env, target_ulong trigger_index,
192
return;
193
}
194
195
-typedef target_ulong (*tdata_read_func)(CPURISCVState *env,
196
- target_ulong trigger_index,
197
- int tdata_index);
198
-
199
-static tdata_read_func trigger_read_funcs[TRIGGER_NUM] = {
200
- [TRIGGER_TYPE2_IDX_0 ... TRIGGER_TYPE2_IDX_1] = type2_reg_read,
201
-};
202
-
203
-typedef void (*tdata_write_func)(CPURISCVState *env,
204
- target_ulong trigger_index,
205
- int tdata_index,
206
- target_ulong val);
207
-
208
-static tdata_write_func trigger_write_funcs[TRIGGER_NUM] = {
209
- [TRIGGER_TYPE2_IDX_0 ... TRIGGER_TYPE2_IDX_1] = type2_reg_write,
210
-};
211
-
212
target_ulong tdata_csr_read(CPURISCVState *env, int tdata_index)
213
{
214
- tdata_read_func read_func = trigger_read_funcs[env->trigger_cur];
215
+ int trigger_type = get_trigger_type(env, env->trigger_cur);
216
+
217
+ switch (trigger_type) {
218
+ case TRIGGER_TYPE_AD_MATCH:
219
+ return type2_reg_read(env, env->trigger_cur, tdata_index);
220
+ break;
221
+ case TRIGGER_TYPE_INST_CNT:
222
+ case TRIGGER_TYPE_INT:
223
+ case TRIGGER_TYPE_EXCP:
224
+ case TRIGGER_TYPE_AD_MATCH6:
225
+ case TRIGGER_TYPE_EXT_SRC:
226
+ qemu_log_mask(LOG_UNIMP, "trigger type: %d is not supported\n",
227
+ trigger_type);
228
+ break;
229
+ case TRIGGER_TYPE_NO_EXIST:
230
+ case TRIGGER_TYPE_UNAVAIL:
231
+ qemu_log_mask(LOG_GUEST_ERROR, "trigger type: %d does not exit\n",
232
+ trigger_type);
233
+ break;
234
+ default:
235
+ g_assert_not_reached();
236
+ }
237
238
- return read_func(env, env->trigger_cur, tdata_index);
239
+ return 0;
240
}
241
242
void tdata_csr_write(CPURISCVState *env, int tdata_index, target_ulong val)
243
{
244
- tdata_write_func write_func = trigger_write_funcs[env->trigger_cur];
245
+ int trigger_type;
246
247
- return write_func(env, env->trigger_cur, tdata_index, val);
248
+ if (tdata_index == TDATA1) {
249
+ trigger_type = extract_trigger_type(env, val);
250
+ } else {
251
+ trigger_type = get_trigger_type(env, env->trigger_cur);
252
+ }
253
+
254
+ switch (trigger_type) {
255
+ case TRIGGER_TYPE_AD_MATCH:
256
+ type2_reg_write(env, env->trigger_cur, tdata_index, val);
257
+ break;
258
+ case TRIGGER_TYPE_INST_CNT:
259
+ case TRIGGER_TYPE_INT:
260
+ case TRIGGER_TYPE_EXCP:
261
+ case TRIGGER_TYPE_AD_MATCH6:
262
+ case TRIGGER_TYPE_EXT_SRC:
263
+ qemu_log_mask(LOG_UNIMP, "trigger type: %d is not supported\n",
264
+ trigger_type);
265
+ break;
266
+ case TRIGGER_TYPE_NO_EXIST:
267
+ case TRIGGER_TYPE_UNAVAIL:
268
+ qemu_log_mask(LOG_GUEST_ERROR, "trigger type: %d does not exit\n",
269
+ trigger_type);
270
+ break;
271
+ default:
272
+ g_assert_not_reached();
273
+ }
274
}
275
276
void riscv_cpu_debug_excp_handler(CPUState *cs)
277
@@ -XXX,XX +XXX,XX @@ bool riscv_cpu_debug_check_breakpoint(CPUState *cs)
278
CPUBreakpoint *bp;
279
target_ulong ctrl;
280
target_ulong pc;
281
+ int trigger_type;
282
int i;
283
284
QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {
285
- for (i = 0; i < TRIGGER_TYPE2_NUM; i++) {
286
- ctrl = env->type2_trig[i].mcontrol;
287
- pc = env->type2_trig[i].maddress;
288
-
289
- if ((ctrl & TYPE2_EXEC) && (bp->pc == pc)) {
290
- /* check U/S/M bit against current privilege level */
291
- if ((ctrl >> 3) & BIT(env->priv)) {
292
- return true;
293
+ for (i = 0; i < RV_MAX_TRIGGERS; i++) {
294
+ trigger_type = get_trigger_type(env, i);
295
+
296
+ switch (trigger_type) {
297
+ case TRIGGER_TYPE_AD_MATCH:
298
+ ctrl = env->type2_trig[i].mcontrol;
299
+ pc = env->type2_trig[i].maddress;
300
+
301
+ if ((ctrl & TYPE2_EXEC) && (bp->pc == pc)) {
302
+ /* check U/S/M bit against current privilege level */
303
+ if ((ctrl >> 3) & BIT(env->priv)) {
304
+ return true;
305
+ }
306
}
307
+ break;
308
+ default:
309
+ /* other trigger types are not supported or irrelevant */
310
+ break;
311
}
312
}
313
}
314
@@ -XXX,XX +XXX,XX @@ bool riscv_cpu_debug_check_watchpoint(CPUState *cs, CPUWatchpoint *wp)
315
CPURISCVState *env = &cpu->env;
316
target_ulong ctrl;
317
target_ulong addr;
318
+ int trigger_type;
319
int flags;
320
int i;
321
322
- for (i = 0; i < TRIGGER_TYPE2_NUM; i++) {
323
- ctrl = env->type2_trig[i].mcontrol;
324
- addr = env->type2_trig[i].maddress;
325
- flags = 0;
326
+ for (i = 0; i < RV_MAX_TRIGGERS; i++) {
327
+ trigger_type = get_trigger_type(env, i);
328
329
- if (ctrl & TYPE2_LOAD) {
330
- flags |= BP_MEM_READ;
331
- }
332
- if (ctrl & TYPE2_STORE) {
333
- flags |= BP_MEM_WRITE;
334
- }
335
+ switch (trigger_type) {
336
+ case TRIGGER_TYPE_AD_MATCH:
337
+ ctrl = env->type2_trig[i].mcontrol;
338
+ addr = env->type2_trig[i].maddress;
339
+ flags = 0;
340
341
- if ((wp->flags & flags) && (wp->vaddr == addr)) {
342
- /* check U/S/M bit against current privilege level */
343
- if ((ctrl >> 3) & BIT(env->priv)) {
344
- return true;
345
+ if (ctrl & TYPE2_LOAD) {
346
+ flags |= BP_MEM_READ;
347
+ }
348
+ if (ctrl & TYPE2_STORE) {
349
+ flags |= BP_MEM_WRITE;
350
+ }
351
+
352
+ if ((wp->flags & flags) && (wp->vaddr == addr)) {
353
+ /* check U/S/M bit against current privilege level */
354
+ if ((ctrl >> 3) & BIT(env->priv)) {
355
+ return true;
356
+ }
357
}
358
+ break;
359
+ default:
360
+ /* other trigger types are not supported */
361
+ break;
362
}
363
}
364
365
@@ -XXX,XX +XXX,XX @@ bool riscv_cpu_debug_check_watchpoint(CPUState *cs, CPUWatchpoint *wp)
366
367
void riscv_trigger_init(CPURISCVState *env)
368
{
369
- target_ulong type2 = trigger_type(env, TRIGGER_TYPE_AD_MATCH);
370
+ target_ulong tdata1 = trigger_type(env, TRIGGER_TYPE_AD_MATCH);
371
int i;
372
373
- /* type 2 triggers */
374
- for (i = 0; i < TRIGGER_TYPE2_NUM; i++) {
375
+ /* init to type 2 triggers */
376
+ for (i = 0; i < RV_MAX_TRIGGERS; i++) {
377
/*
378
* type = TRIGGER_TYPE_AD_MATCH
379
* dmode = 0 (both debug and M-mode can write tdata)
380
@@ -XXX,XX +XXX,XX @@ void riscv_trigger_init(CPURISCVState *env)
381
* chain = 0 (unimplemented, always 0)
382
* match = 0 (always 0, when any compare value equals tdata2)
383
*/
384
- env->type2_trig[i].mcontrol = type2;
385
+ env->type2_trig[i].mcontrol = tdata1;
386
env->type2_trig[i].maddress = 0;
387
env->type2_trig[i].bp = NULL;
388
env->type2_trig[i].wp = NULL;
389
diff --git a/target/riscv/machine.c b/target/riscv/machine.c
56
index XXXXXXX..XXXXXXX 100644
390
index XXXXXXX..XXXXXXX 100644
57
--- a/target/riscv/cpu_helper.c
391
--- a/target/riscv/machine.c
58
+++ b/target/riscv/cpu_helper.c
392
+++ b/target/riscv/machine.c
59
@@ -XXX,XX +XXX,XX @@ void riscv_cpu_do_interrupt(CPUState *cs)
393
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_debug = {
60
}
394
.needed = debug_needed,
61
}
395
.fields = (VMStateField[]) {
62
396
VMSTATE_UINTTL(env.trigger_cur, RISCVCPU),
63
- trace_riscv_trap(env->mhartid, async, cause, env->pc, tval, cause < 23 ?
397
- VMSTATE_STRUCT_ARRAY(env.type2_trig, RISCVCPU, TRIGGER_TYPE2_NUM,
64
- (async ? riscv_intr_names : riscv_excp_names)[cause] : "(unknown)");
398
+ VMSTATE_STRUCT_ARRAY(env.type2_trig, RISCVCPU, RV_MAX_TRIGGERS,
65
+ trace_riscv_trap(env->mhartid, async, cause, env->pc, tval,
399
0, vmstate_debug_type2, type2_trigger_t),
66
+ riscv_cpu_get_trap_name(cause, async));
400
VMSTATE_END_OF_LIST()
67
401
}
68
if (env->priv <= PRV_S &&
69
cause < TARGET_LONG_BITS && ((deleg >> cause) & 1)) {
70
--
402
--
71
2.28.0
403
2.37.3
72
73
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Frank Chang <frank.chang@sifive.com>
2
2
3
SiFive FU540 SoC integrates a platform DMA controller with 4 DMA
3
Introduce build_tdata1() to build tdata1 register content, which can be
4
channels. This connects the exsiting SiFive PDMA model to the SoC,
4
shared among all types of triggers.
5
and adds its device tree data as well.
6
5
7
Signed-off-by: Bin Meng <bin.meng@windriver.com>
6
Signed-off-by: Frank Chang <frank.chang@sifive.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
9
Message-Id: <1598924352-89526-17-git-send-email-bmeng.cn@gmail.com>
8
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
9
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
10
[bmeng: moved RV{32,64}_DATA_MASK definition to this patch]
11
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
12
Message-Id: <20220909134215.1843865-3-bmeng.cn@gmail.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
14
---
12
include/hw/riscv/sifive_u.h | 11 +++++++++++
15
target/riscv/debug.h | 2 ++
13
hw/riscv/sifive_u.c | 30 ++++++++++++++++++++++++++++++
16
target/riscv/debug.c | 15 ++++++++++-----
14
hw/riscv/Kconfig | 1 +
17
2 files changed, 12 insertions(+), 5 deletions(-)
15
3 files changed, 42 insertions(+)
16
18
17
diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h
19
diff --git a/target/riscv/debug.h b/target/riscv/debug.h
18
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/riscv/sifive_u.h
21
--- a/target/riscv/debug.h
20
+++ b/include/hw/riscv/sifive_u.h
22
+++ b/target/riscv/debug.h
21
@@ -XXX,XX +XXX,XX @@
23
@@ -XXX,XX +XXX,XX @@ typedef struct {
22
#ifndef HW_SIFIVE_U_H
24
#define RV32_TYPE(t) ((uint32_t)(t) << 28)
23
#define HW_SIFIVE_U_H
25
#define RV32_TYPE_MASK (0xf << 28)
24
26
#define RV32_DMODE BIT(27)
25
+#include "hw/dma/sifive_pdma.h"
27
+#define RV32_DATA_MASK 0x7ffffff
26
#include "hw/net/cadence_gem.h"
28
#define RV64_TYPE(t) ((uint64_t)(t) << 60)
27
#include "hw/riscv/riscv_hart.h"
29
#define RV64_TYPE_MASK (0xfULL << 60)
28
#include "hw/riscv/sifive_cpu.h"
30
#define RV64_DMODE BIT_ULL(59)
29
@@ -XXX,XX +XXX,XX @@ typedef struct SiFiveUSoCState {
31
+#define RV64_DATA_MASK 0x7ffffffffffffff
30
SiFiveUPRCIState prci;
32
31
SIFIVEGPIOState gpio;
33
/* mcontrol field masks */
32
SiFiveUOTPState otp;
34
33
+ SiFivePDMAState dma;
35
diff --git a/target/riscv/debug.c b/target/riscv/debug.c
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
36
index XXXXXXX..XXXXXXX 100644
62
--- a/hw/riscv/sifive_u.c
37
--- a/target/riscv/debug.c
63
+++ b/hw/riscv/sifive_u.c
38
+++ b/target/riscv/debug.c
64
@@ -XXX,XX +XXX,XX @@
39
@@ -XXX,XX +XXX,XX @@ static inline target_ulong get_trigger_type(CPURISCVState *env,
65
* 4) GPIO (General Purpose Input/Output Controller)
40
return extract_trigger_type(env, tdata1);
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
}
41
}
109
42
110
static void sifive_u_soc_realize(DeviceState *dev, Error **errp)
43
-static inline target_ulong trigger_type(CPURISCVState *env,
111
@@ -XXX,XX +XXX,XX @@ static void sifive_u_soc_realize(DeviceState *dev, Error **errp)
44
- trigger_type_t type)
112
SIFIVE_U_GPIO_IRQ0 + i));
45
+static inline target_ulong build_tdata1(CPURISCVState *env,
113
}
46
+ trigger_type_t type,
114
47
+ bool dmode, target_ulong data)
115
+ /* PDMA */
48
{
116
+ sysbus_realize(SYS_BUS_DEVICE(&s->dma), errp);
49
target_ulong tdata1;
117
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->dma), 0, memmap[SIFIVE_U_PDMA].base);
50
118
+
51
switch (riscv_cpu_mxl(env)) {
119
+ /* Connect PDMA interrupts to the PLIC */
52
case MXL_RV32:
120
+ for (i = 0; i < SIFIVE_PDMA_IRQS; i++) {
53
- tdata1 = RV32_TYPE(type);
121
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->dma), i,
54
+ tdata1 = RV32_TYPE(type) |
122
+ qdev_get_gpio_in(DEVICE(s->plic),
55
+ (dmode ? RV32_DMODE : 0) |
123
+ SIFIVE_U_PDMA_IRQ0 + i));
56
+ (data & RV32_DATA_MASK);
124
+ }
57
break;
125
+
58
case MXL_RV64:
126
qdev_prop_set_uint32(DEVICE(&s->otp), "serial", s->serial);
59
case MXL_RV128:
127
if (!sysbus_realize(SYS_BUS_DEVICE(&s->otp), errp)) {
60
- tdata1 = RV64_TYPE(type);
128
return;
61
+ tdata1 = RV64_TYPE(type) |
129
diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
62
+ (dmode ? RV64_DMODE : 0) |
130
index XXXXXXX..XXXXXXX 100644
63
+ (data & RV64_DATA_MASK);
131
--- a/hw/riscv/Kconfig
64
break;
132
+++ b/hw/riscv/Kconfig
65
default:
133
@@ -XXX,XX +XXX,XX @@ config SIFIVE_U
66
g_assert_not_reached();
134
select CADENCE
67
@@ -XXX,XX +XXX,XX @@ bool riscv_cpu_debug_check_watchpoint(CPUState *cs, CPUWatchpoint *wp)
135
select HART
68
136
select SIFIVE
69
void riscv_trigger_init(CPURISCVState *env)
137
+ select SIFIVE_PDMA
70
{
138
select UNIMP
71
- target_ulong tdata1 = trigger_type(env, TRIGGER_TYPE_AD_MATCH);
139
72
+ target_ulong tdata1 = build_tdata1(env, TRIGGER_TYPE_AD_MATCH, 0, 0);
140
config SPIKE
73
int i;
74
75
/* init to type 2 triggers */
141
--
76
--
142
2.28.0
77
2.37.3
143
144
diff view generated by jsdifflib
1
From: Nathan Chancellor <natechancellor@gmail.com>
1
From: Frank Chang <frank.chang@sifive.com>
2
2
3
When shutting down the machine running a mainline Linux kernel, the
3
Replace type2_trigger_t with the real tdata1, tdata2, and tdata3 CSRs,
4
following error happens:
4
which allows us to support more types of triggers in the future.
5
5
6
$ build/riscv64-softmmu/qemu-system-riscv64 -bios default -M virt \
6
Signed-off-by: Frank Chang <frank.chang@sifive.com>
7
-display none -initrd rootfs.cpio -kernel Image -m 512m \
7
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
8
-nodefaults -serial mon:stdio
8
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
9
...
9
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
10
Requesting system poweroff
10
Message-Id: <20220909134215.1843865-4-bmeng.cn@gmail.com>
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
32
The kernel does a 16-bit write when powering off the machine, which
33
was allowed before commit 5d971f9e67 ("memory: Revert "memory: accept
34
mismatching sizes in memory_region_access_valid""). Make min_access_size
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>
43
Message-Id: <20200901055822.2721209-1-natechancellor@gmail.com>
44
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
45
---
12
---
46
hw/riscv/sifive_test.c | 2 +-
13
target/riscv/cpu.h | 6 ++-
47
1 file changed, 1 insertion(+), 1 deletion(-)
14
target/riscv/debug.h | 7 ---
15
target/riscv/debug.c | 103 +++++++++++++++--------------------------
16
target/riscv/machine.c | 20 ++------
17
4 files changed, 48 insertions(+), 88 deletions(-)
48
18
49
diff --git a/hw/riscv/sifive_test.c b/hw/riscv/sifive_test.c
19
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
50
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
51
--- a/hw/riscv/sifive_test.c
21
--- a/target/riscv/cpu.h
52
+++ b/hw/riscv/sifive_test.c
22
+++ b/target/riscv/cpu.h
53
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps sifive_test_ops = {
23
@@ -XXX,XX +XXX,XX @@ struct CPUArchState {
54
.write = sifive_test_write,
24
55
.endianness = DEVICE_NATIVE_ENDIAN,
25
/* trigger module */
56
.valid = {
26
target_ulong trigger_cur;
57
- .min_access_size = 4,
27
- type2_trigger_t type2_trig[RV_MAX_TRIGGERS];
58
+ .min_access_size = 2,
28
+ target_ulong tdata1[RV_MAX_TRIGGERS];
59
.max_access_size = 4
29
+ target_ulong tdata2[RV_MAX_TRIGGERS];
30
+ target_ulong tdata3[RV_MAX_TRIGGERS];
31
+ struct CPUBreakpoint *cpu_breakpoint[RV_MAX_TRIGGERS];
32
+ struct CPUWatchpoint *cpu_watchpoint[RV_MAX_TRIGGERS];
33
34
/* machine specific rdtime callback */
35
uint64_t (*rdtime_fn)(void *);
36
diff --git a/target/riscv/debug.h b/target/riscv/debug.h
37
index XXXXXXX..XXXXXXX 100644
38
--- a/target/riscv/debug.h
39
+++ b/target/riscv/debug.h
40
@@ -XXX,XX +XXX,XX @@ typedef enum {
41
TRIGGER_TYPE_NUM
42
} trigger_type_t;
43
44
-typedef struct {
45
- target_ulong mcontrol;
46
- target_ulong maddress;
47
- struct CPUBreakpoint *bp;
48
- struct CPUWatchpoint *wp;
49
-} type2_trigger_t;
50
-
51
/* tdata1 field masks */
52
53
#define RV32_TYPE(t) ((uint32_t)(t) << 28)
54
diff --git a/target/riscv/debug.c b/target/riscv/debug.c
55
index XXXXXXX..XXXXXXX 100644
56
--- a/target/riscv/debug.c
57
+++ b/target/riscv/debug.c
58
@@ -XXX,XX +XXX,XX @@ static inline target_ulong extract_trigger_type(CPURISCVState *env,
59
static inline target_ulong get_trigger_type(CPURISCVState *env,
60
target_ulong trigger_index)
61
{
62
- target_ulong tdata1 = env->type2_trig[trigger_index].mcontrol;
63
- return extract_trigger_type(env, tdata1);
64
+ return extract_trigger_type(env, env->tdata1[trigger_index]);
65
}
66
67
static inline target_ulong build_tdata1(CPURISCVState *env,
68
@@ -XXX,XX +XXX,XX @@ static inline void warn_always_zero_bit(target_ulong val, target_ulong mask,
69
}
70
}
71
72
+/* type 2 trigger */
73
+
74
static uint32_t type2_breakpoint_size(CPURISCVState *env, target_ulong ctrl)
75
{
76
uint32_t size, sizelo, sizehi = 0;
77
@@ -XXX,XX +XXX,XX @@ static target_ulong type2_mcontrol_validate(CPURISCVState *env,
78
79
static void type2_breakpoint_insert(CPURISCVState *env, target_ulong index)
80
{
81
- target_ulong ctrl = env->type2_trig[index].mcontrol;
82
- target_ulong addr = env->type2_trig[index].maddress;
83
+ target_ulong ctrl = env->tdata1[index];
84
+ target_ulong addr = env->tdata2[index];
85
bool enabled = type2_breakpoint_enabled(ctrl);
86
CPUState *cs = env_cpu(env);
87
int flags = BP_CPU | BP_STOP_BEFORE_ACCESS;
88
@@ -XXX,XX +XXX,XX @@ static void type2_breakpoint_insert(CPURISCVState *env, target_ulong index)
89
}
90
91
if (ctrl & TYPE2_EXEC) {
92
- cpu_breakpoint_insert(cs, addr, flags, &env->type2_trig[index].bp);
93
+ cpu_breakpoint_insert(cs, addr, flags, &env->cpu_breakpoint[index]);
94
}
95
96
if (ctrl & TYPE2_LOAD) {
97
@@ -XXX,XX +XXX,XX @@ static void type2_breakpoint_insert(CPURISCVState *env, target_ulong index)
98
size = type2_breakpoint_size(env, ctrl);
99
if (size != 0) {
100
cpu_watchpoint_insert(cs, addr, size, flags,
101
- &env->type2_trig[index].wp);
102
+ &env->cpu_watchpoint[index]);
103
} else {
104
cpu_watchpoint_insert(cs, addr, 8, flags,
105
- &env->type2_trig[index].wp);
106
+ &env->cpu_watchpoint[index]);
107
}
108
}
109
}
110
@@ -XXX,XX +XXX,XX @@ static void type2_breakpoint_remove(CPURISCVState *env, target_ulong index)
111
{
112
CPUState *cs = env_cpu(env);
113
114
- if (env->type2_trig[index].bp) {
115
- cpu_breakpoint_remove_by_ref(cs, env->type2_trig[index].bp);
116
- env->type2_trig[index].bp = NULL;
117
+ if (env->cpu_breakpoint[index]) {
118
+ cpu_breakpoint_remove_by_ref(cs, env->cpu_breakpoint[index]);
119
+ env->cpu_breakpoint[index] = NULL;
120
}
121
122
- if (env->type2_trig[index].wp) {
123
- cpu_watchpoint_remove_by_ref(cs, env->type2_trig[index].wp);
124
- env->type2_trig[index].wp = NULL;
125
+ if (env->cpu_watchpoint[index]) {
126
+ cpu_watchpoint_remove_by_ref(cs, env->cpu_watchpoint[index]);
127
+ env->cpu_watchpoint[index] = NULL;
128
}
129
}
130
131
-static target_ulong type2_reg_read(CPURISCVState *env,
132
- target_ulong index, int tdata_index)
133
-{
134
- target_ulong tdata;
135
-
136
- switch (tdata_index) {
137
- case TDATA1:
138
- tdata = env->type2_trig[index].mcontrol;
139
- break;
140
- case TDATA2:
141
- tdata = env->type2_trig[index].maddress;
142
- break;
143
- default:
144
- g_assert_not_reached();
145
- }
146
-
147
- return tdata;
148
-}
149
-
150
static void type2_reg_write(CPURISCVState *env, target_ulong index,
151
int tdata_index, target_ulong val)
152
{
153
@@ -XXX,XX +XXX,XX @@ static void type2_reg_write(CPURISCVState *env, target_ulong index,
154
switch (tdata_index) {
155
case TDATA1:
156
new_val = type2_mcontrol_validate(env, val);
157
- if (new_val != env->type2_trig[index].mcontrol) {
158
- env->type2_trig[index].mcontrol = new_val;
159
+ if (new_val != env->tdata1[index]) {
160
+ env->tdata1[index] = new_val;
161
type2_breakpoint_remove(env, index);
162
type2_breakpoint_insert(env, index);
163
}
164
break;
165
case TDATA2:
166
- if (val != env->type2_trig[index].maddress) {
167
- env->type2_trig[index].maddress = val;
168
+ if (val != env->tdata2[index]) {
169
+ env->tdata2[index] = val;
170
type2_breakpoint_remove(env, index);
171
type2_breakpoint_insert(env, index);
172
}
173
break;
174
+ case TDATA3:
175
+ qemu_log_mask(LOG_UNIMP,
176
+ "tdata3 is not supported for type 2 trigger\n");
177
+ break;
178
default:
179
g_assert_not_reached();
180
}
181
@@ -XXX,XX +XXX,XX @@ static void type2_reg_write(CPURISCVState *env, target_ulong index,
182
183
target_ulong tdata_csr_read(CPURISCVState *env, int tdata_index)
184
{
185
- int trigger_type = get_trigger_type(env, env->trigger_cur);
186
-
187
- switch (trigger_type) {
188
- case TRIGGER_TYPE_AD_MATCH:
189
- return type2_reg_read(env, env->trigger_cur, tdata_index);
190
- break;
191
- case TRIGGER_TYPE_INST_CNT:
192
- case TRIGGER_TYPE_INT:
193
- case TRIGGER_TYPE_EXCP:
194
- case TRIGGER_TYPE_AD_MATCH6:
195
- case TRIGGER_TYPE_EXT_SRC:
196
- qemu_log_mask(LOG_UNIMP, "trigger type: %d is not supported\n",
197
- trigger_type);
198
- break;
199
- case TRIGGER_TYPE_NO_EXIST:
200
- case TRIGGER_TYPE_UNAVAIL:
201
- qemu_log_mask(LOG_GUEST_ERROR, "trigger type: %d does not exit\n",
202
- trigger_type);
203
- break;
204
+ switch (tdata_index) {
205
+ case TDATA1:
206
+ return env->tdata1[env->trigger_cur];
207
+ case TDATA2:
208
+ return env->tdata2[env->trigger_cur];
209
+ case TDATA3:
210
+ return env->tdata3[env->trigger_cur];
211
default:
212
g_assert_not_reached();
213
}
214
-
215
- return 0;
216
}
217
218
void tdata_csr_write(CPURISCVState *env, int tdata_index, target_ulong val)
219
@@ -XXX,XX +XXX,XX @@ bool riscv_cpu_debug_check_breakpoint(CPUState *cs)
220
221
switch (trigger_type) {
222
case TRIGGER_TYPE_AD_MATCH:
223
- ctrl = env->type2_trig[i].mcontrol;
224
- pc = env->type2_trig[i].maddress;
225
+ ctrl = env->tdata1[i];
226
+ pc = env->tdata2[i];
227
228
if ((ctrl & TYPE2_EXEC) && (bp->pc == pc)) {
229
/* check U/S/M bit against current privilege level */
230
@@ -XXX,XX +XXX,XX @@ bool riscv_cpu_debug_check_watchpoint(CPUState *cs, CPUWatchpoint *wp)
231
232
switch (trigger_type) {
233
case TRIGGER_TYPE_AD_MATCH:
234
- ctrl = env->type2_trig[i].mcontrol;
235
- addr = env->type2_trig[i].maddress;
236
+ ctrl = env->tdata1[i];
237
+ addr = env->tdata2[i];
238
flags = 0;
239
240
if (ctrl & TYPE2_LOAD) {
241
@@ -XXX,XX +XXX,XX @@ void riscv_trigger_init(CPURISCVState *env)
242
* chain = 0 (unimplemented, always 0)
243
* match = 0 (always 0, when any compare value equals tdata2)
244
*/
245
- env->type2_trig[i].mcontrol = tdata1;
246
- env->type2_trig[i].maddress = 0;
247
- env->type2_trig[i].bp = NULL;
248
- env->type2_trig[i].wp = NULL;
249
+ env->tdata1[i] = tdata1;
250
+ env->tdata2[i] = 0;
251
+ env->tdata3[i] = 0;
252
+ env->cpu_breakpoint[i] = NULL;
253
+ env->cpu_watchpoint[i] = NULL;
254
}
255
}
256
diff --git a/target/riscv/machine.c b/target/riscv/machine.c
257
index XXXXXXX..XXXXXXX 100644
258
--- a/target/riscv/machine.c
259
+++ b/target/riscv/machine.c
260
@@ -XXX,XX +XXX,XX @@ static bool debug_needed(void *opaque)
261
return riscv_feature(env, RISCV_FEATURE_DEBUG);
262
}
263
264
-static const VMStateDescription vmstate_debug_type2 = {
265
- .name = "cpu/debug/type2",
266
- .version_id = 1,
267
- .minimum_version_id = 1,
268
- .fields = (VMStateField[]) {
269
- VMSTATE_UINTTL(mcontrol, type2_trigger_t),
270
- VMSTATE_UINTTL(maddress, type2_trigger_t),
271
- VMSTATE_END_OF_LIST()
272
- }
273
-};
274
-
275
static const VMStateDescription vmstate_debug = {
276
.name = "cpu/debug",
277
- .version_id = 1,
278
- .minimum_version_id = 1,
279
+ .version_id = 2,
280
+ .minimum_version_id = 2,
281
.needed = debug_needed,
282
.fields = (VMStateField[]) {
283
VMSTATE_UINTTL(env.trigger_cur, RISCVCPU),
284
- VMSTATE_STRUCT_ARRAY(env.type2_trig, RISCVCPU, RV_MAX_TRIGGERS,
285
- 0, vmstate_debug_type2, type2_trigger_t),
286
+ VMSTATE_UINTTL_ARRAY(env.tdata1, RISCVCPU, RV_MAX_TRIGGERS),
287
+ VMSTATE_UINTTL_ARRAY(env.tdata2, RISCVCPU, RV_MAX_TRIGGERS),
288
+ VMSTATE_UINTTL_ARRAY(env.tdata3, RISCVCPU, RV_MAX_TRIGGERS),
289
VMSTATE_END_OF_LIST()
60
}
290
}
61
};
291
};
62
--
292
--
63
2.28.0
293
2.37.3
64
65
diff view generated by jsdifflib
Deleted patch
1
From: Bin Meng <bin.meng@windriver.com>
2
1
3
RISC-V machines do not instantiate RISC-V CPUs directly, instead
4
they do that via the hart array. Add a new property for the reset
5
vector address to allow the value to be passed to the CPU, before
6
CPU is realized.
7
8
Signed-off-by: Bin Meng <bin.meng@windriver.com>
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
20
--- a/include/hw/riscv/riscv_hart.h
21
+++ b/include/hw/riscv/riscv_hart.h
22
@@ -XXX,XX +XXX,XX @@ typedef struct RISCVHartArrayState {
23
uint32_t num_harts;
24
uint32_t hartid_base;
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
{
46
object_initialize_child(OBJECT(s), "harts[*]", &s->harts[idx], cpu_type);
47
+ qdev_prop_set_uint64(DEVICE(&s->harts[idx]), "resetvec", s->resetvec);
48
s->harts[idx].env.mhartid = s->hartid_base + idx;
49
qemu_register_reset(riscv_harts_cpu_reset, &s->harts[idx]);
50
return qdev_realize(DEVICE(&s->harts[idx]), NULL, errp);
51
--
52
2.28.0
53
54
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Frank Chang <frank.chang@sifive.com>
2
2
3
Microchip PolarFire SoC integrates one Cadence SDHCI controller.
3
The value of tselect CSR can be written should be limited within the
4
On the Icicle Kit board, one eMMC chip and an external SD card
4
range of supported triggers number.
5
connect to this controller depending on different configuration.
6
5
7
As QEMU does not support eMMC yet, we just emulate the SD card
6
Signed-off-by: Frank Chang <frank.chang@sifive.com>
8
configuration. To test this, the Hart Software Services (HSS)
7
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
9
should choose the SD card configuration:
8
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
10
9
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
11
$ cp boards/icicle-kit-es/def_config.sdcard .config
10
Message-Id: <20220909134215.1843865-5-bmeng.cn@gmail.com>
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>
26
Message-Id: <1598924352-89526-9-git-send-email-bmeng.cn@gmail.com>
27
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
28
---
12
---
29
include/hw/riscv/microchip_pfsoc.h | 4 ++++
13
target/riscv/debug.c | 9 +++------
30
hw/riscv/microchip_pfsoc.c | 23 +++++++++++++++++++++++
14
1 file changed, 3 insertions(+), 6 deletions(-)
31
hw/riscv/Kconfig | 1 +
32
3 files changed, 28 insertions(+)
33
15
34
diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchip_pfsoc.h
16
diff --git a/target/riscv/debug.c b/target/riscv/debug.c
35
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
36
--- a/include/hw/riscv/microchip_pfsoc.h
18
--- a/target/riscv/debug.c
37
+++ b/include/hw/riscv/microchip_pfsoc.h
19
+++ b/target/riscv/debug.c
38
@@ -XXX,XX +XXX,XX @@
20
@@ -XXX,XX +XXX,XX @@ bool tdata_available(CPURISCVState *env, int tdata_index)
39
#define HW_MICROCHIP_PFSOC_H
21
return false;
40
22
}
41
#include "hw/char/mchp_pfsoc_mmuart.h"
23
42
+#include "hw/sd/cadence_sdhci.h"
24
- if (unlikely(env->trigger_cur >= RV_MAX_TRIGGERS)) {
43
25
- return false;
44
typedef struct MicrochipPFSoCState {
26
- }
45
/*< private >*/
27
-
46
@@ -XXX,XX +XXX,XX @@ typedef struct MicrochipPFSoCState {
28
return tdata_mapping[trigger_type][tdata_index];
47
MchpPfSoCMMUartState *serial2;
48
MchpPfSoCMMUartState *serial3;
49
MchpPfSoCMMUartState *serial4;
50
+ CadenceSDHCIState sdhci;
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
72
--- a/hw/riscv/microchip_pfsoc.c
73
+++ b/hw/riscv/microchip_pfsoc.c
74
@@ -XXX,XX +XXX,XX @@
75
* 1) PLIC (Platform Level Interrupt Controller)
76
* 2) eNVM (Embedded Non-Volatile Memory)
77
* 3) MMUARTs (Multi-Mode UART)
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
+
95
+ object_initialize_child(obj, "sd-controller", &s->sdhci,
96
+ TYPE_CADENCE_SDHCI);
97
}
29
}
98
30
99
static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp)
31
@@ -XXX,XX +XXX,XX @@ target_ulong tselect_csr_read(CPURISCVState *env)
100
@@ -XXX,XX +XXX,XX @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp)
32
101
memmap[MICROCHIP_PFSOC_MPUCFG].base,
33
void tselect_csr_write(CPURISCVState *env, target_ulong val)
102
memmap[MICROCHIP_PFSOC_MPUCFG].size);
34
{
103
35
- /* all target_ulong bits of tselect are implemented */
104
+ /* SDHCI */
36
- env->trigger_cur = val;
105
+ sysbus_realize(SYS_BUS_DEVICE(&s->sdhci), errp);
37
+ if (val < RV_MAX_TRIGGERS) {
106
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdhci), 0,
38
+ env->trigger_cur = val;
107
+ memmap[MICROCHIP_PFSOC_EMMC_SD].base);
108
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci), 0,
109
+ qdev_get_gpio_in(DEVICE(s->plic), MICROCHIP_PFSOC_EMMC_SD_IRQ));
110
+
111
/* MMUARTs */
112
s->serial0 = mchp_pfsoc_mmuart_create(system_memory,
113
memmap[MICROCHIP_PFSOC_MMUART0].base,
114
@@ -XXX,XX +XXX,XX @@ static void microchip_icicle_kit_machine_init(MachineState *machine)
115
MicrochipIcicleKitState *s = MICROCHIP_ICICLE_KIT_MACHINE(machine);
116
MemoryRegion *system_memory = get_system_memory();
117
MemoryRegion *main_mem = g_new(MemoryRegion, 1);
118
+ DriveInfo *dinfo = drive_get_next(IF_SD);
119
120
/* Sanity check on RAM size */
121
if (machine->ram_size < mc->default_ram_size) {
122
@@ -XXX,XX +XXX,XX @@ static void microchip_icicle_kit_machine_init(MachineState *machine)
123
124
/* Load the firmware */
125
riscv_find_and_load_firmware(machine, BIOS_FILENAME, RESET_VECTOR, NULL);
126
+
127
+ /* Attach an SD card */
128
+ if (dinfo) {
129
+ CadenceSDHCIState *sdhci = &(s->soc.sdhci);
130
+ DeviceState *card = qdev_new(TYPE_SD_CARD);
131
+
132
+ qdev_prop_set_drive_err(card, "drive", blk_by_legacy_dinfo(dinfo),
133
+ &error_fatal);
134
+ qdev_realize_and_unref(card, sdhci->bus, &error_fatal);
135
+ }
39
+ }
136
}
40
}
137
41
138
static void microchip_icicle_kit_machine_class_init(ObjectClass *oc, void *data)
42
static target_ulong tdata1_validate(CPURISCVState *env, target_ulong val,
139
diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
140
index XXXXXXX..XXXXXXX 100644
141
--- a/hw/riscv/Kconfig
142
+++ b/hw/riscv/Kconfig
143
@@ -XXX,XX +XXX,XX @@ config MICROCHIP_PFSOC
144
select SIFIVE
145
select UNIMP
146
select MCHP_PFSOC_MMUART
147
+ select CADENCE_SDHCI
148
--
43
--
149
2.28.0
44
2.37.3
150
151
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Frank Chang <frank.chang@sifive.com>
2
2
3
Cadence SD/SDIO/eMMC Host Controller (SD4HC) is an SDHCI compatible
3
tinfo.info:
4
controller. The SDHCI compatible registers start from offset 0x200,
4
One bit for each possible type enumerated in tdata1.
5
which are called Slot Register Set (SRS) in its datasheet.
5
If the bit is set, then that type is supported by the currently
6
selected trigger.
6
7
7
This creates a Cadence SDHCI model built on top of the existing
8
Signed-off-by: Frank Chang <frank.chang@sifive.com>
8
generic SDHCI model. Cadence specific Host Register Set (HRS) is
9
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
9
implemented to make guest software happy.
10
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
10
11
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
11
Signed-off-by: Bin Meng <bin.meng@windriver.com>
12
Message-Id: <20220909134215.1843865-6-bmeng.cn@gmail.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>
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
16
---
14
---
17
include/hw/sd/cadence_sdhci.h | 47 +++++++++
15
target/riscv/cpu_bits.h | 1 +
18
hw/sd/cadence_sdhci.c | 193 ++++++++++++++++++++++++++++++++++
16
target/riscv/debug.h | 2 ++
19
hw/sd/Kconfig | 4 +
17
target/riscv/csr.c | 8 ++++++++
20
hw/sd/meson.build | 1 +
18
target/riscv/debug.c | 10 +++++++---
21
4 files changed, 245 insertions(+)
19
4 files changed, 18 insertions(+), 3 deletions(-)
22
create mode 100644 include/hw/sd/cadence_sdhci.h
23
create mode 100644 hw/sd/cadence_sdhci.c
24
20
25
diff --git a/include/hw/sd/cadence_sdhci.h b/include/hw/sd/cadence_sdhci.h
21
diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h
26
new file mode 100644
22
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX
23
--- a/target/riscv/cpu_bits.h
28
--- /dev/null
24
+++ b/target/riscv/cpu_bits.h
29
+++ b/include/hw/sd/cadence_sdhci.h
30
@@ -XXX,XX +XXX,XX @@
25
@@ -XXX,XX +XXX,XX @@
31
+/*
26
#define CSR_TDATA1 0x7a1
32
+ * Cadence SDHCI emulation
27
#define CSR_TDATA2 0x7a2
33
+ *
28
#define CSR_TDATA3 0x7a3
34
+ * Copyright (c) 2020 Wind River Systems, Inc.
29
+#define CSR_TINFO 0x7a4
35
+ *
30
36
+ * Author:
31
/* Debug Mode Registers */
37
+ * Bin Meng <bin.meng@windriver.com>
32
#define CSR_DCSR 0x7b0
38
+ *
33
diff --git a/target/riscv/debug.h b/target/riscv/debug.h
39
+ * This program is free software; you can redistribute it and/or
34
index XXXXXXX..XXXXXXX 100644
40
+ * modify it under the terms of the GNU General Public License as
35
--- a/target/riscv/debug.h
41
+ * published by the Free Software Foundation; either version 2 or
36
+++ b/target/riscv/debug.h
42
+ * (at your option) version 3 of the License.
37
@@ -XXX,XX +XXX,XX @@ void tselect_csr_write(CPURISCVState *env, target_ulong val);
43
+ *
38
target_ulong tdata_csr_read(CPURISCVState *env, int tdata_index);
44
+ * This program is distributed in the hope that it will be useful,
39
void tdata_csr_write(CPURISCVState *env, int tdata_index, target_ulong val);
45
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
40
46
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41
+target_ulong tinfo_csr_read(CPURISCVState *env);
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
+
42
+
53
+#ifndef CADENCE_SDHCI_H
43
void riscv_cpu_debug_excp_handler(CPUState *cs);
54
+#define CADENCE_SDHCI_H
44
bool riscv_cpu_debug_check_breakpoint(CPUState *cs);
55
+
45
bool riscv_cpu_debug_check_watchpoint(CPUState *cs, CPUWatchpoint *wp);
56
+#include "hw/sd/sdhci.h"
46
diff --git a/target/riscv/csr.c b/target/riscv/csr.c
57
+
47
index XXXXXXX..XXXXXXX 100644
58
+#define CADENCE_SDHCI_REG_SIZE 0x100
48
--- a/target/riscv/csr.c
59
+#define CADENCE_SDHCI_NUM_REGS (CADENCE_SDHCI_REG_SIZE / sizeof(uint32_t))
49
+++ b/target/riscv/csr.c
60
+
50
@@ -XXX,XX +XXX,XX @@ static RISCVException write_tdata(CPURISCVState *env, int csrno,
61
+typedef struct CadenceSDHCIState {
51
return RISCV_EXCP_NONE;
62
+ SysBusDevice parent;
52
}
63
+
53
64
+ MemoryRegion container;
54
+static RISCVException read_tinfo(CPURISCVState *env, int csrno,
65
+ MemoryRegion iomem;
55
+ target_ulong *val)
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
+{
56
+{
138
+ CadenceSDHCIState *s = CADENCE_SDHCI(obj);
57
+ *val = tinfo_csr_read(env);
139
+
58
+ return RISCV_EXCP_NONE;
140
+ object_initialize_child(OBJECT(s), "generic-sdhci",
141
+ &s->sdhci, TYPE_SYSBUS_SDHCI);
142
+}
59
+}
143
+
60
+
144
+static void cadence_sdhci_reset(DeviceState *dev)
61
/*
62
* Functions to access Pointer Masking feature registers
63
* We have to check if current priv lvl could modify
64
@@ -XXX,XX +XXX,XX @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = {
65
[CSR_TDATA1] = { "tdata1", debug, read_tdata, write_tdata },
66
[CSR_TDATA2] = { "tdata2", debug, read_tdata, write_tdata },
67
[CSR_TDATA3] = { "tdata3", debug, read_tdata, write_tdata },
68
+ [CSR_TINFO] = { "tinfo", debug, read_tinfo, write_ignore },
69
70
/* User Pointer Masking */
71
[CSR_UMTE] = { "umte", pointer_masking, read_umte, write_umte },
72
diff --git a/target/riscv/debug.c b/target/riscv/debug.c
73
index XXXXXXX..XXXXXXX 100644
74
--- a/target/riscv/debug.c
75
+++ b/target/riscv/debug.c
76
@@ -XXX,XX +XXX,XX @@
77
* - tdata1
78
* - tdata2
79
* - tdata3
80
- *
81
- * We don't support writable 'type' field in the tdata1 register, so there is
82
- * no need to implement the "tinfo" CSR.
83
+ * - tinfo
84
*
85
* The following triggers are implemented:
86
*
87
@@ -XXX,XX +XXX,XX @@ void tdata_csr_write(CPURISCVState *env, int tdata_index, target_ulong val)
88
}
89
}
90
91
+target_ulong tinfo_csr_read(CPURISCVState *env)
145
+{
92
+{
146
+ CadenceSDHCIState *s = CADENCE_SDHCI(dev);
93
+ /* assume all triggers support the same types of triggers */
147
+
94
+ return BIT(TRIGGER_TYPE_AD_MATCH);
148
+ memset(s->regs, 0, CADENCE_SDHCI_REG_SIZE);
149
+ s->regs[TO_REG(CADENCE_SDHCI_HRS00)] = CADENCE_SDHCI_HRS00_POR_VAL;
150
+
151
+ device_cold_reset(DEVICE(&s->sdhci));
152
+}
95
+}
153
+
96
+
154
+static uint64_t cadence_sdhci_read(void *opaque, hwaddr addr, unsigned int size)
97
void riscv_cpu_debug_excp_handler(CPUState *cs)
155
+{
98
{
156
+ CadenceSDHCIState *s = opaque;
99
RISCVCPU *cpu = RISCV_CPU(cs);
157
+ uint32_t val;
158
+
159
+ val = s->regs[TO_REG(addr)];
160
+
161
+ return (uint64_t)val;
162
+}
163
+
164
+static void cadence_sdhci_write(void *opaque, hwaddr addr, uint64_t val,
165
+ unsigned int size)
166
+{
167
+ CadenceSDHCIState *s = opaque;
168
+ uint32_t val32 = (uint32_t)val;
169
+
170
+ switch (addr) {
171
+ case CADENCE_SDHCI_HRS00:
172
+ /*
173
+ * The only writable bit is SWR (software reset) and it automatically
174
+ * clears to zero, so essentially this register remains unchanged.
175
+ */
176
+ if (val32 & CADENCE_SDHCI_HRS00_SWR) {
177
+ cadence_sdhci_reset(DEVICE(s));
178
+ }
179
+
180
+ break;
181
+ case CADENCE_SDHCI_HRS04:
182
+ /*
183
+ * Only emulate the ACK bit behavior when read or write transaction
184
+ * are requested.
185
+ */
186
+ if (val32 & (CADENCE_SDHCI_HRS04_WR | CADENCE_SDHCI_HRS04_RD)) {
187
+ val32 |= CADENCE_SDHCI_HRS04_ACK;
188
+ } else {
189
+ val32 &= ~CADENCE_SDHCI_HRS04_ACK;
190
+ }
191
+
192
+ s->regs[TO_REG(addr)] = val32;
193
+ break;
194
+ case CADENCE_SDHCI_HRS06:
195
+ if (val32 & CADENCE_SDHCI_HRS06_TUNE_UP) {
196
+ val32 &= ~CADENCE_SDHCI_HRS06_TUNE_UP;
197
+ }
198
+
199
+ s->regs[TO_REG(addr)] = val32;
200
+ break;
201
+ default:
202
+ s->regs[TO_REG(addr)] = val32;
203
+ break;
204
+ }
205
+}
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
--
100
--
299
2.28.0
101
2.37.3
300
301
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Frank Chang <frank.chang@sifive.com>
2
2
3
Microchip PolarFire SoC integrates a DMA engine that supports:
3
Trigger actions are shared among all triggers. Extract to a common
4
* Independent concurrent DMA transfers using 4 DMA channels
4
function.
5
* Generation of interrupts on various conditions during execution
6
which is actually an IP reused from the SiFive FU540 chip.
7
5
8
This creates a model to support both polling and interrupt modes.
6
Signed-off-by: Frank Chang <frank.chang@sifive.com>
9
7
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
10
Signed-off-by: Bin Meng <bin.meng@windriver.com>
8
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
11
Acked-by: Alistair Francis <alistair.francis@wdc.com>
9
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
12
Message-Id: <1598924352-89526-10-git-send-email-bmeng.cn@gmail.com>
10
[bmeng: handle the DBG_ACTION_NONE case]
11
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
12
Message-Id: <20220909134215.1843865-7-bmeng.cn@gmail.com>
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
14
---
14
---
15
include/hw/dma/sifive_pdma.h | 57 +++++++
15
target/riscv/debug.h | 13 ++++++++++
16
hw/dma/sifive_pdma.c | 313 +++++++++++++++++++++++++++++++++++
16
target/riscv/debug.c | 59 ++++++++++++++++++++++++++++++++++++++++++--
17
hw/dma/Kconfig | 3 +
17
2 files changed, 70 insertions(+), 2 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
18
23
diff --git a/include/hw/dma/sifive_pdma.h b/include/hw/dma/sifive_pdma.h
19
diff --git a/target/riscv/debug.h b/target/riscv/debug.h
24
new file mode 100644
20
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX
21
--- a/target/riscv/debug.h
26
--- /dev/null
22
+++ b/target/riscv/debug.h
27
+++ b/include/hw/dma/sifive_pdma.h
23
@@ -XXX,XX +XXX,XX @@ typedef enum {
28
@@ -XXX,XX +XXX,XX @@
24
TRIGGER_TYPE_NUM
29
+/*
25
} trigger_type_t;
30
+ * SiFive Platform DMA emulation
26
31
+ *
27
+/* actions */
32
+ * Copyright (c) 2020 Wind River Systems, Inc.
28
+typedef enum {
33
+ *
29
+ DBG_ACTION_NONE = -1, /* sentinel value */
34
+ * Author:
30
+ DBG_ACTION_BP = 0,
35
+ * Bin Meng <bin.meng@windriver.com>
31
+ DBG_ACTION_DBG_MODE,
36
+ *
32
+ DBG_ACTION_TRACE0,
37
+ * This program is free software; you can redistribute it and/or
33
+ DBG_ACTION_TRACE1,
38
+ * modify it under the terms of the GNU General Public License as
34
+ DBG_ACTION_TRACE2,
39
+ * published by the Free Software Foundation; either version 2 or
35
+ DBG_ACTION_TRACE3,
40
+ * (at your option) version 3 of the License.
36
+ DBG_ACTION_EXT_DBG0 = 8,
41
+ *
37
+ DBG_ACTION_EXT_DBG1
42
+ * This program is distributed in the hope that it will be useful,
38
+} trigger_action_t;
43
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
44
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45
+ * GNU General Public License for more details.
46
+ *
47
+ * You should have received a copy of the GNU General Public License along
48
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
49
+ */
50
+
39
+
51
+#ifndef SIFIVE_PDMA_H
40
/* tdata1 field masks */
52
+#define SIFIVE_PDMA_H
41
42
#define RV32_TYPE(t) ((uint32_t)(t) << 28)
43
diff --git a/target/riscv/debug.c b/target/riscv/debug.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/target/riscv/debug.c
46
+++ b/target/riscv/debug.c
47
@@ -XXX,XX +XXX,XX @@ static inline target_ulong get_trigger_type(CPURISCVState *env,
48
return extract_trigger_type(env, env->tdata1[trigger_index]);
49
}
50
51
+static trigger_action_t get_trigger_action(CPURISCVState *env,
52
+ target_ulong trigger_index)
53
+{
54
+ target_ulong tdata1 = env->tdata1[trigger_index];
55
+ int trigger_type = get_trigger_type(env, trigger_index);
56
+ trigger_action_t action = DBG_ACTION_NONE;
53
+
57
+
54
+struct sifive_pdma_chan {
58
+ switch (trigger_type) {
55
+ uint32_t control;
59
+ case TRIGGER_TYPE_AD_MATCH:
56
+ uint32_t next_config;
60
+ action = (tdata1 & TYPE2_ACTION) >> 12;
57
+ uint64_t next_bytes;
61
+ break;
58
+ uint64_t next_dst;
62
+ case TRIGGER_TYPE_INST_CNT:
59
+ uint64_t next_src;
63
+ case TRIGGER_TYPE_INT:
60
+ uint32_t exec_config;
64
+ case TRIGGER_TYPE_EXCP:
61
+ uint64_t exec_bytes;
65
+ case TRIGGER_TYPE_AD_MATCH6:
62
+ uint64_t exec_dst;
66
+ case TRIGGER_TYPE_EXT_SRC:
63
+ uint64_t exec_src;
67
+ qemu_log_mask(LOG_UNIMP, "trigger type: %d is not supported\n",
64
+ int state;
68
+ trigger_type);
65
+};
69
+ break;
66
+
70
+ case TRIGGER_TYPE_NO_EXIST:
67
+#define SIFIVE_PDMA_CHANS 4
71
+ case TRIGGER_TYPE_UNAVAIL:
68
+#define SIFIVE_PDMA_IRQS (SIFIVE_PDMA_CHANS * 2)
72
+ qemu_log_mask(LOG_GUEST_ERROR, "trigger type: %d does not exit\n",
69
+#define SIFIVE_PDMA_REG_SIZE 0x100000
73
+ trigger_type);
70
+#define SIFIVE_PDMA_CHAN_NO(reg) ((reg & (SIFIVE_PDMA_REG_SIZE - 1)) >> 12)
74
+ break;
71
+
75
+ default:
72
+typedef struct SiFivePDMAState {
76
+ g_assert_not_reached();
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
+ }
77
+ }
170
+
78
+
171
+ /*
79
+ return action;
172
+ * The manual does not describe how the hardware behaviors when
173
+ * config.wsize and config.rsize are given different values.
174
+ * A common case is memory to memory DMA, and in this case they
175
+ * are normally the same. Abort if this expectation fails.
176
+ */
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
+ }
182
+
183
+ /*
184
+ * Calculate the transaction size
185
+ *
186
+ * size field is base 2 logarithm of DMA transaction size,
187
+ * but there is an upper limit of 64 bytes per transaction.
188
+ */
189
+ size = wsize;
190
+ if (size > 6) {
191
+ size = 6;
192
+ }
193
+ size = 1 << size;
194
+
195
+ /* the bytes to transfer should be multiple of transaction size */
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
+}
80
+}
238
+
81
+
239
+static inline void sifive_pdma_update_irq(SiFivePDMAState *s, int ch)
82
static inline target_ulong build_tdata1(CPURISCVState *env,
83
trigger_type_t type,
84
bool dmode, target_ulong data)
85
@@ -XXX,XX +XXX,XX @@ static inline void warn_always_zero_bit(target_ulong val, target_ulong mask,
86
}
87
}
88
89
+static void do_trigger_action(CPURISCVState *env, target_ulong trigger_index)
240
+{
90
+{
241
+ bool done_ie, err_ie;
91
+ trigger_action_t action = get_trigger_action(env, trigger_index);
242
+
92
+
243
+ done_ie = !!(s->chan[ch].control & CONTROL_DONE_IE);
93
+ switch (action) {
244
+ err_ie = !!(s->chan[ch].control & CONTROL_ERR_IE);
94
+ case DBG_ACTION_NONE:
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;
95
+ break;
278
+ case DMA_NEXT_CONFIG:
96
+ case DBG_ACTION_BP:
279
+ val = s->chan[ch].next_config;
97
+ riscv_raise_exception(env, RISCV_EXCP_BREAKPOINT, 0);
280
+ break;
98
+ break;
281
+ case DMA_NEXT_BYTES:
99
+ case DBG_ACTION_DBG_MODE:
282
+ val = s->chan[ch].next_bytes;
100
+ case DBG_ACTION_TRACE0:
283
+ break;
101
+ case DBG_ACTION_TRACE1:
284
+ case DMA_NEXT_DST:
102
+ case DBG_ACTION_TRACE2:
285
+ val = s->chan[ch].next_dst;
103
+ case DBG_ACTION_TRACE3:
286
+ break;
104
+ case DBG_ACTION_EXT_DBG0:
287
+ case DMA_NEXT_SRC:
105
+ case DBG_ACTION_EXT_DBG1:
288
+ val = s->chan[ch].next_src;
106
+ qemu_log_mask(LOG_UNIMP, "action: %d is not supported\n", action);
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;
107
+ break;
302
+ default:
108
+ default:
303
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIX "\n",
109
+ g_assert_not_reached();
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
+ }
110
+ }
357
+}
111
+}
358
+
112
+
359
+static const MemoryRegionOps sifive_pdma_ops = {
113
/* type 2 trigger */
360
+ .read = sifive_pdma_read,
114
361
+ .write = sifive_pdma_write,
115
static uint32_t type2_breakpoint_size(CPURISCVState *env, target_ulong ctrl)
362
+ .endianness = DEVICE_LITTLE_ENDIAN,
116
@@ -XXX,XX +XXX,XX @@ void riscv_cpu_debug_excp_handler(CPUState *cs)
363
+ /* there are 32-bit and 64-bit wide registers */
117
if (cs->watchpoint_hit) {
364
+ .impl = {
118
if (cs->watchpoint_hit->flags & BP_CPU) {
365
+ .min_access_size = 4,
119
cs->watchpoint_hit = NULL;
366
+ .max_access_size = 8,
120
- riscv_raise_exception(env, RISCV_EXCP_BREAKPOINT, 0);
367
+ }
121
+ do_trigger_action(env, DBG_ACTION_BP);
368
+};
122
}
369
+
123
} else {
370
+static void sifive_pdma_realize(DeviceState *dev, Error **errp)
124
if (cpu_breakpoint_test(cs, env->pc, BP_CPU)) {
371
+{
125
- riscv_raise_exception(env, RISCV_EXCP_BREAKPOINT, 0);
372
+ SiFivePDMAState *s = SIFIVE_PDMA(dev);
126
+ do_trigger_action(env, DBG_ACTION_BP);
373
+ int i;
127
}
374
+
128
}
375
+ memory_region_init_io(&s->iomem, OBJECT(dev), &sifive_pdma_ops, s,
129
}
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.37.3
427
428
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
Type 2 trigger cannot be fired in VU/VS modes.
4
should only contain the RISC-V SoC / machine codes plus generic
5
codes. Let's move sifive_plic model to hw/intc directory.
6
4
7
Signed-off-by: Bin Meng <bin.meng@windriver.com>
5
Signed-off-by: Frank Chang <frank.chang@sifive.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
6
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
9
Message-Id: <1599129623-68957-7-git-send-email-bmeng.cn@gmail.com>
7
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
8
Message-Id: <20220909134215.1843865-8-bmeng.cn@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
{include/hw/riscv => hw/intc}/sifive_plic.h | 0
11
target/riscv/debug.c | 10 ++++++++++
13
hw/{riscv => intc}/sifive_plic.c | 2 +-
12
1 file changed, 10 insertions(+)
14
hw/riscv/microchip_pfsoc.c | 2 +-
15
hw/riscv/sifive_e.c | 2 +-
16
hw/riscv/sifive_u.c | 2 +-
17
hw/riscv/virt.c | 2 +-
18
hw/intc/Kconfig | 3 +++
19
hw/intc/meson.build | 1 +
20
hw/riscv/Kconfig | 5 +++++
21
hw/riscv/meson.build | 1 -
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
13
26
diff --git a/include/hw/riscv/sifive_plic.h b/hw/intc/sifive_plic.h
14
diff --git a/target/riscv/debug.c b/target/riscv/debug.c
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
15
index XXXXXXX..XXXXXXX 100644
35
--- a/hw/riscv/sifive_plic.c
16
--- a/target/riscv/debug.c
36
+++ b/hw/intc/sifive_plic.c
17
+++ b/target/riscv/debug.c
37
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@ bool riscv_cpu_debug_check_breakpoint(CPUState *cs)
38
#include "hw/pci/msi.h"
19
39
#include "hw/boards.h"
20
switch (trigger_type) {
40
#include "hw/qdev-properties.h"
21
case TRIGGER_TYPE_AD_MATCH:
41
+#include "hw/intc/sifive_plic.h"
22
+ /* type 2 trigger cannot be fired in VU/VS mode */
42
#include "target/riscv/cpu.h"
23
+ if (riscv_cpu_virt_enabled(env)) {
43
#include "sysemu/sysemu.h"
24
+ return false;
44
-#include "hw/riscv/sifive_plic.h"
25
+ }
45
46
#define RISCV_DEBUG_PLIC 0
47
48
diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c
49
index XXXXXXX..XXXXXXX 100644
50
--- a/hw/riscv/microchip_pfsoc.c
51
+++ b/hw/riscv/microchip_pfsoc.c
52
@@ -XXX,XX +XXX,XX @@
53
#include "hw/misc/unimp.h"
54
#include "hw/riscv/boot.h"
55
#include "hw/riscv/riscv_hart.h"
56
-#include "hw/riscv/sifive_plic.h"
57
#include "hw/riscv/microchip_pfsoc.h"
58
#include "hw/intc/sifive_clint.h"
59
+#include "hw/intc/sifive_plic.h"
60
#include "sysemu/sysemu.h"
61
62
/*
63
diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c
64
index XXXXXXX..XXXXXXX 100644
65
--- a/hw/riscv/sifive_e.c
66
+++ b/hw/riscv/sifive_e.c
67
@@ -XXX,XX +XXX,XX @@
68
#include "hw/misc/unimp.h"
69
#include "target/riscv/cpu.h"
70
#include "hw/riscv/riscv_hart.h"
71
-#include "hw/riscv/sifive_plic.h"
72
#include "hw/riscv/sifive_uart.h"
73
#include "hw/riscv/sifive_e.h"
74
#include "hw/riscv/boot.h"
75
#include "hw/intc/sifive_clint.h"
76
+#include "hw/intc/sifive_plic.h"
77
#include "hw/misc/sifive_e_prci.h"
78
#include "chardev/char.h"
79
#include "sysemu/arch_init.h"
80
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
81
index XXXXXXX..XXXXXXX 100644
82
--- a/hw/riscv/sifive_u.c
83
+++ b/hw/riscv/sifive_u.c
84
@@ -XXX,XX +XXX,XX @@
85
#include "hw/misc/unimp.h"
86
#include "target/riscv/cpu.h"
87
#include "hw/riscv/riscv_hart.h"
88
-#include "hw/riscv/sifive_plic.h"
89
#include "hw/riscv/sifive_uart.h"
90
#include "hw/riscv/sifive_u.h"
91
#include "hw/riscv/boot.h"
92
#include "hw/intc/sifive_clint.h"
93
+#include "hw/intc/sifive_plic.h"
94
#include "chardev/char.h"
95
#include "net/eth.h"
96
#include "sysemu/arch_init.h"
97
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
98
index XXXXXXX..XXXXXXX 100644
99
--- a/hw/riscv/virt.c
100
+++ b/hw/riscv/virt.c
101
@@ -XXX,XX +XXX,XX @@
102
#include "hw/char/serial.h"
103
#include "target/riscv/cpu.h"
104
#include "hw/riscv/riscv_hart.h"
105
-#include "hw/riscv/sifive_plic.h"
106
#include "hw/riscv/sifive_test.h"
107
#include "hw/riscv/virt.h"
108
#include "hw/riscv/boot.h"
109
#include "hw/riscv/numa.h"
110
#include "hw/intc/sifive_clint.h"
111
+#include "hw/intc/sifive_plic.h"
112
#include "chardev/char.h"
113
#include "sysemu/arch_init.h"
114
#include "sysemu/device_tree.h"
115
diff --git a/hw/intc/Kconfig b/hw/intc/Kconfig
116
index XXXXXXX..XXXXXXX 100644
117
--- a/hw/intc/Kconfig
118
+++ b/hw/intc/Kconfig
119
@@ -XXX,XX +XXX,XX @@ config LOONGSON_LIOINTC
120
121
config SIFIVE_CLINT
122
bool
123
+
26
+
124
+config SIFIVE_PLIC
27
ctrl = env->tdata1[i];
125
+ bool
28
pc = env->tdata2[i];
126
diff --git a/hw/intc/meson.build b/hw/intc/meson.build
29
127
index XXXXXXX..XXXXXXX 100644
30
@@ -XXX,XX +XXX,XX @@ bool riscv_cpu_debug_check_watchpoint(CPUState *cs, CPUWatchpoint *wp)
128
--- a/hw/intc/meson.build
31
129
+++ b/hw/intc/meson.build
32
switch (trigger_type) {
130
@@ -XXX,XX +XXX,XX @@ specific_ss.add(when: 'CONFIG_S390_FLIC', if_true: files('s390_flic.c'))
33
case TRIGGER_TYPE_AD_MATCH:
131
specific_ss.add(when: 'CONFIG_S390_FLIC_KVM', if_true: files('s390_flic_kvm.c'))
34
+ /* type 2 trigger cannot be fired in VU/VS mode */
132
specific_ss.add(when: 'CONFIG_SH4', if_true: files('sh_intc.c'))
35
+ if (riscv_cpu_virt_enabled(env)) {
133
specific_ss.add(when: 'CONFIG_SIFIVE_CLINT', if_true: files('sifive_clint.c'))
36
+ return false;
134
+specific_ss.add(when: 'CONFIG_SIFIVE_PLIC', if_true: files('sifive_plic.c'))
37
+ }
135
specific_ss.add(when: 'CONFIG_XICS', if_true: files('xics.c'))
38
+
136
specific_ss.add(when: 'CONFIG_XICS_KVM', if_true: files('xics_kvm.c'))
39
ctrl = env->tdata1[i];
137
specific_ss.add(when: 'CONFIG_XICS_SPAPR', if_true: files('xics_spapr.c'))
40
addr = env->tdata2[i];
138
diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
41
flags = 0;
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
--
42
--
193
2.28.0
43
2.37.3
194
195
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Frank Chang <frank.chang@sifive.com>
2
2
3
Microchip PolarFire SoC MMUART is ns16550 compatible, with some
3
Type 6 trigger is similar to a type 2 trigger, but provides additional
4
additional registers. Create a simple MMUART model built on top
4
functionality and should be used instead of type 2 in newer
5
of the existing ns16550 model.
5
implementations.
6
6
7
Signed-off-by: Bin Meng <bin.meng@windriver.com>
7
Signed-off-by: Frank Chang <frank.chang@sifive.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
9
Message-Id: <1598924352-89526-6-git-send-email-bmeng.cn@gmail.com>
9
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
10
Message-Id: <20220909134215.1843865-9-bmeng.cn@gmail.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
12
---
12
include/hw/char/mchp_pfsoc_mmuart.h | 61 ++++++++++++++++++++
13
target/riscv/debug.h | 18 +++++
13
hw/char/mchp_pfsoc_mmuart.c | 86 +++++++++++++++++++++++++++++
14
target/riscv/debug.c | 174 ++++++++++++++++++++++++++++++++++++++++++-
14
MAINTAINERS | 2 +
15
2 files changed, 188 insertions(+), 4 deletions(-)
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
16
21
diff --git a/include/hw/char/mchp_pfsoc_mmuart.h b/include/hw/char/mchp_pfsoc_mmuart.h
17
diff --git a/target/riscv/debug.h b/target/riscv/debug.h
22
new file mode 100644
18
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX
19
--- a/target/riscv/debug.h
24
--- /dev/null
20
+++ b/target/riscv/debug.h
25
+++ b/include/hw/char/mchp_pfsoc_mmuart.h
21
@@ -XXX,XX +XXX,XX @@ typedef enum {
22
#define TYPE2_HIT BIT(20)
23
#define TYPE2_SIZEHI (0x3 << 21) /* RV64 only */
24
25
+/* mcontrol6 field masks */
26
+
27
+#define TYPE6_LOAD BIT(0)
28
+#define TYPE6_STORE BIT(1)
29
+#define TYPE6_EXEC BIT(2)
30
+#define TYPE6_U BIT(3)
31
+#define TYPE6_S BIT(4)
32
+#define TYPE6_M BIT(6)
33
+#define TYPE6_MATCH (0xf << 7)
34
+#define TYPE6_CHAIN BIT(11)
35
+#define TYPE6_ACTION (0xf << 12)
36
+#define TYPE6_SIZE (0xf << 16)
37
+#define TYPE6_TIMING BIT(20)
38
+#define TYPE6_SELECT BIT(21)
39
+#define TYPE6_HIT BIT(22)
40
+#define TYPE6_VU BIT(23)
41
+#define TYPE6_VS BIT(24)
42
+
43
/* access size */
44
enum {
45
SIZE_ANY = 0,
46
diff --git a/target/riscv/debug.c b/target/riscv/debug.c
47
index XXXXXXX..XXXXXXX 100644
48
--- a/target/riscv/debug.c
49
+++ b/target/riscv/debug.c
26
@@ -XXX,XX +XXX,XX @@
50
@@ -XXX,XX +XXX,XX @@
27
+/*
51
* - tdata3
28
+ * Microchip PolarFire SoC MMUART emulation
52
* - tinfo
29
+ *
53
*
30
+ * Copyright (c) 2020 Wind River Systems, Inc.
54
- * The following triggers are implemented:
31
+ *
55
+ * The following triggers are initialized by default:
32
+ * Author:
56
*
33
+ * Bin Meng <bin.meng@windriver.com>
57
* Index | Type | tdata mapping | Description
34
+ *
58
* ------+------+------------------------+------------
35
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
59
@@ -XXX,XX +XXX,XX @@ static trigger_action_t get_trigger_action(CPURISCVState *env,
36
+ * of this software and associated documentation files (the "Software"), to deal
60
case TRIGGER_TYPE_AD_MATCH:
37
+ * in the Software without restriction, including without limitation the rights
61
action = (tdata1 & TYPE2_ACTION) >> 12;
38
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
62
break;
39
+ * copies of the Software, and to permit persons to whom the Software is
63
+ case TRIGGER_TYPE_AD_MATCH6:
40
+ * furnished to do so, subject to the following conditions:
64
+ action = (tdata1 & TYPE6_ACTION) >> 12;
41
+ *
65
+ break;
42
+ * The above copyright notice and this permission notice shall be included in
66
case TRIGGER_TYPE_INST_CNT:
43
+ * all copies or substantial portions of the Software.
67
case TRIGGER_TYPE_INT:
44
+ *
68
case TRIGGER_TYPE_EXCP:
45
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
69
- case TRIGGER_TYPE_AD_MATCH6:
46
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
70
case TRIGGER_TYPE_EXT_SRC:
47
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
71
qemu_log_mask(LOG_UNIMP, "trigger type: %d is not supported\n",
48
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
72
trigger_type);
49
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
73
@@ -XXX,XX +XXX,XX @@ static void type2_reg_write(CPURISCVState *env, target_ulong index,
50
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
74
return;
51
+ * THE SOFTWARE.
75
}
52
+ */
76
53
+
77
+/* type 6 trigger */
54
+#ifndef HW_MCHP_PFSOC_MMUART_H
78
+
55
+#define HW_MCHP_PFSOC_MMUART_H
79
+static inline bool type6_breakpoint_enabled(target_ulong ctrl)
56
+
80
+{
57
+#include "hw/char/serial.h"
81
+ bool mode = !!(ctrl & (TYPE6_VU | TYPE6_VS | TYPE6_U | TYPE6_S | TYPE6_M));
58
+
82
+ bool rwx = !!(ctrl & (TYPE6_LOAD | TYPE6_STORE | TYPE6_EXEC));
59
+#define MCHP_PFSOC_MMUART_REG_SIZE 52
83
+
60
+
84
+ return mode && rwx;
61
+typedef struct MchpPfSoCMMUartState {
85
+}
62
+ MemoryRegion iomem;
86
+
63
+ hwaddr base;
87
+static target_ulong type6_mcontrol6_validate(CPURISCVState *env,
64
+ qemu_irq irq;
88
+ target_ulong ctrl)
65
+
89
+{
66
+ SerialMM *serial;
90
+ target_ulong val;
67
+
91
+ uint32_t size;
68
+ uint32_t reg[MCHP_PFSOC_MMUART_REG_SIZE / sizeof(uint32_t)];
92
+
69
+} MchpPfSoCMMUartState;
93
+ /* validate the generic part first */
70
+
94
+ val = tdata1_validate(env, ctrl, TRIGGER_TYPE_AD_MATCH6);
71
+/**
95
+
72
+ * mchp_pfsoc_mmuart_create - Create a Microchip PolarFire SoC MMUART
96
+ /* validate unimplemented (always zero) bits */
73
+ *
97
+ warn_always_zero_bit(ctrl, TYPE6_MATCH, "match");
74
+ * This is a helper routine for board to create a MMUART device that is
98
+ warn_always_zero_bit(ctrl, TYPE6_CHAIN, "chain");
75
+ * compatible with Microchip PolarFire SoC.
99
+ warn_always_zero_bit(ctrl, TYPE6_ACTION, "action");
76
+ *
100
+ warn_always_zero_bit(ctrl, TYPE6_TIMING, "timing");
77
+ * @sysmem: system memory region to map
101
+ warn_always_zero_bit(ctrl, TYPE6_SELECT, "select");
78
+ * @base: base address of the MMUART registers
102
+ warn_always_zero_bit(ctrl, TYPE6_HIT, "hit");
79
+ * @irq: IRQ number of the MMUART device
103
+
80
+ * @chr: character device to associate to
104
+ /* validate size encoding */
81
+ *
105
+ size = extract32(ctrl, 16, 4);
82
+ * @return: a pointer to the device specific control structure
106
+ if (access_size[size] == -1) {
83
+ */
107
+ qemu_log_mask(LOG_UNIMP, "access size %d is not supported, using SIZE_ANY\n",
84
+MchpPfSoCMMUartState *mchp_pfsoc_mmuart_create(MemoryRegion *sysmem,
108
+ size);
85
+ hwaddr base, qemu_irq irq, Chardev *chr);
109
+ } else {
86
+
110
+ val |= (ctrl & TYPE6_SIZE);
87
+#endif /* HW_MCHP_PFSOC_MMUART_H */
111
+ }
88
diff --git a/hw/char/mchp_pfsoc_mmuart.c b/hw/char/mchp_pfsoc_mmuart.c
112
+
89
new file mode 100644
113
+ /* keep the mode and attribute bits */
90
index XXXXXXX..XXXXXXX
114
+ val |= (ctrl & (TYPE6_VU | TYPE6_VS | TYPE6_U | TYPE6_S | TYPE6_M |
91
--- /dev/null
115
+ TYPE6_LOAD | TYPE6_STORE | TYPE6_EXEC));
92
+++ b/hw/char/mchp_pfsoc_mmuart.c
116
+
93
@@ -XXX,XX +XXX,XX @@
117
+ return val;
94
+/*
118
+}
95
+ * Microchip PolarFire SoC MMUART emulation
119
+
96
+ *
120
+static void type6_breakpoint_insert(CPURISCVState *env, target_ulong index)
97
+ * Copyright (c) 2020 Wind River Systems, Inc.
121
+{
98
+ *
122
+ target_ulong ctrl = env->tdata1[index];
99
+ * Author:
123
+ target_ulong addr = env->tdata2[index];
100
+ * Bin Meng <bin.meng@windriver.com>
124
+ bool enabled = type6_breakpoint_enabled(ctrl);
101
+ *
125
+ CPUState *cs = env_cpu(env);
102
+ * This program is free software; you can redistribute it and/or
126
+ int flags = BP_CPU | BP_STOP_BEFORE_ACCESS;
103
+ * modify it under the terms of the GNU General Public License as
127
+ uint32_t size;
104
+ * published by the Free Software Foundation; either version 2 or
128
+
105
+ * (at your option) version 3 of the License.
129
+ if (!enabled) {
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
+{
124
+ MchpPfSoCMMUartState *s = opaque;
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
+}
134
+
135
+static void mchp_pfsoc_mmuart_write(void *opaque, hwaddr addr,
136
+ uint64_t value, unsigned size)
137
+{
138
+ MchpPfSoCMMUartState *s = opaque;
139
+ uint32_t val32 = (uint32_t)value;
140
+
141
+ if (addr >= MCHP_PFSOC_MMUART_REG_SIZE) {
142
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: bad write: addr=0x%" HWADDR_PRIx
143
+ " v=0x%x\n", __func__, addr, val32);
144
+ return;
130
+ return;
145
+ }
131
+ }
146
+
132
+
147
+ s->reg[addr / sizeof(uint32_t)] = val32;
133
+ if (ctrl & TYPE6_EXEC) {
148
+}
134
+ cpu_breakpoint_insert(cs, addr, flags, &env->cpu_breakpoint[index]);
149
+
135
+ }
150
+static const MemoryRegionOps mchp_pfsoc_mmuart_ops = {
136
+
151
+ .read = mchp_pfsoc_mmuart_read,
137
+ if (ctrl & TYPE6_LOAD) {
152
+ .write = mchp_pfsoc_mmuart_write,
138
+ flags |= BP_MEM_READ;
153
+ .endianness = DEVICE_LITTLE_ENDIAN,
139
+ }
154
+ .impl = {
140
+
155
+ .min_access_size = 4,
141
+ if (ctrl & TYPE6_STORE) {
156
+ .max_access_size = 4,
142
+ flags |= BP_MEM_WRITE;
157
+ },
143
+ }
158
+};
144
+
159
+
145
+ if (flags & BP_MEM_ACCESS) {
160
+MchpPfSoCMMUartState *mchp_pfsoc_mmuart_create(MemoryRegion *sysmem,
146
+ size = extract32(ctrl, 16, 4);
161
+ hwaddr base, qemu_irq irq, Chardev *chr)
147
+ if (size != 0) {
162
+{
148
+ cpu_watchpoint_insert(cs, addr, size, flags,
163
+ MchpPfSoCMMUartState *s;
149
+ &env->cpu_watchpoint[index]);
164
+
150
+ } else {
165
+ s = g_new0(MchpPfSoCMMUartState, 1);
151
+ cpu_watchpoint_insert(cs, addr, 8, flags,
166
+
152
+ &env->cpu_watchpoint[index]);
167
+ memory_region_init_io(&s->iomem, NULL, &mchp_pfsoc_mmuart_ops, s,
153
+ }
168
+ "mchp.pfsoc.mmuart", 0x1000);
154
+ }
169
+
155
+}
170
+ s->base = base;
156
+
171
+ s->irq = irq;
157
+static void type6_breakpoint_remove(CPURISCVState *env, target_ulong index)
172
+
158
+{
173
+ s->serial = serial_mm_init(sysmem, base, 2, irq, 399193, chr,
159
+ type2_breakpoint_remove(env, index);
174
+ DEVICE_LITTLE_ENDIAN);
160
+}
175
+
161
+
176
+ memory_region_add_subregion(sysmem, base + 0x20, &s->iomem);
162
+static void type6_reg_write(CPURISCVState *env, target_ulong index,
177
+
163
+ int tdata_index, target_ulong val)
178
+ return s;
164
+{
179
+}
165
+ target_ulong new_val;
180
diff --git a/MAINTAINERS b/MAINTAINERS
166
+
181
index XXXXXXX..XXXXXXX 100644
167
+ switch (tdata_index) {
182
--- a/MAINTAINERS
168
+ case TDATA1:
183
+++ b/MAINTAINERS
169
+ new_val = type6_mcontrol6_validate(env, val);
184
@@ -XXX,XX +XXX,XX @@ M: Bin Meng <bin.meng@windriver.com>
170
+ if (new_val != env->tdata1[index]) {
185
L: qemu-riscv@nongnu.org
171
+ env->tdata1[index] = new_val;
186
S: Supported
172
+ type6_breakpoint_remove(env, index);
187
F: hw/riscv/microchip_pfsoc.c
173
+ type6_breakpoint_insert(env, index);
188
+F: hw/char/mchp_pfsoc_mmuart.c
174
+ }
189
F: include/hw/riscv/microchip_pfsoc.h
175
+ break;
190
+F: include/hw/char/mchp_pfsoc_mmuart.h
176
+ case TDATA2:
191
177
+ if (val != env->tdata2[index]) {
192
RX Machines
178
+ env->tdata2[index] = val;
193
-----------
179
+ type6_breakpoint_remove(env, index);
194
diff --git a/hw/char/Kconfig b/hw/char/Kconfig
180
+ type6_breakpoint_insert(env, index);
195
index XXXXXXX..XXXXXXX 100644
181
+ }
196
--- a/hw/char/Kconfig
182
+ break;
197
+++ b/hw/char/Kconfig
183
+ case TDATA3:
198
@@ -XXX,XX +XXX,XX @@ config RENESAS_SCI
184
+ qemu_log_mask(LOG_UNIMP,
199
185
+ "tdata3 is not supported for type 6 trigger\n");
200
config AVR_USART
186
+ break;
201
bool
187
+ default:
202
+
188
+ g_assert_not_reached();
203
+config MCHP_PFSOC_MMUART
189
+ }
204
+ bool
190
+
205
diff --git a/hw/char/meson.build b/hw/char/meson.build
191
+ return;
206
index XXXXXXX..XXXXXXX 100644
192
+}
207
--- a/hw/char/meson.build
193
+
208
+++ b/hw/char/meson.build
194
target_ulong tdata_csr_read(CPURISCVState *env, int tdata_index)
209
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_aux.c'))
195
{
210
softmmu_ss.add(when: 'CONFIG_RENESAS_SCI', if_true: files('renesas_sci.c'))
196
switch (tdata_index) {
211
softmmu_ss.add(when: 'CONFIG_SH4', if_true: files('sh_serial.c'))
197
@@ -XXX,XX +XXX,XX @@ void tdata_csr_write(CPURISCVState *env, int tdata_index, target_ulong val)
212
softmmu_ss.add(when: 'CONFIG_STM32F2XX_USART', if_true: files('stm32f2xx_usart.c'))
198
case TRIGGER_TYPE_AD_MATCH:
213
+softmmu_ss.add(when: 'CONFIG_MCHP_PFSOC_MMUART', if_true: files('mchp_pfsoc_mmuart.c'))
199
type2_reg_write(env, env->trigger_cur, tdata_index, val);
214
200
break;
215
specific_ss.add(when: 'CONFIG_TERMINAL3270', if_true: files('terminal3270.c'))
201
+ case TRIGGER_TYPE_AD_MATCH6:
216
specific_ss.add(when: 'CONFIG_VIRTIO', if_true: files('virtio-serial-bus.c'))
202
+ type6_reg_write(env, env->trigger_cur, tdata_index, val);
203
+ break;
204
case TRIGGER_TYPE_INST_CNT:
205
case TRIGGER_TYPE_INT:
206
case TRIGGER_TYPE_EXCP:
207
- case TRIGGER_TYPE_AD_MATCH6:
208
case TRIGGER_TYPE_EXT_SRC:
209
qemu_log_mask(LOG_UNIMP, "trigger type: %d is not supported\n",
210
trigger_type);
211
@@ -XXX,XX +XXX,XX @@ void tdata_csr_write(CPURISCVState *env, int tdata_index, target_ulong val)
212
target_ulong tinfo_csr_read(CPURISCVState *env)
213
{
214
/* assume all triggers support the same types of triggers */
215
- return BIT(TRIGGER_TYPE_AD_MATCH);
216
+ return BIT(TRIGGER_TYPE_AD_MATCH) |
217
+ BIT(TRIGGER_TYPE_AD_MATCH6);
218
}
219
220
void riscv_cpu_debug_excp_handler(CPUState *cs)
221
@@ -XXX,XX +XXX,XX @@ bool riscv_cpu_debug_check_breakpoint(CPUState *cs)
222
}
223
}
224
break;
225
+ case TRIGGER_TYPE_AD_MATCH6:
226
+ ctrl = env->tdata1[i];
227
+ pc = env->tdata2[i];
228
+
229
+ if ((ctrl & TYPE6_EXEC) && (bp->pc == pc)) {
230
+ if (riscv_cpu_virt_enabled(env)) {
231
+ /* check VU/VS bit against current privilege level */
232
+ if ((ctrl >> 23) & BIT(env->priv)) {
233
+ return true;
234
+ }
235
+ } else {
236
+ /* check U/S/M bit against current privilege level */
237
+ if ((ctrl >> 3) & BIT(env->priv)) {
238
+ return true;
239
+ }
240
+ }
241
+ }
242
+ break;
243
default:
244
/* other trigger types are not supported or irrelevant */
245
break;
246
@@ -XXX,XX +XXX,XX @@ bool riscv_cpu_debug_check_watchpoint(CPUState *cs, CPUWatchpoint *wp)
247
}
248
}
249
break;
250
+ case TRIGGER_TYPE_AD_MATCH6:
251
+ ctrl = env->tdata1[i];
252
+ addr = env->tdata2[i];
253
+ flags = 0;
254
+
255
+ if (ctrl & TYPE6_LOAD) {
256
+ flags |= BP_MEM_READ;
257
+ }
258
+ if (ctrl & TYPE6_STORE) {
259
+ flags |= BP_MEM_WRITE;
260
+ }
261
+
262
+ if ((wp->flags & flags) && (wp->vaddr == addr)) {
263
+ if (riscv_cpu_virt_enabled(env)) {
264
+ /* check VU/VS bit against current privilege level */
265
+ if ((ctrl >> 23) & BIT(env->priv)) {
266
+ return true;
267
+ }
268
+ } else {
269
+ /* check U/S/M bit against current privilege level */
270
+ if ((ctrl >> 3) & BIT(env->priv)) {
271
+ return true;
272
+ }
273
+ }
274
+ }
275
+ break;
276
default:
277
/* other trigger types are not supported */
278
break;
217
--
279
--
218
2.28.0
280
2.37.3
219
220
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Yang Liu <liuyang22@iscas.ac.cn>
2
2
3
This is an effort to clean up the hw/riscv directory. Ideally it
3
Remove duplicate code by wrapping vfwredsum_vs's OP function.
4
should only contain the RISC-V SoC / machine codes plus generic
5
codes. Let's move sifive_clint model to hw/intc directory.
6
4
7
Signed-off-by: Bin Meng <bin.meng@windriver.com>
5
Signed-off-by: Yang Liu <liuyang22@iscas.ac.cn>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-Id: <1599129623-68957-6-git-send-email-bmeng.cn@gmail.com>
7
Reviewed-by: Frank Chang <frank.chang@sifive.com>
8
Message-Id: <20220817074802.20765-1-liuyang22@iscas.ac.cn>
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 => intc}/sifive_clint.h | 0
11
target/riscv/vector_helper.c | 56 +++++++-----------------------------
13
hw/{riscv => intc}/sifive_clint.c | 2 +-
12
1 file changed, 10 insertions(+), 46 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
13
27
diff --git a/include/hw/riscv/sifive_clint.h b/include/hw/intc/sifive_clint.h
14
diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c
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
15
index XXXXXXX..XXXXXXX 100644
36
--- a/hw/riscv/sifive_clint.c
16
--- a/target/riscv/vector_helper.c
37
+++ b/hw/intc/sifive_clint.c
17
+++ b/target/riscv/vector_helper.c
38
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@ GEN_VEXT_FRED(vfredmin_vs_h, uint16_t, uint16_t, H2, H2, float16_minimum_number)
39
#include "hw/sysbus.h"
19
GEN_VEXT_FRED(vfredmin_vs_w, uint32_t, uint32_t, H4, H4, float32_minimum_number)
40
#include "target/riscv/cpu.h"
20
GEN_VEXT_FRED(vfredmin_vs_d, uint64_t, uint64_t, H8, H8, float64_minimum_number)
41
#include "hw/qdev-properties.h"
21
42
-#include "hw/riscv/sifive_clint.h"
22
-/* Vector Widening Floating-Point Reduction Instructions */
43
+#include "hw/intc/sifive_clint.h"
23
-/* Unordered reduce 2*SEW = 2*SEW + sum(promote(SEW)) */
44
#include "qemu/timer.h"
24
-void HELPER(vfwredsum_vs_h)(void *vd, void *v0, void *vs1,
45
25
- void *vs2, CPURISCVState *env, uint32_t desc)
46
static uint64_t cpu_riscv_read_rtc(uint32_t timebase_freq)
26
+/* Vector Widening Floating-Point Add Instructions */
47
diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c
27
+static uint32_t fwadd16(uint32_t a, uint16_t b, float_status *s)
48
index XXXXXXX..XXXXXXX 100644
28
{
49
--- a/hw/riscv/microchip_pfsoc.c
29
- uint32_t vm = vext_vm(desc);
50
+++ b/hw/riscv/microchip_pfsoc.c
30
- uint32_t vl = env->vl;
51
@@ -XXX,XX +XXX,XX @@
31
- uint32_t esz = sizeof(uint32_t);
52
#include "hw/misc/unimp.h"
32
- uint32_t vlenb = simd_maxsz(desc);
53
#include "hw/riscv/boot.h"
33
- uint32_t vta = vext_vta(desc);
54
#include "hw/riscv/riscv_hart.h"
34
- uint32_t i;
55
-#include "hw/riscv/sifive_clint.h"
35
- uint32_t s1 = *((uint32_t *)vs1 + H4(0));
56
#include "hw/riscv/sifive_plic.h"
36
-
57
#include "hw/riscv/microchip_pfsoc.h"
37
- for (i = env->vstart; i < vl; i++) {
58
+#include "hw/intc/sifive_clint.h"
38
- uint16_t s2 = *((uint16_t *)vs2 + H2(i));
59
#include "sysemu/sysemu.h"
39
- if (!vm && !vext_elem_mask(v0, i)) {
60
40
- continue;
41
- }
42
- s1 = float32_add(s1, float16_to_float32(s2, true, &env->fp_status),
43
- &env->fp_status);
44
- }
45
- *((uint32_t *)vd + H4(0)) = s1;
46
- env->vstart = 0;
47
- /* set tail elements to 1s */
48
- vext_set_elems_1s(vd, vta, esz, vlenb);
49
+ return float32_add(a, float16_to_float32(b, true, s), s);
50
}
51
52
-void HELPER(vfwredsum_vs_w)(void *vd, void *v0, void *vs1,
53
- void *vs2, CPURISCVState *env, uint32_t desc)
54
+static uint64_t fwadd32(uint64_t a, uint32_t b, float_status *s)
55
{
56
- uint32_t vm = vext_vm(desc);
57
- uint32_t vl = env->vl;
58
- uint32_t esz = sizeof(uint64_t);
59
- uint32_t vlenb = simd_maxsz(desc);
60
- uint32_t vta = vext_vta(desc);
61
- uint32_t i;
62
- uint64_t s1 = *((uint64_t *)vs1);
63
-
64
- for (i = env->vstart; i < vl; i++) {
65
- uint32_t s2 = *((uint32_t *)vs2 + H4(i));
66
- if (!vm && !vext_elem_mask(v0, i)) {
67
- continue;
68
- }
69
- s1 = float64_add(s1, float32_to_float64(s2, &env->fp_status),
70
- &env->fp_status);
71
- }
72
- *((uint64_t *)vd) = s1;
73
- env->vstart = 0;
74
- /* set tail elements to 1s */
75
- vext_set_elems_1s(vd, vta, esz, vlenb);
76
+ return float64_add(a, float32_to_float64(b, s), s);
77
}
78
79
+/* Vector Widening Floating-Point Reduction Instructions */
80
+/* Unordered reduce 2*SEW = 2*SEW + sum(promote(SEW)) */
81
+GEN_VEXT_FRED(vfwredsum_vs_h, uint32_t, uint16_t, H4, H2, fwadd16)
82
+GEN_VEXT_FRED(vfwredsum_vs_w, uint64_t, uint32_t, H8, H4, fwadd32)
83
+
61
/*
84
/*
62
diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c
85
*** Vector Mask Operations
63
index XXXXXXX..XXXXXXX 100644
86
*/
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
95
index XXXXXXX..XXXXXXX 100644
96
--- a/hw/riscv/spike.c
97
+++ b/hw/riscv/spike.c
98
@@ -XXX,XX +XXX,XX @@
99
#include "target/riscv/cpu.h"
100
#include "hw/riscv/riscv_htif.h"
101
#include "hw/riscv/riscv_hart.h"
102
-#include "hw/riscv/sifive_clint.h"
103
#include "hw/riscv/spike.h"
104
#include "hw/riscv/boot.h"
105
#include "hw/riscv/numa.h"
106
+#include "hw/intc/sifive_clint.h"
107
#include "chardev/char.h"
108
#include "sysemu/arch_init.h"
109
#include "sysemu/device_tree.h"
110
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
111
index XXXXXXX..XXXXXXX 100644
112
--- a/hw/riscv/virt.c
113
+++ b/hw/riscv/virt.c
114
@@ -XXX,XX +XXX,XX @@
115
#include "target/riscv/cpu.h"
116
#include "hw/riscv/riscv_hart.h"
117
#include "hw/riscv/sifive_plic.h"
118
-#include "hw/riscv/sifive_clint.h"
119
#include "hw/riscv/sifive_test.h"
120
#include "hw/riscv/virt.h"
121
#include "hw/riscv/boot.h"
122
#include "hw/riscv/numa.h"
123
+#include "hw/intc/sifive_clint.h"
124
#include "chardev/char.h"
125
#include "sysemu/arch_init.h"
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
--
87
--
205
2.28.0
88
2.37.3
206
207
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Yang Liu <liuyang22@iscas.ac.cn>
2
2
3
Microchip PolarFire SoC has 5 MMUARTs, and the Icicle Kit board
3
Starting with RVV1.0, the original vf[w]redsum_vs instruction was renamed
4
wires 4 of them out. Let's connect all 5 MMUARTs.
4
to vf[w]redusum_vs. The distinction between ordered and unordered is also
5
more consistent with other instructions, although there is no difference
6
in implementation between the two for QEMU.
5
7
6
Signed-off-by: Bin Meng <bin.meng@windriver.com>
8
Signed-off-by: Yang Liu <liuyang22@iscas.ac.cn>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Acked-by: Alistair Francis <alistair.francis@wdc.com>
8
Message-Id: <1598924352-89526-7-git-send-email-bmeng.cn@gmail.com>
10
Reviewed-by: Frank Chang <frank.chang@sifive.com>
11
Message-Id: <20220817074802.20765-2-liuyang22@iscas.ac.cn>
9
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
12
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
---
13
---
11
include/hw/riscv/microchip_pfsoc.h | 20 ++++++++++++++++++++
14
target/riscv/helper.h | 15 ++++++++++-----
12
hw/riscv/microchip_pfsoc.c | 30 ++++++++++++++++++++++++++++++
15
target/riscv/insn32.decode | 6 ++++--
13
hw/riscv/Kconfig | 1 +
16
target/riscv/vector_helper.c | 19 +++++++++++++------
14
3 files changed, 51 insertions(+)
17
target/riscv/insn_trans/trans_rvv.c.inc | 6 ++++--
18
4 files changed, 31 insertions(+), 15 deletions(-)
15
19
16
diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchip_pfsoc.h
20
diff --git a/target/riscv/helper.h b/target/riscv/helper.h
17
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/riscv/microchip_pfsoc.h
22
--- a/target/riscv/helper.h
19
+++ b/include/hw/riscv/microchip_pfsoc.h
23
+++ b/target/riscv/helper.h
20
@@ -XXX,XX +XXX,XX @@
24
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vwredsum_vs_b, void, ptr, ptr, ptr, ptr, env, i32)
21
#ifndef HW_MICROCHIP_PFSOC_H
25
DEF_HELPER_6(vwredsum_vs_h, void, ptr, ptr, ptr, ptr, env, i32)
22
#define HW_MICROCHIP_PFSOC_H
26
DEF_HELPER_6(vwredsum_vs_w, void, ptr, ptr, ptr, ptr, env, i32)
23
27
24
+#include "hw/char/mchp_pfsoc_mmuart.h"
28
-DEF_HELPER_6(vfredsum_vs_h, void, ptr, ptr, ptr, ptr, env, i32)
29
-DEF_HELPER_6(vfredsum_vs_w, void, ptr, ptr, ptr, ptr, env, i32)
30
-DEF_HELPER_6(vfredsum_vs_d, void, ptr, ptr, ptr, ptr, env, i32)
31
+DEF_HELPER_6(vfredusum_vs_h, void, ptr, ptr, ptr, ptr, env, i32)
32
+DEF_HELPER_6(vfredusum_vs_w, void, ptr, ptr, ptr, ptr, env, i32)
33
+DEF_HELPER_6(vfredusum_vs_d, void, ptr, ptr, ptr, ptr, env, i32)
34
+DEF_HELPER_6(vfredosum_vs_h, void, ptr, ptr, ptr, ptr, env, i32)
35
+DEF_HELPER_6(vfredosum_vs_w, void, ptr, ptr, ptr, ptr, env, i32)
36
+DEF_HELPER_6(vfredosum_vs_d, void, ptr, ptr, ptr, ptr, env, i32)
37
DEF_HELPER_6(vfredmax_vs_h, void, ptr, ptr, ptr, ptr, env, i32)
38
DEF_HELPER_6(vfredmax_vs_w, void, ptr, ptr, ptr, ptr, env, i32)
39
DEF_HELPER_6(vfredmax_vs_d, void, ptr, ptr, ptr, ptr, env, i32)
40
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_6(vfredmin_vs_h, void, ptr, ptr, ptr, ptr, env, i32)
41
DEF_HELPER_6(vfredmin_vs_w, void, ptr, ptr, ptr, ptr, env, i32)
42
DEF_HELPER_6(vfredmin_vs_d, void, ptr, ptr, ptr, ptr, env, i32)
43
44
-DEF_HELPER_6(vfwredsum_vs_h, void, ptr, ptr, ptr, ptr, env, i32)
45
-DEF_HELPER_6(vfwredsum_vs_w, void, ptr, ptr, ptr, ptr, env, i32)
46
+DEF_HELPER_6(vfwredusum_vs_h, void, ptr, ptr, ptr, ptr, env, i32)
47
+DEF_HELPER_6(vfwredusum_vs_w, void, ptr, ptr, ptr, ptr, env, i32)
48
+DEF_HELPER_6(vfwredosum_vs_h, void, ptr, ptr, ptr, ptr, env, i32)
49
+DEF_HELPER_6(vfwredosum_vs_w, void, ptr, ptr, ptr, ptr, env, i32)
50
51
DEF_HELPER_6(vmand_mm, void, ptr, ptr, ptr, ptr, env, i32)
52
DEF_HELPER_6(vmnand_mm, void, ptr, ptr, ptr, ptr, env, i32)
53
diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode
54
index XXXXXXX..XXXXXXX 100644
55
--- a/target/riscv/insn32.decode
56
+++ b/target/riscv/insn32.decode
57
@@ -XXX,XX +XXX,XX @@ vredmax_vs 000111 . ..... ..... 010 ..... 1010111 @r_vm
58
vwredsumu_vs 110000 . ..... ..... 000 ..... 1010111 @r_vm
59
vwredsum_vs 110001 . ..... ..... 000 ..... 1010111 @r_vm
60
# Vector ordered and unordered reduction sum
61
-vfredsum_vs 0000-1 . ..... ..... 001 ..... 1010111 @r_vm
62
+vfredusum_vs 000001 . ..... ..... 001 ..... 1010111 @r_vm
63
+vfredosum_vs 000011 . ..... ..... 001 ..... 1010111 @r_vm
64
vfredmin_vs 000101 . ..... ..... 001 ..... 1010111 @r_vm
65
vfredmax_vs 000111 . ..... ..... 001 ..... 1010111 @r_vm
66
# Vector widening ordered and unordered float reduction sum
67
-vfwredsum_vs 1100-1 . ..... ..... 001 ..... 1010111 @r_vm
68
+vfwredusum_vs 110001 . ..... ..... 001 ..... 1010111 @r_vm
69
+vfwredosum_vs 110011 . ..... ..... 001 ..... 1010111 @r_vm
70
vmand_mm 011001 - ..... ..... 010 ..... 1010111 @r
71
vmnand_mm 011101 - ..... ..... 010 ..... 1010111 @r
72
vmandn_mm 011000 - ..... ..... 010 ..... 1010111 @r
73
diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c
74
index XXXXXXX..XXXXXXX 100644
75
--- a/target/riscv/vector_helper.c
76
+++ b/target/riscv/vector_helper.c
77
@@ -XXX,XX +XXX,XX @@ void HELPER(NAME)(void *vd, void *v0, void *vs1, \
78
}
79
80
/* Unordered sum */
81
-GEN_VEXT_FRED(vfredsum_vs_h, uint16_t, uint16_t, H2, H2, float16_add)
82
-GEN_VEXT_FRED(vfredsum_vs_w, uint32_t, uint32_t, H4, H4, float32_add)
83
-GEN_VEXT_FRED(vfredsum_vs_d, uint64_t, uint64_t, H8, H8, float64_add)
84
+GEN_VEXT_FRED(vfredusum_vs_h, uint16_t, uint16_t, H2, H2, float16_add)
85
+GEN_VEXT_FRED(vfredusum_vs_w, uint32_t, uint32_t, H4, H4, float32_add)
86
+GEN_VEXT_FRED(vfredusum_vs_d, uint64_t, uint64_t, H8, H8, float64_add)
25
+
87
+
26
typedef struct MicrochipPFSoCState {
88
+/* Ordered sum */
27
/*< private >*/
89
+GEN_VEXT_FRED(vfredosum_vs_h, uint16_t, uint16_t, H2, H2, float16_add)
28
DeviceState parent_obj;
90
+GEN_VEXT_FRED(vfredosum_vs_w, uint32_t, uint32_t, H4, H4, float32_add)
29
@@ -XXX,XX +XXX,XX @@ typedef struct MicrochipPFSoCState {
91
+GEN_VEXT_FRED(vfredosum_vs_d, uint64_t, uint64_t, H8, H8, float64_add)
30
RISCVHartArrayState e_cpus;
92
31
RISCVHartArrayState u_cpus;
93
/* Maximum value */
32
DeviceState *plic;
94
GEN_VEXT_FRED(vfredmax_vs_h, uint16_t, uint16_t, H2, H2, float16_maximum_number)
33
+ MchpPfSoCMMUartState *serial0;
95
@@ -XXX,XX +XXX,XX @@ static uint64_t fwadd32(uint64_t a, uint32_t b, float_status *s)
34
+ MchpPfSoCMMUartState *serial1;
96
}
35
+ MchpPfSoCMMUartState *serial2;
97
36
+ MchpPfSoCMMUartState *serial3;
98
/* Vector Widening Floating-Point Reduction Instructions */
37
+ MchpPfSoCMMUartState *serial4;
99
-/* Unordered reduce 2*SEW = 2*SEW + sum(promote(SEW)) */
38
} MicrochipPFSoCState;
100
-GEN_VEXT_FRED(vfwredsum_vs_h, uint32_t, uint16_t, H4, H2, fwadd16)
39
101
-GEN_VEXT_FRED(vfwredsum_vs_w, uint64_t, uint32_t, H8, H4, fwadd32)
40
#define TYPE_MICROCHIP_PFSOC "microchip.pfsoc"
102
+/* Ordered/unordered reduce 2*SEW = 2*SEW + sum(promote(SEW)) */
41
@@ -XXX,XX +XXX,XX @@ enum {
103
+GEN_VEXT_FRED(vfwredusum_vs_h, uint32_t, uint16_t, H4, H2, fwadd16)
42
MICROCHIP_PFSOC_L2CC,
104
+GEN_VEXT_FRED(vfwredusum_vs_w, uint64_t, uint32_t, H8, H4, fwadd32)
43
MICROCHIP_PFSOC_L2LIM,
105
+GEN_VEXT_FRED(vfwredosum_vs_h, uint32_t, uint16_t, H4, H2, fwadd16)
44
MICROCHIP_PFSOC_PLIC,
106
+GEN_VEXT_FRED(vfwredosum_vs_w, uint64_t, uint32_t, H8, H4, fwadd32)
45
+ MICROCHIP_PFSOC_MMUART0,
107
46
MICROCHIP_PFSOC_SYSREG,
108
/*
47
MICROCHIP_PFSOC_MPUCFG,
109
*** Vector Mask Operations
48
+ MICROCHIP_PFSOC_MMUART1,
110
diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_trans/trans_rvv.c.inc
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
};
57
58
+enum {
59
+ MICROCHIP_PFSOC_MMUART0_IRQ = 90,
60
+ MICROCHIP_PFSOC_MMUART1_IRQ = 91,
61
+ MICROCHIP_PFSOC_MMUART2_IRQ = 92,
62
+ MICROCHIP_PFSOC_MMUART3_IRQ = 93,
63
+ MICROCHIP_PFSOC_MMUART4_IRQ = 94,
64
+};
65
+
66
#define MICROCHIP_PFSOC_MANAGEMENT_CPU_COUNT 1
67
#define MICROCHIP_PFSOC_COMPUTE_CPU_COUNT 4
68
69
diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c
70
index XXXXXXX..XXXXXXX 100644
111
index XXXXXXX..XXXXXXX 100644
71
--- a/hw/riscv/microchip_pfsoc.c
112
--- a/target/riscv/insn_trans/trans_rvv.c.inc
72
+++ b/hw/riscv/microchip_pfsoc.c
113
+++ b/target/riscv/insn_trans/trans_rvv.c.inc
73
@@ -XXX,XX +XXX,XX @@
114
@@ -XXX,XX +XXX,XX @@ static bool freduction_check(DisasContext *s, arg_rmrr *a)
74
* 0) CLINT (Core Level Interruptor)
115
require_zve64f(s);
75
* 1) PLIC (Platform Level Interrupt Controller)
116
}
76
* 2) eNVM (Embedded Non-Volatile Memory)
117
77
+ * 3) MMUARTs (Multi-Mode UART)
118
-GEN_OPFVV_TRANS(vfredsum_vs, freduction_check)
78
*
119
+GEN_OPFVV_TRANS(vfredusum_vs, freduction_check)
79
* This board currently generates devicetree dynamically that indicates at least
120
+GEN_OPFVV_TRANS(vfredosum_vs, freduction_check)
80
* two harts and up to five harts.
121
GEN_OPFVV_TRANS(vfredmax_vs, freduction_check)
81
@@ -XXX,XX +XXX,XX @@
122
GEN_OPFVV_TRANS(vfredmin_vs, freduction_check)
82
#include "hw/irq.h"
123
83
#include "hw/loader.h"
124
@@ -XXX,XX +XXX,XX @@ static bool freduction_widen_check(DisasContext *s, arg_rmrr *a)
84
#include "hw/sysbus.h"
125
(s->sew != MO_8);
85
+#include "chardev/char.h"
126
}
86
#include "hw/cpu/cluster.h"
127
87
#include "target/riscv/cpu.h"
128
-GEN_OPFVV_WIDEN_TRANS(vfwredsum_vs, freduction_widen_check)
88
#include "hw/misc/unimp.h"
129
+GEN_OPFVV_WIDEN_TRANS(vfwredusum_vs, freduction_widen_check)
89
@@ -XXX,XX +XXX,XX @@
130
+GEN_OPFVV_WIDEN_TRANS(vfwredosum_vs, freduction_widen_check)
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
131
95
/*
132
/*
96
* The BIOS image used by this machine is called Hart Software Services (HSS).
133
*** Vector Mask Operations
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
--
134
--
150
2.28.0
135
2.37.3
151
152
diff view generated by jsdifflib
Deleted patch
1
From: Bin Meng <bin.meng@windriver.com>
2
1
3
On the Icicle Kit board, the HSS firmware utilizes the on-chip DMA
4
controller to move the 2nd stage bootloader in the system memory.
5
Let's connect a DMA controller to Microchip PolarFire SoC.
6
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>
11
---
12
include/hw/riscv/microchip_pfsoc.h | 11 +++++++++++
13
hw/riscv/microchip_pfsoc.c | 15 +++++++++++++++
14
hw/riscv/Kconfig | 1 +
15
3 files changed, 27 insertions(+)
16
17
diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchip_pfsoc.h
18
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/riscv/microchip_pfsoc.h
20
+++ b/include/hw/riscv/microchip_pfsoc.h
21
@@ -XXX,XX +XXX,XX @@
22
#define HW_MICROCHIP_PFSOC_H
23
24
#include "hw/char/mchp_pfsoc_mmuart.h"
25
+#include "hw/dma/sifive_pdma.h"
26
#include "hw/sd/cadence_sdhci.h"
27
28
typedef struct MicrochipPFSoCState {
29
@@ -XXX,XX +XXX,XX @@ typedef struct MicrochipPFSoCState {
30
MchpPfSoCMMUartState *serial2;
31
MchpPfSoCMMUartState *serial3;
32
MchpPfSoCMMUartState *serial4;
33
+ SiFivePDMAState dma;
34
CadenceSDHCIState sdhci;
35
} MicrochipPFSoCState;
36
37
@@ -XXX,XX +XXX,XX @@ enum {
38
MICROCHIP_PFSOC_BUSERR_UNIT4,
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 {
46
};
47
48
enum {
49
+ MICROCHIP_PFSOC_DMA_IRQ0 = 5,
50
+ MICROCHIP_PFSOC_DMA_IRQ1 = 6,
51
+ MICROCHIP_PFSOC_DMA_IRQ2 = 7,
52
+ MICROCHIP_PFSOC_DMA_IRQ3 = 8,
53
+ MICROCHIP_PFSOC_DMA_IRQ4 = 9,
54
+ MICROCHIP_PFSOC_DMA_IRQ5 = 10,
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
62
--- a/hw/riscv/microchip_pfsoc.c
63
+++ b/hw/riscv/microchip_pfsoc.c
64
@@ -XXX,XX +XXX,XX @@
65
* 2) eNVM (Embedded Non-Volatile Memory)
66
* 3) MMUARTs (Multi-Mode UART)
67
* 4) Cadence eMMC/SDHC controller and an SD card connected to it
68
+ * 5) SiFive Platform 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
[MICROCHIP_PFSOC_BUSERR_UNIT4] = { 0x1704000, 0x1000 },
74
[MICROCHIP_PFSOC_CLINT] = { 0x2000000, 0x10000 },
75
[MICROCHIP_PFSOC_L2CC] = { 0x2010000, 0x1000 },
76
+ [MICROCHIP_PFSOC_DMA] = { 0x3000000, 0x100000 },
77
[MICROCHIP_PFSOC_L2LIM] = { 0x8000000, 0x2000000 },
78
[MICROCHIP_PFSOC_PLIC] = { 0xc000000, 0x4000000 },
79
[MICROCHIP_PFSOC_MMUART0] = { 0x20000000, 0x1000 },
80
@@ -XXX,XX +XXX,XX @@ static void microchip_pfsoc_soc_instance_init(Object *obj)
81
TYPE_RISCV_CPU_SIFIVE_U54);
82
qdev_prop_set_uint64(DEVICE(&s->u_cpus), "resetvec", RESET_VECTOR);
83
84
+ object_initialize_child(obj, "dma-controller", &s->dma,
85
+ TYPE_SIFIVE_PDMA);
86
+
87
object_initialize_child(obj, "sd-controller", &s->sdhci,
88
TYPE_CADENCE_SDHCI);
89
}
90
@@ -XXX,XX +XXX,XX @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp)
91
memmap[MICROCHIP_PFSOC_PLIC].size);
92
g_free(plic_hart_config);
93
94
+ /* DMA */
95
+ sysbus_realize(SYS_BUS_DEVICE(&s->dma), errp);
96
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->dma), 0,
97
+ memmap[MICROCHIP_PFSOC_DMA].base);
98
+ for (i = 0; i < SIFIVE_PDMA_IRQS; i++) {
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
--
118
2.28.0
119
120
diff view generated by jsdifflib
Deleted patch
1
From: Bin Meng <bin.meng@windriver.com>
2
1
3
At present the PHY address of the PHY connected to GEM is hard-coded
4
to either 23 (BOARD_PHY_ADDRESS) or 0. This might not be the case for
5
all boards. Add a new 'phy-addr' property so that board can specify
6
the PHY address for each GEM instance.
7
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>
12
Message-Id: <1598924352-89526-12-git-send-email-bmeng.cn@gmail.com>
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
14
---
15
include/hw/net/cadence_gem.h | 2 ++
16
hw/net/cadence_gem.c | 5 +++--
17
2 files changed, 5 insertions(+), 2 deletions(-)
18
19
diff --git a/include/hw/net/cadence_gem.h b/include/hw/net/cadence_gem.h
20
index XXXXXXX..XXXXXXX 100644
21
--- a/include/hw/net/cadence_gem.h
22
+++ b/include/hw/net/cadence_gem.h
23
@@ -XXX,XX +XXX,XX @@ typedef struct CadenceGEMState {
24
/* Mask of register bits which are write 1 to clear */
25
uint32_t regs_w1c[CADENCE_GEM_MAXREG];
26
27
+ /* PHY address */
28
+ uint8_t phy_addr;
29
/* PHY registers backing store */
30
uint16_t phy_regs[32];
31
32
diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/net/cadence_gem.c
35
+++ b/hw/net/cadence_gem.c
36
@@ -XXX,XX +XXX,XX @@ static uint64_t gem_read(void *opaque, hwaddr offset, unsigned size)
37
uint32_t phy_addr, reg_num;
38
39
phy_addr = (retval & GEM_PHYMNTNC_ADDR) >> GEM_PHYMNTNC_ADDR_SHFT;
40
- if (phy_addr == BOARD_PHY_ADDRESS || phy_addr == 0) {
41
+ if (phy_addr == s->phy_addr || phy_addr == 0) {
42
reg_num = (retval & GEM_PHYMNTNC_REG) >> GEM_PHYMNTNC_REG_SHIFT;
43
retval &= 0xFFFF0000;
44
retval |= gem_phy_read(s, reg_num);
45
@@ -XXX,XX +XXX,XX @@ static void gem_write(void *opaque, hwaddr offset, uint64_t val,
46
uint32_t phy_addr, reg_num;
47
48
phy_addr = (val & GEM_PHYMNTNC_ADDR) >> GEM_PHYMNTNC_ADDR_SHFT;
49
- if (phy_addr == BOARD_PHY_ADDRESS || phy_addr == 0) {
50
+ if (phy_addr == s->phy_addr || phy_addr == 0) {
51
reg_num = (val & GEM_PHYMNTNC_REG) >> GEM_PHYMNTNC_REG_SHIFT;
52
gem_phy_write(s, reg_num, val);
53
}
54
@@ -XXX,XX +XXX,XX @@ static Property gem_properties[] = {
55
DEFINE_NIC_PROPERTIES(CadenceGEMState, conf),
56
DEFINE_PROP_UINT32("revision", CadenceGEMState, revision,
57
GEM_MODID_VALUE),
58
+ DEFINE_PROP_UINT8("phy-addr", CadenceGEMState, phy_addr, BOARD_PHY_ADDRESS),
59
DEFINE_PROP_UINT8("num-priority-queues", CadenceGEMState,
60
num_priority_queues, 1),
61
DEFINE_PROP_UINT8("num-type1-screeners", CadenceGEMState,
62
--
63
2.28.0
64
65
diff view generated by jsdifflib
Deleted patch
1
From: Bin Meng <bin.meng@windriver.com>
2
1
3
When cadence_gem model was created for Xilinx boards, the PHY address
4
was hard-coded to 23 in the GEM model. Now that we have introduced a
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
9
Signed-off-by: Bin Meng <bin.meng@windriver.com>
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
12
Message-Id: <1598924352-89526-13-git-send-email-bmeng.cn@gmail.com>
13
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
14
---
15
hw/arm/xilinx_zynq.c | 1 +
16
hw/arm/xlnx-versal.c | 1 +
17
hw/arm/xlnx-zynqmp.c | 2 ++
18
hw/net/cadence_gem.c | 6 +++---
19
4 files changed, 7 insertions(+), 3 deletions(-)
20
21
diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
22
index XXXXXXX..XXXXXXX 100644
23
--- a/hw/arm/xilinx_zynq.c
24
+++ b/hw/arm/xilinx_zynq.c
25
@@ -XXX,XX +XXX,XX @@ static void gem_init(NICInfo *nd, uint32_t base, qemu_irq irq)
26
qemu_check_nic_model(nd, TYPE_CADENCE_GEM);
27
qdev_set_nic_properties(dev, nd);
28
}
29
+ object_property_set_int(OBJECT(dev), "phy-addr", 23, &error_abort);
30
s = SYS_BUS_DEVICE(dev);
31
sysbus_realize_and_unref(s, &error_fatal);
32
sysbus_mmio_map(s, 0, base);
33
diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c
34
index XXXXXXX..XXXXXXX 100644
35
--- a/hw/arm/xlnx-versal.c
36
+++ b/hw/arm/xlnx-versal.c
37
@@ -XXX,XX +XXX,XX @@ static void versal_create_gems(Versal *s, qemu_irq *pic)
38
qemu_check_nic_model(nd, "cadence_gem");
39
qdev_set_nic_properties(dev, nd);
40
}
41
+ object_property_set_int(OBJECT(dev), "phy-addr", 23, &error_abort);
42
object_property_set_int(OBJECT(dev), "num-priority-queues", 2,
43
&error_abort);
44
object_property_set_link(OBJECT(dev), "dma", OBJECT(&s->mr_ps),
45
diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c
46
index XXXXXXX..XXXXXXX 100644
47
--- a/hw/arm/xlnx-zynqmp.c
48
+++ b/hw/arm/xlnx-zynqmp.c
49
@@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
50
}
51
object_property_set_int(OBJECT(&s->gem[i]), "revision", GEM_REVISION,
52
&error_abort);
53
+ object_property_set_int(OBJECT(&s->gem[i]), "phy-addr", 23,
54
+ &error_abort);
55
object_property_set_int(OBJECT(&s->gem[i]), "num-priority-queues", 2,
56
&error_abort);
57
if (!sysbus_realize(SYS_BUS_DEVICE(&s->gem[i]), errp)) {
58
diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
59
index XXXXXXX..XXXXXXX 100644
60
--- a/hw/net/cadence_gem.c
61
+++ b/hw/net/cadence_gem.c
62
@@ -XXX,XX +XXX,XX @@
63
#define GEM_PHYMNTNC_REG_SHIFT 18
64
65
/* Marvell PHY definitions */
66
-#define BOARD_PHY_ADDRESS 23 /* PHY address we will emulate a device at */
67
+#define BOARD_PHY_ADDRESS 0 /* PHY address we will emulate a device at */
68
69
#define PHY_REG_CONTROL 0
70
#define PHY_REG_STATUS 1
71
@@ -XXX,XX +XXX,XX @@ static uint64_t gem_read(void *opaque, hwaddr offset, unsigned size)
72
uint32_t phy_addr, reg_num;
73
74
phy_addr = (retval & GEM_PHYMNTNC_ADDR) >> GEM_PHYMNTNC_ADDR_SHFT;
75
- if (phy_addr == s->phy_addr || phy_addr == 0) {
76
+ if (phy_addr == s->phy_addr) {
77
reg_num = (retval & GEM_PHYMNTNC_REG) >> GEM_PHYMNTNC_REG_SHIFT;
78
retval &= 0xFFFF0000;
79
retval |= gem_phy_read(s, reg_num);
80
@@ -XXX,XX +XXX,XX @@ static void gem_write(void *opaque, hwaddr offset, uint64_t val,
81
uint32_t phy_addr, reg_num;
82
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
--
90
2.28.0
91
92
diff view generated by jsdifflib
Deleted patch
1
From: Bin Meng <bin.meng@windriver.com>
2
1
3
Microchip PolarFire SoC integrates 3 GPIOs controllers. It seems
4
enough to create unimplemented devices to cover their register
5
spaces at this point.
6
7
With this commit, QEMU can boot to U-Boot (2nd stage bootloader)
8
all the way to the Linux shell login prompt, with a modified HSS
9
(1st stage bootloader).
10
11
For detailed instructions on how to create images for the Icicle
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>
17
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
18
Message-Id: <1598924352-89526-15-git-send-email-bmeng.cn@gmail.com>
19
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
20
---
21
include/hw/riscv/microchip_pfsoc.h | 3 +++
22
hw/riscv/microchip_pfsoc.c | 14 ++++++++++++++
23
2 files changed, 17 insertions(+)
24
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
40
index XXXXXXX..XXXXXXX 100644
41
--- a/hw/riscv/microchip_pfsoc.c
42
+++ b/hw/riscv/microchip_pfsoc.c
43
@@ -XXX,XX +XXX,XX @@ static const struct MemmapEntry {
44
[MICROCHIP_PFSOC_MMUART4] = { 0x20106000, 0x1000 },
45
[MICROCHIP_PFSOC_GEM0] = { 0x20110000, 0x2000 },
46
[MICROCHIP_PFSOC_GEM1] = { 0x20112000, 0x2000 },
47
+ [MICROCHIP_PFSOC_GPIO0] = { 0x20120000, 0x1000 },
48
+ [MICROCHIP_PFSOC_GPIO1] = { 0x20121000, 0x1000 },
49
+ [MICROCHIP_PFSOC_GPIO2] = { 0x20122000, 0x1000 },
50
[MICROCHIP_PFSOC_ENVM_CFG] = { 0x20200000, 0x1000 },
51
[MICROCHIP_PFSOC_ENVM_DATA] = { 0x20220000, 0x20000 },
52
[MICROCHIP_PFSOC_IOSCB_CFG] = { 0x37080000, 0x1000 },
53
@@ -XXX,XX +XXX,XX @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp)
54
sysbus_connect_irq(SYS_BUS_DEVICE(&s->gem1), 0,
55
qdev_get_gpio_in(DEVICE(s->plic), MICROCHIP_PFSOC_GEM1_IRQ));
56
57
+ /* GPIOs */
58
+ create_unimplemented_device("microchip.pfsoc.gpio0",
59
+ memmap[MICROCHIP_PFSOC_GPIO0].base,
60
+ memmap[MICROCHIP_PFSOC_GPIO0].size);
61
+ create_unimplemented_device("microchip.pfsoc.gpio1",
62
+ memmap[MICROCHIP_PFSOC_GPIO1].base,
63
+ memmap[MICROCHIP_PFSOC_GPIO1].size);
64
+ create_unimplemented_device("microchip.pfsoc.gpio2",
65
+ memmap[MICROCHIP_PFSOC_GPIO2].base,
66
+ memmap[MICROCHIP_PFSOC_GPIO2].size);
67
+
68
/* eNVM */
69
memory_region_init_rom(envm_data, OBJECT(dev), "microchip.pfsoc.envm.data",
70
memmap[MICROCHIP_PFSOC_ENVM_DATA].size,
71
--
72
2.28.0
73
74
diff view generated by jsdifflib
Deleted patch
1
From: Bin Meng <bin.meng@windriver.com>
2
1
3
This is an effort to clean up the hw/riscv directory. Ideally it
4
should only contain the RISC-V SoC / machine codes plus generic
5
codes. Let's move sifive_e_prci model to hw/misc directory.
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-2-git-send-email-bmeng.cn@gmail.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
12
include/hw/{riscv => misc}/sifive_e_prci.h | 0
13
hw/{riscv => misc}/sifive_e_prci.c | 2 +-
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
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
44
index XXXXXXX..XXXXXXX 100644
45
--- a/hw/riscv/sifive_e.c
46
+++ b/hw/riscv/sifive_e.c
47
@@ -XXX,XX +XXX,XX @@
48
#include "hw/riscv/sifive_clint.h"
49
#include "hw/riscv/sifive_uart.h"
50
#include "hw/riscv/sifive_e.h"
51
-#include "hw/riscv/sifive_e_prci.h"
52
#include "hw/riscv/boot.h"
53
+#include "hw/misc/sifive_e_prci.h"
54
#include "chardev/char.h"
55
#include "sysemu/arch_init.h"
56
#include "sysemu/sysemu.h"
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 MAC_VIA
62
config AVR_POWER
63
bool
64
65
+config SIFIVE_E_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_ARM11SCU', if_true: files('arm11scu.c'))
74
# Mac devices
75
softmmu_ss.add(when: 'CONFIG_MOS6522', if_true: files('mos6522.c'))
76
77
+# RISC-V devices
78
+softmmu_ss.add(when: 'CONFIG_SIFIVE_E_PRCI', if_true: files('sifive_e_prci.c'))
79
+
80
# PKUnity SoC devices
81
softmmu_ss.add(when: 'CONFIG_PUV3', if_true: files('puv3_pm.c'))
82
83
diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
84
index XXXXXXX..XXXXXXX 100644
85
--- a/hw/riscv/Kconfig
86
+++ b/hw/riscv/Kconfig
87
@@ -XXX,XX +XXX,XX @@ config SIFIVE_E
88
bool
89
select HART
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
--
108
2.28.0
109
110
diff view generated by jsdifflib
Deleted patch
1
From: Bin Meng <bin.meng@windriver.com>
2
1
3
This is an effort to clean up the hw/riscv directory. Ideally it
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
7
Signed-off-by: Bin Meng <bin.meng@windriver.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-Id: <1599129623-68957-3-git-send-email-bmeng.cn@gmail.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
12
include/hw/{riscv => misc}/sifive_u_prci.h | 0
13
include/hw/riscv/sifive_u.h | 2 +-
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
23
diff --git a/include/hw/riscv/sifive_u_prci.h b/include/hw/misc/sifive_u_prci.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
29
--- a/include/hw/riscv/sifive_u.h
30
+++ b/include/hw/riscv/sifive_u.h
31
@@ -XXX,XX +XXX,XX @@
32
#include "hw/riscv/riscv_hart.h"
33
#include "hw/riscv/sifive_cpu.h"
34
#include "hw/riscv/sifive_gpio.h"
35
-#include "hw/riscv/sifive_u_prci.h"
36
#include "hw/riscv/sifive_u_otp.h"
37
+#include "hw/misc/sifive_u_prci.h"
38
39
#define TYPE_RISCV_U_SOC "riscv.sifive.u.soc"
40
#define RISCV_U_SOC(obj) \
41
diff --git a/hw/riscv/sifive_u_prci.c b/hw/misc/sifive_u_prci.c
42
similarity index 99%
43
rename from hw/riscv/sifive_u_prci.c
44
rename to hw/misc/sifive_u_prci.c
45
index XXXXXXX..XXXXXXX 100644
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
--
106
2.28.0
107
108
diff view generated by jsdifflib
Deleted patch
1
From: Bin Meng <bin.meng@windriver.com>
2
1
3
This is an effort to clean up the hw/riscv directory. Ideally it
4
should only contain the RISC-V SoC / machine codes plus generic
5
codes. Let's move sifive_u_otp model to hw/misc directory.
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>
11
---
12
include/hw/{riscv => misc}/sifive_u_otp.h | 0
13
include/hw/riscv/sifive_u.h | 2 +-
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
23
diff --git a/include/hw/riscv/sifive_u_otp.h b/include/hw/misc/sifive_u_otp.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
29
--- a/include/hw/riscv/sifive_u.h
30
+++ b/include/hw/riscv/sifive_u.h
31
@@ -XXX,XX +XXX,XX @@
32
#include "hw/riscv/riscv_hart.h"
33
#include "hw/riscv/sifive_cpu.h"
34
#include "hw/riscv/sifive_gpio.h"
35
-#include "hw/riscv/sifive_u_otp.h"
36
+#include "hw/misc/sifive_u_otp.h"
37
#include "hw/misc/sifive_u_prci.h"
38
39
#define TYPE_RISCV_U_SOC "riscv.sifive.u.soc"
40
diff --git a/hw/riscv/sifive_u_otp.c b/hw/misc/sifive_u_otp.c
41
similarity index 99%
42
rename from hw/riscv/sifive_u_otp.c
43
rename to hw/misc/sifive_u_otp.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/hw/riscv/sifive_u_otp.c
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
--
107
2.28.0
108
109
diff view generated by jsdifflib