Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Masahiro Yamada | 59cbe79 | 2014-09-01 11:06:32 +0900 | [diff] [blame] | 2 | /* |
| 3 | * linux/arch/arm/kernel/debug.S |
| 4 | * |
| 5 | * Copyright (C) 1994-1999 Russell King |
| 6 | * |
Masahiro Yamada | 59cbe79 | 2014-09-01 11:06:32 +0900 | [diff] [blame] | 7 | * 32-bit debugging code |
| 8 | */ |
| 9 | #include <linux/linkage.h> |
| 10 | #include <asm/assembler.h> |
| 11 | |
| 12 | .text |
| 13 | |
| 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 | |
| 20 | #if !defined(CONFIG_DEBUG_SEMIHOSTING) |
| 21 | #include CONFIG_DEBUG_LL_INCLUDE |
| 22 | #endif |
| 23 | |
Masahiro Yamada | 59cbe79 | 2014-09-01 11:06:32 +0900 | [diff] [blame] | 24 | .macro addruart_current, rx, tmp1, tmp2 |
Masahiro Yamada | 4cb23ab | 2014-09-01 11:06:35 +0900 | [diff] [blame] | 25 | addruart \rx, \tmp1, \tmp2 |
Masahiro Yamada | 59cbe79 | 2014-09-01 11:06:32 +0900 | [diff] [blame] | 26 | .endm |
| 27 | |
Masahiro Yamada | 59cbe79 | 2014-09-01 11:06:32 +0900 | [diff] [blame] | 28 | /* |
| 29 | * Useful debugging routines |
| 30 | */ |
| 31 | ENTRY(printhex8) |
| 32 | mov r1, #8 |
| 33 | b printhex |
| 34 | ENDPROC(printhex8) |
| 35 | |
| 36 | ENTRY(printhex4) |
| 37 | mov r1, #4 |
| 38 | b printhex |
| 39 | ENDPROC(printhex4) |
| 40 | |
| 41 | ENTRY(printhex2) |
| 42 | mov r1, #2 |
| 43 | printhex: adr r2, hexbuf |
| 44 | add r3, r2, r1 |
| 45 | mov r1, #0 |
| 46 | strb r1, [r3] |
| 47 | 1: and r1, r0, #15 |
| 48 | mov r0, r0, lsr #4 |
| 49 | cmp r1, #10 |
| 50 | addlt r1, r1, #'0' |
| 51 | addge r1, r1, #'a' - 10 |
| 52 | strb r1, [r3, #-1]! |
| 53 | teq r3, r2 |
| 54 | bne 1b |
| 55 | mov r0, r2 |
| 56 | b printascii |
| 57 | ENDPROC(printhex2) |
| 58 | |
| 59 | hexbuf: .space 16 |
| 60 | |
| 61 | .ltorg |
| 62 | |
| 63 | #ifndef CONFIG_DEBUG_SEMIHOSTING |
| 64 | |
| 65 | ENTRY(printascii) |
| 66 | addruart_current r3, r1, r2 |
| 67 | b 2f |
| 68 | 1: waituart r2, r3 |
| 69 | senduart r1, r3 |
| 70 | busyuart r2, r3 |
| 71 | teq r1, #'\n' |
| 72 | moveq r1, #'\r' |
| 73 | beq 1b |
| 74 | 2: teq r0, #0 |
| 75 | ldrneb r1, [r0], #1 |
| 76 | teqne r1, #0 |
| 77 | bne 1b |
| 78 | mov pc, lr |
| 79 | ENDPROC(printascii) |
| 80 | |
| 81 | ENTRY(printch) |
| 82 | addruart_current r3, r1, r2 |
| 83 | mov r1, r0 |
| 84 | mov r0, #0 |
| 85 | b 1b |
| 86 | ENDPROC(printch) |
| 87 | |
Masahiro Yamada | 59cbe79 | 2014-09-01 11:06:32 +0900 | [diff] [blame] | 88 | #else |
| 89 | |
| 90 | ENTRY(printascii) |
| 91 | mov r1, r0 |
| 92 | mov r0, #0x04 @ SYS_WRITE0 |
| 93 | ARM( svc #0x123456 ) |
| 94 | THUMB( svc #0xab ) |
| 95 | mov pc, lr |
| 96 | ENDPROC(printascii) |
| 97 | |
| 98 | ENTRY(printch) |
| 99 | adr r1, hexbuf |
| 100 | strb r0, [r1] |
| 101 | mov r0, #0x03 @ SYS_WRITEC |
| 102 | ARM( svc #0x123456 ) |
| 103 | THUMB( svc #0xab ) |
| 104 | mov pc, lr |
| 105 | ENDPROC(printch) |
| 106 | |
| 107 | ENTRY(debug_ll_addr) |
| 108 | mov r2, #0 |
| 109 | str r2, [r0] |
| 110 | str r2, [r1] |
| 111 | mov pc, lr |
| 112 | ENDPROC(debug_ll_addr) |
| 113 | |
| 114 | #endif |