Home | History | Annotate | Line # | Download | only in sparc
SYS.h revision 1.16
      1   1.1       cgd /*-
      2   1.1       cgd  * Copyright (c) 1992, 1993
      3   1.1       cgd  *	The Regents of the University of California.  All rights reserved.
      4   1.1       cgd  *
      5   1.1       cgd  * This software was developed by the Computer Systems Engineering group
      6   1.1       cgd  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
      7   1.1       cgd  * contributed to Berkeley.
      8   1.1       cgd  *
      9   1.1       cgd  * Redistribution and use in source and binary forms, with or without
     10   1.1       cgd  * modification, are permitted provided that the following conditions
     11   1.1       cgd  * are met:
     12   1.1       cgd  * 1. Redistributions of source code must retain the above copyright
     13   1.1       cgd  *    notice, this list of conditions and the following disclaimer.
     14   1.1       cgd  * 2. Redistributions in binary form must reproduce the above copyright
     15   1.1       cgd  *    notice, this list of conditions and the following disclaimer in the
     16   1.1       cgd  *    documentation and/or other materials provided with the distribution.
     17  1.15       agc  * 3. Neither the name of the University nor the names of its contributors
     18   1.1       cgd  *    may be used to endorse or promote products derived from this software
     19   1.1       cgd  *    without specific prior written permission.
     20   1.1       cgd  *
     21   1.1       cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     22   1.1       cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     23   1.1       cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24   1.1       cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     25   1.1       cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     26   1.1       cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     27   1.1       cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     28   1.1       cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     29   1.1       cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     30   1.1       cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     31   1.1       cgd  * SUCH DAMAGE.
     32   1.1       cgd  *
     33   1.1       cgd  *	@(#)SYS.h	8.1 (Berkeley) 6/4/93
     34   1.1       cgd  *
     35   1.1       cgd  *	from: Header: SYS.h,v 1.2 92/07/03 18:57:00 torek Exp
     36  1.16       uwe  *	$NetBSD: SYS.h,v 1.16 2005/05/20 23:56:15 uwe Exp $
     37   1.1       cgd  */
     38   1.1       cgd 
     39   1.3        pk #include <machine/asm.h>
     40   1.1       cgd #include <sys/syscall.h>
     41   1.1       cgd #include <machine/trap.h>
     42   1.1       cgd 
     43  1.14       wiz #ifdef __STDC__
     44   1.2        pk #define _CAT(x,y) x##y
     45  1.14       wiz #else
     46  1.14       wiz #define _CAT(x,y) x/**/y
     47  1.14       wiz #endif
     48   1.2        pk 
     49   1.9    kleink #ifdef __ELF__
     50   1.9    kleink #define CERROR		_C_LABEL(__cerror)
     51   1.9    kleink #define CURBRK		_C_LABEL(__curbrk)
     52   1.9    kleink #else
     53   1.9    kleink #define CERROR		_ASM_LABEL(cerror)
     54   1.9    kleink #define CURBRK		_ASM_LABEL(curbrk)
     55   1.9    kleink #endif
     56   1.9    kleink 
     57   1.1       cgd /*
     58  1.16       uwe  * ERROR branches to cerror.
     59   1.1       cgd  */
     60   1.3        pk #ifdef PIC
     61  1.16       uwe #define CALL(name)				\
     62  1.16       uwe 	PIC_PROLOGUE(%g1, %g2);			\
     63  1.16       uwe 	ld	[%g1 + name], %g2;		\
     64  1.16       uwe 	jmp	%g2;				\
     65  1.16       uwe 	 nop
     66   1.3        pk #else
     67  1.16       uwe #define	CALL(name)				\
     68  1.16       uwe 	set	name, %g1;			\
     69  1.16       uwe 	jmp	%g1;				\
     70  1.16       uwe 	 nop
     71   1.3        pk #endif
     72  1.11  christos #define	ERROR() CALL(CERROR)
     73   1.1       cgd 
     74   1.1       cgd /*
     75   1.1       cgd  * SYSCALL is used when further action must be taken before returning.
     76  1.16       uwe  * Note that it adds a `nop' over what we could do, if we only knew
     77  1.16       uwe  * what came at label 1....
     78   1.1       cgd  */
     79  1.16       uwe #define	_SYSCALL(x,y)				\
     80  1.16       uwe ENTRY(x);					\
     81  1.16       uwe 	mov	_CAT(SYS_,y), %g1;		\
     82  1.16       uwe 	t	ST_SYSCALL;			\
     83  1.16       uwe 	bcc	1f;				\
     84  1.16       uwe 	 nop;					\
     85  1.16       uwe 	ERROR();				\
     86  1.16       uwe 1:	/* next insn */
     87  1.10    kleink 
     88  1.16       uwe #define	SYSCALL(x)				\
     89  1.10    kleink 	_SYSCALL(x,x)
     90   1.1       cgd 
     91   1.1       cgd /*
     92  1.16       uwe  * RSYSCALL is used when the system call should just return.  Here we
     93  1.16       uwe  * use the SYSCALL_G2RFLAG to put the `success' return address in %g2
     94   1.1       cgd  * and avoid a branch.
     95  1.16       uwe  *
     96  1.16       uwe  * PSEUDO(x,y) is like RSYSCALL(y), except that the name is x.
     97   1.1       cgd  */
     98  1.16       uwe #define	_RSYSCALL(x,y)					\
     99  1.16       uwe ENTRY(x);						\
    100  1.16       uwe 	mov	(_CAT(SYS_,y)) | SYSCALL_G2RFLAG, %g1;	\
    101  1.16       uwe 	add	%o7, 8, %g2;				\
    102  1.16       uwe 	t	ST_SYSCALL;				\
    103  1.16       uwe 	ERROR()
    104   1.1       cgd 
    105  1.16       uwe #define	RSYSCALL(x)	_RSYSCALL(x,x)
    106  1.16       uwe #define	PSEUDO(x,y)	_RSYSCALL(x,y)
    107  1.12   thorpej 
    108  1.12   thorpej /*
    109  1.16       uwe  * WSYSCALL(weak,strong) is like RSYSCALL(weak),
    110  1.16       uwe  * except that weak is a weak internal alias for the strong symbol.
    111  1.12   thorpej  */
    112  1.12   thorpej #ifdef WEAK_ALIAS
    113  1.16       uwe #define	WSYSCALL(weak,strong)			\
    114  1.16       uwe 	WEAK_ALIAS(weak,strong);		\
    115  1.12   thorpej 	PSEUDO(strong,weak)
    116  1.12   thorpej #else
    117  1.16       uwe #define	WSYSCALL(weak,strong)			\
    118  1.12   thorpej 	RSYSCALL(weak)
    119  1.12   thorpej #endif
    120   1.4       jtc 
    121   1.4       jtc /*
    122  1.16       uwe  * SYSCALL_NOERROR is like SYSCALL, except it's used for syscalls that
    123  1.16       uwe  * never fail.
    124   1.4       jtc  *
    125   1.4       jtc  * XXX - This should be optimized.
    126   1.4       jtc  */
    127  1.16       uwe #define SYSCALL_NOERROR(x)			\
    128  1.16       uwe ENTRY(x);					\
    129  1.16       uwe 	mov	_CAT(SYS_,x), %g1;		\
    130  1.16       uwe 	t	ST_SYSCALL
    131   1.4       jtc 
    132   1.4       jtc /*
    133  1.16       uwe  * RSYSCALL_NOERROR is like RSYSCALL, except it's used for syscalls
    134   1.4       jtc  * that never fail.
    135   1.4       jtc  *
    136  1.16       uwe  * PSEUDO_NOERROR(x,y) is like RSYSCALL_NOERROR(y), except that the
    137  1.16       uwe  * name is x.
    138  1.16       uwe  *
    139   1.4       jtc  * XXX - This should be optimized.
    140   1.4       jtc  */
    141  1.16       uwe #define _RSYSCALL_NOERROR(x,y)				\
    142  1.16       uwe ENTRY(x);						\
    143  1.16       uwe 	mov	(_CAT(SYS_,y)) | SYSCALL_G2RFLAG, %g1;	\
    144  1.16       uwe 	add	%o7, 8, %g2;				\
    145  1.16       uwe 	t	ST_SYSCALL
    146   1.7    kleink 
    147  1.16       uwe #define RSYSCALL_NOERROR(x)	_RSYSCALL_NOERROR(x,x)
    148  1.16       uwe #define PSEUDO_NOERROR(x,y)	_RSYSCALL_NOERROR(x,y)
    149   1.1       cgd 
    150   1.9    kleink 	.globl	CERROR
    151