watch.S 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Kernel debug stuff to use the Watch registers.
  7. * Useful to find stack overflows, dangling pointers etc.
  8. *
  9. * Copyright (C) 1995, 1996, 1999 by Ralf Baechle
  10. */
  11. #include <asm/asm.h>
  12. #include <asm/mipsregs.h>
  13. #include <asm/regdef.h>
  14. .set noreorder
  15. /*
  16. * Parameter: a0 - logic address to watch
  17. * Currently only KSEG0 addresses are allowed!
  18. * a1 - set bit #1 to trap on load references
  19. * bit #0 to trap on store references
  20. * Results : none
  21. */
  22. LEAF(__watch_set)
  23. li t0, 0x80000000
  24. subu a0, t0
  25. ori a0, 7
  26. xori a0, 7
  27. or a0, a1
  28. mtc0 a0, CP0_WATCHLO
  29. sw a0, watch_savelo
  30. jr ra
  31. mtc0 zero, CP0_WATCHHI
  32. END(__watch_set)
  33. /*
  34. * Parameter: none
  35. * Results : none
  36. */
  37. LEAF(__watch_clear)
  38. jr ra
  39. mtc0 zero, CP0_WATCHLO
  40. END(__watch_clear)
  41. /*
  42. * Parameter: none
  43. * Results : none
  44. */
  45. LEAF(__watch_reenable)
  46. lw t0, watch_savelo
  47. jr ra
  48. mtc0 t0, CP0_WATCHLO
  49. END(__watch_reenable)
  50. /*
  51. * Saved value of the c0_watchlo register for watch_reenable()
  52. */
  53. .data
  54. watch_savelo: .word 0
  55. .text