/[gxemul]/trunk/src/include/memory.h
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/include/memory.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 6 by dpavlin, Mon Oct 8 16:18:11 2007 UTC revision 22 by dpavlin, Mon Oct 8 16:19:37 2007 UTC
# Line 28  Line 28 
28   *  SUCH DAMAGE.   *  SUCH DAMAGE.
29   *   *
30   *   *
31   *  $Id: memory.h,v 1.32 2005/05/23 14:22:03 debug Exp $   *  $Id: memory.h,v 1.47 2006/01/01 13:17:18 debug Exp $
32   *   *
33   *  Memory controller related functions.   *  Memory controller related functions.
34   */   */
# Line 40  Line 40 
40    
41    
42  #define DEFAULT_RAM_IN_MB               32  #define DEFAULT_RAM_IN_MB               32
43  #define MAX_DEVICES                     24  #define MAX_DEVICES                     26
   
 #define DEVICE_STATE_TYPE_INT           1  
 #define DEVICE_STATE_TYPE_UINT64_T      2  
44    
45  struct cpu;  struct cpu;
46  struct translation_page_entry;  struct translation_page_entry;
# Line 64  struct memory { Line 61  struct memory {
61    
62          const char      *dev_name[MAX_DEVICES];          const char      *dev_name[MAX_DEVICES];
63          uint64_t        dev_baseaddr[MAX_DEVICES];          uint64_t        dev_baseaddr[MAX_DEVICES];
64            uint64_t        dev_endaddr[MAX_DEVICES];       /*  after the end!  */
65          uint64_t        dev_length[MAX_DEVICES];          uint64_t        dev_length[MAX_DEVICES];
66          int             dev_flags[MAX_DEVICES];          int             dev_flags[MAX_DEVICES];
67          void            *dev_extra[MAX_DEVICES];          void            *dev_extra[MAX_DEVICES];
68          int             (*dev_f[MAX_DEVICES])(struct cpu *,struct memory *,          int             (*dev_f[MAX_DEVICES])(struct cpu *,struct memory *,
69                              uint64_t,unsigned char *,size_t,int,void *);                              uint64_t,unsigned char *,size_t,int,void *);
70          int             (*dev_f_state[MAX_DEVICES])(struct cpu *,          unsigned char   *dev_dyntrans_data[MAX_DEVICES];
71                              struct memory *, void *extra, int wf, int nr,  
72                              int *type, char **namep, void **data, size_t *len);          uint64_t        dev_dyntrans_write_low[MAX_DEVICES];
73          unsigned char   *dev_bintrans_data[MAX_DEVICES];          uint64_t        dev_dyntrans_write_high[MAX_DEVICES];
74    
75  #ifdef BINTRANS          int             dev_dyntrans_alignment;
76          uint64_t        dev_bintrans_write_low[MAX_DEVICES];  
77          uint64_t        dev_bintrans_write_high[MAX_DEVICES];  
78            /*
79             *  NOTE/TODO: This bintrans was for MIPS only. Ugly. :-/
80             */
81    
82          /*          /*
83           *  translation_code_chunk_space is a large chunk of (linear) memory           *  translation_code_chunk_space is a large chunk of (linear) memory
# Line 98  struct memory { Line 99  struct memory {
99          struct translation_page_entry **translation_page_entry_array;          struct translation_page_entry **translation_page_entry_array;
100    
101          unsigned char   *quick_jump_host_address[MAX_QUICK_JUMPS];          unsigned char   *quick_jump_host_address[MAX_QUICK_JUMPS];
102          int             quick_jump_page_offset[MAX_QUICK_JUMPS];          size_t          quick_jump_page_offset[MAX_QUICK_JUMPS];
103          int             n_quick_jumps;          int             n_quick_jumps;
104          int             quick_jumps_index;          int             quick_jumps_index;
 #endif  
105  };  };
106    
107  #define BITS_PER_PAGETABLE      20  #define BITS_PER_PAGETABLE      20
108  #define BITS_PER_MEMBLOCK       20  #define BITS_PER_MEMBLOCK       20
109  #define MAX_BITS                40  #define MAX_BITS                40
110    
 #define MEM_READ                        0  
 #define MEM_WRITE                       1  
   
   
 #define CACHE_DATA                      0  
 #define CACHE_INSTRUCTION               1  
 #define CACHE_NONE                      2  
   
 #define CACHE_FLAGS_MASK                0x3  
   
 #define NO_EXCEPTIONS                   16  
 #define PHYSICAL                        32  
 #define NO_SEGMENTATION                 64      /*  for X86  */  
   
111    
112  /*  memory.c:  */  /*  memory.c:  */
113    #define MEM_PCI_LITTLE_ENDIAN   128
114  uint64_t memory_readmax64(struct cpu *cpu, unsigned char *buf, int len);  uint64_t memory_readmax64(struct cpu *cpu, unsigned char *buf, int len);
115  void memory_writemax64(struct cpu *cpu, unsigned char *buf, int len,  void memory_writemax64(struct cpu *cpu, unsigned char *buf, int len,
116          uint64_t data);          uint64_t data);
117    
118  void *zeroed_alloc(size_t s);  void *zeroed_alloc(size_t s);
119    
120  struct memory *memory_new(uint64_t physical_max);  struct memory *memory_new(uint64_t physical_max, int arch);
121    
122  int memory_points_to_string(struct cpu *cpu, struct memory *mem,  int memory_points_to_string(struct cpu *cpu, struct memory *mem,
123          uint64_t addr, int min_string_length);          uint64_t addr, int min_string_length);
# Line 156  int translate_address_mmu4100(struct cpu Line 143  int translate_address_mmu4100(struct cpu
143  int translate_address_generic(struct cpu *cpu, uint64_t vaddr,  int translate_address_generic(struct cpu *cpu, uint64_t vaddr,
144          uint64_t *return_addr, int flags);          uint64_t *return_addr, int flags);
145    
 /*  X86 stuff:  */  
 int translate_address_x86(struct cpu *cpu, uint64_t vaddr,  
         uint64_t *return_addr, int flags);  
146    
147    /*  Writeflag:  */
148    #define MEM_READ                        0
149    #define MEM_WRITE                       1
150    #define MEM_DOWNGRADE                   128
151    
152    /*  Misc. flags:  */
153    #define CACHE_DATA                      0
154    #define CACHE_INSTRUCTION               1
155    #define CACHE_NONE                      2
156    #define CACHE_FLAGS_MASK                0x3
157    #define NO_EXCEPTIONS                   16
158    #define PHYSICAL                        32
159    #define NO_SEGMENTATION                 64      /*  for X86  */
160    #define MEMORY_USER_ACCESS              128     /*  for ARM, at least  */
161    
162    /*  Dyntrans Memory flags:  */
163    #define DM_DEFAULT                              0
164    #define DM_DYNTRANS_OK                          1
165    #define DM_DYNTRANS_WRITE_OK                    2
166    #define DM_READS_HAVE_NO_SIDE_EFFECTS           4
167    #define DM_EMULATED_RAM                         8
168    
169  #define FLAG_WRITEFLAG          1  #define FLAG_WRITEFLAG          1
170  #define FLAG_NOEXCEPTIONS       2  #define FLAG_NOEXCEPTIONS       2
# Line 167  int translate_address_x86(struct cpu *cp Line 172  int translate_address_x86(struct cpu *cp
172    
173  int userland_memory_rw(struct cpu *cpu, struct memory *mem, uint64_t vaddr,  int userland_memory_rw(struct cpu *cpu, struct memory *mem, uint64_t vaddr,
174          unsigned char *data, size_t len, int writeflag, int cache);          unsigned char *data, size_t len, int writeflag, int cache);
175  #define MEMORY_ACCESS_FAILED    0  #define MEMORY_ACCESS_FAILED            0
176  #define MEMORY_ACCESS_OK        1  #define MEMORY_ACCESS_OK                1
177    #define MEMORY_ACCESS_OK_WRITE          2
178    #define MEMORY_NOT_FULL_PAGE            256
179    
180  void memory_device_bintrans_access(struct cpu *, struct memory *mem,  void memory_device_dyntrans_access(struct cpu *, struct memory *mem,
181          void *extra, uint64_t *low, uint64_t *high);          void *extra, uint64_t *low, uint64_t *high);
182    
183  void memory_device_register_statefunction(  #define DEVICE_ACCESS(x)        int dev_ ## x ## _access(struct cpu *cpu, \
184          struct memory *mem, void *extra,          struct memory *mem, uint64_t relative_addr, unsigned char *data,  \
185          int (*dev_f_state)(struct cpu *,          size_t len, int writeflag, void *extra)
             struct memory *, void *extra, int wf, int nr,  
             int *type, char **namep, void **data, size_t *len));  
186    
187  void memory_device_register(struct memory *mem, const char *,  void memory_device_register(struct memory *mem, const char *,
188          uint64_t baseaddr, uint64_t len, int (*f)(struct cpu *,          uint64_t baseaddr, uint64_t len, int (*f)(struct cpu *,
189              struct memory *,uint64_t,unsigned char *,size_t,int,void *),              struct memory *,uint64_t,unsigned char *,size_t,int,void *),
190          void *extra, int flags, unsigned char *bintrans_data);          void *extra, int flags, unsigned char *dyntrans_data);
191  void memory_device_remove(struct memory *mem, int i);  void memory_device_remove(struct memory *mem, int i);
192    
 /*  Bit flags:  */  
 #define MEM_DEFAULT                             0  
 #define MEM_BINTRANS_OK                         1  
 #define MEM_BINTRANS_WRITE_OK                   2  
 #define MEM_READING_HAS_NO_SIDE_EFFECTS         4  
   
   
193  #endif  /*  MEMORY_H  */  #endif  /*  MEMORY_H  */

Legend:
Removed from v.6  
changed lines
  Added in v.22

  ViewVC Help
Powered by ViewVC 1.1.26