190 CHAPTER 8 RDI
J-Link / J-Trace (UM08001) ©
2004-2012 SEGGER Microcontroller GmbH & Co. KG
The available semihosting operation numbers passed in r0 are allocated as follows:
0x00 to 0x31 These are used by ARM.
0x32 to 0xFF These are reserved for future use by ARM.
0x100 to 0x1FF Reserved for applications.
8.5.2.1 Changing the semihosting SWI numbers
It is strongly recommended that you do not change the semihosting SWI numbers
0x123456 (ARM) or 0xAB (Thumb). If you do so you must:
• change all the code in your system, including library code, to use the new SWI
number
• reconfigure your debugger to use the new SWI number.
8.5.3 Implementation of semihosting in J-Link RDI
When using J-Link RDI in default configuration, semihosting is implemented as fol-
lows:
• A breakpoint / vector catch is set on the SWI vector.
• When this breakpoint is hit, J-Link RDI examines the SWI number.
• If the SWI is recognized as a semihosting SWI, J-Link RDI emulates it and trans-
parently restarts execution of the application.
• If the SWI is not recognized as a semihosting SWI, J-Link RDI halts the processor
and reports an error. (See
Unexpected / unhandled SWIs on page 191)
8.5.3.1 DCC semihosting
J-Link RDI does not support using the debug communications channel for semihost-
ing.
8.5.4 Semihosting with AXD
This semihosting mechanism can be disabled or changed by the following debugger
internal variables:
$semihosting_enabled
Set this variable to 0 to disable semihosting. If you are debugging an application run-
ning from ROM, this allows you to use an additional watchpoint unit.
Set this variable to 1 to enable semihosting. This is the default.
Set this variable to 2 to enable Debug Communications Channel (DCC) semihosting.
The S bit in $vector_catch has no effect unless semihosting is disabled.
$semihosting_vector
This variable controls the location of the breakpoint set by J-Link RDI to detect a
semihosted SWI. It is set to the SWI entry in the exception vector table () by default.
8.5.4.1 Using SWIs in your application
If your application requires semihosting as well as having its own SWI handler, set
$semihosting_vector to an address in your SWI handler. This address must point to
an instruction that is only executed if your SWI handler has identified a call to a
semihosting SWI. All registers must already have been restored to whatever values
they had on entry to your SWI handler.