translation_flush interface is an optional interface
which can be implemented by objects implementing the
transaction_translator or translator interface.
The interface is used
by Simics an optimization when Simics flushes its simulation caches.
Simics caches translations returned by translators but
quite often this cache needs to be invalidated, usually, due to
the changes in the memory map of the target system. In such cases
Simics may use this interface (if it is available) to do a fine-grain
invalidation of its simulation caches.
The translation_flush interface has one method
- flush_range - which will be called whenever there is
a need to flush simulation caches. The flush_range method
has the following parameters:
- base is the start of the region to flush;
- size is the size of the region to flush;
- access is a bitmask which specifies targets
for what access types should be flushed;
- default_target is only used for translators implementing
the translator interface and has the same as value as
the default_target parameter of
the translate method of the translator interface.
Please see the documentation of the translator for more
information about the parameter.
In the flush_range method, the translator object is expected
to flush all previously returned destinations of the translation requests
that the translator did for
the [base, base+size) range.
The flushing is done by calling the SIM_map_target_flush function
for the destination map target(s). If no translation requests were processed
to the range since the last invocation of the flush_range method
then no flushing is needed, and the flush_range may immediately
return the true value.
Please note that there is no need to call
the SIM_map_target_flush function for the translations which
were tagged with the Sim_Translation_Dynamic flag. Either,
no invalidation is needed for the parts of the range where nothing is mapped.
The return value is used to report whether the invalidation request
completed successfully, i.e. whether all calls to
the SIM_map_target_flush function succeeded (i.e. returned
the true value). If a call to
the SIM_map_target_flush fails (i.e.
the false value is returned) then
the flush_range function is expected to
return immediately with the false return value. If, for
some reason, the translator cannot invalidate all possible destinations,
then it can just immediately return the false value.
If false is returned, then all translations in the simulator
will typically be flushed, which could be an expensive operation.
bool flush_range(obj, base, size, access):
for (map_target, start, size) in destinations(obj, base, size, access):
if not SIM_map_target_flush(map_target, start, size, access):
return False
return True
SIM_INTERFACE(translation_flush) {
bool (*flush_range)(
conf_object_t *obj,
uint64 base,
uint64 size,
access_t access,
const map_target_t *default_target);
};
#define TRANSLATION_FLUSH_INTERFACE "translation_flush"