mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
sh2 drc, wrap generated function ptrs if called from host
This commit is contained in:
parent
e1b916547d
commit
0512a22869
8 changed files with 43 additions and 15 deletions
|
@ -506,7 +506,14 @@ static signed char reg_map_host[HOST_REGS];
|
|||
|
||||
static guest_reg_t guest_regs[SH2_REGS];
|
||||
|
||||
// generated functions called from C, to be called only through host_call()
|
||||
static void REGPARM(1) (*sh2_drc_entry)(SH2 *sh2);
|
||||
#ifdef DRC_SR_REG
|
||||
void REGPARM(1) (*sh2_drc_save_sr)(SH2 *sh2);
|
||||
void REGPARM(1) (*sh2_drc_restore_sr)(SH2 *sh2);
|
||||
#endif
|
||||
|
||||
// generated DRC helper functions, only called from generated code via emith_call*()
|
||||
static void REGPARM(1) (*sh2_drc_dispatcher)(u32 pc);
|
||||
#if CALL_STACK
|
||||
static u32 REGPARM(2) (*sh2_drc_dispatcher_call)(u32 pc);
|
||||
|
@ -525,11 +532,6 @@ static void REGPARM(2) (*sh2_drc_write8)(u32 a, u32 d);
|
|||
static void REGPARM(2) (*sh2_drc_write16)(u32 a, u32 d);
|
||||
static void REGPARM(2) (*sh2_drc_write32)(u32 a, u32 d);
|
||||
|
||||
#ifdef DRC_SR_REG
|
||||
void REGPARM(1) (*sh2_drc_save_sr)(SH2 *sh2);
|
||||
void REGPARM(1) (*sh2_drc_restore_sr)(SH2 *sh2);
|
||||
#endif
|
||||
|
||||
// flags for memory access
|
||||
#define MF_SIZEMASK 0x03 // size of access
|
||||
#define MF_POSTINCR 0x10 // post increment (for read_rr)
|
||||
|
@ -5513,7 +5515,7 @@ static void sh2_generate_utils(void)
|
|||
emith_sub_r_imm(sr, 13 << 12); // at least 13 cycles
|
||||
rcache_flush();
|
||||
emith_move_r_r_ptr(arg0, CONTEXT_REG);
|
||||
emith_call_ctx(offsetof(SH2, irq_callback)); // vector = sh2->irq_callback(sh2, level);
|
||||
emith_abicall_ctx(offsetof(SH2, irq_callback)); // vector = sh2->irq_callback(sh2, level);
|
||||
// obtain new PC
|
||||
tmp = rcache_get_reg_arg(1, SHR_VBR, &tmp2);
|
||||
emith_add_r_r_r_lsl(arg0, tmp2, RET_REG, 2);
|
||||
|
@ -5711,7 +5713,7 @@ int sh2_execute_drc(SH2 *sh2c, int cycles)
|
|||
#endif
|
||||
|
||||
sh2c->state |= SH2_IN_DRC;
|
||||
sh2_drc_entry(sh2c);
|
||||
host_call(sh2_drc_entry, (SH2 *))(sh2c);
|
||||
sh2c->state &= ~SH2_IN_DRC;
|
||||
|
||||
// TODO: irq cycles
|
||||
|
|
|
@ -74,11 +74,11 @@ extern void REGPARM(1) (*sh2_drc_restore_sr)(SH2 *sh2);
|
|||
#define DRC_SAVE_SR(sh2) \
|
||||
if (likely((sh2->state & (SH2_IN_DRC|SH2_STATE_SLEEP)) == SH2_IN_DRC)) \
|
||||
sh2->sr = (s32)_sh2_sr
|
||||
// sh2_drc_save_sr(sh2)
|
||||
// host_call(sh2_drc_save_sr, (SH2 *))(sh2)
|
||||
#define DRC_RESTORE_SR(sh2) \
|
||||
if (likely((sh2->state & (SH2_IN_DRC|SH2_STATE_SLEEP)) == SH2_IN_DRC)) \
|
||||
_sh2_sr = (s32)sh2->sr
|
||||
// sh2_drc_restore_sr(sh2)
|
||||
// host_call(sh2_drc_restore_sr, (SH2 *))(sh2)
|
||||
#else
|
||||
#define DRC_DECLARE_SR
|
||||
#define DRC_SAVE_SR(sh2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue