123 |
|
uint32 SonyDiskIconAddr; |
124 |
|
uint32 SonyDriveIconAddr; |
125 |
|
|
126 |
< |
// Flag: accRun called for the first time, run PatchAfterStartup() |
127 |
< |
static bool periodic_first_time = false; |
126 |
> |
// Number of ticks between checks for disk insertion |
127 |
> |
const int driver_delay = 120; |
128 |
> |
|
129 |
> |
// Flag: Control(accRun) has been called, interrupt routine is now active |
130 |
> |
static bool acc_run_called = false; |
131 |
|
|
132 |
|
|
133 |
|
/* |
219 |
|
|
220 |
|
|
221 |
|
/* |
222 |
+ |
* Mount volumes for which the to_be_mounted flag is set |
223 |
+ |
* (called during interrupt time) |
224 |
+ |
*/ |
225 |
+ |
|
226 |
+ |
static void mount_mountable_volumes(void) |
227 |
+ |
{ |
228 |
+ |
DriveInfo *info = first_drive_info; |
229 |
+ |
while (info != NULL) { |
230 |
+ |
|
231 |
+ |
#if DISK_INSERT_CHECK |
232 |
+ |
// Disk in drive? |
233 |
+ |
if (!ReadMacInt8(info->status + dsDiskInPlace)) { |
234 |
+ |
|
235 |
+ |
// No, check if disk was inserted |
236 |
+ |
if (SysIsDiskInserted(info->fh)) |
237 |
+ |
SonyMountVolume(info->fh); |
238 |
+ |
} |
239 |
+ |
#endif |
240 |
+ |
|
241 |
+ |
// Mount disk if flagged |
242 |
+ |
if (info->to_be_mounted) { |
243 |
+ |
D(bug(" mounting drive %d\n", info->num)); |
244 |
+ |
M68kRegisters r; |
245 |
+ |
r.d[0] = info->num; |
246 |
+ |
r.a[0] = 7; // diskEvent |
247 |
+ |
Execute68kTrap(0xa02f, &r); // PostEvent() |
248 |
+ |
info->to_be_mounted = false; |
249 |
+ |
} |
250 |
+ |
|
251 |
+ |
info = info->next; |
252 |
+ |
} |
253 |
+ |
} |
254 |
+ |
|
255 |
+ |
|
256 |
+ |
/* |
257 |
|
* Driver Open() routine |
258 |
|
*/ |
259 |
|
|
264 |
|
// Set up DCE |
265 |
|
WriteMacInt32(dce + dCtlPosition, 0); |
266 |
|
WriteMacInt16(dce + dCtlQHdr + qFlags, ReadMacInt16(dce + dCtlQHdr + qFlags) & 0xff00 | 3); // Version number, must be >=3 or System 8 will replace us |
267 |
< |
periodic_first_time = true; |
267 |
> |
acc_run_called = false; |
268 |
|
|
269 |
|
// Install driver again with refnum -2 (HD20) |
270 |
|
uint32 utab = ReadMacInt32(0x11c); |
392 |
|
case 9: // Track cache |
393 |
|
return noErr; |
394 |
|
|
395 |
< |
case 65: { // Periodic action ("insert" disks on startup and check for disk changes) |
396 |
< |
DriveInfo *info = first_drive_info; |
397 |
< |
while (info != NULL) { |
398 |
< |
|
399 |
< |
// Disk in drive? |
362 |
< |
if (!ReadMacInt8(info->status + dsDiskInPlace)) { |
363 |
< |
|
364 |
< |
#if DISK_INSERT_CHECK |
365 |
< |
// No, check if disk was inserted |
366 |
< |
if (SysIsDiskInserted(info->fh)) |
367 |
< |
SonyMountVolume(info->fh); |
368 |
< |
#endif |
369 |
< |
} |
370 |
< |
|
371 |
< |
// Mount disk if flagged |
372 |
< |
if (info->to_be_mounted) { |
373 |
< |
D(bug(" mounting drive %d\n", info->num)); |
374 |
< |
M68kRegisters r; |
375 |
< |
r.d[0] = info->num; |
376 |
< |
r.a[0] = 7; // diskEvent |
377 |
< |
Execute68kTrap(0xa02f, &r); // PostEvent() |
378 |
< |
info->to_be_mounted = false; |
379 |
< |
} |
380 |
< |
|
381 |
< |
info = info->next; |
382 |
< |
} |
383 |
< |
if (periodic_first_time) { |
384 |
< |
periodic_first_time = false; |
385 |
< |
PatchAfterStartup(); // Install patches after system startup |
386 |
< |
} |
395 |
> |
case 65: // Periodic action (accRun, "insert" disks on startup) |
396 |
> |
mount_mountable_volumes(); |
397 |
> |
PatchAfterStartup(); // Install patches after system startup |
398 |
> |
WriteMacInt16(dce + dCtlFlags, ReadMacInt16(dce + dCtlFlags) & ~0x2000); // Disable periodic action |
399 |
> |
acc_run_called = true; |
400 |
|
return noErr; |
388 |
– |
} |
401 |
|
} |
402 |
|
|
403 |
|
// Drive valid? |
517 |
|
return statusErr; |
518 |
|
} |
519 |
|
} |
520 |
+ |
|
521 |
+ |
|
522 |
+ |
/* |
523 |
+ |
* Driver interrupt routine - check for volumes to be mounted |
524 |
+ |
*/ |
525 |
+ |
|
526 |
+ |
void SonyInterrupt(void) |
527 |
+ |
{ |
528 |
+ |
static int tick_count = 0; |
529 |
+ |
if (!acc_run_called) |
530 |
+ |
return; |
531 |
+ |
|
532 |
+ |
tick_count++; |
533 |
+ |
if (tick_count > driver_delay) { |
534 |
+ |
tick_count = 0; |
535 |
+ |
mount_mountable_volumes(); |
536 |
+ |
} |
537 |
+ |
} |