freebsd32_util.h revision 183365
1232922Stheraven/*- 2232922Stheraven * Copyright (c) 1998-1999 Andrew Gallatin 3232922Stheraven * All rights reserved. 4232922Stheraven * 5232922Stheraven * Redistribution and use in source and binary forms, with or without 6232922Stheraven * modification, are permitted provided that the following conditions 7232922Stheraven * are met: 8232922Stheraven * 1. Redistributions of source code must retain the above copyright 9232922Stheraven * notice, this list of conditions and the following disclaimer 10232922Stheraven * in this position and unchanged. 11232922Stheraven * 2. Redistributions in binary form must reproduce the above copyright 12232922Stheraven * notice, this list of conditions and the following disclaimer in the 13232922Stheraven * documentation and/or other materials provided with the distribution. 14232922Stheraven * 3. The name of the author may not be used to endorse or promote products 15232922Stheraven * derived from this software withough specific prior written permission 16232922Stheraven * 17232922Stheraven * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18232922Stheraven * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19232922Stheraven * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20232922Stheraven * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21232922Stheraven * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22232922Stheraven * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23232922Stheraven * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24232922Stheraven * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25232922Stheraven * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26232922Stheraven * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27227825Stheraven * 28227825Stheraven * $FreeBSD: head/sys/compat/freebsd32/freebsd32_util.h 183365 2008-09-25 20:50:21Z jhb $ 29227825Stheraven */ 30227825Stheraven 31227825Stheraven#ifndef _COMPAT_FREEBSD32_FREEBSD32_UTIL_H_ 32233233Stheraven#define _COMPAT_FREEBSD32_FREEBSD32_UTIL_H_ 33233233Stheraven 34233233Stheraven#include <sys/cdefs.h> 35233233Stheraven#include <sys/exec.h> 36227825Stheraven#include <sys/sysent.h> 37233233Stheraven 38233233Stheraven#include <vm/vm.h> 39233233Stheraven#include <vm/vm_param.h> 40233233Stheraven#include <vm/pmap.h> 41233233Stheraven 42233233Stheravenstruct freebsd32_ps_strings { 43233233Stheraven u_int32_t ps_argvstr; /* first of 0 or more argument strings */ 44233233Stheraven int ps_nargvstr; /* the number of argument strings */ 45233233Stheraven u_int32_t ps_envstr; /* first of 0 or more environment strings */ 46233233Stheraven int ps_nenvstr; /* the number of environment strings */ 47233233Stheraven}; 48233233Stheraven 49233233Stheraven#if defined(__amd64__) || defined(__ia64__) 50233233Stheraven#include <compat/ia32/ia32_util.h> 51233233Stheraven#endif 52233233Stheraven 53233233Stheraven#define FREEBSD32_PS_STRINGS \ 54233233Stheraven (FREEBSD32_USRSTACK - sizeof(struct freebsd32_ps_strings)) 55233233Stheraven 56233233Stheravenextern struct sysent freebsd32_sysent[]; 57233233Stheraven 58233233Stheraven#define SYSCALL32_MODULE(name, offset, new_sysent, evh, arg) \ 59233233Stheravenstatic struct syscall_module_data name##_syscall32_mod = { \ 60233233Stheraven evh, arg, offset, new_sysent, { 0, NULL } \ 61233233Stheraven}; \ 62233233Stheraven \ 63233233Stheravenstatic moduledata_t name##32_mod = { \ 64233233Stheraven #name, \ 65233233Stheraven syscall32_module_handler, \ 66233233Stheraven &name##_syscall32_mod \ 67233233Stheraven}; \ 68233233StheravenDECLARE_MODULE(name##32, name##32_mod, SI_SUB_SYSCALLS, SI_ORDER_MIDDLE) 69233233Stheraven 70233233Stheraven#define SYSCALL32_MODULE_HELPER(syscallname) \ 71233233Stheravenstatic int syscallname##_syscall32 = FREEBSD32_SYS_##syscallname; \ 72233233Stheravenstatic struct sysent syscallname##_sysent32 = { \ 73245302Stheraven (sizeof(struct syscallname ## _args ) \ 74245302Stheraven / sizeof(register_t)), \ 75245302Stheraven (sy_call_t *)& syscallname \ 76245302Stheraven}; \ 77245302StheravenSYSCALL32_MODULE(syscallname, \ 78245302Stheraven & syscallname##_syscall32, & syscallname##_sysent32,\ 79245302Stheraven NULL, NULL); 80245302Stheraven 81233233Stheravenint syscall32_register(int *offset, struct sysent *new_sysent, 82233233Stheraven struct sysent *old_sysent); 83233233Stheravenint syscall32_deregister(int *offset, struct sysent *old_sysent); 84233233Stheravenint syscall32_module_handler(struct module *mod, int what, void *arg); 85233233Stheraven 86233233Stheraven#endif /* !_COMPAT_FREEBSD32_FREEBSD32_UTIL_H_ */ 87233233Stheraven