watch.S 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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, 2001 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 - physical address to watch
  17. * a1 - set bit #1 to trap on load references
  18. * bit #0 to trap on store references
  19. * Results : none
  20. */
  21. LEAF(__watch_set)
  22. ori a0, 7
  23. xori a0, 7
  24. or a0, a1
  25. mtc0 a0, CP0_WATCHLO
  26. sd a0, watch_savelo
  27. dsrl32 a0, a0, 0
  28. jr ra
  29. mtc0 zero, CP0_WATCHHI
  30. END(__watch_set)
  31. /*
  32. * Parameter: none
  33. * Results : none
  34. */
  35. LEAF(__watch_clear)
  36. jr ra
  37. mtc0 zero, CP0_WATCHLO
  38. END(__watch_clear)
  39. /*
  40. * Parameter: none
  41. * Results : none
  42. */
  43. LEAF(__watch_reenable)
  44. ld t0, watch_savelo
  45. jr ra
  46. mtc0 t0, CP0_WATCHLO
  47. END(__watch_reenable)
  48. /*
  49. * Saved value of the c0_watchlo register for watch_reenable()
  50. */
  51. .local watch_savelo
  52. .comm watch_savelo, 8, 8