/[pcsx2_0.9.7]/trunk/pcsx2/ps2/HwInternal.h
ViewVC logotype

Contents of /trunk/pcsx2/ps2/HwInternal.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62 - (show annotations) (download)
Tue Sep 7 11:08:22 2010 UTC (10 years, 4 months ago) by william
File MIME type: text/plain
File size: 4031 byte(s)
Auto Commited Import of: pcsx2-0.9.7-r3738-debug 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 "Hw.h"
19
20 // --------------------------------------------------------------------------------------
21 // IsPageFor() / iswitch() / icase() [macros!]
22 // --------------------------------------------------------------------------------------
23 // Page-granulated switch helpers: In order for the compiler to optimize hardware register
24 // handlers, which dispatch registers along a series of switches, the compiler needs to know
25 // that the case entry applies to the current page only. Under MSVC, I tried all manners of
26 // bitmasks against the templated page value, and this was the only one that worked:
27 //
28 // Note: MSVC 2008 actually fails to optimize "switch" properly due to being overly aggressive
29 // about trying to use its clever BSP-tree logic for long switches. It adds the BSP tree logic,
30 // even though most of the "tree" is empty (resulting in several compare/jumps that do nothing).
31 // Explained: Even though only one or two of the switch entires are valid, MSVC will still
32 // compile in its BSP tree check (which divides the switch into 2 or 4 ranges of values). Three
33 // of the ranges just link to "RET", while the fourth range contains the handler for the one
34 // register operation contained in the templated page.
35
36 #define IsPageFor(_mem) ((page<<12) == (_mem&(0xf<<12)))
37 #define icase(ugh) if(IsPageFor(ugh) && (mem==ugh))
38 #define iswitch(mem)
39
40 // hw read functions
41 template< uint page > extern mem8_t __fastcall hwRead8 (u32 mem);
42 template< uint page > extern mem16_t __fastcall hwRead16 (u32 mem);
43 template< uint page > extern mem32_t __fastcall hwRead32 (u32 mem);
44 template< uint page > extern void __fastcall hwRead64 (u32 mem, mem64_t* out );
45 template< uint page > extern void __fastcall hwRead128(u32 mem, mem128_t* out);
46
47 // Internal hwRead32 which does not log reads, used by hwWrite8/16 to perform
48 // read-modify-write operations.
49 template< uint page, bool intcstathack >
50 extern mem32_t __fastcall _hwRead32(u32 mem);
51
52 extern mem16_t __fastcall hwRead16_page_0F_INTC_HACK(u32 mem);
53 extern mem32_t __fastcall hwRead32_page_0F_INTC_HACK(u32 mem);
54
55
56 // hw write functions
57 template<uint page> extern void __fastcall hwWrite8 (u32 mem, u8 value);
58 template<uint page> extern void __fastcall hwWrite16 (u32 mem, u16 value);
59
60 template<uint page> extern void __fastcall hwWrite32 (u32 mem, mem32_t value);
61 template<uint page> extern void __fastcall hwWrite64 (u32 mem, const mem64_t* srcval);
62 template<uint page> extern void __fastcall hwWrite128(u32 mem, const mem128_t* srcval);
63
64 // --------------------------------------------------------------------------------------
65 // Hardware FIFOs (128 bit access only!)
66 // --------------------------------------------------------------------------------------
67 // VIF0 -- 0x10004000 -- eeHw[0x4000]
68 // VIF1 -- 0x10005000 -- eeHw[0x5000]
69 // GIF -- 0x10006000 -- eeHw[0x6000]
70 // IPUout -- 0x10007000 -- eeHw[0x7000]
71 // IPUin -- 0x10007010 -- eeHw[0x7010]
72
73 extern void __fastcall ReadFIFO_VIF1(mem128_t* out);
74 extern void __fastcall ReadFIFO_IPUout(mem128_t* out);
75
76 extern void __fastcall WriteFIFO_VIF0(const mem128_t* value);
77 extern void __fastcall WriteFIFO_VIF1(const mem128_t* value);
78 extern void __fastcall WriteFIFO_GIF(const mem128_t* value);
79 extern void __fastcall WriteFIFO_IPUin(const mem128_t* value);

  ViewVC Help
Powered by ViewVC 1.1.22