Home | History | Annotate | Line # | Download | only in mips
SYS.h revision 1.12
      1 /*	$NetBSD: SYS.h,v 1.12 2000/03/23 04:58:59 mycroft Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 1996 Jonathan STone
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *      This product includes software developed by Jonathan Stone for
     18  *      the NetBSD Project.
     19  * 4. The name of the author may not be used to endorse or promote products
     20  *    derived from this software without specific prior written permission.
     21  *
     22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     27  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     31  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32  */
     33 
     34 /*-
     35  * Copyright (c) 1991, 1993
     36  *	The Regents of the University of California.  All rights reserved.
     37  *
     38  * This code is derived from software contributed to Berkeley by
     39  * Ralph Campbell.
     40  *
     41  * Redistribution and use in source and binary forms, with or without
     42  * modification, are permitted provided that the following conditions
     43  * are met:
     44  * 1. Redistributions of source code must retain the above copyright
     45  *    notice, this list of conditions and the following disclaimer.
     46  * 2. Redistributions in binary form must reproduce the above copyright
     47  *    notice, this list of conditions and the following disclaimer in the
     48  *    documentation and/or other materials provided with the distribution.
     49  * 3. All advertising materials mentioning features or use of this software
     50  *    must display the following acknowledgement:
     51  *	This product includes software developed by the University of
     52  *	California, Berkeley and its contributors.
     53  * 4. Neither the name of the University nor the names of its contributors
     54  *    may be used to endorse or promote products derived from this software
     55  *    without specific prior written permission.
     56  *
     57  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     58  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     59  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     60  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     61  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     62  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     63  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     64  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     65  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     66  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     67  * SUCH DAMAGE.
     68  *
     69  *	from: @(#)SYS.h	8.1 (Berkeley) 6/4/93
     70  */
     71 
     72 #include <sys/syscall.h>
     73 #include <mips/asm.h>
     74 
     75 
     76 /*
     77  * If compiling for shared libs, Emit sysV ABI PIC segment pseudo-ops.
     78  *
     79  * i)  Emit .abicalls before .LEAF entrypoint, and .cpload/.cprestore after.
     80  * ii) Do interprocedure jumps indirectly via t9, with the side-effect of
     81  *     preserving the callee's entry address in t9.
     82  */
     83 #ifdef ABICALLS
     84 	.abicalls
     85 # define PIC_PROLOGUE(x,sr)	.set noreorder; .cpload sr; .set reorder
     86 # define PIC_CALL(l,sr)		la sr, _C_LABEL(l); jr sr
     87 #else
     88 # define PIC_PROLOGUE(x,sr)
     89 # define PIC_CALL(l,sr)		j  _C_LABEL(l)
     90 #endif
     91 
     92 
     93 #ifdef __STDC__
     94 # define SYSTRAP(x)	li v0,SYS_ ## x; syscall;
     95 #else
     96 # define SYSTRAP(x)	li v0,SYS_/**/x; syscall;
     97 #endif
     98 
     99 
    100 /*
    101  * Do a syscall that cannot fail (sync, get{p,u,g,eu,eg)id)
    102  */
    103 #define RSYSCALL_NOERROR(x)						\
    104 	PSEUDO_NOERROR(x,x)
    105 
    106 /*
    107  * Do a normal syscall.
    108  */
    109 #define RSYSCALL(x)							\
    110 	PSEUDO(x,x)
    111 
    112 
    113 /*
    114  * Do a renamed or pseudo syscall (e.g., _exit()), where the entrypoint
    115  * and syscall name are not the same.
    116  */
    117 #define PSEUDO_NOERROR(x,y)						\
    118 LEAF(x);								\
    119 	SYSTRAP(y);							\
    120 	j ra;								\
    121 	END(x)
    122 
    123 #define PSEUDO(x,y)							\
    124 LEAF(x);								\
    125 	PIC_PROLOGUE(x,t9);						\
    126 	SYSTRAP(y);							\
    127 	bne a3,zero,err;						\
    128 	j ra;								\
    129 err:									\
    130 	PIC_CALL(__cerror,t9);						\
    131 	END(x)
    132