probes.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef _ASM_POWERPC_PROBES_H
  2. #define _ASM_POWERPC_PROBES_H
  3. #ifdef __KERNEL__
  4. /*
  5. * Definitions common to probes files
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. *
  21. * Copyright IBM Corporation, 2012
  22. */
  23. #include <linux/types.h>
  24. typedef u32 ppc_opcode_t;
  25. #define BREAKPOINT_INSTRUCTION 0x7fe00008 /* trap */
  26. /* Trap definitions per ISA */
  27. #define IS_TW(instr) (((instr) & 0xfc0007fe) == 0x7c000008)
  28. #define IS_TD(instr) (((instr) & 0xfc0007fe) == 0x7c000088)
  29. #define IS_TDI(instr) (((instr) & 0xfc000000) == 0x08000000)
  30. #define IS_TWI(instr) (((instr) & 0xfc000000) == 0x0c000000)
  31. #ifdef CONFIG_PPC64
  32. #define is_trap(instr) (IS_TW(instr) || IS_TD(instr) || \
  33. IS_TWI(instr) || IS_TDI(instr))
  34. #else
  35. #define is_trap(instr) (IS_TW(instr) || IS_TWI(instr))
  36. #endif /* CONFIG_PPC64 */
  37. #ifdef CONFIG_PPC_ADV_DEBUG_REGS
  38. #define MSR_SINGLESTEP (MSR_DE)
  39. #else
  40. #define MSR_SINGLESTEP (MSR_SE)
  41. #endif
  42. /* Enable single stepping for the current task */
  43. static inline void enable_single_step(struct pt_regs *regs)
  44. {
  45. regs->msr |= MSR_SINGLESTEP;
  46. #ifdef CONFIG_PPC_ADV_DEBUG_REGS
  47. /*
  48. * We turn off Critical Input Exception(CE) to ensure that the single
  49. * step will be for the instruction we have the probe on; if we don't,
  50. * it is possible we'd get the single step reported for CE.
  51. */
  52. regs->msr &= ~MSR_CE;
  53. mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) | DBCR0_IC | DBCR0_IDM);
  54. #ifdef CONFIG_PPC_47x
  55. isync();
  56. #endif
  57. #endif
  58. }
  59. #endif /* __KERNEL__ */
  60. #endif /* _ASM_POWERPC_PROBES_H */