--- upstream/dynamips-0.2.7-RC1/mips64_exec.c 2007/10/06 16:23:47 7 +++ trunk/mips64_exec.c 2007/10/06 16:45:40 12 @@ -51,7 +51,7 @@ for(i=0,count=0;mips64_exec_tags[i].exec;i++) count++; - ilt = ilt_create(count+1, + ilt = ilt_create("mips64e",count, (ilt_get_insn_cbk_t)mips64_exec_get_insn, (ilt_check_cbk_t)mips64_exec_chk_lo, (ilt_check_cbk_t)mips64_exec_chk_hi); @@ -279,28 +279,28 @@ } /* Execute a memory operation */ -static forced_inline int mips64_exec_memop(cpu_mips_t *cpu,int memop, - m_uint64_t vaddr,u_int dst_reg, - int keep_ll_bit) +static forced_inline void mips64_exec_memop(cpu_mips_t *cpu,int memop, + m_uint64_t vaddr,u_int dst_reg, + int keep_ll_bit) { fastcall mips_memop_fn fn; if (!keep_ll_bit) cpu->ll_bit = 0; fn = cpu->mem_op_fn[memop]; - return(fn(cpu,vaddr,dst_reg)); + fn(cpu,vaddr,dst_reg); } /* Execute a memory operation (2) */ -static forced_inline int mips64_exec_memop2(cpu_mips_t *cpu,int memop, - m_uint64_t base,int offset, - u_int dst_reg,int keep_ll_bit) +static forced_inline void mips64_exec_memop2(cpu_mips_t *cpu,int memop, + m_uint64_t base,int offset, + u_int dst_reg,int keep_ll_bit) { m_uint64_t vaddr = cpu->gpr[base] + sign_extend(offset,16); fastcall mips_memop_fn fn; - + if (!keep_ll_bit) cpu->ll_bit = 0; fn = cpu->mem_op_fn[memop]; - return(fn(cpu,vaddr,dst_reg)); + fn(cpu,vaddr,dst_reg); } /* Fetch an instruction */ @@ -322,6 +322,14 @@ return(0); } +/* Unknown opcode */ +static fastcall int mips64_exec_unknown(cpu_mips_t *cpu,mips_insn_t insn) +{ + printf("MIPS64: unknown opcode 0x%8.8x at pc = 0x%llx\n",insn,cpu->pc); + mips64_dump_regs(cpu->gen); + return(0); +} + /* Execute a single instruction */ static forced_inline int mips64_exec_single_instruction(cpu_mips_t *cpu,mips_insn_t instruction) @@ -342,27 +350,19 @@ tag = mips64_exec_get_insn(index); exec = tag->exec; - if (likely(exec != NULL)) { #if NJM_STATS_ENABLE - cpu->insn_exec_count++; - mips64_exec_tags[index].count++; + cpu->insn_exec_count++; + mips64_exec_tags[index].count++; #endif #if 0 { char buffer[80]; if (mips64_dump_insn(buffer,sizeof(buffer),0,cpu->pc,instruction)!=-1) - fprintf(log_file,"0x%llx: %s\n",cpu->pc,buffer); + cpu_log(cpu->gen,"EXEC","0x%llx: %s\n",cpu->pc,buffer); } #endif - - return(exec(cpu,instruction)); - } - - printf("MIPS64: unknown opcode 0x%8.8x at pc = 0x%llx\n", - instruction,cpu->pc); - mips64_dump_regs(cpu->gen); - return(0); + return(exec(cpu,instruction)); } /* Single-step execution */ @@ -395,6 +395,7 @@ } gen->cpu_thread_running = TRUE; + cpu_exec_loop_set(gen); start_cpu: gen->idle_count = 0; @@ -1075,7 +1076,8 @@ int op = bits(insn,16,20); int offset = bits(insn,0,15); - return(mips64_exec_memop2(cpu,MIPS_MEMOP_CACHE,base,offset,op,FALSE)); + mips64_exec_memop2(cpu,MIPS_MEMOP_CACHE,base,offset,op,FALSE); + return(0); } /* CFC0 */ @@ -1393,7 +1395,8 @@ int rt = bits(insn,16,20); int offset = bits(insn,0,15); - return(mips64_exec_memop2(cpu,MIPS_MEMOP_LB,base,offset,rt,TRUE)); + mips64_exec_memop2(cpu,MIPS_MEMOP_LB,base,offset,rt,TRUE); + return(0); } /* LBU (Load Byte Unsigned) */ @@ -1403,7 +1406,8 @@ int rt = bits(insn,16,20); int offset = bits(insn,0,15); - return(mips64_exec_memop2(cpu,MIPS_MEMOP_LBU,base,offset,rt,TRUE)); + mips64_exec_memop2(cpu,MIPS_MEMOP_LBU,base,offset,rt,TRUE); + return(0); } /* LD (Load Double-Word) */ @@ -1413,7 +1417,8 @@ int rt = bits(insn,16,20); int offset = bits(insn,0,15); - return(mips64_exec_memop2(cpu,MIPS_MEMOP_LD,base,offset,rt,TRUE)); + mips64_exec_memop2(cpu,MIPS_MEMOP_LD,base,offset,rt,TRUE); + return(0); } /* LDC1 (Load Double-Word to Coprocessor 1) */ @@ -1423,7 +1428,8 @@ int ft = bits(insn,16,20); int offset = bits(insn,0,15); - return(mips64_exec_memop2(cpu,MIPS_MEMOP_LDC1,base,offset,ft,TRUE)); + mips64_exec_memop2(cpu,MIPS_MEMOP_LDC1,base,offset,ft,TRUE); + return(0); } /* LDL (Load Double-Word Left) */ @@ -1433,7 +1439,8 @@ int rt = bits(insn,16,20); int offset = bits(insn,0,15); - return(mips64_exec_memop2(cpu,MIPS_MEMOP_LDL,base,offset,rt,TRUE)); + mips64_exec_memop2(cpu,MIPS_MEMOP_LDL,base,offset,rt,TRUE); + return(0); } /* LDR (Load Double-Word Right) */ @@ -1443,7 +1450,8 @@ int rt = bits(insn,16,20); int offset = bits(insn,0,15); - return(mips64_exec_memop2(cpu,MIPS_MEMOP_LDR,base,offset,rt,TRUE)); + mips64_exec_memop2(cpu,MIPS_MEMOP_LDR,base,offset,rt,TRUE); + return(0); } /* LH (Load Half-Word) */ @@ -1453,7 +1461,8 @@ int rt = bits(insn,16,20); int offset = bits(insn,0,15); - return(mips64_exec_memop2(cpu,MIPS_MEMOP_LH,base,offset,rt,TRUE)); + mips64_exec_memop2(cpu,MIPS_MEMOP_LH,base,offset,rt,TRUE); + return(0); } /* LHU (Load Half-Word Unsigned) */ @@ -1463,7 +1472,8 @@ int rt = bits(insn,16,20); int offset = bits(insn,0,15); - return(mips64_exec_memop2(cpu,MIPS_MEMOP_LHU,base,offset,rt,TRUE)); + mips64_exec_memop2(cpu,MIPS_MEMOP_LHU,base,offset,rt,TRUE); + return(0); } /* LI (virtual) */ @@ -1483,7 +1493,8 @@ int rt = bits(insn,16,20); int offset = bits(insn,0,15); - return(mips64_exec_memop2(cpu,MIPS_MEMOP_LL,base,offset,rt,TRUE)); + mips64_exec_memop2(cpu,MIPS_MEMOP_LL,base,offset,rt,TRUE); + return(0); } /* LUI */ @@ -1503,7 +1514,8 @@ int rt = bits(insn,16,20); int offset = bits(insn,0,15); - return(mips64_exec_memop2(cpu,MIPS_MEMOP_LW,base,offset,rt,TRUE)); + mips64_exec_memop2(cpu,MIPS_MEMOP_LW,base,offset,rt,TRUE); + return(0); } /* LWL (Load Word Left) */ @@ -1513,7 +1525,8 @@ int rt = bits(insn,16,20); int offset = bits(insn,0,15); - return(mips64_exec_memop2(cpu,MIPS_MEMOP_LWL,base,offset,rt,TRUE)); + mips64_exec_memop2(cpu,MIPS_MEMOP_LWL,base,offset,rt,TRUE); + return(0); } /* LWR (Load Word Right) */ @@ -1523,7 +1536,8 @@ int rt = bits(insn,16,20); int offset = bits(insn,0,15); - return(mips64_exec_memop2(cpu,MIPS_MEMOP_LWR,base,offset,rt,TRUE)); + mips64_exec_memop2(cpu,MIPS_MEMOP_LWR,base,offset,rt,TRUE); + return(0); } /* LWU (Load Word Unsigned) */ @@ -1533,7 +1547,8 @@ int rt = bits(insn,16,20); int offset = bits(insn,0,15); - return(mips64_exec_memop2(cpu,MIPS_MEMOP_LWU,base,offset,rt,TRUE)); + mips64_exec_memop2(cpu,MIPS_MEMOP_LWU,base,offset,rt,TRUE); + return(0); } /* MFC0 */ @@ -1723,7 +1738,8 @@ int rt = bits(insn,16,20); int offset = bits(insn,0,15); - return(mips64_exec_memop2(cpu,MIPS_MEMOP_SB,base,offset,rt,FALSE)); + mips64_exec_memop2(cpu,MIPS_MEMOP_SB,base,offset,rt,FALSE); + return(0); } /* SC (Store Conditional) */ @@ -1733,7 +1749,8 @@ int rt = bits(insn,16,20); int offset = bits(insn,0,15); - return(mips64_exec_memop2(cpu,MIPS_MEMOP_SC,base,offset,rt,TRUE)); + mips64_exec_memop2(cpu,MIPS_MEMOP_SC,base,offset,rt,TRUE); + return(0); } /* SD (Store Double-Word) */ @@ -1743,7 +1760,8 @@ int rt = bits(insn,16,20); int offset = bits(insn,0,15); - return(mips64_exec_memop2(cpu,MIPS_MEMOP_SD,base,offset,rt,FALSE)); + mips64_exec_memop2(cpu,MIPS_MEMOP_SD,base,offset,rt,FALSE); + return(0); } /* SDL (Store Double-Word Left) */ @@ -1753,7 +1771,8 @@ int rt = bits(insn,16,20); int offset = bits(insn,0,15); - return(mips64_exec_memop2(cpu,MIPS_MEMOP_SDL,base,offset,rt,FALSE)); + mips64_exec_memop2(cpu,MIPS_MEMOP_SDL,base,offset,rt,FALSE); + return(0); } /* SDR (Store Double-Word Right) */ @@ -1763,7 +1782,8 @@ int rt = bits(insn,16,20); int offset = bits(insn,0,15); - return(mips64_exec_memop2(cpu,MIPS_MEMOP_SDR,base,offset,rt,FALSE)); + mips64_exec_memop2(cpu,MIPS_MEMOP_SDR,base,offset,rt,FALSE); + return(0); } /* SDC1 (Store Double-Word from Coprocessor 1) */ @@ -1773,7 +1793,8 @@ int ft = bits(insn,16,20); int offset = bits(insn,0,15); - return(mips64_exec_memop2(cpu,MIPS_MEMOP_SDC1,base,offset,ft,FALSE)); + mips64_exec_memop2(cpu,MIPS_MEMOP_SDC1,base,offset,ft,FALSE); + return(0); } /* SH (Store Half-Word) */ @@ -1783,7 +1804,8 @@ int rt = bits(insn,16,20); int offset = bits(insn,0,15); - return(mips64_exec_memop2(cpu,MIPS_MEMOP_SH,base,offset,rt,FALSE)); + mips64_exec_memop2(cpu,MIPS_MEMOP_SH,base,offset,rt,FALSE); + return(0); } /* SLL */ @@ -1960,7 +1982,8 @@ int rt = bits(insn,16,20); int offset = bits(insn,0,15); - return(mips64_exec_memop2(cpu,MIPS_MEMOP_SW,base,offset,rt,FALSE)); + mips64_exec_memop2(cpu,MIPS_MEMOP_SW,base,offset,rt,FALSE); + return(0); } /* SWL (Store Word Left) */ @@ -1970,7 +1993,8 @@ int rt = bits(insn,16,20); int offset = bits(insn,0,15); - return(mips64_exec_memop2(cpu,MIPS_MEMOP_SWL,base,offset,rt,FALSE)); + mips64_exec_memop2(cpu,MIPS_MEMOP_SWL,base,offset,rt,FALSE); + return(0); } /* SWR (Store Word Right) */ @@ -1980,7 +2004,8 @@ int rt = bits(insn,16,20); int offset = bits(insn,0,15); - return(mips64_exec_memop2(cpu,MIPS_MEMOP_SWR,base,offset,rt,FALSE)); + mips64_exec_memop2(cpu,MIPS_MEMOP_SWR,base,offset,rt,FALSE); + return(0); } /* SYNC */ @@ -2196,6 +2221,7 @@ { "tlbwr" , mips64_exec_TLBWR , 0xffffffff , 0x42000006, 1, 1 }, { "xor" , mips64_exec_XOR , 0xfc0007ff , 0x00000026, 1, 3 }, { "xori" , mips64_exec_XORI , 0xfc000000 , 0x38000000, 1, 5 }, + { "unknown", mips64_exec_unknown , 0x00000000 , 0x00000000, 1, 0 }, { NULL , NULL , 0x00000000 , 0x00000000, 1, 0 }, };