ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/sony.cpp
(Generate patch)

Comparing BasiliskII/src/sony.cpp (file contents):
Revision 1.1 by cebix, 1999-10-03T14:16:25Z vs.
Revision 1.7 by cebix, 2000-07-14T21:29:10Z

# Line 1 | Line 1
1   /*
2   *  sony.cpp - Replacement .Sony driver (floppy drives)
3   *
4 < *  Basilisk II (C) 1997-1999 Christian Bauer
4 > *  Basilisk II (C) 1997-2000 Christian Bauer
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 42 | Line 42
42   #define DEBUG 0
43   #include "debug.h"
44  
45 +
46 + // Check for inserted disks by polling?
47   #ifdef AMIGA
48 < #define DISK_INSERT_CHECK 1             // Check for inserted disks (problem: on most hardware, disks are not ejected and automatically remounted)
48 > #define DISK_INSERT_CHECK 1
49   #else
50   #define DISK_INSERT_CHECK 0
51   #endif
# Line 123 | Line 125 | static DriveInfo *first_drive_info;
125   uint32 SonyDiskIconAddr;
126   uint32 SonyDriveIconAddr;
127  
128 < // Flag: accRun called for the first time, run PatchAfterStartup()
129 < static bool periodic_first_time = false;
128 > // Flag: Control(accRun) has been called, interrupt routine is now active
129 > static bool acc_run_called = false;
130  
131  
132   /*
# Line 216 | Line 218 | bool SonyMountVolume(void *fh)
218  
219  
220   /*
221 + *  Mount volumes for which the to_be_mounted flag is set
222 + *  (called during interrupt time)
223 + */
224 +
225 + static void mount_mountable_volumes(void)
226 + {
227 +        DriveInfo *info = first_drive_info;
228 +        while (info != NULL) {
229 +
230 + #if DISK_INSERT_CHECK
231 +                // Disk in drive?
232 +                if (!ReadMacInt8(info->status + dsDiskInPlace)) {
233 +
234 +                        // No, check if disk was inserted
235 +                        if (SysIsDiskInserted(info->fh))
236 +                                SonyMountVolume(info->fh);
237 +                }
238 + #endif
239 +
240 +                // Mount disk if flagged
241 +                if (info->to_be_mounted) {
242 +                        D(bug(" mounting drive %d\n", info->num));
243 +                        M68kRegisters r;
244 +                        r.d[0] = info->num;
245 +                        r.a[0] = 7;     // diskEvent
246 +                        Execute68kTrap(0xa02f, &r);             // PostEvent()
247 +                        info->to_be_mounted = false;
248 +                }
249 +
250 +                info = info->next;
251 +        }
252 + }
253 +
254 +
255 + /*
256   *  Driver Open() routine
257   */
258  
# Line 226 | Line 263 | int16 SonyOpen(uint32 pb, uint32 dce)
263          // Set up DCE
264          WriteMacInt32(dce + dCtlPosition, 0);
265          WriteMacInt16(dce + dCtlQHdr + qFlags, ReadMacInt16(dce + dCtlQHdr + qFlags) & 0xff00 | 3);     // Version number, must be >=3 or System 8 will replace us
266 <        periodic_first_time = true;
266 >        acc_run_called = false;
267  
268          // Install driver again with refnum -2 (HD20)
269          uint32 utab = ReadMacInt32(0x11c);
# Line 354 | Line 391 | int16 SonyControl(uint32 pb, uint32 dce)
391                  case 9:         // Track cache
392                          return noErr;
393  
394 <                case 65: {      // Periodic action ("insert" disks on startup and check for disk changes)
395 <                        DriveInfo *info = first_drive_info;
396 <                        while (info != NULL) {
397 <
398 <                                // 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 <                        }
394 >                case 65:        // Periodic action (accRun, "insert" disks on startup)
395 >                        mount_mountable_volumes();
396 >                        PatchAfterStartup();            // Install patches after system startup
397 >                        WriteMacInt16(dce + dCtlFlags, ReadMacInt16(dce + dCtlFlags) & ~0x2000);        // Disable periodic action
398 >                        acc_run_called = true;
399                          return noErr;
388                }
400          }
401  
402          // Drive valid?
# Line 485 | Line 496 | int16 SonyStatus(uint32 pb, uint32 dce)
496                                  return paramErr;
497  
498                  case 8:         // Get drive status
499 <                        memcpy(Mac2HostAddr(pb + csParam), Mac2HostAddr(info->status), 22);
499 >                        Mac2Mac_memcpy(pb + csParam, info->status, 22);
500                          return noErr;
501  
502                  case 10:        // Get disk type
# Line 505 | Line 516 | int16 SonyStatus(uint32 pb, uint32 dce)
516                          return statusErr;
517          }
518   }
519 +
520 +
521 + /*
522 + *  Driver interrupt routine (1Hz) - check for volumes to be mounted
523 + */
524 +
525 + void SonyInterrupt(void)
526 + {
527 +        if (!acc_run_called)
528 +                return;
529 +
530 +        mount_mountable_volumes();
531 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines