[kaffe] patch for pxa

Gérard Basler gerard.basler at starticket.ch
Thu Jan 22 08:46:02 PST 2004


Hi!

I've fixed the cache problem. At least for linux...

Gérard

--- kaffe/config/arm/linux/md.c 2002-10-19 13:04:41.000000000 +0200
+++ kaffe-jit/config/arm/linux/md.c     2004-01-22 17:36:04.000000000
+0100
@@ -12,6 +12,7 @@
 #include "config.h"
 #include <malloc.h>
 #include <sched.h>
+#include <asm/unistd.h>

 void
 init_md(void)
@@ -21,18 +22,17 @@
 #endif
 }

-#define CACHE_SIZE (32 * 1024)
-#define LINE_SIZE sizeof(int)
-#define CACHE_LINES (CACHE_SIZE / LINE_SIZE)
-
-static volatile int flusher[CACHE_LINES];
-
-void
-flush_dcache(void)
-{
-        int i;
-        for (i = 0; i < CACHE_LINES; i++) {
-                flusher[i]++;
-        }
-        sched_yield();
+/**
+ * Shamelessly stolen from parrot... ([perl]/parrot/jit/arm/jit_emit.h
arm_sync_d_i_cache)
+ *
+ * r2 should be zero for 2.4 (but it's ignored) so passing VM_EXEC
(needed for 2.6) should be okay.
+ */
+void flush_dcache(void *start, void *end) {
+  __asm __volatile ("mov r0, %0\n"
+                   "mov r1, %1\n"
+                   "mov r2, #VM_EXEC\n"
+                   "swi " __sys1(__ARM_NR_cacheflush) "\n"
+                   : /* no return value */
+                   : "r" ((long)start), "r" ((long)end)
+                   : "r0","r1","r2");
 }
--- kaffe/config/arm/jit.h      2004-01-19 18:48:01.000000000 +0100
+++ kaffe-jit/config/arm/jit.h  2004-01-22 17:26:19.000000000 +0100
@@ -302,9 +302,8 @@
 /* Wrap up a native call for the JIT */
 #define KAFFEJIT_TO_NATIVE(M)

-/* For now, ignore BEG and END since we flush the complete I&D cache
FIXME */
-extern void flush_dcache(void);
-#define        FLUSH_DCACHE(BEG, END)  flush_dcache()
+extern void flush_dcache(void *start, void *end);
+#define        FLUSH_DCACHE(BEG, END) flush_dcache(BEG, END)

 #if defined(JIT3)
 /*
--- kaffe/config/arm/riscos/md.c        2003-02-26 00:19:58.000000000
+0100
+++ kaffe-jit/config/arm/riscos/md.c    2004-01-22 17:42:14.000000000
+0100
@@ -17,14 +17,14 @@
 }

 /* This may not be correct for all ARMs, e.g. XScale */
+/* If you ever have to change it: Set CACHE_SIZE to 2x real cache size
*/
 #define CACHE_SIZE (32 * 1024)
 #define LINE_SIZE sizeof(int)
 #define CACHE_LINES (CACHE_SIZE / LINE_SIZE)

 static volatile int flusher[CACHE_LINES];

-void
-flush_dcache(void)
+void flush_dcache(void *start, void *end);
 {
         int cache_line;
--- kaffe/config/arm/netbsd1/md.c       1999-10-16 05:16:24.000000000
+0200
+++ kaffe-jit/config/arm/netbsd1/md.c   2004-01-22 17:42:21.000000000
+0100
@@ -18,8 +18,7 @@

 static volatile int flusher[CACHE_LINES];

-void
-flush_dcache(void)
+void flush_dcache(void *start, void *end);
 {
         int i;
         for (i = 0; i < CACHE_LINES; i++) {






More information about the kaffe mailing list