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

Comparing BasiliskII/src/disk.cpp (file contents):
Revision 1.1 by cebix, 1999-10-03T14:16:25Z vs.
Revision 1.2 by cebix, 1999-10-12T20:00:43Z

# Line 90 | Line 90 | static DriveInfo *first_drive_info;
90   // Icon address (Mac address space, set by PatchROM())
91   uint32 DiskIconAddr;
92  
93 + // Number of ticks between checks for disk insertion
94 + const int driver_delay = 120;
95 +
96 + // Flag: Control(accRun) has been called, interrupt routine is now active
97 + static bool acc_run_called = false;
98 +
99  
100   /*
101   *  Get pointer to drive info, NULL = invalid drive number
# Line 184 | Line 190 | bool DiskMountVolume(void *fh)
190  
191  
192   /*
193 + *  Mount volumes for which the to_be_mounted flag is set
194 + *  (called during interrupt time)
195 + */
196 +
197 + static void mount_mountable_volumes(void)
198 + {
199 +        DriveInfo *info = first_drive_info;
200 +        while (info != NULL) {
201 +
202 +                // Disk in drive?
203 +                if (!ReadMacInt8(info->status + dsDiskInPlace)) {
204 +
205 +                        // No, check if disk was inserted
206 +                        if (SysIsDiskInserted(info->fh))
207 +                                DiskMountVolume(info->fh);
208 +                }
209 +
210 +                // Mount disk if flagged
211 +                if (info->to_be_mounted) {
212 +                        D(bug(" mounting drive %d\n", info->num));
213 +                        M68kRegisters r;
214 +                        r.d[0] = info->num;
215 +                        r.a[0] = 7;     // diskEvent
216 +                        Execute68kTrap(0xa02f, &r);             // PostEvent()
217 +                        info->to_be_mounted = false;
218 +                }
219 +
220 +                info = info->next;
221 +        }
222 + }
223 +
224 +
225 + /*
226   *  Driver Open() routine
227   */
228  
# Line 193 | Line 232 | int16 DiskOpen(uint32 pb, uint32 dce)
232  
233          // Set up DCE
234          WriteMacInt32(dce + dCtlPosition, 0);
235 +        acc_run_called = false;
236  
237          // Install drives
238          for (DriveInfo *info = first_drive_info; info; info = info->next) {
# Line 306 | Line 346 | int16 DiskControl(uint32 pb, uint32 dce)
346                  case 1:         // KillIO
347                          return noErr;
348  
349 <                case 65: {      // Periodic action ("insert" disks on startup and check for disk changes)
350 <                        DriveInfo *info = first_drive_info;
351 <                        while (info != NULL) {
352 <
313 <                                // Disk in drive?
314 <                                if (!ReadMacInt8(info->status + dsDiskInPlace)) {
315 <
316 <                                        // No, check if disk was inserted
317 <                                        if (SysIsDiskInserted(info->fh))
318 <                                                DiskMountVolume(info->fh);
319 <                                }
320 <
321 <                                // Mount disk if flagged
322 <                                if (info->to_be_mounted) {
323 <                                        D(bug(" mounting drive %d\n", info->num));
324 <                                        M68kRegisters r;
325 <                                        r.d[0] = info->num;
326 <                                        r.a[0] = 7;     // diskEvent
327 <                                        Execute68kTrap(0xa02f, &r);             // PostEvent()
328 <                                        info->to_be_mounted = false;
329 <                                }
330 <
331 <                                info = info->next;
332 <                        }
349 >                case 65: {      // Periodic action (accRun, "insert" disks on startup)
350 >                        mount_mountable_volumes();
351 >                        WriteMacInt16(dce + dCtlFlags, ReadMacInt16(dce + dCtlFlags) & ~0x2000);        // Disable periodic action
352 >                        acc_run_called = true;
353                          return noErr;
354                  }
355          }
# Line 472 | Line 492 | int16 DiskStatus(uint32 pb, uint32 dce)
492                          return statusErr;
493          }
494   }
495 +
496 +
497 + /*
498 + *  Driver interrupt routine - check for volumes to be mounted
499 + */
500 +
501 + void DiskInterrupt(void)
502 + {
503 +        static int tick_count = 0;
504 +        if (!acc_run_called)
505 +                return;
506 +
507 +        tick_count++;
508 +        if (tick_count > driver_delay) {
509 +                tick_count = 0;
510 +                mount_mountable_volumes();
511 +        }
512 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines