sysent.h revision 102808
12255Ssos/*- 22255Ssos * Copyright (c) 1982, 1988, 1991 The Regents of the University of California. 32255Ssos * All rights reserved. 42255Ssos * 52255Ssos * Redistribution and use in source and binary forms, with or without 62255Ssos * modification, are permitted provided that the following conditions 72255Ssos * are met: 82255Ssos * 1. Redistributions of source code must retain the above copyright 92255Ssos * notice, this list of conditions and the following disclaimer. 102255Ssos * 2. Redistributions in binary form must reproduce the above copyright 112255Ssos * notice, this list of conditions and the following disclaimer in the 122255Ssos * documentation and/or other materials provided with the distribution. 132255Ssos * 3. All advertising materials mentioning features or use of this software 142255Ssos * must display the following acknowledgement: 152255Ssos * This product includes software developed by the University of 162255Ssos * California, Berkeley and its contributors. 172255Ssos * 4. Neither the name of the University nor the names of its contributors 182255Ssos * may be used to endorse or promote products derived from this software 192255Ssos * without specific prior written permission. 202255Ssos * 212255Ssos * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 222255Ssos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 232255Ssos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 242255Ssos * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 252255Ssos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 262255Ssos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 272255Ssos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 282255Ssos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 292255Ssos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 302255Ssos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 312255Ssos * SUCH DAMAGE. 322255Ssos * 3350477Speter * $FreeBSD: head/sys/sys/sysent.h 102808 2002-09-01 21:41:24Z jake $ 342255Ssos */ 352255Ssos 362255Ssos#ifndef _SYS_SYSENT_H_ 3714917Sbde#define _SYS_SYSENT_H_ 382255Ssos 3983366Sjulianstruct thread; 4033054Sbde 4192719Salfredtypedef int sy_call_t(struct thread *, void *); 4210905Sbde 432255Ssosstruct sysent { /* system call table */ 442255Ssos int sy_narg; /* number of arguments */ 4510905Sbde sy_call_t *sy_call; /* implementing function */ 462255Ssos}; 4758717Sdillon 4858717Sdillon#define SYF_ARGMASK 0x0000FFFF 4958717Sdillon#define SYF_MPSAFE 0x00010000 5058717Sdillon 5122521Sdyson#define SCARG(p,k) ((p)->k) /* get arg from args pointer */ 5222521Sdyson /* placeholder till we integrate rest of lite2 syscallargs changes XXX */ 532255Ssos 5410905Sbdestruct image_params; 5555152Sbdestruct __sigset; 5614331Speterstruct trapframe; 5750791Smarcelstruct vnode; 5810905Sbde 592255Ssosstruct sysentvec { 602255Ssos int sv_size; /* number of entries */ 612255Ssos struct sysent *sv_table; /* pointer to sysent */ 6214917Sbde u_int sv_mask; /* optional mask to index */ 633472Ssos int sv_sigsize; /* size of signal translation table */ 643472Ssos int *sv_sigtbl; /* signal translation table */ 6515036Ssmpatel int sv_errsize; /* size of errno translation table */ 663472Ssos int *sv_errtbl; /* errno translation table */ 6792719Salfred int (*sv_transtrap)(int, int); 6835496Seivind /* translate trap-to-signal mapping */ 6992719Salfred int (*sv_fixup)(register_t **, struct image_params *); 7010905Sbde /* stack fixup function */ 7193008Sbde void (*sv_sendsig)(void (*)(int), int, struct __sigset *, 7293008Sbde u_long); /* send signal */ 7314331Speter char *sv_sigcode; /* start of sigtramp code */ 7414331Speter int *sv_szsigcode; /* size of sigtramp code */ 7593008Sbde void (*sv_prepsyscall)(struct trapframe *, int *, u_int *, 7693008Sbde caddr_t *); 7716474Sdyson char *sv_name; /* name of binary type */ 7893008Sbde int (*sv_coredump)(struct thread *, struct vnode *, off_t); 7939154Sjdp /* function to dump core, or NULL */ 8092719Salfred int (*sv_imgact_try)(struct image_params *); 8168520Smarcel int sv_minsigstksz; /* minimum signal stack size */ 82102808Sjake int sv_pagesize; /* pagesize */ 83102808Sjake vm_offset_t sv_minuser; /* VM_MIN_ADDRESS */ 84102808Sjake vm_offset_t sv_maxuser; /* VM_MAXUSER_ADDRESS */ 85102808Sjake vm_offset_t sv_usrstack; /* USRSTACK */ 86102808Sjake vm_offset_t sv_psstrings; /* PS_STRINGS */ 87102808Sjake int sv_stackprot; /* vm protection for stack */ 88100384Speter register_t *(*sv_copyout_strings)(struct image_params *); 89100384Speter void (*sv_setregs)(struct thread *, u_long, u_long, u_long); 902255Ssos}; 912255Ssos 9255205Speter#ifdef _KERNEL 937090Sbdeextern struct sysentvec aout_sysvec; 9468356Sobrienextern struct sysentvec elf_freebsd_sysvec; 95102808Sjakeextern struct sysentvec null_sysvec; 962255Ssosextern struct sysent sysent[]; 972255Ssos 9842433Sdfr#define NO_SYSCALL (-1) 9942433Sdfr 10042433Sdfrstruct module; 10142433Sdfr 10242433Sdfrstruct syscall_module_data { 10342433Sdfr int (*chainevh)(struct module *, int, void *); /* next handler */ 10442433Sdfr void *chainarg; /* arg for next event handler */ 10542433Sdfr int *offset; /* offset into sysent */ 10642433Sdfr struct sysent *new_sysent; /* new sysent */ 10742433Sdfr struct sysent old_sysent; /* old sysent */ 10842433Sdfr}; 10942433Sdfr 11042433Sdfr#define SYSCALL_MODULE(name, offset, new_sysent, evh, arg) \ 11142433Sdfrstatic struct syscall_module_data name##_syscall_mod = { \ 11292604Salfred evh, arg, offset, new_sysent, { 0, NULL } \ 11342433Sdfr}; \ 11442433Sdfr \ 11542433Sdfrstatic moduledata_t name##_mod = { \ 11642433Sdfr #name, \ 11742433Sdfr syscall_module_handler, \ 11842433Sdfr &name##_syscall_mod \ 11942433Sdfr}; \ 12042433SdfrDECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE) 12142433Sdfr 12288633Salfred#define SYSCALL_MODULE_HELPER(syscallname) \ 12369449Salfredstatic int syscallname##_syscall = SYS_##syscallname; \ 12469449Salfredstatic struct sysent syscallname##_sysent = { \ 12588633Salfred (sizeof(struct syscallname ## _args ) \ 12688633Salfred / sizeof(register_t)), \ 12788633Salfred (sy_call_t *)& syscallname \ 12869449Salfred}; \ 12969449SalfredSYSCALL_MODULE(syscallname, \ 13069449Salfred & syscallname##_syscall, & syscallname##_sysent, \ 13169449Salfred NULL, NULL); 13269449Salfred 13392719Salfredint syscall_register(int *offset, struct sysent *new_sysent, 13493008Sbde struct sysent *old_sysent); 13592719Salfredint syscall_deregister(int *offset, struct sysent *old_sysent); 13692719Salfredint syscall_module_handler(struct module *mod, int what, void *arg); 13742433Sdfr 13855205Speter#endif /* _KERNEL */ 13942433Sdfr 14014917Sbde#endif /* !_SYS_SYSENT_H_ */ 141