Home | History | Annotate | Line # | Download | only in mips
SYS.h revision 1.18
      1  1.18     pooka /*	$NetBSD: SYS.h,v 1.18 2003/10/29 12:28:33 pooka Exp $ */
      2   1.4  jonathan 
      3   1.1     glass /*-
      4  1.18     pooka  * 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.17       agc  * 3. Neither the name of the University nor the names of its contributors
     50   1.1     glass  *    may be used to endorse or promote products derived from this software
     51   1.1     glass  *    without specific prior written permission.
     52   1.1     glass  *
     53   1.1     glass  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     54   1.1     glass  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     55   1.1     glass  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     56   1.1     glass  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     57   1.1     glass  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     58   1.1     glass  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     59   1.1     glass  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     60   1.1     glass  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     61   1.1     glass  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     62   1.1     glass  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     63   1.1     glass  * SUCH DAMAGE.
     64   1.1     glass  *
     65   1.1     glass  *	from: @(#)SYS.h	8.1 (Berkeley) 6/4/93
     66   1.1     glass  */
     67   1.1     glass 
     68   1.1     glass #include <sys/syscall.h>
     69  1.10  jonathan #include <mips/asm.h>
     70   1.1     glass 
     71   1.7  jonathan 
     72   1.7  jonathan /*
     73   1.7  jonathan  * If compiling for shared libs, Emit sysV ABI PIC segment pseudo-ops.
     74   1.7  jonathan  *
     75   1.7  jonathan  * i)  Emit .abicalls before .LEAF entrypoint, and .cpload/.cprestore after.
     76   1.7  jonathan  * ii) Do interprocedure jumps indirectly via t9, with the side-effect of
     77   1.7  jonathan  *     preserving the callee's entry address in t9.
     78   1.7  jonathan  */
     79  1.16   thorpej #ifdef __ABICALLS__
     80  1.12   mycroft 	.abicalls
     81  1.12   mycroft # define PIC_PROLOGUE(x,sr)	.set noreorder; .cpload sr; .set reorder
     82  1.12   mycroft # define PIC_CALL(l,sr)		la sr, _C_LABEL(l); jr sr
     83   1.7  jonathan #else
     84  1.12   mycroft # define PIC_PROLOGUE(x,sr)
     85  1.12   mycroft # define PIC_CALL(l,sr)		j  _C_LABEL(l)
     86   1.7  jonathan #endif
     87   1.7  jonathan 
     88   1.7  jonathan 
     89  1.15       wiz #ifdef __STDC__
     90  1.15       wiz # define SYSTRAP(x)	li v0,SYS_ ## x; syscall;
     91  1.15       wiz #else
     92  1.15       wiz # define SYSTRAP(x)	li v0,SYS_/**/x; syscall;
     93  1.15       wiz #endif
     94   1.7  jonathan 
     95   1.7  jonathan 
     96   1.7  jonathan /*
     97   1.7  jonathan  * Do a syscall that cannot fail (sync, get{p,u,g,eu,eg)id)
     98   1.6       jtc  */
     99   1.9    kleink #define RSYSCALL_NOERROR(x)						\
    100   1.9    kleink 	PSEUDO_NOERROR(x,x)
    101   1.7  jonathan 
    102   1.7  jonathan /*
    103   1.7  jonathan  * Do a normal syscall.
    104   1.7  jonathan  */
    105   1.9    kleink #define RSYSCALL(x)							\
    106   1.7  jonathan 	PSEUDO(x,x)
    107   1.7  jonathan 
    108  1.13   thorpej /*
    109  1.13   thorpej  * Do a syscall that has an internal name and a weak external alias.
    110  1.13   thorpej  */
    111  1.13   thorpej #define	WSYSCALL(weak,strong)						\
    112  1.13   thorpej 	WEAK_ALIAS(weak,strong);					\
    113  1.13   thorpej 	PSEUDO(strong,weak)
    114   1.7  jonathan 
    115   1.7  jonathan /*
    116   1.7  jonathan  * Do a renamed or pseudo syscall (e.g., _exit()), where the entrypoint
    117   1.7  jonathan  * and syscall name are not the same.
    118   1.7  jonathan  */
    119   1.9    kleink #define PSEUDO_NOERROR(x,y)						\
    120  1.12   mycroft LEAF(x);								\
    121  1.12   mycroft 	SYSTRAP(y);							\
    122   1.9    kleink 	j ra;								\
    123   1.9    kleink 	END(x)
    124   1.9    kleink 
    125   1.9    kleink #define PSEUDO(x,y)							\
    126  1.12   mycroft LEAF(x);								\
    127  1.12   mycroft 	PIC_PROLOGUE(x,t9);						\
    128  1.12   mycroft 	SYSTRAP(y);							\
    129  1.12   mycroft 	bne a3,zero,err;						\
    130  1.12   mycroft 	j ra;								\
    131  1.12   mycroft err:									\
    132  1.12   mycroft 	PIC_CALL(__cerror,t9);						\
    133   1.7  jonathan 	END(x)
    134