25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: memory_mips.c,v 1.8 2006/06/24 21:47:23 debug Exp $ |
* $Id: memory_mips.c,v 1.9 2006/07/14 16:33:28 debug Exp $ |
29 |
* |
* |
30 |
* MIPS-specific memory routines. Included from cpu_mips.c. |
* MIPS-specific memory routines. Included from cpu_mips.c. |
31 |
* |
* |
54 |
uint32_t tag_mask; |
uint32_t tag_mask; |
55 |
unsigned char *memblock; |
unsigned char *memblock; |
56 |
struct memory *mem = cpu->mem; |
struct memory *mem = cpu->mem; |
|
int offset; |
|
57 |
#endif |
#endif |
58 |
unsigned int i; |
unsigned int i; |
59 |
int cache_isolated = 0, addr, hit, which_cache = cache; |
int cache_isolated = 0, addr, hit, which_cache = cache; |
126 |
old_cached_paddr); |
old_cached_paddr); |
127 |
*/ |
*/ |
128 |
memblock = memory_paddr_to_hostaddr( |
memblock = memory_paddr_to_hostaddr( |
129 |
mem, old_cached_paddr, MEM_WRITE); |
mem, old_cached_paddr & ~cpu->cd.mips. |
130 |
offset = old_cached_paddr |
cache_mask[which_cache], MEM_WRITE); |
|
& ((1 << BITS_PER_MEMBLOCK) - 1) |
|
|
& ~cpu->cd.mips.cache_mask[which_cache]; |
|
131 |
|
|
132 |
src = cpu->cd.mips.cache[which_cache]; |
src = cpu->cd.mips.cache[which_cache]; |
133 |
dst = memblock + (offset & |
dst = memblock; |
|
~cpu->cd.mips.cache_mask[which_cache]); |
|
134 |
|
|
135 |
src += cache_line * |
src += cache_line * |
136 |
cpu->cd.mips.cache_linesize[which_cache]; |
cpu->cd.mips.cache_linesize[which_cache]; |
143 |
memcpy(dst, src, |
memcpy(dst, src, |
144 |
cpu->cd.mips.cache_linesize[which_cache]); |
cpu->cd.mips.cache_linesize[which_cache]); |
145 |
} |
} |
|
/* offset is the offset within |
|
|
* the memblock: |
|
|
* printf("read: offset = 0x%x\n", offset); |
|
|
*/ |
|
146 |
} |
} |
147 |
|
|
148 |
/* Copy from main memory into the cache: */ |
/* Copy from main memory into the cache: */ |
149 |
memblock = memory_paddr_to_hostaddr(mem, paddr, writeflag); |
memblock = memory_paddr_to_hostaddr(mem, paddr |
150 |
offset = paddr & ((1 << BITS_PER_MEMBLOCK) - 1) |
& ~cpu->cd.mips.cache_mask[which_cache], writeflag); |
|
& ~cpu->cd.mips.cache_mask[which_cache]; |
|
|
/* offset is offset within the memblock: |
|
|
* printf("write: offset = 0x%x\n", offset); |
|
|
*/ |
|
151 |
|
|
152 |
/* fatal(" FETCHING new paddr=0%08x\n", paddr); |
/* fatal(" FETCHING new paddr=0%08x\n", paddr); |
153 |
*/ |
*/ |
158 |
memset(dst, 0, |
memset(dst, 0, |
159 |
cpu->cd.mips.cache_linesize[which_cache]); |
cpu->cd.mips.cache_linesize[which_cache]); |
160 |
} else { |
} else { |
161 |
src = memblock + (offset & |
src = memblock; |
|
~cpu->cd.mips.cache_mask[which_cache]); |
|
162 |
|
|
163 |
src += cache_line * |
src += cache_line * |
164 |
cpu->cd.mips.cache_linesize[which_cache]; |
cpu->cd.mips.cache_linesize[which_cache]; |