debug.S 1.7 KB

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