Previous 15994 Revisions Next

r13993 Thursday 12th January, 2012 at 15:52:02 UTC by Miodrag Milanović
Added support for 2 drives on IDE controller [Miodrag Milanovic]
[src/emu/machine]idectrl.c idectrl.h
[src/mame/drivers]kinst.c

src/mame/drivers/kinst.c
r13992r13993
167167{
168168   kinst_state *state = machine.driver_data<kinst_state>();
169169   device_t *ide = machine.device("ide");
170   UINT8 *features = ide_get_features(ide);
170   UINT8 *features = ide_get_features(ide,0);
171171
172172   if (strncmp(machine.system().name, "kinst2", 6) != 0)
173173   {
src/emu/machine/idectrl.c
r13992r13993
9191
9292#define IDE_ERROR_NONE               0x00
9393#define IDE_ERROR_DEFAULT            0x01
94#define IDE_ERROR_TRACK0_NOT_FOUND      0x02
9495#define IDE_ERROR_UNKNOWN_COMMAND      0x04
9596#define IDE_ERROR_BAD_LOCATION         0x10
9697#define IDE_ERROR_BAD_SECTOR         0x80
r13992r13993
104105/***************************************************************************
105106    TYPE DEFINITIONS
106107***************************************************************************/
108typedef struct _ide_device ide_device;
109struct _ide_device
110{
111   UINT8         features[IDE_DISK_SECTOR_SIZE];
107112
113   UINT16         cur_cylinder;
114   UINT8         cur_sector;
115   UINT8         cur_head;
116   UINT8         cur_head_reg;
117
118   UINT32         cur_lba;
119
120   UINT16         num_cylinders;
121   UINT8         num_sectors;
122   UINT8         num_heads;
123   
124   chd_file       *handle;
125   hard_disk_file *disk;
126   bool         is_image_device;   
127};   
128
129
108130typedef struct _ide_state ide_state;
109131struct _ide_state
110132{
r13992r13993
118140   UINT8         precomp_offset;
119141
120142   UINT8         buffer[IDE_DISK_SECTOR_SIZE];
121   UINT8         features[IDE_DISK_SECTOR_SIZE];
122143   UINT16         buffer_offset;
123144   UINT16         sector_count;
124145
r13992r13993
138159   UINT8         bus_master_status;
139160   UINT32         bus_master_descriptor;
140161
141   UINT16         cur_cylinder;
142   UINT8         cur_sector;
143   UINT8         cur_head;
144   UINT8         cur_head_reg;
145
146   UINT32         cur_lba;
147
148   UINT16         num_cylinders;
149   UINT8         num_sectors;
150   UINT8         num_heads;
151
152162   UINT8         config_unknown;
153163   UINT8         config_register[IDE_CONFIG_REGISTERS];
154164   UINT8         config_register_num;
155165
156   chd_file       *handle;
157   hard_disk_file *disk;
158   bool         is_image_device;
159166   emu_timer *      last_status_timer;
160167   emu_timer *      reset_timer;
161168
r13992r13993
166173
167174   UINT8         gnetreadlock;
168175   ide_hardware *   hardware;
176   
177   UINT8         cur_drive;
178   ide_device      drive[2];
169179};
170180
171181
r13992r13993
176186
177187static TIMER_CALLBACK( reset_callback );
178188
179static void ide_build_features(ide_state *ide);
189static void ide_build_features(ide_state *ide, int drive);
180190
181191static void continue_read(ide_state *ide);
182192static void read_sector_done(ide_state *ide);
r13992r13993
275285    INITIALIZATION AND RESET
276286***************************************************************************/
277287
278UINT8 *ide_get_features(device_t *device)
288UINT8 *ide_get_features(device_t *device, int drive)
279289{
280290   ide_state *ide = get_safe_token(device);
281   return ide->features;
291   return ide->drive[drive].features;
282292}
283293
284294void ide_set_gnet_readlock(device_t *device, const UINT8 onoff)
r13992r13993
373383INLINE UINT32 lba_address(ide_state *ide)
374384{
375385   /* LBA direct? */
376   if (ide->cur_head_reg & 0x40)
377      return ide->cur_sector + ide->cur_cylinder * 256 + ide->cur_head * 16777216;
386   if (ide->drive[ide->cur_drive].cur_head_reg & 0x40)
387      return ide->drive[ide->cur_drive].cur_sector + ide->drive[ide->cur_drive].cur_cylinder * 256 + ide->drive[ide->cur_drive].cur_head * 16777216;
378388
379389   /* standard CHS */
380390   else
381      return (ide->cur_cylinder * ide->num_heads + ide->cur_head) * ide->num_sectors + ide->cur_sector - 1;
391      return (ide->drive[ide->cur_drive].cur_cylinder * ide->drive[ide->cur_drive].num_heads + ide->drive[ide->cur_drive].cur_head) * ide->drive[ide->cur_drive].num_sectors + ide->drive[ide->cur_drive].cur_sector - 1;
382392}
383393
384394
r13992r13993
392402INLINE void next_sector(ide_state *ide)
393403{
394404   /* LBA direct? */
395   if (ide->cur_head_reg & 0x40)
405   if (ide->drive[ide->cur_drive].cur_head_reg & 0x40)
396406   {
397      ide->cur_sector++;
398      if (ide->cur_sector == 0)
407      ide->drive[ide->cur_drive].cur_sector++;
408      if (ide->drive[ide->cur_drive].cur_sector == 0)
399409      {
400         ide->cur_cylinder++;
401         if (ide->cur_cylinder == 0)
402            ide->cur_head++;
410         ide->drive[ide->cur_drive].cur_cylinder++;
411         if (ide->drive[ide->cur_drive].cur_cylinder == 0)
412            ide->drive[ide->cur_drive].cur_head++;
403413      }
404414   }
405415
r13992r13993
407417   else
408418   {
409419      /* sectors are 1-based */
410      ide->cur_sector++;
411      if (ide->cur_sector > ide->num_sectors)
420      ide->drive[ide->cur_drive].cur_sector++;
421      if (ide->drive[ide->cur_drive].cur_sector > ide->drive[ide->cur_drive].num_sectors)
412422      {
413423         /* heads are 0 based */
414         ide->cur_sector = 1;
415         ide->cur_head++;
416         if (ide->cur_head >= ide->num_heads)
424         ide->drive[ide->cur_drive].cur_sector = 1;
425         ide->drive[ide->cur_drive].cur_head++;
426         if (ide->drive[ide->cur_drive].cur_head >= ide->drive[ide->cur_drive].num_heads)
417427         {
418            ide->cur_head = 0;
419            ide->cur_cylinder++;
428            ide->drive[ide->cur_drive].cur_head = 0;
429            ide->drive[ide->cur_drive].cur_cylinder++;
420430         }
421431      }
422432   }
423433
424   ide->cur_lba = lba_address(ide);
434   ide->drive[ide->cur_drive].cur_lba = lba_address(ide);
425435}
426436
427437
r13992r13993
445455}
446456
447457
448static void ide_generate_features(ide_state *ide)
458static void ide_generate_features(ide_state *ide,int drive)
449459{
450   int total_sectors = ide->num_cylinders * ide->num_heads * ide->num_sectors;
451   int sectors_per_track = ide->num_heads * ide->num_sectors;
460   int total_sectors = ide->drive[drive].num_cylinders * ide->drive[drive].num_heads * ide->drive[drive].num_sectors;
461   int sectors_per_track = ide->drive[drive].num_heads * ide->drive[drive].num_sectors;
452462
453463   /* basic geometry */
454   ide->features[ 0*2+0] = 0x5a;                  /*  0: configuration bits */
455   ide->features[ 0*2+1] = 0x04;
456   ide->features[ 1*2+0] = ide->num_cylinders & 0xff;   /*  1: logical cylinders */
457   ide->features[ 1*2+1] = ide->num_cylinders >> 8;
458   ide->features[ 2*2+0] = 0;                     /*  2: reserved */
459   ide->features[ 2*2+1] = 0;
460   ide->features[ 3*2+0] = ide->num_heads & 0xff;      /*  3: logical heads */
461   ide->features[ 3*2+1] = 0;/*ide->num_heads >> 8;*/
462   ide->features[ 4*2+0] = 0;                     /*  4: vendor specific (obsolete) */
463   ide->features[ 4*2+1] = 0;
464   ide->features[ 5*2+0] = 0;                     /*  5: vendor specific (obsolete) */
465   ide->features[ 5*2+1] = 0;
466   ide->features[ 6*2+0] = ide->num_sectors & 0xff;   /*  6: logical sectors per logical track */
467   ide->features[ 6*2+1] = 0;/*ide->num_sectors >> 8;*/
468   ide->features[ 7*2+0] = 0;                     /*  7: vendor-specific */
469   ide->features[ 7*2+1] = 0;
470   ide->features[ 8*2+0] = 0;                     /*  8: vendor-specific */
471   ide->features[ 8*2+1] = 0;
472   ide->features[ 9*2+0] = 0;                     /*  9: vendor-specific */
473   ide->features[ 9*2+1] = 0;
474   swap_strncpy(&ide->features[10*2+0],            /* 10-19: serial number */
464   ide->drive[drive].features[ 0*2+0] = 0x5a;                  /*  0: configuration bits */
465   ide->drive[drive].features[ 0*2+1] = 0x04;
466   ide->drive[drive].features[ 1*2+0] = ide->drive[drive].num_cylinders & 0xff;   /*  1: logical cylinders */
467   ide->drive[drive].features[ 1*2+1] = ide->drive[drive].num_cylinders >> 8;
468   ide->drive[drive].features[ 2*2+0] = 0;                     /*  2: reserved */
469   ide->drive[drive].features[ 2*2+1] = 0;
470   ide->drive[drive].features[ 3*2+0] = ide->drive[drive].num_heads & 0xff;      /*  3: logical heads */
471   ide->drive[drive].features[ 3*2+1] = 0;/*ide->num_heads >> 8;*/
472   ide->drive[drive].features[ 4*2+0] = 0;                     /*  4: vendor specific (obsolete) */
473   ide->drive[drive].features[ 4*2+1] = 0;
474   ide->drive[drive].features[ 5*2+0] = 0;                     /*  5: vendor specific (obsolete) */
475   ide->drive[drive].features[ 5*2+1] = 0;
476   ide->drive[drive].features[ 6*2+0] = ide->drive[drive].num_sectors & 0xff;   /*  6: logical sectors per logical track */
477   ide->drive[drive].features[ 6*2+1] = 0;/*ide->num_sectors >> 8;*/
478   ide->drive[drive].features[ 7*2+0] = 0;                     /*  7: vendor-specific */
479   ide->drive[drive].features[ 7*2+1] = 0;
480   ide->drive[drive].features[ 8*2+0] = 0;                     /*  8: vendor-specific */
481   ide->drive[drive].features[ 8*2+1] = 0;
482   ide->drive[drive].features[ 9*2+0] = 0;                     /*  9: vendor-specific */
483   ide->drive[drive].features[ 9*2+1] = 0;
484   swap_strncpy(&ide->drive[drive].features[10*2+0],            /* 10-19: serial number */
475485         "00000000000000000000", 10);
476   ide->features[20*2+0] = 0;                     /* 20: vendor-specific */
477   ide->features[20*2+1] = 0;
478   ide->features[21*2+0] = 0;                     /* 21: vendor-specific */
479   ide->features[21*2+1] = 0;
480   ide->features[22*2+0] = 4;                     /* 22: # of vendor-specific bytes on read/write long commands */
481   ide->features[22*2+1] = 0;
482   swap_strncpy(&ide->features[23*2+0],            /* 23-26: firmware revision */
486   ide->drive[drive].features[20*2+0] = 0;                     /* 20: vendor-specific */
487   ide->drive[drive].features[20*2+1] = 0;
488   ide->drive[drive].features[21*2+0] = 0;                     /* 21: vendor-specific */
489   ide->drive[drive].features[21*2+1] = 0;
490   ide->drive[drive].features[22*2+0] = 4;                     /* 22: # of vendor-specific bytes on read/write long commands */
491   ide->drive[drive].features[22*2+1] = 0;
492   swap_strncpy(&ide->drive[drive].features[23*2+0],            /* 23-26: firmware revision */
483493         "1.0", 4);
484   swap_strncpy(&ide->features[27*2+0],            /* 27-46: model number */
494   swap_strncpy(&ide->drive[drive].features[27*2+0],            /* 27-46: model number */
485495         "MAME Compressed Hard Disk", 20);
486   ide->features[47*2+0] = 0x01;                  /* 47: read/write multiple support */
487   ide->features[47*2+1] = 0x80;
488   ide->features[48*2+0] = 0;                     /* 48: reserved */
489   ide->features[48*2+1] = 0;
490   ide->features[49*2+0] = 0x03;                  /* 49: capabilities */
491   ide->features[49*2+1] = 0x0f;
492   ide->features[50*2+0] = 0;                     /* 50: reserved */
493   ide->features[50*2+1] = 0;
494   ide->features[51*2+0] = 2;                     /* 51: PIO data transfer cycle timing mode */
495   ide->features[51*2+1] = 0;
496   ide->features[52*2+0] = 2;                     /* 52: single word DMA transfer cycle timing mode */
497   ide->features[52*2+1] = 0;
498   ide->features[53*2+0] = 3;                     /* 53: field validity */
499   ide->features[53*2+1] = 0;
500   ide->features[54*2+0] = ide->num_cylinders & 0xff;   /* 54: number of current logical cylinders */
501   ide->features[54*2+1] = ide->num_cylinders >> 8;
502   ide->features[55*2+0] = ide->num_heads & 0xff;      /* 55: number of current logical heads */
503   ide->features[55*2+1] = 0;/*ide->num_heads >> 8;*/
504   ide->features[56*2+0] = ide->num_sectors & 0xff;   /* 56: number of current logical sectors per track */
505   ide->features[56*2+1] = 0;/*ide->num_sectors >> 8;*/
506   ide->features[57*2+0] = sectors_per_track & 0xff;   /* 57-58: number of current logical sectors per track */
507   ide->features[57*2+1] = sectors_per_track >> 8;
508   ide->features[58*2+0] = sectors_per_track >> 16;
509   ide->features[58*2+1] = sectors_per_track >> 24;
510   ide->features[59*2+0] = 0;                     /* 59: multiple sector timing */
511   ide->features[59*2+1] = 0;
512   ide->features[60*2+0] = total_sectors & 0xff;      /* 60-61: total user addressable sectors */
513   ide->features[60*2+1] = total_sectors >> 8;
514   ide->features[61*2+0] = total_sectors >> 16;
515   ide->features[61*2+1] = total_sectors >> 24;
516   ide->features[62*2+0] = 0x07;                  /* 62: single word dma transfer */
517   ide->features[62*2+1] = 0x00;
518   ide->features[63*2+0] = 0x07;                  /* 63: multiword DMA transfer */
519   ide->features[63*2+1] = 0x04;
520   ide->features[64*2+0] = 0x03;                  /* 64: flow control PIO transfer modes supported */
521   ide->features[64*2+1] = 0x00;
522   ide->features[65*2+0] = 0x78;                  /* 65: minimum multiword DMA transfer cycle time per word */
523   ide->features[65*2+1] = 0x00;
524   ide->features[66*2+0] = 0x78;                  /* 66: mfr's recommended multiword DMA transfer cycle time */
525   ide->features[66*2+1] = 0x00;
526   ide->features[67*2+0] = 0x4d;                  /* 67: minimum PIO transfer cycle time without flow control */
527   ide->features[67*2+1] = 0x01;
528   ide->features[68*2+0] = 0x78;                  /* 68: minimum PIO transfer cycle time with IORDY */
529   ide->features[68*2+1] = 0x00;
530   ide->features[69*2+0] = 0x00;                  /* 69-70: reserved */
531   ide->features[69*2+1] = 0x00;
532   ide->features[71*2+0] = 0x00;                  /* 71: reserved for IDENTIFY PACKET command */
533   ide->features[71*2+1] = 0x00;
534   ide->features[72*2+0] = 0x00;                  /* 72: reserved for IDENTIFY PACKET command */
535   ide->features[72*2+1] = 0x00;
536   ide->features[73*2+0] = 0x00;                  /* 73: reserved for IDENTIFY PACKET command */
537   ide->features[73*2+1] = 0x00;
538   ide->features[74*2+0] = 0x00;                  /* 74: reserved for IDENTIFY PACKET command */
539   ide->features[74*2+1] = 0x00;
540   ide->features[75*2+0] = 0x00;                  /* 75: queue depth */
541   ide->features[75*2+1] = 0x00;
542   ide->features[76*2+0] = 0x00;                  /* 76-79: reserved */
543   ide->features[76*2+1] = 0x00;
544   ide->features[80*2+0] = 0x00;                  /* 80: major version number */
545   ide->features[80*2+1] = 0x00;
546   ide->features[81*2+0] = 0x00;                  /* 81: minor version number */
547   ide->features[81*2+1] = 0x00;
548   ide->features[82*2+0] = 0x00;                  /* 82: command set supported */
549   ide->features[82*2+1] = 0x00;
550   ide->features[83*2+0] = 0x00;                  /* 83: command sets supported */
551   ide->features[83*2+1] = 0x00;
552   ide->features[84*2+0] = 0x00;                  /* 84: command set/feature supported extension */
553   ide->features[84*2+1] = 0x00;
554   ide->features[85*2+0] = 0x00;                  /* 85: command set/feature enabled */
555   ide->features[85*2+1] = 0x00;
556   ide->features[86*2+0] = 0x00;                  /* 86: command set/feature enabled */
557   ide->features[86*2+1] = 0x00;
558   ide->features[87*2+0] = 0x00;                  /* 87: command set/feature default */
559   ide->features[87*2+1] = 0x00;
560   ide->features[88*2+0] = 0x00;                  /* 88: additional DMA modes */
561   ide->features[88*2+1] = 0x00;
562   ide->features[89*2+0] = 0x00;                  /* 89: time required for security erase unit completion */
563   ide->features[89*2+1] = 0x00;
564   ide->features[90*2+0] = 0x00;                  /* 90: time required for enhanced security erase unit completion */
565   ide->features[90*2+1] = 0x00;
566   ide->features[91*2+0] = 0x00;                  /* 91: current advanced power management value */
567   ide->features[91*2+1] = 0x00;
568   ide->features[92*2+0] = 0x00;                  /* 92: master password revision code */
569   ide->features[92*2+1] = 0x00;
570   ide->features[93*2+0] = 0x00;                  /* 93: hardware reset result */
571   ide->features[93*2+1] = 0x00;
572   ide->features[94*2+0] = 0x00;                  /* 94: acoustic management values */
573   ide->features[94*2+1] = 0x00;
574   ide->features[95*2+0] = 0x00;                  /* 95-99: reserved */
575   ide->features[95*2+1] = 0x00;
576   ide->features[100*2+0] = total_sectors & 0xff;      /* 100-103: maximum 48-bit LBA */
577   ide->features[100*2+1] = total_sectors >> 8;
578   ide->features[101*2+0] = total_sectors >> 16;
579   ide->features[101*2+1] = total_sectors >> 24;
580   ide->features[102*2+0] = 0x00;
581   ide->features[102*2+1] = 0x00;
582   ide->features[103*2+0] = 0x00;
583   ide->features[103*2+1] = 0x00;
584   ide->features[104*2+0] = 0x00;                  /* 104-126: reserved */
585   ide->features[104*2+1] = 0x00;
586   ide->features[127*2+0] = 0x00;                  /* 127: removable media status notification */
587   ide->features[127*2+1] = 0x00;
588   ide->features[128*2+0] = 0x00;                  /* 128: security status */
589   ide->features[128*2+1] = 0x00;
590   ide->features[129*2+0] = 0x00;                  /* 129-159: vendor specific */
591   ide->features[129*2+1] = 0x00;
592   ide->features[160*2+0] = 0x00;                  /* 160: CFA power mode 1 */
593   ide->features[160*2+1] = 0x00;
594   ide->features[161*2+0] = 0x00;                  /* 161-175: reserved for CompactFlash */
595   ide->features[161*2+1] = 0x00;
596   ide->features[176*2+0] = 0x00;                  /* 176-205: current media serial number */
597   ide->features[176*2+1] = 0x00;
598   ide->features[206*2+0] = 0x00;                  /* 206-254: reserved */
599   ide->features[206*2+1] = 0x00;
600   ide->features[255*2+0] = 0x00;                  /* 255: integrity word */
601   ide->features[255*2+1] = 0x00;
496   ide->drive[drive].features[47*2+0] = 0x01;                  /* 47: read/write multiple support */
497   ide->drive[drive].features[47*2+1] = 0x80;
498   ide->drive[drive].features[48*2+0] = 0;                     /* 48: reserved */
499   ide->drive[drive].features[48*2+1] = 0;
500   ide->drive[drive].features[49*2+0] = 0x03;                  /* 49: capabilities */
501   ide->drive[drive].features[49*2+1] = 0x0f;
502   ide->drive[drive].features[50*2+0] = 0;                     /* 50: reserved */
503   ide->drive[drive].features[50*2+1] = 0;
504   ide->drive[drive].features[51*2+0] = 2;                     /* 51: PIO data transfer cycle timing mode */
505   ide->drive[drive].features[51*2+1] = 0;
506   ide->drive[drive].features[52*2+0] = 2;                     /* 52: single word DMA transfer cycle timing mode */
507   ide->drive[drive].features[52*2+1] = 0;
508   ide->drive[drive].features[53*2+0] = 3;                     /* 53: field validity */
509   ide->drive[drive].features[53*2+1] = 0;
510   ide->drive[drive].features[54*2+0] = ide->drive[drive].num_cylinders & 0xff;   /* 54: number of current logical cylinders */
511   ide->drive[drive].features[54*2+1] = ide->drive[drive].num_cylinders >> 8;
512   ide->drive[drive].features[55*2+0] = ide->drive[drive].num_heads & 0xff;      /* 55: number of current logical heads */
513   ide->drive[drive].features[55*2+1] = 0;/*ide->num_heads >> 8;*/
514   ide->drive[drive].features[56*2+0] = ide->drive[drive].num_sectors & 0xff;   /* 56: number of current logical sectors per track */
515   ide->drive[drive].features[56*2+1] = 0;/*ide->num_sectors >> 8;*/
516   ide->drive[drive].features[57*2+0] = sectors_per_track & 0xff;   /* 57-58: number of current logical sectors per track */
517   ide->drive[drive].features[57*2+1] = sectors_per_track >> 8;
518   ide->drive[drive].features[58*2+0] = sectors_per_track >> 16;
519   ide->drive[drive].features[58*2+1] = sectors_per_track >> 24;
520   ide->drive[drive].features[59*2+0] = 0;                     /* 59: multiple sector timing */
521   ide->drive[drive].features[59*2+1] = 0;
522   ide->drive[drive].features[60*2+0] = total_sectors & 0xff;      /* 60-61: total user addressable sectors */
523   ide->drive[drive].features[60*2+1] = total_sectors >> 8;
524   ide->drive[drive].features[61*2+0] = total_sectors >> 16;
525   ide->drive[drive].features[61*2+1] = total_sectors >> 24;
526   ide->drive[drive].features[62*2+0] = 0x07;                  /* 62: single word dma transfer */
527   ide->drive[drive].features[62*2+1] = 0x00;
528   ide->drive[drive].features[63*2+0] = 0x07;                  /* 63: multiword DMA transfer */
529   ide->drive[drive].features[63*2+1] = 0x04;
530   ide->drive[drive].features[64*2+0] = 0x03;                  /* 64: flow control PIO transfer modes supported */
531   ide->drive[drive].features[64*2+1] = 0x00;
532   ide->drive[drive].features[65*2+0] = 0x78;                  /* 65: minimum multiword DMA transfer cycle time per word */
533   ide->drive[drive].features[65*2+1] = 0x00;
534   ide->drive[drive].features[66*2+0] = 0x78;                  /* 66: mfr's recommended multiword DMA transfer cycle time */
535   ide->drive[drive].features[66*2+1] = 0x00;
536   ide->drive[drive].features[67*2+0] = 0x4d;                  /* 67: minimum PIO transfer cycle time without flow control */
537   ide->drive[drive].features[67*2+1] = 0x01;
538   ide->drive[drive].features[68*2+0] = 0x78;                  /* 68: minimum PIO transfer cycle time with IORDY */
539   ide->drive[drive].features[68*2+1] = 0x00;
540   ide->drive[drive].features[69*2+0] = 0x00;                  /* 69-70: reserved */
541   ide->drive[drive].features[69*2+1] = 0x00;
542   ide->drive[drive].features[71*2+0] = 0x00;                  /* 71: reserved for IDENTIFY PACKET command */
543   ide->drive[drive].features[71*2+1] = 0x00;
544   ide->drive[drive].features[72*2+0] = 0x00;                  /* 72: reserved for IDENTIFY PACKET command */
545   ide->drive[drive].features[72*2+1] = 0x00;
546   ide->drive[drive].features[73*2+0] = 0x00;                  /* 73: reserved for IDENTIFY PACKET command */
547   ide->drive[drive].features[73*2+1] = 0x00;
548   ide->drive[drive].features[74*2+0] = 0x00;                  /* 74: reserved for IDENTIFY PACKET command */
549   ide->drive[drive].features[74*2+1] = 0x00;
550   ide->drive[drive].features[75*2+0] = 0x00;                  /* 75: queue depth */
551   ide->drive[drive].features[75*2+1] = 0x00;
552   ide->drive[drive].features[76*2+0] = 0x00;                  /* 76-79: reserved */
553   ide->drive[drive].features[76*2+1] = 0x00;
554   ide->drive[drive].features[80*2+0] = 0x00;                  /* 80: major version number */
555   ide->drive[drive].features[80*2+1] = 0x00;
556   ide->drive[drive].features[81*2+0] = 0x00;                  /* 81: minor version number */
557   ide->drive[drive].features[81*2+1] = 0x00;
558   ide->drive[drive].features[82*2+0] = 0x00;                  /* 82: command set supported */
559   ide->drive[drive].features[82*2+1] = 0x00;
560   ide->drive[drive].features[83*2+0] = 0x00;                  /* 83: command sets supported */
561   ide->drive[drive].features[83*2+1] = 0x00;
562   ide->drive[drive].features[84*2+0] = 0x00;                  /* 84: command set/feature supported extension */
563   ide->drive[drive].features[84*2+1] = 0x00;
564   ide->drive[drive].features[85*2+0] = 0x00;                  /* 85: command set/feature enabled */
565   ide->drive[drive].features[85*2+1] = 0x00;
566   ide->drive[drive].features[86*2+0] = 0x00;                  /* 86: command set/feature enabled */
567   ide->drive[drive].features[86*2+1] = 0x00;
568   ide->drive[drive].features[87*2+0] = 0x00;                  /* 87: command set/feature default */
569   ide->drive[drive].features[87*2+1] = 0x00;
570   ide->drive[drive].features[88*2+0] = 0x00;                  /* 88: additional DMA modes */
571   ide->drive[drive].features[88*2+1] = 0x00;
572   ide->drive[drive].features[89*2+0] = 0x00;                  /* 89: time required for security erase unit completion */
573   ide->drive[drive].features[89*2+1] = 0x00;
574   ide->drive[drive].features[90*2+0] = 0x00;                  /* 90: time required for enhanced security erase unit completion */
575   ide->drive[drive].features[90*2+1] = 0x00;
576   ide->drive[drive].features[91*2+0] = 0x00;                  /* 91: current advanced power management value */
577   ide->drive[drive].features[91*2+1] = 0x00;
578   ide->drive[drive].features[92*2+0] = 0x00;                  /* 92: master password revision code */
579   ide->drive[drive].features[92*2+1] = 0x00;
580   ide->drive[drive].features[93*2+0] = 0x00;                  /* 93: hardware reset result */
581   ide->drive[drive].features[93*2+1] = 0x00;
582   ide->drive[drive].features[94*2+0] = 0x00;                  /* 94: acoustic management values */
583   ide->drive[drive].features[94*2+1] = 0x00;
584   ide->drive[drive].features[95*2+0] = 0x00;                  /* 95-99: reserved */
585   ide->drive[drive].features[95*2+1] = 0x00;
586   ide->drive[drive].features[100*2+0] = total_sectors & 0xff;      /* 100-103: maximum 48-bit LBA */
587   ide->drive[drive].features[100*2+1] = total_sectors >> 8;
588   ide->drive[drive].features[101*2+0] = total_sectors >> 16;
589   ide->drive[drive].features[101*2+1] = total_sectors >> 24;
590   ide->drive[drive].features[102*2+0] = 0x00;
591   ide->drive[drive].features[102*2+1] = 0x00;
592   ide->drive[drive].features[103*2+0] = 0x00;
593   ide->drive[drive].features[103*2+1] = 0x00;
594   ide->drive[drive].features[104*2+0] = 0x00;                  /* 104-126: reserved */
595   ide->drive[drive].features[104*2+1] = 0x00;
596   ide->drive[drive].features[127*2+0] = 0x00;                  /* 127: removable media status notification */
597   ide->drive[drive].features[127*2+1] = 0x00;
598   ide->drive[drive].features[128*2+0] = 0x00;                  /* 128: security status */
599   ide->drive[drive].features[128*2+1] = 0x00;
600   ide->drive[drive].features[129*2+0] = 0x00;                  /* 129-159: vendor specific */
601   ide->drive[drive].features[129*2+1] = 0x00;
602   ide->drive[drive].features[160*2+0] = 0x00;                  /* 160: CFA power mode 1 */
603   ide->drive[drive].features[160*2+1] = 0x00;
604   ide->drive[drive].features[161*2+0] = 0x00;                  /* 161-175: reserved for CompactFlash */
605   ide->drive[drive].features[161*2+1] = 0x00;
606   ide->drive[drive].features[176*2+0] = 0x00;                  /* 176-205: current media serial number */
607   ide->drive[drive].features[176*2+1] = 0x00;
608   ide->drive[drive].features[206*2+0] = 0x00;                  /* 206-254: reserved */
609   ide->drive[drive].features[206*2+1] = 0x00;
610   ide->drive[drive].features[255*2+0] = 0x00;                  /* 255: integrity word */
611   ide->drive[drive].features[255*2+1] = 0x00;
602612}
603613
604614
605static void ide_build_features(ide_state *ide)
615static void ide_build_features(ide_state *ide, int drive)
606616{
607   memset(ide->features, 0, IDE_DISK_SECTOR_SIZE);
608   if (chd_get_metadata (ide->handle, HARD_DISK_IDENT_METADATA_TAG, 0, ide->features, IDE_DISK_SECTOR_SIZE, 0, 0, 0) != CHDERR_NONE)
609      ide_generate_features (ide);
617   memset(ide->drive[drive].features, 0, IDE_DISK_SECTOR_SIZE);
618   if (chd_get_metadata (ide->drive[drive].handle, HARD_DISK_IDENT_METADATA_TAG, 0, ide->drive[drive].features, IDE_DISK_SECTOR_SIZE, 0, 0, 0) != CHDERR_NONE)
619      ide_generate_features (ide,drive);
610620}
611621
612622/*************************************
r13992r13993
733743      return;
734744   }
735745   /* now do the read */
736   if (ide->disk)
737      count = hard_disk_read(ide->disk, lba, ide->buffer);
746   if (ide->drive[ide->cur_drive].disk)
747      count = hard_disk_read(ide->drive[ide->cur_drive].disk, lba, ide->buffer);
738748   else if (ide->hardware != NULL) {
739749      count = ide->hardware->read_sector(ide->device, lba, ide->buffer);
740750   }
r13992r13993
809819      int new_lba = lba_address(ide);
810820      attotime seek_time;
811821
812      if (new_lba == ide->cur_lba || new_lba == ide->cur_lba + 1)
822      if (new_lba == ide->drive[ide->cur_drive].cur_lba || new_lba == ide->drive[ide->cur_drive].cur_lba + 1)
813823         seek_time = TIME_NO_SEEK_MULTISECTOR;
814824      else
815825         seek_time = TIME_SEEK_MULTISECTOR;
816826
817      ide->cur_lba = new_lba;
827      ide->drive[ide->cur_drive].cur_lba = new_lba;
818828      ide->device->machine().scheduler().timer_set(seek_time, FUNC(read_sector_done_callback), 0, ide);
819829   }
820830   else
r13992r13993
934944   int lba = lba_address(ide), count = 0;
935945
936946   /* now do the write */
937   if (ide->disk)
938      count = hard_disk_write(ide->disk, lba, ide->buffer);
947   if (ide->drive[ide->cur_drive].disk)
948      count = hard_disk_write(ide->drive[ide->cur_drive].disk, lba, ide->buffer);
939949   else if (ide->hardware != NULL) {
940950      count = ide->hardware->write_sector(ide->device, lba, ide->buffer);
941951   }
r13992r13993
10161026
10171027   /* implicitly clear interrupts here */
10181028   clear_interrupt(ide);
1019
10201029   ide->command = command;
10211030   switch (command)
10221031   {
10231032      case IDE_COMMAND_READ_MULTIPLE:
10241033      case IDE_COMMAND_READ_MULTIPLE_ONCE:
10251034         LOGPRINT(("IDE Read multiple: C=%d H=%d S=%d LBA=%d count=%d\n",
1026            ide->cur_cylinder, ide->cur_head, ide->cur_sector, lba_address(ide), ide->sector_count));
1035            ide->drive[ide->cur_drive].cur_cylinder, ide->drive[ide->cur_drive].cur_head, ide->drive[ide->cur_drive].cur_sector, lba_address(ide), ide->sector_count));
10271036
10281037         /* reset the buffer */
10291038         ide->buffer_offset = 0;
r13992r13993
10371046
10381047      case IDE_COMMAND_READ_MULTIPLE_BLOCK:
10391048         LOGPRINT(("IDE Read multiple block: C=%d H=%d S=%d LBA=%d count=%d\n",
1040            ide->cur_cylinder, ide->cur_head, ide->cur_sector, lba_address(ide), ide->sector_count));
1049            ide->drive[ide->cur_drive].cur_cylinder, ide->drive[ide->cur_drive].cur_head, ide->drive[ide->cur_drive].cur_sector, lba_address(ide), ide->sector_count));
10411050
10421051         /* reset the buffer */
10431052         ide->buffer_offset = 0;
r13992r13993
10521061      case IDE_COMMAND_VERIFY_MULTIPLE:
10531062      case IDE_COMMAND_VERIFY_NORETRY:
10541063         LOGPRINT(("IDE Read verify multiple with/without retries: C=%d H=%d S=%d LBA=%d count=%d\n",
1055            ide->cur_cylinder, ide->cur_head, ide->cur_sector, lba_address(ide), ide->sector_count));
1064            ide->drive[ide->cur_drive].cur_cylinder, ide->drive[ide->cur_drive].cur_head, ide->drive[ide->cur_drive].cur_sector, lba_address(ide), ide->sector_count));
10561065
10571066         /* reset the buffer */
10581067         ide->buffer_offset = 0;
r13992r13993
10661075
10671076      case IDE_COMMAND_READ_DMA:
10681077         LOGPRINT(("IDE Read multiple DMA: C=%d H=%d S=%d LBA=%d count=%d\n",
1069            ide->cur_cylinder, ide->cur_head, ide->cur_sector, lba_address(ide), ide->sector_count));
1078            ide->drive[ide->cur_drive].cur_cylinder, ide->drive[ide->cur_drive].cur_head, ide->drive[ide->cur_drive].cur_sector, lba_address(ide), ide->sector_count));
10701079
10711080         /* reset the buffer */
10721081         ide->buffer_offset = 0;
r13992r13993
10811090
10821091      case IDE_COMMAND_WRITE_MULTIPLE:
10831092         LOGPRINT(("IDE Write multiple: C=%d H=%d S=%d LBA=%d count=%d\n",
1084            ide->cur_cylinder, ide->cur_head, ide->cur_sector, lba_address(ide), ide->sector_count));
1093            ide->drive[ide->cur_drive].cur_cylinder, ide->drive[ide->cur_drive].cur_head, ide->drive[ide->cur_drive].cur_sector, lba_address(ide), ide->sector_count));
10851094
10861095         /* reset the buffer */
10871096         ide->buffer_offset = 0;
r13992r13993
10941103
10951104      case IDE_COMMAND_WRITE_MULTIPLE_BLOCK:
10961105         LOGPRINT(("IDE Write multiple block: C=%d H=%d S=%d LBA=%d count=%d\n",
1097            ide->cur_cylinder, ide->cur_head, ide->cur_sector, lba_address(ide), ide->sector_count));
1106            ide->drive[ide->cur_drive].cur_cylinder, ide->drive[ide->cur_drive].cur_head, ide->drive[ide->cur_drive].cur_sector, lba_address(ide), ide->sector_count));
10981107
10991108         /* reset the buffer */
11001109         ide->buffer_offset = 0;
r13992r13993
11071116
11081117      case IDE_COMMAND_WRITE_DMA:
11091118         LOGPRINT(("IDE Write multiple DMA: C=%d H=%d S=%d LBA=%d count=%d\n",
1110            ide->cur_cylinder, ide->cur_head, ide->cur_sector, lba_address(ide), ide->sector_count));
1119            ide->drive[ide->cur_drive].cur_cylinder, ide->drive[ide->cur_drive].cur_head, ide->drive[ide->cur_drive].cur_sector, lba_address(ide), ide->sector_count));
11111120
11121121         /* reset the buffer */
11131122         ide->buffer_offset = 0;
r13992r13993
11431152         ide->sector_count = 1;
11441153
11451154         /* build the features page */
1146         memcpy(ide->buffer, ide->features, sizeof(ide->buffer));
1155         memcpy(ide->buffer, ide->drive[ide->cur_drive].features, sizeof(ide->buffer));
11471156
11481157         /* indicate everything is ready */
11491158         ide->status |= IDE_STATUS_BUFFER_READY;
r13992r13993
11711180      case IDE_COMMAND_RECALIBRATE:
11721181         /* clear the error too */
11731182         ide->error = IDE_ERROR_NONE;
1174
11751183         /* signal an interrupt */
11761184         signal_delayed_interrupt(ide, MINIMUM_COMMAND_TIME, 0);
11771185         break;
r13992r13993
11871195         break;
11881196
11891197      case IDE_COMMAND_SET_CONFIG:
1190         LOGPRINT(("IDE Set configuration (%d heads, %d sectors)\n", ide->cur_head + 1, ide->sector_count));
1198         LOGPRINT(("IDE Set configuration (%d heads, %d sectors)\n", ide->drive[ide->cur_drive].cur_head + 1, ide->sector_count));
11911199         ide->status &= ~IDE_STATUS_ERROR;
11921200         ide->error = IDE_ERROR_NONE;
11931201
1194         ide->num_sectors = ide->sector_count;
1195         ide->num_heads = ide->cur_head + 1;
1202         ide->drive[ide->cur_drive].num_sectors = ide->sector_count;
1203         ide->drive[ide->cur_drive].num_heads = ide->drive[ide->cur_drive].cur_head + 1;
11961204
11971205         /* signal an interrupt */
11981206         signal_delayed_interrupt(ide, MINIMUM_COMMAND_TIME, 0);
r13992r13993
12071215         break;
12081216
12091217      case IDE_COMMAND_SET_FEATURES:
1210         LOGPRINT(("IDE Set features (%02X %02X %02X %02X %02X)\n", ide->precomp_offset, ide->sector_count & 0xff, ide->cur_sector, ide->cur_cylinder & 0xff, ide->cur_cylinder >> 8));
1218         LOGPRINT(("IDE Set features (%02X %02X %02X %02X %02X)\n", ide->precomp_offset, ide->sector_count & 0xff, ide->drive[ide->cur_drive].cur_sector, ide->drive[ide->cur_drive].cur_cylinder & 0xff, ide->drive[ide->cur_drive].cur_cylinder >> 8));
12111219
12121220         /* signal an interrupt */
12131221         signal_delayed_interrupt(ide, MINIMUM_COMMAND_TIME, 0);
r13992r13993
12501258         LOGPRINT(("IDE GNET Unlock 3\n"));
12511259
12521260         /* key check */
1253         chd_get_metadata (ide->handle, HARD_DISK_KEY_METADATA_TAG, 0, key, 5, 0, 0, 0);
1254         if ((ide->precomp_offset == key[0]) && (ide->sector_count == key[1]) && (ide->cur_sector == key[2]) && (ide->cur_cylinder == (((UINT16)key[4]<<8)|key[3])))
1261         chd_get_metadata (ide->drive[ide->cur_drive].handle, HARD_DISK_KEY_METADATA_TAG, 0, key, 5, 0, 0, 0);
1262         if ((ide->precomp_offset == key[0]) && (ide->sector_count == key[1]) && (ide->drive[ide->cur_drive].cur_sector == key[2]) && (ide->drive[ide->cur_drive].cur_cylinder == (((UINT16)key[4]<<8)|key[3])))
12551263         {
12561264            ide->gnetreadlock= 0;
12571265         }
r13992r13993
13051313//  if (BANK(bank, offset) != IDE_BANK0_DATA && BANK(bank, offset) != IDE_BANK0_STATUS_COMMAND && BANK(bank, offset) != IDE_BANK1_STATUS_CONTROL)
13061314      LOG(("%s:IDE read at %d:%X, size=%d\n", device->machine().describe_context(), bank, offset, size));
13071315
1316   if (ide->drive[ide->cur_drive].disk) {
1317      ide->status |= IDE_STATUS_DRIVE_READY;
1318   } else {
1319      ide->status &= ~IDE_STATUS_DRIVE_READY;
1320   }
1321
13081322   switch (BANK(bank, offset))
13091323   {
13101324      /* unknown config register */
r13992r13993
13551369
13561370      /* return the current sector */
13571371      case IDE_BANK0_SECTOR_NUMBER:
1358         return ide->cur_sector;
1372         return ide->drive[ide->cur_drive].cur_sector;
13591373
13601374      /* return the current cylinder LSB */
13611375      case IDE_BANK0_CYLINDER_LSB:
1362         return ide->cur_cylinder & 0xff;
1376         return ide->drive[ide->cur_drive].cur_cylinder & 0xff;
13631377
13641378      /* return the current cylinder MSB */
13651379      case IDE_BANK0_CYLINDER_MSB:
1366         return ide->cur_cylinder >> 8;
1380         return ide->drive[ide->cur_drive].cur_cylinder >> 8;
13671381
13681382      /* return the current head */
13691383      case IDE_BANK0_HEAD_NUMBER:
1370         return ide->cur_head_reg;
1384         return ide->drive[ide->cur_drive].cur_head_reg;
13711385
13721386      /* return the current status and clear any pending interrupts */
13731387      case IDE_BANK0_STATUS_COMMAND:
r13992r13993
14911505               {
14921506                  UINT8 key[5] = { 0, 0, 0, 0, 0 };
14931507                  int i, bad = 0;
1494                  chd_get_metadata (ide->handle, HARD_DISK_KEY_METADATA_TAG, 0, key, 5, 0, 0, 0);
1508                  chd_get_metadata (ide->drive[ide->cur_drive].handle, HARD_DISK_KEY_METADATA_TAG, 0, key, 5, 0, 0, 0);
14951509
14961510                  for (i=0; !bad && i<512; i++)
14971511                     bad = ((i < 2 || i >= 7) && ide->buffer[i]) || ((i >= 2 && i < 7) && ide->buffer[i] != key[i-2]);
r13992r13993
15241538
15251539      /* current sector */
15261540      case IDE_BANK0_SECTOR_NUMBER:
1527         ide->cur_sector = data;
1541         ide->drive[ide->cur_drive].cur_sector = data;
15281542         break;
15291543
15301544      /* current cylinder LSB */
15311545      case IDE_BANK0_CYLINDER_LSB:
1532         ide->cur_cylinder = (ide->cur_cylinder & 0xff00) | (data & 0xff);
1546         ide->drive[ide->cur_drive].cur_cylinder = (ide->drive[ide->cur_drive].cur_cylinder & 0xff00) | (data & 0xff);
15331547         break;
15341548
15351549      /* current cylinder MSB */
15361550      case IDE_BANK0_CYLINDER_MSB:
1537         ide->cur_cylinder = (ide->cur_cylinder & 0x00ff) | ((data & 0xff) << 8);
1551         ide->drive[ide->cur_drive].cur_cylinder = (ide->drive[ide->cur_drive].cur_cylinder & 0x00ff) | ((data & 0xff) << 8);
15381552         break;
15391553
15401554      /* current head */
15411555      case IDE_BANK0_HEAD_NUMBER:
1542         ide->cur_head = data & 0x0f;
1543         ide->cur_head_reg = data;
1544         // drive index = data & 0x10
1556         ide->cur_drive = (data & 0x10) >> 4;
1557         ide->drive[ide->cur_drive].cur_head = data & 0x0f;
1558         ide->drive[ide->cur_drive].cur_head_reg = data;
15451559         // LBA mode = data & 0x40
15461560         break;
15471561
r13992r13993
18581872
18591873   /* set MAME harddisk handle */
18601874   config = (const ide_config *)downcast<const legacy_device_base *>(device)->inline_config();
1861   ide->handle = get_disk_handle(device->machine(), (config->master != NULL) ? config->master : device->tag());
1862   ide->disk = hard_disk_open(ide->handle);
1863   ide->is_image_device = false;
1875   
1876   ide->drive[0].handle = get_disk_handle(device->machine(), (config->master != NULL) ? config->master : device->tag());
1877   ide->drive[0].disk = hard_disk_open(ide->drive[0].handle);
1878   ide->drive[0].is_image_device = false;
1879
1880   if (config->slave) {
1881      ide->drive[1].handle = get_disk_handle(device->machine(), config->slave);
1882      ide->drive[1].disk = hard_disk_open(ide->drive[1].handle);
1883      ide->drive[1].is_image_device = false;
1884   }
1885
18641886   //assert_always(config->slave == NULL, "IDE controller does not yet support slave drives\n");
18651887
18661888   /* find the bus master space */
r13992r13993
18791901   }
18801902
18811903   /* get and copy the geometry */
1882   if (ide->disk != NULL)
1904   if (ide->drive[0].disk != NULL)
18831905   {
1884      hdinfo = hard_disk_get_info(ide->disk);
1906      hdinfo = hard_disk_get_info(ide->drive[0].disk);
18851907      if (hdinfo->sectorbytes == IDE_DISK_SECTOR_SIZE)
18861908      {
1887         ide->num_cylinders = hdinfo->cylinders;
1888         ide->num_sectors = hdinfo->sectors;
1889         ide->num_heads = hdinfo->heads;
1890         if (PRINTF_IDE_COMMANDS) mame_printf_debug("CHS: %d %d %d\n", ide->num_cylinders, ide->num_heads, ide->num_sectors);
1909         ide->drive[0].num_cylinders = hdinfo->cylinders;
1910         ide->drive[0].num_sectors = hdinfo->sectors;
1911         ide->drive[0].num_heads = hdinfo->heads;
1912         if (PRINTF_IDE_COMMANDS) mame_printf_debug("CHS: %d %d %d\n", ide->drive[0].num_cylinders, ide->drive[0].num_heads, ide->drive[0].num_sectors);
18911913      }
18921914
18931915      /* build the features page */
1894      ide_build_features(ide);
1895   } else if (config->hardware != NULL) {
1916      ide_build_features(ide,0);
1917   }
1918   if (ide->drive[1].disk != NULL)
1919   {
1920      hdinfo = hard_disk_get_info(ide->drive[1].disk);
1921      if (hdinfo->sectorbytes == IDE_DISK_SECTOR_SIZE)
1922      {
1923         ide->drive[1].num_cylinders = hdinfo->cylinders;
1924         ide->drive[1].num_sectors = hdinfo->sectors;
1925         ide->drive[1].num_heads = hdinfo->heads;
1926         if (PRINTF_IDE_COMMANDS) mame_printf_debug("CHS: %d %d %d\n", ide->drive[1].num_cylinders, ide->drive[1].num_heads, ide->drive[1].num_sectors);
1927      }
1928
1929      /* build the features page */
1930      ide_build_features(ide,1);
1931   }   
1932   if (config->hardware != NULL) {
18961933      ide->hardware = (ide_hardware *)config->hardware;
1897      ide->hardware->get_info(ide->device, ide->features, ide->num_cylinders, ide->num_sectors, ide->num_heads);
1898      ide_generate_features (ide);
1934      ide->hardware->get_info(ide->device, ide->drive[0].features, ide->drive[0].num_cylinders, ide->drive[0].num_sectors, ide->drive[0].num_heads);
1935      ide_generate_features (ide,0);
18991936   }
19001937
19011938   /* create a timer for timing status */
r13992r13993
19111948   device->save_item(NAME(ide->precomp_offset));
19121949
19131950   device->save_item(NAME(ide->buffer));
1914   device->save_item(NAME(ide->features));
1951   //device->save_item(NAME(ide->features));
19151952   device->save_item(NAME(ide->buffer_offset));
19161953   device->save_item(NAME(ide->sector_count));
19171954
r13992r13993
19281965   device->save_item(NAME(ide->bus_master_status));
19291966   device->save_item(NAME(ide->bus_master_descriptor));
19301967
1931   device->save_item(NAME(ide->cur_cylinder));
1932   device->save_item(NAME(ide->cur_sector));
1933   device->save_item(NAME(ide->cur_head));
1934   device->save_item(NAME(ide->cur_head_reg));
1968   //device->save_item(NAME(ide->cur_cylinder));
1969   //device->save_item(NAME(ide->cur_sector));
1970   //device->save_item(NAME(ide->cur_head));
1971   //device->save_item(NAME(ide->cur_head_reg));
19351972
1936   device->save_item(NAME(ide->cur_lba));
1973   //device->save_item(NAME(ide->cur_lba));
19371974
1938   device->save_item(NAME(ide->num_cylinders));
1939   device->save_item(NAME(ide->num_sectors));
1940   device->save_item(NAME(ide->num_heads));
1975   //device->save_item(NAME(ide->num_cylinders));
1976   //device->save_item(NAME(ide->num_sectors));
1977   //device->save_item(NAME(ide->num_heads));
19411978
19421979   device->save_item(NAME(ide->config_unknown));
19431980   device->save_item(NAME(ide->config_register));
r13992r13993
19571994static DEVICE_STOP( ide_controller )
19581995{
19591996   ide_state *ide = get_safe_token(device);
1960   if (!ide->is_image_device) {
1997   if (!ide->drive[0].is_image_device) {
19611998      /* close the hard disk */
1962      if (ide->disk != NULL)
1963         hard_disk_close(ide->disk);
1999      if (ide->drive[0].disk != NULL)
2000         hard_disk_close(ide->drive[0].disk);
19642001   }
2002   if (!ide->drive[1].is_image_device) {
2003      /* close the hard disk */
2004      if (ide->drive[1].disk != NULL)
2005         hard_disk_close(ide->drive[1].disk);
2006   }
19652007}
19662008
19672009
r13992r13993
19742016   ide_state *ide = get_safe_token(device);
19752017   const ide_config *config = (const ide_config *)downcast<const legacy_device_base *>(device)->inline_config();
19762018
2019   ide->cur_drive = 0;
19772020   LOG(("IDE controller reset performed\n"));
1978   astring hardtag;
2021   astring hardtag_master;
2022   astring hardtag_slave;
19792023   if (config->master) {
1980      device->siblingtag(hardtag, config->master);
2024      device->siblingtag(hardtag_master, config->master);
19812025   }
2026   if (config->slave) {
2027      device->siblingtag(hardtag_slave, config->slave);
2028   }
19822029
1983   if (device->machine().device( hardtag.cstr() )) {
1984      if (!ide->disk)
2030   if (device->machine().device( hardtag_master.cstr() )) {
2031      if (!ide->drive[0].disk)
19852032      {
1986         ide->handle = device->machine().device<harddisk_image_device>(hardtag.cstr())->get_chd_file();   // should be config->master
2033         ide->drive[0].handle = device->machine().device<harddisk_image_device>(hardtag_master.cstr())->get_chd_file();   // should be config->master
19872034
1988         if (ide->handle)
2035         if (ide->drive[0].handle)
19892036         {
1990            ide->disk = device->machine().device<harddisk_image_device>(hardtag.cstr())->get_hard_disk_file();   // should be config->master
1991            ide->is_image_device = true;
2037            ide->drive[0].disk = device->machine().device<harddisk_image_device>(hardtag_master.cstr())->get_hard_disk_file();   // should be config->master
2038            ide->drive[0].is_image_device = true;
19922039
1993            if (ide->disk != NULL)
2040            if (ide->drive[0].disk != NULL)
19942041            {
19952042               const hard_disk_info *hdinfo;
19962043
1997               hdinfo = hard_disk_get_info(ide->disk);
2044               hdinfo = hard_disk_get_info(ide->drive[0].disk);
19982045               if (hdinfo->sectorbytes == IDE_DISK_SECTOR_SIZE)
19992046               {
2000                  ide->num_cylinders = hdinfo->cylinders;
2001                  ide->num_sectors = hdinfo->sectors;
2002                  ide->num_heads = hdinfo->heads;
2003                  if (PRINTF_IDE_COMMANDS) printf("CHS: %d %d %d\n", ide->num_cylinders, ide->num_heads, ide->num_sectors);
2047                  ide->drive[0].num_cylinders = hdinfo->cylinders;
2048                  ide->drive[0].num_sectors = hdinfo->sectors;
2049                  ide->drive[0].num_heads = hdinfo->heads;
2050                  if (PRINTF_IDE_COMMANDS) printf("CHS: %d %d %d\n", ide->drive[0].num_cylinders, ide->drive[0].num_heads, ide->drive[0].num_sectors);
20042051               }
20052052
20062053               /* build the features page */
2007               ide_build_features(ide);
2054               ide_build_features(ide,0);
20082055            }
20092056         }
20102057      }
2011   } else if (ide->hardware != NULL) {
2012      ide->hardware->get_info(ide->device, ide->features, ide->num_cylinders, ide->num_sectors, ide->num_heads);
2013      ide_generate_features (ide);
2058   }
2059   if (device->machine().device( hardtag_slave.cstr() )) {
2060      if (!ide->drive[1].disk)
2061      {
2062         ide->drive[1].handle = device->machine().device<harddisk_image_device>(hardtag_slave.cstr())->get_chd_file();   // should be config->master
2063
2064         if (ide->drive[1].handle)
2065         {
2066            ide->drive[1].disk = device->machine().device<harddisk_image_device>(hardtag_slave.cstr())->get_hard_disk_file();   // should be config->master
2067            ide->drive[1].is_image_device = true;
2068
2069            if (ide->drive[1].disk != NULL)
2070            {
2071               const hard_disk_info *hdinfo;
2072
2073               hdinfo = hard_disk_get_info(ide->drive[1].disk);
2074               if (hdinfo->sectorbytes == IDE_DISK_SECTOR_SIZE)
2075               {
2076                  ide->drive[1].num_cylinders = hdinfo->cylinders;
2077                  ide->drive[1].num_sectors = hdinfo->sectors;
2078                  ide->drive[1].num_heads = hdinfo->heads;
2079                  if (PRINTF_IDE_COMMANDS) printf("CHS: %d %d %d\n", ide->drive[1].num_cylinders, ide->drive[1].num_heads, ide->drive[1].num_sectors);
2080               }
2081
2082               /* build the features page */
2083               ide_build_features(ide,1);
2084            }
2085         }
2086      }
2087   }   
2088   if (ide->hardware != NULL) {
2089      ide->hardware->get_info(ide->device, ide->drive[0].features, ide->drive[0].num_cylinders, ide->drive[0].num_sectors, ide->drive[0].num_heads);
2090      ide_generate_features (ide,0);
20142091   }
20152092
20162093   /* reset the drive state */
src/emu/machine/idectrl.h
r13992r13993
6767    FUNCTION PROTOTYPES
6868***************************************************************************/
6969
70UINT8 *ide_get_features(device_t *device);
70UINT8 *ide_get_features(device_t *device, int drive);
7171
7272void ide_set_master_password(device_t *device, const UINT8 *password);
7373void ide_set_user_password(device_t *device, const UINT8 *password);

Previous 15994 Revisions Next


© 1998-2018 The MESS Team