5.18.2 Enabling semihosting input

Enabling semihosting input typically involves the following steps:


  1. The client activates the IRIS_SEMIHOSTING_INPUT_REQUEST event source and optionally IRIS_SEMIHOSTING_INPUT_UNBLOCKED 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. The input that they provide might be interleaved and unsynchronized.
  2. When the application requires user input, it causes the semihosting implementation to issue an IRIS_SEMIHOSTING_INPUT_REQUEST event. The client might then read from the console or open a terminal window UI, for example. Applications that do not require input do not issue these events.
  3. When the user has entered a character or a line of data, the client passes this data to the semihosting interface using the function semihosting_provideInputData().
  4. If the simulated application requires more data, the client waits for user input and sends it to the semihosting interface when it is available. If the application does not require 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.
  5. The client can send user input to the semihosting implementation using semihosting_provideInputData() at any time, even if the application is not waiting for data, in other words 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 passed to 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 to the model before the model has processed it. The client should send a maximum of 1MB of data to the simulation before receiving an IRIS_SEMIHOSTING_INPUT_REQUEST event. After receiving this 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_03_en
Copyright © 2018, 2019 Arm Limited or its affiliates. All rights reserved.