279 |
} |
} |
280 |
|
|
281 |
/* Execute a memory operation */ |
/* Execute a memory operation */ |
282 |
static forced_inline int mips64_exec_memop(cpu_mips_t *cpu,int memop, |
static forced_inline void mips64_exec_memop(cpu_mips_t *cpu,int memop, |
283 |
m_uint64_t vaddr,u_int dst_reg, |
m_uint64_t vaddr,u_int dst_reg, |
284 |
int keep_ll_bit) |
int keep_ll_bit) |
285 |
{ |
{ |
286 |
fastcall mips_memop_fn fn; |
fastcall mips_memop_fn fn; |
287 |
|
|
288 |
if (!keep_ll_bit) cpu->ll_bit = 0; |
if (!keep_ll_bit) cpu->ll_bit = 0; |
289 |
fn = cpu->mem_op_fn[memop]; |
fn = cpu->mem_op_fn[memop]; |
290 |
return(fn(cpu,vaddr,dst_reg)); |
fn(cpu,vaddr,dst_reg); |
291 |
} |
} |
292 |
|
|
293 |
/* Execute a memory operation (2) */ |
/* Execute a memory operation (2) */ |
294 |
static forced_inline int mips64_exec_memop2(cpu_mips_t *cpu,int memop, |
static forced_inline void mips64_exec_memop2(cpu_mips_t *cpu,int memop, |
295 |
m_uint64_t base,int offset, |
m_uint64_t base,int offset, |
296 |
u_int dst_reg,int keep_ll_bit) |
u_int dst_reg,int keep_ll_bit) |
297 |
{ |
{ |
298 |
m_uint64_t vaddr = cpu->gpr[base] + sign_extend(offset,16); |
m_uint64_t vaddr = cpu->gpr[base] + sign_extend(offset,16); |
299 |
fastcall mips_memop_fn fn; |
fastcall mips_memop_fn fn; |
300 |
|
|
301 |
if (!keep_ll_bit) cpu->ll_bit = 0; |
if (!keep_ll_bit) cpu->ll_bit = 0; |
302 |
fn = cpu->mem_op_fn[memop]; |
fn = cpu->mem_op_fn[memop]; |
303 |
return(fn(cpu,vaddr,dst_reg)); |
fn(cpu,vaddr,dst_reg); |
304 |
} |
} |
305 |
|
|
306 |
/* Fetch an instruction */ |
/* Fetch an instruction */ |
359 |
char buffer[80]; |
char buffer[80]; |
360 |
|
|
361 |
if (mips64_dump_insn(buffer,sizeof(buffer),0,cpu->pc,instruction)!=-1) |
if (mips64_dump_insn(buffer,sizeof(buffer),0,cpu->pc,instruction)!=-1) |
362 |
fprintf(log_file,"0x%llx: %s\n",cpu->pc,buffer); |
cpu_log(cpu->gen,"EXEC","0x%llx: %s\n",cpu->pc,buffer); |
363 |
} |
} |
364 |
#endif |
#endif |
|
|
|
365 |
return(exec(cpu,instruction)); |
return(exec(cpu,instruction)); |
366 |
} |
} |
367 |
|
|
395 |
} |
} |
396 |
|
|
397 |
gen->cpu_thread_running = TRUE; |
gen->cpu_thread_running = TRUE; |
398 |
|
cpu_exec_loop_set(gen); |
399 |
|
|
400 |
start_cpu: |
start_cpu: |
401 |
gen->idle_count = 0; |
gen->idle_count = 0; |
1076 |
int op = bits(insn,16,20); |
int op = bits(insn,16,20); |
1077 |
int offset = bits(insn,0,15); |
int offset = bits(insn,0,15); |
1078 |
|
|
1079 |
return(mips64_exec_memop2(cpu,MIPS_MEMOP_CACHE,base,offset,op,FALSE)); |
mips64_exec_memop2(cpu,MIPS_MEMOP_CACHE,base,offset,op,FALSE); |
1080 |
|
return(0); |
1081 |
} |
} |
1082 |
|
|
1083 |
/* CFC0 */ |
/* CFC0 */ |
1395 |
int rt = bits(insn,16,20); |
int rt = bits(insn,16,20); |
1396 |
int offset = bits(insn,0,15); |
int offset = bits(insn,0,15); |
1397 |
|
|
1398 |
return(mips64_exec_memop2(cpu,MIPS_MEMOP_LB,base,offset,rt,TRUE)); |
mips64_exec_memop2(cpu,MIPS_MEMOP_LB,base,offset,rt,TRUE); |
1399 |
|
return(0); |
1400 |
} |
} |
1401 |
|
|
1402 |
/* LBU (Load Byte Unsigned) */ |
/* LBU (Load Byte Unsigned) */ |
1406 |
int rt = bits(insn,16,20); |
int rt = bits(insn,16,20); |
1407 |
int offset = bits(insn,0,15); |
int offset = bits(insn,0,15); |
1408 |
|
|
1409 |
return(mips64_exec_memop2(cpu,MIPS_MEMOP_LBU,base,offset,rt,TRUE)); |
mips64_exec_memop2(cpu,MIPS_MEMOP_LBU,base,offset,rt,TRUE); |
1410 |
|
return(0); |
1411 |
} |
} |
1412 |
|
|
1413 |
/* LD (Load Double-Word) */ |
/* LD (Load Double-Word) */ |
1417 |
int rt = bits(insn,16,20); |
int rt = bits(insn,16,20); |
1418 |
int offset = bits(insn,0,15); |
int offset = bits(insn,0,15); |
1419 |
|
|
1420 |
return(mips64_exec_memop2(cpu,MIPS_MEMOP_LD,base,offset,rt,TRUE)); |
mips64_exec_memop2(cpu,MIPS_MEMOP_LD,base,offset,rt,TRUE); |
1421 |
|
return(0); |
1422 |
} |
} |
1423 |
|
|
1424 |
/* LDC1 (Load Double-Word to Coprocessor 1) */ |
/* LDC1 (Load Double-Word to Coprocessor 1) */ |
1428 |
int ft = bits(insn,16,20); |
int ft = bits(insn,16,20); |
1429 |
int offset = bits(insn,0,15); |
int offset = bits(insn,0,15); |
1430 |
|
|
1431 |
return(mips64_exec_memop2(cpu,MIPS_MEMOP_LDC1,base,offset,ft,TRUE)); |
mips64_exec_memop2(cpu,MIPS_MEMOP_LDC1,base,offset,ft,TRUE); |
1432 |
|
return(0); |
1433 |
} |
} |
1434 |
|
|
1435 |
/* LDL (Load Double-Word Left) */ |
/* LDL (Load Double-Word Left) */ |
1439 |
int rt = bits(insn,16,20); |
int rt = bits(insn,16,20); |
1440 |
int offset = bits(insn,0,15); |
int offset = bits(insn,0,15); |
1441 |
|
|
1442 |
return(mips64_exec_memop2(cpu,MIPS_MEMOP_LDL,base,offset,rt,TRUE)); |
mips64_exec_memop2(cpu,MIPS_MEMOP_LDL,base,offset,rt,TRUE); |
1443 |
|
return(0); |
1444 |
} |
} |
1445 |
|
|
1446 |
/* LDR (Load Double-Word Right) */ |
/* LDR (Load Double-Word Right) */ |
1450 |
int rt = bits(insn,16,20); |
int rt = bits(insn,16,20); |
1451 |
int offset = bits(insn,0,15); |
int offset = bits(insn,0,15); |
1452 |
|
|
1453 |
return(mips64_exec_memop2(cpu,MIPS_MEMOP_LDR,base,offset,rt,TRUE)); |
mips64_exec_memop2(cpu,MIPS_MEMOP_LDR,base,offset,rt,TRUE); |
1454 |
|
return(0); |
1455 |
} |
} |
1456 |
|
|
1457 |
/* LH (Load Half-Word) */ |
/* LH (Load Half-Word) */ |
1461 |
int rt = bits(insn,16,20); |
int rt = bits(insn,16,20); |
1462 |
int offset = bits(insn,0,15); |
int offset = bits(insn,0,15); |
1463 |
|
|
1464 |
return(mips64_exec_memop2(cpu,MIPS_MEMOP_LH,base,offset,rt,TRUE)); |
mips64_exec_memop2(cpu,MIPS_MEMOP_LH,base,offset,rt,TRUE); |
1465 |
|
return(0); |
1466 |
} |
} |
1467 |
|
|
1468 |
/* LHU (Load Half-Word Unsigned) */ |
/* LHU (Load Half-Word Unsigned) */ |
1472 |
int rt = bits(insn,16,20); |
int rt = bits(insn,16,20); |
1473 |
int offset = bits(insn,0,15); |
int offset = bits(insn,0,15); |
1474 |
|
|
1475 |
return(mips64_exec_memop2(cpu,MIPS_MEMOP_LHU,base,offset,rt,TRUE)); |
mips64_exec_memop2(cpu,MIPS_MEMOP_LHU,base,offset,rt,TRUE); |
1476 |
|
return(0); |
1477 |
} |
} |
1478 |
|
|
1479 |
/* LI (virtual) */ |
/* LI (virtual) */ |
1493 |
int rt = bits(insn,16,20); |
int rt = bits(insn,16,20); |
1494 |
int offset = bits(insn,0,15); |
int offset = bits(insn,0,15); |
1495 |
|
|
1496 |
return(mips64_exec_memop2(cpu,MIPS_MEMOP_LL,base,offset,rt,TRUE)); |
mips64_exec_memop2(cpu,MIPS_MEMOP_LL,base,offset,rt,TRUE); |
1497 |
|
return(0); |
1498 |
} |
} |
1499 |
|
|
1500 |
/* LUI */ |
/* LUI */ |
1514 |
int rt = bits(insn,16,20); |
int rt = bits(insn,16,20); |
1515 |
int offset = bits(insn,0,15); |
int offset = bits(insn,0,15); |
1516 |
|
|
1517 |
return(mips64_exec_memop2(cpu,MIPS_MEMOP_LW,base,offset,rt,TRUE)); |
mips64_exec_memop2(cpu,MIPS_MEMOP_LW,base,offset,rt,TRUE); |
1518 |
|
return(0); |
1519 |
} |
} |
1520 |
|
|
1521 |
/* LWL (Load Word Left) */ |
/* LWL (Load Word Left) */ |
1525 |
int rt = bits(insn,16,20); |
int rt = bits(insn,16,20); |
1526 |
int offset = bits(insn,0,15); |
int offset = bits(insn,0,15); |
1527 |
|
|
1528 |
return(mips64_exec_memop2(cpu,MIPS_MEMOP_LWL,base,offset,rt,TRUE)); |
mips64_exec_memop2(cpu,MIPS_MEMOP_LWL,base,offset,rt,TRUE); |
1529 |
|
return(0); |
1530 |
} |
} |
1531 |
|
|
1532 |
/* LWR (Load Word Right) */ |
/* LWR (Load Word Right) */ |
1536 |
int rt = bits(insn,16,20); |
int rt = bits(insn,16,20); |
1537 |
int offset = bits(insn,0,15); |
int offset = bits(insn,0,15); |
1538 |
|
|
1539 |
return(mips64_exec_memop2(cpu,MIPS_MEMOP_LWR,base,offset,rt,TRUE)); |
mips64_exec_memop2(cpu,MIPS_MEMOP_LWR,base,offset,rt,TRUE); |
1540 |
|
return(0); |
1541 |
} |
} |
1542 |
|
|
1543 |
/* LWU (Load Word Unsigned) */ |
/* LWU (Load Word Unsigned) */ |
1547 |
int rt = bits(insn,16,20); |
int rt = bits(insn,16,20); |
1548 |
int offset = bits(insn,0,15); |
int offset = bits(insn,0,15); |
1549 |
|
|
1550 |
return(mips64_exec_memop2(cpu,MIPS_MEMOP_LWU,base,offset,rt,TRUE)); |
mips64_exec_memop2(cpu,MIPS_MEMOP_LWU,base,offset,rt,TRUE); |
1551 |
|
return(0); |
1552 |
} |
} |
1553 |
|
|
1554 |
/* MFC0 */ |
/* MFC0 */ |
1738 |
int rt = bits(insn,16,20); |
int rt = bits(insn,16,20); |
1739 |
int offset = bits(insn,0,15); |
int offset = bits(insn,0,15); |
1740 |
|
|
1741 |
return(mips64_exec_memop2(cpu,MIPS_MEMOP_SB,base,offset,rt,FALSE)); |
mips64_exec_memop2(cpu,MIPS_MEMOP_SB,base,offset,rt,FALSE); |
1742 |
|
return(0); |
1743 |
} |
} |
1744 |
|
|
1745 |
/* SC (Store Conditional) */ |
/* SC (Store Conditional) */ |
1749 |
int rt = bits(insn,16,20); |
int rt = bits(insn,16,20); |
1750 |
int offset = bits(insn,0,15); |
int offset = bits(insn,0,15); |
1751 |
|
|
1752 |
return(mips64_exec_memop2(cpu,MIPS_MEMOP_SC,base,offset,rt,TRUE)); |
mips64_exec_memop2(cpu,MIPS_MEMOP_SC,base,offset,rt,TRUE); |
1753 |
|
return(0); |
1754 |
} |
} |
1755 |
|
|
1756 |
/* SD (Store Double-Word) */ |
/* SD (Store Double-Word) */ |
1760 |
int rt = bits(insn,16,20); |
int rt = bits(insn,16,20); |
1761 |
int offset = bits(insn,0,15); |
int offset = bits(insn,0,15); |
1762 |
|
|
1763 |
return(mips64_exec_memop2(cpu,MIPS_MEMOP_SD,base,offset,rt,FALSE)); |
mips64_exec_memop2(cpu,MIPS_MEMOP_SD,base,offset,rt,FALSE); |
1764 |
|
return(0); |
1765 |
} |
} |
1766 |
|
|
1767 |
/* SDL (Store Double-Word Left) */ |
/* SDL (Store Double-Word Left) */ |
1771 |
int rt = bits(insn,16,20); |
int rt = bits(insn,16,20); |
1772 |
int offset = bits(insn,0,15); |
int offset = bits(insn,0,15); |
1773 |
|
|
1774 |
return(mips64_exec_memop2(cpu,MIPS_MEMOP_SDL,base,offset,rt,FALSE)); |
mips64_exec_memop2(cpu,MIPS_MEMOP_SDL,base,offset,rt,FALSE); |
1775 |
|
return(0); |
1776 |
} |
} |
1777 |
|
|
1778 |
/* SDR (Store Double-Word Right) */ |
/* SDR (Store Double-Word Right) */ |
1782 |
int rt = bits(insn,16,20); |
int rt = bits(insn,16,20); |
1783 |
int offset = bits(insn,0,15); |
int offset = bits(insn,0,15); |
1784 |
|
|
1785 |
return(mips64_exec_memop2(cpu,MIPS_MEMOP_SDR,base,offset,rt,FALSE)); |
mips64_exec_memop2(cpu,MIPS_MEMOP_SDR,base,offset,rt,FALSE); |
1786 |
|
return(0); |
1787 |
} |
} |
1788 |
|
|
1789 |
/* SDC1 (Store Double-Word from Coprocessor 1) */ |
/* SDC1 (Store Double-Word from Coprocessor 1) */ |
1793 |
int ft = bits(insn,16,20); |
int ft = bits(insn,16,20); |
1794 |
int offset = bits(insn,0,15); |
int offset = bits(insn,0,15); |
1795 |
|
|
1796 |
return(mips64_exec_memop2(cpu,MIPS_MEMOP_SDC1,base,offset,ft,FALSE)); |
mips64_exec_memop2(cpu,MIPS_MEMOP_SDC1,base,offset,ft,FALSE); |
1797 |
|
return(0); |
1798 |
} |
} |
1799 |
|
|
1800 |
/* SH (Store Half-Word) */ |
/* SH (Store Half-Word) */ |
1804 |
int rt = bits(insn,16,20); |
int rt = bits(insn,16,20); |
1805 |
int offset = bits(insn,0,15); |
int offset = bits(insn,0,15); |
1806 |
|
|
1807 |
return(mips64_exec_memop2(cpu,MIPS_MEMOP_SH,base,offset,rt,FALSE)); |
mips64_exec_memop2(cpu,MIPS_MEMOP_SH,base,offset,rt,FALSE); |
1808 |
|
return(0); |
1809 |
} |
} |
1810 |
|
|
1811 |
/* SLL */ |
/* SLL */ |
1982 |
int rt = bits(insn,16,20); |
int rt = bits(insn,16,20); |
1983 |
int offset = bits(insn,0,15); |
int offset = bits(insn,0,15); |
1984 |
|
|
1985 |
return(mips64_exec_memop2(cpu,MIPS_MEMOP_SW,base,offset,rt,FALSE)); |
mips64_exec_memop2(cpu,MIPS_MEMOP_SW,base,offset,rt,FALSE); |
1986 |
|
return(0); |
1987 |
} |
} |
1988 |
|
|
1989 |
/* SWL (Store Word Left) */ |
/* SWL (Store Word Left) */ |
1993 |
int rt = bits(insn,16,20); |
int rt = bits(insn,16,20); |
1994 |
int offset = bits(insn,0,15); |
int offset = bits(insn,0,15); |
1995 |
|
|
1996 |
return(mips64_exec_memop2(cpu,MIPS_MEMOP_SWL,base,offset,rt,FALSE)); |
mips64_exec_memop2(cpu,MIPS_MEMOP_SWL,base,offset,rt,FALSE); |
1997 |
|
return(0); |
1998 |
} |
} |
1999 |
|
|
2000 |
/* SWR (Store Word Right) */ |
/* SWR (Store Word Right) */ |
2004 |
int rt = bits(insn,16,20); |
int rt = bits(insn,16,20); |
2005 |
int offset = bits(insn,0,15); |
int offset = bits(insn,0,15); |
2006 |
|
|
2007 |
return(mips64_exec_memop2(cpu,MIPS_MEMOP_SWR,base,offset,rt,FALSE)); |
mips64_exec_memop2(cpu,MIPS_MEMOP_SWR,base,offset,rt,FALSE); |
2008 |
|
return(0); |
2009 |
} |
} |
2010 |
|
|
2011 |
/* SYNC */ |
/* SYNC */ |