cpu_instrumentation_subscribe
interface.
The interface consist of just one method and looks like this:
SIM_INTERFACE(cpu_instruction_decoder) { void (*register_emulation_cb)(conf_object_t *cpu, cpu_emulation_cb_t cb, decoder_handle_t *handle, lang_void *user_data, cpu_callback_free_user_data_cb_t free_cb); }; #define CPU_INSTRUCTION_DECODER_INTERFACE "cpu_instruction_decoder"
register_emulation_cb is used to set a callback function that
implements the semantics of the new or changed instruction. Every time the
instructions is executed on the cpu this function will be called
instead of the build-in implementation. The handle is the
decoder_handle_t
handle passed to the
cpu_instruction_decoder_cb_t callback. The user_data
argument is user data for the callback. The free_cb is a clean-up
callback function that Simics calls when the instruction is overwritten or
if Simics wants to flush decoding caches. This function should deallocate
any the user data if present. Can be NULL if not used.
The signature of the emulation callback looks like this:
typedef cpu_emulation_t (*cpu_emulation_cb_t)( conf_object_t *obj, conf_object_t *cpu, lang_void *user_data);
obj is the connection object, the same object as passed to the cpu_instruction_decoder_cb_t callback. cpu is the processor executing the replaced instruction. user_data is user data for the emulation callback. This is a useful place for storing immediate or register values for the new instruction. In the emulation function the whole Cell Context API is available for use.
CPU_Emulation_Fall_Through
should be returned from the emulation
callback if replaced one is a fall through instruction. The program counter
does not need to be updated. If the replaced instruction is doing any
control flow then CPU_Emulation_Control_Flow
should be returned and
the program counter should be set to the destination address. This can be
done for fall through instruction as well but is less efficient.
CPU_Emulation_Default_Semantics
can also be returned to indicate that
the default semantics should be used instead of the user defined. This can
be useful if the instruction only should be replaced under certain
circumstances.
cpu_instrumentation_subscribe
interface.