Home | History | Annotate | Line # | Download | only in i386
SYS.h revision 1.21.4.1
      1      1.21       ad /*	$NetBSD: SYS.h,v 1.21.4.1 2008/01/09 01:33:56 matt Exp $	*/
      2      1.21       ad 
      3      1.21       ad /*-
      4      1.21       ad  * Copyright (c) 2007 The NetBSD Foundation, Inc.
      5      1.21       ad  * All rights reserved.
      6      1.21       ad  *
      7      1.21       ad  * This code is derived from software contributed to The NetBSD Foundation
      8      1.21       ad  * by Andrew Doran.
      9      1.21       ad  *
     10      1.21       ad  * Redistribution and use in source and binary forms, with or without
     11      1.21       ad  * modification, are permitted provided that the following conditions
     12      1.21       ad  * are met:
     13      1.21       ad  * 1. Redistributions of source code must retain the above copyright
     14      1.21       ad  *    notice, this list of conditions and the following disclaimer.
     15      1.21       ad  * 2. Redistributions in binary form must reproduce the above copyright
     16      1.21       ad  *    notice, this list of conditions and the following disclaimer in the
     17      1.21       ad  *    documentation and/or other materials provided with the distribution.
     18      1.21       ad  * 3. All advertising materials mentioning features or use of this software
     19      1.21       ad  *    must display the following acknowledgement:
     20      1.21       ad  *	This product includes software developed by the NetBSD
     21      1.21       ad  *	Foundation, Inc. and its contributors.
     22      1.21       ad  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23      1.21       ad  *    contributors may be used to endorse or promote products derived
     24      1.21       ad  *    from this software without specific prior written permission.
     25      1.21       ad  *
     26      1.21       ad  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27      1.21       ad  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28      1.21       ad  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29      1.21       ad  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30      1.21       ad  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31      1.21       ad  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32      1.21       ad  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33      1.21       ad  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34      1.21       ad  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35      1.21       ad  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36      1.21       ad  * POSSIBILITY OF SUCH DAMAGE.
     37      1.21       ad  */
     38      1.21       ad 
     39       1.1      cgd /*-
     40       1.1      cgd  * Copyright (c) 1990 The Regents of the University of California.
     41       1.1      cgd  * All rights reserved.
     42       1.1      cgd  *
     43       1.1      cgd  * This code is derived from software contributed to Berkeley by
     44       1.1      cgd  * William Jolitz.
     45       1.1      cgd  *
     46       1.1      cgd  * Redistribution and use in source and binary forms, with or without
     47       1.1      cgd  * modification, are permitted provided that the following conditions
     48       1.1      cgd  * are met:
     49       1.1      cgd  * 1. Redistributions of source code must retain the above copyright
     50       1.1      cgd  *    notice, this list of conditions and the following disclaimer.
     51       1.1      cgd  * 2. Redistributions in binary form must reproduce the above copyright
     52       1.1      cgd  *    notice, this list of conditions and the following disclaimer in the
     53       1.1      cgd  *    documentation and/or other materials provided with the distribution.
     54      1.20      agc  * 3. Neither the name of the University nor the names of its contributors
     55       1.1      cgd  *    may be used to endorse or promote products derived from this software
     56       1.1      cgd  *    without specific prior written permission.
     57       1.1      cgd  *
     58       1.1      cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     59       1.1      cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     60       1.1      cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     61       1.1      cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     62       1.1      cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     63       1.1      cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     64       1.1      cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     65       1.1      cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     66       1.1      cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     67       1.1      cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     68       1.1      cgd  * SUCH DAMAGE.
     69       1.1      cgd  *
     70       1.1      cgd  *	from: @(#)SYS.h	5.5 (Berkeley) 5/7/91
     71       1.1      cgd  */
     72       1.1      cgd 
     73       1.1      cgd #include <machine/asm.h>
     74       1.1      cgd #include <sys/syscall.h>
     75       1.1      cgd 
     76      1.19      wiz #ifdef __STDC__
     77      1.21       ad #define _SYSNAM(x)	$(SYS_ ## x)
     78      1.19      wiz #else
     79      1.21       ad #define	_SYSNAM(x)	$(SYS_/**/x)
     80      1.19      wiz #endif
     81       1.8      jtc 
     82      1.21       ad #define OSYSTRAP(x)			\
     83      1.21       ad 	movl _SYSNAM(x),%eax		;\
     84      1.21       ad 	int $0x80
     85      1.21       ad 
     86      1.21       ad #ifdef I686_LIBC
     87      1.21       ad #define SYSTRAP(x)			\
     88      1.21       ad 	pushl	%ebx			;\
     89      1.21       ad 	movl	_SYSNAM(x),%eax		;\
     90      1.21       ad 	movl	$123f,%edx		;\
     91      1.21       ad 	movl	%esp,%ecx		;\
     92      1.21       ad 	sysenter			;\
     93      1.21       ad 123:	movl	%ebx,%edx		;\
     94      1.21       ad 	popl	%ebx
     95      1.21       ad #else	/* I686_LIBC */
     96      1.21       ad #define SYSTRAP(x)	OSYSTRAP(x)
     97      1.21       ad #endif	/* I686_LIBC */
     98      1.21       ad 
     99      1.12   kleink #ifdef __ELF__
    100      1.12   kleink #define CERROR		_C_LABEL(__cerror)
    101      1.12   kleink #define CURBRK		_C_LABEL(__curbrk)
    102      1.12   kleink #else
    103      1.12   kleink #define CERROR		_ASM_LABEL(cerror)
    104      1.12   kleink #define CURBRK		_ASM_LABEL(curbrk)
    105      1.12   kleink #endif
    106       1.8      jtc 
    107      1.11   kleink #define _SYSCALL_NOERROR(x,y)						\
    108      1.11   kleink 	ENTRY(x);							\
    109      1.11   kleink 	SYSTRAP(y)
    110      1.11   kleink 
    111      1.15  mycroft #ifdef PIC
    112  1.21.4.1     matt #define _SYSCALL_ERR							\
    113  1.21.4.1     matt 	PIC_PROLOGUE;							\
    114  1.21.4.1     matt 	mov PIC_GOT(CERROR), %ecx;					\
    115  1.21.4.1     matt 	PIC_EPILOGUE;							\
    116  1.21.4.1     matt 	jmp *%ecx
    117      1.15  mycroft #else
    118  1.21.4.1     matt #define _SYSCALL_ERR							\
    119  1.21.4.1     matt 	jmp CERROR
    120  1.21.4.1     matt #endif
    121  1.21.4.1     matt 
    122      1.15  mycroft #define _SYSCALL(x,y)							\
    123      1.15  mycroft 	.text; _ALIGN_TEXT;						\
    124  1.21.4.1     matt 	2: _SYSCALL_ERR;						\
    125      1.15  mycroft 	_SYSCALL_NOERROR(x,y);						\
    126      1.15  mycroft 	jc 2b
    127      1.10      jtc 
    128      1.11   kleink #define SYSCALL_NOERROR(x)						\
    129      1.11   kleink 	_SYSCALL_NOERROR(x,x)
    130      1.11   kleink 
    131      1.11   kleink #define SYSCALL(x)							\
    132      1.11   kleink 	_SYSCALL(x,x)
    133      1.11   kleink 
    134      1.11   kleink #define PSEUDO_NOERROR(x,y)						\
    135      1.11   kleink 	_SYSCALL_NOERROR(x,y);						\
    136      1.10      jtc 	ret
    137      1.10      jtc 
    138      1.11   kleink #define PSEUDO(x,y)							\
    139  1.21.4.1     matt 	_SYSCALL_NOERROR(x,y);						\
    140  1.21.4.1     matt 	jc 2f;								\
    141  1.21.4.1     matt 	ret;								\
    142  1.21.4.1     matt 	2: _SYSCALL_ERR
    143      1.10      jtc 
    144      1.11   kleink #define RSYSCALL_NOERROR(x)						\
    145      1.11   kleink 	PSEUDO_NOERROR(x,x)
    146      1.11   kleink 
    147      1.11   kleink #define RSYSCALL(x)							\
    148      1.11   kleink 	PSEUDO(x,x)
    149      1.11   kleink 
    150      1.16  thorpej #ifdef WEAK_ALIAS
    151      1.16  thorpej #define	WSYSCALL(weak,strong)						\
    152      1.16  thorpej 	WEAK_ALIAS(weak,strong);					\
    153      1.16  thorpej 	PSEUDO(strong,weak)
    154      1.16  thorpej #else
    155      1.16  thorpej #define	WSYSCALL(weak,strong)						\
    156      1.16  thorpej 	PSEUDO(weak,weak)
    157      1.16  thorpej #endif
    158       1.1      cgd 
    159      1.12   kleink 	.globl	CERROR
    160