From: Shin-ichiro KAWASAKI <kawasaki@juno.dti.ne.jp>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Re: [PATCH 0/5] [sh4] patches for SH4 system emulation
Date: Sat, 23 Aug 2008 04:54:50 +0900 [thread overview]
Message-ID: <48AF198A.9040505@juno.dti.ne.jp> (raw)
In-Reply-To: <48AD1A2C.1030609@web.de>
Jan Kiszka wrote:
>> I hope these patches will help and merged in trunk.
>> Any comments will be welcome.
>
> I cannot comment on your patches, but maybe you can comment on (or test)
> the tas.b issue of qemu's sh4 emulation
>
> http://comments.gmane.org/gmane.comp.emulators.qemu/27235
>
> specifically the last proposed solution
>
> http://permalink.gmane.org/gmane.comp.emulators.qemu/27337
Andrzej's two patches are both seem to be consistent with tas.b
specification.
To make it sure, I've taken out a function, __pthread_spin_trylock(),
from glibc's linuxthreads/sysdeps/sh/pspinlock.c, as the test code for
tas.b. I confirmed that current QEMU implementation fails
this test, and whichever of the two patches makes it pass the test.
In my opinion, the first patch is the better, because it is smaller and
easier to understand. I add the patch to the end of this mail again,
which is modified to avoid patch failure.
FYI, I add the test code, too.
Regards,
Shin-ichiro KAWASAKI
=== test code starts here ===
#include <stdio.h>
typedef volatile int pthread_spinlock_t;
#define EBUSY 16
int
__pthread_spin_trylock (pthread_spinlock_t *lock)
{
unsigned int val;
asm volatile ("tas.b @%1; movt %0"
: "=r" (val)
: "r" (lock)
: "memory");
return val ? 0 : EBUSY;
}
int main(int argc, char * argv[])
{
pthread_spinlock_t lock = 0;
printf("test #1 : ");
printf(" %s.\n", __pthread_spin_trylock(&lock) ? "NG" : "ok");
printf("test #2 : ");
printf(" %s.\n", __pthread_spin_trylock(&lock) ? "ok" : "NG");
}
=== test code ends ===
diff -ruwN a/target-sh4/op.c b/target-sh4/op.c
--- a/target-sh4/op.c 2008-08-22 17:57:27.000000000 +0900
+++ b/target-sh4/op.c 2008-08-23 03:42:30.000000000 +0900
@@ -592,13 +592,6 @@
RETURN();
}
-void OPPROTO op_tasb_rN(void)
-{
- cond_t((env->gregs[PARAM1] & 0xff) == 0);
- *(int8_t *) &env->gregs[PARAM1] |= 0x80;
- RETURN();
-}
-
void OPPROTO op_movl_T0_rN(void)
{
env->gregs[PARAM1] = T0;
diff -ruwN a/target-sh4/translate.c b/target-sh4/translate.c
--- a/target-sh4/translate.c 2008-08-22 17:58:00.000000000 +0900
+++ b/target-sh4/translate.c 2008-08-23 03:42:30.000000000 +0900
@@ -1100,7 +1100,12 @@
gen_op_shlr16_Rn(REG(B11_8));
return;
case 0x401b: /* tas.b @Rn */
- gen_op_tasb_rN(REG(B11_8));
+ gen_op_movl_rN_T0(REG(B11_8));
+ gen_op_movl_T0_T1();
+ gen_op_ldub_T0_T0(ctx);
+ gen_op_cmp_eq_imm_T0(0);
+ gen_op_or_imm_T0(0x80);
+ gen_op_stb_T0_T1(ctx);
return;
case 0xf00d: /* fsts FPUL,FRn - FPSCR: Nothing */
gen_op_movl_fpul_FT0();
next prev parent reply other threads:[~2008-08-22 19:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-18 16:20 [Qemu-devel] [PATCH 0/5] [sh4] patches for SH4 system emulation Shin-ichiro KAWASAKI
2008-08-21 7:33 ` [Qemu-devel] " Jan Kiszka
2008-08-22 19:54 ` Shin-ichiro KAWASAKI [this message]
2008-08-22 21:30 ` Aurelien Jarno
2008-08-22 9:00 ` [Qemu-devel] " Aurelien Jarno
2008-08-22 20:03 ` Shin-ichiro KAWASAKI
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=48AF198A.9040505@juno.dti.ne.jp \
--to=kawasaki@juno.dti.ne.jp \
--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).