Dunno how these came to be..
Signed-off-by: Michel Pollet <buserror@gmail.com>
void
avr_global_logger(
- struct avr_t* avr,
- const int level,
- const char * format,
+ struct avr_t* avr,
+ const int level,
+ const char * format,
... )
{
va_list args;
va_start(args, format);
if (_avr_global_logger)
_avr_global_logger(avr, level, format, args);
- va_end(args);
+ va_end(args);
}
void
#ifdef CONFIG_SIMAVR_TRACE
avr->trace_data = calloc(1, sizeof(struct avr_trace_data_t));
#endif
-
+
AVR_LOG(avr, LOG_TRACE, "%s init\n", avr->mmcu);
// cpu is in limbo before init is finished.
// number of address bytes to push/pull on/off the stack
avr->address_size = avr->eind ? 3 : 2;
avr->log = 1;
- avr_reset(avr);
+ avr_reset(avr);
return 0;
}
// enable gdb server, and wait
if (!avr->gdb)
avr_gdb_init(avr);
- }
+ }
if (!avr->gdb)
avr->state = cpu_Crashed;
}
* a minimum count of requested sleep microseconds are reached
* (low amounts cannot be handled accurately).
*/
-uint32_t
+uint32_t
avr_pending_sleep_usec(
- avr_t * avr,
+ avr_t * avr,
avr_cycle_count_t howLong)
{
avr->sleep_usec += avr_cycles_to_usec(avr, howLong);
int step = avr->state == cpu_Step;
if (step)
avr->state = cpu_Running;
-
+
avr_flashaddr_t new_pc = avr->pc;
if (avr->state == cpu_Running) {
// Interrupt servicing might change the PC too, during 'sleep'
if (avr->state == cpu_Running || avr->state == cpu_Sleeping)
avr_service_interrupts(avr);
-
+
// if we were stepping, use this state to inform remote gdb
if (step)
avr->state = cpu_StepDone;
// code that munches the stack -under- their own frame
struct {
uint32_t pc;
- uint16_t sp;
+ uint16_t sp;
} stack_frame[STACK_FRAME_SIZE];
int stack_frame_index;
#endif
typedef struct avr_t {
const char * mmcu; // name of the AVR
// these are filled by sim_core_declare from constants in /usr/lib/avr/include/avr/io*.h
- uint16_t ramend;
+ uint16_t ramend;
uint32_t flashend;
uint32_t e2end;
uint8_t vector_size;
avr_io_addr_t rampz; // optional, only for ELPM/SPM on >64Kb cores
avr_io_addr_t eind; // optional, only for EIJMP/EICALL on >64Kb cores
uint8_t address_size; // 2, or 3 for cores >128KB in flash
-
+
// filled by the ELF data, this allow tracking of invalid jumps
uint32_t codeend;
>0: interrupt pending */
int8_t interrupt_state; // interrupt state
- /*
+ /*
* ** current PC **
* Note that the PC is representing /bytes/ while the AVR value is
* assumed to be "words". This is in line with what GDB does...
// DEBUG ONLY -- value ignored if CONFIG_SIMAVR_TRACE = 0
uint8_t trace : 1,
log : 2; // log level, default to 1
-
+
// Only used if CONFIG_SIMAVR_TRACE is defined
struct avr_trace_data_t *trace_data;
// VALUE CHANGE DUMP file (waveforms)
- // this is the VCD file that gets allocated if the
+ // this is the VCD file that gets allocated if the
// firmware that is loaded explicitly asks for a trace
// to be generated, and allocates it's own symbols
// using AVR_MMCU_TAG_VCD_TRACE (see avr_mcu_section.h)
struct avr_vcd_t * vcd;
-
+
// gdb hooking structure. Only present when gdb server is active
struct avr_gdb_t * gdb;
int
avr_run(
avr_t * avr);
-// finish any pending operations
+// finish any pending operations
void
avr_terminate(
avr_t * avr);
*/
void
avr_global_logger(
- struct avr_t* avr,
- const int level,
- const char * format,
+ struct avr_t* avr,
+ const int level,
+ const char * format,
... );
#ifndef AVR_CORE
* (low amounts cannot be handled accurately).
* This function is an utility function for the sleep callbacks
*/
-uint32_t
+uint32_t
avr_pending_sleep_usec(
- avr_t * avr,
+ avr_t * avr,
avr_cycle_count_t howLong);
#ifdef __cplusplus
stderr = stdout; \
} }
#endif
-
+
static void atexit_handler(void) {
if (!finished)
_fail(NULL, 0, "Test exit without indicating success.");
// Interrupt servicing might change the PC too, during 'sleep'
if (avr->state == cpu_Running || avr->state == cpu_Sleeping)
avr_service_interrupts(avr);
-
+
// if we were stepping, use this state to inform remote gdb
return avr->state;
avr_t *tests_init_avr(const char *elfname) {
tests_cycle_count = 0;
map_stderr();
-
+
elf_firmware_t fw;
if (elf_read_firmware(elfname, &fw))
fail("Failed to read ELF firmware \"%s\"", elfname);
return reason;
}
fail("Error in test case: Should never reach this.");
- return 0;
+ return 0;
}
int tests_init_and_run_test(const char *elfname, unsigned long run_usec) {