blob: bd38142c8d6e2b661f5226f4338449b8130da3cd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
#include <cstddef>
#include <dolphin/dolphin.h>
#include <dolphin/hw_regs.h>
#include "__dsp.h"
#define BUILD_DATE "Apr 5 2004"
#if DEBUG
#define BUILD_TIME "03:56:49"
#else
#define BUILD_TIME "04:15:32"
#endif
#if DEBUG
const char* __DSPVersion = "<< Dolphin SDK - DSP\tdebug build: Apr 5 2004 03:56:49 (0x2301) >>";
#else
const char* __DSPVersion = "<< Dolphin SDK - DSP\trelease build: Apr 5 2004 04:15:32 (0x2301) >>";
#endif
extern DSPTaskInfo* __DSP_rude_task;
extern int __DSP_rude_task_pending;
static BOOL __DSP_init_flag;
u32 DSPCheckMailToDSP(void) {
return (__DSPRegs[0] & (1 << 15)) >> 15;
}
u32 DSPCheckMailFromDSP(void) {
return (__DSPRegs[2] & (1 << 15)) >> 15;
}
u32 DSPReadCPUToDSPMbox(void) {
return (__DSPRegs[0] << 16) | __DSPRegs[1];
}
u32 DSPReadMailFromDSP(void) {
return (__DSPRegs[2] << 16) | __DSPRegs[3];
}
void DSPSendMailToDSP(u32 mail) {
__DSPRegs[0] = mail >> 16;
__DSPRegs[1] = mail & 0xFFFF;
}
void DSPAssertInt(void) {
BOOL old;
u16 tmp;
old = OSDisableInterrupts();
tmp = __DSPRegs[5];
tmp = (tmp & ~0xA8) | 2;
__DSPRegs[5] = tmp;
OSRestoreInterrupts(old);
}
void DSPInit(void) {
BOOL old;
u16 tmp;
__DSP_debug_printf("DSPInit(): Build Date: %s %s\n", BUILD_DATE, BUILD_TIME);
if (__DSP_init_flag == 1)
return;
OSRegisterVersion(__DSPVersion);
old = OSDisableInterrupts();
__OSSetInterruptHandler(7, __DSPHandler);
__OSUnmaskInterrupts(OS_INTERRUPTMASK_DSP_DSP);
tmp = __DSPRegs[5];
tmp = (tmp & ~0xA8) | 0x800;
__DSPRegs[5] = tmp;
tmp = __DSPRegs[5];
__DSPRegs[5] = tmp = tmp & ~0xAC;
__DSP_first_task = __DSP_last_task = __DSP_curr_task = __DSP_tmp_task = NULL;
__DSP_init_flag = 1;
OSRestoreInterrupts(old);
}
BOOL DSPCheckInit(void) {
return __DSP_init_flag;
}
void DSPReset(void) {
BOOL old;
u16 tmp;
old = OSDisableInterrupts();
tmp = __DSPRegs[5];
tmp = (tmp & ~0xA8) | 0x800 | 1;
__DSPRegs[5] = tmp;
__DSP_init_flag = 0;
OSRestoreInterrupts(old);
}
void DSPHalt(void) {
BOOL old;
u16 tmp;
old = OSDisableInterrupts();
tmp = __DSPRegs[5];
tmp = (tmp & ~0xA8) | 4;
__DSPRegs[5] = tmp;
OSRestoreInterrupts(old);
}
void DSPUnhalt(void) {
BOOL old;
u16 tmp;
old = OSDisableInterrupts();
tmp = __DSPRegs[5];
tmp = (tmp & ~0xAC);
__DSPRegs[5] = tmp;
OSRestoreInterrupts(old);
}
u32 DSPGetDMAStatus(void) {
return (__DSPRegs[5] & (1 << 9));
}
DSPTaskInfo* DSPAddTask(DSPTaskInfo* task) {
BOOL old;
ASSERTMSGLINE(556, __DSP_init_flag == 1, "DSPAddTask(): DSP driver not initialized!\n");
old = OSDisableInterrupts();
__DSP_insert_task(task);
task->state = 0;
task->flags = 1;
OSRestoreInterrupts(old);
if (task == __DSP_first_task)
__DSP_boot_task(task);
return task;
}
DSPTaskInfo* DSPCancelTask(DSPTaskInfo* task) {
BOOL old;
ASSERTMSGLINE(592, __DSP_init_flag == 1, "DSPCancelTask(): DSP driver not initialized!\n");
old = OSDisableInterrupts();
task->flags |= 2;
OSRestoreInterrupts(old);
return task;
}
DSPTaskInfo* DSPAssertTask(DSPTaskInfo* task) {
s32 old;
ASSERTMSGLINE(623, __DSP_init_flag == 1, "DSPAssertTask(): DSP driver not initialized!\n");
ASSERTMSGLINE(624, task->flags & 1, "DSPAssertTask(): Specified task not in active task list!\n");
old = OSDisableInterrupts();
if (__DSP_curr_task == task) {
__DSP_rude_task = task;
__DSP_rude_task_pending = 1;
OSRestoreInterrupts(old);
return task;
}
if (task->priority < __DSP_curr_task->priority) {
__DSP_rude_task = task;
__DSP_rude_task_pending = 1;
if (__DSP_curr_task->state == 1) {
DSPAssertInt();
}
OSRestoreInterrupts(old);
return task;
}
OSRestoreInterrupts(old);
return NULL;
}
|