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

Contents of /trunk/pcsx2/R5900Exceptions.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62 - (show annotations) (download)
Tue Sep 7 11:08:22 2010 UTC (9 years, 5 months ago) by william
File MIME type: text/plain
File size: 3732 byte(s)
Auto Commited Import of: pcsx2-0.9.7-r3738-debug in ./trunk
1 /* PCSX2 - PS2 Emulator for PCs
2 * Copyright (C) 2002-2010 PCSX2 Dev Team
3 *
4 * PCSX2 is free software: you can redistribute it and/or modify it under the terms
5 * of the GNU Lesser General Public License as published by the Free Software Found-
6 * ation, either version 3 of the License, or (at your option) any later version.
7 *
8 * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10 * PURPOSE. See the GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License along with PCSX2.
13 * If not, see <http://www.gnu.org/licenses/>.
14 */
15
16 #pragma once
17
18 // --------------------------------------------------------------------------------------
19 // BaseR5900Exception
20 // --------------------------------------------------------------------------------------
21 // Abstract base class for R5900 exceptions; contains the cpuRegs instance at the
22 // time the exception is raised.
23 //
24 // Translation note: EE Emulation exceptions are untranslated only. There's really no
25 // point in providing translations for this hardcore mess. :)
26 //
27 class BaseR5900Exception : public Exception::Ps2Generic
28 {
29 DEFINE_EXCEPTION_COPYTORS(BaseR5900Exception, Exception::Ps2Generic)
30
31 public:
32 cpuRegisters cpuState;
33
34 public:
35 u32 GetPc() const { return cpuState.pc; }
36 bool IsDelaySlot() const { return !!cpuState.IsDelaySlot; }
37
38 wxString& Message() { return m_message; }
39 wxString FormatMessage() const
40 {
41 return wxsFormat(L"(EE pc:%8.8X) ", cpuRegs.pc) + m_message;
42 }
43
44 protected:
45 void Init( const wxString& msg )
46 {
47 m_message = msg;;
48 cpuState = cpuRegs;
49 }
50
51 void Init( const char* msg )
52 {
53 m_message = fromUTF8( msg );
54 cpuState = cpuRegs;
55 }
56 };
57
58 namespace R5900Exception
59 {
60 // --------------------------------------------------------------------------------------
61 // BaseAddressError
62 // --------------------------------------------------------------------------------------
63 class BaseAddressError : public BaseR5900Exception
64 {
65 DEFINE_EXCEPTION_COPYTORS(BaseAddressError, BaseR5900Exception)
66
67 public:
68 bool OnWrite;
69 u32 Address;
70
71 protected:
72 void Init( u32 ps2addr, bool onWrite, const wxString& msg )
73 {
74 _parent::Init( wxsFormat( msg+L", addr=0x%x [%s]", ps2addr, onWrite ? L"store" : L"load" ) );
75 OnWrite = onWrite;
76 Address = ps2addr;
77 }
78 };
79
80
81 class AddressError : public BaseAddressError
82 {
83 public:
84 AddressError( u32 ps2addr, bool onWrite )
85 {
86 BaseAddressError::Init( ps2addr, onWrite, L"Address error" );
87 }
88 };
89
90 class TLBMiss : public BaseAddressError
91 {
92 DEFINE_EXCEPTION_COPYTORS(TLBMiss, BaseAddressError)
93
94 public:
95 TLBMiss( u32 ps2addr, bool onWrite )
96 {
97 BaseAddressError::Init( ps2addr, onWrite, L"TLB Miss" );
98 }
99 };
100
101 class BusError : public BaseAddressError
102 {
103 DEFINE_EXCEPTION_COPYTORS(BusError, BaseAddressError)
104
105 public:
106 BusError( u32 ps2addr, bool onWrite )
107 {
108 BaseAddressError::Init( ps2addr, onWrite, L"Bus Error" );
109 }
110 };
111
112 class Trap : public BaseR5900Exception
113 {
114 DEFINE_EXCEPTION_COPYTORS(Trap, BaseR5900Exception)
115
116 public:
117 u16 TrapCode;
118
119 public:
120 // Generates a trap for immediate-style Trap opcodes
121 Trap()
122 {
123 _parent::Init( "Trap" );
124 TrapCode = 0;
125 }
126
127 // Generates a trap for register-style Trap instructions, which contain an
128 // error code in the opcode
129 explicit Trap( u16 trapcode )
130 {
131 _parent::Init( "Trap" ),
132 TrapCode = trapcode;
133 }
134 };
135
136 class DebugBreakpoint : public BaseR5900Exception
137 {
138 DEFINE_EXCEPTION_COPYTORS(DebugBreakpoint, BaseR5900Exception)
139
140 public:
141 explicit DebugBreakpoint()
142 {
143 _parent::Init( "Debug Breakpoint" );
144 }
145 };
146 }

  ViewVC Help
Powered by ViewVC 1.1.22