TEMU
4.4
The Terma Emulator
|
#include </builds/termade/temu/temu/include/temu-c/Target/CodePatterns.h>
Data Fields | |
uint64_t | PhysicalAddress |
Physical address matched in the decoder (currently ignored) More... | |
uint64_t | PhysicalAddressMask |
temu_PatternAction | Action |
Action to take on this match. More... | |
void(* | Callback )(void *, void *) |
void * | CallbackData |
Data passed in second parameter to callback (currently ignored) More... | |
int | Parameter |
Number of instructions to skip (in case of tePA_Skip), or tag for idle. More... | |
unsigned | PatternLength |
Number of pattern entries. More... | |
const temu_CodePatternEntry * | Pattern |
Code pattern structure
The code pattern structure exists to make it possible to define a static list of code patterns. The patterns should be installed on a processor using the code pattern interface.
The code pattern can be used to attach custom actions, either at a specific physical address or when a sequence of instructions have been matched.
TEMU uses this mechanism internally to detect idle-loops.
A pattern is matched if the physical address of the start matches, and all instructions in the pattern match. Zero length patterns are legal if the physical address mask is non-zero. Normally, skip length and pattern length should be the same.
It is possible to skip backwards. It is also possible to skip more or less than the matched instructions.
When the pattern is installed, it is injected into a trie. The injected structure is after that no longer used and can be disposed.
Patterns are matched at decode time, for both interpreter and binary translator.
For the interpreter, a pseudo instruction will be inserted to carry out the action.
In the case of processors with branch delay slots (e.g. SPARC), the pattern is only triggered if the nPC follows the PC.
Pattern entries match individual instruction chunks, i.e. for Thumb2 an entry matches a 16-bit part, meaning two entries will be needed for a 32-bit instruction.
Note that processors are expected to implement one pattern interface per instruction set.
Patterns are not matched if they cross page boundaries.
temu_PatternAction temu_CodePattern::Action |
Action to take on this match.
void(* temu_CodePattern::Callback) (void *, void *) |
Function to call for actions tePA_Call and tePA_CallAndSkip, first argument is the processor pointer (currently ignored)
void* temu_CodePattern::CallbackData |
Data passed in second parameter to callback (currently ignored)
int temu_CodePattern::Parameter |
Number of instructions to skip (in case of tePA_Skip), or tag for idle.
const temu_CodePatternEntry* temu_CodePattern::Pattern |
unsigned temu_CodePattern::PatternLength |
Number of pattern entries.
uint64_t temu_CodePattern::PhysicalAddress |
Physical address matched in the decoder (currently ignored)
uint64_t temu_CodePattern::PhysicalAddressMask |
Physical address mask matched in the decoder, set to 0 to ignore address (currently ignored)