From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org,
"Thomas Huth" <thuth@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
qemu-ppc@nongnu.org, "Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH v2 19/25] hw/sparc: Use explicit big-endian LD/ST API
Date: Fri, 4 Oct 2024 13:30:35 -0300 [thread overview]
Message-ID: <20241004163042.85922-20-philmd@linaro.org> (raw)
In-Reply-To: <20241004163042.85922-1-philmd@linaro.org>
The SPARC architecture uses big endianness. Directly use
the big-endian LD/ST API.
for a in uw w l q;do sed -i -e "s/ld${a}_p(/ld${a}_be_p(/" $(git grep -wlE '(ld|st)u?[wlq]_p' hw/sparc/);done
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/sparc/leon3.c | 42 +++++++++++++++++++++---------------------
hw/sparc/sun4m.c | 6 +++---
hw/sparc64/sun4u.c | 6 +++---
3 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c
index 6aaa04cb191..021b5070128 100644
--- a/hw/sparc/leon3.c
+++ b/hw/sparc/leon3.c
@@ -78,21 +78,21 @@ typedef struct ResetData {
static uint32_t *gen_store_u32(uint32_t *code, hwaddr addr, uint32_t val)
{
- stl_p(code++, 0x82100000); /* mov %g0, %g1 */
- stl_p(code++, 0x84100000); /* mov %g0, %g2 */
- stl_p(code++, 0x03000000 +
+ stl_be_p(code++, 0x82100000); /* mov %g0, %g1 */
+ stl_be_p(code++, 0x84100000); /* mov %g0, %g2 */
+ stl_be_p(code++, 0x03000000 +
extract32(addr, 10, 22));
/* sethi %hi(addr), %g1 */
- stl_p(code++, 0x82106000 +
+ stl_be_p(code++, 0x82106000 +
extract32(addr, 0, 10));
/* or %g1, addr, %g1 */
- stl_p(code++, 0x05000000 +
+ stl_be_p(code++, 0x05000000 +
extract32(val, 10, 22));
/* sethi %hi(val), %g2 */
- stl_p(code++, 0x8410a000 +
+ stl_be_p(code++, 0x8410a000 +
extract32(val, 0, 10));
/* or %g2, val, %g2 */
- stl_p(code++, 0xc4204000); /* st %g2, [ %g1 ] */
+ stl_be_p(code++, 0xc4204000); /* st %g2, [ %g1 ] */
return code;
}
@@ -112,13 +112,13 @@ static void write_bootloader(void *ptr, hwaddr kernel_addr)
/* If we are running on a secondary CPU, jump directly to the kernel. */
- stl_p(p++, 0x85444000); /* rd %asr17, %g2 */
- stl_p(p++, 0x8530a01c); /* srl %g2, 0x1c, %g2 */
- stl_p(p++, 0x80908000); /* tst %g2 */
+ stl_be_p(p++, 0x85444000); /* rd %asr17, %g2 */
+ stl_be_p(p++, 0x8530a01c); /* srl %g2, 0x1c, %g2 */
+ stl_be_p(p++, 0x80908000); /* tst %g2 */
/* Filled below. */
sec_cpu_branch_p = p;
- stl_p(p++, 0x0BADC0DE); /* bne xxx */
- stl_p(p++, 0x01000000); /* nop */
+ stl_be_p(p++, 0x0BADC0DE); /* bne xxx */
+ stl_be_p(p++, 0x01000000); /* nop */
/* Initialize the UARTs */
/* *UART_CONTROL = UART_RECEIVE_ENABLE | UART_TRANSMIT_ENABLE; */
@@ -133,17 +133,17 @@ static void write_bootloader(void *ptr, hwaddr kernel_addr)
p = gen_store_u32(p, 0x80000318, 3);
/* Now, the relative branch above can be computed. */
- stl_p(sec_cpu_branch_p, 0x12800000
- + (p - sec_cpu_branch_p));
+ stl_be_p(sec_cpu_branch_p, 0x12800000
+ + (p - sec_cpu_branch_p));
/* JUMP to the entry point */
- stl_p(p++, 0x82100000); /* mov %g0, %g1 */
- stl_p(p++, 0x03000000 + extract32(kernel_addr, 10, 22));
- /* sethi %hi(kernel_addr), %g1 */
- stl_p(p++, 0x82106000 + extract32(kernel_addr, 0, 10));
- /* or kernel_addr, %g1 */
- stl_p(p++, 0x81c04000); /* jmp %g1 */
- stl_p(p++, 0x01000000); /* nop */
+ stl_be_p(p++, 0x82100000); /* mov %g0, %g1 */
+ stl_be_p(p++, 0x03000000 + extract32(kernel_addr, 10, 22));
+ /* sethi %hi(kernel_addr), %g1 */
+ stl_be_p(p++, 0x82106000 + extract32(kernel_addr, 0, 10));
+ /* or kernel_addr, %g1 */
+ stl_be_p(p++, 0x81c04000); /* jmp %g1 */
+ stl_be_p(p++, 0x01000000); /* nop */
}
static void leon3_cpu_reset(void *opaque)
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index d52e6a7213f..f375f0d389b 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -271,9 +271,9 @@ static unsigned long sun4m_load_kernel(const char *kernel_filename,
if (*initrd_size > 0) {
for (i = 0; i < 64 * TARGET_PAGE_SIZE; i += TARGET_PAGE_SIZE) {
ptr = rom_ptr(KERNEL_LOAD_ADDR + i, 24);
- if (ptr && ldl_p(ptr) == 0x48647253) { /* HdrS */
- stl_p(ptr + 16, INITRD_LOAD_ADDR);
- stl_p(ptr + 20, *initrd_size);
+ if (ptr && ldl_be_p(ptr) == 0x48647253) { /* HdrS */
+ stl_be_p(ptr + 16, INITRD_LOAD_ADDR);
+ stl_be_p(ptr + 20, *initrd_size);
break;
}
}
diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index 4ece1ac1ffc..e591e5a741a 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -210,9 +210,9 @@ static uint64_t sun4u_load_kernel(const char *kernel_filename,
if (*initrd_size > 0) {
for (i = 0; i < 64 * TARGET_PAGE_SIZE; i += TARGET_PAGE_SIZE) {
ptr = rom_ptr(*kernel_addr + i, 32);
- if (ptr && ldl_p(ptr + 8) == 0x48647253) { /* HdrS */
- stl_p(ptr + 24, *initrd_addr + *kernel_addr);
- stl_p(ptr + 28, *initrd_size);
+ if (ptr && ldl_be_p(ptr + 8) == 0x48647253) { /* HdrS */
+ stl_be_p(ptr + 24, *initrd_addr + *kernel_addr);
+ stl_be_p(ptr + 28, *initrd_size);
break;
}
}
--
2.45.2
next prev parent reply other threads:[~2024-10-04 16:41 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-04 16:30 [PATCH v2 00/25] misc: Use explicit endian LD/ST API Philippe Mathieu-Daudé
2024-10-04 16:30 ` [PATCH v2 01/25] gdbstub/helpers: Have ldtul_p() definition use ldn_p() Philippe Mathieu-Daudé
2024-10-05 1:10 ` Richard Henderson
2024-10-04 16:30 ` [PATCH v2 02/25] target/hexagon: Replace ldtul_p() -> ldl_p() Philippe Mathieu-Daudé
2024-10-05 1:08 ` Richard Henderson
2024-10-04 16:30 ` [PATCH v2 03/25] target/alpha: Replace ldtul_p() -> ldq_p() Philippe Mathieu-Daudé
2024-10-05 1:10 ` Richard Henderson
2024-10-04 16:30 ` [PATCH v2 04/25] target/s390x: " Philippe Mathieu-Daudé
2024-10-05 1:11 ` Richard Henderson
2024-10-04 16:30 ` [PATCH v2 05/25] gdbstub/helpers: Introduce ldtul_$endian_p() helpers Philippe Mathieu-Daudé
2024-10-05 1:13 ` Richard Henderson
2024-10-04 16:30 ` [PATCH v2 06/25] target/alpha: Use explicit little-endian LD/ST API Philippe Mathieu-Daudé
2024-10-05 1:13 ` Richard Henderson
2024-10-04 16:30 ` [PATCH v2 07/25] target/hexagon: " Philippe Mathieu-Daudé
2024-10-05 1:16 ` Richard Henderson
2024-10-04 16:30 ` [PATCH v2 08/25] hw/i386: " Philippe Mathieu-Daudé
2024-10-05 1:17 ` Richard Henderson
2024-10-04 16:30 ` [PATCH v2 09/25] target/i386: " Philippe Mathieu-Daudé
2024-10-05 1:18 ` Richard Henderson
2024-10-04 16:30 ` [PATCH v2 10/25] target/avr: " Philippe Mathieu-Daudé
2024-10-05 1:18 ` Richard Henderson
2024-10-04 16:30 ` [PATCH v2 11/25] linux-user/i386: " Philippe Mathieu-Daudé
2024-10-05 1:19 ` Richard Henderson
2024-10-04 16:30 ` [PATCH v2 12/25] target/loongarch: " Philippe Mathieu-Daudé
2024-10-05 1:22 ` Richard Henderson
2024-10-04 16:30 ` [PATCH v2 13/25] target/sh4: " Philippe Mathieu-Daudé
2024-10-07 19:59 ` Philippe Mathieu-Daudé
2024-10-04 16:30 ` [PATCH v2 14/25] target/tricore: " Philippe Mathieu-Daudé
2024-10-05 1:24 ` Richard Henderson
2024-10-04 16:30 ` [PATCH v2 15/25] target/rx: " Philippe Mathieu-Daudé
2024-10-04 16:30 ` [PATCH v2 16/25] target/riscv: " Philippe Mathieu-Daudé
2024-10-04 16:30 ` [PATCH v2 17/25] hw/m68k: Use explicit big-endian " Philippe Mathieu-Daudé
2024-10-04 16:40 ` Philippe Mathieu-Daudé
2024-10-05 1:29 ` Richard Henderson
2024-10-04 16:30 ` [PATCH v2 18/25] target/m68k: " Philippe Mathieu-Daudé
2024-10-04 16:41 ` Philippe Mathieu-Daudé
2024-10-04 16:30 ` Philippe Mathieu-Daudé [this message]
2024-10-04 16:30 ` [PATCH v2 20/25] target/sparc: " Philippe Mathieu-Daudé
2024-10-04 16:30 ` [PATCH v2 21/25] target/hppa: " Philippe Mathieu-Daudé
2024-10-04 16:30 ` [PATCH v2 22/25] hw/s390x: " Philippe Mathieu-Daudé
2024-10-07 5:54 ` Thomas Huth
2024-10-04 16:30 ` [PATCH v2 23/25] target/s390x: " Philippe Mathieu-Daudé
2024-10-07 5:57 ` Thomas Huth
2024-10-04 16:30 ` [PATCH v2 24/25] target/openrisc: " Philippe Mathieu-Daudé
2024-10-04 16:30 ` [PATCH v2 25/25] hw/ppc/e500: " Philippe Mathieu-Daudé
2024-10-04 16:39 ` [PATCH v2 00/25] misc: Use explicit endian " Philippe Mathieu-Daudé
2024-10-05 1:39 ` Richard Henderson
2024-10-07 7:52 ` Pierre Muller
2024-10-07 14:40 ` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241004163042.85922-20-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).