2005-04-17 02:20:36 +04:00
/ *
* linux/ a r c h / a r m / k e r n e l / d e b u g . S
*
* Copyright ( C ) 1 9 9 4 - 1 9 9 9 R u s s e l l K i n g
*
* This p r o g r a m i s f r e e s o f t w a r e ; you can redistribute it and/or modify
* it u n d e r t h e t e r m s o f t h e G N U G e n e r a l P u b l i c L i c e n s e v e r s i o n 2 a s
* published b y t h e F r e e S o f t w a r e F o u n d a t i o n .
*
* 3 2 - bit d e b u g g i n g c o d e
* /
# include < l i n u x / l i n k a g e . h >
.text
/ *
* Some d e b u g g i n g r o u t i n e s ( u s e f u l i f y o u ' v e g o t M M p r o b l e m s a n d
* printk i s n ' t w o r k i n g ) . F o r D E B U G G I N G O N L Y ! ! ! D o n o t l e a v e
* references t o t h e s e i n a p r o d u c t i o n k e r n e l !
* /
# if d e f i n e d ( C O N F I G _ D E B U G _ I C E D C C )
@@ debug using ARM EmbeddedICE DCC channel
2006-09-20 16:03:34 +04:00
2011-09-01 06:55:46 +04:00
.macro addruart, r p , r v , t m p
2006-09-20 16:03:34 +04:00
.endm
2011-03-24 00:46:15 +03:00
# if d e f i n e d ( C O N F I G _ C P U _ V 6 ) | | d e f i n e d ( C O N F I G _ C P U _ V 6 K ) | | d e f i n e d ( C O N F I G _ C P U _ V 7 )
2010-07-21 12:40:50 +04:00
2006-09-20 16:03:34 +04:00
.macro senduart, r d , r x
mcr p14 , 0 , \ r d , c0 , c5 , 0
.endm
.macro busyuart, r d , r x
1001 :
mrc p14 , 0 , \ r x , c0 , c1 , 0
tst \ r x , #0x20000000
beq 1 0 0 1 b
.endm
.macro waituart, r d , r x
mov \ r d , #0x2000000
1001 :
subs \ r d , \ r d , #1
bmi 1 0 0 2 f
mrc p14 , 0 , \ r x , c0 , c1 , 0
tst \ r x , #0x20000000
bne 1 0 0 1 b
1002 :
.endm
2009-02-25 06:20:40 +03:00
# elif d e f i n e d ( C O N F I G _ C P U _ X S C A L E )
.macro senduart, r d , r x
mcr p14 , 0 , \ r d , c8 , c0 , 0
.endm
.macro busyuart, r d , r x
1001 :
mrc p14 , 0 , \ r x , c14 , c0 , 0
tst \ r x , #0x10000000
beq 1 0 0 1 b
.endm
.macro waituart, r d , r x
mov \ r d , #0x10000000
1001 :
subs \ r d , \ r d , #1
bmi 1 0 0 2 f
mrc p14 , 0 , \ r x , c14 , c0 , 0
tst \ r x , #0x10000000
bne 1 0 0 1 b
1002 :
.endm
2006-09-20 16:03:34 +04:00
# else
2005-04-17 02:20:36 +04:00
.macro senduart, r d , r x
mcr p14 , 0 , \ r d , c1 , c0 , 0
.endm
.macro busyuart, r d , r x
1001 :
mrc p14 , 0 , \ r x , c0 , c0 , 0
tst \ r x , #2
beq 1 0 0 1 b
.endm
.macro waituart, r d , r x
mov \ r d , #0x2000000
1001 :
subs \ r d , \ r d , #1
bmi 1 0 0 2 f
mrc p14 , 0 , \ r x , c0 , c0 , 0
tst \ r x , #2
bne 1 0 0 1 b
1002 :
.endm
2006-09-20 16:03:34 +04:00
# endif / * C O N F I G _ C P U _ V 6 * /
2005-04-17 02:20:36 +04:00
# else
2008-08-05 19:14:15 +04:00
# include < m a c h / d e b u g - m a c r o . S >
2006-09-20 16:03:34 +04:00
# endif / * C O N F I G _ D E B U G _ I C E D C C * /
2005-04-17 02:20:36 +04:00
2010-07-06 14:30:06 +04:00
# ifdef C O N F I G _ M M U
.macro addruart_ c u r r e n t , r x , t m p1 , t m p2
2011-09-01 06:55:46 +04:00
addruart \ t m p1 , \ t m p2 , \ r x
2010-07-06 14:30:06 +04:00
mrc p15 , 0 , \ r x , c1 , c0
tst \ r x , #1
moveq \ r x , \ t m p1
movne \ r x , \ t m p2
.endm
# else / * ! C O N F I G _ M M U * /
.macro addruart_ c u r r e n t , r x , t m p1 , t m p2
addruart \ r x , \ t m p1
.endm
# endif / * C O N F I G _ M M U * /
2005-04-17 02:20:36 +04:00
/ *
* Useful d e b u g g i n g r o u t i n e s
* /
ENTRY( p r i n t h e x8 )
mov r1 , #8
b p r i n t h e x
2008-08-28 14:22:32 +04:00
ENDPROC( p r i n t h e x8 )
2005-04-17 02:20:36 +04:00
ENTRY( p r i n t h e x4 )
mov r1 , #4
b p r i n t h e x
2008-08-28 14:22:32 +04:00
ENDPROC( p r i n t h e x4 )
2005-04-17 02:20:36 +04:00
ENTRY( p r i n t h e x2 )
mov r1 , #2
printhex : adr r2 , h e x b u f
add r3 , r2 , r1
mov r1 , #0
strb r1 , [ r3 ]
1 : and r1 , r0 , #15
mov r0 , r0 , l s r #4
cmp r1 , #10
addlt r1 , r1 , #' 0 '
addge r1 , r1 , #' a ' - 1 0
strb r1 , [ r3 , #- 1 ] !
teq r3 , r2
bne 1 b
mov r0 , r2
b p r i n t a s c i i
2008-08-28 14:22:32 +04:00
ENDPROC( p r i n t h e x2 )
2005-04-17 02:20:36 +04:00
2011-10-20 22:32:07 +04:00
hexbuf : .space 16
2005-04-17 02:20:36 +04:00
.ltorg
ENTRY( p r i n t a s c i i )
2010-07-06 14:30:06 +04:00
addruart_ c u r r e n t r3 , r1 , r2
2005-04-17 02:20:36 +04:00
b 2 f
1 : waituart r2 , r3
senduart r1 , r3
busyuart r2 , r3
teq r1 , #' \n '
moveq r1 , #' \r '
beq 1 b
2 : teq r0 , #0
ldrneb r1 , [ r0 ] , #1
teqne r1 , #0
bne 1 b
mov p c , l r
2008-08-28 14:22:32 +04:00
ENDPROC( p r i n t a s c i i )
2005-04-17 02:20:36 +04:00
ENTRY( p r i n t c h )
2010-07-06 14:30:06 +04:00
addruart_ c u r r e n t r3 , r1 , r2
2005-04-17 02:20:36 +04:00
mov r1 , r0
mov r0 , #0
b 1 b
2008-08-28 14:22:32 +04:00
ENDPROC( p r i n t c h )