[Softpear-cvs] softpear/src/cpu/cpu_generic ppc_alu.cc,1.1.1.1,1.2 ppc_alu.h,1.1.1.1,1.2 ppc_cpu.cc,
Status: Pre-Alpha
Brought to you by:
mist
|
From: <mas...@us...> - 2005-03-14 22:55:22
|
Update of /cvsroot/softpear/softpear/src/cpu/cpu_generic In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7977/src/cpu/cpu_generic Modified Files: ppc_alu.cc ppc_alu.h ppc_cpu.cc ppc_cpu.h ppc_dec.cc ppc_dec.h ppc_exc.cc ppc_exc.h ppc_fpu.cc ppc_fpu.h ppc_mmu.cc ppc_mmu.h ppc_opc.cc ppc_opc.h Log Message: Implemented preliminary pthread-support. The idea is to have an interpreter thread running on the host for every guest thread. To achieve this, the global gCPU structure is now local per thread. Because I didn't think enough, it is still called gCPU everywhere, although it is no longer a global structure. Only pthread_create and pthread_join are implemented. I'm sure they need some additional code to work correctly, but the major work should be done, now. Index: ppc_alu.cc =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu_generic/ppc_alu.cc,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ppc_alu.cc 16 Nov 2004 22:50:15 -0000 1.1.1.1 +++ ppc_alu.cc 14 Mar 2005 22:55:11 -0000 1.2 @@ -46,28 +46,28 @@ * addx Add * .422 */ -void ppc_opc_addx() +void ppc_opc_addx(PPC_CPU_State *gCPU) { int rD, rA, rB; - PPC_OPC_TEMPL_XO(gCPU.current_opc, rD, rA, rB); - gCPU.gpr[rD] = gCPU.gpr[rA] + gCPU.gpr[rB]; - if (gCPU.current_opc & PPC_OPC_Rc) { + PPC_OPC_TEMPL_XO(gCPU->current_opc, rD, rA, rB); [...1727 lines suppressed...] - PPC_OPC_TEMPL_D_UImm(gCPU.current_opc, rS, rA, imm); - gCPU.gpr[rA] = gCPU.gpr[rS] ^ imm; + PPC_OPC_TEMPL_D_UImm(gCPU->current_opc, rS, rA, imm); + gCPU->gpr[rA] = gCPU->gpr[rS] ^ imm; } /* * xoris XOR Immediate Shifted * .682 */ -void ppc_opc_xoris() +void ppc_opc_xoris(PPC_CPU_State *gCPU) { int rS, rA; uint32 imm; - PPC_OPC_TEMPL_D_Shift16(gCPU.current_opc, rS, rA, imm); - gCPU.gpr[rA] = gCPU.gpr[rS] ^ imm; + PPC_OPC_TEMPL_D_Shift16(gCPU->current_opc, rS, rA, imm); + gCPU->gpr[rA] = gCPU->gpr[rS] ^ imm; } Index: ppc_alu.h =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu_generic/ppc_alu.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ppc_alu.h 16 Nov 2004 22:50:15 -0000 1.1.1.1 +++ ppc_alu.h 14 Mar 2005 22:55:11 -0000 1.2 @@ -21,79 +21,81 @@ #ifndef __PPC_ALU_H__ #define __PPC_ALU_H__ -void ppc_opc_addx(); -void ppc_opc_addcx(); -void ppc_opc_addex(); -void ppc_opc_addi(); -void ppc_opc_addic(); -void ppc_opc_addic_(); -void ppc_opc_addis(); -void ppc_opc_addmex(); -void ppc_opc_addzex(); +#include "cpu/cpu.h" -void ppc_opc_andx(); -void ppc_opc_andcx(); -void ppc_opc_andi_(); -void ppc_opc_andis_(); +void ppc_opc_addx(PPC_CPU_State*); +void ppc_opc_addcx(PPC_CPU_State*); +void ppc_opc_addex(PPC_CPU_State*); +void ppc_opc_addi(PPC_CPU_State*); +void ppc_opc_addic(PPC_CPU_State*); +void ppc_opc_addic_(PPC_CPU_State*); +void ppc_opc_addis(PPC_CPU_State*); +void ppc_opc_addmex(PPC_CPU_State*); +void ppc_opc_addzex(PPC_CPU_State*); -void ppc_opc_cmp(); -void ppc_opc_cmpi(); -void ppc_opc_cmpl(); -void ppc_opc_cmpli(); +void ppc_opc_andx(PPC_CPU_State*); +void ppc_opc_andcx(PPC_CPU_State*); +void ppc_opc_andi_(PPC_CPU_State*); +void ppc_opc_andis_(PPC_CPU_State*); -void ppc_opc_cntlzwx(); +void ppc_opc_cmp(PPC_CPU_State*); +void ppc_opc_cmpi(PPC_CPU_State*); +void ppc_opc_cmpl(PPC_CPU_State*); +void ppc_opc_cmpli(PPC_CPU_State*); -void ppc_opc_crand(); -void ppc_opc_crandc(); -void ppc_opc_creqv(); -void ppc_opc_crnand(); -void ppc_opc_crnor(); -void ppc_opc_cror(); -void ppc_opc_crorc(); -void ppc_opc_crxor(); +void ppc_opc_cntlzwx(PPC_CPU_State*); -void ppc_opc_divwx(); -void ppc_opc_divwux(); +void ppc_opc_crand(PPC_CPU_State*); +void ppc_opc_crandc(PPC_CPU_State*); +void ppc_opc_creqv(PPC_CPU_State*); +void ppc_opc_crnand(PPC_CPU_State*); +void ppc_opc_crnor(PPC_CPU_State*); +void ppc_opc_cror(PPC_CPU_State*); +void ppc_opc_crorc(PPC_CPU_State*); +void ppc_opc_crxor(PPC_CPU_State*); -void ppc_opc_eqvx(); +void ppc_opc_divwx(PPC_CPU_State*); +void ppc_opc_divwux(PPC_CPU_State*); -void ppc_opc_extsbx(); -void ppc_opc_extshx(); +void ppc_opc_eqvx(PPC_CPU_State*); -void ppc_opc_mulhwx(); -void ppc_opc_mulhwux(); -void ppc_opc_mulli(); -void ppc_opc_mullwx(); +void ppc_opc_extsbx(PPC_CPU_State*); +void ppc_opc_extshx(PPC_CPU_State*); -void ppc_opc_nandx(); +void ppc_opc_mulhwx(PPC_CPU_State*); +void ppc_opc_mulhwux(PPC_CPU_State*); +void ppc_opc_mulli(PPC_CPU_State*); +void ppc_opc_mullwx(PPC_CPU_State*); -void ppc_opc_negx(); -void ppc_opc_norx(); +void ppc_opc_nandx(PPC_CPU_State*); -void ppc_opc_orx(); -void ppc_opc_orcx(); -void ppc_opc_ori(); -void ppc_opc_oris(); +void ppc_opc_negx(PPC_CPU_State*); +void ppc_opc_norx(PPC_CPU_State*); -void ppc_opc_rlwimix(); -void ppc_opc_rlwinmx(); -void ppc_opc_rlwnmx(); +void ppc_opc_orx(PPC_CPU_State*); +void ppc_opc_orcx(PPC_CPU_State*); +void ppc_opc_ori(PPC_CPU_State*); +void ppc_opc_oris(PPC_CPU_State*); -void ppc_opc_slwx(); -void ppc_opc_srawx(); -void ppc_opc_srawix(); -void ppc_opc_srwx(); +void ppc_opc_rlwimix(PPC_CPU_State*); +void ppc_opc_rlwinmx(PPC_CPU_State*); +void ppc_opc_rlwnmx(PPC_CPU_State*); -void ppc_opc_subfx(); -void ppc_opc_subfcx(); -void ppc_opc_subfex(); -void ppc_opc_subfic(); -void ppc_opc_subfmex(); -void ppc_opc_subfzex(); +void ppc_opc_slwx(PPC_CPU_State*); +void ppc_opc_srawx(PPC_CPU_State*); +void ppc_opc_srawix(PPC_CPU_State*); +void ppc_opc_srwx(PPC_CPU_State*); -void ppc_opc_xorx(); -void ppc_opc_xori(); -void ppc_opc_xoris(); +void ppc_opc_subfx(PPC_CPU_State*); +void ppc_opc_subfcx(PPC_CPU_State*); +void ppc_opc_subfex(PPC_CPU_State*); +void ppc_opc_subfic(PPC_CPU_State*); +void ppc_opc_subfmex(PPC_CPU_State*); +void ppc_opc_subfzex(PPC_CPU_State*); + +void ppc_opc_xorx(PPC_CPU_State*); +void ppc_opc_xori(PPC_CPU_State*); +void ppc_opc_xoris(PPC_CPU_State*); #endif Index: ppc_cpu.cc =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu_generic/ppc_cpu.cc,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- ppc_cpu.cc 14 Mar 2005 18:47:06 -0000 1.10 +++ ppc_cpu.cc 14 Mar 2005 22:55:11 -0000 1.11 @@ -29,6 +29,7 @@ #include "cpu/debug.h" #include "info.h" #include "io/pic/pic.h" +#include "loader/spmalloc.h" #ifdef PEARPC #include "debug/debugger.h" #endif @@ -40,9 +41,6 @@ #include "ppc_mmu.h" #include "ppc_tools.h" -//#include "io/graphic/gcard.h" - -PPC_CPU_State gCPU; #ifdef PEARPC Debugger *gDebugger; #endif @@ -55,17 +53,17 @@ uint32 gBreakpoint2 = 0xc017a4f4&0; bool activate = false; -static inline void ppc_debug_hook() +static inline void ppc_debug_hook(PPC_CPU_State *gCPU) { - if (gCPU.pc == gBreakpoint) { + if (gCPU->pc == gBreakpoint) { gSinglestep = true; // SINGLESTEP("breakpoint 1"); } - if (gCPU.pc == gBreakpoint2) { + if (gCPU->pc == gBreakpoint2) { SINGLESTEP("breakpoint 2"); } -// if (gCPU.pc == gBreakpoint3 && gCPU.gpr[5]==0x100004ec) { -/* if (gCPU.pc == gBreakpoint3) { +// if (gCPU->pc == gBreakpoint3 && gCPU->gpr[5]==0x100004ec) { +/* if (gCPU->pc == gBreakpoint3) { activate = true; SINGLESTEP("breakpoint 3"); }*/ @@ -78,27 +76,27 @@ sys_mutex exception_mutex; -void ppc_cpu_atomic_raise_ext_exception() +void ppc_cpu_atomic_raise_ext_exception(PPC_CPU_State *gCPU) { sys_lock_mutex(exception_mutex); - gCPU.ext_exception = true; - gCPU.exception_pending = true; + gCPU->ext_exception = true; + gCPU->exception_pending = true; sys_unlock_mutex(exception_mutex); } -void ppc_cpu_atomic_cancel_ext_exception() +void ppc_cpu_atomic_cancel_ext_exception(PPC_CPU_State *gCPU) { sys_lock_mutex(exception_mutex); - gCPU.ext_exception = false; - if (!gCPU.dec_exception) gCPU.exception_pending = false; + gCPU->ext_exception = false; + if (!gCPU->dec_exception) gCPU->exception_pending = false; sys_unlock_mutex(exception_mutex); } -void ppc_cpu_atomic_raise_dec_exception() +void ppc_cpu_atomic_raise_dec_exception(PPC_CPU_State *gCPU) { sys_lock_mutex(exception_mutex); - gCPU.dec_exception = true; - gCPU.exception_pending = true; + gCPU->dec_exception = true; + gCPU->exception_pending = true; sys_unlock_mutex(exception_mutex); } @@ -106,15 +104,18 @@ { } -void ppc_cpu_run() +void *ppc_cpu_run(void *p) { + + PPC_CPU_State *gCPU = (PPC_CPU_State*)p; + #ifdef PEARPC gDebugger = new Debugger(); gDebugger->mAlwaysShowRegs = true; #endif - PPC_CPU_TRACE("execution started at %08x\n", gCPU.pc); + PPC_CPU_TRACE("execution started at %08x\n", gCPU->pc); int ops=0; - gCPU.effective_code_page = 0xffffffff; + gCPU->effective_code_page = 0xffffffff; // ppc_fpu_test(); // return; while (true) { @@ -122,63 +123,64 @@ #ifdef DEBUG // BEGIN MIST - for (i=0; i<32; i++) { - printf("r%02i: %08x ", i, gCPU.gpr[i]); +/* for (i=0; i<32; i++) { + printf("r%02i: %08x ", i, gCPU->gpr[i]); if (!((i+1) & 7)) printf("\n"); } - printf("pc: %08x lr: %08x opc: %08x\n", gCPU.pc, gCPU.lr, gCPU.current_opc);//MIST + printf("pc: %08x lr: %08x opc: %08x\n", gCPU->pc, gCPU->lr, gCPU->current_opc);//MIST printf("----------\n"); +*/ // END MIST #endif - gCPU.npc = gCPU.pc+4; + gCPU->npc = gCPU->pc+4; #ifdef PEARPC - if ((gCPU.pc & ~0xfff) == gCPU.effective_code_page) { - gCPU.current_opc = ppc_word_to_BE(*((uint32*)(&gCPU.physical_code_page[gCPU.pc & 0xfff]))); + if ((gCPU->pc & ~0xfff) == gCPU->effective_code_page) { + gCPU->current_opc = ppc_word_to_BE(*((uint32*)(&gCPU->physical_code_page[gCPU->pc & 0xfff]))); ppc_debug_hook(); } else { int ret; - if ((ret = ppc_direct_effective_memory_handle_code(gCPU.pc & ~0xfff, gCPU.physical_code_page))) { + if ((ret = ppc_direct_effective_memory_handle_code(gCPU->pc & ~0xfff, gCPU->physical_code_page))) { if (ret == PPC_MMU_EXC) { - gCPU.pc = gCPU.npc; + gCPU->pc = gCPU->npc; continue; } else { PPC_CPU_ERR("?\n"); } } - gCPU.effective_code_page = gCPU.pc & ~0xfff; + gCPU->effective_code_page = gCPU->pc & ~0xfff; continue; } #else //printf("X\n");//MIST -// gCPU.current_opc = ppc_word_to_BE(*((uint32*)(gMemory+gCPU.pc))); - ppc_read_physical_word(gCPU.pc, gCPU.current_opc); -// printf("opcode: %08x\n", gCPU.current_opc); +// gCPU->current_opc = ppc_word_to_BE(*((uint32*)(gMemory+gCPU->pc))); + ppc_read_physical_word(gCPU->pc, gCPU->current_opc); +// printf("opcode: %08x\n", gCPU->current_opc); #endif // printf("Executing...\n"); //MIST - ppc_exec_opc(); + ppc_exec_opc(gCPU); #ifndef PEARPC - if (gCPU.npc == 0xdeadbeec) return; + if (gCPU->npc == 0xdeadbeec) return NULL; #endif ops++; - gCPU.ptb++; - if (gCPU.pdec == 0) { - gCPU.exception_pending = true; - gCPU.dec_exception = true; - gCPU.pdec=0xffffffff*TB_TO_PTB_FACTOR; + gCPU->ptb++; + if (gCPU->pdec == 0) { + gCPU->exception_pending = true; + gCPU->dec_exception = true; + gCPU->pdec=0xffffffff*TB_TO_PTB_FACTOR; } else { - gCPU.pdec--; + gCPU->pdec--; } if ((ops & 0x3ffff)==0) { /* if (pic_check_interrupt()) { - gCPU.exception_pending = true; - gCPU.ext_exception = true; + gCPU->exception_pending = true; + gCPU->ext_exception = true; }*/ if ((ops & 0x0fffff)==0) { // uint32 j=0; // ppc_read_effective_word(0xc046b2f8, j); #ifdef PEARPC - ht_printf("@%08x (%d ops) pdec: %08x lr: %08x\r", gCPU.pc, ops, gCPU.pdec, gCPU.lr); + ht_printf("@%08x (%d ops) pdec: %08x lr: %08x\r", gCPU->pc, ops, gCPU->pdec, gCPU->lr); #endif #if 0 extern uint32 PIC_enable_low; @@ -203,29 +205,29 @@ } } - gCPU.pc = gCPU.npc; + gCPU->pc = gCPU->npc; - if (gCPU.exception_pending) { - if (gCPU.stop_exception) { - gCPU.stop_exception = false; - if (!gCPU.dec_exception && !gCPU.ext_exception) gCPU.exception_pending = false; + if (gCPU->exception_pending) { + if (gCPU->stop_exception) { + gCPU->stop_exception = false; + if (!gCPU->dec_exception && !gCPU->ext_exception) gCPU->exception_pending = false; break; } - if (gCPU.msr & MSR_EE) { + if (gCPU->msr & MSR_EE) { sys_lock_mutex(exception_mutex); - if (gCPU.ext_exception) { - ppc_exception(PPC_EXC_EXT_INT); - gCPU.ext_exception = false; - gCPU.pc = gCPU.npc; - if (!gCPU.dec_exception) gCPU.exception_pending = false; + if (gCPU->ext_exception) { + ppc_exception(gCPU, PPC_EXC_EXT_INT); + gCPU->ext_exception = false; + gCPU->pc = gCPU->npc; + if (!gCPU->dec_exception) gCPU->exception_pending = false; sys_unlock_mutex(exception_mutex); continue; } - if (gCPU.dec_exception) { - ppc_exception(PPC_EXC_DEC); - gCPU.dec_exception = false; - gCPU.pc = gCPU.npc; - gCPU.exception_pending = false; + if (gCPU->dec_exception) { + ppc_exception(gCPU, PPC_EXC_DEC); + gCPU->dec_exception = false; + gCPU->pc = gCPU->npc; + gCPU->exception_pending = false; sys_unlock_mutex(exception_mutex); continue; } @@ -234,24 +236,31 @@ } } #ifdef PPC_CPU_ENABLE_SINGLESTEP - if (gCPU.msr & MSR_SE) { - if (gCPU.singlestep_ignore) { - gCPU.singlestep_ignore = false; + if (gCPU->msr & MSR_SE) { + if (gCPU->singlestep_ignore) { + gCPU->singlestep_ignore = false; } else { - ppc_exception(PPC_EXC_TRACE2); - gCPU.pc = gCPU.npc; + ppc_exception(gCPU, PPC_EXC_TRACE2); + gCPU->pc = gCPU->npc; continue; } } #endif } + + return NULL; } -void ppc_cpu_stop() +void ppc_cpu_run_threaded(PPC_CPU_State *gCPU) +{ + pthread_create(&gCPU->thread, NULL, ppc_cpu_run, (void*)gCPU); +} + +void ppc_cpu_stop(PPC_CPU_State *gCPU) { sys_lock_mutex(exception_mutex); - gCPU.stop_exception = true; - gCPU.exception_pending = true; + gCPU->stop_exception = true; + gCPU->exception_pending = true; sys_unlock_mutex(exception_mutex); } @@ -276,43 +285,47 @@ PPC_CPU_ERR("machine check exception\n"); } +/* The following functions are unnecessary with SoftPear's threaded CPU model uint32 ppc_cpu_get_gpr(int cpu, int i) { - return gCPU.gpr[i]; + return gCPU->gpr[i]; } void ppc_cpu_set_gpr(int cpu, int i, uint32 newvalue) { - gCPU.gpr[i] = newvalue; + gCPU->gpr[i] = newvalue; } void ppc_cpu_set_msr(int cpu, uint32 newvalue) { - gCPU.msr = newvalue; + gCPU->msr = newvalue; } void ppc_cpu_set_pc(int cpu, uint32 newvalue) { - gCPU.pc = newvalue; + gCPU->pc = newvalue; } uint32 ppc_cpu_get_pc(int cpu) { - return gCPU.pc; + return gCPU->pc; } uint32 ppc_cpu_get_pvr(int cpu) { - return gCPU.pvr; + return gCPU->pvr; } +*/ +/* void ppc_cpu_map_framebuffer(uint32 pa, uint32 ea) { // use BAT for framebuffer - gCPU.dbatu[0] = ea|(7<<2)|0x3; - gCPU.dbat_bl17[0] = ~(BATU_BL(gCPU.dbatu[0])<<17); - gCPU.dbatl[0] = pa; + gCPU->dbatu[0] = ea|(7<<2)|0x3; + gCPU->dbat_bl17[0] = ~(BATU_BL(gCPU->dbatu[0])<<17); + gCPU->dbatl[0] = pa; } +*/ void ppc_set_singlestep_v(bool v, const char *file, int line, const char *format, ...) { @@ -336,20 +349,42 @@ #include "configparser.h" #endif -bool ppc_cpu_init() +PPC_CPU_State *ppc_cpu_init() { - memset(&gCPU, 0, sizeof gCPU); + PPC_CPU_State *gCPU = (PPC_CPU_State*)spmalloc(sizeof(PPC_CPU_State)); + if(!gCPU) + return NULL; + + memset(gCPU, 0, sizeof gCPU); #ifdef PEARPC - gCPU.pvr = gConfig->getConfigInt(CPU_KEY_PVR); + gCPU->pvr = gConfig->getConfigInt(CPU_KEY_PVR); #endif - gCPU.msr = MSR_FP; + +#define STACK_SIZE 1024*1024 + gCPU->stack = (byte*) spmalloc(STACK_SIZE); + byte *stack_end = gCPU->stack + STACK_SIZE; + /* the stack pointer will be initialized to the top of stack + (some bytes will be kept free) + gMemory will be subtracted, because every read access will + add gMemory in order to convert guest to host addresses + */ + gCPU->gpr[1] = (int)(stack_end-32) - (int)gMemory; + + gCPU->lr = 0xdeadbeef; // will be recognized as return address by the interpreter + + gCPU->msr = MSR_FP; ppc_dec_init(); // initialize srs (mostly for prom) for (int i=0; i<16; i++) { - gCPU.sr[i] = 0x2aa*i; + gCPU->sr[i] = 0x2aa*i; } sys_create_mutex(&exception_mutex); - return true; + return gCPU; +} + +void ppc_cpu_deinit(PPC_CPU_State *gCPU) { + spfree(gCPU->stack); + spfree(gCPU); } void ppc_cpu_init_config() Index: ppc_cpu.h =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu_generic/ppc_cpu.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ppc_cpu.h 16 Nov 2004 22:50:18 -0000 1.1.1.1 +++ ppc_cpu.h 14 Mar 2005 22:55:11 -0000 1.2 @@ -22,6 +22,7 @@ #define __PPC_CPU_H__ #include <stddef.h> +#include <pthread.h> #include "system/types.h" #define PPC_MHz(v) ((v)*1000*1000) @@ -95,10 +96,15 @@ byte *physical_code_page; uint64 pdec; // more precise version of dec uint64 ptb; // more precise version of tb - + + // stack reference for freeing stack associated with this CPU + byte *stack; + + // thread-reference + pthread_t thread; }; -extern PPC_CPU_State gCPU; +typedef struct PPC_CPU_State PPC_CPU_State; /* cr: .67 @@ -441,8 +447,8 @@ #define HID0_nopti 31 #define HID0_noptim 0x00000001 -void ppc_cpu_atomic_raise_ext_exception(); -void ppc_cpu_atomic_cancel_ext_exception(); +void ppc_cpu_atomic_raise_ext_exception(PPC_CPU_State*); +void ppc_cpu_atomic_cancel_ext_exception(PPC_CPU_State*); extern uint32 gBreakpoint; extern uint32 gBreakpoint2; Index: ppc_dec.cc =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu_generic/ppc_dec.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ppc_dec.cc 16 Dec 2004 21:08:01 -0000 1.3 +++ ppc_dec.cc 14 Mar 2005 22:55:11 -0000 1.4 @@ -35,19 +35,19 @@ #include "loader/nativelib.h" #include "stdlib.h" -static void ppc_opc_invalid() +static void ppc_opc_invalid(PPC_CPU_State *gCPU) { #ifdef PEARPC - if (gCPU.pc == gPromOSIEntry && gCPU.current_opc == PROM_MAGIC_OPCODE) { + if (gCPU->pc == gPromOSIEntry && gCPU->current_opc == PROM_MAGIC_OPCODE) { call_prom_osi(); return; } #endif - if (gCPU.current_opc == 0x00333301) { + if (gCPU->current_opc == 0x00333301) { // memset(r3, r4, r5) - uint32 dest = gCPU.gpr[3]; - uint32 c = gCPU.gpr[4]; - uint32 size = gCPU.gpr[5]; + uint32 dest = gCPU->gpr[3]; + uint32 c = gCPU->gpr[4]; + uint32 size = gCPU->gpr[5]; if (dest & 0xfff) { byte *dst; ppc_direct_effective_memory_handle(dest, dst); @@ -68,14 +68,14 @@ ppc_direct_effective_memory_handle(dest, dst); memset(dst, c, size); } - gCPU.pc = gCPU.npc; + gCPU->pc = gCPU->npc; return; } - if (gCPU.current_opc == 0x00333302) { + if (gCPU->current_opc == 0x00333302) { // memcpy - uint32 dest = gCPU.gpr[3]; - uint32 src = gCPU.gpr[4]; - uint32 size = gCPU.gpr[5]; + uint32 dest = gCPU->gpr[3]; + uint32 src = gCPU->gpr[4]; + uint32 size = gCPU->gpr[5]; byte *d, *s; ppc_direct_effective_memory_handle(dest, d); ppc_direct_effective_memory_handle(src, s); @@ -85,54 +85,54 @@ *d = *s; src++; dest++; d++; s++; } - gCPU.pc = gCPU.npc; + gCPU->pc = gCPU->npc; return; } - if ((gCPU.current_opc & 0xffff0000) == 0x08000000) { - nativelib_execute(gCPU.current_opc & 0xffff); + if ((gCPU->current_opc & 0xffff0000) == 0x08000000) { + nativelib_execute(gCPU->current_opc & 0xffff, gCPU); return; } - printf("\nunknown instruction: %08x\n", gCPU.current_opc); + printf("\nunknown instruction: %08x\n", gCPU->current_opc); exit(1); //SINGLESTEP("unknown instruction\n"); } // main opcode 19 -static void ppc_opc_group_1() +static void ppc_opc_group_1(PPC_CPU_State *gCPU) { - uint32 ext = PPC_OPC_EXT(gCPU.current_opc); + uint32 ext = PPC_OPC_EXT(gCPU->current_opc); if (ext & 1) { // crxxx if (ext <= 225) { switch (ext) { - case 33: ppc_opc_crnor(); return; - case 129: ppc_opc_crandc(); return; - case 193: ppc_opc_crxor(); return; - case 225: ppc_opc_crnand(); return; + case 33: ppc_opc_crnor(gCPU); return; + case 129: ppc_opc_crandc(gCPU); return; + case 193: ppc_opc_crxor(gCPU); return; + case 225: ppc_opc_crnand(gCPU); return; } } else { switch (ext) { - case 257: ppc_opc_crand(); return; - case 289: ppc_opc_creqv(); return; - case 417: ppc_opc_crorc(); return; - case 449: ppc_opc_cror(); return; + case 257: ppc_opc_crand(gCPU); return; + case 289: ppc_opc_creqv(gCPU); return; + case 417: ppc_opc_crorc(gCPU); return; + case 449: ppc_opc_cror(gCPU); return; } } } else if (ext & (1<<9)) { // bcctrx if (ext == 528) { - ppc_opc_bcctrx(); + ppc_opc_bcctrx(gCPU); return; } } else { switch (ext) { - case 16: ppc_opc_bclrx(); return; - case 0: ppc_opc_mcrf(); return; - case 50: ppc_opc_rfi(); return; - case 150: ppc_opc_isync(); return; + case 16: ppc_opc_bclrx(gCPU); return; + case 0: ppc_opc_mcrf(gCPU); return; + case 50: ppc_opc_rfi(gCPU); return; + case 150: ppc_opc_isync(gCPU); return; } } - ppc_opc_invalid(); + ppc_opc_invalid(gCPU); } ppc_opc_function ppc_opc_table_group2[1015]; @@ -240,81 +240,81 @@ } // main opcode 31 -static void ppc_opc_group_2() +static void ppc_opc_group_2(PPC_CPU_State *gCPU) { - uint32 ext = PPC_OPC_EXT(gCPU.current_opc); + uint32 ext = PPC_OPC_EXT(gCPU->current_opc); if (ext >= (sizeof ppc_opc_table_group2 / sizeof ppc_opc_table_group2[0])) { - ppc_opc_invalid(); + ppc_opc_invalid(gCPU); } - ppc_opc_table_group2[ext](); + ppc_opc_table_group2[ext](gCPU); } // main opcode 59 -static void ppc_opc_group_f1() +static void ppc_opc_group_f1(PPC_CPU_State *gCPU) { - if ((gCPU.msr & MSR_FP) == 0) { - ppc_exception(PPC_EXC_NO_FPU); + if ((gCPU->msr & MSR_FP) == 0) { + ppc_exception(gCPU, PPC_EXC_NO_FPU); return; } - uint32 ext = PPC_OPC_EXT(gCPU.current_opc); + uint32 ext = PPC_OPC_EXT(gCPU->current_opc); switch (ext & 0x1f) { - case 18: ppc_opc_fdivsx(); return; - case 20: ppc_opc_fsubsx(); return; - case 21: ppc_opc_faddsx(); return; - case 22: ppc_opc_fsqrtsx(); return; - case 24: ppc_opc_fresx(); return; - case 25: ppc_opc_fmulsx(); return; - case 28: ppc_opc_fmsubsx(); return; - case 29: ppc_opc_fmaddsx(); return; - case 30: ppc_opc_fnmsubsx(); return; - case 31: ppc_opc_fnmaddsx(); return; + case 18: ppc_opc_fdivsx(gCPU); return; + case 20: ppc_opc_fsubsx(gCPU); return; + case 21: ppc_opc_faddsx(gCPU); return; + case 22: ppc_opc_fsqrtsx(gCPU); return; + case 24: ppc_opc_fresx(gCPU); return; + case 25: ppc_opc_fmulsx(gCPU); return; + case 28: ppc_opc_fmsubsx(gCPU); return; + case 29: ppc_opc_fmaddsx(gCPU); return; + case 30: ppc_opc_fnmsubsx(gCPU); return; + case 31: ppc_opc_fnmaddsx(gCPU); return; } - ppc_opc_invalid(); + ppc_opc_invalid(gCPU); } // main opcode 63 -static void ppc_opc_group_f2() +static void ppc_opc_group_f2(PPC_CPU_State *gCPU) { - if ((gCPU.msr & MSR_FP) == 0) { - ppc_exception(PPC_EXC_NO_FPU); + if ((gCPU->msr & MSR_FP) == 0) { + ppc_exception(gCPU, PPC_EXC_NO_FPU); return; } - uint32 ext = PPC_OPC_EXT(gCPU.current_opc); + uint32 ext = PPC_OPC_EXT(gCPU->current_opc); if (ext & 16) { switch (ext & 0x1f) { - case 18: ppc_opc_fdivx(); return; - case 20: ppc_opc_fsubx(); return; - case 21: ppc_opc_faddx(); return; - case 22: ppc_opc_fsqrtx(); return; - case 23: ppc_opc_fselx(); return; - case 25: ppc_opc_fmulx(); return; - case 26: ppc_opc_frsqrtex(); return; - case 28: ppc_opc_fmsubx(); return; - case 29: ppc_opc_fmaddx(); return; - case 30: ppc_opc_fnmsubx(); return; - case 31: ppc_opc_fnmaddx(); return; + case 18: ppc_opc_fdivx(gCPU); return; + case 20: ppc_opc_fsubx(gCPU); return; + case 21: ppc_opc_faddx(gCPU); return; + case 22: ppc_opc_fsqrtx(gCPU); return; + case 23: ppc_opc_fselx(gCPU); return; + case 25: ppc_opc_fmulx(gCPU); return; + case 26: ppc_opc_frsqrtex(gCPU); return; + case 28: ppc_opc_fmsubx(gCPU); return; + case 29: ppc_opc_fmaddx(gCPU); return; + case 30: ppc_opc_fnmsubx(gCPU); return; + case 31: ppc_opc_fnmaddx(gCPU); return; } } else { switch (ext) { - case 0: ppc_opc_fcmpu(); return; - case 12: ppc_opc_frspx(); return; - case 14: ppc_opc_fctiwx(); return; - case 15: ppc_opc_fctiwzx(); return; + case 0: ppc_opc_fcmpu(gCPU); return; + case 12: ppc_opc_frspx(gCPU); return; + case 14: ppc_opc_fctiwx(gCPU); return; + case 15: ppc_opc_fctiwzx(gCPU); return; //-- - case 32: ppc_opc_fcmpo(); return; - case 38: ppc_opc_mtfsb1x(); return; - case 40: ppc_opc_fnegx(); return; - case 64: ppc_opc_mcrfs(); return; - case 70: ppc_opc_mtfsb0x(); return; - case 72: ppc_opc_fmrx(); return; - case 134: ppc_opc_mtfsfix(); return; - case 136: ppc_opc_fnabsx(); return; - case 264: ppc_opc_fabsx(); return; - case 583: ppc_opc_mffsx(); return; - case 711: ppc_opc_mtfsfx(); return; + case 32: ppc_opc_fcmpo(gCPU); return; + case 38: ppc_opc_mtfsb1x(gCPU); return; + case 40: ppc_opc_fnegx(gCPU); return; + case 64: ppc_opc_mcrfs(gCPU); return; + case 70: ppc_opc_mtfsb0x(gCPU); return; + case 72: ppc_opc_fmrx(gCPU); return; + case 134: ppc_opc_mtfsfix(gCPU); return; + case 136: ppc_opc_fnabsx(gCPU); return; + case 264: ppc_opc_fabsx(gCPU); return; + case 583: ppc_opc_mffsx(gCPU); return; + case 711: ppc_opc_mtfsfx(gCPU); return; } } - ppc_opc_invalid(); + ppc_opc_invalid(gCPU); } static ppc_opc_function ppc_opc_table_main[64] = { @@ -384,10 +384,10 @@ &ppc_opc_group_f2, // 63 }; -void FASTCALL ppc_exec_opc() +void FASTCALL ppc_exec_opc(PPC_CPU_State *gCPU) { - uint32 mainopc = PPC_OPC_MAIN(gCPU.current_opc); - ppc_opc_table_main[mainopc](); + uint32 mainopc = PPC_OPC_MAIN(gCPU->current_opc); + ppc_opc_table_main[mainopc](gCPU); } void ppc_dec_init() Index: ppc_dec.h =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu_generic/ppc_dec.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ppc_dec.h 16 Nov 2004 22:50:18 -0000 1.1.1.1 +++ ppc_dec.h 14 Mar 2005 22:55:11 -0000 1.2 @@ -22,11 +22,12 @@ #define __PPC_DEC_H__ #include "system/types.h" +#include "cpu/cpu.h" -void FASTCALL ppc_exec_opc(); +void FASTCALL ppc_exec_opc(PPC_CPU_State*); void ppc_dec_init(); -typedef void (*ppc_opc_function)(); +typedef void (*ppc_opc_function)(PPC_CPU_State*); #define PPC_OPC_ASSERT(v) Index: ppc_exc.cc =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu_generic/ppc_exc.cc,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ppc_exc.cc 16 Nov 2004 22:50:18 -0000 1.1.1.1 +++ ppc_exc.cc 14 Mar 2005 22:55:11 -0000 1.2 @@ -29,71 +29,71 @@ /* * .247 */ -bool FASTCALL ppc_exception(uint32 type, uint32 flags, uint32 a) +bool FASTCALL ppc_exception(PPC_CPU_State *gCPU, uint32 type, uint32 flags, uint32 a) { - if (type != PPC_EXC_DEC) PPC_EXC_TRACE("@%08x: type = %08x (%08x, %08x)\n", gCPU.pc, type, flags, a); + if (type != PPC_EXC_DEC) PPC_EXC_TRACE("@%08x: type = %08x (%08x, %08x)\n", gCPU->pc, type, flags, a); switch (type) { case PPC_EXC_DSI: { // .271 - gCPU.srr[0] = gCPU.pc; - gCPU.srr[1] = gCPU.msr & 0x87c0ffff; - gCPU.dar = a; - gCPU.dsisr = flags; + gCPU->srr[0] = gCPU->pc; + gCPU->srr[1] = gCPU->msr & 0x87c0ffff; + gCPU->dar = a; + gCPU->dsisr = flags; break; } case PPC_EXC_ISI: { // .274 - if (gCPU.pc == 0) { + if (gCPU->pc == 0) { PPC_EXC_WARN("pc == 0 in ISI\n"); SINGLESTEP(""); } - gCPU.srr[0] = gCPU.pc; - gCPU.srr[1] = (gCPU.msr & 0x87c0ffff) | flags; + gCPU->srr[0] = gCPU->pc; + gCPU->srr[1] = (gCPU->msr & 0x87c0ffff) | flags; break; } case PPC_EXC_DEC: { // .284 - gCPU.srr[0] = gCPU.pc; - gCPU.srr[1] = gCPU.msr & 0x87c0ffff; + gCPU->srr[0] = gCPU->pc; + gCPU->srr[1] = gCPU->msr & 0x87c0ffff; break; } case PPC_EXC_EXT_INT: { - gCPU.srr[0] = gCPU.pc; - gCPU.srr[1] = gCPU.msr & 0x87c0ffff; + gCPU->srr[0] = gCPU->pc; + gCPU->srr[1] = gCPU->msr & 0x87c0ffff; break; } case PPC_EXC_SC: { // .285 - gCPU.srr[0] = gCPU.npc; - gCPU.srr[1] = gCPU.msr & 0x87c0ffff; + gCPU->srr[0] = gCPU->npc; + gCPU->srr[1] = gCPU->msr & 0x87c0ffff; break; } case PPC_EXC_NO_FPU: { // .284 - gCPU.srr[0] = gCPU.pc; - gCPU.srr[1] = gCPU.msr & 0x87c0ffff; + gCPU->srr[0] = gCPU->pc; + gCPU->srr[1] = gCPU->msr & 0x87c0ffff; break; } case PPC_EXC_PROGRAM: { // .283 if (flags & PPC_EXC_PROGRAM_NEXT) { - gCPU.srr[0] = gCPU.npc; + gCPU->srr[0] = gCPU->npc; } else { - gCPU.srr[0] = gCPU.pc; + gCPU->srr[0] = gCPU->pc; } - gCPU.srr[1] = (gCPU.msr & 0x87c0ffff) | flags; + gCPU->srr[1] = (gCPU->msr & 0x87c0ffff) | flags; break; } case PPC_EXC_FLOAT_ASSIST: { // .288 - gCPU.srr[0] = gCPU.pc; - gCPU.srr[1] = gCPU.msr & 0x87c0ffff; + gCPU->srr[0] = gCPU->pc; + gCPU->srr[1] = gCPU->msr & 0x87c0ffff; break; } case PPC_EXC_MACHINE_CHECK: { // .270 - if (!(gCPU.msr & MSR_ME)) { + if (!(gCPU->msr & MSR_ME)) { PPC_EXC_ERR("machine check exception and MSR[ME]=0.\n"); } - gCPU.srr[0] = gCPU.pc; - gCPU.srr[1] = (gCPU.msr & 0x87c0ffff) | MSR_RI; + gCPU->srr[0] = gCPU->pc; + gCPU->srr[1] = (gCPU->msr & 0x87c0ffff) | MSR_RI; break; } case PPC_EXC_TRACE2: { // .286 - gCPU.srr[0] = gCPU.pc; - gCPU.srr[1] = gCPU.msr & 0x87c0ffff; + gCPU->srr[0] = gCPU->pc; + gCPU->srr[1] = gCPU->msr & 0x87c0ffff; break; } default: @@ -101,17 +101,17 @@ return false; } ppc_mmu_tlb_invalidate(); - gCPU.msr = 0; - gCPU.npc = type; + gCPU->msr = 0; + gCPU->npc = type; return true; } -void ppc_cpu_raise_ext_exception() +void ppc_cpu_raise_ext_exception(PPC_CPU_State *gCPU) { - ppc_cpu_atomic_raise_ext_exception(); + ppc_cpu_atomic_raise_ext_exception(gCPU); } -void ppc_cpu_cancel_ext_exception() +void ppc_cpu_cancel_ext_exception(PPC_CPU_State *gCPU) { - ppc_cpu_atomic_cancel_ext_exception(); + ppc_cpu_atomic_cancel_ext_exception(gCPU); } Index: ppc_exc.h =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu_generic/ppc_exc.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ppc_exc.h 16 Nov 2004 22:50:18 -0000 1.1.1.1 +++ ppc_exc.h 14 Mar 2005 22:55:11 -0000 1.2 @@ -22,6 +22,7 @@ #define __PPC_EXC_H__ #include "system/types.h" +#include "cpu/cpu.h" /* * .250 @@ -65,9 +66,9 @@ */ #define PPC_EXC_PROGRAM_NEXT (1<<16) -bool FASTCALL ppc_exception(uint32 type=0, uint32 flags=0, uint32 a=0); -void ppc_cpu_raise_ext_exception(); -void ppc_cpu_cancel_ext_exception(); +bool FASTCALL ppc_exception(PPC_CPU_State*, uint32 type=0, uint32 flags=0, uint32 a=0); +void ppc_cpu_raise_ext_exception(PPC_CPU_State*); +void ppc_cpu_cancel_ext_exception(PPC_CPU_State*); #endif Index: ppc_fpu.cc =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu_generic/ppc_fpu.cc,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ppc_fpu.cc 16 Nov 2004 22:50:33 -0000 1.1.1.1 +++ ppc_fpu.cc 14 Mar 2005 22:55:11 -0000 1.2 @@ -28,7 +28,7 @@ #define PPC_FPR_TYPE2(a,b) (((a)<<8)|(b)) -inline void ppc_fpu_add(ppc_double &res, ppc_double &a, ppc_double &b) +inline void ppc_fpu_add(ppc_double &res, ppc_double &a, ppc_double &b, PPC_CPU_State *gCPU) { switch (PPC_FPR_TYPE2(a.type, b.type)) { case PPC_FPR_TYPE2(ppc_fpr_norm, ppc_fpr_norm): { @@ -65,7 +65,7 @@ res.s = a.s; res.m = a.m - b.m; if (!res.m) { - if (FPSCR_RN(gCPU.fpscr) == FPSCR_RN_MINF) { + if (FPSCR_RN(gCPU->fpscr) == FPSCR_RN_MINF) { res.s |= b.s; } else { res.s &= b.s; @@ -180,7 +180,7 @@ } // res has 107 significant bits. a, b have 106 significant bits each. -inline void ppc_fpu_add_quadro(ppc_quadro &res, ppc_quadro &a, ppc_quadro &b) +inline void ppc_fpu_add_quadro(ppc_quadro &res, ppc_quadro &a, ppc_quadro &b, PPC_CPU_State *gCPU) { // treat as 107 bit mantissa if (a.type == ppc_fpr_norm) ppc_fpu_quadro_mshl(a, 1); @@ -242,7 +242,7 @@ } } if (!cmp) { - if (FPSCR_RN(gCPU.fpscr) == FPSCR_RN_MINF) { + if (FPSCR_RN(gCPU->fpscr) == FPSCR_RN_MINF) { res.s |= b.s; } else { res.s &= b.s; @@ -496,7 +496,7 @@ // button: the top line is not rendered correctly. This works with the jitc_x86 // FPU however... inline void ppc_fpu_mul_add(ppc_double &res, ppc_double &m1, ppc_double &m2, - ppc_double &s) + ppc_double &s, PPC_CPU_State *gCPU) { ppc_quadro p; /* ht_printf("m1 = %d * %016qx * 2^%d, %s\n", m1.s, m1.m, m1.e, @@ -522,7 +522,7 @@ ppc_fpu_get_fpr_type(q.type));*/ // now we must add p, q. ppc_quadro x; - ppc_fpu_add_quadro(x, p, q); + ppc_fpu_add_quadro(x, p, q, gCPU); // x = [107] /* ht_printf("x = %d * %016qx%016qx * 2^%d %s\n", x.s, x.m0, x.m1, x.e, ppc_fpu_get_fpr_type(x.type));*/ @@ -600,13 +600,13 @@ } } -inline void ppc_fpu_sqrt(ppc_double &D, const ppc_double &B) +inline void ppc_fpu_sqrt(ppc_double &D, const ppc_double &B, PPC_CPU_State *gCPU) { switch (B.type) { case ppc_fpr_norm: if (B.s) { D.type = ppc_fpr_NaN; - gCPU.fpscr |= FPSCR_VXSQRT; + gCPU->fpscr |= FPSCR_VXSQRT; break; } // D := 1/2(D_old + B/D_old) @@ -616,7 +616,7 @@ ppc_double D_old = D; ppc_double B_div_D_old; ppc_fpu_div(B_div_D_old, B, D_old); - ppc_fpu_add(D, D_old, B_div_D_old); + ppc_fpu_add(D, D_old, B_div_D_old, gCPU); D.e--; /* uint64 e; @@ -632,7 +632,7 @@ case ppc_fpr_Inf: if (B.s) { D.type = ppc_fpr_NaN; - gCPU.fpscr |= FPSCR_VXSQRT; + gCPU->fpscr |= FPSCR_VXSQRT; } else { D.type = ppc_fpr_Inf; D.s = 0; @@ -644,7 +644,7 @@ } } -void ppc_fpu_test() +void ppc_fpu_test(PPC_CPU_State *gCPU) { ppc_double A, B, C; double a, b, c; @@ -661,13 +661,13 @@ a = ppc_fpu_get_double(A); b = ppc_fpu_get_double(B); printf("%f + %f = \n", a, b); - ppc_fpu_add(C, A, B); + ppc_fpu_add(C, A, B, gCPU); uint64 d; uint32 s; - ppc_fpu_pack_double_as_single(C, d); + ppc_fpu_pack_double_as_single(C, d, gCPU); ht_printf("%064qb\n", d); ppc_fpu_unpack_double(C, d); - ppc_fpu_pack_single(C, s); + ppc_fpu_pack_single(C, s, gCPU); ht_printf("single: %032b\n", s); ppc_single Cs; ppc_fpu_unpack_single(Cs, s); @@ -734,13 +734,13 @@ * fabsx Floating Absolute Value * .484 */ -void ppc_opc_fabsx() +void ppc_opc_fabsx(PPC_CPU_State *gCPU) { int frD, frA, frB; - PPC_OPC_TEMPL_X(gCPU.current_opc, frD, frA, frB); + PPC_OPC_TEMPL_X(gCPU->current_opc, frD, frA, frB); PPC_OPC_ASSERT(frA==0); - gCPU.fpr[frD] = gCPU.fpr[frB] & ~FPU_SIGN_BIT; - if (gCPU.current_opc & PPC_OPC_Rc) { + gCPU->fpr[frD] = gCPU->fpr[frB] & ~FPU_SIGN_BIT; + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fabs.\n"); } @@ -749,20 +749,20 @@ * faddx Floating Add (Double-Precision) * .485 */ -void ppc_opc_faddx() +void ppc_opc_faddx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); PPC_OPC_ASSERT(frC==0); ppc_double A, B, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); if (A.s != B.s && A.type == ppc_fpr_Inf && B.type == ppc_fpr_Inf) { - gCPU.fpscr |= FPSCR_VXISI; + gCPU->fpscr |= FPSCR_VXISI; } - ppc_fpu_add(D, A, B); - gCPU.fpscr |= ppc_fpu_pack_double(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + ppc_fpu_add(D, A, B, gCPU); + gCPU->fpscr |= ppc_fpu_pack_double(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fadd.\n"); } @@ -771,20 +771,20 @@ * faddx Floating Add Single * .486 */ -void ppc_opc_faddsx() +void ppc_opc_faddsx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); PPC_OPC_ASSERT(frC==0); ppc_double A, B, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); if (A.s != B.s && A.type == ppc_fpr_Inf && B.type == ppc_fpr_Inf) { - gCPU.fpscr |= FPSCR_VXISI; + gCPU->fpscr |= FPSCR_VXISI; } - ppc_fpu_add(D, A, B); - gCPU.fpscr |= ppc_fpu_pack_double_as_single(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + ppc_fpu_add(D, A, B, gCPU); + gCPU->fpscr |= ppc_fpu_pack_double_as_single(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fadds.\n"); } @@ -803,66 +803,66 @@ 0xf0ffffff, 0x0fffffff, }; -void ppc_opc_fcmpo() +void ppc_opc_fcmpo(PPC_CPU_State *gCPU) { int crfD, frA, frB; - PPC_OPC_TEMPL_X(gCPU.current_opc, crfD, frA, frB); + PPC_OPC_TEMPL_X(gCPU->current_opc, crfD, frA, frB); crfD >>= 2; ppc_double A, B; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); uint32 cmp; if (A.type == ppc_fpr_NaN || B.type == ppc_fpr_NaN) { - gCPU.fpscr |= FPSCR_VXSNAN; - /*if (bla)*/ gCPU.fpscr |= FPSCR_VXVC; + gCPU->fpscr |= FPSCR_VXSNAN; + /*if (bla)*/ gCPU->fpscr |= FPSCR_VXVC; cmp = 1; } else { cmp = ppc_fpu_compare(A, B); } crfD = 7-crfD; - gCPU.fpscr &= ~0x1f000; - gCPU.fpscr |= (cmp << 12); - gCPU.cr &= ppc_fpu_cmp_and_mask[crfD]; - gCPU.cr |= (cmp << (crfD * 4)); + gCPU->fpscr &= ~0x1f000; + gCPU->fpscr |= (cmp << 12); + gCPU->cr &= ppc_fpu_cmp_and_mask[crfD]; + gCPU->cr |= (cmp << (crfD * 4)); } /* * fcmpu Floating Compare Unordered * .489 */ -void ppc_opc_fcmpu() +void ppc_opc_fcmpu(PPC_CPU_State *gCPU) { int crfD, frA, frB; - PPC_OPC_TEMPL_X(gCPU.current_opc, crfD, frA, frB); + PPC_OPC_TEMPL_X(gCPU->current_opc, crfD, frA, frB); crfD >>= 2; ppc_double A, B; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); uint32 cmp; if (A.type == ppc_fpr_NaN || B.type == ppc_fpr_NaN) { - gCPU.fpscr |= FPSCR_VXSNAN; + gCPU->fpscr |= FPSCR_VXSNAN; cmp = 1; } else { cmp = ppc_fpu_compare(A, B); } crfD = 7-crfD; - gCPU.fpscr &= ~0x1f000; - gCPU.fpscr |= (cmp << 12); - gCPU.cr &= ppc_fpu_cmp_and_mask[crfD]; - gCPU.cr |= (cmp << (crfD * 4)); + gCPU->fpscr &= ~0x1f000; + gCPU->fpscr |= (cmp << 12); + gCPU->cr &= ppc_fpu_cmp_and_mask[crfD]; + gCPU->cr |= (cmp << (crfD * 4)); } /* * fctiwx Floating Convert to Integer Word * .492 */ -void ppc_opc_fctiwx() +void ppc_opc_fctiwx(PPC_CPU_State *gCPU) { int frD, frA, frB; - PPC_OPC_TEMPL_X(gCPU.current_opc, frD, frA, frB); + PPC_OPC_TEMPL_X(gCPU->current_opc, frD, frA, frB); PPC_OPC_ASSERT(frA==0); ppc_double B; - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); - gCPU.fpr[frD] = ppc_fpu_double_to_int(B); - if (gCPU.current_opc & PPC_OPC_Rc) { + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); + gCPU->fpr[frD] = ppc_fpu_double_to_int(B, gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fctiw.\n"); } @@ -871,19 +871,19 @@ * fctiwzx Floating Convert to Integer Word with Round toward Zero * .493 */ -void ppc_opc_fctiwzx() +void ppc_opc_fctiwzx(PPC_CPU_State *gCPU) { int frD, frA, frB; - PPC_OPC_TEMPL_X(gCPU.current_opc, frD, frA, frB); + PPC_OPC_TEMPL_X(gCPU->current_opc, frD, frA, frB); PPC_OPC_ASSERT(frA==0); - uint32 oldfpscr = gCPU.fpscr; - gCPU.fpscr &= ~3; - gCPU.fpscr |= 1; + uint32 oldfpscr = gCPU->fpscr; + gCPU->fpscr &= ~3; + gCPU->fpscr |= 1; ppc_double B; - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); - gCPU.fpr[frD] = ppc_fpu_double_to_int(B); - gCPU.fpscr = oldfpscr; - if (gCPU.current_opc & PPC_OPC_Rc) { + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); + gCPU->fpr[frD] = ppc_fpu_double_to_int(B, gCPU); + gCPU->fpscr = oldfpscr; + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fctiwz.\n"); } @@ -892,27 +892,27 @@ * fdivx Floating Divide (Double-Precision) * .494 */ -void ppc_opc_fdivx() +void ppc_opc_fdivx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); PPC_OPC_ASSERT(frC==0); ppc_double A, B, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); if (A.type == ppc_fpr_zero && B.type == ppc_fpr_zero) { - gCPU.fpscr |= FPSCR_VXZDZ; + gCPU->fpscr |= FPSCR_VXZDZ; } if (A.type == ppc_fpr_Inf && B.type == ppc_fpr_Inf) { - gCPU.fpscr |= FPSCR_VXIDI; + gCPU->fpscr |= FPSCR_VXIDI; } if (B.type == ppc_fpr_zero && A.type != ppc_fpr_zero) { // FIXME:: - gCPU.fpscr |= FPSCR_VXIDI; + gCPU->fpscr |= FPSCR_VXIDI; } ppc_fpu_div(D, A, B); - gCPU.fpscr |= ppc_fpu_pack_double(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + gCPU->fpscr |= ppc_fpu_pack_double(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fdiv.\n"); } @@ -921,27 +921,27 @@ * fdivsx Floating Divide Single * .495 */ -void ppc_opc_fdivsx() +void ppc_opc_fdivsx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); PPC_OPC_ASSERT(frC==0); ppc_double A, B, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); if (A.type == ppc_fpr_zero && B.type == ppc_fpr_zero) { - gCPU.fpscr |= FPSCR_VXZDZ; + gCPU->fpscr |= FPSCR_VXZDZ; } if (A.type == ppc_fpr_Inf && B.type == ppc_fpr_Inf) { - gCPU.fpscr |= FPSCR_VXIDI; + gCPU->fpscr |= FPSCR_VXIDI; } if (B.type == ppc_fpr_zero && A.type != ppc_fpr_zero) { // FIXME:: - gCPU.fpscr |= FPSCR_VXIDI; + gCPU->fpscr |= FPSCR_VXIDI; } ppc_fpu_div(D, A, B); - gCPU.fpscr |= ppc_fpu_pack_double_as_single(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + gCPU->fpscr |= ppc_fpu_pack_double_as_single(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fdivs.\n"); } @@ -950,17 +950,17 @@ * fmaddx Floating Multiply-Add (Double-Precision) * .496 */ -void ppc_opc_fmaddx() +void ppc_opc_fmaddx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); ppc_double A, B, C, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); - ppc_fpu_unpack_double(C, gCPU.fpr[frC]); - ppc_fpu_mul_add(D, A, C, B); - gCPU.fpscr |= ppc_fpu_pack_double(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); + ppc_fpu_unpack_double(C, gCPU->fpr[frC]); + ppc_fpu_mul_add(D, A, C, B, gCPU); + gCPU->fpscr |= ppc_fpu_pack_double(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fmadd.\n"); } @@ -969,17 +969,17 @@ * fmaddx Floating Multiply-Add Single * .497 */ -void ppc_opc_fmaddsx() +void ppc_opc_fmaddsx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); ppc_double A, B, C, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); - ppc_fpu_unpack_double(C, gCPU.fpr[frC]); - ppc_fpu_mul_add(D, A, C, B); - gCPU.fpscr |= ppc_fpu_pack_double_as_single(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); + ppc_fpu_unpack_double(C, gCPU->fpr[frC]); + ppc_fpu_mul_add(D, A, C, B, gCPU); + gCPU->fpscr |= ppc_fpu_pack_double_as_single(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fmadds.\n"); } @@ -988,13 +988,13 @@ * fmrx Floating Move Register * .498 */ -void ppc_opc_fmrx() +void ppc_opc_fmrx(PPC_CPU_State *gCPU) { int frD, rA, frB; - PPC_OPC_TEMPL_X(gCPU.current_opc, frD, rA, frB); + PPC_OPC_TEMPL_X(gCPU->current_opc, frD, rA, frB); PPC_OPC_ASSERT(rA==0); - gCPU.fpr[frD] = gCPU.fpr[frB]; - if (gCPU.current_opc & PPC_OPC_Rc) { + gCPU->fpr[frD] = gCPU->fpr[frB]; + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fmr.\n"); } @@ -1003,18 +1003,18 @@ * fmsubx Floating Multiply-Subtract (Double-Precision) * .499 */ -void ppc_opc_fmsubx() +void ppc_opc_fmsubx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); ppc_double A, B, C, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); - ppc_fpu_unpack_double(C, gCPU.fpr[frC]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); + ppc_fpu_unpack_double(C, gCPU->fpr[frC]); B.s ^= 1; - ppc_fpu_mul_add(D, A, C, B); - gCPU.fpscr |= ppc_fpu_pack_double(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + ppc_fpu_mul_add(D, A, C, B, gCPU); + gCPU->fpscr |= ppc_fpu_pack_double(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fmsub.\n"); } @@ -1023,17 +1023,17 @@ * fmsubsx Floating Multiply-Subtract Single * .500 */ -void ppc_opc_fmsubsx() +void ppc_opc_fmsubsx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); ppc_double A, B, C, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); - ppc_fpu_unpack_double(C, gCPU.fpr[frC]); - ppc_fpu_mul_add(D, A, C, B); - gCPU.fpscr |= ppc_fpu_pack_double_as_single(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); + ppc_fpu_unpack_double(C, gCPU->fpr[frC]); + ppc_fpu_mul_add(D, A, C, B, gCPU); + gCPU->fpscr |= ppc_fpu_pack_double_as_single(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fmsubs.\n"); } @@ -1042,22 +1042,22 @@ * fmulx Floating Multipy (Double-Precision) * .501 */ -void ppc_opc_fmulx() +void ppc_opc_fmulx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); PPC_OPC_ASSERT(frB==0); ppc_double A, C, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(C, gCPU.fpr[frC]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(C, gCPU->fpr[frC]); if ((A.type == ppc_fpr_Inf && C.type == ppc_fpr_zero) || (A.type == ppc_fpr_zero && C.type == ppc_fpr_Inf)) { - gCPU.fpscr |= FPSCR_VXIMZ; + gCPU->fpscr |= FPSCR_VXIMZ; } ppc_fpu_mul(D, A, C); - gCPU.fpscr |= ppc_fpu_pack_double(D, gCPU.fpr[frD]); -// *((double*)&gCPU.fpr[frD]) = *((double*)(&gCPU.fpr[frA]))*(*((double*)(&gCPU.fpr[frC]))); - if (gCPU.current_opc & PPC_OPC_Rc) { + gCPU->fpscr |= ppc_fpu_pack_double(D, gCPU->fpr[frD], gCPU); +// *((double*)&gCPU->fpr[frD]) = *((double*)(&gCPU->fpr[frA]))*(*((double*)(&gCPU->fpr[frC]))); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fmul.\n"); } @@ -1066,21 +1066,21 @@ * fmulsx Floating Multipy Single * .502 */ -void ppc_opc_fmulsx() +void ppc_opc_fmulsx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); PPC_OPC_ASSERT(frB==0); ppc_double A, C, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(C, gCPU.fpr[frC]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(C, gCPU->fpr[frC]); if ((A.type == ppc_fpr_Inf && C.type == ppc_fpr_zero) || (A.type == ppc_fpr_zero && C.type == ppc_fpr_Inf)) { - gCPU.fpscr |= FPSCR_VXIMZ; + gCPU->fpscr |= FPSCR_VXIMZ; } ppc_fpu_mul(D, A, C); - gCPU.fpscr |= ppc_fpu_pack_double_as_single(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + gCPU->fpscr |= ppc_fpu_pack_double_as_single(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fmuls.\n"); } @@ -1089,13 +1089,13 @@ * fnabsx Floating Negative Absolute Value * .503 */ -void ppc_opc_fnabsx() +void ppc_opc_fnabsx(PPC_CPU_State *gCPU) { int frD, frA, frB; - PPC_OPC_TEMPL_X(gCPU.current_opc, frD, frA, frB); + PPC_OPC_TEMPL_X(gCPU->current_opc, frD, frA, frB); PPC_OPC_ASSERT(frA==0); - gCPU.fpr[frD] = gCPU.fpr[frB] | FPU_SIGN_BIT; - if (gCPU.current_opc & PPC_OPC_Rc) { + gCPU->fpr[frD] = gCPU->fpr[frB] | FPU_SIGN_BIT; + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fnabs.\n"); } @@ -1104,13 +1104,13 @@ * fnegx Floating Negate * .504 */ -void ppc_opc_fnegx() +void ppc_opc_fnegx(PPC_CPU_State *gCPU) { int frD, frA, frB; - PPC_OPC_TEMPL_X(gCPU.current_opc, frD, frA, frB); + PPC_OPC_TEMPL_X(gCPU->current_opc, frD, frA, frB); PPC_OPC_ASSERT(frA==0); - gCPU.fpr[frD] = gCPU.fpr[frB] ^ FPU_SIGN_BIT; - if (gCPU.current_opc & PPC_OPC_Rc) { + gCPU->fpr[frD] = gCPU->fpr[frB] ^ FPU_SIGN_BIT; + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fneg.\n"); } @@ -1119,18 +1119,18 @@ * fnmaddx Floating Negative Multiply-Add (Double-Precision) * .505 */ -void ppc_opc_fnmaddx() +void ppc_opc_fnmaddx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); ppc_double A, B, C, D/*, E*/; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); - ppc_fpu_unpack_double(C, gCPU.fpr[frC]); - ppc_fpu_mul_add(D, A, C, B); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); + ppc_fpu_unpack_double(C, gCPU->fpr[frC]); + ppc_fpu_mul_add(D, A, C, B, gCPU); D.s ^= 1; - gCPU.fpscr |= ppc_fpu_pack_double(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + gCPU->fpscr |= ppc_fpu_pack_double(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fnmadd.\n"); } @@ -1139,18 +1139,18 @@ * fnmaddsx Floating Negative Multiply-Add Single * .506 */ -void ppc_opc_fnmaddsx() +void ppc_opc_fnmaddsx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); ppc_double A, B, C, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); - ppc_fpu_unpack_double(C, gCPU.fpr[frC]); - ppc_fpu_mul_add(D, A, C, B); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); + ppc_fpu_unpack_double(C, gCPU->fpr[frC]); + ppc_fpu_mul_add(D, A, C, B, gCPU); D.s ^= 1; - gCPU.fpscr |= ppc_fpu_pack_double_as_single(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + gCPU->fpscr |= ppc_fpu_pack_double_as_single(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fnmadds.\n"); } @@ -1159,19 +1159,19 @@ * fnmsubx Floating Negative Multiply-Subtract (Double-Precision) * .507 */ -void ppc_opc_fnmsubx() +void ppc_opc_fnmsubx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); ppc_double A, B, C, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); - ppc_fpu_unpack_double(C, gCPU.fpr[frC]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); + ppc_fpu_unpack_double(C, gCPU->fpr[frC]); B.s ^= 1; - ppc_fpu_mul_add(D, A, C, B); + ppc_fpu_mul_add(D, A, C, B, gCPU); D.s ^= 1; - gCPU.fpscr |= ppc_fpu_pack_double(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + gCPU->fpscr |= ppc_fpu_pack_double(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fnmsub.\n"); } @@ -1180,19 +1180,19 @@ * fnsubsx Floating Negative Multiply-Subtract Single * .508 */ -void ppc_opc_fnmsubsx() +void ppc_opc_fnmsubsx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); ppc_double A, B, C, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); - ppc_fpu_unpack_double(C, gCPU.fpr[frC]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); + ppc_fpu_unpack_double(C, gCPU->fpr[frC]); B.s ^= 1; - ppc_fpu_mul_add(D, A, C, B); + ppc_fpu_mul_add(D, A, C, B, gCPU); D.s ^= 1; - gCPU.fpscr |= ppc_fpu_pack_double_as_single(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + gCPU->fpscr |= ppc_fpu_pack_double_as_single(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fnmsubs.\n"); } @@ -1201,12 +1201,12 @@ * fresx Floating Reciprocal Estimate Single * .509 */ -void ppc_opc_fresx() +void ppc_opc_fresx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); PPC_OPC_ASSERT(frA==0 && frC==0); - if (gCPU.current_opc & PPC_OPC_Rc) { + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fres.\n"); } @@ -1216,15 +1216,15 @@ * frspx Floating Round to Single * .511 */ -void ppc_opc_frspx() +void ppc_opc_frspx(PPC_CPU_State *gCPU) { int frD, frA, frB; - PPC_OPC_TEMPL_X(gCPU.current_opc, frD, frA, frB); + PPC_OPC_TEMPL_X(gCPU->current_opc, frD, frA, frB); PPC_OPC_ASSERT(frA==0); ppc_double B; - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); - gCPU.fpscr |= ppc_fpu_pack_double_as_single(B, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); + gCPU->fpscr |= ppc_fpu_pack_double_as_single(B, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("frsp.\n"); } @@ -1233,21 +1233,21 @@ * frsqrtex Floating Reciprocal Square Root Estimate * .512 */ -void ppc_opc_frsqrtex() +void ppc_opc_frsqrtex(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); PPC_OPC_ASSERT(frA==0 && frC==0); ppc_double B; ppc_double D; ppc_double E; ppc_double Q; - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); - ppc_fpu_sqrt(Q, B); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); + ppc_fpu_sqrt(Q, B, gCPU); E.type = ppc_fpr_norm; E.s = 0; E.e = 0; E.m = 0x80000000000000ULL; ppc_fpu_div(D, E, Q); - gCPU.fpscr |= ppc_fpu_pack_double(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + gCPU->fpscr |= ppc_fpu_pack_double(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("frsqrte.\n"); } @@ -1256,18 +1256,18 @@ * fselx Floating Select * .514 */ -void ppc_opc_fselx() +void ppc_opc_fselx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); ppc_double A; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); if (A.type == ppc_fpr_NaN || (A.type != ppc_fpr_zero && A.s)) { - gCPU.fpr[frD] = gCPU.fpr[frB]; + gCPU->fpr[frD] = gCPU->fpr[frB]; } else { - gCPU.fpr[frD] = gCPU.fpr[frC]; + gCPU->fpr[frD] = gCPU->fpr[frC]; } - if (gCPU.current_opc & PPC_OPC_Rc) { + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fsel.\n"); } @@ -1276,17 +1276,17 @@ * fsqrtx Floating Square Root (Double-Precision) * .515 */ -void ppc_opc_fsqrtx() +void ppc_opc_fsqrtx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); PPC_OPC_ASSERT(frA==0 && frC==0); ppc_double B; ppc_double D; - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); - ppc_fpu_sqrt(D, B); - gCPU.fpscr |= ppc_fpu_pack_double(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); + ppc_fpu_sqrt(D, B, gCPU); + gCPU->fpscr |= ppc_fpu_pack_double(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fsqrt.\n"); } @@ -1295,12 +1295,12 @@ * fsqrtsx Floating Square Root Single * .515 */ -void ppc_opc_fsqrtsx() +void ppc_opc_fsqrtsx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); PPC_OPC_ASSERT(frA==0 && frC==0); - if (gCPU.current_opc & PPC_OPC_Rc) { + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fsqrts.\n"); } @@ -1310,23 +1310,23 @@ * fsubx Floating Subtract (Double-Precision) * .517 */ -void ppc_opc_fsubx() +void ppc_opc_fsubx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); PPC_OPC_ASSERT(frC==0); ppc_double A, B, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); if (B.type != ppc_fpr_NaN) { B.s ^= 1; } if (A.s != B.s && A.type == ppc_fpr_Inf && B.type == ppc_fpr_Inf) { - gCPU.fpscr |= FPSCR_VXISI; + gCPU->fpscr |= FPSCR_VXISI; } - ppc_fpu_add(D, A, B); - gCPU.fpscr |= ppc_fpu_pack_double(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + ppc_fpu_add(D, A, B, gCPU); + gCPU->fpscr |= ppc_fpu_pack_double(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fsub.\n"); } @@ -1335,23 +1335,23 @@ * fsubsx Floating Subtract Single * .518 */ -void ppc_opc_fsubsx() +void ppc_opc_fsubsx(PPC_CPU_State *gCPU) { int frD, frA, frB, frC; - PPC_OPC_TEMPL_A(gCPU.current_opc, frD, frA, frB, frC); + PPC_OPC_TEMPL_A(gCPU->current_opc, frD, frA, frB, frC); PPC_OPC_ASSERT(frC==0); ppc_double A, B, D; - ppc_fpu_unpack_double(A, gCPU.fpr[frA]); - ppc_fpu_unpack_double(B, gCPU.fpr[frB]); + ppc_fpu_unpack_double(A, gCPU->fpr[frA]); + ppc_fpu_unpack_double(B, gCPU->fpr[frB]); if (B.type != ppc_fpr_NaN) { B.s ^= 1; } if (A.s != B.s && A.type == ppc_fpr_Inf && B.type == ppc_fpr_Inf) { - gCPU.fpscr |= FPSCR_VXISI; + gCPU->fpscr |= FPSCR_VXISI; } - ppc_fpu_add(D, A, B); - gCPU.fpscr |= ppc_fpu_pack_double_as_single(D, gCPU.fpr[frD]); - if (gCPU.current_opc & PPC_OPC_Rc) { + ppc_fpu_add(D, A, B, gCPU); + gCPU->fpscr |= ppc_fpu_pack_double_as_single(D, gCPU->fpr[frD], gCPU); + if (gCPU->current_opc & PPC_OPC_Rc) { // update cr1 flags PPC_FPU_ERR("fsubs.\n"); } Index: ppc_fpu.h =================================================================== RCS file: /cvsroot/softpear/softpear/src/cpu/cpu_generic/ppc_fpu.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ppc_fpu.h 16 Nov 2004 22:50:33 -0000 1.1.1.1 +++ ppc_fpu.h 14 Mar 2005 22:55:11 -0000 1.2 @@ -21,6 +21,8 @@ #ifndef __PPC_FPU_H__ #define __PPC_FPU_H__ +#include "cpu/cpu.h" + #define FPU_SIGN_BIT (0x8000000000000000ULL) @@ -182,10 +184,10 @@ } } -inline uint32 ppc_fpu_round(ppc_double &d) +inline uint32 ppc_fpu_round(ppc_double &d, PPC_CPU_State *gCPU) { // .132 - switch (FPSCR_RN(gCPU.fpscr)) { + switch (FPSCR_RN(gCPU->fpscr)) { case FPSCR_RN_NEAR: if (d.m & 0x7) { if ((d.m & 0x7) != 4) { @@ -217,9 +219,9 @@ return 0; } -inline uint32 ppc_fpu_round_single(ppc_single &s) +inline uint32 ppc_fpu_round_singl... [truncated message content] |