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

Diff of /trunk/pcsx2/vtlb.h

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

revision 62 by william, Tue Sep 7 11:08:22 2010 UTC revision 280 by william, Thu Dec 23 12:02:12 2010 UTC
# Line 17  Line 17 
17    
18  #include "MemoryTypes.h"  #include "MemoryTypes.h"
19    
20    #include "Utilities/PageFaultSource.h"
21    
22    static const uptr VTLB_AllocUpperBounds = _1gb * 2;
23    
24  // Specialized function pointers for each read type  // Specialized function pointers for each read type
25  typedef  mem8_t __fastcall vtlbMemR8FP(u32 addr);  typedef  mem8_t __fastcall vtlbMemR8FP(u32 addr);
26  typedef  mem16_t __fastcall vtlbMemR16FP(u32 addr);  typedef  mem16_t __fastcall vtlbMemR16FP(u32 addr);
# Line 34  typedef  void __fastcall vtlbMemW128FP(u Line 38  typedef  void __fastcall vtlbMemW128FP(u
38  typedef u32 vtlbHandler;  typedef u32 vtlbHandler;
39    
40  extern void vtlb_Core_Alloc();  extern void vtlb_Core_Alloc();
41  extern void vtlb_Core_Shutdown();  extern void vtlb_Core_Free();
42  extern void vtlb_Init();  extern void vtlb_Init();
43  extern void vtlb_Reset();  extern void vtlb_Reset();
44  extern void vtlb_Term();  extern void vtlb_Term();
 extern u8* vtlb_malloc( uint size, uint align );  
 extern void vtlb_free( void* pmem, uint size );  
45    
46    
47  extern vtlbHandler vtlb_NewHandler();  extern vtlbHandler vtlb_NewHandler();
# Line 85  extern void vtlb_DynGenWrite_Const( u32 Line 87  extern void vtlb_DynGenWrite_Const( u32
87  extern void vtlb_DynGenRead64_Const( u32 bits, u32 addr_const );  extern void vtlb_DynGenRead64_Const( u32 bits, u32 addr_const );
88  extern void vtlb_DynGenRead32_Const( u32 bits, bool sign, u32 addr_const );  extern void vtlb_DynGenRead32_Const( u32 bits, bool sign, u32 addr_const );
89    
90  namespace vtlb_private  // --------------------------------------------------------------------------------------
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          // Allocate enough memory for both EE and IOP memory space (IOP is roughly 2.5mb,          typedef VtlbMemoryReserve _parent;
164          // so we alloc 4mb for now -- a little more than is needed).  
165          static const uint VTLB_ALLOC_SIZE = sizeof(*eeMem) + (_1mb*4);  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    namespace vtlb_private
179    {
180          static const uint VTLB_PAGE_BITS = 12;          static const uint VTLB_PAGE_BITS = 12;
181          static const uint VTLB_PAGE_MASK = 4095;          static const uint VTLB_PAGE_MASK = 4095;
182          static const uint VTLB_PAGE_SIZE = 4096;          static const uint VTLB_PAGE_SIZE = 4096;
183    
184          static const uint VTLB_PMAP_ITEMS = 0x20000000 / VTLB_PAGE_SIZE;          static const uint VTLB_PMAP_SZ          = _1mb * 512;
185          static const uint VTLB_PMAP_SZ = 0x20000000;          static const uint VTLB_PMAP_ITEMS       = VTLB_PMAP_SZ / VTLB_PAGE_SIZE;
186          static const uint VTLB_VMAP_ITEMS = 0x100000000ULL / VTLB_PAGE_SIZE;          static const uint VTLB_VMAP_ITEMS       = _4gb / VTLB_PAGE_SIZE;
187    
188            static const uint VTLB_HANDLER_ITEMS = 128;
189    
190          struct MapData          struct MapData
191          {          {
                 u8* alloc_base;                 //base of the memory array  
                 int alloc_current;              //current base  
   
                 s32 pmap[VTLB_PMAP_ITEMS];      //512KB  
                 s32 vmap[VTLB_VMAP_ITEMS];   //4MB  
   
192                  // first indexer -- 8/16/32/64/128 bit tables [values 0-4]                  // first indexer -- 8/16/32/64/128 bit tables [values 0-4]
193                  // second indexer -- read/write  [0 or 1]                  // second indexer -- read/write  [0 or 1]
194                  // third indexer -- 128 possible handlers!                  // third indexer -- 128 possible handlers!
195                  void* RWFT[5][2][128];                  void* RWFT[5][2][VTLB_HANDLER_ITEMS];
196    
197                    s32 pmap[VTLB_PMAP_ITEMS];      //512KB
198    
199                    s32* vmap;                              //4MB (allocated by vtlb_init)
200    
201                    MapData()
202                    {
203                            vmap = NULL;
204                    }
205          };          };
206    
207          extern __aligned(64) MapData vtlbdata;          extern __aligned(64) MapData vtlbdata;

Legend:
Removed from v.62  
changed lines
  Added in v.280

  ViewVC Help
Powered by ViewVC 1.1.22