/[gxemul]/trunk/src/diskimage.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/diskimage.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3 by dpavlin, Mon Oct 8 16:17:48 2007 UTC revision 4 by dpavlin, Mon Oct 8 16:18:00 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: diskimage.c,v 1.81 2005/04/04 21:50:05 debug Exp $   *  $Id: diskimage.c,v 1.84 2005/04/17 00:15:24 debug Exp $
29   *   *
30   *  Disk image support.   *  Disk image support.
31   *   *
# Line 216  int diskimage_exist(struct machine *mach Line 216  int diskimage_exist(struct machine *mach
216          struct diskimage *d = machine->first_diskimage;          struct diskimage *d = machine->first_diskimage;
217    
218          while (d != NULL) {          while (d != NULL) {
219                  if (d->type == DISKIMAGE_SCSI && d->id == scsi_id)                  if ( /* d->type == DISKIMAGE_SCSI && */ d->id == scsi_id)
220                          return 1;                          return 1;
221                  d = d->next;                  d = d->next;
222          }          }
# Line 270  int64_t diskimage_getsize(struct machine Line 270  int64_t diskimage_getsize(struct machine
270          struct diskimage *d = machine->first_diskimage;          struct diskimage *d = machine->first_diskimage;
271    
272          while (d != NULL) {          while (d != NULL) {
273                  if (d->type == DISKIMAGE_SCSI && d->id == scsi_id)                  if ( /* d->type == DISKIMAGE_SCSI && */ d->id == scsi_id)
274                          return d->total_size;                          return d->total_size;
275                  d = d->next;                  d = d->next;
276          }          }
# Line 464  int diskimage_scsicommand(struct cpu *cp Line 464  int diskimage_scsicommand(struct cpu *cp
464    
465          d = machine->first_diskimage;          d = machine->first_diskimage;
466          while (d != NULL) {          while (d != NULL) {
467                  if (d->type == DISKIMAGE_SCSI && d->id == scsi_id)                  if ( /* d->type == DISKIMAGE_SCSI && */ d->id == scsi_id)
468                          break;                          break;
469                  d = d->next;                  d = d->next;
470          }          }
# Line 1300  int diskimage_access(struct machine *mac Line 1300  int diskimage_access(struct machine *mac
1300  {  {
1301          struct diskimage *d = machine->first_diskimage;          struct diskimage *d = machine->first_diskimage;
1302    
1303            /*
1304             *  TODO: How about mixing SCSI, IDE, and FLOPPY in one
1305             *        emulated machine?
1306             */
1307    
1308          while (d != NULL) {          while (d != NULL) {
1309                  if (d->type == DISKIMAGE_SCSI && d->id == scsi_id)                  if ( /* d->type == DISKIMAGE_SCSI && */ d->id == scsi_id)
1310                          break;                          break;
1311                  d = d->next;                  d = d->next;
1312          }          }
# Line 1325  int diskimage_access(struct machine *mac Line 1330  int diskimage_access(struct machine *mac
1330   *   *
1331   *      b       specifies that this is the boot device   *      b       specifies that this is the boot device
1332   *      c       CD-ROM (instead of normal SCSI DISK)   *      c       CD-ROM (instead of normal SCSI DISK)
1333   *      d       SCSI DISK (this is the default)   *      d       DISK (this is the default)
1334     *      f       FLOPPY (instead of SCSI)
1335   *      i       IDE (instead of SCSI)   *      i       IDE (instead of SCSI)
1336   *      r       read-only (don't allow changes to the file)   *      r       read-only (don't allow changes to the file)
1337   *      t       SCSI tape   *      s       SCSI (this is the default)
1338     *      t       tape
1339   *      0-7     force a specific SCSI ID number   *      0-7     force a specific SCSI ID number
1340   *   *
1341   *  machine is assumed to be non-NULL.   *  machine is assumed to be non-NULL.
# Line 1342  int diskimage_add(struct machine *machin Line 1349  int diskimage_add(struct machine *machin
1349          int prefix_b = 0;          int prefix_b = 0;
1350          int prefix_c = 0;          int prefix_c = 0;
1351          int prefix_d = 0;          int prefix_d = 0;
1352            int prefix_f = 0;
1353          int prefix_i = 0;          int prefix_i = 0;
1354            int prefix_r = 0;
1355            int prefix_s = 0;
1356          int prefix_t = 0;          int prefix_t = 0;
1357          int prefix_id = -1;          int prefix_id = -1;
         int prefix_r = 0;  
1358    
1359          if (fname == NULL) {          if (fname == NULL) {
1360                  fprintf(stderr, "diskimage_add(): NULL ptr\n");                  fprintf(stderr, "diskimage_add(): NULL ptr\n");
# Line 1377  int diskimage_add(struct machine *machin Line 1386  int diskimage_add(struct machine *machin
1386                          case 'd':                          case 'd':
1387                                  prefix_d = 1;                                  prefix_d = 1;
1388                                  break;                                  break;
1389                            case 'f':
1390                                    prefix_f = 1;
1391                                    break;
1392                          case 'i':                          case 'i':
1393                                  prefix_i = 1;                                  prefix_i = 1;
1394                                  break;                                  break;
                         case 't':  
                                 prefix_t = 1;  
                                 break;  
1395                          case 'r':                          case 'r':
1396                                  prefix_r = 1;                                  prefix_r = 1;
1397                                  break;                                  break;
1398                            case 's':
1399                                    prefix_s = 1;
1400                                    break;
1401                            case 't':
1402                                    prefix_t = 1;
1403                                    break;
1404                          case ':':                          case ':':
1405                                  break;                                  break;
1406                          default:                          default:
# Line 1449  int diskimage_add(struct machine *machin Line 1464  int diskimage_add(struct machine *machin
1464          d->type = DISKIMAGE_SCSI;          d->type = DISKIMAGE_SCSI;
1465          d->id = id;          d->id = id;
1466    
1467            /*  Special cases: some machines usually have FLOPPY/IDE, not SCSI:  */
1468            if (machine->arch == ARCH_X86 ||
1469                machine->machine_type == MACHINE_COBALT ||
1470                machine->machine_type == MACHINE_HPCMIPS ||
1471                machine->machine_type == MACHINE_PS2)
1472                    d->type = DISKIMAGE_IDE;
1473    
1474            if (prefix_i + prefix_f + prefix_s > 1) {
1475                    fprintf(stderr, "Invalid disk image prefix(es). You can"
1476                        "only use one of i, f, and s\nfor each disk image.\n");
1477                    exit(1);
1478            }
1479    
1480          if (prefix_i)          if (prefix_i)
1481                  d->type = DISKIMAGE_IDE;                  d->type = DISKIMAGE_IDE;
1482            if (prefix_f)
1483                    d->type = DISKIMAGE_FLOPPY;
1484            if (prefix_s)
1485                    d->type = DISKIMAGE_SCSI;
1486    
1487          d->fname = strdup(fname);          d->fname = strdup(fname);
1488          if (d->fname == NULL) {          if (d->fname == NULL) {
# Line 1500  int diskimage_add(struct machine *machin Line 1532  int diskimage_add(struct machine *machin
1532    
1533          diskimage_recalc_size(d);          diskimage_recalc_size(d);
1534    
1535            if (d->total_size == 1474560 && !prefix_i && !prefix_s)
1536                    d->type = DISKIMAGE_FLOPPY;
1537    
1538          d->rpms = 3600;          d->rpms = 3600;
1539    
1540          if (prefix_b)          if (prefix_b)
# Line 1604  void diskimage_dump_info(struct machine Line 1639  void diskimage_dump_info(struct machine
1639                  case DISKIMAGE_IDE:                  case DISKIMAGE_IDE:
1640                          debug("IDE");                          debug("IDE");
1641                          break;                          break;
1642                    case DISKIMAGE_FLOPPY:
1643                            debug("FLOPPY");
1644                            break;
1645                  default:                  default:
1646                          debug("UNKNOWN type %i", d->type);                          debug("UNKNOWN type %i", d->type);
1647                  }                  }
# Line 1613  void diskimage_dump_info(struct machine Line 1651  void diskimage_dump_info(struct machine
1651                  debug(" id %i, ", d->id);                  debug(" id %i, ", d->id);
1652                  debug("%s, ", d->writable? "read/write" : "read-only");                  debug("%s, ", d->writable? "read/write" : "read-only");
1653    
1654                  debug("%lli MB (%lli sectors)%s\n",                  if (d->type == DISKIMAGE_FLOPPY)
1655                      (long long) (d->total_size / 1048576),                          debug("%lli KB", (long long) (d->total_size / 1024));
1656                    else
1657                            debug("%lli MB", (long long) (d->total_size / 1048576));
1658    
1659                    debug(" (%lli sectors)%s\n",
1660                      (long long) (d->total_size / 512),                      (long long) (d->total_size / 512),
1661                      d->is_boot_device? " (BOOT)" : "");                      d->is_boot_device? " (BOOT)" : "");
1662    

Legend:
Removed from v.3  
changed lines
  Added in v.4

  ViewVC Help
Powered by ViewVC 1.1.26