Skip to contentSkip to conversation

patches for SH4 system emulation

PATCH Applied Shin-ichiro KAWASAKI 3 participants 6 messages Aug 18, 2008 – Aug 22, 2008

lore
Share & tools
lore
#0 lore raw

cover patches for SH4 system emulation

Hello all,

To improve SH4 system emulation, I'm sending five patches which implement some MMU featrues, bug fixes, and sleep instruction.
With these patches, simple '/init' scripts can be executed after Linux kernel boot. I saw BusyBox ash's prompt is printed, though I cannot input key types because serial controler's implementation is not enough.

The kernel and command line I used to check is available here.
http://www.assembla.com/wiki/show/qemu-sh4/BuildingEnvironment

I hope these patches will help and merged in trunk. Any comments will be welcome.

Regards,
Shin-ichiro KAWASAKI

#1 lore raw
Quoted 8 lines · Shin-ichiro KAWASAKI

Hello all,

To improve SH4 system emulation, I'm sending five patches which implement some MMU featrues, bug fixes, and sleep instruction.
With these patches, simple '/init' scripts can be executed after Linux kernel boot. I saw BusyBox ash's prompt is printed, though I cannot input key types because serial controler's implementation is not enough.

Quoted 5 lines

The kernel and command line I used to check is available here.
http://www.assembla.com/wiki/show/qemu-sh4/BuildingEnvironment

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

Jan

#2 lore raw
Quoted 11 lines · Jan Kiszka
Quoted 2 lines

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 ===

target-sh4/op.c +0 -0
diff -ruwN a/target-sh4/op.c b/target-sh4/op.c
@@ -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;
target-sh4/translate.c +0 -0
diff -ruwN a/target-sh4/translate.c b/target-sh4/translate.c
@@ -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();
#3 lore raw
Quoted 20 lines · Shin-ichiro KAWASAKI
Quoted 11 lines · Jan Kiszka
Quoted 2 lines

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.

Quoted 4 lines

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.

Thanks, applied.

Signature · 4 lines
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   [email protected]         | [email protected]
   `-    people.debian.org/~aurel32 | www.aurel32.net
#4 lore raw
In reply to Shin-ichiro KAWASAKI
Quoted 8 lines · Shin-ichiro KAWASAKI

Hello all,

To improve SH4 system emulation, I'm sending five patches which implement some MMU featrues, bug fixes, and sleep instruction.
With these patches, simple '/init' scripts can be executed after Linux kernel boot. I saw BusyBox ash's prompt is printed, though I cannot input key types because serial controler's implementation is not enough.

Quoted 6 lines

The kernel and command line I used to check is available here.
http://www.assembla.com/wiki/show/qemu-sh4/BuildingEnvironment

I hope these patches will help and merged in trunk. Any comments will be welcome.

All patches of the series committed, thanks.

By the way, do you have any plan to convert the SH4 target to TCG? It is one of the few missing targets.

Signature · 4 lines
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   [email protected]         | [email protected]
   `-    people.debian.org/~aurel32 | www.aurel32.net
#5 lore raw
Quoted 9 lines · Aurelien Jarno
Quoted 8 lines · Shin-ichiro KAWASAKI

Hello all,

To improve SH4 system emulation, I'm sending five patches which implement some MMU featrues, bug fixes, and sleep instruction.
With these patches, simple '/init' scripts can be executed after Linux kernel boot. I saw BusyBox ash's prompt is printed, though I cannot input key types because serial controler's implementation is not enough.

Quoted 8 lines
Quoted 6 lines

The kernel and command line I used to check is available here.
http://www.assembla.com/wiki/show/qemu-sh4/BuildingEnvironment

I hope these patches will help and merged in trunk. Any comments will be welcome.

All patches of the series committed, thanks.

Thanks a lot!

Quoted 1 line

By the way, do you have any plan to convert the SH4 target to TCG?

Yes. I've just started working to eliminate target-sh4/op.c.

Regards,
Shin-ichiro KAWASAKI