Semihosting; Overview; The Swi Interface - Segger J-Link Series User Manual

Table of Contents

Advertisement

8.5

Semihosting

Semihosting is a mechanism for ARM targets to communicate input/output requests
from application code to a host computer running a debugger.
It effectively allows the target to do disk operations and console I/O and is used pri-
marily for flash loaders with ARM debuggers such as AXD.
8.5.1

Overview

Semihosting
Semihosting is a mechanism for ARM targets to communicate input/output requests
from application code to a host computer running a debugger. This mechanism is
used, to allow functions in the C library, such as printf() and scanf() , to use the
screen and keyboard of the host rather than having a screen and keyboard on the
target system.
This is useful because development hardware often does not have all the input and
output facilities of the final system. Semihosting allows the host computer to provide
these facilities.
Semihosting is also used for Disk I/O and flash programming; a flash loader uses
semihosting to load the target program from disk.
Semihosting is implemented by a set of defined software interrupt (SWI) operations.
The application invokes the appropriate SWI and the debug agent then handles the
SWI exception. The debug agent provides the required communication with the host.
In many cases, the semihosting SWI will be invoked by code within library functions.
Usage of semihosting
The application can also invoke the semihosting SWI directly. Refer to the C library
descriptions in the ADS Compilers and Libraries Guide for more information on sup-
port for semihosting in the ARM C library.
Semihosting is not used by all tool chains; most modern tool chains (such as IAR)
use different mechanisms to achive the same goal.
Semihosting is used primarily by ARM's tool chain and debuggers, such as AXD.
Since semihosting has been used primarily by ARM, documents published by ARM are
the best source of add. information.
For further information on semihosting and the C libraries, see the "C and C++
Libraries" chapter in ADS Compilers and Libraries Guide. Please see also the "Writing
Code for ROM" chapter in ADS Developer Guide.
8.5.2

The SWI interface

The ARM and Thumb SWI instructions contain a field that encodes the SWI number
used by the application code. This number can be decoded by the SWI handler in the
system. See the chapter on exception handling in ADS Developer Guide for more
information on SWI handlers.
Semihosting operations are requested using a single SWI number. This leaves the
other SWI numbers available for use by the application or operating system. The SWI
used for semihosting is:
0x123456 in ARM state
0xAB
in Thumb state
The SWI number indicates to the debug agent that the SWI is a semihosting request.
In order to distinguish between operations, the operation type is passed in r0. All
other parameters are passed in a block that is pointed to by r1. The result is returned
in r0, either as an explicit return value or as a pointer to a data block. Even if no
result is returned, assume that r0 is corrupted.
J-Link / J-Trace (UM08001)
© 2004-2012 SEGGER Microcontroller GmbH & Co. KG
189

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the J-Link Series and is the answer not in the manual?

Table of Contents

Save PDF