3.9. Using the semihosting API

CADI provides a semi-hosting interface that enables interaction between a user and a connected target. As shown in Figure 3.6, a debugger can use the host machine I/O to emulate the I/O devices in a simulation platform. An application running on a target component can request keyboard input that is then provided interactively by the user entering the input on the host keyboard.

Figure 3.6. Semihosting interface

To view this graphic, your browser must support the SVG format. Either install a browser with native support, or install an appropriate plugin such as Adobe SVG Viewer.

Because semi hosting is used by the simulation target to provide and receive information, the interface methods are provided by the CADICallbackObj object. The primary methods are appliInput() and appliOutput(). See CADICallbackObj::appliInput() and CADICallbackObj::appliOutput(). Both use a data buffer of type char and the buffer size defined by the target.

After the call returns, the actualCount parameter indicates:

Because the forwarded string might contain '\0' characters, the end of the string is not indicated by '\0'.


actualCount is also used to indicate:

  • that the end of file was reached by returning zero

  • that a string reading error occurred by returning static_cast<uint32_t>(-1).

The addressed target of appliInput() and appliOutput() is typically one StdIn, StdOut, and StdErr streams on the host. The host can redirect these standard stream calls to log files. The IDs for the standard streams are defined in the enumeration type CADIStreamId. The numbering corresponds to the C file conventions:

Use the appliOpen() and appliClose() callbacks to open and close streams to files. The returned ID identifies the stream. The file stream IDs and standard stream IDs cannot overlap.

The semi-hosting interface also provides the doString() method to send messages from the target to the caller. This method can be used, for example, to send error messages or debug output. This call is not intended to be used for passing printouts from an application. See CADICallbackObj::doString().

Copyright © 2008-2010 ARM Limited. All rights reserved.ARM DUI 0444F