debug.S 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. .text
  14. /*
  15. * Some debugging routines (useful if you've got MM problems and
  16. * printk isn't working). For DEBUGGING ONLY!!! Do not leave
  17. * references to these in a production kernel!
  18. */
  19. #if defined(CONFIG_DEBUG_ICEDCC)
  20. @@ debug using ARM EmbeddedICE DCC channel
  21. .macro addruart, rp, rv
  22. .endm
  23. #if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_V6K) || defined(CONFIG_CPU_V7)
  24. .macro senduart, rd, rx
  25. mcr p14, 0, \rd, c0, c5, 0
  26. .endm
  27. .macro busyuart, rd, rx
  28. 1001:
  29. mrc p14, 0, \rx, c0, c1, 0
  30. tst \rx, #0x20000000
  31. beq 1001b
  32. .endm
  33. .macro waituart, rd, rx
  34. mov \rd, #0x2000000
  35. 1001:
  36. subs \rd, \rd, #1
  37. bmi 1002f
  38. mrc p14, 0, \rx, c0, c1, 0
  39. tst \rx, #0x20000000
  40. bne 1001b
  41. 1002:
  42. .endm
  43. #elif defined(CONFIG_CPU_XSCALE)
  44. .macro senduart, rd, rx
  45. mcr p14, 0, \rd, c8, c0, 0
  46. .endm
  47. .macro busyuart, rd, rx
  48. 1001:
  49. mrc p14, 0, \rx, c14, c0, 0
  50. tst \rx, #0x10000000
  51. beq 1001b
  52. .endm
  53. .macro waituart, rd, rx
  54. mov \rd, #0x10000000
  55. 1001:
  56. subs \rd, \rd, #1
  57. bmi 1002f
  58. mrc p14, 0, \rx, c14, c0, 0
  59. tst \rx, #0x10000000
  60. bne 1001b
  61. 1002:
  62. .endm
  63. #else
  64. .macro senduart, rd, rx
  65. mcr p14, 0, \rd, c1, c0, 0
  66. .endm
  67. .macro busyuart, rd, rx
  68. 1001:
  69. mrc p14, 0, \rx, c0, c0, 0
  70. tst \rx, #2
  71. beq 1001b
  72. .endm
  73. .macro waituart, rd, rx
  74. mov \rd, #0x2000000
  75. 1001:
  76. subs \rd, \rd, #1
  77. bmi 1002f
  78. mrc p14, 0, \rx, c0, c0, 0
  79. tst \rx, #2
  80. bne 1001b
  81. 1002:
  82. .endm
  83. #endif /* CONFIG_CPU_V6 */
  84. #else
  85. #include <mach/debug-macro.S>
  86. #endif /* CONFIG_DEBUG_ICEDCC */
  87. #ifdef CONFIG_MMU
  88. .macro addruart_current, rx, tmp1, tmp2
  89. addruart \tmp1, \tmp2
  90. mrc p15, 0, \rx, c1, c0
  91. tst \rx, #1
  92. moveq \rx, \tmp1
  93. movne \rx, \tmp2
  94. .endm
  95. #else /* !CONFIG_MMU */
  96. .macro addruart_current, rx, tmp1, tmp2
  97. addruart \rx, \tmp1
  98. .endm
  99. #endif /* CONFIG_MMU */
  100. /*
  101. * Useful debugging routines
  102. */
  103. ENTRY(printhex8)
  104. mov r1, #8
  105. b printhex
  106. ENDPROC(printhex8)
  107. ENTRY(printhex4)
  108. mov r1, #4
  109. b printhex
  110. ENDPROC(printhex4)
  111. ENTRY(printhex2)
  112. mov r1, #2
  113. printhex: adr r2, hexbuf
  114. add r3, r2, r1
  115. mov r1, #0
  116. strb r1, [r3]
  117. 1: and r1, r0, #15
  118. mov r0, r0, lsr #4
  119. cmp r1, #10
  120. addlt r1, r1, #'0'
  121. addge r1, r1, #'a' - 10
  122. strb r1, [r3, #-1]!
  123. teq r3, r2
  124. bne 1b
  125. mov r0, r2
  126. b printascii
  127. ENDPROC(printhex2)
  128. .ltorg
  129. ENTRY(printascii)
  130. addruart_current r3, r1, r2
  131. b 2f
  132. 1: waituart r2, r3
  133. senduart r1, r3
  134. busyuart r2, r3
  135. teq r1, #'\n'
  136. moveq r1, #'\r'
  137. beq 1b
  138. 2: teq r0, #0
  139. ldrneb r1, [r0], #1
  140. teqne r1, #0
  141. bne 1b
  142. mov pc, lr
  143. ENDPROC(printascii)
  144. ENTRY(printch)
  145. addruart_current r3, r1, r2
  146. mov r1, r0
  147. mov r0, #0
  148. b 1b
  149. ENDPROC(printch)
  150. hexbuf: .space 16