Patch to run on linux m68k

Remi Perrot r_perrot at mail.club-internet.fr
Sat May 23 02:13:39 PDT 1998


Here is my very fist contribution to the free software.

Since there is no jdk running on linux m68k I'm interested
in Kaffe but I have been desapointed when I have tried to
compile it on my amiga and so I decided to make it run on it
at least on interpreter mode.

Unfortunately the problem come from the asm code in config.h.
Since I don't know neither m68k asm nor i386 asm it my work is
not perfect but it's beter than nothing.

With this patch all the test pass but those thread related for
which I've got:

java.lang.NullPointerException
        at java/lang/Thread.<init>(84)
        at java/lang/Thread.<init>(line unknown, pc 0x6)
        at btest.<init>(line unknown, pc 0x1)
        at DeadThread.main(18)

------------
diff -ru kaffe-snap.orig/config/m68k/common.h kaffe-snap/config/m68k/common.h
--- kaffe-snap.orig/config/m68k/common.h        Sat May 23 00:41:58 1998
+++ kaffe-snap/config/m68k/common.h     Sat May 23 00:13:28 1998
@@ -7,55 +7,53 @@
  *
  * See the file "license.terms" for information on usage and redistribution 
  * of this file. 
+ *
+ * Written by Rémi Perrot <remi.perrot at mail.dotcom.fr>
  */
 
 #ifndef __m68k_common_h
 #define __m68k_common_h
 
-#if 0
-#define        NO_KAFFE_STUBS
-#define        sysdepCallMethod(CALL)                                          \
-       asm volatile ("                                                 \n\
-               ld [%2],%%o0                                            \n\
-               ld [%2+4],%%o1                                          \n\
-               ld [%2+8],%%o2                                          \n\
-               ld [%2+12],%%o3                                         \n\
-               ld [%2+16],%%o4                                         \n\
-               ld [%2+20],%%o5                                         \n\
-               call %1,0                                               \n\
-               nop                                                     \n\
-               st [%0],%%o0                                            \n\
-       " :                                                             \
-         : "r" ((CALL)->ret),                                          \
-           "r" ((CALL)->function),                                     \
-           "r" ((CALL)->args)                                          \
-         : "g1" , "g2", "g3", "g4", "o0", "o1", "o2", "o3", "o4", "o5", "o7" )
-
-#define        CALL_KAFFE_METHOD_VARARGS(meth, obj, nargs, argptr, retval)     \
-
-       movem%.l %/d0-%/d7/%/a0-%/a5,%-
-       fmovem %/fp0-%/fp7,%-
-
-       move%.l %3,%/d0
-       beq 2f
-       lea 0(%4,%/d0:l*4),%/a0
-       subq %#1,%/d0
-1:     move%.l -(%/a0),%-
-       dbra %/d0, 1b
-
-2:     move%.l %2,%-
-       jsr (%1)
-       move%.l %5,%/d1
-       addl %/d1,%/sp
-       move%.l %/d0,%0
-       fmovem %+,%/fp0-%/fp7
-       movem%.l %+,%/d0-%/d7/%/a0-%/a5
-
-       : "=m"(retval)                                          \
-       : "a"(meth->ncode), "g"(obj), "g"(nargs), "a"(argptr),  \
-         "m"(4*(nargs+1))                                      \
-       : "cc", "memory")
-
-#endif
-
+#define        sysdepCallMethod(CALL)                                          \
+               asm volatile ("                                       \n\
+       1:                                                            \n\
+               cmp.l   #0,%0                                         \n\
+                beq     3f                                            \n\
+               subq.l  #1,%0                                         \n\
+               cmp.b   #0,(%2,%0.l)                                  \n\
+               beq     1b                                            \n\
+               cmp.b   #1,(%2,%0.l)                                  \n\
+               beq     2f                                            \n\
+               move.l  4(%1,%0.l*8),-(%%sp)                          \n\
+       2:                                                            \n\
+               move.l  (%1,%0.l*8),-(%%sp)                           \n\
+                jmp     1b                                            \n\
+       3:                                                            \n\
+               jsr     (%3)                                          \n\
+               cmp.b   #0x46,%4                                      \n\
+               bne     4f                                            \n\
+               fmove.s %%fp0,(%5)                                    \n\
+               jmp     6f                                            \n\
+       4:                                                            \n\
+               cmp.b   #0x44,%4                                      \n\
+               bne     5f                                            \n\
+               fmove.d %%fp0,(%5)                                    \n\
+               jmp     6f                                            \n\
+       5:                                                            \n\
+               move.l  %%d0,(%5)                                     \n\
+               cmp.b   #0x4a,%4                                      \n\
+               bne     6f                                            \n\
+               move.l  %%d1,4(%5)                                    \n\
+       6:                                                              \
+        " :                                                             \
+         : "r" ((CALL)->nrargs),                                       \
+           "a" ((CALL)->args),                                         \
+           "a" ((CALL)->callsize),                                     \
+           "a" ((CALL)->function),                                     \
+            "m" ((CALL)->rettype),                                      \
+            "a" ((CALL)->ret)                                           \
+          : "d0", "d1", "fp0", "cc", "memory");                         \
+               asm volatile ("                                       \n\
+               add.w %0,%%sp                                         \n\
+        " : : "r" ((CALL)->argsize * sizeof(jint)) : "cc")
 #endif
diff -ru kaffe-snap.orig/config/m68k/linux/md.h kaffe-snap/config/m68k/linux/md.h
--- kaffe-snap.orig/config/m68k/linux/md.h      Sat May 23 00:41:59 1998
+++ kaffe-snap/config/m68k/linux/md.h   Sun May 17 21:20:02 1998
@@ -12,6 +12,7 @@
 #ifndef __m68k_linux_md_h
 #define __m68k_linux_md_h
 
+#include "m68k/common.h"
 #include "m68k/threads.h"
 
 #if defined(TRANSLATOR)
diff -ru kaffe-snap.orig/config/m68k/threads.h kaffe-snap/config/m68k/threads.h
--- kaffe-snap.orig/config/m68k/threads.h       Sat May 23 00:42:00 1998
+++ kaffe-snap/config/m68k/threads.h    Sun May 17 18:32:53 1998
@@ -27,6 +27,6 @@
  * This is the offset into the setjmp buffer where the stack pointer is
  * stored.  This may be different with different OSes.
  */
-#define        SP_OFFSET               ?
+#define        SP_OFFSET               14
 
 #endif
diff -ru kaffe-snap.orig/kaffe/kaffevm/systems/unix-jthreads/config-jthreads.h kaffe-snap/kaffe/kaffevm/systems/unix-jthreads/config-jthreads.h
--- kaffe-snap.orig/kaffe/kaffevm/systems/unix-jthreads/config-jthreads.h       Sat May 23 00:42:03 1998
+++ kaffe-snap/kaffe/kaffevm/systems/unix-jthreads/config-jthreads.h    Fri May 22 23:26:52 1998
@@ -46,8 +46,12 @@
 #define SP_OFFSET               2
 #define HAVE_SYS_FILIO_H 1
 
-#elif defined(__linux__)
-/* Linux */
+#elif defined(__linux__) && defined(mc68000)
+/* Linux m68k */
+#define SP_OFFSET              14
+
+#elif defined(__linux__) && defined(i386)
+/* Linux i386 */
 #define SP_OFFSET              4
 
 #elif defined(__svr4__) && defined(__sparc__)



Ad'tchao,

--- 
remi.perrot at mail.dotcom.fr (Remi Perrot)



More information about the kaffe mailing list