#ifndef SIM_CORE_H
#define SIM_CORE_H
typedef enum {
sim_core_unmapped_signal,
sim_core_unaligned_signal,
nr_sim_core_signals,
} sim_core_signals;
typedef void (SIM_CORE_SIGNAL_FN)
(SIM_DESC sd, sim_cpu *cpu, sim_cia cia, unsigned map, int nr_bytes,
address_word addr, transfer_type transfer, sim_core_signals sig);
extern SIM_CORE_SIGNAL_FN sim_core_signal;
typedef struct _sim_core_mapping sim_core_mapping;
struct _sim_core_mapping {
int level;
int space;
unsigned_word base;
unsigned_word bound;
unsigned_word nr_bytes;
unsigned mask;
void *free_buffer;
void *buffer;
#if (WITH_HW)
struct hw *device;
#else
device *device;
#endif
int trace;
sim_core_mapping *next;
};
typedef struct _sim_core_map sim_core_map;
struct _sim_core_map {
sim_core_mapping *first;
};
typedef struct _sim_core_common {
sim_core_map map[nr_maps];
} sim_core_common;
typedef struct _sim_core sim_core;
struct _sim_core {
sim_core_common common;
address_word byte_xor;
};
typedef struct _sim_cpu_core {
sim_core_common common;
address_word xor[WITH_XOR_ENDIAN + 1];
} sim_cpu_core;
extern SIM_RC sim_core_install (SIM_DESC sd);
extern void sim_core_attach
(SIM_DESC sd,
sim_cpu *cpu,
int level,
unsigned mapmask,
int address_space,
address_word addr,
address_word nr_bytes,
unsigned modulo,
#if (WITH_HW)
struct hw *client,
#else
device *client,
#endif
void *optional_buffer);
extern void sim_core_detach
(SIM_DESC sd,
sim_cpu *cpu,
int level,
int address_space,
address_word addr);
extern unsigned sim_core_read_buffer
(SIM_DESC sd,
sim_cpu *cpu,
unsigned map,
void *buffer,
address_word addr,
unsigned nr_bytes);
extern unsigned sim_core_write_buffer
(SIM_DESC sd,
sim_cpu *cpu,
unsigned map,
const void *buffer,
address_word addr,
unsigned nr_bytes);
extern void sim_core_set_xor
(SIM_DESC sd,
sim_cpu *cpu,
int is_xor);
extern unsigned sim_core_xor_read_buffer
(SIM_DESC sd,
sim_cpu *cpu,
unsigned map,
void *buffer,
address_word addr,
unsigned nr_bytes);
extern unsigned sim_core_xor_write_buffer
(SIM_DESC sd,
sim_cpu *cpu,
unsigned map,
const void *buffer,
address_word addr,
unsigned nr_bytes);
#define DECLARE_SIM_CORE_WRITE_N(ALIGNMENT,N,M) \
INLINE_SIM_CORE\
(void) sim_core_write_##ALIGNMENT##_##N \
(sim_cpu *cpu, \
sim_cia cia, \
unsigned map, \
address_word addr, \
unsigned_##M val);
DECLARE_SIM_CORE_WRITE_N(aligned,1,1)
DECLARE_SIM_CORE_WRITE_N(aligned,2,2)
DECLARE_SIM_CORE_WRITE_N(aligned,4,4)
DECLARE_SIM_CORE_WRITE_N(aligned,8,8)
DECLARE_SIM_CORE_WRITE_N(aligned,16,16)
#define sim_core_write_unaligned_1 sim_core_write_aligned_1
DECLARE_SIM_CORE_WRITE_N(unaligned,2,2)
DECLARE_SIM_CORE_WRITE_N(unaligned,4,4)
DECLARE_SIM_CORE_WRITE_N(unaligned,8,8)
DECLARE_SIM_CORE_WRITE_N(unaligned,16,16)
DECLARE_SIM_CORE_WRITE_N(misaligned,3,4)
DECLARE_SIM_CORE_WRITE_N(misaligned,5,8)
DECLARE_SIM_CORE_WRITE_N(misaligned,6,8)
DECLARE_SIM_CORE_WRITE_N(misaligned,7,8)
#define sim_core_write_1 sim_core_write_aligned_1
#define sim_core_write_2 sim_core_write_aligned_2
#define sim_core_write_4 sim_core_write_aligned_4
#define sim_core_write_8 sim_core_write_aligned_8
#define sim_core_write_16 sim_core_write_aligned_16
#define sim_core_write_unaligned_word XCONCAT2(sim_core_write_unaligned_,WITH_TARGET_WORD_BITSIZE)
#define sim_core_write_aligned_word XCONCAT2(sim_core_write_aligned_,WITH_TARGET_WORD_BITSIZE)
#define sim_core_write_word XCONCAT2(sim_core_write_,WITH_TARGET_WORD_BITSIZE)
#undef DECLARE_SIM_CORE_WRITE_N
#define DECLARE_SIM_CORE_READ_N(ALIGNMENT,N,M) \
INLINE_SIM_CORE\
(unsigned_##M) sim_core_read_##ALIGNMENT##_##N \
(sim_cpu *cpu, \
sim_cia cia, \
unsigned map, \
address_word addr);
DECLARE_SIM_CORE_READ_N(aligned,1,1)
DECLARE_SIM_CORE_READ_N(aligned,2,2)
DECLARE_SIM_CORE_READ_N(aligned,4,4)
DECLARE_SIM_CORE_READ_N(aligned,8,8)
DECLARE_SIM_CORE_READ_N(aligned,16,16)
#define sim_core_read_unaligned_1 sim_core_read_aligned_1
DECLARE_SIM_CORE_READ_N(unaligned,2,2)
DECLARE_SIM_CORE_READ_N(unaligned,4,4)
DECLARE_SIM_CORE_READ_N(unaligned,8,8)
DECLARE_SIM_CORE_READ_N(unaligned,16,16)
DECLARE_SIM_CORE_READ_N(misaligned,3,4)
DECLARE_SIM_CORE_READ_N(misaligned,5,8)
DECLARE_SIM_CORE_READ_N(misaligned,6,8)
DECLARE_SIM_CORE_READ_N(misaligned,7,8)
#define sim_core_read_1 sim_core_read_aligned_1
#define sim_core_read_2 sim_core_read_aligned_2
#define sim_core_read_4 sim_core_read_aligned_4
#define sim_core_read_8 sim_core_read_aligned_8
#define sim_core_read_16 sim_core_read_aligned_16
#define sim_core_read_unaligned_word XCONCAT2(sim_core_read_unaligned_,WITH_TARGET_WORD_BITSIZE)
#define sim_core_read_aligned_word XCONCAT2(sim_core_read_aligned_,WITH_TARGET_WORD_BITSIZE)
#define sim_core_read_word XCONCAT2(sim_core_read_,WITH_TARGET_WORD_BITSIZE)
#undef DECLARE_SIM_CORE_READ_N
#if (WITH_DEVICES)
void device_error (device *me, char* message, ...);
int device_io_read_buffer(device *me, void *dest, int space, address_word addr, unsigned nr_bytes, SIM_DESC sd, sim_cpu *processor, sim_cia cia);
int device_io_write_buffer(device *me, const void *source, int space, address_word addr, unsigned nr_bytes, SIM_DESC sd, sim_cpu *processor, sim_cia cia);
#endif
#endif