From: Vladimir Prus <vladimir@codesourcery.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [SH4] Fix swap.b
Date: Sun, 12 Oct 2008 19:21:05 +0400 [thread overview]
Message-ID: <200810121921.05267.vladimir@codesourcery.com> (raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1324 bytes --]
The SH4 manual documents the swap.b instruction as follows:
SWAP.B Rm,Rn
Rm → swap lower 2 bytes → Rn
Current QEMU code, in addition to the above, also clears the high
16 bits. The immediate breakage I saw is that htonl function applied
to netmask of 255.255.255.0 gives 0, which breaks all networking.
Attached patch fixes the problem.
- Volodya
---
target-sh4/translate.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/target-sh4/translate.c b/target-sh4/translate.c
index 365936f..2ef8c00 100644
--- a/target-sh4/translate.c
+++ b/target-sh4/translate.c
@@ -686,7 +686,9 @@ void _decode_opc(DisasContext * ctx)
return;
case 0x6008: /* swap.b Rm,Rn */
{
- TCGv high, low;
+ TCGv highw, high, low;
+ highw = tcg_temp_new(TCG_TYPE_I32);
+ tcg_gen_andi_i32(highw, REG(B7_4), 0xffff0000);
high = tcg_temp_new(TCG_TYPE_I32);
tcg_gen_ext8u_i32(high, REG(B7_4));
tcg_gen_shli_i32(high, high, 8);
@@ -694,6 +696,7 @@ void _decode_opc(DisasContext * ctx)
tcg_gen_shri_i32(low, REG(B7_4), 8);
tcg_gen_ext8u_i32(low, low);
tcg_gen_or_i32(REG(B11_8), high, low);
+ tcg_gen_or_i32(REG(B11_8), REG(B11_8), highw);
tcg_temp_free(low);
tcg_temp_free(high);
}
--
1.5.3.5
next reply other threads:[~2008-10-12 15:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-12 15:21 Vladimir Prus [this message]
2008-10-12 23:31 ` [Qemu-devel] [SH4] Fix swap.b Aurelien Jarno
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=200810121921.05267.vladimir@codesourcery.com \
--to=vladimir@codesourcery.com \
--cc=qemu-devel@nongnu.org \
/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).