2 |
#define MEMORY_H |
#define MEMORY_H |
3 |
|
|
4 |
/* |
/* |
5 |
* Copyright (C) 2004-2005 Anders Gavare. All rights reserved. |
* Copyright (C) 2004-2006 Anders Gavare. All rights reserved. |
6 |
* |
* |
7 |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
8 |
* modification, are permitted provided that the following conditions are met: |
* modification, are permitted provided that the following conditions are met: |
28 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
29 |
* |
* |
30 |
* |
* |
31 |
* $Id: memory.h,v 1.44 2005/11/22 16:26:38 debug Exp $ |
* $Id: memory.h,v 1.49 2006/06/16 18:31:26 debug Exp $ |
32 |
* |
* |
33 |
* Memory controller related functions. |
* Memory controller related functions. |
34 |
*/ |
*/ |
42 |
#define DEFAULT_RAM_IN_MB 32 |
#define DEFAULT_RAM_IN_MB 32 |
43 |
#define MAX_DEVICES 26 |
#define MAX_DEVICES 26 |
44 |
|
|
|
#define DEVICE_STATE_TYPE_INT 1 |
|
|
#define DEVICE_STATE_TYPE_UINT64_T 2 |
|
|
|
|
45 |
struct cpu; |
struct cpu; |
46 |
struct translation_page_entry; |
struct translation_page_entry; |
47 |
|
|
|
/* For bintrans: */ |
|
|
#define MAX_QUICK_JUMPS 8 |
|
|
|
|
48 |
struct memory { |
struct memory { |
49 |
uint64_t physical_max; |
uint64_t physical_max; |
50 |
void *pagetable; |
void *pagetable; |
64 |
void *dev_extra[MAX_DEVICES]; |
void *dev_extra[MAX_DEVICES]; |
65 |
int (*dev_f[MAX_DEVICES])(struct cpu *,struct memory *, |
int (*dev_f[MAX_DEVICES])(struct cpu *,struct memory *, |
66 |
uint64_t,unsigned char *,size_t,int,void *); |
uint64_t,unsigned char *,size_t,int,void *); |
|
int (*dev_f_state[MAX_DEVICES])(struct cpu *, |
|
|
struct memory *, void *extra, int wf, int nr, |
|
|
int *type, char **namep, void **data, size_t *len); |
|
67 |
unsigned char *dev_dyntrans_data[MAX_DEVICES]; |
unsigned char *dev_dyntrans_data[MAX_DEVICES]; |
68 |
|
|
69 |
uint64_t dev_dyntrans_write_low[MAX_DEVICES]; |
uint64_t dev_dyntrans_write_low[MAX_DEVICES]; |
70 |
uint64_t dev_dyntrans_write_high[MAX_DEVICES]; |
uint64_t dev_dyntrans_write_high[MAX_DEVICES]; |
71 |
|
|
72 |
int dev_dyntrans_alignment; |
int dev_dyntrans_alignment; |
|
|
|
|
|
|
|
/* |
|
|
* NOTE/TODO: This bintrans was for MIPS only. Ugly. :-/ |
|
|
*/ |
|
|
|
|
|
/* |
|
|
* translation_code_chunk_space is a large chunk of (linear) memory |
|
|
* where translated code chunks and translation_entrys are stored. |
|
|
* When this is filled, translation is restart from scratch (by |
|
|
* resetting translation_code_chunk_space_head to 0, and removing all |
|
|
* translation entries). |
|
|
* |
|
|
* (Using a static memory region like this is somewhat inspired by |
|
|
* the QEMU web pages, |
|
|
* http://fabrice.bellard.free.fr/qemu/qemu-tech.html#SEC13) |
|
|
*/ |
|
|
|
|
|
unsigned char *translation_code_chunk_space; |
|
|
size_t translation_code_chunk_space_head; |
|
|
|
|
|
int bintrans_32bit_only; |
|
|
|
|
|
struct translation_page_entry **translation_page_entry_array; |
|
|
|
|
|
unsigned char *quick_jump_host_address[MAX_QUICK_JUMPS]; |
|
|
int quick_jump_page_offset[MAX_QUICK_JUMPS]; |
|
|
int n_quick_jumps; |
|
|
int quick_jumps_index; |
|
73 |
}; |
}; |
74 |
|
|
75 |
#define BITS_PER_PAGETABLE 20 |
#define BITS_PER_PAGETABLE 20 |
148 |
void memory_device_dyntrans_access(struct cpu *, struct memory *mem, |
void memory_device_dyntrans_access(struct cpu *, struct memory *mem, |
149 |
void *extra, uint64_t *low, uint64_t *high); |
void *extra, uint64_t *low, uint64_t *high); |
150 |
|
|
151 |
void memory_device_register_statefunction( |
#define DEVICE_ACCESS(x) int dev_ ## x ## _access(struct cpu *cpu, \ |
152 |
struct memory *mem, void *extra, |
struct memory *mem, uint64_t relative_addr, unsigned char *data, \ |
153 |
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)); |
|
154 |
|
|
155 |
void memory_device_register(struct memory *mem, const char *, |
void memory_device_register(struct memory *mem, const char *, |
156 |
uint64_t baseaddr, uint64_t len, int (*f)(struct cpu *, |
uint64_t baseaddr, uint64_t len, int (*f)(struct cpu *, |
158 |
void *extra, int flags, unsigned char *dyntrans_data); |
void *extra, int flags, unsigned char *dyntrans_data); |
159 |
void memory_device_remove(struct memory *mem, int i); |
void memory_device_remove(struct memory *mem, int i); |
160 |
|
|
161 |
|
uint64_t memory_checksum(struct memory *mem); |
162 |
|
|
163 |
|
|
164 |
#endif /* MEMORY_H */ |
#endif /* MEMORY_H */ |