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

Annotation of /trunk/pcsx2/System.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 280 - (hide annotations) (download)
Thu Dec 23 12:02:12 2010 UTC (9 years, 2 months ago) by william
File MIME type: text/plain
File size: 7603 byte(s)
re-commit (had local access denied errors when committing)
1 william 31 /* 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 william 62 #include "SysForwardDefs.h"
19    
20 william 31 #include "Utilities/SafeArray.h"
21     #include "Utilities/Threading.h" // to use threading stuff, include the Threading namespace in your file.
22     #include "CDVD/CDVDaccess.h"
23    
24 william 280 #include "vtlb.h"
25    
26 william 62 typedef SafeArray<u8> VmStateBuffer;
27 william 280
28 william 62 class BaseVUmicroCPU;
29 william 280 class RecompiledCodeReserve;
30 william 31
31 william 280 // This is a table of default virtual map addresses for ps2vm components. These locations
32     // are provided and used to assist in debugging and possibly hacking; as it makes it possible
33     // for a programmer to know exactly where to look (consistently!) for the base address of
34     // the various virtual machine components. These addresses can be keyed directly into the
35     // debugger's disasm window to get disassembly of recompiled code, and they can be used to help
36     // identify recompiled code addresses in the callstack.
37    
38     // All of these areas should be reserved as soon as possible during program startup, and its
39     // important that none of the areas overlap. In all but superVU's case, failure due to overlap
40     // or other conflict will result in the operating system picking a preferred address for the mapping.
41    
42     namespace HostMemoryMap
43     {
44     // superVU is OLD SCHOOL, and it requires its allocation to be in the lower 256mb
45     // of the virtual memory space. (8mb each)
46     static const uptr sVU0rec = _256mb - (_8mb*3);
47     static const uptr sVU1rec = _256mb - (_8mb*2);
48    
49     // PS2 main memory, SPR, and ROMs
50     static const uptr EEmem = 0x20000000;
51    
52     // IOP main memory and ROMs
53     static const uptr IOPmem = 0x24000000;
54    
55     // VU0 and VU1 memory.
56     static const uptr VUmem = 0x28000000;
57    
58     // EE recompiler code cache area (64mb)
59     static const uptr EErec = 0x30000000;
60    
61     // IOP recompiler code cache area (16 or 32mb)
62     static const uptr IOPrec = 0x34000000;
63    
64     // newVif0 recompiler code cache area (16mb)
65     static const uptr VIF0rec = 0x36000000;
66    
67     // newVif1 recompiler code cache area (32mb)
68     static const uptr VIF1rec = 0x38000000;
69    
70     // microVU1 recompiler code cache area (32 or 64mb)
71     static const uptr mVU0rec = 0x3C000000;
72    
73     // microVU0 recompiler code cache area (64mb)
74     static const uptr mVU1rec = 0x40000000;
75    
76     }
77    
78 william 62 // --------------------------------------------------------------------------------------
79 william 280 // SysMainMemory
80     // --------------------------------------------------------------------------------------
81     // This class provides the main memory for the virtual machines.
82     class SysMainMemory
83     {
84     protected:
85     eeMemoryReserve m_ee;
86     iopMemoryReserve m_iop;
87     vuMemoryReserve m_vu;
88    
89     public:
90     SysMainMemory();
91     virtual ~SysMainMemory() throw();
92    
93     virtual void ReserveAll();
94     virtual void CommitAll();
95     virtual void ResetAll();
96     virtual void DecommitAll();
97     virtual void ReleaseAll();
98     };
99    
100     // --------------------------------------------------------------------------------------
101 william 62 // SysAllocVM
102     // --------------------------------------------------------------------------------------
103     class SysAllocVM
104     {
105     public:
106     SysAllocVM();
107     virtual ~SysAllocVM() throw();
108 william 31
109 william 62 protected:
110     void CleanupMess() throw();
111     };
112 william 31
113     // --------------------------------------------------------------------------------------
114 william 62 // SysCpuProviderPack
115 william 31 // --------------------------------------------------------------------------------------
116 william 62 class SysCpuProviderPack
117 william 31 {
118     protected:
119 william 273 ScopedExcept m_RecExceptionEE;
120     ScopedExcept m_RecExceptionIOP;
121 william 62
122     public:
123 william 31 ScopedPtr<CpuInitializerSet> CpuProviders;
124    
125 william 62 SysCpuProviderPack();
126     virtual ~SysCpuProviderPack() throw();
127 william 31
128 william 62 void ApplyConfig() const;
129     BaseVUmicroCPU* getVUprovider(int whichProvider, int vuIndex) const;
130 william 31
131     bool HadSomeFailures( const Pcsx2Config::RecompilerOptions& recOpts ) const;
132    
133 william 62 bool IsRecAvailable_EE() const { return !m_RecExceptionEE; }
134     bool IsRecAvailable_IOP() const { return !m_RecExceptionIOP; }
135 william 31
136 william 62 BaseException* GetException_EE() const { return m_RecExceptionEE; }
137     BaseException* GetException_IOP() const { return m_RecExceptionIOP; }
138    
139 william 31 bool IsRecAvailable_MicroVU0() const;
140     bool IsRecAvailable_MicroVU1() const;
141 william 62 BaseException* GetException_MicroVU0() const;
142     BaseException* GetException_MicroVU1() const;
143 william 31
144     bool IsRecAvailable_SuperVU0() const;
145     bool IsRecAvailable_SuperVU1() const;
146 william 62 BaseException* GetException_SuperVU0() const;
147     BaseException* GetException_SuperVU1() const;
148 william 31
149     protected:
150     void CleanupMess() throw();
151     };
152    
153 william 62 // GetCpuProviders - this function is not implemented by PCSX2 core -- it must be
154 william 31 // implemented by the provisioning interface.
155 william 62 extern SysCpuProviderPack& GetCpuProviders();
156 william 31
157     extern void SysLogMachineCaps(); // Detects cpu type and fills cpuInfo structs.
158     extern void SysClearExecutionCache(); // clears recompiled execution caches!
159 william 280 extern void SysOutOfMemory_EmergencyResponse(uptr blocksize);
160 william 31
161     extern u8 *SysMmapEx(uptr base, u32 size, uptr bounds, const char *caller="Unnamed");
162     extern void vSyncDebugStuff( uint frame );
163     extern void NTFS_CompressFile( const wxString& file, bool compressStatus=true );
164    
165 william 62 extern wxString SysGetDiscID();
166    
167 william 280 extern SysMainMemory& GetVmMemory();
168    
169 william 31 // --------------------------------------------------------------------------------------
170     // PCSX2_SEH - Defines existence of "built in" Structured Exception Handling support.
171     // --------------------------------------------------------------------------------------
172     // This should be available on Windows, via Microsoft or Intel compilers (I'm pretty sure Intel
173     // supports native SEH model). GNUC in Windows, or any compiler in a non-windows platform, will
174     // need to use setjmp/longjmp instead to exit recompiled code.
175     //
176    
177     //#define PCSX2_SEH 0 // use this to force disable SEH on win32, to test setjmp functionality.
178    
179     #ifndef PCSX2_SEH
180     # if defined(_WIN32) && !defined(__GNUC__)
181     # define PCSX2_SEH 1
182     # else
183     # define PCSX2_SEH 0
184     # endif
185     #endif
186    
187     // special macro which disables inlining on functions that require their own function stackframe.
188     // This is due to how Win32 handles structured exception handling. Linux uses signals instead
189     // of SEH, and so these functions can be inlined.
190     #ifdef _WIN32
191     # define __unique_stackframe __noinline
192     #else
193     # define __unique_stackframe
194     #endif
195    
196    
197     //////////////////////////////////////////////////////////////////////////////////////////
198     // Different types of message boxes that the emulator can employ from the friendly confines
199     // of it's blissful unawareness of whatever GUI it runs under. :) All message boxes exhibit
200     // blocking behavior -- they prompt the user for action and only return after the user has
201     // responded to the prompt.
202     //
203    
204     namespace Msgbox
205     {
206     extern bool Alert( const wxString& text, const wxString& caption=L"PCSX2 Message", int icon=wxICON_EXCLAMATION );
207     extern bool OkCancel( const wxString& text, const wxString& caption=L"PCSX2 Message", int icon=0 );
208     extern bool YesNo( const wxString& text, const wxString& caption=L"PCSX2 Message", int icon=wxICON_QUESTION );
209    
210     extern int Assertion( const wxString& text, const wxString& stacktrace );
211     }
212    

  ViewVC Help
Powered by ViewVC 1.1.22