[BACK]Return to asm.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / arch / mips / include

Annotation of src/sys/arch/mips/include/asm.h, Revision 1.26

1.26    ! cgd         1: /*     $NetBSD: asm.h,v 1.25 2000/07/25 17:56:05 jeffs Exp $   */
1.4       cgd         2:
1.1       deraadt     3: /*
1.2       glass       4:  * Copyright (c) 1992, 1993
                      5:  *     The Regents of the University of California.  All rights reserved.
1.1       deraadt     6:  *
                      7:  * This code is derived from software contributed to Berkeley by
                      8:  * Ralph Campbell.
                      9:  *
                     10:  * Redistribution and use in source and binary forms, with or without
                     11:  * modification, are permitted provided that the following conditions
                     12:  * are met:
                     13:  * 1. Redistributions of source code must retain the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer.
                     15:  * 2. Redistributions in binary form must reproduce the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer in the
                     17:  *    documentation and/or other materials provided with the distribution.
                     18:  * 3. All advertising materials mentioning features or use of this software
                     19:  *    must display the following acknowledgement:
                     20:  *     This product includes software developed by the University of
                     21:  *     California, Berkeley and its contributors.
                     22:  * 4. Neither the name of the University nor the names of its contributors
                     23:  *    may be used to endorse or promote products derived from this software
                     24:  *    without specific prior written permission.
                     25:  *
                     26:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     27:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     28:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     29:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     30:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     31:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     32:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     33:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     34:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     35:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     36:  * SUCH DAMAGE.
                     37:  *
1.4       cgd        38:  *     @(#)machAsmDefs.h       8.1 (Berkeley) 6/10/93
1.1       deraadt    39:  */
                     40:
                     41: /*
                     42:  * machAsmDefs.h --
                     43:  *
                     44:  *     Macros used when writing assembler programs.
                     45:  *
                     46:  *     Copyright (C) 1989 Digital Equipment Corporation.
                     47:  *     Permission to use, copy, modify, and distribute this software and
                     48:  *     its documentation for any purpose and without fee is hereby granted,
                     49:  *     provided that the above copyright notice appears in all copies.
                     50:  *     Digital Equipment Corporation makes no representations about the
                     51:  *     suitability of this software for any purpose.  It is provided "as is"
                     52:  *     without express or implied warranty.
                     53:  *
                     54:  * from: Header: /sprite/src/kernel/mach/ds3100.md/RCS/machAsmDefs.h,
1.2       glass      55:  *     v 1.2 89/08/15 18:28:24 rab Exp  SPRITE (DECWRL)
1.1       deraadt    56:  */
                     57:
1.8       jonathan   58: #ifndef _MIPS_ASM_H
                     59: #define _MIPS_ASM_H
1.1       deraadt    60:
1.21      soda       61: #include <mips/regdef.h>
1.1       deraadt    62:
                     63: /*
                     64:  * Define -pg profile entry code.
1.23      castor     65:  * Must always be noreorder, must never use a macro instruction
                     66:  * Final addiu to t9 must always equal the size of this _KERN_MCOUNT
1.1       deraadt    67:  */
1.23      castor     68: #define _KERN_MCOUNT                                           \
                     69:        .set    push;                                           \
                     70:        .set    noreorder;                                      \
                     71:        .set    noat;                                           \
                     72:        sw      t9,-4(sp);                                      \
                     73:        move    AT,ra;                                          \
                     74:        lui     t9,%hi(_mcount);                                \
                     75:        addiu   t9,t9,%lo(_mcount);                             \
                     76:        jalr    t9;                                             \
                     77:        subu    sp,sp,16;                                       \
                     78:        lw      t9,4(sp);                                       \
                     79:        addiu   sp,sp,8;                                        \
                     80:        addiu   t9,t9,36;                                       \
                     81:        .set    pop;
1.13      jonathan   82:
1.11      jtc        83: #ifdef GPROF
1.23      castor     84: #define MCOUNT _KERN_MCOUNT
1.1       deraadt    85: #else
                     86: #define        MCOUNT
1.2       glass      87: #endif
1.1       deraadt    88:
1.7       mellon     89: #ifdef __NO_LEADING_UNDERSCORES__
1.6       mycroft    90: # define _C_LABEL(x)   x
                     91: #else
                     92: # ifdef __STDC__
                     93: #  define _C_LABEL(x)  _ ## x
                     94: # else
                     95: #  define _C_LABEL(x)  _/**/x
                     96: # endif
                     97: #endif
1.14      thorpej    98:
1.15      castor     99: #ifdef USE_AENT
                    100: #define AENT(x)                                \
                    101:        .aent   x, 0
                    102: #else
                    103: #define AENT(x)
1.24      kleink    104: #endif
                    105:
                    106: #ifdef __ELF__
                    107: #define        WEAK_ALIAS(alias,sym)                                           \
                    108:        .weak alias;                                                    \
                    109:        alias = sym
1.15      castor    110: #endif
                    111:
1.14      thorpej   112: /*
                    113:  * WARN_REFERENCES: create a warning if the specified symbol is referenced
                    114:  * (ELF only, and thus, no leading underscores).
                    115:  */
                    116: #ifdef __ELF__
                    117: #ifdef __STDC__
                    118: #define        WARN_REFERENCES(_sym,_msg)                              \
                    119:        .section .gnu.warning. ## _sym ; .ascii _msg ; .text
                    120: #else
                    121: #define        WARN_REFERENCES(_sym,_msg)                              \
                    122:        .section .gnu.warning./**/_sym ; .ascii _msg ; .text
                    123: #endif /* __STDC__ */
                    124: #endif /* __ELF__ */
1.6       mycroft   125:
1.1       deraadt   126: /*
1.15      castor    127:  * LEAF
                    128:  *     A leaf routine does
                    129:  *     - call no other function,
                    130:  *     - never use any register that callee-saved (S0-S8), and
                    131:  *     - not use any local stack storage.
                    132:  */
                    133: #define LEAF(x)                                \
                    134:        .globl  _C_LABEL(x);            \
                    135:        .ent    _C_LABEL(x), 0;         \
                    136: _C_LABEL(x): ;                         \
                    137:        .frame sp, 0, ra;               \
1.1       deraadt   138:        MCOUNT
                    139:
                    140: /*
1.15      castor    141:  * LEAF_NOPROFILE
                    142:  *     No profilable leaf routine.
1.1       deraadt   143:  */
1.15      castor    144: #define LEAF_NOPROFILE(x)              \
                    145:        .globl  _C_LABEL(x);            \
                    146:        .ent    _C_LABEL(x), 0;         \
                    147: _C_LABEL(x): ;                         \
                    148:        .frame  sp, 0, ra
                    149:
                    150: /*
                    151:  * XLEAF
                    152:  *     declare alternate entry to leaf routine
                    153:  */
                    154: #define XLEAF(x)                       \
                    155:        .globl  _C_LABEL(x);            \
1.20      soda      156:        AENT (_C_LABEL(x));             \
1.15      castor    157: _C_LABEL(x):
                    158:
                    159: /*
                    160:  * NESTED
                    161:  *     A function calls other functions and needs
                    162:  *     therefore stack space to save/restore registers.
                    163:  */
                    164: #define NESTED(x, fsize, retpc)                \
                    165:        .globl  _C_LABEL(x);            \
                    166:        .ent    _C_LABEL(x), 0;         \
                    167: _C_LABEL(x): ;                         \
                    168:        .frame  sp, fsize, retpc;       \
                    169:        MCOUNT
1.1       deraadt   170:
                    171: /*
1.15      castor    172:  * NESTED_NOPROFILE(x)
                    173:  *     No profilable nested routine.
1.1       deraadt   174:  */
1.15      castor    175: #define NESTED_NOPROFILE(x, fsize, retpc)      \
                    176:        .globl  _C_LABEL(x);            \
                    177:        .ent    _C_LABEL(x), 0;         \
                    178: _C_LABEL(x): ;                         \
                    179:        .frame  sp, fsize, retpc
                    180:
                    181: /*
                    182:  * XNESTED
                    183:  *     declare alternate entry point to nested routine.
                    184:  */
                    185: #define XNESTED(x)                     \
                    186:        .globl  _C_LABEL(x);            \
1.20      soda      187:        AENT (_C_LABEL(x));             \
1.6       mycroft   188: _C_LABEL(x):
1.1       deraadt   189:
                    190: /*
1.15      castor    191:  * END
                    192:  *     Mark end of a procedure.
1.1       deraadt   193:  */
1.15      castor    194: #define END(x) \
                    195:        .end _C_LABEL(x)
1.2       glass     196:
                    197: /*
1.15      castor    198:  * IMPORT -- import external symbol
1.2       glass     199:  */
1.15      castor    200: #define IMPORT(sym, size)              \
1.20      soda      201:        .extern _C_LABEL(sym),size
1.1       deraadt   202:
                    203: /*
1.15      castor    204:  * EXPORT -- export definition of symbol
1.1       deraadt   205:  */
1.15      castor    206: #define EXPORT(x)                      \
                    207:        .globl  _C_LABEL(x);            \
                    208: _C_LABEL(x):
1.1       deraadt   209:
1.15      castor    210: /*
1.17      jonathan  211:  * VECTOR
                    212:  *     exception vector entrypoint
1.20      soda      213:  *     XXX: regmask should be used to generate .mask
1.17      jonathan  214:  */
                    215: #define VECTOR(x, regmask)             \
                    216:        .ent    _C_LABEL(x),0;          \
                    217:        EXPORT(x);                      \
                    218:
1.19      soda      219: #ifdef __STDC__
                    220: #define VECTOR_END(x)                  \
1.20      soda      221:        EXPORT(x ## End);               \
                    222:        END(x)
1.19      soda      223: #else
1.17      jonathan  224: #define VECTOR_END(x)                  \
1.20      soda      225:        EXPORT(x/**/End);               \
                    226:        END(x)
1.19      soda      227: #endif
1.1       deraadt   228:
                    229: /*
1.10      christos  230:  * Macros to panic and printf from assembly language.
1.1       deraadt   231:  */
1.15      castor    232: #define PANIC(msg)                     \
                    233:        la      a0, 9f;                 \
                    234:        jal     _C_LABEL(panic);        \
1.26    ! cgd       235:        nop;                            \
1.1       deraadt   236:        MSG(msg)
                    237:
1.15      castor    238: #define        PRINTF(msg)                     \
                    239:        la      a0, 9f;                 \
                    240:        jal     _C_LABEL(printf);       \
1.26    ! cgd       241:        nop;                            \
1.1       deraadt   242:        MSG(msg)
                    243:
1.15      castor    244: #define        MSG(msg)                        \
                    245:        .rdata;                         \
                    246: 9:     .asciiz msg;                    \
1.1       deraadt   247:        .text
                    248:
1.15      castor    249: #define ASMSTR(str)                    \
                    250:        .asciiz str;                    \
1.12      jonathan  251:        .align  3
1.15      castor    252:
                    253: /*
                    254:  * XXX retain dialects XXX
                    255:  */
1.19      soda      256: #define ALEAF(x)                       XLEAF(x)
                    257: #define NLEAF(x)                       LEAF_NOPROFILE(x)
                    258: #define NON_LEAF(x, fsize, retpc)      NESTED(x, fsize, retpc)
                    259: #define NNON_LEAF(x, fsize, retpc)     NESTED_NOPROFILE(x, fsize, retpc)
1.15      castor    260:
1.22      simonb    261: /*
1.16      castor    262:  *  standard callframe {
                    263:  *     register_t cf_args[4];          arg0 - arg3
                    264:  *     register_t cf_sp;               frame pointer
                    265:  *     register_t cf_ra;               return address
                    266:  *  };
                    267:  */
                    268: #define        CALLFRAME_SIZ   (4 * (4 + 2))
                    269: #define        CALLFRAME_SP    (4 * 4)
                    270: #define        CALLFRAME_RA    (4 * 5)
                    271:
1.15      castor    272: /*
1.22      simonb    273:  * While it would be nice to be compatible with the SGI
1.15      castor    274:  * REG_L and REG_S macros, because they do not take parameters, it
                    275:  * is impossible to use them with the _MIPS_SIM_ABIX32 model.
                    276:  *
1.22      simonb    277:  * These macros hide the use of mips3 instructions from the
1.15      castor    278:  * assembler to prevent the assembler from generating 64-bit style
                    279:  * ABI calls.
                    280:  */
                    281:
1.16      castor    282: #if !defined(_MIPS_BSD_API) || _MIPS_BSD_API == _MIPS_BSD_API_LP32
                    283: #define        REG_L   lw
                    284: #define REG_S  sw
                    285: #define        REG_LI  li
1.22      simonb    286: #define        REG_PROLOGUE    .set push
1.16      castor    287: #define        REG_EPILOGUE    .set pop
                    288: #define SZREG  4
                    289: #else
1.15      castor    290: #define        REG_L   ld
                    291: #define REG_S  sd
                    292: #define        REG_LI  dli
                    293: #define        REG_PROLOGUE    .set push ; .set mips3
                    294: #define        REG_EPILOGUE    .set pop
                    295: #define SZREG  8
1.16      castor    296: #endif /* _MIPS_BSD_API */
1.25      jeffs     297:
                    298: /*
                    299:  * The DYNAMIC_STATUS_MASK option adds an additional masking operation
                    300:  * when updating the hardware interrupt mask in the status register.
                    301:  *
                    302:  * This is useful for platforms that need to at run-time mask
                    303:  * interrupts based on motherboard configuration or to handle
                    304:  * slowly clearing interrupts.
                    305:  *
                    306:  * XXX this is only currently implemented for mips3.
                    307:  */
                    308: #ifdef MIPS_DYNAMIC_STATUS_MASK
                    309: #define DYNAMIC_STATUS_MASK(sr,scratch)        \
                    310:        lw      scratch, mips_dynamic_status_mask; \
                    311:        and     sr, sr, scratch
                    312: #else
                    313: #define DYNAMIC_STATUS_MASK(sr,scratch)
                    314: #endif
1.1       deraadt   315:
1.8       jonathan  316: #endif /* _MIPS_ASM_H */

CVSweb <webmaster@jp.NetBSD.org>