2 * Copyright (C) 2003, 2004, 2006, 2007
3 * Robert Lougher <rob@lougher.org.uk>.
5 * This file is part of JamVM.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2,
10 * or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //#include <fpu_control.h>
24 #include <sys/syscall.h>
27 #include <asm/cachectl.h>
29 #include "arch/avr32_jem.h"
31 /* Change floating point precision to double (64-bit) from
32 * the extended (80-bit) Linux default. */
34 //void setDoublePrecision() {
38 // cw &= ~_FPU_EXTENDED;
44 extern size_t trap_h_size
;
46 static char *trap_handler(void)
52 " sub %[trap], -8\n" /* Return pointer to trap label */
53 " bral 1f\n" /* Leave the function */
54 /* The actual trap-handler */
55 "trap: mov r12, pc\n" /* Store trap entry point */
56 " .globl debug_jem_trap\n"
59 " .globl trap_h_size\n" /* and its size */
62 " .size trap_h_size, . - trap_h_size\n"
69 extern int do_jamInstrps(struct jem_state
*jem
);
72 void initialisePlatform(void)
74 //TODO: is this needed for avr32? setDoublePrecision();
77 * Setup the real traps,the entries are actually loaded when entering
78 * the interpreter engine
80 char *trap_b
, *trap_aligned
, *trap_h
;
83 trap_b
= mmap(0, 8192, PROT_READ
| PROT_WRITE
| PROT_EXEC
, MAP_SHARED
| MAP_ANONYMOUS
, 0, 0);
84 if (trap_b
== MAP_FAILED
)
87 trap_aligned
= (void *)(((unsigned long)trap_b
+ 4095) & ~4095);
89 trap_h
= trap_handler();
91 for (i
= 0; i
< 24; i
++) {
93 memcpy(trap_aligned
+ i
* 0x80, trap_h
, trap_h_size
);
94 printf("%p:", trap_aligned
+ i
* 0x80);
95 for (j
= 0; j
< trap_h_size
; j
++)
96 printf(" %02x", trap_aligned
[i
* 0x80 + j
]);
100 /* Clean the data cache, flush the instruction cache */
101 syscall(__NR_cacheflush
, CACHE_IFLUSH
, trap_aligned
, 4096);
102 syscall(__NR_java_settrap
, trap_aligned
);