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>
29 /* Change floating point precision to double (64-bit) from
30 * the extended (80-bit) Linux default. */
32 //void setDoublePrecision() {
36 // cw &= ~_FPU_EXTENDED;
41 //real global trap table used for JEM
46 extern size_t trap_h_size
;
48 static char *trap_handler(void)
54 " sub %[trap], -8\n" /* Return pointer to trap label */
55 " bral 1f\n" /* Leave the function */
56 /* The actual trap-handler */
57 "trap: mov r12, pc\n" /* Store trap entry point */
60 " .globl trap_h_size\n" /* and its size */
63 " .size trap_h_size, . - trap_h_size\n"
70 void initialisePlatform() {
71 //TODO: is this needed for avr32? setDoublePrecision();
74 * Setup the real traps,the entries are actually loaded when entering
75 * the interpreter engine
77 char *trap_b
, *trap_aligned
, *trap_h
;
80 trap_b
= mmap(0, 8192, PROT_READ
| PROT_WRITE
| PROT_EXEC
, MAP_SHARED
| MAP_ANONYMOUS
, 0, 0);
81 if (trap_b
== MAP_FAILED
)
84 trap_aligned
= (void *)(((unsigned long)trap_b
+ 4095) & ~4095);
86 trap_h
= trap_handler();
88 for (i
= 0; i
< 24; i
++) {
89 memcpy(trap_aligned
+ i
* 0x80, trap_h
, trap_h_size
);
90 printf("%p\n", trap_aligned
+ i
* 0x80);
93 syscall(__NR_java_settrap
, trap_aligned
);