njn | 9abd608 | 2005-06-17 21:31:45 +0000 | [diff] [blame] | 1 | |
| 2 | /*--------------------------------------------------------------------*/ |
| 3 | /*--- Doing system calls. pub_core_syscall.h ---*/ |
| 4 | /*--------------------------------------------------------------------*/ |
| 5 | |
| 6 | /* |
| 7 | This file is part of Valgrind, a dynamic binary instrumentation |
| 8 | framework. |
| 9 | |
sewardj | b3a1e4b | 2015-08-21 11:32:26 +0000 | [diff] [blame] | 10 | Copyright (C) 2000-2015 Julian Seward |
njn | 9abd608 | 2005-06-17 21:31:45 +0000 | [diff] [blame] | 11 | jseward@acm.org |
| 12 | |
| 13 | This program is free software; you can redistribute it and/or |
| 14 | modify it under the terms of the GNU General Public License as |
| 15 | published by the Free Software Foundation; either version 2 of the |
| 16 | License, or (at your option) any later version. |
| 17 | |
| 18 | This program is distributed in the hope that it will be useful, but |
| 19 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 21 | General Public License for more details. |
| 22 | |
| 23 | You should have received a copy of the GNU General Public License |
| 24 | along with this program; if not, write to the Free Software |
| 25 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 26 | 02111-1307, USA. |
| 27 | |
| 28 | The GNU General Public License is contained in the file COPYING. |
| 29 | */ |
| 30 | |
| 31 | #ifndef __PUB_CORE_SYSCALL_H |
| 32 | #define __PUB_CORE_SYSCALL_H |
| 33 | |
florian | 535fb1b | 2013-09-15 13:54:34 +0000 | [diff] [blame] | 34 | #include "pub_core_basics.h" // VG_ macro |
| 35 | |
njn | 9abd608 | 2005-06-17 21:31:45 +0000 | [diff] [blame] | 36 | //-------------------------------------------------------------------- |
| 37 | // PURPOSE: This module contains the code for actually executing syscalls. |
| 38 | //-------------------------------------------------------------------- |
| 39 | |
njn | b08a6b7 | 2009-05-21 03:52:03 +0000 | [diff] [blame] | 40 | /* Do a syscall on this platform, with 8 args, and return the result |
njn | 9abd608 | 2005-06-17 21:31:45 +0000 | [diff] [blame] | 41 | in canonical format in a SysRes value. */ |
| 42 | |
| 43 | // We use a full prototype for VG_(do_syscall) rather than "..." to ensure |
| 44 | // that all arguments get converted to a UWord appropriately. Not doing so |
| 45 | // can cause problems when passing 32-bit integers on 64-bit platforms, |
| 46 | // because the top 32-bits might not be zeroed appropriately, eg. as would |
| 47 | // happen with the 6th arg on AMD64 which is passed on the stack. |
| 48 | |
| 49 | extern SysRes VG_(do_syscall) ( UWord sysno, |
| 50 | UWord, UWord, UWord, |
sewardj | 17edf03 | 2006-10-17 01:53:34 +0000 | [diff] [blame] | 51 | UWord, UWord, UWord, |
| 52 | UWord, UWord ); |
njn | 9abd608 | 2005-06-17 21:31:45 +0000 | [diff] [blame] | 53 | |
| 54 | /* Macros make life easier. */ |
| 55 | |
sewardj | 17edf03 | 2006-10-17 01:53:34 +0000 | [diff] [blame] | 56 | #define vgPlain_do_syscall0(s) VG_(do_syscall)((s),0,0,0,0,0,0,0,0) |
| 57 | #define vgPlain_do_syscall1(s,a) VG_(do_syscall)((s),(a),\ |
| 58 | 0,0,0,0,0,0,0) |
| 59 | #define vgPlain_do_syscall2(s,a,b) VG_(do_syscall)((s),(a),(b),\ |
| 60 | 0,0,0,0,0,0) |
| 61 | #define vgPlain_do_syscall3(s,a,b,c) VG_(do_syscall)((s),(a),(b),(c),\ |
| 62 | 0,0,0,0,0) |
njn | b08a6b7 | 2009-05-21 03:52:03 +0000 | [diff] [blame] | 63 | #define vgPlain_do_syscall4(s,a,b,c,d) VG_(do_syscall)((s),(a),(b),(c),\ |
| 64 | (d),0,0,0,0) |
| 65 | #define vgPlain_do_syscall5(s,a,b,c,d,e) VG_(do_syscall)((s),(a),(b),(c),\ |
| 66 | (d),(e),0,0,0) |
sewardj | 17edf03 | 2006-10-17 01:53:34 +0000 | [diff] [blame] | 67 | #define vgPlain_do_syscall6(s,a,b,c,d,e,f) VG_(do_syscall)((s),(a),(b),(c),\ |
| 68 | (d),(e),(f),0,0) |
njn | b08a6b7 | 2009-05-21 03:52:03 +0000 | [diff] [blame] | 69 | #define vgPlain_do_syscall7(s,a,b,c,d,e,f,g) VG_(do_syscall)((s),(a),(b),(c),\ |
| 70 | (d),(e),(f),(g),0) |
| 71 | #define vgPlain_do_syscall8(s,a,b,c,d,e,f,g,h) VG_(do_syscall)((s),(a),(b),(c),\ |
| 72 | (d),(e),(f),(g),(h)) |
njn | 9abd608 | 2005-06-17 21:31:45 +0000 | [diff] [blame] | 73 | |
njn | cda2f0f | 2009-05-18 02:12:08 +0000 | [diff] [blame] | 74 | extern SysRes VG_(mk_SysRes_x86_linux) ( Int val ); |
| 75 | extern SysRes VG_(mk_SysRes_amd64_linux) ( Long val ); |
sewardj | 2c48c7b | 2005-11-29 13:05:56 +0000 | [diff] [blame] | 76 | extern SysRes VG_(mk_SysRes_ppc32_linux) ( UInt val, UInt cr0so ); |
| 77 | extern SysRes VG_(mk_SysRes_ppc64_linux) ( ULong val, ULong cr0so ); |
sewardj | 59570ff | 2010-01-01 11:59:33 +0000 | [diff] [blame] | 78 | extern SysRes VG_(mk_SysRes_arm_linux) ( Int val ); |
sewardj | f0c1250 | 2014-01-12 12:54:00 +0000 | [diff] [blame] | 79 | extern SysRes VG_(mk_SysRes_arm64_linux) ( Long val ); |
njn | f76d27a | 2009-05-28 01:53:07 +0000 | [diff] [blame] | 80 | extern SysRes VG_(mk_SysRes_x86_darwin) ( UChar scclass, Bool isErr, |
| 81 | UInt wHI, UInt wLO ); |
| 82 | extern SysRes VG_(mk_SysRes_amd64_darwin)( UChar scclass, Bool isErr, |
| 83 | ULong wHI, ULong wLO ); |
sewardj | b5b8740 | 2011-03-07 16:05:35 +0000 | [diff] [blame] | 84 | extern SysRes VG_(mk_SysRes_s390x_linux) ( Long val ); |
sewardj | 5db1540 | 2012-06-07 09:13:21 +0000 | [diff] [blame] | 85 | extern SysRes VG_(mk_SysRes_mips32_linux)( UWord v0, UWord v1, |
| 86 | UWord a3 ); |
petarj | 4df0bfc | 2013-02-27 23:17:33 +0000 | [diff] [blame] | 87 | extern SysRes VG_(mk_SysRes_mips64_linux)( ULong v0, ULong v1, |
| 88 | ULong a3 ); |
sewardj | 112711a | 2015-04-10 12:30:09 +0000 | [diff] [blame] | 89 | extern SysRes VG_(mk_SysRes_tilegx_linux)( Long val ); |
sewardj | 8eb8bab | 2015-07-21 14:44:28 +0000 | [diff] [blame] | 90 | extern SysRes VG_(mk_SysRes_x86_solaris) ( Bool isErr, UInt val, UInt val2 ); |
| 91 | extern SysRes VG_(mk_SysRes_amd64_solaris) ( Bool isErr, ULong val, ULong val2 ); |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 92 | extern SysRes VG_(mk_SysRes_Error) ( UWord val ); |
| 93 | extern SysRes VG_(mk_SysRes_Success) ( UWord val ); |
njn | 9abd608 | 2005-06-17 21:31:45 +0000 | [diff] [blame] | 94 | |
sewardj | bd664fd | 2015-07-08 17:08:23 +0000 | [diff] [blame] | 95 | #if defined(VGP_mips32_linux) || defined(VGP_mips64_linux) |
| 96 | /* On Linux/MIPS, VG_(mk_SysRes_Success) sets the second result word |
| 97 | to zero. Here is a version that allows setting both values. */ |
| 98 | extern SysRes VG_(mk_SysRes_SuccessEx) ( UWord val, UWord valEx ); |
| 99 | #endif |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 100 | |
njn | cda2f0f | 2009-05-18 02:12:08 +0000 | [diff] [blame] | 101 | |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 102 | /* Return a string which gives the name of an error value. Note, |
| 103 | unlike the standard C syserror fn, the returned string is not |
| 104 | malloc-allocated or writable -- treat it as a constant. */ |
| 105 | |
| 106 | extern const HChar* VG_(strerror) ( UWord errnum ); |
| 107 | |
| 108 | |
njn | 9abd608 | 2005-06-17 21:31:45 +0000 | [diff] [blame] | 109 | #endif // __PUB_CORE_SYSCALL_H |
| 110 | |
| 111 | /*--------------------------------------------------------------------*/ |
| 112 | /*--- end ---*/ |
| 113 | /*--------------------------------------------------------------------*/ |