Annotation of gforth/decstation.h, revision 1.3

1.1       anton       1: /*
                      2:   $Id: decstation.h,v 1.8 1993/05/25 10:24:18 anton Exp $
                      3:   Copyright 1992 by the ANSI figForth Development Group
                      4: 
                      5:   This is the machine-specific part for a Decstation running Ultrix
                      6: */
1.3     ! pazsan      7: /* cache flush stuff */
1.1       anton       8: 
1.3     ! pazsan      9: #ifdef DIRECT_THREADED
        !            10: 
        !            11: #include <mips/cachectl.h>
        !            12: 
        !            13: #define CACHE_FLUSH(addr,size) \
        !            14:                                cacheflush((char *)(addr), (int)(size), BCACHE)
        !            15: 
        !            16: #endif
1.1       anton      17: 
                     18: /* Cell and UCell must be the same size as a pointer */
                     19: typedef long Cell;
                     20: typedef unsigned long UCell;
                     21: 
                     22: /* DCell and UDCell must be twice as large as Cell */
                     23: typedef long long DCell;
                     24: typedef unsigned long long UDCell;
                     25: 
                     26: /* define this if IEEE singles and doubles are available as C data types */
                     27: #define IEEE_FP
                     28: 
                     29: /* the IEEE types are used only for loading and storing */
                     30: /* the IEEE double precision type */
                     31: typedef double DFloat;
                     32: /* the IEEE single precision type */
                     33: typedef float SFloat;
                     34: 
                     35: /* define this if the least-significant byte is at the largets address */
                     36: /* #define BIG_ENDIAN */
                     37: 
                     38: /* some definitions for composing opcodes */
                     39: #define JUMP_MASK      0x03ffffff
                     40: #define J_PATTERN      0x08000000
                     41: #define JAL_PATTERN    0x0c000000
                     42: /* this provides the first 4 bits of a jump address, i.e. it must be <16 */
                     43: #define SEGMENT_NUM    1
                     44: 
                     45: #ifdef DIRECT_THREADED
                     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: #      define PFA1(cfa)        PFA(cfa)
                     50:        /* CODE_ADDRESS is the address of the code jumped to through the code field */
                     51: #      define CODE_ADDRESS(cfa)        ((Label)(((*(unsigned *)(cfa))^J_PATTERN^(SEGMENT_NUM<<26))<<2))
                     52:        /* MAKE_CF creates an appropriate code field at the cfa; ca is the code address */
                     53: #      define MAKE_CF(cfa,ca)  ({long * _cfa = (long *)(cfa); \
                     54:                                          _cfa[0] = J_PATTERN|((((long)(ca))&JUMP_MASK)>>2); /* J ca */ \
                     55:                                          _cfa[1] = 0; /* nop */})
                     56: #      ifdef undefined
                     57:                /* the following version uses JAL to make PFA1 faster */
                     58: #              define PFA1(label)      ({register Cell *pfa asm("$31"); \
                     59:                                                pfa; })
                     60:                /* CODE_ADDRESS is the address of the code jumped to through the code field */
                     61: #              define CODE_ADDRESS(cfa)        ((Label)(((*(unsigned *)(cfa))^JAL_PATTERN^(SEGMENT_NUM<<26))<<2))
                     62: #              define MAKE_CF(cfa,ca)  ({long *_cfa = (long *)(cfa); \
1.2       pazsan     63:                                          long _ca = (long)(ca); \
                     64:                                                  _cfa[0] = JAL_PATTERN|(((((long)_ca)>>2))&JUMP_MASK); /* JAL ca+4 */ \
                     65:                                                  _cfa[1] = 0; /* *(long *)_ca; delay slot */})
1.1       anton      66: #      endif /* undefined */
                     67: 
                     68:        /* this is the point where the does code starts if label points to the
                     69:         * jump dodoes */
                     70: #      define DOES_CODE(cfa)   ((Xt *)(((char *)CODE_ADDRESS(cfa))+8))
                     71: 
                     72:        /* this is a special version of DOES_CODE for use in dodoes */
                     73: #      define DOES_CODE1(cfa)  DOES_CODE(cfa)
                     74: 
                     75: #      define DOES_HANDLER_SIZE        8
1.2       pazsan     76: #      define MAKE_DOES_CF(cfa,does_code) \
                     77:                        ({long does_handlerp=((long)(does_code))-DOES_HANDLER_SIZE; \
                     78:                          long *_cfa = (long*)(cfa); \
                     79:                          _cfa[0] = J_PATTERN|((does_handlerp&JUMP_MASK)>>2); /* J ca */ \
                     80:                          _cfa[1] = 0; /* nop */})
                     81: /*
1.1       anton      82: #      define MAKE_DOES_CF(cfa, does_code)     ({char *does_handlerp=((char *)does_code)-DOES_HANDLER_SIZE;    \
                     83:                                                  MAKE_CF(cfa,does_handlerp);   \
1.2       pazsan     84:                                                  MAKE_DOES_HANDLER(does_handlerp) ;})
                     85: */
1.1       anton      86:        /* this stores a jump dodoes at addr */
1.2       pazsan     87: #      define MAKE_DOES_HANDLER(addr)  MAKE_CF(addr,symbols[DODOES])
                     88: 
1.1       anton      89: #endif
                     90: #ifdef undefined
                     91: /* and here are some more efficient versions that can be tried later */
                     92: 
                     93: /* the first version saves one cycle by doing something useful in the
                     94:    delay slot. !! check that the instruction in the delay slot is legal
                     95: */
                     96: 
                     97: #define MAKE_DOESJUMP(addr)    ({long * _addr = (long *)addr; \
1.2       pazsan     98:                                  _addr[0] = J_PATTERN|(((((long)symbols[DODOES])>>2)+4)&JUMP_MASK), /* J dodoes+4 */ \
                     99:                                  _addr[1] = *(long *)symbols[DODOES]; /* delay */})
1.1       anton     100: 
                    101: /* the following version uses JAL to make DOES_CODE1 faster */
                    102: /* !! does the declaration clear the register ? */
                    103: /* it's ok to use the same reg as in PFA1:
                    104:    dodoes is the only potential problem and I have taken care of it */
1.2       pazsan    105: 
1.1       anton     106: #define DOES_CODE1(cfa)        ({register Code *_does_code asm("$31"); \
                    107:                                    _does_code; })
                    108: #define MAKE_DOESJUMP(addr)    ({long * _addr = (long *)addr; \
1.2       pazsan    109:                                  _addr[0] = JAL_PATTERN|(((((long)symbols[DODOES])>>2)+4)&JUMP_MASK), /* JAL dodoes+4 */ \
                    110:                                  _addr[1] = *(long *)symbols[DODOES]; /* delay */})
1.1       anton     111: 
                    112: #endif
1.2       pazsan    113: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>