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

Contents of /trunk/pcsx2/IopMem.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 273 - (show annotations) (download)
Fri Nov 12 01:10:22 2010 UTC (9 years, 3 months ago) by william
File MIME type: text/plain
File size: 5401 byte(s)
Auto Commited Import of: pcsx2-0.9.7-DEBUG (upstream: v0.9.7.4013 local: v0.9.7.197-latest) in ./trunk
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 #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 static __fi T* iopVirtMemW( u32 mem )
30 {
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 static __fi const T* iopVirtMemR( u32 mem )
42 {
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 static __fi u8* iopPhysMem( u32 addr )
49 {
50 return &iopMem->Main[addr & 0x1fffff];
51 }
52
53 #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
60 #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
67 #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
74 extern void psxMemAlloc();
75 extern void psxMemReset();
76 extern void psxMemShutdown();
77
78 extern u8 __fastcall iopMemRead8 (u32 mem);
79 extern u16 __fastcall iopMemRead16(u32 mem);
80 extern u32 __fastcall iopMemRead32(u32 mem);
81 extern void __fastcall iopMemWrite8 (u32 mem, u8 value);
82 extern void __fastcall iopMemWrite16(u32 mem, u16 value);
83 extern void __fastcall iopMemWrite32(u32 mem, u32 value);
84
85 namespace IopMemory
86 {
87 // Sif functions not made yet (will for future Iop improvements):
88 extern mem8_t __fastcall SifRead8( u32 iopaddr );
89 extern mem16_t __fastcall SifRead16( u32 iopaddr );
90 extern mem32_t __fastcall SifRead32( u32 iopaddr );
91
92 extern void __fastcall SifWrite8( u32 iopaddr, mem8_t data );
93 extern void __fastcall SifWrite16( u32 iopaddr, mem16_t data );
94 extern void __fastcall SifWrite32( u32 iopaddr, mem32_t data );
95
96 extern mem8_t __fastcall iopHwRead8_generic( u32 addr );
97 extern mem16_t __fastcall iopHwRead16_generic( u32 addr );
98 extern mem32_t __fastcall iopHwRead32_generic( u32 addr );
99 extern void __fastcall iopHwWrite8_generic( u32 addr, mem8_t val );
100 extern void __fastcall iopHwWrite16_generic( u32 addr, mem16_t val );
101 extern void __fastcall iopHwWrite32_generic( u32 addr, mem32_t val );
102
103
104 extern mem8_t __fastcall iopHwRead8_Page1( u32 iopaddr );
105 extern mem8_t __fastcall iopHwRead8_Page3( u32 iopaddr );
106 extern mem8_t __fastcall iopHwRead8_Page8( u32 iopaddr );
107 extern mem16_t __fastcall iopHwRead16_Page1( u32 iopaddr );
108 extern mem16_t __fastcall iopHwRead16_Page3( u32 iopaddr );
109 extern mem16_t __fastcall iopHwRead16_Page8( u32 iopaddr );
110 extern mem32_t __fastcall iopHwRead32_Page1( u32 iopaddr );
111 extern mem32_t __fastcall iopHwRead32_Page3( u32 iopaddr );
112 extern mem32_t __fastcall iopHwRead32_Page8( u32 iopaddr );
113
114 extern void __fastcall iopHwWrite8_Page1( u32 iopaddr, mem8_t data );
115 extern void __fastcall iopHwWrite8_Page3( u32 iopaddr, mem8_t data );
116 extern void __fastcall iopHwWrite8_Page8( u32 iopaddr, mem8_t data );
117 extern void __fastcall iopHwWrite16_Page1( u32 iopaddr, mem16_t data );
118 extern void __fastcall iopHwWrite16_Page3( u32 iopaddr, mem16_t data );
119 extern void __fastcall iopHwWrite16_Page8( u32 iopaddr, mem16_t data );
120 extern void __fastcall iopHwWrite32_Page1( u32 iopaddr, mem32_t data );
121 extern void __fastcall iopHwWrite32_Page3( u32 iopaddr, mem32_t data );
122 extern void __fastcall iopHwWrite32_Page8( u32 iopaddr, mem32_t data );
123 }

  ViewVC Help
Powered by ViewVC 1.1.22