1
The following changes since commit 20c1df5476e1e9b5d3f5b94f9f3ce01d21f14c46:
1
From: Alistair Francis <alistair.francis@wdc.com>
2
2
3
Merge remote-tracking branch 'remotes/kraxel/tags/fixes-20200713-pull-request' into staging (2020-07-13 16:58:44 +0100)
3
The following changes since commit c5fbdd60cf1fb52f01bdfe342b6fa65d5343e1b1:
4
5
Merge tag 'qemu-sparc-20211121' of git://github.com/mcayland/qemu into staging (2021-11-21 14:12:25 +0100)
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-20200713
9
git@github.com:alistair23/qemu.git tags/pull-riscv-to-apply-20211122
8
10
9
for you to fetch changes up to cfad709bceb629a4ebeb5d8a3acd1871b9a6436b:
11
for you to fetch changes up to 526e7443027c71fe7b04c29df529e1f9f425f9e3:
10
12
11
target/riscv: Fix pmp NA4 implementation (2020-07-13 17:25:37 -0700)
13
hw/misc/sifive_u_otp: Do not reset OTP content on hardware reset (2021-11-22 10:46:22 +1000)
12
14
13
----------------------------------------------------------------
15
----------------------------------------------------------------
14
This is a colection of bug fixes and small imrprovements for RISC-V.
16
Seventh RISC-V PR for QEMU 6.2
15
17
16
This includes some vector extensions fixes, a PMP bug fix, OpenTitan
18
- Deprecate IF_NONE for SiFive OTP
17
UART bug fix and support for OpenSBI dynamic firmware.
19
- Don't reset SiFive OTP content
18
20
19
----------------------------------------------------------------
21
----------------------------------------------------------------
20
Alexandre Mergnat (1):
22
Philippe Mathieu-Daudé (1):
21
target/riscv: Fix pmp NA4 implementation
23
hw/misc/sifive_u_otp: Do not reset OTP content on hardware reset
22
24
23
Alistair Francis (2):
25
Thomas Huth (1):
24
hw/char: Convert the Ibex UART to use the qdev Clock model
26
hw/misc/sifive_u_otp: Use IF_PFLASH for the OTP device instead of IF_NONE
25
hw/char: Convert the Ibex UART to use the registerfields API
26
27
27
Atish Patra (4):
28
docs/about/deprecated.rst | 6 ++++++
28
riscv: Unify Qemu's reset vector code path
29
hw/misc/sifive_u_otp.c | 22 +++++++++++++---------
29
RISC-V: Copy the fdt in dram instead of ROM
30
2 files changed, 19 insertions(+), 9 deletions(-)
30
riscv: Add opensbi firmware dynamic support
31
RISC-V: Support 64 bit start address
32
31
33
Bin Meng (3):
34
MAINTAINERS: Add an entry for OpenSBI firmware
35
hw/riscv: virt: Sort the SoC memmap table entries
36
hw/riscv: Modify MROM size to end at 0x10000
37
38
Frank Chang (4):
39
target/riscv: fix rsub gvec tcg_assert_listed_vecop assertion
40
target/riscv: correct the gvec IR called in gen_vec_rsub16_i64()
41
target/riscv: fix return value of do_opivx_widen()
42
target/riscv: fix vill bit index in vtype register
43
44
Liao Pingfang (1):
45
tcg/riscv: Remove superfluous breaks
46
47
include/hw/char/ibex_uart.h | 79 ++++++++--------
48
include/hw/riscv/boot.h | 7 ++
49
include/hw/riscv/boot_opensbi.h | 58 ++++++++++++
50
target/riscv/cpu.h | 2 +-
51
hw/char/ibex_uart.c | 158 ++++++++++++++++++--------------
52
hw/riscv/boot.c | 107 +++++++++++++++++++++
53
hw/riscv/sifive_u.c | 53 ++++++-----
54
hw/riscv/spike.c | 59 ++++--------
55
hw/riscv/virt.c | 63 ++++---------
56
target/riscv/insn_trans/trans_rvv.inc.c | 9 +-
57
target/riscv/pmp.c | 2 +-
58
tcg/riscv/tcg-target.inc.c | 2 -
59
MAINTAINERS | 7 ++
60
13 files changed, 387 insertions(+), 219 deletions(-)
61
create mode 100644 include/hw/riscv/boot_opensbi.h
62
diff view generated by jsdifflib
Deleted patch
1
From: Bin Meng <bmeng.cn@gmail.com>
2
1
3
List me as the maintainer for OpenSBI firmware related files.
4
5
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
6
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Message-Id: <1593177220-28143-1-git-send-email-bmeng.cn@gmail.com>
8
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
9
---
10
MAINTAINERS | 7 +++++++
11
1 file changed, 7 insertions(+)
12
13
diff --git a/MAINTAINERS b/MAINTAINERS
14
index XXXXXXX..XXXXXXX 100644
15
--- a/MAINTAINERS
16
+++ b/MAINTAINERS
17
@@ -XXX,XX +XXX,XX @@ F: hw/i386/intel_iommu.c
18
F: hw/i386/intel_iommu_internal.h
19
F: include/hw/i386/intel_iommu.h
20
21
+OpenSBI Firmware
22
+M: Bin Meng <bmeng.cn@gmail.com>
23
+S: Supported
24
+F: pc-bios/opensbi-*
25
+F: .gitlab-ci.d/opensbi.yml
26
+F: .gitlab-ci.d/opensbi/
27
+
28
Usermode Emulation
29
------------------
30
Overall usermode emulation
31
--
32
2.27.0
33
34
diff view generated by jsdifflib
Deleted patch
1
From: Bin Meng <bin.meng@windriver.com>
2
1
3
Adjust the PCIe memory maps to follow the order.
4
5
Signed-off-by: Bin Meng <bin.meng@windriver.com>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Message-Id: <1593746511-19517-1-git-send-email-bmeng.cn@gmail.com>
8
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
9
---
10
hw/riscv/virt.c | 6 +++---
11
1 file changed, 3 insertions(+), 3 deletions(-)
12
13
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/riscv/virt.c
16
+++ b/hw/riscv/virt.c
17
@@ -XXX,XX +XXX,XX @@ static const struct MemmapEntry {
18
[VIRT_TEST] = { 0x100000, 0x1000 },
19
[VIRT_RTC] = { 0x101000, 0x1000 },
20
[VIRT_CLINT] = { 0x2000000, 0x10000 },
21
+ [VIRT_PCIE_PIO] = { 0x3000000, 0x10000 },
22
[VIRT_PLIC] = { 0xc000000, 0x4000000 },
23
[VIRT_UART0] = { 0x10000000, 0x100 },
24
[VIRT_VIRTIO] = { 0x10001000, 0x1000 },
25
[VIRT_FLASH] = { 0x20000000, 0x4000000 },
26
- [VIRT_DRAM] = { 0x80000000, 0x0 },
27
- [VIRT_PCIE_MMIO] = { 0x40000000, 0x40000000 },
28
- [VIRT_PCIE_PIO] = { 0x03000000, 0x00010000 },
29
[VIRT_PCIE_ECAM] = { 0x30000000, 0x10000000 },
30
+ [VIRT_PCIE_MMIO] = { 0x40000000, 0x40000000 },
31
+ [VIRT_DRAM] = { 0x80000000, 0x0 },
32
};
33
34
#define VIRT_FLASH_SECTOR_SIZE (256 * KiB)
35
--
36
2.27.0
37
38
diff view generated by jsdifflib
Deleted patch
1
From: Atish Patra <atish.patra@wdc.com>
2
1
3
Currently, all riscv machines except sifive_u have identical reset vector
4
code implementations with memory addresses being different for all machines.
5
They can be easily combined into a single function in common code.
6
7
Move it to common function and let all the machines use the common function.
8
9
Signed-off-by: Atish Patra <atish.patra@wdc.com>
10
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
11
Reviewed-by: Bin Meng <bin.meng@windriver.com>
12
Tested-by: Bin Meng <bin.meng@windriver.com>
13
Message-Id: <20200701183949.398134-2-atish.patra@wdc.com>
14
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
15
---
16
include/hw/riscv/boot.h | 2 ++
17
hw/riscv/boot.c | 46 +++++++++++++++++++++++++++++++++++++++++
18
hw/riscv/sifive_u.c | 1 -
19
hw/riscv/spike.c | 41 +++---------------------------------
20
hw/riscv/virt.c | 40 +++--------------------------------
21
5 files changed, 54 insertions(+), 76 deletions(-)
22
23
diff --git a/include/hw/riscv/boot.h b/include/hw/riscv/boot.h
24
index XXXXXXX..XXXXXXX 100644
25
--- a/include/hw/riscv/boot.h
26
+++ b/include/hw/riscv/boot.h
27
@@ -XXX,XX +XXX,XX @@ target_ulong riscv_load_kernel(const char *kernel_filename,
28
symbol_fn_t sym_cb);
29
hwaddr riscv_load_initrd(const char *filename, uint64_t mem_size,
30
uint64_t kernel_entry, hwaddr *start);
31
+void riscv_setup_rom_reset_vec(hwaddr saddr, hwaddr rom_base,
32
+ hwaddr rom_size, void *fdt);
33
34
#endif /* RISCV_BOOT_H */
35
diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c
36
index XXXXXXX..XXXXXXX 100644
37
--- a/hw/riscv/boot.c
38
+++ b/hw/riscv/boot.c
39
@@ -XXX,XX +XXX,XX @@
40
#include "hw/loader.h"
41
#include "hw/riscv/boot.h"
42
#include "elf.h"
43
+#include "sysemu/device_tree.h"
44
#include "sysemu/qtest.h"
45
46
+#include <libfdt.h>
47
+
48
#if defined(TARGET_RISCV32)
49
# define KERNEL_BOOT_ADDRESS 0x80400000
50
#else
51
@@ -XXX,XX +XXX,XX @@ hwaddr riscv_load_initrd(const char *filename, uint64_t mem_size,
52
53
return *start + size;
54
}
55
+
56
+void riscv_setup_rom_reset_vec(hwaddr start_addr, hwaddr rom_base,
57
+ hwaddr rom_size, void *fdt)
58
+{
59
+ int i;
60
+
61
+ /* reset vector */
62
+ uint32_t reset_vec[8] = {
63
+ 0x00000297, /* 1: auipc t0, %pcrel_hi(dtb) */
64
+ 0x02028593, /* addi a1, t0, %pcrel_lo(1b) */
65
+ 0xf1402573, /* csrr a0, mhartid */
66
+#if defined(TARGET_RISCV32)
67
+ 0x0182a283, /* lw t0, 24(t0) */
68
+#elif defined(TARGET_RISCV64)
69
+ 0x0182b283, /* ld t0, 24(t0) */
70
+#endif
71
+ 0x00028067, /* jr t0 */
72
+ 0x00000000,
73
+ start_addr, /* start: .dword */
74
+ 0x00000000,
75
+ /* dtb: */
76
+ };
77
+
78
+ /* copy in the reset vector in little_endian byte order */
79
+ for (i = 0; i < sizeof(reset_vec) >> 2; i++) {
80
+ reset_vec[i] = cpu_to_le32(reset_vec[i]);
81
+ }
82
+ rom_add_blob_fixed_as("mrom.reset", reset_vec, sizeof(reset_vec),
83
+ rom_base, &address_space_memory);
84
+
85
+ /* copy in the device tree */
86
+ if (fdt_pack(fdt) || fdt_totalsize(fdt) >
87
+ rom_size - sizeof(reset_vec)) {
88
+ error_report("not enough space to store device-tree");
89
+ exit(1);
90
+ }
91
+ qemu_fdt_dumpdtb(fdt, fdt_totalsize(fdt));
92
+ rom_add_blob_fixed_as("mrom.fdt", fdt, fdt_totalsize(fdt),
93
+ rom_base + sizeof(reset_vec),
94
+ &address_space_memory);
95
+
96
+ return;
97
+}
98
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
99
index XXXXXXX..XXXXXXX 100644
100
--- a/hw/riscv/sifive_u.c
101
+++ b/hw/riscv/sifive_u.c
102
@@ -XXX,XX +XXX,XX @@
103
#include "sysemu/device_tree.h"
104
#include "sysemu/runstate.h"
105
#include "sysemu/sysemu.h"
106
-#include "exec/address-spaces.h"
107
108
#include <libfdt.h>
109
110
diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c
111
index XXXXXXX..XXXXXXX 100644
112
--- a/hw/riscv/spike.c
113
+++ b/hw/riscv/spike.c
114
@@ -XXX,XX +XXX,XX @@
115
#include "sysemu/device_tree.h"
116
#include "sysemu/qtest.h"
117
#include "sysemu/sysemu.h"
118
-#include "exec/address-spaces.h"
119
-
120
-#include <libfdt.h>
121
122
#if defined(TARGET_RISCV32)
123
# define BIOS_FILENAME "opensbi-riscv32-spike-fw_jump.elf"
124
@@ -XXX,XX +XXX,XX @@ static void spike_board_init(MachineState *machine)
125
MemoryRegion *system_memory = get_system_memory();
126
MemoryRegion *main_mem = g_new(MemoryRegion, 1);
127
MemoryRegion *mask_rom = g_new(MemoryRegion, 1);
128
- int i;
129
unsigned int smp_cpus = machine->smp.cpus;
130
131
/* Initialize SOC */
132
@@ -XXX,XX +XXX,XX @@ static void spike_board_init(MachineState *machine)
133
}
134
}
135
136
- /* reset vector */
137
- uint32_t reset_vec[8] = {
138
- 0x00000297, /* 1: auipc t0, %pcrel_hi(dtb) */
139
- 0x02028593, /* addi a1, t0, %pcrel_lo(1b) */
140
- 0xf1402573, /* csrr a0, mhartid */
141
-#if defined(TARGET_RISCV32)
142
- 0x0182a283, /* lw t0, 24(t0) */
143
-#elif defined(TARGET_RISCV64)
144
- 0x0182b283, /* ld t0, 24(t0) */
145
-#endif
146
- 0x00028067, /* jr t0 */
147
- 0x00000000,
148
- memmap[SPIKE_DRAM].base, /* start: .dword DRAM_BASE */
149
- 0x00000000,
150
- /* dtb: */
151
- };
152
-
153
- /* copy in the reset vector in little_endian byte order */
154
- for (i = 0; i < sizeof(reset_vec) >> 2; i++) {
155
- reset_vec[i] = cpu_to_le32(reset_vec[i]);
156
- }
157
- rom_add_blob_fixed_as("mrom.reset", reset_vec, sizeof(reset_vec),
158
- memmap[SPIKE_MROM].base, &address_space_memory);
159
-
160
- /* copy in the device tree */
161
- if (fdt_pack(s->fdt) || fdt_totalsize(s->fdt) >
162
- memmap[SPIKE_MROM].size - sizeof(reset_vec)) {
163
- error_report("not enough space to store device-tree");
164
- exit(1);
165
- }
166
- qemu_fdt_dumpdtb(s->fdt, fdt_totalsize(s->fdt));
167
- rom_add_blob_fixed_as("mrom.fdt", s->fdt, fdt_totalsize(s->fdt),
168
- memmap[SPIKE_MROM].base + sizeof(reset_vec),
169
- &address_space_memory);
170
+ /* load the reset vector */
171
+ riscv_setup_rom_reset_vec(memmap[SPIKE_DRAM].base, memmap[SPIKE_MROM].base,
172
+ memmap[SPIKE_MROM].size, s->fdt);
173
174
/* initialize HTIF using symbols found in load_kernel */
175
htif_mm_init(system_memory, mask_rom, &s->soc.harts[0].env, serial_hd(0));
176
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
177
index XXXXXXX..XXXXXXX 100644
178
--- a/hw/riscv/virt.c
179
+++ b/hw/riscv/virt.c
180
@@ -XXX,XX +XXX,XX @@
181
#include "sysemu/arch_init.h"
182
#include "sysemu/device_tree.h"
183
#include "sysemu/sysemu.h"
184
-#include "exec/address-spaces.h"
185
#include "hw/pci/pci.h"
186
#include "hw/pci-host/gpex.h"
187
188
-#include <libfdt.h>
189
-
190
#if defined(TARGET_RISCV32)
191
# define BIOS_FILENAME "opensbi-riscv32-virt-fw_jump.bin"
192
#else
193
@@ -XXX,XX +XXX,XX @@ static void virt_machine_init(MachineState *machine)
194
start_addr = virt_memmap[VIRT_FLASH].base;
195
}
196
197
- /* reset vector */
198
- uint32_t reset_vec[8] = {
199
- 0x00000297, /* 1: auipc t0, %pcrel_hi(dtb) */
200
- 0x02028593, /* addi a1, t0, %pcrel_lo(1b) */
201
- 0xf1402573, /* csrr a0, mhartid */
202
-#if defined(TARGET_RISCV32)
203
- 0x0182a283, /* lw t0, 24(t0) */
204
-#elif defined(TARGET_RISCV64)
205
- 0x0182b283, /* ld t0, 24(t0) */
206
-#endif
207
- 0x00028067, /* jr t0 */
208
- 0x00000000,
209
- start_addr, /* start: .dword */
210
- 0x00000000,
211
- /* dtb: */
212
- };
213
-
214
- /* copy in the reset vector in little_endian byte order */
215
- for (i = 0; i < sizeof(reset_vec) >> 2; i++) {
216
- reset_vec[i] = cpu_to_le32(reset_vec[i]);
217
- }
218
- rom_add_blob_fixed_as("mrom.reset", reset_vec, sizeof(reset_vec),
219
- memmap[VIRT_MROM].base, &address_space_memory);
220
-
221
- /* copy in the device tree */
222
- if (fdt_pack(s->fdt) || fdt_totalsize(s->fdt) >
223
- memmap[VIRT_MROM].size - sizeof(reset_vec)) {
224
- error_report("not enough space to store device-tree");
225
- exit(1);
226
- }
227
- qemu_fdt_dumpdtb(s->fdt, fdt_totalsize(s->fdt));
228
- rom_add_blob_fixed_as("mrom.fdt", s->fdt, fdt_totalsize(s->fdt),
229
- memmap[VIRT_MROM].base + sizeof(reset_vec),
230
- &address_space_memory);
231
+ /* load the reset vector */
232
+ riscv_setup_rom_reset_vec(start_addr, virt_memmap[VIRT_MROM].base,
233
+ virt_memmap[VIRT_MROM].size, s->fdt);
234
235
/* create PLIC hart topology configuration string */
236
plic_hart_config_len = (strlen(VIRT_PLIC_HART_CONFIG) + 1) * smp_cpus;
237
--
238
2.27.0
239
240
diff view generated by jsdifflib
1
From: Alexandre Mergnat <amergnat@baylibre.com>
1
From: Thomas Huth <thuth@redhat.com>
2
2
3
The end address calculation for NA4 mode is wrong because the address
3
Configuring a drive with "if=none" is meant for creation of a backend
4
used isn't shifted.
4
only, it should not get automatically assigned to a device frontend.
5
Use "if=pflash" for the One-Time-Programmable device instead (like
6
it is e.g. also done for the efuse device in hw/arm/xlnx-zcu102.c).
5
7
6
It doesn't watch 4 bytes but a huge range because the end address
8
Since the old way of configuring the device has already been published
7
calculation is wrong.
9
with the previous QEMU versions, we cannot remove this immediately, but
10
have to deprecate it and support it for at least two more releases.
8
11
9
The solution is to use the shifted address calculated for start address
12
Signed-off-by: Thomas Huth <thuth@redhat.com>
10
variable.
13
Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
14
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12
Modifications are tested on Zephyr OS userspace test suite which works
13
for other RISC-V boards (E31 and E34 core).
14
15
Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
16
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
15
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
17
Message-id: 20200706084550.24117-1-amergnat@baylibre.com
16
Message-id: 20211119102549.217755-1-thuth@redhat.com
18
Message-Id: <20200706084550.24117-1-amergnat@baylibre.com>
19
[ Changes by AF:
20
- Improve the commit title and message
21
]
22
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
17
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
23
---
18
---
24
target/riscv/pmp.c | 2 +-
19
docs/about/deprecated.rst | 6 ++++++
25
1 file changed, 1 insertion(+), 1 deletion(-)
20
hw/misc/sifive_u_otp.c | 9 ++++++++-
21
2 files changed, 14 insertions(+), 1 deletion(-)
26
22
27
diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c
23
diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
28
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
29
--- a/target/riscv/pmp.c
25
--- a/docs/about/deprecated.rst
30
+++ b/target/riscv/pmp.c
26
+++ b/docs/about/deprecated.rst
31
@@ -XXX,XX +XXX,XX @@ static void pmp_update_rule(CPURISCVState *env, uint32_t pmp_index)
27
@@ -XXX,XX +XXX,XX @@ as short-form boolean values, and passed to plugins as ``arg_name=on``.
32
28
However, short-form booleans are deprecated and full explicit ``arg_name=on``
33
case PMP_AMATCH_NA4:
29
form is preferred.
34
sa = this_addr << 2; /* shift up from [xx:0] to [xx+2:2] */
30
35
- ea = (this_addr + 4u) - 1u;
31
+``-drive if=none`` for the sifive_u OTP device (since 6.2)
36
+ ea = (sa + 4u) - 1u;
32
+''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
37
break;
33
+
38
34
+Using ``-drive if=none`` to configure the OTP device of the sifive_u
39
case PMP_AMATCH_NAPOT:
35
+RISC-V machine is deprecated. Use ``-drive if=pflash`` instead.
36
+
37
38
QEMU Machine Protocol (QMP) commands
39
------------------------------------
40
diff --git a/hw/misc/sifive_u_otp.c b/hw/misc/sifive_u_otp.c
41
index XXXXXXX..XXXXXXX 100644
42
--- a/hw/misc/sifive_u_otp.c
43
+++ b/hw/misc/sifive_u_otp.c
44
@@ -XXX,XX +XXX,XX @@ static void sifive_u_otp_realize(DeviceState *dev, Error **errp)
45
TYPE_SIFIVE_U_OTP, SIFIVE_U_OTP_REG_SIZE);
46
sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mmio);
47
48
- dinfo = drive_get_next(IF_NONE);
49
+ dinfo = drive_get_next(IF_PFLASH);
50
+ if (!dinfo) {
51
+ dinfo = drive_get_next(IF_NONE);
52
+ if (dinfo) {
53
+ warn_report("using \"-drive if=none\" for the OTP is deprecated, "
54
+ "use \"-drive if=pflash\" instead.");
55
+ }
56
+ }
57
if (dinfo) {
58
int ret;
59
uint64_t perm;
40
--
60
--
41
2.27.0
61
2.31.1
42
62
43
63
diff view generated by jsdifflib
1
From: Atish Patra <atish.patra@wdc.com>
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
Currently, the fdt is copied to the ROM after the reset vector. The firmware
3
Once a "One Time Programmable" is programmed, it shouldn't be reset.
4
has to copy it to DRAM. Instead of this, directly copy the device tree to a
5
pre-computed dram address. The device tree load address should be as far as
6
possible from kernel and initrd images. That's why it is kept at the end of
7
the DRAM or 4GB whichever is lesser.
8
4
9
Signed-off-by: Atish Patra <atish.patra@wdc.com>
5
Do not re-initialize the OTP content in the DeviceReset handler,
6
initialize it once in the DeviceRealize one.
7
8
Fixes: 9fb45c62ae8 ("riscv: sifive: Implement a model for SiFive FU540 OTP")
9
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
11
Reviewed-by: Bin Meng <bin.meng@windriver.com>
11
Message-Id: <20211119104757.331579-1-f4bug@amsat.org>
12
Tested-by: Bin Meng <bin.meng@windriver.com>
13
Message-Id: <20200701183949.398134-3-atish.patra@wdc.com>
14
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
12
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
15
---
13
---
16
include/hw/riscv/boot.h | 4 +++-
14
hw/misc/sifive_u_otp.c | 13 +++++--------
17
hw/riscv/boot.c | 53 +++++++++++++++++++++++++++++------------
15
1 file changed, 5 insertions(+), 8 deletions(-)
18
hw/riscv/sifive_u.c | 28 ++++++++++------------
19
hw/riscv/spike.c | 7 +++++-
20
hw/riscv/virt.c | 7 +++++-
21
5 files changed, 66 insertions(+), 33 deletions(-)
22
16
23
diff --git a/include/hw/riscv/boot.h b/include/hw/riscv/boot.h
17
diff --git a/hw/misc/sifive_u_otp.c b/hw/misc/sifive_u_otp.c
24
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
25
--- a/include/hw/riscv/boot.h
19
--- a/hw/misc/sifive_u_otp.c
26
+++ b/include/hw/riscv/boot.h
20
+++ b/hw/misc/sifive_u_otp.c
27
@@ -XXX,XX +XXX,XX @@ target_ulong riscv_load_kernel(const char *kernel_filename,
21
@@ -XXX,XX +XXX,XX @@ static void sifive_u_otp_realize(DeviceState *dev, Error **errp)
28
symbol_fn_t sym_cb);
22
29
hwaddr riscv_load_initrd(const char *filename, uint64_t mem_size,
23
if (blk_pread(s->blk, 0, s->fuse, filesize) != filesize) {
30
uint64_t kernel_entry, hwaddr *start);
24
error_setg(errp, "failed to read the initial flash content");
31
+uint32_t riscv_load_fdt(hwaddr dram_start, uint64_t dram_size, void *fdt);
25
+ return;
32
void riscv_setup_rom_reset_vec(hwaddr saddr, hwaddr rom_base,
26
}
33
- hwaddr rom_size, void *fdt);
34
+ hwaddr rom_size,
35
+ uint32_t fdt_load_addr, void *fdt);
36
37
#endif /* RISCV_BOOT_H */
38
diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c
39
index XXXXXXX..XXXXXXX 100644
40
--- a/hw/riscv/boot.c
41
+++ b/hw/riscv/boot.c
42
@@ -XXX,XX +XXX,XX @@ hwaddr riscv_load_initrd(const char *filename, uint64_t mem_size,
43
return *start + size;
44
}
45
46
+uint32_t riscv_load_fdt(hwaddr dram_base, uint64_t mem_size, void *fdt)
47
+{
48
+ uint32_t temp, fdt_addr;
49
+ hwaddr dram_end = dram_base + mem_size;
50
+ int fdtsize = fdt_totalsize(fdt);
51
+
52
+ if (fdtsize <= 0) {
53
+ error_report("invalid device-tree");
54
+ exit(1);
55
+ }
56
+
57
+ /*
58
+ * We should put fdt as far as possible to avoid kernel/initrd overwriting
59
+ * its content. But it should be addressable by 32 bit system as well.
60
+ * Thus, put it at an aligned address that less than fdt size from end of
61
+ * dram or 4GB whichever is lesser.
62
+ */
63
+ temp = MIN(dram_end, 4096 * MiB);
64
+ fdt_addr = QEMU_ALIGN_DOWN(temp - fdtsize, 2 * MiB);
65
+
66
+ fdt_pack(fdt);
67
+ /* copy in the device tree */
68
+ qemu_fdt_dumpdtb(fdt, fdtsize);
69
+
70
+ rom_add_blob_fixed_as("fdt", fdt, fdtsize, fdt_addr,
71
+ &address_space_memory);
72
+
73
+ return fdt_addr;
74
+}
75
+
76
void riscv_setup_rom_reset_vec(hwaddr start_addr, hwaddr rom_base,
77
- hwaddr rom_size, void *fdt)
78
+ hwaddr rom_size,
79
+ uint32_t fdt_load_addr, void *fdt)
80
{
81
int i;
82
83
/* reset vector */
84
- uint32_t reset_vec[8] = {
85
+ uint32_t reset_vec[10] = {
86
0x00000297, /* 1: auipc t0, %pcrel_hi(dtb) */
87
- 0x02028593, /* addi a1, t0, %pcrel_lo(1b) */
88
0xf1402573, /* csrr a0, mhartid */
89
#if defined(TARGET_RISCV32)
90
+ 0x0202a583, /* lw a1, 32(t0) */
91
0x0182a283, /* lw t0, 24(t0) */
92
#elif defined(TARGET_RISCV64)
93
+ 0x0202b583, /* ld a1, 32(t0) */
94
0x0182b283, /* ld t0, 24(t0) */
95
#endif
96
0x00028067, /* jr t0 */
97
0x00000000,
98
start_addr, /* start: .dword */
99
+ 0x00000000,
100
+ fdt_load_addr, /* fdt_laddr: .dword */
101
0x00000000,
102
/* dtb: */
103
};
104
105
/* copy in the reset vector in little_endian byte order */
106
- for (i = 0; i < sizeof(reset_vec) >> 2; i++) {
107
+ for (i = 0; i < ARRAY_SIZE(reset_vec); i++) {
108
reset_vec[i] = cpu_to_le32(reset_vec[i]);
109
}
110
rom_add_blob_fixed_as("mrom.reset", reset_vec, sizeof(reset_vec),
111
rom_base, &address_space_memory);
112
113
- /* copy in the device tree */
114
- if (fdt_pack(fdt) || fdt_totalsize(fdt) >
115
- rom_size - sizeof(reset_vec)) {
116
- error_report("not enough space to store device-tree");
117
- exit(1);
118
- }
119
- qemu_fdt_dumpdtb(fdt, fdt_totalsize(fdt));
120
- rom_add_blob_fixed_as("mrom.fdt", fdt, fdt_totalsize(fdt),
121
- rom_base + sizeof(reset_vec),
122
- &address_space_memory);
123
-
124
return;
125
}
126
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
127
index XXXXXXX..XXXXXXX 100644
128
--- a/hw/riscv/sifive_u.c
129
+++ b/hw/riscv/sifive_u.c
130
@@ -XXX,XX +XXX,XX @@ static void sifive_u_machine_init(MachineState *machine)
131
MemoryRegion *flash0 = g_new(MemoryRegion, 1);
132
target_ulong start_addr = memmap[SIFIVE_U_DRAM].base;
133
int i;
134
+ uint32_t fdt_load_addr;
135
136
/* Initialize SoC */
137
object_initialize_child(OBJECT(machine), "soc", &s->soc, TYPE_RISCV_U_SOC);
138
@@ -XXX,XX +XXX,XX @@ static void sifive_u_machine_init(MachineState *machine)
139
}
27
}
140
}
28
}
141
29
-}
142
+ /* Compute the fdt load address in dram */
143
+ fdt_load_addr = riscv_load_fdt(memmap[SIFIVE_U_DRAM].base,
144
+ machine->ram_size, s->fdt);
145
+
146
/* reset vector */
147
- uint32_t reset_vec[8] = {
148
+ uint32_t reset_vec[11] = {
149
s->msel, /* MSEL pin state */
150
0x00000297, /* 1: auipc t0, %pcrel_hi(dtb) */
151
- 0x01c28593, /* addi a1, t0, %pcrel_lo(1b) */
152
0xf1402573, /* csrr a0, mhartid */
153
#if defined(TARGET_RISCV32)
154
+ 0x0202a583, /* lw a1, 32(t0) */
155
0x0182a283, /* lw t0, 24(t0) */
156
#elif defined(TARGET_RISCV64)
157
- 0x0182e283, /* lwu t0, 24(t0) */
158
+ 0x0202b583, /* ld a1, 32(t0) */
159
+ 0x0182b283, /* ld t0, 24(t0) */
160
#endif
161
0x00028067, /* jr t0 */
162
0x00000000,
163
start_addr, /* start: .dword */
164
+ 0x00000000,
165
+ fdt_load_addr, /* fdt_laddr: .dword */
166
+ 0x00000000,
167
/* dtb: */
168
};
169
170
/* copy in the reset vector in little_endian byte order */
171
- for (i = 0; i < sizeof(reset_vec) >> 2; i++) {
172
+ for (i = 0; i < ARRAY_SIZE(reset_vec); i++) {
173
reset_vec[i] = cpu_to_le32(reset_vec[i]);
174
}
175
rom_add_blob_fixed_as("mrom.reset", reset_vec, sizeof(reset_vec),
176
memmap[SIFIVE_U_MROM].base, &address_space_memory);
177
-
30
-
178
- /* copy in the device tree */
31
-static void sifive_u_otp_reset(DeviceState *dev)
179
- if (fdt_pack(s->fdt) || fdt_totalsize(s->fdt) >
32
-{
180
- memmap[SIFIVE_U_MROM].size - sizeof(reset_vec)) {
33
- SiFiveUOTPState *s = SIFIVE_U_OTP(dev);
181
- error_report("not enough space to store device-tree");
34
182
- exit(1);
35
/* Initialize all fuses' initial value to 0xFFs */
183
- }
36
memset(s->fuse, 0xff, sizeof(s->fuse));
184
- qemu_fdt_dumpdtb(s->fdt, fdt_totalsize(s->fdt));
37
@@ -XXX,XX +XXX,XX @@ static void sifive_u_otp_reset(DeviceState *dev)
185
- rom_add_blob_fixed_as("mrom.fdt", s->fdt, fdt_totalsize(s->fdt),
38
serial_data = s->serial;
186
- memmap[SIFIVE_U_MROM].base + sizeof(reset_vec),
39
if (blk_pwrite(s->blk, index * SIFIVE_U_OTP_FUSE_WORD,
187
- &address_space_memory);
40
&serial_data, SIFIVE_U_OTP_FUSE_WORD, 0) < 0) {
188
}
41
- error_report("write error index<%d>", index);
189
42
+ error_setg(errp, "failed to write index<%d>", index);
190
static bool sifive_u_machine_get_start_in_flash(Object *obj, Error **errp)
43
+ return;
191
diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c
44
}
192
index XXXXXXX..XXXXXXX 100644
45
193
--- a/hw/riscv/spike.c
46
serial_data = ~(s->serial);
194
+++ b/hw/riscv/spike.c
47
if (blk_pwrite(s->blk, (index + 1) * SIFIVE_U_OTP_FUSE_WORD,
195
@@ -XXX,XX +XXX,XX @@ static void spike_board_init(MachineState *machine)
48
&serial_data, SIFIVE_U_OTP_FUSE_WORD, 0) < 0) {
196
MemoryRegion *main_mem = g_new(MemoryRegion, 1);
49
- error_report("write error index<%d>", index + 1);
197
MemoryRegion *mask_rom = g_new(MemoryRegion, 1);
50
+ error_setg(errp, "failed to write index<%d>", index + 1);
198
unsigned int smp_cpus = machine->smp.cpus;
51
+ return;
199
+ uint32_t fdt_load_addr;
200
201
/* Initialize SOC */
202
object_initialize_child(OBJECT(machine), "soc", &s->soc,
203
@@ -XXX,XX +XXX,XX @@ static void spike_board_init(MachineState *machine)
204
}
52
}
205
}
53
}
206
54
207
+ /* Compute the fdt load address in dram */
55
@@ -XXX,XX +XXX,XX @@ static void sifive_u_otp_class_init(ObjectClass *klass, void *data)
208
+ fdt_load_addr = riscv_load_fdt(memmap[SPIKE_DRAM].base,
56
209
+ machine->ram_size, s->fdt);
57
device_class_set_props(dc, sifive_u_otp_properties);
210
/* load the reset vector */
58
dc->realize = sifive_u_otp_realize;
211
riscv_setup_rom_reset_vec(memmap[SPIKE_DRAM].base, memmap[SPIKE_MROM].base,
59
- dc->reset = sifive_u_otp_reset;
212
- memmap[SPIKE_MROM].size, s->fdt);
60
}
213
+ memmap[SPIKE_MROM].size,
61
214
+ fdt_load_addr, s->fdt);
62
static const TypeInfo sifive_u_otp_info = {
215
216
/* initialize HTIF using symbols found in load_kernel */
217
htif_mm_init(system_memory, mask_rom, &s->soc.harts[0].env, serial_hd(0));
218
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
219
index XXXXXXX..XXXXXXX 100644
220
--- a/hw/riscv/virt.c
221
+++ b/hw/riscv/virt.c
222
@@ -XXX,XX +XXX,XX @@ static void virt_machine_init(MachineState *machine)
223
char *plic_hart_config;
224
size_t plic_hart_config_len;
225
target_ulong start_addr = memmap[VIRT_DRAM].base;
226
+ uint32_t fdt_load_addr;
227
int i;
228
unsigned int smp_cpus = machine->smp.cpus;
229
230
@@ -XXX,XX +XXX,XX @@ static void virt_machine_init(MachineState *machine)
231
start_addr = virt_memmap[VIRT_FLASH].base;
232
}
233
234
+ /* Compute the fdt load address in dram */
235
+ fdt_load_addr = riscv_load_fdt(memmap[VIRT_DRAM].base,
236
+ machine->ram_size, s->fdt);
237
/* load the reset vector */
238
riscv_setup_rom_reset_vec(start_addr, virt_memmap[VIRT_MROM].base,
239
- virt_memmap[VIRT_MROM].size, s->fdt);
240
+ virt_memmap[VIRT_MROM].size,
241
+ fdt_load_addr, s->fdt);
242
243
/* create PLIC hart topology configuration string */
244
plic_hart_config_len = (strlen(VIRT_PLIC_HART_CONFIG) + 1) * smp_cpus;
245
--
63
--
246
2.27.0
64
2.31.1
247
65
248
66
diff view generated by jsdifflib
Deleted patch
1
From: Atish Patra <atish.patra@wdc.com>
2
1
3
OpenSBI is the default firmware in Qemu and has various firmware loading
4
options. Currently, qemu loader uses fw_jump which has a compile time
5
pre-defined address where fdt & kernel image must reside. This puts a
6
constraint on image size of the Linux kernel depending on the fdt location
7
and available memory. However, fw_dynamic allows the loader to specify
8
the next stage location (i.e. Linux kernel/U-Boot) in memory and other
9
configurable boot options available in OpenSBI.
10
11
Add support for OpenSBI dynamic firmware loading support. This doesn't
12
break existing setup and fw_jump will continue to work as it is. Any
13
other firmware will continue to work without any issues as long as it
14
doesn't expect anything specific from loader in "a2" register.
15
16
Signed-off-by: Atish Patra <atish.patra@wdc.com>
17
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
18
Reviewed-by: Bin Meng <bin.meng@windriver.com>
19
Tested-by: Bin Meng <bin.meng@windriver.com>
20
Message-Id: <20200701183949.398134-4-atish.patra@wdc.com>
21
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
22
---
23
include/hw/riscv/boot.h | 5 ++-
24
include/hw/riscv/boot_opensbi.h | 58 +++++++++++++++++++++++++++++++++
25
hw/riscv/boot.c | 42 +++++++++++++++++++++---
26
hw/riscv/sifive_u.c | 20 +++++++++---
27
hw/riscv/spike.c | 13 ++++++--
28
hw/riscv/virt.c | 12 +++++--
29
6 files changed, 134 insertions(+), 16 deletions(-)
30
create mode 100644 include/hw/riscv/boot_opensbi.h
31
32
diff --git a/include/hw/riscv/boot.h b/include/hw/riscv/boot.h
33
index XXXXXXX..XXXXXXX 100644
34
--- a/include/hw/riscv/boot.h
35
+++ b/include/hw/riscv/boot.h
36
@@ -XXX,XX +XXX,XX @@ hwaddr riscv_load_initrd(const char *filename, uint64_t mem_size,
37
uint64_t kernel_entry, hwaddr *start);
38
uint32_t riscv_load_fdt(hwaddr dram_start, uint64_t dram_size, void *fdt);
39
void riscv_setup_rom_reset_vec(hwaddr saddr, hwaddr rom_base,
40
- hwaddr rom_size,
41
+ hwaddr rom_size, uint64_t kernel_entry,
42
uint32_t fdt_load_addr, void *fdt);
43
+void riscv_rom_copy_firmware_info(hwaddr rom_base, hwaddr rom_size,
44
+ uint32_t reset_vec_size,
45
+ uint64_t kernel_entry);
46
47
#endif /* RISCV_BOOT_H */
48
diff --git a/include/hw/riscv/boot_opensbi.h b/include/hw/riscv/boot_opensbi.h
49
new file mode 100644
50
index XXXXXXX..XXXXXXX
51
--- /dev/null
52
+++ b/include/hw/riscv/boot_opensbi.h
53
@@ -XXX,XX +XXX,XX @@
54
+/* SPDX-License-Identifier: BSD-2-Clause */
55
+/*
56
+ * Copyright (c) 2019 Western Digital Corporation or its affiliates.
57
+ *
58
+ * Based on include/sbi/{fw_dynamic.h,sbi_scratch.h} from the OpenSBI project.
59
+ */
60
+#ifndef OPENSBI_H
61
+#define OPENSBI_H
62
+
63
+/** Expected value of info magic ('OSBI' ascii string in hex) */
64
+#define FW_DYNAMIC_INFO_MAGIC_VALUE 0x4942534f
65
+
66
+/** Maximum supported info version */
67
+#define FW_DYNAMIC_INFO_VERSION 0x2
68
+
69
+/** Possible next mode values */
70
+#define FW_DYNAMIC_INFO_NEXT_MODE_U 0x0
71
+#define FW_DYNAMIC_INFO_NEXT_MODE_S 0x1
72
+#define FW_DYNAMIC_INFO_NEXT_MODE_M 0x3
73
+
74
+enum sbi_scratch_options {
75
+ /** Disable prints during boot */
76
+ SBI_SCRATCH_NO_BOOT_PRINTS = (1 << 0),
77
+ /** Enable runtime debug prints */
78
+ SBI_SCRATCH_DEBUG_PRINTS = (1 << 1),
79
+};
80
+
81
+/** Representation dynamic info passed by previous booting stage */
82
+struct fw_dynamic_info {
83
+ /** Info magic */
84
+ target_long magic;
85
+ /** Info version */
86
+ target_long version;
87
+ /** Next booting stage address */
88
+ target_long next_addr;
89
+ /** Next booting stage mode */
90
+ target_long next_mode;
91
+ /** Options for OpenSBI library */
92
+ target_long options;
93
+ /**
94
+ * Preferred boot HART id
95
+ *
96
+ * It is possible that the previous booting stage uses same link
97
+ * address as the FW_DYNAMIC firmware. In this case, the relocation
98
+ * lottery mechanism can potentially overwrite the previous booting
99
+ * stage while other HARTs are still running in the previous booting
100
+ * stage leading to boot-time crash. To avoid this boot-time crash,
101
+ * the previous booting stage can specify last HART that will jump
102
+ * to the FW_DYNAMIC firmware as the preferred boot HART.
103
+ *
104
+ * To avoid specifying a preferred boot HART, the previous booting
105
+ * stage can set it to -1UL which will force the FW_DYNAMIC firmware
106
+ * to use the relocation lottery mechanism.
107
+ */
108
+ target_long boot_hart;
109
+};
110
+
111
+#endif
112
diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c
113
index XXXXXXX..XXXXXXX 100644
114
--- a/hw/riscv/boot.c
115
+++ b/hw/riscv/boot.c
116
@@ -XXX,XX +XXX,XX @@
117
#include "hw/boards.h"
118
#include "hw/loader.h"
119
#include "hw/riscv/boot.h"
120
+#include "hw/riscv/boot_opensbi.h"
121
#include "elf.h"
122
#include "sysemu/device_tree.h"
123
#include "sysemu/qtest.h"
124
@@ -XXX,XX +XXX,XX @@
125
126
#if defined(TARGET_RISCV32)
127
# define KERNEL_BOOT_ADDRESS 0x80400000
128
+#define fw_dynamic_info_data(__val) cpu_to_le32(__val)
129
#else
130
# define KERNEL_BOOT_ADDRESS 0x80200000
131
+#define fw_dynamic_info_data(__val) cpu_to_le64(__val)
132
#endif
133
134
void riscv_find_and_load_firmware(MachineState *machine,
135
@@ -XXX,XX +XXX,XX @@ uint32_t riscv_load_fdt(hwaddr dram_base, uint64_t mem_size, void *fdt)
136
return fdt_addr;
137
}
138
139
+void riscv_rom_copy_firmware_info(hwaddr rom_base, hwaddr rom_size,
140
+ uint32_t reset_vec_size, uint64_t kernel_entry)
141
+{
142
+ struct fw_dynamic_info dinfo;
143
+ size_t dinfo_len;
144
+
145
+ dinfo.magic = fw_dynamic_info_data(FW_DYNAMIC_INFO_MAGIC_VALUE);
146
+ dinfo.version = fw_dynamic_info_data(FW_DYNAMIC_INFO_VERSION);
147
+ dinfo.next_mode = fw_dynamic_info_data(FW_DYNAMIC_INFO_NEXT_MODE_S);
148
+ dinfo.next_addr = fw_dynamic_info_data(kernel_entry);
149
+ dinfo.options = 0;
150
+ dinfo.boot_hart = 0;
151
+ dinfo_len = sizeof(dinfo);
152
+
153
+ /**
154
+ * copy the dynamic firmware info. This information is specific to
155
+ * OpenSBI but doesn't break any other firmware as long as they don't
156
+ * expect any certain value in "a2" register.
157
+ */
158
+ if (dinfo_len > (rom_size - reset_vec_size)) {
159
+ error_report("not enough space to store dynamic firmware info");
160
+ exit(1);
161
+ }
162
+
163
+ rom_add_blob_fixed_as("mrom.finfo", &dinfo, dinfo_len,
164
+ rom_base + reset_vec_size,
165
+ &address_space_memory);
166
+}
167
+
168
void riscv_setup_rom_reset_vec(hwaddr start_addr, hwaddr rom_base,
169
- hwaddr rom_size,
170
+ hwaddr rom_size, uint64_t kernel_entry,
171
uint32_t fdt_load_addr, void *fdt)
172
{
173
int i;
174
175
/* reset vector */
176
uint32_t reset_vec[10] = {
177
- 0x00000297, /* 1: auipc t0, %pcrel_hi(dtb) */
178
+ 0x00000297, /* 1: auipc t0, %pcrel_hi(fw_dyn) */
179
+ 0x02828613, /* addi a2, t0, %pcrel_lo(1b) */
180
0xf1402573, /* csrr a0, mhartid */
181
#if defined(TARGET_RISCV32)
182
0x0202a583, /* lw a1, 32(t0) */
183
@@ -XXX,XX +XXX,XX @@ void riscv_setup_rom_reset_vec(hwaddr start_addr, hwaddr rom_base,
184
0x0182b283, /* ld t0, 24(t0) */
185
#endif
186
0x00028067, /* jr t0 */
187
- 0x00000000,
188
start_addr, /* start: .dword */
189
0x00000000,
190
fdt_load_addr, /* fdt_laddr: .dword */
191
0x00000000,
192
- /* dtb: */
193
+ /* fw_dyn: */
194
};
195
196
/* copy in the reset vector in little_endian byte order */
197
@@ -XXX,XX +XXX,XX @@ void riscv_setup_rom_reset_vec(hwaddr start_addr, hwaddr rom_base,
198
}
199
rom_add_blob_fixed_as("mrom.reset", reset_vec, sizeof(reset_vec),
200
rom_base, &address_space_memory);
201
+ riscv_rom_copy_firmware_info(rom_base, rom_size, sizeof(reset_vec),
202
+ kernel_entry);
203
204
return;
205
}
206
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
207
index XXXXXXX..XXXXXXX 100644
208
--- a/hw/riscv/sifive_u.c
209
+++ b/hw/riscv/sifive_u.c
210
@@ -XXX,XX +XXX,XX @@ static void sifive_u_machine_init(MachineState *machine)
211
target_ulong start_addr = memmap[SIFIVE_U_DRAM].base;
212
int i;
213
uint32_t fdt_load_addr;
214
+ uint64_t kernel_entry;
215
216
/* Initialize SoC */
217
object_initialize_child(OBJECT(machine), "soc", &s->soc, TYPE_RISCV_U_SOC);
218
@@ -XXX,XX +XXX,XX @@ static void sifive_u_machine_init(MachineState *machine)
219
riscv_find_and_load_firmware(machine, BIOS_FILENAME, start_addr, NULL);
220
221
if (machine->kernel_filename) {
222
- uint64_t kernel_entry = riscv_load_kernel(machine->kernel_filename,
223
- NULL);
224
+ kernel_entry = riscv_load_kernel(machine->kernel_filename, NULL);
225
226
if (machine->initrd_filename) {
227
hwaddr start;
228
@@ -XXX,XX +XXX,XX @@ static void sifive_u_machine_init(MachineState *machine)
229
qemu_fdt_setprop_cell(s->fdt, "/chosen", "linux,initrd-end",
230
end);
231
}
232
+ } else {
233
+ /*
234
+ * If dynamic firmware is used, it doesn't know where is the next mode
235
+ * if kernel argument is not set.
236
+ */
237
+ kernel_entry = 0;
238
}
239
240
/* Compute the fdt load address in dram */
241
@@ -XXX,XX +XXX,XX @@ static void sifive_u_machine_init(MachineState *machine)
242
/* reset vector */
243
uint32_t reset_vec[11] = {
244
s->msel, /* MSEL pin state */
245
- 0x00000297, /* 1: auipc t0, %pcrel_hi(dtb) */
246
+ 0x00000297, /* 1: auipc t0, %pcrel_hi(fw_dyn) */
247
+ 0x02828613, /* addi a2, t0, %pcrel_lo(1b) */
248
0xf1402573, /* csrr a0, mhartid */
249
#if defined(TARGET_RISCV32)
250
0x0202a583, /* lw a1, 32(t0) */
251
@@ -XXX,XX +XXX,XX @@ static void sifive_u_machine_init(MachineState *machine)
252
0x0182b283, /* ld t0, 24(t0) */
253
#endif
254
0x00028067, /* jr t0 */
255
- 0x00000000,
256
start_addr, /* start: .dword */
257
0x00000000,
258
fdt_load_addr, /* fdt_laddr: .dword */
259
0x00000000,
260
- /* dtb: */
261
+ /* fw_dyn: */
262
};
263
264
/* copy in the reset vector in little_endian byte order */
265
@@ -XXX,XX +XXX,XX @@ static void sifive_u_machine_init(MachineState *machine)
266
}
267
rom_add_blob_fixed_as("mrom.reset", reset_vec, sizeof(reset_vec),
268
memmap[SIFIVE_U_MROM].base, &address_space_memory);
269
+
270
+ riscv_rom_copy_firmware_info(memmap[SIFIVE_U_MROM].base,
271
+ memmap[SIFIVE_U_MROM].size,
272
+ sizeof(reset_vec), kernel_entry);
273
}
274
275
static bool sifive_u_machine_get_start_in_flash(Object *obj, Error **errp)
276
diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c
277
index XXXXXXX..XXXXXXX 100644
278
--- a/hw/riscv/spike.c
279
+++ b/hw/riscv/spike.c
280
@@ -XXX,XX +XXX,XX @@ static void spike_board_init(MachineState *machine)
281
MemoryRegion *mask_rom = g_new(MemoryRegion, 1);
282
unsigned int smp_cpus = machine->smp.cpus;
283
uint32_t fdt_load_addr;
284
+ uint64_t kernel_entry;
285
286
/* Initialize SOC */
287
object_initialize_child(OBJECT(machine), "soc", &s->soc,
288
@@ -XXX,XX +XXX,XX @@ static void spike_board_init(MachineState *machine)
289
htif_symbol_callback);
290
291
if (machine->kernel_filename) {
292
- uint64_t kernel_entry = riscv_load_kernel(machine->kernel_filename,
293
- htif_symbol_callback);
294
+ kernel_entry = riscv_load_kernel(machine->kernel_filename,
295
+ htif_symbol_callback);
296
297
if (machine->initrd_filename) {
298
hwaddr start;
299
@@ -XXX,XX +XXX,XX @@ static void spike_board_init(MachineState *machine)
300
qemu_fdt_setprop_cell(s->fdt, "/chosen", "linux,initrd-end",
301
end);
302
}
303
+ } else {
304
+ /*
305
+ * If dynamic firmware is used, it doesn't know where is the next mode
306
+ * if kernel argument is not set.
307
+ */
308
+ kernel_entry = 0;
309
}
310
311
/* Compute the fdt load address in dram */
312
@@ -XXX,XX +XXX,XX @@ static void spike_board_init(MachineState *machine)
313
machine->ram_size, s->fdt);
314
/* load the reset vector */
315
riscv_setup_rom_reset_vec(memmap[SPIKE_DRAM].base, memmap[SPIKE_MROM].base,
316
- memmap[SPIKE_MROM].size,
317
+ memmap[SPIKE_MROM].size, kernel_entry,
318
fdt_load_addr, s->fdt);
319
320
/* initialize HTIF using symbols found in load_kernel */
321
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
322
index XXXXXXX..XXXXXXX 100644
323
--- a/hw/riscv/virt.c
324
+++ b/hw/riscv/virt.c
325
@@ -XXX,XX +XXX,XX @@ static void virt_machine_init(MachineState *machine)
326
size_t plic_hart_config_len;
327
target_ulong start_addr = memmap[VIRT_DRAM].base;
328
uint32_t fdt_load_addr;
329
+ uint64_t kernel_entry;
330
int i;
331
unsigned int smp_cpus = machine->smp.cpus;
332
333
@@ -XXX,XX +XXX,XX @@ static void virt_machine_init(MachineState *machine)
334
memmap[VIRT_DRAM].base, NULL);
335
336
if (machine->kernel_filename) {
337
- uint64_t kernel_entry = riscv_load_kernel(machine->kernel_filename,
338
- NULL);
339
+ kernel_entry = riscv_load_kernel(machine->kernel_filename, NULL);
340
341
if (machine->initrd_filename) {
342
hwaddr start;
343
@@ -XXX,XX +XXX,XX @@ static void virt_machine_init(MachineState *machine)
344
qemu_fdt_setprop_cell(s->fdt, "/chosen", "linux,initrd-end",
345
end);
346
}
347
+ } else {
348
+ /*
349
+ * If dynamic firmware is used, it doesn't know where is the next mode
350
+ * if kernel argument is not set.
351
+ */
352
+ kernel_entry = 0;
353
}
354
355
if (drive_get(IF_PFLASH, 0, 0)) {
356
@@ -XXX,XX +XXX,XX @@ static void virt_machine_init(MachineState *machine)
357
machine->ram_size, s->fdt);
358
/* load the reset vector */
359
riscv_setup_rom_reset_vec(start_addr, virt_memmap[VIRT_MROM].base,
360
- virt_memmap[VIRT_MROM].size,
361
+ virt_memmap[VIRT_MROM].size, kernel_entry,
362
fdt_load_addr, s->fdt);
363
364
/* create PLIC hart topology configuration string */
365
--
366
2.27.0
367
368
diff view generated by jsdifflib
Deleted patch
1
From: Atish Patra <atish.patra@wdc.com>
2
1
3
Even though the start address in ROM code is declared as a 64 bit address
4
for RV64, it can't be used as upper bits are set to zero in ROM code.
5
6
Update the ROM code correctly to reflect the 64bit value.
7
8
Signed-off-by: Atish Patra <atish.patra@wdc.com>
9
Reviewed-by: Bin Meng <bin.meng@windriver.com>
10
Tested-by: Bin Meng <bin.meng@windriver.com>
11
Message-Id: <20200701183949.398134-5-atish.patra@wdc.com>
12
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
13
---
14
hw/riscv/boot.c | 6 +++++-
15
hw/riscv/sifive_u.c | 6 +++++-
16
2 files changed, 10 insertions(+), 2 deletions(-)
17
18
diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/riscv/boot.c
21
+++ b/hw/riscv/boot.c
22
@@ -XXX,XX +XXX,XX @@ void riscv_setup_rom_reset_vec(hwaddr start_addr, hwaddr rom_base,
23
uint32_t fdt_load_addr, void *fdt)
24
{
25
int i;
26
+ uint32_t start_addr_hi32 = 0x00000000;
27
28
+ #if defined(TARGET_RISCV64)
29
+ start_addr_hi32 = start_addr >> 32;
30
+ #endif
31
/* reset vector */
32
uint32_t reset_vec[10] = {
33
0x00000297, /* 1: auipc t0, %pcrel_hi(fw_dyn) */
34
@@ -XXX,XX +XXX,XX @@ void riscv_setup_rom_reset_vec(hwaddr start_addr, hwaddr rom_base,
35
#endif
36
0x00028067, /* jr t0 */
37
start_addr, /* start: .dword */
38
- 0x00000000,
39
+ start_addr_hi32,
40
fdt_load_addr, /* fdt_laddr: .dword */
41
0x00000000,
42
/* fw_dyn: */
43
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/hw/riscv/sifive_u.c
46
+++ b/hw/riscv/sifive_u.c
47
@@ -XXX,XX +XXX,XX @@ static void sifive_u_machine_init(MachineState *machine)
48
MemoryRegion *main_mem = g_new(MemoryRegion, 1);
49
MemoryRegion *flash0 = g_new(MemoryRegion, 1);
50
target_ulong start_addr = memmap[SIFIVE_U_DRAM].base;
51
+ uint32_t start_addr_hi32 = 0x00000000;
52
int i;
53
uint32_t fdt_load_addr;
54
uint64_t kernel_entry;
55
@@ -XXX,XX +XXX,XX @@ static void sifive_u_machine_init(MachineState *machine)
56
/* Compute the fdt load address in dram */
57
fdt_load_addr = riscv_load_fdt(memmap[SIFIVE_U_DRAM].base,
58
machine->ram_size, s->fdt);
59
+ #if defined(TARGET_RISCV64)
60
+ start_addr_hi32 = start_addr >> 32;
61
+ #endif
62
63
/* reset vector */
64
uint32_t reset_vec[11] = {
65
@@ -XXX,XX +XXX,XX @@ static void sifive_u_machine_init(MachineState *machine)
66
#endif
67
0x00028067, /* jr t0 */
68
start_addr, /* start: .dword */
69
- 0x00000000,
70
+ start_addr_hi32,
71
fdt_load_addr, /* fdt_laddr: .dword */
72
0x00000000,
73
/* fw_dyn: */
74
--
75
2.27.0
76
77
diff view generated by jsdifflib
Deleted patch
1
From: Bin Meng <bin.meng@windriver.com>
2
1
3
At present the size of Mask ROM for sifive_u / spike / virt machines
4
is set to 0x11000, which ends at an unusual address. This changes the
5
size to 0xf000 so that it ends at 0x10000.
6
7
Signed-off-by: Bin Meng <bin.meng@windriver.com>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-Id: <1594289144-24723-1-git-send-email-bmeng.cn@gmail.com>
10
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
---
12
hw/riscv/sifive_u.c | 2 +-
13
hw/riscv/spike.c | 2 +-
14
hw/riscv/virt.c | 2 +-
15
3 files changed, 3 insertions(+), 3 deletions(-)
16
17
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/riscv/sifive_u.c
20
+++ b/hw/riscv/sifive_u.c
21
@@ -XXX,XX +XXX,XX @@ static const struct MemmapEntry {
22
hwaddr size;
23
} sifive_u_memmap[] = {
24
[SIFIVE_U_DEBUG] = { 0x0, 0x100 },
25
- [SIFIVE_U_MROM] = { 0x1000, 0x11000 },
26
+ [SIFIVE_U_MROM] = { 0x1000, 0xf000 },
27
[SIFIVE_U_CLINT] = { 0x2000000, 0x10000 },
28
[SIFIVE_U_L2LIM] = { 0x8000000, 0x2000000 },
29
[SIFIVE_U_PLIC] = { 0xc000000, 0x4000000 },
30
diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c
31
index XXXXXXX..XXXXXXX 100644
32
--- a/hw/riscv/spike.c
33
+++ b/hw/riscv/spike.c
34
@@ -XXX,XX +XXX,XX @@ static const struct MemmapEntry {
35
hwaddr base;
36
hwaddr size;
37
} spike_memmap[] = {
38
- [SPIKE_MROM] = { 0x1000, 0x11000 },
39
+ [SPIKE_MROM] = { 0x1000, 0xf000 },
40
[SPIKE_CLINT] = { 0x2000000, 0x10000 },
41
[SPIKE_DRAM] = { 0x80000000, 0x0 },
42
};
43
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/hw/riscv/virt.c
46
+++ b/hw/riscv/virt.c
47
@@ -XXX,XX +XXX,XX @@ static const struct MemmapEntry {
48
hwaddr size;
49
} virt_memmap[] = {
50
[VIRT_DEBUG] = { 0x0, 0x100 },
51
- [VIRT_MROM] = { 0x1000, 0x11000 },
52
+ [VIRT_MROM] = { 0x1000, 0xf000 },
53
[VIRT_TEST] = { 0x100000, 0x1000 },
54
[VIRT_RTC] = { 0x101000, 0x1000 },
55
[VIRT_CLINT] = { 0x2000000, 0x10000 },
56
--
57
2.27.0
58
59
diff view generated by jsdifflib
Deleted patch
1
From: Frank Chang <frank.chang@sifive.com>
2
1
3
gvec should provide vecop_list to avoid:
4
"tcg_tcg_assert_listed_vecop: code should not be reached bug" assertion.
5
6
Signed-off-by: Frank Chang <frank.chang@sifive.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-Id: <20200710104920.13550-2-frank.chang@sifive.com>
9
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
10
---
11
target/riscv/insn_trans/trans_rvv.inc.c | 5 +++++
12
1 file changed, 5 insertions(+)
13
14
diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/riscv/insn_trans/trans_rvv.inc.c
17
+++ b/target/riscv/insn_trans/trans_rvv.inc.c
18
@@ -XXX,XX +XXX,XX @@ static void gen_rsub_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b)
19
static void tcg_gen_gvec_rsubs(unsigned vece, uint32_t dofs, uint32_t aofs,
20
TCGv_i64 c, uint32_t oprsz, uint32_t maxsz)
21
{
22
+ static const TCGOpcode vecop_list[] = { INDEX_op_sub_vec, 0 };
23
static const GVecGen2s rsub_op[4] = {
24
{ .fni8 = gen_vec_rsub8_i64,
25
.fniv = gen_rsub_vec,
26
.fno = gen_helper_vec_rsubs8,
27
+ .opt_opc = vecop_list,
28
.vece = MO_8 },
29
{ .fni8 = gen_vec_rsub16_i64,
30
.fniv = gen_rsub_vec,
31
.fno = gen_helper_vec_rsubs16,
32
+ .opt_opc = vecop_list,
33
.vece = MO_16 },
34
{ .fni4 = gen_rsub_i32,
35
.fniv = gen_rsub_vec,
36
.fno = gen_helper_vec_rsubs32,
37
+ .opt_opc = vecop_list,
38
.vece = MO_32 },
39
{ .fni8 = gen_rsub_i64,
40
.fniv = gen_rsub_vec,
41
.fno = gen_helper_vec_rsubs64,
42
+ .opt_opc = vecop_list,
43
.prefer_i64 = TCG_TARGET_REG_BITS == 64,
44
.vece = MO_64 },
45
};
46
--
47
2.27.0
48
49
diff view generated by jsdifflib
Deleted patch
1
From: Frank Chang <frank.chang@sifive.com>
2
1
3
Signed-off-by: Frank Chang <frank.chang@sifive.com>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-Id: <20200710104920.13550-3-frank.chang@sifive.com>
6
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
7
---
8
target/riscv/insn_trans/trans_rvv.inc.c | 2 +-
9
1 file changed, 1 insertion(+), 1 deletion(-)
10
11
diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/target/riscv/insn_trans/trans_rvv.inc.c
14
+++ b/target/riscv/insn_trans/trans_rvv.inc.c
15
@@ -XXX,XX +XXX,XX @@ static void gen_vec_rsub8_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b)
16
17
static void gen_vec_rsub16_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b)
18
{
19
- tcg_gen_vec_sub8_i64(d, b, a);
20
+ tcg_gen_vec_sub16_i64(d, b, a);
21
}
22
23
static void gen_rsub_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
24
--
25
2.27.0
26
27
diff view generated by jsdifflib
Deleted patch
1
From: Frank Chang <frank.chang@sifive.com>
2
1
3
do_opivx_widen() should return false if check function returns false.
4
5
Signed-off-by: Frank Chang <frank.chang@sifive.com>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-Id: <20200710104920.13550-4-frank.chang@sifive.com>
8
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
9
---
10
target/riscv/insn_trans/trans_rvv.inc.c | 2 +-
11
1 file changed, 1 insertion(+), 1 deletion(-)
12
13
diff --git a/target/riscv/insn_trans/trans_rvv.inc.c b/target/riscv/insn_trans/trans_rvv.inc.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/riscv/insn_trans/trans_rvv.inc.c
16
+++ b/target/riscv/insn_trans/trans_rvv.inc.c
17
@@ -XXX,XX +XXX,XX @@ static bool do_opivx_widen(DisasContext *s, arg_rmrr *a,
18
if (opivx_widen_check(s, a)) {
19
return opivx_trans(a->rd, a->rs1, a->rs2, a->vm, fn, s);
20
}
21
- return true;
22
+ return false;
23
}
24
25
#define GEN_OPIVX_WIDEN_TRANS(NAME) \
26
--
27
2.27.0
28
29
diff view generated by jsdifflib
Deleted patch
1
From: Frank Chang <frank.chang@sifive.com>
2
1
3
vill bit is at vtype[XLEN-1].
4
5
Signed-off-by: Frank Chang <frank.chang@sifive.com>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-Id: <20200710104920.13550-5-frank.chang@sifive.com>
8
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
9
---
10
target/riscv/cpu.h | 2 +-
11
1 file changed, 1 insertion(+), 1 deletion(-)
12
13
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/riscv/cpu.h
16
+++ b/target/riscv/cpu.h
17
@@ -XXX,XX +XXX,XX @@ FIELD(VTYPE, VLMUL, 0, 2)
18
FIELD(VTYPE, VSEW, 2, 3)
19
FIELD(VTYPE, VEDIV, 5, 2)
20
FIELD(VTYPE, RESERVED, 7, sizeof(target_ulong) * 8 - 9)
21
-FIELD(VTYPE, VILL, sizeof(target_ulong) * 8 - 2, 1)
22
+FIELD(VTYPE, VILL, sizeof(target_ulong) * 8 - 1, 1)
23
24
struct CPURISCVState {
25
target_ulong gpr[32];
26
--
27
2.27.0
28
29
diff view generated by jsdifflib
Deleted patch
1
Conver the Ibex UART to use the recently added qdev-clock functions.
2
1
3
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
4
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
5
Message-id: b0136fad870a29049959ec161c1217b967d7e19d.1594332223.git.alistair.francis@wdc.com
6
Message-Id: <b0136fad870a29049959ec161c1217b967d7e19d.1594332223.git.alistair.francis@wdc.com>
7
---
8
include/hw/char/ibex_uart.h | 3 +++
9
hw/char/ibex_uart.c | 30 +++++++++++++++++++++++++++---
10
2 files changed, 30 insertions(+), 3 deletions(-)
11
12
diff --git a/include/hw/char/ibex_uart.h b/include/hw/char/ibex_uart.h
13
index XXXXXXX..XXXXXXX 100644
14
--- a/include/hw/char/ibex_uart.h
15
+++ b/include/hw/char/ibex_uart.h
16
@@ -XXX,XX +XXX,XX @@
17
#define IBEX_UART_TIMEOUT_CTRL 0x2c
18
19
#define IBEX_UART_TX_FIFO_SIZE 16
20
+#define IBEX_UART_CLOCK 50000000 /* 50MHz clock */
21
22
#define TYPE_IBEX_UART "ibex-uart"
23
#define IBEX_UART(obj) \
24
@@ -XXX,XX +XXX,XX @@ typedef struct {
25
uint32_t uart_val;
26
uint32_t uart_timeout_ctrl;
27
28
+ Clock *f_clk;
29
+
30
CharBackend chr;
31
qemu_irq tx_watermark;
32
qemu_irq rx_watermark;
33
diff --git a/hw/char/ibex_uart.c b/hw/char/ibex_uart.c
34
index XXXXXXX..XXXXXXX 100644
35
--- a/hw/char/ibex_uart.c
36
+++ b/hw/char/ibex_uart.c
37
@@ -XXX,XX +XXX,XX @@
38
#include "qemu/osdep.h"
39
#include "hw/char/ibex_uart.h"
40
#include "hw/irq.h"
41
+#include "hw/qdev-clock.h"
42
#include "hw/qdev-properties.h"
43
#include "migration/vmstate.h"
44
#include "qemu/log.h"
45
@@ -XXX,XX +XXX,XX @@ static void ibex_uart_reset(DeviceState *dev)
46
ibex_uart_update_irqs(s);
47
}
48
49
+static uint64_t ibex_uart_get_baud(IbexUartState *s)
50
+{
51
+ uint64_t baud;
52
+
53
+ baud = ((s->uart_ctrl & UART_CTRL_NCO) >> 16);
54
+ baud *= clock_get_hz(s->f_clk);
55
+ baud >>= 20;
56
+
57
+ return baud;
58
+}
59
+
60
static uint64_t ibex_uart_read(void *opaque, hwaddr addr,
61
unsigned int size)
62
{
63
@@ -XXX,XX +XXX,XX @@ static void ibex_uart_write(void *opaque, hwaddr addr,
64
"%s: UART_CTRL_RXBLVL is not supported\n", __func__);
65
}
66
if (value & UART_CTRL_NCO) {
67
- uint64_t baud = ((value & UART_CTRL_NCO) >> 16);
68
- baud *= 1000;
69
- baud >>= 20;
70
+ uint64_t baud = ibex_uart_get_baud(s);
71
72
s->char_tx_time = (NANOSECONDS_PER_SECOND / baud) * 10;
73
}
74
@@ -XXX,XX +XXX,XX @@ static void ibex_uart_write(void *opaque, hwaddr addr,
75
}
76
}
77
78
+static void ibex_uart_clk_update(void *opaque)
79
+{
80
+ IbexUartState *s = opaque;
81
+
82
+ /* recompute uart's speed on clock change */
83
+ uint64_t baud = ibex_uart_get_baud(s);
84
+
85
+ s->char_tx_time = (NANOSECONDS_PER_SECOND / baud) * 10;
86
+}
87
+
88
static void fifo_trigger_update(void *opaque)
89
{
90
IbexUartState *s = opaque;
91
@@ -XXX,XX +XXX,XX @@ static void ibex_uart_init(Object *obj)
92
{
93
IbexUartState *s = IBEX_UART(obj);
94
95
+ s->f_clk = qdev_init_clock_in(DEVICE(obj), "f_clock",
96
+ ibex_uart_clk_update, s);
97
+ clock_set_hz(s->f_clk, IBEX_UART_CLOCK);
98
+
99
sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->tx_watermark);
100
sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->rx_watermark);
101
sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->tx_empty);
102
--
103
2.27.0
104
105
diff view generated by jsdifflib
Deleted patch
1
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2
Message-id: 06372c9cdeec715077899e71c858d9f0a2a3395b.1594332223.git.alistair.francis@wdc.com
3
Message-Id: <06372c9cdeec715077899e71c858d9f0a2a3395b.1594332223.git.alistair.francis@wdc.com>
4
---
5
include/hw/char/ibex_uart.h | 76 ++++++++++-----------
6
hw/char/ibex_uart.c | 130 ++++++++++++++++++------------------
7
2 files changed, 100 insertions(+), 106 deletions(-)
8
1
9
diff --git a/include/hw/char/ibex_uart.h b/include/hw/char/ibex_uart.h
10
index XXXXXXX..XXXXXXX 100644
11
--- a/include/hw/char/ibex_uart.h
12
+++ b/include/hw/char/ibex_uart.h
13
@@ -XXX,XX +XXX,XX @@
14
#define HW_IBEX_UART_H
15
16
#include "hw/sysbus.h"
17
+#include "hw/registerfields.h"
18
#include "chardev/char-fe.h"
19
#include "qemu/timer.h"
20
21
-#define IBEX_UART_INTR_STATE 0x00
22
- #define INTR_STATE_TX_WATERMARK (1 << 0)
23
- #define INTR_STATE_RX_WATERMARK (1 << 1)
24
- #define INTR_STATE_TX_EMPTY (1 << 2)
25
- #define INTR_STATE_RX_OVERFLOW (1 << 3)
26
-#define IBEX_UART_INTR_ENABLE 0x04
27
-#define IBEX_UART_INTR_TEST 0x08
28
-
29
-#define IBEX_UART_CTRL 0x0c
30
- #define UART_CTRL_TX_ENABLE (1 << 0)
31
- #define UART_CTRL_RX_ENABLE (1 << 1)
32
- #define UART_CTRL_NF (1 << 2)
33
- #define UART_CTRL_SLPBK (1 << 4)
34
- #define UART_CTRL_LLPBK (1 << 5)
35
- #define UART_CTRL_PARITY_EN (1 << 6)
36
- #define UART_CTRL_PARITY_ODD (1 << 7)
37
- #define UART_CTRL_RXBLVL (3 << 8)
38
- #define UART_CTRL_NCO (0xFFFF << 16)
39
-
40
-#define IBEX_UART_STATUS 0x10
41
- #define UART_STATUS_TXFULL (1 << 0)
42
- #define UART_STATUS_RXFULL (1 << 1)
43
- #define UART_STATUS_TXEMPTY (1 << 2)
44
- #define UART_STATUS_RXIDLE (1 << 4)
45
- #define UART_STATUS_RXEMPTY (1 << 5)
46
-
47
-#define IBEX_UART_RDATA 0x14
48
-#define IBEX_UART_WDATA 0x18
49
-
50
-#define IBEX_UART_FIFO_CTRL 0x1c
51
- #define FIFO_CTRL_RXRST (1 << 0)
52
- #define FIFO_CTRL_TXRST (1 << 1)
53
- #define FIFO_CTRL_RXILVL (7 << 2)
54
- #define FIFO_CTRL_RXILVL_SHIFT (2)
55
- #define FIFO_CTRL_TXILVL (3 << 5)
56
- #define FIFO_CTRL_TXILVL_SHIFT (5)
57
-
58
-#define IBEX_UART_FIFO_STATUS 0x20
59
-#define IBEX_UART_OVRD 0x24
60
-#define IBEX_UART_VAL 0x28
61
-#define IBEX_UART_TIMEOUT_CTRL 0x2c
62
+REG32(INTR_STATE, 0x00)
63
+ FIELD(INTR_STATE, TX_WATERMARK, 0, 1)
64
+ FIELD(INTR_STATE, RX_WATERMARK, 1, 1)
65
+ FIELD(INTR_STATE, TX_EMPTY, 2, 1)
66
+ FIELD(INTR_STATE, RX_OVERFLOW, 3, 1)
67
+REG32(INTR_ENABLE, 0x04)
68
+REG32(INTR_TEST, 0x08)
69
+REG32(CTRL, 0x0C)
70
+ FIELD(CTRL, TX_ENABLE, 0, 1)
71
+ FIELD(CTRL, RX_ENABLE, 1, 1)
72
+ FIELD(CTRL, NF, 2, 1)
73
+ FIELD(CTRL, SLPBK, 4, 1)
74
+ FIELD(CTRL, LLPBK, 5, 1)
75
+ FIELD(CTRL, PARITY_EN, 6, 1)
76
+ FIELD(CTRL, PARITY_ODD, 7, 1)
77
+ FIELD(CTRL, RXBLVL, 8, 2)
78
+ FIELD(CTRL, NCO, 16, 16)
79
+REG32(STATUS, 0x10)
80
+ FIELD(STATUS, TXFULL, 0, 1)
81
+ FIELD(STATUS, RXFULL, 1, 1)
82
+ FIELD(STATUS, TXEMPTY, 2, 1)
83
+ FIELD(STATUS, RXIDLE, 4, 1)
84
+ FIELD(STATUS, RXEMPTY, 5, 1)
85
+REG32(RDATA, 0x14)
86
+REG32(WDATA, 0x18)
87
+REG32(FIFO_CTRL, 0x1c)
88
+ FIELD(FIFO_CTRL, RXRST, 0, 1)
89
+ FIELD(FIFO_CTRL, TXRST, 1, 1)
90
+ FIELD(FIFO_CTRL, RXILVL, 2, 3)
91
+ FIELD(FIFO_CTRL, TXILVL, 5, 2)
92
+REG32(FIFO_STATUS, 0x20)
93
+REG32(OVRD, 0x24)
94
+REG32(VAL, 0x28)
95
+REG32(TIMEOUT_CTRL, 0x2c)
96
97
#define IBEX_UART_TX_FIFO_SIZE 16
98
#define IBEX_UART_CLOCK 50000000 /* 50MHz clock */
99
diff --git a/hw/char/ibex_uart.c b/hw/char/ibex_uart.c
100
index XXXXXXX..XXXXXXX 100644
101
--- a/hw/char/ibex_uart.c
102
+++ b/hw/char/ibex_uart.c
103
@@ -XXX,XX +XXX,XX @@
104
105
static void ibex_uart_update_irqs(IbexUartState *s)
106
{
107
- if (s->uart_intr_state & s->uart_intr_enable & INTR_STATE_TX_WATERMARK) {
108
+ if (s->uart_intr_state & s->uart_intr_enable & R_INTR_STATE_TX_WATERMARK_MASK) {
109
qemu_set_irq(s->tx_watermark, 1);
110
} else {
111
qemu_set_irq(s->tx_watermark, 0);
112
}
113
114
- if (s->uart_intr_state & s->uart_intr_enable & INTR_STATE_RX_WATERMARK) {
115
+ if (s->uart_intr_state & s->uart_intr_enable & R_INTR_STATE_RX_WATERMARK_MASK) {
116
qemu_set_irq(s->rx_watermark, 1);
117
} else {
118
qemu_set_irq(s->rx_watermark, 0);
119
}
120
121
- if (s->uart_intr_state & s->uart_intr_enable & INTR_STATE_TX_EMPTY) {
122
+ if (s->uart_intr_state & s->uart_intr_enable & R_INTR_STATE_TX_EMPTY_MASK) {
123
qemu_set_irq(s->tx_empty, 1);
124
} else {
125
qemu_set_irq(s->tx_empty, 0);
126
}
127
128
- if (s->uart_intr_state & s->uart_intr_enable & INTR_STATE_RX_OVERFLOW) {
129
+ if (s->uart_intr_state & s->uart_intr_enable & R_INTR_STATE_RX_OVERFLOW_MASK) {
130
qemu_set_irq(s->rx_overflow, 1);
131
} else {
132
qemu_set_irq(s->rx_overflow, 0);
133
@@ -XXX,XX +XXX,XX @@ static int ibex_uart_can_receive(void *opaque)
134
{
135
IbexUartState *s = opaque;
136
137
- if (s->uart_ctrl & UART_CTRL_RX_ENABLE) {
138
+ if (s->uart_ctrl & R_CTRL_RX_ENABLE_MASK) {
139
return 1;
140
}
141
142
@@ -XXX,XX +XXX,XX @@ static int ibex_uart_can_receive(void *opaque)
143
static void ibex_uart_receive(void *opaque, const uint8_t *buf, int size)
144
{
145
IbexUartState *s = opaque;
146
- uint8_t rx_fifo_level = (s->uart_fifo_ctrl & FIFO_CTRL_RXILVL)
147
- >> FIFO_CTRL_RXILVL_SHIFT;
148
+ uint8_t rx_fifo_level = (s->uart_fifo_ctrl & R_FIFO_CTRL_RXILVL_MASK)
149
+ >> R_FIFO_CTRL_RXILVL_SHIFT;
150
151
s->uart_rdata = *buf;
152
153
- s->uart_status &= ~UART_STATUS_RXIDLE;
154
- s->uart_status &= ~UART_STATUS_RXEMPTY;
155
+ s->uart_status &= ~R_STATUS_RXIDLE_MASK;
156
+ s->uart_status &= ~R_STATUS_RXEMPTY_MASK;
157
158
if (size > rx_fifo_level) {
159
- s->uart_intr_state |= INTR_STATE_RX_WATERMARK;
160
+ s->uart_intr_state |= R_INTR_STATE_RX_WATERMARK_MASK;
161
}
162
163
ibex_uart_update_irqs(s);
164
@@ -XXX,XX +XXX,XX @@ static gboolean ibex_uart_xmit(GIOChannel *chan, GIOCondition cond,
165
void *opaque)
166
{
167
IbexUartState *s = opaque;
168
- uint8_t tx_fifo_level = (s->uart_fifo_ctrl & FIFO_CTRL_TXILVL)
169
- >> FIFO_CTRL_TXILVL_SHIFT;
170
+ uint8_t tx_fifo_level = (s->uart_fifo_ctrl & R_FIFO_CTRL_TXILVL_MASK)
171
+ >> R_FIFO_CTRL_TXILVL_SHIFT;
172
int ret;
173
174
/* instant drain the fifo when there's no back-end */
175
@@ -XXX,XX +XXX,XX @@ static gboolean ibex_uart_xmit(GIOChannel *chan, GIOCondition cond,
176
}
177
178
if (!s->tx_level) {
179
- s->uart_status &= ~UART_STATUS_TXFULL;
180
- s->uart_status |= UART_STATUS_TXEMPTY;
181
- s->uart_intr_state |= INTR_STATE_TX_EMPTY;
182
- s->uart_intr_state &= ~INTR_STATE_TX_WATERMARK;
183
+ s->uart_status &= ~R_STATUS_TXFULL_MASK;
184
+ s->uart_status |= R_STATUS_TXEMPTY_MASK;
185
+ s->uart_intr_state |= R_INTR_STATE_TX_EMPTY_MASK;
186
+ s->uart_intr_state &= ~R_INTR_STATE_TX_WATERMARK_MASK;
187
ibex_uart_update_irqs(s);
188
return FALSE;
189
}
190
@@ -XXX,XX +XXX,XX @@ static gboolean ibex_uart_xmit(GIOChannel *chan, GIOCondition cond,
191
192
/* Clear the TX Full bit */
193
if (s->tx_level != IBEX_UART_TX_FIFO_SIZE) {
194
- s->uart_status &= ~UART_STATUS_TXFULL;
195
+ s->uart_status &= ~R_STATUS_TXFULL_MASK;
196
}
197
198
/* Disable the TX_WATERMARK IRQ */
199
if (s->tx_level < tx_fifo_level) {
200
- s->uart_intr_state &= ~INTR_STATE_TX_WATERMARK;
201
+ s->uart_intr_state &= ~R_INTR_STATE_TX_WATERMARK_MASK;
202
}
203
204
/* Set TX empty */
205
if (s->tx_level == 0) {
206
- s->uart_status |= UART_STATUS_TXEMPTY;
207
- s->uart_intr_state |= INTR_STATE_TX_EMPTY;
208
+ s->uart_status |= R_STATUS_TXEMPTY_MASK;
209
+ s->uart_intr_state |= R_INTR_STATE_TX_EMPTY_MASK;
210
}
211
212
ibex_uart_update_irqs(s);
213
@@ -XXX,XX +XXX,XX @@ static void uart_write_tx_fifo(IbexUartState *s, const uint8_t *buf,
214
int size)
215
{
216
uint64_t current_time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
217
- uint8_t tx_fifo_level = (s->uart_fifo_ctrl & FIFO_CTRL_TXILVL)
218
- >> FIFO_CTRL_TXILVL_SHIFT;
219
+ uint8_t tx_fifo_level = (s->uart_fifo_ctrl & R_FIFO_CTRL_TXILVL_MASK)
220
+ >> R_FIFO_CTRL_TXILVL_SHIFT;
221
222
if (size > IBEX_UART_TX_FIFO_SIZE - s->tx_level) {
223
size = IBEX_UART_TX_FIFO_SIZE - s->tx_level;
224
@@ -XXX,XX +XXX,XX @@ static void uart_write_tx_fifo(IbexUartState *s, const uint8_t *buf,
225
s->tx_level += size;
226
227
if (s->tx_level > 0) {
228
- s->uart_status &= ~UART_STATUS_TXEMPTY;
229
+ s->uart_status &= ~R_STATUS_TXEMPTY_MASK;
230
}
231
232
if (s->tx_level >= tx_fifo_level) {
233
- s->uart_intr_state |= INTR_STATE_TX_WATERMARK;
234
+ s->uart_intr_state |= R_INTR_STATE_TX_WATERMARK_MASK;
235
ibex_uart_update_irqs(s);
236
}
237
238
if (s->tx_level == IBEX_UART_TX_FIFO_SIZE) {
239
- s->uart_status |= UART_STATUS_TXFULL;
240
+ s->uart_status |= R_STATUS_TXFULL_MASK;
241
}
242
243
timer_mod(s->fifo_trigger_handle, current_time +
244
@@ -XXX,XX +XXX,XX @@ static uint64_t ibex_uart_get_baud(IbexUartState *s)
245
{
246
uint64_t baud;
247
248
- baud = ((s->uart_ctrl & UART_CTRL_NCO) >> 16);
249
+ baud = ((s->uart_ctrl & R_CTRL_NCO_MASK) >> 16);
250
baud *= clock_get_hz(s->f_clk);
251
baud >>= 20;
252
253
@@ -XXX,XX +XXX,XX @@ static uint64_t ibex_uart_read(void *opaque, hwaddr addr,
254
IbexUartState *s = opaque;
255
uint64_t retvalue = 0;
256
257
- switch (addr) {
258
- case IBEX_UART_INTR_STATE:
259
+ switch (addr >> 2) {
260
+ case R_INTR_STATE:
261
retvalue = s->uart_intr_state;
262
break;
263
- case IBEX_UART_INTR_ENABLE:
264
+ case R_INTR_ENABLE:
265
retvalue = s->uart_intr_enable;
266
break;
267
- case IBEX_UART_INTR_TEST:
268
+ case R_INTR_TEST:
269
qemu_log_mask(LOG_GUEST_ERROR,
270
"%s: wdata is write only\n", __func__);
271
break;
272
273
- case IBEX_UART_CTRL:
274
+ case R_CTRL:
275
retvalue = s->uart_ctrl;
276
break;
277
- case IBEX_UART_STATUS:
278
+ case R_STATUS:
279
retvalue = s->uart_status;
280
break;
281
282
- case IBEX_UART_RDATA:
283
+ case R_RDATA:
284
retvalue = s->uart_rdata;
285
- if (s->uart_ctrl & UART_CTRL_RX_ENABLE) {
286
+ if (s->uart_ctrl & R_CTRL_RX_ENABLE_MASK) {
287
qemu_chr_fe_accept_input(&s->chr);
288
289
- s->uart_status |= UART_STATUS_RXIDLE;
290
- s->uart_status |= UART_STATUS_RXEMPTY;
291
+ s->uart_status |= R_STATUS_RXIDLE_MASK;
292
+ s->uart_status |= R_STATUS_RXEMPTY_MASK;
293
}
294
break;
295
- case IBEX_UART_WDATA:
296
+ case R_WDATA:
297
qemu_log_mask(LOG_GUEST_ERROR,
298
"%s: wdata is write only\n", __func__);
299
break;
300
301
- case IBEX_UART_FIFO_CTRL:
302
+ case R_FIFO_CTRL:
303
retvalue = s->uart_fifo_ctrl;
304
break;
305
- case IBEX_UART_FIFO_STATUS:
306
+ case R_FIFO_STATUS:
307
retvalue = s->uart_fifo_status;
308
309
retvalue |= s->tx_level & 0x1F;
310
@@ -XXX,XX +XXX,XX @@ static uint64_t ibex_uart_read(void *opaque, hwaddr addr,
311
"%s: RX fifos are not supported\n", __func__);
312
break;
313
314
- case IBEX_UART_OVRD:
315
+ case R_OVRD:
316
retvalue = s->uart_ovrd;
317
qemu_log_mask(LOG_UNIMP,
318
"%s: ovrd is not supported\n", __func__);
319
break;
320
- case IBEX_UART_VAL:
321
+ case R_VAL:
322
retvalue = s->uart_val;
323
qemu_log_mask(LOG_UNIMP,
324
"%s: val is not supported\n", __func__);
325
break;
326
- case IBEX_UART_TIMEOUT_CTRL:
327
+ case R_TIMEOUT_CTRL:
328
retvalue = s->uart_timeout_ctrl;
329
qemu_log_mask(LOG_UNIMP,
330
"%s: timeout_ctrl is not supported\n", __func__);
331
@@ -XXX,XX +XXX,XX @@ static void ibex_uart_write(void *opaque, hwaddr addr,
332
IbexUartState *s = opaque;
333
uint32_t value = val64;
334
335
- switch (addr) {
336
- case IBEX_UART_INTR_STATE:
337
+ switch (addr >> 2) {
338
+ case R_INTR_STATE:
339
/* Write 1 clear */
340
s->uart_intr_state &= ~value;
341
ibex_uart_update_irqs(s);
342
break;
343
- case IBEX_UART_INTR_ENABLE:
344
+ case R_INTR_ENABLE:
345
s->uart_intr_enable = value;
346
ibex_uart_update_irqs(s);
347
break;
348
- case IBEX_UART_INTR_TEST:
349
+ case R_INTR_TEST:
350
s->uart_intr_state |= value;
351
ibex_uart_update_irqs(s);
352
break;
353
354
- case IBEX_UART_CTRL:
355
+ case R_CTRL:
356
s->uart_ctrl = value;
357
358
- if (value & UART_CTRL_NF) {
359
+ if (value & R_CTRL_NF_MASK) {
360
qemu_log_mask(LOG_UNIMP,
361
"%s: UART_CTRL_NF is not supported\n", __func__);
362
}
363
- if (value & UART_CTRL_SLPBK) {
364
+ if (value & R_CTRL_SLPBK_MASK) {
365
qemu_log_mask(LOG_UNIMP,
366
"%s: UART_CTRL_SLPBK is not supported\n", __func__);
367
}
368
- if (value & UART_CTRL_LLPBK) {
369
+ if (value & R_CTRL_LLPBK_MASK) {
370
qemu_log_mask(LOG_UNIMP,
371
"%s: UART_CTRL_LLPBK is not supported\n", __func__);
372
}
373
- if (value & UART_CTRL_PARITY_EN) {
374
+ if (value & R_CTRL_PARITY_EN_MASK) {
375
qemu_log_mask(LOG_UNIMP,
376
"%s: UART_CTRL_PARITY_EN is not supported\n",
377
__func__);
378
}
379
- if (value & UART_CTRL_PARITY_ODD) {
380
+ if (value & R_CTRL_PARITY_ODD_MASK) {
381
qemu_log_mask(LOG_UNIMP,
382
"%s: UART_CTRL_PARITY_ODD is not supported\n",
383
__func__);
384
}
385
- if (value & UART_CTRL_RXBLVL) {
386
+ if (value & R_CTRL_RXBLVL_MASK) {
387
qemu_log_mask(LOG_UNIMP,
388
"%s: UART_CTRL_RXBLVL is not supported\n", __func__);
389
}
390
- if (value & UART_CTRL_NCO) {
391
+ if (value & R_CTRL_NCO_MASK) {
392
uint64_t baud = ibex_uart_get_baud(s);
393
394
s->char_tx_time = (NANOSECONDS_PER_SECOND / baud) * 10;
395
}
396
break;
397
- case IBEX_UART_STATUS:
398
+ case R_STATUS:
399
qemu_log_mask(LOG_GUEST_ERROR,
400
"%s: status is read only\n", __func__);
401
break;
402
403
- case IBEX_UART_RDATA:
404
+ case R_RDATA:
405
qemu_log_mask(LOG_GUEST_ERROR,
406
"%s: rdata is read only\n", __func__);
407
break;
408
- case IBEX_UART_WDATA:
409
+ case R_WDATA:
410
uart_write_tx_fifo(s, (uint8_t *) &value, 1);
411
break;
412
413
- case IBEX_UART_FIFO_CTRL:
414
+ case R_FIFO_CTRL:
415
s->uart_fifo_ctrl = value;
416
417
- if (value & FIFO_CTRL_RXRST) {
418
+ if (value & R_FIFO_CTRL_RXRST_MASK) {
419
qemu_log_mask(LOG_UNIMP,
420
"%s: RX fifos are not supported\n", __func__);
421
}
422
- if (value & FIFO_CTRL_TXRST) {
423
+ if (value & R_FIFO_CTRL_TXRST_MASK) {
424
s->tx_level = 0;
425
}
426
break;
427
- case IBEX_UART_FIFO_STATUS:
428
+ case R_FIFO_STATUS:
429
qemu_log_mask(LOG_GUEST_ERROR,
430
"%s: fifo_status is read only\n", __func__);
431
break;
432
433
- case IBEX_UART_OVRD:
434
+ case R_OVRD:
435
s->uart_ovrd = value;
436
qemu_log_mask(LOG_UNIMP,
437
"%s: ovrd is not supported\n", __func__);
438
break;
439
- case IBEX_UART_VAL:
440
+ case R_VAL:
441
qemu_log_mask(LOG_GUEST_ERROR,
442
"%s: val is read only\n", __func__);
443
break;
444
- case IBEX_UART_TIMEOUT_CTRL:
445
+ case R_TIMEOUT_CTRL:
446
s->uart_timeout_ctrl = value;
447
qemu_log_mask(LOG_UNIMP,
448
"%s: timeout_ctrl is not supported\n", __func__);
449
@@ -XXX,XX +XXX,XX @@ static void fifo_trigger_update(void *opaque)
450
{
451
IbexUartState *s = opaque;
452
453
- if (s->uart_ctrl & UART_CTRL_TX_ENABLE) {
454
+ if (s->uart_ctrl & R_CTRL_TX_ENABLE_MASK) {
455
ibex_uart_xmit(NULL, G_IO_OUT, s);
456
}
457
}
458
--
459
2.27.0
460
461
diff view generated by jsdifflib
Deleted patch
1
From: Liao Pingfang <liao.pingfang@zte.com.cn>
2
1
3
Remove superfluous breaks, as there is a "return" before them.
4
5
Signed-off-by: Liao Pingfang <liao.pingfang@zte.com.cn>
6
Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Reviewed-by: Thomas Huth <thuth@redhat.com>
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
Message-Id: <1594600421-22942-1-git-send-email-wang.yi59@zte.com.cn>
11
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
12
---
13
tcg/riscv/tcg-target.inc.c | 2 --
14
1 file changed, 2 deletions(-)
15
16
diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/tcg/riscv/tcg-target.inc.c
19
+++ b/tcg/riscv/tcg-target.inc.c
20
@@ -XXX,XX +XXX,XX @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type,
21
break;
22
case R_RISCV_JAL:
23
return reloc_jimm20(code_ptr, (tcg_insn_unit *)value);
24
- break;
25
case R_RISCV_CALL:
26
return reloc_call(code_ptr, (tcg_insn_unit *)value);
27
- break;
28
default:
29
tcg_abort();
30
}
31
--
32
2.27.0
33
34
diff view generated by jsdifflib