4.15.3 Semihosting input interface

Semihosting input is implemented using event sources and functions.

Enabling semihosting input typically involves the following steps:

  • The client activates the IRIS_SEMIHOSTING_INPUT_REQUEST and, optionally, IRIS_SEMIHOSTING_INPUT_UNBLOCKED event sources using eventStream_create(). This step tells the global instance that this client is able to provide semihosting input. If multiple clients activate these event sources, they all receive these events, and also they all might provide input that is interleaved and unsynchronized.
  • Applications that do not require input do not issue an IRIS_SEMIHOSTING_INPUT_REQUEST event.
  • When the application requires user input, it causes the semihosting implementation to issue an IRIS_SEMIHOSTING_INPUT_REQUEST event. The client might read from the console or open a terminal window UI, for example.
  • When the user has entered either one character or one line of data, the client passes this data to the semihosting interface using the function semihosting_provideInputData().
  • If the simulated application wants more data, the client waits for user input and sends it to the semihosting interface when it is available. If the application does not want more data, for example it is no longer blocked in a read() call, the semihosting implementation issues an IRIS_SEMIHOSTING_INPUT_UNBLOCKED event. The client can then close the terminal window or simply ignore this event.
  • The client can send user input to the semihosting implementation using semihosting_provideInputData() at any time, even if the running application is not waiting for data. This can happen before an IRIS_SEMIHOSTING_INPUT_REQUEST or after an IRIS_SEMIHOSTING_INPUT_UNBLOCKED event. In these cases, the semihosting implementation must buffer the data for subsequent reads. Sending user input to the model before the first IRIS_SEMIHOSTING_INPUT_REQEST must assume that the IRIS_SEMIHOSTING_INPUT_REQUEST RAW field is False. This means user input should be fed into the model when the user presses the Enter key, in other words terminal cooked mode.


    The following rules apply to buffering the data that is provided by semihosting_provideInputData(). They are only relevant when the semihosting implementation must handle megabytes of input data, for example from streams or files. For interactive user input, they are not relevant and can be ignored:

    • The target must not impose a limit on the buffer.
    • The client is responsible for not pushing too much data into the model without the model processing it. The client should send a maximum of 1MB of data to the simulation before receiving an IRIS_SEMIHOSTING_INPUT_REQUEST event. After receiving an IRIS_SEMIHOSTING_INPUT_REQUEST event, the client can send a maximum of SIZEHINT + 1MB of data, because this event indicates that all previous data has been consumed. This ensures that the model only needs to buffer at most 1MB in addition to the currently requested data size, assuming only a single client is pushing data. The client effectively controls the buffer size in the model. The advantage over the model limiting the data size is that the client can choose a suitable behavior when more data becomes available. For example, it can block the thread that produces the data, or it can discard unwanted data.
Non-ConfidentialPDF file icon PDF version101196_0100_00_en
Copyright © 2018 Arm Limited or its affiliates. All rights reserved.