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