SimAVR
AVR Simulator
|
Data Structures | |
struct | avr_trace_data_t |
This is only ever used if CONFIG_SIMAVR_TRACE is defined. More... | |
struct | avr_t |
Main AVR instance. More... | |
struct | avr_kind_t |
Static constructor for each of the AVR devices. More... | |
struct | avr_symbol_t |
Symbol loaded from the .elf file. More... | |
Macros | |
#define | AVR_LOG(avr, level, ...) |
#define | AVR_TRACE(avr, ...) AVR_LOG(avr, LOG_TRACE, __VA_ARGS__) |
#define | IO_START_ADDRESS 0x20 |
IOs are located just after the register file (32 registers) More... | |
#define | AVR_IO_TO_DATA(v) ((v) + IO_START_ADDRESS) |
Map an IO address to the SRAM address space, i.e. add the register file offset to the address. More... | |
#define | AVR_DATA_TO_IO(v) ((v) - IO_START_ADDRESS) |
Unmap an IO address from the address SRAM, i.e. subtract the register file offset to the address. More... | |
Typedefs | |
typedef uint32_t | avr_flashaddr_t |
typedef uint8_t(* | avr_io_read_t) (struct avr_t *avr, avr_io_addr_t addr, void *param) |
typedef void(* | avr_io_write_t) (struct avr_t *avr, avr_io_addr_t addr, uint8_t v, void *param) |
typedef void(* | avr_run_t) (struct avr_t *avr) |
typedef struct avr_t | avr_t |
Main AVR instance. More... | |
typedef struct avr_kind_t | avr_kind_t |
Static constructor for each of the AVR devices. More... | |
typedef struct avr_symbol_t | avr_symbol_t |
Symbol loaded from the .elf file. More... | |
typedef void(* | avr_logger_p) (struct avr_t *avr, const int level, const char *format, va_list ap) |
Type for custom logging functions. More... | |
Enumerations | |
enum | { LOG_OUTPUT = 0, LOG_ERROR, LOG_WARNING, LOG_TRACE } |
Logging macros and associated log levels. More... | |
enum | { S_C = 0, S_Z, S_N, S_V, S_S, S_H, S_T, S_I, R_XL = 0x1a, R_XH, R_YL, R_YH, R_ZL, R_ZH, R_SPL = AVR_IO_TO_DATA(0x3d), R_SPH, R_SREG = AVR_IO_TO_DATA(0x3f), MAX_IOs = 280 } |
enum | { cpu_Limbo = 0, cpu_Stopped, cpu_Running, cpu_Sleeping, cpu_Step, cpu_StepDone, cpu_Done, cpu_Crashed } |
Core states. More... | |
Functions | |
avr_t * | avr_make_mcu_by_name (const char *name) |
Locate the maker for mcu "name" and allocates a new avr instance. More... | |
int | avr_init (avr_t *avr) |
Initializes a new AVR instance. Will call the IO registers init(), and then reset() More... | |
avr_t * | avr_core_allocate (const avr_t *core, uint32_t coreLen) |
Used by the cores, allocated a mutable avr_t from the const global. More... | |
void | avr_reset (avr_t *avr) |
Resets the AVR, and the IO modules. More... | |
int | avr_run (avr_t *avr) |
Run one cycle of the AVR, sleep if necessary. More... | |
void | avr_terminate (avr_t *avr) |
Finish any pending operations. More... | |
void | avr_set_command_register (avr_t *avr, avr_io_addr_t addr) |
Set an IO register to receive commands from the AVR firmware it's optional, and uses the ELF tags. More... | |
void | avr_set_console_register (avr_t *avr, avr_io_addr_t addr) |
Specify the "console register" – output sent to this register is printed on the simulator console, without using a UART. More... | |
void | avr_loadcode (avr_t *avr, uint8_t *code, uint32_t size, avr_flashaddr_t address) |
Load code in the "flash". More... | |
void | avr_core_watch_write (avr_t *avr, uint16_t addr, uint8_t v) |
These are accessors for avr->data but allows watchpoints to be set for gdb IO modules use that to set values to registers, and the AVR core decoder uses that to register "public" read by instructions. More... | |
uint8_t | avr_core_watch_read (avr_t *avr, uint16_t addr) |
void | avr_sadly_crashed (avr_t *avr, uint8_t signal) |
Called when the core has detected a crash somehow. More... | |
void | avr_global_logger (struct avr_t *avr, const int level, const char *format,...) |
Logs a message using the current logger. More... | |
void | avr_global_logger_set (avr_logger_p logger) |
Sets a global logging function in place of the default. More... | |
avr_logger_p | avr_global_logger_get (void) |
Gets the current global logger function. More... | |
void | avr_callback_sleep_gdb (avr_t *avr, avr_cycle_count_t howLong) |
These are callbacks for the two 'main' behaviour in simavr. More... | |
void | avr_callback_run_gdb (avr_t *avr) |
void | avr_callback_sleep_raw (avr_t *avr, avr_cycle_count_t howLong) |
void | avr_callback_run_raw (avr_t *avr) |
uint32_t | avr_pending_sleep_usec (avr_t *avr, avr_cycle_count_t howLong) |
Accumulates sleep requests (and returns a sleep time of 0) until a minimum count of requested sleep microseconds are reached (low amounts cannot be handled accurately). More... | |
#define AVR_DATA_TO_IO | ( | v | ) | ((v) - IO_START_ADDRESS) |
Unmap an IO address from the address SRAM, i.e. subtract the register file offset to the address.
#define AVR_IO_TO_DATA | ( | v | ) | ((v) + IO_START_ADDRESS) |
Map an IO address to the SRAM address space, i.e. add the register file offset to the address.
#define AVR_LOG | ( | avr, | |
level, | |||
... | |||
) |
#define IO_START_ADDRESS 0x20 |
IOs are located just after the register file (32 registers)
typedef uint32_t avr_flashaddr_t |
typedef uint8_t(* avr_io_read_t) (struct avr_t *avr, avr_io_addr_t addr, void *param) |
typedef void(* avr_io_write_t) (struct avr_t *avr, avr_io_addr_t addr, uint8_t v, void *param) |
typedef struct avr_kind_t avr_kind_t |
Static constructor for each of the AVR devices.
Type for custom logging functions.
typedef struct avr_symbol_t avr_symbol_t |
Symbol loaded from the .elf file.
Main AVR instance.
Some of these fields are set by the AVR "Core" definition files the rest is runtime data (as little as possible)
anonymous enum |
anonymous enum |
anonymous enum |
Core states.
void avr_callback_run_gdb | ( | avr_t * | avr | ) |
void avr_callback_run_raw | ( | avr_t * | avr | ) |
void avr_callback_sleep_gdb | ( | avr_t * | avr, |
avr_cycle_count_t | howLong | ||
) |
These are callbacks for the two 'main' behaviour in simavr.
void avr_callback_sleep_raw | ( | avr_t * | avr, |
avr_cycle_count_t | howLong | ||
) |
Used by the cores, allocated a mutable avr_t from the const global.
uint8_t avr_core_watch_read | ( | avr_t * | avr, |
uint16_t | addr | ||
) |
void avr_core_watch_write | ( | avr_t * | avr, |
uint16_t | addr, | ||
uint8_t | v | ||
) |
These are accessors for avr->data but allows watchpoints to be set for gdb IO modules use that to set values to registers, and the AVR core decoder uses that to register "public" read by instructions.
void avr_global_logger | ( | struct avr_t * | avr, |
const int | level, | ||
const char * | format, | ||
... | |||
) |
Logs a message using the current logger.
avr_logger_p avr_global_logger_get | ( | void | ) |
Gets the current global logger function.
void avr_global_logger_set | ( | avr_logger_p | logger | ) |
Sets a global logging function in place of the default.
int avr_init | ( | avr_t * | avr | ) |
void avr_loadcode | ( | avr_t * | avr, |
uint8_t * | code, | ||
uint32_t | size, | ||
avr_flashaddr_t | address | ||
) |
Load code in the "flash".
avr_t* avr_make_mcu_by_name | ( | const char * | name | ) |
Locate the maker for mcu "name" and allocates a new avr instance.
uint32_t avr_pending_sleep_usec | ( | avr_t * | avr, |
avr_cycle_count_t | howLong | ||
) |
Accumulates sleep requests (and returns a sleep time of 0) until a minimum count of requested sleep microseconds are reached (low amounts cannot be handled accurately).
This function is an utility function for the sleep callbacks
void avr_reset | ( | avr_t * | avr | ) |
Resets the AVR, and the IO modules.
int avr_run | ( | avr_t * | avr | ) |
Run one cycle of the AVR, sleep if necessary.
void avr_sadly_crashed | ( | avr_t * | avr, |
uint8_t | signal | ||
) |
Called when the core has detected a crash somehow.
This might activate gdb server
void avr_set_command_register | ( | avr_t * | avr, |
avr_io_addr_t | addr | ||
) |
Set an IO register to receive commands from the AVR firmware it's optional, and uses the ELF tags.
void avr_set_console_register | ( | avr_t * | avr, |
avr_io_addr_t | addr | ||
) |
Specify the "console register" – output sent to this register is printed on the simulator console, without using a UART.
void avr_terminate | ( | avr_t * | avr | ) |
Finish any pending operations.