Skip to content

Commit 9b5a146

Browse files
Nicolas PitreRussell King
authored andcommitted
ARM: 7338/1: add support for early console output via semihosting
This is a very simple method for code running in an emulator, or under the supervision of a debugger, to use I/O facilities on the controlling host. Tested with OpenOCD, and ARM's Fast Models. Details on semihosting can be found in chapter 8 of DUI0203I_rvct_developer_guide.pdf from ARM Ltd. Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent 101d9b0 commit 9b5a146

3 files changed

Lines changed: 44 additions & 5 deletions

File tree

‎arch/arm/Kconfig.debug‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,22 @@ choice
100100
Note that the system will appear to hang during boot if there
101101
is nothing connected to read from the DCC.
102102

103+
config DEBUG_SEMIHOSTING
104+
bool "Kernel low-level debug output via semihosting I"
105+
help
106+
Semihosting enables code running on an ARM target to use
107+
the I/O facilities on a host debugger/emulator through a
108+
simple SVC calls. The host debugger or emulator must have
109+
semihosting enabled for the special svc call to be trapped
110+
otherwise the kernel will crash.
111+
112+
This is known to work with OpenOCD, as wellas
113+
ARM's Fast Models, or any other controlling environment
114+
that implements semihosting.
115+
116+
For more details about semihosting, please see
117+
chapter 8 of DUI0203I_rvct_developer_guide.pdf from ARM Ltd.
118+
103119
config AT91_DEBUG_LL_DBGU0
104120
bool "Kernel low-level debugging on rm9200, 9260/9g20, 9261/9g10 and 9rl"
105121
depends on HAVE_AT91_DBGU0

‎arch/arm/kernel/debug.S‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100

101101
#endif /* CONFIG_CPU_V6 */
102102

103-
#else
103+
#elif !defined(CONFIG_DEBUG_SEMIHOSTING)
104104
#include <mach/debug-macro.S>
105105
#endif /* CONFIG_DEBUG_ICEDCC */
106106

@@ -155,6 +155,8 @@ hexbuf: .space 16
155155

156156
.ltorg
157157

158+
#ifndef CONFIG_DEBUG_SEMIHOSTING
159+
158160
ENTRY(printascii)
159161
addruart_current r3, r1, r2
160162
b 2f
@@ -177,3 +179,24 @@ ENTRY(printch)
177179
mov r0, #0
178180
b 1b
179181
ENDPROC(printch)
182+
183+
#else
184+
185+
ENTRY(printascii)
186+
mov r1, r0
187+
mov r0, #0x04 @ SYS_WRITE0
188+
ARM( svc #0x123456 )
189+
THUMB( svc #0xab )
190+
mov pc, lr
191+
ENDPROC(printascii)
192+
193+
ENTRY(printch)
194+
adr r1, hexbuf
195+
strb r0, [r1]
196+
mov r0, #0x03 @ SYS_WRITEC
197+
ARM( svc #0x123456 )
198+
THUMB( svc #0xab )
199+
mov pc, lr
200+
ENDPROC(printch)
201+
202+
#endif

‎arch/arm/kernel/head.S‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ __create_page_tables:
265265
str r6, [r3]
266266

267267
#ifdef CONFIG_DEBUG_LL
268-
#ifndef CONFIG_DEBUG_ICEDCC
268+
#if !defined(CONFIG_DEBUG_ICEDCC) && !defined(CONFIG_DEBUG_SEMIHOSTING)
269269
/*
270270
* Map in IO space for serial debugging.
271271
* This allows debug messages to be output
@@ -297,10 +297,10 @@ __create_page_tables:
297297
cmp r0, r6
298298
blo 1b
299299

300-
#else /* CONFIG_DEBUG_ICEDCC */
301-
/* we don't need any serial debugging mappings for ICEDCC */
300+
#else /* CONFIG_DEBUG_ICEDCC || CONFIG_DEBUG_SEMIHOSTING */
301+
/* we don't need any serial debugging mappings */
302302
ldr r7, [r10, #PROCINFO_IO_MMUFLAGS] @ io_mmuflags
303-
#endif /* !CONFIG_DEBUG_ICEDCC */
303+
#endif
304304

305305
#if defined(CONFIG_ARCH_NETWINDER) || defined(CONFIG_ARCH_CATS)
306306
/*

0 commit comments

Comments
 (0)