[BACK]Return to asm.h CVS log [TXT][DIR] Up to [local] / sys / arch / mips64 / include

Annotation of sys/arch/mips64/include/asm.h, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: asm.h,v 1.7 2004/10/20 12:49:15 pefo Exp $ */
                      2:
                      3: /*
                      4:  * Copyright (c) 2001-2002 Opsycon AB  (www.opsycon.se / www.opsycon.com)
                      5:  *
                      6:  * Redistribution and use in source and binary forms, with or without
                      7:  * modification, are permitted provided that the following conditions
                      8:  * are met:
                      9:  * 1. Redistributions of source code must retain the above copyright
                     10:  *    notice, this list of conditions and the following disclaimer.
                     11:  * 2. Redistributions in binary form must reproduce the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer in the
                     13:  *    documentation and/or other materials provided with the distribution.
                     14:  *
                     15:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
                     16:  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
                     17:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     18:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
                     19:  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     20:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     21:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     22:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     23:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     24:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     25:  * SUCH DAMAGE.
                     26:  *
                     27:  */
                     28: #ifndef _MIPS64_ASM_H
                     29: #define _MIPS64_ASM_H
                     30:
                     31: #include <machine/regdef.h>
                     32:
                     33: #ifdef NEED_OLD_RM7KFIX
                     34: #define ITLBNOPFIX      nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;
                     35: #else
                     36: #define ITLBNOPFIX      nop;nop;nop;nop
                     37: #endif
                     38:
                     39: #define        _MIPS_ISA_MIPS1 1       /* R2000/R3000 */
                     40: #define        _MIPS_ISA_MIPS2 2       /* R4000/R6000 */
                     41: #define        _MIPS_ISA_MIPS3 3       /* R4000 */
                     42: #define        _MIPS_ISA_MIPS4 4       /* TFP (R1x000) */
                     43:
                     44: #if !defined(ABICALLS) && !defined(_NO_ABICALLS)
                     45: #define        ABICALLS        .abicalls
                     46: #endif
                     47:
                     48: #if defined(ABICALLS) && !defined(_KERNEL)
                     49:        ABICALLS
                     50: #endif
                     51:
                     52: #define _C_LABEL(x) x          /* XXX Obsolete but keep for a while */
                     53:
                     54: #if !defined(__MIPSEL__) && !defined(__MIPSEB__)
                     55: #error "__MIPSEL__ or __MIPSEB__ must be defined"
                     56: #endif
                     57: /*
                     58:  * Define how to access unaligned data word
                     59:  */
                     60: #if defined(__MIPSEL__)
                     61: #define LWLO    lwl
                     62: #define LWHI    lwr
                     63: #define        SWLO    swl
                     64: #define        SWHI    swr
                     65: #define LDLO    ldl
                     66: #define LDHI    ldr
                     67: #define        SDLO    sdl
                     68: #define        SDHI    sdr
                     69: #endif
                     70: #if defined(__MIPSEB__)
                     71: #define LWLO    lwr
                     72: #define LWHI    lwl
                     73: #define        SWLO    swr
                     74: #define        SWHI    swl
                     75: #define LDLO    ldr
                     76: #define LDHI    ldl
                     77: #define        SDLO    sdr
                     78: #define        SDHI    sdl
                     79: #endif
                     80:
                     81: /*
                     82:  *  Define programming environment for ABI.
                     83:  */
                     84: #if defined(ABICALLS) && !defined(_KERNEL) && !defined(_STANDALONE)
                     85:
                     86: #ifndef _MIPS_SIM
                     87: #define _MIPS_SIM 1
                     88: #define _ABIO32        1
                     89: #endif
                     90: #ifndef _MIPS_ISA
                     91: #define _MIPS_ISA 2
                     92: #define _MIPS_ISA_MIPS2 2
                     93: #endif
                     94:
                     95: #if (_MIPS_SIM == _ABIO32) || (_MIPS_SIM == _ABI32)
                     96: #define NARGSAVE       4
                     97:
                     98: #define        SETUP_GP                \
                     99:        .set    noreorder;      \
                    100:        .cpload t9;             \
                    101:        .set    reorder;
                    102:
                    103: #define        SAVE_GP(x)              \
                    104:        .cprestore x
                    105:
                    106: #define        SETUP_GP64(gpoff, name)
                    107: #define        RESTORE_GP64
                    108: #endif
                    109:
                    110: #if (_MIPS_SIM == _ABI64) || (_MIPS_SIM == _ABIN32)
                    111: #define NARGSAVE       0
                    112:
                    113: #define        SETUP_GP
                    114: #define        SAVE_GP(x)
                    115: #define        SETUP_GP64(gpoff, name) \
                    116:        .cpsetup t9, gpoff, name
                    117: #define        RESTORE_GP64            \
                    118:        .cpreturn
                    119: #endif
                    120:
                    121: #define        MKFSIZ(narg,locals) (((narg+locals)*REGSZ+31)&(~31))
                    122:
                    123: #else /* defined(ABICALLS) && !defined(_KERNEL) */
                    124:
                    125: #define        NARGSAVE        4
                    126: #define        SETUP_GP
                    127: #define        SAVE_GP(x)
                    128:
                    129: #define        ALIGNSZ         16      /* Stack layout alignment */
                    130: #define        FRAMESZ(sz)     (((sz) + (ALIGNSZ-1)) & ~(ALIGNSZ-1))
                    131:
                    132: #endif
                    133:
                    134: /*
                    135:  *  Basic register operations based on selected ISA
                    136:  */
                    137: #if (_MIPS_ISA == _MIPS_ISA_MIPS1 || _MIPS_ISA == _MIPS_ISA_MIPS2)
                    138: #define REGSZ          4       /* 32 bit mode register size */
                    139: #define LOGREGSZ       2       /* log rsize */
                    140: #define        REG_S   sw
                    141: #define        REG_L   lw
                    142: #define        CF_SZ           24      /* Call frame size */
                    143: #define        CF_ARGSZ        16      /* Call frame arg size */
                    144: #define        CF_RA_OFFS      20      /* Call ra save offset */
                    145: #endif
                    146:
                    147: #if (_MIPS_ISA == _MIPS_ISA_MIPS3 || _MIPS_ISA == _MIPS_ISA_MIPS4)
                    148: #define REGSZ          8       /* 64 bit mode register size */
                    149: #define LOGREGSZ       3       /* log rsize */
                    150: #define        REG_S   sd
                    151: #define        REG_L   ld
                    152: #define        CF_SZ           48      /* Call frame size (multiple of ALIGNSZ) */
                    153: #define        CF_ARGSZ        32      /* Call frame arg size */
                    154: #define        CF_RA_OFFS      40      /* Call ra save offset */
                    155: #endif
                    156:
                    157: #ifndef __LP64__
                    158: #define        PTR_L           lw
                    159: #define        PTR_S           sw
                    160: #define        PTR_SUB         sub
                    161: #define        PTR_ADD         add
                    162: #define        PTR_SUBU        subu
                    163: #define        PTR_ADDU        addu
                    164: #define LI             li
                    165: #define        LA              la
                    166: #define        PTR_SLL         sll
                    167: #define        PTR_SRL         srl
                    168: #define        PTR_VAL         .word
                    169: #else
                    170: #define        PTR_L           ld
                    171: #define        PTR_S           sd
                    172: #define        PTR_ADD         dadd
                    173: #define        PTR_SUB         dsub
                    174: #define        PTR_SUBU        dsubu
                    175: #define        PTR_ADDU        daddu
                    176: #define LI             dli
                    177: #define LA             dla
                    178: #define        PTR_SLL         dsll
                    179: #define        PTR_SRL         dsrl
                    180: #define        PTR_VAL         .dword
                    181: #endif
                    182:
                    183: /*
                    184:  * Define -pg profile entry code.
                    185:  */
                    186: #if defined(XGPROF) || defined(XPROF)
                    187: #define        MCOUNT                  \
                    188:        PTR_SUBU sp, sp, 32;    \
                    189:        SAVE_GP(16);            \
                    190:        sw      ra, 28(sp);     \
                    191:        sw      gp, 24(sp);     \
                    192:        .set    noat;           \
                    193:        .set    noreorder;      \
                    194:        move    AT, ra;         \
                    195:        jal     _mcount;        \
                    196:        PTR_SUBU sp, sp, 8;     \
                    197:        lw      ra, 28(sp);     \
                    198:        PTR_ADDU sp, sp, 32;    \
                    199:        .set reorder;           \
                    200:        .set    at;
                    201: #else
                    202: #define        MCOUNT
                    203: #endif
                    204:
                    205: /*
                    206:  * LEAF(x, fsize)
                    207:  *
                    208:  *     Declare a leaf routine.
                    209:  */
                    210: #define LEAF(x, fsize)         \
                    211:        .align  3;              \
                    212:        .globl x;               \
                    213:        .ent x, 0;              \
                    214: x: ;                           \
                    215:        .frame sp, fsize, ra;   \
                    216:        SETUP_GP                \
                    217:        MCOUNT
                    218:
                    219: #define        ALEAF(x)                \
                    220:        .globl  x;              \
                    221: x:
                    222:
                    223: /*
                    224:  * NLEAF(x)
                    225:  *
                    226:  *     Declare a non-profiled leaf routine.
                    227:  */
                    228: #define NLEAF(x, fsize)                \
                    229:        .align  3;              \
                    230:        .globl x;               \
                    231:        .ent x, 0;              \
                    232: x: ;                           \
                    233:        .frame sp, fsize, ra;   \
                    234:        SETUP_GP
                    235:
                    236: /*
                    237:  * NON_LEAF(x)
                    238:  *
                    239:  *     Declare a non-leaf routine (a routine that makes other C calls).
                    240:  */
                    241: #define NON_LEAF(x, fsize, retpc) \
                    242:        .align  3;              \
                    243:        .globl x;               \
                    244:        .ent x, 0;              \
                    245: x: ;                           \
                    246:        .frame sp, fsize, retpc; \
                    247:        SETUP_GP                \
                    248:        MCOUNT
                    249:
                    250: /*
                    251:  * NNON_LEAF(x)
                    252:  *
                    253:  *     Declare a non-profiled non-leaf routine
                    254:  *     (a routine that makes other C calls).
                    255:  */
                    256: #define NNON_LEAF(x, fsize, retpc) \
                    257:        .align  3;              \
                    258:        .globl x;               \
                    259:        .ent x, 0;              \
                    260: x: ;                           \
                    261:        .frame sp, fsize, retpc \
                    262:        SETUP_GP
                    263:
                    264: /*
                    265:  * END(x)
                    266:  *
                    267:  *     Mark end of a procedure.
                    268:  */
                    269: #define END(x) \
                    270:        .end x
                    271:
                    272: /*
                    273:  * Macros to panic and printf from assembly language.
                    274:  */
                    275: #define PANIC(msg) \
                    276:        LA      a0, 9f; \
                    277:        jal     panic;  \
                    278:        nop     ;       \
                    279:        MSG(msg)
                    280:
                    281: #define        PRINTF(msg) \
                    282:        la      a0, 9f; \
                    283:        jal     printf; \
                    284:        nop     ;       \
                    285:        MSG(msg)
                    286:
                    287: #define        MSG(msg) \
                    288:        .rdata; \
                    289: 9:     .asciiz msg; \
                    290:        .text
                    291:
                    292: #define ASMSTR(str) \
                    293:        .asciiz str; \
                    294:        .align  3
                    295:
                    296: #endif /* !_MIPS_ASM_H */

CVSweb