--- trunk/src/include/memory.h 2007/10/08 16:19:56 24 +++ trunk/src/include/memory.h 2007/10/08 16:20:58 32 @@ -28,9 +28,9 @@ * SUCH DAMAGE. * * - * $Id: memory.h,v 1.49 2006/06/16 18:31:26 debug Exp $ + * $Id: memory.h,v 1.52 2006/09/01 15:42:59 debug Exp $ * - * Memory controller related functions. + * Memory related functions. */ #include @@ -40,15 +40,46 @@ #define DEFAULT_RAM_IN_MB 32 -#define MAX_DEVICES 26 struct cpu; -struct translation_page_entry; + +/* + * Memory mapped device + */ +struct memory_device { + uint64_t baseaddr; + uint64_t endaddr; /* NOTE: after the last byte! */ + uint64_t length; + int flags; + + const char *name; + + int (*f)(struct cpu *,struct memory *, + uint64_t,unsigned char *,size_t,int,void *); + void *extra; + + unsigned char *dyntrans_data; + + uint64_t dyntrans_write_low; + uint64_t dyntrans_write_high; +}; + + +/* + * Memory + * ------ + * + * This struct defines a memory object. Most machines only use one memory + * object (the main memory), but if necessary, multiple memories can be + * used. + */ struct memory { uint64_t physical_max; void *pagetable; + int dev_dyntrans_alignment; + int n_mmapped_devices; int last_accessed_device; /* The following two might speed up things a little bit. */ @@ -56,20 +87,7 @@ uint64_t mmap_dev_minaddr; uint64_t mmap_dev_maxaddr; - const char *dev_name[MAX_DEVICES]; - uint64_t dev_baseaddr[MAX_DEVICES]; - uint64_t dev_endaddr[MAX_DEVICES]; /* after the end! */ - uint64_t dev_length[MAX_DEVICES]; - int dev_flags[MAX_DEVICES]; - void *dev_extra[MAX_DEVICES]; - int (*dev_f[MAX_DEVICES])(struct cpu *,struct memory *, - uint64_t,unsigned char *,size_t,int,void *); - unsigned char *dev_dyntrans_data[MAX_DEVICES]; - - uint64_t dev_dyntrans_write_low[MAX_DEVICES]; - uint64_t dev_dyntrans_write_high[MAX_DEVICES]; - - int dev_dyntrans_alignment; + struct memory_device *devices; }; #define BITS_PER_PAGETABLE 20 @@ -95,22 +113,6 @@ unsigned char *memory_paddr_to_hostaddr(struct memory *mem, uint64_t paddr, int writeflag); -/* memory_fast_v2h.c: */ -unsigned char *fast_vaddr_to_hostaddr(struct cpu *cpu, uint64_t vaddr, - int writeflag); - -/* MIPS stuff: */ -int translate_address_mmu3k(struct cpu *cpu, uint64_t vaddr, - uint64_t *return_addr, int flags); -int translate_address_mmu8k(struct cpu *cpu, uint64_t vaddr, - uint64_t *return_addr, int flags); -int translate_address_mmu10k(struct cpu *cpu, uint64_t vaddr, - uint64_t *return_addr, int flags); -int translate_address_mmu4100(struct cpu *cpu, uint64_t vaddr, - uint64_t *return_addr, int flags); -int translate_address_generic(struct cpu *cpu, uint64_t vaddr, - uint64_t *return_addr, int flags); - /* Writeflag: */ #define MEM_READ 0 @@ -152,6 +154,9 @@ struct memory *mem, uint64_t relative_addr, unsigned char *data, \ size_t len, int writeflag, void *extra) +void memory_device_update_data(struct memory *mem, void *extra, + unsigned char *data); + void memory_device_register(struct memory *mem, const char *, uint64_t baseaddr, uint64_t len, int (*f)(struct cpu *, struct memory *,uint64_t,unsigned char *,size_t,int,void *),