Path: blob/main/sys/compat/freebsd32/freebsd32_util.h
39478 views
/*-1* SPDX-License-Identifier: BSD-3-Clause2*3* Copyright (c) 1998-1999 Andrew Gallatin4* All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer11* in this position and unchanged.12* 2. Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in the14* documentation and/or other materials provided with the distribution.15* 3. The name of the author may not be used to endorse or promote products16* derived from this software withough specific prior written permission17*18* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR19* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES20* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.21* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,22* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT23* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,24* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY25* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT26* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF27* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.28*/2930#ifndef _COMPAT_FREEBSD32_FREEBSD32_UTIL_H_31#define _COMPAT_FREEBSD32_FREEBSD32_UTIL_H_3233#include <sys/cdefs.h>34#include <sys/exec.h>35#include <sys/sysent.h>36#include <sys/uio.h>3738#include <vm/vm.h>39#include <vm/vm_param.h>40#include <vm/pmap.h>4142struct freebsd32_ps_strings {43uint32_t ps_argvstr; /* first of 0 or more argument strings */44int ps_nargvstr; /* the number of argument strings */45uint32_t ps_envstr; /* first of 0 or more environment strings */46int ps_nenvstr; /* the number of environment strings */47};4849#if defined(__amd64__)50#include <compat/ia32/ia32_util.h>51#endif5253#define FREEBSD32_PS_STRINGS \54(FREEBSD32_USRSTACK - sizeof(struct freebsd32_ps_strings))5556extern struct sysent freebsd32_sysent[];5758#define SYSCALL32_MODULE(name, offset, new_sysent, evh, arg) \59static struct syscall_module_data name##_syscall32_mod = { \60evh, arg, offset, new_sysent, { 0, NULL } \61}; \62\63static moduledata_t name##32_mod = { \64"sys32/" #name, \65syscall32_module_handler, \66&name##_syscall32_mod \67}; \68DECLARE_MODULE(name##32, name##32_mod, SI_SUB_SYSCALLS, SI_ORDER_MIDDLE)6970#define SYSCALL32_MODULE_HELPER(syscallname) \71static int syscallname##_syscall32 = FREEBSD32_SYS_##syscallname; \72static struct sysent syscallname##_sysent32 = { \73(sizeof(struct syscallname ## _args ) \74/ sizeof(register_t)), \75(sy_call_t *)& syscallname \76}; \77SYSCALL32_MODULE(syscallname, \78& syscallname##_syscall32, & syscallname##_sysent32,\79NULL, NULL);8081#define SYSCALL32_INIT_HELPER_F(syscallname, flags) { \82.new_sysent = { \83.sy_narg = (sizeof(struct syscallname ## _args ) \84/ sizeof(register_t)), \85.sy_call = (sy_call_t *)& syscallname, \86.sy_flags = (flags) \87}, \88.syscall_no = FREEBSD32_SYS_##syscallname \89}9091#define SYSCALL32_INIT_HELPER_COMPAT_F(syscallname, flags) { \92.new_sysent = { \93.sy_narg = (sizeof(struct syscallname ## _args ) \94/ sizeof(register_t)), \95.sy_call = (sy_call_t *)& sys_ ## syscallname, \96.sy_flags = (flags) \97}, \98.syscall_no = FREEBSD32_SYS_##syscallname \99}100101#define SYSCALL32_INIT_HELPER(syscallname) \102SYSCALL32_INIT_HELPER_F(syscallname, 0)103#define SYSCALL32_INIT_HELPER_COMPAT(syscallname) \104SYSCALL32_INIT_HELPER_COMPAT_F(syscallname, 0)105106int syscall32_module_handler(struct module *mod, int what, void *arg);107int syscall32_helper_register(struct syscall_helper_data *sd, int flags);108int syscall32_helper_unregister(struct syscall_helper_data *sd);109110struct iovec32;111struct rusage32;112int freebsd32_copyout_strings(struct image_params *imgp,113uintptr_t *stack_base);114int freebsd32_copyiniov(struct iovec32 *iovp, u_int iovcnt,115struct iovec **iov, int error);116int freebsd32_copyinuio(const struct iovec32 *iovp, u_int iovcnt,117struct uio **uiop);118void freebsd32_rusage_out(const struct rusage *s, struct rusage32 *s32);119120struct image_args;121int freebsd32_exec_copyin_args(struct image_args *args, const char *fname,122uint32_t *argv, uint32_t *envv);123124struct kinfo_knote;125struct kinfo_knote32;126void freebsd32_kinfo_knote_to_32(const struct kinfo_knote *kin,127struct kinfo_knote32 *kin32);128129extern int compat_freebsd_32bit;130131#endif /* !_COMPAT_FREEBSD32_FREEBSD32_UTIL_H_ */132133134