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 >
2012-03-10 20:30:31 +04:00
# include < a s m / a s s e m b l e r . h >
2005-04-17 02:20:36 +04:00
.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 !
* /
2012-08-31 09:03:46 +04:00
# if ! d e f i n e d ( C O N F I G _ D E B U G _ S E M I H O S T I N G )
# include C O N F I G _ D E B U G _ L L _ I N C L U D E
# endif
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
2012-02-23 00:58:03 +04:00
# ifndef C O N F I G _ D E B U G _ S E M I H O S T I N G
2005-04-17 02:20:36 +04:00
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 )
2012-02-23 00:58:03 +04:00
ARM: implement debug_ll_io_init()
When using DEBUG_LL, the UART's (or other HW's) registers are mapped
into early page tables based on the results of assembly macro addruart.
Later, when the page tables are replaced, the same virtual address must
remain valid. Historically, this has been ensured by using defines from
<mach/iomap.h> in both the implementation of addruart, and the machine's
.map_io() function. However, with the move to single zImage, we wish to
remove <mach/iomap.h>. To enable this, the macro addruart may be used
when constructing the late page tables too; addruart is exposed as a
C function debug_ll_addr(), and used to set up the required mapping in
debug_ll_io_init(), which may called on an opt-in basis from a machine's
.map_io() function.
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
[swarren: Mask map.virtual with PAGE_MASK. Checked for NULL results from
debug_ll_addr (e.g. when selected UART isn't valid). Fixed compile when
either !CONFIG_DEBUG_LL or CONFIG_DEBUG_SEMIHOSTING.]
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Olof Johansson <olof@lixom.net>
2012-10-22 21:42:54 +04:00
ENTRY( d e b u g _ l l _ a d d r )
addruart r2 , r3 , i p
str r2 , [ r0 ]
str r3 , [ r1 ]
mov p c , l r
ENDPROC( d e b u g _ l l _ a d d r )
2012-02-23 00:58:03 +04:00
# else
ENTRY( p r i n t a s c i i )
mov r1 , r0
mov r0 , #0x04 @ SYS_WRITE0
ARM( s v c #0x123456 )
THUMB( s v c #0xab )
mov p c , l r
ENDPROC( p r i n t a s c i i )
ENTRY( p r i n t c h )
adr r1 , h e x b u f
strb r0 , [ r1 ]
mov r0 , #0x03 @ SYS_WRITEC
ARM( s v c #0x123456 )
THUMB( s v c #0xab )
mov p c , l r
ENDPROC( p r i n t c h )
ARM: implement debug_ll_io_init()
When using DEBUG_LL, the UART's (or other HW's) registers are mapped
into early page tables based on the results of assembly macro addruart.
Later, when the page tables are replaced, the same virtual address must
remain valid. Historically, this has been ensured by using defines from
<mach/iomap.h> in both the implementation of addruart, and the machine's
.map_io() function. However, with the move to single zImage, we wish to
remove <mach/iomap.h>. To enable this, the macro addruart may be used
when constructing the late page tables too; addruart is exposed as a
C function debug_ll_addr(), and used to set up the required mapping in
debug_ll_io_init(), which may called on an opt-in basis from a machine's
.map_io() function.
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
[swarren: Mask map.virtual with PAGE_MASK. Checked for NULL results from
debug_ll_addr (e.g. when selected UART isn't valid). Fixed compile when
either !CONFIG_DEBUG_LL or CONFIG_DEBUG_SEMIHOSTING.]
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Olof Johansson <olof@lixom.net>
2012-10-22 21:42:54 +04:00
ENTRY( d e b u g _ l l _ a d d r )
mov r2 , #0
str r2 , [ r0 ]
str r2 , [ r1 ]
mov p c , l r
ENDPROC( d e b u g _ l l _ a d d r )
2012-02-23 00:58:03 +04:00
# endif