processor_info_v2
interface is implemented by
processors models. The interface has processor generic functions
that are architecture independent.
The disassemble function returns the disassemble string for an
instruction at address with opcode according to
instruction_data. The instruction_data is an
attr_value_t value of data type with the bytes of the
opcode. The bytes are in the same order as they are stored in memory. For
VLIW architectures, sub_operation is used to select which
sub-operation to disassemble. The sub-operations start at zero, and a
request for the entire unit including all sub-operations is encoded with
sub-operation -1. A request for a sub-operation that is not present (for
example when sub-operation is neither 0 nor -1 for non-VLIW
architectures) results in the integer part of the return tuple being set to
zero. If successful, the function should return a tuple with the size of the
instruction in bytes and the disassembly string. The disassembly string
should be allocated with MM_MALLOC or similar and is to be freed by the
caller. If more bytes are needed, then the function should indicate that by
returning a negative number in the tuple where the absolute value of the
number is the required number of bytes. The string should be NULL if more
bytes are needed. The implementor of processor_info_v2
is
allowed to request one additional byte at a time until enough bytes are
passed to determine what the instruction is. Illegal instructions should
still result in a valid returned tuple, where the integer part will be used
by the disassemble command to skip that many bytes before disassembling the
next instruction. The address can be used to display absolute
destinations of program counter relative branches.
The set_program_counter function sets the program counter in the processor. The get_program_counter function returns the current program counter.
The logical_to_physical function translates a logical
address to a physical address of the type defined by
access_type. The function returns a physical_block_t
struct with valid bit and the address. The
address is valid when the valid bit is not 0
. The
logical_to_physical function also returns
block_start and block_end. The start and end
of a block has the same logical to physical transformation as the translated
address. The range is inclusive, so block_end should be the
address of the last byte of the block.
This information can be used to figure out how often the
logical_to_physical function needs to be called. An implementation would
typically return the page start and end here, but it is free to return any
power of 2 sized block as long as it includes the translated address.
The current operating mode of the processor is returned with get_processor_mode.
The processor can be enabled or disabled with the
enable_processor or disable_processor
functions. The functions should return 0
if the processor
changed from enabled to disabled or from disabled to enabled, and
1
if the processor did not change state. The current state
is returned by the get_enabled function. Enabled or
disabled here refers to the state that the user of the model has
put the processor into. In particular, it is independent of the
power mode of the processor. A processor that has powered down does
not count as disabled in this sense, nor does the
enable_processor wake up a processor that is in
a power-saving sleep state.
The endianness of the processor is returned by the get_endian function.
The physical memory object is returned by the
get_physical_memory function. The object returned by
get_physical_memory is used to set breakpoints by the
global break command, and to read and write physical
memory through set, get,
load-binary, load-file, and the default
implementation of disassemble. The object returned
implements the memory_space
and
breakpoint
interfaces. The
memory_space
interface for the returned object is
only be used in inquiry mode corresponding to actions by the
simulator itself rather than by the simulated software. An
implementation may return NULL from this method, which will lead to
the command listed above not being supported when such a processor
is selected.
The get_logical_address_width function returns the number of logical/virtual address bits and the get_physical_address_width function returns the number of physical address bits.
The processor architecture is returned by calling the
architecture function. The architecture should be one of
arm
, mips32
,
mips64
, ppc32
, ppc64
, sparc-v8
,
sparc-v9
, x86
, x86-64
, or something else
if none of the listed is a good match.
All functions in the interface are optional. Each function can be set to NULL if it is not supported.
SIM_INTERFACE(processor_info_v2) { tuple_int_string_t (*disassemble)(conf_object_t *obj, generic_address_t address, attr_value_t instruction_data, int sub_operation); void (*set_program_counter)(conf_object_t *obj, logical_address_t pc); logical_address_t (*get_program_counter)(conf_object_t *obj); physical_block_t (*logical_to_physical)(conf_object_t *obj, logical_address_t address, access_t access_type); processor_mode_t (*get_processor_mode)(conf_object_t *obj); int (*enable_processor)(conf_object_t *obj); int (*disable_processor)(conf_object_t *obj); int (*get_enabled)(conf_object_t *obj); cpu_endian_t (*get_endian)(conf_object_t *obj); conf_object_t *(*get_physical_memory)(conf_object_t *obj); int (*get_logical_address_width)(conf_object_t *obj); int (*get_physical_address_width)(conf_object_t *obj); const char *(*architecture)(conf_object_t *obj); }; #define PROCESSOR_INFO_V2_INTERFACE "processor_info_v2"
Note that the original version of this interface
(processor_info
) must also be implemented. The only
difference between the two interfaces is that the original version lacks the
get_processor_mode function.
disassemble | Cell Context |
set_program_counter | Global Context (with some additions; see below) |
get_program_counter | Cell Context |
logical_to_physical | Cell Context |
get_processor_mode | Cell Context |
enable_processor | Cell Context |
disable_processor | Cell Context |
get_enabled | Cell Context |
get_endian | Cell Context |
get_physical_memory | Cell Context |
get_logical_address_width | Cell Context |
get_physical_address_width | Cell Context |
architecture | Cell Context |
It is explicitly permitted to call set_program_counter from inside an execution breakpoint handler.