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

Annotation of /trunk/pcsx2/vtlb.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 280 - (hide annotations) (download)
Thu Dec 23 12:02:12 2010 UTC (9 years, 7 months ago) by william
File MIME type: text/plain
File size: 6220 byte(s)
re-commit (had local access denied errors when committing)
1 william 62 /* 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 william 31
16     #pragma once
17    
18 william 62 #include "MemoryTypes.h"
19    
20 william 280 #include "Utilities/PageFaultSource.h"
21    
22     static const uptr VTLB_AllocUpperBounds = _1gb * 2;
23    
24 william 31 // Specialized function pointers for each read type
25     typedef mem8_t __fastcall vtlbMemR8FP(u32 addr);
26     typedef mem16_t __fastcall vtlbMemR16FP(u32 addr);
27     typedef mem32_t __fastcall vtlbMemR32FP(u32 addr);
28     typedef void __fastcall vtlbMemR64FP(u32 addr,mem64_t* data);
29     typedef void __fastcall vtlbMemR128FP(u32 addr,mem128_t* data);
30    
31     // Specialized function pointers for each write type
32     typedef void __fastcall vtlbMemW8FP(u32 addr,mem8_t data);
33     typedef void __fastcall vtlbMemW16FP(u32 addr,mem16_t data);
34     typedef void __fastcall vtlbMemW32FP(u32 addr,mem32_t data);
35     typedef void __fastcall vtlbMemW64FP(u32 addr,const mem64_t* data);
36     typedef void __fastcall vtlbMemW128FP(u32 addr,const mem128_t* data);
37    
38     typedef u32 vtlbHandler;
39    
40     extern void vtlb_Core_Alloc();
41 william 280 extern void vtlb_Core_Free();
42 william 31 extern void vtlb_Init();
43     extern void vtlb_Reset();
44     extern void vtlb_Term();
45    
46    
47     extern vtlbHandler vtlb_NewHandler();
48    
49     extern vtlbHandler vtlb_RegisterHandler(
50     vtlbMemR8FP* r8,vtlbMemR16FP* r16,vtlbMemR32FP* r32,vtlbMemR64FP* r64,vtlbMemR128FP* r128,
51     vtlbMemW8FP* w8,vtlbMemW16FP* w16,vtlbMemW32FP* w32,vtlbMemW64FP* w64,vtlbMemW128FP* w128
52     );
53    
54     extern void vtlb_ReassignHandler( vtlbHandler rv,
55     vtlbMemR8FP* r8,vtlbMemR16FP* r16,vtlbMemR32FP* r32,vtlbMemR64FP* r64,vtlbMemR128FP* r128,
56     vtlbMemW8FP* w8,vtlbMemW16FP* w16,vtlbMemW32FP* w32,vtlbMemW64FP* w64,vtlbMemW128FP* w128
57     );
58    
59    
60     extern void vtlb_MapHandler(vtlbHandler handler,u32 start,u32 size);
61     extern void vtlb_MapBlock(void* base,u32 start,u32 size,u32 blocksize=0);
62     extern void* vtlb_GetPhyPtr(u32 paddr);
63     //extern void vtlb_Mirror(u32 new_region,u32 start,u32 size); // -> not working yet :(
64    
65     //virtual mappings
66     extern void vtlb_VMap(u32 vaddr,u32 paddr,u32 sz);
67     extern void vtlb_VMapBuffer(u32 vaddr,void* buffer,u32 sz);
68     extern void vtlb_VMapUnmap(u32 vaddr,u32 sz);
69    
70     //Memory functions
71    
72 william 62 template< typename DataType >
73     extern DataType __fastcall vtlb_memRead(u32 mem);
74     extern void __fastcall vtlb_memRead64(u32 mem, mem64_t *out);
75     extern void __fastcall vtlb_memRead128(u32 mem, mem128_t *out);
76 william 31
77 william 62 template< typename DataType >
78     extern void __fastcall vtlb_memWrite(u32 mem, DataType value);
79     extern void __fastcall vtlb_memWrite64(u32 mem, const mem64_t* value);
80     extern void __fastcall vtlb_memWrite128(u32 mem, const mem128_t* value);
81    
82 william 31 extern void vtlb_DynGenWrite(u32 sz);
83     extern void vtlb_DynGenRead32(u32 bits, bool sign);
84     extern void vtlb_DynGenRead64(u32 sz);
85    
86     extern void vtlb_DynGenWrite_Const( u32 bits, u32 addr_const );
87     extern void vtlb_DynGenRead64_Const( u32 bits, u32 addr_const );
88     extern void vtlb_DynGenRead32_Const( u32 bits, bool sign, u32 addr_const );
89    
90 william 280 // --------------------------------------------------------------------------------------
91     // VtlbMemoryReserve
92     // --------------------------------------------------------------------------------------
93     class VtlbMemoryReserve
94     {
95     protected:
96     VirtualMemoryReserve m_reserve;
97    
98     public:
99     VtlbMemoryReserve( const wxString& name, size_t size );
100     virtual ~VtlbMemoryReserve() throw()
101     {
102     m_reserve.Release();
103     }
104    
105     virtual void Reserve( sptr hostptr );
106     virtual void Release();
107    
108     virtual void Commit();
109     virtual void Reset();
110     virtual void Decommit();
111     virtual void SetBaseAddr( uptr newaddr );
112    
113     bool IsCommitted() const;
114     };
115    
116     // --------------------------------------------------------------------------------------
117     // eeMemoryReserve
118     // --------------------------------------------------------------------------------------
119     class eeMemoryReserve : public VtlbMemoryReserve
120     {
121     typedef VtlbMemoryReserve _parent;
122    
123     public:
124     eeMemoryReserve();
125     virtual ~eeMemoryReserve() throw()
126     {
127     Release();
128     }
129    
130     void Reserve();
131     void Commit();
132     void Decommit();
133     void Reset();
134     void Release();
135     };
136    
137     // --------------------------------------------------------------------------------------
138     // iopMemoryReserve
139     // --------------------------------------------------------------------------------------
140     class iopMemoryReserve : public VtlbMemoryReserve
141     {
142     typedef VtlbMemoryReserve _parent;
143    
144     public:
145     iopMemoryReserve();
146     virtual ~iopMemoryReserve() throw()
147     {
148     Release();
149     }
150    
151     void Reserve();
152     void Commit();
153     void Decommit();
154     void Release();
155     void Reset();
156     };
157    
158     // --------------------------------------------------------------------------------------
159     // vuMemoryReserve
160     // --------------------------------------------------------------------------------------
161     class vuMemoryReserve : public VtlbMemoryReserve
162     {
163     typedef VtlbMemoryReserve _parent;
164    
165     public:
166     vuMemoryReserve();
167     virtual ~vuMemoryReserve() throw()
168     {
169     Release();
170     }
171    
172     virtual void Reserve();
173     virtual void Release();
174    
175     void Reset();
176     };
177    
178 william 31 namespace vtlb_private
179     {
180     static const uint VTLB_PAGE_BITS = 12;
181     static const uint VTLB_PAGE_MASK = 4095;
182     static const uint VTLB_PAGE_SIZE = 4096;
183    
184 william 280 static const uint VTLB_PMAP_SZ = _1mb * 512;
185     static const uint VTLB_PMAP_ITEMS = VTLB_PMAP_SZ / VTLB_PAGE_SIZE;
186     static const uint VTLB_VMAP_ITEMS = _4gb / VTLB_PAGE_SIZE;
187 william 31
188 william 280 static const uint VTLB_HANDLER_ITEMS = 128;
189    
190 william 31 struct MapData
191     {
192 william 280 // first indexer -- 8/16/32/64/128 bit tables [values 0-4]
193     // second indexer -- read/write [0 or 1]
194     // third indexer -- 128 possible handlers!
195     void* RWFT[5][2][VTLB_HANDLER_ITEMS];
196 william 31
197     s32 pmap[VTLB_PMAP_ITEMS]; //512KB
198    
199 william 280 s32* vmap; //4MB (allocated by vtlb_init)
200    
201     MapData()
202     {
203     vmap = NULL;
204     }
205 william 31 };
206    
207     extern __aligned(64) MapData vtlbdata;
208     }

  ViewVC Help
Powered by ViewVC 1.1.22