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

Contents of /trunk/pcsx2/Sif.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 273 - (show annotations) (download)
Fri Nov 12 01:10:22 2010 UTC (9 years, 2 months ago) by william
File MIME type: text/plain
File size: 3406 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 #ifndef __SIF_H__
17 #define __SIF_H__
18
19 static const int FIFO_SIF_W = 128;
20
21 static DMACh& sif0dma = (DMACh&)eeHw[0xc000];
22 static DMACh& sif1dma = (DMACh&)eeHw[0xc400];
23 static DMACh& sif2dma = (DMACh&)eeHw[0xc800];
24
25 // Despite its name, this is actually the IOP's DMAtag, which itself also contains
26 // the EE's DMAtag in its upper 64 bits. Note that only the lower 24 bits of 'data' is
27 // the IOP's chain transfer address (loaded into MADR). Bits 30 and 31 are transfer stop
28 // bits of some sort.
29 struct sifData
30 {
31 s32 data;
32 s32 words;
33
34 tDMA_TAG tag_lo; // EE DMA tag
35 tDMA_TAG tag_hi; // EE DMA tag
36 };
37
38 struct sifFifo
39 {
40 u32 data[FIFO_SIF_W];
41 s32 readPos;
42 s32 writePos;
43 s32 size;
44
45 s32 free()
46 {
47 return FIFO_SIF_W - size;
48 }
49
50 void write(u32 *from, int words)
51 {
52 if (words > 0)
53 {
54 const int wP0 = min((FIFO_SIF_W - writePos), words);
55 const int wP1 = words - wP0;
56
57 memcpy_fast(&data[writePos], from, wP0 << 2);
58 memcpy_fast(&data[0], &from[wP0], wP1 << 2);
59
60 writePos = (writePos + words) & (FIFO_SIF_W - 1);
61 size += words;
62 }
63 SIF_LOG(" SIF + %d = %d (pos=%d)", words, size, writePos);
64 }
65
66 void read(u32 *to, int words)
67 {
68 if (words > 0)
69 {
70 const int wP0 = min((FIFO_SIF_W - readPos), words);
71 const int wP1 = words - wP0;
72
73 memcpy_fast(to, &data[readPos], wP0 << 2);
74 memcpy_fast(&to[wP0], &data[0], wP1 << 2);
75
76 readPos = (readPos + words) & (FIFO_SIF_W - 1);
77 size -= words;
78 }
79 SIF_LOG(" SIF - %d = %d (pos=%d)", words, size, readPos);
80 }
81 void clear()
82 {
83 memzero(data);
84 readPos = 0;
85 writePos = 0;
86 size = 0;
87 }
88 };
89
90 struct old_sif_structure
91 {
92 sifFifo fifo; // Used in both.
93 s32 chain; // Not used.
94 s32 end; // Only used for EE.
95 s32 tagMode; // No longer used.
96 s32 counter; // Used to keep track of how much is left in IOP.
97 struct sifData data; // Only used in IOP.
98 };
99
100 struct sif_ee
101 {
102 bool end; // Only used for EE.
103 bool busy;
104
105 s32 cycles;
106 };
107
108 struct sif_iop
109 {
110 bool end;
111 bool busy;
112
113 s32 cycles;
114
115 s32 counter; // Used to keep track of how much is left in IOP.
116 struct sifData data; // Only used in IOP.
117 };
118
119 struct _sif
120 {
121 sifFifo fifo; // Used in both.
122 sif_ee ee;
123 sif_iop iop;
124 };
125
126 extern _sif sif0, sif1;
127
128 extern void sifInit();
129
130 extern void SIF0Dma();
131 extern void SIF1Dma();
132
133 extern void dmaSIF0();
134 extern void dmaSIF1();
135 extern void dmaSIF2();
136
137 extern void EEsif0Interrupt();
138 extern void EEsif1Interrupt();
139
140 extern void sif0Interrupt();
141 extern void sif1Interrupt();
142
143 #define sif0data sif0.iop.data.data
144 #define sif1data sif1.iop.data.data
145
146 #define sif0words sif0.iop.data.words
147 #define sif1words sif1.iop.data.words
148
149 #define sif0tag DMA_TAG(sif0data)
150 #define sif1tag DMA_TAG(sif1data)
151
152 #endif /* __SIF_H__ */

  ViewVC Help
Powered by ViewVC 1.1.22