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

Contents of /trunk/pcsx2/System/PageFaultSource.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 31 - (show annotations) (download)
Tue Sep 7 03:24:11 2010 UTC (9 years, 11 months ago) by william
File MIME type: text/plain
File size: 3147 byte(s)
committing r3113 initial commit again...
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 // Cross-Platform Memory Protection (Used by VTLB, Recompilers and Texture caches)
20 // =====================================================================================================
21 // Win32 platforms use the SEH model: __try {} __except {}
22 // Linux platforms use the POSIX Signals model: sigaction()
23
24 #include "Utilities/EventSource.h"
25
26 struct PageFaultInfo
27 {
28 uptr addr;
29
30 PageFaultInfo( uptr address )
31 {
32 addr = address;
33 }
34 };
35
36 // --------------------------------------------------------------------------------------
37 // IEventListener_PageFault
38 // --------------------------------------------------------------------------------------
39 class IEventListener_PageFault : public IEventDispatcher<PageFaultInfo>
40 {
41 public:
42 typedef PageFaultInfo EvtParams;
43
44 public:
45 virtual ~IEventListener_PageFault() throw() {}
46
47 virtual void DispatchEvent( const PageFaultInfo& evtinfo, bool& handled )
48 {
49 OnPageFaultEvent( evtinfo, handled );
50 }
51
52 virtual void DispatchEvent( const PageFaultInfo& evtinfo )
53 {
54 pxFailRel( "Don't call me, damnit. Use DispatchException instead." );
55 }
56
57 protected:
58 virtual void OnPageFaultEvent( const PageFaultInfo& evtinfo, bool& handled ) {}
59 };
60
61 class EventListener_PageFault : public IEventListener_PageFault
62 {
63 public:
64 EventListener_PageFault();
65 virtual ~EventListener_PageFault() throw();
66 };
67
68 class SrcType_PageFault : public EventSource<IEventListener_PageFault>
69 {
70 protected:
71 typedef EventSource<IEventListener_PageFault> _parent;
72
73 protected:
74 bool m_handled;
75
76 public:
77 SrcType_PageFault() {}
78 virtual ~SrcType_PageFault() throw() { }
79
80 bool WasHandled() const { return m_handled; }
81 virtual void Dispatch( const PageFaultInfo& params );
82
83 protected:
84 virtual void _DispatchRaw( ListenerIterator iter, const ListenerIterator& iend, const PageFaultInfo& evt );
85 };
86
87 #ifdef __LINUX__
88
89 # define PCSX2_PAGEFAULT_PROTECT
90 # define PCSX2_PAGEFAULT_EXCEPT
91
92 #elif defined( _WIN32 )
93
94 struct _EXCEPTION_POINTERS;
95 extern int SysPageFaultExceptionFilter(struct _EXCEPTION_POINTERS* eps);
96
97 # define PCSX2_PAGEFAULT_PROTECT __try
98 # define PCSX2_PAGEFAULT_EXCEPT __except(SysPageFaultExceptionFilter(GetExceptionInformation())) {}
99
100 #else
101 # error PCSX2 - Unsupported operating system platform.
102 #endif
103
104
105 extern void InstallSignalHandler();
106
107 extern SrcType_PageFault Source_PageFault;

  ViewVC Help
Powered by ViewVC 1.1.22