Annotation of gforth/power.h, revision 1.3
1.3 ! anton 1: /* This is the machine-specific part for the Power (incl. PPC) architecture
1.1 anton 2:
1.3 ! anton 3: 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.
1.1 anton 20: */
21:
22: #if !defined(USE_TOS) && !defined(USE_NO_TOS)
23: #define USE_TOS
24: #endif
25:
26: #ifndef INDIRECT_THREADED
27: #ifndef DIRECT_THREADED
28: /* #define DIRECT_THREADED */
29: #endif
30: #endif
31:
32: #include "32bit.h"
33:
34: /* cache flush stuff */
35: #warning If you get assembly errors, here is the reason why
1.2 anton 36: #define FLUSH_ICACHE(addr,size) asm("icbi (%0); isync"::"b"(addr))
1.1 anton 37: /* this assumes size=4 */
38: /* the mnemonics are for the PPC and the syntax is a wild guess; for
39: Power the mnemonic for the isync instruction is "ics" and I have
40: not found an equivalent for the icbi instruction in my reference.
41: */
1.2 anton 42:
43: #ifdef DIRECT_THREADED
44: #warning Direct threading for Power has not been tested
1.1 anton 45:
46: /* 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: #define PFA1(cfa) PFA(cfa)
51:
52: /* I'll assume the code resides in the lower (or upper) 32M of the
53: address space and use absolute addressing in the jumps to the
54: handlers. This makes it possible to use the full address space for
55: direct threaded Forth (even on 64-bit PowerPCs). However, the
56: linker has to ensure that this really happens */
57:
58: #define JUMP_TARGET_BITS 0
59: /* assuming the code is in the lower 32M; if it is in the upper 32M,
60: define JUMP_TARGET_BITS as ~0x3ffffff */
61: #define JUMP_MASK 0x3fffffc
62:
63: /* CODE_ADDRESS is the address of the code jumped to through the code field */
64: #define CODE_ADDRESS(cfa) ((Label)(((*(unsigned *)(cfa))&JUMP_MASK)|JUMP_TARGET_BITS))
65:
66: /* MAKE_CF creates an appropriate code field at the cfa; ca is the
67: code address. For those familiar with assembly, this is a `ba'
68: instruction in both Power and PowerPC assembly languages */
69: #define MAKE_CF(cfa,ca) (*(long *)(cfa) = 0x48000002|(ca))
70:
71: /* this is the point where the does code for the word with the xt cfa
72: starts. Since a branch is only a cell on Power, we can use the
73: second cell of the cfa for storing the does address */
74: #define DOES_CODE(cfa) ((Xt *)(((long *)(cfa))[1]))
75: /* this is a special version of DOES_CODE for use in dodoes */
76: #define DOES_CODE1(label) DOES_CODE(label)
77:
78: /* the does handler resides between DOES> and the following Forth
79: code. Since the code-field jumps directly to dodoes, the
80: does-handler is not needed for the Power architecture */
81: #define DOES_HANDLER_SIZE 8
82: #define MAKE_DOES_HANDLER(addr) 0
83:
84: /* This makes a code field for a does-defined word. doesp is the
85: address of the does-code. On the PPC, the code field consists of a
86: jump to dodoes and the address of the does code */
87: #define MAKE_DOES_CF(cfa,doesp) ({Xt *_cfa = (Xt *)(cfa); \
88: MAKE_CF(_cfa, symbols[DODOES]); \
89: _cfa[1] = (doesp); })
90: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>