1ad2056f2SAlexander Leidinger /*- 2ad2056f2SAlexander Leidinger * Copyright (c) 2006 Roman Divacky 3ad2056f2SAlexander Leidinger * All rights reserved. 4ad2056f2SAlexander Leidinger * 5ad2056f2SAlexander Leidinger * Redistribution and use in source and binary forms, with or without 6ad2056f2SAlexander Leidinger * modification, are permitted provided that the following conditions 7ad2056f2SAlexander Leidinger * are met: 8ad2056f2SAlexander Leidinger * 1. Redistributions of source code must retain the above copyright 9ad2056f2SAlexander Leidinger * notice, this list of conditions and the following disclaimer 10ad2056f2SAlexander Leidinger * in this position and unchanged. 11ad2056f2SAlexander Leidinger * 2. Redistributions in binary form must reproduce the above copyright 12ad2056f2SAlexander Leidinger * notice, this list of conditions and the following disclaimer in the 13ad2056f2SAlexander Leidinger * documentation and/or other materials provided with the distribution. 14ad2056f2SAlexander Leidinger * 3. The name of the author may not be used to endorse or promote products 15ad2056f2SAlexander Leidinger * derived from this software without specific prior written permission 16ad2056f2SAlexander Leidinger * 17ad2056f2SAlexander Leidinger * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18ad2056f2SAlexander Leidinger * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19ad2056f2SAlexander Leidinger * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20ad2056f2SAlexander Leidinger * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21ad2056f2SAlexander Leidinger * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22ad2056f2SAlexander Leidinger * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23ad2056f2SAlexander Leidinger * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24ad2056f2SAlexander Leidinger * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25ad2056f2SAlexander Leidinger * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26ad2056f2SAlexander Leidinger * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27ad2056f2SAlexander Leidinger * 28ad2056f2SAlexander Leidinger * $FreeBSD$ 29ad2056f2SAlexander Leidinger */ 30ad2056f2SAlexander Leidinger 31ad2056f2SAlexander Leidinger #ifndef _LINUX_EMUL_H_ 32ad2056f2SAlexander Leidinger #define _LINUX_EMUL_H_ 33ad2056f2SAlexander Leidinger 34bb63fddeSAlexander Leidinger #define EMUL_SHARED_HASXSTAT 0x01 35bb63fddeSAlexander Leidinger 36ad2056f2SAlexander Leidinger struct linux_emuldata_shared { 37ad2056f2SAlexander Leidinger int refs; 38bb63fddeSAlexander Leidinger int flags; 39bb63fddeSAlexander Leidinger int xstat; 40ad2056f2SAlexander Leidinger pid_t group_pid; 41ad2056f2SAlexander Leidinger 42ad2056f2SAlexander Leidinger LIST_HEAD(, linux_emuldata) threads; /* head of list of linux threads */ 43ad2056f2SAlexander Leidinger }; 44ad2056f2SAlexander Leidinger 450eef2f8aSAlexander Leidinger /* 460eef2f8aSAlexander Leidinger * modeled after similar structure in NetBSD 47ad2056f2SAlexander Leidinger * this will be extended as we need more functionality 48ad2056f2SAlexander Leidinger */ 49ad2056f2SAlexander Leidinger struct linux_emuldata { 50ad2056f2SAlexander Leidinger pid_t pid; 51ad2056f2SAlexander Leidinger 52ad2056f2SAlexander Leidinger int *child_set_tid; /* in clone(): Child's TID to set on clone */ 53ad2056f2SAlexander Leidinger int *child_clear_tid;/* in clone(): Child's TID to clear on exit */ 54ad2056f2SAlexander Leidinger 55ad2056f2SAlexander Leidinger struct linux_emuldata_shared *shared; 56ad2056f2SAlexander Leidinger 57955d762aSAlexander Leidinger int pdeath_signal; /* parent death signal */ 58d14cc07dSDmitry Chagin int flags; /* different emuldata flags */ 59955d762aSAlexander Leidinger 604732e446SRoman Divacky struct linux_robust_list_head *robust_futexes; 614732e446SRoman Divacky 62ad2056f2SAlexander Leidinger LIST_ENTRY(linux_emuldata) threads; /* list of linux threads */ 63ad2056f2SAlexander Leidinger }; 64ad2056f2SAlexander Leidinger 65ad2056f2SAlexander Leidinger struct linux_emuldata *em_find(struct proc *, int locked); 66ad2056f2SAlexander Leidinger 67357afa71SJung-uk Kim #define EMUL_LOCK(l) mtx_lock(l) 68357afa71SJung-uk Kim #define EMUL_UNLOCK(l) mtx_unlock(l) 69ad2056f2SAlexander Leidinger 70ad2056f2SAlexander Leidinger #define EMUL_SHARED_RLOCK(l) sx_slock(l) 71ad2056f2SAlexander Leidinger #define EMUL_SHARED_RUNLOCK(l) sx_sunlock(l) 72ad2056f2SAlexander Leidinger #define EMUL_SHARED_WLOCK(l) sx_xlock(l) 73ad2056f2SAlexander Leidinger #define EMUL_SHARED_WUNLOCK(l) sx_xunlock(l) 74ad2056f2SAlexander Leidinger 75ad2056f2SAlexander Leidinger /* for em_find use */ 761c65504cSAlexander Leidinger #define EMUL_DOLOCK 1 771c65504cSAlexander Leidinger #define EMUL_DONTLOCK 0 78ad2056f2SAlexander Leidinger 79d14cc07dSDmitry Chagin /* emuldata flags */ 80d14cc07dSDmitry Chagin #define LINUX_XDEPR_REQUEUEOP 0x00000001 /* uses deprecated 81d14cc07dSDmitry Chagin futex REQUEUE op*/ 82d14cc07dSDmitry Chagin 83ad2056f2SAlexander Leidinger int linux_proc_init(struct thread *, pid_t, int); 84ad2056f2SAlexander Leidinger void linux_proc_exit(void *, struct proc *); 85*e5d81ef1SDmitry Chagin void linux_schedtail(struct thread *); 86ad2056f2SAlexander Leidinger void linux_proc_exec(void *, struct proc *, struct image_params *); 87bb63fddeSAlexander Leidinger void linux_kill_threads(struct thread *, int); 88ad2056f2SAlexander Leidinger 8994cb2ecfSAlexander Leidinger extern struct sx emul_shared_lock; 90357afa71SJung-uk Kim extern struct mtx emul_lock; 9194cb2ecfSAlexander Leidinger 92ad2056f2SAlexander Leidinger #endif /* !_LINUX_EMUL_H_ */ 93