28 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
29 |
* |
* |
30 |
* |
* |
31 |
* $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 $ |
32 |
* |
* |
33 |
* Memory controller related functions. |
* Memory related functions. |
34 |
*/ |
*/ |
35 |
|
|
36 |
#include <sys/types.h> |
#include <sys/types.h> |
40 |
|
|
41 |
|
|
42 |
#define DEFAULT_RAM_IN_MB 32 |
#define DEFAULT_RAM_IN_MB 32 |
|
#define MAX_DEVICES 26 |
|
43 |
|
|
44 |
struct cpu; |
struct cpu; |
|
struct translation_page_entry; |
|
45 |
|
|
46 |
|
|
47 |
|
/* |
48 |
|
* Memory mapped device |
49 |
|
*/ |
50 |
|
struct memory_device { |
51 |
|
uint64_t baseaddr; |
52 |
|
uint64_t endaddr; /* NOTE: after the last byte! */ |
53 |
|
uint64_t length; |
54 |
|
int flags; |
55 |
|
|
56 |
|
const char *name; |
57 |
|
|
58 |
|
int (*f)(struct cpu *,struct memory *, |
59 |
|
uint64_t,unsigned char *,size_t,int,void *); |
60 |
|
void *extra; |
61 |
|
|
62 |
|
unsigned char *dyntrans_data; |
63 |
|
|
64 |
|
uint64_t dyntrans_write_low; |
65 |
|
uint64_t dyntrans_write_high; |
66 |
|
}; |
67 |
|
|
68 |
|
|
69 |
|
/* |
70 |
|
* Memory |
71 |
|
* ------ |
72 |
|
* |
73 |
|
* This struct defines a memory object. Most machines only use one memory |
74 |
|
* object (the main memory), but if necessary, multiple memories can be |
75 |
|
* used. |
76 |
|
*/ |
77 |
struct memory { |
struct memory { |
78 |
uint64_t physical_max; |
uint64_t physical_max; |
79 |
void *pagetable; |
void *pagetable; |
80 |
|
|
81 |
|
int dev_dyntrans_alignment; |
82 |
|
|
83 |
int n_mmapped_devices; |
int n_mmapped_devices; |
84 |
int last_accessed_device; |
int last_accessed_device; |
85 |
/* The following two might speed up things a little bit. */ |
/* The following two might speed up things a little bit. */ |
87 |
uint64_t mmap_dev_minaddr; |
uint64_t mmap_dev_minaddr; |
88 |
uint64_t mmap_dev_maxaddr; |
uint64_t mmap_dev_maxaddr; |
89 |
|
|
90 |
const char *dev_name[MAX_DEVICES]; |
struct memory_device *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; |
|
91 |
}; |
}; |
92 |
|
|
93 |
#define BITS_PER_PAGETABLE 20 |
#define BITS_PER_PAGETABLE 20 |
113 |
unsigned char *memory_paddr_to_hostaddr(struct memory *mem, |
unsigned char *memory_paddr_to_hostaddr(struct memory *mem, |
114 |
uint64_t paddr, int writeflag); |
uint64_t paddr, int writeflag); |
115 |
|
|
|
/* 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); |
|
|
|
|
116 |
|
|
117 |
/* Writeflag: */ |
/* Writeflag: */ |
118 |
#define MEM_READ 0 |
#define MEM_READ 0 |
154 |
struct memory *mem, uint64_t relative_addr, unsigned char *data, \ |
struct memory *mem, uint64_t relative_addr, unsigned char *data, \ |
155 |
size_t len, int writeflag, void *extra) |
size_t len, int writeflag, void *extra) |
156 |
|
|
157 |
|
void memory_device_update_data(struct memory *mem, void *extra, |
158 |
|
unsigned char *data); |
159 |
|
|
160 |
void memory_device_register(struct memory *mem, const char *, |
void memory_device_register(struct memory *mem, const char *, |
161 |
uint64_t baseaddr, uint64_t len, int (*f)(struct cpu *, |
uint64_t baseaddr, uint64_t len, int (*f)(struct cpu *, |
162 |
struct memory *,uint64_t,unsigned char *,size_t,int,void *), |
struct memory *,uint64_t,unsigned char *,size_t,int,void *), |