debug.S 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. #include <asm/hardware.h>
  15. .text
  16. /*
  17. * Some debugging routines (useful if you've got MM problems and
  18. * printk isn't working). For DEBUGGING ONLY!!! Do not leave
  19. * references to these in a production kernel!
  20. */
  21. #if defined(CONFIG_DEBUG_ICEDCC)
  22. @@ debug using ARM EmbeddedICE DCC channel
  23. .macro addruart, rx
  24. .endm
  25. .macro senduart, rd, rx
  26. mcr p14, 0, \rd, c1, c0, 0
  27. .endm
  28. .macro busyuart, rd, rx
  29. 1001:
  30. mrc p14, 0, \rx, c0, c0, 0
  31. tst \rx, #2
  32. beq 1001b
  33. .endm
  34. .macro waituart, rd, rx
  35. mov \rd, #0x2000000
  36. 1001:
  37. subs \rd, \rd, #1
  38. bmi 1002f
  39. mrc p14, 0, \rx, c0, c0, 0
  40. tst \rx, #2
  41. bne 1001b
  42. 1002:
  43. .endm
  44. #else
  45. #include <asm/arch/debug-macro.S>
  46. #endif
  47. /*
  48. * Useful debugging routines
  49. */
  50. ENTRY(printhex8)
  51. mov r1, #8
  52. b printhex
  53. ENTRY(printhex4)
  54. mov r1, #4
  55. b printhex
  56. ENTRY(printhex2)
  57. mov r1, #2
  58. printhex: adr r2, hexbuf
  59. add r3, r2, r1
  60. mov r1, #0
  61. strb r1, [r3]
  62. 1: and r1, r0, #15
  63. mov r0, r0, lsr #4
  64. cmp r1, #10
  65. addlt r1, r1, #'0'
  66. addge r1, r1, #'a' - 10
  67. strb r1, [r3, #-1]!
  68. teq r3, r2
  69. bne 1b
  70. mov r0, r2
  71. b printascii
  72. .ltorg
  73. ENTRY(printascii)
  74. addruart r3
  75. b 2f
  76. 1: waituart r2, r3
  77. senduart r1, r3
  78. busyuart r2, r3
  79. teq r1, #'\n'
  80. moveq r1, #'\r'
  81. beq 1b
  82. 2: teq r0, #0
  83. ldrneb r1, [r0], #1
  84. teqne r1, #0
  85. bne 1b
  86. mov pc, lr
  87. ENTRY(printch)
  88. addruart r3
  89. mov r1, r0
  90. mov r0, #0
  91. b 1b
  92. hexbuf: .space 16