Examples of these facilities include keyboard input, screen
output, and disk I/O. For example, you can use this mechanism to
enable functions in the C library, such as printf()
and scanf()
, to
use the screen and keyboard of the host instead of 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
enables the host computer to provide these facilities.
Semihosting is implemented by a set of defined software instructions, for example SVCs,
that generate exceptions from program control. The application invokes the appropriate
semihosting call and the debug agent then handles the exception. The debug agent provides
the required communication with the host.
The semihosting interface is common across all debug agents
provided by ARM. Semihosted operations work when you are debugging
applications on your development platform, as shown in the following
figure:
Figure 11-1 Semihosting overview
In many cases, semihosting is invoked by code within library
functions. The application can also invoke the semihosting operation
directly.
Note
ARM processors use the SVC
instructions,
formerly known as SWI
instructions, to make semihosting
calls. However, if you are compiling for an ARMv6-M or ARMv7-M, for example a Cortex-M1 or
Cortex-M3 processor, semihosting is implemented using the BKPT
instruction.