debug.S 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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
  50. add r3, r2, r1
  51. mov r1, #0
  52. strb r1, [r3]
  53. 1: and r1, r0, #15
  54. mov r0, r0, lsr #4
  55. cmp r1, #10
  56. addlt r1, r1, #'0'
  57. addge r1, r1, #'a' - 10
  58. strb r1, [r3, #-1]!
  59. teq r3, r2
  60. bne 1b
  61. mov r0, r2
  62. b printascii
  63. ENDPROC(printhex2)
  64. hexbuf: .space 16
  65. .ltorg
  66. #ifndef CONFIG_DEBUG_SEMIHOSTING
  67. ENTRY(printascii)
  68. addruart_current r3, r1, r2
  69. b 2f
  70. 1: waituart r2, r3
  71. senduart r1, r3
  72. busyuart r2, r3
  73. teq r1, #'\n'
  74. moveq r1, #'\r'
  75. beq 1b
  76. 2: teq r0, #0
  77. ldrneb r1, [r0], #1
  78. teqne r1, #0
  79. bne 1b
  80. ret lr
  81. ENDPROC(printascii)
  82. ENTRY(printch)
  83. addruart_current r3, r1, r2
  84. mov r1, r0
  85. mov r0, #0
  86. b 1b
  87. ENDPROC(printch)
  88. #ifdef CONFIG_MMU
  89. ENTRY(debug_ll_addr)
  90. addruart r2, r3, ip
  91. str r2, [r0]
  92. str r3, [r1]
  93. ret lr
  94. ENDPROC(debug_ll_addr)
  95. #endif
  96. #else
  97. ENTRY(printascii)
  98. mov r1, r0
  99. mov r0, #0x04 @ SYS_WRITE0
  100. ARM( svc #0x123456 )
  101. THUMB( svc #0xab )
  102. ret lr
  103. ENDPROC(printascii)
  104. ENTRY(printch)
  105. adr r1, hexbuf
  106. strb r0, [r1]
  107. mov r0, #0x03 @ SYS_WRITEC
  108. ARM( svc #0x123456 )
  109. THUMB( svc #0xab )
  110. ret lr
  111. ENDPROC(printch)
  112. ENTRY(debug_ll_addr)
  113. mov r2, #0
  114. str r2, [r0]
  115. str r2, [r1]
  116. ret lr
  117. ENDPROC(debug_ll_addr)
  118. #endif