ptrace.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * Copyright 2003 PathScale, Inc.
  3. *
  4. * Licensed under the GPL
  5. */
  6. #define __FRAME_OFFSETS
  7. #include "asm/ptrace.h"
  8. #include "linux/sched.h"
  9. #include "linux/errno.h"
  10. #include "asm/elf.h"
  11. /* XXX x86_64 */
  12. unsigned long not_ss;
  13. unsigned long not_ds;
  14. unsigned long not_es;
  15. #define SC_SS(r) (not_ss)
  16. #define SC_DS(r) (not_ds)
  17. #define SC_ES(r) (not_es)
  18. /* determines which flags the user has access to. */
  19. /* 1 = access 0 = no access */
  20. #define FLAG_MASK 0x44dd5UL
  21. int putreg(struct task_struct *child, int regno, unsigned long value)
  22. {
  23. unsigned long tmp;
  24. #ifdef TIF_IA32
  25. /* Some code in the 64bit emulation may not be 64bit clean.
  26. Don't take any chances. */
  27. if (test_tsk_thread_flag(child, TIF_IA32))
  28. value &= 0xffffffff;
  29. #endif
  30. switch (regno){
  31. case FS:
  32. case GS:
  33. case DS:
  34. case ES:
  35. case SS:
  36. case CS:
  37. if (value && (value & 3) != 3)
  38. return -EIO;
  39. value &= 0xffff;
  40. break;
  41. case FS_BASE:
  42. case GS_BASE:
  43. if (!((value >> 48) == 0 || (value >> 48) == 0xffff))
  44. return -EIO;
  45. break;
  46. case EFLAGS:
  47. value &= FLAG_MASK;
  48. tmp = PT_REGS_EFLAGS(&child->thread.regs) & ~FLAG_MASK;
  49. value |= tmp;
  50. break;
  51. }
  52. PT_REGS_SET(&child->thread.regs, regno, value);
  53. return 0;
  54. }
  55. unsigned long getreg(struct task_struct *child, int regno)
  56. {
  57. unsigned long retval = ~0UL;
  58. switch (regno) {
  59. case FS:
  60. case GS:
  61. case DS:
  62. case ES:
  63. case SS:
  64. case CS:
  65. retval = 0xffff;
  66. /* fall through */
  67. default:
  68. retval &= PT_REG(&child->thread.regs, regno);
  69. #ifdef TIF_IA32
  70. if (test_tsk_thread_flag(child, TIF_IA32))
  71. retval &= 0xffffffff;
  72. #endif
  73. }
  74. return retval;
  75. }
  76. void arch_switch(void)
  77. {
  78. /* XXX
  79. printk("arch_switch\n");
  80. */
  81. }
  82. int is_syscall(unsigned long addr)
  83. {
  84. panic("is_syscall");
  85. }
  86. int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu )
  87. {
  88. panic("dump_fpu");
  89. return(1);
  90. }
  91. int get_fpregs(unsigned long buf, struct task_struct *child)
  92. {
  93. panic("get_fpregs");
  94. return(0);
  95. }
  96. int set_fpregs(unsigned long buf, struct task_struct *child)
  97. {
  98. panic("set_fpregs");
  99. return(0);
  100. }
  101. int get_fpxregs(unsigned long buf, struct task_struct *tsk)
  102. {
  103. panic("get_fpxregs");
  104. return(0);
  105. }
  106. int set_fpxregs(unsigned long buf, struct task_struct *tsk)
  107. {
  108. panic("set_fxpregs");
  109. return(0);
  110. }
  111. /*
  112. * Overrides for Emacs so that we follow Linus's tabbing style.
  113. * Emacs will notice this stuff at the end of the file and automatically
  114. * adjust the settings for this buffer only. This must remain at the end
  115. * of the file.
  116. * ---------------------------------------------------------------------------
  117. * Local variables:
  118. * c-file-style: "linux"
  119. * End:
  120. */