/[gxemul]/upstream/0.4.4/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 /upstream/0.4.4/src/include/memory.h

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

revision 4 by dpavlin, Mon Oct 8 16:18:00 2007 UTC revision 20 by dpavlin, Mon Oct 8 16:19:23 2007 UTC
# Line 28  Line 28 
28   *  SUCH DAMAGE.   *  SUCH DAMAGE.
29   *   *
30   *   *
31   *  $Id: memory.h,v 1.29 2005/02/26 16:53:32 debug Exp $   *  $Id: memory.h,v 1.44 2005/11/22 16:26:38 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
44    
45  #define DEVICE_STATE_TYPE_INT           1  #define DEVICE_STATE_TYPE_INT           1
46  #define DEVICE_STATE_TYPE_UINT64_T      2  #define DEVICE_STATE_TYPE_UINT64_T      2
# Line 64  struct memory { Line 64  struct memory {
64    
65          const char      *dev_name[MAX_DEVICES];          const char      *dev_name[MAX_DEVICES];
66          uint64_t        dev_baseaddr[MAX_DEVICES];          uint64_t        dev_baseaddr[MAX_DEVICES];
67            uint64_t        dev_endaddr[MAX_DEVICES];       /*  after the end!  */
68          uint64_t        dev_length[MAX_DEVICES];          uint64_t        dev_length[MAX_DEVICES];
69          int             dev_flags[MAX_DEVICES];          int             dev_flags[MAX_DEVICES];
70          void            *dev_extra[MAX_DEVICES];          void            *dev_extra[MAX_DEVICES];
# Line 72  struct memory { Line 73  struct memory {
73          int             (*dev_f_state[MAX_DEVICES])(struct cpu *,          int             (*dev_f_state[MAX_DEVICES])(struct cpu *,
74                              struct memory *, void *extra, int wf, int nr,                              struct memory *, void *extra, int wf, int nr,
75                              int *type, char **namep, void **data, size_t *len);                              int *type, char **namep, void **data, size_t *len);
76          unsigned char   *dev_bintrans_data[MAX_DEVICES];          unsigned char   *dev_dyntrans_data[MAX_DEVICES];
77    
78            uint64_t        dev_dyntrans_write_low[MAX_DEVICES];
79            uint64_t        dev_dyntrans_write_high[MAX_DEVICES];
80    
81            int             dev_dyntrans_alignment;
82    
83  #ifdef BINTRANS  
84          uint64_t        dev_bintrans_write_low[MAX_DEVICES];          /*
85          uint64_t        dev_bintrans_write_high[MAX_DEVICES];           *  NOTE/TODO: This bintrans was for MIPS only. Ugly. :-/
86             */
87    
88          /*          /*
89           *  translation_code_chunk_space is a large chunk of (linear) memory           *  translation_code_chunk_space is a large chunk of (linear) memory
# Line 101  struct memory { Line 108  struct memory {
108          int             quick_jump_page_offset[MAX_QUICK_JUMPS];          int             quick_jump_page_offset[MAX_QUICK_JUMPS];
109          int             n_quick_jumps;          int             n_quick_jumps;
110          int             quick_jumps_index;          int             quick_jumps_index;
 #endif  
111  };  };
112    
113  #define BITS_PER_PAGETABLE      20  #define BITS_PER_PAGETABLE      20
114  #define BITS_PER_MEMBLOCK       20  #define BITS_PER_MEMBLOCK       20
115  #define MAX_BITS                40  #define MAX_BITS                40
116    
 #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                   8  
 #define PHYSICAL                        16  
   
117    
118  /*  memory.c:  */  /*  memory.c:  */
119    #define MEM_PCI_LITTLE_ENDIAN   128
120  uint64_t memory_readmax64(struct cpu *cpu, unsigned char *buf, int len);  uint64_t memory_readmax64(struct cpu *cpu, unsigned char *buf, int len);
121  void memory_writemax64(struct cpu *cpu, unsigned char *buf, int len,  void memory_writemax64(struct cpu *cpu, unsigned char *buf, int len,
122          uint64_t data);          uint64_t data);
123    
124  void *zeroed_alloc(size_t s);  void *zeroed_alloc(size_t s);
125    
126  struct memory *memory_new(uint64_t physical_max);  struct memory *memory_new(uint64_t physical_max, int arch);
127    
128  int memory_points_to_string(struct cpu *cpu, struct memory *mem,  int memory_points_to_string(struct cpu *cpu, struct memory *mem,
129          uint64_t addr, int min_string_length);          uint64_t addr, int min_string_length);
# Line 143  unsigned char *memory_paddr_to_hostaddr( Line 137  unsigned char *memory_paddr_to_hostaddr(
137  unsigned char *fast_vaddr_to_hostaddr(struct cpu *cpu, uint64_t vaddr,  unsigned char *fast_vaddr_to_hostaddr(struct cpu *cpu, uint64_t vaddr,
138          int writeflag);          int writeflag);
139    
140    /*  MIPS stuff:  */
141  int translate_address_mmu3k(struct cpu *cpu, uint64_t vaddr,  int translate_address_mmu3k(struct cpu *cpu, uint64_t vaddr,
142          uint64_t *return_addr, int flags);          uint64_t *return_addr, int flags);
143  int translate_address_mmu8k(struct cpu *cpu, uint64_t vaddr,  int translate_address_mmu8k(struct cpu *cpu, uint64_t vaddr,
# Line 154  int translate_address_mmu4100(struct cpu Line 149  int translate_address_mmu4100(struct cpu
149  int translate_address_generic(struct cpu *cpu, uint64_t vaddr,  int translate_address_generic(struct cpu *cpu, uint64_t vaddr,
150          uint64_t *return_addr, int flags);          uint64_t *return_addr, int flags);
151    
152    
153    /*  Writeflag:  */
154    #define MEM_READ                        0
155    #define MEM_WRITE                       1
156    #define MEM_DOWNGRADE                   128
157    
158    /*  Misc. flags:  */
159    #define CACHE_DATA                      0
160    #define CACHE_INSTRUCTION               1
161    #define CACHE_NONE                      2
162    #define CACHE_FLAGS_MASK                0x3
163    #define NO_EXCEPTIONS                   16
164    #define PHYSICAL                        32
165    #define NO_SEGMENTATION                 64      /*  for X86  */
166    #define MEMORY_USER_ACCESS              128     /*  for ARM, at least  */
167    
168    /*  Dyntrans Memory flags:  */
169    #define DM_DEFAULT                              0
170    #define DM_DYNTRANS_OK                          1
171    #define DM_DYNTRANS_WRITE_OK                    2
172    #define DM_READS_HAVE_NO_SIDE_EFFECTS           4
173    #define DM_EMULATED_RAM                         8
174    
175  #define FLAG_WRITEFLAG          1  #define FLAG_WRITEFLAG          1
176  #define FLAG_NOEXCEPTIONS       2  #define FLAG_NOEXCEPTIONS       2
177  #define FLAG_INSTR              4  #define FLAG_INSTR              4
178    
179  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,
180          unsigned char *data, size_t len, int writeflag, int cache);          unsigned char *data, size_t len, int writeflag, int cache);
181  #define MEMORY_ACCESS_FAILED    0  #define MEMORY_ACCESS_FAILED            0
182  #define MEMORY_ACCESS_OK        1  #define MEMORY_ACCESS_OK                1
183    #define MEMORY_ACCESS_OK_WRITE          2
184    #define MEMORY_NOT_FULL_PAGE            256
185    
186  void memory_device_bintrans_access(struct cpu *, struct memory *mem,  void memory_device_dyntrans_access(struct cpu *, struct memory *mem,
187          void *extra, uint64_t *low, uint64_t *high);          void *extra, uint64_t *low, uint64_t *high);
188    
189  void memory_device_register_statefunction(  void memory_device_register_statefunction(
# Line 175  void memory_device_register_statefunctio Line 195  void memory_device_register_statefunctio
195  void memory_device_register(struct memory *mem, const char *,  void memory_device_register(struct memory *mem, const char *,
196          uint64_t baseaddr, uint64_t len, int (*f)(struct cpu *,          uint64_t baseaddr, uint64_t len, int (*f)(struct cpu *,
197              struct memory *,uint64_t,unsigned char *,size_t,int,void *),              struct memory *,uint64_t,unsigned char *,size_t,int,void *),
198          void *extra, int flags, unsigned char *bintrans_data);          void *extra, int flags, unsigned char *dyntrans_data);
199  void memory_device_remove(struct memory *mem, int i);  void memory_device_remove(struct memory *mem, int i);
200    
 #define MEM_DEFAULT                     0  
 #define MEM_BINTRANS_OK                 1  
 #define MEM_BINTRANS_WRITE_OK           2  
   
   
201  #endif  /*  MEMORY_H  */  #endif  /*  MEMORY_H  */

Legend:
Removed from v.4  
changed lines
  Added in v.20

  ViewVC Help
Powered by ViewVC 1.1.26