/[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 62 - (hide annotations) (download)
Tue Sep 7 11:08:22 2010 UTC (9 years, 5 months ago) by william
File MIME type: text/plain
File size: 4437 byte(s)
Auto Commited Import of: pcsx2-0.9.7-r3738-debug in ./trunk
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 31 // Specialized function pointers for each read type
21     typedef mem8_t __fastcall vtlbMemR8FP(u32 addr);
22     typedef mem16_t __fastcall vtlbMemR16FP(u32 addr);
23     typedef mem32_t __fastcall vtlbMemR32FP(u32 addr);
24     typedef void __fastcall vtlbMemR64FP(u32 addr,mem64_t* data);
25     typedef void __fastcall vtlbMemR128FP(u32 addr,mem128_t* data);
26    
27     // Specialized function pointers for each write type
28     typedef void __fastcall vtlbMemW8FP(u32 addr,mem8_t data);
29     typedef void __fastcall vtlbMemW16FP(u32 addr,mem16_t data);
30     typedef void __fastcall vtlbMemW32FP(u32 addr,mem32_t data);
31     typedef void __fastcall vtlbMemW64FP(u32 addr,const mem64_t* data);
32     typedef void __fastcall vtlbMemW128FP(u32 addr,const mem128_t* data);
33    
34     typedef u32 vtlbHandler;
35    
36     extern void vtlb_Core_Alloc();
37     extern void vtlb_Core_Shutdown();
38     extern void vtlb_Init();
39     extern void vtlb_Reset();
40     extern void vtlb_Term();
41     extern u8* vtlb_malloc( uint size, uint align );
42     extern void vtlb_free( void* pmem, uint size );
43    
44    
45     extern vtlbHandler vtlb_NewHandler();
46    
47     extern vtlbHandler vtlb_RegisterHandler(
48     vtlbMemR8FP* r8,vtlbMemR16FP* r16,vtlbMemR32FP* r32,vtlbMemR64FP* r64,vtlbMemR128FP* r128,
49     vtlbMemW8FP* w8,vtlbMemW16FP* w16,vtlbMemW32FP* w32,vtlbMemW64FP* w64,vtlbMemW128FP* w128
50     );
51    
52     extern void vtlb_ReassignHandler( vtlbHandler rv,
53     vtlbMemR8FP* r8,vtlbMemR16FP* r16,vtlbMemR32FP* r32,vtlbMemR64FP* r64,vtlbMemR128FP* r128,
54     vtlbMemW8FP* w8,vtlbMemW16FP* w16,vtlbMemW32FP* w32,vtlbMemW64FP* w64,vtlbMemW128FP* w128
55     );
56    
57    
58     extern void vtlb_MapHandler(vtlbHandler handler,u32 start,u32 size);
59     extern void vtlb_MapBlock(void* base,u32 start,u32 size,u32 blocksize=0);
60     extern void* vtlb_GetPhyPtr(u32 paddr);
61     //extern void vtlb_Mirror(u32 new_region,u32 start,u32 size); // -> not working yet :(
62    
63     //virtual mappings
64     extern void vtlb_VMap(u32 vaddr,u32 paddr,u32 sz);
65     extern void vtlb_VMapBuffer(u32 vaddr,void* buffer,u32 sz);
66     extern void vtlb_VMapUnmap(u32 vaddr,u32 sz);
67    
68     //Memory functions
69    
70 william 62 template< typename DataType >
71     extern DataType __fastcall vtlb_memRead(u32 mem);
72     extern void __fastcall vtlb_memRead64(u32 mem, mem64_t *out);
73     extern void __fastcall vtlb_memRead128(u32 mem, mem128_t *out);
74 william 31
75 william 62 template< typename DataType >
76     extern void __fastcall vtlb_memWrite(u32 mem, DataType value);
77     extern void __fastcall vtlb_memWrite64(u32 mem, const mem64_t* value);
78     extern void __fastcall vtlb_memWrite128(u32 mem, const mem128_t* value);
79    
80 william 31 extern void vtlb_DynGenWrite(u32 sz);
81     extern void vtlb_DynGenRead32(u32 bits, bool sign);
82     extern void vtlb_DynGenRead64(u32 sz);
83    
84     extern void vtlb_DynGenWrite_Const( u32 bits, u32 addr_const );
85     extern void vtlb_DynGenRead64_Const( u32 bits, u32 addr_const );
86     extern void vtlb_DynGenRead32_Const( u32 bits, bool sign, u32 addr_const );
87    
88     namespace vtlb_private
89     {
90 william 62 // Allocate enough memory for both EE and IOP memory space (IOP is roughly 2.5mb,
91     // so we alloc 4mb for now -- a little more than is needed).
92     static const uint VTLB_ALLOC_SIZE = sizeof(*eeMem) + (_1mb*4);
93 william 31
94     static const uint VTLB_PAGE_BITS = 12;
95     static const uint VTLB_PAGE_MASK = 4095;
96     static const uint VTLB_PAGE_SIZE = 4096;
97    
98     static const uint VTLB_PMAP_ITEMS = 0x20000000 / VTLB_PAGE_SIZE;
99     static const uint VTLB_PMAP_SZ = 0x20000000;
100     static const uint VTLB_VMAP_ITEMS = 0x100000000ULL / VTLB_PAGE_SIZE;
101    
102     struct MapData
103     {
104     u8* alloc_base; //base of the memory array
105     int alloc_current; //current base
106    
107     s32 pmap[VTLB_PMAP_ITEMS]; //512KB
108     s32 vmap[VTLB_VMAP_ITEMS]; //4MB
109    
110     // first indexer -- 8/16/32/64/128 bit tables [values 0-4]
111     // second indexer -- read/write [0 or 1]
112     // third indexer -- 128 possible handlers!
113     void* RWFT[5][2][128];
114     };
115    
116     extern __aligned(64) MapData vtlbdata;
117     }

  ViewVC Help
Powered by ViewVC 1.1.22