target_arch_sysarch.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * i386 sysarch system call emulation
  3. *
  4. * Copyright (c) 2013 Stacey D. Son
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef TARGET_ARCH_SYSARCH_H
  20. #define TARGET_ARCH_SYSARCH_H
  21. #include "target_syscall.h"
  22. static inline abi_long do_freebsd_arch_sysarch(CPUX86State *env, int op,
  23. abi_ulong parms)
  24. {
  25. abi_long ret = 0;
  26. abi_ulong val;
  27. int idx;
  28. switch (op) {
  29. case TARGET_FREEBSD_I386_SET_GSBASE:
  30. case TARGET_FREEBSD_I386_SET_FSBASE:
  31. if (op == TARGET_FREEBSD_I386_SET_GSBASE) {
  32. idx = R_GS;
  33. } else {
  34. idx = R_FS;
  35. }
  36. if (get_user(val, parms, abi_ulong)) {
  37. return -TARGET_EFAULT;
  38. }
  39. cpu_x86_load_seg(env, idx, 0);
  40. env->segs[idx].base = val;
  41. break;
  42. case TARGET_FREEBSD_I386_GET_GSBASE:
  43. case TARGET_FREEBSD_I386_GET_FSBASE:
  44. if (op == TARGET_FREEBSD_I386_GET_GSBASE) {
  45. idx = R_GS;
  46. } else {
  47. idx = R_FS;
  48. }
  49. val = env->segs[idx].base;
  50. if (put_user(val, parms, abi_ulong)) {
  51. return -TARGET_EFAULT;
  52. }
  53. break;
  54. /* XXX handle the others... */
  55. default:
  56. ret = -TARGET_EINVAL;
  57. break;
  58. }
  59. return ret;
  60. }
  61. static inline void do_freebsd_arch_print_sysarch(
  62. const struct syscallname *name, abi_long arg1, abi_long arg2,
  63. abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
  64. {
  65. gemu_log("%s(%d, " TARGET_ABI_FMT_lx ", " TARGET_ABI_FMT_lx ", "
  66. TARGET_ABI_FMT_lx ")", name->name, (int)arg1, arg2, arg3, arg4);
  67. }
  68. #endif /* TARGET_ARCH_SYSARCH_H */