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.6 by cebix, 2000-07-14T21:29:08Z

# Line 1 | Line 1
1   /*
2   *  disk.cpp - Generic disk driver
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 90 | Line 90 | static DriveInfo *first_drive_info;
90   // Icon address (Mac address space, set by PatchROM())
91   uint32 DiskIconAddr;
92  
93 + // Flag: Control(accRun) has been called, interrupt routine is now active
94 + static bool acc_run_called = false;
95 +
96  
97   /*
98   *  Get pointer to drive info, NULL = invalid drive number
# Line 184 | Line 187 | bool DiskMountVolume(void *fh)
187  
188  
189   /*
190 + *  Mount volumes for which the to_be_mounted flag is set
191 + *  (called during interrupt time)
192 + */
193 +
194 + static void mount_mountable_volumes(void)
195 + {
196 +        DriveInfo *info = first_drive_info;
197 +        while (info != NULL) {
198 +
199 +                // Disk in drive?
200 +                if (!ReadMacInt8(info->status + dsDiskInPlace)) {
201 +
202 +                        // No, check if disk was inserted
203 +                        if (SysIsDiskInserted(info->fh))
204 +                                DiskMountVolume(info->fh);
205 +                }
206 +
207 +                // Mount disk if flagged
208 +                if (info->to_be_mounted) {
209 +                        D(bug(" mounting drive %d\n", info->num));
210 +                        M68kRegisters r;
211 +                        r.d[0] = info->num;
212 +                        r.a[0] = 7;     // diskEvent
213 +                        Execute68kTrap(0xa02f, &r);             // PostEvent()
214 +                        info->to_be_mounted = false;
215 +                }
216 +
217 +                info = info->next;
218 +        }
219 + }
220 +
221 +
222 + /*
223   *  Driver Open() routine
224   */
225  
# Line 193 | Line 229 | int16 DiskOpen(uint32 pb, uint32 dce)
229  
230          // Set up DCE
231          WriteMacInt32(dce + dCtlPosition, 0);
232 +        acc_run_called = false;
233  
234          // Install drives
235          for (DriveInfo *info = first_drive_info; info; info = info->next) {
# Line 228 | Line 265 | int16 DiskOpen(uint32 pb, uint32 dce)
265                                  info->num_blocks = SysGetFileSize(info->fh) / 512;
266                                  info->to_be_mounted = true;
267                          }
268 <                        D(bug(" %ld blocks\n", info->num_blocks));
268 >                        D(bug(" %d blocks\n", info->num_blocks));
269                          WriteMacInt16(info->status + dsDriveSize, info->num_blocks & 0xffff);
270                          WriteMacInt16(info->status + dsDriveS1, info->num_blocks >> 16);
271  
# Line 306 | Line 343 | int16 DiskControl(uint32 pb, uint32 dce)
343                  case 1:         // KillIO
344                          return noErr;
345  
346 <                case 65: {      // Periodic action ("insert" disks on startup and check for disk changes)
347 <                        DriveInfo *info = first_drive_info;
348 <                        while (info != NULL) {
349 <
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 <                        }
346 >                case 65: {      // Periodic action (accRun, "insert" disks on startup)
347 >                        mount_mountable_volumes();
348 >                        WriteMacInt16(dce + dCtlFlags, ReadMacInt16(dce + dCtlFlags) & ~0x2000);        // Disable periodic action
349 >                        acc_run_called = true;
350                          return noErr;
351                  }
352          }
# Line 464 | Line 481 | int16 DiskStatus(uint32 pb, uint32 dce)
481          // Drive-specific codes
482          switch (code) {
483                  case 8:         // Get drive status
484 <                        memcpy(Mac2HostAddr(pb + csParam), Mac2HostAddr(info->status), 22);
484 >                        Mac2Mac_memcpy(pb + csParam, info->status, 22);
485                          return noErr;
486  
487                  default:
# Line 472 | Line 489 | int16 DiskStatus(uint32 pb, uint32 dce)
489                          return statusErr;
490          }
491   }
492 +
493 +
494 + /*
495 + *  Driver interrupt routine (1Hz) - check for volumes to be mounted
496 + */
497 +
498 + void DiskInterrupt(void)
499 + {
500 +        if (!acc_run_called)
501 +                return;
502 +
503 +        mount_mountable_volumes();
504 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines