| 1 : |
anton
|
1.12
|
/* This is the machine-specific part for a SPARC |
| 2 : |
anton
|
1.1
|
|
| 3 : |
anton
|
1.12
|
Copyright (C) 1995 Free Software Foundation, Inc. |
| 4 : |
|
|
|
| 5 : |
|
|
This file is part of Gforth. |
| 6 : |
|
|
|
| 7 : |
|
|
Gforth 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 : |
|
|
of the License, or (at your option) any later version. |
| 11 : |
|
|
|
| 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. |
| 16 : |
|
|
|
| 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, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 20 : |
anton
|
1.1
|
*/ |
| 21 : |
anton
|
1.5
|
|
| 22 : |
|
|
#include "32bit.h" |
| 23 : |
anton
|
1.4
|
|
| 24 : |
|
|
#if !defined(USE_TOS) && !defined(USE_NO_TOS) |
| 25 : |
|
|
#define USE_TOS |
| 26 : |
|
|
#endif |
| 27 : |
anton
|
1.1
|
|
| 28 : |
anton
|
1.9
|
#if !defined(INDIRECT_THREADED) && !defined(DIRECT_THREADED) |
| 29 : |
|
|
#define DIRECT_THREADED |
| 30 : |
|
|
#endif |
| 31 : |
anton
|
1.1
|
|
| 32 : |
anton
|
1.11
|
#define FLUSH_ICACHE(addr,size) \ |
| 33 : |
anton
|
1.13
|
({void *_addr=(addr); void *_end=_addr+((Cell)(size)); \ |
| 34 : |
anton
|
1.11
|
for (_addr=((long)_addr)&~7; _addr<_end; _addr += 8) \ |
| 35 : |
anton
|
1.13
|
asm("iflush %0"::"r"(_addr)); \ |
| 36 : |
anton
|
1.11
|
}) |
| 37 : |
|
|
|
| 38 : |
anton
|
1.1
|
#ifdef DIRECT_THREADED |
| 39 : |
anton
|
1.7
|
#ifndef WORDS_BIGENDIAN |
| 40 : |
anton
|
1.10
|
#error Direct threading only supported for big-endian SPARCs. |
| 41 : |
anton
|
1.7
|
/* little endian SPARCs still store instructions in big-endian format, |
| 42 : |
|
|
so you would have to reverse the instructions stores in the following |
| 43 : |
|
|
*/ |
| 44 : |
|
|
#endif |
| 45 : |
|
|
|
| 46 : |
anton
|
1.1
|
/* PFA gives the parameter field address corresponding to a cfa */ |
| 47 : |
|
|
#define PFA(cfa) (((Cell *)cfa)+2) |
| 48 : |
|
|
/* PFA1 is a special version for use just after a NEXT1 */ |
| 49 : |
|
|
/* the improvement here is that we may destroy cfa before using PFA1 */ |
| 50 : |
anton
|
1.6
|
#define PFA1(cfa) PFA(cfa) |
| 51 : |
|
|
#ifdef undefined |
| 52 : |
anton
|
1.1
|
#define PFA1(cfa) /* PFA(cfa) */ \ |
| 53 : |
anton
|
1.6
|
({register Cell *pfa asm("%o7"); \ |
| 54 : |
anton
|
1.1
|
pfa+2; }) |
| 55 : |
anton
|
1.6
|
#endif |
| 56 : |
anton
|
1.1
|
/* CODE_ADDRESS is the address of the code jumped to through the code field */ |
| 57 : |
anton
|
1.6
|
#define CODE_ADDRESS(cfa) ({unsigned _cfa = (unsigned)(cfa); \ |
| 58 : |
anton
|
1.14
|
(Label)(_cfa+((*(unsigned *)_cfa)<<2)-4);}) |
| 59 : |
anton
|
1.1
|
/* MAKE_CF creates an appropriate code field at the cfa; ca is the code address */ |
| 60 : |
|
|
/* we use call, since 'branch always' only has 22 bits displacement */ |
| 61 : |
|
|
#define MAKE_CF(cfa,ca) ({long *_cfa = (long *)(cfa); \ |
| 62 : |
|
|
unsigned _ca = (unsigned)(ca); \ |
| 63 : |
anton
|
1.6
|
_cfa[0] = 0x40000000|((_ca+4-(unsigned)_cfa)>>2); /* CALL ca */ \ |
| 64 : |
anton
|
1.1
|
_cfa[1] = *(long *)_ca; /* delay slot */}) |
| 65 : |
|
|
|
| 66 : |
|
|
/* this is the point where the does code starts if label points to the |
| 67 : |
|
|
* jump dodoes */ |
| 68 : |
anton
|
1.14
|
/* the +4 is due to the fact, that the does_cf jumps directly to the |
| 69 : |
|
|
code address, whereas CODE_ADDRESS expects a jump to |
| 70 : |
|
|
code_address+4, and corrects for that (which is countercorrected by |
| 71 : |
|
|
the +4) */ |
| 72 : |
|
|
#define DOES_CODE(label) ((Xt *)(CODE_ADDRESS(label)+4+DOES_HANDLER_SIZE)) |
| 73 : |
anton
|
1.1
|
|
| 74 : |
|
|
/* this is a special version of DOES_CODE for use in dodoes */ |
| 75 : |
anton
|
1.6
|
#define DOES_CODE1(label) DOES_CODE(label) |
| 76 : |
|
|
#ifdef undefined |
| 77 : |
|
|
#define DOES_CODE1(label) ({register Xt *_does_code asm("%o7"); \ |
| 78 : |
anton
|
1.1
|
_does_code+2; }) |
| 79 : |
anton
|
1.6
|
#endif |
| 80 : |
anton
|
1.1
|
|
| 81 : |
|
|
/* this stores a call dodoes at addr */ |
| 82 : |
anton
|
1.6
|
#define MAKE_DOES_HANDLER(addr) MAKE_CF(addr,symbols[DODOES]) |
| 83 : |
|
|
|
| 84 : |
|
|
#define DOES_HANDLER_SIZE 8 |
| 85 : |
|
|
|
| 86 : |
|
|
#define MAKE_DOES_CF(addr,doesp) ({long *_addr = (long *)(addr); \ |
| 87 : |
|
|
unsigned _doesp = (unsigned)(doesp); \ |
| 88 : |
|
|
_addr[0] = 0x40000000|((_doesp-8-(unsigned)_addr)>>2); /* CALL doesp-8 */ \ |
| 89 : |
|
|
_addr[1] = 0x01000000; /* nop */}) |
| 90 : |
anton
|
1.3
|
#endif |
| 91 : |
anton
|
1.6
|
|