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

Contents of /trunk/pcsx2/Memory.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 280 - (show annotations) (download)
Thu Dec 23 12:02:12 2010 UTC (9 years, 1 month ago) by william
File MIME type: text/plain
File size: 6158 byte(s)
re-commit (had local access denied errors when committing)
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 #ifdef __LINUX__
19 #include <signal.h>
20 #endif
21
22 //#define ENABLECACHE
23 #include "vtlb.h"
24
25 #include <xmmintrin.h>
26
27 // [TODO] This *could* be replaced with an assignment operator on u128 that implicitly
28 // uses _mm_store and _mm_load internally. However, there are alignment concerns --
29 // u128 is not alignment strict. (we would need a u128 and u128a for types known to
30 // be strictly 128-bit aligned).
31 static __fi void CopyQWC( void* dest, const void* src )
32 {
33 _mm_store_ps( (float*)dest, _mm_load_ps((const float*)src) );
34 }
35
36 static __fi void ZeroQWC( void* dest )
37 {
38 _mm_store_ps( (float*)dest, _mm_setzero_ps() );
39 }
40
41 static __fi void ZeroQWC( u128& dest )
42 {
43 _mm_store_ps( (float*)&dest, _mm_setzero_ps() );
44 }
45
46 #define PSM(mem) (vtlb_GetPhyPtr((mem)&0x1fffffff)) //pcsx2 is a competition.The one with most hacks wins :D
47
48 #define psHs8(mem) (*(s8 *)&eeHw[(mem) & 0xffff])
49 #define psHs16(mem) (*(s16*)&eeHw[(mem) & 0xffff])
50 #define psHs32(mem) (*(s32*)&eeHw[(mem) & 0xffff])
51 #define psHs64(mem) (*(s64*)&eeHw[(mem) & 0xffff])
52 #define psHu8(mem) (*(u8 *)&eeHw[(mem) & 0xffff])
53 #define psHu16(mem) (*(u16*)&eeHw[(mem) & 0xffff])
54 #define psHu32(mem) (*(u32*)&eeHw[(mem) & 0xffff])
55 #define psHu64(mem) (*(u64*)&eeHw[(mem) & 0xffff])
56 #define psHu128(mem)(*(u128*)&eeHw[(mem) & 0xffff])
57
58 #define psMs8(mem) (*(s8 *)&eeMem->Main[(mem) & 0x1ffffff])
59 #define psMs16(mem) (*(s16*)&eeMem->Main[(mem) & 0x1ffffff])
60 #define psMs32(mem) (*(s32*)&eeMem->Main[(mem) & 0x1ffffff])
61 #define psMs64(mem) (*(s64*)&eeMem->Main[(mem) & 0x1ffffff])
62 #define psMu8(mem) (*(u8 *)&eeMem->Main[(mem) & 0x1ffffff])
63 #define psMu16(mem) (*(u16*)&eeMem->Main[(mem) & 0x1ffffff])
64 #define psMu32(mem) (*(u32*)&eeMem->Main[(mem) & 0x1ffffff])
65 #define psMu64(mem) (*(u64*)&eeMem->Main[(mem) & 0x1ffffff])
66
67 #define psRs8(mem) (*(s8 *)&eeMem->ROM[(mem) & 0x3fffff])
68 #define psRs16(mem) (*(s16*)&eeMem->ROM[(mem) & 0x3fffff])
69 #define psRs32(mem) (*(s32*)&eeMem->ROM[(mem) & 0x3fffff])
70 #define psRs64(mem) (*(s64*)&eeMem->ROM[(mem) & 0x3fffff])
71 #define psRu8(mem) (*(u8 *)&eeMem->ROM[(mem) & 0x3fffff])
72 #define psRu16(mem) (*(u16*)&eeMem->ROM[(mem) & 0x3fffff])
73 #define psRu32(mem) (*(u32*)&eeMem->ROM[(mem) & 0x3fffff])
74 #define psRu64(mem) (*(u64*)&eeMem->ROM[(mem) & 0x3fffff])
75
76 #define psR1s8(mem) (*(s8 *)&eeMem->ROM1[(mem) & 0x3ffff])
77 #define psR1s16(mem) (*(s16*)&eeMem->ROM1[(mem) & 0x3ffff])
78 #define psR1s32(mem) (*(s32*)&eeMem->ROM1[(mem) & 0x3ffff])
79 #define psR1s64(mem) (*(s64*)&eeMem->ROM1[(mem) & 0x3ffff])
80 #define psR1u8(mem) (*(u8 *)&eeMem->ROM1[(mem) & 0x3ffff])
81 #define psR1u16(mem) (*(u16*)&eeMem->ROM1[(mem) & 0x3ffff])
82 #define psR1u32(mem) (*(u32*)&eeMem->ROM1[(mem) & 0x3ffff])
83 #define psR1u64(mem) (*(u64*)&eeMem->ROM1[(mem) & 0x3ffff])
84
85 #define psR2s8(mem) (*(s8 *)&eeMem->ROM2[(mem) & 0x3ffff])
86 #define psR2s16(mem) (*(s16*)&eeMem->ROM2[(mem) & 0x3ffff])
87 #define psR2s32(mem) (*(s32*)&eeMem->ROM2[(mem) & 0x3ffff])
88 #define psR2s64(mem) (*(s64*)&eeMem->ROM2[(mem) & 0x3ffff])
89 #define psR2u8(mem) (*(u8 *)&eeMem->ROM2[(mem) & 0x3ffff])
90 #define psR2u16(mem) (*(u16*)&eeMem->ROM2[(mem) & 0x3ffff])
91 #define psR2u32(mem) (*(u32*)&eeMem->ROM2[(mem) & 0x3ffff])
92 #define psR2u64(mem) (*(u64*)&eeMem->ROM2[(mem) & 0x3ffff])
93
94 #define psERs8(mem) (*(s8 *)&eeMem->EROM[(mem) & 0x3ffff])
95 #define psERs16(mem) (*(s16*)&eeMem->EROM[(mem) & 0x3ffff])
96 #define psERs32(mem) (*(s32*)&eeMem->EROM[(mem) & 0x3ffff])
97 #define psERs64(mem) (*(s64*)&eeMem->EROM[(mem) & 0x3ffff])
98 #define psERu8(mem) (*(u8 *)&eeMem->EROM[(mem) & 0x3ffff])
99 #define psERu16(mem) (*(u16*)&eeMem->EROM[(mem) & 0x3ffff])
100 #define psERu32(mem) (*(u32*)&eeMem->EROM[(mem) & 0x3ffff])
101 #define psERu64(mem) (*(u64*)&eeMem->EROM[(mem) & 0x3ffff])
102
103 #define psSs32(mem) (*(s32 *)&eeMem->Scratch[(mem) & 0x3fff])
104 #define psSs64(mem) (*(s64 *)&eeMem->Scratch[(mem) & 0x3fff])
105 #define psSs128(mem) (*(s128*)&eeMem->Scratch[(mem) & 0x3fff])
106 #define psSu32(mem) (*(u32 *)&eeMem->Scratch[(mem) & 0x3fff])
107 #define psSu64(mem) (*(u64 *)&eeMem->Scratch[(mem) & 0x3fff])
108 #define psSu128(mem) (*(u128*)&eeMem->Scratch[(mem) & 0x3fff])
109
110
111 extern void memSetKernelMode();
112 //extern void memSetSupervisorMode();
113 extern void memSetUserMode();
114 extern void memSetPageAddr(u32 vaddr, u32 paddr);
115 extern void memClearPageAddr(u32 vaddr);
116 extern void memBindConditionalHandlers();
117
118 extern void memMapVUmicro();
119
120 extern int mmap_GetRamPageInfo( u32 paddr );
121 extern void mmap_MarkCountedRamPage( u32 paddr );
122 extern void mmap_ResetBlockTracking();
123
124 #define memRead8 vtlb_memRead<mem8_t>
125 #define memRead16 vtlb_memRead<mem16_t>
126 #define memRead32 vtlb_memRead<mem32_t>
127
128 #define memWrite8 vtlb_memWrite<mem8_t>
129 #define memWrite16 vtlb_memWrite<mem16_t>
130 #define memWrite32 vtlb_memWrite<mem32_t>
131
132 static __fi void memRead64(u32 mem, mem64_t* out) { vtlb_memRead64(mem, out); }
133 static __fi void memRead64(u32 mem, mem64_t& out) { vtlb_memRead64(mem, &out); }
134
135 static __fi void memRead128(u32 mem, mem128_t* out) { vtlb_memRead128(mem, out); }
136 static __fi void memRead128(u32 mem, mem128_t& out) { vtlb_memRead128(mem, &out); }
137
138 static __fi void memWrite64(u32 mem, const mem64_t* val) { vtlb_memWrite64(mem, val); }
139 static __fi void memWrite64(u32 mem, const mem64_t& val) { vtlb_memWrite64(mem, &val); }
140 static __fi void memWrite128(u32 mem, const mem128_t* val) { vtlb_memWrite128(mem, val); }
141 static __fi void memWrite128(u32 mem, const mem128_t& val) { vtlb_memWrite128(mem, &val); }
142
143
144 extern u16 ba0R16(u32 mem);

  ViewVC Help
Powered by ViewVC 1.1.22