Fix LDC, LDC_W, and INSTANCEOF opcodes, more debugging
[jamvm-avr32-jem.git] / src / arch / avr32.h
blob1ad9b4be68aa642d413551bdd77c1b1f750dbe76
1 /*
2 * Copyright (C) 2003, 2004, 2005, 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 #define OS_ARCH "avr32"
23 //#ifndef DEBUG
24 //#define DEBUG
25 //#endif
27 /* Override default min and max heap sizes. AVR32 machines are
28 usually embedded, and the standard defaults are too large. */
29 #define DEFAULT_MAX_HEAP 8*MB
30 #define DEFAULT_MIN_HEAP 1*MB
32 #define HANDLER_TABLE_T static const void
33 #define DOUBLE_1_BITS 0x3ff0000000000000LL
35 #define READ_DBL(v,p,l) v = ((u8)p[0]<<56)|((u8)p[1]<<48)|((u8)p[2]<<40) \
36 |((u8)p[3]<<32)|((u8)p[4]<<24)|((u8)p[5]<<16) \
37 |((u8)p[6]<<8)|(u8)p[7]; p+=8
39 //extern void setDoublePrecision();
40 #define FPU_HACK
42 //see C:\Cygwin\usr\local\avr32-linux\include\bits\atomicity.h
43 //see http://www.avr32linux.org/twiki/bin/view/Main/AtomicOperations
44 //see http://www.mail-archive.com/uclibc@uclibc.org/msg00914.html
45 //http://www.avr32linux.org/twiki/pub/Main/MicroClibcPatches/uClibc-0.9.28-avr32-20060621.patch
46 //http://www.google.com/codesearch?hl=en&q=+cmpxchg+avr32+show:WwwDfOAAdbA:L2BlPHy6h_g:nY7RakaTOnE&sa=N&cd=1&ct=rc&cs_p=http://gobo.calica.com/packages/official/Linux--2.6.20.4-r1--i686.tar.bz2&cs_f=Linux/2.6.20.4/Resources/Unmanaged/Files/Compile/Sources/linux-2.6.20.4/include/asm-avr32/system.h#first
49 * The original avr32 compare_and_swap is different from
50 * all other versions (arm, ppc, i386), even varying from
51 * implementation in uClibc. It simply returns the value
52 * stored in the addr, which makes no sense for the lock.
53 * Replace with the in uClibc implementation
55 extern int avr32_compare_and_swap(uintptr_t* addr, uintptr_t old_val,
56 uintptr_t new_val);
58 #define COMPARE_AND_SWAP(addr, old_val, new_val) \
59 avr32_compare_and_swap(addr, old_val, new_val)
61 #define FLUSH_CACHE(addr, length)
63 #define LOCKWORD_READ(addr) *addr
64 #define LOCKWORD_WRITE(addr, value) *addr = value
65 #define LOCKWORD_COMPARE_AND_SWAP(addr, old_val, new_val) \
66 COMPARE_AND_SWAP(addr, old_val, new_val)
68 #define UNLOCK_MBARRIER() __asm__ __volatile__ ("" ::: "memory")
69 #define JMM_LOCK_MBARRIER() __asm__ __volatile__ ("" ::: "memory")
70 #define JMM_UNLOCK_MBARRIER() __asm__ __volatile__ ("" ::: "memory")
72 //TODO: lto
73 #define MBARRIER() __asm__ __volatile__ ("" ::: "memory")
74 //#define MBARRIER() __asm__ __volatile__ ("lock; addl $0,0(%%esp)" ::: "memory")