From 83f0c75dfb1c6ba1a8e5d1ff02cbd6e71232c6ed Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Wed, 19 Nov 2008 02:26:05 +0000 Subject: [PATCH] Set a few of the IRQ handlers to __forceinline since they're only called from one place (cpuBranchTest, psxBranchTest). Changed all uses of _inline to __forceinline as well, since _inline is a useless keyword [all modern compilers by default assume _inline status on everything]. Also a few code cleanups and fixme's marking unused/unreferenced functions. git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@340 a6443dda-0b58-4228-96e9-037be469359c --- pcsx2/CDVD.c | 3 ++- pcsx2/CDVD.h | 2 +- pcsx2/CdRom.c | 10 ++++----- pcsx2/GS.cpp | 6 ++++-- pcsx2/GS.h | 2 +- pcsx2/IPU/IPU.c | 4 ++-- pcsx2/IPU/IPU.h | 4 ++-- pcsx2/PsxDma.c | 55 ++++++++++++++++++++++--------------------------- pcsx2/SPR.c | 2 +- pcsx2/Sif.c | 19 ++++++++++------- pcsx2/Sio.c | 2 +- pcsx2/Sio.h | 2 +- pcsx2/Vif.c | 6 +++--- pcsx2/VifDma.c | 14 +++++++------ pcsx2/VifDma.h | 4 ++-- 15 files changed, 69 insertions(+), 66 deletions(-) diff --git a/pcsx2/CDVD.c b/pcsx2/CDVD.c index d5c635f76e..da2a61702d 100644 --- a/pcsx2/CDVD.c +++ b/pcsx2/CDVD.c @@ -884,7 +884,8 @@ int cdvdReadSector() { return 0; } -void cdvdReadInterrupt() { +// inlined due to being referenced in only one place. +__forceinline void cdvdReadInterrupt() { //SysPrintf("cdvdReadInterrupt %x %x %x %x %x\n", cpuRegs.interrupt, cdvd.Readed, cdvd.Reading, cdvd.nSectors, (HW_DMA3_BCR_H16 * HW_DMA3_BCR_L16) *4); cdvd.Ready = 0x00; diff --git a/pcsx2/CDVD.h b/pcsx2/CDVD.h index 8ee5c6ce28..44e24d1766 100644 --- a/pcsx2/CDVD.h +++ b/pcsx2/CDVD.h @@ -92,7 +92,7 @@ void cdvdReadTimeRcnt(int mode); void cdvdVsync(); int cdvdInterrupt(); int cdvdFreeze(gzFile f, int Mode); -void cdvdReadInterrupt(); +extern void cdvdReadInterrupt(); void cdvdNewDiskCB(); u8 cdvdRead04(void); u8 cdvdRead05(void); diff --git a/pcsx2/CdRom.c b/pcsx2/CdRom.c index f1a5fc054b..220843a25d 100644 --- a/pcsx2/CdRom.c +++ b/pcsx2/CdRom.c @@ -91,34 +91,34 @@ unsigned long cdReadTime;// = ((PSXCLK / 75) / BIAS); #define CDR_INT(eCycle) PSX_INT(17, eCycle) #define CDREAD_INT(eCycle) PSX_INT(18, eCycle) -static __inline void StartReading(unsigned long type) { +static __forceinline void StartReading(unsigned long type) { cdr.Reading = type; cdr.FirstSector = 1; cdr.Readed = 0xff; AddIrqQueue(READ_ACK, 0x800); } -static __inline void StopReading() { +static __forceinline void StopReading() { if (cdr.Reading) { cdr.Reading = 0; psxRegs.interrupt&=~0x40000; } } -static __inline void StopCdda() { +static __forceinline void StopCdda() { if (cdr.Play) { cdr.StatP&=~0x80; cdr.Play = 0; } } -__inline void SetResultSize(u8 size) { +__forceinline void SetResultSize(u8 size) { cdr.ResultP = 0; cdr.ResultC = size; cdr.ResultReady = 1; } -s32 MSFtoLSN(u8 *Time) { +__forceinline s32 MSFtoLSN(u8 *Time) { u32 lsn; lsn = Time[2]; diff --git a/pcsx2/GS.cpp b/pcsx2/GS.cpp index 19307731dd..68812c1e43 100644 --- a/pcsx2/GS.cpp +++ b/pcsx2/GS.cpp @@ -887,7 +887,7 @@ u32 GSgifTransferDummy(int path, u32 *pMem, u32 size) static int gspath3done=0; int gscycles = 0; -void gsInterrupt() { +__forceinline void gsInterrupt() { GIF_LOG("gsInterrupt: %8.8x\n", cpuRegs.cycle); if((gif->chcr & 0x100) == 0){ @@ -1361,11 +1361,13 @@ void gifMFIFOInterrupt() mfifoGIFtransfer(0); return; } +#ifndef PCSX2_PUBLIC if(gifdone == 0 || gif->qwc > 0) { - SysPrintf("Shouldnt go here\n"); + SysPrintf("gifMFIFO Panic > Shouldnt go here!\n"); cpuRegs.interrupt &= ~(1 << 11); return; } +#endif //if(gifqwc > 0)SysPrintf("GIF MFIFO ending with stuff in it %x\n", gifqwc); gifqwc = 0; gifdone = 0; diff --git a/pcsx2/GS.h b/pcsx2/GS.h index c2cbaa7378..0171b551fa 100644 --- a/pcsx2/GS.h +++ b/pcsx2/GS.h @@ -157,7 +157,7 @@ void gsConstRead64(u32 mem, int mmreg); void gsConstRead128(u32 mem, int xmmreg); void gsIrq(); -void gsInterrupt(); +extern void gsInterrupt(); void dmaGIF(); void GIFdma(); void mfifoGIFtransfer(int qwc); diff --git a/pcsx2/IPU/IPU.c b/pcsx2/IPU/IPU.c index 3f966ed7c6..7d22d71ee0 100644 --- a/pcsx2/IPU/IPU.c +++ b/pcsx2/IPU/IPU.c @@ -1922,7 +1922,7 @@ void dmaIPU1() // toIPU extern void GIFdma(); -void ipu0Interrupt() { +__forceinline void ipu0Interrupt() { IPU_LOG("ipu0Interrupt: %x\n", cpuRegs.cycle); if( g_nDMATransfer & IPU_DMA_FIREINT0 ) { @@ -1953,7 +1953,7 @@ void ipu0Interrupt() { cpuRegs.interrupt &= ~(1 << 3); } -void ipu1Interrupt() { +__forceinline void ipu1Interrupt() { IPU_LOG("ipu1Interrupt %x:\n", cpuRegs.cycle); if( g_nDMATransfer & IPU_DMA_FIREINT1 ) { diff --git a/pcsx2/IPU/IPU.h b/pcsx2/IPU/IPU.h index 83ea9beec3..9621e9aac5 100644 --- a/pcsx2/IPU/IPU.h +++ b/pcsx2/IPU/IPU.h @@ -192,8 +192,8 @@ void ipuConstWrite32(u32 mem, int mmreg); void ipuWrite64(u32 mem,u64 value); void ipuConstWrite64(u32 mem, int mmreg); -void ipu0Interrupt(); -void ipu1Interrupt(); +extern void ipu0Interrupt(); +extern void ipu1Interrupt(); u8 getBits32(u8 *address, u32 advance); u8 getBits16(u8 *address, u32 advance); diff --git a/pcsx2/PsxDma.c b/pcsx2/PsxDma.c index 7497ee1f4b..89d06aa7f7 100644 --- a/pcsx2/PsxDma.c +++ b/pcsx2/PsxDma.c @@ -27,23 +27,23 @@ int iopsifbusy[2] = { 0, 0 }; void psxDma4(u32 madr, u32 bcr, u32 chcr) { // SPU - int size; - /*if (chcr & 0x400) SysPrintf("SPU 2 DMA 4 linked list chain mode! chcr = %x madr = %x bcr = %x\n", chcr, madr, bcr); - if (chcr & 0x40000000) SysPrintf("SPU 2 DMA 4 Unusual bit set on 'to' direction chcr = %x madr = %x bcr = %x\n", chcr, madr, bcr); - if ((chcr & 0x1) == 0) SysPrintf("SPU 2 DMA 4 loading from spu2 memory chcr = %x madr = %x bcr = %x\n", chcr, madr, bcr);*/ + const int size = (bcr >> 16) * (bcr & 0xFFFF); // Number of blocks to transfer + + /*if (chcr & 0x400) SysPrintf("SPU 2 DMA 4 linked list chain mode! chcr = %x madr = %x bcr = %x\n", chcr, madr, bcr); + if (chcr & 0x40000000) SysPrintf("SPU 2 DMA 4 Unusual bit set on 'to' direction chcr = %x madr = %x bcr = %x\n", chcr, madr, bcr); + if ((chcr & 0x1) == 0) SysPrintf("SPU 2 DMA 4 loading from spu2 memory chcr = %x madr = %x bcr = %x\n", chcr, madr, bcr);*/ if(SPU2async) - { - SPU2async(psxRegs.cycle - psxCounters[6].sCycleT); - - //SysPrintf("cycles sent to SPU2 %x\n", psxRegs.cycle - psxCounters[6].sCycleT); - psxCounters[6].sCycleT = psxRegs.cycle; - psxCounters[6].CycleT = ((bcr >> 16) * (bcr & 0xFFFF)) * 3; - - psxNextCounter -= (psxRegs.cycle-psxNextsCounter); - psxNextsCounter = psxRegs.cycle; - if(psxCounters[6].CycleT < psxNextCounter) psxNextCounter = psxCounters[6].CycleT; - + { + SPU2async(psxRegs.cycle - psxCounters[6].sCycleT); + + //SysPrintf("cycles sent to SPU2 %x\n", psxRegs.cycle - psxCounters[6].sCycleT); + psxCounters[6].sCycleT = psxRegs.cycle; + psxCounters[6].CycleT = size * 3; + + psxNextCounter -= (psxRegs.cycle-psxNextsCounter); + psxNextsCounter = psxRegs.cycle; + if(psxCounters[6].CycleT < psxNextCounter) psxNextCounter = psxCounters[6].CycleT; } switch (chcr) { @@ -51,14 +51,12 @@ void psxDma4(u32 madr, u32 bcr, u32 chcr) { // SPU PSXDMA_LOG("*** DMA 4 - SPU mem2spu *** %lx addr = %lx size = %lx\n", chcr, madr, bcr); //SysPrintf("DMA4 write blocks %x, size per block %x\n", (bcr >> 16), (bcr & 0xFFFF)); - size = (bcr >> 16) * (bcr & 0xFFFF); // Number of blocks to transfer SPU2writeDMA4Mem((u16 *)PSXM(madr), size*2); break; case 0x01000200: //spu to cpu transfer PSXDMA_LOG("*** DMA 4 - SPU spu2mem *** %lx addr = %lx size = %lx\n", chcr, madr, bcr); //SysPrintf("DMA4 read blocks %x, size per block %x\n", (bcr >> 16), (bcr & 0xFFFF)); - size = (bcr >> 16) * (bcr & 0xFFFF); // Number of blocks to transfer SPU2readDMA4Mem((u16 *)PSXM(madr), size*2); psxCpu->Clear(HW_DMA4_MADR, size); break; @@ -101,19 +99,18 @@ void psxDma6(u32 madr, u32 bcr, u32 chcr) { } void psxDma7(u32 madr, u32 bcr, u32 chcr) { - int size; + int size = (bcr >> 16) * (bcr & 0xFFFF); if(SPU2async) - { - SPU2async(psxRegs.cycle - psxCounters[6].sCycleT); - //SysPrintf("cycles sent to SPU2 %x\n", psxRegs.cycle - psxCounters[6].sCycleT); - - psxCounters[6].sCycleT = psxRegs.cycle; - psxCounters[6].CycleT = ((bcr >> 16) * (bcr & 0xFFFF)) * 3; - - psxNextCounter -= (psxRegs.cycle-psxNextsCounter); - psxNextsCounter = psxRegs.cycle; - if(psxCounters[6].CycleT < psxNextCounter) psxNextCounter = psxCounters[6].CycleT; + { + SPU2async(psxRegs.cycle - psxCounters[6].sCycleT); + + psxCounters[6].sCycleT = psxRegs.cycle; + psxCounters[6].CycleT = size * 3; + + psxNextCounter -= (psxRegs.cycle-psxNextsCounter); + psxNextsCounter = psxRegs.cycle; + if(psxCounters[6].CycleT < psxNextCounter) psxNextCounter = psxCounters[6].CycleT; } @@ -122,14 +119,12 @@ void psxDma7(u32 madr, u32 bcr, u32 chcr) { PSXDMA_LOG("*** DMA 7 - SPU2 mem2spu *** %lx addr = %lx size = %lx\n", chcr, madr, bcr); //SysPrintf("DMA7 write blocks %x, size per block %x\n", (bcr >> 16), (bcr & 0xFFFF)); - size = (bcr >> 16) * (bcr & 0xFFFF); // Number of blocks to transfer SPU2writeDMA7Mem((u16 *)PSXM(madr), size*2); break; case 0x01000200: //spu2 to cpu transfer PSXDMA_LOG("*** DMA 7 - SPU2 spu2mem *** %lx addr = %lx size = %lx\n", chcr, madr, bcr); //SysPrintf("DMA7 read blocks %x, size per block %x\n", (bcr >> 16), (bcr & 0xFFFF)); - size = (bcr >> 16) * (bcr & 0xFFFF); // Number of blocks to transfer SPU2readDMA7Mem((u16 *)PSXM(madr), size*2); psxCpu->Clear(HW_DMA7_MADR, size); break; diff --git a/pcsx2/SPR.c b/pcsx2/SPR.c index a08ecf37f9..d98d5b9bb6 100644 --- a/pcsx2/SPR.c +++ b/pcsx2/SPR.c @@ -252,7 +252,7 @@ void dmaSPR0() { // fromSPR } -__inline static void SPR1transfer(u32 *data, int size) { +__forceinline static void SPR1transfer(u32 *data, int size) { /* { int i; for (i=0; ichcr, sif0dma->madr, sif0dma->qwc, sif0dma->tadr); @@ -565,6 +566,7 @@ _inline void dmaSIF0() { } } +// fixme: Unused code _inline void dmaSIF1() { SIF_LOG("EE: dmaSIF1 chcr = %lx, madr = %lx, qwc = %lx, tadr = %lx\n", sif1dma->chcr, sif1dma->madr, sif1dma->qwc, sif1dma->tadr); @@ -591,6 +593,7 @@ _inline void dmaSIF1() { } +// fixme: Unused code _inline void dmaSIF2() { SIF_LOG("dmaSIF2 chcr = %lx, madr = %lx, qwc = %lx\n", sif2dma->chcr, sif2dma->madr, sif2dma->qwc); diff --git a/pcsx2/Sio.c b/pcsx2/Sio.c index 808e61bf61..06850c96cc 100644 --- a/pcsx2/Sio.c +++ b/pcsx2/Sio.c @@ -497,7 +497,7 @@ void sioWriteCtrl16(unsigned short value) { } } -void sioInterrupt() { +__forceinline void sioInterrupt() { PAD_LOG("Sio Interrupt\n"); sio.StatReg|= IRQ; psxHu32(0x1070)|=0x80; diff --git a/pcsx2/Sio.h b/pcsx2/Sio.h index 9342bdd41d..4bf8c5a920 100644 --- a/pcsx2/Sio.h +++ b/pcsx2/Sio.h @@ -77,7 +77,7 @@ void psxSIOShutdown(); unsigned char sioRead8(); void sioWrite8(unsigned char value); void sioWriteCtrl16(unsigned short value); -void sioInterrupt(); +extern void sioInterrupt(); int sioFreeze(gzFile f, int Mode); void InitializeSIO(u8 value); diff --git a/pcsx2/Vif.c b/pcsx2/Vif.c index 49b6d3789f..58d7c6ea13 100644 --- a/pcsx2/Vif.c +++ b/pcsx2/Vif.c @@ -38,7 +38,7 @@ vifStruct *_vif; static int n; -__inline static int _limit( int a, int max ) +__forceinline static int _limit( int a, int max ) { return ( a > max ? max : a ); } @@ -401,7 +401,7 @@ void UNPACK_V4_5(u32 *dest, u32 *data, int size) { static int cycles; extern int g_vifCycles; u16 vifqwc = 0; -__inline int mfifoVIF1rbTransfer() { +static __forceinline int mfifoVIF1rbTransfer() { u32 maddr = psHu32(DMAC_RBOR); u32 ret, msize = psHu32(DMAC_RBOR) + psHu32(DMAC_RBSR) + 16; u16 mfifoqwc = min(vif1ch->qwc, vifqwc); @@ -447,7 +447,7 @@ __inline int mfifoVIF1rbTransfer() { return ret; } -__inline int mfifoVIF1chain() { +static __forceinline int mfifoVIF1chain() { int ret; /* Is QWC = 0? if so there is nothing to transfer */ diff --git a/pcsx2/VifDma.c b/pcsx2/VifDma.c index 4dd4c7e845..3b10e96b3f 100644 --- a/pcsx2/VifDma.c +++ b/pcsx2/VifDma.c @@ -229,7 +229,7 @@ __forceinline void vif1FLUSH() { void vifDmaInit() { } -__inline static int _limit( int a, int max ) { +__forceinline static int _limit( int a, int max ) { return ( a > max ? max : a ); } @@ -833,7 +833,7 @@ void vif0Init() SetNewMask(g_vif0Masks, g_vif0HasMask3, 0, 0xffffffff); } -__inline void vif0UNPACK(u32 *data) { +static __forceinline void vif0UNPACK(u32 *data) { int vifNum; int vl, vn; int len; @@ -870,7 +870,7 @@ __inline void vif0UNPACK(u32 *data) { vif0Regs->offset = 0; } -__inline void _vif0mpgTransfer(u32 addr, u32 *data, int size) { +static __forceinline void _vif0mpgTransfer(u32 addr, u32 *data, int size) { /* SysPrintf("_vif0mpgTransfer addr=%x; size=%x\n", addr, size); { FILE *f = fopen("vu1.raw", "wb"); @@ -1510,7 +1510,7 @@ void vif1Init() { SetNewMask(g_vif1Masks, g_vif1HasMask3, 0, 0xffffffff); } -__inline void vif1UNPACK(u32 *data) { +static __forceinline void vif1UNPACK(u32 *data) { int vifNum; int vl, vn; //int len; @@ -1551,7 +1551,7 @@ __inline void vif1UNPACK(u32 *data) { // vif1Regs->offset = 0; } -__inline void _vif1mpgTransfer(u32 addr, u32 *data, int size) { +static __forceinline void _vif1mpgTransfer(u32 addr, u32 *data, int size) { /* SysPrintf("_vif1mpgTransfer addr=%x; size=%x\n", addr, size); { FILE *f = fopen("vu1.raw", "wb"); @@ -2158,7 +2158,7 @@ int _chainVIF1() { return vif1.done; //Return Done } -void vif1Interrupt() { +__forceinline void vif1Interrupt() { VIF_LOG("vif1Interrupt: %8.8x\n", cpuRegs.cycle); g_vifCycles = 0; @@ -2216,8 +2216,10 @@ void vif1Interrupt() { return; } +#ifndef PCSX2_PUBLIC if(vif1ch->qwc > 0) SysPrintf("VIF1 Ending with QWC left\n"); if(vif1.cmd != 0) SysPrintf("vif1.cmd still set %x\n", vif1.cmd); +#endif //SysPrintf("VIF Interrupt\n"); //if((gif->chcr & 0x100) && vif1Regs->mskpath3) gsInterrupt(); prevviftag = NULL; diff --git a/pcsx2/VifDma.h b/pcsx2/VifDma.h index d96ffae13b..424d6de06e 100644 --- a/pcsx2/VifDma.h +++ b/pcsx2/VifDma.h @@ -84,8 +84,8 @@ void UNPACK_V4_5( u32 *dest, u32 *data, int size ); void vifDmaInit(); void vif0Init(); void vif1Init(); -void vif0Interrupt(); -void vif1Interrupt(); +extern void vif0Interrupt(); +extern void vif1Interrupt(); void vif0Write32(u32 mem, u32 value); void vif1Write32(u32 mem, u32 value);