A.1.2. 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.
Note
If you are compiling for v6-M or v7-M processor such as Cortex-M1 or Cortex-M3, 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 Thumb state, excluding ARMv7‑M, and ARM state. This behavior is not guaranteed on all debug targets from ARM or from third parties.
BKPT 0xABfor ARMv7‑M, Thumb state only.
See also Changing the semihosting operation numbers.
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 use the operation names defined in semihost.h. This is installed as part of the RealView ARMulator Extension Kit. You can define the operation names with an EQU directive. For example:
SYS_OPEN EQU 0x01
SYS_CLOSE EQU 0x02
Changing the semihosting operation numbers
It is strongly recommended that you do not change the semihosting operation numbers. If you do, you must:
change all the code in your system, including library code, to use the new number
reconfigure your debugger to use the new number.