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>
This commit is contained in:
Nicolas Pitre 2012-02-22 21:58:03 +01:00 committed by Russell King
parent 101d9b0ded
commit 9b5a146a43
3 changed files with 44 additions and 5 deletions

View File

@ -100,6 +100,22 @@ choice
Note that the system will appear to hang during boot if there Note that the system will appear to hang during boot if there
is nothing connected to read from the DCC. is nothing connected to read from the DCC.
config DEBUG_SEMIHOSTING
bool "Kernel low-level debug output via semihosting I"
help
Semihosting enables code running on an ARM target to use
the I/O facilities on a host debugger/emulator through a
simple SVC calls. The host debugger or emulator must have
semihosting enabled for the special svc call to be trapped
otherwise the kernel will crash.
This is known to work with OpenOCD, as wellas
ARM's Fast Models, or any other controlling environment
that implements semihosting.
For more details about semihosting, please see
chapter 8 of DUI0203I_rvct_developer_guide.pdf from ARM Ltd.
config AT91_DEBUG_LL_DBGU0 config AT91_DEBUG_LL_DBGU0
bool "Kernel low-level debugging on rm9200, 9260/9g20, 9261/9g10 and 9rl" bool "Kernel low-level debugging on rm9200, 9260/9g20, 9261/9g10 and 9rl"
depends on HAVE_AT91_DBGU0 depends on HAVE_AT91_DBGU0

View File

@ -100,7 +100,7 @@
#endif /* CONFIG_CPU_V6 */ #endif /* CONFIG_CPU_V6 */
#else #elif !defined(CONFIG_DEBUG_SEMIHOSTING)
#include <mach/debug-macro.S> #include <mach/debug-macro.S>
#endif /* CONFIG_DEBUG_ICEDCC */ #endif /* CONFIG_DEBUG_ICEDCC */
@ -155,6 +155,8 @@ hexbuf: .space 16
.ltorg .ltorg
#ifndef CONFIG_DEBUG_SEMIHOSTING
ENTRY(printascii) ENTRY(printascii)
addruart_current r3, r1, r2 addruart_current r3, r1, r2
b 2f b 2f
@ -177,3 +179,24 @@ ENTRY(printch)
mov r0, #0 mov r0, #0
b 1b b 1b
ENDPROC(printch) ENDPROC(printch)
#else
ENTRY(printascii)
mov r1, r0
mov r0, #0x04 @ SYS_WRITE0
ARM( svc #0x123456 )
THUMB( svc #0xab )
mov pc, lr
ENDPROC(printascii)
ENTRY(printch)
adr r1, hexbuf
strb r0, [r1]
mov r0, #0x03 @ SYS_WRITEC
ARM( svc #0x123456 )
THUMB( svc #0xab )
mov pc, lr
ENDPROC(printch)
#endif

View File

@ -265,7 +265,7 @@ __create_page_tables:
str r6, [r3] str r6, [r3]
#ifdef CONFIG_DEBUG_LL #ifdef CONFIG_DEBUG_LL
#ifndef CONFIG_DEBUG_ICEDCC #if !defined(CONFIG_DEBUG_ICEDCC) && !defined(CONFIG_DEBUG_SEMIHOSTING)
/* /*
* Map in IO space for serial debugging. * Map in IO space for serial debugging.
* This allows debug messages to be output * This allows debug messages to be output
@ -297,10 +297,10 @@ __create_page_tables:
cmp r0, r6 cmp r0, r6
blo 1b blo 1b
#else /* CONFIG_DEBUG_ICEDCC */ #else /* CONFIG_DEBUG_ICEDCC || CONFIG_DEBUG_SEMIHOSTING */
/* we don't need any serial debugging mappings for ICEDCC */ /* we don't need any serial debugging mappings */
ldr r7, [r10, #PROCINFO_IO_MMUFLAGS] @ io_mmuflags ldr r7, [r10, #PROCINFO_IO_MMUFLAGS] @ io_mmuflags
#endif /* !CONFIG_DEBUG_ICEDCC */ #endif
#if defined(CONFIG_ARCH_NETWINDER) || defined(CONFIG_ARCH_CATS) #if defined(CONFIG_ARCH_NETWINDER) || defined(CONFIG_ARCH_CATS)
/* /*