debug.S 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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, rx
  22. .endm
  23. .macro senduart, rd, rx
  24. mcr p14, 0, \rd, c1, c0, 0
  25. .endm
  26. .macro busyuart, rd, rx
  27. 1001:
  28. mrc p14, 0, \rx, c0, c0, 0
  29. tst \rx, #2
  30. beq 1001b
  31. .endm
  32. .macro waituart, rd, rx
  33. mov \rd, #0x2000000
  34. 1001:
  35. subs \rd, \rd, #1
  36. bmi 1002f
  37. mrc p14, 0, \rx, c0, c0, 0
  38. tst \rx, #2
  39. bne 1001b
  40. 1002:
  41. .endm
  42. #else
  43. #include <asm/arch/debug-macro.S>
  44. #endif
  45. /*
  46. * Useful debugging routines
  47. */
  48. ENTRY(printhex8)
  49. mov r1, #8
  50. b printhex
  51. ENTRY(printhex4)
  52. mov r1, #4
  53. b printhex
  54. ENTRY(printhex2)
  55. mov r1, #2
  56. printhex: adr r2, hexbuf
  57. add r3, r2, r1
  58. mov r1, #0
  59. strb r1, [r3]
  60. 1: and r1, r0, #15
  61. mov r0, r0, lsr #4
  62. cmp r1, #10
  63. addlt r1, r1, #'0'
  64. addge r1, r1, #'a' - 10
  65. strb r1, [r3, #-1]!
  66. teq r3, r2
  67. bne 1b
  68. mov r0, r2
  69. b printascii
  70. .ltorg
  71. ENTRY(printascii)
  72. addruart r3
  73. b 2f
  74. 1: waituart r2, r3
  75. senduart r1, r3
  76. busyuart r2, r3
  77. teq r1, #'\n'
  78. moveq r1, #'\r'
  79. beq 1b
  80. 2: teq r0, #0
  81. ldrneb r1, [r0], #1
  82. teqne r1, #0
  83. bne 1b
  84. mov pc, lr
  85. ENTRY(printch)
  86. addruart r3
  87. mov r1, r0
  88. mov r0, #0
  89. b 1b
  90. hexbuf: .space 16