Home | History | Annotate | Line # | Download | only in mips
SYS.h revision 1.19
      1  1.19      matt /*	$NetBSD: SYS.h,v 1.19 2009/12/14 01:07:41 matt 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.19      matt # if defined(__mips_o32) || defined(__mips_o64)
     82  1.19      matt #  define PIC_PROLOGUE(x)	SETUP_GP
     83  1.19      matt #  define PIC_TAILCALL(l)	PTR_LA t9, _C_LABEL(l); jr t9
     84  1.19      matt #  define PIC_RETURN()		j ra
     85  1.19      matt # else
     86  1.19      matt #  define PIC_PROLOGUE(x)	SETUP_GP64(t3, x)
     87  1.19      matt #  define PIC_TAILCALL(l)	PTR_LA t9, _C_LABEL(l); RESTORE_GP64; jr t9
     88  1.19      matt #  define PIC_RETURN()		RESTORE_GP64; j ra
     89  1.19      matt # endif
     90   1.7  jonathan #else
     91  1.19      matt # define PIC_PROLOGUE(x)
     92  1.19      matt # define PIC_TAILCALL(l)	j  _C_LABEL(l)
     93  1.19      matt # define PIC_RETURN()
     94  1.19      matt #endif /* __ABICALLS__ */
     95   1.7  jonathan 
     96   1.7  jonathan 
     97  1.15       wiz #ifdef __STDC__
     98  1.15       wiz # define SYSTRAP(x)	li v0,SYS_ ## x; syscall;
     99  1.15       wiz #else
    100  1.15       wiz # define SYSTRAP(x)	li v0,SYS_/**/x; syscall;
    101  1.15       wiz #endif
    102   1.7  jonathan 
    103   1.7  jonathan 
    104   1.7  jonathan /*
    105   1.7  jonathan  * Do a syscall that cannot fail (sync, get{p,u,g,eu,eg)id)
    106   1.6       jtc  */
    107   1.9    kleink #define RSYSCALL_NOERROR(x)						\
    108   1.9    kleink 	PSEUDO_NOERROR(x,x)
    109   1.7  jonathan 
    110   1.7  jonathan /*
    111   1.7  jonathan  * Do a normal syscall.
    112   1.7  jonathan  */
    113   1.9    kleink #define RSYSCALL(x)							\
    114   1.7  jonathan 	PSEUDO(x,x)
    115   1.7  jonathan 
    116  1.13   thorpej /*
    117  1.13   thorpej  * Do a syscall that has an internal name and a weak external alias.
    118  1.13   thorpej  */
    119  1.13   thorpej #define	WSYSCALL(weak,strong)						\
    120  1.13   thorpej 	WEAK_ALIAS(weak,strong);					\
    121  1.13   thorpej 	PSEUDO(strong,weak)
    122   1.7  jonathan 
    123   1.7  jonathan /*
    124   1.7  jonathan  * Do a renamed or pseudo syscall (e.g., _exit()), where the entrypoint
    125   1.7  jonathan  * and syscall name are not the same.
    126   1.7  jonathan  */
    127   1.9    kleink #define PSEUDO_NOERROR(x,y)						\
    128  1.12   mycroft LEAF(x);								\
    129  1.12   mycroft 	SYSTRAP(y);							\
    130   1.9    kleink 	j ra;								\
    131   1.9    kleink 	END(x)
    132   1.9    kleink 
    133   1.9    kleink #define PSEUDO(x,y)							\
    134  1.12   mycroft LEAF(x);								\
    135  1.19      matt 	PIC_PROLOGUE(x);						\
    136  1.12   mycroft 	SYSTRAP(y);							\
    137  1.12   mycroft 	bne a3,zero,err;						\
    138  1.19      matt 	PIC_RETURN();							\
    139  1.12   mycroft err:									\
    140  1.19      matt 	PIC_TAILCALL(__cerror);						\
    141  1.19      matt END(x)
    142