2019-06-04 11:11:33 +03:00
/* SPDX-License-Identifier: GPL-2.0-only */
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
*
* 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
2015-05-20 01:03:50 +03:00
addruart \ r x , \ t m p1 , \ t m p2
2010-07-06 14:30:06 +04:00
.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
2017-10-06 21:36:58 +03:00
printhex : adr r2 , h e x b u f _ r e l
ldr r3 , [ r2 ]
add r2 , r2 , r3
2005-04-17 02:20:36 +04:00
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
2017-10-06 21:36:58 +03:00
.pushsection .bss
hexbuf_addr : .space 16
.popsection
.align
hexbuf_rel : .long h e x b u f _ a d d r - .
2011-10-20 22:32:07 +04:00
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
2017-11-02 23:58:41 +03:00
1 : teq r0 , #0
2019-02-18 02:57:38 +03:00
ldrbne r1 , [ r0 ] , #1
2005-04-17 02:20:36 +04:00
teqne r1 , #0
2017-11-02 23:58:41 +03:00
reteq l r
2 : teq r1 , #' \n '
bne 3 f
mov r1 , #' \r '
2020-08-28 01:28:56 +03:00
# ifdef C O N F I G _ D E B U G _ U A R T _ F L O W _ C O N T R O L
2020-08-28 01:25:37 +03:00
waituartcts r2 , r3
2020-08-28 01:28:56 +03:00
# endif
2020-08-28 01:25:37 +03:00
waituarttxrdy r2 , r3
2017-11-02 23:58:41 +03:00
senduart r1 , r3
busyuart r2 , r3
mov r1 , #' \n '
2020-08-28 01:28:56 +03:00
3 :
# ifdef C O N F I G _ D E B U G _ U A R T _ F L O W _ C O N T R O L
waituartcts r2 , r3
# endif
2020-08-28 01:25:37 +03:00
waituarttxrdy r2 , r3
2017-11-02 23:58:41 +03:00
senduart r1 , r3
busyuart r2 , r3
b 1 b
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
2017-11-02 23:58:41 +03:00
b 2 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
2013-01-16 18:32:06 +04:00
# ifdef C O N F I G _ M M U
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 ]
2014-06-30 19:29:12 +04:00
ret l r
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
ENDPROC( d e b u g _ l l _ a d d r )
2013-01-16 18:32:06 +04:00
# endif
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
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 )
2017-10-06 21:39:57 +03:00
# ifdef C O N F I G _ C P U _ V 7 M
THUMB( b k p t #0xab )
# else
2012-02-23 00:58:03 +04:00
THUMB( s v c #0xab )
2017-10-06 21:39:57 +03:00
# endif
2014-06-30 19:29:12 +04:00
ret l r
2012-02-23 00:58:03 +04:00
ENDPROC( p r i n t a s c i i )
ENTRY( p r i n t c h )
2017-10-06 21:36:58 +03:00
adr r1 , h e x b u f _ r e l
ldr r2 , [ r1 ]
add r1 , r1 , r2
2012-02-23 00:58:03 +04:00
strb r0 , [ r1 ]
mov r0 , #0x03 @ SYS_WRITEC
ARM( s v c #0x123456 )
2017-10-06 21:39:57 +03:00
# ifdef C O N F I G _ C P U _ V 7 M
THUMB( b k p t #0xab )
# else
2012-02-23 00:58:03 +04:00
THUMB( s v c #0xab )
2017-10-06 21:39:57 +03:00
# endif
2014-06-30 19:29:12 +04:00
ret l r
2012-02-23 00:58:03 +04:00
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 ]
2014-06-30 19:29:12 +04:00
ret l r
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
ENDPROC( d e b u g _ l l _ a d d r )
2012-02-23 00:58:03 +04:00
# endif