Provide a DEV9async and use it to call irq

This commit is contained in:
TheLastRar 2015-05-13 10:04:04 +01:00
parent bd96a73580
commit a0ec633c46
7 changed files with 27 additions and 3 deletions

View File

@ -702,6 +702,7 @@ typedef void (CALLBACK* _DEV9writeDMA8Mem)(u32 *pMem, int size);
#endif
typedef void (CALLBACK* _DEV9irqCallback)(DEV9callback callback);
typedef DEV9handler (CALLBACK* _DEV9irqHandler)(void);
typedef void (CALLBACK* _DEV9async)(u32 cycles);
// USB
// NOTE: The read/write functions CANNOT use XMM/MMX regs
@ -820,6 +821,7 @@ extern _DEV9writeDMA8Mem DEV9writeDMA8Mem;
#endif
extern _DEV9irqCallback DEV9irqCallback;
extern _DEV9irqHandler DEV9irqHandler;
extern _DEV9async DEV9async;
// USB
extern _USBopen USBopen;

View File

@ -453,7 +453,10 @@ void psxRcntUpdate()
else c -= difference;
psxNextCounter = c;
}
if (DEV9async)
{
DEV9async(1);
}
if(USBasync)
{
const s32 difference = psxRegs.cycle - psxCounters[7].sCycleT;

View File

@ -320,6 +320,7 @@ _DEV9writeDMA8Mem DEV9writeDMA8Mem;
#endif
_DEV9irqCallback DEV9irqCallback;
_DEV9irqHandler DEV9irqHandler;
_DEV9async DEV9async;
// USB
_USBopen USBopen;
@ -630,6 +631,7 @@ static const LegacyApi_ReqMethod s_MethMessReq_DEV9[] =
static const LegacyApi_OptMethod s_MethMessOpt_DEV9[] =
{
{ "DEV9async", (vMeth**)&DEV9async },
{ NULL }
};

View File

@ -600,6 +600,10 @@ void CALLBACK DEV9irqCallback(void (*callback)(int cycles)) {
DEV9irq = callback;
}
void CALLBACK DEV9async(u32 cycles)
{
smap_async(cycles);
}
// extended funcs

View File

@ -24,5 +24,6 @@ EXPORTS
DEV9about @19
DEV9irqCallback @20
DEV9irqHandler @21
DEV9async @22
DEV9setSettingsDir

View File

@ -81,6 +81,7 @@ bool rx_fifo_can_rx()
//we can recv a packet !
return true;
}
bool fireIntR = false;
void rx_process(NetPacket* pk)
{
if (!rx_fifo_can_rx())
@ -118,7 +119,8 @@ void rx_process(NetPacket* pk)
//increase frame count
dev9Ru8(SMAP_R_RXFIFO_FRAME_CNT)++;
//spams// emu_printf("Got packet, %d bytes (%d fifo)\n", pk->size,bytes);
_DEV9irq(SMAP_INTR_RXEND,0);//now ? or when the fifo is full ? i guess now atm
fireIntR = true;
//_DEV9irq(SMAP_INTR_RXEND,0);//now ? or when the fifo is full ? i guess now atm
//note that this _is_ wrong since the IOP interrupt system is not thread safe.. but nothing i can do about that
}
@ -840,3 +842,12 @@ void CALLBACK smap_writeDMA8Mem(u32* pMem, int size)
}
}
void CALLBACK smap_async(u32 cycles)
{
if (fireIntR)
{
fireIntR = false; //Thread unsafe?
//Is this used to signal each individual packet, or just when there are packets in the RX fifo?
_DEV9irq(SMAP_INTR_RXEND, 0); //Make the call to _DEV9irq in a thread safe way
}
}

View File

@ -25,4 +25,5 @@ void CALLBACK smap_write16(u32 addr, u16 value);
void CALLBACK smap_write32(u32 addr, u32 value);
void CALLBACK smap_readDMA8Mem(u32 *pMem, int size);
void CALLBACK smap_writeDMA8Mem(u32 *pMem, int size);
void CALLBACK smap_writeDMA8Mem(u32 *pMem, int size);
void CALLBACK smap_async(u32 cycles);