11da177e4SLinus Torvalds/* 21da177e4SLinus Torvalds * linux/arch/arm/kernel/debug.S 31da177e4SLinus Torvalds * 41da177e4SLinus Torvalds * Copyright (C) 1994-1999 Russell King 51da177e4SLinus Torvalds * 61da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or modify 71da177e4SLinus Torvalds * it under the terms of the GNU General Public License version 2 as 81da177e4SLinus Torvalds * published by the Free Software Foundation. 91da177e4SLinus Torvalds * 101da177e4SLinus Torvalds * 32-bit debugging code 111da177e4SLinus Torvalds */ 121da177e4SLinus Torvalds#include <linux/linkage.h> 136f6f6a70SRob Herring#include <asm/assembler.h> 141da177e4SLinus Torvalds 151da177e4SLinus Torvalds .text 161da177e4SLinus Torvalds 171da177e4SLinus Torvalds/* 181da177e4SLinus Torvalds * Some debugging routines (useful if you've got MM problems and 191da177e4SLinus Torvalds * printk isn't working). For DEBUGGING ONLY!!! Do not leave 201da177e4SLinus Torvalds * references to these in a production kernel! 211da177e4SLinus Torvalds */ 221da177e4SLinus Torvalds 2391a9fec0SRob Herring#if !defined(CONFIG_DEBUG_SEMIHOSTING) 2491a9fec0SRob Herring#include CONFIG_DEBUG_LL_INCLUDE 2591a9fec0SRob Herring#endif 261da177e4SLinus Torvalds 270ea12930SJeremy Kerr#ifdef CONFIG_MMU 280ea12930SJeremy Kerr .macro addruart_current, rx, tmp1, tmp2 29639da5eeSNicolas Pitre addruart \tmp1, \tmp2, \rx 300ea12930SJeremy Kerr mrc p15, 0, \rx, c1, c0 310ea12930SJeremy Kerr tst \rx, #1 320ea12930SJeremy Kerr moveq \rx, \tmp1 330ea12930SJeremy Kerr movne \rx, \tmp2 340ea12930SJeremy Kerr .endm 350ea12930SJeremy Kerr 360ea12930SJeremy Kerr#else /* !CONFIG_MMU */ 370ea12930SJeremy Kerr .macro addruart_current, rx, tmp1, tmp2 387505f042SStefan Agner addruart \rx, \tmp1, \tmp2 390ea12930SJeremy Kerr .endm 400ea12930SJeremy Kerr 410ea12930SJeremy Kerr#endif /* CONFIG_MMU */ 420ea12930SJeremy Kerr 431da177e4SLinus Torvalds/* 441da177e4SLinus Torvalds * Useful debugging routines 451da177e4SLinus Torvalds */ 461da177e4SLinus TorvaldsENTRY(printhex8) 471da177e4SLinus Torvalds mov r1, #8 481da177e4SLinus Torvalds b printhex 4993ed3970SCatalin MarinasENDPROC(printhex8) 501da177e4SLinus Torvalds 511da177e4SLinus TorvaldsENTRY(printhex4) 521da177e4SLinus Torvalds mov r1, #4 531da177e4SLinus Torvalds b printhex 5493ed3970SCatalin MarinasENDPROC(printhex4) 551da177e4SLinus Torvalds 561da177e4SLinus TorvaldsENTRY(printhex2) 571da177e4SLinus Torvalds mov r1, #2 58e11d1314SNicolas Pitreprinthex: adr r2, hexbuf_rel 59e11d1314SNicolas Pitre ldr r3, [r2] 60e11d1314SNicolas Pitre add r2, r2, r3 611da177e4SLinus Torvalds add r3, r2, r1 621da177e4SLinus Torvalds mov r1, #0 631da177e4SLinus Torvalds strb r1, [r3] 641da177e4SLinus Torvalds1: and r1, r0, #15 651da177e4SLinus Torvalds mov r0, r0, lsr #4 661da177e4SLinus Torvalds cmp r1, #10 671da177e4SLinus Torvalds addlt r1, r1, #'0' 681da177e4SLinus Torvalds addge r1, r1, #'a' - 10 691da177e4SLinus Torvalds strb r1, [r3, #-1]! 701da177e4SLinus Torvalds teq r3, r2 711da177e4SLinus Torvalds bne 1b 721da177e4SLinus Torvalds mov r0, r2 731da177e4SLinus Torvalds b printascii 7493ed3970SCatalin MarinasENDPROC(printhex2) 751da177e4SLinus Torvalds 76e11d1314SNicolas Pitre .pushsection .bss 77e11d1314SNicolas Pitrehexbuf_addr: .space 16 78e11d1314SNicolas Pitre .popsection 79e11d1314SNicolas Pitre .align 80e11d1314SNicolas Pitrehexbuf_rel: .long hexbuf_addr - . 81b55fa188SAfzal Mohammed 821da177e4SLinus Torvalds .ltorg 831da177e4SLinus Torvalds 849b5a146aSNicolas Pitre#ifndef CONFIG_DEBUG_SEMIHOSTING 859b5a146aSNicolas Pitre 861da177e4SLinus TorvaldsENTRY(printascii) 870ea12930SJeremy Kerr addruart_current r3, r1, r2 88*2a14b80cSNicolas Pitre1: teq r0, #0 891da177e4SLinus Torvalds ldrneb r1, [r0], #1 901da177e4SLinus Torvalds teqne r1, #0 91*2a14b80cSNicolas Pitre reteq lr 92*2a14b80cSNicolas Pitre2: teq r1, #'\n' 93*2a14b80cSNicolas Pitre bne 3f 94*2a14b80cSNicolas Pitre mov r1, #'\r' 95*2a14b80cSNicolas Pitre waituart r2, r3 96*2a14b80cSNicolas Pitre senduart r1, r3 97*2a14b80cSNicolas Pitre busyuart r2, r3 98*2a14b80cSNicolas Pitre mov r1, #'\n' 99*2a14b80cSNicolas Pitre3: waituart r2, r3 100*2a14b80cSNicolas Pitre senduart r1, r3 101*2a14b80cSNicolas Pitre busyuart r2, r3 102*2a14b80cSNicolas Pitre b 1b 10393ed3970SCatalin MarinasENDPROC(printascii) 1041da177e4SLinus Torvalds 1051da177e4SLinus TorvaldsENTRY(printch) 1060ea12930SJeremy Kerr addruart_current r3, r1, r2 1071da177e4SLinus Torvalds mov r1, r0 1081da177e4SLinus Torvalds mov r0, #0 109*2a14b80cSNicolas Pitre b 2b 11093ed3970SCatalin MarinasENDPROC(printch) 1119b5a146aSNicolas Pitre 112a73b59c5SUwe Kleine-König#ifdef CONFIG_MMU 113e5c5f2adSRob HerringENTRY(debug_ll_addr) 114e5c5f2adSRob Herring addruart r2, r3, ip 115e5c5f2adSRob Herring str r2, [r0] 116e5c5f2adSRob Herring str r3, [r1] 1176ebbf2ceSRussell King ret lr 118e5c5f2adSRob HerringENDPROC(debug_ll_addr) 119a73b59c5SUwe Kleine-König#endif 120e5c5f2adSRob Herring 1219b5a146aSNicolas Pitre#else 1229b5a146aSNicolas Pitre 1239b5a146aSNicolas PitreENTRY(printascii) 1249b5a146aSNicolas Pitre mov r1, r0 1259b5a146aSNicolas Pitre mov r0, #0x04 @ SYS_WRITE0 1269b5a146aSNicolas Pitre ARM( svc #0x123456 ) 1279b5a146aSNicolas Pitre THUMB( svc #0xab ) 1286ebbf2ceSRussell King ret lr 1299b5a146aSNicolas PitreENDPROC(printascii) 1309b5a146aSNicolas Pitre 1319b5a146aSNicolas PitreENTRY(printch) 132e11d1314SNicolas Pitre adr r1, hexbuf_rel 133e11d1314SNicolas Pitre ldr r2, [r1] 134e11d1314SNicolas Pitre add r1, r1, r2 1359b5a146aSNicolas Pitre strb r0, [r1] 1369b5a146aSNicolas Pitre mov r0, #0x03 @ SYS_WRITEC 1379b5a146aSNicolas Pitre ARM( svc #0x123456 ) 1389b5a146aSNicolas Pitre THUMB( svc #0xab ) 1396ebbf2ceSRussell King ret lr 1409b5a146aSNicolas PitreENDPROC(printch) 1419b5a146aSNicolas Pitre 142e5c5f2adSRob HerringENTRY(debug_ll_addr) 143e5c5f2adSRob Herring mov r2, #0 144e5c5f2adSRob Herring str r2, [r0] 145e5c5f2adSRob Herring str r2, [r1] 1466ebbf2ceSRussell King ret lr 147e5c5f2adSRob HerringENDPROC(debug_ll_addr) 148e5c5f2adSRob Herring 1499b5a146aSNicolas Pitre#endif 150