debug.S 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. * linux/arch/arm/kernel/debug.S
  3. *
  4. * Copyright (C) 1994-1999 Russell King
  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 version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * 32-bit debugging code
  11. */
  12. #include <linux/linkage.h>
  13. #include <asm/assembler.h>
  14. .text
  15. /*
  16. * Some debugging routines (useful if you've got MM problems and
  17. * printk isn't working). For DEBUGGING ONLY!!! Do not leave
  18. * references to these in a production kernel!
  19. */
  20. #if !defined(CONFIG_DEBUG_SEMIHOSTING)
  21. #include CONFIG_DEBUG_LL_INCLUDE
  22. #endif
  23. #ifdef CONFIG_MMU
  24. .macro addruart_current, rx, tmp1, tmp2
  25. addruart \tmp1, \tmp2, \rx
  26. mrc p15, 0, \rx, c1, c0
  27. tst \rx, #1
  28. moveq \rx, \tmp1
  29. movne \rx, \tmp2
  30. .endm
  31. #else /* !CONFIG_MMU */
  32. .macro addruart_current, rx, tmp1, tmp2
  33. addruart \rx, \tmp1, \tmp2
  34. .endm
  35. #endif /* CONFIG_MMU */
  36. /*
  37. * Useful debugging routines
  38. */
  39. ENTRY(printhex8)
  40. mov r1, #8
  41. b printhex
  42. ENDPROC(printhex8)
  43. ENTRY(printhex4)
  44. mov r1, #4
  45. b printhex
  46. ENDPROC(printhex4)
  47. ENTRY(printhex2)
  48. mov r1, #2
  49. printhex: adr r2, hexbuf_rel
  50. ldr r3, [r2]
  51. add r2, r2, r3
  52. add r3, r2, r1
  53. mov r1, #0
  54. strb r1, [r3]
  55. 1: and r1, r0, #15
  56. mov r0, r0, lsr #4
  57. cmp r1, #10
  58. addlt r1, r1, #'0'
  59. addge r1, r1, #'a' - 10
  60. strb r1, [r3, #-1]!
  61. teq r3, r2
  62. bne 1b
  63. mov r0, r2
  64. b printascii
  65. ENDPROC(printhex2)
  66. .pushsection .bss
  67. hexbuf_addr: .space 16
  68. .popsection
  69. .align
  70. hexbuf_rel: .long hexbuf_addr - .
  71. .ltorg
  72. #ifndef CONFIG_DEBUG_SEMIHOSTING
  73. ENTRY(printascii)
  74. addruart_current r3, r1, r2
  75. 1: teq r0, #0
  76. ldrneb r1, [r0], #1
  77. teqne r1, #0
  78. reteq lr
  79. 2: teq r1, #'\n'
  80. bne 3f
  81. mov r1, #'\r'
  82. waituart r2, r3
  83. senduart r1, r3
  84. busyuart r2, r3
  85. mov r1, #'\n'
  86. 3: waituart r2, r3
  87. senduart r1, r3
  88. busyuart r2, r3
  89. b 1b
  90. ENDPROC(printascii)
  91. ENTRY(printch)
  92. addruart_current r3, r1, r2
  93. mov r1, r0
  94. mov r0, #0
  95. b 2b
  96. ENDPROC(printch)
  97. #ifdef CONFIG_MMU
  98. ENTRY(debug_ll_addr)
  99. addruart r2, r3, ip
  100. str r2, [r0]
  101. str r3, [r1]
  102. ret lr
  103. ENDPROC(debug_ll_addr)
  104. #endif
  105. #else
  106. ENTRY(printascii)
  107. mov r1, r0
  108. mov r0, #0x04 @ SYS_WRITE0
  109. ARM( svc #0x123456 )
  110. #ifdef CONFIG_CPU_V7M
  111. THUMB( bkpt #0xab )
  112. #else
  113. THUMB( svc #0xab )
  114. #endif
  115. ret lr
  116. ENDPROC(printascii)
  117. ENTRY(printch)
  118. adr r1, hexbuf_rel
  119. ldr r2, [r1]
  120. add r1, r1, r2
  121. strb r0, [r1]
  122. mov r0, #0x03 @ SYS_WRITEC
  123. ARM( svc #0x123456 )
  124. #ifdef CONFIG_CPU_V7M
  125. THUMB( bkpt #0xab )
  126. #else
  127. THUMB( svc #0xab )
  128. #endif
  129. ret lr
  130. ENDPROC(printch)
  131. ENTRY(debug_ll_addr)
  132. mov r2, #0
  133. str r2, [r0]
  134. str r2, [r1]
  135. ret lr
  136. ENDPROC(debug_ll_addr)
  137. #endif