keyboard_console magic_pipe_reader
API Reference Manual  /  5 Model-to-Simulator Interfaces  / 

linear_image

Description
Note: This interface is an experimental feature. It is excluded from the standard support program, and is subject to change or removal without notice.
The linear_image interface permits direct access to the data in image objects by requesting a linear allocation for the contents. Doing so is not recommended for very large images, since there must be space for all data in memory as a contiguous block.

get_base returns the linear allocation block if one has already been set. Otherwise, a block of the correct size is allocated, set and returned. In the latter case, the block is owned by the image object and should not be freed by the user. If retsize is non-null, it is used to return the size of the image.

set_base specifies an existing memory block to be used for the image contents. The block must be at least the size of the image, and should be aligned to a multiple of 4096 bytes. The caller is responsible for the allocation of the block, which must remain allocated for the remaining lifetime of the image object.

prepare_range must be called, with the matching access type, before any direct access to data in a linear block by user code. It is then permitted to access bytes in the range [offs, offs + size) . For type = Sim_RW_Write, the permission to modify data in that range only extends until any other objects using the image have the opportunity to do so (typically, when the modelling function returns control to the simulator).

set_base and get_base cannot be called after image data has been accessed (read or written) for the first time.

SIM_INTERFACE(linear_image) {
#if !defined(PYWRAP)
        uint8 *(*get_base)(conf_object_t *obj, size_t *retsize);
        void (*set_base)(conf_object_t *obj, uint8 *NOTNULL base);
#endif /* not PYWRAP */
        void (*prepare_range)(conf_object_t *NOTNULL obj,
                              read_or_write_t type, size_t offs, size_t size);
};
#define LINEAR_IMAGE_INTERFACE "linear_image"

Execution Context
set_base Global Context
get_base Global Context
prepare_range Cell Context

keyboard_console magic_pipe_reader