📄 mathemu.c
字号:
}static void emu_mdb (int rx, __u64 val) { current->thread.fp_regs.fprs[rx].d = __muldf3(current->thread.fp_regs.fprs[rx].d,val); set_CC_df(current->thread.fp_regs.fprs[rx].d,0ULL);}static void emu_mdbr (int rx, int ry) { current->thread.fp_regs.fprs[rx].d = __muldf3(current->thread.fp_regs.fprs[rx].d, current->thread.fp_regs.fprs[ry].d); set_CC_df(current->thread.fp_regs.fprs[rx].d,0ULL);}static void emu_mdeb (int rx, __u32 val) { printk("mdeb emulation not implemented!\n");}static void emu_mdebr (int rx, int ry) { printk("mdebr emulation not implemented!\n");}static void emu_meeb (int rx, __u32 val) { current->thread.fp_regs.fprs[rx].f = __mulsf3(current->thread.fp_regs.fprs[rx].f, val); set_CC_sf(current->thread.fp_regs.fprs[rx].f,0);}static void emu_meebr (int rx, int ry) { current->thread.fp_regs.fprs[rx].f = __mulsf3(current->thread.fp_regs.fprs[rx].f, current->thread.fp_regs.fprs[ry].f); set_CC_sf(current->thread.fp_regs.fprs[rx].f,0);}static void emu_msdb (int rx, __u64 val, int mask) { printk("msdb emulation not implemented!\n");}static void emu_msdbr (int rx, int ry, int mask) { printk("msdbr emulation not implemented!\n");}static void emu_mseb (int rx, __u32 val, int mask) { printk("mseb emulation not implemented!\n");}static void emu_msebr (int rx, int ry, int mask) { printk("msebr emulation not implemented!\n");}static void emu_mxbr (int rx, int ry) { printk("mxbr emulation not implemented!\n");}static void emu_mxdb (int rx, __u64 val) { printk("mxdb emulation not implemented!\n");}static void emu_mxdbr (int rx, int ry) { printk("mxdbr emulation not implemented!\n");}static void emu_sdb (int rx, __u64 val) { current->thread.fp_regs.fprs[rx].d = __subdf3(current->thread.fp_regs.fprs[rx].d, val); set_CC_sf(current->thread.fp_regs.fprs[rx].d,0ULL);}static void emu_sdbr (int rx, int ry) { current->thread.fp_regs.fprs[rx].d = __subdf3(current->thread.fp_regs.fprs[rx].d, current->thread.fp_regs.fprs[ry].d); set_CC_sf(current->thread.fp_regs.fprs[rx].d,0ULL);}static void emu_seb (int rx, __u32 val) { current->thread.fp_regs.fprs[rx].f = __subsf3(current->thread.fp_regs.fprs[rx].f, val); set_CC_sf(current->thread.fp_regs.fprs[rx].f,0);}static void emu_sebr (int rx, int ry) { current->thread.fp_regs.fprs[rx].f = __subsf3(current->thread.fp_regs.fprs[rx].f, current->thread.fp_regs.fprs[ry].f); set_CC_sf(current->thread.fp_regs.fprs[rx].f,0);}static void emu_sfpc (int rx, int ry) { printk("sfpc emulation not implemented!\n");}static void emu_sqdb (int rx, __u64 val) { printk("sqdb emulation not implemented!\n");}static void emu_sqdbr (int rx, int ry) { printk("sqdbr emulation not implemented!\n");}static void emu_sqeb (int rx, __u32 val) { printk("sqeb emulation not implemented!\n");}static void emu_sqebr (int rx, int ry) { printk("sqebr emulation not implemented!\n");}static void emu_sqxbr (int rx, int ry) { printk("sqxbr emulation not implemented!\n");}static void emu_sxbr (int rx, int ry) { printk("sxbr emulation not implemented!\n");}static void emu_tcdb (int rx, __u64 val) { printk("tcdb emulation not implemented!\n");}static void emu_tceb (int rx, __u32 val) { printk("tceb emulation not implemented!\n");}static void emu_tcxb (int rx, __u64 val) { printk("tcxb emulation not implemented!\n");}static inline void emu_load_regd(int reg) { if ((reg&9) == 0) { /* test if reg in {0,2,4,6} */ __asm__ __volatile ( /* load reg from fp_regs.fprs[reg] */ " bras 1,0f\n" " ld 0,0(%1)\n" "0: ex %0,0(1)" : /* no output */ : "a" (reg<<4), "a" (¤t->thread.fp_regs.fprs[reg].d) : "1" ); }}static inline void emu_load_rege(int reg) { if ((reg&9) == 0) { /* test if reg in {0,2,4,6} */ __asm__ __volatile ( /* load reg from fp_regs.fprs[reg] */ " bras 1,0f\n" " le 0,0(%1)\n" "0: ex %0,0(1)" : /* no output */ : "a" (reg<<4), "a" (¤t->thread.fp_regs.fprs[reg].f) : "1" ); }}static inline void emu_store_regd(int reg) { if ((reg&9) == 0) { /* test if reg in {0,2,4,6} */ __asm__ __volatile ( /* store reg to fp_regs.fprs[reg] */ " bras 1,0f\n" " std 0,0(%1)\n" "0: ex %0,0(1)" : /* no output */ : "a" (reg<<4), "a" (¤t->thread.fp_regs.fprs[reg].d) : "1" ); }}static inline void emu_store_rege(int reg) { if ((reg&9) == 0) { /* test if reg in {0,2,4,6} */ __asm__ __volatile ( /* store reg to fp_regs.fprs[reg] */ " bras 1,0f\n" " ste 0,0(%1)\n" "0: ex %0,0(1)" : /* no output */ : "a" (reg<<4), "a" (¤t->thread.fp_regs.fprs[reg].f) : "1" ); }}int math_emu_b3(__u8 *opcode, struct pt_regs * regs) { static const __u8 format_table[] = { 2, 2, 2, 2, 9, 1, 2, 1, 2, 2, 2, 2, 9, 2, 4, 4, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,10, 1, 1, 3, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 3, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 5, 6, 6, 0, 7, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static const void *jump_table[]= { emu_lpebr, emu_lnebr, emu_ltebr, emu_lcebr, emu_ldebr, emu_lxdbr, emu_lxebr, emu_mxdbr, emu_kebr, emu_cebr, emu_aebr, emu_sebr, emu_mdebr, emu_debr, emu_maebr, emu_msebr, emu_lpdbr, emu_lndbr, emu_ltdbr, emu_lcdbr, emu_sqebr, emu_sqdbr, emu_sqxbr, emu_meebr, emu_kdbr, emu_cdbr, emu_adbr, emu_sdbr, emu_mdbr, emu_ddbr, emu_madbr, emu_msdbr, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, emu_lpxbr, emu_lnxbr, emu_ltxbr, emu_lcxbr, emu_ledbr, emu_ldxbr, emu_lexbr, emu_fixbr, emu_kxbr, emu_cxbr, emu_axbr, emu_sxbr, emu_mxbr, emu_dxbr, NULL, NULL, NULL, NULL, NULL, emu_diebr, NULL, NULL, NULL, emu_fiebr, NULL, NULL, NULL, emu_didbr, NULL, NULL, NULL, emu_fidbr, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, emu_sfpc, NULL, NULL, NULL, NULL, NULL, NULL, NULL, emu_efpc, NULL, NULL, NULL, NULL, NULL, NULL, NULL, emu_cefbr, emu_cdfbr, emu_cxfbr, NULL, emu_cfebr, emu_cfdbr, emu_cfxbr }; switch (format_table[opcode[1]]) { case 1: /* RRE format, double operation */ emu_store_regd((opcode[3]>>4)&15); emu_store_regd(opcode[3]&15); /* call the emulation function */ ((void (*)(int, int))jump_table[opcode[1]]) (opcode[3]>>4,opcode[3]&15); emu_load_regd((opcode[3]>>4)&15); emu_load_regd(opcode[3]&15); return 0; case 2: /* RRE format, float operation */ emu_store_rege((opcode[3]>>4)&15); emu_store_rege(opcode[3]&15); /* call the emulation function */ ((void (*)(int, int))jump_table[opcode[1]]) (opcode[3]>>4,opcode[3]&15); emu_load_rege((opcode[3]>>4)&15); emu_load_rege(opcode[3]&15); return 0; case 3: /* RRF format, double operation */ emu_store_regd((opcode[3]>>4)&15); emu_store_regd(opcode[3]&15); /* call the emulation function */ ((void (*)(int, int, int))jump_table[opcode[1]]) (opcode[3]>>4,opcode[3]&15,opcode[2]>>4); emu_load_regd((opcode[3]>>4)&15); emu_load_regd(opcode[3]&15); return 0; case 4: /* RRF format, float operation */ emu_store_rege((opcode[3]>>4)&15); emu_store_rege(opcode[3]&15); /* call the emulation function */ ((void (*)(int, int, int))jump_table[opcode[1]]) (opcode[3]>>4,opcode[3]&15,opcode[2]>>4); emu_load_rege((opcode[3]>>4)&15); emu_load_rege(opcode[3]&15); return 0; case 5: /* RRE format, cefbr instruction */ emu_store_rege((opcode[3]>>4)&15); /* call the emulation function */ ((void (*)(int, int))jump_table[opcode[1]]) (opcode[3]>>4,opcode[3]&15); emu_load_rege((opcode[3]>>4)&15); return 0; case 6: /* RRE format, cdfbr & cxfbr instruction */ emu_store_regd((opcode[3]>>4)&15); /* call the emulation function */ ((void (*)(int, int))jump_table[opcode[1]]) (opcode[3]>>4,opcode[3]&15); emu_load_regd((opcode[3]>>4)&15); return 0; /* FIXME !! */ return 0; case 7: /* RRF format, cfebr instruction */ emu_store_rege(opcode[3]&15); /* call the emulation function */ ((void (*)(int, int, int))jump_table[opcode[1]]) (opcode[3]>>4,opcode[3]&15,opcode[2]>>4); return 0; case 8: /* RRF format, cfdbr & cfxbr instruction */ emu_store_regd(opcode[3]&15); /* call the emulation function */ ((void (*)(int, int, int))jump_table[opcode[1]])
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -