2000-10-15 06:50:42 +00:00
|
|
|
/* Assembler macros for PA-RISC.
|
2003-03-23 19:44:31 +00:00
|
|
|
Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
|
2000-10-15 06:50:42 +00:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
Contributed by Ulrich Drepper, <drepper@cygnus.com>, August 1999.
|
|
|
|
Linux/PA-RISC changes by Philipp Rumpf, <prumpf@tux.org>, March 2000.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 04:58:11 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
2000-10-15 06:50:42 +00:00
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2001-07-06 04:58:11 +00:00
|
|
|
Lesser General Public License for more details.
|
2000-10-15 06:50:42 +00:00
|
|
|
|
2001-07-06 04:58:11 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with the GNU C Library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
|
|
02111-1307 USA. */
|
2000-10-15 06:50:42 +00:00
|
|
|
|
|
|
|
#include <asm/unistd.h>
|
|
|
|
#include <sysdeps/generic/sysdep.h>
|
|
|
|
#include <sys/syscall.h>
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#ifndef ASM_LINE_SEP
|
2003-10-15 05:47:36 +00:00
|
|
|
# define ASM_LINE_SEP ;
|
2000-10-15 06:50:42 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#undef SYS_ify
|
|
|
|
#define SYS_ify(syscall_name) (__NR_##syscall_name)
|
|
|
|
|
2003-10-15 05:47:36 +00:00
|
|
|
#ifdef PIC
|
|
|
|
/* WARNING: CANNOT BE USED IN A NOP! */
|
|
|
|
# define STW_PIC stw %r19, -32(%sr0, %sp) ASM_LINE_SEP
|
|
|
|
# define LDW_PIC ldw -32(%sr0, %sp), %r19 ASM_LINE_SEP
|
|
|
|
# define STW_ASM_PIC " copy %%r19, %%r4\n"
|
|
|
|
# define LDW_ASM_PIC " copy %%r4, %%r19\n"
|
|
|
|
# define USING_GR4 "%r4",
|
|
|
|
#else
|
|
|
|
# define STW_PIC ASM_LINE_SEP
|
|
|
|
# define LDW_PIC ASM_LINE_SEP
|
|
|
|
# define STW_ASM_PIC " \n"
|
|
|
|
# define LDW_ASM_PIC " \n"
|
|
|
|
# define USING_GR4
|
|
|
|
#endif
|
2000-10-15 06:50:42 +00:00
|
|
|
|
|
|
|
#ifdef __ASSEMBLER__
|
|
|
|
|
|
|
|
/* Syntactic details of assembler. */
|
|
|
|
|
|
|
|
#define ALIGNARG(log2) log2
|
|
|
|
|
|
|
|
/* For Linux we can use the system call table in the header file
|
|
|
|
/usr/include/asm/unistd.h
|
|
|
|
of the kernel. But these symbols do not follow the SYS_* syntax
|
|
|
|
so we have to redefine the `SYS_ify' macro here. */
|
|
|
|
#undef SYS_ify
|
|
|
|
#define SYS_ify(syscall_name) __NR_##syscall_name
|
|
|
|
|
|
|
|
/* ELF-like local names start with `.L'. */
|
|
|
|
#undef L
|
|
|
|
#define L(name) .L##name
|
|
|
|
|
|
|
|
/* Linux uses a negative return value to indicate syscall errors,
|
|
|
|
unlike most Unices, which use the condition codes' carry flag.
|
|
|
|
|
|
|
|
Since version 2.1 the return value of a system call might be
|
|
|
|
negative even if the call succeeded. E.g., the `lseek' system call
|
|
|
|
might return a large offset. Therefore we must not anymore test
|
|
|
|
for < 0, but test for a real error by making sure the value in %eax
|
|
|
|
is a real error number. Linus said he will make sure the no syscall
|
|
|
|
returns a value in -1 .. -4095 as a valid result so we can safely
|
|
|
|
test with -4095. */
|
|
|
|
|
|
|
|
/* We don't want the label for the error handle to be global when we define
|
|
|
|
it here. */
|
|
|
|
#ifdef PIC
|
|
|
|
# define SYSCALL_ERROR_LABEL 0f
|
|
|
|
#else
|
|
|
|
# define SYSCALL_ERROR_LABEL syscall_error
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Define an entry point visible from C.
|
|
|
|
|
|
|
|
There is currently a bug in gdb which prevents us from specifying
|
|
|
|
incomplete stabs information. Fake some entries here which specify
|
|
|
|
the current source file. */
|
|
|
|
#define ENTRY(name) \
|
|
|
|
.text ASM_LINE_SEP \
|
|
|
|
.export C_SYMBOL_NAME(name) ASM_LINE_SEP \
|
|
|
|
.type C_SYMBOL_NAME(name),@function ASM_LINE_SEP \
|
2003-10-15 05:47:36 +00:00
|
|
|
C_LABEL(name) ASM_LINE_SEP \
|
|
|
|
CALL_MCOUNT ASM_LINE_SEP
|
2003-03-23 19:44:31 +00:00
|
|
|
|
2000-10-15 06:50:42 +00:00
|
|
|
#undef END
|
2003-10-15 05:47:36 +00:00
|
|
|
#define END(name) \
|
|
|
|
1: ASM_LINE_SEP \
|
|
|
|
.size C_SYMBOL_NAME(name),1b-C_SYMBOL_NAME(name) ASM_LINE_SEP
|
2000-10-15 06:50:42 +00:00
|
|
|
|
|
|
|
/* If compiled for profiling, call `mcount' at the start of each function. */
|
2001-04-20 06:06:55 +00:00
|
|
|
/* No, don't bother. gcc will put the call in for us. */
|
2000-10-15 06:50:42 +00:00
|
|
|
#define CALL_MCOUNT /* Do nothing. */
|
|
|
|
|
|
|
|
/* syscall wrappers consist of
|
|
|
|
#include <sysdep.h>
|
|
|
|
PSEUDO(...)
|
|
|
|
ret
|
|
|
|
PSEUDO_END(...)
|
|
|
|
|
|
|
|
which means
|
|
|
|
ENTRY(name)
|
|
|
|
DO_CALL(...)
|
|
|
|
nop
|
|
|
|
bv 0(2)
|
|
|
|
nop
|
|
|
|
*/
|
|
|
|
|
2003-10-15 05:47:36 +00:00
|
|
|
#define PSEUDO(name, syscall_name, args) \
|
|
|
|
ENTRY (name) \
|
|
|
|
DO_CALL(syscall_name, args) ASM_LINE_SEP \
|
|
|
|
nop ASM_LINE_SEP
|
|
|
|
|
|
|
|
#define ret \
|
|
|
|
/* Return value set by ERRNO code */ ASM_LINE_SEP \
|
|
|
|
bv 0(2) ASM_LINE_SEP \
|
|
|
|
nop ASM_LINE_SEP
|
2000-10-15 06:50:42 +00:00
|
|
|
|
|
|
|
#undef PSEUDO_END
|
2003-10-15 05:47:36 +00:00
|
|
|
#define PSEUDO_END(name) \
|
2000-10-15 06:50:42 +00:00
|
|
|
END (name)
|
|
|
|
|
2003-10-15 05:47:36 +00:00
|
|
|
/* We don't set the errno on the return from the syscall */
|
|
|
|
#define PSEUDO_NOERRNO(name, syscall_name, args) \
|
|
|
|
ENTRY (name) \
|
|
|
|
DO_CALL_NOERRNO(syscall_name, args) ASM_LINE_SEP \
|
|
|
|
nop ASM_LINE_SEP
|
|
|
|
|
|
|
|
#define ret_NOERRNO ret
|
2003-03-23 19:44:31 +00:00
|
|
|
|
|
|
|
#undef PSEUDO_END_NOERRNO
|
2003-10-15 05:47:36 +00:00
|
|
|
#define PSEUDO_END_NOERRNO(name) \
|
2003-03-23 19:44:31 +00:00
|
|
|
END (name)
|
|
|
|
|
2003-10-15 05:47:36 +00:00
|
|
|
/* This has to return the error value */
|
|
|
|
#undef PSEUDO_ERRVAL
|
|
|
|
#define PSEUDO_ERRVAL(name, syscall_name, args) \
|
|
|
|
ENTRY(name) \
|
|
|
|
DO_CALL_ERRVAL(syscall_name, args) ASM_LINE_SEP \
|
|
|
|
nop ASM_LINE_SEP
|
|
|
|
|
|
|
|
#define ret_ERRVAL ret
|
|
|
|
|
|
|
|
#undef PSEUDO_END_ERRVAL
|
|
|
|
#define PSEUDO_END_ERRVAL(name) \
|
|
|
|
END(name)
|
|
|
|
|
|
|
|
#undef JUMPTARGET
|
2000-10-15 06:50:42 +00:00
|
|
|
#define JUMPTARGET(name) name
|
|
|
|
#define SYSCALL_PIC_SETUP /* Nothing. */
|
|
|
|
|
2003-10-15 05:47:36 +00:00
|
|
|
|
|
|
|
/* All the syscall assembly macros rely on finding the approriate
|
|
|
|
SYSCALL_ERROR_LABEL or rather HANDLER. */
|
|
|
|
|
|
|
|
/* int * __errno_location(void) so you have to store your value
|
|
|
|
into the return address! */
|
|
|
|
#define DEFAULT_SYSCALL_ERROR_HANDLER \
|
|
|
|
.import __errno_location,code ASM_LINE_SEP \
|
|
|
|
/* branch to errno handler */ ASM_LINE_SEP \
|
|
|
|
bl __errno_location,%rp ASM_LINE_SEP
|
|
|
|
|
|
|
|
/* Here are the myriad of configuration options that the above can
|
|
|
|
work for... what we've done is provide the framework for future
|
|
|
|
changes if required to each section */
|
|
|
|
|
|
|
|
#ifdef PIC
|
|
|
|
# if RTLD_PRIVATE_ERRNO
|
|
|
|
# define SYSCALL_ERROR_HANDLER DEFAULT_SYSCALL_ERROR_HANDLER
|
|
|
|
# else /* !RTLD_PRIVATE_ERRNO */
|
|
|
|
# if defined _LIBC_REENTRANT
|
|
|
|
# define SYSCALL_ERROR_HANDLER DEFAULT_SYSCALL_ERROR_HANDLER
|
|
|
|
# else /* !_LIBC_REENTRANT */
|
|
|
|
# define SYSCALL_ERROR_HANDLER DEFAULT_SYSCALL_ERROR_HANDLER
|
|
|
|
# endif /* _LIBC_REENTRANT */
|
|
|
|
# endif /* RTLD_PRIVATE_ERRNO */
|
|
|
|
#else
|
|
|
|
# ifndef _LIBC_REENTRANT
|
|
|
|
# define SYSCALL_ERROR_HANDLER DEFAULT_SYSCALL_ERROR_HANDLER
|
|
|
|
# else
|
|
|
|
# define SYSCALL_ERROR_HANDLER DEFAULT_SYSCALL_ERROR_HANDLER
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2000-10-15 06:50:42 +00:00
|
|
|
/* Linux takes system call arguments in registers:
|
|
|
|
syscall number gr20
|
|
|
|
arg 1 gr26
|
|
|
|
arg 2 gr25
|
|
|
|
arg 3 gr24
|
|
|
|
arg 4 gr23
|
|
|
|
arg 5 gr22
|
|
|
|
arg 6 gr21
|
|
|
|
|
|
|
|
The compiler calls us by the C convention:
|
|
|
|
syscall number in the DO_CALL macro
|
|
|
|
arg 1 gr26
|
|
|
|
arg 2 gr25
|
|
|
|
arg 3 gr24
|
|
|
|
arg 4 gr23
|
|
|
|
arg 5 -52(gr30)
|
|
|
|
arg 6 -56(gr30)
|
|
|
|
|
|
|
|
gr22 and gr21 are caller-saves, so we can just load the arguments
|
|
|
|
there and generally be happy. */
|
|
|
|
|
|
|
|
/* the cmpb...no_error code below inside DO_CALL
|
|
|
|
* is intended to mimic the if (__sys_res...)
|
|
|
|
* code inside INLINE_SYSCALL
|
|
|
|
*/
|
|
|
|
|
|
|
|
#undef DO_CALL
|
* locale/programs/ld-ctype.c (ctype_read): When given a repertoire
name of "", store a null pointer instead.
* configure.in (elf): Set to yes for freebsd*, netbsd*.
* configure: Regenerated.
* locale/xlocale.c [! (USE_TLS && HAVE___THREAD)] (__libc_tsd_LOCALE):
Initialize this instead of __libc_tsd_LOCALE_data.
* sysdeps/unix/grantpt.c (pts_name): Convert ENOTTY return from
ptsname_r to EINVAL.
* sysdeps/generic/ptsname.c (__ptsname_r): Return ENOSYS instead of 0.
* rt/Makefile: Revert last change, it was inappropriate to presume aio
implementations depend on pthreads.
* rt/tst-aio.c (do_test): Exit happy if first failure is ENOSYS.
* rt/tst-aio64.c (do_test): Likewise.
* rt/tst-aio2.c (do_test): Likewise.
* rt/tst-aio3.c (do_test): Likewise.
* rt/tst-aio4.c (do_test): Likewise.
* rt/tst-aio5.c (do_test): Likewise.
* rt/tst-aio6.c (do_test): Likewise.
* rt/tst-aio7.c (do_test): Likewise.
* sysdeps/generic/bits/libc-lock.h (__libc_setspecific): Use a cast to
void so as to avoid compiler warnings.
* libio/oldstdfiles.c [! _IO_MTSAFE_IO] (DEF_STDFILE): Don't define
_IO_wide_data_FD, which is never used here.
* libio/iofread.c
[! _IO_MTSAFE_IO] (fread_unlocked): Add libc_hidden_ver defn.
* libio/iofputs.c [! _IO_MTSAFE_IO] (fputs_unlocked): Likewise.
* libio/iofgets.c [! _IO_MTSAFE_IO] (fgets_unlocked): Likewise.
* include/resolv.h [! _LIBC_REENTRANT] (_res): #undef it before decl.
* include/netdb.h [! _LIBC_REENTRANT] (h_errno): Declare normal extern.
* misc/syslog.c (openlog): Conditionalize locking on [_LIBC_REENTRANT].
(closelog): Likewise.
2002-07-06 Bruno Haible <bruno@clisp.org>
* sysdeps/alpha/fpu/fpu_control.h: Comment fix.
* sysdeps/unix/sysv/linux/alpha/pipe.S: Moved to ...
* sysdeps/unix/alpha/pipe.S: ... here.
* sysdeps/unix/bsd/osf/alpha/pipe.S: File removed.
* sysdeps/unix/i386/brk.S: Rename local label to '.Lhere' in ELF.
* sysdeps/unix/i386/brk.S: Add PSEUDO_END invocation.
* sysdeps/unix/i386/fork.S: Likewise.
* sysdeps/unix/i386/pipe.S: Likewise.
* sysdeps/unix/i386/wait.S: Likewise.
* sysdeps/unix/fork.S: Fix PSEUDO_END argument.
* sysdeps/unix/arm/fork.S: Likewise.
* sysdeps/unix/sysv/linux/arm/sysdep.h (PSEUDO): Swap DO_CALL
arguments.
(DO_CALL): Swap argument order.
* sysdeps/unix/sysv/linux/hppa/sysdep.h (PSEUDO): Swap DO_CALL
arguments.
(DO_CALL): Swap argument order.
* sysdeps/unix/sysv/linux/i386/sysdep.h (PSEUDO): Swap DO_CALL
arguments.
(DO_CALL): Swap argument order.
* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h (PSEUDO): Swap DO_CALL
arguments.
(DO_CALL): Swap argument order.
* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h (PSEUDO): Swap DO_CALL
arguments.
(DO_CALL): Swap argument order.
* sysdeps/unix/sysv/linux/sh/sysdep.h (PSEUDO): Swap DO_CALL
arguments.
(DO_CALL): Swap argument order.
* sysdeps/unix/sysv/linux/x86_64/sysdep.h (PSEUDO): Swap DO_CALL
arguments.
(DO_CALL): Swap argument order.
* sysdeps/i386/sysdep.h (PSEUDO): Fix syntax error.
(L): Define right for ELF.
* sysdeps/unix/sysv/linux/i386/sysdep.h (L): Remove definition.
Now defined in sysdeps/i386/sysdep.h.
* sysdeps/posix/readv.c: Ansify function definition.
* sysdeps/posix/writev.c: Likewise.
* stdio-common/tst-fseek.c (main): Don't assume that off_t and size_t
have the same size. Avoid direct cast from size_t to off_t.
* login/tst-utmp.c (simulate_login): Don't leave garbage after the
nul byte in entry[n].ut_user.
(simulate_logout): Likewise.
* login/programs/utmpdump.c (print_entry): Test _HAVE_UT_TYPE,
_HAVE_UT_PID, _HAVE_UT_ID, _HAVE_UT_HOST, instead of assuming the
existence of corresponding members of 'struct utmp'.
* login/tst-utmp.c: Trivialize the test if testing 'struct utmp' and
!_HAVE_UT_TYPE.
* sysdeps/unix/opendir.c (__opendir): If st_blksize is 0 or too small,
allocate a buffer of at least BUFSIZ bytes, not just of
sizeof (struct dirent).
* sysdeps/generic/glob.c: Include <limits.h>.
(NAME_MAX): Define a fallback.
(glob_in_dir): Allocate enough room for a 'struct dirent64' on the
stack.
* posix/tst-dir.c: Include <stddef.h>, for offsetof.
(main): Allocate enough room for a 'struct dirent64' on the stack.
* posix/tst-gnuglob.c (my_DIR): Allocate enough room for a
'struct dirent'.
* sysdeps/unix/sysv/linux/init-first.c: Don't include
kernel-features.h.
* inet/htontest.c: Include <sys/types.h>.
* sysdeps/generic/sys/sysinfo.h: Surround with __{BEGIN,END}_DECLS.
* include/sys/sysctl.h: Comment fix.
* elf/rtld.c (_rtld_global) [! _LIBC_REENTRANT]: Don't initialize
_dl_load_lock.
* libio/fileno.c (fileno_unlocked): Define regardless of _IO_MTSAFE_IO.
* sysdeps/unix/bsd/bsd4.4/syscalls.list (__sigaltstack): New alias.
* sysdeps/unix/inet/syscalls.list (__connect_internal): New alias.
(__getpeername): New alias.
(__getsockname): New alias.
(__socket): New alias.
* sysdeps/unix/common/syscalls.list (getpgid): Remove.
* sysdeps/unix/syscalls.list (__chown_internal): New alias.
(__fcntl_internal): New alias.
(__profil): New alias.
2002-08-26 11:39:12 +00:00
|
|
|
#define DO_CALL(syscall_name, args) \
|
2003-10-15 05:47:36 +00:00
|
|
|
DOARGS_##args ASM_LINE_SEP \
|
|
|
|
STW_PIC ASM_LINE_SEP \
|
|
|
|
/* Do syscall, delay loads # */ ASM_LINE_SEP \
|
2000-10-15 06:50:42 +00:00
|
|
|
ble 0x100(%sr2,%r0) ASM_LINE_SEP \
|
|
|
|
ldi SYS_ify (syscall_name), %r20 ASM_LINE_SEP \
|
|
|
|
ldi -0x1000,%r1 ASM_LINE_SEP \
|
|
|
|
cmpb,>>=,n %r1,%ret0,0f ASM_LINE_SEP \
|
2003-10-15 05:47:36 +00:00
|
|
|
/* save rp or we get lost */ ASM_LINE_SEP \
|
|
|
|
stw %rp, -20(%sr0,%sp) ASM_LINE_SEP \
|
|
|
|
/* Restore r19 from frame */ ASM_LINE_SEP \
|
|
|
|
LDW_PIC ASM_LINE_SEP \
|
|
|
|
stw %ret0, -24(%sr0,%sp) ASM_LINE_SEP \
|
|
|
|
SYSCALL_ERROR_HANDLER ASM_LINE_SEP \
|
|
|
|
/* create frame */ ASM_LINE_SEP \
|
|
|
|
ldo 64(%sp), %sp ASM_LINE_SEP \
|
|
|
|
ldo -64(%sp), %sp ASM_LINE_SEP \
|
|
|
|
/* OPTIMIZE: Don't reload r19 */ ASM_LINE_SEP \
|
|
|
|
/* do a -1*syscall_ret0 */ ASM_LINE_SEP \
|
|
|
|
ldw -24(%sr0,%sp), %r26 ASM_LINE_SEP \
|
2000-10-15 06:50:42 +00:00
|
|
|
sub %r0, %r26, %r26 ASM_LINE_SEP \
|
2003-10-15 05:47:36 +00:00
|
|
|
/* Store into errno location */ ASM_LINE_SEP \
|
2000-10-15 06:50:42 +00:00
|
|
|
stw %r26, 0(%sr0,%ret0) ASM_LINE_SEP \
|
2003-10-15 05:47:36 +00:00
|
|
|
/* return -1 as error */ ASM_LINE_SEP \
|
2000-10-15 06:50:42 +00:00
|
|
|
ldo -1(%r0), %ret0 ASM_LINE_SEP \
|
2003-10-15 05:47:36 +00:00
|
|
|
ldw -20(%sr0,%sp), %rp ASM_LINE_SEP \
|
2000-10-15 06:50:42 +00:00
|
|
|
0: ASM_LINE_SEP \
|
2003-10-15 05:47:36 +00:00
|
|
|
UNDOARGS_##args ASM_LINE_SEP
|
|
|
|
|
|
|
|
/* We do nothing with the return, except hand it back to someone else */
|
|
|
|
#undef DO_CALL_NOERRNO
|
|
|
|
#define DO_CALL_NOERRNO(syscall_name, args) \
|
|
|
|
DOARGS_##args \
|
|
|
|
/* No need to store r19 */ ASM_LINE_SEP \
|
|
|
|
ble 0x100(%sr2,%r0) ASM_LINE_SEP \
|
|
|
|
ldi SYS_ify (syscall_name), %r20 ASM_LINE_SEP \
|
|
|
|
/* Caller will restore r19 */ ASM_LINE_SEP \
|
2000-10-15 06:50:42 +00:00
|
|
|
UNDOARGS_##args
|
|
|
|
|
2003-10-15 05:47:36 +00:00
|
|
|
/* Here, we return the ERRVAL in assembly, note we don't call the
|
|
|
|
error handler function, but we do 'negate' the return _IF_
|
|
|
|
it's an error. Not sure if this is the right semantic. */
|
|
|
|
|
|
|
|
#undef DO_CALL_ERRVAL
|
|
|
|
#define DO_CALL_ERRVAL(syscall_name, args) \
|
|
|
|
DOARGS_##args ASM_LINE_SEP \
|
|
|
|
/* No need to store r19 */ ASM_LINE_SEP \
|
|
|
|
ble 0x100(%sr2,%r0) ASM_LINE_SEP \
|
|
|
|
ldi SYS_ify (syscall_name), %r20 ASM_LINE_SEP \
|
|
|
|
/* Caller will restore r19 */ ASM_LINE_SEP \
|
|
|
|
ldi -0x1000,%r1 ASM_LINE_SEP \
|
|
|
|
cmpb,>>=,n %r1,%ret0,0f ASM_LINE_SEP \
|
|
|
|
sub %r0, %ret0, %ret0 ASM_LINE_SEP \
|
|
|
|
0: ASM_LINE_SEP \
|
|
|
|
UNDOARGS_##args ASM_LINE_SEP
|
|
|
|
|
2000-10-15 06:50:42 +00:00
|
|
|
#define DOARGS_0 /* nothing */
|
|
|
|
#define DOARGS_1 /* nothing */
|
|
|
|
#define DOARGS_2 /* nothing */
|
|
|
|
#define DOARGS_3 /* nothing */
|
|
|
|
#define DOARGS_4 /* nothing */
|
|
|
|
#define DOARGS_5 ldw -52(%r30), %r22 ASM_LINE_SEP
|
|
|
|
#define DOARGS_6 ldw -52(%r30), %r22 ASM_LINE_SEP \
|
|
|
|
ldw -56(%r30), %r21 ASM_LINE_SEP
|
|
|
|
|
|
|
|
|
|
|
|
#define UNDOARGS_0 /* nothing */
|
|
|
|
#define UNDOARGS_1 /* nothing */
|
|
|
|
#define UNDOARGS_2 /* nothing */
|
|
|
|
#define UNDOARGS_3 /* nothing */
|
|
|
|
#define UNDOARGS_4 /* nothing */
|
|
|
|
#define UNDOARGS_5 /* nothing */
|
|
|
|
#define UNDOARGS_6 /* nothing */
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2003-10-15 05:47:36 +00:00
|
|
|
/* GCC has to be warned that a syscall may clobber all the ABI
|
|
|
|
registers listed as "caller-saves", see page 8, Table 2
|
|
|
|
in section 2.2.6 of the PA-RISC RUN-TIME architecture
|
|
|
|
document. However! r28 is the result and will conflict with
|
|
|
|
the clobber list so it is left out. Also the input arguments
|
|
|
|
registers r20 -> r26 will conflict with the list so they
|
|
|
|
are treated specially. Although r19 is clobbered by the syscall
|
|
|
|
we cannot say this because it would violate ABI, thus we say
|
|
|
|
r4 is clobbered and use that register to save/restore r19
|
|
|
|
across the syscall. */
|
|
|
|
|
|
|
|
#define CALL_CLOB_REGS "%r1", "%r2", USING_GR4 \
|
|
|
|
"%r20", "%r29", "%r31"
|
|
|
|
|
2000-10-15 06:50:42 +00:00
|
|
|
#undef INLINE_SYSCALL
|
2003-10-15 05:47:36 +00:00
|
|
|
#define INLINE_SYSCALL(name, nr, args...) ({ \
|
|
|
|
long __sys_res; \
|
|
|
|
{ \
|
|
|
|
register unsigned long __res asm("r28"); \
|
|
|
|
LOAD_ARGS_##nr(args) \
|
|
|
|
/* FIXME: HACK stw/ldw r19 around syscall */ \
|
|
|
|
asm volatile( \
|
|
|
|
STW_ASM_PIC \
|
|
|
|
" ble 0x100(%%sr2, %%r0)\n" \
|
|
|
|
" ldi %1, %%r20\n" \
|
|
|
|
LDW_ASM_PIC \
|
|
|
|
: "=r" (__res) \
|
|
|
|
: "i" (SYS_ify(name)) ASM_ARGS_##nr \
|
|
|
|
: CALL_CLOB_REGS CLOB_ARGS_##nr \
|
|
|
|
); \
|
|
|
|
__sys_res = (long)__res; \
|
|
|
|
} \
|
|
|
|
if ( (unsigned long)__sys_res >= (unsigned long)-4095 ){ \
|
|
|
|
__set_errno(-__sys_res); \
|
|
|
|
__sys_res = -1; \
|
|
|
|
} \
|
|
|
|
__sys_res; \
|
|
|
|
})
|
|
|
|
|
|
|
|
/* INTERNAL_SYSCALL_DECL - Allows us to setup some function static
|
|
|
|
value to use within the context of the syscall
|
|
|
|
INTERNAL_SYSCALL_ERROR_P - Returns 0 if it wasn't an error, 1 otherwise
|
|
|
|
You are allowed to use the syscall result (val) and the DECL error variable
|
|
|
|
to determine what went wrong.
|
|
|
|
INTERLAL_SYSCALL_ERRNO - Munges the val/err pair into the error number.
|
|
|
|
In our case we just flip the sign. */
|
|
|
|
|
|
|
|
#undef INTERNAL_SYSCALL_DECL
|
|
|
|
#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
|
|
|
|
|
|
|
|
/* Equivalent to (val < 0)&&(val > -4095) which is what we want */
|
|
|
|
#undef INTERNAL_SYSCALL_ERROR_P
|
|
|
|
#define INTERNAL_SYSCALL_ERROR_P(val, err) \
|
|
|
|
((unsigned long)val >= (unsigned long)-4095)
|
|
|
|
|
|
|
|
#undef INTERNAL_SYSCALL_ERRNO
|
|
|
|
#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
|
|
|
|
|
|
|
|
/* Similar to INLINE_SYSCALL but we don't set errno */
|
|
|
|
#undef INTERNAL_SYSCALL
|
|
|
|
#define INTERNAL_SYSCALL(name, err, nr, args...) \
|
|
|
|
({ \
|
2001-04-19 21:24:46 +00:00
|
|
|
long __sys_res; \
|
2000-10-15 06:50:42 +00:00
|
|
|
{ \
|
|
|
|
register unsigned long __res asm("r28"); \
|
|
|
|
LOAD_ARGS_##nr(args) \
|
2003-10-15 05:47:36 +00:00
|
|
|
/* FIXME: HACK stw/ldw r19 around syscall */ \
|
2000-10-15 06:50:42 +00:00
|
|
|
asm volatile( \
|
2003-10-15 05:47:36 +00:00
|
|
|
STW_ASM_PIC \
|
|
|
|
" ble 0x100(%%sr2, %%r0)\n" \
|
|
|
|
" ldi %1, %%r20\n" \
|
|
|
|
LDW_ASM_PIC \
|
2000-10-15 06:50:42 +00:00
|
|
|
: "=r" (__res) \
|
|
|
|
: "i" (SYS_ify(name)) ASM_ARGS_##nr \
|
2003-10-15 05:47:36 +00:00
|
|
|
: CALL_CLOB_REGS CLOB_ARGS_##nr \
|
|
|
|
); \
|
|
|
|
__sys_res = (long)__res; \
|
2000-10-15 06:50:42 +00:00
|
|
|
} \
|
|
|
|
__sys_res; \
|
2003-10-15 05:47:36 +00:00
|
|
|
})
|
2000-10-15 06:50:42 +00:00
|
|
|
|
|
|
|
#define LOAD_ARGS_0()
|
|
|
|
#define LOAD_ARGS_1(r26) \
|
2003-11-03 17:18:38 +00:00
|
|
|
register unsigned long __r26 __asm__("r26") = (unsigned long)(r26); \
|
2000-10-15 06:50:42 +00:00
|
|
|
LOAD_ARGS_0()
|
|
|
|
#define LOAD_ARGS_2(r26,r25) \
|
2003-11-03 17:18:38 +00:00
|
|
|
register unsigned long __r25 __asm__("r25") = (unsigned long)(r25); \
|
2000-10-15 06:50:42 +00:00
|
|
|
LOAD_ARGS_1(r26)
|
|
|
|
#define LOAD_ARGS_3(r26,r25,r24) \
|
2003-11-03 17:18:38 +00:00
|
|
|
register unsigned long __r24 __asm__("r24") = (unsigned long)(r24); \
|
2000-10-15 06:50:42 +00:00
|
|
|
LOAD_ARGS_2(r26,r25)
|
|
|
|
#define LOAD_ARGS_4(r26,r25,r24,r23) \
|
2003-11-03 17:18:38 +00:00
|
|
|
register unsigned long __r23 __asm__("r23") = (unsigned long)(r23); \
|
2000-10-15 06:50:42 +00:00
|
|
|
LOAD_ARGS_3(r26,r25,r24)
|
|
|
|
#define LOAD_ARGS_5(r26,r25,r24,r23,r22) \
|
2003-11-03 17:18:38 +00:00
|
|
|
register unsigned long __r22 __asm__("r22") = (unsigned long)(r22); \
|
2000-10-15 06:50:42 +00:00
|
|
|
LOAD_ARGS_4(r26,r25,r24,r23)
|
|
|
|
#define LOAD_ARGS_6(r26,r25,r24,r23,r22,r21) \
|
2003-11-03 17:18:38 +00:00
|
|
|
register unsigned long __r21 __asm__("r21") = (unsigned long)(r21); \
|
2000-10-15 06:50:42 +00:00
|
|
|
LOAD_ARGS_5(r26,r25,r24,r23,r22)
|
|
|
|
|
2003-10-15 05:47:36 +00:00
|
|
|
/* Even with zero args we use r20 for the syscall number */
|
2001-04-20 06:06:55 +00:00
|
|
|
#define ASM_ARGS_0
|
2003-10-15 05:47:36 +00:00
|
|
|
#define ASM_ARGS_1 ASM_ARGS_0, "r" (__r26)
|
|
|
|
#define ASM_ARGS_2 ASM_ARGS_1, "r" (__r25)
|
|
|
|
#define ASM_ARGS_3 ASM_ARGS_2, "r" (__r24)
|
|
|
|
#define ASM_ARGS_4 ASM_ARGS_3, "r" (__r23)
|
|
|
|
#define ASM_ARGS_5 ASM_ARGS_4, "r" (__r22)
|
|
|
|
#define ASM_ARGS_6 ASM_ARGS_5, "r" (__r21)
|
|
|
|
|
|
|
|
/* The registers not listed as inputs but clobbered */
|
|
|
|
#define CLOB_ARGS_6
|
|
|
|
#define CLOB_ARGS_5 CLOB_ARGS_6, "%r21"
|
|
|
|
#define CLOB_ARGS_4 CLOB_ARGS_5, "%r22"
|
|
|
|
#define CLOB_ARGS_3 CLOB_ARGS_4, "%r23"
|
|
|
|
#define CLOB_ARGS_2 CLOB_ARGS_3, "%r24"
|
|
|
|
#define CLOB_ARGS_1 CLOB_ARGS_2, "%r25"
|
|
|
|
#define CLOB_ARGS_0 CLOB_ARGS_1, "%r26"
|
2000-10-15 06:50:42 +00:00
|
|
|
|
|
|
|
#endif /* __ASSEMBLER__ */
|