/sys/compat/freebsd32/freebsd32_util.h

https://bitbucket.org/freebsd/freebsd-base · C Header · 124 lines · 77 code · 16 blank · 31 comment · 0 complexity · e86b59896a19651587d41795ad7b1233 MD5 · raw file

  1. /*-
  2. * SPDX-License-Identifier: BSD-3-Clause
  3. *
  4. * Copyright (c) 1998-1999 Andrew Gallatin
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer
  12. * in this position and unchanged.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the distribution.
  16. * 3. The name of the author may not be used to endorse or promote products
  17. * derived from this software withough specific prior written permission
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  20. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  21. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  22. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  23. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  24. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  28. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. *
  30. * $FreeBSD$
  31. */
  32. #ifndef _COMPAT_FREEBSD32_FREEBSD32_UTIL_H_
  33. #define _COMPAT_FREEBSD32_FREEBSD32_UTIL_H_
  34. #include <sys/cdefs.h>
  35. #include <sys/exec.h>
  36. #include <sys/sysent.h>
  37. #include <sys/uio.h>
  38. #include <vm/vm.h>
  39. #include <vm/vm_param.h>
  40. #include <vm/pmap.h>
  41. struct freebsd32_ps_strings {
  42. u_int32_t ps_argvstr; /* first of 0 or more argument strings */
  43. int ps_nargvstr; /* the number of argument strings */
  44. u_int32_t ps_envstr; /* first of 0 or more environment strings */
  45. int ps_nenvstr; /* the number of environment strings */
  46. };
  47. #if defined(__amd64__)
  48. #include <compat/ia32/ia32_util.h>
  49. #endif
  50. #define FREEBSD32_PS_STRINGS \
  51. (FREEBSD32_USRSTACK - sizeof(struct freebsd32_ps_strings))
  52. extern struct sysent freebsd32_sysent[];
  53. #define SYSCALL32_MODULE(name, offset, new_sysent, evh, arg) \
  54. static struct syscall_module_data name##_syscall32_mod = { \
  55. evh, arg, offset, new_sysent, { 0, NULL } \
  56. }; \
  57. \
  58. static moduledata_t name##32_mod = { \
  59. "sys32/" #name, \
  60. syscall32_module_handler, \
  61. &name##_syscall32_mod \
  62. }; \
  63. DECLARE_MODULE(name##32, name##32_mod, SI_SUB_SYSCALLS, SI_ORDER_MIDDLE)
  64. #define SYSCALL32_MODULE_HELPER(syscallname) \
  65. static int syscallname##_syscall32 = FREEBSD32_SYS_##syscallname; \
  66. static struct sysent syscallname##_sysent32 = { \
  67. (sizeof(struct syscallname ## _args ) \
  68. / sizeof(register_t)), \
  69. (sy_call_t *)& syscallname \
  70. }; \
  71. SYSCALL32_MODULE(syscallname, \
  72. & syscallname##_syscall32, & syscallname##_sysent32,\
  73. NULL, NULL);
  74. #define SYSCALL32_INIT_HELPER_F(syscallname, flags) { \
  75. .new_sysent = { \
  76. .sy_narg = (sizeof(struct syscallname ## _args ) \
  77. / sizeof(register_t)), \
  78. .sy_call = (sy_call_t *)& syscallname, \
  79. .sy_flags = (flags) \
  80. }, \
  81. .syscall_no = FREEBSD32_SYS_##syscallname \
  82. }
  83. #define SYSCALL32_INIT_HELPER_COMPAT_F(syscallname, flags) { \
  84. .new_sysent = { \
  85. .sy_narg = (sizeof(struct syscallname ## _args ) \
  86. / sizeof(register_t)), \
  87. .sy_call = (sy_call_t *)& sys_ ## syscallname, \
  88. .sy_flags = (flags) \
  89. }, \
  90. .syscall_no = FREEBSD32_SYS_##syscallname \
  91. }
  92. #define SYSCALL32_INIT_HELPER(syscallname) \
  93. SYSCALL32_INIT_HELPER_F(syscallname, 0)
  94. #define SYSCALL32_INIT_HELPER_COMPAT(syscallname) \
  95. SYSCALL32_INIT_HELPER_COMPAT_F(syscallname, 0)
  96. int syscall32_module_handler(struct module *mod, int what, void *arg);
  97. int syscall32_helper_register(struct syscall_helper_data *sd, int flags);
  98. int syscall32_helper_unregister(struct syscall_helper_data *sd);
  99. struct iovec32;
  100. struct rusage32;
  101. register_t *freebsd32_copyout_strings(struct image_params *imgp);
  102. int freebsd32_copyiniov(struct iovec32 *iovp, u_int iovcnt,
  103. struct iovec **iov, int error);
  104. void freebsd32_rusage_out(const struct rusage *s, struct rusage32 *s32);
  105. struct image_args;
  106. int freebsd32_exec_copyin_args(struct image_args *args, const char *fname,
  107. enum uio_seg segflg, u_int32_t *argv, u_int32_t *envv);
  108. #endif /* !_COMPAT_FREEBSD32_FREEBSD32_UTIL_H_ */