debug.S 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. #if defined(CONFIG_CPU_V6)
  22. .macro addruart, rx
  23. .endm
  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. #else
  44. .macro addruart, rx
  45. .endm
  46. .macro senduart, rd, rx
  47. mcr p14, 0, \rd, c1, c0, 0
  48. .endm
  49. .macro busyuart, rd, rx
  50. 1001:
  51. mrc p14, 0, \rx, c0, c0, 0
  52. tst \rx, #2
  53. beq 1001b
  54. .endm
  55. .macro waituart, rd, rx
  56. mov \rd, #0x2000000
  57. 1001:
  58. subs \rd, \rd, #1
  59. bmi 1002f
  60. mrc p14, 0, \rx, c0, c0, 0
  61. tst \rx, #2
  62. bne 1001b
  63. 1002:
  64. .endm
  65. #endif /* CONFIG_CPU_V6 */
  66. #else
  67. #include <asm/arch/debug-macro.S>
  68. #endif /* CONFIG_DEBUG_ICEDCC */
  69. /*
  70. * Useful debugging routines
  71. */
  72. ENTRY(printhex8)
  73. mov r1, #8
  74. b printhex
  75. ENTRY(printhex4)
  76. mov r1, #4
  77. b printhex
  78. ENTRY(printhex2)
  79. mov r1, #2
  80. printhex: adr r2, hexbuf
  81. add r3, r2, r1
  82. mov r1, #0
  83. strb r1, [r3]
  84. 1: and r1, r0, #15
  85. mov r0, r0, lsr #4
  86. cmp r1, #10
  87. addlt r1, r1, #'0'
  88. addge r1, r1, #'a' - 10
  89. strb r1, [r3, #-1]!
  90. teq r3, r2
  91. bne 1b
  92. mov r0, r2
  93. b printascii
  94. .ltorg
  95. ENTRY(printascii)
  96. addruart r3
  97. b 2f
  98. 1: waituart r2, r3
  99. senduart r1, r3
  100. busyuart r2, r3
  101. teq r1, #'\n'
  102. moveq r1, #'\r'
  103. beq 1b
  104. 2: teq r0, #0
  105. ldrneb r1, [r0], #1
  106. teqne r1, #0
  107. bne 1b
  108. mov pc, lr
  109. ENTRY(printch)
  110. addruart r3
  111. mov r1, r0
  112. mov r0, #0
  113. b 1b
  114. hexbuf: .space 16