X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=simavr%2Fsim%2Fsim_avr.h;h=737b3ce9bc1862619f49c87e0d66d3efe4570372;hb=33cb87d48ecd68f2000d02659bb3752a329274c8;hp=a91c2b98b35ec1cfcc1471fb288d1ae7b584a1f4;hpb=cb7f2424856ade2162aa361ee980a993300ec397;p=simavr diff --git a/simavr/sim/sim_avr.h b/simavr/sim/sim_avr.h index a91c2b9..737b3ce 100644 --- a/simavr/sim/sim_avr.h +++ b/simavr/sim/sim_avr.h @@ -27,8 +27,11 @@ extern "C" { #endif #include "sim_irq.h" +#include "sim_interrupts.h" #include "sim_cycle_timers.h" +typedef uint32_t avr_flashaddr_t; + struct avr_t; typedef uint8_t (*avr_io_read_t)( struct avr_t * avr, @@ -52,7 +55,7 @@ enum { R_SREG = 32+0x3f, // maximum number of IO registers, on normal AVRs - MAX_IOs = 256 - 32, // minus 32 GP registers + MAX_IOs = 279, // Bigger AVRs need more than 256-32 (mega1280) }; #define AVR_DATA_TO_IO(v) ((v) - 32) @@ -136,12 +139,19 @@ typedef struct avr_t { // not only to "cycles that runs" but also "cycles that might have run" // like, sleeping. avr_cycle_count_t cycle; // current cycle + + /** + * Sleep requests are accumulated in sleep_usec until the minimum sleep value + * is reached, at which point sleep_usec is cleared and the sleep request + * is passed on to the operating system. + */ + uint32_t sleep_usec; // called at init time void (*init)(struct avr_t * avr); // called at init time (for special purposes like using a memory mapped file as flash see: simduino) void (*special_init)(struct avr_t * avr); - // called at termination time ( to clean special initalizations) + // called at termination time ( to clean special initializations) void (*special_deinit)(struct avr_t * avr); // called at reset time void (*reset)(struct avr_t * avr); @@ -169,7 +179,7 @@ typedef struct avr_t { // Mirror of the SREG register, to facilitate the access to bits // in the opcode decoder. - // This array is re-synthetized back/forth when SREG changes + // This array is re-synthesized back/forth when SREG changes uint8_t sreg[8]; uint8_t i_shadow; // used to detect edges on I flag @@ -180,7 +190,7 @@ typedef struct avr_t { * this is why you will see >>1 and <<1 in the decoder to handle jumps. * It CAN be a little confusing, so concentrate, young grasshopper. */ - uint32_t pc; + avr_flashaddr_t pc; /* * callback when specific IO registers are read/written. @@ -229,17 +239,13 @@ typedef struct avr_t { // queue of io modules struct avr_io_t *io_port; + // cycle timers tracking & delivery avr_cycle_timer_pool_t cycle_timers; - - // interrupt vectors, and their enable/clear registers - struct avr_int_vector_t * vector[64]; - uint8_t vector_count; - uint8_t pending_wait; // number of cycles to wait for pending - struct avr_int_vector_t * pending[64]; // needs to be >= vectors and a power of two - uint8_t pending_w, pending_r; // fifo cursors + // interrupt vectors and delivery fifo + avr_int_table_t interrupts; // DEBUG ONLY -- value ignored if CONFIG_SIMAVR_TRACE = 0 - int trace : 1, + uint8_t trace : 1, log : 2; // log level, default to 1 // Only used if CONFIG_SIMAVR_TRACE is defined @@ -282,6 +288,12 @@ avr_make_mcu_by_name( int avr_init( avr_t * avr); +// Used by the cores, allocated a mutable avr_t from the const global +avr_t * +avr_core_allocate( + const avr_t * core, + uint32_t coreLen); + // resets the AVR, and the IO modules void avr_reset( @@ -315,10 +327,10 @@ avr_loadcode( avr_t * avr, uint8_t * code, uint32_t size, - uint32_t address); + avr_flashaddr_t address); /* - * these are accessors for avr->data but allows watchpoints to be set for gdb + * 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. */ @@ -341,7 +353,7 @@ avr_sadly_crashed( /* - * These are callbacks for the two 'main' bahaviour in simavr + * These are callbacks for the two 'main' behaviour in simavr */ void avr_callback_sleep_gdb(avr_t * avr, avr_cycle_count_t howLong); void avr_callback_run_gdb(avr_t * avr); @@ -354,8 +366,6 @@ void avr_callback_run_raw(avr_t * avr); #include "sim_io.h" #include "sim_regbit.h" -#include "sim_interrupts.h" -#include "sim_cycle_timers.h" #endif /*__SIM_AVR_H__*/