[kaffe] Coldfire/m68k patch

Roland Lezuo roland.lezuo at chello.at
Tue Jun 5 05:05:54 PDT 2007


Hello!

I've spent the last days with porting kaffe to a coldfire CPU. Coldfire
implements a subset of m68k so porting was straight forward. Here is
what I did to successfully compile kaffe-cvs. The jit3 engine works, but
i could not test it a lot as pthreads makes problems and kaffe hangs
when initializing the threading system. 

If anyone could help with this one I did continue porting the jit3
engine.

regards
roland lezuo

P.S.: please CC me personally as I'm not subscribed.

Here is the backtrace:

0x4015c39e in __pthread_sigsuspend () from /lib/libpthread.so.0
(gdb) bt
#0  0x4015c39e in __pthread_sigsuspend () from /lib/libpthread.so.0
#1  0x4015b5d2 in __pthread_wait_for_restart_signal ()
from /lib/libpthread.so.0
#2  0x40159034 in pthread_cond_wait@@GLIBC_2.4 ()
from /lib/libpthread.so.0
#3  0x40076002 in jcondvar_wait (cv=0x8030efcc, mux=0x8030efb4,
timeout=-1) at lock-impl.c:118
#4  0x4004a48a in ksem_get (sem=0x8030efb4, timeout=-1) at ksem.c:62
#5  0x40050dc8 in startSpecialThread (arg=0xbffff78c) at thread.c:355
#6  0x400785dc in tRun (p=0x8030efa8) at thread-impl.c:787
#7  0x40159ee6 in pthread_start_thread () from /lib/libpthread.so.0
#8  0x40159f5a in pthread_start_thread_event ()
from /lib/libpthread.so.0
#9  0x4024651e in thread_start () from /lib/libc.so.6

Here are the last few lines of kaffe -verbosecall hello

soft_trace: java/util/AbstractMap
$BasicMapEntry.<init>(Ljava/lang/Object;Ljava/lang/Object;)V
soft_trace: java/security/PermissionCollection.setReadOnly()V
soft_trace:
java/security/ProtectionDomain.<init>(Ljava/security/CodeSource;Ljava/security/PermissionCollection;)V
soft_trace:
java/security/ProtectionDomain.<init>(Ljava/security/CodeSource;Ljava/security/PermissionCollection;Ljava/lang/ClassLoader;[Ljava/security/Principal;Z)V
soft_trace: java/security/PermissionCollection.setReadOnly()V
soft_trace:
java/lang/Thread.<init>(Ljava/lang/VMThread;Ljava/lang/String;IZ)V
soft_trace: java/lang/Class.forName(Ljava/lang/String;)Ljava/lang/Class;
soft_trace:
java/lang/ClassLoader.getSystemClassLoader()Ljava/lang/ClassLoader;
soft_trace:
java/lang/Thread.<init>(Ljava/lang/VMThread;Ljava/lang/String;IZ)V
^^
hangs here forever.




There is no cas.l instrcution for coldfire, so the generic
implementation for atmicity needs to be used.

Index: common.h
===================================================================
RCS file: /cvs/kaffe/kaffe/config/m68k/common.h,v
retrieving revision 1.18
diff -u -r1.18 common.h
--- common.h    17 Apr 2005 20:36:41 -0000      1.18
+++ common.h    5 Jun 2007 11:47:08 -0000
@@ -27,7 +27,11 @@
 #include "generic/gentypes.h"
 
 #include "gccbuiltin.h"
+#if 0
 #include "atomic.h"
+#else
+#include "generic/genatomic.h"
+#endif
 #include "katomic.h"
 #include "generic/comparexch.h"


Some forms of opcodes are not available on coldfire, but they are
already optinal used anyways - good! 
One would need to add a coldfire configure option and collect this
defines in one place for a merge.

 
Index: jit3-icode.h
===================================================================
RCS file: /cvs/kaffe/kaffe/config/m68k/jit3-icode.h,v
retrieving revision 1.4
diff -u -r1.4 jit3-icode.h
--- jit3-icode.h        28 May 2005 03:01:45 -0000      1.4
+++ jit3-icode.h        5 Jun 2007 11:47:09 -0000
@@ -149,6 +149,7 @@
 #define HAVE_swap_any                  swap_RxR
 #endif
 
+#define HAVE_NO_MULINTCONST
 #if !defined(HAVE_NO_MULINTCONST)
 #define HAVE_mul_int_const             muli_RRC
 #endif


Index: jit3-m68k.def
===================================================================
RCS file: /cvs/kaffe/kaffe/config/m68k/jit3-m68k.def,v
retrieving revision 1.16
diff -u -r1.16 jit3-m68k.def
--- jit3-m68k.def       9 May 2007 13:43:52 -0000       1.16
+++ jit3-m68k.def       5 Jun 2007 11:47:10 -0000
@@ -108,6 +108,8 @@
        WOUT(0xD080 | (dst << 9) | (MODE_d << 3) | (src & 7));
 }
 
+#define HAVE_NO_ADDAW
+
 #if !defined(HAVE_NO_ADDAW)
 static inline void
 op_addaw_ia(int imm, int dst)
@@ -743,6 +745,8 @@
        LOUT(imm);
 }
 
+#define HAVE_NO_MOVEM
+
 #if !defined(HAVE_NO_MOVEM)
 static inline void
 op_moveml_ro(int mask, int areg, int disp)
@@ -878,6 +882,8 @@
        assert_dreg(dst);
        WOUT(0x9080 | (dst << 9) | (MODE_d << 3) | src);
 }
+
+#define HAVE_NO_SUBAW
 
 #if !defined(HAVE_NO_SUBAW)
 static inline void



The modification for trampolines.S could be merged right now. addql is
not longer than addqw, and i think m68k also has the addql opcode (not
sure).

Index: trampolines.S
===================================================================
RCS file: /cvs/kaffe/kaffe/config/m68k/trampolines.S,v
retrieving revision 1.3
diff -u -r1.3 trampolines.S
--- trampolines.S       29 Jun 2005 17:23:38 -0000      1.3
+++ trampolines.S       5 Jun 2007 11:47:12 -0000
@@ -35,7 +35,7 @@
 
 C_FUNC_NAME(m68k_do_fixup_trampoline) :
      jbsr   C_FUNC_NAME(soft_fixup_trampoline)
-     addqw     #4,%sp
+     addql     #4,%sp
      movel     %d0,%a0
      jmp     %a0@
 
@@ -48,7 +48,7 @@
 C_FUNC_NAME(m68k_do_fixup_trampoline) :
 
      jbsr    C_FUNC_NAME(soft_fixup_trampoline)
-     addqw   #4,sp
+     addql   #4,sp
      movel   d0,a0
      jmp     a0@
 
cvs server: Diffing a-ux
cvs server: Diffing amigaos
cvs server: Diffing linux


The +32 seems to be odd. I figured out that some cacheflush operations
try to flush beyond the address space, which is checked by
sys_cacheflush and the syscall is aborted without flushing any bytes
which is not what ones want. 


Index: linux/clear-cache.h
===================================================================
RCS file: /cvs/kaffe/kaffe/config/m68k/linux/clear-cache.h,v
retrieving revision 1.2
diff -u -r1.2 clear-cache.h
--- linux/clear-cache.h 4 Jul 2005 00:03:51 -0000       1.2
+++ linux/clear-cache.h 5 Jun 2007 11:47:12 -0000
@@ -39,7 +39,7 @@
 {
\
   register unsigned long _beg __asm ("%d1") = (unsigned long) (BEG);
\
   unsigned long _end = (unsigned long) (END);
\
-  register unsigned long _len __asm ("%d4") = (_end - _beg + 32);
\
+  register unsigned long _len __asm ("%d4") = (_end - _beg);   \
   __asm __volatile
\
     ("move%.l #123, %/d0\n\t"  /* system call nr */
\
      "move%.l #1, %/d2\n\t"    /* clear lines */
\

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5112 bytes
Desc: not available
Url : http://kaffe.org/pipermail/kaffe/attachments/20070605/6b1d19d1/attachment-0001.bin 


More information about the kaffe mailing list