180 |
ppc32_mem_map(cpu_ppc_t *cpu,u_int op_type,mts_map_t *map, |
ppc32_mem_map(cpu_ppc_t *cpu,u_int op_type,mts_map_t *map, |
181 |
mts32_entry_t *entry,mts32_entry_t *alt_entry) |
mts32_entry_t *entry,mts32_entry_t *alt_entry) |
182 |
{ |
{ |
183 |
|
ppc32_jit_tcb_t *block; |
184 |
struct vdevice *dev; |
struct vdevice *dev; |
185 |
m_uint32_t offset; |
m_uint32_t offset; |
186 |
m_iptr_t host_ptr; |
m_iptr_t host_ptr; |
187 |
|
m_uint32_t exec_flag = 0; |
188 |
int cow; |
int cow; |
189 |
|
|
190 |
if (!(dev = dev_lookup(cpu->vm,map->paddr,map->cached))) |
if (!(dev = dev_lookup(cpu->vm,map->paddr,map->cached))) |
191 |
return NULL; |
return NULL; |
192 |
|
|
193 |
|
if (cpu->exec_phys_map) { |
194 |
|
block = ppc32_jit_find_by_phys_page(cpu,map->paddr >> VM_PAGE_SHIFT); |
195 |
|
|
196 |
|
if (block) |
197 |
|
exec_flag = MTS_FLAG_EXEC; |
198 |
|
} |
199 |
|
|
200 |
if (dev->flags & VDEVICE_FLAG_SPARSE) { |
if (dev->flags & VDEVICE_FLAG_SPARSE) { |
201 |
host_ptr = dev_sparse_get_host_addr(cpu->vm,dev,map->paddr,op_type,&cow); |
host_ptr = dev_sparse_get_host_addr(cpu->vm,dev,map->paddr,op_type,&cow); |
202 |
|
|
204 |
entry->gppa = map->paddr; |
entry->gppa = map->paddr; |
205 |
entry->hpa = host_ptr; |
entry->hpa = host_ptr; |
206 |
entry->flags = (cow) ? MTS_FLAG_COW : 0; |
entry->flags = (cow) ? MTS_FLAG_COW : 0; |
207 |
|
entry->flags |= exec_flag; |
208 |
return entry; |
return entry; |
209 |
} |
} |
210 |
|
|
221 |
entry->gvpa = map->vaddr; |
entry->gvpa = map->vaddr; |
222 |
entry->gppa = map->paddr; |
entry->gppa = map->paddr; |
223 |
entry->hpa = dev->host_addr + (map->paddr - dev->phys_addr); |
entry->hpa = dev->host_addr + (map->paddr - dev->phys_addr); |
224 |
entry->flags = 0; |
entry->flags = exec_flag; |
225 |
return entry; |
return entry; |
226 |
} |
} |
227 |
|
|
379 |
u_int *exc) |
u_int *exc) |
380 |
{ |
{ |
381 |
mts32_entry_t *entry,alt_entry; |
mts32_entry_t *entry,alt_entry; |
382 |
|
ppc32_jit_tcb_t *block; |
383 |
m_uint32_t hash_bucket; |
m_uint32_t hash_bucket; |
384 |
|
m_uint32_t phys_page; |
385 |
|
m_uint32_t ia_hash; |
386 |
m_iptr_t haddr; |
m_iptr_t haddr; |
387 |
u_int dev_id; |
u_int dev_id; |
388 |
int cow; |
int cow; |
418 |
} |
} |
419 |
} |
} |
420 |
|
|
421 |
|
/* Invalidate JIT code for written pages */ |
422 |
|
if ((op_type == MTS_WRITE) && (entry->flags & MTS_FLAG_EXEC)) { |
423 |
|
if (cpu->exec_phys_map) { |
424 |
|
phys_page = entry->gppa >> VM_PAGE_SHIFT; |
425 |
|
|
426 |
|
if (vaddr >= PPC32_EXC_SYS_RST) { |
427 |
|
block = ppc32_jit_find_by_phys_page(cpu,phys_page); |
428 |
|
|
429 |
|
if (block != NULL) { |
430 |
|
//printf("Invalidation of block 0x%8.8x\n",block->start_ia); |
431 |
|
ia_hash = ppc32_jit_get_ia_hash(block->start_ia); |
432 |
|
ppc32_jit_tcb_free(cpu,block,TRUE); |
433 |
|
|
434 |
|
if (cpu->exec_blk_map[ia_hash] == block) |
435 |
|
cpu->exec_blk_map[ia_hash] = NULL; |
436 |
|
|
437 |
|
entry->flags &= ~MTS_FLAG_EXEC; |
438 |
|
} |
439 |
|
} |
440 |
|
} |
441 |
|
} |
442 |
|
|
443 |
/* Raw memory access */ |
/* Raw memory access */ |
444 |
haddr = entry->hpa + (vaddr & PPC32_MIN_PAGE_IMASK); |
haddr = entry->hpa + (vaddr & PPC32_MIN_PAGE_IMASK); |
445 |
#if MEMLOG_ENABLE |
#if MEMLOG_ENABLE |
904 |
#endif |
#endif |
905 |
|
|
906 |
if (!cpu->translate(cpu,vaddr,PPC32_MTS_ICACHE,&phys_page)) { |
if (!cpu->translate(cpu,vaddr,PPC32_MTS_ICACHE,&phys_page)) { |
907 |
if ((phys_page < 1048576) && cpu->exec_phys_map) { |
if (cpu->exec_phys_map) { |
908 |
block = cpu->exec_phys_map[phys_page]; |
block = ppc32_jit_find_by_phys_page(cpu,phys_page); |
909 |
|
|
910 |
if (block) { |
if (block && ppc32_jit_tcb_match(cpu,block)) { |
|
if ((cpu->ia < block->start_ia) || |
|
|
((cpu->ia - block->start_ia) >= PPC32_MIN_PAGE_SIZE)) |
|
|
{ |
|
911 |
#if DEBUG_ICBI |
#if DEBUG_ICBI |
912 |
cpu_log(cpu->gen,"MTS", |
cpu_log(cpu->gen,"MTS", |
913 |
"ICBI: removing compiled page at 0x%8.8x, pc=0x%8.8x\n", |
"ICBI: removing compiled page at 0x%8.8x, pc=0x%8.8x\n", |
914 |
block->start_ia,cpu->ia); |
block->start_ia,cpu->ia); |
915 |
#endif |
#endif |
916 |
cpu->exec_phys_map[phys_page] = NULL; |
ppc32_jit_tcb_free(cpu,block,TRUE); |
917 |
ppc32_jit_tcb_free(cpu,block,TRUE); |
cpu->exec_blk_map[ppc32_jit_get_ia_hash(vaddr)] = NULL; |
918 |
} |
} |
919 |
else |
else |
920 |
{ |
{ |
921 |
#if DEBUG_ICBI |
#if DEBUG_ICBI |
922 |
cpu_log(cpu->gen,"MTS", |
cpu_log(cpu->gen,"MTS", |
923 |
"ICBI: trying to remove page 0x%llx with pc=0x%llx\n", |
"ICBI: trying to remove page 0x%llx with pc=0x%llx\n", |
924 |
block->start_ia,cpu->ia); |
block->start_ia,cpu->ia); |
925 |
#endif |
#endif |
|
} |
|
926 |
} |
} |
927 |
} |
} |
928 |
} |
} |