/[pcsx2_0.9.7]/trunk/pcsx2/R5900.h
ViewVC logotype

Diff of /trunk/pcsx2/R5900.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/pcsx2/R5900.h	2010/09/07 03:24:11	31
+++ trunk/pcsx2/R5900.h	2010/09/07 11:08:22	62
@@ -15,16 +15,15 @@
 
 #pragma once
 
-//////////////////////////////////////////////////////////////////////////////////////////
-#ifndef __LINUX__
-#pragma region Recompiler Stuffs
-#endif
+class BaseR5900Exception;
 
+// --------------------------------------------------------------------------------------
+//  Recompiler Stuffs
+// --------------------------------------------------------------------------------------
 // This code section contains recompiler vars that are used in "shared" code. Placing
 // them in iR5900.h would mean having to include that into more files than I care to
 // right now, so we're sticking them here for now until a better solution comes along.
 
-extern bool g_EEFreezeRegs;
 extern bool g_SkipBiosHack;
 extern bool g_GameStarted;
 
@@ -39,12 +38,10 @@
 		explicit ExitCpuExecute() { }
 	};
 }
-#ifndef __LINUX__
-#pragma endregion
-#endif
 
-//////////////////////////////////////////////////////////////////////////////////////////
-// EE Bios function name tables.
+// --------------------------------------------------------------------------------------
+//  EE Bios function name tables.
+// --------------------------------------------------------------------------------------
 namespace R5900 {
 extern const char* const bios[256];
 }
@@ -53,6 +50,8 @@
 extern u32 EEoCycle;
 
 union GPR_reg {   // Declare union type GPR register
+	u128 UQ;
+	s128 SQ;
 	u64 UD[2];      //128 bits
 	s64 SD[2];
 	u32 UL[4];
@@ -245,7 +244,7 @@
 extern __aligned16 fpuRegisters fpuRegs;
 extern __aligned16 tlbs tlb[48];
 
-extern u32 g_nextBranchCycle;
+extern u32 g_nextEventCycle;
 extern bool eeEventTestIsActive;
 extern u32 s_iLastCOP0Cycle;
 extern u32 s_iLastPERFCycle[2];
@@ -257,17 +256,17 @@
 void __fastcall intDoBranch(u32 target);
 
 // modules loaded at hardcoded addresses by the kernel
-const u32 EEKERNEL_START = 0;
-const u32 EENULL_START = 0x81FC0;
-const u32 EELOAD_START = 0x82000;
-const u32 EELOAD_SIZE = 0x20000; // overestimate for searching
-
-void __fastcall eeGameStarting();
-void __fastcall eeloadReplaceOSDSYS();
-
-////////////////////////////////////////////////////////////////////
-// R5900 Public Interface / API
-//
+const u32 EEKERNEL_START	= 0;
+const u32 EENULL_START		= 0x81FC0;
+const u32 EELOAD_START		= 0x82000;
+const u32 EELOAD_SIZE		= 0x20000; // overestimate for searching
+
+extern void __fastcall eeGameStarting();
+extern void __fastcall eeloadReplaceOSDSYS();
+
+// --------------------------------------------------------------------------------------
+//  R5900cpu
+// --------------------------------------------------------------------------------------
 // [TODO] : This is on the list to get converted to a proper C++ class.  I'm putting it
 // off until I get my new IOPint and IOPrec re-merged. --air
 //
@@ -282,7 +281,7 @@
 	//   Can be called from any thread.  Execute status must be suspended or stopped
 	//   to prevent multi-thread race conditions.
 	//
-	// Notable Exception Throws:
+	// Exception Throws:
 	//   OutOfMemory - Not enough memory, or the memory areas required were already
 	//                 reserved.
 	//
@@ -306,7 +305,7 @@
 	//   Can be called from any thread.  Execute status must be suspended or stopped
 	//   to prevent multi-thread race conditions.
 	//
-	// Exception Throws:  Emulator-defined.  Common exception types to look for:
+	// Exception Throws:  Emulator-defined.  Common exception types to expect are
 	//   OutOfMemory, Stream Exceptions
 	//
 	void (*Reset)();
@@ -325,7 +324,9 @@
 	// call to return at the nearest state check (typically handled internally using
 	// either C++ exceptions or setjmp/longjmp).
 	//
-	// Exception Throws:  [TODO]  (possible execution-related throws to be added)
+	// Exception Throws: 
+	//   Throws BaseR5900Exception and all derivatives.
+	//   Throws FileNotFound or other Streaming errors (typically related to BIOS MEC/NVM)
 	//
 	void (*Execute)();
 
@@ -336,19 +337,29 @@
 	//
 	// Implementation note: Because of the nuances of recompiled code execution, setjmp
 	// may be used in place of thread cancellation or C++ exceptions (non-SEH exceptions
-	// cannot unwind through the recompiled code stackframes).
+	// cannot unwind through the recompiled code stackframes, thus longjmp must be used).
 	//
 	// Thread Affinity:
-	//   Must be called on the same thread as Execute only.
+	//   Must be called on the same thread as Execute.
 	//
 	// Exception Throws:
-	//   May throw threading/Pthreads cancellations if the compiler supports SEH.
-	//   ThreadTimedOut - For canceling VM execution in response to MTGS deadlock. (if the
-	//     core emulator does not support multithreaded GS then this will not be a throw
-	//     exception).
+	//   May throw Execution/Pthreads cancellations if the compiler supports SEH.
 	//
 	void (*CheckExecutionState)();
 
+	// Safely throws host exceptions from executing code (either recompiled or interpreted).
+	// If this function is called outside the context of the CPU's code execution, then the
+	// given exception will be re-thrown automatically.
+	// 
+	// Exception Throws:
+	//   (SEH) Rethrows the given exception immediately.
+	//   (setjmp) Re-throws immediately if called from outside the context of dynamically
+	//      generated code (either non-executing contexts or interpreters).  Does not throw
+	//      otherwise.
+	//
+	void (*ThrowException)( const BaseException& ex );
+	void (*ThrowCpuException)( const BaseR5900Exception& ex );
+
 	// Manual recompiled code cache clear; typically useful to recompilers only.  Size is
 	// in MIPS words (32 bits).  Dev note: this callback is nearly obsolete, and might be
 	// better off replaced with some generic API callbacks from VTLB block protection.
@@ -369,6 +380,33 @@
 extern R5900cpu intCpu;
 extern R5900cpu recCpu;
 
+enum EE_EventType
+{
+	DMAC_VIF0	= 0,
+	DMAC_VIF1,
+	DMAC_GIF,
+	DMAC_FROM_IPU,
+	DMAC_TO_IPU,
+	DMAC_SIF0,
+	DMAC_SIF1,
+	DMAC_SIF2,
+	DMAC_FROM_SPR,
+	DMAC_TO_SPR,
+
+	DMAC_MFIFO_VIF,
+	DMAC_MFIFO_GIF,
+
+	// We're setting error conditions through hwDmacIrq, so these correspond to the conditions above.
+	DMAC_STALL_SIS		= 13, // SIS
+	DMAC_MFIFO_EMPTY	= 14, // MEIS
+	DMAC_BUS_ERROR	= 15      // BEIS
+};
+
+extern void CPU_INT( EE_EventType n, s32 ecycle );
+extern uint intcInterrupt();
+extern uint dmacInterrupt();
+
+
 extern void cpuInit();
 extern void cpuReset();		// can throw Exception::FileNotFound.
 extern void cpuException(u32 code, u32 bd);
@@ -377,12 +415,12 @@
 extern void cpuTestHwInts();
 extern void cpuClearInt(uint n);
 
-extern void cpuSetNextBranch( u32 startCycle, s32 delta );
-extern void cpuSetNextBranchDelta( s32 delta );
+extern void cpuSetNextEvent( u32 startCycle, s32 delta );
+extern void cpuSetNextEventDelta( s32 delta );
 extern int  cpuTestCycle( u32 startCycle, s32 delta );
-extern void cpuSetBranch();
+extern void cpuSetEvent();
 
-extern void _cpuBranchTest_Shared();		// for internal use by the Dynarecs and Ints inside R5900:
+extern void _cpuEventTest_Shared();		// for internal use by the Dynarecs and Ints inside R5900:
 
 extern void cpuTestINTCInts();
 extern void cpuTestDMACInts();

 

  ViewVC Help
Powered by ViewVC 1.1.22