/[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 31 - (show annotations) (download)
Tue Sep 7 03:24:11 2010 UTC (9 years, 10 months ago) by william
File MIME type: text/plain
File size: 2966 byte(s)
committing r3113 initial commit again...
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 #define FIFO_SIF_W 128
20
21 struct sifData
22 {
23 s32 data;
24 s32 words;
25 s32 count; // I think this is unused.
26 s32 addr; // This too.
27 };
28
29 struct sifFifo
30 {
31 u32 data[FIFO_SIF_W];
32 s32 readPos;
33 s32 writePos;
34 s32 size;
35
36 s32 free()
37 {
38 return FIFO_SIF_W - size;
39 }
40
41 void write(u32 *from, int words)
42 {
43 if (words > 0)
44 {
45 const int wP0 = min((FIFO_SIF_W - writePos), words);
46 const int wP1 = words - wP0;
47
48 memcpy_fast(&data[writePos], from, wP0 << 2);
49 memcpy_fast(&data[0], &from[wP0], wP1 << 2);
50
51 writePos = (writePos + words) & (FIFO_SIF_W - 1);
52 size += words;
53 }
54 SIF_LOG(" SIF + %d = %d (pos=%d)", words, size, writePos);
55 }
56
57 void read(u32 *to, int words)
58 {
59 if (words > 0)
60 {
61 const int wP0 = min((FIFO_SIF_W - readPos), words);
62 const int wP1 = words - wP0;
63
64 memcpy_fast(to, &data[readPos], wP0 << 2);
65 memcpy_fast(&to[wP0], &data[0], wP1 << 2);
66
67 readPos = (readPos + words) & (FIFO_SIF_W - 1);
68 size -= words;
69 }
70 SIF_LOG(" SIF - %d = %d (pos=%d)", words, size, readPos);
71 }
72 void clear()
73 {
74 memzero(data);
75 readPos = 0;
76 writePos = 0;
77 size = 0;
78 }
79 };
80
81 struct old_sif_structure
82 {
83 sifFifo fifo; // Used in both.
84 s32 chain; // Not used.
85 s32 end; // Only used for EE.
86 s32 tagMode; // No longer used.
87 s32 counter; // Used to keep track of how much is left in IOP.
88 struct sifData data; // Only used in IOP.
89 };
90
91 struct sif_ee
92 {
93 bool end; // Only used for EE.
94 bool busy;
95
96 s32 cycles;
97 };
98 struct sif_iop
99 {
100 bool end;
101 bool busy;
102
103 s32 cycles;
104
105 s32 counter; // Used to keep track of how much is left in IOP.
106 struct sifData data; // Only used in IOP.
107 };
108 struct _sif
109 {
110 sifFifo fifo; // Used in both.
111 sif_ee ee;
112 sif_iop iop;
113 };
114
115 extern _sif sif0, sif1;
116
117 extern void sifInit();
118
119 extern void SIF0Dma();
120 extern void SIF1Dma();
121
122 extern void dmaSIF0();
123 extern void dmaSIF1();
124 extern void dmaSIF2();
125
126 extern void EEsif0Interrupt();
127 extern void EEsif1Interrupt();
128
129 extern void sif0Interrupt();
130 extern void sif1Interrupt();
131
132 #define sif0data sif0.iop.data.data
133 #define sif1data sif1.iop.data.data
134
135 #define sif0words sif0.iop.data.words
136 #define sif1words sif1.iop.data.words
137
138 #define sif0tag DMA_TAG(sif0data)
139 #define sif1tag DMA_TAG(sif1data)
140
141 #endif /* __SIF_H__ */

  ViewVC Help
Powered by ViewVC 1.1.22