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

Annotation of /trunk/pcsx2/IopMem.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 280 - (hide annotations) (download)
Thu Dec 23 12:02:12 2010 UTC (9 years, 1 month ago) by william
File MIME type: text/plain
File size: 5430 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     #include "MemoryTypes.h"
19    
20     extern uptr *psxMemWLUT;
21     extern const uptr *psxMemRLUT;
22    
23    
24     // Obtains a writable pointer into the IOP's memory, with TLB address translation.
25     // If the address maps to read-only memory, NULL is returned.
26     // Hacky! This should really never be used, ever, since it bypasses the iop's Hardware
27     // Register handler and SPU/DEV/USB maps.
28     template<typename T>
29 william 62 static __fi T* iopVirtMemW( u32 mem )
30 william 31 {
31     return (psxMemWLUT[(mem) >> 16] == 0) ? NULL : (T*)(psxMemWLUT[(mem) >> 16] + ((mem) & 0xffff));
32     }
33    
34     // Obtains a read-safe pointer into the IOP's physical memory, with TLB address translation.
35     // Returns NULL if the address maps to an invalid/unmapped physical address.
36     //
37     // Hacky! This should really never be used, since anything reading through the
38     // TLB should be using iopMemRead/Write instead for each individual access. That ensures
39     // correct handling of page boundary crossings.
40     template<typename T>
41 william 62 static __fi const T* iopVirtMemR( u32 mem )
42 william 31 {
43     mem &= 0x1fffffff;
44     return (psxMemRLUT[mem >> 16] == 0) ? NULL : (const T*)(psxMemRLUT[mem >> 16] + (mem & 0xffff));
45     }
46    
47     // Obtains a pointer to the IOP's physical mapping (bypasses the TLB)
48 william 62 static __fi u8* iopPhysMem( u32 addr )
49 william 31 {
50 william 273 return &iopMem->Main[addr & 0x1fffff];
51 william 31 }
52    
53 william 273 #define psxSs8(mem) iopMem->Sif[(mem) & 0x00ff]
54     #define psxSs16(mem) (*(s16*)&iopMem->Sif[(mem) & 0x00ff])
55     #define psxSs32(mem) (*(s32*)&iopMem->Sif[(mem) & 0x00ff])
56     #define psxSu8(mem) (*(u8*) &iopMem->Sif[(mem) & 0x00ff])
57     #define psxSu16(mem) (*(u16*)&iopMem->Sif[(mem) & 0x00ff])
58     #define psxSu32(mem) (*(u32*)&iopMem->Sif[(mem) & 0x00ff])
59 william 31
60 william 273 #define psxPs8(mem) iopMem->P[(mem) & 0xffff]
61     #define psxPs16(mem) (*(s16*)&iopMem->P[(mem) & 0xffff])
62     #define psxPs32(mem) (*(s32*)&iopMem->P[(mem) & 0xffff])
63     #define psxPu8(mem) (*(u8*) &iopMem->P[(mem) & 0xffff])
64     #define psxPu16(mem) (*(u16*)&iopMem->P[(mem) & 0xffff])
65     #define psxPu32(mem) (*(u32*)&iopMem->P[(mem) & 0xffff])
66 william 31
67 william 273 #define psxHs8(mem) iopHw[(mem) & 0xffff]
68     #define psxHs16(mem) (*(s16*)&iopHw[(mem) & 0xffff])
69     #define psxHs32(mem) (*(s32*)&iopHw[(mem) & 0xffff])
70     #define psxHu8(mem) (*(u8*) &iopHw[(mem) & 0xffff])
71     #define psxHu16(mem) (*(u16*)&iopHw[(mem) & 0xffff])
72     #define psxHu32(mem) (*(u32*)&iopHw[(mem) & 0xffff])
73 william 31
74 william 280 extern void psxMemReserve();
75 william 31 extern void psxMemAlloc();
76     extern void psxMemReset();
77     extern void psxMemShutdown();
78    
79     extern u8 __fastcall iopMemRead8 (u32 mem);
80     extern u16 __fastcall iopMemRead16(u32 mem);
81     extern u32 __fastcall iopMemRead32(u32 mem);
82     extern void __fastcall iopMemWrite8 (u32 mem, u8 value);
83     extern void __fastcall iopMemWrite16(u32 mem, u16 value);
84     extern void __fastcall iopMemWrite32(u32 mem, u32 value);
85    
86     namespace IopMemory
87     {
88     // Sif functions not made yet (will for future Iop improvements):
89     extern mem8_t __fastcall SifRead8( u32 iopaddr );
90     extern mem16_t __fastcall SifRead16( u32 iopaddr );
91     extern mem32_t __fastcall SifRead32( u32 iopaddr );
92    
93     extern void __fastcall SifWrite8( u32 iopaddr, mem8_t data );
94     extern void __fastcall SifWrite16( u32 iopaddr, mem16_t data );
95     extern void __fastcall SifWrite32( u32 iopaddr, mem32_t data );
96    
97     extern mem8_t __fastcall iopHwRead8_generic( u32 addr );
98     extern mem16_t __fastcall iopHwRead16_generic( u32 addr );
99     extern mem32_t __fastcall iopHwRead32_generic( u32 addr );
100     extern void __fastcall iopHwWrite8_generic( u32 addr, mem8_t val );
101     extern void __fastcall iopHwWrite16_generic( u32 addr, mem16_t val );
102     extern void __fastcall iopHwWrite32_generic( u32 addr, mem32_t val );
103    
104    
105     extern mem8_t __fastcall iopHwRead8_Page1( u32 iopaddr );
106     extern mem8_t __fastcall iopHwRead8_Page3( u32 iopaddr );
107     extern mem8_t __fastcall iopHwRead8_Page8( u32 iopaddr );
108     extern mem16_t __fastcall iopHwRead16_Page1( u32 iopaddr );
109     extern mem16_t __fastcall iopHwRead16_Page3( u32 iopaddr );
110     extern mem16_t __fastcall iopHwRead16_Page8( u32 iopaddr );
111     extern mem32_t __fastcall iopHwRead32_Page1( u32 iopaddr );
112     extern mem32_t __fastcall iopHwRead32_Page3( u32 iopaddr );
113     extern mem32_t __fastcall iopHwRead32_Page8( u32 iopaddr );
114    
115     extern void __fastcall iopHwWrite8_Page1( u32 iopaddr, mem8_t data );
116     extern void __fastcall iopHwWrite8_Page3( u32 iopaddr, mem8_t data );
117     extern void __fastcall iopHwWrite8_Page8( u32 iopaddr, mem8_t data );
118     extern void __fastcall iopHwWrite16_Page1( u32 iopaddr, mem16_t data );
119     extern void __fastcall iopHwWrite16_Page3( u32 iopaddr, mem16_t data );
120     extern void __fastcall iopHwWrite16_Page8( u32 iopaddr, mem16_t data );
121     extern void __fastcall iopHwWrite32_Page1( u32 iopaddr, mem32_t data );
122     extern void __fastcall iopHwWrite32_Page3( u32 iopaddr, mem32_t data );
123     extern void __fastcall iopHwWrite32_Page8( u32 iopaddr, mem32_t data );
124     }

  ViewVC Help
Powered by ViewVC 1.1.22