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