| |||
| Home > Semihosting > The semihosting interface | |||
The ARM and Thumb SVC instructions contain a
field that encodes the SVC number used by the application code.
The system SVC handler can decode this number.
If you are compiling for the ARMv6-M or ARMv7-M, the Thumb BKPT instruction
is used instead of the Thumb SVC instruction. Both BKPT and SVC take
an 8-bit immediate value. In all other respects, semihosting is
the same for all supported ARM processors.
Semihosting operations are requested using a single SVC number, leaving the other numbers available for use by the application or operating system. The SVC number used for semihosting depends on the target architecture or processor:
SVC 0x123456In ARM state for all architectures.
SVC 0xABIn ARM state and Thumb state, excluding ARMv6-M and ARMv7-M. This behavior is not guaranteed on all debug targets from ARM or from third parties.
BKPT 0xABFor ARMv6-M and ARMv7-M, Thumb state only.
The SVC number indicates to the debug agent that the SVC instruction
is a semihosting request. 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.
The available semihosting operation numbers passed in R0 are
allocated as follows:
0x00-0x31Used by ARM.
0x32-0xFFReserved for future use by ARM.
0x100-0x1FFReserved for user applications. These are not used by ARM.
If you are writing your own SVC operations, however, you are advised to use a different SVC number rather than using the semihosted SVC number and these operation type numbers.
0x200-0xFFFFFFFFUndefined and currently unused. It is recommended that you do not use these.
In the following sections, the number in parentheses after
the operation name is the value placed into R0,
for example SYS_OPEN (0x01).
If you are calling SVCs from assembly language code ARM recommends
that you define the semihosting operation names, to their respective
operation numbers, with the EQU directive. For example:
SYS_OPEN EQU 0x01 SYS_CLOSE EQU 0x02